MCPcopy Create free account
hub / github.com/F-Stack/f-stack / replicationGetSlaveName

Function replicationGetSlaveName

app/redis-6.2.6/src/replication.c:59–78  ·  view source on GitHub ↗

Return the pointer to a string representing the slave ip:listening_port * pair. Mostly useful for logging, since we want to log a slave using its * IP address and its listening port which is more clear for the user, for * example: "Closing connection with replica 10.1.2.3:6380". */

Source from the content-addressed store, hash-verified

57 * IP address and its listening port which is more clear for the user, for
58 * example: "Closing connection with replica 10.1.2.3:6380". */
59char *replicationGetSlaveName(client *c) {
60 static char buf[NET_HOST_PORT_STR_LEN];
61 char ip[NET_IP_STR_LEN];
62
63 ip[0] = '\0';
64 buf[0] = '\0';
65 if (c->slave_addr ||
66 connPeerToString(c->conn,ip,sizeof(ip),NULL) != -1)
67 {
68 char *addr = c->slave_addr ? c->slave_addr : ip;
69 if (c->slave_listening_port)
70 anetFormatAddr(buf,sizeof(buf),addr,c->slave_listening_port);
71 else
72 snprintf(buf,sizeof(buf),"%s:<unknown-replica-port>",addr);
73 } else {
74 snprintf(buf,sizeof(buf),"client id #%llu",
75 (unsigned long long) c->id);
76 }
77 return buf;
78}
79
80/* Plain unlink() can block for quite some time in order to actually apply
81 * the file deletion to the filesystem. This call removes the file in a

Callers 6

syncCommandFunction · 0.85
putSlaveOnlineFunction · 0.85
replicationCronFunction · 0.85
freeClientFunction · 0.85

Calls 3

connPeerToStringFunction · 0.85
anetFormatAddrFunction · 0.85
snprintfFunction · 0.85

Tested by

no test coverage detected