Previously, such frames were not accounted as in-flight, and they were not
stored in sent queue.  This prevented proper PTO calculation and ACK handling.


 src/event/quic/ngx_event_quic_ack.c |  62 +++++++++++++++++++++++++-----------
 1 files changed, 43 insertions(+), 19 deletions(-)


# HG changeset patch
# User Vladimir Khomutov <v...@wbsrv.ru>
# Date 1703154552 -10800
#      Thu Dec 21 13:29:12 2023 +0300
# Node ID 5ea917e44e03e88a2b6bc935510839a5a14e5dae
# Parent  cc16989c6d61385027c1ebfd43929f8369fa5f62
QUIC: fixed accounting of in-flight PING frames.

Previously, such frames were not accounted as in-flight, and they were not
stored in sent queue.  This prevented proper PTO calculation and ACK handling.

diff --git a/src/event/quic/ngx_event_quic_ack.c b/src/event/quic/ngx_event_quic_ack.c
--- a/src/event/quic/ngx_event_quic_ack.c
+++ b/src/event/quic/ngx_event_quic_ack.c
@@ -1,5 +1,6 @@
 
 /*
+ * Copyright (C) 2023 Web Server LLC
  * Copyright (C) Nginx, Inc.
  */
 
@@ -43,6 +44,8 @@ static ngx_msec_t ngx_quic_pcg_duration(
 static void ngx_quic_persistent_congestion(ngx_connection_t *c);
 static void ngx_quic_congestion_lost(ngx_connection_t *c,
     ngx_quic_frame_t *frame);
+static ngx_int_t ngx_quic_ping_peer(ngx_connection_t *c,
+    ngx_quic_send_ctx_t *ctx);
 static void ngx_quic_lost_handler(ngx_event_t *ev);
 
 
@@ -834,7 +837,7 @@ void ngx_quic_lost_handler(ngx_event_t *
 void
 ngx_quic_pto_handler(ngx_event_t *ev)
 {
-    ngx_uint_t              i, n;
+    ngx_uint_t              i;
     ngx_msec_t              now;
     ngx_queue_t            *q;
     ngx_msec_int_t          w;
@@ -876,20 +879,9 @@ ngx_quic_pto_handler(ngx_event_t *ev)
                        "quic pto %s pto_count:%ui",
                        ngx_quic_level_name(ctx->level), qc->pto_count);
 
-        for (n = 0; n < 2; n++) {
-
-            f = ngx_quic_alloc_frame(c);
-            if (f == NULL) {
-                goto failed;
-            }
-
-            f->level = ctx->level;
-            f->type = NGX_QUIC_FT_PING;
-            f->ignore_congestion = 1;
-
-            if (ngx_quic_frame_sendto(c, f, 0, qc->path) == NGX_ERROR) {
-                goto failed;
-            }
+        if (ngx_quic_ping_peer(c, ctx) != NGX_OK) {
+            ngx_quic_close_connection(c, NGX_ERROR);
+            return;
         }
     }
 
@@ -898,13 +890,45 @@ ngx_quic_pto_handler(ngx_event_t *ev)
     ngx_quic_set_lost_timer(c);
 
     ngx_quic_connstate_dbg(c);
+}
 
-    return;
+
+static ngx_int_t
+ngx_quic_ping_peer(ngx_connection_t *c, ngx_quic_send_ctx_t *ctx)
+{
+    ngx_uint_t              i;
+    ngx_quic_frame_t       *f;
+    ngx_quic_congestion_t  *cg;
+    ngx_quic_connection_t  *qc;
+
+    qc = ngx_quic_get_connection(c);
+
+    cg = &qc->congestion;
+
+    for (i = 0; i < 2; i++) {
 
-failed:
+        f = ngx_quic_alloc_frame(c);
+        if (f == NULL) {
+            return NGX_ERROR;
+        }
+
+        f->level = ctx->level;
+        f->type = NGX_QUIC_FT_PING;
+        f->ignore_congestion = 1;
+        f->len = ngx_quic_create_frame(NULL, f);
 
-    ngx_quic_close_connection(c, NGX_ERROR);
-    return;
+        if (ngx_quic_frame_sendto(c, f, 0, qc->path) != NGX_OK) {
+            return NGX_ERROR;
+        }
+
+        ngx_queue_insert_tail(&ctx->sent, &f->queue);
+        cg->in_flight += f->plen;
+    }
+
+    ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0,
+                   "quic congestion send if:%uz", cg->in_flight);
+
+    return NGX_OK;
 }
 
 
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
https://mailman.nginx.org/mailman/listinfo/nginx-devel

Reply via email to