[nginx] Event pipe: process data after recv_chain() errors.

Maxim Dounin mdounin at mdounin.ru
Thu Sep 1 15:31:01 UTC 2016

details:   http://hg.nginx.org/nginx/rev/0fa883e92895
changeset: 6672:0fa883e92895
user:      Maxim Dounin <mdounin at mdounin.ru>
date:      Thu Sep 01 18:29:55 2016 +0300
Event pipe: process data after recv_chain() errors.

When c->recv_chain() returns an error, it is possible that we already
have some data previously read, e.g., in preread buffer.  And in some
cases it may be even a complete response.  Changed c->recv_chain() error
handling to process the data, much like it is already done if kevent
reports about an error.

This change, in particular, fixes processing of small responses
when an upstream fails to properly close a connection with lingering and
therefore the connection is reset, but the response is already fully
obtained by nginx (see ticket #1037).


 src/event/ngx_event_pipe.c |  2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diffs (12 lines):

diff --git a/src/event/ngx_event_pipe.c b/src/event/ngx_event_pipe.c
--- a/src/event/ngx_event_pipe.c
+++ b/src/event/ngx_event_pipe.c
@@ -300,7 +300,7 @@ ngx_event_pipe_read_upstream(ngx_event_p
             if (n == NGX_ERROR) {
                 p->upstream_error = 1;
-                return NGX_ERROR;
+                break;
             if (n == NGX_AGAIN) {

More information about the nginx-devel mailing list