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". */
| 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". */ |
| 71 | char *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 | |
| 92 | static bool FSameUuidNoNil(const unsigned char *a, const unsigned char *b) |
| 93 | { |
no test coverage detected