]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MEDIUM: servers: Fix a race condition with idle connections.
authorOlivier Houchard <ohouchard@haproxy.com>
Thu, 11 Jul 2019 13:49:00 +0000 (15:49 +0200)
committerOlivier Houchard <cognet@ci0.org>
Thu, 11 Jul 2019 14:16:38 +0000 (16:16 +0200)
commit4be7190c1024b82248a55456ea44b40c40d4f066
tree03d2d3dcab8a17c46b2855b21277b7cad475a166
parent51596c166b856deaef04c089258b08d3b0b90be3
BUG/MEDIUM: servers: Fix a race condition with idle connections.

When we're purging idle connections, there's a race condition, when we're
removing the connection from the idle list, to add it to the list of
connections to free, if the thread owning the connection tries to free it
at the same time.
To fix this, simply add a per-thread lock, that has to be hold before
removing the connection from the idle list, and when, in conn_free(), we're
about to remove the connection from every list. That way, we know for sure
the connection will stay valid while we remove it from the idle list, to add
it to the list of connections to free.
This should happen rarely enough that it shouldn't have any impact on
performances.
This has not been reported yet, but could provoke random segfaults.

This should be backported to 2.0.
include/proto/connection.h
src/server.c