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

Fix a potential race when retargeting a server by doing an implicit -wait

before mucking with a running server.

If running on a random port, record it for subsequent -starts, so
we use the same (random) port throughout.

Fix the v00014 testcase which made some really bad assumptions relative
to the above, eliminating the delay it used in the process.



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@4503 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 44dabfed
......@@ -6,7 +6,7 @@ server s1 {
rxreq
expect req.url == "/"
txresp -body "slash"
} -start -repeat 4
} -start
varnish v1 -vcl {
......@@ -16,7 +16,7 @@ varnish v1 -vcl {
.max_connections = 1;
.probe = {
.url = "/";
.timeout = 100 ms;
.timeout = 1s;
.interval = 1s;
.window = 3;
.threshold = 2;
......@@ -39,11 +39,22 @@ client c1 {
expect resp.status == 500
} -run
delay 1
server s1 {
rxreq
expect req.url == "/"
txresp -body "slash"
} -start
server s1 {
rxreq
expect req.url == "/foo"
txresp -body "foobar"
} -start
client c2 {
txreq
txreq -url "/foo"
rxresp
expect resp.bodylen == 6
expect resp.status == 200
} -start
......@@ -183,6 +183,9 @@ server_start(struct server *s)
macro_def(s->vl, s->name, "addr", "%s", s->aaddr);
macro_def(s->vl, s->name, "port", "%s", s->aport);
macro_def(s->vl, s->name, "sock", "%s:%s", s->aaddr, s->aport);
/* Record the actual port, and reuse it on subsequent starts */
if (!strcmp(s->port, "0"))
REPLACE(s->port, s->aport);
}
vtc_log(s->vl, 1, "Listen on %s:%s", s->addr, s->port);
s->run = 1;
......@@ -243,6 +246,7 @@ cmd_server(CMD_ARGS)
if (av == NULL) {
/* Reset and free */
VTAILQ_FOREACH_SAFE(s, &servers, list, s2) {
CHECK_OBJ_NOTNULL(s, SERVER_MAGIC);
VTAILQ_REMOVE(&servers, s, list);
if (s->run) {
(void)pthread_cancel(s->tp);
......@@ -261,11 +265,26 @@ cmd_server(CMD_ARGS)
break;
if (s == NULL)
s = server_new(av[0]);
CHECK_OBJ_NOTNULL(s, SERVER_MAGIC);
av++;
for (; *av != NULL; av++) {
if (vtc_error)
break;
if (!strcmp(*av, "-wait")) {
if (!s->run)
vtc_log(s->vl, 0, "Server not -started");
server_wait(s);
continue;
}
/*
* We do an implict -wait if people muck about with a
* running server.
*/
if (s->run)
server_wait(s);
assert(s->run == 0);
if (!strcmp(*av, "-repeat")) {
s->repeat = atoi(av[1]);
av++;
......@@ -281,10 +300,6 @@ cmd_server(CMD_ARGS)
server_start(s);
continue;
}
if (!strcmp(*av, "-wait")) {
server_wait(s);
continue;
}
if (**av == '-')
vtc_log(s->vl, 0, "Unknown server argument: %s", *av);
s->spec = *av;
......
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