Blame server/main.c

Packit 90a5c9
/* Licensed to the Apache Software Foundation (ASF) under one or more
Packit 90a5c9
 * contributor license agreements.  See the NOTICE file distributed with
Packit 90a5c9
 * this work for additional information regarding copyright ownership.
Packit 90a5c9
 * The ASF licenses this file to You under the Apache License, Version 2.0
Packit 90a5c9
 * (the "License"); you may not use this file except in compliance with
Packit 90a5c9
 * the License.  You may obtain a copy of the License at
Packit 90a5c9
 *
Packit 90a5c9
 *     http://www.apache.org/licenses/LICENSE-2.0
Packit 90a5c9
 *
Packit 90a5c9
 * Unless required by applicable law or agreed to in writing, software
Packit 90a5c9
 * distributed under the License is distributed on an "AS IS" BASIS,
Packit 90a5c9
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Packit 90a5c9
 * See the License for the specific language governing permissions and
Packit 90a5c9
 * limitations under the License.
Packit 90a5c9
 */
Packit 90a5c9
Packit 90a5c9
#include "apr.h"
Packit 90a5c9
#include "apr_strings.h"
Packit 90a5c9
#include "apr_getopt.h"
Packit 90a5c9
#include "apr_general.h"
Packit 90a5c9
#include "apr_lib.h"
Packit 90a5c9
#include "apr_md5.h"
Packit 90a5c9
#include "apr_time.h"
Packit 90a5c9
#include "apr_version.h"
Packit 90a5c9
#include "apu_version.h"
Packit 90a5c9
Packit 90a5c9
#define APR_WANT_STDIO
Packit 90a5c9
#define APR_WANT_STRFUNC
Packit 90a5c9
#include "apr_want.h"
Packit 90a5c9
Packit 90a5c9
#include "ap_config.h"
Packit 90a5c9
#include "httpd.h"
Packit 90a5c9
#include "http_main.h"
Packit 90a5c9
#include "http_log.h"
Packit 90a5c9
#include "http_config.h"
Packit 90a5c9
#include "http_core.h"
Packit 90a5c9
#include "mod_core.h"
Packit 90a5c9
#include "http_request.h"
Packit 90a5c9
#include "http_vhost.h"
Packit 90a5c9
#include "apr_uri.h"
Packit 90a5c9
#include "util_ebcdic.h"
Packit 90a5c9
#include "ap_mpm.h"
Packit 90a5c9
Packit 90a5c9
#if APR_HAVE_UNISTD_H
Packit 90a5c9
#include <unistd.h>
Packit 90a5c9
#endif
Packit 90a5c9
Packit 90a5c9
/* WARNING: Win32 binds http_main.c dynamically to the server. Please place
Packit 90a5c9
 *          extern functions and global data in another appropriate module.
Packit 90a5c9
 *
Packit 90a5c9
 * Most significant main() global data can be found in http_config.c
Packit 90a5c9
 */
