diff options
author | Federico G. Schwindt <fgsch@cvs.openbsd.org> | 2001-12-11 00:19:48 +0000 |
---|---|---|
committer | Federico G. Schwindt <fgsch@cvs.openbsd.org> | 2001-12-11 00:19:48 +0000 |
commit | df4b52670da644e7bd952242b6d1e8f6fcd0c5b2 (patch) | |
tree | 362f2780fa4da1e285ed537b8a08e2eccf119a0b /lib/libpthread/uthread/uthread_cancel.c | |
parent | d9bad47758857d3344bedc12dff936f73958442f (diff) |
More sync with freebsd code; join related code this time.
Diffstat (limited to 'lib/libpthread/uthread/uthread_cancel.c')
-rw-r--r-- | lib/libpthread/uthread/uthread_cancel.c | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/lib/libpthread/uthread/uthread_cancel.c b/lib/libpthread/uthread/uthread_cancel.c index b536acc4b8e..8c8515dbbc7 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.7 2001/12/08 14:51:36 fgsch Exp $ */ +/* $OpenBSD: uthread_cancel.c,v 1.8 2001/12/11 00:19:47 fgsch Exp $ */ /* * David Leonard <d@openbsd.org>, 1999. Public domain. */ @@ -6,7 +6,6 @@ #include <pthread.h> #include "pthread_private.h" - static void finish_cancellation(void *arg); int @@ -44,6 +43,7 @@ pthread_cancel(pthread) case PS_FDW_WAIT: case PS_POLL_WAIT: case PS_SELECT_WAIT: + /* Remove these threads from the work queue: */ if ((pthread->flags & PTHREAD_FLAGS_IN_WORKQ) != 0) PTHREAD_WORKQ_REMOVE(pthread); @@ -71,6 +71,19 @@ pthread_cancel(pthread) break; case PS_JOIN: + /* + * Disconnect the thread from the joinee and + * detach: + */ + if (pthread->data.thread != NULL) { + pthread->data.thread->joiner = NULL; + pthread_detach((pthread_t) + pthread->data.thread); + } + pthread->cancelflags |= PTHREAD_CANCELLING; + PTHREAD_NEW_STATE(pthread, PS_RUNNING); + break; + case PS_SUSPENDED: /* Simply wake: */ /* XXX may be incorrect */ @@ -165,6 +178,11 @@ pthread_testcancel() if (((curthread->cancelflags & PTHREAD_CANCEL_DISABLE) == 0) && ((curthread->cancelflags & PTHREAD_CANCELLING) != 0)) { + /* + * It is possible for this thread to be swapped out + * while performing cancellation; do not allow it + * to be cancelled again. + */ curthread->cancelflags &= ~PTHREAD_CANCELLING; #ifdef notyet _thread_exit_cleanup(); |