diff --git a/configure.ac b/configure.ac index ff7133e83..b0b89d5c9 100644 --- a/configure.ac +++ b/configure.ac @@ -201,8 +201,10 @@ AC_FUNC_CHOWN AC_FUNC_FORK AC_FUNC_MMAP AC_FUNC_STRERROR_R -AC_CHECK_FUNCS([alarm clock_gettime ftruncate gettimeofday \ - localtime localtime_r memset munmap socket \ +AC_CHECK_FUNCS([alarm clock_gettime \ + fsync fdatasync ftruncate \ + gettimeofday localtime localtime_r \ + memset munmap socket \ strchr strrchr strdup strstr strcasecmp \ poll epoll_create epoll_create1 kqueue \ random rand getrlimit sysconf \ @@ -270,6 +272,7 @@ fi nongcc_memory_barrier_needed=no arch_force_shmlba=no +file_sync=fdatasync AC_MSG_CHECKING([for architecture in ${host_cpu}]) case $host_cpu in sparc*) @@ -388,6 +391,31 @@ case "$host_os" in ;; esac +while : ; do + case ${file_sync} in + fdatasync) + if test x$HAVE_FDATASYNC != xyes; then + break + fi + file_sync=fsync;; + fsync) + if test x$HAVE_FSYNC != xyes; then + break + fi + file_sync=;; + "") + file_sync=x; break;; + *) + AC_MSG_ERROR([Cannot select file syncer method]);; + esac +done +if test "x${file_sync}" != x; then + AC_DEFINE_UNQUOTED([QB_FILE_SYNC(x)], [${file_sync}(x)], [File sync method]) +else + AC_MSG_WARN([No file sync method applicable!]) + AC_DEFINE([QB_FILE_SYNC(x)], [], [File sync method]) +fi + AC_MSG_CHECKING([whether GCC supports builtin sync intrinsics]) if test -z "$gcc_has_builtin_sync_operations"; then gcc_has_builtin_sync_operations=no @@ -709,7 +737,7 @@ AC_MSG_RESULT([ Arch-independent files = ${datadir}]) AC_MSG_RESULT([ State information = ${localstatedir}]) AC_MSG_RESULT([ System configuration = ${sysconfdir}]) AC_MSG_RESULT([ SOCKETDIR = ${SOCKETDIR}]) -AC_MSG_RESULT([ Features =${PACKAGE_FEATURES}]) +AC_MSG_RESULT([ Features = ${PACKAGE_FEATURES}]) AC_MSG_RESULT([]) AC_MSG_RESULT([$PACKAGE build info:]) AC_MSG_RESULT([ Optimization = ${OPT_CFLAGS}]) diff --git a/lib/log_file.c b/lib/log_file.c index 8f1a94b9a..42f1398dd 100644 --- a/lib/log_file.c +++ b/lib/log_file.c @@ -40,7 +40,7 @@ _file_logger(int32_t t, fflush(f); if (target->file_sync) { - fsync(fileno(f)); + QB_FILE_SYNC(fileno(f)); } }