summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSalvatore Sanfilippo <antirez@gmail.com>2020-03-23 11:15:42 +0100
committerGitHub <noreply@github.com>2020-03-23 11:15:42 +0100
commit7c5dc070163adf2455b035441af9d97658af3a90 (patch)
treebceda290a5eba51bdfc08db81787d11f20782736
parentb9e5be5f56d775f1c02fe38e8abb947093d5b413 (diff)
parentf16eaadd4ff4ebebc5661e5570301ab0c31bf1f6 (diff)
downloadredis-7c5dc070163adf2455b035441af9d97658af3a90.tar.gz
Merge pull request #7003 from guybe7/rm_context_flags_handle_null
Allow RM_GetContextFlags to work with ctx==NULL
-rw-r--r--src/module.c30
1 files changed, 16 insertions, 14 deletions
diff --git a/src/module.c b/src/module.c
index 74da6c24d..d6b055f78 100644
--- a/src/module.c
+++ b/src/module.c
@@ -1848,20 +1848,22 @@ int RM_GetContextFlags(RedisModuleCtx *ctx) {
int flags = 0;
/* Client specific flags */
- if (ctx->client) {
- if (ctx->client->flags & CLIENT_LUA)
- flags |= REDISMODULE_CTX_FLAGS_LUA;
- if (ctx->client->flags & CLIENT_MULTI)
- flags |= REDISMODULE_CTX_FLAGS_MULTI;
- /* Module command recieved from MASTER, is replicated. */
- if (ctx->client->flags & CLIENT_MASTER)
- flags |= REDISMODULE_CTX_FLAGS_REPLICATED;
- }
-
- /* For DIRTY flags, we need the blocked client if used */
- client *c = ctx->blocked_client ? ctx->blocked_client->client : ctx->client;
- if (c && (c->flags & (CLIENT_DIRTY_CAS|CLIENT_DIRTY_EXEC))) {
- flags |= REDISMODULE_CTX_FLAGS_MULTI_DIRTY;
+ if (ctx) {
+ if (ctx->client) {
+ if (ctx->client->flags & CLIENT_LUA)
+ flags |= REDISMODULE_CTX_FLAGS_LUA;
+ if (ctx->client->flags & CLIENT_MULTI)
+ flags |= REDISMODULE_CTX_FLAGS_MULTI;
+ /* Module command recieved from MASTER, is replicated. */
+ if (ctx->client->flags & CLIENT_MASTER)
+ flags |= REDISMODULE_CTX_FLAGS_REPLICATED;
+ }
+
+ /* For DIRTY flags, we need the blocked client if used */
+ client *c = ctx->blocked_client ? ctx->blocked_client->client : ctx->client;
+ if (c && (c->flags & (CLIENT_DIRTY_CAS|CLIENT_DIRTY_EXEC))) {
+ flags |= REDISMODULE_CTX_FLAGS_MULTI_DIRTY;
+ }
}
if (server.cluster_enabled)