You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Ryan Bloom <rb...@covalent.net> on 2002/06/23 16:02:28 UTC

RE: Apache 2.0 Numbers

> > It would be nice
> > if there was an apxs flag that would return the MPM type.
> 
> +1

There is.  -q will query for any value in config_vars.mk, and MPM_NAME
is in that file.  So `apxs -q MPM_NAME` will return the configured MPM
type.

Ryan


Re: Apache 2.0 Numbers

Posted by Ian Holsman <ia...@apache.org>.
Ryan Bloom wrote:
>>>It would be nice
>>>if there was an apxs flag that would return the MPM type.
>>
>>+1
> 
> 
> There is.  -q will query for any value in config_vars.mk, and MPM_NAME
> is in that file.  So `apxs -q MPM_NAME` will return the configured MPM
> type.
> 
> Ryan
> 
This is the wrong approach IMHO. we should have a flag to determine if 
threading is enabled, and use that to base the decision on. I can see in 
the future where we might have 2 non-threaded MPM's and then all the 
people using this flag will break

--Ian





Re: Apache 2.0 Numbers

Posted by "Paul J. Reder" <re...@remulak.net>.
...as in stick a fork in it, its 'DONE". ;)

Rasmus Lerdorf wrote:

>>As it happens, DONE is defined to be -2.   :-)
>>
> 
> Ok, I will use that, but 'DONE' doesn't really give the impression of
> being a fatal error return value.
> 
> -Rasmus
> 
> 
> 


-- 
Paul J. Reder
-----------------------------------------------------------
"The strength of the Constitution lies entirely in the determination of each
citizen to defend it.  Only if every single citizen feels duty bound to do
his share in this defense are the constitutional rights secure."
-- Albert Einstein



RE: Apache 2.0 Numbers

Posted by Ryan Bloom <rb...@covalent.net>.
> From: Rasmus Lerdorf [mailto:rasmus@apache.org]
> 
> > As it happens, DONE is defined to be -2.   :-)
> 
> Ok, I will use that, but 'DONE' doesn't really give the impression of
> being a fatal error return value.

I know.  It's original use was for use during request processing, when a
module wanted to be sure that it was the last function run for a
specific hook.  Basically this value ensured that no other functions
were run for that hook.

Ryan



RE: Apache 2.0 Numbers

Posted by Rasmus Lerdorf <ra...@apache.org>.
> As it happens, DONE is defined to be -2.   :-)

Ok, I will use that, but 'DONE' doesn't really give the impression of
being a fatal error return value.

-Rasmus


RE: Apache 2.0 Numbers

Posted by Ryan Bloom <rb...@covalent.net>.
> From: Rasmus Lerdorf [mailto:rasmus@apache.org]
> 
> On Mon, 24 Jun 2002, Cliff Woolley wrote:
> > On Mon, 24 Jun 2002, Rasmus Lerdorf wrote:
> >
> > > Hrm..  Nope.  doing 'return DECLINED' from the post_config phase
does
> not
> > > stop the server from starting.  I have this:
> >
> > I thought you were supposed to return HTTP_INTERNAL_SERVER_ERROR.
> 
> In include/http_config.h it says:
> 
> /**
>  * Run the post_config function for each module
>  * @param pconf The config pool
>  * @param plog The logging streams pool
>  * @param ptemp The temporary pool
>  * @param s The list of server_recs
>  * @return OK or DECLINED on success anything else is a error
>  */
> 
> So I guess I need to return 'anything else'
> 
> Trying this, ie. returning -2 it does the job.  But this seems a
little
> vague.  Should we perhaps have a #define FATAL -2 or something similar
so
> I don't get stepped on later on if someone decides to use -2 for
something
> else?

As it happens, DONE is defined to be -2.   :-)

Ryan



RE: Apache 2.0 Numbers

Posted by Rasmus Lerdorf <ra...@apache.org>.
On Mon, 24 Jun 2002, Cliff Woolley wrote:
> On Mon, 24 Jun 2002, Rasmus Lerdorf wrote:
>
> > Hrm..  Nope.  doing 'return DECLINED' from the post_config phase does not
> > stop the server from starting.  I have this:
>
> I thought you were supposed to return HTTP_INTERNAL_SERVER_ERROR.

In include/http_config.h it says:

/**
 * Run the post_config function for each module
 * @param pconf The config pool
 * @param plog The logging streams pool
 * @param ptemp The temporary pool
 * @param s The list of server_recs
 * @return OK or DECLINED on success anything else is a error
 */

So I guess I need to return 'anything else'

