From: William A. Rowe Jr Date: Fri, 24 Aug 2007 22:05:55 +0000 (+0000) Subject: log core: fix the new piped logger case where we couldn't connect X-Git-Tag: 2.2.6~122 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=60d8807692d6cc6cae418caf923fd0deec6b7d31;p=thirdparty%2Fapache%2Fhttpd.git 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] also disambiguate an error message to diagnose future error reports Backport: r568326, r568322 git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.2.x@569542 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index b98127da056..1194b5f6f34 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,11 @@  -*- coding: utf-8 -*- Changes with Apache 2.2.6 + *) 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] diff --git a/STATUS b/STATUS index 7bfa76c8edf..dd413334ace 100644 --- a/STATUS +++ b/STATUS @@ -290,17 +290,6 @@ PATCHES PROPOSED TO BACKPORT FROM TRUNK: http://svn.apache.org/viewvc?view=rev&revision=565671 +1: niq - * 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 - 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: Agrees with rpluem. - * main core: Emit errors during the initial apr_app_initialize() or apr_pool_create() (when apr-based error reporting is not ready). http://svn.apache.org/viewvc?view=rev&revision=568779 diff --git a/server/log.c b/server/log.c index c027f002415..43661591d6d 100644 --- a/server/log.c +++ b/server/log.c @@ -213,7 +213,7 @@ AP_DECLARE(apr_status_t) ap_replace_stderr_log(apr_pool_t *p, } if (rc != APR_SUCCESS) { ap_log_error(APLOG_MARK, APLOG_CRIT, rc, NULL, - "unable to replace stderr with error_log"); + "unable to replace stderr with error log file"); } return rc; } @@ -250,18 +250,20 @@ static int log_child(apr_pool_t *p, const char *progname, 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) - && (!dummy_stderr - || ((rc = apr_file_open_stdout(&errfile, p)) == APR_SUCCESS - && (rc = apr_procattr_child_err_set(procattr, - errfile, - errfile)) == 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); @@ -272,13 +274,6 @@ static int log_child(apr_pool_t *p, const char *progname, * close_handle_in_child() */ } - - /* apr_procattr_child_err_set dups errfile twice: close the - * remaining "parent-side" copy (apr_proc_create closes the - * other). */ - if (dummy_stderr) { - apr_file_close(procnew->err); - } } return rc;