[nginx] Request body: logging of timeouts.

Maxim Dounin mdounin at mdounin.ru
Sat Apr 27 15:56:46 UTC 2024


details:   http://freenginx.org/hg/nginx/rev/208a4adb82ef
branches:  
changeset: 9255:208a4adb82ef
user:      Maxim Dounin <mdounin at mdounin.ru>
date:      Sat Apr 27 18:19:27 2024 +0300
description:
Request body: logging of timeouts.

diffstat:

 src/http/ngx_http_request_body.c  |  4 ++++
 src/http/ngx_http_upstream.c      |  1 +
 src/http/v2/ngx_http_v2.c         |  3 +++
 src/http/v3/ngx_http_v3_request.c |  4 ++++
 4 files changed, 12 insertions(+), 0 deletions(-)

diffs (66 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
@@ -262,6 +262,8 @@ ngx_http_read_unbuffered_request_body(ng
 #endif
 
     if (r->connection->read->timedout) {
+        ngx_log_error(NGX_LOG_INFO, r->connection->log, NGX_ETIMEDOUT,
+                      "client timed out");
         r->connection->timedout = 1;
         return NGX_HTTP_REQUEST_TIME_OUT;
     }
@@ -282,6 +284,8 @@ ngx_http_read_client_request_body_handle
     ngx_int_t  rc;
 
     if (r->connection->read->timedout) {
+        ngx_log_error(NGX_LOG_INFO, r->connection->log, NGX_ETIMEDOUT,
+                      "client timed out");
         r->connection->timedout = 1;
         ngx_http_finalize_request(r, NGX_HTTP_REQUEST_TIME_OUT);
         return;
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
@@ -2361,6 +2361,7 @@ ngx_http_upstream_read_request_handler(n
 
     if (c->read->timedout) {
         c->timedout = 1;
+        ngx_connection_error(c, NGX_ETIMEDOUT, "client timed out");
         ngx_http_upstream_finalize_request(r, u, NGX_HTTP_REQUEST_TIME_OUT);
         return;
     }
diff --git a/src/http/v2/ngx_http_v2.c b/src/http/v2/ngx_http_v2.c
--- a/src/http/v2/ngx_http_v2.c
+++ b/src/http/v2/ngx_http_v2.c
@@ -4285,6 +4285,9 @@ ngx_http_v2_read_unbuffered_request_body
 
     if (fc->read->timedout) {
         if (stream->recv_window) {
+            ngx_log_error(NGX_LOG_INFO, fc->log, NGX_ETIMEDOUT,
+                          "client timed out");
+
             stream->skip_data = 1;
             fc->timedout = 1;
 
diff --git a/src/http/v3/ngx_http_v3_request.c b/src/http/v3/ngx_http_v3_request.c
--- a/src/http/v3/ngx_http_v3_request.c
+++ b/src/http/v3/ngx_http_v3_request.c
@@ -1281,6 +1281,8 @@ ngx_http_v3_read_client_request_body_han
     ngx_int_t  rc;
 
     if (r->connection->read->timedout) {
+        ngx_log_error(NGX_LOG_INFO, r->connection->log, NGX_ETIMEDOUT,
+                      "client timed out");
         r->connection->timedout = 1;
         ngx_http_finalize_request(r, NGX_HTTP_REQUEST_TIME_OUT);
         return;
@@ -1300,6 +1302,8 @@ ngx_http_v3_read_unbuffered_request_body
     ngx_int_t  rc;
 
     if (r->connection->read->timedout) {
+        ngx_log_error(NGX_LOG_INFO, r->connection->log, NGX_ETIMEDOUT,
+                      "client timed out");
         r->connection->timedout = 1;
         return NGX_HTTP_REQUEST_TIME_OUT;
     }



More information about the nginx-devel mailing list