mirror of
https://github.com/fluencelabs/redis
synced 2025-04-25 10:32:14 +00:00
Modules shared API: also unregister the module as user.
This commit is contained in:
parent
9403b3d7a3
commit
d3eb0028e9
23
src/module.c
23
src/module.c
@ -4723,6 +4723,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
|
||||||
* -------------------------------------------------------------------------- */
|
* -------------------------------------------------------------------------- */
|
||||||
@ -4867,6 +4888,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);
|
||||||
@ -4906,6 +4928,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);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user