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
d3eb0028
Commit
d3eb0028
authored
Dec 20, 2018
by
antirez
Browse files
Modules shared API: also unregister the module as user.
parent
9403b3d7
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/module.c
View file @
d3eb0028
...
...
@@ -4723,6 +4723,27 @@ int moduleUnregisterSharedAPI(RedisModule *module) {
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
* -------------------------------------------------------------------------- */
...
...
@@ -4867,6 +4888,7 @@ int moduleLoad(const char *path, void **module_argv, int module_argc) {
if
(
ctx
.
module
)
{
moduleUnregisterCommands
(
ctx
.
module
);
moduleUnregisterSharedAPI
(
ctx
.
module
);
moduleUnregisterUsedAPI
(
ctx
.
module
);
moduleFreeModuleStructure
(
ctx
.
module
);
}
dlclose
(
handle
);
...
...
@@ -4906,6 +4928,7 @@ int moduleUnload(sds name) {
moduleUnregisterCommands
(
module
);
moduleUnregisterSharedAPI
(
module
);
moduleUnregisterUsedAPI
(
module
);
/* Remove any notification subscribers this module might have */
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