From: Willy Tarreau Date: Thu, 10 Jul 2025 08:56:34 +0000 (+0200) Subject: REORG: server: move findserver() from proxy.c to server.c X-Git-Tag: v3.3-dev4~97 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=12a6a3bb3fcfb72497e5944c2e1f696fafd033e5;p=thirdparty%2Fhaproxy.git REORG: server: move findserver() from proxy.c to server.c The reason this function was overlooked is that it had mostly equivalent ones in server.c, let's move them together. --- diff --git a/include/haproxy/proxy.h b/include/haproxy/proxy.h index 8fed1b69e..4e371241c 100644 --- a/include/haproxy/proxy.h +++ b/include/haproxy/proxy.h @@ -61,7 +61,6 @@ void proxy_store_name(struct proxy *px); struct proxy *proxy_find_by_id(int id, int cap, int table); struct proxy *proxy_find_by_name(const char *name, int cap, int table); struct proxy *proxy_find_best_match(int cap, const char *name, int id, int *diff); -struct server *findserver(const struct proxy *px, const char *name); int proxy_cfg_ensure_no_http(struct proxy *curproxy); int proxy_cfg_ensure_no_log(struct proxy *curproxy); void init_new_proxy(struct proxy *p); diff --git a/include/haproxy/server.h b/include/haproxy/server.h index db134f153..e435f9a1f 100644 --- a/include/haproxy/server.h +++ b/include/haproxy/server.h @@ -61,6 +61,7 @@ const char *srv_update_check_addr_port(struct server *s, const char *addr, const const char *srv_update_agent_addr_port(struct server *s, const char *addr, const char *port); struct server *server_find_by_id(struct proxy *bk, int id); struct server *server_find_by_id_unique(struct proxy *bk, int id, uint32_t rid); +struct server *findserver(const struct proxy *px, const char *name); struct server *server_find_by_name(struct proxy *bk, const char *name); struct server *server_find_by_name_unique(struct proxy *bk, const char *name, uint32_t rid); struct server *server_find_best_match(struct proxy *bk, char *name, int id, int *diff); diff --git a/src/proxy.c b/src/proxy.c index 1c1e3722d..24939662f 100644 --- a/src/proxy.c +++ b/src/proxy.c @@ -1377,26 +1377,6 @@ struct proxy *proxy_find_best_match(int cap, const char *name, int id, int *diff return NULL; } -/* - * 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; - - if (!px) - return NULL; - - for (cursrv = px->srv; cursrv; cursrv = cursrv->next) { - if (strcmp(cursrv->id, name) == 0) - return cursrv; - } - - return NULL; -} - /* This function checks that the designated proxy has no http directives * enabled. It will output a warning if there are, and will fix some of them. * It returns the number of fatal errors encountered. This should be called diff --git a/src/server.c b/src/server.c index 232446c6f..44e7c4858 100644 --- a/src/server.c +++ b/src/server.c @@ -4002,6 +4002,26 @@ struct server *server_find_by_id_unique(struct proxy *bk, int id, uint32_t rid) return curserver; } +/* + * 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; + + if (!px) + return NULL; + + for (cursrv = px->srv; cursrv; cursrv = cursrv->next) { + if (strcmp(cursrv->id, name) == 0) + return cursrv; + } + + return NULL; +} + /* Returns a pointer to the first server matching either name , or id * if starts with a '#'. NULL is returned if no match is found. * the lookup is performed in the backend