#1 2019-05-14 08:43:15

mattsbg
Member
Registered: 2017-05-23
Posts: 20

TSQLDBProxyConnectionProperties - Quit in destructor after exception

Hi,

i just wanted to share a thought. In SetInternalProperties of the SQLDBProxyConnectionProperties, called from the constructor, the initial connect is made to the SQLDBServerHttpApi. After getting the token the session is established and the session id is retrieved.

SynDB.pas
procedure TSQLDBProxyConnectionPropertiesAbstract.SetInternalProperties;
...
begin
  ...
  Process(cGetToken,self,token);
  ...
  CurrentSession := Process(cGetDBMS,InputCredential,fDBMS);
end;

If anything is going wrong here (causing an exception), the destructor is called - since the exception happened in the constructor. In the destructor Process(Quit) is called, trying to end the session on the server.

destructor TSQLDBProxyConnectionPropertiesAbstract.Destroy;
begin
  try
    inherited Destroy;
    Process(cQuit,self,self);
  finally
    fProtocol.Free;
  end;
end;

If the connection never has been established (due to an connection error, wrong password) it will raise another exception in the destructor and in case of an timeout related connection error another wait for the timeout to happen. Wouldn't it make more sense to suppress the call to quit in such scenarios?

Thanks for your opinion,
Matthias

Offline

Board footer

Powered by FluxBB