Unverified Commit f29a0b93 authored by sundb's avatar sundb Committed by GitHub
Browse files

Fix some wrongly used constants in module.c (#8844)

This change does not fix any bugs.
1. ```moduleUnload``` should return ```C_OK``` or ```C_ERR```, not ```REDISMODULE_ERR``` or ```REDISMODULE_OK```.
2. The ```where``` parameter of ```listTypePush``` and ```listTypePop``` should be ```LIST_HEAD``` or ```LIST_TAIL```
parent cc0091f0
...@@ -2566,7 +2566,7 @@ int RM_ListPush(RedisModuleKey *key, int where, RedisModuleString *ele) { ...@@ -2566,7 +2566,7 @@ int RM_ListPush(RedisModuleKey *key, int where, RedisModuleString *ele) {
if (key->value && key->value->type != OBJ_LIST) return REDISMODULE_ERR; if (key->value && key->value->type != OBJ_LIST) return REDISMODULE_ERR;
if (key->value == NULL) moduleCreateEmptyKey(key,REDISMODULE_KEYTYPE_LIST); if (key->value == NULL) moduleCreateEmptyKey(key,REDISMODULE_KEYTYPE_LIST);
listTypePush(key->value, ele, listTypePush(key->value, ele,
(where == REDISMODULE_LIST_HEAD) ? QUICKLIST_HEAD : QUICKLIST_TAIL); (where == REDISMODULE_LIST_HEAD) ? LIST_HEAD : LIST_TAIL);
return REDISMODULE_OK; return REDISMODULE_OK;
} }
...@@ -2583,7 +2583,7 @@ RedisModuleString *RM_ListPop(RedisModuleKey *key, int where) { ...@@ -2583,7 +2583,7 @@ RedisModuleString *RM_ListPop(RedisModuleKey *key, int where) {
key->value == NULL || key->value == NULL ||
key->value->type != OBJ_LIST) return NULL; key->value->type != OBJ_LIST) return NULL;
robj *ele = listTypePop(key->value, robj *ele = listTypePop(key->value,
(where == REDISMODULE_LIST_HEAD) ? QUICKLIST_HEAD : QUICKLIST_TAIL); (where == REDISMODULE_LIST_HEAD) ? LIST_HEAD : LIST_TAIL);
robj *decoded = getDecodedObject(ele); robj *decoded = getDecodedObject(ele);
decrRefCount(ele); decrRefCount(ele);
moduleDelKeyIfEmpty(key); moduleDelKeyIfEmpty(key);
...@@ -8589,16 +8589,16 @@ int moduleUnload(sds name) { ...@@ -8589,16 +8589,16 @@ int moduleUnload(sds name) {
if (module == NULL) { if (module == NULL) {
errno = ENOENT; errno = ENOENT;
return REDISMODULE_ERR; return C_ERR;
} else if (listLength(module->types)) { } else if (listLength(module->types)) {
errno = EBUSY; errno = EBUSY;
return REDISMODULE_ERR; return C_ERR;
} else if (listLength(module->usedby)) { } else if (listLength(module->usedby)) {
errno = EPERM; errno = EPERM;
return REDISMODULE_ERR; return C_ERR;
} else if (module->blocked_clients) { } else if (module->blocked_clients) {
errno = EAGAIN; errno = EAGAIN;
return REDISMODULE_ERR; return C_ERR;
} }
/* Give module a chance to clean up. */ /* Give module a chance to clean up. */
...@@ -8614,7 +8614,7 @@ int moduleUnload(sds name) { ...@@ -8614,7 +8614,7 @@ int moduleUnload(sds name) {
if (unload_status == REDISMODULE_ERR) { if (unload_status == REDISMODULE_ERR) {
serverLog(LL_WARNING, "Module %s OnUnload failed. Unload canceled.", name); serverLog(LL_WARNING, "Module %s OnUnload failed. Unload canceled.", name);
errno = ECANCELED; errno = ECANCELED;
return REDISMODULE_ERR; return C_ERR;
} }
} }
...@@ -8647,7 +8647,7 @@ int moduleUnload(sds name) { ...@@ -8647,7 +8647,7 @@ int moduleUnload(sds name) {
module->name = NULL; /* The name was already freed by dictDelete(). */ module->name = NULL; /* The name was already freed by dictDelete(). */
moduleFreeModuleStructure(module); moduleFreeModuleStructure(module);
return REDISMODULE_OK; return C_OK;
} }
/* Helper function for the MODULE and HELLO command: send the list of the /* Helper function for the MODULE and HELLO command: send the list of the
......
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