From: Willy Tarreau Date: Tue, 12 Mar 2024 07:16:16 +0000 (+0100) Subject: BUG/MINOR: server: fix first server template not being indexed X-Git-Tag: v3.0-dev6~106 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7223296092c72c2b10729a6da218897887858dba;p=thirdparty%2Fhaproxy.git BUG/MINOR: server: fix first server template not being indexed 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. --- diff --git a/src/server.c b/src/server.c index 8b0d406602..1450b0477a 100644 --- a/src/server.c +++ b/src/server.c @@ -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)