mirror of
https://github.com/fluencelabs/redis
synced 2025-03-19 09:00:51 +00:00
Merge pull request #1966 from mattsta/fix-sentinel-info
Sentinel: Improve INFO command behavior
This commit is contained in:
commit
46bd13b806
@ -2856,24 +2856,30 @@ numargserr:
|
|||||||
|
|
||||||
/* SENTINEL INFO [section] */
|
/* SENTINEL INFO [section] */
|
||||||
void sentinelInfoCommand(redisClient *c) {
|
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) {
|
if (c->argc > 2) {
|
||||||
addReply(c,shared.syntaxerr);
|
addReply(c,shared.syntaxerr);
|
||||||
return;
|
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");
|
if (sections++) info = sdscat(info,"\r\n");
|
||||||
sds serversection = genRedisInfoString("server");
|
sds serversection = genRedisInfoString("server");
|
||||||
info = sdscatlen(info,serversection,sdslen(serversection));
|
info = sdscatlen(info,serversection,sdslen(serversection));
|
||||||
sdsfree(serversection);
|
sdsfree(serversection);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strcasecmp(section,"sentinel") || defsections) {
|
if (defsections || allsections || !strcasecmp(section,"sentinel")) {
|
||||||
dictIterator *di;
|
dictIterator *di;
|
||||||
dictEntry *de;
|
dictEntry *de;
|
||||||
int master_id = 0;
|
int master_id = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user