Threaded IO: bugfix client kill may crash redis

This commit is contained in:
zhaozhao.zz 2020-03-15 23:30:25 +08:00 committed by antirez
parent 9cc7038e54
commit 7c07841632

View File

@ -3040,16 +3040,22 @@ int handleClientsWithPendingReadsUsingThreads(void) {
if (tio_debug) printf("I/O READ All threads finshed\n"); if (tio_debug) printf("I/O READ All threads finshed\n");
/* Run the list of clients again to process the new buffers. */ /* Run the list of clients again to process the new buffers. */
listRewind(server.clients_pending_read,&li); while(listLength(server.clients_pending_read)) {
while((ln = listNext(&li))) { ln = listFirst(server.clients_pending_read);
client *c = listNodeValue(ln); client *c = listNodeValue(ln);
c->flags &= ~CLIENT_PENDING_READ; c->flags &= ~CLIENT_PENDING_READ;
listDelNode(server.clients_pending_read,ln);
if (c->flags & CLIENT_PENDING_COMMAND) { if (c->flags & CLIENT_PENDING_COMMAND) {
c->flags &= ~ CLIENT_PENDING_COMMAND; c->flags &= ~CLIENT_PENDING_COMMAND;
processCommandAndResetClient(c); 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); processInputBufferAndReplicate(c);
} }
listEmpty(server.clients_pending_read);
return processed; return processed;
} }