]> sourceware.org Git - newlib-cygwin.git/commitdiff
Cygwin: FIFO: hit_eof: add a call to fifo_client_lock
authorKen Brown <kbrown@cornell.edu>
Sun, 14 Apr 2019 19:15:56 +0000 (19:15 +0000)
committerCorinna Vinschen <corinna@vinschen.de>
Tue, 16 Apr 2019 10:54:43 +0000 (12:54 +0200)
The second check of nconnected needs to be protected by a lock as well
as the first.

winsup/cygwin/fhandler_fifo.cc

index 9016964444c0901b21e3145dfbc7974a254826df..70551ebac7645f6d9076b17020e3b5fcc19dbd5c 100644 (file)
@@ -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;
 }
 
This page took 0.030865 seconds and 5 git commands to generate.