From d8da89ea5d4d6fb36ae202598ef6c2f2d31038fb Mon Sep 17 00:00:00 2001 From: heqin Date: Fri, 15 Dec 2017 11:06:58 +0800 Subject: [PATCH] fixbug for #4538 Error opening /setting AOF rewrite IPC pipes: No such file or directory --- src/aof.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/aof.c b/src/aof.c index 3f2969636..cf807fc36 100644 --- a/src/aof.c +++ b/src/aof.c @@ -237,11 +237,11 @@ void stopAppendOnly(void) { * at runtime using the CONFIG command. */ int startAppendOnly(void) { char cwd[MAXPATHLEN]; /* Current working dir path for error messages. */ + int newfd; - server.aof_last_fsync = server.unixtime; - server.aof_fd = open(server.aof_filename,O_WRONLY|O_APPEND|O_CREAT,0644); + newfd = open(server.aof_filename,O_WRONLY|O_APPEND|O_CREAT,0644); serverAssert(server.aof_state == AOF_OFF); - if (server.aof_fd == -1) { + if (newfd == -1) { char *cwdp = getcwd(cwd,MAXPATHLEN); serverLog(LL_WARNING, @@ -256,13 +256,15 @@ int startAppendOnly(void) { server.aof_rewrite_scheduled = 1; serverLog(LL_WARNING,"AOF was enabled but there is already a child process saving an RDB file on disk. An AOF background was scheduled to start when possible."); } else if (rewriteAppendOnlyFileBackground() == C_ERR) { - close(server.aof_fd); + close(newfd); serverLog(LL_WARNING,"Redis needs to enable the AOF but can't trigger a background AOF rewrite operation. Check the above logs for more info about the error."); return C_ERR; } /* We correctly switched on AOF, now wait for the rewrite to be complete * in order to append data on disk. */ server.aof_state = AOF_WAIT_REWRITE; + server.aof_last_fsync = server.unixtime; + server.aof_fd = newfd; return C_OK; }