Skip to content

Commit

Permalink
nginx 1.11.13
Browse files Browse the repository at this point in the history
  • Loading branch information
chronolaw committed Apr 6, 2017
1 parent 247a79f commit 2f80517
Show file tree
Hide file tree
Showing 29 changed files with 334 additions and 225 deletions.
28 changes: 28 additions & 0 deletions nginx/CHANGES
Original file line number Diff line number Diff line change
@@ -1,4 +1,32 @@

Changes with nginx 1.11.13 04 Apr 2017

*) Feature: the "http_429" parameter of the "proxy_next_upstream",
"fastcgi_next_upstream", "scgi_next_upstream", and
"uwsgi_next_upstream" directives.
Thanks to Piotr Sikora.

*) Bugfix: in memory allocation error handling.

*) Bugfix: requests might hang when using the "sendfile" and
"timer_resolution" directives on Linux.

*) Bugfix: requests might hang when using the "sendfile" and "aio_write"
directives with subrequests.

*) Bugfix: in the ngx_http_v2_module.
Thanks to Piotr Sikora.

*) Bugfix: a segmentation fault might occur in a worker process when
using HTTP/2.

*) Bugfix: requests might hang when using the "limit_rate",
"sendfile_max_chunk", "limit_req" directives, or the $r->sleep()
embedded perl method with subrequests.

*) Bugfix: in the ngx_http_slice_module.


Changes with nginx 1.11.12 24 Mar 2017

*) Bugfix: nginx might hog CPU; the bug had appeared in 1.11.11.
Expand Down
27 changes: 27 additions & 0 deletions nginx/CHANGES.ru
Original file line number Diff line number Diff line change
@@ -1,4 +1,31 @@

Изменения в nginx 1.11.13 04.04.2017

*) Добавление: параметр http_429 в директивах proxy_next_upstream,
fastcgi_next_upstream, scgi_next_upstream и uwsgi_next_upstream.
Спасибо Piotr Sikora.

*) Исправление: в обработке ошибок выделения памяти.

*) Исправление: при использовании директив sendfile и timer_resolution
на Linux запросы могли зависать.

*) Исправление: при использовании с подзапросами директив sendfile и
aio_write запросы могли зависать.

*) Исправление: в модуле ngx_http_v2_module.
Спасибо Piotr Sikora.

*) Исправление: при использовании HTTP/2 в рабочем процессе мог
произойти segmentation fault.

*) Исправление: запросы могли зависать при использовании с подзапросами
директив limit_rate, sendfile_max_chunk, limit_req или метода
$r->sleep() встроенного перла.

*) Исправление: в модуле ngx_http_slice_module.


Изменения в nginx 1.11.12 24.03.2017

*) Исправление: nginx мог нагружать процессор; ошибка появилась в
Expand Down
4 changes: 2 additions & 2 deletions nginx/src/core/nginx.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
#define _NGINX_H_INCLUDED_


#define nginx_version 1011012
#define NGINX_VERSION "1.11.12"
#define nginx_version 1011013
#define NGINX_VERSION "1.11.13"
#define NGINX_VER "nginx/" NGINX_VERSION

#ifdef NGX_BUILD
Expand Down
34 changes: 15 additions & 19 deletions nginx/src/core/ngx_cycle.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,16 +115,14 @@ ngx_init_cycle(ngx_cycle_t *old_cycle)

n = old_cycle->paths.nelts ? old_cycle->paths.nelts : 10;

