mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-05 22:56:57 +02:00
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:
parent
732cd0dfa2
commit
12a6a3bb3f
@ -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);
|
||||
|
@ -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);
|
||||
|
20
src/proxy.c
20
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
|
||||
|
20
src/server.c
20
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 <name>, or id
|
||||
* if <name> starts with a '#'. NULL is returned if no match is found.
|
||||
* the lookup is performed in the backend <bk>
|
||||
|
Loading…
Reference in New Issue
Block a user