On Mon, 24 Jun 2002, Rasmus Lerdorf wrote:

> > > What is the correct way to fail in a filter post_config?  Do I return
> > -1
> > > from it if my filter finds a fatal error?  I can't use ap_log_rerror()
> > at
> > > this point, right?  How would I log the reason for the failure?
> >
> > I'm confused by the question, but I'll try to answer.  If you mean the
> > post_config phase, then you can use ap_log_error or ap_log_perror.  If
> > you want to stop the server from starting, just return DECLINED.
>
> Right, I found ap_log_error.  It was the return value I was looking for.
> None of the example filter modules had a fatal error check at the config
> phase.  So returning a -1 is the correct way to stop the server from
> starting.  Thanks.

Hrm..  Nope.  doing 'return DECLINED' from the post_config phase does not
stop the server from starting.  I have this:

static int
php_apache_server_startup(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp, 
server_rec *s)
{
    void *data = NULL;
    const char *userdata_key = "apache2filter_post_config";
#ifndef ZTS
    int threaded_mpm;

    ap_mpm_query(AP_MPMQ_IS_THREADED, &threaded_mpm);
    if(threaded_mpm) {
        ap_log_error(APLOG_MARK, APLOG_CRIT, 0, s, "Apache is running a threaded MPM, 
but your PHP Module is not compiled to be threadsafe.  You need to recompile PHP.");
        return DECLINED;
    }
#endif
...
}

...

    ap_hook_pre_config(php_pre_config, NULL, NULL, APR_HOOK_MIDDLE);
    ap_hook_post_config(php_apache_server_startup, NULL, NULL, APR_HOOK_MIDDLE);

And in my log I get:

[Mon Jun 24 08:27:23 2002] [crit] Apache is running a threaded MPM, but your PHP 
Module is not compiled to be threadsafe.  You need to recompile PHP.
[Mon Jun 24 08:27:23 2002] [crit] Apache is running a threaded MPM, but your PHP 
Module is not compiled to be threadsafe.  You need to recompile PHP.
[Mon Jun 24 08:27:23 2002] [notice] Apache/2.0.40-dev (Unix) configured -- resuming 
normal operations

Reply via email to