From e8efcdee0a96ff9950fa3bd545ceb91af1492bcf Mon Sep 17 00:00:00 2001 From: Yossi Gottlieb Date: Wed, 29 Jul 2020 17:03:38 +0300 Subject: [PATCH] Clarify RM_BlockClient() error condition. (#6093) (cherry picked from commit 7af05f07ff72a4246ddaf986a1e815eadd0cbfef) --- src/module.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/module.c b/src/module.c index 9316e004d..b381b4f99 100644 --- a/src/module.c +++ b/src/module.c @@ -4347,6 +4347,7 @@ void unblockClientFromModule(client *c) { * Even when blocking on keys, RM_UnblockClient() can be called however, but * in that case the privdata argument is disregarded, because we pass the * reply callback the privdata that is set here while blocking. + * */ RedisModuleBlockedClient *moduleBlockClient(RedisModuleCtx *ctx, RedisModuleCmdFunc reply_callback, RedisModuleCmdFunc timeout_callback, void (*free_privdata)(RedisModuleCtx*,void*), long long timeout_ms, RedisModuleString **keys, int numkeys, void *privdata) { client *c = ctx->client; @@ -4439,6 +4440,14 @@ int moduleTryServeClientBlockedOnKey(client *c, robj *key) { * Note: RedisModule_UnblockClient should be called for every blocked client, * even if client was killed, timed-out or disconnected. Failing to do so * will result in memory leaks. + * + * There are some cases where RedisModule_BlockClient() cannot be used: + * + * 1. If the client is a Lua script. + * 2. If the client is executing a MULTI block. + * + * In these cases, a call to RedisModule_BlockClient() will **not** block the + * client, but instead produce a specific error reply. */ RedisModuleBlockedClient *RM_BlockClient(RedisModuleCtx *ctx, RedisModuleCmdFunc reply_callback, RedisModuleCmdFunc timeout_callback, void (*free_privdata)(RedisModuleCtx*,void*), long long timeout_ms) { return moduleBlockClient(ctx,reply_callback,timeout_callback,free_privdata,timeout_ms, NULL,0,NULL);