]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: stats: add the ability to kill sessions from the admin interface
authorWilly Tarreau <w@1wt.eu>
Sun, 3 Jun 2012 22:26:23 +0000 (00:26 +0200)
committerWilly Tarreau <w@1wt.eu>
Sun, 3 Jun 2012 22:26:23 +0000 (00:26 +0200)
It was not possible to kill remaining sessions from the admin interface,
which is annoying especially when switching to maintenance mode. Now it's
possible.

include/types/proto_http.h
src/dumpstats.c
src/proto_http.c

index 3457a2a38173544146a4e9c63f80338697580f97..76c8e6b5062eaf7777093f733f97d90976c6d2b4 100644 (file)
@@ -264,6 +264,7 @@ enum {
        ST_ADM_ACTION_ENABLE,
        ST_ADM_ACTION_STOP,
        ST_ADM_ACTION_START,
+       ST_ADM_ACTION_SHUTDOWN,
 };
 
 /* status codes available for the stats admin page */
index a01c6ed0de81c0b88a1fb56eabe4e6793c99c81e..d79c8806266714971526bea1ce37614f0c202e8b 100644 (file)
@@ -3173,6 +3173,7 @@ static int stats_dump_proxy(struct stream_interface *si, struct proxy *px, struc
                                        "<option value=\"enable\">Enable</option>"
                                        "<option value=\"stop\">Soft Stop</option>"
                                        "<option value=\"start\">Soft Start</option>"
+                                       "<option value=\"shutdown\">Kill Sessions</option>"
                                        "</select>"
                                        "<input type=\"hidden\" name=\"b\" value=\"#%d\">"
                                        "&nbsp;<input type=\"submit\" value=\"Apply\">"
index c0a66879fc165bbd5f4547a89c6770c5a61798b8..8834532289bb62cde7226abea9d39270f6282295 100644 (file)
@@ -2611,6 +2611,9 @@ int http_process_req_stat_post(struct stream_interface *si, struct http_txn *txn
                                else if (strcmp(value, "start") == 0) {
                                        action = ST_ADM_ACTION_START;
                                }
+                               else if (strcmp(value, "shutdown") == 0) {
+                                       action = ST_ADM_ACTION_SHUTDOWN;
+                               }
                                else {
                                        si->applet.ctx.stats.st_code = STAT_STATUS_ERRP;
                                        goto out;
@@ -2680,6 +2683,18 @@ int http_process_req_stat_post(struct stream_interface *si, struct http_txn *txn
                                                altered_servers++;
                                                total_servers++;
                                                break;
+                                       case ST_ADM_ACTION_SHUTDOWN:
+                                               if (px->state != PR_STSTOPPED) {
+                                                       struct session *sess, *sess_bck;
+
+                                                       list_for_each_entry_safe(sess, sess_bck, &sv->actconns, by_srv)
+                                                               if (sess->srv_conn == sv)
+                                                                       session_shutdown(sess, SN_ERR_KILLED);
+
+                                                       altered_servers++;
+                                                       total_servers++;
+                                               }
+                                               break;
                                        }
                                } else {
                                        /* the server name is unknown or ambiguous (duplicate names) */