Add log_info_flush()
authorVincent Kang Fu <VFu@fusionio.com>
Fri, 26 Apr 2013 22:56:01 +0000 (16:56 -0600)
committerJens Axboe <axboe@kernel.dk>
Fri, 26 Apr 2013 22:56:01 +0000 (16:56 -0600)
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 <axboe@kernel.dk>
log.c
log.h
stat.c

diff --git a/log.c b/log.c
index d481edf2fd17efb711d454047f625e56b1aebe49..4822c33526d29fd4b7d9c0731f5030c75c982909 100644 (file)
--- a/log.c
+++ b/log.c
@@ -71,6 +71,14 @@ int log_info(const char *format, ...)
                return fwrite(buffer, len, 1, f_out);
 }
 
                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];
 int log_err(const char *format, ...)
 {
        char buffer[1024];
diff --git a/log.h b/log.h
index 25f92f9e2841abbd2dfd201e7e6c18b4f5218fad..a885be7253628e28950115944cca2d937be653c7 100644 (file)
--- 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_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,
 
 enum {
        FIO_LOG_DEBUG   = 1,
diff --git a/stat.c b/stat.c
index 7ff7ad4d8ce42fd504e394d358c7d996102ce665..03a45fc70a197562cc09c2a21d1fbf9f645c3867 100644 (file)
--- a/stat.c
+++ b/stat.c
@@ -1354,6 +1354,7 @@ void show_run_stats(void)
                show_idle_prof_stats(FIO_OUTPUT_NORMAL, NULL);
        }
 
                show_idle_prof_stats(FIO_OUTPUT_NORMAL, NULL);
        }
 
+       log_info_flush();
        free(runstats);
        free(threadstats);
 }
        free(runstats);
        free(threadstats);
 }