]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Change isc_stdio_sync() to use fdatasync()
authorOndřej Surý <ondrej@isc.org>
Thu, 6 Apr 2023 11:32:40 +0000 (13:32 +0200)
committerOndřej Surý <ondrej@isc.org>
Wed, 27 Nov 2024 17:55:33 +0000 (18:55 +0100)
THe isc_stdio_sync() would call fsync() and have an extra check that
sync is called only over regular files.  Remove the extra check and use
fdatasync() instead of fsync() to lighten the load.

lib/isc/include/isc/stdio.h
lib/isc/stdio.c

index c8bac4d251434794d4907dbae2dd3bb145049b25..0d79ae88e9170fdff24c62ce6a2d55526728617b 100644 (file)
@@ -63,7 +63,7 @@ isc_stdio_flush(FILE *f);
 isc_result_t
 isc_stdio_sync(FILE *f);
 /*%<
- * Invoke fsync() on the file descriptor underlying an stdio stream, or an
+ * Invoke fdatasync() on the file descriptor underlying an stdio stream, or an
  * equivalent system-dependent operation.  Note that this function has no
  * direct counterpart in the stdio library.
  */
index 37a7fb768aaac6bfb87c6e35cf19c9a7b2250f2b..99c0c100b1b8e41fd2a3979827fd35ce90e5d2c0 100644 (file)
@@ -116,30 +116,9 @@ isc_stdio_flush(FILE *f) {
        }
 }
 
-/*
- * OpenBSD has deprecated ENOTSUP in favor of EOPNOTSUPP.
- */
-#if defined(EOPNOTSUPP) && !defined(ENOTSUP)
-#define ENOTSUP EOPNOTSUPP
-#endif /* if defined(EOPNOTSUPP) && !defined(ENOTSUP) */
-
 isc_result_t
 isc_stdio_sync(FILE *f) {
-       struct stat buf;
-       int r;
-
-       if (fstat(fileno(f), &buf) != 0) {
-               return isc__errno2result(errno);
-       }
-
-       /*
-        * Only call fsync() on regular files.
-        */
-       if ((buf.st_mode & S_IFMT) != S_IFREG) {
-               return ISC_R_SUCCESS;
-       }
-
-       r = fsync(fileno(f));
+       int r = fdatasync(fileno(f));
        if (r == 0) {
                return ISC_R_SUCCESS;
        } else {