From 468860ae18b11486f734c476bc2930de7860abe1 Mon Sep 17 00:00:00 2001 From: swilly22 Date: Mon, 11 Mar 2019 10:02:19 +0200 Subject: [PATCH] Extend REDISMODULE_CTX_FLAGS to indicate if command was sent by master --- src/module.c | 3 +++ src/redismodule.h | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/module.c b/src/module.c index 81982ba76..5ad999751 100644 --- a/src/module.c +++ b/src/module.c @@ -1391,6 +1391,9 @@ int RM_GetContextFlags(RedisModuleCtx *ctx) { 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; } if (server.cluster_enabled) diff --git a/src/redismodule.h b/src/redismodule.h index d18c38881..540f8e3db 100644 --- a/src/redismodule.h +++ b/src/redismodule.h @@ -85,6 +85,9 @@ #define REDISMODULE_CTX_FLAGS_OOM (1<<10) /* Less than 25% of memory available according to maxmemory. */ #define REDISMODULE_CTX_FLAGS_OOM_WARNING (1<<11) +/* The command was sent over the replication link. */ +#define REDISMODULE_CTX_FLAGS_REPLICATED (1<<12) + #define REDISMODULE_NOTIFY_GENERIC (1<<2) /* g */ #define REDISMODULE_NOTIFY_STRING (1<<3) /* $ */