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
283d6cfd
Commit
283d6cfd
authored
Mar 13, 2019
by
Jim Brunner
Browse files
Addition of OnUnload function
parent
e5acc5ef
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/module.c
View file @
283d6cfd
...
...
@@ -4799,6 +4799,23 @@ int moduleUnload(sds name) {
errno
=
EBUSY
;
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
);
...
...
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