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