From: Amaury Denoyelle Date: Mon, 25 Jan 2021 13:43:17 +0000 (+0100) Subject: MINOR: backend: search conn in idle tree after safe on always reuse X-Git-Tag: v2.4-dev8~74 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aa890aef3def1ad03b3bc4708bbf041e19a23a49;p=thirdparty%2Fhaproxy.git MINOR: backend: search conn in idle tree after safe on always reuse With http-reuse always, if no matching safe connection is found, check in idle tree for a matching one. This is needed because now idle connections can be differentiated from each other. If only the safe tree was checked because not empty, but did not contain a matching connection, we could miss matching entry in idle tree. --- diff --git a/src/backend.c b/src/backend.c index d561b821c4..c7fb3496d0 100644 --- a/src/backend.c +++ b/src/backend.c @@ -1306,8 +1306,15 @@ int connect_server(struct stream *s) /* search for a safe conn */ if (safe) srv_conn = conn_backend_get(s, srv, 1, hash); - else if (reuse_mode == PR_O_REUSE_ALWS && idle) + + /* search for an idle conn if no safe conn found + * on always reuse mode */ + if (!srv_conn && + reuse_mode == PR_O_REUSE_ALWS && idle) { + /* TODO conn_backend_get should not check the + * safe list is this case */ srv_conn = conn_backend_get(s, srv, 0, hash); + } } if (srv_conn)