From 423d1909c507f4f7790f2cb87e34eadac8e9719d Mon Sep 17 00:00:00 2001 From: Binbin Date: Tue, 30 Jan 2024 20:32:17 +0800 Subject: [PATCH] Fix timeout not being set in module blockClient case (#13011) This was introduced in #13004, missing this assignment. It causes timeout to be a random value (may be less than now), and then in `Unblock by timer` test, the client is unblocked and then it call timeout_callback, since the callback is NULL, the server will crash. The crash stack is: ``` beforesleep handleBlockedClientsTimeout checkBlockedClientTimeout unblockClientOnTimeout replyToBlockedClientTimedOut moduleBlockedClientTimedOut -- the timeout_callback is NULL, invalidFunctionWasCalled bc->timeout_callback(&ctx,(void**)c->argv,c->argc); ``` (cherry picked from commit 45a35a79c761766d46b3d97169cf62969e2c9ff4) --- src/module.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/module.c b/src/module.c index 7c755c093..1cb418c9b 100644 --- a/src/module.c +++ b/src/module.c @@ -7732,6 +7732,7 @@ RedisModuleBlockedClient *moduleBlockClient(RedisModuleCtx *ctx, RedisModuleCmdF if (keys) { blockForKeys(c,BLOCKED_MODULE,keys,numkeys,timeout,flags&REDISMODULE_BLOCK_UNBLOCK_DELETED); } else { + c->bstate.timeout = timeout; blockClient(c,BLOCKED_MODULE); } }