Packit 90a5c9
Packit 90a5c9
static void show_mpm_settings(void)
Packit 90a5c9
{
Packit 90a5c9
    int mpm_query_info;
Packit 90a5c9
    apr_status_t retval;
Packit 90a5c9
Packit 90a5c9
    printf("Server MPM:     %s\n", ap_show_mpm());
Packit 90a5c9
Packit 90a5c9
    retval = ap_mpm_query(AP_MPMQ_IS_THREADED, &mpm_query_info);
Packit 90a5c9
Packit 90a5c9
    if (retval == APR_SUCCESS) {
Packit 90a5c9
        printf("  threaded:     ");
Packit 90a5c9
Packit 90a5c9
        if (mpm_query_info == AP_MPMQ_DYNAMIC) {
Packit 90a5c9
            printf("yes (variable thread count)\n");
Packit 90a5c9
        }
Packit 90a5c9
        else if (mpm_query_info == AP_MPMQ_STATIC) {
Packit 90a5c9
            printf("yes (fixed thread count)\n");
Packit 90a5c9
        }
Packit 90a5c9
        else {
Packit 90a5c9
            printf("no\n");
Packit 90a5c9
        }
Packit 90a5c9
    }
Packit 90a5c9
Packit 90a5c9
    retval = ap_mpm_query(AP_MPMQ_IS_FORKED, &mpm_query_info);
Packit 90a5c9
Packit 90a5c9
    if (retval == APR_SUCCESS) {
Packit 90a5c9
        printf("    forked:     ");
Packit 90a5c9
Packit 90a5c9
        if (mpm_query_info == AP_MPMQ_DYNAMIC) {
Packit 90a5c9
            printf("yes (variable process count)\n");
Packit 90a5c9
        }
Packit 90a5c9
        else if (mpm_query_info == AP_MPMQ_STATIC) {
Packit 90a5c9
            printf("yes (fixed process count)\n");
Packit 90a5c9
        }
Packit 90a5c9
        else {
Packit 90a5c9
            printf("no\n");
Packit 90a5c9
        }
Packit 90a5c9
    }
Packit 90a5c9
}
Packit 90a5c9
Packit 90a5c9
static void show_compile_settings(void)
Packit 90a5c9
{
Packit 90a5c9
    printf("Server version: %s\n", ap_get_server_description());
Packit 90a5c9
    printf("Server built:   %s\n", ap_get_server_built());
Packit 90a5c9
    printf("Server's Module Magic Number: %u:%u\n",
Packit 90a5c9
           MODULE_MAGIC_NUMBER_MAJOR, MODULE_MAGIC_NUMBER_MINOR);
Packit 90a5c9
#if APR_MAJOR_VERSION >= 2
Packit 90a5c9
    printf("Server loaded:  APR %s\n", apr_version_string());
Packit 90a5c9
    printf("Compiled using: APR %s\n", APR_VERSION_STRING);
Packit 90a5c9
#else
Packit 90a5c9
    printf("Server loaded:  APR %s, APR-UTIL %s\n",
Packit 90a5c9
           apr_version_string(), apu_version_string());
Packit 90a5c9
    printf("Compiled using: APR %s, APR-UTIL %s\n",
Packit 90a5c9
           APR_VERSION_STRING, APU_VERSION_STRING);
Packit 90a5c9
#endif
Packit 90a5c9
    /* sizeof(foo) is long on some platforms so we might as well
Packit 90a5c9
     * make it long everywhere to keep the printf format
Packit 90a5c9
     * consistent
Packit 90a5c9
     */
Packit 90a5c9
    printf("Architecture:   %ld-bit\n", 8 * (long)sizeof(void *));
Packit 90a5c9
Packit 90a5c9
    show_mpm_settings();
Packit 90a5c9
Packit 90a5c9
    printf("Server compiled with....\n");
Packit 90a5c9
#ifdef BIG_SECURITY_HOLE
Packit 90a5c9
    printf(" -D BIG_SECURITY_HOLE\n");
Packit 90a5c9
#endif
Packit 90a5c9
Packit 90a5c9
#ifdef SECURITY_HOLE_PASS_AUTHORIZATION
Packit 90a5c9
    printf(" -D SECURITY_HOLE_PASS_AUTHORIZATION\n");
Packit 90a5c9
#endif
Packit 90a5c9
Packit 90a5c9
#ifdef OS
Packit 90a5c9
    printf(" -D OS=\"" OS "\"\n");
Packit 90a5c9
#endif
Packit 90a5c9
Packit 90a5c9
#ifdef HAVE_SHMGET
Packit 90a5c9
    printf(" -D HAVE_SHMGET\n");
Packit 90a5c9
#endif
Packit 90a5c9
Packit 90a5c9
#if APR_FILE_BASED_SHM
Packit 90a5c9
    printf(" -D APR_FILE_BASED_SHM\n");
Packit 90a5c9
#endif
Packit 90a5c9
Packit 90a5c9
#if APR_HAS_SENDFILE
Packit 90a5c9
    printf(" -D APR_HAS_SENDFILE\n");
Packit 90a5c9
#endif
Packit 90a5c9
Packit 90a5c9
#if APR_HAS_MMAP
Packit 90a5c9
    printf(" -D APR_HAS_MMAP\n");
Packit 90a5c9
#endif
Packit 90a5c9
Packit 90a5c9
#ifdef NO_WRITEV
Packit 90a5c9
    printf(" -D NO_WRITEV\n");
Packit 90a5c9
#endif
Packit 90a5c9
Packit 90a5c9
#ifdef NO_LINGCLOSE
Packit 90a5c9
    printf(" -D NO_LINGCLOSE\n");
Packit 90a5c9
#endif
Packit 90a5c9
Packit 90a5c9
#if APR_HAVE_IPV6
Packit 90a5c9
    printf(" -D APR_HAVE_IPV6 (IPv4-mapped addresses ");
Packit 90a5c9
#ifdef AP_ENABLE_V4_MAPPED
Packit 90a5c9
    printf("enabled)\n");
Packit 90a5c9
#else
Packit 90a5c9
    printf("disabled)\n");
Packit 90a5c9
#endif
Packit 90a5c9
#endif
Packit 90a5c9
Packit 90a5c9
#if APR_USE_FLOCK_SERIALIZE
Packit 90a5c9
    printf(" -D APR_USE_FLOCK_SERIALIZE\n");
Packit 90a5c9
#endif
Packit 90a5c9
Packit 90a5c9
#if APR_USE_SYSVSEM_SERIALIZE
Packit 90a5c9
    printf(" -D APR_USE_SYSVSEM_SERIALIZE\n");
Packit 90a5c9
#endif
Packit 90a5c9
Packit 90a5c9
#if APR_USE_POSIXSEM_SERIALIZE
Packit 90a5c9
    printf(" -D APR_USE_POSIXSEM_SERIALIZE\n");
Packit 90a5c9
#endif
Packit 90a5c9
Packit 90a5c9
#if APR_USE_FCNTL_SERIALIZE
Packit 90a5c9
    printf(" -D APR_USE_FCNTL_SERIALIZE\n");
Packit 90a5c9
#endif
Packit 90a5c9
Packit 90a5c9
#if APR_USE_PROC_PTHREAD_SERIALIZE
Packit 90a5c9
    printf(" -D APR_USE_PROC_PTHREAD_SERIALIZE\n");
Packit 90a5c9
#endif
Packit 90a5c9
Packit 90a5c9
#if APR_USE_PTHREAD_SERIALIZE
Packit 90a5c9
    printf(" -D APR_USE_PTHREAD_SERIALIZE\n");
Packit 90a5c9
#endif
Packit 90a5c9
Packit 90a5c9
#if APR_PROCESS_LOCK_IS_GLOBAL
Packit 90a5c9
    printf(" -D APR_PROCESS_LOCK_IS_GLOBAL\n");
Packit 90a5c9
#endif
Packit 90a5c9
Packit 90a5c9
#ifdef SINGLE_LISTEN_UNSERIALIZED_ACCEPT
Packit 90a5c9
    printf(" -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT\n");
Packit 90a5c9
#endif
Packit 90a5c9
Packit 90a5c9
#if APR_HAS_OTHER_CHILD
Packit 90a5c9
    printf(" -D APR_HAS_OTHER_CHILD\n");
Packit 90a5c9
#endif
Packit 90a5c9
Packit 90a5c9
#ifdef AP_HAVE_RELIABLE_PIPED_LOGS
Packit 90a5c9
    printf(" -D AP_HAVE_RELIABLE_PIPED_LOGS\n");
Packit 90a5c9
#endif
Packit 90a5c9
Packit 90a5c9
#ifdef BUFFERED_LOGS
Packit 90a5c9
    printf(" -D BUFFERED_LOGS\n");
Packit 90a5c9
#ifdef PIPE_BUF
Packit 90a5c9
    printf(" -D PIPE_BUF=%ld\n",(long)PIPE_BUF);
Packit 90a5c9
#endif
Packit 90a5c9
#endif
Packit 90a5c9
Packit 90a5c9
    printf(" -D DYNAMIC_MODULE_LIMIT=%ld\n",(long)DYNAMIC_MODULE_LIMIT);
Packit 90a5c9
Packit 90a5c9
#if APR_CHARSET_EBCDIC
Packit 90a5c9
    printf(" -D APR_CHARSET_EBCDIC\n");
Packit 90a5c9
#endif
Packit 90a5c9
Packit 90a5c9
#ifdef NEED_HASHBANG_EMUL
Packit 90a5c9
    printf(" -D NEED_HASHBANG_EMUL\n");
Packit 90a5c9
#endif
Packit 90a5c9
Packit 90a5c9
/* This list displays the compiled in default paths: */
Packit 90a5c9
#ifdef HTTPD_ROOT
Packit 90a5c9
    printf(" -D HTTPD_ROOT=\"" HTTPD_ROOT "\"\n");
Packit 90a5c9
#endif
Packit 90a5c9
Packit 90a5c9
#ifdef SUEXEC_BIN
Packit 90a5c9
    printf(" -D SUEXEC_BIN=\"" SUEXEC_BIN "\"\n");
Packit 90a5c9
#endif
Packit 90a5c9
Packit 90a5c9
#ifdef DEFAULT_PIDLOG
Packit 90a5c9
    printf(" -D DEFAULT_PIDLOG=\"" DEFAULT_PIDLOG "\"\n");
Packit 90a5c9
#endif
Packit 90a5c9
Packit 90a5c9
#ifdef DEFAULT_SCOREBOARD
Packit 90a5c9
    printf(" -D DEFAULT_SCOREBOARD=\"" DEFAULT_SCOREBOARD "\"\n");
Packit 90a5c9
#endif
Packit 90a5c9
Packit 90a5c9
#ifdef DEFAULT_ERRORLOG
Packit 90a5c9
    printf(" -D DEFAULT_ERRORLOG=\"" DEFAULT_ERRORLOG "\"\n");
Packit 90a5c9
#endif
Packit 90a5c9
Packit 90a5c9
#ifdef AP_TYPES_CONFIG_FILE
Packit 90a5c9
    printf(" -D AP_TYPES_CONFIG_FILE=\"" AP_TYPES_CONFIG_FILE "\"\n");
Packit 90a5c9
#endif
Packit 90a5c9
Packit 90a5c9
#ifdef SERVER_CONFIG_FILE
Packit 90a5c9
    printf(" -D SERVER_CONFIG_FILE=\"" SERVER_CONFIG_FILE "\"\n");
Packit 90a5c9
#endif
Packit 90a5c9
}
Packit 90a5c9
Packit 90a5c9
#define TASK_SWITCH_SLEEP 10000
Packit 90a5c9
Packit 90a5c9
static void destroy_and_exit_process(process_rec *process,
Packit 90a5c9
                                     int process_exit_value)
