MINOR: cfgparse: Rework peers frontend init.
Even if not already the case, we suppose that the frontend "peers" section
may have been already initialized outside of "peer" line, we seperate
their initializations from their binding initializations.
May be backported to 1.5 and newer.
diff --git a/src/cfgparse.c b/src/cfgparse.c
index b7c85fa..a391b82 100644
--- a/src/cfgparse.c
+++ b/src/cfgparse.c
@@ -658,39 +658,37 @@
/* Current is local peer, it define a frontend */
newpeer->local = 1;
- if (!curpeers->peers_fe) {
- if (init_peers_frontend(file, linenum, args[1], curpeers) != 0) {
+ if (!curpeers->peers_fe &&
+ init_peers_frontend(file, linenum, args[1], curpeers) != 0) {
ha_alert("parsing [%s:%d] : out of memory.\n", file, linenum);
err_code |= ERR_ALERT | ERR_ABORT;
goto out;
- }
-
- bind_conf = bind_conf_alloc(curpeers->peers_fe, file, linenum, args[2], xprt_get(XPRT_RAW));
+ }
- if (!str2listener(args[2], curpeers->peers_fe, bind_conf, file, linenum, &errmsg)) {
- if (errmsg && *errmsg) {
- indent_msg(&errmsg, 2);
- ha_alert("parsing [%s:%d] : '%s %s' : %s\n", file, linenum, args[0], args[1], errmsg);
- }
- else
- ha_alert("parsing [%s:%d] : '%s %s' : error encountered while parsing listening address %s.\n",
- file, linenum, args[0], args[1], args[2]);
- err_code |= ERR_FATAL;
- goto out;
- }
+ bind_conf = bind_conf_alloc(curpeers->peers_fe, file, linenum, args[2], xprt_get(XPRT_RAW));
- list_for_each_entry(l, &bind_conf->listeners, by_bind) {
- l->maxaccept = 1;
- l->maxconn = curpeers->peers_fe->maxconn;
- l->backlog = curpeers->peers_fe->backlog;
- l->accept = session_accept_fd;
- l->analysers |= curpeers->peers_fe->fe_req_ana;
- l->default_target = curpeers->peers_fe->default_target;
- l->options |= LI_O_UNLIMITED; /* don't make the peers subject to global limits */
- global.maxsock += l->maxconn;
+ if (!str2listener(args[2], curpeers->peers_fe, bind_conf, file, linenum, &errmsg)) {
+ if (errmsg && *errmsg) {
+ indent_msg(&errmsg, 2);
+ ha_alert("parsing [%s:%d] : '%s %s' : %s\n", file, linenum, args[0], args[1], errmsg);
}
- cfg_peers->local = newpeer;
+ else
+ ha_alert("parsing [%s:%d] : '%s %s' : error encountered while parsing listening address %s.\n",
+ file, linenum, args[0], args[1], args[2]);
+ err_code |= ERR_FATAL;
+ goto out;
+ }
+ list_for_each_entry(l, &bind_conf->listeners, by_bind) {
+ l->maxaccept = 1;
+ l->maxconn = curpeers->peers_fe->maxconn;
+ l->backlog = curpeers->peers_fe->backlog;
+ l->accept = session_accept_fd;
+ l->analysers |= curpeers->peers_fe->fe_req_ana;
+ l->default_target = curpeers->peers_fe->default_target;
+ l->options |= LI_O_UNLIMITED; /* don't make the peers subject to global limits */
+ global.maxsock += l->maxconn;
}
+ cfg_peers->local = newpeer;
} /* neither "peer" nor "peers" */
else if (!strcmp(args[0], "disabled")) { /* disables this peers section */
curpeers->state = PR_STSTOPPED;