Mercurial > hg > nginx-quic
annotate src/event/quic/ngx_event_quic_frames.c @ 9028:0f4f781e57c1 quic
QUIC: using ngx_ssl_handshake_log().
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Thu, 23 Feb 2023 16:17:29 +0400 |
parents | def8e398d7c5 |
children | 8f2f40d3fd18 |
rev | line source |
---|---|
8409
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
2 /* |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
3 * Copyright (C) Nginx, Inc. |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
4 */ |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
5 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
6 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
7 #include <ngx_config.h> |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
8 #include <ngx_core.h> |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
9 #include <ngx_event.h> |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
10 #include <ngx_event_quic_connection.h> |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
11 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
12 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
13 #define NGX_QUIC_BUFFER_SIZE 4096 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
14 |
8763
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
15 #define ngx_quic_buf_refs(b) (b)->shadow->num |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
16 #define ngx_quic_buf_inc_refs(b) ngx_quic_buf_refs(b)++ |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
17 #define ngx_quic_buf_dec_refs(b) ngx_quic_buf_refs(b)-- |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
18 #define ngx_quic_buf_set_refs(b, v) ngx_quic_buf_refs(b) = v |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
19 |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
20 |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
21 static ngx_buf_t *ngx_quic_alloc_buf(ngx_connection_t *c); |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
22 static void ngx_quic_free_buf(ngx_connection_t *c, ngx_buf_t *b); |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
23 static ngx_buf_t *ngx_quic_clone_buf(ngx_connection_t *c, ngx_buf_t *b); |
8795
065c73221b7b
QUIC: introduced function ngx_quic_split_chain().
Roman Arutyunyan <arut@nginx.com>
parents:
8793
diff
changeset
|
24 static ngx_int_t ngx_quic_split_chain(ngx_connection_t *c, ngx_chain_t *cl, |
065c73221b7b
QUIC: introduced function ngx_quic_split_chain().
Roman Arutyunyan <arut@nginx.com>
parents:
8793
diff
changeset
|
25 off_t offset); |
8763
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
26 |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
27 |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
28 static ngx_buf_t * |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
29 ngx_quic_alloc_buf(ngx_connection_t *c) |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
30 { |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
31 u_char *p; |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
32 ngx_buf_t *b; |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
33 ngx_quic_connection_t *qc; |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
34 |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
35 qc = ngx_quic_get_connection(c); |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
36 |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
37 b = qc->free_bufs; |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
38 |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
39 if (b) { |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
40 qc->free_bufs = b->shadow; |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
41 p = b->start; |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
42 |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
43 } else { |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
44 b = qc->free_shadow_bufs; |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
45 |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
46 if (b) { |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
47 qc->free_shadow_bufs = b->shadow; |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
48 |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
49 #ifdef NGX_QUIC_DEBUG_ALLOC |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
50 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0, |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
51 "quic use shadow buffer n:%ui %ui", |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
52 ++qc->nbufs, --qc->nshadowbufs); |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
53 #endif |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
54 |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
55 } else { |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
56 b = ngx_palloc(c->pool, sizeof(ngx_buf_t)); |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
57 if (b == NULL) { |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
58 return NULL; |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
59 } |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
60 |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
61 #ifdef NGX_QUIC_DEBUG_ALLOC |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
62 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
63 "quic new buffer n:%ui", ++qc->nbufs); |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
64 #endif |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
65 } |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
66 |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
67 p = ngx_pnalloc(c->pool, NGX_QUIC_BUFFER_SIZE); |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
68 if (p == NULL) { |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
69 return NULL; |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
70 } |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
71 } |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
72 |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
73 #ifdef NGX_QUIC_DEBUG_ALLOC |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
74 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, "quic alloc buffer %p", b); |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
75 #endif |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
76 |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
77 ngx_memzero(b, sizeof(ngx_buf_t)); |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
78 |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
79 b->tag = (ngx_buf_tag_t) &ngx_quic_alloc_buf; |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
80 b->temporary = 1; |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
81 b->shadow = b; |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
82 |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
83 b->start = p; |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
84 b->pos = p; |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
85 b->last = p; |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
86 b->end = p + NGX_QUIC_BUFFER_SIZE; |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
87 |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
88 ngx_quic_buf_set_refs(b, 1); |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
89 |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
90 return b; |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
91 } |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
92 |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
93 |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
94 static void |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
95 ngx_quic_free_buf(ngx_connection_t *c, ngx_buf_t *b) |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
96 { |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
97 ngx_buf_t *shadow; |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
98 ngx_quic_connection_t *qc; |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
99 |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
100 qc = ngx_quic_get_connection(c); |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
101 |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
102 ngx_quic_buf_dec_refs(b); |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
103 |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
104 #ifdef NGX_QUIC_DEBUG_ALLOC |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
105 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0, |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
106 "quic free buffer %p r:%ui", |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
107 b, (ngx_uint_t) ngx_quic_buf_refs(b)); |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
108 #endif |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
109 |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
110 shadow = b->shadow; |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
111 |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
112 if (ngx_quic_buf_refs(b) == 0) { |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
113 shadow->shadow = qc->free_bufs; |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
114 qc->free_bufs = shadow; |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
115 } |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
116 |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
117 if (b != shadow) { |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
118 b->shadow = qc->free_shadow_bufs; |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
119 qc->free_shadow_bufs = b; |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
120 } |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
121 |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
122 } |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
123 |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
124 |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
125 static ngx_buf_t * |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
126 ngx_quic_clone_buf(ngx_connection_t *c, ngx_buf_t *b) |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
127 { |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
128 ngx_buf_t *nb; |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
129 ngx_quic_connection_t *qc; |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
130 |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
131 qc = ngx_quic_get_connection(c); |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
132 |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
133 nb = qc->free_shadow_bufs; |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
134 |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
135 if (nb) { |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
136 qc->free_shadow_bufs = nb->shadow; |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
137 |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
138 } else { |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
139 nb = ngx_palloc(c->pool, sizeof(ngx_buf_t)); |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
140 if (nb == NULL) { |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
141 return NULL; |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
142 } |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
143 |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
144 #ifdef NGX_QUIC_DEBUG_ALLOC |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
145 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
146 "quic new shadow buffer n:%ui", ++qc->nshadowbufs); |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
147 #endif |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
148 } |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
149 |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
150 *nb = *b; |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
151 |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
152 ngx_quic_buf_inc_refs(b); |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
153 |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
154 #ifdef NGX_QUIC_DEBUG_ALLOC |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
155 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0, |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
156 "quic clone buffer %p %p r:%ui", |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
157 b, nb, (ngx_uint_t) ngx_quic_buf_refs(b)); |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
158 #endif |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
159 |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
160 return nb; |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
161 } |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
162 |
8409
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
163 |
8795
065c73221b7b
QUIC: introduced function ngx_quic_split_chain().
Roman Arutyunyan <arut@nginx.com>
parents:
8793
diff
changeset
|
164 static ngx_int_t |
065c73221b7b
QUIC: introduced function ngx_quic_split_chain().
Roman Arutyunyan <arut@nginx.com>
parents:
8793
diff
changeset
|
165 ngx_quic_split_chain(ngx_connection_t *c, ngx_chain_t *cl, off_t offset) |
065c73221b7b
QUIC: introduced function ngx_quic_split_chain().
Roman Arutyunyan <arut@nginx.com>
parents:
8793
diff
changeset
|
166 { |
065c73221b7b
QUIC: introduced function ngx_quic_split_chain().
Roman Arutyunyan <arut@nginx.com>
parents:
8793
diff
changeset
|
167 ngx_buf_t *b, *tb; |
065c73221b7b
QUIC: introduced function ngx_quic_split_chain().
Roman Arutyunyan <arut@nginx.com>
parents:
8793
diff
changeset
|
168 ngx_chain_t *tail; |
065c73221b7b
QUIC: introduced function ngx_quic_split_chain().
Roman Arutyunyan <arut@nginx.com>
parents:
8793
diff
changeset
|
169 |
065c73221b7b
QUIC: introduced function ngx_quic_split_chain().
Roman Arutyunyan <arut@nginx.com>
parents:
8793
diff
changeset
|
170 b = cl->buf; |
065c73221b7b
QUIC: introduced function ngx_quic_split_chain().
Roman Arutyunyan <arut@nginx.com>
parents:
8793
diff
changeset
|
171 |
065c73221b7b
QUIC: introduced function ngx_quic_split_chain().
Roman Arutyunyan <arut@nginx.com>
parents:
8793
diff
changeset
|
172 tail = ngx_alloc_chain_link(c->pool); |
065c73221b7b
QUIC: introduced function ngx_quic_split_chain().
Roman Arutyunyan <arut@nginx.com>
parents:
8793
diff
changeset
|
173 if (tail == NULL) { |
065c73221b7b
QUIC: introduced function ngx_quic_split_chain().
Roman Arutyunyan <arut@nginx.com>
parents:
8793
diff
changeset
|
174 return NGX_ERROR; |
065c73221b7b
QUIC: introduced function ngx_quic_split_chain().
Roman Arutyunyan <arut@nginx.com>
parents:
8793
diff
changeset
|
175 } |
065c73221b7b
QUIC: introduced function ngx_quic_split_chain().
Roman Arutyunyan <arut@nginx.com>
parents:
8793
diff
changeset
|
176 |
065c73221b7b
QUIC: introduced function ngx_quic_split_chain().
Roman Arutyunyan <arut@nginx.com>
parents:
8793
diff
changeset
|
177 tb = ngx_quic_clone_buf(c, b); |
065c73221b7b
QUIC: introduced function ngx_quic_split_chain().
Roman Arutyunyan <arut@nginx.com>
parents:
8793
diff
changeset
|
178 if (tb == NULL) { |
065c73221b7b
QUIC: introduced function ngx_quic_split_chain().
Roman Arutyunyan <arut@nginx.com>
parents:
8793
diff
changeset
|
179 return NGX_ERROR; |
065c73221b7b
QUIC: introduced function ngx_quic_split_chain().
Roman Arutyunyan <arut@nginx.com>
parents:
8793
diff
changeset
|
180 } |
065c73221b7b
QUIC: introduced function ngx_quic_split_chain().
Roman Arutyunyan <arut@nginx.com>
parents:
8793
diff
changeset
|
181 |
065c73221b7b
QUIC: introduced function ngx_quic_split_chain().
Roman Arutyunyan <arut@nginx.com>
parents:
8793
diff
changeset
|
182 tail->buf = tb; |
065c73221b7b
QUIC: introduced function ngx_quic_split_chain().
Roman Arutyunyan <arut@nginx.com>
parents:
8793
diff
changeset
|
183 |
065c73221b7b
QUIC: introduced function ngx_quic_split_chain().
Roman Arutyunyan <arut@nginx.com>
parents:
8793
diff
changeset
|
184 tb->pos += offset; |
065c73221b7b
QUIC: introduced function ngx_quic_split_chain().
Roman Arutyunyan <arut@nginx.com>
parents:
8793
diff
changeset
|
185 |
065c73221b7b
QUIC: introduced function ngx_quic_split_chain().
Roman Arutyunyan <arut@nginx.com>
parents:
8793
diff
changeset
|
186 b->last = tb->pos; |
065c73221b7b
QUIC: introduced function ngx_quic_split_chain().
Roman Arutyunyan <arut@nginx.com>
parents:
8793
diff
changeset
|
187 b->last_buf = 0; |
065c73221b7b
QUIC: introduced function ngx_quic_split_chain().
Roman Arutyunyan <arut@nginx.com>
parents:
8793
diff
changeset
|
188 |
065c73221b7b
QUIC: introduced function ngx_quic_split_chain().
Roman Arutyunyan <arut@nginx.com>
parents:
8793
diff
changeset
|
189 tail->next = cl->next; |
065c73221b7b
QUIC: introduced function ngx_quic_split_chain().
Roman Arutyunyan <arut@nginx.com>
parents:
8793
diff
changeset
|
190 cl->next = tail; |
065c73221b7b
QUIC: introduced function ngx_quic_split_chain().
Roman Arutyunyan <arut@nginx.com>
parents:
8793
diff
changeset
|
191 |
065c73221b7b
QUIC: introduced function ngx_quic_split_chain().
Roman Arutyunyan <arut@nginx.com>
parents:
8793
diff
changeset
|
192 return NGX_OK; |
065c73221b7b
QUIC: introduced function ngx_quic_split_chain().
Roman Arutyunyan <arut@nginx.com>
parents:
8793
diff
changeset
|
193 } |
065c73221b7b
QUIC: introduced function ngx_quic_split_chain().
Roman Arutyunyan <arut@nginx.com>
parents:
8793
diff
changeset
|
194 |
065c73221b7b
QUIC: introduced function ngx_quic_split_chain().
Roman Arutyunyan <arut@nginx.com>
parents:
8793
diff
changeset
|
195 |
8409
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
196 ngx_quic_frame_t * |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
197 ngx_quic_alloc_frame(ngx_connection_t *c) |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
198 { |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
199 ngx_queue_t *q; |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
200 ngx_quic_frame_t *frame; |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
201 ngx_quic_connection_t *qc; |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
202 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
203 qc = ngx_quic_get_connection(c); |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
204 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
205 if (!ngx_queue_empty(&qc->free_frames)) { |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
206 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
207 q = ngx_queue_head(&qc->free_frames); |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
208 frame = ngx_queue_data(q, ngx_quic_frame_t, queue); |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
209 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
210 ngx_queue_remove(&frame->queue); |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
211 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
212 #ifdef NGX_QUIC_DEBUG_ALLOC |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
213 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
214 "quic reuse frame n:%ui", qc->nframes); |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
215 #endif |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
216 |
8645
404de224517e
QUIC: limited the total number of frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8545
diff
changeset
|
217 } else if (qc->nframes < 10000) { |
8504
6c213bec71c2
QUIC: fixed double memzero of new frames in ngx_quic_alloc_frame().
Sergey Kandaurov <pluknet@nginx.com>
parents:
8442
diff
changeset
|
218 frame = ngx_palloc(c->pool, sizeof(ngx_quic_frame_t)); |
8409
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
219 if (frame == NULL) { |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
220 return NULL; |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
221 } |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
222 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
223 ++qc->nframes; |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
224 |
8645
404de224517e
QUIC: limited the total number of frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8545
diff
changeset
|
225 #ifdef NGX_QUIC_DEBUG_ALLOC |
8409
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
226 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
227 "quic alloc frame n:%ui", qc->nframes); |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
228 #endif |
8645
404de224517e
QUIC: limited the total number of frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8545
diff
changeset
|
229 |
404de224517e
QUIC: limited the total number of frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8545
diff
changeset
|
230 } else { |
404de224517e
QUIC: limited the total number of frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8545
diff
changeset
|
231 ngx_log_error(NGX_LOG_INFO, c->log, 0, "quic flood detected"); |
404de224517e
QUIC: limited the total number of frames.
Roman Arutyunyan <arut@nginx.com>
parents:
8545
diff
changeset
|
232 return NULL; |
8409
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
233 } |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
234 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
235 ngx_memzero(frame, sizeof(ngx_quic_frame_t)); |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
236 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
237 return frame; |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
238 } |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
239 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
240 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
241 void |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
242 ngx_quic_free_frame(ngx_connection_t *c, ngx_quic_frame_t *frame) |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
243 { |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
244 ngx_quic_connection_t *qc; |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
245 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
246 qc = ngx_quic_get_connection(c); |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
247 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
248 if (frame->data) { |
8761
19e063e955bf
QUIC: renamed buffer-related functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8760
diff
changeset
|
249 ngx_quic_free_chain(c, frame->data); |
8409
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
250 } |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
251 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
252 ngx_queue_insert_head(&qc->free_frames, &frame->queue); |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
253 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
254 #ifdef NGX_QUIC_DEBUG_ALLOC |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
255 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
256 "quic free frame n:%ui", qc->nframes); |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
257 #endif |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
258 } |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
259 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
260 |
8439
f52a2b77d406
QUIC: generic buffering for stream input.
Roman Arutyunyan <arut@nginx.com>
parents:
8413
diff
changeset
|
261 void |
8761
19e063e955bf
QUIC: renamed buffer-related functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8760
diff
changeset
|
262 ngx_quic_free_chain(ngx_connection_t *c, ngx_chain_t *in) |
8409
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
263 { |
8763
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
264 ngx_chain_t *cl; |
8409
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
265 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
266 while (in) { |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
267 cl = in; |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
268 in = in->next; |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
269 |
8763
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
270 ngx_quic_free_buf(c, cl->buf); |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
271 ngx_free_chain(c->pool, cl); |
8409
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
272 } |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
273 } |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
274 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
275 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
276 void |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
277 ngx_quic_free_frames(ngx_connection_t *c, ngx_queue_t *frames) |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
278 { |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
279 ngx_queue_t *q; |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
280 ngx_quic_frame_t *f; |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
281 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
282 do { |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
283 q = ngx_queue_head(frames); |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
284 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
285 if (q == ngx_queue_sentinel(frames)) { |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
286 break; |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
287 } |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
288 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
289 ngx_queue_remove(q); |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
290 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
291 f = ngx_queue_data(q, ngx_quic_frame_t, queue); |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
292 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
293 ngx_quic_free_frame(c, f); |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
294 } while (1); |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
295 } |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
296 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
297 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
298 void |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
299 ngx_quic_queue_frame(ngx_quic_connection_t *qc, ngx_quic_frame_t *frame) |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
300 { |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
301 ngx_quic_send_ctx_t *ctx; |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
302 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
303 ctx = ngx_quic_get_send_ctx(qc, frame->level); |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
304 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
305 ngx_queue_insert_tail(&ctx->frames, &frame->queue); |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
306 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
307 frame->len = ngx_quic_create_frame(NULL, frame); |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
308 /* always succeeds */ |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
309 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
310 if (qc->closing) { |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
311 return; |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
312 } |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
313 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
314 ngx_post_event(&qc->push, &ngx_posted_events); |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
315 } |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
316 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
317 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
318 ngx_int_t |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
319 ngx_quic_split_frame(ngx_connection_t *c, ngx_quic_frame_t *f, size_t len) |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
320 { |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
321 size_t shrink; |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
322 ngx_quic_frame_t *nf; |
8856
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
323 ngx_quic_buffer_t qb; |
8409
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
324 ngx_quic_ordered_frame_t *of, *onf; |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
325 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
326 switch (f->type) { |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
327 case NGX_QUIC_FT_CRYPTO: |
8545
4009f120cad4
QUIC: eliminated stream type from ngx_quic_stream_frame_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8504
diff
changeset
|
328 case NGX_QUIC_FT_STREAM: |
8409
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
329 break; |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
330 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
331 default: |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
332 return NGX_DECLINED; |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
333 } |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
334 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
335 if ((size_t) f->len <= len) { |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
336 return NGX_OK; |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
337 } |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
338 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
339 shrink = f->len - len; |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
340 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
341 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0, |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
342 "quic split frame now:%uz need:%uz shrink:%uz", |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
343 f->len, len, shrink); |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
344 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
345 of = &f->u.ord; |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
346 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
347 if (of->length <= shrink) { |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
348 return NGX_DECLINED; |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
349 } |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
350 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
351 of->length -= shrink; |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
352 f->len = ngx_quic_create_frame(NULL, f); |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
353 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
354 if ((size_t) f->len > len) { |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
355 ngx_log_error(NGX_LOG_ERR, c->log, 0, "could not split QUIC frame"); |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
356 return NGX_ERROR; |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
357 } |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
358 |
8856
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
359 ngx_memzero(&qb, sizeof(ngx_quic_buffer_t)); |
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
360 qb.chain = f->data; |
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
361 |
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
362 f->data = ngx_quic_read_buffer(c, &qb, of->length); |
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
363 if (f->data == NGX_CHAIN_ERROR) { |
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
364 return NGX_ERROR; |
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
365 } |
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
366 |
8409
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
367 nf = ngx_quic_alloc_frame(c); |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
368 if (nf == NULL) { |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
369 return NGX_ERROR; |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
370 } |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
371 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
372 *nf = *f; |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
373 onf = &nf->u.ord; |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
374 onf->offset += of->length; |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
375 onf->length = shrink; |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
376 nf->len = ngx_quic_create_frame(NULL, nf); |
8856
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
377 nf->data = qb.chain; |
8409
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
378 |
8855 | 379 if (f->type == NGX_QUIC_FT_STREAM) { |
380 f->u.stream.fin = 0; | |
381 } | |
382 | |
8409
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
383 ngx_queue_insert_after(&f->queue, &nf->queue); |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
384 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
385 return NGX_OK; |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
386 } |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
387 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
388 |
8760
6ccf3867959a
QUIC: refactored ngx_quic_order_bufs() and ngx_quic_split_bufs().
Roman Arutyunyan <arut@nginx.com>
parents:
8759
diff
changeset
|
389 ngx_chain_t * |
9018
3c98fa8fef6f
QUIC: ngx_quic_copy_buffer() function.
Roman Arutyunyan <arut@nginx.com>
parents:
8861
diff
changeset
|
390 ngx_quic_copy_buffer(ngx_connection_t *c, u_char *data, size_t len) |
3c98fa8fef6f
QUIC: ngx_quic_copy_buffer() function.
Roman Arutyunyan <arut@nginx.com>
parents:
8861
diff
changeset
|
391 { |
3c98fa8fef6f
QUIC: ngx_quic_copy_buffer() function.
Roman Arutyunyan <arut@nginx.com>
parents:
8861
diff
changeset
|
392 ngx_buf_t buf; |
3c98fa8fef6f
QUIC: ngx_quic_copy_buffer() function.
Roman Arutyunyan <arut@nginx.com>
parents:
8861
diff
changeset
|
393 ngx_chain_t cl, *out; |
3c98fa8fef6f
QUIC: ngx_quic_copy_buffer() function.
Roman Arutyunyan <arut@nginx.com>
parents:
8861
diff
changeset
|
394 ngx_quic_buffer_t qb; |
3c98fa8fef6f
QUIC: ngx_quic_copy_buffer() function.
Roman Arutyunyan <arut@nginx.com>
parents:
8861
diff
changeset
|
395 |
3c98fa8fef6f
QUIC: ngx_quic_copy_buffer() function.
Roman Arutyunyan <arut@nginx.com>
parents:
8861
diff
changeset
|
396 ngx_memzero(&buf, sizeof(ngx_buf_t)); |
3c98fa8fef6f
QUIC: ngx_quic_copy_buffer() function.
Roman Arutyunyan <arut@nginx.com>
parents:
8861
diff
changeset
|
397 |
3c98fa8fef6f
QUIC: ngx_quic_copy_buffer() function.
Roman Arutyunyan <arut@nginx.com>
parents:
8861
diff
changeset
|
398 buf.pos = data; |
3c98fa8fef6f
QUIC: ngx_quic_copy_buffer() function.
Roman Arutyunyan <arut@nginx.com>
parents:
8861
diff
changeset
|
399 buf.last = buf.pos + len; |
3c98fa8fef6f
QUIC: ngx_quic_copy_buffer() function.
Roman Arutyunyan <arut@nginx.com>
parents:
8861
diff
changeset
|
400 buf.temporary = 1; |
3c98fa8fef6f
QUIC: ngx_quic_copy_buffer() function.
Roman Arutyunyan <arut@nginx.com>
parents:
8861
diff
changeset
|
401 |
3c98fa8fef6f
QUIC: ngx_quic_copy_buffer() function.
Roman Arutyunyan <arut@nginx.com>
parents:
8861
diff
changeset
|
402 cl.buf = &buf; |
3c98fa8fef6f
QUIC: ngx_quic_copy_buffer() function.
Roman Arutyunyan <arut@nginx.com>
parents:
8861
diff
changeset
|
403 cl.next = NULL; |
3c98fa8fef6f
QUIC: ngx_quic_copy_buffer() function.
Roman Arutyunyan <arut@nginx.com>
parents:
8861
diff
changeset
|
404 |
3c98fa8fef6f
QUIC: ngx_quic_copy_buffer() function.
Roman Arutyunyan <arut@nginx.com>
parents:
8861
diff
changeset
|
405 ngx_memzero(&qb, sizeof(ngx_quic_buffer_t)); |
3c98fa8fef6f
QUIC: ngx_quic_copy_buffer() function.
Roman Arutyunyan <arut@nginx.com>
parents:
8861
diff
changeset
|
406 |
3c98fa8fef6f
QUIC: ngx_quic_copy_buffer() function.
Roman Arutyunyan <arut@nginx.com>
parents:
8861
diff
changeset
|
407 if (ngx_quic_write_buffer(c, &qb, &cl, len, 0) == NGX_CHAIN_ERROR) { |
3c98fa8fef6f
QUIC: ngx_quic_copy_buffer() function.
Roman Arutyunyan <arut@nginx.com>
parents:
8861
diff
changeset
|
408 return NGX_CHAIN_ERROR; |
3c98fa8fef6f
QUIC: ngx_quic_copy_buffer() function.
Roman Arutyunyan <arut@nginx.com>
parents:
8861
diff
changeset
|
409 } |
3c98fa8fef6f
QUIC: ngx_quic_copy_buffer() function.
Roman Arutyunyan <arut@nginx.com>
parents:
8861
diff
changeset
|
410 |
3c98fa8fef6f
QUIC: ngx_quic_copy_buffer() function.
Roman Arutyunyan <arut@nginx.com>
parents:
8861
diff
changeset
|
411 out = ngx_quic_read_buffer(c, &qb, len); |
3c98fa8fef6f
QUIC: ngx_quic_copy_buffer() function.
Roman Arutyunyan <arut@nginx.com>
parents:
8861
diff
changeset
|
412 if (out == NGX_CHAIN_ERROR) { |
3c98fa8fef6f
QUIC: ngx_quic_copy_buffer() function.
Roman Arutyunyan <arut@nginx.com>
parents:
8861
diff
changeset
|
413 return NGX_CHAIN_ERROR; |
3c98fa8fef6f
QUIC: ngx_quic_copy_buffer() function.
Roman Arutyunyan <arut@nginx.com>
parents:
8861
diff
changeset
|
414 } |
3c98fa8fef6f
QUIC: ngx_quic_copy_buffer() function.
Roman Arutyunyan <arut@nginx.com>
parents:
8861
diff
changeset
|
415 |
3c98fa8fef6f
QUIC: ngx_quic_copy_buffer() function.
Roman Arutyunyan <arut@nginx.com>
parents:
8861
diff
changeset
|
416 ngx_quic_free_buffer(c, &qb); |
3c98fa8fef6f
QUIC: ngx_quic_copy_buffer() function.
Roman Arutyunyan <arut@nginx.com>
parents:
8861
diff
changeset
|
417 |
3c98fa8fef6f
QUIC: ngx_quic_copy_buffer() function.
Roman Arutyunyan <arut@nginx.com>
parents:
8861
diff
changeset
|
418 return out; |
3c98fa8fef6f
QUIC: ngx_quic_copy_buffer() function.
Roman Arutyunyan <arut@nginx.com>
parents:
8861
diff
changeset
|
419 } |
3c98fa8fef6f
QUIC: ngx_quic_copy_buffer() function.
Roman Arutyunyan <arut@nginx.com>
parents:
8861
diff
changeset
|
420 |
3c98fa8fef6f
QUIC: ngx_quic_copy_buffer() function.
Roman Arutyunyan <arut@nginx.com>
parents:
8861
diff
changeset
|
421 |
3c98fa8fef6f
QUIC: ngx_quic_copy_buffer() function.
Roman Arutyunyan <arut@nginx.com>
parents:
8861
diff
changeset
|
422 ngx_chain_t * |
8856
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
423 ngx_quic_read_buffer(ngx_connection_t *c, ngx_quic_buffer_t *qb, uint64_t limit) |
8409
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
424 { |
8856
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
425 uint64_t n; |
8763
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
426 ngx_buf_t *b; |
8795
065c73221b7b
QUIC: introduced function ngx_quic_split_chain().
Roman Arutyunyan <arut@nginx.com>
parents:
8793
diff
changeset
|
427 ngx_chain_t *out, **ll; |
8409
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
428 |
8856
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
429 out = qb->chain; |
8409
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
430 |
8760
6ccf3867959a
QUIC: refactored ngx_quic_order_bufs() and ngx_quic_split_bufs().
Roman Arutyunyan <arut@nginx.com>
parents:
8759
diff
changeset
|
431 for (ll = &out; *ll; ll = &(*ll)->next) { |
6ccf3867959a
QUIC: refactored ngx_quic_order_bufs() and ngx_quic_split_bufs().
Roman Arutyunyan <arut@nginx.com>
parents:
8759
diff
changeset
|
432 b = (*ll)->buf; |
6ccf3867959a
QUIC: refactored ngx_quic_order_bufs() and ngx_quic_split_bufs().
Roman Arutyunyan <arut@nginx.com>
parents:
8759
diff
changeset
|
433 |
6ccf3867959a
QUIC: refactored ngx_quic_order_bufs() and ngx_quic_split_bufs().
Roman Arutyunyan <arut@nginx.com>
parents:
8759
diff
changeset
|
434 if (b->sync) { |
6ccf3867959a
QUIC: refactored ngx_quic_order_bufs() and ngx_quic_split_bufs().
Roman Arutyunyan <arut@nginx.com>
parents:
8759
diff
changeset
|
435 /* hole */ |
6ccf3867959a
QUIC: refactored ngx_quic_order_bufs() and ngx_quic_split_bufs().
Roman Arutyunyan <arut@nginx.com>
parents:
8759
diff
changeset
|
436 break; |
8409
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
437 } |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
438 |
8760
6ccf3867959a
QUIC: refactored ngx_quic_order_bufs() and ngx_quic_split_bufs().
Roman Arutyunyan <arut@nginx.com>
parents:
8759
diff
changeset
|
439 if (limit == 0) { |
8409
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
440 break; |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
441 } |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
442 |
8760
6ccf3867959a
QUIC: refactored ngx_quic_order_bufs() and ngx_quic_split_bufs().
Roman Arutyunyan <arut@nginx.com>
parents:
8759
diff
changeset
|
443 n = b->last - b->pos; |
6ccf3867959a
QUIC: refactored ngx_quic_order_bufs() and ngx_quic_split_bufs().
Roman Arutyunyan <arut@nginx.com>
parents:
8759
diff
changeset
|
444 |
6ccf3867959a
QUIC: refactored ngx_quic_order_bufs() and ngx_quic_split_bufs().
Roman Arutyunyan <arut@nginx.com>
parents:
8759
diff
changeset
|
445 if (n > limit) { |
8795
065c73221b7b
QUIC: introduced function ngx_quic_split_chain().
Roman Arutyunyan <arut@nginx.com>
parents:
8793
diff
changeset
|
446 if (ngx_quic_split_chain(c, *ll, limit) != NGX_OK) { |
065c73221b7b
QUIC: introduced function ngx_quic_split_chain().
Roman Arutyunyan <arut@nginx.com>
parents:
8793
diff
changeset
|
447 return NGX_CHAIN_ERROR; |
065c73221b7b
QUIC: introduced function ngx_quic_split_chain().
Roman Arutyunyan <arut@nginx.com>
parents:
8793
diff
changeset
|
448 } |
065c73221b7b
QUIC: introduced function ngx_quic_split_chain().
Roman Arutyunyan <arut@nginx.com>
parents:
8793
diff
changeset
|
449 |
065c73221b7b
QUIC: introduced function ngx_quic_split_chain().
Roman Arutyunyan <arut@nginx.com>
parents:
8793
diff
changeset
|
450 n = limit; |
8760
6ccf3867959a
QUIC: refactored ngx_quic_order_bufs() and ngx_quic_split_bufs().
Roman Arutyunyan <arut@nginx.com>
parents:
8759
diff
changeset
|
451 } |
6ccf3867959a
QUIC: refactored ngx_quic_order_bufs() and ngx_quic_split_bufs().
Roman Arutyunyan <arut@nginx.com>
parents:
8759
diff
changeset
|
452 |
6ccf3867959a
QUIC: refactored ngx_quic_order_bufs() and ngx_quic_split_bufs().
Roman Arutyunyan <arut@nginx.com>
parents:
8759
diff
changeset
|
453 limit -= n; |
8856
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
454 qb->offset += n; |
8409
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
455 } |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
456 |
8859
8d11e2171697
QUIC: optimize insertion at the end of QUIC buffer.
Roman Arutyunyan <arut@nginx.com>
parents:
8858
diff
changeset
|
457 if (qb->offset >= qb->last_offset) { |
8d11e2171697
QUIC: optimize insertion at the end of QUIC buffer.
Roman Arutyunyan <arut@nginx.com>
parents:
8858
diff
changeset
|
458 qb->last_chain = NULL; |
8d11e2171697
QUIC: optimize insertion at the end of QUIC buffer.
Roman Arutyunyan <arut@nginx.com>
parents:
8858
diff
changeset
|
459 } |
8d11e2171697
QUIC: optimize insertion at the end of QUIC buffer.
Roman Arutyunyan <arut@nginx.com>
parents:
8858
diff
changeset
|
460 |
8856
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
461 qb->chain = *ll; |
8760
6ccf3867959a
QUIC: refactored ngx_quic_order_bufs() and ngx_quic_split_bufs().
Roman Arutyunyan <arut@nginx.com>
parents:
8759
diff
changeset
|
462 *ll = NULL; |
6ccf3867959a
QUIC: refactored ngx_quic_order_bufs() and ngx_quic_split_bufs().
Roman Arutyunyan <arut@nginx.com>
parents:
8759
diff
changeset
|
463 |
6ccf3867959a
QUIC: refactored ngx_quic_order_bufs() and ngx_quic_split_bufs().
Roman Arutyunyan <arut@nginx.com>
parents:
8759
diff
changeset
|
464 return out; |
8409
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
465 } |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
466 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
467 |
8856
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
468 void |
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
469 ngx_quic_skip_buffer(ngx_connection_t *c, ngx_quic_buffer_t *qb, |
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
470 uint64_t offset) |
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
471 { |
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
472 size_t n; |
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
473 ngx_buf_t *b; |
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
474 ngx_chain_t *cl; |
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
475 |
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
476 while (qb->chain) { |
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
477 if (qb->offset >= offset) { |
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
478 break; |
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
479 } |
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
480 |
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
481 cl = qb->chain; |
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
482 b = cl->buf; |
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
483 n = b->last - b->pos; |
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
484 |
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
485 if (qb->offset + n > offset) { |
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
486 n = offset - qb->offset; |
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
487 b->pos += n; |
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
488 qb->offset += n; |
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
489 break; |
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
490 } |
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
491 |
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
492 qb->offset += n; |
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
493 qb->chain = cl->next; |
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
494 |
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
495 cl->next = NULL; |
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
496 ngx_quic_free_chain(c, cl); |
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
497 } |
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
498 |
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
499 if (qb->chain == NULL) { |
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
500 qb->offset = offset; |
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
501 } |
8859
8d11e2171697
QUIC: optimize insertion at the end of QUIC buffer.
Roman Arutyunyan <arut@nginx.com>
parents:
8858
diff
changeset
|
502 |
8d11e2171697
QUIC: optimize insertion at the end of QUIC buffer.
Roman Arutyunyan <arut@nginx.com>
parents:
8858
diff
changeset
|
503 if (qb->offset >= qb->last_offset) { |
8d11e2171697
QUIC: optimize insertion at the end of QUIC buffer.
Roman Arutyunyan <arut@nginx.com>
parents:
8858
diff
changeset
|
504 qb->last_chain = NULL; |
8d11e2171697
QUIC: optimize insertion at the end of QUIC buffer.
Roman Arutyunyan <arut@nginx.com>
parents:
8858
diff
changeset
|
505 } |
8856
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
506 } |
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
507 |
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
508 |
8409
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
509 ngx_chain_t * |
8761
19e063e955bf
QUIC: renamed buffer-related functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8760
diff
changeset
|
510 ngx_quic_alloc_chain(ngx_connection_t *c) |
8409
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
511 { |
8763
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
512 ngx_chain_t *cl; |
8409
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
513 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
514 cl = ngx_alloc_chain_link(c->pool); |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
515 if (cl == NULL) { |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
516 return NULL; |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
517 } |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
518 |
8763
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
519 cl->buf = ngx_quic_alloc_buf(c); |
fb811b6c76ee
QUIC: refactored buffer allocation, spliting and freeing.
Roman Arutyunyan <arut@nginx.com>
parents:
8762
diff
changeset
|
520 if (cl->buf == NULL) { |
8409
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
521 return NULL; |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
522 } |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
523 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
524 return cl; |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
525 } |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
526 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
527 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
528 ngx_chain_t * |
8856
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
529 ngx_quic_write_buffer(ngx_connection_t *c, ngx_quic_buffer_t *qb, |
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
530 ngx_chain_t *in, uint64_t limit, uint64_t offset) |
8409
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
531 { |
8442
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
532 u_char *p; |
8856
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
533 uint64_t n, base; |
8442
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
534 ngx_buf_t *b; |
8856
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
535 ngx_chain_t *cl, **chain; |
8409
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
536 |
8859
8d11e2171697
QUIC: optimize insertion at the end of QUIC buffer.
Roman Arutyunyan <arut@nginx.com>
parents:
8858
diff
changeset
|
537 if (qb->last_chain && offset >= qb->last_offset) { |
8d11e2171697
QUIC: optimize insertion at the end of QUIC buffer.
Roman Arutyunyan <arut@nginx.com>
parents:
8858
diff
changeset
|
538 base = qb->last_offset; |
8861
55b38514729b
QUIC: fixed insertion at the end of buffer.
Roman Arutyunyan <arut@nginx.com>
parents:
8859
diff
changeset
|
539 chain = &qb->last_chain; |
8859
8d11e2171697
QUIC: optimize insertion at the end of QUIC buffer.
Roman Arutyunyan <arut@nginx.com>
parents:
8858
diff
changeset
|
540 |
8d11e2171697
QUIC: optimize insertion at the end of QUIC buffer.
Roman Arutyunyan <arut@nginx.com>
parents:
8858
diff
changeset
|
541 } else { |
8d11e2171697
QUIC: optimize insertion at the end of QUIC buffer.
Roman Arutyunyan <arut@nginx.com>
parents:
8858
diff
changeset
|
542 base = qb->offset; |
8d11e2171697
QUIC: optimize insertion at the end of QUIC buffer.
Roman Arutyunyan <arut@nginx.com>
parents:
8858
diff
changeset
|
543 chain = &qb->chain; |
8d11e2171697
QUIC: optimize insertion at the end of QUIC buffer.
Roman Arutyunyan <arut@nginx.com>
parents:
8858
diff
changeset
|
544 } |
8793
3789f4a56d65
QUIC: return written size from ngx_quic_write_chain().
Roman Arutyunyan <arut@nginx.com>
parents:
8789
diff
changeset
|
545 |
8759
56dec0d4e5b1
QUIC: avoid excessive buffer allocations in stream output.
Roman Arutyunyan <arut@nginx.com>
parents:
8708
diff
changeset
|
546 while (in && limit) { |
8857
489c2dcb3180
QUIC: trim input chain in ngx_quic_buffer_write().
Roman Arutyunyan <arut@nginx.com>
parents:
8856
diff
changeset
|
547 |
489c2dcb3180
QUIC: trim input chain in ngx_quic_buffer_write().
Roman Arutyunyan <arut@nginx.com>
parents:
8856
diff
changeset
|
548 if (offset < base) { |
489c2dcb3180
QUIC: trim input chain in ngx_quic_buffer_write().
Roman Arutyunyan <arut@nginx.com>
parents:
8856
diff
changeset
|
549 n = ngx_min((uint64_t) (in->buf->last - in->buf->pos), |
489c2dcb3180
QUIC: trim input chain in ngx_quic_buffer_write().
Roman Arutyunyan <arut@nginx.com>
parents:
8856
diff
changeset
|
550 ngx_min(base - offset, limit)); |
489c2dcb3180
QUIC: trim input chain in ngx_quic_buffer_write().
Roman Arutyunyan <arut@nginx.com>
parents:
8856
diff
changeset
|
551 |
489c2dcb3180
QUIC: trim input chain in ngx_quic_buffer_write().
Roman Arutyunyan <arut@nginx.com>
parents:
8856
diff
changeset
|
552 in->buf->pos += n; |
489c2dcb3180
QUIC: trim input chain in ngx_quic_buffer_write().
Roman Arutyunyan <arut@nginx.com>
parents:
8856
diff
changeset
|
553 offset += n; |
489c2dcb3180
QUIC: trim input chain in ngx_quic_buffer_write().
Roman Arutyunyan <arut@nginx.com>
parents:
8856
diff
changeset
|
554 limit -= n; |
489c2dcb3180
QUIC: trim input chain in ngx_quic_buffer_write().
Roman Arutyunyan <arut@nginx.com>
parents:
8856
diff
changeset
|
555 |
489c2dcb3180
QUIC: trim input chain in ngx_quic_buffer_write().
Roman Arutyunyan <arut@nginx.com>
parents:
8856
diff
changeset
|
556 if (in->buf->pos == in->buf->last) { |
489c2dcb3180
QUIC: trim input chain in ngx_quic_buffer_write().
Roman Arutyunyan <arut@nginx.com>
parents:
8856
diff
changeset
|
557 in = in->next; |
489c2dcb3180
QUIC: trim input chain in ngx_quic_buffer_write().
Roman Arutyunyan <arut@nginx.com>
parents:
8856
diff
changeset
|
558 } |
489c2dcb3180
QUIC: trim input chain in ngx_quic_buffer_write().
Roman Arutyunyan <arut@nginx.com>
parents:
8856
diff
changeset
|
559 |
489c2dcb3180
QUIC: trim input chain in ngx_quic_buffer_write().
Roman Arutyunyan <arut@nginx.com>
parents:
8856
diff
changeset
|
560 continue; |
489c2dcb3180
QUIC: trim input chain in ngx_quic_buffer_write().
Roman Arutyunyan <arut@nginx.com>
parents:
8856
diff
changeset
|
561 } |
489c2dcb3180
QUIC: trim input chain in ngx_quic_buffer_write().
Roman Arutyunyan <arut@nginx.com>
parents:
8856
diff
changeset
|
562 |
8760
6ccf3867959a
QUIC: refactored ngx_quic_order_bufs() and ngx_quic_split_bufs().
Roman Arutyunyan <arut@nginx.com>
parents:
8759
diff
changeset
|
563 cl = *chain; |
8409
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
564 |
8442
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
565 if (cl == NULL) { |
8761
19e063e955bf
QUIC: renamed buffer-related functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8760
diff
changeset
|
566 cl = ngx_quic_alloc_chain(c); |
8442
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
567 if (cl == NULL) { |
8760
6ccf3867959a
QUIC: refactored ngx_quic_order_bufs() and ngx_quic_split_bufs().
Roman Arutyunyan <arut@nginx.com>
parents:
8759
diff
changeset
|
568 return NGX_CHAIN_ERROR; |
8442
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
569 } |
8409
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
570 |
8442
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
571 cl->buf->last = cl->buf->end; |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
572 cl->buf->sync = 1; /* hole */ |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
573 cl->next = NULL; |
8760
6ccf3867959a
QUIC: refactored ngx_quic_order_bufs() and ngx_quic_split_bufs().
Roman Arutyunyan <arut@nginx.com>
parents:
8759
diff
changeset
|
574 *chain = cl; |
8409
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
575 } |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
576 |
8442
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
577 b = cl->buf; |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
578 n = b->last - b->pos; |
8409
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
579 |
8856
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
580 if (base + n <= offset) { |
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
581 base += n; |
8760
6ccf3867959a
QUIC: refactored ngx_quic_order_bufs() and ngx_quic_split_bufs().
Roman Arutyunyan <arut@nginx.com>
parents:
8759
diff
changeset
|
582 chain = &cl->next; |
8442
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
583 continue; |
8409
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
584 } |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
585 |
8856
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
586 if (b->sync && offset > base) { |
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
587 if (ngx_quic_split_chain(c, cl, offset - base) != NGX_OK) { |
8760
6ccf3867959a
QUIC: refactored ngx_quic_order_bufs() and ngx_quic_split_bufs().
Roman Arutyunyan <arut@nginx.com>
parents:
8759
diff
changeset
|
588 return NGX_CHAIN_ERROR; |
8442
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
589 } |
8409
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
590 |
8442
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
591 continue; |
8409
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
592 } |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
593 |
8856
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
594 p = b->pos + (offset - base); |
8801
000b9b048e0c
QUIC: fixed chain returned from ngx_quic_write_chain().
Roman Arutyunyan <arut@nginx.com>
parents:
8795
diff
changeset
|
595 |
000b9b048e0c
QUIC: fixed chain returned from ngx_quic_write_chain().
Roman Arutyunyan <arut@nginx.com>
parents:
8795
diff
changeset
|
596 while (in) { |
8789
5acd0d89d8c2
QUIC: fixed handling stream input buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8763
diff
changeset
|
597 |
5acd0d89d8c2
QUIC: fixed handling stream input buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8763
diff
changeset
|
598 if (!ngx_buf_in_memory(in->buf) || in->buf->pos == in->buf->last) { |
5acd0d89d8c2
QUIC: fixed handling stream input buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8763
diff
changeset
|
599 in = in->next; |
5acd0d89d8c2
QUIC: fixed handling stream input buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8763
diff
changeset
|
600 continue; |
5acd0d89d8c2
QUIC: fixed handling stream input buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8763
diff
changeset
|
601 } |
5acd0d89d8c2
QUIC: fixed handling stream input buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8763
diff
changeset
|
602 |
8801
000b9b048e0c
QUIC: fixed chain returned from ngx_quic_write_chain().
Roman Arutyunyan <arut@nginx.com>
parents:
8795
diff
changeset
|
603 if (p == b->last || limit == 0) { |
8789
5acd0d89d8c2
QUIC: fixed handling stream input buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8763
diff
changeset
|
604 break; |
5acd0d89d8c2
QUIC: fixed handling stream input buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8763
diff
changeset
|
605 } |
5acd0d89d8c2
QUIC: fixed handling stream input buffers.
Roman Arutyunyan <arut@nginx.com>
parents:
8763
diff
changeset
|
606 |
8442
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
607 n = ngx_min(b->last - p, in->buf->last - in->buf->pos); |
8759
56dec0d4e5b1
QUIC: avoid excessive buffer allocations in stream output.
Roman Arutyunyan <arut@nginx.com>
parents:
8708
diff
changeset
|
608 n = ngx_min(n, limit); |
8409
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
609 |
8442
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
610 if (b->sync) { |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
611 ngx_memcpy(p, in->buf->pos, n); |
8856
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
612 qb->size += n; |
8442
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
613 } |
8409
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
614 |
8442
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
615 p += n; |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
616 in->buf->pos += n; |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
617 offset += n; |
8759
56dec0d4e5b1
QUIC: avoid excessive buffer allocations in stream output.
Roman Arutyunyan <arut@nginx.com>
parents:
8708
diff
changeset
|
618 limit -= n; |
8442
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
619 } |
8409
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
620 |
8760
6ccf3867959a
QUIC: refactored ngx_quic_order_bufs() and ngx_quic_split_bufs().
Roman Arutyunyan <arut@nginx.com>
parents:
8759
diff
changeset
|
621 if (b->sync && p == b->last) { |
6ccf3867959a
QUIC: refactored ngx_quic_order_bufs() and ngx_quic_split_bufs().
Roman Arutyunyan <arut@nginx.com>
parents:
8759
diff
changeset
|
622 b->sync = 0; |
6ccf3867959a
QUIC: refactored ngx_quic_order_bufs() and ngx_quic_split_bufs().
Roman Arutyunyan <arut@nginx.com>
parents:
8759
diff
changeset
|
623 continue; |
6ccf3867959a
QUIC: refactored ngx_quic_order_bufs() and ngx_quic_split_bufs().
Roman Arutyunyan <arut@nginx.com>
parents:
8759
diff
changeset
|
624 } |
6ccf3867959a
QUIC: refactored ngx_quic_order_bufs() and ngx_quic_split_bufs().
Roman Arutyunyan <arut@nginx.com>
parents:
8759
diff
changeset
|
625 |
8442
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
626 if (b->sync && p != b->pos) { |
8795
065c73221b7b
QUIC: introduced function ngx_quic_split_chain().
Roman Arutyunyan <arut@nginx.com>
parents:
8793
diff
changeset
|
627 if (ngx_quic_split_chain(c, cl, p - b->pos) != NGX_OK) { |
8760
6ccf3867959a
QUIC: refactored ngx_quic_order_bufs() and ngx_quic_split_bufs().
Roman Arutyunyan <arut@nginx.com>
parents:
8759
diff
changeset
|
628 return NGX_CHAIN_ERROR; |
8442
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
629 } |
8409
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
630 |
8795
065c73221b7b
QUIC: introduced function ngx_quic_split_chain().
Roman Arutyunyan <arut@nginx.com>
parents:
8793
diff
changeset
|
631 b->sync = 0; |
8409
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
632 } |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
633 } |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
634 |
8859
8d11e2171697
QUIC: optimize insertion at the end of QUIC buffer.
Roman Arutyunyan <arut@nginx.com>
parents:
8858
diff
changeset
|
635 qb->last_offset = base; |
8861
55b38514729b
QUIC: fixed insertion at the end of buffer.
Roman Arutyunyan <arut@nginx.com>
parents:
8859
diff
changeset
|
636 qb->last_chain = *chain; |
8859
8d11e2171697
QUIC: optimize insertion at the end of QUIC buffer.
Roman Arutyunyan <arut@nginx.com>
parents:
8858
diff
changeset
|
637 |
8760
6ccf3867959a
QUIC: refactored ngx_quic_order_bufs() and ngx_quic_split_bufs().
Roman Arutyunyan <arut@nginx.com>
parents:
8759
diff
changeset
|
638 return in; |
8409
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
639 } |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
640 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
641 |
8856
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
642 void |
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
643 ngx_quic_free_buffer(ngx_connection_t *c, ngx_quic_buffer_t *qb) |
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
644 { |
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
645 ngx_quic_free_chain(c, qb->chain); |
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
646 |
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
647 qb->chain = NULL; |
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
648 } |
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
649 |
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
650 |
8409
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
651 #if (NGX_DEBUG) |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
652 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
653 void |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
654 ngx_quic_log_frame(ngx_log_t *log, ngx_quic_frame_t *f, ngx_uint_t tx) |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
655 { |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
656 u_char *p, *last, *pos, *end; |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
657 ssize_t n; |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
658 uint64_t gap, range, largest, smallest; |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
659 ngx_uint_t i; |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
660 u_char buf[NGX_MAX_ERROR_STR]; |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
661 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
662 p = buf; |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
663 last = buf + sizeof(buf); |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
664 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
665 switch (f->type) { |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
666 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
667 case NGX_QUIC_FT_CRYPTO: |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
668 p = ngx_slprintf(p, last, "CRYPTO len:%uL off:%uL", |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
669 f->u.crypto.length, f->u.crypto.offset); |
8708
a6a328ebd362
QUIC: logging of CRYPTO frame payload under NGX_QUIC_DEBUG_FRAMES.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8645
diff
changeset
|
670 |
a6a328ebd362
QUIC: logging of CRYPTO frame payload under NGX_QUIC_DEBUG_FRAMES.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8645
diff
changeset
|
671 #ifdef NGX_QUIC_DEBUG_FRAMES |
a6a328ebd362
QUIC: logging of CRYPTO frame payload under NGX_QUIC_DEBUG_FRAMES.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8645
diff
changeset
|
672 { |
a6a328ebd362
QUIC: logging of CRYPTO frame payload under NGX_QUIC_DEBUG_FRAMES.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8645
diff
changeset
|
673 ngx_chain_t *cl; |
a6a328ebd362
QUIC: logging of CRYPTO frame payload under NGX_QUIC_DEBUG_FRAMES.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8645
diff
changeset
|
674 |
a6a328ebd362
QUIC: logging of CRYPTO frame payload under NGX_QUIC_DEBUG_FRAMES.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8645
diff
changeset
|
675 p = ngx_slprintf(p, last, " data:"); |
a6a328ebd362
QUIC: logging of CRYPTO frame payload under NGX_QUIC_DEBUG_FRAMES.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8645
diff
changeset
|
676 |
a6a328ebd362
QUIC: logging of CRYPTO frame payload under NGX_QUIC_DEBUG_FRAMES.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8645
diff
changeset
|
677 for (cl = f->data; cl; cl = cl->next) { |
a6a328ebd362
QUIC: logging of CRYPTO frame payload under NGX_QUIC_DEBUG_FRAMES.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8645
diff
changeset
|
678 p = ngx_slprintf(p, last, "%*xs", |
a6a328ebd362
QUIC: logging of CRYPTO frame payload under NGX_QUIC_DEBUG_FRAMES.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8645
diff
changeset
|
679 cl->buf->last - cl->buf->pos, cl->buf->pos); |
a6a328ebd362
QUIC: logging of CRYPTO frame payload under NGX_QUIC_DEBUG_FRAMES.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8645
diff
changeset
|
680 } |
a6a328ebd362
QUIC: logging of CRYPTO frame payload under NGX_QUIC_DEBUG_FRAMES.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8645
diff
changeset
|
681 } |
a6a328ebd362
QUIC: logging of CRYPTO frame payload under NGX_QUIC_DEBUG_FRAMES.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8645
diff
changeset
|
682 #endif |
a6a328ebd362
QUIC: logging of CRYPTO frame payload under NGX_QUIC_DEBUG_FRAMES.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8645
diff
changeset
|
683 |
8409
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
684 break; |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
685 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
686 case NGX_QUIC_FT_PADDING: |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
687 p = ngx_slprintf(p, last, "PADDING"); |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
688 break; |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
689 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
690 case NGX_QUIC_FT_ACK: |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
691 case NGX_QUIC_FT_ACK_ECN: |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
692 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
693 p = ngx_slprintf(p, last, "ACK n:%ui delay:%uL ", |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
694 f->u.ack.range_count, f->u.ack.delay); |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
695 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
696 if (f->data) { |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
697 pos = f->data->buf->pos; |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
698 end = f->data->buf->last; |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
699 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
700 } else { |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
701 pos = NULL; |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
702 end = NULL; |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
703 } |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
704 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
705 largest = f->u.ack.largest; |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
706 smallest = f->u.ack.largest - f->u.ack.first_range; |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
707 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
708 if (largest == smallest) { |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
709 p = ngx_slprintf(p, last, "%uL", largest); |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
710 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
711 } else { |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
712 p = ngx_slprintf(p, last, "%uL-%uL", largest, smallest); |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
713 } |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
714 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
715 for (i = 0; i < f->u.ack.range_count; i++) { |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
716 n = ngx_quic_parse_ack_range(log, pos, end, &gap, &range); |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
717 if (n == NGX_ERROR) { |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
718 break; |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
719 } |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
720 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
721 pos += n; |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
722 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
723 largest = smallest - gap - 2; |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
724 smallest = largest - range; |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
725 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
726 if (largest == smallest) { |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
727 p = ngx_slprintf(p, last, " %uL", largest); |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
728 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
729 } else { |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
730 p = ngx_slprintf(p, last, " %uL-%uL", largest, smallest); |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
731 } |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
732 } |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
733 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
734 if (f->type == NGX_QUIC_FT_ACK_ECN) { |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
735 p = ngx_slprintf(p, last, " ECN counters ect0:%uL ect1:%uL ce:%uL", |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
736 f->u.ack.ect0, f->u.ack.ect1, f->u.ack.ce); |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
737 } |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
738 break; |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
739 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
740 case NGX_QUIC_FT_PING: |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
741 p = ngx_slprintf(p, last, "PING"); |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
742 break; |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
743 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
744 case NGX_QUIC_FT_NEW_CONNECTION_ID: |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
745 p = ngx_slprintf(p, last, |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
746 "NEW_CONNECTION_ID seq:%uL retire:%uL len:%ud", |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
747 f->u.ncid.seqnum, f->u.ncid.retire, f->u.ncid.len); |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
748 break; |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
749 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
750 case NGX_QUIC_FT_RETIRE_CONNECTION_ID: |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
751 p = ngx_slprintf(p, last, "RETIRE_CONNECTION_ID seqnum:%uL", |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
752 f->u.retire_cid.sequence_number); |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
753 break; |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
754 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
755 case NGX_QUIC_FT_CONNECTION_CLOSE: |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
756 case NGX_QUIC_FT_CONNECTION_CLOSE_APP: |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
757 p = ngx_slprintf(p, last, "CONNECTION_CLOSE%s err:%ui", |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
758 f->type == NGX_QUIC_FT_CONNECTION_CLOSE ? "" : "_APP", |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
759 f->u.close.error_code); |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
760 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
761 if (f->u.close.reason.len) { |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
762 p = ngx_slprintf(p, last, " %V", &f->u.close.reason); |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
763 } |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
764 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
765 if (f->type == NGX_QUIC_FT_CONNECTION_CLOSE) { |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
766 p = ngx_slprintf(p, last, " ft:%ui", f->u.close.frame_type); |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
767 } |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
768 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
769 break; |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
770 |
8545
4009f120cad4
QUIC: eliminated stream type from ngx_quic_stream_frame_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8504
diff
changeset
|
771 case NGX_QUIC_FT_STREAM: |
8409
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
772 p = ngx_slprintf(p, last, "STREAM id:0x%xL", f->u.stream.stream_id); |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
773 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
774 if (f->u.stream.off) { |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
775 p = ngx_slprintf(p, last, " off:%uL", f->u.stream.offset); |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
776 } |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
777 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
778 if (f->u.stream.len) { |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
779 p = ngx_slprintf(p, last, " len:%uL", f->u.stream.length); |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
780 } |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
781 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
782 if (f->u.stream.fin) { |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
783 p = ngx_slprintf(p, last, " fin:1"); |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
784 } |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
785 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
786 #ifdef NGX_QUIC_DEBUG_FRAMES |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
787 { |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
788 ngx_chain_t *cl; |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
789 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
790 p = ngx_slprintf(p, last, " data:"); |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
791 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
792 for (cl = f->data; cl; cl = cl->next) { |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
793 p = ngx_slprintf(p, last, "%*xs", |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
794 cl->buf->last - cl->buf->pos, cl->buf->pos); |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
795 } |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
796 } |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
797 #endif |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
798 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
799 break; |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
800 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
801 case NGX_QUIC_FT_MAX_DATA: |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
802 p = ngx_slprintf(p, last, "MAX_DATA max_data:%uL on recv", |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
803 f->u.max_data.max_data); |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
804 break; |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
805 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
806 case NGX_QUIC_FT_RESET_STREAM: |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
807 p = ngx_slprintf(p, last, "RESET_STREAM" |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
808 " id:0x%xL error_code:0x%xL final_size:0x%xL", |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
809 f->u.reset_stream.id, f->u.reset_stream.error_code, |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
810 f->u.reset_stream.final_size); |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
811 break; |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
812 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
813 case NGX_QUIC_FT_STOP_SENDING: |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
814 p = ngx_slprintf(p, last, "STOP_SENDING id:0x%xL err:0x%xL", |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
815 f->u.stop_sending.id, f->u.stop_sending.error_code); |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
816 break; |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
817 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
818 case NGX_QUIC_FT_STREAMS_BLOCKED: |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
819 case NGX_QUIC_FT_STREAMS_BLOCKED2: |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
820 p = ngx_slprintf(p, last, "STREAMS_BLOCKED limit:%uL bidi:%ui", |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
821 f->u.streams_blocked.limit, f->u.streams_blocked.bidi); |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
822 break; |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
823 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
824 case NGX_QUIC_FT_MAX_STREAMS: |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
825 case NGX_QUIC_FT_MAX_STREAMS2: |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
826 p = ngx_slprintf(p, last, "MAX_STREAMS limit:%uL bidi:%ui", |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
827 f->u.max_streams.limit, f->u.max_streams.bidi); |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
828 break; |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
829 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
830 case NGX_QUIC_FT_MAX_STREAM_DATA: |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
831 p = ngx_slprintf(p, last, "MAX_STREAM_DATA id:0x%xL limit:%uL", |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
832 f->u.max_stream_data.id, f->u.max_stream_data.limit); |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
833 break; |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
834 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
835 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
836 case NGX_QUIC_FT_DATA_BLOCKED: |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
837 p = ngx_slprintf(p, last, "DATA_BLOCKED limit:%uL", |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
838 f->u.data_blocked.limit); |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
839 break; |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
840 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
841 case NGX_QUIC_FT_STREAM_DATA_BLOCKED: |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
842 p = ngx_slprintf(p, last, "STREAM_DATA_BLOCKED id:0x%xL limit:%uL", |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
843 f->u.stream_data_blocked.id, |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
844 f->u.stream_data_blocked.limit); |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
845 break; |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
846 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
847 case NGX_QUIC_FT_PATH_CHALLENGE: |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
848 p = ngx_slprintf(p, last, "PATH_CHALLENGE data:0x%*xs", |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
849 sizeof(f->u.path_challenge.data), |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
850 f->u.path_challenge.data); |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
851 break; |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
852 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
853 case NGX_QUIC_FT_PATH_RESPONSE: |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
854 p = ngx_slprintf(p, last, "PATH_RESPONSE data:0x%*xs", |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
855 sizeof(f->u.path_challenge.data), |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
856 f->u.path_challenge.data); |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
857 break; |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
858 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
859 case NGX_QUIC_FT_NEW_TOKEN: |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
860 p = ngx_slprintf(p, last, "NEW_TOKEN"); |
9019
def8e398d7c5
QUIC: fixed broken token in NEW_TOKEN (ticket #2446).
Roman Arutyunyan <arut@nginx.com>
parents:
9018
diff
changeset
|
861 |
def8e398d7c5
QUIC: fixed broken token in NEW_TOKEN (ticket #2446).
Roman Arutyunyan <arut@nginx.com>
parents:
9018
diff
changeset
|
862 #ifdef NGX_QUIC_DEBUG_FRAMES |
def8e398d7c5
QUIC: fixed broken token in NEW_TOKEN (ticket #2446).
Roman Arutyunyan <arut@nginx.com>
parents:
9018
diff
changeset
|
863 { |
def8e398d7c5
QUIC: fixed broken token in NEW_TOKEN (ticket #2446).
Roman Arutyunyan <arut@nginx.com>
parents:
9018
diff
changeset
|
864 ngx_chain_t *cl; |
def8e398d7c5
QUIC: fixed broken token in NEW_TOKEN (ticket #2446).
Roman Arutyunyan <arut@nginx.com>
parents:
9018
diff
changeset
|
865 |
def8e398d7c5
QUIC: fixed broken token in NEW_TOKEN (ticket #2446).
Roman Arutyunyan <arut@nginx.com>
parents:
9018
diff
changeset
|
866 p = ngx_slprintf(p, last, " token:"); |
def8e398d7c5
QUIC: fixed broken token in NEW_TOKEN (ticket #2446).
Roman Arutyunyan <arut@nginx.com>
parents:
9018
diff
changeset
|
867 |
def8e398d7c5
QUIC: fixed broken token in NEW_TOKEN (ticket #2446).
Roman Arutyunyan <arut@nginx.com>
parents:
9018
diff
changeset
|
868 for (cl = f->data; cl; cl = cl->next) { |
def8e398d7c5
QUIC: fixed broken token in NEW_TOKEN (ticket #2446).
Roman Arutyunyan <arut@nginx.com>
parents:
9018
diff
changeset
|
869 p = ngx_slprintf(p, last, "%*xs", |
def8e398d7c5
QUIC: fixed broken token in NEW_TOKEN (ticket #2446).
Roman Arutyunyan <arut@nginx.com>
parents:
9018
diff
changeset
|
870 cl->buf->last - cl->buf->pos, cl->buf->pos); |
def8e398d7c5
QUIC: fixed broken token in NEW_TOKEN (ticket #2446).
Roman Arutyunyan <arut@nginx.com>
parents:
9018
diff
changeset
|
871 } |
def8e398d7c5
QUIC: fixed broken token in NEW_TOKEN (ticket #2446).
Roman Arutyunyan <arut@nginx.com>
parents:
9018
diff
changeset
|
872 } |
def8e398d7c5
QUIC: fixed broken token in NEW_TOKEN (ticket #2446).
Roman Arutyunyan <arut@nginx.com>
parents:
9018
diff
changeset
|
873 #endif |
def8e398d7c5
QUIC: fixed broken token in NEW_TOKEN (ticket #2446).
Roman Arutyunyan <arut@nginx.com>
parents:
9018
diff
changeset
|
874 |
8409
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
875 break; |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
876 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
877 case NGX_QUIC_FT_HANDSHAKE_DONE: |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
878 p = ngx_slprintf(p, last, "HANDSHAKE DONE"); |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
879 break; |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
880 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
881 default: |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
882 p = ngx_slprintf(p, last, "unknown type 0x%xi", f->type); |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
883 break; |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
884 } |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
885 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
886 ngx_log_debug4(NGX_LOG_DEBUG_EVENT, log, 0, "quic frame %s %s %*s", |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
887 tx ? "tx" : "rx", ngx_quic_level_name(f->level), |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
888 p - buf, buf); |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
889 } |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
890 |
660c4a2f95f3
QUIC: separate files for frames related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
891 #endif |