[nginx] Request body: explicit handling of NGX_AGAIN.
Maxim Dounin
mdounin at mdounin.ru
Sat Mar 30 04:59:46 UTC 2024
details: http://freenginx.org/hg/nginx/rev/392e8e2fd22a
branches:
changeset: 9238:392e8e2fd22a
user: Maxim Dounin <mdounin at mdounin.ru>
date: Sat Mar 30 05:06:59 2024 +0300
description:
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.
diffstat:
src/http/ngx_http_request_body.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diffs (20 lines):
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