Packit 90a5c9
{
Packit 90a5c9
    /*
Packit 90a5c9
     * Sleep for TASK_SWITCH_SLEEP micro seconds to cause a task switch on
Packit 90a5c9
     * OS layer and thus give possibly started piped loggers a chance to
Packit 90a5c9
     * process their input. Otherwise it is possible that they get killed
Packit 90a5c9
     * by us before they can do so. In this case maybe valueable log messages
Packit 90a5c9
     * might get lost.
Packit 90a5c9
     */
Packit 90a5c9
    apr_sleep(TASK_SWITCH_SLEEP);
Packit 90a5c9
    ap_main_state = AP_SQ_MS_EXITING;
Packit 90a5c9
    apr_pool_destroy(process->pool); /* and destroy all descendent pools */
Packit 90a5c9
    apr_terminate();
Packit 90a5c9
    exit(process_exit_value);
Packit 90a5c9
}
Packit 90a5c9
Packit 90a5c9
/* APR callback invoked if allocation fails. */
Packit 90a5c9
static int abort_on_oom(int retcode)
Packit 90a5c9
{
Packit 90a5c9
    ap_abort_on_oom();
Packit 90a5c9
    return retcode; /* unreachable, hopefully. */
Packit 90a5c9
}
Packit 90a5c9
Packit 90a5c9
/* Deregister all hooks when clearing pconf (pre_cleanup).
Packit 90a5c9
 * TODO: have a hook to deregister and run them from here?
Packit 90a5c9
 *       ap_clear_auth_internal() is already a candidate.
Packit 90a5c9
 */
Packit 90a5c9
static apr_status_t deregister_all_hooks(void *unused)
Packit 90a5c9
{
Packit 90a5c9
    (void)unused;
Packit 90a5c9
    ap_clear_auth_internal();
Packit 90a5c9
    apr_hook_deregister_all();
Packit 90a5c9
    return APR_SUCCESS;
Packit 90a5c9
}
Packit 90a5c9
Packit 90a5c9
static void reset_process_pconf(process_rec *process)
Packit 90a5c9
{
Packit 90a5c9
    if (process->pconf) {
Packit 90a5c9
        apr_pool_clear(process->pconf);
Packit 90a5c9
        ap_server_conf = NULL;
Packit 90a5c9
    }
Packit 90a5c9
    else {
Packit 90a5c9
        apr_pool_create(&process->pconf, process->pool);
Packit 90a5c9
        apr_pool_tag(process->pconf, "pconf");
Packit 90a5c9
    }
Packit 90a5c9
    apr_pool_pre_cleanup_register(process->pconf, NULL, deregister_all_hooks);
Packit 90a5c9
}
Packit 90a5c9
Packit 90a5c9
static process_rec *init_process(int *argc, const char * const * *argv)
Packit 90a5c9
{
Packit 90a5c9
    process_rec *process;
Packit 90a5c9
    apr_pool_t *cntx;
Packit 90a5c9
    apr_status_t stat;
Packit 90a5c9
    const char *failed = "apr_app_initialize()";
Packit 90a5c9
Packit 90a5c9
    stat = apr_app_initialize(argc, argv, NULL);
Packit 90a5c9
    if (stat == APR_SUCCESS) {
Packit 90a5c9
        failed = "apr_pool_create()";
Packit 90a5c9
        stat = apr_pool_create(&cntx, NULL);
Packit 90a5c9
    }
Packit 90a5c9
Packit 90a5c9
    if (stat != APR_SUCCESS) {
Packit 90a5c9
        /* For all intents and purposes, this is impossibly unlikely,
Packit 90a5c9
         * but APR doesn't exist yet, we can't use it for reporting
Packit 90a5c9
         * these earliest two failures;
Packit 90a5c9
         *
Packit 90a5c9
         * XXX: Note the apr_ctime() and apr_time_now() calls.  These
Packit 90a5c9
         * work, today, against an uninitialized APR, but in the future
Packit 90a5c9
         * (if they relied on global pools or mutexes, for example) then
Packit 90a5c9
         * the datestamp logic will need to be replaced.
Packit 90a5c9
         */
Packit 90a5c9
        char ctimebuff[APR_CTIME_LEN];
Packit 90a5c9
        apr_ctime(ctimebuff, apr_time_now());
Packit 90a5c9
        fprintf(stderr, "[%s] [crit] (%d) %s: %s failed "
Packit 90a5c9
                        "to initial context, exiting\n",
Packit 90a5c9
                        ctimebuff, stat, (*argv)[0], failed);
Packit 90a5c9
        apr_terminate();
Packit 90a5c9
        exit(1);
Packit 90a5c9
    }
Packit 90a5c9
Packit 90a5c9
    apr_pool_abort_set(abort_on_oom, cntx);
Packit 90a5c9
    apr_pool_tag(cntx, "process");
Packit 90a5c9
    ap_open_stderr_log(cntx);
Packit 90a5c9
Packit 90a5c9
    /* Now we have initialized apr and our logger, no more
Packit 90a5c9
     * exceptional error reporting required for the lifetime
Packit 90a5c9
     * of this server process.
Packit 90a5c9
     */
Packit 90a5c9
Packit 90a5c9
    process = apr_palloc(cntx, sizeof(process_rec));
Packit 90a5c9
    process->pool = cntx;
Packit 90a5c9
Packit 90a5c9
    process->pconf = NULL;
Packit 90a5c9
    reset_process_pconf(process);
Packit 90a5c9
Packit 90a5c9
    process->argc = *argc;
Packit 90a5c9
    process->argv = *argv;
Packit 90a5c9
    process->short_name = apr_filepath_name_get((*argv)[0]);
Packit 90a5c9
    return process;
Packit 90a5c9
}
Packit 90a5c9
Packit 90a5c9
static void usage(process_rec *process)
Packit 90a5c9
{
Packit 90a5c9
    const char *bin = process->argv[0];
Packit 90a5c9
    int pad_len = strlen(bin);
Packit 90a5c9
Packit 90a5c9
    ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
Packit 90a5c9
                 "Usage: %s [-D name] [-d directory] [-f file]", bin);
