-*- coding: utf-8 -*-
Changes with Apache 2.0.61
+ *) 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]
+
+ *) log core: fix the new piped logger case where we couldn't connect
+ the replacement stderr logger's stderr to the NULL stdout stream.
+ Continue in this case, since the previous alternative of no error
+ logging at all (/dev/null) is far worse. [William Rowe]
+
*) mpm_winnt: Prevent the parent-child pipe from leaking into other
spawned processes, and ensure we have a /Device/null handle for
stdout when running as-a-service. [William Rowe]
http://svn.apache.org/viewcvs.cgi?rev=102870&view=rev
+1: wrowe, colm
- * 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]
- http://svn.apache.org/viewvc?view=rev&revision=452431
- log core: fix the new piped logger case where we couldn't connect
- the replacement stderr logger's stderr to the NULL stdout stream.
- Continue in this case, since the previous alternative of no error
- logging at all (/dev/null) is far worse. [William Rowe]
- http://svn.apache.org/viewvc?view=rev&revision=568326
- r452431 plus r568326; adjusted for 2.0 (note second iteration!);
- http://people.apache.org/~wrowe/r568326-backport-2.0-r2.patch
- disambiguate an error message to diagnose future error reports
- http://svn.apache.org/viewvc?view=rev&revision=568322
- +1: wrowe
- rpluem says: +1 once r568446 is backported.
- jim: agree with rpluem
-
* 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]
}
static int log_child(apr_pool_t *p, const char *progname,
- apr_file_t **fpin)
+ apr_file_t **fpin, int dummy_stderr)
{
/* Child process code for 'ErrorLog "|..."';
* may want a common framework for this, since I expect it will
apr_status_t rc;
apr_procattr_t *procattr;
apr_proc_t *procnew;
+ apr_file_t *errfile;
if (((rc = apr_procattr_create(&procattr, p)) == APR_SUCCESS)
&& ((rc = apr_procattr_io_set(procattr,
APR_NO_PIPE,
APR_NO_PIPE)) == APR_SUCCESS)
&& ((rc = apr_procattr_error_check_set(procattr, 1)) == APR_SUCCESS)
- && ((rc = apr_procattr_child_errfn_set(procattr, log_child_errfn)) == APR_SUCCESS)) {
+ && ((rc = apr_procattr_child_errfn_set(procattr, log_child_errfn))
+ == APR_SUCCESS)) {
char **args;
const char *pname;
apr_tokenize_to_argv(progname, &args, p);
pname = apr_pstrdup(p, args[0]);
procnew = (apr_proc_t *)apr_pcalloc(p, sizeof(*procnew));
+
+ if (dummy_stderr) {
+ if ((rc = apr_file_open_stdout(&errfile, p)) == APR_SUCCESS)
+ rc = apr_procattr_child_err_set(procattr, errfile, NULL);
+ }
+
rc = apr_proc_create(procnew, pname, (const char * const *)args,
NULL, procattr, p);
return rc;
}
-static int open_error_log(server_rec *s, apr_pool_t *p)
+static int open_error_log(server_rec *s, int is_main, apr_pool_t *p)
{
const char *fname;
int rc;
if (*s->error_fname == '|') {
apr_file_t *dummy = NULL;
- /* This starts a new process... */
- rc = log_child (p, s->error_fname + 1, &dummy);
+ /* Spawn a new child logger. If this is the main server_rec,
+ * the new child must use a dummy stderr since the current
+ * stderr might be a pipe to the old logger. Otherwise, the
+ * child inherits the parents stderr. */
+ rc = log_child(p, s->error_fname + 1, &dummy, is_main);
if (rc != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_STARTUP, rc, NULL,
"Couldn't start ErrorLog process");
apr_pool_cleanup_register(p, NULL, clear_handle_list,
apr_pool_cleanup_null);
- if (open_error_log(s_main, p) != OK) {
+ if (open_error_log(s_main, 1, p) != OK) {
return DONE;
}
}
if (q == virt) {
- if (open_error_log(virt, p) != OK) {
+ if (open_error_log(virt, 0, p) != OK) {
return DONE;
}
}
apr_file_t *dummy = NULL;
int rc;
- rc = log_child(p, program, &dummy);
+ rc = log_child(p, program, &dummy, 0);
if (rc != APR_SUCCESS) {
ap_log_error(APLOG_MARK, APLOG_STARTUP, rc, NULL,
"Couldn't start piped log process");