diff options
Diffstat (limited to 'lib/libpthread/thread/thr_detach.c')
-rw-r--r-- | lib/libpthread/thread/thr_detach.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/lib/libpthread/thread/thr_detach.c b/lib/libpthread/thread/thr_detach.c index 0b3cfd7..b0e6fc4 100644 --- a/lib/libpthread/thread/thr_detach.c +++ b/lib/libpthread/thread/thr_detach.c @@ -41,7 +41,6 @@ int _pthread_detach(pthread_t pthread) { int rval = 0; - pthread_t next_thread; /* Check for invalid calling parameters: */ if (pthread == NULL || pthread->magic != PTHREAD_MAGIC) @@ -59,19 +58,20 @@ _pthread_detach(pthread_t pthread) */ _thread_kern_sig_defer(); - /* Enter a loop to bring all threads off the join queue: */ - while ((next_thread = TAILQ_FIRST(&pthread->join_queue)) != NULL) { - /* Remove the thread from the queue: */ - TAILQ_REMOVE(&pthread->join_queue, next_thread, sqe); - pthread->flags &= ~PTHREAD_FLAGS_IN_JOINQ; + /* Check if there is a joiner: */ + if (pthread->joiner != NULL) { + struct pthread *joiner = pthread->joiner; /* Make the thread runnable: */ - PTHREAD_NEW_STATE(next_thread, PS_RUNNING); + PTHREAD_NEW_STATE(joiner, PS_RUNNING); + + /* Set the return value for the woken thread: */ + joiner->error = ESRCH; /* - * Set the return value for the woken thread: + * Disconnect the joiner from the thread being detached: */ - next_thread->error = ESRCH; + pthread->joiner = NULL; } /* |