From: Willy Tarreau Date: Sun, 3 Jun 2012 22:26:23 +0000 (+0200) Subject: MEDIUM: stats: add the ability to kill sessions from the admin interface X-Git-Tag: v1.5-dev12~151 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4f8a83cb6edc788550f40d1a5fb5f07aee737831;p=thirdparty%2Fhaproxy.git MEDIUM: stats: add the ability to kill sessions from the admin interface 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. --- diff --git a/include/types/proto_http.h b/include/types/proto_http.h index 3457a2a381..76c8e6b506 100644 --- a/include/types/proto_http.h +++ b/include/types/proto_http.h @@ -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 */ diff --git a/src/dumpstats.c b/src/dumpstats.c index a01c6ed0de..d79c880626 100644 --- a/src/dumpstats.c +++ b/src/dumpstats.c @@ -3173,6 +3173,7 @@ static int stats_dump_proxy(struct stream_interface *si, struct proxy *px, struc "" "" "" + "" "" "" " " diff --git a/src/proto_http.c b/src/proto_http.c index c0a66879fc..8834532289 100644 --- a/src/proto_http.c +++ b/src/proto_http.c @@ -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) */