r4454 - trunk/varnish-cache/bin/varnishtest
phk at projects.linpro.no
phk at projects.linpro.no
Wed Jan 13 14:52:25 CET 2010
Author: phk
Date: 2010-01-13 14:52:24 +0100 (Wed, 13 Jan 2010)
New Revision: 4454
Modified:
trunk/varnish-cache/bin/varnishtest/vtc_varnish.c
Log:
Use the new varnishd -M argument to turn the CLI connection around,
so we can use anonymous TCP ports for it.
Modified: trunk/varnish-cache/bin/varnishtest/vtc_varnish.c
===================================================================
--- trunk/varnish-cache/bin/varnishtest/vtc_varnish.c 2010-01-13 12:34:47 UTC (rev 4453)
+++ trunk/varnish-cache/bin/varnishtest/vtc_varnish.c 2010-01-13 13:52:24 UTC (rev 4454)
@@ -71,8 +71,6 @@
struct vsb *args;
int fds[4];
pid_t pid;
- const char *telnet;
- const char *accept;
pthread_t tp;
@@ -173,8 +171,6 @@
vtc_log(v->vl, 0, "Varnish name must start with 'v'");
v->args = vsb_newauto();
- v->telnet = "127.0.0.1:9001";
- v->accept = "127.0.0.1:0";
v->cli_fd = -1;
VTAILQ_INSERT_TAIL(&varnishes, v, list);
@@ -247,8 +243,17 @@
varnish_launch(struct varnish *v)
{
struct vsb *vsb;
- int i;
+ int i, nfd, nap;
+ struct vss_addr **ap;
+ char abuf[128],pbuf[128];
+ struct pollfd fd;
+ /* Create listener socket */
+ nap = VSS_resolve("127.0.0.1", "0", &ap);
+ AN(nap);
+ v->cli_fd = VSS_listen(ap[0], 1);
+ TCP_myname(v->cli_fd, abuf, sizeof abuf, pbuf, sizeof pbuf);
+
vsb_finish(v->args);
AZ(vsb_overflowed(v->args));
vtc_log(v->vl, 2, "Launch");
@@ -258,7 +263,8 @@
vsb_printf(vsb, " ./varnishd -d -d -n %s", v->workdir);
vsb_printf(vsb, " -p cli_banner=off");
vsb_printf(vsb, " -p auto_restart=off");
- vsb_printf(vsb, " -a '%s' -T %s", v->accept, v->telnet);
+ vsb_printf(vsb, " -a '%s'", "127.0.0.1:0");
+ vsb_printf(vsb, " -M %s:%s", abuf, pbuf);
vsb_printf(vsb, " -P %s/varnishd.pid", v->workdir);
vsb_printf(vsb, " %s", vsb_data(v->args));
vsb_finish(vsb);
@@ -288,19 +294,27 @@
vsb_delete(vsb);
AZ(pthread_create(&v->tp, NULL, varnish_thread, v));
- vtc_log(v->vl, 3, "opening CLI connection");
- for (i = 0; i < 30; i++) {
- (void)usleep(200000);
- v->cli_fd = VSS_open(v->telnet);
- if (v->cli_fd >= 0)
- break;
+ /* Wait for the varnish to call home */
+ fd.fd = v->cli_fd;
+ fd.events = POLLIN;
+ i = poll(&fd, 1, 6000);
+ if (i != 1) {
+ AZ(close(v->fds[1]));
+ (void)kill(v->pid, SIGKILL);
+ vtc_log(v->vl, 0, "FAIL timeout waiting for CLI connection");
+ return;
}
- if (v->cli_fd < 0) {
+ nfd = accept(v->cli_fd, NULL, NULL);
+ if (nfd < 0) {
AZ(close(v->fds[1]));
(void)kill(v->pid, SIGKILL);
- vtc_log(v->vl, 0, "FAIL no CLI connection");
+ vtc_log(v->vl, 0, "FAIL no CLI connection accepted");
return;
}
+
+ AZ(close(v->cli_fd));
+ v->cli_fd = nfd;
+
vtc_log(v->vl, 3, "CLI connection fd = %d", v->cli_fd);
assert(v->cli_fd >= 0);
if (v->stats != NULL)
@@ -611,18 +625,6 @@
for (; *av != NULL; av++) {
if (vtc_error)
break;
- if (!strcmp(*av, "-telnet")) {
- AN(av[1]);
- v->telnet = av[1];
- av++;
- continue;
- }
- if (!strcmp(*av, "-accept")) {
- AN(av[1]);
- v->accept = av[1];
- av++;
- continue;
- }
if (!strcmp(*av, "-arg")) {
AN(av[1]);
vsb_cat(v->args, " ");
@@ -649,10 +651,6 @@
av += 2;
continue;
}
- if (!strcmp(*av, "-launch")) {
- varnish_launch(v);
- continue;
- }
if (!strcmp(*av, "-start")) {
varnish_start(v);
continue;
More information about the varnish-commit
mailing list