]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: server: skip servers with no idle conns earlier
authorWilly Tarreau <w@1wt.eu>
Wed, 1 Jul 2020 06:24:44 +0000 (08:24 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 1 Jul 2020 08:33:39 +0000 (10:33 +0200)
In conn_backend_get() we can avoid locking other servers when trying
to steal their connections when we know for sure they will not have
one, so let's do it to lower the contention on the lock.

src/backend.c

index f87e36e38f8732cbbebb80fc8259410612946182..0faf7240ab51dc73f6fd13bebae18519ffac7957 100644 (file)
@@ -1099,6 +1099,9 @@ static struct connection *conn_backend_get(struct server *srv, int is_safe)
        for (i = tid; !found && (i = ((i + 1 == global.nbthread) ? 0 : i + 1)) != tid;) {
                struct mt_list *elt1, elt2;
 
+               if (!srv->curr_idle_thr[i])
+                       continue;
+
                HA_SPIN_LOCK(OTHER_LOCK, &idle_conns[i].toremove_lock);
                mt_list_for_each_entry_safe(conn, &mt_list[i], list, elt1, elt2) {
                        if (conn->mux->takeover && conn->mux->takeover(conn) == 0) {