Mercurial > hg > nginx
annotate src/http/v3/ngx_http_v3_table.c @ 9295:c5623963c29e
Upstream: fixed proxy_no_cache when caching errors.
Caching errors, notably intercepted errors and internally generated
502/504 errors, as well as handling of cache revalidation with 304,
did not take into account u->conf->no_cache predicates configured.
As a result, an error might be cached even if configuration explicitly
says not to. Fix is to check u->conf->no_cache in these cases.
To simplify usage in multiple places, checking u->conf->no_cache is now
done in a separate function. As a minor optimization, u->conf->no_cache
is only checked if u->cacheable is set.
As a side effect, this change also fixes caching errors after
proxy_cache_bypass. Also, during cache revalidation u->cacheable is
now tested, so 304 responses which disable caching won't extend
cacheability of stored responses.
Additionally, when caching internally generated 502/504 errors
u->cacheable is now explicitly updated from u->headers_in.no_cache and
u->headers_in.expired, restoring the behaviour before 8041:0784ab86ad08
(1.23.0) when an error happens while reading the response headers.
Reported by Kirill A. Korinsky,
https://freenginx.org/pipermail/nginx/2024-April/000082.html
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Tue, 25 Jun 2024 21:44:50 +0300 |
parents | acb8548c00e9 |
children |
rev | line source |
---|---|
8215 | 1 |
2 /* | |
3 * Copyright (C) Roman Arutyunyan | |
4 * Copyright (C) Nginx, Inc. | |
5 */ | |
6 | |
7 | |
8 #include <ngx_config.h> | |
9 #include <ngx_core.h> | |
10 #include <ngx_http.h> | |
11 | |
12 | |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
13 #define ngx_http_v3_table_entry_size(n, v) ((n)->len + (v)->len + 32) |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
14 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
15 |
9062
987bee4363d1
HTTP/3: handled insertion reference to a going to be evicted entry.
Roman Arutyunyan <arut@nginx.com>
parents:
9020
diff
changeset
|
16 static ngx_int_t ngx_http_v3_evict(ngx_connection_t *c, size_t target); |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
17 static void ngx_http_v3_unblock(void *data); |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8785
diff
changeset
|
18 static ngx_int_t ngx_http_v3_new_entry(ngx_connection_t *c); |
8215 | 19 |
20 | |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
21 typedef struct { |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
22 ngx_queue_t queue; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
23 ngx_connection_t *connection; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
24 ngx_uint_t *nblocked; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
25 } ngx_http_v3_block_t; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
26 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
27 |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8785
diff
changeset
|
28 static ngx_http_v3_field_t ngx_http_v3_static_table[] = { |
8215 | 29 |
30 { ngx_string(":authority"), ngx_string("") }, | |
8296
f11b7981a03d
HTTP/3: static table cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8226
diff
changeset
|
31 { ngx_string(":path"), ngx_string("/") }, |
8215 | 32 { ngx_string("age"), ngx_string("0") }, |
33 { ngx_string("content-disposition"), ngx_string("") }, | |
34 { ngx_string("content-length"), ngx_string("0") }, | |
35 { ngx_string("cookie"), ngx_string("") }, | |
36 { ngx_string("date"), ngx_string("") }, | |
37 { ngx_string("etag"), ngx_string("") }, | |
38 { ngx_string("if-modified-since"), ngx_string("") }, | |
39 { ngx_string("if-none-match"), ngx_string("") }, | |
40 { ngx_string("last-modified"), ngx_string("") }, | |
41 { ngx_string("link"), ngx_string("") }, | |
42 { ngx_string("location"), ngx_string("") }, | |
43 { ngx_string("referer"), ngx_string("") }, | |
44 { ngx_string("set-cookie"), ngx_string("") }, | |
45 { ngx_string(":method"), ngx_string("CONNECT") }, | |
46 { ngx_string(":method"), ngx_string("DELETE") }, | |
47 { ngx_string(":method"), ngx_string("GET") }, | |
48 { ngx_string(":method"), ngx_string("HEAD") }, | |
49 { ngx_string(":method"), ngx_string("OPTIONS") }, | |
50 { ngx_string(":method"), ngx_string("POST") }, | |
51 { ngx_string(":method"), ngx_string("PUT") }, | |
52 { ngx_string(":scheme"), ngx_string("http") }, | |
53 { ngx_string(":scheme"), ngx_string("https") }, | |
54 { ngx_string(":status"), ngx_string("103") }, | |
55 { ngx_string(":status"), ngx_string("200") }, | |
56 { ngx_string(":status"), ngx_string("304") }, | |
57 { ngx_string(":status"), ngx_string("404") }, | |
58 { ngx_string(":status"), ngx_string("503") }, | |
59 { ngx_string("accept"), ngx_string("*/*") }, | |
60 { ngx_string("accept"), | |
8296
f11b7981a03d
HTTP/3: static table cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8226
diff
changeset
|
61 ngx_string("application/dns-message") }, |
f11b7981a03d
HTTP/3: static table cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8226
diff
changeset
|
62 { ngx_string("accept-encoding"), ngx_string("gzip, deflate, br") }, |
8215 | 63 { ngx_string("accept-ranges"), ngx_string("bytes") }, |
64 { ngx_string("access-control-allow-headers"), | |
65 ngx_string("cache-control") }, | |
66 { ngx_string("access-control-allow-headers"), | |
67 ngx_string("content-type") }, | |
68 { ngx_string("access-control-allow-origin"), | |
69 ngx_string("*") }, | |
70 { ngx_string("cache-control"), ngx_string("max-age=0") }, | |
71 { ngx_string("cache-control"), ngx_string("max-age=2592000") }, | |
72 { ngx_string("cache-control"), ngx_string("max-age=604800") }, | |
73 { ngx_string("cache-control"), ngx_string("no-cache") }, | |
74 { ngx_string("cache-control"), ngx_string("no-store") }, | |
75 { ngx_string("cache-control"), | |
8296
f11b7981a03d
HTTP/3: static table cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8226
diff
changeset
|
76 ngx_string("public, max-age=31536000") }, |
8215 | 77 { ngx_string("content-encoding"), ngx_string("br") }, |
78 { ngx_string("content-encoding"), ngx_string("gzip") }, | |
79 { ngx_string("content-type"), | |
80 ngx_string("application/dns-message") }, | |
81 { ngx_string("content-type"), | |
82 ngx_string("application/javascript") }, | |
83 { ngx_string("content-type"), ngx_string("application/json") }, | |
84 { ngx_string("content-type"), | |
85 ngx_string("application/x-www-form-urlencoded") }, | |
86 { ngx_string("content-type"), ngx_string("image/gif") }, | |
87 { ngx_string("content-type"), ngx_string("image/jpeg") }, | |
88 { ngx_string("content-type"), ngx_string("image/png") }, | |
89 { ngx_string("content-type"), ngx_string("text/css") }, | |
90 { ngx_string("content-type"), | |
91 ngx_string("text/html;charset=utf-8") }, | |
92 { ngx_string("content-type"), ngx_string("text/plain") }, | |
93 { ngx_string("content-type"), | |
94 ngx_string("text/plain;charset=utf-8") }, | |
95 { ngx_string("range"), ngx_string("bytes=0-") }, | |
96 { ngx_string("strict-transport-security"), | |
97 ngx_string("max-age=31536000") }, | |
98 { ngx_string("strict-transport-security"), | |
99 ngx_string("max-age=31536000;includesubdomains") }, | |
100 { ngx_string("strict-transport-security"), | |
101 ngx_string("max-age=31536000;includesubdomains;preload") }, | |
102 { ngx_string("vary"), ngx_string("accept-encoding") }, | |
103 { ngx_string("vary"), ngx_string("origin") }, | |
8296
f11b7981a03d
HTTP/3: static table cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8226
diff
changeset
|
104 { ngx_string("x-content-type-options"), |
f11b7981a03d
HTTP/3: static table cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8226
diff
changeset
|
105 ngx_string("nosniff") }, |
8215 | 106 { ngx_string("x-xss-protection"), ngx_string("1;mode=block") }, |
107 { ngx_string(":status"), ngx_string("100") }, | |
108 { ngx_string(":status"), ngx_string("204") }, | |
109 { ngx_string(":status"), ngx_string("206") }, | |
110 { ngx_string(":status"), ngx_string("302") }, | |
111 { ngx_string(":status"), ngx_string("400") }, | |
112 { ngx_string(":status"), ngx_string("403") }, | |
113 { ngx_string(":status"), ngx_string("421") }, | |
114 { ngx_string(":status"), ngx_string("425") }, | |
115 { ngx_string(":status"), ngx_string("500") }, | |
116 { ngx_string("accept-language"), ngx_string("") }, | |
117 { ngx_string("access-control-allow-credentials"), | |
118 ngx_string("FALSE") }, | |
119 { ngx_string("access-control-allow-credentials"), | |
120 ngx_string("TRUE") }, | |
121 { ngx_string("access-control-allow-headers"), | |
122 ngx_string("*") }, | |
123 { ngx_string("access-control-allow-methods"), | |
124 ngx_string("get") }, | |
125 { ngx_string("access-control-allow-methods"), | |
126 ngx_string("get, post, options") }, | |
127 { ngx_string("access-control-allow-methods"), | |
128 ngx_string("options") }, | |
129 { ngx_string("access-control-expose-headers"), | |
130 ngx_string("content-length") }, | |
131 { ngx_string("access-control-request-headers"), | |
132 ngx_string("content-type") }, | |
133 { ngx_string("access-control-request-method"), | |
134 ngx_string("get") }, | |
135 { ngx_string("access-control-request-method"), | |
136 ngx_string("post") }, | |
137 { ngx_string("alt-svc"), ngx_string("clear") }, | |
8296
f11b7981a03d
HTTP/3: static table cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8226
diff
changeset
|
138 { ngx_string("authorization"), ngx_string("") }, |
8215 | 139 { ngx_string("content-security-policy"), |
8296
f11b7981a03d
HTTP/3: static table cleanup.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8226
diff
changeset
|
140 ngx_string("script-src 'none';object-src 'none';base-uri 'none'") }, |
8215 | 141 { ngx_string("early-data"), ngx_string("1") }, |
142 { ngx_string("expect-ct"), ngx_string("") }, | |
143 { ngx_string("forwarded"), ngx_string("") }, | |
144 { ngx_string("if-range"), ngx_string("") }, | |
145 { ngx_string("origin"), ngx_string("") }, | |
146 { ngx_string("purpose"), ngx_string("prefetch") }, | |
147 { ngx_string("server"), ngx_string("") }, | |
148 { ngx_string("timing-allow-origin"), ngx_string("*") }, | |
149 { ngx_string("upgrade-insecure-requests"), | |
150 ngx_string("1") }, | |
151 { ngx_string("user-agent"), ngx_string("") }, | |
152 { ngx_string("x-forwarded-for"), ngx_string("") }, | |
153 { ngx_string("x-frame-options"), ngx_string("deny") }, | |
154 { ngx_string("x-frame-options"), ngx_string("sameorigin") } | |
155 }; | |
156 | |
157 | |
158 ngx_int_t | |
159 ngx_http_v3_ref_insert(ngx_connection_t *c, ngx_uint_t dynamic, | |
160 ngx_uint_t index, ngx_str_t *value) | |
161 { | |
8785
e6c26cb4d38b
HTTP/3: fixed Insert With Name Reference index processing.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8775
diff
changeset
|
162 ngx_str_t name; |
e6c26cb4d38b
HTTP/3: fixed Insert With Name Reference index processing.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8775
diff
changeset
|
163 ngx_http_v3_session_t *h3c; |
e6c26cb4d38b
HTTP/3: fixed Insert With Name Reference index processing.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8775
diff
changeset
|
164 ngx_http_v3_dynamic_table_t *dt; |
8215 | 165 |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
166 if (dynamic) { |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
167 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0, |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
168 "http3 ref insert dynamic[%ui] \"%V\"", index, value); |
8215 | 169 |
8785
e6c26cb4d38b
HTTP/3: fixed Insert With Name Reference index processing.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8775
diff
changeset
|
170 h3c = ngx_http_v3_get_session(c); |
e6c26cb4d38b
HTTP/3: fixed Insert With Name Reference index processing.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8775
diff
changeset
|
171 dt = &h3c->table; |
e6c26cb4d38b
HTTP/3: fixed Insert With Name Reference index processing.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8775
diff
changeset
|
172 |
e6c26cb4d38b
HTTP/3: fixed Insert With Name Reference index processing.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8775
diff
changeset
|
173 if (dt->base + dt->nelts <= index) { |
e6c26cb4d38b
HTTP/3: fixed Insert With Name Reference index processing.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8775
diff
changeset
|
174 return NGX_HTTP_V3_ERR_ENCODER_STREAM_ERROR; |
e6c26cb4d38b
HTTP/3: fixed Insert With Name Reference index processing.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8775
diff
changeset
|
175 } |
e6c26cb4d38b
HTTP/3: fixed Insert With Name Reference index processing.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8775
diff
changeset
|
176 |
e6c26cb4d38b
HTTP/3: fixed Insert With Name Reference index processing.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8775
diff
changeset
|
177 index = dt->base + dt->nelts - 1 - index; |
e6c26cb4d38b
HTTP/3: fixed Insert With Name Reference index processing.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8775
diff
changeset
|
178 |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
179 if (ngx_http_v3_lookup(c, index, &name, NULL) != NGX_OK) { |
8460
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
8456
diff
changeset
|
180 return NGX_HTTP_V3_ERR_ENCODER_STREAM_ERROR; |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
181 } |
8409
26cb2f3259b1
HTTP/3: reallocate strings inserted into the dynamic table.
Roman Arutyunyan <arut@nginx.com>
parents:
8296
diff
changeset
|
182 |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
183 } else { |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
184 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0, |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
185 "http3 ref insert static[%ui] \"%V\"", index, value); |
8215 | 186 |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
187 if (ngx_http_v3_lookup_static(c, index, &name, NULL) != NGX_OK) { |
8460
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
8456
diff
changeset
|
188 return NGX_HTTP_V3_ERR_ENCODER_STREAM_ERROR; |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
189 } |
8215 | 190 } |
191 | |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
192 return ngx_http_v3_insert(c, &name, value); |
8215 | 193 } |
194 | |
195 | |
196 ngx_int_t | |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
197 ngx_http_v3_insert(ngx_connection_t *c, ngx_str_t *name, ngx_str_t *value) |
8215 | 198 { |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
199 u_char *p; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
200 size_t size; |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8785
diff
changeset
|
201 ngx_http_v3_field_t *field; |
8770
67f0eb150047
HTTP/3: renamed ngx_http_v3_connection_t to ngx_http_v3_session_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8769
diff
changeset
|
202 ngx_http_v3_session_t *h3c; |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
203 ngx_http_v3_dynamic_table_t *dt; |
8215 | 204 |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
205 size = ngx_http_v3_table_entry_size(name, value); |
8215 | 206 |
9062
987bee4363d1
HTTP/3: handled insertion reference to a going to be evicted entry.
Roman Arutyunyan <arut@nginx.com>
parents:
9020
diff
changeset
|
207 h3c = ngx_http_v3_get_session(c); |
987bee4363d1
HTTP/3: handled insertion reference to a going to be evicted entry.
Roman Arutyunyan <arut@nginx.com>
parents:
9020
diff
changeset
|
208 dt = &h3c->table; |
987bee4363d1
HTTP/3: handled insertion reference to a going to be evicted entry.
Roman Arutyunyan <arut@nginx.com>
parents:
9020
diff
changeset
|
209 |
987bee4363d1
HTTP/3: handled insertion reference to a going to be evicted entry.
Roman Arutyunyan <arut@nginx.com>
parents:
9020
diff
changeset
|
210 if (size > dt->capacity) { |
987bee4363d1
HTTP/3: handled insertion reference to a going to be evicted entry.
Roman Arutyunyan <arut@nginx.com>
parents:
9020
diff
changeset
|
211 ngx_log_error(NGX_LOG_ERR, c->log, 0, |
987bee4363d1
HTTP/3: handled insertion reference to a going to be evicted entry.
Roman Arutyunyan <arut@nginx.com>
parents:
9020
diff
changeset
|
212 "not enough dynamic table capacity"); |
8460
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
8456
diff
changeset
|
213 return NGX_HTTP_V3_ERR_ENCODER_STREAM_ERROR; |
8215 | 214 } |
215 | |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
216 ngx_log_debug4(NGX_LOG_DEBUG_HTTP, c->log, 0, |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
217 "http3 insert [%ui] \"%V\":\"%V\", size:%uz", |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
218 dt->base + dt->nelts, name, value, size); |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
219 |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8785
diff
changeset
|
220 p = ngx_alloc(sizeof(ngx_http_v3_field_t) + name->len + value->len, |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
221 c->log); |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
222 if (p == NULL) { |
8215 | 223 return NGX_ERROR; |
224 } | |
225 | |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8785
diff
changeset
|
226 field = (ngx_http_v3_field_t *) p; |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
227 |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8785
diff
changeset
|
228 field->name.data = p + sizeof(ngx_http_v3_field_t); |
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8785
diff
changeset
|
229 field->name.len = name->len; |
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8785
diff
changeset
|
230 field->value.data = ngx_cpymem(field->name.data, name->data, name->len); |
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8785
diff
changeset
|
231 field->value.len = value->len; |
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8785
diff
changeset
|
232 ngx_memcpy(field->value.data, value->data, value->len); |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
233 |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8785
diff
changeset
|
234 dt->elts[dt->nelts++] = field; |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
235 dt->size += size; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
236 |
8989
81a3429db8b0
HTTP/3: delayed Insert Count Increment instruction.
Roman Arutyunyan <arut@nginx.com>
parents:
8925
diff
changeset
|
237 dt->insert_count++; |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
238 |
9062
987bee4363d1
HTTP/3: handled insertion reference to a going to be evicted entry.
Roman Arutyunyan <arut@nginx.com>
parents:
9020
diff
changeset
|
239 if (ngx_http_v3_evict(c, dt->capacity) != NGX_OK) { |
987bee4363d1
HTTP/3: handled insertion reference to a going to be evicted entry.
Roman Arutyunyan <arut@nginx.com>
parents:
9020
diff
changeset
|
240 return NGX_ERROR; |
987bee4363d1
HTTP/3: handled insertion reference to a going to be evicted entry.
Roman Arutyunyan <arut@nginx.com>
parents:
9020
diff
changeset
|
241 } |
987bee4363d1
HTTP/3: handled insertion reference to a going to be evicted entry.
Roman Arutyunyan <arut@nginx.com>
parents:
9020
diff
changeset
|
242 |
8989
81a3429db8b0
HTTP/3: delayed Insert Count Increment instruction.
Roman Arutyunyan <arut@nginx.com>
parents:
8925
diff
changeset
|
243 ngx_post_event(&dt->send_insert_count, &ngx_posted_events); |
8409
26cb2f3259b1
HTTP/3: reallocate strings inserted into the dynamic table.
Roman Arutyunyan <arut@nginx.com>
parents:
8296
diff
changeset
|
244 |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8785
diff
changeset
|
245 if (ngx_http_v3_new_entry(c) != NGX_OK) { |
8215 | 246 return NGX_ERROR; |
247 } | |
248 | |
249 return NGX_OK; | |
250 } | |
251 | |
252 | |
8989
81a3429db8b0
HTTP/3: delayed Insert Count Increment instruction.
Roman Arutyunyan <arut@nginx.com>
parents:
8925
diff
changeset
|
253 void |
81a3429db8b0
HTTP/3: delayed Insert Count Increment instruction.
Roman Arutyunyan <arut@nginx.com>
parents:
8925
diff
changeset
|
254 ngx_http_v3_inc_insert_count_handler(ngx_event_t *ev) |
81a3429db8b0
HTTP/3: delayed Insert Count Increment instruction.
Roman Arutyunyan <arut@nginx.com>
parents:
8925
diff
changeset
|
255 { |
81a3429db8b0
HTTP/3: delayed Insert Count Increment instruction.
Roman Arutyunyan <arut@nginx.com>
parents:
8925
diff
changeset
|
256 ngx_connection_t *c; |
81a3429db8b0
HTTP/3: delayed Insert Count Increment instruction.
Roman Arutyunyan <arut@nginx.com>
parents:
8925
diff
changeset
|
257 ngx_http_v3_session_t *h3c; |
81a3429db8b0
HTTP/3: delayed Insert Count Increment instruction.
Roman Arutyunyan <arut@nginx.com>
parents:
8925
diff
changeset
|
258 ngx_http_v3_dynamic_table_t *dt; |
81a3429db8b0
HTTP/3: delayed Insert Count Increment instruction.
Roman Arutyunyan <arut@nginx.com>
parents:
8925
diff
changeset
|
259 |
81a3429db8b0
HTTP/3: delayed Insert Count Increment instruction.
Roman Arutyunyan <arut@nginx.com>
parents:
8925
diff
changeset
|
260 c = ev->data; |
81a3429db8b0
HTTP/3: delayed Insert Count Increment instruction.
Roman Arutyunyan <arut@nginx.com>
parents:
8925
diff
changeset
|
261 |
81a3429db8b0
HTTP/3: delayed Insert Count Increment instruction.
Roman Arutyunyan <arut@nginx.com>
parents:
8925
diff
changeset
|
262 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, |
81a3429db8b0
HTTP/3: delayed Insert Count Increment instruction.
Roman Arutyunyan <arut@nginx.com>
parents:
8925
diff
changeset
|
263 "http3 inc insert count handler"); |
81a3429db8b0
HTTP/3: delayed Insert Count Increment instruction.
Roman Arutyunyan <arut@nginx.com>
parents:
8925
diff
changeset
|
264 |
81a3429db8b0
HTTP/3: delayed Insert Count Increment instruction.
Roman Arutyunyan <arut@nginx.com>
parents:
8925
diff
changeset
|
265 h3c = ngx_http_v3_get_session(c); |
81a3429db8b0
HTTP/3: delayed Insert Count Increment instruction.
Roman Arutyunyan <arut@nginx.com>
parents:
8925
diff
changeset
|
266 dt = &h3c->table; |
81a3429db8b0
HTTP/3: delayed Insert Count Increment instruction.
Roman Arutyunyan <arut@nginx.com>
parents:
8925
diff
changeset
|
267 |
81a3429db8b0
HTTP/3: delayed Insert Count Increment instruction.
Roman Arutyunyan <arut@nginx.com>
parents:
8925
diff
changeset
|
268 if (dt->insert_count > dt->ack_insert_count) { |
81a3429db8b0
HTTP/3: delayed Insert Count Increment instruction.
Roman Arutyunyan <arut@nginx.com>
parents:
8925
diff
changeset
|
269 if (ngx_http_v3_send_inc_insert_count(c, |
81a3429db8b0
HTTP/3: delayed Insert Count Increment instruction.
Roman Arutyunyan <arut@nginx.com>
parents:
8925
diff
changeset
|
270 dt->insert_count - dt->ack_insert_count) |
81a3429db8b0
HTTP/3: delayed Insert Count Increment instruction.
Roman Arutyunyan <arut@nginx.com>
parents:
8925
diff
changeset
|
271 != NGX_OK) |
81a3429db8b0
HTTP/3: delayed Insert Count Increment instruction.
Roman Arutyunyan <arut@nginx.com>
parents:
8925
diff
changeset
|
272 { |
81a3429db8b0
HTTP/3: delayed Insert Count Increment instruction.
Roman Arutyunyan <arut@nginx.com>
parents:
8925
diff
changeset
|
273 return; |
81a3429db8b0
HTTP/3: delayed Insert Count Increment instruction.
Roman Arutyunyan <arut@nginx.com>
parents:
8925
diff
changeset
|
274 } |
81a3429db8b0
HTTP/3: delayed Insert Count Increment instruction.
Roman Arutyunyan <arut@nginx.com>
parents:
8925
diff
changeset
|
275 |
81a3429db8b0
HTTP/3: delayed Insert Count Increment instruction.
Roman Arutyunyan <arut@nginx.com>
parents:
8925
diff
changeset
|
276 dt->ack_insert_count = dt->insert_count; |
81a3429db8b0
HTTP/3: delayed Insert Count Increment instruction.
Roman Arutyunyan <arut@nginx.com>
parents:
8925
diff
changeset
|
277 } |
81a3429db8b0
HTTP/3: delayed Insert Count Increment instruction.
Roman Arutyunyan <arut@nginx.com>
parents:
8925
diff
changeset
|
278 } |
81a3429db8b0
HTTP/3: delayed Insert Count Increment instruction.
Roman Arutyunyan <arut@nginx.com>
parents:
8925
diff
changeset
|
279 |
81a3429db8b0
HTTP/3: delayed Insert Count Increment instruction.
Roman Arutyunyan <arut@nginx.com>
parents:
8925
diff
changeset
|
280 |
8215 | 281 ngx_int_t |
282 ngx_http_v3_set_capacity(ngx_connection_t *c, ngx_uint_t capacity) | |
283 { | |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
284 ngx_uint_t max, prev_max; |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8785
diff
changeset
|
285 ngx_http_v3_field_t **elts; |
8770
67f0eb150047
HTTP/3: renamed ngx_http_v3_connection_t to ngx_http_v3_session_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8769
diff
changeset
|
286 ngx_http_v3_session_t *h3c; |
8492
65c1fc5fae15
HTTP/3: renamed server configuration variables from v3cf to h3scf.
Roman Arutyunyan <arut@nginx.com>
parents:
8460
diff
changeset
|
287 ngx_http_v3_srv_conf_t *h3scf; |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
288 ngx_http_v3_dynamic_table_t *dt; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
289 |
8215 | 290 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, |
291 "http3 set capacity %ui", capacity); | |
292 | |
8768
40d710a66aef
HTTP/3: ngx_http_v3_get_session() macro.
Roman Arutyunyan <arut@nginx.com>
parents:
8767
diff
changeset
|
293 h3c = ngx_http_v3_get_session(c); |
8769
9ec3e71f8a61
HTTP/3: reference h3c directly from ngx_http_connection_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8768
diff
changeset
|
294 h3scf = ngx_http_v3_get_module_srv_conf(c, ngx_http_v3_module); |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
295 |
8492
65c1fc5fae15
HTTP/3: renamed server configuration variables from v3cf to h3scf.
Roman Arutyunyan <arut@nginx.com>
parents:
8460
diff
changeset
|
296 if (capacity > h3scf->max_table_capacity) { |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
297 ngx_log_error(NGX_LOG_INFO, c->log, 0, |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
298 "client exceeded http3_max_table_capacity limit"); |
8460
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
8456
diff
changeset
|
299 return NGX_HTTP_V3_ERR_ENCODER_STREAM_ERROR; |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
300 } |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
301 |
9062
987bee4363d1
HTTP/3: handled insertion reference to a going to be evicted entry.
Roman Arutyunyan <arut@nginx.com>
parents:
9020
diff
changeset
|
302 if (ngx_http_v3_evict(c, capacity) != NGX_OK) { |
987bee4363d1
HTTP/3: handled insertion reference to a going to be evicted entry.
Roman Arutyunyan <arut@nginx.com>
parents:
9020
diff
changeset
|
303 return NGX_HTTP_V3_ERR_ENCODER_STREAM_ERROR; |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
304 } |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
305 |
9062
987bee4363d1
HTTP/3: handled insertion reference to a going to be evicted entry.
Roman Arutyunyan <arut@nginx.com>
parents:
9020
diff
changeset
|
306 dt = &h3c->table; |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
307 max = capacity / 32; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
308 prev_max = dt->capacity / 32; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
309 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
310 if (max > prev_max) { |
9282
acb8548c00e9
HTTP/3: fixed dynamic table overflow.
Roman Arutyunyan <arut@nginx.com>
parents:
9062
diff
changeset
|
311 elts = ngx_alloc((max + 1) * sizeof(void *), c->log); |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
312 if (elts == NULL) { |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
313 return NGX_ERROR; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
314 } |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
315 |
8775
6e2c23481abb
HTTP/3: clean up table from session cleanup handler.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
316 if (dt->elts) { |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
317 ngx_memcpy(elts, dt->elts, dt->nelts * sizeof(void *)); |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
318 ngx_free(dt->elts); |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
319 } |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
320 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
321 dt->elts = elts; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
322 } |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
323 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
324 dt->capacity = capacity; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
325 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
326 return NGX_OK; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
327 } |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
328 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
329 |
8775
6e2c23481abb
HTTP/3: clean up table from session cleanup handler.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
330 void |
6e2c23481abb
HTTP/3: clean up table from session cleanup handler.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
331 ngx_http_v3_cleanup_table(ngx_http_v3_session_t *h3c) |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
332 { |
8775
6e2c23481abb
HTTP/3: clean up table from session cleanup handler.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
333 ngx_uint_t n; |
6e2c23481abb
HTTP/3: clean up table from session cleanup handler.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
334 ngx_http_v3_dynamic_table_t *dt; |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
335 |
8775
6e2c23481abb
HTTP/3: clean up table from session cleanup handler.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
336 dt = &h3c->table; |
6e2c23481abb
HTTP/3: clean up table from session cleanup handler.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
337 |
6e2c23481abb
HTTP/3: clean up table from session cleanup handler.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
338 if (dt->elts == NULL) { |
6e2c23481abb
HTTP/3: clean up table from session cleanup handler.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
339 return; |
6e2c23481abb
HTTP/3: clean up table from session cleanup handler.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
340 } |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
341 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
342 for (n = 0; n < dt->nelts; n++) { |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
343 ngx_free(dt->elts[n]); |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
344 } |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
345 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
346 ngx_free(dt->elts); |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
347 } |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
348 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
349 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
350 static ngx_int_t |
9062
987bee4363d1
HTTP/3: handled insertion reference to a going to be evicted entry.
Roman Arutyunyan <arut@nginx.com>
parents:
9020
diff
changeset
|
351 ngx_http_v3_evict(ngx_connection_t *c, size_t target) |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
352 { |
9062
987bee4363d1
HTTP/3: handled insertion reference to a going to be evicted entry.
Roman Arutyunyan <arut@nginx.com>
parents:
9020
diff
changeset
|
353 size_t size; |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
354 ngx_uint_t n; |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8785
diff
changeset
|
355 ngx_http_v3_field_t *field; |
8770
67f0eb150047
HTTP/3: renamed ngx_http_v3_connection_t to ngx_http_v3_session_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8769
diff
changeset
|
356 ngx_http_v3_session_t *h3c; |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
357 ngx_http_v3_dynamic_table_t *dt; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
358 |
8768
40d710a66aef
HTTP/3: ngx_http_v3_get_session() macro.
Roman Arutyunyan <arut@nginx.com>
parents:
8767
diff
changeset
|
359 h3c = ngx_http_v3_get_session(c); |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
360 dt = &h3c->table; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
361 n = 0; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
362 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
363 while (dt->size > target) { |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8785
diff
changeset
|
364 field = dt->elts[n++]; |
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8785
diff
changeset
|
365 size = ngx_http_v3_table_entry_size(&field->name, &field->value); |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
366 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
367 ngx_log_debug4(NGX_LOG_DEBUG_HTTP, c->log, 0, |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
368 "http3 evict [%ui] \"%V\":\"%V\" size:%uz", |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8785
diff
changeset
|
369 dt->base, &field->name, &field->value, size); |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
370 |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8785
diff
changeset
|
371 ngx_free(field); |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
372 dt->size -= size; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
373 } |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
374 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
375 if (n) { |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
376 dt->nelts -= n; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
377 dt->base += n; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
378 ngx_memmove(dt->elts, &dt->elts[n], dt->nelts * sizeof(void *)); |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
379 } |
8215 | 380 |
381 return NGX_OK; | |
382 } | |
383 | |
384 | |
385 ngx_int_t | |
386 ngx_http_v3_duplicate(ngx_connection_t *c, ngx_uint_t index) | |
387 { | |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
388 ngx_str_t name, value; |
8770
67f0eb150047
HTTP/3: renamed ngx_http_v3_connection_t to ngx_http_v3_session_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8769
diff
changeset
|
389 ngx_http_v3_session_t *h3c; |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
390 ngx_http_v3_dynamic_table_t *dt; |
8215 | 391 |
392 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 duplicate %ui", index); | |
393 | |
8768
40d710a66aef
HTTP/3: ngx_http_v3_get_session() macro.
Roman Arutyunyan <arut@nginx.com>
parents:
8767
diff
changeset
|
394 h3c = ngx_http_v3_get_session(c); |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
395 dt = &h3c->table; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
396 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
397 if (dt->base + dt->nelts <= index) { |
8460
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
8456
diff
changeset
|
398 return NGX_HTTP_V3_ERR_ENCODER_STREAM_ERROR; |
8215 | 399 } |
400 | |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
401 index = dt->base + dt->nelts - 1 - index; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
402 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
403 if (ngx_http_v3_lookup(c, index, &name, &value) != NGX_OK) { |
8460
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
8456
diff
changeset
|
404 return NGX_HTTP_V3_ERR_ENCODER_STREAM_ERROR; |
8215 | 405 } |
406 | |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
407 return ngx_http_v3_insert(c, &name, &value); |
8215 | 408 } |
409 | |
410 | |
411 ngx_int_t | |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8785
diff
changeset
|
412 ngx_http_v3_ack_section(ngx_connection_t *c, ngx_uint_t stream_id) |
8215 | 413 { |
414 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, | |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8785
diff
changeset
|
415 "http3 ack section %ui", stream_id); |
8215 | 416 |
8766
70701edfc5d4
HTTP/3: fixed decoder stream stubs.
Roman Arutyunyan <arut@nginx.com>
parents:
8630
diff
changeset
|
417 /* we do not use dynamic tables */ |
8215 | 418 |
8766
70701edfc5d4
HTTP/3: fixed decoder stream stubs.
Roman Arutyunyan <arut@nginx.com>
parents:
8630
diff
changeset
|
419 return NGX_HTTP_V3_ERR_DECODER_STREAM_ERROR; |
8215 | 420 } |
421 | |
422 | |
423 ngx_int_t | |
424 ngx_http_v3_inc_insert_count(ngx_connection_t *c, ngx_uint_t inc) | |
425 { | |
426 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, | |
427 "http3 increment insert count %ui", inc); | |
428 | |
8766
70701edfc5d4
HTTP/3: fixed decoder stream stubs.
Roman Arutyunyan <arut@nginx.com>
parents:
8630
diff
changeset
|
429 /* we do not use dynamic tables */ |
8215 | 430 |
8766
70701edfc5d4
HTTP/3: fixed decoder stream stubs.
Roman Arutyunyan <arut@nginx.com>
parents:
8630
diff
changeset
|
431 return NGX_HTTP_V3_ERR_DECODER_STREAM_ERROR; |
8215 | 432 } |
433 | |
434 | |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
435 ngx_int_t |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
436 ngx_http_v3_lookup_static(ngx_connection_t *c, ngx_uint_t index, |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
437 ngx_str_t *name, ngx_str_t *value) |
8215 | 438 { |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8785
diff
changeset
|
439 ngx_uint_t nelts; |
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8785
diff
changeset
|
440 ngx_http_v3_field_t *field; |
8215 | 441 |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
442 nelts = sizeof(ngx_http_v3_static_table) |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
443 / sizeof(ngx_http_v3_static_table[0]); |
8215 | 444 |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
445 if (index >= nelts) { |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
446 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0, |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
447 "http3 static[%ui] lookup out of bounds: %ui", |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
448 index, nelts); |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
449 return NGX_ERROR; |
8215 | 450 } |
451 | |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8785
diff
changeset
|
452 field = &ngx_http_v3_static_table[index]; |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
453 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
454 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, c->log, 0, |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
455 "http3 static[%ui] lookup \"%V\":\"%V\"", |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8785
diff
changeset
|
456 index, &field->name, &field->value); |
8215 | 457 |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
458 if (name) { |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8785
diff
changeset
|
459 *name = field->name; |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
460 } |
8215 | 461 |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
462 if (value) { |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8785
diff
changeset
|
463 *value = field->value; |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
464 } |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
465 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
466 return NGX_OK; |
8215 | 467 } |
468 | |
469 | |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
470 ngx_int_t |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
471 ngx_http_v3_lookup(ngx_connection_t *c, ngx_uint_t index, ngx_str_t *name, |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
472 ngx_str_t *value) |
8215 | 473 { |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8785
diff
changeset
|
474 ngx_http_v3_field_t *field; |
8770
67f0eb150047
HTTP/3: renamed ngx_http_v3_connection_t to ngx_http_v3_session_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8769
diff
changeset
|
475 ngx_http_v3_session_t *h3c; |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
476 ngx_http_v3_dynamic_table_t *dt; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
477 |
8768
40d710a66aef
HTTP/3: ngx_http_v3_get_session() macro.
Roman Arutyunyan <arut@nginx.com>
parents:
8767
diff
changeset
|
478 h3c = ngx_http_v3_get_session(c); |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
479 dt = &h3c->table; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
480 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
481 if (index < dt->base || index - dt->base >= dt->nelts) { |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
482 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, c->log, 0, |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
483 "http3 dynamic[%ui] lookup out of bounds: [%ui,%ui]", |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
484 index, dt->base, dt->base + dt->nelts); |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
485 return NGX_ERROR; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
486 } |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
487 |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8785
diff
changeset
|
488 field = dt->elts[index - dt->base]; |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
489 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
490 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, c->log, 0, |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
491 "http3 dynamic[%ui] lookup \"%V\":\"%V\"", |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8785
diff
changeset
|
492 index, &field->name, &field->value); |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
493 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
494 if (name) { |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8785
diff
changeset
|
495 *name = field->name; |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
496 } |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
497 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
498 if (value) { |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8785
diff
changeset
|
499 *value = field->value; |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
500 } |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
501 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
502 return NGX_OK; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
503 } |
8215 | 504 |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
505 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
506 ngx_int_t |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
507 ngx_http_v3_decode_insert_count(ngx_connection_t *c, ngx_uint_t *insert_count) |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
508 { |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
509 ngx_uint_t max_entries, full_range, max_value, |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
510 max_wrapped, req_insert_count; |
8492
65c1fc5fae15
HTTP/3: renamed server configuration variables from v3cf to h3scf.
Roman Arutyunyan <arut@nginx.com>
parents:
8460
diff
changeset
|
511 ngx_http_v3_srv_conf_t *h3scf; |
8770
67f0eb150047
HTTP/3: renamed ngx_http_v3_connection_t to ngx_http_v3_session_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8769
diff
changeset
|
512 ngx_http_v3_session_t *h3c; |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
513 ngx_http_v3_dynamic_table_t *dt; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
514 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
515 /* QPACK 4.5.1.1. Required Insert Count */ |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
516 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
517 if (*insert_count == 0) { |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
518 return NGX_OK; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
519 } |
8215 | 520 |
8768
40d710a66aef
HTTP/3: ngx_http_v3_get_session() macro.
Roman Arutyunyan <arut@nginx.com>
parents:
8767
diff
changeset
|
521 h3c = ngx_http_v3_get_session(c); |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
522 dt = &h3c->table; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
523 |
8769
9ec3e71f8a61
HTTP/3: reference h3c directly from ngx_http_connection_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8768
diff
changeset
|
524 h3scf = ngx_http_v3_get_module_srv_conf(c, ngx_http_v3_module); |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
525 |
8492
65c1fc5fae15
HTTP/3: renamed server configuration variables from v3cf to h3scf.
Roman Arutyunyan <arut@nginx.com>
parents:
8460
diff
changeset
|
526 max_entries = h3scf->max_table_capacity / 32; |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
527 full_range = 2 * max_entries; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
528 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
529 if (*insert_count > full_range) { |
8460
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
8456
diff
changeset
|
530 return NGX_HTTP_V3_ERR_DECOMPRESSION_FAILED; |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
531 } |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
532 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
533 max_value = dt->base + dt->nelts + max_entries; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
534 max_wrapped = (max_value / full_range) * full_range; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
535 req_insert_count = max_wrapped + *insert_count - 1; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
536 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
537 if (req_insert_count > max_value) { |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
538 if (req_insert_count <= full_range) { |
8460
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
8456
diff
changeset
|
539 return NGX_HTTP_V3_ERR_DECOMPRESSION_FAILED; |
8215 | 540 } |
541 | |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
542 req_insert_count -= full_range; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
543 } |
8215 | 544 |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
545 if (req_insert_count == 0) { |
8460
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
8456
diff
changeset
|
546 return NGX_HTTP_V3_ERR_DECOMPRESSION_FAILED; |
8215 | 547 } |
548 | |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
549 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0, |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
550 "http3 decode insert_count %ui -> %ui", |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
551 *insert_count, req_insert_count); |
8215 | 552 |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
553 *insert_count = req_insert_count; |
8215 | 554 |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
555 return NGX_OK; |
8215 | 556 } |
557 | |
558 | |
559 ngx_int_t | |
560 ngx_http_v3_check_insert_count(ngx_connection_t *c, ngx_uint_t insert_count) | |
561 { | |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
562 size_t n; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
563 ngx_pool_cleanup_t *cln; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
564 ngx_http_v3_block_t *block; |
8770
67f0eb150047
HTTP/3: renamed ngx_http_v3_connection_t to ngx_http_v3_session_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8769
diff
changeset
|
565 ngx_http_v3_session_t *h3c; |
8492
65c1fc5fae15
HTTP/3: renamed server configuration variables from v3cf to h3scf.
Roman Arutyunyan <arut@nginx.com>
parents:
8460
diff
changeset
|
566 ngx_http_v3_srv_conf_t *h3scf; |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
567 ngx_http_v3_dynamic_table_t *dt; |
8215 | 568 |
8768
40d710a66aef
HTTP/3: ngx_http_v3_get_session() macro.
Roman Arutyunyan <arut@nginx.com>
parents:
8767
diff
changeset
|
569 h3c = ngx_http_v3_get_session(c); |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
570 dt = &h3c->table; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
571 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
572 n = dt->base + dt->nelts; |
8215 | 573 |
574 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0, | |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
575 "http3 check insert count req:%ui, have:%ui", |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
576 insert_count, n); |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
577 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
578 if (n >= insert_count) { |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
579 return NGX_OK; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
580 } |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
581 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
582 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 block stream"); |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
583 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
584 block = NULL; |
8215 | 585 |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
586 for (cln = c->pool->cleanup; cln; cln = cln->next) { |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
587 if (cln->handler == ngx_http_v3_unblock) { |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
588 block = cln->data; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
589 break; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
590 } |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
591 } |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
592 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
593 if (block == NULL) { |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
594 cln = ngx_pool_cleanup_add(c->pool, sizeof(ngx_http_v3_block_t)); |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
595 if (cln == NULL) { |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
596 return NGX_ERROR; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
597 } |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
598 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
599 cln->handler = ngx_http_v3_unblock; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
600 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
601 block = cln->data; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
602 block->queue.prev = NULL; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
603 block->connection = c; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
604 block->nblocked = &h3c->nblocked; |
8215 | 605 } |
606 | |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
607 if (block->queue.prev == NULL) { |
8769
9ec3e71f8a61
HTTP/3: reference h3c directly from ngx_http_connection_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8768
diff
changeset
|
608 h3scf = ngx_http_v3_get_module_srv_conf(c, ngx_http_v3_module); |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
609 |
8492
65c1fc5fae15
HTTP/3: renamed server configuration variables from v3cf to h3scf.
Roman Arutyunyan <arut@nginx.com>
parents:
8460
diff
changeset
|
610 if (h3c->nblocked == h3scf->max_blocked_streams) { |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
611 ngx_log_error(NGX_LOG_INFO, c->log, 0, |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
612 "client exceeded http3_max_blocked_streams limit"); |
8902
925572184d4a
HTTP/3: adjusted QUIC connection finalization.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
613 |
925572184d4a
HTTP/3: adjusted QUIC connection finalization.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
614 ngx_http_v3_finalize_connection(c, |
925572184d4a
HTTP/3: adjusted QUIC connection finalization.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
615 NGX_HTTP_V3_ERR_DECOMPRESSION_FAILED, |
925572184d4a
HTTP/3: adjusted QUIC connection finalization.
Roman Arutyunyan <arut@nginx.com>
parents:
8807
diff
changeset
|
616 "too many blocked streams"); |
8460
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
8456
diff
changeset
|
617 return NGX_HTTP_V3_ERR_DECOMPRESSION_FAILED; |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
618 } |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
619 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
620 h3c->nblocked++; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
621 ngx_queue_insert_tail(&h3c->blocked, &block->queue); |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
622 } |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
623 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
624 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
625 "http3 blocked:%ui", h3c->nblocked); |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
626 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
627 return NGX_BUSY; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
628 } |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
629 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
630 |
8989
81a3429db8b0
HTTP/3: delayed Insert Count Increment instruction.
Roman Arutyunyan <arut@nginx.com>
parents:
8925
diff
changeset
|
631 void |
81a3429db8b0
HTTP/3: delayed Insert Count Increment instruction.
Roman Arutyunyan <arut@nginx.com>
parents:
8925
diff
changeset
|
632 ngx_http_v3_ack_insert_count(ngx_connection_t *c, uint64_t insert_count) |
81a3429db8b0
HTTP/3: delayed Insert Count Increment instruction.
Roman Arutyunyan <arut@nginx.com>
parents:
8925
diff
changeset
|
633 { |
81a3429db8b0
HTTP/3: delayed Insert Count Increment instruction.
Roman Arutyunyan <arut@nginx.com>
parents:
8925
diff
changeset
|
634 ngx_http_v3_session_t *h3c; |
81a3429db8b0
HTTP/3: delayed Insert Count Increment instruction.
Roman Arutyunyan <arut@nginx.com>
parents:
8925
diff
changeset
|
635 ngx_http_v3_dynamic_table_t *dt; |
81a3429db8b0
HTTP/3: delayed Insert Count Increment instruction.
Roman Arutyunyan <arut@nginx.com>
parents:
8925
diff
changeset
|
636 |
81a3429db8b0
HTTP/3: delayed Insert Count Increment instruction.
Roman Arutyunyan <arut@nginx.com>
parents:
8925
diff
changeset
|
637 h3c = ngx_http_v3_get_session(c); |
81a3429db8b0
HTTP/3: delayed Insert Count Increment instruction.
Roman Arutyunyan <arut@nginx.com>
parents:
8925
diff
changeset
|
638 dt = &h3c->table; |
81a3429db8b0
HTTP/3: delayed Insert Count Increment instruction.
Roman Arutyunyan <arut@nginx.com>
parents:
8925
diff
changeset
|
639 |
81a3429db8b0
HTTP/3: delayed Insert Count Increment instruction.
Roman Arutyunyan <arut@nginx.com>
parents:
8925
diff
changeset
|
640 if (dt->ack_insert_count < insert_count) { |
81a3429db8b0
HTTP/3: delayed Insert Count Increment instruction.
Roman Arutyunyan <arut@nginx.com>
parents:
8925
diff
changeset
|
641 dt->ack_insert_count = insert_count; |
81a3429db8b0
HTTP/3: delayed Insert Count Increment instruction.
Roman Arutyunyan <arut@nginx.com>
parents:
8925
diff
changeset
|
642 } |
81a3429db8b0
HTTP/3: delayed Insert Count Increment instruction.
Roman Arutyunyan <arut@nginx.com>
parents:
8925
diff
changeset
|
643 } |
81a3429db8b0
HTTP/3: delayed Insert Count Increment instruction.
Roman Arutyunyan <arut@nginx.com>
parents:
8925
diff
changeset
|
644 |
81a3429db8b0
HTTP/3: delayed Insert Count Increment instruction.
Roman Arutyunyan <arut@nginx.com>
parents:
8925
diff
changeset
|
645 |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
646 static void |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
647 ngx_http_v3_unblock(void *data) |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
648 { |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
649 ngx_http_v3_block_t *block = data; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
650 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
651 if (block->queue.prev) { |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
652 ngx_queue_remove(&block->queue); |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
653 block->queue.prev = NULL; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
654 (*block->nblocked)--; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
655 } |
8215 | 656 } |
657 | |
658 | |
659 static ngx_int_t | |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8785
diff
changeset
|
660 ngx_http_v3_new_entry(ngx_connection_t *c) |
8215 | 661 { |
8770
67f0eb150047
HTTP/3: renamed ngx_http_v3_connection_t to ngx_http_v3_session_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8769
diff
changeset
|
662 ngx_queue_t *q; |
67f0eb150047
HTTP/3: renamed ngx_http_v3_connection_t to ngx_http_v3_session_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8769
diff
changeset
|
663 ngx_connection_t *bc; |
67f0eb150047
HTTP/3: renamed ngx_http_v3_connection_t to ngx_http_v3_session_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8769
diff
changeset
|
664 ngx_http_v3_block_t *block; |
67f0eb150047
HTTP/3: renamed ngx_http_v3_connection_t to ngx_http_v3_session_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8769
diff
changeset
|
665 ngx_http_v3_session_t *h3c; |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
666 |
8768
40d710a66aef
HTTP/3: ngx_http_v3_get_session() macro.
Roman Arutyunyan <arut@nginx.com>
parents:
8767
diff
changeset
|
667 h3c = ngx_http_v3_get_session(c); |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
668 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
669 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8785
diff
changeset
|
670 "http3 new dynamic entry, blocked:%ui", h3c->nblocked); |
8215 | 671 |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
672 while (!ngx_queue_empty(&h3c->blocked)) { |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
673 q = ngx_queue_head(&h3c->blocked); |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
674 block = (ngx_http_v3_block_t *) q; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
675 bc = block->connection; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
676 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
677 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, bc->log, 0, "http3 unblock stream"); |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
678 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
679 ngx_http_v3_unblock(block); |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
680 ngx_post_event(bc->read, &ngx_posted_events); |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8409
diff
changeset
|
681 } |
8215 | 682 |
683 return NGX_OK; | |
684 } | |
8226
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8215
diff
changeset
|
685 |
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8215
diff
changeset
|
686 |
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8215
diff
changeset
|
687 ngx_int_t |
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8215
diff
changeset
|
688 ngx_http_v3_set_param(ngx_connection_t *c, uint64_t id, uint64_t value) |
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8215
diff
changeset
|
689 { |
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8215
diff
changeset
|
690 switch (id) { |
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8215
diff
changeset
|
691 |
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8215
diff
changeset
|
692 case NGX_HTTP_V3_PARAM_MAX_TABLE_CAPACITY: |
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8215
diff
changeset
|
693 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, |
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8215
diff
changeset
|
694 "http3 param QPACK_MAX_TABLE_CAPACITY:%uL", value); |
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8215
diff
changeset
|
695 break; |
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8215
diff
changeset
|
696 |
9020
efbcdb9b37dc
HTTP/3: updated SETTINGS_MAX_FIELD_SECTION_SIZE name.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8989
diff
changeset
|
697 case NGX_HTTP_V3_PARAM_MAX_FIELD_SECTION_SIZE: |
8226
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8215
diff
changeset
|
698 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, |
9020
efbcdb9b37dc
HTTP/3: updated SETTINGS_MAX_FIELD_SECTION_SIZE name.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8989
diff
changeset
|
699 "http3 param SETTINGS_MAX_FIELD_SECTION_SIZE:%uL", |
efbcdb9b37dc
HTTP/3: updated SETTINGS_MAX_FIELD_SECTION_SIZE name.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8989
diff
changeset
|
700 value); |
8226
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8215
diff
changeset
|
701 break; |
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8215
diff
changeset
|
702 |
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8215
diff
changeset
|
703 case NGX_HTTP_V3_PARAM_BLOCKED_STREAMS: |
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8215
diff
changeset
|
704 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, |
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8215
diff
changeset
|
705 "http3 param QPACK_BLOCKED_STREAMS:%uL", value); |
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8215
diff
changeset
|
706 break; |
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8215
diff
changeset
|
707 |
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8215
diff
changeset
|
708 default: |
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8215
diff
changeset
|
709 |
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8215
diff
changeset
|
710 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0, |
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8215
diff
changeset
|
711 "http3 param #%uL:%uL", id, value); |
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8215
diff
changeset
|
712 } |
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8215
diff
changeset
|
713 |
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8215
diff
changeset
|
714 return NGX_OK; |
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8215
diff
changeset
|
715 } |