BUG/MINOR: connection: rearrange union list members
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Wed, 27 Aug 2025 12:58:59 +0000 (14:58 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 1 Oct 2025 14:48:34 +0000 (16:48 +0200)
commit7134bca7fbd58711cc0772ffa70a0e462f3ec0eb
treef0af51429eef52c66df052f97a11953166a30bf8
parentfa73e99233e9f6673266f23f7f94e20657ac27fb
BUG/MINOR: connection: rearrange union list members

A connection can be stored in several lists, thus there is several
attach points in struct connection. Depending on its proxy side, either
frontend or backend, a single connection will only access some of them
during its lifetime.

As an optimization, these attach points are organized in a union.
However, this repartition was not correctly achieved along
frontend/backend side delimitation.

Furthermore, reverse HTTP has recently been introduced. With this
feature, a connection can migrate from frontend to backend side or vice
versa. As such, it becomes even more tedious to ensure that these
members are always accessed in a safe way.

This commit rearrange these fields. First, union is now clearly splitted
between frontend and backend only elements. Next, backend elements are
initialized with conn_backend_init(), which is already used during
connection reversal on an edge endpoint. A new function
conn_frontend_init() serves to initialize the other members, called both
on connection first instantiation and on reversal on a dialer endpoint.

This model is much cleaner and should prevent any access to fields from
the wrong side.

Currently, there is no known case of wrong access in the existing code
base. However, this cleanup is considered an improvement which must be
backported up to 3.0 to remove any possible undefined behavior.

(cherry picked from commit a96f1286a75246fef6db3e615fabdef1de927d83)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit efed852704238d4a523a1154c061e47ca704b951)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 284a60cbbd00409a98e8b2f238ab6667748f0cd1)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
include/haproxy/connection-t.h
src/connection.c