]> git.saurik.com Git - redis.git/commitdiff
Added aof_backgronud_fsync() function, and use it in the bacground rewrite done handl...
authorantirez <antirez@gmail.com>
Fri, 16 Sep 2011 09:08:39 +0000 (11:08 +0200)
committerantirez <antirez@gmail.com>
Fri, 16 Sep 2011 09:08:39 +0000 (11:08 +0200)
src/aof.c

index b1b0d9dce9cfcecb9116c8c66a5929387550a8f7..bc80dac9bb8301875b9392374c9cc677d5002242 100644 (file)
--- a/src/aof.c
+++ b/src/aof.c
 
 void aofUpdateCurrentSize(void);
 
 
 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) {
 /* 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;
             /* 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;
             server.appendseldb = -1; /* Make sure SELECT is re-issued */
             aofUpdateCurrentSize();
             server.auto_aofrewrite_base_size = server.appendonly_current_size;