Token-based flow control
[fio.git] / init.c
diff --git a/init.c b/init.c
index 4a3716bfeb5c058c235e9e529e73c4addef210b2..d7d801181c435247e24217d5d53bfcc372698837 100644 (file)
--- a/init.c
+++ b/init.c
@@ -221,6 +221,7 @@ static void free_shm(void)
 
                threads = NULL;
                file_hash_exit();
+               flow_exit();
                fio_debug_jobp = NULL;
                shmdt(tp);
                shmctl(shm_id, IPC_RMID, &sbuf);
@@ -255,7 +256,7 @@ static int setup_thread_area(void)
                shm_id = shmget(0, size, IPC_CREAT | 0600);
                if (shm_id != -1)
                        break;
-               if (errno != EINVAL) {
+               if (errno != EINVAL && errno != ENOMEM) {
                        perror("shmget");
                        break;
                }
@@ -277,6 +278,9 @@ static int setup_thread_area(void)
        fio_debug_jobp = (void *) hash + file_hash_size;
        *fio_debug_jobp = -1;
        file_hash_init(hash);
+
+       flow_init();
+
        return 0;
 }
 
@@ -324,6 +328,7 @@ static void put_job(struct thread_data *td)
                return;
 
        profile_td_exit(td);
+       flow_exit_job(td);
 
        if (td->error)
                log_info("fio: %s\n", td->verror);
@@ -796,6 +801,8 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num)
        if (fixup_options(td))
                goto err;
 
+       flow_init_job(td);
+
        /*
         * IO engines only need this for option callbacks, and the address may
         * change in subprocesses.