From 25fcc8cfadc04b66bd1fdd938a1631b82bf26016 Mon Sep 17 00:00:00 2001 From: phk Date: Fri, 13 Feb 2009 12:16:34 +0000 Subject: [PATCH] Add two hidden CLI commands for panic'ing the master and worker process. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@3767 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- varnish-cache/bin/varnishd/cache_cli.c | 15 ++++++++++++++ varnish-cache/bin/varnishd/mgt_cli.c | 27 +++++++++++++++++++++----- 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/varnish-cache/bin/varnishd/cache_cli.c b/varnish-cache/bin/varnishd/cache_cli.c index 648ebd8a..1d0a5cb7 100644 --- a/varnish-cache/bin/varnishd/cache_cli.c +++ b/varnish-cache/bin/varnishd/cache_cli.c @@ -223,6 +223,18 @@ ccf_help(struct cli *cli, const char * const *av, void *priv) /*--------------------------------------------------------------------*/ +static void +ccf_panic(struct cli *cli, const char * const *av, void *priv) +{ + + (void)cli; + (void)av; + (void)priv; + assert(!strcmp("", "You asked for it")); +} + +/*--------------------------------------------------------------------*/ + static struct cli_proto master_cmds[] = { { CLI_PING, cli_func_ping }, { CLI_HELP, ccf_help, NULL }, @@ -233,6 +245,9 @@ static struct cli_proto debug_cmds[] = { { "debug.sizeof", "debug.sizeof", "\tDump sizeof various data structures\n", 0, 0, cli_debug_sizeof }, + { "debug.panic.worker", "debug.panic.worker", + "\tPanic the worker process.\n", + 0, 0, ccf_panic }, { NULL } }; diff --git a/varnish-cache/bin/varnishd/mgt_cli.c b/varnish-cache/bin/varnishd/mgt_cli.c index 15a3ce0e..040d2a18 100644 --- a/varnish-cache/bin/varnishd/mgt_cli.c +++ b/varnish-cache/bin/varnishd/mgt_cli.c @@ -161,11 +161,26 @@ static struct cli_proto cli_proto[] = { { CLI_PARAM_SET, mcf_param_set, NULL }, { CLI_QUIT, mcf_close, NULL}, -#if 0 - { CLI_SERVER_RESTART }, - { CLI_ZERO }, - { CLI_VERBOSE, m_cli_func_verbose, NULL }, -#endif + { NULL } +}; + +/*--------------------------------------------------------------------*/ + + +static void +mcf_panic(struct cli *cli, const char * const *av, void *priv) +{ + + (void)cli; + (void)av; + (void)priv; + assert(!strcmp("", "You asked for it")); +} + +static struct cli_proto cli_debug[] = { + { "debug.panic.master", "debug.panic.master", + "\tPanic the master process.\n", + 0, 0, mcf_panic, NULL}, { NULL } }; @@ -267,6 +282,8 @@ mgt_cli_vlu(void *priv, const char *p) return (0); cli_dispatch(cp->cli, cli_proto, p); + if (cp->cli->result == CLIS_UNKNOWN) + cli_dispatch(cp->cli, cli_debug, p); if (cp->cli->result == CLIS_UNKNOWN) { /* * Command not recognized in master, try cacher if it is -- 2.39.5