Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 10 of 14 total
Thread D3.3 ForceClose?
Thu, Jan 7 2010 8:44 AMPermanent Link

durumdara
Hi!

I have a new service that transfer some data through DBISAM 3.3 server and MS-SQL (9).
I want to make it "bomb-safe", so it is full with checks and try/excepts.

The main problem I experienced that I saw in IB/FB too that when the connection was
shutted down unexp. the Session and DataBase components remaining in Active state.
In IB/FB world this can solved with "ForceClose" method. This can cut the all old Handles
and make forced close on components.

Without this I cannot Close my Session and DB components. When I try to Close them, I got
network error, and I cannot get out from this hell...
I try to reopen connections but I cannot close them before... Frown

Can you help me with Magic Method that force closing?

Thanks:
  dd
Thu, Jan 7 2010 2:06 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com


<< I have a new service that transfer some data through DBISAM 3.3 server
and MS-SQL (9). I want to make it "bomb-safe", so it is full with checks and
try/excepts.

The main problem I experienced that I saw in IB/FB too that when the
connection was shutted down unexp. the Session and DataBase components
remaining in Active state. In IB/FB world this can solved with "ForceClose"
method. This can cut the all old Handles and make forced close on
components.

Without this I cannot Close my Session and DB components. When I try to
Close them, I got network error, and I cannot get out from this hell... I
try to reopen connections but I cannot close them before... Frown>>

Just set a global Application.OnException event handler, and disregard any
DBISAM communications error messages:

DBISAM_REMOTECOMMLOST
DBISAM_REMOTECONNECT

Something like this:

if (E is EDBISAMEngineError) then
   begin
   with EDBISAMEngineError(E) do
       begin
       case ErrorCode of
           DBISAM_REMOTECOMMLOST,DBISAM_REMOTECONNECT:
               begin
               if (not ShuttingDown) then
                   Application.ShowException(E);
               { Else ignore }
               end;
           else
               Application.ShowException(E);
           end;
       end;
   end
else
   Application.ShowException(E);

Just use a global ShuttingDown variable to determine if you're trying to
shut down the session, and then reset the ShuttingDown variable to False
before trying to reconnect the session again.

--
Tim Young
Elevate Software
www.elevatesoft.com

Mon, Jan 18 2010 2:45 AMPermanent Link

durumdara
<< I have a new service that transfer some data through DBISAM 3.3 server
and MS-SQL (9). I want to make it "bomb-safe", so it is full with checks and
try/excepts. >>

Hi!

