[PATCH 06 of 10] Request body: explicit handling of NGX_AGAIN
Maxim Dounin
mdounin at mdounin.ru
Fri Mar 15 18:14:20 UTC 2024
# HG changeset patch
# User Maxim Dounin <mdounin at mdounin.ru>
# Date 1710526250 -10800
# Fri Mar 15 21:10:50 2024 +0300
# Node ID 3cd5f5e21b771ba547097e729642cf568ac49932
# Parent 74525610a3b6d8d69f7e0082552494a889aa858e
Request body: explicit handling of NGX_AGAIN.
Request body reading indirectly uses the "do { c->recv() } while
(c->read->ready)" form, which is not really correct, as for example
with SSL c->read->ready may be still set when c->recv() returns NGX_AGAIN
due to SSL_ERROR_WANT_WRITE (see 7351:2b5528023f6b), and therefore this
form might be an infinite loop.
Added explicit NGX_AGAIN handling for the sake of correctness.
diff --git a/src/http/ngx_http_request_body.c b/src/http/ngx_http_request_body.c
--- a/src/http/ngx_http_request_body.c
+++ b/src/http/ngx_http_request_body.c
@@ -307,6 +307,7 @@ ngx_http_do_read_client_request_body(ngx
c = r->connection;
rb = r->request_body;
flush = 1;
+ n = NGX_AGAIN;
ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0,
"http read client request body");
@@ -432,7 +433,7 @@ ngx_http_do_read_client_request_body(ngx
break;
}
- if (!c->read->ready || rb->rest == 0) {
+ if (n == NGX_AGAIN || !c->read->ready || rb->rest == 0) {
clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
ngx_add_timer(c->read, clcf->client_body_timeout);
More information about the nginx-devel
mailing list