Fix a race in regard of p_numthreads.

Submitted by:	Giovanni Trematerra
		<giovanni dot trematerra at gmail dot com>
This commit is contained in:
Attilio Rao 2010-02-19 14:59:41 +00:00
parent 5f1f6da8ba
commit dd55eec791
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=204087

View File

@ -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();
}