Skip to content

Commit

Permalink
Fix for VM swapping out at DB loading time when key is shared
Browse files Browse the repository at this point in the history
  • Loading branch information
antirez committed Jun 7, 2010
1 parent 61e4ff2 commit e8de5c7
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions redis.c
Expand Up @@ -4131,10 +4131,18 @@ static int rdbLoad(char *filename) {
if (de) {
key = dictGetEntryKey(de);
val = dictGetEntryVal(de);

if (val->refcount != 1) continue;

/* 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) {
if (vmSwapObjectBlocking(key,val) == REDIS_OK)
dictGetEntryVal(de) = NULL;
}
}
continue;
}
Expand Down

0 comments on commit e8de5c7

Please sign in to comment.