You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modules-dev@httpd.apache.org by Michael Durket <du...@highwire.stanford.edu> on 2009/11/10 23:40:44 UTC

post-config phase question

Based on the few books that describe Apache module writing and a presentation
that I've found on the web from an Apache conference, the advice to module 
writers is to remember that Apache calls the post-config phase twice - once 
while it's checking its configuration files, and then when it's ready to start up
it discards all that and calls post-config again to really set things up.

But it appears to me (via tracing I've done in my own module) that post-config
is actually called once at configuration file checking time, and then once per 
server process start (we're using MPM here) during the second (actual Apache
startup phase).

Is this correct?


Re: post-config phase question

Posted by Michael Durket <du...@highwire.stanford.edu>.
Actually, I think it had to do with my trace function. Instead of using an ap_log_error call
I was using fprintf for a very quick-and-dirty solution. Once I stopped doing that the 
multiple copies of the messages went away. I thought I could get away with 
using fprintf this time, but obviously not.

On Nov 11, 2009, at 7:26 AM, Eric Covener wrote:

> On Wed, Nov 11, 2009 at 10:06 AM, Michael Durket
> <du...@highwire.stanford.edu> wrote:
>> Weird, because I'm tracing the entry to post-config in my code and the second
>> phase seems to be called 8 times which on my system is the value listed in the StartServers
>> directive.
> 
> Sounds like you're either hooked into child_init or calling some code
> from both post_config and child_init -- can you post the smallest
> working module that demonstrates it?
> 
> (also on Windows, 4 times is normal -- 2 in the parent and 2 in the child)
> 
> -- 
> Eric Covener
> covener@gmail.com


Re: post-config phase question

Posted by Eric Covener <co...@gmail.com>.
On Wed, Nov 11, 2009 at 10:06 AM, Michael Durket
<du...@highwire.stanford.edu> wrote:
> Weird, because I'm tracing the entry to post-config in my code and the second
> phase seems to be called 8 times which on my system is the value listed in the StartServers
> directive.

Sounds like you're either hooked into child_init or calling some code
from both post_config and child_init -- can you post the smallest
working module that demonstrates it?

(also on Windows, 4 times is normal -- 2 in the parent and 2 in the child)

-- 
Eric Covener
covener@gmail.com

Re: post-config phase question

Posted by Michael Durket <du...@highwire.stanford.edu>.
Weird, because I'm tracing the entry to post-config in my code and the second 
phase seems to be called 8 times which on my system is the value listed in the StartServers 
directive.

On Nov 10, 2009, at 2:45 PM, Sorin Manolache wrote:

> On Tue, Nov 10, 2009 at 23:40, Michael Durket
> <du...@highwire.stanford.edu> wrote:
>> Based on the few books that describe Apache module writing and a presentation
>> that I've found on the web from an Apache conference, the advice to module
>> writers is to remember that Apache calls the post-config phase twice - once
>> while it's checking its configuration files, and then when it's ready to start up
>> it discards all that and calls post-config again to really set things up.
>> 
>> But it appears to me (via tracing I've done in my own module) that post-config
>> is actually called once at configuration file checking time, and then once per
>> server process start (we're using MPM here) during the second (actual Apache
>> startup phase).
>> 
>> Is this correct?
> 
> No. It's done twice, before forking the children. The post_configs run
> as the user who launched apache (typically root), before the sever
> switches to the user/group specified in the corresponding
> configuration directives.
> 
> Have a look in server/main.c in the sources of apache.
> 
> Sorin


Re: post-config phase question

Posted by Sorin Manolache <so...@gmail.com>.
On Tue, Nov 10, 2009 at 23:40, Michael Durket
<du...@highwire.stanford.edu> wrote:
> Based on the few books that describe Apache module writing and a presentation
> that I've found on the web from an Apache conference, the advice to module
> writers is to remember that Apache calls the post-config phase twice - once
> while it's checking its configuration files, and then when it's ready to start up
> it discards all that and calls post-config again to really set things up.
>
> But it appears to me (via tracing I've done in my own module) that post-config
> is actually called once at configuration file checking time, and then once per
> server process start (we're using MPM here) during the second (actual Apache
> startup phase).
>
> Is this correct?

No. It's done twice, before forking the children. The post_configs run
as the user who launched apache (typically root), before the sever
switches to the user/group specified in the corresponding
configuration directives.

Have a look in server/main.c in the sources of apache.

Sorin