]> granicus.if.org Git - apache/blobdiff - server/main.c
Fix default Timeout & KeepaliveTimeout. Still need to limit directive
[apache] / server / main.c
index d9b626380ba8ee4b1b285567ede7f93ebc145569..47df11db6eadfbc5f404ce6a182b65286dc6131b 100644 (file)
 #include "http_main.h" 
 #include "http_log.h" 
 #include "http_config.h"
+#include "http_vhost.h"
 #include "util_uri.h" 
 #include "util_ebcdic.h"
+#include "apr_strings.h"
 #include "apr_getopt.h"
 #include "ap_mpm.h"
 
@@ -87,23 +89,17 @@ static void show_compile_settings(void)
 #ifdef SECURITY_HOLE_PASS_AUTHORIZATION
     printf(" -D SECURITY_HOLE_PASS_AUTHORIZATION\n");
 #endif
-#ifdef HAVE_MMAP
+#ifdef APR_HAS_MMAP
     printf(" -D HAVE_MMAP\n");
 #endif
 #ifdef HAVE_SHMGET
     printf(" -D HAVE_SHMGET\n");
 #endif
-#ifdef USE_MMAP_SCOREBOARD
-    printf(" -D USE_MMAP_SCOREBOARD\n");
+#ifdef USE_FILE_BASED_SCOREBOARD
+    printf(" -D USE_FILE_BASED_SCOREBOARD\n");
 #endif
-#ifdef USE_SHMGET_SCOREBOARD
-    printf(" -D USE_SHMGET_SCOREBOARD\n");
-#endif
-#ifdef USE_OS2_SCOREBOARD
-    printf(" -D USE_OS2_SCOREBOARD\n");
-#endif
-#ifdef USE_POSIX_SCOREBOARD
-    printf(" -D USE_POSIX_SCOREBOARD\n");
+#ifdef USE_MEM_BASED_SCOREBOARD
+    printf(" -D USE_MEM_BASED_SCOREBOARD\n");
 #endif
 #ifdef USE_MMAP_FILES
     printf(" -D USE_MMAP_FILES\n");
@@ -117,25 +113,25 @@ static void show_compile_settings(void)
 #ifdef NO_LINGCLOSE
     printf(" -D NO_LINGCLOSE\n");
 #endif
-#ifdef USE_FCNTL_SERIALIZED_ACCEPT
-    printf(" -D USE_FCNTL_SERIALIZED_ACCEPT\n");
+#if APR_USE_FLOCK_SERIALIZE
+    printf(" -D APR_USE_FLOCK_SERIALIZE\n");
 #endif
-#ifdef USE_FLOCK_SERIALIZED_ACCEPT
-    printf(" -D USE_FLOCK_SERIALIZED_ACCEPT\n");
+#if APR_USE_SYSVSEM_SERIALIZE
+    printf(" -D APR_USE_SYSVSEM_SERIALIZE\n");
 #endif
-#ifdef USE_USLOCK_SERIALIZED_ACCEPT
-    printf(" -D USE_USLOCK_SERIALIZED_ACCEPT\n");
+#if APR_USE_FCNTL_SERIALIZE
+    printf(" -D APR_USE_FCNTL_SERIALIZE\n");
 #endif
-#ifdef USE_SYSVSEM_SERIALIZED_ACCEPT
-    printf(" -D USE_SYSVSEM_SERIALIZED_ACCEPT\n");
+#if APR_USE_PROC_PTHREAD_SERIALIZE
+    printf(" -D APR_USE_PROC_PTHREAD_SERIALIZE\n");
 #endif
-#ifdef USE_PTHREAD_SERIALIZED_ACCEPT
-    printf(" -D USE_PTHREAD_SERIALIZED_ACCEPT\n");
+#if APR_USE_PTHREAD_SERIALIZE
+    printf(" -D APR_USE_PTHREAD_SERIALIZE\n");
 #endif
 #ifdef SINGLE_LISTEN_UNSERIALIZED_ACCEPT
     printf(" -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT\n");
 #endif
-#ifdef APR_HAS_OTHER_CHILD
+#if APR_HAS_OTHER_CHILD
     printf(" -D APR_HAS_OTHER_CHILD\n");
 #endif
 #ifdef HAVE_RELIABLE_PIPED_LOGS
@@ -195,35 +191,35 @@ static void show_compile_settings(void)
 
 static void destroy_and_exit_process(process_rec *process, int process_exit_value)
 {
-    ap_destroy_pool(process->pool); /* and destroy all descendent pools */
-    ap_terminate();
+    apr_destroy_pool(process->pool); /* and destroy all descendent pools */
+    apr_terminate();
     exit(process_exit_value);
 }
 
