You need to sign in or sign up before continuing.
Commit 8060de98 authored by antirez's avatar antirez
Browse files

ROLE output improved for slaves.

Info about the replication state with the master added.
parent 41a15205
...@@ -1329,11 +1329,23 @@ void roleCommand(redisClient *c) { ...@@ -1329,11 +1329,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);
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment