[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference turris::digital_unix

Title:DIGITAL UNIX(FORMERLY KNOWN AS DEC OSF/1)
Notice:Welcome to the Digital UNIX Conference
Moderator:SMURF::DENHAM
Created:Thu Mar 16 1995
Last Modified:Fri Jun 06 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:10068
Total number of notes:35879

9157.0. "Forcing a dlclose ?" by MUFFIT::gerry (Gerry Reilly) Thu Mar 13 1997 06:56

I am having a problem with forcing the unload of a shared library.  The 
libary loads fine using dlopen, and unloads fine - provided that I never
call anything in it (no surprise here). 

However, if I have called a function in the library, the dlclose
appears to succeed (no error reported through dlerror), but the libary
has not unloaded.  I am checking what modules are loaded by using
ldr_next_module/ldr_inq_module.

Unfortunately, I need to force an unload of the shared object so that
I can and reload it cleanly.  The reason for needing to do this
is unpleasant, basically around forcing a clean restart of the Micro Focus
runtime, and has worked on other platforms.

This is on Digital UNIX V4.0a.

Any suggestions ?

-gerry
T.RTitleUserPersonal
Name
DateLines
9157.1VAXCPU::michaudJeff Michaud - ObjectBrokerThu Mar 13 1997 10:5415
	I believe shared libs loaded into your process are reference
	counted.  So if someone in your process has done a dlopen
	(either explicitly, or implicitly by being linked against
	the shared lib, or a shared lib that is linked against the shared
	lib, etc etc), subsequent dlopen's of a shared lib already loaded
	simply increment a reference count.

	And the reference happens when with dlclose, it decrements the
	reference count and only if it's zero does the library really
	get unloaded (otherwise you would pull the rug out from under
	somebody else in your process).

	You could try to force the shared lib to be unloaded by making
	multiple calls to dlclose, but this is risky as you are likely
	pulling the rug out from somebody else in your process ...
9157.2I'll try multiple dlclose calls..MUFFIT::gerryGerry ReillyThu Mar 13 1997 11:046
Thanks.  I'll actually try multiple dlclose calls.  I know who
the somebody else is (I know it isn't my code!) and I probably
don't care about pulling the rug as I know they (the somebody else) is
never going to get called again.

-gerry
9157.3SMURF::LOWELLFri Mar 28 1997 09:5118
Gerry,

dlopen keeps two counts.  The first is the number of times dlopen
is called for that library, and the second is the number of other
libraries that reference that library as a dependency.  

Whether you call something in the library shouldn't make any difference
as to whether it can be closed or not.  (Unless of course, you call
something that results in another dlopen of that library or something
that references that library.)

Please submit a QAR, with test case if possible, otherwise include
the dependency lists (odump -Dl) of all of the shared libs used by
the program and note which ones are dynamically loaded. 

Thanks,
Randy
9157.4QAR 52310MUFFIT::gerryGerry ReillyThu Apr 03 1997 08:455
QAR 52310

Thanks for the help.

-gerry