summaryrefslogtreecommitdiffstats
path: root/lib/libpthread
diff options
context:
space:
mode:
authorarchie <archie@FreeBSD.org>2002-05-02 19:57:59 +0000
committerarchie <archie@FreeBSD.org>2002-05-02 19:57:59 +0000
commit7efe637f5aea25bb5a5edc7e5b0b376e4bfaa671 (patch)
tree939a938406d390131d2f8df08d80d12ee8cfd54a /lib/libpthread
parent083e8c787202aa28d2c15eab6c474f8fea87fb5d (diff)
downloadFreeBSD-src-7efe637f5aea25bb5a5edc7e5b0b376e4bfaa671.zip
FreeBSD-src-7efe637f5aea25bb5a5edc7e5b0b376e4bfaa671.tar.gz
Make sure calls to pthread_cancel() do not take effect if the target
thread is already exiting. PR: bin/37614 Reviewed by: deischen MFC after: 1 week
Diffstat (limited to 'lib/libpthread')
-rw-r--r--lib/libpthread/thread/thr_cancel.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/libpthread/thread/thr_cancel.c b/lib/libpthread/thread/thr_cancel.c
index cf72d89..b6b070f 100644
--- a/lib/libpthread/thread/thr_cancel.c
+++ b/lib/libpthread/thread/thr_cancel.c
@@ -20,7 +20,8 @@ _pthread_cancel(pthread_t pthread)
if ((ret = _find_thread(pthread)) != 0) {
/* NOTHING */
- } else if (pthread->state == PS_DEAD || pthread->state == PS_DEADLOCK) {
+ } else if (pthread->state == PS_DEAD || pthread->state == PS_DEADLOCK
+ || (pthread->flags & PTHREAD_EXITING) != 0) {
ret = 0;
} else {
/* Protect the scheduling queues: */
@@ -194,7 +195,8 @@ _pthread_testcancel(void)
struct pthread *curthread = _get_curthread();
if (((curthread->cancelflags & PTHREAD_CANCEL_DISABLE) == 0) &&
- ((curthread->cancelflags & PTHREAD_CANCELLING) != 0)) {
+ ((curthread->cancelflags & PTHREAD_CANCELLING) != 0) &&
+ ((curthread->flags & PTHREAD_EXITING) == 0)) {
/*
* It is possible for this thread to be swapped out
* while performing cancellation; do not allow it
OpenPOWER on IntegriCloud