mirror of https://mirror.osredm.com/root/redis.git
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```
This commit is contained in:
parent
cc0091f0f9
commit
f29a0b9351
16
src/module.c
16
src/module.c
|
@ -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 == NULL) moduleCreateEmptyKey(key,REDISMODULE_KEYTYPE_LIST);
|
||||
listTypePush(key->value, ele,
|
||||
(where == REDISMODULE_LIST_HEAD) ? QUICKLIST_HEAD : QUICKLIST_TAIL);
|
||||
(where == REDISMODULE_LIST_HEAD) ? LIST_HEAD : LIST_TAIL);
|
||||
return REDISMODULE_OK;
|
||||
}
|
||||
|
||||
|
@ -2583,7 +2583,7 @@ RedisModuleString *RM_ListPop(RedisModuleKey *key, int where) {
|
|||
key->value == NULL ||
|
||||
key->value->type != OBJ_LIST) return NULL;
|
||||
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);
|
||||
decrRefCount(ele);
|
||||
moduleDelKeyIfEmpty(key);
|
||||
|
@ -8589,16 +8589,16 @@ int moduleUnload(sds name) {
|
|||
|
||||
if (module == NULL) {
|
||||
errno = ENOENT;
|
||||
return REDISMODULE_ERR;
|
||||
return C_ERR;
|
||||
} else if (listLength(module->types)) {
|
||||
errno = EBUSY;
|
||||
return REDISMODULE_ERR;
|
||||
return C_ERR;
|
||||
} else if (listLength(module->usedby)) {
|
||||
errno = EPERM;
|
||||
return REDISMODULE_ERR;
|
||||
return C_ERR;
|
||||
} else if (module->blocked_clients) {
|
||||
errno = EAGAIN;
|
||||
return REDISMODULE_ERR;
|
||||
return C_ERR;
|
||||
}
|
||||
|
||||
/* Give module a chance to clean up. */
|
||||
|
@ -8614,7 +8614,7 @@ int moduleUnload(sds name) {
|
|||
if (unload_status == REDISMODULE_ERR) {
|
||||
serverLog(LL_WARNING, "Module %s OnUnload failed. Unload canceled.", name);
|
||||
errno = ECANCELED;
|
||||
return REDISMODULE_ERR;
|
||||
return C_ERR;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8647,7 +8647,7 @@ int moduleUnload(sds name) {
|
|||
module->name = NULL; /* The name was already freed by dictDelete(). */
|
||||
moduleFreeModuleStructure(module);
|
||||
|
||||
return REDISMODULE_OK;
|
||||
return C_OK;
|
||||
}
|
||||
|
||||
/* Helper function for the MODULE and HELLO command: send the list of the
|
||||
|
|
Loading…
Reference in New Issue