summaryrefslogtreecommitdiff
path: root/src/redis-cli.c
diff options
context:
space:
mode:
authorBinbin <binloveplay1314@qq.com>2021-12-02 16:41:50 +0800
committerGitHub <noreply@github.com>2021-12-02 10:41:50 +0200
commite3c0ea1cb4ca80c57184a8894586e8fc3c646da1 (patch)
tree2ebf5925c7afb46e612dd1b61f41f068fae981de /src/redis-cli.c
parent0e5b813ef94b373f82bc75efcf3405f2c81af3dc (diff)
downloadredis-e3c0ea1cb4ca80c57184a8894586e8fc3c646da1.tar.gz
Fix a harmless bug when using monitor in redis-cli with wrong reply (#9875)
When we use monitor in redis-cli but encounter an error reply, we will get stuck until we press Ctrl-C to quit. This is a harmless bug. It might be useful if we add parameters to monitor in the future, suck as monitoring only selected db. before: ``` 127.0.0.1:6379> monitor wrong (error) ERR wrong number of arguments for 'monitor' command or subcommand ^C(9.98s) 127.0.0.1:6379> ``` after: ``` 127.0.0.1:6379> monitor wrong (error) ERR wrong number of arguments for 'monitor' command or subcommand 127.0.0.1:6379> ```
Diffstat (limited to 'src/redis-cli.c')
-rw-r--r--src/redis-cli.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/redis-cli.c b/src/redis-cli.c
index 060f3ef66..950e591f1 100644
--- a/src/redis-cli.c
+++ b/src/redis-cli.c
@@ -1347,6 +1347,10 @@ static int cliSendCommand(int argc, char **argv, long repeat) {
do {
if (cliReadReply(output_raw) != REDIS_OK) exit(1);
fflush(stdout);
+
+ /* This happens when the MONITOR command returns an error. */
+ if (config.last_cmd_type == REDIS_REPLY_ERROR)
+ config.monitor_mode = 0;
} while(config.monitor_mode);
zfree(argvlen);
return REDIS_OK;