Packit 90a5c9
Packit 90a5c9
    ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
Packit 90a5c9
                 "       %*s [-C \"directive\"] [-c \"directive\"]", pad_len, " ");
Packit 90a5c9
Packit 90a5c9
#ifdef WIN32
Packit 90a5c9
    ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
Packit 90a5c9
                 "       %*s [-w] [-k start|restart|stop|shutdown] [-n service_name]",
Packit 90a5c9
                 pad_len, " ");
Packit 90a5c9
    ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
Packit 90a5c9
                 "       %*s [-k install|config|uninstall] [-n service_name]",
Packit 90a5c9
                 pad_len, " ");
Packit 90a5c9
#else
Packit 90a5c9
/* XXX not all MPMs support signalling the server in general or graceful-stop
Packit 90a5c9
 * in particular
Packit 90a5c9
 */
Packit 90a5c9
    ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
Packit 90a5c9
                 "       %*s [-k start|restart|graceful|graceful-stop|stop]",
Packit 90a5c9
                 pad_len, " ");
Packit 90a5c9
#endif
Packit 90a5c9
    ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
Packit 90a5c9
                 "       %*s [-v] [-V] [-h] [-l] [-L] [-t] [-T] [-S] [-X]",
Packit 90a5c9
                 pad_len, " ");
Packit 90a5c9
    ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
Packit 90a5c9
                 "Options:");
Packit 90a5c9
Packit 90a5c9
    ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
Packit 90a5c9
                 "  -D name            : define a name for use in "
Packit 90a5c9
                 "<IfDefine name> directives");
Packit 90a5c9
    ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
Packit 90a5c9
                 "  -d directory       : specify an alternate initial "
Packit 90a5c9
                 "ServerRoot");
Packit 90a5c9
    ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
Packit 90a5c9
                 "  -f file            : specify an alternate ServerConfigFile");
Packit 90a5c9
    ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
Packit 90a5c9
                 "  -C \"directive\"     : process directive before reading "
Packit 90a5c9
                 "config files");
Packit 90a5c9
    ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
Packit 90a5c9
                 "  -c \"directive\"     : process directive after reading "
Packit 90a5c9
                 "config files");
Packit 90a5c9
Packit 90a5c9
#ifdef NETWARE
Packit 90a5c9
    ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
Packit 90a5c9
                 "  -n name            : set screen name");
Packit 90a5c9
#endif
Packit 90a5c9
#ifdef WIN32
Packit 90a5c9
    ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
Packit 90a5c9
                 "  -n name            : set service name and use its "
Packit 90a5c9
                 "ServerConfigFile and ServerRoot");
Packit 90a5c9
    ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
Packit 90a5c9
                 "  -k start           : tell Apache to start");
Packit 90a5c9
    ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
Packit 90a5c9
                 "  -k restart         : tell running Apache to do a graceful "
Packit 90a5c9
                 "restart");
Packit 90a5c9
    ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
Packit 90a5c9
                 "  -k stop|shutdown   : tell running Apache to shutdown");
Packit 90a5c9
    ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
Packit 90a5c9
                 "  -k install         : install an Apache service");
Packit 90a5c9
    ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
Packit 90a5c9
                 "  -k config          : change startup Options of an Apache "
Packit 90a5c9
                 "service");
Packit 90a5c9
    ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
Packit 90a5c9
                 "  -k uninstall       : uninstall an Apache service");
Packit 90a5c9
    ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
Packit 90a5c9
                 "  -w                 : hold open the console window on error");
Packit 90a5c9
#endif
Packit 90a5c9
Packit 90a5c9
    ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
Packit 90a5c9
                 "  -e level           : show startup errors of level "
Packit 90a5c9
                 "(see LogLevel)");
Packit 90a5c9
    ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
Packit 90a5c9
                 "  -E file            : log startup errors to file");
Packit 90a5c9
    ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
Packit 90a5c9
                 "  -v                 : show version number");
Packit 90a5c9
    ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
Packit 90a5c9
                 "  -V                 : show compile settings");
Packit 90a5c9
    ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
Packit 90a5c9
                 "  -h                 : list available command line options "
Packit 90a5c9
                 "(this page)");
Packit 90a5c9
    ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
Packit 90a5c9
                 "  -l                 : list compiled in modules");
Packit 90a5c9
    ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
Packit 90a5c9
                 "  -L                 : list available configuration "
