[newlib-cygwin] Cygwin: FIFO: avoid deadlock when closing
Ken Brown
kbrown@sourceware.org
Sun Jun 23 17:09:00 GMT 2019
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=d1b36ea949e275c803787523b0b04657895638fc
commit d1b36ea949e275c803787523b0b04657895638fc
Author: Ken Brown <kbrown@cornell.edu>
Date: Sat Jun 22 13:58:12 2019 -0400
Cygwin: FIFO: avoid deadlock when closing
fhandler_fifo::close could be called from a signal handler or another
thread at a time when another function is holding the fifo_client
lock. This could prevent the listen_client thread from acting on the
thread termination event. Avoid a deadlock by calling
fifo_client_unlock at the beginning of fhandler_fifo::close.
Diff:
---
winsup/cygwin/fhandler_fifo.cc | 3 +++
1 file changed, 3 insertions(+)
diff --git a/winsup/cygwin/fhandler_fifo.cc b/winsup/cygwin/fhandler_fifo.cc
index 4291a7e..8afa397 100644
--- a/winsup/cygwin/fhandler_fifo.cc
+++ b/winsup/cygwin/fhandler_fifo.cc
@@ -928,6 +928,9 @@ fhandler_fifo::stop_listen_client ()
int
fhandler_fifo::close ()
{
+ /* Avoid deadlock with lct in case this is called from a signal
+ handler or another thread. */
+ fifo_client_unlock ();
int ret = stop_listen_client ();
if (read_ready)
CloseHandle (read_ready);
More information about the Cygwin-cvs
mailing list