mirror of
https://github.com/fluencelabs/redis
synced 2025-06-24 14:31:34 +00:00
major bug and a dead lock fixed
This commit is contained in:
5
src/db.c
5
src/db.c
@ -97,11 +97,14 @@ int dbAdd(redisDb *db, robj *key, robj *val) {
|
||||
*
|
||||
* On update (key already existed) 0 is returned. Otherwise 1. */
|
||||
int dbReplace(redisDb *db, robj *key, robj *val) {
|
||||
if (dictFind(db->dict,key->ptr) == NULL) {
|
||||
robj *oldval;
|
||||
|
||||
if ((oldval = dictFetchValue(db->dict,key->ptr)) == NULL) {
|
||||
sds copy = sdsdup(key->ptr);
|
||||
dictAdd(db->dict, copy, val);
|
||||
return 1;
|
||||
} else {
|
||||
val->storage = oldval->storage;
|
||||
dictReplace(db->dict, key->ptr, val);
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user