Remove non semantical spaces from module.c.

This commit is contained in:
antirez 2018-02-15 21:41:03 +01:00
parent 7830f8492f
commit aa57481d8c

View File

@ -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 {
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
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)
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) {
} }
} }
/* -------------------------------------------------------------------------- /* --------------------------------------------------------------------------
* Modules API internals * Modules API internals
* -------------------------------------------------------------------------- */ * -------------------------------------------------------------------------- */
@ -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) {
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);