public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin] Cygwin: FIFO: avoid WFMO error in listen_client_thread
@ 2019-04-23 12:17 Ken Brown
  0 siblings, 0 replies; only message in thread
From: Ken Brown @ 2019-04-23 12:17 UTC (permalink / raw)
  To: cygwin-cvs

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

commit 24c56e5a2c4d5b0970252fccdff327f2480ca024
Author: Ken Brown <kbrown@cornell.edu>
Date:   Sat Apr 20 11:22:29 2019 -0400

    Cygwin: FIFO: avoid WFMO error in listen_client_thread
    
    Don't set lct_termination_evt to NULL too early in
    fhandler_fifo::stop_listen_client.  Doing so leads to an "Invalid
    Handle" error in WFMO.

Diff:
---
 winsup/cygwin/fhandler_fifo.cc | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/winsup/cygwin/fhandler_fifo.cc b/winsup/cygwin/fhandler_fifo.cc
index 0a6dc05..0e4bf3a 100644
--- a/winsup/cygwin/fhandler_fifo.cc
+++ b/winsup/cygwin/fhandler_fifo.cc
@@ -844,22 +844,24 @@ int
 fhandler_fifo::stop_listen_client ()
 {
   int ret = 0;
-  HANDLE evt = InterlockedExchangePointer (&lct_termination_evt, NULL);
-  HANDLE thr = InterlockedExchangePointer (&listen_client_thr, NULL);
+  HANDLE thr, evt;
+
+  thr = InterlockedExchangePointer (&listen_client_thr, NULL);
   if (thr)
     {
-      if (evt)
-	SetEvent (evt);
+      if (lct_termination_evt)
+	SetEvent (lct_termination_evt);
       WaitForSingleObject (thr, INFINITE);
       DWORD err;
       GetExitCodeThread (thr, &err);
       if (err)
 	{
 	  ret = -1;
-	  debug_printf ("listen_client_thread exited with error, %E");
+	  debug_printf ("listen_client_thread exited with error");
 	}
       CloseHandle (thr);
     }
+  evt = InterlockedExchangePointer (&lct_termination_evt, NULL);
   if (evt)
     CloseHandle (evt);
   return ret;


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

only message in thread, other threads:[~2019-04-23 12:17 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-23 12:17 [newlib-cygwin] Cygwin: FIFO: avoid WFMO error in listen_client_thread 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).