Bill Stoddard wrote:
Stas Bekman wrote:

Bill and Bill, do you have any idea why do we get post_config and open_logs phases run 4 times instead of 2 (start+restart) on winnt mpm? It looks like each process that starts does its own config phase.


Yep, that's exactly right. Windows does not support fork(), so each process will run all the startup phase hooks. Twice.

Aha, so Geoff was right, that we can't make any assumption of behavior in different mpms.


You can use code like this to prevent the running a hook twice or running it in the parent process:

What constitutes a parent process if you can't fork?



/* Run post_config only on the second config pass */
apr_pool_userdata_get(&data, userdata_key, server_conf->process->pool);
if (!data) {
apr_pool_userdata_set((const void *)1, userdata_key,
apr_pool_cleanup_null, server_conf->process->pool);
return OK;
}

Yes, I know that trick (even suggested a common API which was never added), but start+restart are not a problem I think.


The problem could be the running of these phases by each process. So below you suggest to skip the run of post_config, open_logs in the child processes, right? I'm not sure whether this is a good, as my guess is that on the opposite you may want to run inside each child but not the parent, if you want to setup some data to be visible by the child processes.

#ifdef WIN32
    /* Do not run post_config in the Windows parent process
     * The envar AP_PARENT_PID is set in the env list (by mpm_winnt)
     * for the child process.
     * **WARNING**:
     * This check is not as robust as I would like because the name of this
     * envar is subject to change. Apache2 needs something like
     * ap_mpm_query(AP_MPMQ_IS_PARENT,&rc);
     */

    if (!getenv("AP_PARENT_PID")) {
        /* This is the parent, process */
    }
#endif

So is this AP_PARENT_PID env var there to stay? In which case we have all we need to control the bahavior. Thanks Bill


---

Steve, Randy, so we have two parts to deal with:

1) mod_perl's own post_config and open_logs hooks - we need to see whether they need to be run in the parent, child or both. e.g. the END blocks must not be run too many or too few times.

2) next, user's custom post_config and open_logs hooks could use the above C techniques (though coded in Perl) to have a complete control over when what happens. The sucky part is that a 3rd party module developer writing a
post_config and open_logs hooks won't be aware of these winnt mpm specifics. sigh.


You probably have much more undestanding of the above in the winnt land. So I'd leave it to you to take the further steps to document this behavior and suggest any special patches if such are required. Thanks.

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to