As I experienced, the Free methods do not contain "Close".
If I call Free on DBISAMTable, the AfterClose method never called (so if I want to make temp tables on my local machine, I need to inherit a new
class for it.
If I call DataBase's Free method, it is not trying to Close.

Is it correct?

Thanks for your help:
  dd
Mon, Jan 18 2010 4:16 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com


<< As I experienced, the Free methods do not contain "Close". If I call Free
on DBISAMTable, the AfterClose method never called (so if I want to make
temp tables on my local machine, I need to inherit a new class for it.
If I call DataBase's Free method, it is not trying to Close.

Is it correct? >>

What version of Delphi are you using ?  I don't see that here with D5 or
higher.

TDataSet.Destroy looks like this:

destructor TDataSet.Destroy;
begin
 Destroying;
 Close;  <<<<<<<<<<<<<
..........

and TCustomConnection.Destroy (database) looks like this:

destructor TCustomConnection.Destroy;
begin
 inherited Destroy;
 SetConnected(False);    <<<<<<<<<<<<
..............

--
Tim Young
Elevate Software
www.elevatesoft.com

Wed, Jan 20 2010 4:27 AMPermanent Link

durumdara
"Tim Young [Elevate Software]" wrote:


<< As I experienced, the Free methods do not contain "Close". If I call Free
on DBISAMTable, the AfterClose method never called (so if I want to make
temp tables on my local machine, I need to inherit a new class for it.
If I call DataBase's Free method, it is not trying to Close.
Is it correct? >>

I use Delphi 6, and DBISAM 3.3.

Table Free:

destructor TDBISAMTable.Destroy;
begin
  FTempStopWords.Free;
  FMasterLink.Free;
  FRestructureFieldDefs.Free;
  FRestructureIndexDefs.Free;
  FIndexDefs.Free;
  inherited Destroy;
end;

None of "Close", and I experienced this when I want to delete temp table on "AfterClose".

Try it:

procedure TForm1.tAfterClose(DataSet: TDataSet);
begin
 Caption := 'XXXX';
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
 t.Open;
 //t.Close; if you use this, you get XXXX. If not, nothing happened...
 t.Free;
end;

And interesting that when I use:
Db.Free;
Session.Free;
then not problem, when the DataBase connection lost.

procedure TForm1.Button2Click(Sender: TObject);
begin
 // Open them all
 DBISAMSession1.Open;
 DBISAMDatabase1.Open;
 DBISAMTable1.Open;
 // After this I shutdown server
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
 // When I use close, I got errors
 DBISAMSession1.Close;
end;

procedure TForm1.Button4Click(Sender: TObject);
begin
 // When I make these Free-s
 DBISAMTable1.Free;
 DBISAMDatabase1.Free;
 // The closing is good, no error
 DBISAMSession1.Close;
end;

Hmmmmm... Interesting....

Sincerely:
   DD
Wed, Jan 20 2010 4:49 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

durumdara


When you see inherited destroy you have to look back along the inheritance chain. If you do you'll get to


destructor TDataSet.Destroy;
begin
 Destroying;
 Close;
 SetDataSetField(nil);
 FreeAndNil(FDesigner);
 if FDataSources <> nil then
   while FDataSources.Count > 0 do
     RemoveDataSource(FDataSources.Last);
 FreeAndNil(FDataSources);
 FreeAndNil(FFields);
 FreeAndNil(FAggFields);
 FreeAndNil(FFieldList);
 FreeAndNil(FFieldDefList);
 FreeAndNil(FFieldDefs);
 FreeAndNil(FConstraints);
 FreeAndNil(FNestedDataSets);
 inherited Destroy;
end;

which Tim is ultimately inheriting from and does have close.

Roy Lambert [Team Elevate]



Wed, Jan 20 2010 6:39 AMPermanent Link

durumdara
Roy Lambert wrote:

>durumdara
>When you see inherited destroy you have to look back along the inheritance chain. If you do you'll get to

Ok, chain is "living", but I tried today too, and when I used Free, that Close not called, and I don't get errors.

Thanks for your read:
  dd
Wed, Jan 20 2010 8:06 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com


<< Ok, chain is "living", but I tried today too, and when I used Free, that
Close not called, and I don't get errors. >>

So, is TDataSet.Destroy getting called ?  If so, is the Close method getting
called also ?  I'm having a hard time seeing how this could possibly be the
case.

--
Tim Young
Elevate Software
www.elevatesoft.com

Thu, Jan 21 2010 3:37 AMPermanent Link

durumdara
"Tim Young [Elevate Software]" wrote:


<< Ok, chain is "living", but I tried today too, and when I used Free, that
Close not called, and I don't get errors. >>

So, is TDataSet.Destroy getting called ?  If so, is the Close method getting
called also ?  I'm having a hard time seeing how this could possibly be the
case. >>>

Hi!

I cannot test it with full source. Because dbisam sources (pas) are wrong, I compile only dcu-s.
I got 64 errors.

The messages you can see in attachment. They are all Type problems, some types are not compatible with
other types. In the prev. year (when I don't tried to use dcus) I tried to eliminate them with forcing good type,
but it is Sisyphus-kind work...

But I don't understand you how to compile it... Surprised
Possible you don't use some options I used.

Thanks:
  dd



Attachments: messages.text
Thu, Jan 21 2010 3:50 AMPermanent Link

durumdara
<<<durumdara wrote:

But I don't understand you how to compile it... Surprised
Possible you don't use some options I used.>>

Hi!

Ok, I found Typed operators option, I disable this, and I can compile the source.

Possible the problem with DBISAMTable that first you do the "Destroying", and After the Close.

In DB.Pas you can see that before close not running on destroy!!!

       if not (csDestroying in ComponentState) then DoBeforeClose; //// THIS IS
       SetState(dsInactive);
       CloseCursor;
       if not (csDestroying in ComponentState) then DoAfterClose; //// AND THIS

This causing that the Table Bef/Aft. Close not handled.

dd
Page 1 of 2Next Page »
Jump to Page:  1 2
Image