cycle->paths.elts = ngx_pcalloc(pool, n * sizeof(ngx_path_t *));
if (cycle->paths.elts == NULL) {
if (ngx_array_init(&cycle->paths, pool, n, sizeof(ngx_path_t *))
!= NGX_OK)
{
ngx_destroy_pool(pool);
return NULL;
}

cycle->paths.nelts = 0;
cycle->paths.size = sizeof(ngx_path_t *);
cycle->paths.nalloc = n;
cycle->paths.pool = pool;
ngx_memzero(cycle->paths.elts, n * sizeof(ngx_path_t *));


if (ngx_array_init(&cycle->config_dump, pool, 1, sizeof(ngx_conf_dump_t))
Expand Down Expand Up @@ -175,16 +173,14 @@ ngx_init_cycle(ngx_cycle_t *old_cycle)

n = old_cycle->listening.nelts ? old_cycle->listening.nelts : 10;

cycle->listening.elts = ngx_pcalloc(pool, n * sizeof(ngx_listening_t));
if (cycle->listening.elts == NULL) {
if (ngx_array_init(&cycle->listening, pool, n, sizeof(ngx_listening_t))
!= NGX_OK)
{
ngx_destroy_pool(pool);
return NULL;
}

cycle->listening.nelts = 0;
cycle->listening.size = sizeof(ngx_listening_t);
cycle->listening.nalloc = n;
cycle->listening.pool = pool;
ngx_memzero(cycle->listening.elts, n * sizeof(ngx_listening_t));


ngx_queue_init(&cycle->reusable_connections_queue);
Expand Down Expand Up @@ -768,15 +764,15 @@ ngx_init_cycle(ngx_cycle_t *old_cycle)
}

n = 10;
ngx_old_cycles.elts = ngx_pcalloc(ngx_temp_pool,
n * sizeof(ngx_cycle_t *));
if (ngx_old_cycles.elts == NULL) {

if (ngx_array_init(&ngx_old_cycles, ngx_temp_pool, n,
sizeof(ngx_cycle_t *))
!= NGX_OK)
{
exit(1);
}
ngx_old_cycles.nelts = 0;
ngx_old_cycles.size = sizeof(ngx_cycle_t *);
ngx_old_cycles.nalloc = n;
ngx_old_cycles.pool = ngx_temp_pool;

ngx_memzero(ngx_old_cycles.elts, n * sizeof(ngx_cycle_t *));

ngx_cleaner_event.handler = ngx_clean_old_cycles;
ngx_cleaner_event.log = cycle->log;
Expand Down
3 changes: 1 addition & 2 deletions nginx/src/event/ngx_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -500,8 +500,7 @@ ngx_event_module_init(ngx_cycle_t *cycle)
#endif

shm.size = size;
shm.name.len = sizeof("nginx_shared_zone") - 1;
shm.name.data = (u_char *) "nginx_shared_zone";
ngx_str_set(&shm.name, "nginx_shared_zone");
shm.log = cycle->log;

if (ngx_shm_alloc(&shm) != NGX_OK) {
Expand Down
1 change: 1 addition & 0 deletions nginx/src/http/modules/ngx_http_fastcgi_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ static ngx_conf_bitmask_t ngx_http_fastcgi_next_upstream_masks[] = {
{ ngx_string("http_503"), NGX_HTTP_UPSTREAM_FT_HTTP_503 },
{ ngx_string("http_403"), NGX_HTTP_UPSTREAM_FT_HTTP_403 },
{ ngx_string("http_404"), NGX_HTTP_UPSTREAM_FT_HTTP_404 },
{ ngx_string("http_429"), NGX_HTTP_UPSTREAM_FT_HTTP_429 },
{ ngx_string("updating"), NGX_HTTP_UPSTREAM_FT_UPDATING },
{ ngx_string("off"), NGX_HTTP_UPSTREAM_FT_OFF },
{ ngx_null_string, 0 }
Expand Down
6 changes: 3 additions & 3 deletions nginx/src/http/modules/ngx_http_index_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,13 +217,13 @@ ngx_http_index_handler(ngx_http_request_t *r)
if (ngx_open_cached_file(clcf->open_file_cache, &path, &of, r->pool)
!= NGX_OK)
{
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, of.err,
"%s \"%s\" failed", of.failed, path.data);

if (of.err == 0) {
return NGX_HTTP_INTERNAL_SERVER_ERROR;
}

ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, of.err,
"%s \"%s\" failed", of.failed, path.data);

#if (NGX_HAVE_OPENAT)
if (of.err == NGX_EMLINK
|| of.err == NGX_ELOOP)
Expand Down
6 changes: 3 additions & 3 deletions nginx/src/http/modules/ngx_http_limit_req_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,8 @@ ngx_http_limit_req_handler(ngx_http_request_t *r)

r->read_event_handler = ngx_http_test_reading;
r->write_event_handler = ngx_http_limit_req_delay;

r->connection->write->delayed = 1;
ngx_add_timer(r->connection->write, delay);

return NGX_AGAIN;
Expand All @@ -292,7 +294,7 @@ ngx_http_limit_req_delay(ngx_http_request_t *r)

wev = r->connection->write;

if (!wev->timedout) {
if (wev->delayed) {

if (ngx_handle_write_event(wev, 0) != NGX_OK) {
ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
Expand All @@ -301,8 +303,6 @@ ngx_http_limit_req_delay(ngx_http_request_t *r)
return;
}

wev->timedout = 0;

if (ngx_handle_read_event(r->connection->read, 0) != NGX_OK) {
ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
return;
Expand Down
5 changes: 5 additions & 0 deletions nginx/src/http/modules/ngx_http_log_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,11 @@ ngx_http_log_script_write(ngx_http_request_t *r, ngx_http_log_script_t *script,
if (ngx_open_cached_file(llcf->open_file_cache, &log, &of, r->pool)
!= NGX_OK)
{
if (of.err == 0) {
/* simulate successful logging */
return len;
}

ngx_log_error(NGX_LOG_CRIT, r->connection->log, ngx_errno,
"%s \"%s\" failed", of.failed, log.data);
/* simulate successful logging */
Expand Down
1 change: 1 addition & 0 deletions nginx/src/http/modules/ngx_http_proxy_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ static ngx_conf_bitmask_t ngx_http_proxy_next_upstream_masks[] = {
{ ngx_string("http_504"), NGX_HTTP_UPSTREAM_FT_HTTP_504 },
{ ngx_string("http_403"), NGX_HTTP_UPSTREAM_FT_HTTP_403 },
{ ngx_string("http_404"), NGX_HTTP_UPSTREAM_FT_HTTP_404 },
{ ngx_string("http_429"), NGX_HTTP_UPSTREAM_FT_HTTP_429 },
{ ngx_string("updating"), NGX_HTTP_UPSTREAM_FT_UPDATING },
{ ngx_string("off"), NGX_HTTP_UPSTREAM_FT_OFF },
{ ngx_null_string, 0 }
Expand Down
1 change: 1 addition & 0 deletions nginx/src/http/modules/ngx_http_scgi_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ static ngx_conf_bitmask_t ngx_http_scgi_next_upstream_masks[] = {
{ ngx_string("http_503"), NGX_HTTP_UPSTREAM_FT_HTTP_503 },
{ ngx_string("http_403"), NGX_HTTP_UPSTREAM_FT_HTTP_403 },
{ ngx_string("http_404"), NGX_HTTP_UPSTREAM_FT_HTTP_404 },
{ ngx_string("http_429"), NGX_HTTP_UPSTREAM_FT_HTTP_429 },
{ ngx_string("updating"), NGX_HTTP_UPSTREAM_FT_UPDATING },
{ ngx_string("off"), NGX_HTTP_UPSTREAM_FT_OFF },
{ ngx_null_string, 0 }
Expand Down
38 changes: 26 additions & 12 deletions nginx/src/http/modules/ngx_http_slice_filter_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,25 @@


typedef struct {
size_t size;
size_t size;
} ngx_http_slice_loc_conf_t;


typedef struct {
off_t start;
off_t end;
ngx_str_t range;
ngx_str_t etag;
ngx_uint_t last; /* unsigned last:1; */
off_t start;
off_t end;
ngx_str_t range;
ngx_str_t etag;
unsigned last:1;
unsigned active:1;
ngx_http_request_t *sr;
} ngx_http_slice_ctx_t;


typedef struct {
off_t start;
off_t end;
off_t complete_length;
off_t start;
off_t end;
off_t complete_length;
} ngx_http_slice_content_range_t;


Expand Down Expand Up @@ -169,6 +171,7 @@ ngx_http_slice_header_filter(ngx_http_request_t *r)
}

ctx->start = end;
ctx->active = 1;

r->headers_out.status = NGX_HTTP_OK;
r->headers_out.status_line.len = 0;
Expand Down Expand Up @@ -209,7 +212,6 @@ ngx_http_slice_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
{
ngx_int_t rc;
ngx_chain_t *cl;
ngx_http_request_t *sr;
ngx_http_slice_ctx_t *ctx;
ngx_http_slice_loc_conf_t *slcf;

Expand All @@ -234,6 +236,16 @@ ngx_http_slice_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
return rc;
}

if (ctx->sr && !ctx->sr->done) {
return rc;
}

if (!ctx->active) {
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
"missing slice response");
return NGX_ERROR;
}

if (ctx->start >= ctx->end) {
ngx_http_set_ctx(r, NULL, ngx_http_slice_filter_module);
ngx_http_send_special(r, NGX_HTTP_LAST);
Expand All @@ -244,21 +256,23 @@ ngx_http_slice_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
return rc;
}

if (ngx_http_subrequest(r, &r->uri, &r->args, &sr, NULL,
if (ngx_http_subrequest(r, &r->uri, &r->args, &ctx->sr, NULL,
NGX_HTTP_SUBREQUEST_CLONE)
!= NGX_OK)
{
return NGX_ERROR;
}

ngx_http_set_ctx(sr, ctx, ngx_http_slice_filter_module);
ngx_http_set_ctx(ctx->sr, ctx, ngx_http_slice_filter_module);

slcf = ngx_http_get_module_loc_conf(r, ngx_http_slice_filter_module);

ctx->range.len = ngx_sprintf(ctx->range.data, "bytes=%O-%O", ctx->start,
ctx->start + (off_t) slcf->size - 1)
- ctx->range.data;

ctx->active = 0;

ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
"http slice subrequest: \"%V\"", &ctx->range);

Expand Down
1 change: 1 addition & 0 deletions nginx/src/http/modules/ngx_http_uwsgi_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ static ngx_conf_bitmask_t ngx_http_uwsgi_next_upstream_masks[] = {
{ ngx_string("http_503"), NGX_HTTP_UPSTREAM_FT_HTTP_503 },
{ ngx_string("http_403"), NGX_HTTP_UPSTREAM_FT_HTTP_403 },
{ ngx_string("http_404"), NGX_HTTP_UPSTREAM_FT_HTTP_404 },
{ ngx_string("http_429"), NGX_HTTP_UPSTREAM_FT_HTTP_429 },
{ ngx_string("updating"), NGX_HTTP_UPSTREAM_FT_UPDATING },
{ ngx_string("off"), NGX_HTTP_UPSTREAM_FT_OFF },
{ ngx_null_string, 0 }
Expand Down
1 change: 1 addition & 0 deletions nginx/src/http/modules/perl/nginx.xs
Original file line number Diff line number Diff line change
Expand Up @@ -1001,6 +1001,7 @@ sleep(r, sleep, next)

ctx->next = SvRV(ST(2));

r->connection->write->delayed = 1;
ngx_add_timer(r->connection->write, sleep);

r->write_event_handler = ngx_http_perl_sleep_handler;
Expand Down
13 changes: 7 additions & 6 deletions nginx/src/http/modules/perl/ngx_http_perl_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -278,15 +278,16 @@ ngx_http_perl_sleep_handler(ngx_http_request_t *r)

wev = r->connection->write;

if (wev->timedout) {
wev->timedout = 0;
ngx_http_perl_handle_request(r);
if (wev->delayed) {

if (ngx_handle_write_event(wev, 0) != NGX_OK) {
ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
}

return;
}

if (ngx_handle_write_event(wev, 0) != NGX_OK) {
ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
}
ngx_http_perl_handle_request(r);
}


Expand Down
Loading

0 comments on commit 2f80517

Please sign in to comment.