]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
REORG: cli: move "shutdown session" to stream.c
authorWilly Tarreau <w@1wt.eu>
Thu, 24 Nov 2016 10:09:25 +0000 (11:09 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 24 Nov 2016 15:59:28 +0000 (16:59 +0100)
It really kills streams in fact, but we can't change the name now.

src/cli.c
src/stream.c

index 8a5bf7fca4d14429e09babf7bbeb4d7b3945f4be..ea9765c897f35af082b95aff36979f82e30f263a 100644 (file)
--- a/src/cli.c
+++ b/src/cli.c
@@ -848,39 +848,6 @@ static int stats_sock_parse_request(struct stream_interface *si, char *line)
                        stop_proxy(px);
                        return 1;
                }
-               else if (strcmp(args[1], "session") == 0) {
-                       struct stream *sess, *ptr;
-
-                       if (strm_li(s)->bind_conf->level < ACCESS_LVL_ADMIN) {
-                               appctx->ctx.cli.msg = stats_permission_denied_msg;
-                               appctx->st0 = STAT_CLI_PRINT;
-                               return 1;
-                       }
-
-                       if (!*args[2]) {
-                               appctx->ctx.cli.msg = "Session pointer expected (use 'show sess').\n";
-                               appctx->st0 = STAT_CLI_PRINT;
-                               return 1;
-                       }
-
-                       ptr = (void *)strtoul(args[2], NULL, 0);
-
-                       /* first, look for the requested stream in the stream table */
-                       list_for_each_entry(sess, &streams, list) {
-                               if (sess == ptr)
-                                       break;
-                       }
-
-                       /* do we have the stream ? */
-                       if (sess != ptr) {
-                               appctx->ctx.cli.msg = "No such session (use 'show sess').\n";
-                               appctx->st0 = STAT_CLI_PRINT;
-                               return 1;
-                       }
-
-                       stream_shutdown(sess, SF_ERR_KILLED);
-                       return 1;
-               }
                else { /* unknown "disable" parameter */
                        appctx->ctx.cli.msg = "'shutdown' only supports 'frontend', 'session' and 'sessions'.\n";
                        appctx->st0 = STAT_CLI_PRINT;
index 721736cec2b24c3c13c774f5e0bfeee404f7aa30..0c0a34f8444c7cb73a7b190b9338368f398a598b 100644 (file)
@@ -3914,6 +3914,39 @@ static void cli_release_show_sess(struct appctx *appctx)
        }
 }
 
+/* Parses the "shutdown session" directive, it always returns 1 */
+static int cli_parse_shutdown_session(char **args, struct appctx *appctx, void *private)
+{
+       struct stream *strm, *ptr;
+
+       if (!cli_has_level(appctx, ACCESS_LVL_ADMIN))
+               return 1;
+
+       if (!*args[2]) {
+               appctx->ctx.cli.msg = "Session pointer expected (use 'show sess').\n";
+               appctx->st0 = STAT_CLI_PRINT;
+               return 1;
+       }
+
+       ptr = (void *)strtoul(args[2], NULL, 0);
+
+       /* first, look for the requested stream in the stream table */
+       list_for_each_entry(strm, &streams, list) {
+               if (strm == ptr)
+                       break;
+       }
+
+       /* do we have the stream ? */
+       if (strm != ptr) {
+               appctx->ctx.cli.msg = "No such session (use 'show sess').\n";
+               appctx->st0 = STAT_CLI_PRINT;
+               return 1;
+       }
+
+       stream_shutdown(strm, SF_ERR_KILLED);
+       return 1;
+}
+
 /* Parses the "shutdown session server" directive, it always returns 1 */
 static int cli_parse_shutdown_sessions_server(char **args, struct appctx *appctx, void *private)
 {
@@ -3937,6 +3970,7 @@ static int cli_parse_shutdown_sessions_server(char **args, struct appctx *appctx
 /* register cli keywords */
 static struct cli_kw_list cli_kws = {{ },{
        { { "show", "sess",  NULL }, "show sess [id] : report the list of current sessions or dump this session", cli_parse_show_sess, cli_io_handler_dump_sess, cli_release_show_sess },
+       { { "shutdown", "session",  NULL }, "shutdown session : kill a specific session", cli_parse_shutdown_session, NULL, NULL },
        { { "shutdown", "sessions",  "server" }, "shutdown sessions server : kill sessions on a server", cli_parse_shutdown_sessions_server, NULL, NULL },
        {{},}
 }};