From: Vincent Kang Fu Date: Fri, 26 Apr 2013 22:56:01 +0000 (-0600) Subject: Add log_info_flush() X-Git-Tag: fio-2.1~9 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=fdd5f15f8231e8c91c4deff22e630a34addd0fef Add log_info_flush() If fio dumps status through -USR1 or similar and output is being stored in a file, the buffering on the file descriptor by the library can cause is not to see all the output. Ensure that it gets flushed after dumping stats. Signed-off-by: Jens Axboe --- diff --git a/log.c b/log.c index d481edf2..4822c335 100644 --- a/log.c +++ b/log.c @@ -71,6 +71,14 @@ int log_info(const char *format, ...) return fwrite(buffer, len, 1, f_out); } +int log_info_flush(void) +{ + if (is_backend || log_syslog) + return 0; + + return fflush(f_out); +} + int log_err(const char *format, ...) { char buffer[1024]; diff --git a/log.h b/log.h index 25f92f9e..a885be72 100644 --- a/log.h +++ b/log.h @@ -12,6 +12,7 @@ extern int log_info(const char *format, ...) __attribute__ ((__format__ (__print extern int log_local(const char *format, ...) __attribute__ ((__format__ (__printf__, 1, 2))); extern int log_valist(const char *str, va_list); extern int log_local_buf(const char *buf, size_t); +extern int log_info_flush(void); enum { FIO_LOG_DEBUG = 1, diff --git a/stat.c b/stat.c index 7ff7ad4d..03a45fc7 100644 --- a/stat.c +++ b/stat.c @@ -1354,6 +1354,7 @@ void show_run_stats(void) show_idle_prof_stats(FIO_OUTPUT_NORMAL, NULL); } + log_info_flush(); free(runstats); free(threadstats); }