From 4b77700a334b5b9ac4dbc04252ef6c6e6e3598ea Mon Sep 17 00:00:00 2001 From: antirez Date: Fri, 16 Sep 2011 11:08:39 +0200 Subject: [PATCH] Added aof_backgronud_fsync() function, and use it in the bacground rewrite done handler when the fsync policy is everysec. --- src/aof.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/aof.c b/src/aof.c index b1b0d9dc..bc80dac9 100644 --- a/src/aof.c +++ b/src/aof.c @@ -11,6 +11,10 @@ void aofUpdateCurrentSize(void); +void aof_background_fsync(int fd) { + bioCreateBackgroundJob(REDIS_BIO_AOF_FSYNC,(void*)(long)fd,NULL); +} + /* Called when the user switches from "appendonly yes" to "appendonly no" * at runtime using the CONFIG command. */ void stopAppendOnly(void) { @@ -762,7 +766,10 @@ void backgroundRewriteDoneHandler(int exitcode, int bysignal) { /* AOF enabled, replace the old fd with the new one. */ oldfd = server.appendfd; server.appendfd = newfd; - if (server.appendfsync != APPENDFSYNC_NO) aof_fsync(newfd); + if (server.appendfsync == APPENDFSYNC_ALWAYS) + aof_fsync(newfd); + else if (server.appendfsync == APPENDFSYNC_EVERYSEC) + aof_background_fsync(newfd); server.appendseldb = -1; /* Make sure SELECT is re-issued */ aofUpdateCurrentSize(); server.auto_aofrewrite_base_size = server.appendonly_current_size; -- 2.47.2