From 555adf7290dba9516a9c2b8b4fabcaa10b85f498 Mon Sep 17 00:00:00 2001 From: antirez Date: Wed, 3 Jun 2020 17:00:52 +0200 Subject: TCC: run threaded commands synchronously if called by Lua/MULTI. --- src/module.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/module.c b/src/module.c index 547d2591d..b313094e3 100644 --- a/src/module.c +++ b/src/module.c @@ -4378,7 +4378,7 @@ RedisModuleBlockedClient *moduleBlockClient(RedisModuleCtx *ctx, RedisModuleCmdF bc->unblocked = 0; c->bpop.timeout = timeout; - if (islua || ismulti) { + if (ctx->module != coremodule && (islua || ismulti)) { c->bpop.module_blocked_handle = NULL; addReplyError(c, islua ? "Blocking module command called from Lua script" : @@ -7303,8 +7303,11 @@ void executeThreadedCommand(client *c, coreThreadedCommandCallback callback, voi sdslen(c->argv[j]->ptr)); /* Try to spawn the thread that will actually execute the command. */ + int islua = c->flags & CLIENT_LUA; + int ismulti = c->flags & CLIENT_MULTI; pthread_t tid; - if (CoreModuleBlockedClients >= CoreModuleThreadsMax || + if (islua || ismulti || + CoreModuleBlockedClients >= CoreModuleThreadsMax || pthread_create(&tid,NULL,threadedCoreCommandEnty,tcpd) != 0) { RM_AbortBlock(bc); -- cgit v1.2.1