From adf603d4b170a8622047e0fd342070ac6f07caf4 Mon Sep 17 00:00:00 2001 From: jasone Date: Sun, 20 May 2001 23:08:33 +0000 Subject: Instead of using a join queue for each thread, use a single pointer to keep track of a joiner. POSIX only supports a single joiner, so this simplification is acceptable. At the same time, make sure to mark a joined thread as detached so that its resources can be freed. Reviewed by: deischen PR: 24345 --- lib/libpthread/thread/thr_cancel.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/libpthread/thread/thr_cancel.c') diff --git a/lib/libpthread/thread/thr_cancel.c b/lib/libpthread/thread/thr_cancel.c index 8b9132c..2af3db6 100644 --- a/lib/libpthread/thread/thr_cancel.c +++ b/lib/libpthread/thread/thr_cancel.c @@ -63,6 +63,7 @@ _pthread_cancel(pthread_t pthread) PTHREAD_NEW_STATE(pthread,PS_RUNNING); break; + case PS_JOIN: case PS_SUSPENDED: if (pthread->suspended == SUSP_NO || pthread->suspended == SUSP_YES || @@ -82,7 +83,6 @@ _pthread_cancel(pthread_t pthread) case PS_FDLR_WAIT: case PS_FDLW_WAIT: case PS_FILE_WAIT: - case PS_JOIN: /* * Threads in these states may be in queues. * In order to preserve queue integrity, the @@ -189,6 +189,7 @@ _pthread_testcancel(void) */ curthread->cancelflags &= ~PTHREAD_CANCELLING; _thread_exit_cleanup(); + pthread_detach((pthread_t)curthread); pthread_exit(PTHREAD_CANCELED); PANIC("cancel"); } @@ -225,6 +226,7 @@ finish_cancellation(void *arg) if ((curthread->cancelflags & PTHREAD_CANCEL_NEEDED) != 0) { curthread->cancelflags &= ~PTHREAD_CANCEL_NEEDED; _thread_exit_cleanup(); + pthread_detach((pthread_t)curthread); pthread_exit(PTHREAD_CANCELED); } } -- cgit v1.1