From 76075f523f38baa374d5d0bc46e26bdded4ec6b4 Mon Sep 17 00:00:00 2001 From: nginx Date: Tue, 2 Jul 2013 13:25:56 +0000 Subject: [PATCH] Changes with nginx 1.5.2 02 Jul 2013 *) Feature: now several "error_log" directives can be used. *) Bugfix: the $r->header_in() embedded perl method did not return value of the "Cookie" and "X-Forwarded-For" request header lines; the bug had appeared in 1.3.14. *) Bugfix: in the ngx_http_spdy_module. Thanks to Jim Radford. *) Bugfix: nginx could not be built on Linux with x32 ABI. Thanks to Serguei Ivantsov. --- CHANGES | 15 ++ CHANGES.ru | 15 ++ src/core/nginx.c | 2 +- src/core/nginx.h | 4 +- src/core/ngx_cycle.c | 19 ++- src/core/ngx_cycle.h | 2 + src/core/ngx_list.c | 10 +- src/core/ngx_log.c | 138 +++++++++++++----- src/core/ngx_log.h | 5 +- .../modules/ngx_http_stub_status_module.c | 1 + src/http/modules/perl/nginx.xs | 36 +++-- src/http/ngx_http_core_module.c | 27 +--- src/http/ngx_http_file_cache.c | 2 + src/http/ngx_http_parse.c | 9 +- src/http/ngx_http_request.h | 1 + src/http/ngx_http_spdy_filter_module.c | 18 ++- src/mail/ngx_mail_parse.c | 4 + src/os/unix/ngx_channel.c | 2 + src/os/unix/ngx_linux_config.h | 9 +- src/os/unix/ngx_process.c | 5 + src/os/unix/ngx_process_cycle.c | 10 ++ 21 files changed, 226 insertions(+), 108 deletions(-) diff --git a/CHANGES b/CHANGES index 6259cf46b6..6e426b1336 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,19 @@ +Changes with nginx 1.5.2 02 Jul 2013 + + *) Feature: now several "error_log" directives can be used. + + *) Bugfix: the $r->header_in() embedded perl method did not return value + of the "Cookie" and "X-Forwarded-For" request header lines; the bug + had appeared in 1.3.14. + + *) Bugfix: in the ngx_http_spdy_module. + Thanks to Jim Radford. + + *) Bugfix: nginx could not be built on Linux with x32 ABI. + Thanks to Serguei Ivantsov. + + Changes with nginx 1.5.1 04 Jun 2013 *) Feature: the "ssi_last_modified", "sub_filter_last_modified", and diff --git a/CHANGES.ru b/CHANGES.ru index 48e9ccc62d..a6dd78b482 100644 --- a/CHANGES.ru +++ b/CHANGES.ru @@ -1,4 +1,19 @@ +Изменения в nginx 1.5.2 02.07.2013 + + *) Добавление: теперь можно использовать несколько директив error_log. + + *) Исправление: метод $r->header_in() встроенного перла не возвращал + значения строк "Cookie" и "X-Forwarded-For" из заголовка запроса; + ошибка появилась в 1.3.14. + + *) Исправление: в модуле ngx_http_spdy_module. + Спасибо Jim Radford. + + *) Исправление: nginx не собирался на Linux при использовании x32 ABI. + Спасибо Сергею Иванцову. + + Изменения в nginx 1.5.1 04.06.2013 *) Добавление: директивы ssi_last_modified, sub_filter_last_modified и diff --git a/src/core/nginx.c b/src/core/nginx.c index 94df9bf74d..796717ab98 100644 --- a/src/core/nginx.c +++ b/src/core/nginx.c @@ -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 --git a/src/core/nginx.h b/src/core/nginx.h index c0588a9f5d..e7105610c5 100644 --- a/src/core/nginx.h +++ b/src/core/nginx.h @@ -9,8 +9,8 @@ #define _NGINX_H_INCLUDED_ -#define nginx_version 1005001 -#define NGINX_VERSION "1.5.1" +#define nginx_version 1005002 +#define NGINX_VERSION "1.5.2" #define NGINX_VER "nginx/" NGINX_VERSION #define NGINX_VAR "NGINX" diff --git a/src/core/ngx_cycle.c b/src/core/ngx_cycle.c index 87b6d7daa0..44edbafd45 100644 --- a/src/core/ngx_cycle.c +++ b/src/core/ngx_cycle.c @@ -84,7 +84,6 @@ ngx_init_cycle(ngx_cycle_t *old_cycle) cycle->pool = pool; cycle->log = log; - cycle->new_log.log_level = NGX_LOG_ERR; cycle->old_cycle = old_cycle; cycle->conf_prefix.len = old_cycle->conf_prefix.len; @@ -344,6 +343,8 @@ ngx_init_cycle(ngx_cycle_t *old_cycle) if (cycle->new_log.file == NULL) { goto failed; } + + cycle->new_log.log_level = NGX_LOG_ERR; } /* open the new files */ @@ -582,8 +583,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,16 +1230,13 @@ ngx_reopen_files(ngx_cycle_t *cycle, ngx_uid_t user) file[i].fd = fd; } -#if !(NGX_WIN32) + if (!cycle->log_use_stderr && cycle->log->file->fd != ngx_stderr) { - if (cycle->log->file->fd != STDERR_FILENO) { - if (dup2(cycle->log->file->fd, STDERR_FILENO) == -1) { - ngx_log_error(NGX_LOG_EMERG, cycle->log, ngx_errno, - "dup2(STDERR) failed"); + 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"); } } - -#endif } diff --git a/src/core/ngx_cycle.h b/src/core/ngx_cycle.h index 2e4bc4ba27..21bf5ca3f2 100644 --- a/src/core/ngx_cycle.h +++ b/src/core/ngx_cycle.h @@ -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 --git a/src/core/ngx_list.c b/src/core/ngx_list.c index 89ea823527..d0eb15930a 100644 --- a/src/core/ngx_list.c +++ b/src/core/ngx_list.c @@ -19,18 +19,10 @@ ngx_list_create(ngx_pool_t *pool, ngx_uint_t n, size_t size) return NULL; } - list->part.elts = ngx_palloc(pool, n * size); - if (list->part.elts == NULL) { + if (ngx_list_init(list, pool, n, size) != NGX_OK) { return NULL; } - list->part.nelts = 0; - list->part.next = NULL; - list->last = &list->part; - list->size = size; - list->nalloc = n; - list->pool = pool; - return list; } diff --git a/src/core/ngx_log.c b/src/core/ngx_log.c index d7830fb4b1..b35a432181 100644 --- a/src/core/ngx_log.c +++ b/src/core/ngx_log.c @@ -10,6 +10,8 @@ static char *ngx_error_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); +static char *ngx_log_set_levels(ngx_conf_t *cf, ngx_log_t *log); +static void ngx_log_insert(ngx_log_t *log, ngx_log_t *new_log); static ngx_command_t ngx_errlog_commands[] = { @@ -86,14 +88,11 @@ ngx_log_error_core(ngx_uint_t level, ngx_log_t *log, ngx_err_t err, #endif { #if (NGX_HAVE_VARIADIC_MACROS) - va_list args; + va_list args; #endif - u_char *p, *last, *msg; - u_char errstr[NGX_MAX_ERROR_STR]; - - if (log->file->fd == NGX_INVALID_FILE) { - return; - } + u_char *p, *last, *msg; + u_char errstr[NGX_MAX_ERROR_STR]; + ngx_uint_t wrote_stderr, debug_connection; last = errstr + NGX_MAX_ERROR_STR; @@ -140,11 +139,27 @@ ngx_log_error_core(ngx_uint_t level, ngx_log_t *log, ngx_err_t err, ngx_linefeed(p); - (void) ngx_write_fd(log->file->fd, errstr, p - errstr); + wrote_stderr = 0; + debug_connection = (log->log_level & NGX_LOG_DEBUG_CONNECTION) != 0; + + while (log) { + + if (log->log_level < level && !debug_connection) { + break; + } + + (void) ngx_write_fd(log->file->fd, errstr, p - errstr); + + if (log->file->fd == ngx_stderr) { + wrote_stderr = 1; + } + + log = log->next; + } if (!ngx_use_stderr || level > NGX_LOG_WARN - || log->file->fd == ngx_stderr) + || wrote_stderr) { return; } @@ -348,31 +363,17 @@ ngx_log_init(u_char *prefix) } -ngx_log_t * -ngx_log_create(ngx_cycle_t *cycle, ngx_str_t *name) -{ - ngx_log_t *log; - - log = ngx_pcalloc(cycle->pool, sizeof(ngx_log_t)); - if (log == NULL) { - return NULL; - } - - log->file = ngx_conf_open_file(cycle, name); - if (log->file == NULL) { - return NULL; - } - - return log; -} - - -char * +static char * ngx_log_set_levels(ngx_conf_t *cf, ngx_log_t *log) { ngx_uint_t i, n, d, found; ngx_str_t *value; + if (cf->args->nelts == 2) { + log->log_level = NGX_LOG_ERR; + return NGX_CONF_OK; + } + value = cf->args->elts; for (i = 2; i < cf->args->nelts; i++) { @@ -428,32 +429,91 @@ ngx_log_set_levels(ngx_conf_t *cf, ngx_log_t *log) static char * ngx_error_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) { + ngx_log_t *dummy; + + dummy = &cf->cycle->new_log; + + return ngx_log_set_log(cf, &dummy); +} + + +char * +ngx_log_set_log(ngx_conf_t *cf, ngx_log_t **head) +{ + ngx_log_t *new_log; ngx_str_t *value, name; - if (cf->cycle->new_log.file) { - return "is duplicate"; + if (*head != NULL && (*head)->log_level == 0) { + new_log = *head; + + } else { + + new_log = ngx_pcalloc(cf->pool, sizeof(ngx_log_t)); + if (new_log == NULL) { + return NGX_CONF_ERROR; + } + + if (*head == NULL) { + *head = new_log; + } } value = cf->args->elts; if (ngx_strcmp(value[1].data, "stderr") == 0) { ngx_str_null(&name); + cf->cycle->log_use_stderr = 1; } else { name = value[1]; } - cf->cycle->new_log.file = ngx_conf_open_file(cf->cycle, &name); - if (cf->cycle->new_log.file == NULL) { - return NULL; + new_log->file = ngx_conf_open_file(cf->cycle, &name); + if (new_log->file == NULL) { + return NGX_CONF_ERROR; } - if (cf->args->nelts == 2) { - cf->cycle->new_log.log_level = NGX_LOG_ERR; - return NGX_CONF_OK; + if (ngx_log_set_levels(cf, new_log) != NGX_CONF_OK) { + return NGX_CONF_ERROR; + } + + if (*head != new_log) { + ngx_log_insert(*head, new_log); } - cf->cycle->new_log.log_level = 0; + return NGX_CONF_OK; +} + + +static void +ngx_log_insert(ngx_log_t *log, ngx_log_t *new_log) +{ + ngx_log_t tmp; + + if (new_log->log_level > log->log_level) { + + /* + * list head address is permanent, insert new log after + * head and swap its contents with head + */ + + tmp = *log; + *log = *new_log; + *new_log = tmp; + + log->next = new_log; + return; + } + + while (log->next) { + if (new_log->log_level > log->next->log_level) { + new_log->next = log->next; + log->next = new_log; + return; + } + + log = log->next; + } - return ngx_log_set_levels(cf, &cf->cycle->new_log); + log->next = new_log; } diff --git a/src/core/ngx_log.h b/src/core/ngx_log.h index 3233647863..82e1e24518 100644 --- a/src/core/ngx_log.h +++ b/src/core/ngx_log.h @@ -61,6 +61,8 @@ struct ngx_log_s { */ char *action; + + ngx_log_t *next; }; @@ -220,11 +222,10 @@ void ngx_cdecl ngx_log_debug_core(ngx_log_t *log, ngx_err_t err, /*********************************/ ngx_log_t *ngx_log_init(u_char *prefix); -ngx_log_t *ngx_log_create(ngx_cycle_t *cycle, ngx_str_t *name); -char *ngx_log_set_levels(ngx_conf_t *cf, ngx_log_t *log); void ngx_cdecl ngx_log_abort(ngx_err_t err, const char *fmt, ...); void ngx_cdecl ngx_log_stderr(ngx_err_t err, const char *fmt, ...); u_char *ngx_log_errno(u_char *buf, u_char *last, ngx_err_t err); +char *ngx_log_set_log(ngx_conf_t *cf, ngx_log_t **head); /* diff --git a/src/http/modules/ngx_http_stub_status_module.c b/src/http/modules/ngx_http_stub_status_module.c index 83a35cda81..fe9132df84 100644 --- a/src/http/modules/ngx_http_stub_status_module.c +++ b/src/http/modules/ngx_http_stub_status_module.c @@ -145,6 +145,7 @@ static ngx_int_t ngx_http_status_handler(ngx_http_request_t *r) r->headers_out.content_length_n = b->last - b->pos; b->last_buf = (r == r->main) ? 1 : 0; + b->last_in_chain = 1; rc = ngx_http_send_header(r); diff --git a/src/http/modules/perl/nginx.xs b/src/http/modules/perl/nginx.xs index de67d5127d..77fb653739 100644 --- a/src/http/modules/perl/nginx.xs +++ b/src/http/modules/perl/nginx.xs @@ -222,10 +222,11 @@ header_in(r, key) dXSTARG; ngx_http_request_t *r; SV *key; - u_char *p, *lowcase_key, *cookie; + u_char *p, *lowcase_key, *value, sep; STRLEN len; ssize_t size; ngx_uint_t i, n, hash; + ngx_array_t *a; ngx_list_part_t *part; ngx_table_elt_t *h, **ph; ngx_http_header_t *hh; @@ -255,6 +256,19 @@ header_in(r, key) hh = ngx_hash_find(&cmcf->headers_in_hash, hash, lowcase_key, len); if (hh) { + + if (hh->offset == offsetof(ngx_http_headers_in_t, cookies)) { + sep = ';'; + goto multi; + } + + #if (NGX_HTTP_X_FORWARDED_FOR) + if (hh->offset == offsetof(ngx_http_headers_in_t, x_forwarded_for)) { + sep = ','; + goto multi; + } + #endif + if (hh->offset) { ph = (ngx_table_elt_t **) ((char *) &r->headers_in + hh->offset); @@ -268,15 +282,19 @@ header_in(r, key) XSRETURN_UNDEF; } - /* Cookie */ + multi: + + /* Cookie, X-Forwarded-For */ + + a = (ngx_array_t *) ((char *) &r->headers_in + hh->offset); - n = r->headers_in.cookies.nelts; + n = a->nelts; if (n == 0) { XSRETURN_UNDEF; } - ph = r->headers_in.cookies.elts; + ph = a->elts; if (n == 1) { ngx_http_perl_set_targ((*ph)->value.data, (*ph)->value.len); @@ -290,12 +308,12 @@ header_in(r, key) size += ph[i]->value.len + sizeof("; ") - 1; } - cookie = ngx_pnalloc(r->pool, size); - if (cookie == NULL) { + value = ngx_pnalloc(r->pool, size); + if (value == NULL) { XSRETURN_UNDEF; } - p = cookie; + p = value; for (i = 0; /* void */ ; i++) { p = ngx_copy(p, ph[i]->value.data, ph[i]->value.len); @@ -304,10 +322,10 @@ header_in(r, key) break; } - *p++ = ';'; *p++ = ' '; + *p++ = sep; *p++ = ' '; } - ngx_http_perl_set_targ(cookie, size); + ngx_http_perl_set_targ(value, size); goto done; } diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c index 25d3dc97de..b32a8842c8 100644 --- a/src/http/ngx_http_core_module.c +++ b/src/http/ngx_http_core_module.c @@ -4888,32 +4888,7 @@ ngx_http_core_error_log(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) { ngx_http_core_loc_conf_t *clcf = conf; - ngx_str_t *value, name; - - if (clcf->error_log) { - return "is duplicate"; - } - - value = cf->args->elts; - - if (ngx_strcmp(value[1].data, "stderr") == 0) { - ngx_str_null(&name); - - } else { - name = value[1]; - } - - clcf->error_log = ngx_log_create(cf->cycle, &name); - if (clcf->error_log == NULL) { - return NGX_CONF_ERROR; - } - - if (cf->args->nelts == 2) { - clcf->error_log->log_level = NGX_LOG_ERR; - return NGX_CONF_OK; - } - - return ngx_log_set_levels(cf, clcf->error_log); + return ngx_log_set_log(cf, &clcf->error_log); } diff --git a/src/http/ngx_http_file_cache.c b/src/http/ngx_http_file_cache.c index 6d94c50342..eacca595ae 100644 --- a/src/http/ngx_http_file_cache.c +++ b/src/http/ngx_http_file_cache.c @@ -875,6 +875,8 @@ ngx_http_file_cache_set_header(ngx_http_request_t *r, u_char *buf) c = r->cache; + ngx_memzero(h, sizeof(ngx_http_file_cache_header_t)); + h->valid_sec = c->valid_sec; h->last_modified = c->last_modified; h->date = c->date; diff --git a/src/http/ngx_http_parse.c b/src/http/ngx_http_parse.c index 3c168aaf25..697d856a01 100644 --- a/src/http/ngx_http_parse.c +++ b/src/http/ngx_http_parse.c @@ -1256,8 +1256,8 @@ ngx_http_parse_complex_uri(ngx_http_request_t *r, ngx_uint_t merge_slashes) * the line feed */ - ngx_log_debug4(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, - "s:%d in:'%Xd:%c', out:'%c'", state, ch, ch, *u); + ngx_log_debug3(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, + "s:%d in:'%Xd:%c'", state, ch, ch); switch (state) { @@ -2180,8 +2180,9 @@ ngx_http_parse_chunked(ngx_http_request_t *r, ngx_buf_t *b, ctx->length = 3 /* "0" LF LF */; break; case sw_chunk_size: - ctx->length = 2 /* LF LF */ - + (ctx->size ? ctx->size + 4 /* LF "0" LF LF */ : 0); + ctx->length = 1 /* LF */ + + (ctx->size ? ctx->size + 4 /* LF "0" LF LF */ + : 1 /* LF */); break; case sw_chunk_extension: case sw_chunk_extension_almost_done: diff --git a/src/http/ngx_http_request.h b/src/http/ngx_http_request.h index 1babeb2b0c..3b0858ace9 100644 --- a/src/http/ngx_http_request.h +++ b/src/http/ngx_http_request.h @@ -585,6 +585,7 @@ extern ngx_http_header_out_t ngx_http_headers_out[]; #define ngx_http_set_connection_log(c, l) \ \ c->log->file = l->file; \ + c->log->next = l->next; \ if (!(c->log->log_level & NGX_LOG_DEBUG_CONNECTION)) { \ c->log->log_level = l->log_level; \ } diff --git a/src/http/ngx_http_spdy_filter_module.c b/src/http/ngx_http_spdy_filter_module.c index 8fe46b2e95..805177651f 100644 --- a/src/http/ngx_http_spdy_filter_module.c +++ b/src/http/ngx_http_spdy_filter_module.c @@ -162,7 +162,9 @@ ngx_http_spdy_header_filter(ngx_http_request_t *r) + ngx_http_spdy_nv_nsize("version") + ngx_http_spdy_nv_vsize("HTTP/1.1") + ngx_http_spdy_nv_nsize("status") - + ngx_http_spdy_nv_vsize("418"); + + (r->headers_out.status_line.len + ? NGX_SPDY_NV_VLEN_SIZE + r->headers_out.status_line.len + : ngx_http_spdy_nv_vsize("418")); clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); @@ -304,8 +306,16 @@ ngx_http_spdy_header_filter(ngx_http_request_t *r) last = ngx_http_spdy_nv_write_val(last, "HTTP/1.1"); last = ngx_http_spdy_nv_write_name(last, "status"); - last = ngx_spdy_frame_write_uint16(last, 3); - last = ngx_sprintf(last, "%03ui", r->headers_out.status); + + if (r->headers_out.status_line.len) { + last = ngx_http_spdy_nv_write_vlen(last, + r->headers_out.status_line.len); + last = ngx_cpymem(last, r->headers_out.status_line.data, + r->headers_out.status_line.len); + } else { + last = ngx_http_spdy_nv_write_vlen(last, 3); + last = ngx_sprintf(last, "%03ui", r->headers_out.status); + } count = 2; @@ -500,7 +510,7 @@ ngx_http_spdy_header_filter(ngx_http_request_t *r) count++; } - (void) ngx_spdy_frame_write_uint16(buf, count); + (void) ngx_http_spdy_nv_write_num(buf, count); stream = r->spdy_stream; sc = stream->connection; diff --git a/src/mail/ngx_mail_parse.c b/src/mail/ngx_mail_parse.c index eb16d5b4fe..7de6c19a13 100644 --- a/src/mail/ngx_mail_parse.c +++ b/src/mail/ngx_mail_parse.c @@ -842,6 +842,10 @@ ngx_mail_auth_parse(ngx_mail_session_t *s, ngx_connection_t *c) } #endif + if (s->args.nelts == 0) { + return NGX_MAIL_PARSE_INVALID_COMMAND; + } + arg = s->args.elts; if (arg[0].len == 5) { diff --git a/src/os/unix/ngx_channel.c b/src/os/unix/ngx_channel.c index 29c69da406..536a9ed4bb 100644 --- a/src/os/unix/ngx_channel.c +++ b/src/os/unix/ngx_channel.c @@ -34,6 +34,8 @@ ngx_write_channel(ngx_socket_t s, ngx_channel_t *ch, size_t size, msg.msg_control = (caddr_t) &cmsg; msg.msg_controllen = sizeof(cmsg); + ngx_memzero(&cmsg, sizeof(cmsg)); + cmsg.cm.cmsg_len = CMSG_LEN(sizeof(int)); cmsg.cm.cmsg_level = SOL_SOCKET; cmsg.cm.cmsg_type = SCM_RIGHTS; diff --git a/src/os/unix/ngx_linux_config.h b/src/os/unix/ngx_linux_config.h index 2834032dea..8467a97fec 100644 --- a/src/os/unix/ngx_linux_config.h +++ b/src/os/unix/ngx_linux_config.h @@ -51,7 +51,6 @@ #include /* memalign() */ #include /* IOV_MAX */ #include -#include #include #include /* uname() */ @@ -77,8 +76,14 @@ extern ssize_t sendfile(int s, int fd, int32_t *offset, size_t size); #endif -#if (NGX_HAVE_POLL || NGX_HAVE_RTSIG) +#if (NGX_HAVE_POLL) +#include +#endif + + +#if (NGX_HAVE_RTSIG) #include +#include #endif diff --git a/src/os/unix/ngx_process.c b/src/os/unix/ngx_process.c index 4ef3582e8a..6f3f38556a 100644 --- a/src/os/unix/ngx_process.c +++ b/src/os/unix/ngx_process.c @@ -291,9 +291,14 @@ ngx_init_signals(ngx_log_t *log) sa.sa_handler = sig->handler; sigemptyset(&sa.sa_mask); if (sigaction(sig->signo, &sa, NULL) == -1) { +#if (NGX_VALGRIND) + ngx_log_error(NGX_LOG_ALERT, log, ngx_errno, + "sigaction(%s) failed, ignored", sig->signame); +#else ngx_log_error(NGX_LOG_EMERG, log, ngx_errno, "sigaction(%s) failed", sig->signame); return NGX_ERROR; +#endif } } diff --git a/src/os/unix/ngx_process_cycle.c b/src/os/unix/ngx_process_cycle.c index dfdfae081c..8ada10652e 100644 --- a/src/os/unix/ngx_process_cycle.c +++ b/src/os/unix/ngx_process_cycle.c @@ -355,6 +355,8 @@ ngx_start_worker_processes(ngx_cycle_t *cycle, ngx_int_t n, ngx_int_t type) ngx_log_error(NGX_LOG_NOTICE, cycle->log, 0, "start worker processes"); + ngx_memzero(&ch, sizeof(ngx_channel_t)); + ch.command = NGX_CMD_OPEN_CHANNEL; for (i = 0; i < n; i++) { @@ -401,6 +403,8 @@ ngx_start_cache_manager_processes(ngx_cycle_t *cycle, ngx_uint_t respawn) &ngx_cache_manager_ctx, "cache manager process", respawn ? NGX_PROCESS_JUST_RESPAWN : NGX_PROCESS_RESPAWN); + ngx_memzero(&ch, sizeof(ngx_channel_t)); + ch.command = NGX_CMD_OPEN_CHANNEL; ch.pid = ngx_processes[ngx_process_slot].pid; ch.slot = ngx_process_slot; @@ -460,6 +464,8 @@ ngx_signal_worker_processes(ngx_cycle_t *cycle, int signo) ngx_err_t err; ngx_channel_t ch; + ngx_memzero(&ch, sizeof(ngx_channel_t)); + #if (NGX_BROKEN_SCM_RIGHTS) ch.command = 0; @@ -561,6 +567,8 @@ ngx_reap_children(ngx_cycle_t *cycle) ngx_channel_t ch; ngx_core_conf_t *ccf; + ngx_memzero(&ch, sizeof(ngx_channel_t)); + ch.command = NGX_CMD_CLOSE_CHANNEL; ch.fd = -1; @@ -706,6 +714,7 @@ ngx_master_process_exit(ngx_cycle_t *cycle) ngx_exit_log = *ngx_cycle->log; ngx_exit_log.file = &ngx_exit_log_file; + ngx_exit_log.next = NULL; ngx_exit_cycle.log = &ngx_exit_log; ngx_exit_cycle.files = ngx_cycle->files; @@ -1058,6 +1067,7 @@ ngx_worker_process_exit(ngx_cycle_t *cycle) ngx_exit_log = *ngx_cycle->log; ngx_exit_log.file = &ngx_exit_log_file; + ngx_exit_log.next = NULL; ngx_exit_cycle.log = &ngx_exit_log; ngx_exit_cycle.files = ngx_cycle->files;