Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 19 Feb 2010 14:59:42 +0000 (UTC)
From:      Attilio Rao <attilio@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r204087 - head/sys/kern
Message-ID:  <201002191459.o1JExgvV017499@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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();
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201002191459.o1JExgvV017499>