diff --git a/src/cfgparse.c b/src/cfgparse.c index bc9d93f86..a3f9c9636 100644 --- a/src/cfgparse.c +++ b/src/cfgparse.c @@ -5690,7 +5690,7 @@ int check_config_validity() struct listener *listener; unsigned int next_id; - if (!curproxy->uuid) { + if (curproxy->uuid < 0) { /* proxy ID not set, use automatic numbering with first * spare entry starting with next_pxid. */ @@ -6512,7 +6512,8 @@ int check_config_validity() } if (curproxy->cap & PR_CAP_FE) { - curproxy->accept = frontend_accept; + if (!curproxy->accept) + curproxy->accept = frontend_accept; if (curproxy->tcp_req.inspect_delay || !LIST_ISEMPTY(&curproxy->tcp_req.inspect_rules)) diff --git a/src/dumpstats.c b/src/dumpstats.c index c8b60a61b..07761218c 100644 --- a/src/dumpstats.c +++ b/src/dumpstats.c @@ -160,7 +160,8 @@ static struct proxy *alloc_stats_fe(const char *name, const char *file, int line return NULL; init_new_proxy(fe); - + fe->next = proxy; + proxy = fe; fe->last_change = now.tv_sec; fe->id = strdup("GLOBAL"); fe->cap = PR_CAP_FE; @@ -169,6 +170,10 @@ static struct proxy *alloc_stats_fe(const char *name, const char *file, int line fe->conf.file = strdup(file); fe->conf.line = line; fe->accept = stats_accept; + + /* the stats frontend is the only one able to assign ID #0 */ + fe->conf.id.key = fe->uuid = 0; + eb32_insert(&used_proxy_id, &fe->conf.id); return fe; } @@ -1709,8 +1714,8 @@ static int stats_dump_raw_to_buffer(struct stream_interface *si) if (si->applet.ctx.stats.flags & STAT_SHOW_STAT) { while (si->applet.ctx.stats.px) { px = si->applet.ctx.stats.px; - /* skip the disabled proxies and non-networked ones */ - if (px->state != PR_STSTOPPED && + /* skip the disabled proxies, global frontend and non-networked ones */ + if (px->state != PR_STSTOPPED && px->uuid > 0 && (px->cap & (PR_CAP_FE | PR_CAP_BE))) { if (stats_dump_proxy(si, px, NULL) == 0) return 0; @@ -2176,8 +2181,8 @@ static int stats_dump_http(struct stream_interface *si, struct uri_auth *uri) if (buffer_almost_full(&rep->buf)) return 0; px = si->applet.ctx.stats.px; - /* skip the disabled proxies and non-networked ones */ - if (px->state != PR_STSTOPPED && (px->cap & (PR_CAP_FE | PR_CAP_BE))) + /* skip the disabled proxies, global frontend and non-networked ones */ + if (px->state != PR_STSTOPPED && px->uuid > 0 && (px->cap & (PR_CAP_FE | PR_CAP_BE))) if (stats_dump_proxy(si, px, uri) == 0) return 0; diff --git a/src/proxy.c b/src/proxy.c index 820be2fa5..2c710bbbc 100644 --- a/src/proxy.c +++ b/src/proxy.c @@ -96,17 +96,17 @@ int get_backend_server(const char *bk_name, const char *sv_name, *sv = NULL; - pid = 0; + pid = -1; if (*bk_name == '#') pid = atoi(bk_name + 1); - sid = 0; + sid = -1; if (*sv_name == '#') sid = atoi(sv_name + 1); for (p = proxy; p; p = p->next) if ((p->cap & PR_CAP_BE) && - ((pid && p->uuid == pid) || - (!pid && strcmp(p->id, bk_name) == 0))) + ((pid >= 0 && p->uuid == pid) || + (pid < 0 && strcmp(p->id, bk_name) == 0))) break; if (bk) *bk = p; @@ -320,15 +320,15 @@ struct proxy *findproxy_mode(const char *name, int mode, int cap) { struct proxy *findproxy(const char *name, int cap) { struct proxy *curproxy, *target = NULL; - int pid = 0; + int pid = -1; if (*name == '#') pid = atoi(name + 1); for (curproxy = proxy; curproxy; curproxy = curproxy->next) { if ((curproxy->cap & cap) != cap || - (pid && curproxy->uuid != pid) || - (!pid && strcmp(curproxy->id, name))) + (pid >= 0 && curproxy->uuid != pid) || + (pid < 0 && strcmp(curproxy->id, name))) continue; if (!target) { @@ -451,6 +451,9 @@ void init_new_proxy(struct proxy *p) /* Timeouts are defined as -1 */ proxy_reset_timeouts(p); p->tcp_rep.inspect_delay = TICK_ETERNITY; + + /* initial uuid is unassigned (-1) */ + p->uuid = -1; } /*