diff options
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/nginx.c | 8 | ||||
| -rw-r--r-- | src/core/ngx_conf_file.c | 9 | ||||
| -rw-r--r-- | src/core/ngx_cycle.c | 44 | ||||
| -rw-r--r-- | src/core/ngx_log.c | 13 | ||||
| -rw-r--r-- | src/core/ngx_log.h | 2 |
5 files changed, 45 insertions, 31 deletions
diff --git a/src/core/nginx.c b/src/core/nginx.c index a41c55cea..18f3cccb4 100644 --- a/src/core/nginx.c +++ b/src/core/nginx.c @@ -89,7 +89,7 @@ ngx_module_t ngx_core_module = { ngx_core_commands, /* module directives */ NGX_CORE_MODULE, /* module type */ NULL, /* init module */ - NULL /* init child */ + NULL /* init process */ }; @@ -146,10 +146,6 @@ int main(int argc, char *const *argv) if (ngx_test_config) { log->log_level = NGX_LOG_INFO; - } else { - if (ngx_log_init_error_log() == NGX_ERROR) { - return 1; - } } if (ngx_os_init(log) == NGX_ERROR) { @@ -183,6 +179,8 @@ int main(int argc, char *const *argv) return 0; } + ngx_os_status(cycle->log); + ngx_cycle = cycle; ccf = (ngx_core_conf_t *) ngx_get_conf(cycle->conf_ctx, ngx_core_module); diff --git a/src/core/ngx_conf_file.c b/src/core/ngx_conf_file.c index d51320908..90a09d231 100644 --- a/src/core/ngx_conf_file.c +++ b/src/core/ngx_conf_file.c @@ -560,7 +560,7 @@ static char *ngx_conf_include(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) return NGX_CONF_ERROR; } - ngx_log_error(NGX_LOG_INFO, cf->log, 0, "include %s", file.data); + ngx_log_debug1(NGX_LOG_DEBUG_CORE, cf->log, 0, "include %s", file.data); return ngx_conf_parse(cf, &file); } @@ -597,6 +597,11 @@ ngx_open_file_t *ngx_conf_open_file(ngx_cycle_t *cycle, ngx_str_t *name) ngx_list_part_t *part; ngx_open_file_t *file; +#if (NGX_SUPPRESS_WARN) + full.len = 0; + full.data = NULL; +#endif + if (name) { full = *name; @@ -637,7 +642,7 @@ ngx_open_file_t *ngx_conf_open_file(ngx_cycle_t *cycle, ngx_str_t *name) file->name = full; } else { - file->fd = STDERR_FILENO; + file->fd = ngx_stderr_fileno; file->name.len = 0; file->name.data = NULL; } diff --git a/src/core/ngx_cycle.c b/src/core/ngx_cycle.c index a545c61d7..ed4d60f89 100644 --- a/src/core/ngx_cycle.c +++ b/src/core/ngx_cycle.c @@ -328,24 +328,6 @@ ngx_cycle_t *ngx_init_cycle(ngx_cycle_t *old_cycle) } } -#if !(WIN32) - - if (!failed && !ngx_test_config && cycle->log->file->fd != STDERR_FILENO) { - - ngx_log_debug3(NGX_LOG_DEBUG_CORE, log, 0, - "dup2: %0X %d \"%s\"", - cycle->log->file, - cycle->log->file->fd, cycle->log->file->name.data); - - if (dup2(cycle->log->file->fd, STDERR_FILENO) == NGX_ERROR) { - ngx_log_error(NGX_LOG_EMERG, log, ngx_errno, - "dup2(STDERR) failed"); - failed = 1; - } - } - -#endif - if (failed) { /* rollback the new cycle configuration */ @@ -364,7 +346,9 @@ ngx_cycle_t *ngx_init_cycle(ngx_cycle_t *old_cycle) i = 0; } - if (file[i].fd == NGX_INVALID_FILE) { + if (file[i].fd == NGX_INVALID_FILE + || file[i].fd == ngx_stderr_fileno) + { continue; } @@ -400,8 +384,26 @@ ngx_cycle_t *ngx_init_cycle(ngx_cycle_t *old_cycle) /* commit the new cycle configuration */ - pool->log = cycle->log; +#if !(WIN32) + + if (!ngx_test_config && cycle->log->file->fd != STDERR_FILENO) { + + ngx_log_debug3(NGX_LOG_DEBUG_CORE, log, 0, + "dup2: %0X %d \"%s\"", + cycle->log->file, + cycle->log->file->fd, cycle->log->file->name.data); + + if (dup2(cycle->log->file->fd, STDERR_FILENO) == NGX_ERROR) { + ngx_log_error(NGX_LOG_EMERG, log, ngx_errno, + "dup2(STDERR) failed"); + /* fatal */ + exit(1); + } + } + +#endif + pool->log = cycle->log; for (i = 0; ngx_modules[i]; i++) { if (ngx_modules[i]->init_module) { @@ -446,7 +448,7 @@ ngx_cycle_t *ngx_init_cycle(ngx_cycle_t *old_cycle) i = 0; } - if (file[i].fd == NGX_INVALID_FILE) { + if (file[i].fd == NGX_INVALID_FILE || file[i].fd == ngx_stderr_fileno) { continue; } diff --git a/src/core/ngx_log.c b/src/core/ngx_log.c index 78f3af5fc..9cf1d5605 100644 --- a/src/core/ngx_log.c +++ b/src/core/ngx_log.c @@ -228,13 +228,16 @@ ngx_log_t *ngx_log_init_stderr() { #if (WIN32) - ngx_stderr.fd = GetStdHandle(STD_ERROR_HANDLE); + ngx_stderr_fileno = GetStdHandle(STD_ERROR_HANDLE); + ngx_stderr.fd = ngx_stderr_fileno; + + if (ngx_stderr_fileno == NGX_INVALID_FILE) { - if (ngx_stderr.fd == NGX_INVALID_FILE) { /* TODO: where can we log error ? */ + return NULL; - } else if (ngx_stderr.fd == NULL) { + } else if (ngx_stderr_fileno == NULL) { /* there are no associated standard handles */ @@ -256,6 +259,8 @@ ngx_log_t *ngx_log_init_stderr() } +#if 0 + ngx_int_t ngx_log_init_error_log() { ngx_fd_t fd; @@ -299,6 +304,8 @@ ngx_int_t ngx_log_init_error_log() return NGX_OK; } +#endif + ngx_log_t *ngx_log_create_errlog(ngx_cycle_t *cycle, ngx_array_t *args) { diff --git a/src/core/ngx_log.h b/src/core/ngx_log.h index 4133f9835..e82995e75 100644 --- a/src/core/ngx_log.h +++ b/src/core/ngx_log.h @@ -196,7 +196,9 @@ void ngx_assert_core(ngx_log_t *log, const char *fmt, ...); #define ngx_log_copy_log(new, old) ngx_memcpy(new, old, sizeof(ngx_log_t)) ngx_log_t *ngx_log_init_stderr(); +#if 0 ngx_int_t ngx_log_init_error_log(); +#endif ngx_log_t *ngx_log_create_errlog(ngx_cycle_t *cycle, ngx_array_t *args); char *ngx_set_error_log_levels(ngx_conf_t *cf, ngx_log_t *log); |
