mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-09-21 05:41:26 +02:00
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.