summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYossi Gottlieb <yossigo@gmail.com>2016-06-05 13:27:38 +0300
committerYossi Gottlieb <yossigo@gmail.com>2016-06-05 13:27:38 +0300
commit87312ff7810a67d6ef6ff38745242dab128aa95b (patch)
tree59586afdd481c545c05e4f0e956fd19b868622f2
parent550fa7e14fd1a5402fc6daace9c7026aca028091 (diff)
downloadredis-87312ff7810a67d6ef6ff38745242dab128aa95b.tar.gz
Fix MODULE UNLOAD crash and/or wrong error message.
-rw-r--r--src/module.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/module.c b/src/module.c
index 0a16b9408..6ef13f2f6 100644
--- a/src/module.c
+++ b/src/module.c
@@ -2956,13 +2956,13 @@ int moduleLoad(const char *path) {
int moduleUnload(sds name) {
struct RedisModule *module = dictFetchValue(modules,name);
- if (listLength(module->types)) {
- errno = EBUSY;
+ if (module == NULL) {
+ errno = ENOENT;
return REDISMODULE_ERR;
}
- if (module == NULL) {
- errno = ENOENT;
+ if (listLength(module->types)) {
+ errno = EBUSY;
return REDISMODULE_ERR;
}
@@ -3020,10 +3020,17 @@ void moduleCommand(client *c) {
if (moduleUnload(c->argv[2]->ptr) == C_OK)
addReply(c,shared.ok);
else {
- char *errmsg = "operation not possible.";
+ char *errmsg;
switch(errno) {
- case ENOENT: errmsg = "no such module with that name";
- case EBUSY: errmsg = "the module exports one or more module-side data types, can't unload";
+ case ENOENT:
+ errmsg = "no such module with that name";
+ break;
+ case EBUSY:
+ errmsg = "the module exports one or more module-side data types, can't unload";
+ break;
+ default:
+ errmsg = "operation not possible.";
+ break;
}
addReplyErrorFormat(c,"Error unloading module: %s",errmsg);
}