From c7e2b33c31105469e8793380646fef22f420368e Mon Sep 17 00:00:00 2001 From: phk Date: Sat, 5 Aug 2006 16:41:11 +0000 Subject: [PATCH] Issue error message for CLI::start and CLI::stop if child is not in a legal state for command. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@678 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- varnish-cache/bin/varnishd/mgt_child.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/varnish-cache/bin/varnishd/mgt_child.c b/varnish-cache/bin/varnishd/mgt_child.c index 431273a9..2b2c3db3 100644 --- a/varnish-cache/bin/varnishd/mgt_child.c +++ b/varnish-cache/bin/varnishd/mgt_child.c @@ -21,6 +21,7 @@ #include "libvarnish.h" #include "heritage.h" #include "mgt.h" +#include "cli.h" #include "cli_priv.h" #include "mgt_cli.h" #include "mgt_event.h" @@ -37,6 +38,14 @@ static enum { CH_DIED = 4 } child_state = CH_STOPPED; +const char *ch_state[] = { + [CH_STOPPED] = "stopped", + [CH_STARTING] = "starting", + [CH_RUNNING] = "running", + [CH_STOPPING] = "stopping", + [CH_DIED] = "died, (restarting)", +}; + struct evbase *mgt_evb; struct ev *ev_poker; struct ev *ev_listen; @@ -327,9 +336,12 @@ mcf_server_startstop(struct cli *cli, char **av, void *priv) (void)cli; (void)av; - if (priv != NULL) { + if (priv != NULL && child_state == CH_RUNNING) stop_child(); - return; - } - start_child(); + else if (priv == NULL && child_state == CH_STOPPED) + start_child(); + else { + cli_result(cli, CLIS_CANT); + cli_out(cli, "Child in state %s", ch_state[child_state]); + } } -- 2.39.5