]> err.no Git - varnish/commitdiff
Report back to CLI if we cannot start the child due to non-bindable sockets
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Fri, 1 Aug 2008 09:24:08 +0000 (09:24 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Fri, 1 Aug 2008 09:24:08 +0000 (09:24 +0000)
git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@3054 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishd/mgt_child.c

index c33ead490413fc8b1418c1cfb8fe397db9703cd6..326c8511dd163e8d29761d816007d3435186459a 100644 (file)
@@ -226,7 +226,7 @@ close_sockets(void)
 /*--------------------------------------------------------------------*/
 
 static void
-start_child(void)
+start_child(struct cli *cli)
 {
        pid_t pid;
        unsigned u;
@@ -238,10 +238,15 @@ start_child(void)
                return;
 
        if (open_sockets() != 0) {
+               child_state = CH_STOPPED;
+               if (cli != NULL) {
+                       cli_result(cli, CLIS_CANT);
+                       cli_out(cli, "Could not open sockets");
+                       return;
+               }
                REPORT0(LOG_ERR,
                    "Child start failed: could not open sockets");
-               child_state = CH_STOPPED;
-               return; /* XXX ?? */
+               return;
        }
 
        child_state = CH_STARTING;
@@ -451,7 +456,7 @@ mgt_sigchld(const struct vev *e, int what)
        REPORT0(LOG_DEBUG, "Child cleanup complete");
 
        if (child_state == CH_DIED && params->auto_restart)
-               start_child();
+               start_child(NULL);
        else if (child_state == CH_DIED) {
                child_state = CH_STOPPED;
        } else if (child_state == CH_STOPPING)
@@ -531,9 +536,11 @@ mgt_run(int dflag, const char *T_arg)
 
        if (!dflag && !mgt_has_vcl()) 
                REPORT0(LOG_ERR, "No VCL loaded yet");
-       else if (!dflag)
-               start_child();
-       else
+       else if (!dflag) {
+               start_child(NULL);
+               if (child_state == CH_STOPPED)
+                       exit(2);
+       } else
                fprintf(stderr,
                    "Debugging mode, enter \"start\" to start child\n");
 
@@ -556,9 +563,9 @@ mcf_server_startstop(struct cli *cli, const char * const *av, void *priv)
        if (priv != NULL && child_state == CH_RUNNING)
                mgt_stop_child();
        else if (priv == NULL && child_state == CH_STOPPED) {
-               if (mgt_has_vcl())
-                       start_child();
-               else {
+               if (mgt_has_vcl()) {
+                       start_child(cli);
+               else {
                        cli_result(cli, CLIS_CANT);
                        cli_out(cli, "No VCL available");
                }