From 56717803e1f8dbe16a825a0dc8a35953a324e9cc Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Wed, 13 Oct 2021 10:10:09 +0200 Subject: [PATCH] MINOR: proxy: Add PR_FL_READY flag on fully configured and usable proxies The PR_FL_READY flags must now be set on a proxy at the end of the configuration validity check to notify it is fully configured and may be safely used. For now there is no real usage of this flag. But it will be usefull for referenced default proxies to finish their configuration only once. This patch is mandatory to support TCP/HTTP rules in defaults sections. --- include/haproxy/proxy-t.h | 1 + src/cfgparse.c | 2 ++ src/proxy.c | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/include/haproxy/proxy-t.h b/include/haproxy/proxy-t.h index 20c97dab9c..8ca4e818d6 100644 --- a/include/haproxy/proxy-t.h +++ b/include/haproxy/proxy-t.h @@ -203,6 +203,7 @@ enum PR_SRV_STATE_FILE { /* Proxy flags */ #define PR_FL_DISABLED 0x01 /* The proxy was disabled in the configuration (not at runtime) */ #define PR_FL_STOPPED 0x02 /* The proxy was stopped */ +#define PR_FL_READY 0x04 /* The proxy is ready to be used (initialized and configured) */ #define PR_FL_EXPLICIT_REF 0x08 /* The default proxy is explicitly referenced by another proxy */ #define PR_FL_IMPLICIT_REF 0x10 /* The default proxy is implicitly referenced by another proxy */ diff --git a/src/cfgparse.c b/src/cfgparse.c index dbb55ed48a..1db94c6522 100644 --- a/src/cfgparse.c +++ b/src/cfgparse.c @@ -3840,6 +3840,7 @@ out_uri_auth_compat: if (curproxy->task) { curproxy->task->context = curproxy; curproxy->task->process = manage_proxy; + curproxy->flags |= PR_FL_READY; } else { ha_alert("Proxy '%s': no more memory when trying to allocate the management task\n", curproxy->id); @@ -3895,6 +3896,7 @@ out_uri_auth_compat: * Note that ->srv is used by the local peer of a new process to connect to the local peer * of an old process. */ + curpeers->peers_fe->flags |= PR_FL_READY; p = curpeers->remote; while (p) { if (p->srv) { diff --git a/src/proxy.c b/src/proxy.c index 36e278321f..c66aa8874d 100644 --- a/src/proxy.c +++ b/src/proxy.c @@ -1568,7 +1568,7 @@ static int proxy_defproxy_cpy(struct proxy *curproxy, const struct proxy *defpro /* set default values from the specified default proxy */ memcpy(&curproxy->defsrv, &defproxy->defsrv, sizeof(curproxy->defsrv)); - curproxy->flags = defproxy->flags; + curproxy->flags = (defproxy->flags & PR_FL_DISABLED); /* Only inherit from disabled flag */ curproxy->options = defproxy->options; curproxy->options2 = defproxy->options2; curproxy->no_options = defproxy->no_options; -- 2.47.3