|
@@ -2526,16 +2526,28 @@ void __fastcall TTerminalThread::Cancel()
|
|
|
//---------------------------------------------------------------------------
|
|
|
void __fastcall TTerminalThread::Idle()
|
|
|
{
|
|
|
- TGuard Guard(FSection);
|
|
|
- // only when running user action already,
|
|
|
- // so that the exception is caught, saved and actually
|
|
|
- // passed back into the terminal thread, saved again
|
|
|
- // and passed back to us
|
|
|
- if ((FUserAction != NULL) && (FIdleException != NULL))
|
|
|
+ // If user action is needed during Idle() call from TTerminalThread::WaitForUserAction
|
|
|
+ // (e.g. when disconnect is detected and session get reconnected)
|
|
|
+ // unconditional Enter() here would deadlock.
|
|
|
+ if (FSection->TryEnter())
|
|
|
{
|
|
|
- Rethrow(FIdleException);
|
|
|
+ try
|
|
|
+ {
|
|
|
+ // only when running user action already,
|
|
|
+ // so that the exception is caught, saved and actually
|
|
|
+ // passed back into the terminal thread, saved again
|
|
|
+ // and passed back to us
|
|
|
+ if ((FUserAction != NULL) && (FIdleException != NULL))
|
|
|
+ {
|
|
|
+ Rethrow(FIdleException);
|
|
|
+ }
|
|
|
+ FPendingIdle = true;
|
|
|
+ }
|
|
|
+ __finally
|
|
|
+ {
|
|
|
+ FSection->Release();
|
|
|
+ }
|
|
|
}
|
|
|
- FPendingIdle = true;
|
|
|
}
|
|
|
//---------------------------------------------------------------------------
|
|
|
void __fastcall TTerminalThread::TerminalOpen()
|