[PATCH 09 of 12] gRPC: reinitialization of ping and settings limits

Maxim Dounin mdounin at mdounin.ru
Fri Aug 8 20:09:04 UTC 2025


# HG changeset patch
# User Maxim Dounin <mdounin at mdounin.ru>
# Date 1754683261 -10800
#      Fri Aug 08 23:01:01 2025 +0300
# Node ID e7b982e718785a517c34ffee9422ae9db3230e82
# Parent  9c5a58441dc9fd62280681e7f92b74b4e69e5104
gRPC: reinitialization of ping and settings limits.

Allocations for PING and SETTINGS frames were limited in 7379:57463f4e2fcd
to prevent potential excessive memory usage due to misbehaving upstream
servers.  The limit as implemented applies to all interactions with all
upstream servers within an upstream, that is, if the limit is reached,
switching to the next upstream server is likely to hit the limit again
on the next PING (or SETTINGS) frame.  This is believed to be incorrect:
other upstream servers shouldn't be responsible for misbehaviour of the
previous one, and only allocations within a particular connection should
be limited.

Fix is to reset limits on request reinitialization.

diff --git a/src/http/modules/ngx_http_grpc_module.c b/src/http/modules/ngx_http_grpc_module.c
--- a/src/http/modules/ngx_http_grpc_module.c
+++ b/src/http/modules/ngx_http_grpc_module.c
@@ -1216,6 +1216,8 @@ ngx_http_grpc_reinit_request(ngx_http_re
     ctx->rst = 0;
     ctx->goaway = 0;
     ctx->connection = NULL;
+    ctx->pings = 0;
+    ctx->settings = 0;
 
     return NGX_OK;
 }



More information about the nginx-devel mailing list