This is the mail archive of the
cygwin-patches
mailing list for the Cygwin project.
[PATCH 3/5] Cygwin: FIFO: avoid WFMO error in listen_client_thread
- From: Ken Brown <kbrown at cornell dot edu>
- To: "cygwin-patches at cygwin dot com" <cygwin-patches at cygwin dot com>
- Date: Sat, 20 Apr 2019 18:58:49 +0000
- Subject: [PATCH 3/5] Cygwin: FIFO: avoid WFMO error in listen_client_thread
- References: <20190420185834.4228-1-kbrown@cornell.edu>
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.
---
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 0a6dc0591..0e4bf3aee 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;
--
2.17.0