Skip to content

Commit 0adb80f

Browse files
committed
Merge #19803: Bugfix: Define and use HAVE_FDATASYNC correctly outside LevelDB
c4b85ba Bugfix: Define and use HAVE_FDATASYNC correctly outside LevelDB (Luke Dashjr) Pull request description: Fixes a bug introduced in #19614 The LevelDB-specific fdatasync check was only using `AC_SUBST`, which works for Makefiles, but doesn't define anything for C++. Furthermore, the #define is typically 0 or 1, never undefined. This fixes both issues by defining it and checking its value instead of whether it is merely defined. Pulled out of #14501 by fanquake's request ACKs for top commit: fanquake: ACK c4b85ba - thanks for catching and fixing my mistake. laanwj: Code review ACK c4b85ba Tree-SHA512: 91d5d426ba000b4f3ee7e2315635e24bbb23ceff16269ddf4f65a63d25fc9e9cf94a3b236eed2f8031cc36ddcf78aeb5916efcb244f415943a8a12f907ede8f9
2 parents 21eda43 + c4b85ba commit 0adb80f

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1047,13 +1047,13 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdint.h>
10471047
[ AC_MSG_RESULT(no)]
10481048
)
10491049

1050-
dnl LevelDB platform checks
10511050
AC_MSG_CHECKING(for fdatasync)
10521051
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <unistd.h>]],
10531052
[[ fdatasync(0); ]])],
10541053
[ AC_MSG_RESULT(yes); HAVE_FDATASYNC=1 ],
10551054
[ AC_MSG_RESULT(no); HAVE_FDATASYNC=0 ]
10561055
)
1056+
AC_DEFINE_UNQUOTED([HAVE_FDATASYNC], [$HAVE_FDATASYNC], [Define to 1 if fdatasync is available.])
10571057

10581058
AC_MSG_CHECKING(for F_FULLFSYNC)
10591059
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <fcntl.h>]],

src/util/system.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1019,7 +1019,7 @@ bool FileCommit(FILE *file)
10191019
return false;
10201020
}
10211021
#else
1022-
#if defined(HAVE_FDATASYNC)
1022+
#if HAVE_FDATASYNC
10231023
if (fdatasync(fileno(file)) != 0 && errno != EINVAL) { // Ignore EINVAL for filesystems that don't support sync
10241024
LogPrintf("%s: fdatasync failed: %d\n", __func__, errno);
10251025
return false;

0 commit comments

Comments
 (0)