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
283d6cfd
Commit
283d6cfd
authored
Mar 13, 2019
by
Jim Brunner
Browse files
Addition of OnUnload function
parent
e5acc5ef
Changes
1
Show whitespace changes
Inline
Side-by-side
src/module.c
View file @
283d6cfd
...
@@ -4800,6 +4800,23 @@ int moduleUnload(sds name) {
...
@@ -4800,6 +4800,23 @@ int moduleUnload(sds name) {
return
REDISMODULE_ERR
;
return
REDISMODULE_ERR
;
}
}
/* Give module a chance to clean up. */
int
(
*
onunload
)(
void
*
);
onunload
=
(
int
(
*
)(
void
*
))(
unsigned
long
)
dlsym
(
module
->
handle
,
"RedisModule_OnUnload"
);
if
(
onunload
)
{
RedisModuleCtx
ctx
=
REDISMODULE_CTX_INIT
;
ctx
.
module
=
module
;
ctx
.
client
=
moduleFreeContextReusedClient
;
int
unload_status
=
onunload
((
void
*
)
&
ctx
);
moduleFreeContext
(
&
ctx
);
if
(
unload_status
==
REDISMODULE_ERR
)
{
serverLog
(
LL_WARNING
,
"Module %s OnUnload failed. Unload canceled."
,
name
);
errno
=
ECANCELED
;
return
REDISMODULE_ERR
;
}
}
moduleUnregisterCommands
(
module
);
moduleUnregisterCommands
(
module
);
/* Remove any notification subscribers this module might have */
/* Remove any notification subscribers this module might have */
...
...
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