Reduce crash probability in TSecureShellCmd.Connect when user disconnects from session before tunnel is reestablished.

This commit is contained in:
Ansgar Becker
2023-01-26 08:11:39 +01:00
parent 649e737891
commit 4abc5c1b3d

View File

@@ -1090,7 +1090,7 @@ var
rx: TRegExpr;
StartupInfo: TStartupInfo;
ExitCode: LongWord;
Waited, PortChecks: Integer;
Waited, PortChecks, SshTimeOutMilliseconds: Integer;
IsPlink: Boolean;
begin
// Check if local port is open
@@ -1163,7 +1163,8 @@ begin
// Parse pipe output and probably show some message in a dialog.
Waited := 0;
DialogTitle := ExtractFileName(FConnection.Parameters.SSHExe);
while Waited < FConnection.Parameters.SSHTimeout*1000 do begin
SshTimeOutMilliseconds := FConnection.Parameters.SSHTimeout * 1000;
while Waited < SshTimeOutMilliseconds do begin
Inc(Waited, 200);
WaitForSingleObject(FProcessInfo.hProcess, 200);
GetExitCodeProcess(FProcessInfo.hProcess, ExitCode);