Use pthread_detach() instead of calling pthread_join() later
authorJens Axboe <jens.axboe@oracle.com>
Mon, 10 Mar 2008 09:52:22 +0000 (10:52 +0100)
committerJens Axboe <jens.axboe@oracle.com>
Mon, 10 Mar 2008 09:52:22 +0000 (10:52 +0100)
Unifies the thread vs process parts a bit more.

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

diff --git a/fio.c b/fio.c
index c1894f5f771fdeb92f1f05cc18ad55d645782a56..1997bb7cc8761e28ba9baf9f8d303530805d37ab 100644 (file)
--- a/fio.c
+++ b/fio.c
@@ -1108,16 +1108,6 @@ static void reap_threads(int *nr_running, int *t_rate, int *m_rate)
                pending++;
                continue;
 reaped:
                pending++;
                continue;
 reaped:
-               if (td->o.use_thread) {
-                       long ret;
-
-                       dprint(FD_PROCESS, "joining tread %d\n", td->pid);
-                       if (pthread_join(td->thread, (void *) &ret)) {
-                               dprint(FD_PROCESS, "join failed %ld\n", ret);
-                               perror("pthread_join");
-                       }
-               }
-
                (*nr_running)--;
                (*m_rate) -= td->o.ratemin;
                (*t_rate) -= td->o.rate;
                (*nr_running)--;
                (*m_rate) -= td->o.ratemin;
                (*t_rate) -= td->o.rate;
@@ -1247,10 +1237,12 @@ static void run_threads(void)
                                dprint(FD_PROCESS, "will pthread_create\n");
                                if (pthread_create(&td->thread, NULL,
                                                   thread_main, td)) {
                                dprint(FD_PROCESS, "will pthread_create\n");
                                if (pthread_create(&td->thread, NULL,
                                                   thread_main, td)) {
-                                       perror("thread_create");
+                                       perror("pthread_create");
                                        nr_started--;
                                        break;
                                }
                                        nr_started--;
                                        break;
                                }
+                               if (pthread_detach(td->thread) < 0)
+                                       perror("pthread_detach");
                        } else {
                                dprint(FD_PROCESS, "will fork\n");
                                if (!fork()) {
                        } else {
                                dprint(FD_PROCESS, "will fork\n");
                                if (!fork()) {