Mercurial > hg > nginx
annotate src/http/v3/ngx_http_v3_streams.c @ 8812:e7a2d3914877 quic
Core: added separate function for local source address cmsg.
author | Vladimir Homutov <vl@nginx.com> |
---|---|
date | Thu, 15 Jul 2021 14:22:54 +0300 |
parents | 0ac25efb2da3 |
children | d80365ca678d |
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 | |
13 typedef struct { | |
8772
345370fdd32d
HTTP/3: moved parsing uni stream type to ngx_http_v3_parse.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
14 ngx_http_v3_parse_uni_t parse; |
8283
dadbc66e9fca
Simplifed handling HTTP/3 streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8281
diff
changeset
|
15 ngx_int_t index; |
8215 | 16 } ngx_http_v3_uni_stream_t; |
17 | |
18 | |
8497 | 19 typedef struct { |
20 ngx_queue_t queue; | |
21 uint64_t id; | |
22 ngx_connection_t *connection; | |
23 ngx_uint_t *npushing; | |
24 } ngx_http_v3_push_t; | |
25 | |
26 | |
8215 | 27 static void ngx_http_v3_close_uni_stream(ngx_connection_t *c); |
8226
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8215
diff
changeset
|
28 static void ngx_http_v3_uni_read_handler(ngx_event_t *rev); |
8281
618a65de08b3
When closing a QUIC connection, wait for all streams to finish.
Roman Arutyunyan <arut@nginx.com>
parents:
8228
diff
changeset
|
29 static void ngx_http_v3_dummy_write_handler(ngx_event_t *wev); |
8497 | 30 static void ngx_http_v3_push_cleanup(void *data); |
8283
dadbc66e9fca
Simplifed handling HTTP/3 streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8281
diff
changeset
|
31 static ngx_connection_t *ngx_http_v3_get_uni_stream(ngx_connection_t *c, |
8215 | 32 ngx_uint_t type); |
8725
98c4020f1c9a
HTTP/3: keepalive timeout.
Roman Arutyunyan <arut@nginx.com>
parents:
8724
diff
changeset
|
33 |
98c4020f1c9a
HTTP/3: keepalive timeout.
Roman Arutyunyan <arut@nginx.com>
parents:
8724
diff
changeset
|
34 |
8679
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8630
diff
changeset
|
35 void |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8630
diff
changeset
|
36 ngx_http_v3_init_uni_stream(ngx_connection_t *c) |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8630
diff
changeset
|
37 { |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8630
diff
changeset
|
38 ngx_http_v3_uni_stream_t *us; |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8630
diff
changeset
|
39 |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8630
diff
changeset
|
40 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 init uni stream"); |
8215 | 41 |
8724
fc64ab301bad
QUIC: connection shutdown.
Roman Arutyunyan <arut@nginx.com>
parents:
8723
diff
changeset
|
42 c->quic->cancelable = 1; |
fc64ab301bad
QUIC: connection shutdown.
Roman Arutyunyan <arut@nginx.com>
parents:
8723
diff
changeset
|
43 |
8215 | 44 us = ngx_pcalloc(c->pool, sizeof(ngx_http_v3_uni_stream_t)); |
45 if (us == NULL) { | |
8679
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8630
diff
changeset
|
46 ngx_http_close_connection(c); |
e1eb7f4ca9f1
HTTP/3: refactored request parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8630
diff
changeset
|
47 return; |
8215 | 48 } |
49 | |
8283
dadbc66e9fca
Simplifed handling HTTP/3 streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8281
diff
changeset
|
50 us->index = -1; |
8215 | 51 |
52 c->data = us; | |
53 | |
8772
345370fdd32d
HTTP/3: moved parsing uni stream type to ngx_http_v3_parse.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
54 c->read->handler = ngx_http_v3_uni_read_handler; |
8281
618a65de08b3
When closing a QUIC connection, wait for all streams to finish.
Roman Arutyunyan <arut@nginx.com>
parents:
8228
diff
changeset
|
55 c->write->handler = ngx_http_v3_dummy_write_handler; |
618a65de08b3
When closing a QUIC connection, wait for all streams to finish.
Roman Arutyunyan <arut@nginx.com>
parents:
8228
diff
changeset
|
56 |
8772
345370fdd32d
HTTP/3: moved parsing uni stream type to ngx_http_v3_parse.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
57 ngx_http_v3_uni_read_handler(c->read); |
8215 | 58 } |
59 | |
60 | |
61 static void | |
62 ngx_http_v3_close_uni_stream(ngx_connection_t *c) | |
63 { | |
8283
dadbc66e9fca
Simplifed handling HTTP/3 streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8281
diff
changeset
|
64 ngx_pool_t *pool; |
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
|
65 ngx_http_v3_session_t *h3c; |
8283
dadbc66e9fca
Simplifed handling HTTP/3 streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8281
diff
changeset
|
66 ngx_http_v3_uni_stream_t *us; |
dadbc66e9fca
Simplifed handling HTTP/3 streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8281
diff
changeset
|
67 |
dadbc66e9fca
Simplifed handling HTTP/3 streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8281
diff
changeset
|
68 us = c->data; |
8768
40d710a66aef
HTTP/3: ngx_http_v3_get_session() macro.
Roman Arutyunyan <arut@nginx.com>
parents:
8767
diff
changeset
|
69 h3c = ngx_http_v3_get_session(c); |
8283
dadbc66e9fca
Simplifed handling HTTP/3 streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8281
diff
changeset
|
70 |
dadbc66e9fca
Simplifed handling HTTP/3 streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8281
diff
changeset
|
71 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 close stream"); |
dadbc66e9fca
Simplifed handling HTTP/3 streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8281
diff
changeset
|
72 |
dadbc66e9fca
Simplifed handling HTTP/3 streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8281
diff
changeset
|
73 if (us->index >= 0) { |
dadbc66e9fca
Simplifed handling HTTP/3 streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8281
diff
changeset
|
74 h3c->known_streams[us->index] = NULL; |
dadbc66e9fca
Simplifed handling HTTP/3 streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8281
diff
changeset
|
75 } |
8215 | 76 |
77 c->destroyed = 1; | |
78 | |
79 pool = c->pool; | |
80 | |
81 ngx_close_connection(c); | |
82 | |
83 ngx_destroy_pool(pool); | |
84 } | |
85 | |
86 | |
8772
345370fdd32d
HTTP/3: moved parsing uni stream type to ngx_http_v3_parse.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
87 ngx_int_t |
345370fdd32d
HTTP/3: moved parsing uni stream type to ngx_http_v3_parse.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
88 ngx_http_v3_register_uni_stream(ngx_connection_t *c, uint64_t type) |
8215 | 89 { |
8772
345370fdd32d
HTTP/3: moved parsing uni stream type to ngx_http_v3_parse.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
90 ngx_int_t index; |
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
|
91 ngx_http_v3_session_t *h3c; |
8283
dadbc66e9fca
Simplifed handling HTTP/3 streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8281
diff
changeset
|
92 ngx_http_v3_uni_stream_t *us; |
8215 | 93 |
8772
345370fdd32d
HTTP/3: moved parsing uni stream type to ngx_http_v3_parse.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
94 switch (type) { |
345370fdd32d
HTTP/3: moved parsing uni stream type to ngx_http_v3_parse.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
95 |
345370fdd32d
HTTP/3: moved parsing uni stream type to ngx_http_v3_parse.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
96 case NGX_HTTP_V3_STREAM_ENCODER: |
345370fdd32d
HTTP/3: moved parsing uni stream type to ngx_http_v3_parse.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
97 |
345370fdd32d
HTTP/3: moved parsing uni stream type to ngx_http_v3_parse.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
98 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, |
345370fdd32d
HTTP/3: moved parsing uni stream type to ngx_http_v3_parse.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
99 "http3 encoder stream"); |
345370fdd32d
HTTP/3: moved parsing uni stream type to ngx_http_v3_parse.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
100 index = NGX_HTTP_V3_STREAM_CLIENT_ENCODER; |
345370fdd32d
HTTP/3: moved parsing uni stream type to ngx_http_v3_parse.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
101 break; |
8215 | 102 |
8772
345370fdd32d
HTTP/3: moved parsing uni stream type to ngx_http_v3_parse.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
103 case NGX_HTTP_V3_STREAM_DECODER: |
8215 | 104 |
8772
345370fdd32d
HTTP/3: moved parsing uni stream type to ngx_http_v3_parse.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
105 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, |
345370fdd32d
HTTP/3: moved parsing uni stream type to ngx_http_v3_parse.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
106 "http3 decoder stream"); |
345370fdd32d
HTTP/3: moved parsing uni stream type to ngx_http_v3_parse.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
107 index = NGX_HTTP_V3_STREAM_CLIENT_DECODER; |
345370fdd32d
HTTP/3: moved parsing uni stream type to ngx_http_v3_parse.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
108 break; |
8215 | 109 |
8772
345370fdd32d
HTTP/3: moved parsing uni stream type to ngx_http_v3_parse.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
110 case NGX_HTTP_V3_STREAM_CONTROL: |
8215 | 111 |
8772
345370fdd32d
HTTP/3: moved parsing uni stream type to ngx_http_v3_parse.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
112 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, |
345370fdd32d
HTTP/3: moved parsing uni stream type to ngx_http_v3_parse.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
113 "http3 control stream"); |
345370fdd32d
HTTP/3: moved parsing uni stream type to ngx_http_v3_parse.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
114 index = NGX_HTTP_V3_STREAM_CLIENT_CONTROL; |
345370fdd32d
HTTP/3: moved parsing uni stream type to ngx_http_v3_parse.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
115 |
345370fdd32d
HTTP/3: moved parsing uni stream type to ngx_http_v3_parse.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
116 break; |
345370fdd32d
HTTP/3: moved parsing uni stream type to ngx_http_v3_parse.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
117 |
345370fdd32d
HTTP/3: moved parsing uni stream type to ngx_http_v3_parse.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
118 default: |
8460
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
8456
diff
changeset
|
119 |
8772
345370fdd32d
HTTP/3: moved parsing uni stream type to ngx_http_v3_parse.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
120 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, |
345370fdd32d
HTTP/3: moved parsing uni stream type to ngx_http_v3_parse.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
121 "http3 stream 0x%02xL", type); |
345370fdd32d
HTTP/3: moved parsing uni stream type to ngx_http_v3_parse.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
122 index = -1; |
345370fdd32d
HTTP/3: moved parsing uni stream type to ngx_http_v3_parse.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
123 } |
8215 | 124 |
8772
345370fdd32d
HTTP/3: moved parsing uni stream type to ngx_http_v3_parse.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
125 if (index >= 0) { |
345370fdd32d
HTTP/3: moved parsing uni stream type to ngx_http_v3_parse.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
126 h3c = ngx_http_v3_get_session(c); |
345370fdd32d
HTTP/3: moved parsing uni stream type to ngx_http_v3_parse.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
127 |
345370fdd32d
HTTP/3: moved parsing uni stream type to ngx_http_v3_parse.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
128 if (h3c->known_streams[index]) { |
345370fdd32d
HTTP/3: moved parsing uni stream type to ngx_http_v3_parse.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
129 ngx_log_error(NGX_LOG_INFO, c->log, 0, "stream exists"); |
345370fdd32d
HTTP/3: moved parsing uni stream type to ngx_http_v3_parse.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
130 return NGX_HTTP_V3_ERR_STREAM_CREATION_ERROR; |
8215 | 131 } |
132 | |
8772
345370fdd32d
HTTP/3: moved parsing uni stream type to ngx_http_v3_parse.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
133 h3c->known_streams[index] = c; |
8226
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8215
diff
changeset
|
134 |
8772
345370fdd32d
HTTP/3: moved parsing uni stream type to ngx_http_v3_parse.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
135 us = c->data; |
345370fdd32d
HTTP/3: moved parsing uni stream type to ngx_http_v3_parse.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
136 us->index = index; |
8215 | 137 } |
138 | |
8772
345370fdd32d
HTTP/3: moved parsing uni stream type to ngx_http_v3_parse.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
139 return NGX_OK; |
8215 | 140 } |
141 | |
142 | |
143 static void | |
8226
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8215
diff
changeset
|
144 ngx_http_v3_uni_read_handler(ngx_event_t *rev) |
8215 | 145 { |
8226
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8215
diff
changeset
|
146 u_char buf[128]; |
8215 | 147 ssize_t n; |
8226
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8215
diff
changeset
|
148 ngx_int_t rc, i; |
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8215
diff
changeset
|
149 ngx_connection_t *c; |
8283
dadbc66e9fca
Simplifed handling HTTP/3 streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8281
diff
changeset
|
150 ngx_http_v3_uni_stream_t *us; |
8215 | 151 |
152 c = rev->data; | |
8283
dadbc66e9fca
Simplifed handling HTTP/3 streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8281
diff
changeset
|
153 us = c->data; |
8215 | 154 |
8226
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8215
diff
changeset
|
155 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 read handler"); |
8215 | 156 |
157 while (rev->ready) { | |
158 | |
8226
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8215
diff
changeset
|
159 n = c->recv(c, buf, sizeof(buf)); |
8215 | 160 |
8460
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
8456
diff
changeset
|
161 if (n == NGX_ERROR) { |
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
8456
diff
changeset
|
162 rc = NGX_HTTP_V3_ERR_INTERNAL_ERROR; |
8215 | 163 goto failed; |
164 } | |
165 | |
8460
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
8456
diff
changeset
|
166 if (n == 0) { |
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
8456
diff
changeset
|
167 if (us->index >= 0) { |
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
8456
diff
changeset
|
168 rc = NGX_HTTP_V3_ERR_CLOSED_CRITICAL_STREAM; |
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
8456
diff
changeset
|
169 goto failed; |
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
8456
diff
changeset
|
170 } |
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
8456
diff
changeset
|
171 |
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
8456
diff
changeset
|
172 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 read eof"); |
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
8456
diff
changeset
|
173 ngx_http_v3_close_uni_stream(c); |
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
8456
diff
changeset
|
174 return; |
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
8456
diff
changeset
|
175 } |
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
8456
diff
changeset
|
176 |
8226
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8215
diff
changeset
|
177 if (n == NGX_AGAIN) { |
8215 | 178 break; |
179 } | |
180 | |
8226
268f4389130d
Refactored HTTP/3 parser.
Roman Arutyunyan <arut@nginx.com>
parents:
8215
diff
changeset
|
181 for (i = 0; i < n; i++) { |
8215 | 182 |
8772
345370fdd32d
HTTP/3: moved parsing uni stream type to ngx_http_v3_parse.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8771
diff
changeset
|
183 rc = ngx_http_v3_parse_uni(c, &us->parse, buf[i]); |
8215 | 184 |
8460
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
8456
diff
changeset
|
185 if (rc == NGX_DONE) { |
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
8456
diff
changeset
|
186 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, |
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
8456
diff
changeset
|
187 "http3 read done"); |
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
8456
diff
changeset
|
188 ngx_http_v3_close_uni_stream(c); |
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
8456
diff
changeset
|
189 return; |
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
8456
diff
changeset
|
190 } |
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
8456
diff
changeset
|
191 |
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
8456
diff
changeset
|
192 if (rc > 0) { |
8215 | 193 goto failed; |
194 } | |
195 | |
8460
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
8456
diff
changeset
|
196 if (rc != NGX_AGAIN) { |
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
8456
diff
changeset
|
197 rc = NGX_HTTP_V3_ERR_GENERAL_PROTOCOL_ERROR; |
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
8456
diff
changeset
|
198 goto failed; |
8215 | 199 } |
200 } | |
201 } | |
202 | |
203 if (ngx_handle_read_event(rev, 0) != NGX_OK) { | |
8460
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
8456
diff
changeset
|
204 rc = NGX_HTTP_V3_ERR_INTERNAL_ERROR; |
8215 | 205 goto failed; |
206 } | |
207 | |
208 return; | |
209 | |
210 failed: | |
211 | |
8460
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
8456
diff
changeset
|
212 ngx_http_v3_finalize_connection(c, rc, "stream error"); |
8215 | 213 ngx_http_v3_close_uni_stream(c); |
214 } | |
215 | |
216 | |
8281
618a65de08b3
When closing a QUIC connection, wait for all streams to finish.
Roman Arutyunyan <arut@nginx.com>
parents:
8228
diff
changeset
|
217 static void |
618a65de08b3
When closing a QUIC connection, wait for all streams to finish.
Roman Arutyunyan <arut@nginx.com>
parents:
8228
diff
changeset
|
218 ngx_http_v3_dummy_write_handler(ngx_event_t *wev) |
618a65de08b3
When closing a QUIC connection, wait for all streams to finish.
Roman Arutyunyan <arut@nginx.com>
parents:
8228
diff
changeset
|
219 { |
618a65de08b3
When closing a QUIC connection, wait for all streams to finish.
Roman Arutyunyan <arut@nginx.com>
parents:
8228
diff
changeset
|
220 ngx_connection_t *c; |
618a65de08b3
When closing a QUIC connection, wait for all streams to finish.
Roman Arutyunyan <arut@nginx.com>
parents:
8228
diff
changeset
|
221 |
618a65de08b3
When closing a QUIC connection, wait for all streams to finish.
Roman Arutyunyan <arut@nginx.com>
parents:
8228
diff
changeset
|
222 c = wev->data; |
618a65de08b3
When closing a QUIC connection, wait for all streams to finish.
Roman Arutyunyan <arut@nginx.com>
parents:
8228
diff
changeset
|
223 |
618a65de08b3
When closing a QUIC connection, wait for all streams to finish.
Roman Arutyunyan <arut@nginx.com>
parents:
8228
diff
changeset
|
224 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 dummy write handler"); |
618a65de08b3
When closing a QUIC connection, wait for all streams to finish.
Roman Arutyunyan <arut@nginx.com>
parents:
8228
diff
changeset
|
225 |
618a65de08b3
When closing a QUIC connection, wait for all streams to finish.
Roman Arutyunyan <arut@nginx.com>
parents:
8228
diff
changeset
|
226 if (ngx_handle_write_event(wev, 0) != NGX_OK) { |
8460
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
8456
diff
changeset
|
227 ngx_http_v3_finalize_connection(c, NGX_HTTP_V3_ERR_INTERNAL_ERROR, |
72f9ff4e0a88
HTTP/3: close QUIC connection with HTTP/QPACK errors when needed.
Roman Arutyunyan <arut@nginx.com>
parents:
8456
diff
changeset
|
228 NULL); |
8281
618a65de08b3
When closing a QUIC connection, wait for all streams to finish.
Roman Arutyunyan <arut@nginx.com>
parents:
8228
diff
changeset
|
229 ngx_http_v3_close_uni_stream(c); |
618a65de08b3
When closing a QUIC connection, wait for all streams to finish.
Roman Arutyunyan <arut@nginx.com>
parents:
8228
diff
changeset
|
230 } |
618a65de08b3
When closing a QUIC connection, wait for all streams to finish.
Roman Arutyunyan <arut@nginx.com>
parents:
8228
diff
changeset
|
231 } |
618a65de08b3
When closing a QUIC connection, wait for all streams to finish.
Roman Arutyunyan <arut@nginx.com>
parents:
8228
diff
changeset
|
232 |
618a65de08b3
When closing a QUIC connection, wait for all streams to finish.
Roman Arutyunyan <arut@nginx.com>
parents:
8228
diff
changeset
|
233 |
8215 | 234 /* XXX async & buffered stream writes */ |
235 | |
8497 | 236 ngx_connection_t * |
237 ngx_http_v3_create_push_stream(ngx_connection_t *c, uint64_t push_id) | |
238 { | |
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
|
239 u_char *p, buf[NGX_HTTP_V3_VARLEN_INT_LEN * 2]; |
67f0eb150047
HTTP/3: renamed ngx_http_v3_connection_t to ngx_http_v3_session_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8769
diff
changeset
|
240 size_t n; |
67f0eb150047
HTTP/3: renamed ngx_http_v3_connection_t to ngx_http_v3_session_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8769
diff
changeset
|
241 ngx_connection_t *sc; |
67f0eb150047
HTTP/3: renamed ngx_http_v3_connection_t to ngx_http_v3_session_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8769
diff
changeset
|
242 ngx_pool_cleanup_t *cln; |
67f0eb150047
HTTP/3: renamed ngx_http_v3_connection_t to ngx_http_v3_session_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8769
diff
changeset
|
243 ngx_http_v3_push_t *push; |
67f0eb150047
HTTP/3: renamed ngx_http_v3_connection_t to ngx_http_v3_session_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8769
diff
changeset
|
244 ngx_http_v3_session_t *h3c; |
8497 | 245 |
246 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, | |
247 "http3 create push stream id:%uL", push_id); | |
248 | |
249 sc = ngx_quic_open_stream(c, 0); | |
250 if (sc == NULL) { | |
251 return NULL; | |
252 } | |
253 | |
254 p = buf; | |
255 p = (u_char *) ngx_http_v3_encode_varlen_int(p, NGX_HTTP_V3_STREAM_PUSH); | |
256 p = (u_char *) ngx_http_v3_encode_varlen_int(p, push_id); | |
257 n = p - buf; | |
258 | |
259 if (sc->send(sc, buf, n) != (ssize_t) n) { | |
260 goto failed; | |
261 } | |
262 | |
263 cln = ngx_pool_cleanup_add(sc->pool, sizeof(ngx_http_v3_push_t)); | |
264 if (cln == NULL) { | |
265 goto failed; | |
266 } | |
267 | |
8768
40d710a66aef
HTTP/3: ngx_http_v3_get_session() macro.
Roman Arutyunyan <arut@nginx.com>
parents:
8767
diff
changeset
|
268 h3c = ngx_http_v3_get_session(c); |
8497 | 269 h3c->npushing++; |
270 | |
271 cln->handler = ngx_http_v3_push_cleanup; | |
272 | |
273 push = cln->data; | |
274 push->id = push_id; | |
275 push->connection = sc; | |
276 push->npushing = &h3c->npushing; | |
277 | |
278 ngx_queue_insert_tail(&h3c->pushing, &push->queue); | |
279 | |
280 return sc; | |
281 | |
282 failed: | |
283 | |
284 ngx_http_v3_close_uni_stream(sc); | |
285 | |
286 return NULL; | |
287 } | |
288 | |
289 | |
290 static void | |
291 ngx_http_v3_push_cleanup(void *data) | |
292 { | |
293 ngx_http_v3_push_t *push = data; | |
294 | |
295 ngx_queue_remove(&push->queue); | |
296 (*push->npushing)--; | |
297 } | |
298 | |
299 | |
8215 | 300 static ngx_connection_t * |
8283
dadbc66e9fca
Simplifed handling HTTP/3 streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8281
diff
changeset
|
301 ngx_http_v3_get_uni_stream(ngx_connection_t *c, ngx_uint_t type) |
8215 | 302 { |
303 u_char buf[NGX_HTTP_V3_VARLEN_INT_LEN]; | |
304 size_t n; | |
8283
dadbc66e9fca
Simplifed handling HTTP/3 streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8281
diff
changeset
|
305 ngx_int_t index; |
8215 | 306 ngx_connection_t *sc; |
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
|
307 ngx_http_v3_session_t *h3c; |
8215 | 308 ngx_http_v3_uni_stream_t *us; |
309 | |
8283
dadbc66e9fca
Simplifed handling HTTP/3 streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8281
diff
changeset
|
310 switch (type) { |
dadbc66e9fca
Simplifed handling HTTP/3 streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8281
diff
changeset
|
311 case NGX_HTTP_V3_STREAM_ENCODER: |
dadbc66e9fca
Simplifed handling HTTP/3 streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8281
diff
changeset
|
312 index = NGX_HTTP_V3_STREAM_SERVER_ENCODER; |
dadbc66e9fca
Simplifed handling HTTP/3 streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8281
diff
changeset
|
313 break; |
dadbc66e9fca
Simplifed handling HTTP/3 streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8281
diff
changeset
|
314 case NGX_HTTP_V3_STREAM_DECODER: |
dadbc66e9fca
Simplifed handling HTTP/3 streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8281
diff
changeset
|
315 index = NGX_HTTP_V3_STREAM_SERVER_DECODER; |
dadbc66e9fca
Simplifed handling HTTP/3 streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8281
diff
changeset
|
316 break; |
dadbc66e9fca
Simplifed handling HTTP/3 streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8281
diff
changeset
|
317 case NGX_HTTP_V3_STREAM_CONTROL: |
dadbc66e9fca
Simplifed handling HTTP/3 streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8281
diff
changeset
|
318 index = NGX_HTTP_V3_STREAM_SERVER_CONTROL; |
dadbc66e9fca
Simplifed handling HTTP/3 streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8281
diff
changeset
|
319 break; |
dadbc66e9fca
Simplifed handling HTTP/3 streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8281
diff
changeset
|
320 default: |
dadbc66e9fca
Simplifed handling HTTP/3 streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8281
diff
changeset
|
321 index = -1; |
dadbc66e9fca
Simplifed handling HTTP/3 streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8281
diff
changeset
|
322 } |
dadbc66e9fca
Simplifed handling HTTP/3 streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8281
diff
changeset
|
323 |
8768
40d710a66aef
HTTP/3: ngx_http_v3_get_session() macro.
Roman Arutyunyan <arut@nginx.com>
parents:
8767
diff
changeset
|
324 h3c = ngx_http_v3_get_session(c); |
8283
dadbc66e9fca
Simplifed handling HTTP/3 streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8281
diff
changeset
|
325 |
dadbc66e9fca
Simplifed handling HTTP/3 streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8281
diff
changeset
|
326 if (index >= 0) { |
dadbc66e9fca
Simplifed handling HTTP/3 streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8281
diff
changeset
|
327 if (h3c->known_streams[index]) { |
dadbc66e9fca
Simplifed handling HTTP/3 streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8281
diff
changeset
|
328 return h3c->known_streams[index]; |
dadbc66e9fca
Simplifed handling HTTP/3 streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8281
diff
changeset
|
329 } |
dadbc66e9fca
Simplifed handling HTTP/3 streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8281
diff
changeset
|
330 } |
dadbc66e9fca
Simplifed handling HTTP/3 streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8281
diff
changeset
|
331 |
8495
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8492
diff
changeset
|
332 sc = ngx_quic_open_stream(c, 0); |
8215 | 333 if (sc == NULL) { |
334 return NULL; | |
335 } | |
336 | |
8724
fc64ab301bad
QUIC: connection shutdown.
Roman Arutyunyan <arut@nginx.com>
parents:
8723
diff
changeset
|
337 sc->quic->cancelable = 1; |
fc64ab301bad
QUIC: connection shutdown.
Roman Arutyunyan <arut@nginx.com>
parents:
8723
diff
changeset
|
338 |
8215 | 339 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, |
340 "http3 create uni stream, type:%ui", type); | |
341 | |
342 us = ngx_pcalloc(sc->pool, sizeof(ngx_http_v3_uni_stream_t)); | |
343 if (us == NULL) { | |
344 goto failed; | |
345 } | |
346 | |
8283
dadbc66e9fca
Simplifed handling HTTP/3 streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8281
diff
changeset
|
347 us->index = index; |
dadbc66e9fca
Simplifed handling HTTP/3 streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8281
diff
changeset
|
348 |
8215 | 349 sc->data = us; |
350 | |
8281
618a65de08b3
When closing a QUIC connection, wait for all streams to finish.
Roman Arutyunyan <arut@nginx.com>
parents:
8228
diff
changeset
|
351 sc->read->handler = ngx_http_v3_uni_read_handler; |
618a65de08b3
When closing a QUIC connection, wait for all streams to finish.
Roman Arutyunyan <arut@nginx.com>
parents:
8228
diff
changeset
|
352 sc->write->handler = ngx_http_v3_dummy_write_handler; |
618a65de08b3
When closing a QUIC connection, wait for all streams to finish.
Roman Arutyunyan <arut@nginx.com>
parents:
8228
diff
changeset
|
353 |
8403
c101438c69a4
HTTP/3: prevent array access by negative index for unknown streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8362
diff
changeset
|
354 if (index >= 0) { |
c101438c69a4
HTTP/3: prevent array access by negative index for unknown streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8362
diff
changeset
|
355 h3c->known_streams[index] = sc; |
c101438c69a4
HTTP/3: prevent array access by negative index for unknown streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8362
diff
changeset
|
356 } |
8215 | 357 |
358 n = (u_char *) ngx_http_v3_encode_varlen_int(buf, type) - buf; | |
359 | |
360 if (sc->send(sc, buf, n) != (ssize_t) n) { | |
361 goto failed; | |
362 } | |
363 | |
364 return sc; | |
365 | |
366 failed: | |
367 | |
368 ngx_http_v3_close_uni_stream(sc); | |
369 | |
370 return NULL; | |
371 } | |
372 | |
373 | |
8774
f4d3f5d93a82
HTTP/3: moved session initialization to a separate file.
Roman Arutyunyan <arut@nginx.com>
parents:
8772
diff
changeset
|
374 ngx_int_t |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8403
diff
changeset
|
375 ngx_http_v3_send_settings(ngx_connection_t *c) |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8403
diff
changeset
|
376 { |
8769
9ec3e71f8a61
HTTP/3: reference h3c directly from ngx_http_connection_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8768
diff
changeset
|
377 u_char *p, buf[NGX_HTTP_V3_VARLEN_INT_LEN * 6]; |
9ec3e71f8a61
HTTP/3: reference h3c directly from ngx_http_connection_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8768
diff
changeset
|
378 size_t n; |
9ec3e71f8a61
HTTP/3: reference h3c directly from ngx_http_connection_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8768
diff
changeset
|
379 ngx_connection_t *cc; |
9ec3e71f8a61
HTTP/3: reference h3c directly from ngx_http_connection_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8768
diff
changeset
|
380 ngx_http_v3_srv_conf_t *h3scf; |
8495
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8492
diff
changeset
|
381 |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8403
diff
changeset
|
382 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 send settings"); |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8403
diff
changeset
|
383 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8403
diff
changeset
|
384 cc = ngx_http_v3_get_uni_stream(c, NGX_HTTP_V3_STREAM_CONTROL); |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8403
diff
changeset
|
385 if (cc == NULL) { |
8495
455a8536eaa7
QUIC: limited the number of server-initiated streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8492
diff
changeset
|
386 return NGX_DECLINED; |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8403
diff
changeset
|
387 } |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8403
diff
changeset
|
388 |
8769
9ec3e71f8a61
HTTP/3: reference h3c directly from ngx_http_connection_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8768
diff
changeset
|
389 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:
8403
diff
changeset
|
390 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8403
diff
changeset
|
391 n = ngx_http_v3_encode_varlen_int(NULL, |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8403
diff
changeset
|
392 NGX_HTTP_V3_PARAM_MAX_TABLE_CAPACITY); |
8492
65c1fc5fae15
HTTP/3: renamed server configuration variables from v3cf to h3scf.
Roman Arutyunyan <arut@nginx.com>
parents:
8481
diff
changeset
|
393 n += ngx_http_v3_encode_varlen_int(NULL, h3scf->max_table_capacity); |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8403
diff
changeset
|
394 n += ngx_http_v3_encode_varlen_int(NULL, NGX_HTTP_V3_PARAM_BLOCKED_STREAMS); |
8492
65c1fc5fae15
HTTP/3: renamed server configuration variables from v3cf to h3scf.
Roman Arutyunyan <arut@nginx.com>
parents:
8481
diff
changeset
|
395 n += ngx_http_v3_encode_varlen_int(NULL, h3scf->max_blocked_streams); |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8403
diff
changeset
|
396 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8403
diff
changeset
|
397 p = (u_char *) ngx_http_v3_encode_varlen_int(buf, |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8403
diff
changeset
|
398 NGX_HTTP_V3_FRAME_SETTINGS); |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8403
diff
changeset
|
399 p = (u_char *) ngx_http_v3_encode_varlen_int(p, n); |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8403
diff
changeset
|
400 p = (u_char *) ngx_http_v3_encode_varlen_int(p, |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8403
diff
changeset
|
401 NGX_HTTP_V3_PARAM_MAX_TABLE_CAPACITY); |
8492
65c1fc5fae15
HTTP/3: renamed server configuration variables from v3cf to h3scf.
Roman Arutyunyan <arut@nginx.com>
parents:
8481
diff
changeset
|
402 p = (u_char *) ngx_http_v3_encode_varlen_int(p, h3scf->max_table_capacity); |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8403
diff
changeset
|
403 p = (u_char *) ngx_http_v3_encode_varlen_int(p, |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8403
diff
changeset
|
404 NGX_HTTP_V3_PARAM_BLOCKED_STREAMS); |
8492
65c1fc5fae15
HTTP/3: renamed server configuration variables from v3cf to h3scf.
Roman Arutyunyan <arut@nginx.com>
parents:
8481
diff
changeset
|
405 p = (u_char *) ngx_http_v3_encode_varlen_int(p, h3scf->max_blocked_streams); |
8456
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8403
diff
changeset
|
406 n = p - buf; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8403
diff
changeset
|
407 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8403
diff
changeset
|
408 if (cc->send(cc, buf, n) != (ssize_t) n) { |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8403
diff
changeset
|
409 goto failed; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8403
diff
changeset
|
410 } |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8403
diff
changeset
|
411 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8403
diff
changeset
|
412 return NGX_OK; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8403
diff
changeset
|
413 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8403
diff
changeset
|
414 failed: |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8403
diff
changeset
|
415 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8403
diff
changeset
|
416 ngx_http_v3_close_uni_stream(cc); |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8403
diff
changeset
|
417 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8403
diff
changeset
|
418 return NGX_ERROR; |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8403
diff
changeset
|
419 } |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8403
diff
changeset
|
420 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8403
diff
changeset
|
421 |
c9538aef3211
HTTP/3: refactored dynamic table implementation.
Roman Arutyunyan <arut@nginx.com>
parents:
8403
diff
changeset
|
422 ngx_int_t |
8723
265062a99043
HTTP/3: send GOAWAY when last request is accepted.
Roman Arutyunyan <arut@nginx.com>
parents:
8719
diff
changeset
|
423 ngx_http_v3_send_goaway(ngx_connection_t *c, uint64_t id) |
265062a99043
HTTP/3: send GOAWAY when last request is accepted.
Roman Arutyunyan <arut@nginx.com>
parents:
8719
diff
changeset
|
424 { |
265062a99043
HTTP/3: send GOAWAY when last request is accepted.
Roman Arutyunyan <arut@nginx.com>
parents:
8719
diff
changeset
|
425 u_char *p, buf[NGX_HTTP_V3_VARLEN_INT_LEN * 3]; |
265062a99043
HTTP/3: send GOAWAY when last request is accepted.
Roman Arutyunyan <arut@nginx.com>
parents:
8719
diff
changeset
|
426 size_t n; |
265062a99043
HTTP/3: send GOAWAY when last request is accepted.
Roman Arutyunyan <arut@nginx.com>
parents:
8719
diff
changeset
|
427 ngx_connection_t *cc; |
265062a99043
HTTP/3: send GOAWAY when last request is accepted.
Roman Arutyunyan <arut@nginx.com>
parents:
8719
diff
changeset
|
428 |
265062a99043
HTTP/3: send GOAWAY when last request is accepted.
Roman Arutyunyan <arut@nginx.com>
parents:
8719
diff
changeset
|
429 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 send goaway %uL", id); |
265062a99043
HTTP/3: send GOAWAY when last request is accepted.
Roman Arutyunyan <arut@nginx.com>
parents:
8719
diff
changeset
|
430 |
265062a99043
HTTP/3: send GOAWAY when last request is accepted.
Roman Arutyunyan <arut@nginx.com>
parents:
8719
diff
changeset
|
431 cc = ngx_http_v3_get_uni_stream(c, NGX_HTTP_V3_STREAM_CONTROL); |
265062a99043
HTTP/3: send GOAWAY when last request is accepted.
Roman Arutyunyan <arut@nginx.com>
parents:
8719
diff
changeset
|
432 if (cc == NULL) { |
265062a99043
HTTP/3: send GOAWAY when last request is accepted.
Roman Arutyunyan <arut@nginx.com>
parents:
8719
diff
changeset
|
433 return NGX_DECLINED; |
265062a99043
HTTP/3: send GOAWAY when last request is accepted.
Roman Arutyunyan <arut@nginx.com>
parents:
8719
diff
changeset
|
434 } |
265062a99043
HTTP/3: send GOAWAY when last request is accepted.
Roman Arutyunyan <arut@nginx.com>
parents:
8719
diff
changeset
|
435 |
265062a99043
HTTP/3: send GOAWAY when last request is accepted.
Roman Arutyunyan <arut@nginx.com>
parents:
8719
diff
changeset
|
436 n = ngx_http_v3_encode_varlen_int(NULL, id); |
265062a99043
HTTP/3: send GOAWAY when last request is accepted.
Roman Arutyunyan <arut@nginx.com>
parents:
8719
diff
changeset
|
437 p = (u_char *) ngx_http_v3_encode_varlen_int(buf, NGX_HTTP_V3_FRAME_GOAWAY); |
265062a99043
HTTP/3: send GOAWAY when last request is accepted.
Roman Arutyunyan <arut@nginx.com>
parents:
8719
diff
changeset
|
438 p = (u_char *) ngx_http_v3_encode_varlen_int(p, n); |
265062a99043
HTTP/3: send GOAWAY when last request is accepted.
Roman Arutyunyan <arut@nginx.com>
parents:
8719
diff
changeset
|
439 p = (u_char *) ngx_http_v3_encode_varlen_int(p, id); |
265062a99043
HTTP/3: send GOAWAY when last request is accepted.
Roman Arutyunyan <arut@nginx.com>
parents:
8719
diff
changeset
|
440 n = p - buf; |
265062a99043
HTTP/3: send GOAWAY when last request is accepted.
Roman Arutyunyan <arut@nginx.com>
parents:
8719
diff
changeset
|
441 |
265062a99043
HTTP/3: send GOAWAY when last request is accepted.
Roman Arutyunyan <arut@nginx.com>
parents:
8719
diff
changeset
|
442 if (cc->send(cc, buf, n) != (ssize_t) n) { |
265062a99043
HTTP/3: send GOAWAY when last request is accepted.
Roman Arutyunyan <arut@nginx.com>
parents:
8719
diff
changeset
|
443 goto failed; |
265062a99043
HTTP/3: send GOAWAY when last request is accepted.
Roman Arutyunyan <arut@nginx.com>
parents:
8719
diff
changeset
|
444 } |
265062a99043
HTTP/3: send GOAWAY when last request is accepted.
Roman Arutyunyan <arut@nginx.com>
parents:
8719
diff
changeset
|
445 |
265062a99043
HTTP/3: send GOAWAY when last request is accepted.
Roman Arutyunyan <arut@nginx.com>
parents:
8719
diff
changeset
|
446 return NGX_OK; |
265062a99043
HTTP/3: send GOAWAY when last request is accepted.
Roman Arutyunyan <arut@nginx.com>
parents:
8719
diff
changeset
|
447 |
265062a99043
HTTP/3: send GOAWAY when last request is accepted.
Roman Arutyunyan <arut@nginx.com>
parents:
8719
diff
changeset
|
448 failed: |
265062a99043
HTTP/3: send GOAWAY when last request is accepted.
Roman Arutyunyan <arut@nginx.com>
parents:
8719
diff
changeset
|
449 |
265062a99043
HTTP/3: send GOAWAY when last request is accepted.
Roman Arutyunyan <arut@nginx.com>
parents:
8719
diff
changeset
|
450 ngx_http_v3_close_uni_stream(cc); |
265062a99043
HTTP/3: send GOAWAY when last request is accepted.
Roman Arutyunyan <arut@nginx.com>
parents:
8719
diff
changeset
|
451 |
265062a99043
HTTP/3: send GOAWAY when last request is accepted.
Roman Arutyunyan <arut@nginx.com>
parents:
8719
diff
changeset
|
452 return NGX_ERROR; |
265062a99043
HTTP/3: send GOAWAY when last request is accepted.
Roman Arutyunyan <arut@nginx.com>
parents:
8719
diff
changeset
|
453 } |
265062a99043
HTTP/3: send GOAWAY when last request is accepted.
Roman Arutyunyan <arut@nginx.com>
parents:
8719
diff
changeset
|
454 |
265062a99043
HTTP/3: send GOAWAY when last request is accepted.
Roman Arutyunyan <arut@nginx.com>
parents:
8719
diff
changeset
|
455 |
265062a99043
HTTP/3: send GOAWAY when last request is accepted.
Roman Arutyunyan <arut@nginx.com>
parents:
8719
diff
changeset
|
456 ngx_int_t |
8771
0981329169ea
HTTP/3: renamed ngx_http_v3_client_XXX() functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8770
diff
changeset
|
457 ngx_http_v3_send_ref_insert(ngx_connection_t *c, ngx_uint_t dynamic, |
8215 | 458 ngx_uint_t index, ngx_str_t *value) |
459 { | |
460 u_char *p, buf[NGX_HTTP_V3_PREFIX_INT_LEN * 2]; | |
461 size_t n; | |
462 ngx_connection_t *ec; | |
463 | |
464 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, c->log, 0, | |
465 "http3 client ref insert, %s[%ui] \"%V\"", | |
466 dynamic ? "dynamic" : "static", index, value); | |
467 | |
8283
dadbc66e9fca
Simplifed handling HTTP/3 streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8281
diff
changeset
|
468 ec = ngx_http_v3_get_uni_stream(c, NGX_HTTP_V3_STREAM_ENCODER); |
8215 | 469 if (ec == NULL) { |
470 return NGX_ERROR; | |
471 } | |
472 | |
473 p = buf; | |
474 | |
475 *p = (dynamic ? 0x80 : 0xc0); | |
476 p = (u_char *) ngx_http_v3_encode_prefix_int(p, index, 6); | |
477 | |
478 /* XXX option for huffman? */ | |
479 *p = 0; | |
480 p = (u_char *) ngx_http_v3_encode_prefix_int(p, value->len, 7); | |
481 | |
482 n = p - buf; | |
483 | |
484 if (ec->send(ec, buf, n) != (ssize_t) n) { | |
485 goto failed; | |
486 } | |
487 | |
488 if (ec->send(ec, value->data, value->len) != (ssize_t) value->len) { | |
489 goto failed; | |
490 } | |
491 | |
492 return NGX_OK; | |
493 | |
494 failed: | |
495 | |
496 ngx_http_v3_close_uni_stream(ec); | |
497 | |
498 return NGX_ERROR; | |
499 } | |
500 | |
501 | |
502 ngx_int_t | |
8771
0981329169ea
HTTP/3: renamed ngx_http_v3_client_XXX() functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8770
diff
changeset
|
503 ngx_http_v3_send_insert(ngx_connection_t *c, ngx_str_t *name, ngx_str_t *value) |
8215 | 504 { |
505 u_char buf[NGX_HTTP_V3_PREFIX_INT_LEN]; | |
506 size_t n; | |
507 ngx_connection_t *ec; | |
508 | |
509 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, c->log, 0, | |
510 "http3 client insert \"%V\":\"%V\"", name, value); | |
511 | |
8283
dadbc66e9fca
Simplifed handling HTTP/3 streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8281
diff
changeset
|
512 ec = ngx_http_v3_get_uni_stream(c, NGX_HTTP_V3_STREAM_ENCODER); |
8215 | 513 if (ec == NULL) { |
514 return NGX_ERROR; | |
515 } | |
516 | |
517 /* XXX option for huffman? */ | |
518 buf[0] = 0x40; | |
519 n = (u_char *) ngx_http_v3_encode_prefix_int(buf, name->len, 5) - buf; | |
520 | |
521 if (ec->send(ec, buf, n) != (ssize_t) n) { | |
522 goto failed; | |
523 } | |
524 | |
525 if (ec->send(ec, name->data, name->len) != (ssize_t) name->len) { | |
526 goto failed; | |
527 } | |
528 | |
529 /* XXX option for huffman? */ | |
530 buf[0] = 0; | |
531 n = (u_char *) ngx_http_v3_encode_prefix_int(buf, value->len, 7) - buf; | |
532 | |
533 if (ec->send(ec, buf, n) != (ssize_t) n) { | |
534 goto failed; | |
535 } | |
536 | |
537 if (ec->send(ec, value->data, value->len) != (ssize_t) value->len) { | |
538 goto failed; | |
539 } | |
540 | |
541 return NGX_OK; | |
542 | |
543 failed: | |
544 | |
545 ngx_http_v3_close_uni_stream(ec); | |
546 | |
547 return NGX_ERROR; | |
548 } | |
549 | |
550 | |
551 ngx_int_t | |
8771
0981329169ea
HTTP/3: renamed ngx_http_v3_client_XXX() functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8770
diff
changeset
|
552 ngx_http_v3_send_set_capacity(ngx_connection_t *c, ngx_uint_t capacity) |
8215 | 553 { |
554 u_char buf[NGX_HTTP_V3_PREFIX_INT_LEN]; | |
555 size_t n; | |
556 ngx_connection_t *ec; | |
557 | |
558 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, | |
559 "http3 client set capacity %ui", capacity); | |
560 | |
8283
dadbc66e9fca
Simplifed handling HTTP/3 streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8281
diff
changeset
|
561 ec = ngx_http_v3_get_uni_stream(c, NGX_HTTP_V3_STREAM_ENCODER); |
8215 | 562 if (ec == NULL) { |
563 return NGX_ERROR; | |
564 } | |
565 | |
566 buf[0] = 0x20; | |
567 n = (u_char *) ngx_http_v3_encode_prefix_int(buf, capacity, 5) - buf; | |
568 | |
569 if (ec->send(ec, buf, n) != (ssize_t) n) { | |
570 ngx_http_v3_close_uni_stream(ec); | |
571 return NGX_ERROR; | |
572 } | |
573 | |
574 return NGX_OK; | |
575 } | |
576 | |
577 | |
578 ngx_int_t | |
8771
0981329169ea
HTTP/3: renamed ngx_http_v3_client_XXX() functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8770
diff
changeset
|
579 ngx_http_v3_send_duplicate(ngx_connection_t *c, ngx_uint_t index) |
8215 | 580 { |
581 u_char buf[NGX_HTTP_V3_PREFIX_INT_LEN]; | |
582 size_t n; | |
583 ngx_connection_t *ec; | |
584 | |
585 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, | |
586 "http3 client duplicate %ui", index); | |
587 | |
8283
dadbc66e9fca
Simplifed handling HTTP/3 streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8281
diff
changeset
|
588 ec = ngx_http_v3_get_uni_stream(c, NGX_HTTP_V3_STREAM_ENCODER); |
8215 | 589 if (ec == NULL) { |
590 return NGX_ERROR; | |
591 } | |
592 | |
593 buf[0] = 0; | |
594 n = (u_char *) ngx_http_v3_encode_prefix_int(buf, index, 5) - buf; | |
595 | |
596 if (ec->send(ec, buf, n) != (ssize_t) n) { | |
597 ngx_http_v3_close_uni_stream(ec); | |
598 return NGX_ERROR; | |
599 } | |
600 | |
601 return NGX_OK; | |
602 } | |
603 | |
604 | |
605 ngx_int_t | |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8796
diff
changeset
|
606 ngx_http_v3_send_ack_section(ngx_connection_t *c, ngx_uint_t stream_id) |
8215 | 607 { |
608 u_char buf[NGX_HTTP_V3_PREFIX_INT_LEN]; | |
609 size_t n; | |
610 ngx_connection_t *dc; | |
611 | |
612 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, | |
8807
0ac25efb2da3
HTTP/3: quic-qpack term updates.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8796
diff
changeset
|
613 "http3 client ack section %ui", stream_id); |
8215 | 614 |
8283
dadbc66e9fca
Simplifed handling HTTP/3 streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8281
diff
changeset
|
615 dc = ngx_http_v3_get_uni_stream(c, NGX_HTTP_V3_STREAM_DECODER); |
8215 | 616 if (dc == NULL) { |
617 return NGX_ERROR; | |
618 } | |
619 | |
620 buf[0] = 0x80; | |
621 n = (u_char *) ngx_http_v3_encode_prefix_int(buf, stream_id, 7) - buf; | |
622 | |
623 if (dc->send(dc, buf, n) != (ssize_t) n) { | |
624 ngx_http_v3_close_uni_stream(dc); | |
625 return NGX_ERROR; | |
626 } | |
627 | |
628 return NGX_OK; | |
629 } | |
630 | |
631 | |
632 ngx_int_t | |
8771
0981329169ea
HTTP/3: renamed ngx_http_v3_client_XXX() functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8770
diff
changeset
|
633 ngx_http_v3_send_cancel_stream(ngx_connection_t *c, ngx_uint_t stream_id) |
8215 | 634 { |
635 u_char buf[NGX_HTTP_V3_PREFIX_INT_LEN]; | |
636 size_t n; | |
637 ngx_connection_t *dc; | |
638 | |
639 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, | |
640 "http3 client cancel stream %ui", stream_id); | |
641 | |
8283
dadbc66e9fca
Simplifed handling HTTP/3 streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8281
diff
changeset
|
642 dc = ngx_http_v3_get_uni_stream(c, NGX_HTTP_V3_STREAM_DECODER); |
8215 | 643 if (dc == NULL) { |
644 return NGX_ERROR; | |
645 } | |
646 | |
647 buf[0] = 0x40; | |
648 n = (u_char *) ngx_http_v3_encode_prefix_int(buf, stream_id, 6) - buf; | |
649 | |
650 if (dc->send(dc, buf, n) != (ssize_t) n) { | |
651 ngx_http_v3_close_uni_stream(dc); | |
652 return NGX_ERROR; | |
653 } | |
654 | |
655 return NGX_OK; | |
656 } | |
657 | |
658 | |
659 ngx_int_t | |
8771
0981329169ea
HTTP/3: renamed ngx_http_v3_client_XXX() functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8770
diff
changeset
|
660 ngx_http_v3_send_inc_insert_count(ngx_connection_t *c, ngx_uint_t inc) |
8215 | 661 { |
662 u_char buf[NGX_HTTP_V3_PREFIX_INT_LEN]; | |
663 size_t n; | |
664 ngx_connection_t *dc; | |
665 | |
666 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, | |
667 "http3 client increment insert count %ui", inc); | |
668 | |
8283
dadbc66e9fca
Simplifed handling HTTP/3 streams.
Roman Arutyunyan <arut@nginx.com>
parents:
8281
diff
changeset
|
669 dc = ngx_http_v3_get_uni_stream(c, NGX_HTTP_V3_STREAM_DECODER); |
8215 | 670 if (dc == NULL) { |
671 return NGX_ERROR; | |
672 } | |
673 | |
674 buf[0] = 0; | |
675 n = (u_char *) ngx_http_v3_encode_prefix_int(buf, inc, 6) - buf; | |
676 | |
677 if (dc->send(dc, buf, n) != (ssize_t) n) { | |
678 ngx_http_v3_close_uni_stream(dc); | |
679 return NGX_ERROR; | |
680 } | |
681 | |
682 return NGX_OK; | |
683 } | |
8497 | 684 |
685 | |
686 ngx_int_t | |
687 ngx_http_v3_set_max_push_id(ngx_connection_t *c, uint64_t max_push_id) | |
688 { | |
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
|
689 ngx_http_v3_session_t *h3c; |
8497 | 690 |
8768
40d710a66aef
HTTP/3: ngx_http_v3_get_session() macro.
Roman Arutyunyan <arut@nginx.com>
parents:
8767
diff
changeset
|
691 h3c = ngx_http_v3_get_session(c); |
8497 | 692 |
693 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, | |
694 "http3 MAX_PUSH_ID:%uL", max_push_id); | |
695 | |
8719
5cb5b568282b
HTTP/3: do not push until a MAX_PUSH_ID frame is received.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8679
diff
changeset
|
696 if (h3c->max_push_id != (uint64_t) -1 && max_push_id < h3c->max_push_id) { |
8497 | 697 return NGX_HTTP_V3_ERR_ID_ERROR; |
698 } | |
699 | |
700 h3c->max_push_id = max_push_id; | |
701 | |
702 return NGX_OK; | |
703 } | |
704 | |
705 | |
706 ngx_int_t | |
8796
1fec68e322d0
HTTP/3: client GOAWAY support.
Roman Arutyunyan <arut@nginx.com>
parents:
8774
diff
changeset
|
707 ngx_http_v3_goaway(ngx_connection_t *c, uint64_t push_id) |
1fec68e322d0
HTTP/3: client GOAWAY support.
Roman Arutyunyan <arut@nginx.com>
parents:
8774
diff
changeset
|
708 { |
1fec68e322d0
HTTP/3: client GOAWAY support.
Roman Arutyunyan <arut@nginx.com>
parents:
8774
diff
changeset
|
709 ngx_http_v3_session_t *h3c; |
1fec68e322d0
HTTP/3: client GOAWAY support.
Roman Arutyunyan <arut@nginx.com>
parents:
8774
diff
changeset
|
710 |
1fec68e322d0
HTTP/3: client GOAWAY support.
Roman Arutyunyan <arut@nginx.com>
parents:
8774
diff
changeset
|
711 h3c = ngx_http_v3_get_session(c); |
1fec68e322d0
HTTP/3: client GOAWAY support.
Roman Arutyunyan <arut@nginx.com>
parents:
8774
diff
changeset
|
712 |
1fec68e322d0
HTTP/3: client GOAWAY support.
Roman Arutyunyan <arut@nginx.com>
parents:
8774
diff
changeset
|
713 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, "http3 GOAWAY:%uL", push_id); |
1fec68e322d0
HTTP/3: client GOAWAY support.
Roman Arutyunyan <arut@nginx.com>
parents:
8774
diff
changeset
|
714 |
1fec68e322d0
HTTP/3: client GOAWAY support.
Roman Arutyunyan <arut@nginx.com>
parents:
8774
diff
changeset
|
715 h3c->goaway_push_id = push_id; |
1fec68e322d0
HTTP/3: client GOAWAY support.
Roman Arutyunyan <arut@nginx.com>
parents:
8774
diff
changeset
|
716 |
1fec68e322d0
HTTP/3: client GOAWAY support.
Roman Arutyunyan <arut@nginx.com>
parents:
8774
diff
changeset
|
717 return NGX_OK; |
1fec68e322d0
HTTP/3: client GOAWAY support.
Roman Arutyunyan <arut@nginx.com>
parents:
8774
diff
changeset
|
718 } |
1fec68e322d0
HTTP/3: client GOAWAY support.
Roman Arutyunyan <arut@nginx.com>
parents:
8774
diff
changeset
|
719 |
1fec68e322d0
HTTP/3: client GOAWAY support.
Roman Arutyunyan <arut@nginx.com>
parents:
8774
diff
changeset
|
720 |
1fec68e322d0
HTTP/3: client GOAWAY support.
Roman Arutyunyan <arut@nginx.com>
parents:
8774
diff
changeset
|
721 ngx_int_t |
8497 | 722 ngx_http_v3_cancel_push(ngx_connection_t *c, uint64_t push_id) |
723 { | |
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
|
724 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
|
725 ngx_http_request_t *r; |
67f0eb150047
HTTP/3: renamed ngx_http_v3_connection_t to ngx_http_v3_session_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8769
diff
changeset
|
726 ngx_http_v3_push_t *push; |
67f0eb150047
HTTP/3: renamed ngx_http_v3_connection_t to ngx_http_v3_session_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8769
diff
changeset
|
727 ngx_http_v3_session_t *h3c; |
8497 | 728 |
8768
40d710a66aef
HTTP/3: ngx_http_v3_get_session() macro.
Roman Arutyunyan <arut@nginx.com>
parents:
8767
diff
changeset
|
729 h3c = ngx_http_v3_get_session(c); |
8497 | 730 |
731 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, | |
732 "http3 CANCEL_PUSH:%uL", push_id); | |
733 | |
734 if (push_id >= h3c->next_push_id) { | |
735 return NGX_HTTP_V3_ERR_ID_ERROR; | |
736 } | |
737 | |
738 for (q = ngx_queue_head(&h3c->pushing); | |
739 q != ngx_queue_sentinel(&h3c->pushing); | |
740 q = ngx_queue_next(&h3c->pushing)) | |
741 { | |
742 push = (ngx_http_v3_push_t *) q; | |
743 | |
744 if (push->id != push_id) { | |
745 continue; | |
746 } | |
747 | |
748 r = push->connection->data; | |
749 | |
750 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
751 "http3 cancel push"); | |
752 | |
753 ngx_http_finalize_request(r, NGX_HTTP_CLOSE); | |
754 | |
755 break; | |
756 } | |
757 | |
758 return NGX_OK; | |
759 } | |
8767
33ec97749b5f
HTTP/3: moved Stream Cancellation stub to ngx_http_v3_streams.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8725
diff
changeset
|
760 |
33ec97749b5f
HTTP/3: moved Stream Cancellation stub to ngx_http_v3_streams.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8725
diff
changeset
|
761 |
33ec97749b5f
HTTP/3: moved Stream Cancellation stub to ngx_http_v3_streams.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8725
diff
changeset
|
762 ngx_int_t |
33ec97749b5f
HTTP/3: moved Stream Cancellation stub to ngx_http_v3_streams.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8725
diff
changeset
|
763 ngx_http_v3_cancel_stream(ngx_connection_t *c, ngx_uint_t stream_id) |
33ec97749b5f
HTTP/3: moved Stream Cancellation stub to ngx_http_v3_streams.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8725
diff
changeset
|
764 { |
33ec97749b5f
HTTP/3: moved Stream Cancellation stub to ngx_http_v3_streams.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8725
diff
changeset
|
765 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, |
33ec97749b5f
HTTP/3: moved Stream Cancellation stub to ngx_http_v3_streams.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8725
diff
changeset
|
766 "http3 cancel stream %ui", stream_id); |
33ec97749b5f
HTTP/3: moved Stream Cancellation stub to ngx_http_v3_streams.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8725
diff
changeset
|
767 |
33ec97749b5f
HTTP/3: moved Stream Cancellation stub to ngx_http_v3_streams.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8725
diff
changeset
|
768 /* we do not use dynamic tables */ |
33ec97749b5f
HTTP/3: moved Stream Cancellation stub to ngx_http_v3_streams.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8725
diff
changeset
|
769 |
33ec97749b5f
HTTP/3: moved Stream Cancellation stub to ngx_http_v3_streams.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8725
diff
changeset
|
770 return NGX_OK; |
33ec97749b5f
HTTP/3: moved Stream Cancellation stub to ngx_http_v3_streams.c.
Roman Arutyunyan <arut@nginx.com>
parents:
8725
diff
changeset
|
771 } |