Fix for VM swapping out at DB loading time when key is shared

This commit is contained in:
antirez
2010-06-07 17:57:56 +02:00
parent 61e4ff2f9c
commit e8de5c7a3f

12
redis.c
View File

@ -4131,10 +4131,18 @@ static int rdbLoad(char *filename) {
if (de) {
key = dictGetEntryKey(de);
val = dictGetEntryVal(de);
if (val->refcount != 1) continue;
if (vmSwapObjectBlocking(key,val) == REDIS_OK) {
dictGetEntryVal(de) = NULL;
/* Unshare the key if needed */
if (key->refcount != 1) {
robj *newkey = dupStringObject(key);
decrRefCount(key);
key = dictGetEntryKey(de) = newkey;
}
if (vmSwapObjectBlocking(key,val) == REDIS_OK)
dictGetEntryVal(de) = NULL;
}
continue;
}