]> granicus.if.org Git - apache/commitdiff
Error log providers need to be able to trigger a startup error from their
authorJeff Trawick <trawick@apache.org>
Fri, 27 Sep 2013 17:52:13 +0000 (17:52 +0000)
committerJeff Trawick <trawick@apache.org>
Fri, 27 Sep 2013 17:52:13 +0000 (17:52 +0000)
init() function.  A NULL return code is the trigger.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1527003 13f79535-47bb-0310-9956-ffa450edef68

include/http_core.h
modules/loggers/mod_syslog.c
server/log.c

index 59b584853cc9a73a75b9965d432f8b010c6c18d4..2e635cffa6a2b1d7d82c214e6154dd235959df99 100644 (file)
@@ -856,6 +856,10 @@ struct ap_errorlog_provider {
      * @param p The pool to create any storage from
      * @param s Server for which the logger is initialized
      * @return Pointer to handle passed later to writer() function
+     * @note On success, the provider must return non-NULL, even if
+     * the handle is not necessary when the writer() function is
+     * called.  On failure, the provider should log a startup error
+     * message and return NULL to abort httpd startup.
      */
     void * (*init)(apr_pool_t *p, server_rec *s);
 
index e04e2d928434ddcbde5f92bf19f760f91404805b..fcea7875a01f2ab26e6944b274f7b1f9a7ea10d4 100644 (file)
@@ -107,6 +107,8 @@ static const TRANS facilities[] = {
 static void *syslog_error_log_init(apr_pool_t *p, server_rec *s)
 {
     char *fname = s->error_fname;
+    void *success = (void *)p; /* anything non-NULL is success */
+
     if (*fname == '\0') {
         openlog(ap_server_argv0, LOG_NDELAY|LOG_CONS|LOG_PID, LOG_LOCAL7);
     }
@@ -117,12 +119,12 @@ static void *syslog_error_log_init(apr_pool_t *p, server_rec *s)
             if (!strcasecmp(fname, fac->t_name)) {
                 openlog(ap_server_argv0, LOG_NDELAY|LOG_CONS|LOG_PID,
                         fac->t_val);
-                return NULL;
+                return success;
             }
         }
     }
 
-    return NULL;
+    return success;
 }
 
 static apr_status_t syslog_error_log(const ap_errorlog_info *info,
index 5f3b4ed98463f0ddd56f12c9688aa145ee702f38..127ecee0e6507db45675090d28b43d0845638dc3 100644 (file)
@@ -334,6 +334,10 @@ static int open_error_log(server_rec *s, int is_main, apr_pool_t *p)
     else if (s->errorlog_provider) {
         s->errorlog_provider_handle = s->errorlog_provider->init(p, s);
         s->error_log = NULL;
+        if (!s->errorlog_provider_handle) {
+            /* provider must log something to the console */
+            return DONE;
+        }
     }
     else {
         fname = ap_server_root_relative(p, s->error_fname);