summaryrefslogtreecommitdiffstats
path: root/lib/libkse/thread/thr_cancel.c
diff options
context:
space:
mode:
authorjasone <jasone@FreeBSD.org>2001-05-20 23:08:33 +0000
committerjasone <jasone@FreeBSD.org>2001-05-20 23:08:33 +0000
commitadf603d4b170a8622047e0fd342070ac6f07caf4 (patch)
treec37f9e05a6d81f226bfef98090c73e613802b9c7 /lib/libkse/thread/thr_cancel.c
parentcdb5d97b478a3e4f97dd6c0cd43105d0951daed5 (diff)
downloadFreeBSD-src-adf603d4b170a8622047e0fd342070ac6f07caf4.zip
FreeBSD-src-adf603d4b170a8622047e0fd342070ac6f07caf4.tar.gz
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
Diffstat (limited to 'lib/libkse/thread/thr_cancel.c')
-rw-r--r--lib/libkse/thread/thr_cancel.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/libkse/thread/thr_cancel.c b/lib/libkse/thread/thr_cancel.c
index 8b9132c..2af3db6 100644
--- a/lib/libkse/thread/thr_cancel.c
+++ b/lib/libkse/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);
}
}
OpenPOWER on IntegriCloud