]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: stream: use server_find_by_addr() in sticking_rule_find_target()
authorWilly Tarreau <w@1wt.eu>
Thu, 10 Jul 2025 12:47:35 +0000 (14:47 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 15 Jul 2025 08:30:28 +0000 (10:30 +0200)
This makes this function a bit less of a mess by no longer manipulating
the low-level server address nodes nor the proxy lock.

src/stream.c

index ef6ae84e4efd2c151f2451fa26dc8c3f031cc79d..acc157098358b25ed47277fcae0990804582d86f 100644 (file)
@@ -1252,7 +1252,7 @@ static inline void sticking_rule_find_target(struct stream *s,
        struct proxy *px = s->be;
        struct dict_entry *de;
        void *ptr;
-       struct server *srv;
+       struct server *srv = NULL;
        int id;
 
        /* Look for the server name previously stored in <t> stick-table */
@@ -1262,21 +1262,13 @@ static inline void sticking_rule_find_target(struct stream *s,
        HA_RWLOCK_RDUNLOCK(STK_SESS_LOCK, &ts->lock);
 
        if (de) {
-               struct ebpt_node *node;
-
-               if (t->server_key_type == STKTABLE_SRV_NAME) {
+               if (t->server_key_type == STKTABLE_SRV_NAME)
                        srv = server_find_by_name(px, de->value.key);
-                       if (srv)
-                               goto found;
-               } else if (t->server_key_type == STKTABLE_SRV_ADDR) {
-                       HA_RWLOCK_RDLOCK(PROXY_LOCK, &px->lock);
-                       node = ebis_lookup(&px->used_server_addr, de->value.key);
-                       HA_RWLOCK_RDUNLOCK(PROXY_LOCK, &px->lock);
-                       if (node) {
-                               srv = container_of(node, struct server, addr_node);
-                               goto found;
-                       }
-               }
+               else if (t->server_key_type == STKTABLE_SRV_ADDR)
+                       srv = server_find_by_addr(px, de->value.key);
+
+               if (srv)
+                       goto found;
        }
 
        /* Look for the server ID */