]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: server: do not check for duplicates anymore in findserver()
authorWilly Tarreau <w@1wt.eu>
Thu, 10 Jul 2025 08:48:05 +0000 (10:48 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 15 Jul 2025 08:30:27 +0000 (10:30 +0200)
findserver() used to check for duplicate server names. These are no
longer accepted in 3.3 so let's get rid of that test and simplify the
code. Note that the function still only uses the list instead of the
tree.

src/proxy.c

index 4a1af2032de2ed2af04c753c6ba1324fbc2a76d9..1c1e3722ddc8f8e99500890b6f4c63074a9ee327 100644 (file)
@@ -1378,34 +1378,23 @@ struct proxy *proxy_find_best_match(int cap, const char *name, int id, int *diff
 }
 
 /*
- * This function finds a server with matching name within selected proxy.
- * It also checks if there are more matching servers with
- * requested name as this often leads into unexpected situations.
+ * This function returns the server with a matching name within selected proxy,
+ * or NULL if not found.
  */
 
-struct server *findserver(const struct proxy *px, const char *name) {
-
-       struct server *cursrv, *target = NULL;
+struct server *findserver(const struct proxy *px, const char *name)
+{
+       struct server *cursrv;
 
        if (!px)
                return NULL;
 
        for (cursrv = px->srv; cursrv; cursrv = cursrv->next) {
-               if (strcmp(cursrv->id, name) != 0)
-                       continue;
-
-               if (!target) {
-                       target = cursrv;
-                       continue;
-               }
-
-               ha_alert("Refusing to use duplicated server '%s' found in proxy: %s!\n",
-                        name, px->id);
-
-               return NULL;
+               if (strcmp(cursrv->id, name) == 0)
+                       return cursrv;
        }
 
-       return target;
+       return NULL;
 }
 
 /* This function checks that the designated proxy has no http directives