]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: h1: Immediately try to read data for frontend
authorOlivier Houchard <ohouchard@haproxy.com>
Wed, 29 Oct 2025 15:39:49 +0000 (15:39 +0000)
committerOlivier Houchard <cognet@ci0.org>
Wed, 29 Oct 2025 16:18:26 +0000 (17:18 +0100)
In h1_init(), if we're a frontend connection, immediately attempt to
read data, if the connection is ready, instead of just subscribing.
There may already be data available, at least if we're using 0RTT.

This may be backported up to 2.8 in a while, after 3.3 is released, so
that if it causes problem, we have a chance to hear about it.

src/mux_h1.c

index 1d5e8c6cf4119e87aff352752a95f6ff01349711..d9d63c271a168142d8049e236081d27c604c14c0 100644 (file)
@@ -1332,8 +1332,21 @@ static int h1_init(struct connection *conn, struct proxy *proxy, struct session
        /* prepare to read something */
        if (b_data(&h1c->ibuf))
                tasklet_wakeup(h1c->wait_event.tasklet);
-       else if (h1_recv_allowed(h1c))
-               h1c->conn->xprt->subscribe(h1c->conn, h1c->conn->xprt_ctx, SUB_RETRY_RECV, &h1c->wait_event);
+       else if (h1_recv_allowed(h1c)) {
+               if (!conn_is_back(conn)) {
+                       /*
+                        * We may have data immediately available,
+                        * especially if we're using 0RTT.
+                        */
+                       if (h1_recv(h1c))
+                               tasklet_wakeup(h1c->wait_event.tasklet);
+               } else {
+                       h1c->conn->xprt->subscribe(h1c->conn,
+                                                  h1c->conn->xprt_ctx,
+                                                  SUB_RETRY_RECV,
+                                                  &h1c->wait_event);
+               }
+       }
 
        if (!conn_is_back(conn))
                proxy_inc_fe_cum_sess_ver_ctr(sess->listener, proxy, 1);