MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / replicationGetSlaveName

Function replicationGetSlaveName

src/replication.cpp:71–90  ·  view source on GitHub ↗

Return the pointer to a string representing the replica ip:listening_port * pair. Mostly useful for logging, since we want to log a replica 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

69 * IP address and its listening port which is more clear for the user, for
70 * example: "Closing connection with replica 10.1.2.3:6380". */
71char *replicationGetSlaveName(client *c) {
72 static char buf[NET_HOST_PORT_STR_LEN];
73 char ip[NET_IP_STR_LEN];
74
75 ip[0] = '\0';
76 buf[0] = '\0';
77 if (c->slave_addr ||
78 connPeerToString(c->conn,ip,sizeof(ip),NULL) != -1)
79 {
80 char *addr = c->slave_addr ? c->slave_addr : ip;
81 if (c->slave_listening_port)
82 anetFormatAddr(buf,sizeof(buf),addr,c->slave_listening_port);
83 else
84 snprintf(buf,sizeof(buf),"%s:<unknown-replica-port>",addr);
85 } else {
86 snprintf(buf,sizeof(buf),"client id #%llu",
87 (unsigned long long) c->id);
88 }
89 return buf;
90}
91
92static bool FSameUuidNoNil(const unsigned char *a, const unsigned char *b)
93{

Callers 6

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

Calls 2

connPeerToStringFunction · 0.85
anetFormatAddrFunction · 0.85

Tested by

no test coverage detected