From: Joe Orton Date: Tue, 17 Aug 2004 13:47:10 +0000 (+0000) Subject: Implement -t -DDUMP_MODULES using generic test_config hook rather than X-Git-Tag: STRIKER_2_1_0_RC1~106 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=28a2fdc5950ab59394b62900c22f57bcb4608479;p=thirdparty%2Fapache%2Fhttpd.git Implement -t -DDUMP_MODULES using generic test_config hook rather than hooking into mod_so from main.c: * include/http_config.h, server/config.c: Declare test_config hook. * server/main.c: Drop hooks into mod_so; run test_config hooks. * modules/mappers/mod_so.h: Drop ap_dump_loaded_modules optional function. * modules/mappers/mod_so.c (dump_loaded_modules): Renamed from ap_dump_loaded_modules; only run if -DDUMP_MODULES is defined. (register_hooks): Register test_config hook instead of optional function. Reviewed by: Justin Erenkrantz, Paul Querna git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@104685 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index bf404e234ca..72bc653a097 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,9 @@ Changes with Apache 2.1.0-dev [Remove entries to the current 2.0 section below, when backported] + *) Add test_config hook, run only if httpd is invoked using -t. + [Joe Orton] + *) WinNT MPM: Fix a broken log message at termination. PR 28063. [Eider Oliveira ] diff --git a/include/http_config.h b/include/http_config.h index 41287de99ab..25aa4461ce6 100644 --- a/include/http_config.h +++ b/include/http_config.h @@ -967,6 +967,13 @@ AP_DECLARE_HOOK(int,header_parser,(request_rec *r)) AP_DECLARE_HOOK(int,pre_config,(apr_pool_t *pconf,apr_pool_t *plog, apr_pool_t *ptemp)) +/** + * Run the test_config function for each module; this hook is run + * only if the server was invoked to test the configuration syntax. + * @param pconf The config pool + * @param s The list of server_recs + */ +AP_DECLARE_HOOK(void,test_config,(apr_pool_t *pconf, server_rec *s)) /** * Run the post_config function for each module diff --git a/modules/mappers/mod_so.c b/modules/mappers/mod_so.c index 2f16beb18e7..079296b8e49 100644 --- a/modules/mappers/mod_so.c +++ b/modules/mappers/mod_so.c @@ -92,7 +92,7 @@ #include "httpd.h" #include "http_config.h" #include "http_log.h" -#include "ap_config.h" +#include "http_core.h" #include "mod_so.h" @@ -347,13 +347,18 @@ static module *ap_find_loaded_module_symbol(server_rec *s, const char *modname) return NULL; } -static void ap_dump_loaded_modules(apr_pool_t* p, server_rec* s) +static void dump_loaded_modules(apr_pool_t *p, server_rec *s) { ap_module_symbol_t *modie; ap_module_symbol_t *modi; so_server_conf *sconf; int i; apr_file_t *out = NULL; + + if (!ap_exists_config_define("DUMP_MODULES")) { + return; + } + apr_file_open_stderr(&out, p); apr_file_printf(out, "Loaded Modules:\n"); @@ -402,7 +407,7 @@ static void register_hooks(apr_pool_t *p) { #ifndef NO_DLOPEN APR_REGISTER_OPTIONAL_FN(ap_find_loaded_module_symbol); - APR_REGISTER_OPTIONAL_FN(ap_dump_loaded_modules); + ap_hook_test_config(dump_loaded_modules, NULL, NULL, APR_HOOK_MIDDLE); #endif } diff --git a/modules/mappers/mod_so.h b/modules/mappers/mod_so.h index 8c32c820b23..514ba6c932c 100644 --- a/modules/mappers/mod_so.h +++ b/modules/mappers/mod_so.h @@ -22,8 +22,6 @@ /* optional function declaration */ APR_DECLARE_OPTIONAL_FN(module *, ap_find_loaded_module_symbol, (server_rec *s, const char *modname)); -APR_DECLARE_OPTIONAL_FN(void, ap_dump_loaded_modules, - (apr_pool_t* p, server_rec *s)); #endif /* MOD_SO_H */ diff --git a/server/config.c b/server/config.c index 5b484926442..24841a61ca8 100644 --- a/server/config.c +++ b/server/config.c @@ -72,6 +72,7 @@ APR_HOOK_STRUCT( APR_HOOK_LINK(handler) APR_HOOK_LINK(quick_handler) APR_HOOK_LINK(optional_fn_retrieve) + APR_HOOK_LINK(test_config) ) AP_IMPLEMENT_HOOK_RUN_ALL(int, header_parser, @@ -82,6 +83,10 @@ AP_IMPLEMENT_HOOK_RUN_ALL(int, pre_config, apr_pool_t *ptemp), (pconf, plog, ptemp), OK, DECLINED) +AP_IMPLEMENT_HOOK_VOID(test_config, + (apr_pool_t *pconf, server_rec *s), + (pconf, s)) + AP_IMPLEMENT_HOOK_RUN_ALL(int, post_config, (apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s), diff --git a/server/main.c b/server/main.c index 500009550f4..fd828fbdc75 100644 --- a/server/main.c +++ b/server/main.c @@ -37,8 +37,6 @@ #include "ap_mpm.h" #include "mpm_common.h" -#include "mod_so.h" /* for dumping loaded modules */ - /* WARNING: Win32 binds http_main.c dynamically to the server. Please place * extern functions and global data in another appropriate module. * @@ -609,18 +607,12 @@ int main(int argc, const char * const argv[]) rv = ap_process_config_tree(server_conf, ap_conftree, process->pconf, ptemp); if (rv == OK) { - APR_OPTIONAL_FN_TYPE(ap_dump_loaded_modules) *dump_modules = - APR_RETRIEVE_OPTIONAL_FN(ap_dump_loaded_modules); - ap_fixup_virtual_hosts(pconf, server_conf); ap_fini_vhost_config(pconf, server_conf); apr_hook_sort_all(); - if (dump_modules && ap_exists_config_define("DUMP_MODULES")) { - dump_modules(pconf, server_conf); - } - if (configtestonly) { + ap_run_test_config(pconf, server_conf); ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, "Syntax OK"); destroy_and_exit_process(process, 0); }