]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Prevent unbuffered stderr I/O on Windows
authorMichał Kępień <michal@isc.org>
Thu, 26 Sep 2019 11:53:03 +0000 (13:53 +0200)
committerMichał Kępień <michal@isc.org>
Thu, 26 Sep 2019 11:56:38 +0000 (13:56 +0200)
Make stderr fully buffered on Windows to improve named performance when
it is logging to stderr, which happens e.g. in system tests.  Note that:

  - line buffering (_IOLBF) is unavailable on Windows,

  - fflush() is called anyway after each log message gets written to the
    default stderr logging channels created by libisc.

(cherry picked from commit c72da3497d821c06a9b641b1c8544f957c726238)

bin/named/main.c

index c64fb0082b9ac1e2af6570d3f54f855a3b748866..7e4273add8f3c2700a535d7323c9da4a5b5954cb 100644 (file)
@@ -1363,6 +1363,17 @@ main(int argc, char *argv[]) {
        (void) ProfilerStart(NULL);
 #endif
 
+#ifdef WIN32
+       /*
+        * Prevent unbuffered I/O from crippling named performance on Windows
+        * when it is logging to stderr (e.g. in system tests).  Use full
+        * buffering (_IOFBF) as line buffering (_IOLBF) is unavailable on
+        * Windows and fflush() is called anyway after each log message gets
+        * written to the default stderr logging channels created by libisc.
+       */
+       setvbuf(stderr, NULL, _IOFBF, BUFSIZ);
+#endif
+
        /*
         * Record version in core image.
         * strings named.core | grep "named version:"