From aa890aef3def1ad03b3bc4708bbf041e19a23a49 Mon Sep 17 00:00:00 2001 From: Amaury Denoyelle Date: Mon, 25 Jan 2021 14:43:17 +0100 Subject: [PATCH] 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. --- src/backend.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/backend.c b/src/backend.c index d561b821c..c7fb3496d 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)