From 9505dd2011ef7143670b68247ff1818ffbad9768 Mon Sep 17 00:00:00 2001 From: tengfeng Date: Tue, 10 Jul 2018 20:58:01 +0800 Subject: [PATCH] fix repeat argument issue and reduce unnessary loop times for redis-cli. --- src/redis-cli.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/redis-cli.c b/src/redis-cli.c index 299d4617..9459f8c3 100644 --- a/src/redis-cli.c +++ b/src/redis-cli.c @@ -1174,6 +1174,16 @@ static int cliSendCommand(int argc, char **argv, long repeat) { } else if (!strcasecmp(command,"auth") && argc == 2) { cliSelect(); } + + + /* Issue the command again if we got redirected in cluster mode */ + if (config.cluster_mode && config.cluster_reissue_command) { + cliConnect(CC_FORCE); + config.cluster_reissue_command = 0; + /* for a '-MOVED' or '-ASK' response, we need to issue the command again, so + * add repeat by 1. */ + repeat++; + } } if (config.interval) usleep(config.interval); fflush(stdout); /* Make it grep friendly */ @@ -1543,13 +1553,8 @@ static int issueCommandRepeat(int argc, char **argv, long repeat) { cliPrintContextError(); return REDIS_ERR; } - } - /* Issue the command again if we got redirected in cluster mode */ - if (config.cluster_mode && config.cluster_reissue_command) { - cliConnect(CC_FORCE); - } else { - break; - } + } else + break; } return REDIS_OK; }