Skip to content

Commit

Permalink
Merge branch 'master' of github.com:antirez/redis
Browse files Browse the repository at this point in the history
  • Loading branch information
antirez committed Apr 21, 2010
2 parents a08bb01 + 122c049 commit 0040fa2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
5 changes: 5 additions & 0 deletions config.h
Expand Up @@ -35,4 +35,9 @@
#define HAVE_KQUEUE 1
#endif

/* test for O_DIRECT */
#ifdef __linux__
#define HAVE_O_DIRECT 1
#endif

#endif
12 changes: 11 additions & 1 deletion redis.c
Expand Up @@ -54,6 +54,7 @@
#include <inttypes.h>
#include <arpa/inet.h>
#include <sys/stat.h>
#define __USE_GNU
#include <fcntl.h>
#include <sys/time.h>
#include <sys/resource.h>
Expand Down Expand Up @@ -1673,7 +1674,16 @@ static void initServer() {
acceptHandler, NULL) == AE_ERR) oom("creating file event");

if (server.appendonly) {
server.appendfd = open(server.appendfilename,O_WRONLY|O_APPEND|O_CREAT,0644);
int flags = O_WRONLY|O_APPEND|O_CREAT;

#ifdef HAVE_O_DIRECT
if (server.appendfsync == APPENDFSYNC_ALWAYS) {
flags |= O_DIRECT;
server.appendfsync = APPENDFSYNC_NO;
}
#endif

server.appendfd = open(server.appendfilename,flags,0644);
if (server.appendfd == -1) {
redisLog(REDIS_WARNING, "Can't open the append-only file: %s",
strerror(errno));
Expand Down

0 comments on commit 0040fa2

Please sign in to comment.