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