# HG changeset patch # User Igor Sysoev # Date 1155910674 0 # Node ID 921a7ce4baf42fd1091b7e40f89c858c6b23053e # Parent c4d2b8200883f4298f327be8edc1f8934d30f5ba nginx-0.3.60-RELEASE import *) Bugfix: a worker process may got caught in an endless loop while an error redirection; the bug had appeared in 0.3.59. diff --git a/docs/xml/nginx/changes.xml b/docs/xml/nginx/changes.xml --- a/docs/xml/nginx/changes.xml +++ b/docs/xml/nginx/changes.xml @@ -9,6 +9,23 @@ nginx changelog + + + + +во время перенаправления ошибки рабочий процесс мог зациклиться; +ошибка появилась в 0.3.59. + + +a worker process may got caught in an endless loop +while an error redirection; +bug appeared in 0.3.59. + + + + + + diff --git a/src/core/nginx.h b/src/core/nginx.h --- a/src/core/nginx.h +++ b/src/core/nginx.h @@ -8,7 +8,7 @@ #define _NGINX_H_INCLUDED_ -#define NGINX_VER "nginx/0.3.59" +#define NGINX_VER "nginx/0.3.60" #define NGINX_VAR "NGINX" #define NGX_OLDPID_EXT ".oldbin" diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c --- a/src/http/ngx_http_core_module.c +++ b/src/http/ngx_http_core_module.c @@ -507,7 +507,7 @@ ngx_http_handler(ngx_http_request_t *r) r->valid_location = 1; r->uri_changed = 1; - r->phase = (r == r->main) ? NGX_HTTP_POST_READ_PHASE: + r->phase = (!r->internal) ? NGX_HTTP_POST_READ_PHASE: NGX_HTTP_SERVER_REWRITE_PHASE; r->phase_handler = 0; @@ -1324,6 +1324,15 @@ ngx_http_internal_redirect(ngx_http_requ { ngx_http_core_srv_conf_t *cscf; + r->uri_changes--; + + if (r->uri_changes == 0) { + ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, + "rewrite or internal redirection cycle"); + ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); + return NGX_DONE; + } + r->uri = *uri; if (args) { @@ -1338,7 +1347,8 @@ ngx_http_internal_redirect(ngx_http_requ "internal redirect: \"%V?%V\"", uri, &r->args); if (ngx_http_set_exten(r) != NGX_OK) { - return NGX_HTTP_INTERNAL_SERVER_ERROR; + ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); + return NGX_DONE; } /* clear the modules contexts */ @@ -1351,8 +1361,6 @@ ngx_http_internal_redirect(ngx_http_requ r->internal = 1; - r->uri_changes--; - ngx_http_handler(r); return NGX_DONE; diff --git a/src/http/ngx_http_special_response.c b/src/http/ngx_http_special_response.c --- a/src/http/ngx_http_special_response.c +++ b/src/http/ngx_http_special_response.c @@ -312,6 +312,7 @@ ngx_http_special_response_handler(ngx_ht } r->headers_out.status = error; + r->err_status = error; if (r->keepalive != 0) { switch (error) { @@ -340,7 +341,7 @@ ngx_http_special_response_handler(ngx_ht clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); - if (clcf->error_pages) { + if (r->uri_changes && clcf->error_pages) { err_page = clcf->error_pages->elts;