Created attachment 22000 [details] pre_config hooks patch for trunk Apparently pre_config hooks are not ordered when ap_run_pre_config is called. I noticed and verified one issue and I noticed another one (syntactically only) while reading through the code. First issue (verified): While during the first configuration pass pre_config hooks seem to be ordered for prelinked modules during the second one hooks are not ordered (i.e. not in the order specified by APR_HOOK_FIRST...defines). Fix: apr_hook_sort_all is called too late during second and further configuration passes. It needs to be called before ap_run_pre_config (l.734 of server/main.c). Second issue (only noticed while reading the code): pre_config hooks might not be ordered for dynamically loaded modules even during first configuration pass. Fix: apr_hook_sort_all needs to be called before ap_run_pre_config (l.656 of server/main.c) I was working on 2.2.3 which suffer from these issues. I checked 2.2.8 and trunk which still suffer these issues. Please see attached a patch for trunk to fix these issues. I compiled the server and checked that my patch correct the first issue (I don't use dynamically loaded modules). My patch shouldn't provoke any regression however I don't know why apr_hook_sort_all was called so late. Was there any reason for that? The only assumption I make is that hooks have to be hooked during register hooks during module initialization or otherwise apr_hook_sort_all should be manually called after registering a hook (as mod_cgid does).
Created attachment 22001 [details] pre_config hooks patch for 2.2.8 Patch for the 2.2.8 version (just in case)
Created attachment 22844 [details] pre_config hooks patch for 2.2.10 Adding patch for 2.2.10 as requested by Bruce Mills (Apache dev mailing list, thread: ap_run_pre_config issue). Note: I didn't test it but it should work as well as older patches.
This is already fixed in trunk and has been proposed for 2.2.20
I checked trunk revision 1032002; the patch to server/main.c is the same as mine so it should effectively be fixed in trunk. Thanks.
Reopen the bug because the fix introduces a very similar bug. Modperl allows to write modules in Perl. Those modules can also register hooks. The earliest point in time when that may happen is in ap_process_config_tree() because there are config statements that influence certain parameters of the perl interpreter. So, we have to process those statements prior to starting the interpreter. But only the perl interpreter knows which modules to load. Those modules then can install hooks. But with revision 1162854 these hooks are called out of order.
Created attachment 27730 [details] fix order for pre_config hooks as well as hooks that are registered later The patch is to be applied on top of revision 1162854 which has MENEAULT's patch applied. In addition to calling apr_hook_sort_all() at the new location it calls it again when ap_process_config_tree() is done.
committed in trunk as r1180325
fixed in 2.2.22