summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_thread.c
diff options
context:
space:
mode:
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