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