Cygwin: pty: Make slave read() thread-safe.

- Currently slave read() is somehow not thread-safe. This patch
  fixes the issue.
This commit is contained in:
Takashi Yano via Cygwin-patches 2021-01-28 23:11:33 +09:00 committed by Corinna Vinschen
parent 0b64cc6812
commit f186f61d60
1 changed files with 6 additions and 0 deletions

View File

@ -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))
{