From: antirez Date: Fri, 16 Sep 2011 09:08:39 +0000 (+0200) Subject: Added aof_backgronud_fsync() function, and use it in the bacground rewrite done handl... X-Git-Url: https://git.saurik.com/redis.git/commitdiff_plain/4b77700a334b5b9ac4dbc04252ef6c6e6e3598ea Added aof_backgronud_fsync() function, and use it in the bacground rewrite done handler when the fsync policy is everysec. --- 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;