From c9275084bcf0147dc0c7e8d79eec912f67b4e672 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Tue, 27 Aug 2024 20:22:08 +0200 Subject: [PATCH] MEDIUM: mux-h2: start to introduce the window size in the offset calculation Instead of incrementing the last_max_ofs by the amount of received bytes, we now start from the new current offset to which we add the static window size. The result is exactly the same but it prepares the code to use a window size combined with an offset instead of just refilling the budget from what was received. It was even verified that changing h2_fe_settings_initial_window_size in the middle of a transfer using gdb does indeed allow the transfer speed to adapt accordingly. --- src/mux_h2.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/mux_h2.c b/src/mux_h2.c index 8446687df..744dea5ea 100644 --- a/src/mux_h2.c +++ b/src/mux_h2.c @@ -2647,12 +2647,27 @@ static int h2c_send_conn_wu(struct h2c *h2c) static int h2c_update_strm_rx_win(struct h2c *h2c) { struct h2s *h2s; + int win = 0; h2s = h2c_st_by_id(h2c, h2c->dsi); if (h2s && h2s->h2c) { /* real stream */ + if (h2s->st < H2_SS_ERROR) { + /* let's use the configured static window size */ + win = (h2c->flags & H2_CF_IS_BACK) ? + h2_be_settings_initial_window_size: + h2_fe_settings_initial_window_size; + win = win ? win : h2_settings_initial_window_size; + } + + /* Principle below: the calculate the next max window offset + * from what was received added to the static window size. In + * practice, for a static window it makes the next max offset + * grow at the same speed as what was received, and + * WINDOW_UPDATE frames will also match one for one. + */ h2s->curr_rx_ofs += h2c->rcvd_s; - h2s->next_max_ofs += h2c->rcvd_s; + h2s->next_max_ofs = h2s->curr_rx_ofs + win; h2c->rcvd_s = 0; h2c->wu_s = (h2s->next_max_ofs > h2s->last_adv_ofs) ? (h2s->next_max_ofs - h2s->last_adv_ofs) : @@ -7516,8 +7531,9 @@ static int h2_dump_h2s_info(struct buffer *msg, const struct h2s *h2s, const cha if (!h2s) return ret; - chunk_appendf(msg, " h2s.id=%d .st=%s .flg=0x%04x .rxbuf=%u@%p+%u/%u", + chunk_appendf(msg, " h2s.id=%d .st=%s .flg=0x%04x .rxwin=%u .rxbuf=%u@%p+%u/%u", h2s->id, h2s_st_to_str(h2s->st), h2s->flags, + (uint)(h2s->next_max_ofs - h2s->curr_rx_ofs), (unsigned int)b_data(&h2s->rxbuf), b_orig(&h2s->rxbuf), (unsigned int)b_head_ofs(&h2s->rxbuf), (unsigned int)b_size(&h2s->rxbuf));