]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[BUG] stats: admin commands must check the proxy state
authorCyril Bonté <cyril.bonte@free.fr>
Thu, 3 Mar 2011 19:49:04 +0000 (20:49 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 4 Mar 2011 09:01:39 +0000 (10:01 +0100)
As reported by Bryan Talbot, enabling and disabling a server in a disabled
proxy causes a segfault.

Changing the weight can also cause a similar segfault.

src/dumpstats.c

index 980b28485aabb575577ba94156a4883ff98f7d90..081e4cd3714c0921fe06a95f99b0abfb406330f1 100644 (file)
@@ -639,6 +639,12 @@ int stats_sock_parse_request(struct stream_interface *si, char *line)
                                return 1;
                        }
 
+                       if (px->state == PR_STSTOPPED) {
+                               s->data_ctx.cli.msg = "Proxy is disabled.\n";
+                               si->st0 = STAT_CLI_PRINT;
+                               return 1;
+                       }
+
                        /* if the weight is terminated with '%', it is set relative to
                         * the initial weight, otherwise it is absolute.
                         */
@@ -749,6 +755,12 @@ int stats_sock_parse_request(struct stream_interface *si, char *line)
                                return 1;
                        }
 
+                       if (px->state == PR_STSTOPPED) {
+                               s->data_ctx.cli.msg = "Proxy is disabled.\n";
+                               si->st0 = STAT_CLI_PRINT;
+                               return 1;
+                       }
+
                        if (sv->state & SRV_MAINTAIN) {
                                /* The server is really in maintenance, we can change the server state */
                                if (sv->tracked) {
@@ -804,6 +816,12 @@ int stats_sock_parse_request(struct stream_interface *si, char *line)
                                return 1;
                        }
 
+                       if (px->state == PR_STSTOPPED) {
+                               s->data_ctx.cli.msg = "Proxy is disabled.\n";
+                               si->st0 = STAT_CLI_PRINT;
+                               return 1;
+                       }
+
                        if (! (sv->state & SRV_MAINTAIN)) {
                                /* Not already in maintenance, we can change the server state */
                                sv->state |= SRV_MAINTAIN;