comparison 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
comparison
equal deleted inserted replaced
8781:81d491f0dc8c 8782:b3f6ad181df4
263 } 263 }
264 264
265 qc->send_ctx[0].level = ssl_encryption_initial; 265 qc->send_ctx[0].level = ssl_encryption_initial;
266 qc->send_ctx[1].level = ssl_encryption_handshake; 266 qc->send_ctx[1].level = ssl_encryption_handshake;
267 qc->send_ctx[2].level = ssl_encryption_application; 267 qc->send_ctx[2].level = ssl_encryption_application;
268
269 for (i = 0; i < NGX_QUIC_ENCRYPTION_LAST; i++) {
270 ngx_queue_init(&qc->crypto[i].frames);
271 }
272 268
273 ngx_queue_init(&qc->free_frames); 269 ngx_queue_init(&qc->free_frames);
274 270
275 qc->avg_rtt = NGX_QUIC_INITIAL_RTT; 271 qc->avg_rtt = NGX_QUIC_INITIAL_RTT;
276 qc->rttvar = NGX_QUIC_INITIAL_RTT / 2; 272 qc->rttvar = NGX_QUIC_INITIAL_RTT / 2;
1020 1016
1021 qc->pto_count = 0; 1017 qc->pto_count = 0;
1022 1018
1023 ctx = ngx_quic_get_send_ctx(qc, level); 1019 ctx = ngx_quic_get_send_ctx(qc, level);
1024 1020
1021 ngx_quic_free_bufs(c, ctx->crypto);
1022
1025 while (!ngx_queue_empty(&ctx->sent)) { 1023 while (!ngx_queue_empty(&ctx->sent)) {
1026 q = ngx_queue_head(&ctx->sent); 1024 q = ngx_queue_head(&ctx->sent);
1027 ngx_queue_remove(q); 1025 ngx_queue_remove(q);
1028 1026
1029 f = ngx_queue_data(q, ngx_quic_frame_t, queue); 1027 f = ngx_queue_data(q, ngx_quic_frame_t, queue);