summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKen Brown <kbrown@cornell.edu>2019-06-22 13:58:12 -0400
committerKen Brown <kbrown@cornell.edu>2019-06-23 10:16:33 -0400
commitd1b36ea949e275c803787523b0b04657895638fc (patch)
treeccfb0d5455ea2bca36ca9c30c1990d2f84dd694e
parent281d3bf060d4de516cd5b47f14598bced786f053 (diff)
downloadcygnal-d1b36ea949e275c803787523b0b04657895638fc.tar.gz
cygnal-d1b36ea949e275c803787523b0b04657895638fc.tar.bz2
cygnal-d1b36ea949e275c803787523b0b04657895638fc.zip
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.
-rw-r--r--winsup/cygwin/fhandler_fifo.cc3
1 files changed, 3 insertions, 0 deletions
diff --git a/winsup/cygwin/fhandler_fifo.cc b/winsup/cygwin/fhandler_fifo.cc
index 4291a7e5c..8afa39747 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);