]> err.no Git - varnish/commitdiff
Issue error message for CLI::start and CLI::stop if child is
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Sat, 5 Aug 2006 16:41:11 +0000 (16:41 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Sat, 5 Aug 2006 16:41:11 +0000 (16:41 +0000)
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

index 431273a97b4da1ae2dd0eacdf3f101f8819369eb..2b2c3db3f8b4326be72a84f69a2e24dd25a82b47 100644 (file)
@@ -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]);
+       }
 }