Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
7cdf272d
Commit
7cdf272d
authored
Sep 18, 2018
by
antirez
Browse files
Modules: rename the reused static client to something more general.
parent
9df1f73e
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/module.c
View file @
7cdf272d
...
...
@@ -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 = module
KeyspaceSubscribers
Client;
ctx.client = module
FreeContextReused
Client;
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 = module
KeyspaceSubscribers
Client;
ctx.client = module
FreeContextReused
Client;
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 = module
KeyspaceSubscribers
Client;
ctx.client = module
FreeContextReused
Client;
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();
module
KeyspaceSubscribers
Client = createClient(-1);
module
KeyspaceSubscribers
Client->flags |= CLIENT_MODULE;
module
FreeContextReused
Client = createClient(-1);
module
FreeContextReused
Client->flags |= CLIENT_MODULE;
moduleRegisterCoreAPI();
if (pipe(server.module_blocked_pipe) == -1) {
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment