Source-Changes-HG archive

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

[src/netbsd-9]: src/sys/kern Pull up following revision(s) (requested by hann...



details:   https://anonhg.NetBSD.org/src/rev/fa09131af2e7
branches:  netbsd-9
changeset: 988641:fa09131af2e7
user:      martin <martin%NetBSD.org@localhost>
date:      Fri Oct 08 14:58:08 2021 +0000

description:
Pull up following revision(s) (requested by hannken in ticket #1357):

        sys/kern/sys_pipe.c: revision 1.157

Fix a deadlock where one thread writes to a pipe, has more data
and no space in the pipe and waits on "pipe_wcv" while the reader
is closing the pipe and waits on "pipe_draincv".

Swap the test for "PIPE_EOF" and the "cv_wait_sig()" in "pipe_write()".

PR bin/56422 "zgrep -l sometimes hangs"

diffstat:

 sys/kern/sys_pipe.c |  15 ++++++++-------
 1 files changed, 8 insertions(+), 7 deletions(-)

diffs (43 lines):

diff -r 23a861dce4ec -r fa09131af2e7 sys/kern/sys_pipe.c
--- a/sys/kern/sys_pipe.c       Tue Oct 05 11:08:04 2021 +0000
+++ b/sys/kern/sys_pipe.c       Fri Oct 08 14:58:08 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sys_pipe.c,v 1.148 2019/04/26 17:24:23 mlelstv Exp $   */
+/*     $NetBSD: sys_pipe.c,v 1.148.2.1 2021/10/08 14:58:08 martin Exp $        */
 
 /*-
  * Copyright (c) 2003, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sys_pipe.c,v 1.148 2019/04/26 17:24:23 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_pipe.c,v 1.148.2.1 2021/10/08 14:58:08 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -1006,11 +1006,6 @@
                                break;
                        }
 
-                       pipeunlock(wpipe);
-                       error = cv_wait_sig(&wpipe->pipe_wcv, lock);
-                       (void)pipelock(wpipe, false);
-                       if (error != 0)
-                               break;
                        /*
                         * If read side wants to go away, we just issue a signal
                         * to ourselves.
@@ -1019,6 +1014,12 @@
                                error = EPIPE;
                                break;
                        }
+
+                       pipeunlock(wpipe);
+                       error = cv_wait_sig(&wpipe->pipe_wcv, lock);
+                       (void)pipelock(wpipe, false);
+                       if (error != 0)
+                               break;
                        wakeup_state = wpipe->pipe_state;
                }
        }



Home | Main Index | Thread Index | Old Index