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.
diff --git a/include/haproxy/proxy-t.h b/include/haproxy/proxy-t.h
index 20c97da..8ca4e81 100644
--- a/include/haproxy/proxy-t.h
+++ b/include/haproxy/proxy-t.h
@@ -203,6 +203,7 @@
/* 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 dbb55ed..1db94c6 100644
--- a/src/cfgparse.c
+++ b/src/cfgparse.c
@@ -3840,6 +3840,7 @@
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 @@
* 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 36e2783..c66aa88 100644
--- a/src/proxy.c
+++ b/src/proxy.c
@@ -1568,7 +1568,7 @@
/* 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;