You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by tr...@apache.org on 2013/09/27 19:52:13 UTC

svn commit: r1527003 - in /httpd/httpd/trunk: include/http_core.h modules/loggers/mod_syslog.c server/log.c

Author: trawick
Date: Fri Sep 27 17:52:13 2013
New Revision: 1527003

URL: http://svn.apache.org/r1527003
Log:
Error log providers need to be able to trigger a startup error from their
init() function.  A NULL return code is the trigger.

Modified:
    httpd/httpd/trunk/include/http_core.h
    httpd/httpd/trunk/modules/loggers/mod_syslog.c
    httpd/httpd/trunk/server/log.c

Modified: httpd/httpd/trunk/include/http_core.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/http_core.h?rev=1527003&r1=1527002&r2=1527003&view=diff
==============================================================================
--- httpd/httpd/trunk/include/http_core.h (original)
+++ httpd/httpd/trunk/include/http_core.h Fri Sep 27 17:52:13 2013
@@ -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);
 

Modified: httpd/httpd/trunk/modules/loggers/mod_syslog.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/loggers/mod_syslog.c?rev=1527003&r1=1527002&r2=1527003&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/loggers/mod_syslog.c (original)
+++ httpd/httpd/trunk/modules/loggers/mod_syslog.c Fri Sep 27 17:52:13 2013
@@ -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_p
             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,

Modified: httpd/httpd/trunk/server/log.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/log.c?rev=1527003&r1=1527002&r2=1527003&view=diff
==============================================================================
--- httpd/httpd/trunk/server/log.c (original)
+++ httpd/httpd/trunk/server/log.c Fri Sep 27 17:52:13 2013
@@ -334,6 +334,10 @@ static int open_error_log(server_rec *s,
     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);