Skip to content

Commit 9505dd2

Browse files
author
tengfeng
committed
fix repeat argument issue and reduce unnessary loop times for redis-cli.
1 parent 0420c32 commit 9505dd2

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/redis-cli.c

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1174,6 +1174,16 @@ static int cliSendCommand(int argc, char **argv, long repeat) {
11741174
} else if (!strcasecmp(command,"auth") && argc == 2) {
11751175
cliSelect();
11761176
}
1177+
1178+
1179+
/* Issue the command again if we got redirected in cluster mode */
1180+
if (config.cluster_mode && config.cluster_reissue_command) {
1181+
cliConnect(CC_FORCE);
1182+
config.cluster_reissue_command = 0;
1183+
/* for a '-MOVED' or '-ASK' response, we need to issue the command again, so
1184+
* add repeat by 1. */
1185+
repeat++;
1186+
}
11771187
}
11781188
if (config.interval) usleep(config.interval);
11791189
fflush(stdout); /* Make it grep friendly */
@@ -1543,13 +1553,8 @@ static int issueCommandRepeat(int argc, char **argv, long repeat) {
15431553
cliPrintContextError();
15441554
return REDIS_ERR;
15451555
}
1546-
}
1547-
/* Issue the command again if we got redirected in cluster mode */
1548-
if (config.cluster_mode && config.cluster_reissue_command) {
1549-
cliConnect(CC_FORCE);
1550-
} else {
1551-
break;
1552-
}
1556+
} else
1557+
break;
15531558
}
15541559
return REDIS_OK;
15551560
}

0 commit comments

Comments
 (0)