]> granicus.if.org Git - apache/commitdiff
Allow restart of httpd to occur even with syntax errors in the config
authorJustin Erenkrantz <jerenkrantz@apache.org>
Mon, 17 Feb 2003 07:04:50 +0000 (07:04 +0000)
committerJustin Erenkrantz <jerenkrantz@apache.org>
Mon, 17 Feb 2003 07:04:50 +0000 (07:04 +0000)
file.  (Out-of-date DSOs with bad MMNs will still be fatal unfortunately.)

Add return parameter to ap_process_config_tree - OK on success, !OK on
syntax error.  We will no longer call exit() from ap_process_config_tree.
The caller must exit if there is an error (makes sense anyway).  This allows
the initial start-up code to delay the exit until trying to let the
signal_server optional function execute first.

(The chances are that the syntax error isn't in the PidFile directive.  If
that happens, we'll try the default one.  Oh, well.)

PR: 16813

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@98693 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
include/http_config.h
server/config.c
server/main.c

diff --git a/CHANGES b/CHANGES
index 6847faa17629772243c125b9c99539a04bcb27ca..99ea482296114f34f7d036af21d8c3dbd1f5ded3 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]
 
+  *) Allow restart of httpd to occur even with syntax errors in the config
+     file.  PR 16813.  [Justin Erenkrantz]
+
   *) Rewrite ap_xml_parse_input to use bucket brigades.  PR 16134.
      [Justin Erenkrantz]
 
index b7522078415ab2ac381768c9c3d6fc7ec2a380f4..3c85429e4a6df5fd2c4e5ea83fd38cffbabb2bdd 100644 (file)
@@ -927,9 +927,12 @@ AP_DECLARE(void) ap_process_resource_config(server_rec *s, const char *fname,
  * @param conftree The config tree to process
  * @param p The pool for general allocation
  * @param ptemp The pool for temporary allocations
+ * @return OK if no problems
  */
-AP_DECLARE(void) ap_process_config_tree(server_rec *s, ap_directive_t *conftree,
-                                        apr_pool_t *p, apr_pool_t *ptemp);
+AP_DECLARE(int) ap_process_config_tree(server_rec *s,
+                                       ap_directive_t *conftree,
+                                       apr_pool_t *p,
+                                       apr_pool_t *ptemp);
 
 /* Module-method dispatchers, also for http_request.c */
 /**
index 2e2b06b38749803fdcbecad9766305a28f2b0e44..3be4368841f1f7ba717a0183d518d8779bfb173c 100644 (file)
@@ -1577,9 +1577,10 @@ AP_DECLARE(void) ap_process_resource_config(server_rec *s, const char *fname,
     ap_cfg_closefile(cfp);
 }
 
-AP_DECLARE(void) ap_process_config_tree(server_rec *s,
-                                        ap_directive_t *conftree,
-                                        apr_pool_t *p, apr_pool_t *ptemp)
+AP_DECLARE(int) ap_process_config_tree(server_rec *s,
+                                       ap_directive_t *conftree,
+                                       apr_pool_t *p,
+                                       apr_pool_t *ptemp)
 {
     const char *errmsg;
     cmd_parms parms;
@@ -1599,8 +1600,10 @@ AP_DECLARE(void) ap_process_config_tree(server_rec *s,
                      parms.err_directive->filename);
         ap_log_perror(APLOG_MARK, APLOG_STARTUP, 0, p,
                      "%s", errmsg);
-        exit(1);
+        return HTTP_INTERNAL_SERVER_ERROR;
     }
+
+    return OK;
 }
 
 AP_CORE_DECLARE(int) ap_parse_htaccess(ap_conf_vector_t **result,
index a2cbcc37174d9f7ba013a435524f8a8367db6692..5472160b63fc40b93158bdd78d293e37f62b7ab8 100644 (file)
@@ -573,13 +573,16 @@ int main(int argc, const char * const argv[])
         destroy_and_exit_process(process, 1);
     }
 
-    ap_process_config_tree(server_conf, ap_conftree, process->pconf, ptemp);
-    ap_fixup_virtual_hosts(pconf, server_conf);
-    ap_fini_vhost_config(pconf, server_conf);
-    apr_hook_sort_all();
-    if (configtestonly) {
-        ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, "Syntax OK");
-        destroy_and_exit_process(process, 0);
+    rv = ap_process_config_tree(server_conf, ap_conftree,
+                                process->pconf, ptemp);
+    if (rv == OK) {
+        ap_fixup_virtual_hosts(pconf, server_conf);
+        ap_fini_vhost_config(pconf, server_conf);
+        apr_hook_sort_all();
+        if (configtestonly) {
+            ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, "Syntax OK");
+            destroy_and_exit_process(process, 0);
+        }
     }
 
     signal_server = APR_RETRIEVE_OPTIONAL_FN(ap_signal_server);
@@ -591,6 +594,11 @@ int main(int argc, const char * const argv[])
         }
     }
 
+    /* If our config failed, deal with that here. */
+    if (rv != OK) {
+        destroy_and_exit_process(process, 1);
+    }
+
     apr_pool_clear(plog);
 
     if ( ap_run_open_logs(pconf, plog, ptemp, server_conf) != OK) {
@@ -630,7 +638,10 @@ int main(int argc, const char * const argv[])
             destroy_and_exit_process(process, 1);
         }
 
-        ap_process_config_tree(server_conf, ap_conftree, process->pconf, ptemp);
+        if (ap_process_config_tree(server_conf, ap_conftree, process->pconf,
+                                   ptemp) != OK) {
+            destroy_and_exit_process(process, 1);
+        }
         ap_fixup_virtual_hosts(pconf, server_conf);
         ap_fini_vhost_config(pconf, server_conf);
         apr_hook_sort_all();