]> granicus.if.org Git - apache/blobdiff - server/main.c
the mpm_get_child_pid hook is unnecessary, as was the per-MPM MPM_CHILD_PID() macro...
[apache] / server / main.c
index 451d2e20adbfd2dd63e3bfbfa27b9cef9538c949..b43daf964097835a262518c7b1c259f19cee41a9 100644 (file)
@@ -259,9 +259,19 @@ static void show_compile_settings(void)
 #endif
 }
 
+#define TASK_SWITCH_SLEEP 10000
+
 static void destroy_and_exit_process(process_rec *process,
                                      int process_exit_value)
 {
+    /*
+     * Sleep for TASK_SWITCH_SLEEP micro seconds to cause a task switch on
+     * OS layer and thus give possibly started piped loggers a chance to
+     * process their input. Otherwise it is possible that they get killed
+     * by us before they can do so. In this case maybe valueable log messages
+     * might get lost.
+     */
+    apr_sleep(TASK_SWITCH_SLEEP);
     apr_pool_destroy(process->pool); /* and destroy all descendent pools */
     apr_terminate();
     exit(process_exit_value);
@@ -361,17 +371,12 @@ static void usage(process_rec *process)
                  "       %s [-k install|config|uninstall] [-n service_name]",
                  pad);
 #endif
-#ifdef AP_MPM_WANT_SIGNAL_SERVER
-#ifdef AP_MPM_WANT_SET_GRACEFUL_SHUTDOWN
+/* XXX not all MPMs support signalling the server in general or graceful-stop
+ * in particular
+ */
     ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
                  "       %s [-k start|restart|graceful|graceful-stop|stop]",
                  pad);
-#else
-    ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
-                 "       %s [-k start|restart|graceful|stop]",
-                 pad);
-#endif /* AP_MPM_WANT_SET_GRACEFUL_SHUTDOWN */
-#endif
     ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
                  "       %s [-v] [-V] [-h] [-l] [-L] [-t] [-S]", pad);
     ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL,
