Merge pull request #7003 from guybe7/rm_context_flags_handle_null

Allow RM_GetContextFlags to work with ctx==NULL
This commit is contained in:
Salvatore Sanfilippo 2020-03-23 11:15:42 +01:00 committed by GitHub
commit 7c5dc07016
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1848,20 +1848,22 @@ int RM_GetContextFlags(RedisModuleCtx *ctx) {
int flags = 0; int flags = 0;
/* Client specific flags */ /* Client specific flags */
if (ctx->client) { if (ctx) {
if (ctx->client->flags & CLIENT_LUA) if (ctx->client) {
flags |= REDISMODULE_CTX_FLAGS_LUA; if (ctx->client->flags & CLIENT_LUA)
if (ctx->client->flags & CLIENT_MULTI) flags |= REDISMODULE_CTX_FLAGS_LUA;
flags |= REDISMODULE_CTX_FLAGS_MULTI; if (ctx->client->flags & CLIENT_MULTI)
/* Module command recieved from MASTER, is replicated. */ flags |= REDISMODULE_CTX_FLAGS_MULTI;
if (ctx->client->flags & CLIENT_MASTER) /* Module command recieved from MASTER, is replicated. */
flags |= REDISMODULE_CTX_FLAGS_REPLICATED; if (ctx->client->flags & CLIENT_MASTER)
} flags |= REDISMODULE_CTX_FLAGS_REPLICATED;
}
/* For DIRTY flags, we need the blocked client if used */ /* For DIRTY flags, we need the blocked client if used */
client *c = ctx->blocked_client ? ctx->blocked_client->client : ctx->client; client *c = ctx->blocked_client ? ctx->blocked_client->client : ctx->client;
if (c && (c->flags & (CLIENT_DIRTY_CAS|CLIENT_DIRTY_EXEC))) { if (c && (c->flags & (CLIENT_DIRTY_CAS|CLIENT_DIRTY_EXEC))) {
flags |= REDISMODULE_CTX_FLAGS_MULTI_DIRTY; flags |= REDISMODULE_CTX_FLAGS_MULTI_DIRTY;
}
} }
if (server.cluster_enabled) if (server.cluster_enabled)