summaryrefslogtreecommitdiffstats
path: root/lib/libc_r/uthread/uthread_cancel.c
diff options
context:
space:
mode:
authorjasone <jasone@FreeBSD.org>2000-06-14 17:17:41 +0000
committerjasone <jasone@FreeBSD.org>2000-06-14 17:17:41 +0000
commit9f479e9f39861a77981b3e6234e796caa25cfe0f (patch)
tree25b4c819ee7794359e6c426e91cd15c2c56a2f49 /lib/libc_r/uthread/uthread_cancel.c
parentcc22f14b179a55f7686e798febd938bfef76c982 (diff)
downloadFreeBSD-src-9f479e9f39861a77981b3e6234e796caa25cfe0f.zip
FreeBSD-src-9f479e9f39861a77981b3e6234e796caa25cfe0f.tar.gz
pthread_mutex_lock(), pthread_cond_trywait(), and pthread_cond_wait() are
not allowed to return EINTR, but use of pthread_suspend_np() could cause EINTR to be returned. To fix this, restructure pthread_suspend_np() so that it does not interrupt a thread that is waiting on a mutex or condition, and keep enough state around that pthread_resume_np() can fix things up afterwards. Reviewed by: deischen
Diffstat (limited to 'lib/libc_r/uthread/uthread_cancel.c')
-rw-r--r--lib/libc_r/uthread/uthread_cancel.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/lib/libc_r/uthread/uthread_cancel.c b/lib/libc_r/uthread/uthread_cancel.c
index 82ddbb8..c6df52e 100644
--- a/lib/libc_r/uthread/uthread_cancel.c
+++ b/lib/libc_r/uthread/uthread_cancel.c
@@ -37,15 +37,6 @@ pthread_cancel(pthread_t pthread)
pthread->cancelflags |= PTHREAD_CANCELLING;
break;
- case PS_SUSPENDED:
- /*
- * This thread isn't in any scheduling
- * queues; just change it's state:
- */
- pthread->cancelflags |= PTHREAD_CANCELLING;
- PTHREAD_SET_STATE(pthread, PS_RUNNING);
- break;
-
case PS_SPINBLOCK:
case PS_FDR_WAIT:
case PS_FDW_WAIT:
@@ -67,6 +58,20 @@ pthread_cancel(pthread_t pthread)
PTHREAD_NEW_STATE(pthread,PS_RUNNING);
break;
+ case PS_SUSPENDED:
+ if (pthread->suspended == SUSP_NO ||
+ pthread->suspended == SUSP_YES ||
+ pthread->suspended == SUSP_NOWAIT) {
+ /*
+ * This thread isn't in any scheduling
+ * queues; just change it's state:
+ */
+ pthread->cancelflags |=
+ PTHREAD_CANCELLING;
+ PTHREAD_SET_STATE(pthread, PS_RUNNING);
+ break;
+ }
+ /* FALLTHROUGH */
case PS_MUTEX_WAIT:
case PS_COND_WAIT:
case PS_FDLR_WAIT:
OpenPOWER on IntegriCloud