Subject Unloading gds32.dll problem
Author dmarmur2002
Hi!

I dont know when this started. When I connect to a database the
application takes ages to stop running in the IDE after normal
shutdown. I checked it stand alone and it resides in memory (task
manager) a long while after shutdown.

I found the source line where this happens, it's called from
IB_Session.pas;

procedure ReleaseSessionHookRef;
begin
if InterlockedDecrement( FGDS_RefCount ) = 0 then
begin
DeleteCriticalSection( AttachCS );
DeleteCriticalSection( GlobalCS );
if FGDS_Handle >= 32 then
FreeLibrary( FGDS_Handle );
^^^ This line takes ages...
FGDS_Handle := 0;
{$IFDEF ALLOW_DEFAULT_SESSION}
TlsFree( hDefaultSession );
hDefaultSession := 0;
{$ENDIF}
{$IFDEF ALLOW_ALT_SESSION}
TlsFree( hAlternateSession );
hAlternateSession := 0;
{$ENDIF}
end;
end;

I compiled a small "clean" project and this shows same behaviour. I
don't know where to start poking. The project is loading fbclient.dll
from C:\WINDOWS\SYSTEM32\gds32.dll.

IBExpert does not seem to suffer from this, so it seems to be IBO
related? It happens on both my machines (connection to the same
server). But, on the machine running the server it takes much longer
to unload.

I have searched my machines for gds32.dll and fbclient.dll and their
all the correct version and not cluttered everywhere. I'm using FB
1.5.2 and IBO 4.5Ai, Delphi 7.1.

Sometimes I get an AV in SysDisconnect, but that's rare and might have
something to do with debugging.

procedure TIB_Connection.SysDisconnect;
begin
if Connected then
begin
SysBeforeDisconnect;
API_Disconnect;
SysAfterDisconnect;
^^^ AV in gds32.dll, debugger stops here!
end;
end;

Anyone have any ideas?

Thanks a lot,

/Dany