mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-06 23:27:04 +02:00
CLEANUP: server: rename server_find_by_name() to server_find()
This function doesn't just look at the name but also the ID when the argument starts with a '#'. So the name is not correct and explains why this function is not always used when the name only is needed, and why the list-based findserver() is used instead. So let's just call the function "server_find()", and rename its generation-id based cousin "server_find_unique()".
This commit is contained in:
parent
5e78ab33cd
commit
6ad9285796
@ -62,8 +62,8 @@ const char *srv_update_agent_addr_port(struct server *s, const char *addr, const
|
||||
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(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(struct proxy *bk, const char *name);
|
||||
struct server *server_find_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);
|
||||
void apply_server_state(void);
|
||||
void srv_compute_all_admin_states(struct proxy *px);
|
||||
|
@ -3716,7 +3716,7 @@ sample_conv_srv_queue(const struct arg *args, struct sample *smp, void *private)
|
||||
px = smp->px;
|
||||
}
|
||||
|
||||
srv = server_find_by_name(px, smp->data.u.str.area);
|
||||
srv = server_find(px, smp->data.u.str.area);
|
||||
if (!srv)
|
||||
return 0;
|
||||
|
||||
|
@ -1863,7 +1863,7 @@ int hlua_listable_servers_index(lua_State *L)
|
||||
name = luaL_checkstring(L, 2);
|
||||
|
||||
/* Perform a server lookup in px list */
|
||||
srv = server_find_by_name(hlua_srv->px, name);
|
||||
srv = server_find(hlua_srv->px, name);
|
||||
if (srv == NULL) {
|
||||
lua_pushnil(L);
|
||||
return 1;
|
||||
|
@ -355,7 +355,7 @@ int rhttp_bind_listener(struct listener *listener, char *errmsg, int errlen)
|
||||
snprintf(errmsg, errlen, "No such backend: '%s'.", name);
|
||||
goto err;
|
||||
}
|
||||
if (!(srv = server_find_by_name(be, ist0(sv_name)))) {
|
||||
if (!(srv = server_find(be, ist0(sv_name)))) {
|
||||
snprintf(errmsg, errlen, "No such server: '%s/%s'.", ist0(be_name), ist0(sv_name));
|
||||
goto err;
|
||||
}
|
||||
|
16
src/server.c
16
src/server.c
@ -4023,7 +4023,7 @@ struct server *findserver(struct proxy *px, const char *name)
|
||||
* if <name> starts with a '#'. NULL is returned if no match is found.
|
||||
* the lookup is performed in the backend <bk>
|
||||
*/
|
||||
struct server *server_find_by_name(struct proxy *bk, const char *name)
|
||||
struct server *server_find(struct proxy *bk, const char *name)
|
||||
{
|
||||
struct server *curserver;
|
||||
|
||||
@ -4066,11 +4066,11 @@ struct server *server_find_by_name(struct proxy *bk, const char *name)
|
||||
* a different server from the one we were expecting to match against at a given
|
||||
* time.
|
||||
*/
|
||||
struct server *server_find_by_name_unique(struct proxy *bk, const char *name, uint32_t rid)
|
||||
struct server *server_find_unique(struct proxy *bk, const char *name, uint32_t rid)
|
||||
{
|
||||
struct server *curserver;
|
||||
|
||||
curserver = server_find_by_name(bk, name);
|
||||
curserver = server_find(bk, name);
|
||||
if (!curserver || curserver->rid != rid)
|
||||
return NULL;
|
||||
return curserver;
|
||||
@ -4090,7 +4090,7 @@ struct server *server_find_best_match(struct proxy *bk, char *name, int id, int
|
||||
byname = byid = NULL;
|
||||
|
||||
if (name) {
|
||||
byname = server_find_by_name(bk, name);
|
||||
byname = server_find(bk, name);
|
||||
if (byname && (!id || byname->puid == id))
|
||||
return byname;
|
||||
}
|
||||
@ -5334,7 +5334,7 @@ struct server *cli_find_server(struct appctx *appctx, char *arg)
|
||||
cli_err(appctx, "No such backend.\n");
|
||||
return NULL;
|
||||
}
|
||||
if (!(sv = server_find_by_name(px, ist0(sv_name)))) {
|
||||
if (!(sv = server_find(px, ist0(sv_name)))) {
|
||||
cli_err(appctx, "No such server.\n");
|
||||
return NULL;
|
||||
}
|
||||
@ -5584,7 +5584,7 @@ static int cli_parse_get_weight(char **args, char *payload, struct appctx *appct
|
||||
|
||||
if (!(be = proxy_be_by_name(ist0(be_name))))
|
||||
return cli_err(appctx, "No such backend.\n");
|
||||
if (!(sv = server_find_by_name(be, ist0(sv_name))))
|
||||
if (!(sv = server_find(be, ist0(sv_name))))
|
||||
return cli_err(appctx, "No such server.\n");
|
||||
|
||||
/* return server's effective weight at the moment */
|
||||
@ -6060,7 +6060,7 @@ static int cli_parse_add_server(char **args, char *payload, struct appctx *appct
|
||||
/*
|
||||
* If a server with the same name is found, reject the new one.
|
||||
*/
|
||||
if (server_find_by_name(be, sv_name)) {
|
||||
if (server_find(be, sv_name)) {
|
||||
thread_release();
|
||||
cli_err(appctx, "Already exists a server with the same name in backend.\n");
|
||||
return 1;
|
||||
@ -6291,7 +6291,7 @@ int srv_check_for_deletion(const char *bename, const char *svname, struct proxy
|
||||
goto leave;
|
||||
}
|
||||
|
||||
if (!(srv = server_find_by_name(be, svname))) {
|
||||
if (!(srv = server_find(be, svname))) {
|
||||
msg = "No such server.";
|
||||
goto leave;
|
||||
}
|
||||
|
@ -3850,7 +3850,7 @@ static int cli_parse_show_sess(char **args, char *payload, struct appctx *appctx
|
||||
if (!(be = proxy_be_by_name(ist0(be_name))))
|
||||
return cli_err(appctx, "No such backend.\n");
|
||||
|
||||
if (!(sv = server_find_by_name(be, ist0(sv_name))))
|
||||
if (!(sv = server_find(be, ist0(sv_name))))
|
||||
return cli_err(appctx, "No such server.\n");
|
||||
ctx->flags |= CLI_SHOWSESS_F_SERVER;
|
||||
ctx->filter = sv;
|
||||
|
@ -508,7 +508,7 @@ static int tcp_check_attach_srv(struct act_rule *rule, struct proxy *px, char **
|
||||
memprintf(err, "attach-srv rule: no such backend '%s/%s'", ist0(be_name), ist0(sv_name));
|
||||
return 0;
|
||||
}
|
||||
if (!(srv = server_find_by_name(be, ist0(sv_name)))) {
|
||||
if (!(srv = server_find(be, ist0(sv_name)))) {
|
||||
memprintf(err, "attach-srv rule: no such server '%s/%s'", ist0(be_name), ist0(sv_name));
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user