1 /* Licensed to the Apache Software Foundation (ASF) under one or more
2 * contributor license agreements. See the NOTICE file distributed with
3 * this work for additional information regarding copyright ownership.
4 * The ASF licenses this file to You under the Apache License, Version 2.0
5 * (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #include "apr_strings.h"
19 #include "apr_getopt.h"
20 #include "apr_general.h"
24 #include "apr_version.h"
25 #include "apu_version.h"
27 #define APR_WANT_STDIO
28 #define APR_WANT_STRFUNC
31 #include "ap_config.h"
33 #include "http_main.h"
35 #include "http_config.h"
36 #include "http_core.h"
38 #include "http_request.h"
39 #include "http_vhost.h"
41 #include "util_ebcdic.h"
47 /* Not sure what absence of unistd would signify for tty. Treating it as a
48 * big NO is safe, as we then won't try to write to stderr that's not a tty.
53 /* we know core's module_index is 0 */
54 #undef APLOG_MODULE_INDEX
55 #define APLOG_MODULE_INDEX AP_CORE_MODULE_INDEX
57 /* WARNING: Win32 binds http_main.c dynamically to the server. Please place
58 * extern functions and global data in another appropriate module.
60 * Most significant main() global data can be found in http_config.c
63 static void show_mpm_settings(void)
68 printf("Server MPM: %s\n", ap_show_mpm());
70 retval = ap_mpm_query(AP_MPMQ_IS_THREADED, &mpm_query_info);
72 if (retval == APR_SUCCESS) {
73 printf(" threaded: ");
75 if (mpm_query_info == AP_MPMQ_DYNAMIC) {
76 printf("yes (variable thread count)\n");
78 else if (mpm_query_info == AP_MPMQ_STATIC) {
79 printf("yes (fixed thread count)\n");
86 retval = ap_mpm_query(AP_MPMQ_IS_FORKED, &mpm_query_info);
88 if (retval == APR_SUCCESS) {
91 if (mpm_query_info == AP_MPMQ_DYNAMIC) {
92 printf("yes (variable process count)\n");
94 else if (mpm_query_info == AP_MPMQ_STATIC) {
95 printf("yes (fixed process count)\n");
103 static void show_compile_settings(void)
105 printf("Server version: %s\n", ap_get_server_description());
106 printf("Server built: %s\n", ap_get_server_built());
107 printf("Server's Module Magic Number: %u:%u\n",
108 MODULE_MAGIC_NUMBER_MAJOR, MODULE_MAGIC_NUMBER_MINOR);
109 #if APR_MAJOR_VERSION >= 2
110 printf("Server loaded: APR %s\n", apr_version_string());
111 printf("Compiled using: APR %s\n", APR_VERSION_STRING);
113 printf("Server loaded: APR %s, APR-UTIL %s\n",
114 apr_version_string(), apu_version_string());
115 printf("Compiled using: APR %s, APR-UTIL %s\n",
116 APR_VERSION_STRING, APU_VERSION_STRING);
118 /* sizeof(foo) is long on some platforms so we might as well
119 * make it long everywhere to keep the printf format
122 printf("Architecture: %ld-bit\n", 8 * (long)sizeof(void *));
126 printf("Server compiled with....\n");
127 #ifdef BIG_SECURITY_HOLE
128 printf(" -D BIG_SECURITY_HOLE\n");
131 #ifdef SECURITY_HOLE_PASS_AUTHORIZATION
132 printf(" -D SECURITY_HOLE_PASS_AUTHORIZATION\n");
136 printf(" -D OS=\"" OS "\"\n");
140 printf(" -D HAVE_SHMGET\n");
143 #if APR_FILE_BASED_SHM
144 printf(" -D APR_FILE_BASED_SHM\n");
148 printf(" -D APR_HAS_SENDFILE\n");
152 printf(" -D APR_HAS_MMAP\n");
156 printf(" -D NO_WRITEV\n");
160 printf(" -D NO_LINGCLOSE\n");
164 printf(" -D APR_HAVE_IPV6 (IPv4-mapped addresses ");
165 #ifdef AP_ENABLE_V4_MAPPED
166 printf("enabled)\n");
168 printf("disabled)\n");
172 #if APR_USE_FLOCK_SERIALIZE
173 printf(" -D APR_USE_FLOCK_SERIALIZE\n");
176 #if APR_USE_SYSVSEM_SERIALIZE
177 printf(" -D APR_USE_SYSVSEM_SERIALIZE\n");
180 #if APR_USE_POSIXSEM_SERIALIZE
181 printf(" -D APR_USE_POSIXSEM_SERIALIZE\n");
184 #if APR_USE_FCNTL_SERIALIZE
185 printf(" -D APR_USE_FCNTL_SERIALIZE\n");
188 #if APR_USE_PROC_PTHREAD_SERIALIZE
189 printf(" -D APR_USE_PROC_PTHREAD_SERIALIZE\n");
192 #if APR_USE_PTHREAD_SERIALIZE
193 printf(" -D APR_USE_PTHREAD_SERIALIZE\n");
196 #if APR_PROCESS_LOCK_IS_GLOBAL
197 printf(" -D APR_PROCESS_LOCK_IS_GLOBAL\n");
200 #ifdef SINGLE_LISTEN_UNSERIALIZED_ACCEPT
201 printf(" -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT\n");
204 #if APR_HAS_OTHER_CHILD
205 printf(" -D APR_HAS_OTHER_CHILD\n");
208 #ifdef AP_HAVE_RELIABLE_PIPED_LOGS
209 printf(" -D AP_HAVE_RELIABLE_PIPED_LOGS\n");
213 printf(" -D BUFFERED_LOGS\n");
215 printf(" -D PIPE_BUF=%ld\n",(long)PIPE_BUF);
219 printf(" -D DYNAMIC_MODULE_LIMIT=%ld\n",(long)DYNAMIC_MODULE_LIMIT);
221 #if APR_CHARSET_EBCDIC
222 printf(" -D APR_CHARSET_EBCDIC\n");
225 #ifdef NEED_HASHBANG_EMUL
226 printf(" -D NEED_HASHBANG_EMUL\n");
229 /* This list displays the compiled in default paths: */
231 printf(" -D HTTPD_ROOT=\"" HTTPD_ROOT "\"\n");
235 printf(" -D SUEXEC_BIN=\"" SUEXEC_BIN "\"\n");
238 #ifdef DEFAULT_PIDLOG
239 printf(" -D DEFAULT_PIDLOG=\"" DEFAULT_PIDLOG "\"\n");
242 #ifdef DEFAULT_SCOREBOARD
243 printf(" -D DEFAULT_SCOREBOARD=\"" DEFAULT_SCOREBOARD "\"\n");
246 #ifdef DEFAULT_ERRORLOG
247 printf(" -D DEFAULT_ERRORLOG=\"" DEFAULT_ERRORLOG "\"\n");
250 #ifdef AP_TYPES_CONFIG_FILE
251 printf(" -D AP_TYPES_CONFIG_FILE=\"" AP_TYPES_CONFIG_FILE "\"\n");
254 #ifdef SERVER_CONFIG_FILE
255 printf(" -D SERVER_CONFIG_FILE=\"" SERVER_CONFIG_FILE "\"\n");
259 #define TASK_SWITCH_SLEEP 10000
261 static void destroy_and_exit_process(process_rec *process,
262 int process_exit_value)
265 * Sleep for TASK_SWITCH_SLEEP micro seconds to cause a task switch on
266 * OS layer and thus give possibly started piped loggers a chance to
267 * process their input. Otherwise it is possible that they get killed
268 * by us before they can do so. In this case maybe valueable log messages
272 /* If we are to print an error, we need the name before we destroy pool.
273 * short_name is a pointer into argv, so remains valid.
275 const char *name = process->short_name ? process->short_name : "httpd";
277 apr_sleep(TASK_SWITCH_SLEEP);
278 ap_main_state = AP_SQ_MS_EXITING;
279 apr_pool_destroy(process->pool); /* and destroy all descendent pools */
281 if ((process_exit_value != 0) && isatty(fileno(stderr))) {
282 fprintf(stderr, "%s: abnormal exit %d\n", name, process_exit_value);
284 exit(process_exit_value);
287 /* APR callback invoked if allocation fails. */
288 static int abort_on_oom(int retcode)
291 return retcode; /* unreachable, hopefully. */
294 static process_rec *init_process(int *argc, const char * const * *argv)
296 process_rec *process;
299 const char *failed = "apr_app_initialize()";
301 stat = apr_app_initialize(argc, argv, NULL);
302 if (stat == APR_SUCCESS) {
303 failed = "apr_pool_create()";
304 stat = apr_pool_create(&cntx, NULL);
307 if (stat != APR_SUCCESS) {
308 /* For all intents and purposes, this is impossibly unlikely,
309 * but APR doesn't exist yet, we can't use it for reporting
310 * these earliest two failures;
312 * XXX: Note the apr_ctime() and apr_time_now() calls. These
313 * work, today, against an uninitialized APR, but in the future
314 * (if they relied on global pools or mutexes, for example) then
315 * the datestamp logic will need to be replaced.
317 char ctimebuff[APR_CTIME_LEN];
318 apr_ctime(ctimebuff, apr_time_now());
319 fprintf(stderr, "[%s] [crit] (%d) %s: %s failed "
320 "to initial context, exiting\n",
321 ctimebuff, stat, (*argv)[0], failed);
326 apr_pool_abort_set(abort_on_oom, cntx);
327 apr_pool_tag(cntx, "process");
328 ap_open_stderr_log(cntx);
330 /* Now we have initialized apr and our logger, no more
331 * exceptional error reporting required for the lifetime
332 * of this server process.
335 process = apr_palloc(cntx, sizeof(process_rec));
336 process->pool = cntx;
338 apr_pool_create(&process->pconf, process->pool);
339 apr_pool_tag(process->pconf, "pconf");
340 process->argc = *argc;
341 process->argv = *argv;
342 process->short_name = apr_filepath_name_get((*argv)[0]);
346 static void usage(process_rec *process)
348 const char *bin = process->argv[0];
349 int pad_len = strlen(bin);
351 ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
352 "Usage: %s [-D name] [-d directory] [-f file]", bin);
354 ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
355 " %*s [-C \"directive\"] [-c \"directive\"]", pad_len, " ");
358 ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
359 " %*s [-w] [-k start|restart|stop|shutdown] [-n service_name]",
361 ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
362 " %*s [-k install|config|uninstall] [-n service_name]",
365 /* XXX not all MPMs support signalling the server in general or graceful-stop
368 ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
369 " %*s [-k start|restart|graceful|graceful-stop|stop]",
372 ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
373 " %*s [-v] [-V] [-h] [-l] [-L] [-t] [-T] [-S] [-X]",
375 ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
378 ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
379 " -D name : define a name for use in "
380 "<IfDefine name> directives");
381 ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
382 " -d directory : specify an alternate initial "
384 ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
385 " -f file : specify an alternate ServerConfigFile");
386 ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
387 " -C \"directive\" : process directive before reading "
389 ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
390 " -c \"directive\" : process directive after reading "
394 ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
395 " -n name : set screen name");
398 ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
399 " -n name : set service name and use its "
400 "ServerConfigFile and ServerRoot");
401 ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
402 " -k start : tell Apache to start");
403 ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
404 " -k restart : tell running Apache to do a graceful "
406 ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
407 " -k stop|shutdown : tell running Apache to shutdown");
408 ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
409 " -k install : install an Apache service");
410 ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
411 " -k config : change startup Options of an Apache "
413 ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
414 " -k uninstall : uninstall an Apache service");
415 ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
416 " -w : hold open the console window on error");
419 ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
420 " -e level : show startup errors of level "
422 ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
423 " -E file : log startup errors to file");
424 ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
425 " -v : show version number");
426 ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
427 " -V : show compile settings");
428 ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
429 " -h : list available command line options "
431 ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
432 " -l : list compiled in modules");
433 ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
434 " -L : list available configuration "
436 ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
437 " -t -D DUMP_VHOSTS : show parsed vhost settings");
438 ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
439 " -t -D DUMP_RUN_CFG : show parsed run settings");
440 ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
441 " -S : a synonym for -t -D DUMP_VHOSTS -D DUMP_RUN_CFG");
442 ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
443 " -t -D DUMP_MODULES : show all loaded modules ");
444 ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
445 " -M : a synonym for -t -D DUMP_MODULES");
446 ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
447 " -t : run syntax check for config files");
448 ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
449 " -T : start without DocumentRoot(s) check");
450 ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
451 " -X : debug mode (only one worker, do not detach)");
453 destroy_and_exit_process(process, 1);
456 int main(int argc, const char * const argv[])
459 int showcompile = 0, showdirectives = 0;
460 const char *confname = SERVER_CONFIG_FILE;
461 const char *def_server_root = HTTPD_ROOT;
462 const char *temp_error_log = NULL;
464 process_rec *process;
466 apr_pool_t *plog; /* Pool of log streams, reset _after_ each read of conf */
467 apr_pool_t *ptemp; /* Pool for temporary config stuff, reset often */
468 apr_pool_t *pcommands; /* Pool for -D, -C and -c switches */
473 APR_OPTIONAL_FN_TYPE(ap_signal_server) *signal_server;
475 AP_MONCONTROL(0); /* turn off profiling of startup */
477 process = init_process(&argc, &argv);
478 ap_pglobal = process->pool;
479 pconf = process->pconf;
480 ap_server_argv0 = process->short_name;
481 ap_init_rng(ap_pglobal);
483 /* Set up the OOM callback in the global pool, so all pools should
484 * by default inherit it. */
485 apr_pool_abort_set(abort_on_oom, apr_pool_parent_get(process->pool));
487 #if APR_CHARSET_EBCDIC
488 if (ap_init_ebcdic(ap_pglobal) != APR_SUCCESS) {
489 destroy_and_exit_process(process, 1);
493 apr_pool_create(&pcommands, ap_pglobal);
494 apr_pool_tag(pcommands, "pcommands");
495 ap_server_pre_read_config = apr_array_make(pcommands, 1, sizeof(char *));
496 ap_server_post_read_config = apr_array_make(pcommands, 1, sizeof(char *));
497 ap_server_config_defines = apr_array_make(pcommands, 1, sizeof(char *));
499 error = ap_setup_prelinked_modules(process);
501 ap_log_error(APLOG_MARK, APLOG_STARTUP|APLOG_EMERG, 0, NULL, APLOGNO(00012)
502 "%s: %s", ap_server_argv0, error);
503 destroy_and_exit_process(process, 1);
506 ap_run_rewrite_args(process);
508 /* Maintain AP_SERVER_BASEARGS list in http_main.h to allow the MPM
509 * to safely pass on our args from its rewrite_args() handler.
511 apr_getopt_init(&opt, pcommands, process->argc, process->argv);
513 while ((rv = apr_getopt(opt, AP_SERVER_BASEARGS, &c, &opt_arg))
519 new = (char **)apr_array_push(ap_server_post_read_config);
520 *new = apr_pstrdup(pcommands, opt_arg);
524 new = (char **)apr_array_push(ap_server_pre_read_config);
525 *new = apr_pstrdup(pcommands, opt_arg);
529 def_server_root = opt_arg;
533 new = (char **)apr_array_push(ap_server_config_defines);
534 *new = apr_pstrdup(pcommands, opt_arg);
535 /* Setting -D DUMP_VHOSTS should work like setting -S */
536 if (strcmp(opt_arg, "DUMP_VHOSTS") == 0)
537 ap_run_mode = AP_SQ_RM_CONFIG_DUMP;
538 /* Setting -D DUMP_RUN_CFG should work like setting -S */
539 else if (strcmp(opt_arg, "DUMP_RUN_CFG") == 0)
540 ap_run_mode = AP_SQ_RM_CONFIG_DUMP;
541 /* Setting -D DUMP_MODULES is equivalent to setting -M */
542 else if (strcmp(opt_arg, "DUMP_MODULES") == 0)
543 ap_run_mode = AP_SQ_RM_CONFIG_DUMP;
547 if (ap_parse_log_level(opt_arg, &ap_default_loglevel) != NULL)
552 temp_error_log = apr_pstrdup(process->pool, opt_arg);
556 new = (char **)apr_array_push(ap_server_config_defines);
565 printf("Server version: %s\n", ap_get_server_description());
566 printf("Server built: %s\n", ap_get_server_built());
567 destroy_and_exit_process(process, 0);
571 destroy_and_exit_process(process, 0);
574 ap_run_mode = AP_SQ_RM_CONFIG_DUMP;
579 if (ap_run_mode == AP_SQ_RM_UNKNOWN)
580 ap_run_mode = AP_SQ_RM_CONFIG_TEST;
584 ap_document_root_check = 0;
588 ap_run_mode = AP_SQ_RM_CONFIG_DUMP;
589 new = (char **)apr_array_push(ap_server_config_defines);
590 *new = "DUMP_VHOSTS";
591 new = (char **)apr_array_push(ap_server_config_defines);
592 *new = "DUMP_RUN_CFG";
596 ap_run_mode = AP_SQ_RM_CONFIG_DUMP;
597 new = (char **)apr_array_push(ap_server_config_defines);
598 *new = "DUMP_MODULES";
602 if (strcmp(ap_show_mpm(), "")) { /* MPM built-in? */
603 show_compile_settings();
604 destroy_and_exit_process(process, 0);
608 ap_run_mode = AP_SQ_RM_CONFIG_DUMP;
618 if (ap_run_mode == AP_SQ_RM_UNKNOWN)
619 ap_run_mode = AP_SQ_RM_NORMAL;
621 /* bad cmdline option? then we die */
622 if (rv != APR_EOF || opt->ind < opt->argc) {
626 ap_main_state = AP_SQ_MS_CREATE_PRE_CONFIG;
627 apr_pool_create(&plog, ap_pglobal);
628 apr_pool_tag(plog, "plog");
629 apr_pool_create(&ptemp, pconf);
630 apr_pool_tag(ptemp, "ptemp");
632 /* Note that we preflight the config file once
633 * before reading it _again_ in the main loop.
634 * This allows things, log files configuration
635 * for example, to settle down.
638 ap_server_root = def_server_root;
639 if (temp_error_log) {
640 ap_replace_stderr_log(process->pool, temp_error_log);
642 ap_server_conf = ap_read_config(process, ptemp, confname, &ap_conftree);
643 if (!ap_server_conf) {
644 destroy_and_exit_process(process, 1);
646 apr_pool_cleanup_register(pconf, &ap_server_conf, ap_pool_cleanup_set_null,
647 apr_pool_cleanup_null);
648 /* sort hooks here to make sure pre_config hooks are sorted properly */
651 if (ap_run_pre_config(pconf, plog, ptemp) != OK) {
652 ap_log_error(APLOG_MARK, APLOG_STARTUP |APLOG_ERR, 0,
653 NULL, APLOGNO(00013) "Pre-configuration failed");
654 destroy_and_exit_process(process, 1);
657 rv = ap_process_config_tree(ap_server_conf, ap_conftree,
658 process->pconf, ptemp);
660 ap_fixup_virtual_hosts(pconf, ap_server_conf);
661 ap_fini_vhost_config(pconf, ap_server_conf);
663 * Sort hooks again because ap_process_config_tree may have add modules
664 * and hence hooks. This happens with mod_perl and modules written in
669 if (ap_run_check_config(pconf, plog, ptemp, ap_server_conf) != OK) {
670 ap_log_error(APLOG_MARK, APLOG_STARTUP |APLOG_ERR, 0,
671 NULL, APLOGNO(00014) "Configuration check failed");
672 destroy_and_exit_process(process, 1);
675 if (ap_run_mode != AP_SQ_RM_NORMAL) {
676 if (showcompile) { /* deferred due to dynamically loaded MPM */
677 show_compile_settings();
679 else if (showdirectives) { /* deferred in case of DSOs */
680 ap_show_directives();
681 destroy_and_exit_process(process, 0);
684 ap_run_test_config(pconf, ap_server_conf);
685 if (ap_run_mode == AP_SQ_RM_CONFIG_TEST)
686 ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, "Syntax OK");
688 destroy_and_exit_process(process, 0);
692 /* If our config failed, deal with that here. */
694 destroy_and_exit_process(process, 1);
697 signal_server = APR_RETRIEVE_OPTIONAL_FN(ap_signal_server);
701 if (signal_server(&exit_status, pconf) != 0) {
702 destroy_and_exit_process(process, exit_status);
706 apr_pool_clear(plog);
708 if ( ap_run_open_logs(pconf, plog, ptemp, ap_server_conf) != OK) {
709 ap_log_error(APLOG_MARK, APLOG_STARTUP |APLOG_ERR,
710 0, NULL, APLOGNO(00015) "Unable to open logs");
711 destroy_and_exit_process(process, 1);
714 if ( ap_run_post_config(pconf, plog, ptemp, ap_server_conf) != OK) {
715 ap_log_error(APLOG_MARK, APLOG_STARTUP |APLOG_ERR, 0,
716 NULL, APLOGNO(00016) "Configuration Failed");
717 destroy_and_exit_process(process, 1);
720 apr_pool_destroy(ptemp);
723 ap_main_state = AP_SQ_MS_DESTROY_CONFIG;
724 apr_hook_deregister_all();
725 apr_pool_clear(pconf);
726 ap_clear_auth_internal();
728 ap_main_state = AP_SQ_MS_CREATE_CONFIG;
729 ap_config_generation++;
730 for (mod = ap_prelinked_modules; *mod != NULL; mod++) {
731 ap_register_hooks(*mod, pconf);
734 /* This is a hack until we finish the code so that it only reads
735 * the config file once and just operates on the tree already in
739 apr_pool_create(&ptemp, pconf);
740 apr_pool_tag(ptemp, "ptemp");
741 ap_server_root = def_server_root;
742 ap_server_conf = ap_read_config(process, ptemp, confname, &ap_conftree);
743 if (!ap_server_conf) {
744 destroy_and_exit_process(process, 1);
746 apr_pool_cleanup_register(pconf, &ap_server_conf,
747 ap_pool_cleanup_set_null, apr_pool_cleanup_null);
748 /* sort hooks here to make sure pre_config hooks are sorted properly */
751 if (ap_run_pre_config(pconf, plog, ptemp) != OK) {
752 ap_log_error(APLOG_MARK, APLOG_EMERG, 0, NULL,
753 APLOGNO(00017) "Pre-configuration failed, exiting");
754 destroy_and_exit_process(process, 1);
757 if (ap_process_config_tree(ap_server_conf, ap_conftree, process->pconf,
759 destroy_and_exit_process(process, 1);
761 ap_fixup_virtual_hosts(pconf, ap_server_conf);
762 ap_fini_vhost_config(pconf, ap_server_conf);
764 * Sort hooks again because ap_process_config_tree may have add modules
765 * and hence hooks. This happens with mod_perl and modules written in
770 if (ap_run_check_config(pconf, plog, ptemp, ap_server_conf) != OK) {
771 ap_log_error(APLOG_MARK, APLOG_EMERG, 0, NULL,
772 APLOGNO(00018) "Configuration check failed, exiting");
773 destroy_and_exit_process(process, 1);
776 apr_pool_clear(plog);
777 if (ap_run_open_logs(pconf, plog, ptemp, ap_server_conf) != OK) {
778 ap_log_error(APLOG_MARK, APLOG_EMERG, 0, NULL,
779 APLOGNO(00019) "Unable to open logs, exiting");
780 destroy_and_exit_process(process, 1);
783 if (ap_run_post_config(pconf, plog, ptemp, ap_server_conf) != OK) {
784 ap_log_error(APLOG_MARK, APLOG_EMERG, 0, NULL,
785 APLOGNO(00020) "Configuration Failed, exiting");
786 destroy_and_exit_process(process, 1);
789 apr_pool_destroy(ptemp);
790 apr_pool_lock(pconf, 1);
792 ap_run_optional_fn_retrieve();
794 ap_main_state = AP_SQ_MS_RUN_MPM;
795 if (ap_run_mpm(pconf, plog, ap_server_conf) != OK)
798 apr_pool_lock(pconf, 0);
801 apr_pool_lock(pconf, 0);
802 destroy_and_exit_process(process, 0);
804 return 0; /* Termination 'ok' */
807 #ifdef AP_USING_AUTOCONF
808 /* This ugly little hack pulls any function referenced in exports.c into
809 * the web server. exports.c is generated during the build, and it
810 * has all of the APR functions specified by the apr/apr.exports and
811 * apr-util/aprutil.exports files.
813 const void *ap_suck_in_APR(void);
814 const void *ap_suck_in_APR(void)
816 extern const void *ap_ugly_hack;