diff options
author | Salvatore Sanfilippo <antirez@gmail.com> | 2017-12-15 12:41:02 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-12-15 12:41:02 +0100 |
commit | 238c9bd0863e713f018587e79f452ade845bee91 (patch) | |
tree | 4e15c94108cbc1a3a4679dfa5f76a30e5a80d48d | |
parent | d745e8dfb3c8448a7a8dd1bbe1bc739a1b04bdcd (diff) | |
parent | ee724cac491c6e6f4ee3c9b91be482f163e6d12c (diff) | |
download | redis-238c9bd0863e713f018587e79f452ade845bee91.tar.gz |
Merge pull request #4540 from hqin6/unstable
fixbug for #4538 Error opening /setting AOF rewrite IPC pipes: No suc…
-rw-r--r-- | src/aof.c | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -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; } |