From 14f073abf2f6c5f96d5245a83cefa48778a196a7 Mon Sep 17 00:00:00 2001 From: nandsky Date: Sat, 9 May 2026 15:11:34 +0800 Subject: [PATCH] QUIC: fixed congestion window check in ngx_quic_allow_segmentation(). QUIC segmentation could be skipped when f->len exceeds 3 * mtu and the available congestion window is between 3 * mtu and f->len, because accumulated queued bytes were checked before the batching threshold. --- src/event/quic/ngx_event_quic_output.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/event/quic/ngx_event_quic_output.c b/src/event/quic/ngx_event_quic_output.c index f98c834a1..c1d07650f 100644 --- a/src/event/quic/ngx_event_quic_output.c +++ b/src/event/quic/ngx_event_quic_output.c @@ -310,6 +310,10 @@ ngx_quic_allow_segmentation(ngx_connection_t *c) bytes = 0; len = ngx_min(qc->path->mtu, NGX_QUIC_MAX_UDP_SEGMENT_BUF); + if (qc->congestion.in_flight + len * 3 >= qc->congestion.window) { + return 0; + } + for (q = ngx_queue_head(&ctx->frames); q != ngx_queue_sentinel(&ctx->frames); q = ngx_queue_next(q)) @@ -318,10 +322,6 @@ ngx_quic_allow_segmentation(ngx_connection_t *c) bytes += f->len; - if (qc->congestion.in_flight + bytes >= qc->congestion.window) { - return 0; - } - if (bytes > len * 3) { /* require at least ~3 full packets to batch */ return 1;