You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Eli Marmor <ma...@netmask.it> on 2002/05/28 03:55:14 UTC

Repeating Calls to apr_dso_load()

Can it be assumed that calling apr_dso_load() twice for the same shared
object, will not re-open that file, but just returns the same handle?

I know that under dlopen platforms (most of the UNIXes), it is true.

If it isn't true under other platforms, then it may help to manage a
list of the files that were loaded (e.g. in win32/dso.c), and before
loading a shared object, to search for it there, and if it is there,
return the original handle rather than re-loading it.

I thing that double load of a shared object may cause crashes and other
strange behaviors.

If you can check the functionality of double call to apr_dso_load()
under win32, DSO_USE_SHL platforms, etc., then please check it. You may
use something like the following program:

#include <dlfcn.h>

main() {
  printf("%d\n", dlopen("/lib/libz.so.1", RTLD_NOW|RTLD_GLOBAL));
  printf("%d\n", dlopen("/lib/libz.so.1", RTLD_NOW|RTLD_GLOBAL));
}

Of course, you should put a shared object that you have in your system,
and replace the dlopen by the appropriate function (e.g. shl_load).

If there is an environment where the returned values are different,
then this platform needs the patch I mentioned above.

And if the conclusion is that such a patch is needed, then I'm willing
to do it.

-- 
Eli Marmor
marmor@netmask.it
CTO, Founder
Netmask (El-Mar) Internet Technologies Ltd.
__________________________________________________________
Tel.:   +972-9-766-1020          8 Yad-Harutzim St.
Fax.:   +972-9-766-1314          P.O.B. 7004
Mobile: +972-50-23-7338          Kfar-Saba 44641, Israel

Re: Repeating Calls to apr_dso_load()

Posted by Eli Marmor <ma...@netmask.it>.
Aaron Bannert wrote:

> [copying the APR dev list]

[I'm not subscribed to APR, and this message will probably be refused,
so please forward it to them]

> On Tue, May 28, 2002 at 04:55:14AM +0300, Eli Marmor wrote:
> > Can it be assumed that calling apr_dso_load() twice for the same shared
> > object, will not re-open that file, but just returns the same handle?
> 
> LoadLibrary*() on Windows does reference counting, and same goes for
> dlopen().

Thank you very much for the info about LoadLibrary().
Regarding dlopen(), I already mentioned it in my original question
(well, you wouldn't expect me to raise a question without checking it
first...).

I think that assuming that most of the rest are not critical
(NSLinkModule, load_add_on of BeOS, DosLoadModule of OS/2, dllload of
OS/390), we have only to check what happens with shl_load() (HP-UX).
If the behavior of shl_load() is similar, then it will not be wrong
to say that more than 99% of the installations of Apache behave this
way (the sum of dlopen() + shl_load() + LoadLibrary() ).

-- 
Eli Marmor
marmor@netmask.it
CTO, Founder
Netmask (El-Mar) Internet Technologies Ltd.
__________________________________________________________
Tel.:   +972-9-766-1020          8 Yad-Harutzim St.
Fax.:   +972-9-766-1314          P.O.B. 7004
Mobile: +972-50-23-7338          Kfar-Saba 44641, Israel

Re: Repeating Calls to apr_dso_load()

Posted by Eli Marmor <ma...@netmask.it>.
Aaron Bannert wrote:

> [copying the APR dev list]

[I'm not subscribed to APR, and this message will probably be refused,
so please forward it to them]

> On Tue, May 28, 2002 at 04:55:14AM +0300, Eli Marmor wrote:
> > Can it be assumed that calling apr_dso_load() twice for the same shared
> > object, will not re-open that file, but just returns the same handle?
> 
> LoadLibrary*() on Windows does reference counting, and same goes for
> dlopen().

Thank you very much for the info about LoadLibrary().
Regarding dlopen(), I already mentioned it in my original question
(well, you wouldn't expect me to raise a question without checking it
first...).

I think that assuming that most of the rest are not critical
(NSLinkModule, load_add_on of BeOS, DosLoadModule of OS/2, dllload of
OS/390), we have only to check what happens with shl_load() (HP-UX).
If the behavior of shl_load() is similar, then it will not be wrong
to say that more than 99% of the installations of Apache behave this
way (the sum of dlopen() + shl_load() + LoadLibrary() ).

-- 
Eli Marmor
marmor@netmask.it
CTO, Founder
Netmask (El-Mar) Internet Technologies Ltd.
__________________________________________________________
Tel.:   +972-9-766-1020          8 Yad-Harutzim St.
Fax.:   +972-9-766-1314          P.O.B. 7004
Mobile: +972-50-23-7338          Kfar-Saba 44641, Israel

Re: Repeating Calls to apr_dso_load()

Posted by Aaron Bannert <aa...@clove.org>.
[copying the APR dev list]

On Tue, May 28, 2002 at 04:55:14AM +0300, Eli Marmor wrote:
> Can it be assumed that calling apr_dso_load() twice for the same shared
> object, will not re-open that file, but just returns the same handle?

LoadLibrary*() on Windows does reference counting, and same goes for
dlopen().

-aaron

Re: Repeating Calls to apr_dso_load()

Posted by Aaron Bannert <aa...@clove.org>.
[copying the APR dev list]

On Tue, May 28, 2002 at 04:55:14AM +0300, Eli Marmor wrote:
> Can it be assumed that calling apr_dso_load() twice for the same shared
> object, will not re-open that file, but just returns the same handle?

LoadLibrary*() on Windows does reference counting, and same goes for
dlopen().

-aaron