BUG/MAJOR: connection: Never remove connection from idle lists outside the lock

Since the idle connections management changed to use eb-trees instead of MT
lists, a lock must be acquired to manipulate servers idle/safe/available
connection lists. However, it remains an unprotected use in
connect_server(), when a connection is removed from an idle list if the mux
has no more streams available. Thus it is possible to remove a connection
from an idle list on a thread, while another one is looking for a idle
connection. Of couse, this may lead to a crash.

To fix the bug, we must take care to acquire the idle connections lock
first. The bug was introduced by the commit f232cb3e9 ("MEDIUM: connection:
replace idle conn lists by eb trees").

The patch must be backported as far as 2.4.

(cherry picked from commit 7ae48a70d6f2de0a6d2b4426bdb2a129baffc579)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 098dc0b3283059f97998c20f4e6ab6e2e9cf43dd)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
1 file changed