]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MEDIUM: connection: Preserve flags when a conn is removed from an idle list
authorChristopher Faulet <cfaulet@haproxy.com>
Thu, 16 Mar 2023 10:43:05 +0000 (11:43 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 16 Mar 2023 14:34:20 +0000 (15:34 +0100)
commit3a7b539b124bccaa57478e0a5a6d66338594615a
tree6f35ed8e3191ee0819cc9a504bee34242c4507b9
parentfc546ab6a7346605c62760569c9afd0c99c6dd76
BUG/MEDIUM: connection: Preserve flags when a conn is removed from an idle list

The commit 5e1b0e7bf ("BUG/MEDIUM: connection: Clear flags when a conn is
removed from an idle list") introduced a regression. CO_FL_SAFE_LIST and
CO_FL_IDLE_LIST flags are used when the connection is released to properly
decrement used/idle connection counters. if a connection is idle, these
flags must be preserved till the connection is really released. It may be
removed from the list but not immediately released. If these flags are lost
when it is finally released, the current number of used connections is
erroneously decremented. If means this counter may become negative and the
counters tracking the number of idle connecitons is not decremented,
suggesting a leak.

So, the above commit is reverted and instead we improve a bit the way to
detect an idle connection. The function conn_get_idle_flag() must now be
used to know if a connection is in an idle list. It returns the connection
flag corresponding to the idle list if the connection is idle
(CO_FL_SAFE_LIST or CO_FL_IDLE_LIST) or 0 otherwise. But if the connection
is scheduled to be removed, 0 is also returned, regardless the connection
flags.

This new function is used when the connection is temporarily removed from
the list to be used, mainly in muxes.

This patch should fix #2078 and #2057. It must be backported as far as 2.2.
include/haproxy/connection.h
src/connection.c
src/mux_fcgi.c
src/mux_h1.c
src/mux_h2.c
src/server.c
src/ssl_sock.c