diff src/event/quic/ngx_event_quic.c @ 8782:b3f6ad181df4 quic

QUIC: refactored CRYPTO and STREAM buffer ordering. Generic function ngx_quic_order_bufs() is introduced. This function creates and maintains a chain of buffers with holes. Holes are marked with b->sync flag. Several buffers and holes in this chain may share the same underlying memory buffer. When processing STREAM frames with this function, frame data is copied only once to the right place in the stream input chain. Previously data could be copied twice. First when buffering an out-of-order frame data, and then when filling stream buffer from ordered frame queue. Now there's only one data chain for both tasks.
author Roman Arutyunyan <arut@nginx.com>
date Tue, 25 May 2021 13:55:12 +0300
parents 5186ee5a94b9
children af33d1ef1c3c
line wrap: on
line diff
--- a/src/event/quic/ngx_event_quic.c
+++ b/src/event/quic/ngx_event_quic.c
@@ -266,10 +266,6 @@ ngx_quic_new_connection(ngx_connection_t
     qc->send_ctx[1].level = ssl_encryption_handshake;
     qc->send_ctx[2].level = ssl_encryption_application;
 
-    for (i = 0; i < NGX_QUIC_ENCRYPTION_LAST; i++) {
-        ngx_queue_init(&qc->crypto[i].frames);
-    }
-
     ngx_queue_init(&qc->free_frames);
 
     qc->avg_rtt = NGX_QUIC_INITIAL_RTT;
@@ -1022,6 +1018,8 @@ ngx_quic_discard_ctx(ngx_connection_t *c
 
     ctx = ngx_quic_get_send_ctx(qc, level);
 
+    ngx_quic_free_bufs(c, ctx->crypto);
+
     while (!ngx_queue_empty(&ctx->sent)) {
         q = ngx_queue_head(&ctx->sent);
         ngx_queue_remove(q);