From: phk Date: Sun, 15 Jun 2008 11:30:13 +0000 (+0000) Subject: Default server to repeat=1. X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=84d1c2f00c94e5222bd9a94bc9c7e3a17b50f712;p=varnish Default server to repeat=1. Accept connections, and close them right away. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@2673 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- diff --git a/varnish-cache/bin/varnishtest/t000.vtc b/varnish-cache/bin/varnishtest/t000.vtc index 0d8c5b40..b717e235 100644 --- a/varnish-cache/bin/varnishtest/t000.vtc +++ b/varnish-cache/bin/varnishtest/t000.vtc @@ -1,7 +1,7 @@ # Quis custodiet ipsos custodes? # -server s1 -listen :9080 { +server s1 -listen :9080 -repeat 2 { rxreq expect url == "/" txresponse -body "0123456789" @@ -18,4 +18,6 @@ client c1 -connect localhost:9080 { client c1 -run +client c1 -run + server s1 -wait diff --git a/varnish-cache/bin/varnishtest/vtc_server.c b/varnish-cache/bin/varnishtest/vtc_server.c index 56a0a0a3..0a98f5e7 100644 --- a/varnish-cache/bin/varnishtest/vtc_server.c +++ b/varnish-cache/bin/varnishtest/vtc_server.c @@ -31,6 +31,9 @@ #include #include +#include +#include + #include "vtc.h" #include "vqueue.h" @@ -68,11 +71,25 @@ static void * server_thread(void *priv) { struct server *s; + int i, fd; + struct sockaddr_storage addr_s; + struct sockaddr *addr; + socklen_t l; + CAST_OBJ_NOTNULL(s, priv, SERVER_MAGIC); + assert(s->sock >= 0); printf("### Server %s started\n", s->name); - sleep(3); + for (i = 0; i < s->repeat; i++) { + if (s->repeat > 1) + printf("#### Server %s iteration %d\n", s->name, i); + addr = (void*)&addr_s; + l = sizeof addr_s; + fd = accept(s->sock, addr, &l); + printf("#### Accepted socket %d\n", fd); + close(fd); + } printf("### Server %s ending\n", s->name); return (NULL); @@ -90,6 +107,7 @@ server_new(char *name) ALLOC_OBJ(s, SERVER_MAGIC); s->name = name; s->listen = ":9080"; + s->repeat = 1; s->depth = 1; s->sock = -1; VTAILQ_INSERT_TAIL(&servers, s, list);