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
b8e02f2b
Unverified
Commit
b8e02f2b
authored
Oct 16, 2019
by
Salvatore Sanfilippo
Committed by
GitHub
Oct 16, 2019
Browse files
Merge pull request #5926 from JimB123/unstable
Addition of RedisModule_OnUnload hook
parents
dd29d441
283d6cfd
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/module.c
View file @
b8e02f2b
...
@@ -5698,6 +5698,23 @@ int moduleUnload(sds name) {
...
@@ -5698,6 +5698,23 @@ int moduleUnload(sds name) {
errno
=
EPERM
;
errno
=
EPERM
;
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
);
moduleUnregisterSharedAPI
(
module
);
moduleUnregisterSharedAPI
(
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