httpd-modules-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sorin Manolache" <>
Subject Re: Where to initialize a global pool/hash - server create or child_init?
Date Sun, 04 Jan 2009 11:17:29 GMT
On Sun, Jan 4, 2009 at 05:03, Jacques Amar <> wrote:
> Where to begin ....
> I am creating a global pool/hash in which I save cached, hard to calculate
> data (pre-compiled regex expressions etc.). I also store pages I've created
> using this data in memcached (using the APR interface). I can't save the
> calculated regex data in memcached. I initially followed the advice of
> creating a private pool, hash and mutex inside a child_init hook in my
> server config structure, protecting all access with the mutex. The module
> works well enough in regular httpd. However, when I tried this in worker MPM
> I got constant:
> [notice] child pid xxxxx exit signal Segmentation fault (11)
> after a few page loads.
> On a whim, I moved the whole creation of these structures into a server
> config hook. All these issues seem to have vanished. I have "theorized" that
> the pool I am creating at every child creation does not properly work.
> I am looking for a discussion of the pros and cons of creating this in a per
> child hook, versus the one time server create hook and any other pointers to
> help decide (and debug) where/when I should use one or the other.

pre/post_config are run as the user who starts the server (root
typically). child_init is run as the httpd user (configured with the
User config directive).

If the hash is read-only (it is never changed after initialisation) I
guess you don't even need the mutex. In this case, I guess there's no
difference between child_init and post_config (except the effective
UID that runs the code, as said above).

If the data is changed by one worker and you want the change be
visible to all other workers, you have to put your initialisation in

Regarding debugging, run your apache in debug (single-process) mode
(apache2 -X) and check if you still get the segfaults. If yes, load
apache2 in a debugger (I use gdb):

gdb $HOME/usr/sbin/apache2
set args -f $HOME/etc/apache2/apache2.conf -X
break my_handler

Issue a request and check where it segfaults.


A: Because it reverses the logical flow of conversation.
Q: Why is top-posting frowned upon?
A: Top-posting.
Q: What is the most annoying thing in e-mail?

View raw message