Author: mjg
Date: Wed Jan 20 23:22:36 2016
New Revision: 294468
URL: https://svnweb.freebsd.org/changeset/base/294468

Log:
  session: tidy up fixjobc
  
  This stops abusing the 'p' pointer for iteration over children processes
  and gets rid of useless locking around PRS_ZOMBIE check.
  
  Suggested by: kib

Modified:
  head/sys/kern/kern_proc.c

Modified: head/sys/kern/kern_proc.c
==============================================================================
--- head/sys/kern/kern_proc.c   Wed Jan 20 23:11:58 2016        (r294467)
+++ head/sys/kern/kern_proc.c   Wed Jan 20 23:22:36 2016        (r294468)
@@ -650,13 +650,11 @@ pgadjustjobc(pgrp, entering)
  * entering == 1 => p is entering specified group.
  */
 void
-fixjobc(p, pgrp, entering)
-       register struct proc *p;
-       register struct pgrp *pgrp;
-       int entering;
+fixjobc(struct proc *p, struct pgrp *pgrp, int entering)
 {
-       register struct pgrp *hispgrp;
-       register struct session *mysession;
+       struct pgrp *hispgrp;
+       struct session *mysession;
+       struct proc *q;
 
        sx_assert(&proctree_lock, SX_LOCKED);
        PROC_LOCK_ASSERT(p, MA_NOTOWNED);
@@ -677,17 +675,13 @@ fixjobc(p, pgrp, entering)
         * their process groups; if so, adjust counts for children's
         * process groups.
         */
-       LIST_FOREACH(p, &p->p_children, p_sibling) {
-               hispgrp = p->p_pgrp;
+       LIST_FOREACH(q, &p->p_children, p_sibling) {
+               hispgrp = q->p_pgrp;
                if (hispgrp == pgrp ||
                    hispgrp->pg_session != mysession)
                        continue;
-               PROC_LOCK(p);
-               if (p->p_state == PRS_ZOMBIE) {
-                       PROC_UNLOCK(p);
+               if (q->p_state == PRS_ZOMBIE)
                        continue;
-               }
-               PROC_UNLOCK(p);
                pgadjustjobc(hispgrp, entering);
        }
 }
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to