debug: avoid free client unexpectedly when reload & loadaof

This commit is contained in:
zhaozhao.zz 2018-03-29 23:20:58 +08:00
parent e08d6bb37e
commit fbef85ca5a

View File

@ -340,7 +340,10 @@ NULL
return;
}
emptyDb(-1,EMPTYDB_NO_FLAGS,NULL);
if (rdbLoad(server.rdb_filename,NULL) != C_OK) {
aeDeleteFileEvent(server.el,c->fd,AE_READABLE);
int ret = rdbLoad(server.rdb_filename,NULL);
aeCreateFileEvent(server.el,c->fd,AE_READABLE,readQueryFromClient,c);
if (ret != C_OK) {
addReplyError(c,"Error trying to load the RDB dump");
return;
}
@ -349,7 +352,10 @@ NULL
} else if (!strcasecmp(c->argv[1]->ptr,"loadaof")) {
if (server.aof_state == AOF_ON) flushAppendOnlyFile(1);
emptyDb(-1,EMPTYDB_NO_FLAGS,NULL);
if (loadAppendOnlyFile(server.aof_filename) != C_OK) {
aeDeleteFileEvent(server.el,c->fd,AE_READABLE);
int ret = loadAppendOnlyFile(server.aof_filename);
aeCreateFileEvent(server.el,c->fd,AE_READABLE,readQueryFromClient,c);
if (ret != C_OK) {
addReply(c,shared.err);
return;
}