Windows: Used specific buffer size for `setvbuf`.

Microsoft MSVCCRT requires a value for the buffer size.

Review: https://reviews.apache.org/r/47873/


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/f61e8350
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/f61e8350
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/f61e8350

Branch: refs/heads/master
Commit: f61e835098626a3323a2677781fc26d1a4d75018
Parents: 563c9ff
Author: Daniel Pravat <dpra...@outlook.com>
Authored: Mon May 30 18:07:35 2016 -0700
Committer: Joris Van Remoortere <joris.van.remoort...@gmail.com>
Committed: Mon May 30 18:30:17 2016 -0700

----------------------------------------------------------------------
 src/exec/exec.cpp | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/f61e8350/src/exec/exec.cpp
----------------------------------------------------------------------
diff --git a/src/exec/exec.cpp b/src/exec/exec.cpp
index 69a1fb2..666b1f4 100644
--- a/src/exec/exec.cpp
+++ b/src/exec/exec.cpp
@@ -648,9 +648,18 @@ Status MesosExecutorDriver::start()
 
     // Set stream buffering mode to flush on newlines so that we
     // capture logs from user processes even when output is redirected
-    // to a file.
-    setvbuf(stdout, 0, _IOLBF, 0);
-    setvbuf(stderr, 0, _IOLBF, 0);
+    // to a file. On POSIX, the buffer size is determined by the system
+    // when the `buf` parameter is null. On Windows we have to specify
+    // the size, so we use 1024 bytes, a number that is arbitrary, but
+    // large enough to not affect performance.
+    const size_t bufferSize =
+#ifdef __WINDOWS__
+      1024;
+#else // __WINDOWS__
+      0;
+#endif // __WINDOWS__
+    setvbuf(stdout, NULL, _IOLBF, bufferSize);
+    setvbuf(stderr, NULL, _IOLBF, bufferSize);
 
     bool local;
 

Reply via email to