From: Jeff Trawick Date: Fri, 27 Sep 2013 17:52:13 +0000 (+0000) Subject: Error log providers need to be able to trigger a startup error from their X-Git-Tag: 2.5.0-alpha~5003 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=528855d54438913d6f07f839b2322fe24912ee49;p=apache Error log providers need to be able to trigger a startup error from their 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 --- diff --git a/include/http_core.h b/include/http_core.h index 59b584853c..2e635cffa6 100644 --- a/include/http_core.h +++ b/include/http_core.h @@ -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); diff --git a/modules/loggers/mod_syslog.c b/modules/loggers/mod_syslog.c index e04e2d9284..fcea7875a0 100644 --- a/modules/loggers/mod_syslog.c +++ b/modules/loggers/mod_syslog.c @@ -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, diff --git a/server/log.c b/server/log.c index 5f3b4ed984..127ecee0e6 100644 --- a/server/log.c +++ b/server/log.c @@ -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);