Commit 91280b2a authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Add a "wait-running" primitive to varnish instances, so we can

avoid fixed sleeps waiting for the child process to start.
parent 6cd21b29
...@@ -5,6 +5,8 @@ server s1 { ...@@ -5,6 +5,8 @@ server s1 {
txresp -hdr "Foo: bar" -body "abcdef\n" txresp -hdr "Foo: bar" -body "abcdef\n"
rxreq rxreq
txresp -hdr "Panic: please" -body "012345\n" txresp -hdr "Panic: please" -body "012345\n"
close
sema r1 sync 2 sema r1 sync 2
accept accept
rxreq rxreq
...@@ -33,10 +35,10 @@ client c1 { ...@@ -33,10 +35,10 @@ client c1 {
rxresp rxresp
txreq -url "/foo" txreq -url "/foo"
# Don't expect answer, the server crashed. # Don't expect answer, the server crashed.
sema r1 sync 2
} -run } -run
delay 2.5 varnish v1 -wait-running
sema r1 sync 2
client c1 { client c1 {
txreq -url "/" txreq -url "/"
......
...@@ -119,6 +119,30 @@ varnish_ask_cli(const struct varnish *v, const char *cmd, char **repl) ...@@ -119,6 +119,30 @@ varnish_ask_cli(const struct varnish *v, const char *cmd, char **repl)
return ((enum VCLI_status_e)retval); return ((enum VCLI_status_e)retval);
} }
/**********************************************************************
*
*/
static void
wait_running(const struct varnish *v)
{
char *r;
enum VCLI_status_e st;
while (1) {
st = varnish_ask_cli(v, "status", &r);
if (st != CLIS_OK)
vtc_log(v->vl, 0,
"CLI status command failed: %u %s", st, r);
if (!strcmp(r, "Child in state running")) {
free(r);
break;
}
free(r);
(void)usleep(200000);
}
}
/********************************************************************** /**********************************************************************
* Varnishlog gatherer + thread * Varnishlog gatherer + thread
*/ */
...@@ -439,6 +463,7 @@ varnish_start(struct varnish *v) ...@@ -439,6 +463,7 @@ varnish_start(struct varnish *v)
return; return;
if (u != CLIS_OK) if (u != CLIS_OK)
vtc_log(v->vl, 0, "CLI start command failed: %u %s", u, resp); vtc_log(v->vl, 0, "CLI start command failed: %u %s", u, resp);
wait_running(v);
free(resp); free(resp);
u = varnish_ask_cli(v, "debug.xid 1000", &resp); u = varnish_ask_cli(v, "debug.xid 1000", &resp);
if (vtc_error) if (vtc_error)
...@@ -823,6 +848,10 @@ cmd_varnish(CMD_ARGS) ...@@ -823,6 +848,10 @@ cmd_varnish(CMD_ARGS)
varnish_stop(v); varnish_stop(v);
continue; continue;
} }
if (!strcmp(*av, "-wait-running")) {
wait_running(v);
continue;
}
if (!strcmp(*av, "-wait")) { if (!strcmp(*av, "-wait")) {
varnish_wait(v); varnish_wait(v);
continue; continue;
......
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