Packit 90a5c9
                 "directives");
Packit 90a5c9
    ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
Packit 90a5c9
                 "  -t -D DUMP_VHOSTS  : show parsed vhost settings");
Packit 90a5c9
    ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
Packit 90a5c9
                 "  -t -D DUMP_RUN_CFG : show parsed run settings");
Packit 90a5c9
    ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
Packit 90a5c9
                 "  -S                 : a synonym for -t -D DUMP_VHOSTS -D DUMP_RUN_CFG");
Packit 90a5c9
    ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
Packit 90a5c9
                 "  -t -D DUMP_MODULES : show all loaded modules ");
Packit 90a5c9
    ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
Packit 90a5c9
                 "  -M                 : a synonym for -t -D DUMP_MODULES");
Packit 90a5c9
    ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
Packit 90a5c9
                 "  -t -D DUMP_INCLUDES: show all included configuration files");
Packit 90a5c9
    ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
Packit 90a5c9
                 "  -t                 : run syntax check for config files");
Packit 90a5c9
    ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
Packit 90a5c9
                 "  -T                 : start without DocumentRoot(s) check");
Packit 90a5c9
    ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
Packit 90a5c9
                 "  -X                 : debug mode (only one worker, do not detach)");
Packit 90a5c9
Packit 90a5c9
    destroy_and_exit_process(process, 1);
