| 1 | # HG changeset patch
|
|---|
| 2 | # User Roman Arutyunyan <arut@nginx.com>
|
|---|
| 3 | # Date 1712124414 -14400
|
|---|
| 4 | # Wed Apr 03 10:06:54 2024 +0400
|
|---|
| 5 | # Node ID a1764cabbf54757af85069aceb638da6d7ce63bf
|
|---|
| 6 | # Parent 99e7050ac886f7c70a4048691e46846b930b1e28
|
|---|
| 7 | QUIC: do not block ACKs by congestion control (ticket #2621).
|
|---|
| 8 |
|
|---|
| 9 | diff --git a/src/event/quic/ngx_event_quic_output.c b/src/event/quic/ngx_event_quic_output.c
|
|---|
| 10 | --- a/src/event/quic/ngx_event_quic_output.c
|
|---|
| 11 | +++ b/src/event/quic/ngx_event_quic_output.c
|
|---|
| 12 | @@ -55,7 +55,8 @@ static ssize_t ngx_quic_send_segments(ng
|
|---|
| 13 | size_t len, struct sockaddr *sockaddr, socklen_t socklen, size_t segment);
|
|---|
| 14 | #endif
|
|---|
| 15 | static ssize_t ngx_quic_output_packet(ngx_connection_t *c,
|
|---|
| 16 | - ngx_quic_send_ctx_t *ctx, u_char *data, size_t max, size_t min);
|
|---|
| 17 | + ngx_quic_send_ctx_t *ctx, u_char *data, size_t max, size_t min,
|
|---|
| 18 | + ngx_uint_t non_ack_eliciting);
|
|---|
| 19 | static void ngx_quic_init_packet(ngx_connection_t *c, ngx_quic_send_ctx_t *ctx,
|
|---|
| 20 | ngx_quic_header_t *pkt, ngx_quic_path_t *path);
|
|---|
| 21 | static ngx_uint_t ngx_quic_get_padding_level(ngx_connection_t *c);
|
|---|
| 22 | @@ -116,7 +117,7 @@ ngx_quic_create_datagrams(ngx_connection
|
|---|
| 23 | ssize_t n;
|
|---|
| 24 | u_char *p;
|
|---|
| 25 | uint64_t preserved_pnum[NGX_QUIC_SEND_CTX_LAST];
|
|---|
| 26 | - ngx_uint_t i, pad;
|
|---|
| 27 | + ngx_uint_t i, pad, non_ack_eliciting;
|
|---|
| 28 | ngx_quic_path_t *path;
|
|---|
| 29 | ngx_quic_send_ctx_t *ctx;
|
|---|
| 30 | ngx_quic_congestion_t *cg;
|
|---|
| 31 | @@ -127,7 +128,7 @@ ngx_quic_create_datagrams(ngx_connection
|
|---|
| 32 | cg = &qc->congestion;
|
|---|
| 33 | path = qc->path;
|
|---|
| 34 |
|
|---|
| 35 | - while (cg->in_flight < cg->window) {
|
|---|
| 36 | + for ( ;; ) {
|
|---|
| 37 |
|
|---|
| 38 | p = dst;
|
|---|
| 39 |
|
|---|
| 40 | @@ -135,6 +136,8 @@ ngx_quic_create_datagrams(ngx_connection
|
|---|
| 41 |
|
|---|
| 42 | pad = ngx_quic_get_padding_level(c);
|
|---|
| 43 |
|
|---|
| 44 | + non_ack_eliciting = (cg->in_flight < cg->window) ? 0 : 1;
|
|---|
| 45 | +
|
|---|
| 46 | for (i = 0; i < NGX_QUIC_SEND_CTX_LAST; i++) {
|
|---|
| 47 |
|
|---|
| 48 | ctx = &qc->send_ctx[i];
|
|---|
| 49 | @@ -159,7 +162,7 @@ ngx_quic_create_datagrams(ngx_connection
|
|---|
| 50 | return NGX_OK;
|
|---|
| 51 | }
|
|---|
| 52 |
|
|---|
| 53 | - n = ngx_quic_output_packet(c, ctx, p, len, min);
|
|---|
| 54 | + n = ngx_quic_output_packet(c, ctx, p, len, min, non_ack_eliciting);
|
|---|
| 55 | if (n == NGX_ERROR) {
|
|---|
| 56 | return NGX_ERROR;
|
|---|
| 57 | }
|
|---|
| 58 | @@ -312,7 +315,7 @@ ngx_quic_create_segments(ngx_connection_
|
|---|
| 59 | ssize_t n;
|
|---|
| 60 | u_char *p, *end;
|
|---|
| 61 | uint64_t preserved_pnum;
|
|---|
| 62 | - ngx_uint_t nseg;
|
|---|
| 63 | + ngx_uint_t nseg, non_ack_eliciting;
|
|---|
| 64 | ngx_quic_path_t *path;
|
|---|
| 65 | ngx_quic_send_ctx_t *ctx;
|
|---|
| 66 | ngx_quic_congestion_t *cg;
|
|---|
| 67 | @@ -341,9 +344,11 @@ ngx_quic_create_segments(ngx_connection_
|
|---|
| 68 |
|
|---|
| 69 | len = ngx_min(segsize, (size_t) (end - p));
|
|---|
| 70 |
|
|---|
| 71 | - if (len && cg->in_flight + (p - dst) < cg->window) {
|
|---|
| 72 | + if (len) {
|
|---|
| 73 | + non_ack_eliciting = (cg->in_flight + (p - dst) < cg->window)
|
|---|
| 74 | + ? 0 : 1;
|
|---|
| 75 |
|
|---|
| 76 | - n = ngx_quic_output_packet(c, ctx, p, len, len);
|
|---|
| 77 | + n = ngx_quic_output_packet(c, ctx, p, len, len, non_ack_eliciting);
|
|---|
| 78 | if (n == NGX_ERROR) {
|
|---|
| 79 | return NGX_ERROR;
|
|---|
| 80 | }
|
|---|
| 81 | @@ -501,7 +506,7 @@ ngx_quic_get_padding_level(ngx_connectio
|
|---|
| 82 |
|
|---|
| 83 | static ssize_t
|
|---|
| 84 | ngx_quic_output_packet(ngx_connection_t *c, ngx_quic_send_ctx_t *ctx,
|
|---|
| 85 | - u_char *data, size_t max, size_t min)
|
|---|
| 86 | + u_char *data, size_t max, size_t min, ngx_uint_t non_ack_eliciting)
|
|---|
| 87 | {
|
|---|
| 88 | size_t len, pad, min_payload, max_payload;
|
|---|
| 89 | u_char *p;
|
|---|
| 90 | @@ -569,6 +574,10 @@ ngx_quic_output_packet(ngx_connection_t
|
|---|
| 91 | break;
|
|---|
| 92 | }
|
|---|
| 93 |
|
|---|
| 94 | + if (non_ack_eliciting && f->need_ack) {
|
|---|
| 95 | + break;
|
|---|
| 96 | + }
|
|---|
| 97 | +
|
|---|
| 98 | if (len + f->len > max_payload) {
|
|---|
| 99 | rc = ngx_quic_split_frame(c, f, max_payload - len);
|
|---|
| 100 |
|
|---|