view docs/text/LICENSE @ 6909:5850fed24639

Upstream: read handler cleared on upstream finalization. With "proxy_ignore_client_abort off" (the default), upstream module changes r->read_event_handler to ngx_http_upstream_rd_check_broken_connection(). If the handler is not cleared during upstream finalization, it can be triggered later, causing unexpected effects, if, for example, a request was redirected to a different location using error_page or X-Accel-Redirect. In particular, it makes "proxy_ignore_client_abort on" non-working after a redirection in a configuration like this: location = / { error_page 502 = /error; proxy_pass http://127.0.0.1:8082; } location /error { proxy_pass http://127.0.0.1:8083; proxy_ignore_client_abort on; } It is also known to cause segmentation faults with aio used, see http://mailman.nginx.org/pipermail/nginx-ru/2015-August/056570.html. Fix is to explicitly set r->read_event_handler to ngx_http_block_reading() during upstream finalization, similar to how it is done in the request body reading code and in the limit_req module.
author Maxim Dounin <mdounin@mdounin.ru>
date Fri, 10 Feb 2017 20:24:26 +0300
parents 8c4d07ef08f5
children c6cc8db553eb
line wrap: on
line source

/* 
 * Copyright (C) 2002-2017 Igor Sysoev
 * Copyright (C) 2011-2017 Nginx, Inc.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 */