You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Stefan Fritsch <sf...@sfritsch.de> on 2010/11/03 00:41:57 UTC

Hook sorting wrong during startup

Hi,

while working on ap_expr, I stumbled on the hook sorting being wrong 
while the config is processed. There is an entry in STATUS about it 
and I think I have found the reason. In main.c, there is the following 
calling order:

	ap_read_config(): loads the modules (through EXEC_ON_READ) and
	calls the modules' register_hooks functions. Also explicitly
	registers a hook through init_config_globals/ap_init_vhost_config.

	ap_run_pre_config(): Uses wrong hook order.

	ap_process_config_tree()
	ap_fixup_virtual_hosts()
	ap_fini_vhost_config()

	apr_hook_sort_all(): This is too late.


I think apr_hook_sort_all() should be called right after 
ap_read_config() before ap_run_pre_config(). Is it really that simple 
or am I missing something?

Cheers,
Stefan

PS: It seems this is a known issue since 2001:
http://svn.apache.org/viewvc?view=revision&revision=88887

Re: Hook sorting wrong during startup

Posted by Stefan Fritsch <sf...@sfritsch.de>.
On Wednesday 03 November 2010, Ruediger Pluem wrote:
> > I think apr_hook_sort_all() should be called right after 
> > ap_read_config() before ap_run_pre_config(). Is it really that
> > simple  or am I missing something?
> 
> I guess the question is if we clean up the hook list after
> ap_run_pre_config() and call the modules register_hooks function
> again somewhere in
> 
>         ap_process_config_tree()
>         ap_fixup_virtual_hosts()
>         ap_fini_vhost_config()
> 
> If yes I guess we need to copy the sort call up otherwise a move
> seems to be ok.

AFAICS, there is no way to clean the hook list except by clearing the 
pconf pool, and this is not done in those functions. Therefore it 
should be safe to move the call.

Re: Hook sorting wrong during startup

Posted by Ruediger Pluem <rp...@apache.org>.

On 11/03/2010 12:41 AM, Stefan Fritsch wrote:
> Hi,
> 
> while working on ap_expr, I stumbled on the hook sorting being wrong 
> while the config is processed. There is an entry in STATUS about it 
> and I think I have found the reason. In main.c, there is the following 
> calling order:
> 
> 	ap_read_config(): loads the modules (through EXEC_ON_READ) and
> 	calls the modules' register_hooks functions. Also explicitly
> 	registers a hook through init_config_globals/ap_init_vhost_config.
> 
> 	ap_run_pre_config(): Uses wrong hook order.
> 
> 	ap_process_config_tree()
> 	ap_fixup_virtual_hosts()
> 	ap_fini_vhost_config()
> 
> 	apr_hook_sort_all(): This is too late.
> 
> 
> I think apr_hook_sort_all() should be called right after 
> ap_read_config() before ap_run_pre_config(). Is it really that simple 
> or am I missing something?

I guess the question is if we clean up the hook list after ap_run_pre_config()
and call the modules register_hooks function again somewhere in

 	ap_process_config_tree()
 	ap_fixup_virtual_hosts()
 	ap_fini_vhost_config()

If yes I guess we need to copy the sort call up otherwise a move seems to be ok.


Regards

RĂ¼diger