Skip to content
This repository

redis-cli: fix prompt after shutdown command #851

Open
wants to merge 1 commit into from

2 participants

Dov Murik moreaki
Dov Murik

Fix redis-cli prompt to state not connected after a SHUTDOWN command is sent.

Original scenario (before fix):

redis 127.0.0.1:6379> KEYS *
1) "aaa"
redis 127.0.0.1:6379> SHUTDOWN
redis 127.0.0.1:6379> KEYS *
redis 127.0.0.1:6379> GET aaa
redis 127.0.0.1:6379> 

Same scenario after redis-cli fix:

redis 127.0.0.1:6379> KEYS *
1) "aaa"
redis 127.0.0.1:6379> SHUTDOWN
not connected> KEYS *
Could not connect to Redis at 127.0.0.1:6379: Connection refused
not connected> GET aaa
Could not connect to Redis at 127.0.0.1:6379: Connection refused
not connected> 
Dov Murik redis-cli: fix prompt after shutdown command
Fix redis-cli prompt to state "not connected" after a SHUTDOWN command
is sent.
39e04e4
moreaki

In my humble opinion a very useful patch and probably the intended invariant of SHUTDOWN on the CLI part. I have just verified it with the newest unstable branch. Do you mind rebasing your patch (I haven't tested if git still applies it, though it should)?

@antirez: I believe this should be merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Dec 26, 2012
Dov Murik redis-cli: fix prompt after shutdown command
Fix redis-cli prompt to state "not connected" after a SHUTDOWN command
is sent.
39e04e4
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 4 additions and 1 deletion. Show diff stats Hide diff stats

  1. +4 1 src/redis-cli.c
5 src/redis-cli.c
@@ -487,8 +487,11 @@ static int cliReadReply(int output_raw_strings) {
487 487 int output = 1;
488 488
489 489 if (redisGetReply(context,&_reply) != REDIS_OK) {
490   - if (config.shutdown)
  490 + if (config.shutdown) {
  491 + redisFree(context);
  492 + context = NULL;
491 493 return REDIS_OK;
  494 + }
492 495 if (config.interactive) {
493 496 /* Filter cases where we should reconnect */
494 497 if (context->err == REDIS_ERR_IO && errno == ECONNRESET)

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.