Skip to content

Commit

Permalink
Issue #1771: prefer a larger SSH process check interval for larger ti…
Browse files Browse the repository at this point in the history
…meouts (timeout:4s => check interval:400ms), and log process exit code each interval.
  • Loading branch information
ansgarbecker committed Feb 28, 2023
1 parent bff590e commit 603e162
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions source/dbconnection.pas
Expand Up @@ -1091,6 +1091,7 @@ procedure TSecureShellCmd.Connect;
StartupInfo: TStartupInfo;
ExitCode: LongWord;
Waited, PortChecks, SshTimeOutMilliseconds: Integer;
SshCheckIntervalMilliseconds: Integer;
IsPlink: Boolean;
begin
// Check if local port is open
Expand Down Expand Up @@ -1164,10 +1165,12 @@ procedure TSecureShellCmd.Connect;
Waited := 0;
DialogTitle := ExtractFileName(FConnection.Parameters.SSHExe);
SshTimeOutMilliseconds := FConnection.Parameters.SSHTimeout * 1000;
SshCheckIntervalMilliseconds := FConnection.Parameters.SSHTimeout * 100;
while Waited < SshTimeOutMilliseconds do begin
Inc(Waited, 200);
WaitForSingleObject(FProcessInfo.hProcess, 200);
Inc(Waited, SshCheckIntervalMilliseconds);
WaitForSingleObject(FProcessInfo.hProcess, SshCheckIntervalMilliseconds);
GetExitCodeProcess(FProcessInfo.hProcess, ExitCode);
FConnection.Log(lcDebug, 'SSH process exit code after '+Waited.ToString+'ms: '+ExitCode.ToString);
if ExitCode <> STILL_ACTIVE then
raise EDbError.CreateFmt(_('SSH exited unexpected. Command line was: %s'), [CRLF+SshCmdDisplay]);

Expand Down

0 comments on commit 603e162

Please sign in to comment.