]> granicus.if.org Git - apache/blob - server/main.c
PID table impl: parent process keeps a local table store of
[apache] / server / main.c
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
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 #include "apr.h"
18 #include "apr_strings.h"
19 #include "apr_getopt.h"
20 #include "apr_general.h"
21 #include "apr_lib.h"
22 #include "apr_md5.h"
23 #include "apr_version.h"
24 #include "apu_version.h"
25
26 #define APR_WANT_STDIO
27 #define APR_WANT_STRFUNC
28 #include "apr_want.h"
29
30 #define CORE_PRIVATE
31 #include "ap_config.h"
32 #include "httpd.h"
33 #include "http_main.h"
34 #include "http_log.h"
35 #include "http_config.h"
36 #include "http_core.h"
37 #include "http_vhost.h"
38 #include "apr_uri.h"
39 #include "util_ebcdic.h"
40 #include "ap_mpm.h"
41 #include "mpm_common.h"
42
43 #if APR_HAVE_UNISTD_H
44 #include <unistd.h>
45 #endif
46
47 /* WARNING: Win32 binds http_main.c dynamically to the server. Please place
48  *          extern functions and global data in another appropriate module.
49  *
50  * Most significant main() global data can be found in http_config.c
51  */
52
53 static void show_mpm_settings(void)
54 {
55     int mpm_query_info;
56     apr_status_t retval;
57
58     printf("Server MPM:     %s\n", ap_show_mpm());
59
60     retval = ap_mpm_query(AP_MPMQ_IS_THREADED, &mpm_query_info);
61
62     if (retval == APR_SUCCESS) {
63         printf("  threaded:     ");
64
65         if (mpm_query_info == AP_MPMQ_DYNAMIC) {
66             printf("yes (variable thread count)\n");
67         }
68         else if (mpm_query_info == AP_MPMQ_STATIC) {
69             printf("yes (fixed thread count)\n");
70         }
71         else {
72             printf("no\n");
73         }
74     }
75
76     retval = ap_mpm_query(AP_MPMQ_IS_FORKED, &mpm_query_info);
77
78     if (retval == APR_SUCCESS) {
79         printf("    forked:     ");
80
81         if (mpm_query_info == AP_MPMQ_DYNAMIC) {
82             printf("yes (variable process count)\n");
83         }
84         else if (mpm_query_info == AP_MPMQ_STATIC) {
85             printf("yes (fixed process count)\n");
86         }
87         else {
88             printf("no\n");
89         }
90     }
91 }
92
93 static void show_compile_settings(void)
94 {
95     printf("Server version: %s\n", ap_get_server_description());
96     printf("Server built:   %s\n", ap_get_server_built());
97     printf("Server's Module Magic Number: %u:%u\n",
98            MODULE_MAGIC_NUMBER_MAJOR, MODULE_MAGIC_NUMBER_MINOR);
99     printf("Server loaded:  APR %s, APR-UTIL %s\n",
100            apr_version_string(), apu_version_string());
101     printf("Compiled using: APR %s, APR-UTIL %s\n",
102            APR_VERSION_STRING, APU_VERSION_STRING);
103     /* sizeof(foo) is long on some platforms so we might as well
104      * make it long everywhere to keep the printf format
105      * consistent
106      */
107     printf("Architecture:   %ld-bit\n", 8 * (long)sizeof(void *));
108
109     show_mpm_settings();
110
111     printf("Server compiled with....\n");
112 #ifdef BIG_SECURITY_HOLE
113     printf(" -D BIG_SECURITY_HOLE\n");
114 #endif
115
116 #ifdef SECURITY_HOLE_PASS_AUTHORIZATION
117     printf(" -D SECURITY_HOLE_PASS_AUTHORIZATION\n");
118 #endif
119
120 #ifdef OS
121     printf(" -D OS=\"" OS "\"\n");
122 #endif
123
124 #ifdef APACHE_MPM_DIR
125     printf(" -D APACHE_MPM_DIR=\"" APACHE_MPM_DIR "\"\n");
126 #endif
127
128 #ifdef HAVE_SHMGET
129     printf(" -D HAVE_SHMGET\n");
130 #endif
131
132 #if APR_FILE_BASED_SHM
133     printf(" -D APR_FILE_BASED_SHM\n");
134 #endif
135
136 #if APR_HAS_SENDFILE
137     printf(" -D APR_HAS_SENDFILE\n");
138 #endif
139
140 #if APR_HAS_MMAP
141     printf(" -D APR_HAS_MMAP\n");
142 #endif
143
144 #ifdef NO_WRITEV
145     printf(" -D NO_WRITEV\n");
146 #endif
147
148 #ifdef NO_LINGCLOSE
149     printf(" -D NO_LINGCLOSE\n");
150 #endif
151
152 #if APR_HAVE_IPV6
153     printf(" -D APR_HAVE_IPV6 (IPv4-mapped addresses ");
154 #ifdef AP_ENABLE_V4_MAPPED
155     printf("enabled)\n");
156 #else
157     printf("disabled)\n");
158 #endif
159 #endif
160
161 #if APR_USE_FLOCK_SERIALIZE
162     printf(" -D APR_USE_FLOCK_SERIALIZE\n");
163 #endif
164
165 #if APR_USE_SYSVSEM_SERIALIZE
166     printf(" -D APR_USE_SYSVSEM_SERIALIZE\n");
167 #endif
168
169 #if APR_USE_POSIXSEM_SERIALIZE
170     printf(" -D APR_USE_POSIXSEM_SERIALIZE\n");
171 #endif
172
173 #if APR_USE_FCNTL_SERIALIZE
174     printf(" -D APR_USE_FCNTL_SERIALIZE\n");
175 #endif
176
177 #if APR_USE_PROC_PTHREAD_SERIALIZE
178     printf(" -D APR_USE_PROC_PTHREAD_SERIALIZE\n");
179 #endif
180
181 #if APR_USE_PTHREAD_SERIALIZE
182     printf(" -D APR_USE_PTHREAD_SERIALIZE\n");
183 #endif
184
185 #if APR_PROCESS_LOCK_IS_GLOBAL
186     printf(" -D APR_PROCESS_LOCK_IS_GLOBAL\n");
187 #endif
188
189 #ifdef SINGLE_LISTEN_UNSERIALIZED_ACCEPT
190     printf(" -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT\n");
191 #endif
192
193 #if APR_HAS_OTHER_CHILD
194     printf(" -D APR_HAS_OTHER_CHILD\n");
195 #endif
196
197 #ifdef AP_HAVE_RELIABLE_PIPED_LOGS
198     printf(" -D AP_HAVE_RELIABLE_PIPED_LOGS\n");
199 #endif
200
201 #ifdef BUFFERED_LOGS
202     printf(" -D BUFFERED_LOGS\n");
203 #ifdef PIPE_BUF
204     printf(" -D PIPE_BUF=%ld\n",(long)PIPE_BUF);
205 #endif
206 #endif
207
208     printf(" -D DYNAMIC_MODULE_LIMIT=%ld\n",(long)DYNAMIC_MODULE_LIMIT);
209
210 #if APR_CHARSET_EBCDIC
211     printf(" -D APR_CHARSET_EBCDIC\n");
212 #endif
213
214 #ifdef NEED_HASHBANG_EMUL
215     printf(" -D NEED_HASHBANG_EMUL\n");
216 #endif
217
218 #ifdef SHARED_CORE
219     printf(" -D SHARED_CORE\n");
220 #endif
221
222 /* This list displays the compiled in default paths: */
223 #ifdef HTTPD_ROOT
224     printf(" -D HTTPD_ROOT=\"" HTTPD_ROOT "\"\n");
225 #endif
226
227 #ifdef SUEXEC_BIN
228     printf(" -D SUEXEC_BIN=\"" SUEXEC_BIN "\"\n");
229 #endif
230
231 #if defined(SHARED_CORE) && defined(SHARED_CORE_DIR)
232     printf(" -D SHARED_CORE_DIR=\"" SHARED_CORE_DIR "\"\n");
233 #endif
234
235 #ifdef DEFAULT_PIDLOG
236     printf(" -D DEFAULT_PIDLOG=\"" DEFAULT_PIDLOG "\"\n");
237 #endif
238
239 #ifdef DEFAULT_SCOREBOARD
240     printf(" -D DEFAULT_SCOREBOARD=\"" DEFAULT_SCOREBOARD "\"\n");
241 #endif
242
243 #ifdef DEFAULT_LOCKFILE
244     printf(" -D DEFAULT_LOCKFILE=\"" DEFAULT_LOCKFILE "\"\n");
245 #endif
246
247 #ifdef DEFAULT_ERRORLOG
248     printf(" -D DEFAULT_ERRORLOG=\"" DEFAULT_ERRORLOG "\"\n");
249 #endif
250
251 #ifdef AP_TYPES_CONFIG_FILE
252     printf(" -D AP_TYPES_CONFIG_FILE=\"" AP_TYPES_CONFIG_FILE "\"\n");
253 #endif
254
255 #ifdef SERVER_CONFIG_FILE
256     printf(" -D SERVER_CONFIG_FILE=\"" SERVER_CONFIG_FILE "\"\n");
257 #endif
258 }
259
260 static void destroy_and_exit_process(process_rec *process,
261                                      int process_exit_value)
262 {
263     apr_pool_destroy(process->pool); /* and destroy all descendent pools */
264     apr_terminate();
265     exit(process_exit_value);
266 }
267
268 #define OOM_MESSAGE "[crit] Memory allocation failed, " \
269     "aborting process." APR_EOL_STR
270
271 /* APR callback invoked if allocation fails. */
272 static int abort_on_oom(int retcode)
273 {
274     write(STDERR_FILENO, OOM_MESSAGE, strlen(OOM_MESSAGE));
275     abort();
276     return retcode; /* unreachable, hopefully. */
277 }
278
279 static process_rec *create_process(int argc, const char * const *argv)
280 {
281     process_rec *process;
282     apr_pool_t *cntx;
283     apr_status_t stat;
284
285     stat = apr_pool_create(&cntx, NULL);
286     if (stat != APR_SUCCESS) {
287         /* XXX From the time that we took away the NULL pool->malloc mapping
288          *     we have been unable to log here without segfaulting.
289          */
290         ap_log_error(APLOG_MARK, APLOG_ERR, stat, NULL,
291                      "apr_pool_create() failed to create "
292                      "initial context");
293         apr_terminate();
294         exit(1);
295     }
296
297     apr_pool_abort_set(abort_on_oom, cntx);
298     apr_pool_tag(cntx, "process");
299     ap_open_stderr_log(cntx);
300
301     process = apr_palloc(cntx, sizeof(process_rec));
302     process->pool = cntx;
303
304     apr_pool_create(&process->pconf, process->pool);
305     apr_pool_tag(process->pconf, "pconf");
306     process->argc = argc;
307     process->argv = argv;
308     process->short_name = apr_filepath_name_get(argv[0]);
309     return process;
310 }
311
312 static void usage(process_rec *process)
313 {
314     const char *bin = process->argv[0];
315     char pad[MAX_STRING_LEN];
316     unsigned i;
317
318     for (i = 0; i < strlen(bin); i++) {
319         pad[i] = ' ';
320     }
321
322     pad[i] = '\0';
323
324 #ifdef SHARED_CORE
325     ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL ,
326                  "Usage: %s [-R directory] [-D name] [-d directory] [-f file]",
327                  bin);
328 #else
329     ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
330                  "Usage: %s [-D name] [-d directory] [-f file]", bin);
331 #endif
332
333     ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
334                  "       %s [-C \"directive\"] [-c \"directive\"]", pad);
335
336 #ifdef WIN32
337     ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
338                  "       %s [-w] [-k start|restart|stop|shutdown]", pad);
339     ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
340                  "       %s [-k install|config|uninstall] [-n service_name]",
341                  pad);
342 #endif
343 #ifdef AP_MPM_WANT_SIGNAL_SERVER
344 #ifdef AP_MPM_WANT_SET_GRACEFUL_SHUTDOWN
345     ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
346                  "       %s [-k start|restart|graceful|graceful-stop|stop]",
347                  pad);
348 #else
349     ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
350                  "       %s [-k start|restart|graceful|stop]",
351                  pad);
352 #endif /* AP_MPM_WANT_SET_GRACEFUL_SHUTDOWN */
353 #endif
354     ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
355                  "       %s [-v] [-V] [-h] [-l] [-L] [-t] [-S]", pad);
356     ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
357                  "Options:");
358
359 #ifdef SHARED_CORE
360     ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
361                  "  -R directory       : specify an alternate location for "
362                  "shared object files");
363 #endif
364
365     ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
366                  "  -D name            : define a name for use in "
367                  "<IfDefine name> directives");
368     ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
369                  "  -d directory       : specify an alternate initial "
370                  "ServerRoot");
371     ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
372                  "  -f file            : specify an alternate ServerConfigFile");
373     ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
374                  "  -C \"directive\"     : process directive before reading "
375                  "config files");
376     ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
377                  "  -c \"directive\"     : process directive after reading "
378                  "config files");
379
380 #ifdef NETWARE
381     ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
382                  "  -n name            : set screen name");
383 #endif
384 #ifdef WIN32
385     ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
386                  "  -n name            : set service name and use its "
387                  "ServerConfigFile");
388     ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
389                  "  -k start           : tell Apache to start");
390     ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
391                  "  -k restart         : tell running Apache to do a graceful "
392                  "restart");
393     ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
394                  "  -k stop|shutdown   : tell running Apache to shutdown");
395     ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
396                  "  -k install         : install an Apache service");
397     ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
398                  "  -k config          : change startup Options of an Apache "
399                  "service");
400     ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
401                  "  -k uninstall       : uninstall an Apache service");
402     ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
403                  "  -w                 : hold open the console window on error");
404 #endif
405
406     ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
407                  "  -e level           : show startup errors of level "
408                  "(see LogLevel)");
409     ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
410                  "  -E file            : log startup errors to file");
411     ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
412                  "  -v                 : show version number");
413     ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
414                  "  -V                 : show compile settings");
415     ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
416                  "  -h                 : list available command line options "
417                  "(this page)");
418     ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
419                  "  -l                 : list compiled in modules");
420     ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
421                  "  -L                 : list available configuration "
422                  "directives");
423     ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
424                  "  -t -D DUMP_VHOSTS  : show parsed settings (currently only "
425                  "vhost settings)");
426     ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
427                  "  -S                 : a synonym for -t -D DUMP_VHOSTS");
428     ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
429                  "  -t -D DUMP_MODULES : show all loaded modules ");
430     ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
431                  "  -M                 : a synonym for -t -D DUMP_MODULES");
432     ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
433                  "  -t                 : run syntax check for config files");
434
435     destroy_and_exit_process(process, 1);
436 }
437
438 int main(int argc, const char * const argv[])
439 {
440     char c;
441     int configtestonly = 0;
442     const char *confname = SERVER_CONFIG_FILE;
443     const char *def_server_root = HTTPD_ROOT;
444     const char *temp_error_log = NULL;
445     const char *error;
446     process_rec *process;
447     server_rec *server_conf;
448     apr_pool_t *pglobal;
449     apr_pool_t *pconf;
450     apr_pool_t *plog; /* Pool of log streams, reset _after_ each read of conf */
451     apr_pool_t *ptemp; /* Pool for temporary config stuff, reset often */
452     apr_pool_t *pcommands; /* Pool for -D, -C and -c switches */
453     apr_getopt_t *opt;
454     apr_status_t rv;
455     module **mod;
456     const char *optarg;
457     APR_OPTIONAL_FN_TYPE(ap_signal_server) *signal_server;
458
459     AP_MONCONTROL(0); /* turn off profiling of startup */
460
461     apr_app_initialize(&argc, &argv, NULL);
462
463     process = create_process(argc, argv);
464     pglobal = process->pool;
465     pconf = process->pconf;
466     ap_server_argv0 = process->short_name;
467
468     /* Set up the OOM callback in the global pool, so all pools should
469      * by default inherit it. */
470     apr_pool_abort_set(abort_on_oom, apr_pool_parent_get(process->pool));
471
472 #if APR_CHARSET_EBCDIC
473     if (ap_init_ebcdic(pglobal) != APR_SUCCESS) {
474         destroy_and_exit_process(process, 1);
475     }
476 #endif
477
478     apr_pool_create(&pcommands, pglobal);
479     apr_pool_tag(pcommands, "pcommands");
480     ap_server_pre_read_config  = apr_array_make(pcommands, 1, sizeof(char *));
481     ap_server_post_read_config = apr_array_make(pcommands, 1, sizeof(char *));
482     ap_server_config_defines   = apr_array_make(pcommands, 1, sizeof(char *));
483     ap_pid_table               = apr_table_make(pglobal, 1024);
484
485     error = ap_setup_prelinked_modules(process);
486     if (error) {
487         ap_log_error(APLOG_MARK, APLOG_STARTUP|APLOG_EMERG, 0, NULL, "%s: %s",
488                      ap_server_argv0, error);
489         destroy_and_exit_process(process, 1);
490     }
491
492     ap_run_rewrite_args(process);
493
494     /* Maintain AP_SERVER_BASEARGS list in http_main.h to allow the MPM
495      * to safely pass on our args from its rewrite_args() handler.
496      */
497     apr_getopt_init(&opt, pcommands, process->argc, process->argv);
498
499     while ((rv = apr_getopt(opt, AP_SERVER_BASEARGS, &c, &optarg))
500             == APR_SUCCESS) {
501         char **new;
502
503         switch (c) {
504         case 'c':
505             new = (char **)apr_array_push(ap_server_post_read_config);
506             *new = apr_pstrdup(pcommands, optarg);
507             break;
508
509         case 'C':
510             new = (char **)apr_array_push(ap_server_pre_read_config);
511             *new = apr_pstrdup(pcommands, optarg);
512             break;
513
514         case 'd':
515             def_server_root = optarg;
516             break;
517
518         case 'D':
519             new = (char **)apr_array_push(ap_server_config_defines);
520             *new = apr_pstrdup(pcommands, optarg);
521             /* Setting -D DUMP_VHOSTS is equivalent to setting -S */
522             if (strcmp(optarg, "DUMP_VHOSTS") == 0)
523                 configtestonly = 1;
524             /* Setting -D DUMP_MODULES is equivalent to setting -M */
525             if (strcmp(optarg, "DUMP_MODULES") == 0)
526                 configtestonly = 1;
527             break;
528
529         case 'e':
530             if (strcasecmp(optarg, "emerg") == 0) {
531                 ap_default_loglevel = APLOG_EMERG;
532             }
533             else if (strcasecmp(optarg, "alert") == 0) {
534                 ap_default_loglevel = APLOG_ALERT;
535             }
536             else if (strcasecmp(optarg, "crit") == 0) {
537                 ap_default_loglevel = APLOG_CRIT;
538             }
539             else if (strncasecmp(optarg, "err", 3) == 0) {
540                 ap_default_loglevel = APLOG_ERR;
541             }
542             else if (strncasecmp(optarg, "warn", 4) == 0) {
543                 ap_default_loglevel = APLOG_WARNING;
544             }
545             else if (strcasecmp(optarg, "notice") == 0) {
546                 ap_default_loglevel = APLOG_NOTICE;
547             }
548             else if (strcasecmp(optarg, "info") == 0) {
549                 ap_default_loglevel = APLOG_INFO;
550             }
551             else if (strcasecmp(optarg, "debug") == 0) {
552                 ap_default_loglevel = APLOG_DEBUG;
553             }
554             else {
555                 usage(process);
556             }
557             break;
558
559         case 'E':
560             temp_error_log = apr_pstrdup(process->pool, optarg);
561             break;
562
563         case 'X':
564             new = (char **)apr_array_push(ap_server_config_defines);
565             *new = "DEBUG";
566             break;
567
568         case 'f':
569             confname = optarg;
570             break;
571
572         case 'v':
573             printf("Server version: %s\n", ap_get_server_description());
574             printf("Server built:   %s\n", ap_get_server_built());
575             destroy_and_exit_process(process, 0);
576
577         case 'V':
578             show_compile_settings();
579             destroy_and_exit_process(process, 0);
580
581         case 'l':
582             ap_show_modules();
583             destroy_and_exit_process(process, 0);
584
585         case 'L':
586             ap_show_directives();
587             destroy_and_exit_process(process, 0);
588
589         case 't':
590             configtestonly = 1;
591             break;
592
593         case 'S':
594             configtestonly = 1;
595             new = (char **)apr_array_push(ap_server_config_defines);
596             *new = "DUMP_VHOSTS";
597             break;
598
599         case 'M':
600             configtestonly = 1;
601             new = (char **)apr_array_push(ap_server_config_defines);
602             *new = "DUMP_MODULES";
603             break;
604
605         case 'h':
606         case '?':
607             usage(process);
608         }
609     }
610
611     /* bad cmdline option?  then we die */
612     if (rv != APR_EOF || opt->ind < opt->argc) {
613         usage(process);
614     }
615
616     apr_pool_create(&plog, pglobal);
617     apr_pool_tag(plog, "plog");
618     apr_pool_create(&ptemp, pconf);
619     apr_pool_tag(ptemp, "ptemp");
620
621     /* Note that we preflight the config file once
622      * before reading it _again_ in the main loop.
623      * This allows things, log files configuration
624      * for example, to settle down.
625      */
626
627     ap_server_root = def_server_root;
628     if (temp_error_log) {
629         ap_replace_stderr_log(process->pool, temp_error_log);
630     }
631     server_conf = ap_read_config(process, ptemp, confname, &ap_conftree);
632     if (!server_conf) {
633         destroy_and_exit_process(process, 1);
634     }
635
636     if (ap_run_pre_config(pconf, plog, ptemp) != OK) {
637         ap_log_error(APLOG_MARK, APLOG_STARTUP |APLOG_ERR, 0,
638                      NULL, "Pre-configuration failed");
639         destroy_and_exit_process(process, 1);
640     }
641
642     rv = ap_process_config_tree(server_conf, ap_conftree,
643                                 process->pconf, ptemp);
644     if (rv == OK) {
645         ap_fixup_virtual_hosts(pconf, server_conf);
646         ap_fini_vhost_config(pconf, server_conf);
647         apr_hook_sort_all();
648
649         if (ap_run_check_config(pconf, plog, ptemp, server_conf) != OK) {
650             ap_log_error(APLOG_MARK, APLOG_STARTUP |APLOG_ERR, 0,
651                          NULL, "Configuration check failed");
652             destroy_and_exit_process(process, 1);
653         }
654
655         if (configtestonly) {
656             ap_run_test_config(pconf, server_conf);
657             ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, "Syntax OK");
658             destroy_and_exit_process(process, 0);
659         }
660     }
661
662     signal_server = APR_RETRIEVE_OPTIONAL_FN(ap_signal_server);
663     if (signal_server) {
664         int exit_status;
665
666         if (signal_server(&exit_status, pconf) != 0) {
667             destroy_and_exit_process(process, exit_status);
668         }
669     }
670
671     /* If our config failed, deal with that here. */
672     if (rv != OK) {
673         destroy_and_exit_process(process, 1);
674     }
675
676     apr_pool_clear(plog);
677
678     if ( ap_run_open_logs(pconf, plog, ptemp, server_conf) != OK) {
679         ap_log_error(APLOG_MARK, APLOG_STARTUP |APLOG_ERR,
680                      0, NULL, "Unable to open logs");
681         destroy_and_exit_process(process, 1);
682     }
683
684     if ( ap_run_post_config(pconf, plog, ptemp, server_conf) != OK) {
685         ap_log_error(APLOG_MARK, APLOG_STARTUP |APLOG_ERR, 0,
686                      NULL, "Configuration Failed");
687         destroy_and_exit_process(process, 1);
688     }
689
690     apr_pool_destroy(ptemp);
691
692     for (;;) {
693         apr_hook_deregister_all();
694         apr_pool_clear(pconf);
695
696         for (mod = ap_prelinked_modules; *mod != NULL; mod++) {
697             ap_register_hooks(*mod, pconf);
698         }
699
700         /* This is a hack until we finish the code so that it only reads
701          * the config file once and just operates on the tree already in
702          * memory.  rbb
703          */
704         ap_conftree = NULL;
705         apr_pool_create(&ptemp, pconf);
706         apr_pool_tag(ptemp, "ptemp");
707         ap_server_root = def_server_root;
708         server_conf = ap_read_config(process, ptemp, confname, &ap_conftree);
709         if (!server_conf) {
710             destroy_and_exit_process(process, 1);
711         }
712
713         if (ap_run_pre_config(pconf, plog, ptemp) != OK) {
714             ap_log_error(APLOG_MARK, APLOG_STARTUP |APLOG_ERR,
715                          0, NULL, "Pre-configuration failed");
716             destroy_and_exit_process(process, 1);
717         }
718
719         if (ap_process_config_tree(server_conf, ap_conftree, process->pconf,
720                                    ptemp) != OK) {
721             destroy_and_exit_process(process, 1);
722         }
723         ap_fixup_virtual_hosts(pconf, server_conf);
724         ap_fini_vhost_config(pconf, server_conf);
725         apr_hook_sort_all();
726
727         if (ap_run_check_config(pconf, plog, ptemp, server_conf) != OK) {
728             ap_log_error(APLOG_MARK, APLOG_STARTUP |APLOG_ERR, 0,
729                          NULL, "Configuration check failed");
730             destroy_and_exit_process(process, 1);
731         }
732
733         apr_pool_clear(plog);
734         if (ap_run_open_logs(pconf, plog, ptemp, server_conf) != OK) {
735             ap_log_error(APLOG_MARK, APLOG_STARTUP |APLOG_ERR,
736                          0, NULL, "Unable to open logs");
737             destroy_and_exit_process(process, 1);
738         }
739
740         if (ap_run_post_config(pconf, plog, ptemp, server_conf) != OK) {
741             ap_log_error(APLOG_MARK, APLOG_STARTUP |APLOG_ERR,
742                          0, NULL, "Configuration Failed");
743             destroy_and_exit_process(process, 1);
744         }
745
746         apr_pool_destroy(ptemp);
747         apr_pool_lock(pconf, 1);
748
749         ap_run_optional_fn_retrieve();
750
751         if (ap_mpm_run(pconf, plog, server_conf))
752             break;
753
754         apr_pool_lock(pconf, 0);
755     }
756
757     apr_pool_lock(pconf, 0);
758     destroy_and_exit_process(process, 0);
759
760     return 0; /* Termination 'ok' */
761 }
762
763 #ifdef AP_USING_AUTOCONF
764 /* This ugly little hack pulls any function referenced in exports.c into
765  * the web server.  exports.c is generated during the build, and it
766  * has all of the APR functions specified by the apr/apr.exports and
767  * apr-util/aprutil.exports files.
768  */
769 const void *suck_in_APR(void);
770 const void *suck_in_APR(void)
771 {
772     extern const void *ap_ugly_hack;
773
774     return ap_ugly_hack;
775 }
776 #endif