NetBSD-Bugs archive

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

PR/59056 CVS commit: src/sys/kern



The following reply was made to PR kern/59056; it has been noted by GNATS.

From: "Taylor R Campbell" <riastradh%netbsd.org@localhost>
To: gnats-bugs%gnats.NetBSD.org@localhost
Cc: 
Subject: PR/59056 CVS commit: src/sys/kern
Date: Sat, 3 Oct 2026 16:23:46 +0000

 Module Name:	src
 Committed By:	riastradh
 Date:		Sat Oct  3 16:23:46 UTC 2026
 
 Modified Files:
 	src/sys/kern: sys_pipe.c
 
 Log Message:
 pipe(2): Make pipe sides a little more symmetric.
 
 1. When reading from or writing to a pipe, busy _this side_ of the
    pipe, not the other side.
 
 2. In pipeclose, all operations on _this side_ of the pipe have already
    quiesced.  But operations on the other side may not have.  So wait
    for the _other side_ to be unbusied before disconnecting the peer
    (changing ppipe->pipe_peer from pipe to NULL).
 
 With (1) and (2) we can prove a simple property that makes reasoning
 about this code easier: If a pipe is busy, its peer pointer is stable
 even across cv_wait on the pipe lock.  Without these changes I'm not
 sure I could prove that property (though I haven't exhibited a
 reproducer for any issues arising from its failure).
 
 3. Make write wait on wpipe->pipe_wcv, and make read wait on
    rpipe->pipe_rcv, consistently, so that any waiters on one side of a
    pipe will always be waiting on one of _that side's_ condvars.
 
    This makes the logic in pipe_restart to wake any pending operations
    on _this side_ simpler -- it doesn't have to reach over to the peer,
    and it doesn't have to inadvertently wake the peer for no reason.
 
    In fact this brings the text of the code in pipe_restart back to
    what it was before I renamed the variables to reflect their actual
    content, suggesting there has been some confusion from the variable
    naming over the years...
 
    (In a future change, I would like to merge pipe_rcv and pipe_wcv
    into a single condvar per side -- no need to initialize two extra
    condvars per pipe that will never be used!)
 
 Preparation for:
 
 PR kern/59056: poll POLLHUP bugs
 
 
 To generate a diff of this commit:
 cvs rdiff -u -r1.171 -r1.172 src/sys/kern/sys_pipe.c
 
 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.
 



Home | Main Index | Thread Index | Old Index