Trying this, ie. returning -2 it does the job.  But this seems a little
vague.  Should we perhaps have a #define FATAL -2 or something similar so
I don't get stepped on later on if someone decides to use -2 for something
else?

And no, I don't think it makes sense to overload INTERNAL_SERVER_ERROR for
this.  To me that is a 500 error which is very much tied to a
request-level error.

-Rasmus


RE: Apache 2.0 Numbers

Posted by Ryan Bloom <rb...@covalent.net>.
> From: Cliff Woolley [mailto:jwoolley@virginia.edu]
> 
> On Mon, 24 Jun 2002, Rasmus Lerdorf wrote:
> 
> > Hrm..  Nope.  doing 'return DECLINED' from the post_config phase
does
> not
> > stop the server from starting.  I have this:
> 
> I thought you were supposed to return HTTP_INTERNAL_SERVER_ERROR.

No.  That implies that you have an actual HTTP error.  You don't, this
is during config processing, not request processing.  Yes, that value
will work, but it is incorrect semantically.

Ryan



RE: Apache 2.0 Numbers

Posted by Cliff Woolley <jw...@virginia.edu>.
On Mon, 24 Jun 2002, Rasmus Lerdorf wrote:

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

I thought you were supposed to return HTTP_INTERNAL_SERVER_ERROR.

--Cliff


RE: Apache 2.0 Numbers

Posted by Ryan Bloom <rb...@covalent.net>.
My bad.  Post_config is a run_all.  If you return DONE the server won't
start.  This is what the MPMs do if the socket is already taken.

Ryan

----------------------------------------------
Ryan Bloom                  rbb@covalent.net
645 Howard St.              rbb@apache.org
San Francisco, CA 

> -----Original Message-----
> From: Rasmus Lerdorf [mailto:rasmus@apache.org]
> Sent: Monday, June 24, 2002 8:34 AM
> To: Ryan Bloom
> Cc: dev@httpd.apache.org
> Subject: RE: Apache 2.0 Numbers
> 
> 
> 
> 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



RE: Apache 2.0 Numbers

Posted by Rasmus Lerdorf <ra...@apache.org>.

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


RE: Apache 2.0 Numbers

Posted by Rasmus Lerdorf <ra...@apache.org>.
> > 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.

-Rasmus


RE: Apache 2.0 Numbers

Posted by Ryan Bloom <rb...@covalent.net>.
> From: Rasmus Lerdorf [mailto:rasmus@apache.org]
> 
> > Runtime is harder, but you can just use ap_mpm_query to get the MPMs
> > characteristics.  This won't give you the MPM name, but it will let
you
> > know if the MPM is threaded or not.
> 
> 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.

Ryan



RE: Apache 2.0 Numbers

Posted by Rasmus Lerdorf <ra...@apache.org>.
> Runtime is harder, but you can just use ap_mpm_query to get the MPMs
> characteristics.  This won't give you the MPM name, but it will let you
> know if the MPM is threaded or not.

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?

-Rasmus


RE: Apache 2.0 Numbers

Posted by Ryan Bloom <rb...@covalent.net>.
> From: Rasmus Lerdorf [mailto:rasmus@apache.org]
> 
> > > > It would be nice
> > > > if there was an apxs flag that would return the MPM type.
> > >
> > > +1
> >
> > There is.  -q will query for any value in config_vars.mk, and
MPM_NAME
> > is in that file.  So `apxs -q MPM_NAME` will return the configured
MPM
> > type.
> 
> Ah right.  Is there a way to check at runtime as well?  I've added a
PHP
> configure check now to the apache2filter sapi module so it will come
up
> non-threaded by default if it sees Apache2-prefork.  Just a bit
worried
> about someone changing their MPM after the fact, so perhaps a runtime
> check is needed as well.

Runtime is harder, but you can just use ap_mpm_query to get the MPMs
characteristics.  This won't give you the MPM name, but it will let you
know if the MPM is threaded or not.

Ryan



RE: Apache 2.0 Numbers

Posted by Rasmus Lerdorf <ra...@apache.org>.
> > > It would be nice
> > > if there was an apxs flag that would return the MPM type.
> >
> > +1
>
> There is.  -q will query for any value in config_vars.mk, and MPM_NAME
> is in that file.  So `apxs -q MPM_NAME` will return the configured MPM
> type.

Ah right.  Is there a way to check at runtime as well?  I've added a PHP
configure check now to the apache2filter sapi module so it will come up
non-threaded by default if it sees Apache2-prefork.  Just a bit worried
about someone changing their MPM after the fact, so perhaps a runtime
check is needed as well.

-Rasmus