Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

List connected slaves with ip,port,state information in INFO, as requ…

…ested by github issue #219
  • Loading branch information...
commit 8b102e041aeb93b0268d5f33ac043830460ccdfc 1 parent 273f410
@antirez antirez authored
Showing with 33 additions and 0 deletions.
  1. +33 −0 src/redis.c
View
33 src/redis.c
@@ -1349,6 +1349,39 @@ sds genRedisInfoString(void) {
bioPendingJobsOfType(REDIS_BIO_AOF_FSYNC));
}
+ /* List connected slaves */
+ if (listLength(server.slaves)) {
+ int slaveid = 0;
+ listNode *ln;
+ listIter li;
+
+ listRewind(server.slaves,&li);
+ while((ln = listNext(&li))) {
+ redisClient *slave = listNodeValue(ln);
+ char *state = NULL;
+ char ip[32];
+ int port;
+
+ if (anetPeerToString(slave->fd,ip,&port) == -1) continue;
+ switch(slave->replstate) {
+ case REDIS_REPL_WAIT_BGSAVE_START:
+ case REDIS_REPL_WAIT_BGSAVE_END:
+ state = "wait_bgsave";
+ break;
+ case REDIS_REPL_SEND_BULK:
+ state = "send_bulk";
+ break;
+ case REDIS_REPL_ONLINE:
+ state = "online";
+ break;
+ }
+ if (state == NULL) continue;
+ info = sdscatprintf(info,"slave%d:%s,%d,%s\r\n",
+ slaveid,ip,port,state);
+ slaveid++;
+ }
+ }
+
if (server.masterhost) {
info = sdscatprintf(info,
"master_host:%s\r\n"
Please sign in to comment.
Something went wrong with that request. Please try again.