]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: mux_h2: reject passive reverse conn if error on add to idle
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 16 Nov 2023 16:13:41 +0000 (17:13 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 16 Nov 2023 17:43:32 +0000 (18:43 +0100)
On passive reverse, H2 mux is responsible to insert the connection in
the server idle list. This is done via srv_add_to_idle_list(). However,
this function may fail for various reason, such as FD usage limit
reached.

Handle properly this error case. H2 mux flags the connection on error
which will cause its release. Prior to this patch, the connection was
only released on server timeout.

This bug was found inspecting server curr_used_conns counter. Indeed, on
connection reverse, this counter is first incremented. It is decremented
just after on srv_add_to_idle_list() if insertion is validated. However,
if insertion is rejected, the connection was not released which cause
curr_used_conns to remains positive. This has the major downside to
break the reusing of idle connection on rhttp causing spurrious 503
errors.

No need to backport.

src/mux_h2.c

index d70f5c5ba6a9873c4c8e5b27074c9f2a857b9d85..3883e15f6efc0796e6414aa50c6b51610c9bc484 100644 (file)
@@ -3295,7 +3295,8 @@ static int h2_conn_reverse(struct h2c *h2c)
 
                HA_ATOMIC_OR(&h2c->wait_event.tasklet->state, TASK_F_USR1);
                xprt_set_idle(conn, conn->xprt, conn->xprt_ctx);
-               srv_add_to_idle_list(srv, conn, 1);
+               if (!srv_add_to_idle_list(srv, conn, 1))
+                       goto err;
        }
        else {
                struct listener *l = __objt_listener(h2c->conn->target);