From 8b8fd56ca56d20931928154ea18f62a5198fb490 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Fri, 18 Jan 2013 11:12:27 +0100 Subject: [PATCH] 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. --- src/cfgparse.c | 9 +++++++++ 1 file changed, 9 insertions(+) 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) { -- 2.47.3