public inbox for cygwin-patches@cygwin.com
 help / color / mirror / Atom feed
* [PATCH 00/21] FIFO: Support multiple readers
@ 2020-05-07 20:21 Ken Brown
  2020-05-07 20:21 ` [PATCH 01/21] Cygwin: FIFO: minor change - use NtClose Ken Brown
                   ` (22 more replies)
  0 siblings, 23 replies; 33+ messages in thread
From: Ken Brown @ 2020-05-07 20:21 UTC (permalink / raw)
  To: cygwin-patches; +Cc: sten.kristian.ivarsson

This project began as a an attempt to allow a FIFO to be opened
multiple times for reading.  The initial motivation was that Midnight
Commander running under tcsh does this (unsuccessfully on Cygwin).
See

   https://sourceware.org/pipermail/cygwin/2019-December/243317.html

It quickly became apparent, however, that the current code doesn't
even properly handle the case where the FIFO is *explicitly* opened
only once for reading, but additional readers are created via
dup/fork/exec.

This explained some of the bugs reported by Kristian Ivarsson.  See,
for example, the thread starting here:

  https://sourceware.org/pipermail/cygwin/2020-March/000206.html

as well as later similar threads.

[The discussion continued in private email, with many bug reports and
test programs by Kristian.  I'm very grateful to him for his reports
and testing.]

The first 10 patches in this series make some improvements and bug
fixes that came up along the way and don't specifically relate to
multiple readers.  The next 10 patches, with the exception of "allow
fc_handler list to grow dynamically", add the support for multiple
readers.  The last one updates the commentary at the beginning of
fhandler_fifo.cc that tries to explain how it all works.

The key ideas in these patches are:

1. Use shared memory, so that all readers have the necessary
information about the writers that are open.

2. Designate one reader as the "owner".  This reader runs a thread
that listens for connections and keeps track of the writers.

3. Use a second shared memory block to be used for transfer of
ownership.  Ownership must be transferred when the owner closes or
execs.  And a reader that wants to read or run select must take
ownership in order to be able to poll the writers for input.

The patches in this series have been applied to the topic/fifo branch
in case it's easier to review/test them there.

Ken Brown (21):
  Cygwin: FIFO: minor change - use NtClose
  Cygwin: FIFO: simplify the fifo_client_handler structure
  Cygwin: FIFO: change the fifo_client_connect_state enum
  Cygwin: FIFO: simplify the listen_client_thread code
  Cygwin: FIFO: remove the arm method
  Cygwin: FIFO: honor the flags argument in dup
  Cygwin: FIFO: dup/fork/exec: make sure child starts unlocked
  Cygwin: FIFO: fix hit_eof
  Cygwin: FIFO: make opening a writer more robust
  Cygwin: FIFO: use a cygthread instead of a homemade thread
  Cygwin: FIFO: add shared memory
  Cygwin: FIFO: keep track of the number of readers
  Cygwin: FIFO: introduce a new type, fifo_reader_id_t
  Cygwin: FIFO: designate one reader as owner
  Cygwin: FIFO: allow fc_handler list to grow dynamically
  Cygwin: FIFO: add a shared fifo_client_handler list
  Cygwin: FIFO: take ownership on exec
  Cygwin: FIFO: find a new owner when closing
  Cygwin: FIFO: allow any reader to take ownership
  Cygwin: FIFO: support opening multiple readers
  Cygwin: FIFO: update commentary

 winsup/cygwin/fhandler.h       |  208 ++++-
 winsup/cygwin/fhandler_fifo.cc | 1564 ++++++++++++++++++++++----------
 winsup/cygwin/select.cc        |   48 +-
 3 files changed, 1311 insertions(+), 509 deletions(-)

-- 
2.21.0


^ permalink raw reply	[flat|nested] 33+ messages in thread

end of thread, other threads:[~2020-05-22 14:40 UTC | newest]

Thread overview: 33+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-07 20:21 [PATCH 00/21] FIFO: Support multiple readers Ken Brown
2020-05-07 20:21 ` [PATCH 01/21] Cygwin: FIFO: minor change - use NtClose Ken Brown
2020-05-07 20:21 ` [PATCH 02/21] Cygwin: FIFO: simplify the fifo_client_handler structure Ken Brown
2020-05-07 20:21 ` [PATCH 03/21] Cygwin: FIFO: change the fifo_client_connect_state enum Ken Brown
2020-05-07 20:21 ` [PATCH 04/21] Cygwin: FIFO: simplify the listen_client_thread code Ken Brown
2020-05-07 20:21 ` [PATCH 05/21] Cygwin: FIFO: remove the arm method Ken Brown
2020-05-07 20:21 ` [PATCH 06/21] Cygwin: FIFO: honor the flags argument in dup Ken Brown
2020-05-07 20:21 ` [PATCH 07/21] Cygwin: FIFO: dup/fork/exec: make sure child starts unlocked Ken Brown
2020-05-07 20:21 ` [PATCH 08/21] Cygwin: FIFO: fix hit_eof Ken Brown
2020-05-07 20:21 ` [PATCH 09/21] Cygwin: FIFO: make opening a writer more robust Ken Brown
2020-05-07 20:21 ` [PATCH 10/21] Cygwin: FIFO: use a cygthread instead of a homemade thread Ken Brown
2020-05-07 20:21 ` [PATCH 11/21] Cygwin: FIFO: add shared memory Ken Brown
2020-05-07 20:21 ` [PATCH 12/21] Cygwin: FIFO: keep track of the number of readers Ken Brown
2020-05-07 20:21 ` [PATCH 13/21] Cygwin: FIFO: introduce a new type, fifo_reader_id_t Ken Brown
2020-05-07 20:21 ` [PATCH 14/21] Cygwin: FIFO: designate one reader as owner Ken Brown
2020-05-07 20:21 ` [PATCH 15/21] Cygwin: FIFO: allow fc_handler list to grow dynamically Ken Brown
2020-05-07 20:21 ` [PATCH 16/21] Cygwin: FIFO: add a shared fifo_client_handler list Ken Brown
2020-05-07 20:21 ` [PATCH 17/21] Cygwin: FIFO: take ownership on exec Ken Brown
2020-05-07 20:21 ` [PATCH 18/21] Cygwin: FIFO: find a new owner when closing Ken Brown
2020-05-07 20:21 ` [PATCH 19/21] Cygwin: FIFO: allow any reader to take ownership Ken Brown
2020-05-07 20:21 ` [PATCH 20/21] Cygwin: FIFO: support opening multiple readers Ken Brown
2020-05-07 20:21 ` [PATCH 21/21] Cygwin: FIFO: update commentary Ken Brown
2020-05-08 10:11 ` [PATCH 00/21] FIFO: Support multiple readers Corinna Vinschen
2020-05-18  5:25 ` Takashi Yano
2020-05-18  5:36   ` Takashi Yano
2020-05-18 16:03     ` Ken Brown
2020-05-18 17:42       ` Ken Brown
2020-05-19  1:26         ` Takashi Yano
2020-05-19  6:15           ` Takashi Yano
2020-05-19 12:51             ` Ken Brown
2020-05-19 13:37               ` Ken Brown
2020-05-19 14:07                 ` Takashi Yano
2020-05-22 14:40                   ` Ken Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).