diff options
author | jhb <jhb@FreeBSD.org> | 2007-11-15 21:45:17 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2007-11-15 21:45:17 +0000 |
commit | b113160d81ef70bc2778ca6510430e65ba9232f3 (patch) | |
tree | 3d4d6b6558cfa162d14014d0850b29241cded7ac /sys/kern/kern_kthread.c | |
parent | c54a45c99ce2687a35d5744ae2c51ec790a3a2ef (diff) | |
download | FreeBSD-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.
Diffstat (limited to 'sys/kern/kern_kthread.c')
-rw-r--r-- | sys/kern/kern_kthread.c | 9 |
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(); } |