From phk at projects.linpro.no Mon Jun 2 19:45:07 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 2 Jun 2008 21:45:07 +0200 (CEST) Subject: r2646 - trunk/varnish-cache/bin/varnishd Message-ID: <20080602194507.8A9251ED25D@projects.linpro.no> Author: phk Date: 2008-06-02 21:45:05 +0200 (Mon, 02 Jun 2008) New Revision: 2646 Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor_epoll.c Log: Add a "timeout counter" and cleans the timeout sockets every 60 seconds instead of cleaning it in every new connection received. We are using it here, and the performance is much better now. Submmitted by: Rafael Umann Closes ticket #235 Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor_epoll.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_acceptor_epoll.c 2008-05-31 21:26:20 UTC (rev 2645) +++ trunk/varnish-cache/bin/varnishd/cache_acceptor_epoll.c 2008-06-02 19:45:05 UTC (rev 2646) @@ -71,6 +71,8 @@ { struct epoll_event ev; double deadline; + int dotimer = 0; + double last_timeout = 0, tmp_timeout; struct sess *sp, *sp2; int i; @@ -83,7 +85,7 @@ vca_add(vca_pipes[0], vca_pipes); while (1) { - if (epoll_wait(epfd, &ev, 1, 100) > 0) { + if ((dotimer = epoll_wait(epfd, &ev, 1, 100)) > 0) { if (ev.data.ptr == vca_pipes) { i = read(vca_pipes[0], &sp, sizeof sp); assert(i == sizeof sp); @@ -100,6 +102,14 @@ } } } + tmp_timeout = TIM_mono(); + if ((tmp_timeout - last_timeout) > 60) { + last_timeout = tmp_timeout; + } else { + if (dotimer > 0) + continue; + } + /* check for timeouts */ deadline = TIM_real() - params->sess_timeout; VTAILQ_FOREACH_SAFE(sp, &sesshead, list, sp2) { From phk at projects.linpro.no Thu Jun 5 09:12:51 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Thu, 5 Jun 2008 11:12:51 +0200 (CEST) Subject: r2647 - trunk/varnish-cache/bin/varnishd Message-ID: <20080605091251.8F77D1ED0A4@projects.linpro.no> Author: phk Date: 2008-06-05 11:12:51 +0200 (Thu, 05 Jun 2008) New Revision: 2647 Modified: trunk/varnish-cache/bin/varnishd/tcp.c Log: Get the sign right on FIONBIO ioctl. Modified: trunk/varnish-cache/bin/varnishd/tcp.c =================================================================== --- trunk/varnish-cache/bin/varnishd/tcp.c 2008-06-02 19:45:05 UTC (rev 2646) +++ trunk/varnish-cache/bin/varnishd/tcp.c 2008-06-05 09:12:51 UTC (rev 2647) @@ -127,7 +127,7 @@ { int i; - i = 0; + i = 1; AZ(ioctl(sock, FIONBIO, &i)); } @@ -136,7 +136,7 @@ { int i; - i = 1; + i = 0; AZ(ioctl(sock, FIONBIO, &i)); } From phk at projects.linpro.no Thu Jun 5 09:16:29 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Thu, 5 Jun 2008 11:16:29 +0200 (CEST) Subject: r2648 - trunk/varnish-cache/bin/varnishd Message-ID: <20080605091629.C3D2F1EC40A@projects.linpro.no> Author: phk Date: 2008-06-05 11:16:29 +0200 (Thu, 05 Jun 2008) New Revision: 2648 Modified: trunk/varnish-cache/bin/varnishd/mgt_param.c Log: Add a new-line before, and reword some of the default cautions a little bit. Automatically calculate the margin, based on the width of the parameter names we have. Modified: trunk/varnish-cache/bin/varnishd/mgt_param.c =================================================================== --- trunk/varnish-cache/bin/varnishd/mgt_param.c 2008-06-05 09:12:51 UTC (rev 2647) +++ trunk/varnish-cache/bin/varnishd/mgt_param.c 2008-06-05 09:16:29 UTC (rev 2648) @@ -56,6 +56,7 @@ #define MAGIC_INIT_STRING "\001" struct parspec; +static int margin; typedef void tweak_t(struct cli *, const struct parspec *, const char *arg); @@ -422,19 +423,20 @@ */ #define DELAYED_EFFECT_TEXT \ - "NB: This parameter will take some time to take effect." + "\nNB: This parameter may take quite some time to take (full) effect." #define MUST_RESTART_TEXT \ - "NB: This parameter will not take any effect until the " \ + "\nNB: This parameter will not take any effect until the " \ "child process has been restarted." #define MUST_RELOAD_TEXT \ - "NB: This parameter will not take any effect until the " \ + "\nNB: This parameter will not take any effect until the " \ "VCL programs have been reloaded." #define EXPERIMENTAL_TEXT \ - "NB: We don't know yet if it is a good idea to change " \ - "this parameter. Caution advised." + "\nNB: We do not know yet if it is a good idea to change " \ + "this parameter, or if the default value is even sensible. " \ + "Caution is advised, and feedback is most welcome." /* * Remember to update varnishd.1 whenever you add / remove a parameter or @@ -672,7 +674,6 @@ /*--------------------------------------------------------------------*/ #define WIDTH 76 -#define MARGIN 20 static void mcf_wrap(struct cli *cli, const char *text) @@ -684,13 +685,13 @@ q = strchr(p, '\n'); if (q == NULL) q = strchr(p, '\0'); - if (q > p + WIDTH - MARGIN) { - q = p + WIDTH - MARGIN; + if (q > p + WIDTH - margin) { + q = p + WIDTH - margin; while (q > p && *q != ' ') q--; AN(q); } - cli_out(cli, "%*s %.*s\n", MARGIN, "", (int)(q - p), p); + cli_out(cli, "%*s %.*s\n", margin, "", (int)(q - p), p); p = q; if (*p == ' ' || *p == '\n') p++; @@ -711,7 +712,7 @@ for (pp = parspec; pp->name != NULL; pp++) { if (av[2] != NULL && !lfmt && strcmp(pp->name, av[2])) continue; - cli_out(cli, "%-*s ", MARGIN, pp->name); + cli_out(cli, "%-*s ", margin, pp->name); if (pp->func == NULL) { cli_out(cli, "Not implemented.\n"); if (av[2] != NULL && !lfmt) @@ -726,7 +727,7 @@ cli_out(cli, "\n"); if (av[2] != NULL) { cli_out(cli, "%-*s Default is %s\n", - MARGIN, "", pp->def); + margin, "", pp->def); mcf_wrap(cli, pp->descr); if (pp->flags & DELAYED_EFFECT) mcf_wrap(cli, DELAYED_EFFECT_TEXT); @@ -803,6 +804,8 @@ for (pp = parspec; pp->name != NULL; pp++) { cli_out(cli, "Set Default for %s = %s\n", pp->name, pp->def); + if (strlen(pp->name) + 1 > margin) + margin = strlen(pp->name) + 1; pp->func(cli, pp, pp->def); if (cli->result != CLIS_OK) return; From phk at projects.linpro.no Thu Jun 5 09:18:09 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Thu, 5 Jun 2008 11:18:09 +0200 (CEST) Subject: r2649 - trunk/varnish-cache/bin/varnishd Message-ID: <20080605091809.D20DD1EC20A@projects.linpro.no> Author: phk Date: 2008-06-05 11:18:09 +0200 (Thu, 05 Jun 2008) New Revision: 2649 Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor.c Log: We don't need srandomdev.h here anymore. Don't hand-roll an assert. Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_acceptor.c 2008-06-05 09:16:29 UTC (rev 2648) +++ trunk/varnish-cache/bin/varnishd/cache_acceptor.c 2008-06-05 09:18:09 UTC (rev 2649) @@ -46,10 +46,6 @@ #include #include -#ifndef HAVE_SRANDOMDEV -#include "compat/srandomdev.h" -#endif - #include "cli.h" #include "cli_priv.h" #include "shmlog.h" @@ -294,10 +290,9 @@ /* XXX: Add selector mechanism at some point */ vca_act = vca_acceptors[0]; - if (vca_act->name == NULL) { - fprintf(stderr, "No acceptor in program\n"); - exit (2); - } + AN(vca_act); + AN(vca_act->name); + if (vca_act->pass == NULL) AZ(pipe(vca_pipes)); vca_act->init(); From phk at projects.linpro.no Thu Jun 5 09:19:27 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Thu, 5 Jun 2008 11:19:27 +0200 (CEST) Subject: r2650 - trunk/varnish-cache/bin/varnishd Message-ID: <20080605091927.9AFD91EC20A@projects.linpro.no> Author: phk Date: 2008-06-05 11:19:27 +0200 (Thu, 05 Jun 2008) New Revision: 2650 Modified: trunk/varnish-cache/bin/varnishd/mgt_param.c Log: Add an XXX comment. Modified: trunk/varnish-cache/bin/varnishd/mgt_param.c =================================================================== --- trunk/varnish-cache/bin/varnishd/mgt_param.c 2008-06-05 09:18:09 UTC (rev 2649) +++ trunk/varnish-cache/bin/varnishd/mgt_param.c 2008-06-05 09:19:27 UTC (rev 2650) @@ -441,6 +441,7 @@ /* * Remember to update varnishd.1 whenever you add / remove a parameter or * change its default value. + * XXX: we should generate the relevant section of varnishd.1 from here. */ static const struct parspec parspec[] = { { "user", tweak_user, NULL, 0, 0, From xlevyv at xlevyv.cz Thu Jun 5 14:04:46 2008 From: xlevyv at xlevyv.cz (Vojtech Levy) Date: Thu, 05 Jun 2008 16:04:46 +0200 Subject: ttl problem In-Reply-To: <4847F231.9000702@hubhosting.cz> References: <4847F231.9000702@hubhosting.cz> Message-ID: <4847F27E.7060709@xlevyv.cz> > Hi, (Sorry, my english is bad) > this is my VCL conf, what is wronk? Varnish didnt starting. > > backend default { > set backend.host = "xxx.xxx.xxx.xxx"; > set backend.port = "xxxx"; set obj.ttl = 2d; > } > sub vcl_recv { > if (req.request == "GET" && req.url ~ > "\.(gif|jpg|swf|css|js|html|htm)$") { > set obj.ttl = 12h; > lookup; > } > } > sub vcl_recv { > if (req.http.host ~ "^(www.)?xxx.ttd/xxxxxx/.*$") { > pass; > } > } > sub vcl_recv { > if (req.http.host ~ "^(www.)?xxx.ttd/xxxx/xxxxxxx/.*$") { > pass; > } > } > sub vcl_recv { > if (req.http.host ~ "^(www.)?xxx.ttd/xxxx/.*$") { > set obj.ttl = 1h; > } > } > > If I disable all [set obj.ttl = xx;] ,varnish start OK. > From phk at phk.freebsd.dk Thu Jun 5 14:33:20 2008 From: phk at phk.freebsd.dk (Poul-Henning Kamp) Date: Thu, 05 Jun 2008 14:33:20 +0000 Subject: ttl problem In-Reply-To: Your message of "Thu, 05 Jun 2008 16:04:46 +0200." <4847F27E.7060709@xlevyv.cz> Message-ID: <7503.1212676400@critter.freebsd.dk> In message <4847F27E.7060709 at xlevyv.cz>, Vojtech Levy writes: >> sub vcl_recv { >> if (req.http.host ~ "^(www.)?xxx.ttd/xxxx/.*$") { >> set obj.ttl = 1h; >> } >> } >> >> If I disable all [set obj.ttl = xx;] ,varnish start OK. You cannot set the ttl in vcl_recv{}, the object has not been found or fetched yet. You probably want to do that in vcl_fetch{} instead. -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk at FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence. From phk at projects.linpro.no Fri Jun 6 10:42:55 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Fri, 6 Jun 2008 12:42:55 +0200 (CEST) Subject: r2651 - trunk/varnish-cache/bin/varnishd Message-ID: <20080606104255.897B01EC106@projects.linpro.no> Author: phk Date: 2008-06-06 12:42:55 +0200 (Fri, 06 Jun 2008) New Revision: 2651 Modified: trunk/varnish-cache/bin/varnishd/tcp.c Log: Duh! I had the sense of FIONBIO args right in the first place. Revert 2647 and promise not to commit when sleepy. Modified: trunk/varnish-cache/bin/varnishd/tcp.c =================================================================== --- trunk/varnish-cache/bin/varnishd/tcp.c 2008-06-05 09:19:27 UTC (rev 2650) +++ trunk/varnish-cache/bin/varnishd/tcp.c 2008-06-06 10:42:55 UTC (rev 2651) @@ -127,7 +127,7 @@ { int i; - i = 1; + i = 0; AZ(ioctl(sock, FIONBIO, &i)); } @@ -136,7 +136,7 @@ { int i; - i = 0; + i = 1; AZ(ioctl(sock, FIONBIO, &i)); } From phk at projects.linpro.no Fri Jun 6 21:50:18 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Fri, 6 Jun 2008 23:50:18 +0200 (CEST) Subject: r2652 - trunk/varnish-cache/bin/varnishd Message-ID: <20080606215018.127241EC209@projects.linpro.no> Author: phk Date: 2008-06-06 23:50:17 +0200 (Fri, 06 Jun 2008) New Revision: 2652 Modified: trunk/varnish-cache/bin/varnishd/cache_http.c Log: Spell "X-Forwarded-for" as "X-Forwarded-For", this seems to match the unwritten lore better. Closes 203 Modified: trunk/varnish-cache/bin/varnishd/cache_http.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_http.c 2008-06-06 10:42:55 UTC (rev 2651) +++ trunk/varnish-cache/bin/varnishd/cache_http.c 2008-06-06 21:50:17 UTC (rev 2652) @@ -655,7 +655,7 @@ http_FilterFields(sp->wrk, sp->fd, hp, sp->http, how); http_PrintfHeader(sp->wrk, sp->fd, hp, "X-Varnish: %u", sp->xid); http_PrintfHeader(sp->wrk, sp->fd, hp, - "X-Forwarded-for: %s", sp->addr); + "X-Forwarded-For: %s", sp->addr); sp->bereq = bereq; From phk at projects.linpro.no Sat Jun 7 21:19:58 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Sat, 7 Jun 2008 23:19:58 +0200 (CEST) Subject: r2653 - trunk/varnish-cache/bin/varnishd Message-ID: <20080607211958.6B3391EC106@projects.linpro.no> Author: phk Date: 2008-06-07 23:19:58 +0200 (Sat, 07 Jun 2008) New Revision: 2653 Modified: trunk/varnish-cache/bin/varnishd/cache.h trunk/varnish-cache/bin/varnishd/cache_pool.c trunk/varnish-cache/bin/varnishd/heritage.h trunk/varnish-cache/bin/varnishd/mgt_param.c Log: Redo the way we manage the thread pool(s). This is necessary to generalize the thread pools to do other tasks for us in the future. Please read the descriptions of the new and changed thread_pool* parameters carefully before you tweak them, some of them have slightly different meanings now. The high-level view of this is that we now have dedicated a thread to adding threads to the pools, in addition to the thread we already had that killed idle threads from the pools. The difference is that this new thread is quite a bit more reluctant to add threads than the previous code, which would add a thread any time it could get away with it. Hopefully that reduces the tendency for thread-pile-ups. This commit also reduces the cross-pool locking contention by making the overflow queue a per pool item. The down side of that is that more of the stats counters have become unlocked and thus can get out of sync if two threads race when updating them. This is an XXX item. Thanks to Anders Nordby for testing this patch. Modified: trunk/varnish-cache/bin/varnishd/cache.h =================================================================== --- trunk/varnish-cache/bin/varnishd/cache.h 2008-06-06 21:50:17 UTC (rev 2652) +++ trunk/varnish-cache/bin/varnishd/cache.h 2008-06-07 21:19:58 UTC (rev 2653) @@ -197,9 +197,19 @@ unsigned wlr; }; +/* Work Request for worker thread ------------------------------------*/ + +/* + * This is a worker-function. + * XXX: typesafety is probably not worth fighting for + */ + +typedef void workfunc(struct worker *, void *priv); + struct workreq { VTAILQ_ENTRY(workreq) list; - struct sess *sess; + workfunc *func; + void *priv; }; #include "hash_slinger.h" @@ -504,6 +514,7 @@ /* cache_pool.c */ void WRK_Init(void); +int WRK_Queue(struct workreq *wrq); void WRK_QueueSession(struct sess *sp); void WRK_Reset(struct worker *w, int *fd); unsigned WRK_Flush(struct worker *w); Modified: trunk/varnish-cache/bin/varnishd/cache_pool.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_pool.c 2008-06-06 21:50:17 UTC (rev 2652) +++ trunk/varnish-cache/bin/varnishd/cache_pool.c 2008-06-07 21:19:58 UTC (rev 2653) @@ -29,6 +29,7 @@ * $Id$ * * XXX: automatic thread-pool size adaptation. + * XXX: unlocked stats variables: consider summing over pools in timer thread. */ #include "config.h" @@ -64,17 +65,25 @@ /* Number of work requests queued in excess of worker threads available */ struct wq { + unsigned magic; +#define WQ_MAGIC 0x606658fa MTX mtx; struct workerhead idle; - unsigned nwrk; + VTAILQ_HEAD(, workreq) overflow; + unsigned nthr; + unsigned nqueue; + uintmax_t drops; }; -static MTX tmtx; -static VTAILQ_HEAD(, workreq) overflow = VTAILQ_HEAD_INITIALIZER(overflow); - static struct wq **wq; static unsigned nwq; +static unsigned ovfl_max; +static unsigned nthr_max; +static unsigned nthr_min; +static pthread_cond_t herder_cond; +static MTX herder_mtx; + /*-------------------------------------------------------------------- * Write data to fd * We try to use writev() if possible in order to minimize number of @@ -180,34 +189,34 @@ /*--------------------------------------------------------------------*/ static void -wrk_do_one(struct worker *w) +wrk_do_cnt_sess(struct worker *w, void *priv) { - struct workreq *wrq; + struct sess *sess; - AN(w->wrq); - wrq = w->wrq; - CHECK_OBJ_NOTNULL(wrq->sess, SESS_MAGIC); - wrq->sess->wrk = w; + CAST_OBJ_NOTNULL(sess, priv, SESS_MAGIC); + sess->wrk = w; CHECK_OBJ_ORNULL(w->nobj, OBJECT_MAGIC); CHECK_OBJ_ORNULL(w->nobjhead, OBJHEAD_MAGIC); w->used = NAN; - CNT_Session(wrq->sess); + CNT_Session(sess); assert(!isnan(w->used)); CHECK_OBJ_ORNULL(w->nobj, OBJECT_MAGIC); CHECK_OBJ_ORNULL(w->nobjhead, OBJHEAD_MAGIC); - w->wrq = NULL; } +/*--------------------------------------------------------------------*/ + static void * wrk_thread(void *priv) { struct worker *w, ww; struct wq *qp; unsigned char wlog[8192]; /* XXX: size */ + struct workreq *wrq; THR_Name("cache-worker"); w = &ww; - qp = priv; + CAST_OBJ_NOTNULL(qp, priv, WQ_MAGIC); memset(w, 0, sizeof *w); w->magic = WORKER_MAGIC; w->used = TIM_real(); @@ -216,42 +225,32 @@ AZ(pthread_cond_init(&w->cond, NULL)); VSL(SLT_WorkThread, 0, "%p start", w); - LOCK(&tmtx); - VSL_stats->n_wrk_create++; - UNLOCK(&tmtx); while (1) { CHECK_OBJ_NOTNULL(w, WORKER_MAGIC); assert(!isnan(w->used)); - w->wrq = VTAILQ_FIRST(&overflow); + /* Process overflow requests, if any */ + LOCK(&qp->mtx); + w->wrq = VTAILQ_FIRST(&qp->overflow); if (w->wrq != NULL) { - LOCK(&tmtx); - - /* Process overflow requests, if any */ - w->wrq = VTAILQ_FIRST(&overflow); - if (w->wrq != NULL) { - VSL_stats->n_wrk_queue--; - VTAILQ_REMOVE(&overflow, w->wrq, list); - } - UNLOCK(&tmtx); - } - if (w->wrq == NULL) { - LOCK(&qp->mtx); + VTAILQ_REMOVE(&qp->overflow, w->wrq, list); + qp->nqueue--; + VSL_stats->n_wrk_queue--; /* XXX: unlocked */ + } else { VTAILQ_INSERT_HEAD(&qp->idle, w, list); AZ(pthread_cond_wait(&w->cond, &qp->mtx)); - UNLOCK(&qp->mtx); } + UNLOCK(&qp->mtx); if (w->wrq == NULL) break; - wrk_do_one(w); + AN(w->wrq); + wrq = w->wrq; + AN(wrq->func); + wrq->func(w, wrq->priv); + w->wrq = NULL; } - LOCK(&tmtx); - VSL_stats->n_wrk--; - qp->nwrk--; - UNLOCK(&tmtx); - VSL(SLT_WorkThread, 0, "%p end", w); if (w->vcl != NULL) VCL_Rel(&w->vcl); @@ -269,19 +268,22 @@ /*--------------------------------------------------------------------*/ -void -WRK_QueueSession(struct sess *sp) +int +WRK_Queue(struct workreq *wrq) { struct worker *w; - pthread_t tp; struct wq *qp; static unsigned nq = 0; unsigned onq; + /* + * Select which pool we issue to + * XXX: better alg ? + * XXX: per CPU ? + */ onq = nq + 1; if (onq >= nwq) onq = 0; - sp->workreq.sess = sp; qp = wq[onq]; nq = onq; @@ -292,136 +294,219 @@ if (w != NULL) { VTAILQ_REMOVE(&qp->idle, w, list); UNLOCK(&qp->mtx); - w->wrq = &sp->workreq; + w->wrq = wrq; AZ(pthread_cond_signal(&w->cond)); - return; + return (0); } + /* If we have too much in the overflow already, refuse */ + + if (qp->nqueue > ovfl_max) { + qp->drops++; + VSL_stats->n_wrk_drop++; /* XXX: unlocked */ + UNLOCK(&qp->mtx); + return (-1); + } + + VTAILQ_INSERT_TAIL(&qp->overflow, wrq, list); + VSL_stats->n_wrk_queue++; /* XXX: unlocked */ + VSL_stats->n_wrk_overflow++; /* XXX: unlocked */ + qp->nqueue++; UNLOCK(&qp->mtx); + AZ(pthread_cond_signal(&herder_cond)); + return (0); +} - LOCK(&tmtx); - /* - * If we have too much in the overflow, and this is a new session - * just drop it. We do not drop sessions which were waiting for - * a busy object, they will be cheap to serve from here and the - * cleanup would be more complex to carry out than delivering - * the result will be - */ - if (sp->obj == NULL && - (VSL_stats->n_wrk_queue > - (params->wthread_max * params->overflow_max) / 100)) { - VSL_stats->n_wrk_drop++; - UNLOCK(&tmtx); - sp->t_end = TIM_real(); - vca_close_session(sp, "dropped"); - if(sp->vcl != NULL) { - /* - * A session parked on a busy object can come here - * after it wakes up. Loose the VCL reference. - */ - VCL_Rel(&sp->vcl); - } - SES_Delete(sp); +/*--------------------------------------------------------------------*/ + +void +WRK_QueueSession(struct sess *sp) +{ + sp->workreq.func = wrk_do_cnt_sess; + sp->workreq.priv = sp; + if (WRK_Queue(&sp->workreq) == 0) return; - } + /* - * XXX: If there are too many requests in the overflow queue - * XXX: we should kill the request right here. - * XXX: Not sure how though. Simply closing may be the better - * XXX: compromise. + * Couldn't queue it -- kill it. + * + * XXX: a notice might be polite, but would potentially + * XXX: sleep whichever thread got us here */ - VTAILQ_INSERT_TAIL(&overflow, &sp->workreq, list); - VSL_stats->n_wrk_overflow++; - VSL_stats->n_wrk_queue++; - /* Can we create more threads ? */ - if (VSL_stats->n_wrk >= params->wthread_max || - qp->nwrk * nwq >= params->wthread_max) { - VSL_stats->n_wrk_max++; - UNLOCK(&tmtx); - return; + sp->t_end = TIM_real(); + vca_close_session(sp, "dropped"); + if(sp->vcl != NULL) { + /* + * A session parked on a busy object can come here + * after it wakes up. Loose the VCL reference. + */ + VCL_Rel(&sp->vcl); } - - /* Try to create a thread */ - VSL_stats->n_wrk++; - qp->nwrk++; - UNLOCK(&tmtx); - - if (!pthread_create(&tp, NULL, wrk_thread, qp)) { - AZ(pthread_detach(tp)); - return; - } - - VSL(SLT_Debug, 0, "Create worker thread failed %d %s", - errno, strerror(errno)); - - LOCK(&tmtx); - /* Register overflow */ - qp->nwrk--; - VSL_stats->n_wrk--; - VSL_stats->n_wrk_failed++; - UNLOCK(&tmtx); + SES_Delete(sp); } /*--------------------------------------------------------------------*/ static void -wrk_addpools(unsigned t) +wrk_addpools(const unsigned pools) { struct wq **pwq, **owq; unsigned u; - if (t <= nwq) - return; - - pwq = calloc(sizeof *pwq, params->wthread_pools); + pwq = calloc(sizeof *pwq, pools); if (pwq == NULL) return; if (wq != NULL) memcpy(pwq, wq, sizeof *pwq * nwq); owq = wq; wq = pwq; - for (u = nwq; u < t; u++) { + for (u = nwq; u < pools; u++) { wq[u] = calloc(sizeof *wq[u], 1); XXXAN(wq[u]); + wq[u]->magic = WQ_MAGIC; MTX_INIT(&wq[u]->mtx); + VTAILQ_INIT(&wq[u]->overflow); VTAILQ_INIT(&wq[u]->idle); } - free(owq); - nwq = t; + (void)owq; /* XXX: avoid race, leak it. */ + nwq = pools; } -/*--------------------------------------------------------------------*/ +/*-------------------------------------------------------------------- + * If a thread is idle or excess, pick it out of the pool... + */ +static void +wrk_decimate_flock(struct wq *qp, double t_idle) +{ + struct worker *w; + + if (qp->nthr <= nthr_min) + return; + + LOCK(&qp->mtx); + w = VTAILQ_LAST(&qp->idle, workerhead); + if (w != NULL && (w->used < t_idle || qp->nthr > nthr_max)) + VTAILQ_REMOVE(&qp->idle, w, list); + UNLOCK(&qp->mtx); + + /* And give it a kiss on the cheek... */ + if (w != NULL) { + AZ(w->wrq); + AZ(pthread_cond_signal(&w->cond)); + qp->nthr--; + VSL_stats->n_wrk--; /* XXX: unlocked */ + (void)usleep(params->wthread_purge_delay * 1000); + } +} + +/*-------------------------------------------------------------------- + * Periodic pool herding thread + * + * Do things which we can do at our leisure: + * Add pools + * Scale constants + * Get rid of excess threads + */ + static void * -wrk_reaperthread(void *priv) +wrk_herdtimer_thread(void *priv) { - double now; - struct worker *w; - struct wq *qp; + volatile unsigned u; + double t_idle; + + THR_Name("wrk_herdtimer"); + + (void)priv; + while (1) { + /* Add Pools */ + u = params->wthread_pools; + if (u > nwq) + wrk_addpools(u); + + /* Scale parameters */ + u = params->wthread_min / nwq; + if (u < 1) + u = 1; + nthr_min = u; + + u = params->wthread_max / nwq; + if (u < nthr_min) + u = nthr_min; + nthr_max = u; + + ovfl_max = (nthr_max * params->overflow_max) / 100; + + t_idle = TIM_real() - params->wthread_timeout; + for (u = 0; u < nwq; u++) + wrk_decimate_flock(wq[u], t_idle); + + (void)usleep(params->wthread_purge_delay * 1000); + } +} + +/*-------------------------------------------------------------------- + * Create more threads, if necessay & possible + */ + +static void +wrk_breed_flock(struct wq *qp) +{ + pthread_t tp; + + /* + * If we need more threads, and have space, create + * one more thread. + */ + if (qp->nqueue > params->wthread_add_threshold || + qp->nthr < nthr_min) { + if (qp->nthr >= nthr_max) { + VSL_stats->n_wrk_max++; + } else if (pthread_create(&tp, NULL, wrk_thread, qp)) { + VSL(SLT_Debug, 0, "Create worker thread failed %d %s", + errno, strerror(errno)); + VSL_stats->n_wrk_failed++; + (void)usleep(params->wthread_fail_delay * 1000); + } else { + qp->nthr++; + AZ(pthread_detach(tp)); + VSL_stats->n_wrk++; /* XXX: unlocked */ + VSL_stats->n_wrk_create++; + (void)usleep(params->wthread_add_delay * 1000); + } + } +} + +/*-------------------------------------------------------------------- + * This thread wakes up whenever a pool overflows. + * + * The trick here is to not be too aggressive about creating threads. + * We do this by only examining one pool at a time, and by sleeping + * a short while whenever we create a thread and a little while longer + * whenever we fail to, hopefully missing a lot of cond_signals in + * the meantime. + * + * XXX: probably need a lot more work. + * + */ + +static void * +wrk_herder_thread(void *priv) +{ unsigned u; + THR_Name("wrk_herder"); (void)priv; while (1) { - wrk_addpools(params->wthread_pools); - AZ(sleep(1)); - if (VSL_stats->n_wrk <= params->wthread_min) - continue; - now = TIM_real(); - for (u = 0; u < nwq; u++) { - qp = wq[u]; - LOCK(&qp->mtx); - w = VTAILQ_LAST(&qp->idle, workerhead); - if (w != NULL && - (w->used + params->wthread_timeout < now || - VSL_stats->n_wrk > params->wthread_max)) - VTAILQ_REMOVE(&qp->idle, w, list); - else - w = NULL; - UNLOCK(&qp->mtx); - if (w == NULL) - continue; - AZ(w->wrq); - AZ(pthread_cond_signal(&w->cond)); + for (u = 0 ; u < nwq; u++) { + /* + * We cannot avoid getting a mutex, so we have a + * bogo mutex just for POSIX_STUPIDITY + */ + AZ(pthread_mutex_lock(&herder_mtx)); + AZ(pthread_cond_wait(&herder_cond, &herder_mtx)); + AZ(pthread_mutex_unlock(&herder_mtx)); + wrk_breed_flock(wq[u]); } } } @@ -433,8 +518,10 @@ { pthread_t tp; - wrk_addpools(params->wthread_pools); - MTX_INIT(&tmtx); - AZ(pthread_create(&tp, NULL, wrk_reaperthread, NULL)); + AZ(pthread_cond_init(&herder_cond, NULL)); + AZ(pthread_mutex_init(&herder_mtx, NULL)); + + AZ(pthread_create(&tp, NULL, wrk_herdtimer_thread, NULL)); + AZ(pthread_create(&tp, NULL, wrk_herder_thread, NULL)); AZ(pthread_detach(tp)); } Modified: trunk/varnish-cache/bin/varnishd/heritage.h =================================================================== --- trunk/varnish-cache/bin/varnishd/heritage.h 2008-06-06 21:50:17 UTC (rev 2652) +++ trunk/varnish-cache/bin/varnishd/heritage.h 2008-06-07 21:19:58 UTC (rev 2653) @@ -76,11 +76,15 @@ /* TTL used for lack of anything better */ unsigned default_ttl; - /* Worker threads */ + /* Worker threads and pool */ unsigned wthread_min; unsigned wthread_max; unsigned wthread_timeout; unsigned wthread_pools; + unsigned wthread_add_threshold; + unsigned wthread_add_delay; + unsigned wthread_fail_delay; + unsigned wthread_purge_delay; unsigned overflow_max; Modified: trunk/varnish-cache/bin/varnishd/mgt_param.c =================================================================== --- trunk/varnish-cache/bin/varnishd/mgt_param.c 2008-06-06 21:50:17 UTC (rev 2652) +++ trunk/varnish-cache/bin/varnishd/mgt_param.c 2008-06-07 21:19:58 UTC (rev 2653) @@ -463,31 +463,96 @@ 0, "120", "seconds" }, { "thread_pools", tweak_uint, &master.wthread_pools, 1, UINT_MAX, - "Number of worker pools. " + "Number of worker thread pools.\n" + "\n" "Increasing number of worker pools decreases lock " - "contention but increases the number of threads as well. " + "contention.\n" + "\n" + "Too many pools waste CPU and RAM resources, and more than " + "one pool for each CPU is probably detrimal to performance.\n" + "\n" "Can be increased on the fly, but decreases require a " "restart to take effect.", - EXPERIMENTAL, + EXPERIMENTAL | DELAYED_EFFECT, "1", "pools" }, - { "thread_pool_max", tweak_thread_pool_max, NULL, 0, 0, - "The maximum number of threads in the total worker pool.\n" - "-1 is unlimited.", + { "thread_pool_max", tweak_thread_pool_max, NULL, 1, 0, + "The maximum number of worker threads in all pools combined.\n" + "\n" + "Do not set this higher than you have to, since excess " + "worker threads soak up RAM and CPU and generally just get " + "in the way of getting work done.\n", EXPERIMENTAL | DELAYED_EFFECT, - "1000", "threads" }, - { "thread_pool_min", tweak_thread_pool_min, NULL, 0, 0, - "The minimum number of threads in the worker pool.\n" + "100", "threads" }, + { "thread_pool_min", tweak_thread_pool_min, NULL, 1, 0, + "The minimum number of threads in all worker pools combined.\n" + "\n" + "Increasing this may help ramp up faster from low load " + "situations where threads have expired.\n" + "\n" "Minimum is 1 thread.", EXPERIMENTAL | DELAYED_EFFECT, "1", "threads" }, - { "thread_pool_timeout", tweak_timeout, &master.wthread_timeout, 0, 0, - "Thread dies after this many seconds of inactivity.\n" + { "thread_pool_timeout", tweak_timeout, &master.wthread_timeout, 1, 0, + "Thread idle threshold.\n" + "\n" + "Threads in excess of thread_pool_min, which have been idle " + "for at least this long are candidates for purging.\n" + "\n" "Minimum is 1 second.", EXPERIMENTAL | DELAYED_EFFECT, "120", "seconds" }, + { "thread_pool_purge_delay", + tweak_timeout, &master.wthread_purge_delay, 100, 0, + "Wait this long between purging threads.\n" + "\n" + "This controls the decay of thread pools when idle(-ish).\n" + "\n" + "Minimum is 100 milliseconds.", + EXPERIMENTAL | DELAYED_EFFECT, + "1000", "milliseconds" }, + { "thread_pool_add_threshold", + tweak_uint, &master.wthread_add_threshold, 0, UINT_MAX, + "Overflow threshold for worker thread creation.\n" + "\n" + "Setting this too low, will result in excess worker threads, " + "which is generally a bad idea.\n" + "\n" + "Setting it too high results in insuffient worker threads.\n", + EXPERIMENTAL, + "2", "requests" }, + { "thread_pool_add_delay", + tweak_timeout, &master.wthread_add_delay, 0, UINT_MAX, + "Wait at least this long between creating threads.\n" + "\n" + "Setting this too long results in insuffient worker threads.\n" + "\n" + "Setting this too short increases the risk of worker " + "thread pile-up.\n", + EXPERIMENTAL, + "10", "milliseconds" }, + { "thread_pool_fail_delay", + tweak_timeout, &master.wthread_fail_delay, 100, UINT_MAX, + "Wait at least this long after a failed thread creation " + "before trying to create another thread.\n" + "\n" + "Failure to create a worker thread is often a sign that " + " the end is near, because the process is running out of " + "RAM resources for thread stacks.\n" + "This delay tries to not rush it on needlessly.\n" + "\n" + "If thread creation failures are a problem, check that " + "thread_pool_max is not too high.\n" + "\n" + "It may also help to increase thread_pool_timeout and " + "thread_pool_min, to reduce the rate at which treads are " + "destroyed and later recreated.\n", + EXPERIMENTAL, + "200", "milliseconds" }, { "overflow_max", tweak_uint, &master.overflow_max, 0, UINT_MAX, - "Limit on overflow queue length in percent of " - "thread_pool_max parameter.", + "Percentage permitted overflow queue length.\n" + "\n" + "This sets the ratio of queued requests to worker threads, " + "above which sessions will be dropped instead of queued.\n", EXPERIMENTAL, "100", "%" }, { "rush_exponent", tweak_uint, &master.rush_exponent, 2, UINT_MAX, From phk at projects.linpro.no Sun Jun 8 20:42:29 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Sun, 8 Jun 2008 22:42:29 +0200 (CEST) Subject: r2654 - trunk/varnish-cache/bin/varnishd Message-ID: <20080608204229.352B51EC0B3@projects.linpro.no> Author: phk Date: 2008-06-08 22:42:28 +0200 (Sun, 08 Jun 2008) New Revision: 2654 Modified: trunk/varnish-cache/bin/varnishd/cache_pool.c Log: If we decide not to eliminate the worker thread, properly do so. Modified: trunk/varnish-cache/bin/varnishd/cache_pool.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_pool.c 2008-06-07 21:19:58 UTC (rev 2653) +++ trunk/varnish-cache/bin/varnishd/cache_pool.c 2008-06-08 20:42:28 UTC (rev 2654) @@ -388,6 +388,8 @@ w = VTAILQ_LAST(&qp->idle, workerhead); if (w != NULL && (w->used < t_idle || qp->nthr > nthr_max)) VTAILQ_REMOVE(&qp->idle, w, list); + else + w = NULL; UNLOCK(&qp->mtx); /* And give it a kiss on the cheek... */ From phk at projects.linpro.no Mon Jun 9 08:12:31 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 9 Jun 2008 10:12:31 +0200 (CEST) Subject: r2655 - trunk/varnish-cache/bin/varnishd Message-ID: <20080609081232.01CEE1EC209@projects.linpro.no> Author: phk Date: 2008-06-09 10:12:31 +0200 (Mon, 09 Jun 2008) New Revision: 2655 Modified: trunk/varnish-cache/bin/varnishd/cache_pool.c Log: Properly lock n_wrk* statics variables without using more lock operations. Have the worker threads add themselves to the pool, while the hold the pool lock anyway. Collect stats per pool, and have the decimator aggregate over all pools and into the shared memory counters. Modified: trunk/varnish-cache/bin/varnishd/cache_pool.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_pool.c 2008-06-08 20:42:28 UTC (rev 2654) +++ trunk/varnish-cache/bin/varnishd/cache_pool.c 2008-06-09 08:12:31 UTC (rev 2655) @@ -29,7 +29,6 @@ * $Id$ * * XXX: automatic thread-pool size adaptation. - * XXX: unlocked stats variables: consider summing over pools in timer thread. */ #include "config.h" @@ -72,7 +71,8 @@ VTAILQ_HEAD(, workreq) overflow; unsigned nthr; unsigned nqueue; - uintmax_t drops; + uintmax_t ndrop; + uintmax_t noverflow; }; static struct wq **wq; @@ -226,30 +226,33 @@ VSL(SLT_WorkThread, 0, "%p start", w); + LOCK(&qp->mtx); + qp->nthr++; while (1) { CHECK_OBJ_NOTNULL(w, WORKER_MAGIC); assert(!isnan(w->used)); /* Process overflow requests, if any */ - LOCK(&qp->mtx); w->wrq = VTAILQ_FIRST(&qp->overflow); if (w->wrq != NULL) { VTAILQ_REMOVE(&qp->overflow, w->wrq, list); qp->nqueue--; - VSL_stats->n_wrk_queue--; /* XXX: unlocked */ } else { VTAILQ_INSERT_HEAD(&qp->idle, w, list); AZ(pthread_cond_wait(&w->cond, &qp->mtx)); } - UNLOCK(&qp->mtx); if (w->wrq == NULL) break; + UNLOCK(&qp->mtx); AN(w->wrq); wrq = w->wrq; AN(wrq->func); wrq->func(w, wrq->priv); w->wrq = NULL; + LOCK(&qp->mtx); } + qp->nthr--; + UNLOCK(&qp->mtx); VSL(SLT_WorkThread, 0, "%p end", w); if (w->vcl != NULL) @@ -302,15 +305,13 @@ /* If we have too much in the overflow already, refuse */ if (qp->nqueue > ovfl_max) { - qp->drops++; - VSL_stats->n_wrk_drop++; /* XXX: unlocked */ + qp->ndrop++; UNLOCK(&qp->mtx); return (-1); } VTAILQ_INSERT_TAIL(&qp->overflow, wrq, list); - VSL_stats->n_wrk_queue++; /* XXX: unlocked */ - VSL_stats->n_wrk_overflow++; /* XXX: unlocked */ + qp->noverflow++; qp->nqueue++; UNLOCK(&qp->mtx); AZ(pthread_cond_signal(&herder_cond)); @@ -373,11 +374,11 @@ } /*-------------------------------------------------------------------- - * If a thread is idle or excess, pick it out of the pool... + * If a thread is idle or excess, pick it out of the pool. */ static void -wrk_decimate_flock(struct wq *qp, double t_idle) +wrk_decimate_flock(struct wq *qp, double t_idle, struct varnish_stats *vs) { struct worker *w; @@ -390,14 +391,16 @@ VTAILQ_REMOVE(&qp->idle, w, list); else w = NULL; + vs->n_wrk += qp->nthr; + vs->n_wrk_queue += qp->nqueue; + vs->n_wrk_drop += qp->ndrop; + vs->n_wrk_overflow += qp->noverflow; UNLOCK(&qp->mtx); /* And give it a kiss on the cheek... */ if (w != NULL) { AZ(w->wrq); AZ(pthread_cond_signal(&w->cond)); - qp->nthr--; - VSL_stats->n_wrk--; /* XXX: unlocked */ (void)usleep(params->wthread_purge_delay * 1000); } } @@ -409,6 +412,7 @@ * Add pools * Scale constants * Get rid of excess threads + * Aggregate stats across pools */ static void * @@ -416,9 +420,13 @@ { volatile unsigned u; double t_idle; + struct varnish_stats vsm, *vs; THR_Name("wrk_herdtimer"); + memset(&vsm, 0, sizeof vsm); + vs = &vsm; + (void)priv; while (1) { /* Add Pools */ @@ -439,10 +447,20 @@ ovfl_max = (nthr_max * params->overflow_max) / 100; + vs->n_wrk = 0; + vs->n_wrk_queue = 0; + vs->n_wrk_drop = 0; + vs->n_wrk_overflow = 0; + t_idle = TIM_real() - params->wthread_timeout; for (u = 0; u < nwq; u++) - wrk_decimate_flock(wq[u], t_idle); + wrk_decimate_flock(wq[u], t_idle, vs); + VSL_stats->n_wrk= vs->n_wrk; + VSL_stats->n_wrk_queue = vs->n_wrk_queue; + VSL_stats->n_wrk_drop = vs->n_wrk_drop; + VSL_stats->n_wrk_overflow = vs->n_wrk_overflow; + (void)usleep(params->wthread_purge_delay * 1000); } } @@ -470,9 +488,7 @@ VSL_stats->n_wrk_failed++; (void)usleep(params->wthread_fail_delay * 1000); } else { - qp->nthr++; AZ(pthread_detach(tp)); - VSL_stats->n_wrk++; /* XXX: unlocked */ VSL_stats->n_wrk_create++; (void)usleep(params->wthread_add_delay * 1000); } From phk at projects.linpro.no Mon Jun 9 08:35:38 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 9 Jun 2008 10:35:38 +0200 (CEST) Subject: r2656 - trunk/varnish-cache/bin/varnishd Message-ID: <20080609083538.E8F911ED1CC@projects.linpro.no> Author: phk Date: 2008-06-09 10:35:38 +0200 (Mon, 09 Jun 2008) New Revision: 2656 Modified: trunk/varnish-cache/bin/varnishd/cache_pool.c Log: Style & Polish. Modified: trunk/varnish-cache/bin/varnishd/cache_pool.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_pool.c 2008-06-09 08:12:31 UTC (rev 2655) +++ trunk/varnish-cache/bin/varnishd/cache_pool.c 2008-06-09 08:35:38 UTC (rev 2656) @@ -28,7 +28,18 @@ * * $Id$ * - * XXX: automatic thread-pool size adaptation. + * We maintain a number of worker thread pools, to spread lock contention. + * + * Pools can be added on the fly, as a means to mitigate lock contention, + * but can only be removed again by a restart. (XXX: we could fix that) + * + * Two threads herd the pools, one eliminates idle threads and aggregates + * statistics for all the pools, the other thread creates new threads + * on demand, subject to various numerical constraints. + * + * The algorithm for when to create threads needs to be reactive enough + * to handle startup spikes, but sufficiently attenuated to not cause + * thread pileups. This remains subject for improvement. */ #include "config.h" @@ -188,24 +199,6 @@ /*--------------------------------------------------------------------*/ -static void -wrk_do_cnt_sess(struct worker *w, void *priv) -{ - struct sess *sess; - - CAST_OBJ_NOTNULL(sess, priv, SESS_MAGIC); - sess->wrk = w; - CHECK_OBJ_ORNULL(w->nobj, OBJECT_MAGIC); - CHECK_OBJ_ORNULL(w->nobjhead, OBJHEAD_MAGIC); - w->used = NAN; - CNT_Session(sess); - assert(!isnan(w->used)); - CHECK_OBJ_ORNULL(w->nobj, OBJECT_MAGIC); - CHECK_OBJ_ORNULL(w->nobjhead, OBJHEAD_MAGIC); -} - -/*--------------------------------------------------------------------*/ - static void * wrk_thread(void *priv) { @@ -269,7 +262,11 @@ return (NULL); } -/*--------------------------------------------------------------------*/ +/*-------------------------------------------------------------------- + * Queue a workrequest if possible. + * + * Return zero if the request was queued, negative if it wasn't. + */ int WRK_Queue(struct workreq *wrq) @@ -302,8 +299,7 @@ return (0); } - /* If we have too much in the overflow already, refuse */ - + /* If we have too much in the overflow already, refuse. */ if (qp->nqueue > ovfl_max) { qp->ndrop++; UNLOCK(&qp->mtx); @@ -320,6 +316,24 @@ /*--------------------------------------------------------------------*/ +static void +wrk_do_cnt_sess(struct worker *w, void *priv) +{ + struct sess *sess; + + CAST_OBJ_NOTNULL(sess, priv, SESS_MAGIC); + sess->wrk = w; + CHECK_OBJ_ORNULL(w->nobj, OBJECT_MAGIC); + CHECK_OBJ_ORNULL(w->nobjhead, OBJHEAD_MAGIC); + w->used = NAN; + CNT_Session(sess); + assert(!isnan(w->used)); + CHECK_OBJ_ORNULL(w->nobj, OBJECT_MAGIC); + CHECK_OBJ_ORNULL(w->nobjhead, OBJHEAD_MAGIC); +} + +/*--------------------------------------------------------------------*/ + void WRK_QueueSession(struct sess *sp) { @@ -346,7 +360,9 @@ SES_Delete(sp); } -/*--------------------------------------------------------------------*/ +/*-------------------------------------------------------------------- + * Add (more) thread pools + */ static void wrk_addpools(const unsigned pools) @@ -466,7 +482,7 @@ } /*-------------------------------------------------------------------- - * Create more threads, if necessay & possible + * Create another thread, if necessary & possible */ static void @@ -540,6 +556,7 @@ AZ(pthread_mutex_init(&herder_mtx, NULL)); AZ(pthread_create(&tp, NULL, wrk_herdtimer_thread, NULL)); + AZ(pthread_detach(tp)); AZ(pthread_create(&tp, NULL, wrk_herder_thread, NULL)); AZ(pthread_detach(tp)); } From phk at projects.linpro.no Mon Jun 9 13:01:28 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 9 Jun 2008 15:01:28 +0200 (CEST) Subject: r2657 - in trunk/varnish-cache: include lib/libvarnish Message-ID: <20080609130128.58F511EC209@projects.linpro.no> Author: phk Date: 2008-06-09 15:01:27 +0200 (Mon, 09 Jun 2008) New Revision: 2657 Modified: trunk/varnish-cache/include/vss.h trunk/varnish-cache/lib/libvarnish/vss.c Log: Add a VSS_bind() function, using the meat of VSS_listen() Modified: trunk/varnish-cache/include/vss.h =================================================================== --- trunk/varnish-cache/include/vss.h 2008-06-09 08:35:38 UTC (rev 2656) +++ trunk/varnish-cache/include/vss.h 2008-06-09 13:01:27 UTC (rev 2657) @@ -32,5 +32,6 @@ int VSS_parse(const char *str, char **addr, char **port); int VSS_resolve(const char *addr, const char *port, struct vss_addr ***ta); +int VSS_bind(const struct vss_addr *addr); int VSS_listen(const struct vss_addr *addr, int depth); int VSS_connect(const struct vss_addr *addr); Modified: trunk/varnish-cache/lib/libvarnish/vss.c =================================================================== --- trunk/varnish-cache/lib/libvarnish/vss.c 2008-06-09 08:35:38 UTC (rev 2656) +++ trunk/varnish-cache/lib/libvarnish/vss.c 2008-06-09 13:01:27 UTC (rev 2657) @@ -165,14 +165,15 @@ } /* - * Given a struct vss_addr, open a socket of the appropriate type, bind it - * to the requested address, and start listening. + * Given a struct vss_addr, open a socket of the appropriate type, and bind + * it to the requested address. * * If the address is an IPv6 address, the IPV6_V6ONLY option is set to * avoid conflicts between INADDR_ANY and IN6ADDR_ANY. */ + int -VSS_listen(const struct vss_addr *va, int depth) +VSS_bind(const struct vss_addr *va) { int sd, val; @@ -202,10 +203,28 @@ (void)close(sd); return (-1); } - if (listen(sd, depth) != 0) { - perror("listen()"); - (void)close(sd); - return (-1); + return (sd); +} + +/* + * Given a struct vss_addr, open a socket of the appropriate type, bind it + * to the requested address, and start listening. + * + * If the address is an IPv6 address, the IPV6_V6ONLY option is set to + * avoid conflicts between INADDR_ANY and IN6ADDR_ANY. + */ +int +VSS_listen(const struct vss_addr *va, int depth) +{ + int sd; + + sd = VSS_bind(va); + if (sd >= 0) { + if (listen(sd, depth) != 0) { + perror("listen()"); + (void)close(sd); + return (-1); + } } return (sd); } From phk at projects.linpro.no Mon Jun 9 13:11:46 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 9 Jun 2008 15:11:46 +0200 (CEST) Subject: r2658 - trunk/varnish-cache/bin/varnishd Message-ID: <20080609131146.895D21EC209@projects.linpro.no> Author: phk Date: 2008-06-09 15:11:45 +0200 (Mon, 09 Jun 2008) New Revision: 2658 Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor.c trunk/varnish-cache/bin/varnishd/heritage.h trunk/varnish-cache/bin/varnishd/mgt_child.c Log: Don't leak listen address structures if we fail to bind to them. Associate ascii representation addr/port strings with each listen socket, already in the manager process. Postpone listen(2) call until client is ready, to limit initial connection spike. XXX: I still miss an unlisten(2). Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_acceptor.c 2008-06-09 13:01:27 UTC (rev 2657) +++ trunk/varnish-cache/bin/varnishd/cache_acceptor.c 2008-06-09 13:11:45 UTC (rev 2658) @@ -161,6 +161,9 @@ AN(pfd); i = 0; VTAILQ_FOREACH(ls, &heritage.socks, list) { + if (ls->sock < 0) + continue; + AZ(listen(ls->sock, params->listen_depth)); AZ(setsockopt(ls->sock, SOL_SOCKET, SO_LINGER, &linger, sizeof linger)); pfd[i].events = POLLIN; Modified: trunk/varnish-cache/bin/varnishd/heritage.h =================================================================== --- trunk/varnish-cache/bin/varnishd/heritage.h 2008-06-09 13:01:27 UTC (rev 2657) +++ trunk/varnish-cache/bin/varnishd/heritage.h 2008-06-09 13:11:45 UTC (rev 2658) @@ -38,6 +38,8 @@ struct listen_sock { VTAILQ_ENTRY(listen_sock) list; int sock; + char *hname; + char *pname; struct vss_addr *addr; }; Modified: trunk/varnish-cache/bin/varnishd/mgt_child.c =================================================================== --- trunk/varnish-cache/bin/varnishd/mgt_child.c 2008-06-09 13:01:27 UTC (rev 2657) +++ trunk/varnish-cache/bin/varnishd/mgt_child.c 2008-06-09 13:11:45 UTC (rev 2658) @@ -138,18 +138,21 @@ { struct listen_sock *ls, *ls2; int good = 0; + char hbuf[TCP_ADDRBUFSIZE]; + char pbuf[TCP_PORTBUFSIZE]; VTAILQ_FOREACH_SAFE(ls, &heritage.socks, list, ls2) { if (ls->sock >= 0) { good++; continue; } - ls->sock = VSS_listen(ls->addr, params->listen_depth); - if (ls->sock < 0) { - VTAILQ_REMOVE(&heritage.socks, ls, list); - free(ls); + ls->sock = VSS_bind(ls->addr); + if (ls->sock < 0) continue; - } + + TCP_myname(ls->sock, hbuf, sizeof hbuf, pbuf, sizeof pbuf); + REPLACE(ls->hname, hbuf); + REPLACE(ls->pname, pbuf); /* * Set nonblocking mode to avoid a race where a client * closes before we call accept(2) and nobody else are in @@ -174,8 +177,10 @@ VTAILQ_FOREACH(ls, &heritage.socks, list) { if (ls->sock < 0) continue; - (void)close(ls->sock); + AZ(close(ls->sock)); ls->sock = -1; + REPLACE(ls->hname, NULL); + REPLACE(ls->pname, NULL); } } From phk at projects.linpro.no Mon Jun 9 13:35:37 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 9 Jun 2008 15:35:37 +0200 (CEST) Subject: r2659 - trunk/varnish-cache/bin/varnishd Message-ID: <20080609133537.20F601EC0FD@projects.linpro.no> Author: phk Date: 2008-06-09 15:35:35 +0200 (Mon, 09 Jun 2008) New Revision: 2659 Modified: trunk/varnish-cache/bin/varnishd/cache.h trunk/varnish-cache/bin/varnishd/cache_acceptor.c trunk/varnish-cache/bin/varnishd/heritage.h trunk/varnish-cache/bin/varnishd/mgt_child.c trunk/varnish-cache/bin/varnishd/mgt_param.c Log: Slight backtracking: Store the specified socket name in the listen socket structure, instead of whatever we actually bound to. It is more informative and intuitive. Report the listen socket spec in the SessionOpen shm record. Close listen sockets as soon as we have forked the child, this eliminated a fd-leak when a socket was eliminated from listen_address while the child ran. Fix various potential problems related to not being able to bind to one or more listen addresses. Modified: trunk/varnish-cache/bin/varnishd/cache.h =================================================================== --- trunk/varnish-cache/bin/varnishd/cache.h 2008-06-09 13:11:45 UTC (rev 2658) +++ trunk/varnish-cache/bin/varnishd/cache.h 2008-06-09 13:35:35 UTC (rev 2659) @@ -319,6 +319,7 @@ socklen_t mysockaddrlen; struct sockaddr *sockaddr; struct sockaddr *mysockaddr; + struct listen_sock *mylsock; /* formatted ascii client address */ char *addr; Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_acceptor.c 2008-06-09 13:11:45 UTC (rev 2658) +++ trunk/varnish-cache/bin/varnishd/cache_acceptor.c 2008-06-09 13:35:35 UTC (rev 2659) @@ -119,7 +119,8 @@ addr, sizeof addr, port, sizeof port); sp->addr = WS_Dup(sp->ws, addr); sp->port = WS_Dup(sp->ws, port); - VSL(SLT_SessionOpen, sp->fd, "%s %s", sp->addr, sp->port); + VSL(SLT_SessionOpen, sp->fd, "%s %s %s", + sp->addr, sp->port, sp->mylsock->name); sp->acct.first = sp->t_open; if (need_test) sock_test(sp->fd); @@ -194,16 +195,19 @@ #endif i = poll(pfd, heritage.nsocks, 1000); now = TIM_real(); - for (u = 0; u < heritage.nsocks; u++) { - if (pfd[u].revents == 0) + u = 0; + VTAILQ_FOREACH(ls, &heritage.socks, list) { + if (ls->sock < 0) continue; + if (pfd[u++].revents == 0) + continue; VSL_stats->client_conn++; l = sizeof addr_s; addr = (void*)&addr_s; - i = accept(pfd[u].fd, addr, &l); + i = accept(ls->sock, addr, &l); if (i < 0) { if (errno != EAGAIN && errno != ECONNABORTED) { - VSL(SLT_Debug, pfd[u].fd, + VSL(SLT_Debug, ls->sock, "Accept failed errno=%d", errno); /* XXX: stats ? */ } @@ -215,6 +219,7 @@ sp->fd = i; sp->id = i; sp->t_open = now; + sp->mylsock = ls; sp->step = STP_FIRST; WRK_QueueSession(sp); Modified: trunk/varnish-cache/bin/varnishd/heritage.h =================================================================== --- trunk/varnish-cache/bin/varnishd/heritage.h 2008-06-09 13:11:45 UTC (rev 2658) +++ trunk/varnish-cache/bin/varnishd/heritage.h 2008-06-09 13:35:35 UTC (rev 2659) @@ -38,8 +38,7 @@ struct listen_sock { VTAILQ_ENTRY(listen_sock) list; int sock; - char *hname; - char *pname; + char *name; struct vss_addr *addr; }; Modified: trunk/varnish-cache/bin/varnishd/mgt_child.c =================================================================== --- trunk/varnish-cache/bin/varnishd/mgt_child.c 2008-06-09 13:11:45 UTC (rev 2658) +++ trunk/varnish-cache/bin/varnishd/mgt_child.c 2008-06-09 13:35:35 UTC (rev 2659) @@ -138,8 +138,6 @@ { struct listen_sock *ls, *ls2; int good = 0; - char hbuf[TCP_ADDRBUFSIZE]; - char pbuf[TCP_PORTBUFSIZE]; VTAILQ_FOREACH_SAFE(ls, &heritage.socks, list, ls2) { if (ls->sock >= 0) { @@ -150,9 +148,6 @@ if (ls->sock < 0) continue; - TCP_myname(ls->sock, hbuf, sizeof hbuf, pbuf, sizeof pbuf); - REPLACE(ls->hname, hbuf); - REPLACE(ls->pname, pbuf); /* * Set nonblocking mode to avoid a race where a client * closes before we call accept(2) and nobody else are in @@ -179,8 +174,6 @@ continue; AZ(close(ls->sock)); ls->sock = -1; - REPLACE(ls->hname, NULL); - REPLACE(ls->pname, NULL); } } @@ -213,6 +206,7 @@ exit(1); } if (pid == 0) { + /* XXX: We should close things like syslog & telnet sockets */ if (geteuid() == 0) { XXXAZ(setgid(params->gid)); XXXAZ(setuid(params->uid)); @@ -240,6 +234,8 @@ fprintf(stderr, "start child pid %jd\n", (intmax_t)pid); + close_sockets(); + AZ(close(child_fds[1])); child_fds[1] = -1; @@ -292,7 +288,6 @@ if (child_state != CH_RUNNING) return; - close_sockets(); child_state = CH_STOPPING; if (ev_poker != NULL) { @@ -365,7 +360,6 @@ if (child_state == CH_DIED && params->auto_restart) start_child(); else if (child_state == CH_DIED) { - close_sockets(); child_state = CH_STOPPED; } else if (child_state == CH_STOPPING) child_state = CH_STOPPED; Modified: trunk/varnish-cache/bin/varnishd/mgt_param.c =================================================================== --- trunk/varnish-cache/bin/varnishd/mgt_param.c 2008-06-09 13:11:45 UTC (rev 2658) +++ trunk/varnish-cache/bin/varnishd/mgt_param.c 2008-06-09 13:35:35 UTC (rev 2659) @@ -299,6 +299,7 @@ VTAILQ_FOREACH_SAFE(ls, lsh, list, ls2) { VTAILQ_REMOVE(lsh, ls, list); + free(ls->name); free(ls->addr); free(ls); } @@ -359,6 +360,8 @@ AN(ls); ls->sock = -1; ls->addr = ta[j]; + ls->name = strdup(av[i]); + AN(ls->name); VTAILQ_INSERT_TAIL(&lsh, ls, list); } free(ta); From phk at projects.linpro.no Tue Jun 10 13:29:08 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Tue, 10 Jun 2008 15:29:08 +0200 (CEST) Subject: r2660 - trunk/varnish-cache/bin/varnishd Message-ID: <20080610132908.E5B1D1EC118@projects.linpro.no> Author: phk Date: 2008-06-10 15:29:08 +0200 (Tue, 10 Jun 2008) New Revision: 2660 Modified: trunk/varnish-cache/bin/varnishd/mgt_param.c Log: Make this compile under OS/X 10.5 Leopard Submitted by: peter Closes: 245 Modified: trunk/varnish-cache/bin/varnishd/mgt_param.c =================================================================== --- trunk/varnish-cache/bin/varnishd/mgt_param.c 2008-06-09 13:35:35 UTC (rev 2659) +++ trunk/varnish-cache/bin/varnishd/mgt_param.c 2008-06-10 13:29:08 UTC (rev 2660) @@ -687,7 +687,7 @@ MUST_RELOAD, #ifdef __APPLE__ "exec cc -dynamiclib -Wl,-undefined,dynamic_lookup -o %o %s" -#elseif defined(__SOLARIS__) +#elif defined(__SOLARIS__) "exec cc -shared -fpic -c %o %s" #else /* default: GCC on Linux & FreeBSD */ "exec cc -fpic -shared -Wl,-x -o %o %s" From phk at projects.linpro.no Tue Jun 10 14:37:15 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Tue, 10 Jun 2008 16:37:15 +0200 (CEST) Subject: r2661 - trunk/varnish-cache/bin/varnishd Message-ID: <20080610143715.144E91EC0F8@projects.linpro.no> Author: phk Date: 2008-06-10 16:37:14 +0200 (Tue, 10 Jun 2008) New Revision: 2661 Added: trunk/varnish-cache/bin/varnishd/acct_fields.h Modified: trunk/varnish-cache/bin/varnishd/cache.h trunk/varnish-cache/bin/varnishd/cache_cli.c trunk/varnish-cache/bin/varnishd/cache_session.c Log: Refactor the fields of struct acct so we don't have to remember them three different places in the code. Added: trunk/varnish-cache/bin/varnishd/acct_fields.h =================================================================== --- trunk/varnish-cache/bin/varnishd/acct_fields.h (rev 0) +++ trunk/varnish-cache/bin/varnishd/acct_fields.h 2008-06-10 14:37:14 UTC (rev 2661) @@ -0,0 +1,38 @@ +/*- + * Copyright (c) 2008 Verdens Gang AS + * Copyright (c) 2008 Linpro AS + * All rights reserved. + * + * Author: Poul-Henning Kamp + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $Id: steps.h 2415 2008-01-31 11:57:51Z des $ + */ + +ACCT(sess) +ACCT(req) +ACCT(pipe) +ACCT(pass) +ACCT(fetch) +ACCT(hdrbytes) +ACCT(bodybytes) Modified: trunk/varnish-cache/bin/varnishd/cache.h =================================================================== --- trunk/varnish-cache/bin/varnishd/cache.h 2008-06-10 13:29:08 UTC (rev 2660) +++ trunk/varnish-cache/bin/varnishd/cache.h 2008-06-10 14:37:14 UTC (rev 2661) @@ -159,13 +159,9 @@ struct acct { double first; - uint64_t sess; - uint64_t req; - uint64_t pipe; - uint64_t pass; - uint64_t fetch; - uint64_t hdrbytes; - uint64_t bodybytes; +#define ACCT(foo) uint64_t foo; +#include "acct_fields.h" +#undef ACCT }; /*--------------------------------------------------------------------*/ Modified: trunk/varnish-cache/bin/varnishd/cache_cli.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_cli.c 2008-06-10 13:29:08 UTC (rev 2660) +++ trunk/varnish-cache/bin/varnishd/cache_cli.c 2008-06-10 14:37:14 UTC (rev 2661) @@ -193,6 +193,7 @@ SZOF(struct objhead); SZOF(struct sess); SZOF(struct vbe_conn); + SZOF(struct varnish_stats); } /*--------------------------------------------------------------------*/ Modified: trunk/varnish-cache/bin/varnishd/cache_session.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_session.c 2008-06-10 13:29:08 UTC (rev 2660) +++ trunk/varnish-cache/bin/varnishd/cache_session.c 2008-06-10 14:37:14 UTC (rev 2661) @@ -213,13 +213,9 @@ ses_sum_acct(struct acct *sum, const struct acct *inc) { - sum->sess += inc->sess; - sum->req += inc->req; - sum->pipe += inc->pipe; - sum->pass += inc->pass; - sum->fetch += inc->fetch; - sum->hdrbytes += inc->hdrbytes; - sum->bodybytes += inc->bodybytes; +#define ACCT(foo) sum->foo += inc->foo; +#include "acct_fields.h" +#undef ACCT } void @@ -243,13 +239,9 @@ b.fetch, b.hdrbytes, b.bodybytes); } LOCK(&stat_mtx); - VSL_stats->s_sess += a->sess; - VSL_stats->s_req += a->req; - VSL_stats->s_pipe += a->pipe; - VSL_stats->s_pass += a->pass; - VSL_stats->s_fetch += a->fetch; - VSL_stats->s_hdrbytes += a->hdrbytes; - VSL_stats->s_bodybytes += a->bodybytes; +#define ACCT(foo) VSL_stats->s_##foo += a->foo; +#include "acct_fields.h" +#undef ACCT UNLOCK(&stat_mtx); memset(a, 0, sizeof *a); } From phk at projects.linpro.no Wed Jun 11 20:50:55 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Wed, 11 Jun 2008 22:50:55 +0200 (CEST) Subject: r2662 - trunk/varnish-cache/bin/varnishd Message-ID: <20080611205055.B2EDB1EC118@projects.linpro.no> Author: phk Date: 2008-06-11 22:50:55 +0200 (Wed, 11 Jun 2008) New Revision: 2662 Modified: trunk/varnish-cache/bin/varnishd/cache_center.c Log: Be a little less hysteric with charging session statistics to srcaddr and global counters. Modified: trunk/varnish-cache/bin/varnishd/cache_center.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_center.c 2008-06-10 14:37:14 UTC (rev 2661) +++ trunk/varnish-cache/bin/varnishd/cache_center.c 2008-06-11 20:50:55 UTC (rev 2662) @@ -232,7 +232,6 @@ sp->xid, sp->t_req, sp->t_end, dh, dp, da); sp->xid = 0; - SES_Charge(sp); sp->t_open = sp->t_end; sp->t_resp = NAN; WSL_Flush(sp->wrk, 0); @@ -246,6 +245,7 @@ if (sp->fd >= 0 && sp->doclose != NULL) vca_close_session(sp, sp->doclose); if (sp->fd < 0) { + SES_Charge(sp); VSL_stats->sess_closed++; assert(!isnan(sp->wrk->used)); sp->wrk = NULL; @@ -268,6 +268,7 @@ return (0); } VSL_stats->sess_herd++; + SES_Charge(sp); assert(!isnan(sp->wrk->used)); sp->wrk = NULL; vca_return_session(sp); From phk at projects.linpro.no Wed Jun 11 21:12:26 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Wed, 11 Jun 2008 23:12:26 +0200 (CEST) Subject: r2663 - in trunk/varnish-cache: bin/varnishd include Message-ID: <20080611211226.951CF1EC40A@projects.linpro.no> Author: phk Date: 2008-06-11 23:12:26 +0200 (Wed, 11 Jun 2008) New Revision: 2663 Modified: trunk/varnish-cache/bin/varnishd/cache_center.c trunk/varnish-cache/bin/varnishd/heritage.h trunk/varnish-cache/bin/varnishd/mgt_param.c trunk/varnish-cache/include/stat_field.h Log: Add an optional shortcut: The parameter session_linger determines how many milliseconds the workerthread waits to see if another request has arrived, before handing the session over to the session herder. If we manage to catch the next request this way, we save a number of semi-expensive steps, if we hang around too long, the worker-thread gets to goof off. A relatively small sample of data from a live server, indicates that 20% of all requests arrive within 50 msec of the previous request and 50% within 100msec. It is not clear at present how these timeintervals relate to client RTT, or if they are systematically too high, due to the duration of the detour over the herder. There is a new line in varnishstat keeping track of how many times this gamble succeeds. Experimentation is encouraged. Modified: trunk/varnish-cache/bin/varnishd/cache_center.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_center.c 2008-06-11 20:50:55 UTC (rev 2662) +++ trunk/varnish-cache/bin/varnishd/cache_center.c 2008-06-11 21:12:26 UTC (rev 2663) @@ -61,6 +61,7 @@ #include #include #include +#include #include #include #include @@ -198,6 +199,7 @@ cnt_done(struct sess *sp) { double dh, dp, da; + struct pollfd pfd[1]; int i; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); @@ -267,6 +269,17 @@ sp->step = STP_AGAIN; return (0); } + if (params->session_linger > 0) { + pfd[0].fd = sp->fd; + pfd[0].events = POLLIN; + pfd[0].revents = 0; + i = poll(pfd, 1, params->session_linger); + if (i > 0) { + VSL_stats->sess_linger++; + sp->step = STP_AGAIN; + return (0); + } + } VSL_stats->sess_herd++; SES_Charge(sp); assert(!isnan(sp->wrk->used)); Modified: trunk/varnish-cache/bin/varnishd/heritage.h =================================================================== --- trunk/varnish-cache/bin/varnishd/heritage.h 2008-06-11 20:50:55 UTC (rev 2662) +++ trunk/varnish-cache/bin/varnishd/heritage.h 2008-06-11 21:12:26 UTC (rev 2663) @@ -148,6 +148,9 @@ /* Default connection_timeout */ unsigned connect_timeout; + /* How long to linger on sessions */ + unsigned session_linger; + /* CLI buffer size */ unsigned cli_buffer; Modified: trunk/varnish-cache/bin/varnishd/mgt_param.c =================================================================== --- trunk/varnish-cache/bin/varnishd/mgt_param.c 2008-06-11 20:50:55 UTC (rev 2662) +++ trunk/varnish-cache/bin/varnishd/mgt_param.c 2008-06-11 21:12:26 UTC (rev 2663) @@ -718,6 +718,18 @@ "VCL can override this default value for each backend.", 0, "400", "ms" }, + { "session_linger", tweak_uint, + &master.session_linger,0, UINT_MAX, + "How long time the workerthread lingers on the session " + "to see if a new request appears right away.\n" + "If sessions are reused, as much as half of all reuses " + "happen within the first 100 msec of the previous request " + "completing.\n" + "Setting this too high results in worker threads not doing " + "anything for their keep, setting it too low just means that " + "more sessions take a detour around the acceptor.", + EXPERIMENTAL, + "0", "ms" }, { "cli_buffer", tweak_uint, &master.cli_buffer, 4096, UINT_MAX, "Size of buffer for CLI input." "\nYou may need to increase this if you have big VCL files " Modified: trunk/varnish-cache/include/stat_field.h =================================================================== --- trunk/varnish-cache/include/stat_field.h 2008-06-11 20:50:55 UTC (rev 2662) +++ trunk/varnish-cache/include/stat_field.h 2008-06-11 21:12:26 UTC (rev 2663) @@ -85,6 +85,7 @@ MAC_STAT(sess_closed, uint64_t, 'a', "Session Closed") MAC_STAT(sess_pipeline, uint64_t, 'a', "Session Pipeline") MAC_STAT(sess_readahead, uint64_t, 'a', "Session Read Ahead") +MAC_STAT(sess_linger, uint64_t, 'a', "Session Linger") MAC_STAT(sess_herd, uint64_t, 'a', "Session herd") MAC_STAT(shm_records, uint64_t, 'a', "SHM records") From phk at projects.linpro.no Sat Jun 14 14:14:28 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Sat, 14 Jun 2008 16:14:28 +0200 (CEST) Subject: r2664 - trunk/varnish-cache/bin/varnishd Message-ID: <20080614141428.CBEF91EC114@projects.linpro.no> Author: phk Date: 2008-06-14 16:14:28 +0200 (Sat, 14 Jun 2008) New Revision: 2664 Modified: trunk/varnish-cache/bin/varnishd/cache_pool.c Log: Slightly change the criteria for starting new worker threads: Don't do it if the number of queued threads dropped since last inspection. Modified: trunk/varnish-cache/bin/varnishd/cache_pool.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_pool.c 2008-06-11 21:12:26 UTC (rev 2663) +++ trunk/varnish-cache/bin/varnishd/cache_pool.c 2008-06-14 14:14:28 UTC (rev 2664) @@ -82,6 +82,7 @@ VTAILQ_HEAD(, workreq) overflow; unsigned nthr; unsigned nqueue; + unsigned lqueue; uintmax_t ndrop; uintmax_t noverflow; }; @@ -494,8 +495,9 @@ * If we need more threads, and have space, create * one more thread. */ - if (qp->nqueue > params->wthread_add_threshold || - qp->nthr < nthr_min) { + if (qp->nthr < nthr_min || /* Not enough threads yet */ + (qp->nqueue > params->wthread_add_threshold && /* more needed */ + qp->nqueue > qp->lqueue)) { /* not getting better since last */ if (qp->nthr >= nthr_max) { VSL_stats->n_wrk_max++; } else if (pthread_create(&tp, NULL, wrk_thread, qp)) { @@ -509,6 +511,7 @@ (void)usleep(params->wthread_add_delay * 1000); } } + qp->lqueue = qp->nqueue; } /*-------------------------------------------------------------------- From phk at projects.linpro.no Sat Jun 14 14:27:00 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Sat, 14 Jun 2008 16:27:00 +0200 (CEST) Subject: r2665 - trunk/varnish-cache/bin/varnishd Message-ID: <20080614142700.34E661EC0F8@projects.linpro.no> Author: phk Date: 2008-06-14 16:26:59 +0200 (Sat, 14 Jun 2008) New Revision: 2665 Modified: trunk/varnish-cache/bin/varnishd/cache_hash.c trunk/varnish-cache/bin/varnishd/cache_session.c trunk/varnish-cache/bin/varnishd/cache_vrt.c trunk/varnish-cache/bin/varnishd/heritage.h trunk/varnish-cache/bin/varnishd/mgt_param.c Log: Change defaults: Make Grace mode the default with 10 seconds (param: default_grace) Make the thread idle timeout 300 seconds (param: thread_pool_timeout) Max one new thread per 20 msec (param: thread_pool_add_delay) Modified: trunk/varnish-cache/bin/varnishd/cache_hash.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_hash.c 2008-06-14 14:14:28 UTC (rev 2664) +++ trunk/varnish-cache/bin/varnishd/cache_hash.c 2008-06-14 14:26:59 UTC (rev 2665) @@ -56,6 +56,7 @@ #include #include +#include #include #include #include @@ -66,6 +67,14 @@ static struct hash_slinger *hash; +static double +HSH_Grace(double g) +{ + if (isnan(g)) + return (double)(params->default_grace); + return (g); +} + /* Precreate an objhead and object for later use */ void HSH_Prealloc(struct sess *sp) @@ -99,6 +108,7 @@ w->nobj->http->magic = HTTP_MAGIC; w->nobj->busy = 1; w->nobj->refcnt = 1; + w->nobj->grace = NAN; VTAILQ_INIT(&w->nobj->store); VTAILQ_INIT(&w->nobj->esibits); VSL_stats->n_object++; @@ -221,7 +231,7 @@ break; /* Remember any matching objects inside their grace period */ - if (o->ttl + o->grace >= sp->t_req) + if (o->ttl + HSH_Grace(o->grace) >= sp->t_req) grace_o = o; } @@ -231,7 +241,7 @@ */ if (o == NULL && grace_o != NULL && grace_o->child != NULL && - grace_o->ttl + sp->grace >= sp->t_req) + grace_o->ttl + HSH_Grace(sp->grace) >= sp->t_req) o = grace_o; if (o != NULL) { Modified: trunk/varnish-cache/bin/varnishd/cache_session.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_session.c 2008-06-14 14:14:28 UTC (rev 2664) +++ trunk/varnish-cache/bin/varnishd/cache_session.c 2008-06-14 14:26:59 UTC (rev 2665) @@ -304,6 +304,7 @@ sp->t_req = NAN; sp->t_resp = NAN; sp->t_end = NAN; + sp->grace = NAN; assert(len <= sp->sockaddrlen); if (addr != NULL) { Modified: trunk/varnish-cache/bin/varnishd/cache_vrt.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_vrt.c 2008-06-14 14:14:28 UTC (rev 2664) +++ trunk/varnish-cache/bin/varnishd/cache_vrt.c 2008-06-14 14:26:59 UTC (rev 2665) @@ -40,6 +40,7 @@ #include #include +#include #include #include #include @@ -326,6 +327,8 @@ { CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC); /* XXX */ + if (isnan(sp->obj->grace)) + return ((double)params->default_grace); return (sp->obj->grace); } @@ -446,6 +449,8 @@ VRT_r_req_grace(struct sess *sp) { CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + if (isnan(sp->grace)) + return ((double)params->default_grace); return (sp->grace); } Modified: trunk/varnish-cache/bin/varnishd/heritage.h =================================================================== --- trunk/varnish-cache/bin/varnishd/heritage.h 2008-06-14 14:14:28 UTC (rev 2664) +++ trunk/varnish-cache/bin/varnishd/heritage.h 2008-06-14 14:26:59 UTC (rev 2665) @@ -156,6 +156,9 @@ /* Control diagnostic code */ unsigned diag_bitmap; + + /* Default grace period */ + unsigned default_grace; }; extern volatile struct params *params; Modified: trunk/varnish-cache/bin/varnishd/mgt_param.c =================================================================== --- trunk/varnish-cache/bin/varnishd/mgt_param.c 2008-06-14 14:14:28 UTC (rev 2664) +++ trunk/varnish-cache/bin/varnishd/mgt_param.c 2008-06-14 14:26:59 UTC (rev 2665) @@ -503,7 +503,7 @@ "\n" "Minimum is 1 second.", EXPERIMENTAL | DELAYED_EFFECT, - "120", "seconds" }, + "300", "seconds" }, { "thread_pool_purge_delay", tweak_timeout, &master.wthread_purge_delay, 100, 0, "Wait this long between purging threads.\n" @@ -532,7 +532,7 @@ "Setting this too short increases the risk of worker " "thread pile-up.\n", EXPERIMENTAL, - "10", "milliseconds" }, + "20", "milliseconds" }, { "thread_pool_fail_delay", tweak_timeout, &master.wthread_fail_delay, 100, UINT_MAX, "Wait at least this long after a failed thread creation " @@ -581,6 +581,12 @@ "Minimum is 1024 bytes.", DELAYED_EFFECT, "8192", "bytes" }, + { "default_grace", tweak_uint, &master.default_grace, 0, UINT_MAX, + "Default grace period. We will deliver an object " + "this long after it has expired, provided another thread " + "is attempting to get a new copy.", + DELAYED_EFFECT, + "10" "seconds" }, { "sess_timeout", tweak_timeout, &master.sess_timeout, 0, 0, "Idle timeout for persistent sessions. " "If a HTTP request has not been received in this many " From phk at projects.linpro.no Sun Jun 15 09:50:13 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Sun, 15 Jun 2008 11:50:13 +0200 (CEST) Subject: r2666 - in trunk/varnish-cache/bin: . varnishtest Message-ID: <20080615095013.B92AB1EC40A@projects.linpro.no> Author: phk Date: 2008-06-15 11:50:13 +0200 (Sun, 15 Jun 2008) New Revision: 2666 Added: trunk/varnish-cache/bin/varnishtest/ trunk/varnish-cache/bin/varnishtest/Makefile trunk/varnish-cache/bin/varnishtest/t000.vtc trunk/varnish-cache/bin/varnishtest/vtc.c trunk/varnish-cache/bin/varnishtest/vtc.h trunk/varnish-cache/bin/varnishtest/vtc_server.c Log: Add Skelton "varnishtest" program. This is a test-driver which will be able to drive low-level tests of varnish functionalty. The present code manages to parse the example testcase description, more work to follow. XXX: needs to be auto*'ed, right now it uses FreeBSD makefile syntax. Added: trunk/varnish-cache/bin/varnishtest/Makefile =================================================================== --- trunk/varnish-cache/bin/varnishtest/Makefile (rev 0) +++ trunk/varnish-cache/bin/varnishtest/Makefile 2008-06-15 09:50:13 UTC (rev 2666) @@ -0,0 +1,15 @@ +PROG = vtc + +SRCS += vtc.c +SRCS += vtc_server.c + +CFLAGS += -g + +NO_MAN = sorry + +WARNS ?= 6 + +.include + +test: ${PROG} + ./${PROG} ${.CURDIR}/t000.vtc Added: trunk/varnish-cache/bin/varnishtest/t000.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/t000.vtc (rev 0) +++ trunk/varnish-cache/bin/varnishtest/t000.vtc 2008-06-15 09:50:13 UTC (rev 2666) @@ -0,0 +1,75 @@ +# Test that we get anything through at all +# + +server s1 -repeat 3 { + rxreq + expect url == "/" + txresponse -body "0123456789" +} + +server s1 -start + +client c1 { + txreq -url "/" + rxresponse + expect status == 200 + expect length == 10 +} + + +####################################################################### +# Test trivial pipe mode + +vcl { + $s1; + sub vcl_recv { + set req.backend = s1; + pipe; + } +} + +client c1 -run + +####################################################################### +# Test trivial pass mode + +vcl { + $s1; + sub vcl_recv { + set req.backend = s1; + pass; + } +} + +client c1 -run + +####################################################################### +# Test trivial cache mode + +vcl { + $s1; + sub vcl_recv { + set req.backend = s1; + } +} + +client c1 -run + +server s1 -wait + +####################################################################### +# And see that it stuck in cache + +client c1 -run + +varnish stop + +stats { + expect client_conn == 4 + expect client_req == 4 + expect cache_hit == 1 + expect cache_miss == 1 + expect s_pipe == 1 + expect s_pass == 1 + expect s_fetch == 2 +} Added: trunk/varnish-cache/bin/varnishtest/vtc.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc.c (rev 0) +++ trunk/varnish-cache/bin/varnishtest/vtc.c 2008-06-15 09:50:13 UTC (rev 2666) @@ -0,0 +1,170 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +#include "vtc.h" + +#define MAX_FILESIZE (1024 * 1024) +#define MAX_TOKENS 20 + +/********************************************************************** + * Read a file into memory + */ + +static char * +read_file(const char *fn) +{ + char *buf; + ssize_t sz = MAX_FILESIZE; + ssize_t s; + int fd; + + fd = open(fn, O_RDONLY); + if (fd < 0) + err(1, "Cannot open %s", fn); + buf = malloc(sz); + assert(buf != NULL); + s = read(fd, buf, sz); + if (s <= 0) + err(1, "Cannot read %s", fn); + assert(s < sz); /* XXX: increase MAX_FILESIZE */ + close (fd); + buf[s] = '\0'; + buf = realloc(buf, s + 1); + assert(buf != NULL); + return (buf); +} + +/********************************************************************** + * Execute a file + */ + +void +parse_string(char *buf, const struct cmds *cmd, void *priv) +{ + char *token_s[MAX_TOKENS], *token_e[MAX_TOKENS]; + char *p; + int nest_brace; + int tn; + const struct cmds *cp; + + assert(buf != NULL); + for (p = buf; *p != '\0'; p++) { + /* Start of line */ + if (isspace(*p)) + continue; + if (*p == '#') { + for (; *p != '\0' && *p != '\n'; p++) + ; + if (*p == '\0') + break; + continue; + } + + /* First content on line, collect tokens */ + tn = 0; + while (*p != '\0') { + assert(tn < MAX_TOKENS); + if (*p == '\n') { /* End on NL */ + break; + } else if (isspace(*p)) { /* Inter-token whitespace */ + p++; + } else if (*p == '{') { /* Braces */ + nest_brace = 0; + token_s[tn] = p + 1; + for (; *p != '\0'; p++) { + if (*p == '{') + nest_brace++; + else if (*p == '}') { + if (--nest_brace == 0) + break; + } + } + assert(*p == '}'); + token_e[tn++] = p; + p++; /* Swallow closing brace */ + } else { /* other tokens */ + token_s[tn] = p; + for (; *p != '\0' && !isspace(*p); p++) + ; + token_e[tn++] = p; + } + } + assert(tn < MAX_TOKENS); + token_s[tn] = NULL; + for (tn = 0; token_s[tn] != NULL; tn++) + *token_e[tn] = '\0'; + + for (cp = cmd; cp->name != NULL; cp++) + if (!strcmp(token_s[0], cp->name)) + break; + if (cp->name == NULL) { + for (tn = 0; token_s[tn] != NULL; tn++) + fprintf(stderr, "%s ", token_s[tn]); + fprintf(stderr, "\n"); + errx(1, "Unknown command: \"%s\"", token_s[0]); + } + + assert(cp->cmd != NULL); + cp->cmd(token_s, priv); + } +} + +/********************************************************************** + * Execute a file + */ + +static void +cmd_bogo(char **av, void *priv) +{ + printf("cmd_bogo(%p)\n", priv); + while (*av) + printf("\t<%s>\n", *av++); +} + +static struct cmds cmds[] = { + { "server", cmd_server }, + { "client", cmd_bogo }, + { "vcl", cmd_bogo }, + { "stats", cmd_bogo }, + { "varnish", cmd_bogo }, + { NULL, NULL } +}; + +static void +exec_file(const char *fn) +{ + char *buf; + + buf = read_file(fn); + parse_string(buf, cmds, NULL); +} + +/********************************************************************** + * Main + */ + +int +main(int argc, char **argv) +{ + int ch; + + setbuf(stdout, NULL); + while ((ch = getopt(argc, argv, "")) != -1) { + switch (ch) { + case '?': + default: + errx(1, "Usage"); + } + } + argc -= optind; + argv += optind; + for (ch = 0; ch < argc; ch++) + exec_file(argv[ch]); + return (0); +} Added: trunk/varnish-cache/bin/varnishtest/vtc.h =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc.h (rev 0) +++ trunk/varnish-cache/bin/varnishtest/vtc.h 2008-06-15 09:50:13 UTC (rev 2666) @@ -0,0 +1,15 @@ + + + +typedef void cmd_f(char **av, void *priv); + +struct cmds { + const char *name; + cmd_f *cmd; +}; + +void parse_string(char *buf, const struct cmds *cmd, void *priv); + +/* vtc_server.c */ +void cmd_server(char **av, void *priv); + Added: trunk/varnish-cache/bin/varnishtest/vtc_server.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_server.c (rev 0) +++ trunk/varnish-cache/bin/varnishtest/vtc_server.c 2008-06-15 09:50:13 UTC (rev 2666) @@ -0,0 +1,13 @@ + +#include + +#include "vtc.h" + +void +cmd_server(char **av, void *priv) +{ + + printf("cmd_server(%p)\n", priv); + while (*av) + printf("\t<%s>\n", *av++); +} From phk at projects.linpro.no Sun Jun 15 09:57:28 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Sun, 15 Jun 2008 11:57:28 +0200 (CEST) Subject: r2667 - trunk/varnish-cache/bin/varnishtest Message-ID: <20080615095728.772A91ED0A4@projects.linpro.no> Author: phk Date: 2008-06-15 11:57:28 +0200 (Sun, 15 Jun 2008) New Revision: 2667 Added: trunk/varnish-cache/bin/varnishtest/vtc_client.c trunk/varnish-cache/bin/varnishtest/vtc_stats.c trunk/varnish-cache/bin/varnishtest/vtc_varnish.c trunk/varnish-cache/bin/varnishtest/vtc_vcl.c Modified: trunk/varnish-cache/bin/varnishtest/Makefile trunk/varnish-cache/bin/varnishtest/vtc.c trunk/varnish-cache/bin/varnishtest/vtc.h trunk/varnish-cache/bin/varnishtest/vtc_server.c Log: Hash out more files and cmd functions Modified: trunk/varnish-cache/bin/varnishtest/Makefile =================================================================== --- trunk/varnish-cache/bin/varnishtest/Makefile 2008-06-15 09:50:13 UTC (rev 2666) +++ trunk/varnish-cache/bin/varnishtest/Makefile 2008-06-15 09:57:28 UTC (rev 2667) @@ -2,6 +2,10 @@ SRCS += vtc.c SRCS += vtc_server.c +SRCS += vtc_client.c +SRCS += vtc_vcl.c +SRCS += vtc_stats.c +SRCS += vtc_varnish.c CFLAGS += -g Modified: trunk/varnish-cache/bin/varnishtest/vtc.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc.c 2008-06-15 09:50:13 UTC (rev 2666) +++ trunk/varnish-cache/bin/varnishtest/vtc.c 2008-06-15 09:57:28 UTC (rev 2667) @@ -76,7 +76,7 @@ p++; } else if (*p == '{') { /* Braces */ nest_brace = 0; - token_s[tn] = p + 1; + token_s[tn] = p; for (; *p != '\0'; p++) { if (*p == '{') nest_brace++; @@ -86,8 +86,7 @@ } } assert(*p == '}'); - token_e[tn++] = p; - p++; /* Swallow closing brace */ + token_e[tn++] = ++p; } else { /* other tokens */ token_s[tn] = p; for (; *p != '\0' && !isspace(*p); p++) @@ -119,20 +118,21 @@ * Execute a file */ -static void -cmd_bogo(char **av, void *priv) +void +cmd_dump(char **av, void *priv) { - printf("cmd_bogo(%p)\n", priv); + + printf("cmd_dump(%p)\n", priv); while (*av) printf("\t<%s>\n", *av++); } static struct cmds cmds[] = { { "server", cmd_server }, - { "client", cmd_bogo }, - { "vcl", cmd_bogo }, - { "stats", cmd_bogo }, - { "varnish", cmd_bogo }, + { "client", cmd_client }, + { "vcl", cmd_vcl }, + { "stats", cmd_stats }, + { "varnish", cmd_varnish }, { NULL, NULL } }; Modified: trunk/varnish-cache/bin/varnishtest/vtc.h =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc.h 2008-06-15 09:50:13 UTC (rev 2666) +++ trunk/varnish-cache/bin/varnishtest/vtc.h 2008-06-15 09:57:28 UTC (rev 2667) @@ -10,6 +10,10 @@ void parse_string(char *buf, const struct cmds *cmd, void *priv); -/* vtc_server.c */ +void cmd_dump(char **av, void *priv); void cmd_server(char **av, void *priv); +void cmd_client(char **av, void *priv); +void cmd_vcl(char **av, void *priv); +void cmd_stats(char **av, void *priv); +void cmd_varnish(char **av, void *priv); Added: trunk/varnish-cache/bin/varnishtest/vtc_client.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_client.c (rev 0) +++ trunk/varnish-cache/bin/varnishtest/vtc_client.c 2008-06-15 09:57:28 UTC (rev 2667) @@ -0,0 +1,11 @@ + +#include + +#include "vtc.h" + +void +cmd_client(char **av, void *priv) +{ + + cmd_dump(av, priv); +} Modified: trunk/varnish-cache/bin/varnishtest/vtc_server.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_server.c 2008-06-15 09:50:13 UTC (rev 2666) +++ trunk/varnish-cache/bin/varnishtest/vtc_server.c 2008-06-15 09:57:28 UTC (rev 2667) @@ -7,7 +7,5 @@ cmd_server(char **av, void *priv) { - printf("cmd_server(%p)\n", priv); - while (*av) - printf("\t<%s>\n", *av++); + cmd_dump(av, priv); } Added: trunk/varnish-cache/bin/varnishtest/vtc_stats.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_stats.c (rev 0) +++ trunk/varnish-cache/bin/varnishtest/vtc_stats.c 2008-06-15 09:57:28 UTC (rev 2667) @@ -0,0 +1,11 @@ + +#include + +#include "vtc.h" + +void +cmd_stats(char **av, void *priv) +{ + + cmd_dump(av, priv); +} Added: trunk/varnish-cache/bin/varnishtest/vtc_varnish.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_varnish.c (rev 0) +++ trunk/varnish-cache/bin/varnishtest/vtc_varnish.c 2008-06-15 09:57:28 UTC (rev 2667) @@ -0,0 +1,11 @@ + +#include + +#include "vtc.h" + +void +cmd_varnish(char **av, void *priv) +{ + + cmd_dump(av, priv); +} Added: trunk/varnish-cache/bin/varnishtest/vtc_vcl.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_vcl.c (rev 0) +++ trunk/varnish-cache/bin/varnishtest/vtc_vcl.c 2008-06-15 09:57:28 UTC (rev 2667) @@ -0,0 +1,11 @@ + +#include + +#include "vtc.h" + +void +cmd_vcl(char **av, void *priv) +{ + + cmd_dump(av, priv); +} From phk at projects.linpro.no Sun Jun 15 10:00:33 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Sun, 15 Jun 2008 12:00:33 +0200 (CEST) Subject: r2668 - trunk/varnish-cache/bin/varnishtest Message-ID: <20080615100033.B85F51EC40A@projects.linpro.no> Author: phk Date: 2008-06-15 12:00:33 +0200 (Sun, 15 Jun 2008) New Revision: 2668 Modified: trunk/varnish-cache/bin/varnishtest/vtc.c trunk/varnish-cache/bin/varnishtest/vtc.h trunk/varnish-cache/bin/varnishtest/vtc_client.c trunk/varnish-cache/bin/varnishtest/vtc_server.c trunk/varnish-cache/bin/varnishtest/vtc_stats.c trunk/varnish-cache/bin/varnishtest/vtc_varnish.c trunk/varnish-cache/bin/varnishtest/vtc_vcl.c Log: Add LICENSE Modified: trunk/varnish-cache/bin/varnishtest/vtc.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc.c 2008-06-15 09:57:28 UTC (rev 2667) +++ trunk/varnish-cache/bin/varnishtest/vtc.c 2008-06-15 10:00:33 UTC (rev 2668) @@ -1,3 +1,29 @@ +/* + * Copyright (c) 2006-2008 Linpro AS + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + #include #include #include Modified: trunk/varnish-cache/bin/varnishtest/vtc.h =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc.h 2008-06-15 09:57:28 UTC (rev 2667) +++ trunk/varnish-cache/bin/varnishtest/vtc.h 2008-06-15 10:00:33 UTC (rev 2668) @@ -1,6 +1,32 @@ +/* + * Copyright (c) 2006-2008 Linpro AS + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + typedef void cmd_f(char **av, void *priv); struct cmds { Modified: trunk/varnish-cache/bin/varnishtest/vtc_client.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_client.c 2008-06-15 09:57:28 UTC (rev 2667) +++ trunk/varnish-cache/bin/varnishtest/vtc_client.c 2008-06-15 10:00:33 UTC (rev 2668) @@ -1,3 +1,28 @@ +/* + * Copyright (c) 2006-2008 Linpro AS + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ #include Modified: trunk/varnish-cache/bin/varnishtest/vtc_server.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_server.c 2008-06-15 09:57:28 UTC (rev 2667) +++ trunk/varnish-cache/bin/varnishtest/vtc_server.c 2008-06-15 10:00:33 UTC (rev 2668) @@ -1,4 +1,30 @@ +/* + * Copyright (c) 2006-2008 Linpro AS + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + #include #include "vtc.h" Modified: trunk/varnish-cache/bin/varnishtest/vtc_stats.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_stats.c 2008-06-15 09:57:28 UTC (rev 2667) +++ trunk/varnish-cache/bin/varnishtest/vtc_stats.c 2008-06-15 10:00:33 UTC (rev 2668) @@ -1,4 +1,30 @@ +/* + * Copyright (c) 2006-2008 Linpro AS + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + #include #include "vtc.h" Modified: trunk/varnish-cache/bin/varnishtest/vtc_varnish.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_varnish.c 2008-06-15 09:57:28 UTC (rev 2667) +++ trunk/varnish-cache/bin/varnishtest/vtc_varnish.c 2008-06-15 10:00:33 UTC (rev 2668) @@ -1,4 +1,30 @@ +/* + * Copyright (c) 2006-2008 Linpro AS + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + #include #include "vtc.h" Modified: trunk/varnish-cache/bin/varnishtest/vtc_vcl.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_vcl.c 2008-06-15 09:57:28 UTC (rev 2667) +++ trunk/varnish-cache/bin/varnishtest/vtc_vcl.c 2008-06-15 10:00:33 UTC (rev 2668) @@ -1,4 +1,30 @@ +/* + * Copyright (c) 2006-2008 Linpro AS + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + #include #include "vtc.h" From phk at projects.linpro.no Sun Jun 15 10:49:12 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Sun, 15 Jun 2008 12:49:12 +0200 (CEST) Subject: r2669 - trunk/varnish-cache/bin/varnishtest Message-ID: <20080615104912.14F4D1EC118@projects.linpro.no> Author: phk Date: 2008-06-15 12:49:11 +0200 (Sun, 15 Jun 2008) New Revision: 2669 Removed: trunk/varnish-cache/bin/varnishtest/Makefile Log: Remove BSD style makefile Deleted: trunk/varnish-cache/bin/varnishtest/Makefile =================================================================== --- trunk/varnish-cache/bin/varnishtest/Makefile 2008-06-15 10:00:33 UTC (rev 2668) +++ trunk/varnish-cache/bin/varnishtest/Makefile 2008-06-15 10:49:11 UTC (rev 2669) @@ -1,19 +0,0 @@ -PROG = vtc - -SRCS += vtc.c -SRCS += vtc_server.c -SRCS += vtc_client.c -SRCS += vtc_vcl.c -SRCS += vtc_stats.c -SRCS += vtc_varnish.c - -CFLAGS += -g - -NO_MAN = sorry - -WARNS ?= 6 - -.include - -test: ${PROG} - ./${PROG} ${.CURDIR}/t000.vtc From phk at projects.linpro.no Sun Jun 15 10:50:15 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Sun, 15 Jun 2008 12:50:15 +0200 (CEST) Subject: r2670 - in trunk/varnish-cache: . bin bin/varnishtest Message-ID: <20080615105015.A95291EC40A@projects.linpro.no> Author: phk Date: 2008-06-15 12:50:15 +0200 (Sun, 15 Jun 2008) New Revision: 2670 Added: trunk/varnish-cache/bin/varnishtest/Makefile.am Modified: trunk/varnish-cache/bin/Makefile.am trunk/varnish-cache/configure.ac Log: put varnishtest under auto* control Modified: trunk/varnish-cache/bin/Makefile.am =================================================================== --- trunk/varnish-cache/bin/Makefile.am 2008-06-15 10:49:11 UTC (rev 2669) +++ trunk/varnish-cache/bin/Makefile.am 2008-06-15 10:50:15 UTC (rev 2670) @@ -3,5 +3,5 @@ SUBDIRS = varnishadm varnishd varnishlog varnishncsa varnishreplay if HAVE_CURSES -SUBDIRS += varnishhist varnishstat varnishtop +SUBDIRS += varnishhist varnishstat varnishtop varnishtest endif Added: trunk/varnish-cache/bin/varnishtest/Makefile.am =================================================================== --- trunk/varnish-cache/bin/varnishtest/Makefile.am (rev 0) +++ trunk/varnish-cache/bin/varnishtest/Makefile.am 2008-06-15 10:50:15 UTC (rev 2670) @@ -0,0 +1,17 @@ +# $Id$ + +INCLUDES = -I$(top_srcdir)/include + +bin_PROGRAMS = varnishtest + +varnishtest_SOURCES = \ + vtc.c \ + vtc_client.c \ + vtc_server.c \ + vtc_stats.c \ + vtc_varnish.c \ + vtc_vcl.c + +varnishtest_LDADD = \ + $(top_builddir)/lib/libvarnish/libvarnish.la \ + $(top_builddir)/lib/libvarnishcompat/libvarnishcompat.la Modified: trunk/varnish-cache/configure.ac =================================================================== --- trunk/varnish-cache/configure.ac 2008-06-15 10:49:11 UTC (rev 2669) +++ trunk/varnish-cache/configure.ac 2008-06-15 10:50:15 UTC (rev 2670) @@ -315,6 +315,7 @@ bin/varnishncsa/Makefile bin/varnishreplay/Makefile bin/varnishstat/Makefile + bin/varnishtest/Makefile bin/varnishtop/Makefile doc/Makefile etc/Makefile From phk at projects.linpro.no Sun Jun 15 11:17:45 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Sun, 15 Jun 2008 13:17:45 +0200 (CEST) Subject: r2671 - trunk/varnish-cache/bin/varnishtest Message-ID: <20080615111745.A8D471ED230@projects.linpro.no> Author: phk Date: 2008-06-15 13:17:45 +0200 (Sun, 15 Jun 2008) New Revision: 2671 Modified: trunk/varnish-cache/bin/varnishtest/Makefile.am trunk/varnish-cache/bin/varnishtest/vtc.h trunk/varnish-cache/bin/varnishtest/vtc_server.c Log: Server socket & thread creation Modified: trunk/varnish-cache/bin/varnishtest/Makefile.am =================================================================== --- trunk/varnish-cache/bin/varnishtest/Makefile.am 2008-06-15 10:50:15 UTC (rev 2670) +++ trunk/varnish-cache/bin/varnishtest/Makefile.am 2008-06-15 11:17:45 UTC (rev 2671) @@ -14,4 +14,5 @@ varnishtest_LDADD = \ $(top_builddir)/lib/libvarnish/libvarnish.la \ - $(top_builddir)/lib/libvarnishcompat/libvarnishcompat.la + $(top_builddir)/lib/libvarnishcompat/libvarnishcompat.la \ + ${PTHREAD_LIBS} Modified: trunk/varnish-cache/bin/varnishtest/vtc.h =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc.h 2008-06-15 10:50:15 UTC (rev 2670) +++ trunk/varnish-cache/bin/varnishtest/vtc.h 2008-06-15 11:17:45 UTC (rev 2671) @@ -24,9 +24,6 @@ * SUCH DAMAGE. */ - - - typedef void cmd_f(char **av, void *priv); struct cmds { Modified: trunk/varnish-cache/bin/varnishtest/vtc_server.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_server.c 2008-06-15 10:50:15 UTC (rev 2670) +++ trunk/varnish-cache/bin/varnishtest/vtc_server.c 2008-06-15 11:17:45 UTC (rev 2671) @@ -26,12 +26,163 @@ #include +#include +#include +#include +#include #include "vtc.h" +#include "vqueue.h" +#include "miniobj.h" +#include "vss.h" +#include "libvarnish.h" + +struct server { + unsigned magic; +#define SERVER_MAGIC 0x55286619 + char *name; + VTAILQ_ENTRY(server) list; + + unsigned repeat; + char *spec; + + int depth; + int sock; + const char *listen; + struct vss_addr **vss_addr; + char *addr; + char *port; + + pthread_t tp; +}; + +static VTAILQ_HEAD(, server) servers = + VTAILQ_HEAD_INITIALIZER(servers); + +/********************************************************************** + * Server thread + */ + +static void * +server_thread(void *priv) +{ + struct server *s; + + CAST_OBJ_NOTNULL(s, priv, SERVER_MAGIC); + + printf("### Server %s started\n", s->name); + sleep(3); + printf("### Server %s ending\n", s->name); + + return (NULL); +} + +/********************************************************************** + * Allocate and initialize a server + */ + +static struct server * +server_new(char *name) +{ + struct server *s; + + ALLOC_OBJ(s, SERVER_MAGIC); + s->name = name; + s->listen = ":9080"; + s->depth = 1; + s->sock = -1; + VTAILQ_INSERT_TAIL(&servers, s, list); + return (s); +} + +/********************************************************************** + * Start the server thread + */ + +static void +server_start(struct server *s) +{ + int naddr; + + CHECK_OBJ_NOTNULL(s, SERVER_MAGIC); + printf("Starting server %s\n", s->name); + if (s->sock < 0) { + AZ(VSS_parse(s->listen, &s->addr, &s->port)); + naddr = VSS_resolve(s->addr, s->port, &s->vss_addr); + if (naddr != 1) { + fprintf(stderr, + "Server %s listen address not unique\n" + " \"%s\" resolves to (%d) sockets\n", + s->name, s->listen, naddr); + exit (1); + } + s->sock = VSS_listen(s->vss_addr[0], s->depth); + assert(s->sock >= 0); + } + printf("\tsocket fd is %d\n", s->sock); + AZ(pthread_create(&s->tp, NULL, server_thread, s)); +} + +/********************************************************************** + * Wait for server thread to stop + */ + +static void +server_wait(struct server *s) +{ + void *res; + + CHECK_OBJ_NOTNULL(s, SERVER_MAGIC); + printf("Waiting for server %s\n", s->name); + AZ(pthread_join(s->tp, &res)); + if (res != NULL) { + fprintf(stderr, "Server %s returned \"%s\"\n", + s->name, (char *)res); + exit (1); + } + s->tp = NULL; +} + +/********************************************************************** + * Server command dispatch + */ + void cmd_server(char **av, void *priv) { + struct server *s; - cmd_dump(av, priv); + (void)priv; + assert(!strcmp(av[0], "server")); + av++; + + VTAILQ_FOREACH(s, &servers, list) + if (!strcmp(s->name, av[0])) + break; + if (s == NULL) + s = server_new(av[0]); + av++; + + for (; *av != NULL; av++) { + if (!strcmp(*av, "-repeat")) { + s->repeat = atoi(av[1]); + av++; + continue; + } + if (!strcmp(*av, "-start")) { + server_start(s); + continue; + } + if (!strcmp(*av, "-wait")) { + server_wait(s); + continue; + } + if (**av == '{') { + s->spec = *av; + continue; + } + fprintf(stderr, "Unknown server argument: %s\n", *av); + exit (1); + } } From phk at projects.linpro.no Sun Jun 15 11:22:55 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Sun, 15 Jun 2008 13:22:55 +0200 (CEST) Subject: r2672 - trunk/varnish-cache/bin/varnishtest Message-ID: <20080615112255.922D91EC40A@projects.linpro.no> Author: phk Date: 2008-06-15 13:22:55 +0200 (Sun, 15 Jun 2008) New Revision: 2672 Added: trunk/varnish-cache/bin/varnishtest/t001.vtc Modified: trunk/varnish-cache/bin/varnishtest/t000.vtc trunk/varnish-cache/bin/varnishtest/vtc_server.c Log: Make the first testcase a test of the testprogram Modified: trunk/varnish-cache/bin/varnishtest/t000.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/t000.vtc 2008-06-15 11:17:45 UTC (rev 2671) +++ trunk/varnish-cache/bin/varnishtest/t000.vtc 2008-06-15 11:22:55 UTC (rev 2672) @@ -1,7 +1,7 @@ -# Test that we get anything through at all +# Quis custodiet ipsos custodes? # -server s1 -repeat 3 { +server s1 -listen :9080 { rxreq expect url == "/" txresponse -body "0123456789" @@ -9,67 +9,13 @@ server s1 -start -client c1 { +client c1 -connect localhost:9080 { txreq -url "/" rxresponse expect status == 200 expect length == 10 } - -####################################################################### -# Test trivial pipe mode - -vcl { - $s1; - sub vcl_recv { - set req.backend = s1; - pipe; - } -} - client c1 -run -####################################################################### -# Test trivial pass mode - -vcl { - $s1; - sub vcl_recv { - set req.backend = s1; - pass; - } -} - -client c1 -run - -####################################################################### -# Test trivial cache mode - -vcl { - $s1; - sub vcl_recv { - set req.backend = s1; - } -} - -client c1 -run - server s1 -wait - -####################################################################### -# And see that it stuck in cache - -client c1 -run - -varnish stop - -stats { - expect client_conn == 4 - expect client_req == 4 - expect cache_hit == 1 - expect cache_miss == 1 - expect s_pipe == 1 - expect s_pass == 1 - expect s_fetch == 2 -} Added: trunk/varnish-cache/bin/varnishtest/t001.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/t001.vtc (rev 0) +++ trunk/varnish-cache/bin/varnishtest/t001.vtc 2008-06-15 11:22:55 UTC (rev 2672) @@ -0,0 +1,75 @@ +# Test that we get anything through at all +# + +server s1 -repeat 3 { + rxreq + expect url == "/" + txresponse -body "0123456789" +} + +server s1 -start + +client c1 { + txreq -url "/" + rxresponse + expect status == 200 + expect length == 10 +} + + +####################################################################### +# Test trivial pipe mode + +vcl { + $s1; + sub vcl_recv { + set req.backend = s1; + pipe; + } +} + +client c1 -run + +####################################################################### +# Test trivial pass mode + +vcl { + $s1; + sub vcl_recv { + set req.backend = s1; + pass; + } +} + +client c1 -run + +####################################################################### +# Test trivial cache mode + +vcl { + $s1; + sub vcl_recv { + set req.backend = s1; + } +} + +client c1 -run + +server s1 -wait + +####################################################################### +# And see that it stuck in cache + +client c1 -run + +varnish stop + +stats { + expect client_conn == 4 + expect client_req == 4 + expect cache_hit == 1 + expect cache_miss == 1 + expect s_pipe == 1 + expect s_pass == 1 + expect s_fetch == 2 +} Modified: trunk/varnish-cache/bin/varnishtest/vtc_server.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_server.c 2008-06-15 11:17:45 UTC (rev 2671) +++ trunk/varnish-cache/bin/varnishtest/vtc_server.c 2008-06-15 11:22:55 UTC (rev 2672) @@ -170,6 +170,11 @@ av++; continue; } + if (!strcmp(*av, "-listen")) { + s->listen = av[1]; + av++; + continue; + } if (!strcmp(*av, "-start")) { server_start(s); continue; From phk at projects.linpro.no Sun Jun 15 11:30:13 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Sun, 15 Jun 2008 13:30:13 +0200 (CEST) Subject: r2673 - trunk/varnish-cache/bin/varnishtest Message-ID: <20080615113013.E98181ED230@projects.linpro.no> Author: phk Date: 2008-06-15 13:30:13 +0200 (Sun, 15 Jun 2008) New Revision: 2673 Modified: trunk/varnish-cache/bin/varnishtest/t000.vtc trunk/varnish-cache/bin/varnishtest/vtc_server.c Log: Default server to repeat=1. Accept connections, and close them right away. Modified: trunk/varnish-cache/bin/varnishtest/t000.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/t000.vtc 2008-06-15 11:22:55 UTC (rev 2672) +++ trunk/varnish-cache/bin/varnishtest/t000.vtc 2008-06-15 11:30:13 UTC (rev 2673) @@ -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 -run +client c1 -run + server s1 -wait Modified: trunk/varnish-cache/bin/varnishtest/vtc_server.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_server.c 2008-06-15 11:22:55 UTC (rev 2672) +++ trunk/varnish-cache/bin/varnishtest/vtc_server.c 2008-06-15 11:30:13 UTC (rev 2673) @@ -31,6 +31,9 @@ #include #include +#include +#include + #include "vtc.h" #include "vqueue.h" @@ -68,11 +71,25 @@ 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 @@ 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); From phk at projects.linpro.no Sun Jun 15 11:47:02 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Sun, 15 Jun 2008 13:47:02 +0200 (CEST) Subject: r2674 - trunk/varnish-cache/bin/varnishtest Message-ID: <20080615114702.2E0E41EC40A@projects.linpro.no> Author: phk Date: 2008-06-15 13:47:01 +0200 (Sun, 15 Jun 2008) New Revision: 2674 Modified: trunk/varnish-cache/bin/varnishtest/vtc_client.c trunk/varnish-cache/bin/varnishtest/vtc_server.c Log: Hash out the client, up to and including connection to the server. Modified: trunk/varnish-cache/bin/varnishtest/vtc_client.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_client.c 2008-06-15 11:30:13 UTC (rev 2673) +++ trunk/varnish-cache/bin/varnishtest/vtc_client.c 2008-06-15 11:47:01 UTC (rev 2674) @@ -25,12 +25,172 @@ */ #include +#include +#include +#include +#include +#include +#include + #include "vtc.h" +#include "vqueue.h" +#include "miniobj.h" +#include "vss.h" +#include "libvarnish.h" + +struct client { + unsigned magic; +#define CLIENT_MAGIC 0x6242397c + char *name; + VTAILQ_ENTRY(client) list; + + char *spec; + + const char *connect; + int naddr; + struct vss_addr **vss_addr; + char *addr; + char *port; + + pthread_t tp; +}; + +static VTAILQ_HEAD(, client) clients = + VTAILQ_HEAD_INITIALIZER(clients); + +/********************************************************************** + * Server thread + */ + +static void * +client_thread(void *priv) +{ + struct client *c; + int i; + int fd; + + CAST_OBJ_NOTNULL(c, priv, CLIENT_MAGIC); + assert(c->naddr > 0); + + printf("### Client %s started\n", c->name); + printf("#### Client %s connect to %s\n", c->name, c->connect); + for (i = 0; i < c->naddr; i++) { + fd = VSS_connect(c->vss_addr[i]); + if (fd >= 0) + break; + } + assert(fd >= 0); + printf("#### Client %s connected to %s fd is %d\n", + c->name, c->connect, fd); + sleep (1); + close(fd); + printf("### Client %s ending\n", c->name); + + return (NULL); +} + +/********************************************************************** + * Allocate and initialize a client + */ + +static struct client * +client_new(char *name) +{ + struct client *c; + + ALLOC_OBJ(c, CLIENT_MAGIC); + c->name = name; + c->connect = ":8080"; + VTAILQ_INSERT_TAIL(&clients, c, list); + return (c); +} + +/********************************************************************** + * Start the client thread + */ + +static void +client_start(struct client *c) +{ + + CHECK_OBJ_NOTNULL(c, CLIENT_MAGIC); + printf("Starting client %s\n", c->name); + AZ(pthread_create(&c->tp, NULL, client_thread, c)); +} + +/********************************************************************** + * Wait for client thread to stop + */ + +static void +client_wait(struct client *c) +{ + void *res; + + CHECK_OBJ_NOTNULL(c, CLIENT_MAGIC); + printf("Waiting for client %s\n", c->name); + AZ(pthread_join(c->tp, &res)); + if (res != NULL) { + fprintf(stderr, "Server %s returned \"%s\"\n", + c->name, (char *)res); + exit (1); + } + c->tp = NULL; +} + +/********************************************************************** + * Run the client thread + */ + +static void +client_run(struct client *c) +{ + + client_start(c); + client_wait(c); +} + + +/********************************************************************** + * Server command dispatch + */ + void cmd_client(char **av, void *priv) { + struct client *c; - cmd_dump(av, priv); + (void)priv; + assert(!strcmp(av[0], "client")); + av++; + + VTAILQ_FOREACH(c, &clients, list) + if (!strcmp(c->name, av[0])) + break; + if (c == NULL) + c = client_new(av[0]); + av++; + + for (; *av != NULL; av++) { + if (!strcmp(*av, "-connect")) { + c->connect = av[1]; + av++; + AZ(VSS_parse(c->connect, &c->addr, &c->port)); + c->naddr = VSS_resolve(c->addr, c->port, &c->vss_addr); + assert(c->naddr > 0); + continue; + } + if (!strcmp(*av, "-run")) { + client_run(c); + continue; + } + if (**av == '{') { + c->spec = *av; + continue; + } + fprintf(stderr, "Unknown client argument: %s\n", *av); + exit (1); + } } Modified: trunk/varnish-cache/bin/varnishtest/vtc_server.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_server.c 2008-06-15 11:30:13 UTC (rev 2673) +++ trunk/varnish-cache/bin/varnishtest/vtc_server.c 2008-06-15 11:47:01 UTC (rev 2674) @@ -138,7 +138,8 @@ s->sock = VSS_listen(s->vss_addr[0], s->depth); assert(s->sock >= 0); } - printf("\tsocket fd is %d\n", s->sock); + printf("#### Server %s listen on %s (fd %d)\n", + s->name, s->listen, s->sock); AZ(pthread_create(&s->tp, NULL, server_thread, s)); } From phk at projects.linpro.no Sun Jun 15 12:08:12 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Sun, 15 Jun 2008 14:08:12 +0200 (CEST) Subject: r2675 - trunk/varnish-cache/bin/varnishtest Message-ID: <20080615120812.0CEC31EC40A@projects.linpro.no> Author: phk Date: 2008-06-15 14:08:11 +0200 (Sun, 15 Jun 2008) New Revision: 2675 Added: trunk/varnish-cache/bin/varnishtest/vtc_http.c Modified: trunk/varnish-cache/bin/varnishtest/Makefile.am trunk/varnish-cache/bin/varnishtest/t000.vtc trunk/varnish-cache/bin/varnishtest/vtc.h trunk/varnish-cache/bin/varnishtest/vtc_client.c trunk/varnish-cache/bin/varnishtest/vtc_server.c Log: Add the HTTP subprocessor Modified: trunk/varnish-cache/bin/varnishtest/Makefile.am =================================================================== --- trunk/varnish-cache/bin/varnishtest/Makefile.am 2008-06-15 11:47:01 UTC (rev 2674) +++ trunk/varnish-cache/bin/varnishtest/Makefile.am 2008-06-15 12:08:11 UTC (rev 2675) @@ -7,6 +7,7 @@ varnishtest_SOURCES = \ vtc.c \ vtc_client.c \ + vtc_http.c \ vtc_server.c \ vtc_stats.c \ vtc_varnish.c \ Modified: trunk/varnish-cache/bin/varnishtest/t000.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/t000.vtc 2008-06-15 11:47:01 UTC (rev 2674) +++ trunk/varnish-cache/bin/varnishtest/t000.vtc 2008-06-15 12:08:11 UTC (rev 2675) @@ -3,7 +3,7 @@ server s1 -listen :9080 -repeat 2 { rxreq - expect url == "/" + expect req.url == "/" txresponse -body "0123456789" } @@ -12,8 +12,8 @@ client c1 -connect localhost:9080 { txreq -url "/" rxresponse - expect status == 200 - expect length == 10 + expect resp.status == 200 + expect resp.length == 10 } client c1 -run Modified: trunk/varnish-cache/bin/varnishtest/vtc.h =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc.h 2008-06-15 11:47:01 UTC (rev 2674) +++ trunk/varnish-cache/bin/varnishtest/vtc.h 2008-06-15 12:08:11 UTC (rev 2675) @@ -40,3 +40,4 @@ void cmd_stats(char **av, void *priv); void cmd_varnish(char **av, void *priv); +void http_process(const char *spec, int sock, int client); Modified: trunk/varnish-cache/bin/varnishtest/vtc_client.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_client.c 2008-06-15 11:47:01 UTC (rev 2674) +++ trunk/varnish-cache/bin/varnishtest/vtc_client.c 2008-06-15 12:08:11 UTC (rev 2675) @@ -84,7 +84,7 @@ assert(fd >= 0); printf("#### Client %s connected to %s fd is %d\n", c->name, c->connect, fd); - sleep (1); + http_process(c->spec, fd, 1); close(fd); printf("### Client %s ending\n", c->name); Added: trunk/varnish-cache/bin/varnishtest/vtc_http.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_http.c (rev 0) +++ trunk/varnish-cache/bin/varnishtest/vtc_http.c 2008-06-15 12:08:11 UTC (rev 2675) @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2006-2008 Linpro AS + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + + +#include +#include +#include + +#include "libvarnish.h" +#include "miniobj.h" + +#include "vtc.h" + + +struct http { + unsigned magic; +#define HTTP_MAGIC 0x2f02169c + int fd; + int client; +}; + + +static struct cmds http_cmds[] = { + { "txreq", cmd_dump }, + { "rxreq", cmd_dump }, + { "txresponse", cmd_dump }, + { "rxresponse", cmd_dump }, + { "expect", cmd_dump }, + { NULL, NULL } +}; + +void +http_process(const char *spec, int sock, int client) +{ + struct http *hp; + char *s, *q; + + ALLOC_OBJ(hp, HTTP_MAGIC); + hp->fd = sock; + hp->client = client; + (void)spec; + (void)sock; + (void)client; + + s = strdup(spec + 1); + q = strchr(s, '\0'); + assert(q > s); + q--; + assert(*q == '}'); + *q = '\0'; + AN(s); + parse_string(s, http_cmds, hp); +} Modified: trunk/varnish-cache/bin/varnishtest/vtc_server.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_server.c 2008-06-15 11:47:01 UTC (rev 2674) +++ trunk/varnish-cache/bin/varnishtest/vtc_server.c 2008-06-15 12:08:11 UTC (rev 2675) @@ -88,6 +88,7 @@ l = sizeof addr_s; fd = accept(s->sock, addr, &l); printf("#### Accepted socket %d\n", fd); + http_process(s->spec, fd, 0); close(fd); } printf("### Server %s ending\n", s->name); From phk at projects.linpro.no Sun Jun 15 12:13:24 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Sun, 15 Jun 2008 14:13:24 +0200 (CEST) Subject: r2676 - trunk/varnish-cache/bin/varnishtest Message-ID: <20080615121324.EF1761EC118@projects.linpro.no> Author: phk Date: 2008-06-15 14:13:24 +0200 (Sun, 15 Jun 2008) New Revision: 2676 Modified: trunk/varnish-cache/bin/varnishtest/vtc.c trunk/varnish-cache/bin/varnishtest/vtc.h trunk/varnish-cache/bin/varnishtest/vtc_client.c trunk/varnish-cache/bin/varnishtest/vtc_http.c trunk/varnish-cache/bin/varnishtest/vtc_server.c trunk/varnish-cache/bin/varnishtest/vtc_stats.c trunk/varnish-cache/bin/varnishtest/vtc_varnish.c trunk/varnish-cache/bin/varnishtest/vtc_vcl.c Log: Add $Id$ Modified: trunk/varnish-cache/bin/varnishtest/vtc.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc.c 2008-06-15 12:08:11 UTC (rev 2675) +++ trunk/varnish-cache/bin/varnishtest/vtc.c 2008-06-15 12:13:24 UTC (rev 2676) @@ -22,6 +22,8 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. + * + * $Id$ */ #include Modified: trunk/varnish-cache/bin/varnishtest/vtc.h =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc.h 2008-06-15 12:08:11 UTC (rev 2675) +++ trunk/varnish-cache/bin/varnishtest/vtc.h 2008-06-15 12:13:24 UTC (rev 2676) @@ -22,6 +22,8 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. + * + * $Id$ */ typedef void cmd_f(char **av, void *priv); Modified: trunk/varnish-cache/bin/varnishtest/vtc_client.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_client.c 2008-06-15 12:08:11 UTC (rev 2675) +++ trunk/varnish-cache/bin/varnishtest/vtc_client.c 2008-06-15 12:13:24 UTC (rev 2676) @@ -22,6 +22,8 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. + * + * $Id$ */ #include Modified: trunk/varnish-cache/bin/varnishtest/vtc_http.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_http.c 2008-06-15 12:08:11 UTC (rev 2675) +++ trunk/varnish-cache/bin/varnishtest/vtc_http.c 2008-06-15 12:13:24 UTC (rev 2676) @@ -22,6 +22,8 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. + * + * $Id$ */ Modified: trunk/varnish-cache/bin/varnishtest/vtc_server.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_server.c 2008-06-15 12:08:11 UTC (rev 2675) +++ trunk/varnish-cache/bin/varnishtest/vtc_server.c 2008-06-15 12:13:24 UTC (rev 2676) @@ -22,6 +22,8 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. + * + * $Id$ */ Modified: trunk/varnish-cache/bin/varnishtest/vtc_stats.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_stats.c 2008-06-15 12:08:11 UTC (rev 2675) +++ trunk/varnish-cache/bin/varnishtest/vtc_stats.c 2008-06-15 12:13:24 UTC (rev 2676) @@ -22,6 +22,8 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. + * + * $Id$ */ Modified: trunk/varnish-cache/bin/varnishtest/vtc_varnish.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_varnish.c 2008-06-15 12:08:11 UTC (rev 2675) +++ trunk/varnish-cache/bin/varnishtest/vtc_varnish.c 2008-06-15 12:13:24 UTC (rev 2676) @@ -22,6 +22,8 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. + * + * $Id$ */ Modified: trunk/varnish-cache/bin/varnishtest/vtc_vcl.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_vcl.c 2008-06-15 12:08:11 UTC (rev 2675) +++ trunk/varnish-cache/bin/varnishtest/vtc_vcl.c 2008-06-15 12:13:24 UTC (rev 2676) @@ -22,6 +22,8 @@ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. + * + * $Id$ */ From phk at projects.linpro.no Sun Jun 15 12:15:47 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Sun, 15 Jun 2008 14:15:47 +0200 (CEST) Subject: r2677 - trunk/varnish-cache/bin/varnishtest Message-ID: <20080615121547.AA0CF1EC40A@projects.linpro.no> Author: phk Date: 2008-06-15 14:15:47 +0200 (Sun, 15 Jun 2008) New Revision: 2677 Modified: trunk/varnish-cache/bin/varnishtest/Makefile.am trunk/varnish-cache/bin/varnishtest/t000.vtc trunk/varnish-cache/bin/varnishtest/t001.vtc trunk/varnish-cache/bin/varnishtest/vtc.h trunk/varnish-cache/bin/varnishtest/vtc_client.c trunk/varnish-cache/bin/varnishtest/vtc_http.c trunk/varnish-cache/bin/varnishtest/vtc_server.c trunk/varnish-cache/bin/varnishtest/vtc_stats.c trunk/varnish-cache/bin/varnishtest/vtc_varnish.c trunk/varnish-cache/bin/varnishtest/vtc_vcl.c Log: Propset svn:keywords and add $Id Property changes on: trunk/varnish-cache/bin/varnishtest/Makefile.am ___________________________________________________________________ Name: svn:keywords + vtc.c Modified: trunk/varnish-cache/bin/varnishtest/t000.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/t000.vtc 2008-06-15 12:13:24 UTC (rev 2676) +++ trunk/varnish-cache/bin/varnishtest/t000.vtc 2008-06-15 12:15:47 UTC (rev 2677) @@ -1,5 +1,6 @@ # Quis custodiet ipsos custodes? # +# $Id$ server s1 -listen :9080 -repeat 2 { rxreq Property changes on: trunk/varnish-cache/bin/varnishtest/t000.vtc ___________________________________________________________________ Name: svn:keywords + vtc.c Modified: trunk/varnish-cache/bin/varnishtest/t001.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/t001.vtc 2008-06-15 12:13:24 UTC (rev 2676) +++ trunk/varnish-cache/bin/varnishtest/t001.vtc 2008-06-15 12:15:47 UTC (rev 2677) @@ -1,5 +1,6 @@ # Test that we get anything through at all # +# $Id$ server s1 -repeat 3 { rxreq Property changes on: trunk/varnish-cache/bin/varnishtest/t001.vtc ___________________________________________________________________ Name: svn:keywords + vtc.c Property changes on: trunk/varnish-cache/bin/varnishtest/vtc.h ___________________________________________________________________ Name: svn:keywords + vtc.c Property changes on: trunk/varnish-cache/bin/varnishtest/vtc_client.c ___________________________________________________________________ Name: svn:keywords + vtc.c Property changes on: trunk/varnish-cache/bin/varnishtest/vtc_http.c ___________________________________________________________________ Name: svn:keywords + vtc.c Property changes on: trunk/varnish-cache/bin/varnishtest/vtc_server.c ___________________________________________________________________ Name: svn:keywords + vtc.c Property changes on: trunk/varnish-cache/bin/varnishtest/vtc_stats.c ___________________________________________________________________ Name: svn:keywords + vtc.c Property changes on: trunk/varnish-cache/bin/varnishtest/vtc_varnish.c ___________________________________________________________________ Name: svn:keywords + vtc.c Property changes on: trunk/varnish-cache/bin/varnishtest/vtc_vcl.c ___________________________________________________________________ Name: svn:keywords + vtc.c From phk at projects.linpro.no Sun Jun 15 12:44:10 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Sun, 15 Jun 2008 14:44:10 +0200 (CEST) Subject: r2678 - trunk/varnish-cache/bin/varnishtest Message-ID: <20080615124410.9F6FB1EC40A@projects.linpro.no> Author: phk Date: 2008-06-15 14:44:10 +0200 (Sun, 15 Jun 2008) New Revision: 2678 Modified: trunk/varnish-cache/bin/varnishtest/vtc.c Log: Implement backslash-newline escapes. Implement "" quoting of strings. Modified: trunk/varnish-cache/bin/varnishtest/vtc.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc.c 2008-06-15 12:15:47 UTC (rev 2677) +++ trunk/varnish-cache/bin/varnishtest/vtc.c 2008-06-15 12:44:10 UTC (rev 2678) @@ -76,7 +76,7 @@ parse_string(char *buf, const struct cmds *cmd, void *priv) { char *token_s[MAX_TOKENS], *token_e[MAX_TOKENS]; - char *p; + char *p, *q; int nest_brace; int tn; const struct cmds *cp; @@ -102,6 +102,31 @@ break; } else if (isspace(*p)) { /* Inter-token whitespace */ p++; + } else if (*p == '\\' && p[1] == '\n') { + p += 2; + } else if (*p == '"') { /* quotes */ + token_s[tn] = ++p; + q = p; + for (; *p != '\0'; p++) { + if (*p == '"') + break; + + if (*p == '\\' && p[1] == 'n') { + *q++ = '\n'; + p++; + } else if (*p == '\\' && p[1] == '\\') { + *q++ = '\\'; + p++; + } else if (*p == '\\' && p[1] == '"') { + *q++ = '"'; + p++; + } else { + assert(*p != '\n'); + *q++ = *p; + } + } + token_e[tn++] = q; + p++; } else if (*p == '{') { /* Braces */ nest_brace = 0; token_s[tn] = p; From phk at projects.linpro.no Sun Jun 15 12:45:54 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Sun, 15 Jun 2008 14:45:54 +0200 (CEST) Subject: r2679 - trunk/varnish-cache/bin/varnishtest Message-ID: <20080615124554.160071EC118@projects.linpro.no> Author: phk Date: 2008-06-15 14:45:53 +0200 (Sun, 15 Jun 2008) New Revision: 2679 Modified: trunk/varnish-cache/bin/varnishtest/t000.vtc trunk/varnish-cache/bin/varnishtest/vtc_http.c Log: Implement http::txreq Modified: trunk/varnish-cache/bin/varnishtest/t000.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/t000.vtc 2008-06-15 12:44:10 UTC (rev 2678) +++ trunk/varnish-cache/bin/varnishtest/t000.vtc 2008-06-15 12:45:53 UTC (rev 2679) @@ -11,7 +11,7 @@ server s1 -start client c1 -connect localhost:9080 { - txreq -url "/" + txreq rxresponse expect resp.status == 200 expect resp.length == 10 Modified: trunk/varnish-cache/bin/varnishtest/vtc_http.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_http.c 2008-06-15 12:44:10 UTC (rev 2678) +++ trunk/varnish-cache/bin/varnishtest/vtc_http.c 2008-06-15 12:45:53 UTC (rev 2679) @@ -30,9 +30,11 @@ #include #include #include +#include #include "libvarnish.h" #include "miniobj.h" +#include "vsb.h" #include "vtc.h" @@ -44,9 +46,80 @@ int client; }; +/********************************************************************** + * Transmit a request + */ +static void +cmd_http_txreq(char **av, void *priv) +{ + struct http *hp; + struct vsb *vsb; + const char *req = "GET"; + const char *url = "/"; + const char *proto = "HTTP/1.1"; + int dohdr = 0; + const char *nl = "\r\n"; + int l; + + CAST_OBJ_NOTNULL(hp, priv, HTTP_MAGIC); + AN(hp->client); + assert(!strcmp(av[0], "txreq")); + av++; + + vsb = vsb_new(NULL, NULL, 0, VSB_AUTOEXTEND); + + for(; *av != NULL; av++) { + if (!strcmp(*av, "-url")) { + AZ(dohdr); + url = av[1]; + av++; + continue; + } + if (!strcmp(*av, "-proto")) { + AZ(dohdr); + proto = av[1]; + av++; + continue; + } + if (!strcmp(*av, "-req")) { + AZ(dohdr); + req = av[1]; + av++; + continue; + } + if (!strcmp(*av, "-hdr")) { + if (dohdr == 0) { + vsb_printf(vsb, "%s %s %s%s", + req, url, proto, nl); + dohdr = 1; + } + vsb_printf(vsb, "%s%s", av[1], nl); + av++; + continue; + } + fprintf(stderr, "Unknown http spec: %s\n", *av); + exit (1); + } + if (dohdr == 0) { + vsb_printf(vsb, "%s %s %s%s", + req, url, proto, nl); + dohdr = 1; + } + vsb_cat(vsb, nl); + vsb_finish(vsb); + AZ(vsb_overflowed(vsb)); + l = write(hp->fd, vsb_data(vsb), vsb_len(vsb)); + assert(l == vsb_len(vsb)); + vsb_delete(vsb); +} + +/********************************************************************** + * Execute HTTP specifications + */ + static struct cmds http_cmds[] = { - { "txreq", cmd_dump }, + { "txreq", cmd_http_txreq }, { "rxreq", cmd_dump }, { "txresponse", cmd_dump }, { "rxresponse", cmd_dump }, @@ -63,9 +136,6 @@ ALLOC_OBJ(hp, HTTP_MAGIC); hp->fd = sock; hp->client = client; - (void)spec; - (void)sock; - (void)client; s = strdup(spec + 1); q = strchr(s, '\0'); From phk at projects.linpro.no Sun Jun 15 13:09:21 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Sun, 15 Jun 2008 15:09:21 +0200 (CEST) Subject: r2680 - trunk/varnish-cache/bin/varnishtest Message-ID: <20080615130921.BF1961EC40A@projects.linpro.no> Author: phk Date: 2008-06-15 15:09:21 +0200 (Sun, 15 Jun 2008) New Revision: 2680 Modified: trunk/varnish-cache/bin/varnishtest/vtc_http.c Log: Function to receive a HTTP header, as request or response. Modified: trunk/varnish-cache/bin/varnishtest/vtc_http.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_http.c 2008-06-15 12:45:53 UTC (rev 2679) +++ trunk/varnish-cache/bin/varnishtest/vtc_http.c 2008-06-15 13:09:21 UTC (rev 2680) @@ -27,6 +27,7 @@ */ +#include #include #include #include @@ -44,9 +45,104 @@ #define HTTP_MAGIC 0x2f02169c int fd; int client; + int timeout; + + int nrxbuf; + char *rxbuf; + + char *req; + char *resp; }; /********************************************************************** + * Receive a HTTP protocol header + */ + +static void +http_rxhdr(struct http *hp) +{ + int l, n, i; + struct pollfd pfd[1]; + char *p; + + CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC); + hp->rxbuf = malloc(hp->nrxbuf); /* XXX */ + AN(hp->rxbuf); + l = 0; + while (1) { + pfd[0].fd = hp->fd; + pfd[0].events = POLLRDNORM; + pfd[0].revents = 0; + i = poll(pfd, 1, hp->timeout); + assert(i > 0); + assert(l < hp->nrxbuf); + n = read(hp->fd, hp->rxbuf + l, 1); + assert(n == 1); + l += n; + hp->rxbuf[l] = '\0'; + assert(n > 0); + p = hp->rxbuf + l - 1; + i = 0; + for (i = 0; p > hp->rxbuf; p--) { + if (*p != '\n') + break; + if (p - 1 > hp->rxbuf && p[-1] == '\r') + p--; + if (++i == 2) + break; + } + if (i == 2) + break; + } +printf("<<<%s>>>\n", hp->rxbuf); +} + + +/********************************************************************** + * Receive a response + */ + +static void +cmd_http_rxresp(char **av, void *priv) +{ + struct http *hp; + + CAST_OBJ_NOTNULL(hp, priv, HTTP_MAGIC); + AN(hp->client); + assert(!strcmp(av[0], "rxresponse")); + av++; + + for(; *av != NULL; av++) { + fprintf(stderr, "Unknown http rxresp spec: %s\n", *av); + exit (1); + } + http_rxhdr(hp); + hp->resp = hp->rxbuf; +} + +/********************************************************************** + * Receive a request + */ + +static void +cmd_http_rxreq(char **av, void *priv) +{ + struct http *hp; + + CAST_OBJ_NOTNULL(hp, priv, HTTP_MAGIC); + AZ(hp->client); + assert(!strcmp(av[0], "rxreq")); + av++; + + for(; *av != NULL; av++) { + fprintf(stderr, "Unknown http rxreq spec: %s\n", *av); + exit (1); + } + http_rxhdr(hp); + hp->req = hp->rxbuf; +} + +/********************************************************************** * Transmit a request */ @@ -98,7 +194,7 @@ av++; continue; } - fprintf(stderr, "Unknown http spec: %s\n", *av); + fprintf(stderr, "Unknown http txreq spec: %s\n", *av); exit (1); } if (dohdr == 0) { @@ -120,9 +216,9 @@ static struct cmds http_cmds[] = { { "txreq", cmd_http_txreq }, - { "rxreq", cmd_dump }, + { "rxreq", cmd_http_rxreq }, { "txresponse", cmd_dump }, - { "rxresponse", cmd_dump }, + { "rxresponse", cmd_http_rxresp }, { "expect", cmd_dump }, { NULL, NULL } }; @@ -136,6 +232,8 @@ ALLOC_OBJ(hp, HTTP_MAGIC); hp->fd = sock; hp->client = client; + hp->timeout = 1000; + hp->nrxbuf = 8192; s = strdup(spec + 1); q = strchr(s, '\0'); From phk at projects.linpro.no Sun Jun 15 13:16:18 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Sun, 15 Jun 2008 15:16:18 +0200 (CEST) Subject: r2681 - trunk/varnish-cache/bin/varnishtest Message-ID: <20080615131618.DF0B31EC118@projects.linpro.no> Author: phk Date: 2008-06-15 15:16:18 +0200 (Sun, 15 Jun 2008) New Revision: 2681 Modified: trunk/varnish-cache/bin/varnishtest/t000.vtc trunk/varnish-cache/bin/varnishtest/vtc_http.c Log: Add http txresponse Modified: trunk/varnish-cache/bin/varnishtest/t000.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/t000.vtc 2008-06-15 13:09:21 UTC (rev 2680) +++ trunk/varnish-cache/bin/varnishtest/t000.vtc 2008-06-15 13:16:18 UTC (rev 2681) @@ -5,14 +5,14 @@ server s1 -listen :9080 -repeat 2 { rxreq expect req.url == "/" - txresponse -body "0123456789" + txresp -body "0123456789" } server s1 -start client c1 -connect localhost:9080 { txreq - rxresponse + rxresp expect resp.status == 200 expect resp.length == 10 } Modified: trunk/varnish-cache/bin/varnishtest/vtc_http.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_http.c 2008-06-15 13:09:21 UTC (rev 2680) +++ trunk/varnish-cache/bin/varnishtest/vtc_http.c 2008-06-15 13:16:18 UTC (rev 2681) @@ -109,7 +109,7 @@ CAST_OBJ_NOTNULL(hp, priv, HTTP_MAGIC); AN(hp->client); - assert(!strcmp(av[0], "rxresponse")); + assert(!strcmp(av[0], "rxresp")); av++; for(; *av != NULL; av++) { @@ -121,6 +121,84 @@ } /********************************************************************** + * Transmit a response + */ + +static void +cmd_http_txresp(char **av, void *priv) +{ + struct http *hp; + struct vsb *vsb; + const char *proto = "HTTP/1.1"; + const char *status = "200"; + const char *msg = "Ok"; + const char *body = NULL; + int dohdr = 0; + const char *nl = "\r\n"; + int l; + + CAST_OBJ_NOTNULL(hp, priv, HTTP_MAGIC); + AZ(hp->client); + assert(!strcmp(av[0], "txresp")); + av++; + + vsb = vsb_new(NULL, NULL, 0, VSB_AUTOEXTEND); + + for(; *av != NULL; av++) { + if (!strcmp(*av, "-proto")) { + AZ(dohdr); + proto = av[1]; + av++; + continue; + } + if (!strcmp(*av, "-status")) { + AZ(dohdr); + status = av[1]; + av++; + continue; + } + if (!strcmp(*av, "-msg")) { + AZ(dohdr); + msg = av[1]; + av++; + continue; + } + if (!strcmp(*av, "-body")) { + body = av[1]; + av++; + continue; + } + if (!strcmp(*av, "-hdr")) { + if (dohdr == 0) { + vsb_printf(vsb, "%s %s %s%s", + proto, status, msg, nl); + dohdr = 1; + } + vsb_printf(vsb, "%s%s", av[1], nl); + av++; + continue; + } + fprintf(stderr, "Unknown http txreq spec: %s\n", *av); + exit (1); + } + if (dohdr == 0) { + vsb_printf(vsb, "%s %s %s%s", + proto, status, msg, nl); + dohdr = 1; + } + vsb_cat(vsb, nl); + if (body != NULL) { + vsb_cat(vsb, body); + vsb_cat(vsb, nl); + } + vsb_finish(vsb); + AZ(vsb_overflowed(vsb)); + l = write(hp->fd, vsb_data(vsb), vsb_len(vsb)); + assert(l == vsb_len(vsb)); + vsb_delete(vsb); +} + +/********************************************************************** * Receive a request */ @@ -217,8 +295,8 @@ static struct cmds http_cmds[] = { { "txreq", cmd_http_txreq }, { "rxreq", cmd_http_rxreq }, - { "txresponse", cmd_dump }, - { "rxresponse", cmd_http_rxresp }, + { "txresp", cmd_http_txresp }, + { "rxresp", cmd_http_rxresp }, { "expect", cmd_dump }, { NULL, NULL } }; From phk at projects.linpro.no Sun Jun 15 13:36:51 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Sun, 15 Jun 2008 15:36:51 +0200 (CEST) Subject: r2682 - trunk/varnish-cache/bin/varnishtest Message-ID: <20080615133651.0F3701ED29D@projects.linpro.no> Author: phk Date: 2008-06-15 15:36:50 +0200 (Sun, 15 Jun 2008) New Revision: 2682 Added: trunk/varnish-cache/bin/varnishtest/flint.lnt trunk/varnish-cache/bin/varnishtest/flint.sh Modified: trunk/varnish-cache/bin/varnishtest/vtc.c trunk/varnish-cache/bin/varnishtest/vtc_client.c trunk/varnish-cache/bin/varnishtest/vtc_http.c trunk/varnish-cache/bin/varnishtest/vtc_server.c Log: FlexeLint varnishtest Added: trunk/varnish-cache/bin/varnishtest/flint.lnt =================================================================== --- trunk/varnish-cache/bin/varnishtest/flint.lnt (rev 0) +++ trunk/varnish-cache/bin/varnishtest/flint.lnt 2008-06-15 13:36:50 UTC (rev 2682) @@ -0,0 +1,78 @@ +-passes=3 + ++libh mgt_event.h ++libh ../../config.h + +-emacro((???),va_arg) // the va_arg() macro can yield 415, 416, 661, 662 + // 796 and 797 (out-of-bounds errors). +-elib(123) // size is both a variable and a macro with args +-emacro(736, isnan) // isnanf + + +-sem(strchr, 1p, type(1), 2n == 0 ? (@p < 1p) : (@p < 1p || @p == 0 )) + +-sem(vsb_new, @p == malloc(1)) +-sem(vsb_delete, custodial(1)) +-sem(lbv_assert, r_no) +-sem(lbv_xxxassert, r_no) + +-ffc // No automatic custody + +-e763 // Redundant declaration for symbol '...' previously declared +-e726 // Extraneous comma ignored +-e728 // Symbol ... not explicitly initialized +-e716 // while(1) ... +-e785 // Too few initializers for aggregate +-e786 // String concatenation within initializer + +-emacro(740, VTAILQ_PREV) // Unusual pointer cast (incompatible indirect types) +-emacro(740, VTAILQ_LAST) // Unusual pointer cast (incompatible indirect types) +-emacro((826), VTAILQ_PREV) // Suspicious pointer-to-pointer conversion (area too small) +-emacro((826), VTAILQ_LAST) // Suspicious pointer-to-pointer conversion (area too small) +-emacro(506, VTAILQ_FOREACH_SAFE) // constant value boolean + +-esym(534, sprintf) // Ignoring return value of function +-esym(534, asprintf) // Ignoring return value of function +-esym(534, printf) // Ignoring return value of function +-esym(534, fprintf) // Ignoring return value of function +-esym(534, memset) // Ignoring return value of function +-esym(534, memcpy) // Ignoring return value of function +-esym(534, memmove) // Ignoring return value of function +-esym(534, strcpy) // Ignoring return value of function +-esym(534, vsb_printf) // Ignoring return value of function +-esym(534, vsb_cat) // Ignoring return value of function +-esym(534, vsb_bcat) // Ignoring return value of function +-esym(534, vsb_putc) // Ignoring return value of function +-esym(534, strcat) // Ignoring return value of function +-esym(534, strcpy) // Ignoring return value of function +-esym(534, strlcpy) // Ignoring return value of function + +-emacro(506, isnan) // constant value boolean +-emacro(747, isnan) // significant coersion +-emacro(506, assert) // constant value boolean +-emacro(827, assert) // loop not reachable +-emacro(774, assert) // booelan always true + +// cache.h +-emacro(506, INCOMPL) // Constant value Boolean + +// Review all below this line /////////////////////////////////////////////// + +-e732 // Loss of sign (arg. no. 2) (int to unsigned +-e737 // [45] Loss of sign in promotion from int to unsigned +-e713 // Loss of precision (assignment) (unsigned long long to long long) +-e574 // Signed-unsigned mix with relational +-e712 // Loss of precision (assignment) (long long to +-e747 // Significant prototype coercion (arg. no. 2) long + +/* + +-e767 // Macro redef (system queue.h vs ours ) + +-e506 // Constant value boolean +-e818 // Pointer parameter '...' could be declared as pointing to const +-e774 // Boolean within 'if' always evaluates to False +-e534 // Ignoring return value of function +-e557 // unrecog format + +*/ Added: trunk/varnish-cache/bin/varnishtest/flint.sh =================================================================== --- trunk/varnish-cache/bin/varnishtest/flint.sh (rev 0) +++ trunk/varnish-cache/bin/varnishtest/flint.sh 2008-06-15 13:36:50 UTC (rev 2682) @@ -0,0 +1,31 @@ +#!/bin/sh + +T=/tmp/_$$ +flexelint \ + -I/usr/include \ + -I. \ + -I../../include \ + -I../.. \ + -DVARNISH_STATE_DIR=\"foo\" \ + flint.lnt \ + *.c > $T 2>&1 + +for t in Error Warning Info +do + sed -n "/$t [0-9][0-9][0-9]:/s/.*\($t [0-9][0-9][0-9]\).*/\1/p" $T +done | awk ' +$2 == 830 { next } +$2 == 831 { next } + { + i=$2"_"$1 + h[i]++ + n++ + } +END { + printf "%5d %s\n", n, "Total" + for (i in h) + printf "%5d %s\n", h[i], i + } +' | sort -rn + +cat $T Property changes on: trunk/varnish-cache/bin/varnishtest/flint.sh ___________________________________________________________________ Name: svn:executable + * Modified: trunk/varnish-cache/bin/varnishtest/vtc.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc.c 2008-06-15 13:16:18 UTC (rev 2681) +++ trunk/varnish-cache/bin/varnishtest/vtc.c 2008-06-15 13:36:50 UTC (rev 2682) @@ -30,11 +30,12 @@ #include #include #include -#include #include #include #include +#include "libvarnish.h" + #include "vtc.h" #define MAX_FILESIZE (1024 * 1024) @@ -61,7 +62,7 @@ if (s <= 0) err(1, "Cannot read %s", fn); assert(s < sz); /* XXX: increase MAX_FILESIZE */ - close (fd); + AZ(close (fd)); buf[s] = '\0'; buf = realloc(buf, s + 1); assert(buf != NULL); @@ -100,11 +101,16 @@ assert(tn < MAX_TOKENS); if (*p == '\n') { /* End on NL */ break; - } else if (isspace(*p)) { /* Inter-token whitespace */ + } + if (isspace(*p)) { /* Inter-token whitespace */ p++; - } else if (*p == '\\' && p[1] == '\n') { + continue; + } + if (*p == '\\' && p[1] == '\n') { /* line-cont */ p += 2; - } else if (*p == '"') { /* quotes */ + continue; + } + if (*p == '"') { /* quotes */ token_s[tn] = ++p; q = p; for (; *p != '\0'; p++) { @@ -149,8 +155,10 @@ } assert(tn < MAX_TOKENS); token_s[tn] = NULL; - for (tn = 0; token_s[tn] != NULL; tn++) - *token_e[tn] = '\0'; + for (tn = 0; token_s[tn] != NULL; tn++) { + AN(token_e[tn]); /*lint !e771 */ + *token_e[tn] = '\0'; /*lint !e771 */ + } for (cp = cmd; cp->name != NULL; cp++) if (!strcmp(token_s[0], cp->name)) Modified: trunk/varnish-cache/bin/varnishtest/vtc_client.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_client.c 2008-06-15 13:16:18 UTC (rev 2681) +++ trunk/varnish-cache/bin/varnishtest/vtc_client.c 2008-06-15 13:36:50 UTC (rev 2682) @@ -71,7 +71,7 @@ { struct client *c; int i; - int fd; + int fd = -1; CAST_OBJ_NOTNULL(c, priv, CLIENT_MAGIC); assert(c->naddr > 0); @@ -87,7 +87,7 @@ printf("#### Client %s connected to %s fd is %d\n", c->name, c->connect, fd); http_process(c->spec, fd, 1); - close(fd); + AZ(close(fd)); printf("### Client %s ending\n", c->name); return (NULL); @@ -103,6 +103,7 @@ struct client *c; ALLOC_OBJ(c, CLIENT_MAGIC); + AN(c); c->name = name; c->connect = ":8080"; VTAILQ_INSERT_TAIL(&clients, c, list); Modified: trunk/varnish-cache/bin/varnishtest/vtc_http.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_http.c 2008-06-15 13:16:18 UTC (rev 2681) +++ trunk/varnish-cache/bin/varnishtest/vtc_http.c 2008-06-15 13:36:50 UTC (rev 2682) @@ -308,6 +308,7 @@ char *s, *q; ALLOC_OBJ(hp, HTTP_MAGIC); + AN(hp); hp->fd = sock; hp->client = client; hp->timeout = 1000; @@ -321,4 +322,5 @@ *q = '\0'; AN(s); parse_string(s, http_cmds, hp); + free(hp); } Modified: trunk/varnish-cache/bin/varnishtest/vtc_server.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_server.c 2008-06-15 13:16:18 UTC (rev 2681) +++ trunk/varnish-cache/bin/varnishtest/vtc_server.c 2008-06-15 13:36:50 UTC (rev 2682) @@ -91,7 +91,7 @@ fd = accept(s->sock, addr, &l); printf("#### Accepted socket %d\n", fd); http_process(s->spec, fd, 0); - close(fd); + AZ(close(fd)); } printf("### Server %s ending\n", s->name); @@ -108,6 +108,7 @@ struct server *s; ALLOC_OBJ(s, SERVER_MAGIC); + AN(s); s->name = name; s->listen = ":9080"; s->repeat = 1; From phk at projects.linpro.no Sun Jun 15 15:30:49 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Sun, 15 Jun 2008 17:30:49 +0200 (CEST) Subject: r2683 - in trunk/varnish-cache: include lib/libvarnish Message-ID: <20080615153049.DCD101ED230@projects.linpro.no> Author: phk Date: 2008-06-15 17:30:49 +0200 (Sun, 15 Jun 2008) New Revision: 2683 Added: trunk/varnish-cache/lib/libvarnish/vct.c Modified: trunk/varnish-cache/include/libvarnish.h trunk/varnish-cache/lib/libvarnish/Makefile.am Log: Add VCT: a RFC2616 ctype Modified: trunk/varnish-cache/include/libvarnish.h =================================================================== --- trunk/varnish-cache/include/libvarnish.h 2008-06-15 13:36:50 UTC (rev 2682) +++ trunk/varnish-cache/include/libvarnish.h 2008-06-15 15:30:49 UTC (rev 2683) @@ -54,6 +54,30 @@ double TIM_mono(void); double TIM_real(void); +/* from libvarnish/vct.c */ +#define VCT_SP (1<<0) +#define VCT_CRLF (1<<1) +#define VCT_LWS (VCT_CRLF | VCT_SP) +#define VCT_CTL (1<<2) +#define VCT_UALPHA (1<<3) +#define VCT_LOALPHA (1<<4) +#define VCT_DIGIT (1<<5) +#define VCT_HEX (1<<6) + +extern unsigned char vct_typtab[256]; + +static inline int +vct_is(unsigned char x, unsigned char y) +{ + + return (vct_typtab[x] & (y)); +} + +#define vct_issp(x) vct_is(x, VCT_SP) +#define vct_iscrlf(x) vct_is(x, VCT_CRLF) +#define vct_islws(x) vct_is(x, VCT_LWS) +#define vct_isctl(x) vct_is(x, VCT_CTL) + /* from libvarnish/version.c */ void varnish_version(const char *); Modified: trunk/varnish-cache/lib/libvarnish/Makefile.am =================================================================== --- trunk/varnish-cache/lib/libvarnish/Makefile.am 2008-06-15 13:36:50 UTC (rev 2682) +++ trunk/varnish-cache/lib/libvarnish/Makefile.am 2008-06-15 15:30:49 UTC (rev 2683) @@ -14,6 +14,7 @@ flopen.c \ num.c \ time.c \ + vct.c \ version.c \ vlu.c \ vpf.c \ Added: trunk/varnish-cache/lib/libvarnish/vct.c =================================================================== --- trunk/varnish-cache/lib/libvarnish/vct.c (rev 0) +++ trunk/varnish-cache/lib/libvarnish/vct.c 2008-06-15 15:30:49 UTC (rev 2683) @@ -0,0 +1,132 @@ +/*- + * Copyright (c) 2006-2008 Linpro AS + * All rights reserved. + * + * Author: Poul-Henning Kamp + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $Id: vpf.h 1410 2007-05-11 11:17:09Z des $ + * + * ctype(3) like functions, according to RFC2616 + */ + +#include + +unsigned char vct_typtab[256] = { + [0x00] = VCT_CTL, + [0x01] = VCT_CTL, + [0x02] = VCT_CTL, + [0x03] = VCT_CTL, + [0x04] = VCT_CTL, + [0x05] = VCT_CTL, + [0x06] = VCT_CTL, + [0x07] = VCT_CTL, + [0x08] = VCT_CTL, + [0x09] = VCT_CTL | VCT_SP, + [0x0a] = VCT_CTL | VCT_CRLF, + [0x0b] = VCT_CTL, + [0x0c] = VCT_CTL, + [0x0d] = VCT_CTL | VCT_CRLF, + [0x0e] = VCT_CTL, + [0x0f] = VCT_CTL, + [0x10] = VCT_CTL, + [0x11] = VCT_CTL, + [0x12] = VCT_CTL, + [0x13] = VCT_CTL, + [0x14] = VCT_CTL, + [0x15] = VCT_CTL, + [0x16] = VCT_CTL, + [0x17] = VCT_CTL, + [0x18] = VCT_CTL, + [0x19] = VCT_CTL, + [0x1a] = VCT_CTL, + [0x1b] = VCT_CTL, + [0x1c] = VCT_CTL, + [0x1d] = VCT_CTL, + [0x1e] = VCT_CTL, + [0x1f] = VCT_CTL, + [0x20] = VCT_SP, + [0x30] = VCT_DIGIT | VCT_HEX, + [0x31] = VCT_DIGIT | VCT_HEX, + [0x32] = VCT_DIGIT | VCT_HEX, + [0x33] = VCT_DIGIT | VCT_HEX, + [0x34] = VCT_DIGIT | VCT_HEX, + [0x35] = VCT_DIGIT | VCT_HEX, + [0x36] = VCT_DIGIT | VCT_HEX, + [0x37] = VCT_DIGIT | VCT_HEX, + [0x38] = VCT_DIGIT | VCT_HEX, + [0x39] = VCT_DIGIT | VCT_HEX, + [0x41] = VCT_UALPHA | VCT_HEX, + [0x42] = VCT_UALPHA | VCT_HEX, + [0x43] = VCT_UALPHA | VCT_HEX, + [0x44] = VCT_UALPHA | VCT_HEX, + [0x45] = VCT_UALPHA | VCT_HEX, + [0x46] = VCT_UALPHA | VCT_HEX, + [0x47] = VCT_UALPHA, + [0x48] = VCT_UALPHA, + [0x49] = VCT_UALPHA, + [0x4a] = VCT_UALPHA, + [0x4b] = VCT_UALPHA, + [0x4c] = VCT_UALPHA, + [0x4d] = VCT_UALPHA, + [0x4e] = VCT_UALPHA, + [0x4f] = VCT_UALPHA, + [0x50] = VCT_UALPHA, + [0x51] = VCT_UALPHA, + [0x52] = VCT_UALPHA, + [0x53] = VCT_UALPHA, + [0x54] = VCT_UALPHA, + [0x55] = VCT_UALPHA, + [0x56] = VCT_UALPHA, + [0x57] = VCT_UALPHA, + [0x58] = VCT_UALPHA, + [0x59] = VCT_UALPHA, + [0x5a] = VCT_UALPHA, + [0x61] = VCT_LOALPHA | VCT_HEX, + [0x62] = VCT_LOALPHA | VCT_HEX, + [0x63] = VCT_LOALPHA | VCT_HEX, + [0x64] = VCT_LOALPHA | VCT_HEX, + [0x65] = VCT_LOALPHA | VCT_HEX, + [0x66] = VCT_LOALPHA | VCT_HEX, + [0x67] = VCT_LOALPHA, + [0x68] = VCT_LOALPHA, + [0x69] = VCT_LOALPHA, + [0x6a] = VCT_LOALPHA, + [0x6b] = VCT_LOALPHA, + [0x6c] = VCT_LOALPHA, + [0x6d] = VCT_LOALPHA, + [0x6e] = VCT_LOALPHA, + [0x6f] = VCT_LOALPHA, + [0x70] = VCT_LOALPHA, + [0x71] = VCT_LOALPHA, + [0x72] = VCT_LOALPHA, + [0x73] = VCT_LOALPHA, + [0x74] = VCT_LOALPHA, + [0x75] = VCT_LOALPHA, + [0x76] = VCT_LOALPHA, + [0x77] = VCT_LOALPHA, + [0x78] = VCT_LOALPHA, + [0x79] = VCT_LOALPHA, + [0x7a] = VCT_LOALPHA, + [0x7f] = VCT_CTL, +}; From phk at projects.linpro.no Sun Jun 15 15:40:40 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Sun, 15 Jun 2008 17:40:40 +0200 (CEST) Subject: r2684 - in trunk/varnish-cache: include lib/libvarnish Message-ID: <20080615154040.1F2221ED2CC@projects.linpro.no> Author: phk Date: 2008-06-15 17:40:39 +0200 (Sun, 15 Jun 2008) New Revision: 2684 Modified: trunk/varnish-cache/include/libvarnish.h trunk/varnish-cache/lib/libvarnish/vct.c Log: Polish VCT a bit more. Modified: trunk/varnish-cache/include/libvarnish.h =================================================================== --- trunk/varnish-cache/include/libvarnish.h 2008-06-15 15:30:49 UTC (rev 2683) +++ trunk/varnish-cache/include/libvarnish.h 2008-06-15 15:40:39 UTC (rev 2684) @@ -78,6 +78,9 @@ #define vct_islws(x) vct_is(x, VCT_LWS) #define vct_isctl(x) vct_is(x, VCT_CTL) +/* NB: VCT always operate in ASCII, don't replace 0x0d with \r etc. */ +#define vct_skipcrlf(p) (p[0] == 0x0d && p[1] == 0x0a ? 2 : 1) + /* from libvarnish/version.c */ void varnish_version(const char *); Modified: trunk/varnish-cache/lib/libvarnish/vct.c =================================================================== --- trunk/varnish-cache/lib/libvarnish/vct.c 2008-06-15 15:30:49 UTC (rev 2683) +++ trunk/varnish-cache/lib/libvarnish/vct.c 2008-06-15 15:40:39 UTC (rev 2684) @@ -32,6 +32,8 @@ #include +/* NB: VCT always operate in ASCII, don't replace 0x0d with \r etc. */ + unsigned char vct_typtab[256] = { [0x00] = VCT_CTL, [0x01] = VCT_CTL, From phk at projects.linpro.no Sun Jun 15 15:43:21 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Sun, 15 Jun 2008 17:43:21 +0200 (CEST) Subject: r2685 - in trunk/varnish-cache: include lib/libvarnish Message-ID: <20080615154321.761641ED157@projects.linpro.no> Author: phk Date: 2008-06-15 17:43:21 +0200 (Sun, 15 Jun 2008) New Revision: 2685 Added: trunk/varnish-cache/include/vct.h Modified: trunk/varnish-cache/include/libvarnish.h trunk/varnish-cache/lib/libvarnish/vct.c Log: On further consideration: give VCT it's own header file. Modified: trunk/varnish-cache/include/libvarnish.h =================================================================== --- trunk/varnish-cache/include/libvarnish.h 2008-06-15 15:40:39 UTC (rev 2684) +++ trunk/varnish-cache/include/libvarnish.h 2008-06-15 15:43:21 UTC (rev 2685) @@ -54,33 +54,6 @@ double TIM_mono(void); double TIM_real(void); -/* from libvarnish/vct.c */ -#define VCT_SP (1<<0) -#define VCT_CRLF (1<<1) -#define VCT_LWS (VCT_CRLF | VCT_SP) -#define VCT_CTL (1<<2) -#define VCT_UALPHA (1<<3) -#define VCT_LOALPHA (1<<4) -#define VCT_DIGIT (1<<5) -#define VCT_HEX (1<<6) - -extern unsigned char vct_typtab[256]; - -static inline int -vct_is(unsigned char x, unsigned char y) -{ - - return (vct_typtab[x] & (y)); -} - -#define vct_issp(x) vct_is(x, VCT_SP) -#define vct_iscrlf(x) vct_is(x, VCT_CRLF) -#define vct_islws(x) vct_is(x, VCT_LWS) -#define vct_isctl(x) vct_is(x, VCT_CTL) - -/* NB: VCT always operate in ASCII, don't replace 0x0d with \r etc. */ -#define vct_skipcrlf(p) (p[0] == 0x0d && p[1] == 0x0a ? 2 : 1) - /* from libvarnish/version.c */ void varnish_version(const char *); Copied: trunk/varnish-cache/include/vct.h (from rev 2684, trunk/varnish-cache/include/libvarnish.h) =================================================================== --- trunk/varnish-cache/include/vct.h (rev 0) +++ trunk/varnish-cache/include/vct.h 2008-06-15 15:43:21 UTC (rev 2685) @@ -0,0 +1,58 @@ +/*- + * Copyright (c) 2006 Verdens Gang AS + * Copyright (c) 2006-2008 Linpro AS + * All rights reserved. + * + * Author: Poul-Henning Kamp + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $Id$ + */ + +/* from libvarnish/vct.c */ + +#define VCT_SP (1<<0) +#define VCT_CRLF (1<<1) +#define VCT_LWS (VCT_CRLF | VCT_SP) +#define VCT_CTL (1<<2) +#define VCT_UALPHA (1<<3) +#define VCT_LOALPHA (1<<4) +#define VCT_DIGIT (1<<5) +#define VCT_HEX (1<<6) + +extern unsigned char vct_typtab[256]; + +static inline int +vct_is(unsigned char x, unsigned char y) +{ + + return (vct_typtab[x] & (y)); +} + +#define vct_issp(x) vct_is(x, VCT_SP) +#define vct_iscrlf(x) vct_is(x, VCT_CRLF) +#define vct_islws(x) vct_is(x, VCT_LWS) +#define vct_isctl(x) vct_is(x, VCT_CTL) + +/* NB: VCT always operate in ASCII, don't replace 0x0d with \r etc. */ +#define vct_skipcrlf(p) (p[0] == 0x0d && p[1] == 0x0a ? 2 : 1) Property changes on: trunk/varnish-cache/include/vct.h ___________________________________________________________________ Name: svn:keywords + Id Name: svn:mergeinfo + Modified: trunk/varnish-cache/lib/libvarnish/vct.c =================================================================== --- trunk/varnish-cache/lib/libvarnish/vct.c 2008-06-15 15:40:39 UTC (rev 2684) +++ trunk/varnish-cache/lib/libvarnish/vct.c 2008-06-15 15:43:21 UTC (rev 2685) @@ -30,7 +30,7 @@ * ctype(3) like functions, according to RFC2616 */ -#include +#include /* NB: VCT always operate in ASCII, don't replace 0x0d with \r etc. */ From phk at projects.linpro.no Sun Jun 15 16:11:17 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Sun, 15 Jun 2008 18:11:17 +0200 (CEST) Subject: r2686 - trunk/varnish-cache/bin/varnishtest Message-ID: <20080615161117.EC9DB1ED0A4@projects.linpro.no> Author: phk Date: 2008-06-15 18:11:17 +0200 (Sun, 15 Jun 2008) New Revision: 2686 Modified: trunk/varnish-cache/bin/varnishtest/t000.vtc trunk/varnish-cache/bin/varnishtest/vtc.c trunk/varnish-cache/bin/varnishtest/vtc.h trunk/varnish-cache/bin/varnishtest/vtc_client.c trunk/varnish-cache/bin/varnishtest/vtc_http.c trunk/varnish-cache/bin/varnishtest/vtc_server.c Log: Get a fair bit further in parsing HTTP stuff. Modified: trunk/varnish-cache/bin/varnishtest/t000.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/t000.vtc 2008-06-15 15:43:21 UTC (rev 2685) +++ trunk/varnish-cache/bin/varnishtest/t000.vtc 2008-06-15 16:11:17 UTC (rev 2686) @@ -5,7 +5,7 @@ server s1 -listen :9080 -repeat 2 { rxreq expect req.url == "/" - txresp -body "0123456789" + txresp -hdr "Foobar: barf" -body "0123456789" } server s1 -start Modified: trunk/varnish-cache/bin/varnishtest/vtc.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc.c 2008-06-15 15:43:21 UTC (rev 2685) +++ trunk/varnish-cache/bin/varnishtest/vtc.c 2008-06-15 16:11:17 UTC (rev 2686) @@ -35,6 +35,7 @@ #include #include "libvarnish.h" +#include "vsb.h" #include "vtc.h" @@ -42,6 +43,46 @@ #define MAX_TOKENS 20 /********************************************************************** + * Dump a string + */ +void +vct_dump(const char *ident, const char *pfx, const char *str) +{ + int nl = 1; + struct vsb *vsb; + + if (pfx == NULL) + pfx = ""; + vsb = vsb_new(NULL, NULL, 0, VSB_AUTOEXTEND); + if (str == NULL) + vsb_printf(vsb, "#### %-4s %s(null)\n", ident, pfx); + for(; *str; str++) { + if (nl) { + vsb_printf(vsb, "#### %-4s %s| ", ident, pfx); + nl = 0; + } + if (*str == '\r') + vsb_printf(vsb, "\\r"); + else if (*str == '\t') + vsb_printf(vsb, "\\t"); + else if (*str == '\n') { + vsb_printf(vsb, "\\n\n"); + nl = 1; + } else if (*str < 0x20 || *str > 0x7e) + vsb_printf(vsb, "\\x%02x", *str); + else + vsb_printf(vsb, "%c", *str); + } + if (!nl) + vsb_printf(vsb, "\n"); + vsb_finish(vsb); + AZ(vsb_overflowed(vsb)); + fputs(vsb_data(vsb), stdout); + vsb_delete(vsb); +} + + +/********************************************************************** * Read a file into memory */ Modified: trunk/varnish-cache/bin/varnishtest/vtc.h =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc.h 2008-06-15 15:43:21 UTC (rev 2685) +++ trunk/varnish-cache/bin/varnishtest/vtc.h 2008-06-15 16:11:17 UTC (rev 2686) @@ -42,4 +42,6 @@ void cmd_stats(char **av, void *priv); void cmd_varnish(char **av, void *priv); -void http_process(const char *spec, int sock, int client); +void http_process(const char *ident, const char *spec, int sock, int client); + +void vct_dump(const char *ident, const char *pfx, const char *str); Modified: trunk/varnish-cache/bin/varnishtest/vtc_client.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_client.c 2008-06-15 15:43:21 UTC (rev 2685) +++ trunk/varnish-cache/bin/varnishtest/vtc_client.c 2008-06-15 16:11:17 UTC (rev 2686) @@ -76,19 +76,19 @@ CAST_OBJ_NOTNULL(c, priv, CLIENT_MAGIC); assert(c->naddr > 0); - printf("### Client %s started\n", c->name); - printf("#### Client %s connect to %s\n", c->name, c->connect); + printf("## %-4s started\n", c->name); + printf("### %-4s connect to %s\n", c->name, c->connect); for (i = 0; i < c->naddr; i++) { fd = VSS_connect(c->vss_addr[i]); if (fd >= 0) break; } assert(fd >= 0); - printf("#### Client %s connected to %s fd is %d\n", + printf("### %-4s connected to %s fd is %d\n", c->name, c->connect, fd); - http_process(c->spec, fd, 1); + http_process(c->name, c->spec, fd, 1); AZ(close(fd)); - printf("### Client %s ending\n", c->name); + printf("## %-4s ending\n", c->name); return (NULL); } @@ -133,7 +133,7 @@ void *res; CHECK_OBJ_NOTNULL(c, CLIENT_MAGIC); - printf("Waiting for client %s\n", c->name); + printf("## %-4s Waiting for client\n", c->name); AZ(pthread_join(c->tp, &res)); if (res != NULL) { fprintf(stderr, "Server %s returned \"%s\"\n", Modified: trunk/varnish-cache/bin/varnishtest/vtc_http.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_http.c 2008-06-15 15:43:21 UTC (rev 2685) +++ trunk/varnish-cache/bin/varnishtest/vtc_http.c 2008-06-15 16:11:17 UTC (rev 2686) @@ -32,13 +32,16 @@ #include #include #include +#include #include "libvarnish.h" +#include "vct.h" #include "miniobj.h" #include "vsb.h" #include "vtc.h" +#define MAX_HDR 50 struct http { unsigned magic; @@ -46,15 +49,114 @@ int fd; int client; int timeout; + const char *ident; int nrxbuf; char *rxbuf; - char *req; - char *resp; + char *req[MAX_HDR]; + char *resp[MAX_HDR]; }; /********************************************************************** + * Expect + */ + +static void +cmd_http_expect(char **av, void *priv) +{ + struct http *hp; + + CAST_OBJ_NOTNULL(hp, priv, HTTP_MAGIC); + assert(!strcmp(av[0], "expect")); + av++; + + for(; *av != NULL; av++) { + fprintf(stderr, "Unknown http expect spec: %s\n", *av); + // exit (1); + } +} + +/********************************************************************** + * Split a HTTP protocol header + */ + +static void +http_splitheader(struct http *hp, int req) +{ + char *p, *q, **hh; + int n; + char buf[20]; + + CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC); + if (req) { + memset(hp->req, 0, sizeof hp->req); + hh = hp->req; + } else { + memset(hp->resp, 0, sizeof hp->resp); + hh = hp->resp; + } + + n = 0; + p = hp->rxbuf; + + /* REQ/PROTO */ + while (vct_islws(*p)) + p++; + hh[n++] = p; + while (!vct_islws(*p)) + p++; + assert(!vct_iscrlf(*p)); + *p++ = '\0'; + + /* URL/STATUS */ + while (vct_issp(*p)) /* XXX: H space only */ + p++; + assert(!vct_iscrlf(*p)); + hh[n++] = p; + while (!vct_islws(*p)) + p++; + if (vct_iscrlf(*p)) { + hh[n++] = NULL; + q = p; + p += vct_skipcrlf(p); + *q = '\0'; + } else { + *p++ = '\0'; + /* PROTO/MSG */ + while (vct_issp(*p)) /* XXX: H space only */ + p++; + hh[n++] = p; + while (!vct_iscrlf(*p)) + p++; + q = p; + p += vct_skipcrlf(p); + *q = '\0'; + } + assert(n == 3); + + while (*p != '\0') { + assert(n < MAX_HDR); + if (vct_iscrlf(*p)) + break; + hh[n++] = p++; + while (*p != '\0' && !vct_iscrlf(*p)) + p++; + q = p; + p += vct_skipcrlf(p); + *q = '\0'; + } + p += vct_skipcrlf(p); + assert(*p == '\0'); + + for (n = 0; n < 3 || hh[n] != NULL; n++) { + sprintf(buf, "http[%2d] ", n); + vct_dump(hp->ident, buf, hh[n]); + } +} + + +/********************************************************************** * Receive a HTTP protocol header */ @@ -94,7 +196,7 @@ if (i == 2) break; } -printf("<<<%s>>>\n", hp->rxbuf); + vct_dump(hp->ident, NULL, hp->rxbuf); } @@ -116,8 +218,9 @@ fprintf(stderr, "Unknown http rxresp spec: %s\n", *av); exit (1); } + printf("### %-4s rxresp\n", hp->ident); http_rxhdr(hp); - hp->resp = hp->rxbuf; + http_splitheader(hp, 0); } /********************************************************************** @@ -193,6 +296,7 @@ } vsb_finish(vsb); AZ(vsb_overflowed(vsb)); + vct_dump(hp->ident, NULL, vsb_data(vsb)); l = write(hp->fd, vsb_data(vsb), vsb_len(vsb)); assert(l == vsb_len(vsb)); vsb_delete(vsb); @@ -216,8 +320,9 @@ fprintf(stderr, "Unknown http rxreq spec: %s\n", *av); exit (1); } + printf("### %-4s rxreq\n", hp->ident); http_rxhdr(hp); - hp->req = hp->rxbuf; + http_splitheader(hp, 1); } /********************************************************************** @@ -283,6 +388,7 @@ vsb_cat(vsb, nl); vsb_finish(vsb); AZ(vsb_overflowed(vsb)); + vct_dump(hp->ident, NULL, vsb_data(vsb)); l = write(hp->fd, vsb_data(vsb), vsb_len(vsb)); assert(l == vsb_len(vsb)); vsb_delete(vsb); @@ -297,12 +403,12 @@ { "rxreq", cmd_http_rxreq }, { "txresp", cmd_http_txresp }, { "rxresp", cmd_http_rxresp }, - { "expect", cmd_dump }, + { "expect", cmd_http_expect }, { NULL, NULL } }; void -http_process(const char *spec, int sock, int client) +http_process(const char *ident, const char *spec, int sock, int client) { struct http *hp; char *s, *q; @@ -310,6 +416,7 @@ ALLOC_OBJ(hp, HTTP_MAGIC); AN(hp); hp->fd = sock; + hp->ident = ident; hp->client = client; hp->timeout = 1000; hp->nrxbuf = 8192; Modified: trunk/varnish-cache/bin/varnishtest/vtc_server.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_server.c 2008-06-15 15:43:21 UTC (rev 2685) +++ trunk/varnish-cache/bin/varnishtest/vtc_server.c 2008-06-15 16:11:17 UTC (rev 2686) @@ -82,18 +82,18 @@ CAST_OBJ_NOTNULL(s, priv, SERVER_MAGIC); assert(s->sock >= 0); - printf("### Server %s started\n", s->name); + printf("## %-4s started\n", s->name); for (i = 0; i < s->repeat; i++) { if (s->repeat > 1) - printf("#### Server %s iteration %d\n", s->name, i); + printf("### %-4s 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); - http_process(s->spec, fd, 0); + printf("#### %-4s Accepted socket %d\n", s->name, fd); + http_process(s->name, s->spec, fd, 0); AZ(close(fd)); } - printf("### Server %s ending\n", s->name); + printf("## %-4s ending\n", s->name); return (NULL); } @@ -157,7 +157,7 @@ void *res; CHECK_OBJ_NOTNULL(s, SERVER_MAGIC); - printf("Waiting for server %s\n", s->name); + printf("## %-4s Waiting for server\n", s->name); AZ(pthread_join(s->tp, &res)); if (res != NULL) { fprintf(stderr, "Server %s returned \"%s\"\n", From phk at projects.linpro.no Sun Jun 15 19:32:03 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Sun, 15 Jun 2008 21:32:03 +0200 (CEST) Subject: r2687 - trunk/varnish-cache/bin/varnishtest Message-ID: <20080615193203.1190A1ED2CC@projects.linpro.no> Author: phk Date: 2008-06-15 21:32:02 +0200 (Sun, 15 Jun 2008) New Revision: 2687 Modified: trunk/varnish-cache/bin/varnishtest/vtc_client.c trunk/varnish-cache/bin/varnishtest/vtc_server.c Log: Regularize a couple of messages. Modified: trunk/varnish-cache/bin/varnishtest/vtc_client.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_client.c 2008-06-15 16:11:17 UTC (rev 2686) +++ trunk/varnish-cache/bin/varnishtest/vtc_client.c 2008-06-15 19:32:02 UTC (rev 2687) @@ -119,7 +119,7 @@ { CHECK_OBJ_NOTNULL(c, CLIENT_MAGIC); - printf("Starting client %s\n", c->name); + printf("## %-4s Starting client\n", c->name); AZ(pthread_create(&c->tp, NULL, client_thread, c)); } Modified: trunk/varnish-cache/bin/varnishtest/vtc_server.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_server.c 2008-06-15 16:11:17 UTC (rev 2686) +++ trunk/varnish-cache/bin/varnishtest/vtc_server.c 2008-06-15 19:32:02 UTC (rev 2687) @@ -128,7 +128,7 @@ int naddr; CHECK_OBJ_NOTNULL(s, SERVER_MAGIC); - printf("Starting server %s\n", s->name); + printf("## %-4s Starting server\n", s->name); if (s->sock < 0) { AZ(VSS_parse(s->listen, &s->addr, &s->port)); naddr = VSS_resolve(s->addr, s->port, &s->vss_addr); @@ -142,7 +142,7 @@ s->sock = VSS_listen(s->vss_addr[0], s->depth); assert(s->sock >= 0); } - printf("#### Server %s listen on %s (fd %d)\n", + printf("### %-4s listen on %s (fd %d)\n", s->name, s->listen, s->sock); AZ(pthread_create(&s->tp, NULL, server_thread, s)); } From phk at projects.linpro.no Sun Jun 15 19:52:34 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Sun, 15 Jun 2008 21:52:34 +0200 (CEST) Subject: r2688 - trunk/varnish-cache/bin/varnishtest Message-ID: <20080615195234.B2B191ED340@projects.linpro.no> Author: phk Date: 2008-06-15 21:52:34 +0200 (Sun, 15 Jun 2008) New Revision: 2688 Modified: trunk/varnish-cache/bin/varnishtest/t000.vtc trunk/varnish-cache/bin/varnishtest/vtc_http.c Log: Make the HTTP expect work for trivial cases. Modified: trunk/varnish-cache/bin/varnishtest/t000.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/t000.vtc 2008-06-15 19:32:02 UTC (rev 2687) +++ trunk/varnish-cache/bin/varnishtest/t000.vtc 2008-06-15 19:52:34 UTC (rev 2688) @@ -14,7 +14,7 @@ txreq rxresp expect resp.status == 200 - expect resp.length == 10 + expect resp.http.foobar == barf } client c1 -run Modified: trunk/varnish-cache/bin/varnishtest/vtc_http.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_http.c 2008-06-15 19:32:02 UTC (rev 2687) +++ trunk/varnish-cache/bin/varnishtest/vtc_http.c 2008-06-15 19:52:34 UTC (rev 2688) @@ -62,18 +62,79 @@ * Expect */ +static char * +cmd_var_resolve(struct http *hp, char *spec) +{ + char **hh, *hdr; + int n, l; + + if (!strcmp(spec, "req.request")) + return(hp->req[0]); + if (!strcmp(spec, "req.url")) + return(hp->req[1]); + if (!strcmp(spec, "req.proto")) + return(hp->req[2]); + if (!strcmp(spec, "resp.proto")) + return(hp->resp[0]); + if (!strcmp(spec, "resp.status")) + return(hp->resp[1]); + if (!strcmp(spec, "resp.msg")) + return(hp->resp[2]); + if (!memcmp(spec, "req.http.", 9)) { + hh = hp->req; + hdr = spec + 9; + } else if (!memcmp(spec, "resp.http.", 10)) { + hh = hp->resp; + hdr = spec + 10; + } else + return (spec); + l = strlen(hdr); + for (n = 3; hh[n] != NULL; n++) { + if (strncasecmp(hdr, hh[n], l) || hh[n][l] != ':') + continue; + hdr = hh[n] + l + 1; + while (vct_issp(*hdr)) + hdr++; + return (hdr); + } + return (spec); +} + static void cmd_http_expect(char **av, void *priv) { struct http *hp; + char *lhs; + char *cmp; + char *rhs; CAST_OBJ_NOTNULL(hp, priv, HTTP_MAGIC); assert(!strcmp(av[0], "expect")); av++; - for(; *av != NULL; av++) { - fprintf(stderr, "Unknown http expect spec: %s\n", *av); - // exit (1); + AN(av[0]); + AN(av[1]); + AN(av[2]); + AZ(av[3]); + lhs = cmd_var_resolve(hp, av[0]); + cmp = av[1]; + rhs = cmd_var_resolve(hp, av[2]); + if (!strcmp(cmp, "==")) { + if (strcmp(lhs, rhs)) { + fprintf(stderr, + "---- %-4s EXPECT %s (%s) %s %s (%s) failed\n", + hp->ident, av[0], lhs, av[1], av[2], rhs); + exit (1); + } else { + printf( + "#### %-4s EXPECT %s (%s) %s %s (%s) match\n", + hp->ident, av[0], lhs, av[1], av[2], rhs); + } + } else { + fprintf(stderr, + "---- %-4s EXPECT %s (%s) %s %s (%s) not implemented\n", + hp->ident, av[0], lhs, av[1], av[2], rhs); + exit (1); } } From phk at projects.linpro.no Sun Jun 15 19:53:36 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Sun, 15 Jun 2008 21:53:36 +0200 (CEST) Subject: r2689 - trunk/varnish-cache/bin/varnishtest Message-ID: <20080615195336.463131ED29D@projects.linpro.no> Author: phk Date: 2008-06-15 21:53:36 +0200 (Sun, 15 Jun 2008) New Revision: 2689 Modified: trunk/varnish-cache/bin/varnishtest/vtc.c Log: Flexelint Modified: trunk/varnish-cache/bin/varnishtest/vtc.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc.c 2008-06-15 19:52:34 UTC (rev 2688) +++ trunk/varnish-cache/bin/varnishtest/vtc.c 2008-06-15 19:53:36 UTC (rev 2689) @@ -56,28 +56,29 @@ vsb = vsb_new(NULL, NULL, 0, VSB_AUTOEXTEND); if (str == NULL) vsb_printf(vsb, "#### %-4s %s(null)\n", ident, pfx); - for(; *str; str++) { - if (nl) { - vsb_printf(vsb, "#### %-4s %s| ", ident, pfx); - nl = 0; + else + for(; *str; str++) { + if (nl) { + vsb_printf(vsb, "#### %-4s %s| ", ident, pfx); + nl = 0; + } + if (*str == '\r') + vsb_printf(vsb, "\\r"); + else if (*str == '\t') + vsb_printf(vsb, "\\t"); + else if (*str == '\n') { + vsb_printf(vsb, "\\n\n"); + nl = 1; + } else if (*str < 0x20 || *str > 0x7e) + vsb_printf(vsb, "\\x%02x", *str); + else + vsb_printf(vsb, "%c", *str); } - if (*str == '\r') - vsb_printf(vsb, "\\r"); - else if (*str == '\t') - vsb_printf(vsb, "\\t"); - else if (*str == '\n') { - vsb_printf(vsb, "\\n\n"); - nl = 1; - } else if (*str < 0x20 || *str > 0x7e) - vsb_printf(vsb, "\\x%02x", *str); - else - vsb_printf(vsb, "%c", *str); - } if (!nl) vsb_printf(vsb, "\n"); vsb_finish(vsb); AZ(vsb_overflowed(vsb)); - fputs(vsb_data(vsb), stdout); + (void)fputs(vsb_data(vsb), stdout); vsb_delete(vsb); } From phk at projects.linpro.no Sun Jun 15 19:55:49 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Sun, 15 Jun 2008 21:55:49 +0200 (CEST) Subject: r2690 - trunk/varnish-cache/bin/varnishtest Message-ID: <20080615195549.668771ED0A4@projects.linpro.no> Author: phk Date: 2008-06-15 21:55:49 +0200 (Sun, 15 Jun 2008) New Revision: 2690 Modified: trunk/varnish-cache/bin/varnishtest/vtc.c Log: Wrap two level 1 messages around each test file. Modified: trunk/varnish-cache/bin/varnishtest/vtc.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc.c 2008-06-15 19:53:36 UTC (rev 2689) +++ trunk/varnish-cache/bin/varnishtest/vtc.c 2008-06-15 19:55:49 UTC (rev 2690) @@ -244,8 +244,10 @@ { char *buf; + printf("# TEST %s starting\n", fn); buf = read_file(fn); parse_string(buf, cmds, NULL); + printf("# TEST %s completed\n", fn); } /********************************************************************** From phk at projects.linpro.no Sun Jun 15 20:37:53 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Sun, 15 Jun 2008 22:37:53 +0200 (CEST) Subject: r2691 - in trunk/varnish-cache/bin/varnishtest: . tests Message-ID: <20080615203753.16DE41ED2CC@projects.linpro.no> Author: phk Date: 2008-06-15 22:37:52 +0200 (Sun, 15 Jun 2008) New Revision: 2691 Added: trunk/varnish-cache/bin/varnishtest/tests/ trunk/varnish-cache/bin/varnishtest/tests/README Modified: trunk/varnish-cache/bin/varnishtest/flint.lnt trunk/varnish-cache/bin/varnishtest/flint.sh Log: Polishing Property changes on: trunk/varnish-cache/bin/varnishtest/flint.lnt ___________________________________________________________________ Name: svn:keywords + Property changes on: trunk/varnish-cache/bin/varnishtest/flint.sh ___________________________________________________________________ Name: svn:keywords + Added: trunk/varnish-cache/bin/varnishtest/tests/README =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/README (rev 0) +++ trunk/varnish-cache/bin/varnishtest/tests/README 2008-06-15 20:37:52 UTC (rev 2691) @@ -0,0 +1,23 @@ +# $Id$ + +Test-scripts for varnishtest +============================ + +Naming scheme +------------- + + The intent is to be able to run all script sin lexicographic + order and get a sensible failure mode. + + This requires more basic tests to be earlier and more complex + tests to be later in the test sequence, we do this with the + prefix/id letter: + + [id]%05d.vtc + + id ~ [a] --> varnishtester(1) tests + id ~ [b] --> Basic functionality tests + id ~ [c] --> Complex functionality tests + id ~ [e] --> ESI tests + id ~ [r] --> Regression tests. + id ~ [t] --> Ticket regression tests, number same as ticket. Property changes on: trunk/varnish-cache/bin/varnishtest/tests/README ___________________________________________________________________ Name: svn:keywords + From phk at projects.linpro.no Sun Jun 15 20:41:04 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Sun, 15 Jun 2008 22:41:04 +0200 (CEST) Subject: r2692 - trunk/varnish-cache/bin/varnishtest/tests Message-ID: <20080615204104.41D6A1ED387@projects.linpro.no> Author: phk Date: 2008-06-15 22:41:04 +0200 (Sun, 15 Jun 2008) New Revision: 2692 Added: trunk/varnish-cache/bin/varnishtest/tests/a00000.vtc trunk/varnish-cache/bin/varnishtest/tests/a00001.vtc Log: Two first testcases Added: trunk/varnish-cache/bin/varnishtest/tests/a00000.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/a00000.vtc (rev 0) +++ trunk/varnish-cache/bin/varnishtest/tests/a00000.vtc 2008-06-15 20:41:04 UTC (rev 2692) @@ -0,0 +1,19 @@ +# Quis custodiet ipsos custodes? +# +# $Id$ + +server s1 -listen :9080 { + rxreq + txresp +} + +server s1 -start + +client c1 -connect localhost:9080 { + txreq + rxresp +} + +client c1 -run + +server s1 -wait Property changes on: trunk/varnish-cache/bin/varnishtest/tests/a00000.vtc ___________________________________________________________________ Name: svn:keywords + Added: trunk/varnish-cache/bin/varnishtest/tests/a00001.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/a00001.vtc (rev 0) +++ trunk/varnish-cache/bin/varnishtest/tests/a00001.vtc 2008-06-15 20:41:04 UTC (rev 2692) @@ -0,0 +1,25 @@ +# Quis custodiet ipsos custodes? +# +# $Id$ + +server s1 -listen :9080 { + rxreq + expect req.request == GET + expect req.proto == HTTP/1.1 + expect req.url == "/" + txresp -body "0123456789" +} + +server s1 -start + +client c1 -connect localhost:9080 { + txreq + rxresp + expect resp.proto == HTTP/1.1 + expect resp.status == 200 + expect resp.msg == Ok +} + +client c1 -run + +server s1 -wait Property changes on: trunk/varnish-cache/bin/varnishtest/tests/a00001.vtc ___________________________________________________________________ Name: svn:keywords + From phk at projects.linpro.no Sun Jun 15 20:41:35 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Sun, 15 Jun 2008 22:41:35 +0200 (CEST) Subject: r2693 - trunk/varnish-cache/bin/varnishtest Message-ID: <20080615204135.B85001ED2CC@projects.linpro.no> Author: phk Date: 2008-06-15 22:41:35 +0200 (Sun, 15 Jun 2008) New Revision: 2693 Removed: trunk/varnish-cache/bin/varnishtest/t000.vtc Log: No longer relevant Deleted: trunk/varnish-cache/bin/varnishtest/t000.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/t000.vtc 2008-06-15 20:41:04 UTC (rev 2692) +++ trunk/varnish-cache/bin/varnishtest/t000.vtc 2008-06-15 20:41:35 UTC (rev 2693) @@ -1,24 +0,0 @@ -# Quis custodiet ipsos custodes? -# -# $Id$ - -server s1 -listen :9080 -repeat 2 { - rxreq - expect req.url == "/" - txresp -hdr "Foobar: barf" -body "0123456789" -} - -server s1 -start - -client c1 -connect localhost:9080 { - txreq - rxresp - expect resp.status == 200 - expect resp.http.foobar == barf -} - -client c1 -run - -client c1 -run - -server s1 -wait From phk at projects.linpro.no Sun Jun 15 20:49:27 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Sun, 15 Jun 2008 22:49:27 +0200 (CEST) Subject: r2694 - trunk/varnish-cache/bin/varnishtest Message-ID: <20080615204927.C920A1ED2CC@projects.linpro.no> Author: phk Date: 2008-06-15 22:49:27 +0200 (Sun, 15 Jun 2008) New Revision: 2694 Modified: trunk/varnish-cache/bin/varnishtest/vtc.c Log: Add "test" keyword for printing a test description Modified: trunk/varnish-cache/bin/varnishtest/vtc.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc.c 2008-06-15 20:41:35 UTC (rev 2693) +++ trunk/varnish-cache/bin/varnishtest/vtc.c 2008-06-15 20:49:27 UTC (rev 2694) @@ -218,6 +218,21 @@ } /********************************************************************** + * Output test description + */ + +static void +cmd_test(char **av, void *priv) +{ + (void)priv; + assert(!strcmp(av[0], "test")); + + printf("# TEST %s\n", av[1]); + AZ(av[2]); +} + + +/********************************************************************** * Execute a file */ @@ -236,6 +251,7 @@ { "vcl", cmd_vcl }, { "stats", cmd_stats }, { "varnish", cmd_varnish }, + { "test", cmd_test }, { NULL, NULL } }; From phk at projects.linpro.no Sun Jun 15 20:50:24 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Sun, 15 Jun 2008 22:50:24 +0200 (CEST) Subject: r2695 - trunk/varnish-cache/bin/varnishtest/tests Message-ID: <20080615205024.34A151EC8B2@projects.linpro.no> Author: phk Date: 2008-06-15 22:50:24 +0200 (Sun, 15 Jun 2008) New Revision: 2695 Added: trunk/varnish-cache/bin/varnishtest/tests/a00002.vtc Modified: trunk/varnish-cache/bin/varnishtest/tests/a00000.vtc trunk/varnish-cache/bin/varnishtest/tests/a00001.vtc Log: Describe tests with test keyword Modified: trunk/varnish-cache/bin/varnishtest/tests/a00000.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/a00000.vtc 2008-06-15 20:49:27 UTC (rev 2694) +++ trunk/varnish-cache/bin/varnishtest/tests/a00000.vtc 2008-06-15 20:50:24 UTC (rev 2695) @@ -1,7 +1,7 @@ -# Quis custodiet ipsos custodes? -# # $Id$ +test "basic default HTTP transactions" + server s1 -listen :9080 { rxreq txresp Modified: trunk/varnish-cache/bin/varnishtest/tests/a00001.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/a00001.vtc 2008-06-15 20:49:27 UTC (rev 2694) +++ trunk/varnish-cache/bin/varnishtest/tests/a00001.vtc 2008-06-15 20:50:24 UTC (rev 2695) @@ -1,13 +1,13 @@ -# Quis custodiet ipsos custodes? -# # $Id$ +test "basic default HTTP transactions with expect" + server s1 -listen :9080 { rxreq expect req.request == GET expect req.proto == HTTP/1.1 expect req.url == "/" - txresp -body "0123456789" + txresp } server s1 -start Added: trunk/varnish-cache/bin/varnishtest/tests/a00002.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/a00002.vtc (rev 0) +++ trunk/varnish-cache/bin/varnishtest/tests/a00002.vtc 2008-06-15 20:50:24 UTC (rev 2695) @@ -0,0 +1,25 @@ +# $Id$ + +test "basic default HTTP transactions with expect and options" + +server s1 -listen :9080 { + rxreq + expect req.request == PUT + expect req.proto == HTTP/1.0 + expect req.url == "/foo" + txresp -proto HTTP/1.2 -status 201 -msg Foo +} + +server s1 -start + +client c1 -connect localhost:9080 { + txreq -req PUT -proto HTTP/1.0 -url /foo + rxresp + expect resp.proto == HTTP/1.2 + expect resp.status == 201 + expect resp.msg == Foo +} + +client c1 -run + +server s1 -wait Property changes on: trunk/varnish-cache/bin/varnishtest/tests/a00002.vtc ___________________________________________________________________ Name: svn:keywords + From phk at projects.linpro.no Sun Jun 15 20:57:08 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Sun, 15 Jun 2008 22:57:08 +0200 (CEST) Subject: r2696 - trunk/varnish-cache/bin/varnishtest/tests Message-ID: <20080615205708.C8E5C1ED384@projects.linpro.no> Author: phk Date: 2008-06-15 22:57:08 +0200 (Sun, 15 Jun 2008) New Revision: 2696 Added: trunk/varnish-cache/bin/varnishtest/tests/a00003.vtc trunk/varnish-cache/bin/varnishtest/tests/a00004.vtc trunk/varnish-cache/bin/varnishtest/tests/a00005.vtc Log: More test-cases Added: trunk/varnish-cache/bin/varnishtest/tests/a00003.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/a00003.vtc (rev 0) +++ trunk/varnish-cache/bin/varnishtest/tests/a00003.vtc 2008-06-15 20:57:08 UTC (rev 2696) @@ -0,0 +1,47 @@ +# $Id$ + +test "dual independent HTTP transactions" + +server s1 -listen :9080 { + rxreq + expect req.request == PUT + expect req.proto == HTTP/1.0 + expect req.url == "/foo" + txresp -proto HTTP/1.2 -status 201 -msg Foo +} + +server s2 -listen :9081 { + rxreq + expect req.request == GET + expect req.proto == HTTP/1.1 + expect req.url == "/" + txresp +} + +server s1 -start +server s2 -start + +client c1 -connect localhost:9080 { + txreq -req PUT -proto HTTP/1.0 -url /foo + rxresp + expect resp.proto == HTTP/1.2 + expect resp.status == 201 + expect resp.msg == Foo +} + +client c2 -connect localhost:9081 { + txreq + rxresp + expect resp.proto == HTTP/1.1 + expect resp.status == 200 + expect resp.msg == Ok +} + +client c1 -start +client c2 -start + +client c1 -wait +client c2 -wait + +server s1 -wait +server s2 -wait Property changes on: trunk/varnish-cache/bin/varnishtest/tests/a00003.vtc ___________________________________________________________________ Name: svn:keywords + Added: trunk/varnish-cache/bin/varnishtest/tests/a00004.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/a00004.vtc (rev 0) +++ trunk/varnish-cache/bin/varnishtest/tests/a00004.vtc 2008-06-15 20:57:08 UTC (rev 2696) @@ -0,0 +1,37 @@ +# $Id$ + +test "dual shared server HTTP transactions" + +server s1 -listen :9080 -repeat 2 { + rxreq + expect req.request == PUT + expect req.proto == HTTP/1.0 + expect req.url == "/foo" + txresp -proto HTTP/1.2 -status 201 -msg Foo +} + +server s1 -start + +client c1 -connect localhost:9080 { + txreq -req PUT -proto HTTP/1.0 -url /foo + rxresp + expect resp.proto == HTTP/1.2 + expect resp.status == 201 + expect resp.msg == Foo +} + +client c2 -connect localhost:9080 { + txreq -req PUT -proto HTTP/1.0 -url /foo + rxresp + expect resp.proto == HTTP/1.2 + expect resp.status == 201 + expect resp.msg == Foo +} + +client c1 -start +client c2 -start + +client c1 -wait +client c2 -wait + +server s1 -wait Property changes on: trunk/varnish-cache/bin/varnishtest/tests/a00004.vtc ___________________________________________________________________ Name: svn:keywords + Added: trunk/varnish-cache/bin/varnishtest/tests/a00005.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/a00005.vtc (rev 0) +++ trunk/varnish-cache/bin/varnishtest/tests/a00005.vtc 2008-06-15 20:57:08 UTC (rev 2696) @@ -0,0 +1,45 @@ +# $Id$ + +test "dual shared client HTTP transactions" + +server s1 -listen :9080 { + rxreq + expect req.request == PUT + expect req.proto == HTTP/1.0 + expect req.url == "/foo" + txresp -proto HTTP/1.2 -status 201 -msg Foo +} + +server s2 -listen :9081 { + rxreq + expect req.request == GET + expect req.proto == HTTP/1.1 + expect req.url == "/" + txresp +} + +server s1 -start +server s2 -start + +client c1 -connect localhost:9080 { + txreq -req PUT -proto HTTP/1.0 -url /foo + rxresp + expect resp.proto == HTTP/1.2 + expect resp.status == 201 + expect resp.msg == Foo +} + +client c1 -run + +client c1 -connect localhost:9081 { + txreq + rxresp + expect resp.proto == HTTP/1.1 + expect resp.status == 200 + expect resp.msg == Ok +} + +client c1 -run + +server s1 -wait +server s2 -wait Property changes on: trunk/varnish-cache/bin/varnishtest/tests/a00005.vtc ___________________________________________________________________ Name: svn:keywords + From phk at projects.linpro.no Sun Jun 15 20:57:31 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Sun, 15 Jun 2008 22:57:31 +0200 (CEST) Subject: r2697 - trunk/varnish-cache/bin/varnishtest Message-ID: <20080615205731.1A84F1ED2CC@projects.linpro.no> Author: phk Date: 2008-06-15 22:57:30 +0200 (Sun, 15 Jun 2008) New Revision: 2697 Modified: trunk/varnish-cache/bin/varnishtest/vtc_client.c Log: Add -start and -wait for clients for async execution Modified: trunk/varnish-cache/bin/varnishtest/vtc_client.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_client.c 2008-06-15 20:57:08 UTC (rev 2696) +++ trunk/varnish-cache/bin/varnishtest/vtc_client.c 2008-06-15 20:57:30 UTC (rev 2697) @@ -185,6 +185,14 @@ assert(c->naddr > 0); continue; } + if (!strcmp(*av, "-start")) { + client_start(c); + continue; + } + if (!strcmp(*av, "-wait")) { + client_wait(c); + continue; + } if (!strcmp(*av, "-run")) { client_run(c); continue; From phk at projects.linpro.no Sun Jun 15 21:11:19 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Sun, 15 Jun 2008 23:11:19 +0200 (CEST) Subject: r2698 - trunk/varnish-cache/bin/varnishtest Message-ID: <20080615211119.92D061ED384@projects.linpro.no> Author: phk Date: 2008-06-15 23:11:19 +0200 (Sun, 15 Jun 2008) New Revision: 2698 Modified: trunk/varnish-cache/bin/varnishtest/vtc.c trunk/varnish-cache/bin/varnishtest/vtc_client.c trunk/varnish-cache/bin/varnishtest/vtc_server.c Log: Add a Reset pass after each testfile Modified: trunk/varnish-cache/bin/varnishtest/vtc.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc.c 2008-06-15 20:57:30 UTC (rev 2697) +++ trunk/varnish-cache/bin/varnishtest/vtc.c 2008-06-15 21:11:19 UTC (rev 2698) @@ -218,13 +218,29 @@ } /********************************************************************** + * Reset commands (between tests) + */ + +static void +reset_cmds(const struct cmds *cmd) +{ + + for (; cmd->name != NULL; cmd++) + cmd->cmd(NULL, NULL); +} + +/********************************************************************** * Output test description */ static void cmd_test(char **av, void *priv) { + (void)priv; + + if (av == NULL) + return; assert(!strcmp(av[0], "test")); printf("# TEST %s\n", av[1]); @@ -240,6 +256,8 @@ cmd_dump(char **av, void *priv) { + if (av == NULL) + return; printf("cmd_dump(%p)\n", priv); while (*av) printf("\t<%s>\n", *av++); @@ -264,6 +282,7 @@ buf = read_file(fn); parse_string(buf, cmds, NULL); printf("# TEST %s completed\n", fn); + reset_cmds(cmds); } /********************************************************************** Modified: trunk/varnish-cache/bin/varnishtest/vtc_client.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_client.c 2008-06-15 20:57:30 UTC (rev 2697) +++ trunk/varnish-cache/bin/varnishtest/vtc_client.c 2008-06-15 21:11:19 UTC (rev 2698) @@ -163,9 +163,20 @@ void cmd_client(char **av, void *priv) { - struct client *c; + struct client *c, *c2; (void)priv; + + if (av == NULL) { + /* Reset and free */ + VTAILQ_FOREACH_SAFE(c, &clients, list, c2) { + VTAILQ_REMOVE(&clients, c, list); + FREE_OBJ(c); + /* XXX: MEMLEAK */ + } + return; + } + assert(!strcmp(av[0], "client")); av++; Modified: trunk/varnish-cache/bin/varnishtest/vtc_server.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_server.c 2008-06-15 20:57:30 UTC (rev 2697) +++ trunk/varnish-cache/bin/varnishtest/vtc_server.c 2008-06-15 21:11:19 UTC (rev 2698) @@ -165,6 +165,8 @@ exit (1); } s->tp = NULL; + AZ(close(s->sock)); + s->sock = -1; } /********************************************************************** @@ -174,9 +176,20 @@ void cmd_server(char **av, void *priv) { - struct server *s; + struct server *s, *s2; (void)priv; + + if (av == NULL) { + /* Reset and free */ + VTAILQ_FOREACH_SAFE(s, &servers, list, s2) { + VTAILQ_REMOVE(&servers, s, list); + FREE_OBJ(s); + /* XXX: MEMLEAK */ + } + return; + } + assert(!strcmp(av[0], "server")); av++; From phk at projects.linpro.no Sun Jun 15 21:25:42 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Sun, 15 Jun 2008 23:25:42 +0200 (CEST) Subject: r2699 - trunk/varnish-cache/bin/varnishd Message-ID: <20080615212542.26E9E1ED2CC@projects.linpro.no> Author: phk Date: 2008-06-15 23:25:41 +0200 (Sun, 15 Jun 2008) New Revision: 2699 Modified: trunk/varnish-cache/bin/varnishd/mgt.h trunk/varnish-cache/bin/varnishd/mgt_child.c trunk/varnish-cache/bin/varnishd/mgt_vcc.c trunk/varnish-cache/bin/varnishd/varnishd.c Log: Allow varnishd to be started with neither -b nor -f, this is useful where a central facility is used to push VCL's to a number of Varnish hosts. Until a VCL is loaded, the child process cannot be started. Modified: trunk/varnish-cache/bin/varnishd/mgt.h =================================================================== --- trunk/varnish-cache/bin/varnishd/mgt.h 2008-06-15 21:11:19 UTC (rev 2698) +++ trunk/varnish-cache/bin/varnishd/mgt.h 2008-06-15 21:25:41 UTC (rev 2699) @@ -59,6 +59,7 @@ void mgt_vcc_init(void); int mgt_vcc_default(const char *bflag, const char *fflag, int f_fd, int Cflag); int mgt_push_vcls_and_start(unsigned *status, char **p); +int mgt_has_vcl(void); extern char *mgt_cc_cmd; #include "hash_slinger.h" Modified: trunk/varnish-cache/bin/varnishd/mgt_child.c =================================================================== --- trunk/varnish-cache/bin/varnishd/mgt_child.c 2008-06-15 21:11:19 UTC (rev 2698) +++ trunk/varnish-cache/bin/varnishd/mgt_child.c 2008-06-15 21:25:41 UTC (rev 2699) @@ -438,7 +438,9 @@ printf("rolling(1)...\n"); fprintf(stderr, "rolling(2)...\n"); - if (!dflag) + if (!dflag && !mgt_has_vcl()) + fprintf(stderr, "No VCL loaded yet\n"); + else if (!dflag) start_child(); else fprintf(stderr, @@ -460,9 +462,14 @@ (void)av; if (priv != NULL && child_state == CH_RUNNING) stop_child(); - else if (priv == NULL && child_state == CH_STOPPED) - start_child(); - else { + else if (priv == NULL && child_state == CH_STOPPED) { + if (mgt_has_vcl()) + start_child(); + else { + cli_result(cli, CLIS_CANT); + cli_out(cli, "No VCL available"); + } + } else { cli_result(cli, CLIS_CANT); cli_out(cli, "Child in state %s", ch_state[child_state]); } Modified: trunk/varnish-cache/bin/varnishd/mgt_vcc.c =================================================================== --- trunk/varnish-cache/bin/varnishd/mgt_vcc.c 2008-06-15 21:11:19 UTC (rev 2698) +++ trunk/varnish-cache/bin/varnishd/mgt_vcc.c 2008-06-15 21:25:41 UTC (rev 2699) @@ -460,6 +460,15 @@ /*--------------------------------------------------------------------*/ int +mgt_has_vcl() +{ + + return (!VTAILQ_EMPTY(&vclhead)); +} + +/*--------------------------------------------------------------------*/ + +int mgt_push_vcls_and_start(unsigned *status, char **p) { struct vclprog *vp; Modified: trunk/varnish-cache/bin/varnishd/varnishd.c =================================================================== --- trunk/varnish-cache/bin/varnishd/varnishd.c 2008-06-15 21:11:19 UTC (rev 2698) +++ trunk/varnish-cache/bin/varnishd/varnishd.c 2008-06-15 21:25:41 UTC (rev 2699) @@ -494,10 +494,6 @@ fprintf(stderr, "Only one of -b or -f can be specified\n"); usage(); } - if (b_arg == NULL && f_arg == NULL) { - fprintf(stderr, "One of -b or -f must be specified\n"); - usage(); - } if (f_arg != NULL) { f_fd = open(f_arg, O_RDONLY); @@ -533,8 +529,9 @@ exit(1); } - if (mgt_vcc_default(b_arg, f_arg, f_fd, C_flag)) - exit (2); + if (b_arg != NULL || f_arg != NULL) + if (mgt_vcc_default(b_arg, f_arg, f_fd, C_flag)) + exit (2); if (C_flag) exit (0); From phk at projects.linpro.no Mon Jun 16 07:10:48 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 16 Jun 2008 09:10:48 +0200 (CEST) Subject: r2700 - trunk/varnish-cache/bin/varnishtest Message-ID: <20080616071048.467571ED0A4@projects.linpro.no> Author: phk Date: 2008-06-16 09:10:47 +0200 (Mon, 16 Jun 2008) New Revision: 2700 Modified: trunk/varnish-cache/bin/varnishtest/vtc_client.c trunk/varnish-cache/bin/varnishtest/vtc_server.c Log: Enforce server and client name initials as 's' and 'c' respectively. Modified: trunk/varnish-cache/bin/varnishtest/vtc_client.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_client.c 2008-06-15 21:25:41 UTC (rev 2699) +++ trunk/varnish-cache/bin/varnishtest/vtc_client.c 2008-06-16 07:10:47 UTC (rev 2700) @@ -102,6 +102,11 @@ { struct client *c; + if (*name != 'c') { + fprintf(stderr, "---- %-4s Client name must start with 'c'\n", + name); + exit (1); + } ALLOC_OBJ(c, CLIENT_MAGIC); AN(c); c->name = name; Modified: trunk/varnish-cache/bin/varnishtest/vtc_server.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_server.c 2008-06-15 21:25:41 UTC (rev 2699) +++ trunk/varnish-cache/bin/varnishtest/vtc_server.c 2008-06-16 07:10:47 UTC (rev 2700) @@ -107,6 +107,11 @@ { struct server *s; + if (*name != 's') { + fprintf(stderr, "---- %-4s Server name must start with 's'\n", + name); + exit (1); + } ALLOC_OBJ(s, SERVER_MAGIC); AN(s); s->name = name; From phk at projects.linpro.no Mon Jun 16 21:25:36 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 16 Jun 2008 23:25:36 +0200 (CEST) Subject: r2701 - in trunk/varnish-cache: include lib/libvarnish Message-ID: <20080616212536.7F7A21ED1C0@projects.linpro.no> Author: phk Date: 2008-06-16 23:25:36 +0200 (Mon, 16 Jun 2008) New Revision: 2701 Modified: trunk/varnish-cache/include/vss.h trunk/varnish-cache/lib/libvarnish/vss.c Log: Add VSS_open(const char *str) for when you just want a connection and don't really care about addresses and all that. Modified: trunk/varnish-cache/include/vss.h =================================================================== --- trunk/varnish-cache/include/vss.h 2008-06-16 07:10:47 UTC (rev 2700) +++ trunk/varnish-cache/include/vss.h 2008-06-16 21:25:36 UTC (rev 2701) @@ -35,3 +35,4 @@ int VSS_bind(const struct vss_addr *addr); int VSS_listen(const struct vss_addr *addr, int depth); int VSS_connect(const struct vss_addr *addr); +int VSS_open(const char *str); Modified: trunk/varnish-cache/lib/libvarnish/vss.c =================================================================== --- trunk/varnish-cache/lib/libvarnish/vss.c 2008-06-16 07:10:47 UTC (rev 2700) +++ trunk/varnish-cache/lib/libvarnish/vss.c 2008-06-16 21:25:36 UTC (rev 2701) @@ -124,6 +124,8 @@ * freeing each individual struct vss_addr as well as the array. * * The return value is the number of addresses resoved, or zero. + * + * XXX: We need a function to free the allocated addresses. */ int VSS_resolve(const char *addr, const char *port, struct vss_addr ***vap) @@ -240,7 +242,8 @@ sd = socket(va->va_family, va->va_socktype, va->va_protocol); if (sd < 0) { - perror("socket()"); + if (errno != EPROTONOSUPPORT) + perror("socket()"); return (-1); } if (connect(sd, &va->va_addr.sa, va->va_addrlen) != 0) { @@ -250,3 +253,37 @@ } return (sd); } + +/* + * And the totally brutal version: Give me connection to this address + */ + +int +VSS_open(const char *str) +{ + int retval; + char *addr = NULL, *port = NULL; + int nvaddr, n; + struct vss_addr **vaddr; + + retval = VSS_parse(str, &addr, &port); + if (retval < 0) + return (retval); + nvaddr = VSS_resolve(addr, port, &vaddr); + if (nvaddr <= 0) { + free(addr); + free(port); + return (-1); + } + for (n = 0; n < nvaddr; n++) { + retval = VSS_connect(vaddr[n]); + if (retval >= 0) + break; + } + for (n = 0; n < nvaddr; n++) + free(vaddr[n]); + free(vaddr); + free(addr); + free(port); + return (retval); +} From phk at projects.linpro.no Mon Jun 16 21:27:27 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 16 Jun 2008 23:27:27 +0200 (CEST) Subject: r2702 - trunk/varnish-cache/bin/varnishtest Message-ID: <20080616212727.303011EC8B2@projects.linpro.no> Author: phk Date: 2008-06-16 23:27:26 +0200 (Mon, 16 Jun 2008) New Revision: 2702 Modified: trunk/varnish-cache/bin/varnishtest/vtc_client.c Log: Use VSS_open() Modified: trunk/varnish-cache/bin/varnishtest/vtc_client.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_client.c 2008-06-16 21:25:36 UTC (rev 2701) +++ trunk/varnish-cache/bin/varnishtest/vtc_client.c 2008-06-16 21:27:26 UTC (rev 2702) @@ -51,10 +51,6 @@ char *spec; const char *connect; - int naddr; - struct vss_addr **vss_addr; - char *addr; - char *port; pthread_t tp; }; @@ -70,19 +66,14 @@ client_thread(void *priv) { struct client *c; - int i; int fd = -1; CAST_OBJ_NOTNULL(c, priv, CLIENT_MAGIC); - assert(c->naddr > 0); + AN(c->connect); printf("## %-4s started\n", c->name); printf("### %-4s connect to %s\n", c->name, c->connect); - for (i = 0; i < c->naddr; i++) { - fd = VSS_connect(c->vss_addr[i]); - if (fd >= 0) - break; - } + fd = VSS_open(c->connect); assert(fd >= 0); printf("### %-4s connected to %s fd is %d\n", c->name, c->connect, fd); @@ -196,9 +187,6 @@ if (!strcmp(*av, "-connect")) { c->connect = av[1]; av++; - AZ(VSS_parse(c->connect, &c->addr, &c->port)); - c->naddr = VSS_resolve(c->addr, c->port, &c->vss_addr); - assert(c->naddr > 0); continue; } if (!strcmp(*av, "-start")) { From phk at projects.linpro.no Mon Jun 16 21:28:18 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 16 Jun 2008 23:28:18 +0200 (CEST) Subject: r2703 - trunk/varnish-cache/bin/varnishtest Message-ID: <20080616212818.D792F1EC8B2@projects.linpro.no> Author: phk Date: 2008-06-16 23:28:18 +0200 (Mon, 16 Jun 2008) New Revision: 2703 Modified: trunk/varnish-cache/bin/varnishtest/vtc_varnish.c Log: Add code to launch a varnish instance and open a CLI connection to it via TELNET. Modified: trunk/varnish-cache/bin/varnishtest/vtc_varnish.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_varnish.c 2008-06-16 21:27:26 UTC (rev 2702) +++ trunk/varnish-cache/bin/varnishtest/vtc_varnish.c 2008-06-16 21:28:18 UTC (rev 2703) @@ -29,11 +29,217 @@ #include +#include +#include +#include +#include +#include +#include + +#include +#include + + +#include "vqueue.h" +#include "miniobj.h" +#include "libvarnish.h" +#include "vss.h" +#include "vsb.h" + #include "vtc.h" +struct varnish { + unsigned magic; +#define VARNISH_MAGIC 0x208cd8e3 + char *name; + VTAILQ_ENTRY(varnish) list; + + const char *args; + int fds[4]; + pid_t pid; + const char *telnet; + const char *accept; + + pthread_t tp; + + char *addr; + char *port; + int naddr; + struct vss_addr **vss_addr; + + int cli_fd; +}; + +static VTAILQ_HEAD(, varnish) varnishes = + VTAILQ_HEAD_INITIALIZER(varnishes); + +/********************************************************************** + * Allocate and initialize a varnish + */ + +static struct varnish * +varnish_new(char *name) +{ + struct varnish *v; + + if (*name != 'v') { + fprintf(stderr, + "---- %-4s Varnish name must start with 'v'\n", name); + exit (1); + } + ALLOC_OBJ(v, VARNISH_MAGIC); + AN(v); + v->name = name; + v->args = ""; + v->telnet = ":9001"; + v->accept = ":9002"; + VTAILQ_INSERT_TAIL(&varnishes, v, list); + return (v); +} + +/********************************************************************** + * Varnish listener + */ + +static void * +varnish_thread(void *priv) +{ + struct varnish *v; + char buf[BUFSIZ]; + int i; + + CAST_OBJ_NOTNULL(v, priv, VARNISH_MAGIC); + while (1) { + i = read(v->fds[0], buf, sizeof buf - 1); + if (i <= 0) + break; + buf[i] = '\0'; + vct_dump(v->name, "debug", buf); + } + return (NULL); +} + +/********************************************************************** + * Launch a Varnish + */ + +static void +varnish_launch(struct varnish *v) +{ + struct vsb *vsb; + int i; + + vsb = vsb_new(NULL, NULL, 0, VSB_AUTOEXTEND); + AN(vsb); + vsb_printf(vsb, "cd ../varnishd &&"); + vsb_printf(vsb, "./varnishd -d -d -n %s", v->name); + vsb_printf(vsb, " -a %s -T %s", v->accept, v->telnet); + vsb_printf(vsb, " %s", v->args); + vsb_finish(vsb); + AZ(vsb_overflowed(vsb)); + printf("### %-4s CMD: %s\n", v->name, vsb_data(vsb)); + AZ(pipe(&v->fds[0])); + AZ(pipe(&v->fds[2])); + v->pid = fork(); + assert(v->pid >= 0); + if (v->pid == 0) { + assert(dup2(v->fds[0], 0) == 0); + AZ(close(v->fds[1])); + AZ(close(v->fds[2])); + assert(dup2(v->fds[3], 1) == 1); + assert(dup2(1, 2) == 2); + AZ(execl("/bin/sh", "/bin/sh", "-c", vsb_data(vsb), NULL)); + exit(1); + } + AZ(close(v->fds[0])); + AZ(close(v->fds[3])); + v->fds[0] = v->fds[2]; + v->fds[2] = v->fds[3] = -1; + vsb_delete(vsb); + AZ(pthread_create(&v->tp, NULL, varnish_thread, v)); + + printf("### %-4s opening CLI connection\n", v->name); + for (i = 0; i < 10; i++) { + usleep(200000); + v->cli_fd = VSS_open(v->telnet); + if (v->cli_fd >= 0) + break; + } + if (v->cli_fd < 0) { + fprintf(stderr, "---- %-4s FAIL no CLI connection\n", v->name); + kill(v->pid, SIGKILL); + exit (1); + } + printf("### %-4s CLI connection fd = %d\n", v->name, v->cli_fd); +} + +/********************************************************************** + * Start a Varnish + */ + +static void +varnish_start(struct varnish *v) +{ + + varnish_launch(v); +} + +/********************************************************************** + * Varnish server cmd dispatch + */ + void cmd_varnish(char **av, void *priv) { + struct varnish *v, *v2; - cmd_dump(av, priv); + (void)priv; + + if (av == NULL) { + /* Reset and free */ + VTAILQ_FOREACH_SAFE(v, &varnishes, list, v2) { + VTAILQ_REMOVE(&varnishes, v, list); + FREE_OBJ(v); + /* XXX: MEMLEAK */ + } + return; + } + + assert(!strcmp(av[0], "varnish")); + av++; + + VTAILQ_FOREACH(v, &varnishes, list) + if (!strcmp(v->name, av[0])) + break; + if (v == NULL) + v = varnish_new(av[0]); + av++; + + for (; *av != NULL; av++) { + if (!strcmp(*av, "-telnet")) { + v->telnet = av[1]; + av++; + continue; + } + if (!strcmp(*av, "-accept")) { + v->accept = av[1]; + av++; + continue; + } + if (!strcmp(*av, "-arg")) { + v->args = av[1]; + av++; + continue; + } + if (!strcmp(*av, "-launch")) { + varnish_launch(v); + continue; + } + if (!strcmp(*av, "-start")) { + varnish_start(v); + continue; + } + fprintf(stderr, "Unknown client argument: %s\n", *av); + exit (1); + } } From phk at projects.linpro.no Mon Jun 16 21:58:58 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 16 Jun 2008 23:58:58 +0200 (CEST) Subject: r2704 - trunk/varnish-cache/include Message-ID: <20080616215858.293031EC0FD@projects.linpro.no> Author: phk Date: 2008-06-16 23:58:57 +0200 (Mon, 16 Jun 2008) New Revision: 2704 Modified: trunk/varnish-cache/include/cli_common.h trunk/varnish-cache/include/cli_priv.h Log: Move cli_func_ping() prototype where it belongs. Modified: trunk/varnish-cache/include/cli_common.h =================================================================== --- trunk/varnish-cache/include/cli_common.h 2008-06-16 21:28:18 UTC (rev 2703) +++ trunk/varnish-cache/include/cli_common.h 2008-06-16 21:58:57 UTC (rev 2704) @@ -37,5 +37,3 @@ int cli_writeres(int fd, const struct cli *cli); int cli_readres(int fd, unsigned *status, char **ptr, double tmo); - -cli_func_t cli_func_ping; Modified: trunk/varnish-cache/include/cli_priv.h =================================================================== --- trunk/varnish-cache/include/cli_priv.h 2008-06-16 21:28:18 UTC (rev 2703) +++ trunk/varnish-cache/include/cli_priv.h 2008-06-16 21:58:57 UTC (rev 2704) @@ -60,4 +60,5 @@ /* From libvarnish/cli.c */ void cli_dispatch(struct cli *cli, struct cli_proto *clp, const char *line); cli_func_t cli_func_help; +cli_func_t cli_func_ping; struct cli_proto *cli_concat(struct cli_proto *, struct cli_proto *); From phk at projects.linpro.no Mon Jun 16 22:10:53 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Tue, 17 Jun 2008 00:10:53 +0200 (CEST) Subject: r2705 - trunk/varnish-cache/bin/varnishd Message-ID: <20080616221053.057881EC8B2@projects.linpro.no> Author: phk Date: 2008-06-17 00:10:52 +0200 (Tue, 17 Jun 2008) New Revision: 2705 Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c trunk/varnish-cache/bin/varnishd/cache_pipe.c Log: Make sure backend connections are blocking before we need them to be. Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_fetch.c 2008-06-16 21:58:57 UTC (rev 2704) +++ trunk/varnish-cache/bin/varnishd/cache_fetch.c 2008-06-16 22:10:52 UTC (rev 2705) @@ -317,10 +317,10 @@ st->len = st->space; WS_Assert(sp->obj->ws_o); http_Setup(sp->obj->http, sp->obj->ws_o); - vc = VBE_GetFd(sp); if (vc == NULL) return (__LINE__); + TCP_blocking(vc->fd); /* XXX: we should timeout instead */ WRK_Reset(w, &vc->fd); http_Write(w, hp, 0); Modified: trunk/varnish-cache/bin/varnishd/cache_pipe.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_pipe.c 2008-06-16 21:58:57 UTC (rev 2704) +++ trunk/varnish-cache/bin/varnishd/cache_pipe.c 2008-06-16 22:10:52 UTC (rev 2705) @@ -80,6 +80,7 @@ vc = VBE_GetFd(sp); if (vc == NULL) return; + TCP_blocking(vc->fd); WRK_Reset(w, &vc->fd); w->acct.hdrbytes += http_Write(w, bereq->http, 0); From phk at projects.linpro.no Mon Jun 16 22:13:52 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Tue, 17 Jun 2008 00:13:52 +0200 (CEST) Subject: r2706 - trunk/varnish-cache/bin/varnishtest Message-ID: <20080616221352.3D0F01EC209@projects.linpro.no> Author: phk Date: 2008-06-17 00:13:52 +0200 (Tue, 17 Jun 2008) New Revision: 2706 Modified: trunk/varnish-cache/bin/varnishtest/vtc_server.c Log: Show servers listen address. Modified: trunk/varnish-cache/bin/varnishtest/vtc_server.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_server.c 2008-06-16 22:10:52 UTC (rev 2705) +++ trunk/varnish-cache/bin/varnishtest/vtc_server.c 2008-06-16 22:13:52 UTC (rev 2706) @@ -82,7 +82,7 @@ CAST_OBJ_NOTNULL(s, priv, SERVER_MAGIC); assert(s->sock >= 0); - printf("## %-4s started\n", s->name); + printf("## %-4s started on %s\n", s->name, s->listen); for (i = 0; i < s->repeat; i++) { if (s->repeat > 1) printf("### %-4s iteration %d\n", s->name, i); From phk at projects.linpro.no Mon Jun 16 22:14:56 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Tue, 17 Jun 2008 00:14:56 +0200 (CEST) Subject: r2707 - trunk/varnish-cache/bin/varnishtest Message-ID: <20080616221456.6E33C1EC0FD@projects.linpro.no> Author: phk Date: 2008-06-17 00:14:56 +0200 (Tue, 17 Jun 2008) New Revision: 2707 Modified: trunk/varnish-cache/bin/varnishtest/vtc_varnish.c Log: Add CLI asking function. Get pipe magic right. Add brutal stop function. See the first test transaction get through. Modified: trunk/varnish-cache/bin/varnishtest/vtc_varnish.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_varnish.c 2008-06-16 22:13:52 UTC (rev 2706) +++ trunk/varnish-cache/bin/varnishtest/vtc_varnish.c 2008-06-16 22:14:56 UTC (rev 2707) @@ -43,6 +43,8 @@ #include "vqueue.h" #include "miniobj.h" #include "libvarnish.h" +#include "cli.h" +#include "cli_common.h" #include "vss.h" #include "vsb.h" @@ -74,6 +76,33 @@ VTAILQ_HEAD_INITIALIZER(varnishes); /********************************************************************** + * Ask a question over CLI + */ + +static unsigned +varnish_ask_cli(struct varnish *v, const char *cmd, char **repl) +{ + int i; + unsigned retval; + char *r; + + vct_dump(v->name, "CLI TX", cmd); + i = write(v->cli_fd, cmd, strlen(cmd)); + assert(i == strlen(cmd)); + i = write(v->cli_fd, "\n", 1); + assert(i == 1); + i = cli_readres(v->cli_fd, &retval, &r, 1000); + assert(i == 0); + printf("### %-4s CLI %u <%s>\n", v->name, retval, cmd); + vct_dump(v->name, "CLI RX", r); + if (repl != NULL) + *repl = r; + else + free(r); + return (retval); +} + +/********************************************************************** * Allocate and initialize a varnish */ @@ -92,7 +121,7 @@ v->name = name; v->args = ""; v->telnet = ":9001"; - v->accept = ":9002"; + v->accept = ":9081"; VTAILQ_INSERT_TAIL(&varnishes, v, list); return (v); } @@ -132,7 +161,7 @@ vsb = vsb_new(NULL, NULL, 0, VSB_AUTOEXTEND); AN(vsb); vsb_printf(vsb, "cd ../varnishd &&"); - vsb_printf(vsb, "./varnishd -d -d -n %s", v->name); + vsb_printf(vsb, " ./varnishd -d -d -n %s", v->name); vsb_printf(vsb, " -a %s -T %s", v->accept, v->telnet); vsb_printf(vsb, " %s", v->args); vsb_finish(vsb); @@ -144,10 +173,12 @@ assert(v->pid >= 0); if (v->pid == 0) { assert(dup2(v->fds[0], 0) == 0); + assert(dup2(v->fds[3], 1) == 1); + assert(dup2(1, 2) == 2); + AZ(close(v->fds[0])); AZ(close(v->fds[1])); AZ(close(v->fds[2])); - assert(dup2(v->fds[3], 1) == 1); - assert(dup2(1, 2) == 2); + AZ(close(v->fds[3])); AZ(execl("/bin/sh", "/bin/sh", "-c", vsb_data(vsb), NULL)); exit(1); } @@ -182,9 +213,27 @@ { varnish_launch(v); + varnish_ask_cli(v, "start", NULL); } /********************************************************************** + * Stop a Varnish + */ + +static void +varnish_stop(struct varnish *v) +{ + void *p; + + varnish_ask_cli(v, "stop", NULL); + AZ(kill(v->pid, SIGKILL)); + AZ(pthread_cancel(v->tp)); + AZ(pthread_join(v->tp, &p)); + close(v->fds[0]); + close(v->fds[1]); +} + +/********************************************************************** * Varnish server cmd dispatch */ @@ -239,6 +288,10 @@ varnish_start(v); continue; } + if (!strcmp(*av, "-stop")) { + varnish_stop(v); + continue; + } fprintf(stderr, "Unknown client argument: %s\n", *av); exit (1); } From phk at projects.linpro.no Mon Jun 16 22:15:27 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Tue, 17 Jun 2008 00:15:27 +0200 (CEST) Subject: r2708 - trunk/varnish-cache/bin/varnishtest Message-ID: <20080616221527.46C241EC209@projects.linpro.no> Author: phk Date: 2008-06-17 00:15:27 +0200 (Tue, 17 Jun 2008) New Revision: 2708 Modified: trunk/varnish-cache/bin/varnishtest/vtc_client.c Log: Use 9081 as default server address Modified: trunk/varnish-cache/bin/varnishtest/vtc_client.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_client.c 2008-06-16 22:14:56 UTC (rev 2707) +++ trunk/varnish-cache/bin/varnishtest/vtc_client.c 2008-06-16 22:15:27 UTC (rev 2708) @@ -101,7 +101,7 @@ ALLOC_OBJ(c, CLIENT_MAGIC); AN(c); c->name = name; - c->connect = ":8080"; + c->connect = ":9081"; VTAILQ_INSERT_TAIL(&clients, c, list); return (c); } From phk at projects.linpro.no Mon Jun 16 22:16:40 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Tue, 17 Jun 2008 00:16:40 +0200 (CEST) Subject: r2709 - trunk/varnish-cache/bin/varnishtest/tests Message-ID: <20080616221640.B98DF1EC8B2@projects.linpro.no> Author: phk Date: 2008-06-17 00:16:40 +0200 (Tue, 17 Jun 2008) New Revision: 2709 Added: trunk/varnish-cache/bin/varnishtest/tests/b00000.vtc Log: Add the first test-case that involves a varnish process Added: trunk/varnish-cache/bin/varnishtest/tests/b00000.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/b00000.vtc (rev 0) +++ trunk/varnish-cache/bin/varnishtest/tests/b00000.vtc 2008-06-16 22:16:40 UTC (rev 2709) @@ -0,0 +1,24 @@ +# Test that we get anything through at all +# +# $Id$ + +varnish v1 -arg "-b localhost:9080" -start + +server s1 -repeat 1 { + rxreq + txresp -hdr "Connection: close" -body "012345\n" +} + +server s1 -start + +client c1 { + txreq -url "/" + rxresp + expect resp.status == 200 +} + +client c1 -run + +server s1 -wait + +varnish v1 -stop Property changes on: trunk/varnish-cache/bin/varnishtest/tests/b00000.vtc ___________________________________________________________________ Name: svn:keywords + From phk at projects.linpro.no Mon Jun 16 22:31:28 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Tue, 17 Jun 2008 00:31:28 +0200 (CEST) Subject: r2710 - trunk/varnish-cache/bin/varnishtest/tests Message-ID: <20080616223128.2BC431EC209@projects.linpro.no> Author: phk Date: 2008-06-17 00:31:27 +0200 (Tue, 17 Jun 2008) New Revision: 2710 Modified: trunk/varnish-cache/bin/varnishtest/tests/b00000.vtc Log: remove redundant -repeat 1 Modified: trunk/varnish-cache/bin/varnishtest/tests/b00000.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/b00000.vtc 2008-06-16 22:16:40 UTC (rev 2709) +++ trunk/varnish-cache/bin/varnishtest/tests/b00000.vtc 2008-06-16 22:31:27 UTC (rev 2710) @@ -4,7 +4,7 @@ varnish v1 -arg "-b localhost:9080" -start -server s1 -repeat 1 { +server s1 { rxreq txresp -hdr "Connection: close" -body "012345\n" } From phk at projects.linpro.no Tue Jun 17 07:04:03 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Tue, 17 Jun 2008 09:04:03 +0200 (CEST) Subject: r2711 - trunk/varnish-cache/bin/varnishtest Message-ID: <20080617070403.9D4301EC0FD@projects.linpro.no> Author: phk Date: 2008-06-17 09:04:03 +0200 (Tue, 17 Jun 2008) New Revision: 2711 Removed: trunk/varnish-cache/bin/varnishtest/vtc_vcl.c Modified: trunk/varnish-cache/bin/varnishtest/Makefile.am trunk/varnish-cache/bin/varnishtest/t001.vtc trunk/varnish-cache/bin/varnishtest/vtc.c Log: We don't want a separate vcl command, it will be a subcommand of the varnish command. Modified: trunk/varnish-cache/bin/varnishtest/Makefile.am =================================================================== --- trunk/varnish-cache/bin/varnishtest/Makefile.am 2008-06-16 22:31:27 UTC (rev 2710) +++ trunk/varnish-cache/bin/varnishtest/Makefile.am 2008-06-17 07:04:03 UTC (rev 2711) @@ -10,8 +10,7 @@ vtc_http.c \ vtc_server.c \ vtc_stats.c \ - vtc_varnish.c \ - vtc_vcl.c + vtc_varnish.c varnishtest_LDADD = \ $(top_builddir)/lib/libvarnish/libvarnish.la \ Modified: trunk/varnish-cache/bin/varnishtest/t001.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/t001.vtc 2008-06-16 22:31:27 UTC (rev 2710) +++ trunk/varnish-cache/bin/varnishtest/t001.vtc 2008-06-17 07:04:03 UTC (rev 2711) @@ -2,75 +2,37 @@ # # $Id$ -server s1 -repeat 3 { - rxreq - expect url == "/" - txresponse -body "0123456789" -} +varnish v1 -arg -launch -server s1 -start - -client c1 { - txreq -url "/" - rxresponse - expect status == 200 - expect length == 10 -} - - -####################################################################### -# Test trivial pipe mode - -vcl { - $s1; - sub vcl_recv { - set req.backend = s1; +varnish v1 -vcl { + backend s1 { + .host = "localhost"; + .port = "9080"; + } + vcl_recv { pipe; } } -client c1 -run - -####################################################################### -# Test trivial pass mode - -vcl { - $s1; - sub vcl_recv { - set req.backend = s1; - pass; - } +server s1 -repeat 1 { + rxreq + txresp \ + -hdr "Connection: close" \ + -hdr "Test1: foobar" \ + -hdr "Test2: foobar" \ + -body "012345\n" } -client c1 -run +server s1 -start -####################################################################### -# Test trivial cache mode - -vcl { - $s1; - sub vcl_recv { - set req.backend = s1; - } +client c1 { + txreq -url "/" + rxresp + expect resp.status == 200 } client c1 -run server s1 -wait -####################################################################### -# And see that it stuck in cache - -client c1 -run - -varnish stop - -stats { - expect client_conn == 4 - expect client_req == 4 - expect cache_hit == 1 - expect cache_miss == 1 - expect s_pipe == 1 - expect s_pass == 1 - expect s_fetch == 2 -} +varnish v1 -stop Modified: trunk/varnish-cache/bin/varnishtest/vtc.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc.c 2008-06-16 22:31:27 UTC (rev 2710) +++ trunk/varnish-cache/bin/varnishtest/vtc.c 2008-06-17 07:04:03 UTC (rev 2711) @@ -266,7 +266,6 @@ static struct cmds cmds[] = { { "server", cmd_server }, { "client", cmd_client }, - { "vcl", cmd_vcl }, { "stats", cmd_stats }, { "varnish", cmd_varnish }, { "test", cmd_test }, Deleted: trunk/varnish-cache/bin/varnishtest/vtc_vcl.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_vcl.c 2008-06-16 22:31:27 UTC (rev 2710) +++ trunk/varnish-cache/bin/varnishtest/vtc_vcl.c 2008-06-17 07:04:03 UTC (rev 2711) @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2006-2008 Linpro AS - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $Id$ - */ - - -#include - -#include "vtc.h" - -void -cmd_vcl(char **av, void *priv) -{ - - cmd_dump(av, priv); -} From phk at projects.linpro.no Tue Jun 17 07:10:15 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Tue, 17 Jun 2008 09:10:15 +0200 (CEST) Subject: r2712 - trunk/varnish-cache/bin/varnishtest Message-ID: <20080617071015.0A5AD1EC0D3@projects.linpro.no> Author: phk Date: 2008-06-17 09:10:14 +0200 (Tue, 17 Jun 2008) New Revision: 2712 Modified: trunk/varnish-cache/bin/varnishtest/vtc.c trunk/varnish-cache/bin/varnishtest/vtc.h Log: Add a delay command, it takes second.fraction and uses usleep() below 100s and sleep() over. Modified: trunk/varnish-cache/bin/varnishtest/vtc.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc.c 2008-06-17 07:04:03 UTC (rev 2711) +++ trunk/varnish-cache/bin/varnishtest/vtc.c 2008-06-17 07:10:14 UTC (rev 2712) @@ -249,10 +249,32 @@ /********************************************************************** - * Execute a file + * Dump command arguments */ void +cmd_delay(char **av, void *priv) +{ + double f; + + (void)priv; + if (av == NULL) + return; + AN(av[1]); + AZ(av[2]); + f = strtod(av[1], NULL); + if (f > 100.) { + sleep((int)f); + } else { + usleep((int)(f * 1e6)); + } +} + +/********************************************************************** + * Dump command arguments + */ + +void cmd_dump(char **av, void *priv) { @@ -263,11 +285,16 @@ printf("\t<%s>\n", *av++); } +/********************************************************************** + * Execute a file + */ + static struct cmds cmds[] = { { "server", cmd_server }, { "client", cmd_client }, { "stats", cmd_stats }, { "varnish", cmd_varnish }, + { "delay", cmd_delay }, { "test", cmd_test }, { NULL, NULL } }; @@ -294,6 +321,7 @@ int ch; setbuf(stdout, NULL); + setbuf(stderr, NULL); while ((ch = getopt(argc, argv, "")) != -1) { switch (ch) { case '?': Modified: trunk/varnish-cache/bin/varnishtest/vtc.h =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc.h 2008-06-17 07:04:03 UTC (rev 2711) +++ trunk/varnish-cache/bin/varnishtest/vtc.h 2008-06-17 07:10:14 UTC (rev 2712) @@ -36,6 +36,8 @@ void parse_string(char *buf, const struct cmds *cmd, void *priv); void cmd_dump(char **av, void *priv); +void cmd_delay(char **av, void *priv); + void cmd_server(char **av, void *priv); void cmd_client(char **av, void *priv); void cmd_vcl(char **av, void *priv); From phk at projects.linpro.no Tue Jun 17 07:24:20 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Tue, 17 Jun 2008 09:24:20 +0200 (CEST) Subject: r2713 - in trunk/varnish-cache: bin/varnishtest include Message-ID: <20080617072421.039BA1EC8B2@projects.linpro.no> Author: phk Date: 2008-06-17 09:24:20 +0200 (Tue, 17 Jun 2008) New Revision: 2713 Modified: trunk/varnish-cache/bin/varnishtest/t001.vtc trunk/varnish-cache/bin/varnishtest/vtc_varnish.c trunk/varnish-cache/include/vsb.h Log: Add a vsb_newauto() macro Modified: trunk/varnish-cache/bin/varnishtest/t001.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/t001.vtc 2008-06-17 07:10:14 UTC (rev 2712) +++ trunk/varnish-cache/bin/varnishtest/t001.vtc 2008-06-17 07:24:20 UTC (rev 2713) @@ -2,8 +2,10 @@ # # $Id$ -varnish v1 -arg -launch +varnish v1 -launch +delay 1 + varnish v1 -vcl { backend s1 { .host = "localhost"; @@ -14,6 +16,10 @@ } } +delay 1 + +varnish v1 -start + server s1 -repeat 1 { rxreq txresp \ Modified: trunk/varnish-cache/bin/varnishtest/vtc_varnish.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_varnish.c 2008-06-17 07:10:14 UTC (rev 2712) +++ trunk/varnish-cache/bin/varnishtest/vtc_varnish.c 2008-06-17 07:24:20 UTC (rev 2713) @@ -30,6 +30,7 @@ #include #include +#include #include #include #include @@ -70,6 +71,7 @@ struct vss_addr **vss_addr; int cli_fd; + int vcl_nbr; }; static VTAILQ_HEAD(, varnish) varnishes = @@ -234,6 +236,42 @@ } /********************************************************************** + * Load a VCL program + */ + +static void +varnish_vcl(struct varnish *v, char *vcl) +{ + struct vsb *vsb; + unsigned u; + + vsb = vsb_newauto(); + AN(vsb); + + v->vcl_nbr++; + vsb_printf(vsb, "vcl.inline vcl%d \"", v->vcl_nbr); + for (; *vcl != '\0'; vcl++) { + if (isgraph(*vcl) || *vcl == '\\' || *vcl == '"') + vsb_putc(vsb, *vcl); + else + vsb_printf(vsb, "\\x%02x", *vcl); + } + vsb_printf(vsb, "\"", *vcl); + vsb_finish(vsb); + AZ(vsb_overflowed(vsb)); + + u = varnish_ask_cli(v, vsb_data(vsb), NULL); + assert(u == CLIS_OK); + vsb_clear(vsb); + vsb_printf(vsb, "vcl.use vcl%d \"", v->vcl_nbr); + vsb_finish(vsb); + AZ(vsb_overflowed(vsb)); + u = varnish_ask_cli(v, vsb_data(vsb), NULL); + assert(u == CLIS_OK); + vsb_delete(vsb); +} + +/********************************************************************** * Varnish server cmd dispatch */ @@ -288,11 +326,16 @@ varnish_start(v); continue; } + if (!strcmp(*av, "-vcl")) { + varnish_vcl(v, av[1]); + av++; + continue; + } if (!strcmp(*av, "-stop")) { varnish_stop(v); continue; } - fprintf(stderr, "Unknown client argument: %s\n", *av); + fprintf(stderr, "Unknown varnish argument: %s\n", *av); exit (1); } } Modified: trunk/varnish-cache/include/vsb.h =================================================================== --- trunk/varnish-cache/include/vsb.h 2008-06-17 07:10:14 UTC (rev 2712) +++ trunk/varnish-cache/include/vsb.h 2008-06-17 07:24:20 UTC (rev 2713) @@ -57,6 +57,7 @@ * API functions */ struct vsb *vsb_new(struct vsb *, char *, int, int); +#define vsb_newauto() vsb_new(NULL, NULL, 0, VSB_AUTOEXTEND) void vsb_clear(struct vsb *); int vsb_setpos(struct vsb *, int); int vsb_bcat(struct vsb *, const void *, size_t); From phk at projects.linpro.no Tue Jun 17 07:30:21 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Tue, 17 Jun 2008 09:30:21 +0200 (CEST) Subject: r2714 - trunk/varnish-cache/bin/varnishtest Message-ID: <20080617073021.66DC61ED3E4@projects.linpro.no> Author: phk Date: 2008-06-17 09:30:16 +0200 (Tue, 17 Jun 2008) New Revision: 2714 Modified: trunk/varnish-cache/bin/varnishtest/vtc_varnish.c Log: Add -vcl option varnish command, to load inline VCL code. Modified: trunk/varnish-cache/bin/varnishtest/vtc_varnish.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_varnish.c 2008-06-17 07:24:20 UTC (rev 2713) +++ trunk/varnish-cache/bin/varnishtest/vtc_varnish.c 2008-06-17 07:30:16 UTC (rev 2714) @@ -250,11 +250,21 @@ v->vcl_nbr++; vsb_printf(vsb, "vcl.inline vcl%d \"", v->vcl_nbr); - for (; *vcl != '\0'; vcl++) { - if (isgraph(*vcl) || *vcl == '\\' || *vcl == '"') - vsb_putc(vsb, *vcl); - else - vsb_printf(vsb, "\\x%02x", *vcl); + for (vcl++; vcl[1] != '\0'; vcl++) { + switch (*vcl) { + case '\\': + case '"': + vsb_printf(vsb, "\\%c", *vcl); break; + case '\n': + vsb_printf(vsb, "\\n"); break; + case '\t': + vsb_printf(vsb, "\\t"); break; + default: + if (isgraph(*vcl) || *vcl == ' ') + vsb_putc(vsb, *vcl); + else + vsb_printf(vsb, "\\x%02x", *vcl); + } } vsb_printf(vsb, "\"", *vcl); vsb_finish(vsb); @@ -263,7 +273,7 @@ u = varnish_ask_cli(v, vsb_data(vsb), NULL); assert(u == CLIS_OK); vsb_clear(vsb); - vsb_printf(vsb, "vcl.use vcl%d \"", v->vcl_nbr); + vsb_printf(vsb, "vcl.use vcl%d", v->vcl_nbr); vsb_finish(vsb); AZ(vsb_overflowed(vsb)); u = varnish_ask_cli(v, vsb_data(vsb), NULL); From phk at projects.linpro.no Tue Jun 17 07:32:43 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Tue, 17 Jun 2008 09:32:43 +0200 (CEST) Subject: r2715 - trunk/varnish-cache/bin/varnishtest Message-ID: <20080617073243.C1E241EC8B2@projects.linpro.no> Author: phk Date: 2008-06-17 09:32:43 +0200 (Tue, 17 Jun 2008) New Revision: 2715 Modified: trunk/varnish-cache/bin/varnishtest/t001.vtc trunk/varnish-cache/bin/varnishtest/vtc_http.c Log: allow delays in http procssing (client & server) Modified: trunk/varnish-cache/bin/varnishtest/t001.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/t001.vtc 2008-06-17 07:30:16 UTC (rev 2714) +++ trunk/varnish-cache/bin/varnishtest/t001.vtc 2008-06-17 07:32:43 UTC (rev 2715) @@ -4,20 +4,16 @@ varnish v1 -launch -delay 1 - varnish v1 -vcl { backend s1 { .host = "localhost"; .port = "9080"; } - vcl_recv { + sub vcl_recv { pipe; } } -delay 1 - varnish v1 -start server s1 -repeat 1 { Modified: trunk/varnish-cache/bin/varnishtest/vtc_http.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_http.c 2008-06-17 07:30:16 UTC (rev 2714) +++ trunk/varnish-cache/bin/varnishtest/vtc_http.c 2008-06-17 07:32:43 UTC (rev 2715) @@ -465,6 +465,7 @@ { "txresp", cmd_http_txresp }, { "rxresp", cmd_http_rxresp }, { "expect", cmd_http_expect }, + { "delay", cmd_delay }, { NULL, NULL } }; From phk at projects.linpro.no Tue Jun 17 07:37:28 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Tue, 17 Jun 2008 09:37:28 +0200 (CEST) Subject: r2716 - in trunk/varnish-cache: bin/varnishd bin/varnishlog bin/varnishtest lib/libvcl Message-ID: <20080617073728.22CEF1EC0D3@projects.linpro.no> Author: phk Date: 2008-06-17 09:37:27 +0200 (Tue, 17 Jun 2008) New Revision: 2716 Modified: trunk/varnish-cache/bin/varnishd/cache_cli.c trunk/varnish-cache/bin/varnishd/cache_vary.c trunk/varnish-cache/bin/varnishd/mgt_cli.c trunk/varnish-cache/bin/varnishd/mgt_vcc.c trunk/varnish-cache/bin/varnishd/varnishd.c trunk/varnish-cache/bin/varnishlog/varnishlog.c trunk/varnish-cache/bin/varnishtest/vtc.c trunk/varnish-cache/bin/varnishtest/vtc_http.c trunk/varnish-cache/bin/varnishtest/vtc_varnish.c trunk/varnish-cache/lib/libvcl/vcc_compile.c Log: Use vsb_newauto() macro throughout Modified: trunk/varnish-cache/bin/varnishd/cache_cli.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_cli.c 2008-06-17 07:32:43 UTC (rev 2715) +++ trunk/varnish-cache/bin/varnishd/cache_cli.c 2008-06-17 07:37:27 UTC (rev 2716) @@ -142,7 +142,7 @@ cli = &clis; memset(cli, 0, sizeof *cli); - cli->sb = vsb_new(NULL, NULL, 0, VSB_AUTOEXTEND); + cli->sb = vsb_newauto(); XXXAN(cli->sb); vlu = VLU_New(cli, cli_vlu, params->cli_buffer); XXXAN(vlu); Modified: trunk/varnish-cache/bin/varnishd/cache_vary.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_vary.c 2008-06-17 07:32:43 UTC (rev 2715) +++ trunk/varnish-cache/bin/varnishd/cache_vary.c 2008-06-17 07:37:27 UTC (rev 2716) @@ -74,11 +74,11 @@ return; /* For vary matching string */ - sb = vsb_new(NULL, NULL, 0, VSB_AUTOEXTEND); + sb = vsb_newauto(); AN(sb); /* For header matching strings */ - sbh = vsb_new(NULL, NULL, 0, VSB_AUTOEXTEND); + sbh = vsb_newauto(); AN(sbh); for (p = v; *p; p++) { Modified: trunk/varnish-cache/bin/varnishd/mgt_cli.c =================================================================== --- trunk/varnish-cache/bin/varnishd/mgt_cli.c 2008-06-17 07:32:43 UTC (rev 2715) +++ trunk/varnish-cache/bin/varnishd/mgt_cli.c 2008-06-17 07:37:27 UTC (rev 2716) @@ -353,7 +353,7 @@ cp->fdo = fdo; cp->verbose = verbose; - cp->cli->sb = vsb_new(NULL, NULL, 0, VSB_AUTOEXTEND); + cp->cli->sb = vsb_newauto(); XXXAN(cp->cli->sb); cp->ev = calloc(sizeof *cp->ev, 1); Modified: trunk/varnish-cache/bin/varnishd/mgt_vcc.c =================================================================== --- trunk/varnish-cache/bin/varnishd/mgt_vcc.c 2008-06-17 07:32:43 UTC (rev 2715) +++ trunk/varnish-cache/bin/varnishd/mgt_vcc.c 2008-06-17 07:37:27 UTC (rev 2716) @@ -402,7 +402,7 @@ struct vsb *sb; struct vclprog *vp; - sb = vsb_new(NULL, NULL, 0, VSB_AUTOEXTEND); + sb = vsb_newauto(); XXXAN(sb); if (b_arg != NULL) { /* @@ -529,7 +529,7 @@ (void)priv; - sb = vsb_new(NULL, NULL, 0, VSB_AUTOEXTEND); + sb = vsb_newauto(); XXXAN(sb); vf = mgt_VccCompile(sb, av[3], NULL, 0); vsb_finish(sb); @@ -563,7 +563,7 @@ (void)priv; - sb = vsb_new(NULL, NULL, 0, VSB_AUTOEXTEND); + sb = vsb_newauto(); XXXAN(sb); vf = mgt_VccCompileFile(sb, av[3], 0, -1); vsb_finish(sb); Modified: trunk/varnish-cache/bin/varnishd/varnishd.c =================================================================== --- trunk/varnish-cache/bin/varnishd/varnishd.c 2008-06-17 07:32:43 UTC (rev 2715) +++ trunk/varnish-cache/bin/varnishd/varnishd.c 2008-06-17 07:37:27 UTC (rev 2716) @@ -382,7 +382,7 @@ tzset(); memset(cli, 0, sizeof cli); - cli[0].sb = vsb_new(NULL, NULL, 0, VSB_AUTOEXTEND); + cli[0].sb = vsb_newauto(); XXXAN(cli[0].sb); cli[0].result = CLIS_OK; Modified: trunk/varnish-cache/bin/varnishlog/varnishlog.c =================================================================== --- trunk/varnish-cache/bin/varnishlog/varnishlog.c 2008-06-17 07:32:43 UTC (rev 2715) +++ trunk/varnish-cache/bin/varnishlog/varnishlog.c 2008-06-17 07:37:27 UTC (rev 2716) @@ -134,7 +134,7 @@ return (0); } if (ob[fd] == NULL) { - ob[fd] = vsb_new(NULL, NULL, 0, VSB_AUTOEXTEND); + ob[fd] = vsb_newauto(); assert(ob[fd] != NULL); } if (tag == match_tag && Modified: trunk/varnish-cache/bin/varnishtest/vtc.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc.c 2008-06-17 07:32:43 UTC (rev 2715) +++ trunk/varnish-cache/bin/varnishtest/vtc.c 2008-06-17 07:37:27 UTC (rev 2716) @@ -53,7 +53,7 @@ if (pfx == NULL) pfx = ""; - vsb = vsb_new(NULL, NULL, 0, VSB_AUTOEXTEND); + vsb = vsb_newauto(); if (str == NULL) vsb_printf(vsb, "#### %-4s %s(null)\n", ident, pfx); else Modified: trunk/varnish-cache/bin/varnishtest/vtc_http.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_http.c 2008-06-17 07:32:43 UTC (rev 2715) +++ trunk/varnish-cache/bin/varnishtest/vtc_http.c 2008-06-17 07:37:27 UTC (rev 2716) @@ -306,7 +306,7 @@ assert(!strcmp(av[0], "txresp")); av++; - vsb = vsb_new(NULL, NULL, 0, VSB_AUTOEXTEND); + vsb = vsb_newauto(); for(; *av != NULL; av++) { if (!strcmp(*av, "-proto")) { @@ -407,7 +407,7 @@ assert(!strcmp(av[0], "txreq")); av++; - vsb = vsb_new(NULL, NULL, 0, VSB_AUTOEXTEND); + vsb = vsb_newauto(); for(; *av != NULL; av++) { if (!strcmp(*av, "-url")) { Modified: trunk/varnish-cache/bin/varnishtest/vtc_varnish.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_varnish.c 2008-06-17 07:32:43 UTC (rev 2715) +++ trunk/varnish-cache/bin/varnishtest/vtc_varnish.c 2008-06-17 07:37:27 UTC (rev 2716) @@ -160,7 +160,7 @@ struct vsb *vsb; int i; - vsb = vsb_new(NULL, NULL, 0, VSB_AUTOEXTEND); + vsb = vsb_newauto(); AN(vsb); vsb_printf(vsb, "cd ../varnishd &&"); vsb_printf(vsb, " ./varnishd -d -d -n %s", v->name); Modified: trunk/varnish-cache/lib/libvcl/vcc_compile.c =================================================================== --- trunk/varnish-cache/lib/libvcl/vcc_compile.c 2008-06-17 07:32:43 UTC (rev 2715) +++ trunk/varnish-cache/lib/libvcl/vcc_compile.c 2008-06-17 07:37:27 UTC (rev 2716) @@ -490,24 +490,24 @@ tl->nsources = 0; /* General C code */ - tl->fc = vsb_new(NULL, NULL, 0, VSB_AUTOEXTEND); + tl->fc = vsb_newauto(); assert(tl->fc != NULL); /* Forward decls (.h like) */ - tl->fh = vsb_new(NULL, NULL, 0, VSB_AUTOEXTEND); + tl->fh = vsb_newauto(); assert(tl->fh != NULL); /* Init C code */ - tl->fi = vsb_new(NULL, NULL, 0, VSB_AUTOEXTEND); + tl->fi = vsb_newauto(); assert(tl->fi != NULL); /* Finish C code */ - tl->ff = vsb_new(NULL, NULL, 0, VSB_AUTOEXTEND); + tl->ff = vsb_newauto(); assert(tl->ff != NULL); /* body code of methods */ for (i = 0; i < N_METHODS; i++) { - tl->fm[i] = vsb_new(NULL, NULL, 0, VSB_AUTOEXTEND); \ + tl->fm[i] = vsb_newauto(); assert(tl->fm[i] != NULL); } return (tl); From phk at projects.linpro.no Tue Jun 17 07:53:21 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Tue, 17 Jun 2008 09:53:21 +0200 (CEST) Subject: r2717 - trunk/varnish-cache/bin/varnishtest Message-ID: <20080617075321.97CAF1EC208@projects.linpro.no> Author: phk Date: 2008-06-17 09:53:21 +0200 (Tue, 17 Jun 2008) New Revision: 2717 Modified: trunk/varnish-cache/bin/varnishtest/vtc.h trunk/varnish-cache/bin/varnishtest/vtc_server.c trunk/varnish-cache/bin/varnishtest/vtc_varnish.c Log: Add a -vcl+backend argument to the varnish command which autogenerates backend stanzas for the servers we know about. Modified: trunk/varnish-cache/bin/varnishtest/vtc.h =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc.h 2008-06-17 07:37:27 UTC (rev 2716) +++ trunk/varnish-cache/bin/varnishtest/vtc.h 2008-06-17 07:53:21 UTC (rev 2717) @@ -28,6 +28,8 @@ typedef void cmd_f(char **av, void *priv); +struct vsb; + struct cmds { const char *name; cmd_f *cmd; @@ -47,3 +49,5 @@ void http_process(const char *ident, const char *spec, int sock, int client); void vct_dump(const char *ident, const char *pfx, const char *str); + +void cmd_server_genvcl(struct vsb *vsb); Modified: trunk/varnish-cache/bin/varnishtest/vtc_server.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_server.c 2008-06-17 07:37:27 UTC (rev 2716) +++ trunk/varnish-cache/bin/varnishtest/vtc_server.c 2008-06-17 07:53:21 UTC (rev 2717) @@ -40,6 +40,7 @@ #include "vqueue.h" #include "miniobj.h" +#include "vsb.h" #include "vss.h" #include "libvarnish.h" @@ -116,6 +117,7 @@ AN(s); s->name = name; s->listen = ":9080"; + AZ(VSS_parse(s->listen, &s->addr, &s->port)); s->repeat = 1; s->depth = 1; s->sock = -1; @@ -135,7 +137,6 @@ CHECK_OBJ_NOTNULL(s, SERVER_MAGIC); printf("## %-4s Starting server\n", s->name); if (s->sock < 0) { - AZ(VSS_parse(s->listen, &s->addr, &s->port)); naddr = VSS_resolve(s->addr, s->port, &s->vss_addr); if (naddr != 1) { fprintf(stderr, @@ -175,6 +176,25 @@ } /********************************************************************** + * Generate VCL backend decls for our servers + */ + +void +cmd_server_genvcl(struct vsb *vsb) +{ + struct server *s; + + VTAILQ_FOREACH(s, &servers, list) { + vsb_printf(vsb, + "backend %s { .host = \"%s\"; .port = \"%s\"; }\n", + s->name, + s->addr == NULL ? "localhost" : s->addr, + s->port); + } +} + + +/********************************************************************** * Server command dispatch */ @@ -213,6 +233,7 @@ } if (!strcmp(*av, "-listen")) { s->listen = av[1]; + AZ(VSS_parse(s->listen, &s->addr, &s->port)); av++; continue; } Modified: trunk/varnish-cache/bin/varnishtest/vtc_varnish.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_varnish.c 2008-06-17 07:37:27 UTC (rev 2716) +++ trunk/varnish-cache/bin/varnishtest/vtc_varnish.c 2008-06-17 07:53:21 UTC (rev 2717) @@ -104,6 +104,28 @@ return (retval); } +static void +varnish_cli_encode(struct vsb *vsb, const char *str) +{ + + for (; *str != '\0'; str++) { + switch (*str) { + case '\\': + case '"': + vsb_printf(vsb, "\\%c", *str); break; + case '\n': + vsb_printf(vsb, "\\n"); break; + case '\t': + vsb_printf(vsb, "\\t"); break; + default: + if (isgraph(*str) || *str == ' ') + vsb_putc(vsb, *str); + else + vsb_printf(vsb, "\\x%02x", *str); + } + } +} + /********************************************************************** * Allocate and initialize a varnish */ @@ -282,6 +304,55 @@ } /********************************************************************** + * Load a VCL program prefixed by backend decls for our servers + */ + +static void +varnish_vclbackend(struct varnish *v, char *vcl) +{ + struct vsb *vsb, *vsb2; + char *p; + unsigned u; + + vsb = vsb_newauto(); + AN(vsb); + + vsb2 = vsb_newauto(); + AN(vsb2); + + cmd_server_genvcl(vsb2); + vsb_finish(vsb2); + AZ(vsb_overflowed(vsb2)); + + v->vcl_nbr++; + vsb_printf(vsb, "vcl.inline vcl%d \"", v->vcl_nbr); + + varnish_cli_encode(vsb, vsb_data(vsb2)); + + if (*vcl == '{') { + p = strchr(++vcl, '\0'); + if (p > vcl && p[-1] == '}') + p[-1] = '\0'; + } + varnish_cli_encode(vsb, vcl); + + vsb_printf(vsb, "\"", *vcl); + vsb_finish(vsb); + AZ(vsb_overflowed(vsb)); + + u = varnish_ask_cli(v, vsb_data(vsb), NULL); + assert(u == CLIS_OK); + vsb_clear(vsb); + vsb_printf(vsb, "vcl.use vcl%d", v->vcl_nbr); + vsb_finish(vsb); + AZ(vsb_overflowed(vsb)); + u = varnish_ask_cli(v, vsb_data(vsb), NULL); + assert(u == CLIS_OK); + vsb_delete(vsb); + vsb_delete(vsb2); +} + +/********************************************************************** * Varnish server cmd dispatch */ @@ -336,6 +407,11 @@ varnish_start(v); continue; } + if (!strcmp(*av, "-vcl+backend")) { + varnish_vclbackend(v, av[1]); + av++; + continue; + } if (!strcmp(*av, "-vcl")) { varnish_vcl(v, av[1]); av++; From phk at projects.linpro.no Tue Jun 17 08:03:58 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Tue, 17 Jun 2008 10:03:58 +0200 (CEST) Subject: r2718 - trunk/varnish-cache/bin/varnishtest Message-ID: <20080617080358.6820B1EC0FD@projects.linpro.no> Author: phk Date: 2008-06-17 10:03:58 +0200 (Tue, 17 Jun 2008) New Revision: 2718 Modified: trunk/varnish-cache/bin/varnishtest/vtc_varnish.c Log: Add varnish -wait and make varnish -stop mean the logical thing Modified: trunk/varnish-cache/bin/varnishtest/vtc_varnish.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_varnish.c 2008-06-17 07:53:21 UTC (rev 2717) +++ trunk/varnish-cache/bin/varnishtest/vtc_varnish.c 2008-06-17 08:03:58 UTC (rev 2718) @@ -146,6 +146,7 @@ v->args = ""; v->telnet = ":9001"; v->accept = ":9081"; + v->cli_fd = -1; VTAILQ_INSERT_TAIL(&varnishes, v, list); return (v); } @@ -182,6 +183,7 @@ struct vsb *vsb; int i; + printf("## %-4s Launch\n", v->name); vsb = vsb_newauto(); AN(vsb); vsb_printf(vsb, "cd ../varnishd &&"); @@ -226,6 +228,7 @@ exit (1); } printf("### %-4s CLI connection fd = %d\n", v->name, v->cli_fd); + assert(v->cli_fd >= 0); } /********************************************************************** @@ -236,7 +239,9 @@ varnish_start(struct varnish *v) { - varnish_launch(v); + if (v->cli_fd < 0) + varnish_launch(v); + printf("## %-4s Start\n", v->name); varnish_ask_cli(v, "start", NULL); } @@ -247,14 +252,33 @@ static void varnish_stop(struct varnish *v) { + + if (v->cli_fd < 0) + varnish_launch(v); + printf("## %-4s Stop\n", v->name); + varnish_ask_cli(v, "stop", NULL); +} + +/********************************************************************** + * Wait for a Varnish + */ + +static void +varnish_wait(struct varnish *v) +{ void *p; - varnish_ask_cli(v, "stop", NULL); + if (v->cli_fd < 0) + return; + varnish_stop(v); + printf("## %-4s Wait\n", v->name); AZ(kill(v->pid, SIGKILL)); AZ(pthread_cancel(v->tp)); AZ(pthread_join(v->tp, &p)); close(v->fds[0]); close(v->fds[1]); + close(v->cli_fd); + v->cli_fd = -1; } /********************************************************************** @@ -366,6 +390,8 @@ if (av == NULL) { /* Reset and free */ VTAILQ_FOREACH_SAFE(v, &varnishes, list, v2) { + if (v->cli_fd >= 0) + varnish_wait(v); VTAILQ_REMOVE(&varnishes, v, list); FREE_OBJ(v); /* XXX: MEMLEAK */ @@ -421,6 +447,10 @@ varnish_stop(v); continue; } + if (!strcmp(*av, "-wait")) { + varnish_wait(v); + continue; + } fprintf(stderr, "Unknown varnish argument: %s\n", *av); exit (1); } From phk at projects.linpro.no Tue Jun 17 08:18:43 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Tue, 17 Jun 2008 10:18:43 +0200 (CEST) Subject: r2719 - trunk/varnish-cache/bin/varnishd Message-ID: <20080617081843.5E1161ED2CC@projects.linpro.no> Author: phk Date: 2008-06-17 10:18:42 +0200 (Tue, 17 Jun 2008) New Revision: 2719 Modified: trunk/varnish-cache/bin/varnishd/mgt_event.c Log: Assert that the event manager found something for each pending fd. Modified: trunk/varnish-cache/bin/varnishd/mgt_event.c =================================================================== --- trunk/varnish-cache/bin/varnishd/mgt_event.c 2008-06-17 08:03:58 UTC (rev 2718) +++ trunk/varnish-cache/bin/varnishd/mgt_event.c 2008-06-17 08:18:42 UTC (rev 2719) @@ -480,5 +480,6 @@ free(e); } } + assert(i == 0); return (1); } From phk at projects.linpro.no Tue Jun 17 08:57:47 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Tue, 17 Jun 2008 10:57:47 +0200 (CEST) Subject: r2720 - trunk/varnish-cache/bin/varnishtest Message-ID: <20080617085747.451F01EC0FD@projects.linpro.no> Author: phk Date: 2008-06-17 10:57:46 +0200 (Tue, 17 Jun 2008) New Revision: 2720 Modified: trunk/varnish-cache/bin/varnishtest/vtc_http.c Log: Use POLLIN instead of POLLRDNORM Modified: trunk/varnish-cache/bin/varnishtest/vtc_http.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_http.c 2008-06-17 08:18:42 UTC (rev 2719) +++ trunk/varnish-cache/bin/varnishtest/vtc_http.c 2008-06-17 08:57:46 UTC (rev 2720) @@ -234,7 +234,7 @@ l = 0; while (1) { pfd[0].fd = hp->fd; - pfd[0].events = POLLRDNORM; + pfd[0].events = POLLIN; pfd[0].revents = 0; i = poll(pfd, 1, hp->timeout); assert(i > 0); From phk at projects.linpro.no Tue Jun 17 09:21:58 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Tue, 17 Jun 2008 11:21:58 +0200 (CEST) Subject: r2721 - trunk/varnish-cache/bin/varnishd Message-ID: <20080617092158.ECC8C1EC208@projects.linpro.no> Author: phk Date: 2008-06-17 11:21:58 +0200 (Tue, 17 Jun 2008) New Revision: 2721 Modified: trunk/varnish-cache/bin/varnishd/mgt_event.c Log: Hack up a crude debugging facility for the event manager. Modified: trunk/varnish-cache/bin/varnishd/mgt_event.c =================================================================== --- trunk/varnish-cache/bin/varnishd/mgt_event.c 2008-06-17 08:57:46 UTC (rev 2720) +++ trunk/varnish-cache/bin/varnishd/mgt_event.c 2008-06-17 09:21:58 UTC (rev 2721) @@ -72,10 +72,24 @@ unsigned char disturbed; unsigned psig; pthread_t thread; + FILE *debug; }; /*--------------------------------------------------------------------*/ +#undef DEBUG_EVENTS + +#ifdef DEBUG_EVENTS +#define DBG(evb, ...) do { \ + if ((evb)->debug != NULL) \ + fprintf((evb)->debug, __VA_ARGS__); \ + } while (0); +#else +#define DBG(evb, ...) /* ... */ +#endif + +/*--------------------------------------------------------------------*/ + static void ev_bh_update(void *priv, void *a, unsigned u) { @@ -180,6 +194,12 @@ VTAILQ_INIT(&evb->events); evb->binheap = binheap_new(evb, ev_bh_cmp, ev_bh_update); evb->thread = pthread_self(); +#ifdef DEBUG_EVENTS + evb->debug = fopen("/tmp/_.events", "w"); + AN(evb->debug); + setbuf(evb->debug, NULL); + DBG(evb, "\n\nStart debugging\n"); +#endif return (evb); } @@ -222,6 +242,7 @@ assert(e->timeout >= 0.0); assert(e->fd < 0 || e->fd_flags); assert(evb->thread == pthread_self()); + DBG(evb, "ev_add(%p) fd = %d\n", e, e->fd); if (e->sig > 0 && ev_get_sig(e->sig)) return (ENOMEM); @@ -249,6 +270,8 @@ e->fd_flags & (EV_RD|EV_WR|EV_ERR|EV_HUP); e->__poll_idx = evb->lpfd; evb->lpfd++; + DBG(evb, "... pidx = %d lpfd = %d\n", + e->__poll_idx, evb->lpfd); } else e->__poll_idx = -1; @@ -258,6 +281,7 @@ e->__when += TIM_mono() + e->timeout; binheap_insert(evb->binheap, e); assert(e->__binheap_idx > 0); + DBG(evb, "... bidx = %d\n", e->__binheap_idx); } else { e->__when = 0.0; e->__binheap_idx = 0; @@ -287,6 +311,7 @@ CHECK_OBJ_NOTNULL(evb, EVBASE_MAGIC); CHECK_OBJ_NOTNULL(e, EV_MAGIC); + DBG(evb, "ev_del(%p) fd = %d\n", e, e->fd); assert(evb == e->__evb); assert(evb->thread == pthread_self()); @@ -295,12 +320,14 @@ assert(e->__binheap_idx == 0); if (e->fd >= 0) { + DBG(evb, "... pidx = %d\n", e->__poll_idx); evb->pfd[e->__poll_idx].fd = -1; if (e->__poll_idx == evb->lpfd - 1) evb->lpfd--; else evb->compact_pfd++; e->fd = -1; + DBG(evb, "... lpfd = %d\n", evb->lpfd); } if (e->sig > 0) { @@ -461,6 +488,8 @@ assert(pfd->fd == e->fd); if (!pfd->revents) continue; + DBG(evb, "callback(%p) fd = %d what = 0x%x pidx = %d\n", + e, e->fd, pfd->revents, e->__poll_idx); j = e->callback(e, pfd->revents); i--; if (evb->disturbed) { From phk at projects.linpro.no Tue Jun 17 09:37:45 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Tue, 17 Jun 2008 11:37:45 +0200 (CEST) Subject: r2722 - trunk/varnish-cache/bin/varnishd Message-ID: <20080617093745.426031EC0FD@projects.linpro.no> Author: phk Date: 2008-06-17 11:37:44 +0200 (Tue, 17 Jun 2008) New Revision: 2722 Modified: trunk/varnish-cache/bin/varnishd/mgt_event.c Log: Fix broken logic in the poll-fd compaction function, which resulted in a panic during this sequence: varnishd -d -d -T :8082 ctrl-D telnet localhost 8082 (from other terminal) Modified: trunk/varnish-cache/bin/varnishd/mgt_event.c =================================================================== --- trunk/varnish-cache/bin/varnishd/mgt_event.c 2008-06-17 09:21:58 UTC (rev 2721) +++ trunk/varnish-cache/bin/varnishd/mgt_event.c 2008-06-17 09:37:44 UTC (rev 2722) @@ -373,23 +373,26 @@ unsigned u; struct pollfd *p; struct ev *ep; + int lfd; + DBG(evb, "compact_pfd() lpfd = %d\n", evb->lpfd); p = evb->pfd; - ep = VTAILQ_FIRST(&evb->events); for (u = 0; u < evb->lpfd; u++, p++) { + DBG(evb, "...[%d] fd = %d\n", u, p->fd); if (p->fd >= 0) continue; - for(; ep != NULL; ep = VTAILQ_NEXT(ep, __list)) { - if (ep->fd >= 0 && ep->__poll_idx > u) + lfd = evb->pfd[evb->lpfd - 1].fd; + VTAILQ_FOREACH(ep, &evb->events, __list) + if (ep->fd == lfd) break; - } - if (ep == NULL) - break; - *p = evb->pfd[ep->__poll_idx]; + AN(ep); + DBG(evb, "...[%d] move %p pidx %d\n", u, ep, ep->__poll_idx); + *p = evb->pfd[--evb->lpfd]; ep->__poll_idx = u; } evb->lpfd = u; evb->compact_pfd = 0; + DBG(evb, "... lpfd = %d\n", evb->lpfd); } /*--------------------------------------------------------------------*/ From phk at projects.linpro.no Tue Jun 17 10:11:45 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Tue, 17 Jun 2008 12:11:45 +0200 (CEST) Subject: r2723 - trunk/varnish-cache/bin/varnishd Message-ID: <20080617101145.0E66A1ED30D@projects.linpro.no> Author: phk Date: 2008-06-17 12:11:44 +0200 (Tue, 17 Jun 2008) New Revision: 2723 Modified: trunk/varnish-cache/bin/varnishd/mgt_event.c Log: Fix another corner case in teardown of the event manager. Modified: trunk/varnish-cache/bin/varnishd/mgt_event.c =================================================================== --- trunk/varnish-cache/bin/varnishd/mgt_event.c 2008-06-17 09:37:44 UTC (rev 2722) +++ trunk/varnish-cache/bin/varnishd/mgt_event.c 2008-06-17 10:11:44 UTC (rev 2723) @@ -381,6 +381,8 @@ DBG(evb, "...[%d] fd = %d\n", u, p->fd); if (p->fd >= 0) continue; + if (u == evb->lpfd - 1) + break; lfd = evb->pfd[evb->lpfd - 1].fd; VTAILQ_FOREACH(ep, &evb->events, __list) if (ep->fd == lfd) From phk at projects.linpro.no Tue Jun 17 10:13:03 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Tue, 17 Jun 2008 12:13:03 +0200 (CEST) Subject: r2724 - trunk/varnish-cache/bin/varnishd Message-ID: <20080617101303.5EB9E1ED2F1@projects.linpro.no> Author: phk Date: 2008-06-17 12:13:03 +0200 (Tue, 17 Jun 2008) New Revision: 2724 Modified: trunk/varnish-cache/bin/varnishd/mgt.h trunk/varnish-cache/bin/varnishd/mgt_child.c trunk/varnish-cache/bin/varnishd/mgt_cli.c Log: When running in -d -d mode, close all telnet sockets when stdin closes. ... But do not do this for the single -d mode. Modified: trunk/varnish-cache/bin/varnishd/mgt.h =================================================================== --- trunk/varnish-cache/bin/varnishd/mgt.h 2008-06-17 10:11:44 UTC (rev 2723) +++ trunk/varnish-cache/bin/varnishd/mgt.h 2008-06-17 10:13:03 UTC (rev 2724) @@ -48,7 +48,7 @@ int mgt_cli_askchild(unsigned *status, char **resp, const char *fmt, ...); void mgt_cli_start_child(int fdi, int fdo); void mgt_cli_stop_child(void); -int mgt_cli_telnet(const char *T_arg); +int mgt_cli_telnet(int dflag, const char *T_arg); /* mgt_param.c */ void MCF_ParamSync(void); Modified: trunk/varnish-cache/bin/varnishd/mgt_child.c =================================================================== --- trunk/varnish-cache/bin/varnishd/mgt_child.c 2008-06-17 10:11:44 UTC (rev 2723) +++ trunk/varnish-cache/bin/varnishd/mgt_child.c 2008-06-17 10:13:03 UTC (rev 2724) @@ -403,7 +403,7 @@ mgt_cli_setup(0, 1, 1, "debug"); if (T_arg) - mgt_cli_telnet(T_arg); + mgt_cli_telnet(dflag, T_arg); e = ev_new(); XXXAN(e); Modified: trunk/varnish-cache/bin/varnishd/mgt_cli.c =================================================================== --- trunk/varnish-cache/bin/varnishd/mgt_cli.c 2008-06-17 10:11:44 UTC (rev 2723) +++ trunk/varnish-cache/bin/varnishd/mgt_cli.c 2008-06-17 10:13:03 UTC (rev 2724) @@ -64,6 +64,18 @@ static int cli_i = -1, cli_o = -1; +struct telnet { + int fd; + struct ev *ev; + VTAILQ_ENTRY(telnet) list; +}; + +static VTAILQ_HEAD(,telnet) telnets = VTAILQ_HEAD_INITIALIZER(telnets); +static void telnet_close_all(void); +static void telnet_close_one(int fd); + +static int dflag_copy; + /*--------------------------------------------------------------------*/ static void @@ -302,12 +314,16 @@ (void)close(cp->fdo); /* Special case for stdin/out/err */ - if (cp->fdi == 0) + if (cp->fdi == 0) { assert(open("/dev/null", O_RDONLY) == 0); - if (cp->fdo == 1) { assert(open("/dev/null", O_WRONLY) == 1); (void)close(2); assert(open("/dev/null", O_WRONLY) == 2); + + if (dflag_copy == 2) + telnet_close_all(); + } else { + telnet_close_one(cp->fdi); } free(cp); @@ -365,6 +381,48 @@ AZ(ev_add(mgt_evb, cp->ev)); } +/*--------------------------------------------------------------------*/ + +static void +telnet_close_one(int fd) +{ + struct telnet *tn, *tn2; + + VTAILQ_FOREACH_SAFE(tn, &telnets, list, tn2) { + if (tn->fd != fd) + continue; + VTAILQ_REMOVE(&telnets, tn, list); + AZ(close(tn->fd)); + free(tn); + break; + } +} + + +static void +telnet_close_all() +{ + struct telnet *tn, *tn2; + + VTAILQ_FOREACH_SAFE(tn, &telnets, list, tn2) { + VTAILQ_REMOVE(&telnets, tn, list); + AZ(close(tn->fd)); + free(tn); + } +} + +static struct telnet * +telnet_new(int fd) +{ + struct telnet *tn; + + tn = calloc(sizeof *tn, 1); + AN(tn); + tn->fd = fd; + VTAILQ_INSERT_TAIL(&telnets, tn, list); + return (tn); +} + static int telnet_accept(const struct ev *ev, int what) { @@ -378,6 +436,8 @@ (void)what; addrlen = sizeof addr; i = accept(ev->fd, (void *)&addr, &addrlen); + if (i < 0 && errno == EBADF) + return (1); if (i < 0) return (0); @@ -387,18 +447,23 @@ asprintf(&p, "telnet %s:%s %s:%s", abuf2, pbuf2, abuf1, pbuf1); XXXAN(p); + telnet_new(i); + mgt_cli_setup(i, i, 0, p); free(p); return (0); } int -mgt_cli_telnet(const char *T_arg) +mgt_cli_telnet(int dflag, const char *T_arg) { struct vss_addr **ta; char *addr, *port; - int i, n; + int i, n, sock; + struct telnet *tn; + dflag_copy = dflag; + XXXAZ(VSS_parse(T_arg, &addr, &port)); n = VSS_resolve(addr, port, &ta); free(addr); @@ -408,13 +473,15 @@ exit(2); } for (i = 0; i < n; ++i) { - int sock = VSS_listen(ta[i], 10); - struct ev *ev = ev_new(); - XXXAN(ev); - ev->fd = sock; - ev->fd_flags = POLLIN; - ev->callback = telnet_accept; - AZ(ev_add(mgt_evb, ev)); + sock = VSS_listen(ta[i], 10); + assert(sock >= 0); + tn = telnet_new(sock); + tn->ev = ev_new(); + XXXAN(tn->ev); + tn->ev->fd = sock; + tn->ev->fd_flags = POLLIN; + tn->ev->callback = telnet_accept; + AZ(ev_add(mgt_evb, tn->ev)); free(ta[i]); ta[i] = NULL; } From phk at projects.linpro.no Tue Jun 17 10:14:23 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Tue, 17 Jun 2008 12:14:23 +0200 (CEST) Subject: r2725 - trunk/varnish-cache/bin/varnishd Message-ID: <20080617101423.F07A41EC208@projects.linpro.no> Author: phk Date: 2008-06-17 12:14:23 +0200 (Tue, 17 Jun 2008) New Revision: 2725 Modified: trunk/varnish-cache/bin/varnishd/mgt_cli.c Log: Don't assert that the close succeeds, we may already have closed the telnet socket. Modified: trunk/varnish-cache/bin/varnishd/mgt_cli.c =================================================================== --- trunk/varnish-cache/bin/varnishd/mgt_cli.c 2008-06-17 10:13:03 UTC (rev 2724) +++ trunk/varnish-cache/bin/varnishd/mgt_cli.c 2008-06-17 10:14:23 UTC (rev 2725) @@ -392,7 +392,7 @@ if (tn->fd != fd) continue; VTAILQ_REMOVE(&telnets, tn, list); - AZ(close(tn->fd)); + (void)close(tn->fd); free(tn); break; } From phk at projects.linpro.no Tue Jun 17 10:15:21 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Tue, 17 Jun 2008 12:15:21 +0200 (CEST) Subject: r2726 - trunk/varnish-cache/bin/varnishtest Message-ID: <20080617101521.2B9501EC0D3@projects.linpro.no> Author: phk Date: 2008-06-17 12:15:20 +0200 (Tue, 17 Jun 2008) New Revision: 2726 Modified: trunk/varnish-cache/bin/varnishtest/vtc_varnish.c Log: Now that varnishd's -d -d mode behaves correctly, use a more civilized shutdown sequence. Modified: trunk/varnish-cache/bin/varnishtest/vtc_varnish.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_varnish.c 2008-06-17 10:14:23 UTC (rev 2725) +++ trunk/varnish-cache/bin/varnishtest/vtc_varnish.c 2008-06-17 10:15:20 UTC (rev 2726) @@ -38,6 +38,7 @@ #include #include +#include #include @@ -267,18 +268,21 @@ varnish_wait(struct varnish *v) { void *p; + int status, r; if (v->cli_fd < 0) return; varnish_stop(v); printf("## %-4s Wait\n", v->name); - AZ(kill(v->pid, SIGKILL)); - AZ(pthread_cancel(v->tp)); + AZ(close(v->cli_fd)); + v->cli_fd = -1; + + AZ(close(v->fds[1])); + AZ(pthread_join(v->tp, &p)); - close(v->fds[0]); - close(v->fds[1]); - close(v->cli_fd); - v->cli_fd = -1; + AZ(close(v->fds[0])); + r = wait4(v->pid, &status, 0, NULL); + printf("## %-4s R %d Status: %04x\n", v->name, r, status); } /********************************************************************** From phk at projects.linpro.no Tue Jun 17 10:19:14 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Tue, 17 Jun 2008 12:19:14 +0200 (CEST) Subject: r2727 - trunk/varnish-cache/bin/varnishtest Message-ID: <20080617101914.1FB5C1EC208@projects.linpro.no> Author: phk Date: 2008-06-17 12:19:13 +0200 (Tue, 17 Jun 2008) New Revision: 2727 Modified: trunk/varnish-cache/bin/varnishtest/vtc.c Log: Don't say we're done until after we have reset everything. Modified: trunk/varnish-cache/bin/varnishtest/vtc.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc.c 2008-06-17 10:15:20 UTC (rev 2726) +++ trunk/varnish-cache/bin/varnishtest/vtc.c 2008-06-17 10:19:13 UTC (rev 2727) @@ -307,8 +307,9 @@ printf("# TEST %s starting\n", fn); buf = read_file(fn); parse_string(buf, cmds, NULL); + printf("# RESETTING after %s\n", fn); + reset_cmds(cmds); printf("# TEST %s completed\n", fn); - reset_cmds(cmds); } /********************************************************************** From phk at projects.linpro.no Tue Jun 17 10:19:33 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Tue, 17 Jun 2008 12:19:33 +0200 (CEST) Subject: r2728 - trunk/varnish-cache/bin/varnishtest Message-ID: <20080617101933.A41B71EC0D3@projects.linpro.no> Author: phk Date: 2008-06-17 12:19:33 +0200 (Tue, 17 Jun 2008) New Revision: 2728 Modified: trunk/varnish-cache/bin/varnishtest/vtc_varnish.c Log: Launch varnish on -vcl or -vcl+backend if not already done. Modified: trunk/varnish-cache/bin/varnishtest/vtc_varnish.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_varnish.c 2008-06-17 10:19:13 UTC (rev 2727) +++ trunk/varnish-cache/bin/varnishtest/vtc_varnish.c 2008-06-17 10:19:33 UTC (rev 2728) @@ -295,6 +295,8 @@ struct vsb *vsb; unsigned u; + if (v->cli_fd < 0) + varnish_launch(v); vsb = vsb_newauto(); AN(vsb); @@ -342,6 +344,8 @@ char *p; unsigned u; + if (v->cli_fd < 0) + varnish_launch(v); vsb = vsb_newauto(); AN(vsb); From phk at projects.linpro.no Tue Jun 17 10:20:29 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Tue, 17 Jun 2008 12:20:29 +0200 (CEST) Subject: r2729 - trunk/varnish-cache/bin/varnishtest/tests Message-ID: <20080617102029.89D7C1ED2F1@projects.linpro.no> Author: phk Date: 2008-06-17 12:20:29 +0200 (Tue, 17 Jun 2008) New Revision: 2729 Added: trunk/varnish-cache/bin/varnishtest/tests/b00001.vtc Log: Add a trivial pipe test Added: trunk/varnish-cache/bin/varnishtest/tests/b00001.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/b00001.vtc (rev 0) +++ trunk/varnish-cache/bin/varnishtest/tests/b00001.vtc 2008-06-17 10:20:29 UTC (rev 2729) @@ -0,0 +1,26 @@ +# $Id$ + +test "Check that a pipe transaction works" + +server s1 -repeat 1 { + rxreq + txresp \ + -hdr "Connection: close" \ + -body "012345\n" +} + +varnish v1 -vcl+backend { + sub vcl_recv { + pipe; + } +} -start + +server s1 -start + +client c1 { + txreq -url "/" + rxresp + expect resp.status == 200 +} + +client c1 -run Property changes on: trunk/varnish-cache/bin/varnishtest/tests/b00001.vtc ___________________________________________________________________ Name: svn:keywords + From phk at projects.linpro.no Tue Jun 17 20:27:31 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Tue, 17 Jun 2008 22:27:31 +0200 (CEST) Subject: r2730 - trunk/varnish-cache/bin/varnishtest Message-ID: <20080617202731.B1C341EC208@projects.linpro.no> Author: phk Date: 2008-06-17 22:27:31 +0200 (Tue, 17 Jun 2008) New Revision: 2730 Modified: trunk/varnish-cache/bin/varnishtest/t001.vtc trunk/varnish-cache/bin/varnishtest/vtc_client.c trunk/varnish-cache/bin/varnishtest/vtc_server.c Log: Automatically wait for servers and clients during reset pass. Modified: trunk/varnish-cache/bin/varnishtest/t001.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/t001.vtc 2008-06-17 10:20:29 UTC (rev 2729) +++ trunk/varnish-cache/bin/varnishtest/t001.vtc 2008-06-17 20:27:31 UTC (rev 2730) @@ -2,20 +2,6 @@ # # $Id$ -varnish v1 -launch - -varnish v1 -vcl { - backend s1 { - .host = "localhost"; - .port = "9080"; - } - sub vcl_recv { - pipe; - } -} - -varnish v1 -start - server s1 -repeat 1 { rxreq txresp \ @@ -25,6 +11,16 @@ -body "012345\n" } +varnish v1 -launch + +varnish v1 -vcl+backend { + sub vcl_recv { + pipe; + } +} + +varnish v1 -start + server s1 -start client c1 { @@ -35,6 +31,6 @@ client c1 -run -server s1 -wait +# server s1 -wait -varnish v1 -stop +# varnish v1 -wait Modified: trunk/varnish-cache/bin/varnishtest/vtc_client.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_client.c 2008-06-17 10:20:29 UTC (rev 2729) +++ trunk/varnish-cache/bin/varnishtest/vtc_client.c 2008-06-17 20:27:31 UTC (rev 2730) @@ -167,6 +167,8 @@ /* Reset and free */ VTAILQ_FOREACH_SAFE(c, &clients, list, c2) { VTAILQ_REMOVE(&clients, c, list); + if (c->tp != NULL) + client_wait(c); FREE_OBJ(c); /* XXX: MEMLEAK */ } Modified: trunk/varnish-cache/bin/varnishtest/vtc_server.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_server.c 2008-06-17 10:20:29 UTC (rev 2729) +++ trunk/varnish-cache/bin/varnishtest/vtc_server.c 2008-06-17 20:27:31 UTC (rev 2730) @@ -209,6 +209,8 @@ /* Reset and free */ VTAILQ_FOREACH_SAFE(s, &servers, list, s2) { VTAILQ_REMOVE(&servers, s, list); + if (s->sock >= 0) + server_wait(s); FREE_OBJ(s); /* XXX: MEMLEAK */ } From phk at projects.linpro.no Tue Jun 17 20:35:45 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Tue, 17 Jun 2008 22:35:45 +0200 (CEST) Subject: r2731 - trunk/varnish-cache/bin/varnishtest/tests Message-ID: <20080617203545.733761ED2B5@projects.linpro.no> Author: phk Date: 2008-06-17 22:35:45 +0200 (Tue, 17 Jun 2008) New Revision: 2731 Added: trunk/varnish-cache/bin/varnishtest/tests/b00002.vtc trunk/varnish-cache/bin/varnishtest/tests/b00003.vtc Log: A couple more basic tests: pass and cache hit Added: trunk/varnish-cache/bin/varnishtest/tests/b00002.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/b00002.vtc (rev 0) +++ trunk/varnish-cache/bin/varnishtest/tests/b00002.vtc 2008-06-17 20:35:45 UTC (rev 2731) @@ -0,0 +1,26 @@ +# $Id$ + +test "Check that a pass transaction works" + +server s1 -repeat 1 { + rxreq + txresp \ + -hdr "Connection: close" \ + -body "012345\n" +} + +varnish v1 -vcl+backend { + sub vcl_recv { + pass; + } +} -start + +server s1 -start + +client c1 { + txreq -url "/" + rxresp + expect resp.status == 200 +} + +client c1 -run Property changes on: trunk/varnish-cache/bin/varnishtest/tests/b00002.vtc ___________________________________________________________________ Name: svn:keywords + Added: trunk/varnish-cache/bin/varnishtest/tests/b00003.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/b00003.vtc (rev 0) +++ trunk/varnish-cache/bin/varnishtest/tests/b00003.vtc 2008-06-17 20:35:45 UTC (rev 2731) @@ -0,0 +1,23 @@ +# $Id$ + +test "Check that a cache fetch + hit transaction works" + +server s1 { + rxreq + txresp \ + -hdr "Connection: close" \ + -body "012345\n" +} + +varnish v1 -vcl+backend { } -start + +server s1 -start + +client c1 { + txreq -url "/" + rxresp + expect resp.status == 200 +} + +client c1 -run +client c1 -run Property changes on: trunk/varnish-cache/bin/varnishtest/tests/b00003.vtc ___________________________________________________________________ Name: svn:keywords + From phk at projects.linpro.no Tue Jun 17 20:46:29 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Tue, 17 Jun 2008 22:46:29 +0200 (CEST) Subject: r2732 - trunk/varnish-cache/bin/varnishd Message-ID: <20080617204629.87BD31EC208@projects.linpro.no> Author: phk Date: 2008-06-17 22:46:29 +0200 (Tue, 17 Jun 2008) New Revision: 2732 Modified: trunk/varnish-cache/bin/varnishd/cache_center.c Log: Add a debug.xid CLI command to the child process that allows us to inspect and change the XID counter. This will allow varnishtester to test XID headers for correct behaviour. Modified: trunk/varnish-cache/bin/varnishd/cache_center.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_center.c 2008-06-17 20:35:45 UTC (rev 2731) +++ trunk/varnish-cache/bin/varnishd/cache_center.c 2008-06-17 20:46:29 UTC (rev 2732) @@ -72,6 +72,8 @@ #include "shmlog.h" #include "vcl.h" +#include "cli.h" +#include "cli_priv.h" #include "cache.h" static unsigned xids; @@ -966,10 +968,36 @@ DOT } */ +/*-------------------------------------------------------------------- + * Debugging aids + */ + +static void +cli_debug_xid(struct cli *cli, const char * const *av, void *priv) +{ + (void)priv; + if (av[2] != NULL) + xids = strtoul(av[2], NULL, 0); + cli_out(cli, "XID is %u\n", xids); +} + +static struct cli_proto debug_cmds[] = { + { "debug.xid", "debug.xid", + "\tExamine or set XID\n", 0, 1, cli_debug_xid }, + { NULL } +}; + +/*-------------------------------------------------------------------- + * + */ + void CNT_Init(void) { srandomdev(); xids = random(); + CLI_AddFuncs(DEBUG_CLI, debug_cmds); } + + From phk at projects.linpro.no Tue Jun 17 20:52:00 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Tue, 17 Jun 2008 22:52:00 +0200 (CEST) Subject: r2733 - trunk/varnish-cache/bin/varnishtest Message-ID: <20080617205200.505251ED2B5@projects.linpro.no> Author: phk Date: 2008-06-17 22:52:00 +0200 (Tue, 17 Jun 2008) New Revision: 2733 Modified: trunk/varnish-cache/bin/varnishtest/vtc_varnish.c Log: Add -cli command. Always reset XID to 1000 on start. Modified: trunk/varnish-cache/bin/varnishtest/vtc_varnish.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_varnish.c 2008-06-17 20:46:29 UTC (rev 2732) +++ trunk/varnish-cache/bin/varnishtest/vtc_varnish.c 2008-06-17 20:52:00 UTC (rev 2733) @@ -239,11 +239,15 @@ static void varnish_start(struct varnish *v) { + unsigned u; if (v->cli_fd < 0) varnish_launch(v); printf("## %-4s Start\n", v->name); - varnish_ask_cli(v, "start", NULL); + u = varnish_ask_cli(v, "start", NULL); + assert(u == CLIS_OK); + u = varnish_ask_cli(v, "debug.xid 1000", NULL); + assert(u == CLIS_OK); } /********************************************************************** @@ -286,6 +290,21 @@ } /********************************************************************** + * Ask a CLI question + */ + +static void +varnish_cli(struct varnish *v, const char *cli) +{ + unsigned u; + + if (v->cli_fd < 0) + varnish_launch(v); + u = varnish_ask_cli(v, cli, NULL); + printf("## %-4s CLI %03u <%s>\n", v->name, u, cli); +} + +/********************************************************************** * Load a VCL program */ @@ -433,6 +452,11 @@ av++; continue; } + if (!strcmp(*av, "-cli")) { + varnish_cli(v, av[1]); + av++; + continue; + } if (!strcmp(*av, "-launch")) { varnish_launch(v); continue; From phk at projects.linpro.no Tue Jun 17 20:52:20 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Tue, 17 Jun 2008 22:52:20 +0200 (CEST) Subject: r2734 - trunk/varnish-cache/bin/varnishtest/tests Message-ID: <20080617205220.467EA1EC208@projects.linpro.no> Author: phk Date: 2008-06-17 22:52:20 +0200 (Tue, 17 Jun 2008) New Revision: 2734 Modified: trunk/varnish-cache/bin/varnishtest/tests/b00003.vtc Log: Expect X-Varnish to show the correct XIDs Modified: trunk/varnish-cache/bin/varnishtest/tests/b00003.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/b00003.vtc 2008-06-17 20:52:00 UTC (rev 2733) +++ trunk/varnish-cache/bin/varnishtest/tests/b00003.vtc 2008-06-17 20:52:20 UTC (rev 2734) @@ -9,7 +9,7 @@ -body "012345\n" } -varnish v1 -vcl+backend { } -start +varnish v1 -vcl+backend { } -start server s1 -start @@ -17,7 +17,15 @@ txreq -url "/" rxresp expect resp.status == 200 + expect resp.http.X-Varnish == "1001" } +client c2 { + txreq -url "/" + rxresp + expect resp.status == 200 + expect resp.http.X-Varnish == "1002 1001" +} + client c1 -run -client c1 -run +client c2 -run From tfheen at projects.linpro.no Wed Jun 18 20:32:16 2008 From: tfheen at projects.linpro.no (tfheen at projects.linpro.no) Date: Wed, 18 Jun 2008 22:32:16 +0200 (CEST) Subject: r2735 - tags Message-ID: <20080618203216.8C0E71ED1CC@projects.linpro.no> Author: tfheen Date: 2008-06-18 22:32:16 +0200 (Wed, 18 Jun 2008) New Revision: 2735 Added: tags/varnish-2.0-tp1/ Log: Tech preview 1 Copied: tags/varnish-2.0-tp1 (from rev 2734, trunk) From phk at projects.linpro.no Fri Jun 20 06:56:04 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Fri, 20 Jun 2008 08:56:04 +0200 (CEST) Subject: r2736 - trunk/varnish-cache/bin/varnishtest Message-ID: <20080620065604.ABBEF1ED0A4@projects.linpro.no> Author: phk Date: 2008-06-20 08:56:03 +0200 (Fri, 20 Jun 2008) New Revision: 2736 Modified: trunk/varnish-cache/bin/varnishtest/Makefile.am trunk/varnish-cache/bin/varnishtest/vtc.c trunk/varnish-cache/bin/varnishtest/vtc.h trunk/varnish-cache/bin/varnishtest/vtc_client.c trunk/varnish-cache/bin/varnishtest/vtc_http.c trunk/varnish-cache/bin/varnishtest/vtc_server.c trunk/varnish-cache/bin/varnishtest/vtc_varnish.c Log: Rework the output of messages and add -q and -v options. This allows us to use buffered approaches later, if the file descritor lock stats to interfere with our concurrency. Modified: trunk/varnish-cache/bin/varnishtest/Makefile.am =================================================================== --- trunk/varnish-cache/bin/varnishtest/Makefile.am 2008-06-18 20:32:16 UTC (rev 2735) +++ trunk/varnish-cache/bin/varnishtest/Makefile.am 2008-06-20 06:56:03 UTC (rev 2736) @@ -8,6 +8,7 @@ vtc.c \ vtc_client.c \ vtc_http.c \ + vtc_log.c \ vtc_server.c \ vtc_stats.c \ vtc_varnish.c Modified: trunk/varnish-cache/bin/varnishtest/vtc.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc.c 2008-06-18 20:32:16 UTC (rev 2735) +++ trunk/varnish-cache/bin/varnishtest/vtc.c 2008-06-20 06:56:03 UTC (rev 2736) @@ -43,47 +43,6 @@ #define MAX_TOKENS 20 /********************************************************************** - * Dump a string - */ -void -vct_dump(const char *ident, const char *pfx, const char *str) -{ - int nl = 1; - struct vsb *vsb; - - if (pfx == NULL) - pfx = ""; - vsb = vsb_newauto(); - if (str == NULL) - vsb_printf(vsb, "#### %-4s %s(null)\n", ident, pfx); - else - for(; *str; str++) { - if (nl) { - vsb_printf(vsb, "#### %-4s %s| ", ident, pfx); - nl = 0; - } - if (*str == '\r') - vsb_printf(vsb, "\\r"); - else if (*str == '\t') - vsb_printf(vsb, "\\t"); - else if (*str == '\n') { - vsb_printf(vsb, "\\n\n"); - nl = 1; - } else if (*str < 0x20 || *str > 0x7e) - vsb_printf(vsb, "\\x%02x", *str); - else - vsb_printf(vsb, "%c", *str); - } - if (!nl) - vsb_printf(vsb, "\n"); - vsb_finish(vsb); - AZ(vsb_overflowed(vsb)); - (void)fputs(vsb_data(vsb), stdout); - vsb_delete(vsb); -} - - -/********************************************************************** * Read a file into memory */ @@ -264,9 +223,9 @@ AZ(av[2]); f = strtod(av[1], NULL); if (f > 100.) { - sleep((int)f); + (void)sleep((int)f); } else { - usleep((int)(f * 1e6)); + (void)usleep((int)(f * 1e6)); } } @@ -323,8 +282,14 @@ setbuf(stdout, NULL); setbuf(stderr, NULL); - while ((ch = getopt(argc, argv, "")) != -1) { + while ((ch = getopt(argc, argv, "qv")) != -1) { switch (ch) { + case 'q': + vtc_verbosity--; + break; + case 'v': + vtc_verbosity++; + break; case '?': default: errx(1, "Usage"); Modified: trunk/varnish-cache/bin/varnishtest/vtc.h =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc.h 2008-06-18 20:32:16 UTC (rev 2735) +++ trunk/varnish-cache/bin/varnishtest/vtc.h 2008-06-20 06:56:03 UTC (rev 2736) @@ -29,6 +29,7 @@ typedef void cmd_f(char **av, void *priv); struct vsb; +struct vtclog; struct cmds { const char *name; @@ -37,17 +38,18 @@ void parse_string(char *buf, const struct cmds *cmd, void *priv); -void cmd_dump(char **av, void *priv); -void cmd_delay(char **av, void *priv); +cmd_f cmd_dump; +cmd_f cmd_delay; +cmd_f cmd_server; +cmd_f cmd_client; +cmd_f cmd_stats; +cmd_f cmd_varnish; -void cmd_server(char **av, void *priv); -void cmd_client(char **av, void *priv); -void cmd_vcl(char **av, void *priv); -void cmd_stats(char **av, void *priv); -void cmd_varnish(char **av, void *priv); +void http_process(struct vtclog *vl, const char *spec, int sock, int client); -void http_process(const char *ident, const char *spec, int sock, int client); +void cmd_server_genvcl(struct vsb *vsb); -void vct_dump(const char *ident, const char *pfx, const char *str); - -void cmd_server_genvcl(struct vsb *vsb); +extern int vtc_verbosity; +struct vtclog *vtc_logopen(const char *id); +void vtc_log(struct vtclog *vl, unsigned lvl, const char *fmt, ...); +void vtc_dump(struct vtclog *vl, unsigned lvl, const char *pfx, const char *str); Modified: trunk/varnish-cache/bin/varnishtest/vtc_client.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_client.c 2008-06-18 20:32:16 UTC (rev 2735) +++ trunk/varnish-cache/bin/varnishtest/vtc_client.c 2008-06-20 06:56:03 UTC (rev 2736) @@ -46,6 +46,7 @@ unsigned magic; #define CLIENT_MAGIC 0x6242397c char *name; + struct vtclog *vl; VTAILQ_ENTRY(client) list; char *spec; @@ -66,20 +67,22 @@ client_thread(void *priv) { struct client *c; + struct vtclog *vl; int fd = -1; CAST_OBJ_NOTNULL(c, priv, CLIENT_MAGIC); AN(c->connect); - printf("## %-4s started\n", c->name); - printf("### %-4s connect to %s\n", c->name, 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); assert(fd >= 0); - printf("### %-4s connected to %s fd is %d\n", - c->name, c->connect, fd); - http_process(c->name, c->spec, fd, 1); + vtc_log(vl, 3, "Connected to %s fd is %d", c->connect, fd); + http_process(vl, c->spec, fd, 1); AZ(close(fd)); - printf("## %-4s ending\n", c->name); + vtc_log(vl, 2, "Ending"); return (NULL); } @@ -93,14 +96,16 @@ { struct client *c; + ALLOC_OBJ(c, CLIENT_MAGIC); + AN(c); + c->name = name; + c->vl = vtc_logopen(name); + AN(c->vl); if (*name != 'c') { - fprintf(stderr, "---- %-4s Client name must start with 'c'\n", - name); + vtc_log(c->vl, 0, "Client name must start with 'c'"); exit (1); } - ALLOC_OBJ(c, CLIENT_MAGIC); - AN(c); - c->name = name; + c->connect = ":9081"; VTAILQ_INSERT_TAIL(&clients, c, list); return (c); @@ -115,7 +120,7 @@ { CHECK_OBJ_NOTNULL(c, CLIENT_MAGIC); - printf("## %-4s Starting client\n", c->name); + vtc_log(c->vl, 2, "Starting client"); AZ(pthread_create(&c->tp, NULL, client_thread, c)); } @@ -129,11 +134,10 @@ void *res; CHECK_OBJ_NOTNULL(c, CLIENT_MAGIC); - printf("## %-4s Waiting for client\n", c->name); + vtc_log(c->vl, 2, "Waiting for client"); AZ(pthread_join(c->tp, &res)); if (res != NULL) { - fprintf(stderr, "Server %s returned \"%s\"\n", - c->name, (char *)res); + vtc_log(c->vl, 0, "Client returned \"%s\"", (char *)res); exit (1); } c->tp = NULL; @@ -207,7 +211,7 @@ c->spec = *av; continue; } - fprintf(stderr, "Unknown client argument: %s\n", *av); + vtc_log(c->vl, 0, "Unknown client argument: %s", *av); exit (1); } } Modified: trunk/varnish-cache/bin/varnishtest/vtc_http.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_http.c 2008-06-18 20:32:16 UTC (rev 2735) +++ trunk/varnish-cache/bin/varnishtest/vtc_http.c 2008-06-20 06:56:03 UTC (rev 2736) @@ -49,7 +49,7 @@ int fd; int client; int timeout; - const char *ident; + struct vtclog *vl; int nrxbuf; char *rxbuf; @@ -121,19 +121,16 @@ rhs = cmd_var_resolve(hp, av[2]); if (!strcmp(cmp, "==")) { if (strcmp(lhs, rhs)) { - fprintf(stderr, - "---- %-4s EXPECT %s (%s) %s %s (%s) failed\n", - hp->ident, av[0], lhs, av[1], av[2], rhs); + vtc_log(hp->vl, 0, "EXPECT %s (%s) %s %s (%s) failed", + av[0], lhs, av[1], av[2], rhs); exit (1); } else { - printf( - "#### %-4s EXPECT %s (%s) %s %s (%s) match\n", - hp->ident, av[0], lhs, av[1], av[2], rhs); + vtc_log(hp->vl, 4, "EXPECT %s (%s) %s %s (%s) match", + av[0], lhs, av[1], av[2], rhs); } } else { - fprintf(stderr, - "---- %-4s EXPECT %s (%s) %s %s (%s) not implemented\n", - hp->ident, av[0], lhs, av[1], av[2], rhs); + vtc_log(hp->vl, 0, "EXPECT %s (%s) %s %s (%s) not implemented", + av[0], lhs, av[1], av[2], rhs); exit (1); } } @@ -212,7 +209,7 @@ for (n = 0; n < 3 || hh[n] != NULL; n++) { sprintf(buf, "http[%2d] ", n); - vct_dump(hp->ident, buf, hh[n]); + vtc_dump(hp->vl, 4, buf, hh[n]); } } @@ -257,7 +254,7 @@ if (i == 2) break; } - vct_dump(hp->ident, NULL, hp->rxbuf); + vtc_dump(hp->vl, 4, NULL, hp->rxbuf); } @@ -279,7 +276,7 @@ fprintf(stderr, "Unknown http rxresp spec: %s\n", *av); exit (1); } - printf("### %-4s rxresp\n", hp->ident); + vtc_log(hp->vl, 3, "rxresp"); http_rxhdr(hp); http_splitheader(hp, 0); } @@ -357,7 +354,7 @@ } vsb_finish(vsb); AZ(vsb_overflowed(vsb)); - vct_dump(hp->ident, NULL, vsb_data(vsb)); + vtc_dump(hp->vl, 4, NULL, vsb_data(vsb)); l = write(hp->fd, vsb_data(vsb), vsb_len(vsb)); assert(l == vsb_len(vsb)); vsb_delete(vsb); @@ -381,7 +378,7 @@ fprintf(stderr, "Unknown http rxreq spec: %s\n", *av); exit (1); } - printf("### %-4s rxreq\n", hp->ident); + vtc_log(hp->vl, 3, "rxreq"); http_rxhdr(hp); http_splitheader(hp, 1); } @@ -449,7 +446,7 @@ vsb_cat(vsb, nl); vsb_finish(vsb); AZ(vsb_overflowed(vsb)); - vct_dump(hp->ident, NULL, vsb_data(vsb)); + vtc_dump(hp->vl, 4, NULL, vsb_data(vsb)); l = write(hp->fd, vsb_data(vsb), vsb_len(vsb)); assert(l == vsb_len(vsb)); vsb_delete(vsb); @@ -470,7 +467,7 @@ }; void -http_process(const char *ident, const char *spec, int sock, int client) +http_process(struct vtclog *vl, const char *spec, int sock, int client) { struct http *hp; char *s, *q; @@ -478,7 +475,7 @@ ALLOC_OBJ(hp, HTTP_MAGIC); AN(hp); hp->fd = sock; - hp->ident = ident; + hp->vl = vl; hp->client = client; hp->timeout = 1000; hp->nrxbuf = 8192; Modified: trunk/varnish-cache/bin/varnishtest/vtc_server.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_server.c 2008-06-18 20:32:16 UTC (rev 2735) +++ trunk/varnish-cache/bin/varnishtest/vtc_server.c 2008-06-20 06:56:03 UTC (rev 2736) @@ -48,6 +48,7 @@ unsigned magic; #define SERVER_MAGIC 0x55286619 char *name; + struct vtclog *vl; VTAILQ_ENTRY(server) list; unsigned repeat; @@ -74,6 +75,7 @@ server_thread(void *priv) { struct server *s; + struct vtclog *vl; int i, fd; struct sockaddr_storage addr_s; struct sockaddr *addr; @@ -83,19 +85,20 @@ CAST_OBJ_NOTNULL(s, priv, SERVER_MAGIC); assert(s->sock >= 0); - printf("## %-4s started on %s\n", s->name, s->listen); + vl = vtc_logopen(s->name); + + vtc_log(vl, 2, "Started on %s", s->listen); for (i = 0; i < s->repeat; i++) { if (s->repeat > 1) - printf("### %-4s iteration %d\n", s->name, i); + vtc_log(vl, 3, "Iteration %d", i); addr = (void*)&addr_s; l = sizeof addr_s; fd = accept(s->sock, addr, &l); - printf("#### %-4s Accepted socket %d\n", s->name, fd); - http_process(s->name, s->spec, fd, 0); + vtc_log(vl, 3, "Accepted socket fd is %d", fd); + http_process(vl, s->spec, fd, 0); AZ(close(fd)); } - printf("## %-4s ending\n", s->name); - + vtc_log(vl, 2, "Ending"); return (NULL); } @@ -108,14 +111,15 @@ { struct server *s; + ALLOC_OBJ(s, SERVER_MAGIC); + AN(s); + s->name = name; + s->vl = vtc_logopen(name); + AN(s->vl); if (*name != 's') { - fprintf(stderr, "---- %-4s Server name must start with 's'\n", - name); + vtc_log(s->vl, 0, "Server name must start with 's'"); exit (1); } - ALLOC_OBJ(s, SERVER_MAGIC); - AN(s); - s->name = name; s->listen = ":9080"; AZ(VSS_parse(s->listen, &s->addr, &s->port)); s->repeat = 1; @@ -135,21 +139,21 @@ int naddr; CHECK_OBJ_NOTNULL(s, SERVER_MAGIC); - printf("## %-4s Starting server\n", s->name); + vtc_log(s->vl, 2, "Starting server"); if (s->sock < 0) { naddr = VSS_resolve(s->addr, s->port, &s->vss_addr); if (naddr != 1) { - fprintf(stderr, - "Server %s listen address not unique\n" - " \"%s\" resolves to (%d) sockets\n", - s->name, s->listen, naddr); + vtc_log(s->vl, 0, + "Server s listen address not unique" + " \"%s\" resolves to (%d) sockets", + s->listen, naddr); exit (1); } s->sock = VSS_listen(s->vss_addr[0], s->depth); assert(s->sock >= 0); } - printf("### %-4s listen on %s (fd %d)\n", - s->name, s->listen, s->sock); + vtc_log(s->vl, 3, "listen on %s (fd %d)", + s->listen, s->sock); AZ(pthread_create(&s->tp, NULL, server_thread, s)); } @@ -163,11 +167,11 @@ void *res; CHECK_OBJ_NOTNULL(s, SERVER_MAGIC); - printf("## %-4s Waiting for server\n", s->name); + vtc_log(s->vl, 2, "Waiting for server"); AZ(pthread_join(s->tp, &res)); if (res != NULL) { - fprintf(stderr, "Server %s returned \"%s\"\n", - s->name, (char *)res); + vtc_log(s->vl, 0, "Server returned \"%s\"", + (char *)res); exit (1); } s->tp = NULL; @@ -251,7 +255,7 @@ s->spec = *av; continue; } - fprintf(stderr, "Unknown server argument: %s\n", *av); + vtc_log(s->vl, 0, "Unknown server argument: %s", *av); exit (1); } } Modified: trunk/varnish-cache/bin/varnishtest/vtc_varnish.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_varnish.c 2008-06-18 20:32:16 UTC (rev 2735) +++ trunk/varnish-cache/bin/varnishtest/vtc_varnish.c 2008-06-20 06:56:03 UTC (rev 2736) @@ -56,6 +56,7 @@ unsigned magic; #define VARNISH_MAGIC 0x208cd8e3 char *name; + struct vtclog *vl; VTAILQ_ENTRY(varnish) list; const char *args; @@ -66,11 +67,6 @@ pthread_t tp; - char *addr; - char *port; - int naddr; - struct vss_addr **vss_addr; - int cli_fd; int vcl_nbr; }; @@ -82,27 +78,27 @@ * Ask a question over CLI */ -static unsigned -varnish_ask_cli(struct varnish *v, const char *cmd, char **repl) +static enum cli_status_e +varnish_ask_cli(const struct varnish *v, const char *cmd, char **repl) { int i; unsigned retval; char *r; - vct_dump(v->name, "CLI TX", cmd); + vtc_dump(v->vl, 4, "CLI TX", cmd); i = write(v->cli_fd, cmd, strlen(cmd)); assert(i == strlen(cmd)); i = write(v->cli_fd, "\n", 1); assert(i == 1); i = cli_readres(v->cli_fd, &retval, &r, 1000); assert(i == 0); - printf("### %-4s CLI %u <%s>\n", v->name, retval, cmd); - vct_dump(v->name, "CLI RX", r); + vtc_log(v->vl, 3, "CLI %u <%s>", retval, cmd); + vtc_dump(v->vl, 4, "CLI RX", r); if (repl != NULL) *repl = r; else free(r); - return (retval); + return ((enum cli_status_e)retval); } static void @@ -136,14 +132,16 @@ { struct varnish *v; - if (*name != 'v') { - fprintf(stderr, - "---- %-4s Varnish name must start with 'v'\n", name); - exit (1); - } ALLOC_OBJ(v, VARNISH_MAGIC); AN(v); v->name = name; + v->vl = vtc_logopen(name); + AN(v->vl); + if (*name != 'v') { + vtc_log(v->vl, 0, "Varnish name must start with 'v'"); + exit (1); + } + v->args = ""; v->telnet = ":9001"; v->accept = ":9081"; @@ -169,7 +167,7 @@ if (i <= 0) break; buf[i] = '\0'; - vct_dump(v->name, "debug", buf); + vtc_dump(v->vl, 4, "debug", buf); } return (NULL); } @@ -184,7 +182,7 @@ struct vsb *vsb; int i; - printf("## %-4s Launch\n", v->name); + vtc_log(v->vl, 2, "Launch"); vsb = vsb_newauto(); AN(vsb); vsb_printf(vsb, "cd ../varnishd &&"); @@ -193,7 +191,7 @@ vsb_printf(vsb, " %s", v->args); vsb_finish(vsb); AZ(vsb_overflowed(vsb)); - printf("### %-4s CMD: %s\n", v->name, vsb_data(vsb)); + vtc_log(v->vl, 3, "CMD: %s", vsb_data(vsb)); AZ(pipe(&v->fds[0])); AZ(pipe(&v->fds[2])); v->pid = fork(); @@ -216,19 +214,19 @@ vsb_delete(vsb); AZ(pthread_create(&v->tp, NULL, varnish_thread, v)); - printf("### %-4s opening CLI connection\n", v->name); + vtc_log(v->vl, 3, "opening CLI connection"); for (i = 0; i < 10; i++) { - usleep(200000); + (void)usleep(200000); v->cli_fd = VSS_open(v->telnet); if (v->cli_fd >= 0) break; } if (v->cli_fd < 0) { - fprintf(stderr, "---- %-4s FAIL no CLI connection\n", v->name); - kill(v->pid, SIGKILL); + vtc_log(v->vl, 0, "FAIL no CLI connection"); + (void)kill(v->pid, SIGKILL); exit (1); } - printf("### %-4s CLI connection fd = %d\n", v->name, v->cli_fd); + vtc_log(v->vl, 3, "CLI connection fd = %d", v->cli_fd); assert(v->cli_fd >= 0); } @@ -239,11 +237,11 @@ static void varnish_start(struct varnish *v) { - unsigned u; + enum cli_status_e u; if (v->cli_fd < 0) varnish_launch(v); - printf("## %-4s Start\n", v->name); + vtc_log(v->vl, 2, "Start"); u = varnish_ask_cli(v, "start", NULL); assert(u == CLIS_OK); u = varnish_ask_cli(v, "debug.xid 1000", NULL); @@ -260,8 +258,8 @@ if (v->cli_fd < 0) varnish_launch(v); - printf("## %-4s Stop\n", v->name); - varnish_ask_cli(v, "stop", NULL); + vtc_log(v->vl, 2, "Stop"); + (void)varnish_ask_cli(v, "stop", NULL); } /********************************************************************** @@ -277,7 +275,7 @@ if (v->cli_fd < 0) return; varnish_stop(v); - printf("## %-4s Wait\n", v->name); + vtc_log(v->vl, 2, "Wait"); AZ(close(v->cli_fd)); v->cli_fd = -1; @@ -286,7 +284,7 @@ AZ(pthread_join(v->tp, &p)); AZ(close(v->fds[0])); r = wait4(v->pid, &status, 0, NULL); - printf("## %-4s R %d Status: %04x\n", v->name, r, status); + vtc_log(v->vl, 2, "R %d Status: %04x", r, status); } /********************************************************************** @@ -296,12 +294,12 @@ static void varnish_cli(struct varnish *v, const char *cli) { - unsigned u; + enum cli_status_e u; if (v->cli_fd < 0) varnish_launch(v); u = varnish_ask_cli(v, cli, NULL); - printf("## %-4s CLI %03u <%s>\n", v->name, u, cli); + vtc_log(v->vl, 2, "CLI %03u <%s>", u, cli); } /********************************************************************** @@ -309,10 +307,10 @@ */ static void -varnish_vcl(struct varnish *v, char *vcl) +varnish_vcl(struct varnish *v, const char *vcl) { struct vsb *vsb; - unsigned u; + enum cli_status_e u; if (v->cli_fd < 0) varnish_launch(v); @@ -361,7 +359,7 @@ { struct vsb *vsb, *vsb2; char *p; - unsigned u; + enum cli_status_e u; if (v->cli_fd < 0) varnish_launch(v); @@ -483,7 +481,7 @@ varnish_wait(v); continue; } - fprintf(stderr, "Unknown varnish argument: %s\n", *av); + vtc_log(v->vl, 0, "Unknown varnish argument: %s", *av); exit (1); } } From phk at projects.linpro.no Fri Jun 20 07:32:40 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Fri, 20 Jun 2008 09:32:40 +0200 (CEST) Subject: r2737 - trunk/varnish-cache/bin/varnishd Message-ID: <20080620073240.299271EC11A@projects.linpro.no> Author: phk Date: 2008-06-20 09:32:38 +0200 (Fri, 20 Jun 2008) New Revision: 2737 Modified: trunk/varnish-cache/bin/varnishd/cache.h trunk/varnish-cache/bin/varnishd/cache_expire.c trunk/varnish-cache/bin/varnishd/cache_hash.c Log: Use default_grace consistently or it will all be in vain. Submitted by: sky Fixes: ticket 253 Modified: trunk/varnish-cache/bin/varnishd/cache.h =================================================================== --- trunk/varnish-cache/bin/varnishd/cache.h 2008-06-20 06:56:03 UTC (rev 2736) +++ trunk/varnish-cache/bin/varnishd/cache.h 2008-06-20 07:32:38 UTC (rev 2737) @@ -462,6 +462,7 @@ void HSH_Unbusy(struct sess *sp); void HSH_Ref(struct object *o); void HSH_Deref(struct object *o); +double HSH_Grace(double g); void HSH_Init(void); /* cache_http.c */ Modified: trunk/varnish-cache/bin/varnishd/cache_expire.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_expire.c 2008-06-20 06:56:03 UTC (rev 2736) +++ trunk/varnish-cache/bin/varnishd/cache_expire.c 2008-06-20 07:32:38 UTC (rev 2737) @@ -147,7 +147,7 @@ oe->timer_when = o->prefetch; oe->timer_what = tmr_prefetch; } else { - oe->timer_when = o->ttl + o->grace; + oe->timer_when = o->ttl + HSH_Grace(o->grace); oe->timer_what = tmr_ttl; } } Modified: trunk/varnish-cache/bin/varnishd/cache_hash.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_hash.c 2008-06-20 06:56:03 UTC (rev 2736) +++ trunk/varnish-cache/bin/varnishd/cache_hash.c 2008-06-20 07:32:38 UTC (rev 2737) @@ -67,7 +67,7 @@ static struct hash_slinger *hash; -static double +double HSH_Grace(double g) { if (isnan(g)) From phk at projects.linpro.no Fri Jun 20 10:15:57 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Fri, 20 Jun 2008 12:15:57 +0200 (CEST) Subject: r2738 - trunk/varnish-cache/bin/varnishd Message-ID: <20080620101557.7C3111EC404@projects.linpro.no> Author: phk Date: 2008-06-20 12:15:56 +0200 (Fri, 20 Jun 2008) New Revision: 2738 Modified: trunk/varnish-cache/bin/varnishd/cache.h Log: Add a hand function to safely add text to a txt Modified: trunk/varnish-cache/bin/varnishd/cache.h =================================================================== --- trunk/varnish-cache/bin/varnishd/cache.h 2008-06-20 07:32:38 UTC (rev 2737) +++ trunk/varnish-cache/bin/varnishd/cache.h 2008-06-20 10:15:56 UTC (rev 2738) @@ -38,6 +38,7 @@ #include #endif #include +#include #include #include "vqueue.h" @@ -687,6 +688,18 @@ ((unsigned)(t.e - t.b)); } +static inline void +Tadd(txt *t, const char *p, int l) +{ + if (l <= 0) { + } if (t->b + l < t->e) { + memcpy(t->b, p, l); + t->b += l; + } else { + t->b = t->e; + } +} + #ifdef WITHOUT_ASSERTS #define spassert(cond) ((void)(cond)) #define SPAZ(val) ((void)(val) == 0) From phk at projects.linpro.no Fri Jun 20 10:20:12 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Fri, 20 Jun 2008 12:20:12 +0200 (CEST) Subject: r2739 - trunk/varnish-cache/bin/varnishd Message-ID: <20080620102012.8DFE51EC114@projects.linpro.no> Author: phk Date: 2008-06-20 12:20:12 +0200 (Fri, 20 Jun 2008) New Revision: 2739 Modified: trunk/varnish-cache/bin/varnishd/cache_vrt_re.c Log: Fix a number of issues and bugs with regsub(): Allow '\' to escape the next char. Make '$$' be the same as '&': entire match XXX: NB: Should we drop the sed(1) usage of '&' here, it means XXX: a lot of backslashing in query string urls ? Make $-digit work correctly. Fixes ticket 249 Modified: trunk/varnish-cache/bin/varnishd/cache_vrt_re.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_vrt_re.c 2008-06-20 10:15:56 UTC (rev 2738) +++ trunk/varnish-cache/bin/varnishd/cache_vrt_re.c 2008-06-20 10:20:12 UTC (rev 2739) @@ -109,7 +109,8 @@ regmatch_t pm[10]; regex_t *t; int i, l; - char *b, *p, *e; + txt res; + char *p; const char *s; unsigned u, x; @@ -122,38 +123,31 @@ return(str); u = WS_Reserve(sp->http->ws, 0); - e = p = b = sp->http->ws->f; - e += u; + res.e = res.b = p = sp->http->ws->f; + res.e += u; do { /* Copy prefix to match */ - if (pm[0].rm_so > 0) { - if (p + pm[0].rm_so < e) - memcpy(p, str, pm[0].rm_so); - p += pm[0].rm_so; - } + Tadd(&res, str, pm[0].rm_so); for (s = sub ; *s != '\0'; s++ ) { - if (*s == '&') { + if (*s == '\\') { + if (res.b < res.e) + *res.b++ = *++s; + } else if (*s == '&') { l = pm[0].rm_eo - pm[0].rm_so; - if (l > 0) { - if (p + l < e) - memcpy(p, str + pm[0].rm_so, l); - p += l; - } + Tadd(&res, str + pm[0].rm_so, l); + } else if (*s == '$' && s[1] == '$') { + l = pm[0].rm_eo - pm[0].rm_so; + Tadd(&res, str + pm[0].rm_so, l); + s++; } else if (*s == '$' && isdigit(s[1])) { - x = sub[1] - '0'; - sub++; + x = digittoint(*++s); l = pm[x].rm_eo - pm[x].rm_so; - if (l > 0) { - if (p + l < e) - memcpy(p, str + pm[x].rm_so, l); - p += l; - } + Tadd(&res, str + pm[x].rm_so, l); } else { - if (p + 1 < e) - *p = *s; - p++; + if (res.b < res.e) + *res.b++ = *s; } } str += pm[0].rm_eo; @@ -163,19 +157,13 @@ } while (i != REG_NOMATCH); /* Copy suffix to match */ - l = strlen(str); - if (l > 0) { - if (p + l < e) - memcpy(p, str, l); - p += l; - } - if (p + 1 < e) - *p++ = '\0'; - xxxassert(p <= e); - if (p > e) { + l = strlen(str) + 1; + Tadd(&res, str, l); + if (res.b >= res.e) { WS_Release(sp->http->ws, 0); return (str); } - WS_Release(sp->http->ws, p - b); - return (b); + Tcheck(res); + WS_Release(sp->http->ws, p - res.b); + return (p); } From phk at projects.linpro.no Fri Jun 20 10:20:31 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Fri, 20 Jun 2008 12:20:31 +0200 (CEST) Subject: r2740 - trunk/varnish-cache/bin/varnishtest/tests Message-ID: <20080620102031.295F11EC404@projects.linpro.no> Author: phk Date: 2008-06-20 12:20:30 +0200 (Fri, 20 Jun 2008) New Revision: 2740 Added: trunk/varnish-cache/bin/varnishtest/tests/c00001.vtc Log: Add regsub test case so I don't break it again. Added: trunk/varnish-cache/bin/varnishtest/tests/c00001.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/c00001.vtc (rev 0) +++ trunk/varnish-cache/bin/varnishtest/tests/c00001.vtc 2008-06-20 10:20:30 UTC (rev 2740) @@ -0,0 +1,42 @@ +# $Id$ + +test "Test VCL regsub()" + +server s1 { + rxreq + txresp \ + -hdr "Foobar: barf" \ + -hdr "Connection: close" \ + -body "012345\n" +} + +varnish v1 -vcl+backend { + sub vcl_fetch { + set obj.http.Snafu1 = regsub(obj.http.Foobar, "ar", "&&"); + set obj.http.Snafu2 = + regsub(obj.http.Foobar, "(b)(a)(r)(f)", "$4$3$2p"); + set obj.http.Snafu3 = + regsub(obj.http.Foobar, "(b)(a)(r)(f)", "$4\$$3$2p"); + set obj.http.Snafu4 = + regsub(obj.http.Foobar, "(b)(a)(r)(f)", "$4\&$3$2p"); + set obj.http.Snafu5 = + regsub(obj.http.Foobar, "(b)(a)(r)(f)", "$$$4$3$2\$p"); + } +} -start + +server s1 -start + +client c1 { + txreq -url "/" + rxresp + expect resp.status == 200 + expect resp.http.X-Varnish == "1001" + expect resp.http.foobar == "barf" + expect resp.http.snafu1 == "bararf" + expect resp.http.snafu2 == "frap" + expect resp.http.snafu3 == "f$rap" + expect resp.http.snafu4 == "f&rap" + expect resp.http.snafu5 == "barffra$p" +} + +client c1 -run From phk at projects.linpro.no Fri Jun 20 11:58:26 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Fri, 20 Jun 2008 13:58:26 +0200 (CEST) Subject: r2741 - in trunk/varnish-cache/bin: varnishd varnishtest/tests Message-ID: <20080620115826.426151EC0FD@projects.linpro.no> Author: phk Date: 2008-06-20 13:58:25 +0200 (Fri, 20 Jun 2008) New Revision: 2741 Modified: trunk/varnish-cache/bin/varnishd/cache_vrt_re.c trunk/varnish-cache/bin/varnishtest/tests/c00001.vtc Log: NB: FLAGDAY! Make an executive decision, and change the regsub() replacement specifiers to get something which is consistent and nontroubling for URL and query strings. Since $ and & both are heavily used in query strings, we (DES & I) have chosen to use \0 ... \9 for replacement indicators, with \0 being the "all matched text" replacement and \1...\9 replacing with tne N'th paranthesized subexpressions. regsub("_barf_", "(b)(a)(r)(f)", "\0\4\3\2\\p") -> "_barffra\p_" Modified: trunk/varnish-cache/bin/varnishd/cache_vrt_re.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_vrt_re.c 2008-06-20 10:20:30 UTC (rev 2740) +++ trunk/varnish-cache/bin/varnishd/cache_vrt_re.c 2008-06-20 11:58:25 UTC (rev 2741) @@ -131,20 +131,17 @@ Tadd(&res, str, pm[0].rm_so); for (s = sub ; *s != '\0'; s++ ) { - if (*s == '\\') { + if (*s != '\\' || s[1] == '\0') { if (res.b < res.e) - *res.b++ = *++s; - } else if (*s == '&') { - l = pm[0].rm_eo - pm[0].rm_so; - Tadd(&res, str + pm[0].rm_so, l); - } else if (*s == '$' && s[1] == '$') { - l = pm[0].rm_eo - pm[0].rm_so; - Tadd(&res, str + pm[0].rm_so, l); - s++; - } else if (*s == '$' && isdigit(s[1])) { - x = digittoint(*++s); + *res.b++ = *s; + continue; + } + s++; + if (isdigit(*s)) { + x = digittoint(*s); l = pm[x].rm_eo - pm[x].rm_so; Tadd(&res, str + pm[x].rm_so, l); + continue; } else { if (res.b < res.e) *res.b++ = *s; Modified: trunk/varnish-cache/bin/varnishtest/tests/c00001.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/c00001.vtc 2008-06-20 10:20:30 UTC (rev 2740) +++ trunk/varnish-cache/bin/varnishtest/tests/c00001.vtc 2008-06-20 11:58:25 UTC (rev 2741) @@ -5,22 +5,24 @@ server s1 { rxreq txresp \ - -hdr "Foobar: barf" \ + -hdr "Foobar: _barf_" \ -hdr "Connection: close" \ -body "012345\n" } varnish v1 -vcl+backend { sub vcl_fetch { - set obj.http.Snafu1 = regsub(obj.http.Foobar, "ar", "&&"); + set obj.http.Snafu1 = regsub(obj.http.Foobar, "ar", "\0\0"); set obj.http.Snafu2 = - regsub(obj.http.Foobar, "(b)(a)(r)(f)", "$4$3$2p"); + regsub(obj.http.Foobar, "(b)(a)(r)(f)", "\4\3\2p"); set obj.http.Snafu3 = - regsub(obj.http.Foobar, "(b)(a)(r)(f)", "$4\$$3$2p"); + regsub(obj.http.Foobar, "(b)(a)(r)(f)", "\4\\\3\2p"); set obj.http.Snafu4 = - regsub(obj.http.Foobar, "(b)(a)(r)(f)", "$4\&$3$2p"); + regsub(obj.http.Foobar, "(b)(a)(r)(f)", "\4\&\3\2p"); set obj.http.Snafu5 = - regsub(obj.http.Foobar, "(b)(a)(r)(f)", "$$$4$3$2\$p"); + regsub(obj.http.Foobar, "(b)(a)(r)(f)", "\0\4\3\2\\p"); + set obj.http.Snafu6 = + regsub(obj.http.Foobar, "(b)(a)(r)(f)", "\4\&\3\2p\"); } } -start @@ -31,12 +33,14 @@ rxresp expect resp.status == 200 expect resp.http.X-Varnish == "1001" - expect resp.http.foobar == "barf" - expect resp.http.snafu1 == "bararf" - expect resp.http.snafu2 == "frap" - expect resp.http.snafu3 == "f$rap" - expect resp.http.snafu4 == "f&rap" - expect resp.http.snafu5 == "barffra$p" + expect resp.http.foobar == "_barf_" + expect resp.http.snafu1 == "_bararf_" + expect resp.http.snafu2 == "_frap_" + expect resp.http.snafu3 == "_f\rap_" + expect resp.http.snafu4 == "_f&rap_" + expect resp.http.snafu5 == "_barffra\p_" + # NB: have to escape the \\ in the next line + expect resp.http.snafu6 == "_f&rap\\_" } client c1 -run From phk at projects.linpro.no Fri Jun 20 12:25:39 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Fri, 20 Jun 2008 14:25:39 +0200 (CEST) Subject: r2742 - trunk/varnish-cache/bin/varnishtest Message-ID: <20080620122539.2E0991EC0B3@projects.linpro.no> Author: phk Date: 2008-06-20 14:25:25 +0200 (Fri, 20 Jun 2008) New Revision: 2742 Added: trunk/varnish-cache/bin/varnishtest/vtc_log.c Log: forgot to svn add this one: logging functions for varnishtest Added: trunk/varnish-cache/bin/varnishtest/vtc_log.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_log.c (rev 0) +++ trunk/varnish-cache/bin/varnishtest/vtc_log.c 2008-06-20 12:25:25 UTC (rev 2742) @@ -0,0 +1,141 @@ +/* + * Copyright (c) 2006-2008 Linpro AS + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $Id$ + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "libvarnish.h" +#include "vsb.h" +#include "miniobj.h" + +#include "vtc.h" + +int vtc_verbosity = 3; + +struct vtclog { + unsigned magic; +#define VTCLOG_MAGIC 0x82731202 + const char *id; + struct vsb *vsb; +}; + +struct vtclog * +vtc_logopen(const char *id) +{ + struct vtclog *vl; + + ALLOC_OBJ(vl, VTCLOG_MAGIC); + AN(vl); + vl->id = id; + vl->vsb = vsb_newauto(); + return (vl); +} + +static const char *lead[] = { + "----", + "# ", + "## ", + "### ", + "####" +}; + +#define NLEAD (sizeof(lead)/sizeof(lead[0])) + +void +vtc_log(struct vtclog *vl, unsigned lvl, const char *fmt, ...) +{ + + assert(lvl < NLEAD); + if (lvl > vtc_verbosity) + return; + vsb_printf(vl->vsb, "%s %-4s ", lead[lvl], vl->id); + va_list ap; + va_start(ap, fmt); + (void)vsb_vprintf(vl->vsb, fmt, ap); + va_end(ap); + vsb_putc(vl->vsb, '\n'); + vsb_finish(vl->vsb); + AZ(vsb_overflowed(vl->vsb)); + (void)fputs(vsb_data(vl->vsb), stdout); + vsb_clear(vl->vsb); + if (lvl == 0) + exit (1); +} + +/********************************************************************** + * Dump a string + */ + +void +vtc_dump(struct vtclog *vl, unsigned lvl, const char *pfx, const char *str) +{ + int nl = 1; + + assert(lvl < NLEAD); + if (lvl > vtc_verbosity) + return; + if (pfx == NULL) + pfx = ""; + if (str == NULL) + vsb_printf(vl->vsb, "%s %-4s %s(null)\n", + lead[lvl], vl->id, pfx); + else + for(; *str; str++) { + if (nl) { + vsb_printf(vl->vsb, "%s %-4s %s| ", + lead[lvl], vl->id, pfx); + nl = 0; + } + if (*str == '\r') + vsb_printf(vl->vsb, "\\r"); + else if (*str == '\t') + vsb_printf(vl->vsb, "\\t"); + else if (*str == '\n') { + vsb_printf(vl->vsb, "\\n\n"); + nl = 1; + } else if (*str < 0x20 || *str > 0x7e) + vsb_printf(vl->vsb, "\\x%02x", *str); + else + vsb_printf(vl->vsb, "%c", *str); + } + if (!nl) + vsb_printf(vl->vsb, "\n"); + vsb_finish(vl->vsb); + AZ(vsb_overflowed(vl->vsb)); + (void)fputs(vsb_data(vl->vsb), stdout); + vsb_clear(vl->vsb); + if (lvl == 0) + exit (1); +} From phk at projects.linpro.no Fri Jun 20 12:43:45 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Fri, 20 Jun 2008 14:43:45 +0200 (CEST) Subject: r2743 - in trunk/varnish-cache/bin: varnishd varnishtest/tests Message-ID: <20080620124345.74A4B1EC114@projects.linpro.no> Author: phk Date: 2008-06-20 14:43:45 +0200 (Fri, 20 Jun 2008) New Revision: 2743 Added: trunk/varnish-cache/bin/varnishtest/tests/r00251.vtc Modified: trunk/varnish-cache/bin/varnishd/cache_vrt_re.c Log: Make regsub() return an empty string if it gets no input. Fixes ticket 251 (regression test added) Modified: trunk/varnish-cache/bin/varnishd/cache_vrt_re.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_vrt_re.c 2008-06-20 12:25:25 UTC (rev 2742) +++ trunk/varnish-cache/bin/varnishd/cache_vrt_re.c 2008-06-20 12:43:45 UTC (rev 2743) @@ -115,6 +115,8 @@ unsigned u, x; AN(re); + if (str == NULL) + return (""); t = re; i = regexec(t, str, 10, pm, 0); Added: trunk/varnish-cache/bin/varnishtest/tests/r00251.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/r00251.vtc (rev 0) +++ trunk/varnish-cache/bin/varnishtest/tests/r00251.vtc 2008-06-20 12:43:45 UTC (rev 2743) @@ -0,0 +1,33 @@ +# $Id$ + +test "Regression test for #251: segfault on regsub on missing http header" + +server s1 { + rxreq + txresp \ + -hdr "Foobar: _barf_" \ + -hdr "Connection: close" \ + -body "012345\n" +} + +varnish v1 -vcl+backend { + sub vcl_fetch { + set obj.http.Snafu1 = + "zoom" + regsub(obj.http.Foomble, "ar", "\0\0") + "box"; + } +} -start + +server s1 -start + +client c1 { + txreq -url "/" + rxresp + expect resp.status == 200 + expect resp.http.X-Varnish == "1001" + expect resp.http.foobar == "_barf_" + expect resp.http.snafu1 == "zoombox" +} + +client c1 -run From phk at projects.linpro.no Fri Jun 20 13:08:52 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Fri, 20 Jun 2008 15:08:52 +0200 (CEST) Subject: r2744 - in trunk/varnish-cache: bin/varnishd include Message-ID: <20080620130852.837021EC0FD@projects.linpro.no> Author: phk Date: 2008-06-20 15:08:52 +0200 (Fri, 20 Jun 2008) New Revision: 2744 Modified: trunk/varnish-cache/bin/varnishd/cache_hash.c trunk/varnish-cache/bin/varnishd/heritage.h trunk/varnish-cache/bin/varnishd/mgt_param.c trunk/varnish-cache/include/shmlog_tags.h Log: Add a param "log_hashstring" that controls logging of the completed hash string in SHM log under the "Hash" tag. Enabling this increases pressure on the SHM log considerably, so don't enable it, unless you need it. Modified: trunk/varnish-cache/bin/varnishd/cache_hash.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_hash.c 2008-06-20 12:43:45 UTC (rev 2743) +++ trunk/varnish-cache/bin/varnishd/cache_hash.c 2008-06-20 13:08:52 UTC (rev 2744) @@ -248,6 +248,8 @@ /* We found an object we like */ o->refcnt++; UNLOCK(&oh->mtx); + if (params->log_hash) + WSP(sp, SLT_Hash, "%s", oh->hash); (void)hash->deref(oh); return (o); } @@ -273,6 +275,8 @@ grace_o->refcnt++; } UNLOCK(&oh->mtx); + if (params->log_hash) + WSP(sp, SLT_Hash, "%s", oh->hash); /* * XXX: This may be too early, relative to pass objects. * XXX: possibly move to when we commit to have it in the cache. Modified: trunk/varnish-cache/bin/varnishd/heritage.h =================================================================== --- trunk/varnish-cache/bin/varnishd/heritage.h 2008-06-20 12:43:45 UTC (rev 2743) +++ trunk/varnish-cache/bin/varnishd/heritage.h 2008-06-20 13:08:52 UTC (rev 2744) @@ -159,6 +159,9 @@ /* Default grace period */ unsigned default_grace; + + /* Log hash string to shm */ + unsigned log_hash; }; extern volatile struct params *params; Modified: trunk/varnish-cache/bin/varnishd/mgt_param.c =================================================================== --- trunk/varnish-cache/bin/varnishd/mgt_param.c 2008-06-20 12:43:45 UTC (rev 2743) +++ trunk/varnish-cache/bin/varnishd/mgt_param.c 2008-06-20 13:08:52 UTC (rev 2744) @@ -743,6 +743,10 @@ "NB: Must be specified with -p to have effect.\n", 0, "8192", "bytes" }, + { "log_hashstring", tweak_bool, &master.log_hash, 0, 0, + "Log the hash string to shared memory log.\n", + 0, + "off", "bool" }, { "diag_bitmap", tweak_diag_bitmap, 0, 0, 0, "Bitmap controlling diagnostics code:\n" " 0x00000001 - CNT_Session states.\n" Modified: trunk/varnish-cache/include/shmlog_tags.h =================================================================== --- trunk/varnish-cache/include/shmlog_tags.h 2008-06-20 12:43:45 UTC (rev 2743) +++ trunk/varnish-cache/include/shmlog_tags.h 2008-06-20 13:08:52 UTC (rev 2744) @@ -97,3 +97,5 @@ SLTM(ESItrace) SLTM(ESI_xmlerror) + +SLTM(Hash) From phk at projects.linpro.no Fri Jun 20 14:47:51 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Fri, 20 Jun 2008 16:47:51 +0200 (CEST) Subject: r2745 - trunk/varnish-cache/bin/varnishd Message-ID: <20080620144751.29E501ED1BF@projects.linpro.no> Author: phk Date: 2008-06-20 16:47:50 +0200 (Fri, 20 Jun 2008) New Revision: 2745 Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor.c trunk/varnish-cache/bin/varnishd/heritage.h trunk/varnish-cache/bin/varnishd/mgt_param.c Log: Add a boolean paramter "log_local_address" which enables logging of the local socket address in the SessionOpen records in SHM. This costs us an extra getsockname(2) call per connection, so default to off. SHM clients can tell the state of this option by the number of fields in SessionOpen: 3 (off) or 4 (on). Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_acceptor.c 2008-06-20 13:08:52 UTC (rev 2744) +++ trunk/varnish-cache/bin/varnishd/cache_acceptor.c 2008-06-20 14:47:50 UTC (rev 2745) @@ -119,8 +119,16 @@ addr, sizeof addr, port, sizeof port); sp->addr = WS_Dup(sp->ws, addr); sp->port = WS_Dup(sp->ws, port); - VSL(SLT_SessionOpen, sp->fd, "%s %s %s", - sp->addr, sp->port, sp->mylsock->name); + if (params->log_local_addr) { + AZ(getsockname(sp->fd, sp->mysockaddr, &sp->mysockaddrlen)); + TCP_name(sp->mysockaddr, sp->mysockaddrlen, + addr, sizeof addr, port, sizeof port); + VSL(SLT_SessionOpen, sp->fd, "%s %s %s %s", + sp->addr, sp->port, addr, port); + } else { + VSL(SLT_SessionOpen, sp->fd, "%s %s %s", + sp->addr, sp->port, sp->mylsock->name); + } sp->acct.first = sp->t_open; if (need_test) sock_test(sp->fd); Modified: trunk/varnish-cache/bin/varnishd/heritage.h =================================================================== --- trunk/varnish-cache/bin/varnishd/heritage.h 2008-06-20 13:08:52 UTC (rev 2744) +++ trunk/varnish-cache/bin/varnishd/heritage.h 2008-06-20 14:47:50 UTC (rev 2745) @@ -162,6 +162,9 @@ /* Log hash string to shm */ unsigned log_hash; + + /* Log local socket address to shm */ + unsigned log_local_addr; }; extern volatile struct params *params; Modified: trunk/varnish-cache/bin/varnishd/mgt_param.c =================================================================== --- trunk/varnish-cache/bin/varnishd/mgt_param.c 2008-06-20 13:08:52 UTC (rev 2744) +++ trunk/varnish-cache/bin/varnishd/mgt_param.c 2008-06-20 14:47:50 UTC (rev 2745) @@ -747,6 +747,11 @@ "Log the hash string to shared memory log.\n", 0, "off", "bool" }, + { "log_local_address", tweak_bool, &master.log_local_addr, 0, 0, + "Log the local address on the TCP connection in the " + "SessionOpen shared memory record.\n", + 0, + "off", "bool" }, { "diag_bitmap", tweak_diag_bitmap, 0, 0, 0, "Bitmap controlling diagnostics code:\n" " 0x00000001 - CNT_Session states.\n" From phk at projects.linpro.no Fri Jun 20 14:51:51 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Fri, 20 Jun 2008 16:51:51 +0200 (CEST) Subject: r2746 - trunk/varnish-cache/man Message-ID: <20080620145151.993E31EC404@projects.linpro.no> Author: phk Date: 2008-06-20 16:51:51 +0200 (Fri, 20 Jun 2008) New Revision: 2746 Modified: trunk/varnish-cache/man/vcl.7 Log: Mention that strings use %xx escapes in VCL. Closes 252 Modified: trunk/varnish-cache/man/vcl.7 =================================================================== --- trunk/varnish-cache/man/vcl.7 2008-06-20 14:47:50 UTC (rev 2745) +++ trunk/varnish-cache/man/vcl.7 2008-06-20 14:51:51 UTC (rev 2746) @@ -57,7 +57,7 @@ matching using the ~ operator. .Pp Unlike C and Perl, the backslash (\\) character has no special meaning -in strings in VCL, +in strings in VCL, which use the (%xx) escape mechanism just like URLs, so it can be freely used in regular expressions without doubling. .Pp Assignments are introduced with the From phk at projects.linpro.no Fri Jun 20 15:26:03 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Fri, 20 Jun 2008 17:26:03 +0200 (CEST) Subject: r2747 - in trunk/varnish-cache/bin/varnishtest: . tests Message-ID: <20080620152603.6829C1EC0FD@projects.linpro.no> Author: phk Date: 2008-06-20 17:26:02 +0200 (Fri, 20 Jun 2008) New Revision: 2747 Added: trunk/varnish-cache/bin/varnishtest/tests/a00006.vtc Modified: trunk/varnish-cache/bin/varnishtest/vtc_http.c Log: More support for message bodies Added: trunk/varnish-cache/bin/varnishtest/tests/a00006.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/a00006.vtc (rev 0) +++ trunk/varnish-cache/bin/varnishtest/tests/a00006.vtc 2008-06-20 15:26:02 UTC (rev 2747) @@ -0,0 +1,37 @@ +# $Id$ + +test "dual shared client HTTP transactions" + +server s1 -listen :9080 { + rxreq + expect req.request == PUT + expect req.proto == HTTP/1.0 + expect req.url == "/foo" + txresp -proto HTTP/1.2 -status 201 -msg Foo \ + -hdr "Length: 10" \ + -body "987654321\n" +} + +server s1 -start + +client c1 -connect localhost:9080 { + txreq -req PUT -proto HTTP/1.0 -url /foo \ + -hdr "Length: 10" \ + -body "123456789\n" + rxresp + expect resp.proto == HTTP/1.2 + expect resp.status == 201 + expect resp.msg == Foo +} + +client c1 -run + +client c1 -connect localhost:9081 { + txreq + rxresp + expect resp.proto == HTTP/1.1 + expect resp.status == 200 + expect resp.msg == Ok +} + +server s1 -wait Modified: trunk/varnish-cache/bin/varnishtest/vtc_http.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_http.c 2008-06-20 14:51:51 UTC (rev 2746) +++ trunk/varnish-cache/bin/varnishtest/vtc_http.c 2008-06-20 15:26:02 UTC (rev 2747) @@ -59,6 +59,28 @@ }; /********************************************************************** + * find header + */ + +static char * +http_find_header(char **hh, const char *hdr) +{ + int n, l; + char *r; + + l = strlen(hdr); + + for (n = 3; hh[n] != NULL; n++) { + if (strncasecmp(hdr, hh[n], l) || hh[n][l] != ':') + continue; + for (r = hh[n] + l + 1; vct_issp(*r); r++) + continue; + return (r); + } + return (NULL); +} + +/********************************************************************** * Expect */ @@ -66,7 +88,6 @@ cmd_var_resolve(struct http *hp, char *spec) { char **hh, *hdr; - int n, l; if (!strcmp(spec, "req.request")) return(hp->req[0]); @@ -88,15 +109,9 @@ hdr = spec + 10; } else return (spec); - l = strlen(hdr); - for (n = 3; hh[n] != NULL; n++) { - if (strncasecmp(hdr, hh[n], l) || hh[n][l] != ':') - continue; - hdr = hh[n] + l + 1; - while (vct_issp(*hdr)) - hdr++; + hdr = http_find_header(hh, hdr); + if (hdr != NULL) return (hdr); - } return (spec); } @@ -215,6 +230,33 @@ /********************************************************************** + * Swallow a HTTP message body + */ + +static void +http_swallow_body(struct http *hp, char **hh) +{ + char *p, b[BUFSIZ + 1]; + int l, i; + + + p = http_find_header(hh, "length"); + if (p == NULL) + return; + l = strtoul(p, NULL, 0); + while (l > 0) { + i = sizeof b - 1; + if (i > l) + i = l; + i = read(hp->fd, b, i); + assert(i > 0); + b[i] = '\0'; + vtc_dump(hp->vl, 4, "body", b); + l -= i; + } +} + +/********************************************************************** * Receive a HTTP protocol header */ @@ -279,6 +321,7 @@ vtc_log(hp->vl, 3, "rxresp"); http_rxhdr(hp); http_splitheader(hp, 0); + http_swallow_body(hp, hp->resp); } /********************************************************************** @@ -381,6 +424,7 @@ vtc_log(hp->vl, 3, "rxreq"); http_rxhdr(hp); http_splitheader(hp, 1); + http_swallow_body(hp, hp->req); } /********************************************************************** @@ -395,6 +439,7 @@ const char *req = "GET"; const char *url = "/"; const char *proto = "HTTP/1.1"; + const char *body = NULL; int dohdr = 0; const char *nl = "\r\n"; int l; @@ -435,6 +480,11 @@ av++; continue; } + if (!strcmp(*av, "-body")) { + body = av[1]; + av++; + continue; + } fprintf(stderr, "Unknown http txreq spec: %s\n", *av); exit (1); } @@ -444,6 +494,10 @@ dohdr = 1; } vsb_cat(vsb, nl); + if (body != NULL) { + vsb_cat(vsb, body); + vsb_cat(vsb, nl); + } vsb_finish(vsb); AZ(vsb_overflowed(vsb)); vtc_dump(hp->vl, 4, NULL, vsb_data(vsb)); From phk at projects.linpro.no Fri Jun 20 15:34:15 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Fri, 20 Jun 2008 17:34:15 +0200 (CEST) Subject: r2748 - trunk/varnish-cache/bin/varnishtest/tests Message-ID: <20080620153415.2133E1EC0FD@projects.linpro.no> Author: phk Date: 2008-06-20 17:34:14 +0200 (Fri, 20 Jun 2008) New Revision: 2748 Added: trunk/varnish-cache/bin/varnishtest/tests/a00007.vtc Modified: trunk/varnish-cache/bin/varnishtest/tests/a00006.vtc Log: Add a TCP reuse testcase, and polish the a00006 case a bit Modified: trunk/varnish-cache/bin/varnishtest/tests/a00006.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/a00006.vtc 2008-06-20 15:26:02 UTC (rev 2747) +++ trunk/varnish-cache/bin/varnishtest/tests/a00006.vtc 2008-06-20 15:34:14 UTC (rev 2748) @@ -1,6 +1,6 @@ # $Id$ -test "dual shared client HTTP transactions" +test "bidirectional message bodies" server s1 -listen :9080 { rxreq @@ -26,12 +26,4 @@ client c1 -run -client c1 -connect localhost:9081 { - txreq - rxresp - expect resp.proto == HTTP/1.1 - expect resp.status == 200 - expect resp.msg == Ok -} - server s1 -wait Added: trunk/varnish-cache/bin/varnishtest/tests/a00007.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/a00007.vtc (rev 0) +++ trunk/varnish-cache/bin/varnishtest/tests/a00007.vtc 2008-06-20 15:34:14 UTC (rev 2748) @@ -0,0 +1,25 @@ +# $Id$ + +test "TCP reuse" + +server s1 -listen :9080 { + rxreq + expect req.url == "/1" + txresp -hdr "Length: 10" -body "123456789\n" + rxreq + expect req.url == "/2" + txresp -hdr "Length: 10" -body "987654321\n" +} + +server s1 -start + +client c1 -connect localhost:9080 { + txreq -url "/1" -req "POST" -hdr "Length: 10" -body "abcdefghi\n" + rxresp + txreq -url "/2" -req "POST" -hdr "Length: 10" -body "ihgfedcba\n" + rxresp +} + +client c1 -run + +server s1 -wait From phk at projects.linpro.no Fri Jun 20 15:49:11 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Fri, 20 Jun 2008 17:49:11 +0200 (CEST) Subject: r2749 - in trunk/varnish-cache/bin/varnishtest: . tests Message-ID: <20080620154911.3C4501EC0B3@projects.linpro.no> Author: phk Date: 2008-06-20 17:49:10 +0200 (Fri, 20 Jun 2008) New Revision: 2749 Added: trunk/varnish-cache/bin/varnishtest/tests/r00102.vtc Modified: trunk/varnish-cache/bin/varnishtest/tests/a00006.vtc trunk/varnish-cache/bin/varnishtest/tests/a00007.vtc trunk/varnish-cache/bin/varnishtest/vtc_http.c Log: Spell "content-length" correctly. Add regresion test for ticket 102 Modified: trunk/varnish-cache/bin/varnishtest/tests/a00006.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/a00006.vtc 2008-06-20 15:34:14 UTC (rev 2748) +++ trunk/varnish-cache/bin/varnishtest/tests/a00006.vtc 2008-06-20 15:49:10 UTC (rev 2749) @@ -8,7 +8,7 @@ expect req.proto == HTTP/1.0 expect req.url == "/foo" txresp -proto HTTP/1.2 -status 201 -msg Foo \ - -hdr "Length: 10" \ + -hdr "Content-Length: 10" \ -body "987654321\n" } @@ -16,7 +16,7 @@ client c1 -connect localhost:9080 { txreq -req PUT -proto HTTP/1.0 -url /foo \ - -hdr "Length: 10" \ + -hdr "Content-Length: 10" \ -body "123456789\n" rxresp expect resp.proto == HTTP/1.2 Modified: trunk/varnish-cache/bin/varnishtest/tests/a00007.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/a00007.vtc 2008-06-20 15:34:14 UTC (rev 2748) +++ trunk/varnish-cache/bin/varnishtest/tests/a00007.vtc 2008-06-20 15:49:10 UTC (rev 2749) @@ -5,18 +5,20 @@ server s1 -listen :9080 { rxreq expect req.url == "/1" - txresp -hdr "Length: 10" -body "123456789\n" + txresp -hdr "Content-Length: 10" -body "123456789\n" rxreq expect req.url == "/2" - txresp -hdr "Length: 10" -body "987654321\n" + txresp -hdr "Content-Length: 10" -body "987654321\n" } server s1 -start client c1 -connect localhost:9080 { - txreq -url "/1" -req "POST" -hdr "Length: 10" -body "abcdefghi\n" + txreq -url "/1" -req "POST" \ + -hdr "Content-Length: 10" -body "abcdefghi\n" rxresp - txreq -url "/2" -req "POST" -hdr "Length: 10" -body "ihgfedcba\n" + txreq -url "/2" -req "POST" \ + -hdr "Content-Length: 10" -body "ihgfedcba\n" rxresp } Added: trunk/varnish-cache/bin/varnishtest/tests/r00102.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/r00102.vtc (rev 0) +++ trunk/varnish-cache/bin/varnishtest/tests/r00102.vtc 2008-06-20 15:49:10 UTC (rev 2749) @@ -0,0 +1,38 @@ +# $Id$ + +test "Test VCL regsub()" + +server s1 { + rxreq + txresp \ + -hdr "Connection: close" \ + -body "012345\n" +} + +varnish v1 -vcl+backend { + sub vcl_recv { + if (req.request == "POST") { + set req.request = "GET"; + } + } +} -start + +server s1 -start + +client c1 { + txreq -req POST -url "/" \ + -hdr "Content-Length: 10" \ + -body "123456789\n" + rxresp + expect resp.status == 200 + expect resp.http.X-Varnish == "1001" + + txreq -req POST -url "/" \ + -hdr "Content-Length: 10" \ + -body "123456789\n" + rxresp + expect resp.status == 200 + expect resp.http.X-Varnish == "1002 1001" +} + +client c1 -run Modified: trunk/varnish-cache/bin/varnishtest/vtc_http.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_http.c 2008-06-20 15:34:14 UTC (rev 2748) +++ trunk/varnish-cache/bin/varnishtest/vtc_http.c 2008-06-20 15:49:10 UTC (rev 2749) @@ -240,7 +240,7 @@ int l, i; - p = http_find_header(hh, "length"); + p = http_find_header(hh, "content-length"); if (p == NULL) return; l = strtoul(p, NULL, 0); From phk at projects.linpro.no Fri Jun 20 21:16:22 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Fri, 20 Jun 2008 23:16:22 +0200 (CEST) Subject: r2750 - trunk/varnish-cache/bin/varnishd Message-ID: <20080620211622.D59F21EC0FD@projects.linpro.no> Author: phk Date: 2008-06-20 23:16:22 +0200 (Fri, 20 Jun 2008) New Revision: 2750 Modified: trunk/varnish-cache/bin/varnishd/cache.h trunk/varnish-cache/bin/varnishd/cache_ban.c trunk/varnish-cache/bin/varnishd/cache_vrt.c Log: Rename AddBan() to BAN_Add() for consistency. Modified: trunk/varnish-cache/bin/varnishd/cache.h =================================================================== --- trunk/varnish-cache/bin/varnishd/cache.h 2008-06-20 15:49:10 UTC (rev 2749) +++ trunk/varnish-cache/bin/varnishd/cache.h 2008-06-20 21:16:22 UTC (rev 2750) @@ -426,7 +426,7 @@ void VBE_SelectBackend(struct sess *sp); /* cache_ban.c */ -void AddBan(const char *, int hash); +void BAN_Add(const char *, int hash); void BAN_Init(void); void BAN_NewObj(struct object *o); void BAN_DestroyObj(struct object *o); Modified: trunk/varnish-cache/bin/varnishd/cache_ban.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_ban.c 2008-06-20 15:49:10 UTC (rev 2749) +++ trunk/varnish-cache/bin/varnishd/cache_ban.c 2008-06-20 21:16:22 UTC (rev 2750) @@ -66,7 +66,7 @@ static struct ban * volatile ban_start; void -AddBan(const char *regexp, int hash) +BAN_Add(const char *regexp, int hash) { struct ban *b; int i; @@ -179,7 +179,7 @@ { (void)priv; - AddBan(av[2], 0); + BAN_Add(av[2], 0); cli_out(cli, "URL_PURGE %s\n", av[2]); } @@ -188,7 +188,7 @@ { (void)priv; - AddBan(av[2], 1); + BAN_Add(av[2], 1); cli_out(cli, "HASH_PURGE %s\n", av[2]); } @@ -235,5 +235,6 @@ MTX_INIT(&ban_mtx); CLI_AddFuncs(PUBLIC_CLI, ban_cmds); - AddBan("^\001$", 0); + /* Add an initial ban, since the list can never be empty */ + BAN_Add(".", 0); } Modified: trunk/varnish-cache/bin/varnishd/cache_vrt.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_vrt.c 2008-06-20 15:49:10 UTC (rev 2749) +++ trunk/varnish-cache/bin/varnishd/cache_vrt.c 2008-06-20 21:16:22 UTC (rev 2750) @@ -638,7 +638,7 @@ VRT_purge(const char *regexp, int hash) { - AddBan(regexp, hash); + BAN_Add(regexp, hash); } /*-------------------------------------------------------------------- From phk at projects.linpro.no Fri Jun 20 21:33:22 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Fri, 20 Jun 2008 23:33:22 +0200 (CEST) Subject: r2751 - trunk/varnish-cache/bin/varnishd Message-ID: <20080620213323.005031EC0FD@projects.linpro.no> Author: phk Date: 2008-06-20 23:33:21 +0200 (Fri, 20 Jun 2008) New Revision: 2751 Modified: trunk/varnish-cache/bin/varnishd/cache.h trunk/varnish-cache/bin/varnishd/cache_ban.c trunk/varnish-cache/bin/varnishd/cache_vrt.c Log: Give BAN_Add() an (option) cli argument so errors can be reported but also give it a return value since we don't have a cli in VCL. However, I'm not sure how we will report the error in VCL, so still log the trouble in shmlog. Modified: trunk/varnish-cache/bin/varnishd/cache.h =================================================================== --- trunk/varnish-cache/bin/varnishd/cache.h 2008-06-20 21:16:22 UTC (rev 2750) +++ trunk/varnish-cache/bin/varnishd/cache.h 2008-06-20 21:33:21 UTC (rev 2751) @@ -426,7 +426,7 @@ void VBE_SelectBackend(struct sess *sp); /* cache_ban.c */ -void BAN_Add(const char *, int hash); +int BAN_Add(struct cli *cli, const char *regexp, int hash); void BAN_Init(void); void BAN_NewObj(struct object *o); void BAN_DestroyObj(struct object *o); Modified: trunk/varnish-cache/bin/varnishd/cache_ban.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_ban.c 2008-06-20 21:16:22 UTC (rev 2750) +++ trunk/varnish-cache/bin/varnishd/cache_ban.c 2008-06-20 21:33:21 UTC (rev 2751) @@ -65,22 +65,29 @@ */ static struct ban * volatile ban_start; -void -BAN_Add(const char *regexp, int hash) +int +BAN_Add(struct cli *cli, const char *regexp, int hash) { struct ban *b; + char buf[512]; int i; ALLOC_OBJ(b, BAN_MAGIC); - XXXAN(b); + if (b == NULL) { + cli_out(cli, "Out of Memory"); + cli_result(cli, CLIS_CANT); + return (-1); + } i = regcomp(&b->regexp, regexp, REG_EXTENDED | REG_ICASE | REG_NOSUB); if (i) { - char buf[512]; - (void)regerror(i, &b->regexp, buf, sizeof buf); + regfree(&b->regexp); VSL(SLT_Debug, 0, "REGEX: <%s>", buf); - return; + cli_out(cli, "%s", buf); + cli_result(cli, CLIS_PARAM); + FREE_OBJ(b); + return (-1); } b->hash = hash; b->ban = strdup(regexp); @@ -89,6 +96,7 @@ VTAILQ_INSERT_HEAD(&ban_head, b, list); ban_start = b; UNLOCK(&ban_mtx); + return (0); } void @@ -179,8 +187,7 @@ { (void)priv; - BAN_Add(av[2], 0); - cli_out(cli, "URL_PURGE %s\n", av[2]); + (void)BAN_Add(cli, av[2], 0); } static void @@ -188,8 +195,7 @@ { (void)priv; - BAN_Add(av[2], 1); - cli_out(cli, "HASH_PURGE %s\n", av[2]); + (void)BAN_Add(cli, av[2], 1); } static void @@ -211,7 +217,9 @@ if (b0->refcount == 0 && VTAILQ_NEXT(b0, list) == NULL) break; cli_out(cli, "%5u %s \"%s\"\n", - b0->refcount, b0->hash ? "hash" : "url ", b0->ban); + b0->refcount, + b0->hash ? "hash" : "url ", + b0->ban); } } @@ -236,5 +244,5 @@ MTX_INIT(&ban_mtx); CLI_AddFuncs(PUBLIC_CLI, ban_cmds); /* Add an initial ban, since the list can never be empty */ - BAN_Add(".", 0); + (void)BAN_Add(NULL, ".", 0); } Modified: trunk/varnish-cache/bin/varnishd/cache_vrt.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_vrt.c 2008-06-20 21:16:22 UTC (rev 2750) +++ trunk/varnish-cache/bin/varnishd/cache_vrt.c 2008-06-20 21:33:21 UTC (rev 2751) @@ -638,7 +638,7 @@ VRT_purge(const char *regexp, int hash) { - BAN_Add(regexp, hash); + (void)BAN_Add(NULL, regexp, hash); } /*-------------------------------------------------------------------- From tfheen at projects.linpro.no Sat Jun 21 06:42:34 2008 From: tfheen at projects.linpro.no (tfheen at projects.linpro.no) Date: Sat, 21 Jun 2008 08:42:34 +0200 (CEST) Subject: r2752 - trunk/varnish-cache/bin/varnishd Message-ID: <20080621064234.603DC1EC0B3@projects.linpro.no> Author: tfheen Date: 2008-06-21 08:42:34 +0200 (Sat, 21 Jun 2008) New Revision: 2752 Modified: trunk/varnish-cache/bin/varnishd/cache_vrt_re.c Log: Use subtraction rather than digittoint since digittoint does not exist on non-BSDs Modified: trunk/varnish-cache/bin/varnishd/cache_vrt_re.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_vrt_re.c 2008-06-20 21:33:21 UTC (rev 2751) +++ trunk/varnish-cache/bin/varnishd/cache_vrt_re.c 2008-06-21 06:42:34 UTC (rev 2752) @@ -140,7 +140,7 @@ } s++; if (isdigit(*s)) { - x = digittoint(*s); + x = *s - '0'; l = pm[x].rm_eo - pm[x].rm_so; Tadd(&res, str + pm[x].rm_so, l); continue; From phk at projects.linpro.no Sat Jun 21 07:48:02 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Sat, 21 Jun 2008 09:48:02 +0200 (CEST) Subject: r2753 - trunk/varnish-cache/bin/varnishd Message-ID: <20080621074802.8E4DA1EC11A@projects.linpro.no> Author: phk Date: 2008-06-21 09:48:02 +0200 (Sat, 21 Jun 2008) New Revision: 2753 Modified: trunk/varnish-cache/bin/varnishd/mgt_param.c trunk/varnish-cache/bin/varnishd/varnishd.c Log: Fix the default thread pool parameters to 2 pools, 500 threads and 300 seconds. Add usage for -u while here. Modified: trunk/varnish-cache/bin/varnishd/mgt_param.c =================================================================== --- trunk/varnish-cache/bin/varnishd/mgt_param.c 2008-06-21 06:42:34 UTC (rev 2752) +++ trunk/varnish-cache/bin/varnishd/mgt_param.c 2008-06-21 07:48:02 UTC (rev 2753) @@ -477,7 +477,7 @@ "Can be increased on the fly, but decreases require a " "restart to take effect.", EXPERIMENTAL | DELAYED_EFFECT, - "1", "pools" }, + "2", "pools" }, { "thread_pool_max", tweak_thread_pool_max, NULL, 1, 0, "The maximum number of worker threads in all pools combined.\n" "\n" @@ -485,7 +485,7 @@ "worker threads soak up RAM and CPU and generally just get " "in the way of getting work done.\n", EXPERIMENTAL | DELAYED_EFFECT, - "100", "threads" }, + "500", "threads" }, { "thread_pool_min", tweak_thread_pool_min, NULL, 1, 0, "The minimum number of threads in all worker pools combined.\n" "\n" Modified: trunk/varnish-cache/bin/varnishd/varnishd.c =================================================================== --- trunk/varnish-cache/bin/varnishd/varnishd.c 2008-06-21 06:42:34 UTC (rev 2752) +++ trunk/varnish-cache/bin/varnishd/varnishd.c 2008-06-21 07:48:02 UTC (rev 2753) @@ -157,14 +157,9 @@ fprintf(stderr, FMT, "-w int[,int[,int]]", "Number of worker threads"); fprintf(stderr, FMT, "", " -w "); fprintf(stderr, FMT, "", " -w min,max"); - fprintf(stderr, FMT, "", " -w min,max,timeout [default: -w1,1000,120]"); + fprintf(stderr, FMT, "", " -w min,max,timeout [default: -w2,500,300]"); + fprintf(stderr, FMT, "-u user", "Priviledge separation user id"); #undef FMT -#if 0 - -c clusterid at cluster_controller - -m memory_limit - -u uid - -a CLI_port -#endif exit(1); } From phk at projects.linpro.no Sat Jun 21 08:39:15 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Sat, 21 Jun 2008 10:39:15 +0200 (CEST) Subject: r2754 - trunk/varnish-cache/bin/varnishd Message-ID: <20080621083915.BE2861EC220@projects.linpro.no> Author: phk Date: 2008-06-21 10:39:14 +0200 (Sat, 21 Jun 2008) New Revision: 2754 Modified: trunk/varnish-cache/bin/varnishd/cache_expire.c Log: Assert that deadlines are not NAN Modified: trunk/varnish-cache/bin/varnishd/cache_expire.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_expire.c 2008-06-21 07:48:02 UTC (rev 2753) +++ trunk/varnish-cache/bin/varnishd/cache_expire.c 2008-06-21 08:39:14 UTC (rev 2754) @@ -55,6 +55,7 @@ #include #include #include +#include #include "shmlog.h" #include "binary_heap.h" @@ -150,6 +151,7 @@ oe->timer_when = o->ttl + HSH_Grace(o->grace); oe->timer_what = tmr_ttl; } + assert(!isnan(oe->timer_when)); } /*-------------------------------------------------------------------- @@ -259,7 +261,7 @@ struct object *o; double t; struct sess *sp; - unsigned char log[1024]; /* XXX size ? */ + unsigned char logbuf[1024]; /* XXX size ? */ THR_Name("cache-timeout"); (void)arg; @@ -268,8 +270,8 @@ XXXAN(sp); sp->wrk = &ww; ww.magic = WORKER_MAGIC; - ww.wlp = ww.wlb = log; - ww.wle = log + sizeof log; + ww.wlp = ww.wlb = logbuf; + ww.wle = logbuf + sizeof logbuf; AZ(sleep(10)); /* XXX: Takes time for VCL to arrive */ VCL_Get(&sp->vcl); From phk at projects.linpro.no Sat Jun 21 17:18:16 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Sat, 21 Jun 2008 19:18:16 +0200 (CEST) Subject: r2755 - trunk/varnish-cache/bin/varnishd Message-ID: <20080621171816.46E981EC11A@projects.linpro.no> Author: phk Date: 2008-06-21 19:18:15 +0200 (Sat, 21 Jun 2008) New Revision: 2755 Modified: trunk/varnish-cache/bin/varnishd/mgt_param.c Log: Go back to 1 pool by default, there is a startup problem if you only get a single request. Modified: trunk/varnish-cache/bin/varnishd/mgt_param.c =================================================================== --- trunk/varnish-cache/bin/varnishd/mgt_param.c 2008-06-21 08:39:14 UTC (rev 2754) +++ trunk/varnish-cache/bin/varnishd/mgt_param.c 2008-06-21 17:18:15 UTC (rev 2755) @@ -477,7 +477,7 @@ "Can be increased on the fly, but decreases require a " "restart to take effect.", EXPERIMENTAL | DELAYED_EFFECT, - "2", "pools" }, + "1", "pools" }, { "thread_pool_max", tweak_thread_pool_max, NULL, 1, 0, "The maximum number of worker threads in all pools combined.\n" "\n" From phk at projects.linpro.no Sat Jun 21 18:37:48 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Sat, 21 Jun 2008 20:37:48 +0200 (CEST) Subject: r2756 - in trunk/varnish-cache: include lib/libvarnish Message-ID: <20080621183748.D7BBD1EC40A@projects.linpro.no> Author: phk Date: 2008-06-21 20:37:48 +0200 (Sat, 21 Jun 2008) New Revision: 2756 Modified: trunk/varnish-cache/include/vct.h trunk/varnish-cache/lib/libvarnish/vct.c Log: Collapse the upper/lower alpha class until we need them separate. Add "separator" class. Modified: trunk/varnish-cache/include/vct.h =================================================================== --- trunk/varnish-cache/include/vct.h 2008-06-21 17:18:15 UTC (rev 2755) +++ trunk/varnish-cache/include/vct.h 2008-06-21 18:37:48 UTC (rev 2756) @@ -35,8 +35,8 @@ #define VCT_CRLF (1<<1) #define VCT_LWS (VCT_CRLF | VCT_SP) #define VCT_CTL (1<<2) -#define VCT_UALPHA (1<<3) -#define VCT_LOALPHA (1<<4) +#define VCT_ALPHA (1<<3) +#define VCT_SEPARATOR (1<<4) #define VCT_DIGIT (1<<5) #define VCT_HEX (1<<6) @@ -53,6 +53,8 @@ #define vct_iscrlf(x) vct_is(x, VCT_CRLF) #define vct_islws(x) vct_is(x, VCT_LWS) #define vct_isctl(x) vct_is(x, VCT_CTL) +#define vct_isalpha(x) vct_is(x, VCT_ALPHA) +#define vct_issep(x) vct_is(x, VCT_SEPARATOR) /* NB: VCT always operate in ASCII, don't replace 0x0d with \r etc. */ #define vct_skipcrlf(p) (p[0] == 0x0d && p[1] == 0x0a ? 2 : 1) Modified: trunk/varnish-cache/lib/libvarnish/vct.c =================================================================== --- trunk/varnish-cache/lib/libvarnish/vct.c 2008-06-21 17:18:15 UTC (rev 2755) +++ trunk/varnish-cache/lib/libvarnish/vct.c 2008-06-21 18:37:48 UTC (rev 2756) @@ -34,6 +34,9 @@ /* NB: VCT always operate in ASCII, don't replace 0x0d with \r etc. */ +#define VCT_UPALPHA VCT_ALPHA +#define VCT_LOALPHA VCT_ALPHA + unsigned char vct_typtab[256] = { [0x00] = VCT_CTL, [0x01] = VCT_CTL, @@ -44,7 +47,7 @@ [0x06] = VCT_CTL, [0x07] = VCT_CTL, [0x08] = VCT_CTL, - [0x09] = VCT_CTL | VCT_SP, + [0x09] = VCT_CTL | VCT_SP | VCT_SEPARATOR, [0x0a] = VCT_CTL | VCT_CRLF, [0x0b] = VCT_CTL, [0x0c] = VCT_CTL, @@ -67,7 +70,12 @@ [0x1d] = VCT_CTL, [0x1e] = VCT_CTL, [0x1f] = VCT_CTL, - [0x20] = VCT_SP, + [0x20] = VCT_SP | VCT_SEPARATOR, + [0x22] = VCT_SEPARATOR, + [0x28] = VCT_SEPARATOR, + [0x29] = VCT_SEPARATOR, + [0x2c] = VCT_SEPARATOR, + [0x2f] = VCT_SEPARATOR, [0x30] = VCT_DIGIT | VCT_HEX, [0x31] = VCT_DIGIT | VCT_HEX, [0x32] = VCT_DIGIT | VCT_HEX, @@ -78,32 +86,42 @@ [0x37] = VCT_DIGIT | VCT_HEX, [0x38] = VCT_DIGIT | VCT_HEX, [0x39] = VCT_DIGIT | VCT_HEX, - [0x41] = VCT_UALPHA | VCT_HEX, - [0x42] = VCT_UALPHA | VCT_HEX, - [0x43] = VCT_UALPHA | VCT_HEX, - [0x44] = VCT_UALPHA | VCT_HEX, - [0x45] = VCT_UALPHA | VCT_HEX, - [0x46] = VCT_UALPHA | VCT_HEX, - [0x47] = VCT_UALPHA, - [0x48] = VCT_UALPHA, - [0x49] = VCT_UALPHA, - [0x4a] = VCT_UALPHA, - [0x4b] = VCT_UALPHA, - [0x4c] = VCT_UALPHA, - [0x4d] = VCT_UALPHA, - [0x4e] = VCT_UALPHA, - [0x4f] = VCT_UALPHA, - [0x50] = VCT_UALPHA, - [0x51] = VCT_UALPHA, - [0x52] = VCT_UALPHA, - [0x53] = VCT_UALPHA, - [0x54] = VCT_UALPHA, - [0x55] = VCT_UALPHA, - [0x56] = VCT_UALPHA, - [0x57] = VCT_UALPHA, - [0x58] = VCT_UALPHA, - [0x59] = VCT_UALPHA, - [0x5a] = VCT_UALPHA, + [0x3a] = VCT_SEPARATOR, + [0x3b] = VCT_SEPARATOR, + [0x3c] = VCT_SEPARATOR, + [0x3d] = VCT_SEPARATOR, + [0x3e] = VCT_SEPARATOR, + [0x3f] = VCT_SEPARATOR, + [0x40] = VCT_SEPARATOR, + [0x41] = VCT_UPALPHA | VCT_HEX, + [0x42] = VCT_UPALPHA | VCT_HEX, + [0x43] = VCT_UPALPHA | VCT_HEX, + [0x44] = VCT_UPALPHA | VCT_HEX, + [0x45] = VCT_UPALPHA | VCT_HEX, + [0x46] = VCT_UPALPHA | VCT_HEX, + [0x47] = VCT_UPALPHA, + [0x48] = VCT_UPALPHA, + [0x49] = VCT_UPALPHA, + [0x4a] = VCT_UPALPHA, + [0x4b] = VCT_UPALPHA, + [0x4c] = VCT_UPALPHA, + [0x4d] = VCT_UPALPHA, + [0x4e] = VCT_UPALPHA, + [0x4f] = VCT_UPALPHA, + [0x50] = VCT_UPALPHA, + [0x51] = VCT_UPALPHA, + [0x52] = VCT_UPALPHA, + [0x53] = VCT_UPALPHA, + [0x54] = VCT_UPALPHA, + [0x55] = VCT_UPALPHA, + [0x56] = VCT_UPALPHA, + [0x57] = VCT_UPALPHA, + [0x58] = VCT_UPALPHA, + [0x59] = VCT_UPALPHA, + [0x5a] = VCT_UPALPHA, + [0x5b] = VCT_SEPARATOR, + [0x5c] = VCT_SEPARATOR, + [0x5d] = VCT_SEPARATOR, [0x61] = VCT_LOALPHA | VCT_HEX, [0x62] = VCT_LOALPHA | VCT_HEX, [0x63] = VCT_LOALPHA | VCT_HEX, @@ -130,5 +148,7 @@ [0x78] = VCT_LOALPHA, [0x79] = VCT_LOALPHA, [0x7a] = VCT_LOALPHA, + [0x7b] = VCT_SEPARATOR, + [0x7d] = VCT_SEPARATOR, [0x7f] = VCT_CTL, }; From phk at projects.linpro.no Sat Jun 21 18:51:29 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Sat, 21 Jun 2008 20:51:29 +0200 (CEST) Subject: r2757 - in trunk/varnish-cache: bin/varnishd bin/varnishtest include Message-ID: <20080621185129.DDDD31ED1AD@projects.linpro.no> Author: phk Date: 2008-06-21 20:51:29 +0200 (Sat, 21 Jun 2008) New Revision: 2757 Modified: trunk/varnish-cache/bin/varnishd/cache_http.c trunk/varnish-cache/bin/varnishd/rfc2616.c trunk/varnish-cache/bin/varnishtest/vtc.c trunk/varnish-cache/include/vct.h Log: Add vct_issepctl() Modified: trunk/varnish-cache/bin/varnishd/cache_http.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_http.c 2008-06-21 18:37:48 UTC (rev 2756) +++ trunk/varnish-cache/bin/varnishd/cache_http.c 2008-06-21 18:51:29 UTC (rev 2757) @@ -43,6 +43,7 @@ #include #include "shmlog.h" +#include "vct.h" #include "cache.h" #ifndef HAVE_STRLCPY @@ -244,37 +245,48 @@ return (1); } -/*--------------------------------------------------------------------*/ +/*-------------------------------------------------------------------- + * Find a given headerfield, and if present and wanted, the beginning + * of its value. + */ int http_GetHdrField(const struct http *hp, const char *hdr, const char *field, char **ptr) { - char *h; + char *h, *e; unsigned fl; + if (ptr != NULL) + *ptr = NULL; if (!http_GetHdr(hp, hdr, &h)) return (0); + AN(h); + e = strchr(h, '\0'); fl = strlen(field); - while (*h) { - if (isspace(*h)) { + while (h + fl <= e) { + /* Skip leading separators */ + if (vct_issepctl(*h)) { h++; continue; } - if (*h == ',') { + if ((h + fl == e || vct_issepctl(h[fl])) && + !memcmp(h, field, fl)) { + /* got it */ + h += fl; + if (ptr != NULL) { + while (vct_issp(*h)) + h++; + if (*h == '=') { + h++; + while (vct_issp(*h)) + h++; + *ptr = h; + } + } + return (1); + } + while (*h && !vct_issepctl(*h)) h++; - continue; - } - if (memcmp(h, field, fl) || - isalpha(h[fl]) || h[fl] == '-') { - while (*h && !(isspace(*h) || *h == ',')) - h++; - continue; - } - if (h[fl] == '=') - *ptr = &h[fl + 1]; - else - *ptr = NULL; - return (1); } return (0); } Modified: trunk/varnish-cache/bin/varnishd/rfc2616.c =================================================================== --- trunk/varnish-cache/bin/varnishd/rfc2616.c 2008-06-21 18:37:48 UTC (rev 2756) +++ trunk/varnish-cache/bin/varnishd/rfc2616.c 2008-06-21 18:51:29 UTC (rev 2757) @@ -112,6 +112,7 @@ u1 = u2 = 0; if (http_GetHdrField(hp, H_Cache_Control, "s-maxage", &p) || http_GetHdrField(hp, H_Cache_Control, "max-age", &p)) { + AN(p); u1 = strtoul(p, NULL, 0); u2 = 0; if (http_GetHdr(hp, H_Age, &p)) { Modified: trunk/varnish-cache/bin/varnishtest/vtc.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc.c 2008-06-21 18:37:48 UTC (rev 2756) +++ trunk/varnish-cache/bin/varnishtest/vtc.c 2008-06-21 18:51:29 UTC (rev 2757) @@ -40,7 +40,7 @@ #include "vtc.h" #define MAX_FILESIZE (1024 * 1024) -#define MAX_TOKENS 20 +#define MAX_TOKENS 100 /********************************************************************** * Read a file into memory Modified: trunk/varnish-cache/include/vct.h =================================================================== --- trunk/varnish-cache/include/vct.h 2008-06-21 18:37:48 UTC (rev 2756) +++ trunk/varnish-cache/include/vct.h 2008-06-21 18:51:29 UTC (rev 2757) @@ -55,6 +55,7 @@ #define vct_isctl(x) vct_is(x, VCT_CTL) #define vct_isalpha(x) vct_is(x, VCT_ALPHA) #define vct_issep(x) vct_is(x, VCT_SEPARATOR) +#define vct_issepctl(x) vct_is(x, VCT_SEPARATOR | VCT_CTL) /* NB: VCT always operate in ASCII, don't replace 0x0d with \r etc. */ #define vct_skipcrlf(p) (p[0] == 0x0d && p[1] == 0x0a ? 2 : 1) From phk at projects.linpro.no Sat Jun 21 18:55:13 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Sat, 21 Jun 2008 20:55:13 +0200 (CEST) Subject: r2758 - trunk/varnish-cache/bin/varnishd Message-ID: <20080621185513.387F51EC118@projects.linpro.no> Author: phk Date: 2008-06-21 20:55:13 +0200 (Sat, 21 Jun 2008) New Revision: 2758 Modified: trunk/varnish-cache/bin/varnishd/cache_http.c trunk/varnish-cache/bin/varnishd/rfc2616.c Log: NB: some of this commit sneaked into #2757 Fix http_GetHdrField() to use the correct RFC2616 syntax for tokens and separators. Fixes ticket #255. Modified: trunk/varnish-cache/bin/varnishd/cache_http.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_http.c 2008-06-21 18:51:29 UTC (rev 2757) +++ trunk/varnish-cache/bin/varnishd/cache_http.c 2008-06-21 18:55:13 UTC (rev 2758) @@ -269,22 +269,25 @@ h++; continue; } + /* Check for substrings before memcmp() */ if ((h + fl == e || vct_issepctl(h[fl])) && !memcmp(h, field, fl)) { /* got it */ h += fl; if (ptr != NULL) { - while (vct_issp(*h)) + /* Skip whitespace, looking for '=' */ + while (*h && vct_issp(*h)) h++; if (*h == '=') { h++; - while (vct_issp(*h)) + while (*h && vct_issp(*h)) h++; *ptr = h; } } return (1); } + /* Skip token */ while (*h && !vct_issepctl(*h)) h++; } Modified: trunk/varnish-cache/bin/varnishd/rfc2616.c =================================================================== --- trunk/varnish-cache/bin/varnishd/rfc2616.c 2008-06-21 18:51:29 UTC (rev 2757) +++ trunk/varnish-cache/bin/varnishd/rfc2616.c 2008-06-21 18:55:13 UTC (rev 2758) @@ -110,9 +110,9 @@ retirement_age = INT_MAX; u1 = u2 = 0; - if (http_GetHdrField(hp, H_Cache_Control, "s-maxage", &p) || - http_GetHdrField(hp, H_Cache_Control, "max-age", &p)) { - AN(p); + if ((http_GetHdrField(hp, H_Cache_Control, "s-maxage", &p) || + http_GetHdrField(hp, H_Cache_Control, "max-age", &p)) && + p != NULL { u1 = strtoul(p, NULL, 0); u2 = 0; if (http_GetHdr(hp, H_Age, &p)) { From phk at projects.linpro.no Sat Jun 21 18:55:42 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Sat, 21 Jun 2008 20:55:42 +0200 (CEST) Subject: r2759 - trunk/varnish-cache/bin/varnishd Message-ID: <20080621185542.F3BB61ED1AD@projects.linpro.no> Author: phk Date: 2008-06-21 20:55:42 +0200 (Sat, 21 Jun 2008) New Revision: 2759 Modified: trunk/varnish-cache/bin/varnishd/rfc2616.c Log: editor-bogon: add missing ')' Modified: trunk/varnish-cache/bin/varnishd/rfc2616.c =================================================================== --- trunk/varnish-cache/bin/varnishd/rfc2616.c 2008-06-21 18:55:13 UTC (rev 2758) +++ trunk/varnish-cache/bin/varnishd/rfc2616.c 2008-06-21 18:55:42 UTC (rev 2759) @@ -112,7 +112,7 @@ u1 = u2 = 0; if ((http_GetHdrField(hp, H_Cache_Control, "s-maxage", &p) || http_GetHdrField(hp, H_Cache_Control, "max-age", &p)) && - p != NULL { + p != NULL) { u1 = strtoul(p, NULL, 0); u2 = 0; if (http_GetHdr(hp, H_Age, &p)) { From phk at projects.linpro.no Sat Jun 21 18:57:44 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Sat, 21 Jun 2008 20:57:44 +0200 (CEST) Subject: r2760 - trunk/varnish-cache/bin/varnishtest/tests Message-ID: <20080621185744.506571EC118@projects.linpro.no> Author: phk Date: 2008-06-21 20:57:44 +0200 (Sat, 21 Jun 2008) New Revision: 2760 Added: trunk/varnish-cache/bin/varnishtest/tests/r00255.vtc Log: Regression test case for ticket 255 Added: trunk/varnish-cache/bin/varnishtest/tests/r00255.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/r00255.vtc (rev 0) +++ trunk/varnish-cache/bin/varnishtest/tests/r00255.vtc 2008-06-21 18:57:44 UTC (rev 2760) @@ -0,0 +1,28 @@ +# $Id$ + +test "Regression test for #255: Segfault on header token separation" + +server s1 { + rxreq + txresp \ + -hdr "Date: Thu, 19 Jun 2008 21:14:49 GMT" \ + -hdr "Content-Length: 7" \ + -hdr "Expires: Thu, 19 Jun 2008 21:14:49 GMT" \ + -hdr "Last-Modified: Sun, 27 Nov 2005 05:41:47 GMT" \ + -hdr "Cache-Control: max-age =0" \ + -body "012345\n" +} + +varnish v1 -vcl+backend { sub vcl_recv {set req.backend = s1;} } -start + +server s1 -start + +client c1 { + txreq -url "/" + rxresp + expect resp.status == 200 + expect resp.http.X-Varnish == "1001" + expect resp.http.Cache-Control == "max-age =0" +} + +client c1 -run From phk at projects.linpro.no Sat Jun 21 20:52:02 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Sat, 21 Jun 2008 22:52:02 +0200 (CEST) Subject: r2761 - trunk/varnish-cache/bin/varnishd Message-ID: <20080621205202.3CBF11ED1AD@projects.linpro.no> Author: phk Date: 2008-06-21 22:51:58 +0200 (Sat, 21 Jun 2008) New Revision: 2761 Modified: trunk/varnish-cache/bin/varnishd/cache_http.c Log: Use vct character classification instead of private table. Modified: trunk/varnish-cache/bin/varnishd/cache_http.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_http.c 2008-06-21 18:57:44 UTC (rev 2760) +++ trunk/varnish-cache/bin/varnishd/cache_http.c 2008-06-21 20:51:58 UTC (rev 2761) @@ -54,25 +54,6 @@ #include "http_headers.h" #undef HTTPH -#define C_SP (1<<0) -#define C_CRLF (1<<1) -#define C_LWS (C_CRLF | C_SP) -#define C_CTL (1<<2) - -static unsigned char vctyptab[256] = { - ['\t'] = C_SP, - ['\n'] = C_CRLF, - ['\r'] = C_CRLF, - [' '] = C_SP, -}; - -static int -vctyp(unsigned char x, unsigned char y) -{ - - return (vctyptab[x] & (y)); -} - #define LOGMTX2(ax, bx, cx) [bx] = SLT_##ax##cx #define LOGMTX1(ax) { \ @@ -433,36 +414,36 @@ Tcheck(htc->rxbuf); /* Skip leading LWS */ - for (p = htc->rxbuf.b ; vctyp(*p, C_LWS); p++) + for (p = htc->rxbuf.b ; vct_islws(*p); p++) continue; /* First field cannot contain SP, CRLF or CTL */ hp->hd[h1].b = p; - for (; !vctyp(*p, C_SP); p++) - if (vctyp(*p, C_CRLF | C_CTL)) + for (; !vct_issp(*p); p++) + if (vct_isctl(*p)) return (400); hp->hd[h1].e = p; /* Skip SP */ - for (; vctyp(*p, C_SP); p++) + for (; vct_issp(*p); p++) ; /* Second field cannot contain SP, CRLF or CTL */ hp->hd[h2].b = p; - for (; !vctyp(*p, C_SP); p++) - if (vctyp(*p, C_CRLF | C_CTL)) + for (; !vct_issp(*p); p++) + if (vct_isctl(*p)) return (400); hp->hd[h2].e = p; /* Skip SP */ - for (; vctyp(*p, C_SP); p++) + for (; vct_issp(*p); p++) ; /* Third field is optional and cannot contain CTL */ - if (!vctyp(*p, C_CRLF)) { + if (!vct_iscrlf(*p)) { hp->hd[h3].b = p; - for (; !vctyp(*p, C_CRLF); p++) - if (vctyp(*p, C_CTL)) + for (; !vct_iscrlf(*p); p++) + if (vct_isctl(*p)) return (400); hp->hd[h3].e = p; } else { @@ -471,9 +452,7 @@ } /* Skip CRLF */ - for (; vctyp(*p, C_CRLF); p++) - if (vctyp(*p, C_CTL)) - return (400); + p += vct_skipcrlf(p); *hp->hd[h1].e = '\0'; WSLH(w, fd, hp, h1); @@ -864,13 +843,8 @@ void HTTP_Init(void) { - int i; + #define HTTPH(a, b, c, d, e, f, g) b[0] = (char)strlen(b + 1); #include "http_headers.h" #undef HTTPH - - for (i = 1; i < 32; i++) - if (vctyptab[i] == 0) - vctyptab[i] = C_CTL; - vctyptab[127] = C_CTL; } From phk at projects.linpro.no Sat Jun 21 20:56:14 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Sat, 21 Jun 2008 22:56:14 +0200 (CEST) Subject: r2762 - trunk/varnish-cache/bin/varnishd Message-ID: <20080621205614.CF4161ED246@projects.linpro.no> Author: phk Date: 2008-06-21 22:56:14 +0200 (Sat, 21 Jun 2008) New Revision: 2762 Modified: trunk/varnish-cache/bin/varnishd/cache_http.c Log: Avoid entirely Modified: trunk/varnish-cache/bin/varnishd/cache_http.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_http.c 2008-06-21 20:51:58 UTC (rev 2761) +++ trunk/varnish-cache/bin/varnishd/cache_http.c 2008-06-21 20:56:14 UTC (rev 2762) @@ -33,7 +33,6 @@ #include "config.h" -#include #include #include #include @@ -219,7 +218,7 @@ } if (ptr != NULL) { p = hp->hd[u].b + l; - while (isspace(*p)) + while (vct_issp(*p)) p++; *ptr = p; } @@ -275,7 +274,9 @@ return (0); } -/*--------------------------------------------------------------------*/ +/*-------------------------------------------------------------------- + * XXX: redo with http_GetHdrField() ? + */ const char * http_DoConnection(struct http *hp) @@ -291,12 +292,12 @@ } ret = NULL; for (; *p; p++) { - if (isspace(*p)) + if (vct_issp(*p)) continue; if (*p == ',') continue; for (q = p + 1; *q; q++) - if (*q == ',' || isspace(*q)) + if (*q == ',' || vct_issp(*q)) break; u = pdiff(p, q); if (u == 5 && !strncasecmp(p, "close", u)) From phk at projects.linpro.no Sat Jun 21 21:03:33 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Sat, 21 Jun 2008 23:03:33 +0200 (CEST) Subject: r2763 - trunk/varnish-cache/include Message-ID: <20080621210333.4467B1ED0A9@projects.linpro.no> Author: phk Date: 2008-06-21 23:03:27 +0200 (Sat, 21 Jun 2008) New Revision: 2763 Modified: trunk/varnish-cache/include/libvarnish.h Log: Add a diagnostic() wrapper around assert() for checks which are so expensive that we may want to compile them out for performance at a latter date. Modified: trunk/varnish-cache/include/libvarnish.h =================================================================== --- trunk/varnish-cache/include/libvarnish.h 2008-06-21 20:56:14 UTC (rev 2762) +++ trunk/varnish-cache/include/libvarnish.h 2008-06-21 21:03:27 UTC (rev 2763) @@ -62,7 +62,12 @@ /* * assert(), AN() and AZ() are static checks that should not happen. - * xxxassert(), XXXAN() and XXXAZ() are markers for missing code. + * In general asserts should be cheap, such as checking return + * values and similar. + * diagnostic() are asserts which are so expensive that we may want + * to compile them out for performance at a later date. + * xxxassert(), XXXAN() and XXXAZ() marks conditions we ought to + * handle gracefully, such as malloc failure. */ #ifdef WITHOUT_ASSERTS @@ -89,3 +94,4 @@ #define AN(foo) do { assert((foo) != 0); } while (0) #define XXXAZ(foo) do { xxxassert((foo) == 0); } while (0) #define XXXAN(foo) do { xxxassert((foo) != 0); } while (0) +#define diagnostic(foo) assert(foo) From phk at projects.linpro.no Sat Jun 21 21:04:59 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Sat, 21 Jun 2008 23:04:59 +0200 (CEST) Subject: r2764 - trunk/varnish-cache/bin/varnishd Message-ID: <20080621210459.AACAE1EC10A@projects.linpro.no> Author: phk Date: 2008-06-21 23:04:59 +0200 (Sat, 21 Jun 2008) New Revision: 2764 Modified: trunk/varnish-cache/bin/varnishd/cache_http.c Log: Change an assert() to diagnostic() since it negates the benefit we seek from the HTTP header indentification speedup. Modified: trunk/varnish-cache/bin/varnishd/cache_http.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_http.c 2008-06-21 21:03:27 UTC (rev 2763) +++ trunk/varnish-cache/bin/varnishd/cache_http.c 2008-06-21 21:04:59 UTC (rev 2764) @@ -207,7 +207,7 @@ char *p; l = hdr[0]; - assert(l == strlen(hdr + 1)); + diagnostic(l == strlen(hdr + 1)); assert(hdr[l] == ':'); hdr++; u = http_findhdr(hp, l - 1, hdr); From phk at projects.linpro.no Sun Jun 22 08:10:07 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Sun, 22 Jun 2008 10:10:07 +0200 (CEST) Subject: r2765 - trunk/varnish-cache/bin/varnishd Message-ID: <20080622081007.B048C1ED0A9@projects.linpro.no> Author: phk Date: 2008-06-22 10:10:05 +0200 (Sun, 22 Jun 2008) New Revision: 2765 Modified: trunk/varnish-cache/bin/varnishd/cache_pool.c Log: Make sure all pools have their minimum complement of threads. Modified: trunk/varnish-cache/bin/varnishd/cache_pool.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_pool.c 2008-06-21 21:04:59 UTC (rev 2764) +++ trunk/varnish-cache/bin/varnishd/cache_pool.c 2008-06-22 08:10:05 UTC (rev 2765) @@ -530,13 +530,20 @@ static void * wrk_herder_thread(void *priv) { - unsigned u; + unsigned u, w; THR_Name("wrk_herder"); (void)priv; while (1) { for (u = 0 ; u < nwq; u++) { /* + * Make sure all pools have their minimum complement + */ + for (w = 0 ; w < nwq; w++) { + if (wq[w]->nthr < nthr_min) + wrk_breed_flock(wq[w]); + } + /* * We cannot avoid getting a mutex, so we have a * bogo mutex just for POSIX_STUPIDITY */ From phk at projects.linpro.no Sun Jun 22 08:10:20 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Sun, 22 Jun 2008 10:10:20 +0200 (CEST) Subject: r2766 - trunk/varnish-cache/bin/varnishd Message-ID: <20080622081020.129371EC236@projects.linpro.no> Author: phk Date: 2008-06-22 10:10:19 +0200 (Sun, 22 Jun 2008) New Revision: 2766 Modified: trunk/varnish-cache/bin/varnishd/mgt_param.c Log: Default to 2 thread pools again. Modified: trunk/varnish-cache/bin/varnishd/mgt_param.c =================================================================== --- trunk/varnish-cache/bin/varnishd/mgt_param.c 2008-06-22 08:10:05 UTC (rev 2765) +++ trunk/varnish-cache/bin/varnishd/mgt_param.c 2008-06-22 08:10:19 UTC (rev 2766) @@ -477,7 +477,7 @@ "Can be increased on the fly, but decreases require a " "restart to take effect.", EXPERIMENTAL | DELAYED_EFFECT, - "1", "pools" }, + "2", "pools" }, { "thread_pool_max", tweak_thread_pool_max, NULL, 1, 0, "The maximum number of worker threads in all pools combined.\n" "\n" From phk at projects.linpro.no Sun Jun 22 08:10:38 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Sun, 22 Jun 2008 10:10:38 +0200 (CEST) Subject: r2767 - trunk/varnish-cache/bin/varnishtest/tests Message-ID: <20080622081038.421111ED0A9@projects.linpro.no> Author: phk Date: 2008-06-22 10:10:38 +0200 (Sun, 22 Jun 2008) New Revision: 2767 Added: trunk/varnish-cache/bin/varnishtest/tests/c00002.vtc Log: Add testcase for multiple thread pools Added: trunk/varnish-cache/bin/varnishtest/tests/c00002.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/c00002.vtc (rev 0) +++ trunk/varnish-cache/bin/varnishtest/tests/c00002.vtc 2008-06-22 08:10:38 UTC (rev 2767) @@ -0,0 +1,26 @@ +# Test that we get anything through at all +# +# $Id$ + +test "Check that multiple thread pools all get started" + +varnish v1 -arg "-b localhost:9080 -p thread_pools=9" -start + +server s1 { + rxreq + txresp -hdr "Connection: close" -body "012345\n" +} + +server s1 -start + +client c1 { + txreq -url "/" + rxresp + expect resp.status == 200 +} + +client c1 -run + +server s1 -wait + +varnish v1 -stop From phk at projects.linpro.no Sun Jun 22 08:50:24 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Sun, 22 Jun 2008 10:50:24 +0200 (CEST) Subject: r2768 - trunk/varnish-cache/bin/varnishd Message-ID: <20080622085024.0EFF51EC236@projects.linpro.no> Author: phk Date: 2008-06-22 10:50:23 +0200 (Sun, 22 Jun 2008) New Revision: 2768 Modified: trunk/varnish-cache/bin/varnishd/mgt_vcc.c Log: Use VLU to assemble output from the C-compiler. Close all fd's above stderr before exec'ing the C-compiler. Modified: trunk/varnish-cache/bin/varnishd/mgt_vcc.c =================================================================== --- trunk/varnish-cache/bin/varnishd/mgt_vcc.c 2008-06-22 08:10:38 UTC (rev 2767) +++ trunk/varnish-cache/bin/varnishd/mgt_vcc.c 2008-06-22 08:50:23 UTC (rev 2768) @@ -47,6 +47,7 @@ #include "compat/asprintf.h" #endif #include "vsb.h" +#include "vlu.h" #include "vqueue.h" @@ -201,6 +202,16 @@ * Errors goes in sb; */ +static int +mgt_cc_vlu(void *priv, const char *str) +{ + struct vsb *vsb; + + vsb = priv; + vsb_printf(vsb, "C-compiler said: %s\n", str); + return (0); +} + static char * mgt_run_cc(const char *source, struct vsb *sb) { @@ -208,10 +219,10 @@ struct vsb cmdsb; char sf[] = "./vcl.########.c"; char *of; - char buf[128]; int p[2], sfd, srclen, status; pid_t pid; void *dlh; + struct vlu *vlu; /* Create temporary C source file */ sfd = vtmpfile(sf); @@ -235,6 +246,7 @@ /* Name the output shared library by overwriting the final 'c' */ of = strdup(sf); XXXAN(of); + assert(of[sizeof sf - 2] == 'c'); of[sizeof sf - 2] = 'o'; AN(vsb_new(&cmdsb, cmdline, sizeof cmdline, 0)); mgt_make_cc_cmd(&cmdsb, sf, of); @@ -249,6 +261,8 @@ free(of); return (NULL); } + assert(p[0] > STDERR_FILENO); + assert(p[1] > STDERR_FILENO); if ((pid = fork()) < 0) { vsb_printf(sb, "%s(): fork() failed: %s", __func__, strerror(errno)); @@ -259,21 +273,22 @@ return (NULL); } if (pid == 0) { - AZ(close(p[0])); AZ(close(STDIN_FILENO)); assert(open("/dev/null", O_RDONLY) == STDIN_FILENO); assert(dup2(p[1], STDOUT_FILENO) == STDOUT_FILENO); assert(dup2(p[1], STDERR_FILENO) == STDERR_FILENO); + /* Close all other fds */ + for (sfd = STDERR_FILENO + 1; sfd < 100; sfd++) + (void)close(sfd); (void)execl("/bin/sh", "/bin/sh", "-c", cmdline, NULL); _exit(1); } AZ(close(p[1])); - do { - status = read(p[0], buf, sizeof buf); - if (status > 0) - vsb_printf(sb, "C-Compiler said: %.*s", status, buf); - } while (status > 0); + vlu = VLU_New(sb, mgt_cc_vlu, 0); + while (!VLU_Fd(p[0], vlu)) + continue; AZ(close(p[0])); + VLU_Destroy(vlu); (void)unlink(sf); if (waitpid(pid, &status, 0) < 0) { vsb_printf(sb, "%s(): waitpid() failed: %s", From phk at projects.linpro.no Sun Jun 22 11:41:32 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Sun, 22 Jun 2008 13:41:32 +0200 (CEST) Subject: r2769 - trunk/varnish-cache/include Message-ID: <20080622114132.EA3041ED0A9@projects.linpro.no> Author: phk Date: 2008-06-22 13:41:32 +0200 (Sun, 22 Jun 2008) New Revision: 2769 Added: trunk/varnish-cache/include/vbm.h Log: Add VBM, a resizing bitmap implementation we previously had in kqueue. Added: trunk/varnish-cache/include/vbm.h =================================================================== --- trunk/varnish-cache/include/vbm.h (rev 0) +++ trunk/varnish-cache/include/vbm.h 2008-06-22 11:41:32 UTC (rev 2769) @@ -0,0 +1,103 @@ +/*- + * Copyright (c) 2006 Verdens Gang AS + * Copyright (c) 2006-2008 Linpro AS + * All rights reserved. + * + * Author: Poul-Henning Kamp + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $Id: cache_acceptor_kqueue.c 2513 2008-02-18 17:04:30Z des $ + * + * Self-sizeing bitmap operations + */ + +#include "config.h" + +/********************************************************************** + * Generic bitmap functions, may be generalized at some point. + */ + +#define VBITMAP_TYPE unsigned /* Our preferred wordsize */ +#define VBITMAP_LUMP (32*1024) /* How many bits we alloc at a time */ +#define VBITMAP_WORD (sizeof(VBITMAP_TYPE) * 8) +#define VBITMAP_IDX(n) (n / VBITMAP_WORD) +#define VBITMAP_BIT(n) (1U << (n % VBITMAP_WORD)) + +struct vbitmap { + VBITMAP_TYPE *bits; + unsigned nbits; +}; + +static inline void +vbit_expand(struct vbitmap *vb, unsigned bit) +{ + unsigned char *p; + + bit += VBITMAP_LUMP - 1; + bit -= (bit % VBITMAP_LUMP); + p = realloc(vb->bits, bit / 8); + AN(p); + memset(p + vb->nbits / 8, 0, (bit - vb->nbits) / 8); + vb->bits = (void*)p; + vb->nbits = bit; +} + +static inline struct vbitmap * +vbit_init(unsigned initial) +{ + struct vbitmap *vb; + + vb = calloc(sizeof *vb, 1); + AN(vb); + if (initial == 0) + initial = VBITMAP_LUMP; + vbit_expand(vb, initial); + return (vb); +} + +static inline void +vbit_set(struct vbitmap *vb, unsigned bit) +{ + + if (bit >= vb->nbits) + vbit_expand(vb, bit); + vb->bits[VBITMAP_IDX(bit)] |= VBITMAP_BIT(bit); +} + +static inline void +vbit_clr(struct vbitmap *vb, unsigned bit) +{ + + if (bit >= vb->nbits) + vbit_expand(vb, bit); + vb->bits[VBITMAP_IDX(bit)] &= ~VBITMAP_BIT(bit); +} + +static inline int +vbit_test(struct vbitmap *vb, unsigned bit) +{ + + if (bit >= vb->nbits) + vbit_expand(vb, bit); + return (vb->bits[VBITMAP_IDX(bit)] & VBITMAP_BIT(bit)); +} From phk at projects.linpro.no Sun Jun 22 11:46:00 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Sun, 22 Jun 2008 13:46:00 +0200 (CEST) Subject: r2770 - trunk/varnish-cache/include Message-ID: <20080622114600.887091EC236@projects.linpro.no> Author: phk Date: 2008-06-22 13:46:00 +0200 (Sun, 22 Jun 2008) New Revision: 2770 Modified: trunk/varnish-cache/include/vbm.h Log: Polish this to the new more general usage: Allocate smaller lumps. Don't extend to clear bits. Modified: trunk/varnish-cache/include/vbm.h =================================================================== --- trunk/varnish-cache/include/vbm.h 2008-06-22 11:41:32 UTC (rev 2769) +++ trunk/varnish-cache/include/vbm.h 2008-06-22 11:46:00 UTC (rev 2770) @@ -38,7 +38,7 @@ */ #define VBITMAP_TYPE unsigned /* Our preferred wordsize */ -#define VBITMAP_LUMP (32*1024) /* How many bits we alloc at a time */ +#define VBITMAP_LUMP (1024) /* How many bits we alloc at a time */ #define VBITMAP_WORD (sizeof(VBITMAP_TYPE) * 8) #define VBITMAP_IDX(n) (n / VBITMAP_WORD) #define VBITMAP_BIT(n) (1U << (n % VBITMAP_WORD)) @@ -88,9 +88,8 @@ vbit_clr(struct vbitmap *vb, unsigned bit) { - if (bit >= vb->nbits) - vbit_expand(vb, bit); - vb->bits[VBITMAP_IDX(bit)] &= ~VBITMAP_BIT(bit); + if (bit < vb->nbits) + vb->bits[VBITMAP_IDX(bit)] &= ~VBITMAP_BIT(bit); } static inline int @@ -98,6 +97,6 @@ { if (bit >= vb->nbits) - vbit_expand(vb, bit); + return (0); return (vb->bits[VBITMAP_IDX(bit)] & VBITMAP_BIT(bit)); } From phk at projects.linpro.no Sun Jun 22 11:50:39 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Sun, 22 Jun 2008 13:50:39 +0200 (CEST) Subject: r2771 - trunk/varnish-cache/bin/varnishd Message-ID: <20080622115039.988BA1EC874@projects.linpro.no> Author: phk Date: 2008-06-22 13:50:39 +0200 (Sun, 22 Jun 2008) New Revision: 2771 Modified: trunk/varnish-cache/bin/varnishd/cache_cli.c trunk/varnish-cache/bin/varnishd/common.h trunk/varnish-cache/bin/varnishd/heritage.h trunk/varnish-cache/bin/varnishd/mgt_child.c trunk/varnish-cache/bin/varnishd/storage_file.c Log: Add a VBM bitmap for keeping track of which filedescriptors the worker process should inherit, and close all other fd's in the child. Rename variables used for the various fd's to more understandable names. Modified: trunk/varnish-cache/bin/varnishd/cache_cli.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_cli.c 2008-06-22 11:46:00 UTC (rev 2770) +++ trunk/varnish-cache/bin/varnishd/cache_cli.c 2008-06-22 11:50:39 UTC (rev 2771) @@ -118,7 +118,7 @@ UNLOCK(&cli_mtx); vsb_finish(cli->sb); AZ(vsb_overflowed(cli->sb)); - i = cli_writeres(heritage.fds[1], cli); + i = cli_writeres(heritage.cli_out, cli); if (i) VSL(SLT_Error, 0, "CLI write failed (errno=%d)", errno); else @@ -148,7 +148,7 @@ XXXAN(vlu); printf("Ready\n"); while (1) { - pfd[0].fd = heritage.fds[2]; + pfd[0].fd = heritage.cli_in; pfd[0].events = POLLIN; i = poll(pfd, 1, 5000); if (i == 0) { @@ -160,7 +160,7 @@ "EOF on CLI connection, exiting\n"); break; } - i = VLU_Fd(heritage.fds[2], vlu); + i = VLU_Fd(heritage.cli_in, vlu); if (i) { fprintf(stderr, "Error on CLI connection, exiting " Modified: trunk/varnish-cache/bin/varnishd/common.h =================================================================== --- trunk/varnish-cache/bin/varnishd/common.h 2008-06-22 11:46:00 UTC (rev 2770) +++ trunk/varnish-cache/bin/varnishd/common.h 2008-06-22 11:50:39 UTC (rev 2771) @@ -51,3 +51,6 @@ #endif #define TRUST_ME(ptr) ((void*)(uintptr_t)(ptr)) + +/* Really belongs in mgt.h, but storage_file chokes on both */ +void mgt_child_inherit(int fd, const char *what); Modified: trunk/varnish-cache/bin/varnishd/heritage.h =================================================================== --- trunk/varnish-cache/bin/varnishd/heritage.h 2008-06-22 11:46:00 UTC (rev 2770) +++ trunk/varnish-cache/bin/varnishd/heritage.h 2008-06-22 11:50:39 UTC (rev 2771) @@ -46,12 +46,13 @@ struct heritage { - /* - * Two pipe(2)'s for CLI connection between cache and mgt. - * cache reads [2] and writes [1]. Mgt reads [0] and writes [3]. - */ - int fds[4]; + /* Two pipe(2)'s for CLI connection between cache and mgt. */ + int cli_in; + int cli_out; + /* File descriptor for stdout/stderr */ + int std_fd; + /* Sockets from which to accept connections */ struct listen_sock_head socks; unsigned nsocks; Modified: trunk/varnish-cache/bin/varnishd/mgt_child.c =================================================================== --- trunk/varnish-cache/bin/varnishd/mgt_child.c 2008-06-22 11:46:00 UTC (rev 2770) +++ trunk/varnish-cache/bin/varnishd/mgt_child.c 2008-06-22 11:50:39 UTC (rev 2771) @@ -57,11 +57,17 @@ #include "mgt_event.h" #include "vlu.h" #include "vss.h" +#include "vbm.h" pid_t mgt_pid; pid_t child_pid = -1; -static int child_fds[2]; +static struct vbitmap *fd_map; + +static int child_cli_in = -1; +static int child_cli_out = -1; +static int child_output = -1; + static enum { CH_STOPPED = 0, CH_STARTING = 1, @@ -83,6 +89,26 @@ static struct ev *ev_listen; static struct vlu *vlu; +/*-------------------------------------------------------------------- + * Keep track of which filedescriptors the child should inherit and + * which should be closed after fork() + */ + +void +mgt_child_inherit(int fd, const char *what) +{ + + printf("Inherit %d %s\n", fd, what); + assert(fd >= 0); + if(fd_map == NULL) + fd_map = vbit_init(128); + AN(fd_map); + if (what != NULL) + vbit_set(fd_map, fd); + else + vbit_clr(fd_map, fd); +} + /*--------------------------------------------------------------------*/ static int @@ -107,7 +133,7 @@ ev_listen = NULL; return (1); } - if (VLU_Fd(child_fds[0], vlu)) { + if (VLU_Fd(child_output, vlu)) { ev_listen = NULL; return (1); } @@ -148,13 +174,15 @@ if (ls->sock < 0) continue; + mgt_child_inherit(ls->sock, "sock"); + /* * Set nonblocking mode to avoid a race where a client * closes before we call accept(2) and nobody else are in * the listen queue to release us. */ TCP_nonblocking(ls->sock); - TCP_filter_http(ls->sock); + (void)TCP_filter_http(ls->sock); good++; } if (!good) @@ -172,6 +200,7 @@ VTAILQ_FOREACH(ls, &heritage.socks, list) { if (ls->sock < 0) continue; + mgt_child_inherit(ls->sock, NULL); AZ(close(ls->sock)); ls->sock = -1; } @@ -186,6 +215,7 @@ unsigned u; char *p; struct ev *e; + int i, cp[2]; if (child_state != CH_STOPPED && child_state != CH_DIED) return; @@ -197,31 +227,53 @@ child_state = CH_STARTING; - AZ(pipe(&heritage.fds[0])); - AZ(pipe(&heritage.fds[2])); - AZ(pipe(child_fds)); + /* Open pipe for mgr->child CLI */ + AZ(pipe(cp)); + heritage.cli_in = cp[0]; + mgt_child_inherit(heritage.cli_in, "cli_in"); + child_cli_out = cp[1]; + + /* Open pipe for child->mgr CLI */ + AZ(pipe(cp)); + heritage.cli_out = cp[1]; + mgt_child_inherit(heritage.cli_out, "cli_out"); + child_cli_in = cp[0]; + + /* + * Open pipe for child stdout/err + * NB: not inherited, because we dup2() it to stdout/stderr in child + */ + AZ(pipe(cp)); + heritage.std_fd = cp[1]; + child_output = cp[0]; + MCF_ParamSync(); if ((pid = fork()) < 0) { perror("Could not fork child"); exit(1); } if (pid == 0) { - /* XXX: We should close things like syslog & telnet sockets */ if (geteuid() == 0) { XXXAZ(setgid(params->gid)); XXXAZ(setuid(params->uid)); } /* Redirect stdin/out/err */ - AZ(close(0)); - assert(open("/dev/null", O_RDONLY) == 0); - assert(dup2(child_fds[1], 1) == 1); - assert(dup2(child_fds[1], 2) == 2); - AZ(close(child_fds[0])); - AZ(close(child_fds[1])); + AZ(close(STDIN_FILENO)); + assert(open("/dev/null", O_RDONLY) == STDIN_FILENO); + assert(dup2(heritage.std_fd, STDOUT_FILENO) == STDOUT_FILENO); + assert(dup2(heritage.std_fd, STDERR_FILENO) == STDERR_FILENO); - AZ(close(heritage.fds[0])); - AZ(close(heritage.fds[3])); + /* Close anything we shouldn't know about */ + closelog(); + printf("Closed fds:"); + for (i = STDERR_FILENO + 1; i < getdtablesize(); i++) { + if (vbit_test(fd_map, i)) + continue; + if (close(i) == 0) + printf(" %d", i); + } + printf("\n"); setproctitle("Varnish-Chld %s", heritage.name); @@ -231,21 +283,29 @@ exit(1); } - fprintf(stderr, "start child pid %jd\n", (intmax_t)pid); + /* Close stuff the child got */ + AZ(close(heritage.std_fd)); + heritage.std_fd = -1; + + mgt_child_inherit(heritage.cli_in, NULL); + AZ(close(heritage.cli_in)); + heritage.cli_in = -1; + + mgt_child_inherit(heritage.cli_out, NULL); + AZ(close(heritage.cli_out)); + heritage.cli_out = -1; + close_sockets(); - AZ(close(child_fds[1])); - child_fds[1] = -1; - vlu = VLU_New(NULL, child_line, 0); AN(vlu); AZ(ev_listen); e = ev_new(); XXXAN(e); - e->fd = child_fds[0]; + e->fd = child_output; e->fd_flags = EV_RD; e->name = "Child listener"; e->callback = child_listener; @@ -263,17 +323,13 @@ ev_poker = e; } - mgt_cli_start_child(heritage.fds[0], heritage.fds[3]); - AZ(close(heritage.fds[1])); - heritage.fds[1] = -1; - AZ(close(heritage.fds[2])); - heritage.fds[2] = -1; + mgt_cli_start_child(child_cli_in, child_cli_out); child_pid = pid; if (mgt_push_vcls_and_start(&u, &p)) { fprintf(stderr, "Pushing vcls failed:\n%s\n", p); free(p); /* Pick up any stuff lingering on stdout/stderr */ - child_listener(NULL, EV_RD); + (void)child_listener(NULL, EV_RD); exit(2); } child_state = CH_RUNNING; @@ -300,10 +356,10 @@ mgt_cli_stop_child(); /* We tell the child to die gracefully by closing the CLI */ - AZ(close(heritage.fds[0])); - heritage.fds[0] = -1; - AZ(close(heritage.fds[3])); - heritage.fds[3] = -1; + AZ(close(child_cli_out)); + child_cli_out= -1; + AZ(close(child_cli_in)); + child_cli_in = -1; fprintf(stderr, "Child stopping\n"); } @@ -333,7 +389,7 @@ child_pid = -1; /* Pick up any stuff lingering on stdout/stderr */ - child_listener(NULL, EV_RD); + (void)child_listener(NULL, EV_RD); if (child_state == CH_RUNNING) { child_state = CH_DIED; @@ -341,10 +397,10 @@ mgt_cli_stop_child(); /* We tell the child to die gracefully by closing the CLI */ - AZ(close(heritage.fds[0])); - heritage.fds[0] = -1; - AZ(close(heritage.fds[3])); - heritage.fds[3] = -1; + AZ(close(child_cli_out)); + child_cli_out = -1; + AZ(close(child_cli_in)); + child_cli_in = -1; } if (ev_listen != NULL) { @@ -353,8 +409,8 @@ } ev_listen = NULL; - AZ(close(child_fds[0])); - child_fds[0] = -1; + AZ(close(child_output)); + child_output = -1; fprintf(stderr, "Child cleaned\n"); if (child_state == CH_DIED && params->auto_restart) Modified: trunk/varnish-cache/bin/varnishd/storage_file.c =================================================================== --- trunk/varnish-cache/bin/varnishd/storage_file.c 2008-06-22 11:46:00 UTC (rev 2770) +++ trunk/varnish-cache/bin/varnishd/storage_file.c 2008-06-22 11:50:39 UTC (rev 2771) @@ -329,6 +329,7 @@ XXXAN(sc->filename); free(q); smf_initfile(sc, size, 1); + mgt_child_inherit(sc->fd, "storage_file"); free(p); } From phk at projects.linpro.no Sun Jun 22 12:15:11 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Sun, 22 Jun 2008 14:15:11 +0200 (CEST) Subject: r2772 - trunk/varnish-cache/bin/varnishd Message-ID: <20080622121511.5F7C01EC236@projects.linpro.no> Author: phk Date: 2008-06-22 14:15:11 +0200 (Sun, 22 Jun 2008) New Revision: 2772 Modified: trunk/varnish-cache/bin/varnishd/varnishd.c Log: Use instance name (-n) or "varnishd" for syslog identifier. Log under facility LOCAL0 Modified: trunk/varnish-cache/bin/varnishd/varnishd.c =================================================================== --- trunk/varnish-cache/bin/varnishd/varnishd.c 2008-06-22 11:50:39 UTC (rev 2771) +++ trunk/varnish-cache/bin/varnishd/varnishd.c 2008-06-22 12:15:11 UTC (rev 2772) @@ -45,6 +45,7 @@ #include #include #include +#include #include #include @@ -506,6 +507,11 @@ exit(1); } + if (n_arg != NULL) + openlog(n_arg, LOG_PID, LOG_LOCAL0); + else + openlog("varnishd", LOG_PID, LOG_LOCAL0); + if (mkdir(dirname, 0755) < 0 && errno != EEXIST) { fprintf(stderr, "Cannot create working directory '%s': %s\n", dirname, strerror(errno)); From phk at projects.linpro.no Sun Jun 22 14:20:31 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Sun, 22 Jun 2008 16:20:31 +0200 (CEST) Subject: r2773 - trunk/varnish-cache/bin/varnishd Message-ID: <20080622142031.E55051EC874@projects.linpro.no> Author: phk Date: 2008-06-22 16:20:31 +0200 (Sun, 22 Jun 2008) New Revision: 2773 Modified: trunk/varnish-cache/bin/varnishd/cache_cli.c trunk/varnish-cache/bin/varnishd/mgt.h trunk/varnish-cache/bin/varnishd/mgt_child.c trunk/varnish-cache/bin/varnishd/mgt_cli.c Log: More work to polish the manager/client interaction, and get more systematic messages into syslog. Modified: trunk/varnish-cache/bin/varnishd/cache_cli.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_cli.c 2008-06-22 12:15:11 UTC (rev 2772) +++ trunk/varnish-cache/bin/varnishd/cache_cli.c 2008-06-22 14:20:31 UTC (rev 2773) @@ -128,7 +128,7 @@ } /*-------------------------------------------------------------------- - * Run CLI on stdin/stdout pipe from manager + * Run CLI on cli pipes from manager */ void @@ -158,7 +158,7 @@ if (pfd[0].revents & POLLHUP) { fprintf(stderr, "EOF on CLI connection, exiting\n"); - break; + exit(0); } i = VLU_Fd(heritage.cli_in, vlu); if (i) { Modified: trunk/varnish-cache/bin/varnishd/mgt.h =================================================================== --- trunk/varnish-cache/bin/varnishd/mgt.h 2008-06-22 12:15:11 UTC (rev 2772) +++ trunk/varnish-cache/bin/varnishd/mgt.h 2008-06-22 14:20:31 UTC (rev 2773) @@ -41,6 +41,7 @@ /* mgt_child.c */ void mgt_run(int dflag, const char *T_arg); extern pid_t mgt_pid, child_pid; +void mgt_stop_child(void); /* mgt_cli.c */ @@ -66,3 +67,16 @@ extern struct hash_slinger hsl_slinger; extern struct hash_slinger hcl_slinger; + +#define REPORT0(pri, fmt) \ + do { \ + fprintf(stderr, fmt "\n"); \ + syslog(pri, fmt); \ + } while (0) + +#define REPORT(pri, fmt, ...) \ + do { \ + fprintf(stderr, fmt "\n", __VA_ARGS__); \ + syslog(pri, fmt, __VA_ARGS__); \ + } while (0) + Modified: trunk/varnish-cache/bin/varnishd/mgt_child.c =================================================================== --- trunk/varnish-cache/bin/varnishd/mgt_child.c 2008-06-22 12:15:11 UTC (rev 2772) +++ trunk/varnish-cache/bin/varnishd/mgt_child.c 2008-06-22 14:20:31 UTC (rev 2773) @@ -56,6 +56,7 @@ #include "mgt_cli.h" #include "mgt_event.h" #include "vlu.h" +#include "vsb.h" #include "vss.h" #include "vbm.h" @@ -90,6 +91,19 @@ static struct vlu *vlu; /*-------------------------------------------------------------------- + * A handy little function + */ + +static inline void +closex(int *fd) +{ + + assert(*fd >= 0); + AZ(close(*fd)); + *fd = -1; +} + +/*-------------------------------------------------------------------- * Keep track of which filedescriptors the child should inherit and * which should be closed after fork() */ @@ -98,7 +112,6 @@ mgt_child_inherit(int fd, const char *what) { - printf("Inherit %d %s\n", fd, what); assert(fd >= 0); if(fd_map == NULL) fd_map = vbit_init(128); @@ -116,9 +129,7 @@ { (void)priv; - fprintf(stderr, "Child said (%d, %d): <<%s>>\n", - child_state, child_pid, p); - syslog(LOG_NOTICE, "Child (%d) said <<%s>>", child_pid, p); + REPORT(LOG_NOTICE, "Child (%d) said %s", child_pid, p); return (0); } @@ -150,10 +161,14 @@ (void)what; if (child_state != CH_RUNNING) return (1); - if (child_pid > 0 && mgt_cli_askchild(NULL, NULL, "ping\n")) { - fprintf(stderr, "Child not responding to ping\n"); - (void)kill(child_pid, SIGKILL); - } + if (child_pid < 0) + return (0); + if (!mgt_cli_askchild(NULL, NULL, "ping\n")) + return (0); + REPORT(LOG_ERR, + "Child (%d) not responding to ping, killing it.", + child_pid); + (void)kill(child_pid, SIGKILL); return (0); } @@ -201,8 +216,7 @@ if (ls->sock < 0) continue; mgt_child_inherit(ls->sock, NULL); - AZ(close(ls->sock)); - ls->sock = -1; + closex(&ls->sock); } } @@ -221,6 +235,8 @@ return; if (open_sockets() != 0) { + REPORT0(LOG_ERR, + "Child start failed: could not open sockets"); child_state = CH_STOPPED; return; /* XXX ?? */ } @@ -283,19 +299,16 @@ exit(1); } - fprintf(stderr, "start child pid %jd\n", (intmax_t)pid); + REPORT(LOG_NOTICE, "child (%d) Started", pid); /* Close stuff the child got */ - AZ(close(heritage.std_fd)); - heritage.std_fd = -1; + closex(&heritage.std_fd); mgt_child_inherit(heritage.cli_in, NULL); - AZ(close(heritage.cli_in)); - heritage.cli_in = -1; + closex(&heritage.cli_in); mgt_child_inherit(heritage.cli_out, NULL); - AZ(close(heritage.cli_out)); - heritage.cli_out = -1; + closex(&heritage.cli_out); close_sockets(); @@ -326,7 +339,7 @@ mgt_cli_start_child(child_cli_in, child_cli_out); child_pid = pid; if (mgt_push_vcls_and_start(&u, &p)) { - fprintf(stderr, "Pushing vcls failed:\n%s\n", p); + REPORT(LOG_ERR, "Pushing vcls failed: %s", p); free(p); /* Pick up any stuff lingering on stdout/stderr */ (void)child_listener(NULL, EV_RD); @@ -337,8 +350,8 @@ /*--------------------------------------------------------------------*/ -static void -stop_child(void) +void +mgt_stop_child(void) { if (child_state != CH_RUNNING) @@ -346,22 +359,18 @@ child_state = CH_STOPPING; + REPORT0(LOG_DEBUG, "Stopping Child"); if (ev_poker != NULL) { ev_del(mgt_evb, ev_poker); free(ev_poker); } ev_poker = NULL; - fprintf(stderr, "Clean child\n"); mgt_cli_stop_child(); /* We tell the child to die gracefully by closing the CLI */ - AZ(close(child_cli_out)); - child_cli_out= -1; - AZ(close(child_cli_in)); - child_cli_in = -1; - - fprintf(stderr, "Child stopping\n"); + closex(&child_cli_out); + closex(&child_cli_in); } /*--------------------------------------------------------------------*/ @@ -370,6 +379,7 @@ mgt_sigchld(const struct ev *e, int what) { int status; + struct vsb *vsb; pid_t r; (void)e; @@ -381,37 +391,45 @@ } ev_poker = NULL; - r = wait4(child_pid, &status, WNOHANG, NULL); + r = waitpid(child_pid, &status, WNOHANG); if (r == 0 || (r == -1 && errno == ECHILD)) return (0); assert(r == child_pid); - fprintf(stderr, "Cache child died pid=%d status=0x%x\n", r, status); + vsb = vsb_newauto(); + XXXAN(vsb); + vsb_printf(vsb, "Child (%d) %s", r, status ? "died" : "ended"); + if (!WIFEXITED(status) && WEXITSTATUS(status)) + vsb_printf(vsb, " status=%d", WEXITSTATUS(status)); + if (WIFSIGNALED(status)) + vsb_printf(vsb, " signal=%d", WTERMSIG(status)); +#ifdef WCOREDUMP + if (WCOREDUMP(status)) + vsb_printf(vsb, " (core dumped)"); +#endif + vsb_finish(vsb); + AZ(vsb_overflowed(vsb)); + REPORT(LOG_INFO, "%s", vsb_data(vsb)); + vsb_delete(vsb); + child_pid = -1; - /* Pick up any stuff lingering on stdout/stderr */ - (void)child_listener(NULL, EV_RD); - if (child_state == CH_RUNNING) { child_state = CH_DIED; - fprintf(stderr, "Clean child\n"); mgt_cli_stop_child(); - - /* We tell the child to die gracefully by closing the CLI */ - AZ(close(child_cli_out)); - child_cli_out = -1; - AZ(close(child_cli_in)); - child_cli_in = -1; + closex(&child_cli_out); + closex(&child_cli_in); } if (ev_listen != NULL) { ev_del(mgt_evb, ev_listen); free(ev_listen); + ev_listen = NULL; } - ev_listen = NULL; + /* Pick up any stuff lingering on stdout/stderr */ + (void)child_listener(NULL, EV_RD); + closex(&child_output); - AZ(close(child_output)); - child_output = -1; - fprintf(stderr, "Child cleaned\n"); + REPORT0(LOG_DEBUG, "Child cleanup complete"); if (child_state == CH_DIED && params->auto_restart) start_child(); @@ -430,10 +448,10 @@ (void)e; (void)what; - fprintf(stderr, "Manager got SIGINT\n"); + REPORT0(LOG_ERR, "Manager got SIGINT"); (void)fflush(stdout); if (child_pid >= 0) - stop_child(); + mgt_stop_child(); exit (2); } @@ -492,10 +510,8 @@ AZ(sigaction(SIGPIPE, &sac, NULL)); AZ(sigaction(SIGHUP, &sac, NULL)); - printf("rolling(1)...\n"); - fprintf(stderr, "rolling(2)...\n"); if (!dflag && !mgt_has_vcl()) - fprintf(stderr, "No VCL loaded yet\n"); + REPORT0(LOG_ERR, "No VCL loaded yet"); else if (!dflag) start_child(); else @@ -503,9 +519,10 @@ "Debugging mode, enter \"start\" to start child\n"); i = ev_schedule(mgt_evb); - fprintf(stderr, "ev_schedule = %d\n", i); + if (i != 0) + REPORT(LOG_ERR, "ev_schedule() = %d", i); - fprintf(stderr, "manager dies\n"); + REPORT0(LOG_ERR, "manager dies"); exit(2); } @@ -517,7 +534,7 @@ (void)av; if (priv != NULL && child_state == CH_RUNNING) - stop_child(); + mgt_stop_child(); else if (priv == NULL && child_state == CH_STOPPED) { if (mgt_has_vcl()) start_child(); Modified: trunk/varnish-cache/bin/varnishd/mgt_cli.c =================================================================== --- trunk/varnish-cache/bin/varnishd/mgt_cli.c 2008-06-22 12:15:11 UTC (rev 2772) +++ trunk/varnish-cache/bin/varnishd/mgt_cli.c 2008-06-22 14:20:31 UTC (rev 2773) @@ -320,8 +320,10 @@ (void)close(2); assert(open("/dev/null", O_WRONLY) == 2); - if (dflag_copy == 2) + if (dflag_copy == 2) { + mgt_stop_child(); telnet_close_all(); + } } else { telnet_close_one(cp->fdi); } From phk at projects.linpro.no Sun Jun 22 21:34:51 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Sun, 22 Jun 2008 23:34:51 +0200 (CEST) Subject: r2774 - trunk/varnish-cache/bin/varnishtest Message-ID: <20080622213451.98EA81EC236@projects.linpro.no> Author: phk Date: 2008-06-22 23:34:50 +0200 (Sun, 22 Jun 2008) New Revision: 2774 Modified: trunk/varnish-cache/bin/varnishtest/vtc_log.c Log: Hold a mutex for each log destination Modified: trunk/varnish-cache/bin/varnishtest/vtc_log.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_log.c 2008-06-22 14:20:31 UTC (rev 2773) +++ trunk/varnish-cache/bin/varnishtest/vtc_log.c 2008-06-22 21:34:50 UTC (rev 2774) @@ -49,6 +49,7 @@ #define VTCLOG_MAGIC 0x82731202 const char *id; struct vsb *vsb; + pthread_mutex_t mtx; }; struct vtclog * @@ -60,6 +61,7 @@ AN(vl); vl->id = id; vl->vsb = vsb_newauto(); + AZ(pthread_mutex_init(&vl->mtx, NULL)); return (vl); } @@ -80,6 +82,7 @@ assert(lvl < NLEAD); if (lvl > vtc_verbosity) return; + AZ(pthread_mutex_lock(&vl->mtx)); vsb_printf(vl->vsb, "%s %-4s ", lead[lvl], vl->id); va_list ap; va_start(ap, fmt); @@ -90,6 +93,7 @@ AZ(vsb_overflowed(vl->vsb)); (void)fputs(vsb_data(vl->vsb), stdout); vsb_clear(vl->vsb); + AZ(pthread_mutex_unlock(&vl->mtx)); if (lvl == 0) exit (1); } @@ -108,6 +112,7 @@ return; if (pfx == NULL) pfx = ""; + AZ(pthread_mutex_lock(&vl->mtx)); if (str == NULL) vsb_printf(vl->vsb, "%s %-4s %s(null)\n", lead[lvl], vl->id, pfx); @@ -136,6 +141,7 @@ AZ(vsb_overflowed(vl->vsb)); (void)fputs(vsb_data(vl->vsb), stdout); vsb_clear(vl->vsb); + AZ(pthread_mutex_unlock(&vl->mtx)); if (lvl == 0) exit (1); } From phk at projects.linpro.no Sun Jun 22 21:40:22 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Sun, 22 Jun 2008 23:40:22 +0200 (CEST) Subject: r2775 - trunk/varnish-cache/bin/varnishtest Message-ID: <20080622214022.2F4AF1EC0D3@projects.linpro.no> Author: phk Date: 2008-06-22 23:40:21 +0200 (Sun, 22 Jun 2008) New Revision: 2775 Modified: trunk/varnish-cache/bin/varnishtest/vtc_log.c trunk/varnish-cache/bin/varnishtest/vtc_varnish.c Log: A better solution than mutexes: give the thread that listens to varnish debugging output a separate log handle. (The point here is to maximize the amount of concurrency we can simulate. Down the road, the logging may become pre thread with a final sorting pass to get all the messages correctly interleaved.) Modified: trunk/varnish-cache/bin/varnishtest/vtc_log.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_log.c 2008-06-22 21:34:50 UTC (rev 2774) +++ trunk/varnish-cache/bin/varnishtest/vtc_log.c 2008-06-22 21:40:21 UTC (rev 2775) @@ -49,7 +49,6 @@ #define VTCLOG_MAGIC 0x82731202 const char *id; struct vsb *vsb; - pthread_mutex_t mtx; }; struct vtclog * @@ -61,7 +60,6 @@ AN(vl); vl->id = id; vl->vsb = vsb_newauto(); - AZ(pthread_mutex_init(&vl->mtx, NULL)); return (vl); } @@ -82,7 +80,6 @@ assert(lvl < NLEAD); if (lvl > vtc_verbosity) return; - AZ(pthread_mutex_lock(&vl->mtx)); vsb_printf(vl->vsb, "%s %-4s ", lead[lvl], vl->id); va_list ap; va_start(ap, fmt); @@ -93,7 +90,6 @@ AZ(vsb_overflowed(vl->vsb)); (void)fputs(vsb_data(vl->vsb), stdout); vsb_clear(vl->vsb); - AZ(pthread_mutex_unlock(&vl->mtx)); if (lvl == 0) exit (1); } @@ -112,7 +108,6 @@ return; if (pfx == NULL) pfx = ""; - AZ(pthread_mutex_lock(&vl->mtx)); if (str == NULL) vsb_printf(vl->vsb, "%s %-4s %s(null)\n", lead[lvl], vl->id, pfx); @@ -141,7 +136,6 @@ AZ(vsb_overflowed(vl->vsb)); (void)fputs(vsb_data(vl->vsb), stdout); vsb_clear(vl->vsb); - AZ(pthread_mutex_unlock(&vl->mtx)); if (lvl == 0) exit (1); } Modified: trunk/varnish-cache/bin/varnishtest/vtc_varnish.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_varnish.c 2008-06-22 21:34:50 UTC (rev 2774) +++ trunk/varnish-cache/bin/varnishtest/vtc_varnish.c 2008-06-22 21:40:21 UTC (rev 2775) @@ -57,6 +57,7 @@ #define VARNISH_MAGIC 0x208cd8e3 char *name; struct vtclog *vl; + struct vtclog *vl1; VTAILQ_ENTRY(varnish) list; const char *args; @@ -92,8 +93,8 @@ assert(i == 1); i = cli_readres(v->cli_fd, &retval, &r, 1000); assert(i == 0); - vtc_log(v->vl, 3, "CLI %u <%s>", retval, cmd); vtc_dump(v->vl, 4, "CLI RX", r); + vtc_log(v->vl, 3, "CLI STATUS %u", retval); if (repl != NULL) *repl = r; else @@ -137,6 +138,8 @@ v->name = name; v->vl = vtc_logopen(name); AN(v->vl); + v->vl1 = vtc_logopen(name); + AN(v->vl1); if (*name != 'v') { vtc_log(v->vl, 0, "Varnish name must start with 'v'"); exit (1); @@ -167,7 +170,7 @@ if (i <= 0) break; buf[i] = '\0'; - vtc_dump(v->vl, 4, "debug", buf); + vtc_dump(v->vl1, 4, "debug", buf); } return (NULL); } From phk at projects.linpro.no Sun Jun 22 21:41:21 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Sun, 22 Jun 2008 23:41:21 +0200 (CEST) Subject: r2776 - trunk/varnish-cache/bin/varnishtest/tests Message-ID: <20080622214121.044571ED249@projects.linpro.no> Author: phk Date: 2008-06-22 23:41:20 +0200 (Sun, 22 Jun 2008) New Revision: 2776 Added: trunk/varnish-cache/bin/varnishtest/tests/b00004.vtc Log: Add a start/stop CLI command test Added: trunk/varnish-cache/bin/varnishtest/tests/b00004.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/b00004.vtc (rev 0) +++ trunk/varnish-cache/bin/varnishtest/tests/b00004.vtc 2008-06-22 21:41:20 UTC (rev 2776) @@ -0,0 +1,28 @@ +# $Id$ + +test "Torture Varnish with start/stop commands" + +server s1 { + rxreq +} + +varnish v1 -vcl+backend { } + +varnish v1 -cli start +varnish v1 -cli start +varnish v1 -cli start + +varnish v1 -cli stop +varnish v1 -cli stop +varnish v1 -cli stop + +varnish v1 -cli start +varnish v1 -cli stop + +varnish v1 -cli start +varnish v1 -cli stop + +varnish v1 -cli start +varnish v1 -cli stop + +varnish v1 -wait From phk at projects.linpro.no Sun Jun 22 22:00:02 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 23 Jun 2008 00:00:02 +0200 (CEST) Subject: r2777 - trunk/varnish-cache/bin/varnishtest Message-ID: <20080622220002.B89921ED249@projects.linpro.no> Author: phk Date: 2008-06-23 00:00:02 +0200 (Mon, 23 Jun 2008) New Revision: 2777 Modified: trunk/varnish-cache/bin/varnishtest/vtc.c trunk/varnish-cache/bin/varnishtest/vtc.h trunk/varnish-cache/bin/varnishtest/vtc_client.c trunk/varnish-cache/bin/varnishtest/vtc_http.c trunk/varnish-cache/bin/varnishtest/vtc_server.c trunk/varnish-cache/bin/varnishtest/vtc_stats.c trunk/varnish-cache/bin/varnishtest/vtc_varnish.c Log: Macroize the method function arguments Modified: trunk/varnish-cache/bin/varnishtest/vtc.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc.c 2008-06-22 21:41:20 UTC (rev 2776) +++ trunk/varnish-cache/bin/varnishtest/vtc.c 2008-06-22 22:00:02 UTC (rev 2777) @@ -172,7 +172,7 @@ } assert(cp->cmd != NULL); - cp->cmd(token_s, priv); + cp->cmd(token_s, priv, cmd); } } @@ -185,7 +185,7 @@ { for (; cmd->name != NULL; cmd++) - cmd->cmd(NULL, NULL); + cmd->cmd(NULL, NULL, NULL); } /********************************************************************** @@ -193,10 +193,11 @@ */ static void -cmd_test(char **av, void *priv) +cmd_test(CMD_ARGS) { (void)priv; + (void)cmd; if (av == NULL) return; @@ -212,11 +213,12 @@ */ void -cmd_delay(char **av, void *priv) +cmd_delay(CMD_ARGS) { double f; (void)priv; + (void)cmd; if (av == NULL) return; AN(av[1]); @@ -234,9 +236,10 @@ */ void -cmd_dump(char **av, void *priv) +cmd_dump(CMD_ARGS) { + (void)cmd; if (av == NULL) return; printf("cmd_dump(%p)\n", priv); Modified: trunk/varnish-cache/bin/varnishtest/vtc.h =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc.h 2008-06-22 21:41:20 UTC (rev 2776) +++ trunk/varnish-cache/bin/varnishtest/vtc.h 2008-06-22 22:00:02 UTC (rev 2777) @@ -26,11 +26,13 @@ * $Id$ */ -typedef void cmd_f(char **av, void *priv); - struct vsb; struct vtclog; +struct cmds; +#define CMD_ARGS char **av, void *priv, const struct cmds *cmd +typedef void cmd_f(CMD_ARGS); + struct cmds { const char *name; cmd_f *cmd; Modified: trunk/varnish-cache/bin/varnishtest/vtc_client.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_client.c 2008-06-22 21:41:20 UTC (rev 2776) +++ trunk/varnish-cache/bin/varnishtest/vtc_client.c 2008-06-22 22:00:02 UTC (rev 2777) @@ -161,11 +161,12 @@ */ void -cmd_client(char **av, void *priv) +cmd_client(CMD_ARGS) { struct client *c, *c2; (void)priv; + (void)cmd; if (av == NULL) { /* Reset and free */ Modified: trunk/varnish-cache/bin/varnishtest/vtc_http.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_http.c 2008-06-22 21:41:20 UTC (rev 2776) +++ trunk/varnish-cache/bin/varnishtest/vtc_http.c 2008-06-22 22:00:02 UTC (rev 2777) @@ -116,13 +116,14 @@ } static void -cmd_http_expect(char **av, void *priv) +cmd_http_expect(CMD_ARGS) { struct http *hp; char *lhs; char *cmp; char *rhs; + (void)cmd; CAST_OBJ_NOTNULL(hp, priv, HTTP_MAGIC); assert(!strcmp(av[0], "expect")); av++; @@ -305,10 +306,11 @@ */ static void -cmd_http_rxresp(char **av, void *priv) +cmd_http_rxresp(CMD_ARGS) { struct http *hp; + (void)cmd; CAST_OBJ_NOTNULL(hp, priv, HTTP_MAGIC); AN(hp->client); assert(!strcmp(av[0], "rxresp")); @@ -329,7 +331,7 @@ */ static void -cmd_http_txresp(char **av, void *priv) +cmd_http_txresp(CMD_ARGS) { struct http *hp; struct vsb *vsb; @@ -341,6 +343,7 @@ const char *nl = "\r\n"; int l; + (void)cmd; CAST_OBJ_NOTNULL(hp, priv, HTTP_MAGIC); AZ(hp->client); assert(!strcmp(av[0], "txresp")); @@ -408,10 +411,11 @@ */ static void -cmd_http_rxreq(char **av, void *priv) +cmd_http_rxreq(CMD_ARGS) { struct http *hp; + (void)cmd; CAST_OBJ_NOTNULL(hp, priv, HTTP_MAGIC); AZ(hp->client); assert(!strcmp(av[0], "rxreq")); @@ -432,7 +436,7 @@ */ static void -cmd_http_txreq(char **av, void *priv) +cmd_http_txreq(CMD_ARGS) { struct http *hp; struct vsb *vsb; @@ -444,6 +448,7 @@ const char *nl = "\r\n"; int l; + (void)cmd; CAST_OBJ_NOTNULL(hp, priv, HTTP_MAGIC); AN(hp->client); assert(!strcmp(av[0], "txreq")); Modified: trunk/varnish-cache/bin/varnishtest/vtc_server.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_server.c 2008-06-22 21:41:20 UTC (rev 2776) +++ trunk/varnish-cache/bin/varnishtest/vtc_server.c 2008-06-22 22:00:02 UTC (rev 2777) @@ -203,11 +203,12 @@ */ void -cmd_server(char **av, void *priv) +cmd_server(CMD_ARGS) { struct server *s, *s2; (void)priv; + (void)cmd; if (av == NULL) { /* Reset and free */ Modified: trunk/varnish-cache/bin/varnishtest/vtc_stats.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_stats.c 2008-06-22 21:41:20 UTC (rev 2776) +++ trunk/varnish-cache/bin/varnishtest/vtc_stats.c 2008-06-22 22:00:02 UTC (rev 2777) @@ -32,8 +32,8 @@ #include "vtc.h" void -cmd_stats(char **av, void *priv) +cmd_stats(CMD_ARGS) { - cmd_dump(av, priv); + cmd_dump(av, priv, cmd); } Modified: trunk/varnish-cache/bin/varnishtest/vtc_varnish.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_varnish.c 2008-06-22 21:41:20 UTC (rev 2776) +++ trunk/varnish-cache/bin/varnishtest/vtc_varnish.c 2008-06-22 22:00:02 UTC (rev 2777) @@ -409,11 +409,12 @@ */ void -cmd_varnish(char **av, void *priv) +cmd_varnish(CMD_ARGS) { struct varnish *v, *v2; (void)priv; + (void)cmd; if (av == NULL) { /* Reset and free */ From tfheen at projects.linpro.no Mon Jun 23 13:23:47 2008 From: tfheen at projects.linpro.no (tfheen at projects.linpro.no) Date: Mon, 23 Jun 2008 15:23:47 +0200 (CEST) Subject: r2778 - in trunk/varnish-cache/bin/varnishtest: . tests Message-ID: <20080623132347.41C581EC11A@projects.linpro.no> Author: tfheen Date: 2008-06-23 15:23:45 +0200 (Mon, 23 Jun 2008) New Revision: 2778 Modified: trunk/varnish-cache/bin/varnishtest/tests/a00000.vtc trunk/varnish-cache/bin/varnishtest/tests/a00001.vtc trunk/varnish-cache/bin/varnishtest/tests/a00002.vtc trunk/varnish-cache/bin/varnishtest/tests/a00003.vtc trunk/varnish-cache/bin/varnishtest/tests/a00004.vtc trunk/varnish-cache/bin/varnishtest/tests/a00005.vtc trunk/varnish-cache/bin/varnishtest/tests/a00006.vtc trunk/varnish-cache/bin/varnishtest/tests/a00007.vtc trunk/varnish-cache/bin/varnishtest/vtc_server.c Log: Be explicit about listening to localhost Modified: trunk/varnish-cache/bin/varnishtest/tests/a00000.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/a00000.vtc 2008-06-22 22:00:02 UTC (rev 2777) +++ trunk/varnish-cache/bin/varnishtest/tests/a00000.vtc 2008-06-23 13:23:45 UTC (rev 2778) @@ -2,7 +2,7 @@ test "basic default HTTP transactions" -server s1 -listen :9080 { +server s1 -listen localhost:9080 { rxreq txresp } Modified: trunk/varnish-cache/bin/varnishtest/tests/a00001.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/a00001.vtc 2008-06-22 22:00:02 UTC (rev 2777) +++ trunk/varnish-cache/bin/varnishtest/tests/a00001.vtc 2008-06-23 13:23:45 UTC (rev 2778) @@ -2,7 +2,7 @@ test "basic default HTTP transactions with expect" -server s1 -listen :9080 { +server s1 -listen localhost:9080 { rxreq expect req.request == GET expect req.proto == HTTP/1.1 Modified: trunk/varnish-cache/bin/varnishtest/tests/a00002.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/a00002.vtc 2008-06-22 22:00:02 UTC (rev 2777) +++ trunk/varnish-cache/bin/varnishtest/tests/a00002.vtc 2008-06-23 13:23:45 UTC (rev 2778) @@ -2,7 +2,7 @@ test "basic default HTTP transactions with expect and options" -server s1 -listen :9080 { +server s1 -listen localhost:9080 { rxreq expect req.request == PUT expect req.proto == HTTP/1.0 Modified: trunk/varnish-cache/bin/varnishtest/tests/a00003.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/a00003.vtc 2008-06-22 22:00:02 UTC (rev 2777) +++ trunk/varnish-cache/bin/varnishtest/tests/a00003.vtc 2008-06-23 13:23:45 UTC (rev 2778) @@ -2,7 +2,7 @@ test "dual independent HTTP transactions" -server s1 -listen :9080 { +server s1 -listen localhost:9080 { rxreq expect req.request == PUT expect req.proto == HTTP/1.0 @@ -10,7 +10,7 @@ txresp -proto HTTP/1.2 -status 201 -msg Foo } -server s2 -listen :9081 { +server s2 -listen localhost:9081 { rxreq expect req.request == GET expect req.proto == HTTP/1.1 Modified: trunk/varnish-cache/bin/varnishtest/tests/a00004.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/a00004.vtc 2008-06-22 22:00:02 UTC (rev 2777) +++ trunk/varnish-cache/bin/varnishtest/tests/a00004.vtc 2008-06-23 13:23:45 UTC (rev 2778) @@ -2,7 +2,7 @@ test "dual shared server HTTP transactions" -server s1 -listen :9080 -repeat 2 { +server s1 -listen localhost:9080 -repeat 2 { rxreq expect req.request == PUT expect req.proto == HTTP/1.0 Modified: trunk/varnish-cache/bin/varnishtest/tests/a00005.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/a00005.vtc 2008-06-22 22:00:02 UTC (rev 2777) +++ trunk/varnish-cache/bin/varnishtest/tests/a00005.vtc 2008-06-23 13:23:45 UTC (rev 2778) @@ -2,7 +2,7 @@ test "dual shared client HTTP transactions" -server s1 -listen :9080 { +server s1 -listen localhost:9080 { rxreq expect req.request == PUT expect req.proto == HTTP/1.0 @@ -10,7 +10,7 @@ txresp -proto HTTP/1.2 -status 201 -msg Foo } -server s2 -listen :9081 { +server s2 -listen localhost:9081 { rxreq expect req.request == GET expect req.proto == HTTP/1.1 Modified: trunk/varnish-cache/bin/varnishtest/tests/a00006.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/a00006.vtc 2008-06-22 22:00:02 UTC (rev 2777) +++ trunk/varnish-cache/bin/varnishtest/tests/a00006.vtc 2008-06-23 13:23:45 UTC (rev 2778) @@ -2,7 +2,7 @@ test "bidirectional message bodies" -server s1 -listen :9080 { +server s1 -listen localhost:9080 { rxreq expect req.request == PUT expect req.proto == HTTP/1.0 Modified: trunk/varnish-cache/bin/varnishtest/tests/a00007.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/a00007.vtc 2008-06-22 22:00:02 UTC (rev 2777) +++ trunk/varnish-cache/bin/varnishtest/tests/a00007.vtc 2008-06-23 13:23:45 UTC (rev 2778) @@ -2,7 +2,7 @@ test "TCP reuse" -server s1 -listen :9080 { +server s1 -listen localhost:9080 { rxreq expect req.url == "/1" txresp -hdr "Content-Length: 10" -body "123456789\n" Modified: trunk/varnish-cache/bin/varnishtest/vtc_server.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_server.c 2008-06-22 22:00:02 UTC (rev 2777) +++ trunk/varnish-cache/bin/varnishtest/vtc_server.c 2008-06-23 13:23:45 UTC (rev 2778) @@ -120,7 +120,7 @@ vtc_log(s->vl, 0, "Server name must start with 's'"); exit (1); } - s->listen = ":9080"; + s->listen = "localhost:9080"; AZ(VSS_parse(s->listen, &s->addr, &s->port)); s->repeat = 1; s->depth = 1; From tfheen at projects.linpro.no Mon Jun 23 14:11:03 2008 From: tfheen at projects.linpro.no (tfheen at projects.linpro.no) Date: Mon, 23 Jun 2008 16:11:03 +0200 (CEST) Subject: r2779 - trunk/varnish-cache Message-ID: <20080623141103.584B61EC0E6@projects.linpro.no> Author: tfheen Date: 2008-06-23 16:11:02 +0200 (Mon, 23 Jun 2008) New Revision: 2779 Modified: trunk/varnish-cache/Makefile.am Log: Stop distributing debian/ in the tarball Modified: trunk/varnish-cache/Makefile.am =================================================================== --- trunk/varnish-cache/Makefile.am 2008-06-23 13:23:45 UTC (rev 2778) +++ trunk/varnish-cache/Makefile.am 2008-06-23 14:11:02 UTC (rev 2779) @@ -2,7 +2,7 @@ SUBDIRS = include lib bin man etc doc -SUBDIRS += debian redhat +SUBDIRS += redhat pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = varnishapi.pc From phk at projects.linpro.no Mon Jun 23 16:49:48 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Mon, 23 Jun 2008 18:49:48 +0200 (CEST) Subject: r2780 - in trunk/varnish-cache/bin/varnishtest: . tests Message-ID: <20080623164948.B80641EC11A@projects.linpro.no> Author: phk Date: 2008-06-23 18:49:48 +0200 (Mon, 23 Jun 2008) New Revision: 2780 Modified: trunk/varnish-cache/bin/varnishtest/tests/a00000.vtc trunk/varnish-cache/bin/varnishtest/tests/a00001.vtc trunk/varnish-cache/bin/varnishtest/tests/a00002.vtc trunk/varnish-cache/bin/varnishtest/tests/a00003.vtc trunk/varnish-cache/bin/varnishtest/tests/a00004.vtc trunk/varnish-cache/bin/varnishtest/tests/a00005.vtc trunk/varnish-cache/bin/varnishtest/tests/a00006.vtc trunk/varnish-cache/bin/varnishtest/tests/a00007.vtc trunk/varnish-cache/bin/varnishtest/tests/b00000.vtc trunk/varnish-cache/bin/varnishtest/tests/c00002.vtc trunk/varnish-cache/bin/varnishtest/vtc_server.c Log: On FreeBSD at least "localhost" resolves to two address, one IPv4 and one IPv6, resort to "127.0.0.1" Modified: trunk/varnish-cache/bin/varnishtest/tests/a00000.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/a00000.vtc 2008-06-23 14:11:02 UTC (rev 2779) +++ trunk/varnish-cache/bin/varnishtest/tests/a00000.vtc 2008-06-23 16:49:48 UTC (rev 2780) @@ -2,14 +2,14 @@ test "basic default HTTP transactions" -server s1 -listen localhost:9080 { +server s1 -listen 127.0.0.1:9080 { rxreq txresp } server s1 -start -client c1 -connect localhost:9080 { +client c1 -connect 127.0.0.1:9080 { txreq rxresp } Modified: trunk/varnish-cache/bin/varnishtest/tests/a00001.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/a00001.vtc 2008-06-23 14:11:02 UTC (rev 2779) +++ trunk/varnish-cache/bin/varnishtest/tests/a00001.vtc 2008-06-23 16:49:48 UTC (rev 2780) @@ -2,7 +2,7 @@ test "basic default HTTP transactions with expect" -server s1 -listen localhost:9080 { +server s1 -listen 127.0.0.1:9080 { rxreq expect req.request == GET expect req.proto == HTTP/1.1 @@ -12,7 +12,7 @@ server s1 -start -client c1 -connect localhost:9080 { +client c1 -connect 127.0.0.1:9080 { txreq rxresp expect resp.proto == HTTP/1.1 Modified: trunk/varnish-cache/bin/varnishtest/tests/a00002.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/a00002.vtc 2008-06-23 14:11:02 UTC (rev 2779) +++ trunk/varnish-cache/bin/varnishtest/tests/a00002.vtc 2008-06-23 16:49:48 UTC (rev 2780) @@ -2,7 +2,7 @@ test "basic default HTTP transactions with expect and options" -server s1 -listen localhost:9080 { +server s1 -listen 127.0.0.1:9080 { rxreq expect req.request == PUT expect req.proto == HTTP/1.0 @@ -12,7 +12,7 @@ server s1 -start -client c1 -connect localhost:9080 { +client c1 -connect 127.0.0.1:9080 { txreq -req PUT -proto HTTP/1.0 -url /foo rxresp expect resp.proto == HTTP/1.2 Modified: trunk/varnish-cache/bin/varnishtest/tests/a00003.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/a00003.vtc 2008-06-23 14:11:02 UTC (rev 2779) +++ trunk/varnish-cache/bin/varnishtest/tests/a00003.vtc 2008-06-23 16:49:48 UTC (rev 2780) @@ -2,7 +2,7 @@ test "dual independent HTTP transactions" -server s1 -listen localhost:9080 { +server s1 -listen 127.0.0.1:9080 { rxreq expect req.request == PUT expect req.proto == HTTP/1.0 @@ -10,7 +10,7 @@ txresp -proto HTTP/1.2 -status 201 -msg Foo } -server s2 -listen localhost:9081 { +server s2 -listen 127.0.0.1:9081 { rxreq expect req.request == GET expect req.proto == HTTP/1.1 @@ -21,7 +21,7 @@ server s1 -start server s2 -start -client c1 -connect localhost:9080 { +client c1 -connect 127.0.0.1:9080 { txreq -req PUT -proto HTTP/1.0 -url /foo rxresp expect resp.proto == HTTP/1.2 @@ -29,7 +29,7 @@ expect resp.msg == Foo } -client c2 -connect localhost:9081 { +client c2 -connect 127.0.0.1:9081 { txreq rxresp expect resp.proto == HTTP/1.1 Modified: trunk/varnish-cache/bin/varnishtest/tests/a00004.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/a00004.vtc 2008-06-23 14:11:02 UTC (rev 2779) +++ trunk/varnish-cache/bin/varnishtest/tests/a00004.vtc 2008-06-23 16:49:48 UTC (rev 2780) @@ -2,7 +2,7 @@ test "dual shared server HTTP transactions" -server s1 -listen localhost:9080 -repeat 2 { +server s1 -listen 127.0.0.1:9080 -repeat 2 { rxreq expect req.request == PUT expect req.proto == HTTP/1.0 @@ -12,7 +12,7 @@ server s1 -start -client c1 -connect localhost:9080 { +client c1 -connect 127.0.0.1:9080 { txreq -req PUT -proto HTTP/1.0 -url /foo rxresp expect resp.proto == HTTP/1.2 @@ -20,7 +20,7 @@ expect resp.msg == Foo } -client c2 -connect localhost:9080 { +client c2 -connect 127.0.0.1:9080 { txreq -req PUT -proto HTTP/1.0 -url /foo rxresp expect resp.proto == HTTP/1.2 Modified: trunk/varnish-cache/bin/varnishtest/tests/a00005.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/a00005.vtc 2008-06-23 14:11:02 UTC (rev 2779) +++ trunk/varnish-cache/bin/varnishtest/tests/a00005.vtc 2008-06-23 16:49:48 UTC (rev 2780) @@ -2,7 +2,7 @@ test "dual shared client HTTP transactions" -server s1 -listen localhost:9080 { +server s1 -listen 127.0.0.1:9080 { rxreq expect req.request == PUT expect req.proto == HTTP/1.0 @@ -10,7 +10,7 @@ txresp -proto HTTP/1.2 -status 201 -msg Foo } -server s2 -listen localhost:9081 { +server s2 -listen 127.0.0.1:9081 { rxreq expect req.request == GET expect req.proto == HTTP/1.1 @@ -21,7 +21,7 @@ server s1 -start server s2 -start -client c1 -connect localhost:9080 { +client c1 -connect 127.0.0.1:9080 { txreq -req PUT -proto HTTP/1.0 -url /foo rxresp expect resp.proto == HTTP/1.2 @@ -31,7 +31,7 @@ client c1 -run -client c1 -connect localhost:9081 { +client c1 -connect 127.0.0.1:9081 { txreq rxresp expect resp.proto == HTTP/1.1 Modified: trunk/varnish-cache/bin/varnishtest/tests/a00006.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/a00006.vtc 2008-06-23 14:11:02 UTC (rev 2779) +++ trunk/varnish-cache/bin/varnishtest/tests/a00006.vtc 2008-06-23 16:49:48 UTC (rev 2780) @@ -2,7 +2,7 @@ test "bidirectional message bodies" -server s1 -listen localhost:9080 { +server s1 -listen 127.0.0.1:9080 { rxreq expect req.request == PUT expect req.proto == HTTP/1.0 @@ -14,7 +14,7 @@ server s1 -start -client c1 -connect localhost:9080 { +client c1 -connect 127.0.0.1:9080 { txreq -req PUT -proto HTTP/1.0 -url /foo \ -hdr "Content-Length: 10" \ -body "123456789\n" Modified: trunk/varnish-cache/bin/varnishtest/tests/a00007.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/a00007.vtc 2008-06-23 14:11:02 UTC (rev 2779) +++ trunk/varnish-cache/bin/varnishtest/tests/a00007.vtc 2008-06-23 16:49:48 UTC (rev 2780) @@ -2,7 +2,7 @@ test "TCP reuse" -server s1 -listen localhost:9080 { +server s1 -listen 127.0.0.1:9080 { rxreq expect req.url == "/1" txresp -hdr "Content-Length: 10" -body "123456789\n" @@ -13,7 +13,7 @@ server s1 -start -client c1 -connect localhost:9080 { +client c1 -connect 127.0.0.1:9080 { txreq -url "/1" -req "POST" \ -hdr "Content-Length: 10" -body "abcdefghi\n" rxresp Modified: trunk/varnish-cache/bin/varnishtest/tests/b00000.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/b00000.vtc 2008-06-23 14:11:02 UTC (rev 2779) +++ trunk/varnish-cache/bin/varnishtest/tests/b00000.vtc 2008-06-23 16:49:48 UTC (rev 2780) @@ -2,7 +2,7 @@ # # $Id$ -varnish v1 -arg "-b localhost:9080" -start +varnish v1 -arg "-b 127.0.0.1:9080" -start server s1 { rxreq Modified: trunk/varnish-cache/bin/varnishtest/tests/c00002.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/c00002.vtc 2008-06-23 14:11:02 UTC (rev 2779) +++ trunk/varnish-cache/bin/varnishtest/tests/c00002.vtc 2008-06-23 16:49:48 UTC (rev 2780) @@ -4,7 +4,7 @@ test "Check that multiple thread pools all get started" -varnish v1 -arg "-b localhost:9080 -p thread_pools=9" -start +varnish v1 -arg "-b 127.0.0.1:9080 -p thread_pools=9" -start server s1 { rxreq Modified: trunk/varnish-cache/bin/varnishtest/vtc_server.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_server.c 2008-06-23 14:11:02 UTC (rev 2779) +++ trunk/varnish-cache/bin/varnishtest/vtc_server.c 2008-06-23 16:49:48 UTC (rev 2780) @@ -120,7 +120,7 @@ vtc_log(s->vl, 0, "Server name must start with 's'"); exit (1); } - s->listen = "localhost:9080"; + s->listen = "127.0.0.1:9080"; AZ(VSS_parse(s->listen, &s->addr, &s->port)); s->repeat = 1; s->depth = 1; @@ -192,7 +192,7 @@ vsb_printf(vsb, "backend %s { .host = \"%s\"; .port = \"%s\"; }\n", s->name, - s->addr == NULL ? "localhost" : s->addr, + s->addr == NULL ? "127.0.0.1" : s->addr, s->port); } } From tfheen at projects.linpro.no Tue Jun 24 07:45:56 2008 From: tfheen at projects.linpro.no (tfheen at projects.linpro.no) Date: Tue, 24 Jun 2008 09:45:56 +0200 (CEST) Subject: r2781 - trunk/varnish-cache Message-ID: <20080624074556.B831C1EC0E6@projects.linpro.no> Author: tfheen Date: 2008-06-24 09:45:56 +0200 (Tue, 24 Jun 2008) New Revision: 2781 Modified: trunk/varnish-cache/configure.ac Log: Drop debian/Makefile from configure.ac too Modified: trunk/varnish-cache/configure.ac =================================================================== --- trunk/varnish-cache/configure.ac 2008-06-23 16:49:48 UTC (rev 2780) +++ trunk/varnish-cache/configure.ac 2008-06-24 07:45:56 UTC (rev 2781) @@ -326,7 +326,6 @@ lib/libvarnishcompat/Makefile lib/libvcl/Makefile man/Makefile - debian/Makefile redhat/Makefile varnishapi.pc ]) From tfheen at projects.linpro.no Tue Jun 24 08:18:10 2008 From: tfheen at projects.linpro.no (tfheen at projects.linpro.no) Date: Tue, 24 Jun 2008 10:18:10 +0200 (CEST) Subject: r2782 - in trunk/varnish-cache: bin/varnishd bin/varnishtest include Message-ID: <20080624081810.9DA701ED1C0@projects.linpro.no> Author: tfheen Date: 2008-06-24 10:18:10 +0200 (Tue, 24 Jun 2008) New Revision: 2782 Modified: trunk/varnish-cache/bin/varnishd/Makefile.am trunk/varnish-cache/bin/varnishtest/Makefile.am trunk/varnish-cache/include/Makefile.am Log: Add missing header files to make make distcheck happier Modified: trunk/varnish-cache/bin/varnishd/Makefile.am =================================================================== --- trunk/varnish-cache/bin/varnishd/Makefile.am 2008-06-24 07:45:56 UTC (rev 2781) +++ trunk/varnish-cache/bin/varnishd/Makefile.am 2008-06-24 08:18:10 UTC (rev 2782) @@ -53,6 +53,7 @@ varnishd.c noinst_HEADERS = \ + acct_fields.h \ cache.h \ cache_acceptor.h \ common.h \ Modified: trunk/varnish-cache/bin/varnishtest/Makefile.am =================================================================== --- trunk/varnish-cache/bin/varnishtest/Makefile.am 2008-06-24 07:45:56 UTC (rev 2781) +++ trunk/varnish-cache/bin/varnishtest/Makefile.am 2008-06-24 08:18:10 UTC (rev 2782) @@ -6,6 +6,7 @@ varnishtest_SOURCES = \ vtc.c \ + vtc.h \ vtc_client.c \ vtc_http.c \ vtc_log.c \ Modified: trunk/varnish-cache/include/Makefile.am =================================================================== --- trunk/varnish-cache/include/Makefile.am 2008-06-24 07:45:56 UTC (rev 2781) +++ trunk/varnish-cache/include/Makefile.am 2008-06-24 08:18:10 UTC (rev 2782) @@ -31,6 +31,9 @@ vsb.h \ vcl.h \ vcl_returns.h \ + vct.h \ + vlu.h \ + vbm.h \ vrt.h \ vrt_obj.h \ vss.h From tfheen at projects.linpro.no Tue Jun 24 08:21:43 2008 From: tfheen at projects.linpro.no (tfheen at projects.linpro.no) Date: Tue, 24 Jun 2008 10:21:43 +0200 (CEST) Subject: r2783 - trunk/varnish-cache/lib/libvarnish Message-ID: <20080624082143.233A41EC0E6@projects.linpro.no> Author: tfheen Date: 2008-06-24 10:21:42 +0200 (Tue, 24 Jun 2008) New Revision: 2783 Modified: trunk/varnish-cache/lib/libvarnish/Makefile.am Log: Move setting of TESTS inside the if ENABLE_TESTS block so as to make make distcheck happy Modified: trunk/varnish-cache/lib/libvarnish/Makefile.am =================================================================== --- trunk/varnish-cache/lib/libvarnish/Makefile.am 2008-06-24 08:18:10 UTC (rev 2782) +++ trunk/varnish-cache/lib/libvarnish/Makefile.am 2008-06-24 08:21:42 UTC (rev 2783) @@ -24,9 +24,10 @@ libvarnish_la_LIBADD = ${RT_LIBS} ${NET_LIBS} ${LIBM} + +if ENABLE_TESTS TESTS = num_c_test -if ENABLE_TESTS noinst_PROGRAMS = ${TESTS} num_c_test_SOURCES = num.c From phk at projects.linpro.no Tue Jun 24 10:04:09 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Tue, 24 Jun 2008 12:04:09 +0200 (CEST) Subject: r2784 - in trunk/varnish-cache/bin/varnishtest: . tests Message-ID: <20080624100409.06AC21EC209@projects.linpro.no> Author: phk Date: 2008-06-24 12:04:08 +0200 (Tue, 24 Jun 2008) New Revision: 2784 Added: trunk/varnish-cache/bin/varnishtest/tests/c00003.vtc Modified: trunk/varnish-cache/bin/varnishtest/vtc_varnish.c Log: Add a testcase for starting with some bad listen sockets. Added: trunk/varnish-cache/bin/varnishtest/tests/c00003.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/c00003.vtc (rev 0) +++ trunk/varnish-cache/bin/varnishtest/tests/c00003.vtc 2008-06-24 10:04:08 UTC (rev 2784) @@ -0,0 +1,22 @@ +# Test that we get anything through at all +# +# $Id$ + +test "Check that we start if one listen address works" + +varnish v1 -accept ":9081 127.0.0.2:9082" -arg "-b 127.0.0.1:9080" -start + +server s1 { + rxreq + txresp -hdr "Connection: close" -body "012345\n" +} -start + +client c1 { + txreq -url "/" + rxresp + expect resp.status == 200 +} -run + +server s1 -wait + +varnish v1 -stop Modified: trunk/varnish-cache/bin/varnishtest/vtc_varnish.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_varnish.c 2008-06-24 08:21:42 UTC (rev 2783) +++ trunk/varnish-cache/bin/varnishtest/vtc_varnish.c 2008-06-24 10:04:08 UTC (rev 2784) @@ -190,7 +190,7 @@ AN(vsb); vsb_printf(vsb, "cd ../varnishd &&"); vsb_printf(vsb, " ./varnishd -d -d -n %s", v->name); - vsb_printf(vsb, " -a %s -T %s", v->accept, v->telnet); + vsb_printf(vsb, " -a '%s' -T %s", v->accept, v->telnet); vsb_printf(vsb, " %s", v->args); vsb_finish(vsb); AZ(vsb_overflowed(vsb)); From phk at projects.linpro.no Tue Jun 24 10:04:48 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Tue, 24 Jun 2008 12:04:48 +0200 (CEST) Subject: r2785 - trunk/varnish-cache/bin/varnishd Message-ID: <20080624100448.8134B1EC0B7@projects.linpro.no> Author: phk Date: 2008-06-24 12:04:48 +0200 (Tue, 24 Jun 2008) New Revision: 2785 Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor.c Log: Fix code, so varnish will still start as long as at least one listen address works. Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_acceptor.c 2008-06-24 10:04:08 UTC (rev 2784) +++ trunk/varnish-cache/bin/varnishd/cache_acceptor.c 2008-06-24 10:04:48 UTC (rev 2785) @@ -185,20 +185,26 @@ if (params->send_timeout != tv_sndtimeo.tv_sec) { need_test = 1; tv_sndtimeo.tv_sec = params->send_timeout; - VTAILQ_FOREACH(ls, &heritage.socks, list) + VTAILQ_FOREACH(ls, &heritage.socks, list) { + if (ls->sock < 0) + continue; AZ(setsockopt(ls->sock, SOL_SOCKET, SO_SNDTIMEO, &tv_sndtimeo, sizeof tv_sndtimeo)); + } } #endif #ifdef SO_RCVTIMEO_WORKS if (params->sess_timeout != tv_rcvtimeo.tv_sec) { need_test = 1; tv_rcvtimeo.tv_sec = params->sess_timeout; - VTAILQ_FOREACH(ls, &heritage.socks, list) + VTAILQ_FOREACH(ls, &heritage.socks, list) { + if (ls->sock < 0) + continue; AZ(setsockopt(ls->sock, SOL_SOCKET, SO_RCVTIMEO, &tv_rcvtimeo, sizeof tv_rcvtimeo)); + } } #endif i = poll(pfd, heritage.nsocks, 1000); From phk at projects.linpro.no Tue Jun 24 10:15:17 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Tue, 24 Jun 2008 12:15:17 +0200 (CEST) Subject: r2786 - trunk/varnish-cache/bin/varnishd Message-ID: <20080624101517.3E66F1EC209@projects.linpro.no> Author: phk Date: 2008-06-24 12:15:17 +0200 (Tue, 24 Jun 2008) New Revision: 2786 Modified: trunk/varnish-cache/bin/varnishd/storage_file.c Log: Catch two other return cases from smf_init() so we don't close the storage file by accident. Modified: trunk/varnish-cache/bin/varnishd/storage_file.c =================================================================== --- trunk/varnish-cache/bin/varnishd/storage_file.c 2008-06-24 10:04:48 UTC (rev 2785) +++ trunk/varnish-cache/bin/varnishd/storage_file.c 2008-06-24 10:15:17 UTC (rev 2786) @@ -274,6 +274,7 @@ sc->fd = open(p, O_RDWR | O_CREAT | O_EXCL, 0600); if (sc->fd >= 0) { sc->filename = p; + mgt_child_inherit(sc->fd, "storage_file"); smf_initfile(sc, size, 1); return; } @@ -310,6 +311,7 @@ exit (2); } sc->filename = p; + mgt_child_inherit(sc->fd, "storage_file"); smf_initfile(sc, size, 0); return; } From phk at projects.linpro.no Tue Jun 24 10:35:15 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Tue, 24 Jun 2008 12:35:15 +0200 (CEST) Subject: r2787 - trunk/varnish-cache/bin/varnishtest Message-ID: <20080624103515.E8E901ED33D@projects.linpro.no> Author: phk Date: 2008-06-24 12:35:15 +0200 (Tue, 24 Jun 2008) New Revision: 2787 Modified: trunk/varnish-cache/bin/varnishtest/vtc.c Log: Add a "shell" keyword for executing shell commands with system(3). Modified: trunk/varnish-cache/bin/varnishtest/vtc.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc.c 2008-06-24 10:15:17 UTC (rev 2786) +++ trunk/varnish-cache/bin/varnishtest/vtc.c 2008-06-24 10:35:15 UTC (rev 2787) @@ -42,6 +42,8 @@ #define MAX_FILESIZE (1024 * 1024) #define MAX_TOKENS 100 +static struct vtclog *vl; + /********************************************************************** * Read a file into memory */ @@ -207,7 +209,23 @@ AZ(av[2]); } +/********************************************************************** + * Shell command execution + */ +static void +cmd_shell(CMD_ARGS) +{ + + (void)priv; + (void)cmd; + + AN(av[1]); + AZ(av[2]); + vtc_dump(vl, 4, "shell", av[1]); + system(av[1]); +} + /********************************************************************** * Dump command arguments */ @@ -258,6 +276,7 @@ { "varnish", cmd_varnish }, { "delay", cmd_delay }, { "test", cmd_test }, + { "shell", cmd_shell }, { NULL, NULL } }; @@ -285,6 +304,8 @@ setbuf(stdout, NULL); setbuf(stderr, NULL); + vl = vtc_logopen(""); + AN(vl); while ((ch = getopt(argc, argv, "qv")) != -1) { switch (ch) { case 'q': From tfheen at projects.linpro.no Tue Jun 24 10:53:57 2008 From: tfheen at projects.linpro.no (tfheen at projects.linpro.no) Date: Tue, 24 Jun 2008 12:53:57 +0200 (CEST) Subject: r2788 - trunk/varnish-cache/bin/varnishtest Message-ID: <20080624105357.600651EC209@projects.linpro.no> Author: tfheen Date: 2008-06-24 12:53:56 +0200 (Tue, 24 Jun 2008) New Revision: 2788 Modified: trunk/varnish-cache/bin/varnishtest/vtc.c Log: Fix segfault when reset_cmds is called for cmd_shell Modified: trunk/varnish-cache/bin/varnishtest/vtc.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc.c 2008-06-24 10:35:15 UTC (rev 2787) +++ trunk/varnish-cache/bin/varnishtest/vtc.c 2008-06-24 10:53:56 UTC (rev 2788) @@ -220,6 +220,8 @@ (void)priv; (void)cmd; + if (av == NULL) + return; AN(av[1]); AZ(av[2]); vtc_dump(vl, 4, "shell", av[1]); From tfheen at projects.linpro.no Tue Jun 24 10:58:00 2008 From: tfheen at projects.linpro.no (tfheen at projects.linpro.no) Date: Tue, 24 Jun 2008 12:58:00 +0200 (CEST) Subject: r2789 - trunk/varnish-cache/bin/varnishtest/tests Message-ID: <20080624105800.7079D1EC208@projects.linpro.no> Author: tfheen Date: 2008-06-24 12:57:59 +0200 (Tue, 24 Jun 2008) New Revision: 2789 Added: trunk/varnish-cache/bin/varnishtest/tests/b00005.vtc Log: Add test to exercise the -s parameter Added: trunk/varnish-cache/bin/varnishtest/tests/b00005.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/b00005.vtc (rev 0) +++ trunk/varnish-cache/bin/varnishtest/tests/b00005.vtc 2008-06-24 10:57:59 UTC (rev 2789) @@ -0,0 +1,25 @@ +# $Id$ + +test "Check that -s works" + +varnish v1 -arg "-s file,varnishtest_backing,10M -b 127.0.0.1:9080" -start + +server s1 { + rxreq + txresp -hdr "Connection: close" -body "012345\n" +} + +server s1 -start + +client c1 { + txreq -url "/" + rxresp + expect resp.status == 200 +} + +client c1 -run + +server s1 -wait + +varnish v1 -stop +shell "rm ../varnishd/varnishtest_backing" From des at projects.linpro.no Tue Jun 24 11:46:24 2008 From: des at projects.linpro.no (des at projects.linpro.no) Date: Tue, 24 Jun 2008 13:46:24 +0200 (CEST) Subject: r2790 - in trunk/varnish-cache/bin: varnishd varnishlog varnishncsa Message-ID: <20080624114624.54EF91ECEFC@projects.linpro.no> Author: des Date: 2008-06-24 13:46:24 +0200 (Tue, 24 Jun 2008) New Revision: 2790 Modified: trunk/varnish-cache/bin/varnishd/varnishd.c trunk/varnish-cache/bin/varnishlog/varnishlog.c trunk/varnish-cache/bin/varnishncsa/varnishncsa.c Log: #260: make pidfile mode less restrictive. Modified: trunk/varnish-cache/bin/varnishd/varnishd.c =================================================================== --- trunk/varnish-cache/bin/varnishd/varnishd.c 2008-06-24 10:57:59 UTC (rev 2789) +++ trunk/varnish-cache/bin/varnishd/varnishd.c 2008-06-24 11:46:24 UTC (rev 2790) @@ -525,7 +525,7 @@ } /* XXX: should this be relative to the -n arg ? */ - if (P_arg && (pfh = vpf_open(P_arg, 0600, NULL)) == NULL) { + if (P_arg && (pfh = vpf_open(P_arg, 0644, NULL)) == NULL) { perror(P_arg); exit(1); } Modified: trunk/varnish-cache/bin/varnishlog/varnishlog.c =================================================================== --- trunk/varnish-cache/bin/varnishlog/varnishlog.c 2008-06-24 10:57:59 UTC (rev 2789) +++ trunk/varnish-cache/bin/varnishlog/varnishlog.c 2008-06-24 11:46:24 UTC (rev 2790) @@ -366,7 +366,7 @@ if (VSL_OpenLog(vd, n_arg)) exit(1); - if (P_arg && (pfh = vpf_open(P_arg, 0600, NULL)) == NULL) { + if (P_arg && (pfh = vpf_open(P_arg, 0644, NULL)) == NULL) { perror(P_arg); exit(1); } Modified: trunk/varnish-cache/bin/varnishncsa/varnishncsa.c =================================================================== --- trunk/varnish-cache/bin/varnishncsa/varnishncsa.c 2008-06-24 10:57:59 UTC (rev 2789) +++ trunk/varnish-cache/bin/varnishncsa/varnishncsa.c 2008-06-24 11:46:24 UTC (rev 2790) @@ -550,7 +550,7 @@ if (VSL_OpenLog(vd, n_arg)) exit(1); - if (P_arg && (pfh = vpf_open(P_arg, 0600, NULL)) == NULL) { + if (P_arg && (pfh = vpf_open(P_arg, 0644, NULL)) == NULL) { perror(P_arg); exit(1); } From phk at projects.linpro.no Tue Jun 24 18:09:38 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Tue, 24 Jun 2008 20:09:38 +0200 (CEST) Subject: r2791 - trunk/varnish-cache/bin/varnishd Message-ID: <20080624180938.BDA531EC6CB@projects.linpro.no> Author: phk Date: 2008-06-24 20:09:38 +0200 (Tue, 24 Jun 2008) New Revision: 2791 Modified: trunk/varnish-cache/bin/varnishd/cache.h trunk/varnish-cache/bin/varnishd/cache_vrt_re.c trunk/varnish-cache/bin/varnishd/cache_ws.c Log: Never release more bytes than there is room for. Modified: trunk/varnish-cache/bin/varnishd/cache.h =================================================================== --- trunk/varnish-cache/bin/varnishd/cache.h 2008-06-24 11:46:24 UTC (rev 2790) +++ trunk/varnish-cache/bin/varnishd/cache.h 2008-06-24 18:09:38 UTC (rev 2791) @@ -691,6 +691,8 @@ static inline void Tadd(txt *t, const char *p, int l) { + Tcheck(*t); + if (l <= 0) { } if (t->b + l < t->e) { memcpy(t->b, p, l); Modified: trunk/varnish-cache/bin/varnishd/cache_vrt_re.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_vrt_re.c 2008-06-24 11:46:24 UTC (rev 2790) +++ trunk/varnish-cache/bin/varnishd/cache_vrt_re.c 2008-06-24 18:09:38 UTC (rev 2791) @@ -110,7 +110,7 @@ regex_t *t; int i, l; txt res; - char *p; + char *b0; const char *s; unsigned u, x; @@ -124,8 +124,9 @@ if (i == REG_NOMATCH) return(str); +VSL(SLT_Debug, sp->fd, "REGSUB {"); u = WS_Reserve(sp->http->ws, 0); - res.e = res.b = p = sp->http->ws->f; + res.e = res.b = b0 = sp->http->ws->f; res.e += u; do { @@ -163,6 +164,7 @@ return (str); } Tcheck(res); - WS_Release(sp->http->ws, p - res.b); - return (p); + WS_Release(sp->http->ws, b0 - res.b); +VSL(SLT_Debug, sp->fd, "REGSUB }"); + return (b0); } Modified: trunk/varnish-cache/bin/varnishd/cache_ws.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_ws.c 2008-06-24 11:46:24 UTC (rev 2790) +++ trunk/varnish-cache/bin/varnishd/cache_ws.c 2008-06-24 18:09:38 UTC (rev 2791) @@ -167,6 +167,7 @@ WS_Release(struct ws *ws, unsigned bytes) { WS_Assert(ws); + assert(bytes <= ws->e - ws->f); DSL(0x02, SLT_Debug, 0, "WS_Release(%p, %u)", ws, bytes); assert(ws->r != NULL); assert(ws->f + bytes <= ws->r); From phk at projects.linpro.no Tue Jun 24 18:12:03 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Tue, 24 Jun 2008 20:12:03 +0200 (CEST) Subject: r2792 - trunk/varnish-cache/bin/varnishd Message-ID: <20080624181203.3292D1EC40A@projects.linpro.no> Author: phk Date: 2008-06-24 20:12:02 +0200 (Tue, 24 Jun 2008) New Revision: 2792 Modified: trunk/varnish-cache/bin/varnishd/cache_vrt_re.c Log: Ooops, last commit got one file more than intended. Here is the fix for the regsub() issue: Don't release negative bytecounts, we have the special variant WS_ReleaseP() just for jobs like this. Modified: trunk/varnish-cache/bin/varnishd/cache_vrt_re.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_vrt_re.c 2008-06-24 18:09:38 UTC (rev 2791) +++ trunk/varnish-cache/bin/varnishd/cache_vrt_re.c 2008-06-24 18:12:02 UTC (rev 2792) @@ -124,7 +124,6 @@ if (i == REG_NOMATCH) return(str); -VSL(SLT_Debug, sp->fd, "REGSUB {"); u = WS_Reserve(sp->http->ws, 0); res.e = res.b = b0 = sp->http->ws->f; res.e += u; @@ -164,7 +163,6 @@ return (str); } Tcheck(res); - WS_Release(sp->http->ws, b0 - res.b); -VSL(SLT_Debug, sp->fd, "REGSUB }"); + WS_ReleaseP(sp->http->ws, res.b); return (b0); } From phk at projects.linpro.no Tue Jun 24 21:29:33 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Tue, 24 Jun 2008 23:29:33 +0200 (CEST) Subject: r2793 - trunk/varnish-cache/bin/varnishd Message-ID: <20080624212933.B325A1EC874@projects.linpro.no> Author: phk Date: 2008-06-24 23:29:32 +0200 (Tue, 24 Jun 2008) New Revision: 2793 Modified: trunk/varnish-cache/bin/varnishd/mgt_event.c Log: Make the debug element conditional on DEBUG macro being defined. Modified: trunk/varnish-cache/bin/varnishd/mgt_event.c =================================================================== --- trunk/varnish-cache/bin/varnishd/mgt_event.c 2008-06-24 18:12:02 UTC (rev 2792) +++ trunk/varnish-cache/bin/varnishd/mgt_event.c 2008-06-24 21:29:32 UTC (rev 2793) @@ -45,6 +45,8 @@ #include "miniobj.h" #include "binary_heap.h" +#undef DEBUG_EVENTS + /* INFTIM indicates an infinite timeout for poll(2) */ #ifndef INFTIM #define INFTIM -1 @@ -72,13 +74,13 @@ unsigned char disturbed; unsigned psig; pthread_t thread; +#ifdef DEBUG_EVENTS FILE *debug; +#endif }; /*--------------------------------------------------------------------*/ -#undef DEBUG_EVENTS - #ifdef DEBUG_EVENTS #define DBG(evb, ...) do { \ if ((evb)->debug != NULL) \ From phk at projects.linpro.no Tue Jun 24 21:29:56 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Tue, 24 Jun 2008 23:29:56 +0200 (CEST) Subject: r2794 - trunk/varnish-cache/bin/varnishd Message-ID: <20080624212956.D425C1EC0F8@projects.linpro.no> Author: phk Date: 2008-06-24 23:29:56 +0200 (Tue, 24 Jun 2008) New Revision: 2794 Modified: trunk/varnish-cache/bin/varnishd/flint.sh Log: Also tally Notes Modified: trunk/varnish-cache/bin/varnishd/flint.sh =================================================================== --- trunk/varnish-cache/bin/varnishd/flint.sh 2008-06-24 21:29:32 UTC (rev 2793) +++ trunk/varnish-cache/bin/varnishd/flint.sh 2008-06-24 21:29:56 UTC (rev 2794) @@ -10,7 +10,7 @@ flint.lnt \ *.c > $T 2>&1 -for t in Error Warning Info +for t in Error Warning Info Note do sed -n "/$t [0-9][0-9][0-9]:/s/.*\($t [0-9][0-9][0-9]\).*/\1/p" $T done | awk ' From phk at projects.linpro.no Tue Jun 24 21:30:25 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Tue, 24 Jun 2008 23:30:25 +0200 (CEST) Subject: r2795 - trunk/varnish-cache/bin/varnishd Message-ID: <20080624213025.214221EC874@projects.linpro.no> Author: phk Date: 2008-06-24 23:30:24 +0200 (Tue, 24 Jun 2008) New Revision: 2795 Modified: trunk/varnish-cache/bin/varnishd/flint.lnt Log: Don't whine about ../../config.h Modified: trunk/varnish-cache/bin/varnishd/flint.lnt =================================================================== --- trunk/varnish-cache/bin/varnishd/flint.lnt 2008-06-24 21:29:56 UTC (rev 2794) +++ trunk/varnish-cache/bin/varnishd/flint.lnt 2008-06-24 21:30:24 UTC (rev 2795) @@ -7,6 +7,7 @@ // 796 and 797 (out-of-bounds errors). -elib(123) // size is both a variable and a macro with args -emacro(736, isnan) // isnanf +-efile(766, ../../config.h) // -header(../../config.h) From phk at projects.linpro.no Tue Jun 24 21:37:32 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Tue, 24 Jun 2008 23:37:32 +0200 (CEST) Subject: r2796 - trunk/varnish-cache/bin/varnishd Message-ID: <20080624213732.31F151ED30E@projects.linpro.no> Author: phk Date: 2008-06-24 23:37:22 +0200 (Tue, 24 Jun 2008) New Revision: 2796 Modified: trunk/varnish-cache/bin/varnishd/mgt_cli.c Log: Fix an interesting shortcoming in GCC's error checks which Flexelint correctly spotted: deconsting through strchr(). A couple of other flexelint nits while here Modified: trunk/varnish-cache/bin/varnishd/mgt_cli.c =================================================================== --- trunk/varnish-cache/bin/varnishd/mgt_cli.c 2008-06-24 21:30:24 UTC (rev 2795) +++ trunk/varnish-cache/bin/varnishd/mgt_cli.c 2008-06-24 21:37:22 UTC (rev 2796) @@ -132,7 +132,7 @@ { CLI_PING, cli_func_ping }, { CLI_SERVER_STATUS, mcf_server_status, NULL }, { CLI_SERVER_START, mcf_server_startstop, NULL }, - { CLI_SERVER_STOP, mcf_server_startstop, &cli_proto }, + { CLI_SERVER_STOP, mcf_server_startstop, cli_proto }, { CLI_STATS, mcf_stats, NULL }, { CLI_VCL_LOAD, mcf_config_load, NULL }, { CLI_VCL_INLINE, mcf_config_inline, NULL }, @@ -241,14 +241,12 @@ CAST_OBJ_NOTNULL(cp, priv, CLI_PORT_MAGIC); vsb_clear(cp->cli->sb); - /* Remove trailing whitespace */ - q = strchr(p, '\0'); - while (q > p && isspace(q[-1])) - q--; - *q = '\0'; + /* Skip whitespace */ + for (; isspace(*p); p++) + continue; /* Ignore empty lines */ - if (*p == 0) + if (*p == '\0') return (0); cli_dispatch(cp->cli, cli_proto, p); @@ -449,7 +447,7 @@ asprintf(&p, "telnet %s:%s %s:%s", abuf2, pbuf2, abuf1, pbuf1); XXXAN(p); - telnet_new(i); + (void)telnet_new(i); mgt_cli_setup(i, i, 0, p); free(p); From phk at projects.linpro.no Tue Jun 24 21:39:06 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Tue, 24 Jun 2008 23:39:06 +0200 (CEST) Subject: r2797 - trunk/varnish-cache/lib/libvarnish Message-ID: <20080624213906.08F681EC40A@projects.linpro.no> Author: phk Date: 2008-06-24 23:39:04 +0200 (Tue, 24 Jun 2008) New Revision: 2797 Modified: trunk/varnish-cache/lib/libvarnish/flint.sh trunk/varnish-cache/lib/libvarnish/vlu.c Log: Fix Flexelint complaints Modified: trunk/varnish-cache/lib/libvarnish/flint.sh =================================================================== --- trunk/varnish-cache/lib/libvarnish/flint.sh 2008-06-24 21:37:22 UTC (rev 2796) +++ trunk/varnish-cache/lib/libvarnish/flint.sh 2008-06-24 21:39:04 UTC (rev 2797) @@ -5,6 +5,7 @@ -I/usr/include \ -I. \ -I../../include \ + -I../.. \ flint.lnt \ *.c > $T 2>&1 Modified: trunk/varnish-cache/lib/libvarnish/vlu.c =================================================================== --- trunk/varnish-cache/lib/libvarnish/vlu.c 2008-06-24 21:37:22 UTC (rev 2796) +++ trunk/varnish-cache/lib/libvarnish/vlu.c 2008-06-24 21:39:04 UTC (rev 2797) @@ -32,8 +32,8 @@ #include #include #include -#include #include +#include "libvarnish.h" #include "vlu.h" #include "miniobj.h" From phk at projects.linpro.no Wed Jun 25 09:57:55 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Wed, 25 Jun 2008 11:57:55 +0200 (CEST) Subject: r2798 - trunk/varnish-cache/bin/varnishtest Message-ID: <20080625095755.9FD1E1EC0F8@projects.linpro.no> Author: phk Date: 2008-06-25 11:57:54 +0200 (Wed, 25 Jun 2008) New Revision: 2798 Modified: trunk/varnish-cache/bin/varnishtest/vtc.c Log: Handle \r in strings Modified: trunk/varnish-cache/bin/varnishtest/vtc.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc.c 2008-06-24 21:39:04 UTC (rev 2797) +++ trunk/varnish-cache/bin/varnishtest/vtc.c 2008-06-25 09:57:54 UTC (rev 2798) @@ -123,6 +123,9 @@ if (*p == '\\' && p[1] == 'n') { *q++ = '\n'; p++; + } else if (*p == '\\' && p[1] == 'r') { + *q++ = '\r'; + p++; } else if (*p == '\\' && p[1] == '\\') { *q++ = '\\'; p++; From phk at projects.linpro.no Wed Jun 25 09:58:31 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Wed, 25 Jun 2008 11:58:31 +0200 (CEST) Subject: r2799 - trunk/varnish-cache/bin/varnishtest Message-ID: <20080625095831.F34621EC236@projects.linpro.no> Author: phk Date: 2008-06-25 11:58:31 +0200 (Wed, 25 Jun 2008) New Revision: 2799 Modified: trunk/varnish-cache/bin/varnishtest/vtc_http.c Log: Add "send" command for explicitly sending bytestrings Modified: trunk/varnish-cache/bin/varnishtest/vtc_http.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_http.c 2008-06-25 09:57:54 UTC (rev 2798) +++ trunk/varnish-cache/bin/varnishtest/vtc_http.c 2008-06-25 09:58:31 UTC (rev 2799) @@ -512,6 +512,27 @@ } /********************************************************************** + * Send a string + */ + +static void +cmd_http_send(CMD_ARGS) +{ + struct http *hp; + int i; + + (void)cmd; + CAST_OBJ_NOTNULL(hp, priv, HTTP_MAGIC); + AN(av[1]); + AZ(av[2]); + vtc_dump(hp->vl, 4, "send", av[1]); + i = write(hp->fd, av[1], strlen(av[1])); + assert(i == strlen(av[1])); + +} + + +/********************************************************************** * Execute HTTP specifications */ @@ -521,6 +542,7 @@ { "txresp", cmd_http_txresp }, { "rxresp", cmd_http_rxresp }, { "expect", cmd_http_expect }, + { "send", cmd_http_send }, { "delay", cmd_delay }, { NULL, NULL } }; From phk at projects.linpro.no Wed Jun 25 09:58:43 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Wed, 25 Jun 2008 11:58:43 +0200 (CEST) Subject: r2800 - trunk/varnish-cache/bin/varnishtest/tests Message-ID: <20080625095843.AAD061EC0F8@projects.linpro.no> Author: phk Date: 2008-06-25 11:58:43 +0200 (Wed, 25 Jun 2008) New Revision: 2800 Added: trunk/varnish-cache/bin/varnishtest/tests/r00262.vtc Log: Add regression test for ticket 262 Added: trunk/varnish-cache/bin/varnishtest/tests/r00262.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/r00262.vtc (rev 0) +++ trunk/varnish-cache/bin/varnishtest/tests/r00262.vtc 2008-06-25 09:58:43 UTC (rev 2800) @@ -0,0 +1,29 @@ +# $Id$ + +test "Test that inter-request whitespace trimming works" + +server s1 { + rxreq + txresp \ + -hdr "Connection: close" \ + -body "012345\n" +} + +varnish v1 -arg "-p session_linger=20" -vcl+backend { } -start + +server s1 -start + +client c1 { + send "GET / HTTP/1.1\r\n\r\n\r\n" + + rxresp + expect resp.status == 200 + expect resp.http.X-Varnish == "1001" + + send "GET / HTTP/1.1\r\n\r\n" + rxresp + expect resp.status == 200 + expect resp.http.X-Varnish == "1002 1001" +} + +client c1 -run From phk at projects.linpro.no Wed Jun 25 09:59:22 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Wed, 25 Jun 2008 11:59:22 +0200 (CEST) Subject: r2801 - trunk/varnish-cache/bin/varnishd Message-ID: <20080625095922.315151EC209@projects.linpro.no> Author: phk Date: 2008-06-25 11:59:21 +0200 (Wed, 25 Jun 2008) New Revision: 2801 Modified: trunk/varnish-cache/bin/varnishd/cache_httpconn.c Log: Fix for ticket 262: When we trim leading whitespace that was read-ahead, NUL the rxbuffer. Modified: trunk/varnish-cache/bin/varnishd/cache_httpconn.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_httpconn.c 2008-06-25 09:58:43 UTC (rev 2800) +++ trunk/varnish-cache/bin/varnishd/cache_httpconn.c 2008-06-25 09:59:21 UTC (rev 2801) @@ -63,6 +63,7 @@ continue; if (*p == '\0') { t->e = t->b; + *t->e = '\0'; return (0); } while (1) { From phk at projects.linpro.no Wed Jun 25 10:04:50 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Wed, 25 Jun 2008 12:04:50 +0200 (CEST) Subject: r2802 - trunk/varnish-cache/bin/varnishtest/tests Message-ID: <20080625100450.1CA841EC0F8@projects.linpro.no> Author: phk Date: 2008-06-25 12:04:49 +0200 (Wed, 25 Jun 2008) New Revision: 2802 Modified: trunk/varnish-cache/bin/varnishtest/tests/c00001.vtc Log: Compensate for \r being magic now. Modified: trunk/varnish-cache/bin/varnishtest/tests/c00001.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/c00001.vtc 2008-06-25 09:59:21 UTC (rev 2801) +++ trunk/varnish-cache/bin/varnishtest/tests/c00001.vtc 2008-06-25 10:04:49 UTC (rev 2802) @@ -36,7 +36,7 @@ expect resp.http.foobar == "_barf_" expect resp.http.snafu1 == "_bararf_" expect resp.http.snafu2 == "_frap_" - expect resp.http.snafu3 == "_f\rap_" + expect resp.http.snafu3 == "_f\\rap_" expect resp.http.snafu4 == "_f&rap_" expect resp.http.snafu5 == "_barffra\p_" # NB: have to escape the \\ in the next line From tfheen at projects.linpro.no Wed Jun 25 13:32:29 2008 From: tfheen at projects.linpro.no (tfheen at projects.linpro.no) Date: Wed, 25 Jun 2008 15:32:29 +0200 (CEST) Subject: r2803 - trunk/varnish-cache Message-ID: <20080625133229.919401ED3E4@projects.linpro.no> Author: tfheen Date: 2008-06-25 15:32:29 +0200 (Wed, 25 Jun 2008) New Revision: 2803 Modified: trunk/varnish-cache/configure.ac Log: Set version to 2.0-tp2 in configure.ac Modified: trunk/varnish-cache/configure.ac =================================================================== --- trunk/varnish-cache/configure.ac 2008-06-25 10:04:49 UTC (rev 2802) +++ trunk/varnish-cache/configure.ac 2008-06-25 13:32:29 UTC (rev 2803) @@ -3,7 +3,7 @@ AC_PREREQ(2.59) AC_COPYRIGHT([Copyright (c) 2006-2008 Linpro AS / Verdens Gang AS]) AC_REVISION([$Id$]) -AC_INIT([Varnish], [trunk], [varnish-dev at projects.linpro.no]) +AC_INIT([Varnish], [2.0-tp2], [varnish-dev at projects.linpro.no]) AC_CONFIG_SRCDIR(include/varnishapi.h) AM_CONFIG_HEADER(config.h) From tfheen at projects.linpro.no Wed Jun 25 13:32:45 2008 From: tfheen at projects.linpro.no (tfheen at projects.linpro.no) Date: Wed, 25 Jun 2008 15:32:45 +0200 (CEST) Subject: r2804 - tags Message-ID: <20080625133245.79F4E1ED336@projects.linpro.no> Author: tfheen Date: 2008-06-25 15:32:45 +0200 (Wed, 25 Jun 2008) New Revision: 2804 Added: tags/varnish-2.0-tp2/ Log: Release 2.0-tp2 Copied: tags/varnish-2.0-tp2 (from rev 2803, trunk) From tfheen at projects.linpro.no Wed Jun 25 13:33:12 2008 From: tfheen at projects.linpro.no (tfheen at projects.linpro.no) Date: Wed, 25 Jun 2008 15:33:12 +0200 (CEST) Subject: r2805 - trunk/varnish-cache Message-ID: <20080625133312.5BCA21EC874@projects.linpro.no> Author: tfheen Date: 2008-06-25 15:33:12 +0200 (Wed, 25 Jun 2008) New Revision: 2805 Modified: trunk/varnish-cache/configure.ac Log: Set version to trunk in configure.ac Modified: trunk/varnish-cache/configure.ac =================================================================== --- trunk/varnish-cache/configure.ac 2008-06-25 13:32:45 UTC (rev 2804) +++ trunk/varnish-cache/configure.ac 2008-06-25 13:33:12 UTC (rev 2805) @@ -3,7 +3,7 @@ AC_PREREQ(2.59) AC_COPYRIGHT([Copyright (c) 2006-2008 Linpro AS / Verdens Gang AS]) AC_REVISION([$Id$]) -AC_INIT([Varnish], [2.0-tp2], [varnish-dev at projects.linpro.no]) +AC_INIT([Varnish], [trunk], [varnish-dev at projects.linpro.no]) AC_CONFIG_SRCDIR(include/varnishapi.h) AM_CONFIG_HEADER(config.h) From phk at projects.linpro.no Wed Jun 25 15:36:29 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Wed, 25 Jun 2008 17:36:29 +0200 (CEST) Subject: r2806 - trunk/varnish-cache/bin/varnishd Message-ID: <20080625153629.1EEF71ECEFC@projects.linpro.no> Author: phk Date: 2008-06-25 17:36:28 +0200 (Wed, 25 Jun 2008) New Revision: 2806 Modified: trunk/varnish-cache/bin/varnishd/cache_pool.c Log: Fix a startup race condition: Make sure the threadpools are created before the herder starts, in order that it will create the minimum number of threads in the pool. Modified: trunk/varnish-cache/bin/varnishd/cache_pool.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_pool.c 2008-06-25 13:33:12 UTC (rev 2805) +++ trunk/varnish-cache/bin/varnishd/cache_pool.c 2008-06-25 15:36:28 UTC (rev 2806) @@ -565,6 +565,7 @@ AZ(pthread_cond_init(&herder_cond, NULL)); AZ(pthread_mutex_init(&herder_mtx, NULL)); + wrk_addpools(params->wthread_pools); AZ(pthread_create(&tp, NULL, wrk_herdtimer_thread, NULL)); AZ(pthread_detach(tp)); AZ(pthread_create(&tp, NULL, wrk_herder_thread, NULL)); From phk at projects.linpro.no Wed Jun 25 15:54:52 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Wed, 25 Jun 2008 17:54:52 +0200 (CEST) Subject: r2807 - trunk/varnish-cache/bin/varnishtest/tests Message-ID: <20080625155452.C587F1EC874@projects.linpro.no> Author: phk Date: 2008-06-25 17:54:52 +0200 (Wed, 25 Jun 2008) New Revision: 2807 Added: trunk/varnish-cache/bin/varnishtest/tests/r00263.vtc Log: Testcase for ticket 263 Added: trunk/varnish-cache/bin/varnishtest/tests/r00263.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/r00263.vtc (rev 0) +++ trunk/varnish-cache/bin/varnishtest/tests/r00263.vtc 2008-06-25 15:54:52 UTC (rev 2807) @@ -0,0 +1,21 @@ +# $Id$ + +test "Test refcounting backends from director" + +varnish v1 -vcl+backend { + backend node1 { .host = "10.0.0.1"; .port = "80"; } + backend node2 { .host = "10.0.0.2"; .port = "80"; } + backend node3 { .host = "10.0.0.3"; .port = "80"; } + + director cluster random { + { .backend = node1; .weight = 1; } + { .backend = node2; .weight = 1; } + { .backend = node3; .weight = 1; } + } + + sub vcl_recv { + set req.backend = cluster; + } +} -start + +varnish v1 -wait From phk at projects.linpro.no Wed Jun 25 15:56:05 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Wed, 25 Jun 2008 17:56:05 +0200 (CEST) Subject: r2808 - trunk/varnish-cache/lib/libvcl Message-ID: <20080625155605.7FBC01ED1C0@projects.linpro.no> Author: phk Date: 2008-06-25 17:56:05 +0200 (Wed, 25 Jun 2008) New Revision: 2808 Modified: trunk/varnish-cache/lib/libvcl/vcc_backend.c Log: Grap reference count on backend used by name in directors. Fixes ticket 263 Modified: trunk/varnish-cache/lib/libvcl/vcc_backend.c =================================================================== --- trunk/varnish-cache/lib/libvcl/vcc_backend.c 2008-06-25 15:54:52 UTC (rev 2807) +++ trunk/varnish-cache/lib/libvcl/vcc_backend.c 2008-06-25 15:56:05 UTC (rev 2808) @@ -238,6 +238,7 @@ vcc_ErrWhere(tl, tl->t); return; } + vcc_AddRef(tl, h->name, R_BACKEND); vcc_NextToken(tl); ExpectErr(tl, ';'); vcc_NextToken(tl); From phk at projects.linpro.no Wed Jun 25 20:53:43 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Wed, 25 Jun 2008 22:53:43 +0200 (CEST) Subject: r2809 - trunk/varnish-cache/bin/varnishtest/tests Message-ID: <20080625205343.B2D721EC236@projects.linpro.no> Author: phk Date: 2008-06-25 22:53:43 +0200 (Wed, 25 Jun 2008) New Revision: 2809 Added: trunk/varnish-cache/bin/varnishtest/tests/c00004.vtc Log: Add a Vary testcase Added: trunk/varnish-cache/bin/varnishtest/tests/c00004.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/c00004.vtc (rev 0) +++ trunk/varnish-cache/bin/varnishtest/tests/c00004.vtc 2008-06-25 20:53:43 UTC (rev 2809) @@ -0,0 +1,55 @@ +# $Id$ + +test "Test Vary functionality" + +varnish v1 -arg "-b 127.0.0.1:9080" -start + +server s1 { + rxreq + expect req.http.foobar == "1" + txresp -hdr "Vary: Foobar" -hdr "Snafu: 1" -hdr "Content-Length: 5" -body "1111\n" + rxreq + expect req.http.foobar == "2" + txresp -hdr "Vary: Foobar" -hdr "Snafu: 2" -hdr "Content-Length: 5" -body "2222\n" + rxreq + expect req.http.foobar == "3" + txresp -hdr "Vary: Foobar" -hdr "Snafu: 3" -hdr "Content-Length: 5" -body "3333\n" + rxreq + expect req.http.foobar == "4" + txresp -hdr "Vary: Foobar" -hdr "Snafu: 4" -hdr "Content-Length: 5" -body "4444\n" +} -start + +client c1 { + txreq -hdr "Foobar: 1" + rxresp + expect resp.status == 200 + expect resp.http.X-Varnish == "1001" + expect resp.http.snafu == "1" + + txreq -hdr "Foobar: 2" + rxresp + expect resp.status == 200 + expect resp.http.X-Varnish == "1002" + expect resp.http.snafu == "2" + + txreq -hdr "Foobar: 3" + rxresp + expect resp.status == 200 + expect resp.http.X-Varnish == "1003" + expect resp.http.snafu == "3" + + txreq -hdr "Foobar: 4" + rxresp + expect resp.status == 200 + expect resp.http.X-Varnish == "1004" + expect resp.http.snafu == "4" + + txreq -hdr "Foobar: 1" + rxresp + expect resp.status == 200 + expect resp.http.X-Varnish == "1005 1001" + expect resp.http.snafu == "1" + +} + +client c1 -run From phk at projects.linpro.no Wed Jun 25 21:06:40 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Wed, 25 Jun 2008 23:06:40 +0200 (CEST) Subject: r2810 - trunk/varnish-cache/bin/varnishtest/tests Message-ID: <20080625210640.9D1E51EC04B@projects.linpro.no> Author: phk Date: 2008-06-25 23:06:40 +0200 (Wed, 25 Jun 2008) New Revision: 2810 Modified: trunk/varnish-cache/bin/varnishtest/tests/c00004.vtc Log: Remember to test the case with missing vary header Modified: trunk/varnish-cache/bin/varnishtest/tests/c00004.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/c00004.vtc 2008-06-25 20:53:43 UTC (rev 2809) +++ trunk/varnish-cache/bin/varnishtest/tests/c00004.vtc 2008-06-25 21:06:40 UTC (rev 2810) @@ -15,7 +15,6 @@ expect req.http.foobar == "3" txresp -hdr "Vary: Foobar" -hdr "Snafu: 3" -hdr "Content-Length: 5" -body "3333\n" rxreq - expect req.http.foobar == "4" txresp -hdr "Vary: Foobar" -hdr "Snafu: 4" -hdr "Content-Length: 5" -body "4444\n" } -start @@ -38,7 +37,7 @@ expect resp.http.X-Varnish == "1003" expect resp.http.snafu == "3" - txreq -hdr "Foobar: 4" + txreq rxresp expect resp.status == 200 expect resp.http.X-Varnish == "1004" From phk at projects.linpro.no Wed Jun 25 21:12:04 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Wed, 25 Jun 2008 23:12:04 +0200 (CEST) Subject: r2811 - trunk/varnish-cache/bin/varnishtest/tests Message-ID: <20080625211204.8A6851EC8B2@projects.linpro.no> Author: phk Date: 2008-06-25 23:12:04 +0200 (Wed, 25 Jun 2008) New Revision: 2811 Modified: trunk/varnish-cache/bin/varnishtest/tests/c00004.vtc Log: Test for match with leading and trailing space as well. Modified: trunk/varnish-cache/bin/varnishtest/tests/c00004.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/c00004.vtc 2008-06-25 21:06:40 UTC (rev 2810) +++ trunk/varnish-cache/bin/varnishtest/tests/c00004.vtc 2008-06-25 21:12:04 UTC (rev 2811) @@ -43,7 +43,7 @@ expect resp.http.X-Varnish == "1004" expect resp.http.snafu == "4" - txreq -hdr "Foobar: 1" + txreq -hdr "Foobar: 1 " rxresp expect resp.status == 200 expect resp.http.X-Varnish == "1005 1001" From phk at projects.linpro.no Wed Jun 25 21:22:14 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Wed, 25 Jun 2008 23:22:14 +0200 (CEST) Subject: r2812 - trunk/varnish-cache/bin/varnishtest/tests Message-ID: <20080625212214.61B5D1ECEFC@projects.linpro.no> Author: phk Date: 2008-06-25 23:22:13 +0200 (Wed, 25 Jun 2008) New Revision: 2812 Added: trunk/varnish-cache/bin/varnishtest/tests/c00005.vtc Log: A simple ACL testcase Added: trunk/varnish-cache/bin/varnishtest/tests/c00005.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/c00005.vtc (rev 0) +++ trunk/varnish-cache/bin/varnishtest/tests/c00005.vtc 2008-06-25 21:22:13 UTC (rev 2812) @@ -0,0 +1,46 @@ +# $Id$ + +test "Test simple ACL" + +server s1 { + rxreq + expect req.url == "/" + txresp -hdr "Content-Length: 5" -body "1111\n" + rxreq + expect req.url == "foo" + txresp -hdr "Content-Length: 5" -body "2222\n" +} -start + +varnish v1 -vcl+backend { + acl acl1 { + "127.0.0.1"; + } + + sub vcl_recv { + if (client.ip ~ acl1) { + set req.url = "/"; + } + } +} -start + +client c1 { + txreq -url "foo" + rxresp + expect resp.status == 200 +} + +client c1 -run + +varnish v1 -vcl+backend { + acl acl1 { + "!127.0.0.1"; + } + + sub vcl_recv { + if (client.ip ~ acl1) { + set req.url = "/"; + } + } +} + +client c1 -run From phk at projects.linpro.no Wed Jun 25 21:52:55 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Wed, 25 Jun 2008 23:52:55 +0200 (CEST) Subject: r2813 - trunk/varnish-cache/bin/varnishtest/tests Message-ID: <20080625215255.5D2121EC8B2@projects.linpro.no> Author: phk Date: 2008-06-25 23:52:55 +0200 (Wed, 25 Jun 2008) New Revision: 2813 Added: trunk/varnish-cache/bin/varnishtest/tests/b00006.vtc Log: Add a -s malloc testcase Added: trunk/varnish-cache/bin/varnishtest/tests/b00006.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/b00006.vtc (rev 0) +++ trunk/varnish-cache/bin/varnishtest/tests/b00006.vtc 2008-06-25 21:52:55 UTC (rev 2813) @@ -0,0 +1,25 @@ +# $Id$ + +test "Check that -s malloc works" + +varnish v1 -arg "-s malloc -b 127.0.0.1:9080" -start + +server s1 { + rxreq + txresp -hdr "Connection: close" -body "012345\n" +} + +server s1 -start + +client c1 { + txreq -url "/" + rxresp + expect resp.status == 200 +} + +client c1 -run + +server s1 -wait + +varnish v1 -stop +shell "rm ../varnishd/varnishtest_backing" From phk at projects.linpro.no Wed Jun 25 21:57:57 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Wed, 25 Jun 2008 23:57:57 +0200 (CEST) Subject: r2814 - trunk/varnish-cache/bin/varnishtest/tests Message-ID: <20080625215757.40C9D1EC0F8@projects.linpro.no> Author: phk Date: 2008-06-25 23:57:56 +0200 (Wed, 25 Jun 2008) New Revision: 2814 Added: trunk/varnish-cache/bin/varnishtest/tests/b00007.vtc Modified: trunk/varnish-cache/bin/varnishtest/tests/b00006.vtc Log: Add chunked encoding from backend test. Fix copy&paste mistake in test b00006 Modified: trunk/varnish-cache/bin/varnishtest/tests/b00006.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/b00006.vtc 2008-06-25 21:52:55 UTC (rev 2813) +++ trunk/varnish-cache/bin/varnishtest/tests/b00006.vtc 2008-06-25 21:57:56 UTC (rev 2814) @@ -22,4 +22,3 @@ server s1 -wait varnish v1 -stop -shell "rm ../varnishd/varnishtest_backing" Added: trunk/varnish-cache/bin/varnishtest/tests/b00007.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/b00007.vtc (rev 0) +++ trunk/varnish-cache/bin/varnishtest/tests/b00007.vtc 2008-06-25 21:57:56 UTC (rev 2814) @@ -0,0 +1,43 @@ +# $Id$ + +test "Check chunked encoding from backend works" + +varnish v1 -arg "-s malloc -b 127.0.0.1:9080" -start + +server s1 { + rxreq + expect req.url == "/bar" + send "HTTP/1.1 200 Ok\r\n" + send "Transfer-encoding: chunked\r\n" + send "\r\n" + send "00000004\r\n1234\r\n" + send "00000000\r\n" + + rxreq + expect req.url == "/foo" + send "HTTP/1.1 200 Ok\r\n" + send "Transfer-encoding: chunked\r\n" + send "\r\n" + send "00000004\r\n1234\r\n" + send "00000004\r\n1234\r\n" + send "00000000\r\n" +} + +server s1 -start + +client c1 { + txreq -url "/bar" + rxresp + expect resp.status == 200 + expect resp.http.content-length == "4" + txreq -url "/foo" + rxresp + expect resp.status == 200 + expect resp.http.content-length == "8" +} + +client c1 -run + +server s1 -wait + +varnish v1 -stop From phk at projects.linpro.no Wed Jun 25 22:09:00 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Thu, 26 Jun 2008 00:09:00 +0200 (CEST) Subject: r2815 - trunk/varnish-cache/bin/varnishtest/tests Message-ID: <20080625220900.C49CE1EC115@projects.linpro.no> Author: phk Date: 2008-06-26 00:09:00 +0200 (Thu, 26 Jun 2008) New Revision: 2815 Added: trunk/varnish-cache/bin/varnishtest/tests/b00008.vtc Log: Test case for CLI help and parameter functions Added: trunk/varnish-cache/bin/varnishtest/tests/b00008.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/b00008.vtc (rev 0) +++ trunk/varnish-cache/bin/varnishtest/tests/b00008.vtc 2008-06-25 22:09:00 UTC (rev 2815) @@ -0,0 +1,19 @@ +# $Id$ + +test "Test CLI help and parameter functions" + +varnish v1 -arg "-b localhost:9080" + +varnish v1 -cli "help" + +varnish v1 -cli "param.show" + +varnish v1 -cli "param.show diag_bitmap" + +varnish v1 -cli "param.set diag_bitmap 0x40" + +varnish v1 -cli "param.set diag_bitmap 0x0" + +varnish v1 -start + +varnish v1 -cli "help" From phk at projects.linpro.no Thu Jun 26 08:53:52 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Thu, 26 Jun 2008 10:53:52 +0200 (CEST) Subject: r2816 - in trunk/varnish-cache/bin/varnishtest: . tests Message-ID: <20080626085352.1CF171EC874@projects.linpro.no> Author: phk Date: 2008-06-26 10:53:51 +0200 (Thu, 26 Jun 2008) New Revision: 2816 Modified: trunk/varnish-cache/bin/varnishtest/flint.lnt trunk/varnish-cache/bin/varnishtest/flint.sh trunk/varnish-cache/bin/varnishtest/tests/b00007.vtc trunk/varnish-cache/bin/varnishtest/vtc.c trunk/varnish-cache/bin/varnishtest/vtc.h trunk/varnish-cache/bin/varnishtest/vtc_client.c trunk/varnish-cache/bin/varnishtest/vtc_http.c trunk/varnish-cache/bin/varnishtest/vtc_log.c trunk/varnish-cache/bin/varnishtest/vtc_server.c trunk/varnish-cache/bin/varnishtest/vtc_varnish.c Log: Add -chunked primitive for easier message composition. Go over varnishtest with FlexeLint Modified: trunk/varnish-cache/bin/varnishtest/flint.lnt =================================================================== --- trunk/varnish-cache/bin/varnishtest/flint.lnt 2008-06-25 22:09:00 UTC (rev 2815) +++ trunk/varnish-cache/bin/varnishtest/flint.lnt 2008-06-26 08:53:51 UTC (rev 2816) @@ -7,38 +7,44 @@ // 796 and 797 (out-of-bounds errors). -elib(123) // size is both a variable and a macro with args -emacro(736, isnan) // isnanf +-efile(766, ../../config.h) +// -header(../../config.h) + +// Fix strchr() semtics, it can only return NULL if arg2 != 0 -sem(strchr, 1p, type(1), 2n == 0 ? (@p < 1p) : (@p < 1p || @p == 0 )) - --sem(vsb_new, @p == malloc(1)) --sem(vsb_delete, custodial(1)) +// +// -sem(vsb_new, @p == malloc(1)) +// -sem(vsb_delete, custodial(1)) -sem(lbv_assert, r_no) -sem(lbv_xxxassert, r_no) - --ffc // No automatic custody - +// -sem(WS_Init, custodial(2)) +// -sem(http_Setup, custodial(2)) +// +// -ffc // No automatic custody +// -e763 // Redundant declaration for symbol '...' previously declared --e726 // Extraneous comma ignored --e728 // Symbol ... not explicitly initialized +// -e726 // Extraneous comma ignored +// -e728 // Symbol ... not explicitly initialized -e716 // while(1) ... --e785 // Too few initializers for aggregate --e786 // String concatenation within initializer - --emacro(740, VTAILQ_PREV) // Unusual pointer cast (incompatible indirect types) --emacro(740, VTAILQ_LAST) // Unusual pointer cast (incompatible indirect types) --emacro((826), VTAILQ_PREV) // Suspicious pointer-to-pointer conversion (area too small) --emacro((826), VTAILQ_LAST) // Suspicious pointer-to-pointer conversion (area too small) +// -e785 // Too few initializers for aggregate +// -e786 // String concatenation within initializer +// +// -emacro(740, VTAILQ_PREV) // Unusual pointer cast (incompatible indirect types) +// -emacro(740, VTAILQ_LAST) // Unusual pointer cast (incompatible indirect types) +// -emacro((826), VTAILQ_PREV) // Suspicious pointer-to-pointer conversion (area too small) +// -emacro((826), VTAILQ_LAST) // Suspicious pointer-to-pointer conversion (area too small) -emacro(506, VTAILQ_FOREACH_SAFE) // constant value boolean - +// -esym(534, sprintf) // Ignoring return value of function --esym(534, asprintf) // Ignoring return value of function +// -esym(534, asprintf) // Ignoring return value of function -esym(534, printf) // Ignoring return value of function -esym(534, fprintf) // Ignoring return value of function -esym(534, memset) // Ignoring return value of function --esym(534, memcpy) // Ignoring return value of function --esym(534, memmove) // Ignoring return value of function --esym(534, strcpy) // Ignoring return value of function +// -esym(534, memcpy) // Ignoring return value of function +// -esym(534, memmove) // Ignoring return value of function +// -esym(534, strcpy) // Ignoring return value of function -esym(534, vsb_printf) // Ignoring return value of function -esym(534, vsb_cat) // Ignoring return value of function -esym(534, vsb_bcat) // Ignoring return value of function @@ -46,33 +52,44 @@ -esym(534, strcat) // Ignoring return value of function -esym(534, strcpy) // Ignoring return value of function -esym(534, strlcpy) // Ignoring return value of function - --emacro(506, isnan) // constant value boolean --emacro(747, isnan) // significant coersion --emacro(506, assert) // constant value boolean --emacro(827, assert) // loop not reachable --emacro(774, assert) // booelan always true - -// cache.h --emacro(506, INCOMPL) // Constant value Boolean - -// Review all below this line /////////////////////////////////////////////// - +// +// -emacro(506, isnan) // constant value boolean +// -emacro(747, isnan) // significant coersion +// -emacro(506, assert) // constant value boolean +// -emacro(827, assert) // loop not reachable +// -emacro(774, assert) // booelan always true +// -emacro(774, HTTPH) // always false +// +// // cache.h +// -emacro(506, INCOMPL) // Constant value Boolean +// +// // cache_center.c +// -efunc(525, CNT_Session) // Negative indentation from line +// -efunc(525, http_FilterFields) // Negative indentation from line +// -efunc(539, http_FilterFields) // Positive indentation from line +// +// // cache_vcl.c +// -efunc(525, vcl_handlingname) // Negative indentation from line +// -esym(528, vcl_handlingname) // Not referenced +// -e641 // Converting enum 'cli_status_e' to int +// +// // Review all below this line /////////////////////////////////////////////// +// -e732 // Loss of sign (arg. no. 2) (int to unsigned -e737 // [45] Loss of sign in promotion from int to unsigned -e713 // Loss of precision (assignment) (unsigned long long to long long) -e574 // Signed-unsigned mix with relational --e712 // Loss of precision (assignment) (long long to --e747 // Significant prototype coercion (arg. no. 2) long - -/* - --e767 // Macro redef (system queue.h vs ours ) - --e506 // Constant value boolean --e818 // Pointer parameter '...' could be declared as pointing to const --e774 // Boolean within 'if' always evaluates to False --e534 // Ignoring return value of function --e557 // unrecog format - -*/ +// -e712 // Loss of precision (assignment) (long long to +// -e747 // Significant prototype coercion (arg. no. 2) long +// +// /* +// +// -e767 // Macro redef (system queue.h vs ours ) +// +// -e506 // Constant value boolean +// -e818 // Pointer parameter '...' could be declared as pointing to const +// -e774 // Boolean within 'if' always evaluates to False +// -e534 // Ignoring return value of function +// -e557 // unrecog format +// +// */ Modified: trunk/varnish-cache/bin/varnishtest/flint.sh =================================================================== --- trunk/varnish-cache/bin/varnishtest/flint.sh 2008-06-25 22:09:00 UTC (rev 2815) +++ trunk/varnish-cache/bin/varnishtest/flint.sh 2008-06-26 08:53:51 UTC (rev 2816) @@ -6,11 +6,10 @@ -I. \ -I../../include \ -I../.. \ - -DVARNISH_STATE_DIR=\"foo\" \ flint.lnt \ *.c > $T 2>&1 -for t in Error Warning Info +for t in Error Warning Info Note do sed -n "/$t [0-9][0-9][0-9]:/s/.*\($t [0-9][0-9][0-9]\).*/\1/p" $T done | awk ' Modified: trunk/varnish-cache/bin/varnishtest/tests/b00007.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/b00007.vtc 2008-06-25 22:09:00 UTC (rev 2815) +++ trunk/varnish-cache/bin/varnishtest/tests/b00007.vtc 2008-06-26 08:53:51 UTC (rev 2816) @@ -19,8 +19,8 @@ send "Transfer-encoding: chunked\r\n" send "\r\n" send "00000004\r\n1234\r\n" - send "00000004\r\n1234\r\n" - send "00000000\r\n" + chunked "1234" + chunked "" } server s1 -start Modified: trunk/varnish-cache/bin/varnishtest/vtc.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc.c 2008-06-25 22:09:00 UTC (rev 2815) +++ trunk/varnish-cache/bin/varnishtest/vtc.c 2008-06-26 08:53:51 UTC (rev 2816) @@ -61,11 +61,11 @@ err(1, "Cannot open %s", fn); buf = malloc(sz); assert(buf != NULL); - s = read(fd, buf, sz); + s = read(fd, buf, sz - 1); if (s <= 0) err(1, "Cannot read %s", fn); + AZ(close (fd)); assert(s < sz); /* XXX: increase MAX_FILESIZE */ - AZ(close (fd)); buf[s] = '\0'; buf = realloc(buf, s + 1); assert(buf != NULL); @@ -141,7 +141,7 @@ p++; } else if (*p == '{') { /* Braces */ nest_brace = 0; - token_s[tn] = p; + token_s[tn] = p + 1; for (; *p != '\0'; p++) { if (*p == '{') nest_brace++; @@ -151,7 +151,7 @@ } } assert(*p == '}'); - token_e[tn++] = ++p; + token_e[tn++] = p++; } else { /* other tokens */ token_s[tn] = p; for (; *p != '\0' && !isspace(*p); p++) @@ -228,7 +228,7 @@ AN(av[1]); AZ(av[2]); vtc_dump(vl, 4, "shell", av[1]); - system(av[1]); + (void)system(av[1]); /* XXX: assert ? */ } /********************************************************************** @@ -303,7 +303,7 @@ */ int -main(int argc, char **argv) +main(int argc, char * const *argv) { int ch; Modified: trunk/varnish-cache/bin/varnishtest/vtc.h =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc.h 2008-06-25 22:09:00 UTC (rev 2815) +++ trunk/varnish-cache/bin/varnishtest/vtc.h 2008-06-26 08:53:51 UTC (rev 2816) @@ -30,7 +30,7 @@ struct vtclog; struct cmds; -#define CMD_ARGS char **av, void *priv, const struct cmds *cmd +#define CMD_ARGS char * const *av, void *priv, const struct cmds *cmd typedef void cmd_f(CMD_ARGS); struct cmds { Modified: trunk/varnish-cache/bin/varnishtest/vtc_client.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_client.c 2008-06-25 22:09:00 UTC (rev 2815) +++ trunk/varnish-cache/bin/varnishtest/vtc_client.c 2008-06-26 08:53:51 UTC (rev 2816) @@ -208,11 +208,10 @@ client_run(c); continue; } - if (**av == '{') { - c->spec = *av; - continue; + if (**av == '-') { + vtc_log(c->vl, 0, "Unknown client argument: %s", *av); + exit (1); } - vtc_log(c->vl, 0, "Unknown client argument: %s", *av); - exit (1); + c->spec = *av; } } Modified: trunk/varnish-cache/bin/varnishtest/vtc_http.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_http.c 2008-06-25 22:09:00 UTC (rev 2815) +++ trunk/varnish-cache/bin/varnishtest/vtc_http.c 2008-06-26 08:53:51 UTC (rev 2816) @@ -51,6 +51,8 @@ int timeout; struct vtclog *vl; + struct vsb *vsb; + int nrxbuf; char *rxbuf; @@ -58,12 +60,31 @@ char *resp[MAX_HDR]; }; +/* XXX: we may want to vary this */ +static const char *nl = "\r\n"; + /********************************************************************** + * Finish and write the vsb to the fd + */ + +static void +http_write(const struct http *hp, int lvl, const char *pfx) +{ + int l; + + vsb_finish(hp->vsb); + AZ(vsb_overflowed(hp->vsb)); + vtc_dump(hp->vl, lvl, pfx, vsb_data(hp->vsb)); + l = write(hp->fd, vsb_data(hp->vsb), vsb_len(hp->vsb)); + assert(l == vsb_len(hp->vsb)); +} + +/********************************************************************** * find header */ static char * -http_find_header(char **hh, const char *hdr) +http_find_header(char * const *hh, const char *hdr) { int n, l; char *r; @@ -235,7 +256,7 @@ */ static void -http_swallow_body(struct http *hp, char **hh) +http_swallow_body(const struct http *hp, char * const *hh) { char *p, b[BUFSIZ + 1]; int l, i; @@ -334,14 +355,11 @@ cmd_http_txresp(CMD_ARGS) { struct http *hp; - struct vsb *vsb; const char *proto = "HTTP/1.1"; const char *status = "200"; const char *msg = "Ok"; const char *body = NULL; int dohdr = 0; - const char *nl = "\r\n"; - int l; (void)cmd; CAST_OBJ_NOTNULL(hp, priv, HTTP_MAGIC); @@ -349,7 +367,7 @@ assert(!strcmp(av[0], "txresp")); av++; - vsb = vsb_newauto(); + vsb_clear(hp->vsb); for(; *av != NULL; av++) { if (!strcmp(*av, "-proto")) { @@ -377,11 +395,11 @@ } if (!strcmp(*av, "-hdr")) { if (dohdr == 0) { - vsb_printf(vsb, "%s %s %s%s", + vsb_printf(hp->vsb, "%s %s %s%s", proto, status, msg, nl); dohdr = 1; } - vsb_printf(vsb, "%s%s", av[1], nl); + vsb_printf(hp->vsb, "%s%s", av[1], nl); av++; continue; } @@ -389,21 +407,16 @@ exit (1); } if (dohdr == 0) { - vsb_printf(vsb, "%s %s %s%s", + vsb_printf(hp->vsb, "%s %s %s%s", proto, status, msg, nl); dohdr = 1; } - vsb_cat(vsb, nl); + vsb_cat(hp->vsb, nl); if (body != NULL) { - vsb_cat(vsb, body); - vsb_cat(vsb, nl); + vsb_cat(hp->vsb, body); + vsb_cat(hp->vsb, nl); } - vsb_finish(vsb); - AZ(vsb_overflowed(vsb)); - vtc_dump(hp->vl, 4, NULL, vsb_data(vsb)); - l = write(hp->fd, vsb_data(vsb), vsb_len(vsb)); - assert(l == vsb_len(vsb)); - vsb_delete(vsb); + http_write(hp, 4, "txresp"); } /********************************************************************** @@ -439,14 +452,11 @@ cmd_http_txreq(CMD_ARGS) { struct http *hp; - struct vsb *vsb; const char *req = "GET"; const char *url = "/"; const char *proto = "HTTP/1.1"; const char *body = NULL; int dohdr = 0; - const char *nl = "\r\n"; - int l; (void)cmd; CAST_OBJ_NOTNULL(hp, priv, HTTP_MAGIC); @@ -454,7 +464,7 @@ assert(!strcmp(av[0], "txreq")); av++; - vsb = vsb_newauto(); + vsb_clear(hp->vsb); for(; *av != NULL; av++) { if (!strcmp(*av, "-url")) { @@ -477,11 +487,11 @@ } if (!strcmp(*av, "-hdr")) { if (dohdr == 0) { - vsb_printf(vsb, "%s %s %s%s", + vsb_printf(hp->vsb, "%s %s %s%s", req, url, proto, nl); dohdr = 1; } - vsb_printf(vsb, "%s%s", av[1], nl); + vsb_printf(hp->vsb, "%s%s", av[1], nl); av++; continue; } @@ -494,21 +504,16 @@ exit (1); } if (dohdr == 0) { - vsb_printf(vsb, "%s %s %s%s", + vsb_printf(hp->vsb, "%s %s %s%s", req, url, proto, nl); dohdr = 1; } - vsb_cat(vsb, nl); + vsb_cat(hp->vsb, nl); if (body != NULL) { - vsb_cat(vsb, body); - vsb_cat(vsb, nl); + vsb_cat(hp->vsb, body); + vsb_cat(hp->vsb, nl); } - vsb_finish(vsb); - AZ(vsb_overflowed(vsb)); - vtc_dump(hp->vl, 4, NULL, vsb_data(vsb)); - l = write(hp->fd, vsb_data(vsb), vsb_len(vsb)); - assert(l == vsb_len(vsb)); - vsb_delete(vsb); + http_write(hp, 4, "txreq"); } /********************************************************************** @@ -531,7 +536,25 @@ } +/********************************************************************** + * Send a string as chunked encoding + */ +static void +cmd_http_chunked(CMD_ARGS) +{ + struct http *hp; + + (void)cmd; + CAST_OBJ_NOTNULL(hp, priv, HTTP_MAGIC); + AN(av[1]); + AZ(av[2]); + vsb_clear(hp->vsb); + vsb_printf(hp->vsb, "%x%s%s%s", strlen(av[1]), nl, av[1], nl); + http_write(hp, 4, "chunked"); +} + + /********************************************************************** * Execute HTTP specifications */ @@ -543,6 +566,7 @@ { "rxresp", cmd_http_rxresp }, { "expect", cmd_http_expect }, { "send", cmd_http_send }, + { "chunked", cmd_http_chunked }, { "delay", cmd_delay }, { NULL, NULL } }; @@ -560,14 +584,14 @@ hp->client = client; hp->timeout = 1000; hp->nrxbuf = 8192; + hp->vsb = vsb_newauto(); + AN(hp->vsb); - s = strdup(spec + 1); + s = strdup(spec); q = strchr(s, '\0'); assert(q > s); - q--; - assert(*q == '}'); - *q = '\0'; AN(s); parse_string(s, http_cmds, hp); + vsb_delete(hp->vsb); free(hp); } Modified: trunk/varnish-cache/bin/varnishtest/vtc_log.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_log.c 2008-06-25 22:09:00 UTC (rev 2815) +++ trunk/varnish-cache/bin/varnishtest/vtc_log.c 2008-06-26 08:53:51 UTC (rev 2816) @@ -73,6 +73,7 @@ #define NLEAD (sizeof(lead)/sizeof(lead[0])) +//lint -e{818} void vtc_log(struct vtclog *vl, unsigned lvl, const char *fmt, ...) { @@ -98,6 +99,7 @@ * Dump a string */ +//lint -e{818} void vtc_dump(struct vtclog *vl, unsigned lvl, const char *pfx, const char *str) { Modified: trunk/varnish-cache/bin/varnishtest/vtc_server.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_server.c 2008-06-25 22:09:00 UTC (rev 2815) +++ trunk/varnish-cache/bin/varnishtest/vtc_server.c 2008-06-26 08:53:51 UTC (rev 2816) @@ -252,11 +252,10 @@ server_wait(s); continue; } - if (**av == '{') { - s->spec = *av; - continue; + if (**av == '-') { + vtc_log(s->vl, 0, "Unknown server argument: %s", *av); + exit (1); } - vtc_log(s->vl, 0, "Unknown server argument: %s", *av); - exit (1); + s->spec = *av; } } Modified: trunk/varnish-cache/bin/varnishtest/vtc_varnish.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_varnish.c 2008-06-25 22:09:00 UTC (rev 2815) +++ trunk/varnish-cache/bin/varnishtest/vtc_varnish.c 2008-06-26 08:53:51 UTC (rev 2816) @@ -29,19 +29,17 @@ #include -#include #include #include #include #include -#include #include +#include #include #include #include - #include "vqueue.h" #include "miniobj.h" #include "libvarnish.h" @@ -91,7 +89,7 @@ assert(i == strlen(cmd)); i = write(v->cli_fd, "\n", 1); assert(i == 1); - i = cli_readres(v->cli_fd, &retval, &r, 1000); + i = cli_readres(v->cli_fd, &retval, &r, 1.0); assert(i == 0); vtc_dump(v->vl, 4, "CLI RX", r); vtc_log(v->vl, 3, "CLI STATUS %u", retval); @@ -358,10 +356,9 @@ */ static void -varnish_vclbackend(struct varnish *v, char *vcl) +varnish_vclbackend(struct varnish *v, const char *vcl) { struct vsb *vsb, *vsb2; - char *p; enum cli_status_e u; if (v->cli_fd < 0) @@ -381,11 +378,6 @@ varnish_cli_encode(vsb, vsb_data(vsb2)); - if (*vcl == '{') { - p = strchr(++vcl, '\0'); - if (p > vcl && p[-1] == '}') - p[-1] = '\0'; - } varnish_cli_encode(vsb, vcl); vsb_printf(vsb, "\"", *vcl); From phk at projects.linpro.no Thu Jun 26 09:22:47 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Thu, 26 Jun 2008 11:22:47 +0200 (CEST) Subject: r2817 - trunk/varnish-cache/bin/varnishtest Message-ID: <20080626092247.94D381EC0B3@projects.linpro.no> Author: phk Date: 2008-06-26 11:22:46 +0200 (Thu, 26 Jun 2008) New Revision: 2817 Modified: trunk/varnish-cache/bin/varnishtest/vtc_varnish.c Log: Use 10 second CLI timeout Modified: trunk/varnish-cache/bin/varnishtest/vtc_varnish.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_varnish.c 2008-06-26 08:53:51 UTC (rev 2816) +++ trunk/varnish-cache/bin/varnishtest/vtc_varnish.c 2008-06-26 09:22:46 UTC (rev 2817) @@ -89,7 +89,7 @@ assert(i == strlen(cmd)); i = write(v->cli_fd, "\n", 1); assert(i == 1); - i = cli_readres(v->cli_fd, &retval, &r, 1.0); + i = cli_readres(v->cli_fd, &retval, &r, 10.0); assert(i == 0); vtc_dump(v->vl, 4, "CLI RX", r); vtc_log(v->vl, 3, "CLI STATUS %u", retval); From phk at projects.linpro.no Thu Jun 26 09:45:31 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Thu, 26 Jun 2008 11:45:31 +0200 (CEST) Subject: r2818 - in trunk/varnish-cache/bin/varnishtest: . tests Message-ID: <20080626094531.2AB6D1EC874@projects.linpro.no> Author: phk Date: 2008-06-26 11:45:29 +0200 (Thu, 26 Jun 2008) New Revision: 2818 Modified: trunk/varnish-cache/bin/varnishtest/tests/a00006.vtc trunk/varnish-cache/bin/varnishtest/tests/a00007.vtc trunk/varnish-cache/bin/varnishtest/tests/c00004.vtc trunk/varnish-cache/bin/varnishtest/tests/c00005.vtc trunk/varnish-cache/bin/varnishtest/tests/r00255.vtc trunk/varnish-cache/bin/varnishtest/vtc_http.c Log: Make -body automatically create a Content-Length header in txresp and txreq. For lowerlevel syntax based tests, we can revert to send and chunked. Modified: trunk/varnish-cache/bin/varnishtest/tests/a00006.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/a00006.vtc 2008-06-26 09:22:46 UTC (rev 2817) +++ trunk/varnish-cache/bin/varnishtest/tests/a00006.vtc 2008-06-26 09:45:29 UTC (rev 2818) @@ -8,7 +8,6 @@ expect req.proto == HTTP/1.0 expect req.url == "/foo" txresp -proto HTTP/1.2 -status 201 -msg Foo \ - -hdr "Content-Length: 10" \ -body "987654321\n" } @@ -16,7 +15,6 @@ client c1 -connect 127.0.0.1:9080 { txreq -req PUT -proto HTTP/1.0 -url /foo \ - -hdr "Content-Length: 10" \ -body "123456789\n" rxresp expect resp.proto == HTTP/1.2 Modified: trunk/varnish-cache/bin/varnishtest/tests/a00007.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/a00007.vtc 2008-06-26 09:22:46 UTC (rev 2817) +++ trunk/varnish-cache/bin/varnishtest/tests/a00007.vtc 2008-06-26 09:45:29 UTC (rev 2818) @@ -5,20 +5,18 @@ server s1 -listen 127.0.0.1:9080 { rxreq expect req.url == "/1" - txresp -hdr "Content-Length: 10" -body "123456789\n" + txresp -body "123456789\n" rxreq expect req.url == "/2" - txresp -hdr "Content-Length: 10" -body "987654321\n" + txresp -body "987654321\n" } server s1 -start client c1 -connect 127.0.0.1:9080 { - txreq -url "/1" -req "POST" \ - -hdr "Content-Length: 10" -body "abcdefghi\n" + txreq -url "/1" -req "POST" -body "abcdefghi\n" rxresp - txreq -url "/2" -req "POST" \ - -hdr "Content-Length: 10" -body "ihgfedcba\n" + txreq -url "/2" -req "POST" -body "ihgfedcba\n" rxresp } Modified: trunk/varnish-cache/bin/varnishtest/tests/c00004.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/c00004.vtc 2008-06-26 09:22:46 UTC (rev 2817) +++ trunk/varnish-cache/bin/varnishtest/tests/c00004.vtc 2008-06-26 09:45:29 UTC (rev 2818) @@ -7,15 +7,15 @@ server s1 { rxreq expect req.http.foobar == "1" - txresp -hdr "Vary: Foobar" -hdr "Snafu: 1" -hdr "Content-Length: 5" -body "1111\n" + txresp -hdr "Vary: Foobar" -hdr "Snafu: 1" -body "1111\n" rxreq expect req.http.foobar == "2" - txresp -hdr "Vary: Foobar" -hdr "Snafu: 2" -hdr "Content-Length: 5" -body "2222\n" + txresp -hdr "Vary: Foobar" -hdr "Snafu: 2" -body "2222\n" rxreq expect req.http.foobar == "3" - txresp -hdr "Vary: Foobar" -hdr "Snafu: 3" -hdr "Content-Length: 5" -body "3333\n" + txresp -hdr "Vary: Foobar" -hdr "Snafu: 3" -body "3333\n" rxreq - txresp -hdr "Vary: Foobar" -hdr "Snafu: 4" -hdr "Content-Length: 5" -body "4444\n" + txresp -hdr "Vary: Foobar" -hdr "Snafu: 4" -body "4444\n" } -start client c1 { Modified: trunk/varnish-cache/bin/varnishtest/tests/c00005.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/c00005.vtc 2008-06-26 09:22:46 UTC (rev 2817) +++ trunk/varnish-cache/bin/varnishtest/tests/c00005.vtc 2008-06-26 09:45:29 UTC (rev 2818) @@ -5,10 +5,10 @@ server s1 { rxreq expect req.url == "/" - txresp -hdr "Content-Length: 5" -body "1111\n" + txresp -body "1111\n" rxreq expect req.url == "foo" - txresp -hdr "Content-Length: 5" -body "2222\n" + txresp -body "2222\n" } -start varnish v1 -vcl+backend { Modified: trunk/varnish-cache/bin/varnishtest/tests/r00255.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/r00255.vtc 2008-06-26 09:22:46 UTC (rev 2817) +++ trunk/varnish-cache/bin/varnishtest/tests/r00255.vtc 2008-06-26 09:45:29 UTC (rev 2818) @@ -6,7 +6,6 @@ rxreq txresp \ -hdr "Date: Thu, 19 Jun 2008 21:14:49 GMT" \ - -hdr "Content-Length: 7" \ -hdr "Expires: Thu, 19 Jun 2008 21:14:49 GMT" \ -hdr "Last-Modified: Sun, 27 Nov 2005 05:41:47 GMT" \ -hdr "Cache-Control: max-age =0" \ Modified: trunk/varnish-cache/bin/varnishtest/vtc_http.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_http.c 2008-06-26 09:22:46 UTC (rev 2817) +++ trunk/varnish-cache/bin/varnishtest/vtc_http.c 2008-06-26 09:45:29 UTC (rev 2818) @@ -359,7 +359,6 @@ const char *status = "200"; const char *msg = "Ok"; const char *body = NULL; - int dohdr = 0; (void)cmd; CAST_OBJ_NOTNULL(hp, priv, HTTP_MAGIC); @@ -371,46 +370,42 @@ for(; *av != NULL; av++) { if (!strcmp(*av, "-proto")) { - AZ(dohdr); proto = av[1]; av++; - continue; - } - if (!strcmp(*av, "-status")) { - AZ(dohdr); + } else if (!strcmp(*av, "-status")) { status = av[1]; av++; - continue; - } - if (!strcmp(*av, "-msg")) { - AZ(dohdr); + } else if (!strcmp(*av, "-msg")) { msg = av[1]; av++; continue; - } - if (!strcmp(*av, "-body")) { - body = av[1]; - av++; - continue; - } + } else + break; + } + + vsb_printf(hp->vsb, "%s %s %s%s", proto, status, msg, nl); + + for(; *av != NULL; av++) { if (!strcmp(*av, "-hdr")) { - if (dohdr == 0) { - vsb_printf(hp->vsb, "%s %s %s%s", - proto, status, msg, nl); - dohdr = 1; - } vsb_printf(hp->vsb, "%s%s", av[1], nl); av++; - continue; - } - fprintf(stderr, "Unknown http txreq spec: %s\n", *av); - exit (1); + } else + break; } - if (dohdr == 0) { - vsb_printf(hp->vsb, "%s %s %s%s", - proto, status, msg, nl); - dohdr = 1; + for(; *av != NULL; av++) { + if (!strcmp(*av, "-body")) { + AZ(body); + body = av[1]; + av++; + } else + break; } + if (*av != NULL) { + fprintf(stderr, "Unknown http txresp spec: %s\n", *av); + exit (1); + } + if (body != NULL) + vsb_printf(hp->vsb, "Content-Length: %d%s", strlen(body), nl); vsb_cat(hp->vsb, nl); if (body != NULL) { vsb_cat(hp->vsb, body); @@ -456,7 +451,6 @@ const char *url = "/"; const char *proto = "HTTP/1.1"; const char *body = NULL; - int dohdr = 0; (void)cmd; CAST_OBJ_NOTNULL(hp, priv, HTTP_MAGIC); @@ -468,46 +462,39 @@ for(; *av != NULL; av++) { if (!strcmp(*av, "-url")) { - AZ(dohdr); url = av[1]; av++; - continue; - } - if (!strcmp(*av, "-proto")) { - AZ(dohdr); + } else if (!strcmp(*av, "-proto")) { proto = av[1]; av++; - continue; - } - if (!strcmp(*av, "-req")) { - AZ(dohdr); + } else if (!strcmp(*av, "-req")) { req = av[1]; av++; - continue; - } + } else + break; + } + vsb_printf(hp->vsb, "%s %s %s%s", req, url, proto, nl); + for(; *av != NULL; av++) { if (!strcmp(*av, "-hdr")) { - if (dohdr == 0) { - vsb_printf(hp->vsb, "%s %s %s%s", - req, url, proto, nl); - dohdr = 1; - } vsb_printf(hp->vsb, "%s%s", av[1], nl); av++; - continue; - } + } else + break; + } + for(; *av != NULL; av++) { if (!strcmp(*av, "-body")) { + AZ(body); body = av[1]; av++; - continue; - } + } else + break; + } + if (*av != NULL) { fprintf(stderr, "Unknown http txreq spec: %s\n", *av); exit (1); } - if (dohdr == 0) { - vsb_printf(hp->vsb, "%s %s %s%s", - req, url, proto, nl); - dohdr = 1; - } + if (body != NULL) + vsb_printf(hp->vsb, "Content-Length: %d%s", strlen(body), nl); vsb_cat(hp->vsb, nl); if (body != NULL) { vsb_cat(hp->vsb, body); From phk at projects.linpro.no Thu Jun 26 10:26:13 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Thu, 26 Jun 2008 12:26:13 +0200 (CEST) Subject: r2819 - trunk/varnish-cache/bin/varnishtest Message-ID: <20080626102613.104491ED157@projects.linpro.no> Author: phk Date: 2008-06-26 12:26:12 +0200 (Thu, 26 Jun 2008) New Revision: 2819 Modified: trunk/varnish-cache/bin/varnishtest/vtc.c Log: Better diagnostics Modified: trunk/varnish-cache/bin/varnishtest/vtc.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc.c 2008-06-26 09:45:29 UTC (rev 2818) +++ trunk/varnish-cache/bin/varnishtest/vtc.c 2008-06-26 10:26:12 UTC (rev 2819) @@ -133,6 +133,7 @@ *q++ = '"'; p++; } else { + fprintf(stderr, "Unterminated quoted string\n"); assert(*p != '\n'); *q++ = *p; } From phk at projects.linpro.no Thu Jun 26 10:27:45 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Thu, 26 Jun 2008 12:27:45 +0200 (CEST) Subject: r2820 - trunk/varnish-cache/bin/varnishtest Message-ID: <20080626102745.11EB61ED0A4@projects.linpro.no> Author: phk Date: 2008-06-26 12:27:44 +0200 (Thu, 26 Jun 2008) New Revision: 2820 Modified: trunk/varnish-cache/bin/varnishtest/vtc.c Log: Oops: only whine when we do have an unterminated strin Modified: trunk/varnish-cache/bin/varnishtest/vtc.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc.c 2008-06-26 10:26:12 UTC (rev 2819) +++ trunk/varnish-cache/bin/varnishtest/vtc.c 2008-06-26 10:27:44 UTC (rev 2820) @@ -133,7 +133,8 @@ *q++ = '"'; p++; } else { - fprintf(stderr, "Unterminated quoted string\n"); + if (*p == '\n') + fprintf(stderr, "Unterminated quoted string\n"); assert(*p != '\n'); *q++ = *p; } From phk at projects.linpro.no Thu Jun 26 10:28:49 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Thu, 26 Jun 2008 12:28:49 +0200 (CEST) Subject: r2821 - trunk/varnish-cache/bin/varnishtest Message-ID: <20080626102849.77A021EC0B3@projects.linpro.no> Author: phk Date: 2008-06-26 12:28:49 +0200 (Thu, 26 Jun 2008) New Revision: 2821 Modified: trunk/varnish-cache/bin/varnishtest/vtc_http.c Log: Also receive chunked encoding bodies. Modified: trunk/varnish-cache/bin/varnishtest/vtc_http.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_http.c 2008-06-26 10:27:44 UTC (rev 2820) +++ trunk/varnish-cache/bin/varnishtest/vtc_http.c 2008-06-26 10:28:49 UTC (rev 2821) @@ -55,6 +55,8 @@ int nrxbuf; char *rxbuf; + int prxbuf; + char *body; char *req[MAX_HDR]; char *resp[MAX_HDR]; @@ -252,30 +254,75 @@ /********************************************************************** + * Receive another character + */ + +static void +http_rxchar(struct http *hp, int n) +{ + int i; + struct pollfd pfd[1]; + + while (n > 0) { + pfd[0].fd = hp->fd; + pfd[0].events = POLLIN; + pfd[0].revents = 0; + i = poll(pfd, 1, hp->timeout); + assert(i > 0); + assert(hp->prxbuf < hp->nrxbuf); + i = read(hp->fd, hp->rxbuf + hp->prxbuf, n); + assert(i > 0); + hp->prxbuf += i; + hp->rxbuf[hp->prxbuf] = '\0'; + n -= i; + } +} + +/********************************************************************** * Swallow a HTTP message body */ static void -http_swallow_body(const struct http *hp, char * const *hh) +http_swallow_body(struct http *hp, char * const *hh) { - char *p, b[BUFSIZ + 1]; - int l, i; + char *p, *q; + int i, l; p = http_find_header(hh, "content-length"); - if (p == NULL) - return; - l = strtoul(p, NULL, 0); - while (l > 0) { - i = sizeof b - 1; - if (i > l) - i = l; - i = read(hp->fd, b, i); - assert(i > 0); - b[i] = '\0'; - vtc_dump(hp->vl, 4, "body", b); - l -= i; + if (p != NULL) { + l = strtoul(p, NULL, 0); + hp->body = q = hp->rxbuf + hp->prxbuf; + http_rxchar(hp, l); + vtc_dump(hp->vl, 4, "body", hp->body); } + p = http_find_header(hh, "transfer-encoding"); + if (p != NULL && !strcmp(p, "chunked")) { + hp->body = hp->rxbuf + hp->prxbuf; + while (1) { + l = hp->prxbuf; + do + http_rxchar(hp, 1); + while (hp->rxbuf[hp->prxbuf - 1] != '\n'); + vtc_dump(hp->vl, 4, "len", hp->rxbuf + l); + i = strtoul(hp->rxbuf + l, &q, 16); + assert(q != hp->rxbuf + l); + assert(*q == '\0' || vct_islws(*q)); + hp->prxbuf = l; + if (i > 0) { + http_rxchar(hp, i); + vtc_dump(hp->vl, 4, "chunk", hp->rxbuf + l); + } + l = hp->prxbuf; + http_rxchar(hp, 2); + assert(vct_iscrlf(hp->rxbuf[l])); + assert(vct_iscrlf(hp->rxbuf[l + 1])); + hp->prxbuf = l; + if (i == 0) + break; + } + vtc_dump(hp->vl, 4, "body", hp->body); + } } /********************************************************************** @@ -285,27 +332,15 @@ static void http_rxhdr(struct http *hp) { - int l, n, i; - struct pollfd pfd[1]; + int i; char *p; CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC); - hp->rxbuf = malloc(hp->nrxbuf); /* XXX */ - AN(hp->rxbuf); - l = 0; + hp->prxbuf = 0; + hp->body = NULL; while (1) { - pfd[0].fd = hp->fd; - pfd[0].events = POLLIN; - pfd[0].revents = 0; - i = poll(pfd, 1, hp->timeout); - assert(i > 0); - assert(l < hp->nrxbuf); - n = read(hp->fd, hp->rxbuf + l, 1); - assert(n == 1); - l += n; - hp->rxbuf[l] = '\0'; - assert(n > 0); - p = hp->rxbuf + l - 1; + http_rxchar(hp, 1); + p = hp->rxbuf + hp->prxbuf - 1; i = 0; for (i = 0; p > hp->rxbuf; p--) { if (*p != '\n') @@ -318,7 +353,7 @@ if (i == 2) break; } - vtc_dump(hp->vl, 4, NULL, hp->rxbuf); + vtc_dump(hp->vl, 4, "rxhdr", hp->rxbuf); } @@ -572,6 +607,8 @@ hp->timeout = 1000; hp->nrxbuf = 8192; hp->vsb = vsb_newauto(); + hp->rxbuf = malloc(hp->nrxbuf); /* XXX */ + AN(hp->rxbuf); AN(hp->vsb); s = strdup(spec); @@ -580,5 +617,6 @@ AN(s); parse_string(s, http_cmds, hp); vsb_delete(hp->vsb); + free(hp->rxbuf); free(hp); } From phk at projects.linpro.no Thu Jun 26 10:29:07 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Thu, 26 Jun 2008 12:29:07 +0200 (CEST) Subject: r2822 - trunk/varnish-cache/bin/varnishtest/tests Message-ID: <20080626102907.C60831EC04B@projects.linpro.no> Author: phk Date: 2008-06-26 12:29:07 +0200 (Thu, 26 Jun 2008) New Revision: 2822 Added: trunk/varnish-cache/bin/varnishtest/tests/e00000.vtc trunk/varnish-cache/bin/varnishtest/tests/e00001.vtc Log: The first two incomplete ESI testcases Added: trunk/varnish-cache/bin/varnishtest/tests/e00000.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/e00000.vtc (rev 0) +++ trunk/varnish-cache/bin/varnishtest/tests/e00000.vtc 2008-06-26 10:29:07 UTC (rev 2822) @@ -0,0 +1,26 @@ +# $Id$ + +test "ESI test with no ESI content" + + +server s1 { + rxreq + txresp -body { + -This is a test: Hello world + } +} -start + +varnish v1 -vcl+backend { + sub vcl_fetch { + esi; + } +} -start + +client c1 { + txreq + rxresp + expect resp.status == 200 + expect resp.http.content-length == 33 +} + +client c1 -run Added: trunk/varnish-cache/bin/varnishtest/tests/e00001.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/e00001.vtc (rev 0) +++ trunk/varnish-cache/bin/varnishtest/tests/e00001.vtc 2008-06-26 10:29:07 UTC (rev 2822) @@ -0,0 +1,28 @@ +# $Id$ + +test "ESI:remove" + + +server s1 { + rxreq + txresp -body { + + This is a test: Unseen University + + This is a test: Hello world + } +} -start + +varnish v1 -vcl+backend { + sub vcl_fetch { + esi; + } +} -start + +client c1 { + txreq + rxresp + expect resp.status == 200 +} + +client c1 -run From phk at projects.linpro.no Thu Jun 26 10:36:54 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Thu, 26 Jun 2008 12:36:54 +0200 (CEST) Subject: r2823 - trunk/varnish-cache/bin/varnishtest/tests Message-ID: <20080626103654.E1EBF1EC0B3@projects.linpro.no> Author: phk Date: 2008-06-26 12:36:54 +0200 (Thu, 26 Jun 2008) New Revision: 2823 Added: trunk/varnish-cache/bin/varnishtest/tests/e00002.vtc Log: Test ESI CDATA quoting Added: trunk/varnish-cache/bin/varnishtest/tests/e00002.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/e00002.vtc (rev 0) +++ trunk/varnish-cache/bin/varnishtest/tests/e00002.vtc 2008-06-26 10:36:54 UTC (rev 2823) @@ -0,0 +1,29 @@ +# $Id$ + +test "ESI CDATA" + + +server s1 { + rxreq + txresp -body { + + ]]> + This is a test: Unseen University + + This is a test: Hello world + } +} -start + +varnish v1 -vcl+backend { + sub vcl_fetch { + esi; + } +} -start + +client c1 { + txreq + rxresp + expect resp.status == 200 +} + +client c1 -run From phk at projects.linpro.no Thu Jun 26 10:39:23 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Thu, 26 Jun 2008 12:39:23 +0200 (CEST) Subject: r2824 - trunk/varnish-cache/bin/varnishtest/tests Message-ID: <20080626103923.D26011EC0B3@projects.linpro.no> Author: phk Date: 2008-06-26 12:39:23 +0200 (Thu, 26 Jun 2008) New Revision: 2824 Added: trunk/varnish-cache/bin/varnishtest/tests/e00003.vtc Log: ESI:include test case Added: trunk/varnish-cache/bin/varnishtest/tests/e00003.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/e00003.vtc (rev 0) +++ trunk/varnish-cache/bin/varnishtest/tests/e00003.vtc 2008-06-26 10:39:23 UTC (rev 2824) @@ -0,0 +1,32 @@ +# $Id$ + +test "ESI include" + + +server s1 { + rxreq + txresp -body { + Before include + + After include + } + rxreq + expect req.url == "/body" + txresp -body { + Included file + } +} -start + +varnish v1 -vcl+backend { + sub vcl_fetch { + esi; + } +} -start + +client c1 { + txreq + rxresp + expect resp.status == 200 +} + +client c1 -run From phk at projects.linpro.no Thu Jun 26 10:41:57 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Thu, 26 Jun 2008 12:41:57 +0200 (CEST) Subject: r2825 - trunk/varnish-cache/bin/varnishtest/tests Message-ID: <20080626104157.22AF51ED381@projects.linpro.no> Author: phk Date: 2008-06-26 12:41:56 +0200 (Thu, 26 Jun 2008) New Revision: 2825 Added: trunk/varnish-cache/bin/varnishtest/tests/e00004.vtc Log: Commented ESI:include Added: trunk/varnish-cache/bin/varnishtest/tests/e00004.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/e00004.vtc (rev 0) +++ trunk/varnish-cache/bin/varnishtest/tests/e00004.vtc 2008-06-26 10:41:56 UTC (rev 2825) @@ -0,0 +1,32 @@ +# $Id$ + +test "ESI commented include" + + +server s1 { + rxreq + txresp -body { + Before include + + After include + } + rxreq + expect req.url == "/body" + txresp -body { + Included file + } +} -start + +varnish v1 -vcl+backend { + sub vcl_fetch { + esi; + } +} -start + +client c1 { + txreq + rxresp + expect resp.status == 200 +} + +client c1 -run From phk at projects.linpro.no Thu Jun 26 11:15:22 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Thu, 26 Jun 2008 13:15:22 +0200 (CEST) Subject: r2826 - trunk/varnish-cache/bin/varnishd Message-ID: <20080626111522.F0EAA1ED1CC@projects.linpro.no> Author: phk Date: 2008-06-26 13:15:22 +0200 (Thu, 26 Jun 2008) New Revision: 2826 Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor.c trunk/varnish-cache/bin/varnishd/common.h trunk/varnish-cache/bin/varnishd/mgt_param.c Log: Allow the selector to be chosen by parameter "acceptor" Modified: trunk/varnish-cache/bin/varnishd/cache_acceptor.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_acceptor.c 2008-06-26 10:41:56 UTC (rev 2825) +++ trunk/varnish-cache/bin/varnishd/cache_acceptor.c 2008-06-26 11:15:22 UTC (rev 2826) @@ -309,8 +309,9 @@ (void)cli; (void)av; (void)priv; - /* XXX: Add selector mechanism at some point */ - vca_act = vca_acceptors[0]; + + if (vca_act == NULL) + vca_act = vca_acceptors[0]; AN(vca_act); AN(vca_act->name); @@ -333,3 +334,35 @@ CLI_AddFuncs(MASTER_CLI, vca_cmds); } + +void +VCA_tweak_acceptor(struct cli *cli, const char *arg) +{ + int i; + + if (arg == NULL) { + if (vca_act == NULL) + cli_out(cli, "default"); + else + cli_out(cli, "%s", vca_act->name); + + cli_out(cli, " ("); + for (i = 0; vca_acceptors[i] != NULL; i++) + cli_out(cli, "%s%s", i == 0 ? "" : ", ", + vca_acceptors[i]->name); + cli_out(cli, ")"); + return; + } + if (!strcmp(arg, "default")) { + vca_act = NULL; + return; + } + for (i = 0; vca_acceptors[i]->name; i++) { + if (!strcmp(arg, vca_acceptors[i]->name)) { + vca_act = vca_acceptors[i]; + return; + } + } + cli_out(cli, "Unknown acceptor"); + cli_result(cli, CLIS_PARAM); +} Modified: trunk/varnish-cache/bin/varnishd/common.h =================================================================== --- trunk/varnish-cache/bin/varnishd/common.h 2008-06-26 10:41:56 UTC (rev 2825) +++ trunk/varnish-cache/bin/varnishd/common.h 2008-06-26 11:15:22 UTC (rev 2826) @@ -32,6 +32,10 @@ struct cli; struct sockaddr; +/* cache_acceptor.c */ +void VCA_tweak_acceptor(struct cli *cli, const char *arg); + + /* shmlog.c */ void VSL_MgtInit(const char *fn, unsigned size); extern struct varnish_stats *VSL_stats; Modified: trunk/varnish-cache/bin/varnishd/mgt_param.c =================================================================== --- trunk/varnish-cache/bin/varnishd/mgt_param.c 2008-06-26 10:41:56 UTC (rev 2825) +++ trunk/varnish-cache/bin/varnishd/mgt_param.c 2008-06-26 11:15:22 UTC (rev 2826) @@ -405,6 +405,17 @@ /*--------------------------------------------------------------------*/ static void +tweak_acceptor(struct cli *cli, const struct parspec *par, const char *arg) +{ + + /* XXX should have tweak_generic_string */ + (void)par; + VCA_tweak_acceptor(cli, arg); +} + +/*--------------------------------------------------------------------*/ + +static void tweak_diag_bitmap(struct cli *cli, const struct parspec *par, const char *arg) { unsigned u; @@ -752,6 +763,10 @@ "SessionOpen shared memory record.\n", 0, "off", "bool" }, + { "acceptor", tweak_acceptor, NULL, 0, 0, + "Select the acceptor kernel interface.\n", + EXPERIMENTAL | MUST_RESTART, + "default", NULL }, { "diag_bitmap", tweak_diag_bitmap, 0, 0, 0, "Bitmap controlling diagnostics code:\n" " 0x00000001 - CNT_Session states.\n" From phk at projects.linpro.no Thu Jun 26 11:17:03 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Thu, 26 Jun 2008 13:17:03 +0200 (CEST) Subject: r2827 - trunk/varnish-cache/bin/varnishtest/tests Message-ID: <20080626111703.A048A1ED3DA@projects.linpro.no> Author: phk Date: 2008-06-26 13:17:03 +0200 (Thu, 26 Jun 2008) New Revision: 2827 Added: trunk/varnish-cache/bin/varnishtest/tests/b00009.vtc Log: Testcase for the poll acceptor Added: trunk/varnish-cache/bin/varnishtest/tests/b00009.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/b00009.vtc (rev 0) +++ trunk/varnish-cache/bin/varnishtest/tests/b00009.vtc 2008-06-26 11:17:03 UTC (rev 2827) @@ -0,0 +1,24 @@ +# $Id$ + +test "Check poll acceptor" + +varnish v1 -arg "-p acceptor=poll -b 127.0.0.1:9080" -start + +server s1 { + rxreq + txresp -hdr "Connection: close" -body "012345\n" +} + +server s1 -start + +client c1 { + txreq -url "/" + rxresp + expect resp.status == 200 +} + +client c1 -run + +server s1 -wait + +varnish v1 -stop From phk at projects.linpro.no Thu Jun 26 11:24:25 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Thu, 26 Jun 2008 13:24:25 +0200 (CEST) Subject: r2828 - trunk/varnish-cache/bin/varnishtest/tests Message-ID: <20080626112425.A92841EC0B3@projects.linpro.no> Author: phk Date: 2008-06-26 13:24:25 +0200 (Thu, 26 Jun 2008) New Revision: 2828 Added: trunk/varnish-cache/bin/varnishtest/tests/b00010.vtc Log: A testcase for the simple_list hasher Added: trunk/varnish-cache/bin/varnishtest/tests/b00010.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/b00010.vtc (rev 0) +++ trunk/varnish-cache/bin/varnishtest/tests/b00010.vtc 2008-06-26 11:24:25 UTC (rev 2828) @@ -0,0 +1,28 @@ +# $Id$ + +test "Check simple list hasher" + +varnish v1 -arg "-h simple_list -b 127.0.0.1:9080" -start + +server s1 { + rxreq + txresp -hdr "Connection: close" -body "012345\n" +} + +server s1 -start + +client c1 { + txreq -url "/" + rxresp + expect resp.status == 200 + txreq -url "/" + rxresp + expect resp.status == 200 + expect resp.http.x-varnish == "1002 1001" +} + +client c1 -run + +server s1 -wait + +varnish v1 -stop From phk at projects.linpro.no Thu Jun 26 11:36:07 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Thu, 26 Jun 2008 13:36:07 +0200 (CEST) Subject: r2829 - trunk/varnish-cache/bin/varnishtest/tests Message-ID: <20080626113607.C38BA1EC04B@projects.linpro.no> Author: phk Date: 2008-06-26 13:36:07 +0200 (Thu, 26 Jun 2008) New Revision: 2829 Added: trunk/varnish-cache/bin/varnishtest/tests/c00006.vtc Log: Test banning a URL Added: trunk/varnish-cache/bin/varnishtest/tests/c00006.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/c00006.vtc (rev 0) +++ trunk/varnish-cache/bin/varnishtest/tests/c00006.vtc 2008-06-26 11:36:07 UTC (rev 2829) @@ -0,0 +1,34 @@ +# $Id$ + +test "Test banning a url" + +server s1 { + rxreq + expect req.url == "/foo" + txresp -body "1111\n" + rxreq + expect req.url == "/foo" + txresp -body "11111\n" +} -start + +varnish v1 -vcl+backend { } -start + +client c1 { + txreq -url "/foo" + rxresp + expect resp.status == 200 + expect resp.http.content-length == 5 +} + +client c1 -run + +varnish v1 -cli "purge.url foo" + +client c1 { + txreq -url "/foo" + rxresp + expect resp.status == 200 + expect resp.http.content-length == 6 +} + +client c1 -run From phk at projects.linpro.no Thu Jun 26 11:36:46 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Thu, 26 Jun 2008 13:36:46 +0200 (CEST) Subject: r2830 - trunk/varnish-cache/bin/varnishtest/tests Message-ID: <20080626113646.A5B061ED1CC@projects.linpro.no> Author: phk Date: 2008-06-26 13:36:46 +0200 (Thu, 26 Jun 2008) New Revision: 2830 Added: trunk/varnish-cache/bin/varnishtest/tests/c00007.vtc Log: Test banning a hash Added: trunk/varnish-cache/bin/varnishtest/tests/c00007.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/c00007.vtc (rev 0) +++ trunk/varnish-cache/bin/varnishtest/tests/c00007.vtc 2008-06-26 11:36:46 UTC (rev 2830) @@ -0,0 +1,34 @@ +# $Id$ + +test "Test banning a hash" + +server s1 { + rxreq + expect req.url == "/foo" + txresp -body "1111\n" + rxreq + expect req.url == "/foo" + txresp -body "11111\n" +} -start + +varnish v1 -vcl+backend { } -start + +client c1 { + txreq -url "/foo" + rxresp + expect resp.status == 200 + expect resp.http.content-length == 5 +} + +client c1 -run + +varnish v1 -cli "purge.hash foo" + +client c1 { + txreq -url "/foo" + rxresp + expect resp.status == 200 + expect resp.http.content-length == 6 +} + +client c1 -run From phk at projects.linpro.no Thu Jun 26 11:49:59 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Thu, 26 Jun 2008 13:49:59 +0200 (CEST) Subject: r2831 - trunk/varnish-cache/bin/varnishtest/tests Message-ID: <20080626114959.19A101EC04B@projects.linpro.no> Author: phk Date: 2008-06-26 13:49:58 +0200 (Thu, 26 Jun 2008) New Revision: 2831 Added: trunk/varnish-cache/bin/varnishtest/tests/e00005.vtc Log: ESI include with relative src Added: trunk/varnish-cache/bin/varnishtest/tests/e00005.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/e00005.vtc (rev 0) +++ trunk/varnish-cache/bin/varnishtest/tests/e00005.vtc 2008-06-26 11:49:58 UTC (rev 2831) @@ -0,0 +1,33 @@ +# $Id$ + +test "ESI relative include" + + +server s1 { + rxreq + expect req.url == "/foo/bar" + txresp -body { + Before include + + After include + } + rxreq + expect req.url == "/foo/body" + txresp -body { + Included file + } +} -start + +varnish v1 -vcl+backend { + sub vcl_fetch { + esi; + } +} -start + +client c1 { + txreq -url /foo/bar + rxresp + expect resp.status == 200 +} + +client c1 -run From phk at projects.linpro.no Thu Jun 26 11:55:39 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Thu, 26 Jun 2008 13:55:39 +0200 (CEST) Subject: r2832 - trunk/varnish-cache/bin/varnishtest/tests Message-ID: <20080626115539.571B61EC0B3@projects.linpro.no> Author: phk Date: 2008-06-26 13:55:39 +0200 (Thu, 26 Jun 2008) New Revision: 2832 Added: trunk/varnish-cache/bin/varnishtest/tests/e00006.vtc Log: ESI testcase for including from different host (http://...) Added: trunk/varnish-cache/bin/varnishtest/tests/e00006.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/e00006.vtc (rev 0) +++ trunk/varnish-cache/bin/varnishtest/tests/e00006.vtc 2008-06-26 11:55:39 UTC (rev 2832) @@ -0,0 +1,44 @@ +# $Id$ + +test "ESI include with http://" + + +server s1 { + rxreq + expect req.url == "/foo/bar" + txresp -body { + Before include + + After include + } +} -start + + +server s2 -listen 127.0.0.1:9180 { + rxreq + expect req.url == "/body" + txresp -body { + Included file + } +} -start + +varnish v1 -vcl+backend { + sub vcl_recv { + if (req.http.host == "bozz") { + set req.backend = s2; + } else { + set req.backend = s1; + } + } + sub vcl_fetch { + esi; + } +} -start + +client c1 { + txreq -url /foo/bar -hdr "Host: froboz" + rxresp + expect resp.status == 200 +} + +client c1 -run From phk at projects.linpro.no Thu Jun 26 12:12:29 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Thu, 26 Jun 2008 14:12:29 +0200 (CEST) Subject: r2833 - trunk/varnish-cache/bin/varnishtest/tests Message-ID: <20080626121229.83EBB1ED1CC@projects.linpro.no> Author: phk Date: 2008-06-26 14:12:29 +0200 (Thu, 26 Jun 2008) New Revision: 2833 Added: trunk/varnish-cache/bin/varnishtest/tests/c00008.vtc Log: Test If-Modified-Since Added: trunk/varnish-cache/bin/varnishtest/tests/c00008.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/c00008.vtc (rev 0) +++ trunk/varnish-cache/bin/varnishtest/tests/c00008.vtc 2008-06-26 12:12:29 UTC (rev 2833) @@ -0,0 +1,34 @@ +# $Id$ + +test "Test If-Modified-Since" + +server s1 { + rxreq + expect req.url == "/foo" + txresp -hdr "Last-Modified: Thu, 26 Jun 2008 12:00:01 GMT" -body "11111\n" +} -start + +varnish v1 -vcl+backend { } -start + +client c1 { + txreq -url "/foo" + rxresp + expect resp.status == 200 + expect resp.http.content-length == 6 + + txreq -url "/foo" -hdr "If-Modified-Since: Thu, 26 Jun 2008 12:00:00 GMT" + rxresp + expect resp.status == 200 + + txreq -url "/foo" -hdr "If-Modified-Since: Thu, 26 Jun 2008 12:00:01 GMT" + rxresp + expect resp.status == 304 + + txreq -url "/foo" -hdr "If-Modified-Since: Thu, 26 Jun 2008 12:00:02 GMT" + rxresp + expect resp.status == 304 +} + +client c1 -run + +client c1 -run From phk at projects.linpro.no Thu Jun 26 12:32:06 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Thu, 26 Jun 2008 14:32:06 +0200 (CEST) Subject: r2834 - trunk/varnish-cache/bin/varnishtest/tests Message-ID: <20080626123206.E67E21EC0B3@projects.linpro.no> Author: phk Date: 2008-06-26 14:32:06 +0200 (Thu, 26 Jun 2008) New Revision: 2834 Added: trunk/varnish-cache/bin/varnishtest/tests/s00000.vtc trunk/varnish-cache/bin/varnishtest/tests/s00001.vtc Modified: trunk/varnish-cache/bin/varnishtest/tests/README Log: Two slow testcases to test object expiry Modified: trunk/varnish-cache/bin/varnishtest/tests/README =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/README 2008-06-26 12:12:29 UTC (rev 2833) +++ trunk/varnish-cache/bin/varnishtest/tests/README 2008-06-26 12:32:06 UTC (rev 2834) @@ -19,5 +19,5 @@ id ~ [b] --> Basic functionality tests id ~ [c] --> Complex functionality tests id ~ [e] --> ESI tests - id ~ [r] --> Regression tests. - id ~ [t] --> Ticket regression tests, number same as ticket. + id ~ [r] --> Regression tests, same number as ticket + id ~ [s] --> Slow tests, expiry, grace etc. Added: trunk/varnish-cache/bin/varnishtest/tests/s00000.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/s00000.vtc (rev 0) +++ trunk/varnish-cache/bin/varnishtest/tests/s00000.vtc 2008-06-26 12:32:06 UTC (rev 2834) @@ -0,0 +1,33 @@ +# $Id$ + +test "Simple expiry test" + +server s1 { + rxreq + expect req.url == "/" + txresp -hdr "Cache-control: max-age = 1" -body "1111\n" + delay 3 + rxreq + expect req.url == "/" + txresp -hdr "Cache-control: max-age = 1" -body "22222\n" +} -start + +varnish v1 -vcl+backend { } -start + +client c1 { + txreq -url "/" + rxresp + expect resp.http.content-length == 5 + expect resp.http.x-varnish == "1001" + expect resp.status == 200 +} -run + +delay 3 + +client c2 { + txreq -url "/" + rxresp + expect resp.status == 200 + expect resp.http.x-varnish == "1002" + expect resp.http.content-length == 6 +} -run Added: trunk/varnish-cache/bin/varnishtest/tests/s00001.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/s00001.vtc (rev 0) +++ trunk/varnish-cache/bin/varnishtest/tests/s00001.vtc 2008-06-26 12:32:06 UTC (rev 2834) @@ -0,0 +1,33 @@ +# $Id$ + +test "Simple expiry test (fully reaped object)" + +server s1 { + rxreq + expect req.url == "/" + txresp -hdr "Cache-control: max-age = 1" -body "1111\n" + delay 20 + rxreq + expect req.url == "/" + txresp -hdr "Cache-control: max-age = 1" -body "22222\n" +} -start + +varnish v1 -vcl+backend { } -start + +client c1 { + txreq -url "/" + rxresp + expect resp.http.content-length == 5 + expect resp.http.x-varnish == "1001" + expect resp.status == 200 +} -run + +delay 20 + +client c2 { + txreq -url "/" + rxresp + expect resp.status == 200 + expect resp.http.x-varnish == "1002" + expect resp.http.content-length == 6 +} -run From phk at projects.linpro.no Thu Jun 26 12:41:51 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Thu, 26 Jun 2008 14:41:51 +0200 (CEST) Subject: r2835 - trunk/varnish-cache/bin/varnishtest/tests Message-ID: <20080626124151.6771F1ED1CC@projects.linpro.no> Author: phk Date: 2008-06-26 14:41:51 +0200 (Thu, 26 Jun 2008) New Revision: 2835 Added: trunk/varnish-cache/bin/varnishtest/tests/b00011.vtc Log: Test for HTTP/1.0 (EOF) transmission Added: trunk/varnish-cache/bin/varnishtest/tests/b00011.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/b00011.vtc (rev 0) +++ trunk/varnish-cache/bin/varnishtest/tests/b00011.vtc 2008-06-26 12:41:51 UTC (rev 2835) @@ -0,0 +1,24 @@ +# $Id$ + +test "Check HTTP/1.0 EOF transmission" + +varnish v1 -arg "-h simple_list -b 127.0.0.1:9080" -start + +server s1 { + rxreq + txresp -hdr "Connection: close" + send "Body line 1\n" + send "Body line 2\n" + send "Body line 3\n" +} + +server s1 -start + +client c1 { + txreq -url "/" + rxresp + expect resp.status == 200 + expect resp.http.content-length == 36 +} + +client c1 -run From phk at projects.linpro.no Thu Jun 26 21:07:07 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Thu, 26 Jun 2008 23:07:07 +0200 (CEST) Subject: r2836 - trunk/varnish-cache/bin/varnishd Message-ID: <20080626210707.9A2CD1EC236@projects.linpro.no> Author: phk Date: 2008-06-26 23:07:07 +0200 (Thu, 26 Jun 2008) New Revision: 2836 Modified: trunk/varnish-cache/bin/varnishd/cache.h trunk/varnish-cache/bin/varnishd/cache_fetch.c trunk/varnish-cache/bin/varnishd/cache_main.c Log: Add an undocumented debug facility that allows us to force a received object to be fragmented into smaller bits are out command. This is necessary to be able to write sensible testcases for the abilities of the ESI parsing code to navigate storage boundaries. Modified: trunk/varnish-cache/bin/varnishd/cache.h =================================================================== --- trunk/varnish-cache/bin/varnishd/cache.h 2008-06-26 12:41:51 UTC (rev 2835) +++ trunk/varnish-cache/bin/varnishd/cache.h 2008-06-26 21:07:07 UTC (rev 2836) @@ -454,6 +454,7 @@ /* cache_fetch.c */ int Fetch(struct sess *sp); int FetchReqBody(struct sess *sp); +void Fetch_Init(void); /* cache_hash.c */ void HSH_Prealloc(struct sess *sp); Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_fetch.c 2008-06-26 12:41:51 UTC (rev 2835) +++ trunk/varnish-cache/bin/varnishd/cache_fetch.c 2008-06-26 21:07:07 UTC (rev 2836) @@ -40,7 +40,11 @@ #include "shmlog.h" #include "cache.h" #include "stevedore.h" +#include "cli.h" +#include "cli_priv.h" +static unsigned fetchfrag; + /*--------------------------------------------------------------------*/ static int @@ -199,6 +203,16 @@ /*--------------------------------------------------------------------*/ +static void +dump_st(struct sess *sp, struct storage *st) +{ + txt t; + + t.b = (void*)st->ptr; + t.e = (void*)(st->ptr + st->len); + WSLR(sp->wrk, SLT_Debug, sp->fd, t); +} + static int fetch_eof(struct sess *sp, struct http_conn *htc) { @@ -212,10 +226,14 @@ st = NULL; while (1) { if (v == 0) { + if (st != NULL && fetchfrag > 0) + dump_st(sp, st); st = STV_alloc(sp, params->fetch_chunksize * 1024); VTAILQ_INSERT_TAIL(&sp->obj->store, st, list); p = st->ptr + st->len; v = st->space - st->len; + if (v > fetchfrag) + v = fetchfrag; } AN(p); AN(st); @@ -229,6 +247,8 @@ st->len += i; sp->obj->len += i; } + if (st != NULL && fetchfrag > 0) + dump_st(sp, st); if (st->len == 0) { VTAILQ_REMOVE(&sp->obj->store, st, list); @@ -442,3 +462,34 @@ return (0); } + +/*-------------------------------------------------------------------- + * Debugging aids + */ + +static void +debug_fragfetch(struct cli *cli, const char * const *av, void *priv) +{ + (void)priv; + (void)cli; + fetchfrag = strtoul(av[2], NULL, 0); +} + +static struct cli_proto debug_cmds[] = { + { "debug.fragfetch", "debug.fragfetch", + "\tEnable fetch fragmentation\n", 1, 1, debug_fragfetch }, + { NULL } +}; + +/*-------------------------------------------------------------------- + * + */ + +void +Fetch_Init(void) +{ + + CLI_AddFuncs(DEBUG_CLI, debug_cmds); +} + + Modified: trunk/varnish-cache/bin/varnishd/cache_main.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_main.c 2008-06-26 12:41:51 UTC (rev 2835) +++ trunk/varnish-cache/bin/varnishd/cache_main.c 2008-06-26 21:07:07 UTC (rev 2836) @@ -72,6 +72,7 @@ THR_Name("cache-main"); CLI_Init(); + Fetch_Init(); CNT_Init(); VCL_Init(); From phk at projects.linpro.no Thu Jun 26 21:09:32 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Thu, 26 Jun 2008 23:09:32 +0200 (CEST) Subject: r2837 - trunk/varnish-cache/bin/varnishtest/tests Message-ID: <20080626210932.BCB9C1EC220@projects.linpro.no> Author: phk Date: 2008-06-26 23:09:32 +0200 (Thu, 26 Jun 2008) New Revision: 2837 Added: trunk/varnish-cache/bin/varnishtest/tests/e00007.vtc Log: Testcase for ESI fragmented storage parsing Added: trunk/varnish-cache/bin/varnishtest/tests/e00007.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/e00007.vtc (rev 0) +++ trunk/varnish-cache/bin/varnishtest/tests/e00007.vtc 2008-06-26 21:09:32 UTC (rev 2837) @@ -0,0 +1,32 @@ +# $Id$ + +test "ESI spanning storage bits" + + +server s1 { + rxreq + expect req.url == "/foo/bar" + txresp -hdr "Connection: close" + send { + This is before the test + + + This is a test: Unseen University + + This is a test: Hello world + } +} -start + +varnish v1 -vcl+backend { + sub vcl_fetch { + esi; + } +} -start -cli "debug.fragfetch 32" + +client c1 { + txreq -url /foo/bar -hdr "Host: froboz" + rxresp + expect resp.status == 200 +} + +client c1 -run From phk at projects.linpro.no Thu Jun 26 21:42:06 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Thu, 26 Jun 2008 23:42:06 +0200 (CEST) Subject: r2838 - trunk/varnish-cache/bin/varnishd Message-ID: <20080626214206.3FD991EC0B3@projects.linpro.no> Author: phk Date: 2008-06-26 23:42:05 +0200 (Thu, 26 Jun 2008) New Revision: 2838 Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c Log: Oops, only enable $evilhack when we want to. Modified: trunk/varnish-cache/bin/varnishd/cache_fetch.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_fetch.c 2008-06-26 21:09:32 UTC (rev 2837) +++ trunk/varnish-cache/bin/varnishd/cache_fetch.c 2008-06-26 21:42:05 UTC (rev 2838) @@ -232,7 +232,7 @@ VTAILQ_INSERT_TAIL(&sp->obj->store, st, list); p = st->ptr + st->len; v = st->space - st->len; - if (v > fetchfrag) + if (fetchfrag > 0 && v > fetchfrag) v = fetchfrag; } AN(p); From phk at projects.linpro.no Thu Jun 26 22:12:23 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Fri, 27 Jun 2008 00:12:23 +0200 (CEST) Subject: r2839 - trunk/varnish-cache/bin/varnishtest Message-ID: <20080626221223.9ADBE1ED1AD@projects.linpro.no> Author: phk Date: 2008-06-27 00:12:23 +0200 (Fri, 27 Jun 2008) New Revision: 2839 Modified: trunk/varnish-cache/bin/varnishtest/vtc_server.c Log: Close servers TCP connection more gracefully for EOF handling. Modified: trunk/varnish-cache/bin/varnishtest/vtc_server.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_server.c 2008-06-26 21:42:05 UTC (rev 2838) +++ trunk/varnish-cache/bin/varnishtest/vtc_server.c 2008-06-26 22:12:23 UTC (rev 2839) @@ -80,6 +80,7 @@ struct sockaddr_storage addr_s; struct sockaddr *addr; socklen_t l; + char c; CAST_OBJ_NOTNULL(s, priv, SERVER_MAGIC); @@ -96,6 +97,11 @@ fd = accept(s->sock, addr, &l); vtc_log(vl, 3, "Accepted socket fd is %d", fd); http_process(vl, s->spec, fd, 0); + vtc_log(vl, 3, "shutting fd %d", fd); + AZ(shutdown(fd, SHUT_WR)); + while (1 == read(fd, &c, 1)) + continue; + vtc_log(vl, 3, "closing fd %d", fd); AZ(close(fd)); } vtc_log(vl, 2, "Ending"); From phk at projects.linpro.no Thu Jun 26 22:14:02 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Fri, 27 Jun 2008 00:14:02 +0200 (CEST) Subject: r2840 - trunk/varnish-cache/bin/varnishtest Message-ID: <20080626221402.3946C1EC220@projects.linpro.no> Author: phk Date: 2008-06-27 00:14:02 +0200 (Fri, 27 Jun 2008) New Revision: 2840 Modified: trunk/varnish-cache/bin/varnishtest/vtc.c Log: Drop a _.ok file if we are all done. Modified: trunk/varnish-cache/bin/varnishtest/vtc.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc.c 2008-06-26 22:12:23 UTC (rev 2839) +++ trunk/varnish-cache/bin/varnishtest/vtc.c 2008-06-26 22:14:02 UTC (rev 2840) @@ -308,6 +308,7 @@ main(int argc, char * const *argv) { int ch; + FILE *fok; setbuf(stdout, NULL); setbuf(stderr, NULL); @@ -330,5 +331,8 @@ argv += optind; for (ch = 0; ch < argc; ch++) exec_file(argv[ch]); + fok = fopen("_.ok", "w"); + if (fok != NULL) + fclose(fok); return (0); } From phk at projects.linpro.no Thu Jun 26 22:27:37 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Fri, 27 Jun 2008 00:27:37 +0200 (CEST) Subject: r2841 - in trunk/varnish-cache/bin/varnishtest: . tests Message-ID: <20080626222737.E43F71EC0B3@projects.linpro.no> Author: phk Date: 2008-06-27 00:27:37 +0200 (Fri, 27 Jun 2008) New Revision: 2841 Modified: trunk/varnish-cache/bin/varnishtest/tests/b00007.vtc trunk/varnish-cache/bin/varnishtest/vtc_server.c Log: Use shutdown for both directions, TCP works correctly. Modified: trunk/varnish-cache/bin/varnishtest/tests/b00007.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/b00007.vtc 2008-06-26 22:14:02 UTC (rev 2840) +++ trunk/varnish-cache/bin/varnishtest/tests/b00007.vtc 2008-06-26 22:27:37 UTC (rev 2841) @@ -37,7 +37,3 @@ } client c1 -run - -server s1 -wait - -varnish v1 -stop Modified: trunk/varnish-cache/bin/varnishtest/vtc_server.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_server.c 2008-06-26 22:14:02 UTC (rev 2840) +++ trunk/varnish-cache/bin/varnishtest/vtc_server.c 2008-06-26 22:27:37 UTC (rev 2841) @@ -80,9 +80,7 @@ struct sockaddr_storage addr_s; struct sockaddr *addr; socklen_t l; - char c; - CAST_OBJ_NOTNULL(s, priv, SERVER_MAGIC); assert(s->sock >= 0); @@ -99,10 +97,7 @@ http_process(vl, s->spec, fd, 0); vtc_log(vl, 3, "shutting fd %d", fd); AZ(shutdown(fd, SHUT_WR)); - while (1 == read(fd, &c, 1)) - continue; - vtc_log(vl, 3, "closing fd %d", fd); - AZ(close(fd)); + AZ(shutdown(fd, SHUT_RD)); } vtc_log(vl, 2, "Ending"); return (NULL); @@ -176,7 +171,7 @@ vtc_log(s->vl, 2, "Waiting for server"); AZ(pthread_join(s->tp, &res)); if (res != NULL) { - vtc_log(s->vl, 0, "Server returned \"%s\"", + vtc_log(s->vl, 0, "Server returned \"%p\"", (char *)res); exit (1); } From phk at projects.linpro.no Thu Jun 26 22:45:49 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Fri, 27 Jun 2008 00:45:49 +0200 (CEST) Subject: r2842 - trunk/varnish-cache/bin/varnishtest/tests Message-ID: <20080626224549.CB7C31EC236@projects.linpro.no> Author: phk Date: 2008-06-27 00:45:49 +0200 (Fri, 27 Jun 2008) New Revision: 2842 Modified: trunk/varnish-cache/bin/varnishtest/tests/e00003.vtc trunk/varnish-cache/bin/varnishtest/tests/e00004.vtc trunk/varnish-cache/bin/varnishtest/tests/e00005.vtc trunk/varnish-cache/bin/varnishtest/tests/e00006.vtc Log: Fix ESI:include tags: they have to be empty. Modified: trunk/varnish-cache/bin/varnishtest/tests/e00003.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/e00003.vtc 2008-06-26 22:27:37 UTC (rev 2841) +++ trunk/varnish-cache/bin/varnishtest/tests/e00003.vtc 2008-06-26 22:45:49 UTC (rev 2842) @@ -7,7 +7,7 @@ rxreq txresp -body { Before include - + After include } rxreq Modified: trunk/varnish-cache/bin/varnishtest/tests/e00004.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/e00004.vtc 2008-06-26 22:27:37 UTC (rev 2841) +++ trunk/varnish-cache/bin/varnishtest/tests/e00004.vtc 2008-06-26 22:45:49 UTC (rev 2842) @@ -7,7 +7,7 @@ rxreq txresp -body { Before include - + After include } rxreq Modified: trunk/varnish-cache/bin/varnishtest/tests/e00005.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/e00005.vtc 2008-06-26 22:27:37 UTC (rev 2841) +++ trunk/varnish-cache/bin/varnishtest/tests/e00005.vtc 2008-06-26 22:45:49 UTC (rev 2842) @@ -8,7 +8,7 @@ expect req.url == "/foo/bar" txresp -body { Before include - + After include } rxreq Modified: trunk/varnish-cache/bin/varnishtest/tests/e00006.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/e00006.vtc 2008-06-26 22:27:37 UTC (rev 2841) +++ trunk/varnish-cache/bin/varnishtest/tests/e00006.vtc 2008-06-26 22:45:49 UTC (rev 2842) @@ -8,7 +8,7 @@ expect req.url == "/foo/bar" txresp -body { Before include - + After include } } -start From phk at projects.linpro.no Thu Jun 26 22:55:25 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Fri, 27 Jun 2008 00:55:25 +0200 (CEST) Subject: r2843 - trunk/varnish-cache/bin/varnishtest Message-ID: <20080626225525.815DD1EC220@projects.linpro.no> Author: phk Date: 2008-06-27 00:55:25 +0200 (Fri, 27 Jun 2008) New Revision: 2843 Modified: trunk/varnish-cache/bin/varnishtest/vtc_server.c trunk/varnish-cache/bin/varnishtest/vtc_varnish.c Log: Be even more careful with server fd's Modified: trunk/varnish-cache/bin/varnishtest/vtc_server.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_server.c 2008-06-26 22:45:49 UTC (rev 2842) +++ trunk/varnish-cache/bin/varnishtest/vtc_server.c 2008-06-26 22:55:25 UTC (rev 2843) @@ -97,7 +97,7 @@ http_process(vl, s->spec, fd, 0); vtc_log(vl, 3, "shutting fd %d", fd); AZ(shutdown(fd, SHUT_WR)); - AZ(shutdown(fd, SHUT_RD)); + AZ(close(fd)); } vtc_log(vl, 2, "Ending"); return (NULL); Modified: trunk/varnish-cache/bin/varnishtest/vtc_varnish.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_varnish.c 2008-06-26 22:45:49 UTC (rev 2842) +++ trunk/varnish-cache/bin/varnishtest/vtc_varnish.c 2008-06-26 22:55:25 UTC (rev 2843) @@ -205,6 +205,8 @@ AZ(close(v->fds[1])); AZ(close(v->fds[2])); AZ(close(v->fds[3])); + for (i = 3; i Author: phk Date: 2008-06-27 12:15:55 +0200 (Fri, 27 Jun 2008) New Revision: 2844 Added: trunk/varnish-cache/bin/varnishtest/tests/v00000.vtc Modified: trunk/varnish-cache/bin/varnishtest/tests/README Log: Add testcase for VCL/VRT obj.ttl and obj.grace Modified: trunk/varnish-cache/bin/varnishtest/tests/README =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/README 2008-06-26 22:55:25 UTC (rev 2843) +++ trunk/varnish-cache/bin/varnishtest/tests/README 2008-06-27 10:15:55 UTC (rev 2844) @@ -21,3 +21,4 @@ id ~ [e] --> ESI tests id ~ [r] --> Regression tests, same number as ticket id ~ [s] --> Slow tests, expiry, grace etc. + id ~ [v] --> VCL tests: execute VRT functions Added: trunk/varnish-cache/bin/varnishtest/tests/v00000.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/v00000.vtc (rev 0) +++ trunk/varnish-cache/bin/varnishtest/tests/v00000.vtc 2008-06-27 10:15:55 UTC (rev 2844) @@ -0,0 +1,30 @@ +# $Id$ + +test "VCL/VRT: obj.ttl and obj.grace" + + +server s1 { + rxreq + txresp -hdr "Connection: close" -body "012345\n" +} + +server s1 -start + +varnish v1 -vcl+backend { + sub vcl_fetch { + set obj.ttl += 1 m; + set obj.grace += 1 m; + } +} -start + +client c1 { + txreq -url "/" + rxresp + expect resp.status == 200 +} + +client c1 -run + +server s1 -wait + +varnish v1 -stop From phk at projects.linpro.no Fri Jun 27 10:37:24 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Fri, 27 Jun 2008 12:37:24 +0200 (CEST) Subject: r2845 - trunk/varnish-cache/bin/varnishtest/tests Message-ID: <20080627103724.64F391EC115@projects.linpro.no> Author: phk Date: 2008-06-27 12:37:23 +0200 (Fri, 27 Jun 2008) New Revision: 2845 Modified: trunk/varnish-cache/bin/varnishtest/tests/v00000.vtc Log: add req.grace handling as well Modified: trunk/varnish-cache/bin/varnishtest/tests/v00000.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/v00000.vtc 2008-06-27 10:15:55 UTC (rev 2844) +++ trunk/varnish-cache/bin/varnishtest/tests/v00000.vtc 2008-06-27 10:37:23 UTC (rev 2845) @@ -1,6 +1,6 @@ # $Id$ -test "VCL/VRT: obj.ttl and obj.grace" +test "VCL/VRT: req.grace, obj.ttl and obj.grace" server s1 { @@ -11,9 +11,12 @@ server s1 -start varnish v1 -vcl+backend { + sub vcl_recv { + set req.grace += 1 s; + } sub vcl_fetch { set obj.ttl += 1 m; - set obj.grace += 1 m; + set obj.grace += 1 h; } } -start From phk at projects.linpro.no Fri Jun 27 11:04:55 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Fri, 27 Jun 2008 13:04:55 +0200 (CEST) Subject: r2846 - trunk/varnish-cache/bin/varnishtest/tests Message-ID: <20080627110455.1615C1EC115@projects.linpro.no> Author: phk Date: 2008-06-27 13:04:54 +0200 (Fri, 27 Jun 2008) New Revision: 2846 Added: trunk/varnish-cache/bin/varnishtest/tests/v00001.vtc Log: VCL/VRT testcase for proto/request/url/response fields. Added: trunk/varnish-cache/bin/varnishtest/tests/v00001.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/v00001.vtc (rev 0) +++ trunk/varnish-cache/bin/varnishtest/tests/v00001.vtc 2008-06-27 11:04:54 UTC (rev 2846) @@ -0,0 +1,57 @@ +# $Id$ + +test "VCL/VRT: misc" + + +server s1 { + rxreq + txresp -hdr "Connection: close" -body "012345\n" +} + +server s1 -start + +varnish v1 -vcl+backend { + sub vcl_recv { + set req.http.foobar = + req.url + req.request + req.proto; + set req.url = "/"; + set req.proto = "HTTP/1.2"; + set req.request = "GET"; + } + sub vcl_miss { + set bereq.http.foobar = + bereq.url + bereq.proto; + set bereq.url = "/"; + set bereq.proto = "HTTP/1.2"; + set bereq.request = "GET"; + } + sub vcl_fetch { + set obj.http.foobar = + obj.proto obj.response; + set obj.proto = "HTTP/1.2"; + set obj.response = "For circular files"; + } + sub vcl_deliver { + set resp.proto = "HTTP/1.2"; + set resp.response = "Naah, lets fail it"; + set resp.http.foobar = + resp.proto + resp.status; + error 904 "because I say so:"; + } +} -start + +client c1 { + txreq -url "/" + rxresp + expect resp.status == 904 +} + +client c1 -run + +server s1 -wait + +varnish v1 -stop From phk at projects.linpro.no Fri Jun 27 11:16:58 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Fri, 27 Jun 2008 13:16:58 +0200 (CEST) Subject: r2847 - trunk/varnish-cache/bin/varnishtest/tests Message-ID: <20080627111658.BB6191EC0FD@projects.linpro.no> Author: phk Date: 2008-06-27 13:16:58 +0200 (Fri, 27 Jun 2008) New Revision: 2847 Modified: trunk/varnish-cache/bin/varnishtest/tests/v00001.vtc Log: polish Modified: trunk/varnish-cache/bin/varnishtest/tests/v00001.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/v00001.vtc 2008-06-27 11:04:54 UTC (rev 2846) +++ trunk/varnish-cache/bin/varnishtest/tests/v00001.vtc 2008-06-27 11:16:58 UTC (rev 2847) @@ -1,6 +1,6 @@ # $Id$ -test "VCL/VRT: misc" +test "VCL/VRT: url/request/proto/response/status" server s1 { @@ -30,9 +30,10 @@ } sub vcl_fetch { set obj.http.foobar = - obj.proto obj.response; + obj.proto obj.response obj.status; set obj.proto = "HTTP/1.2"; set obj.response = "For circular files"; + set obj.status = 903; } sub vcl_deliver { set resp.proto = "HTTP/1.2"; From phk at projects.linpro.no Fri Jun 27 11:18:00 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Fri, 27 Jun 2008 13:18:00 +0200 (CEST) Subject: r2848 - trunk/varnish-cache/bin/varnishd Message-ID: <20080627111800.730A71ED1C3@projects.linpro.no> Author: phk Date: 2008-06-27 13:18:00 +0200 (Fri, 27 Jun 2008) New Revision: 2848 Modified: trunk/varnish-cache/bin/varnishd/cache_vrt.c Log: Get "line1" request/reponse fields under control. Modified: trunk/varnish-cache/bin/varnishd/cache_vrt.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_vrt.c 2008-06-27 11:16:58 UTC (rev 2847) +++ trunk/varnish-cache/bin/varnishd/cache_vrt.c 2008-06-27 11:18:00 UTC (rev 2848) @@ -210,6 +210,14 @@ vrt_do_string(sp->wrk, sp->fd, \ http, fld, #obj "." #hdr, p, ap); \ va_end(ap); \ +} \ + \ +const char * \ +VRT_r_##obj##_##hdr(const struct sess *sp) \ +{ \ + CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); \ + CHECK_OBJ_NOTNULL(http, HTTP_MAGIC); \ + return (http->hd[fld].b); \ } VRT_DO_HDR(req, request, sp->http, HTTP_HDR_REQ) @@ -223,6 +231,10 @@ VRT_DO_HDR(resp, proto, sp->http, HTTP_HDR_PROTO) VRT_DO_HDR(resp, response, sp->http, HTTP_HDR_RESPONSE) +/*--------------------------------------------------------------------*/ + +/* XXX: review this */ + void VRT_l_obj_status(const struct sess *sp, int num) { @@ -262,6 +274,14 @@ http_SetH(sp->http, HTTP_HDR_STATUS, p); } +int +VRT_r_resp_status(const struct sess *sp) +{ + CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC); + return (atoi(sp->obj->http->hd[HTTP_HDR_STATUS].b)); +} + /*--------------------------------------------------------------------*/ void @@ -408,21 +428,6 @@ /*--------------------------------------------------------------------*/ -#define VREQ(n1, n2) \ -const char * \ -VRT_r_req_##n1(const struct sess *sp) \ -{ \ - CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); \ - CHECK_OBJ_NOTNULL(sp->http, HTTP_MAGIC); \ - return (sp->http->hd[n2].b); \ -} - -VREQ(request, HTTP_HDR_REQ) -VREQ(url, HTTP_HDR_URL) -VREQ(proto, HTTP_HDR_PROTO) - -/*--------------------------------------------------------------------*/ - int VRT_r_req_restarts(const struct sess *sp) { @@ -456,32 +461,6 @@ /*--------------------------------------------------------------------*/ -const char * -VRT_r_resp_proto(const struct sess *sp) -{ - CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); - CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC); - return (sp->obj->http->hd[HTTP_HDR_PROTO].b); -} - -const char * -VRT_r_resp_response(const struct sess *sp) -{ - CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); - CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC); - return (sp->obj->http->hd[HTTP_HDR_RESPONSE].b); -} - -int -VRT_r_resp_status(const struct sess *sp) -{ - CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); - CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC); - return (atoi(sp->obj->http->hd[HTTP_HDR_STATUS].b)); -} - -/*--------------------------------------------------------------------*/ - struct sockaddr * VRT_r_client_ip(const struct sess *sp) { From phk at projects.linpro.no Fri Jun 27 11:33:30 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Fri, 27 Jun 2008 13:33:30 +0200 (CEST) Subject: r2849 - trunk/varnish-cache/bin/varnishtest/tests Message-ID: <20080627113330.550881ED1C3@projects.linpro.no> Author: phk Date: 2008-06-27 13:33:29 +0200 (Fri, 27 Jun 2008) New Revision: 2849 Modified: trunk/varnish-cache/bin/varnishtest/tests/v00001.vtc Log: Forgot to set resp.status Modified: trunk/varnish-cache/bin/varnishtest/tests/v00001.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/v00001.vtc 2008-06-27 11:18:00 UTC (rev 2848) +++ trunk/varnish-cache/bin/varnishtest/tests/v00001.vtc 2008-06-27 11:33:29 UTC (rev 2849) @@ -38,6 +38,7 @@ sub vcl_deliver { set resp.proto = "HTTP/1.2"; set resp.response = "Naah, lets fail it"; + set resp.status = 903; set resp.http.foobar = resp.proto resp.status; From phk at projects.linpro.no Fri Jun 27 12:30:26 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Fri, 27 Jun 2008 14:30:26 +0200 (CEST) Subject: r2850 - trunk/varnish-cache/bin/varnishd Message-ID: <20080627123026.5B57D1ED29D@projects.linpro.no> Author: phk Date: 2008-06-27 14:30:25 +0200 (Fri, 27 Jun 2008) New Revision: 2850 Modified: trunk/varnish-cache/bin/varnishd/cache_httpconn.c Log: Fix a minor issue in pipelining Modified: trunk/varnish-cache/bin/varnishd/cache_httpconn.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_httpconn.c 2008-06-27 11:33:29 UTC (rev 2849) +++ trunk/varnish-cache/bin/varnishd/cache_httpconn.c 2008-06-27 12:30:25 UTC (rev 2850) @@ -106,7 +106,6 @@ HTC_Reinit(struct http_conn *htc) { unsigned l; - int i; CHECK_OBJ_NOTNULL(htc, HTTP_CONN_MAGIC); (void)WS_Reserve(htc->ws, (htc->ws->e - htc->ws->s) / 2); @@ -120,8 +119,7 @@ htc->pipeline.e = NULL; } *htc->rxbuf.e = '\0'; - i = htc_header_complete(&htc->rxbuf); - return (i); + return (HTC_Complete(htc)); } /*-------------------------------------------------------------------- From phk at projects.linpro.no Fri Jun 27 12:30:42 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Fri, 27 Jun 2008 14:30:42 +0200 (CEST) Subject: r2851 - trunk/varnish-cache/bin/varnishtest/tests Message-ID: <20080627123042.BB21B1ED1C3@projects.linpro.no> Author: phk Date: 2008-06-27 14:30:42 +0200 (Fri, 27 Jun 2008) New Revision: 2851 Added: trunk/varnish-cache/bin/varnishtest/tests/b00012.vtc Log: Add testcase for pipelining Added: trunk/varnish-cache/bin/varnishtest/tests/b00012.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/b00012.vtc (rev 0) +++ trunk/varnish-cache/bin/varnishtest/tests/b00012.vtc 2008-06-27 12:30:42 UTC (rev 2851) @@ -0,0 +1,34 @@ +# $Id$ + +test "Check pipelining" + +varnish v1 -arg "-h simple_list -b 127.0.0.1:9080" -start + +server s1 { + rxreq + expect req.url == "/foo" + txresp -body "foo" + rxreq + expect req.url == "/bar" + txresp -body "foobar" +} + +server s1 -start + +client c1 { + send "GET /foo HTTP/1.1\n\nGET /bar HTTP/1.1\n\nGET /bar HTTP/1.1\n\n" + rxresp + expect resp.status == 200 + expect resp.http.content-length == 3 + expect resp.http.x-varnish == "1001" + rxresp + expect resp.status == 200 + expect resp.http.content-length == 6 + expect resp.http.x-varnish == "1002" + rxresp + expect resp.status == 200 + expect resp.http.content-length == 6 + expect resp.http.x-varnish == "1003 1002" +} + +client c1 -run From phk at projects.linpro.no Fri Jun 27 12:32:02 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Fri, 27 Jun 2008 14:32:02 +0200 (CEST) Subject: r2852 - trunk/varnish-cache/bin/varnishtest/tests Message-ID: <20080627123202.95F491EC115@projects.linpro.no> Author: phk Date: 2008-06-27 14:32:02 +0200 (Fri, 27 Jun 2008) New Revision: 2852 Added: trunk/varnish-cache/bin/varnishtest/tests/b00013.vtc Log: Add testcase for partial pipelining/read-ahead Added: trunk/varnish-cache/bin/varnishtest/tests/b00013.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/b00013.vtc (rev 0) +++ trunk/varnish-cache/bin/varnishtest/tests/b00013.vtc 2008-06-27 12:32:02 UTC (rev 2852) @@ -0,0 +1,36 @@ +# $Id$ + +test "Check read-head / partial pipelining" + +varnish v1 -arg "-h simple_list -b 127.0.0.1:9080" -start + +server s1 { + rxreq + expect req.url == "/foo" + txresp -body "foo" + rxreq + expect req.url == "/bar" + txresp -body "foobar" +} + +server s1 -start + +client c1 { + send "GET /foo HTTP/1.1\n\nGET " + rxresp + expect resp.status == 200 + expect resp.http.content-length == 3 + expect resp.http.x-varnish == "1001" + send "/bar HTTP/1.1\n\nGET /bar " + rxresp + expect resp.status == 200 + expect resp.http.content-length == 6 + expect resp.http.x-varnish == "1002" + send "HTTP/1.1\n\n" + rxresp + expect resp.status == 200 + expect resp.http.content-length == 6 + expect resp.http.x-varnish == "1003 1002" +} + +client c1 -run From phk at projects.linpro.no Fri Jun 27 12:44:47 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Fri, 27 Jun 2008 14:44:47 +0200 (CEST) Subject: r2853 - trunk/varnish-cache/bin/varnishtest/tests Message-ID: <20080627124447.B48341EC115@projects.linpro.no> Author: phk Date: 2008-06-27 14:44:47 +0200 (Fri, 27 Jun 2008) New Revision: 2853 Added: trunk/varnish-cache/bin/varnishtest/tests/c00009.vtc Log: Add test for simple restarts Added: trunk/varnish-cache/bin/varnishtest/tests/c00009.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/c00009.vtc (rev 0) +++ trunk/varnish-cache/bin/varnishtest/tests/c00009.vtc 2008-06-27 12:44:47 UTC (rev 2853) @@ -0,0 +1,40 @@ +# $Id$ + +test "Test restarts" + +server s1 { + rxreq + expect req.url == "/foo" + txresp -status 404 +} -start + +server s2 -listen 127.0.0.1:9180 { + rxreq + expect req.url == "/foo" + txresp -body "foobar" +} -start + +varnish v1 -vcl+backend { + sub vcl_recv { + if (req.restarts == 0) { + set req.backend = s1; + } else { + set req.backend = s2; + } + } + + sub vcl_fetch { + if (obj.status != 200) { + restart; + } + } +} -start + +client c1 { + txreq -url "/foo" + rxresp + expect resp.status == 200 + expect resp.http.content-length == 6 +} + +client c1 -run From phk at projects.linpro.no Fri Jun 27 12:48:13 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Fri, 27 Jun 2008 14:48:13 +0200 (CEST) Subject: r2854 - trunk/varnish-cache/bin/varnishtest/tests Message-ID: <20080627124813.3437C1EC0FD@projects.linpro.no> Author: phk Date: 2008-06-27 14:48:12 +0200 (Fri, 27 Jun 2008) New Revision: 2854 Added: trunk/varnish-cache/bin/varnishtest/tests/c00010.vtc Log: Test pass from vcl_hit{} Added: trunk/varnish-cache/bin/varnishtest/tests/c00010.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/c00010.vtc (rev 0) +++ trunk/varnish-cache/bin/varnishtest/tests/c00010.vtc 2008-06-27 12:48:12 UTC (rev 2854) @@ -0,0 +1,33 @@ +# $Id$ + +test "Test pass from hit" + +server s1 { + rxreq + expect req.url == "/foo" + txresp -body foobar + rxreq + expect req.url == "/foo" + txresp -body foobar1 +} -start + +varnish v1 -vcl+backend { + sub vcl_hit { + pass; + } +} -start + +client c1 { + txreq -url "/foo" + rxresp + expect resp.status == 200 + expect resp.http.content-length == 6 + expect resp.http.x-varnish == "1001" + txreq -url "/foo" + rxresp + expect resp.status == 200 + expect resp.http.content-length == 7 + expect resp.http.x-varnish == "1002" +} + +client c1 -run From phk at projects.linpro.no Fri Jun 27 12:51:48 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Fri, 27 Jun 2008 14:51:48 +0200 (CEST) Subject: r2855 - trunk/varnish-cache/bin/varnishtest/tests Message-ID: <20080627125148.03BE41EC115@projects.linpro.no> Author: phk Date: 2008-06-27 14:51:47 +0200 (Fri, 27 Jun 2008) New Revision: 2855 Added: trunk/varnish-cache/bin/varnishtest/tests/c00011.vtc Log: Test "hit for pass" (pass from vcl_fetch) Added: trunk/varnish-cache/bin/varnishtest/tests/c00011.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/c00011.vtc (rev 0) +++ trunk/varnish-cache/bin/varnishtest/tests/c00011.vtc 2008-06-27 12:51:47 UTC (rev 2855) @@ -0,0 +1,33 @@ +# $Id$ + +test "Test hit for pass (pass from fetch)" + +server s1 { + rxreq + expect req.url == "/foo" + txresp -body foobar + rxreq + expect req.url == "/foo" + txresp -body foobar1 +} -start + +varnish v1 -vcl+backend { + sub vcl_fetch { + pass; + } +} -start + +client c1 { + txreq -url "/foo" + rxresp + expect resp.status == 200 + expect resp.http.content-length == 6 + expect resp.http.x-varnish == "1001" + txreq -url "/foo" + rxresp + expect resp.status == 200 + expect resp.http.content-length == 7 + expect resp.http.x-varnish == "1002" +} + +client c1 -run From phk at projects.linpro.no Fri Jun 27 12:58:46 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Fri, 27 Jun 2008 14:58:46 +0200 (CEST) Subject: r2856 - trunk/varnish-cache/bin/varnishtest/tests Message-ID: <20080627125846.EC9F01EC115@projects.linpro.no> Author: phk Date: 2008-06-27 14:58:46 +0200 (Fri, 27 Jun 2008) New Revision: 2856 Added: trunk/varnish-cache/bin/varnishtest/tests/c00012.vtc Log: test miss from pass Added: trunk/varnish-cache/bin/varnishtest/tests/c00012.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/c00012.vtc (rev 0) +++ trunk/varnish-cache/bin/varnishtest/tests/c00012.vtc 2008-06-27 12:58:46 UTC (rev 2856) @@ -0,0 +1,33 @@ +# $Id$ + +test "Test pass from miss" + +server s1 { + rxreq + expect req.url == "/foo" + txresp -body foobar + rxreq + expect req.url == "/foo" + txresp -body foobar1 +} -start + +varnish v1 -vcl+backend { + sub vcl_miss { + pass; + } +} -start + +client c1 { + txreq -url "/foo" + rxresp + expect resp.status == 200 + expect resp.http.content-length == 6 + expect resp.http.x-varnish == "1001" + txreq -url "/foo" + rxresp + expect resp.status == 200 + expect resp.http.content-length == 7 + expect resp.http.x-varnish == "1002" +} + +client c1 -run From phk at projects.linpro.no Fri Jun 27 13:09:15 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Fri, 27 Jun 2008 15:09:15 +0200 (CEST) Subject: r2857 - trunk/varnish-cache/bin/varnishtest Message-ID: <20080627130915.46FD51EC0FD@projects.linpro.no> Author: phk Date: 2008-06-27 15:09:15 +0200 (Fri, 27 Jun 2008) New Revision: 2857 Modified: trunk/varnish-cache/bin/varnishtest/vtc_http.c Log: One second is too hysterical a timeout Modified: trunk/varnish-cache/bin/varnishtest/vtc_http.c =================================================================== --- trunk/varnish-cache/bin/varnishtest/vtc_http.c 2008-06-27 12:58:46 UTC (rev 2856) +++ trunk/varnish-cache/bin/varnishtest/vtc_http.c 2008-06-27 13:09:15 UTC (rev 2857) @@ -604,7 +604,7 @@ hp->fd = sock; hp->vl = vl; hp->client = client; - hp->timeout = 1000; + hp->timeout = 3000; hp->nrxbuf = 8192; hp->vsb = vsb_newauto(); hp->rxbuf = malloc(hp->nrxbuf); /* XXX */ From phk at projects.linpro.no Fri Jun 27 13:09:49 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Fri, 27 Jun 2008 15:09:49 +0200 (CEST) Subject: r2858 - trunk/varnish-cache/bin/varnishtest/tests Message-ID: <20080627130949.E85731EC115@projects.linpro.no> Author: phk Date: 2008-06-27 15:09:49 +0200 (Fri, 27 Jun 2008) New Revision: 2858 Added: trunk/varnish-cache/bin/varnishtest/tests/c00013.vtc Log: test busying subsequent requests on backend access. Added: trunk/varnish-cache/bin/varnishtest/tests/c00013.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/c00013.vtc (rev 0) +++ trunk/varnish-cache/bin/varnishtest/tests/c00013.vtc 2008-06-27 13:09:49 UTC (rev 2858) @@ -0,0 +1,31 @@ +# $Id$ + +test "Test parking second request on backend delay" + +server s1 { + rxreq + expect req.url == "/foo" + send "HTTP/1.1 200 Ok\r\nConnection: close\r\n\r\n" + delay .5 + send "line1\n" + delay .5 + send "line2\n" +} -start + +varnish v1 -vcl+backend { } -start + +client c1 { + txreq -url "/foo" + rxresp + expect resp.status == 200 + expect resp.http.content-length == 12 + expect resp.http.x-varnish == "1001" +} -start +delay .2 +client c2 { + txreq -url "/foo" + rxresp + expect resp.status == 200 + expect resp.http.content-length == 12 + expect resp.http.x-varnish == "1002 1001" +} -start From phk at projects.linpro.no Fri Jun 27 13:12:02 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Fri, 27 Jun 2008 15:12:02 +0200 (CEST) Subject: r2859 - trunk/varnish-cache/bin/varnishtest/tests Message-ID: <20080627131202.76E6B1EC0FD@projects.linpro.no> Author: phk Date: 2008-06-27 15:12:02 +0200 (Fri, 27 Jun 2008) New Revision: 2859 Added: trunk/varnish-cache/bin/varnishtest/tests/c00014.vtc Log: Test busy then pass Added: trunk/varnish-cache/bin/varnishtest/tests/c00014.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/c00014.vtc (rev 0) +++ trunk/varnish-cache/bin/varnishtest/tests/c00014.vtc 2008-06-27 13:12:02 UTC (rev 2859) @@ -0,0 +1,39 @@ +# $Id$ + +test "Test parking second request on backend delay, then pass" + +server s1 { + rxreq + expect req.url == "/foo" + send "HTTP/1.1 200 Ok\r\nContent-Length: 12\r\n\r\n" + delay .5 + send "line1\n" + delay .5 + send "line2\n" + + rxreq + expect req.url == "/foo" + txresp -body "foobar" +} -start + +varnish v1 -vcl+backend { + sub vcl_fetch { + pass; + } +} -start + +client c1 { + txreq -url "/foo" + rxresp + expect resp.status == 200 + expect resp.http.content-length == 12 + expect resp.http.x-varnish == "1001" +} -start +delay .2 +client c2 { + txreq -url "/foo" + rxresp + expect resp.status == 200 + expect resp.http.content-length == 6 + expect resp.http.x-varnish == "1002" +} -start From phk at projects.linpro.no Fri Jun 27 13:31:27 2008 From: phk at projects.linpro.no (phk at projects.linpro.no) Date: Fri, 27 Jun 2008 15:31:27 +0200 (CEST) Subject: r2860 - trunk/varnish-cache/bin/varnishtest/tests Message-ID: <20080627133127.C69F01ED246@projects.linpro.no> Author: phk Date: 2008-06-27 15:31:27 +0200 (Fri, 27 Jun 2008) New Revision: 2860 Added: trunk/varnish-cache/bin/varnishtest/tests/c00015.vtc Log: Test switching of VCLs Added: trunk/varnish-cache/bin/varnishtest/tests/c00015.vtc =================================================================== --- trunk/varnish-cache/bin/varnishtest/tests/c00015.vtc (rev 0) +++ trunk/varnish-cache/bin/varnishtest/tests/c00015.vtc 2008-06-27 13:31:27 UTC (rev 2860) @@ -0,0 +1,56 @@ +# $Id$ + +test "Test switching VCLs" + +server s1 { + rxreq + expect req.url == "/foo" + txresp -body "foobar" + rxreq + expect req.url == "/foo" + txresp -body "foobar1" +} -start + +varnish v1 -vcl+backend { +} -start + +varnish v1 -vcl+backend { + sub vcl_recv { + pass; + } +} + +varnish v1 -cli "vcl.list" +varnish v1 -cli "vcl.use vcl1" + +client c1 { + txreq -url "/foo" + rxresp + expect resp.status == 200 + expect resp.http.content-length == 6 + expect resp.http.x-varnish == "1001" +} -start + +varnish v1 -cli "vcl.use vcl2" + +client c2 { + txreq -url "/foo" + rxresp + expect resp.status == 200 + expect resp.http.content-length == 7 + expect resp.http.x-varnish == "1002" +} -start + +varnish v1 -cli "vcl.use vcl1" + +client c3 { + txreq -url "/foo" + rxresp + expect resp.status == 200 + expect resp.http.content-length == 6 + expect resp.http.x-varnish == "1003 1001" +} -start + +varnish v1 -cli "vcl.show vcl2" +varnish v1 -cli "vcl.discard vcl2" +varnish v1 -cli "vcl.list" From des at projects.linpro.no Mon Jun 30 01:40:13 2008 From: des at projects.linpro.no (des at projects.linpro.no) Date: Mon, 30 Jun 2008 03:40:13 +0200 (CEST) Subject: r2861 - in trunk: varnish-cache/bin/varnishd varnish-cache/bin/varnishhist varnish-cache/bin/varnishlog varnish-cache/bin/varnishncsa varnish-cache/bin/varnishstat varnish-cache/bin/varnishtop varnish-cache/include/compat varnish-cache/lib/libvarnish varnish-cache/lib/libvarnishapi varnish-cache/lib/libvarnishcompat varnish-cache/man varnish-cache/redhat varnish-tools/fetcher varnish-tools/munin Message-ID: <20080630014013.5A0F01EC220@projects.linpro.no> Author: des Date: 2008-06-30 03:40:12 +0200 (Mon, 30 Jun 2008) New Revision: 2861 Modified: trunk/varnish-cache/bin/varnishd/cache_panic.c trunk/varnish-cache/bin/varnishd/cache_synthetic.c trunk/varnish-cache/bin/varnishd/stevedore.c trunk/varnish-cache/bin/varnishd/varnishd.1 trunk/varnish-cache/bin/varnishhist/varnishhist.1 trunk/varnish-cache/bin/varnishhist/varnishhist.c trunk/varnish-cache/bin/varnishlog/varnishlog.1 trunk/varnish-cache/bin/varnishncsa/varnishncsa.1 trunk/varnish-cache/bin/varnishstat/varnishstat.1 trunk/varnish-cache/bin/varnishstat/varnishstat.c trunk/varnish-cache/bin/varnishtop/varnishtop.1 trunk/varnish-cache/bin/varnishtop/varnishtop.c trunk/varnish-cache/include/compat/asprintf.h trunk/varnish-cache/include/compat/daemon.h trunk/varnish-cache/include/compat/setproctitle.h trunk/varnish-cache/include/compat/srandomdev.h trunk/varnish-cache/include/compat/strlcat.h trunk/varnish-cache/include/compat/strlcpy.h trunk/varnish-cache/include/compat/strndup.h trunk/varnish-cache/include/compat/vasprintf.h trunk/varnish-cache/lib/libvarnish/version.c trunk/varnish-cache/lib/libvarnish/vss.c trunk/varnish-cache/lib/libvarnish/vtmpfile.c trunk/varnish-cache/lib/libvarnishapi/instance.c trunk/varnish-cache/lib/libvarnishcompat/asprintf.c trunk/varnish-cache/lib/libvarnishcompat/setproctitle.c trunk/varnish-cache/lib/libvarnishcompat/srandomdev.c trunk/varnish-cache/lib/libvarnishcompat/strndup.c trunk/varnish-cache/lib/libvarnishcompat/vasprintf.c trunk/varnish-cache/man/vcl.7 trunk/varnish-cache/redhat/varnish.spec trunk/varnish-tools/fetcher/fetcher.pl trunk/varnish-tools/munin/varnish_munin_plugin.pl Log: Change my email address. Modified: trunk/varnish-cache/bin/varnishd/cache_panic.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_panic.c 2008-06-27 13:31:27 UTC (rev 2860) +++ trunk/varnish-cache/bin/varnishd/cache_panic.c 2008-06-30 01:40:12 UTC (rev 2861) @@ -3,7 +3,7 @@ * Copyright (c) 2006-2008 Linpro AS * All rights reserved. * - * Author: Dag-Erling Sm??rgrav + * Author: Dag-Erling Sm??rgrav * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions Modified: trunk/varnish-cache/bin/varnishd/cache_synthetic.c =================================================================== --- trunk/varnish-cache/bin/varnishd/cache_synthetic.c 2008-06-27 13:31:27 UTC (rev 2860) +++ trunk/varnish-cache/bin/varnishd/cache_synthetic.c 2008-06-30 01:40:12 UTC (rev 2861) @@ -2,7 +2,7 @@ * Copyright (c) 2007-2008 Linpro AS * All rights reserved. * - * Author: Dag-Erling Sm??rgrav + * Author: Dag-Erling Sm??rgrav * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions Modified: trunk/varnish-cache/bin/varnishd/stevedore.c =================================================================== --- trunk/varnish-cache/bin/varnishd/stevedore.c 2008-06-27 13:31:27 UTC (rev 2860) +++ trunk/varnish-cache/bin/varnishd/stevedore.c 2008-06-30 01:40:12 UTC (rev 2861) @@ -2,7 +2,7 @@ * Copyright (c) 2007-2008 Linpro AS * All rights reserved. * - * Author: Dag-Erling Sm?rgav + * Author: Dag-Erling Sm??rgav * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions Modified: trunk/varnish-cache/bin/varnishd/varnishd.1 =================================================================== --- trunk/varnish-cache/bin/varnishd/varnishd.1 2008-06-27 13:31:27 UTC (rev 2860) +++ trunk/varnish-cache/bin/varnishd/varnishd.1 2008-06-30 01:40:12 UTC (rev 2861) @@ -3,7 +3,7 @@ .\" Copyright (c) 2006-2008 Linpro AS .\" All rights reserved. .\" -.\" Author: Dag-Erling Sm??rgrav +.\" Author: Dag-Erling Sm??rgrav .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions @@ -549,4 +549,4 @@ .An Poul-Henning Kamp Aq phk at phk.freebsd.dk in cooperation with Verdens Gang AS and Linpro AS. This manual page was written by -.An Dag-Erling Sm\(/orgrav Aq des at linpro.no . +.An Dag-Erling Sm\(/orgrav Aq des at des.no . Modified: trunk/varnish-cache/bin/varnishhist/varnishhist.1 =================================================================== --- trunk/varnish-cache/bin/varnishhist/varnishhist.1 2008-06-27 13:31:27 UTC (rev 2860) +++ trunk/varnish-cache/bin/varnishhist/varnishhist.1 2008-06-30 01:40:12 UTC (rev 2861) @@ -3,7 +3,7 @@ .\" Copyright (c) 2006-2008 Linpro AS .\" All rights reserved. .\" -.\" Author: Dag-Erling Sm??rgrav +.\" Author: Dag-Erling Sm??rgrav .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions @@ -148,4 +148,4 @@ .An Poul-Henning Kamp Aq phk at phk.freebsd.dk in cooperation with Verdens Gang AS and Linpro AS. This manual page was written by -.An Dag-Erling Sm\(/orgrav Aq des at linpro.no . +.An Dag-Erling Sm\(/orgrav Aq des at des.no . Modified: trunk/varnish-cache/bin/varnishhist/varnishhist.c =================================================================== --- trunk/varnish-cache/bin/varnishhist/varnishhist.c 2008-06-27 13:31:27 UTC (rev 2860) +++ trunk/varnish-cache/bin/varnishhist/varnishhist.c 2008-06-30 01:40:12 UTC (rev 2861) @@ -4,7 +4,7 @@ * All rights reserved. * * Author: Poul-Henning Kamp - * Author: Dag-Erling Sm??rgrav + * Author: Dag-Erling Sm??rgrav * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions Modified: trunk/varnish-cache/bin/varnishlog/varnishlog.1 =================================================================== --- trunk/varnish-cache/bin/varnishlog/varnishlog.1 2008-06-27 13:31:27 UTC (rev 2860) +++ trunk/varnish-cache/bin/varnishlog/varnishlog.1 2008-06-30 01:40:12 UTC (rev 2861) @@ -3,7 +3,7 @@ .\" Copyright (c) 2006-2008 Linpro AS .\" All rights reserved. .\" -.\" Author: Dag-Erling Sm??rgrav +.\" Author: Dag-Erling Sm??rgrav .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions @@ -250,4 +250,4 @@ .An Poul-Henning Kamp Aq phk at phk.freebsd.dk in cooperation with Verdens Gang AS and Linpro AS. This manual page was written by -.An Dag-Erling Sm\(/orgrav Aq des at linpro.no . +.An Dag-Erling Sm\(/orgrav Aq des at des.no . Modified: trunk/varnish-cache/bin/varnishncsa/varnishncsa.1 =================================================================== --- trunk/varnish-cache/bin/varnishncsa/varnishncsa.1 2008-06-27 13:31:27 UTC (rev 2860) +++ trunk/varnish-cache/bin/varnishncsa/varnishncsa.1 2008-06-30 01:40:12 UTC (rev 2861) @@ -3,7 +3,7 @@ .\" Copyright (c) 2006-2008 Linpro AS .\" All rights reserved. .\" -.\" Author: Dag-Erling Sm??rgrav +.\" Author: Dag-Erling Sm??rgrav .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions @@ -154,4 +154,4 @@ .An Poul-Henning Kamp Aq phk at phk.freebsd.dk in cooperation with Verdens Gang AS and Linpro AS. This manual page was written by -.An Dag-Erling Sm\(/orgrav Aq des at linpro.no . +.An Dag-Erling Sm\(/orgrav Aq des at des.no . Modified: trunk/varnish-cache/bin/varnishstat/varnishstat.1 =================================================================== --- trunk/varnish-cache/bin/varnishstat/varnishstat.1 2008-06-27 13:31:27 UTC (rev 2860) +++ trunk/varnish-cache/bin/varnishstat/varnishstat.1 2008-06-30 01:40:12 UTC (rev 2861) @@ -3,7 +3,7 @@ .\" Copyright (c) 2006-2008 Linpro AS .\" All rights reserved. .\" -.\" Author: Dag-Erling Sm??rgrav +.\" Author: Dag-Erling Sm??rgrav .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions @@ -110,6 +110,6 @@ .An Poul-Henning Kamp Aq phk at phk.freebsd.dk in cooperation with Verdens Gang AS and Linpro AS, and later substantially rewritten by -.An Dag-Erling Sm\(/orgrav Aq des at linpro.no . +.An Dag-Erling Sm\(/orgrav Aq des at des.no . This manual page was written by -.An Dag-Erling Sm\(/orgrav Aq des at linpro.no . +.An Dag-Erling Sm\(/orgrav Aq des at des.no . Modified: trunk/varnish-cache/bin/varnishstat/varnishstat.c =================================================================== --- trunk/varnish-cache/bin/varnishstat/varnishstat.c 2008-06-27 13:31:27 UTC (rev 2860) +++ trunk/varnish-cache/bin/varnishstat/varnishstat.c 2008-06-30 01:40:12 UTC (rev 2861) @@ -4,7 +4,7 @@ * All rights reserved. * * Author: Poul-Henning Kamp - * Author: Dag-Erling Sm??rgrav + * Author: Dag-Erling Sm??rgrav * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions Modified: trunk/varnish-cache/bin/varnishtop/varnishtop.1 =================================================================== --- trunk/varnish-cache/bin/varnishtop/varnishtop.1 2008-06-27 13:31:27 UTC (rev 2860) +++ trunk/varnish-cache/bin/varnishtop/varnishtop.1 2008-06-30 01:40:12 UTC (rev 2861) @@ -3,7 +3,7 @@ .\" Copyright (c) 2006-2008 Linpro AS .\" All rights reserved. .\" -.\" Author: Dag-Erling Sm??rgrav +.\" Author: Dag-Erling Sm??rgrav .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions @@ -162,6 +162,6 @@ .An Poul-Henning Kamp Aq phk at phk.freebsd.dk in cooperation with Verdens Gang AS and Linpro AS, and later substantially rewritten by -.An Dag-Erling Sm\(/orgrav Aq des at linpro.no . +.An Dag-Erling Sm\(/orgrav Aq des at des.no . This manual page was written by -.An Dag-Erling Sm\(/orgrav Aq des at linpro.no . +.An Dag-Erling Sm\(/orgrav Aq des at des.no . Modified: trunk/varnish-cache/bin/varnishtop/varnishtop.c =================================================================== --- trunk/varnish-cache/bin/varnishtop/varnishtop.c 2008-06-27 13:31:27 UTC (rev 2860) +++ trunk/varnish-cache/bin/varnishtop/varnishtop.c 2008-06-30 01:40:12 UTC (rev 2861) @@ -4,7 +4,7 @@ * All rights reserved. * * Author: Poul-Henning Kamp - * Author: Dag-Erling Sm??rgrav + * Author: Dag-Erling Sm??rgrav * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions Modified: trunk/varnish-cache/include/compat/asprintf.h =================================================================== --- trunk/varnish-cache/include/compat/asprintf.h 2008-06-27 13:31:27 UTC (rev 2860) +++ trunk/varnish-cache/include/compat/asprintf.h 2008-06-30 01:40:12 UTC (rev 2861) @@ -3,7 +3,7 @@ * Copyright (c) 2006-2008 Linpro AS * All rights reserved. * - * Author: Dag-Erling Sm??rgrav + * Author: Dag-Erling Sm??rgrav * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions Modified: trunk/varnish-cache/include/compat/daemon.h =================================================================== --- trunk/varnish-cache/include/compat/daemon.h 2008-06-27 13:31:27 UTC (rev 2860) +++ trunk/varnish-cache/include/compat/daemon.h 2008-06-30 01:40:12 UTC (rev 2861) @@ -3,7 +3,7 @@ * Copyright (c) 2006-2008 Linpro AS * All rights reserved. * - * Author: Dag-Erling Sm??rgrav + * Author: Dag-Erling Sm??rgrav * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions Modified: trunk/varnish-cache/include/compat/setproctitle.h =================================================================== --- trunk/varnish-cache/include/compat/setproctitle.h 2008-06-27 13:31:27 UTC (rev 2860) +++ trunk/varnish-cache/include/compat/setproctitle.h 2008-06-30 01:40:12 UTC (rev 2861) @@ -3,7 +3,7 @@ * Copyright (c) 2006-2008 Linpro AS * All rights reserved. * - * Author: Dag-Erling Sm??rgrav + * Author: Dag-Erling Sm??rgrav * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions Modified: trunk/varnish-cache/include/compat/srandomdev.h =================================================================== --- trunk/varnish-cache/include/compat/srandomdev.h 2008-06-27 13:31:27 UTC (rev 2860) +++ trunk/varnish-cache/include/compat/srandomdev.h 2008-06-30 01:40:12 UTC (rev 2861) @@ -3,7 +3,7 @@ * Copyright (c) 2006-2008 Linpro AS * All rights reserved. * - * Author: Dag-Erling Sm??rgrav + * Author: Dag-Erling Sm??rgrav * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions Modified: trunk/varnish-cache/include/compat/strlcat.h =================================================================== --- trunk/varnish-cache/include/compat/strlcat.h 2008-06-27 13:31:27 UTC (rev 2860) +++ trunk/varnish-cache/include/compat/strlcat.h 2008-06-30 01:40:12 UTC (rev 2861) @@ -3,7 +3,7 @@ * Copyright (c) 2006-2008 Linpro AS * All rights reserved. * - * Author: Dag-Erling Sm??rgrav + * Author: Dag-Erling Sm??rgrav * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions Modified: trunk/varnish-cache/include/compat/strlcpy.h =================================================================== --- trunk/varnish-cache/include/compat/strlcpy.h 2008-06-27 13:31:27 UTC (rev 2860) +++ trunk/varnish-cache/include/compat/strlcpy.h 2008-06-30 01:40:12 UTC (rev 2861) @@ -3,7 +3,7 @@ * Copyright (c) 2006-2008 Linpro AS * All rights reserved. * - * Author: Dag-Erling Sm??rgrav + * Author: Dag-Erling Sm??rgrav * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions Modified: trunk/varnish-cache/include/compat/strndup.h =================================================================== --- trunk/varnish-cache/include/compat/strndup.h 2008-06-27 13:31:27 UTC (rev 2860) +++ trunk/varnish-cache/include/compat/strndup.h 2008-06-30 01:40:12 UTC (rev 2861) @@ -3,7 +3,7 @@ * Copyright (c) 2006-2008 Linpro AS * All rights reserved. * - * Author: Dag-Erling Sm??rgrav + * Author: Dag-Erling Sm??rgrav * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions Modified: trunk/varnish-cache/include/compat/vasprintf.h =================================================================== --- trunk/varnish-cache/include/compat/vasprintf.h 2008-06-27 13:31:27 UTC (rev 2860) +++ trunk/varnish-cache/include/compat/vasprintf.h 2008-06-30 01:40:12 UTC (rev 2861) @@ -3,7 +3,7 @@ * Copyright (c) 2006-2008 Linpro AS * All rights reserved. * - * Author: Dag-Erling Sm??rgrav + * Author: Dag-Erling Sm??rgrav * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions Modified: trunk/varnish-cache/lib/libvarnish/version.c =================================================================== --- trunk/varnish-cache/lib/libvarnish/version.c 2008-06-27 13:31:27 UTC (rev 2860) +++ trunk/varnish-cache/lib/libvarnish/version.c 2008-06-30 01:40:12 UTC (rev 2861) @@ -3,7 +3,7 @@ * Copyright (c) 2006-2008 Linpro AS * All rights reserved. * - * Author: Dag-Erling Sm??rgrav + * Author: Dag-Erling Sm??rgrav * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions Modified: trunk/varnish-cache/lib/libvarnish/vss.c =================================================================== --- trunk/varnish-cache/lib/libvarnish/vss.c 2008-06-27 13:31:27 UTC (rev 2860) +++ trunk/varnish-cache/lib/libvarnish/vss.c 2008-06-30 01:40:12 UTC (rev 2861) @@ -3,7 +3,7 @@ * Copyright (c) 2006-2008 Linpro AS * All rights reserved. * - * Author: Dag-Erling Sm??rgrav + * Author: Dag-Erling Sm??rgrav * Author: Cecilie Fritzvold * * Redistribution and use in source and binary forms, with or without Modified: trunk/varnish-cache/lib/libvarnish/vtmpfile.c =================================================================== --- trunk/varnish-cache/lib/libvarnish/vtmpfile.c 2008-06-27 13:31:27 UTC (rev 2860) +++ trunk/varnish-cache/lib/libvarnish/vtmpfile.c 2008-06-30 01:40:12 UTC (rev 2861) @@ -3,7 +3,7 @@ * Copyright (c) 2006-2008 Linpro AS * All rights reserved. * - * Author: Dag-Erling Sm??rgrav + * Author: Dag-Erling Sm??rgrav * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions Modified: trunk/varnish-cache/lib/libvarnishapi/instance.c =================================================================== --- trunk/varnish-cache/lib/libvarnishapi/instance.c 2008-06-27 13:31:27 UTC (rev 2860) +++ trunk/varnish-cache/lib/libvarnishapi/instance.c 2008-06-30 01:40:12 UTC (rev 2861) @@ -2,7 +2,7 @@ * Copyright (c) 2007-2008 Linpro AS * All rights reserved. * - * Author: Dag-Erling Sm??rgrav + * Author: Dag-Erling Sm??rgrav * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions Modified: trunk/varnish-cache/lib/libvarnishcompat/asprintf.c =================================================================== --- trunk/varnish-cache/lib/libvarnishcompat/asprintf.c 2008-06-27 13:31:27 UTC (rev 2860) +++ trunk/varnish-cache/lib/libvarnishcompat/asprintf.c 2008-06-30 01:40:12 UTC (rev 2861) @@ -3,7 +3,7 @@ * Copyright (c) 2006-2008 Linpro AS * All rights reserved. * - * Author: Dag-Erling Sm??rgrav + * Author: Dag-Erling Sm??rgrav * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions Modified: trunk/varnish-cache/lib/libvarnishcompat/setproctitle.c =================================================================== --- trunk/varnish-cache/lib/libvarnishcompat/setproctitle.c 2008-06-27 13:31:27 UTC (rev 2860) +++ trunk/varnish-cache/lib/libvarnishcompat/setproctitle.c 2008-06-30 01:40:12 UTC (rev 2861) @@ -3,7 +3,7 @@ * Copyright (c) 2006-2008 Linpro AS * All rights reserved. * - * Author: Dag-Erling Sm??rgrav + * Author: Dag-Erling Sm??rgrav * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions Modified: trunk/varnish-cache/lib/libvarnishcompat/srandomdev.c =================================================================== --- trunk/varnish-cache/lib/libvarnishcompat/srandomdev.c 2008-06-27 13:31:27 UTC (rev 2860) +++ trunk/varnish-cache/lib/libvarnishcompat/srandomdev.c 2008-06-30 01:40:12 UTC (rev 2861) @@ -3,7 +3,7 @@ * Copyright (c) 2006-2008 Linpro AS * All rights reserved. * - * Author: Dag-Erling Sm??rgrav + * Author: Dag-Erling Sm??rgrav * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions Modified: trunk/varnish-cache/lib/libvarnishcompat/strndup.c =================================================================== --- trunk/varnish-cache/lib/libvarnishcompat/strndup.c 2008-06-27 13:31:27 UTC (rev 2860) +++ trunk/varnish-cache/lib/libvarnishcompat/strndup.c 2008-06-30 01:40:12 UTC (rev 2861) @@ -3,7 +3,7 @@ * Copyright (c) 2006-2008 Linpro AS * All rights reserved. * - * Author: Dag-Erling Sm??rgrav + * Author: Dag-Erling Sm??rgrav * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions Modified: trunk/varnish-cache/lib/libvarnishcompat/vasprintf.c =================================================================== --- trunk/varnish-cache/lib/libvarnishcompat/vasprintf.c 2008-06-27 13:31:27 UTC (rev 2860) +++ trunk/varnish-cache/lib/libvarnishcompat/vasprintf.c 2008-06-30 01:40:12 UTC (rev 2861) @@ -3,7 +3,7 @@ * Copyright (c) 2006-2008 Linpro AS * All rights reserved. * - * Author: Dag-Erling Sm??rgrav + * Author: Dag-Erling Sm??rgrav * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions Modified: trunk/varnish-cache/man/vcl.7 =================================================================== --- trunk/varnish-cache/man/vcl.7 2008-06-27 13:31:27 UTC (rev 2860) +++ trunk/varnish-cache/man/vcl.7 2008-06-30 01:40:12 UTC (rev 2861) @@ -3,7 +3,7 @@ .\" Copyright (c) 2006-2008 Linpro AS .\" All rights reserved. .\" -.\" Author: Dag-Erling Sm??rgrav +.\" Author: Dag-Erling Sm??rgrav .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions @@ -662,4 +662,4 @@ .An Poul-Henning Kamp Aq phk at phk.freebsd.dk in cooperation with Verdens Gang AS and Linpro AS. This manual page was written by -.An Dag-Erling Sm\(/orgrav Aq des at linpro.no . +.An Dag-Erling Sm\(/orgrav Aq des at des.no . Modified: trunk/varnish-cache/redhat/varnish.spec =================================================================== --- trunk/varnish-cache/redhat/varnish.spec 2008-06-27 13:31:27 UTC (rev 2860) +++ trunk/varnish-cache/redhat/varnish.spec 2008-06-30 01:40:12 UTC (rev 2861) @@ -201,7 +201,7 @@ - Added the devel package for the header files and static library files - Added a varnish user, and fixed the init script accordingly -* Thu Jul 05 2007 Dag-Erling Sm??rgrav - 1.1-1 +* Thu Jul 05 2007 Dag-Erling Sm??rgrav - 1.1-1 - Bump Version and Release for 1.1 * Mon May 28 2007 Ingvar Hagelund - 1.0.4-3 Modified: trunk/varnish-tools/fetcher/fetcher.pl =================================================================== --- trunk/varnish-tools/fetcher/fetcher.pl 2008-06-27 13:31:27 UTC (rev 2860) +++ trunk/varnish-tools/fetcher/fetcher.pl 2008-06-30 01:40:12 UTC (rev 2861) @@ -3,7 +3,7 @@ # Copyright (c) 2007-2008 Linpro AS # All rights reserved. # -# Author: Dag-Erling Sm??rgrav +# Author: Dag-Erling Sm??rgrav # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions Modified: trunk/varnish-tools/munin/varnish_munin_plugin.pl =================================================================== --- trunk/varnish-tools/munin/varnish_munin_plugin.pl 2008-06-27 13:31:27 UTC (rev 2860) +++ trunk/varnish-tools/munin/varnish_munin_plugin.pl 2008-06-30 01:40:12 UTC (rev 2861) @@ -3,7 +3,7 @@ # Copyright (c) 2007-2008 Linpro AS # All rights reserved. # -# Author: Dag-Erling Sm??rgrav +# Author: Dag-Erling Sm??rgrav # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions From des at projects.linpro.no Mon Jun 30 01:44:33 2008 From: des at projects.linpro.no (des at projects.linpro.no) Date: Mon, 30 Jun 2008 03:44:33 +0200 (CEST) Subject: r2862 - trunk/varnish-cache/lib/libvarnishapi Message-ID: <20080630014433.51DB11ED1CC@projects.linpro.no> Author: des Date: 2008-06-30 03:44:33 +0200 (Mon, 30 Jun 2008) New Revision: 2862 Modified: trunk/varnish-cache/lib/libvarnishapi/shmlog.c Log: The correct return value when we reach the end is -1, not 0. Modified: trunk/varnish-cache/lib/libvarnishapi/shmlog.c =================================================================== --- trunk/varnish-cache/lib/libvarnishapi/shmlog.c 2008-06-30 01:40:12 UTC (rev 2861) +++ trunk/varnish-cache/lib/libvarnishapi/shmlog.c 2008-06-30 01:44:33 UTC (rev 2862) @@ -300,7 +300,7 @@ continue; } else if (vd->keep) { if (--vd->keep == 0) - return (0); + return (-1); } if (vd->map[p[SHMLOG_TAG]] & M_SELECT) { *pp = p; From des at projects.linpro.no Mon Jun 30 02:03:58 2008 From: des at projects.linpro.no (des at projects.linpro.no) Date: Mon, 30 Jun 2008 04:03:58 +0200 (CEST) Subject: r2863 - trunk/varnish-cache/lib/libvarnishapi Message-ID: <20080630020358.877361EC11A@projects.linpro.no> Author: des Date: 2008-06-30 04:03:58 +0200 (Mon, 30 Jun 2008) New Revision: 2863 Modified: trunk/varnish-cache/lib/libvarnishapi/shmlog.c Log: Convert from FILE * to fd. Modified: trunk/varnish-cache/lib/libvarnishapi/shmlog.c =================================================================== --- trunk/varnish-cache/lib/libvarnishapi/shmlog.c 2008-06-30 01:44:33 UTC (rev 2862) +++ trunk/varnish-cache/lib/libvarnishapi/shmlog.c 2008-06-30 02:03:58 UTC (rev 2863) @@ -65,7 +65,7 @@ unsigned char *ptr; /* for -r option */ - FILE *fi; + int fd; unsigned char rbuf[SHMLOG_NEXTTAG + 255 + 1]; int b_opt; @@ -171,6 +171,7 @@ assert(vd != NULL); vd->regflags = REG_EXTENDED | REG_NOSUB; vd->magic = VSL_MAGIC; + vd->fd = -1; return (vd); } @@ -192,7 +193,7 @@ unsigned char *p; CHECK_OBJ_NOTNULL(vd, VSL_MAGIC); - if (vd->fi != NULL) + if (vd->fd != -1) return (0); if (vsl_shmem_map(varnish_name)) @@ -203,7 +204,7 @@ vd->logend = vd->logstart + vsl_lh->size; vd->ptr = vd->logstart; - if (!vd->d_opt && vd->fi == NULL) { + if (!vd->d_opt && vd->fd == -1) { for (p = vd->ptr; *p != SLT_ENDMARKER; ) p += SHMLOG_LEN(p) + SHMLOG_NEXTTAG; vd->ptr = p; @@ -232,13 +233,13 @@ int i; CHECK_OBJ_NOTNULL(vd, VSL_MAGIC); - if (vd->fi != NULL) { - i = fread(vd->rbuf, SHMLOG_DATA, 1, vd->fi); - if (i != 1) + if (vd->fd != -1) { + i = read(vd->fd, vd->rbuf, SHMLOG_DATA); + if (i != SHMLOG_DATA) return (-1); - i = fread(vd->rbuf + SHMLOG_DATA, - SHMLOG_LEN(vd->rbuf) + 1, 1, vd->fi); - if (i != 1) + i = read(vd->fd, vd->rbuf + SHMLOG_DATA, + SHMLOG_LEN(vd->rbuf) + 1); + if (i != SHMLOG_LEN(vd->rbuf) + 1) return (-1); *pp = vd->rbuf; return (1); @@ -394,13 +395,14 @@ CHECK_OBJ_NOTNULL(vd, VSL_MAGIC); if (!strcmp(opt, "-")) - vd->fi = stdin; + vd->fd = STDIN_FILENO; else - vd->fi = fopen(opt, "r"); - if (vd->fi != NULL) - return (1); - perror(opt); - return (-1); + vd->fd = open(opt, O_RDONLY); + if (vd->fd < 0) { + perror(opt); + return (-1); + } + return (1); } /*--------------------------------------------------------------------*/ From des at projects.linpro.no Mon Jun 30 02:11:54 2008 From: des at projects.linpro.no (des at projects.linpro.no) Date: Mon, 30 Jun 2008 04:11:54 +0200 (CEST) Subject: r2864 - trunk/varnish-cache/bin/varnishreplay Message-ID: <20080630021154.38F621EC220@projects.linpro.no> Author: des Date: 2008-06-30 04:11:54 +0200 (Mon, 30 Jun 2008) New Revision: 2864 Modified: trunk/varnish-cache/bin/varnishreplay/varnishreplay.c Log: Old patch: greatly improve performance and memory usage by using per-thread pre-allocated buffers instead of malloc(). Modified: trunk/varnish-cache/bin/varnishreplay/varnishreplay.c =================================================================== --- trunk/varnish-cache/bin/varnishreplay/varnishreplay.c 2008-06-30 02:03:58 UTC (rev 2863) +++ trunk/varnish-cache/bin/varnishreplay/varnishreplay.c 2008-06-30 02:11:54 UTC (rev 2864) @@ -58,6 +58,37 @@ static struct vss_addr *addr_info; static int debug; +static int +isprefix(const char *str, const char *prefix, const char **next) +{ + + while (*str && *prefix && + tolower((int)*str) == tolower((int)*prefix)) + ++str, ++prefix; + if (*str && *str != ' ') + return (0); + if (next) { + while (*str && *str == ' ') + ++str; + *next = str; + } + return (1); +} + +#if 0 +static int +isequal(const char *str, const char *reference, const char *end) +{ + + while (str < end && *str && *reference && + tolower((int)*str) == tolower((int)*reference)) + ++str, ++reference; + if (str != end || *reference) + return (0); + return (1); +} +#endif + /* * mailbox toolkit */ @@ -69,6 +100,8 @@ VSTAILQ_ENTRY(message) list; }; +#define MAX_MAILBOX_SIZE 30 + struct mailbox { pthread_mutex_t lock; pthread_cond_t has_mail; @@ -136,11 +169,6 @@ * thread toolkit */ -struct thread { - pthread_t thread_id; - struct mailbox mbox; -}; - static pthread_mutex_t log_mutex = PTHREAD_MUTEX_INITIALIZER; static void @@ -161,9 +189,56 @@ pthread_mutex_unlock(&log_mutex); } +struct thread { + pthread_t thread_id; + struct mailbox mbox; + + int sock; + + int fd; /* original fd from logs */ + + char *method; /* Request method*/ + char *proto; /* Protocol version */ + char *url; /* URL and query string */ + const char *conn; /* Connection info (keep-alive, close) */ + char *hdr[64]; /* Headers */ + int nhdr; /* Number of headers */ + int bogus; /* bogus request */ + + char arena[4096]; + int top; + char line[2048]; + char temp[2048]; +}; + static struct thread **threads; static size_t nthreads; +/* + * Clear thread state + */ +static void +thread_clear(struct thread *thr) +{ + + thr->method = thr->proto = thr->url = NULL; + thr->conn = NULL; + memset(&thr->hdr, 0, sizeof thr->hdr); + thr->nhdr = 0; + thr->bogus = 0; + memset(&thr->arena, 0, sizeof thr->arena); + thr->top = 0; + memset(&thr->line, 0, sizeof thr->line); + memset(&thr->temp, 0, sizeof thr->temp); + if (thr->sock != -1) + close(thr->sock); + thr->sock = -1; +} + +#define THREAD_FAIL ((struct thread *)-1) + +static pthread_attr_t thread_attr; + static struct thread * thread_get(int fd, void *(*thread_main)(void *)) { @@ -185,16 +260,23 @@ if (threads[fd] == NULL) { threads[fd] = malloc(sizeof *threads[fd]); assert(threads[fd] != NULL); + threads[fd]->sock = -1; + thread_clear(threads[fd]); mailbox_create(&threads[fd]->mbox); - if (pthread_create(&threads[fd]->thread_id, NULL, + if (pthread_create(&threads[fd]->thread_id, &thread_attr, thread_main, threads[fd]) != 0) { thread_log(0, errno, "pthread_create()"); mailbox_destroy(&threads[fd]->mbox); freez(threads[fd]); + threads[fd] = THREAD_FAIL; + } else { + threads[fd]->fd = fd; + thread_log(0, 0, "thread %p:%d started", + (void *)threads[fd]->thread_id, fd); } - thread_log(0, 0, "thread %p started", - (void *)threads[fd]->thread_id); } + if (threads[fd] == THREAD_FAIL) + return (NULL); return (threads[fd]); } @@ -202,74 +284,56 @@ thread_close(int fd) { - assert(fd == 0 || fd < nthreads); - if (fd == 0) { - for (fd = 1; fd < nthreads; ++fd) + if (fd == -1) { + for (fd = 0; fd < nthreads; ++fd) thread_close(fd); return; } + assert(fd < nthreads); + if (threads[fd] == NULL) return; mailbox_close(&threads[fd]->mbox); pthread_join(threads[fd]->thread_id, NULL); thread_log(0, 0, "thread %p stopped", (void *)threads[fd]->thread_id); + thread_clear(threads[fd]); mailbox_destroy(&threads[fd]->mbox); freez(threads[fd]); } /* - * ... + * Allocate from thread arena */ - -static int -isprefix(const char *str, const char *prefix, const char *end, const char **next) +static void * +thread_alloc(struct thread *thr, size_t len) { + void *ptr; - while (str < end && *str && *prefix && - tolower((int)*str) == tolower((int)*prefix)) - ++str, ++prefix; - if (*str && *str != ' ') - return (0); - if (next) { - while (str < end && *str && *str == ' ') - ++str; - *next = str; - } - return (1); + if (sizeof thr->arena - thr->top < len) + return (NULL); + ptr = thr->arena + thr->top; + thr->top += len; + return (ptr); } -#if 0 -static int -isequal(const char *str, const char *reference, const char *end) -{ - - while (str < end && *str && *reference && - tolower((int)*str) == tolower((int)*reference)) - ++str, ++reference; - if (str != end || *reference) - return (0); - return (1); -} -#endif - /* * Returns a copy of the entire string with leading and trailing spaces * trimmed. */ static char * -trimline(const char *str, const char *end) +trimline(struct thread *thr, const char *str) { size_t len; char *p; /* skip leading space */ - while (str < end && *str && *str == ' ') + while (*str && *str == ' ') ++str; /* seek to end of string */ - for (len = 0; &str[len] < end && str[len]; ++len) + for (len = 0; str[len]; ++len) /* nothing */ ; /* trim trailing space */ @@ -277,87 +341,45 @@ --len; /* copy and return */ - p = malloc(len + 1); - assert(p != NULL); + if ((p = thread_alloc(thr, len + 1)) == NULL) + return (NULL); memcpy(p, str, len); p[len] = '\0'; return (p); } -/* Initiate a connection to
by resolving the - * hostname and returning a struct with necessary - * connection info. - */ -static struct vss_addr * -init_connection(const char *address) -{ - struct vss_addr **ta; - struct vss_addr *tap; - char *addr, *port; - int i, n; - - if (VSS_parse(address, &addr, &port) != 0) { - thread_log(0, 0, "Invalid address"); - exit(2); - } - n = VSS_resolve(addr, port, &ta); - free(addr); - free(port); - if (n == 0) { - thread_log(0, 0, "Could not connect to server"); - exit(2); - } - for (i = 1; i < n; ++i) { - free(ta[i]); - ta[i] = NULL; - } - tap = ta[0]; - free(ta); - - return (tap); -} - /* Read a line from the socket and return the number of bytes read. * After returning, line will point to the read bytes in memory. * A line is terminated by \r\n */ static int -read_line(char **line, int sock) +read_line(struct thread *thr) { - char *buf; - unsigned nbuf, lbuf; - int i; + int i, len; - lbuf = 4096; - buf = malloc(lbuf); - XXXAN(buf); - nbuf = 0; + len = 0; while (1) { - if (nbuf + 2 >= lbuf) { - lbuf += lbuf; - buf = realloc(buf, lbuf); - XXXAN(buf); + if (len + 2 > sizeof thr->line) { + thread_log(0, 0, "overflow"); + return (-1); } - i = read(sock, buf + nbuf, 1); + i = read(thr->sock, thr->line + len, 1); if (i < 0) { thread_log(0, errno, "read(%d, %p, %d)", - sock, buf + nbuf, 1); - free(buf); + thr->sock, thr->line + len, 1); return (-1); } - if (i == 0) { - buf[nbuf] = '\0'; + if (i == 0) break; - } - nbuf += i; - if (nbuf >= 2 && buf[nbuf-2] == '\r' && buf[nbuf-1] == '\n') { - buf[nbuf-2] = '\0'; + len += i; + if (len >= 2 && thr->line[len - 2] == '\r' && + thr->line[len - 1] == '\n') { + len -= 2; break; } - } - *line = buf; - return (nbuf - 2); + thr->line[len] = '\0'; + return (len); } /* Read a block of data from the socket, and do nothing with it. @@ -365,36 +387,31 @@ * the number of bytes read. */ static int -read_block(int length, int sock) +read_block(struct thread *thr, int len) { - char *buf; - int len, n, nbuf; + int n, r, tot; - buf = malloc(length); - nbuf = 0; - while (nbuf < length) { - len = 2048 < length - nbuf ? 2048 : length - nbuf; - n = read(sock, buf + nbuf, len); - if (n < 0) { + for (tot = 0; tot < len; tot += r) { + n = len - tot; + if (n > sizeof thr->temp) + n = sizeof thr->temp; + r = read(thr->sock, thr->temp, n); + if (r < 0) { thread_log(0, errno, "read(%d, %p, %d)", - sock, buf + nbuf, len); - nbuf = -1; - break; + thr->sock, thr->temp, n); + return (-1); } - if (n == 0) + if (r == 0) break; - nbuf += n; } - free(buf); - return (nbuf); + return (tot); } /* Receive the response after sending a request. */ static int -receive_response(int sock) +receive_response(struct thread *thr) { - char *line, *end; const char *next; int line_len; long chunk_length, content_length; @@ -406,26 +423,22 @@ /* Read header */ for (;;) { - line_len = read_line(&line, sock); + line_len = read_line(thr); if (line_len < 0) return (-1); - thread_log(2, 0, "< %.*s", line_len, line); - end = line + line_len; - if (line_len == 0) { - freez(line); + thread_log(2, 0, "< %.*s", line_len, thr->line); + if (line_len == 0) break; - } - if (strncmp(line, "HTTP", 4) == 0) { - sscanf(line, "%*s %d %*s\r\n", &status); + if (strncmp(thr->line, "HTTP", 4) == 0) { + sscanf(thr->line, "%*s %d %*s\r\n", &status); failed = (status != 200); - } else if (isprefix(line, "content-length:", end, &next)) { + } else if (isprefix(thr->line, "content-length:", &next)) { content_length = strtol(next, NULL, 10); - } else if (isprefix(line, "transfer-encoding:", end, &next)) { + } else if (isprefix(thr->line, "transfer-encoding:", &next)) { chunked = (strcasecmp(next, "chunked") == 0); - } else if (isprefix(line, "connection:", end, &next)) { + } else if (isprefix(thr->line, "connection:", &next)) { connclose = (strcasecmp(next, "close") == 0); } - freez(line); } thread_log(1, 0, "status: %d", status); @@ -435,34 +448,33 @@ /* Chunked encoding, read size and bytes until no more */ thread_log(1, 0, "chunked encoding"); for (;;) { - if ((line_len = read_line(&line, sock)) < 0) + line_len = read_line(thr); + if (line_len < 0) return (-1); - end = line + line_len; /* read_line() guarantees null-termination */ - chunk_length = strtol(line, NULL, 16); - freez(line); + chunk_length = strtol(thr->line, NULL, 16); if (chunk_length == 0) break; - if ((n = read_block(chunk_length, sock)) < 0) + if ((n = read_block(thr, chunk_length)) < 0) return (-1); if (n < chunk_length) thread_log(0, 0, "short read: %d/%ld", n, chunk_length); thread_log(1, 0, "chunk length: %ld", chunk_length); thread_log(1, 0, "bytes read: %d", n); - /* trainling CR LF */ - if ((n = read_line(&line, sock)) < 0) + /* trailing CR LF */ + if ((n = read_line(thr)) < 0) return (-1); - freez(line); } /* trailing CR LF */ - n = read_line(&line, sock); - freez(line); + n = read_line(thr); + if (n < 0) + return (-1); } else if (content_length > 0) { /* Fixed body size, read content_length bytes */ thread_log(1, 0, "fixed length"); thread_log(1, 0, "content length: %ld", content_length); - if ((n = read_block(content_length, sock)) < 0) + if ((n = read_block(thr, content_length)) < 0) return (1); if (n < content_length) thread_log(0, 0, "short read: %d/%ld", @@ -487,62 +499,49 @@ enum shmlogtag tag; size_t len; char *ptr; - const char *end, *next; + const char *next; - char *df_method = NULL; /* Request method*/ - char *df_proto = NULL; /* Protocol version */ - char *df_url = NULL; /* URL and query string */ - char *df_conn = NULL; /* Connection info (keep-alive, close) */ - char **df_hdr = NULL; /* Headers */ - size_t df_hdrsz = 0; /* Size of df_hdr */ - int df_nhdr = 0; /* Number of headers */ - int bogus = 0; /* bogus request */ int i; - int sock = -1, reopen = 1; + int reopen = 1; - df_hdrsz = 16; - df_hdr = malloc(df_hdrsz * sizeof *df_hdr); - while ((msg = mailbox_get(&thr->mbox)) != NULL) { tag = msg->tag; len = msg->len; ptr = msg->ptr; - end = ptr + len; thread_log(2, 0, "%s(%s)", VSL_tags[tag], msg->ptr); switch (tag) { case SLT_RxRequest: - if (df_method != NULL) - bogus = 1; + if (thr->method != NULL) + thr->bogus = 1; else - df_method = trimline(ptr, end); + thr->method = trimline(thr, ptr); break; case SLT_RxURL: - if (df_url != NULL) - bogus = 1; + if (thr->url != NULL) + thr->bogus = 1; else - df_url = trimline(ptr, end); + thr->url = trimline(thr, ptr); break; case SLT_RxProtocol: - if (df_proto != NULL) - bogus = 1; + if (thr->proto != NULL) + thr->bogus = 1; else - df_proto = trimline(ptr, end); + thr->proto = trimline(thr, ptr); break; case SLT_RxHeader: - while (df_hdrsz <= df_nhdr) { - df_hdrsz *= 2; - df_hdr = realloc(df_hdr, df_hdrsz * sizeof *df_hdr); - XXXAN(df_hdr); + if (thr->nhdr >= sizeof thr->hdr / sizeof *thr->hdr) { + thr->bogus = 1; + } else { + thr->hdr[thr->nhdr++] = trimline(thr, ptr); + if (isprefix(ptr, "connection:", &next)) + thr->conn = trimline(thr, next); } - df_hdr[df_nhdr++] = trimline(ptr, end); - if (isprefix(ptr, "connection:", end, &next)) - df_conn = trimline(next, end); break; default: @@ -555,89 +554,81 @@ if (tag != SLT_ReqEnd) continue; - if (!df_method || !df_url || !df_proto) { - bogus = 1; - } else if (strcmp(df_method, "GET") != 0 && strcmp(df_method, "HEAD") != 0) { - bogus = 1; - } else if (strcmp(df_proto, "HTTP/1.0") == 0) { - reopen = !(df_conn && strcasecmp(df_conn, "keep-alive") == 0); - } else if (strcmp(df_proto, "HTTP/1.1") == 0) { - reopen = (df_conn && strcasecmp(df_conn, "close") == 0); + if (!thr->method || !thr->url || !thr->proto) { + thr->bogus = 1; + } else if (strcmp(thr->method, "GET") != 0 && strcmp(thr->method, "HEAD") != 0) { + thr->bogus = 1; + } else if (strcmp(thr->proto, "HTTP/1.0") == 0) { + reopen = !(thr->conn && strcasecmp(thr->conn, "keep-alive") == 0); + } else if (strcmp(thr->proto, "HTTP/1.1") == 0) { + reopen = (thr->conn && strcasecmp(thr->conn, "close") == 0); } else { - bogus = 1; + thr->bogus = 1; } - if (bogus) { + if (thr->bogus) { thread_log(1, 0, "bogus"); - } else { - if (sock == -1) { - thread_log(1, 0, "open"); - sock = VSS_connect(addr_info); - assert(sock != -1); + goto clear; + } + + if (thr->sock == -1) { + for (;;) { + thread_log(1, 0, "sleeping before connect..."); + usleep(1000 * (thr->fd % 3001)); + if ((thr->sock = VSS_connect(addr_info)) >= 0) + break; + thread_log(0, errno, "connect failed"); } + } - thread_log(1, 0, "%s %s %s", df_method, df_url, df_proto); + thread_log(1, 0, "%s %s %s", thr->method, thr->url, thr->proto); - iov[0].iov_base = df_method; - iov[0].iov_len = strlen(df_method); - iov[2].iov_base = df_url; - iov[2].iov_len = strlen(df_url); - iov[4].iov_base = df_proto; - iov[4].iov_len = strlen(df_proto); - iov[1].iov_base = iov[3].iov_base = space; - iov[1].iov_len = iov[3].iov_len = 1; - iov[5].iov_base = crlf; - iov[5].iov_len = 2; - if (writev(sock, iov, 6) == -1) { - thread_log(0, errno, "writev()"); - goto close; - } + iov[0].iov_base = thr->method; + iov[0].iov_len = strlen(thr->method); + iov[2].iov_base = thr->url; + iov[2].iov_len = strlen(thr->url); + iov[4].iov_base = thr->proto; + iov[4].iov_len = strlen(thr->proto); + iov[1].iov_base = iov[3].iov_base = space; + iov[1].iov_len = iov[3].iov_len = 1; + iov[5].iov_base = crlf; + iov[5].iov_len = 2; + if (writev(thr->sock, iov, 6) == -1) { + thread_log(0, errno, "writev()"); + goto close; + } - for (i = 0; i < df_nhdr; ++i) { - thread_log(2, 0, "%d %s", i, df_hdr[i]); - iov[0].iov_base = df_hdr[i]; - iov[0].iov_len = strlen(df_hdr[i]); - iov[1].iov_base = crlf; - iov[1].iov_len = 2; - if (writev(sock, iov, 2) == -1) { - thread_log(0, errno, "writev()"); - goto close; - } - } - if (write(sock, crlf, 2) == -1) { + for (i = 0; i < thr->nhdr; ++i) { + thread_log(2, 0, "%d %s", i, thr->hdr[i]); + iov[0].iov_base = thr->hdr[i]; + iov[0].iov_len = strlen(thr->hdr[i]); + iov[1].iov_base = crlf; + iov[1].iov_len = 2; + if (writev(thr->sock, iov, 2) == -1) { thread_log(0, errno, "writev()"); goto close; } - if (receive_response(sock) || reopen) { + } + if (write(thr->sock, crlf, 2) == -1) { + thread_log(0, errno, "writev()"); + goto close; + } + if (receive_response(thr) || reopen) { close: - thread_log(1, 0, "close"); - close(sock); - sock = -1; - } + thread_log(1, 0, "close"); + assert(thr->sock != -1); + close(thr->sock); + thr->sock = -1; } + sleep(1); +clear: /* clean up */ - freez(df_method); - freez(df_url); - freez(df_proto); - freez(df_conn); - while (df_nhdr) { - --df_nhdr; - freez(df_hdr[df_nhdr]); - } - bogus = 0; + thread_clear(thr); } /* leftovers */ - freez(df_method); - freez(df_url); - freez(df_proto); - freez(df_conn); - while (df_nhdr) { - --df_nhdr; - freez(df_hdr[df_nhdr]); - } - freez(df_hdr); + thread_clear(thr); return (0); } @@ -659,6 +650,8 @@ thread_log(3, 0, "%d %s", fd, VSL_tags[tag]); thr = thread_get(fd, replay_thread); + if (thr == NULL) + return (0); msg = malloc(sizeof (struct message)); msg->tag = tag; msg->len = len; @@ -668,6 +661,39 @@ return (0); } +/* Initiate a connection to
by resolving the + * hostname and returning a struct with necessary + * connection info. + */ +static struct vss_addr * +init_connection(const char *address) +{ + struct vss_addr **ta; + struct vss_addr *tap; + char *addr, *port; + int i, n; + + if (VSS_parse(address, &addr, &port) != 0) { + thread_log(0, 0, "Invalid address"); + exit(2); + } + n = VSS_resolve(addr, port, &ta); + free(addr); + free(port); + if (n == 0) { + thread_log(0, 0, "Could not connect to server"); + exit(2); + } + for (i = 1; i < n; ++i) { + free(ta[i]); + ta[i] = NULL; + } + tap = ta[0]; + free(ta); + + return (tap); +} + /*--------------------------------------------------------------------*/ static void @@ -715,8 +741,11 @@ signal(SIGPIPE, SIG_IGN); + pthread_attr_init(&thread_attr); + pthread_attr_setstacksize(&thread_attr, 16384); + while (VSL_Dispatch(vd, gen_traffic, NULL) == 0) /* nothing */ ; - thread_close(0); + thread_close(-1); exit(0); } From des at projects.linpro.no Mon Jun 30 02:29:12 2008 From: des at projects.linpro.no (des at projects.linpro.no) Date: Mon, 30 Jun 2008 04:29:12 +0200 (CEST) Subject: r2865 - branches/1.1 Message-ID: <20080630022912.24DE61ED24A@projects.linpro.no> Author: des Date: 2008-06-30 04:29:11 +0200 (Mon, 30 Jun 2008) New Revision: 2865 Modified: branches/1.1/ Log: Merged revisions 2180,2191-2193 via svnmerge from svn+ssh://projects.linpro.no/svn/varnish/trunk/varnish-cache ........ r2180 | phk | 2007-10-29 09:24:04 +0100 (Mon, 29 Oct 2007) | 2 lines Mask negative characters to 8 bit before formatting. ........ r2193 | des | 2007-10-30 11:48:30 +0100 (Tue, 30 Oct 2007) | 2 lines Use a cast to prevent sign extension instead of masking it off after the fact. ........ Property changes on: branches/1.1 ___________________________________________________________________ Name: svnmerge-integrated - /trunk/varnish-cache:1-1722,1727-1729,1733,1738,1743-1777,1779-1798,1800-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865-1868,1871-1880,1883-1884,1886,1888-1889,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949,1955,1957-1958,1967-1968,1970-1974,1976-1977,1984,1986-1989,1991-1998,2026,2031-2033,2057,2077-2080,2086,2088,2091,2097,2106-2107,2116,2133,2154,2173,2181,2206-2207,2211-2212,2215-2245,2256-2262,2270-2271,2275,2285-2286,2288-2291,2295-2301,2304-2327,2337,2357-2359,2361-2364,2366,2374-2386,2404,2414-2415,2421-2422,2426,2432-2434,2444-2445,2447,2453-2461,2467,2492-2505,2520-2524,2545,2563-2565,2569,2572,2575-2577 + /trunk/varnish-cache:1-1722,1727-1729,1733,1738,1743-1777,1779-1798,1800-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865-1868,1871-1880,1883-1884,1886,1888-1889,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949,1955,1957-1958,1967-1968,1970-1974,1976-1977,1984,1986-1989,1991-1998,2026,2031-2033,2057,2077-2080,2086,2088,2091,2097,2106-2107,2116,2133,2154,2173,2180-2181,2191-2193,2206-2207,2211-2212,2215-2245,2256-2262,2270-2271,2275,2285-2286,2288-2291,2295-2301,2304-2327,2337,2357-2359,2361-2364,2366,2374-2386,2404,2414-2415,2421-2422,2426,2432-2434,2444-2445,2447,2453-2461,2467,2492-2505,2520-2524,2545,2563-2565,2569,2572,2575-2577 From des at projects.linpro.no Mon Jun 30 02:29:59 2008 From: des at projects.linpro.no (des at projects.linpro.no) Date: Mon, 30 Jun 2008 04:29:59 +0200 (CEST) Subject: r2866 - branches/1.1 Message-ID: <20080630022959.A4A311EC11A@projects.linpro.no> Author: des Date: 2008-06-30 04:29:59 +0200 (Mon, 30 Jun 2008) New Revision: 2866 Modified: branches/1.1/ Log: Merged revisions 2443 via svnmerge from svn+ssh://projects.linpro.no/svn/varnish/trunk/varnish-cache ........ r2443 | phk | 2008-02-09 16:59:21 +0100 (Sat, 09 Feb 2008) | 2 lines required by ........ Property changes on: branches/1.1 ___________________________________________________________________ Name: svnmerge-integrated - /trunk/varnish-cache:1-1722,1727-1729,1733,1738,1743-1777,1779-1798,1800-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865-1868,1871-1880,1883-1884,1886,1888-1889,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949,1955,1957-1958,1967-1968,1970-1974,1976-1977,1984,1986-1989,1991-1998,2026,2031-2033,2057,2077-2080,2086,2088,2091,2097,2106-2107,2116,2133,2154,2173,2180-2181,2191-2193,2206-2207,2211-2212,2215-2245,2256-2262,2270-2271,2275,2285-2286,2288-2291,2295-2301,2304-2327,2337,2357-2359,2361-2364,2366,2374-2386,2404,2414-2415,2421-2422,2426,2432-2434,2444-2445,2447,2453-2461,2467,2492-2505,2520-2524,2545,2563-2565,2569,2572,2575-2577 + /trunk/varnish-cache:1-1722,1727-1729,1733,1738,1743-1777,1779-1798,1800-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865-1868,1871-1880,1883-1884,1886,1888-1889,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949,1955,1957-1958,1967-1968,1970-1974,1976-1977,1984,1986-1989,1991-1998,2026,2031-2033,2057,2077-2080,2086,2088,2091,2097,2106-2107,2116,2133,2154,2173,2180-2181,2191-2193,2206-2207,2211-2212,2215-2245,2256-2262,2270-2271,2275,2285-2286,2288-2291,2295-2301,2304-2327,2337,2357-2359,2361-2364,2366,2374-2386,2404,2414-2415,2421-2422,2426,2432-2434,2443-2445,2447,2453-2461,2467,2492-2505,2520-2524,2545,2563-2565,2569,2572,2575-2577 From des at projects.linpro.no Mon Jun 30 02:32:07 2008 From: des at projects.linpro.no (des at projects.linpro.no) Date: Mon, 30 Jun 2008 04:32:07 +0200 (CEST) Subject: r2867 - in branches/1.1: . lib/libvarnishapi Message-ID: <20080630023207.32E001EC220@projects.linpro.no> Author: des Date: 2008-06-30 04:32:07 +0200 (Mon, 30 Jun 2008) New Revision: 2867 Modified: branches/1.1/ branches/1.1/lib/libvarnishapi/shmlog.c Log: Merged revisions 2862 via svnmerge from svn+ssh://projects.linpro.no/svn/varnish/trunk/varnish-cache ........ r2862 | des | 2008-06-30 03:44:33 +0200 (Mon, 30 Jun 2008) | 2 lines The correct return value when we reach the end is -1, not 0. ........ Property changes on: branches/1.1 ___________________________________________________________________ Name: svnmerge-integrated - /trunk/varnish-cache:1-1722,1727-1729,1733,1738,1743-1777,1779-1798,1800-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865-1868,1871-1880,1883-1884,1886,1888-1889,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949,1955,1957-1958,1967-1968,1970-1974,1976-1977,1984,1986-1989,1991-1998,2026,2031-2033,2057,2077-2080,2086,2088,2091,2097,2106-2107,2116,2133,2154,2173,2180-2181,2191-2193,2206-2207,2211-2212,2215-2245,2256-2262,2270-2271,2275,2285-2286,2288-2291,2295-2301,2304-2327,2337,2357-2359,2361-2364,2366,2374-2386,2404,2414-2415,2421-2422,2426,2432-2434,2443-2445,2447,2453-2461,2467,2492-2505,2520-2524,2545,2563-2565,2569,2572,2575-2577 + /trunk/varnish-cache:1-1722,1727-1729,1733,1738,1743-1777,1779-1798,1800-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865-1868,1871-1880,1883-1884,1886,1888-1889,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949,1955,1957-1958,1967-1968,1970-1974,1976-1977,1984,1986-1989,1991-1998,2026,2031-2033,2057,2077-2080,2086,2088,2091,2097,2106-2107,2116,2133,2154,2173,2180-2181,2191-2193,2206-2207,2211-2212,2215-2245,2256-2262,2270-2271,2275,2285-2286,2288-2291,2295-2301,2304-2327,2337,2357-2359,2361-2364,2366,2374-2386,2404,2414-2415,2421-2422,2426,2432-2434,2443-2445,2447,2453-2461,2467,2492-2505,2520-2524,2545,2563-2565,2569,2572,2575-2577,2862 Modified: branches/1.1/lib/libvarnishapi/shmlog.c =================================================================== --- branches/1.1/lib/libvarnishapi/shmlog.c 2008-06-30 02:29:59 UTC (rev 2866) +++ branches/1.1/lib/libvarnishapi/shmlog.c 2008-06-30 02:32:07 UTC (rev 2867) @@ -297,7 +297,7 @@ continue; } else if (vd->keep) { if (--vd->keep == 0) - return (0); + return (-1); } if (vd->map[p[0]] & M_SELECT) { *pp = p; From des at projects.linpro.no Mon Jun 30 02:39:11 2008 From: des at projects.linpro.no (des at projects.linpro.no) Date: Mon, 30 Jun 2008 04:39:11 +0200 (CEST) Subject: r2868 - in branches/1.1: . lib/libvarnishapi Message-ID: <20080630023911.A86F41EC11A@projects.linpro.no> Author: des Date: 2008-06-30 04:39:11 +0200 (Mon, 30 Jun 2008) New Revision: 2868 Modified: branches/1.1/ branches/1.1/lib/libvarnishapi/shmlog.c Log: Merged revisions 2863 via svnmerge from svn+ssh://projects.linpro.no/svn/varnish/trunk/varnish-cache ........ r2863 | des | 2008-06-30 04:03:58 +0200 (Mon, 30 Jun 2008) | 2 lines Convert from FILE * to fd. ........ Property changes on: branches/1.1 ___________________________________________________________________ Name: svnmerge-integrated - /trunk/varnish-cache:1-1722,1727-1729,1733,1738,1743-1777,1779-1798,1800-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865-1868,1871-1880,1883-1884,1886,1888-1889,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949,1955,1957-1958,1967-1968,1970-1974,1976-1977,1984,1986-1989,1991-1998,2026,2031-2033,2057,2077-2080,2086,2088,2091,2097,2106-2107,2116,2133,2154,2173,2180-2181,2191-2193,2206-2207,2211-2212,2215-2245,2256-2262,2270-2271,2275,2285-2286,2288-2291,2295-2301,2304-2327,2337,2357-2359,2361-2364,2366,2374-2386,2404,2414-2415,2421-2422,2426,2432-2434,2443-2445,2447,2453-2461,2467,2492-2505,2520-2524,2545,2563-2565,2569,2572,2575-2577,2862 + /trunk/varnish-cache:1-1722,1727-1729,1733,1738,1743-1777,1779-1798,1800-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865-1868,1871-1880,1883-1884,1886,1888-1889,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949,1955,1957-1958,1967-1968,1970-1974,1976-1977,1984,1986-1989,1991-1998,2026,2031-2033,2057,2077-2080,2086,2088,2091,2097,2106-2107,2116,2133,2154,2173,2180-2181,2191-2193,2206-2207,2211-2212,2215-2245,2256-2262,2270-2271,2275,2285-2286,2288-2291,2295-2301,2304-2327,2337,2357-2359,2361-2364,2366,2374-2386,2404,2414-2415,2421-2422,2426,2432-2434,2443-2445,2447,2453-2461,2467,2492-2505,2520-2524,2545,2563-2565,2569,2572,2575-2577,2862-2863 Modified: branches/1.1/lib/libvarnishapi/shmlog.c =================================================================== --- branches/1.1/lib/libvarnishapi/shmlog.c 2008-06-30 02:32:07 UTC (rev 2867) +++ branches/1.1/lib/libvarnishapi/shmlog.c 2008-06-30 02:39:11 UTC (rev 2868) @@ -65,7 +65,7 @@ unsigned char *ptr; /* for -r option */ - FILE *fi; + int fd; unsigned char rbuf[5 + 255 + 1]; int b_opt; @@ -171,6 +171,7 @@ assert(vd != NULL); vd->regflags = REG_EXTENDED | REG_NOSUB; vd->magic = VSL_MAGIC; + vd->fd = -1; return (vd); } @@ -192,7 +193,7 @@ unsigned char *p; CHECK_OBJ_NOTNULL(vd, VSL_MAGIC); - if (vd->fi != NULL) + if (vd->fd != -1) return (0); if (vsl_shmem_map(varnish_name)) @@ -203,7 +204,7 @@ vd->logend = vd->logstart + vsl_lh->size; vd->ptr = vd->logstart; - if (!vd->d_opt && vd->fi == NULL) { + if (!vd->d_opt && vd->fd == -1) { for (p = vd->ptr; *p != SLT_ENDMARKER; ) p += p[1] + 5; vd->ptr = p; @@ -232,12 +233,12 @@ int i; CHECK_OBJ_NOTNULL(vd, VSL_MAGIC); - if (vd->fi != NULL) { - i = fread(vd->rbuf, 4, 1, vd->fi); - if (i != 1) + if (vd->fd != -1) { + i = read(vd->fd, vd->rbuf, 4); + if (i != 4) return (-1); - i = fread(vd->rbuf + 4, vd->rbuf[1] + 1, 1, vd->fi); - if (i != 1) + i = read(vd->fd, vd->rbuf + 4, vd->rbuf[1] + 1); + if (i != vd->rbuf[1] + 1) return (-1); *pp = vd->rbuf; return (1); @@ -387,13 +388,14 @@ CHECK_OBJ_NOTNULL(vd, VSL_MAGIC); if (!strcmp(opt, "-")) - vd->fi = stdin; + vd->fd = STDIN_FILENO; else - vd->fi = fopen(opt, "r"); - if (vd->fi != NULL) - return (1); - perror(opt); - return (-1); + vd->fd = open(opt, O_RDONLY); + if (vd->fd < 0) { + perror(opt); + return (-1); + } + return (1); } /*--------------------------------------------------------------------*/ From des at projects.linpro.no Mon Jun 30 02:41:02 2008 From: des at projects.linpro.no (des at projects.linpro.no) Date: Mon, 30 Jun 2008 04:41:02 +0200 (CEST) Subject: r2869 - in branches/1.1: . bin/varnishreplay Message-ID: <20080630024102.5172C1EC220@projects.linpro.no> Author: des Date: 2008-06-30 04:41:02 +0200 (Mon, 30 Jun 2008) New Revision: 2869 Modified: branches/1.1/ branches/1.1/bin/varnishreplay/varnishreplay.c Log: Merged revisions 2864 via svnmerge from svn+ssh://projects.linpro.no/svn/varnish/trunk/varnish-cache ........ r2864 | des | 2008-06-30 04:11:54 +0200 (Mon, 30 Jun 2008) | 3 lines Old patch: greatly improve performance and memory usage by using per-thread pre-allocated buffers instead of malloc(). ........ Property changes on: branches/1.1 ___________________________________________________________________ Name: svnmerge-integrated - /trunk/varnish-cache:1-1722,1727-1729,1733,1738,1743-1777,1779-1798,1800-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865-1868,1871-1880,1883-1884,1886,1888-1889,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949,1955,1957-1958,1967-1968,1970-1974,1976-1977,1984,1986-1989,1991-1998,2026,2031-2033,2057,2077-2080,2086,2088,2091,2097,2106-2107,2116,2133,2154,2173,2180-2181,2191-2193,2206-2207,2211-2212,2215-2245,2256-2262,2270-2271,2275,2285-2286,2288-2291,2295-2301,2304-2327,2337,2357-2359,2361-2364,2366,2374-2386,2404,2414-2415,2421-2422,2426,2432-2434,2443-2445,2447,2453-2461,2467,2492-2505,2520-2524,2545,2563-2565,2569,2572,2575-2577,2862-2863 + /trunk/varnish-cache:1-1722,1727-1729,1733,1738,1743-1777,1779-1798,1800-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865-1868,1871-1880,1883-1884,1886,1888-1889,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949,1955,1957-1958,1967-1968,1970-1974,1976-1977,1984,1986-1989,1991-1998,2026,2031-2033,2057,2077-2080,2086,2088,2091,2097,2106-2107,2116,2133,2154,2173,2180-2181,2191-2193,2206-2207,2211-2212,2215-2245,2256-2262,2270-2271,2275,2285-2286,2288-2291,2295-2301,2304-2327,2337,2357-2359,2361-2364,2366,2374-2386,2404,2414-2415,2421-2422,2426,2432-2434,2443-2445,2447,2453-2461,2467,2492-2505,2520-2524,2545,2563-2565,2569,2572,2575-2577,2862-2864 Modified: branches/1.1/bin/varnishreplay/varnishreplay.c =================================================================== --- branches/1.1/bin/varnishreplay/varnishreplay.c 2008-06-30 02:39:11 UTC (rev 2868) +++ branches/1.1/bin/varnishreplay/varnishreplay.c 2008-06-30 02:41:02 UTC (rev 2869) @@ -57,6 +57,37 @@ static struct vss_addr *addr_info; static int debug; +static int +isprefix(const char *str, const char *prefix, const char **next) +{ + + while (*str && *prefix && + tolower((int)*str) == tolower((int)*prefix)) + ++str, ++prefix; + if (*str && *str != ' ') + return (0); + if (next) { + while (*str && *str == ' ') + ++str; + *next = str; + } + return (1); +} + +#if 0 +static int +isequal(const char *str, const char *reference, const char *end) +{ + + while (str < end && *str && *reference && + tolower((int)*str) == tolower((int)*reference)) + ++str, ++reference; + if (str != end || *reference) + return (0); + return (1); +} +#endif + /* * mailbox toolkit */ @@ -68,6 +99,8 @@ VSTAILQ_ENTRY(message) list; }; +#define MAX_MAILBOX_SIZE 30 + struct mailbox { pthread_mutex_t lock; pthread_cond_t has_mail; @@ -135,11 +168,6 @@ * thread toolkit */ -struct thread { - pthread_t thread_id; - struct mailbox mbox; -}; - static pthread_mutex_t log_mutex = PTHREAD_MUTEX_INITIALIZER; static void @@ -160,9 +188,56 @@ pthread_mutex_unlock(&log_mutex); } +struct thread { + pthread_t thread_id; + struct mailbox mbox; + + int sock; + + int fd; /* original fd from logs */ + + char *method; /* Request method*/ + char *proto; /* Protocol version */ + char *url; /* URL and query string */ + const char *conn; /* Connection info (keep-alive, close) */ + char *hdr[64]; /* Headers */ + int nhdr; /* Number of headers */ + int bogus; /* bogus request */ + + char arena[4096]; + int top; + char line[2048]; + char temp[2048]; +}; + static struct thread **threads; static size_t nthreads; +/* + * Clear thread state + */ +static void +thread_clear(struct thread *thr) +{ + + thr->method = thr->proto = thr->url = NULL; + thr->conn = NULL; + memset(&thr->hdr, 0, sizeof thr->hdr); + thr->nhdr = 0; + thr->bogus = 0; + memset(&thr->arena, 0, sizeof thr->arena); + thr->top = 0; + memset(&thr->line, 0, sizeof thr->line); + memset(&thr->temp, 0, sizeof thr->temp); + if (thr->sock != -1) + close(thr->sock); + thr->sock = -1; +} + +#define THREAD_FAIL ((struct thread *)-1) + +static pthread_attr_t thread_attr; + static struct thread * thread_get(int fd, void *(*thread_main)(void *)) { @@ -184,16 +259,23 @@ if (threads[fd] == NULL) { threads[fd] = malloc(sizeof *threads[fd]); assert(threads[fd] != NULL); + threads[fd]->sock = -1; + thread_clear(threads[fd]); mailbox_create(&threads[fd]->mbox); - if (pthread_create(&threads[fd]->thread_id, NULL, + if (pthread_create(&threads[fd]->thread_id, &thread_attr, thread_main, threads[fd]) != 0) { thread_log(0, errno, "pthread_create()"); mailbox_destroy(&threads[fd]->mbox); freez(threads[fd]); + threads[fd] = THREAD_FAIL; + } else { + threads[fd]->fd = fd; + thread_log(0, 0, "thread %p:%d started", + (void *)threads[fd]->thread_id, fd); } - thread_log(0, 0, "thread %p started", - (void *)threads[fd]->thread_id); } + if (threads[fd] == THREAD_FAIL) + return (NULL); return (threads[fd]); } @@ -201,74 +283,56 @@ thread_close(int fd) { - assert(fd == 0 || fd < nthreads); - if (fd == 0) { - for (fd = 1; fd < nthreads; ++fd) + if (fd == -1) { + for (fd = 0; fd < nthreads; ++fd) thread_close(fd); return; } + assert(fd < nthreads); + if (threads[fd] == NULL) return; mailbox_close(&threads[fd]->mbox); pthread_join(threads[fd]->thread_id, NULL); thread_log(0, 0, "thread %p stopped", (void *)threads[fd]->thread_id); + thread_clear(threads[fd]); mailbox_destroy(&threads[fd]->mbox); freez(threads[fd]); } /* - * ... + * Allocate from thread arena */ - -static int -isprefix(const char *str, const char *prefix, const char *end, const char **next) +static void * +thread_alloc(struct thread *thr, size_t len) { + void *ptr; - while (str < end && *str && *prefix && - tolower((int)*str) == tolower((int)*prefix)) - ++str, ++prefix; - if (*str && *str != ' ') - return (0); - if (next) { - while (str < end && *str && *str == ' ') - ++str; - *next = str; - } - return (1); + if (sizeof thr->arena - thr->top < len) + return (NULL); + ptr = thr->arena + thr->top; + thr->top += len; + return (ptr); } -#if 0 -static int -isequal(const char *str, const char *reference, const char *end) -{ - - while (str < end && *str && *reference && - tolower((int)*str) == tolower((int)*reference)) - ++str, ++reference; - if (str != end || *reference) - return (0); - return (1); -} -#endif - /* * Returns a copy of the entire string with leading and trailing spaces * trimmed. */ static char * -trimline(const char *str, const char *end) +trimline(struct thread *thr, const char *str) { size_t len; char *p; /* skip leading space */ - while (str < end && *str && *str == ' ') + while (*str && *str == ' ') ++str; /* seek to end of string */ - for (len = 0; &str[len] < end && str[len]; ++len) + for (len = 0; str[len]; ++len) /* nothing */ ; /* trim trailing space */ @@ -276,87 +340,45 @@ --len; /* copy and return */ - p = malloc(len + 1); - assert(p != NULL); + if ((p = thread_alloc(thr, len + 1)) == NULL) + return (NULL); memcpy(p, str, len); p[len] = '\0'; return (p); } -/* Initiate a connection to
by resolving the - * hostname and returning a struct with necessary - * connection info. - */ -static struct vss_addr * -init_connection(const char *address) -{ - struct vss_addr **ta; - struct vss_addr *tap; - char *addr, *port; - int i, n; - - if (VSS_parse(address, &addr, &port) != 0) { - thread_log(0, 0, "Invalid address"); - exit(2); - } - n = VSS_resolve(addr, port, &ta); - free(addr); - free(port); - if (n == 0) { - thread_log(0, 0, "Could not connect to server"); - exit(2); - } - for (i = 1; i < n; ++i) { - free(ta[i]); - ta[i] = NULL; - } - tap = ta[0]; - free(ta); - - return (tap); -} - /* Read a line from the socket and return the number of bytes read. * After returning, line will point to the read bytes in memory. * A line is terminated by \r\n */ static int -read_line(char **line, int sock) +read_line(struct thread *thr) { - char *buf; - unsigned nbuf, lbuf; - int i; + int i, len; - lbuf = 4096; - buf = malloc(lbuf); - XXXAN(buf); - nbuf = 0; + len = 0; while (1) { - if (nbuf + 2 >= lbuf) { - lbuf += lbuf; - buf = realloc(buf, lbuf); - XXXAN(buf); + if (len + 2 > sizeof thr->line) { + thread_log(0, 0, "overflow"); + return (-1); } - i = read(sock, buf + nbuf, 1); + i = read(thr->sock, thr->line + len, 1); if (i < 0) { thread_log(0, errno, "read(%d, %p, %d)", - sock, buf + nbuf, 1); - free(buf); + thr->sock, thr->line + len, 1); return (-1); } - if (i == 0) { - buf[nbuf] = '\0'; + if (i == 0) break; - } - nbuf += i; - if (nbuf >= 2 && buf[nbuf-2] == '\r' && buf[nbuf-1] == '\n') { - buf[nbuf-2] = '\0'; + len += i; + if (len >= 2 && thr->line[len - 2] == '\r' && + thr->line[len - 1] == '\n') { + len -= 2; break; } - } - *line = buf; - return (nbuf - 2); + thr->line[len] = '\0'; + return (len); } /* Read a block of data from the socket, and do nothing with it. @@ -364,36 +386,31 @@ * the number of bytes read. */ static int -read_block(int length, int sock) +read_block(struct thread *thr, int len) { - char *buf; - int len, n, nbuf; + int n, r, tot; - buf = malloc(length); - nbuf = 0; - while (nbuf < length) { - len = 2048 < length - nbuf ? 2048 : length - nbuf; - n = read(sock, buf + nbuf, len); - if (n < 0) { + for (tot = 0; tot < len; tot += r) { + n = len - tot; + if (n > sizeof thr->temp) + n = sizeof thr->temp; + r = read(thr->sock, thr->temp, n); + if (r < 0) { thread_log(0, errno, "read(%d, %p, %d)", - sock, buf + nbuf, len); - nbuf = -1; - break; + thr->sock, thr->temp, n); + return (-1); } - if (n == 0) + if (r == 0) break; - nbuf += n; } - free(buf); - return (nbuf); + return (tot); } /* Receive the response after sending a request. */ static int -receive_response(int sock) +receive_response(struct thread *thr) { - char *line, *end; const char *next; int line_len; long chunk_length, content_length; @@ -405,26 +422,22 @@ /* Read header */ for (;;) { - line_len = read_line(&line, sock); + line_len = read_line(thr); if (line_len < 0) return (-1); - thread_log(2, 0, "< %.*s", line_len, line); - end = line + line_len; - if (line_len == 0) { - freez(line); + thread_log(2, 0, "< %.*s", line_len, thr->line); + if (line_len == 0) break; - } - if (strncmp(line, "HTTP", 4) == 0) { - sscanf(line, "%*s %d %*s\r\n", &status); + if (strncmp(thr->line, "HTTP", 4) == 0) { + sscanf(thr->line, "%*s %d %*s\r\n", &status); failed = (status != 200); - } else if (isprefix(line, "content-length:", end, &next)) { + } else if (isprefix(thr->line, "content-length:", &next)) { content_length = strtol(next, NULL, 10); - } else if (isprefix(line, "transfer-encoding:", end, &next)) { + } else if (isprefix(thr->line, "transfer-encoding:", &next)) { chunked = (strcasecmp(next, "chunked") == 0); - } else if (isprefix(line, "connection:", end, &next)) { + } else if (isprefix(thr->line, "connection:", &next)) { connclose = (strcasecmp(next, "close") == 0); } - freez(line); } thread_log(1, 0, "status: %d", status); @@ -434,34 +447,33 @@ /* Chunked encoding, read size and bytes until no more */ thread_log(1, 0, "chunked encoding"); for (;;) { - if ((line_len = read_line(&line, sock)) < 0) + line_len = read_line(thr); + if (line_len < 0) return (-1); - end = line + line_len; /* read_line() guarantees null-termination */ - chunk_length = strtol(line, NULL, 16); - freez(line); + chunk_length = strtol(thr->line, NULL, 16); if (chunk_length == 0) break; - if ((n = read_block(chunk_length, sock)) < 0) + if ((n = read_block(thr, chunk_length)) < 0) return (-1); if (n < chunk_length) thread_log(0, 0, "short read: %d/%ld", n, chunk_length); thread_log(1, 0, "chunk length: %ld", chunk_length); thread_log(1, 0, "bytes read: %d", n); - /* trainling CR LF */ - if ((n = read_line(&line, sock)) < 0) + /* trailing CR LF */ + if ((n = read_line(thr)) < 0) return (-1); - freez(line); } /* trailing CR LF */ - n = read_line(&line, sock); - freez(line); + n = read_line(thr); + if (n < 0) + return (-1); } else if (content_length > 0) { /* Fixed body size, read content_length bytes */ thread_log(1, 0, "fixed length"); thread_log(1, 0, "content length: %ld", content_length); - if ((n = read_block(content_length, sock)) < 0) + if ((n = read_block(thr, content_length)) < 0) return (1); if (n < content_length) thread_log(0, 0, "short read: %d/%ld", @@ -486,62 +498,49 @@ enum shmlogtag tag; size_t len; char *ptr; - const char *end, *next; + const char *next; - char *df_method = NULL; /* Request method*/ - char *df_proto = NULL; /* Protocol version */ - char *df_url = NULL; /* URL and query string */ - char *df_conn = NULL; /* Connection info (keep-alive, close) */ - char **df_hdr = NULL; /* Headers */ - size_t df_hdrsz = 0; /* Size of df_hdr */ - int df_nhdr = 0; /* Number of headers */ - int bogus = 0; /* bogus request */ int i; - int sock = -1, reopen = 1; + int reopen = 1; - df_hdrsz = 16; - df_hdr = malloc(df_hdrsz * sizeof *df_hdr); - while ((msg = mailbox_get(&thr->mbox)) != NULL) { tag = msg->tag; len = msg->len; ptr = msg->ptr; - end = ptr + len; thread_log(2, 0, "%s(%s)", VSL_tags[tag], msg->ptr); switch (tag) { case SLT_RxRequest: - if (df_method != NULL) - bogus = 1; + if (thr->method != NULL) + thr->bogus = 1; else - df_method = trimline(ptr, end); + thr->method = trimline(thr, ptr); break; case SLT_RxURL: - if (df_url != NULL) - bogus = 1; + if (thr->url != NULL) + thr->bogus = 1; else - df_url = trimline(ptr, end); + thr->url = trimline(thr, ptr); break; case SLT_RxProtocol: - if (df_proto != NULL) - bogus = 1; + if (thr->proto != NULL) + thr->bogus = 1; else - df_proto = trimline(ptr, end); + thr->proto = trimline(thr, ptr); break; case SLT_RxHeader: - while (df_hdrsz <= df_nhdr) { - df_hdrsz *= 2; - df_hdr = realloc(df_hdr, df_hdrsz * sizeof *df_hdr); - XXXAN(df_hdr); + if (thr->nhdr >= sizeof thr->hdr / sizeof *thr->hdr) { + thr->bogus = 1; + } else { + thr->hdr[thr->nhdr++] = trimline(thr, ptr); + if (isprefix(ptr, "connection:", &next)) + thr->conn = trimline(thr, next); } - df_hdr[df_nhdr++] = trimline(ptr, end); - if (isprefix(ptr, "connection:", end, &next)) - df_conn = trimline(next, end); break; default: @@ -554,89 +553,81 @@ if (tag != SLT_ReqEnd) continue; - if (!df_method || !df_url || !df_proto) { - bogus = 1; - } else if (strcmp(df_method, "GET") != 0 && strcmp(df_method, "HEAD") != 0) { - bogus = 1; - } else if (strcmp(df_proto, "HTTP/1.0") == 0) { - reopen = !(df_conn && strcasecmp(df_conn, "keep-alive") == 0); - } else if (strcmp(df_proto, "HTTP/1.1") == 0) { - reopen = (df_conn && strcasecmp(df_conn, "close") == 0); + if (!thr->method || !thr->url || !thr->proto) { + thr->bogus = 1; + } else if (strcmp(thr->method, "GET") != 0 && strcmp(thr->method, "HEAD") != 0) { + thr->bogus = 1; + } else if (strcmp(thr->proto, "HTTP/1.0") == 0) { + reopen = !(thr->conn && strcasecmp(thr->conn, "keep-alive") == 0); + } else if (strcmp(thr->proto, "HTTP/1.1") == 0) { + reopen = (thr->conn && strcasecmp(thr->conn, "close") == 0); } else { - bogus = 1; + thr->bogus = 1; } - if (bogus) { + if (thr->bogus) { thread_log(1, 0, "bogus"); - } else { - if (sock == -1) { - thread_log(1, 0, "open"); - sock = VSS_connect(addr_info); - assert(sock != -1); + goto clear; + } + + if (thr->sock == -1) { + for (;;) { + thread_log(1, 0, "sleeping before connect..."); + usleep(1000 * (thr->fd % 3001)); + if ((thr->sock = VSS_connect(addr_info)) >= 0) + break; + thread_log(0, errno, "connect failed"); } + } - thread_log(1, 0, "%s %s %s", df_method, df_url, df_proto); + thread_log(1, 0, "%s %s %s", thr->method, thr->url, thr->proto); - iov[0].iov_base = df_method; - iov[0].iov_len = strlen(df_method); - iov[2].iov_base = df_url; - iov[2].iov_len = strlen(df_url); - iov[4].iov_base = df_proto; - iov[4].iov_len = strlen(df_proto); - iov[1].iov_base = iov[3].iov_base = space; - iov[1].iov_len = iov[3].iov_len = 1; - iov[5].iov_base = crlf; - iov[5].iov_len = 2; - if (writev(sock, iov, 6) == -1) { - thread_log(0, errno, "writev()"); - goto close; - } + iov[0].iov_base = thr->method; + iov[0].iov_len = strlen(thr->method); + iov[2].iov_base = thr->url; + iov[2].iov_len = strlen(thr->url); + iov[4].iov_base = thr->proto; + iov[4].iov_len = strlen(thr->proto); + iov[1].iov_base = iov[3].iov_base = space; + iov[1].iov_len = iov[3].iov_len = 1; + iov[5].iov_base = crlf; + iov[5].iov_len = 2; + if (writev(thr->sock, iov, 6) == -1) { + thread_log(0, errno, "writev()"); + goto close; + } - for (i = 0; i < df_nhdr; ++i) { - thread_log(2, 0, "%d %s", i, df_hdr[i]); - iov[0].iov_base = df_hdr[i]; - iov[0].iov_len = strlen(df_hdr[i]); - iov[1].iov_base = crlf; - iov[1].iov_len = 2; - if (writev(sock, iov, 2) == -1) { - thread_log(0, errno, "writev()"); - goto close; - } - } - if (write(sock, crlf, 2) == -1) { + for (i = 0; i < thr->nhdr; ++i) { + thread_log(2, 0, "%d %s", i, thr->hdr[i]); + iov[0].iov_base = thr->hdr[i]; + iov[0].iov_len = strlen(thr->hdr[i]); + iov[1].iov_base = crlf; + iov[1].iov_len = 2; + if (writev(thr->sock, iov, 2) == -1) { thread_log(0, errno, "writev()"); goto close; } - if (receive_response(sock) || reopen) { + } + if (write(thr->sock, crlf, 2) == -1) { + thread_log(0, errno, "writev()"); + goto close; + } + if (receive_response(thr) || reopen) { close: - thread_log(1, 0, "close"); - close(sock); - sock = -1; - } + thread_log(1, 0, "close"); + assert(thr->sock != -1); + close(thr->sock); + thr->sock = -1; } + sleep(1); +clear: /* clean up */ - freez(df_method); - freez(df_url); - freez(df_proto); - freez(df_conn); - while (df_nhdr) { - --df_nhdr; - freez(df_hdr[df_nhdr]); - } - bogus = 0; + thread_clear(thr); } /* leftovers */ - freez(df_method); - freez(df_url); - freez(df_proto); - freez(df_conn); - while (df_nhdr) { - --df_nhdr; - freez(df_hdr[df_nhdr]); - } - freez(df_hdr); + thread_clear(thr); return (0); } @@ -658,6 +649,8 @@ thread_log(3, 0, "%d %s", fd, VSL_tags[tag]); thr = thread_get(fd, replay_thread); + if (thr == NULL) + return (0); msg = malloc(sizeof (struct message)); msg->tag = tag; msg->len = len; @@ -667,6 +660,39 @@ return (0); } +/* Initiate a connection to
by resolving the + * hostname and returning a struct with necessary + * connection info. + */ +static struct vss_addr * +init_connection(const char *address) +{ + struct vss_addr **ta; + struct vss_addr *tap; + char *addr, *port; + int i, n; + + if (VSS_parse(address, &addr, &port) != 0) { + thread_log(0, 0, "Invalid address"); + exit(2); + } + n = VSS_resolve(addr, port, &ta); + free(addr); + free(port); + if (n == 0) { + thread_log(0, 0, "Could not connect to server"); + exit(2); + } + for (i = 1; i < n; ++i) { + free(ta[i]); + ta[i] = NULL; + } + tap = ta[0]; + free(ta); + + return (tap); +} + /*--------------------------------------------------------------------*/ static void @@ -714,8 +740,11 @@ signal(SIGPIPE, SIG_IGN); + pthread_attr_init(&thread_attr); + pthread_attr_setstacksize(&thread_attr, 16384); + while (VSL_Dispatch(vd, gen_traffic, NULL) == 0) /* nothing */ ; - thread_close(0); + thread_close(-1); exit(0); } From des at projects.linpro.no Mon Jun 30 02:45:45 2008 From: des at projects.linpro.no (des at projects.linpro.no) Date: Mon, 30 Jun 2008 04:45:45 +0200 (CEST) Subject: r2870 - in branches/1.1: . bin/varnishd bin/varnishhist bin/varnishlog bin/varnishncsa bin/varnishstat bin/varnishtop include/compat lib/libvarnish lib/libvarnishapi lib/libvarnishcompat man Message-ID: <20080630024545.51AB31ED230@projects.linpro.no> Author: des Date: 2008-06-30 04:45:45 +0200 (Mon, 30 Jun 2008) New Revision: 2870 Modified: branches/1.1/ branches/1.1/bin/varnishd/cache_lru.c branches/1.1/bin/varnishd/cache_synthetic.c branches/1.1/bin/varnishd/stevedore.c branches/1.1/bin/varnishd/varnishd.1 branches/1.1/bin/varnishhist/varnishhist.1 branches/1.1/bin/varnishhist/varnishhist.c branches/1.1/bin/varnishlog/varnishlog.1 branches/1.1/bin/varnishncsa/varnishncsa.1 branches/1.1/bin/varnishstat/varnishstat.1 branches/1.1/bin/varnishstat/varnishstat.c branches/1.1/bin/varnishtop/varnishtop.1 branches/1.1/bin/varnishtop/varnishtop.c branches/1.1/include/compat/asprintf.h branches/1.1/include/compat/daemon.h branches/1.1/include/compat/setproctitle.h branches/1.1/include/compat/srandomdev.h branches/1.1/include/compat/strlcat.h branches/1.1/include/compat/strlcpy.h branches/1.1/include/compat/strndup.h branches/1.1/include/compat/vasprintf.h branches/1.1/lib/libvarnish/version.c branches/1.1/lib/libvarnish/vss.c branches/1.1/lib/libvarnishapi/instance.c branches/1.1/lib/libvarnishcompat/asprintf.c branches/1.1/lib/libvarnishcompat/setproctitle.c branches/1.1/lib/libvarnishcompat/srandomdev.c branches/1.1/lib/libvarnishcompat/strndup.c branches/1.1/lib/libvarnishcompat/vasprintf.c branches/1.1/man/vcl.7 Log: Merged revisions 2861 via svnmerge from svn+ssh://projects.linpro.no/svn/varnish/trunk/varnish-cache ........ r2861 | des | 2008-06-30 03:40:12 +0200 (Mon, 30 Jun 2008) | 2 lines Change my email address. ........ Property changes on: branches/1.1 ___________________________________________________________________ Name: svnmerge-integrated - /trunk/varnish-cache:1-1722,1727-1729,1733,1738,1743-1777,1779-1798,1800-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865-1868,1871-1880,1883-1884,1886,1888-1889,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949,1955,1957-1958,1967-1968,1970-1974,1976-1977,1984,1986-1989,1991-1998,2026,2031-2033,2057,2077-2080,2086,2088,2091,2097,2106-2107,2116,2133,2154,2173,2180-2181,2191-2193,2206-2207,2211-2212,2215-2245,2256-2262,2270-2271,2275,2285-2286,2288-2291,2295-2301,2304-2327,2337,2357-2359,2361-2364,2366,2374-2386,2404,2414-2415,2421-2422,2426,2432-2434,2443-2445,2447,2453-2461,2467,2492-2505,2520-2524,2545,2563-2565,2569,2572,2575-2577,2862-2864 + /trunk/varnish-cache:1-1722,1727-1729,1733,1738,1743-1777,1779-1798,1800-1815,1817,1819,1823,1830-1838,1846,1853-1855,1857-1859,1862,1865-1868,1871-1880,1883-1884,1886,1888-1889,1896,1898,1902-1905,1907,1909,1912-1916,1920-1928,1935-1939,1941-1949,1955,1957-1958,1967-1968,1970-1974,1976-1977,1984,1986-1989,1991-1998,2026,2031-2033,2057,2077-2080,2086,2088,2091,2097,2106-2107,2116,2133,2154,2173,2180-2181,2191-2193,2206-2207,2211-2212,2215-2245,2256-2262,2270-2271,2275,2285-2286,2288-2291,2295-2301,2304-2327,2337,2357-2359,2361-2364,2366,2374-2386,2404,2414-2415,2421-2422,2426,2432-2434,2443-2445,2447,2453-2461,2467,2492-2505,2520-2524,2545,2563-2565,2569,2572,2575-2577,2861-2864 Modified: branches/1.1/bin/varnishd/cache_lru.c =================================================================== --- branches/1.1/bin/varnishd/cache_lru.c 2008-06-30 02:41:02 UTC (rev 2869) +++ branches/1.1/bin/varnishd/cache_lru.c 2008-06-30 02:45:45 UTC (rev 2870) @@ -2,7 +2,7 @@ * Copyright (c) 2007 Linpro AS * All rights reserved. * - * Author: Dag-Erling Sm??rgav + * Author: Dag-Erling Sm??rgav * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions Modified: branches/1.1/bin/varnishd/cache_synthetic.c =================================================================== --- branches/1.1/bin/varnishd/cache_synthetic.c 2008-06-30 02:41:02 UTC (rev 2869) +++ branches/1.1/bin/varnishd/cache_synthetic.c 2008-06-30 02:45:45 UTC (rev 2870) @@ -2,7 +2,7 @@ * Copyright (c) 2007-2008 Linpro AS * All rights reserved. * - * Author: Dag-Erling Sm??rgrav + * Author: Dag-Erling Sm??rgrav * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions Modified: branches/1.1/bin/varnishd/stevedore.c =================================================================== --- branches/1.1/bin/varnishd/stevedore.c 2008-06-30 02:41:02 UTC (rev 2869) +++ branches/1.1/bin/varnishd/stevedore.c 2008-06-30 02:45:45 UTC (rev 2870) @@ -2,7 +2,7 @@ * Copyright (c) 2007-2008 Linpro AS * All rights reserved. * - * Author: Dag-Erling Sm?rgav + * Author: Dag-Erling Sm??rgav * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions Modified: branches/1.1/bin/varnishd/varnishd.1 =================================================================== --- branches/1.1/bin/varnishd/varnishd.1 2008-06-30 02:41:02 UTC (rev 2869) +++ branches/1.1/bin/varnishd/varnishd.1 2008-06-30 02:45:45 UTC (rev 2870) @@ -3,7 +3,7 @@ .\" Copyright (c) 2006-2008 Linpro AS .\" All rights reserved. .\" -.\" Author: Dag-Erling Sm??rgrav +.\" Author: Dag-Erling Sm??rgrav .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions @@ -541,4 +541,4 @@ .An Poul-Henning Kamp Aq phk at phk.freebsd.dk in cooperation with Verdens Gang AS and Linpro AS. This manual page was written by -.An Dag-Erling Sm\(/orgrav Aq des at linpro.no . +.An Dag-Erling Sm\(/orgrav Aq des at des.no . Modified: branches/1.1/bin/varnishhist/varnishhist.1 =================================================================== --- branches/1.1/bin/varnishhist/varnishhist.1 2008-06-30 02:41:02 UTC (rev 2869) +++ branches/1.1/bin/varnishhist/varnishhist.1 2008-06-30 02:45:45 UTC (rev 2870) @@ -3,7 +3,7 @@ .\" Copyright (c) 2006-2008 Linpro AS .\" All rights reserved. .\" -.\" Author: Dag-Erling Sm??rgrav +.\" Author: Dag-Erling Sm??rgrav .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions @@ -148,4 +148,4 @@ .An Poul-Henning Kamp Aq phk at phk.freebsd.dk in cooperation with Verdens Gang AS and Linpro AS. This manual page was written by -.An Dag-Erling Sm\(/orgrav Aq des at linpro.no . +.An Dag-Erling Sm\(/orgrav Aq des at des.no . Modified: branches/1.1/bin/varnishhist/varnishhist.c =================================================================== --- branches/1.1/bin/varnishhist/varnishhist.c 2008-06-30 02:41:02 UTC (rev 2869) +++ branches/1.1/bin/varnishhist/varnishhist.c 2008-06-30 02:45:45 UTC (rev 2870) @@ -4,7 +4,7 @@ * All rights reserved. * * Author: Poul-Henning Kamp - * Author: Dag-Erling Sm??rgrav + * Author: Dag-Erling Sm??rgrav * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions Modified: branches/1.1/bin/varnishlog/varnishlog.1 =================================================================== --- branches/1.1/bin/varnishlog/varnishlog.1 2008-06-30 02:41:02 UTC (rev 2869) +++ branches/1.1/bin/varnishlog/varnishlog.1 2008-06-30 02:45:45 UTC (rev 2870) @@ -3,7 +3,7 @@ .\" Copyright (c) 2006-2008 Linpro AS .\" All rights reserved. .\" -.\" Author: Dag-Erling Sm??rgrav +.\" Author: Dag-Erling Sm??rgrav .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions @@ -250,4 +250,4 @@ .An Poul-Henning Kamp Aq phk at phk.freebsd.dk in cooperation with Verdens Gang AS and Linpro AS. This manual page was written by -.An Dag-Erling Sm\(/orgrav Aq des at linpro.no . +.An Dag-Erling Sm\(/orgrav Aq des at des.no . Modified: branches/1.1/bin/varnishncsa/varnishncsa.1 =================================================================== --- branches/1.1/bin/varnishncsa/varnishncsa.1 2008-06-30 02:41:02 UTC (rev 2869) +++ branches/1.1/bin/varnishncsa/varnishncsa.1 2008-06-30 02:45:45 UTC (rev 2870) @@ -3,7 +3,7 @@ .\" Copyright (c) 2006-2008 Linpro AS .\" All rights reserved. .\" -.\" Author: Dag-Erling Sm??rgrav +.\" Author: Dag-Erling Sm??rgrav .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions @@ -154,4 +154,4 @@ .An Poul-Henning Kamp Aq phk at phk.freebsd.dk in cooperation with Verdens Gang AS and Linpro AS. This manual page was written by -.An Dag-Erling Sm\(/orgrav Aq des at linpro.no . +.An Dag-Erling Sm\(/orgrav Aq des at des.no . Modified: branches/1.1/bin/varnishstat/varnishstat.1 =================================================================== --- branches/1.1/bin/varnishstat/varnishstat.1 2008-06-30 02:41:02 UTC (rev 2869) +++ branches/1.1/bin/varnishstat/varnishstat.1 2008-06-30 02:45:45 UTC (rev 2870) @@ -3,7 +3,7 @@ .\" Copyright (c) 2006-2008 Linpro AS .\" All rights reserved. .\" -.\" Author: Dag-Erling Sm??rgrav +.\" Author: Dag-Erling Sm??rgrav .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions @@ -110,6 +110,6 @@ .An Poul-Henning Kamp Aq phk at phk.freebsd.dk in cooperation with Verdens Gang AS and Linpro AS, and later substantially rewritten by -.An Dag-Erling Sm\(/orgrav Aq des at linpro.no . +.An Dag-Erling Sm\(/orgrav Aq des at des.no . This manual page was written by -.An Dag-Erling Sm\(/orgrav Aq des at linpro.no . +.An Dag-Erling Sm\(/orgrav Aq des at des.no . Modified: branches/1.1/bin/varnishstat/varnishstat.c =================================================================== --- branches/1.1/bin/varnishstat/varnishstat.c 2008-06-30 02:41:02 UTC (rev 2869) +++ branches/1.1/bin/varnishstat/varnishstat.c 2008-06-30 02:45:45 UTC (rev 2870) @@ -4,7 +4,7 @@ * All rights reserved. * * Author: Poul-Henning Kamp - * Author: Dag-Erling Sm??rgrav + * Author: Dag-Erling Sm??rgrav * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions Modified: branches/1.1/bin/varnishtop/varnishtop.1 =================================================================== --- branches/1.1/bin/varnishtop/varnishtop.1 2008-06-30 02:41:02 UTC (rev 2869) +++ branches/1.1/bin/varnishtop/varnishtop.1 2008-06-30 02:45:45 UTC (rev 2870) @@ -3,7 +3,7 @@ .\" Copyright (c) 2006-2008 Linpro AS .\" All rights reserved. .\" -.\" Author: Dag-Erling Sm??rgrav +.\" Author: Dag-Erling Sm??rgrav .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions @@ -162,6 +162,6 @@ .An Poul-Henning Kamp Aq phk at phk.freebsd.dk in cooperation with Verdens Gang AS and Linpro AS, and later substantially rewritten by -.An Dag-Erling Sm\(/orgrav Aq des at linpro.no . +.An Dag-Erling Sm\(/orgrav Aq des at des.no . This manual page was written by -.An Dag-Erling Sm\(/orgrav Aq des at linpro.no . +.An Dag-Erling Sm\(/orgrav Aq des at des.no . Modified: branches/1.1/bin/varnishtop/varnishtop.c =================================================================== --- branches/1.1/bin/varnishtop/varnishtop.c 2008-06-30 02:41:02 UTC (rev 2869) +++ branches/1.1/bin/varnishtop/varnishtop.c 2008-06-30 02:45:45 UTC (rev 2870) @@ -4,7 +4,7 @@ * All rights reserved. * * Author: Poul-Henning Kamp - * Author: Dag-Erling Sm??rgrav + * Author: Dag-Erling Sm??rgrav * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions Modified: branches/1.1/include/compat/asprintf.h =================================================================== --- branches/1.1/include/compat/asprintf.h 2008-06-30 02:41:02 UTC (rev 2869) +++ branches/1.1/include/compat/asprintf.h 2008-06-30 02:45:45 UTC (rev 2870) @@ -3,7 +3,7 @@ * Copyright (c) 2006-2008 Linpro AS * All rights reserved. * - * Author: Dag-Erling Sm??rgrav + * Author: Dag-Erling Sm??rgrav * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions Modified: branches/1.1/include/compat/daemon.h =================================================================== --- branches/1.1/include/compat/daemon.h 2008-06-30 02:41:02 UTC (rev 2869) +++ branches/1.1/include/compat/daemon.h 2008-06-30 02:45:45 UTC (rev 2870) @@ -3,7 +3,7 @@ * Copyright (c) 2006-2008 Linpro AS * All rights reserved. * - * Author: Dag-Erling Sm??rgrav + * Author: Dag-Erling Sm??rgrav * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions Modified: branches/1.1/include/compat/setproctitle.h =================================================================== --- branches/1.1/include/compat/setproctitle.h 2008-06-30 02:41:02 UTC (rev 2869) +++ branches/1.1/include/compat/setproctitle.h 2008-06-30 02:45:45 UTC (rev 2870) @@ -3,7 +3,7 @@ * Copyright (c) 2006-2008 Linpro AS * All rights reserved. * - * Author: Dag-Erling Sm??rgrav + * Author: Dag-Erling Sm??rgrav * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions Modified: branches/1.1/include/compat/srandomdev.h =================================================================== --- branches/1.1/include/compat/srandomdev.h 2008-06-30 02:41:02 UTC (rev 2869) +++ branches/1.1/include/compat/srandomdev.h 2008-06-30 02:45:45 UTC (rev 2870) @@ -3,7 +3,7 @@ * Copyright (c) 2006-2008 Linpro AS * All rights reserved. * - * Author: Dag-Erling Sm??rgrav + * Author: Dag-Erling Sm??rgrav * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions Modified: branches/1.1/include/compat/strlcat.h =================================================================== --- branches/1.1/include/compat/strlcat.h 2008-06-30 02:41:02 UTC (rev 2869) +++ branches/1.1/include/compat/strlcat.h 2008-06-30 02:45:45 UTC (rev 2870) @@ -3,7 +3,7 @@ * Copyright (c) 2006-2008 Linpro AS * All rights reserved. * - * Author: Dag-Erling Sm??rgrav + * Author: Dag-Erling Sm??rgrav * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions Modified: branches/1.1/include/compat/strlcpy.h =================================================================== --- branches/1.1/include/compat/strlcpy.h 2008-06-30 02:41:02 UTC (rev 2869) +++ branches/1.1/include/compat/strlcpy.h 2008-06-30 02:45:45 UTC (rev 2870) @@ -3,7 +3,7 @@ * Copyright (c) 2006-2008 Linpro AS * All rights reserved. * - * Author: Dag-Erling Sm??rgrav + * Author: Dag-Erling Sm??rgrav * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions Modified: branches/1.1/include/compat/strndup.h =================================================================== --- branches/1.1/include/compat/strndup.h 2008-06-30 02:41:02 UTC (rev 2869) +++ branches/1.1/include/compat/strndup.h 2008-06-30 02:45:45 UTC (rev 2870) @@ -3,7 +3,7 @@ * Copyright (c) 2006-2008 Linpro AS * All rights reserved. * - * Author: Dag-Erling Sm??rgrav + * Author: Dag-Erling Sm??rgrav * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions Modified: branches/1.1/include/compat/vasprintf.h =================================================================== --- branches/1.1/include/compat/vasprintf.h 2008-06-30 02:41:02 UTC (rev 2869) +++ branches/1.1/include/compat/vasprintf.h 2008-06-30 02:45:45 UTC (rev 2870) @@ -3,7 +3,7 @@ * Copyright (c) 2006-2008 Linpro AS * All rights reserved. * - * Author: Dag-Erling Sm??rgrav + * Author: Dag-Erling Sm??rgrav * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions Modified: branches/1.1/lib/libvarnish/version.c =================================================================== --- branches/1.1/lib/libvarnish/version.c 2008-06-30 02:41:02 UTC (rev 2869) +++ branches/1.1/lib/libvarnish/version.c 2008-06-30 02:45:45 UTC (rev 2870) @@ -3,7 +3,7 @@ * Copyright (c) 2006-2008 Linpro AS * All rights reserved. * - * Author: Dag-Erling Sm??rgrav + * Author: Dag-Erling Sm??rgrav * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions Modified: branches/1.1/lib/libvarnish/vss.c =================================================================== --- branches/1.1/lib/libvarnish/vss.c 2008-06-30 02:41:02 UTC (rev 2869) +++ branches/1.1/lib/libvarnish/vss.c 2008-06-30 02:45:45 UTC (rev 2870) @@ -3,7 +3,7 @@ * Copyright (c) 2006-2008 Linpro AS * All rights reserved. * - * Author: Dag-Erling Sm??rgrav + * Author: Dag-Erling Sm??rgrav * Author: Cecilie Fritzvold * * Redistribution and use in source and binary forms, with or without Modified: branches/1.1/lib/libvarnishapi/instance.c =================================================================== --- branches/1.1/lib/libvarnishapi/instance.c 2008-06-30 02:41:02 UTC (rev 2869) +++ branches/1.1/lib/libvarnishapi/instance.c 2008-06-30 02:45:45 UTC (rev 2870) @@ -2,7 +2,7 @@ * Copyright (c) 2007-2008 Linpro AS * All rights reserved. * - * Author: Dag-Erling Sm??rgrav + * Author: Dag-Erling Sm??rgrav * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions Modified: branches/1.1/lib/libvarnishcompat/asprintf.c =================================================================== --- branches/1.1/lib/libvarnishcompat/asprintf.c 2008-06-30 02:41:02 UTC (rev 2869) +++ branches/1.1/lib/libvarnishcompat/asprintf.c 2008-06-30 02:45:45 UTC (rev 2870) @@ -3,7 +3,7 @@ * Copyright (c) 2006-2008 Linpro AS * All rights reserved. * - * Author: Dag-Erling Sm??rgrav + * Author: Dag-Erling Sm??rgrav * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions Modified: branches/1.1/lib/libvarnishcompat/setproctitle.c =================================================================== --- branches/1.1/lib/libvarnishcompat/setproctitle.c 2008-06-30 02:41:02 UTC (rev 2869) +++ branches/1.1/lib/libvarnishcompat/setproctitle.c 2008-06-30 02:45:45 UTC (rev 2870) @@ -3,7 +3,7 @@ * Copyright (c) 2006-2008 Linpro AS * All rights reserved. * - * Author: Dag-Erling Sm??rgrav + * Author: Dag-Erling Sm??rgrav * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions Modified: branches/1.1/lib/libvarnishcompat/srandomdev.c =================================================================== --- branches/1.1/lib/libvarnishcompat/srandomdev.c 2008-06-30 02:41:02 UTC (rev 2869) +++ branches/1.1/lib/libvarnishcompat/srandomdev.c 2008-06-30 02:45:45 UTC (rev 2870) @@ -3,7 +3,7 @@ * Copyright (c) 2006-2008 Linpro AS * All rights reserved. * - * Author: Dag-Erling Sm??rgrav + * Author: Dag-Erling Sm??rgrav * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions Modified: branches/1.1/lib/libvarnishcompat/strndup.c =================================================================== --- branches/1.1/lib/libvarnishcompat/strndup.c 2008-06-30 02:41:02 UTC (rev 2869) +++ branches/1.1/lib/libvarnishcompat/strndup.c 2008-06-30 02:45:45 UTC (rev 2870) @@ -3,7 +3,7 @@ * Copyright (c) 2006-2008 Linpro AS * All rights reserved. * - * Author: Dag-Erling Sm??rgrav + * Author: Dag-Erling Sm??rgrav * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions Modified: branches/1.1/lib/libvarnishcompat/vasprintf.c =================================================================== --- branches/1.1/lib/libvarnishcompat/vasprintf.c 2008-06-30 02:41:02 UTC (rev 2869) +++ branches/1.1/lib/libvarnishcompat/vasprintf.c 2008-06-30 02:45:45 UTC (rev 2870) @@ -3,7 +3,7 @@ * Copyright (c) 2006-2008 Linpro AS * All rights reserved. * - * Author: Dag-Erling Sm??rgrav + * Author: Dag-Erling Sm??rgrav * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions Modified: branches/1.1/man/vcl.7 =================================================================== --- branches/1.1/man/vcl.7 2008-06-30 02:41:02 UTC (rev 2869) +++ branches/1.1/man/vcl.7 2008-06-30 02:45:45 UTC (rev 2870) @@ -3,7 +3,7 @@ .\" Copyright (c) 2006-2008 Linpro AS .\" All rights reserved. .\" -.\" Author: Dag-Erling Sm??rgrav +.\" Author: Dag-Erling Sm??rgrav .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions @@ -655,4 +655,4 @@ .An Poul-Henning Kamp Aq phk at phk.freebsd.dk in cooperation with Verdens Gang AS and Linpro AS. This manual page was written by -.An Dag-Erling Sm\(/orgrav Aq des at linpro.no . +.An Dag-Erling Sm\(/orgrav Aq des at des.no . From tfheen at projects.linpro.no Mon Jun 30 09:08:02 2008 From: tfheen at projects.linpro.no (tfheen at projects.linpro.no) Date: Mon, 30 Jun 2008 11:08:02 +0200 (CEST) Subject: r2871 - trunk/varnish-cache/bin/varnishtest Message-ID: <20080630090802.271571EC220@projects.linpro.no> Author: tfheen Date: 2008-06-30 11:08:01 +0200 (Mon, 30 Jun 2008) New Revision: 2871 Modified: trunk/varnish-cache/bin/varnishtest/Makefile.am Log: Make sure to distribute tests as well Modified: trunk/varnish-cache/bin/varnishtest/Makefile.am =================================================================== --- trunk/varnish-cache/bin/varnishtest/Makefile.am 2008-06-30 02:45:45 UTC (rev 2870) +++ trunk/varnish-cache/bin/varnishtest/Makefile.am 2008-06-30 09:08:01 UTC (rev 2871) @@ -18,3 +18,6 @@ $(top_builddir)/lib/libvarnish/libvarnish.la \ $(top_builddir)/lib/libvarnishcompat/libvarnishcompat.la \ ${PTHREAD_LIBS} + +EXTRA_DIST = $(top_srcdir)/bin/varnishtest/tests/*.vtc \ + $(top_srcdir)/bin/varnishtest/tests/README