1
0
mirror of https://github.com/fluencelabs/redis synced 2025-04-02 07:41:04 +00:00

ROLE output improved for slaves.

Info about the replication state with the master added.
This commit is contained in:
antirez 2014-06-07 17:38:16 +02:00
parent d34c2fa3bb
commit 6a13193d8f

@ -1353,11 +1353,23 @@ void roleCommand(redisClient *c) {
} }
setDeferredMultiBulkLength(c,mbcount,slaves); setDeferredMultiBulkLength(c,mbcount,slaves);
} else { } else {
char *slavestate = NULL;
addReplyMultiBulkLen(c,4); addReplyMultiBulkLen(c,4);
addReplyBulkCBuffer(c,"slave",5); addReplyBulkCBuffer(c,"slave",5);
addReplyBulkCString(c,server.masterhost); addReplyBulkCString(c,server.masterhost);
addReplyLongLong(c,server.masterport); addReplyLongLong(c,server.masterport);
addReplyLongLong(c,server.master->reploff); switch(server.repl_state) {
case REDIS_REPL_NONE: slavestate = "none"; break;
case REDIS_REPL_CONNECT: slavestate = "connect"; break;
case REDIS_REPL_CONNECTING: slavestate = "connecting"; break;
case REDIS_REPL_RECEIVE_PONG: /* see next */
case REDIS_REPL_TRANSFER: slavestate = "sync"; break;
case REDIS_REPL_CONNECTED: slavestate = "connected"; break;
default: slavestate = "unknown"; break;
}
addReplyBulkCString(c,slavestate);
addReplyLongLong(c,server.master ? server.master->reploff : -1);
} }
} }