]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Implement -t -DDUMP_MODULES using generic test_config hook rather than
authorJoe Orton <jorton@apache.org>
Tue, 17 Aug 2004 13:47:10 +0000 (13:47 +0000)
committerJoe Orton <jorton@apache.org>
Tue, 17 Aug 2004 13:47:10 +0000 (13:47 +0000)
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

CHANGES
include/http_config.h
modules/mappers/mod_so.c
modules/mappers/mod_so.h
server/config.c
server/main.c

diff --git a/CHANGES b/CHANGES
index bf404e234ca9207a79ba00148ac446b464ccea87..72bc653a097944ef8bedb01c895e1a5df51afbf5 100644 (file)
--- 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 <eider bol.com.br>]
 
index 41287de99ab80e5432cc01a121c5d693f1e86470..25aa4461ce6fe53cc95d9ba39a68df8dac7deb02 100644 (file)
@@ -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
index 2f16beb18e76bedb25c25978361adf32bac3476e..079296b8e495e20b0c66a5145ed85bb6350d8e15 100644 (file)
@@ -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
 }
 
index 8c32c820b23900b095ba4b0ac7b1749e9b517f24..514ba6c932cd702a8595f138759cc067e4a96197 100644 (file)
@@ -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 */
 
index 5b484926442801d3ba2d3fbb5a10fad0fe16d14d..24841a61ca80343624c51bd66d4f5952b2705189 100644 (file)
@@ -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),
index 500009550f4fa09ec2d0dc9a0044cf8760f293b5..fd828fbdc75eed029d481e9266e297072fd85ee8 100644 (file)
@@ -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);
         }