#1 2012-09-18 20:39:48

VojkoCendak
Member
From: Celje Slovenia
Registered: 2012-09-02
Posts: 88

Issues with TSQLite3HttpClientWinSock client with no actual connection

Hi, (D2009 ent)

Strange behaviour, when there is no server:

    result := TSQLite3HttpClientWinSock.Create(FHost,IntToStr(FPort),Fmodel);
    try
       result := TSQLite3HttpClientWinSock.Create(FHost,IntToStr(FPort),Fmodel);
       result.SetUser('User','synopse');
       result.ServiceRegister([TypeInfo(IEMRAsvr_tags)],sicShared);
  except
    // ===> on except (no connection to server) actual result is undefined (debugger)
    // in debugger it (TSQLite3HttpClientWinSock) destroys !? How is that possible ?
    raise;
  end;

Possible troubled source:

{ TSQLite3HttpClientWinSock }

constructor TSQLite3HttpClientWinSock.Create(const aServer, aPort: AnsiString;
  aModel: TSQLModel);
begin
  inherited Create(aModel);
  fSocket := THttpClientSocket.Open(aServer,aPort);  //===>
{$ifdef USETCPPREFIX}
  fSocket.TCPPrefix := 'magic';
{$endif}
  KeepAliveMS := 20000; // 20 seconds connection keep alive by default
{$ifdef COMPRESSSYNLZ}
   // SynLZ is very fast and efficient, perfect for a Delphi Client
   fSocket.RegisterCompress(CompressSynLZ);
{$endif}
{$ifdef COMPRESSDEFLATE}
   fSocket.RegisterCompress(CompressDeflate);
{$endif}
end;

destructor TSQLite3HttpClientWinSock.Destroy;
begin
   // ===> if THttpClientSocket.Open doesn't succeed fSocket remains nil
   // so here would be trouble
  fSocket.Free;
  inherited Destroy;
end;

Last edited by VojkoCendak (2012-09-18 20:41:25)

Offline

#2 2012-09-21 19:39:30

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,238
Website

Re: Issues with TSQLite3HttpClientWinSock client with no actual connection

Why do you create the TSQLite3HttpClientWinSock instance twice?

Perhaps a try...finally is to be added in TSQLite3HttpClientWinSock.Create to handle connection failure, you are right.
I'll look at it.

Offline

#3 2012-09-22 00:37:39

VojkoCendak
Member
From: Celje Slovenia
Registered: 2012-09-02
Posts: 88

Re: Issues with TSQLite3HttpClientWinSock client with no actual connection

I made a mistake in copying the text:
This is the code:

    result := TSQLite3HttpClientWinSock.Create(FHost,IntToStr(FPort),Fmodel);
    try
       result.SetUser('User','synopse');
       result.ServiceRegister([TypeInfo(IEMRAsvr_tags)],sicShared);
  except
    // ===> on except (no connection to server) actual result is undefined (debugger)
    // in debugger it (TSQLite3HttpClientWinSock) destroys !? How is that possible ?
    raise;
  end;

When I step through the debugger and I don't call Free to destroy the instance.
Destroy is called before raise. Maybe I'm missing something wink

Last edited by VojkoCendak (2012-09-22 00:40:20)

Offline

#4 2012-09-26 10:06:15

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,238
Website

Re: Issues with TSQLite3HttpClientWinSock client with no actual connection

Your result variable is not set if an exception raise at Create().

And AFAIK TSQLite3HttpClientWinSock.Destroy is always to be called by the Delphi RTL if an exception is raised within the constructor.
Sounds as expected to me.

Offline

Board footer

Powered by FluxBB