[PATCH 2/2] Cygwin: pty: Make slave read() thread-safe.
Takashi Yano
takashi.yano@nifty.ne.jp
Thu Jan 28 11:14:09 GMT 2021
- Currently slave read() is somehow not thread-safe. This patch
fixes the issue.
---
winsup/cygwin/fhandler_tty.cc | 6 ++++++
1 file changed, 6 insertions(+)
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))
{
--
2.30.0
More information about the Cygwin-patches
mailing list