svn commit: r204087 - head/sys/kern
Attilio Rao
attilio at FreeBSD.org
Fri Feb 19 14:59:42 UTC 2010
Author: attilio
Date: Fri Feb 19 14:59:41 2010
New Revision: 204087
URL: http://svn.freebsd.org/changeset/base/204087
Log:
Fix a race in regard of p_numthreads.
Submitted by: Giovanni Trematerra
<giovanni dot trematerra at gmail dot com>
Modified:
head/sys/kern/kern_kthread.c
Modified: head/sys/kern/kern_kthread.c
==============================================================================
--- head/sys/kern/kern_kthread.c Fri Feb 19 14:31:01 2010 (r204086)
+++ head/sys/kern/kern_kthread.c Fri Feb 19 14:59:41 2010 (r204087)
@@ -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();
}
More information about the svn-src-head
mailing list