]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: server: fix first server template not being indexed
authorWilly Tarreau <w@1wt.eu>
Tue, 12 Mar 2024 07:16:16 +0000 (08:16 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 12 Mar 2024 07:23:03 +0000 (08:23 +0100)
3.0-dev1 introduced a small regression with commit b4db3be86e ("BUG/MINOR:
server: fix server_find_by_name() usage during parsing"). By changing the
way servers are indexed and moving it into the server template loop, the
first one is no longer indexed because the loop starts at low+1 since it
focuses on duplication. Let's index the first one explicitly now.

This should not be backported, unless the commit above is backported.

src/server.c

index 8b0d4066029c184999724320966f05ec03990ca1..1450b0477accf4e6a0ca66ef96235701eb4d6dd8 100644 (file)
@@ -3017,6 +3017,12 @@ static int _srv_parse_tmpl_init(struct server *srv, struct proxy *px)
        int i;
        struct server *newsrv;
 
+       /* Set the first server's ID. */
+       _srv_parse_set_id_from_prefix(srv, srv->tmpl_info.prefix, srv->tmpl_info.nb_low);
+       srv->conf.name.key = srv->id;
+       ebis_insert(&curproxy->conf.used_server_name, &srv->conf.name);
+
+       /* then create other servers from this one */
        for (i = srv->tmpl_info.nb_low + 1; i <= srv->tmpl_info.nb_high; i++) {
                newsrv = new_server(px);
                if (!newsrv)