diff --git a/src/cfgparse.c b/src/cfgparse.c index 40c5a16e1..52bf2ffdd 100644 --- a/src/cfgparse.c +++ b/src/cfgparse.c @@ -615,9 +615,10 @@ static struct bind_conf *bind_conf_uniq_alloc(struct proxy *p, if (!LIST_ISEMPTY(&p->conf.bind)) { bind_conf = LIST_ELEM((&p->conf.bind)->n, typeof(bind_conf), by_fe); - free(bind_conf->file); - bind_conf->file = strdup(file); - bind_conf->line = line; + /* + * We keep bind_conf->file and bind_conf->line unchanged + * to make them available for error messages + */ if (arg) { free(bind_conf->arg); bind_conf->arg = strdup(arg); @@ -712,6 +713,11 @@ int cfg_parse_peers(const char *file, int linenum, char **args, int kwm) goto out; } + if (!LIST_ISEMPTY(&bind_conf->listeners)) { + ha_alert("parsing [%s:%d] : One listener per \"peers\" section is authorized but another is already configured at [%s:%d].\n", file, linenum, bind_conf->file, bind_conf->line); + err_code |= ERR_FATAL; + } + if (!str2listener(args[1], curpeers->peers_fe, bind_conf, file, linenum, &errmsg)) { if (errmsg && *errmsg) { indent_msg(&errmsg, 2); @@ -910,6 +916,11 @@ int cfg_parse_peers(const char *file, int linenum, char **args, int kwm) bind_conf = bind_conf_uniq_alloc(curpeers->peers_fe, file, linenum, args[2], xprt_get(XPRT_RAW)); + if (!LIST_ISEMPTY(&bind_conf->listeners)) { + ha_alert("parsing [%s:%d] : One listener per \"peers\" section is authorized but another is already configured at [%s:%d].\n", file, linenum, bind_conf->file, bind_conf->line); + err_code |= ERR_FATAL; + } + if (!str2listener(args[2], curpeers->peers_fe, bind_conf, file, linenum, &errmsg)) { if (errmsg && *errmsg) { indent_msg(&errmsg, 2);