public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin] Cygwin: FIFO: hit_eof: add a call to fifo_client_lock
@ 2019-04-16 11:15 Corinna Vinschen
  0 siblings, 0 replies; only message in thread
From: Corinna Vinschen @ 2019-04-16 11:15 UTC (permalink / raw)
  To: cygwin-cvs

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=528169992668a7e292b8c1c5a39e2c1e24ff6683

commit 528169992668a7e292b8c1c5a39e2c1e24ff6683
Author: Ken Brown <kbrown@cornell.edu>
Date:   Sun Apr 14 19:15:56 2019 +0000

    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.

Diff:
---
 winsup/cygwin/fhandler_fifo.cc | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/winsup/cygwin/fhandler_fifo.cc b/winsup/cygwin/fhandler_fifo.cc
index 9016964..70551eb 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;
 }


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-04-16 11:15 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-16 11:15 [newlib-cygwin] Cygwin: FIFO: hit_eof: add a call to fifo_client_lock Corinna Vinschen

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).