httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christophe JAILLET <>
Subject [users@httpd] Re: ap_run_mpm
Date Fri, 19 Jul 2013 04:56:29 GMT
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


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 

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

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

line 137 of ap_hooks.h, we have:
AP_IMPLEMENT_HOOK_RUN_FIRST(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
    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, 
line 3393 of mpm/event.c      ap_hook_mpm(event_run, NULL, NULL, 

I hope this is clear enough and helps you.
You can also get some information about hooks in


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message