Mercurial > hg > nginx-quic
annotate src/event/quic/ngx_event_quic_streams.c @ 8717:e06283038ec8 quic
QUIC: clear SSL_OP_ENABLE_MIDDLEBOX_COMPAT on SSL context switch.
The SSL_OP_ENABLE_MIDDLEBOX_COMPAT option is provided by QuicTLS and enabled
by default in the newly created SSL contexts. SSL_set_quic_method() is used
to clear it, which is required for SSL handshake to work on QUIC connections.
Switching context in the ngx_http_ssl_servername() SNI callback overrides SSL
options from the new SSL context. This results in the option set again.
Fix is to explicitly clear it when switching to another SSL context.
Initially reported here (in Russian):
http://mailman.nginx.org/pipermail/nginx-ru/2021-November/063989.html
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Tue, 07 Dec 2021 15:49:51 +0300 |
parents | d6ef13c5fd8e |
children | 86f5a738ac2a |
rev | line source |
---|---|
8410
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 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
16 static ngx_quic_stream_t *ngx_quic_create_client_stream(ngx_connection_t *c, |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
17 uint64_t id); |
8695
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
18 static ngx_int_t ngx_quic_reject_stream(ngx_connection_t *c, uint64_t id); |
8552
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
19 static ngx_int_t ngx_quic_init_stream(ngx_quic_stream_t *qs); |
8648
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8638
diff
changeset
|
20 static void ngx_quic_init_streams_handler(ngx_connection_t *c); |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
21 static ngx_quic_stream_t *ngx_quic_create_stream(ngx_connection_t *c, |
8439
f52a2b77d406
QUIC: generic buffering for stream input.
Roman Arutyunyan <arut@nginx.com>
parents:
8421
diff
changeset
|
22 uint64_t id); |
8552
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
23 static void ngx_quic_empty_handler(ngx_event_t *ev); |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
24 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
|
25 size_t size); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
26 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
|
27 size_t size); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
28 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
|
29 ngx_chain_t *in, off_t limit); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
30 static size_t ngx_quic_max_stream_flow(ngx_connection_t *c); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
31 static void ngx_quic_stream_cleanup_handler(void *data); |
8492
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
32 static ngx_int_t ngx_quic_control_flow(ngx_connection_t *c, uint64_t last); |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
33 static ngx_int_t ngx_quic_update_flow(ngx_connection_t *c, uint64_t last); |
8697
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8695
diff
changeset
|
34 static ngx_int_t ngx_quic_update_max_stream_data(ngx_connection_t *c); |
8698
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
35 static ngx_int_t ngx_quic_update_max_data(ngx_connection_t *c); |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
36 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
37 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
38 ngx_connection_t * |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
39 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
|
40 { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
41 uint64_t id; |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
42 ngx_quic_stream_t *qs, *nqs; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
43 ngx_quic_connection_t *qc; |
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 qs = c->quic; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
46 qc = ngx_quic_get_connection(qs->parent); |
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 if (bidi) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
49 if (qc->streams.server_streams_bidi |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
50 >= qc->streams.server_max_streams_bidi) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
51 { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
52 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
|
53 "quic too many server bidi streams:%uL", |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
54 qc->streams.server_streams_bidi); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
55 return NULL; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
56 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
57 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
58 id = (qc->streams.server_streams_bidi << 2) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
59 | NGX_QUIC_STREAM_SERVER_INITIATED; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
60 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
61 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
|
62 "quic creating server bidi stream" |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
63 " streams:%uL max:%uL id:0x%xL", |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
64 qc->streams.server_streams_bidi, |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
65 qc->streams.server_max_streams_bidi, id); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
66 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
67 qc->streams.server_streams_bidi++; |
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 } else { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
70 if (qc->streams.server_streams_uni |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
71 >= qc->streams.server_max_streams_uni) |
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_debug1(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 too many server uni streams:%uL", |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
75 qc->streams.server_streams_uni); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
76 return NULL; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
77 } |
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 id = (qc->streams.server_streams_uni << 2) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
80 | NGX_QUIC_STREAM_SERVER_INITIATED |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
81 | NGX_QUIC_STREAM_UNIDIRECTIONAL; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
82 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
83 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
|
84 "quic creating server uni stream" |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
85 " streams:%uL max:%uL id:0x%xL", |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
86 qc->streams.server_streams_uni, |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
87 qc->streams.server_max_streams_uni, id); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
88 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
89 qc->streams.server_streams_uni++; |
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 |
8439
f52a2b77d406
QUIC: generic buffering for stream input.
Roman Arutyunyan <arut@nginx.com>
parents:
8421
diff
changeset
|
92 nqs = ngx_quic_create_stream(qs->parent, id); |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
93 if (nqs == NULL) { |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
94 return NULL; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
95 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
96 |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
97 return nqs->connection; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
98 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
99 |
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 void |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
102 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
|
103 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
|
104 { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
105 ngx_rbtree_node_t **p; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
106 ngx_quic_stream_t *qn, *qnt; |
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 for ( ;; ) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
109 qn = (ngx_quic_stream_t *) node; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
110 qnt = (ngx_quic_stream_t *) temp; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
111 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
112 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
|
113 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
114 if (*p == sentinel) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
115 break; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
116 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
117 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
118 temp = *p; |
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 *p = node; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
122 node->parent = temp; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
123 node->left = sentinel; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
124 node->right = sentinel; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
125 ngx_rbt_red(node); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
126 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
127 |
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 ngx_quic_stream_t * |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
130 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
|
131 { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
132 ngx_rbtree_node_t *node, *sentinel; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
133 ngx_quic_stream_t *qn; |
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 node = rbtree->root; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
136 sentinel = rbtree->sentinel; |
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 while (node != sentinel) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
139 qn = (ngx_quic_stream_t *) node; |
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 if (id == qn->id) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
142 return qn; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
143 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
144 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
145 node = (id < qn->id) ? node->left : node->right; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
146 } |
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 return NULL; |
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 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
151 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
152 ngx_int_t |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
153 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
|
154 { |
8552
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
155 ngx_pool_t *pool; |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
156 ngx_queue_t *q; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
157 ngx_event_t *rev, *wev; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
158 ngx_rbtree_t *tree; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
159 ngx_rbtree_node_t *node; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
160 ngx_quic_stream_t *qs; |
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 (NGX_DEBUG) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
163 ngx_uint_t ns; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
164 #endif |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
165 |
8552
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
166 while (!ngx_queue_empty(&qc->streams.uninitialized)) { |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
167 q = ngx_queue_head(&qc->streams.uninitialized); |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
168 ngx_queue_remove(q); |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
169 |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
170 qs = ngx_queue_data(q, ngx_quic_stream_t, queue); |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
171 pool = qs->connection->pool; |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
172 |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
173 ngx_close_connection(qs->connection); |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
174 ngx_destroy_pool(pool); |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
175 } |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
176 |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
177 tree = &qc->streams.tree; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
178 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
179 if (tree->root == tree->sentinel) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
180 return NGX_OK; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
181 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
182 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
183 #if (NGX_DEBUG) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
184 ns = 0; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
185 #endif |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
186 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
187 for (node = ngx_rbtree_min(tree->root, tree->sentinel); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
188 node; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
189 node = ngx_rbtree_next(tree, node)) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
190 { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
191 qs = (ngx_quic_stream_t *) node; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
192 |
8420
baf9551b4a5b
QUIC: renamed stream field from c to connection.
Roman Arutyunyan <arut@nginx.com>
parents:
8416
diff
changeset
|
193 rev = qs->connection->read; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
194 rev->error = 1; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
195 rev->ready = 1; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
196 |
8420
baf9551b4a5b
QUIC: renamed stream field from c to connection.
Roman Arutyunyan <arut@nginx.com>
parents:
8416
diff
changeset
|
197 wev = qs->connection->write; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
198 wev->error = 1; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
199 wev->ready = 1; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
200 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
201 ngx_post_event(rev, &ngx_posted_events); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
202 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
203 if (rev->timer_set) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
204 ngx_del_timer(rev); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
205 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
206 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
207 #if (NGX_DEBUG) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
208 ns++; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
209 #endif |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
210 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
211 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
212 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
|
213 "quic connection has %ui active streams", ns); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
214 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
215 return NGX_AGAIN; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
216 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
217 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
218 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
219 ngx_int_t |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
220 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
|
221 { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
222 ngx_event_t *wev; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
223 ngx_connection_t *pc; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
224 ngx_quic_frame_t *frame; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
225 ngx_quic_stream_t *qs; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
226 ngx_quic_connection_t *qc; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
227 |
8637
13cb758e6ac0
QUIC: reset stream only once.
Roman Arutyunyan <arut@nginx.com>
parents:
8623
diff
changeset
|
228 wev = c->write; |
13cb758e6ac0
QUIC: reset stream only once.
Roman Arutyunyan <arut@nginx.com>
parents:
8623
diff
changeset
|
229 |
13cb758e6ac0
QUIC: reset stream only once.
Roman Arutyunyan <arut@nginx.com>
parents:
8623
diff
changeset
|
230 if (wev->error) { |
13cb758e6ac0
QUIC: reset stream only once.
Roman Arutyunyan <arut@nginx.com>
parents:
8623
diff
changeset
|
231 return NGX_OK; |
13cb758e6ac0
QUIC: reset stream only once.
Roman Arutyunyan <arut@nginx.com>
parents:
8623
diff
changeset
|
232 } |
13cb758e6ac0
QUIC: reset stream only once.
Roman Arutyunyan <arut@nginx.com>
parents:
8623
diff
changeset
|
233 |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
234 qs = c->quic; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
235 pc = qs->parent; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
236 qc = ngx_quic_get_connection(pc); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
237 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
238 frame = ngx_quic_alloc_frame(pc); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
239 if (frame == NULL) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
240 return NGX_ERROR; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
241 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
242 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
243 frame->level = ssl_encryption_application; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
244 frame->type = NGX_QUIC_FT_RESET_STREAM; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
245 frame->u.reset_stream.id = qs->id; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
246 frame->u.reset_stream.error_code = err; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
247 frame->u.reset_stream.final_size = c->sent; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
248 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
249 ngx_quic_queue_frame(qc, frame); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
250 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
251 wev->error = 1; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
252 wev->ready = 1; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
253 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
254 return NGX_OK; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
255 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
256 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
257 |
8679
b4c7853b0488
QUIC: added shutdown support in stream proxy.
Vladimir Homutov <vl@nginx.com>
parents:
8648
diff
changeset
|
258 ngx_int_t |
b4c7853b0488
QUIC: added shutdown support in stream proxy.
Vladimir Homutov <vl@nginx.com>
parents:
8648
diff
changeset
|
259 ngx_quic_shutdown_stream(ngx_connection_t *c, int how) |
b4c7853b0488
QUIC: added shutdown support in stream proxy.
Vladimir Homutov <vl@nginx.com>
parents:
8648
diff
changeset
|
260 { |
b4c7853b0488
QUIC: added shutdown support in stream proxy.
Vladimir Homutov <vl@nginx.com>
parents:
8648
diff
changeset
|
261 ngx_event_t *wev; |
b4c7853b0488
QUIC: added shutdown support in stream proxy.
Vladimir Homutov <vl@nginx.com>
parents:
8648
diff
changeset
|
262 ngx_connection_t *pc; |
b4c7853b0488
QUIC: added shutdown support in stream proxy.
Vladimir Homutov <vl@nginx.com>
parents:
8648
diff
changeset
|
263 ngx_quic_frame_t *frame; |
b4c7853b0488
QUIC: added shutdown support in stream proxy.
Vladimir Homutov <vl@nginx.com>
parents:
8648
diff
changeset
|
264 ngx_quic_stream_t *qs; |
b4c7853b0488
QUIC: added shutdown support in stream proxy.
Vladimir Homutov <vl@nginx.com>
parents:
8648
diff
changeset
|
265 ngx_quic_connection_t *qc; |
b4c7853b0488
QUIC: added shutdown support in stream proxy.
Vladimir Homutov <vl@nginx.com>
parents:
8648
diff
changeset
|
266 |
b4c7853b0488
QUIC: added shutdown support in stream proxy.
Vladimir Homutov <vl@nginx.com>
parents:
8648
diff
changeset
|
267 if (how != NGX_WRITE_SHUTDOWN) { |
b4c7853b0488
QUIC: added shutdown support in stream proxy.
Vladimir Homutov <vl@nginx.com>
parents:
8648
diff
changeset
|
268 return NGX_OK; |
b4c7853b0488
QUIC: added shutdown support in stream proxy.
Vladimir Homutov <vl@nginx.com>
parents:
8648
diff
changeset
|
269 } |
b4c7853b0488
QUIC: added shutdown support in stream proxy.
Vladimir Homutov <vl@nginx.com>
parents:
8648
diff
changeset
|
270 |
b4c7853b0488
QUIC: added shutdown support in stream proxy.
Vladimir Homutov <vl@nginx.com>
parents:
8648
diff
changeset
|
271 wev = c->write; |
b4c7853b0488
QUIC: added shutdown support in stream proxy.
Vladimir Homutov <vl@nginx.com>
parents:
8648
diff
changeset
|
272 |
b4c7853b0488
QUIC: added shutdown support in stream proxy.
Vladimir Homutov <vl@nginx.com>
parents:
8648
diff
changeset
|
273 if (wev->error) { |
b4c7853b0488
QUIC: added shutdown support in stream proxy.
Vladimir Homutov <vl@nginx.com>
parents:
8648
diff
changeset
|
274 return NGX_OK; |
b4c7853b0488
QUIC: added shutdown support in stream proxy.
Vladimir Homutov <vl@nginx.com>
parents:
8648
diff
changeset
|
275 } |
b4c7853b0488
QUIC: added shutdown support in stream proxy.
Vladimir Homutov <vl@nginx.com>
parents:
8648
diff
changeset
|
276 |
b4c7853b0488
QUIC: added shutdown support in stream proxy.
Vladimir Homutov <vl@nginx.com>
parents:
8648
diff
changeset
|
277 qs = c->quic; |
b4c7853b0488
QUIC: added shutdown support in stream proxy.
Vladimir Homutov <vl@nginx.com>
parents:
8648
diff
changeset
|
278 pc = qs->parent; |
b4c7853b0488
QUIC: added shutdown support in stream proxy.
Vladimir Homutov <vl@nginx.com>
parents:
8648
diff
changeset
|
279 qc = ngx_quic_get_connection(pc); |
b4c7853b0488
QUIC: added shutdown support in stream proxy.
Vladimir Homutov <vl@nginx.com>
parents:
8648
diff
changeset
|
280 |
b4c7853b0488
QUIC: added shutdown support in stream proxy.
Vladimir Homutov <vl@nginx.com>
parents:
8648
diff
changeset
|
281 frame = ngx_quic_alloc_frame(pc); |
b4c7853b0488
QUIC: added shutdown support in stream proxy.
Vladimir Homutov <vl@nginx.com>
parents:
8648
diff
changeset
|
282 if (frame == NULL) { |
b4c7853b0488
QUIC: added shutdown support in stream proxy.
Vladimir Homutov <vl@nginx.com>
parents:
8648
diff
changeset
|
283 return NGX_ERROR; |
b4c7853b0488
QUIC: added shutdown support in stream proxy.
Vladimir Homutov <vl@nginx.com>
parents:
8648
diff
changeset
|
284 } |
b4c7853b0488
QUIC: added shutdown support in stream proxy.
Vladimir Homutov <vl@nginx.com>
parents:
8648
diff
changeset
|
285 |
b4c7853b0488
QUIC: added shutdown support in stream proxy.
Vladimir Homutov <vl@nginx.com>
parents:
8648
diff
changeset
|
286 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
b4c7853b0488
QUIC: added shutdown support in stream proxy.
Vladimir Homutov <vl@nginx.com>
parents:
8648
diff
changeset
|
287 "quic stream id:0x%xL shutdown", qs->id); |
b4c7853b0488
QUIC: added shutdown support in stream proxy.
Vladimir Homutov <vl@nginx.com>
parents:
8648
diff
changeset
|
288 |
b4c7853b0488
QUIC: added shutdown support in stream proxy.
Vladimir Homutov <vl@nginx.com>
parents:
8648
diff
changeset
|
289 frame->level = ssl_encryption_application; |
b4c7853b0488
QUIC: added shutdown support in stream proxy.
Vladimir Homutov <vl@nginx.com>
parents:
8648
diff
changeset
|
290 frame->type = NGX_QUIC_FT_STREAM; |
b4c7853b0488
QUIC: added shutdown support in stream proxy.
Vladimir Homutov <vl@nginx.com>
parents:
8648
diff
changeset
|
291 frame->u.stream.off = 1; |
b4c7853b0488
QUIC: added shutdown support in stream proxy.
Vladimir Homutov <vl@nginx.com>
parents:
8648
diff
changeset
|
292 frame->u.stream.len = 1; |
b4c7853b0488
QUIC: added shutdown support in stream proxy.
Vladimir Homutov <vl@nginx.com>
parents:
8648
diff
changeset
|
293 frame->u.stream.fin = 1; |
b4c7853b0488
QUIC: added shutdown support in stream proxy.
Vladimir Homutov <vl@nginx.com>
parents:
8648
diff
changeset
|
294 |
b4c7853b0488
QUIC: added shutdown support in stream proxy.
Vladimir Homutov <vl@nginx.com>
parents:
8648
diff
changeset
|
295 frame->u.stream.stream_id = qs->id; |
b4c7853b0488
QUIC: added shutdown support in stream proxy.
Vladimir Homutov <vl@nginx.com>
parents:
8648
diff
changeset
|
296 frame->u.stream.offset = c->sent; |
b4c7853b0488
QUIC: added shutdown support in stream proxy.
Vladimir Homutov <vl@nginx.com>
parents:
8648
diff
changeset
|
297 frame->u.stream.length = 0; |
b4c7853b0488
QUIC: added shutdown support in stream proxy.
Vladimir Homutov <vl@nginx.com>
parents:
8648
diff
changeset
|
298 |
b4c7853b0488
QUIC: added shutdown support in stream proxy.
Vladimir Homutov <vl@nginx.com>
parents:
8648
diff
changeset
|
299 ngx_quic_queue_frame(qc, frame); |
b4c7853b0488
QUIC: added shutdown support in stream proxy.
Vladimir Homutov <vl@nginx.com>
parents:
8648
diff
changeset
|
300 |
b4c7853b0488
QUIC: added shutdown support in stream proxy.
Vladimir Homutov <vl@nginx.com>
parents:
8648
diff
changeset
|
301 wev->ready = 1; |
b4c7853b0488
QUIC: added shutdown support in stream proxy.
Vladimir Homutov <vl@nginx.com>
parents:
8648
diff
changeset
|
302 wev->error = 1; |
b4c7853b0488
QUIC: added shutdown support in stream proxy.
Vladimir Homutov <vl@nginx.com>
parents:
8648
diff
changeset
|
303 |
b4c7853b0488
QUIC: added shutdown support in stream proxy.
Vladimir Homutov <vl@nginx.com>
parents:
8648
diff
changeset
|
304 return NGX_OK; |
b4c7853b0488
QUIC: added shutdown support in stream proxy.
Vladimir Homutov <vl@nginx.com>
parents:
8648
diff
changeset
|
305 } |
b4c7853b0488
QUIC: added shutdown support in stream proxy.
Vladimir Homutov <vl@nginx.com>
parents:
8648
diff
changeset
|
306 |
b4c7853b0488
QUIC: added shutdown support in stream proxy.
Vladimir Homutov <vl@nginx.com>
parents:
8648
diff
changeset
|
307 |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
308 static ngx_quic_stream_t * |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
309 ngx_quic_create_client_stream(ngx_connection_t *c, uint64_t id) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
310 { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
311 uint64_t min_id; |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
312 ngx_quic_stream_t *qs; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
313 ngx_quic_connection_t *qc; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
314 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
315 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
|
316 "quic stream id:0x%xL is new", id); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
317 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
318 qc = ngx_quic_get_connection(c); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
319 |
8694
832723a49026
QUIC: stop processing new client streams at the closing state.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8679
diff
changeset
|
320 if (qc->shutdown || qc->closing) { |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
321 return NGX_QUIC_STREAM_GONE; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
322 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
323 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
324 if (id & NGX_QUIC_STREAM_UNIDIRECTIONAL) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
325 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
326 if (id & NGX_QUIC_STREAM_SERVER_INITIATED) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
327 if ((id >> 2) < qc->streams.server_streams_uni) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
328 return NGX_QUIC_STREAM_GONE; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
329 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
330 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
331 qc->error = NGX_QUIC_ERR_STREAM_STATE_ERROR; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
332 return NULL; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
333 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
334 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
335 if ((id >> 2) < qc->streams.client_streams_uni) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
336 return NGX_QUIC_STREAM_GONE; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
337 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
338 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
339 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
|
340 qc->error = NGX_QUIC_ERR_STREAM_LIMIT_ERROR; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
341 return NULL; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
342 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
343 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
344 min_id = (qc->streams.client_streams_uni << 2) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
345 | NGX_QUIC_STREAM_UNIDIRECTIONAL; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
346 qc->streams.client_streams_uni = (id >> 2) + 1; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
347 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
348 } else { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
349 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
350 if (id & NGX_QUIC_STREAM_SERVER_INITIATED) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
351 if ((id >> 2) < qc->streams.server_streams_bidi) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
352 return NGX_QUIC_STREAM_GONE; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
353 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
354 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
355 qc->error = NGX_QUIC_ERR_STREAM_STATE_ERROR; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
356 return NULL; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
357 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
358 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
359 if ((id >> 2) < qc->streams.client_streams_bidi) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
360 return NGX_QUIC_STREAM_GONE; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
361 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
362 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
363 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
|
364 qc->error = NGX_QUIC_ERR_STREAM_LIMIT_ERROR; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
365 return NULL; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
366 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
367 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
368 min_id = (qc->streams.client_streams_bidi << 2); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
369 qc->streams.client_streams_bidi = (id >> 2) + 1; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
370 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
371 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
372 /* |
8498
4715f3e669f1
QUIC: updated specification references.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8492
diff
changeset
|
373 * RFC 9000, 2.1. Stream Types and Identifiers |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
374 * |
8498
4715f3e669f1
QUIC: updated specification references.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8492
diff
changeset
|
375 * successive streams of each type are created with numerically increasing |
4715f3e669f1
QUIC: updated specification references.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8492
diff
changeset
|
376 * 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:
8492
diff
changeset
|
377 * streams of that type with lower-numbered stream IDs also being opened. |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
378 */ |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
379 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
380 for ( /* void */ ; min_id < id; min_id += 0x04) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
381 |
8439
f52a2b77d406
QUIC: generic buffering for stream input.
Roman Arutyunyan <arut@nginx.com>
parents:
8421
diff
changeset
|
382 qs = ngx_quic_create_stream(c, min_id); |
8695
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
383 |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
384 if (qs == NULL) { |
8695
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
385 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:
8694
diff
changeset
|
386 return NULL; |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
387 } |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
388 |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
389 continue; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
390 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
391 |
8552
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
392 if (ngx_quic_init_stream(qs) != NGX_OK) { |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
393 return NULL; |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
394 } |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
395 |
8694
832723a49026
QUIC: stop processing new client streams at the closing state.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8679
diff
changeset
|
396 if (qc->shutdown || qc->closing) { |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
397 return NGX_QUIC_STREAM_GONE; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
398 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
399 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
400 |
8695
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
401 qs = ngx_quic_create_stream(c, id); |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
402 |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
403 if (qs == NULL) { |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
404 if (ngx_quic_reject_stream(c, id) != NGX_OK) { |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
405 return NULL; |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
406 } |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
407 |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
408 return NGX_QUIC_STREAM_GONE; |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
409 } |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
410 |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
411 return qs; |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
412 } |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
413 |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
414 |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
415 static ngx_int_t |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
416 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:
8694
diff
changeset
|
417 { |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
418 uint64_t code; |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
419 ngx_quic_frame_t *frame; |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
420 ngx_quic_connection_t *qc; |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
421 |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
422 qc = ngx_quic_get_connection(c); |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
423 |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
424 code = (id & NGX_QUIC_STREAM_UNIDIRECTIONAL) |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
425 ? qc->conf->stream_reject_code_uni |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
426 : qc->conf->stream_reject_code_bidi; |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
427 |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
428 if (code == 0) { |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
429 return NGX_DECLINED; |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
430 } |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
431 |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
432 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:
8694
diff
changeset
|
433 "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:
8694
diff
changeset
|
434 |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
435 frame = ngx_quic_alloc_frame(c); |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
436 if (frame == NULL) { |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
437 return NGX_ERROR; |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
438 } |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
439 |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
440 frame->level = ssl_encryption_application; |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
441 frame->type = NGX_QUIC_FT_RESET_STREAM; |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
442 frame->u.reset_stream.id = id; |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
443 frame->u.reset_stream.error_code = code; |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
444 frame->u.reset_stream.final_size = 0; |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
445 |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
446 ngx_quic_queue_frame(qc, frame); |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
447 |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
448 frame = ngx_quic_alloc_frame(c); |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
449 if (frame == NULL) { |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
450 return NGX_ERROR; |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
451 } |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
452 |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
453 frame->level = ssl_encryption_application; |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
454 frame->type = NGX_QUIC_FT_STOP_SENDING; |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
455 frame->u.stop_sending.id = id; |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
456 frame->u.stop_sending.error_code = code; |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
457 |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
458 ngx_quic_queue_frame(qc, frame); |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
459 |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
460 return NGX_OK; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
461 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
462 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
463 |
8552
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
464 static ngx_int_t |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
465 ngx_quic_init_stream(ngx_quic_stream_t *qs) |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
466 { |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
467 ngx_connection_t *c; |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
468 ngx_quic_connection_t *qc; |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
469 |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
470 qc = ngx_quic_get_connection(qs->parent); |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
471 |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
472 c = qs->connection; |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
473 |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
474 if (!qc->streams.initialized) { |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
475 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, 0, |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
476 "quic postpone stream init"); |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
477 |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
478 ngx_queue_insert_tail(&qc->streams.uninitialized, &qs->queue); |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
479 return NGX_OK; |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
480 } |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
481 |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
482 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:
8545
diff
changeset
|
483 |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
484 c->listening->handler(c); |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
485 |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
486 return NGX_OK; |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
487 } |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
488 |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
489 |
8648
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8638
diff
changeset
|
490 ngx_int_t |
8552
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
491 ngx_quic_init_streams(ngx_connection_t *c) |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
492 { |
8648
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8638
diff
changeset
|
493 ngx_int_t rc; |
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8638
diff
changeset
|
494 ngx_quic_connection_t *qc; |
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8638
diff
changeset
|
495 |
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8638
diff
changeset
|
496 qc = ngx_quic_get_connection(c); |
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8638
diff
changeset
|
497 |
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8638
diff
changeset
|
498 if (qc->streams.initialized) { |
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8638
diff
changeset
|
499 return NGX_OK; |
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8638
diff
changeset
|
500 } |
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8638
diff
changeset
|
501 |
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8638
diff
changeset
|
502 rc = ngx_ssl_ocsp_validate(c); |
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8638
diff
changeset
|
503 |
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8638
diff
changeset
|
504 if (rc == NGX_ERROR) { |
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8638
diff
changeset
|
505 return NGX_ERROR; |
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8638
diff
changeset
|
506 } |
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8638
diff
changeset
|
507 |
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8638
diff
changeset
|
508 if (rc == NGX_AGAIN) { |
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8638
diff
changeset
|
509 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:
8638
diff
changeset
|
510 return NGX_OK; |
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8638
diff
changeset
|
511 } |
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8638
diff
changeset
|
512 |
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8638
diff
changeset
|
513 ngx_quic_init_streams_handler(c); |
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8638
diff
changeset
|
514 |
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8638
diff
changeset
|
515 return NGX_OK; |
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8638
diff
changeset
|
516 } |
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8638
diff
changeset
|
517 |
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8638
diff
changeset
|
518 |
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8638
diff
changeset
|
519 static void |
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8638
diff
changeset
|
520 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:
8638
diff
changeset
|
521 { |
8552
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
522 ngx_queue_t *q; |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
523 ngx_quic_stream_t *qs; |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
524 ngx_quic_connection_t *qc; |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
525 |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
526 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:
8545
diff
changeset
|
527 |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
528 qc = ngx_quic_get_connection(c); |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
529 |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
530 while (!ngx_queue_empty(&qc->streams.uninitialized)) { |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
531 q = ngx_queue_head(&qc->streams.uninitialized); |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
532 ngx_queue_remove(q); |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
533 |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
534 qs = ngx_queue_data(q, ngx_quic_stream_t, queue); |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
535 |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
536 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, qs->connection->log, 0, |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
537 "quic init postponed stream"); |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
538 |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
539 qs->connection->listening->handler(qs->connection); |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
540 } |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
541 |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
542 qc->streams.initialized = 1; |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
543 } |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
544 |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
545 |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
546 static ngx_quic_stream_t * |
8439
f52a2b77d406
QUIC: generic buffering for stream input.
Roman Arutyunyan <arut@nginx.com>
parents:
8421
diff
changeset
|
547 ngx_quic_create_stream(ngx_connection_t *c, uint64_t id) |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
548 { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
549 ngx_log_t *log; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
550 ngx_pool_t *pool; |
8420
baf9551b4a5b
QUIC: renamed stream field from c to connection.
Roman Arutyunyan <arut@nginx.com>
parents:
8416
diff
changeset
|
551 ngx_connection_t *sc; |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
552 ngx_quic_stream_t *qs; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
553 ngx_pool_cleanup_t *cln; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
554 ngx_quic_connection_t *qc; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
555 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
556 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
|
557 "quic stream id:0x%xL create", id); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
558 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
559 qc = ngx_quic_get_connection(c); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
560 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
561 pool = ngx_create_pool(NGX_DEFAULT_POOL_SIZE, c->log); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
562 if (pool == NULL) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
563 return NULL; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
564 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
565 |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
566 qs = ngx_pcalloc(pool, sizeof(ngx_quic_stream_t)); |
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
567 if (qs == NULL) { |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
568 ngx_destroy_pool(pool); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
569 return NULL; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
570 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
571 |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
572 qs->node.key = id; |
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
573 qs->parent = c; |
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
574 qs->id = id; |
8442
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
575 qs->final_size = (uint64_t) -1; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
576 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
577 log = ngx_palloc(pool, sizeof(ngx_log_t)); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
578 if (log == NULL) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
579 ngx_destroy_pool(pool); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
580 return NULL; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
581 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
582 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
583 *log = *c->log; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
584 pool->log = log; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
585 |
8622
a2cef164a924
QUIC: simplified stream fd initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8617
diff
changeset
|
586 sc = ngx_get_connection(c->fd, log); |
8420
baf9551b4a5b
QUIC: renamed stream field from c to connection.
Roman Arutyunyan <arut@nginx.com>
parents:
8416
diff
changeset
|
587 if (sc == NULL) { |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
588 ngx_destroy_pool(pool); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
589 return NULL; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
590 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
591 |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
592 qs->connection = sc; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
593 |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
594 sc->quic = qs; |
8597
486c6a9be111
QUIC: store QUIC connection fd in stream fake connection.
Roman Arutyunyan <arut@nginx.com>
parents:
8596
diff
changeset
|
595 sc->shared = 1; |
8420
baf9551b4a5b
QUIC: renamed stream field from c to connection.
Roman Arutyunyan <arut@nginx.com>
parents:
8416
diff
changeset
|
596 sc->type = SOCK_STREAM; |
baf9551b4a5b
QUIC: renamed stream field from c to connection.
Roman Arutyunyan <arut@nginx.com>
parents:
8416
diff
changeset
|
597 sc->pool = pool; |
baf9551b4a5b
QUIC: renamed stream field from c to connection.
Roman Arutyunyan <arut@nginx.com>
parents:
8416
diff
changeset
|
598 sc->ssl = c->ssl; |
baf9551b4a5b
QUIC: renamed stream field from c to connection.
Roman Arutyunyan <arut@nginx.com>
parents:
8416
diff
changeset
|
599 sc->sockaddr = c->sockaddr; |
baf9551b4a5b
QUIC: renamed stream field from c to connection.
Roman Arutyunyan <arut@nginx.com>
parents:
8416
diff
changeset
|
600 sc->listening = c->listening; |
baf9551b4a5b
QUIC: renamed stream field from c to connection.
Roman Arutyunyan <arut@nginx.com>
parents:
8416
diff
changeset
|
601 sc->addr_text = c->addr_text; |
baf9551b4a5b
QUIC: renamed stream field from c to connection.
Roman Arutyunyan <arut@nginx.com>
parents:
8416
diff
changeset
|
602 sc->local_sockaddr = c->local_sockaddr; |
baf9551b4a5b
QUIC: renamed stream field from c to connection.
Roman Arutyunyan <arut@nginx.com>
parents:
8416
diff
changeset
|
603 sc->local_socklen = c->local_socklen; |
baf9551b4a5b
QUIC: renamed stream field from c to connection.
Roman Arutyunyan <arut@nginx.com>
parents:
8416
diff
changeset
|
604 sc->number = ngx_atomic_fetch_add(ngx_connection_counter, 1); |
8623
630ecd703805
QUIC: set NGX_TCP_NODELAY_DISABLED for fake stream connections.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8622
diff
changeset
|
605 sc->tcp_nodelay = NGX_TCP_NODELAY_DISABLED; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
606 |
8420
baf9551b4a5b
QUIC: renamed stream field from c to connection.
Roman Arutyunyan <arut@nginx.com>
parents:
8416
diff
changeset
|
607 sc->recv = ngx_quic_stream_recv; |
baf9551b4a5b
QUIC: renamed stream field from c to connection.
Roman Arutyunyan <arut@nginx.com>
parents:
8416
diff
changeset
|
608 sc->send = ngx_quic_stream_send; |
baf9551b4a5b
QUIC: renamed stream field from c to connection.
Roman Arutyunyan <arut@nginx.com>
parents:
8416
diff
changeset
|
609 sc->send_chain = ngx_quic_stream_send_chain; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
610 |
8420
baf9551b4a5b
QUIC: renamed stream field from c to connection.
Roman Arutyunyan <arut@nginx.com>
parents:
8416
diff
changeset
|
611 sc->read->log = log; |
baf9551b4a5b
QUIC: renamed stream field from c to connection.
Roman Arutyunyan <arut@nginx.com>
parents:
8416
diff
changeset
|
612 sc->write->log = log; |
baf9551b4a5b
QUIC: renamed stream field from c to connection.
Roman Arutyunyan <arut@nginx.com>
parents:
8416
diff
changeset
|
613 |
8552
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
614 sc->read->handler = ngx_quic_empty_handler; |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
615 sc->write->handler = ngx_quic_empty_handler; |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
616 |
8420
baf9551b4a5b
QUIC: renamed stream field from c to connection.
Roman Arutyunyan <arut@nginx.com>
parents:
8416
diff
changeset
|
617 log->connection = sc->number; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
618 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
619 if ((id & NGX_QUIC_STREAM_UNIDIRECTIONAL) == 0 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
620 || (id & NGX_QUIC_STREAM_SERVER_INITIATED)) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
621 { |
8420
baf9551b4a5b
QUIC: renamed stream field from c to connection.
Roman Arutyunyan <arut@nginx.com>
parents:
8416
diff
changeset
|
622 sc->write->ready = 1; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
623 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
624 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
625 if (id & NGX_QUIC_STREAM_UNIDIRECTIONAL) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
626 if (id & NGX_QUIC_STREAM_SERVER_INITIATED) { |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
627 qs->send_max_data = qc->ctp.initial_max_stream_data_uni; |
8439
f52a2b77d406
QUIC: generic buffering for stream input.
Roman Arutyunyan <arut@nginx.com>
parents:
8421
diff
changeset
|
628 |
f52a2b77d406
QUIC: generic buffering for stream input.
Roman Arutyunyan <arut@nginx.com>
parents:
8421
diff
changeset
|
629 } else { |
f52a2b77d406
QUIC: generic buffering for stream input.
Roman Arutyunyan <arut@nginx.com>
parents:
8421
diff
changeset
|
630 qs->recv_max_data = qc->tp.initial_max_stream_data_uni; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
631 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
632 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
633 } else { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
634 if (id & NGX_QUIC_STREAM_SERVER_INITIATED) { |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
635 qs->send_max_data = qc->ctp.initial_max_stream_data_bidi_remote; |
8439
f52a2b77d406
QUIC: generic buffering for stream input.
Roman Arutyunyan <arut@nginx.com>
parents:
8421
diff
changeset
|
636 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:
8421
diff
changeset
|
637 |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
638 } else { |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
639 qs->send_max_data = qc->ctp.initial_max_stream_data_bidi_local; |
8439
f52a2b77d406
QUIC: generic buffering for stream input.
Roman Arutyunyan <arut@nginx.com>
parents:
8421
diff
changeset
|
640 qs->recv_max_data = qc->tp.initial_max_stream_data_bidi_remote; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
641 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
642 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
643 |
8492
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
644 qs->recv_window = qs->recv_max_data; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
645 |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
646 cln = ngx_pool_cleanup_add(pool, 0); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
647 if (cln == NULL) { |
8420
baf9551b4a5b
QUIC: renamed stream field from c to connection.
Roman Arutyunyan <arut@nginx.com>
parents:
8416
diff
changeset
|
648 ngx_close_connection(sc); |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
649 ngx_destroy_pool(pool); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
650 return NULL; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
651 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
652 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
653 cln->handler = ngx_quic_stream_cleanup_handler; |
8420
baf9551b4a5b
QUIC: renamed stream field from c to connection.
Roman Arutyunyan <arut@nginx.com>
parents:
8416
diff
changeset
|
654 cln->data = sc; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
655 |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
656 ngx_rbtree_insert(&qc->streams.tree, &qs->node); |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
657 |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
658 return qs; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
659 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
660 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
661 |
8552
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
662 static void |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
663 ngx_quic_empty_handler(ngx_event_t *ev) |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
664 { |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
665 } |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
666 |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
667 |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
668 static ssize_t |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
669 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
|
670 { |
8492
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
671 ssize_t len, n; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
672 ngx_buf_t *b; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
673 ngx_chain_t *cl, **ll; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
674 ngx_event_t *rev; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
675 ngx_connection_t *pc; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
676 ngx_quic_stream_t *qs; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
677 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
678 qs = c->quic; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
679 pc = qs->parent; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
680 rev = c->read; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
681 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
682 if (rev->error) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
683 return NGX_ERROR; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
684 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
685 |
8442
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
686 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, c->log, 0, |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
687 "quic stream id:0x%xL recv eof:%d buf:%uz", |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
688 qs->id, rev->pending_eof, size); |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
689 |
8442
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
690 if (qs->in == NULL || qs->in->buf->sync) { |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
691 rev->ready = 0; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
692 |
8442
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
693 if (qs->recv_offset == qs->final_size) { |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
694 rev->eof = 1; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
695 return 0; |
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 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
|
699 "quic stream id:0x%xL recv() not ready", qs->id); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
700 return NGX_AGAIN; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
701 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
702 |
8439
f52a2b77d406
QUIC: generic buffering for stream input.
Roman Arutyunyan <arut@nginx.com>
parents:
8421
diff
changeset
|
703 len = 0; |
f52a2b77d406
QUIC: generic buffering for stream input.
Roman Arutyunyan <arut@nginx.com>
parents:
8421
diff
changeset
|
704 cl = qs->in; |
f52a2b77d406
QUIC: generic buffering for stream input.
Roman Arutyunyan <arut@nginx.com>
parents:
8421
diff
changeset
|
705 |
f52a2b77d406
QUIC: generic buffering for stream input.
Roman Arutyunyan <arut@nginx.com>
parents:
8421
diff
changeset
|
706 for (ll = &cl; *ll; ll = &(*ll)->next) { |
f52a2b77d406
QUIC: generic buffering for stream input.
Roman Arutyunyan <arut@nginx.com>
parents:
8421
diff
changeset
|
707 b = (*ll)->buf; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
708 |
8442
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
709 if (b->sync) { |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
710 /* hole */ |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
711 break; |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
712 } |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
713 |
8439
f52a2b77d406
QUIC: generic buffering for stream input.
Roman Arutyunyan <arut@nginx.com>
parents:
8421
diff
changeset
|
714 n = ngx_min(b->last - b->pos, (ssize_t) size); |
f52a2b77d406
QUIC: generic buffering for stream input.
Roman Arutyunyan <arut@nginx.com>
parents:
8421
diff
changeset
|
715 buf = ngx_cpymem(buf, b->pos, n); |
f52a2b77d406
QUIC: generic buffering for stream input.
Roman Arutyunyan <arut@nginx.com>
parents:
8421
diff
changeset
|
716 |
f52a2b77d406
QUIC: generic buffering for stream input.
Roman Arutyunyan <arut@nginx.com>
parents:
8421
diff
changeset
|
717 len += n; |
f52a2b77d406
QUIC: generic buffering for stream input.
Roman Arutyunyan <arut@nginx.com>
parents:
8421
diff
changeset
|
718 size -= n; |
f52a2b77d406
QUIC: generic buffering for stream input.
Roman Arutyunyan <arut@nginx.com>
parents:
8421
diff
changeset
|
719 b->pos += n; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
720 |
8439
f52a2b77d406
QUIC: generic buffering for stream input.
Roman Arutyunyan <arut@nginx.com>
parents:
8421
diff
changeset
|
721 if (b->pos != b->last) { |
f52a2b77d406
QUIC: generic buffering for stream input.
Roman Arutyunyan <arut@nginx.com>
parents:
8421
diff
changeset
|
722 break; |
f52a2b77d406
QUIC: generic buffering for stream input.
Roman Arutyunyan <arut@nginx.com>
parents:
8421
diff
changeset
|
723 } |
f52a2b77d406
QUIC: generic buffering for stream input.
Roman Arutyunyan <arut@nginx.com>
parents:
8421
diff
changeset
|
724 } |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
725 |
8439
f52a2b77d406
QUIC: generic buffering for stream input.
Roman Arutyunyan <arut@nginx.com>
parents:
8421
diff
changeset
|
726 qs->in = *ll; |
f52a2b77d406
QUIC: generic buffering for stream input.
Roman Arutyunyan <arut@nginx.com>
parents:
8421
diff
changeset
|
727 *ll = NULL; |
f52a2b77d406
QUIC: generic buffering for stream input.
Roman Arutyunyan <arut@nginx.com>
parents:
8421
diff
changeset
|
728 |
f52a2b77d406
QUIC: generic buffering for stream input.
Roman Arutyunyan <arut@nginx.com>
parents:
8421
diff
changeset
|
729 ngx_quic_free_bufs(pc, cl); |
f52a2b77d406
QUIC: generic buffering for stream input.
Roman Arutyunyan <arut@nginx.com>
parents:
8421
diff
changeset
|
730 |
f52a2b77d406
QUIC: generic buffering for stream input.
Roman Arutyunyan <arut@nginx.com>
parents:
8421
diff
changeset
|
731 if (qs->in == NULL) { |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
732 rev->ready = rev->pending_eof; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
733 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
734 |
8442
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
735 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, c->log, 0, |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
736 "quic stream id:0x%xL recv len:%z", qs->id, len); |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
737 |
8492
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
738 if (ngx_quic_update_flow(c, qs->recv_offset + len) != NGX_OK) { |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
739 return NGX_ERROR; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
740 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
741 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
742 return len; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
743 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
744 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
745 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
746 static ssize_t |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
747 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
|
748 { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
749 ngx_buf_t b; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
750 ngx_chain_t cl; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
751 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
752 ngx_memzero(&b, sizeof(ngx_buf_t)); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
753 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
754 b.memory = 1; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
755 b.pos = buf; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
756 b.last = buf + size; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
757 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
758 cl.buf = &b; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
759 cl.next = NULL; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
760 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
761 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
|
762 return NGX_ERROR; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
763 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
764 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
765 if (b.pos == buf) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
766 return NGX_AGAIN; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
767 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
768 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
769 return b.pos - buf; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
770 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
771 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
772 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
773 static ngx_chain_t * |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
774 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
|
775 { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
776 size_t n, flow; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
777 ngx_event_t *wev; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
778 ngx_chain_t *cl; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
779 ngx_connection_t *pc; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
780 ngx_quic_frame_t *frame; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
781 ngx_quic_stream_t *qs; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
782 ngx_quic_connection_t *qc; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
783 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
784 qs = c->quic; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
785 pc = qs->parent; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
786 qc = ngx_quic_get_connection(pc); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
787 wev = c->write; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
788 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
789 if (wev->error) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
790 return NGX_CHAIN_ERROR; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
791 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
792 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
793 flow = ngx_quic_max_stream_flow(c); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
794 if (flow == 0) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
795 wev->ready = 0; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
796 return in; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
797 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
798 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
799 n = (limit && (size_t) limit < flow) ? (size_t) limit : flow; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
800 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
801 frame = ngx_quic_alloc_frame(pc); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
802 if (frame == NULL) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
803 return NGX_CHAIN_ERROR; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
804 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
805 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
806 frame->data = ngx_quic_copy_chain(pc, in, n); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
807 if (frame->data == NGX_CHAIN_ERROR) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
808 return NGX_CHAIN_ERROR; |
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 for (n = 0, cl = frame->data; cl; cl = cl->next) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
812 n += ngx_buf_size(cl->buf); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
813 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
814 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
815 while (in && ngx_buf_size(in->buf) == 0) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
816 in = in->next; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
817 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
818 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
819 frame->level = ssl_encryption_application; |
8545
4009f120cad4
QUIC: eliminated stream type from ngx_quic_stream_frame_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8498
diff
changeset
|
820 frame->type = NGX_QUIC_FT_STREAM; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
821 frame->u.stream.off = 1; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
822 frame->u.stream.len = 1; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
823 frame->u.stream.fin = 0; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
824 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
825 frame->u.stream.stream_id = qs->id; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
826 frame->u.stream.offset = c->sent; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
827 frame->u.stream.length = n; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
828 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
829 c->sent += n; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
830 qc->streams.sent += n; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
831 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
832 ngx_quic_queue_frame(qc, frame); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
833 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
834 wev->ready = (n < flow) ? 1 : 0; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
835 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
836 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
|
837 "quic send_chain sent:%uz", n); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
838 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
839 return in; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
840 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
841 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
842 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
843 static size_t |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
844 ngx_quic_max_stream_flow(ngx_connection_t *c) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
845 { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
846 size_t size; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
847 uint64_t sent, unacked; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
848 ngx_quic_stream_t *qs; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
849 ngx_quic_connection_t *qc; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
850 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
851 qs = c->quic; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
852 qc = ngx_quic_get_connection(qs->parent); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
853 |
8713
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8698
diff
changeset
|
854 size = qc->conf->stream_buffer_size; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
855 sent = c->sent; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
856 unacked = sent - qs->acked; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
857 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
858 if (qc->streams.send_max_data == 0) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
859 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
|
860 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
861 |
8713
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8698
diff
changeset
|
862 if (unacked >= size) { |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
863 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, 0, |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
864 "quic send flow hit buffer size"); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
865 return 0; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
866 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
867 |
8713
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8698
diff
changeset
|
868 size -= unacked; |
8410
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 if (qc->streams.sent >= qc->streams.send_max_data) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
871 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, 0, |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
872 "quic send flow hit MAX_DATA"); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
873 return 0; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
874 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
875 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
876 if (qc->streams.sent + size > qc->streams.send_max_data) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
877 size = qc->streams.send_max_data - qc->streams.sent; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
878 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
879 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
880 if (sent >= qs->send_max_data) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
881 ngx_log_debug0(NGX_LOG_DEBUG_EVENT, c->log, 0, |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
882 "quic send flow hit MAX_STREAM_DATA"); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
883 return 0; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
884 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
885 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
886 if (sent + size > qs->send_max_data) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
887 size = qs->send_max_data - sent; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
888 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
889 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
890 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
|
891 "quic send flow:%uz", size); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
892 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
893 return size; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
894 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
895 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
896 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
897 static void |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
898 ngx_quic_stream_cleanup_handler(void *data) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
899 { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
900 ngx_connection_t *c = data; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
901 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
902 ngx_connection_t *pc; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
903 ngx_quic_frame_t *frame; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
904 ngx_quic_stream_t *qs; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
905 ngx_quic_connection_t *qc; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
906 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
907 qs = c->quic; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
908 pc = qs->parent; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
909 qc = ngx_quic_get_connection(pc); |
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 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
|
912 "quic stream id:0x%xL cleanup", qs->id); |
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 ngx_rbtree_delete(&qc->streams.tree, &qs->node); |
8439
f52a2b77d406
QUIC: generic buffering for stream input.
Roman Arutyunyan <arut@nginx.com>
parents:
8421
diff
changeset
|
915 ngx_quic_free_bufs(pc, qs->in); |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
916 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
917 if (qc->closing) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
918 /* schedule handler call to continue ngx_quic_close_connection() */ |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
919 ngx_post_event(pc->read, &ngx_posted_events); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
920 return; |
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 |
8416
e29b7508b8b3
QUIC: avoid sending extra frames in case of error.
Vladimir Homutov <vl@nginx.com>
parents:
8415
diff
changeset
|
923 if (qc->error) { |
e29b7508b8b3
QUIC: avoid sending extra frames in case of error.
Vladimir Homutov <vl@nginx.com>
parents:
8415
diff
changeset
|
924 goto done; |
e29b7508b8b3
QUIC: avoid sending extra frames in case of error.
Vladimir Homutov <vl@nginx.com>
parents:
8415
diff
changeset
|
925 } |
e29b7508b8b3
QUIC: avoid sending extra frames in case of error.
Vladimir Homutov <vl@nginx.com>
parents:
8415
diff
changeset
|
926 |
8492
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
927 c->read->pending_eof = 1; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
928 |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
929 (void) ngx_quic_update_flow(c, qs->recv_last); |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
930 |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
931 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
|
932 || (qs->id & NGX_QUIC_STREAM_UNIDIRECTIONAL) == 0) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
933 { |
8695
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
934 if (!c->read->pending_eof && !c->read->error |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
935 && qc->conf->stream_close_code) |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
936 { |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
937 frame = ngx_quic_alloc_frame(pc); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
938 if (frame == NULL) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
939 goto done; |
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 frame->level = ssl_encryption_application; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
943 frame->type = NGX_QUIC_FT_STOP_SENDING; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
944 frame->u.stop_sending.id = qs->id; |
8695
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
945 frame->u.stop_sending.error_code = qc->conf->stream_close_code; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
946 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
947 ngx_quic_queue_frame(qc, frame); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
948 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
949 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
950 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
951 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
|
952 frame = ngx_quic_alloc_frame(pc); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
953 if (frame == NULL) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
954 goto done; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
955 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
956 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
957 frame->level = ssl_encryption_application; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
958 frame->type = NGX_QUIC_FT_MAX_STREAMS; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
959 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
960 if (qs->id & NGX_QUIC_STREAM_UNIDIRECTIONAL) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
961 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
|
962 frame->u.max_streams.bidi = 0; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
963 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
964 } else { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
965 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
|
966 frame->u.max_streams.bidi = 1; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
967 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
968 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
969 ngx_quic_queue_frame(qc, frame); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
970 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
971 if (qs->id & NGX_QUIC_STREAM_UNIDIRECTIONAL) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
972 /* do not send fin for client unidirectional streams */ |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
973 goto done; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
974 } |
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 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
977 if (c->write->error) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
978 goto done; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
979 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
980 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
981 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
|
982 "quic stream id:0x%xL send fin", qs->id); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
983 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
984 frame = ngx_quic_alloc_frame(pc); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
985 if (frame == NULL) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
986 goto done; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
987 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
988 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
989 frame->level = ssl_encryption_application; |
8545
4009f120cad4
QUIC: eliminated stream type from ngx_quic_stream_frame_t.
Roman Arutyunyan <arut@nginx.com>
parents:
8498
diff
changeset
|
990 frame->type = NGX_QUIC_FT_STREAM; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
991 frame->u.stream.off = 1; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
992 frame->u.stream.len = 1; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
993 frame->u.stream.fin = 1; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
994 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
995 frame->u.stream.stream_id = qs->id; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
996 frame->u.stream.offset = c->sent; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
997 frame->u.stream.length = 0; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
998 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
999 ngx_quic_queue_frame(qc, frame); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1000 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1001 done: |
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 (void) ngx_quic_output(pc); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1004 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1005 if (qc->shutdown) { |
8553
a9f6540e61da
QUIC: asynchronous shutdown.
Roman Arutyunyan <arut@nginx.com>
parents:
8552
diff
changeset
|
1006 ngx_post_event(pc->read, &ngx_posted_events); |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1007 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1008 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1009 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1010 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1011 ngx_int_t |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1012 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
|
1013 ngx_quic_frame_t *frame) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1014 { |
8442
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
1015 uint64_t last; |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
1016 ngx_pool_t *pool; |
8444
7d32c3c93678
QUIC: call stream read handler on new data arrival.
Roman Arutyunyan <arut@nginx.com>
parents:
8443
diff
changeset
|
1017 ngx_event_t *rev; |
8442
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
1018 ngx_connection_t *sc; |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
1019 ngx_quic_stream_t *qs; |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
1020 ngx_quic_connection_t *qc; |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
1021 ngx_quic_stream_frame_t *f; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1022 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1023 qc = ngx_quic_get_connection(c); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1024 f = &frame->u.stream; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1025 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1026 if ((f->stream_id & NGX_QUIC_STREAM_UNIDIRECTIONAL) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1027 && (f->stream_id & NGX_QUIC_STREAM_SERVER_INITIATED)) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1028 { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1029 qc->error = NGX_QUIC_ERR_STREAM_STATE_ERROR; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1030 return NGX_ERROR; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1031 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1032 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1033 /* no overflow since both values are 62-bit */ |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1034 last = f->offset + f->length; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1035 |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
1036 qs = ngx_quic_find_stream(&qc->streams.tree, f->stream_id); |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1037 |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
1038 if (qs == NULL) { |
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
1039 qs = ngx_quic_create_client_stream(c, f->stream_id); |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1040 |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
1041 if (qs == NULL) { |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1042 return NGX_ERROR; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1043 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1044 |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
1045 if (qs == NGX_QUIC_STREAM_GONE) { |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1046 return NGX_OK; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1047 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1048 |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
1049 sc = qs->connection; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1050 |
8492
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1051 if (ngx_quic_control_flow(sc, last) != NGX_OK) { |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1052 goto cleanup; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1053 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1054 |
8442
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
1055 if (f->fin) { |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
1056 sc->read->pending_eof = 1; |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
1057 qs->final_size = last; |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
1058 } |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
1059 |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
1060 if (f->offset == 0) { |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
1061 sc->read->ready = 1; |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
1062 } |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
1063 |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
1064 if (ngx_quic_order_bufs(c, &qs->in, frame->data, f->offset) != NGX_OK) { |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1065 goto cleanup; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1066 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1067 |
8552
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
1068 return ngx_quic_init_stream(qs); |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1069 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1070 |
8492
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1071 sc = qs->connection; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1072 |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1073 rev = sc->read; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1074 |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1075 if (rev->error) { |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1076 return NGX_OK; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1077 } |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1078 |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1079 if (ngx_quic_control_flow(sc, last) != NGX_OK) { |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1080 return NGX_ERROR; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1081 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1082 |
8442
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
1083 if (qs->final_size != (uint64_t) -1 && last > qs->final_size) { |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
1084 qc->error = NGX_QUIC_ERR_FINAL_SIZE_ERROR; |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
1085 return NGX_ERROR; |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
1086 } |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
1087 |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
1088 if (last <= qs->recv_offset) { |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
1089 return NGX_OK; |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
1090 } |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
1091 |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
1092 if (f->offset < qs->recv_offset) { |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
1093 ngx_quic_trim_bufs(frame->data, qs->recv_offset - f->offset); |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
1094 f->offset = qs->recv_offset; |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
1095 } |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
1096 |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
1097 if (f->fin) { |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
1098 if (qs->final_size != (uint64_t) -1 && qs->final_size != last) { |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
1099 qc->error = NGX_QUIC_ERR_FINAL_SIZE_ERROR; |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
1100 return NGX_ERROR; |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
1101 } |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
1102 |
8443
60c6e8d8d3ae
QUIC: make sure stream data size is lower than final size.
Roman Arutyunyan <arut@nginx.com>
parents:
8442
diff
changeset
|
1103 if (qs->recv_last > last) { |
60c6e8d8d3ae
QUIC: make sure stream data size is lower than final size.
Roman Arutyunyan <arut@nginx.com>
parents:
8442
diff
changeset
|
1104 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:
8442
diff
changeset
|
1105 return NGX_ERROR; |
60c6e8d8d3ae
QUIC: make sure stream data size is lower than final size.
Roman Arutyunyan <arut@nginx.com>
parents:
8442
diff
changeset
|
1106 } |
60c6e8d8d3ae
QUIC: make sure stream data size is lower than final size.
Roman Arutyunyan <arut@nginx.com>
parents:
8442
diff
changeset
|
1107 |
8444
7d32c3c93678
QUIC: call stream read handler on new data arrival.
Roman Arutyunyan <arut@nginx.com>
parents:
8443
diff
changeset
|
1108 rev->pending_eof = 1; |
8442
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
1109 qs->final_size = last; |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
1110 } |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
1111 |
8444
7d32c3c93678
QUIC: call stream read handler on new data arrival.
Roman Arutyunyan <arut@nginx.com>
parents:
8443
diff
changeset
|
1112 if (ngx_quic_order_bufs(c, &qs->in, frame->data, |
7d32c3c93678
QUIC: call stream read handler on new data arrival.
Roman Arutyunyan <arut@nginx.com>
parents:
8443
diff
changeset
|
1113 f->offset - qs->recv_offset) |
7d32c3c93678
QUIC: call stream read handler on new data arrival.
Roman Arutyunyan <arut@nginx.com>
parents:
8443
diff
changeset
|
1114 != NGX_OK) |
7d32c3c93678
QUIC: call stream read handler on new data arrival.
Roman Arutyunyan <arut@nginx.com>
parents:
8443
diff
changeset
|
1115 { |
7d32c3c93678
QUIC: call stream read handler on new data arrival.
Roman Arutyunyan <arut@nginx.com>
parents:
8443
diff
changeset
|
1116 return NGX_ERROR; |
7d32c3c93678
QUIC: call stream read handler on new data arrival.
Roman Arutyunyan <arut@nginx.com>
parents:
8443
diff
changeset
|
1117 } |
7d32c3c93678
QUIC: call stream read handler on new data arrival.
Roman Arutyunyan <arut@nginx.com>
parents:
8443
diff
changeset
|
1118 |
7d32c3c93678
QUIC: call stream read handler on new data arrival.
Roman Arutyunyan <arut@nginx.com>
parents:
8443
diff
changeset
|
1119 if (f->offset == qs->recv_offset) { |
7d32c3c93678
QUIC: call stream read handler on new data arrival.
Roman Arutyunyan <arut@nginx.com>
parents:
8443
diff
changeset
|
1120 rev->ready = 1; |
7d32c3c93678
QUIC: call stream read handler on new data arrival.
Roman Arutyunyan <arut@nginx.com>
parents:
8443
diff
changeset
|
1121 |
7d32c3c93678
QUIC: call stream read handler on new data arrival.
Roman Arutyunyan <arut@nginx.com>
parents:
8443
diff
changeset
|
1122 if (rev->active) { |
7d32c3c93678
QUIC: call stream read handler on new data arrival.
Roman Arutyunyan <arut@nginx.com>
parents:
8443
diff
changeset
|
1123 rev->handler(rev); |
7d32c3c93678
QUIC: call stream read handler on new data arrival.
Roman Arutyunyan <arut@nginx.com>
parents:
8443
diff
changeset
|
1124 } |
7d32c3c93678
QUIC: call stream read handler on new data arrival.
Roman Arutyunyan <arut@nginx.com>
parents:
8443
diff
changeset
|
1125 } |
7d32c3c93678
QUIC: call stream read handler on new data arrival.
Roman Arutyunyan <arut@nginx.com>
parents:
8443
diff
changeset
|
1126 |
7d32c3c93678
QUIC: call stream read handler on new data arrival.
Roman Arutyunyan <arut@nginx.com>
parents:
8443
diff
changeset
|
1127 return NGX_OK; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1128 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1129 cleanup: |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1130 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1131 pool = sc->pool; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1132 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1133 ngx_close_connection(sc); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1134 ngx_destroy_pool(pool); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1135 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1136 return NGX_ERROR; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1137 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1138 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1139 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1140 ngx_int_t |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1141 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
|
1142 ngx_quic_max_data_frame_t *f) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1143 { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1144 ngx_event_t *wev; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1145 ngx_rbtree_t *tree; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1146 ngx_rbtree_node_t *node; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1147 ngx_quic_stream_t *qs; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1148 ngx_quic_connection_t *qc; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1149 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1150 qc = ngx_quic_get_connection(c); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1151 tree = &qc->streams.tree; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1152 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1153 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
|
1154 return NGX_OK; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1155 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1156 |
8596
1f7f98638dc2
QUIC: fixed null pointer dereference in MAX_DATA handler.
Mariano Di Martino <mariano.dimartino@uhasselt.be>
parents:
8553
diff
changeset
|
1157 if (tree->root != tree->sentinel |
1f7f98638dc2
QUIC: fixed null pointer dereference in MAX_DATA handler.
Mariano Di Martino <mariano.dimartino@uhasselt.be>
parents:
8553
diff
changeset
|
1158 && qc->streams.sent >= qc->streams.send_max_data) |
1f7f98638dc2
QUIC: fixed null pointer dereference in MAX_DATA handler.
Mariano Di Martino <mariano.dimartino@uhasselt.be>
parents:
8553
diff
changeset
|
1159 { |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1160 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1161 for (node = ngx_rbtree_min(tree->root, tree->sentinel); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1162 node; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1163 node = ngx_rbtree_next(tree, node)) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1164 { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1165 qs = (ngx_quic_stream_t *) node; |
8420
baf9551b4a5b
QUIC: renamed stream field from c to connection.
Roman Arutyunyan <arut@nginx.com>
parents:
8416
diff
changeset
|
1166 wev = qs->connection->write; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1167 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1168 if (wev->active) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1169 wev->ready = 1; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1170 ngx_post_event(wev, &ngx_posted_events); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1171 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1172 } |
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 qc->streams.send_max_data = f->max_data; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1176 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1177 return NGX_OK; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1178 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1179 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1180 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1181 ngx_int_t |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1182 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
|
1183 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
|
1184 { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1185 return NGX_OK; |
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 |
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 ngx_int_t |
8698
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
1190 ngx_quic_handle_data_blocked_frame(ngx_connection_t *c, |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
1191 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:
8697
diff
changeset
|
1192 { |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
1193 return ngx_quic_update_max_data(c); |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
1194 } |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
1195 |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
1196 |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
1197 ngx_int_t |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1198 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
|
1199 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
|
1200 { |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
1201 ngx_quic_stream_t *qs; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1202 ngx_quic_connection_t *qc; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1203 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1204 qc = ngx_quic_get_connection(c); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1205 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1206 if ((f->id & NGX_QUIC_STREAM_UNIDIRECTIONAL) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1207 && (f->id & NGX_QUIC_STREAM_SERVER_INITIATED)) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1208 { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1209 qc->error = NGX_QUIC_ERR_STREAM_STATE_ERROR; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1210 return NGX_ERROR; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1211 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1212 |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
1213 qs = ngx_quic_find_stream(&qc->streams.tree, f->id); |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1214 |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
1215 if (qs == NULL) { |
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
1216 qs = ngx_quic_create_client_stream(c, f->id); |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1217 |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
1218 if (qs == NULL) { |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1219 return NGX_ERROR; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1220 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1221 |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
1222 if (qs == NGX_QUIC_STREAM_GONE) { |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1223 return NGX_OK; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1224 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1225 |
8697
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8695
diff
changeset
|
1226 return ngx_quic_init_stream(qs); |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1227 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1228 |
8697
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8695
diff
changeset
|
1229 return ngx_quic_update_max_stream_data(qs->connection); |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1230 } |
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 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1233 ngx_int_t |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1234 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
|
1235 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
|
1236 { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1237 uint64_t sent; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1238 ngx_event_t *wev; |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
1239 ngx_quic_stream_t *qs; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1240 ngx_quic_connection_t *qc; |
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 qc = ngx_quic_get_connection(c); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1243 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1244 if ((f->id & NGX_QUIC_STREAM_UNIDIRECTIONAL) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1245 && (f->id & NGX_QUIC_STREAM_SERVER_INITIATED) == 0) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1246 { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1247 qc->error = NGX_QUIC_ERR_STREAM_STATE_ERROR; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1248 return NGX_ERROR; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1249 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1250 |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
1251 qs = ngx_quic_find_stream(&qc->streams.tree, f->id); |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1252 |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
1253 if (qs == NULL) { |
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
1254 qs = ngx_quic_create_client_stream(c, f->id); |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1255 |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
1256 if (qs == NULL) { |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1257 return NGX_ERROR; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1258 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1259 |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
1260 if (qs == NGX_QUIC_STREAM_GONE) { |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1261 return NGX_OK; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1262 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1263 |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
1264 if (f->limit > qs->send_max_data) { |
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
1265 qs->send_max_data = f->limit; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1266 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1267 |
8552
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
1268 return ngx_quic_init_stream(qs); |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1269 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1270 |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
1271 if (f->limit <= qs->send_max_data) { |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1272 return NGX_OK; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1273 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1274 |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
1275 sent = qs->connection->sent; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1276 |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
1277 if (sent >= qs->send_max_data) { |
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
1278 wev = qs->connection->write; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1279 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1280 if (wev->active) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1281 wev->ready = 1; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1282 ngx_post_event(wev, &ngx_posted_events); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1283 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1284 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1285 |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
1286 qs->send_max_data = f->limit; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1287 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1288 return NGX_OK; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1289 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1290 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1291 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1292 ngx_int_t |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1293 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
|
1294 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
|
1295 { |
8492
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1296 ngx_pool_t *pool; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1297 ngx_event_t *rev; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1298 ngx_connection_t *sc; |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
1299 ngx_quic_stream_t *qs; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1300 ngx_quic_connection_t *qc; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1301 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1302 qc = ngx_quic_get_connection(c); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1303 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1304 if ((f->id & NGX_QUIC_STREAM_UNIDIRECTIONAL) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1305 && (f->id & NGX_QUIC_STREAM_SERVER_INITIATED)) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1306 { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1307 qc->error = NGX_QUIC_ERR_STREAM_STATE_ERROR; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1308 return NGX_ERROR; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1309 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1310 |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
1311 qs = ngx_quic_find_stream(&qc->streams.tree, f->id); |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1312 |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
1313 if (qs == NULL) { |
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
1314 qs = ngx_quic_create_client_stream(c, f->id); |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1315 |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
1316 if (qs == NULL) { |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1317 return NGX_ERROR; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1318 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1319 |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
1320 if (qs == NGX_QUIC_STREAM_GONE) { |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1321 return NGX_OK; |
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 |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
1324 sc = qs->connection; |
8410
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 rev = sc->read; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1327 rev->error = 1; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1328 rev->ready = 1; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1329 |
8492
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1330 if (ngx_quic_control_flow(sc, f->final_size) != NGX_OK) { |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1331 goto cleanup; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1332 } |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1333 |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1334 qs->final_size = f->final_size; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1335 |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1336 if (ngx_quic_update_flow(sc, qs->final_size) != NGX_OK) { |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1337 goto cleanup; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1338 } |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1339 |
8552
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
1340 return ngx_quic_init_stream(qs); |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1341 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1342 |
8492
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1343 sc = qs->connection; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1344 |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1345 rev = sc->read; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1346 rev->error = 1; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1347 rev->ready = 1; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1348 |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1349 if (ngx_quic_control_flow(sc, f->final_size) != NGX_OK) { |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1350 return NGX_ERROR; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1351 } |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1352 |
8442
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
1353 if (qs->final_size != (uint64_t) -1 && qs->final_size != f->final_size) { |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
1354 qc->error = NGX_QUIC_ERR_FINAL_SIZE_ERROR; |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
1355 return NGX_ERROR; |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
1356 } |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
1357 |
8443
60c6e8d8d3ae
QUIC: make sure stream data size is lower than final size.
Roman Arutyunyan <arut@nginx.com>
parents:
8442
diff
changeset
|
1358 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:
8442
diff
changeset
|
1359 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:
8442
diff
changeset
|
1360 return NGX_ERROR; |
60c6e8d8d3ae
QUIC: make sure stream data size is lower than final size.
Roman Arutyunyan <arut@nginx.com>
parents:
8442
diff
changeset
|
1361 } |
60c6e8d8d3ae
QUIC: make sure stream data size is lower than final size.
Roman Arutyunyan <arut@nginx.com>
parents:
8442
diff
changeset
|
1362 |
8442
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
1363 qs->final_size = f->final_size; |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
1364 |
8492
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1365 if (ngx_quic_update_flow(sc, qs->final_size) != NGX_OK) { |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1366 return NGX_ERROR; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1367 } |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1368 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1369 if (rev->active) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1370 rev->handler(rev); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1371 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1372 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1373 return NGX_OK; |
8492
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1374 |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1375 cleanup: |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1376 |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1377 pool = sc->pool; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1378 |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1379 ngx_close_connection(sc); |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1380 ngx_destroy_pool(pool); |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1381 |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1382 return NGX_ERROR; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1383 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1384 |
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 ngx_int_t |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1387 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
|
1388 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
|
1389 { |
8638
1ead7d64e993
QUIC: send RESET_STREAM in response to STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8637
diff
changeset
|
1390 ngx_pool_t *pool; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1391 ngx_event_t *wev; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1392 ngx_connection_t *sc; |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
1393 ngx_quic_stream_t *qs; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1394 ngx_quic_connection_t *qc; |
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 qc = ngx_quic_get_connection(c); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1397 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1398 if ((f->id & NGX_QUIC_STREAM_UNIDIRECTIONAL) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1399 && (f->id & NGX_QUIC_STREAM_SERVER_INITIATED) == 0) |
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 qc->error = NGX_QUIC_ERR_STREAM_STATE_ERROR; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1402 return NGX_ERROR; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1403 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1404 |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
1405 qs = ngx_quic_find_stream(&qc->streams.tree, f->id); |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1406 |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
1407 if (qs == NULL) { |
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
1408 qs = ngx_quic_create_client_stream(c, f->id); |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1409 |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
1410 if (qs == NULL) { |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1411 return NGX_ERROR; |
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 |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
1414 if (qs == NGX_QUIC_STREAM_GONE) { |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1415 return NGX_OK; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1416 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1417 |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
1418 sc = qs->connection; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1419 |
8638
1ead7d64e993
QUIC: send RESET_STREAM in response to STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8637
diff
changeset
|
1420 if (ngx_quic_reset_stream(sc, f->error_code) != NGX_OK) { |
1ead7d64e993
QUIC: send RESET_STREAM in response to STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8637
diff
changeset
|
1421 pool = sc->pool; |
1ead7d64e993
QUIC: send RESET_STREAM in response to STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8637
diff
changeset
|
1422 |
1ead7d64e993
QUIC: send RESET_STREAM in response to STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8637
diff
changeset
|
1423 ngx_close_connection(sc); |
1ead7d64e993
QUIC: send RESET_STREAM in response to STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8637
diff
changeset
|
1424 ngx_destroy_pool(pool); |
1ead7d64e993
QUIC: send RESET_STREAM in response to STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8637
diff
changeset
|
1425 |
1ead7d64e993
QUIC: send RESET_STREAM in response to STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8637
diff
changeset
|
1426 return NGX_ERROR; |
1ead7d64e993
QUIC: send RESET_STREAM in response to STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8637
diff
changeset
|
1427 } |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1428 |
8552
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
1429 return ngx_quic_init_stream(qs); |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1430 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1431 |
8638
1ead7d64e993
QUIC: send RESET_STREAM in response to STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8637
diff
changeset
|
1432 if (ngx_quic_reset_stream(qs->connection, f->error_code) != NGX_OK) { |
1ead7d64e993
QUIC: send RESET_STREAM in response to STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8637
diff
changeset
|
1433 return NGX_ERROR; |
1ead7d64e993
QUIC: send RESET_STREAM in response to STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8637
diff
changeset
|
1434 } |
1ead7d64e993
QUIC: send RESET_STREAM in response to STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8637
diff
changeset
|
1435 |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
1436 wev = qs->connection->write; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1437 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1438 if (wev->active) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1439 wev->handler(wev); |
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 return NGX_OK; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1443 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1444 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1445 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1446 ngx_int_t |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1447 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
|
1448 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
|
1449 { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1450 ngx_quic_connection_t *qc; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1451 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1452 qc = ngx_quic_get_connection(c); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1453 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1454 if (f->bidi) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1455 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
|
1456 qc->streams.server_max_streams_bidi = f->limit; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1457 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1458 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
|
1459 "quic max_streams_bidi:%uL", f->limit); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1460 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1461 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1462 } else { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1463 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
|
1464 qc->streams.server_max_streams_uni = f->limit; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1465 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1466 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
|
1467 "quic max_streams_uni:%uL", f->limit); |
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 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1470 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1471 return NGX_OK; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1472 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1473 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1474 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1475 void |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1476 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
|
1477 { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1478 uint64_t sent, unacked; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1479 ngx_event_t *wev; |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
1480 ngx_quic_stream_t *qs; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1481 ngx_quic_connection_t *qc; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1482 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1483 qc = ngx_quic_get_connection(c); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1484 |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
1485 qs = ngx_quic_find_stream(&qc->streams.tree, f->u.stream.stream_id); |
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
1486 if (qs == NULL) { |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1487 return; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1488 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1489 |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
1490 wev = qs->connection->write; |
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
1491 sent = qs->connection->sent; |
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
1492 unacked = sent - qs->acked; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1493 |
8713
d6ef13c5fd8e
QUIC: simplified configuration.
Vladimir Homutov <vl@nginx.com>
parents:
8698
diff
changeset
|
1494 if (unacked >= qc->conf->stream_buffer_size && wev->active) { |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1495 wev->ready = 1; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1496 ngx_post_event(wev, &ngx_posted_events); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1497 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1498 |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
1499 qs->acked += f->u.stream.length; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1500 |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
1501 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, qs->connection->log, 0, |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1502 "quic stream ack len:%uL acked:%uL unacked:%uL", |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
1503 f->u.stream.length, qs->acked, sent - qs->acked); |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1504 } |
8492
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1505 |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1506 |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1507 static ngx_int_t |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1508 ngx_quic_control_flow(ngx_connection_t *c, uint64_t last) |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1509 { |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1510 uint64_t len; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1511 ngx_event_t *rev; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1512 ngx_quic_stream_t *qs; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1513 ngx_quic_connection_t *qc; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1514 |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1515 rev = c->read; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1516 qs = c->quic; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1517 qc = ngx_quic_get_connection(qs->parent); |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1518 |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1519 if (last <= qs->recv_last) { |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1520 return NGX_OK; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1521 } |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1522 |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1523 len = last - qs->recv_last; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1524 |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1525 ngx_log_debug4(NGX_LOG_DEBUG_EVENT, c->log, 0, |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1526 "quic flow control msd:%uL/%uL md:%uL/%uL", |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1527 last, qs->recv_max_data, qc->streams.recv_last + len, |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1528 qc->streams.recv_max_data); |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1529 |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1530 qs->recv_last += len; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1531 |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1532 if (!rev->error && qs->recv_last > qs->recv_max_data) { |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1533 qc->error = NGX_QUIC_ERR_FLOW_CONTROL_ERROR; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1534 return NGX_ERROR; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1535 } |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1536 |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1537 qc->streams.recv_last += len; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1538 |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1539 if (qc->streams.recv_last > qc->streams.recv_max_data) { |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1540 qc->error = NGX_QUIC_ERR_FLOW_CONTROL_ERROR; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1541 return NGX_ERROR; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1542 } |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1543 |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1544 return NGX_OK; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1545 } |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1546 |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1547 |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1548 static ngx_int_t |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1549 ngx_quic_update_flow(ngx_connection_t *c, uint64_t last) |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1550 { |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1551 uint64_t len; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1552 ngx_event_t *rev; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1553 ngx_connection_t *pc; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1554 ngx_quic_stream_t *qs; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1555 ngx_quic_connection_t *qc; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1556 |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1557 rev = c->read; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1558 qs = c->quic; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1559 pc = qs->parent; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1560 qc = ngx_quic_get_connection(pc); |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1561 |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1562 if (last <= qs->recv_offset) { |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1563 return NGX_OK; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1564 } |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1565 |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1566 len = last - qs->recv_offset; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1567 |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1568 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1569 "quic flow update %uL", last); |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1570 |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1571 qs->recv_offset += len; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1572 |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1573 if (!rev->pending_eof && !rev->error |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1574 && qs->recv_max_data <= qs->recv_offset + qs->recv_window / 2) |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1575 { |
8697
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8695
diff
changeset
|
1576 if (ngx_quic_update_max_stream_data(c) != NGX_OK) { |
8492
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1577 return NGX_ERROR; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1578 } |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1579 } |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1580 |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1581 qc->streams.recv_offset += len; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1582 |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1583 if (qc->streams.recv_max_data |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1584 <= qc->streams.recv_offset + qc->streams.recv_window / 2) |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1585 { |
8698
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
1586 if (ngx_quic_update_max_data(pc) != NGX_OK) { |
8492
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1587 return NGX_ERROR; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1588 } |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1589 } |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1590 |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1591 return NGX_OK; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1592 } |
8617
9ae239d2547d
QUIC: separate event handling functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8597
diff
changeset
|
1593 |
9ae239d2547d
QUIC: separate event handling functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8597
diff
changeset
|
1594 |
8697
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8695
diff
changeset
|
1595 static ngx_int_t |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8695
diff
changeset
|
1596 ngx_quic_update_max_stream_data(ngx_connection_t *c) |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8695
diff
changeset
|
1597 { |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8695
diff
changeset
|
1598 uint64_t recv_max_data; |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8695
diff
changeset
|
1599 ngx_connection_t *pc; |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8695
diff
changeset
|
1600 ngx_quic_frame_t *frame; |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8695
diff
changeset
|
1601 ngx_quic_stream_t *qs; |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8695
diff
changeset
|
1602 ngx_quic_connection_t *qc; |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8695
diff
changeset
|
1603 |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8695
diff
changeset
|
1604 qs = c->quic; |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8695
diff
changeset
|
1605 pc = qs->parent; |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8695
diff
changeset
|
1606 qc = ngx_quic_get_connection(pc); |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8695
diff
changeset
|
1607 |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8695
diff
changeset
|
1608 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:
8695
diff
changeset
|
1609 |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8695
diff
changeset
|
1610 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:
8695
diff
changeset
|
1611 return NGX_OK; |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8695
diff
changeset
|
1612 } |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8695
diff
changeset
|
1613 |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8695
diff
changeset
|
1614 qs->recv_max_data = recv_max_data; |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8695
diff
changeset
|
1615 |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8695
diff
changeset
|
1616 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8695
diff
changeset
|
1617 "quic flow update msd:%uL", qs->recv_max_data); |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8695
diff
changeset
|
1618 |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8695
diff
changeset
|
1619 frame = ngx_quic_alloc_frame(pc); |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8695
diff
changeset
|
1620 if (frame == NULL) { |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8695
diff
changeset
|
1621 return NGX_ERROR; |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8695
diff
changeset
|
1622 } |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8695
diff
changeset
|
1623 |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8695
diff
changeset
|
1624 frame->level = ssl_encryption_application; |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8695
diff
changeset
|
1625 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:
8695
diff
changeset
|
1626 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:
8695
diff
changeset
|
1627 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:
8695
diff
changeset
|
1628 |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8695
diff
changeset
|
1629 ngx_quic_queue_frame(qc, frame); |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8695
diff
changeset
|
1630 |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8695
diff
changeset
|
1631 return NGX_OK; |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8695
diff
changeset
|
1632 } |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8695
diff
changeset
|
1633 |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8695
diff
changeset
|
1634 |
8698
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
1635 static ngx_int_t |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
1636 ngx_quic_update_max_data(ngx_connection_t *c) |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
1637 { |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
1638 uint64_t recv_max_data; |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
1639 ngx_quic_frame_t *frame; |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
1640 ngx_quic_connection_t *qc; |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
1641 |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
1642 qc = ngx_quic_get_connection(c); |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
1643 |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
1644 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:
8697
diff
changeset
|
1645 |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
1646 if (qc->streams.recv_max_data == recv_max_data) { |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
1647 return NGX_OK; |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
1648 } |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
1649 |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
1650 qc->streams.recv_max_data = recv_max_data; |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
1651 |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
1652 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
1653 "quic flow update md:%uL", qc->streams.recv_max_data); |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
1654 |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
1655 frame = ngx_quic_alloc_frame(c); |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
1656 if (frame == NULL) { |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
1657 return NGX_ERROR; |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
1658 } |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
1659 |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
1660 frame->level = ssl_encryption_application; |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
1661 frame->type = NGX_QUIC_FT_MAX_DATA; |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
1662 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:
8697
diff
changeset
|
1663 |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
1664 ngx_quic_queue_frame(qc, frame); |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
1665 |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
1666 return NGX_OK; |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
1667 } |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
1668 |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
1669 |
8617
9ae239d2547d
QUIC: separate event handling functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8597
diff
changeset
|
1670 ngx_int_t |
9ae239d2547d
QUIC: separate event handling functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8597
diff
changeset
|
1671 ngx_quic_handle_read_event(ngx_event_t *rev, ngx_uint_t flags) |
9ae239d2547d
QUIC: separate event handling functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8597
diff
changeset
|
1672 { |
9ae239d2547d
QUIC: separate event handling functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8597
diff
changeset
|
1673 if (!rev->active && !rev->ready) { |
9ae239d2547d
QUIC: separate event handling functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8597
diff
changeset
|
1674 rev->active = 1; |
9ae239d2547d
QUIC: separate event handling functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8597
diff
changeset
|
1675 |
9ae239d2547d
QUIC: separate event handling functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8597
diff
changeset
|
1676 } else if (rev->active && (rev->ready || (flags & NGX_CLOSE_EVENT))) { |
9ae239d2547d
QUIC: separate event handling functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8597
diff
changeset
|
1677 rev->active = 0; |
9ae239d2547d
QUIC: separate event handling functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8597
diff
changeset
|
1678 } |
9ae239d2547d
QUIC: separate event handling functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8597
diff
changeset
|
1679 |
9ae239d2547d
QUIC: separate event handling functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8597
diff
changeset
|
1680 return NGX_OK; |
9ae239d2547d
QUIC: separate event handling functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8597
diff
changeset
|
1681 } |
9ae239d2547d
QUIC: separate event handling functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8597
diff
changeset
|
1682 |
9ae239d2547d
QUIC: separate event handling functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8597
diff
changeset
|
1683 |
9ae239d2547d
QUIC: separate event handling functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8597
diff
changeset
|
1684 ngx_int_t |
9ae239d2547d
QUIC: separate event handling functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8597
diff
changeset
|
1685 ngx_quic_handle_write_event(ngx_event_t *wev, size_t lowat) |
9ae239d2547d
QUIC: separate event handling functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8597
diff
changeset
|
1686 { |
9ae239d2547d
QUIC: separate event handling functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8597
diff
changeset
|
1687 if (!wev->active && !wev->ready) { |
9ae239d2547d
QUIC: separate event handling functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8597
diff
changeset
|
1688 wev->active = 1; |
9ae239d2547d
QUIC: separate event handling functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8597
diff
changeset
|
1689 |
9ae239d2547d
QUIC: separate event handling functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8597
diff
changeset
|
1690 } else if (wev->active && wev->ready) { |
9ae239d2547d
QUIC: separate event handling functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8597
diff
changeset
|
1691 wev->active = 0; |
9ae239d2547d
QUIC: separate event handling functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8597
diff
changeset
|
1692 } |
9ae239d2547d
QUIC: separate event handling functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8597
diff
changeset
|
1693 |
9ae239d2547d
QUIC: separate event handling functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8597
diff
changeset
|
1694 return NGX_OK; |
9ae239d2547d
QUIC: separate event handling functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8597
diff
changeset
|
1695 } |