Packit 90a5c9
}
Packit 90a5c9
Packit 90a5c9
int main(int argc, const char * const argv[])
Packit 90a5c9
{
Packit 90a5c9
    char c;
Packit 90a5c9
    int showcompile = 0, showdirectives = 0;
Packit 90a5c9
    const char *confname = SERVER_CONFIG_FILE;
Packit 90a5c9
    const char *def_server_root = HTTPD_ROOT;
Packit 90a5c9
    const char *temp_error_log = NULL;
Packit 90a5c9
    const char *error;
Packit 90a5c9
    process_rec *process;
Packit 90a5c9
    apr_pool_t *pconf;
Packit 90a5c9
    apr_pool_t *plog; /* Pool of log streams, reset _after_ each read of conf */
Packit 90a5c9
    apr_pool_t *ptemp; /* Pool for temporary config stuff, reset often */
Packit 90a5c9
    apr_pool_t *pcommands; /* Pool for -D, -C and -c switches */
Packit 90a5c9
    apr_getopt_t *opt;
Packit 90a5c9
    apr_status_t rv;
Packit 90a5c9
    module **mod;
Packit 90a5c9
    const char *opt_arg;
Packit 90a5c9
    APR_OPTIONAL_FN_TYPE(ap_signal_server) *signal_server;
Packit 90a5c9
    int rc = OK;
Packit 90a5c9
Packit 90a5c9
    AP_MONCONTROL(0); /* turn off profiling of startup */
Packit 90a5c9
Packit 90a5c9
    process = init_process(&argc, &argv);
Packit 90a5c9
    ap_pglobal = process->pool;
Packit 90a5c9
    pconf = process->pconf;
Packit 90a5c9
    ap_server_argv0 = process->short_name;
Packit 90a5c9
    ap_init_rng(ap_pglobal);
Packit 90a5c9
Packit 90a5c9
    /* Set up the OOM callback in the global pool, so all pools should
Packit 90a5c9
     * by default inherit it. */
Packit 90a5c9
    apr_pool_abort_set(abort_on_oom, apr_pool_parent_get(process->pool));
Packit 90a5c9
Packit 90a5c9
#if APR_CHARSET_EBCDIC
Packit 90a5c9
    if (ap_init_ebcdic(ap_pglobal) != APR_SUCCESS) {
Packit 90a5c9
        destroy_and_exit_process(process, 1);
Packit 90a5c9
    }
Packit 90a5c9
#endif
Packit 90a5c9
Packit 90a5c9
    apr_pool_create(&pcommands, ap_pglobal);
Packit 90a5c9
    apr_pool_tag(pcommands, "pcommands");
Packit 90a5c9
    ap_server_pre_read_config  = apr_array_make(pcommands, 1,
Packit 90a5c9
                                                sizeof(const char *));
Packit 90a5c9
    ap_server_post_read_config = apr_array_make(pcommands, 1,
Packit 90a5c9
                                                sizeof(const char *));
Packit 90a5c9
    ap_server_config_defines   = apr_array_make(pcommands, 1,
Packit 90a5c9
                                                sizeof(const char *));
Packit 90a5c9
Packit 90a5c9
    error = ap_setup_prelinked_modules(process);
Packit 90a5c9
    if (error) {
Packit 90a5c9
        ap_log_error(APLOG_MARK, APLOG_STARTUP|APLOG_EMERG, 0, NULL, APLOGNO(00012)
Packit 90a5c9
                     "%s: %s", ap_server_argv0, error);
Packit 90a5c9
        destroy_and_exit_process(process, 1);
Packit 90a5c9
    }
Packit 90a5c9
Packit 90a5c9
    ap_run_rewrite_args(process);
Packit 90a5c9
Packit 90a5c9
    /* Maintain AP_SERVER_BASEARGS list in http_main.h to allow the MPM
Packit 90a5c9
     * to safely pass on our args from its rewrite_args() handler.
Packit 90a5c9
     */
Packit 90a5c9
    apr_getopt_init(&opt, pcommands, process->argc, process->argv);
Packit 90a5c9
Packit 90a5c9
    while ((rv = apr_getopt(opt, AP_SERVER_BASEARGS, &c, &opt_arg))
Packit 90a5c9
            == APR_SUCCESS) {
Packit 90a5c9
        const char **new;
Packit 90a5c9
Packit 90a5c9
        switch (c) {
Packit 90a5c9
        case 'c':
Packit 90a5c9
            new = (const char **)apr_array_push(ap_server_post_read_config);
Packit 90a5c9
            *new = apr_pstrdup(pcommands, opt_arg);
Packit 90a5c9
            break;
Packit 90a5c9
Packit 90a5c9
        case 'C':
Packit 90a5c9
            new = (const char **)apr_array_push(ap_server_pre_read_config);
Packit 90a5c9
            *new = apr_pstrdup(pcommands, opt_arg);
Packit 90a5c9
            break;
Packit 90a5c9
Packit 90a5c9
        case 'd':
Packit 90a5c9
            def_server_root = opt_arg;
Packit 90a5c9
            break;
Packit 90a5c9
Packit 90a5c9
        case 'D':
Packit 90a5c9
            new = (const char **)apr_array_push(ap_server_config_defines);
Packit 90a5c9
            *new = apr_pstrdup(pcommands, opt_arg);
Packit 90a5c9
            /* Setting -D DUMP_VHOSTS should work like setting -S */
Packit 90a5c9
            if (strcmp(opt_arg, "DUMP_VHOSTS") == 0)
Packit 90a5c9
                ap_run_mode = AP_SQ_RM_CONFIG_DUMP;
Packit 90a5c9
            /* Setting -D DUMP_RUN_CFG should work like setting -S */
Packit 90a5c9
            else if (strcmp(opt_arg, "DUMP_RUN_CFG") == 0)
Packit 90a5c9
                ap_run_mode = AP_SQ_RM_CONFIG_DUMP;
Packit 90a5c9
            /* Setting -D DUMP_MODULES is equivalent to setting -M */
Packit 90a5c9
            else if (strcmp(opt_arg, "DUMP_MODULES") == 0)
Packit 90a5c9
                ap_run_mode = AP_SQ_RM_CONFIG_DUMP;
Packit 90a5c9
            /* Setting -D DUMP_INCLUDES is a type of configuration dump */
Packit 90a5c9
            else if (strcmp(opt_arg, "DUMP_INCLUDES") == 0)
Packit 90a5c9
                ap_run_mode = AP_SQ_RM_CONFIG_DUMP;
Packit 90a5c9
            break;
Packit 90a5c9
Packit 90a5c9
        case 'e':
Packit 90a5c9
            if (ap_parse_log_level(opt_arg, &ap_default_loglevel) != NULL)
Packit 90a5c9
                usage(process);
Packit 90a5c9
            break;
Packit 90a5c9
Packit 90a5c9
        case 'E':
Packit 90a5c9
            temp_error_log = apr_pstrdup(process->pool, opt_arg);
Packit 90a5c9
            break;
Packit 90a5c9
Packit 90a5c9
        case 'X':
Packit 90a5c9
            new = (const char **)apr_array_push(ap_server_config_defines);
Packit 90a5c9
            *new = "DEBUG";
Packit 90a5c9
            break;
Packit 90a5c9
Packit 90a5c9
        case 'f':
Packit 90a5c9
            confname = opt_arg;
Packit 90a5c9
            break;
Packit 90a5c9
Packit 90a5c9
        case 'v':
Packit 90a5c9
            printf("Server version: %s\n", ap_get_server_description());
Packit 90a5c9
            printf("Server built:   %s\n", ap_get_server_built());
Packit 90a5c9
            destroy_and_exit_process(process, 0);
Packit 90a5c9
Packit 90a5c9
        case 'l':
Packit 90a5c9
            ap_show_modules();
Packit 90a5c9
            destroy_and_exit_process(process, 0);
Packit 90a5c9
Packit 90a5c9
        case 'L':
Packit 90a5c9
            ap_run_mode = AP_SQ_RM_CONFIG_DUMP;
Packit 90a5c9
            showdirectives = 1;
Packit 90a5c9
            break;
Packit 90a5c9
Packit 90a5c9
        case 't':
Packit 90a5c9
            if (ap_run_mode == AP_SQ_RM_UNKNOWN)
Packit 90a5c9
                ap_run_mode = AP_SQ_RM_CONFIG_TEST;
Packit 90a5c9
            break;
Packit 90a5c9
Packit 90a5c9
       case 'T':
Packit 90a5c9
           ap_document_root_check = 0;
Packit 90a5c9
           break;
Packit 90a5c9
Packit 90a5c9
        case 'S':
Packit 90a5c9
            ap_run_mode = AP_SQ_RM_CONFIG_DUMP;
Packit 90a5c9
            new = (const char **)apr_array_push(ap_server_config_defines);
Packit 90a5c9
            *new = "DUMP_VHOSTS";
Packit 90a5c9
            new = (const char **)apr_array_push(ap_server_config_defines);
Packit 90a5c9
            *new = "DUMP_RUN_CFG";
Packit 90a5c9
            break;
Packit 90a5c9
Packit 90a5c9
        case 'M':
Packit 90a5c9
            ap_run_mode = AP_SQ_RM_CONFIG_DUMP;
Packit 90a5c9
            new = (const char **)apr_array_push(ap_server_config_defines);
Packit 90a5c9
            *new = "DUMP_MODULES";
Packit 90a5c9
            break;
Packit 90a5c9
Packit 90a5c9
        case 'V':
Packit 90a5c9
            if (strcmp(ap_show_mpm(), "")) { /* MPM built-in? */
Packit 90a5c9
                show_compile_settings();
Packit 90a5c9
                destroy_and_exit_process(process, 0);
Packit 90a5c9
            }
Packit 90a5c9
            else {
Packit 90a5c9
                showcompile = 1;
Packit 90a5c9
                ap_run_mode = AP_SQ_RM_CONFIG_DUMP;
Packit 90a5c9
            }
Packit 90a5c9
            break;
Packit 90a5c9
Packit 90a5c9
        case 'h':
Packit 90a5c9
        case '?':
Packit 90a5c9
            usage(process);
Packit 90a5c9
        }
Packit 90a5c9
    }
Packit 90a5c9
Packit 90a5c9
    if (ap_run_mode == AP_SQ_RM_UNKNOWN)
Packit 90a5c9
        ap_run_mode = AP_SQ_RM_NORMAL;
Packit 90a5c9
Packit 90a5c9
    /* bad cmdline option?  then we die */
Packit 90a5c9
    if (rv != APR_EOF || opt->ind < opt->argc) {
Packit 90a5c9
        usage(process);
Packit 90a5c9
    }
Packit 90a5c9
Packit 90a5c9
    ap_main_state = AP_SQ_MS_CREATE_PRE_CONFIG;
Packit 90a5c9
    apr_pool_create(&plog, ap_pglobal);
Packit 90a5c9
    apr_pool_tag(plog, "plog");
Packit 90a5c9
    apr_pool_create(&ptemp, pconf);
Packit 90a5c9
    apr_pool_tag(ptemp, "ptemp");
Packit 90a5c9
Packit 90a5c9
    /* Note that we preflight the config file once
Packit 90a5c9
     * before reading it _again_ in the main loop.
Packit 90a5c9
     * This allows things, log files configuration
Packit 90a5c9
     * for example, to settle down.
Packit 90a5c9
     */
Packit 90a5c9
Packit 90a5c9
    ap_server_root = def_server_root;
Packit 90a5c9
    if (temp_error_log) {
Packit 90a5c9
        ap_replace_stderr_log(process->pool, temp_error_log);
Packit 90a5c9
    }
Packit 90a5c9
    ap_server_conf = ap_read_config(process, ptemp, confname, &ap_conftree);
Packit 90a5c9
    if (!ap_server_conf) {
Packit 90a5c9
        if (showcompile) {
Packit 90a5c9
            /* Well, we tried. Show as much as we can, but exit nonzero to
Packit 90a5c9
             * indicate that something's not right. The cause should have
Packit 90a5c9
             * already been logged. */
Packit 90a5c9
            show_compile_settings();
Packit 90a5c9
        }
Packit 90a5c9
        destroy_and_exit_process(process, 1);
Packit 90a5c9
    }
Packit 90a5c9
    apr_pool_cleanup_register(pconf, &ap_server_conf, ap_pool_cleanup_set_null,
Packit 90a5c9
                              apr_pool_cleanup_null);
Packit 90a5c9
Packit 90a5c9
    if (showcompile) { /* deferred due to dynamically loaded MPM */
Packit 90a5c9
        show_compile_settings();
Packit 90a5c9
        destroy_and_exit_process(process, 0);
Packit 90a5c9
    }
Packit 90a5c9
Packit 90a5c9
    /* sort hooks here to make sure pre_config hooks are sorted properly */
Packit 90a5c9
    apr_hook_sort_all();
Packit 90a5c9
Packit 90a5c9
    if (ap_run_pre_config(pconf, plog, ptemp) != OK) {
Packit 90a5c9
        ap_log_error(APLOG_MARK, APLOG_STARTUP |APLOG_ERR, 0,
Packit 90a5c9
                     NULL, APLOGNO(00013) "Pre-configuration failed");
Packit 90a5c9
        destroy_and_exit_process(process, 1);
Packit 90a5c9
    }
Packit 90a5c9
Packit 90a5c9
    rv = ap_process_config_tree(ap_server_conf, ap_conftree,
Packit 90a5c9
                                process->pconf, ptemp);
Packit 90a5c9
    if (rv == OK) {
Packit 90a5c9
        ap_fixup_virtual_hosts(pconf, ap_server_conf);
Packit 90a5c9
        ap_fini_vhost_config(pconf, ap_server_conf);
Packit 90a5c9
        /*
Packit 90a5c9
         * Sort hooks again because ap_process_config_tree may have add modules
Packit 90a5c9
         * and hence hooks. This happens with mod_perl and modules written in
Packit 90a5c9
         * perl.
Packit 90a5c9
         */
Packit 90a5c9
        apr_hook_sort_all();
Packit 90a5c9
Packit 90a5c9
        if (ap_run_check_config(pconf, plog, ptemp, ap_server_conf) != OK) {
Packit 90a5c9
            ap_log_error(APLOG_MARK, APLOG_STARTUP |APLOG_ERR, 0,
Packit 90a5c9
                         NULL, APLOGNO(00014) "Configuration check failed");
Packit 90a5c9
            destroy_and_exit_process(process, 1);
Packit 90a5c9
        }
Packit 90a5c9
Packit 90a5c9
        if (ap_run_mode != AP_SQ_RM_NORMAL) {
Packit 90a5c9
            if (showdirectives) { /* deferred in case of DSOs */
Packit 90a5c9
                ap_show_directives();
Packit 90a5c9
                destroy_and_exit_process(process, 0);
Packit 90a5c9
            }
Packit 90a5c9
            else {
Packit 90a5c9
                ap_run_test_config(pconf, ap_server_conf);
Packit 90a5c9
                if (ap_run_mode == AP_SQ_RM_CONFIG_TEST)
Packit 90a5c9
                    ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, "Syntax OK");
Packit 90a5c9
            }
Packit 90a5c9
            destroy_and_exit_process(process, 0);
Packit 90a5c9
        }
Packit 90a5c9
    }
