]> git.kaiwu.me - nginx.git/commitdiff
QUIC: fixed in-flight bytes accounting.
authorVladimir Homutov <vl@nginx.com>
Wed, 9 Feb 2022 12:51:42 +0000 (15:51 +0300)
committerVladimir Homutov <vl@nginx.com>
Wed, 9 Feb 2022 12:51:42 +0000 (15:51 +0300)
Initially, frames are genereated and stored in ctx->frames.
Next, ngx_quic_output() collects frames to be sent in in ctx->sending.
On failure, ngx_quic_revert_sned() returns frames into ctx->frames.

On success, the ngx_quic_commit_send() moves ack-eliciting frames into
ctx->sent and frees non-ack-eliciting frames.
This function also updates in-flight bytes counter, so only actually sent
frames are accounted.

The counter is decremented in the following cases:
 - acknowledgment is received
 - packet was declared lost
 - we are discarding context completely

In each of this cases frame is removed from ctx->sent queue and in-flight
counter is accordingly decremented.

The patch fixes the case of discarding context - only removing frames
from ctx->sent must be followed by in-flight bytes counter decrement,
otherwise cg->in_flight could experience type underflow.

The issue appeared in b1676cd64dc9.

src/event/quic/ngx_event_quic.c

index 2a51c79a76410ce3014d46f2d9c74ea51f387354..66f63fe0e949b9f46c8c7321dbbda816dd8dbfe0 100644 (file)
@@ -1092,7 +1092,6 @@ ngx_quic_discard_ctx(ngx_connection_t *c, enum ssl_encryption_level_t level)
         ngx_queue_remove(q);
 
         f = ngx_queue_data(q, ngx_quic_frame_t, queue);
-        ngx_quic_congestion_ack(c, f);
         ngx_quic_free_frame(c, f);
     }