]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: proxy: improve code when checking server name conflicts
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 23 Feb 2026 09:10:05 +0000 (10:10 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 23 Feb 2026 15:28:41 +0000 (16:28 +0100)
During proxy_finalize(), a lookup is performed over the servers by name
tree to detect any collision. Only the first conflict for each server
instance is reported to avoid a combinatory explosion with too many
alerts shown.

Previously, this was written using a for loop without any iteration.
Replace this by a simple if statement as this is cleaner.

This should fix github issue #3276.

src/proxy.c

index dadcff0c6949b8e0f448635a49fe6c03af1ed1b6..49aa4a2ec9f202fb6f8ba1ee890f4196c6e15430 100644 (file)
@@ -2481,14 +2481,13 @@ int proxy_finalize(struct proxy *px, int *err_code)
                if (!ceb_intree(&newsrv->conf.name_node))
                        continue;
 
-               for (other_srv = newsrv;
-                    (other_srv = cebis_item_prev_dup(&px->conf.used_server_name, conf.name_node, id, other_srv)); ) {
+               if ((other_srv = cebis_item_prev_dup(&px->conf.used_server_name, conf.name_node, id, newsrv))) {
                        ha_alert("parsing [%s:%d] : %s '%s', another server named '%s' was already defined at line %d, please use distinct names.\n",
                                 newsrv->conf.file, newsrv->conf.line,
                                 proxy_type_str(px), px->id,
                                 newsrv->id, other_srv->conf.line);
                        cfgerr++;
-                       break;
+                       continue;
                }
        }