Mercurial > hg > nginx
annotate src/event/quic/ngx_event_quic_streams.c @ 9250:55a5a40dccde
Reordered checks for Content-Length and Transfer-Encoding.
This ensures that r->headers_in.content_length_n is not set when both
Content-Length and Transfer-Encoding headers are present, making it slightly
safer to use complex processing for 400 (Bad Request) errors.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Sat, 27 Apr 2024 18:16:27 +0300 |
parents | 4ed4e1e7f115 |
children |
rev | line source |
---|---|
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
2 /* |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
3 * Copyright (C) Nginx, Inc. |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
4 */ |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
5 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
6 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
7 #include <ngx_config.h> |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
8 #include <ngx_core.h> |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
9 #include <ngx_event.h> |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
10 #include <ngx_event_quic_connection.h> |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
11 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
12 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
13 #define NGX_QUIC_STREAM_GONE (void *) -1 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
14 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
15 |
9010 | 16 static ngx_int_t ngx_quic_do_reset_stream(ngx_quic_stream_t *qs, |
17 ngx_uint_t err); | |
8938
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8937
diff
changeset
|
18 static ngx_int_t ngx_quic_shutdown_stream_send(ngx_connection_t *c); |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8937
diff
changeset
|
19 static ngx_int_t ngx_quic_shutdown_stream_recv(ngx_connection_t *c); |
8937
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8936
diff
changeset
|
20 static ngx_quic_stream_t *ngx_quic_get_stream(ngx_connection_t *c, uint64_t id); |
8906
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8905
diff
changeset
|
21 static ngx_int_t ngx_quic_reject_stream(ngx_connection_t *c, uint64_t id); |
8937
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8936
diff
changeset
|
22 static void ngx_quic_init_stream_handler(ngx_event_t *ev); |
8886
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8876
diff
changeset
|
23 static void ngx_quic_init_streams_handler(ngx_connection_t *c); |
9058
b0c2234aaa9f
QUIC: application init() callback.
Roman Arutyunyan <arut@nginx.com>
parents:
9053
diff
changeset
|
24 static ngx_int_t ngx_quic_do_init_streams(ngx_connection_t *c); |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
25 static ngx_quic_stream_t *ngx_quic_create_stream(ngx_connection_t *c, |
8779
f52a2b77d406
QUIC: generic buffering for stream input.
Roman Arutyunyan <arut@nginx.com>
parents:
8761
diff
changeset
|
26 uint64_t id); |
8827
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8820
diff
changeset
|
27 static void ngx_quic_empty_handler(ngx_event_t *ev); |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
28 static ssize_t ngx_quic_stream_recv(ngx_connection_t *c, u_char *buf, |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
29 size_t size); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
30 static ssize_t ngx_quic_stream_send(ngx_connection_t *c, u_char *buf, |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
31 size_t size); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
32 static ngx_chain_t *ngx_quic_stream_send_chain(ngx_connection_t *c, |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
33 ngx_chain_t *in, off_t limit); |
9010 | 34 static ngx_int_t ngx_quic_stream_flush(ngx_quic_stream_t *qs); |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
35 static void ngx_quic_stream_cleanup_handler(void *data); |
9010 | 36 static ngx_int_t ngx_quic_close_stream(ngx_quic_stream_t *qs); |
9051
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
37 static ngx_int_t ngx_quic_can_shutdown(ngx_connection_t *c); |
9010 | 38 static ngx_int_t ngx_quic_control_flow(ngx_quic_stream_t *qs, uint64_t last); |
39 static ngx_int_t ngx_quic_update_flow(ngx_quic_stream_t *qs, uint64_t last); | |
40 static ngx_int_t ngx_quic_update_max_stream_data(ngx_quic_stream_t *qs); | |
8909
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8908
diff
changeset
|
41 static ngx_int_t ngx_quic_update_max_data(ngx_connection_t *c); |
8993
7626aa7a2156
QUIC: stream event setting function.
Roman Arutyunyan <arut@nginx.com>
parents:
8990
diff
changeset
|
42 static void ngx_quic_set_event(ngx_event_t *ev); |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
43 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
44 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
45 ngx_connection_t * |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
46 ngx_quic_open_stream(ngx_connection_t *c, ngx_uint_t bidi) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
47 { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
48 uint64_t id; |
9069
03897c45798e
QUIC: defer setting the active flag for client stream events.
Sergey Kandaurov <pluknet@nginx.com>
parents:
9065
diff
changeset
|
49 ngx_connection_t *pc, *sc; |
03897c45798e
QUIC: defer setting the active flag for client stream events.
Sergey Kandaurov <pluknet@nginx.com>
parents:
9065
diff
changeset
|
50 ngx_quic_stream_t *qs; |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
51 ngx_quic_connection_t *qc; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
52 |
8988
6434160b4b78
QUIC: allowed main QUIC connection for some operations.
Roman Arutyunyan <arut@nginx.com>
parents:
8968
diff
changeset
|
53 pc = c->quic ? c->quic->parent : c; |
6434160b4b78
QUIC: allowed main QUIC connection for some operations.
Roman Arutyunyan <arut@nginx.com>
parents:
8968
diff
changeset
|
54 qc = ngx_quic_get_connection(pc); |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
55 |
9051
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
56 if (qc->closing) { |
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
57 return NULL; |
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
58 } |
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
59 |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
60 if (bidi) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
61 if (qc->streams.server_streams_bidi |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
62 >= qc->streams.server_max_streams_bidi) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
63 { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
64 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
65 "quic too many server bidi streams:%uL", |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
66 qc->streams.server_streams_bidi); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
67 return NULL; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
68 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
69 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
70 id = (qc->streams.server_streams_bidi << 2) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
71 | NGX_QUIC_STREAM_SERVER_INITIATED; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
72 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
73 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0, |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
74 "quic creating server bidi stream" |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
75 " streams:%uL max:%uL id:0x%xL", |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
76 qc->streams.server_streams_bidi, |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
77 qc->streams.server_max_streams_bidi, id); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
78 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
79 qc->streams.server_streams_bidi++; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
80 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
81 } else { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
82 if (qc->streams.server_streams_uni |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
83 >= qc->streams.server_max_streams_uni) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
84 { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
85 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
86 "quic too many server uni streams:%uL", |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
87 qc->streams.server_streams_uni); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
88 return NULL; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
89 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
90 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
91 id = (qc->streams.server_streams_uni << 2) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
92 | NGX_QUIC_STREAM_SERVER_INITIATED |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
93 | NGX_QUIC_STREAM_UNIDIRECTIONAL; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
94 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
95 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0, |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
96 "quic creating server uni stream" |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
97 " streams:%uL max:%uL id:0x%xL", |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
98 qc->streams.server_streams_uni, |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
99 qc->streams.server_max_streams_uni, id); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
100 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
101 qc->streams.server_streams_uni++; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
102 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
103 |
9069
03897c45798e
QUIC: defer setting the active flag for client stream events.
Sergey Kandaurov <pluknet@nginx.com>
parents:
9065
diff
changeset
|
104 qs = ngx_quic_create_stream(pc, id); |
03897c45798e
QUIC: defer setting the active flag for client stream events.
Sergey Kandaurov <pluknet@nginx.com>
parents:
9065
diff
changeset
|
105 if (qs == NULL) { |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
106 return NULL; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
107 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
108 |
9069
03897c45798e
QUIC: defer setting the active flag for client stream events.
Sergey Kandaurov <pluknet@nginx.com>
parents:
9065
diff
changeset
|
109 sc = qs->connection; |
03897c45798e
QUIC: defer setting the active flag for client stream events.
Sergey Kandaurov <pluknet@nginx.com>
parents:
9065
diff
changeset
|
110 |
03897c45798e
QUIC: defer setting the active flag for client stream events.
Sergey Kandaurov <pluknet@nginx.com>
parents:
9065
diff
changeset
|
111 sc->write->active = 1; |
03897c45798e
QUIC: defer setting the active flag for client stream events.
Sergey Kandaurov <pluknet@nginx.com>
parents:
9065
diff
changeset
|
112 sc->write->ready = 1; |
03897c45798e
QUIC: defer setting the active flag for client stream events.
Sergey Kandaurov <pluknet@nginx.com>
parents:
9065
diff
changeset
|
113 |
03897c45798e
QUIC: defer setting the active flag for client stream events.
Sergey Kandaurov <pluknet@nginx.com>
parents:
9065
diff
changeset
|
114 if (bidi) { |
03897c45798e
QUIC: defer setting the active flag for client stream events.
Sergey Kandaurov <pluknet@nginx.com>
parents:
9065
diff
changeset
|
115 sc->read->active = 1; |
03897c45798e
QUIC: defer setting the active flag for client stream events.
Sergey Kandaurov <pluknet@nginx.com>
parents:
9065
diff
changeset
|
116 } |
03897c45798e
QUIC: defer setting the active flag for client stream events.
Sergey Kandaurov <pluknet@nginx.com>
parents:
9065
diff
changeset
|
117 |
03897c45798e
QUIC: defer setting the active flag for client stream events.
Sergey Kandaurov <pluknet@nginx.com>
parents:
9065
diff
changeset
|
118 return sc; |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
119 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
120 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
121 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
122 void |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
123 ngx_quic_rbtree_insert_stream(ngx_rbtree_node_t *temp, |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
124 ngx_rbtree_node_t *node, ngx_rbtree_node_t *sentinel) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
125 { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
126 ngx_rbtree_node_t **p; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
127 ngx_quic_stream_t *qn, *qnt; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
128 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
129 for ( ;; ) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
130 qn = (ngx_quic_stream_t *) node; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
131 qnt = (ngx_quic_stream_t *) temp; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
132 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
133 p = (qn->id < qnt->id) ? &temp->left : &temp->right; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
134 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
135 if (*p == sentinel) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
136 break; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
137 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
138 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
139 temp = *p; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
140 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
141 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
142 *p = node; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
143 node->parent = temp; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
144 node->left = sentinel; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
145 node->right = sentinel; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
146 ngx_rbt_red(node); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
147 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
148 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
149 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
150 ngx_quic_stream_t * |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
151 ngx_quic_find_stream(ngx_rbtree_t *rbtree, uint64_t id) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
152 { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
153 ngx_rbtree_node_t *node, *sentinel; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
154 ngx_quic_stream_t *qn; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
155 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
156 node = rbtree->root; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
157 sentinel = rbtree->sentinel; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
158 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
159 while (node != sentinel) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
160 qn = (ngx_quic_stream_t *) node; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
161 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
162 if (id == qn->id) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
163 return qn; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
164 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
165 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
166 node = (id < qn->id) ? node->left : node->right; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
167 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
168 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
169 return NULL; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
170 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
171 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
172 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
173 ngx_int_t |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
174 ngx_quic_close_streams(ngx_connection_t *c, ngx_quic_connection_t *qc) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
175 { |
8827
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8820
diff
changeset
|
176 ngx_pool_t *pool; |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8820
diff
changeset
|
177 ngx_queue_t *q; |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
178 ngx_rbtree_t *tree; |
9051
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
179 ngx_connection_t *sc; |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
180 ngx_rbtree_node_t *node; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
181 ngx_quic_stream_t *qs; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
182 |
8827
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8820
diff
changeset
|
183 while (!ngx_queue_empty(&qc->streams.uninitialized)) { |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8820
diff
changeset
|
184 q = ngx_queue_head(&qc->streams.uninitialized); |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8820
diff
changeset
|
185 ngx_queue_remove(q); |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8820
diff
changeset
|
186 |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8820
diff
changeset
|
187 qs = ngx_queue_data(q, ngx_quic_stream_t, queue); |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8820
diff
changeset
|
188 pool = qs->connection->pool; |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8820
diff
changeset
|
189 |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8820
diff
changeset
|
190 ngx_close_connection(qs->connection); |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8820
diff
changeset
|
191 ngx_destroy_pool(pool); |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8820
diff
changeset
|
192 } |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8820
diff
changeset
|
193 |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
194 tree = &qc->streams.tree; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
195 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
196 if (tree->root == tree->sentinel) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
197 return NGX_OK; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
198 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
199 |
9010 | 200 node = ngx_rbtree_min(tree->root, tree->sentinel); |
201 | |
202 while (node) { | |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
203 qs = (ngx_quic_stream_t *) node; |
9010 | 204 node = ngx_rbtree_next(tree, node); |
9051
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
205 sc = qs->connection; |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
206 |
8990
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8988
diff
changeset
|
207 qs->recv_state = NGX_QUIC_STREAM_RECV_RESET_RECVD; |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8988
diff
changeset
|
208 qs->send_state = NGX_QUIC_STREAM_SEND_RESET_SENT; |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8988
diff
changeset
|
209 |
9051
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
210 if (sc == NULL) { |
9010 | 211 ngx_quic_close_stream(qs); |
212 continue; | |
213 } | |
214 | |
9065
2ee6f9729739
QUIC: set stream error flag on reset.
Roman Arutyunyan <arut@nginx.com>
parents:
9064
diff
changeset
|
215 sc->read->error = 1; |
2ee6f9729739
QUIC: set stream error flag on reset.
Roman Arutyunyan <arut@nginx.com>
parents:
9064
diff
changeset
|
216 sc->write->error = 1; |
2ee6f9729739
QUIC: set stream error flag on reset.
Roman Arutyunyan <arut@nginx.com>
parents:
9064
diff
changeset
|
217 |
9051
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
218 ngx_quic_set_event(sc->read); |
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
219 ngx_quic_set_event(sc->write); |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
220 |
9051
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
221 sc->close = 1; |
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
222 sc->read->handler(sc->read); |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
223 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
224 |
9051
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
225 if (tree->root == tree->sentinel) { |
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
226 return NGX_OK; |
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
227 } |
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
228 |
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
229 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, 0, |
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
230 "quic connection has active streams"); |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
231 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
232 return NGX_AGAIN; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
233 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
234 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
235 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
236 ngx_int_t |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
237 ngx_quic_reset_stream(ngx_connection_t *c, ngx_uint_t err) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
238 { |
9010 | 239 return ngx_quic_do_reset_stream(c->quic, err); |
240 } | |
241 | |
242 | |
243 static ngx_int_t | |
244 ngx_quic_do_reset_stream(ngx_quic_stream_t *qs, ngx_uint_t err) | |
245 { | |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
246 ngx_connection_t *pc; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
247 ngx_quic_frame_t *frame; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
248 ngx_quic_connection_t *qc; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
249 |
8990
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8988
diff
changeset
|
250 if (qs->send_state == NGX_QUIC_STREAM_SEND_DATA_RECVD |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8988
diff
changeset
|
251 || qs->send_state == NGX_QUIC_STREAM_SEND_RESET_SENT |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8988
diff
changeset
|
252 || qs->send_state == NGX_QUIC_STREAM_SEND_RESET_RECVD) |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8988
diff
changeset
|
253 { |
8875
13cb758e6ac0
QUIC: reset stream only once.
Roman Arutyunyan <arut@nginx.com>
parents:
8861
diff
changeset
|
254 return NGX_OK; |
13cb758e6ac0
QUIC: reset stream only once.
Roman Arutyunyan <arut@nginx.com>
parents:
8861
diff
changeset
|
255 } |
13cb758e6ac0
QUIC: reset stream only once.
Roman Arutyunyan <arut@nginx.com>
parents:
8861
diff
changeset
|
256 |
8990
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8988
diff
changeset
|
257 qs->send_state = NGX_QUIC_STREAM_SEND_RESET_SENT; |
9010 | 258 qs->send_final_size = qs->send_offset; |
8990
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8988
diff
changeset
|
259 |
9065
2ee6f9729739
QUIC: set stream error flag on reset.
Roman Arutyunyan <arut@nginx.com>
parents:
9064
diff
changeset
|
260 if (qs->connection) { |
2ee6f9729739
QUIC: set stream error flag on reset.
Roman Arutyunyan <arut@nginx.com>
parents:
9064
diff
changeset
|
261 qs->connection->write->error = 1; |
2ee6f9729739
QUIC: set stream error flag on reset.
Roman Arutyunyan <arut@nginx.com>
parents:
9064
diff
changeset
|
262 } |
2ee6f9729739
QUIC: set stream error flag on reset.
Roman Arutyunyan <arut@nginx.com>
parents:
9064
diff
changeset
|
263 |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
264 pc = qs->parent; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
265 qc = ngx_quic_get_connection(pc); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
266 |
9010 | 267 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, pc->log, 0, |
268 "quic stream id:0x%xL reset", qs->id); | |
269 | |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
270 frame = ngx_quic_alloc_frame(pc); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
271 if (frame == NULL) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
272 return NGX_ERROR; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
273 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
274 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
275 frame->level = ssl_encryption_application; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
276 frame->type = NGX_QUIC_FT_RESET_STREAM; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
277 frame->u.reset_stream.id = qs->id; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
278 frame->u.reset_stream.error_code = err; |
9010 | 279 frame->u.reset_stream.final_size = qs->send_offset; |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
280 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
281 ngx_quic_queue_frame(qc, frame); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
282 |
9011
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
9010
diff
changeset
|
283 ngx_quic_free_buffer(pc, &qs->send); |
9010 | 284 |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
285 return NGX_OK; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
286 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
287 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
288 |
8890
b4c7853b0488
QUIC: added shutdown support in stream proxy.
Vladimir Homutov <vl@nginx.com>
parents:
8886
diff
changeset
|
289 ngx_int_t |
b4c7853b0488
QUIC: added shutdown support in stream proxy.
Vladimir Homutov <vl@nginx.com>
parents:
8886
diff
changeset
|
290 ngx_quic_shutdown_stream(ngx_connection_t *c, int how) |
b4c7853b0488
QUIC: added shutdown support in stream proxy.
Vladimir Homutov <vl@nginx.com>
parents:
8886
diff
changeset
|
291 { |
8938
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8937
diff
changeset
|
292 if (how == NGX_RDWR_SHUTDOWN || how == NGX_WRITE_SHUTDOWN) { |
8990
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8988
diff
changeset
|
293 if (ngx_quic_shutdown_stream_send(c) != NGX_OK) { |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8988
diff
changeset
|
294 return NGX_ERROR; |
8938
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8937
diff
changeset
|
295 } |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8937
diff
changeset
|
296 } |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8937
diff
changeset
|
297 |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8937
diff
changeset
|
298 if (how == NGX_RDWR_SHUTDOWN || how == NGX_READ_SHUTDOWN) { |
8990
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8988
diff
changeset
|
299 if (ngx_quic_shutdown_stream_recv(c) != NGX_OK) { |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8988
diff
changeset
|
300 return NGX_ERROR; |
8938
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8937
diff
changeset
|
301 } |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8937
diff
changeset
|
302 } |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8937
diff
changeset
|
303 |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8937
diff
changeset
|
304 return NGX_OK; |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8937
diff
changeset
|
305 } |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8937
diff
changeset
|
306 |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8937
diff
changeset
|
307 |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8937
diff
changeset
|
308 static ngx_int_t |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8937
diff
changeset
|
309 ngx_quic_shutdown_stream_send(ngx_connection_t *c) |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8937
diff
changeset
|
310 { |
9010 | 311 ngx_quic_stream_t *qs; |
8890
b4c7853b0488
QUIC: added shutdown support in stream proxy.
Vladimir Homutov <vl@nginx.com>
parents:
8886
diff
changeset
|
312 |
8990
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8988
diff
changeset
|
313 qs = c->quic; |
8890
b4c7853b0488
QUIC: added shutdown support in stream proxy.
Vladimir Homutov <vl@nginx.com>
parents:
8886
diff
changeset
|
314 |
8990
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8988
diff
changeset
|
315 if (qs->send_state != NGX_QUIC_STREAM_SEND_READY |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8988
diff
changeset
|
316 && qs->send_state != NGX_QUIC_STREAM_SEND_SEND) |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8988
diff
changeset
|
317 { |
8890
b4c7853b0488
QUIC: added shutdown support in stream proxy.
Vladimir Homutov <vl@nginx.com>
parents:
8886
diff
changeset
|
318 return NGX_OK; |
b4c7853b0488
QUIC: added shutdown support in stream proxy.
Vladimir Homutov <vl@nginx.com>
parents:
8886
diff
changeset
|
319 } |
b4c7853b0488
QUIC: added shutdown support in stream proxy.
Vladimir Homutov <vl@nginx.com>
parents:
8886
diff
changeset
|
320 |
9010 | 321 qs->send_state = NGX_QUIC_STREAM_SEND_SEND; |
322 qs->send_final_size = c->sent; | |
8890
b4c7853b0488
QUIC: added shutdown support in stream proxy.
Vladimir Homutov <vl@nginx.com>
parents:
8886
diff
changeset
|
323 |
9010 | 324 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, qs->parent->log, 0, |
8938
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8937
diff
changeset
|
325 "quic stream id:0x%xL send shutdown", qs->id); |
8890
b4c7853b0488
QUIC: added shutdown support in stream proxy.
Vladimir Homutov <vl@nginx.com>
parents:
8886
diff
changeset
|
326 |
9010 | 327 return ngx_quic_stream_flush(qs); |
8890
b4c7853b0488
QUIC: added shutdown support in stream proxy.
Vladimir Homutov <vl@nginx.com>
parents:
8886
diff
changeset
|
328 } |
b4c7853b0488
QUIC: added shutdown support in stream proxy.
Vladimir Homutov <vl@nginx.com>
parents:
8886
diff
changeset
|
329 |
b4c7853b0488
QUIC: added shutdown support in stream proxy.
Vladimir Homutov <vl@nginx.com>
parents:
8886
diff
changeset
|
330 |
8938
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8937
diff
changeset
|
331 static ngx_int_t |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8937
diff
changeset
|
332 ngx_quic_shutdown_stream_recv(ngx_connection_t *c) |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8937
diff
changeset
|
333 { |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8937
diff
changeset
|
334 ngx_connection_t *pc; |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8937
diff
changeset
|
335 ngx_quic_frame_t *frame; |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8937
diff
changeset
|
336 ngx_quic_stream_t *qs; |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8937
diff
changeset
|
337 ngx_quic_connection_t *qc; |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8937
diff
changeset
|
338 |
8990
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8988
diff
changeset
|
339 qs = c->quic; |
8938
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8937
diff
changeset
|
340 |
8990
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8988
diff
changeset
|
341 if (qs->recv_state != NGX_QUIC_STREAM_RECV_RECV |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8988
diff
changeset
|
342 && qs->recv_state != NGX_QUIC_STREAM_RECV_SIZE_KNOWN) |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8988
diff
changeset
|
343 { |
8938
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8937
diff
changeset
|
344 return NGX_OK; |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8937
diff
changeset
|
345 } |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8937
diff
changeset
|
346 |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8937
diff
changeset
|
347 pc = qs->parent; |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8937
diff
changeset
|
348 qc = ngx_quic_get_connection(pc); |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8937
diff
changeset
|
349 |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8937
diff
changeset
|
350 if (qc->conf->stream_close_code == 0) { |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8937
diff
changeset
|
351 return NGX_OK; |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8937
diff
changeset
|
352 } |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8937
diff
changeset
|
353 |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8937
diff
changeset
|
354 frame = ngx_quic_alloc_frame(pc); |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8937
diff
changeset
|
355 if (frame == NULL) { |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8937
diff
changeset
|
356 return NGX_ERROR; |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8937
diff
changeset
|
357 } |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8937
diff
changeset
|
358 |
9010 | 359 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, pc->log, 0, |
8938
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8937
diff
changeset
|
360 "quic stream id:0x%xL recv shutdown", qs->id); |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8937
diff
changeset
|
361 |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8937
diff
changeset
|
362 frame->level = ssl_encryption_application; |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8937
diff
changeset
|
363 frame->type = NGX_QUIC_FT_STOP_SENDING; |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8937
diff
changeset
|
364 frame->u.stop_sending.id = qs->id; |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8937
diff
changeset
|
365 frame->u.stop_sending.error_code = qc->conf->stream_close_code; |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8937
diff
changeset
|
366 |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8937
diff
changeset
|
367 ngx_quic_queue_frame(qc, frame); |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8937
diff
changeset
|
368 |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8937
diff
changeset
|
369 return NGX_OK; |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8937
diff
changeset
|
370 } |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8937
diff
changeset
|
371 |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8937
diff
changeset
|
372 |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
373 static ngx_quic_stream_t * |
8937
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8936
diff
changeset
|
374 ngx_quic_get_stream(ngx_connection_t *c, uint64_t id) |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
375 { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
376 uint64_t min_id; |
8937
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8936
diff
changeset
|
377 ngx_event_t *rev; |
8761
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8760
diff
changeset
|
378 ngx_quic_stream_t *qs; |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
379 ngx_quic_connection_t *qc; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
380 |
8937
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8936
diff
changeset
|
381 qc = ngx_quic_get_connection(c); |
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8936
diff
changeset
|
382 |
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8936
diff
changeset
|
383 qs = ngx_quic_find_stream(&qc->streams.tree, id); |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
384 |
8937
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8936
diff
changeset
|
385 if (qs) { |
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8936
diff
changeset
|
386 return qs; |
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8936
diff
changeset
|
387 } |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
388 |
8905
832723a49026
QUIC: stop processing new client streams at the closing state.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8890
diff
changeset
|
389 if (qc->shutdown || qc->closing) { |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
390 return NGX_QUIC_STREAM_GONE; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
391 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
392 |
8937
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8936
diff
changeset
|
393 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8936
diff
changeset
|
394 "quic stream id:0x%xL is missing", id); |
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8936
diff
changeset
|
395 |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
396 if (id & NGX_QUIC_STREAM_UNIDIRECTIONAL) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
397 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
398 if (id & NGX_QUIC_STREAM_SERVER_INITIATED) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
399 if ((id >> 2) < qc->streams.server_streams_uni) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
400 return NGX_QUIC_STREAM_GONE; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
401 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
402 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
403 qc->error = NGX_QUIC_ERR_STREAM_STATE_ERROR; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
404 return NULL; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
405 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
406 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
407 if ((id >> 2) < qc->streams.client_streams_uni) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
408 return NGX_QUIC_STREAM_GONE; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
409 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
410 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
411 if ((id >> 2) >= qc->streams.client_max_streams_uni) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
412 qc->error = NGX_QUIC_ERR_STREAM_LIMIT_ERROR; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
413 return NULL; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
414 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
415 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
416 min_id = (qc->streams.client_streams_uni << 2) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
417 | NGX_QUIC_STREAM_UNIDIRECTIONAL; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
418 qc->streams.client_streams_uni = (id >> 2) + 1; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
419 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
420 } else { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
421 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
422 if (id & NGX_QUIC_STREAM_SERVER_INITIATED) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
423 if ((id >> 2) < qc->streams.server_streams_bidi) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
424 return NGX_QUIC_STREAM_GONE; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
425 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
426 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
427 qc->error = NGX_QUIC_ERR_STREAM_STATE_ERROR; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
428 return NULL; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
429 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
430 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
431 if ((id >> 2) < qc->streams.client_streams_bidi) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
432 return NGX_QUIC_STREAM_GONE; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
433 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
434 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
435 if ((id >> 2) >= qc->streams.client_max_streams_bidi) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
436 qc->error = NGX_QUIC_ERR_STREAM_LIMIT_ERROR; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
437 return NULL; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
438 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
439 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
440 min_id = (qc->streams.client_streams_bidi << 2); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
441 qc->streams.client_streams_bidi = (id >> 2) + 1; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
442 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
443 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
444 /* |
8797
4715f3e669f1
QUIC: updated specification references.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8791
diff
changeset
|
445 * RFC 9000, 2.1. Stream Types and Identifiers |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
446 * |
8797
4715f3e669f1
QUIC: updated specification references.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8791
diff
changeset
|
447 * successive streams of each type are created with numerically increasing |
4715f3e669f1
QUIC: updated specification references.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8791
diff
changeset
|
448 * stream IDs. A stream ID that is used out of order results in all |
4715f3e669f1
QUIC: updated specification references.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8791
diff
changeset
|
449 * streams of that type with lower-numbered stream IDs also being opened. |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
450 */ |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
451 |
8937
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8936
diff
changeset
|
452 #if (NGX_SUPPRESS_WARN) |
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8936
diff
changeset
|
453 qs = NULL; |
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8936
diff
changeset
|
454 #endif |
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8936
diff
changeset
|
455 |
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8936
diff
changeset
|
456 for ( /* void */ ; min_id <= id; min_id += 0x04) { |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
457 |
8779
f52a2b77d406
QUIC: generic buffering for stream input.
Roman Arutyunyan <arut@nginx.com>
parents:
8761
diff
changeset
|
458 qs = ngx_quic_create_stream(c, min_id); |
8906
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8905
diff
changeset
|
459 |
8761
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8760
diff
changeset
|
460 if (qs == NULL) { |
8906
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8905
diff
changeset
|
461 if (ngx_quic_reject_stream(c, min_id) != NGX_OK) { |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8905
diff
changeset
|
462 return NULL; |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8905
diff
changeset
|
463 } |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8905
diff
changeset
|
464 |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8905
diff
changeset
|
465 continue; |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
466 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
467 |
8937
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8936
diff
changeset
|
468 ngx_queue_insert_tail(&qc->streams.uninitialized, &qs->queue); |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
469 |
8937
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8936
diff
changeset
|
470 rev = qs->connection->read; |
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8936
diff
changeset
|
471 rev->handler = ngx_quic_init_stream_handler; |
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8936
diff
changeset
|
472 |
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8936
diff
changeset
|
473 if (qc->streams.initialized) { |
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8936
diff
changeset
|
474 ngx_post_event(rev, &ngx_posted_events); |
9086
f68fdb017141
QUIC: optimized sending stream response.
Roman Arutyunyan <arut@nginx.com>
parents:
9075
diff
changeset
|
475 |
f68fdb017141
QUIC: optimized sending stream response.
Roman Arutyunyan <arut@nginx.com>
parents:
9075
diff
changeset
|
476 if (qc->push.posted) { |
f68fdb017141
QUIC: optimized sending stream response.
Roman Arutyunyan <arut@nginx.com>
parents:
9075
diff
changeset
|
477 /* |
f68fdb017141
QUIC: optimized sending stream response.
Roman Arutyunyan <arut@nginx.com>
parents:
9075
diff
changeset
|
478 * The posted stream can produce output immediately. |
f68fdb017141
QUIC: optimized sending stream response.
Roman Arutyunyan <arut@nginx.com>
parents:
9075
diff
changeset
|
479 * By postponing the push event, we coalesce the stream |
f68fdb017141
QUIC: optimized sending stream response.
Roman Arutyunyan <arut@nginx.com>
parents:
9075
diff
changeset
|
480 * output with queued frames in one UDP datagram. |
f68fdb017141
QUIC: optimized sending stream response.
Roman Arutyunyan <arut@nginx.com>
parents:
9075
diff
changeset
|
481 */ |
f68fdb017141
QUIC: optimized sending stream response.
Roman Arutyunyan <arut@nginx.com>
parents:
9075
diff
changeset
|
482 |
f68fdb017141
QUIC: optimized sending stream response.
Roman Arutyunyan <arut@nginx.com>
parents:
9075
diff
changeset
|
483 ngx_delete_posted_event(&qc->push); |
f68fdb017141
QUIC: optimized sending stream response.
Roman Arutyunyan <arut@nginx.com>
parents:
9075
diff
changeset
|
484 ngx_post_event(&qc->push, &ngx_posted_events); |
f68fdb017141
QUIC: optimized sending stream response.
Roman Arutyunyan <arut@nginx.com>
parents:
9075
diff
changeset
|
485 } |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
486 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
487 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
488 |
8906
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8905
diff
changeset
|
489 if (qs == NULL) { |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8905
diff
changeset
|
490 return NGX_QUIC_STREAM_GONE; |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8905
diff
changeset
|
491 } |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8905
diff
changeset
|
492 |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8905
diff
changeset
|
493 return qs; |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8905
diff
changeset
|
494 } |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8905
diff
changeset
|
495 |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8905
diff
changeset
|
496 |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8905
diff
changeset
|
497 static ngx_int_t |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8905
diff
changeset
|
498 ngx_quic_reject_stream(ngx_connection_t *c, uint64_t id) |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8905
diff
changeset
|
499 { |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8905
diff
changeset
|
500 uint64_t code; |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8905
diff
changeset
|
501 ngx_quic_frame_t *frame; |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8905
diff
changeset
|
502 ngx_quic_connection_t *qc; |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8905
diff
changeset
|
503 |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8905
diff
changeset
|
504 qc = ngx_quic_get_connection(c); |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8905
diff
changeset
|
505 |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8905
diff
changeset
|
506 code = (id & NGX_QUIC_STREAM_UNIDIRECTIONAL) |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8905
diff
changeset
|
507 ? qc->conf->stream_reject_code_uni |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8905
diff
changeset
|
508 : qc->conf->stream_reject_code_bidi; |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8905
diff
changeset
|
509 |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8905
diff
changeset
|
510 if (code == 0) { |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8905
diff
changeset
|
511 return NGX_DECLINED; |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8905
diff
changeset
|
512 } |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8905
diff
changeset
|
513 |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8905
diff
changeset
|
514 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0, |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8905
diff
changeset
|
515 "quic stream id:0x%xL reject err:0x%xL", id, code); |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8905
diff
changeset
|
516 |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8905
diff
changeset
|
517 frame = ngx_quic_alloc_frame(c); |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8905
diff
changeset
|
518 if (frame == NULL) { |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8905
diff
changeset
|
519 return NGX_ERROR; |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8905
diff
changeset
|
520 } |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8905
diff
changeset
|
521 |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8905
diff
changeset
|
522 frame->level = ssl_encryption_application; |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8905
diff
changeset
|
523 frame->type = NGX_QUIC_FT_RESET_STREAM; |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8905
diff
changeset
|
524 frame->u.reset_stream.id = id; |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8905
diff
changeset
|
525 frame->u.reset_stream.error_code = code; |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8905
diff
changeset
|
526 frame->u.reset_stream.final_size = 0; |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8905
diff
changeset
|
527 |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8905
diff
changeset
|
528 ngx_quic_queue_frame(qc, frame); |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8905
diff
changeset
|
529 |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8905
diff
changeset
|
530 frame = ngx_quic_alloc_frame(c); |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8905
diff
changeset
|
531 if (frame == NULL) { |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8905
diff
changeset
|
532 return NGX_ERROR; |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8905
diff
changeset
|
533 } |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8905
diff
changeset
|
534 |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8905
diff
changeset
|
535 frame->level = ssl_encryption_application; |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8905
diff
changeset
|
536 frame->type = NGX_QUIC_FT_STOP_SENDING; |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8905
diff
changeset
|
537 frame->u.stop_sending.id = id; |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8905
diff
changeset
|
538 frame->u.stop_sending.error_code = code; |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8905
diff
changeset
|
539 |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8905
diff
changeset
|
540 ngx_quic_queue_frame(qc, frame); |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8905
diff
changeset
|
541 |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8905
diff
changeset
|
542 return NGX_OK; |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
543 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
544 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
545 |
8937
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8936
diff
changeset
|
546 static void |
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8936
diff
changeset
|
547 ngx_quic_init_stream_handler(ngx_event_t *ev) |
8827
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8820
diff
changeset
|
548 { |
8937
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8936
diff
changeset
|
549 ngx_connection_t *c; |
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8936
diff
changeset
|
550 ngx_quic_stream_t *qs; |
8827
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8820
diff
changeset
|
551 |
8937
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8936
diff
changeset
|
552 c = ev->data; |
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8936
diff
changeset
|
553 qs = c->quic; |
8827
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8820
diff
changeset
|
554 |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8820
diff
changeset
|
555 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, 0, "quic init stream"); |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8820
diff
changeset
|
556 |
9069
03897c45798e
QUIC: defer setting the active flag for client stream events.
Sergey Kandaurov <pluknet@nginx.com>
parents:
9065
diff
changeset
|
557 if ((qs->id & NGX_QUIC_STREAM_UNIDIRECTIONAL) == 0) { |
03897c45798e
QUIC: defer setting the active flag for client stream events.
Sergey Kandaurov <pluknet@nginx.com>
parents:
9065
diff
changeset
|
558 c->write->active = 1; |
03897c45798e
QUIC: defer setting the active flag for client stream events.
Sergey Kandaurov <pluknet@nginx.com>
parents:
9065
diff
changeset
|
559 c->write->ready = 1; |
03897c45798e
QUIC: defer setting the active flag for client stream events.
Sergey Kandaurov <pluknet@nginx.com>
parents:
9065
diff
changeset
|
560 } |
03897c45798e
QUIC: defer setting the active flag for client stream events.
Sergey Kandaurov <pluknet@nginx.com>
parents:
9065
diff
changeset
|
561 |
03897c45798e
QUIC: defer setting the active flag for client stream events.
Sergey Kandaurov <pluknet@nginx.com>
parents:
9065
diff
changeset
|
562 c->read->active = 1; |
03897c45798e
QUIC: defer setting the active flag for client stream events.
Sergey Kandaurov <pluknet@nginx.com>
parents:
9065
diff
changeset
|
563 |
8937
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8936
diff
changeset
|
564 ngx_queue_remove(&qs->queue); |
8827
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8820
diff
changeset
|
565 |
8937
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8936
diff
changeset
|
566 c->listening->handler(c); |
8827
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8820
diff
changeset
|
567 } |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8820
diff
changeset
|
568 |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8820
diff
changeset
|
569 |
8886
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8876
diff
changeset
|
570 ngx_int_t |
8827
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8820
diff
changeset
|
571 ngx_quic_init_streams(ngx_connection_t *c) |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8820
diff
changeset
|
572 { |
8886
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8876
diff
changeset
|
573 ngx_int_t rc; |
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8876
diff
changeset
|
574 ngx_quic_connection_t *qc; |
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8876
diff
changeset
|
575 |
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8876
diff
changeset
|
576 qc = ngx_quic_get_connection(c); |
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8876
diff
changeset
|
577 |
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8876
diff
changeset
|
578 if (qc->streams.initialized) { |
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8876
diff
changeset
|
579 return NGX_OK; |
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8876
diff
changeset
|
580 } |
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8876
diff
changeset
|
581 |
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8876
diff
changeset
|
582 rc = ngx_ssl_ocsp_validate(c); |
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8876
diff
changeset
|
583 |
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8876
diff
changeset
|
584 if (rc == NGX_ERROR) { |
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8876
diff
changeset
|
585 return NGX_ERROR; |
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8876
diff
changeset
|
586 } |
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8876
diff
changeset
|
587 |
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8876
diff
changeset
|
588 if (rc == NGX_AGAIN) { |
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8876
diff
changeset
|
589 c->ssl->handler = ngx_quic_init_streams_handler; |
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8876
diff
changeset
|
590 return NGX_OK; |
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8876
diff
changeset
|
591 } |
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8876
diff
changeset
|
592 |
9058
b0c2234aaa9f
QUIC: application init() callback.
Roman Arutyunyan <arut@nginx.com>
parents:
9053
diff
changeset
|
593 return ngx_quic_do_init_streams(c); |
8886
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8876
diff
changeset
|
594 } |
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8876
diff
changeset
|
595 |
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8876
diff
changeset
|
596 |
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8876
diff
changeset
|
597 static void |
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8876
diff
changeset
|
598 ngx_quic_init_streams_handler(ngx_connection_t *c) |
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8876
diff
changeset
|
599 { |
9058
b0c2234aaa9f
QUIC: application init() callback.
Roman Arutyunyan <arut@nginx.com>
parents:
9053
diff
changeset
|
600 if (ngx_quic_do_init_streams(c) != NGX_OK) { |
b0c2234aaa9f
QUIC: application init() callback.
Roman Arutyunyan <arut@nginx.com>
parents:
9053
diff
changeset
|
601 ngx_quic_close_connection(c, NGX_ERROR); |
b0c2234aaa9f
QUIC: application init() callback.
Roman Arutyunyan <arut@nginx.com>
parents:
9053
diff
changeset
|
602 } |
b0c2234aaa9f
QUIC: application init() callback.
Roman Arutyunyan <arut@nginx.com>
parents:
9053
diff
changeset
|
603 } |
b0c2234aaa9f
QUIC: application init() callback.
Roman Arutyunyan <arut@nginx.com>
parents:
9053
diff
changeset
|
604 |
b0c2234aaa9f
QUIC: application init() callback.
Roman Arutyunyan <arut@nginx.com>
parents:
9053
diff
changeset
|
605 |
b0c2234aaa9f
QUIC: application init() callback.
Roman Arutyunyan <arut@nginx.com>
parents:
9053
diff
changeset
|
606 static ngx_int_t |
b0c2234aaa9f
QUIC: application init() callback.
Roman Arutyunyan <arut@nginx.com>
parents:
9053
diff
changeset
|
607 ngx_quic_do_init_streams(ngx_connection_t *c) |
b0c2234aaa9f
QUIC: application init() callback.
Roman Arutyunyan <arut@nginx.com>
parents:
9053
diff
changeset
|
608 { |
8827
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8820
diff
changeset
|
609 ngx_queue_t *q; |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8820
diff
changeset
|
610 ngx_quic_stream_t *qs; |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8820
diff
changeset
|
611 ngx_quic_connection_t *qc; |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8820
diff
changeset
|
612 |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8820
diff
changeset
|
613 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, 0, "quic init streams"); |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8820
diff
changeset
|
614 |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8820
diff
changeset
|
615 qc = ngx_quic_get_connection(c); |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8820
diff
changeset
|
616 |
9058
b0c2234aaa9f
QUIC: application init() callback.
Roman Arutyunyan <arut@nginx.com>
parents:
9053
diff
changeset
|
617 if (qc->conf->init) { |
b0c2234aaa9f
QUIC: application init() callback.
Roman Arutyunyan <arut@nginx.com>
parents:
9053
diff
changeset
|
618 if (qc->conf->init(c) != NGX_OK) { |
b0c2234aaa9f
QUIC: application init() callback.
Roman Arutyunyan <arut@nginx.com>
parents:
9053
diff
changeset
|
619 return NGX_ERROR; |
b0c2234aaa9f
QUIC: application init() callback.
Roman Arutyunyan <arut@nginx.com>
parents:
9053
diff
changeset
|
620 } |
b0c2234aaa9f
QUIC: application init() callback.
Roman Arutyunyan <arut@nginx.com>
parents:
9053
diff
changeset
|
621 } |
b0c2234aaa9f
QUIC: application init() callback.
Roman Arutyunyan <arut@nginx.com>
parents:
9053
diff
changeset
|
622 |
8937
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8936
diff
changeset
|
623 for (q = ngx_queue_head(&qc->streams.uninitialized); |
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8936
diff
changeset
|
624 q != ngx_queue_sentinel(&qc->streams.uninitialized); |
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8936
diff
changeset
|
625 q = ngx_queue_next(q)) |
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8936
diff
changeset
|
626 { |
8827
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8820
diff
changeset
|
627 qs = ngx_queue_data(q, ngx_quic_stream_t, queue); |
8937
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8936
diff
changeset
|
628 ngx_post_event(qs->connection->read, &ngx_posted_events); |
8827
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8820
diff
changeset
|
629 } |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8820
diff
changeset
|
630 |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8820
diff
changeset
|
631 qc->streams.initialized = 1; |
9058
b0c2234aaa9f
QUIC: application init() callback.
Roman Arutyunyan <arut@nginx.com>
parents:
9053
diff
changeset
|
632 |
9158
ad3d34ddfdcc
QUIC: "handshake_timeout" configuration parameter.
Roman Arutyunyan <arut@nginx.com>
parents:
9112
diff
changeset
|
633 if (!qc->closing && qc->close.timer_set) { |
ad3d34ddfdcc
QUIC: "handshake_timeout" configuration parameter.
Roman Arutyunyan <arut@nginx.com>
parents:
9112
diff
changeset
|
634 ngx_del_timer(&qc->close); |
ad3d34ddfdcc
QUIC: "handshake_timeout" configuration parameter.
Roman Arutyunyan <arut@nginx.com>
parents:
9112
diff
changeset
|
635 } |
ad3d34ddfdcc
QUIC: "handshake_timeout" configuration parameter.
Roman Arutyunyan <arut@nginx.com>
parents:
9112
diff
changeset
|
636 |
9058
b0c2234aaa9f
QUIC: application init() callback.
Roman Arutyunyan <arut@nginx.com>
parents:
9053
diff
changeset
|
637 return NGX_OK; |
8827
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8820
diff
changeset
|
638 } |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8820
diff
changeset
|
639 |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8820
diff
changeset
|
640 |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
641 static ngx_quic_stream_t * |
8779
f52a2b77d406
QUIC: generic buffering for stream input.
Roman Arutyunyan <arut@nginx.com>
parents:
8761
diff
changeset
|
642 ngx_quic_create_stream(ngx_connection_t *c, uint64_t id) |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
643 { |
9101
3bb003fcd682
QUIC: keep stream sockaddr and addr_text constant.
Roman Arutyunyan <arut@nginx.com>
parents:
9100
diff
changeset
|
644 ngx_str_t addr_text; |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
645 ngx_log_t *log; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
646 ngx_pool_t *pool; |
9051
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
647 ngx_uint_t reusable; |
9010 | 648 ngx_queue_t *q; |
9101
3bb003fcd682
QUIC: keep stream sockaddr and addr_text constant.
Roman Arutyunyan <arut@nginx.com>
parents:
9100
diff
changeset
|
649 struct sockaddr *sockaddr; |
8760
baf9551b4a5b
QUIC: renamed stream field from c to connection.
Roman Arutyunyan <arut@nginx.com>
parents:
8756
diff
changeset
|
650 ngx_connection_t *sc; |
8761
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8760
diff
changeset
|
651 ngx_quic_stream_t *qs; |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
652 ngx_pool_cleanup_t *cln; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
653 ngx_quic_connection_t *qc; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
654 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
655 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
656 "quic stream id:0x%xL create", id); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
657 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
658 qc = ngx_quic_get_connection(c); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
659 |
9010 | 660 if (!ngx_queue_empty(&qc->streams.free)) { |
661 q = ngx_queue_head(&qc->streams.free); | |
662 qs = ngx_queue_data(q, ngx_quic_stream_t, queue); | |
663 ngx_queue_remove(&qs->queue); | |
664 | |
665 } else { | |
666 /* | |
667 * the number of streams is limited by transport | |
668 * parameters and application requirements | |
669 */ | |
670 | |
671 qs = ngx_palloc(c->pool, sizeof(ngx_quic_stream_t)); | |
672 if (qs == NULL) { | |
673 return NULL; | |
674 } | |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
675 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
676 |
9010 | 677 ngx_memzero(qs, sizeof(ngx_quic_stream_t)); |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
678 |
8761
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8760
diff
changeset
|
679 qs->node.key = id; |
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8760
diff
changeset
|
680 qs->parent = c; |
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8760
diff
changeset
|
681 qs->id = id; |
9010 | 682 qs->send_final_size = (uint64_t) -1; |
683 qs->recv_final_size = (uint64_t) -1; | |
684 | |
685 pool = ngx_create_pool(NGX_DEFAULT_POOL_SIZE, c->log); | |
686 if (pool == NULL) { | |
687 ngx_queue_insert_tail(&qc->streams.free, &qs->queue); | |
688 return NULL; | |
689 } | |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
690 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
691 log = ngx_palloc(pool, sizeof(ngx_log_t)); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
692 if (log == NULL) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
693 ngx_destroy_pool(pool); |
9010 | 694 ngx_queue_insert_tail(&qc->streams.free, &qs->queue); |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
695 return NULL; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
696 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
697 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
698 *log = *c->log; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
699 pool->log = log; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
700 |
9101
3bb003fcd682
QUIC: keep stream sockaddr and addr_text constant.
Roman Arutyunyan <arut@nginx.com>
parents:
9100
diff
changeset
|
701 sockaddr = ngx_palloc(pool, c->socklen); |
3bb003fcd682
QUIC: keep stream sockaddr and addr_text constant.
Roman Arutyunyan <arut@nginx.com>
parents:
9100
diff
changeset
|
702 if (sockaddr == NULL) { |
3bb003fcd682
QUIC: keep stream sockaddr and addr_text constant.
Roman Arutyunyan <arut@nginx.com>
parents:
9100
diff
changeset
|
703 ngx_destroy_pool(pool); |
3bb003fcd682
QUIC: keep stream sockaddr and addr_text constant.
Roman Arutyunyan <arut@nginx.com>
parents:
9100
diff
changeset
|
704 ngx_queue_insert_tail(&qc->streams.free, &qs->queue); |
3bb003fcd682
QUIC: keep stream sockaddr and addr_text constant.
Roman Arutyunyan <arut@nginx.com>
parents:
9100
diff
changeset
|
705 return NULL; |
3bb003fcd682
QUIC: keep stream sockaddr and addr_text constant.
Roman Arutyunyan <arut@nginx.com>
parents:
9100
diff
changeset
|
706 } |
3bb003fcd682
QUIC: keep stream sockaddr and addr_text constant.
Roman Arutyunyan <arut@nginx.com>
parents:
9100
diff
changeset
|
707 |
3bb003fcd682
QUIC: keep stream sockaddr and addr_text constant.
Roman Arutyunyan <arut@nginx.com>
parents:
9100
diff
changeset
|
708 ngx_memcpy(sockaddr, c->sockaddr, c->socklen); |
3bb003fcd682
QUIC: keep stream sockaddr and addr_text constant.
Roman Arutyunyan <arut@nginx.com>
parents:
9100
diff
changeset
|
709 |
3bb003fcd682
QUIC: keep stream sockaddr and addr_text constant.
Roman Arutyunyan <arut@nginx.com>
parents:
9100
diff
changeset
|
710 if (c->addr_text.data) { |
3bb003fcd682
QUIC: keep stream sockaddr and addr_text constant.
Roman Arutyunyan <arut@nginx.com>
parents:
9100
diff
changeset
|
711 addr_text.data = ngx_pnalloc(pool, c->addr_text.len); |
3bb003fcd682
QUIC: keep stream sockaddr and addr_text constant.
Roman Arutyunyan <arut@nginx.com>
parents:
9100
diff
changeset
|
712 if (addr_text.data == NULL) { |
3bb003fcd682
QUIC: keep stream sockaddr and addr_text constant.
Roman Arutyunyan <arut@nginx.com>
parents:
9100
diff
changeset
|
713 ngx_destroy_pool(pool); |
3bb003fcd682
QUIC: keep stream sockaddr and addr_text constant.
Roman Arutyunyan <arut@nginx.com>
parents:
9100
diff
changeset
|
714 ngx_queue_insert_tail(&qc->streams.free, &qs->queue); |
3bb003fcd682
QUIC: keep stream sockaddr and addr_text constant.
Roman Arutyunyan <arut@nginx.com>
parents:
9100
diff
changeset
|
715 return NULL; |
3bb003fcd682
QUIC: keep stream sockaddr and addr_text constant.
Roman Arutyunyan <arut@nginx.com>
parents:
9100
diff
changeset
|
716 } |
3bb003fcd682
QUIC: keep stream sockaddr and addr_text constant.
Roman Arutyunyan <arut@nginx.com>
parents:
9100
diff
changeset
|
717 |
3bb003fcd682
QUIC: keep stream sockaddr and addr_text constant.
Roman Arutyunyan <arut@nginx.com>
parents:
9100
diff
changeset
|
718 ngx_memcpy(addr_text.data, c->addr_text.data, c->addr_text.len); |
3bb003fcd682
QUIC: keep stream sockaddr and addr_text constant.
Roman Arutyunyan <arut@nginx.com>
parents:
9100
diff
changeset
|
719 addr_text.len = c->addr_text.len; |
3bb003fcd682
QUIC: keep stream sockaddr and addr_text constant.
Roman Arutyunyan <arut@nginx.com>
parents:
9100
diff
changeset
|
720 |
3bb003fcd682
QUIC: keep stream sockaddr and addr_text constant.
Roman Arutyunyan <arut@nginx.com>
parents:
9100
diff
changeset
|
721 } else { |
3bb003fcd682
QUIC: keep stream sockaddr and addr_text constant.
Roman Arutyunyan <arut@nginx.com>
parents:
9100
diff
changeset
|
722 addr_text.len = 0; |
3bb003fcd682
QUIC: keep stream sockaddr and addr_text constant.
Roman Arutyunyan <arut@nginx.com>
parents:
9100
diff
changeset
|
723 addr_text.data = NULL; |
3bb003fcd682
QUIC: keep stream sockaddr and addr_text constant.
Roman Arutyunyan <arut@nginx.com>
parents:
9100
diff
changeset
|
724 } |
3bb003fcd682
QUIC: keep stream sockaddr and addr_text constant.
Roman Arutyunyan <arut@nginx.com>
parents:
9100
diff
changeset
|
725 |
9051
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
726 reusable = c->reusable; |
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
727 ngx_reusable_connection(c, 0); |
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
728 |
8860
a2cef164a924
QUIC: simplified stream fd initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
729 sc = ngx_get_connection(c->fd, log); |
8760
baf9551b4a5b
QUIC: renamed stream field from c to connection.
Roman Arutyunyan <arut@nginx.com>
parents:
8756
diff
changeset
|
730 if (sc == NULL) { |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
731 ngx_destroy_pool(pool); |
9010 | 732 ngx_queue_insert_tail(&qc->streams.free, &qs->queue); |
9051
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
733 ngx_reusable_connection(c, reusable); |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
734 return NULL; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
735 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
736 |
8761
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8760
diff
changeset
|
737 qs->connection = sc; |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
738 |
8761
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8760
diff
changeset
|
739 sc->quic = qs; |
8842
486c6a9be111
QUIC: store QUIC connection fd in stream fake connection.
Roman Arutyunyan <arut@nginx.com>
parents:
8841
diff
changeset
|
740 sc->shared = 1; |
8760
baf9551b4a5b
QUIC: renamed stream field from c to connection.
Roman Arutyunyan <arut@nginx.com>
parents:
8756
diff
changeset
|
741 sc->type = SOCK_STREAM; |
baf9551b4a5b
QUIC: renamed stream field from c to connection.
Roman Arutyunyan <arut@nginx.com>
parents:
8756
diff
changeset
|
742 sc->pool = pool; |
baf9551b4a5b
QUIC: renamed stream field from c to connection.
Roman Arutyunyan <arut@nginx.com>
parents:
8756
diff
changeset
|
743 sc->ssl = c->ssl; |
9101
3bb003fcd682
QUIC: keep stream sockaddr and addr_text constant.
Roman Arutyunyan <arut@nginx.com>
parents:
9100
diff
changeset
|
744 sc->sockaddr = sockaddr; |
9100
cc3d24a9b76f
QUIC: set c->socklen for streams.
Roman Arutyunyan <arut@nginx.com>
parents:
9086
diff
changeset
|
745 sc->socklen = c->socklen; |
8760
baf9551b4a5b
QUIC: renamed stream field from c to connection.
Roman Arutyunyan <arut@nginx.com>
parents:
8756
diff
changeset
|
746 sc->listening = c->listening; |
9101
3bb003fcd682
QUIC: keep stream sockaddr and addr_text constant.
Roman Arutyunyan <arut@nginx.com>
parents:
9100
diff
changeset
|
747 sc->addr_text = addr_text; |
8760
baf9551b4a5b
QUIC: renamed stream field from c to connection.
Roman Arutyunyan <arut@nginx.com>
parents:
8756
diff
changeset
|
748 sc->local_sockaddr = c->local_sockaddr; |
baf9551b4a5b
QUIC: renamed stream field from c to connection.
Roman Arutyunyan <arut@nginx.com>
parents:
8756
diff
changeset
|
749 sc->local_socklen = c->local_socklen; |
baf9551b4a5b
QUIC: renamed stream field from c to connection.
Roman Arutyunyan <arut@nginx.com>
parents:
8756
diff
changeset
|
750 sc->number = ngx_atomic_fetch_add(ngx_connection_counter, 1); |
9063
e3760b9b7c8e
HTTP/3: fixed $connection_time.
Sergey Kandaurov <pluknet@nginx.com>
parents:
9058
diff
changeset
|
751 sc->start_time = c->start_time; |
8861
630ecd703805
QUIC: set NGX_TCP_NODELAY_DISABLED for fake stream connections.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8860
diff
changeset
|
752 sc->tcp_nodelay = NGX_TCP_NODELAY_DISABLED; |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
753 |
8760
baf9551b4a5b
QUIC: renamed stream field from c to connection.
Roman Arutyunyan <arut@nginx.com>
parents:
8756
diff
changeset
|
754 sc->recv = ngx_quic_stream_recv; |
baf9551b4a5b
QUIC: renamed stream field from c to connection.
Roman Arutyunyan <arut@nginx.com>
parents:
8756
diff
changeset
|
755 sc->send = ngx_quic_stream_send; |
baf9551b4a5b
QUIC: renamed stream field from c to connection.
Roman Arutyunyan <arut@nginx.com>
parents:
8756
diff
changeset
|
756 sc->send_chain = ngx_quic_stream_send_chain; |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
757 |
8760
baf9551b4a5b
QUIC: renamed stream field from c to connection.
Roman Arutyunyan <arut@nginx.com>
parents:
8756
diff
changeset
|
758 sc->read->log = log; |
baf9551b4a5b
QUIC: renamed stream field from c to connection.
Roman Arutyunyan <arut@nginx.com>
parents:
8756
diff
changeset
|
759 sc->write->log = log; |
baf9551b4a5b
QUIC: renamed stream field from c to connection.
Roman Arutyunyan <arut@nginx.com>
parents:
8756
diff
changeset
|
760 |
8827
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8820
diff
changeset
|
761 sc->read->handler = ngx_quic_empty_handler; |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8820
diff
changeset
|
762 sc->write->handler = ngx_quic_empty_handler; |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8820
diff
changeset
|
763 |
8760
baf9551b4a5b
QUIC: renamed stream field from c to connection.
Roman Arutyunyan <arut@nginx.com>
parents:
8756
diff
changeset
|
764 log->connection = sc->number; |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
765 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
766 if (id & NGX_QUIC_STREAM_UNIDIRECTIONAL) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
767 if (id & NGX_QUIC_STREAM_SERVER_INITIATED) { |
8761
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8760
diff
changeset
|
768 qs->send_max_data = qc->ctp.initial_max_stream_data_uni; |
8990
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8988
diff
changeset
|
769 qs->recv_state = NGX_QUIC_STREAM_RECV_DATA_READ; |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8988
diff
changeset
|
770 qs->send_state = NGX_QUIC_STREAM_SEND_READY; |
8779
f52a2b77d406
QUIC: generic buffering for stream input.
Roman Arutyunyan <arut@nginx.com>
parents:
8761
diff
changeset
|
771 |
f52a2b77d406
QUIC: generic buffering for stream input.
Roman Arutyunyan <arut@nginx.com>
parents:
8761
diff
changeset
|
772 } else { |
f52a2b77d406
QUIC: generic buffering for stream input.
Roman Arutyunyan <arut@nginx.com>
parents:
8761
diff
changeset
|
773 qs->recv_max_data = qc->tp.initial_max_stream_data_uni; |
8990
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8988
diff
changeset
|
774 qs->recv_state = NGX_QUIC_STREAM_RECV_RECV; |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8988
diff
changeset
|
775 qs->send_state = NGX_QUIC_STREAM_SEND_DATA_RECVD; |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
776 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
777 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
778 } else { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
779 if (id & NGX_QUIC_STREAM_SERVER_INITIATED) { |
8761
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8760
diff
changeset
|
780 qs->send_max_data = qc->ctp.initial_max_stream_data_bidi_remote; |
8779
f52a2b77d406
QUIC: generic buffering for stream input.
Roman Arutyunyan <arut@nginx.com>
parents:
8761
diff
changeset
|
781 qs->recv_max_data = qc->tp.initial_max_stream_data_bidi_local; |
f52a2b77d406
QUIC: generic buffering for stream input.
Roman Arutyunyan <arut@nginx.com>
parents:
8761
diff
changeset
|
782 |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
783 } else { |
8761
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8760
diff
changeset
|
784 qs->send_max_data = qc->ctp.initial_max_stream_data_bidi_local; |
8779
f52a2b77d406
QUIC: generic buffering for stream input.
Roman Arutyunyan <arut@nginx.com>
parents:
8761
diff
changeset
|
785 qs->recv_max_data = qc->tp.initial_max_stream_data_bidi_remote; |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
786 } |
8990
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8988
diff
changeset
|
787 |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8988
diff
changeset
|
788 qs->recv_state = NGX_QUIC_STREAM_RECV_RECV; |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8988
diff
changeset
|
789 qs->send_state = NGX_QUIC_STREAM_SEND_READY; |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
790 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
791 |
8791
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
792 qs->recv_window = qs->recv_max_data; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
793 |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
794 cln = ngx_pool_cleanup_add(pool, 0); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
795 if (cln == NULL) { |
8760
baf9551b4a5b
QUIC: renamed stream field from c to connection.
Roman Arutyunyan <arut@nginx.com>
parents:
8756
diff
changeset
|
796 ngx_close_connection(sc); |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
797 ngx_destroy_pool(pool); |
9010 | 798 ngx_queue_insert_tail(&qc->streams.free, &qs->queue); |
9051
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
799 ngx_reusable_connection(c, reusable); |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
800 return NULL; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
801 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
802 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
803 cln->handler = ngx_quic_stream_cleanup_handler; |
8760
baf9551b4a5b
QUIC: renamed stream field from c to connection.
Roman Arutyunyan <arut@nginx.com>
parents:
8756
diff
changeset
|
804 cln->data = sc; |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
805 |
8761
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8760
diff
changeset
|
806 ngx_rbtree_insert(&qc->streams.tree, &qs->node); |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
807 |
8761
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8760
diff
changeset
|
808 return qs; |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
809 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
810 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
811 |
9051
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
812 void |
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
813 ngx_quic_cancelable_stream(ngx_connection_t *c) |
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
814 { |
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
815 ngx_connection_t *pc; |
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
816 ngx_quic_stream_t *qs; |
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
817 ngx_quic_connection_t *qc; |
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
818 |
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
819 qs = c->quic; |
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
820 pc = qs->parent; |
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
821 qc = ngx_quic_get_connection(pc); |
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
822 |
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
823 if (!qs->cancelable) { |
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
824 qs->cancelable = 1; |
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
825 |
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
826 if (ngx_quic_can_shutdown(pc) == NGX_OK) { |
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
827 ngx_reusable_connection(pc, 1); |
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
828 |
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
829 if (qc->shutdown) { |
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
830 ngx_quic_shutdown_quic(pc); |
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
831 } |
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
832 } |
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
833 } |
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
834 } |
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
835 |
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
836 |
8827
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8820
diff
changeset
|
837 static void |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8820
diff
changeset
|
838 ngx_quic_empty_handler(ngx_event_t *ev) |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8820
diff
changeset
|
839 { |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8820
diff
changeset
|
840 } |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8820
diff
changeset
|
841 |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8820
diff
changeset
|
842 |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
843 static ssize_t |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
844 ngx_quic_stream_recv(ngx_connection_t *c, u_char *buf, size_t size) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
845 { |
8947
6ccf3867959a
QUIC: refactored ngx_quic_order_bufs() and ngx_quic_split_bufs().
Roman Arutyunyan <arut@nginx.com>
parents:
8946
diff
changeset
|
846 ssize_t len; |
8791
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
847 ngx_buf_t *b; |
8947
6ccf3867959a
QUIC: refactored ngx_quic_order_bufs() and ngx_quic_split_bufs().
Roman Arutyunyan <arut@nginx.com>
parents:
8946
diff
changeset
|
848 ngx_chain_t *cl, *in; |
8791
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
849 ngx_event_t *rev; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
850 ngx_connection_t *pc; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
851 ngx_quic_stream_t *qs; |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
852 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
853 qs = c->quic; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
854 pc = qs->parent; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
855 rev = c->read; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
856 |
8990
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8988
diff
changeset
|
857 if (qs->recv_state == NGX_QUIC_STREAM_RECV_RESET_RECVD |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8988
diff
changeset
|
858 || qs->recv_state == NGX_QUIC_STREAM_RECV_RESET_READ) |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8988
diff
changeset
|
859 { |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8988
diff
changeset
|
860 qs->recv_state = NGX_QUIC_STREAM_RECV_RESET_READ; |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
861 return NGX_ERROR; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
862 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
863 |
9010 | 864 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, pc->log, 0, |
8990
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8988
diff
changeset
|
865 "quic stream id:0x%xL recv buf:%uz", qs->id, size); |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
866 |
8990
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8988
diff
changeset
|
867 if (size == 0) { |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8988
diff
changeset
|
868 return 0; |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
869 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
870 |
9011
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
9010
diff
changeset
|
871 in = ngx_quic_read_buffer(pc, &qs->recv, size); |
8947
6ccf3867959a
QUIC: refactored ngx_quic_order_bufs() and ngx_quic_split_bufs().
Roman Arutyunyan <arut@nginx.com>
parents:
8946
diff
changeset
|
872 if (in == NGX_CHAIN_ERROR) { |
6ccf3867959a
QUIC: refactored ngx_quic_order_bufs() and ngx_quic_split_bufs().
Roman Arutyunyan <arut@nginx.com>
parents:
8946
diff
changeset
|
873 return NGX_ERROR; |
8779
f52a2b77d406
QUIC: generic buffering for stream input.
Roman Arutyunyan <arut@nginx.com>
parents:
8761
diff
changeset
|
874 } |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
875 |
8947
6ccf3867959a
QUIC: refactored ngx_quic_order_bufs() and ngx_quic_split_bufs().
Roman Arutyunyan <arut@nginx.com>
parents:
8946
diff
changeset
|
876 len = 0; |
8779
f52a2b77d406
QUIC: generic buffering for stream input.
Roman Arutyunyan <arut@nginx.com>
parents:
8761
diff
changeset
|
877 |
8947
6ccf3867959a
QUIC: refactored ngx_quic_order_bufs() and ngx_quic_split_bufs().
Roman Arutyunyan <arut@nginx.com>
parents:
8946
diff
changeset
|
878 for (cl = in; cl; cl = cl->next) { |
6ccf3867959a
QUIC: refactored ngx_quic_order_bufs() and ngx_quic_split_bufs().
Roman Arutyunyan <arut@nginx.com>
parents:
8946
diff
changeset
|
879 b = cl->buf; |
6ccf3867959a
QUIC: refactored ngx_quic_order_bufs() and ngx_quic_split_bufs().
Roman Arutyunyan <arut@nginx.com>
parents:
8946
diff
changeset
|
880 len += b->last - b->pos; |
6ccf3867959a
QUIC: refactored ngx_quic_order_bufs() and ngx_quic_split_bufs().
Roman Arutyunyan <arut@nginx.com>
parents:
8946
diff
changeset
|
881 buf = ngx_cpymem(buf, b->pos, b->last - b->pos); |
6ccf3867959a
QUIC: refactored ngx_quic_order_bufs() and ngx_quic_split_bufs().
Roman Arutyunyan <arut@nginx.com>
parents:
8946
diff
changeset
|
882 } |
6ccf3867959a
QUIC: refactored ngx_quic_order_bufs() and ngx_quic_split_bufs().
Roman Arutyunyan <arut@nginx.com>
parents:
8946
diff
changeset
|
883 |
8948
19e063e955bf
QUIC: renamed buffer-related functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8947
diff
changeset
|
884 ngx_quic_free_chain(pc, in); |
8779
f52a2b77d406
QUIC: generic buffering for stream input.
Roman Arutyunyan <arut@nginx.com>
parents:
8761
diff
changeset
|
885 |
8990
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8988
diff
changeset
|
886 if (len == 0) { |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8988
diff
changeset
|
887 rev->ready = 0; |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8988
diff
changeset
|
888 |
9003
6c1dfd072859
QUIC: switch stream to DATA_RECVD state.
Roman Arutyunyan <arut@nginx.com>
parents:
8993
diff
changeset
|
889 if (qs->recv_state == NGX_QUIC_STREAM_RECV_DATA_RECVD |
9010 | 890 && qs->recv_offset == qs->recv_final_size) |
8990
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8988
diff
changeset
|
891 { |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8988
diff
changeset
|
892 qs->recv_state = NGX_QUIC_STREAM_RECV_DATA_READ; |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8988
diff
changeset
|
893 } |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8988
diff
changeset
|
894 |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8988
diff
changeset
|
895 if (qs->recv_state == NGX_QUIC_STREAM_RECV_DATA_READ) { |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8988
diff
changeset
|
896 rev->eof = 1; |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8988
diff
changeset
|
897 return 0; |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8988
diff
changeset
|
898 } |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8988
diff
changeset
|
899 |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8988
diff
changeset
|
900 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8988
diff
changeset
|
901 "quic stream id:0x%xL recv() not ready", qs->id); |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8988
diff
changeset
|
902 return NGX_AGAIN; |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
903 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
904 |
8782
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8779
diff
changeset
|
905 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0, |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8779
diff
changeset
|
906 "quic stream id:0x%xL recv len:%z", qs->id, len); |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
907 |
9010 | 908 if (ngx_quic_update_flow(qs, qs->recv_offset + len) != NGX_OK) { |
8791
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
909 return NGX_ERROR; |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
910 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
911 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
912 return len; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
913 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
914 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
915 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
916 static ssize_t |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
917 ngx_quic_stream_send(ngx_connection_t *c, u_char *buf, size_t size) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
918 { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
919 ngx_buf_t b; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
920 ngx_chain_t cl; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
921 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
922 ngx_memzero(&b, sizeof(ngx_buf_t)); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
923 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
924 b.memory = 1; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
925 b.pos = buf; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
926 b.last = buf + size; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
927 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
928 cl.buf = &b; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
929 cl.next = NULL; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
930 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
931 if (ngx_quic_stream_send_chain(c, &cl, 0) == NGX_CHAIN_ERROR) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
932 return NGX_ERROR; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
933 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
934 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
935 if (b.pos == buf) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
936 return NGX_AGAIN; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
937 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
938 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
939 return b.pos - buf; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
940 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
941 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
942 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
943 static ngx_chain_t * |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
944 ngx_quic_stream_send_chain(ngx_connection_t *c, ngx_chain_t *in, off_t limit) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
945 { |
9011
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
9010
diff
changeset
|
946 uint64_t n, flow; |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
947 ngx_event_t *wev; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
948 ngx_connection_t *pc; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
949 ngx_quic_stream_t *qs; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
950 ngx_quic_connection_t *qc; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
951 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
952 qs = c->quic; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
953 pc = qs->parent; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
954 qc = ngx_quic_get_connection(pc); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
955 wev = c->write; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
956 |
8990
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8988
diff
changeset
|
957 if (qs->send_state != NGX_QUIC_STREAM_SEND_READY |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8988
diff
changeset
|
958 && qs->send_state != NGX_QUIC_STREAM_SEND_SEND) |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8988
diff
changeset
|
959 { |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8988
diff
changeset
|
960 wev->error = 1; |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
961 return NGX_CHAIN_ERROR; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
962 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
963 |
8990
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8988
diff
changeset
|
964 qs->send_state = NGX_QUIC_STREAM_SEND_SEND; |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8988
diff
changeset
|
965 |
9052
2e51cf3ffd90
QUIC: defer stream removal until all its data is acked.
Roman Arutyunyan <arut@nginx.com>
parents:
9051
diff
changeset
|
966 flow = qs->acked + qc->conf->stream_buffer_size - qs->sent; |
9010 | 967 |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
968 if (flow == 0) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
969 wev->ready = 0; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
970 return in; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
971 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
972 |
9011
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
9010
diff
changeset
|
973 if (limit == 0 || limit > (off_t) flow) { |
8947
6ccf3867959a
QUIC: refactored ngx_quic_order_bufs() and ngx_quic_split_bufs().
Roman Arutyunyan <arut@nginx.com>
parents:
8946
diff
changeset
|
974 limit = flow; |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
975 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
976 |
9011
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
9010
diff
changeset
|
977 n = qs->send.size; |
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
9010
diff
changeset
|
978 |
9052
2e51cf3ffd90
QUIC: defer stream removal until all its data is acked.
Roman Arutyunyan <arut@nginx.com>
parents:
9051
diff
changeset
|
979 in = ngx_quic_write_buffer(pc, &qs->send, in, limit, qs->sent); |
8947
6ccf3867959a
QUIC: refactored ngx_quic_order_bufs() and ngx_quic_split_bufs().
Roman Arutyunyan <arut@nginx.com>
parents:
8946
diff
changeset
|
980 if (in == NGX_CHAIN_ERROR) { |
6ccf3867959a
QUIC: refactored ngx_quic_order_bufs() and ngx_quic_split_bufs().
Roman Arutyunyan <arut@nginx.com>
parents:
8946
diff
changeset
|
981 return NGX_CHAIN_ERROR; |
6ccf3867959a
QUIC: refactored ngx_quic_order_bufs() and ngx_quic_split_bufs().
Roman Arutyunyan <arut@nginx.com>
parents:
8946
diff
changeset
|
982 } |
6ccf3867959a
QUIC: refactored ngx_quic_order_bufs() and ngx_quic_split_bufs().
Roman Arutyunyan <arut@nginx.com>
parents:
8946
diff
changeset
|
983 |
9011
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
9010
diff
changeset
|
984 n = qs->send.size - n; |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
985 c->sent += n; |
9052
2e51cf3ffd90
QUIC: defer stream removal until all its data is acked.
Roman Arutyunyan <arut@nginx.com>
parents:
9051
diff
changeset
|
986 qs->sent += n; |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
987 qc->streams.sent += n; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
988 |
9011
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
9010
diff
changeset
|
989 if (flow == n) { |
8947
6ccf3867959a
QUIC: refactored ngx_quic_order_bufs() and ngx_quic_split_bufs().
Roman Arutyunyan <arut@nginx.com>
parents:
8946
diff
changeset
|
990 wev->ready = 0; |
6ccf3867959a
QUIC: refactored ngx_quic_order_bufs() and ngx_quic_split_bufs().
Roman Arutyunyan <arut@nginx.com>
parents:
8946
diff
changeset
|
991 } |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
992 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
993 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
9011
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
9010
diff
changeset
|
994 "quic send_chain sent:%uL", n); |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
995 |
9010 | 996 if (ngx_quic_stream_flush(qs) != NGX_OK) { |
997 return NGX_CHAIN_ERROR; | |
998 } | |
999 | |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1000 return in; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1001 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1002 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1003 |
9010 | 1004 static ngx_int_t |
1005 ngx_quic_stream_flush(ngx_quic_stream_t *qs) | |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1006 { |
9011
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
9010
diff
changeset
|
1007 off_t limit, len; |
9010 | 1008 ngx_uint_t last; |
9011
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
9010
diff
changeset
|
1009 ngx_chain_t *out; |
9010 | 1010 ngx_quic_frame_t *frame; |
1011 ngx_connection_t *pc; | |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1012 ngx_quic_connection_t *qc; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1013 |
9010 | 1014 if (qs->send_state != NGX_QUIC_STREAM_SEND_SEND) { |
1015 return NGX_OK; | |
1016 } | |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1017 |
9010 | 1018 pc = qs->parent; |
1019 qc = ngx_quic_get_connection(pc); | |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1020 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1021 if (qc->streams.send_max_data == 0) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1022 qc->streams.send_max_data = qc->ctp.initial_max_data; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1023 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1024 |
9010 | 1025 limit = ngx_min(qc->streams.send_max_data - qc->streams.send_offset, |
1026 qs->send_max_data - qs->send_offset); | |
1027 | |
1028 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, pc->log, 0, | |
1029 "quic stream id:0x%xL flush limit:%O", qs->id, limit); | |
1030 | |
9011
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
9010
diff
changeset
|
1031 len = qs->send.offset; |
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
9010
diff
changeset
|
1032 |
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
9010
diff
changeset
|
1033 out = ngx_quic_read_buffer(pc, &qs->send, limit); |
9010 | 1034 if (out == NGX_CHAIN_ERROR) { |
1035 return NGX_ERROR; | |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1036 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1037 |
9011
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
9010
diff
changeset
|
1038 len = qs->send.offset - len; |
9010 | 1039 last = 0; |
1040 | |
1041 if (qs->send_final_size != (uint64_t) -1 | |
9011
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
9010
diff
changeset
|
1042 && qs->send_final_size == qs->send.offset) |
9010 | 1043 { |
1044 qs->send_state = NGX_QUIC_STREAM_SEND_DATA_SENT; | |
1045 last = 1; | |
1046 } | |
1047 | |
1048 if (len == 0 && !last) { | |
1049 return NGX_OK; | |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1050 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1051 |
9010 | 1052 frame = ngx_quic_alloc_frame(pc); |
1053 if (frame == NULL) { | |
1054 return NGX_ERROR; | |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1055 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1056 |
9010 | 1057 frame->level = ssl_encryption_application; |
1058 frame->type = NGX_QUIC_FT_STREAM; | |
1059 frame->data = out; | |
1060 | |
1061 frame->u.stream.off = 1; | |
1062 frame->u.stream.len = 1; | |
1063 frame->u.stream.fin = last; | |
1064 | |
1065 frame->u.stream.stream_id = qs->id; | |
1066 frame->u.stream.offset = qs->send_offset; | |
1067 frame->u.stream.length = len; | |
1068 | |
1069 ngx_quic_queue_frame(qc, frame); | |
1070 | |
1071 qs->send_offset += len; | |
1072 qc->streams.send_offset += len; | |
1073 | |
1074 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, pc->log, 0, | |
9011
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
9010
diff
changeset
|
1075 "quic stream id:0x%xL flush len:%O last:%ui", |
9010 | 1076 qs->id, len, last); |
1077 | |
1078 if (qs->connection == NULL) { | |
1079 return ngx_quic_close_stream(qs); | |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1080 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1081 |
9010 | 1082 return NGX_OK; |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1083 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1084 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1085 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1086 static void |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1087 ngx_quic_stream_cleanup_handler(void *data) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1088 { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1089 ngx_connection_t *c = data; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1090 |
9112
d59277dd3d8c
QUIC: fixed post-close use-after-free.
Roman Arutyunyan <arut@nginx.com>
parents:
9101
diff
changeset
|
1091 ngx_quic_stream_t *qs; |
d59277dd3d8c
QUIC: fixed post-close use-after-free.
Roman Arutyunyan <arut@nginx.com>
parents:
9101
diff
changeset
|
1092 ngx_quic_connection_t *qc; |
9010 | 1093 |
1094 qs = c->quic; | |
1095 | |
1096 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, qs->parent->log, 0, | |
1097 "quic stream id:0x%xL cleanup", qs->id); | |
1098 | |
1099 if (ngx_quic_shutdown_stream(c, NGX_RDWR_SHUTDOWN) != NGX_OK) { | |
9210
4ed4e1e7f115
QUIC: fixed stream cleanup (ticket #2586).
Roman Arutyunyan <arut@nginx.com>
parents:
9158
diff
changeset
|
1100 qs->connection = NULL; |
9112
d59277dd3d8c
QUIC: fixed post-close use-after-free.
Roman Arutyunyan <arut@nginx.com>
parents:
9101
diff
changeset
|
1101 goto failed; |
9010 | 1102 } |
1103 | |
1104 qs->connection = NULL; | |
1105 | |
1106 if (ngx_quic_close_stream(qs) != NGX_OK) { | |
9112
d59277dd3d8c
QUIC: fixed post-close use-after-free.
Roman Arutyunyan <arut@nginx.com>
parents:
9101
diff
changeset
|
1107 goto failed; |
9010 | 1108 } |
9112
d59277dd3d8c
QUIC: fixed post-close use-after-free.
Roman Arutyunyan <arut@nginx.com>
parents:
9101
diff
changeset
|
1109 |
d59277dd3d8c
QUIC: fixed post-close use-after-free.
Roman Arutyunyan <arut@nginx.com>
parents:
9101
diff
changeset
|
1110 return; |
d59277dd3d8c
QUIC: fixed post-close use-after-free.
Roman Arutyunyan <arut@nginx.com>
parents:
9101
diff
changeset
|
1111 |
d59277dd3d8c
QUIC: fixed post-close use-after-free.
Roman Arutyunyan <arut@nginx.com>
parents:
9101
diff
changeset
|
1112 failed: |
d59277dd3d8c
QUIC: fixed post-close use-after-free.
Roman Arutyunyan <arut@nginx.com>
parents:
9101
diff
changeset
|
1113 |
d59277dd3d8c
QUIC: fixed post-close use-after-free.
Roman Arutyunyan <arut@nginx.com>
parents:
9101
diff
changeset
|
1114 qc = ngx_quic_get_connection(qs->parent); |
d59277dd3d8c
QUIC: fixed post-close use-after-free.
Roman Arutyunyan <arut@nginx.com>
parents:
9101
diff
changeset
|
1115 qc->error = NGX_QUIC_ERR_INTERNAL_ERROR; |
d59277dd3d8c
QUIC: fixed post-close use-after-free.
Roman Arutyunyan <arut@nginx.com>
parents:
9101
diff
changeset
|
1116 |
d59277dd3d8c
QUIC: fixed post-close use-after-free.
Roman Arutyunyan <arut@nginx.com>
parents:
9101
diff
changeset
|
1117 ngx_post_event(&qc->close, &ngx_posted_events); |
9010 | 1118 } |
1119 | |
1120 | |
1121 static ngx_int_t | |
1122 ngx_quic_close_stream(ngx_quic_stream_t *qs) | |
1123 { | |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1124 ngx_connection_t *pc; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1125 ngx_quic_frame_t *frame; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1126 ngx_quic_connection_t *qc; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1127 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1128 pc = qs->parent; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1129 qc = ngx_quic_get_connection(pc); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1130 |
9010 | 1131 if (!qc->closing) { |
1132 /* make sure everything is sent and final size is received */ | |
1133 | |
9052
2e51cf3ffd90
QUIC: defer stream removal until all its data is acked.
Roman Arutyunyan <arut@nginx.com>
parents:
9051
diff
changeset
|
1134 if (qs->recv_state == NGX_QUIC_STREAM_RECV_RECV) { |
2e51cf3ffd90
QUIC: defer stream removal until all its data is acked.
Roman Arutyunyan <arut@nginx.com>
parents:
9051
diff
changeset
|
1135 return NGX_OK; |
2e51cf3ffd90
QUIC: defer stream removal until all its data is acked.
Roman Arutyunyan <arut@nginx.com>
parents:
9051
diff
changeset
|
1136 } |
2e51cf3ffd90
QUIC: defer stream removal until all its data is acked.
Roman Arutyunyan <arut@nginx.com>
parents:
9051
diff
changeset
|
1137 |
2e51cf3ffd90
QUIC: defer stream removal until all its data is acked.
Roman Arutyunyan <arut@nginx.com>
parents:
9051
diff
changeset
|
1138 if (qs->send_state != NGX_QUIC_STREAM_SEND_DATA_RECVD |
2e51cf3ffd90
QUIC: defer stream removal until all its data is acked.
Roman Arutyunyan <arut@nginx.com>
parents:
9051
diff
changeset
|
1139 && qs->send_state != NGX_QUIC_STREAM_SEND_RESET_RECVD) |
9010 | 1140 { |
1141 return NGX_OK; | |
1142 } | |
1143 } | |
1144 | |
1145 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, pc->log, 0, | |
1146 "quic stream id:0x%xL close", qs->id); | |
1147 | |
9011
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
9010
diff
changeset
|
1148 ngx_quic_free_buffer(pc, &qs->send); |
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
9010
diff
changeset
|
1149 ngx_quic_free_buffer(pc, &qs->recv); |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1150 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1151 ngx_rbtree_delete(&qc->streams.tree, &qs->node); |
9010 | 1152 ngx_queue_insert_tail(&qc->streams.free, &qs->queue); |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1153 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1154 if (qc->closing) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1155 /* schedule handler call to continue ngx_quic_close_connection() */ |
9050
aaca8e111959
QUIC: post close event for connection close.
Roman Arutyunyan <arut@nginx.com>
parents:
9045
diff
changeset
|
1156 ngx_post_event(&qc->close, &ngx_posted_events); |
9010 | 1157 return NGX_OK; |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1158 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1159 |
9053
740d7d6e8ff0
QUIC: do not send MAX_STREAMS in shutdown state.
Roman Arutyunyan <arut@nginx.com>
parents:
9052
diff
changeset
|
1160 if (!pc->reusable && ngx_quic_can_shutdown(pc) == NGX_OK) { |
740d7d6e8ff0
QUIC: do not send MAX_STREAMS in shutdown state.
Roman Arutyunyan <arut@nginx.com>
parents:
9052
diff
changeset
|
1161 ngx_reusable_connection(pc, 1); |
740d7d6e8ff0
QUIC: do not send MAX_STREAMS in shutdown state.
Roman Arutyunyan <arut@nginx.com>
parents:
9052
diff
changeset
|
1162 } |
740d7d6e8ff0
QUIC: do not send MAX_STREAMS in shutdown state.
Roman Arutyunyan <arut@nginx.com>
parents:
9052
diff
changeset
|
1163 |
740d7d6e8ff0
QUIC: do not send MAX_STREAMS in shutdown state.
Roman Arutyunyan <arut@nginx.com>
parents:
9052
diff
changeset
|
1164 if (qc->shutdown) { |
740d7d6e8ff0
QUIC: do not send MAX_STREAMS in shutdown state.
Roman Arutyunyan <arut@nginx.com>
parents:
9052
diff
changeset
|
1165 ngx_quic_shutdown_quic(pc); |
740d7d6e8ff0
QUIC: do not send MAX_STREAMS in shutdown state.
Roman Arutyunyan <arut@nginx.com>
parents:
9052
diff
changeset
|
1166 return NGX_OK; |
740d7d6e8ff0
QUIC: do not send MAX_STREAMS in shutdown state.
Roman Arutyunyan <arut@nginx.com>
parents:
9052
diff
changeset
|
1167 } |
740d7d6e8ff0
QUIC: do not send MAX_STREAMS in shutdown state.
Roman Arutyunyan <arut@nginx.com>
parents:
9052
diff
changeset
|
1168 |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1169 if ((qs->id & NGX_QUIC_STREAM_SERVER_INITIATED) == 0) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1170 frame = ngx_quic_alloc_frame(pc); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1171 if (frame == NULL) { |
9010 | 1172 return NGX_ERROR; |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1173 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1174 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1175 frame->level = ssl_encryption_application; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1176 frame->type = NGX_QUIC_FT_MAX_STREAMS; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1177 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1178 if (qs->id & NGX_QUIC_STREAM_UNIDIRECTIONAL) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1179 frame->u.max_streams.limit = ++qc->streams.client_max_streams_uni; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1180 frame->u.max_streams.bidi = 0; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1181 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1182 } else { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1183 frame->u.max_streams.limit = ++qc->streams.client_max_streams_bidi; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1184 frame->u.max_streams.bidi = 1; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1185 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1186 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1187 ngx_quic_queue_frame(qc, frame); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1188 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1189 |
9010 | 1190 return NGX_OK; |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1191 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1192 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1193 |
9051
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
1194 static ngx_int_t |
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
1195 ngx_quic_can_shutdown(ngx_connection_t *c) |
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
1196 { |
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
1197 ngx_rbtree_t *tree; |
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
1198 ngx_rbtree_node_t *node; |
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
1199 ngx_quic_stream_t *qs; |
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
1200 ngx_quic_connection_t *qc; |
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
1201 |
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
1202 qc = ngx_quic_get_connection(c); |
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
1203 |
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
1204 tree = &qc->streams.tree; |
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
1205 |
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
1206 if (tree->root != tree->sentinel) { |
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
1207 for (node = ngx_rbtree_min(tree->root, tree->sentinel); |
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
1208 node; |
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
1209 node = ngx_rbtree_next(tree, node)) |
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
1210 { |
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
1211 qs = (ngx_quic_stream_t *) node; |
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
1212 |
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
1213 if (!qs->cancelable) { |
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
1214 return NGX_DECLINED; |
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
1215 } |
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
1216 } |
9075
12b756caaf16
QUIC: fixed indentation.
Sergey Kandaurov <pluknet@nginx.com>
parents:
9069
diff
changeset
|
1217 } |
9051
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
1218 |
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
1219 return NGX_OK; |
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
1220 } |
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
1221 |
37d5dddabaea
QUIC: reusable mode for main connection.
Roman Arutyunyan <arut@nginx.com>
parents:
9050
diff
changeset
|
1222 |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1223 ngx_int_t |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1224 ngx_quic_handle_stream_frame(ngx_connection_t *c, ngx_quic_header_t *pkt, |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1225 ngx_quic_frame_t *frame) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1226 { |
8782
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8779
diff
changeset
|
1227 uint64_t last; |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8779
diff
changeset
|
1228 ngx_quic_stream_t *qs; |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8779
diff
changeset
|
1229 ngx_quic_connection_t *qc; |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8779
diff
changeset
|
1230 ngx_quic_stream_frame_t *f; |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1231 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1232 qc = ngx_quic_get_connection(c); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1233 f = &frame->u.stream; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1234 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1235 if ((f->stream_id & NGX_QUIC_STREAM_UNIDIRECTIONAL) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1236 && (f->stream_id & NGX_QUIC_STREAM_SERVER_INITIATED)) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1237 { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1238 qc->error = NGX_QUIC_ERR_STREAM_STATE_ERROR; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1239 return NGX_ERROR; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1240 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1241 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1242 /* no overflow since both values are 62-bit */ |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1243 last = f->offset + f->length; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1244 |
8937
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8936
diff
changeset
|
1245 qs = ngx_quic_get_stream(c, f->stream_id); |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1246 |
8761
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8760
diff
changeset
|
1247 if (qs == NULL) { |
8937
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8936
diff
changeset
|
1248 return NGX_ERROR; |
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8936
diff
changeset
|
1249 } |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1250 |
8937
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8936
diff
changeset
|
1251 if (qs == NGX_QUIC_STREAM_GONE) { |
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8936
diff
changeset
|
1252 return NGX_OK; |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1253 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1254 |
8990
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8988
diff
changeset
|
1255 if (qs->recv_state != NGX_QUIC_STREAM_RECV_RECV |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8988
diff
changeset
|
1256 && qs->recv_state != NGX_QUIC_STREAM_RECV_SIZE_KNOWN) |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8988
diff
changeset
|
1257 { |
8791
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
1258 return NGX_OK; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
1259 } |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
1260 |
9010 | 1261 if (ngx_quic_control_flow(qs, last) != NGX_OK) { |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1262 return NGX_ERROR; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1263 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1264 |
9010 | 1265 if (qs->recv_final_size != (uint64_t) -1 && last > qs->recv_final_size) { |
8782
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8779
diff
changeset
|
1266 qc->error = NGX_QUIC_ERR_FINAL_SIZE_ERROR; |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8779
diff
changeset
|
1267 return NGX_ERROR; |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8779
diff
changeset
|
1268 } |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8779
diff
changeset
|
1269 |
8962
47f45a98f892
QUIC: fixed handling STREAM FIN.
Roman Arutyunyan <arut@nginx.com>
parents:
8952
diff
changeset
|
1270 if (last < qs->recv_offset) { |
8782
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8779
diff
changeset
|
1271 return NGX_OK; |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8779
diff
changeset
|
1272 } |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8779
diff
changeset
|
1273 |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8779
diff
changeset
|
1274 if (f->fin) { |
9010 | 1275 if (qs->recv_final_size != (uint64_t) -1 && qs->recv_final_size != last) |
1276 { | |
8782
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8779
diff
changeset
|
1277 qc->error = NGX_QUIC_ERR_FINAL_SIZE_ERROR; |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8779
diff
changeset
|
1278 return NGX_ERROR; |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8779
diff
changeset
|
1279 } |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8779
diff
changeset
|
1280 |
8783
60c6e8d8d3ae
QUIC: make sure stream data size is lower than final size.
Roman Arutyunyan <arut@nginx.com>
parents:
8782
diff
changeset
|
1281 if (qs->recv_last > last) { |
60c6e8d8d3ae
QUIC: make sure stream data size is lower than final size.
Roman Arutyunyan <arut@nginx.com>
parents:
8782
diff
changeset
|
1282 qc->error = NGX_QUIC_ERR_FINAL_SIZE_ERROR; |
60c6e8d8d3ae
QUIC: make sure stream data size is lower than final size.
Roman Arutyunyan <arut@nginx.com>
parents:
8782
diff
changeset
|
1283 return NGX_ERROR; |
60c6e8d8d3ae
QUIC: make sure stream data size is lower than final size.
Roman Arutyunyan <arut@nginx.com>
parents:
8782
diff
changeset
|
1284 } |
60c6e8d8d3ae
QUIC: make sure stream data size is lower than final size.
Roman Arutyunyan <arut@nginx.com>
parents:
8782
diff
changeset
|
1285 |
9010 | 1286 qs->recv_final_size = last; |
8990
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8988
diff
changeset
|
1287 qs->recv_state = NGX_QUIC_STREAM_RECV_SIZE_KNOWN; |
8782
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8779
diff
changeset
|
1288 } |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8779
diff
changeset
|
1289 |
9011
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
9010
diff
changeset
|
1290 if (ngx_quic_write_buffer(c, &qs->recv, frame->data, f->length, f->offset) |
8947
6ccf3867959a
QUIC: refactored ngx_quic_order_bufs() and ngx_quic_split_bufs().
Roman Arutyunyan <arut@nginx.com>
parents:
8946
diff
changeset
|
1291 == NGX_CHAIN_ERROR) |
8784
7d32c3c93678
QUIC: call stream read handler on new data arrival.
Roman Arutyunyan <arut@nginx.com>
parents:
8783
diff
changeset
|
1292 { |
7d32c3c93678
QUIC: call stream read handler on new data arrival.
Roman Arutyunyan <arut@nginx.com>
parents:
8783
diff
changeset
|
1293 return NGX_ERROR; |
7d32c3c93678
QUIC: call stream read handler on new data arrival.
Roman Arutyunyan <arut@nginx.com>
parents:
8783
diff
changeset
|
1294 } |
7d32c3c93678
QUIC: call stream read handler on new data arrival.
Roman Arutyunyan <arut@nginx.com>
parents:
8783
diff
changeset
|
1295 |
9003
6c1dfd072859
QUIC: switch stream to DATA_RECVD state.
Roman Arutyunyan <arut@nginx.com>
parents:
8993
diff
changeset
|
1296 if (qs->recv_state == NGX_QUIC_STREAM_RECV_SIZE_KNOWN |
9011
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
9010
diff
changeset
|
1297 && qs->recv.size == qs->recv_final_size) |
9003
6c1dfd072859
QUIC: switch stream to DATA_RECVD state.
Roman Arutyunyan <arut@nginx.com>
parents:
8993
diff
changeset
|
1298 { |
6c1dfd072859
QUIC: switch stream to DATA_RECVD state.
Roman Arutyunyan <arut@nginx.com>
parents:
8993
diff
changeset
|
1299 qs->recv_state = NGX_QUIC_STREAM_RECV_DATA_RECVD; |
6c1dfd072859
QUIC: switch stream to DATA_RECVD state.
Roman Arutyunyan <arut@nginx.com>
parents:
8993
diff
changeset
|
1300 } |
6c1dfd072859
QUIC: switch stream to DATA_RECVD state.
Roman Arutyunyan <arut@nginx.com>
parents:
8993
diff
changeset
|
1301 |
9010 | 1302 if (qs->connection == NULL) { |
1303 return ngx_quic_close_stream(qs); | |
1304 } | |
1305 | |
9045
c6580dce98a8
QUIC: fixed triggering stream read event (ticket #2409).
Roman Arutyunyan <arut@nginx.com>
parents:
9012
diff
changeset
|
1306 if (f->offset <= qs->recv_offset) { |
9010 | 1307 ngx_quic_set_event(qs->connection->read); |
8784
7d32c3c93678
QUIC: call stream read handler on new data arrival.
Roman Arutyunyan <arut@nginx.com>
parents:
8783
diff
changeset
|
1308 } |
7d32c3c93678
QUIC: call stream read handler on new data arrival.
Roman Arutyunyan <arut@nginx.com>
parents:
8783
diff
changeset
|
1309 |
7d32c3c93678
QUIC: call stream read handler on new data arrival.
Roman Arutyunyan <arut@nginx.com>
parents:
8783
diff
changeset
|
1310 return NGX_OK; |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1311 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1312 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1313 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1314 ngx_int_t |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1315 ngx_quic_handle_max_data_frame(ngx_connection_t *c, |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1316 ngx_quic_max_data_frame_t *f) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1317 { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1318 ngx_rbtree_t *tree; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1319 ngx_rbtree_node_t *node; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1320 ngx_quic_stream_t *qs; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1321 ngx_quic_connection_t *qc; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1322 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1323 qc = ngx_quic_get_connection(c); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1324 tree = &qc->streams.tree; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1325 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1326 if (f->max_data <= qc->streams.send_max_data) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1327 return NGX_OK; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1328 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1329 |
9010 | 1330 if (tree->root == tree->sentinel |
1331 || qc->streams.send_offset < qc->streams.send_max_data) | |
8841
1f7f98638dc2
QUIC: fixed null pointer dereference in MAX_DATA handler.
Mariano Di Martino <mariano.dimartino@uhasselt.be>
parents:
8828
diff
changeset
|
1332 { |
9010 | 1333 /* not blocked on MAX_DATA */ |
1334 qc->streams.send_max_data = f->max_data; | |
1335 return NGX_OK; | |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1336 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1337 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1338 qc->streams.send_max_data = f->max_data; |
9010 | 1339 node = ngx_rbtree_min(tree->root, tree->sentinel); |
1340 | |
1341 while (node && qc->streams.send_offset < qc->streams.send_max_data) { | |
1342 | |
1343 qs = (ngx_quic_stream_t *) node; | |
1344 node = ngx_rbtree_next(tree, node); | |
1345 | |
1346 if (ngx_quic_stream_flush(qs) != NGX_OK) { | |
1347 return NGX_ERROR; | |
1348 } | |
1349 } | |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1350 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1351 return NGX_OK; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1352 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1353 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1354 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1355 ngx_int_t |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1356 ngx_quic_handle_streams_blocked_frame(ngx_connection_t *c, |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1357 ngx_quic_header_t *pkt, ngx_quic_streams_blocked_frame_t *f) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1358 { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1359 return NGX_OK; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1360 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1361 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1362 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1363 ngx_int_t |
8909
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8908
diff
changeset
|
1364 ngx_quic_handle_data_blocked_frame(ngx_connection_t *c, |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8908
diff
changeset
|
1365 ngx_quic_header_t *pkt, ngx_quic_data_blocked_frame_t *f) |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8908
diff
changeset
|
1366 { |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8908
diff
changeset
|
1367 return ngx_quic_update_max_data(c); |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8908
diff
changeset
|
1368 } |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8908
diff
changeset
|
1369 |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8908
diff
changeset
|
1370 |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8908
diff
changeset
|
1371 ngx_int_t |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1372 ngx_quic_handle_stream_data_blocked_frame(ngx_connection_t *c, |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1373 ngx_quic_header_t *pkt, ngx_quic_stream_data_blocked_frame_t *f) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1374 { |
8761
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8760
diff
changeset
|
1375 ngx_quic_stream_t *qs; |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1376 ngx_quic_connection_t *qc; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1377 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1378 qc = ngx_quic_get_connection(c); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1379 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1380 if ((f->id & NGX_QUIC_STREAM_UNIDIRECTIONAL) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1381 && (f->id & NGX_QUIC_STREAM_SERVER_INITIATED)) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1382 { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1383 qc->error = NGX_QUIC_ERR_STREAM_STATE_ERROR; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1384 return NGX_ERROR; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1385 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1386 |
8937
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8936
diff
changeset
|
1387 qs = ngx_quic_get_stream(c, f->id); |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1388 |
8761
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8760
diff
changeset
|
1389 if (qs == NULL) { |
8937
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8936
diff
changeset
|
1390 return NGX_ERROR; |
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8936
diff
changeset
|
1391 } |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1392 |
8937
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8936
diff
changeset
|
1393 if (qs == NGX_QUIC_STREAM_GONE) { |
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8936
diff
changeset
|
1394 return NGX_OK; |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1395 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1396 |
9010 | 1397 return ngx_quic_update_max_stream_data(qs); |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1398 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1399 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1400 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1401 ngx_int_t |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1402 ngx_quic_handle_max_stream_data_frame(ngx_connection_t *c, |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1403 ngx_quic_header_t *pkt, ngx_quic_max_stream_data_frame_t *f) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1404 { |
8761
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8760
diff
changeset
|
1405 ngx_quic_stream_t *qs; |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1406 ngx_quic_connection_t *qc; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1407 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1408 qc = ngx_quic_get_connection(c); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1409 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1410 if ((f->id & NGX_QUIC_STREAM_UNIDIRECTIONAL) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1411 && (f->id & NGX_QUIC_STREAM_SERVER_INITIATED) == 0) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1412 { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1413 qc->error = NGX_QUIC_ERR_STREAM_STATE_ERROR; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1414 return NGX_ERROR; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1415 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1416 |
8937
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8936
diff
changeset
|
1417 qs = ngx_quic_get_stream(c, f->id); |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1418 |
8761
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8760
diff
changeset
|
1419 if (qs == NULL) { |
8937
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8936
diff
changeset
|
1420 return NGX_ERROR; |
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8936
diff
changeset
|
1421 } |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1422 |
8937
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8936
diff
changeset
|
1423 if (qs == NGX_QUIC_STREAM_GONE) { |
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8936
diff
changeset
|
1424 return NGX_OK; |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1425 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1426 |
8761
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8760
diff
changeset
|
1427 if (f->limit <= qs->send_max_data) { |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1428 return NGX_OK; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1429 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1430 |
9010 | 1431 if (qs->send_offset < qs->send_max_data) { |
1432 /* not blocked on MAX_STREAM_DATA */ | |
1433 qs->send_max_data = f->limit; | |
1434 return NGX_OK; | |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1435 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1436 |
8761
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8760
diff
changeset
|
1437 qs->send_max_data = f->limit; |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1438 |
9010 | 1439 return ngx_quic_stream_flush(qs); |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1440 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1441 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1442 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1443 ngx_int_t |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1444 ngx_quic_handle_reset_stream_frame(ngx_connection_t *c, |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1445 ngx_quic_header_t *pkt, ngx_quic_reset_stream_frame_t *f) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1446 { |
9065
2ee6f9729739
QUIC: set stream error flag on reset.
Roman Arutyunyan <arut@nginx.com>
parents:
9064
diff
changeset
|
1447 ngx_event_t *rev; |
8761
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8760
diff
changeset
|
1448 ngx_quic_stream_t *qs; |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1449 ngx_quic_connection_t *qc; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1450 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1451 qc = ngx_quic_get_connection(c); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1452 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1453 if ((f->id & NGX_QUIC_STREAM_UNIDIRECTIONAL) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1454 && (f->id & NGX_QUIC_STREAM_SERVER_INITIATED)) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1455 { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1456 qc->error = NGX_QUIC_ERR_STREAM_STATE_ERROR; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1457 return NGX_ERROR; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1458 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1459 |
8937
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8936
diff
changeset
|
1460 qs = ngx_quic_get_stream(c, f->id); |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1461 |
8761
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8760
diff
changeset
|
1462 if (qs == NULL) { |
8937
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8936
diff
changeset
|
1463 return NGX_ERROR; |
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8936
diff
changeset
|
1464 } |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1465 |
8937
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8936
diff
changeset
|
1466 if (qs == NGX_QUIC_STREAM_GONE) { |
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8936
diff
changeset
|
1467 return NGX_OK; |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1468 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1469 |
8990
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8988
diff
changeset
|
1470 if (qs->recv_state == NGX_QUIC_STREAM_RECV_RESET_RECVD |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8988
diff
changeset
|
1471 || qs->recv_state == NGX_QUIC_STREAM_RECV_RESET_READ) |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8988
diff
changeset
|
1472 { |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8988
diff
changeset
|
1473 return NGX_OK; |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8988
diff
changeset
|
1474 } |
8791
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
1475 |
8990
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8988
diff
changeset
|
1476 qs->recv_state = NGX_QUIC_STREAM_RECV_RESET_RECVD; |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8988
diff
changeset
|
1477 |
9010 | 1478 if (ngx_quic_control_flow(qs, f->final_size) != NGX_OK) { |
8791
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
1479 return NGX_ERROR; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
1480 } |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
1481 |
9010 | 1482 if (qs->recv_final_size != (uint64_t) -1 |
1483 && qs->recv_final_size != f->final_size) | |
1484 { | |
8782
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8779
diff
changeset
|
1485 qc->error = NGX_QUIC_ERR_FINAL_SIZE_ERROR; |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8779
diff
changeset
|
1486 return NGX_ERROR; |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8779
diff
changeset
|
1487 } |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8779
diff
changeset
|
1488 |
8783
60c6e8d8d3ae
QUIC: make sure stream data size is lower than final size.
Roman Arutyunyan <arut@nginx.com>
parents:
8782
diff
changeset
|
1489 if (qs->recv_last > f->final_size) { |
60c6e8d8d3ae
QUIC: make sure stream data size is lower than final size.
Roman Arutyunyan <arut@nginx.com>
parents:
8782
diff
changeset
|
1490 qc->error = NGX_QUIC_ERR_FINAL_SIZE_ERROR; |
60c6e8d8d3ae
QUIC: make sure stream data size is lower than final size.
Roman Arutyunyan <arut@nginx.com>
parents:
8782
diff
changeset
|
1491 return NGX_ERROR; |
60c6e8d8d3ae
QUIC: make sure stream data size is lower than final size.
Roman Arutyunyan <arut@nginx.com>
parents:
8782
diff
changeset
|
1492 } |
60c6e8d8d3ae
QUIC: make sure stream data size is lower than final size.
Roman Arutyunyan <arut@nginx.com>
parents:
8782
diff
changeset
|
1493 |
9010 | 1494 qs->recv_final_size = f->final_size; |
8782
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8779
diff
changeset
|
1495 |
9010 | 1496 if (ngx_quic_update_flow(qs, qs->recv_final_size) != NGX_OK) { |
8791
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
1497 return NGX_ERROR; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
1498 } |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1499 |
9010 | 1500 if (qs->connection == NULL) { |
1501 return ngx_quic_close_stream(qs); | |
1502 } | |
1503 | |
9065
2ee6f9729739
QUIC: set stream error flag on reset.
Roman Arutyunyan <arut@nginx.com>
parents:
9064
diff
changeset
|
1504 rev = qs->connection->read; |
2ee6f9729739
QUIC: set stream error flag on reset.
Roman Arutyunyan <arut@nginx.com>
parents:
9064
diff
changeset
|
1505 rev->error = 1; |
2ee6f9729739
QUIC: set stream error flag on reset.
Roman Arutyunyan <arut@nginx.com>
parents:
9064
diff
changeset
|
1506 |
2ee6f9729739
QUIC: set stream error flag on reset.
Roman Arutyunyan <arut@nginx.com>
parents:
9064
diff
changeset
|
1507 ngx_quic_set_event(rev); |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1508 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1509 return NGX_OK; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1510 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1511 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1512 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1513 ngx_int_t |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1514 ngx_quic_handle_stop_sending_frame(ngx_connection_t *c, |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1515 ngx_quic_header_t *pkt, ngx_quic_stop_sending_frame_t *f) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1516 { |
8761
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8760
diff
changeset
|
1517 ngx_quic_stream_t *qs; |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1518 ngx_quic_connection_t *qc; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1519 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1520 qc = ngx_quic_get_connection(c); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1521 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1522 if ((f->id & NGX_QUIC_STREAM_UNIDIRECTIONAL) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1523 && (f->id & NGX_QUIC_STREAM_SERVER_INITIATED) == 0) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1524 { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1525 qc->error = NGX_QUIC_ERR_STREAM_STATE_ERROR; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1526 return NGX_ERROR; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1527 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1528 |
8937
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8936
diff
changeset
|
1529 qs = ngx_quic_get_stream(c, f->id); |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1530 |
8761
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8760
diff
changeset
|
1531 if (qs == NULL) { |
8937
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8936
diff
changeset
|
1532 return NGX_ERROR; |
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8936
diff
changeset
|
1533 } |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1534 |
8937
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8936
diff
changeset
|
1535 if (qs == NGX_QUIC_STREAM_GONE) { |
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8936
diff
changeset
|
1536 return NGX_OK; |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1537 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1538 |
9010 | 1539 if (ngx_quic_do_reset_stream(qs, f->error_code) != NGX_OK) { |
8876
1ead7d64e993
QUIC: send RESET_STREAM in response to STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8875
diff
changeset
|
1540 return NGX_ERROR; |
1ead7d64e993
QUIC: send RESET_STREAM in response to STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8875
diff
changeset
|
1541 } |
1ead7d64e993
QUIC: send RESET_STREAM in response to STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8875
diff
changeset
|
1542 |
9010 | 1543 if (qs->connection == NULL) { |
1544 return ngx_quic_close_stream(qs); | |
1545 } | |
1546 | |
8993
7626aa7a2156
QUIC: stream event setting function.
Roman Arutyunyan <arut@nginx.com>
parents:
8990
diff
changeset
|
1547 ngx_quic_set_event(qs->connection->write); |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1548 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1549 return NGX_OK; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1550 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1551 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1552 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1553 ngx_int_t |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1554 ngx_quic_handle_max_streams_frame(ngx_connection_t *c, |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1555 ngx_quic_header_t *pkt, ngx_quic_max_streams_frame_t *f) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1556 { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1557 ngx_quic_connection_t *qc; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1558 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1559 qc = ngx_quic_get_connection(c); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1560 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1561 if (f->bidi) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1562 if (qc->streams.server_max_streams_bidi < f->limit) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1563 qc->streams.server_max_streams_bidi = f->limit; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1564 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1565 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1566 "quic max_streams_bidi:%uL", f->limit); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1567 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1568 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1569 } else { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1570 if (qc->streams.server_max_streams_uni < f->limit) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1571 qc->streams.server_max_streams_uni = f->limit; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1572 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1573 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1574 "quic max_streams_uni:%uL", f->limit); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1575 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1576 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1577 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1578 return NGX_OK; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1579 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1580 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1581 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1582 void |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1583 ngx_quic_handle_stream_ack(ngx_connection_t *c, ngx_quic_frame_t *f) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1584 { |
9052
2e51cf3ffd90
QUIC: defer stream removal until all its data is acked.
Roman Arutyunyan <arut@nginx.com>
parents:
9051
diff
changeset
|
1585 uint64_t acked; |
8761
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8760
diff
changeset
|
1586 ngx_quic_stream_t *qs; |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1587 ngx_quic_connection_t *qc; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1588 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1589 qc = ngx_quic_get_connection(c); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1590 |
9052
2e51cf3ffd90
QUIC: defer stream removal until all its data is acked.
Roman Arutyunyan <arut@nginx.com>
parents:
9051
diff
changeset
|
1591 switch (f->type) { |
2e51cf3ffd90
QUIC: defer stream removal until all its data is acked.
Roman Arutyunyan <arut@nginx.com>
parents:
9051
diff
changeset
|
1592 |
2e51cf3ffd90
QUIC: defer stream removal until all its data is acked.
Roman Arutyunyan <arut@nginx.com>
parents:
9051
diff
changeset
|
1593 case NGX_QUIC_FT_RESET_STREAM: |
2e51cf3ffd90
QUIC: defer stream removal until all its data is acked.
Roman Arutyunyan <arut@nginx.com>
parents:
9051
diff
changeset
|
1594 |
2e51cf3ffd90
QUIC: defer stream removal until all its data is acked.
Roman Arutyunyan <arut@nginx.com>
parents:
9051
diff
changeset
|
1595 qs = ngx_quic_find_stream(&qc->streams.tree, f->u.reset_stream.id); |
2e51cf3ffd90
QUIC: defer stream removal until all its data is acked.
Roman Arutyunyan <arut@nginx.com>
parents:
9051
diff
changeset
|
1596 if (qs == NULL) { |
2e51cf3ffd90
QUIC: defer stream removal until all its data is acked.
Roman Arutyunyan <arut@nginx.com>
parents:
9051
diff
changeset
|
1597 return; |
2e51cf3ffd90
QUIC: defer stream removal until all its data is acked.
Roman Arutyunyan <arut@nginx.com>
parents:
9051
diff
changeset
|
1598 } |
2e51cf3ffd90
QUIC: defer stream removal until all its data is acked.
Roman Arutyunyan <arut@nginx.com>
parents:
9051
diff
changeset
|
1599 |
2e51cf3ffd90
QUIC: defer stream removal until all its data is acked.
Roman Arutyunyan <arut@nginx.com>
parents:
9051
diff
changeset
|
1600 qs->send_state = NGX_QUIC_STREAM_SEND_RESET_RECVD; |
2e51cf3ffd90
QUIC: defer stream removal until all its data is acked.
Roman Arutyunyan <arut@nginx.com>
parents:
9051
diff
changeset
|
1601 |
2e51cf3ffd90
QUIC: defer stream removal until all its data is acked.
Roman Arutyunyan <arut@nginx.com>
parents:
9051
diff
changeset
|
1602 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0, |
2e51cf3ffd90
QUIC: defer stream removal until all its data is acked.
Roman Arutyunyan <arut@nginx.com>
parents:
9051
diff
changeset
|
1603 "quic stream id:0x%xL ack reset final_size:%uL", |
2e51cf3ffd90
QUIC: defer stream removal until all its data is acked.
Roman Arutyunyan <arut@nginx.com>
parents:
9051
diff
changeset
|
1604 qs->id, f->u.reset_stream.final_size); |
2e51cf3ffd90
QUIC: defer stream removal until all its data is acked.
Roman Arutyunyan <arut@nginx.com>
parents:
9051
diff
changeset
|
1605 |
2e51cf3ffd90
QUIC: defer stream removal until all its data is acked.
Roman Arutyunyan <arut@nginx.com>
parents:
9051
diff
changeset
|
1606 break; |
2e51cf3ffd90
QUIC: defer stream removal until all its data is acked.
Roman Arutyunyan <arut@nginx.com>
parents:
9051
diff
changeset
|
1607 |
2e51cf3ffd90
QUIC: defer stream removal until all its data is acked.
Roman Arutyunyan <arut@nginx.com>
parents:
9051
diff
changeset
|
1608 case NGX_QUIC_FT_STREAM: |
2e51cf3ffd90
QUIC: defer stream removal until all its data is acked.
Roman Arutyunyan <arut@nginx.com>
parents:
9051
diff
changeset
|
1609 |
2e51cf3ffd90
QUIC: defer stream removal until all its data is acked.
Roman Arutyunyan <arut@nginx.com>
parents:
9051
diff
changeset
|
1610 qs = ngx_quic_find_stream(&qc->streams.tree, f->u.stream.stream_id); |
2e51cf3ffd90
QUIC: defer stream removal until all its data is acked.
Roman Arutyunyan <arut@nginx.com>
parents:
9051
diff
changeset
|
1611 if (qs == NULL) { |
2e51cf3ffd90
QUIC: defer stream removal until all its data is acked.
Roman Arutyunyan <arut@nginx.com>
parents:
9051
diff
changeset
|
1612 return; |
2e51cf3ffd90
QUIC: defer stream removal until all its data is acked.
Roman Arutyunyan <arut@nginx.com>
parents:
9051
diff
changeset
|
1613 } |
2e51cf3ffd90
QUIC: defer stream removal until all its data is acked.
Roman Arutyunyan <arut@nginx.com>
parents:
9051
diff
changeset
|
1614 |
2e51cf3ffd90
QUIC: defer stream removal until all its data is acked.
Roman Arutyunyan <arut@nginx.com>
parents:
9051
diff
changeset
|
1615 acked = qs->acked; |
2e51cf3ffd90
QUIC: defer stream removal until all its data is acked.
Roman Arutyunyan <arut@nginx.com>
parents:
9051
diff
changeset
|
1616 qs->acked += f->u.stream.length; |
2e51cf3ffd90
QUIC: defer stream removal until all its data is acked.
Roman Arutyunyan <arut@nginx.com>
parents:
9051
diff
changeset
|
1617 |
2e51cf3ffd90
QUIC: defer stream removal until all its data is acked.
Roman Arutyunyan <arut@nginx.com>
parents:
9051
diff
changeset
|
1618 if (f->u.stream.fin) { |
2e51cf3ffd90
QUIC: defer stream removal until all its data is acked.
Roman Arutyunyan <arut@nginx.com>
parents:
9051
diff
changeset
|
1619 qs->fin_acked = 1; |
2e51cf3ffd90
QUIC: defer stream removal until all its data is acked.
Roman Arutyunyan <arut@nginx.com>
parents:
9051
diff
changeset
|
1620 } |
2e51cf3ffd90
QUIC: defer stream removal until all its data is acked.
Roman Arutyunyan <arut@nginx.com>
parents:
9051
diff
changeset
|
1621 |
2e51cf3ffd90
QUIC: defer stream removal until all its data is acked.
Roman Arutyunyan <arut@nginx.com>
parents:
9051
diff
changeset
|
1622 if (qs->send_state == NGX_QUIC_STREAM_SEND_DATA_SENT |
2e51cf3ffd90
QUIC: defer stream removal until all its data is acked.
Roman Arutyunyan <arut@nginx.com>
parents:
9051
diff
changeset
|
1623 && qs->acked == qs->sent && qs->fin_acked) |
2e51cf3ffd90
QUIC: defer stream removal until all its data is acked.
Roman Arutyunyan <arut@nginx.com>
parents:
9051
diff
changeset
|
1624 { |
2e51cf3ffd90
QUIC: defer stream removal until all its data is acked.
Roman Arutyunyan <arut@nginx.com>
parents:
9051
diff
changeset
|
1625 qs->send_state = NGX_QUIC_STREAM_SEND_DATA_RECVD; |
2e51cf3ffd90
QUIC: defer stream removal until all its data is acked.
Roman Arutyunyan <arut@nginx.com>
parents:
9051
diff
changeset
|
1626 } |
2e51cf3ffd90
QUIC: defer stream removal until all its data is acked.
Roman Arutyunyan <arut@nginx.com>
parents:
9051
diff
changeset
|
1627 |
2e51cf3ffd90
QUIC: defer stream removal until all its data is acked.
Roman Arutyunyan <arut@nginx.com>
parents:
9051
diff
changeset
|
1628 ngx_log_debug4(NGX_LOG_DEBUG_EVENT, c->log, 0, |
2e51cf3ffd90
QUIC: defer stream removal until all its data is acked.
Roman Arutyunyan <arut@nginx.com>
parents:
9051
diff
changeset
|
1629 "quic stream id:0x%xL ack len:%uL fin:%d unacked:%uL", |
2e51cf3ffd90
QUIC: defer stream removal until all its data is acked.
Roman Arutyunyan <arut@nginx.com>
parents:
9051
diff
changeset
|
1630 qs->id, f->u.stream.length, f->u.stream.fin, |
2e51cf3ffd90
QUIC: defer stream removal until all its data is acked.
Roman Arutyunyan <arut@nginx.com>
parents:
9051
diff
changeset
|
1631 qs->sent - qs->acked); |
2e51cf3ffd90
QUIC: defer stream removal until all its data is acked.
Roman Arutyunyan <arut@nginx.com>
parents:
9051
diff
changeset
|
1632 |
2e51cf3ffd90
QUIC: defer stream removal until all its data is acked.
Roman Arutyunyan <arut@nginx.com>
parents:
9051
diff
changeset
|
1633 if (qs->connection |
2e51cf3ffd90
QUIC: defer stream removal until all its data is acked.
Roman Arutyunyan <arut@nginx.com>
parents:
9051
diff
changeset
|
1634 && qs->sent - acked == qc->conf->stream_buffer_size |
2e51cf3ffd90
QUIC: defer stream removal until all its data is acked.
Roman Arutyunyan <arut@nginx.com>
parents:
9051
diff
changeset
|
1635 && f->u.stream.length > 0) |
2e51cf3ffd90
QUIC: defer stream removal until all its data is acked.
Roman Arutyunyan <arut@nginx.com>
parents:
9051
diff
changeset
|
1636 { |
2e51cf3ffd90
QUIC: defer stream removal until all its data is acked.
Roman Arutyunyan <arut@nginx.com>
parents:
9051
diff
changeset
|
1637 ngx_quic_set_event(qs->connection->write); |
2e51cf3ffd90
QUIC: defer stream removal until all its data is acked.
Roman Arutyunyan <arut@nginx.com>
parents:
9051
diff
changeset
|
1638 } |
2e51cf3ffd90
QUIC: defer stream removal until all its data is acked.
Roman Arutyunyan <arut@nginx.com>
parents:
9051
diff
changeset
|
1639 |
2e51cf3ffd90
QUIC: defer stream removal until all its data is acked.
Roman Arutyunyan <arut@nginx.com>
parents:
9051
diff
changeset
|
1640 break; |
2e51cf3ffd90
QUIC: defer stream removal until all its data is acked.
Roman Arutyunyan <arut@nginx.com>
parents:
9051
diff
changeset
|
1641 |
2e51cf3ffd90
QUIC: defer stream removal until all its data is acked.
Roman Arutyunyan <arut@nginx.com>
parents:
9051
diff
changeset
|
1642 default: |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1643 return; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1644 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1645 |
9010 | 1646 if (qs->connection == NULL) { |
9052
2e51cf3ffd90
QUIC: defer stream removal until all its data is acked.
Roman Arutyunyan <arut@nginx.com>
parents:
9051
diff
changeset
|
1647 ngx_quic_close_stream(qs); |
9010 | 1648 } |
8750
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1649 } |
8791
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
1650 |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
1651 |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
1652 static ngx_int_t |
9010 | 1653 ngx_quic_control_flow(ngx_quic_stream_t *qs, uint64_t last) |
8791
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
1654 { |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
1655 uint64_t len; |
9010 | 1656 ngx_connection_t *pc; |
8791
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
1657 ngx_quic_connection_t *qc; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
1658 |
9010 | 1659 pc = qs->parent; |
1660 qc = ngx_quic_get_connection(pc); | |
8791
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
1661 |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
1662 if (last <= qs->recv_last) { |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
1663 return NGX_OK; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
1664 } |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
1665 |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
1666 len = last - qs->recv_last; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
1667 |
9010 | 1668 ngx_log_debug5(NGX_LOG_DEBUG_EVENT, pc->log, 0, |
1669 "quic stream id:0x%xL flow control msd:%uL/%uL md:%uL/%uL", | |
1670 qs->id, last, qs->recv_max_data, qc->streams.recv_last + len, | |
8791
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
1671 qc->streams.recv_max_data); |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
1672 |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
1673 qs->recv_last += len; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
1674 |
8990
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8988
diff
changeset
|
1675 if (qs->recv_state == NGX_QUIC_STREAM_RECV_RECV |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8988
diff
changeset
|
1676 && qs->recv_last > qs->recv_max_data) |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8988
diff
changeset
|
1677 { |
8791
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
1678 qc->error = NGX_QUIC_ERR_FLOW_CONTROL_ERROR; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
1679 return NGX_ERROR; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
1680 } |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
1681 |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
1682 qc->streams.recv_last += len; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
1683 |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
1684 if (qc->streams.recv_last > qc->streams.recv_max_data) { |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
1685 qc->error = NGX_QUIC_ERR_FLOW_CONTROL_ERROR; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
1686 return NGX_ERROR; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
1687 } |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
1688 |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
1689 return NGX_OK; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
1690 } |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
1691 |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
1692 |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
1693 static ngx_int_t |
9010 | 1694 ngx_quic_update_flow(ngx_quic_stream_t *qs, uint64_t last) |
8791
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
1695 { |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
1696 uint64_t len; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
1697 ngx_connection_t *pc; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
1698 ngx_quic_connection_t *qc; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
1699 |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
1700 pc = qs->parent; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
1701 qc = ngx_quic_get_connection(pc); |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
1702 |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
1703 if (last <= qs->recv_offset) { |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
1704 return NGX_OK; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
1705 } |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
1706 |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
1707 len = last - qs->recv_offset; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
1708 |
9010 | 1709 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, pc->log, 0, |
1710 "quic stream id:0x%xL flow update %uL", qs->id, last); | |
8791
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
1711 |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
1712 qs->recv_offset += len; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
1713 |
8990
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8988
diff
changeset
|
1714 if (qs->recv_max_data <= qs->recv_offset + qs->recv_window / 2) { |
9010 | 1715 if (ngx_quic_update_max_stream_data(qs) != NGX_OK) { |
8791
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
1716 return NGX_ERROR; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
1717 } |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
1718 } |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
1719 |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
1720 qc->streams.recv_offset += len; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
1721 |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
1722 if (qc->streams.recv_max_data |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
1723 <= qc->streams.recv_offset + qc->streams.recv_window / 2) |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
1724 { |
8909
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8908
diff
changeset
|
1725 if (ngx_quic_update_max_data(pc) != NGX_OK) { |
8791
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
1726 return NGX_ERROR; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
1727 } |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
1728 } |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
1729 |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
1730 return NGX_OK; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8784
diff
changeset
|
1731 } |
8855
9ae239d2547d
QUIC: separate event handling functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8842
diff
changeset
|
1732 |
9ae239d2547d
QUIC: separate event handling functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8842
diff
changeset
|
1733 |
8908
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8906
diff
changeset
|
1734 static ngx_int_t |
9010 | 1735 ngx_quic_update_max_stream_data(ngx_quic_stream_t *qs) |
8908
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8906
diff
changeset
|
1736 { |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8906
diff
changeset
|
1737 uint64_t recv_max_data; |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8906
diff
changeset
|
1738 ngx_connection_t *pc; |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8906
diff
changeset
|
1739 ngx_quic_frame_t *frame; |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8906
diff
changeset
|
1740 ngx_quic_connection_t *qc; |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8906
diff
changeset
|
1741 |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8906
diff
changeset
|
1742 pc = qs->parent; |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8906
diff
changeset
|
1743 qc = ngx_quic_get_connection(pc); |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8906
diff
changeset
|
1744 |
8990
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8988
diff
changeset
|
1745 if (qs->recv_state != NGX_QUIC_STREAM_RECV_RECV) { |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8988
diff
changeset
|
1746 return NGX_OK; |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8988
diff
changeset
|
1747 } |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8988
diff
changeset
|
1748 |
8908
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8906
diff
changeset
|
1749 recv_max_data = qs->recv_offset + qs->recv_window; |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8906
diff
changeset
|
1750 |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8906
diff
changeset
|
1751 if (qs->recv_max_data == recv_max_data) { |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8906
diff
changeset
|
1752 return NGX_OK; |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8906
diff
changeset
|
1753 } |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8906
diff
changeset
|
1754 |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8906
diff
changeset
|
1755 qs->recv_max_data = recv_max_data; |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8906
diff
changeset
|
1756 |
9010 | 1757 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, pc->log, 0, |
1758 "quic stream id:0x%xL flow update msd:%uL", | |
1759 qs->id, qs->recv_max_data); | |
8908
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8906
diff
changeset
|
1760 |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8906
diff
changeset
|
1761 frame = ngx_quic_alloc_frame(pc); |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8906
diff
changeset
|
1762 if (frame == NULL) { |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8906
diff
changeset
|
1763 return NGX_ERROR; |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8906
diff
changeset
|
1764 } |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8906
diff
changeset
|
1765 |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8906
diff
changeset
|
1766 frame->level = ssl_encryption_application; |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8906
diff
changeset
|
1767 frame->type = NGX_QUIC_FT_MAX_STREAM_DATA; |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8906
diff
changeset
|
1768 frame->u.max_stream_data.id = qs->id; |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8906
diff
changeset
|
1769 frame->u.max_stream_data.limit = qs->recv_max_data; |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8906
diff
changeset
|
1770 |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8906
diff
changeset
|
1771 ngx_quic_queue_frame(qc, frame); |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8906
diff
changeset
|
1772 |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8906
diff
changeset
|
1773 return NGX_OK; |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8906
diff
changeset
|
1774 } |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8906
diff
changeset
|
1775 |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8906
diff
changeset
|
1776 |
8909
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8908
diff
changeset
|
1777 static ngx_int_t |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8908
diff
changeset
|
1778 ngx_quic_update_max_data(ngx_connection_t *c) |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8908
diff
changeset
|
1779 { |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8908
diff
changeset
|
1780 uint64_t recv_max_data; |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8908
diff
changeset
|
1781 ngx_quic_frame_t *frame; |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8908
diff
changeset
|
1782 ngx_quic_connection_t *qc; |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8908
diff
changeset
|
1783 |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8908
diff
changeset
|
1784 qc = ngx_quic_get_connection(c); |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8908
diff
changeset
|
1785 |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8908
diff
changeset
|
1786 recv_max_data = qc->streams.recv_offset + qc->streams.recv_window; |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8908
diff
changeset
|
1787 |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8908
diff
changeset
|
1788 if (qc->streams.recv_max_data == recv_max_data) { |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8908
diff
changeset
|
1789 return NGX_OK; |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8908
diff
changeset
|
1790 } |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8908
diff
changeset
|
1791 |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8908
diff
changeset
|
1792 qc->streams.recv_max_data = recv_max_data; |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8908
diff
changeset
|
1793 |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8908
diff
changeset
|
1794 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8908
diff
changeset
|
1795 "quic flow update md:%uL", qc->streams.recv_max_data); |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8908
diff
changeset
|
1796 |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8908
diff
changeset
|
1797 frame = ngx_quic_alloc_frame(c); |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8908
diff
changeset
|
1798 if (frame == NULL) { |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8908
diff
changeset
|
1799 return NGX_ERROR; |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8908
diff
changeset
|
1800 } |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8908
diff
changeset
|
1801 |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8908
diff
changeset
|
1802 frame->level = ssl_encryption_application; |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8908
diff
changeset
|
1803 frame->type = NGX_QUIC_FT_MAX_DATA; |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8908
diff
changeset
|
1804 frame->u.max_data.max_data = qc->streams.recv_max_data; |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8908
diff
changeset
|
1805 |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8908
diff
changeset
|
1806 ngx_quic_queue_frame(qc, frame); |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8908
diff
changeset
|
1807 |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8908
diff
changeset
|
1808 return NGX_OK; |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8908
diff
changeset
|
1809 } |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8908
diff
changeset
|
1810 |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8908
diff
changeset
|
1811 |
8993
7626aa7a2156
QUIC: stream event setting function.
Roman Arutyunyan <arut@nginx.com>
parents:
8990
diff
changeset
|
1812 static void |
7626aa7a2156
QUIC: stream event setting function.
Roman Arutyunyan <arut@nginx.com>
parents:
8990
diff
changeset
|
1813 ngx_quic_set_event(ngx_event_t *ev) |
7626aa7a2156
QUIC: stream event setting function.
Roman Arutyunyan <arut@nginx.com>
parents:
8990
diff
changeset
|
1814 { |
7626aa7a2156
QUIC: stream event setting function.
Roman Arutyunyan <arut@nginx.com>
parents:
8990
diff
changeset
|
1815 ev->ready = 1; |
7626aa7a2156
QUIC: stream event setting function.
Roman Arutyunyan <arut@nginx.com>
parents:
8990
diff
changeset
|
1816 |
7626aa7a2156
QUIC: stream event setting function.
Roman Arutyunyan <arut@nginx.com>
parents:
8990
diff
changeset
|
1817 if (ev->active) { |
7626aa7a2156
QUIC: stream event setting function.
Roman Arutyunyan <arut@nginx.com>
parents:
8990
diff
changeset
|
1818 ngx_post_event(ev, &ngx_posted_events); |
7626aa7a2156
QUIC: stream event setting function.
Roman Arutyunyan <arut@nginx.com>
parents:
8990
diff
changeset
|
1819 } |
7626aa7a2156
QUIC: stream event setting function.
Roman Arutyunyan <arut@nginx.com>
parents:
8990
diff
changeset
|
1820 } |