summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTakashi Yano via Cygwin-patches <cygwin-patches@cygwin.com>2021-01-28 23:11:33 +0900
committerCorinna Vinschen <corinna@vinschen.de>2021-02-01 10:54:04 +0100
commitf186f61d60b342c8167e652073bdc6e3f704a90a (patch)
tree3ba256c70a229c64a96ad5ea3c02a5cd722a13bc
parent0b64cc6812e054dbc09cc1ee82b6582d4b5205e8 (diff)
downloadcygnal-f186f61d60b342c8167e652073bdc6e3f704a90a.tar.gz
cygnal-f186f61d60b342c8167e652073bdc6e3f704a90a.tar.bz2
cygnal-f186f61d60b342c8167e652073bdc6e3f704a90a.zip
Cygwin: pty: Make slave read() thread-safe.
- Currently slave read() is somehow not thread-safe. This patch fixes the issue.
-rw-r--r--winsup/cygwin/fhandler_tty.cc6
1 files changed, 6 insertions, 0 deletions
diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc
index 06fc19ac2..48b89ae77 100644
--- a/winsup/cygwin/fhandler_tty.cc
+++ b/winsup/cygwin/fhandler_tty.cc
@@ -1241,6 +1241,7 @@ fhandler_pty_slave::read (void *ptr, size_t& len)
time_to_wait = !vtime ? INFINITE : 100 * vtime;
}
+wait_retry:
while (len)
{
switch (cygwait (input_available_event, time_to_wait))
@@ -1319,6 +1320,11 @@ fhandler_pty_slave::read (void *ptr, size_t& len)
}
goto out;
}
+ if (!IsEventSignalled (input_available_event))
+ { /* Maybe another thread has processed input. */
+ ReleaseMutex (input_mutex);
+ goto wait_retry;
+ }
if (!bytes_available (bytes_in_pipe))
{