Use a safe iterator while saving the DB, since the getExpire() function will access the iterating dictionary.

This commit is contained in:
antirez 2011-06-17 15:40:55 +02:00
parent 4ec8b732b7
commit 25e805b417
2 changed files with 2 additions and 2 deletions

View File

@ -348,7 +348,7 @@ int rewriteAppendOnlyFile(char *filename) {
redisDb *db = server.db+j; redisDb *db = server.db+j;
dict *d = db->dict; dict *d = db->dict;
if (dictSize(d) == 0) continue; if (dictSize(d) == 0) continue;
di = dictGetIterator(d); di = dictGetSafeIterator(d);
if (!di) { if (!di) {
fclose(fp); fclose(fp);
return REDIS_ERR; return REDIS_ERR;

View File

@ -427,7 +427,7 @@ int rdbSave(char *filename) {
redisDb *db = server.db+j; redisDb *db = server.db+j;
dict *d = db->dict; dict *d = db->dict;
if (dictSize(d) == 0) continue; if (dictSize(d) == 0) continue;
di = dictGetIterator(d); di = dictGetSafeIterator(d);
if (!di) { if (!di) {
fclose(fp); fclose(fp);
return REDIS_ERR; return REDIS_ERR;