Packit 90a5c9
Packit 90a5c9
    /* If our config failed, deal with that here. */
Packit 90a5c9
    if (rv != OK) {
Packit 90a5c9
        destroy_and_exit_process(process, 1);
Packit 90a5c9
    }
Packit 90a5c9
Packit 90a5c9
    signal_server = APR_RETRIEVE_OPTIONAL_FN(ap_signal_server);
Packit 90a5c9
    if (signal_server) {
Packit 90a5c9
        int exit_status;
Packit 90a5c9
Packit 90a5c9
        if (signal_server(&exit_status, pconf) != 0) {
Packit 90a5c9
            destroy_and_exit_process(process, exit_status);
Packit 90a5c9
        }
Packit 90a5c9
    }
Packit 90a5c9
Packit 90a5c9
    apr_pool_clear(plog);
Packit 90a5c9
Packit 90a5c9
    if ( ap_run_open_logs(pconf, plog, ptemp, ap_server_conf) != OK) {
Packit 90a5c9
        ap_log_error(APLOG_MARK, APLOG_STARTUP |APLOG_ERR,
Packit 90a5c9
                     0, NULL, APLOGNO(00015) "Unable to open logs");
Packit 90a5c9
        destroy_and_exit_process(process, 1);
Packit 90a5c9
    }
Packit 90a5c9
Packit 90a5c9
    if ( ap_run_post_config(pconf, plog, ptemp, ap_server_conf) != OK) {
Packit 90a5c9
        ap_log_error(APLOG_MARK, APLOG_STARTUP |APLOG_ERR, 0,
Packit 90a5c9
                     NULL, APLOGNO(00016) "Configuration Failed");
Packit 90a5c9
        destroy_and_exit_process(process, 1);
Packit 90a5c9
    }
Packit 90a5c9
Packit 90a5c9
    apr_pool_destroy(ptemp);
