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
3aab1241
Commit
3aab1241
authored
Dec 07, 2017
by
Dvir Volk
Browse files
Remove the NOTIFY_MODULE flag and simplify the module notification flow if there aren't subscribers
parent
a8e2e99a
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/module.c
View file @
3aab1241
...
...
@@ -3748,8 +3748,6 @@ int RM_SubscribeToKeyspaceEvents(RedisModuleCtx *ctx, int types, RedisModuleNoti
sub
->
notify_callback
=
callback
;
sub
->
active
=
0
;
/* Let the notification system know that modules are interested in notifications */
server
.
notify_keyspace_events
|=
NOTIFY_MODULE
;
listAddNodeTail
(
moduleKeyspaceSubscribers
,
sub
);
return
REDISMODULE_OK
;
...
...
@@ -3759,6 +3757,10 @@ int RM_SubscribeToKeyspaceEvents(RedisModuleCtx *ctx, int types, RedisModuleNoti
* This gets called only if at least one module requested to be notified on
* keyspace notifications */
void
moduleNotifyKeyspaceEvent
(
int
type
,
const
char
*
event
,
robj
*
key
,
int
dbid
)
{
/* Don't do anything if there aren't any subscribers */
if
(
listLength
(
moduleKeyspaceSubscribers
)
==
0
)
return
;
listIter
li
;
listNode
*
ln
;
...
...
@@ -3805,10 +3807,6 @@ void moduleUnsubscribeNotifications(RedisModule *module) {
zfree
(
sub
);
}
}
/* If no subscribers are left - do not call the module norification function */
if
(
listLength
(
moduleKeyspaceSubscribers
)
==
0
)
{
server
.
notify_keyspace_events
&=
~
NOTIFY_MODULE
;
}
}
...
...
src/notify.c
View file @
3aab1241
...
...
@@ -104,8 +104,7 @@ void notifyKeyspaceEvent(int type, char *event, robj *key, int dbid) {
* This bypasses the notifications configuration, but the module engine
* will only call event subscribers if the event type matches the types
* they are interested in. */
if
(
server
.
notify_keyspace_events
&
NOTIFY_MODULE
)
moduleNotifyKeyspaceEvent
(
type
,
event
,
key
,
dbid
);
moduleNotifyKeyspaceEvent
(
type
,
event
,
key
,
dbid
);
/* If notifications for this class of events are off, return ASAP. */
if
(
!
(
server
.
notify_keyspace_events
&
type
))
return
;
...
...
src/server.h
View file @
3aab1241
...
...
@@ -429,7 +429,6 @@ typedef long long mstime_t; /* millisecond time type. */
#define NOTIFY_EXPIRED (1<<8)
/* x */
#define NOTIFY_EVICTED (1<<9)
/* e */
#define NOTIFY_STREAM (1<<10)
/* t */
#define NOTIFY_MODULE (1<<11)
/* modules are interested in notifications */
#define NOTIFY_ALL (NOTIFY_GENERIC | NOTIFY_STRING | NOTIFY_LIST | NOTIFY_SET | NOTIFY_HASH | NOTIFY_ZSET | NOTIFY_EXPIRED | NOTIFY_EVICTED | NOTIFY_STREAM)
/* A flag */
/* Get the first bind addr or NULL */
...
...
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