diff options
author | antirez <antirez@gmail.com> | 2018-12-20 17:31:55 +0100 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2018-12-20 17:57:43 +0100 |
commit | 9403b3d7a39ea80f95ae71f386d6949f52284426 (patch) | |
tree | f8ba89e4af2d626d69911994feb5c94150a67ffa | |
parent | 6bb8cdaebe74f9c79bb754ccd7a7f05fe8385f81 (diff) | |
download | redis-9403b3d7a39ea80f95ae71f386d6949f52284426.tar.gz |
Modules shared API: prevent unloading of used modules.
-rw-r--r-- | src/module.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/module.c b/src/module.c index eafdd81f6..4f0e5b126 100644 --- a/src/module.c +++ b/src/module.c @@ -4896,11 +4896,12 @@ int moduleUnload(sds name) { if (module == NULL) { errno = ENOENT; return REDISMODULE_ERR; - } - - if (listLength(module->types)) { + } else if (listLength(module->types)) { errno = EBUSY; return REDISMODULE_ERR; + } else if (listLength(module->usedby)) { + errno = EPERM; + return REDISMODULE_ERR; } moduleUnregisterCommands(module); @@ -4966,7 +4967,12 @@ NULL errmsg = "no such module with that name"; break; case EBUSY: - errmsg = "the module exports one or more module-side data types, can't unload"; + errmsg = "the module exports one or more module-side data " + "types, can't unload"; + break; + case EPERM: + errmsg = "the module exports APIs used by other modules. " + "Please unload them first and try again"; break; default: errmsg = "operation not possible."; |