Packit 90a5c9
Packit 90a5c9
    do {
Packit 90a5c9
        ap_main_state = AP_SQ_MS_DESTROY_CONFIG;
Packit 90a5c9
        reset_process_pconf(process);
Packit 90a5c9
Packit 90a5c9
        ap_main_state = AP_SQ_MS_CREATE_CONFIG;
Packit 90a5c9
        ap_config_generation++;
Packit 90a5c9
        for (mod = ap_prelinked_modules; *mod != NULL; mod++) {
Packit 90a5c9
            ap_register_hooks(*mod, pconf);
Packit 90a5c9
        }
Packit 90a5c9
Packit 90a5c9
        /* This is a hack until we finish the code so that it only reads
Packit 90a5c9
         * the config file once and just operates on the tree already in
Packit 90a5c9
         * memory.  rbb
Packit 90a5c9
         */
Packit 90a5c9
        ap_conftree = NULL;
Packit 90a5c9
        apr_pool_create(&ptemp, pconf);
Packit 90a5c9
        apr_pool_tag(ptemp, "ptemp");
Packit 90a5c9
        ap_server_root = def_server_root;
Packit 90a5c9
        ap_server_conf = ap_read_config(process, ptemp, confname, &ap_conftree);
Packit 90a5c9
        if (!ap_server_conf) {
Packit 90a5c9
            destroy_and_exit_process(process, 1);
Packit 90a5c9
        }
Packit 90a5c9
        apr_pool_cleanup_register(pconf, &ap_server_conf,
Packit 90a5c9
                                  ap_pool_cleanup_set_null, apr_pool_cleanup_null);
Packit 90a5c9
        /* sort hooks here to make sure pre_config hooks are sorted properly */
Packit 90a5c9
        apr_hook_sort_all();
Packit 90a5c9
Packit 90a5c9
        if (ap_run_pre_config(pconf, plog, ptemp) != OK) {
Packit 90a5c9
            ap_log_error(APLOG_MARK, APLOG_EMERG, 0, NULL,
Packit 90a5c9
                         APLOGNO(00017) "Pre-configuration failed, exiting");
Packit 90a5c9
            destroy_and_exit_process(process, 1);
Packit 90a5c9
        }
Packit 90a5c9
Packit 90a5c9
        if (ap_process_config_tree(ap_server_conf, ap_conftree, process->pconf,
Packit 90a5c9
                                   ptemp) != OK) {
Packit 90a5c9
            destroy_and_exit_process(process, 1);
Packit 90a5c9
        }
Packit 90a5c9
        ap_fixup_virtual_hosts(pconf, ap_server_conf);
Packit 90a5c9
        ap_fini_vhost_config(pconf, ap_server_conf);
Packit 90a5c9
        /*
Packit 90a5c9
         * Sort hooks again because ap_process_config_tree may have add modules
Packit 90a5c9
         * and hence hooks. This happens with mod_perl and modules written in
Packit 90a5c9
         * perl.
Packit 90a5c9
         */
Packit 90a5c9
        apr_hook_sort_all();
Packit 90a5c9
Packit 90a5c9
        if (ap_run_check_config(pconf, plog, ptemp, ap_server_conf) != OK) {
Packit 90a5c9
            ap_log_error(APLOG_MARK, APLOG_EMERG, 0, NULL,
Packit 90a5c9
                         APLOGNO(00018) "Configuration check failed, exiting");
Packit 90a5c9
            destroy_and_exit_process(process, 1);
Packit 90a5c9
        }
Packit 90a5c9
Packit 90a5c9
        apr_pool_clear(plog);
Packit 90a5c9
        if (ap_run_open_logs(pconf, plog, ptemp, ap_server_conf) != OK) {
Packit 90a5c9
            ap_log_error(APLOG_MARK, APLOG_EMERG, 0, NULL,
Packit 90a5c9
                         APLOGNO(00019) "Unable to open logs, exiting");
Packit 90a5c9
            destroy_and_exit_process(process, 1);
Packit 90a5c9
        }
Packit 90a5c9
Packit 90a5c9
        if (ap_run_post_config(pconf, plog, ptemp, ap_server_conf) != OK) {
Packit 90a5c9
            ap_log_error(APLOG_MARK, APLOG_EMERG, 0, NULL,
Packit 90a5c9
                         APLOGNO(00020) "Configuration Failed, exiting");
Packit 90a5c9
            destroy_and_exit_process(process, 1);
Packit 90a5c9
        }
Packit 90a5c9
Packit 90a5c9
        apr_pool_destroy(ptemp);
Packit 90a5c9
        apr_pool_lock(pconf, 1);
Packit 90a5c9
Packit 90a5c9
        ap_run_optional_fn_retrieve();
Packit 90a5c9
Packit 90a5c9
        ap_main_state = AP_SQ_MS_RUN_MPM;
Packit 90a5c9
        rc = ap_run_mpm(pconf, plog, ap_server_conf);
Packit 90a5c9
Packit 90a5c9
        apr_pool_lock(pconf, 0);
Packit 90a5c9
Packit 90a5c9
    } while (rc == OK);
Packit 90a5c9
Packit 90a5c9
    if (rc == DONE) {
Packit 90a5c9
        rc = OK;
Packit 90a5c9
    }
Packit 90a5c9
    else if (rc != OK) {
Packit 90a5c9
        ap_log_error(APLOG_MARK, APLOG_EMERG, 0, NULL, APLOGNO(02818)
Packit 90a5c9
                     "MPM run failed, exiting");
Packit 90a5c9
    }
Packit 90a5c9
    destroy_and_exit_process(process, rc);
Packit 90a5c9
Packit 90a5c9
    /* NOTREACHED */
Packit 90a5c9
    return !OK;
Packit 90a5c9
}
Packit 90a5c9
Packit 90a5c9
#ifdef AP_USING_AUTOCONF
Packit 90a5c9
/* This ugly little hack pulls any function referenced in exports.c into
Packit 90a5c9
 * the web server.  exports.c is generated during the build, and it
Packit 90a5c9
 * has all of the APR functions specified by the apr/apr.exports and
Packit 90a5c9
 * apr-util/aprutil.exports files.
Packit 90a5c9
 */
Packit 90a5c9
const void *ap_suck_in_APR(void);
Packit 90a5c9
const void *ap_suck_in_APR(void)
Packit 90a5c9
{
Packit 90a5c9
    extern const void *ap_ugly_hack;
Packit 90a5c9
Packit 90a5c9
    return ap_ugly_hack;
Packit 90a5c9
}
Packit 90a5c9
#endif