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.
This commit is contained in:
Willy Tarreau 2013-01-18 11:12:27 +01:00
parent ab012dd394
commit 8b8fd56ca5

View File

@ -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) {