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 {
char *connect;
unsigned repeat;
pthread_t tp;
};
......@@ -75,26 +77,30 @@ client_thread(void *priv)
struct vtclog *vl;
int fd;
int i;
unsigned u;
CAST_OBJ_NOTNULL(c, priv, CLIENT_MAGIC);
AN(c->connect);
vl = vtc_logopen(c->name);
vtc_log(vl, 2, "Started");
vtc_log(vl, 3, "Connect to %s", c->connect);
fd = VSS_open(c->connect);
for (i = 0; fd < 0 && i < 3; i++) {
(void)sleep(1);
if (c->repeat == 0)
c->repeat = 1;
vtc_log(vl, 2, "Started (%u iterations)", c->repeat);
for (u = 0; u < c->repeat; u++) {
vtc_log(vl, 3, "Connect to %s", 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");
return (NULL);
}
......@@ -223,6 +229,11 @@ cmd_client(CMD_ARGS)
av++;
continue;
}
if (!strcmp(*av, "-repeat")) {
c->repeat = atoi(av[1]);
av++;
continue;
}
if (!strcmp(*av, "-start")) {
client_start(c);
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