Add log_info_flush()
[fio.git] / stat.c
diff --git a/stat.c b/stat.c
index 3db06125092b5fee1cbbeaa1749d839a426cab2d..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);
        }
 
+       log_info_flush();
        free(runstats);
        free(threadstats);
 }
@@ -1420,6 +1421,40 @@ void show_running_run_stats(void)
        pthread_detach(thread);
 }
 
+static int status_interval_init;
+static struct timeval status_time;
+
+#define FIO_STATUS_FILE                "/tmp/fio-dump-status"
+
+static int check_status_file(void)
+{
+       struct stat sb;
+
+       if (stat(FIO_STATUS_FILE, &sb))
+               return 0;
+
+       unlink(FIO_STATUS_FILE);
+       return 1;
+}
+
+void check_for_running_stats(void)
+{
+       if (status_interval) {
+               if (!status_interval_init) {
+                       fio_gettime(&status_time, NULL);
+                       status_interval_init = 1;
+               } else if (mtime_since_now(&status_time) >= status_interval) {
+                       show_running_run_stats();
+                       fio_gettime(&status_time, NULL);
+                       return;
+               }
+       }
+       if (check_status_file()) {
+               show_running_run_stats();
+               return;
+       }
+}
+
 static inline void add_stat_sample(struct io_stat *is, unsigned long data)
 {
        double val = data;