From edb92db53323ca3952a5509b3950f9d89eddad30 Mon Sep 17 00:00:00 2001 From: "zhaozhao.zz" Date: Tue, 8 May 2018 19:22:13 +0800 Subject: [PATCH] AOF & RDB: be compatible with rdbchecksum no --- src/rdb.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/rdb.c b/src/rdb.c index 27c3aa786..3ef1f5108 100644 --- a/src/rdb.c +++ b/src/rdb.c @@ -2009,16 +2009,18 @@ int rdbLoadRio(rio *rdb, rdbSaveInfo *rsi) { lru_idle = -1; } /* Verify the checksum if RDB version is >= 5 */ - if (rdbver >= 5 && server.rdb_checksum) { + if (rdbver >= 5) { uint64_t cksum, expected = rdb->cksum; if (rioRead(rdb,&cksum,8) == 0) goto eoferr; - memrev64ifbe(&cksum); - if (cksum == 0) { - serverLog(LL_WARNING,"RDB file was saved with checksum disabled: no check performed."); - } else if (cksum != expected) { - serverLog(LL_WARNING,"Wrong RDB checksum. Aborting now."); - rdbExitReportCorruptRDB("RDB CRC error"); + if (server.rdb_checksum) { + memrev64ifbe(&cksum); + if (cksum == 0) { + serverLog(LL_WARNING,"RDB file was saved with checksum disabled: no check performed."); + } else if (cksum != expected) { + serverLog(LL_WARNING,"Wrong RDB checksum. Aborting now."); + rdbExitReportCorruptRDB("RDB CRC error"); + } } } return C_OK;