]> 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>
Tue, 28 Aug 2007 05:23:46 +0000 (05:23 +0000)
committerWilliam A. Rowe Jr <wrowe@apache.org>
Tue, 28 Aug 2007 05:23:46 +0000 (05:23 +0000)
or apr_pool_create() (when apr-based error reporting is not ready).
[William Rowe, Jeff Trawick]

Backport: 568779, 569934

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

CHANGES
STATUS
server/main.c

diff --git a/CHANGES b/CHANGES
index a9b0518db0d7d9142a0ebf940b15d7b1d2161d03..9c023909c8089f31e3c9823e72625f41f4c333ff 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,10 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache 2.0.61
 
+  *) main core: Emit errors during the initial apr_app_initialize()
+     or apr_pool_create() (when apr-based error reporting is not ready).
+     [William Rowe, Jeff Trawick]
+
   *) log core: Fix issue which could cause piped loggers to be orphaned 
      and never terminate after a graceful restart. PR 40651. [Joe Orton, 
      Ruediger Pluem]
diff --git a/STATUS b/STATUS
index 51f230018f0e4211c66426e4e4a3ee4f99f99343..b467fcf3b41479ed5a2aa41f2f7d5e66aa716ff8 100644 (file)
--- a/STATUS
+++ b/STATUS
@@ -133,17 +133,6 @@ PATCHES PROPOSED TO BACKPORT FROM TRUNK:
          http://svn.apache.org/viewcvs.cgi?rev=102870&view=rev
        +1: wrowe, colm
 
-    * main core: Emit errors during the initial apr_app_initialize()
-      or apr_pool_create() (when apr-based error reporting is not ready).
-      [William Rowe, Jeff Trawick]
-        http://svn.apache.org/viewvc?view=rev&revision=568779
-        http://svn.apache.org/viewvc?view=rev&revision=569934
-      adjusted for 2.0 including both patches;
-        http://people.apache.org/~wrowe/r568779-backport-2.0-r2.patch
-        +1: wrowe
-      r568779-backport-2.0-r2.patch without the Makefile.in:
-        +1: trawick, jim, rpluem
-
     * log core: ensure we use a special pool for stderr logging, so that
       the stderr channel remains valid from the time plog is destroyed,
       until the time the open_logs hook is called again.  [William Rowe]
index 7007ce8c046ffbaa86656e5ef400b2f7921b3cf0..aa356418e85030ea59a8fe70ba5de7793721f1b2 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"
 
@@ -216,20 +217,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];
+        apr_ctime(ctimebuff, apr_time_now());
+        fprintf(stderr, "[%s] [crit] (%d) %s: %s failed "
+                        "to initial context, exiting\n", 
+                        ctimebuff, stat, (*argv)[0], failed);
         apr_terminate();
         exit(1);
     }
@@ -237,14 +247,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_filename_of_pathname(argv[0]);
+    process->argc = *argc;
+    process->argv = *argv;
+    process->short_name = apr_filepath_name_get((*argv)[0]);
     return process;
 }
 
@@ -386,9 +401,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;