diff options
author | attilio <attilio@FreeBSD.org> | 2010-02-19 14:59:41 +0000 |
---|---|---|
committer | attilio <attilio@FreeBSD.org> | 2010-02-19 14:59:41 +0000 |
commit | 56877714595f92a6c8ee701d82e7d1377b50e349 (patch) | |
tree | ef5d1809aceb5be3696c83b86950ce8f3a4136fd | |
parent | e2e4685935bccf21629efeb6947f54dd998fc4c5 (diff) | |
download | FreeBSD-src-56877714595f92a6c8ee701d82e7d1377b50e349.zip FreeBSD-src-56877714595f92a6c8ee701d82e7d1377b50e349.tar.gz |
Fix a race in regard of p_numthreads.
Submitted by: Giovanni Trematerra
<giovanni dot trematerra at gmail dot com>
-rw-r--r-- | sys/kern/kern_kthread.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/sys/kern/kern_kthread.c b/sys/kern/kern_kthread.c index 5809d14..86a37e6 100644 --- a/sys/kern/kern_kthread.c +++ b/sys/kern/kern_kthread.c @@ -312,18 +312,17 @@ kthread_exit(void) { struct proc *p; + p = curthread->td_proc; + /* 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); + if (curthread->td_proc->p_numthreads == 1) { + PROC_UNLOCK(p); + kproc_exit(0); + + /* NOTREACHED. */ + } PROC_SLOCK(p); thread_exit(); } |