changeset 9237:41db21d1ca7c

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.
author Maxim Dounin <mdounin@mdounin.ru>
date Sat, 30 Mar 2024 05:06:15 +0300
parents d9a52ebb9b00
children 392e8e2fd22a
files src/http/ngx_http_upstream.c
diffstat 1 files changed, 6 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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