develooper Front page | perl.perl5.porters | Postings from February 2000

[PATCH 5.5.660] ExtUtils::DynaLoader dl_unload_file() patch

Alan Burlison
February 29, 2000 10:01
[PATCH 5.5.660] ExtUtils::DynaLoader dl_unload_file() patch
Message ID:
Here's a patch against 5.5.660 to unload any shared objects opened via
ExtUtils::DynaLoader.  This fixes a long-standing and insidious bug
triggered by Apache/mod_perl when built with APXs - see the threads
starting at

I've implemented this as follows:

1.  Added a new XSUB to dl_dlopen.xs called dl_unload_file().  This
takes a library handle as returned by dl_load_file() and closes it.

2.  Added a new function to dlutils.c called dl_unload_all_files(). 
This checks to see if the XSUB dl_unload_file() has been defined, and if
it has it pops all the library handles from dl_librefs and calls
dl_close_file() on each one.  This unloads the dynamically loaded
libraries in the reverse order to which they were loaded.

3.  Modified dl_generic_private_init() in dlutils.c to install
Perl_call_atexit() handler that calls dl_unload_all_files() when the
interpreter exits.

4.  Documented the above in the appropriate places.

5.  Incremented the version number of ExtUtils::DynaLoader to 1.04

If this functionality is required for other platforms it should just be
necessary to add a dl_unload_file() XSUB to the appropriate dl_XXXX.xs
file.  I havn't done this for any files other than dl_dlopen.xs, as I
don't have access to any platforms other than Solaris.

Alan Burlison Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About