@@ -459,14 +464,12 @@ static void usage(process_rec *process)
 int main(int argc, const char * const argv[])
 {
     char c;
-    int configtestonly = 0;
+    int configtestonly = 0, showcompile = 0;
     const char *confname = SERVER_CONFIG_FILE;
     const char *def_server_root = HTTPD_ROOT;
     const char *temp_error_log = NULL;
     const char *error;
     process_rec *process;
-    server_rec *server_conf;
-    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 */
@@ -480,7 +483,7 @@ int main(int argc, const char * const argv[])
     AP_MONCONTROL(0); /* turn off profiling of startup */
 
     process = init_process(&argc, &argv);
-    pglobal = process->pool;
+    ap_pglobal = process->pool;
     pconf = process->pconf;
     ap_server_argv0 = process->short_name;
 
@@ -489,15 +492,15 @@ int main(int argc, const char * const argv[])
     apr_pool_abort_set(abort_on_oom, apr_pool_parent_get(process->pool));
 
 #if APR_CHARSET_EBCDIC
-    if (ap_init_ebcdic(pglobal) != APR_SUCCESS) {
+    if (ap_init_ebcdic(ap_pglobal) != APR_SUCCESS) {
         destroy_and_exit_process(process, 1);
     }
 #endif
-    if (ap_expr_init(pglobal) != APR_SUCCESS) {
+    if (ap_expr_init(ap_pglobal) != APR_SUCCESS) {
         destroy_and_exit_process(process, 1);
     }
 
-    apr_pool_create(&pcommands, pglobal);
+    apr_pool_create(&pcommands, ap_pglobal);
     apr_pool_tag(pcommands, "pcommands");
     ap_server_pre_read_config  = apr_array_make(pcommands, 1, sizeof(char *));
     ap_server_post_read_config = apr_array_make(pcommands, 1, sizeof(char *));
@@ -596,8 +599,14 @@ int main(int argc, const char * const argv[])
             destroy_and_exit_process(process, 0);
 
         case 'V':
-            show_compile_settings();
-            destroy_and_exit_process(process, 0);
+            if (strcmp(ap_show_mpm(), "")) { /* MPM built-in? */
+                show_compile_settings();
+                destroy_and_exit_process(process, 0);
+            }
+            else {
+                showcompile = 1;
+            }
+            break;
 
         case 'l':
             ap_show_modules();
@@ -634,7 +643,7 @@ int main(int argc, const char * const argv[])
         usage(process);
     }
 
-    apr_pool_create(&plog, pglobal);
+    apr_pool_create(&plog, ap_pglobal);
     apr_pool_tag(plog, "plog");
     apr_pool_create(&ptemp, pconf);
     apr_pool_tag(ptemp, "ptemp");
@@ -649,8 +658,8 @@ int main(int argc, const char * const argv[])
     if (temp_error_log) {
         ap_replace_stderr_log(process->pool, temp_error_log);
     }
-    server_conf = ap_read_config(process, ptemp, confname, &ap_conftree);
-    if (!server_conf) {
+    ap_server_conf = ap_read_config(process, ptemp, confname, &ap_conftree);
+    if (!ap_server_conf) {
         destroy_and_exit_process(process, 1);
     }
 
@@ -660,24 +669,28 @@ int main(int argc, const char * const argv[])
         destroy_and_exit_process(process, 1);
     }
 
-    rv = ap_process_config_tree(server_conf, ap_conftree,
+    rv = ap_process_config_tree(ap_server_conf, ap_conftree,
                                 process->pconf, ptemp);
     if (rv == OK) {
-        ap_fixup_virtual_hosts(pconf, server_conf);
-        ap_fini_vhost_config(pconf, server_conf);
+        ap_fixup_virtual_hosts(pconf, ap_server_conf);
+        ap_fini_vhost_config(pconf, ap_server_conf);
         apr_hook_sort_all();
 
-        if (ap_run_check_config(pconf, plog, ptemp, server_conf) != OK) {
+        if (ap_run_check_config(pconf, plog, ptemp, ap_server_conf) != OK) {
             ap_log_error(APLOG_MARK, APLOG_STARTUP |APLOG_ERR, 0,
                          NULL, "Configuration check failed");
             destroy_and_exit_process(process, 1);
         }
 
         if (configtestonly) {
-            ap_run_test_config(pconf, server_conf);
+            ap_run_test_config(pconf, ap_server_conf);
             ap_log_error(APLOG_MARK, APLOG_STARTUP, 0, NULL, "Syntax OK");
             destroy_and_exit_process(process, 0);
         }
+        else if (showcompile) { /* deferred due to dynamically loaded MPM */
+            show_compile_settings();
+            destroy_and_exit_process(process, 0);
+        }
     }
 
     signal_server = APR_RETRIEVE_OPTIONAL_FN(ap_signal_server);
@@ -696,13 +709,13 @@ int main(int argc, const char * const argv[])
 
     apr_pool_clear(plog);
 
-    if ( ap_run_open_logs(pconf, plog, ptemp, server_conf) != OK) {
+    if ( ap_run_open_logs(pconf, plog, ptemp, ap_server_conf) != OK) {
         ap_log_error(APLOG_MARK, APLOG_STARTUP |APLOG_ERR,
                      0, NULL, "Unable to open logs");
         destroy_and_exit_process(process, 1);
     }
 
-    if ( ap_run_post_config(pconf, plog, ptemp, server_conf) != OK) {
+    if ( ap_run_post_config(pconf, plog, ptemp, ap_server_conf) != OK) {
         ap_log_error(APLOG_MARK, APLOG_STARTUP |APLOG_ERR, 0,
                      NULL, "Configuration Failed");
         destroy_and_exit_process(process, 1);
@@ -727,8 +740,8 @@ int main(int argc, const char * const argv[])
         apr_pool_create(&ptemp, pconf);
         apr_pool_tag(ptemp, "ptemp");
         ap_server_root = def_server_root;
-        server_conf = ap_read_config(process, ptemp, confname, &ap_conftree);
-        if (!server_conf) {
+        ap_server_conf = ap_read_config(process, ptemp, confname, &ap_conftree);
+        if (!ap_server_conf) {
             destroy_and_exit_process(process, 1);
         }
 
@@ -738,28 +751,28 @@ int main(int argc, const char * const argv[])
             destroy_and_exit_process(process, 1);
         }
 
-        if (ap_process_config_tree(server_conf, ap_conftree, process->pconf,
+        if (ap_process_config_tree(ap_server_conf, ap_conftree, process->pconf,
                                    ptemp) != OK) {
             destroy_and_exit_process(process, 1);
         }
-        ap_fixup_virtual_hosts(pconf, server_conf);
-        ap_fini_vhost_config(pconf, server_conf);
+        ap_fixup_virtual_hosts(pconf, ap_server_conf);
+        ap_fini_vhost_config(pconf, ap_server_conf);
         apr_hook_sort_all();
 
-        if (ap_run_check_config(pconf, plog, ptemp, server_conf) != OK) {
+        if (ap_run_check_config(pconf, plog, ptemp, ap_server_conf) != OK) {
             ap_log_error(APLOG_MARK, APLOG_STARTUP |APLOG_ERR, 0,
                          NULL, "Configuration check failed");
             destroy_and_exit_process(process, 1);
         }
 
         apr_pool_clear(plog);
-        if (ap_run_open_logs(pconf, plog, ptemp, server_conf) != OK) {
+        if (ap_run_open_logs(pconf, plog, ptemp, ap_server_conf) != OK) {
             ap_log_error(APLOG_MARK, APLOG_STARTUP |APLOG_ERR,
                          0, NULL, "Unable to open logs");
             destroy_and_exit_process(process, 1);
         }
 
-        if (ap_run_post_config(pconf, plog, ptemp, server_conf) != OK) {
+        if (ap_run_post_config(pconf, plog, ptemp, ap_server_conf) != OK) {
             ap_log_error(APLOG_MARK, APLOG_STARTUP |APLOG_ERR,
                          0, NULL, "Configuration Failed");
             destroy_and_exit_process(process, 1);
@@ -770,7 +783,7 @@ int main(int argc, const char * const argv[])
 
         ap_run_optional_fn_retrieve();
 
-        if (ap_mpm_run(pconf, plog, server_conf))
+        if (ap_mpm_run(pconf, plog, ap_server_conf))
             break;
 
         apr_pool_lock(pconf, 0);
@@ -788,8 +801,8 @@ int main(int argc, const char * const argv[])
  * has all of the APR functions specified by the apr/apr.exports and
  * apr-util/aprutil.exports files.
  */
-const void *suck_in_APR(void);
-const void *suck_in_APR(void)
+const void *ap_suck_in_APR(void);
+const void *ap_suck_in_APR(void)
 {
     extern const void *ap_ugly_hack;