Welcome! Log In Create A New Profile

Advanced

[nginx] Core: fixed handling of "stderr" in error_log.

Homutov Vladimir
June 04, 2013 11:34AM
details: http://hg.nginx.org/nginx/rev/d8af1005e886
branches:
changeset: 5240:d8af1005e886
user: Vladimir Homutov <vl@nginx.com>
date: Tue Jun 04 11:27:36 2013 +0400
description:
Core: fixed handling of "stderr" in error_log.

If "stderr" was specified in one of the "error_log" directives,
stderr is not redirected to the first error_log on startup,
configuration reload, and reopening log files.

diffstat:

src/core/nginx.c | 2 +-
src/core/ngx_cycle.c | 7 ++++---
src/core/ngx_cycle.h | 2 ++
src/core/ngx_log.c | 1 +
src/http/ngx_http_core_module.c | 1 +
5 files changed, 9 insertions(+), 4 deletions(-)

diffs (70 lines):

diff -r 85e72ea8fbfd -r d8af1005e886 src/core/nginx.c
--- a/src/core/nginx.c Mon Jun 03 16:54:28 2013 +0400
+++ b/src/core/nginx.c Tue Jun 04 11:27:36 2013 +0400
@@ -387,7 +387,7 @@ main(int argc, char *const *argv)
return 1;
}

- if (cycle->log->file->fd != ngx_stderr) {
+ if (!cycle->log_use_stderr && cycle->log->file->fd != ngx_stderr) {

if (ngx_set_stderr(cycle->log->file->fd) == NGX_FILE_ERROR) {
ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno,
diff -r 85e72ea8fbfd -r d8af1005e886 src/core/ngx_cycle.c
--- a/src/core/ngx_cycle.c Mon Jun 03 16:54:28 2013 +0400
+++ b/src/core/ngx_cycle.c Tue Jun 04 11:27:36 2013 +0400
@@ -582,8 +582,9 @@ ngx_init_cycle(ngx_cycle_t *old_cycle)

/* commit the new cycle configuration */

- if (!ngx_use_stderr && cycle->log->file->fd != ngx_stderr) {
-
+ if (!ngx_use_stderr && !cycle->log_use_stderr
+ && cycle->log->file->fd != ngx_stderr)
+ {
if (ngx_set_stderr(cycle->log->file->fd) == NGX_FILE_ERROR) {
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
ngx_set_stderr_n " failed");
@@ -1228,7 +1229,7 @@ ngx_reopen_files(ngx_cycle_t *cycle, ngx
file[i].fd = fd;
}

- if (cycle->log->file->fd != ngx_stderr) {
+ if (!cycle->log_use_stderr && cycle->log->file->fd != ngx_stderr) {

if (ngx_set_stderr(cycle->log->file->fd) == NGX_FILE_ERROR) {
ngx_log_error(NGX_LOG_ALERT, cycle->log, ngx_errno,
diff -r 85e72ea8fbfd -r d8af1005e886 src/core/ngx_cycle.h
--- a/src/core/ngx_cycle.h Mon Jun 03 16:54:28 2013 +0400
+++ b/src/core/ngx_cycle.h Tue Jun 04 11:27:36 2013 +0400
@@ -41,6 +41,8 @@ struct ngx_cycle_s {
ngx_log_t *log;
ngx_log_t new_log;

+ ngx_uint_t log_use_stderr; /* unsigned log_use_stderr:1; */
+
ngx_connection_t **files;
ngx_connection_t *free_connections;
ngx_uint_t free_connection_n;
diff -r 85e72ea8fbfd -r d8af1005e886 src/core/ngx_log.c
--- a/src/core/ngx_log.c Mon Jun 03 16:54:28 2013 +0400
+++ b/src/core/ngx_log.c Tue Jun 04 11:27:36 2013 +0400
@@ -438,6 +438,7 @@ ngx_error_log(ngx_conf_t *cf, ngx_comman

if (ngx_strcmp(value[1].data, "stderr") == 0) {
ngx_str_null(&name);
+ cf->cycle->log_use_stderr = 1;

} else {
name = value[1];
diff -r 85e72ea8fbfd -r d8af1005e886 src/http/ngx_http_core_module.c
--- a/src/http/ngx_http_core_module.c Mon Jun 03 16:54:28 2013 +0400
+++ b/src/http/ngx_http_core_module.c Tue Jun 04 11:27:36 2013 +0400
@@ -4898,6 +4898,7 @@ ngx_http_core_error_log(ngx_conf_t *cf,

if (ngx_strcmp(value[1].data, "stderr") == 0) {
ngx_str_null(&name);
+ cf->cycle->log_use_stderr = 1;

} else {
name = value[1];

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[nginx] Core: fixed handling of "stderr" in error_log.

Homutov Vladimir 594 June 04, 2013 11:34AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 157
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready