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.
This commit is contained in:
Willy Tarreau 2025-07-10 10:56:34 +02:00
parent 732cd0dfa2
commit 12a6a3bb3f
4 changed files with 21 additions and 21 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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

View File

@ -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 <name>, or id
* if <name> starts with a '#'. NULL is returned if no match is found.
* the lookup is performed in the backend <bk>