diff --git a/src/cfgparse.c b/src/cfgparse.c index 344123115..3880549b8 100644 --- a/src/cfgparse.c +++ b/src/cfgparse.c @@ -4279,14 +4279,6 @@ init_proxies_list_stage2: /* enable separate counters */ if (curproxy->options2 & PR_O2_SOCKSTAT) { listener->counters = calloc(1, sizeof(*listener->counters)); - if (listener->counters) { - if (!counters_fe_shared_prepare(&listener->counters->shared, &listener->guid)) { - ha_free(&listener->counters); - ha_alert("config: %s '%s': out of memory.\n", - proxy_type_str(curproxy), curproxy->id); - } - - } if (!listener->name) memprintf(&listener->name, "sock-%d", listener->luid); } diff --git a/src/proxy.c b/src/proxy.c index 2bcd87f6f..028d2ac14 100644 --- a/src/proxy.c +++ b/src/proxy.c @@ -1748,6 +1748,7 @@ struct proxy *alloc_new_proxy(const char *name, unsigned int cap, char **errmsg) /* post-check for proxies */ static int proxy_postcheck(struct proxy *px) { + struct listener *listener; int err_code = ERR_NONE; /* allocate private memory for shared counters: used as a fallback @@ -1777,6 +1778,17 @@ static int proxy_postcheck(struct proxy *px) } + list_for_each_entry(listener, &px->conf.listeners, by_fe) { + if (listener->counters) { + if (!counters_fe_shared_prepare(&listener->counters->shared, &listener->guid)) { + ha_free(&listener->counters); + ha_alert("out of memory while setting up shared listener counters for %s %s\n", + proxy_type_str(px), px->id); + err_code |= ERR_ALERT | ERR_FATAL; + goto out; + } + } + } out: return err_code;