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 Roland Genske <rh...@marxmeier.com> on 2006/10/13 18:10:05 UTC

How to detect at runtime if this is a prefork or threaded server?

Hello all,

is it possible for a module to detect at runtime whether it runs in
a "prefork" server or in a "worker" (threaded) server? Our module
must behave differently depending on this.

Or are we required to provide a separate build for each configuration?

Thank you for your help,
Roland

Re: How to detect at runtime if this is a prefork or threaded server?

Posted by Nick Kew <ni...@webthing.com>.
On Friday 13 October 2006 17:10, Roland Genske wrote:
> Hello all,
>
> is it possible for a module to detect at runtime whether it runs in
> a "prefork" server or in a "worker" (threaded) server? Our module
> must behave differently depending on this.

You already got the straight answer.

There's an alternative that might be worth looking at, depending on
what your module does that prompts the question.  You can also use 
APR definitions

#if APR_HAS_THREADS
    ... do thready things ...
#else
    ... do non-thready things ...
#endif

This will give different results to ap_mpm_query, as Prefork can
be built on a threaded APR.

-- 
Nick Kew

Application Development with Apache - the Apache Modules Book
http://www.prenhallprofessional.com/title/0132409674

Re: How to detect at runtime if this is a prefork or threaded server?

Posted by Roland Genske <rh...@marxmeier.com>.
Hello Davi,

great, thank you very much!

Roland

Davi Arnaut wrote:
> Roland Genske wrote:
>> Hello all,
>>
>> is it possible for a module to detect at runtime whether it runs in
>> a "prefork" server or in a "worker" (threaded) server? Our module
>> must behave differently depending on this.
> 
> ap_mpm_query() with AP_MPMQ_IS_FORKED or AP_MPMQ_IS_THREADED.
> 
> --
> Davi Arnaut


Re: How to detect at runtime if this is a prefork or threaded server?

Posted by Davi Arnaut <da...@haxent.com.br>.
Roland Genske wrote:
> Hello all,
> 
> is it possible for a module to detect at runtime whether it runs in
> a "prefork" server or in a "worker" (threaded) server? Our module
> must behave differently depending on this.

ap_mpm_query() with AP_MPMQ_IS_FORKED or AP_MPMQ_IS_THREADED.

--
Davi Arnaut

Re: How to detect at runtime if this is a prefork or threaded server?

Posted by Roland Genske <rh...@marxmeier.com>.
Hi Sander,

thank you very much. This is what I needed to know :-)

Roland


Sander Temme wrote:
> 
> On Oct 13, 2006, at 11:10 AM, Roland Genske wrote:
> 
>> is it possible for a module to detect at runtime whether it runs in
>> a "prefork" server or in a "worker" (threaded) server? Our module
>> must behave differently depending on this.
> 
> Check out ap_mpm_query(), defined in ap_mpm.h. It can tell you whether 
> you're running in a threaded MPM, a forked one or one that does both.
> 
>> Or are we required to provide a separate build for each configuration?
> 
> I don't think you should need that.
> 
> S.
> 
> --sctemme@apache.org            http://www.temme.net/sander/
> PGP FP: 51B4 8727 466A 0BC3 69F4  B7B8 B2BE BC40 1529 24AF


Re: How to detect at runtime if this is a prefork or threaded server?

Posted by Sander Temme <sc...@apache.org>.
On Oct 13, 2006, at 11:10 AM, Roland Genske wrote:

> is it possible for a module to detect at runtime whether it runs in
> a "prefork" server or in a "worker" (threaded) server? Our module
> must behave differently depending on this.

Check out ap_mpm_query(), defined in ap_mpm.h. It can tell you  
whether you're running in a threaded MPM, a forked one or one that  
does both.

> Or are we required to provide a separate build for each configuration?

I don't think you should need that.

S.

-- 
sctemme@apache.org            http://www.temme.net/sander/
PGP FP: 51B4 8727 466A 0BC3 69F4  B7B8 B2BE BC40 1529 24AF