From: Aurelien DARRAGON Date: Mon, 12 May 2025 15:12:49 +0000 (+0200) Subject: MINOR: proxy: collect per-capability stat in proxy_cond_disable() X-Git-Tag: v3.3-dev1~29 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6ccf770fe2cae4bea588e93947c87795d9f6f35f;p=thirdparty%2Fhaproxy.git MINOR: proxy: collect per-capability stat in proxy_cond_disable() proxy_cond_disable() collects and prints cumulated connections for be and fe proxies no matter their type. With shared stats it may cause issues because depending on the proxy capabilities only fe or be counters may be allocated. In this patch we add some checks to ensure we only try to read from valid memory locations, else we rely on default values (0). --- diff --git a/src/proxy.c b/src/proxy.c index 5ce282747..56066bf8e 100644 --- a/src/proxy.c +++ b/src/proxy.c @@ -2058,6 +2058,9 @@ void proxy_cond_resume(struct proxy *p) */ void proxy_cond_disable(struct proxy *p) { + long long cum_conn = 0; + long long cum_sess = 0; + if (p->flags & (PR_FL_DISABLED|PR_FL_STOPPED)) return; @@ -2072,13 +2075,18 @@ void proxy_cond_disable(struct proxy *p) * peers, etc) we must not report them at all as they're not really on * the data plane but on the control plane. */ + if (p->cap & PR_CAP_FE) + cum_conn = p->fe_counters.cum_conn; + if (p->cap & PR_CAP_BE) + cum_sess = p->be_counters.cum_sess; + if ((p->mode == PR_MODE_TCP || p->mode == PR_MODE_HTTP || p->mode == PR_MODE_SYSLOG || p->mode == PR_MODE_SPOP) && !(p->cap & PR_CAP_INT)) ha_warning("Proxy %s stopped (cumulated conns: FE: %lld, BE: %lld).\n", - p->id, p->fe_counters.cum_conn, p->be_counters.cum_sess); + p->id, cum_conn, cum_sess); if ((p->mode == PR_MODE_TCP || p->mode == PR_MODE_HTTP || p->mode == PR_MODE_SPOP) && !(p->cap & PR_CAP_INT)) send_log(p, LOG_WARNING, "Proxy %s stopped (cumulated conns: FE: %lld, BE: %lld).\n", - p->id, p->fe_counters.cum_conn, p->be_counters.cum_sess); + p->id, cum_conn, cum_sess); if (p->table && p->table->size && p->table->sync_task) task_wakeup(p->table->sync_task, TASK_WOKEN_MSG);