summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKen Brown <kbrown@cornell.edu>2019-04-14 19:15:56 +0000
committerCorinna Vinschen <corinna@vinschen.de>2019-04-16 12:54:43 +0200
commit528169992668a7e292b8c1c5a39e2c1e24ff6683 (patch)
tree2d1d9221fc91120a5af5d5ab948a2d75459377ef
parentb63843ed569c1e4b15f2b197733c334cee1c4454 (diff)
downloadcygnal-528169992668a7e292b8c1c5a39e2c1e24ff6683.tar.gz
cygnal-528169992668a7e292b8c1c5a39e2c1e24ff6683.tar.bz2
cygnal-528169992668a7e292b8c1c5a39e2c1e24ff6683.zip
Cygwin: FIFO: hit_eof: add a call to fifo_client_lock
The second check of nconnected needs to be protected by a lock as well as the first.
-rw-r--r--winsup/cygwin/fhandler_fifo.cc21
1 files changed, 13 insertions, 8 deletions
diff --git a/winsup/cygwin/fhandler_fifo.cc b/winsup/cygwin/fhandler_fifo.cc
index 901696444..70551ebac 100644
--- a/winsup/cygwin/fhandler_fifo.cc
+++ b/winsup/cygwin/fhandler_fifo.cc
@@ -705,15 +705,20 @@ fhandler_fifo::raw_write (const void *ptr, size_t len)
bool
fhandler_fifo::hit_eof ()
{
- fifo_client_lock ();
- bool eof = (nconnected == 0);
- fifo_client_unlock ();
- if (eof)
- {
- /* Give the listen_client thread time to catch up, then recheck. */
- Sleep (1);
+ bool eof;
+ bool retry = true;
+
+retry:
+ fifo_client_lock ();
eof = (nconnected == 0);
- }
+ fifo_client_unlock ();
+ if (eof && retry)
+ {
+ retry = false;
+ /* Give the listen_client thread time to catch up. */
+ Sleep (1);
+ goto retry;
+ }
return eof;
}