Mercurial > hg > nginx-quic
comparison src/event/ngx_event_quic_transport.c @ 7815:0f9e9786b90d quic
Added primitive flow control mechanisms.
+ MAX_STREAM_DATA frame is sent when recv() is performed on stream
The new value is a sum of total bytes received by stream + free
space in a buffer;
The sending of MAX_STREM_DATA frame in response to STREAM_DATA_BLOCKED
frame is adjusted to follow the same logic as above.
+ MAX_DATA frame is sent when total amount of received data is 2x
of current limit. The limit is doubled.
+ Default values of transport parameters are adjusted to more meaningful
values:
initial stream limits are set to quic buffer size instead of
unrealistically small 255.
initial max data is decreased to 16 buffer sizes, in an assumption that
this is enough for a relatively short connection, instead of randomly
chosen big number.
All this allows to initiate a stable flow of streams that does not block
on stream/connection limits (tested with FF 77.0a1 and 100K requests)
author | Vladimir Homutov <vl@nginx.com> |
---|---|
date | Wed, 15 Apr 2020 18:54:03 +0300 |
parents | 167d32476737 |
children | 76e8ec502c69 |
comparison
equal
deleted
inserted
replaced
7814:ab443e80d9e4 | 7815:0f9e9786b90d |
---|---|
75 static size_t ngx_quic_create_stream(u_char *p, ngx_quic_stream_frame_t *sf); | 75 static size_t ngx_quic_create_stream(u_char *p, ngx_quic_stream_frame_t *sf); |
76 static size_t ngx_quic_create_max_streams(u_char *p, | 76 static size_t ngx_quic_create_max_streams(u_char *p, |
77 ngx_quic_max_streams_frame_t *ms); | 77 ngx_quic_max_streams_frame_t *ms); |
78 static size_t ngx_quic_create_max_stream_data(u_char *p, | 78 static size_t ngx_quic_create_max_stream_data(u_char *p, |
79 ngx_quic_max_stream_data_frame_t *ms); | 79 ngx_quic_max_stream_data_frame_t *ms); |
80 static size_t ngx_quic_create_max_data(u_char *p, | |
81 ngx_quic_max_data_frame_t *md); | |
80 static size_t ngx_quic_create_close(u_char *p, ngx_quic_close_frame_t *cl); | 82 static size_t ngx_quic_create_close(u_char *p, ngx_quic_close_frame_t *cl); |
81 | 83 |
82 static ngx_int_t ngx_quic_parse_transport_param(u_char *p, u_char *end, | 84 static ngx_int_t ngx_quic_parse_transport_param(u_char *p, u_char *end, |
83 uint16_t id, ngx_quic_tp_t *dst); | 85 uint16_t id, ngx_quic_tp_t *dst); |
84 | 86 |
1194 return ngx_quic_create_max_streams(p, &f->u.max_streams); | 1196 return ngx_quic_create_max_streams(p, &f->u.max_streams); |
1195 | 1197 |
1196 case NGX_QUIC_FT_MAX_STREAM_DATA: | 1198 case NGX_QUIC_FT_MAX_STREAM_DATA: |
1197 return ngx_quic_create_max_stream_data(p, &f->u.max_stream_data); | 1199 return ngx_quic_create_max_stream_data(p, &f->u.max_stream_data); |
1198 | 1200 |
1201 case NGX_QUIC_FT_MAX_DATA: | |
1202 return ngx_quic_create_max_data(p, &f->u.max_data); | |
1203 | |
1199 default: | 1204 default: |
1200 /* BUG: unsupported frame type generated */ | 1205 /* BUG: unsupported frame type generated */ |
1201 return NGX_ERROR; | 1206 return NGX_ERROR; |
1202 } | 1207 } |
1203 } | 1208 } |
1614 | 1619 |
1615 return p - start; | 1620 return p - start; |
1616 } | 1621 } |
1617 | 1622 |
1618 | 1623 |
1624 static size_t | |
1625 ngx_quic_create_max_data(u_char *p, ngx_quic_max_data_frame_t *md) | |
1626 { | |
1627 size_t len; | |
1628 u_char *start; | |
1629 | |
1630 if (p == NULL) { | |
1631 len = ngx_quic_varint_len(NGX_QUIC_FT_MAX_DATA); | |
1632 len += ngx_quic_varint_len(md->max_data); | |
1633 return len; | |
1634 } | |
1635 | |
1636 start = p; | |
1637 | |
1638 ngx_quic_build_int(&p, NGX_QUIC_FT_MAX_DATA); | |
1639 ngx_quic_build_int(&p, md->max_data); | |
1640 | |
1641 return p - start; | |
1642 } | |
1643 | |
1644 | |
1619 ssize_t | 1645 ssize_t |
1620 ngx_quic_create_transport_params(u_char *pos, u_char *end, ngx_quic_tp_t *tp) | 1646 ngx_quic_create_transport_params(u_char *pos, u_char *end, ngx_quic_tp_t *tp) |
1621 { | 1647 { |
1622 u_char *p; | 1648 u_char *p; |
1623 size_t len; | 1649 size_t len; |