]> git.ipfire.org Git - thirdparty/haproxy.git/commit
OPTIM: backend: reduce contention when checking MUX init with ALPN
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 19 Feb 2026 10:12:47 +0000 (11:12 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 19 Feb 2026 10:27:49 +0000 (11:27 +0100)
commitc71ef2969b2b055ef166e9fedea306a7bbe2dcba
treef6847afea62bfc81addc66306eb60d81c3360887
parent55e9c673811983529132c2e46a2fc5289740e55f
OPTIM: backend: reduce contention when checking MUX init with ALPN

In connect_server(), MUX initialization must be delayed if ALPN
negotiation is configured, unless ALPN can already be retrieved via the
server cache.

A readlock is used to consult the server cache. Prior to this patch, it
was always taken even if no ALPN is configured. The lock was thus used
for every new backend connection instantiation.

Rewrite the check so that now the lock is only used if ALPN is
configured. Thus, no lock access is done if SSL is not used or if ALPN
is not defined.

In practice, there will be no performance gain, as the read lock should
never block if ALPN is not configured. However, the code is cleaner as
it better reflect that only access to server nego_alpn requires the
path_params lock protection.
src/backend.c