Commit 283d6cfd authored by Jim Brunner's avatar Jim Brunner
Browse files

Addition of OnUnload function

parent e5acc5ef
......@@ -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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment