]> git.saurik.com Git - redis.git/blobdiff - src/rdb.c
DB API refactoring. The changes were designed together with Pieter Noordhuis.
[redis.git] / src / rdb.c
index d9dac659c4b14d73680974865b86b3201d2dc5e2..d019d94f95093510eb33a735773ba57092c81f83 100644 (file)
--- a/src/rdb.c
+++ b/src/rdb.c
@@ -430,7 +430,7 @@ int rdbSave(char *filename) {
         redisDb *db = server.db+j;
         dict *d = db->dict;
         if (dictSize(d) == 0) continue;
-        di = dictGetIterator(d);
+        di = dictGetSafeIterator(d);
         if (!di) {
             fclose(fp);
             return REDIS_ERR;
@@ -918,7 +918,7 @@ void stopLoading(void) {
 int rdbLoad(char *filename) {
     FILE *fp;
     uint32_t dbid;
-    int type, retval, rdbver;
+    int type, rdbver;
     redisDb *db = server.db+0;
     char buf[1024];
     time_t expiretime, now = time(NULL);
@@ -981,11 +981,8 @@ int rdbLoad(char *filename) {
             continue;
         }
         /* Add the new object in the hash table */
-        retval = dbAdd(db,key,val);
-        if (retval == REDIS_ERR) {
-            redisLog(REDIS_WARNING,"Loading DB, duplicated key (%s) found! Unrecoverable error, exiting now.", key->ptr);
-            exit(1);
-        }
+        dbAdd(db,key,val);
+
         /* Set the expire time if needed */
         if (expiretime != -1) setExpire(db,key,expiretime);
 
@@ -1038,12 +1035,9 @@ void saveCommand(redisClient *c) {
 void bgsaveCommand(redisClient *c) {
     if (server.bgsavechildpid != -1 || server.bgsavethread != (pthread_t)-1) {
         addReplyError(c,"Background save already in progress");
-        return;
     } else if (server.bgrewritechildpid != -1) {
         addReplyError(c,"Can't BGSAVE while AOF log rewriting is in progress");
-        return;
-    }
-    if (rdbSaveBackground(server.dbfilename) == REDIS_OK) {
+    } else if (rdbSaveBackground(server.dbfilename) == REDIS_OK) {
         addReplyStatus(c,"Background saving started");
     } else {
         addReply(c,shared.err);