/**
* Open the error log and replace stderr with it.
+ * @param pconf Not used
+ * @param plog The pool to allocate the logs from
+ * @param ptemp Pool used for temporary allocations
* @param s_main The main server
- * @param p The pool to allocate out of
+ * @tip ap_open_logs isn't expected to be used by modules, it is
+ * an internal core function
*/
-void ap_open_logs (server_rec *s_main, apr_pool_t *p);
+int ap_open_logs(apr_pool_t *pconf, apr_pool_t *plog,
+ apr_pool_t *ptemp, server_rec *s_main);
/*
* The three primary logging functions, ap_log_error, ap_log_rerror, and
return OK;
}
-static int core_open_logs(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp, server_rec *s)
-{
- ap_open_logs(s, plog);
- return OK;
-}
-
static void core_insert_filter(request_rec *r)
{
core_dir_config *conf = (core_dir_config *)
ap_hook_post_config(core_post_config,NULL,NULL,APR_HOOK_REALLY_FIRST);
ap_hook_translate_name(ap_core_translate,NULL,NULL,APR_HOOK_REALLY_LAST);
ap_hook_map_to_storage(core_map_to_storage,NULL,NULL,APR_HOOK_REALLY_LAST);
- ap_hook_open_logs(core_open_logs,NULL,NULL,APR_HOOK_MIDDLE);
+ ap_hook_open_logs(ap_open_logs,NULL,NULL,APR_HOOK_REALLY_FIRST);
ap_hook_handler(default_handler,NULL,NULL,APR_HOOK_REALLY_LAST);
/* FIXME: I suspect we can eliminate the need for these do_nothings - Ben */
ap_hook_type_checker(do_nothing,NULL,NULL,APR_HOOK_REALLY_LAST);
ap_log_error(APLOG_MARK, APLOG_STARTUP|APLOG_CRIT,
APR_EBADPATH, NULL, "Invalid -E error log file %s",
fname);
- exit(1);
+ return APR_EBADPATH;
}
if ((rc = apr_file_open(&stderr_file, filename,
APR_APPEND | APR_READ | APR_WRITE | APR_CREATE,
return rc;
}
-static void open_error_log(server_rec *s, apr_pool_t *p)
+static int open_error_log(server_rec *s, apr_pool_t *p)
{
const char *fname;
int rc;
if (rc != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_STARTUP, rc, NULL,
"Couldn't start ErrorLog process");
- exit(1);
+ return DONE;
}
s->error_log = dummy;
openlog(ap_server_argv0, LOG_NDELAY|LOG_CONS|LOG_PID,
fac->t_val);
s->error_log = NULL;
- return;
+ return OK;
}
}
}
ap_log_error(APLOG_MARK, APLOG_STARTUP, APR_EBADPATH, NULL,
"%s: Invalid error log path %s.",
ap_server_argv0, s->error_fname);
- exit(1);
+ return DONE;
}
if ((rc = apr_file_open(&s->error_log, fname,
APR_APPEND | APR_READ | APR_WRITE | APR_CREATE,
ap_log_error(APLOG_MARK, APLOG_STARTUP, rc, NULL,
"%s: could not open error log file %s.",
ap_server_argv0, fname);
- exit(1);
+ return DONE;
}
apr_file_inherit_set(s->error_log);
}
+
+ return OK;
}
-void ap_open_logs(server_rec *s_main, apr_pool_t *p)
+int ap_open_logs(apr_pool_t *pconf, apr_pool_t *p /* plog */,
+ apr_pool_t *ptemp, server_rec *s_main)
{
apr_status_t rc = APR_SUCCESS;
server_rec *virt, *q;
int replace_stderr;
apr_file_t *errfile = NULL;
- open_error_log(s_main, p);
+ if (open_error_log(s_main, p) != OK) {
+ return DONE;
+ }
replace_stderr = 1;
if (s_main->error_log) {
}
if (q == virt) {
- open_error_log(virt, p);
+ if (open_error_log(virt, p) != OK) {
+ return DONE;
+ }
}
else {
virt->error_log = q->error_log;
virt->error_log = s_main->error_log;
}
}
+ return OK;
}
AP_DECLARE(void) ap_error_log2stderr(server_rec *s) {
if (rc != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_STARTUP, rc, NULL,
"Couldn't start piped log process");
- exit (1);
+ return NULL;
}
pl = apr_palloc(p, sizeof (*pl));