summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTakashi Yano via Cygwin-patches <cygwin-patches@cygwin.com>2020-12-14 17:26:09 +0900
committerCorinna Vinschen <corinna@vinschen.de>2020-12-14 11:02:23 +0100
commit55eff668b878fe6571cd363a4ce80dd0b1d718da (patch)
tree72d971d422ad6515844d9c4c9519908ba8eba2c6
parentc2c33e4d673f630a4f85ef8339e3456384e94850 (diff)
downloadcygnal-55eff668b878fe6571cd363a4ce80dd0b1d718da.tar.gz
cygnal-55eff668b878fe6571cd363a4ce80dd0b1d718da.tar.bz2
cygnal-55eff668b878fe6571cd363a4ce80dd0b1d718da.zip
Cygwin: pty: Revise the code for timeout in term_has_pcon_cap().
- Sometimes timeout period in term_has_pcon_cap() may not be enough when the machine slows down for some reason. This patch eases the issue. In the new code, effective timeout period is expected to be extended as a result due to slowing-down the wait loop as well when the machine gets into busy.
-rw-r--r--winsup/cygwin/fhandler_tty.cc6
1 files changed, 3 insertions, 3 deletions
diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc
index 845e51184..04a9a2bf5 100644
--- a/winsup/cygwin/fhandler_tty.cc
+++ b/winsup/cygwin/fhandler_tty.cc
@@ -2651,7 +2651,7 @@ fhandler_pty_slave::term_has_pcon_cap (const WCHAR *env)
char *p;
int len;
int x1, y1, x2, y2;
- DWORD t0;
+ int wait_cnt = 0;
/* Check if terminal has ANSI escape sequence. */
if (!has_ansi_escape_sequences (env))
@@ -2668,7 +2668,6 @@ fhandler_pty_slave::term_has_pcon_cap (const WCHAR *env)
ReleaseMutex (input_mutex);
p = buf;
len = sizeof (buf) - 1;
- t0 = GetTickCount ();
do
{
if (::bytes_available (n, get_handle ()) && n)
@@ -2680,9 +2679,10 @@ fhandler_pty_slave::term_has_pcon_cap (const WCHAR *env)
char *p1 = strrchr (buf, '\033');
if (p1 == NULL || sscanf (p1, "\033[%d;%dR", &y1, &x1) != 2)
continue;
+ wait_cnt = 0;
break;
}
- else if (GetTickCount () - t0 > 40) /* Timeout */
+ else if (++wait_cnt > 100) /* Timeout */
goto not_has_csi6n;
else
Sleep (1);