Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
256ddbf6
Commit
256ddbf6
authored
Feb 15, 2018
by
antirez
Browse files
Remove non semantical spaces from module.c.
parent
280c3e39
Changes
1
Show whitespace changes
Inline
Side-by-side
src/module.c
View file @
256ddbf6
...
@@ -220,7 +220,8 @@ static pthread_mutex_t moduleGIL = PTHREAD_MUTEX_INITIALIZER;
...
@@ -220,7 +220,8 @@ static pthread_mutex_t moduleGIL = PTHREAD_MUTEX_INITIALIZER;
/* Function pointer type for keyspace event notification subscriptions from modules. */
/* Function pointer type for keyspace event notification subscriptions from modules. */
typedef int (*RedisModuleNotificationFunc) (RedisModuleCtx *ctx, int type, const char *event, RedisModuleString *key);
typedef int (*RedisModuleNotificationFunc) (RedisModuleCtx *ctx, int type, const char *event, RedisModuleString *key);
/* Keyspace notification subscriber information. See RM_SubscribeToKeyspaceEvents */
/* Keyspace notification subscriber information.
* See RM_SubscribeToKeyspaceEvents() for more information. */
typedef struct RedisModuleKeyspaceSubscriber {
typedef struct RedisModuleKeyspaceSubscriber {
/* The module subscribed to the event */
/* The module subscribed to the event */
RedisModule *module;
RedisModule *module;
...
@@ -228,14 +229,16 @@ typedef struct RedisModuleKeyspaceSubscriber {
...
@@ -228,14 +229,16 @@ typedef struct RedisModuleKeyspaceSubscriber {
RedisModuleNotificationFunc notify_callback;
RedisModuleNotificationFunc notify_callback;
/* A bit mask of the events the module is interested in */
/* A bit mask of the events the module is interested in */
int event_mask;
int event_mask;
/* Active flag set on entry, to avoid reentrant subscribers calling themselves */
/* Active flag set on entry, to avoid reentrant subscribers
* calling themselves */
int active;
int active;
} RedisModuleKeyspaceSubscriber;
} 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 per round. */
/* Static client recycled for all notification clients, to avoid allocating
* per round. */
static client *moduleKeyspaceSubscribersClient;
static client *moduleKeyspaceSubscribersClient;
/* --------------------------------------------------------------------------
/* --------------------------------------------------------------------------
...
@@ -3754,26 +3757,22 @@ int RM_SubscribeToKeyspaceEvents(RedisModuleCtx *ctx, int types, RedisModuleNoti
...
@@ -3754,26 +3757,22 @@ int RM_SubscribeToKeyspaceEvents(RedisModuleCtx *ctx, int types, RedisModuleNoti
listAddNodeTail(moduleKeyspaceSubscribers, sub);
listAddNodeTail(moduleKeyspaceSubscribers, sub);
return REDISMODULE_OK;
return REDISMODULE_OK;
}
}
/* Dispatcher for keyspace notifications to module subscriber functions.
/* Dispatcher for keyspace notifications to module subscriber functions.
* This gets called only if at least one module requested to be notified on
* This gets called only if at least one module requested to be notified on
* keyspace notifications */
* keyspace notifications */
void moduleNotifyKeyspaceEvent(int type, const char *event, robj *key, int dbid) {
void moduleNotifyKeyspaceEvent(int type, const char *event, robj *key, int dbid) {
/* Don't do anything if there aren't any subscribers */
/* Don't do anything if there aren't any subscribers */
if (listLength(moduleKeyspaceSubscribers) == 0) return;
if (listLength(moduleKeyspaceSubscribers) == 0) return;
listIter li;
listIter li;
listNode *ln;
listNode *ln;
listRewind(moduleKeyspaceSubscribers,&li);
listRewind(moduleKeyspaceSubscribers,&li);
/* Remove irrelevant flags from the type mask */
/* Remove irrelevant flags from the type mask */
type &= ~(NOTIFY_KEYEVENT | NOTIFY_KEYSPACE);
type &= ~(NOTIFY_KEYEVENT | NOTIFY_KEYSPACE);
while((ln = listNext(&li))) {
while((ln = listNext(&li))) {
RedisModuleKeyspaceSubscriber *sub = ln->value;
RedisModuleKeyspaceSubscriber *sub = ln->value;
/* Only notify subscribers on events matching they registration,
/* Only notify subscribers on events matching they registration,
...
@@ -3793,7 +3792,6 @@ void moduleNotifyKeyspaceEvent(int type, const char *event, robj *key, int dbid)
...
@@ -3793,7 +3792,6 @@ void moduleNotifyKeyspaceEvent(int type, const char *event, robj *key, int dbid)
moduleFreeContext(&ctx);
moduleFreeContext(&ctx);
}
}
}
}
}
}
/* Unsubscribe any notification subscirbers this module has upon unloading */
/* Unsubscribe any notification subscirbers this module has upon unloading */
...
@@ -3810,7 +3808,6 @@ void moduleUnsubscribeNotifications(RedisModule *module) {
...
@@ -3810,7 +3808,6 @@ void moduleUnsubscribeNotifications(RedisModule *module) {
}
}
}
}
/* --------------------------------------------------------------------------
/* --------------------------------------------------------------------------
* Modules API internals
* Modules API internals
* -------------------------------------------------------------------------- */
* -------------------------------------------------------------------------- */
...
@@ -3848,7 +3845,6 @@ void moduleRegisterCoreAPI(void);
...
@@ -3848,7 +3845,6 @@ void moduleRegisterCoreAPI(void);
void moduleInitModulesSystem(void) {
void moduleInitModulesSystem(void) {
moduleUnblockedClients = listCreate();
moduleUnblockedClients = listCreate();
server.loadmodule_queue = listCreate();
server.loadmodule_queue = listCreate();
modules = dictCreate(&modulesDictType,NULL);
modules = dictCreate(&modulesDictType,NULL);
...
@@ -3907,7 +3903,6 @@ void moduleFreeModuleStructure(struct RedisModule *module) {
...
@@ -3907,7 +3903,6 @@ void moduleFreeModuleStructure(struct RedisModule *module) {
zfree(module);
zfree(module);
}
}
void moduleUnregisterCommands(struct RedisModule *module) {
void moduleUnregisterCommands(struct RedisModule *module) {
/* Unregister all the commands registered by this module. */
/* Unregister all the commands registered by this module. */
dictIterator *di = dictGetSafeIterator(server.commands);
dictIterator *di = dictGetSafeIterator(server.commands);
...
...
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