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
0ff35370
Commit
0ff35370
authored
Sep 18, 2018
by
antirez
Browse files
Modules: rename the reused static client to something more general.
parent
2d11ee95
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/module.c
View file @
0ff35370
...
@@ -241,9 +241,11 @@ typedef struct RedisModuleKeyspaceSubscriber {
...
@@ -241,9 +241,11 @@ typedef struct RedisModuleKeyspaceSubscriber {
/* The module keyspace notification subscribers list */
/* The module keyspace notification subscribers list */
static
list
*
moduleKeyspaceSubscribers
;
static
list
*
moduleKeyspaceSubscribers
;
/* Static client recycled for all notification clients, to avoid allocating
/* Static client recycled for when we need to provide a context with a client
* per round. */
* in a situation where there is no client to provide. This avoidsallocating
static
client
*
moduleKeyspaceSubscribersClient
;
* a new client per round. For instance this is used in the keyspace
* notifications, timers and cluster messages callbacks. */
static
client
*
moduleFreeContextReusedClient
;
/* --------------------------------------------------------------------------
/* --------------------------------------------------------------------------
* Prototypes
* Prototypes
...
@@ -3875,7 +3877,7 @@ void moduleNotifyKeyspaceEvent(int type, const char *event, robj *key, int dbid)
...
@@ -3875,7 +3877,7 @@ void moduleNotifyKeyspaceEvent(int type, const char *event, robj *key, int dbid)
if
((
sub
->
event_mask
&
type
)
&&
sub
->
active
==
0
)
{
if
((
sub
->
event_mask
&
type
)
&&
sub
->
active
==
0
)
{
RedisModuleCtx
ctx
=
REDISMODULE_CTX_INIT
;
RedisModuleCtx
ctx
=
REDISMODULE_CTX_INIT
;
ctx
.
module
=
sub
->
module
;
ctx
.
module
=
sub
->
module
;
ctx
.
client
=
module
KeyspaceSubscribers
Client
;
ctx
.
client
=
module
FreeContextReused
Client
;
selectDb
(
ctx
.
client
,
dbid
);
selectDb
(
ctx
.
client
,
dbid
);
/* mark the handler as active to avoid reentrant loops.
/* mark the handler as active to avoid reentrant loops.
...
@@ -3938,7 +3940,7 @@ void moduleCallClusterReceivers(const char *sender_id, uint64_t module_id, uint8
...
@@ -3938,7 +3940,7 @@ void moduleCallClusterReceivers(const char *sender_id, uint64_t module_id, uint8
if
(
r
->
module_id
==
module_id
)
{
if
(
r
->
module_id
==
module_id
)
{
RedisModuleCtx
ctx
=
REDISMODULE_CTX_INIT
;
RedisModuleCtx
ctx
=
REDISMODULE_CTX_INIT
;
ctx
.
module
=
r
->
module
;
ctx
.
module
=
r
->
module
;
ctx
.
client
=
module
KeyspaceSubscribers
Client
;
ctx
.
client
=
module
FreeContextReused
Client
;
selectDb
(
ctx
.
client
,
0
);
selectDb
(
ctx
.
client
,
0
);
r
->
callback
(
&
ctx
,
sender_id
,
type
,
payload
,
len
);
r
->
callback
(
&
ctx
,
sender_id
,
type
,
payload
,
len
);
moduleFreeContext
(
&
ctx
);
moduleFreeContext
(
&
ctx
);
...
@@ -4184,7 +4186,7 @@ int moduleTimerHandler(struct aeEventLoop *eventLoop, long long id, void *client
...
@@ -4184,7 +4186,7 @@ int moduleTimerHandler(struct aeEventLoop *eventLoop, long long id, void *client
RedisModuleCtx
ctx
=
REDISMODULE_CTX_INIT
;
RedisModuleCtx
ctx
=
REDISMODULE_CTX_INIT
;
ctx
.
module
=
timer
->
module
;
ctx
.
module
=
timer
->
module
;
ctx
.
client
=
module
KeyspaceSubscribers
Client
;
ctx
.
client
=
module
FreeContextReused
Client
;
selectDb
(
ctx
.
client
,
0
);
selectDb
(
ctx
.
client
,
0
);
timer
->
callback
(
&
ctx
,
timer
->
data
);
timer
->
callback
(
&
ctx
,
timer
->
data
);
moduleFreeContext
(
&
ctx
);
moduleFreeContext
(
&
ctx
);
...
@@ -4342,8 +4344,8 @@ void moduleInitModulesSystem(void) {
...
@@ -4342,8 +4344,8 @@ void moduleInitModulesSystem(void) {
/* Set up the keyspace notification susbscriber list and static client */
/* Set up the keyspace notification susbscriber list and static client */
moduleKeyspaceSubscribers
=
listCreate
();
moduleKeyspaceSubscribers
=
listCreate
();
module
KeyspaceSubscribers
Client
=
createClient
(
-
1
);
module
FreeContextReused
Client
=
createClient
(
-
1
);
module
KeyspaceSubscribers
Client
->
flags
|=
CLIENT_MODULE
;
module
FreeContextReused
Client
->
flags
|=
CLIENT_MODULE
;
moduleRegisterCoreAPI
();
moduleRegisterCoreAPI
();
if
(
pipe
(
server
.
module_blocked_pipe
)
==
-
1
)
{
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