[patch_done] Patch in ZConnection.pas

Code patches written by our users to solve certain "problems" that were not solved, yet.

Moderators: gto, cipto_kh, EgonHugeist, mdaems

Post Reply
MerijnB
Fresh Boarder
Fresh Boarder
Posts: 13
Joined: 10.03.2009, 10:31
Location: The Netherlands
Contact:

[patch_done] Patch in ZConnection.pas

Post 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!
- A software developer is somebody who looks both left and right before crossing a one-way street.
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

SVN commit 604.

Mark
Image
Post Reply