Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern revert racy vfork() parent-blocking-before-child-ex...



details:   https://anonhg.NetBSD.org/src/rev/937ba85ecc7b
branches:  trunk
changeset: 780514:937ba85ecc7b
user:      christos <christos%NetBSD.org@localhost>
date:      Fri Jul 27 20:52:49 2012 +0000

description:
revert racy vfork() parent-blocking-before-child-execs-or-exits code.
ok rmind

diffstat:

 sys/kern/kern_exec.c |  12 ++++++++++--
 sys/kern/kern_exit.c |  10 ++++++++--
 sys/kern/kern_fork.c |   9 +++++++--
 3 files changed, 25 insertions(+), 6 deletions(-)

diffs (111 lines):

diff -r 705497a3227e -r 937ba85ecc7b sys/kern/kern_exec.c
--- a/sys/kern/kern_exec.c      Fri Jul 27 20:49:48 2012 +0000
+++ b/sys/kern/kern_exec.c      Fri Jul 27 20:52:49 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_exec.c,v 1.353 2012/07/22 22:40:19 rmind Exp $    */
+/*     $NetBSD: kern_exec.c,v 1.354 2012/07/27 20:52:49 christos Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -59,7 +59,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.353 2012/07/22 22:40:19 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.354 2012/07/27 20:52:49 christos Exp $");
 
 #include "opt_exec.h"
 #include "opt_ktrace.h"
@@ -1180,6 +1180,7 @@
         * exited and exec()/exit() are the only places it will be cleared.
         */
        if ((p->p_lflag & PL_PPWAIT) != 0) {
+#if 0
                lwp_t *lp;
 
                mutex_enter(proc_lock);
@@ -1192,6 +1193,13 @@
                lp->l_pflag &= ~LP_VFORKWAIT; /* XXX */
                cv_broadcast(&lp->l_waitcv);
                mutex_exit(proc_lock);
+#else
+               mutex_enter(proc_lock);
+               l->l_lwpctl = NULL; /* was on loan from blocked parent */
+               p->p_lflag &= ~PL_PPWAIT;
+               cv_broadcast(&p->p_pptr->p_waitcv);
+               mutex_exit(proc_lock);
+#endif
        }
 
        /*
diff -r 705497a3227e -r 937ba85ecc7b sys/kern/kern_exit.c
--- a/sys/kern/kern_exit.c      Fri Jul 27 20:49:48 2012 +0000
+++ b/sys/kern/kern_exit.c      Fri Jul 27 20:52:49 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_exit.c,v 1.239 2012/07/22 22:40:19 rmind Exp $    */
+/*     $NetBSD: kern_exit.c,v 1.240 2012/07/27 20:52:49 christos Exp $ */
 
 /*-
  * Copyright (c) 1998, 1999, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_exit.c,v 1.239 2012/07/22 22:40:19 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_exit.c,v 1.240 2012/07/27 20:52:49 christos Exp $");
 
 #include "opt_ktrace.h"
 #include "opt_perfctrs.h"
@@ -330,6 +330,7 @@
         */
        mutex_enter(proc_lock);
        if (p->p_lflag & PL_PPWAIT) {
+#if 0
                lwp_t *lp;
 
                l->l_lwpctl = NULL; /* was on loan from blocked parent */
@@ -339,6 +340,11 @@
                p->p_vforklwp = NULL;
                lp->l_pflag &= ~LP_VFORKWAIT; /* XXX */
                cv_broadcast(&lp->l_waitcv);
+#else
+               l->l_lwpctl = NULL; /* was on loan from blocked parent */
+               p->p_lflag &= ~PL_PPWAIT;
+               cv_broadcast(&p->p_pptr->p_waitcv);
+#endif
        }
 
        if (SESS_LEADER(p)) {
diff -r 705497a3227e -r 937ba85ecc7b sys/kern/kern_fork.c
--- a/sys/kern/kern_fork.c      Fri Jul 27 20:49:48 2012 +0000
+++ b/sys/kern/kern_fork.c      Fri Jul 27 20:52:49 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_fork.c,v 1.190 2012/07/22 22:40:19 rmind Exp $    */
+/*     $NetBSD: kern_fork.c,v 1.191 2012/07/27 20:52:49 christos Exp $ */
 
 /*-
  * Copyright (c) 1999, 2001, 2004, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_fork.c,v 1.190 2012/07/22 22:40:19 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_fork.c,v 1.191 2012/07/27 20:52:49 christos Exp $");
 
 #include "opt_ktrace.h"
 
@@ -587,9 +587,14 @@
         * Preserve synchronization semantics of vfork.  If waiting for
         * child to exec or exit, sleep until it clears LP_VFORKWAIT.
         */
+#if 0
        while (l1->l_pflag & LP_VFORKWAIT) {
                cv_wait(&l1->l_waitcv, proc_lock);
        }
+#else
+       while (p2->p_lflag & PL_PPWAIT)
+               cv_wait(&p1->p_waitcv, proc_lock);
+#endif
 
        /*
         * Let the parent know that we are tracing its child.



Home | Main Index | Thread Index | Old Index