#include <unistd.h>
#endif
-#if HAVE_NETINET_IN_H
-#include <netinet/in.h>
-#endif
-#if HAVE_ARPA_NAMESER_H
-#include <arpa/nameser.h>
-#endif
-#if HAVE_RESOLV_H
-#include <resolv.h>
-#endif
-
/* WARNING: Win32 binds http_main.c dynamically to the server. Please place
* extern functions and global data in another appropriate module.
*
* might get lost.
*/
apr_sleep(TASK_SWITCH_SLEEP);
+ ap_main_state = AP_SQ_MS_EXITING;
apr_pool_destroy(process->pool); /* and destroy all descendent pools */
apr_terminate();
exit(process_exit_value);
int main(int argc, const char * const argv[])
{
char c;
- int configtestonly = 0, showcompile = 0;
+ int showcompile = 0;
const char *confname = SERVER_CONFIG_FILE;
const char *def_server_root = HTTPD_ROOT;
const char *temp_error_log = NULL;
*new = apr_pstrdup(pcommands, opt_arg);
/* Setting -D DUMP_VHOSTS is equivalent to setting -S */
if (strcmp(opt_arg, "DUMP_VHOSTS") == 0)
- configtestonly = 1;
+ ap_run_mode = AP_SQ_RM_CONFIG_DUMP;
/* Setting -D DUMP_MODULES is equivalent to setting -M */
if (strcmp(opt_arg, "DUMP_MODULES") == 0)
- configtestonly = 1;
+ ap_run_mode = AP_SQ_RM_CONFIG_DUMP;
break;
case 'e':
printf("Server built: %s\n", ap_get_server_built());
destroy_and_exit_process(process, 0);
- case 'V':
- if (strcmp(ap_show_mpm(), "")) { /* MPM built-in? */
- show_compile_settings();
- destroy_and_exit_process(process, 0);
- }
- else {
- showcompile = 1;
- }
- break;
-
case 'l':
ap_show_modules();
destroy_and_exit_process(process, 0);
destroy_and_exit_process(process, 0);
case 't':
- configtestonly = 1;
+ if (ap_run_mode == AP_SQ_RM_UNKNOWN)
+ ap_run_mode = AP_SQ_RM_CONFIG_TEST;
break;
case 'T':
break;
case 'S':
- configtestonly = 1;
+ ap_run_mode = AP_SQ_RM_CONFIG_DUMP;
new = (char **)apr_array_push(ap_server_config_defines);
*new = "DUMP_VHOSTS";
break;
case 'M':
- configtestonly = 1;
+ ap_run_mode = AP_SQ_RM_CONFIG_DUMP;
new = (char **)apr_array_push(ap_server_config_defines);
*new = "DUMP_MODULES";
break;
+ case 'V':
+ if (strcmp(ap_show_mpm(), "")) { /* MPM built-in? */
+ show_compile_settings();
+ destroy_and_exit_process(process, 0);
+ }
+ else {
+ showcompile = 1;
+ ap_run_mode = AP_SQ_RM_CONFIG_DUMP;
+ }
+ break;
+
case 'h':
case '?':
usage(process);
}
}
+ if (ap_run_mode == AP_SQ_RM_UNKNOWN)
+ ap_run_mode = AP_SQ_RM_NORMAL;
+
/* bad cmdline option? then we die */
if (rv != APR_EOF || opt->ind < opt->argc) {
usage(process);
}
+ ap_main_state = AP_SQ_MS_CREATE_PRE_CONFIG;
apr_pool_create(&plog, ap_pglobal);
apr_pool_tag(plog, "plog");
apr_pool_create(&ptemp, pconf);
if (!ap_server_conf) {
destroy_and_exit_process(process, 1);
}
+ apr_pool_cleanup_register(pconf, &ap_server_conf, ap_pool_cleanup_set_null,
+ NULL);
apr_hook_sort_all();
if (ap_run_pre_config(pconf, plog, ptemp) != OK) {
destroy_and_exit_process(process, 1);
}
- if (configtestonly) {
- ap_run_test_config(pconf, ap_server_conf);
- ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, "Syntax OK");
- destroy_and_exit_process(process, 0);
- }
- else if (showcompile) { /* deferred due to dynamically loaded MPM */
- show_compile_settings();
+ if (ap_run_mode != AP_SQ_RM_NORMAL) {
+ if (showcompile) { /* deferred due to dynamically loaded MPM */
+ show_compile_settings();
+ }
+ else {
+ ap_run_test_config(pconf, ap_server_conf);
+ if (ap_run_mode == AP_SQ_RM_CONFIG_TEST)
+ ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, "Syntax OK");
+ }
destroy_and_exit_process(process, 0);
}
}
apr_pool_destroy(ptemp);
for (;;) {
+ ap_main_state = AP_SQ_MS_DESTROY_CONFIG;
apr_hook_deregister_all();
apr_pool_clear(pconf);
ap_clear_auth_internal();
-#if 0
-/* glibc has __res_init that is #defined to res_init */
-#if HAVE_RES_INIT || HAVE___RES_INIT
- /*
- * resolv.conf may have changed, so this will read/reread it.
- */
- if (res_init() == -1) {
- ap_log_error(APLOG_MARK, APLOG_WARNING, 0, NULL,
- "Resolver initialization failed.");
- }
-#endif
-#endif
+
+ ap_main_state = AP_SQ_MS_CREATE_CONFIG;
for (mod = ap_prelinked_modules; *mod != NULL; mod++) {
ap_register_hooks(*mod, pconf);
}
if (!ap_server_conf) {
destroy_and_exit_process(process, 1);
}
+ apr_pool_cleanup_register(pconf, &ap_server_conf,
+ ap_pool_cleanup_set_null, NULL);
apr_hook_sort_all();
if (ap_run_pre_config(pconf, plog, ptemp) != OK) {
ap_run_optional_fn_retrieve();
+ ap_main_state = AP_SQ_MS_RUN_MPM;
if (ap_run_mpm(pconf, plog, ap_server_conf) != OK)
break;