Welcome! Log In Create A New Profile

Advanced

[nginx] Upstream: fixed cache send error handling.

Roman Arutyunyan
September 03, 2015 08:14AM
details: http://hg.nginx.org/nginx/rev/0e3a45ec2a3a
branches:
changeset: 6242:0e3a45ec2a3a
user: Roman Arutyunyan <arut@nginx.com>
date: Thu Sep 03 15:09:21 2015 +0300
description:
Upstream: fixed cache send error handling.

The value of NGX_ERROR, returned from filter handlers, was treated as a generic
upstream error and changed to NGX_HTTP_INTERNAL_SERVER_ERROR before calling
ngx_http_finalize_request(). This resulted in "header already sent" alert
if header was already sent in filter handlers.

The problem appeared in 54e9b83d00f0 (1.7.5).

diffstat:

src/http/ngx_http_upstream.c | 25 ++++++++++++++-----------
1 files changed, 14 insertions(+), 11 deletions(-)

diffs (47 lines):

diff -r 387696b36c29 -r 0e3a45ec2a3a src/http/ngx_http_upstream.c
--- a/src/http/ngx_http_upstream.c Wed Sep 02 19:45:40 2015 +0300
+++ b/src/http/ngx_http_upstream.c Thu Sep 03 15:09:21 2015 +0300
@@ -534,15 +534,24 @@ ngx_http_upstream_init_request(ngx_http_

r->write_event_handler = ngx_http_request_empty_handler;

- if (rc == NGX_DONE) {
- return;
- }
-
if (rc == NGX_ERROR) {
ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
return;
}

+ if (rc == NGX_OK) {
+ rc = ngx_http_upstream_cache_send(r, u);
+
+ if (rc == NGX_DONE) {
+ return;
+ }
+
+ if (rc == NGX_HTTP_UPSTREAM_INVALID_HEADER) {
+ rc = NGX_DECLINED;
+ r->cached = 0;
+ }
+ }
+
if (rc != NGX_DECLINED) {
ngx_http_finalize_request(r, rc);
return;
@@ -837,13 +846,7 @@ ngx_http_upstream_cache(ngx_http_request

case NGX_OK:

- rc = ngx_http_upstream_cache_send(r, u);
-
- if (rc != NGX_HTTP_UPSTREAM_INVALID_HEADER) {
- return rc;
- }
-
- break;
+ return NGX_OK;

case NGX_HTTP_CACHE_STALE:


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

[nginx] Upstream: fixed cache send error handling.

Roman Arutyunyan 639 September 03, 2015 08:14AM



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

Online Users

Guests: 177
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