summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_kthread.c
diff options
context:
space:
mode:
authorattilio <attilio@FreeBSD.org>2010-02-19 14:59:41 +0000
committerattilio <attilio@FreeBSD.org>2010-02-19 14:59:41 +0000
commit56877714595f92a6c8ee701d82e7d1377b50e349 (patch)
treeef5d1809aceb5be3696c83b86950ce8f3a4136fd /sys/kern/kern_kthread.c
parente2e4685935bccf21629efeb6947f54dd998fc4c5 (diff)
downloadFreeBSD-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>
Diffstat (limited to 'sys/kern/kern_kthread.c')
-rw-r--r--sys/kern/kern_kthread.c17
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();
}
OpenPOWER on IntegriCloud