Source-Changes-HG archive

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

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



details:   https://anonhg.NetBSD.org/src/rev/16ccc759fc38
branches:  netbsd-8
changeset: 450970:16ccc759fc38
user:      martin <martin%NetBSD.org@localhost>
date:      Wed May 01 14:51:17 2019 +0000

description:
Pull up following revision(s) (requested by mlelstv in ticket #1253):

        sys/kern/sys_pipe.c: revision 1.147
        sys/kern/sys_pipe.c: revision 1.148

Clean up pipe structure before recycling it.

Handle half-closed pipes in FIONWRITE and FIONSPACE.

diffstat:

 sys/kern/sys_pipe.c |  17 ++++++++++++-----
 1 files changed, 12 insertions(+), 5 deletions(-)

diffs (55 lines):

diff -r 4b764d596fa1 -r 16ccc759fc38 sys/kern/sys_pipe.c
--- a/sys/kern/sys_pipe.c       Wed May 01 09:13:31 2019 +0000
+++ b/sys/kern/sys_pipe.c       Wed May 01 14:51:17 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sys_pipe.c,v 1.140 2014/09/05 09:20:59 matt Exp $      */
+/*     $NetBSD: sys_pipe.c,v 1.140.12.1 2019/05/01 14:51:17 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.140 2014/09/05 09:20:59 matt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sys_pipe.c,v 1.140.12.1 2019/05/01 14:51:17 martin Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -1107,10 +1107,12 @@
 
        case FIONWRITE:
                /* Look at other side */
+               mutex_enter(lock);
                pipe = pipe->pipe_peer;
-               mutex_enter(lock);
+               if (pipe == NULL)
+                       *(int *)data = 0;
 #ifndef PIPE_NODIRECT
-               if (pipe->pipe_state & PIPE_DIRECTW)
+               else if (pipe->pipe_state & PIPE_DIRECTW)
                        *(int *)data = pipe->pipe_map.cnt;
                else
 #endif
@@ -1120,8 +1122,11 @@
 
        case FIONSPACE:
                /* Look at other side */
+               mutex_enter(lock);
                pipe = pipe->pipe_peer;
-               mutex_enter(lock);
+               if (pipe == NULL)
+                       *(int *)data = 0;
+               else
 #ifndef PIPE_NODIRECT
                /*
                 * If we're in direct-mode, we don't really have a
@@ -1346,6 +1351,8 @@
     free_resources:
        pipe->pipe_pgid = 0;
        pipe->pipe_state = PIPE_SIGNALR;
+       pipe->pipe_peer = NULL;
+       pipe->pipe_lock = NULL;
        pipe_free_kmem(pipe);
        if (pipe->pipe_kmem != 0) {
                pool_cache_put(pipe_rd_cache, pipe);



Home | Main Index | Thread Index | Old Index