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". */
| 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". */ |
| 59 | char *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 |
no test coverage detected