]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: server: use server_find_by_id() when looking for already used IDs
authorWilly Tarreau <w@1wt.eu>
Sat, 23 Aug 2025 17:26:54 +0000 (19:26 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 16 Sep 2025 07:23:46 +0000 (09:23 +0200)
In srv_parse_id(), there's no point doing all the low-level work with
the tree functions to check for the existence of an ID, we already have
server_find_by_id() which does exactly this, so let's use it.

src/server.c

index a5dc0ff5c91520a3dd438996b0447c72281e9719..a473b56a54c91909effdd2922bf749acf5ac9b4e 100644 (file)
@@ -1302,7 +1302,7 @@ static int srv_parse_pool_max_conn(char **args, int *cur_arg, struct proxy *curp
 /* parse the "id" server keyword */
 static int srv_parse_id(char **args, int *cur_arg, struct proxy *curproxy, struct server *newsrv, char **err)
 {
-       struct eb32_node *node;
+       struct server *target;
 
        if (!*args[*cur_arg + 1]) {
                memprintf(err, "'%s' : expects an integer argument", args[*cur_arg]);
@@ -1317,9 +1317,8 @@ static int srv_parse_id(char **args, int *cur_arg, struct proxy *curproxy, struc
                return ERR_ALERT | ERR_FATAL;
        }
 
-       node = eb32_lookup(&curproxy->conf.used_server_id, newsrv->puid);
-       if (node) {
-               struct server *target = container_of(node, struct server, conf.id);
+       target = server_find_by_id(curproxy, newsrv->puid);
+       if (target) {
                memprintf(err, "'%s' : custom id %d already used at %s:%d ('server %s')",
                          args[*cur_arg], newsrv->puid, target->conf.file, target->conf.line,
                          target->id);