From: Yann Ylavic Date: Tue, 14 Mar 2023 15:48:41 +0000 (+0000) Subject: core: Set ap_server_conf ASAP. X-Git-Tag: 2.5.0-alpha2-ci-test-only~43 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=feb15a2eb57e28d896b27a83c0e80f079a8ea509;p=thirdparty%2Fapache%2Fhttpd.git core: Set ap_server_conf ASAP. * 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 --- diff --git a/server/config.c b/server/config.c index 5f88ea5718e..b59fea1d4fd 100644 --- a/server/config.c +++ b/server/config.c @@ -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); diff --git a/server/main.c b/server/main.c index 9512ea141ad..5bc3b659e9d 100644 --- a/server/main.c +++ b/server/main.c @@ -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 */