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

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

From:
Alan Burlison
Date:
February 29, 2000 10:01
Subject:
[PATCH 5.5.660] ExtUtils::DynaLoader dl_unload_file() patch
Message ID:
38BC0976.6121A0ED@uk.sun.com
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
http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2000-01/msg00709.html
and
http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2000-01/msg00794.html

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


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About