diff options
author | Salvatore Sanfilippo <antirez@gmail.com> | 2020-03-16 10:53:54 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-16 10:53:54 +0100 |
commit | 15338ab694a2a57a55690f8a69d7869a7ebcf7da (patch) | |
tree | 47442213cd361195ada60b5503c31ff5a2863957 | |
parent | f1e4af2c29d5520c69fe15e68145fa66bd01bdbd (diff) | |
parent | a6a0e05a1a3573f03d3c42af2ec9aee378bb66b9 (diff) | |
download | redis-15338ab694a2a57a55690f8a69d7869a7ebcf7da.tar.gz |
Merge pull request #6991 from soloestoy/io-threads-bugfix
Threaded IO: bugfix client kill may crash redis
-rw-r--r-- | src/networking.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/networking.c b/src/networking.c index c7dd2f23c..0690bbdf6 100644 --- a/src/networking.c +++ b/src/networking.c @@ -3040,16 +3040,22 @@ int handleClientsWithPendingReadsUsingThreads(void) { if (tio_debug) printf("I/O READ All threads finshed\n"); /* Run the list of clients again to process the new buffers. */ - listRewind(server.clients_pending_read,&li); - while((ln = listNext(&li))) { + while(listLength(server.clients_pending_read)) { + ln = listFirst(server.clients_pending_read); client *c = listNodeValue(ln); c->flags &= ~CLIENT_PENDING_READ; + listDelNode(server.clients_pending_read,ln); + if (c->flags & CLIENT_PENDING_COMMAND) { - c->flags &= ~ CLIENT_PENDING_COMMAND; - processCommandAndResetClient(c); + c->flags &= ~CLIENT_PENDING_COMMAND; + if (processCommandAndResetClient(c) == C_ERR) { + /* If the client is no longer valid, we avoid + * processing the client later. So we just go + * to the next. */ + continue; + } } processInputBufferAndReplicate(c); } - listEmpty(server.clients_pending_read); return processed; } |