diff options
author | Meir Shpilraien (Spielrein) <meir@redislabs.com> | 2021-03-29 13:34:16 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-29 13:34:16 +0300 |
commit | 036963a7daa03778ed5a8a0672bb7aa5d7aa74e4 (patch) | |
tree | 1c7393e504f92e82ecce27909d1624cd433e6e6c /src | |
parent | 54fd3d40246e16376c78a0dccd21b92f2292d765 (diff) | |
download | redis-036963a7daa03778ed5a8a0672bb7aa5d7aa74e4.tar.gz |
Restore old client 'processCommandAndResetClient' to fix false dead client indicator (#8715)
'processCommandAndResetClient' returns 1 if client is dead. It does it
by checking if serve.current_client is NULL. On script timeout, Redis will re-enter
'processCommandAndResetClient' and when finish we will set server.current_client
to NULL. This will cause later to falsely return 1 and think that the client that
sent the timed-out script is dead (Redis to stop reading from the client buffer).
Diffstat (limited to 'src')
-rw-r--r-- | src/networking.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/networking.c b/src/networking.c index bd0bcadb2..d554d748b 100644 --- a/src/networking.c +++ b/src/networking.c @@ -1990,12 +1990,20 @@ void commandProcessed(client *c) { * of processing the command, otherwise C_OK is returned. */ int processCommandAndResetClient(client *c) { int deadclient = 0; + client *old_client = server.current_client; server.current_client = c; if (processCommand(c) == C_OK) { commandProcessed(c); } if (server.current_client == NULL) deadclient = 1; - server.current_client = NULL; + /* + * Restore the old client, this is needed because when a script + * times out, we will get into this code from processEventsWhileBlocked. + * Which will cause to set the server.current_client. If not restored + * we will return 1 to our caller which will falsely indicate the client + * is dead and will stop reading from its buffer. + */ + server.current_client = old_client; /* performEvictions may flush slave output buffers. This may * result in a slave, that may be the active client, to be * freed. */ |