From owner-svn-src-all@FreeBSD.ORG Fri Feb 19 14:59:42 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 44DAD106566B; Fri, 19 Feb 2010 14:59:42 +0000 (UTC) (envelope-from attilio@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 346218FC0A; Fri, 19 Feb 2010 14:59:42 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o1JExgaC017501; Fri, 19 Feb 2010 14:59:42 GMT (envelope-from attilio@svn.freebsd.org) Received: (from attilio@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o1JExgvV017499; Fri, 19 Feb 2010 14:59:42 GMT (envelope-from attilio@svn.freebsd.org) Message-Id: <201002191459.o1JExgvV017499@svn.freebsd.org> From: Attilio Rao Date: Fri, 19 Feb 2010 14:59:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r204087 - head/sys/kern X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 19 Feb 2010 14:59:42 -0000 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 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(); }