Commit b00e1592 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Report back to CLI if we cannot start the child due to non-bindable sockets



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@3054 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 9aa19c21
...@@ -226,7 +226,7 @@ close_sockets(void) ...@@ -226,7 +226,7 @@ close_sockets(void)
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
static void static void
start_child(void) start_child(struct cli *cli)
{ {
pid_t pid; pid_t pid;
unsigned u; unsigned u;
...@@ -238,10 +238,15 @@ start_child(void) ...@@ -238,10 +238,15 @@ start_child(void)
return; return;
if (open_sockets() != 0) { 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, REPORT0(LOG_ERR,
"Child start failed: could not open sockets"); "Child start failed: could not open sockets");
child_state = CH_STOPPED; return;
return; /* XXX ?? */
} }
child_state = CH_STARTING; child_state = CH_STARTING;
...@@ -451,7 +456,7 @@ mgt_sigchld(const struct vev *e, int what) ...@@ -451,7 +456,7 @@ mgt_sigchld(const struct vev *e, int what)
REPORT0(LOG_DEBUG, "Child cleanup complete"); REPORT0(LOG_DEBUG, "Child cleanup complete");
if (child_state == CH_DIED && params->auto_restart) if (child_state == CH_DIED && params->auto_restart)
start_child(); start_child(NULL);
else if (child_state == CH_DIED) { else if (child_state == CH_DIED) {
child_state = CH_STOPPED; child_state = CH_STOPPED;
} else if (child_state == CH_STOPPING) } else if (child_state == CH_STOPPING)
...@@ -531,9 +536,11 @@ mgt_run(int dflag, const char *T_arg) ...@@ -531,9 +536,11 @@ mgt_run(int dflag, const char *T_arg)
if (!dflag && !mgt_has_vcl()) if (!dflag && !mgt_has_vcl())
REPORT0(LOG_ERR, "No VCL loaded yet"); REPORT0(LOG_ERR, "No VCL loaded yet");
else if (!dflag) else if (!dflag) {
start_child(); start_child(NULL);
else if (child_state == CH_STOPPED)
exit(2);
} else
fprintf(stderr, fprintf(stderr,
"Debugging mode, enter \"start\" to start child\n"); "Debugging mode, enter \"start\" to start child\n");
...@@ -556,9 +563,9 @@ mcf_server_startstop(struct cli *cli, const char * const *av, void *priv) ...@@ -556,9 +563,9 @@ mcf_server_startstop(struct cli *cli, const char * const *av, void *priv)
if (priv != NULL && child_state == CH_RUNNING) if (priv != NULL && child_state == CH_RUNNING)
mgt_stop_child(); mgt_stop_child();
else if (priv == NULL && child_state == CH_STOPPED) { else if (priv == NULL && child_state == CH_STOPPED) {
if (mgt_has_vcl()) if (mgt_has_vcl()) {
start_child(); start_child(cli);
else { } else {
cli_result(cli, CLIS_CANT); cli_result(cli, CLIS_CANT);
cli_out(cli, "No VCL available"); cli_out(cli, "No VCL available");
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment