diff options
author | Qu Chen <QuChen88@users.noreply.github.com> | 2022-05-15 04:07:45 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-15 14:07:45 +0300 |
commit | a7d6ca9770933b7d9fec7c137232831f08ba7ccc (patch) | |
tree | 70f037669a416bd307f3284303c8e01940371bba | |
parent | 4b262182d95f286222039ee52fc420eb1f9bb955 (diff) | |
download | redis-a7d6ca9770933b7d9fec7c137232831f08ba7ccc.tar.gz |
Make the check for if script is running or not consistent (#10725)
sometimes it is using `scriptIsRunning()` and other times it is using `server.in_script`.
We should use the `scriptIsRunning()` method consistently throughout the code base.
Removed server.in_script sine it's no longer used / needed.
-rw-r--r-- | src/module.c | 5 | ||||
-rw-r--r-- | src/script.c | 3 | ||||
-rw-r--r-- | src/server.c | 3 | ||||
-rw-r--r-- | src/server.h | 1 |
4 files changed, 4 insertions, 8 deletions
diff --git a/src/module.c b/src/module.c index 125226089..be0b5e965 100644 --- a/src/module.c +++ b/src/module.c @@ -56,6 +56,7 @@ #include "slowlog.h" #include "rdb.h" #include "monotonic.h" +#include "script.h" #include "call_reply.h" #include <dlfcn.h> #include <sys/stat.h> @@ -3485,7 +3486,7 @@ int RM_GetContextFlags(RedisModuleCtx *ctx) { } } - if (server.in_script) + if (scriptIsRunning()) flags |= REDISMODULE_CTX_FLAGS_LUA; if (server.in_exec) @@ -7058,7 +7059,7 @@ void unblockClientFromModule(client *c) { */ 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; - int islua = server.in_script; + int islua = scriptIsRunning(); int ismulti = server.in_exec; c->bpop.module_blocked_handle = zmalloc(sizeof(RedisModuleBlockedClient)); diff --git a/src/script.c b/src/script.c index 8216b47f5..d4325ee05 100644 --- a/src/script.c +++ b/src/script.c @@ -202,8 +202,6 @@ int scriptPrepareForRun(scriptRunCtx *run_ctx, client *engine_client, client *ca script_client->flags |= CLIENT_MULTI; } - server.in_script = 1; - run_ctx->start_time = getMonotonicUs(); run_ctx->snapshot_time = mstime(); @@ -236,7 +234,6 @@ void scriptResetRun(scriptRunCtx *run_ctx) { /* After the script done, remove the MULTI state. */ run_ctx->c->flags &= ~CLIENT_MULTI; - server.in_script = 0; server.script_caller = NULL; if (scriptIsTimedout()) { diff --git a/src/server.c b/src/server.c index 95f32f83f..14019b671 100644 --- a/src/server.c +++ b/src/server.c @@ -2500,7 +2500,6 @@ void initServer(void) { server.pubsub_patterns = dictCreate(&keylistDictType); server.pubsubshard_channels = dictCreate(&keylistDictType); server.cronloops = 0; - server.in_script = 0; server.in_exec = 0; server.busy_module_yield_flags = BUSY_MODULE_YIELD_NONE; server.busy_module_yield_reply = NULL; @@ -3566,7 +3565,7 @@ int processCommand(client *c) { * That is unless lua_timedout, in which case client may run * some commands. */ serverAssert(!server.in_exec); - serverAssert(!server.in_script); + serverAssert(!scriptIsRunning()); } moduleCallCommandFilters(c); diff --git a/src/server.h b/src/server.h index 5209a8ffb..446ba5ab1 100644 --- a/src/server.h +++ b/src/server.h @@ -1476,7 +1476,6 @@ struct redisServer { int sentinel_mode; /* True if this instance is a Sentinel. */ size_t initial_memory_usage; /* Bytes used after initialization. */ int always_show_logo; /* Show logo even for non-stdout logging. */ - int in_script; /* Are we inside EVAL? */ int in_exec; /* Are we inside EXEC? */ int busy_module_yield_flags; /* Are we inside a busy module? (triggered by RM_Yield). see BUSY_MODULE_YIELD_ flags. */ const char *busy_module_yield_reply; /* When non-null, we are inside RM_Yield. */ |