Просмотр исходного кода

More frequently flush stdout buffers to achieve correct serialization.

This fixes the issue of incorrect ordering of output when output is buffered
from both ch.exe and ChakraCore.dll, which now have separate instances of the
stdout buffer each statically linked into the respective modules (previously,
all buffered output calls to stdout would use the same buffer from
ucrtbased.dll).

Performance changes that result from extra flushes is unimportant
especially when most of the instances where we write to stdout are related
ch.exe's WScript.Echo and debugging code.
Doug Ilijev 9 лет назад
Родитель
Сommit
02aff24dbc
2 измененных файлов с 3 добавлено и 4 удалено
  1. 1 0
      bin/ch/WScriptJsrt.cpp
  2. 2 4
      lib/Common/Core/Output.cpp

+ 1 - 0
bin/ch/WScriptJsrt.cpp

@@ -65,6 +65,7 @@ JsValueRef __stdcall WScriptJsrt::EchoCallback(JsValueRef callee, bool isConstru
     }
 
     wprintf(L"\n");
+    fflush(stdout);
 
     JsValueRef undefinedValue;
     if (ChakraRTInterface::JsGetUndefinedValue(&undefinedValue) == JsNoError)

+ 2 - 4
lib/Common/Core/Output.cpp

@@ -52,6 +52,7 @@ Output::VerboseNote(const char16 * format, ...)
         va_list argptr;
         va_start(argptr, format);
         size_t size = vfwprintf(stdout, format, argptr);
+        fflush(stdout);
         va_end(argptr);
         return size;
     }
@@ -344,10 +345,7 @@ Output::PrintBuffer(const char16 * buf, size_t size)
         }
     }
 
-    if (IsDebuggerPresent())
-    {
-        Output::Flush();
-    }
+    Output::Flush();
 
     return size;
 }