comparison src/http/ngx_http_upstream.c @ 7260:08f114ed5449

Upstream: fixed u->conf->preserve_output (ticket #1519). Previously, ngx_http_upstream_process_header() might be called after we've finished reading response headers and switched to a different read event handler, leading to errors with gRPC proxying. Additionally, the u->conf->read_timeout timer might be re-armed during reading response headers (while this is expected to be a single timeout on reading the whole response header).
author Maxim Dounin <mdounin@mdounin.ru>
date Thu, 05 Apr 2018 16:56:12 +0300
parents 4db4fe3bdeda
children a10e5fe44762
comparison
equal deleted inserted replaced
7259:8ce771bf9260 7260:08f114ed5449
2011 return; 2011 return;
2012 } 2012 }
2013 2013
2014 /* rc == NGX_OK */ 2014 /* rc == NGX_OK */
2015 2015
2016 u->request_body_sent = 1;
2017
2018 if (c->write->timer_set) { 2016 if (c->write->timer_set) {
2019 ngx_del_timer(c->write); 2017 ngx_del_timer(c->write);
2020 } 2018 }
2021 2019
2022 if (c->tcp_nopush == NGX_TCP_NOPUSH_SET) { 2020 if (c->tcp_nopush == NGX_TCP_NOPUSH_SET) {
2039 ngx_http_upstream_finalize_request(r, u, 2037 ngx_http_upstream_finalize_request(r, u,
2040 NGX_HTTP_INTERNAL_SERVER_ERROR); 2038 NGX_HTTP_INTERNAL_SERVER_ERROR);
2041 return; 2039 return;
2042 } 2040 }
2043 2041
2044 ngx_add_timer(c->read, u->conf->read_timeout); 2042 if (!u->request_body_sent) {
2045 2043 u->request_body_sent = 1;
2046 if (c->read->ready) { 2044
2047 ngx_http_upstream_process_header(r, u); 2045 if (u->header_sent) {
2048 return; 2046 return;
2047 }
2048
2049 ngx_add_timer(c->read, u->conf->read_timeout);
2050
2051 if (c->read->ready) {
2052 ngx_http_upstream_process_header(r, u);
2053 return;
2054 }
2049 } 2055 }
2050 } 2056 }
2051 2057
2052 2058
2053 static ngx_int_t 2059 static ngx_int_t