mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-01-31 19:40:33 +08:00
Cygwin: pty: Fix a race issue in startup of pseudo console.
- If two non-cygwin apps are started simultaneously and this is the first execution of non-cygwin apps in the pty, these occasionally hang up. The cause is the race issue between term_has_pcon_cap(), reset_switch_to_pcon() and setup_pseudoconsole(). This patch fixes the issue.
This commit is contained in:
parent
182ba1f022
commit
919dea66d3
@ -1118,15 +1118,20 @@ fhandler_pty_slave::reset_switch_to_pcon (void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (get_ttyp ()->pcon_pid && get_ttyp ()->pcon_pid != myself->pid
|
|
||||||
&& !!pinfo (get_ttyp ()->pcon_pid))
|
|
||||||
/* There is a process which is grabbing pseudo console. */
|
|
||||||
return;
|
|
||||||
if (isHybrid)
|
if (isHybrid)
|
||||||
return;
|
return;
|
||||||
|
WaitForSingleObject (pcon_mutex, INFINITE);
|
||||||
|
if (get_ttyp ()->pcon_pid && get_ttyp ()->pcon_pid != myself->pid
|
||||||
|
&& !!pinfo (get_ttyp ()->pcon_pid))
|
||||||
|
{
|
||||||
|
/* There is a process which is grabbing pseudo console. */
|
||||||
|
ReleaseMutex (pcon_mutex);
|
||||||
|
return;
|
||||||
|
}
|
||||||
get_ttyp ()->pcon_pid = 0;
|
get_ttyp ()->pcon_pid = 0;
|
||||||
get_ttyp ()->switch_to_pcon_in = false;
|
get_ttyp ()->switch_to_pcon_in = false;
|
||||||
get_ttyp ()->pcon_activated = false;
|
get_ttyp ()->pcon_activated = false;
|
||||||
|
ReleaseMutex (pcon_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t __stdcall
|
ssize_t __stdcall
|
||||||
@ -3538,6 +3543,7 @@ fhandler_pty_slave::term_has_pcon_cap (const WCHAR *env)
|
|||||||
goto maybe_dumb;
|
goto maybe_dumb;
|
||||||
|
|
||||||
/* Check if terminal has CSI6n */
|
/* Check if terminal has CSI6n */
|
||||||
|
WaitForSingleObject (pcon_mutex, INFINITE);
|
||||||
WaitForSingleObject (input_mutex, INFINITE);
|
WaitForSingleObject (input_mutex, INFINITE);
|
||||||
/* Set pcon_activated and pcon_start so that the response
|
/* Set pcon_activated and pcon_start so that the response
|
||||||
will sent to io_handle rather than io_handle_cyg. */
|
will sent to io_handle rather than io_handle_cyg. */
|
||||||
@ -3573,6 +3579,7 @@ fhandler_pty_slave::term_has_pcon_cap (const WCHAR *env)
|
|||||||
while (len);
|
while (len);
|
||||||
get_ttyp ()->pcon_activated = false;
|
get_ttyp ()->pcon_activated = false;
|
||||||
get_ttyp ()->pcon_pid = 0;
|
get_ttyp ()->pcon_pid = 0;
|
||||||
|
ReleaseMutex (pcon_mutex);
|
||||||
if (len == 0)
|
if (len == 0)
|
||||||
goto not_has_csi6n;
|
goto not_has_csi6n;
|
||||||
|
|
||||||
@ -3588,6 +3595,7 @@ not_has_csi6n:
|
|||||||
get_ttyp ()->pcon_start = false;
|
get_ttyp ()->pcon_start = false;
|
||||||
get_ttyp ()->pcon_activated = false;
|
get_ttyp ()->pcon_activated = false;
|
||||||
ReleaseMutex (input_mutex);
|
ReleaseMutex (input_mutex);
|
||||||
|
ReleaseMutex (pcon_mutex);
|
||||||
maybe_dumb:
|
maybe_dumb:
|
||||||
get_ttyp ()->pcon_cap_checked = true;
|
get_ttyp ()->pcon_cap_checked = true;
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user