EldoS | Feel safer!

Software components for data protection, secure storage and transfer

SSH and Indy

Also by EldoS: MsgConnect
Cross-platform protocol-independent communication framework for building peer-to-peer and client-server applications and middleware components.
#10718
Posted: 08/03/2009 15:39:11
by Denis Sletkov (Standard support level)
Joined: 11/27/2007
Posts: 14

When SSH server work (indy based) EIdReadTimeout exception raised the call stack is:
InputLn
ReadChar
ReadByte
ReadBytes
ReadFromSource

in ReadFromSource is "if Readable(ATimeout) then" if condition is False exception raised. In SSHIOHandle is
Code
  if Assigned(FTunnelConnection) and FActive then
    Result := FSpool.Size > 0
  else
    Result := false;

So if no data, function return False. I check for example standard Telnet server they wait for data in socket in Readable function. So i think need to add something that wait for data (Stange that add DataAvailable procedure do not help).

PS. Indy version 10.5.6
#10721
Posted: 08/04/2009 02:47:11
by Mykola Olshevsky (Basic support level)
Joined: 07/07/2005
Posts: 450

ReadFromSource should be overriden in TElIdSSHConnectionIOHandler class, and it doesn't call 'if Readable(ATImeout)', possibly you incorrectly defined INDY version at the beginning of SBIndySSHServerIOHandler10.pas ?
#10724
Posted: 08/04/2009 04:34:33
by Denis Sletkov (Standard support level)
Joined: 11/27/2007
Posts: 14

In 10.5.6 ReadFromSource is not virtual so can not be override, only ReadDataFromSource can be. So Readable code execute.
Code
    // This is the main Read function which all other default implementations
    // use.
    function ReadFromSource(ARaiseExceptionIfDisconnected: Boolean = True;
     ATimeout: Integer = IdTimeoutDefault;
     ARaiseExceptionOnTimeout: Boolean = True): Integer;
    function ReadDataFromSource(var VBuffer: TIdBytes): Integer; virtual; abstract;
#10729
Posted: 08/04/2009 08:15:31
by Mykola Olshevsky (Basic support level)
Joined: 07/07/2005
Posts: 450

I see, but, btw, where you got version 10.5.6? On their site I see only 10.2.3 development snapshot.
Unfortunately, Indy team introduces changes from one version to another, which breaks compatibility with older versions.
We will need some time to update our sources, and, at the moment, you can add to .Readable() method something like

Code
var
  BgnTime : cardinal;

begin
  if (ATimeout = IdTimeoutDefault) or (ATimeout = IdTimeoutInfinite) then
    ATimeout := 0;
  if (ATimeout > 0) then
  begin
    BgnTime := GetTickCount();
    while (FSpool.Size = 0) and (GetTickCount() - BgnTime < ATimeout) do
    begin
      FSSHServer.DataAvailable;
      Sleep(10);
    end;

  ...
#10730
Posted: 08/04/2009 08:32:29
by Denis Sletkov (Standard support level)
Joined: 11/27/2007
Posts: 14

See /branches/Tiburon in Indy SVN. I see that they work only on this branch now.

I change code, but exception is raised, beacuse ReadFromSource execute Readable with timeout IdTimeoutInfinite, so condition (AMSec > 0) is False.
Code
function TElIdSSHConnectionIOHandler.Readable(AMSec: Integer): Boolean;
var
  BgnTime : cardinal;
begin
  if (AMSec = IdTimeoutDefault) or (AMSec = IdTimeoutInfinite) then
    AMSec := 0;
  if (AMSec > 0) then
  begin
    BgnTime := GetTickCount();
    while (FSpool.Size = 0) and (GetTickCount() - BgnTime < AMSec) do
    begin
      FSSHServer.DataAvailable;
      Sleep(10);
    end;
  end;

  if Assigned(FTunnelConnection) and FActive then
    Result := FSpool.Size > 0
  else
    Result := false;
end;
#10731
Posted: 08/04/2009 08:36:52
by Denis Sletkov (Standard support level)
Joined: 11/27/2007
Posts: 14

I redone Readable function to
Code
function TElIdSSHConnectionIOHandler.Readable(AMSec: Integer): Boolean;
var
  BgnTime : cardinal;
begin
  if (AMSec = IdTimeoutDefault) or (AMSec = IdTimeoutInfinite) then
    AMSec := 0;
  if (AMSec > 0) then
  begin
    BgnTime := GetTickCount();
    while (FSpool.Size = 0) and (GetTickCount() - BgnTime < AMSec) do
    begin
      FSSHServer.DataAvailable;
      Sleep(10);
    end;
  end
  else begin
    while (FSpool.Size = 0) do
    begin
      FSSHServer.DataAvailable;
      Sleep(10);
    end;
  end;

  if Assigned(FTunnelConnection) and FActive then
    Result := FSpool.Size > 0
  else
    Result := false;
end;


But there is other problem in this case server deadlock when finsh because there is no disconnect checked in while loop.
#10732
Posted: 08/04/2009 08:43:19
by Eugene Mayevski (EldoS Corp.)

Officially: we don't support "developer branches", "work in progress" and whatever else they might produce. We support *only* officially released platforms and libraries. If you use some internal developments, you can do this at your own risk. We don't support them and and won't help you with them.


Sincerely yours
Eugene Mayevski
#10733
Posted: 08/04/2009 08:44:41
by Mykola Olshevsky (Basic support level)
Joined: 07/07/2005
Posts: 450

Thank you for information.

Please also try add check for FActive = true in while() loop.
#10735
Posted: 08/04/2009 09:28:59
by Denis Sletkov (Standard support level)
Joined: 11/27/2007
Posts: 14

As i see the 10.5.6 is latest official verison of Indy, i do not see any other information what version of Indy is lasest official. I know that D2009 ships with 10.2.3.

https://forums.codegear.com/message.jspa?messageID=139064
https://forums.embarcadero.com/thread.jspa?messageID=139272
https://forums.embarcadero.com/thread.jspa?threadID=21775
#10737
Posted: 08/04/2009 09:36:49
by Mykola Olshevsky (Basic support level)
Joined: 07/07/2005
Posts: 450

On that links there is nothing about official release 10.5.6, just information that such version exists in SVN (what we already know from your posts).

www.indyproject.org (which, I assume, is the official source for Indy) in downloads section offers only 10.2.3 version.
Also by EldoS: CallbackProcess
A component to control process creation and termination in Windows and .NET applications.

Reply

Statistics

Topic viewed 5107 times

Number of guests: 1, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!