Merge pull request #1979 from JuhaSointusalo/client-no-flush-in-mainloop

client/lib: don't flush stdout and stderr in main loop
This commit is contained in:
David Anderson 2017-08-04 15:04:48 -07:00 committed by GitHub
commit 59716fc84d
3 changed files with 11 additions and 2 deletions

View File

@ -125,6 +125,11 @@ void show_message(
// print message to the console
printf("%s", evt_message);
#ifdef _MSC_VER
// MSVCRT doesn't support line buffered streams
fflush(stdout);
#endif
// print message to the debugger view port
diagnostics_trace_to_debugger(evt_message);
}

View File

@ -83,6 +83,10 @@ void log_message_startup(const char* msg) {
);
if (!gstate.executing_as_daemon) {
fprintf(stdout, "%s", evt_msg);
#ifdef _MSC_VER
// MSVCRT doesn't support line buffered streams
fflush(stdout);
#endif
} else {
#ifdef _WIN32
LogEventInfoMessage(evt_msg);
@ -373,8 +377,6 @@ int boinc_main_loop() {
if (!gstate.poll_slow_events()) {
gstate.do_io_or_sleep(POLL_INTERVAL);
}
fflush(stderr);
fflush(stdout);
if (gstate.time_to_exit()) {
msg_printf(NULL, MSG_INFO, "Time to exit");

View File

@ -352,6 +352,7 @@ int diagnostics_init(
if (!stdout_file) {
return ERR_FOPEN;
}
setvbuf(stdout_file, NULL, _IOLBF, BUFSIZ);
}
if (flags & BOINC_DIAG_REDIRECTSTDOUTOVERWRITE) {
@ -359,6 +360,7 @@ int diagnostics_init(
if (!stdout_file) {
return ERR_FOPEN;
}
setvbuf(stdout_file, NULL, _IOLBF, BUFSIZ);
}