diff options
author | Salvatore Sanfilippo <antirez@gmail.com> | 2015-02-24 17:20:09 +0100 |
---|---|---|
committer | Salvatore Sanfilippo <antirez@gmail.com> | 2015-02-24 17:20:09 +0100 |
commit | 46bd13b8062227b529c851bd2ee7431309fdcfbb (patch) | |
tree | b332a2b8ef8b6798df1a16c4cd4c40bb3253bbf3 | |
parent | 3689a0582bef619a574835044c68c05dd8bd13f7 (diff) | |
parent | 391fc9b6335329e513664c69bdc18865ab944beb (diff) | |
download | redis-46bd13b8062227b529c851bd2ee7431309fdcfbb.tar.gz |
Merge pull request #1966 from mattsta/fix-sentinel-info
Sentinel: Improve INFO command behavior
-rw-r--r-- | src/sentinel.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/src/sentinel.c b/src/sentinel.c index c693a5862..7d174ac28 100644 --- a/src/sentinel.c +++ b/src/sentinel.c @@ -2856,24 +2856,30 @@ numargserr: /* SENTINEL INFO [section] */ void sentinelInfoCommand(redisClient *c) { - char *section = c->argc == 2 ? c->argv[1]->ptr : "default"; - sds info = sdsempty(); - int defsections = !strcasecmp(section,"default"); - int sections = 0; - if (c->argc > 2) { addReply(c,shared.syntaxerr); return; } - if (!strcasecmp(section,"server") || defsections) { + int defsections = 0, allsections = 0; + char *section = c->argc == 2 ? c->argv[1]->ptr : NULL; + if (section) { + allsections = !strcasecmp(section,"all"); + defsections = !strcasecmp(section,"default"); + } else { + defsections = 1; + } + + int sections = 0; + sds info = sdsempty(); + if (defsections || allsections || !strcasecmp(section,"server")) { if (sections++) info = sdscat(info,"\r\n"); sds serversection = genRedisInfoString("server"); info = sdscatlen(info,serversection,sdslen(serversection)); sdsfree(serversection); } - if (!strcasecmp(section,"sentinel") || defsections) { + if (defsections || allsections || !strcasecmp(section,"sentinel")) { dictIterator *di; dictEntry *de; int master_id = 0; |