diff options
| author | Maxim Dounin <mdounin@mdounin.ru> | 2018-04-05 16:56:12 +0300 |
|---|---|---|
| committer | Maxim Dounin <mdounin@mdounin.ru> | 2018-04-05 16:56:12 +0300 |
| commit | f9e43a31544bb67f24703e1dad91ea51f49c7a16 (patch) | |
| tree | b7bcbda7f08ecc517f6b2bcf2d6166effc80d752 | |
| parent | 923c9d5f3b09c54ebbd841c2e36a8997b1430207 (diff) | |
| download | nginx-f9e43a31544bb67f24703e1dad91ea51f49c7a16.tar.gz nginx-f9e43a31544bb67f24703e1dad91ea51f49c7a16.tar.bz2 | |
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).
| -rw-r--r-- | src/http/ngx_http_upstream.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c index a415f58e3..8fc3042e7 100644 --- a/src/http/ngx_http_upstream.c +++ b/src/http/ngx_http_upstream.c @@ -2013,8 +2013,6 @@ ngx_http_upstream_send_request(ngx_http_request_t *r, ngx_http_upstream_t *u, /* rc == NGX_OK */ - u->request_body_sent = 1; - if (c->write->timer_set) { ngx_del_timer(c->write); } @@ -2041,11 +2039,19 @@ ngx_http_upstream_send_request(ngx_http_request_t *r, ngx_http_upstream_t *u, return; } - ngx_add_timer(c->read, u->conf->read_timeout); + if (!u->request_body_sent) { + u->request_body_sent = 1; - if (c->read->ready) { - ngx_http_upstream_process_header(r, u); - return; + if (u->header_sent) { + return; + } + + ngx_add_timer(c->read, u->conf->read_timeout); + + if (c->read->ready) { + ngx_http_upstream_process_header(r, u); + return; + } } } |
