]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: session: always reset the conn->owner on backend when installing mux
authorWilly Tarreau <w@1wt.eu>
Mon, 20 Apr 2026 12:05:09 +0000 (14:05 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 21 Apr 2026 06:45:46 +0000 (08:45 +0200)
When installing a mux on the backend, unless we have a good reason for
keeping the session set in conn->owner, we must reset it. Having the
session there just hides potential bugs and prevents certain tests from
being properly done.

Now it is much clearer: conn->owner remains set to the session on
frontend connections, is set to the session when the connection is
private or assimilated private and belongs to the session list, or
is NULL.

src/connection.c

index f75895a76df9b4156e2147efd98a642b32ccb149..f5f5d5ee47ca4333fcece9e9a0ea6c3b3095057d 100644 (file)
@@ -383,6 +383,17 @@ int conn_install_mux_be(struct connection *conn, void *ctx, struct session *sess
                if (!mux_ops)
                        return -1;
        }
+
+       /* unless the connection is private or it's temporarily reserved to the
+        * session due to a mux presenting a risk of head-of-line blocking and
+        * the reuse mode is set to "safe", we should reset the owner to avoid
+        * any ambiguity.
+        */
+       if (!(conn->flags & CO_FL_PRIVATE) &&
+           ((prx->options & PR_O_REUSE_MASK) != PR_O_REUSE_SAFE ||
+            !(mux_ops->flags & MX_FL_HOL_RISK)))
+               conn->owner = NULL;
+
        return conn_install_mux(conn, mux_ops, ctx, prx, sess);
 }