]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: proxy: Add PR_FL_READY flag on fully configured and usable proxies
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 13 Oct 2021 08:10:09 +0000 (10:10 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 15 Oct 2021 12:12:19 +0000 (14:12 +0200)
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
src/cfgparse.c
src/proxy.c

index 20c97dab9c25f6f999d7d759de9ddeec11b48dcf..8ca4e818d62f2bf30602a21e679469fc1dd39170 100644 (file)
@@ -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 */
 
index dbb55ed48aaf07312a9b2e6599d99eee9368ddc0..1db94c652203ddfbd4b46b290e3ad8675326c503 100644 (file)
@@ -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) {
index 36e278321f6adb8be8d9b4d5d02d44bae19ece13..c66aa8874da291cb584892e2af897216f6f9dd0d 100644 (file)
@@ -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;