[PATCH 05 of 10] Upstream: improved c->read->ready flag handling
Maxim Dounin
mdounin at mdounin.ru
Fri Mar 15 18:14:19 UTC 2024
# HG changeset patch
# User Maxim Dounin <mdounin at mdounin.ru>
# Date 1710526248 -10800
# Fri Mar 15 21:10:48 2024 +0300
# Node ID 74525610a3b6d8d69f7e0082552494a889aa858e
# Parent c2e67d39c6daab0c67b68aaa199f42975c37d676
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.
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