summaryrefslogtreecommitdiffhomepage
path: root/src/event/quic/ngx_event_quic_ack.c
diff options
context:
space:
mode:
authorRoman Arutyunyan <arut@nginx.com>2021-07-29 12:49:16 +0300
committerRoman Arutyunyan <arut@nginx.com>2021-07-29 12:49:16 +0300
commit7a8fa1182812cd2408f2fe404b3ec6de35b9299c (patch)
tree8e15ac61c72bbd6eb6862e8dba065024b1f37b18 /src/event/quic/ngx_event_quic_ack.c
parentcc3752ce8e7d2ff93df3da054cec2cccbbcfe260 (diff)
downloadnginx-7a8fa1182812cd2408f2fe404b3ec6de35b9299c.tar.gz
nginx-7a8fa1182812cd2408f2fe404b3ec6de35b9299c.tar.bz2
QUIC: limit in-flight bytes by congestion window.
Previously, in-flight byte counter and congestion window were properly maintained, but the limit was not properly implemented. Now a new datagram is sent only if in-flight byte counter is less than window. The limit is datagram-based, which means that a single datagram may lead to exceeding the limit, but the next one will not be sent.
Diffstat (limited to 'src/event/quic/ngx_event_quic_ack.c')
-rw-r--r--src/event/quic/ngx_event_quic_ack.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/event/quic/ngx_event_quic_ack.c b/src/event/quic/ngx_event_quic_ack.c
index 06205c1ba..3e4bb6d4f 100644
--- a/src/event/quic/ngx_event_quic_ack.c
+++ b/src/event/quic/ngx_event_quic_ack.c
@@ -293,6 +293,7 @@ ngx_quic_handle_ack_frame_range(ngx_connection_t *c, ngx_quic_send_ctx_t *ctx,
void
ngx_quic_congestion_ack(ngx_connection_t *c, ngx_quic_frame_t *f)
{
+ ngx_uint_t blocked;
ngx_msec_t timer;
ngx_quic_congestion_t *cg;
ngx_quic_connection_t *qc;
@@ -304,6 +305,8 @@ ngx_quic_congestion_ack(ngx_connection_t *c, ngx_quic_frame_t *f)
qc = ngx_quic_get_connection(c);
cg = &qc->congestion;
+ blocked = (cg->in_flight >= cg->window) ? 1 : 0;
+
cg->in_flight -= f->plen;
timer = f->last - cg->recovery_start;
@@ -313,7 +316,7 @@ ngx_quic_congestion_ack(ngx_connection_t *c, ngx_quic_frame_t *f)
"quic congestion ack recovery win:%uz ss:%z if:%uz",
cg->window, cg->ssthresh, cg->in_flight);
- return;
+ goto done;
}
if (cg->window < cg->ssthresh) {
@@ -338,6 +341,12 @@ ngx_quic_congestion_ack(ngx_connection_t *c, ngx_quic_frame_t *f)
if ((ngx_msec_int_t) timer < 0) {
cg->recovery_start = ngx_current_msec - qc->tp.max_idle_timeout * 2;
}
+
+done:
+
+ if (blocked && cg->in_flight < cg->window) {
+ ngx_post_event(&qc->push, &ngx_posted_events);
+ }
}
@@ -620,6 +629,7 @@ ngx_quic_resend_frames(ngx_connection_t *c, ngx_quic_send_ctx_t *ctx)
static void
ngx_quic_congestion_lost(ngx_connection_t *c, ngx_quic_frame_t *f)
{
+ ngx_uint_t blocked;
ngx_msec_t timer;
ngx_quic_congestion_t *cg;
ngx_quic_connection_t *qc;
@@ -631,6 +641,8 @@ ngx_quic_congestion_lost(ngx_connection_t *c, ngx_quic_frame_t *f)
qc = ngx_quic_get_connection(c);
cg = &qc->congestion;
+ blocked = (cg->in_flight >= cg->window) ? 1 : 0;
+
cg->in_flight -= f->plen;
f->plen = 0;
@@ -641,7 +653,7 @@ ngx_quic_congestion_lost(ngx_connection_t *c, ngx_quic_frame_t *f)
"quic congestion lost recovery win:%uz ss:%z if:%uz",
cg->window, cg->ssthresh, cg->in_flight);
- return;
+ goto done;
}
cg->recovery_start = ngx_current_msec;
@@ -656,6 +668,12 @@ ngx_quic_congestion_lost(ngx_connection_t *c, ngx_quic_frame_t *f)
ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0,
"quic congestion lost win:%uz ss:%z if:%uz",
cg->window, cg->ssthresh, cg->in_flight);
+
+done:
+
+ if (blocked && cg->in_flight < cg->window) {
+ ngx_post_event(&qc->push, &ngx_posted_events);
+ }
}