Source-Changes archive

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

CVS commit: src



Module Name:    src
Committed By:   riastradh
Date:           Sat Oct  3 16:23:18 UTC 2026

Modified Files:
        src/sys/kern: sys_pipe.c
        src/tests/kernel: t_fdrestart.c

Log Message:
pipe(2): Fix wakeup of pending writers on close of write side.

The job of pipe_restart is to wake any pending I/O operations on the
file when it is about to be closed.  New references cannot be taken
for new I/O operations; once all existing references are drained, the
system calls pipe_close.

What pipe_restart did was to wake pipe->pipe_rcv and pipe->pipe_wcv.
But the condvars of _which pipe_?

After renaming the variables to match reality, it becomes clear that
wpipe->pipe_wcv and wpipe->pipe_rcv are never used -- instead,
pipe_read waits for rpipe->pipe_rcv, and pipe_write waits for
rpipe->pipe_wcv.  So pipe_restart on the write side of a pipe woke
wpipe->pipe_rcv and wpipe->pipe_wcv, which nothing was waiting for,
and failed to wake rpipe->pipe_rcv or rpipe->pipe_wcv.

(Perhaps we should just have a single struct pipe::pipe_cv member,
and have pipe_read use rpipe->pipe_cv and pipe_write use
wpipe->pipe_cv.  But that will be left for future cleanup.)

PR kern/57659: closing pipe writefd fails to wake concurrent write on
same writefd


To generate a diff of this commit:
cvs rdiff -u -r1.170 -r1.171 src/sys/kern/sys_pipe.c
cvs rdiff -u -r1.11 -r1.12 src/tests/kernel/t_fdrestart.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