cancel
Showing results for 
Search instead for 
Did you mean: 

Apache 2 mod_so on HP_UX 11.11

Tony Abo
Occasional Advisor

Apache 2 mod_so on HP_UX 11.11

I have a software library that runs as a dynamically loaded Apache module. In the operation of the software, processes are forked from the the httpd handler processes in response to certain types of requests.

My intention has been to use the Apache web server provided by HP (Apache/2.0.59 HP-UX_Apache-based_Web_Server). Because the HP supplied Apache is compiled with worker mpm, my library code assumes that it will be called in a multithreaded environment, and uses thread local storage to maintain certain information.

My immediate problem is that on some systems the fork() function fails frequently with ENOMEM. It would seem that the httpd processes have very large working sets, and forking new processes from them must be requiring too much virtual memory.

On examination of things, I discovered that all of the shared libraries being loaded with the LoadModule directive (including mine), are being loaded with text segments being copied to local storage. That would certainly explain unusually large working sets.

I used chatr to check the setting of and to attempt to insure the setting of "+dgb disable", but the behavior does not seem to change. I have also found that on other HP-UX 11.11 systems, the text segments of shared libraries are being used in shared memory, so the behavior on this one system is extremely baffling.

In an attempt to learn more about shared library mapping, I attempted to write my own standalone program to dynamically map my shared library and see if it was behaving similar to the Apache case. I soon discovered that I could neither load my library with dlopen() nor with shl_load(), because the library uses thread local storage (as documented on their respective manual pages). How then does Apache load my module?

I tried building an Apache server from sources and discovered that my own server refuses to load my library due to the TLS restriction in dlopen() and shl_load().

I have concluded that the Apache built by HP has it's own special code to load libraries. Since I have no idea how that code works, I cannot do any further experiments to understand the dynamic of my situation.

Can anyone tell me:

1. why the text segments of my library are being copied to private memory for each process, even though chatr reports "shared library private mapping disabled" (+dbg disable)?

2. how the HP supplied Apache 2 implements the LoadModule command? Is there source code for this version available?

Thank you.
3 REPLIES
Dennis Handly
Acclaimed Contributor

Re: Apache 2 mod_so on HP_UX 11.11

>1. why the text segments of my library are being copied to private memory for each process, even though chatr reports "shared library private mapping disabled" (+dbg disable)?

Where are you using chatr(1), on the executable?

>2. how the HP supplied Apache 2 implements the LoadModule command?

It has to call dlopen(3) or shl_load(3), there is no other way.

>my library code assumes that it will be called in a multi-threaded environment, and uses thread local storage

If you were on Integrity, you could use dynamic TLS.

>How then does Apache load my module? ... Since I have no idea how that code works,

I don't see how. You could try using tusc to see what happens.
Shinji Teragaito_1
Respected Contributor

Re: Apache 2 mod_so on HP_UX 11.11

HP-UX Apached-based Web Server B.2.0.* and B.2.2.8.* provide
sample module code:
- B.2.0.*: /opt/hpws/apache/build/examples
- B.2.2.8.*: /opt/hpws22/apache/build/examples

They may be helpful to you.

I don't suppose Web Server Suite lab changes the methods to load
modules from the original ASF code.... So if you have Apache
2.0.* or 2.2.* source code, that should give you some helps.
Dennis Handly
Acclaimed Contributor

Re: Apache 2 mod_so on HP_UX 11.11

>uses thread local storage

You could replace hardware TLS by software TLS and use pthread_getspecific(3).