summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2007-11-15 21:45:17 +0000
committerjhb <jhb@FreeBSD.org>2007-11-15 21:45:17 +0000
commitb113160d81ef70bc2778ca6510430e65ba9232f3 (patch)
tree3d4d6b6558cfa162d14014d0850b29241cded7ac
parentc54a45c99ce2687a35d5744ae2c51ec790a3a2ef (diff)
downloadFreeBSD-src-b113160d81ef70bc2778ca6510430e65ba9232f3.zip
FreeBSD-src-b113160d81ef70bc2778ca6510430e65ba9232f3.tar.gz
Acquire the process mutex and spin locks before calling thread_exit() in
kthread_exit() to fix panics when using INVARIANTS.
-rw-r--r--sys/kern/kern_kthread.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/sys/kern/kern_kthread.c b/sys/kern/kern_kthread.c
index 532b3c2..ed74774 100644
--- a/sys/kern/kern_kthread.c
+++ b/sys/kern/kern_kthread.c
@@ -317,14 +317,21 @@ kthread_add(void (*func)(void *), void *arg, struct proc *p,
void
kthread_exit(void)
{
- /* a module may be waiting for us to exit */
+ struct proc *p;
+
+ /* A module may be waiting for us to exit. */
wakeup(curthread);
+
/*
* We could rely on thread_exit to call exit1() but
* there is extra work that needs to be done
*/
if (curthread->td_proc->p_numthreads == 1)
kproc_exit(0); /* never returns */
+
+ p = curthread->td_proc;
+ PROC_LOCK(p);
+ PROC_SLOCK(p);
thread_exit();
}
OpenPOWER on IntegriCloud