Skip to content

Commit b6cd3b3

Browse files
committed
asyncCloseClientOnOutputBufferLimitReached(): don't free fake clients.
Fake clients are used in special situations and are not linked to the normal clients list, freeing them will always result in Redis crashing in one way or the other. It's not common to send replies to fake clients, but we have one usage in the modules API. When a client is blocked, we associate to the blocked client object (that is safe to manipulate in a thread), a fake client that accumulates replies. So because of this bug there was the problem described in issue redis#5443. The fix was verified to work with the provided example module. To write a regression is very hard and unlikely to be triggered in the future.
1 parent e16402b commit b6cd3b3

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/networking.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1944,6 +1944,7 @@ int checkClientOutputBufferLimits(client *c) {
19441944
* called from contexts where the client can't be freed safely, i.e. from the
19451945
* lower level functions pushing data inside the client output buffers. */
19461946
void asyncCloseClientOnOutputBufferLimitReached(client *c) {
1947+
if (c->fd == -1) return; /* It is unsafe to free fake clients. */
19471948
serverAssert(c->reply_bytes < SIZE_MAX-(1024*64));
19481949
if (c->reply_bytes == 0 || c->flags & CLIENT_CLOSE_ASAP) return;
19491950
if (checkClientOutputBufferLimits(c)) {

0 commit comments

Comments
 (0)