summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_thread.c
diff options
context:
space:
mode:
authordavidxu <davidxu@FreeBSD.org>2002-11-14 06:06:45 +0000
committerdavidxu <davidxu@FreeBSD.org>2002-11-14 06:06:45 +0000
commitaabe0b2183ab18738e1b5761a4251a12305a17b1 (patch)
treea28878d82317bd91174b76450cccbee4a6859e3c /sys/kern/kern_thread.c
parentc953e0308c9b346d10a8f11ad9872a82b579f1b8 (diff)
downloadFreeBSD-src-aabe0b2183ab18738e1b5761a4251a12305a17b1.zip
FreeBSD-src-aabe0b2183ab18738e1b5761a4251a12305a17b1.tar.gz
In kse_release(), check if current thread is bound
and current kse mailbox was already initialized, also prevent last thread from exiting unless we figure out how to safely support null thread proc.
Diffstat (limited to 'sys/kern/kern_thread.c')
-rw-r--r--sys/kern/kern_thread.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/sys/kern/kern_thread.c b/sys/kern/kern_thread.c
index 078a6e9..93ead67 100644
--- a/sys/kern/kern_thread.c
+++ b/sys/kern/kern_thread.c
@@ -341,12 +341,24 @@ kse_release(struct thread *td, struct kse_release_args *uap)
struct proc *p;
p = td->td_proc;
- /* KSE-enabled processes only, please. */
- if (p->p_flag & P_KSES) {
+ /* KSE-enabled processes only */
+ if (!(p->p_flag & P_KSES))
+ return (EINVAL);
+ /*
+ * Must be a bound thread. And kse must have a mailbox ready,
+ * if not, the kse would can not generate an upcall.
+ */
+ if (!(td->td_flags & TDF_UNBOUND) && (td->td_kse->ke_mailbox != NULL)) {
PROC_LOCK(p);
mtx_lock_spin(&sched_lock);
- thread_exit();
- /* NOTREACHED */
+ /* prevent last thread from exiting */
+ if (p->p_numthreads > 1) {
+ thread_exit();
+ /* NOTREACHED */
+ } else {
+ mtx_unlock_spin(&sched_lock);
+ PROC_UNLOCK(p);
+ }
}
return (EINVAL);
}
OpenPOWER on IntegriCloud