Respect user's plink timeout setting when plink takes longer than 2s after the first text output. Closes #1114

This commit is contained in:
Ansgar Becker
2020-08-09 07:52:38 +02:00
parent 2569ae5c21
commit c33624aa12

View File

@ -945,7 +945,7 @@ var
rx: TRegExpr;
StartupInfo: TStartupInfo;
ExitCode: LongWord;
Waited, ReturnedSomethingAt, PortChecks: Integer;
Waited, PortChecks: Integer;
begin
// Check if local port is open
PortChecks := 0;
@ -1008,10 +1008,10 @@ begin
raise EDbError.Create(ErrorText);
end;
// Wait until timeout has finished, or some text returned.
// Wait until timeout has finished.
// Todo: Find a way to wait only until connection is established
// Parse pipe output and probably show some message in a dialog.
Waited := 0;
ReturnedSomethingAt := -1;
while Waited < FConnection.Parameters.SSHTimeout*1000 do begin
Inc(Waited, 200);
WaitForSingleObject(FProcessInfo.hProcess, 200);
@ -1022,7 +1022,6 @@ begin
OutText := Trim(ReadPipe(FOutPipe));
ErrorText := ReadPipe(FErrorPipe);
if (OutText <> '') or (ErrorText <> '') then begin
ReturnedSomethingAt := Waited;
FConnection.Log(lcDebug, Format('PLink output after %d ms. OutPipe: "%s" ErrorPipe: "%s"', [Waited, OutText, ErrorText]));
end;
@ -1079,10 +1078,6 @@ begin
end;
end;
end;
// Exit loop after 2s idletime when there was output earlier
if (ReturnedSomethingAt > 0) and (Waited >= ReturnedSomethingAt+2000) then
Break;
Application.ProcessMessages;
end;