aboutsummaryrefslogtreecommitdiff
path: root/src/event/quic/ngx_event_quic_ack.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/event/quic/ngx_event_quic_ack.c')
-rw-r--r--src/event/quic/ngx_event_quic_ack.c54
1 files changed, 42 insertions, 12 deletions
diff --git a/src/event/quic/ngx_event_quic_ack.c b/src/event/quic/ngx_event_quic_ack.c
index 4616e7053..29c5bfed1 100644
--- a/src/event/quic/ngx_event_quic_ack.c
+++ b/src/event/quic/ngx_event_quic_ack.c
@@ -41,6 +41,7 @@ static ngx_int_t ngx_quic_detect_lost(ngx_connection_t *c,
ngx_quic_ack_stat_t *st);
static ngx_msec_t ngx_quic_pcg_duration(ngx_connection_t *c);
static void ngx_quic_persistent_congestion(ngx_connection_t *c);
+static ngx_msec_t ngx_quic_oldest_sent_packet(ngx_connection_t *c);
static void ngx_quic_congestion_lost(ngx_connection_t *c,
ngx_quic_frame_t *frame);
static void ngx_quic_lost_handler(ngx_event_t *ev);
@@ -335,6 +336,14 @@ ngx_quic_congestion_ack(ngx_connection_t *c, ngx_quic_frame_t *f)
cg->in_flight -= f->plen;
+ /* prevent recovery_start from wrapping */
+
+ timer = now - cg->recovery_start;
+
+ if ((ngx_msec_int_t) timer < 0) {
+ cg->recovery_start = ngx_quic_oldest_sent_packet(c) - 1;
+ }
+
timer = f->send_time - cg->recovery_start;
if ((ngx_msec_int_t) timer <= 0) {
@@ -360,14 +369,6 @@ ngx_quic_congestion_ack(ngx_connection_t *c, ngx_quic_frame_t *f)
now, cg->window, cg->in_flight);
}
- /* prevent recovery_start from wrapping */
-
- timer = cg->recovery_start - now + qc->tp.max_idle_timeout * 2;
-
- if ((ngx_msec_int_t) timer < 0) {
- cg->recovery_start = now - qc->tp.max_idle_timeout * 2;
- }
-
done:
if (blocked && cg->in_flight < cg->window) {
@@ -543,19 +544,48 @@ ngx_quic_pcg_duration(ngx_connection_t *c)
static void
ngx_quic_persistent_congestion(ngx_connection_t *c)
{
- ngx_msec_t now;
ngx_quic_congestion_t *cg;
ngx_quic_connection_t *qc;
qc = ngx_quic_get_connection(c);
cg = &qc->congestion;
- now = ngx_current_msec;
- cg->recovery_start = now;
+ cg->recovery_start = ngx_quic_oldest_sent_packet(c) - 1;
cg->window = qc->path->mtu * 2;
ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0,
- "quic congestion persistent t:%M win:%uz", now, cg->window);
+ "quic congestion persistent t:%M win:%uz",
+ ngx_current_msec, cg->window);
+}
+
+
+static ngx_msec_t
+ngx_quic_oldest_sent_packet(ngx_connection_t *c)
+{
+ ngx_msec_t oldest;
+ ngx_uint_t i;
+ ngx_queue_t *q;
+ ngx_quic_frame_t *start;
+ ngx_quic_send_ctx_t *ctx;
+ ngx_quic_connection_t *qc;
+
+ qc = ngx_quic_get_connection(c);
+ oldest = ngx_current_msec;
+
+ for (i = 0; i < NGX_QUIC_SEND_CTX_LAST; i++) {
+ ctx = &qc->send_ctx[i];
+
+ if (!ngx_queue_empty(&ctx->sent)) {
+ q = ngx_queue_head(&ctx->sent);
+ start = ngx_queue_data(q, ngx_quic_frame_t, queue);
+
+ if ((ngx_msec_int_t) (start->send_time - oldest) < 0) {
+ oldest = start->send_time;
+ }
+ }
+ }
+
+ return oldest;
}