Fixup wrong enum used for __check_min_rate()
[fio.git] / fio.c
diff --git a/fio.c b/fio.c
index 77451db2c37deb4e1c80db8dfa5b8d020e746ae0..34956e9f101ead149ee430d3b64b6c6ba52304d2 100644 (file)
--- a/fio.c
+++ b/fio.c
@@ -45,6 +45,7 @@
 #include "cgroup.h"
 #include "profile.h"
 #include "lib/rand.h"
+#include "memalign.h"
 
 unsigned long page_mask;
 unsigned long page_size;
@@ -113,18 +114,12 @@ static void terminate_threads(int group_id)
        }
 }
 
-/*
- * Happens on thread runs with ctrl-c, ignore our own SIGQUIT
- */
-static void sig_quit(int sig)
-{
-}
-
 static void sig_int(int sig)
 {
        if (threads) {
                log_info("\nfio: terminating on signal %d\n", sig);
                fflush(stdout);
+               exit_value = 128;
                terminate_threads(TERMINATE_ALL);
        }
 }
@@ -135,6 +130,8 @@ static void *disk_thread_main(void *data)
 
        while (threads) {
                usleep(DISK_UTIL_MSEC * 1000);
+               if (!threads)
+                       break;
                update_io_ticks();
                print_thread_status();
        }
@@ -144,13 +141,9 @@ static void *disk_thread_main(void *data)
 
 static int create_disk_util_thread(void)
 {
-       pthread_attr_t attr;
        int ret;
 
-       pthread_attr_init(&attr);
-       pthread_attr_setstacksize(&attr, PTHREAD_STACK_MIN);
-       ret = pthread_create(&disk_util_thread, &attr, disk_thread_main, NULL);
-       pthread_attr_destroy(&attr);
+       ret = pthread_create(&disk_util_thread, NULL, disk_thread_main, NULL);
        if (ret) {
                log_err("Can't create disk util thread: %s\n", strerror(ret));
                return 1;
@@ -178,7 +171,7 @@ static void set_sig_handlers(void)
        sigaction(SIGINT, &act, NULL);
 
        memset(&act, 0, sizeof(act));
-       act.sa_handler = sig_quit;
+       act.sa_handler = sig_int;
        act.sa_flags = SA_RESTART;
        sigaction(SIGTERM, &act, NULL);
 }
@@ -187,7 +180,7 @@ static void set_sig_handlers(void)
  * Check if we are above the minimum rate given.
  */
 static int __check_min_rate(struct thread_data *td, struct timeval *now,
-                           enum td_ddir ddir)
+                           enum fio_ddir ddir)
 {
        unsigned long long bytes = 0;
        unsigned long iops = 0;
@@ -499,7 +492,6 @@ static void do_verify(struct thread_data *td)
                                clear_io_u(td, io_u);
                        } else if (io_u->resid) {
                                int bytes = io_u->xfer_buflen - io_u->resid;
-                               struct fio_file *f = io_u->file;
 
                                /*
                                 * zero read, fail
@@ -517,6 +509,7 @@ static void do_verify(struct thread_data *td)
                                if (ddir_rw(io_u->ddir))
                                        td->ts.short_io_u[io_u->ddir]++;
 
+                               f = io_u->file;
                                if (io_u->offset == f->real_file_size)
                                        goto sync_done;
 
@@ -798,7 +791,7 @@ static void cleanup_io_u(struct thread_data *td)
                io_u = flist_entry(entry, struct io_u, list);
 
                flist_del(&io_u->list);
-               free(io_u);
+               fio_memfree(io_u, sizeof(*io_u));
        }
 
        free_io_mem(td);
@@ -845,8 +838,9 @@ static int init_io_u(struct thread_data *td)
                if (td->terminate)
                        return 1;
 
-               if (posix_memalign(&ptr, cl_align, sizeof(*io_u))) {
-                       log_err("fio: posix_memalign=%s\n", strerror(errno));
+               ptr = fio_memalign(cl_align, sizeof(*io_u));
+               if (!ptr) {
+                       log_err("fio: unable to allocate aligned memory\n");
                        break;
                }
 
@@ -1499,14 +1493,14 @@ static void run_threads(void)
                        todo--;
                } else {
                        struct fio_file *f;
-                       unsigned int i;
+                       unsigned int j;
 
                        /*
                         * for sharing to work, each job must always open
                         * its own files. so close them, if we opened them
                         * for creation
                         */
-                       for_each_file(td, f, i) {
+                       for_each_file(td, f, j) {
                                if (fio_file_open(f))
                                        td_io_close_file(td, f);
                        }