[nginx] Upstream: improved c->read->ready flag handling.
Maxim Dounin
mdounin at mdounin.ru
Sat Mar 30 04:59:46 UTC 2024
details: http://freenginx.org/hg/nginx/rev/41db21d1ca7c
branches:
changeset: 9237:41db21d1ca7c
user: Maxim Dounin <mdounin at mdounin.ru>
date: Sat Mar 30 05:06:15 2024 +0300
description:
Upstream: improved c->read->ready flag handling.
Previously, reading the upstream response headers did not check the
c->read->ready flag. Now the flag is checked.
This ensures that ev->available checks as introduced in 7583:efd71d49bde0
and 7584:9d2ad2fb4423 will be able to prevent reading from the socket
when using event methods other than kqueue or epoll, and when using SSL.
This might be important to avoid looping for a long time when working
with fast upstream servers over protocols where large chunks of data can
be skipped while reading response headers, notably FastCGI and gRPC.
diffstat:
src/http/ngx_http_upstream.c | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
diffs (17 lines):
diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c
--- a/src/http/ngx_http_upstream.c
+++ b/src/http/ngx_http_upstream.c
@@ -2437,7 +2437,12 @@ ngx_http_upstream_process_header(ngx_htt
for ( ;; ) {
- n = c->recv(c, u->buffer.last, u->buffer.end - u->buffer.last);
+ if (c->read->ready) {
+ n = c->recv(c, u->buffer.last, u->buffer.end - u->buffer.last);
+
+ } else {
+ n = NGX_AGAIN;
+ }
if (n == NGX_AGAIN) {
#if 0
More information about the nginx-devel
mailing list