You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Valter Nogueira <va...@fastway.com.br> on 2013/07/19 02:38:55 UTC

[users@httpd] ap_run_mpm

I don't know if this question belongs here.

While reading over internet how apache works I learned that different
threading/multi-process models are called thru

ap_run_mpm

inded, main.c calls ap_run_mpm, but I don't figure out where it is defined
nor how it is linked with the correct mpm model.

Thanks

Re: [users@httpd] Re: ap_run_mpm

Posted by Valter Nogueira <va...@fastway.com.br>.
It takes a while to figure out your explanation.

And I not sure a get it.

When ap_run_mpm is called, what is called is a "hook function" for that is
like a dynamic loaded function from a shared library. Is that correct?

So, where is configured the function that will actually be called on each
platform?

Thanks

Valter



*
*


2013/7/19 Christophe JAILLET <ch...@wanadoo.fr>

> Le 19/07/2013 02:38, Valter Nogueira a écrit :
>
>  I don't know if this question belongs here.
>>
>> While reading over internet how apache works I learned that different
>> threading/multi-process models are called thru
>>
>> ap_run_mpm
>>
>> inded, main.c calls ap_run_mpm, but I don't figure out where it is
>> defined nor how it is linked with the correct mpm model.
>>
>> Thanks
>>
>
> Hi,
>
> this is defined at line 92 of include/mpm.h
> this is implemented at line 100 of server/mpm_common.c
>
> All this is done via macro that is why you didn't find it easily.
> After expansion, these macros ends up to a call to 'ap_hook_mpm' which
> must be implemented in the mpm module to register the right function to
> call.
>
>
>
> Here is how it is expanded (using trunk version of both apr and httpd for
> line numbers):
>
> line 100 of server/mpm_common.c
> AP_IMPLEMENT_HOOK_RUN_FIRST(**int, mpm,
>                                (apr_pool_t *pconf, apr_pool_t *plog,
> server_rec *s),
>                                (pconf, plog, s), DECLINED)
>
> line 137 of ap_hooks.h, we have:
>    #define AP_IMPLEMENT_HOOK_RUN_FIRST(**ret,name,args_decl,args_use,**decline)
> \
> APR_IMPLEMENT_EXTERNAL_HOOK_**RUN_FIRST(ap,AP,ret,name,args_**decl, \
>                                                  args_use,decline)
>
> ==> APR_IMPLEMENT_EXTERNAL_HOOK_**RUN_FIRST(ap, AP, int, mpm, (apr_pool_t
> *pconf, apr_pool_t *plog, server_rec *s), (pconf, plog, s), DECLINED)
>
> line 237 of apr/include/apr_hooks.h
>    #define APR_IMPLEMENT_EXTERNAL_HOOK_**RUN_FIRST(ns,link,ret,name,**args_decl,args_use,decline)
> \
>    APR_IMPLEMENT_EXTERNAL_HOOK_**BASE(ns,link,name) \
>    link##_DECLARE(ret) ns##_run_##name args_decl \
>        { \
>    ...
>
> line 143 of apr/include/apr_hooks.h
>    #define APR_IMPLEMENT_EXTERNAL_HOOK_**BASE(ns,link,name) \
>    link##_DECLARE(void) ns##_hook_##name(ns##_HOOK_##**name##_t *pf,const
> char * const *aszPre, \
>                                          const char * const *aszSucc,int
> nOrder) \
>        { \
>    ...
>
>
> ==> AP_DECLARE(void) ap_hook_mpm(...
>
>
> Then, in each mpm module, you have a call to the ap_hook_mpm to register
> the function to get called via the hook.
> line 2292 of mpm/worker.c     ap_hook_mpm(worker_run, NULL, NULL,
> APR_HOOK_MIDDLE);
> line 3393 of mpm/event.c      ap_hook_mpm(event_run, NULL, NULL,
> APR_HOOK_MIDDLE);
> ...
>
>
> I hope this is clear enough and helps you.
> You can also get some information about hooks in
> https://httpd.apache.org/docs/**2.4/developer/hooks.html<https://httpd.apache.org/docs/2.4/developer/hooks.html>
>
> CJ
>
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: users-unsubscribe@httpd.**apache.org<us...@httpd.apache.org>
> For additional commands, e-mail: users-help@httpd.apache.org
>
>

[users@httpd] Re: ap_run_mpm

Posted by Christophe JAILLET <ch...@wanadoo.fr>.
Le 19/07/2013 02:38, Valter Nogueira a écrit :
> I don't know if this question belongs here.
>
> While reading over internet how apache works I learned that different 
> threading/multi-process models are called thru
>
> ap_run_mpm
>
> inded, main.c calls ap_run_mpm, but I don't figure out where it is 
> defined nor how it is linked with the correct mpm model.
>
> Thanks

Hi,

this is defined at line 92 of include/mpm.h
this is implemented at line 100 of server/mpm_common.c

All this is done via macro that is why you didn't find it easily.
After expansion, these macros ends up to a call to 'ap_hook_mpm' which 
must be implemented in the mpm module to register the right function to 
call.



Here is how it is expanded (using trunk version of both apr and httpd 
for line numbers):

line 100 of server/mpm_common.c
AP_IMPLEMENT_HOOK_RUN_FIRST(int, mpm,
                                (apr_pool_t *pconf, apr_pool_t *plog, 
server_rec *s),
                                (pconf, plog, s), DECLINED)

line 137 of ap_hooks.h, we have:
    #define 
AP_IMPLEMENT_HOOK_RUN_FIRST(ret,name,args_decl,args_use,decline) \
APR_IMPLEMENT_EXTERNAL_HOOK_RUN_FIRST(ap,AP,ret,name,args_decl, \
                                                  args_use,decline)

==> APR_IMPLEMENT_EXTERNAL_HOOK_RUN_FIRST(ap, AP, int, mpm, (apr_pool_t 
*pconf, apr_pool_t *plog, server_rec *s), (pconf, plog, s), DECLINED)

line 237 of apr/include/apr_hooks.h
    #define 
APR_IMPLEMENT_EXTERNAL_HOOK_RUN_FIRST(ns,link,ret,name,args_decl,args_use,decline) 
\
    APR_IMPLEMENT_EXTERNAL_HOOK_BASE(ns,link,name) \
    link##_DECLARE(ret) ns##_run_##name args_decl \
        { \
    ...

line 143 of apr/include/apr_hooks.h
    #define APR_IMPLEMENT_EXTERNAL_HOOK_BASE(ns,link,name) \
    link##_DECLARE(void) ns##_hook_##name(ns##_HOOK_##name##_t *pf,const 
char * const *aszPre, \
                                          const char * const 
*aszSucc,int nOrder) \
        { \
    ...


==> AP_DECLARE(void) ap_hook_mpm(...


Then, in each mpm module, you have a call to the ap_hook_mpm to register 
the function to get called via the hook.
line 2292 of mpm/worker.c     ap_hook_mpm(worker_run, NULL, NULL, 
APR_HOOK_MIDDLE);
line 3393 of mpm/event.c      ap_hook_mpm(event_run, NULL, NULL, 
APR_HOOK_MIDDLE);
...


I hope this is clear enough and helps you.
You can also get some information about hooks in 
https://httpd.apache.org/docs/2.4/developer/hooks.html

CJ


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org