]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: backend: search conn in idle/safe trees after available
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Fri, 22 Jan 2021 18:37:44 +0000 (19:37 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Fri, 12 Feb 2021 11:33:05 +0000 (12:33 +0100)
If no matching connection is found on available, check on idle/safe
trees for a matching one. This is needed because now idle connections
can be differentiated from each other.

If only the available list was checked because not empty, but did not
contain a matching connection, we could miss matching entries in idle or
safe trees.

src/backend.c

index 7d256de36823409b2997be1b922b4e7c280a5a87..d561b821c4daf3a5935af878f083dc39aa80a6b1 100644 (file)
@@ -1288,8 +1288,9 @@ int connect_server(struct stream *s)
                        if (srv_conn)
                                reuse = 1;
                }
+
                /* if no available connections found, search for an idle/safe */
-               else if (srv->max_idle_conns && srv->curr_idle_conns > 0) {
+               if (!srv_conn && srv->max_idle_conns && srv->curr_idle_conns > 0) {
                        const int not_first_req = s->txn && s->txn->flags & TX_NOT_FIRST;
                        const int idle = srv->curr_idle_nb > 0;
                        const int safe = srv->curr_safe_nb > 0;