-static process_rec *create_process(int argc, const char **argv)
+static process_rec *create_process(int argc, char *const *argv)
 {
     process_rec *process;
     
     {
-       ap_pool_t *cntx;
-        ap_status_t stat;
+       apr_pool_t *cntx;
+        apr_status_t stat;
 
-       stat = ap_create_pool(&cntx, NULL);
+       stat = apr_create_pool(&cntx, NULL);
         if (stat != APR_SUCCESS) {
             ap_log_error(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO, 0, NULL,
-                         "ap_create_pool() failed to create "
+                         "apr_create_pool() failed to create "
                          "initial context");
-            ap_terminate();
+            apr_terminate();
             exit(1);
         }
 
-       process = ap_palloc(cntx, sizeof(process_rec));
+       process = apr_palloc(cntx, sizeof(process_rec));
        process->pool = cntx;
     }
-    ap_create_pool(&process->pconf, process->pool);
+    apr_create_pool(&process->pconf, process->pool);
     process->argc = argc;
     process->argv = argv;
-    process->short_name = ap_filename_of_pathname(argv[0]);
+    process->short_name = apr_filename_of_pathname(argv[0]);
     return process;
 }
 
@@ -278,29 +274,26 @@ static void usage(process_rec *process)
     destroy_and_exit_process(process, 1);
 }
 
