httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Valter Nogueira <val...@fastway.com.br>
Subject Re: [users@httpd] Re: ap_run_mpm
Date Mon, 22 Jul 2013 18:06:22 GMT
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 <christophe.jaillet@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<users-unsubscribe@httpd.apache.org>
> For additional commands, e-mail: users-help@httpd.apache.org
>
>

Mime
View raw message