Skip to content

Commit 496bf37

Browse files
committed
Replace connAddr with connAddrPeerName; Wrap logging with verbosity check
Signed-off-by: Zhijun <dszhijun@gmail.com>
1 parent cfcaea2 commit 496bf37

File tree

1 file changed

+24
-20
lines changed

1 file changed

+24
-20
lines changed

src/cluster_legacy.c

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1696,14 +1696,16 @@ void setClusterNodeToInboundClusterLink(clusterNode *node, clusterLink *link) {
16961696
serverAssert(!node->inbound_link);
16971697
node->inbound_link = link;
16981698
link->node = node;
1699-
char ip[NET_IP_STR_LEN];
1700-
int port;
1701-
if (connAddr(link->conn, ip, sizeof(ip), &port, 1) != -1) {
1702-
serverLog(LL_VERBOSE, "Bound cluster node %.40s (%s) to connection of client %s:%d",
1703-
node->name, node->human_nodename, ip, port);
1704-
} else {
1705-
serverLog(LL_WARNING, "Error resolving the inbound connection address of node %.40s (%s)",
1706-
node->name, node->human_nodename);
1699+
if (server.verbosity <= LL_VERBOSE) {
1700+
char ip[NET_IP_STR_LEN];
1701+
int port;
1702+
if (connAddrPeerName(link->conn, ip, sizeof(ip), &port) != -1) {
1703+
serverLog(LL_VERBOSE, "Bound cluster node %.40s (%s) to connection of client %s:%d",
1704+
node->name, node->human_nodename, ip, port);
1705+
} else {
1706+
serverLog(LL_VERBOSE, "Error resolving the inbound connection address of node %.40s (%s)",
1707+
node->name, node->human_nodename);
1708+
}
17071709
}
17081710
}
17091711

@@ -3829,18 +3831,20 @@ int clusterProcessPacket(clusterLink *link) {
38293831
clusterSendPing(link, CLUSTERMSG_TYPE_PONG);
38303832
}
38313833

3832-
char ip[NET_IP_STR_LEN];
3833-
int port;
3834-
if (connAddr(link->conn, ip, sizeof(ip), &port, 1) != -1) {
3835-
serverLog(LL_DEBUG, "%s packet received from: %.40s (%s) from client: %s:%d",
3836-
clusterGetMessageTypeString(type),
3837-
link->node ? link->node->name : "NULL",
3838-
link->node ? link->node->human_nodename : "",
3839-
ip, port);
3840-
} else {
3841-
serverLog(LL_WARNING, "Error resolving the address of packet sender %.40s (%s)",
3842-
link->node ? link->node->name : "NULL",
3843-
link->node ? link->node->human_nodename : "");
3834+
if (server.verbosity <= LL_DEBUG) {
3835+
char ip[NET_IP_STR_LEN];
3836+
int port;
3837+
if (connAddrPeerName(link->conn, ip, sizeof(ip), &port) != -1) {
3838+
serverLog(LL_DEBUG, "%s packet received from: %.40s (%s) from client: %s:%d",
3839+
clusterGetMessageTypeString(type),
3840+
link->node ? link->node->name : "NULL",
3841+
link->node ? link->node->human_nodename : "",
3842+
ip, port);
3843+
} else {
3844+
serverLog(LL_DEBUG, "Error resolving the address of packet sender %.40s (%s)",
3845+
link->node ? link->node->name : "NULL",
3846+
link->node ? link->node->human_nodename : "");
3847+
}
38443848
}
38453849
/* PING, PONG, MEET: process config information. */
38463850
if (type == CLUSTERMSG_TYPE_PING || type == CLUSTERMSG_TYPE_PONG || type == CLUSTERMSG_TYPE_MEET) {

0 commit comments

Comments
 (0)