mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-06 23:27:04 +02:00
MINOR: server: use the tree to look up the server name in findserver()
Let's just use the tree-based lookup instead of walking through the list. This function is used to find duplicates in "track" statements and a few such places, so it's important not to waste too much time on large setups.
This commit is contained in:
parent
12a6a3bb3f
commit
5e78ab33cd
@ -61,7 +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);
|
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(struct proxy *bk, int id);
|
||||||
struct server *server_find_by_id_unique(struct proxy *bk, int id, uint32_t rid);
|
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 *findserver(struct proxy *px, const char *name);
|
||||||
struct server *server_find_by_name(struct proxy *bk, 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_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);
|
struct server *server_find_best_match(struct proxy *bk, char *name, int id, int *diff);
|
||||||
|
13
src/server.c
13
src/server.c
@ -4006,20 +4006,17 @@ struct server *server_find_by_id_unique(struct proxy *bk, int id, uint32_t rid)
|
|||||||
* This function returns the server with a matching name within selected proxy,
|
* This function returns the server with a matching name within selected proxy,
|
||||||
* or NULL if not found.
|
* or NULL if not found.
|
||||||
*/
|
*/
|
||||||
|
struct server *findserver(struct proxy *px, const char *name)
|
||||||
struct server *findserver(const struct proxy *px, const char *name)
|
|
||||||
{
|
{
|
||||||
|
struct ebpt_node *node;
|
||||||
struct server *cursrv;
|
struct server *cursrv;
|
||||||
|
|
||||||
if (!px)
|
if (!px)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
for (cursrv = px->srv; cursrv; cursrv = cursrv->next) {
|
node = ebis_lookup(&px->conf.used_server_name, name);
|
||||||
if (strcmp(cursrv->id, name) == 0)
|
cursrv = node ? container_of(node, struct server, conf.name) : NULL;
|
||||||
return cursrv;
|
return cursrv;
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Returns a pointer to the first server matching either name <name>, or id
|
/* Returns a pointer to the first server matching either name <name>, or id
|
||||||
|
Loading…
Reference in New Issue
Block a user