]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
main core: Emit errors during the initial apr_app_initialize()
authorWilliam A. Rowe Jr <wrowe@apache.org>
Fri, 24 Aug 2007 22:07:07 +0000 (22:07 +0000)
committerWilliam A. Rowe Jr <wrowe@apache.org>
Fri, 24 Aug 2007 22:07:07 +0000 (22:07 +0000)
or apr_pool_create() (when apr-based error reporting is not ready).

Backport: r568779

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.2.x@569543 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
STATUS
server/main.c

diff --git a/CHANGES b/CHANGES
index 1194b5f6f344095d05a30a469bfeebe4a0c2f4c4..62f5a56673608bc7866e044c8f51bbacd620cc84 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,10 @@
                                                         -*- coding: utf-8 -*-
 Changes with Apache 2.2.6
 
+  *) main core: Emit errors during the initial apr_app_initialize()
+     or apr_pool_create() (when apr-based error reporting is not ready).
+     [William Rowe]
+
   *) log core: fix the new piped logger case where we couldn't connect 
      the replacement stderr logger's stderr to the NULL stdout stream.  
      Continue in this case, since the previous alternative of no error 
diff --git a/STATUS b/STATUS
index dd413334ace0db3830c1bf1c3b8d4be12b023bb0..b85b40a48d014609d65ed2733a42d073a9385c59 100644 (file)
--- a/STATUS
+++ b/STATUS
@@ -290,11 +290,6 @@ PATCHES PROPOSED TO BACKPORT FROM TRUNK:
       http://svn.apache.org/viewvc?view=rev&revision=565671
       +1: niq
  
-    * main core: Emit errors during the initial apr_app_initialize()
-      or apr_pool_create() (when apr-based error reporting is not ready).
-        http://svn.apache.org/viewvc?view=rev&revision=568779
-        +1: wrowe, rpluem, jim
-
 
 PATCHES/ISSUES THAT ARE STALLED
 
index 29557f23748e1cf1634dbe04e6c08e17078de05a..f41fcb9baaf4cb052e088d7855ff5891d95d4014 100644 (file)
@@ -20,6 +20,7 @@
 #include "apr_general.h"
 #include "apr_lib.h"
 #include "apr_md5.h"
+#include "apr_time.h"
 #include "apr_version.h"
 #include "apu_version.h"
 
@@ -261,20 +262,29 @@ static void destroy_and_exit_process(process_rec *process,
     exit(process_exit_value);
 }
 
-static process_rec *create_process(int argc, const char * const *argv)
+static process_rec *init_process(int *argc, const char * const * *argv)
 {
     process_rec *process;
     apr_pool_t *cntx;
     apr_status_t stat;
+    const char *failed = "apr_app_initialize()";
+    stat = apr_app_initialize(argc, argv, NULL);
+    if (stat == APR_SUCCESS) {
+        failed = "apr_pool_create()";
+        stat = apr_pool_create(&cntx, NULL);
+    }
 
-    stat = apr_pool_create(&cntx, NULL);
     if (stat != APR_SUCCESS) {
-        /* XXX From the time that we took away the NULL pool->malloc mapping
-         *     we have been unable to log here without segfaulting.
+        /* For all intents and purposes, this is impossibly unlikely,
+         * but APR doesn't exist yet, we can't use it for reporting
+         * these earliest two failures;
          */
-        ap_log_error(APLOG_MARK, APLOG_ERR, stat, NULL,
-                     "apr_pool_create() failed to create "
-                     "initial context");
+        char ctimebuff[APR_CTIME_LEN + 1];
+        apr_ctime(ctimebuff, apr_time_now());
+        ctimebuff[APR_CTIME_LEN] = '\0';
+        fprintf(stderr, "[%s] [crit] (%d) %s: %s failed "
+                        "to initial context, exiting", 
+                        ctimebuff, stat, (*argv)[0], failed);
         apr_terminate();
         exit(1);
     }
@@ -282,14 +292,19 @@ static process_rec *create_process(int argc, const char * const *argv)
     apr_pool_tag(cntx, "process");
     ap_open_stderr_log(cntx);
 
+    /* Now we have initialized apr and our logger, no more
+     * exceptional error reporting required for the lifetime
+     * of this server process.
+     */
+
     process = apr_palloc(cntx, sizeof(process_rec));
     process->pool = cntx;
 
     apr_pool_create(&process->pconf, process->pool);
     apr_pool_tag(process->pconf, "pconf");
-    process->argc = argc;
-    process->argv = argv;
-    process->short_name = apr_filepath_name_get(argv[0]);
+    process->argc = *argc;
+    process->argv = *argv;
+    process->short_name = apr_filepath_name_get((*argv)[0]);
     return process;
 }
 
@@ -442,9 +457,7 @@ int main(int argc, const char * const argv[])
 
     AP_MONCONTROL(0); /* turn off profiling of startup */
 
-    apr_app_initialize(&argc, &argv, NULL);
-
-    process = create_process(argc, argv);
+    process = init_process(&argc, &argv);
     pglobal = process->pool;
     pconf = process->pconf;
     ap_server_argv0 = process->short_name;