From: Ondřej Surý Date: Thu, 6 Apr 2023 11:32:40 +0000 (+0200) Subject: Change isc_stdio_sync() to use fdatasync() X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=f316e9fee737864b58be85d816437554fb004640;p=thirdparty%2Fbind9.git Change isc_stdio_sync() to use fdatasync() 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. --- diff --git a/lib/isc/include/isc/stdio.h b/lib/isc/include/isc/stdio.h index c8bac4d2514..0d79ae88e91 100644 --- a/lib/isc/include/isc/stdio.h +++ b/lib/isc/include/isc/stdio.h @@ -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. */ diff --git a/lib/isc/stdio.c b/lib/isc/stdio.c index 37a7fb768aa..99c0c100b1b 100644 --- a/lib/isc/stdio.c +++ b/lib/isc/stdio.c @@ -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 {