]> sourceware.org Git - newlib-cygwin.git/commit
Cygwin: FIFO: fix hit_eof
authorKen Brown <kbrown@cornell.edu>
Sun, 26 Apr 2020 13:38:46 +0000 (09:38 -0400)
committerKen Brown <kbrown@cornell.edu>
Fri, 8 May 2020 10:32:00 +0000 (06:32 -0400)
commit301454f1320bf1cfaf826fcabf5556cb20ee642a
tree9031e7f0b9af184ac8b10a20a0d493918e7519eb
parent13c65c43c24015f75b6488dc476b8d7b22c84f18
Cygwin: FIFO: fix hit_eof

According to Posix, a FIFO open for reading is at EOF if it is empty
and there are no writers open.

The only way to test this is to poll the fifo_client_handlers as in
raw_read and select.cc:peek_fifo.  The current hit_eof instead relies
on the value of nconnected, which can be out of date.  On the one
hand, it doesn't take into account writers that were connected but
have since closed.  On the other hand, it doesn't take into account
writers that are in the process of opening but haven't yet connected.

Fix this by introducing a maybe_eof method that tentatively assumes
EOF if there are no connected writers after polling.  Then check for
writers currently opening (via a new 'writer_opening' event), and wait
for the fifo_reader_thread to record any new connection that was made
while we were polling.

To handle the needs of peek_fifo, replace the get_fc_handle method
by a get_fc_handler method, and add a fifo_client_handler::get_state
method.

Remove the is_connected method, which was used only in peek_fifo and
is no longer needed.

Remove the nconnected data member, which was used only for the flawed
hit_eof.

Add some comments about events to fhandler.h.
winsup/cygwin/fhandler.h
winsup/cygwin/fhandler_fifo.cc
winsup/cygwin/select.cc
This page took 0.031646 seconds and 5 git commands to generate.