]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: proxy: disabled takes a stopping and a disabled state
authorWilliam Lallemand <wlallemand@haproxy.org>
Tue, 3 Aug 2021 09:58:03 +0000 (11:58 +0200)
committerWilliam Lallemand <wlallemand@haproxy.org>
Tue, 3 Aug 2021 12:17:45 +0000 (14:17 +0200)
This patch splits the disabled state of a proxy into a PR_DISABLED and a
PR_STOPPED state.

The first one is set when the proxy is disabled in the configuration
file, and the second one is set upon a stop_proxy().

include/haproxy/proxy-t.h
src/cfgparse-listen.c
src/cfgparse.c
src/mworker.c
src/proxy.c

index f2a3e7d0bab392a5b24a5dc8fc0400a94d65f182..a34752bbae638c3aeba173d83c3344473fb44318 100644 (file)
@@ -200,6 +200,11 @@ enum PR_SRV_STATE_FILE {
  */
 #define PR_RE_EARLY_ERROR         0x00010000 /* Retry if we failed at sending early data */
 #define PR_RE_JUNK_REQUEST        0x00020000 /* We received an incomplete or garbage response */
+
+/* disabled state */
+#define PR_DISABLED               0x1  /* The proxy was disabled in the configuration (not at runtime) */
+#define PR_STOPPED                0x2  /* The proxy was stopped */
+
 struct stream;
 
 struct http_snapshot {
@@ -254,7 +259,7 @@ struct error_snapshot {
 
 struct proxy {
        enum obj_type obj_type;                 /* object type == OBJ_TYPE_PROXY */
-       char disabled;                          /* non-zero if disabled or shutdown */
+       char disabled;                          /* bit field PR_DISABLED | PR_STOPPED */
        enum pr_mode mode;                      /* mode = PR_MODE_TCP, PR_MODE_HTTP, ... */
        char cap;                               /* supported capabilities (PR_CAP_*) */
        unsigned int maxconn;                   /* max # of active streams on the frontend */
index bdbb6030a96de50004cd20c65427ac6f76efd02c..790566a62d2202f7c94a727a983608871f0d3685 100644 (file)
@@ -593,7 +593,7 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
        else if (strcmp(args[0], "disabled") == 0) {  /* disables this proxy */
                if (alertif_too_many_args(0, file, linenum, args, &err_code))
                        goto out;
-               curproxy->disabled = 1;
+               curproxy->disabled = PR_DISABLED;
        }
        else if (strcmp(args[0], "enabled") == 0) {  /* enables this proxy (used to revert a disabled default) */
                if (alertif_too_many_args(0, file, linenum, args, &err_code))
index 3ac31fc9bd110cf7e2552d2e0e0754cde3d2b809..f7eac9753c52ec612a8a5a7e97daf9c2e2ec09fe 100644 (file)
@@ -1018,7 +1018,7 @@ int cfg_parse_peers(const char *file, int linenum, char **args, int kwm)
                stktables_list = t;
        }
        else if (strcmp(args[0], "disabled") == 0) {  /* disables this peers section */
-               curpeers->disabled = 1;
+               curpeers->disabled = PR_DISABLED;
        }
        else if (strcmp(args[0], "enabled") == 0) {  /* enables this peers section (used to revert a disabled default) */
                curpeers->disabled = 0;
index 7842db398d079a13fd44062bc23a5e58092d0826..ca1cc74248f0b4dda7dbb1dc128f1b2773dfe912 100644 (file)
@@ -443,7 +443,7 @@ void mworker_cleanlisteners()
                }
                /* if the proxy shouldn't be in the master, we stop it */
                if (!listen_in_master)
-                       curproxy->disabled = 1;
+                       curproxy->disabled = PR_DISABLED;
        }
 }
 
index 245c22b9e5b2b93e49c2f7eaabc0744d05a29850..237f297d75e49a548589e872fa499a06118b9496 100644 (file)
@@ -1801,7 +1801,7 @@ void proxy_cond_disable(struct proxy *p)
        if (p->li_ready + p->li_paused > 0)
                return;
 
-       p->disabled = 1;
+       p->disabled = PR_STOPPED;
 
        /* Note: syslog proxies use their own loggers so while it's somewhat OK
         * to report them being stopped as a warning, we must not spam their log
@@ -2050,7 +2050,7 @@ void stop_proxy(struct proxy *p)
 
        if (!p->disabled && !p->li_ready) {
                /* might be just a backend */
-               p->disabled = 1;
+               p->disabled |= PR_STOPPED;
        }
 
        HA_RWLOCK_WRUNLOCK(PROXY_LOCK, &p->lock);