[PATCH fifo 0/8] Allow a FIFO to have multiple writers

Ken Brown kbrown@cornell.edu
Fri Mar 22 19:30:00 GMT 2019

Currently a FIFO can have only one writer.  A second attempt to open
the FIFO for writing blocks while fhandler_fifo::open waits for the
read_ready event to be signalled.

This patch series tries to fix the problem by having the reader open
multiple instances of the Windows named pipe underlying the FIFO.
When the FIFO is opened for reading, a 'listen_client' thread is
created that listens for clients (writers) to connect to the pipe.  It
creates new pipe instances as needed.

fhandler_fifo::raw_read loops through the connected writers, checking
for input.

I've tested it by running the fifo client and server programs from
Chapter 44 of the book "The Linux Programming Interface: Linux and
UNIX System Programming Handbook" by Michael Kerrisk.  (See
https://cygwin.com/ml/cygwin/2015-03/msg00047.html for simplified
versions of these programs.)  These work as on Linux.

I've also tried the test given in
http://www.cygwin.org/ml/cygwin/2015-12/msg00311.html.  It works as on
Linux also.


 - Try to get the code to work for duplexers (FIFOs opened for reading
   and writing).  I haven't thought about this at all yet.

 - Think about what it would take to allow multiple readers.  I'm not
   very optimistic about this, but my impression is that the
   multiple-writer case is more important in practice.


Ken Brown (8):
  Cygwin: FIFO: stop using overlapped I/O
  Cygwin: FIFO: allow multiple writers
  Cygwin: FIFO: add a spinlock
  Cygwin: FIFO: improve EOF detection
  Cygwin: FIFO: update clone and dup
  Cygwin: FIFO: update fixup_after_fork
  Cygwin: FIFO: update set_close_on_exec
  Cygwin: FIFO: update select

 winsup/cygwin/fhandler.h       |  58 ++-
 winsup/cygwin/fhandler_fifo.cc | 732 +++++++++++++++++++++++++++------
 winsup/cygwin/select.cc        | 161 +++++++-
 winsup/cygwin/select.h         |   7 +
 4 files changed, 819 insertions(+), 139 deletions(-)


More information about the Cygwin-patches mailing list