From owner-svn-src-all@FreeBSD.ORG Mon Apr 2 19:34:57 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 48F9E1065674; Mon, 2 Apr 2012 19:34:57 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 34E098FC15; Mon, 2 Apr 2012 19:34:57 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q32JYvpv013590; Mon, 2 Apr 2012 19:34:57 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q32JYuFE013588; Mon, 2 Apr 2012 19:34:57 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201204021934.q32JYuFE013588@svn.freebsd.org> From: Konstantin Belousov Date: Mon, 2 Apr 2012 19:34:56 +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: r233808 - 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: Mon, 02 Apr 2012 19:34:57 -0000 Author: kib Date: Mon Apr 2 19:34:56 2012 New Revision: 233808 URL: http://svn.freebsd.org/changeset/base/233808 Log: Add helper function to remove the process from the orphans list and use it instead of inlined code. Tested by: pho MFC after: 3 days Modified: head/sys/kern/kern_exit.c Modified: head/sys/kern/kern_exit.c ============================================================================== --- head/sys/kern/kern_exit.c Mon Apr 2 19:17:01 2012 (r233807) +++ head/sys/kern/kern_exit.c Mon Apr 2 19:34:56 2012 (r233808) @@ -100,6 +100,18 @@ SDT_PROBE_ARGTYPE(proc, kernel, , exit, /* Hook for NFS teardown procedure. */ void (*nlminfo_release_p)(struct proc *p); +static void +clear_orphan(struct proc *p) +{ + + PROC_LOCK_ASSERT(p, MA_OWNED); + + if (p->p_flag & P_ORPHAN) { + LIST_REMOVE(p, p_orphan); + p->p_flag &= ~P_ORPHAN; + } +} + /* * exit -- death of process. */ @@ -739,10 +751,7 @@ proc_reap(struct thread *td, struct proc sx_xunlock(&allproc_lock); LIST_REMOVE(p, p_sibling); PROC_LOCK(p); - if (p->p_flag & P_ORPHAN) { - LIST_REMOVE(p, p_orphan); - p->p_flag &= ~P_ORPHAN; - } + clear_orphan(p); PROC_UNLOCK(p); leavepgrp(p); #ifdef PROCDESC @@ -987,10 +996,7 @@ proc_reparent(struct proc *child, struct LIST_REMOVE(child, p_sibling); LIST_INSERT_HEAD(&parent->p_children, child, p_sibling); - if (child->p_flag & P_ORPHAN) { - LIST_REMOVE(child, p_orphan); - child->p_flag &= ~P_ORPHAN; - } + clear_orphan(child); if (child->p_flag & P_TRACED) { LIST_INSERT_HEAD(&child->p_pptr->p_orphans, child, p_orphan); child->p_flag |= P_ORPHAN;