Unverified Commit a7d6ca97 authored by Qu Chen's avatar Qu Chen Committed by GitHub
Browse files

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.
parent 4b262182
...@@ -56,6 +56,7 @@ ...@@ -56,6 +56,7 @@
#include "slowlog.h" #include "slowlog.h"
#include "rdb.h" #include "rdb.h"
#include "monotonic.h" #include "monotonic.h"
#include "script.h"
#include "call_reply.h" #include "call_reply.h"
#include <dlfcn.h> #include <dlfcn.h>
#include <sys/stat.h> #include <sys/stat.h>
...@@ -3485,7 +3486,7 @@ int RM_GetContextFlags(RedisModuleCtx *ctx) { ...@@ -3485,7 +3486,7 @@ int RM_GetContextFlags(RedisModuleCtx *ctx) {
} }
} }
if (server.in_script) if (scriptIsRunning())
flags |= REDISMODULE_CTX_FLAGS_LUA; flags |= REDISMODULE_CTX_FLAGS_LUA;
if (server.in_exec) if (server.in_exec)
...@@ -7058,7 +7059,7 @@ void unblockClientFromModule(client *c) { ...@@ -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) { 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; client *c = ctx->client;
int islua = server.in_script; int islua = scriptIsRunning();
int ismulti = server.in_exec; int ismulti = server.in_exec;
c->bpop.module_blocked_handle = zmalloc(sizeof(RedisModuleBlockedClient)); c->bpop.module_blocked_handle = zmalloc(sizeof(RedisModuleBlockedClient));
......
...@@ -202,8 +202,6 @@ int scriptPrepareForRun(scriptRunCtx *run_ctx, client *engine_client, client *ca ...@@ -202,8 +202,6 @@ int scriptPrepareForRun(scriptRunCtx *run_ctx, client *engine_client, client *ca
script_client->flags |= CLIENT_MULTI; script_client->flags |= CLIENT_MULTI;
} }
server.in_script = 1;
run_ctx->start_time = getMonotonicUs(); run_ctx->start_time = getMonotonicUs();
run_ctx->snapshot_time = mstime(); run_ctx->snapshot_time = mstime();
...@@ -236,7 +234,6 @@ void scriptResetRun(scriptRunCtx *run_ctx) { ...@@ -236,7 +234,6 @@ void scriptResetRun(scriptRunCtx *run_ctx) {
/* After the script done, remove the MULTI state. */ /* After the script done, remove the MULTI state. */
run_ctx->c->flags &= ~CLIENT_MULTI; run_ctx->c->flags &= ~CLIENT_MULTI;
server.in_script = 0;
server.script_caller = NULL; server.script_caller = NULL;
if (scriptIsTimedout()) { if (scriptIsTimedout()) {
......
...@@ -2500,7 +2500,6 @@ void initServer(void) { ...@@ -2500,7 +2500,6 @@ void initServer(void) {
server.pubsub_patterns = dictCreate(&keylistDictType); server.pubsub_patterns = dictCreate(&keylistDictType);
server.pubsubshard_channels = dictCreate(&keylistDictType); server.pubsubshard_channels = dictCreate(&keylistDictType);
server.cronloops = 0; server.cronloops = 0;
server.in_script = 0;
server.in_exec = 0; server.in_exec = 0;
server.busy_module_yield_flags = BUSY_MODULE_YIELD_NONE; server.busy_module_yield_flags = BUSY_MODULE_YIELD_NONE;
server.busy_module_yield_reply = NULL; server.busy_module_yield_reply = NULL;
...@@ -3566,7 +3565,7 @@ int processCommand(client *c) { ...@@ -3566,7 +3565,7 @@ int processCommand(client *c) {
* That is unless lua_timedout, in which case client may run * That is unless lua_timedout, in which case client may run
* some commands. */ * some commands. */
serverAssert(!server.in_exec); serverAssert(!server.in_exec);
serverAssert(!server.in_script); serverAssert(!scriptIsRunning());
} }
moduleCallCommandFilters(c); moduleCallCommandFilters(c);
......
...@@ -1476,7 +1476,6 @@ struct redisServer { ...@@ -1476,7 +1476,6 @@ struct redisServer {
int sentinel_mode; /* True if this instance is a Sentinel. */ int sentinel_mode; /* True if this instance is a Sentinel. */
size_t initial_memory_usage; /* Bytes used after initialization. */ size_t initial_memory_usage; /* Bytes used after initialization. */
int always_show_logo; /* Show logo even for non-stdout logging. */ 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 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. */ 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. */ const char *busy_module_yield_reply; /* When non-null, we are inside RM_Yield. */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment