Add FIO_SIGQUIT engine option
authorJens Axboe <jens.axboe@oracle.com>
Mon, 18 Feb 2008 20:11:24 +0000 (21:11 +0100)
committerJens Axboe <jens.axboe@oracle.com>
Mon, 18 Feb 2008 20:11:24 +0000 (21:11 +0100)
For network engines, we need a signal to make it abort the connection
if it isn't already running. Otherwise fio would just stall on ctrl-c
before the connection was established.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
engines/net.c
fio.c
fio.h

index 552ad0bdb551abebb68f26571df5dc5e2ad20b8f..f6ae37905abf16750f74ed151cc28154002665c5 100644 (file)
@@ -264,6 +264,7 @@ static int fio_netio_accept(struct thread_data *td, struct fio_file *f)
                pfd.events = POLLIN;
 
                ret = poll(&pfd, 1, -1);
+               printf("got ret %d\n", ret);
                if (ret < 0) {
                        if (errno == EINTR)
                                continue;
@@ -463,7 +464,8 @@ static struct ioengine_ops ioengine_rw = {
        .cleanup        = fio_netio_cleanup,
        .open_file      = fio_netio_open_file,
        .close_file     = generic_close_file,
-       .flags          = FIO_SYNCIO | FIO_DISKLESSIO | FIO_UNIDIR,
+       .flags          = FIO_SYNCIO | FIO_DISKLESSIO | FIO_UNIDIR |
+                         FIO_SIGQUIT,
 };
 
 static struct ioengine_ops ioengine_splice = {
@@ -476,7 +478,8 @@ static struct ioengine_ops ioengine_splice = {
        .cleanup        = fio_netio_cleanup,
        .open_file      = fio_netio_open_file,
        .close_file     = generic_close_file,
-       .flags          = FIO_SYNCIO | FIO_DISKLESSIO | FIO_UNIDIR,
+       .flags          = FIO_SYNCIO | FIO_DISKLESSIO | FIO_UNIDIR |
+                         FIO_SIGQUIT,
 };
 
 static void fio_init fio_netio_register(void)
diff --git a/fio.c b/fio.c
index fcd15286a95b971692b5ca65af9de34e2bfd5662..355d8730862643eb02aff27a90d56f1188818572 100644 (file)
--- a/fio.c
+++ b/fio.c
@@ -73,13 +73,17 @@ static void terminate_threads(int group_id)
        for_each_td(td, i) {
                if (group_id == TERMINATE_ALL || groupid == td->groupid) {
                        dprint(FD_PROCESS, "setting terminate on %d\n",td->pid);
+
+                       td->terminate = 1;
+                       td->o.start_delay = 0;
+
                        /*
                         * if the thread is running, just let it exit
                         */
                        if (td->runstate < TD_RUNNING)
                                kill(td->pid, SIGQUIT);
-                       td->terminate = 1;
-                       td->o.start_delay = 0;
+                       else if (td->io_ops->flags & FIO_SIGQUIT)
+                               kill(td->pid, SIGQUIT);
                }
        }
 }
diff --git a/fio.h b/fio.h
index 6dbc4cd59c31a4cdf8c54e4e9c7d9110deaf32a5..9c9002454054e3aa37cbb7bc5da7ef8e0e8e0f2a 100644 (file)
--- a/fio.h
+++ b/fio.h
@@ -263,6 +263,7 @@ enum fio_ioengine_flags {
        FIO_NODISKUTIL  = 1 << 4,       /* diskutil can't handle filename */
        FIO_UNIDIR      = 1 << 5,       /* engine is uni-directional */
        FIO_NOIO        = 1 << 6,       /* thread does only pseudo IO */
+       FIO_SIGQUIT     = 1 << 7,       /* needs SIGQUIT to exit */
 };
 
 enum fio_file_flags {