Add close_files() that closes all files
[fio.git] / fio.c
diff --git a/fio.c b/fio.c
index 1594bf64e5976c8a4d107aa2768d50bde0ca0404..c609f55d8e9520672e8c1e67e8c7b811dbceb002 100644 (file)
--- a/fio.c
+++ b/fio.c
@@ -82,8 +82,12 @@ static void terminate_threads(int group_id)
                         */
                        if (td->runstate < TD_RUNNING)
                                kill(td->pid, SIGQUIT);
-                       else if (td->io_ops->flags & FIO_SIGQUIT)
-                               kill(td->pid, SIGQUIT);
+                       else {
+                               struct ioengine_ops *ops = td->io_ops;
+
+                               if (ops && (ops->flags & FIO_SIGQUIT))
+                                       kill(td->pid, SIGQUIT);
+                       }
                }
        }
 }
@@ -783,8 +787,7 @@ static int clear_io_state(struct thread_data *td)
        if (td->o.time_based || td->o.loops)
                td->nr_done_files = 0;
 
-       for_each_file(td, f, i)
-               td_io_close_file(td, f);
+       close_files(td);
 
        ret = 0;
        for_each_file(td, f, i) {
@@ -962,7 +965,7 @@ static void *thread_main(void *data)
 err:
        if (td->error)
                printf("fio: pid=%d, err=%d/%s\n", td->pid, td->error, td->verror);
-       close_files(td);
+       close_and_free_files(td);
        close_ioengine(td);
        cleanup_io_u(td);