Page 1 of 1

[patch_done] Patch in ZConnection.pas

Posted: 10.03.2009, 10:50
by MerijnB
I'm doing some test with detecting connection problems while being connected to a FireBird database. I noticed the following in ZConnection.pas, which might be an issue:

Code: Select all

procedure TZConnection.Disconnect;
begin
  if FConnection <> nil then
  begin
    DoBeforeDisconnect;

    ShowSqlHourGlass;
    try
      CloseAllDataSets;
      // Modified by cipto 8/2/2007 10:11:02 AM
      CloseAllSequences;
      FConnection.Close;
      FConnection := nil;
    finally
      HideSqlHourGlass;
    end;

    DoAfterDisconnect;
  end;
end;
FConnect := nil; comes after FConnection.Close;
If your network connection is gone, and you try to close the connection to reconnect later, calling FConnection.Close will raise an exception (in ZDbcInterbase6Utils.CheckInterbase6Error), which causes FConnection never to be changed to nil.

As long as FConnection is assigned, you can't reconnect. My suggestion is to change above code to:

Code: Select all

procedure TZConnection.Disconnect;
begin
  if FConnection <> nil then
  begin
    DoBeforeDisconnect;

    ShowSqlHourGlass;
    try
      CloseAllDataSets;
      // Modified by cipto 8/2/2007 10:11:02 AM
      CloseAllSequences;
      FConnection.Close;
    finally
      FConnection := nil;
      HideSqlHourGlass;
    end;

    DoAfterDisconnect;
  end;
end;
Every feedback is welcome!

Posted: 20.03.2009, 23:08
by mdaems
SVN commit 604.

Mark