]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: mux-h2: Don't expect data from server as long as request is unfinished
authorChristopher Faulet <cfaulet@haproxy.com>
Thu, 23 Feb 2023 13:26:34 +0000 (14:26 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Mon, 27 Feb 2023 16:45:45 +0000 (17:45 +0100)
As for the H1 stream, the H2 stream now states it does not expect data from
the server as long as the request is unfinished. The aim is the same. We
must be sure to not trigger a read timeout on server side if the client is
still uploading data.

From the moment the end of the request is received and forwarded to upper
layer, the H2 stream reports it expects to receive data from the opposite
endpoint. This re-enables read timeout on the server side.

src/mux_h2.c

index 2ba46195c2cc385f4d838d1892c7296daaa4b932..4ac7fc5da2cab07a8c35b26fe8507e177a00438a 100644 (file)
@@ -1537,6 +1537,7 @@ static struct h2s *h2c_frt_stream_new(struct h2c *h2c, int id, struct buffer *in
        h2s->sd->se   = h2s;
        h2s->sd->conn = h2c->conn;
        se_fl_set(h2s->sd, SE_FL_T_MUX | SE_FL_ORPHAN | SE_FL_NOT_FIRST);
+       se_expect_no_data(h2s->sd);
 
        /* FIXME wrong analogy between ext-connect and websocket, this need to
         * be refine.
@@ -6401,9 +6402,17 @@ static size_t h2_rcv_buf(struct stconn *sc, struct buffer *buf, size_t count, in
                if (htx_is_empty(buf_htx))
                        se_fl_set(h2s->sd, SE_FL_EOI);
        }
-       else if (htx_is_empty(h2s_htx))
+       else if (htx_is_empty(h2s_htx)) {
                buf_htx->flags |= (h2s_htx->flags & HTX_FL_EOM);
 
+               if (!(h2c->flags & H2_CF_IS_BACK) && (buf_htx->flags & HTX_FL_EOM)) {
+                       /* If request EOM is reported to the upper layer, it means the
+                        * H2S now expects data from the opposite side.
+                        */
+                       se_expect_data(h2s->sd);
+               }
+       }
+
        buf_htx->extra = (h2s_htx->extra ? (h2s_htx->data + h2s_htx->extra) : 0);
        htx_to_buf(buf_htx, buf);
        htx_to_buf(h2s_htx, &h2s->rxbuf);