svn commit: r233919 - stable/9/sys/kern

Konstantin Belousov kib at FreeBSD.org
Thu Apr 5 10:30:55 UTC 2012


Author: kib
Date: Thu Apr  5 10:30:54 2012
New Revision: 233919
URL: http://svn.freebsd.org/changeset/base/233919

Log:
  MFC r233808:
  Add helper function to remove the process from the orphans list and
  use it instead of inlined code.

Modified:
  stable/9/sys/kern/kern_exit.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/kern/kern_exit.c
==============================================================================
--- stable/9/sys/kern/kern_exit.c	Thu Apr  5 07:59:59 2012	(r233918)
+++ stable/9/sys/kern/kern_exit.c	Thu Apr  5 10:30:54 2012	(r233919)
@@ -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;


More information about the svn-src-stable-9 mailing list