You are not logged in.
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
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
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
Last edited by VojkoCendak (2012-09-22 00:40:20)
Offline
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