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
a13ba750
Commit
a13ba750
authored
Dec 20, 2018
by
antirez
Browse files
Modules shared API: also unregister the module as user.
parent
500e5117
Changes
1
Show whitespace changes
Inline
Side-by-side
src/module.c
View file @
a13ba750
...
@@ -4729,6 +4729,27 @@ int moduleUnregisterSharedAPI(RedisModule *module) {
...
@@ -4729,6 +4729,27 @@ int moduleUnregisterSharedAPI(RedisModule *module) {
return count;
return count;
}
}
/* Remove the specified module as an user of APIs of ever other module.
* This is usually called when a module is unloaded.
*
* Returns the number of modules this module was using APIs from. */
int moduleUnregisterUsedAPI(RedisModule *module) {
listIter li;
listNode *ln;
int count = 0;
listRewind(module->using,&li);
while((ln = listNext(&li))) {
RedisModule *used = ln->value;
listNode *ln = listSearchKey(used->usedby,module);
if (ln) {
listDelNode(module->using,ln);
count++;
}
}
return count;
}
/* --------------------------------------------------------------------------
/* --------------------------------------------------------------------------
* Modules API internals
* Modules API internals
* -------------------------------------------------------------------------- */
* -------------------------------------------------------------------------- */
...
@@ -4873,6 +4894,7 @@ int moduleLoad(const char *path, void **module_argv, int module_argc) {
...
@@ -4873,6 +4894,7 @@ int moduleLoad(const char *path, void **module_argv, int module_argc) {
if (ctx.module) {
if (ctx.module) {
moduleUnregisterCommands(ctx.module);
moduleUnregisterCommands(ctx.module);
moduleUnregisterSharedAPI(ctx.module);
moduleUnregisterSharedAPI(ctx.module);
moduleUnregisterUsedAPI(ctx.module);
moduleFreeModuleStructure(ctx.module);
moduleFreeModuleStructure(ctx.module);
}
}
dlclose(handle);
dlclose(handle);
...
@@ -4912,6 +4934,7 @@ int moduleUnload(sds name) {
...
@@ -4912,6 +4934,7 @@ int moduleUnload(sds name) {
moduleUnregisterCommands(module);
moduleUnregisterCommands(module);
moduleUnregisterSharedAPI(module);
moduleUnregisterSharedAPI(module);
moduleUnregisterUsedAPI(module);
/* Remove any notification subscribers this module might have */
/* Remove any notification subscribers this module might have */
moduleUnsubscribeNotifications(module);
moduleUnsubscribeNotifications(module);
...
...
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