Menu

#5 Shared DB Info reference counting doesn't work

closed-accepted
None
6
2005-10-05
2005-10-04
No

When using the same database in several connections,
the reference count is not increased for subsequent
uses. This means that the first connection to stop using
the database gives the corresponding DatabaseInfo
object free. All other uses of the connection (e.g. in other
threads) then crash because the shared critical section
for the database is gone.

The problem can be fixed in passqlite.pas in TLiteDB.Use
by changing the handling when a database already exists
(beginning on line 716):

FActive := (Database<>'');
Result := FActive;
if Result then begin
FBaseInfo:= TBaseInfo(DataBases.
Objects[DataBases.IndexOf(DataBase)]);
>>> Inc( FBaseInfo.ReferenceCount );
end else
FBaseInfo := nil;

The crucial line to add is marked with >>>.

passqlite3 suffers from the same problem and can be
fixed similarly on line 353.

Discussion

  • René Tegel

    René Tegel - 2005-10-05
    • priority: 5 --> 6
    • assigned_to: nobody --> artee
    • status: open --> open-accepted
     
  • René Tegel

    René Tegel - 2005-10-05
    • status: open-accepted --> closed-accepted
     
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.