Mercurial > hg > nginx-quic
annotate src/event/quic/ngx_event_quic_streams.c @ 8954:41796b6804d9 quic
QUIC: support for setting QUIC methods with LibreSSL.
Setting QUIC methods is converted to use C99 designated initializers
for simplicity, as LibreSSL 3.6.0 has different SSL_QUIC_METHOD layout.
Additionally, only set_read_secret/set_write_secret callbacks are set.
Although they are preferred in LibreSSL over set_encryption_secrets,
better be on a safe side as LibreSSL has unexpectedly incompatible
set_encryption_secrets calling convention expressed in passing read
and write secrets split in separate calls, unlike this is documented
in old BoringSSL sources. To avoid introducing further changes for
the old API, it is simply disabled.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Thu, 20 Oct 2022 16:21:06 +0400 |
parents | 489c2dcb3180 |
children | c6580dce98a8 |
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 |
8855 | 16 static ngx_int_t ngx_quic_do_reset_stream(ngx_quic_stream_t *qs, |
17 ngx_uint_t err); | |
8727
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8726
diff
changeset
|
18 static ngx_int_t ngx_quic_shutdown_stream_send(ngx_connection_t *c); |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8726
diff
changeset
|
19 static ngx_int_t ngx_quic_shutdown_stream_recv(ngx_connection_t *c); |
8726
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8725
diff
changeset
|
20 static ngx_quic_stream_t *ngx_quic_get_stream(ngx_connection_t *c, uint64_t id); |
8695
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
21 static ngx_int_t ngx_quic_reject_stream(ngx_connection_t *c, uint64_t id); |
8726
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8725
diff
changeset
|
22 static void ngx_quic_init_stream_handler(ngx_event_t *ev); |
8648
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8638
diff
changeset
|
23 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
|
24 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
|
25 uint64_t id); |
8552
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
26 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
|
27 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
|
28 size_t size); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
29 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
|
30 size_t size); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
31 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
|
32 ngx_chain_t *in, off_t limit); |
8855 | 33 static ngx_int_t ngx_quic_stream_flush(ngx_quic_stream_t *qs); |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
34 static void ngx_quic_stream_cleanup_handler(void *data); |
8855 | 35 static ngx_int_t ngx_quic_close_stream(ngx_quic_stream_t *qs); |
36 static ngx_int_t ngx_quic_control_flow(ngx_quic_stream_t *qs, uint64_t last); | |
37 static ngx_int_t ngx_quic_update_flow(ngx_quic_stream_t *qs, uint64_t last); | |
38 static ngx_int_t ngx_quic_update_max_stream_data(ngx_quic_stream_t *qs); | |
8698
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
39 static ngx_int_t ngx_quic_update_max_data(ngx_connection_t *c); |
8828
7626aa7a2156
QUIC: stream event setting function.
Roman Arutyunyan <arut@nginx.com>
parents:
8825
diff
changeset
|
40 static void ngx_quic_set_event(ngx_event_t *ev); |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
41 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
42 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
43 ngx_connection_t * |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
44 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
|
45 { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
46 uint64_t id; |
8823
6434160b4b78
QUIC: allowed main QUIC connection for some operations.
Roman Arutyunyan <arut@nginx.com>
parents:
8794
diff
changeset
|
47 ngx_connection_t *pc; |
6434160b4b78
QUIC: allowed main QUIC connection for some operations.
Roman Arutyunyan <arut@nginx.com>
parents:
8794
diff
changeset
|
48 ngx_quic_stream_t *nqs; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
49 ngx_quic_connection_t *qc; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
50 |
8823
6434160b4b78
QUIC: allowed main QUIC connection for some operations.
Roman Arutyunyan <arut@nginx.com>
parents:
8794
diff
changeset
|
51 pc = c->quic ? c->quic->parent : c; |
6434160b4b78
QUIC: allowed main QUIC connection for some operations.
Roman Arutyunyan <arut@nginx.com>
parents:
8794
diff
changeset
|
52 qc = ngx_quic_get_connection(pc); |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
53 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
54 if (bidi) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
55 if (qc->streams.server_streams_bidi |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
56 >= qc->streams.server_max_streams_bidi) |
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 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
|
59 "quic too many server bidi streams:%uL", |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
60 qc->streams.server_streams_bidi); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
61 return NULL; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
62 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
63 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
64 id = (qc->streams.server_streams_bidi << 2) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
65 | NGX_QUIC_STREAM_SERVER_INITIATED; |
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 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
|
68 "quic creating server bidi stream" |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
69 " streams:%uL max:%uL id:0x%xL", |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
70 qc->streams.server_streams_bidi, |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
71 qc->streams.server_max_streams_bidi, id); |
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 qc->streams.server_streams_bidi++; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
74 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
75 } else { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
76 if (qc->streams.server_streams_uni |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
77 >= qc->streams.server_max_streams_uni) |
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 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
|
80 "quic too many server uni streams:%uL", |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
81 qc->streams.server_streams_uni); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
82 return NULL; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
83 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
84 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
85 id = (qc->streams.server_streams_uni << 2) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
86 | NGX_QUIC_STREAM_SERVER_INITIATED |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
87 | NGX_QUIC_STREAM_UNIDIRECTIONAL; |
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 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
|
90 "quic creating server uni stream" |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
91 " streams:%uL max:%uL id:0x%xL", |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
92 qc->streams.server_streams_uni, |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
93 qc->streams.server_max_streams_uni, id); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
94 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
95 qc->streams.server_streams_uni++; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
96 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
97 |
8823
6434160b4b78
QUIC: allowed main QUIC connection for some operations.
Roman Arutyunyan <arut@nginx.com>
parents:
8794
diff
changeset
|
98 nqs = ngx_quic_create_stream(pc, id); |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
99 if (nqs == NULL) { |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
100 return NULL; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
101 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
102 |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
103 return nqs->connection; |
8410
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 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
106 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
107 void |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
108 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
|
109 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
|
110 { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
111 ngx_rbtree_node_t **p; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
112 ngx_quic_stream_t *qn, *qnt; |
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 for ( ;; ) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
115 qn = (ngx_quic_stream_t *) node; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
116 qnt = (ngx_quic_stream_t *) temp; |
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 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
|
119 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
120 if (*p == sentinel) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
121 break; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
122 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
123 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
124 temp = *p; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
125 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
126 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
127 *p = node; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
128 node->parent = temp; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
129 node->left = sentinel; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
130 node->right = sentinel; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
131 ngx_rbt_red(node); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
132 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
133 |
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 ngx_quic_stream_t * |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
136 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
|
137 { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
138 ngx_rbtree_node_t *node, *sentinel; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
139 ngx_quic_stream_t *qn; |
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 node = rbtree->root; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
142 sentinel = rbtree->sentinel; |
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 while (node != sentinel) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
145 qn = (ngx_quic_stream_t *) node; |
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 if (id == qn->id) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
148 return qn; |
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 node = (id < qn->id) ? node->left : node->right; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
152 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
153 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
154 return NULL; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
155 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
156 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
157 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
158 ngx_int_t |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
159 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
|
160 { |
8552
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
161 ngx_pool_t *pool; |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
162 ngx_queue_t *q; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
163 ngx_rbtree_t *tree; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
164 ngx_rbtree_node_t *node; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
165 ngx_quic_stream_t *qs; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
166 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
167 #if (NGX_DEBUG) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
168 ngx_uint_t ns; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
169 #endif |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
170 |
8552
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
171 while (!ngx_queue_empty(&qc->streams.uninitialized)) { |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
172 q = ngx_queue_head(&qc->streams.uninitialized); |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
173 ngx_queue_remove(q); |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
174 |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
175 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
|
176 pool = qs->connection->pool; |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
177 |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
178 ngx_close_connection(qs->connection); |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
179 ngx_destroy_pool(pool); |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
180 } |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
181 |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
182 tree = &qc->streams.tree; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
183 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
184 if (tree->root == tree->sentinel) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
185 return NGX_OK; |
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 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
188 #if (NGX_DEBUG) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
189 ns = 0; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
190 #endif |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
191 |
8855 | 192 node = ngx_rbtree_min(tree->root, tree->sentinel); |
193 | |
194 while (node) { | |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
195 qs = (ngx_quic_stream_t *) node; |
8855 | 196 node = ngx_rbtree_next(tree, node); |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
197 |
8825
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8823
diff
changeset
|
198 qs->recv_state = NGX_QUIC_STREAM_RECV_RESET_RECVD; |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8823
diff
changeset
|
199 qs->send_state = NGX_QUIC_STREAM_SEND_RESET_SENT; |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8823
diff
changeset
|
200 |
8855 | 201 if (qs->connection == NULL) { |
202 ngx_quic_close_stream(qs); | |
203 continue; | |
204 } | |
205 | |
8828
7626aa7a2156
QUIC: stream event setting function.
Roman Arutyunyan <arut@nginx.com>
parents:
8825
diff
changeset
|
206 ngx_quic_set_event(qs->connection->read); |
7626aa7a2156
QUIC: stream event setting function.
Roman Arutyunyan <arut@nginx.com>
parents:
8825
diff
changeset
|
207 ngx_quic_set_event(qs->connection->write); |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
208 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
209 #if (NGX_DEBUG) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
210 ns++; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
211 #endif |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
212 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
213 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
214 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
|
215 "quic connection has %ui active streams", ns); |
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 return NGX_AGAIN; |
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 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
220 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
221 ngx_int_t |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
222 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
|
223 { |
8855 | 224 return ngx_quic_do_reset_stream(c->quic, err); |
225 } | |
226 | |
227 | |
228 static ngx_int_t | |
229 ngx_quic_do_reset_stream(ngx_quic_stream_t *qs, ngx_uint_t err) | |
230 { | |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
231 ngx_connection_t *pc; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
232 ngx_quic_frame_t *frame; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
233 ngx_quic_connection_t *qc; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
234 |
8825
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8823
diff
changeset
|
235 if (qs->send_state == NGX_QUIC_STREAM_SEND_DATA_RECVD |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8823
diff
changeset
|
236 || qs->send_state == NGX_QUIC_STREAM_SEND_RESET_SENT |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8823
diff
changeset
|
237 || qs->send_state == NGX_QUIC_STREAM_SEND_RESET_RECVD) |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8823
diff
changeset
|
238 { |
8637
13cb758e6ac0
QUIC: reset stream only once.
Roman Arutyunyan <arut@nginx.com>
parents:
8623
diff
changeset
|
239 return NGX_OK; |
13cb758e6ac0
QUIC: reset stream only once.
Roman Arutyunyan <arut@nginx.com>
parents:
8623
diff
changeset
|
240 } |
13cb758e6ac0
QUIC: reset stream only once.
Roman Arutyunyan <arut@nginx.com>
parents:
8623
diff
changeset
|
241 |
8825
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8823
diff
changeset
|
242 qs->send_state = NGX_QUIC_STREAM_SEND_RESET_SENT; |
8855 | 243 qs->send_final_size = qs->send_offset; |
8825
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8823
diff
changeset
|
244 |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
245 pc = qs->parent; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
246 qc = ngx_quic_get_connection(pc); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
247 |
8855 | 248 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, pc->log, 0, |
249 "quic stream id:0x%xL reset", qs->id); | |
250 | |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
251 frame = ngx_quic_alloc_frame(pc); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
252 if (frame == NULL) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
253 return NGX_ERROR; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
254 } |
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 frame->level = ssl_encryption_application; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
257 frame->type = NGX_QUIC_FT_RESET_STREAM; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
258 frame->u.reset_stream.id = qs->id; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
259 frame->u.reset_stream.error_code = err; |
8855 | 260 frame->u.reset_stream.final_size = qs->send_offset; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
261 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
262 ngx_quic_queue_frame(qc, frame); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
263 |
8856
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
264 ngx_quic_free_buffer(pc, &qs->send); |
8855 | 265 |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
266 return NGX_OK; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
267 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
268 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
269 |
8679
b4c7853b0488
QUIC: added shutdown support in stream proxy.
Vladimir Homutov <vl@nginx.com>
parents:
8648
diff
changeset
|
270 ngx_int_t |
b4c7853b0488
QUIC: added shutdown support in stream proxy.
Vladimir Homutov <vl@nginx.com>
parents:
8648
diff
changeset
|
271 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
|
272 { |
8727
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8726
diff
changeset
|
273 if (how == NGX_RDWR_SHUTDOWN || how == NGX_WRITE_SHUTDOWN) { |
8825
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8823
diff
changeset
|
274 if (ngx_quic_shutdown_stream_send(c) != NGX_OK) { |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8823
diff
changeset
|
275 return NGX_ERROR; |
8727
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8726
diff
changeset
|
276 } |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8726
diff
changeset
|
277 } |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8726
diff
changeset
|
278 |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8726
diff
changeset
|
279 if (how == NGX_RDWR_SHUTDOWN || how == NGX_READ_SHUTDOWN) { |
8825
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8823
diff
changeset
|
280 if (ngx_quic_shutdown_stream_recv(c) != NGX_OK) { |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8823
diff
changeset
|
281 return NGX_ERROR; |
8727
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8726
diff
changeset
|
282 } |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8726
diff
changeset
|
283 } |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8726
diff
changeset
|
284 |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8726
diff
changeset
|
285 return NGX_OK; |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8726
diff
changeset
|
286 } |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8726
diff
changeset
|
287 |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8726
diff
changeset
|
288 |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8726
diff
changeset
|
289 static ngx_int_t |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8726
diff
changeset
|
290 ngx_quic_shutdown_stream_send(ngx_connection_t *c) |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8726
diff
changeset
|
291 { |
8855 | 292 ngx_quic_stream_t *qs; |
8679
b4c7853b0488
QUIC: added shutdown support in stream proxy.
Vladimir Homutov <vl@nginx.com>
parents:
8648
diff
changeset
|
293 |
8825
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8823
diff
changeset
|
294 qs = c->quic; |
8679
b4c7853b0488
QUIC: added shutdown support in stream proxy.
Vladimir Homutov <vl@nginx.com>
parents:
8648
diff
changeset
|
295 |
8825
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8823
diff
changeset
|
296 if (qs->send_state != NGX_QUIC_STREAM_SEND_READY |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8823
diff
changeset
|
297 && qs->send_state != NGX_QUIC_STREAM_SEND_SEND) |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8823
diff
changeset
|
298 { |
8679
b4c7853b0488
QUIC: added shutdown support in stream proxy.
Vladimir Homutov <vl@nginx.com>
parents:
8648
diff
changeset
|
299 return NGX_OK; |
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 |
8855 | 302 qs->send_state = NGX_QUIC_STREAM_SEND_SEND; |
303 qs->send_final_size = c->sent; | |
8679
b4c7853b0488
QUIC: added shutdown support in stream proxy.
Vladimir Homutov <vl@nginx.com>
parents:
8648
diff
changeset
|
304 |
8855 | 305 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, qs->parent->log, 0, |
8727
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8726
diff
changeset
|
306 "quic stream id:0x%xL send shutdown", qs->id); |
8679
b4c7853b0488
QUIC: added shutdown support in stream proxy.
Vladimir Homutov <vl@nginx.com>
parents:
8648
diff
changeset
|
307 |
8855 | 308 return ngx_quic_stream_flush(qs); |
8679
b4c7853b0488
QUIC: added shutdown support in stream proxy.
Vladimir Homutov <vl@nginx.com>
parents:
8648
diff
changeset
|
309 } |
b4c7853b0488
QUIC: added shutdown support in stream proxy.
Vladimir Homutov <vl@nginx.com>
parents:
8648
diff
changeset
|
310 |
b4c7853b0488
QUIC: added shutdown support in stream proxy.
Vladimir Homutov <vl@nginx.com>
parents:
8648
diff
changeset
|
311 |
8727
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8726
diff
changeset
|
312 static ngx_int_t |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8726
diff
changeset
|
313 ngx_quic_shutdown_stream_recv(ngx_connection_t *c) |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8726
diff
changeset
|
314 { |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8726
diff
changeset
|
315 ngx_connection_t *pc; |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8726
diff
changeset
|
316 ngx_quic_frame_t *frame; |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8726
diff
changeset
|
317 ngx_quic_stream_t *qs; |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8726
diff
changeset
|
318 ngx_quic_connection_t *qc; |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8726
diff
changeset
|
319 |
8825
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8823
diff
changeset
|
320 qs = c->quic; |
8727
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8726
diff
changeset
|
321 |
8825
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8823
diff
changeset
|
322 if (qs->recv_state != NGX_QUIC_STREAM_RECV_RECV |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8823
diff
changeset
|
323 && qs->recv_state != NGX_QUIC_STREAM_RECV_SIZE_KNOWN) |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8823
diff
changeset
|
324 { |
8727
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8726
diff
changeset
|
325 return NGX_OK; |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8726
diff
changeset
|
326 } |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8726
diff
changeset
|
327 |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8726
diff
changeset
|
328 pc = qs->parent; |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8726
diff
changeset
|
329 qc = ngx_quic_get_connection(pc); |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8726
diff
changeset
|
330 |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8726
diff
changeset
|
331 if (qc->conf->stream_close_code == 0) { |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8726
diff
changeset
|
332 return NGX_OK; |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8726
diff
changeset
|
333 } |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8726
diff
changeset
|
334 |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8726
diff
changeset
|
335 frame = ngx_quic_alloc_frame(pc); |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8726
diff
changeset
|
336 if (frame == NULL) { |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8726
diff
changeset
|
337 return NGX_ERROR; |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8726
diff
changeset
|
338 } |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8726
diff
changeset
|
339 |
8855 | 340 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, pc->log, 0, |
8727
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8726
diff
changeset
|
341 "quic stream id:0x%xL recv shutdown", qs->id); |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8726
diff
changeset
|
342 |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8726
diff
changeset
|
343 frame->level = ssl_encryption_application; |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8726
diff
changeset
|
344 frame->type = NGX_QUIC_FT_STOP_SENDING; |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8726
diff
changeset
|
345 frame->u.stop_sending.id = qs->id; |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8726
diff
changeset
|
346 frame->u.stop_sending.error_code = qc->conf->stream_close_code; |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8726
diff
changeset
|
347 |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8726
diff
changeset
|
348 ngx_quic_queue_frame(qc, frame); |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8726
diff
changeset
|
349 |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8726
diff
changeset
|
350 return NGX_OK; |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8726
diff
changeset
|
351 } |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8726
diff
changeset
|
352 |
23880e4ad3e2
QUIC: write and full stream shutdown support.
Roman Arutyunyan <arut@nginx.com>
parents:
8726
diff
changeset
|
353 |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
354 static ngx_quic_stream_t * |
8726
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8725
diff
changeset
|
355 ngx_quic_get_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
|
356 { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
357 uint64_t min_id; |
8726
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8725
diff
changeset
|
358 ngx_event_t *rev; |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
359 ngx_quic_stream_t *qs; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
360 ngx_quic_connection_t *qc; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
361 |
8726
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8725
diff
changeset
|
362 qc = ngx_quic_get_connection(c); |
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8725
diff
changeset
|
363 |
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8725
diff
changeset
|
364 qs = ngx_quic_find_stream(&qc->streams.tree, id); |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
365 |
8726
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8725
diff
changeset
|
366 if (qs) { |
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8725
diff
changeset
|
367 return qs; |
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8725
diff
changeset
|
368 } |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
369 |
8694
832723a49026
QUIC: stop processing new client streams at the closing state.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8679
diff
changeset
|
370 if (qc->shutdown || qc->closing) { |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
371 return NGX_QUIC_STREAM_GONE; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
372 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
373 |
8726
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8725
diff
changeset
|
374 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8725
diff
changeset
|
375 "quic stream id:0x%xL is missing", id); |
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8725
diff
changeset
|
376 |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
377 if (id & NGX_QUIC_STREAM_UNIDIRECTIONAL) { |
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 if (id & NGX_QUIC_STREAM_SERVER_INITIATED) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
380 if ((id >> 2) < qc->streams.server_streams_uni) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
381 return NGX_QUIC_STREAM_GONE; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
382 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
383 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
384 qc->error = NGX_QUIC_ERR_STREAM_STATE_ERROR; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
385 return NULL; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
386 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
387 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
388 if ((id >> 2) < qc->streams.client_streams_uni) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
389 return NGX_QUIC_STREAM_GONE; |
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 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
392 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
|
393 qc->error = NGX_QUIC_ERR_STREAM_LIMIT_ERROR; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
394 return NULL; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
395 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
396 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
397 min_id = (qc->streams.client_streams_uni << 2) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
398 | NGX_QUIC_STREAM_UNIDIRECTIONAL; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
399 qc->streams.client_streams_uni = (id >> 2) + 1; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
400 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
401 } else { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
402 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
403 if (id & NGX_QUIC_STREAM_SERVER_INITIATED) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
404 if ((id >> 2) < qc->streams.server_streams_bidi) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
405 return NGX_QUIC_STREAM_GONE; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
406 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
407 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
408 qc->error = NGX_QUIC_ERR_STREAM_STATE_ERROR; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
409 return NULL; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
410 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
411 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
412 if ((id >> 2) < qc->streams.client_streams_bidi) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
413 return NGX_QUIC_STREAM_GONE; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
414 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
415 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
416 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
|
417 qc->error = NGX_QUIC_ERR_STREAM_LIMIT_ERROR; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
418 return NULL; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
419 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
420 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
421 min_id = (qc->streams.client_streams_bidi << 2); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
422 qc->streams.client_streams_bidi = (id >> 2) + 1; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
423 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
424 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
425 /* |
8498
4715f3e669f1
QUIC: updated specification references.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8492
diff
changeset
|
426 * 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
|
427 * |
8498
4715f3e669f1
QUIC: updated specification references.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8492
diff
changeset
|
428 * successive streams of each type are created with numerically increasing |
4715f3e669f1
QUIC: updated specification references.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8492
diff
changeset
|
429 * 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
|
430 * 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
|
431 */ |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
432 |
8726
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8725
diff
changeset
|
433 #if (NGX_SUPPRESS_WARN) |
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8725
diff
changeset
|
434 qs = NULL; |
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8725
diff
changeset
|
435 #endif |
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8725
diff
changeset
|
436 |
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8725
diff
changeset
|
437 for ( /* void */ ; min_id <= id; min_id += 0x04) { |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
438 |
8439
f52a2b77d406
QUIC: generic buffering for stream input.
Roman Arutyunyan <arut@nginx.com>
parents:
8421
diff
changeset
|
439 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
|
440 |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
441 if (qs == NULL) { |
8695
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
442 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
|
443 return NULL; |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
444 } |
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 continue; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
447 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
448 |
8726
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8725
diff
changeset
|
449 ngx_queue_insert_tail(&qc->streams.uninitialized, &qs->queue); |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
450 |
8726
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8725
diff
changeset
|
451 rev = qs->connection->read; |
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8725
diff
changeset
|
452 rev->handler = ngx_quic_init_stream_handler; |
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8725
diff
changeset
|
453 |
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8725
diff
changeset
|
454 if (qc->streams.initialized) { |
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8725
diff
changeset
|
455 ngx_post_event(rev, &ngx_posted_events); |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
456 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
457 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
458 |
8695
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
459 if (qs == NULL) { |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
460 return NGX_QUIC_STREAM_GONE; |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
461 } |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
462 |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
463 return qs; |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
464 } |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
465 |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
466 |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
467 static ngx_int_t |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
468 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
|
469 { |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
470 uint64_t code; |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
471 ngx_quic_frame_t *frame; |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
472 ngx_quic_connection_t *qc; |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
473 |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
474 qc = ngx_quic_get_connection(c); |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
475 |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
476 code = (id & NGX_QUIC_STREAM_UNIDIRECTIONAL) |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
477 ? qc->conf->stream_reject_code_uni |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
478 : qc->conf->stream_reject_code_bidi; |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
479 |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
480 if (code == 0) { |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
481 return NGX_DECLINED; |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
482 } |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
483 |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
484 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
|
485 "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
|
486 |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
487 frame = ngx_quic_alloc_frame(c); |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
488 if (frame == NULL) { |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
489 return NGX_ERROR; |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
490 } |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
491 |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
492 frame->level = ssl_encryption_application; |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
493 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
|
494 frame->u.reset_stream.id = id; |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
495 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
|
496 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
|
497 |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
498 ngx_quic_queue_frame(qc, frame); |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
499 |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
500 frame = ngx_quic_alloc_frame(c); |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
501 if (frame == NULL) { |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
502 return NGX_ERROR; |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
503 } |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
504 |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
505 frame->level = ssl_encryption_application; |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
506 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
|
507 frame->u.stop_sending.id = id; |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
508 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
|
509 |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
510 ngx_quic_queue_frame(qc, frame); |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
511 |
41caf5410110
QUIC: reject streams which we could not create.
Roman Arutyunyan <arut@nginx.com>
parents:
8694
diff
changeset
|
512 return NGX_OK; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
513 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
514 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
515 |
8726
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8725
diff
changeset
|
516 static void |
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8725
diff
changeset
|
517 ngx_quic_init_stream_handler(ngx_event_t *ev) |
8552
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
518 { |
8726
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8725
diff
changeset
|
519 ngx_connection_t *c; |
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8725
diff
changeset
|
520 ngx_quic_stream_t *qs; |
8552
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
521 |
8726
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8725
diff
changeset
|
522 c = ev->data; |
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8725
diff
changeset
|
523 qs = c->quic; |
8552
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
524 |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
525 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
|
526 |
8726
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8725
diff
changeset
|
527 ngx_queue_remove(&qs->queue); |
8552
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
528 |
8726
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8725
diff
changeset
|
529 c->listening->handler(c); |
8552
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
530 } |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
531 |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
532 |
8648
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8638
diff
changeset
|
533 ngx_int_t |
8552
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
534 ngx_quic_init_streams(ngx_connection_t *c) |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
535 { |
8648
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8638
diff
changeset
|
536 ngx_int_t rc; |
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8638
diff
changeset
|
537 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
|
538 |
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8638
diff
changeset
|
539 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
|
540 |
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8638
diff
changeset
|
541 if (qc->streams.initialized) { |
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8638
diff
changeset
|
542 return NGX_OK; |
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8638
diff
changeset
|
543 } |
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8638
diff
changeset
|
544 |
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8638
diff
changeset
|
545 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
|
546 |
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8638
diff
changeset
|
547 if (rc == NGX_ERROR) { |
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8638
diff
changeset
|
548 return NGX_ERROR; |
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8638
diff
changeset
|
549 } |
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8638
diff
changeset
|
550 |
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8638
diff
changeset
|
551 if (rc == NGX_AGAIN) { |
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8638
diff
changeset
|
552 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
|
553 return NGX_OK; |
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8638
diff
changeset
|
554 } |
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8638
diff
changeset
|
555 |
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8638
diff
changeset
|
556 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
|
557 |
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8638
diff
changeset
|
558 return NGX_OK; |
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8638
diff
changeset
|
559 } |
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8638
diff
changeset
|
560 |
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8638
diff
changeset
|
561 |
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8638
diff
changeset
|
562 static void |
66b4ff373dd9
QUIC: refactored OCSP validation in preparation for 0-RTT support.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8638
diff
changeset
|
563 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
|
564 { |
8552
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
565 ngx_queue_t *q; |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
566 ngx_quic_stream_t *qs; |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
567 ngx_quic_connection_t *qc; |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
568 |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
569 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
|
570 |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
571 qc = ngx_quic_get_connection(c); |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
572 |
8726
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8725
diff
changeset
|
573 for (q = ngx_queue_head(&qc->streams.uninitialized); |
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8725
diff
changeset
|
574 q != ngx_queue_sentinel(&qc->streams.uninitialized); |
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8725
diff
changeset
|
575 q = ngx_queue_next(q)) |
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8725
diff
changeset
|
576 { |
8552
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
577 qs = ngx_queue_data(q, ngx_quic_stream_t, queue); |
8726
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8725
diff
changeset
|
578 ngx_post_event(qs->connection->read, &ngx_posted_events); |
8552
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
579 } |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
580 |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
581 qc->streams.initialized = 1; |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
582 } |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
583 |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
584 |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
585 static ngx_quic_stream_t * |
8439
f52a2b77d406
QUIC: generic buffering for stream input.
Roman Arutyunyan <arut@nginx.com>
parents:
8421
diff
changeset
|
586 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
|
587 { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
588 ngx_log_t *log; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
589 ngx_pool_t *pool; |
8855 | 590 ngx_queue_t *q; |
8420
baf9551b4a5b
QUIC: renamed stream field from c to connection.
Roman Arutyunyan <arut@nginx.com>
parents:
8416
diff
changeset
|
591 ngx_connection_t *sc; |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
592 ngx_quic_stream_t *qs; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
593 ngx_pool_cleanup_t *cln; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
594 ngx_quic_connection_t *qc; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
595 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
596 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
|
597 "quic stream id:0x%xL create", id); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
598 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
599 qc = ngx_quic_get_connection(c); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
600 |
8855 | 601 if (!ngx_queue_empty(&qc->streams.free)) { |
602 q = ngx_queue_head(&qc->streams.free); | |
603 qs = ngx_queue_data(q, ngx_quic_stream_t, queue); | |
604 ngx_queue_remove(&qs->queue); | |
605 | |
606 } else { | |
607 /* | |
608 * the number of streams is limited by transport | |
609 * parameters and application requirements | |
610 */ | |
611 | |
612 qs = ngx_palloc(c->pool, sizeof(ngx_quic_stream_t)); | |
613 if (qs == NULL) { | |
614 return NULL; | |
615 } | |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
616 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
617 |
8855 | 618 ngx_memzero(qs, sizeof(ngx_quic_stream_t)); |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
619 |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
620 qs->node.key = id; |
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
621 qs->parent = c; |
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
622 qs->id = id; |
8855 | 623 qs->send_final_size = (uint64_t) -1; |
624 qs->recv_final_size = (uint64_t) -1; | |
625 | |
626 pool = ngx_create_pool(NGX_DEFAULT_POOL_SIZE, c->log); | |
627 if (pool == NULL) { | |
628 ngx_queue_insert_tail(&qc->streams.free, &qs->queue); | |
629 return NULL; | |
630 } | |
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 log = ngx_palloc(pool, sizeof(ngx_log_t)); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
633 if (log == NULL) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
634 ngx_destroy_pool(pool); |
8855 | 635 ngx_queue_insert_tail(&qc->streams.free, &qs->queue); |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
636 return NULL; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
637 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
638 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
639 *log = *c->log; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
640 pool->log = log; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
641 |
8622
a2cef164a924
QUIC: simplified stream fd initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8617
diff
changeset
|
642 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
|
643 if (sc == NULL) { |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
644 ngx_destroy_pool(pool); |
8855 | 645 ngx_queue_insert_tail(&qc->streams.free, &qs->queue); |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
646 return NULL; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
647 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
648 |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
649 qs->connection = sc; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
650 |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
651 sc->quic = qs; |
8597
486c6a9be111
QUIC: store QUIC connection fd in stream fake connection.
Roman Arutyunyan <arut@nginx.com>
parents:
8596
diff
changeset
|
652 sc->shared = 1; |
8420
baf9551b4a5b
QUIC: renamed stream field from c to connection.
Roman Arutyunyan <arut@nginx.com>
parents:
8416
diff
changeset
|
653 sc->type = SOCK_STREAM; |
baf9551b4a5b
QUIC: renamed stream field from c to connection.
Roman Arutyunyan <arut@nginx.com>
parents:
8416
diff
changeset
|
654 sc->pool = pool; |
baf9551b4a5b
QUIC: renamed stream field from c to connection.
Roman Arutyunyan <arut@nginx.com>
parents:
8416
diff
changeset
|
655 sc->ssl = c->ssl; |
baf9551b4a5b
QUIC: renamed stream field from c to connection.
Roman Arutyunyan <arut@nginx.com>
parents:
8416
diff
changeset
|
656 sc->sockaddr = c->sockaddr; |
baf9551b4a5b
QUIC: renamed stream field from c to connection.
Roman Arutyunyan <arut@nginx.com>
parents:
8416
diff
changeset
|
657 sc->listening = c->listening; |
baf9551b4a5b
QUIC: renamed stream field from c to connection.
Roman Arutyunyan <arut@nginx.com>
parents:
8416
diff
changeset
|
658 sc->addr_text = c->addr_text; |
baf9551b4a5b
QUIC: renamed stream field from c to connection.
Roman Arutyunyan <arut@nginx.com>
parents:
8416
diff
changeset
|
659 sc->local_sockaddr = c->local_sockaddr; |
baf9551b4a5b
QUIC: renamed stream field from c to connection.
Roman Arutyunyan <arut@nginx.com>
parents:
8416
diff
changeset
|
660 sc->local_socklen = c->local_socklen; |
baf9551b4a5b
QUIC: renamed stream field from c to connection.
Roman Arutyunyan <arut@nginx.com>
parents:
8416
diff
changeset
|
661 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
|
662 sc->tcp_nodelay = NGX_TCP_NODELAY_DISABLED; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
663 |
8420
baf9551b4a5b
QUIC: renamed stream field from c to connection.
Roman Arutyunyan <arut@nginx.com>
parents:
8416
diff
changeset
|
664 sc->recv = ngx_quic_stream_recv; |
baf9551b4a5b
QUIC: renamed stream field from c to connection.
Roman Arutyunyan <arut@nginx.com>
parents:
8416
diff
changeset
|
665 sc->send = ngx_quic_stream_send; |
baf9551b4a5b
QUIC: renamed stream field from c to connection.
Roman Arutyunyan <arut@nginx.com>
parents:
8416
diff
changeset
|
666 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
|
667 |
8420
baf9551b4a5b
QUIC: renamed stream field from c to connection.
Roman Arutyunyan <arut@nginx.com>
parents:
8416
diff
changeset
|
668 sc->read->log = log; |
baf9551b4a5b
QUIC: renamed stream field from c to connection.
Roman Arutyunyan <arut@nginx.com>
parents:
8416
diff
changeset
|
669 sc->write->log = log; |
baf9551b4a5b
QUIC: renamed stream field from c to connection.
Roman Arutyunyan <arut@nginx.com>
parents:
8416
diff
changeset
|
670 |
8552
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
671 sc->read->handler = ngx_quic_empty_handler; |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
672 sc->write->handler = ngx_quic_empty_handler; |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
673 |
8420
baf9551b4a5b
QUIC: renamed stream field from c to connection.
Roman Arutyunyan <arut@nginx.com>
parents:
8416
diff
changeset
|
674 log->connection = sc->number; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
675 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
676 if ((id & NGX_QUIC_STREAM_UNIDIRECTIONAL) == 0 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
677 || (id & NGX_QUIC_STREAM_SERVER_INITIATED)) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
678 { |
8420
baf9551b4a5b
QUIC: renamed stream field from c to connection.
Roman Arutyunyan <arut@nginx.com>
parents:
8416
diff
changeset
|
679 sc->write->ready = 1; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
680 } |
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 (id & NGX_QUIC_STREAM_UNIDIRECTIONAL) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
683 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
|
684 qs->send_max_data = qc->ctp.initial_max_stream_data_uni; |
8825
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8823
diff
changeset
|
685 qs->recv_state = NGX_QUIC_STREAM_RECV_DATA_READ; |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8823
diff
changeset
|
686 qs->send_state = NGX_QUIC_STREAM_SEND_READY; |
8439
f52a2b77d406
QUIC: generic buffering for stream input.
Roman Arutyunyan <arut@nginx.com>
parents:
8421
diff
changeset
|
687 |
f52a2b77d406
QUIC: generic buffering for stream input.
Roman Arutyunyan <arut@nginx.com>
parents:
8421
diff
changeset
|
688 } else { |
f52a2b77d406
QUIC: generic buffering for stream input.
Roman Arutyunyan <arut@nginx.com>
parents:
8421
diff
changeset
|
689 qs->recv_max_data = qc->tp.initial_max_stream_data_uni; |
8825
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8823
diff
changeset
|
690 qs->recv_state = NGX_QUIC_STREAM_RECV_RECV; |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8823
diff
changeset
|
691 qs->send_state = NGX_QUIC_STREAM_SEND_DATA_RECVD; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
692 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
693 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
694 } else { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
695 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
|
696 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
|
697 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
|
698 |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
699 } else { |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
700 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
|
701 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
|
702 } |
8825
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8823
diff
changeset
|
703 |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8823
diff
changeset
|
704 qs->recv_state = NGX_QUIC_STREAM_RECV_RECV; |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8823
diff
changeset
|
705 qs->send_state = NGX_QUIC_STREAM_SEND_READY; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
706 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
707 |
8492
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
708 qs->recv_window = qs->recv_max_data; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
709 |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
710 cln = ngx_pool_cleanup_add(pool, 0); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
711 if (cln == NULL) { |
8420
baf9551b4a5b
QUIC: renamed stream field from c to connection.
Roman Arutyunyan <arut@nginx.com>
parents:
8416
diff
changeset
|
712 ngx_close_connection(sc); |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
713 ngx_destroy_pool(pool); |
8855 | 714 ngx_queue_insert_tail(&qc->streams.free, &qs->queue); |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
715 return NULL; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
716 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
717 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
718 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
|
719 cln->data = sc; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
720 |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
721 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
|
722 |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
723 return qs; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
724 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
725 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
726 |
8552
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
727 static void |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
728 ngx_quic_empty_handler(ngx_event_t *ev) |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
729 { |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
730 } |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
731 |
fe919fd63b0b
QUIC: client certificate validation with OCSP.
Sergey Kandaurov <pluknet@nginx.com>
parents:
8545
diff
changeset
|
732 |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
733 static ssize_t |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
734 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
|
735 { |
8760
6ccf3867959a
QUIC: refactored ngx_quic_order_bufs() and ngx_quic_split_bufs().
Roman Arutyunyan <arut@nginx.com>
parents:
8759
diff
changeset
|
736 ssize_t len; |
8492
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
737 ngx_buf_t *b; |
8760
6ccf3867959a
QUIC: refactored ngx_quic_order_bufs() and ngx_quic_split_bufs().
Roman Arutyunyan <arut@nginx.com>
parents:
8759
diff
changeset
|
738 ngx_chain_t *cl, *in; |
8492
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
739 ngx_event_t *rev; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
740 ngx_connection_t *pc; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
741 ngx_quic_stream_t *qs; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
742 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
743 qs = c->quic; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
744 pc = qs->parent; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
745 rev = c->read; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
746 |
8825
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8823
diff
changeset
|
747 if (qs->recv_state == NGX_QUIC_STREAM_RECV_RESET_RECVD |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8823
diff
changeset
|
748 || qs->recv_state == NGX_QUIC_STREAM_RECV_RESET_READ) |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8823
diff
changeset
|
749 { |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8823
diff
changeset
|
750 qs->recv_state = NGX_QUIC_STREAM_RECV_RESET_READ; |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8823
diff
changeset
|
751 rev->error = 1; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
752 return NGX_ERROR; |
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 |
8855 | 755 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, pc->log, 0, |
8825
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8823
diff
changeset
|
756 "quic stream id:0x%xL recv buf:%uz", qs->id, size); |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
757 |
8825
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8823
diff
changeset
|
758 if (size == 0) { |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8823
diff
changeset
|
759 return 0; |
8410
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 |
8856
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
762 in = ngx_quic_read_buffer(pc, &qs->recv, size); |
8760
6ccf3867959a
QUIC: refactored ngx_quic_order_bufs() and ngx_quic_split_bufs().
Roman Arutyunyan <arut@nginx.com>
parents:
8759
diff
changeset
|
763 if (in == NGX_CHAIN_ERROR) { |
6ccf3867959a
QUIC: refactored ngx_quic_order_bufs() and ngx_quic_split_bufs().
Roman Arutyunyan <arut@nginx.com>
parents:
8759
diff
changeset
|
764 return NGX_ERROR; |
8439
f52a2b77d406
QUIC: generic buffering for stream input.
Roman Arutyunyan <arut@nginx.com>
parents:
8421
diff
changeset
|
765 } |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
766 |
8760
6ccf3867959a
QUIC: refactored ngx_quic_order_bufs() and ngx_quic_split_bufs().
Roman Arutyunyan <arut@nginx.com>
parents:
8759
diff
changeset
|
767 len = 0; |
8439
f52a2b77d406
QUIC: generic buffering for stream input.
Roman Arutyunyan <arut@nginx.com>
parents:
8421
diff
changeset
|
768 |
8760
6ccf3867959a
QUIC: refactored ngx_quic_order_bufs() and ngx_quic_split_bufs().
Roman Arutyunyan <arut@nginx.com>
parents:
8759
diff
changeset
|
769 for (cl = in; cl; cl = cl->next) { |
6ccf3867959a
QUIC: refactored ngx_quic_order_bufs() and ngx_quic_split_bufs().
Roman Arutyunyan <arut@nginx.com>
parents:
8759
diff
changeset
|
770 b = cl->buf; |
6ccf3867959a
QUIC: refactored ngx_quic_order_bufs() and ngx_quic_split_bufs().
Roman Arutyunyan <arut@nginx.com>
parents:
8759
diff
changeset
|
771 len += b->last - b->pos; |
6ccf3867959a
QUIC: refactored ngx_quic_order_bufs() and ngx_quic_split_bufs().
Roman Arutyunyan <arut@nginx.com>
parents:
8759
diff
changeset
|
772 buf = ngx_cpymem(buf, b->pos, b->last - b->pos); |
6ccf3867959a
QUIC: refactored ngx_quic_order_bufs() and ngx_quic_split_bufs().
Roman Arutyunyan <arut@nginx.com>
parents:
8759
diff
changeset
|
773 } |
6ccf3867959a
QUIC: refactored ngx_quic_order_bufs() and ngx_quic_split_bufs().
Roman Arutyunyan <arut@nginx.com>
parents:
8759
diff
changeset
|
774 |
8761
19e063e955bf
QUIC: renamed buffer-related functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8760
diff
changeset
|
775 ngx_quic_free_chain(pc, in); |
8439
f52a2b77d406
QUIC: generic buffering for stream input.
Roman Arutyunyan <arut@nginx.com>
parents:
8421
diff
changeset
|
776 |
8825
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8823
diff
changeset
|
777 if (len == 0) { |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8823
diff
changeset
|
778 rev->ready = 0; |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8823
diff
changeset
|
779 |
8847
6c1dfd072859
QUIC: switch stream to DATA_RECVD state.
Roman Arutyunyan <arut@nginx.com>
parents:
8828
diff
changeset
|
780 if (qs->recv_state == NGX_QUIC_STREAM_RECV_DATA_RECVD |
8855 | 781 && qs->recv_offset == qs->recv_final_size) |
8825
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8823
diff
changeset
|
782 { |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8823
diff
changeset
|
783 qs->recv_state = NGX_QUIC_STREAM_RECV_DATA_READ; |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8823
diff
changeset
|
784 } |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8823
diff
changeset
|
785 |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8823
diff
changeset
|
786 if (qs->recv_state == NGX_QUIC_STREAM_RECV_DATA_READ) { |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8823
diff
changeset
|
787 rev->eof = 1; |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8823
diff
changeset
|
788 return 0; |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8823
diff
changeset
|
789 } |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8823
diff
changeset
|
790 |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8823
diff
changeset
|
791 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8823
diff
changeset
|
792 "quic stream id:0x%xL recv() not ready", qs->id); |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8823
diff
changeset
|
793 return NGX_AGAIN; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
794 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
795 |
8442
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
796 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
|
797 "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
|
798 |
8855 | 799 if (ngx_quic_update_flow(qs, qs->recv_offset + len) != NGX_OK) { |
8492
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
800 return NGX_ERROR; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
801 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
802 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
803 return len; |
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 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
807 static ssize_t |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
808 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
|
809 { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
810 ngx_buf_t b; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
811 ngx_chain_t cl; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
812 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
813 ngx_memzero(&b, sizeof(ngx_buf_t)); |
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 b.memory = 1; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
816 b.pos = buf; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
817 b.last = buf + size; |
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 cl.buf = &b; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
820 cl.next = NULL; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
821 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
822 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
|
823 return NGX_ERROR; |
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 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
826 if (b.pos == buf) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
827 return NGX_AGAIN; |
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 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
830 return b.pos - buf; |
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 |
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 static ngx_chain_t * |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
835 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
|
836 { |
8856
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
837 uint64_t n, flow; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
838 ngx_event_t *wev; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
839 ngx_connection_t *pc; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
840 ngx_quic_stream_t *qs; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
841 ngx_quic_connection_t *qc; |
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 qs = c->quic; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
844 pc = qs->parent; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
845 qc = ngx_quic_get_connection(pc); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
846 wev = c->write; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
847 |
8825
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8823
diff
changeset
|
848 if (qs->send_state != NGX_QUIC_STREAM_SEND_READY |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8823
diff
changeset
|
849 && qs->send_state != NGX_QUIC_STREAM_SEND_SEND) |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8823
diff
changeset
|
850 { |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8823
diff
changeset
|
851 wev->error = 1; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
852 return NGX_CHAIN_ERROR; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
853 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
854 |
8825
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8823
diff
changeset
|
855 qs->send_state = NGX_QUIC_STREAM_SEND_SEND; |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8823
diff
changeset
|
856 |
8855 | 857 flow = qs->acked + qc->conf->stream_buffer_size - c->sent; |
858 | |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
859 if (flow == 0) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
860 wev->ready = 0; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
861 return in; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
862 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
863 |
8856
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
864 if (limit == 0 || limit > (off_t) flow) { |
8760
6ccf3867959a
QUIC: refactored ngx_quic_order_bufs() and ngx_quic_split_bufs().
Roman Arutyunyan <arut@nginx.com>
parents:
8759
diff
changeset
|
865 limit = flow; |
8410
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 |
8856
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
868 n = qs->send.size; |
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
869 |
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
870 in = ngx_quic_write_buffer(pc, &qs->send, in, limit, c->sent); |
8760
6ccf3867959a
QUIC: refactored ngx_quic_order_bufs() and ngx_quic_split_bufs().
Roman Arutyunyan <arut@nginx.com>
parents:
8759
diff
changeset
|
871 if (in == NGX_CHAIN_ERROR) { |
6ccf3867959a
QUIC: refactored ngx_quic_order_bufs() and ngx_quic_split_bufs().
Roman Arutyunyan <arut@nginx.com>
parents:
8759
diff
changeset
|
872 return NGX_CHAIN_ERROR; |
6ccf3867959a
QUIC: refactored ngx_quic_order_bufs() and ngx_quic_split_bufs().
Roman Arutyunyan <arut@nginx.com>
parents:
8759
diff
changeset
|
873 } |
6ccf3867959a
QUIC: refactored ngx_quic_order_bufs() and ngx_quic_split_bufs().
Roman Arutyunyan <arut@nginx.com>
parents:
8759
diff
changeset
|
874 |
8856
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
875 n = qs->send.size - n; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
876 c->sent += n; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
877 qc->streams.sent += n; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
878 |
8856
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
879 if (flow == n) { |
8760
6ccf3867959a
QUIC: refactored ngx_quic_order_bufs() and ngx_quic_split_bufs().
Roman Arutyunyan <arut@nginx.com>
parents:
8759
diff
changeset
|
880 wev->ready = 0; |
6ccf3867959a
QUIC: refactored ngx_quic_order_bufs() and ngx_quic_split_bufs().
Roman Arutyunyan <arut@nginx.com>
parents:
8759
diff
changeset
|
881 } |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
882 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
883 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, c->log, 0, |
8856
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
884 "quic send_chain sent:%uL", n); |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
885 |
8855 | 886 if (ngx_quic_stream_flush(qs) != NGX_OK) { |
887 return NGX_CHAIN_ERROR; | |
888 } | |
889 | |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
890 return in; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
891 } |
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 |
8855 | 894 static ngx_int_t |
895 ngx_quic_stream_flush(ngx_quic_stream_t *qs) | |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
896 { |
8856
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
897 off_t limit, len; |
8855 | 898 ngx_uint_t last; |
8856
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
899 ngx_chain_t *out; |
8855 | 900 ngx_quic_frame_t *frame; |
901 ngx_connection_t *pc; | |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
902 ngx_quic_connection_t *qc; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
903 |
8855 | 904 if (qs->send_state != NGX_QUIC_STREAM_SEND_SEND) { |
905 return NGX_OK; | |
906 } | |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
907 |
8855 | 908 pc = qs->parent; |
909 qc = ngx_quic_get_connection(pc); | |
8410
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 if (qc->streams.send_max_data == 0) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
912 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
|
913 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
914 |
8855 | 915 limit = ngx_min(qc->streams.send_max_data - qc->streams.send_offset, |
916 qs->send_max_data - qs->send_offset); | |
917 | |
918 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, pc->log, 0, | |
919 "quic stream id:0x%xL flush limit:%O", qs->id, limit); | |
920 | |
8856
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
921 len = qs->send.offset; |
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
922 |
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
923 out = ngx_quic_read_buffer(pc, &qs->send, limit); |
8855 | 924 if (out == NGX_CHAIN_ERROR) { |
925 return NGX_ERROR; | |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
926 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
927 |
8856
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
928 len = qs->send.offset - len; |
8855 | 929 last = 0; |
930 | |
931 if (qs->send_final_size != (uint64_t) -1 | |
8856
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
932 && qs->send_final_size == qs->send.offset) |
8855 | 933 { |
934 qs->send_state = NGX_QUIC_STREAM_SEND_DATA_SENT; | |
935 last = 1; | |
936 } | |
937 | |
938 if (len == 0 && !last) { | |
939 return NGX_OK; | |
8410
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 |
8855 | 942 frame = ngx_quic_alloc_frame(pc); |
943 if (frame == NULL) { | |
944 return NGX_ERROR; | |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
945 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
946 |
8855 | 947 frame->level = ssl_encryption_application; |
948 frame->type = NGX_QUIC_FT_STREAM; | |
949 frame->data = out; | |
950 | |
951 frame->u.stream.off = 1; | |
952 frame->u.stream.len = 1; | |
953 frame->u.stream.fin = last; | |
954 | |
955 frame->u.stream.stream_id = qs->id; | |
956 frame->u.stream.offset = qs->send_offset; | |
957 frame->u.stream.length = len; | |
958 | |
959 ngx_quic_queue_frame(qc, frame); | |
960 | |
961 qs->send_offset += len; | |
962 qc->streams.send_offset += len; | |
963 | |
964 ngx_log_debug3(NGX_LOG_DEBUG_EVENT, pc->log, 0, | |
8856
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
965 "quic stream id:0x%xL flush len:%O last:%ui", |
8855 | 966 qs->id, len, last); |
967 | |
968 if (qs->connection == NULL) { | |
969 return ngx_quic_close_stream(qs); | |
8410
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 |
8855 | 972 return NGX_OK; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
973 } |
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 static void |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
977 ngx_quic_stream_cleanup_handler(void *data) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
978 { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
979 ngx_connection_t *c = data; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
980 |
8855 | 981 ngx_quic_stream_t *qs; |
982 | |
983 qs = c->quic; | |
984 | |
985 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, qs->parent->log, 0, | |
986 "quic stream id:0x%xL cleanup", qs->id); | |
987 | |
988 if (ngx_quic_shutdown_stream(c, NGX_RDWR_SHUTDOWN) != NGX_OK) { | |
989 ngx_quic_close_connection(c, NGX_ERROR); | |
990 return; | |
991 } | |
992 | |
993 qs->connection = NULL; | |
994 | |
995 if (ngx_quic_close_stream(qs) != NGX_OK) { | |
996 ngx_quic_close_connection(c, NGX_ERROR); | |
997 return; | |
998 } | |
999 } | |
1000 | |
1001 | |
1002 static ngx_int_t | |
1003 ngx_quic_close_stream(ngx_quic_stream_t *qs) | |
1004 { | |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1005 ngx_connection_t *pc; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1006 ngx_quic_frame_t *frame; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1007 ngx_quic_connection_t *qc; |
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 pc = qs->parent; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1010 qc = ngx_quic_get_connection(pc); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1011 |
8855 | 1012 if (!qc->closing) { |
1013 /* make sure everything is sent and final size is received */ | |
1014 | |
1015 if (qs->recv_state == NGX_QUIC_STREAM_RECV_RECV | |
1016 || qs->send_state == NGX_QUIC_STREAM_SEND_READY | |
1017 || qs->send_state == NGX_QUIC_STREAM_SEND_SEND) | |
1018 { | |
1019 return NGX_OK; | |
1020 } | |
1021 } | |
1022 | |
1023 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, pc->log, 0, | |
1024 "quic stream id:0x%xL close", qs->id); | |
1025 | |
8856
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
1026 ngx_quic_free_buffer(pc, &qs->send); |
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
1027 ngx_quic_free_buffer(pc, &qs->recv); |
8410
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 ngx_rbtree_delete(&qc->streams.tree, &qs->node); |
8855 | 1030 ngx_queue_insert_tail(&qc->streams.free, &qs->queue); |
8410
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 if (qc->closing) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1033 /* 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
|
1034 ngx_post_event(pc->read, &ngx_posted_events); |
8855 | 1035 return NGX_OK; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1036 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1037 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1038 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
|
1039 frame = ngx_quic_alloc_frame(pc); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1040 if (frame == NULL) { |
8855 | 1041 return NGX_ERROR; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1042 } |
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 frame->level = ssl_encryption_application; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1045 frame->type = NGX_QUIC_FT_MAX_STREAMS; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1046 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1047 if (qs->id & NGX_QUIC_STREAM_UNIDIRECTIONAL) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1048 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
|
1049 frame->u.max_streams.bidi = 0; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1050 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1051 } else { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1052 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
|
1053 frame->u.max_streams.bidi = 1; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1054 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1055 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1056 ngx_quic_queue_frame(qc, frame); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1057 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1058 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1059 if (qc->shutdown) { |
8553
a9f6540e61da
QUIC: asynchronous shutdown.
Roman Arutyunyan <arut@nginx.com>
parents:
8552
diff
changeset
|
1060 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
|
1061 } |
8855 | 1062 |
1063 return NGX_OK; | |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1064 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1065 |
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 ngx_int_t |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1068 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
|
1069 ngx_quic_frame_t *frame) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1070 { |
8442
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
1071 uint64_t last; |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
1072 ngx_quic_stream_t *qs; |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
1073 ngx_quic_connection_t *qc; |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
1074 ngx_quic_stream_frame_t *f; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1075 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1076 qc = ngx_quic_get_connection(c); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1077 f = &frame->u.stream; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1078 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1079 if ((f->stream_id & NGX_QUIC_STREAM_UNIDIRECTIONAL) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1080 && (f->stream_id & NGX_QUIC_STREAM_SERVER_INITIATED)) |
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 qc->error = NGX_QUIC_ERR_STREAM_STATE_ERROR; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1083 return NGX_ERROR; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1084 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1085 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1086 /* no overflow since both values are 62-bit */ |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1087 last = f->offset + f->length; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1088 |
8726
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8725
diff
changeset
|
1089 qs = ngx_quic_get_stream(c, f->stream_id); |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1090 |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
1091 if (qs == NULL) { |
8726
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8725
diff
changeset
|
1092 return NGX_ERROR; |
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8725
diff
changeset
|
1093 } |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1094 |
8726
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8725
diff
changeset
|
1095 if (qs == NGX_QUIC_STREAM_GONE) { |
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8725
diff
changeset
|
1096 return NGX_OK; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1097 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1098 |
8825
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8823
diff
changeset
|
1099 if (qs->recv_state != NGX_QUIC_STREAM_RECV_RECV |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8823
diff
changeset
|
1100 && qs->recv_state != NGX_QUIC_STREAM_RECV_SIZE_KNOWN) |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8823
diff
changeset
|
1101 { |
8492
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1102 return NGX_OK; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1103 } |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1104 |
8855 | 1105 if (ngx_quic_control_flow(qs, last) != NGX_OK) { |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1106 return NGX_ERROR; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1107 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1108 |
8855 | 1109 if (qs->recv_final_size != (uint64_t) -1 && last > qs->recv_final_size) { |
8442
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
1110 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
|
1111 return NGX_ERROR; |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
1112 } |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
1113 |
8788
47f45a98f892
QUIC: fixed handling STREAM FIN.
Roman Arutyunyan <arut@nginx.com>
parents:
8765
diff
changeset
|
1114 if (last < qs->recv_offset) { |
8442
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
1115 return NGX_OK; |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
1116 } |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
1117 |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
1118 if (f->fin) { |
8855 | 1119 if (qs->recv_final_size != (uint64_t) -1 && qs->recv_final_size != last) |
1120 { | |
8442
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
1121 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
|
1122 return NGX_ERROR; |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
1123 } |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
1124 |
8443
60c6e8d8d3ae
QUIC: make sure stream data size is lower than final size.
Roman Arutyunyan <arut@nginx.com>
parents:
8442
diff
changeset
|
1125 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
|
1126 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
|
1127 return NGX_ERROR; |
60c6e8d8d3ae
QUIC: make sure stream data size is lower than final size.
Roman Arutyunyan <arut@nginx.com>
parents:
8442
diff
changeset
|
1128 } |
60c6e8d8d3ae
QUIC: make sure stream data size is lower than final size.
Roman Arutyunyan <arut@nginx.com>
parents:
8442
diff
changeset
|
1129 |
8855 | 1130 qs->recv_final_size = last; |
8825
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8823
diff
changeset
|
1131 qs->recv_state = NGX_QUIC_STREAM_RECV_SIZE_KNOWN; |
8442
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
1132 } |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
1133 |
8856
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
1134 if (ngx_quic_write_buffer(c, &qs->recv, frame->data, f->length, f->offset) |
8760
6ccf3867959a
QUIC: refactored ngx_quic_order_bufs() and ngx_quic_split_bufs().
Roman Arutyunyan <arut@nginx.com>
parents:
8759
diff
changeset
|
1135 == NGX_CHAIN_ERROR) |
8444
7d32c3c93678
QUIC: call stream read handler on new data arrival.
Roman Arutyunyan <arut@nginx.com>
parents:
8443
diff
changeset
|
1136 { |
7d32c3c93678
QUIC: call stream read handler on new data arrival.
Roman Arutyunyan <arut@nginx.com>
parents:
8443
diff
changeset
|
1137 return NGX_ERROR; |
7d32c3c93678
QUIC: call stream read handler on new data arrival.
Roman Arutyunyan <arut@nginx.com>
parents:
8443
diff
changeset
|
1138 } |
7d32c3c93678
QUIC: call stream read handler on new data arrival.
Roman Arutyunyan <arut@nginx.com>
parents:
8443
diff
changeset
|
1139 |
8847
6c1dfd072859
QUIC: switch stream to DATA_RECVD state.
Roman Arutyunyan <arut@nginx.com>
parents:
8828
diff
changeset
|
1140 if (qs->recv_state == NGX_QUIC_STREAM_RECV_SIZE_KNOWN |
8856
f9c788f3f5cc
QUIC: ngx_quic_buffer_t object.
Roman Arutyunyan <arut@nginx.com>
parents:
8855
diff
changeset
|
1141 && qs->recv.size == qs->recv_final_size) |
8847
6c1dfd072859
QUIC: switch stream to DATA_RECVD state.
Roman Arutyunyan <arut@nginx.com>
parents:
8828
diff
changeset
|
1142 { |
6c1dfd072859
QUIC: switch stream to DATA_RECVD state.
Roman Arutyunyan <arut@nginx.com>
parents:
8828
diff
changeset
|
1143 qs->recv_state = NGX_QUIC_STREAM_RECV_DATA_RECVD; |
6c1dfd072859
QUIC: switch stream to DATA_RECVD state.
Roman Arutyunyan <arut@nginx.com>
parents:
8828
diff
changeset
|
1144 } |
6c1dfd072859
QUIC: switch stream to DATA_RECVD state.
Roman Arutyunyan <arut@nginx.com>
parents:
8828
diff
changeset
|
1145 |
8855 | 1146 if (qs->connection == NULL) { |
1147 return ngx_quic_close_stream(qs); | |
1148 } | |
1149 | |
8444
7d32c3c93678
QUIC: call stream read handler on new data arrival.
Roman Arutyunyan <arut@nginx.com>
parents:
8443
diff
changeset
|
1150 if (f->offset == qs->recv_offset) { |
8855 | 1151 ngx_quic_set_event(qs->connection->read); |
8444
7d32c3c93678
QUIC: call stream read handler on new data arrival.
Roman Arutyunyan <arut@nginx.com>
parents:
8443
diff
changeset
|
1152 } |
7d32c3c93678
QUIC: call stream read handler on new data arrival.
Roman Arutyunyan <arut@nginx.com>
parents:
8443
diff
changeset
|
1153 |
7d32c3c93678
QUIC: call stream read handler on new data arrival.
Roman Arutyunyan <arut@nginx.com>
parents:
8443
diff
changeset
|
1154 return NGX_OK; |
8410
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 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1157 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1158 ngx_int_t |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1159 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
|
1160 ngx_quic_max_data_frame_t *f) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1161 { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1162 ngx_rbtree_t *tree; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1163 ngx_rbtree_node_t *node; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1164 ngx_quic_stream_t *qs; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1165 ngx_quic_connection_t *qc; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1166 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1167 qc = ngx_quic_get_connection(c); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1168 tree = &qc->streams.tree; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1169 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1170 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
|
1171 return NGX_OK; |
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 |
8855 | 1174 if (tree->root == tree->sentinel |
1175 || qc->streams.send_offset < qc->streams.send_max_data) | |
8596
1f7f98638dc2
QUIC: fixed null pointer dereference in MAX_DATA handler.
Mariano Di Martino <mariano.dimartino@uhasselt.be>
parents:
8553
diff
changeset
|
1176 { |
8855 | 1177 /* not blocked on MAX_DATA */ |
1178 qc->streams.send_max_data = f->max_data; | |
1179 return NGX_OK; | |
8410
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 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1182 qc->streams.send_max_data = f->max_data; |
8855 | 1183 node = ngx_rbtree_min(tree->root, tree->sentinel); |
1184 | |
1185 while (node && qc->streams.send_offset < qc->streams.send_max_data) { | |
1186 | |
1187 qs = (ngx_quic_stream_t *) node; | |
1188 node = ngx_rbtree_next(tree, node); | |
1189 | |
1190 if (ngx_quic_stream_flush(qs) != NGX_OK) { | |
1191 return NGX_ERROR; | |
1192 } | |
1193 } | |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1194 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1195 return NGX_OK; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1196 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1197 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1198 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1199 ngx_int_t |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1200 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
|
1201 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
|
1202 { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1203 return NGX_OK; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1204 } |
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 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1207 ngx_int_t |
8698
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
1208 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
|
1209 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
|
1210 { |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
1211 return ngx_quic_update_max_data(c); |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
1212 } |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
1213 |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
1214 |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
1215 ngx_int_t |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1216 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
|
1217 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
|
1218 { |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
1219 ngx_quic_stream_t *qs; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1220 ngx_quic_connection_t *qc; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1221 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1222 qc = ngx_quic_get_connection(c); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1223 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1224 if ((f->id & NGX_QUIC_STREAM_UNIDIRECTIONAL) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1225 && (f->id & NGX_QUIC_STREAM_SERVER_INITIATED)) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1226 { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1227 qc->error = NGX_QUIC_ERR_STREAM_STATE_ERROR; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1228 return NGX_ERROR; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1229 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1230 |
8726
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8725
diff
changeset
|
1231 qs = ngx_quic_get_stream(c, f->id); |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1232 |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
1233 if (qs == NULL) { |
8726
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8725
diff
changeset
|
1234 return NGX_ERROR; |
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8725
diff
changeset
|
1235 } |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1236 |
8726
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8725
diff
changeset
|
1237 if (qs == NGX_QUIC_STREAM_GONE) { |
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8725
diff
changeset
|
1238 return NGX_OK; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1239 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1240 |
8855 | 1241 return ngx_quic_update_max_stream_data(qs); |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1242 } |
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 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1245 ngx_int_t |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1246 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
|
1247 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
|
1248 { |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
1249 ngx_quic_stream_t *qs; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1250 ngx_quic_connection_t *qc; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1251 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1252 qc = ngx_quic_get_connection(c); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1253 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1254 if ((f->id & NGX_QUIC_STREAM_UNIDIRECTIONAL) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1255 && (f->id & NGX_QUIC_STREAM_SERVER_INITIATED) == 0) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1256 { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1257 qc->error = NGX_QUIC_ERR_STREAM_STATE_ERROR; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1258 return NGX_ERROR; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1259 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1260 |
8726
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8725
diff
changeset
|
1261 qs = ngx_quic_get_stream(c, f->id); |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1262 |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
1263 if (qs == NULL) { |
8726
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8725
diff
changeset
|
1264 return NGX_ERROR; |
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8725
diff
changeset
|
1265 } |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1266 |
8726
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8725
diff
changeset
|
1267 if (qs == NGX_QUIC_STREAM_GONE) { |
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8725
diff
changeset
|
1268 return NGX_OK; |
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 |
8855 | 1275 if (qs->send_offset < qs->send_max_data) { |
1276 /* not blocked on MAX_STREAM_DATA */ | |
1277 qs->send_max_data = f->limit; | |
1278 return NGX_OK; | |
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 |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
1281 qs->send_max_data = f->limit; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1282 |
8855 | 1283 return ngx_quic_stream_flush(qs); |
8410
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 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1286 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1287 ngx_int_t |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1288 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
|
1289 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
|
1290 { |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
1291 ngx_quic_stream_t *qs; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1292 ngx_quic_connection_t *qc; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1293 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1294 qc = ngx_quic_get_connection(c); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1295 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1296 if ((f->id & NGX_QUIC_STREAM_UNIDIRECTIONAL) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1297 && (f->id & NGX_QUIC_STREAM_SERVER_INITIATED)) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1298 { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1299 qc->error = NGX_QUIC_ERR_STREAM_STATE_ERROR; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1300 return NGX_ERROR; |
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 |
8726
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8725
diff
changeset
|
1303 qs = ngx_quic_get_stream(c, f->id); |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1304 |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
1305 if (qs == NULL) { |
8726
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8725
diff
changeset
|
1306 return NGX_ERROR; |
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8725
diff
changeset
|
1307 } |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1308 |
8726
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8725
diff
changeset
|
1309 if (qs == NGX_QUIC_STREAM_GONE) { |
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8725
diff
changeset
|
1310 return NGX_OK; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1311 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1312 |
8825
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8823
diff
changeset
|
1313 if (qs->recv_state == NGX_QUIC_STREAM_RECV_RESET_RECVD |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8823
diff
changeset
|
1314 || qs->recv_state == NGX_QUIC_STREAM_RECV_RESET_READ) |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8823
diff
changeset
|
1315 { |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8823
diff
changeset
|
1316 return NGX_OK; |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8823
diff
changeset
|
1317 } |
8492
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1318 |
8825
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8823
diff
changeset
|
1319 qs->recv_state = NGX_QUIC_STREAM_RECV_RESET_RECVD; |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8823
diff
changeset
|
1320 |
8855 | 1321 if (ngx_quic_control_flow(qs, f->final_size) != NGX_OK) { |
8492
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1322 return NGX_ERROR; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1323 } |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1324 |
8855 | 1325 if (qs->recv_final_size != (uint64_t) -1 |
1326 && qs->recv_final_size != f->final_size) | |
1327 { | |
8442
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
1328 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
|
1329 return NGX_ERROR; |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
1330 } |
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
1331 |
8443
60c6e8d8d3ae
QUIC: make sure stream data size is lower than final size.
Roman Arutyunyan <arut@nginx.com>
parents:
8442
diff
changeset
|
1332 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
|
1333 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
|
1334 return NGX_ERROR; |
60c6e8d8d3ae
QUIC: make sure stream data size is lower than final size.
Roman Arutyunyan <arut@nginx.com>
parents:
8442
diff
changeset
|
1335 } |
60c6e8d8d3ae
QUIC: make sure stream data size is lower than final size.
Roman Arutyunyan <arut@nginx.com>
parents:
8442
diff
changeset
|
1336 |
8855 | 1337 qs->recv_final_size = f->final_size; |
8442
b3f6ad181df4
QUIC: refactored CRYPTO and STREAM buffer ordering.
Roman Arutyunyan <arut@nginx.com>
parents:
8439
diff
changeset
|
1338 |
8855 | 1339 if (ngx_quic_update_flow(qs, qs->recv_final_size) != NGX_OK) { |
8492
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1340 return NGX_ERROR; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1341 } |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1342 |
8855 | 1343 if (qs->connection == NULL) { |
1344 return ngx_quic_close_stream(qs); | |
1345 } | |
1346 | |
8828
7626aa7a2156
QUIC: stream event setting function.
Roman Arutyunyan <arut@nginx.com>
parents:
8825
diff
changeset
|
1347 ngx_quic_set_event(qs->connection->read); |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1348 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1349 return NGX_OK; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1350 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1351 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1352 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1353 ngx_int_t |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1354 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
|
1355 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
|
1356 { |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
1357 ngx_quic_stream_t *qs; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1358 ngx_quic_connection_t *qc; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1359 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1360 qc = ngx_quic_get_connection(c); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1361 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1362 if ((f->id & NGX_QUIC_STREAM_UNIDIRECTIONAL) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1363 && (f->id & NGX_QUIC_STREAM_SERVER_INITIATED) == 0) |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1364 { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1365 qc->error = NGX_QUIC_ERR_STREAM_STATE_ERROR; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1366 return NGX_ERROR; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1367 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1368 |
8726
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8725
diff
changeset
|
1369 qs = ngx_quic_get_stream(c, f->id); |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1370 |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
1371 if (qs == NULL) { |
8726
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8725
diff
changeset
|
1372 return NGX_ERROR; |
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8725
diff
changeset
|
1373 } |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1374 |
8726
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8725
diff
changeset
|
1375 if (qs == NGX_QUIC_STREAM_GONE) { |
0692355a3519
QUIC: simplified stream initialization.
Roman Arutyunyan <arut@nginx.com>
parents:
8725
diff
changeset
|
1376 return NGX_OK; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1377 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1378 |
8855 | 1379 if (ngx_quic_do_reset_stream(qs, f->error_code) != NGX_OK) { |
8638
1ead7d64e993
QUIC: send RESET_STREAM in response to STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8637
diff
changeset
|
1380 return NGX_ERROR; |
1ead7d64e993
QUIC: send RESET_STREAM in response to STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8637
diff
changeset
|
1381 } |
1ead7d64e993
QUIC: send RESET_STREAM in response to STOP_SENDING.
Roman Arutyunyan <arut@nginx.com>
parents:
8637
diff
changeset
|
1382 |
8855 | 1383 if (qs->connection == NULL) { |
1384 return ngx_quic_close_stream(qs); | |
1385 } | |
1386 | |
8828
7626aa7a2156
QUIC: stream event setting function.
Roman Arutyunyan <arut@nginx.com>
parents:
8825
diff
changeset
|
1387 ngx_quic_set_event(qs->connection->write); |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1388 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1389 return NGX_OK; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1390 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1391 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1392 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1393 ngx_int_t |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1394 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
|
1395 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
|
1396 { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1397 ngx_quic_connection_t *qc; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1398 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1399 qc = ngx_quic_get_connection(c); |
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 if (f->bidi) { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1402 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
|
1403 qc->streams.server_max_streams_bidi = f->limit; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1404 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1405 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
|
1406 "quic max_streams_bidi:%uL", f->limit); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1407 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1408 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1409 } else { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1410 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
|
1411 qc->streams.server_max_streams_uni = f->limit; |
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 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
|
1414 "quic max_streams_uni:%uL", f->limit); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1415 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1416 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1417 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1418 return NGX_OK; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1419 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1420 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1421 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1422 void |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1423 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
|
1424 { |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1425 uint64_t sent, unacked; |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
1426 ngx_quic_stream_t *qs; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1427 ngx_quic_connection_t *qc; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1428 |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1429 qc = ngx_quic_get_connection(c); |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1430 |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
1431 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
|
1432 if (qs == NULL) { |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1433 return; |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1434 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1435 |
8855 | 1436 if (qs->connection == NULL) { |
1437 qs->acked += f->u.stream.length; | |
1438 return; | |
1439 } | |
1440 | |
8421
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
1441 sent = qs->connection->sent; |
225e9f1dfe7c
QUIC: renamed stream variables from sn to qs.
Roman Arutyunyan <arut@nginx.com>
parents:
8420
diff
changeset
|
1442 unacked = sent - qs->acked; |
8855 | 1443 qs->acked += f->u.stream.length; |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1444 |
8855 | 1445 ngx_log_debug4(NGX_LOG_DEBUG_EVENT, c->log, 0, |
1446 "quic stream id:0x%xL ack len:%uL acked:%uL unacked:%uL", | |
1447 qs->id, f->u.stream.length, qs->acked, sent - qs->acked); | |
1448 | |
1449 if (unacked != qc->conf->stream_buffer_size) { | |
1450 /* not blocked on buffer size */ | |
1451 return; | |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1452 } |
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1453 |
8855 | 1454 ngx_quic_set_event(qs->connection->write); |
8410
41807e581de9
QUIC: separate files for stream related processing.
Vladimir Homutov <vl@nginx.com>
parents:
diff
changeset
|
1455 } |
8492
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1456 |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1457 |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1458 static ngx_int_t |
8855 | 1459 ngx_quic_control_flow(ngx_quic_stream_t *qs, uint64_t last) |
8492
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1460 { |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1461 uint64_t len; |
8855 | 1462 ngx_connection_t *pc; |
8492
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1463 ngx_quic_connection_t *qc; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1464 |
8855 | 1465 pc = qs->parent; |
1466 qc = ngx_quic_get_connection(pc); | |
8492
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1467 |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1468 if (last <= qs->recv_last) { |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1469 return NGX_OK; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1470 } |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1471 |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1472 len = last - qs->recv_last; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1473 |
8855 | 1474 ngx_log_debug5(NGX_LOG_DEBUG_EVENT, pc->log, 0, |
1475 "quic stream id:0x%xL flow control msd:%uL/%uL md:%uL/%uL", | |
1476 qs->id, last, qs->recv_max_data, qc->streams.recv_last + len, | |
8492
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1477 qc->streams.recv_max_data); |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1478 |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1479 qs->recv_last += len; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1480 |
8825
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8823
diff
changeset
|
1481 if (qs->recv_state == NGX_QUIC_STREAM_RECV_RECV |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8823
diff
changeset
|
1482 && qs->recv_last > qs->recv_max_data) |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8823
diff
changeset
|
1483 { |
8492
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1484 qc->error = NGX_QUIC_ERR_FLOW_CONTROL_ERROR; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1485 return NGX_ERROR; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1486 } |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1487 |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1488 qc->streams.recv_last += len; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1489 |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1490 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
|
1491 qc->error = NGX_QUIC_ERR_FLOW_CONTROL_ERROR; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1492 return NGX_ERROR; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1493 } |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1494 |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1495 return NGX_OK; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1496 } |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1497 |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1498 |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1499 static ngx_int_t |
8855 | 1500 ngx_quic_update_flow(ngx_quic_stream_t *qs, uint64_t last) |
8492
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1501 { |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1502 uint64_t len; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1503 ngx_connection_t *pc; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1504 ngx_quic_connection_t *qc; |
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 pc = qs->parent; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1507 qc = ngx_quic_get_connection(pc); |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1508 |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1509 if (last <= qs->recv_offset) { |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1510 return NGX_OK; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1511 } |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1512 |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1513 len = last - qs->recv_offset; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1514 |
8855 | 1515 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, pc->log, 0, |
1516 "quic stream id:0x%xL flow update %uL", qs->id, last); | |
8492
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1517 |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1518 qs->recv_offset += len; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1519 |
8825
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8823
diff
changeset
|
1520 if (qs->recv_max_data <= qs->recv_offset + qs->recv_window / 2) { |
8855 | 1521 if (ngx_quic_update_max_stream_data(qs) != NGX_OK) { |
8492
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1522 return NGX_ERROR; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1523 } |
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 |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1526 qc->streams.recv_offset += len; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1527 |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1528 if (qc->streams.recv_max_data |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1529 <= qc->streams.recv_offset + qc->streams.recv_window / 2) |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1530 { |
8698
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
1531 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
|
1532 return NGX_ERROR; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1533 } |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1534 } |
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 return NGX_OK; |
af33d1ef1c3c
QUIC: stream flow control refactored.
Roman Arutyunyan <arut@nginx.com>
parents:
8444
diff
changeset
|
1537 } |
8617
9ae239d2547d
QUIC: separate event handling functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8597
diff
changeset
|
1538 |
9ae239d2547d
QUIC: separate event handling functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8597
diff
changeset
|
1539 |
8697
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8695
diff
changeset
|
1540 static ngx_int_t |
8855 | 1541 ngx_quic_update_max_stream_data(ngx_quic_stream_t *qs) |
8697
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8695
diff
changeset
|
1542 { |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8695
diff
changeset
|
1543 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
|
1544 ngx_connection_t *pc; |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8695
diff
changeset
|
1545 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
|
1546 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
|
1547 |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8695
diff
changeset
|
1548 pc = qs->parent; |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8695
diff
changeset
|
1549 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
|
1550 |
8825
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8823
diff
changeset
|
1551 if (qs->recv_state != NGX_QUIC_STREAM_RECV_RECV) { |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8823
diff
changeset
|
1552 return NGX_OK; |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8823
diff
changeset
|
1553 } |
b42a041d23a2
QUIC: introduced explicit stream states.
Roman Arutyunyan <arut@nginx.com>
parents:
8823
diff
changeset
|
1554 |
8697
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8695
diff
changeset
|
1555 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
|
1556 |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8695
diff
changeset
|
1557 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
|
1558 return NGX_OK; |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8695
diff
changeset
|
1559 } |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8695
diff
changeset
|
1560 |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8695
diff
changeset
|
1561 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
|
1562 |
8855 | 1563 ngx_log_debug2(NGX_LOG_DEBUG_EVENT, pc->log, 0, |
1564 "quic stream id:0x%xL flow update msd:%uL", | |
1565 qs->id, qs->recv_max_data); | |
8697
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8695
diff
changeset
|
1566 |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8695
diff
changeset
|
1567 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
|
1568 if (frame == NULL) { |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8695
diff
changeset
|
1569 return NGX_ERROR; |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8695
diff
changeset
|
1570 } |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8695
diff
changeset
|
1571 |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8695
diff
changeset
|
1572 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
|
1573 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
|
1574 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
|
1575 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
|
1576 |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8695
diff
changeset
|
1577 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
|
1578 |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8695
diff
changeset
|
1579 return NGX_OK; |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8695
diff
changeset
|
1580 } |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8695
diff
changeset
|
1581 |
e8cbbfabe547
QUIC: update stream flow control credit on STREAM_DATA_BLOCKED.
Roman Arutyunyan <arut@nginx.com>
parents:
8695
diff
changeset
|
1582 |
8698
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
1583 static ngx_int_t |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
1584 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
|
1585 { |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
1586 uint64_t recv_max_data; |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
1587 ngx_quic_frame_t *frame; |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
1588 ngx_quic_connection_t *qc; |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
1589 |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
1590 qc = ngx_quic_get_connection(c); |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
1591 |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
1592 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
|
1593 |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
1594 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
|
1595 return NGX_OK; |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
1596 } |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
1597 |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
1598 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
|
1599 |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
1600 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
|
1601 "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
|
1602 |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
1603 frame = ngx_quic_alloc_frame(c); |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
1604 if (frame == NULL) { |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
1605 return NGX_ERROR; |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
1606 } |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
1607 |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
1608 frame->level = ssl_encryption_application; |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
1609 frame->type = NGX_QUIC_FT_MAX_DATA; |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
1610 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
|
1611 |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
1612 ngx_quic_queue_frame(qc, frame); |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
1613 |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
1614 return NGX_OK; |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
1615 } |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
1616 |
d041b8d6ab0b
QUIC: handle DATA_BLOCKED frame from client.
Roman Arutyunyan <arut@nginx.com>
parents:
8697
diff
changeset
|
1617 |
8828
7626aa7a2156
QUIC: stream event setting function.
Roman Arutyunyan <arut@nginx.com>
parents:
8825
diff
changeset
|
1618 static void |
7626aa7a2156
QUIC: stream event setting function.
Roman Arutyunyan <arut@nginx.com>
parents:
8825
diff
changeset
|
1619 ngx_quic_set_event(ngx_event_t *ev) |
7626aa7a2156
QUIC: stream event setting function.
Roman Arutyunyan <arut@nginx.com>
parents:
8825
diff
changeset
|
1620 { |
7626aa7a2156
QUIC: stream event setting function.
Roman Arutyunyan <arut@nginx.com>
parents:
8825
diff
changeset
|
1621 ev->ready = 1; |
7626aa7a2156
QUIC: stream event setting function.
Roman Arutyunyan <arut@nginx.com>
parents:
8825
diff
changeset
|
1622 |
7626aa7a2156
QUIC: stream event setting function.
Roman Arutyunyan <arut@nginx.com>
parents:
8825
diff
changeset
|
1623 if (ev->active) { |
7626aa7a2156
QUIC: stream event setting function.
Roman Arutyunyan <arut@nginx.com>
parents:
8825
diff
changeset
|
1624 ngx_post_event(ev, &ngx_posted_events); |
7626aa7a2156
QUIC: stream event setting function.
Roman Arutyunyan <arut@nginx.com>
parents:
8825
diff
changeset
|
1625 } |
7626aa7a2156
QUIC: stream event setting function.
Roman Arutyunyan <arut@nginx.com>
parents:
8825
diff
changeset
|
1626 } |
7626aa7a2156
QUIC: stream event setting function.
Roman Arutyunyan <arut@nginx.com>
parents:
8825
diff
changeset
|
1627 |
7626aa7a2156
QUIC: stream event setting function.
Roman Arutyunyan <arut@nginx.com>
parents:
8825
diff
changeset
|
1628 |
8617
9ae239d2547d
QUIC: separate event handling functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8597
diff
changeset
|
1629 ngx_int_t |
9ae239d2547d
QUIC: separate event handling functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8597
diff
changeset
|
1630 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
|
1631 { |
9ae239d2547d
QUIC: separate event handling functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8597
diff
changeset
|
1632 if (!rev->active && !rev->ready) { |
9ae239d2547d
QUIC: separate event handling functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8597
diff
changeset
|
1633 rev->active = 1; |
9ae239d2547d
QUIC: separate event handling functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8597
diff
changeset
|
1634 |
9ae239d2547d
QUIC: separate event handling functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8597
diff
changeset
|
1635 } 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
|
1636 rev->active = 0; |
9ae239d2547d
QUIC: separate event handling functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8597
diff
changeset
|
1637 } |
9ae239d2547d
QUIC: separate event handling functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8597
diff
changeset
|
1638 |
9ae239d2547d
QUIC: separate event handling functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8597
diff
changeset
|
1639 return NGX_OK; |
9ae239d2547d
QUIC: separate event handling functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8597
diff
changeset
|
1640 } |
9ae239d2547d
QUIC: separate event handling functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8597
diff
changeset
|
1641 |
9ae239d2547d
QUIC: separate event handling functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8597
diff
changeset
|
1642 |
9ae239d2547d
QUIC: separate event handling functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8597
diff
changeset
|
1643 ngx_int_t |
9ae239d2547d
QUIC: separate event handling functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8597
diff
changeset
|
1644 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
|
1645 { |
9ae239d2547d
QUIC: separate event handling functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8597
diff
changeset
|
1646 if (!wev->active && !wev->ready) { |
9ae239d2547d
QUIC: separate event handling functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8597
diff
changeset
|
1647 wev->active = 1; |
9ae239d2547d
QUIC: separate event handling functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8597
diff
changeset
|
1648 |
9ae239d2547d
QUIC: separate event handling functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8597
diff
changeset
|
1649 } else if (wev->active && wev->ready) { |
9ae239d2547d
QUIC: separate event handling functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8597
diff
changeset
|
1650 wev->active = 0; |
9ae239d2547d
QUIC: separate event handling functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8597
diff
changeset
|
1651 } |
9ae239d2547d
QUIC: separate event handling functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8597
diff
changeset
|
1652 |
9ae239d2547d
QUIC: separate event handling functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8597
diff
changeset
|
1653 return NGX_OK; |
9ae239d2547d
QUIC: separate event handling functions.
Roman Arutyunyan <arut@nginx.com>
parents:
8597
diff
changeset
|
1654 } |