]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
core: Set ap_server_conf ASAP.
authorYann Ylavic <ylavic@apache.org>
Tue, 14 Mar 2023 15:48:41 +0000 (15:48 +0000)
committerYann Ylavic <ylavic@apache.org>
Tue, 14 Mar 2023 15:48:41 +0000 (15:48 +0000)
* server/config.c(ap_read_config):
  Set ap_server_conf as soon as it exists (with defaults).

* server/main.c(main):
  Now that ap_server_conf is set by ap_read_config(), just make
  sure it's not NULL afterward with an ap_assert()ion.

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

server/config.c
server/main.c

index 5f88ea5718e09642e5ebb1498f7de0d1cd194199..b59fea1d4fddd2b875bbf1391a94fc3ab1d27083 100644 (file)
@@ -2308,6 +2308,9 @@ AP_DECLARE(server_rec*) ap_read_config(process_rec *process, apr_pool_t *ptemp,
     if (s == NULL) {
         return s;
     }
+    if (ap_server_conf == NULL) {
+        ap_server_conf = s;
+    }
 
     init_config_globals(p);
 
index 9512ea141ad15d7b8ecd5ffbdfa7ef24e799f139..5bc3b659e9d575ee4aace53882774ed995aed56d 100644 (file)
@@ -717,8 +717,7 @@ static void usage(process_rec *process)
     if (temp_error_log) {
         ap_replace_stderr_log(process->pool, temp_error_log);
     }
-    ap_server_conf = ap_read_config(process, ptemp, confname, &ap_conftree);
-    if (!ap_server_conf) {
+    if (!ap_read_config(process, ptemp, confname, &ap_conftree)) {
         if (showcompile) {
             /* Well, we tried. Show as much as we can, but exit nonzero to
              * indicate that something's not right. The cause should have
@@ -727,6 +726,7 @@ static void usage(process_rec *process)
         }
         destroy_and_exit_process(process, 1);
     }
+    ap_assert(ap_server_conf != NULL);
     apr_pool_cleanup_register(pconf, &ap_server_conf, ap_pool_cleanup_set_null,
                               apr_pool_cleanup_null);
 
@@ -824,10 +824,10 @@ static void usage(process_rec *process)
         apr_pool_create(&ptemp, pconf);
         apr_pool_tag(ptemp, "ptemp");
         ap_server_root = def_server_root;
-        ap_server_conf = ap_read_config(process, ptemp, confname, &ap_conftree);
-        if (!ap_server_conf) {
+        if (!ap_read_config(process, ptemp, confname, &ap_conftree)) {
             destroy_and_exit_process(process, 1);
         }
+        ap_assert(ap_server_conf != NULL);
         apr_pool_cleanup_register(pconf, &ap_server_conf,
                                   ap_pool_cleanup_set_null, apr_pool_cleanup_null);
         /* sort hooks here to make sure pre_config hooks are sorted properly */