X-Git-Url: https://git.saurik.com/redis.git/blobdiff_plain/aaada3f962a9f87fb239e55e3d26c1e794d411d5..8df3dcada5e34c6a99666931ee6dcccd57685353:/src/rdb.c?ds=sidebyside diff --git a/src/rdb.c b/src/rdb.c index 019aa9a0..589b536a 100644 --- a/src/rdb.c +++ b/src/rdb.c @@ -273,7 +273,7 @@ int rdbSaveObject(FILE *fp, robj *o) { dictReleaseIterator(di); } else if (o->encoding == REDIS_ENCODING_INTSET) { intset *is = o->ptr; - long long llval; + int64_t llval; int i = 0; if (rdbSaveLen(fp,intsetLen(is)) == -1) return -1; @@ -457,10 +457,12 @@ int rdbSaveBackground(char *filename) { if (server.bgsavechildpid != -1) return REDIS_ERR; if (server.vm_enabled) waitEmptyIOJobsQueue(); + server.dirty_before_bgsave = server.dirty; if ((childpid = fork()) == 0) { /* Child */ if (server.vm_enabled) vmReopenSwapFile(); - close(server.fd); + if (server.ipfd > 0) close(server.ipfd); + if (server.sofd > 0) close(server.sofd); if (rdbSave(filename) == REDIS_OK) { _exit(0); } else { @@ -702,7 +704,7 @@ robj *rdbLoadObject(int type, FILE *fp) { if (o->encoding == REDIS_ENCODING_INTSET) { /* Fetch integer value from element */ - if (getLongLongFromObject(ele,&llval) == REDIS_OK) { + if (isObjectRepresentableAsLongLong(ele,&llval) == REDIS_OK) { o->ptr = intsetAdd(o->ptr,llval,NULL); } else { setTypeConvert(o,REDIS_ENCODING_HT); @@ -714,6 +716,8 @@ robj *rdbLoadObject(int type, FILE *fp) { * to regular hashtable encoded set */ if (o->encoding == REDIS_ENCODING_HT) { dictAdd((dict*)o->ptr,ele,NULL); + } else { + decrRefCount(ele); } } } else if (type == REDIS_ZSET) { @@ -727,13 +731,14 @@ robj *rdbLoadObject(int type, FILE *fp) { /* Load every single element of the list/set */ while(zsetlen--) { robj *ele; - double *score = zmalloc(sizeof(double)); + double score; + zskiplistNode *znode; if ((ele = rdbLoadEncodedStringObject(fp)) == NULL) return NULL; ele = tryObjectEncoding(ele); - if (rdbLoadDoubleValue(fp,score) == -1) return NULL; - dictAdd(zs->dict,ele,score); - zslInsert(zs->zsl,*score,ele); + if (rdbLoadDoubleValue(fp,&score) == -1) return NULL; + znode = zslInsert(zs->zsl,score,ele); + dictAdd(zs->dict,ele,&znode->score); incrRefCount(ele); /* added to skiplist */ } } else if (type == REDIS_HASH) { @@ -911,7 +916,7 @@ void backgroundSaveDoneHandler(int statloc) { if (!bysignal && exitcode == 0) { redisLog(REDIS_NOTICE, "Background saving terminated with success"); - server.dirty = 0; + server.dirty = server.dirty - server.dirty_before_bgsave; server.lastsave = time(NULL); } else if (!bysignal && exitcode != 0) { redisLog(REDIS_WARNING, "Background saving error");