break;
}
- /* Check that no server name conflicts. This causes trouble in the stats.
- * We only emit an error for the first conflict affecting each server,
- * in order to avoid combinatory explosion if all servers have the same
- * name. Since servers names are stored in a tree before landing here,
- * we simply have to check for the current server's duplicates to spot
- * conflicts.
- */
- list_for_each_entry(newsrv, &px->servers, el_px) {
- struct server *other_srv;
-
- /* Note: internal servers are not always registered and
- * they do not conflict.
- */
- if (!ceb_intree(&newsrv->conf.name_node))
- continue;
-
- if ((other_srv = cebis_item_prev_dup(&px->conf.used_server_name, conf.name_node, id, newsrv))) {
- ha_alert("parsing [%s:%d] : %s '%s', another server named '%s' was already defined at line %d, please use distinct names.\n",
- newsrv->conf.file, newsrv->conf.line,
- proxy_type_str(px), px->id,
- newsrv->id, other_srv->conf.line);
- cfgerr++;
- continue;
- }
- }
-
/* assign automatic UIDs to servers which don't have one yet */
next_id = 1;
list_for_each_entry(newsrv, &px->servers, el_px) {
static int _srv_parse_tmpl_init(struct server *srv, struct proxy *px)
{
int err_code = ERR_NONE, i = 0;
- struct server *newsrv = NULL;
+ struct server *newsrv = NULL, *other;
char *msg = NULL;
/* Set the first server's ID. */
goto out;
}
+ if ((other = server_find_by_name(px, srv->id))) {
+ ha_alert("another server named '%s' was already defined at line %d, please use a distinct name.\n",
+ srv->id, other->conf.line);
+ err_code |= ERR_ALERT | ERR_FATAL;
+ goto out;
+ }
+
cebis_item_insert(&curproxy->conf.used_server_name, conf.name_node, id, srv);
/* then create other servers from this one */
goto out;
}
+ if ((other = server_find_by_name(px, newsrv->id))) {
+ ha_alert("another server named '%s' was already defined at line %d, please use a distinct name.\n",
+ newsrv->id, other->conf.line);
+ err_code |= ERR_ALERT | ERR_FATAL;
+ goto out;
+ }
+
cebis_item_insert(&curproxy->conf.used_server_name, conf.name_node, id, newsrv);
}
struct proxy *curproxy,
int parse_flags)
{
- struct server *newsrv = NULL;
+ struct server *newsrv = NULL, *other;
const char *err = NULL;
int err_code = 0;
char *fqdn = NULL;
err_code |= ERR_ALERT | ERR_ABORT;
goto out;
}
+
+ if ((other = server_find_by_name(curproxy, newsrv->id))) {
+ ha_alert("another server named '%s' was already defined at line %d, please use a distinct name.\n",
+ args[1], other->conf.line);
+ err_code |= ERR_ALERT | ERR_FATAL;
+ goto out;
+ }
}
else {
newsrv->tmpl_info.prefix = strdup(args[1]);