-#ifdef WIN32
-int apache_main(int argc, char *argv[])
-#else
-API_EXPORT(int)        main(int argc, char *argv[])
-#endif
+int main(int argc, char *argv[])
 {
-    int c;
+    char c;
     int configtestonly = 0;
     const char *confname = SERVER_CONFIG_FILE;
     const char *def_server_root = HTTPD_ROOT;
     process_rec *process;
     server_rec *server_conf;
-    ap_pool_t *pglobal;
-    ap_pool_t *pconf;
-    ap_pool_t *plog; /* Pool of log streams, reset _after_ each read of conf */
-    ap_pool_t *ptemp; /* Pool for temporary config stuff, reset often */
-    ap_pool_t *pcommands; /* Pool for -D, -C and -c switches */
+    apr_pool_t *pglobal;
+    apr_pool_t *pconf;
+    apr_pool_t *plog; /* Pool of log streams, reset _after_ each read of conf */
+    apr_pool_t *ptemp; /* Pool for temporary config stuff, reset often */
+    apr_pool_t *pcommands; /* Pool for -D, -C and -c switches */
+    apr_getopt_t *opt;
     module **mod;
+    ap_directive_t *conftree = NULL;
+    const char *optarg;
 
-#ifndef WIN32 /* done in main_win32.c */
-    ap_initialize();
-#endif
-    process = create_process(argc, (const char **)argv);
+    apr_initialize();
+    process = create_process(argc, argv);
     pglobal = process->pool;
     pconf = process->pconf;
     ap_server_argv0 = process->short_name;
@@ -315,37 +308,39 @@ API_EXPORT(int)        main(int argc, char *argv[])
 
     ap_setup_prelinked_modules(process);
 
-    ap_create_pool(&pcommands, pglobal);
-    ap_server_pre_read_config  = ap_make_array(pcommands, 1, sizeof(char *));
-    ap_server_post_read_config = ap_make_array(pcommands, 1, sizeof(char *));
-    ap_server_config_defines   = ap_make_array(pcommands, 1, sizeof(char *));
+    apr_create_pool(&pcommands, pglobal);
+    ap_server_pre_read_config  = apr_make_array(pcommands, 1, sizeof(char *));
+    ap_server_post_read_config = apr_make_array(pcommands, 1, sizeof(char *));
+    ap_server_config_defines   = apr_make_array(pcommands, 1, sizeof(char *));
 
     ap_run_rewrite_args(process);
 
     /* Maintain AP_SERVER_BASEARGS list in http_main.h to allow the MPM 
      * to safely pass on our args from its rewrite_args() handler.
      */
-    while (ap_getopt(argc, argv, AP_SERVER_BASEARGS, &c, pcommands) 
+    apr_initopt(&opt, pcommands, process->argc, process->argv);
+
+    while (apr_getopt(opt, AP_SERVER_BASEARGS, &c, &optarg) 
             == APR_SUCCESS) {
         char **new;
         switch (c) {
        case 'c':
-           new = (char **)ap_push_array(ap_server_post_read_config);
-           *new = ap_pstrdup(pcommands, ap_optarg);
+           new = (char **)apr_push_array(ap_server_post_read_config);
+           *new = apr_pstrdup(pcommands, optarg);
            break;
        case 'C':
-           new = (char **)ap_push_array(ap_server_pre_read_config);
-           *new = ap_pstrdup(pcommands, ap_optarg);
+           new = (char **)apr_push_array(ap_server_pre_read_config);
+           *new = apr_pstrdup(pcommands, optarg);
            break;
        case 'd':
-           def_server_root = ap_optarg;
+           def_server_root = optarg;
            break;
        case 'D':
-           new = (char **)ap_push_array(ap_server_config_defines);
-           *new = ap_pstrdup(pcommands, ap_optarg);
+           new = (char **)apr_push_array(ap_server_config_defines);
+           *new = apr_pstrdup(pcommands, optarg);
            break;
        case 'f':
-           confname = ap_optarg;
+           confname = optarg;
            break;
        case 'v':
            printf("Server version: %s\n", ap_get_server_version());
@@ -369,8 +364,8 @@ API_EXPORT(int)        main(int argc, char *argv[])
        }
     }
 
-    ap_create_pool(&plog, pglobal);
-    ap_create_pool(&ptemp, pconf);
+    apr_create_pool(&plog, pglobal);
+    apr_create_pool(&ptemp, pconf);
 
     /* Note that we preflight the config file once
        before reading it _again_ in the main loop.
@@ -378,31 +373,44 @@ API_EXPORT(int)        main(int argc, char *argv[])
        for example, to settle down. */
 
     ap_server_root = def_server_root;
+    server_conf = ap_read_config(process, ptemp, confname, &conftree);
     ap_run_pre_config(pconf, plog, ptemp);
-    server_conf = ap_read_config(process, ptemp, confname);
+    ap_process_config_tree(server_conf, conftree, process->pconf, ptemp); 
+    ap_fixup_virtual_hosts(pconf, server_conf);
+    ap_fini_vhost_config(pconf, server_conf);
+    ap_sort_hooks();
     if (configtestonly) {
        ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, "Syntax OK\n");
        destroy_and_exit_process(process, 0);
     }
-    ap_clear_pool(plog);
+    apr_clear_pool(plog);
     ap_run_open_logs(pconf, plog, ptemp, server_conf);
     ap_post_config_hook(pconf, plog, ptemp, server_conf);
-    ap_destroy_pool(ptemp);
+    apr_destroy_pool(ptemp);
 
     for (;;) {
        ap_hook_deregister_all();
-       ap_clear_pool(pconf);
+       apr_clear_pool(pconf);
        for (mod = ap_prelinked_modules; *mod != NULL; mod++) {
                ap_register_hooks(*mod);
        }
-       ap_create_pool(&ptemp, pconf);
+        /* This is a hack until we finish the code so that it only reads
+         * the config file once and just operates on the tree already in
+         * memory.  rbb
+         */
+        conftree = NULL;
+       apr_create_pool(&ptemp, pconf);
        ap_server_root = def_server_root;
+        server_conf = ap_read_config(process, ptemp, confname, &conftree);
        ap_run_pre_config(pconf, plog, ptemp);
-       server_conf = ap_read_config(process, ptemp, confname);
-       ap_clear_pool(plog);
+        ap_process_config_tree(server_conf, conftree, process->pconf, ptemp); 
+        ap_fixup_virtual_hosts(pconf, server_conf);
+        ap_fini_vhost_config(pconf, server_conf);
+        ap_sort_hooks();
+       apr_clear_pool(plog);
        ap_run_open_logs(pconf, plog, ptemp, server_conf);
        ap_post_config_hook(pconf, plog, ptemp, server_conf);
-       ap_destroy_pool(ptemp);
+       apr_destroy_pool(ptemp);
 
        if (ap_mpm_run(pconf, plog, server_conf)) break;
     }
@@ -422,13 +430,13 @@ const XML_LChar *suck_in_expat(void)
 
 #ifndef SHARED_CORE_BOOTSTRAP
 /*
- * Force ap_validate_password() into the image so that modules like
+ * Force apr_validate_password() into the image so that modules like
  * mod_auth can use it even if they're dynamically loaded.
  */
-void suck_in_ap_validate_password(void);
-void suck_in_ap_validate_password(void)
+void suck_in_apr_validate_password(void);
+void suck_in_apr_validate_password(void)
 {
-    ap_validate_password("a", "b");
+    apr_validate_password("a", "b");
 }
 #endif