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

Implicitly wait on client to complete before we do anything disruptive

to it's state.



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@5415 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent abf3df21
...@@ -63,6 +63,7 @@ struct client { ...@@ -63,6 +63,7 @@ struct client {
unsigned repeat; unsigned repeat;
pthread_t tp; pthread_t tp;
unsigned running;
}; };
static VTAILQ_HEAD(, client) clients = static VTAILQ_HEAD(, client) clients =
...@@ -171,6 +172,7 @@ client_start(struct client *c) ...@@ -171,6 +172,7 @@ client_start(struct client *c)
CHECK_OBJ_NOTNULL(c, CLIENT_MAGIC); CHECK_OBJ_NOTNULL(c, CLIENT_MAGIC);
vtc_log(c->vl, 2, "Starting client"); vtc_log(c->vl, 2, "Starting client");
AZ(pthread_create(&c->tp, NULL, client_thread, c)); AZ(pthread_create(&c->tp, NULL, client_thread, c));
c->running = 1;
} }
/********************************************************************** /**********************************************************************
...@@ -188,6 +190,7 @@ client_wait(struct client *c) ...@@ -188,6 +190,7 @@ client_wait(struct client *c)
if (res != NULL) if (res != NULL)
vtc_log(c->vl, 0, "Client returned \"%s\"", (char *)res); vtc_log(c->vl, 0, "Client returned \"%s\"", (char *)res);
c->tp = 0; c->tp = 0;
c->running = 0;
} }
/********************************************************************** /**********************************************************************
...@@ -240,6 +243,16 @@ cmd_client(CMD_ARGS) ...@@ -240,6 +243,16 @@ cmd_client(CMD_ARGS)
for (; *av != NULL; av++) { for (; *av != NULL; av++) {
if (vtc_error) if (vtc_error)
break; break;
if (!strcmp(*av, "-wait")) {
client_wait(c);
continue;
}
/* Don't muck about with a running client */
if (c->running)
client_wait(c);
if (!strcmp(*av, "-connect")) { if (!strcmp(*av, "-connect")) {
bprintf(c->connect, "%s", av[1]); bprintf(c->connect, "%s", av[1]);
av++; av++;
...@@ -254,10 +267,6 @@ cmd_client(CMD_ARGS) ...@@ -254,10 +267,6 @@ cmd_client(CMD_ARGS)
client_start(c); client_start(c);
continue; continue;
} }
if (!strcmp(*av, "-wait")) {
client_wait(c);
continue;
}
if (!strcmp(*av, "-run")) { if (!strcmp(*av, "-run")) {
client_run(c); client_run(c);
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