]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: mux-h2: start to introduce the window size in the offset calculation
authorWilly Tarreau <w@1wt.eu>
Tue, 27 Aug 2024 18:22:08 +0000 (20:22 +0200)
committerWilly Tarreau <w@1wt.eu>
Sat, 12 Oct 2024 14:29:16 +0000 (16:29 +0200)
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

index 8446687df127136168149b19f63dfebec8bcbf19..744dea5ea2860de267fe3f2779d4b4e472b447d2 100644 (file)
@@ -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));