diff --git a/config.h b/config.h index 754d3aa86f7341c7dad02664b8d10f47d270598e..6e98fbb2cecbceb32a192f1c8bae367cb1b7a11f 100644 --- a/config.h +++ b/config.h @@ -35,4 +35,11 @@ #define HAVE_KQUEUE 1 #endif +/* define aof_fsync to fdatasync() in Linux and fsync() for all the rest */ +#ifdef __linux__ +#define aof_fsync fdatasync +#else +#define aof_fsync fsync +#endif + #endif diff --git a/fmacros.h b/fmacros.h index 986776f2241d2b5df9fce7833d09133c26ffc859..405be20aa98e870cadda1a4c3e00e83f37df28f2 100644 --- a/fmacros.h +++ b/fmacros.h @@ -2,7 +2,7 @@ #define _REDIS_FMACRO_H #define _BSD_SOURCE -#define _XOPEN_SOURCE +#define _XOPEN_SOURCE 700 #define _LARGEFILE_SOURCE #define _FILE_OFFSET_BITS 64 diff --git a/redis.c b/redis.c index 78f5fac0188140d854744904a8d80e360491e949..05f1c64a4f2bab232315fc81ca25c5ce26c000f0 100644 --- a/redis.c +++ b/redis.c @@ -37,8 +37,6 @@ #include #include #include -#define __USE_POSIX199309 -#define __USE_UNIX98 #include #ifdef HAVE_BACKTRACE @@ -4049,7 +4047,7 @@ static void echoCommand(redisClient *c) { static void setGenericCommand(redisClient *c, int nx, robj *key, robj *val, robj *expire) { int retval; - long seconds; + long seconds = 0; /* initialized to avoid an harmness warning */ if (expire) { if (getLongFromObjectOrReply(c, expire, &seconds, NULL) != REDIS_OK) @@ -8090,7 +8088,9 @@ static void feedAppendOnlyFile(struct redisCommand *cmd, int dictid, robj **argv (server.appendfsync == APPENDFSYNC_EVERYSEC && now-server.lastfsync > 1)) { - fsync(server.appendfd); /* Let's try to get this data on the disk */ + /* aof_fsync is defined as fdatasync() for Linux in order to avoid + * flushing metadata. */ + aof_fsync(server.appendfd); /* Let's try to get this data on the disk */ server.lastfsync = now; } }