Permalink
Browse files

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

  • Loading branch information...
1 parent 61e4ff2 commit e8de5c7a3fa2d0952293a12326719950a6f5535a @antirez committed Jun 7, 2010
Showing with 10 additions and 2 deletions.
  1. +10 −2 redis.c
View
12 redis.c
@@ -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;
}

0 comments on commit e8de5c7

Please sign in to comment.