From: Willy Tarreau Date: Wed, 1 Jul 2020 11:57:49 +0000 (+0200) Subject: BUG/MINOR: server: fix the connection release logic regarding nearly full conditions X-Git-Tag: v2.2-dev12~35 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=35e30c9670dcc76d5a35d3472e38e4afaf93c615;p=thirdparty%2Fhaproxy.git BUG/MINOR: server: fix the connection release logic regarding nearly full conditions There was a logic bug in commit ddfe0743d ("MEDIUM: server: use the two thresholds for the connection release algorithm"): instead of keeping only our first idle connection when FDs become scarce, the condition was inverted resulting in enforcing this constraint unless FDs are scarce. This results in less idle connections than permitted to be kept under normal condition. No backport needed. --- diff --git a/include/haproxy/server.h b/include/haproxy/server.h index 1fa1b2d4db..6ab6c07fa8 100644 --- a/include/haproxy/server.h +++ b/include/haproxy/server.h @@ -255,11 +255,11 @@ static inline int srv_add_to_idle_list(struct server *srv, struct connection *co ((srv->proxy->options & PR_O_REUSE_MASK) != PR_O_REUSE_NEVR) && ha_used_fds < global.tune.pool_high_count && (srv->max_idle_conns == -1 || srv->max_idle_conns > srv->curr_idle_conns) && - ((ha_used_fds < global.tune.pool_low_count && - MT_LIST_ISEMPTY(&srv->safe_conns[tid]) && + ((MT_LIST_ISEMPTY(&srv->safe_conns[tid]) && (is_safe || MT_LIST_ISEMPTY(&srv->idle_conns[tid]))) || - (srv->curr_used_conns + srv->curr_idle_conns < - MAX(srv->curr_used_conns, srv->est_need_conns) + global.nbthread)) && + (ha_used_fds < global.tune.pool_low_count && + (srv->curr_used_conns + srv->curr_idle_conns < + MAX(srv->curr_used_conns, srv->est_need_conns) + global.nbthread))) && !conn->mux->used_streams(conn) && conn->mux->avail_streams(conn)) { int retadd;