summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2018-09-18 13:22:05 +0200
committerantirez <antirez@gmail.com>2018-09-18 13:22:05 +0200
commit7cdf272d46ad9b658ef8f5d8485af0eeb17cae6d (patch)
tree9bdc5645e2233afba94c2e5c317bb6e2cfb0f32b
parent9df1f73e4c32b2bfc54471761b64f2b86c5b913b (diff)
downloadredis-7cdf272d46ad9b658ef8f5d8485af0eeb17cae6d.tar.gz
Modules: rename the reused static client to something more general.
-rw-r--r--src/module.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/module.c b/src/module.c
index eed9770b5..9b7365fe2 100644
--- a/src/module.c
+++ b/src/module.c
@@ -241,9 +241,11 @@ typedef struct RedisModuleKeyspaceSubscriber {
/* The module keyspace notification subscribers list */
static list *moduleKeyspaceSubscribers;
-/* Static client recycled for all notification clients, to avoid allocating
- * per round. */
-static client *moduleKeyspaceSubscribersClient;
+/* Static client recycled for when we need to provide a context with a client
+ * in a situation where there is no client to provide. This avoidsallocating
+ * a new client per round. For instance this is used in the keyspace
+ * notifications, timers and cluster messages callbacks. */
+static client *moduleFreeContextReusedClient;
/* --------------------------------------------------------------------------
* Prototypes
@@ -3875,7 +3877,7 @@ void moduleNotifyKeyspaceEvent(int type, const char *event, robj *key, int dbid)
if ((sub->event_mask & type) && sub->active == 0) {
RedisModuleCtx ctx = REDISMODULE_CTX_INIT;
ctx.module = sub->module;
- ctx.client = moduleKeyspaceSubscribersClient;
+ ctx.client = moduleFreeContextReusedClient;
selectDb(ctx.client, dbid);
/* mark the handler as active to avoid reentrant loops.
@@ -3938,7 +3940,7 @@ void moduleCallClusterReceivers(const char *sender_id, uint64_t module_id, uint8
if (r->module_id == module_id) {
RedisModuleCtx ctx = REDISMODULE_CTX_INIT;
ctx.module = r->module;
- ctx.client = moduleKeyspaceSubscribersClient;
+ ctx.client = moduleFreeContextReusedClient;
selectDb(ctx.client, 0);
r->callback(&ctx,sender_id,type,payload,len);
moduleFreeContext(&ctx);
@@ -4184,7 +4186,7 @@ int moduleTimerHandler(struct aeEventLoop *eventLoop, long long id, void *client
RedisModuleCtx ctx = REDISMODULE_CTX_INIT;
ctx.module = timer->module;
- ctx.client = moduleKeyspaceSubscribersClient;
+ ctx.client = moduleFreeContextReusedClient;
selectDb(ctx.client, 0);
timer->callback(&ctx,timer->data);
moduleFreeContext(&ctx);
@@ -4342,8 +4344,8 @@ void moduleInitModulesSystem(void) {
/* Set up the keyspace notification susbscriber list and static client */
moduleKeyspaceSubscribers = listCreate();
- moduleKeyspaceSubscribersClient = createClient(-1);
- moduleKeyspaceSubscribersClient->flags |= CLIENT_MODULE;
+ moduleFreeContextReusedClient = createClient(-1);
+ moduleFreeContextReusedClient->flags |= CLIENT_MODULE;
moduleRegisterCoreAPI();
if (pipe(server.module_blocked_pipe) == -1) {