mirror of
https://github.com/fluencelabs/redis
synced 2025-05-08 17:02:13 +00:00
Addition of OnUnload function
This commit is contained in:
parent
e5acc5ef4f
commit
283d6cfd58
17
src/module.c
17
src/module.c
@ -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 */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user