server: ensure that fio_time_init() is called before option parsing
authorBruce Cran <bcran@fusionio.com>
Fri, 1 Nov 2013 18:32:40 +0000 (12:32 -0600)
committerJens Axboe <axboe@kernel.dk>
Fri, 1 Nov 2013 18:32:40 +0000 (12:32 -0600)
When run in server mode, jobs are processed before fio_time_init()
is called, which causes pthread_setspecific() to be called before
pthread_key_create(). Work around this by calling it in thread_main()
too.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
backend.c

index 180a48747607294d8a14dd8552677b18bbad6bef..00a23db6ecd1dfa6caaf98124605653bd2c85c97 100644 (file)
--- a/backend.c
+++ b/backend.c
@@ -1129,6 +1129,11 @@ static void *thread_main(void *data)
        } else
                td->pid = gettid();
 
+       /*
+        * fio_time_init() may not have been called yet if running as a server
+        */
+       fio_time_init();
+
        fio_local_clock_init(o->use_thread);
 
        dprint(FD_PROCESS, "jobs pid=%d started\n", (int) td->pid);
@@ -1590,7 +1595,7 @@ static void run_threads(void)
 
        if (fio_gtod_offload && fio_start_gtod_thread())
                return;
-       
+
        fio_idle_prof_init();
 
        set_sig_handlers();