From: Willy Tarreau Date: Fri, 18 Jan 2013 10:12:27 +0000 (+0100) Subject: BUG/MEDIUM: config: verbosely reject peers sections with multiple local peers X-Git-Tag: v1.5-dev18~124 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8b8fd56ca56d20931928154ea18f62a5198fb490;p=thirdparty%2Fhaproxy.git BUG/MEDIUM: config: verbosely reject peers sections with multiple local peers If a peers section contains several instances of the local peer name, only the first one was considered and the next ones were silently ignored. This can cause some trouble to debug such a configuration. Now the extra entries are rejected with an error message indicating where the first occurrence was found. --- diff --git a/src/cfgparse.c b/src/cfgparse.c index 87fbcfff3e..bbf0da2899 100644 --- a/src/cfgparse.c +++ b/src/cfgparse.c @@ -1555,6 +1555,8 @@ int cfg_parse_peers(const char *file, int linenum, char **args, int kwm) curpeers->peers_fe->timeout.connect = 5000; curpeers->peers_fe->accept = peer_accept; curpeers->peers_fe->options2 |= PR_O2_INDEPSTR | PR_O2_SMARTCON | PR_O2_SMARTACC; + curpeers->peers_fe->conf.file = strdup(file); + curpeers->peers_fe->conf.line = linenum; bind_conf = bind_conf_alloc(&curpeers->peers_fe->conf.bind, file, linenum, args[2]); @@ -1582,6 +1584,13 @@ int cfg_parse_peers(const char *file, int linenum, char **args, int kwm) global.maxsock += l->maxconn; } } + else { + Alert("parsing [%s:%d] : '%s %s' : local peer name already referenced at %s:%d.\n", + file, linenum, args[0], args[1], + curpeers->peers_fe->conf.file, curpeers->peers_fe->conf.line); + err_code |= ERR_FATAL; + goto out; + } } } /* neither "peer" nor "peers" */ else if (*args[0] != 0) {