X-Git-Url: https://git.saurik.com/redis.git/blobdiff_plain/36c17a53b6aece050b79b667fd32064f6eb116c2..419e1cca74102440d5ce174fbbf36d81a9b8956a:/src/rdb.c diff --git a/src/rdb.c b/src/rdb.c index 62756d30..02317fda 100644 --- a/src/rdb.c +++ b/src/rdb.c @@ -399,13 +399,9 @@ off_t rdbSavedObjectLen(robj *o) { * On error -1 is returned. * On success if the key was actaully saved 1 is returned, otherwise 0 * is returned (the key was already expired). */ -int rdbSaveKeyValuePair(FILE *fp, redisDb *db, robj *key, robj *val, - time_t now) +int rdbSaveKeyValuePair(FILE *fp, robj *key, robj *val, + time_t expiretime, time_t now) { - time_t expiretime; - - expiretime = getExpire(db,key); - /* Save the expire time */ if (expiretime != -1) { /* If this key is already expired skip it */ @@ -437,7 +433,8 @@ int rdbSave(char *filename) { snprintf(tmpfile,256,"temp-%d.rdb", (int) getpid()); fp = fopen(tmpfile,"w"); if (!fp) { - redisLog(REDIS_WARNING, "Failed saving the DB: %s", strerror(errno)); + redisLog(REDIS_WARNING, "Failed opening .rdb for saving: %s", + strerror(errno)); return REDIS_ERR; } if (fwrite("REDIS0001",9,1,fp) == 0) goto werr; @@ -459,9 +456,11 @@ int rdbSave(char *filename) { while((de = dictNext(di)) != NULL) { sds keystr = dictGetEntryKey(de); robj key, *o = dictGetEntryVal(de); + time_t expire; initStaticStringObject(key,keystr); - if (rdbSaveKeyValuePair(fp,db,&key,o,now) == -1) goto werr; + expire = getExpire(db,&key); + if (rdbSaveKeyValuePair(fp,&key,o,expire,now) == -1) goto werr; } dictReleaseIterator(di); } @@ -503,7 +502,7 @@ int rdbSaveBackground(char *filename) { if (server.ds_enabled) { cacheForcePointInTime(); - return dsRdbSave(filename); + return dsRdbSaveBackground(filename); } if ((childpid = fork()) == 0) { @@ -973,7 +972,7 @@ void backgroundSaveDoneHandler(int exitcode, int bysignal) { } void saveCommand(redisClient *c) { - if (server.bgsavechildpid != -1 || server.bgsavethread != (pthread-t)-1) { + if (server.bgsavechildpid != -1 || server.bgsavethread != (pthread_t)-1) { addReplyError(c,"Background save already in progress"); return; } @@ -985,7 +984,7 @@ void saveCommand(redisClient *c) { } void bgsaveCommand(redisClient *c) { - if (server.bgsavechildpid != -1 || server.bgsavethread != (pthread-t)-1) { + if (server.bgsavechildpid != -1 || server.bgsavethread != (pthread_t)-1) { addReplyError(c,"Background save already in progress"); return; }