mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2024-12-26 06:32:13 +00:00
BUG/MINOR: server: fix server_find_by_name() usage during parsing
Since below commit, server_find_by_name() now search using
'used_server_id' proxy backend tree :
4bcfe30414
OPTIM: server: eb lookup for server_find_by_name()
This introduces a regression if server_find_by_name() is used via
check_config_validity() during post-parsing. Indeed, used_server_id tree
is populated at the same stage so it's possible to not found an existing
server. This can cause incorrect rejection of previously valid
configuration file.
To fix this, servers are now inserted in used_server_id tree during
parsing via parse_server(). This guarantees that server instances can be
retrieved during post parsing.
A known feature which uses server_find_by_name() during post parsing is
attach-srv tcp-rule used for reverse HTTP. Prior to the current fix, a
config was wrongly rejected if the rule was declared before the server
line.
This should not be backported unless the mentionned commit is.
This commit is contained in:
parent
9d869b10de
commit
b4db3be86e
@ -3658,8 +3658,6 @@ out_uri_auth_compat:
|
||||
newsrv->conf.id.key = newsrv->puid = next_id;
|
||||
eb32_insert(&curproxy->conf.used_server_id, &newsrv->conf.id);
|
||||
}
|
||||
newsrv->conf.name.key = newsrv->id;
|
||||
ebis_insert(&curproxy->conf.used_server_name, &newsrv->conf.name);
|
||||
|
||||
next_id++;
|
||||
newsrv = newsrv->next;
|
||||
|
10
src/server.c
10
src/server.c
@ -3008,6 +3008,9 @@ static int _srv_parse_tmpl_init(struct server *srv, struct proxy *px)
|
||||
/* Linked backwards first. This will be restablished after parsing. */
|
||||
newsrv->next = px->srv;
|
||||
px->srv = newsrv;
|
||||
|
||||
newsrv->conf.name.key = newsrv->id;
|
||||
ebis_insert(&curproxy->conf.used_server_name, &newsrv->conf.name);
|
||||
}
|
||||
_srv_parse_set_id_from_prefix(srv, srv->tmpl_info.prefix, srv->tmpl_info.nb_low);
|
||||
|
||||
@ -3525,8 +3528,13 @@ int parse_server(const char *file, int linenum, char **args,
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (parse_flags & SRV_PARSE_TEMPLATE)
|
||||
if (parse_flags & SRV_PARSE_TEMPLATE) {
|
||||
_srv_parse_tmpl_init(newsrv, curproxy);
|
||||
}
|
||||
else if (!(parse_flags & SRV_PARSE_DEFAULT_SERVER)) {
|
||||
newsrv->conf.name.key = newsrv->id;
|
||||
ebis_insert(&curproxy->conf.used_server_name, &newsrv->conf.name);
|
||||
}
|
||||
|
||||
/* If the server id is fixed, insert it in the proxy used_id tree.
|
||||
* This is needed to detect a later duplicate id via srv_parse_id.
|
||||
|
Loading…
Reference in New Issue
Block a user