diff options
author | 2002-05-07 05:13:17 +0000 | |
---|---|---|
committer | 2002-05-07 05:13:17 +0000 | |
commit | 6572e59fcc5940f68e53bae6a9793e928f263af5 (patch) | |
tree | 49729198d4b94ca2cb03f88af413e5477cf6103f | |
parent | All architectures now use miniroot, so eliminate last few getresp() (diff) | |
download | wireguard-openbsd-6572e59fcc5940f68e53bae6a9793e928f263af5.tar.xz wireguard-openbsd-6572e59fcc5940f68e53bae6a9793e928f263af5.zip |
Make sure calls to pthread_cancel() do not take effect if the target
thread is already exiting, from archie@FreeBSD, ok fgs
-rw-r--r-- | lib/libc_r/uthread/uthread_cancel.c | 8 | ||||
-rw-r--r-- | lib/libpthread/uthread/uthread_cancel.c | 8 |
2 files changed, 10 insertions, 6 deletions
diff --git a/lib/libc_r/uthread/uthread_cancel.c b/lib/libc_r/uthread/uthread_cancel.c index 23c960d98b8..b08702ce857 100644 --- a/lib/libc_r/uthread/uthread_cancel.c +++ b/lib/libc_r/uthread/uthread_cancel.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uthread_cancel.c,v 1.12 2002/03/07 23:05:10 fgsch Exp $ */ +/* $OpenBSD: uthread_cancel.c,v 1.13 2002/05/07 05:13:17 pvalchev Exp $ */ /* * David Leonard <d@openbsd.org>, 1999. Public domain. */ @@ -15,7 +15,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: */ @@ -190,7 +191,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 diff --git a/lib/libpthread/uthread/uthread_cancel.c b/lib/libpthread/uthread/uthread_cancel.c index 23c960d98b8..b08702ce857 100644 --- a/lib/libpthread/uthread/uthread_cancel.c +++ b/lib/libpthread/uthread/uthread_cancel.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uthread_cancel.c,v 1.12 2002/03/07 23:05:10 fgsch Exp $ */ +/* $OpenBSD: uthread_cancel.c,v 1.13 2002/05/07 05:13:17 pvalchev Exp $ */ /* * David Leonard <d@openbsd.org>, 1999. Public domain. */ @@ -15,7 +15,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: */ @@ -190,7 +191,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 |