Commit 0da4a755 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Add a -repeat N facility to clients.



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@4348 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 2993c644
...@@ -58,6 +58,8 @@ struct client { ...@@ -58,6 +58,8 @@ struct client {
char *connect; char *connect;
unsigned repeat;
pthread_t tp; pthread_t tp;
}; };
...@@ -75,26 +77,30 @@ client_thread(void *priv) ...@@ -75,26 +77,30 @@ client_thread(void *priv)
struct vtclog *vl; struct vtclog *vl;
int fd; int fd;
int i; int i;
unsigned u;
CAST_OBJ_NOTNULL(c, priv, CLIENT_MAGIC); CAST_OBJ_NOTNULL(c, priv, CLIENT_MAGIC);
AN(c->connect); AN(c->connect);
vl = vtc_logopen(c->name); vl = vtc_logopen(c->name);
vtc_log(vl, 2, "Started"); if (c->repeat == 0)
vtc_log(vl, 3, "Connect to %s", c->connect); c->repeat = 1;
fd = VSS_open(c->connect); vtc_log(vl, 2, "Started (%u iterations)", c->repeat);
for (i = 0; fd < 0 && i < 3; i++) { for (u = 0; u < c->repeat; u++) {
(void)sleep(1); vtc_log(vl, 3, "Connect to %s", c->connect);
fd = VSS_open(c->connect); fd = VSS_open(c->connect);
for (i = 0; fd < 0 && i < 3; i++) {
(void)sleep(1);
fd = VSS_open(c->connect);
}
assert(fd >= 0);
vtc_log(vl, 3, "Connected to %s fd is %d", c->connect, fd);
http_process(vl, c->spec, fd, 1);
vtc_log(vl, 3, "Closing fd %d", fd);
TCP_close(&fd);
} }
assert(fd >= 0);
vtc_log(vl, 3, "Connected to %s fd is %d", c->connect, fd);
http_process(vl, c->spec, fd, 1);
vtc_log(vl, 3, "Closing fd %d", fd);
TCP_close(&fd);
vtc_log(vl, 2, "Ending"); vtc_log(vl, 2, "Ending");
return (NULL); return (NULL);
} }
...@@ -223,6 +229,11 @@ cmd_client(CMD_ARGS) ...@@ -223,6 +229,11 @@ cmd_client(CMD_ARGS)
av++; av++;
continue; continue;
} }
if (!strcmp(*av, "-repeat")) {
c->repeat = atoi(av[1]);
av++;
continue;
}
if (!strcmp(*av, "-start")) { if (!strcmp(*av, "-start")) {
client_start(c); client_start(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