lib: set correct buffering mode after cycling logs

After freopen() stream is fully buffered. In this mode client's log
messages are written to stdoutdae.txt BUFSIZ (typically 512) bytes
at a time.

Set stdout to line buffered mode after freopen() so that messages
are written one line at a time.

Set stderr's buffering mode after making sure freopen() succeeded.

Fixes #2141.
This commit is contained in:
Juha Sointusalo 2017-09-23 23:23:38 +03:00
parent acc1662563
commit 27dfa374e3
1 changed files with 2 additions and 1 deletions

View File

@ -666,8 +666,8 @@ int diagnostics_cycle_logs() {
boinc_copy(stderr_log, stderr_archive);
stderr_file_size = 0;
stderr_file = freopen(stderr_log, "w", stderr);
setbuf(stderr_file, 0);
if (NULL == stderr_file) return ERR_FOPEN;
setbuf(stderr_file, 0);
}
}
@ -679,6 +679,7 @@ int diagnostics_cycle_logs() {
boinc_copy(stdout_log, stdout_archive);
stdout_file = freopen(stdout_log, "w", stdout);
if (NULL == stdout_file) return ERR_FOPEN;
setvbuf(stdout_file, NULL, _IOLBF, BUFSIZ);
}
}
return BOINC_SUCCESS;