From phk at varnish-cache.org Mon May 2 08:57:54 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 02 May 2011 10:57:54 +0200 Subject: [master] fdbb6f0 Add a stream_context structure to hold the state for streaming when we need it. Message-ID: commit fdbb6f0347c5d31aa81254aae9ca938e7bd5a731 Author: Poul-Henning Kamp Date: Mon May 2 08:40:00 2011 +0000 Add a stream_context structure to hold the state for streaming when we need it. diff --git a/bin/varnishd/cache.h b/bin/varnishd/cache.h index 7e9c0d9..adc76f3 100644 --- a/bin/varnishd/cache.h +++ b/bin/varnishd/cache.h @@ -247,7 +247,6 @@ struct exp { /*--------------------------------------------------------------------*/ -/* WRW related fields */ struct wrw { int *wfd; unsigned werr; /* valid after WRK_Flush() */ @@ -259,6 +258,21 @@ struct wrw { unsigned ciov; /* Chunked header marker */ }; +/*--------------------------------------------------------------------*/ + +struct stream_ctx { + unsigned magic; +#define STREAM_CTX_MAGIC 0x8213728b +#if 0 + struct vgz *vgz; + void *obuf; + ssize_t obuf_len; + ssize_t obuf_ptr; +#endif + ssize_t stream_next; +}; + +/*--------------------------------------------------------------------*/ struct worker { unsigned magic; #define WORKER_MAGIC 0x6391adcf @@ -312,7 +326,7 @@ struct worker { char *h_content_length; /* Stream state */ - ssize_t stream_next; + struct stream_ctx *sctx; /* ESI stuff */ struct vep_state *vep; diff --git a/bin/varnishd/cache_center.c b/bin/varnishd/cache_center.c index de7632a..36fe329 100644 --- a/bin/varnishd/cache_center.c +++ b/bin/varnishd/cache_center.c @@ -839,6 +839,13 @@ static int cnt_streambody(struct sess *sp) { int i; + struct stream_ctx sctx; + + + memset(&sctx, 0, sizeof sctx); + sctx.magic = STREAM_CTX_MAGIC; + AZ(sp->wrk->sctx); + sp->wrk->sctx = &sctx; RES_StreamStart(sp); @@ -854,6 +861,7 @@ cnt_streambody(struct sess *sp) AN(sp->director); if (i) { + sp->wrk->sctx = NULL; HSH_Drop(sp); AZ(sp->obj); sp->err_code = 503; @@ -873,6 +881,7 @@ cnt_streambody(struct sess *sp) RES_StreamEnd(sp); + sp->wrk->sctx = NULL; assert(WRW_IsReleased(sp->wrk)); assert(sp->wrk->wrw.ciov == sp->wrk->wrw.siov); (void)HSH_Deref(sp->wrk, NULL, &sp->obj); diff --git a/bin/varnishd/cache_response.c b/bin/varnishd/cache_response.c index 5ff645c..484ca1e 100644 --- a/bin/varnishd/cache_response.c +++ b/bin/varnishd/cache_response.c @@ -394,6 +394,10 @@ RES_WriteObj(struct sess *sp) void RES_StreamStart(struct sess *sp) { + struct stream_ctx *sctx; + + sctx = sp->wrk->sctx; + CHECK_OBJ_NOTNULL(sctx, STREAM_CTX_MAGIC); AZ(sp->wrk->res_mode & RES_ESI_CHILD); AN(sp->wantbody); @@ -410,31 +414,32 @@ RES_StreamStart(struct sess *sp) if (sp->wrk->res_mode & RES_CHUNKED) WRW_Chunked(sp->wrk); - - sp->wrk->stream_next = 0; } void RES_StreamPoll(const struct sess *sp) { + struct stream_ctx *sctx; struct storage *st; ssize_t l, l2; void *ptr; - if (sp->obj->len == sp->wrk->stream_next) + sctx = sp->wrk->sctx; + CHECK_OBJ_NOTNULL(sctx, STREAM_CTX_MAGIC); + if (sp->obj->len == sctx->stream_next) return; - assert(sp->obj->len > sp->wrk->stream_next); + assert(sp->obj->len > sctx->stream_next); l = 0; VTAILQ_FOREACH(st, &sp->obj->store, list) { - if (st->len + l <= sp->wrk->stream_next) { + if (st->len + l <= sctx->stream_next) { l += st->len; continue; } - l2 = st->len + l - sp->wrk->stream_next; - ptr = st->ptr + (sp->wrk->stream_next - l); + l2 = st->len + l - sctx->stream_next; + ptr = st->ptr + (sctx->stream_next - l); (void)WRW_Write(sp->wrk, ptr, l2); l += st->len; - sp->wrk->stream_next += l2; + sctx->stream_next += l2; } (void)WRW_Flush(sp->wrk); } @@ -442,6 +447,10 @@ RES_StreamPoll(const struct sess *sp) void RES_StreamEnd(struct sess *sp) { + struct stream_ctx *sctx; + + sctx = sp->wrk->sctx; + CHECK_OBJ_NOTNULL(sctx, STREAM_CTX_MAGIC); if (sp->wrk->res_mode & RES_GUNZIP) { INCOMPL(); From phk at varnish-cache.org Mon May 2 08:57:54 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 02 May 2011 10:57:54 +0200 Subject: [master] 4b9d3f4 Let streaming delivery free the storage when done with it for PASS requests. Message-ID: commit 4b9d3f43038c714626a7de0bb73e6e8f6a4e2a4b Author: Poul-Henning Kamp Date: Mon May 2 08:57:01 2011 +0000 Let streaming delivery free the storage when done with it for PASS requests. This should make it possible to deliver arbitrarily sized objects with pass mode. diff --git a/bin/varnishd/cache.h b/bin/varnishd/cache.h index adc76f3..4383292 100644 --- a/bin/varnishd/cache.h +++ b/bin/varnishd/cache.h @@ -263,13 +263,18 @@ struct wrw { struct stream_ctx { unsigned magic; #define STREAM_CTX_MAGIC 0x8213728b + #if 0 struct vgz *vgz; void *obuf; ssize_t obuf_len; ssize_t obuf_ptr; #endif + /* Next byte we will take from storage */ ssize_t stream_next; + + /* First byte of storage if we free it as we go (pass) */ + ssize_t stream_front; }; /*--------------------------------------------------------------------*/ diff --git a/bin/varnishd/cache_fetch.c b/bin/varnishd/cache_fetch.c index abd9e32..ddbd3ab 100644 --- a/bin/varnishd/cache_fetch.c +++ b/bin/varnishd/cache_fetch.c @@ -576,7 +576,11 @@ FetchBody(struct sess *sp) uu = 0; VTAILQ_FOREACH(st, &sp->obj->store, list) uu += st->len; - assert(uu == sp->obj->len); + if (sp->objcore == NULL || (sp->objcore->flags & OC_F_PASS)) + /* Streaming might have started freeing stuff */ + assert (uu <= sp->obj->len); + else + assert(uu == sp->obj->len); } if (mklen > 0) { diff --git a/bin/varnishd/cache_response.c b/bin/varnishd/cache_response.c index 484ca1e..bdf2814 100644 --- a/bin/varnishd/cache_response.c +++ b/bin/varnishd/cache_response.c @@ -36,6 +36,7 @@ #include #include "cache.h" +#include "stevedore.h" #include "vct.h" /*--------------------------------------------------------------------*/ @@ -429,7 +430,7 @@ RES_StreamPoll(const struct sess *sp) if (sp->obj->len == sctx->stream_next) return; assert(sp->obj->len > sctx->stream_next); - l = 0; + l = sctx->stream_front; VTAILQ_FOREACH(st, &sp->obj->store, list) { if (st->len + l <= sctx->stream_next) { l += st->len; @@ -442,6 +443,22 @@ RES_StreamPoll(const struct sess *sp) sctx->stream_next += l2; } (void)WRW_Flush(sp->wrk); + + if (sp->objcore == NULL || (sp->objcore->flags & OC_F_PASS)) { + /* + * This is a pass object, release storage as soon as we + * have delivered it. + */ + while (1) { + st = VTAILQ_FIRST(&sp->obj->store); + if (st == NULL || + sctx->stream_front + st->len > sctx->stream_next) + break; + VTAILQ_REMOVE(&sp->obj->store, st, list); + sctx->stream_front += st->len; + STV_free(st); + } + } } void From phk at varnish-cache.org Mon May 2 12:32:50 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 02 May 2011 14:32:50 +0200 Subject: [master] 349269f Centralize obj->gzipped setting and get it right up front. Message-ID: commit 349269f15403ca5f616bd49677e3882126918c1f Author: Poul-Henning Kamp Date: Mon May 2 12:05:42 2011 +0000 Centralize obj->gzipped setting and get it right up front. Edging closer to streap+gunzip diff --git a/bin/varnishd/cache.h b/bin/varnishd/cache.h index 4383292..b42385f 100644 --- a/bin/varnishd/cache.h +++ b/bin/varnishd/cache.h @@ -264,12 +264,11 @@ struct stream_ctx { unsigned magic; #define STREAM_CTX_MAGIC 0x8213728b -#if 0 struct vgz *vgz; void *obuf; ssize_t obuf_len; ssize_t obuf_ptr; -#endif + /* Next byte we will take from storage */ ssize_t stream_next; diff --git a/bin/varnishd/cache_center.c b/bin/varnishd/cache_center.c index 36fe329..4514346 100644 --- a/bin/varnishd/cache_center.c +++ b/bin/varnishd/cache_center.c @@ -414,6 +414,7 @@ cnt_error(struct sess *sp) EXP_Clr(&w->exp); sp->obj = STV_NewObject(sp, NULL, 1024, &w->exp, params->http_max_hdr); + XXXAN(sp->obj); sp->obj->xid = sp->xid; sp->obj->entered = sp->t_req; } else { @@ -754,8 +755,8 @@ cnt_fetchbody(struct sess *sp) sp->wrk->storage_hint = NULL; - /* VFP will update as needed */ - sp->obj->gziped = sp->wrk->is_gzip; + if (sp->wrk->do_gzip || (sp->wrk->is_gzip && !sp->wrk->do_gunzip)) + sp->obj->gziped = 1; if (vary != NULL) { sp->obj->vary = @@ -840,13 +841,20 @@ cnt_streambody(struct sess *sp) { int i; struct stream_ctx sctx; - + uint8_t obuf[sp->wrk->res_mode & RES_GUNZIP ? + params->gzip_stack_buffer : 1]; memset(&sctx, 0, sizeof sctx); sctx.magic = STREAM_CTX_MAGIC; AZ(sp->wrk->sctx); sp->wrk->sctx = &sctx; + if (sp->wrk->res_mode & RES_GUNZIP) { + sctx.vgz = VGZ_NewUngzip(sp, "U S -"); + sctx.obuf = obuf; + sctx.obuf_len = sizeof (obuf); + } + RES_StreamStart(sp); /* Use unmodified headers*/ diff --git a/bin/varnishd/cache_esi_fetch.c b/bin/varnishd/cache_esi_fetch.c index 9dbb501..58b3852 100644 --- a/bin/varnishd/cache_esi_fetch.c +++ b/bin/varnishd/cache_esi_fetch.c @@ -386,10 +386,7 @@ vfp_esi_end(struct sess *sp) VGZ_UpdateObj(vef->vgz, sp->obj); VGZ_Destroy(&vef->vgz); XXXAZ(vef->error); - sp->obj->gziped = 1; FREE_OBJ(vef); - } else { - sp->obj->gziped = 0; } return (0); } diff --git a/bin/varnishd/cache_gzip.c b/bin/varnishd/cache_gzip.c index 0c29293..2239884 100644 --- a/bin/varnishd/cache_gzip.c +++ b/bin/varnishd/cache_gzip.c @@ -491,7 +491,6 @@ vfp_gunzip_end(struct sess *sp) sp->wrk->vgz_rx = NULL; CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC); VGZ_Destroy(&vg); - sp->obj->gziped = 0; return (0); } @@ -572,7 +571,6 @@ vfp_gzip_end(struct sess *sp) } while (i != Z_STREAM_END); VGZ_UpdateObj(vg, sp->obj); VGZ_Destroy(&vg); - sp->obj->gziped = 1; return (0); } @@ -653,7 +651,6 @@ vfp_testgzip_end(struct sess *sp) CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC); VGZ_UpdateObj(vg, sp->obj); VGZ_Destroy(&vg); - sp->obj->gziped = 1; return (0); } From phk at varnish-cache.org Mon May 2 12:32:51 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 02 May 2011 14:32:51 +0200 Subject: [master] fe361cf Complete support for gunzip'ing during streaming delivery. Message-ID: commit fe361cf2ec69425f1352c9a5d6e32668d0f3aa98 Author: Poul-Henning Kamp Date: Mon May 2 12:32:11 2011 +0000 Complete support for gunzip'ing during streaming delivery. diff --git a/bin/varnishd/cache.h b/bin/varnishd/cache.h index b42385f..885974a 100644 --- a/bin/varnishd/cache.h +++ b/bin/varnishd/cache.h @@ -878,7 +878,7 @@ void RES_BuildHttp(struct sess *sp); void RES_WriteObj(struct sess *sp); void RES_StreamStart(struct sess *sp); void RES_StreamEnd(struct sess *sp); -void RES_StreamPoll(const struct sess *sp); +void RES_StreamPoll(struct sess *sp); /* cache_vary.c */ struct vsb *VRY_Create(const struct sess *sp, const struct http *hp); diff --git a/bin/varnishd/cache_center.c b/bin/varnishd/cache_center.c index 4514346..4b408ae 100644 --- a/bin/varnishd/cache_center.c +++ b/bin/varnishd/cache_center.c @@ -857,7 +857,6 @@ cnt_streambody(struct sess *sp) RES_StreamStart(sp); - /* Use unmodified headers*/ i = FetchBody(sp); sp->wrk->h_content_length = NULL; @@ -888,6 +887,8 @@ cnt_streambody(struct sess *sp) sp->restarts = 0; RES_StreamEnd(sp); + if (sp->wrk->res_mode & RES_GUNZIP) + VGZ_Destroy(&sctx.vgz); sp->wrk->sctx = NULL; assert(WRW_IsReleased(sp->wrk)); diff --git a/bin/varnishd/cache_gzip.c b/bin/varnishd/cache_gzip.c index 2239884..290da72 100644 --- a/bin/varnishd/cache_gzip.c +++ b/bin/varnishd/cache_gzip.c @@ -569,6 +569,8 @@ vfp_gzip_end(struct sess *sp) i = VGZ_Gzip(vg, &dp, &dl, VGZ_FINISH); sp->obj->len += dl; } while (i != Z_STREAM_END); + if (sp->wrk->do_stream) + RES_StreamPoll(sp); VGZ_UpdateObj(vg, sp->obj); VGZ_Destroy(&vg); return (0); diff --git a/bin/varnishd/cache_response.c b/bin/varnishd/cache_response.c index bdf2814..9ffb95e 100644 --- a/bin/varnishd/cache_response.c +++ b/bin/varnishd/cache_response.c @@ -418,7 +418,7 @@ RES_StreamStart(struct sess *sp) } void -RES_StreamPoll(const struct sess *sp) +RES_StreamPoll(struct sess *sp) { struct stream_ctx *sctx; struct storage *st; @@ -438,11 +438,17 @@ RES_StreamPoll(const struct sess *sp) } l2 = st->len + l - sctx->stream_next; ptr = st->ptr + (sctx->stream_next - l); - (void)WRW_Write(sp->wrk, ptr, l2); + if (sp->wrk->res_mode & RES_GUNZIP) { + (void)VGZ_WrwGunzip(sp, sctx->vgz, ptr, l2, + sctx->obuf, sctx->obuf_len, &sctx->obuf_ptr); + } else { + (void)WRW_Write(sp->wrk, ptr, l2); + } l += st->len; sctx->stream_next += l2; } - (void)WRW_Flush(sp->wrk); + if (!(sp->wrk->res_mode & RES_GUNZIP)) + (void)WRW_Flush(sp->wrk); if (sp->objcore == NULL || (sp->objcore->flags & OC_F_PASS)) { /* @@ -469,10 +475,8 @@ RES_StreamEnd(struct sess *sp) sctx = sp->wrk->sctx; CHECK_OBJ_NOTNULL(sctx, STREAM_CTX_MAGIC); - if (sp->wrk->res_mode & RES_GUNZIP) { - INCOMPL(); - res_WriteGunzipObj(sp); - } + if (sp->wrk->res_mode & RES_GUNZIP && sctx->obuf_ptr > 0) + (void)WRW_Write(sp->wrk, sctx->obuf, sctx->obuf_ptr); if (sp->wrk->res_mode & RES_CHUNKED && !(sp->wrk->res_mode & RES_ESI_CHILD)) WRW_EndChunk(sp->wrk); diff --git a/bin/varnishtest/tests/t00001.vtc b/bin/varnishtest/tests/t00001.vtc new file mode 100644 index 0000000..5fefc70 --- /dev/null +++ b/bin/varnishtest/tests/t00001.vtc @@ -0,0 +1,49 @@ +varnishtest "Test stream/gunzip" + +server s1 { + rxreq + expect req.url == "/bar" + txresp -body "foobar" + + rxreq + expect req.url == "/bla" + expect req.http.accept-encoding == "gzip" + txresp -gzipbody blablabla + + rxreq + expect req.url == "/foo" + txresp -body "snafu" + + rxreq + expect req.url == "/barf" + expect req.http.accept-encoding == "gzip" + txresp -gzipbody Iamoutofnonsensewords + +} -start + +varnish v1 -vcl+backend { + sub vcl_fetch { + if (req.url == "/foo") { + set beresp.do_gzip = true; + } + if (req.url == "/barf") { + set beresp.do_gunzip = true; + } + set beresp.do_stream = true; + } +} -start + +client c1 { + txreq -url /bar + rxresp + expect resp.bodylen == 6 + txreq -url /bla + rxresp + expect resp.bodylen == 9 + txreq -url /foo + rxresp + expect resp.bodylen == 5 + txreq -url /barf + rxresp + expect resp.bodylen == 21 +} -run From phk at varnish-cache.org Mon May 2 14:09:05 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 02 May 2011 16:09:05 +0200 Subject: [master] d969d62 We cannot elope to vcl_error if things go bad with a streaming fetch, we simply have to abandon it. Message-ID: commit d969d627c940727dda0c1bcecccb9d0193d42d13 Author: Poul-Henning Kamp Date: Mon May 2 14:06:19 2011 +0000 We cannot elope to vcl_error if things go bad with a streaming fetch, we simply have to abandon it. diff --git a/bin/varnishd/cache_center.c b/bin/varnishd/cache_center.c index 4b408ae..0447dc7 100644 --- a/bin/varnishd/cache_center.c +++ b/bin/varnishd/cache_center.c @@ -867,16 +867,7 @@ cnt_streambody(struct sess *sp) AZ(sp->vbc); AN(sp->director); - if (i) { - sp->wrk->sctx = NULL; - HSH_Drop(sp); - AZ(sp->obj); - sp->err_code = 503; - sp->step = STP_ERROR; - return (0); - } - - if (sp->obj->objcore != NULL) { + if (!i && sp->obj->objcore != NULL) { EXP_Insert(sp->obj); AN(sp->obj->objcore); AN(sp->obj->objcore->ban); From phk at varnish-cache.org Mon May 2 14:09:06 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 02 May 2011 16:09:06 +0200 Subject: [master] 42b9b11 Make sure we get a proper diagnostic on stream delivery errors. Message-ID: commit 42b9b11bff48ecb9ab1afe212e34d0b3a7b21544 Author: Poul-Henning Kamp Date: Mon May 2 14:08:37 2011 +0000 Make sure we get a proper diagnostic on stream delivery errors. diff --git a/bin/varnishd/cache_center.c b/bin/varnishd/cache_center.c index 0447dc7..ac86da0 100644 --- a/bin/varnishd/cache_center.c +++ b/bin/varnishd/cache_center.c @@ -872,6 +872,8 @@ cnt_streambody(struct sess *sp) AN(sp->obj->objcore); AN(sp->obj->objcore->ban); HSH_Unbusy(sp); + } else { + sp->doclose = "Stream error"; } sp->acct_tmp.fetch++; sp->director = NULL; From tfheen at varnish-cache.org Tue May 3 08:18:13 2011 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Tue, 03 May 2011 10:18:13 +0200 Subject: [master] a7c1871 Round down synthesized last-modified timestamp in object Message-ID: commit a7c18717f45390231bf62cfedcf805458b26ca26 Author: Tollef Fog Heen Date: Tue May 3 10:12:08 2011 +0200 Round down synthesized last-modified timestamp in object Commit 3bd239e9b2361c96b1acf1c03bce9c50baaf838d makes it so we set the object's last-modified timestamp to the current timestamp if there's no Last-Modified header. This makes it so we can do conditional gets even when there's no Last-Modified or ETag header from the backend. However, the time entered was a float, so we effectively ended up with an off-by-up-to-one-minus-epsilon error. This lead to requests ending up in a 304/200 response code round-dance. We now round the timestamp down to the nearest whole second instead, which should fix this bug. Thanks to lrowe for a helpful bug report. Fixes: #907 diff --git a/bin/varnishd/cache_center.c b/bin/varnishd/cache_center.c index ac86da0..edfe75d 100644 --- a/bin/varnishd/cache_center.c +++ b/bin/varnishd/cache_center.c @@ -785,7 +785,7 @@ cnt_fetchbody(struct sess *sp) if (http_GetHdr(hp, H_Last_Modified, &b)) sp->obj->last_modified = TIM_parse(b); else - sp->obj->last_modified = sp->wrk->entered; + sp->obj->last_modified = floor(sp->wrk->entered); assert(WRW_IsReleased(sp->wrk)); diff --git a/bin/varnishtest/tests/r00907.vtc b/bin/varnishtest/tests/r00907.vtc new file mode 100644 index 0000000..8bbcd2e --- /dev/null +++ b/bin/varnishtest/tests/r00907.vtc @@ -0,0 +1,23 @@ +varnishtest "Ticket #907 200/304 handling with Etags + Last-Modified" + +server s1 { + rxreq + txresp \ + -hdr "ETag: saengei1Ohshicich4iteesu" +} -start + +varnish v1 -vcl+backend { + sub vcl_deliver { + set resp.http.x-timestamp = now; + } +} -start + +client c1 { + txreq -hdr "If-None-Match: saengei1Ohshicich4iteesu" + rxresp + expect resp.status == 304 + txreq -hdr "If-None-Match: saengei1Ohshicich4iteesu" \ + -hdr "If-Modified-Since: ${date}" + rxresp + expect resp.status == 304 +} -run From tfheen at varnish-cache.org Thu May 5 12:39:32 2011 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Thu, 05 May 2011 14:39:32 +0200 Subject: [master] f8dd5cc Documentation updates Message-ID: commit f8dd5cccebe2101dc2114e5d1b8d4be5e0ecfe31 Author: Tollef Fog Heen Date: Thu May 5 14:38:45 2011 +0200 Documentation updates Update docs for purge ? ban rename plus various typos and grammatical errors. diff --git a/doc/sphinx/faq/general.rst b/doc/sphinx/faq/general.rst index 26b86fa..12617f5 100644 --- a/doc/sphinx/faq/general.rst +++ b/doc/sphinx/faq/general.rst @@ -33,11 +33,11 @@ How... That depends on pretty much everything. I think our best current guidance is that you go for a cost-effective -RAM configuration, something like 1-16GB, and a SSD disk. +RAM configuration, something like 1-16GB, and an SSD. Unless you positively know that you will need it, there is -little point in spendng a fortune on a hand-sewn motherboard -that can fit several TB in special RAM blocks, rivetet together +little point in spending a fortune on a hand-sewn motherboard +that can fit several TB in special RAM blocks, riveted together by leftover watch-makers in Switzerland. On the other hand, if you plot your traffic in Gb/s, you probably @@ -65,14 +65,14 @@ Refreshing is often called `purging `_ - as its argument. Hence the ``^`` and ``$`` at the front and end. If the ``^`` is ommited, all the documents ending in a ``/`` in the cache would be deleted. + to ban your / document. As you might see ban.url takes an `regular expression `_ + as its argument. Hence the ``^`` and ``$`` at the front and end. If the ``^`` is omitted, all the documents ending in a ``/`` in the cache would be deleted. So to delete all the documents in the cache, write:: - url.purge .* + ban.url . at the command line. @@ -96,15 +96,15 @@ At the shell command line, type:: **How can I rewrite URLS before they are sent to the backend?** -You can use the ``regsub()`` function to do this. Here's an example for zope, to rewrite URL's for the virtualhostmonster:: +You can use the ``regsub()`` function to do this. Here's an example for zope, to rewrite URLs for the virtualhostmonster:: if (req.http.host ~ "^(www.)?example.com") { set req.url = regsub(req.url, "^", "/VirtualHostBase/http/example.com:80/Sites/example.com/VirtualHostRoot"); } -**I have a site with many hostnames, how do I keep them from multiplying the cache?** +**I have a site with many host names, how do I keep them from multiplying the cache?** -You can do this by normalizing the ``Host`` header for all your hostnames. Here's a VCL example:: +You can do this by normalizing the ``Host`` header for all your host names. Here's a VCL example:: if (req.http.host ~ "^(www.)?example.com") { set req.http.host = "example.com"; @@ -120,7 +120,7 @@ You can use the ``bereq`` object for altering requests going to the backend, but **How do I force the backend to send Vary headers?** -We have anectdotal evidence of non-RFC2616 compliant backends, which support content negotiation, but which do not emit a Vary header, unless the request contains Accept headers. +We have anecdotal evidence of non-RFC2616 compliant backends, which support content negotiation, but which do not emit a Vary header, unless the request contains Accept headers. It may be appropriate to send no-op Accept headers to trick the backend into sending us the Vary header. @@ -177,8 +177,8 @@ Where... **Can I find varnish for my operating system?** We know that Varnish has been packaged for Debian, Ubuntu, RHEL, -Centos, (Open)SuSE, Gentoo and FreeBSD, possibly more. Check whatever -packagemanager you use. Or read :ref:`Installing Varnish on your computer `. +CentOS, (Open)SUSE, Gentoo and FreeBSD, possibly more. Check whatever +package manager you use. Or read :ref:`Installing Varnish on your computer `. Can I... ======== @@ -211,7 +211,7 @@ Yes, as long as you give them different TCP ports and different ``-n`` arguments, you will be fine. -**Can I cache multiple vhosts with one Varnish?** +**Can I cache multiple virtual hosts with one Varnish?** Yes, that works right out of the box. @@ -228,7 +228,7 @@ Besides, the output is a lot less useful than you might think. Not at present, and while we keep an eye on this, there are no current plans to add HTTPS support, until we can find a way where it adds significant value, relative to running a stand-alone -HTTPS proxy such as ngnix or pound. +HTTPS proxy such as nginx or pound. **Can Varnish load balance between multiple backends?** @@ -259,10 +259,10 @@ There are 2 common reasons for this: **Why are regular expressions case-sensitive?** -Some HTTP headers, such as ``Host:`` and ``Location:`` -contain FQDN's which by definition is not case-sensitive. Other -HTTP headers are case-sensitive, most notably the URLs. Therefore -a "one size fits all" solution is not possible. +Some HTTP headers, such as ``Host:`` and ``Location:`` contain fully +qualified domain names, which by definition is not case-sensitive. +Other HTTP headers are case-sensitive, most notably the URLs. +Therefore a "one size fits all" solution is not possible. In previous releases, we used the POSIX regular expressions supplied with the operating system, and decided, because the @@ -272,12 +272,12 @@ they should not be case-sensitive. From version 2.1.0 and forward, we use PCRE regular expressions, where it *is* possible to control case-sensitivity in the individual regular expressions, so we decided that it would -probably confuse people if we made the default case-insentive. +probably confuse people if we made the default case-insensitive. (We promise not to change our minds about this again.) To make a PCRE regex case insensitive, put ``(?i)`` at the start:: - if (req.http.host ~ "?iexample.com$") { + if (req.http.host ~ "(?i)example.com$") { ... } @@ -295,7 +295,7 @@ See the `PCRE man pages `_ for more information. **Why does the ``Via:`` header say 1.1 in Varnish 2.1.x?** The number in the ``Via:`` header is the HTTP protocol version -supported/applied, not the softwares version number. +supported/applied, not the software's version number. **Why did you call it *Varnish*?** @@ -336,14 +336,14 @@ Varnish has a feature called **hit for pass**, which is used when Varnish gets a * Worker returns object to varnish which turns out to be non-cacheable. * Client 2..N are now given the **hit for pass** object instructing them to go to the backend -The **hit for pass** object will stay cached for the duration of it's ttl. This means that subsequent clients requesting /foo will be sent straight to the backend as long as the **hit for pass** object exists. +The **hit for pass** object will stay cached for the duration of its ttl. This means that subsequent clients requesting /foo will be sent straight to the backend as long as the **hit for pass** object exists. The :command:`varnishstat` can tell you how many **hit for pass** objects varnish has served. You can lower the ttl for such an object if you are sure this is needed, using the following logic:: sub vcl_fetch { if (!obj.cacheable) { # Limit the lifetime of all 'hit for pass' objects to 10 seconds obj.ttl = 10s; - pass; + return(hit_for_pass); } } diff --git a/doc/sphinx/reference/varnish-cli.rst b/doc/sphinx/reference/varnish-cli.rst index 145f960..36e4c16 100644 --- a/doc/sphinx/reference/varnish-cli.rst +++ b/doc/sphinx/reference/varnish-cli.rst @@ -120,7 +120,7 @@ ban.url regexp Immediately invalidate all documents whose URL matches the specified regular expression. Please note that the Host part of the URL is ignored, so if you have several virtual hosts all of - them will be purged. Use *ban* to specify a complete ban if you + them will be banned. Use *ban* to specify a complete ban if you need to narrow it down. quit @@ -280,16 +280,16 @@ EXAMPLES ======== Simple example: All requests where req.url exactly matches the string -/news are purged from the cache::: +/news are banned from the cache::: req.url == "/news" -Example: Purge all documents where the name does not end with ".ogg", +Example: Ban all documents where the name does not end with ".ogg", and where the size of the object is greater than 10 megabytes::: req.url !~ "\.ogg$" && obj.size > 10MB -Example: Purge all documents where the serving host is "example.com" +Example: Ban all documents where the serving host is "example.com" or "www.example.com", and where the Set-Cookie header received from the backend contains "USERID=1663"::: diff --git a/doc/sphinx/reference/vcl.rst b/doc/sphinx/reference/vcl.rst index 85553f4..cfb1c38 100644 --- a/doc/sphinx/reference/vcl.rst +++ b/doc/sphinx/reference/vcl.rst @@ -323,8 +323,8 @@ regsub(str, regex, sub) regsuball(str, regex, sub) As regsuball() but this replaces all occurrences. -purge_url(regex) - Purge all objects in cache whose URLs match regex. +ban_url(regex) + Ban all objects in cache whose URLs match regex. Subroutines ~~~~~~~~~~~ @@ -523,7 +523,7 @@ Example::: # in file "main.vcl" include "backends.vcl"; - include "purge.vcl"; + include "ban.vcl"; # in file "backends.vcl" sub vcl_recv { @@ -534,11 +534,11 @@ Example::: } } - # in file "purge.vcl" + # in file "ban.vcl" sub vcl_recv { if (client.ip ~ admin_network) { if (req.http.Cache-Control ~ "no-cache") { - purge_url(req.url); + ban_url(req.url); } } } @@ -858,14 +858,15 @@ for object invalidation::: sub vcl_hit { if (req.request == "PURGE") { - set obj.ttl = 0s; + purge; error 200 "Purged."; } } sub vcl_miss { if (req.request == "PURGE") { - error 404 "Not in cache."; + purge; + error 200 "Purged."; } } diff --git a/doc/sphinx/tutorial/purging.rst b/doc/sphinx/tutorial/purging.rst index 61e1e69..bd00e49 100644 --- a/doc/sphinx/tutorial/purging.rst +++ b/doc/sphinx/tutorial/purging.rst @@ -1,7 +1,8 @@ .. _tutorial-purging: -Purging and banning -------------------- +===================== + Purging and banning +===================== One of the most effective way of increasing your hit ratio is to increase the time-to-live (ttl) of your objects. But, as you're aware @@ -14,7 +15,7 @@ bans. First, let me explain the HTTP purges. HTTP Purges -~~~~~~~~~~~ +=========== An HTTP purge is similar to an HTTP GET request, except that the *method* is PURGE. Actually you can call the method whatever you'd @@ -40,17 +41,15 @@ following VCL in place:: sub vcl_hit { if (req.request == "PURGE") { - # Note that setting ttl to 0 is magical. - # the object is zapped from cache. - set obj.ttl = 0s; + purge; error 200 "Purged."; } } sub vcl_miss { if (req.request == "PURGE") { - - error 404 "Not in cache."; + purge; + error 200 "Purged."; } } @@ -60,23 +59,17 @@ its cache. It will either hit an object or miss it and so the corresponding subroutine is called. In vcl_hit the object that is stored in cache is available and we can set the TTL. -So for vg.no to invalidate their front page they would call out to -Varnish like this:: +So for example.com to invalidate their front page they would call out +to Varnish like this:: PURGE / HTTP/1.0 - Host: vg.no + Host: example.com -And Varnish would then discard the front page. If there are several -variants of the same URL in the cache however, only the matching -variant will be purged. To purge a gzip variant of the same page the -request would have to look like this:: - - PURGE / HTTP/1.0 - Host: vg.no - Accept-Encoding: gzip +And Varnish would then discard the front page. This will remove all +variants as defined by Vary. Bans -~~~~ +==== There is another way to invalidate content. Bans. You can think of bans as a sort of a filter. You *ban* certain content from being @@ -84,10 +77,10 @@ served from your cache. You can ban content based on any metadata we have. Support for bans is built into Varnish and available in the CLI -interface. For VG to ban every png object belonging on vg.no they could -issue:: +interface. For VG to ban every png object belonging on example.com +they could issue:: - purge req.http.host == "vg.no" && req.http.url ~ "\.png$" + ban req.http.host == "example.com" && req.http.url ~ "\.png$" Quite powerful, really. @@ -104,7 +97,7 @@ You can also add bans to Varnish via HTTP. Doing so requires a bit of VCL:: if (!client.ip ~ purge) { error 405 "Not allowed."; } - purge("req.http.host == " req.http.host + ban("req.http.host == " req.http.host "&& req.url == " req.url); # Throw a synthetic page so the From phk at varnish-cache.org Fri May 6 11:10:24 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Fri, 06 May 2011 13:10:24 +0200 Subject: [master] 42a844a Code Polish Message-ID: commit 42a844a2761edd01f42e5770a35a8e4197c7b21f Author: Poul-Henning Kamp Date: Fri May 6 09:21:05 2011 +0000 Code Polish diff --git a/bin/varnishd/cache.h b/bin/varnishd/cache.h index 885974a..fc55996 100644 --- a/bin/varnishd/cache.h +++ b/bin/varnishd/cache.h @@ -656,7 +656,7 @@ void BAN_Reload(double t0, unsigned flags, const char *ban); struct ban *BAN_TailRef(void); void BAN_Compile(void); struct ban *BAN_RefBan(struct objcore *oc, double t0, const struct ban *tail); -void BAN_Deref(struct ban **ban); +void BAN_TailDeref(struct ban **ban); /* cache_center.c [CNT] */ void CNT_Session(struct sess *sp); diff --git a/bin/varnishd/cache_ban.c b/bin/varnishd/cache_ban.c index 2ba366c..1065e35 100644 --- a/bin/varnishd/cache_ban.c +++ b/bin/varnishd/cache_ban.c @@ -549,11 +549,11 @@ ban_lurker(struct sess *sp, void *priv) /*-------------------------------------------------------------------- - * Release a reference + * Release a tail reference */ void -BAN_Deref(struct ban **bb) +BAN_TailDeref(struct ban **bb) { struct ban *b; diff --git a/bin/varnishd/storage_persistent.c b/bin/varnishd/storage_persistent.c index d5ee060..c1d88de 100644 --- a/bin/varnishd/storage_persistent.c +++ b/bin/varnishd/storage_persistent.c @@ -303,8 +303,8 @@ smp_thread(struct sess *sp, void *priv) smp_load_seg(sp, sc, sg); sc->flags |= SMP_SC_LOADED; - BAN_Deref(&sc->tailban); - sc->tailban = NULL; + BAN_TailDeref(&sc->tailban); + AZ(sc->tailban); printf("Silo completely loaded\n"); while (1) { (void)sleep (1); @@ -352,6 +352,11 @@ smp_open(const struct stevedore *st) if (smp_open_segs(sc, &sc->seg1)) AZ(smp_open_segs(sc, &sc->seg2)); + /* + * Grap a reference to the tail of the ban list, until the thread + * has loaded all objects, so we can be sure that all of our + * proto-bans survive until then. + */ sc->tailban = BAN_TailRef(); AN(sc->tailban); From phk at varnish-cache.org Fri May 6 11:10:26 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Fri, 06 May 2011 13:10:26 +0200 Subject: [master] 1704e16 Change a typedef to _s suffix for clarity Message-ID: commit 1704e16a6611a8757357562de983ffc078a8c493 Author: Poul-Henning Kamp Date: Fri May 6 09:34:46 2011 +0000 Change a typedef to _s suffix for clarity diff --git a/bin/varnishd/cache_ban.c b/bin/varnishd/cache_ban.c index 1065e35..2cac80f 100644 --- a/bin/varnishd/cache_ban.c +++ b/bin/varnishd/cache_ban.c @@ -56,7 +56,7 @@ #include "cache_ban.h" -static VTAILQ_HEAD(banhead,ban) ban_head = VTAILQ_HEAD_INITIALIZER(ban_head); +static VTAILQ_HEAD(banhead_s,ban) ban_head = VTAILQ_HEAD_INITIALIZER(ban_head); static struct lock ban_mtx; static struct ban *ban_magic; static pthread_t ban_thread; @@ -322,7 +322,7 @@ BAN_Insert(struct ban *b) VSC_main->n_ban++; VSC_main->n_ban_add++; - be = VTAILQ_LAST(&ban_head, banhead); + be = VTAILQ_LAST(&ban_head, banhead_s); if (params->ban_dups && be != b) be->refcount++; else @@ -380,7 +380,7 @@ BAN_CheckLast(void) struct ban *b; Lck_AssertHeld(&ban_mtx); - b = VTAILQ_LAST(&ban_head, banhead); + b = VTAILQ_LAST(&ban_head, banhead_s); if (b != VTAILQ_FIRST(&ban_head) && b->refcount == 0) { VSC_main->n_ban--; VSC_main->n_ban_retire++; @@ -523,7 +523,7 @@ ban_lurker(struct sess *sp, void *priv) /* Then try to poke the first object on the last ban */ oc = NULL; while (1) { - b = VTAILQ_LAST(&ban_head, banhead); + b = VTAILQ_LAST(&ban_head, banhead_s); if (b == ban_start) break; oc = VTAILQ_FIRST(&b->objcore); @@ -574,7 +574,7 @@ BAN_TailRef(void) struct ban *b; ASSERT_CLI(); - b = VTAILQ_LAST(&ban_head, banhead); + b = VTAILQ_LAST(&ban_head, banhead_s); AN(b); b->refcount++; return (b); @@ -760,7 +760,7 @@ ccf_ban_list(struct cli *cli, const char * const *av, void *priv) /* Attempt to purge last ban entry */ Lck_Lock(&ban_mtx); b = BAN_CheckLast(); - bl = VTAILQ_LAST(&ban_head, banhead); + bl = VTAILQ_LAST(&ban_head, banhead_s); if (b == NULL) bl->refcount++; Lck_Unlock(&ban_mtx); From phk at varnish-cache.org Fri May 6 11:10:27 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Fri, 06 May 2011 13:10:27 +0200 Subject: [master] 4c18047 Overhaul the ban_lurker to avoid a race condition where it checks an object at the same time a request-lookup does. Message-ID: commit 4c18047ef64fb5a40f229dfb0e30dc85530ffb7e Author: Poul-Henning Kamp Date: Fri May 6 11:07:11 2011 +0000 Overhaul the ban_lurker to avoid a race condition where it checks an object at the same time a request-lookup does. The functional solution to this race is to hold the objhdr mutex, which we already hold briefly to get the refcount, also when we do the check. In terms of souce code this inlines the problematic HSH_FindBan() function in the lurker. And since that was major surgery af few other acts of improvement was carried out also. Most notably, we will now scan all applicable bans in the lurker and not give up on the first ban that tests req.* variables. diff --git a/bin/varnishd/cache_ban.c b/bin/varnishd/cache_ban.c index 2cac80f..94ff84d 100644 --- a/bin/varnishd/cache_ban.c +++ b/bin/varnishd/cache_ban.c @@ -421,7 +421,7 @@ ban_check_object(struct object *o, const struct sess *sp, int has_req) struct objcore *oc; struct ban_test *bt; struct ban * volatile b0; - unsigned tests; + unsigned tests, skipped; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); @@ -441,12 +441,19 @@ ban_check_object(struct object *o, const struct sess *sp, int has_req) * inspect the list past that ban. */ tests = 0; + skipped = 0; for (b = b0; b != oc->ban; b = VTAILQ_NEXT(b, list)) { CHECK_OBJ_NOTNULL(b, BAN_MAGIC); if (b->flags & BAN_F_GONE) continue; - if (!has_req && (b->flags & BAN_F_REQ)) - return (0); + if (!has_req && (b->flags & BAN_F_REQ)) { + /* + * We cannot test this one, but there might + * be other bans that match, so we soldier on + */ + skipped++; + continue; + } VTAILQ_FOREACH(bt, &b->tests, list) { tests++; if (bt->func(bt, o, sp)) @@ -456,6 +463,14 @@ ban_check_object(struct object *o, const struct sess *sp, int has_req) break; } + if (b == oc->ban && skipped > 0) { + /* + * Not banned, but some tests were skipped, so we cannot know + * for certain that it cannot be, so we just have to give up. + */ + return (0); + } + Lck_Lock(&ban_mtx); oc->ban->refcount--; VTAILQ_REMOVE(&oc->ban->objcore, oc, ban_list); @@ -487,67 +502,105 @@ int BAN_CheckObject(struct object *o, const struct sess *sp) { - return ban_check_object(o, sp, 1); + return (ban_check_object(o, sp, 1)); } /*-------------------------------------------------------------------- * Ban tail lurker thread */ -static void * __match_proto__(bgthread_t) -ban_lurker(struct sess *sp, void *priv) +static void +ban_lurker_work(const struct sess *sp) { struct ban *b, *bf; - struct objcore *oc; + struct objhead *oh; + struct objcore *oc, *oc2; struct object *o; int i; - (void)priv; - while (1) { - WSL_Flush(sp->wrk, 0); - WRK_SumStat(sp->wrk); - if (params->ban_lurker_sleep == 0.0) { - AZ(sleep(1)); - continue; - } - Lck_Lock(&ban_mtx); + WSL_Flush(sp->wrk, 0); + WRK_SumStat(sp->wrk); - /* First try to route the last ban */ - bf = BAN_CheckLast(); - if (bf != NULL) { - Lck_Unlock(&ban_mtx); - BAN_Free(bf); - TIM_sleep(params->ban_lurker_sleep); - continue; - } - /* Then try to poke the first object on the last ban */ - oc = NULL; - while (1) { - b = VTAILQ_LAST(&ban_head, banhead_s); - if (b == ban_start) - break; - oc = VTAILQ_FIRST(&b->objcore); - if (oc == NULL) - break; - HSH_FindBan(sp, &oc); + Lck_Lock(&ban_mtx); + + /* First try to route the last ban */ + bf = BAN_CheckLast(); + if (bf != NULL) { + Lck_Unlock(&ban_mtx); + BAN_Free(bf); + return; + } + + /* Find the last ban give up, if we have only one */ + b = VTAILQ_LAST(&ban_head, banhead_s); + if (b == ban_start) { + Lck_Unlock(&ban_mtx); + return; + } + + /* Find the first object on it, if any */ + oc = VTAILQ_FIRST(&b->objcore); + if (oc == NULL) { + Lck_Unlock(&ban_mtx); + return; + } + + /* Try to lock the objhead */ + oh = oc->objhead; + CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC); + if (Lck_Trylock(&oh->mtx)) { + Lck_Unlock(&ban_mtx); + return; + } + + /* + * See if the objcore is still on the objhead since we race against + * HSH_Deref() which comes in the opposite locking order. + */ + VTAILQ_FOREACH(oc2, &oh->objcs, list) + if (oc == oc2) break; - } + if (oc2 == NULL) { + Lck_Unlock(&oh->mtx); Lck_Unlock(&ban_mtx); - if (oc == NULL) { + return; + } + /* + * Grab a reference to the OC and we can let go of the BAN mutex + */ + AN(oc->refcnt); + oc->refcnt++; + Lck_Unlock(&ban_mtx); + + /* + * Get the object and check it against all relevant bans + */ + o = oc_getobj(sp->wrk, oc); + i = ban_check_object(o, sp, 0); + Lck_Unlock(&oh->mtx); + WSP(sp, SLT_Debug, "lurker: %p %g %d", oc, o->exp.ttl, i); + (void)HSH_Deref(sp->wrk, NULL, &o); +} + +static void * __match_proto__(bgthread_t) +ban_lurker(struct sess *sp, void *priv) +{ + + (void)priv; + while (1) { + if (params->ban_lurker_sleep == 0.0) { + /* Lurker is disabled. */ TIM_sleep(1.0); continue; } - // AZ(oc->flags & OC_F_PERSISTENT); - o = oc_getobj(sp->wrk, oc); - i = ban_check_object(o, sp, 0); - WSP(sp, SLT_Debug, "lurker: %p %g %d", oc, o->exp.ttl, i); - (void)HSH_Deref(sp->wrk, NULL, &o); TIM_sleep(params->ban_lurker_sleep); + ban_lurker_work(sp); + WSL_Flush(sp->wrk, 0); + WRK_SumStat(sp->wrk); } NEEDLESS_RETURN(NULL); } - /*-------------------------------------------------------------------- * Release a tail reference */ @@ -680,12 +733,14 @@ BAN_Compile(void) av = ParseArgv(b->test, 0); XXXAN(av); XXXAZ(av[0]); - for (i = 1; av[i] != NULL; i += 3) { - if (i != 1) { - AZ(strcmp(av[i], "&&")); - i++; - } - AZ(BAN_AddTest(NULL, b, av[i], av[i + 1], av[i + 2])); + XXXAN(av[1]); + XXXAN(av[2]); + XXXAN(av[3]); + AZ(BAN_AddTest(NULL, b, av[1], av[2], av[3])); + for (i = 4; av[i] != NULL; i += 4) { + AZ(strcmp(av[i], "&&")); + AZ(BAN_AddTest(NULL, b, + av[i + 1], av[i + 2], av[i + 3])); } } ban_start = VTAILQ_FIRST(&ban_head); diff --git a/bin/varnishd/cache_hash.c b/bin/varnishd/cache_hash.c index bb18642..c25d0ab 100644 --- a/bin/varnishd/cache_hash.c +++ b/bin/varnishd/cache_hash.c @@ -710,43 +710,6 @@ HSH_Deref(struct worker *w, struct objcore *oc, struct object **oo) return (0); } -/*-------------------------------------------------------------------- - * This one is slightly tricky. This is called from the BAN module - * to try to wash the object which holds the oldest ban. - * We compete against HSH_Deref() which comes in the opposite - * locking order, we need to hold the BAN mutex, to stop the - * BAN_DestroyObj() call in HSH_Deref(), so that the objhead - * will not be removed under us. - * NB: Do not call this function any other way or from any other - * NB: place in the code. It will not work for you. - */ - -void -HSH_FindBan(const struct sess *sp, struct objcore **oc) -{ - struct objcore *oc1, *oc2; - struct objhead *oh; - - oc1 = *oc; - CHECK_OBJ_NOTNULL(oc1, OBJCORE_MAGIC); - oh = oc1->objhead; - CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC); - if (Lck_Trylock(&oh->mtx)) { - *oc = NULL; - return; - } - VTAILQ_FOREACH(oc2, &oh->objcs, list) - if (oc1 == oc2) - break; - if (oc2 != NULL) - (void)oc_getobj(sp->wrk, oc2); - if (oc2 != NULL) - oc2->refcnt++; - Lck_Unlock(&oh->mtx); - *oc = oc2; -} - - void HSH_Init(void) { diff --git a/bin/varnishd/hash_slinger.h b/bin/varnishd/hash_slinger.h index 65367ad..42fa50b 100644 --- a/bin/varnishd/hash_slinger.h +++ b/bin/varnishd/hash_slinger.h @@ -59,7 +59,6 @@ void HSH_Ref(struct objcore *o); void HSH_Drop(struct sess *sp); void HSH_Init(void); void HSH_AddString(const struct sess *sp, const char *str); -void HSH_FindBan(const struct sess *sp, struct objcore **oc); struct objcore *HSH_Insert(const struct sess *sp); void HSH_Purge(const struct sess *, struct objhead *, double ttl, double grace); void HSH_config(const char *h_arg); From phk at varnish-cache.org Fri May 6 11:10:28 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Fri, 06 May 2011 13:10:28 +0200 Subject: [master] a15f37d Merge branch 'master' of ssh://git.varnish-cache.org/git/varnish-cache Message-ID: commit a15f37d32766d8a923f67cb0ff98f00240cecc1a Merge: 4c18047 f8dd5cc Author: Poul-Henning Kamp Date: Fri May 6 11:10:20 2011 +0000 Merge branch 'master' of ssh://git.varnish-cache.org/git/varnish-cache From tfheen at varnish-cache.org Fri May 6 13:17:07 2011 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Fri, 06 May 2011 15:17:07 +0200 Subject: [master] a69a488 Implement support for multiple matches in varnish tools Message-ID: commit a69a488296aa644f7439677894bfcd0d0d9b477f Author: Tollef Fog Heen Date: Wed Apr 27 10:35:17 2011 +0200 Implement support for multiple matches in varnish tools Make -o tag:regex only act on transactions where the regex matches tag, generalised from what varnishlog and varnishncsa already had support for. In addition, support multiple -o options which are then and-ed together. diff --git a/bin/varnishhist/varnishhist.c b/bin/varnishhist/varnishhist.c index bfda305..5ff237a 100644 --- a/bin/varnishhist/varnishhist.c +++ b/bin/varnishhist/varnishhist.c @@ -65,6 +65,7 @@ static unsigned next_hist; static unsigned bucket_miss[HIST_BUCKETS]; static unsigned bucket_hit[HIST_BUCKETS]; static unsigned char hh[FD_SETSIZE]; +static uint64_t bitmap[FD_SETSIZE]; static double log_ten; @@ -146,12 +147,12 @@ update(struct VSM_data *vd) static int h_hist(void *priv, enum vsl_tag tag, unsigned fd, unsigned len, - unsigned spec, const char *ptr) + unsigned spec, const char *ptr, uint64_t bm) { double b; int i, j; + struct VSM_data *vd = priv; - (void)priv; (void)len; (void)spec; @@ -159,6 +160,8 @@ h_hist(void *priv, enum vsl_tag tag, unsigned fd, unsigned len, /* oops */ return (0); + bitmap[fd] |= bm; + if (tag == SLT_Hit) { hh[fd] = 1; return (0); @@ -166,6 +169,12 @@ h_hist(void *priv, enum vsl_tag tag, unsigned fd, unsigned len, if (tag != SLT_ReqEnd) return (0); + if (!VSL_Matched(vd, bitmap[fd])) { + bitmap[fd] = 0; + hh[fd] = 0; + return (0); + } + /* determine processing time */ #if 1 i = sscanf(ptr, "%*d %*f %*f %*f %lf", &b); @@ -212,6 +221,7 @@ h_hist(void *priv, enum vsl_tag tag, unsigned fd, unsigned len, next_hist = 0; } hh[fd] = 0; + bitmap[fd] = 0; pthread_mutex_unlock(&mtx); @@ -225,7 +235,7 @@ accumulate_thread(void *arg) int i; for (;;) { - i = VSL_Dispatch(vd, h_hist, NULL); + i = VSL_Dispatch(vd, h_hist, vd); if (i < 0) break; if (i == 0) diff --git a/bin/varnishlog/varnishlog.c b/bin/varnishlog/varnishlog.c index 81593c6..26bb3cb 100644 --- a/bin/varnishlog/varnishlog.c +++ b/bin/varnishlog/varnishlog.c @@ -51,47 +51,28 @@ static int b_flag, c_flag; -/* -------------------------------------------------------------------*/ - -static int -name2tag(const char *n) -{ - int i; - - for (i = 0; i < 256; i++) { - if (VSL_tags[i] == NULL) - continue; - if (!strcasecmp(n, VSL_tags[i])) - return (i); - } - return (-1); -} - /* Ordering-----------------------------------------------------------*/ static struct vsb *ob[65536]; static unsigned char flg[65536]; static enum vsl_tag last[65536]; +static uint64_t bitmap[65536]; #define F_INVCL (1 << 0) -#define F_MATCH (1 << 1) - -static int match_tag = -1; -static const vre_t *match_re; static void -h_order_finish(int fd) +h_order_finish(int fd, struct VSM_data *vd) { AZ(vsb_finish(ob[fd])); - if (vsb_len(ob[fd]) > 1 && - (match_tag == -1 || flg[fd] & F_MATCH)) + if (vsb_len(ob[fd]) > 1 && VSL_Matched(vd, bitmap[fd])) { printf("%s\n", vsb_data(ob[fd])); - flg[fd] &= ~F_MATCH; + } + bitmap[fd] = 0; vsb_clear(ob[fd]); } static void -clean_order(void) +clean_order(struct VSM_data *vd) { unsigned u; @@ -99,38 +80,37 @@ clean_order(void) if (ob[u] == NULL) continue; AZ(vsb_finish(ob[u])); - if (vsb_len(ob[u]) > 1 && - (match_tag == -1 || flg[u] & F_MATCH)) + if (vsb_len(ob[u]) > 1 && VSL_Matched(vd, bitmap[u])) { printf("%s\n", vsb_data(ob[u])); + } flg[u] = 0; + bitmap[u] = 0; vsb_clear(ob[u]); } } static int h_order(void *priv, enum vsl_tag tag, unsigned fd, unsigned len, - unsigned spec, const char *ptr) + unsigned spec, const char *ptr, uint64_t bm) { char type; - (void)priv; + struct VSM_data *vd = priv; + + bitmap[fd] |= bm; type = (spec & VSL_S_CLIENT) ? 'c' : (spec & VSL_S_BACKEND) ? 'b' : '-'; if (!(spec & (VSL_S_CLIENT|VSL_S_BACKEND))) { if (!b_flag && !c_flag) - (void)VSL_H_Print(stdout, tag, fd, len, spec, ptr); + (void)VSL_H_Print(stdout, tag, fd, len, spec, ptr, bm); return (0); } if (ob[fd] == NULL) { ob[fd] = vsb_new_auto(); assert(ob[fd] != NULL); } - if (tag == match_tag && - VRE_exec(match_re, ptr, len, 0, 0, NULL, 0) > 0) - flg[fd] |= F_MATCH; - if ((tag == SLT_BackendOpen || tag == SLT_SessionOpen || (tag == SLT_ReqStart && last[fd] != SLT_SessionOpen && @@ -146,7 +126,7 @@ h_order(void *priv, enum vsl_tag tag, unsigned fd, unsigned len, if (last[fd] != SLT_SessionClose) vsb_printf(ob[fd], "%5d %-12s %c %s\n", fd, "Interrupted", type, VSL_tags[tag]); - h_order_finish(fd); + h_order_finish(fd, vd); } last[fd] = tag; @@ -182,7 +162,7 @@ h_order(void *priv, enum vsl_tag tag, unsigned fd, unsigned len, case SLT_BackendClose: case SLT_BackendReuse: case SLT_StatSess: - h_order_finish(fd); + h_order_finish(fd, vd); break; default: break; @@ -191,24 +171,10 @@ h_order(void *priv, enum vsl_tag tag, unsigned fd, unsigned len, } static void -do_order(struct VSM_data *vd, int argc, char * const *argv) +do_order(struct VSM_data *vd) { int i; - const char *error; - int erroroffset; - - if (argc == 2) { - match_tag = name2tag(argv[0]); - if (match_tag < 0) { - fprintf(stderr, "Tag \"%s\" unknown\n", argv[0]); - exit(2); - } - match_re = VRE_compile(argv[1], 0, &error, &erroroffset); - if (match_re == NULL) { - fprintf(stderr, "Invalid regex: %s\n", error); - exit(2); - } - } + if (!b_flag) { VSL_Select(vd, SLT_SessionOpen); VSL_Select(vd, SLT_SessionClose); @@ -220,15 +186,15 @@ do_order(struct VSM_data *vd, int argc, char * const *argv) VSL_Select(vd, SLT_BackendReuse); } while (1) { - i = VSL_Dispatch(vd, h_order, NULL); + i = VSL_Dispatch(vd, h_order, vd); if (i == 0) { - clean_order(); + clean_order(vd); AZ(fflush(stdout)); } else if (i < 0) break; } - clean_order(); + clean_order(vd); } /*--------------------------------------------------------------------*/ @@ -273,7 +239,7 @@ do_write(const struct VSM_data *vd, const char *w_arg, int a_flag) XXXAN(fd >= 0); (void)signal(SIGHUP, sighup); while (1) { - i = VSL_NextLog(vd, &p); + i = VSL_NextLog(vd, &p, NULL); if (i < 0) break; if (i > 0) { @@ -317,7 +283,7 @@ main(int argc, char * const *argv) vd = VSM_New(); VSL_Setup(vd); - while ((c = getopt(argc, argv, VSL_ARGS "aDoP:uVw:")) != -1) { + while ((c = getopt(argc, argv, VSL_ARGS "aDP:uVw:")) != -1) { switch (c) { case 'a': a_flag = 1; @@ -335,6 +301,7 @@ main(int argc, char * const *argv) break; case 'o': o_flag = 1; + AN(VSL_Arg(vd, c, optarg)); break; case 'P': P_arg = optarg; @@ -386,7 +353,7 @@ main(int argc, char * const *argv) setbuf(stdout, NULL); if (o_flag) - do_order(vd, argc - optind, argv + optind); + do_order(vd); while (VSL_Dispatch(vd, VSL_H_Print, stdout) >= 0) { if (fflush(stdout) != 0) { diff --git a/bin/varnishncsa/varnishncsa.c b/bin/varnishncsa/varnishncsa.c index 0124705..308fab2 100644 --- a/bin/varnishncsa/varnishncsa.c +++ b/bin/varnishncsa/varnishncsa.c @@ -100,32 +100,18 @@ static struct logline { const char *df_handling; /* How the request was handled (hit/miss/pass/pipe) */ int active; /* Is log line in an active trans */ int complete; /* Is log line complete */ - int matched; /* Did log line match */ + uint64_t bitmap; /* Bitmap for regex matches */ } **ll; +struct VSM_data *vd; + static size_t nll; static int o_flag = 0; -static int match_tag; -static const vre_t *match_tag_re; static const char *format; static int -name2tag(const char *n) -{ - int i; - - for (i = 0; i < 256; i++) { - if (VSL_tags[i] == NULL) - continue; - if (!strcasecmp(n, VSL_tags[i])) - return (i); - } - return (-1); -} - -static int isprefix(const char *str, const char *prefix, const char *end, const char **next) { @@ -346,11 +332,6 @@ collect_client(struct logline *lp, enum vsl_tag tag, unsigned spec, assert(spec & VSL_S_CLIENT); end = ptr + len; - /* Do -o matching if specified */ - if (o_flag && match_tag == tag && lp->active && - VRE_exec(match_tag_re, ptr, len, 0, 0, NULL, 0) > 0) - lp->matched = 1; - switch (tag) { case SLT_ReqStart: if (lp->active || lp->df_h != NULL) { @@ -496,7 +477,7 @@ collect_client(struct logline *lp, enum vsl_tag tag, unsigned spec, static int h_ncsa(void *priv, enum vsl_tag tag, unsigned fd, - unsigned len, unsigned spec, const char *ptr) + unsigned len, unsigned spec, const char *ptr, uint64_t bitmap) { struct logline *lp; FILE *fo = priv; @@ -530,10 +511,12 @@ h_ncsa(void *priv, enum vsl_tag tag, unsigned fd, return (reopen); } + lp->bitmap |= bitmap; + if (!lp->complete) return (reopen); - if (o_flag && !lp->matched) + if (o_flag && !VSL_Matched(vd, lp->bitmap)) /* -o is in effect matching rule failed. Don't display */ return (reopen); @@ -738,14 +721,13 @@ main(int argc, char *argv[]) const char *P_arg = NULL; const char *w_arg = NULL; struct pidfh *pfh = NULL; - struct VSM_data *vd; FILE *of; format = "%h %l %u %t \"%r\" %s %b \"%{Referer}i\" \"%{User-agent}i\""; vd = VSM_New(); VSL_Setup(vd); - while ((c = getopt(argc, argv, VSL_ARGS "aDP:Vw:foF:")) != -1) { + while ((c = getopt(argc, argv, VSL_ARGS "aDP:Vw:fF:")) != -1) { switch (c) { case 'a': a_flag = 1; @@ -795,7 +777,9 @@ main(int argc, char *argv[]) break; case 'o': o_flag = 1; - break; + if (VSL_Arg(vd, c, optarg) > 0) + break; + usage(); default: if (VSL_Arg(vd, c, optarg) > 0) break; @@ -805,26 +789,6 @@ main(int argc, char *argv[]) VSL_Arg(vd, 'c', optarg); - if (o_flag) { - const char *error; - int erroroffset; - - if (argc-optind != 2) { - fprintf(stderr, "Wrong number of arguments when using -o\n"); - exit(2); - } - match_tag = name2tag(argv[optind]); - if (match_tag < 0) { - fprintf(stderr, "Tag \"%s\" unknown\n", argv[optind]); - exit(2); - } - match_tag_re = VRE_compile(argv[optind + 1], 0, &error, &erroroffset); - if (match_tag_re==NULL) { - fprintf(stderr, "Invalid regex: %s\n", error); - exit(2); - } - } - if (VSL_Open(vd, 1)) exit(1); diff --git a/bin/varnishreplay/varnishreplay.c b/bin/varnishreplay/varnishreplay.c index b582d91..2ef996f 100644 --- a/bin/varnishreplay/varnishreplay.c +++ b/bin/varnishreplay/varnishreplay.c @@ -640,13 +640,14 @@ clear: static int gen_traffic(void *priv, enum vsl_tag tag, unsigned fd, - unsigned len, unsigned spec, const char *ptr) + unsigned len, unsigned spec, const char *ptr, uint64_t bitmap) { struct replay_thread *thr; const char *end; struct message *msg; (void)priv; + (void)bitmap; end = ptr + len; diff --git a/bin/varnishsizes/varnishsizes.c b/bin/varnishsizes/varnishsizes.c index 8fd15bc..29c218b 100644 --- a/bin/varnishsizes/varnishsizes.c +++ b/bin/varnishsizes/varnishsizes.c @@ -65,6 +65,7 @@ static unsigned next_hist; static unsigned bucket_miss[HIST_BUCKETS]; static unsigned bucket_hit[HIST_BUCKETS]; static unsigned char hh[FD_SETSIZE]; +static uint64_t bitmap[FD_SETSIZE]; static double log_ten; @@ -146,12 +147,12 @@ update(struct VSM_data *vd) static int h_hist(void *priv, enum vsl_tag tag, unsigned fd, unsigned len, - unsigned spec, const char *ptr) + unsigned spec, const char *ptr, uint64_t bm) { double b; int i, j, tmp; + struct VSM_data *vd = priv; - (void)priv; (void)len; (void)spec; @@ -159,6 +160,8 @@ h_hist(void *priv, enum vsl_tag tag, unsigned fd, unsigned len, /* oops */ return (0); + bitmap[fd] |= bm; + if (tag == SLT_Hit) { hh[fd] = 1; return (0); @@ -166,6 +169,12 @@ h_hist(void *priv, enum vsl_tag tag, unsigned fd, unsigned len, if (tag != SLT_Length) return (0); + if (!VSL_Matched(vd, bitmap[fd])) { + bitmap[fd] = 0; + hh[fd] = 0; + return (0); + } + /* determine processing time */ i = sscanf(ptr, "%d", &tmp); assert(i == 1); @@ -213,6 +222,7 @@ h_hist(void *priv, enum vsl_tag tag, unsigned fd, unsigned len, next_hist = 0; } hh[fd] = 0; + bitmap[fd] = 0; pthread_mutex_unlock(&mtx); @@ -226,7 +236,7 @@ accumulate_thread(void *arg) int i; for (;;) { - i = VSL_Dispatch(vd, h_hist, NULL); + i = VSL_Dispatch(vd, h_hist, vd); if (i < 0) break; if (i == 0) diff --git a/bin/varnishtop/varnishtop.c b/bin/varnishtop/varnishtop.c index 4224bf9..eca542d 100644 --- a/bin/varnishtop/varnishtop.c +++ b/bin/varnishtop/varnishtop.c @@ -195,7 +195,7 @@ accumulate_thread(void *arg) for (;;) { - i = VSL_NextLog(vd, &p); + i = VSL_NextLog(vd, &p, NULL); if (i < 0) break; if (i == 0) { @@ -292,7 +292,7 @@ do_once(struct VSM_data *vd) { uint32_t *p; - while (VSL_NextLog(vd, &p) > 0) + while (VSL_NextLog(vd, &p, NULL) > 0) accumulate(p); dump(); } @@ -335,6 +335,9 @@ main(int argc, char **argv) case 'V': varnish_version("varnishtop"); exit(0); + case 'o': + fprintf(stderr, "-o is not supported\n"); + exit(1); default: if (VSL_Arg(vd, o, optarg) > 0) break; diff --git a/include/varnishapi.h b/include/varnishapi.h index 7524842..cda0bb3 100644 --- a/include/varnishapi.h +++ b/include/varnishapi.h @@ -214,7 +214,7 @@ int VSL_Open(struct VSM_data *vd, int diag); * != 0 on failure */ -#define VSL_ARGS "bCcdI:i:k:n:r:s:X:x:" +#define VSL_ARGS "bCcdI:i:k:n:r:s:X:x:o:" #define VSL_b_USAGE "[-b]" #define VSL_c_USAGE "[-c]" #define VSL_C_USAGE "[-C]" @@ -223,6 +223,7 @@ int VSL_Open(struct VSM_data *vd, int diag); #define VSL_I_USAGE "[-I regexp]" #define VSL_k_USAGE "[-k keep]" #define VSL_n_USAGE VSM_n_USAGE +#define VSL_o_USAGE "[-o tag:regex]" #define VSL_r_USAGE "[-r file]" #define VSL_s_USAGE "[-s skip]" #define VSL_x_USAGE "[-x tag]" @@ -232,6 +233,7 @@ int VSL_Open(struct VSM_data *vd, int diag); VSL_I_USAGE " " \ VSL_k_USAGE " " \ VSL_n_USAGE " " \ + VSL_o_USAGE " " \ VSL_r_USAGE " " \ VSL_s_USAGE " " \ VSL_X_USAGE " " \ @@ -247,7 +249,8 @@ int VSL_Arg(struct VSM_data *vd, int arg, const char *opt); */ typedef int vsl_handler(void *priv, enum vsl_tag tag, unsigned fd, - unsigned len, unsigned spec, const char *ptr); + unsigned len, unsigned spec, const char *ptr, uint64_t bitmap); + #define VSL_S_CLIENT (1 << 0) #define VSL_S_BACKEND (1 << 1) vsl_handler VSL_H_Print; @@ -255,7 +258,8 @@ struct VSM_data; void VSL_Select(const struct VSM_data *vd, unsigned tag); void VSL_NonBlocking(const struct VSM_data *vd, int nb); int VSL_Dispatch(struct VSM_data *vd, vsl_handler *func, void *priv); -int VSL_NextLog(const struct VSM_data *lh, uint32_t **pp); +int VSL_NextLog(const struct VSM_data *lh, uint32_t **pp, uint64_t *bitmap); +int VSL_Matched(const struct VSM_data *vd, uint64_t bitmap); extern const char *VSL_tags[256]; diff --git a/lib/libvarnishapi/vsl.c b/lib/libvarnishapi/vsl.c index 6d5f4e5..23d2ff7 100644 --- a/lib/libvarnishapi/vsl.c +++ b/lib/libvarnishapi/vsl.c @@ -85,6 +85,9 @@ VSL_Setup(struct VSM_data *vd) vsl->rbuflen = 256; /* XXX ?? */ vsl->rbuf = malloc(vsl->rbuflen * 4L); assert(vsl->rbuf != NULL); + + vsl->num_matchers = 0; + VTAILQ_INIT(&vsl->matchers); } /*--------------------------------------------------------------------*/ @@ -193,7 +196,7 @@ vsl_nextlog(struct vsl *vsl, uint32_t **pp) } int -VSL_NextLog(const struct VSM_data *vd, uint32_t **pp) +VSL_NextLog(const struct VSM_data *vd, uint32_t **pp, uint64_t *mb) { struct vsl *vsl; uint32_t *p; @@ -255,6 +258,19 @@ VSL_NextLog(const struct VSM_data *vd, uint32_t **pp) if (i != VRE_ERROR_NOMATCH) continue; } + if (mb != NULL) { + struct vsl_re_match *vrm; + int j = 0; + VTAILQ_FOREACH(vrm, &vsl->matchers, next) { + if (vrm->tag == t) { + i = VRE_exec(vrm->re, VSL_DATA(p), + VSL_LEN(p), 0, 0, NULL, 0); + if (i >= 0) + *mb |= 1 << j; + } + j++; + } + } *pp = p; return (1); } @@ -269,13 +285,15 @@ VSL_Dispatch(struct VSM_data *vd, vsl_handler *func, void *priv) int i; unsigned u, l, s; uint32_t *p; + uint64_t bitmap; CHECK_OBJ_NOTNULL(vd, VSM_MAGIC); vsl = vd->vsl; CHECK_OBJ_NOTNULL(vsl, VSL_MAGIC); while (1) { - i = VSL_NextLog(vd, &p); + bitmap = 0; + i = VSL_NextLog(vd, &p, &bitmap); if (i == 0 && VSM_ReOpen(vd, 0) == 1) continue; if (i != 1) @@ -287,7 +305,7 @@ VSL_Dispatch(struct VSM_data *vd, vsl_handler *func, void *priv) s |= VSL_S_BACKEND; if (vbit_test(vsl->vbm_client, u)) s |= VSL_S_CLIENT; - if (func(priv, VSL_TAG(p), u, l, s, VSL_DATA(p))) + if (func(priv, VSL_TAG(p), u, l, s, VSL_DATA(p), bitmap)) return (1); } } @@ -296,11 +314,12 @@ VSL_Dispatch(struct VSM_data *vd, vsl_handler *func, void *priv) int VSL_H_Print(void *priv, enum vsl_tag tag, unsigned fd, unsigned len, - unsigned spec, const char *ptr) + unsigned spec, const char *ptr, uint64_t bitmap) { FILE *fo = priv; int type; + (void) bitmap; assert(fo != NULL); type = (spec & VSL_S_CLIENT) ? 'c' : @@ -366,3 +385,15 @@ VSL_Open(struct VSM_data *vd, int diag) } return (0); } + +/*--------------------------------------------------------------------*/ + +int VSL_Matched(const struct VSM_data *vd, uint64_t bitmap) +{ + if (vd->vsl->num_matchers > 0) { + uint64_t t; + t = vd->vsl->num_matchers | (vd->vsl->num_matchers - 1); + return (bitmap == t); + } + return (1); +} diff --git a/lib/libvarnishapi/vsl_api.h b/lib/libvarnishapi/vsl_api.h index 29e0b4b..edf73eb 100644 --- a/lib/libvarnishapi/vsl_api.h +++ b/lib/libvarnishapi/vsl_api.h @@ -28,6 +28,16 @@ * */ +#include "vqueue.h" + +struct vsl_re_match { + unsigned magic; +#define VSL_RE_MATCH_MAGIC 0x4013151e + int tag; + vre_t *re; + VTAILQ_ENTRY(vsl_re_match) next; +}; + struct vsl { unsigned magic; #define VSL_MAGIC 0x7a31db38 @@ -73,7 +83,10 @@ struct vsl { int regflags; vre_t *regincl; vre_t *regexcl; + int num_matchers; + VTAILQ_HEAD(, vsl_re_match) matchers; unsigned long skip; unsigned long keep; }; + diff --git a/lib/libvarnishapi/vsl_arg.c b/lib/libvarnishapi/vsl_arg.c index bc610f2..502ad09 100644 --- a/lib/libvarnishapi/vsl_arg.c +++ b/lib/libvarnishapi/vsl_arg.c @@ -149,6 +149,64 @@ vsl_ix_arg(const struct VSM_data *vd, const char *opt, int arg) /*--------------------------------------------------------------------*/ static int +name2tag(const char *n) +{ + int i; + + for (i = 0; i < 256; i++) { + if (VSL_tags[i] == NULL) + continue; + if (!strcasecmp(n, VSL_tags[i])) + return (i); + } + return (-1); +} + +static int +vsl_o_arg(const struct VSM_data *vd, const char *opt) +{ + struct vsl_re_match *m; + const char *error; + char *o, *regex; + int erroroffset; + + CHECK_OBJ_NOTNULL(vd, VSM_MAGIC); + ALLOC_OBJ(m, VSL_RE_MATCH_MAGIC); + AN(m); + + if (! index(opt, ':')) { + fprintf(stderr, "No : found in -o option %s\n", opt); + return (-1); + } + + o = strdup(opt); + AN(o); + regex = index(o, ':'); + *regex = '\0'; + regex++; + + m->tag = name2tag(o); + if (m->tag == -1) { + fprintf(stderr, "Illegal tag %s specified\n", o); + free(o); + return (-1); + } + /* Get tag, regex */ + m->re = VRE_compile(regex, vd->vsl->regflags, &error, &erroroffset); + if (m->re == NULL) { + fprintf(stderr, "Illegal regex: %s\n", error); + free(o); + return (-1); + } + vd->vsl->num_matchers++; + VTAILQ_INSERT_TAIL(&vd->vsl->matchers, m, next); + free(o); + return (1); +} + +/*--------------------------------------------------------------------*/ + +static int vsl_s_arg(const struct VSM_data *vd, const char *opt) { char *end; @@ -206,6 +264,7 @@ VSL_Arg(struct VSM_data *vd, int arg, const char *opt) case 'r': return (vsl_r_arg(vd, opt)); case 's': return (vsl_s_arg(vd, opt)); case 'I': case 'X': return (vsl_IX_arg(vd, opt, arg)); + case 'o': return (vsl_o_arg(vd, opt)); case 'C': vd->vsl->regflags = VRE_CASELESS; return (1); default: return (0); From tfheen at varnish-cache.org Fri May 6 13:22:39 2011 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Fri, 06 May 2011 15:22:39 +0200 Subject: [master] 62764ca Rename -o to -m ; documentation Message-ID: commit 62764cacaf9fbd9743f6ceb92a4c71eb713111d7 Author: Tollef Fog Heen Date: Fri May 6 15:22:14 2011 +0200 Rename -o to -m ; documentation Rename -o added in last commit to -m, add documentation. diff --git a/bin/varnishlog/varnishlog.c b/bin/varnishlog/varnishlog.c index 26bb3cb..df6a7bd 100644 --- a/bin/varnishlog/varnishlog.c +++ b/bin/varnishlog/varnishlog.c @@ -315,6 +315,8 @@ main(int argc, char * const *argv) case 'w': w_arg = optarg; break; + case 'm': + o_flag = 1; /* fall through */ default: if (VSL_Arg(vd, c, optarg) > 0) break; diff --git a/bin/varnishncsa/varnishncsa.c b/bin/varnishncsa/varnishncsa.c index 308fab2..308d9fa 100644 --- a/bin/varnishncsa/varnishncsa.c +++ b/bin/varnishncsa/varnishncsa.c @@ -107,7 +107,7 @@ struct VSM_data *vd; static size_t nll; -static int o_flag = 0; +static int m_flag = 0; static const char *format; @@ -516,7 +516,7 @@ h_ncsa(void *priv, enum vsl_tag tag, unsigned fd, if (!lp->complete) return (reopen); - if (o_flag && !VSL_Matched(vd, lp->bitmap)) + if (m_flag && !VSL_Matched(vd, lp->bitmap)) /* -o is in effect matching rule failed. Don't display */ return (reopen); @@ -775,11 +775,8 @@ main(int argc, char *argv[]) case 'c': /* XXX: Silently ignored: it's required anyway */ break; - case 'o': - o_flag = 1; - if (VSL_Arg(vd, c, optarg) > 0) - break; - usage(); + case 'm': + m_flag = 1; /* Fall through */ default: if (VSL_Arg(vd, c, optarg) > 0) break; diff --git a/bin/varnishtop/varnishtop.c b/bin/varnishtop/varnishtop.c index eca542d..c98f154 100644 --- a/bin/varnishtop/varnishtop.c +++ b/bin/varnishtop/varnishtop.c @@ -335,8 +335,8 @@ main(int argc, char **argv) case 'V': varnish_version("varnishtop"); exit(0); - case 'o': - fprintf(stderr, "-o is not supported\n"); + case 'm': + fprintf(stderr, "-m is not supported\n"); exit(1); default: if (VSL_Arg(vd, o, optarg) > 0) diff --git a/doc/sphinx/reference/varnishhist.rst b/doc/sphinx/reference/varnishhist.rst index a89539c..5c0cc05 100644 --- a/doc/sphinx/reference/varnishhist.rst +++ b/doc/sphinx/reference/varnishhist.rst @@ -15,8 +15,8 @@ Varnish request histogram SYNOPSIS ======== -varnishhist [-b] [-C] [-c] [-d] [-I regex] [-i tag] [-n varnish_name] -[-r file] [-V] [-w delay] [-X regex] [-x tag] +varnishhist [-b] [-C] [-c] [-d] [-I regex] [-i tag] [-m tag:regex ...] +[-n varnish_name] [-r file] [-V] [-w delay] [-X regex] [-x tag] DESCRIPTION =========== @@ -51,6 +51,9 @@ The following options are available: -i tag Include log entries with the specified tag. If neither -I nor -i is specified, all log entries are included. +-m tag:regex only count transactions where tag matches regex. Multiple + -m options are AND-ed together. + -n Specifies the name of the varnishd instance to get logs from. If -n is not specified, the host name is used. diff --git a/doc/sphinx/reference/varnishlog.rst b/doc/sphinx/reference/varnishlog.rst index 8af8030..d703b47 100644 --- a/doc/sphinx/reference/varnishlog.rst +++ b/doc/sphinx/reference/varnishlog.rst @@ -17,7 +17,7 @@ SYNOPSIS ======== varnishlog [-a] [-b] [-C] [-c] [-D] [-d] [-I regex] [-i tag] [-k keep] -[-n varnish_name] [-o [tag regex]] [-P file] [-r file] [-s num] [-u] [-V] +[-n varnish_name] [-o] [-m tag:regex ...] [-P file] [-r file] [-s num] [-u] [-V] [-w file] [-X regex] [-x tag] DESCRIPTION @@ -51,6 +51,9 @@ The following options are available: -k num Only show the first num log records. +-m tag:regex only list transactions where tag matches regex. Multiple + -m options are AND-ed together. + -n Specifies the name of the varnishd instance to get logs from. If -n is not specified, the host name is used. diff --git a/doc/sphinx/reference/varnishncsa.rst b/doc/sphinx/reference/varnishncsa.rst index 2cb64af..3fe1b35 100644 --- a/doc/sphinx/reference/varnishncsa.rst +++ b/doc/sphinx/reference/varnishncsa.rst @@ -16,7 +16,7 @@ SYNOPSIS ======== varnishncsa [-a] [-b] [-C] [-c] [-D] [-d] [-f] [-F format] [-I regex] -[-i tag] [-n varnish_name] [-o tag regex] [-P file] [-r file] [-V] [-w file] +[-i tag] [-n varnish_name] [-m tag:regex ...] [-P file] [-r file] [-V] [-w file] [-X regex] [-x tag] @@ -110,8 +110,8 @@ The following options are available: How the request was handled, whether it was a cache hit, miss, pass, pipe or error. --o Filter log output to request groups that match a regular - expression on a specified tag. +-m tag:regex only list records where tag matches regex. Multiple + -m options are AND-ed together. -n Specifies the name of the varnishd instance to get logs from. If -n is not specified, the host name is used. diff --git a/doc/sphinx/reference/varnishsizes.rst b/doc/sphinx/reference/varnishsizes.rst index 045166a..cc36277 100644 --- a/doc/sphinx/reference/varnishsizes.rst +++ b/doc/sphinx/reference/varnishsizes.rst @@ -17,8 +17,8 @@ Varnish object size request histogram SYNOPSIS ======== -varnishsizes [-b] [-C] [-c] [-d] [-I regex] [-i tag] [-n varnish_name] - [-r file] [-V] [-w delay] [-X regex] [-x tag] +varnishsizes [-b] [-C] [-c] [-d] [-I regex] [-i tag] [-m tag:regex ...] + [-n varnish_name] [-r file] [-V] [-w delay] [-X regex] [-x tag] DESCRIPTION =========== @@ -49,6 +49,9 @@ The following options are available: -i tag Include log entries with the specified tag. If neither -I nor -i is specified, all log entries are included. +-m tag:regex only list record where tag matches regex. Multiple -m + options are AND-ed together. + -n Specifies the name of the varnishd instance to get logs from. If -n is not specified, the host name is used. diff --git a/include/varnishapi.h b/include/varnishapi.h index cda0bb3..230bdbb 100644 --- a/include/varnishapi.h +++ b/include/varnishapi.h @@ -214,7 +214,7 @@ int VSL_Open(struct VSM_data *vd, int diag); * != 0 on failure */ -#define VSL_ARGS "bCcdI:i:k:n:r:s:X:x:o:" +#define VSL_ARGS "bCcdI:i:k:n:r:s:X:x:m:" #define VSL_b_USAGE "[-b]" #define VSL_c_USAGE "[-c]" #define VSL_C_USAGE "[-C]" @@ -222,8 +222,8 @@ int VSL_Open(struct VSM_data *vd, int diag); #define VSL_i_USAGE "[-i tag]" #define VSL_I_USAGE "[-I regexp]" #define VSL_k_USAGE "[-k keep]" +#define VSL_m_USAGE "[-m tag:regex]" #define VSL_n_USAGE VSM_n_USAGE -#define VSL_o_USAGE "[-o tag:regex]" #define VSL_r_USAGE "[-r file]" #define VSL_s_USAGE "[-s skip]" #define VSL_x_USAGE "[-x tag]" @@ -232,8 +232,8 @@ int VSL_Open(struct VSM_data *vd, int diag); VSL_i_USAGE " " \ VSL_I_USAGE " " \ VSL_k_USAGE " " \ + VSL_m_USAGE " " \ VSL_n_USAGE " " \ - VSL_o_USAGE " " \ VSL_r_USAGE " " \ VSL_s_USAGE " " \ VSL_X_USAGE " " \ diff --git a/lib/libvarnishapi/vsl_arg.c b/lib/libvarnishapi/vsl_arg.c index 502ad09..a6a2700 100644 --- a/lib/libvarnishapi/vsl_arg.c +++ b/lib/libvarnishapi/vsl_arg.c @@ -163,7 +163,7 @@ name2tag(const char *n) } static int -vsl_o_arg(const struct VSM_data *vd, const char *opt) +vsl_m_arg(const struct VSM_data *vd, const char *opt) { struct vsl_re_match *m; const char *error; @@ -264,7 +264,7 @@ VSL_Arg(struct VSM_data *vd, int arg, const char *opt) case 'r': return (vsl_r_arg(vd, opt)); case 's': return (vsl_s_arg(vd, opt)); case 'I': case 'X': return (vsl_IX_arg(vd, opt, arg)); - case 'o': return (vsl_o_arg(vd, opt)); + case 'm': return (vsl_m_arg(vd, opt)); case 'C': vd->vsl->regflags = VRE_CASELESS; return (1); default: return (0); From tfheen at varnish-cache.org Fri May 6 16:18:00 2011 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Fri, 06 May 2011 18:18:00 +0200 Subject: [master] 4e7def9 Group requests by default in varnishlog Message-ID: commit 4e7def9fb8cb0c760d4bd47a851acd11abfcbcd4 Author: Tollef Fog Heen Date: Fri May 6 18:16:59 2011 +0200 Group requests by default in varnishlog Add -O option to turn off grouping. Get rid of blank line separating requests. diff --git a/bin/varnishlog/varnishlog.c b/bin/varnishlog/varnishlog.c index df6a7bd..c6373f6 100644 --- a/bin/varnishlog/varnishlog.c +++ b/bin/varnishlog/varnishlog.c @@ -65,7 +65,7 @@ h_order_finish(int fd, struct VSM_data *vd) AZ(vsb_finish(ob[fd])); if (vsb_len(ob[fd]) > 1 && VSL_Matched(vd, bitmap[fd])) { - printf("%s\n", vsb_data(ob[fd])); + printf("%s", vsb_data(ob[fd])); } bitmap[fd] = 0; vsb_clear(ob[fd]); @@ -274,7 +274,7 @@ int main(int argc, char * const *argv) { int c; - int a_flag = 0, D_flag = 0, o_flag = 0, u_flag = 0; + int a_flag = 0, D_flag = 0, O_flag = 0, u_flag = 0, m_flag = 0; const char *P_arg = NULL; const char *w_arg = NULL; struct pidfh *pfh = NULL; @@ -283,7 +283,7 @@ main(int argc, char * const *argv) vd = VSM_New(); VSL_Setup(vd); - while ((c = getopt(argc, argv, VSL_ARGS "aDP:uVw:")) != -1) { + while ((c = getopt(argc, argv, VSL_ARGS "aDP:uVw:oO")) != -1) { switch (c) { case 'a': a_flag = 1; @@ -299,9 +299,10 @@ main(int argc, char * const *argv) case 'D': D_flag = 1; break; - case 'o': - o_flag = 1; - AN(VSL_Arg(vd, c, optarg)); + case 'o': /* ignored for compatibility with older versions */ + break; + case 'O': + O_flag = 1; break; case 'P': P_arg = optarg; @@ -316,7 +317,7 @@ main(int argc, char * const *argv) w_arg = optarg; break; case 'm': - o_flag = 1; /* fall through */ + m_flag = 1; /* fall through */ default: if (VSL_Arg(vd, c, optarg) > 0) break; @@ -324,10 +325,10 @@ main(int argc, char * const *argv) } } - if (o_flag && w_arg != NULL) + if (O_flag && m_flag) usage(); - if ((argc - optind) > 0 && !o_flag) + if ((argc - optind) > 0) usage(); if (VSL_Open(vd, 1)) @@ -354,7 +355,7 @@ main(int argc, char * const *argv) if (u_flag) setbuf(stdout, NULL); - if (o_flag) + if (!O_flag) do_order(vd); while (VSL_Dispatch(vd, VSL_H_Print, stdout) >= 0) { diff --git a/doc/sphinx/reference/varnishlog.rst b/doc/sphinx/reference/varnishlog.rst index d703b47..2c74e24 100644 --- a/doc/sphinx/reference/varnishlog.rst +++ b/doc/sphinx/reference/varnishlog.rst @@ -17,7 +17,7 @@ SYNOPSIS ======== varnishlog [-a] [-b] [-C] [-c] [-D] [-d] [-I regex] [-i tag] [-k keep] -[-n varnish_name] [-o] [-m tag:regex ...] [-P file] [-r file] [-s num] [-u] [-V] +[-n varnish_name] [-o] [-O] [-m tag:regex ...] [-P file] [-r file] [-s num] [-u] [-V] [-w file] [-X regex] [-x tag] DESCRIPTION @@ -52,13 +52,15 @@ The following options are available: -k num Only show the first num log records. -m tag:regex only list transactions where tag matches regex. Multiple - -m options are AND-ed together. + -m options are AND-ed together. Can not be combined with -O -n Specifies the name of the varnishd instance to get logs from. If -n is not specified, the host name is used. --o Group log entries by request ID. This has no effect when writing to a - file using the -w option. +-o Ignored for compatibility with earlier versions. + +-O Do not group log entries by request ID. Can not be + combined with -m. -P file Write the process's PID to the specified file. From phk at varnish-cache.org Mon May 9 09:30:20 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 09 May 2011 11:30:20 +0200 Subject: [master] 4f17a11 If the backend sends content-length header and streaming does not gunzip, send content-length to client rather than chunked. Message-ID: commit 4f17a11950fc0e4e66e1997ebb9768317175b8b6 Author: Poul-Henning Kamp Date: Mon May 9 09:29:31 2011 +0000 If the backend sends content-length header and streaming does not gunzip, send content-length to client rather than chunked. This makes progress-bars possible in browsers. diff --git a/bin/varnishd/cache_center.c b/bin/varnishd/cache_center.c index edfe75d..d6101e1 100644 --- a/bin/varnishd/cache_center.c +++ b/bin/varnishd/cache_center.c @@ -166,7 +166,8 @@ cnt_prepresp(struct sess *sp) sp->wrk->res_mode = 0; - if (!sp->wrk->do_stream) + if (!sp->wrk->do_stream || + (sp->wrk->h_content_length != NULL && !sp->wrk->do_gunzip)) sp->wrk->res_mode |= RES_LEN; if (!sp->disable_esi && sp->obj->esidata != NULL) { diff --git a/bin/varnishd/cache_response.c b/bin/varnishd/cache_response.c index 9ffb95e..509954d 100644 --- a/bin/varnishd/cache_response.c +++ b/bin/varnishd/cache_response.c @@ -410,6 +410,11 @@ RES_StreamStart(struct sess *sp) if (sp->wrk->res_mode & RES_GUNZIP) http_Unset(sp->wrk->resp, H_Content_Encoding); + if (!(sp->wrk->res_mode & RES_CHUNKED) && + sp->wrk->h_content_length != NULL) + http_PrintfHeader(sp->wrk, sp->fd, sp->wrk->resp, + "Content-Length: %s", sp->wrk->h_content_length); + sp->acct_tmp.hdrbytes += http_Write(sp->wrk, sp->wrk->resp, 1); diff --git a/bin/varnishtest/tests/t00001.vtc b/bin/varnishtest/tests/t00001.vtc index 5fefc70..2237466 100644 --- a/bin/varnishtest/tests/t00001.vtc +++ b/bin/varnishtest/tests/t00001.vtc @@ -36,6 +36,7 @@ varnish v1 -vcl+backend { client c1 { txreq -url /bar rxresp + expect resp.http.content-length == 6 expect resp.bodylen == 6 txreq -url /bla rxresp From phk at varnish-cache.org Tue May 10 10:48:08 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 10 May 2011 12:48:08 +0200 Subject: [master] 1184edd Do not bail out of the VGZ functions if WRW fails to write, we may still need the object. Message-ID: commit 1184eddd7337d1ee6312dac629aaca0ac2fdebcf Author: Poul-Henning Kamp Date: Tue May 10 10:46:50 2011 +0000 Do not bail out of the VGZ functions if WRW fails to write, we may still need the object. Instead, add a WRW_error() function to query if there are WRW trouble. Fixes #904 diff --git a/bin/varnishd/cache.h b/bin/varnishd/cache.h index fc55996..c39bfe5 100644 --- a/bin/varnishd/cache.h +++ b/bin/varnishd/cache.h @@ -714,7 +714,6 @@ int VGZ_WrwGunzip(struct sess *, struct vgz *, void *ibuf, ssize_t ibufl, char *obuf, ssize_t obufl, ssize_t *obufp); /* Return values */ -#define VGZ_SOCKET -2 #define VGZ_ERROR -1 #define VGZ_OK 0 #define VGZ_END 1 @@ -819,6 +818,7 @@ int WRK_QueueSession(struct sess *sp); void WRK_SumStat(struct worker *w); #define WRW_IsReleased(w) ((w)->wrw.wfd == NULL) +int WRW_Error(const struct worker *w); void WRW_Chunked(struct worker *w); void WRW_EndChunk(struct worker *w); void WRW_Reserve(struct worker *w, int *fd); diff --git a/bin/varnishd/cache_esi_deliver.c b/bin/varnishd/cache_esi_deliver.c index 33ce9b8..85e1b15 100644 --- a/bin/varnishd/cache_esi_deliver.c +++ b/bin/varnishd/cache_esi_deliver.c @@ -327,7 +327,7 @@ ESI_Deliver(struct sess *sp) i = VGZ_WrwGunzip(sp, vgz, st->ptr + off, l2, obuf, sizeof obuf, &obufl); - if (i == VGZ_SOCKET) { + if (WRW_Error(sp->wrk)) { vca_close_session(sp, "remote closed"); p = e; diff --git a/bin/varnishd/cache_gzip.c b/bin/varnishd/cache_gzip.c index 290da72..c48fe21 100644 --- a/bin/varnishd/cache_gzip.c +++ b/bin/varnishd/cache_gzip.c @@ -379,8 +379,7 @@ VGZ_WrwGunzip(struct sess *sp, struct vgz *vg, void *ibuf, ssize_t ibufl, } if (obufl == *obufp || i == VGZ_STUCK) { (void)WRW_Write(sp->wrk, obuf, *obufp); - if (WRW_Flush(sp->wrk)) - return (VGZ_SOCKET); + (void)WRW_Flush(sp->wrk); *obufp = 0; VGZ_Obuf(vg, obuf + *obufp, obufl - *obufp); } diff --git a/bin/varnishd/cache_wrw.c b/bin/varnishd/cache_wrw.c index 688a5a0..5567f94 100644 --- a/bin/varnishd/cache_wrw.c +++ b/bin/varnishd/cache_wrw.c @@ -55,6 +55,13 @@ /*-------------------------------------------------------------------- */ +int +WRW_Error(const struct worker *w) +{ + + return (w->wrw.werr); +} + void WRW_Reserve(struct worker *w, int *fd) { From phk at varnish-cache.org Tue May 10 11:02:47 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 10 May 2011 13:02:47 +0200 Subject: [master] f830854 vcc_err_unref=false should also allow unreferenced subroutines. Message-ID: commit f830854cdbaf40870d810d35d1cd6667352f0daa Author: Poul-Henning Kamp Date: Tue May 10 10:55:28 2011 +0000 vcc_err_unref=false should also allow unreferenced subroutines. Submitted by: ehocdet Fixes #911 diff --git a/bin/varnishtest/tests/r00911.vtc b/bin/varnishtest/tests/r00911.vtc new file mode 100644 index 0000000..f85556c --- /dev/null +++ b/bin/varnishtest/tests/r00911.vtc @@ -0,0 +1,20 @@ +varnishtest "vcc_err_unref should also cover subs" + +server s1 { + rxreq + expect req.url == "/bar" + txresp -body "foobar" +} -start + +varnish v1 -arg "-p vcc_err_unref=false" -vcl+backend { + sub foobar { + set req.http.foobar = "foobar"; + } +} -start + +client c1 { + txreq -url /bar + rxresp + expect resp.http.content-length == 6 + expect resp.bodylen == 6 +} -run diff --git a/lib/libvcl/vcc_xref.c b/lib/libvcl/vcc_xref.c index f76d910..17b3a8a 100644 --- a/lib/libvcl/vcc_xref.c +++ b/lib/libvcl/vcc_xref.c @@ -292,6 +292,10 @@ vcc_checkaction2(struct vcc *tl, const struct symbol *sym) return; vsb_printf(tl->sb, "Function unused\n"); vcc_ErrWhere(tl, p->name); + if (!tl->err_unref) { + vsb_printf(tl->sb, "(That was just a warning)\n"); + tl->err = 0; + } } int From phk at varnish-cache.org Tue May 10 22:12:32 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Wed, 11 May 2011 00:12:32 +0200 Subject: [master] b15c018 Fix a printf format error. Message-ID: commit b15c018496b66e1a49a7f89215795c1db1301afd Author: Poul-Henning Kamp Date: Tue May 10 22:10:58 2011 +0000 Fix a printf format error. A couple of constifications while I wait for the tests to run. Spotted by: DocWilco diff --git a/bin/varnishd/cache.h b/bin/varnishd/cache.h index c39bfe5..216c432 100644 --- a/bin/varnishd/cache.h +++ b/bin/varnishd/cache.h @@ -710,7 +710,7 @@ int VGZ_Gzip(struct vgz *, const void **, size_t *len, enum vgz_flag); int VGZ_Gunzip(struct vgz *, const void **, size_t *len); void VGZ_Destroy(struct vgz **); void VGZ_UpdateObj(const struct vgz*, struct object *); -int VGZ_WrwGunzip(struct sess *, struct vgz *, void *ibuf, ssize_t ibufl, +int VGZ_WrwGunzip(const struct sess *, struct vgz *, void *ibuf, ssize_t ibufl, char *obuf, ssize_t obufl, ssize_t *obufp); /* Return values */ @@ -878,7 +878,7 @@ void RES_BuildHttp(struct sess *sp); void RES_WriteObj(struct sess *sp); void RES_StreamStart(struct sess *sp); void RES_StreamEnd(struct sess *sp); -void RES_StreamPoll(struct sess *sp); +void RES_StreamPoll(const struct sess *sp); /* cache_vary.c */ struct vsb *VRY_Create(const struct sess *sp, const struct http *hp); diff --git a/bin/varnishd/cache_gzip.c b/bin/varnishd/cache_gzip.c index c48fe21..015b907 100644 --- a/bin/varnishd/cache_gzip.c +++ b/bin/varnishd/cache_gzip.c @@ -353,7 +353,7 @@ VGZ_Gzip(struct vgz *vg, const void **pptr, size_t *plen, enum vgz_flag flags) */ int -VGZ_WrwGunzip(struct sess *sp, struct vgz *vg, void *ibuf, ssize_t ibufl, +VGZ_WrwGunzip(const struct sess *sp, struct vgz *vg, void *ibuf, ssize_t ibufl, char *obuf, ssize_t obufl, ssize_t *obufp) { int i; diff --git a/bin/varnishd/cache_panic.c b/bin/varnishd/cache_panic.c index f44584f..08cff86 100644 --- a/bin/varnishd/cache_panic.c +++ b/bin/varnishd/cache_panic.c @@ -163,7 +163,7 @@ pan_object(const struct object *o) vsb_printf(vsp, " xid = %u,\n", o->xid); pan_ws(o->ws_o, 4); pan_http("obj", o->http, 4); - vsb_printf(vsp, " len = %lu,\n", o->len); + vsb_printf(vsp, " len = %jd,\n", (intmax_t)o->len); vsb_printf(vsp, " store = {\n"); VTAILQ_FOREACH(st, &o->store, list) pan_storage(st); diff --git a/bin/varnishd/cache_response.c b/bin/varnishd/cache_response.c index 509954d..ad8302c 100644 --- a/bin/varnishd/cache_response.c +++ b/bin/varnishd/cache_response.c @@ -423,7 +423,7 @@ RES_StreamStart(struct sess *sp) } void -RES_StreamPoll(struct sess *sp) +RES_StreamPoll(const struct sess *sp) { struct stream_ctx *sctx; struct storage *st; From phk at varnish-cache.org Wed May 11 08:17:10 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Wed, 11 May 2011 10:17:10 +0200 Subject: [master] e45eb41 Give vreadfile() a size pointer return argument. Message-ID: commit e45eb41e0cf92804c79cb21db68e33986c50563c Author: Poul-Henning Kamp Date: Wed May 11 08:16:19 2011 +0000 Give vreadfile() a size pointer return argument. Expose vreadfd(), also with a size pointer return argument. Use vreadfd() in std.fileread() diff --git a/bin/varnishd/mgt_vcc.c b/bin/varnishd/mgt_vcc.c index de70939..a3028ad 100644 --- a/bin/varnishd/mgt_vcc.c +++ b/bin/varnishd/mgt_vcc.c @@ -252,7 +252,7 @@ mgt_run_cc(const char *vcl, struct vsb *sb, int C_flag) } if (C_flag) { - csrc = vreadfile(NULL, sf); + csrc = vreadfile(NULL, sf, NULL); XXXAN(csrc); (void)fputs(csrc, stdout); free(csrc); @@ -524,7 +524,7 @@ mcf_config_load(struct cli *cli, const char * const *av, void *priv) return; } - vcl = vreadfile(mgt_vcl_dir, av[3]); + vcl = vreadfile(mgt_vcl_dir, av[3], NULL); if (vcl == NULL) { cli_out(cli, "Cannot open '%s'", av[3]); cli_result(cli, CLIS_PARAM); diff --git a/bin/varnishd/varnishd.c b/bin/varnishd/varnishd.c index aa9d876..7f423f1 100644 --- a/bin/varnishd/varnishd.c +++ b/bin/varnishd/varnishd.c @@ -553,7 +553,7 @@ main(int argc, char * const *argv) } if (f_arg != NULL) { - vcl = vreadfile(NULL, f_arg); + vcl = vreadfile(NULL, f_arg, NULL); if (vcl == NULL) { fprintf(stderr, "Cannot read '%s': %s\n", f_arg, strerror(errno)); diff --git a/include/libvarnish.h b/include/libvarnish.h index e706e55..039e373 100644 --- a/include/libvarnish.h +++ b/include/libvarnish.h @@ -31,6 +31,7 @@ #include #include #include +#include #include "vas.h" @@ -99,7 +100,8 @@ void varnish_version(const char *); /* from libvarnish/vtmpfile.c */ int vtmpfile(char *); -char *vreadfile(const char *pfx, const char *fn); +char *vreadfile(const char *pfx, const char *fn, ssize_t *sz); +char *vreadfd(int fd, ssize_t *sz); const char* vcs_version(void); diff --git a/lib/libvarnish/vtmpfile.c b/lib/libvarnish/vtmpfile.c index 9b5c1b2..99160c7 100644 --- a/lib/libvarnish/vtmpfile.c +++ b/lib/libvarnish/vtmpfile.c @@ -77,8 +77,8 @@ vtmpfile(char *template) /* not reached */ } -static char * -vreadfd(int fd) +char * +vreadfd(int fd, ssize_t *sz) { struct stat st; char *f; @@ -92,11 +92,13 @@ vreadfd(int fd) i = read(fd, f, st.st_size); assert(i == st.st_size); f[i] = '\0'; + if (sz != NULL) + *sz = st.st_size; return (f); } char * -vreadfile(const char *pfx, const char *fn) +vreadfile(const char *pfx, const char *fn, ssize_t *sz) { int fd, err; char *r; @@ -111,7 +113,7 @@ vreadfile(const char *pfx, const char *fn) fd = open(fn, O_RDONLY); if (fd < 0) return (NULL); - r = vreadfd(fd); + r = vreadfd(fd, sz); err = errno; AZ(close(fd)); errno = err; diff --git a/lib/libvcl/vcc_compile.c b/lib/libvcl/vcc_compile.c index 103c141..823b2a6 100644 --- a/lib/libvcl/vcc_compile.c +++ b/lib/libvcl/vcc_compile.c @@ -418,7 +418,7 @@ vcc_file_source(const struct vcc *tl, struct vsb *sb, const char *fn) char *f; struct source *sp; - f = vreadfile(tl->vcl_dir, fn); + f = vreadfile(tl->vcl_dir, fn, NULL); if (f == NULL) { vsb_printf(sb, "Cannot read file '%s': %s\n", fn, strerror(errno)); diff --git a/lib/libvmod_std/vmod_std_fileread.c b/lib/libvmod_std/vmod_std_fileread.c index 9171a4b..22d05ad 100644 --- a/lib/libvmod_std/vmod_std_fileread.c +++ b/lib/libvmod_std/vmod_std_fileread.c @@ -151,14 +151,11 @@ vmod_fileread(struct sess *sp, struct vmod_priv *priv, const char *file_name) iter->file_name = strdup(file_name); iter->last_modification = buf.st_mtime; - iter->contents = malloc(buf.st_size + 1); + iter->contents = vreadfd(fd, &iter->file_sz); AN(iter->contents); - iter->file_sz = read(fd, iter->contents, buf.st_size); assert(iter->file_sz == buf.st_size); AZ(close(fd)); - iter->contents[iter->file_sz] = '\0'; - VSLIST_INSERT_HEAD(list, iter, next); filelist_update++; From phk at varnish-cache.org Wed May 11 08:21:41 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Wed, 11 May 2011 10:21:41 +0200 Subject: [master] d30f2a6 Fix variable type. off_t makes no sense for variable we keep in VM. Message-ID: commit d30f2a6ed8e7d175575f7ccd06ad0a19941ece4f Author: Poul-Henning Kamp Date: Wed May 11 08:21:22 2011 +0000 Fix variable type. off_t makes no sense for variable we keep in VM. diff --git a/lib/libvmod_std/vmod_std_fileread.c b/lib/libvmod_std/vmod_std_fileread.c index 22d05ad..3e2fcf4 100644 --- a/lib/libvmod_std/vmod_std_fileread.c +++ b/lib/libvmod_std/vmod_std_fileread.c @@ -56,7 +56,7 @@ struct cached_file { char *file_name; char *contents; time_t last_modification; - off_t file_sz; + ssize_t file_sz; VSLIST_ENTRY(cached_file) next; }; From phk at varnish-cache.org Wed May 11 09:01:12 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Wed, 11 May 2011 11:01:12 +0200 Subject: [master] 1bb10f4 Use reference counts to avoid duplicated files in std.fileread(). Message-ID: commit 1bb10f4b261f07ef4bada8aabc63dc84cf50a206 Author: Poul-Henning Kamp Date: Wed May 11 09:00:38 2011 +0000 Use reference counts to avoid duplicated files in std.fileread(). diff --git a/lib/libvmod_std/vmod_std_fileread.c b/lib/libvmod_std/vmod_std_fileread.c index 3e2fcf4..1890b76 100644 --- a/lib/libvmod_std/vmod_std_fileread.c +++ b/lib/libvmod_std/vmod_std_fileread.c @@ -48,119 +48,75 @@ #include "vcc_if.h" -VSLIST_HEAD(cached_file_list, cached_file); - -struct cached_file { - unsigned magic; +struct frfile { + unsigned magic; #define CACHED_FILE_MAGIC 0xa8e9d87a - char *file_name; - char *contents; - time_t last_modification; - ssize_t file_sz; - VSLIST_ENTRY(cached_file) next; + char *file_name; + char *contents; + int refcount; + VTAILQ_ENTRY(frfile) list; }; +static VTAILQ_HEAD(, frfile) frlist = VTAILQ_HEAD_INITIALIZER(frlist); +static pthread_mutex_t frmtx = PTHREAD_MUTEX_INITIALIZER; + static void -free_cached_files(void *file_list) +free_frfile(void *ptr) { - struct cached_file *iter, *tmp; - struct cached_file_list *list = file_list; - VSLIST_FOREACH_SAFE(iter, list, next, tmp) { - CHECK_OBJ(iter, CACHED_FILE_MAGIC); - free(iter->file_name); - free(iter->contents); - FREE_OBJ(iter); + struct frfile *frf; + + CAST_OBJ_NOTNULL(frf, ptr, CACHED_FILE_MAGIC); + + AZ(pthread_mutex_lock(&frmtx)); + if (--frf->refcount > 0) + frf = NULL; + else + VTAILQ_REMOVE(&frlist, frf, list); + AZ(pthread_mutex_unlock(&frmtx)); + if (frf != NULL) { + free(frf->contents); + free(frf->file_name); + FREE_OBJ(frf); } - free(file_list); } -static pthread_rwlock_t filelist_lock = PTHREAD_RWLOCK_INITIALIZER; -static int filelist_update = 0; - const char * vmod_fileread(struct sess *sp, struct vmod_priv *priv, const char *file_name) { - struct cached_file *iter = NULL; - struct stat buf; - struct cached_file_list *list; - int fd, my_filelist_update; + struct frfile *frf; + char *s; (void)sp; - - AZ(pthread_rwlock_rdlock(&filelist_lock)); - - if (priv->free == NULL) { - AZ(pthread_rwlock_unlock(&filelist_lock)); - /* - * Another thread may already have initialized priv - * here, making the repeat check necessary. - */ - AZ(pthread_rwlock_wrlock(&filelist_lock)); - if (priv->free == NULL) { - priv->free = free_cached_files; - priv->priv = malloc(sizeof(struct cached_file_list)); - AN(priv->priv); - list = priv->priv; - VSLIST_INIT(list); - } - AZ(pthread_rwlock_unlock(&filelist_lock)); - AZ(pthread_rwlock_rdlock(&filelist_lock)); - } else { - list = priv->priv; - VSLIST_FOREACH(iter, list, next) { - CHECK_OBJ(iter, CACHED_FILE_MAGIC); - if (strcmp(iter->file_name, file_name) == 0) { - /* This thread was holding a read lock. */ - AZ(pthread_rwlock_unlock(&filelist_lock)); - return iter->contents; - } - } + AN(priv); + if (priv->priv != NULL) { + CAST_OBJ_NOTNULL(frf, priv->priv, CACHED_FILE_MAGIC); + return (frf->contents); } - - my_filelist_update = filelist_update; - - /* This thread was holding a read lock. */ - AZ(pthread_rwlock_unlock(&filelist_lock)); - - if ((fd = open(file_name, O_RDONLY)) == -1) - return ""; - - AZ(fstat(fd, &buf)); - - AZ(pthread_rwlock_wrlock(&filelist_lock)); - - if (my_filelist_update != filelist_update) { - - /* - * Small optimization: search through the linked list again - * only if something has been changed. - */ - VSLIST_FOREACH(iter, list, next) { - CHECK_OBJ(iter, CACHED_FILE_MAGIC); - if (strcmp(iter->file_name, file_name) == 0) { - /* This thread was holding a write lock. */ - AZ(pthread_rwlock_unlock(&filelist_lock)); - return iter->contents; - } + + AZ(pthread_mutex_lock(&frmtx)); + VTAILQ_FOREACH(frf, &frlist, list) { + if (!strcmp(file_name, frf->file_name)) { + frf->refcount++; + break; } } - - ALLOC_OBJ(iter, CACHED_FILE_MAGIC); - AN(iter); - - iter->file_name = strdup(file_name); - iter->last_modification = buf.st_mtime; - - iter->contents = vreadfd(fd, &iter->file_sz); - AN(iter->contents); - assert(iter->file_sz == buf.st_size); - AZ(close(fd)); - - VSLIST_INSERT_HEAD(list, iter, next); - - filelist_update++; - - /* This thread was holding a write lock. */ - AZ(pthread_rwlock_unlock(&filelist_lock)); - return iter->contents; + AZ(pthread_mutex_unlock(&frmtx)); + if (frf != NULL) + return (frf->contents); + + s = vreadfile(NULL, file_name, NULL); + if (s != NULL) { + ALLOC_OBJ(frf, CACHED_FILE_MAGIC); + AN(frf); + frf->file_name = strdup(file_name); + AN(frf->file_name); + frf->refcount = 1; + frf->contents = s; + priv->free = free_frfile; + priv->priv = frf; + AZ(pthread_mutex_lock(&frmtx)); + VTAILQ_INSERT_HEAD(&frlist, frf, list); + AZ(pthread_mutex_unlock(&frmtx)); + } + return (s); } From tfheen at varnish-cache.org Wed May 11 10:05:16 2011 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Wed, 11 May 2011 12:05:16 +0200 Subject: [master] d250722 Add changelogs for 2.1.1 Message-ID: commit d250722253f3d3d033327468583e0eb292bf0ad9 Author: Tollef Fog Heen Date: Wed Apr 21 13:00:14 2010 +0000 Add changelogs for 2.1.1 git-svn-id: http://www.varnish-cache.org/svn/branches/2.1 at 4711 d4fa192b-c00b-0410-8231-f00ffab90ce4 diff --git a/doc/Makefile.am b/doc/Makefile.am index 8495bf7..2eabaf8 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -1,6 +1,7 @@ # CHANGELOGS = \ + changes-2.1.1.html \ changes-2.1.0.html \ changes-2.0.6.html \ changes-2.0.5.html \ @@ -15,6 +16,7 @@ CHANGELOGS = \ changes-1.0.4.html XML = \ + changes-2.1.0-2.1.1.xml \ changes-2.0.6-2.1.0.xml \ changes-2.0.5-2.0.6.xml \ changes-2.0.4-2.0.5.xml \ diff --git a/doc/changes-2.1.0-2.1.1.xml b/doc/changes-2.1.0-2.1.1.xml new file mode 100644 index 0000000..ae6c3bf --- /dev/null +++ b/doc/changes-2.1.0-2.1.1.xml @@ -0,0 +1,87 @@ + + +]> + + + + varnishd + + + The changelog in 2.1.0 included syntax errors, causing + the generated changelog to be empty. + + + + The help text for default_grace was wrongly + formatted and included a syntax error. This has now been fixed. + + + + varnishd now closes the file descriptor used + to read the management secret file (from the -S + parameter). + + + + The child would previously try to close every valid file + descriptor, something which could cause problems if the file + descriptor ulimit was set too high. We now keep track of all + the file descriptors we open and only close up to that number. + + + + + ESI was partially broken in 2.1.0 due to a bug in the + rollback of session workspace. This has been fixed. + + + + Reject the authcommand rather than crash if + there is no -S parameter given. + + + + Align pointers in allocated objects. This will in theory + make Varnish a tiny bit faster at the expense of slightly more + memory usage. + + + + Ensure the master process process id is updated in the + shared memory log file after we go into the background. + + + + HEAD requests would be converted to GET + requests too early, which affected pass + and pipe. This has been fixed. + + + + Update the documentation to point out that the TTL is no + longer taken into account to decide whether an object is + cacheable or not. + + + + Add support for completely obliterating an object and all + variants of it. Currently, this has to be done using inline C. + + + + Add experimental support for the Range + header. This has to be enabled using the parameter + http_range_support. + + + + varnishsizes + + + varnishsizes, which is + like varnishhost, but for the length of objects, + has been added.. + + + diff --git a/doc/changes-2.1.1.xml b/doc/changes-2.1.1.xml new file mode 100644 index 0000000..f5a91ba --- /dev/null +++ b/doc/changes-2.1.1.xml @@ -0,0 +1,12 @@ + + + +]> + + + Varnish + 2.1 + + + From tfheen at varnish-cache.org Wed May 11 10:05:16 2011 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Wed, 11 May 2011 12:05:16 +0200 Subject: [master] e6fac62 Update changelog with critbit fixes Message-ID: commit e6fac62bf46040789621d4d2e5981cb428e79cc8 Author: Tollef Fog Heen Date: Mon Apr 26 08:18:42 2010 +0000 Update changelog with critbit fixes git-svn-id: http://www.varnish-cache.org/svn/branches/2.1 at 4725 d4fa192b-c00b-0410-8231-f00ffab90ce4 diff --git a/doc/changes-2.1.0-2.1.1.xml b/doc/changes-2.1.0-2.1.1.xml index ae6c3bf..3c3a7c9 100644 --- a/doc/changes-2.1.0-2.1.1.xml +++ b/doc/changes-2.1.0-2.1.1.xml @@ -74,6 +74,12 @@ header. This has to be enabled using the parameter http_range_support. + + + The critbit hasher could get into a deadlock + and had a race condition. Both those have now been fixed. + + varnishsizes From tfheen at varnish-cache.org Wed May 11 10:05:19 2011 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Wed, 11 May 2011 12:05:19 +0200 Subject: [master] 0a0dbc3 Document 2.1.2 changes Message-ID: commit 0a0dbc34b10fbf804418b402d4b16a22eafb0b37 Author: Tollef Fog Heen Date: Wed May 5 08:15:50 2010 +0000 Document 2.1.2 changes git-svn-id: http://www.varnish-cache.org/svn/branches/2.1 at 4766 d4fa192b-c00b-0410-8231-f00ffab90ce4 diff --git a/doc/Makefile.am b/doc/Makefile.am index 2eabaf8..bb63e94 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -1,6 +1,7 @@ # CHANGELOGS = \ + changes-2.1.2.html \ changes-2.1.1.html \ changes-2.1.0.html \ changes-2.0.6.html \ @@ -16,6 +17,7 @@ CHANGELOGS = \ changes-1.0.4.html XML = \ + changes-2.1.1-2.1.2.xml \ changes-2.1.0-2.1.1.xml \ changes-2.0.6-2.1.0.xml \ changes-2.0.5-2.0.6.xml \ diff --git a/doc/changes-2.1.1-2.1.2.xml b/doc/changes-2.1.1-2.1.2.xml new file mode 100644 index 0000000..486d530 --- /dev/null +++ b/doc/changes-2.1.1-2.1.2.xml @@ -0,0 +1,19 @@ + + +]> + + + + varnishd + + + When adding Range support for 2.1.1, we + accidentially introduced a bug which would append garbage to + objects larger than the chunk size, by default 128k. Browsers + would do the right thing due to Content-Length, but some load + balancers would get very confused. + + + + diff --git a/doc/changes-2.1.2.xml b/doc/changes-2.1.2.xml new file mode 100644 index 0000000..c34aae6 --- /dev/null +++ b/doc/changes-2.1.2.xml @@ -0,0 +1,12 @@ + + + +]> + + + Varnish + 2.1.2 + + + From tfheen at varnish-cache.org Wed May 11 10:05:21 2011 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Wed, 11 May 2011 12:05:21 +0200 Subject: [master] 6a41472 Document changes for 2.1.3 Message-ID: commit 6a4147270518c9fbead8dd100f50482458476221 Author: Tollef Fog Heen Date: Wed Jul 28 09:20:52 2010 +0000 Document changes for 2.1.3 git-svn-id: http://www.varnish-cache.org/svn/branches/2.1 at 5049 d4fa192b-c00b-0410-8231-f00ffab90ce4 diff --git a/doc/Makefile.am b/doc/Makefile.am index bb63e94..28030db 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -1,6 +1,7 @@ # CHANGELOGS = \ + changes-2.1.3.html \ changes-2.1.2.html \ changes-2.1.1.html \ changes-2.1.0.html \ @@ -17,6 +18,7 @@ CHANGELOGS = \ changes-1.0.4.html XML = \ + changes-2.1.2-2.1.3.xml \ changes-2.1.1-2.1.2.xml \ changes-2.1.0-2.1.1.xml \ changes-2.0.6-2.1.0.xml \ diff --git a/doc/changes-2.1.2-2.1.3.xml b/doc/changes-2.1.2-2.1.3.xml new file mode 100644 index 0000000..58b0a1a --- /dev/null +++ b/doc/changes-2.1.2-2.1.3.xml @@ -0,0 +1,74 @@ + + +]> + + + + varnishd + + + Improve scalability of critbit. + + + + The critbit hash algorithm has now been tightened to make + sure the tree is in a consistent state at all points, and the + time we wait for an object to cool off after it is eligible for + garbage collection has been tweaked. + + + + Add log command to VCL. This emits + a VCL_log entry into the shared memory log. + + + + Only emit Length and ReqEnd log entries if we actually + have an XID. This should get rid of some empty log lines in + varnishncsa. + + + + Destroy directors in a predictable fashion, namely reverse + of creation order. + + + + Fix bug when ESI elements spanned storage elements causing + a panic. + + + + In some cases, the VCL compiler would panic instead of + giving sensible messages. This has now been fixed. + + + + Correct an off-by-one error when the requested range + exceeds the size of an object. + + + + Handle requests for the end of an object correctly. + + + + Allow tabulator characters in the third field of the + first line of HTTP requests + + + + On Solaris, if the remote end sends us an RST, all system + calls related to that socket will return EINVAL. We now handle + this better. + + + + libvarnishapi + + The -X parameter didn't work correctly. This + has been fixed. + + + diff --git a/doc/changes-2.1.3.xml b/doc/changes-2.1.3.xml new file mode 100644 index 0000000..6cfe24d --- /dev/null +++ b/doc/changes-2.1.3.xml @@ -0,0 +1,12 @@ + + + +]> + + + Varnish + 2.1.3 + + + From tfheen at varnish-cache.org Wed May 11 10:05:21 2011 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Wed, 11 May 2011 12:05:21 +0200 Subject: [master] ea31946 Fix syntax error in XML file Message-ID: commit ea319463f6454adbc13a4181b065a479a87d424d Author: Tollef Fog Heen Date: Wed Jul 28 11:26:10 2010 +0000 Fix syntax error in XML file git-svn-id: http://www.varnish-cache.org/svn/branches/2.1 at 5054 d4fa192b-c00b-0410-8231-f00ffab90ce4 diff --git a/doc/changes-2.1.2-2.1.3.xml b/doc/changes-2.1.2-2.1.3.xml index 58b0a1a..638bbf4 100644 --- a/doc/changes-2.1.2-2.1.3.xml +++ b/doc/changes-2.1.2-2.1.3.xml @@ -70,5 +70,6 @@ The -X parameter didn't work correctly. This has been fixed. + From tfheen at varnish-cache.org Wed May 11 10:05:22 2011 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Wed, 11 May 2011 12:05:22 +0200 Subject: [master] c77f650 Document changes in 2.1.4 Message-ID: commit c77f65073d1a1f5a4a79aef2959190624aaed62d Author: Tollef Fog Heen Date: Tue Oct 12 10:30:07 2010 +0000 Document changes in 2.1.4 git-svn-id: http://www.varnish-cache.org/svn/branches/2.1 at 5424 d4fa192b-c00b-0410-8231-f00ffab90ce4 diff --git a/doc/Makefile.am b/doc/Makefile.am index 28030db..ad6a1e2 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -1,6 +1,7 @@ # CHANGELOGS = \ + changes-2.1.4.html \ changes-2.1.3.html \ changes-2.1.2.html \ changes-2.1.1.html \ @@ -18,6 +19,7 @@ CHANGELOGS = \ changes-1.0.4.html XML = \ + changes-2.1.3-2.1.4.xml \ changes-2.1.2-2.1.3.xml \ changes-2.1.1-2.1.2.xml \ changes-2.1.0-2.1.1.xml \ diff --git a/doc/changes-2.1.3-2.1.4.xml b/doc/changes-2.1.3-2.1.4.xml new file mode 100644 index 0000000..dff3e36 --- /dev/null +++ b/doc/changes-2.1.3-2.1.4.xml @@ -0,0 +1,179 @@ + + +]> + + + + varnishd + + An embarrasing typo in the new binary heap layout caused + inflated obj/objcore/objhdr counts and could cause odd problems + when the LRU expunge mechanism was invoked. This has been + fixed. + + + + We now have updated documentation in the reStructuredText + format. Manual pages and reference documentation are both built + from this.. + + + + If you restarted a request, the HTTP header + X-Forwarded-For would be updated multiple times. + This has been fixed. + + + + If a VCL contained a % sign, and the vcl.show + CLI command was used, varnishd would crash. This has been + fixed. + + + + When doing a pass operation, we would remove the + Content-Length, Age and + Proxy-Auth headers. We are no longer doing + this. + + + + now has a string representation, making it + easier to construct Expires headers in VCL. + + + + In a high traffic environment, we would sometimes reuse a + file descriptor before flushing the logs from a worker thread to + the shared log buffer. This would cause confusion in some of + the tools. This has been fixed by explicitly flushing the log + when a backend connection is closed. + + + + In a high traffic environment, we would sometimes reuse a + file descriptor before flushing the logs from a worker thread to + the shared log buffer. This would cause confusion in some of + the tools. This has been fixed by explicitly flushing the log + when a backend connection is closed. + + + + If the communication between the management and the child + process gets out of sync, we have no way to recover. + Previously, varnishd would be confused, but we now + just kill the child and restart it. + + + + If the backend closes the connection on us just as we sent + a request to it, we retry the request. This should solve some + interoperability problems with Apache and the mpm-itk multi + processing module. + + + + varnishd now only provides help output the + current CLI session is authenticated for. + + + + If the backend does not tell us which length indication it + is using, we now assume the resource ends EOF at. + + + + The client director now has a variable + client.identity which is used to choose which + backend should receive a given request. + + + + The client director now has a variable + client.identity which is used to choose which + backend should receive a given request. + + + + The Solaris port waiter has been updated, and + other portability fixes for Solaris. + + + + There was a corner case in the close-down processing of pipes, this has now been fixed. + + + + Previously, if we stopped polling a backend which was + sick, it never got marked as healthy. This has now been + changed. + + + + It is now possible to specify ports as part of the .host field in VCL. + + + + The synthetic counters were not locked properly, and so + the sms_ counters could underflow. This has now + been fixed. + + + + The value of obj.status as a string in vcl_error would not be correct in all cases. This has been fixed. + + + + Varnish would try to trim storage segments completely + filled when using the malloc stevedore and the object was + received chunked encoding. This has been fixed. + + + + If a buggy backend sends us a Vary header + with two colons, we would previously abort. We now rather fix + this up and ignore the extra colon. + + + + req.hash_always_miss and + req.hash_ignore_busy has been added, to make + preloading or periodically refreshing content work better. + + + + + varnishncsa + + varnishncsa would in some cases be confused + by ESI requests and output invalid lines. This has now been + fixed. + + + + + varnishlog + + varnishlog now allows -o and -u together. + + + + + varnishtop + + varnishtop would crash on 32 bit + architectures. This has been fixed. + + + + + libvarnishapi + + Regex inclusion and exclusion had problems with matching + particular parts of the string being matched. This has been + fixed. + + + + diff --git a/doc/changes-2.1.4.xml b/doc/changes-2.1.4.xml new file mode 100644 index 0000000..4bb266f --- /dev/null +++ b/doc/changes-2.1.4.xml @@ -0,0 +1,12 @@ + + + +]> + + + Varnish + 2.1.4 + + + From tfheen at varnish-cache.org Wed May 11 10:05:24 2011 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Wed, 11 May 2011 12:05:24 +0200 Subject: [master] 86d4a10 Remove duplicate section from changelog Message-ID: commit 86d4a10c1622014697ebdd20913d4b83327a98ad Author: Tollef Fog Heen Date: Thu Oct 14 08:11:52 2010 +0000 Remove duplicate section from changelog git-svn-id: http://www.varnish-cache.org/svn/branches/2.1 at 5430 d4fa192b-c00b-0410-8231-f00ffab90ce4 diff --git a/doc/changes-2.1.3-2.1.4.xml b/doc/changes-2.1.3-2.1.4.xml index dff3e36..0fb7c17 100644 --- a/doc/changes-2.1.3-2.1.4.xml +++ b/doc/changes-2.1.3-2.1.4.xml @@ -90,12 +90,6 @@ - The client director now has a variable - client.identity which is used to choose which - backend should receive a given request. - - - The Solaris port waiter has been updated, and other portability fixes for Solaris. From tfheen at varnish-cache.org Wed May 11 10:05:27 2011 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Wed, 11 May 2011 12:05:27 +0200 Subject: [master] a7cdd83 Fix typo in include path Message-ID: commit a7cdd831f1c27bd80aee5922450255f233f520f4 Author: Tollef Fog Heen Date: Wed Oct 20 07:40:58 2010 +0000 Fix typo in include path git-svn-id: http://www.varnish-cache.org/svn/branches/2.1 at 5437 d4fa192b-c00b-0410-8231-f00ffab90ce4 diff --git a/doc/changes-2.1.4.xml b/doc/changes-2.1.4.xml index 4bb266f..c9211d8 100644 --- a/doc/changes-2.1.4.xml +++ b/doc/changes-2.1.4.xml @@ -8,5 +8,5 @@ Varnish 2.1.4 - + From tfheen at varnish-cache.org Wed May 11 10:05:30 2011 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Wed, 11 May 2011 12:05:30 +0200 Subject: [master] b7e82ae Add DNS director to changes, fix typo Message-ID: commit b7e82aebff8beb0bc036b1e01723ebae03ddc7fe Author: Tollef Fog Heen Date: Wed Oct 20 07:43:15 2010 +0000 Add DNS director to changes, fix typo git-svn-id: http://www.varnish-cache.org/svn/branches/2.1 at 5438 d4fa192b-c00b-0410-8231-f00ffab90ce4 diff --git a/doc/changes-2.1.3-2.1.4.xml b/doc/changes-2.1.3-2.1.4.xml index 0fb7c17..ae4a0e5 100644 --- a/doc/changes-2.1.3-2.1.4.xml +++ b/doc/changes-2.1.3-2.1.4.xml @@ -16,7 +16,13 @@ We now have updated documentation in the reStructuredText format. Manual pages and reference documentation are both built - from this.. + from this. + + + + We now include a DNS director which uses DNS for choosing + which backend to route requests to. Please see the + documentation for more details. From tfheen at varnish-cache.org Wed May 11 10:05:36 2011 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Wed, 11 May 2011 12:05:36 +0200 Subject: [master] cc88d1a Fix duplicated section Message-ID: commit cc88d1ae934b8e1c26eb9ac135cdabb4c0f07d5e Author: Tollef Fog Heen Date: Thu Oct 21 09:52:14 2010 +0000 Fix duplicated section git-svn-id: http://www.varnish-cache.org/svn/branches/2.1 at 5447 d4fa192b-c00b-0410-8231-f00ffab90ce4 diff --git a/doc/changes-2.1.3-2.1.4.xml b/doc/changes-2.1.3-2.1.4.xml index ae4a0e5..cccfb42 100644 --- a/doc/changes-2.1.3-2.1.4.xml +++ b/doc/changes-2.1.3-2.1.4.xml @@ -57,14 +57,6 @@ when a backend connection is closed. - - In a high traffic environment, we would sometimes reuse a - file descriptor before flushing the logs from a worker thread to - the shared log buffer. This would cause confusion in some of - the tools. This has been fixed by explicitly flushing the log - when a backend connection is closed. - - If the communication between the management and the child process gets out of sync, we have no way to recover. From tfheen at varnish-cache.org Wed May 11 10:05:39 2011 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Wed, 11 May 2011 12:05:39 +0200 Subject: [master] 61af4ba Fix copy/paste blunder in Changes XML for 2.1.4 Message-ID: commit 61af4ba674b8f800c349b2758dbcb8af1966c398 Author: Kristian Lyngstol Date: Mon Jan 24 11:56:13 2011 +0100 Fix copy/paste blunder in Changes XML for 2.1.4 Also removed the $Id$, which was both incorrect and now obsolete. diff --git a/doc/changes-2.1.3-2.1.4.xml b/doc/changes-2.1.3-2.1.4.xml index cccfb42..775b6bd 100644 --- a/doc/changes-2.1.3-2.1.4.xml +++ b/doc/changes-2.1.3-2.1.4.xml @@ -2,8 +2,7 @@ ]> - - + varnishd From tfheen at varnish-cache.org Wed May 11 10:05:41 2011 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Wed, 11 May 2011 12:05:41 +0200 Subject: [master] f0259be Changes for 2.1.5 Message-ID: commit f0259bec4558960771f8850a68415fdb2f368a74 Author: Kristian Lyngstol Date: Mon Jan 24 13:09:21 2011 +0100 Changes for 2.1.5 diff --git a/doc/changes-2.1.4-2.1.5.xml b/doc/changes-2.1.4-2.1.5.xml new file mode 100644 index 0000000..a2c482a --- /dev/null +++ b/doc/changes-2.1.4-2.1.5.xml @@ -0,0 +1,132 @@ + + +]> + + + varnishd + + On pass from vcl_recv, we did not remove the backends Content-Length + header before adding our own. This could cause confusion for + browsers and has been fixed. + + + + Make pass with content-length work again. An issue with regards + to 304, Content-Length and pass has been resolved. + + + + An issue relating to passed requests with If-Modified-Since + headers has been fixed. Varnish did not recognize that the + 304-response did not have a body. + + + + A potential lock-inversion with the ban lurker thread has been + resolved. + + + + Several build-dependency issues relating to rst2man have been + fixed. Varnish should now build from source without rst2man if you + are using tar-balls. + + + + Ensure Varnish reads the expected last CRLF after chunked data + from the backend. This allows re-use of the connection. + + + + Remove a GNU Make-ism during make dist to make BSD + happier. + + + + Document the log, set, unset, return and restart statements in + the VCL documentation. + + + + Fix an embarrassingly old bug where Varnish would run out of + workspace when requests come in fast over a single connection, + typically during synthetic benchmarks. + + + + Varnish will now allow If-Modified-Since requests + to objects without a Last-Modified-header, and instead + use the time the object was cached instead. + + + + Do not filter out Content-Range headers in + pass. + + + + Require -d, -b, -f, -S or -T when starting Varnishd. In human + terms, this means that it is legal to start varnishd without a Vcl or + backend, but only if you have a CLI channel of some kind. + + + + Don't suppress Cache-Control headers in pass + responses. + + + + Merge multi-line Cache-Control and Vary header fields. Until + now, no browsers have needed this, but Chromium seems to find it + necessary to spread its Cache-Control across two lines, and we get to + deal with it. + + + + Make new-purge not touch busy objects. This fixes a potential + crash when calling VRT_purge. + + + + If there are everal grace-able objects, pick the least expired + one. + + + + Fix an issue with varnishadm -T :6082 + shorthand. + + + + Add bourn-shell like "here" documents on the CLI. Typical + usage: + + vcl.inline vcl_new << 42 + backend foo {...} + sub vcl_recv {...} + 42 + + + + + Add CLI version to the CLI-banner, starting with version 1.0 to + mark here-documents. + + + + Fix a problem with the expiry thread slacking off during high + load. + + + + + + varnishtest + + Remove no longer existing -L option. + + + + + From tfheen at varnish-cache.org Wed May 11 10:05:46 2011 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Wed, 11 May 2011 12:05:46 +0200 Subject: [master] 2c72458 Add changes for 2.1.5 to the build system Message-ID: commit 2c7245899277b75366d0117f637315d9d1b09986 Author: Kristian Lyngstol Date: Mon Jan 24 13:13:55 2011 +0100 Add changes for 2.1.5 to the build system diff --git a/doc/Makefile.am b/doc/Makefile.am index ad6a1e2..9774622 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -1,6 +1,7 @@ # CHANGELOGS = \ + changes-2.1.5.html \ changes-2.1.4.html \ changes-2.1.3.html \ changes-2.1.2.html \ @@ -19,6 +20,7 @@ CHANGELOGS = \ changes-1.0.4.html XML = \ + changes-2.1.4-2.1.5.xml \ changes-2.1.3-2.1.4.xml \ changes-2.1.2-2.1.3.xml \ changes-2.1.1-2.1.2.xml \ diff --git a/doc/changes-2.1.4-2.1.5.xml b/doc/changes-2.1.4-2.1.5.xml index a2c482a..9b7e8ae 100644 --- a/doc/changes-2.1.4-2.1.5.xml +++ b/doc/changes-2.1.4-2.1.5.xml @@ -102,7 +102,7 @@ Add bourn-shell like "here" documents on the CLI. Typical usage: - vcl.inline vcl_new << 42 + vcl.inline vcl_new << 42 backend foo {...} sub vcl_recv {...} 42 diff --git a/doc/changes-2.1.5.xml b/doc/changes-2.1.5.xml new file mode 100644 index 0000000..7e37731 --- /dev/null +++ b/doc/changes-2.1.5.xml @@ -0,0 +1,11 @@ + + + +]> + + Varnish + 2.1.5 + + + From tfheen at varnish-cache.org Wed May 11 10:05:56 2011 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Wed, 11 May 2011 12:05:56 +0200 Subject: [master] cc8a173 Link pipe/pass FAQ VCLExamplePipe Message-ID: commit cc8a1733ca2232f2b7ef8cd4d63f737d8d4100ea Author: Tollef Fog Heen Date: Tue May 10 10:43:00 2011 +0200 Link pipe/pass FAQ VCLExamplePipe reworked from a commit to 2.1 by Bj?rn Ruberg. diff --git a/doc/sphinx/faq/configuration.rst b/doc/sphinx/faq/configuration.rst index 345edd7..df06b07 100644 --- a/doc/sphinx/faq/configuration.rst +++ b/doc/sphinx/faq/configuration.rst @@ -36,7 +36,9 @@ _only_ pushes bytes back and forth, with no other actions taken. Since most HTTP clients do pipeline several requests into one connection this might give you an undesirable result - as every -subsequent request will reuse the existing ``pipe``. +subsequent request will reuse the existing ``pipe``. Please see `this +article ` for +more details and a workaround. Varnish versions prior to 2.0 does not support handling a request body with ``pass`` mode, so in those releases ``pipe`` is required for From tfheen at varnish-cache.org Wed May 11 10:06:07 2011 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Wed, 11 May 2011 12:06:07 +0200 Subject: [master] 7b841df Write up 2.1.5 → 3.0 beta 1 changes Message-ID: commit 7b841df818ec169bd7b176e2fd36acbc3cbfb537 Author: Tollef Fog Heen Date: Wed May 11 08:51:55 2011 +0200 Write up 2.1.5 ? 3.0 beta 1 changes diff --git a/doc/changes.rst b/doc/changes.rst new file mode 100644 index 0000000..780b882 --- /dev/null +++ b/doc/changes.rst @@ -0,0 +1,242 @@ +================================ +Changes from 2.1.5 to 3.0 beta 1 +================================ + +Upcoming changes +---------------- + +- The interpretation of bans will change slightly between 3.0 beta 1 + and 3.0 release. Currently, doing ``ban("req.url == req.url")`` + will cause the right hand req.url to be interpreted in the context + of the request creating the ban. This will change so you will have + to do ``ban("req.url == " + req.url)`` instead. This syntax already + works and is recommended. + +Varnishd +-------- + +- Add streaming on ``pass`` and ``miss``. This is controlled by the + ``beresp.do_stream`` boolean. This includes support for + compression/uncompression. +- Add support for ESI and gzip. +- Handle objects larger than 2G. +- HTTP Range support is now enabled by default +- The ban lurker is enabled by default +- if there is a backend or director with the name ``default``, use + that as the default backend, otherwise use the first one listed. +- Add many more stats counters. Amongst those, add per storage + backend stats and per-backend statistics. +- Syslog the platform we are running on +- The ``-l`` (shared memory log file) argument has been changed, + please see the varnishd manual for the new syntax. +- The ``-S`` and ``-T`` arguments are now stored in the shmlog +- Fix off-by-one error when exactly filling up the workspace. `Bug #693`_. +- Make it possible to name storage backends. The names have to be + unique. +- Update usage output to match the code. `Bug #683`_ +- Add per-backend health information to shared memory log. +- Always recreate the shared memory log on startup. +- Add a ``vcl_dir`` parameter. This is used to resolve relative path + names for ``vcl.load`` and ``include`` in .vcl files. +- Make it possible to specify ``-T :0``. This causes varnishd to look + for a free port automatically. The port is written in the shared + memory log so varnishadm can find it. +- Classify locks into kinds and collect stats for each kind, + recording the data in the shared memory log. +- Auto-detect necessary flags for pthread support and ``VCC_CC`` + flags. This should make Varnish somewhat happier on Solaris. `Bug + #663`_ +- The ``overflow_max`` parameter has been renamed to ``queue_max``. +- If setting a parameter fails, report which parameter failed as this + is not obvious during startup. +- Add a parameter named ``shortlived``. Objects whose TTL is less + than the parameter go into transient (malloc) storage. +- Reduce the default ``thread_add_delay`` to 2ms. +- The ``max_esi_includes`` parameter has been renamed to + ``max_esi_depth``. +- Hash string components are now logged by default. +- The default connect timeout parameter has been increased to 0.7 + seconds. +- The ``err_ttl`` parameter has been removed and is replaced by a + setting in default.vcl. +- The default ``send_timeout`` parameter has been reduced to 1 minute. +- The default ``ban_lurker`` sleep has been set to 10ms. +- When an object is banned, make sure to set its grace to 0 as well. +- Add ``panic.show`` and ``panic.clear`` CLI commands. +- The default ``http_resp_hdr_len`` and ``http_req_hdr_len`` has been + increased to 2048 bytes. +- If ``vcl_fetch`` results in ``restart`` or ``error``, close the + backend connection rather than fetching the object. +- If allocating storage for an object, try reducing the chunk size + before evicting objects to make room. `Bug #880`_ +- Add ``restart`` from ``vcl_deliver``. `Bug #411`_ +- Fix an off-by-up-to-one-minus-epsilon bug where if an object from + the backend did not have a last-modified header we would send out a + 304 response which did include a ``Last-Modified`` header set to + when we received the object. However, we would compare the + timestamp to the fractional second we got the object, meaning any + request with the exact timestamp would get a ``200`` response rather + than the correct ``304``. +- Fix a race condition in the ban lurker where a serving thread and + the lurker would both look at an object at the same time, leading to + Varnish crashing. +- If a backend sends a ``Content-Length`` header and we are streaming and + we are not uncompressing it, send the ``Content-Length`` header on, + allowing browsers to diplay a progress bar. +- All storage must be at least 1M large. This is to prevent + administrator errors when specifying the size of storage where the + admin might have forgotten to specify units. + +.. _bug #693: http://varnish-cache.org/trac/ticket/693 +.. _bug #683: http://varnish-cache.org/trac/ticket/683 +.. _bug #663: http://varnish-cache.org/trac/ticket/663 +.. _bug #880: http://varnish-cache.org/trac/ticket/880 +.. _bug #411: http://varnish-cache.org/trac/ticket/411 +.. _bug #693: http://varnish-cache.org/trac/ticket/693 + +Tools +----- + +common +****** + +- Add an ``-m $tag:$regex`` parameter, used for selecting some + transactions. The parameter can be repeated, in which case it is + logically and-ed together. + +varnishadm +********** + +- varnishadm will now pick up the -S and -T arguments from the shared + memory log, meaning just running it without any arguments will + connect to the running varnish. `Bug #875`_ +- varnishadm now accepts an -n argument to specify the location of the + shared memory log file +- add libedit support + +.. _bug #875: http://varnish-cache.org/trac/ticket/875 + +varnishstat +*********** + +- reopen shared memory log if the varnishd process is restarted. +- Improve support for selecting some, but not all fields using the + ``-f`` argument. Please see the documentation for further details on + the use of ``-f``. +- display per-backend health information + +varnishncsa +*********** + +- Report error if called with ``-i`` and ``-I`` as they do not make + any sense for varnishncsa. +- Add custom log formats, specified with ``-F``. Most of the Apache + log formats are supported, as well as some Varnish-specific ones. + See the documentation for further information. `Bug #712`_ and `bug #485`_ + +.. _bug #712: http://varnish-cache.org/trac/ticket/712 +.. _bug #485: http://varnish-cache.org/trac/ticket/485 + +varnishtest +*********** + +- add ``-l`` and ``-L`` switches which leave ``/tmp/vtc.*`` behind on + error and unconditionally respectively. +- add ``-j`` parameter to run tests in parallell and use this by + default. + +varnishtop +********** + +- add ``-p $period`` parameter. The units in varnishtop were + previously undefined, they are now in requests/period. The default + period is 60 seconds. + +varnishlog +********** + +- group requests by default. This can be turned off by using ``-O`` +- the ``-o`` parameter is now a no-op and is ignored. + +VMODs +----- + +- Add a std vmod which includes a random function, log, syslog, + fileread, collect, + +VCL +--- + +- Change string concatenation to be done using ``+`` rather than + implicitly. +- Stop using ``%xx`` escapes in VCL strings. +- Change ``req.hash += value`` to ``hash_data(value)`` +- Variables in VCL now have distinct read/write access +- ``bereq.connect_timeout`` is now available in ``vcl_pipe``. +- Make it possible to declare probes outside of a director. Please see + the documentation on how to do this. +- The VCL compiler has been reworked greatly, expanding its abilities + with regards to what kinds of expressions it understands. +- Add ``beresp.backend.name``, ``beresp.backend.ip`` and + ``beresp.backend.port`` variables. They are only available from + ``vcl_fetch`` and are read only. `Bug #481`_ +- The default VCL now calls pass for any objects where + ``beresp.http.Vary == "*"``. `Bug #787`_ +- The ``log`` keyword has been moved to the ``std`` vmod. +- It is now possible to choose which storage backend to be used +- Add variables ``storage.$name.free_space``, + ``storage.$name.used_space`` and ``storage.$name.happy`` +- The variable ``req.can_gzip`` tells us whether the client accepts + gzipped objects or not. +- ``purge`` is now called ``ban``, since that is what it really is and + has always been. +- ``req.esi_level`` is now available. `Bug #782`_ +- esi handling is now controlled by the ``beresp.do_esi`` boolean rather + than the ``esi`` function. +- ``beresp.do_gzip`` and ``beresp.do_gunzip`` now control whether an + uncompressed object should be compressed and a compressed object + should be uncompressed in the cache. +- make it possible to control compression level using the + ``gzip_level`` parameter. +- ``obj.cacheable`` and ``beresp.cacheable`` have been removed. + Cacheability is now solely through the ``beresp.ttl`` and + ``beresp.grace`` variables. +- setting the ``obj.ttl`` or ``beresp.ttl`` to zero now also sets the + corresponding grace to zero. If you want a non-zero grace, set + grace after setting the TTL. +- ``return(pass)`` in ``vcl_fetch`` has been renamed to + ``return(hit_for_pass)`` to make it clear that pass in ``vcl_fetch`` + and ``vcl_recv`` are different beasts. +- Add actual purge support. Doing ``purge`` will remove an object and + all its variants. + +.. _bug #481: http://varnish-cache.org/trac/ticket/481 +.. _bug #787: http://varnish-cache.org/trac/ticket/787 +.. _bug #782: http://varnish-cache.org/trac/ticket/782 + + +Libraries +--------- + +- ``libvarnishapi`` has been overhauled and the API has been broken. + Please see git commit logs and the support tools to understand + what's been changed. +- Add functions to walk over all the available counters. This is + needed because some of the counter names might only be available at + runtime. +- Limit the amount of time varnishapi waits for a shared memory log + to appear before returning an error. +- All libraries but ``libvarnishapi`` have been moved to a private + directory as they are not for public consumption and have no ABI/API + guarantees. + +Other +----- + +- Python is now required to build +- Varnish Cache is now consistently named Varnish Cache. +- The compilation process now looks for kqueue on NetBSD +- Make it possible to use a system jemalloc rather than the bundled + version. +- The documentation has been improved all over and should now be in + much better shape than before From tfheen at varnish-cache.org Wed May 11 10:06:20 2011 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Wed, 11 May 2011 12:06:20 +0200 Subject: [master] b4f2417 Update configure.ac copyright Message-ID: commit b4f241735f04c6bb6efd29174cd5a94a1503755d Author: Tollef Fog Heen Date: Wed May 11 10:02:38 2011 +0200 Update configure.ac copyright diff --git a/configure.ac b/configure.ac index 616d411..7f0926c 100644 --- a/configure.ac +++ b/configure.ac @@ -1,6 +1,7 @@ AC_PREREQ(2.59) AC_COPYRIGHT([Copyright (c) 2006 Verdens Gang AS -Copyright (c) 2006-2010 Linpro AS]) +Copyright (c) 2006-2010 Linpro AS +Copyright (c) 2010-2011 Varnish Software AS]) AC_REVISION([$Id$]) AC_INIT([Varnish], [trunk], [varnish-dev at varnish-cache.org]) AC_CONFIG_SRCDIR(include/varnishapi.h) From tfheen at varnish-cache.org Wed May 11 10:06:27 2011 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Wed, 11 May 2011 12:06:27 +0200 Subject: [master] 0899568 Bump version to 3.0.0-beta1 Message-ID: commit 0899568656f7e87461b0427c79628a25734d1f46 Author: Tollef Fog Heen Date: Wed May 11 10:02:55 2011 +0200 Bump version to 3.0.0-beta1 diff --git a/configure.ac b/configure.ac index 7f0926c..cff648d 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ AC_COPYRIGHT([Copyright (c) 2006 Verdens Gang AS Copyright (c) 2006-2010 Linpro AS Copyright (c) 2010-2011 Varnish Software AS]) AC_REVISION([$Id$]) -AC_INIT([Varnish], [trunk], [varnish-dev at varnish-cache.org]) +AC_INIT([Varnish], [3.0.0-beta1], [varnish-dev at varnish-cache.org]) AC_CONFIG_SRCDIR(include/varnishapi.h) AM_CONFIG_HEADER(config.h) From tfheen at varnish-cache.org Wed May 11 10:06:30 2011 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Wed, 11 May 2011 12:06:30 +0200 Subject: [master] 7af4ffd Adjust spec file and distcheck hook for 3.0.0-beta1 Message-ID: commit 7af4ffd89658d749846a6b100b2a303fd2aa58df Author: Tollef Fog Heen Date: Wed May 11 11:09:11 2011 +0200 Adjust spec file and distcheck hook for 3.0.0-beta1 diff --git a/Makefile.am b/Makefile.am index 802c91e..bc0bfc2 100644 --- a/Makefile.am +++ b/Makefile.am @@ -15,8 +15,11 @@ install-data-local: $(install_sh) -d -m 0755 $(DESTDIR)$(localstatedir)/varnish distcheck-hook: - if ! grep "^Version: @PACKAGE_VERSION@$$" $(top_distdir)/redhat/varnish.spec && \ + V="@PACKAGE_VERSION@" ; \ + V="$${V%%-*}" ; \ + if ! grep "^Version: $$V$$" $(top_distdir)/redhat/varnish.spec && \ [ "@PACKAGE_VERSION@" != "trunk" ]; then \ + echo "$$V" ; \ echo "redhat/varnish.spec does not have a version number matching the package" ; \ exit 1 ; \ fi diff --git a/redhat/varnish.spec b/redhat/varnish.spec index 46072af..e50084d 100644 --- a/redhat/varnish.spec +++ b/redhat/varnish.spec @@ -1,12 +1,12 @@ Summary: High-performance HTTP accelerator Name: varnish Version: 3.0.0 -Release: 0.git20110210%{?dist} +Release: 0.beta1%{?dist} License: BSD Group: System Environment/Daemons URL: http://www.varnish-cache.org/ #Source0: http://repo.varnish-cache.org/source/%{name}-%{version}.tar.gz -Source0: %{name}-trunk.tar.gz +Source0: %{name}-3.0-beta1.tar.gz BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) # To build from git, start with a make dist, see redhat/README.redhat # You will need at least automake autoconf libtool python-docutils @@ -72,7 +72,7 @@ Documentation files for %name %prep #%setup -q -%setup -q -n varnish-trunk +%setup -q -n varnish-3.0-beta1 mkdir examples cp bin/varnishd/default.vcl etc/zope-plone.vcl examples From tfheen at varnish-cache.org Wed May 11 10:06:03 2011 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Wed, 11 May 2011 12:06:03 +0200 Subject: [master] 2f991e1 Require all storage to be at least 1M Message-ID: commit 2f991e163c6d9a93f94246ea8e6587139ea39cb5 Author: Tollef Fog Heen Date: Wed May 11 09:56:58 2011 +0200 Require all storage to be at least 1M It does not make sense to specify less that 1M of storage, so error out if a user specifies -smalloc,512 for instance. They probably meant -smalloc,512M, but require them to be explicit. Adjust C00027 test case to match diff --git a/bin/varnishd/stevedore_utils.c b/bin/varnishd/stevedore_utils.c index 1a4227c..8242df8 100644 --- a/bin/varnishd/stevedore_utils.c +++ b/bin/varnishd/stevedore_utils.c @@ -201,6 +201,10 @@ STV_FileSize(int fd, const char *size, unsigned *granularity, const char *ctx) if (q != NULL) ARGV_ERR("(%s) size \"%s\": %s\n", size, ctx, q); + + if (l < 1024*1024) + ARGV_ERR("(-spersistent) size \"%s\": too small, " + "did you forget to specify M or G?\n", size); } /* diff --git a/bin/varnishd/storage_malloc.c b/bin/varnishd/storage_malloc.c index 658ca6e..5cd6b84 100644 --- a/bin/varnishd/storage_malloc.c +++ b/bin/varnishd/storage_malloc.c @@ -187,6 +187,9 @@ sma_init(struct stevedore *parent, int ac, char * const *av) ARGV_ERR("(-smalloc) size \"%s\": %s\n", av[0], e); if ((u != (uintmax_t)(size_t)u)) ARGV_ERR("(-smalloc) size \"%s\": too big\n", av[0]); + if (u < 1024*1024) + ARGV_ERR("(-smalloc) size \"%s\": too small, " + "did you forget to specify M or G?\n", av[0]); printf("SMA.%s: max size %ju MB.\n", parent->ident, u / (1024 * 1024)); diff --git a/bin/varnishtest/tests/c00027.vtc b/bin/varnishtest/tests/c00027.vtc index 5f49fcb..62d0716 100644 --- a/bin/varnishtest/tests/c00027.vtc +++ b/bin/varnishtest/tests/c00027.vtc @@ -18,7 +18,7 @@ server s1 { txresp -body "1111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111" } -start -varnish v1 -arg "-s malloc,40k" -vcl+backend { +varnish v1 -arg "-s malloc,1M" -vcl+backend { sub vcl_fetch { set beresp.ttl = 10m; } From tfheen at varnish-cache.org Wed May 11 10:06:11 2011 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Wed, 11 May 2011 12:06:11 +0200 Subject: [master] 8d38f05 Hook changes.rst into build system Message-ID: commit 8d38f05c4876b09d457480e24cb8e60424c8e48c Author: Tollef Fog Heen Date: Wed May 11 08:52:13 2011 +0200 Hook changes.rst into build system diff --git a/configure.ac b/configure.ac index f401b45..616d411 100644 --- a/configure.ac +++ b/configure.ac @@ -56,6 +56,12 @@ if test "x$RST2MAN" = "xno"; then fi AM_CONDITIONAL(HAVE_RST2MAN,[test "x$RST2MAN" != "xno"]) +AC_CHECK_PROGS(RST2HTML, [rst2html rst2html.py], "no") +if test "x$RST2HTML" = "xno"; then + AC_MSG_WARN([rst2html not found ? not building changelog]) +fi +AM_CONDITIONAL(HAVE_RST2HTML,[test "x$RST2HTML" != "xno"]) + # Checks for libraries. save_LIBS="${LIBS}" LIBS="" diff --git a/doc/Makefile.am b/doc/Makefile.am index 9774622..58d9dc7 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -44,7 +44,8 @@ all: ${CHANGELOGS} endif EXTRA_DIST = ${CHANGELOGS} ${XML} \ - changes.css changes-html.xsl + changes.css changes-html.xsl \ + changes.rst changes.html CLEANFILES = ${CHANGELOGS} SUFFIXES = .xml .html @@ -59,6 +60,17 @@ else @false endif +changes.html: changes.rst +if HAVE_RST2HTML + ${RST2HTML} $? $@ +else + @echo "========================================" + @echo "You need rst2html installed to make dist" + @echo "========================================" + @false +endif + + ${CHANGELOGS}: changes-html.xsl SUBDIRS = sphinx From tfheen at varnish-cache.org Wed May 11 10:06:15 2011 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Wed, 11 May 2011 12:06:15 +0200 Subject: [master] 0647e66 Fix typo in comment Message-ID: commit 0647e669896a1b9bdff472157fb4a59444f3dc34 Author: Tollef Fog Heen Date: Wed May 11 09:03:56 2011 +0200 Fix typo in comment diff --git a/bin/varnishd/stevedore_utils.c b/bin/varnishd/stevedore_utils.c index 8242df8..0a8e9cb 100644 --- a/bin/varnishd/stevedore_utils.c +++ b/bin/varnishd/stevedore_utils.c @@ -192,7 +192,7 @@ STV_FileSize(int fd, const char *size, unsigned *granularity, const char *ctx) if ((size == NULL || *size == '\0') && st.st_size != 0) { /* * We have no size specification, but an existing file, - * use it's existing size. + * use its existing size. */ l = st.st_size; } else { From phk at varnish-cache.org Thu May 12 07:56:19 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Thu, 12 May 2011 09:56:19 +0200 Subject: [master] cd0d495 More comprehensive testing of std.fileread() Message-ID: commit cd0d4954c10ba82409f12c48bffb3d6edf59ff5c Author: Poul-Henning Kamp Date: Thu May 12 07:40:45 2011 +0000 More comprehensive testing of std.fileread() diff --git a/bin/varnishtest/tests/m00004.vtc b/bin/varnishtest/tests/m00004.vtc index e88dac2..4aa4291 100644 --- a/bin/varnishtest/tests/m00004.vtc +++ b/bin/varnishtest/tests/m00004.vtc @@ -13,7 +13,9 @@ server s1 { } } -start -varnish v1 -arg "-pvmod_dir=${topbuild}/lib/libvmod_std/.libs/" \ +varnish v1 \ + -arg "-pvmod_dir=${topbuild}/lib/libvmod_std/.libs/" \ + -arg "-pthread_pools=1" \ -vcl+backend { import std; @@ -29,86 +31,63 @@ varnish v1 -arg "-pvmod_dir=${topbuild}/lib/libvmod_std/.libs/" \ } -start client c1 { - loop 5 { - txreq -url "/one" - rxresp - expect resp.status == 200 - expect resp.http.content-length == "4" - expect resp.http.foo == "bar" - expect resp.http.one == "File One" - } + txreq -url "/one" + rxresp + expect resp.status == 200 + expect resp.http.content-length == "4" + expect resp.http.foo == "bar" + expect resp.http.one == "File One" - loop 5 { - txreq -url "/two" - rxresp - expect resp.status == 200 - expect resp.http.content-length == "4" - expect resp.http.foo == "bar" - expect resp.http.two == "File Two" - - txreq -url "/three" - rxresp - expect resp.status == 200 - expect resp.http.content-length == "4" - expect resp.http.foo == "bar" - expect resp.http.three == "File Three" - } -} + txreq -url "/two" + rxresp + expect resp.status == 200 + expect resp.http.content-length == "4" + expect resp.http.foo == "bar" + expect resp.http.two == "File Two" -client c2 { - loop 5 { - txreq -url "/two" - rxresp - expect resp.status == 200 - expect resp.http.content-length == "4" - expect resp.http.foo == "bar" - expect resp.http.two == "File Two" - } + txreq -url "/three" + rxresp + expect resp.status == 200 + expect resp.http.content-length == "4" + expect resp.http.foo == "bar" + expect resp.http.three == "File Three" +} -run - loop 5 { - txreq -url "/one" - rxresp - expect resp.status == 200 - expect resp.http.content-length == "4" - expect resp.http.foo == "bar" - expect resp.http.one == "File One" - - txreq -url "/three" - rxresp - expect resp.status == 200 - expect resp.http.content-length == "4" - expect resp.http.foo == "bar" - expect resp.http.three == "File Three" - } -} +varnish v1 -vcl+backend { + import std; -client c3 { - loop 5 { - txreq -url "/three" - rxresp - expect resp.status == 200 - expect resp.http.content-length == "4" - expect resp.http.foo == "bar" - expect resp.http.three == "File Three" + sub vcl_deliver { + if (req.url == "/one") { + set resp.http.one = std.fileread("${tmpdir}/m00004_file_one"); + } else if (req.url == "/two") { + set resp.http.two = std.fileread("${tmpdir}/m00004_file_two"); + } else if (req.url == "/three") { + set resp.http.three = std.fileread("${tmpdir}/m00004_file_three"); + } } +} - loop 5 { - txreq -url "/two" - rxresp - expect resp.status == 200 - expect resp.http.content-length == "4" - expect resp.http.foo == "bar" - expect resp.http.two == "File Two" - - txreq -url "/one" - rxresp - expect resp.status == 200 - expect resp.http.content-length == "4" - expect resp.http.foo == "bar" - expect resp.http.one == "File One" - } -} +varnish v1 -cli "vcl.list" +varnish v1 -cli "vcl.use vcl2" client c1 -run -client c2 -run -client c3 -run + +varnish v1 -cli "vcl.list" +varnish v1 -cli "vcl.discard vcl1" + +varnish v1 -vcl+backend { } + +varnish v1 -cli "vcl.list" +varnish v1 -cli "vcl.discard vcl2" + + +client c1 { + txreq -url "/one" + rxresp + txreq -url "/two" + rxresp + txreq -url "/three" + rxresp +} -run + +varnish v1 -cli "vcl.list" From phk at varnish-cache.org Thu May 12 08:35:17 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Thu, 12 May 2011 10:35:17 +0200 Subject: [master] 3fe0d1d Get refcounting and testing thereoff correct in std.fileread() Message-ID: commit 3fe0d1d96d9b0940b409c10aeaea95c13c9d243e Author: Poul-Henning Kamp Date: Thu May 12 08:34:57 2011 +0000 Get refcounting and testing thereoff correct in std.fileread() diff --git a/bin/varnishtest/tests/m00004.vtc b/bin/varnishtest/tests/m00004.vtc index 4aa4291..839d106 100644 --- a/bin/varnishtest/tests/m00004.vtc +++ b/bin/varnishtest/tests/m00004.vtc @@ -76,10 +76,7 @@ varnish v1 -cli "vcl.list" varnish v1 -cli "vcl.discard vcl1" varnish v1 -vcl+backend { } - -varnish v1 -cli "vcl.list" -varnish v1 -cli "vcl.discard vcl2" - +varnish v1 -cli "vcl.use vcl3" client c1 { txreq -url "/one" @@ -91,3 +88,8 @@ client c1 { } -run varnish v1 -cli "vcl.list" +varnish v1 -cli "vcl.discard vcl2" + +client c1 -run + +varnish v1 -cli "vcl.list" diff --git a/lib/libvmod_std/vmod_std_fileread.c b/lib/libvmod_std/vmod_std_fileread.c index 1890b76..f7654e2 100644 --- a/lib/libvmod_std/vmod_std_fileread.c +++ b/lib/libvmod_std/vmod_std_fileread.c @@ -37,12 +37,7 @@ * XXX: underlying file has been updated. */ -#include -#include #include -#include -#include -#include #include "vrt.h" #include "../../bin/varnishd/cache.h" @@ -101,8 +96,11 @@ vmod_fileread(struct sess *sp, struct vmod_priv *priv, const char *file_name) } } AZ(pthread_mutex_unlock(&frmtx)); - if (frf != NULL) + if (frf != NULL) { + priv->free = free_frfile; + priv->priv = frf; return (frf->contents); + } s = vreadfile(NULL, file_name, NULL); if (s != NULL) { From phk at varnish-cache.org Thu May 12 09:01:28 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Thu, 12 May 2011 11:01:28 +0200 Subject: [master] 0dfc7c7 Try harder to cover all of std.fileread() Message-ID: commit 0dfc7c787c03d839df8211e1fc179fc022cbe07d Author: Poul-Henning Kamp Date: Thu May 12 09:01:12 2011 +0000 Try harder to cover all of std.fileread() diff --git a/bin/varnishtest/tests/m00004.vtc b/bin/varnishtest/tests/m00004.vtc index 839d106..0dbe2cc 100644 --- a/bin/varnishtest/tests/m00004.vtc +++ b/bin/varnishtest/tests/m00004.vtc @@ -71,6 +71,7 @@ varnish v1 -cli "vcl.list" varnish v1 -cli "vcl.use vcl2" client c1 -run +client c1 -run varnish v1 -cli "vcl.list" varnish v1 -cli "vcl.discard vcl1" From phk at varnish-cache.org Thu May 12 12:19:13 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Thu, 12 May 2011 14:19:13 +0200 Subject: [master] 78308e3 White-space polishing Message-ID: commit 78308e370c32b2f2f5db249c97d9fadd9633e63e Author: Poul-Henning Kamp Date: Thu May 12 10:33:46 2011 +0000 White-space polishing diff --git a/bin/varnishd/cache_ban.c b/bin/varnishd/cache_ban.c index 94ff84d..2ce40ef 100644 --- a/bin/varnishd/cache_ban.c +++ b/bin/varnishd/cache_ban.c @@ -549,7 +549,7 @@ ban_lurker_work(const struct sess *sp) oh = oc->objhead; CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC); if (Lck_Trylock(&oh->mtx)) { - Lck_Unlock(&ban_mtx); + Lck_Unlock(&ban_mtx); return; } diff --git a/bin/varnishd/cache_center.c b/bin/varnishd/cache_center.c index d6101e1..5d2a0d7 100644 --- a/bin/varnishd/cache_center.c +++ b/bin/varnishd/cache_center.c @@ -166,7 +166,7 @@ cnt_prepresp(struct sess *sp) sp->wrk->res_mode = 0; - if (!sp->wrk->do_stream || + if (!sp->wrk->do_stream || (sp->wrk->h_content_length != NULL && !sp->wrk->do_gunzip)) sp->wrk->res_mode |= RES_LEN; diff --git a/lib/libvmod_std/vmod_std_fileread.c b/lib/libvmod_std/vmod_std_fileread.c index f7654e2..fdc04a5 100644 --- a/lib/libvmod_std/vmod_std_fileread.c +++ b/lib/libvmod_std/vmod_std_fileread.c @@ -87,7 +87,7 @@ vmod_fileread(struct sess *sp, struct vmod_priv *priv, const char *file_name) CAST_OBJ_NOTNULL(frf, priv->priv, CACHED_FILE_MAGIC); return (frf->contents); } - + AZ(pthread_mutex_lock(&frmtx)); VTAILQ_FOREACH(frf, &frlist, list) { if (!strcmp(file_name, frf->file_name)) { From phk at varnish-cache.org Thu May 12 12:19:13 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Thu, 12 May 2011 14:19:13 +0200 Subject: [master] 343c89d Remove now unused file Message-ID: commit 343c89d810e29504f7c415174b36e237b731968d Author: Poul-Henning Kamp Date: Thu May 12 10:46:00 2011 +0000 Remove now unused file diff --git a/bin/varnishd/cache_esi.c b/bin/varnishd/cache_esi.c deleted file mode 100644 index e69de29..0000000 From phk at varnish-cache.org Thu May 12 12:19:14 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Thu, 12 May 2011 14:19:14 +0200 Subject: [master] acffa04 Blow away old configure script before we start. Message-ID: commit acffa040a1922260d9f6d7ef8f5d6aad7fd19224 Author: Poul-Henning Kamp Date: Thu May 12 10:46:25 2011 +0000 Blow away old configure script before we start. diff --git a/autogen.des b/autogen.des index 1bed874..a75d482 100755 --- a/autogen.des +++ b/autogen.des @@ -10,6 +10,7 @@ if [ -f /usr/bin/clang -a "x${CC}" = "x" ] ; then export CC fi +rm -f configure . ./autogen.sh # autoconf prior to 2.62 has issues with zsh 4.2 and newer From phk at varnish-cache.org Thu May 12 12:19:14 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Thu, 12 May 2011 14:19:14 +0200 Subject: [master] 2378a51 Eradicate strlcat() compat function, we don't use strlcat() anywhere. Message-ID: commit 2378a511e25d61e500db1a3b36b9ae4b978b3116 Author: Poul-Henning Kamp Date: Thu May 12 10:46:44 2011 +0000 Eradicate strlcat() compat function, we don't use strlcat() anywhere. diff --git a/configure.ac b/configure.ac index cff648d..de6688a 100644 --- a/configure.ac +++ b/configure.ac @@ -296,7 +296,7 @@ AC_SUBST(LIBUMEM) # are not available AC_CHECK_FUNCS([setproctitle]) AC_CHECK_FUNCS([srandomdev]) -AC_CHECK_FUNCS([strlcat strlcpy]) +AC_CHECK_FUNCS([strlcpy]) AC_CHECK_FUNCS([strndup]) AC_CHECK_FUNCS([backtrace]) # white lie - we don't actually test it diff --git a/include/Makefile.am b/include/Makefile.am index e5b4348..866adc0 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -21,7 +21,6 @@ nobase_noinst_HEADERS = \ compat/execinfo.h \ compat/setproctitle.h \ compat/srandomdev.h \ - compat/strlcat.h \ compat/strlcpy.h \ compat/strndup.h \ flopen.h \ diff --git a/include/compat/strlcat.h b/include/compat/strlcat.h deleted file mode 100644 index 619e648..0000000 --- a/include/compat/strlcat.h +++ /dev/null @@ -1,38 +0,0 @@ -/*- - * Copyright (c) 2006 Verdens Gang AS - * Copyright (c) 2006-2009 Linpro AS - * All rights reserved. - * - * Author: Dag-Erling Sm?rgrav - * - * 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. - * - */ - -#ifndef COMPAT_STRLCAT_H_INCLUDED -#define COMPAT_STRLCAT_H_INCLUDED - -#ifndef HAVE_STRLCAT -size_t strlcat(char *dst, const char *src, size_t size); -#endif - -#endif diff --git a/lib/libvarnishcompat/Makefile.am b/lib/libvarnishcompat/Makefile.am index a75daeb..551a23d 100644 --- a/lib/libvarnishcompat/Makefile.am +++ b/lib/libvarnishcompat/Makefile.am @@ -11,6 +11,5 @@ libvarnishcompat_la_SOURCES = \ execinfo.c \ setproctitle.c \ srandomdev.c \ - strlcat.c \ strlcpy.c \ strndup.c diff --git a/lib/libvarnishcompat/strlcat.c b/lib/libvarnishcompat/strlcat.c deleted file mode 100644 index 387650d..0000000 --- a/lib/libvarnishcompat/strlcat.c +++ /dev/null @@ -1,62 +0,0 @@ -/* $OpenBSD: strlcat.c,v 1.13 2005/08/08 08:05:37 espie Exp $ */ - -/* - * Copyright (c) 1998 Todd C. Miller - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include "config.h" - -#ifndef HAVE_STRLCAT - -#include -#include - -#include "compat/strlcat.h" - -/* - * Appends src to string dst of size siz (unlike strncat, siz is the - * full size of dst, not space left). At most siz-1 characters - * will be copied. Always NUL terminates (unless siz <= strlen(dst)). - * Returns strlen(src) + MIN(siz, strlen(initial dst)). - * If retval >= siz, truncation occurred. - */ -size_t -strlcat(char *dst, const char *src, size_t siz) -{ - char *d = dst; - const char *s = src; - size_t n = siz; - size_t dlen; - - /* Find the end of dst and adjust bytes left but don't go past end */ - while (n-- != 0 && *d != '\0') - d++; - dlen = d - dst; - n = siz - dlen; - - if (n == 0) - return(dlen + strlen(s)); - while (*s != '\0') { - if (n != 1) { - *d++ = *s; - n--; - } - s++; - } - *d = '\0'; - - return(dlen + (s - src)); /* count does not include NUL */ -} -#endif From phk at varnish-cache.org Thu May 12 12:19:14 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Thu, 12 May 2011 14:19:14 +0200 Subject: [master] 71b8584 Remove strlcpy() compat includery, strlcpy() is not used. Message-ID: commit 71b8584857c8ffe4fc3b3367de5d3e20ba490952 Author: Poul-Henning Kamp Date: Thu May 12 10:47:51 2011 +0000 Remove strlcpy() compat includery, strlcpy() is not used. diff --git a/bin/varnishd/cache_http.c b/bin/varnishd/cache_http.c index fc03c1a..5dc922a 100644 --- a/bin/varnishd/cache_http.c +++ b/bin/varnishd/cache_http.c @@ -41,10 +41,6 @@ #include "vct.h" #include "cache.h" -#ifndef HAVE_STRLCPY -#include -#endif - #define HTTPH(a, b, c, d, e, f, g) char b[] = "*" a ":"; #include "http_headers.h" #undef HTTPH diff --git a/bin/varnishd/varnishd.c b/bin/varnishd/varnishd.c index 7f423f1..32d97e8 100644 --- a/bin/varnishd/varnishd.c +++ b/bin/varnishd/varnishd.c @@ -50,10 +50,6 @@ #include "compat/daemon.h" -#ifndef HAVE_STRLCPY -#include "compat/strlcpy.h" -#endif - #include "vsb.h" #include "vev.h" #include "vpf.h" From phk at varnish-cache.org Thu May 12 12:19:15 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Thu, 12 May 2011 14:19:15 +0200 Subject: [master] c1e484b Eliminate strlcpy() compat includery, it is not used. Message-ID: commit c1e484b5b1fb7cda98cfba6f0efc70f961e94b33 Author: Poul-Henning Kamp Date: Thu May 12 10:48:57 2011 +0000 Eliminate strlcpy() compat includery, it is not used. diff --git a/lib/libvarnish/vpf.c b/lib/libvarnish/vpf.c index f0db8e9..641fbb9 100644 --- a/lib/libvarnish/vpf.c +++ b/lib/libvarnish/vpf.c @@ -39,10 +39,6 @@ #include #include -#ifndef HAVE_STRLCPY -#include "compat/strlcpy.h" -#endif - #include "libvarnish.h" /* XXX: for assert() */ #include "flopen.h" #include "vpf.h" From phk at varnish-cache.org Thu May 12 12:19:16 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Thu, 12 May 2011 14:19:16 +0200 Subject: [master] dd0ca90 Remove two unused stats fields Message-ID: commit dd0ca90e93237f11f40bcb67006988cea274ae93 Author: Poul-Henning Kamp Date: Thu May 12 10:51:43 2011 +0000 Remove two unused stats fields diff --git a/include/vsc_fields.h b/include/vsc_fields.h index a77939c..a96da33 100644 --- a/include/vsc_fields.h +++ b/include/vsc_fields.h @@ -50,7 +50,6 @@ VSC_F(backend_fail, uint64_t, 0, 'a', "Backend conn. failures") VSC_F(backend_reuse, uint64_t, 0, 'a', "Backend conn. reuses") VSC_F(backend_toolate, uint64_t, 0, 'a', "Backend conn. was closed") VSC_F(backend_recycle, uint64_t, 0, 'a', "Backend conn. recycles") -VSC_F(backend_unused, uint64_t, 0, 'a', "Backend conn. unused") VSC_F(backend_retry, uint64_t, 0, 'a', "Backend conn. retry") VSC_F(fetch_head, uint64_t, 1, 'a', "Fetch head") @@ -140,7 +139,6 @@ VSC_F(hcb_nolock, uint64_t, 0, 'a', "HCB Lookups without lock") VSC_F(hcb_lock, uint64_t, 0, 'a', "HCB Lookups with lock") VSC_F(hcb_insert, uint64_t, 0, 'a', "HCB Inserts") -VSC_F(esi_parse, uint64_t, 0, 'a', "Objects ESI parsed (unlock)") VSC_F(esi_errors, uint64_t, 0, 'a', "ESI parse errors (unlock)") VSC_F(esi_warnings, uint64_t, 0, 'a', "ESI parse warnings (unlock)") VSC_F(accept_fail, uint64_t, 0, 'a', "Accept failures") From phk at varnish-cache.org Thu May 12 12:19:16 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Thu, 12 May 2011 14:19:16 +0200 Subject: [master] f4390be Eliminate strlcpy() compat includery, it is not used. Message-ID: commit f4390be4c59e2b3fe1d11ebd55da202ea81905da Author: Poul-Henning Kamp Date: Thu May 12 10:55:16 2011 +0000 Eliminate strlcpy() compat includery, it is not used. diff --git a/lib/libvarnish/vss.c b/lib/libvarnish/vss.c index dfad6f7..18ac41d 100644 --- a/lib/libvarnish/vss.c +++ b/lib/libvarnish/vss.c @@ -43,9 +43,6 @@ #include #include -#ifndef HAVE_STRLCPY -#include "compat/strlcpy.h" -#endif #ifndef HAVE_STRNDUP #include "compat/strndup.h" #endif From phk at varnish-cache.org Thu May 12 12:19:16 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Thu, 12 May 2011 14:19:16 +0200 Subject: [master] 24459e2 use snprintf() instead of strlcpy() Message-ID: commit 24459e2e77b111d721ee2b5fae1f0cfc0c9e3365 Author: Poul-Henning Kamp Date: Thu May 12 10:55:41 2011 +0000 use snprintf() instead of strlcpy() diff --git a/lib/libvarnish/tcp.c b/lib/libvarnish/tcp.c index bed3b99..1f529b3 100644 --- a/lib/libvarnish/tcp.c +++ b/lib/libvarnish/tcp.c @@ -52,9 +52,6 @@ #include #include "config.h" -#ifndef HAVE_STRLCPY -#include "compat/strlcpy.h" -#endif #include "libvarnish.h" @@ -92,8 +89,8 @@ TCP_name(const struct sockaddr_storage *addr, unsigned l, * for the gai_strerror in the bufffer :-( */ printf("getnameinfo = %d %s\n", i, gai_strerror(i)); - strlcpy(abuf, "Conversion", alen); - strlcpy(pbuf, "Failed", plen); + snprintf(abuf, alen, "Conversion"); + snprintf(pbuf, plen, "Failed"); return; } /* XXX dirty hack for v4-to-v6 mapped addresses */ @@ -128,8 +125,8 @@ TCP_hisname(int sock, char *abuf, unsigned alen, char *pbuf, unsigned plen) if (!getpeername(sock, (void*)&addr_s, &l)) TCP_name(&addr_s, l, abuf, alen, pbuf, plen); else { - strlcpy(abuf, "", alen); - strlcpy(pbuf, "", plen); + snprintf(abuf, alen, ""); + snprintf(pbuf, plen, ""); } } From phk at varnish-cache.org Thu May 12 12:19:17 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Thu, 12 May 2011 14:19:17 +0200 Subject: [master] f06aa9f Remove pointless expecations Message-ID: commit f06aa9fd58b40a8b5737588074f6d77ec56c80e7 Author: Poul-Henning Kamp Date: Thu May 12 10:57:42 2011 +0000 Remove pointless expecations diff --git a/bin/varnishtest/tests/e00013.vtc b/bin/varnishtest/tests/e00013.vtc index d3de7a4..700914c 100644 --- a/bin/varnishtest/tests/e00013.vtc +++ b/bin/varnishtest/tests/e00013.vtc @@ -20,5 +20,4 @@ client c1 { rxresp } -run -varnish v1 -expect esi_parse == 0 varnish v1 -expect esi_errors == 0 diff --git a/bin/varnishtest/tests/e00014.vtc b/bin/varnishtest/tests/e00014.vtc index 0c36700..e366f1f 100644 --- a/bin/varnishtest/tests/e00014.vtc +++ b/bin/varnishtest/tests/e00014.vtc @@ -23,5 +23,4 @@ client c1 { expect resp.bodylen == 49 } -run -varnish v1 -expect esi_parse == 0 varnish v1 -expect esi_errors == 0 From phk at varnish-cache.org Thu May 12 12:19:17 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Thu, 12 May 2011 14:19:17 +0200 Subject: [master] e4f312d Eliminate use of strndup(), in this case the length is known to match precisely. Message-ID: commit e4f312d354be8f95f2d07e7567c2ca5f56d8217e Author: Poul-Henning Kamp Date: Thu May 12 12:15:36 2011 +0000 Eliminate use of strndup(), in this case the length is known to match precisely. diff --git a/bin/varnishreplay/varnishreplay.c b/bin/varnishreplay/varnishreplay.c index 2ef996f..713f125 100644 --- a/bin/varnishreplay/varnishreplay.c +++ b/bin/varnishreplay/varnishreplay.c @@ -49,10 +49,6 @@ #include "varnishapi.h" #include "vss.h" -#ifndef HAVE_STRNDUP -#include "compat/strndup.h" -#endif - #define freez(x) do { if (x) free(x); x = NULL; } while (0); static struct vss_addr *addr_info; @@ -661,7 +657,9 @@ gen_traffic(void *priv, enum vsl_tag tag, unsigned fd, msg = malloc(sizeof (struct message)); msg->tag = tag; msg->len = len; - msg->ptr = strndup(ptr, len); + msg->ptr = malloc(len); + AN(msg->ptr); + memcpy(msg->ptr, ptr, len); mailbox_put(&thr->mbox, msg); return (0); From phk at varnish-cache.org Thu May 12 12:19:18 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Thu, 12 May 2011 14:19:18 +0200 Subject: [master] 8f389e5 Eliminate strndup() from here, strdup() is just fine. Message-ID: commit 8f389e554f1b41c4788c018d2ac874c91a8379f2 Author: Poul-Henning Kamp Date: Thu May 12 12:16:26 2011 +0000 Eliminate strndup() from here, strdup() is just fine. diff --git a/lib/libvarnish/vss.c b/lib/libvarnish/vss.c index 18ac41d..43f3e4a 100644 --- a/lib/libvarnish/vss.c +++ b/lib/libvarnish/vss.c @@ -43,10 +43,6 @@ #include #include -#ifndef HAVE_STRNDUP -#include "compat/strndup.h" -#endif - #include "libvarnish.h" #include "vss.h" @@ -87,8 +83,9 @@ VSS_parse(const char *str, char **addr, char **port) p == str + 1 || (p[1] != '\0' && p[1] != ':')) return (-1); - *addr = strndup(str + 1, p - (str + 1)); + *addr = strdup(str + 1); XXXAN(*addr); + (*addr)[p - (str + 1)] = '\0'; if (p[1] == ':') { *port = strdup(p + 2); XXXAN(*port); @@ -103,8 +100,9 @@ VSS_parse(const char *str, char **addr, char **port) XXXAN(*addr); } else { if (p > str) { - *addr = strndup(str, p - str); + *addr = strdup(str); XXXAN(*addr); + (*addr)[p - str] = '\0'; } *port = strdup(p + 1); XXXAN(*port); From phk at varnish-cache.org Thu May 12 12:19:18 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Thu, 12 May 2011 14:19:18 +0200 Subject: [master] 9070819 Eliminate strlcpy() and strndup() functions, now unused. Message-ID: commit 907081961a1420dfc62378fb66dced5c94166e8c Author: Poul-Henning Kamp Date: Thu May 12 12:16:52 2011 +0000 Eliminate strlcpy() and strndup() functions, now unused. diff --git a/configure.ac b/configure.ac index de6688a..8ab0a9f 100644 --- a/configure.ac +++ b/configure.ac @@ -296,8 +296,6 @@ AC_SUBST(LIBUMEM) # are not available AC_CHECK_FUNCS([setproctitle]) AC_CHECK_FUNCS([srandomdev]) -AC_CHECK_FUNCS([strlcpy]) -AC_CHECK_FUNCS([strndup]) AC_CHECK_FUNCS([backtrace]) # white lie - we don't actually test it AC_MSG_CHECKING([whether daemon() works]) diff --git a/include/Makefile.am b/include/Makefile.am index 866adc0..146cc6a 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -21,8 +21,6 @@ nobase_noinst_HEADERS = \ compat/execinfo.h \ compat/setproctitle.h \ compat/srandomdev.h \ - compat/strlcpy.h \ - compat/strndup.h \ flopen.h \ http_headers.h \ http_response.h \ diff --git a/include/compat/strlcpy.h b/include/compat/strlcpy.h deleted file mode 100644 index 9d2f842..0000000 --- a/include/compat/strlcpy.h +++ /dev/null @@ -1,38 +0,0 @@ -/*- - * Copyright (c) 2006 Verdens Gang AS - * Copyright (c) 2006-2009 Linpro AS - * All rights reserved. - * - * Author: Dag-Erling Sm?rgrav - * - * 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. - * - */ - -#ifndef COMPAT_STRLCPY_H_INCLUDED -#define COMPAT_STRLCPY_H_INCLUDED - -#ifndef HAVE_STRLCPY -size_t strlcpy(char *dst, const char *src, size_t size); -#endif - -#endif diff --git a/include/compat/strndup.h b/include/compat/strndup.h deleted file mode 100644 index 51a43b6..0000000 --- a/include/compat/strndup.h +++ /dev/null @@ -1,38 +0,0 @@ -/*- - * Copyright (c) 2006 Verdens Gang AS - * Copyright (c) 2006-2009 Linpro AS - * All rights reserved. - * - * Author: Dag-Erling Sm?rgrav - * - * 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. - * - */ - -#ifndef COMPAT_STRNDUP_H_INCLUDED -#define COMPAT_STRNDUP_H_INCLUDED - -#ifndef HAVE_STRNDUP -char *strndup(const char *str, size_t len); -#endif - -#endif diff --git a/lib/libvarnishcompat/Makefile.am b/lib/libvarnishcompat/Makefile.am index 551a23d..7e6102c 100644 --- a/lib/libvarnishcompat/Makefile.am +++ b/lib/libvarnishcompat/Makefile.am @@ -10,6 +10,4 @@ libvarnishcompat_la_SOURCES = \ daemon.c \ execinfo.c \ setproctitle.c \ - srandomdev.c \ - strlcpy.c \ - strndup.c + srandomdev.c diff --git a/lib/libvarnishcompat/strlcpy.c b/lib/libvarnishcompat/strlcpy.c deleted file mode 100644 index aef313a..0000000 --- a/lib/libvarnishcompat/strlcpy.c +++ /dev/null @@ -1,58 +0,0 @@ -/* $OpenBSD: strlcpy.c,v 1.10 2005/08/08 08:05:37 espie Exp $ */ - -/* - * Copyright (c) 1998 Todd C. Miller - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include "config.h" - -#ifndef HAVE_STRLCPY - -#include -#include - -#include "compat/strlcpy.h" - -/* - * Copy src to string dst of size siz. At most siz-1 characters - * will be copied. Always NUL terminates (unless siz == 0). - * Returns strlen(src); if retval >= siz, truncation occurred. - */ -size_t -strlcpy(char *dst, const char *src, size_t siz) -{ - char *d = dst; - const char *s = src; - size_t n = siz; - - /* Copy as many bytes as will fit */ - if (n != 0 && --n != 0) { - do { - if ((*d++ = *s++) == 0) - break; - } while (--n != 0); - } - - /* Not enough room in dst, add NUL and traverse rest of src */ - if (n == 0) { - if (siz != 0) - *d = '\0'; /* NUL-terminate dst */ - while (*s++) - ; - } - - return(s - src - 1); /* count does not include NUL */ -} -#endif diff --git a/lib/libvarnishcompat/strndup.c b/lib/libvarnishcompat/strndup.c deleted file mode 100644 index e39a489..0000000 --- a/lib/libvarnishcompat/strndup.c +++ /dev/null @@ -1,55 +0,0 @@ -/*- - * Copyright (c) 2006 Verdens Gang AS - * Copyright (c) 2006-2009 Linpro AS - * All rights reserved. - * - * Author: Dag-Erling Sm?rgrav - * - * 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 "config.h" - -#ifndef HAVE_STRNDUP - -#include -#include - -#ifndef HAVE_STRLCPY -#include "compat/strlcpy.h" -#endif - -#include "compat/strndup.h" - -char * -strndup(const char *str, size_t len) -{ - char *dup; - - /* wasteful if len is large and str is short */ - if ((dup = malloc(len + 1)) != NULL) - strlcpy(dup, str, len + 1); - return (dup); -} - -#endif From phk at varnish-cache.org Thu May 12 13:54:30 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Thu, 12 May 2011 15:54:30 +0200 Subject: [master] d0ee07f Remove empty setproctitle() compat function. Message-ID: commit d0ee07f8c5e2e24c73bef5a50cdc425398425164 Author: Poul-Henning Kamp Date: Thu May 12 13:54:13 2011 +0000 Remove empty setproctitle() compat function. diff --git a/bin/varnishd/mgt_child.c b/bin/varnishd/mgt_child.c index a7c91a4..3ed569d 100644 --- a/bin/varnishd/mgt_child.c +++ b/bin/varnishd/mgt_child.c @@ -43,10 +43,6 @@ #include #include -#ifndef HAVE_SETPROCTITLE -#include "compat/setproctitle.h" -#endif - #include "mgt.h" #include "vsm.h" #include "heritage.h" @@ -337,7 +333,9 @@ start_child(struct cli *cli) continue; (void)(close(i) == 0); } +#ifdef HAVE_SETPROCTITLE setproctitle("Varnish-Chld %s", heritage.name); +#endif (void)signal(SIGINT, SIG_DFL); (void)signal(SIGTERM, SIG_DFL); @@ -582,7 +580,9 @@ MGT_Run(void) e->name = "mgt_sigchild"; AZ(vev_add(mgt_evb, e)); +#ifdef HAVE_SETPROCTITLE setproctitle("Varnish-Mgr %s", heritage.name); +#endif memset(&sac, 0, sizeof sac); sac.sa_handler = SIG_IGN; diff --git a/bin/varnishd/mgt_sandbox.c b/bin/varnishd/mgt_sandbox.c index 0922490..653f1d5 100644 --- a/bin/varnishd/mgt_sandbox.c +++ b/bin/varnishd/mgt_sandbox.c @@ -52,10 +52,6 @@ #include #endif -#ifndef HAVE_SETPROCTITLE -#include "compat/setproctitle.h" -#endif - #ifdef __linux__ #include #endif diff --git a/include/Makefile.am b/include/Makefile.am index 146cc6a..29ddec3 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -19,7 +19,6 @@ nobase_noinst_HEADERS = \ cli_serve.h \ compat/daemon.h \ compat/execinfo.h \ - compat/setproctitle.h \ compat/srandomdev.h \ flopen.h \ http_headers.h \ diff --git a/include/compat/setproctitle.h b/include/compat/setproctitle.h deleted file mode 100644 index 85bb5e8..0000000 --- a/include/compat/setproctitle.h +++ /dev/null @@ -1,38 +0,0 @@ -/*- - * Copyright (c) 2006 Verdens Gang AS - * Copyright (c) 2006-2009 Linpro AS - * All rights reserved. - * - * Author: Dag-Erling Sm?rgrav - * - * 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. - * - */ - -#ifndef COMPAT_SETPROCTITLE_H_INCLUDED -#define COMPAT_SETPROCTITLE_H_INCLUDED - -#ifndef HAVE_SETPROCTITLE -void setproctitle(const char *fmt, ...); -#endif - -#endif diff --git a/lib/libvarnishcompat/Makefile.am b/lib/libvarnishcompat/Makefile.am index 7e6102c..22c652e 100644 --- a/lib/libvarnishcompat/Makefile.am +++ b/lib/libvarnishcompat/Makefile.am @@ -9,5 +9,4 @@ libvarnishcompat_la_LDFLAGS = -avoid-version libvarnishcompat_la_SOURCES = \ daemon.c \ execinfo.c \ - setproctitle.c \ srandomdev.c diff --git a/lib/libvarnishcompat/setproctitle.c b/lib/libvarnishcompat/setproctitle.c deleted file mode 100644 index a8d46d1..0000000 --- a/lib/libvarnishcompat/setproctitle.c +++ /dev/null @@ -1,47 +0,0 @@ -/*- - * Copyright (c) 2006 Verdens Gang AS - * Copyright (c) 2006-2009 Linpro AS - * All rights reserved. - * - * Author: Dag-Erling Sm?rgrav - * - * 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 "config.h" - -#ifndef HAVE_SETPROCTITLE - -#include - -#include "compat/setproctitle.h" - -void -setproctitle(const char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - /* XXX */ - va_end(ap); -} -#endif From phk at varnish-cache.org Thu May 12 14:25:52 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Thu, 12 May 2011 16:25:52 +0200 Subject: [master] 5a83d47 srandom() argument is unsigned long, not unsigned int. Message-ID: commit 5a83d477adf258a5ea95081f7f1dfceb1311eff5 Author: Poul-Henning Kamp Date: Thu May 12 13:56:28 2011 +0000 srandom() argument is unsigned long, not unsigned int. diff --git a/lib/libvarnishcompat/srandomdev.c b/lib/libvarnishcompat/srandomdev.c index 47ae815..bedea6a 100644 --- a/lib/libvarnishcompat/srandomdev.c +++ b/lib/libvarnishcompat/srandomdev.c @@ -44,7 +44,7 @@ void srandomdev(void) { struct timeval tv; - unsigned int seed; + unsigned long seed; int fd; if ((fd = open("/dev/urandom", O_RDONLY)) >= 0 || From phk at varnish-cache.org Thu May 12 14:25:52 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Thu, 12 May 2011 16:25:52 +0200 Subject: [master] 4ef7a77 Include python files in white-space sweep Message-ID: commit 4ef7a77fd1676a911876e662e84f15148f14d56b Author: Poul-Henning Kamp Date: Thu May 12 14:25:38 2011 +0000 Include python files in white-space sweep diff --git a/lib/libvcl/generate.py b/lib/libvcl/generate.py index 06620e5..904fea1 100755 --- a/lib/libvcl/generate.py +++ b/lib/libvcl/generate.py @@ -572,7 +572,7 @@ def emit_file(fo, fn): w = 66 # Width of lines, after white space prefix maxlen = 10240 # Max length of string literal - x = 0 + x = 0 l = 0 fo.write("\n\t/* %s */\n\n" % fn) for c in fc: @@ -600,7 +600,7 @@ def emit_file(fo, fn): fo.write(d + "\"\n") x = 0 continue - + fo.write(d) x += len(d) l += len(d) @@ -663,7 +663,7 @@ for i in returns: vcls.append(i[0]) for j in i[1]: rets[j] = True - + ####################################################################### fo = open(buildroot + "/include/vcl_returns.h", "w") @@ -782,7 +782,7 @@ def restrict(fo, spec): n += 1 fo.write(p + "VCL_MET_" + j.upper()) p = " | " - + fo.write(",\n") ####################################################################### diff --git a/lib/libvmod_std/vmod.py b/lib/libvmod_std/vmod.py index 5ff69f0..6614115 100755 --- a/lib/libvmod_std/vmod.py +++ b/lib/libvmod_std/vmod.py @@ -196,7 +196,7 @@ while True: while -1 == l.find(")"): l1 = nextline() - if l1 == "": + if l1 == "": raise Exception("End Of Input looking for ')'") l = l + l1 @@ -229,7 +229,7 @@ while True: elif tq != None: raise Exception( "Argument type '%s' cannot be qualified with {...}" % at) - + vargs.append(at) do_func(fname, rt_type, args, vargs) From tfheen at varnish-cache.org Fri May 13 07:45:58 2011 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Fri, 13 May 2011 09:45:58 +0200 Subject: [master] 3d973f5 Fix spec file for 3.0.0-beta1 Message-ID: commit 3d973f5438fb5ba721c63f00ab7fbfc9641edb12 Author: Tollef Fog Heen Date: Fri May 13 09:42:37 2011 +0200 Fix spec file for 3.0.0-beta1 diff --git a/redhat/varnish.spec b/redhat/varnish.spec index e50084d..c2d2ee9 100644 --- a/redhat/varnish.spec +++ b/redhat/varnish.spec @@ -6,7 +6,7 @@ License: BSD Group: System Environment/Daemons URL: http://www.varnish-cache.org/ #Source0: http://repo.varnish-cache.org/source/%{name}-%{version}.tar.gz -Source0: %{name}-3.0-beta1.tar.gz +Source0: %{name}-3.0.0-beta1.tar.gz BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) # To build from git, start with a make dist, see redhat/README.redhat # You will need at least automake autoconf libtool python-docutils @@ -72,7 +72,7 @@ Documentation files for %name %prep #%setup -q -%setup -q -n varnish-3.0-beta1 +%setup -q -n varnish-3.0.0-beta1 mkdir examples cp bin/varnishd/default.vcl etc/zope-plone.vcl examples From phk at varnish-cache.org Fri May 13 07:52:06 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Fri, 13 May 2011 09:52:06 +0200 Subject: [master] 14a0992 Make thread_pool_max and thread_pool_min consistent so they both apply to individual pools. Message-ID: commit 14a09925afd07d27528996ff133a14cd425a8f14 Author: Poul-Henning Kamp Date: Fri May 13 07:50:11 2011 +0000 Make thread_pool_max and thread_pool_min consistent so they both apply to individual pools. diff --git a/bin/varnishd/cache_pool.c b/bin/varnishd/cache_pool.c index f701442..2b82455 100644 --- a/bin/varnishd/cache_pool.c +++ b/bin/varnishd/cache_pool.c @@ -436,7 +436,7 @@ wrk_herdtimer_thread(void *priv) /* Scale parameters */ - u = params->wthread_max / nwq; + u = params->wthread_max; if (u < params->wthread_min) u = params->wthread_min; nthr_max = u; diff --git a/bin/varnishd/mgt_pool.c b/bin/varnishd/mgt_pool.c index afa8435..fce1a8f 100644 --- a/bin/varnishd/mgt_pool.c +++ b/bin/varnishd/mgt_pool.c @@ -121,7 +121,7 @@ const struct parspec WRK_parspec[] = { EXPERIMENTAL | DELAYED_EFFECT, "2", "pools" }, { "thread_pool_max", tweak_thread_pool_max, NULL, 1, 0, - "The maximum number of worker threads in all pools combined.\n" + "The maximum number of worker threads in each pool.\n" "\n" "Do not set this higher than you have to, since excess " "worker threads soak up RAM and CPU and generally just get " @@ -129,7 +129,7 @@ const struct parspec WRK_parspec[] = { EXPERIMENTAL | DELAYED_EFFECT, "500", "threads" }, { "thread_pool_min", tweak_thread_pool_min, NULL, 2, 0, - "The minimum number of threads in each worker pool.\n" + "The minimum number of threads in each pool.\n" "\n" "Increasing this may help ramp up faster from low load " "situations where threads have expired.\n" From phk at varnish-cache.org Fri May 13 07:52:07 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Fri, 13 May 2011 09:52:07 +0200 Subject: [master] 5f954d2 Merge branch 'master' of ssh://git.varnish-cache.org/git/varnish-cache Message-ID: commit 5f954d2c401bbc85e95c2c54bed2d89cc4bf4f64 Merge: 14a0992 3d973f5 Author: Poul-Henning Kamp Date: Fri May 13 07:50:45 2011 +0000 Merge branch 'master' of ssh://git.varnish-cache.org/git/varnish-cache From tfheen at varnish-cache.org Fri May 13 08:25:17 2011 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Fri, 13 May 2011 10:25:17 +0200 Subject: [master] 88f8a36 Add missing paranthesis, needed on platforms without nanosleep Message-ID: commit 88f8a36b961b5fd254bbda6cd1577737e792ff1e Author: Thomas Woinke Date: Fri May 13 10:24:51 2011 +0200 Add missing paranthesis, needed on platforms without nanosleep diff --git a/lib/libvarnish/time.c b/lib/libvarnish/time.c index 4c7abe7..8e79a1c 100644 --- a/lib/libvarnish/time.c +++ b/lib/libvarnish/time.c @@ -166,7 +166,7 @@ TIM_sleep(double t) (void)nanosleep(&ts, NULL); #else if (t >= 1.) { - (void)sleep(floor(t); + (void)sleep(floor(t)); t -= floor(t); } /* XXX: usleep() is not mandated to be thread safe */ From phk at varnish-cache.org Fri May 13 10:09:46 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Fri, 13 May 2011 12:09:46 +0200 Subject: [master] f1bb6a6 Improve phrasing. Message-ID: commit f1bb6a6c49fdd2ea60a68c40b8d2aafd79949db3 Author: Poul-Henning Kamp Date: Fri May 13 10:08:46 2011 +0000 Improve phrasing. diff --git a/bin/varnishd/mgt_pool.c b/bin/varnishd/mgt_pool.c index fce1a8f..56f9dca 100644 --- a/bin/varnishd/mgt_pool.c +++ b/bin/varnishd/mgt_pool.c @@ -129,7 +129,7 @@ const struct parspec WRK_parspec[] = { EXPERIMENTAL | DELAYED_EFFECT, "500", "threads" }, { "thread_pool_min", tweak_thread_pool_min, NULL, 2, 0, - "The minimum number of threads in each pool.\n" + "The minimum number of worker threads in each pool.\n" "\n" "Increasing this may help ramp up faster from low load " "situations where threads have expired.\n" From phk at varnish-cache.org Fri May 13 10:09:46 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Fri, 13 May 2011 12:09:46 +0200 Subject: [master] 1bc5ac7 Don't use index(3), use strchr(3). Message-ID: commit 1bc5ac7ecea59a250b64fcc4b89568a4969594c7 Author: Poul-Henning Kamp Date: Fri May 13 10:09:04 2011 +0000 Don't use index(3), use strchr(3). diff --git a/lib/libvarnishapi/vsl_arg.c b/lib/libvarnishapi/vsl_arg.c index a6a2700..d6426a6 100644 --- a/lib/libvarnishapi/vsl_arg.c +++ b/lib/libvarnishapi/vsl_arg.c @@ -174,14 +174,14 @@ vsl_m_arg(const struct VSM_data *vd, const char *opt) ALLOC_OBJ(m, VSL_RE_MATCH_MAGIC); AN(m); - if (! index(opt, ':')) { + if (!strchr(opt, ':')) { fprintf(stderr, "No : found in -o option %s\n", opt); return (-1); } o = strdup(opt); AN(o); - regex = index(o, ':'); + regex = strchr(o, ':'); *regex = '\0'; regex++; From phk at varnish-cache.org Fri May 13 10:09:46 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Fri, 13 May 2011 12:09:46 +0200 Subject: [master] c7e17e0 Merge branch 'master' of ssh://git.varnish-cache.org/git/varnish-cache Message-ID: commit c7e17e082c6d6e39425b1457df5e5ba03e729b57 Merge: 1bc5ac7 88f8a36 Author: Poul-Henning Kamp Date: Fri May 13 10:09:41 2011 +0000 Merge branch 'master' of ssh://git.varnish-cache.org/git/varnish-cache From phk at varnish-cache.org Fri May 13 10:24:00 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Fri, 13 May 2011 12:24:00 +0200 Subject: [master] e633a7f Various FlexeLint inspired cleanups. Message-ID: commit e633a7f885660ee76d075098810c31bdad4e5571 Author: Poul-Henning Kamp Date: Fri May 13 10:23:41 2011 +0000 Various FlexeLint inspired cleanups. diff --git a/bin/varnishd/cache.h b/bin/varnishd/cache.h index 216c432..75ce56d 100644 --- a/bin/varnishd/cache.h +++ b/bin/varnishd/cache.h @@ -703,15 +703,15 @@ struct vgz *VGZ_NewUngzip(struct sess *sp, const char *id); struct vgz *VGZ_NewGzip(struct sess *sp, const char *id); void VGZ_Ibuf(struct vgz *, const void *, ssize_t len); int VGZ_IbufEmpty(const struct vgz *vg); -void VGZ_Obuf(struct vgz *, const void *, ssize_t len); +void VGZ_Obuf(struct vgz *, void *, ssize_t len); int VGZ_ObufFull(const struct vgz *vg); int VGZ_ObufStorage(const struct sess *sp, struct vgz *vg); int VGZ_Gzip(struct vgz *, const void **, size_t *len, enum vgz_flag); int VGZ_Gunzip(struct vgz *, const void **, size_t *len); void VGZ_Destroy(struct vgz **); void VGZ_UpdateObj(const struct vgz*, struct object *); -int VGZ_WrwGunzip(const struct sess *, struct vgz *, void *ibuf, ssize_t ibufl, - char *obuf, ssize_t obufl, ssize_t *obufp); +int VGZ_WrwGunzip(const struct sess *, struct vgz *, const void *ibuf, + ssize_t ibufl, char *obuf, ssize_t obufl, ssize_t *obufp); /* Return values */ #define VGZ_ERROR -1 diff --git a/bin/varnishd/cache_gzip.c b/bin/varnishd/cache_gzip.c index 015b907..73a185e 100644 --- a/bin/varnishd/cache_gzip.c +++ b/bin/varnishd/cache_gzip.c @@ -235,7 +235,7 @@ VGZ_IbufEmpty(const struct vgz *vg) /*--------------------------------------------------------------------*/ void -VGZ_Obuf(struct vgz *vg, const void *ptr, ssize_t len) +VGZ_Obuf(struct vgz *vg, void *ptr, ssize_t len) { CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC); @@ -353,8 +353,8 @@ VGZ_Gzip(struct vgz *vg, const void **pptr, size_t *plen, enum vgz_flag flags) */ int -VGZ_WrwGunzip(const struct sess *sp, struct vgz *vg, void *ibuf, ssize_t ibufl, - char *obuf, ssize_t obufl, ssize_t *obufp) +VGZ_WrwGunzip(const struct sess *sp, struct vgz *vg, const void *ibuf, + ssize_t ibufl, char *obuf, ssize_t obufl, ssize_t *obufp) { int i; size_t dl; @@ -601,7 +601,7 @@ vfp_testgzip_bytes(struct sess *sp, struct http_conn *htc, ssize_t bytes) struct vgz *vg; ssize_t l, w; int i = -100; - uint8_t ibuf[params->gzip_stack_buffer]; + uint8_t obuf[params->gzip_stack_buffer]; size_t dl; const void *dp; struct storage *st; @@ -627,7 +627,7 @@ vfp_testgzip_bytes(struct sess *sp, struct http_conn *htc, ssize_t bytes) RES_StreamPoll(sp); while (!VGZ_IbufEmpty(vg)) { - VGZ_Obuf(vg, ibuf, sizeof ibuf); + VGZ_Obuf(vg, obuf, sizeof obuf); i = VGZ_Gunzip(vg, &dp, &dl); if (i != VGZ_OK && i != VGZ_END) { WSP(sp, SLT_FetchError, diff --git a/lib/libvarnish/tcp.c b/lib/libvarnish/tcp.c index 1f529b3..9e132f3 100644 --- a/lib/libvarnish/tcp.c +++ b/lib/libvarnish/tcp.c @@ -89,8 +89,8 @@ TCP_name(const struct sockaddr_storage *addr, unsigned l, * for the gai_strerror in the bufffer :-( */ printf("getnameinfo = %d %s\n", i, gai_strerror(i)); - snprintf(abuf, alen, "Conversion"); - snprintf(pbuf, plen, "Failed"); + (void)snprintf(abuf, alen, "Conversion"); + (void)snprintf(pbuf, plen, "Failed"); return; } /* XXX dirty hack for v4-to-v6 mapped addresses */ @@ -125,8 +125,8 @@ TCP_hisname(int sock, char *abuf, unsigned alen, char *pbuf, unsigned plen) if (!getpeername(sock, (void*)&addr_s, &l)) TCP_name(&addr_s, l, abuf, alen, pbuf, plen); else { - snprintf(abuf, alen, ""); - snprintf(pbuf, plen, ""); + (void)snprintf(abuf, alen, ""); + (void)snprintf(pbuf, plen, ""); } } From phk at varnish-cache.org Fri May 13 11:59:37 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Fri, 13 May 2011 13:59:37 +0200 Subject: [master] 1e10378 Fix printf formats for 32/64 issues Message-ID: commit 1e10378ad3f7c54b7deaec46d6b792a986b385a0 Author: Poul-Henning Kamp Date: Fri May 13 11:59:24 2011 +0000 Fix printf formats for 32/64 issues diff --git a/bin/varnishtest/vtc_http.c b/bin/varnishtest/vtc_http.c index e0d3ef0..ea12752 100644 --- a/bin/varnishtest/vtc_http.c +++ b/bin/varnishtest/vtc_http.c @@ -871,7 +871,8 @@ cmd_http_txreq(CMD_ARGS) if (*av != NULL) vtc_log(hp->vl, 0, "Unknown http txreq spec: %s\n", *av); if (body != NULL) - vsb_printf(hp->vsb, "Content-Length: %lu%s", strlen(body), nl); + vsb_printf(hp->vsb, "Content-Length: %ju%s", + (uintmax_t)strlen(body), nl); vsb_cat(hp->vsb, nl); if (body != NULL) { vsb_cat(hp->vsb, body); @@ -916,7 +917,8 @@ cmd_http_chunked(CMD_ARGS) AN(av[1]); AZ(av[2]); vsb_clear(hp->vsb); - vsb_printf(hp->vsb, "%lx%s%s%s", strlen(av[1]), nl, av[1], nl); + vsb_printf(hp->vsb, "%jx%s%s%s", + (uintmax_t)strlen(av[1]), nl, av[1], nl); http_write(hp, 4, "chunked"); } From phk at varnish-cache.org Sat May 14 09:53:21 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Sat, 14 May 2011 11:53:21 +0200 Subject: [master] 1bf7f62 Eliminate the cache_ban.h header file, it's contents is entirely private to cache_ban.c, so inline it there. Message-ID: commit 1bf7f6209c44388e4e6603c4a02fa738de398242 Author: Poul-Henning Kamp Date: Sat May 14 09:52:45 2011 +0000 Eliminate the cache_ban.h header file, it's contents is entirely private to cache_ban.c, so inline it there. diff --git a/bin/varnishd/Makefile.am b/bin/varnishd/Makefile.am index f293d09..b6d78e7 100644 --- a/bin/varnishd/Makefile.am +++ b/bin/varnishd/Makefile.am @@ -77,7 +77,6 @@ varnishd_SOURCES = \ noinst_HEADERS = \ acct_fields.h \ cache.h \ - cache_ban.h \ cache_backend.h \ cache_backend_poll.h \ cache_esi.h \ diff --git a/bin/varnishd/cache_ban.c b/bin/varnishd/cache_ban.c index 2ce40ef..becfd4e 100644 --- a/bin/varnishd/cache_ban.c +++ b/bin/varnishd/cache_ban.c @@ -54,7 +54,41 @@ #include "hash_slinger.h" #include "vre.h" -#include "cache_ban.h" +struct ban_test; + +/* A ban-testing function */ +typedef int ban_cond_f(const struct ban_test *bt, const struct object *o, + const struct sess *sp); + +/* Each individual test to be performed on a ban */ +struct ban_test { + unsigned magic; +#define BAN_TEST_MAGIC 0x54feec67 + VTAILQ_ENTRY(ban_test) list; + ban_cond_f *func; + int flags; +#define BAN_T_REGEXP (1 << 0) +#define BAN_T_NOT (1 << 1) + vre_t *re; + char *dst; + char *src; +}; + +struct ban { + unsigned magic; +#define BAN_MAGIC 0x700b08ea + VTAILQ_ENTRY(ban) list; + unsigned refcount; + int flags; +#define BAN_F_GONE (1 << 0) +#define BAN_F_PENDING (1 << 1) +#define BAN_F_REQ (1 << 2) + VTAILQ_HEAD(,ban_test) tests; + VTAILQ_HEAD(,objcore) objcore; + double t0; + struct vsb *vsb; + char *test; +}; static VTAILQ_HEAD(banhead_s,ban) ban_head = VTAILQ_HEAD_INITIALIZER(ban_head); static struct lock ban_mtx; diff --git a/bin/varnishd/cache_ban.h b/bin/varnishd/cache_ban.h deleted file mode 100644 index 700bc12..0000000 --- a/bin/varnishd/cache_ban.h +++ /dev/null @@ -1,65 +0,0 @@ -/*- - * Copyright (c) 2006 Verdens Gang AS - * Copyright (c) 2006-2009 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. - * - */ - -struct ban_test; - -/* A ban-testing function */ -typedef int ban_cond_f(const struct ban_test *bt, const struct object *o, - const struct sess *sp); - -/* Each individual test to be performed on a ban */ -struct ban_test { - unsigned magic; -#define BAN_TEST_MAGIC 0x54feec67 - VTAILQ_ENTRY(ban_test) list; - ban_cond_f *func; - int flags; -#define BAN_T_REGEXP (1 << 0) -#define BAN_T_NOT (1 << 1) - vre_t *re; - char *dst; - char *src; -}; - -struct ban { - unsigned magic; -#define BAN_MAGIC 0x700b08ea - VTAILQ_ENTRY(ban) list; - unsigned refcount; - int flags; -#define BAN_F_GONE (1 << 0) -#define BAN_F_PENDING (1 << 1) -#define BAN_F_REQ (1 << 2) - VTAILQ_HEAD(,ban_test) tests; - VTAILQ_HEAD(,objcore) objcore; - double t0; - struct vsb *vsb; - char *test; -}; From phk at varnish-cache.org Sat May 14 16:08:55 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Sat, 14 May 2011 18:08:55 +0200 Subject: [master] 52ef567 Almost complete reimplementation of the internals of bans. Message-ID: commit 52ef567657c2e881a85a968c341465f32f9c3f48 Author: Poul-Henning Kamp Date: Sat May 14 16:08:44 2011 +0000 Almost complete reimplementation of the internals of bans. -spersistent changed the requirements a fair bit, and amongst other things introduced a ban timestamp as a unique identifier of a ban, and the need to save and reinstate a ban. The way this was implemented somewhat less than elegant, but we had little choice due to the way regexps work, and amongst other horrors it involved too much parsing and quoting of bans as text strings. Since then we have switched to PCRE, which compiles regexps to a bytestream which can be saved offline, and this paved the way for this rewrite. Instead of a datastructure with a list of tests to be carried out, build a byte-string which encodes the same information, along with additional information (the uncompiled regexp) to allow the ban to be reconstructed for display in ban.list. Include the ban timestamp as the first 8 bytes of the ban specification, to eliminate obj->ban_t, saving 8 bytes per object. Additional polishing to be expected. diff --git a/bin/varnishd/Makefile.am b/bin/varnishd/Makefile.am index b6d78e7..0e0bc83 100644 --- a/bin/varnishd/Makefile.am +++ b/bin/varnishd/Makefile.am @@ -94,6 +94,7 @@ noinst_HEADERS = \ vparam.h varnishd_CFLAGS = \ + @PCRE_CFLAGS@ \ -DVARNISH_STATE_DIR='"${VARNISH_STATE_DIR}"' \ -DVARNISH_VMOD_DIR='"${pkglibdir}/vmods"' \ -DVARNISH_VCL_DIR='"${varnishconfdir}"' @@ -106,6 +107,7 @@ varnishd_LDADD = \ $(top_builddir)/lib/libvcl/libvcl.la \ $(top_builddir)/lib/libvgz/libvgz.la \ @JEMALLOC_LDADD@ \ + @PCRE_LIBS@ \ ${DL_LIBS} ${PTHREAD_LIBS} ${NET_LIBS} ${LIBM} ${LIBUMEM} EXTRA_DIST = default.vcl diff --git a/bin/varnishd/cache.h b/bin/varnishd/cache.h index 75ce56d..2d75137 100644 --- a/bin/varnishd/cache.h +++ b/bin/varnishd/cache.h @@ -480,7 +480,6 @@ struct object { struct ws ws_o[1]; unsigned char *vary; - double ban_t; unsigned response; /* XXX: make bitmap */ @@ -649,14 +648,15 @@ int BAN_AddTest(struct cli *, struct ban *, const char *, const char *, void BAN_Free(struct ban *b); void BAN_Insert(struct ban *b); void BAN_Init(void); -void BAN_NewObj(struct object *o); +void BAN_NewObjCore(struct objcore *oc); void BAN_DestroyObj(struct objcore *oc); int BAN_CheckObject(struct object *o, const struct sess *sp); -void BAN_Reload(double t0, unsigned flags, const char *ban); +void BAN_Reload(const uint8_t *ban, unsigned len); struct ban *BAN_TailRef(void); void BAN_Compile(void); struct ban *BAN_RefBan(struct objcore *oc, double t0, const struct ban *tail); void BAN_TailDeref(struct ban **ban); +double BAN_Time(const struct ban *ban); /* cache_center.c [CNT] */ void CNT_Session(struct sess *sp); @@ -931,7 +931,7 @@ void SMS_Finish(struct object *obj); /* storage_persistent.c */ void SMP_Init(void); void SMP_Ready(void); -void SMP_NewBan(double t0, const char *ban); +void SMP_NewBan(const uint8_t *ban, unsigned len); /* * A normal pointer difference is signed, but we never want a negative value diff --git a/bin/varnishd/cache_ban.c b/bin/varnishd/cache_ban.c index becfd4e..3c58afd 100644 --- a/bin/varnishd/cache_ban.c +++ b/bin/varnishd/cache_ban.c @@ -48,61 +48,69 @@ #include #include +#include + #include "cli.h" +#include "vend.h" #include "cli_priv.h" #include "cache.h" #include "hash_slinger.h" -#include "vre.h" - -struct ban_test; - -/* A ban-testing function */ -typedef int ban_cond_f(const struct ban_test *bt, const struct object *o, - const struct sess *sp); - -/* Each individual test to be performed on a ban */ -struct ban_test { - unsigned magic; -#define BAN_TEST_MAGIC 0x54feec67 - VTAILQ_ENTRY(ban_test) list; - ban_cond_f *func; - int flags; -#define BAN_T_REGEXP (1 << 0) -#define BAN_T_NOT (1 << 1) - vre_t *re; - char *dst; - char *src; -}; struct ban { unsigned magic; #define BAN_MAGIC 0x700b08ea VTAILQ_ENTRY(ban) list; unsigned refcount; - int flags; + unsigned flags; #define BAN_F_GONE (1 << 0) -#define BAN_F_PENDING (1 << 1) #define BAN_F_REQ (1 << 2) - VTAILQ_HEAD(,ban_test) tests; VTAILQ_HEAD(,objcore) objcore; - double t0; struct vsb *vsb; - char *test; + uint8_t *spec; }; static VTAILQ_HEAD(banhead_s,ban) ban_head = VTAILQ_HEAD_INITIALIZER(ban_head); static struct lock ban_mtx; static struct ban *ban_magic; static pthread_t ban_thread; +static struct ban * volatile ban_start; + +/*-------------------------------------------------------------------- + * Variables we can purge on + */ + +static const struct pvar { + const char *name; + unsigned flag; +} pvars[] = { +#define PVAR(a, b, c) { (a), (b) }, +#include "ban_vars.h" +#undef PVAR + { 0, 0} +}; /*-------------------------------------------------------------------- - * Manipulation of bans + * BAN string magic markers + */ + +#define BAN_OPER_EQ 0x10 +#define BAN_OPER_NEQ 0x11 +#define BAN_OPER_MATCH 0x12 +#define BAN_OPER_NMATCH 0x13 + +#define BAN_ARG_URL 0x18 +#define BAN_ARG_REQHTTP 0x19 +#define BAN_ARG_OBJHTTP 0x1a + +/*-------------------------------------------------------------------- + * Storage handling of bans */ struct ban * BAN_New(void) { struct ban *b; + ALLOC_OBJ(b, BAN_MAGIC); if (b == NULL) return (b); @@ -111,28 +119,13 @@ BAN_New(void) FREE_OBJ(b); return (NULL); } - VTAILQ_INIT(&b->tests); VTAILQ_INIT(&b->objcore); return (b); } -static struct ban_test * -ban_add_test(struct ban *b) -{ - struct ban_test *bt; - - CHECK_OBJ_NOTNULL(b, BAN_MAGIC); - ALLOC_OBJ(bt, BAN_TEST_MAGIC); - if (bt == NULL) - return (bt); - VTAILQ_INSERT_TAIL(&b->tests, bt, list); - return (bt); -} - void BAN_Free(struct ban *b) { - struct ban_test *bt; CHECK_OBJ_NOTNULL(b, BAN_MAGIC); AZ(b->refcount); @@ -140,77 +133,125 @@ BAN_Free(struct ban *b) if (b->vsb != NULL) vsb_delete(b->vsb); - if (b->test != NULL) - free(b->test); - while (!VTAILQ_EMPTY(&b->tests)) { - bt = VTAILQ_FIRST(&b->tests); - VTAILQ_REMOVE(&b->tests, bt, list); - if (bt->flags & BAN_T_REGEXP) - VRE_free(&bt->re); - if (bt->dst != NULL) - free(bt->dst); - if (bt->src != NULL) - free(bt->src); - FREE_OBJ(bt); - } + if (b->spec != NULL) + free(b->spec); FREE_OBJ(b); } +static struct ban * +ban_CheckLast(void) +{ + struct ban *b; + + Lck_AssertHeld(&ban_mtx); + b = VTAILQ_LAST(&ban_head, banhead_s); + if (b != VTAILQ_FIRST(&ban_head) && b->refcount == 0) { + VSC_main->n_ban--; + VSC_main->n_ban_retire++; + VTAILQ_REMOVE(&ban_head, b, list); + } else { + b = NULL; + } + return (b); +} + /*-------------------------------------------------------------------- - * Test functions -- return 0 if the test matches + * Get & Release a tail reference, used to hold the list stable while + * persistent storage loads. */ -static int -ban_cond_str(const struct ban_test *bt, const char *p) +struct ban * +BAN_TailRef(void) { - int i; + struct ban *b; - if (p == NULL) - return(!(bt->flags & BAN_T_NOT)); - if (bt->flags & BAN_T_REGEXP) { - i = VRE_exec(bt->re, p, strlen(p), 0, 0, NULL, 0); - if (i >= 0) - i = 0; - } else { - i = strcmp(bt->dst, p); - } - if (bt->flags & BAN_T_NOT) - return (!i); - return (i); + ASSERT_CLI(); + Lck_Lock(&ban_mtx); + b = VTAILQ_LAST(&ban_head, banhead_s); + AN(b); + b->refcount++; + Lck_Unlock(&ban_mtx); + return (b); } -static int -ban_cond_url(const struct ban_test *bt, const struct object *o, - const struct sess *sp) +void +BAN_TailDeref(struct ban **bb) { - (void)o; + struct ban *b; - CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); - return(ban_cond_str(bt, sp->http->hd[HTTP_HDR_URL].b)); + b = *bb; + *bb = NULL; + Lck_Lock(&ban_mtx); + b->refcount--; + Lck_Unlock(&ban_mtx); } -static int -ban_cond_req_http(const struct ban_test *bt, const struct object *o, - const struct sess *sp) +/*-------------------------------------------------------------------- + * Extract time and length from ban-spec + */ + +static double +ban_time(const uint8_t *banspec) { - char *s; + double t; - (void)o; - CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); - (void)http_GetHdr(sp->http, bt->src, &s); - return (ban_cond_str(bt, s)); + assert(sizeof t == 8); + memcpy(&t, banspec, sizeof t); + return (t); } -static int -ban_cond_obj_http(const struct ban_test *bt, const struct object *o, - const struct sess *sp) +static unsigned +ban_len(const uint8_t *banspec) { - char *s; + unsigned u; - (void)sp; - CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); - (void)http_GetHdr(o->http, bt->src, &s); - return (ban_cond_str(bt, s)); + u = vbe32dec(banspec + 8); + return (u); +} + +/*-------------------------------------------------------------------- + * Access a lump of bytes in a ban test spec + */ + +static void +ban_add_lump(const struct ban *b, const void *p, uint32_t len) +{ + uint8_t buf[sizeof len]; + + vbe32enc(buf, len); + vsb_bcat(b->vsb, buf, sizeof buf); + vsb_bcat(b->vsb, p, len); +} + +static const void * +ban_get_lump(const uint8_t **bs) +{ + void *r; + unsigned ln; + + ln = vbe32dec(*bs); + *bs += 4; + r = (void*)*bs; + *bs += ln; + return (r); +} + +/*-------------------------------------------------------------------- + * Parse and add a http argument specification + * Output something which HTTP_GetHdr understands + */ + +static void +ban_parse_http(const struct ban *b, const char *a1) +{ + int l; + + l = strlen(a1) + 1; + assert(l <= 127); + vsb_putc(b->vsb, (char)l); + vsb_cat(b->vsb, a1); + vsb_putc(b->vsb, ':'); + vsb_putc(b->vsb, '\0'); } /*-------------------------------------------------------------------- @@ -218,138 +259,126 @@ ban_cond_obj_http(const struct ban_test *bt, const struct object *o, */ static int -ban_parse_regexp(struct cli *cli, struct ban_test *bt, const char *a3) +ban_parse_regexp(struct cli *cli, const struct ban *b, const char *a3) { const char *error; - int erroroffset; + int erroroffset, rc, sz; + pcre *re; - bt->re = VRE_compile(a3, 0, &error, &erroroffset); - if (bt->re == NULL) { + re = pcre_compile(a3, 0, &error, &erroroffset, NULL); + if (re == NULL) { VSL(SLT_Debug, 0, "REGEX: <%s>", error); cli_out(cli, "%s", error); cli_result(cli, CLIS_PARAM); return (-1); } - bt->flags |= BAN_T_REGEXP; + rc = pcre_fullinfo(re, NULL, PCRE_INFO_SIZE, &sz); + AZ(rc); + ban_add_lump(b, re, sz); return (0); } -static void -ban_parse_http(struct ban_test *bt, const char *a1) -{ - int l; - - l = strlen(a1); - assert(l < 127); - bt->src = malloc(l + 3L); - XXXAN(bt->src); - bt->src[0] = (char)l + 1; - memcpy(bt->src + 1, a1, l); - bt->src[l + 1] = ':'; - bt->src[l + 2] = '\0'; -} - -static const struct pvar { - const char *name; - unsigned flag; - ban_cond_f *func; -} pvars[] = { -#define PVAR(a, b, c) { (a), (b), (c) }, -#include "ban_vars.h" -#undef PVAR - { 0, 0, 0} -}; +/*-------------------------------------------------------------------- + * Add a (and'ed) test-condition to a ban + */ int BAN_AddTest(struct cli *cli, struct ban *b, const char *a1, const char *a2, const char *a3) { - struct ban_test *bt; const struct pvar *pv; int i; CHECK_OBJ_NOTNULL(b, BAN_MAGIC); - if (!VTAILQ_EMPTY(&b->tests)) - vsb_cat(b->vsb, " && "); - bt = ban_add_test(b); - if (bt == NULL) { - cli_out(cli, "Out of Memory"); - cli_result(cli, CLIS_CANT); + + for (pv = pvars; pv->name != NULL; pv++) + if (!strncmp(a1, pv->name, strlen(pv->name))) + break; + if (pv->name == NULL) { + cli_out(cli, "unknown or unsupported field \"%s\"", a1); + cli_result(cli, CLIS_PARAM); return (-1); } + if (pv->flag & PVAR_REQ) + b->flags |= BAN_F_REQ; + + if (pv->flag == PVAR_REQ) { + vsb_putc(b->vsb, BAN_ARG_URL); + } else if (pv->flag == (PVAR_REQ|PVAR_HTTP)) { + vsb_putc(b->vsb, BAN_ARG_REQHTTP); + ban_parse_http(b, a1 + strlen(pv->name)); + } else if (pv->flag == PVAR_HTTP) { + vsb_putc(b->vsb, BAN_ARG_OBJHTTP); + ban_parse_http(b, a1 + strlen(pv->name)); + } else { + INCOMPL(); + } + if (!strcmp(a2, "~")) { - i = ban_parse_regexp(cli, bt, a3); + vsb_putc(b->vsb, BAN_OPER_MATCH); + ban_add_lump(b, a3, strlen(a3) + 1); + i = ban_parse_regexp(cli, b, a3); if (i) return (i); } else if (!strcmp(a2, "!~")) { - bt->flags |= BAN_T_NOT; - i = ban_parse_regexp(cli, bt, a3); + vsb_putc(b->vsb, BAN_OPER_NMATCH); + ban_add_lump(b, a3, strlen(a3) + 1); + i = ban_parse_regexp(cli, b, a3); if (i) return (i); } else if (!strcmp(a2, "==")) { - bt->dst = strdup(a3); - XXXAN(bt->dst); + vsb_putc(b->vsb, BAN_OPER_EQ); + ban_add_lump(b, a3, strlen(a3) + 1); } else if (!strcmp(a2, "!=")) { - bt->flags |= BAN_T_NOT; - bt->dst = strdup(a3); - XXXAN(bt->dst); + vsb_putc(b->vsb, BAN_OPER_NEQ); + ban_add_lump(b, a3, strlen(a3) + 1); } else { cli_out(cli, "expected conditional (~, !~, == or !=) got \"%s\"", a2); cli_result(cli, CLIS_PARAM); return (-1); } - - - for (pv = pvars; pv->name != NULL; pv++) { - if (strncmp(a1, pv->name, strlen(pv->name))) - continue; - bt->func = pv->func; - if (pv->flag & PVAR_REQ) - b->flags |= BAN_F_REQ; - if (pv->flag & PVAR_HTTP) - ban_parse_http(bt, a1 + strlen(pv->name)); - break; - } - if (pv->name == NULL) { - cli_out(cli, "unknown or unsupported field \"%s\"", a1); - cli_result(cli, CLIS_PARAM); - return (-1); - } - - vsb_printf(b->vsb, "%s %s ", a1, a2); - vsb_quote(b->vsb, a3, -1, 0); return (0); } /*-------------------------------------------------------------------- - */ - - -/* * We maintain ban_start as a pointer to the first element of the list * as a separate variable from the VTAILQ, to avoid depending on the * internals of the VTAILQ macros. We tacitly assume that a pointer * write is always atomic in doing so. */ -static struct ban * volatile ban_start; void BAN_Insert(struct ban *b) { struct ban *bi, *be; unsigned pcount; + ssize_t ln; + double t0; CHECK_OBJ_NOTNULL(b, BAN_MAGIC); - b->t0 = TIM_real(); AZ(vsb_finish(b->vsb)); - b->test = strdup(vsb_data(b->vsb)); - AN(b->test); + ln = vsb_len(b->vsb); + assert(ln >= 0); + + b->spec = malloc(ln + 12L); /* XXX */ + XXXAN(b->spec); + + t0 = TIM_real(); + assert(sizeof t0 == 8); + memcpy(b->spec, &t0, sizeof t0); + + vbe32enc(b->spec + 8, ln + 12); + + memcpy(b->spec + 12, vsb_data(b->vsb), ln); + vsb_delete(b->vsb); b->vsb = NULL; + ln += 12; + Lck_Lock(&ban_mtx); VTAILQ_INSERT_HEAD(&ban_head, b, list); ban_start = b; @@ -362,7 +391,7 @@ BAN_Insert(struct ban *b) else be = NULL; - SMP_NewBan(b->t0, b->test); + SMP_NewBan(b->spec, ln); Lck_Unlock(&ban_mtx); if (be == NULL) @@ -375,7 +404,8 @@ BAN_Insert(struct ban *b) bi = VTAILQ_NEXT(bi, list); if (bi->flags & BAN_F_GONE) continue; - if (strcmp(b->test, bi->test)) + /* Safe because the length is part of the fixed size hdr */ + if (memcmp(b->spec + 8, bi->spec + 8, ln - 8)) continue; bi->flags |= BAN_F_GONE; pcount++; @@ -386,13 +416,14 @@ BAN_Insert(struct ban *b) Lck_Unlock(&ban_mtx); } +/*-------------------------------------------------------------------- + * A new object is created, grab a reference to the newest ban + */ + void -BAN_NewObj(struct object *o) +BAN_NewObjCore(struct objcore *oc) { - struct objcore *oc; - CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); - oc = o->objcore; CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); AZ(oc->ban); Lck_Lock(&ban_mtx); @@ -400,30 +431,11 @@ BAN_NewObj(struct object *o) ban_start->refcount++; VTAILQ_INSERT_TAIL(&ban_start->objcore, oc, ban_list); Lck_Unlock(&ban_mtx); - /* - * XXX Should this happen here or in stevedore.c ? - * XXX Or even at all ? -spersistent is only user - * XXX and has the field duplicated. - */ - o->ban_t = oc->ban->t0; } -static struct ban * -BAN_CheckLast(void) -{ - struct ban *b; - - Lck_AssertHeld(&ban_mtx); - b = VTAILQ_LAST(&ban_head, banhead_s); - if (b != VTAILQ_FIRST(&ban_head) && b->refcount == 0) { - VSC_main->n_ban--; - VSC_main->n_ban_retire++; - VTAILQ_REMOVE(&ban_head, b, list); - } else { - b = NULL; - } - return (b); -} +/*-------------------------------------------------------------------- + * An object is destroyed, release its ban reference + */ void BAN_DestroyObj(struct objcore *oc) @@ -441,19 +453,217 @@ BAN_DestroyObj(struct objcore *oc) oc->ban = NULL; /* Attempt to purge last ban entry */ - b = BAN_CheckLast(); + b = ban_CheckLast(); Lck_Unlock(&ban_mtx); if (b != NULL) BAN_Free(b); } +/*-------------------------------------------------------------------- + * Find and/or Grab a reference to an objects ban based on timestamp + * Assume we hold a TailRef, so list traversal is safe. + */ + +struct ban * +BAN_RefBan(struct objcore *oc, double t0, const struct ban *tail) +{ + struct ban *b; + double t1 = 0; + + VTAILQ_FOREACH(b, &ban_head, list) { + t1 = ban_time(b->spec); + if (t1 <= t0) + break; + if (b == tail) + break; + } + AN(b); + assert(t1 == t0); + Lck_Lock(&ban_mtx); + b->refcount++; + VTAILQ_INSERT_TAIL(&b->objcore, oc, ban_list); + Lck_Unlock(&ban_mtx); + return (b); +} + +/*-------------------------------------------------------------------- + * Put a skeleton ban in the list, unless there is an identical, + * time & condition, ban already in place. + * + * If a newer ban has same condition, mark the new ban GONE. + * mark any older bans, with the same condition, GONE as well. + */ + +void +BAN_Reload(const uint8_t *ban, unsigned len) +{ + struct ban *b, *b2; + int gone = 0; + double t0, t1, t2; + unsigned ln; + + ASSERT_CLI(); + + t0 = ban_time(ban); + ln = ban_len(ban); + assert(ln == len); + + t2 = 9e99; + VTAILQ_FOREACH(b, &ban_head, list) { + t1 = ban_time(b->spec); + assert (t1 < t2); + t2 = t1; + + if (!memcmp(b->spec + 8, ban + 8, ln - 8)) { + if (t1 == t0) + return; + if (t1 > t0) + gone |= BAN_F_GONE; + } + if (t1 < t0) + break; + } + + VSC_main->n_ban++; + VSC_main->n_ban_add++; + + b2 = BAN_New(); + AN(b2); + b2->spec = malloc(ln); + AN(b2->spec); + memcpy(b2->spec, ban, ln); + b2->flags |= gone; + if (b == NULL) + VTAILQ_INSERT_TAIL(&ban_head, b2, list); + else + VTAILQ_INSERT_BEFORE(b, b2, list); + + /* Hunt down older duplicates */ + for (b = VTAILQ_NEXT(b2, list); b != NULL; b = VTAILQ_NEXT(b, list)) { + if (b->flags & BAN_F_GONE) + continue; + if (!memcmp(b->spec + 8, ban + 8, ln - 8)) + b->flags |= BAN_F_GONE; + } + t2 = 9e99; + VTAILQ_FOREACH(b, &ban_head, list) { + t1 = ban_time(b->spec); + assert (t1 < t2); + t2 = t1; + } +} + +/*-------------------------------------------------------------------- + * Get a bans timestamp + */ + +double +BAN_Time(const struct ban *b) +{ + + if (b == NULL) + return (0.0); + + CHECK_OBJ_NOTNULL(b, BAN_MAGIC); + return (ban_time(b->spec)); +} + +/*-------------------------------------------------------------------- + * All silos have read their bans, ready for action + */ + +void +BAN_Compile(void) +{ + + ASSERT_CLI(); + + SMP_NewBan(ban_magic->spec, ban_len(ban_magic->spec)); + ban_start = VTAILQ_FIRST(&ban_head); +} + +/*-------------------------------------------------------------------- + * Evaluate ban-spec + */ + +static int +ban_evaluate(const uint8_t *bs, const struct http *objhttp, + const struct http *reqhttp, unsigned *tests) +{ + const uint8_t *be; + uint8_t op; + char *arg1; + const void *arg2; + int i; + + (void)objhttp; + (void)reqhttp; + + be = bs + ban_len(bs); + bs += 12; + while (bs < be) { + (*tests)++; + arg1 = NULL; + switch (*bs) { + case BAN_ARG_URL: + arg1 = reqhttp->hd[HTTP_HDR_URL].b; + bs++; + break; + case BAN_ARG_REQHTTP: + (void)http_GetHdr(reqhttp, + (const char *)(bs + 1), &arg1); + bs += bs[1] + 3; + break; + case BAN_ARG_OBJHTTP: + (void)http_GetHdr(objhttp, + (const char *)(bs + 1), &arg1); + bs += bs[1] + 3; + break; + default: + INCOMPL(); + } + op = *bs++; + + arg2 = ban_get_lump(&bs); + + if (op == BAN_OPER_EQ) { + if (arg1 == NULL || strcmp(arg1, arg2)) + return (0); + continue; + } else if (op == BAN_OPER_NEQ) { + if (arg1 != NULL && !strcmp(arg1, arg2)) + return (0); + continue; + } + + arg2 = ban_get_lump(&bs); + + if (op == BAN_OPER_MATCH) { + i = pcre_exec(arg2, NULL, arg1, strlen(arg1), + 0, 0, NULL, 0); + if (i < 0) + return (0); + } else if (op == BAN_OPER_NMATCH) { + i = pcre_exec(arg2, NULL, arg1, strlen(arg1), + 0, 0, NULL, 0); + if (i >= 0) + return (0); + } else { + INCOMPL(); + } + } + return (1); +} + +/*-------------------------------------------------------------------- + * Check an object any fresh bans + */ static int ban_check_object(struct object *o, const struct sess *sp, int has_req) { struct ban *b; struct objcore *oc; - struct ban_test *bt; struct ban * volatile b0; unsigned tests, skipped; @@ -486,14 +696,7 @@ ban_check_object(struct object *o, const struct sess *sp, int has_req) * be other bans that match, so we soldier on */ skipped++; - continue; - } - VTAILQ_FOREACH(bt, &b->tests, list) { - tests++; - if (bt->func(bt, o, sp)) - break; - } - if (bt == NULL) + } else if (ban_evaluate(b->spec, o->http, sp->http, &tests)) break; } @@ -518,7 +721,6 @@ ban_check_object(struct object *o, const struct sess *sp, int has_req) if (b == oc->ban) { /* not banned */ oc->ban = b0; - o->ban_t = oc->ban->t0; oc_updatemeta(oc); return (0); } else { @@ -558,7 +760,7 @@ ban_lurker_work(const struct sess *sp) Lck_Lock(&ban_mtx); /* First try to route the last ban */ - bf = BAN_CheckLast(); + bf = ban_CheckLast(); if (bf != NULL) { Lck_Unlock(&ban_mtx); BAN_Free(bf); @@ -636,151 +838,6 @@ ban_lurker(struct sess *sp, void *priv) } /*-------------------------------------------------------------------- - * Release a tail reference - */ - -void -BAN_TailDeref(struct ban **bb) -{ - struct ban *b; - - b = *bb; - *bb = NULL; - Lck_Lock(&ban_mtx); - b->refcount--; - Lck_Unlock(&ban_mtx); -} - -/*-------------------------------------------------------------------- - * Get a reference to the oldest ban in the list - */ - -struct ban * -BAN_TailRef(void) -{ - struct ban *b; - - ASSERT_CLI(); - b = VTAILQ_LAST(&ban_head, banhead_s); - AN(b); - b->refcount++; - return (b); -} - -/*-------------------------------------------------------------------- - * Find and/or Grab a reference to an objects ban based on timestamp - */ - -struct ban * -BAN_RefBan(struct objcore *oc, double t0, const struct ban *tail) -{ - struct ban *b; - - VTAILQ_FOREACH(b, &ban_head, list) { - if (b == tail) - break; - if (b->t0 <= t0) - break; - } - AN(b); - assert(b->t0 == t0); - Lck_Lock(&ban_mtx); - b->refcount++; - VTAILQ_INSERT_TAIL(&b->objcore, oc, ban_list); - Lck_Unlock(&ban_mtx); - return (b); -} - -/*-------------------------------------------------------------------- - * Put a skeleton ban in the list, unless there is an identical, - * time & condition, ban already in place. - * - * If a newer ban has same condition, mark the new ban GONE, and - * mark any older bans, with the same condition, GONE as well. - */ - -void -BAN_Reload(double t0, unsigned flags, const char *ban) -{ - struct ban *b, *b2; - int gone = 0; - - ASSERT_CLI(); - - (void)flags; /* for future use */ - - VTAILQ_FOREACH(b, &ban_head, list) { - if (!strcmp(b->test, ban)) { - if (b->t0 > t0) - gone |= BAN_F_GONE; - else if (b->t0 == t0) - return; - } else if (b->t0 > t0) - continue; - if (b->t0 < t0) - break; - } - - VSC_main->n_ban++; - VSC_main->n_ban_add++; - - b2 = BAN_New(); - AN(b2); - b2->test = strdup(ban); - AN(b2->test); - b2->t0 = t0; - b2->flags |= BAN_F_PENDING | gone; - if (b == NULL) - VTAILQ_INSERT_TAIL(&ban_head, b2, list); - else - VTAILQ_INSERT_BEFORE(b, b2, list); - - /* Hunt down older duplicates */ - for (b = VTAILQ_NEXT(b2, list); b != NULL; b = VTAILQ_NEXT(b, list)) { - if (b->flags & BAN_F_GONE) - continue; - if (!strcmp(b->test, b2->test)) - b->flags |= BAN_F_GONE; - } -} - -/*-------------------------------------------------------------------- - * All silos have read their bans, now compile them. - */ - -void -BAN_Compile(void) -{ - struct ban *b; - char **av; - int i; - - ASSERT_CLI(); - - SMP_NewBan(ban_magic->t0, ban_magic->test); - VTAILQ_FOREACH(b, &ban_head, list) { - if (!(b->flags & BAN_F_PENDING)) - continue; - b->flags &= ~BAN_F_PENDING; - if (b->flags & BAN_F_GONE) - continue; - av = ParseArgv(b->test, 0); - XXXAN(av); - XXXAZ(av[0]); - XXXAN(av[1]); - XXXAN(av[2]); - XXXAN(av[3]); - AZ(BAN_AddTest(NULL, b, av[1], av[2], av[3])); - for (i = 4; av[i] != NULL; i += 4) { - AZ(strcmp(av[i], "&&")); - AZ(BAN_AddTest(NULL, b, - av[i + 1], av[i + 2], av[i + 3])); - } - } - ban_start = VTAILQ_FIRST(&ban_head); -} - -/*-------------------------------------------------------------------- * CLI functions to add bans */ @@ -838,37 +895,79 @@ ccf_ban_url(struct cli *cli, const char * const *av, void *priv) } static void +ban_render(struct cli *cli, const uint8_t *bs) +{ + const uint8_t *be; + const void *arg2; + uint8_t op; + + be = bs + ban_len(bs); + bs += 12; + while (bs < be) { + switch (*bs) { + case BAN_ARG_URL: + cli_out(cli, "req.url"); + bs++; + break; + case BAN_ARG_REQHTTP: + cli_out(cli, "req.http.%.*s", bs[1] - 1, bs + 2); + bs += bs[1] + 3; + break; + case BAN_ARG_OBJHTTP: + cli_out(cli, "obj.http.%.*s", bs[1] - 1, bs + 2); + bs += bs[1] + 3; + break; + default: + INCOMPL(); + } + op = *bs++; + arg2 = ban_get_lump(&bs); + switch (op) { + case BAN_OPER_EQ: + cli_out(cli, " == "); + break; + case BAN_OPER_NEQ: + cli_out(cli, " != "); + break; + case BAN_OPER_MATCH: + cli_out(cli, " ~ "); + (void)ban_get_lump(&bs); + break; + case BAN_OPER_NMATCH: + cli_out(cli, " !~ "); + (void)ban_get_lump(&bs); + break; + default: + INCOMPL(); + } + cli_out(cli, "%s", arg2); + if (bs < be) + cli_out(cli, " && "); + } + cli_out(cli, "\n"); +} + +static void ccf_ban_list(struct cli *cli, const char * const *av, void *priv) { - struct ban *b, *bl = NULL; + struct ban *b, *bl; (void)av; (void)priv; - do { - /* Attempt to purge last ban entry */ - Lck_Lock(&ban_mtx); - b = BAN_CheckLast(); - bl = VTAILQ_LAST(&ban_head, banhead_s); - if (b == NULL) - bl->refcount++; - Lck_Unlock(&ban_mtx); - if (b != NULL) - BAN_Free(b); - } while (b != NULL); - AN(bl); + /* Get a reference so we are safe to traverse the list */ + bl = BAN_TailRef(); VTAILQ_FOREACH(b, &ban_head, list) { - // if (b->refcount == 0 && (b->flags & BAN_F_GONE)) - // continue; - cli_out(cli, "%p %10.6f %5u%s\t%s\n", b, b->t0, + if (b == bl) + break; + cli_out(cli, "%p %10.6f %5u%s\t", b, ban_time(b->spec), bl == b ? b->refcount - 1 : b->refcount, - b->flags & BAN_F_GONE ? "G" : " ", b->test); + b->flags & BAN_F_GONE ? "G" : " "); + ban_render(cli, b->spec); } - Lck_Lock(&ban_mtx); - bl->refcount--; - Lck_Unlock(&ban_mtx); + BAN_TailDeref(&bl); } static struct cli_proto ban_cmds[] = { diff --git a/bin/varnishd/stevedore.c b/bin/varnishd/stevedore.c index 5b3d94d..4feb189 100644 --- a/bin/varnishd/stevedore.c +++ b/bin/varnishd/stevedore.c @@ -257,7 +257,7 @@ STV_MkObject(struct sess *sp, void *ptr, unsigned ltot, o->objcore = sp->objcore; sp->objcore = NULL; /* refcnt follows pointer. */ - BAN_NewObj(o); + BAN_NewObjCore(o->objcore); o->objcore->methods = &default_oc_methods; o->objcore->priv = o; diff --git a/bin/varnishd/storage_persistent.c b/bin/varnishd/storage_persistent.c index c1d88de..dd43ba2 100644 --- a/bin/varnishd/storage_persistent.c +++ b/bin/varnishd/storage_persistent.c @@ -50,6 +50,7 @@ #include "vsha256.h" #include "cli.h" #include "cli_priv.h" +#include "vend.h" #include "persistent.h" #include "storage_persistent.h" @@ -67,8 +68,8 @@ static VTAILQ_HEAD(,smp_sc) silos = VTAILQ_HEAD_INITIALIZER(silos); */ static void -smp_appendban(struct smp_sc *sc, struct smp_signctx *ctx, double t0, - uint32_t flags, uint32_t len, const char *ban) +smp_appendban(struct smp_sc *sc, struct smp_signctx *ctx, + uint32_t len, const uint8_t *ban) { uint8_t *ptr, *ptr2; @@ -78,14 +79,8 @@ smp_appendban(struct smp_sc *sc, struct smp_signctx *ctx, double t0, memcpy(ptr, "BAN", 4); ptr += 4; - memcpy(ptr, &t0, sizeof t0); - ptr += sizeof t0; - - memcpy(ptr, &flags, sizeof flags); - ptr += sizeof flags; - - memcpy(ptr, &len, sizeof len); - ptr += sizeof len; + vbe32enc(ptr, len); + ptr += 4; memcpy(ptr, ban, len); ptr += len; @@ -96,14 +91,13 @@ smp_appendban(struct smp_sc *sc, struct smp_signctx *ctx, double t0, /* Trust that cache_ban.c takes care of locking */ void -SMP_NewBan(double t0, const char *ban) +SMP_NewBan(const uint8_t *ban, unsigned ln) { struct smp_sc *sc; - uint32_t l = strlen(ban) + 1; VTAILQ_FOREACH(sc, &silos, list) { - smp_appendban(sc, &sc->ban1, t0, 0, l, ban); - smp_appendban(sc, &sc->ban2, t0, 0, l, ban); + smp_appendban(sc, &sc->ban1, ln, ban); + smp_appendban(sc, &sc->ban2, ln, ban); } } @@ -115,8 +109,7 @@ static int smp_open_bans(struct smp_sc *sc, struct smp_signctx *ctx) { uint8_t *ptr, *pe; - double t0; - uint32_t flags, length; + uint32_t length; int i, retval = 0; ASSERT_CLI(); @@ -134,29 +127,15 @@ smp_open_bans(struct smp_sc *sc, struct smp_signctx *ctx) } ptr += 4; - memcpy(&t0, ptr, sizeof t0); - ptr += sizeof t0; - - memcpy(&flags, ptr, sizeof flags); - ptr += sizeof flags; - if (flags != 0) { - retval = 1002; - break; - } + length = vbe32dec(ptr); + ptr += 4; - memcpy(&length, ptr, sizeof length); - ptr += sizeof length; if (ptr + length > pe) { retval = 1003; break; } - if (ptr[length - 1] != '\0') { - retval = 1004; - break; - } - - BAN_Reload(t0, flags, (const char *)ptr); + BAN_Reload(ptr, length); ptr += length; } @@ -523,7 +502,7 @@ smp_allocobj(struct stevedore *stv, struct sess *sp, unsigned ltot, memcpy(so->hash, oc->objhead->digest, DIGEST_LEN); so->ttl = EXP_Grace(NULL, o); so->ptr = (uint8_t*)o - sc->base; - so->ban = o->ban_t; + so->ban = BAN_Time(oc->ban); smp_init_oc(oc, sg, objidx); diff --git a/bin/varnishd/storage_persistent_silo.c b/bin/varnishd/storage_persistent_silo.c index 18e6ea9..90b376f 100644 --- a/bin/varnishd/storage_persistent_silo.c +++ b/bin/varnishd/storage_persistent_silo.c @@ -463,11 +463,11 @@ smp_oc_updatemeta(struct objcore *oc) if (sg == sg->sc->cur_seg) { /* Lock necessary, we might race close_seg */ Lck_Lock(&sg->sc->mtx); - so->ban = o->ban_t; + so->ban = BAN_Time(oc->ban); so->ttl = mttl; Lck_Unlock(&sg->sc->mtx); } else { - so->ban = o->ban_t; + so->ban = BAN_Time(oc->ban); so->ttl = mttl; } } From phk at varnish-cache.org Sat May 14 17:53:33 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Sat, 14 May 2011 19:53:33 +0200 Subject: [master] 7c513b1 Polish the new BAN code Message-ID: commit 7c513b1033d5f6d15f4280e0bcc6d54344035670 Author: Poul-Henning Kamp Date: Sat May 14 17:53:18 2011 +0000 Polish the new BAN code diff --git a/bin/varnishd/cache_ban.c b/bin/varnishd/cache_ban.c index 3c58afd..3593490 100644 --- a/bin/varnishd/cache_ban.c +++ b/bin/varnishd/cache_ban.c @@ -69,6 +69,14 @@ struct ban { uint8_t *spec; }; +struct ban_test { + uint8_t arg1; + const char *arg1_spec; + uint8_t oper; + const char *arg2; + const void *arg2_spec; +}; + static VTAILQ_HEAD(banhead_s,ban) ban_head = VTAILQ_HEAD_INITIALIZER(ban_head); static struct lock ban_mtx; static struct ban *ban_magic; @@ -76,20 +84,6 @@ static pthread_t ban_thread; static struct ban * volatile ban_start; /*-------------------------------------------------------------------- - * Variables we can purge on - */ - -static const struct pvar { - const char *name; - unsigned flag; -} pvars[] = { -#define PVAR(a, b, c) { (a), (b) }, -#include "ban_vars.h" -#undef PVAR - { 0, 0} -}; - -/*-------------------------------------------------------------------- * BAN string magic markers */ @@ -103,6 +97,21 @@ static const struct pvar { #define BAN_ARG_OBJHTTP 0x1a /*-------------------------------------------------------------------- + * Variables we can purge on + */ + +static const struct pvar { + const char *name; + unsigned flag; + uint8_t tag; +} pvars[] = { +#define PVAR(a, b, c) { (a), (b), (c) }, +#include "ban_vars.h" +#undef PVAR + { 0, 0, 0} +}; + +/*-------------------------------------------------------------------- * Storage handling of bans */ @@ -156,8 +165,8 @@ ban_CheckLast(void) } /*-------------------------------------------------------------------- - * Get & Release a tail reference, used to hold the list stable while - * persistent storage loads. + * Get & Release a tail reference, used to hold the list stable for + * traversals etc. */ struct ban * @@ -237,6 +246,26 @@ ban_get_lump(const uint8_t **bs) } /*-------------------------------------------------------------------- + * Pick a test apart from a spec string + */ + +static void +ban_iter(const uint8_t **bs, struct ban_test *bt) +{ + + memset(bt, 0, sizeof *bt); + bt->arg1 = *(*bs)++; + if (bt->arg1 == BAN_ARG_REQHTTP || bt->arg1 == BAN_ARG_OBJHTTP) { + bt->arg1_spec = (char *)*bs; + (*bs) += (*bs)[0] + 2; + } + bt->arg2 = ban_get_lump(bs); + bt->oper = *(*bs)++; + if (bt->oper == BAN_OPER_MATCH || bt->oper == BAN_OPER_NMATCH) + bt->arg2_spec = ban_get_lump(bs); +} + +/*-------------------------------------------------------------------- * Parse and add a http argument specification * Output something which HTTP_GetHdr understands */ @@ -303,36 +332,25 @@ BAN_AddTest(struct cli *cli, struct ban *b, const char *a1, const char *a2, if (pv->flag & PVAR_REQ) b->flags |= BAN_F_REQ; - if (pv->flag == PVAR_REQ) { - vsb_putc(b->vsb, BAN_ARG_URL); - } else if (pv->flag == (PVAR_REQ|PVAR_HTTP)) { - vsb_putc(b->vsb, BAN_ARG_REQHTTP); + vsb_putc(b->vsb, pv->tag); + if (pv->flag & PVAR_HTTP) ban_parse_http(b, a1 + strlen(pv->name)); - } else if (pv->flag == PVAR_HTTP) { - vsb_putc(b->vsb, BAN_ARG_OBJHTTP); - ban_parse_http(b, a1 + strlen(pv->name)); - } else { - INCOMPL(); - } + ban_add_lump(b, a3, strlen(a3) + 1); if (!strcmp(a2, "~")) { vsb_putc(b->vsb, BAN_OPER_MATCH); - ban_add_lump(b, a3, strlen(a3) + 1); i = ban_parse_regexp(cli, b, a3); if (i) return (i); } else if (!strcmp(a2, "!~")) { vsb_putc(b->vsb, BAN_OPER_NMATCH); - ban_add_lump(b, a3, strlen(a3) + 1); i = ban_parse_regexp(cli, b, a3); if (i) return (i); } else if (!strcmp(a2, "==")) { vsb_putc(b->vsb, BAN_OPER_EQ); - ban_add_lump(b, a3, strlen(a3) + 1); } else if (!strcmp(a2, "!=")) { vsb_putc(b->vsb, BAN_OPER_NEQ); - ban_add_lump(b, a3, strlen(a3) + 1); } else { cli_out(cli, "expected conditional (~, !~, == or !=) got \"%s\"", a2); @@ -367,18 +385,16 @@ BAN_Insert(struct ban *b) XXXAN(b->spec); t0 = TIM_real(); - assert(sizeof t0 == 8); memcpy(b->spec, &t0, sizeof t0); vbe32enc(b->spec + 8, ln + 12); memcpy(b->spec + 12, vsb_data(b->vsb), ln); + ln += 12; vsb_delete(b->vsb); b->vsb = NULL; - ln += 12; - Lck_Lock(&ban_mtx); VTAILQ_INSERT_HEAD(&ban_head, b, list); ban_start = b; @@ -499,29 +515,22 @@ BAN_Reload(const uint8_t *ban, unsigned len) { struct ban *b, *b2; int gone = 0; - double t0, t1, t2; - unsigned ln; + double t0, t1, t2 = 9e99; ASSERT_CLI(); t0 = ban_time(ban); - ln = ban_len(ban); - assert(ln == len); - - t2 = 9e99; + assert(len == ban_len(ban)); VTAILQ_FOREACH(b, &ban_head, list) { t1 = ban_time(b->spec); assert (t1 < t2); t2 = t1; - - if (!memcmp(b->spec + 8, ban + 8, ln - 8)) { - if (t1 == t0) - return; - if (t1 > t0) - gone |= BAN_F_GONE; - } + if (t1 == t0) + return; if (t1 < t0) break; + if (!memcmp(b->spec + 8, ban + 8, len - 8)) + gone |= BAN_F_GONE; } VSC_main->n_ban++; @@ -529,9 +538,9 @@ BAN_Reload(const uint8_t *ban, unsigned len) b2 = BAN_New(); AN(b2); - b2->spec = malloc(ln); + b2->spec = malloc(len); AN(b2->spec); - memcpy(b2->spec, ban, ln); + memcpy(b2->spec, ban, len); b2->flags |= gone; if (b == NULL) VTAILQ_INSERT_TAIL(&ban_head, b2, list); @@ -542,15 +551,9 @@ BAN_Reload(const uint8_t *ban, unsigned len) for (b = VTAILQ_NEXT(b2, list); b != NULL; b = VTAILQ_NEXT(b, list)) { if (b->flags & BAN_F_GONE) continue; - if (!memcmp(b->spec + 8, ban + 8, ln - 8)) + if (!memcmp(b->spec + 8, ban + 8, len - 8)) b->flags |= BAN_F_GONE; } - t2 = 9e99; - VTAILQ_FOREACH(b, &ban_head, list) { - t1 = ban_time(b->spec); - assert (t1 < t2); - t2 = t1; - } } /*-------------------------------------------------------------------- @@ -578,6 +581,10 @@ BAN_Compile(void) ASSERT_CLI(); + /* + * XXX: we need to derive the BAN_F_REQ flag from all the + * XXX: all the loaded bans + */ SMP_NewBan(ban_magic->spec, ban_len(ban_magic->spec)); ban_start = VTAILQ_FIRST(&ban_head); } @@ -590,65 +597,52 @@ static int ban_evaluate(const uint8_t *bs, const struct http *objhttp, const struct http *reqhttp, unsigned *tests) { + struct ban_test bt; const uint8_t *be; - uint8_t op; char *arg1; - const void *arg2; - int i; - - (void)objhttp; - (void)reqhttp; be = bs + ban_len(bs); bs += 12; while (bs < be) { (*tests)++; + ban_iter(&bs, &bt); arg1 = NULL; - switch (*bs) { + switch (bt.arg1) { case BAN_ARG_URL: arg1 = reqhttp->hd[HTTP_HDR_URL].b; - bs++; break; case BAN_ARG_REQHTTP: - (void)http_GetHdr(reqhttp, - (const char *)(bs + 1), &arg1); - bs += bs[1] + 3; + (void)http_GetHdr(reqhttp, bt.arg1_spec, &arg1); break; case BAN_ARG_OBJHTTP: - (void)http_GetHdr(objhttp, - (const char *)(bs + 1), &arg1); - bs += bs[1] + 3; + (void)http_GetHdr(objhttp, bt.arg1_spec, &arg1); break; default: INCOMPL(); } - op = *bs++; - arg2 = ban_get_lump(&bs); - - if (op == BAN_OPER_EQ) { - if (arg1 == NULL || strcmp(arg1, arg2)) + switch (bt.oper) { + case BAN_OPER_EQ: + if (arg1 == NULL || strcmp(arg1, bt.arg2)) return (0); - continue; - } else if (op == BAN_OPER_NEQ) { - if (arg1 != NULL && !strcmp(arg1, arg2)) + break; + case BAN_OPER_NEQ: + if (arg1 != NULL && !strcmp(arg1, bt.arg2)) return (0); - continue; - } - - arg2 = ban_get_lump(&bs); - - if (op == BAN_OPER_MATCH) { - i = pcre_exec(arg2, NULL, arg1, strlen(arg1), - 0, 0, NULL, 0); - if (i < 0) + break; + case BAN_OPER_MATCH: + if (arg1 == NULL || + pcre_exec(bt.arg2_spec, NULL, arg1, strlen(arg1), + 0, 0, NULL, 0) < 0) return (0); - } else if (op == BAN_OPER_NMATCH) { - i = pcre_exec(arg2, NULL, arg1, strlen(arg1), - 0, 0, NULL, 0); - if (i >= 0) + break; + case BAN_OPER_NMATCH: + if (arg1 != NULL && + pcre_exec(bt.arg2_spec, NULL, arg1, strlen(arg1), + 0, 0, NULL, 0) >= 0) return (0); - } else { + break; + default: INCOMPL(); } } @@ -897,54 +891,40 @@ ccf_ban_url(struct cli *cli, const char * const *av, void *priv) static void ban_render(struct cli *cli, const uint8_t *bs) { + struct ban_test bt; const uint8_t *be; - const void *arg2; - uint8_t op; be = bs + ban_len(bs); bs += 12; while (bs < be) { - switch (*bs) { + ban_iter(&bs, &bt); + switch (bt.arg1) { case BAN_ARG_URL: cli_out(cli, "req.url"); - bs++; break; case BAN_ARG_REQHTTP: - cli_out(cli, "req.http.%.*s", bs[1] - 1, bs + 2); - bs += bs[1] + 3; + cli_out(cli, "req.http.%.*s", + bt.arg1_spec[0] - 1, bt.arg1_spec + 1); break; case BAN_ARG_OBJHTTP: - cli_out(cli, "obj.http.%.*s", bs[1] - 1, bs + 2); - bs += bs[1] + 3; + cli_out(cli, "obj.http.%.*s", + bt.arg1_spec[0] - 1, bt.arg1_spec + 1); break; default: INCOMPL(); } - op = *bs++; - arg2 = ban_get_lump(&bs); - switch (op) { - case BAN_OPER_EQ: - cli_out(cli, " == "); - break; - case BAN_OPER_NEQ: - cli_out(cli, " != "); - break; - case BAN_OPER_MATCH: - cli_out(cli, " ~ "); - (void)ban_get_lump(&bs); - break; - case BAN_OPER_NMATCH: - cli_out(cli, " !~ "); - (void)ban_get_lump(&bs); - break; + switch (bt.oper) { + case BAN_OPER_EQ: cli_out(cli, " == "); break; + case BAN_OPER_NEQ: cli_out(cli, " != "); break; + case BAN_OPER_MATCH: cli_out(cli, " ~ "); break; + case BAN_OPER_NMATCH: cli_out(cli, " !~ "); break; default: INCOMPL(); } - cli_out(cli, "%s", arg2); + cli_out(cli, "%s", bt.arg2); if (bs < be) cli_out(cli, " && "); } - cli_out(cli, "\n"); } static void @@ -965,6 +945,7 @@ ccf_ban_list(struct cli *cli, const char * const *av, void *priv) bl == b ? b->refcount - 1 : b->refcount, b->flags & BAN_F_GONE ? "G" : " "); ban_render(cli, b->spec); + cli_out(cli, "\n"); } BAN_TailDeref(&bl); diff --git a/include/ban_vars.h b/include/ban_vars.h index 2ba0930..df94d15 100644 --- a/include/ban_vars.h +++ b/include/ban_vars.h @@ -32,6 +32,6 @@ #define PVAR_HTTP 1 #define PVAR_REQ 2 -PVAR("req.url", PVAR_REQ, ban_cond_url) -PVAR("req.http.", PVAR_REQ|PVAR_HTTP, ban_cond_req_http) -PVAR("obj.http.", PVAR_HTTP, ban_cond_obj_http) +PVAR("req.url", PVAR_REQ, BAN_ARG_URL) +PVAR("req.http.", PVAR_REQ|PVAR_HTTP, BAN_ARG_REQHTTP) +PVAR("obj.http.", PVAR_HTTP, BAN_ARG_OBJHTTP) From phk at varnish-cache.org Sat May 14 19:24:36 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Sat, 14 May 2011 21:24:36 +0200 Subject: [master] 95d515f Silence a warning from pcre.h Message-ID: commit 95d515f41fef77316a0eac9af15f3e3d1d5827f8 Author: Poul-Henning Kamp Date: Sat May 14 19:23:49 2011 +0000 Silence a warning from pcre.h diff --git a/bin/varnishd/flint.lnt b/bin/varnishd/flint.lnt index 9d9a231..41ed4f9 100644 --- a/bin/varnishd/flint.lnt +++ b/bin/varnishd/flint.lnt @@ -76,6 +76,7 @@ -emacro(835, HTTPH) // Info 835: A zero has been given as left argument to operator '&' -emacro(845, HTTPH) // Info 845: The left argument to operator '&&' is certain to be 0 +-esym(773, PCRE_DATE) // Expression-like macro '___' not parenthesized ////////////// -efunc(1791, pdiff) // return last on line ////////////// From phk at varnish-cache.org Sat May 14 19:24:36 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Sat, 14 May 2011 21:24:36 +0200 Subject: [master] 7a3c8e2 Store the BAN_F_REQ flag in the encoded specification, so we can recover it when -spersistent reloads Message-ID: commit 7a3c8e2c4312830ffb840b695b1ccd32d2c1f070 Author: Poul-Henning Kamp Date: Sat May 14 19:24:08 2011 +0000 Store the BAN_F_REQ flag in the encoded specification, so we can recover it when -spersistent reloads diff --git a/bin/varnishd/cache_ban.c b/bin/varnishd/cache_ban.c index 3593490..31c6c78 100644 --- a/bin/varnishd/cache_ban.c +++ b/bin/varnishd/cache_ban.c @@ -381,16 +381,15 @@ BAN_Insert(struct ban *b) ln = vsb_len(b->vsb); assert(ln >= 0); - b->spec = malloc(ln + 12L); /* XXX */ + b->spec = malloc(ln + 13L); /* XXX */ XXXAN(b->spec); t0 = TIM_real(); memcpy(b->spec, &t0, sizeof t0); - - vbe32enc(b->spec + 8, ln + 12); - - memcpy(b->spec + 12, vsb_data(b->vsb), ln); - ln += 12; + b->spec[12] = (b->flags & BAN_F_REQ) ? 1 : 0; + memcpy(b->spec + 13, vsb_data(b->vsb), ln); + ln += 13; + vbe32enc(b->spec + 8, ln); vsb_delete(b->vsb); b->vsb = NULL; @@ -542,6 +541,8 @@ BAN_Reload(const uint8_t *ban, unsigned len) AN(b2->spec); memcpy(b2->spec, ban, len); b2->flags |= gone; + if (ban[12]) + b2->flags |= BAN_F_REQ; if (b == NULL) VTAILQ_INSERT_TAIL(&ban_head, b2, list); else @@ -581,10 +582,6 @@ BAN_Compile(void) ASSERT_CLI(); - /* - * XXX: we need to derive the BAN_F_REQ flag from all the - * XXX: all the loaded bans - */ SMP_NewBan(ban_magic->spec, ban_len(ban_magic->spec)); ban_start = VTAILQ_FIRST(&ban_head); } @@ -602,7 +599,7 @@ ban_evaluate(const uint8_t *bs, const struct http *objhttp, char *arg1; be = bs + ban_len(bs); - bs += 12; + bs += 13; while (bs < be) { (*tests)++; ban_iter(&bs, &bt); @@ -895,7 +892,7 @@ ban_render(struct cli *cli, const uint8_t *bs) const uint8_t *be; be = bs + ban_len(bs); - bs += 12; + bs += 13; while (bs < be) { ban_iter(&bs, &bt); switch (bt.arg1) { From phk at varnish-cache.org Mon May 16 07:42:47 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 16 May 2011 09:42:47 +0200 Subject: [master] 2cbaf86 Allow for functions which takes no arguments. Message-ID: commit 2cbaf866ed92846309742c7e4ef8878aef035212 Author: Poul-Henning Kamp Date: Mon May 16 07:42:27 2011 +0000 Allow for functions which takes no arguments. Spotted by: Martin diff --git a/lib/libvcl/vcc_expr.c b/lib/libvcl/vcc_expr.c index 14ddf0b..0839e8b 100644 --- a/lib/libvcl/vcc_expr.c +++ b/lib/libvcl/vcc_expr.c @@ -518,7 +518,7 @@ vcc_Eval_Var(struct vcc *tl, struct expr **e, const struct symbol *sym) void vcc_Eval_Func(struct vcc *tl, struct expr **e, const struct symbol *sym) { - const char *p, *q, *r; + const char *p, *r; struct expr *e1, *e2; enum var_type fmt; char buf[32]; @@ -529,8 +529,7 @@ vcc_Eval_Func(struct vcc *tl, struct expr **e, const struct symbol *sym) SkipToken(tl, ID); SkipToken(tl, '('); p = sym->args; - e2 = vcc_mk_expr(vcc_arg_type(&p), "%s(sp, \v+", sym->cfunc); - q = "\v1\n\v2"; + e2 = vcc_mk_expr(vcc_arg_type(&p), "%s(sp\v+", sym->cfunc); while (*p != '\0') { e1 = NULL; fmt = vcc_arg_type(&p); @@ -619,8 +618,7 @@ vcc_Eval_Func(struct vcc *tl, struct expr **e, const struct symbol *sym) if (*p != '\0') SkipToken(tl, ','); } - e2 = vcc_expr_edit(e2->fmt, q, e2, e1); - q = "\v1,\n\v2"; + e2 = vcc_expr_edit(e2->fmt, "\v1,\n\v2", e2, e1); } SkipToken(tl, ')'); e2 = vcc_expr_edit(e2->fmt, "\v1\n)\v-", e2, NULL); From phk at varnish-cache.org Mon May 16 09:21:55 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 16 May 2011 11:21:55 +0200 Subject: [master] 5698533 Build the CLI command we send to the child from av[] rather than rely on cli->cmd which is (by purpose) incomplete for here documents. Message-ID: commit 5698533c83b75d755f985e310a5a77a87112bd44 Author: Poul-Henning Kamp Date: Mon May 16 09:09:25 2011 +0000 Build the CLI command we send to the child from av[] rather than rely on cli->cmd which is (by purpose) incomplete for here documents. diff --git a/bin/varnishd/mgt_cli.c b/bin/varnishd/mgt_cli.c index aed41b1..4390866 100644 --- a/bin/varnishd/mgt_cli.c +++ b/bin/varnishd/mgt_cli.c @@ -156,6 +156,7 @@ mcf_askchild(struct cli *cli, const char * const *av, void *priv) int i; char *q; unsigned u; + struct vsb *vsb; (void)priv; /* @@ -174,21 +175,22 @@ mcf_askchild(struct cli *cli, const char * const *av, void *priv) "Type 'help' for more info."); return; } - AN(cli->cmd); - i = write(cli_o, cli->cmd, strlen(cli->cmd)); - if (i != strlen(cli->cmd)) { - cli_result(cli, CLIS_COMMS); - cli_out(cli, "CLI communication error"); - MGT_Child_Cli_Fail(); - return; + vsb = vsb_new_auto(); + for (i = 1; av[i] != NULL; i++) { + vsb_quote(vsb, av[i], strlen(av[i]), 0); + vsb_putc(vsb, ' '); } - i = write(cli_o, "\n", 1); - if (i != 1) { + vsb_putc(vsb, '\n'); + AZ(vsb_finish(vsb)); + i = write(cli_o, vsb_data(vsb), vsb_len(vsb)); + if (i != vsb_len(vsb)) { + vsb_delete(vsb); cli_result(cli, CLIS_COMMS); cli_out(cli, "CLI communication error"); MGT_Child_Cli_Fail(); return; } + vsb_delete(vsb); (void)cli_readres(cli_i, &u, &q, params->cli_timeout); cli_result(cli, u); cli_out(cli, "%s", q); From phk at varnish-cache.org Mon May 16 09:21:56 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 16 May 2011 11:21:56 +0200 Subject: [master] 8d15ec9 Give CLS_AddFd() an argument for initial authority for this CLI connection, the child needs it since we do not accept CLI here documents on unauthorized CLI connections. Message-ID: commit 8d15ec9f4ed5a3089fb287db20643b41051f657e Author: Poul-Henning Kamp Date: Mon May 16 09:20:33 2011 +0000 Give CLS_AddFd() an argument for initial authority for this CLI connection, the child needs it since we do not accept CLI here documents on unauthorized CLI connections. Make the mgr-child CLI connection authorized in the child so we accept CLI here documents. Add testcase for this. Fixes #917 diff --git a/bin/varnishd/cache_cli.c b/bin/varnishd/cache_cli.c index 0ea5ba7..9592b6e 100644 --- a/bin/varnishd/cache_cli.c +++ b/bin/varnishd/cache_cli.c @@ -107,7 +107,7 @@ CLI_Run(void) add_check = 1; - AN(CLS_AddFd(cls, heritage.cli_in, heritage.cli_out, NULL, NULL)); + AN(CLS_AddFd(cls, heritage.cli_in, heritage.cli_out, NULL, NULL, 1)); do { i = CLS_Poll(cls, -1); diff --git a/bin/varnishd/mgt_cli.c b/bin/varnishd/mgt_cli.c index 4390866..4b380e2 100644 --- a/bin/varnishd/mgt_cli.c +++ b/bin/varnishd/mgt_cli.c @@ -404,7 +404,7 @@ mgt_cli_setup(int fdi, int fdo, int verbose, const char *ident, mgt_cli_close_f if (cls == NULL) mgt_cli_init_cls(); - cli = CLS_AddFd(cls, fdi, fdo, closefunc, priv); + cli = CLS_AddFd(cls, fdi, fdo, closefunc, priv, MCF_NOAUTH); cli->ident = strdup(ident); diff --git a/bin/varnishtest/tests/r00917.vtc b/bin/varnishtest/tests/r00917.vtc new file mode 100644 index 0000000..6591079 --- /dev/null +++ b/bin/varnishtest/tests/r00917.vtc @@ -0,0 +1,24 @@ +varnishtest "test here documents for bans" + +server s1 { + rxreq + expect req.url == "/bar" + txresp -body "foobar" +} -start + +varnish v1 -vcl+backend { } -start + +client c1 { + txreq -url /bar + rxresp + expect resp.http.content-length == 6 +} -run + +varnish v1 -cliok {ban req.url ~ << foo +\.bar +foo +} + +varnish v1 -cliok ban.list + +varnish v1 -expect n_ban_add == 2 diff --git a/include/cli_serve.h b/include/cli_serve.h index d834b4d..0f5d047 100644 --- a/include/cli_serve.h +++ b/include/cli_serve.h @@ -32,7 +32,7 @@ typedef void cls_cb_f(void *priv); typedef void cls_cbc_f(const struct cli*); struct cls *CLS_New(cls_cbc_f *before, cls_cbc_f *after, unsigned maxlen); struct cli *CLS_AddFd(struct cls *cs, int fdi, int fdo, cls_cb_f *closefunc, - void *priv); + void *priv, unsigned auth); int CLS_AddFunc(struct cls *cs, unsigned auth, struct cli_proto *clp); int CLS_Poll(struct cls *cs, int timeout); int CLS_PollFd(struct cls *cs, int fd, int timeout); diff --git a/lib/libvarnish/cli_serve.c b/lib/libvarnish/cli_serve.c index a666654..36197b0 100644 --- a/lib/libvarnish/cli_serve.c +++ b/lib/libvarnish/cli_serve.c @@ -390,7 +390,8 @@ CLS_New(cls_cbc_f *before, cls_cbc_f *after, unsigned maxlen) } struct cli * -CLS_AddFd(struct cls *cs, int fdi, int fdo, cls_cb_f *closefunc, void *priv) +CLS_AddFd(struct cls *cs, int fdi, int fdo, cls_cb_f *closefunc, void *priv, + unsigned auth) { struct cls_fd *cfd; @@ -406,6 +407,7 @@ CLS_AddFd(struct cls *cs, int fdi, int fdo, cls_cb_f *closefunc, void *priv) cfd->cli->magic = CLI_MAGIC; cfd->cli->vlu = VLU_New(cfd, cls_vlu, cs->maxlen); cfd->cli->sb = vsb_new_auto(); + cfd->cli->auth = auth; cfd->closefunc = closefunc; cfd->priv = priv; AN(cfd->cli->sb); From phk at varnish-cache.org Mon May 16 09:39:16 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 16 May 2011 11:39:16 +0200 Subject: [master] 7ff31e9 Revert most of the last commit, we don't need to run the child CLI in authorized mode, since mgt_ask_child() does not send here CLI commands. Message-ID: commit 7ff31e985171e79f2971863b7fc9adf4b01dac3d Author: Poul-Henning Kamp Date: Mon May 16 09:38:23 2011 +0000 Revert most of the last commit, we don't need to run the child CLI in authorized mode, since mgt_ask_child() does not send here CLI commands. diff --git a/bin/varnishd/cache_cli.c b/bin/varnishd/cache_cli.c index 9592b6e..0ea5ba7 100644 --- a/bin/varnishd/cache_cli.c +++ b/bin/varnishd/cache_cli.c @@ -107,7 +107,7 @@ CLI_Run(void) add_check = 1; - AN(CLS_AddFd(cls, heritage.cli_in, heritage.cli_out, NULL, NULL, 1)); + AN(CLS_AddFd(cls, heritage.cli_in, heritage.cli_out, NULL, NULL)); do { i = CLS_Poll(cls, -1); diff --git a/bin/varnishd/mgt_cli.c b/bin/varnishd/mgt_cli.c index 4b380e2..4390866 100644 --- a/bin/varnishd/mgt_cli.c +++ b/bin/varnishd/mgt_cli.c @@ -404,7 +404,7 @@ mgt_cli_setup(int fdi, int fdo, int verbose, const char *ident, mgt_cli_close_f if (cls == NULL) mgt_cli_init_cls(); - cli = CLS_AddFd(cls, fdi, fdo, closefunc, priv, MCF_NOAUTH); + cli = CLS_AddFd(cls, fdi, fdo, closefunc, priv); cli->ident = strdup(ident); diff --git a/include/cli_serve.h b/include/cli_serve.h index 0f5d047..d834b4d 100644 --- a/include/cli_serve.h +++ b/include/cli_serve.h @@ -32,7 +32,7 @@ typedef void cls_cb_f(void *priv); typedef void cls_cbc_f(const struct cli*); struct cls *CLS_New(cls_cbc_f *before, cls_cbc_f *after, unsigned maxlen); struct cli *CLS_AddFd(struct cls *cs, int fdi, int fdo, cls_cb_f *closefunc, - void *priv, unsigned auth); + void *priv); int CLS_AddFunc(struct cls *cs, unsigned auth, struct cli_proto *clp); int CLS_Poll(struct cls *cs, int timeout); int CLS_PollFd(struct cls *cs, int fd, int timeout); diff --git a/lib/libvarnish/cli_serve.c b/lib/libvarnish/cli_serve.c index 36197b0..a666654 100644 --- a/lib/libvarnish/cli_serve.c +++ b/lib/libvarnish/cli_serve.c @@ -390,8 +390,7 @@ CLS_New(cls_cbc_f *before, cls_cbc_f *after, unsigned maxlen) } struct cli * -CLS_AddFd(struct cls *cs, int fdi, int fdo, cls_cb_f *closefunc, void *priv, - unsigned auth) +CLS_AddFd(struct cls *cs, int fdi, int fdo, cls_cb_f *closefunc, void *priv) { struct cls_fd *cfd; @@ -407,7 +406,6 @@ CLS_AddFd(struct cls *cs, int fdi, int fdo, cls_cb_f *closefunc, void *priv, cfd->cli->magic = CLI_MAGIC; cfd->cli->vlu = VLU_New(cfd, cls_vlu, cs->maxlen); cfd->cli->sb = vsb_new_auto(); - cfd->cli->auth = auth; cfd->closefunc = closefunc; cfd->priv = priv; AN(cfd->cli->sb); From phk at varnish-cache.org Mon May 16 11:05:56 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 16 May 2011 13:05:56 +0200 Subject: [master] 25228a2 VCL regexp and regsub should treat a NULL argument as an empty string. Message-ID: commit 25228a235b50c2e3b224a08473954bc99cf1d365 Author: Poul-Henning Kamp Date: Mon May 16 11:05:15 2011 +0000 VCL regexp and regsub should treat a NULL argument as an empty string. Fixes #913 diff --git a/bin/varnishd/cache_vrt_re.c b/bin/varnishd/cache_vrt_re.c index 97d657c..0ae09ae 100644 --- a/bin/varnishd/cache_vrt_re.c +++ b/bin/varnishd/cache_vrt_re.c @@ -70,7 +70,7 @@ VRT_re_match(const char *s, void *re) int i; if (s == NULL) - return (0); + s = ""; AN(re); t = re; i = VRE_exec(t, s, strlen(s), 0, 0, NULL, 0); @@ -94,7 +94,7 @@ VRT_regsub(const struct sess *sp, int all, const char *str, void *re, AN(re); if (str == NULL) - return (""); + str = ""; t = re; memset(ovector, 0, sizeof(ovector)); i = VRE_exec(t, str, strlen(str), 0, 0, ovector, 30); diff --git a/bin/varnishtest/tests/r00913.vtc b/bin/varnishtest/tests/r00913.vtc new file mode 100644 index 0000000..519436f --- /dev/null +++ b/bin/varnishtest/tests/r00913.vtc @@ -0,0 +1,22 @@ +varnishtest "test regsub(NULL)" + +server s1 { + rxreq + expect req.url == "/bar" + txresp -body "foobar" +} -start + +varnish v1 -vcl+backend { + sub vcl_fetch { + if (beresp.http.bar ~ "$") { + set beresp.http.foo = regsub(beresp.http.bar, "$", "XXX"); + } + } +} -start + +client c1 { + txreq -url /bar + rxresp + expect resp.http.content-length == 6 + expect resp.http.foo == "XXX" +} -run From kristian at varnish-cache.org Mon May 16 12:01:50 2011 From: kristian at varnish-cache.org (=?UTF-8?Q?Kristian_Lyngst=C3=B8l?=) Date: Mon, 16 May 2011 14:01:50 +0200 Subject: [master] 1d64806 Include stdint.h before vend.h Message-ID: commit 1d648067f31c7ea49a0bc21e4234f50e717cca59 Author: Kristian Lyngstol Date: Mon May 16 14:01:28 2011 +0200 Include stdint.h before vend.h Fixes build issues. diff --git a/bin/varnishd/cache_ban.c b/bin/varnishd/cache_ban.c index 31c6c78..35c687c 100644 --- a/bin/varnishd/cache_ban.c +++ b/bin/varnishd/cache_ban.c @@ -47,6 +47,7 @@ #include #include #include +#include #include From phk at varnish-cache.org Mon May 16 13:21:25 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 16 May 2011 15:21:25 +0200 Subject: [master] c4d7754 Correctly quote backslash, even if it is the only thing that needs quoting in the string. Message-ID: commit c4d7754730928c8fe66a206958de5a7b40b9a9ff Author: Poul-Henning Kamp Date: Mon May 16 13:20:58 2011 +0000 Correctly quote backslash, even if it is the only thing that needs quoting in the string. Fixes #900 diff --git a/lib/libvarnish/vsb.c b/lib/libvarnish/vsb.c index d3f044d..ac0c608 100644 --- a/lib/libvarnish/vsb.c +++ b/lib/libvarnish/vsb.c @@ -534,7 +534,7 @@ vsb_quote(struct vsb *s, const char *p, int len, int how) len = strlen(p); for (q = p; q < p + len; q++) { - if (!isgraph(*q) || *q == '"') { + if (!isgraph(*q) || *q == '"' || *q == '\\') { quote++; break; } From phk at varnish-cache.org Mon May 16 13:26:24 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 16 May 2011 15:26:24 +0200 Subject: [master] 3314353 Fix missing constification in cast. Message-ID: commit 3314353cdebfeab7397d2c1c57f0a21307cd2901 Author: Poul-Henning Kamp Date: Mon May 16 13:25:57 2011 +0000 Fix missing constification in cast. Spotted by: GCC Missed by: LLVM, FlexeLint diff --git a/bin/varnishd/cache_ban.c b/bin/varnishd/cache_ban.c index 35c687c..53073e9 100644 --- a/bin/varnishd/cache_ban.c +++ b/bin/varnishd/cache_ban.c @@ -236,12 +236,12 @@ ban_add_lump(const struct ban *b, const void *p, uint32_t len) static const void * ban_get_lump(const uint8_t **bs) { - void *r; + const void *r; unsigned ln; ln = vbe32dec(*bs); *bs += 4; - r = (void*)*bs; + r = (const void*)*bs; *bs += ln; return (r); } From phk at varnish-cache.org Mon May 16 13:35:02 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 16 May 2011 15:35:02 +0200 Subject: [master] 3e98f98 Another constification. Message-ID: commit 3e98f982533c2beea628aff1d2b2885842a02aa3 Author: Poul-Henning Kamp Date: Mon May 16 13:34:55 2011 +0000 Another constification. diff --git a/bin/varnishd/cache_ban.c b/bin/varnishd/cache_ban.c index 53073e9..1fa569a 100644 --- a/bin/varnishd/cache_ban.c +++ b/bin/varnishd/cache_ban.c @@ -257,7 +257,7 @@ ban_iter(const uint8_t **bs, struct ban_test *bt) memset(bt, 0, sizeof *bt); bt->arg1 = *(*bs)++; if (bt->arg1 == BAN_ARG_REQHTTP || bt->arg1 == BAN_ARG_OBJHTTP) { - bt->arg1_spec = (char *)*bs; + bt->arg1_spec = (const char *)*bs; (*bs) += (*bs)[0] + 2; } bt->arg2 = ban_get_lump(bs); From phk at varnish-cache.org Tue May 17 09:17:56 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 17 May 2011 11:17:56 +0200 Subject: [master] 4e00e65 Merge closer to FreeBSD's present sbuf version Message-ID: commit 4e00e65c36d4d469041f2e168aa6f75387ce55a3 Author: Poul-Henning Kamp Date: Tue May 17 09:17:41 2011 +0000 Merge closer to FreeBSD's present sbuf version diff --git a/include/vsb.h b/include/vsb.h index 5db06b9..e363a1f 100644 --- a/include/vsb.h +++ b/include/vsb.h @@ -25,7 +25,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $FreeBSD: head/sys/sys/sbuf.h 212425 2010-09-10 16:42:16Z mdf $ + * $FreeBSD: head/sys/sys/vsb.h 221993 2011-05-16 16:18:40Z phk $ */ #ifndef VSB_H_INCLUDED @@ -76,7 +76,7 @@ int vsb_printf(struct vsb *, const char *, ...) int vsb_vprintf(struct vsb *, const char *, va_list) __printflike(2, 0); #endif -int vsb_putc(struct vsb *, char); +int vsb_putc(struct vsb *, int); int vsb_trim(struct vsb *); int vsb_error(const struct vsb *); int vsb_finish(struct vsb *); diff --git a/lib/libvarnish/vsb.c b/lib/libvarnish/vsb.c index ac0c608..c5cdb07 100644 --- a/lib/libvarnish/vsb.c +++ b/lib/libvarnish/vsb.c @@ -24,7 +24,7 @@ * 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. -__FBSDID("$FreeBSD: head/sys/kern/subr_vsb.c 212750 2010-09-16 16:13:12Z mdf $ +__FBSDID("$FreeBSD: head/sys/kern/subr_vsb.c 222004 2011-05-17 06:36:32Z phk $") */ #include "config.h" @@ -62,6 +62,7 @@ __FBSDID("$FreeBSD: head/sys/kern/subr_vsb.c 212750 2010-09-16 16:13:12Z mdf $ #define VSB_CLEARFLAG(s, f) do { (s)->s_flags &= ~(f); } while (0) #define VSB_MINEXTENDSIZE 16 /* Should be power of 2. */ + #ifdef PAGE_SIZE #define VSB_MAXEXTENDSIZE PAGE_SIZE #define VSB_MAXEXTENDINCR PAGE_SIZE @@ -108,6 +109,12 @@ _assert_vsb_state(const char *fun, struct vsb *s, int state) #define assert_vsb_state(s, i) do { } while (0) #endif +#ifdef CTASSERT +CTASSERT(powerof2(VSB_MAXEXTENDSIZE)); +CTASSERT(powerof2(VSB_MAXEXTENDINCR)); +#endif + + static int vsb_extendsize(int size) { @@ -124,7 +131,6 @@ vsb_extendsize(int size) return (newsize); } - /* * Extend an vsb. */ @@ -164,8 +170,6 @@ vsb_newbuf(struct vsb *s, char *buf, int length, int flags) s->s_magic = VSB_MAGIC; if (buf != NULL) { - KASSERT(length > 0, - ("zero or negative length (%d)", length)); s->s_size = length; s->s_buf = buf; return (s); @@ -182,6 +186,8 @@ vsb_newbuf(struct vsb *s, char *buf, int length, int flags) /* * Initialize an vsb. + * If buf is non-NULL, it points to a static or already-allocated string + * big enough to hold at least length characters. */ struct vsb * vsb_new(struct vsb *s, char *buf, int length, int flags) @@ -234,9 +240,10 @@ vsb_setpos(struct vsb *s, ssize_t pos) assert_vsb_state(s, 0); KASSERT(pos >= 0, - ("attempt to seek to a negative position (%d)", pos)); + ("attempt to seek to a negative position (%jd)", (intmax_t)pos)); KASSERT(pos < s->s_size, - ("attempt to seek past end of vsb (%d >= %d)", pos, s->s_size)); + ("attempt to seek past end of vsb (%jd >= %jd)", + (intmax_t)pos, (intmax_t)->s_size)); if (pos < 0 || pos > s->s_len) return (-1); @@ -250,7 +257,7 @@ vsb_setpos(struct vsb *s, ssize_t pos) * buffer and marking overflow. */ static void -vsb_put_byte(struct vsb *s, char c) +vsb_put_byte(struct vsb *s, int c) { assert_vsb_integrity(s); @@ -264,10 +271,9 @@ vsb_put_byte(struct vsb *s, char c) if (s->s_error != 0) return; } - s->s_buf[s->s_len++] = c; + s->s_buf[s->s_len++] = (char)c; } - /* * Append a byte string to an vsb. */ @@ -357,6 +363,17 @@ vsb_vprintf(struct vsb *s, const char *fmt, va_list ap) if (s->s_error != 0) return (-1); + /* + * For the moment, there is no way to get vsnprintf(3) to hand + * back a character at a time, to push everything into + * vsb_putc_func() as was done for the kernel. + * + * In userspace, while drains are useful, there's generally + * not a problem attempting to malloc(3) on out of space. So + * expand a userland vsb if there is not enough room for the + * data produced by vsb_[v]printf(3). + */ + do { va_copy(ap_copy, ap); len = vsnprintf(&s->s_buf[s->s_len], VSB_FREESPACE(s) + 1, @@ -407,7 +424,7 @@ vsb_printf(struct vsb *s, const char *fmt, ...) * Append a character to an vsb. */ int -vsb_putc(struct vsb *s, char c) +vsb_putc(struct vsb *s, int c) { vsb_put_byte(s, c); From phk at varnish-cache.org Tue May 17 18:36:06 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 17 May 2011 20:36:06 +0200 Subject: [master] 8e58c80 Add vcl_init() and vcl_fini() methods which are called when a VCL after a vcl file is loaded and before it is discarded. Message-ID: commit 8e58c809758ad572eb16998b3c984ba6b996bd66 Author: Poul-Henning Kamp Date: Tue May 17 18:34:46 2011 +0000 Add vcl_init() and vcl_fini() methods which are called when a VCL after a vcl file is loaded and before it is discarded. The major use will probably be to tell VMODs things like filenames. Requested by: geoff & DocWilco diff --git a/bin/varnishd/cache_vcl.c b/bin/varnishd/cache_vcl.c index 0b25346..d2f74fc 100644 --- a/bin/varnishd/cache_vcl.c +++ b/bin/varnishd/cache_vcl.c @@ -172,12 +172,13 @@ VCL_Load(const char *fn, const char *name, struct cli *cli) } REPLACE(vcl->name, name); VTAILQ_INSERT_TAIL(&vcl_head, vcl, list); + cli_out(cli, "Loaded \"%s\" as \"%s\"", fn , name); + vcl->conf->init_vcl(cli); + (void)vcl->conf->init_func(NULL); Lck_Lock(&vcl_mtx); if (vcl_active == NULL) vcl_active = vcl; Lck_Unlock(&vcl_mtx); - cli_out(cli, "Loaded \"%s\" as \"%s\"", fn , name); - vcl->conf->init_func(cli); VSC_main->n_vcl++; VSC_main->n_vcl_avail++; return (0); @@ -197,7 +198,8 @@ VCL_Nuke(struct vcls *vcl) assert(vcl->conf->discard); assert(vcl->conf->busy == 0); VTAILQ_REMOVE(&vcl_head, vcl, list); - vcl->conf->fini_func(NULL); + (void)vcl->conf->fini_func(NULL); + vcl->conf->fini_vcl(NULL); free(vcl->name); (void)dlclose(vcl->dlh); FREE_OBJ(vcl); diff --git a/bin/varnishd/cache_vrt.c b/bin/varnishd/cache_vrt.c index 0d66435..4cb9e9c 100644 --- a/bin/varnishd/cache_vrt.c +++ b/bin/varnishd/cache_vrt.c @@ -71,6 +71,8 @@ void VRT_count(const struct sess *sp, unsigned u) { + if (sp == NULL) + return; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); if (params->vcl_trace) WSP(sp, SLT_VCL_trace, "%u %d.%d", u, @@ -240,6 +242,10 @@ void VRT_handling(struct sess *sp, unsigned hand) { + if (sp == NULL) { + assert(hand == VCL_RET_OK); + return; + } CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); assert(hand < VCL_RET_MAX); sp->handling = hand; diff --git a/bin/varnishd/default.vcl b/bin/varnishd/default.vcl index 3681ffe..59ed706 100644 --- a/bin/varnishd/default.vcl +++ b/bin/varnishd/default.vcl @@ -139,3 +139,11 @@ sub vcl_error { "}; return (deliver); } + +sub vcl_init { + return (ok); +} + +sub vcl_fini { + return (ok); +} diff --git a/lib/libvarnish/vsb.c b/lib/libvarnish/vsb.c index c5cdb07..1806416 100644 --- a/lib/libvarnish/vsb.c +++ b/lib/libvarnish/vsb.c @@ -166,17 +166,22 @@ vsb_newbuf(struct vsb *s, char *buf, int length, int flags) { memset(s, 0, sizeof(*s)); - s->s_flags = flags; s->s_magic = VSB_MAGIC; + s->s_flags = flags; + s->s_size = length; + s->s_buf = buf; - if (buf != NULL) { - s->s_size = length; - s->s_buf = buf; - return (s); + if ((s->s_flags & VSB_AUTOEXTEND) == 0) { + KASSERT(s->s_size > 1, + ("attempt to create a too small vsb")); } - s->s_size = length; + + if (s->s_buf != NULL) + return (s); + if ((flags & VSB_AUTOEXTEND) != 0) s->s_size = vsb_extendsize(s->s_size); + s->s_buf = SBMALLOC(s->s_size); if (s->s_buf == NULL) return (NULL); @@ -243,7 +248,7 @@ vsb_setpos(struct vsb *s, ssize_t pos) ("attempt to seek to a negative position (%jd)", (intmax_t)pos)); KASSERT(pos < s->s_size, ("attempt to seek past end of vsb (%jd >= %jd)", - (intmax_t)pos, (intmax_t)->s_size)); + (intmax_t)pos, (intmax_t)s->s_size)); if (pos < 0 || pos > s->s_len) return (-1); diff --git a/lib/libvcl/generate.py b/lib/libvcl/generate.py index 904fea1..15c1a51 100755 --- a/lib/libvcl/generate.py +++ b/lib/libvcl/generate.py @@ -92,6 +92,8 @@ returns =( ('fetch', ('error', 'restart', 'hit_for_pass', 'deliver',)), ('deliver', ('restart', 'deliver',)), ('error', ('restart', 'deliver',)), + ('init', ('ok',)), + ('fini', ('ok',)), ) ####################################################################### @@ -750,8 +752,8 @@ struct VCL_conf { const char **srcname; const char **srcbody; - vcl_init_f *init_func; - vcl_fini_f *fini_func; + vcl_init_f *init_vcl; + vcl_fini_f *fini_vcl; """) for i in returns: diff --git a/lib/libvcl/vcc_compile.c b/lib/libvcl/vcc_compile.c index 823b2a6..e9f85b9 100644 --- a/lib/libvcl/vcc_compile.c +++ b/lib/libvcl/vcc_compile.c @@ -366,8 +366,8 @@ EmitStruct(const struct vcc *tl) Fc(tl, 0, "\nconst struct VCL_conf VCL_conf = {\n"); Fc(tl, 0, "\t.magic = VCL_CONF_MAGIC,\n"); - Fc(tl, 0, "\t.init_func = VGC_Init,\n"); - Fc(tl, 0, "\t.fini_func = VGC_Fini,\n"); + Fc(tl, 0, "\t.init_vcl = VGC_Init,\n"); + Fc(tl, 0, "\t.fini_vcl = VGC_Fini,\n"); Fc(tl, 0, "\t.ndirector = %d,\n", tl->ndirector); Fc(tl, 0, "\t.director = directors,\n"); Fc(tl, 0, "\t.ref = VGC_ref,\n"); From phk at varnish-cache.org Tue May 17 19:43:30 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 17 May 2011 21:43:30 +0200 Subject: [master] 1752321 Make struct storage fields used onlyr for SENDFILE_WORKS conditional. Message-ID: commit 17523212895f272476ee7dc0823c5fdd5f8cabe7 Author: Poul-Henning Kamp Date: Tue May 17 19:42:59 2011 +0000 Make struct storage fields used onlyr for SENDFILE_WORKS conditional. Spotted by: sky diff --git a/bin/varnishd/cache.h b/bin/varnishd/cache.h index 2d75137..f7b9083 100644 --- a/bin/varnishd/cache.h +++ b/bin/varnishd/cache.h @@ -382,8 +382,10 @@ struct storage { unsigned len; unsigned space; +#ifdef SENDFILE_WORKS int fd; off_t where; +#endif }; /* Object core structure --------------------------------------------- diff --git a/bin/varnishd/storage_file.c b/bin/varnishd/storage_file.c index 63bcdf3..eca769a 100644 --- a/bin/varnishd/storage_file.c +++ b/bin/varnishd/storage_file.c @@ -487,8 +487,10 @@ smf_alloc(struct stevedore *st, size_t size) smf->s.ptr = smf->ptr; smf->s.len = 0; smf->s.stevedore = st; +#ifdef SENDFILE_WORKS smf->s.fd = smf->sc->fd; smf->s.where = smf->offset; +#endif return (&smf->s); } diff --git a/bin/varnishd/storage_malloc.c b/bin/varnishd/storage_malloc.c index 5cd6b84..18a9cbf 100644 --- a/bin/varnishd/storage_malloc.c +++ b/bin/varnishd/storage_malloc.c @@ -95,7 +95,9 @@ sma_alloc(struct stevedore *st, size_t size) } sma->s.len = 0; sma->s.space = size; +#ifdef SENDFILE_WORKS sma->s.fd = -1; +#endif sma->s.stevedore = st; sma->s.magic = STORAGE_MAGIC; return (&sma->s); diff --git a/bin/varnishd/storage_persistent.c b/bin/varnishd/storage_persistent.c index dd43ba2..6add1c7 100644 --- a/bin/varnishd/storage_persistent.c +++ b/bin/varnishd/storage_persistent.c @@ -450,7 +450,9 @@ smp_allocx(struct stevedore *st, size_t min_size, size_t max_size, ss->space = max_size; ss->priv = sc; ss->stevedore = st; +#ifdef SENDFILE_WORKS ss->fd = sc->fd; +#endif if (ssg != NULL) *ssg = sg; return (ss); diff --git a/bin/varnishd/storage_synth.c b/bin/varnishd/storage_synth.c index b70e609..f21158c 100644 --- a/bin/varnishd/storage_synth.c +++ b/bin/varnishd/storage_synth.c @@ -91,7 +91,9 @@ SMS_Makesynth(struct object *obj) sto->priv = vsb; sto->len = 0; sto->space = 0; +#ifdef SENDFILE_WORKS sto->fd = -1; +#endif sto->stevedore = &sms_stevedore; sto->magic = STORAGE_MAGIC; From phk at varnish-cache.org Tue May 17 20:08:01 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 17 May 2011 22:08:01 +0200 Subject: [master] 496a4d6 Rearrange struct storage a bit, to bring it down to 64 bytes for SENDFILE_WORKS 64-bit platforms. Message-ID: commit 496a4d6d1cbfbd5ff08482f4acbb681364df9e70 Author: Poul-Henning Kamp Date: Tue May 17 20:07:31 2011 +0000 Rearrange struct storage a bit, to bring it down to 64 bytes for SENDFILE_WORKS 64-bit platforms. diff --git a/bin/varnishd/cache.h b/bin/varnishd/cache.h index f7b9083..6a85ce6 100644 --- a/bin/varnishd/cache.h +++ b/bin/varnishd/cache.h @@ -374,6 +374,12 @@ struct workreq { struct storage { unsigned magic; #define STORAGE_MAGIC 0x1a4e51c0 + +#ifdef SENDFILE_WORKS + int fd; + off_t where; +#endif + VTAILQ_ENTRY(storage) list; struct stevedore *stevedore; void *priv; @@ -381,11 +387,6 @@ struct storage { unsigned char *ptr; unsigned len; unsigned space; - -#ifdef SENDFILE_WORKS - int fd; - off_t where; -#endif }; /* Object core structure --------------------------------------------- From phk at varnish-cache.org Wed May 18 07:37:28 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Wed, 18 May 2011 09:37:28 +0200 Subject: [master] 57ff148 Remove the hybrid VCL ban() syntax, it was only confusing everybody. Message-ID: commit 57ff1484fb46f70eac65f7eb64bb872eaa7c3cf8 Author: Poul-Henning Kamp Date: Wed May 18 07:37:01 2011 +0000 Remove the hybrid VCL ban() syntax, it was only confusing everybody. diff --git a/bin/varnishtest/tests/c00022.vtc b/bin/varnishtest/tests/c00022.vtc index 4097c65..ca64e59 100644 --- a/bin/varnishtest/tests/c00022.vtc +++ b/bin/varnishtest/tests/c00022.vtc @@ -21,7 +21,7 @@ server s1 { varnish v1 -vcl+backend { sub vcl_recv { if (req.request == "PURGE") { - ban (req.url == req.url); + ban ("req.url == " + req.url); error 410; } if (req.request == "PURGESTR") { @@ -31,26 +31,6 @@ varnish v1 -vcl+backend { } } -start -# Trigger syntax check -varnish v1 -badvcl { - backend foo { - .host = "127.0.0.1"; - } - sub vcl_recv { - ban (req.foo == req.url); - } -} - -# Trigger syntax check -varnish v1 -badvcl { - backend foo { - .host = "127.0.0.1"; - } - sub vcl_recv { - ban (req.http. == req.url); - } -} - # Fetch into cache client c1 { txreq -url "/foo" diff --git a/lib/libvcl/vcc_action.c b/lib/libvcl/vcc_action.c index fdb2c63..f90c3b9 100644 --- a/lib/libvcl/vcc_action.c +++ b/lib/libvcl/vcc_action.c @@ -176,84 +176,19 @@ parse_unset(struct vcc *tl) /*--------------------------------------------------------------------*/ -static const struct ban_var { - const char *name; - unsigned flag; -} ban_var[] = { -#define PVAR(a, b, c) { (a), (b) }, -#include "ban_vars.h" -#undef PVAR - { 0, 0 } -}; - static void parse_ban(struct vcc *tl) { - const struct ban_var *pv; vcc_NextToken(tl); ExpectErr(tl, '('); vcc_NextToken(tl); - if (tl->t->tok == ID) { - Fb(tl, 1, "VRT_ban(sp,\n"); - tl->indent += INDENT; - while (1) { - ExpectErr(tl, ID); - - /* Check valididity of ban variable */ - for (pv = ban_var; pv->name != NULL; pv++) { - if (!strncmp(pv->name, tl->t->b, - strlen(pv->name))) - break; - } - if (pv->name == NULL) { - vsb_printf(tl->sb, "Unknown ban variable."); - vcc_ErrWhere(tl, tl->t); - return; - } - if ((pv->flag & PVAR_HTTP) && - tl->t->b + strlen(pv->name) >= tl->t->e) { - vsb_printf(tl->sb, "Missing header name."); - vcc_ErrWhere(tl, tl->t); - return; - } - - Fb(tl, 1, " \"%.*s\",\n", PF(tl->t)); - vcc_NextToken(tl); - switch(tl->t->tok) { - case '~': - case T_NOMATCH: - case T_EQ: - case T_NEQ: - Fb(tl, 1, " \"%.*s\",\n", PF(tl->t)); - break; - default: - vsb_printf(tl->sb, - "Expected ~, !~, == or !=.\n"); - vcc_ErrWhere(tl, tl->t); - return; - } - vcc_NextToken(tl); - Fb(tl, 1, " "); - vcc_Expr(tl, STRING); - ERRCHK(tl); - Fb(tl, 0, ",\n"); - if (tl->t->tok == ')') - break; - ExpectErr(tl, T_CAND); - Fb(tl, 1, "\"%.*s\",\n", PF(tl->t)); - vcc_NextToken(tl); - } - Fb(tl, 1, "0);\n"); - tl->indent -= INDENT; - } else { - Fb(tl, 1, "VRT_ban_string(sp, "); - vcc_Expr(tl, STRING); - ERRCHK(tl); - Fb(tl, 0, ");\n"); - } + Fb(tl, 1, "VRT_ban_string(sp, "); + vcc_Expr(tl, STRING); + ERRCHK(tl); + Fb(tl, 0, ");\n"); ExpectErr(tl, ')'); vcc_NextToken(tl); From phk at varnish-cache.org Wed May 18 08:26:01 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Wed, 18 May 2011 10:26:01 +0200 Subject: [master] 4607e60 Give ParseArgv() and "int *argc" argument and a ARGV_NOESC flag Message-ID: commit 4607e6046ee3f1c429fc14820269a6627c3be48c Author: Poul-Henning Kamp Date: Wed May 18 08:25:29 2011 +0000 Give ParseArgv() and "int *argc" argument and a ARGV_NOESC flag diff --git a/bin/varnishd/cache_hash.c b/bin/varnishd/cache_hash.c index c25d0ab..14e3841 100644 --- a/bin/varnishd/cache_hash.c +++ b/bin/varnishd/cache_hash.c @@ -738,7 +738,7 @@ HSH_config(const char *h_arg) const struct hash_slinger *hp; ASSERT_MGT(); - av = ParseArgv(h_arg, ARGV_COMMA); + av = ParseArgv(h_arg, NULL, ARGV_COMMA); AN(av); if (av[0] != NULL) diff --git a/bin/varnishd/cache_vrt.c b/bin/varnishd/cache_vrt.c index 4cb9e9c..c20e243 100644 --- a/bin/varnishd/cache_vrt.c +++ b/bin/varnishd/cache_vrt.c @@ -467,7 +467,7 @@ VRT_ban_string(struct sess *sp, const char *str) int i; (void)sp; - av = ParseArgv(str, 0); + av = ParseArgv(str, NULL, 0); if (av[0] != NULL) { /* XXX: report error how ? */ FreeArgv(av); diff --git a/bin/varnishd/mgt_param.c b/bin/varnishd/mgt_param.c index 72e5939..7c2ccb1 100644 --- a/bin/varnishd/mgt_param.c +++ b/bin/varnishd/mgt_param.c @@ -354,7 +354,7 @@ tweak_listen_address(struct cli *cli, const struct parspec *par, return; } - av = ParseArgv(arg, ARGV_COMMA); + av = ParseArgv(arg, NULL, ARGV_COMMA); if (av == NULL) { cli_out(cli, "Parse error: out of memory"); cli_result(cli, CLIS_PARAM); diff --git a/bin/varnishd/mgt_shmem.c b/bin/varnishd/mgt_shmem.c index e0a371d..81e5a4e 100644 --- a/bin/varnishd/mgt_shmem.c +++ b/bin/varnishd/mgt_shmem.c @@ -206,7 +206,7 @@ mgt_SHM_Init(const char *l_arg) if (l_arg == NULL) l_arg = ""; - av = ParseArgv(l_arg, ARGV_COMMA); + av = ParseArgv(l_arg, NULL, ARGV_COMMA); AN(av); if (av[0] != NULL) ARGV_ERR("\t-l ...: %s", av[0]); diff --git a/bin/varnishd/stevedore.c b/bin/varnishd/stevedore.c index 4feb189..1a6cab1 100644 --- a/bin/varnishd/stevedore.c +++ b/bin/varnishd/stevedore.c @@ -438,9 +438,9 @@ STV_Config(const char *spec) p = strchr(spec, '='); q = strchr(spec, ','); if (p != NULL && (q == NULL || q > p)) { - av = ParseArgv(p + 1, ARGV_COMMA); + av = ParseArgv(p + 1, NULL, ARGV_COMMA); } else { - av = ParseArgv(spec, ARGV_COMMA); + av = ParseArgv(spec, NULL, ARGV_COMMA); p = NULL; } AN(av); diff --git a/bin/varnishd/varnishd.c b/bin/varnishd/varnishd.c index 32d97e8..5bcea1a 100644 --- a/bin/varnishd/varnishd.c +++ b/bin/varnishd/varnishd.c @@ -185,7 +185,7 @@ tackle_warg(const char *argv) char **av; unsigned int u; - av = ParseArgv(argv, ARGV_COMMA); + av = ParseArgv(argv, NULL, ARGV_COMMA); AN(av); if (av[0] != NULL) diff --git a/include/argv.h b/include/argv.h index d2ece25..0aa7cef 100644 --- a/include/argv.h +++ b/include/argv.h @@ -29,8 +29,9 @@ */ void FreeArgv(char **argv); -char **ParseArgv(const char *s, int flag); +char **ParseArgv(const char *s, int *argc, int flag); char *BackSlashDecode(const char *s, const char *e); int BackSlash(const char *s, char *res); #define ARGV_COMMENT (1 << 0) #define ARGV_COMMA (1 << 1) +#define ARGV_NOESC (1 << 2) diff --git a/lib/libvarnish/argv.c b/lib/libvarnish/argv.c index b2f4243..d8fefa2 100644 --- a/lib/libvarnish/argv.c +++ b/lib/libvarnish/argv.c @@ -131,7 +131,7 @@ static char err_invalid_backslash[] = "Invalid backslash sequence"; static char err_missing_quote[] = "Missing '\"'"; char ** -ParseArgv(const char *s, int flag) +ParseArgv(const char *s, int *argc, int flag) { char **argv; const char *p; @@ -162,7 +162,7 @@ ParseArgv(const char *s, int flag) quote = 0; } while (1) { - if (*s == '\\') { + if (*s == '\\' && !(flag & ARGV_NOESC)) { i = BackSlash(s, NULL); if (i == 0) { argv[0] = err_invalid_backslash; @@ -195,7 +195,9 @@ ParseArgv(const char *s, int flag) if (*s != '\0') s++; } - argv[nargv++] = NULL; + argv[nargv] = NULL; + if (argc != NULL) + *argc = nargv; return (argv); } diff --git a/lib/libvarnish/cli_serve.c b/lib/libvarnish/cli_serve.c index a666654..6306dff 100644 --- a/lib/libvarnish/cli_serve.c +++ b/lib/libvarnish/cli_serve.c @@ -323,7 +323,7 @@ cls_vlu(void *priv, const char *p) return (0); REPLACE(cli->cmd, p); - av = ParseArgv(p, 0); + av = ParseArgv(p, NULL, 0); AN(av); if (av[0] != NULL) { i = cls_vlu2(priv, av); diff --git a/lib/libvarnishapi/vsc.c b/lib/libvarnishapi/vsc.c index 5b870d5..d47584f 100644 --- a/lib/libvarnishapi/vsc.c +++ b/lib/libvarnishapi/vsc.c @@ -123,7 +123,7 @@ vsc_sf_arg(const struct VSM_data *vd, const char *opt) vsc->sf_init = 1; } - av = ParseArgv(opt, ARGV_COMMA); + av = ParseArgv(opt, NULL, ARGV_COMMA); AN(av); if (av[0] != NULL) { vd->diag(vd->priv, "Parse error: %s", av[0]); From phk at varnish-cache.org Wed May 18 09:38:17 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Wed, 18 May 2011 11:38:17 +0200 Subject: [master] 896c923 More comprehensive implementation of ARGV_NOESC Message-ID: commit 896c923fb270466ee910102240cf2f9e2e31994f Author: Poul-Henning Kamp Date: Wed May 18 09:37:23 2011 +0000 More comprehensive implementation of ARGV_NOESC diff --git a/lib/libvarnish/argv.c b/lib/libvarnish/argv.c index d8fefa2..7fbf95c 100644 --- a/lib/libvarnish/argv.c +++ b/lib/libvarnish/argv.c @@ -154,7 +154,7 @@ ParseArgv(const char *s, int *argc, int flag) } if ((flag & ARGV_COMMENT) && *s == '#') break; - if (*s == '"') { + if (*s == '"' && !(flag & ARGV_NOESC)) { p = ++s; quote = 1; } else { @@ -179,7 +179,7 @@ ParseArgv(const char *s, int *argc, int flag) s++; continue; } - if (*s == '"') + if (*s == '"' && !(flag & ARGV_NOESC)) break; if (*s == '\0') { argv[0] = err_missing_quote; @@ -191,7 +191,15 @@ ParseArgv(const char *s, int *argc, int flag) argv = realloc(argv, sizeof (*argv) * (largv += largv)); assert(argv != NULL); } - argv[nargv++] = BackSlashDecode(p, s); + if (flag & ARGV_NOESC) { + argv[nargv] = malloc(1 + (s - p)); + assert(argv[nargv] != NULL); + memcpy(argv[nargv], p, s - p); + argv[nargv][s - p] = '\0'; + nargv++; + } else { + argv[nargv++] = BackSlashDecode(p, s); + } if (*s != '\0') s++; } From phk at varnish-cache.org Wed May 18 09:38:17 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Wed, 18 May 2011 11:38:17 +0200 Subject: [master] dd4c1ed Don't interpret \ escapes in ban strings from vcl::ban() Message-ID: commit dd4c1ed0b7e25d088ab1f50ce3444f8d087eb31d Author: Poul-Henning Kamp Date: Wed May 18 09:37:36 2011 +0000 Don't interpret \ escapes in ban strings from vcl::ban() diff --git a/bin/varnishd/cache_vrt.c b/bin/varnishd/cache_vrt.c index c20e243..d66c66c 100644 --- a/bin/varnishd/cache_vrt.c +++ b/bin/varnishd/cache_vrt.c @@ -467,7 +467,7 @@ VRT_ban_string(struct sess *sp, const char *str) int i; (void)sp; - av = ParseArgv(str, NULL, 0); + av = ParseArgv(str, NULL, ARGV_NOESC); if (av[0] != NULL) { /* XXX: report error how ? */ FreeArgv(av); diff --git a/bin/varnishtest/tests/c00022.vtc b/bin/varnishtest/tests/c00022.vtc index ca64e59..33e20cc 100644 --- a/bin/varnishtest/tests/c00022.vtc +++ b/bin/varnishtest/tests/c00022.vtc @@ -93,7 +93,7 @@ client c1 { # Ban: it client c1 { - txreq -req PURGESTR -hdr "Ban: obj.http.foo == \"bar6\"" + txreq -req PURGESTR -hdr "Ban: obj.http.foo == bar6" rxresp expect resp.status == 410 } -run @@ -110,10 +110,11 @@ client c1 { # Ban: something else client c1 { - txreq -req PURGESTR -hdr "Ban: obj.http.foo == \"bar6\"" + txreq -req PURGESTR -hdr "Ban: obj.http.foo == bar6" rxresp expect resp.status == 410 } -run + varnish v1 -cliok "ban.list" # Still there @@ -127,7 +128,7 @@ client c1 { # Header match client c1 { - txreq -req PURGESTR -hdr "Ban: req.http.foo == \"barcheck\"" + txreq -req PURGESTR -hdr "Ban: req.http.foo == barcheck" rxresp expect resp.status == 410 } -run @@ -143,7 +144,7 @@ client c1 { # Header match client c1 { - txreq -req PURGESTR -hdr "Ban: obj.http.foo == \"barcheck\"" + txreq -req PURGESTR -hdr "Ban: obj.http.foo == barcheck" rxresp expect resp.status == 410 } -run From phk at varnish-cache.org Wed May 18 10:03:49 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Wed, 18 May 2011 12:03:49 +0200 Subject: [master] 28ece2a Try to make this test more stable under load. Message-ID: commit 28ece2a06e6c01620e1a8aaab248aa9f9990f5a3 Author: Poul-Henning Kamp Date: Wed May 18 10:03:35 2011 +0000 Try to make this test more stable under load. diff --git a/bin/varnishtest/tests/b00021.vtc b/bin/varnishtest/tests/b00021.vtc index 87d91e3..d46caa2 100644 --- a/bin/varnishtest/tests/b00021.vtc +++ b/bin/varnishtest/tests/b00021.vtc @@ -5,13 +5,13 @@ feature SO_RCVTIMEO_WORKS server s1 { rxreq send "HTTP/1.1 200 Ok\r\nConnection: close\r\n\r\n" - delay 1.5 + delay 4.0 send "Baba\n" } -start varnish v1 -vcl+backend { sub vcl_miss { - set bereq.between_bytes_timeout = 1s; + set bereq.between_bytes_timeout = 2s; } } -start @@ -24,14 +24,22 @@ client c1 { server s1 { rxreq send "HTTP/1.1 200 Ok\r\nConnection: close\r\n\r\n" - delay 0.5 + delay 1.0 send "Baba\n" - delay 0.5 + delay 1.0 + send "Baba\n" + delay 1.0 + send "Baba\n" + delay 1.0 + send "Baba\n" + delay 1.0 send "Baba\n" } -start client c1 { txreq + timeout 10 rxresp expect resp.status == 200 + expect resp.bodylen == 25 } -run From phk at varnish-cache.org Wed May 18 10:37:17 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Wed, 18 May 2011 12:37:17 +0200 Subject: [master] 5840a2a Break down and add a column with time since start so we can see where the timeouts happen etc. Message-ID: commit 5840a2a86843f9bafff1cdf8cdaef788a7a1eb73 Author: Poul-Henning Kamp Date: Wed May 18 10:36:45 2011 +0000 Break down and add a column with time since start so we can see where the timeouts happen etc. diff --git a/bin/varnishtest/vtc_log.c b/bin/varnishtest/vtc_log.c index 3d5a5ac..ebeb7df 100644 --- a/bin/varnishtest/vtc_log.c +++ b/bin/varnishtest/vtc_log.c @@ -55,6 +55,7 @@ struct vtclog { }; static pthread_key_t log_key; +static double t0; /**********************************************************************/ @@ -62,6 +63,7 @@ void vtc_loginit(char *buf, unsigned buflen) { + t0 = TIM_mono(); vtclog_buf = buf; vtclog_left = buflen; AZ(pthread_mutex_init(&vtclog_mtx, NULL)); @@ -126,12 +128,14 @@ vtc_log_emit(const struct vtclog *vl, unsigned lvl) void vtc_log(struct vtclog *vl, unsigned lvl, const char *fmt, ...) { + double tx; CHECK_OBJ_NOTNULL(vl, VTCLOG_MAGIC); + tx = TIM_mono() - t0; AZ(pthread_mutex_lock(&vl->mtx)); assert(lvl < NLEAD); vsb_clear(vl->vsb); - vsb_printf(vl->vsb, "%s %-4s ", lead[lvl], vl->id); + vsb_printf(vl->vsb, "%s %-4s %4.1f ", lead[lvl], vl->id, tx); va_list ap; va_start(ap, fmt); (void)vsb_vprintf(vl->vsb, fmt, ap); @@ -160,25 +164,18 @@ vtc_dump(struct vtclog *vl, unsigned lvl, const char *pfx, const char *str, int { int nl = 1; unsigned l; + double tx; CHECK_OBJ_NOTNULL(vl, VTCLOG_MAGIC); + tx = TIM_mono() - t0; assert(lvl < NLEAD); - if (0 && str != NULL && len > 0) { - for (l = 0; l < len; l++) { - if (str[l] & 0x80) { - vtc_hexdump(vl, lvl, pfx, - (const void*)str, len); - return; - } - } - } AZ(pthread_mutex_lock(&vl->mtx)); vsb_clear(vl->vsb); if (pfx == NULL) pfx = ""; if (str == NULL) - vsb_printf(vl->vsb, "%s %-4s %s(null)\n", - lead[lvl], vl->id, pfx); + vsb_printf(vl->vsb, "%s %-4s %4.1f %s(null)\n", + lead[lvl], vl->id, tx, pfx); else { if (len == -1) len = strlen(str); @@ -188,8 +185,8 @@ vtc_dump(struct vtclog *vl, unsigned lvl, const char *pfx, const char *str, int break; } if (nl) { - vsb_printf(vl->vsb, "%s %-4s %s| ", - lead[lvl], vl->id, pfx); + vsb_printf(vl->vsb, "%s %-4s %4.1f %s| ", + lead[lvl], vl->id, tx, pfx); nl = 0; } if (*str == '\r') From perbu at varnish-cache.org Fri May 20 09:12:11 2011 From: perbu at varnish-cache.org (Per Andreas Buer) Date: Fri, 20 May 2011 11:12:11 +0200 Subject: [master] 1cd4f0c explain the ban list Message-ID: commit 1cd4f0ceaf07ce5dd8e35e59a0510377759c87d2 Author: Per Buer Date: Thu May 19 12:36:45 2011 +0200 explain the ban list diff --git a/doc/sphinx/reference/varnish-cli.rst b/doc/sphinx/reference/varnish-cli.rst index 145f960..a52713e 100644 --- a/doc/sphinx/reference/varnish-cli.rst +++ b/doc/sphinx/reference/varnish-cli.rst @@ -106,8 +106,6 @@ ban *field operator argument* [&& field operator argument [...]] examples. ban.list - Display the ban list. - All requests for objects from the cache are matched against items on the ban list. If an object in the cache is older than a matching ban list item, it is considered "banned", and will be @@ -116,6 +114,28 @@ ban.list When a ban expression is older than all the objects in the cache, it is removed from the list. + ban.list displays the ban list. The output looks something like + this (broken into two lines): + + 0x7fea4fcb0580 1303835108.618863 131G req.http.host ~ + www.myhost.com && req.url ~ /some/url + + The first field is the address of the ban. + + The second is the time of entry into the list, given + as a high precision timestamp. + + The third field describes many objects point to this ban. When + an object is compared to a ban the object is marked with a + reference to the newest ban it was tested against. This isn't + really useful unless you're debugging. + + A "G" marks that the ban is "Gone". Meaning it has been marked + as a duplicate or it is no longer valid. It stays in the list + for effiency reasons. + + Then follows the actual ban it self. + ban.url regexp Immediately invalidate all documents whose URL matches the specified regular expression. Please note that the Host part of From perbu at varnish-cache.org Fri May 20 09:12:11 2011 From: perbu at varnish-cache.org (Per Andreas Buer) Date: Fri, 20 May 2011 11:12:11 +0200 Subject: [master] 7d7c8ab add ban and ban_url Message-ID: commit 7d7c8abdb2621da0d7174e5bfef43f5af452d29a Author: Per Buer Date: Thu May 19 12:37:44 2011 +0200 add ban and ban_url diff --git a/doc/sphinx/reference/vcl.rst b/doc/sphinx/reference/vcl.rst index 85553f4..8837142 100644 --- a/doc/sphinx/reference/vcl.rst +++ b/doc/sphinx/reference/vcl.rst @@ -323,8 +323,11 @@ regsub(str, regex, sub) regsuball(str, regex, sub) As regsuball() but this replaces all occurrences. -purge_url(regex) - Purge all objects in cache whose URLs match regex. +ban(ban expression) + Executes a ban. + +ban_url(regex) + Bans all objects in cache whose URLs match regex. Subroutines ~~~~~~~~~~~ From perbu at varnish-cache.org Fri May 20 09:12:11 2011 From: perbu at varnish-cache.org (Per Andreas Buer) Date: Fri, 20 May 2011 11:12:11 +0200 Subject: [master] 29d4914 document the std module Message-ID: commit 29d4914089c2a6c8122c305dcc79db5a21289758 Author: Per Buer Date: Fri May 20 11:07:39 2011 +0200 document the std module diff --git a/doc/sphinx/reference/vmod_std.rst b/doc/sphinx/reference/vmod_std.rst new file mode 100644 index 0000000..ca1c745 --- /dev/null +++ b/doc/sphinx/reference/vmod_std.rst @@ -0,0 +1,163 @@ +======== +vmod_std +======== + +----------------------- +Varnish Standard Module +----------------------- + +:Author: Per Buer +:Date: 2011-05-19 +:Version: 1.0 +:Manual section: 1 + + +SYNOPSIS +======== + +import std + +DESCRIPTION +=========== + +The Varnish standard module contains useful, generic function that +don't quite fit in the VCL core, but are still considered very useful +to a broad audience. + +FUNCTIONS +========= + +toupper +------- + +Prototype + toupper(STRING S) +Return value + String +Description + Converts the STRING S to upper case. +Example + set beresp.x-scream = std.toupper("yes!"); + +tolower +------- +Prototype + tolower(STRING S) +Return value + String +Description + Converts the STRING to lower case. +Example + set beresp.x-nice = std.tolower("VerY"); + +set_up_tos +---------- +Prototype + set_ip_tos(INT I) +Return value + Void +Description + Sets the Type-of-Service flag for the current session. Please + note that the TOS flag is not removed by the end of the + request so probably want to set it on every request should you + utilize it. +Example + | if (req.url ~ ^/slow/) { + | std.set_up_tos(0x0); + | } + +random +------ +Prototype + random(REAL a, REAL b) +Return value + Real +Description + Returns a random REAL number between *a* and *b*. +Example + set beresp.x-random-number = std.random(1, 100); + +log +--- +Prototype + log(STRING string) +Return value + Void +Description + Logs string to the shared memory log. +Example + std.log("Something fishy is going on with the vhost " + req.host); + +syslog +------ +Prototype + syslog(INT priority, STRING string) +Return value + Void +Description + Logs *string* to syslog marked with *priority*. +Example + std.syslog( LOG_USER|LOG_ALERT, "There is serious troble"); + +fileread +-------- +Prototype + fileread(STRING filename) +Return value + String +Description + Reads a file and returns a string with the content. Please + note that it is not recommended to send variables to this + function the caching in the function doesn't take this into + account. Also, files are not re-read. +Example + set beresp.http.x-served-by = std.fileread("/etc/hostname"); + +duration +-------- +Prototype + duration(STRING s, DURATION fallback) +Return value + Duration +Description + Converts the string s to seconds. s can be quantified with the + usual s (seconds), m (minutes), h (hours), d (days) and w + (weeks) units. If it fails to parse the string *fallback* + will be used +Example + set beresp.ttl = std.duration("1w", 3600); + +collect +------- +Prototype + collect(HEADER header) +Return value + Void +Description + Collapses the header, joining the headers into one. +Example + std.collect(req.http.cookie); + This will collapse several Cookie: headers into one, long + cookie header. + + +SEE ALSO +======== + +* vcl(7) +* varnishd(1) + +HISTORY +======= + +The Varnish standard module was released along with Varnish Cache 3.0. +This manual page was written by Per Buer with help from Martin Blix +Grydeland. + +COPYRIGHT +========= + +This document is licensed under the same licence as Varnish +itself. See LICENCE for details. + +* Copyright (c) 2011 Varnish Software From perbu at varnish-cache.org Fri May 20 09:12:12 2011 From: perbu at varnish-cache.org (Per Andreas Buer) Date: Fri, 20 May 2011 11:12:12 +0200 Subject: [master] 001f86f Merge branch 'master' of ssh://git.varnish-cache.org/git/varnish-cache Message-ID: commit 001f86f8deb9e1e9e6dde3d2c4fe95016204a0a6 Merge: 29d4914 5840a2a Author: Per Buer Date: Fri May 20 11:11:08 2011 +0200 Merge branch 'master' of ssh://git.varnish-cache.org/git/varnish-cache Conflicts: doc/sphinx/reference/vcl.rst diff --cc doc/sphinx/reference/vcl.rst index 8837142,cfb1c38..4a88dd1 --- a/doc/sphinx/reference/vcl.rst +++ b/doc/sphinx/reference/vcl.rst @@@ -323,11 -323,8 +323,10 @@@ regsub(str, regex, sub regsuball(str, regex, sub) As regsuball() but this replaces all occurrences. +ban(ban expression) - Executes a ban. + ban_url(regex) - Ban all objects in cache whose URLs match regex. + Bans all objects in cache whose URLs match regex. Subroutines ~~~~~~~~~~~ From perbu at varnish-cache.org Fri May 20 12:39:28 2011 From: perbu at varnish-cache.org (Per Buer) Date: Fri, 20 May 2011 14:39:28 +0200 Subject: [master] cb6187c Move man vmod_std to section 3 Message-ID: commit cb6187c71a9025983ef810fa72562b73fcbd035a Author: Per Buer Date: Fri May 20 14:39:27 2011 +0200 Move man vmod_std to section 3 diff --git a/doc/sphinx/reference/vmod_std.rst b/doc/sphinx/reference/vmod_std.rst index ca1c745..a023aa3 100644 --- a/doc/sphinx/reference/vmod_std.rst +++ b/doc/sphinx/reference/vmod_std.rst @@ -9,7 +9,7 @@ Varnish Standard Module :Author: Per Buer :Date: 2011-05-19 :Version: 1.0 -:Manual section: 1 +:Manual section: 3 SYNOPSIS From perbu at varnish-cache.org Fri May 20 12:41:39 2011 From: perbu at varnish-cache.org (Per Buer) Date: Fri, 20 May 2011 14:41:39 +0200 Subject: [master] 5e2c77b add vmod_std to the sphinx index Message-ID: commit 5e2c77b51c9d6cb4e159ae38628af0950ce57b79 Author: Per Buer Date: Fri May 20 14:41:35 2011 +0200 add vmod_std to the sphinx index diff --git a/doc/sphinx/reference/index.rst b/doc/sphinx/reference/index.rst index 2834983..84449da 100644 --- a/doc/sphinx/reference/index.rst +++ b/doc/sphinx/reference/index.rst @@ -20,6 +20,7 @@ The Varnish Reference Manual varnishtop.rst shmem.rst vmod.rst + vmod_std.rst vsl.rst .. todo:: From phk at varnish-cache.org Mon May 23 07:19:58 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 23 May 2011 09:19:58 +0200 Subject: [master] aa07de4 Don't allow symbols in expressions unless we can evaluate them. Message-ID: commit aa07de47e21abce49b35a51d27c80c03b71e0f36 Author: Poul-Henning Kamp Date: Mon May 23 07:19:17 2011 +0000 Don't allow symbols in expressions unless we can evaluate them. Fixes: #916 diff --git a/bin/varnishtest/tests/r00916.vtc b/bin/varnishtest/tests/r00916.vtc new file mode 100644 index 0000000..bf2ee63 --- /dev/null +++ b/bin/varnishtest/tests/r00916.vtc @@ -0,0 +1,16 @@ +varnishtest "VCC reference bug" + +server s1 { + rxreq + txresp -body "FOO" +} -start + +varnish v1 -badvcl { + sub s1 { + } + sub vcl_fetch { + if (req.backend == s-1){ + set req.backend = s-1; + } + } +} diff --git a/lib/libvcl/vcc_expr.c b/lib/libvcl/vcc_expr.c index 0839e8b..43e6ee1 100644 --- a/lib/libvcl/vcc_expr.c +++ b/lib/libvcl/vcc_expr.c @@ -656,7 +656,7 @@ vcc_expr4(struct vcc *tl, struct expr **e, enum var_type fmt) * XXX: look for SYM_VAR first for consistency ? */ sym = VCC_FindSymbol(tl, tl->t, SYM_NONE); - if (sym == NULL) { + if (sym == NULL || sym->eval == NULL) { vsb_printf(tl->sb, "Symbol not found: "); vcc_ErrToken(tl, tl->t); vsb_printf(tl->sb, " (expected type %s):\n", From phk at varnish-cache.org Mon May 23 07:19:58 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 23 May 2011 09:19:58 +0200 Subject: [master] 1a5b7fd Merge branch 'master' of ssh://git.varnish-cache.org/git/varnish-cache Message-ID: commit 1a5b7fd02cb7643934383cfbf6d276741e5158bc Merge: aa07de4 5e2c77b Author: Poul-Henning Kamp Date: Mon May 23 07:19:54 2011 +0000 Merge branch 'master' of ssh://git.varnish-cache.org/git/varnish-cache From phk at varnish-cache.org Mon May 23 07:58:07 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 23 May 2011 09:58:07 +0200 Subject: [master] b3484a4 Catch redefinition of non-method sub's early. Message-ID: commit b3484a49f736c8457756a6d24d553d27cae60113 Author: Poul-Henning Kamp Date: Mon May 23 07:57:46 2011 +0000 Catch redefinition of non-method sub's early. diff --git a/bin/varnishtest/tests/v00034.vtc b/bin/varnishtest/tests/v00034.vtc new file mode 100644 index 0000000..c73994b --- /dev/null +++ b/bin/varnishtest/tests/v00034.vtc @@ -0,0 +1,15 @@ +varnishtest "Test sub redefinition" + +server s1 { + rxreq + txresp +} -start + +varnish v1 -vcl+backend { } -start + +varnish v1 -badvcl { + backend foo { .host = "127.0.0.1"; } + sub c1 { } + sub c1 { } + sub vcl_recv { call c1; } +} diff --git a/lib/libvcl/vcc_compile.h b/lib/libvcl/vcc_compile.h index df2c01f..09138b9 100644 --- a/lib/libvcl/vcc_compile.h +++ b/lib/libvcl/vcc_compile.h @@ -310,7 +310,7 @@ void vcc_VarVal(struct vcc *tl, const struct var *vp, void vcc_ParseImport(struct vcc *tl); /* vcc_xref.c */ -void vcc_AddDef(struct vcc *tl, const struct token *t, enum symkind type); +int vcc_AddDef(struct vcc *tl, const struct token *t, enum symkind type); void vcc_AddRef(struct vcc *tl, const struct token *t, enum symkind type); int vcc_CheckReferences(struct vcc *tl); diff --git a/lib/libvcl/vcc_parse.c b/lib/libvcl/vcc_parse.c index 8f694d3..5636b71 100644 --- a/lib/libvcl/vcc_parse.c +++ b/lib/libvcl/vcc_parse.c @@ -194,7 +194,7 @@ vcc_Compound(struct vcc *tl) static void vcc_Function(struct vcc *tl) { - int m; + int m, i; vcc_NextToken(tl); ExpectErr(tl, ID); @@ -214,7 +214,13 @@ vcc_Function(struct vcc *tl) Fb(tl, 0, " */\n"); } else { tl->fb = tl->fc; - vcc_AddDef(tl, tl->t, SYM_SUB); + i = vcc_AddDef(tl, tl->t, SYM_SUB); + if (i > 1) { + vsb_printf(tl->sb, + "Function %.*s redefined\n", PF(tl->t)); + vcc_ErrWhere(tl, tl->t); + return; + } tl->curproc = vcc_AddProc(tl, tl->t); Fh(tl, 0, "static int VGC_function_%.*s (struct sess *sp);\n", PF(tl->t)); diff --git a/lib/libvcl/vcc_xref.c b/lib/libvcl/vcc_xref.c index 17b3a8a..3cd2627 100644 --- a/lib/libvcl/vcc_xref.c +++ b/lib/libvcl/vcc_xref.c @@ -87,7 +87,7 @@ vcc_AddRef(struct vcc *tl, const struct token *t, enum symkind kind) sym->nref++; } -void +int vcc_AddDef(struct vcc *tl, const struct token *t, enum symkind kind) { struct symbol *sym; @@ -95,6 +95,7 @@ vcc_AddDef(struct vcc *tl, const struct token *t, enum symkind kind) sym = VCC_GetSymbolTok(tl, t, kind); AN(sym); sym->ndef++; + return (sym->ndef); } /*--------------------------------------------------------------------*/ From kristian at varnish-cache.org Mon May 23 08:47:06 2011 From: kristian at varnish-cache.org (=?UTF-8?Q?Kristian_Lyngst=C3=B8l?=) Date: Mon, 23 May 2011 10:47:06 +0200 Subject: [master] feba493 Document gzip-enabled-later + ESI Message-ID: commit feba4935cc0f07bb248554d1fe96fdacfbb95459 Author: Kristian Lyngstol Date: Mon May 23 10:46:07 2011 +0200 Document gzip-enabled-later + ESI Closes #899 diff --git a/doc/sphinx/reference/varnishd.rst b/doc/sphinx/reference/varnishd.rst index 1a3f2de..4036f65 100644 --- a/doc/sphinx/reference/varnishd.rst +++ b/doc/sphinx/reference/varnishd.rst @@ -454,6 +454,11 @@ http_gzip_support Clients that do not support gzip will have their Accept-Encoding header removed. For more information on how gzip is implemented please see the chapter on gzip in the Varnish reference. + Note: Enabling gzip on a running Varnish instance using ESI can + yield content where cached, uncompressed pages have compressed ESI + elements. To avoid this, either ban all ESI-related elements before + enabling gzip, or restart Varnish. + http_headers - Units: header lines - Default: 64 From phk at varnish-cache.org Mon May 23 09:07:19 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 23 May 2011 11:07:19 +0200 Subject: [master] 474b9fc Also check for duplicate definitions of backends, probes and acls. Message-ID: commit 474b9fcedbc7f056b6e7dc09e8231f08c16d8e12 Author: Poul-Henning Kamp Date: Mon May 23 09:06:47 2011 +0000 Also check for duplicate definitions of backends, probes and acls. diff --git a/bin/varnishtest/tests/v00034.vtc b/bin/varnishtest/tests/v00034.vtc index c73994b..fdc6e20 100644 --- a/bin/varnishtest/tests/v00034.vtc +++ b/bin/varnishtest/tests/v00034.vtc @@ -1,4 +1,4 @@ -varnishtest "Test sub redefinition" +varnishtest "Test sub and backend redefinition" server s1 { rxreq @@ -13,3 +13,14 @@ varnish v1 -badvcl { sub c1 { } sub vcl_recv { call c1; } } + +varnish v1 -badvcl { + backend s1 { .host = "127.0.0.1"; } + backend s1 { .host = "127.0.0.1"; } +} + +varnish v1 -badvcl { + backend s1 { .host = "127.0.0.1"; .probe = p1;} + probe p1 { } + probe p1 { } +} diff --git a/lib/libvcl/vcc_acl.c b/lib/libvcl/vcc_acl.c index 6d7e629..e344d3d 100644 --- a/lib/libvcl/vcc_acl.c +++ b/lib/libvcl/vcc_acl.c @@ -465,6 +465,7 @@ void vcc_Acl(struct vcc *tl) { struct token *an; + int i; char acln[1024]; vcc_NextToken(tl); @@ -474,7 +475,12 @@ vcc_Acl(struct vcc *tl) an = tl->t; vcc_NextToken(tl); - vcc_AddDef(tl, an, SYM_ACL); + i = vcc_AddDef(tl, an, SYM_ACL); + if (i > 1) { + vsb_printf(tl->sb, "ACL %.*s redefined\n", PF(an)); + vcc_ErrWhere(tl, an); + return; + } bprintf(acln, "%.*s", PF(an)); SkipToken(tl, '{'); diff --git a/lib/libvcl/vcc_backend.c b/lib/libvcl/vcc_backend.c index e8cd700..ab102bb 100644 --- a/lib/libvcl/vcc_backend.c +++ b/lib/libvcl/vcc_backend.c @@ -412,6 +412,7 @@ void vcc_ParseProbe(struct vcc *tl) { struct token *t_probe; + int i; vcc_NextToken(tl); /* ID: probe */ @@ -419,7 +420,11 @@ vcc_ParseProbe(struct vcc *tl) ERRCHK(tl); t_probe = tl->t; vcc_NextToken(tl); - vcc_AddDef(tl, t_probe, SYM_PROBE); + i = vcc_AddDef(tl, t_probe, SYM_PROBE); + if (i > 1) { + vsb_printf(tl->sb, "Probe %.*s redefined\n", PF(t_probe)); + vcc_ErrWhere(tl, t_probe); + } Fh(tl, 0, "\n#define vgc_probe_%.*s\tvgc_probe__%d\n", PF(t_probe), tl->nprobe); @@ -682,6 +687,11 @@ vcc_DefBackend(struct vcc *tl, const struct token *nm) sym = VCC_GetSymbolTok(tl, nm, SYM_BACKEND); AN(sym); + if (sym->ndef > 0) { + vsb_printf(tl->sb, "Backend %.*s redefined\n", PF(tl->t)); + vcc_ErrWhere(tl, nm); + return; + } sym->fmt = BACKEND; sym->eval = vcc_Eval_Backend; sym->ndef++; @@ -700,6 +710,7 @@ vcc_ParseSimpleDirector(struct vcc *tl) h = TlAlloc(tl, sizeof *h); h->name = tl->t_dir; vcc_DefBackend(tl, tl->t_dir); + ERRCHK(tl); sprintf(vgcname, "_%.*s", PF(h->name)); h->vgcname = TlAlloc(tl, strlen(vgcname) + 1); strcpy(h->vgcname, vgcname); @@ -748,6 +759,7 @@ vcc_ParseDirector(struct vcc *tl) vcc_ParseSimpleDirector(tl); } else { vcc_DefBackend(tl, tl->t_dir); + ERRCHK(tl); ExpectErr(tl, ID); /* ID: policy */ tl->t_policy = tl->t; vcc_NextToken(tl); diff --git a/lib/libvcl/vcc_parse.c b/lib/libvcl/vcc_parse.c index 5636b71..34f9c33 100644 --- a/lib/libvcl/vcc_parse.c +++ b/lib/libvcl/vcc_parse.c @@ -204,7 +204,7 @@ vcc_Function(struct vcc *tl) assert(m < VCL_MET_MAX); tl->fb = tl->fm[m]; if (tl->mprocs[m] == NULL) { - vcc_AddDef(tl, tl->t, SYM_SUB); + (void)vcc_AddDef(tl, tl->t, SYM_SUB); vcc_AddRef(tl, tl->t, SYM_SUB); tl->mprocs[m] = vcc_AddProc(tl, tl->t); } From phk at varnish-cache.org Mon May 23 09:07:19 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 23 May 2011 11:07:19 +0200 Subject: [master] b92c383 Merge branch 'master' of ssh://git.varnish-cache.org/git/varnish-cache Message-ID: commit b92c383ee87fe2d66cd969797660068242bc209e Merge: 474b9fc feba493 Author: Poul-Henning Kamp Date: Mon May 23 09:07:16 2011 +0000 Merge branch 'master' of ssh://git.varnish-cache.org/git/varnish-cache From phk at varnish-cache.org Mon May 23 10:27:57 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 23 May 2011 12:27:57 +0200 Subject: [master] 0fb00eb Add 307 Temporary Redirect to the list of responses we consider cacheable. Message-ID: commit 0fb00eb730e9a41b8cc696607585d9982764fe39 Author: Poul-Henning Kamp Date: Mon May 23 10:27:23 2011 +0000 Add 307 Temporary Redirect to the list of responses we consider cacheable. Fixes #908 diff --git a/bin/varnishd/rfc2616.c b/bin/varnishd/rfc2616.c index 457edbe..97bbe81 100644 --- a/bin/varnishd/rfc2616.c +++ b/bin/varnishd/rfc2616.c @@ -98,6 +98,7 @@ RFC2616_Ttl(const struct sess *sp) case 300: /* Multiple Choices */ case 301: /* Moved Permanently */ case 302: /* Moved Temporarily */ + case 307: /* Temporary Redirect */ case 410: /* Gone */ case 404: /* Not Found */ /* From phk at varnish-cache.org Tue May 24 07:00:54 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 24 May 2011 09:00:54 +0200 Subject: [master] 5a490f0 Fix the wrong test for user-configured Transient storage. Message-ID: commit 5a490f0503c8f5e9e9b0ad9d1d078a384dd90f9b Author: Poul-Henning Kamp Date: Tue May 24 06:44:35 2011 +0000 Fix the wrong test for user-configured Transient storage. Spotted by: nav diff --git a/bin/varnishd/stevedore.c b/bin/varnishd/stevedore.c index 1a6cab1..03df098 100644 --- a/bin/varnishd/stevedore.c +++ b/bin/varnishd/stevedore.c @@ -509,13 +509,11 @@ STV_Config(const char *spec) void STV_Config_Transient(void) { - const struct stevedore *stv; ASSERT_MGT(); - VTAILQ_FOREACH(stv, &stevedores, list) - if (!strcmp(stv->ident, TRANSIENT_STORAGE)) - return; - STV_Config(TRANSIENT_STORAGE "=malloc"); + + if (stv_transient == NULL) + STV_Config(TRANSIENT_STORAGE "=malloc"); } /*--------------------------------------------------------------------*/ @@ -529,6 +527,8 @@ stv_cli_list(struct cli *cli, const char * const *av, void *priv) (void)av; (void)priv; cli_out(cli, "Storage devices:\n"); + stv = stv_transient; + cli_out(cli, "\tstorage.%s = %s\n", stv->ident, stv->name); VTAILQ_FOREACH(stv, &stevedores, list) cli_out(cli, "\tstorage.%s = %s\n", stv->ident, stv->name); } From phk at varnish-cache.org Tue May 24 07:00:57 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 24 May 2011 09:00:57 +0200 Subject: [master] eb81298 Symbol visibility reduction. Message-ID: commit eb812987bb040eeea10672d81e0deb75e7387730 Author: Poul-Henning Kamp Date: Tue May 24 06:53:10 2011 +0000 Symbol visibility reduction. diff --git a/bin/varnishd/cache.h b/bin/varnishd/cache.h index 6a85ce6..69cb666 100644 --- a/bin/varnishd/cache.h +++ b/bin/varnishd/cache.h @@ -177,7 +177,6 @@ struct http { txt *hd; unsigned char *hdf; #define HDF_FILTER (1 << 0) /* Filtered by Connection */ -#define HDF_COPY (1 << 1) /* Copy this field */ unsigned nhd; /* Next free hd */ }; @@ -683,7 +682,6 @@ void EXP_Set_keep(struct exp *e, double v); double EXP_Ttl(const struct sess *, const struct object*); double EXP_Grace(const struct sess *, const struct object*); -double EXP_Keep(const struct sess *, const struct object*); void EXP_Insert(struct object *o); void EXP_Inject(struct objcore *oc, struct lru *lru, double when); void EXP_Init(void); @@ -802,7 +800,6 @@ void Lck_CondWait(pthread_cond_t *cond, struct lock *lck); #define Lck_Unlock(a) Lck__Unlock(a, __func__, __FILE__, __LINE__) #define Lck_Trylock(a) Lck__Trylock(a, __func__, __FILE__, __LINE__) #define Lck_AssertHeld(a) Lck__Assert(a, 1) -#define Lck_AssertNotHeld(a) Lck__Assert(a, 0) #define LOCK(nam) extern struct vsc_lck *lck_##nam; #include "locks.h" @@ -816,7 +813,6 @@ void PipeSession(struct sess *sp); /* cache_pool.c */ void WRK_Init(void); -int WRK_Queue(struct workreq *wrq); int WRK_QueueSession(struct sess *sp); void WRK_SumStat(struct worker *w); @@ -891,7 +887,6 @@ int VRY_Match(const struct sess *sp, const unsigned char *vary); void VCL_Init(void); void VCL_Refresh(struct VCL_conf **vcc); void VCL_Rel(struct VCL_conf **vcc); -void VCL_Get(struct VCL_conf **vcc); void VCL_Poll(void); #define VCL_MET_MAC(l,u,b) void VCL_##l##_method(struct sess *); diff --git a/bin/varnishd/cache_expire.c b/bin/varnishd/cache_expire.c index f758053..a8b391f 100644 --- a/bin/varnishd/cache_expire.c +++ b/bin/varnishd/cache_expire.c @@ -97,7 +97,7 @@ EXP_ACCESS(keep, 0.,) * by per-session limits. */ -double +static double EXP_Keep(const struct sess *sp, const struct object *o) { double r; diff --git a/bin/varnishd/cache_pool.c b/bin/varnishd/cache_pool.c index 2b82455..816bdbe 100644 --- a/bin/varnishd/cache_pool.c +++ b/bin/varnishd/cache_pool.c @@ -239,7 +239,7 @@ wrk_thread(void *priv) * Return zero if the request was queued, negative if it wasn't. */ -int +static int WRK_Queue(struct workreq *wrq) { struct worker *w; diff --git a/bin/varnishd/cache_vcl.c b/bin/varnishd/cache_vcl.c index d2f74fc..e851f06 100644 --- a/bin/varnishd/cache_vcl.c +++ b/bin/varnishd/cache_vcl.c @@ -67,17 +67,7 @@ static struct vcls *vcl_active; /* protected by vcl_mtx */ /*--------------------------------------------------------------------*/ -void -VCL_Refresh(struct VCL_conf **vcc) -{ - if (*vcc == vcl_active->conf) - return; - if (*vcc != NULL) - VCL_Rel(vcc); /* XXX: optimize locking */ - VCL_Get(vcc); -} - -void +static void VCL_Get(struct VCL_conf **vcc) { static int once = 0; @@ -97,6 +87,16 @@ VCL_Get(struct VCL_conf **vcc) } void +VCL_Refresh(struct VCL_conf **vcc) +{ + if (*vcc == vcl_active->conf) + return; + if (*vcc != NULL) + VCL_Rel(vcc); /* XXX: optimize locking */ + VCL_Get(vcc); +} + +void VCL_Rel(struct VCL_conf **vcc) { struct VCL_conf *vc; From phk at varnish-cache.org Tue May 24 07:01:00 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 24 May 2011 09:01:00 +0200 Subject: [master] 94f9edb Unit conformance, comparing bytes with kilobytes is not smart. Message-ID: commit 94f9edba707fe736ef6a49f1b7546f6516e11a12 Author: Poul-Henning Kamp Date: Tue May 24 06:56:39 2011 +0000 Unit conformance, comparing bytes with kilobytes is not smart. Spotted by: nav diff --git a/bin/varnishd/stevedore.c b/bin/varnishd/stevedore.c index 03df098..51f4422 100644 --- a/bin/varnishd/stevedore.c +++ b/bin/varnishd/stevedore.c @@ -178,7 +178,7 @@ stv_alloc(const struct sess *sp, size_t size) if (st != NULL) break; - if (size > params->fetch_chunksize) { + if (size > params->fetch_chunksize * 1024LL) { size >>= 1; continue; } From phk at varnish-cache.org Tue May 24 07:01:03 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 24 May 2011 09:01:03 +0200 Subject: [master] bba36ef Don't drop non-existent object. Message-ID: commit bba36ef068fbb5d0a09149bb8df78aa9da2babd2 Author: Poul-Henning Kamp Date: Tue May 24 07:00:34 2011 +0000 Don't drop non-existent object. diff --git a/bin/varnishd/cache_center.c b/bin/varnishd/cache_center.c index 5d2a0d7..13a0bd3 100644 --- a/bin/varnishd/cache_center.c +++ b/bin/varnishd/cache_center.c @@ -746,7 +746,6 @@ cnt_fetchbody(struct sess *sp) sp->wrk->exp.ttl = params->shortlived; } if (sp->obj == NULL) { - HSH_Drop(sp); sp->err_code = 503; sp->step = STP_ERROR; VDI_CloseFd(sp); From martin at varnish-cache.org Wed May 25 08:34:52 2011 From: martin at varnish-cache.org (Martin Blix Grydeland) Date: Wed, 25 May 2011 10:34:52 +0200 Subject: [master] 49c479a Add doc/sphinx/reference/vmod_std.rst to doc/sphinx/Makefile.am Message-ID: commit 49c479a61fe0ce8d1bd7a0f3fe081debb029b5b7 Author: Martin Blix Grydeland Date: Wed May 25 10:32:48 2011 +0200 Add doc/sphinx/reference/vmod_std.rst to doc/sphinx/Makefile.am diff --git a/doc/sphinx/Makefile.am b/doc/sphinx/Makefile.am index 73371db..69eab17 100644 --- a/doc/sphinx/Makefile.am +++ b/doc/sphinx/Makefile.am @@ -126,6 +126,7 @@ EXTRA_DIST = \ reference/varnish-cli.rst \ reference/vcl.rst \ reference/vmod.rst \ + reference/vmod_std.rst \ tutorial/advanced_backend_servers.rst \ tutorial/advanced_topics.rst \ tutorial/backend_servers.rst \ From martin at varnish-cache.org Wed May 25 09:40:21 2011 From: martin at varnish-cache.org (Martin Blix Grydeland) Date: Wed, 25 May 2011 11:40:21 +0200 Subject: [master] bbc2f91 Install the vmod_std.7 man page Message-ID: commit bbc2f9194c45c94b4c7348a3fd3b4f1bc9574398 Author: Martin Blix Grydeland Date: Wed May 25 11:39:06 2011 +0200 Install the vmod_std.7 man page diff --git a/lib/libvmod_std/Makefile.am b/lib/libvmod_std/Makefile.am index 7ddd0ac..706a132 100644 --- a/lib/libvmod_std/Makefile.am +++ b/lib/libvmod_std/Makefile.am @@ -2,6 +2,8 @@ INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include +dist_man_MANS = vmod_std.7 + vmoddir = $(pkglibdir)/vmods vmod_LTLIBRARIES = libvmod_std.la @@ -20,3 +22,13 @@ vcc_if.c vcc_if.h: $(top_srcdir)/lib/libvmod_std/vmod.py $(top_srcdir)/lib/libvm EXTRA_DIST = vmod.py vmod.vcc CLEANFILES = $(builddir)/vcc_if.c $(builddir)/vcc_if.h + +vmod_std.7: $(top_srcdir)/doc/sphinx/reference/vmod_std.rst +if HAVE_RST2MAN + ${RST2MAN} $? $@ +else + @echo "========================================" + @echo "You need rst2man installed to make dist" + @echo "========================================" + @false +endif From tfheen at varnish-cache.org Thu May 26 06:49:32 2011 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Thu, 26 May 2011 08:49:32 +0200 Subject: [master] 39227a1 Update varnishncsa todo Message-ID: commit 39227a148f64d1158e73390606bc4814156d7352 Author: Tollef Fog Heen Date: Thu May 26 08:49:29 2011 +0200 Update varnishncsa todo diff --git a/bin/varnishncsa/varnishncsa.c b/bin/varnishncsa/varnishncsa.c index 308d9fa..6a3f684 100644 --- a/bin/varnishncsa/varnishncsa.c +++ b/bin/varnishncsa/varnishncsa.c @@ -55,7 +55,7 @@ * %q Query string * %H Protocol version * - * TODO: - Log in any format one wants + * TODO: - Make it possible to grab any request header * - Maybe rotate/compress log */ From tfheen at varnish-cache.org Thu May 26 07:56:52 2011 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Thu, 26 May 2011 09:56:52 +0200 Subject: [master] 0c9a575 Move libvmod_std to section 3 Message-ID: commit 0c9a575fabb9e3db4be25595c2ce4488d792140e Author: Tollef Fog Heen Date: Thu May 26 09:56:48 2011 +0200 Move libvmod_std to section 3 diff --git a/lib/libvmod_std/Makefile.am b/lib/libvmod_std/Makefile.am index 706a132..49699cb 100644 --- a/lib/libvmod_std/Makefile.am +++ b/lib/libvmod_std/Makefile.am @@ -2,7 +2,7 @@ INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include -dist_man_MANS = vmod_std.7 +dist_man_MANS = vmod_std.3 vmoddir = $(pkglibdir)/vmods vmod_LTLIBRARIES = libvmod_std.la @@ -23,7 +23,7 @@ EXTRA_DIST = vmod.py vmod.vcc CLEANFILES = $(builddir)/vcc_if.c $(builddir)/vcc_if.h -vmod_std.7: $(top_srcdir)/doc/sphinx/reference/vmod_std.rst +vmod_std.3: $(top_srcdir)/doc/sphinx/reference/vmod_std.rst if HAVE_RST2MAN ${RST2MAN} $? $@ else From tfheen at varnish-cache.org Fri May 27 08:48:17 2011 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Fri, 27 May 2011 10:48:17 +0200 Subject: [master] 37fe258 Fix up redhat build to ship vmod_std man page too Message-ID: commit 37fe258667e450064bad14c8e987da733d7294d8 Author: Tollef Fog Heen Date: Fri May 27 10:48:13 2011 +0200 Fix up redhat build to ship vmod_std man page too diff --git a/redhat/varnish.spec b/redhat/varnish.spec index c2d2ee9..da604bb 100644 --- a/redhat/varnish.spec +++ b/redhat/varnish.spec @@ -171,6 +171,7 @@ rm -rf %{buildroot} %{_var}/lib/varnish %{_var}/log/varnish %{_mandir}/man1/*.1* +%{_mandir}/man3/*.3* %{_mandir}/man7/*.7* %doc INSTALL LICENSE README redhat/README.redhat ChangeLog %doc examples From phk at varnish-cache.org Fri May 27 09:55:20 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Fri, 27 May 2011 11:55:20 +0200 Subject: [master] 218d4fb The params pointer itself is not volatile, only what it points to. Message-ID: commit 218d4fb0b434f346e3ed27652d3525810b9a7d32 Author: Poul-Henning Kamp Date: Tue May 24 07:09:05 2011 +0000 The params pointer itself is not volatile, only what it points to. diff --git a/bin/varnishd/heritage.h b/bin/varnishd/heritage.h index 2198b59..ad3b363 100644 --- a/bin/varnishd/heritage.h +++ b/bin/varnishd/heritage.h @@ -214,7 +214,7 @@ struct params { * We declare this a volatile pointer, so that reads of parameters * become atomic, leaving the CLI thread lattitude to change the values */ -extern volatile struct params * volatile params; +extern volatile struct params * params; extern struct heritage heritage; void child_main(void); diff --git a/bin/varnishd/varnishd.c b/bin/varnishd/varnishd.c index 5bcea1a..b36f28c 100644 --- a/bin/varnishd/varnishd.c +++ b/bin/varnishd/varnishd.c @@ -71,7 +71,7 @@ #endif struct heritage heritage; -volatile struct params * volatile params; +volatile struct params *params; unsigned d_flag = 0; pid_t mgt_pid; struct vev_base *mgt_evb; From phk at varnish-cache.org Fri May 27 09:55:21 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Fri, 27 May 2011 11:55:21 +0200 Subject: [master] 34c1fb1 Merge branch 'master' of ssh://git.varnish-cache.org/git/varnish-cache Message-ID: commit 34c1fb12b54260a389912648b4c9444aa50f9261 Merge: 218d4fb 0c9a575 Author: Poul-Henning Kamp Date: Fri May 27 08:41:45 2011 +0000 Merge branch 'master' of ssh://git.varnish-cache.org/git/varnish-cache From phk at varnish-cache.org Fri May 27 09:55:23 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Fri, 27 May 2011 11:55:23 +0200 Subject: [master] 6f72a59 Merge branch 'master' of ssh://git.varnish-cache.org/git/varnish-cache Message-ID: commit 6f72a59a7173182cc0bbda9d389428d36366e820 Merge: 34c1fb1 37fe258 Author: Poul-Henning Kamp Date: Fri May 27 09:43:11 2011 +0000 Merge branch 'master' of ssh://git.varnish-cache.org/git/varnish-cache From phk at varnish-cache.org Fri May 27 09:55:24 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Fri, 27 May 2011 11:55:24 +0200 Subject: [master] 24d9048 Remove the CLI::stats command. Message-ID: commit 24d904838e3b8d0426d3347d2f3bbef07d98d135 Author: Poul-Henning Kamp Date: Fri May 27 09:49:23 2011 +0000 Remove the CLI::stats command. This was added as a quick-ish hack back in 1.0 days, but it was never meant to be a primary interface for getting stats information, and using it as such leads to problems. The CLI is single-threaded and any kind of TCP trouble from a client polling stats information would cause the CLI to get stuck, preventing any other kind of management from happening. The trigger for this removal is that the stats implementation has never learned to handle dynamic stats counters, and since this as added a lot of new stats, the next thing you need filtering facilites, paging etc. All of that belongs in varnishstat, where it is already implemented, and were its operation does not negatively impact the primary task of varnish: service HTTP clients. For reference we never made the mistake of showing the varnish-log from the CLI. See also ticket #925. diff --git a/bin/varnishd/mgt_cli.c b/bin/varnishd/mgt_cli.c index 4390866..66ee1b4 100644 --- a/bin/varnishd/mgt_cli.c +++ b/bin/varnishd/mgt_cli.c @@ -71,25 +71,6 @@ static const char *secret_file; /*--------------------------------------------------------------------*/ static void -mcf_stats(struct cli *cli, const char * const *av, void *priv) -{ - - (void)av; - (void)priv; - - AN(VSC_main); -#define VSC_DO_MAIN -#define VSC_F(n, t, l, f, d) \ - if (VSC_main->n != 0) \ - cli_out(cli, "%12ju %s\n", (VSC_main->n), d); -#include "vsc_fields.h" -#undef VSC_F -#undef VSC_DO_MAIN -} - -/*--------------------------------------------------------------------*/ - -static void mcf_banner(struct cli *cli, const char *const *av, void *priv) { @@ -115,7 +96,6 @@ static struct cli_proto cli_proto[] = { { CLI_SERVER_STATUS, "", mcf_server_status, NULL }, { CLI_SERVER_START, "", mcf_server_startstop, NULL }, { 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 }, { CLI_VCL_USE, "", mcf_config_use, NULL }, diff --git a/bin/varnishtest/tests/b00008.vtc b/bin/varnishtest/tests/b00008.vtc index 3d0c7e5..1e9aa9d 100644 --- a/bin/varnishtest/tests/b00008.vtc +++ b/bin/varnishtest/tests/b00008.vtc @@ -30,8 +30,6 @@ varnish v1 -start varnish v1 -cliok "help" -varnish v1 -cliok "stats" - varnish v1 -cliok "param.set waiter default" varnish v1 -clierr 106 "param.set waiter HASH(0x8839c4c)" diff --git a/bin/varnishtest/tests/c00002.vtc b/bin/varnishtest/tests/c00002.vtc index 6e633e0..62eaf17 100644 --- a/bin/varnishtest/tests/c00002.vtc +++ b/bin/varnishtest/tests/c00002.vtc @@ -16,5 +16,4 @@ client c1 { expect resp.status == 200 } -run -varnish v1 -cliok stats varnish v1 -expect n_wrk == 8 From phk at varnish-cache.org Fri May 27 09:55:25 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Fri, 27 May 2011 11:55:25 +0200 Subject: [master] 8e8d4e8 Remove declaration of unimplemented CLI commands. Most of these were things we dreamt up without knowing what reality would look like. Message-ID: commit 8e8d4e8aa5f2746fdb1c90a6a7268bd9224e294d Author: Poul-Henning Kamp Date: Fri May 27 09:54:27 2011 +0000 Remove declaration of unimplemented CLI commands. Most of these were things we dreamt up without knowing what reality would look like. diff --git a/include/cli.h b/include/cli.h index e5c4f0c..a82178a 100644 --- a/include/cli.h +++ b/include/cli.h @@ -78,12 +78,6 @@ "\tList the active bans.", \ 0, 0 -#define CLI_URL_STATUS \ - "url.status", \ - "url.status ", \ - "\tReturns all metadata for the specified URL", \ - 1, 1 - #define CLI_VCL_LOAD \ "vcl.load", \ "vcl.load ", \ @@ -132,30 +126,6 @@ "\tSet parameter value.", \ 2,2 -#define CLI_SERVER_FREEZE \ - "server.freeze", \ - "server.freeze", \ - "\tStop the clock, freeze object store.", \ - 0, 0 - -#define CLI_SERVER_THAW \ - "thaw", \ - "thaw", \ - "\tRestart the clock, unfreeze object store.", \ - 0, 0 - -#define CLI_SERVER_SUSPEND \ - "suspend", \ - "suspend", \ - "\tStop accepting requests.", \ - 0, 0 - -#define CLI_SERVER_RESUME \ - "resume", \ - "resume", \ - "\tAccept requests.", \ - 0, 0 - #define CLI_SERVER_STOP \ "stop", \ "stop", \ @@ -168,42 +138,18 @@ "\tStart the Varnish cache process.", \ 0, 0 -#define CLI_SERVER_RESTART \ - "restart", \ - "restart", \ - "\tRestart the Varnish cache process.", \ - 0, 0 - #define CLI_PING \ "ping", \ "ping [timestamp]", \ "\tKeep connection alive", \ 0, 1 -#define CLI_STATS \ - "stats", \ - "stats", \ - "\tShow summary statistics", \ - 0, 0 - -#define CLI_ZERO \ - "zero", \ - "zero", \ - "\tZero summary statistics", \ - 0, 0 - #define CLI_HELP \ "help", \ "help [command]", \ "\tShow command/protocol help", \ 0, 1 -#define CLI_VERBOSE \ - "verbose", \ - "verbose", \ - "\tEnable/Disable verbosity", \ - 0, 0 - #define CLI_QUIT \ "quit", \ "quit", \ @@ -240,9 +186,6 @@ "\tClear the last panic, if any.", \ 0, 0 -#define CLI_HIDDEN(foo, min_arg, max_arg) \ - foo, NULL, NULL, min_arg, max_arg, - /* * Status/return codes in the CLI protocol */ From martin at varnish-cache.org Fri May 27 11:39:31 2011 From: martin at varnish-cache.org (Martin Blix Grydeland) Date: Fri, 27 May 2011 13:39:31 +0200 Subject: [master] 1a4915f Correct missing .http. typos in vmod_std.rst Message-ID: commit 1a4915fef0638eb2cc631774f13b4d3d7f0270c0 Author: Martin Blix Grydeland Date: Fri May 27 12:48:20 2011 +0200 Correct missing .http. typos in vmod_std.rst diff --git a/doc/sphinx/reference/vmod_std.rst b/doc/sphinx/reference/vmod_std.rst index a023aa3..0d236b0 100644 --- a/doc/sphinx/reference/vmod_std.rst +++ b/doc/sphinx/reference/vmod_std.rst @@ -37,7 +37,7 @@ Return value Description Converts the STRING S to upper case. Example - set beresp.x-scream = std.toupper("yes!"); + set beresp.http.x-scream = std.toupper("yes!"); tolower ------- @@ -48,7 +48,7 @@ Return value Description Converts the STRING to lower case. Example - set beresp.x-nice = std.tolower("VerY"); + set beresp.http.x-nice = std.tolower("VerY"); set_up_tos ---------- @@ -75,7 +75,7 @@ Return value Description Returns a random REAL number between *a* and *b*. Example - set beresp.x-random-number = std.random(1, 100); + set beresp.http.x-random-number = std.random(1, 100); log --- From phk at varnish-cache.org Fri May 27 13:00:10 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Fri, 27 May 2011 15:00:10 +0200 Subject: [master] varnish-3.0.0-beta1-80-g94fe195 Message-ID: commit 94fe1956a596430501a6fe4100d998007f3b4215 Author: Poul-Henning Kamp Date: Fri May 27 12:46:51 2011 +0000 If we cannot allocate an object in cnt_error() just close and go to cnt_done(), there is nothing we can do. For some inderterminate value of "fixes" this... Fixes #924 diff --git a/bin/varnishd/cache_center.c b/bin/varnishd/cache_center.c index 13a0bd3..5b19c3e 100644 --- a/bin/varnishd/cache_center.c +++ b/bin/varnishd/cache_center.c @@ -415,7 +415,12 @@ cnt_error(struct sess *sp) EXP_Clr(&w->exp); sp->obj = STV_NewObject(sp, NULL, 1024, &w->exp, params->http_max_hdr); - XXXAN(sp->obj); + if (sp->obj == NULL) { + sp->doclose = "Out of objects"; + sp->step = STP_DONE; + return(0); + } + AN(sp->obj); sp->obj->xid = sp->xid; sp->obj->entered = sp->t_req; } else { From phk at varnish-cache.org Fri May 27 13:00:11 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Fri, 27 May 2011 15:00:11 +0200 Subject: [master] varnish-3.0.0-beta1-82-gec14ff3 Message-ID: commit ec14ff3fec9e2e58b684d33fb0be56c79512d153 Merge: 94fe195 1a4915f Author: Poul-Henning Kamp Date: Fri May 27 13:00:05 2011 +0000 Merge branch 'master' of ssh://git.varnish-cache.org/git/varnish-cache From phk at varnish-cache.org Fri May 27 19:48:35 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Fri, 27 May 2011 21:48:35 +0200 Subject: [master] varnish-3.0.0-beta1-83-gcfad478 Message-ID: commit cfad47881d155111cb38bb049a106d1865e099bd Author: Poul-Henning Kamp Date: Fri May 27 19:47:12 2011 +0000 The persistent stevedore is not even able to allocate an object without and objcore, so return NULL if asked to. Add a fallback in cnt_error() to attempt the Transient storage if we hit this case. There already is a similar retry for the regular object allocation attempt. Fixes #915 diff --git a/bin/varnishd/cache_center.c b/bin/varnishd/cache_center.c index 5b19c3e..7f4eedc 100644 --- a/bin/varnishd/cache_center.c +++ b/bin/varnishd/cache_center.c @@ -415,6 +415,9 @@ cnt_error(struct sess *sp) EXP_Clr(&w->exp); sp->obj = STV_NewObject(sp, NULL, 1024, &w->exp, params->http_max_hdr); + if (sp->obj == NULL) + sp->obj = STV_NewObject(sp, TRANSIENT_STORAGE, + 1024, &w->exp, params->http_max_hdr); if (sp->obj == NULL) { sp->doclose = "Out of objects"; sp->step = STP_DONE; diff --git a/bin/varnishd/storage_persistent.c b/bin/varnishd/storage_persistent.c index 6add1c7..d37ef45 100644 --- a/bin/varnishd/storage_persistent.c +++ b/bin/varnishd/storage_persistent.c @@ -474,6 +474,8 @@ smp_allocobj(struct stevedore *stv, struct sess *sp, unsigned ltot, struct objcore *oc; unsigned objidx; + if (sp->objcore == NULL) + return (NULL); /* from cnt_error */ CAST_OBJ_NOTNULL(sc, stv->priv, SMP_SC_MAGIC); AN(sp->objcore); AN(sp->wrk->exp.ttl > 0.); diff --git a/bin/varnishtest/tests/r00915.vtc b/bin/varnishtest/tests/r00915.vtc new file mode 100644 index 0000000..07a39d9 --- /dev/null +++ b/bin/varnishtest/tests/r00915.vtc @@ -0,0 +1,24 @@ +varnishtest "error object allocation with persistent" + +server s1 { + rxreq + txresp +} -start + +shell "rm -f ${tmpdir}/_.per" + +varnish v1 \ + -arg "-pdiag_bitmap=0x20000" \ + -storage "-spersistent,${tmpdir}/_.per,10m" \ + -vcl+backend { + + sub vcl_fetch { + error(751); + } +} -start + +client c1 { + txreq -url "/" + rxresp + expect resp.status == 751 +} -run From phk at varnish-cache.org Fri May 27 20:22:45 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Fri, 27 May 2011 22:22:45 +0200 Subject: [master] varnish-3.0.0-beta1-84-g76fc17c Message-ID: commit 76fc17c1852e2a1cb29f4e49a32009a93bb45972 Author: Poul-Henning Kamp Date: Fri May 27 20:22:15 2011 +0000 Make sure that the arguments we pass regsub() came out as strings. Fixes #921 diff --git a/bin/varnishtest/tests/r00921.vtc b/bin/varnishtest/tests/r00921.vtc new file mode 100644 index 0000000..d3e643d --- /dev/null +++ b/bin/varnishtest/tests/r00921.vtc @@ -0,0 +1,21 @@ +varnishtest "VCC type issue in regsub arg 1" + +server s1 { + rxreq + expect req.http.foo == "127.0.0.1" + expect req.http.bar == "127.0.0.1" + txresp +} -start + +varnish v1 -vcl+backend { + sub vcl_recv { + set req.http.bar = regsub(req.url, ".*", client.ip); + set req.http.foo = regsub(client.ip, ":.*", client.ip); + } +} -start + +client c1 { + txreq -url "/" + rxresp + expect resp.status == 200 +} -run diff --git a/lib/libvcl/vcc_expr.c b/lib/libvcl/vcc_expr.c index 43e6ee1..8774d8d 100644 --- a/lib/libvcl/vcc_expr.c +++ b/lib/libvcl/vcc_expr.c @@ -454,6 +454,8 @@ vcc_Eval_Regsub(struct vcc *tl, struct expr **e, const struct symbol *sym) SkipToken(tl, '('); vcc_expr0(tl, &e2, STRING); + if (e2->fmt != STRING) + vcc_expr_tostring(&e2, STRING); SkipToken(tl, ','); ExpectErr(tl, CSTR); @@ -465,6 +467,8 @@ vcc_Eval_Regsub(struct vcc *tl, struct expr **e, const struct symbol *sym) SkipToken(tl, ','); vcc_expr0(tl, &e2, STRING); + if (e2->fmt != STRING) + vcc_expr_tostring(&e2, STRING); *e = vcc_expr_edit(STRING, "\v1, \v2)", *e, e2); SkipToken(tl, ')'); } From tfheen at varnish-cache.org Mon May 30 11:34:30 2011 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Mon, 30 May 2011 13:34:30 +0200 Subject: [master] ebf15eb Ignore piped requests in varnishncsa, since we probably miss some of their information Message-ID: commit ebf15ebd61974be719ce315f95caa8c835ea37d6 Author: Tollef Fog Heen Date: Mon May 30 13:02:23 2011 +0200 Ignore piped requests in varnishncsa, since we probably miss some of their information Fixes: #918 diff --git a/bin/varnishncsa/varnishncsa.c b/bin/varnishncsa/varnishncsa.c index 6a3f684..022d955 100644 --- a/bin/varnishncsa/varnishncsa.c +++ b/bin/varnishncsa/varnishncsa.c @@ -426,8 +426,10 @@ collect_client(struct logline *lp, enum vsl_tag tag, unsigned spec, lp->df_hitmiss = "miss"; lp->df_handling = "pass"; } else if (strncmp(ptr, "pipe", len) == 0) { - lp->df_hitmiss = "miss"; - lp->df_handling = "pipe"; + /* Just skip piped requests, since we can't + * print their status code */ + clean_logline(lp); + break; } break; @@ -587,7 +589,7 @@ h_ncsa(void *priv, enum vsl_tag tag, unsigned fd, case 's': /* %s */ - fprintf(fo, "%s", lp->df_s); + fprintf(fo, "%s", lp->df_s ? lp->df_s : ""); break; case 't': From tfheen at varnish-cache.org Mon May 30 11:34:30 2011 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Mon, 30 May 2011 13:34:30 +0200 Subject: [master] 8435381 Don't emit Length records for piped requests Message-ID: commit 84353810d7e8aff9de925066ce3392093001d0b9 Author: Tollef Fog Heen Date: Mon May 30 13:28:16 2011 +0200 Don't emit Length records for piped requests We don't have a file descriptor for piped requests, so just don't emit a Length record. Fixes: #923 diff --git a/bin/varnishd/cache_center.c b/bin/varnishd/cache_center.c index 7f4eedc..7325f5a 100644 --- a/bin/varnishd/cache_center.c +++ b/bin/varnishd/cache_center.c @@ -323,7 +323,10 @@ cnt_done(struct sess *sp) da = sp->t_end - sp->t_resp; dh = sp->t_req - sp->t_open; /* XXX: Add StatReq == StatSess */ - WSP(sp, SLT_Length, "%ju", (uintmax_t)sp->acct_req.bodybytes); + /* XXX: Workaround for pipe */ + if (sp->fd >= 0) { + WSP(sp, SLT_Length, "%ju", (uintmax_t)sp->acct_req.bodybytes); + } WSL(sp->wrk, SLT_ReqEnd, sp->id, "%u %.9f %.9f %.9f %.9f %.9f", sp->xid, sp->t_req, sp->t_end, dh, dp, da); } From tfheen at varnish-cache.org Mon May 30 11:50:34 2011 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Mon, 30 May 2011 13:50:34 +0200 Subject: [master] 32e40a6 Make it possible to convert strings to numbers Message-ID: commit 32e40a6ececf4a2ea65830e723c770d1ce261898 Author: Tollef Fog Heen Date: Mon May 30 13:48:45 2011 +0200 Make it possible to convert strings to numbers diff --git a/bin/varnishtest/tests/m00007.vtc b/bin/varnishtest/tests/m00007.vtc new file mode 100644 index 0000000..68ee347 --- /dev/null +++ b/bin/varnishtest/tests/m00007.vtc @@ -0,0 +1,53 @@ +varnishtest "test vmod_std.integer conversion" + +server s1 { + rxreq + expect req.url == "/1" + txresp -bodylen 1 + +} -start + +varnish v1 -vcl+backend { + import std from "${topbuild}/lib/libvmod_std/.libs/libvmod_std.so" ; + + sub vcl_deliver { + set resp.http.biggerthanzero = (std.integer(req.http.foo,0) > 0); + set resp.http.smallerthanzero = (std.integer(req.http.foo,0) < 0); + set resp.http.iszero = (std.integer(req.http.foo,0) == 0); + set resp.http.converted = std.integer(req.http.foo,0); + } +} -start + +client c1 { + txreq -url "/1" -hdr "foo: 1" + rxresp + expect resp.status == 200 + expect resp.http.biggerthanzero == true + expect resp.http.smallerthanzero == false + expect resp.http.iszero == false + expect resp.http.converted == 1 + + txreq -url "/1" -hdr "foo: -1" + rxresp + expect resp.status == 200 + expect resp.http.biggerthanzero == false + expect resp.http.smallerthanzero == true + expect resp.http.iszero == false + expect resp.http.converted == -1 + + txreq -url "/1" + rxresp + expect resp.status == 200 + expect resp.http.biggerthanzero == false + expect resp.http.smallerthanzero == false + expect resp.http.iszero == true + expect resp.http.converted == 0 + + txreq -url "/1" -hdr "foo: bar" + rxresp + expect resp.status == 200 + expect resp.http.biggerthanzero == false + expect resp.http.smallerthanzero == false + expect resp.http.iszero == true + expect resp.http.converted == 0 +} -run diff --git a/doc/sphinx/reference/vmod_std.rst b/doc/sphinx/reference/vmod_std.rst index 0d236b0..1ea8193 100644 --- a/doc/sphinx/reference/vmod_std.rst +++ b/doc/sphinx/reference/vmod_std.rst @@ -127,6 +127,18 @@ Description Example set beresp.ttl = std.duration("1w", 3600); +integer +-------- +Prototype + integer(STRING s, INT fallback) +Return value + Int +Description + Converts the string s to an integer. If it fails to parse the + string *fallback* will be used +Example + if (std.integer(beresp.http.x-foo, 0) > 5) { ? } + collect ------- Prototype diff --git a/lib/libvmod_std/vmod.vcc b/lib/libvmod_std/vmod.vcc index 121b375..d0ade10 100644 --- a/lib/libvmod_std/vmod.vcc +++ b/lib/libvmod_std/vmod.vcc @@ -36,4 +36,5 @@ Function VOID syslog(INT, STRING_LIST) Function STRING fileread(PRIV_CALL, STRING) Function STRING author(ENUM { phk, des, kristian, mithrandir }) Function DURATION duration(STRING, DURATION) +Function INT integer(STRING, INT) Function VOID collect(HEADER) diff --git a/lib/libvmod_std/vmod_std_conversions.c b/lib/libvmod_std/vmod_std_conversions.c index 1167f55..1aaf095 100644 --- a/lib/libvmod_std/vmod_std_conversions.c +++ b/lib/libvmod_std/vmod_std_conversions.c @@ -30,6 +30,8 @@ #include #include #include +#include +#include #include "../../bin/varnishd/cache.h" @@ -85,3 +87,36 @@ vmod_duration(struct sess *sp, const char *p, double d) return (r); } + +int __match_proto__() +vmod_integer(struct sess *sp, const char *p, int i) +{ + char *e; + int r; + + (void)sp; + + if (p == NULL) + return (i); + + while(isspace(*p)) + p++; + + if (*p != '+' && *p != '-' && !isdigit(*p)) + return (i); + + e = NULL; + + r = strtol(p, &e, 0); + + if (!isfinite(r)) + return (i); + + if (e == NULL) + return (i); + + if (*e != '\0') + return (i); + + return (r); +} From martin at varnish-cache.org Tue May 31 08:32:34 2011 From: martin at varnish-cache.org (Martin Blix Grydeland) Date: Tue, 31 May 2011 10:32:34 +0200 Subject: [master] effaada - Make varnishtest default to use path look up varnishd, and allow macro redefinition of varnishd location on command line. This allows varnishtest to work when installed/packaged. - Added -i command line option to set in-tree varnishd lookup relative to the varnishtest directory. - Update Makefile.am to specify the build-tree varnishd during testing. Message-ID: commit effaadab98ef44a29bb3bd0544dfffa3f8ae1452 Author: Martin Blix Grydeland Date: Tue May 31 10:10:16 2011 +0200 - Make varnishtest default to use path look up varnishd, and allow macro redefinition of varnishd location on command line. This allows varnishtest to work when installed/packaged. - Added -i command line option to set in-tree varnishd lookup relative to the varnishtest directory. - Update Makefile.am to specify the build-tree varnishd during testing. diff --git a/bin/varnishtest/Makefile.am b/bin/varnishtest/Makefile.am index e538120..4562dc5 100644 --- a/bin/varnishtest/Makefile.am +++ b/bin/varnishtest/Makefile.am @@ -2,7 +2,7 @@ TESTS_PARALLELISM = 3 check: varnishtest - ./varnishtest -j$(TESTS_PARALLELISM) $(srcdir)/tests/*.vtc + ./varnishtest -i -j$(TESTS_PARALLELISM) $(srcdir)/tests/*.vtc @echo "===================" @echo "All tests succeeded" @echo "===================" diff --git a/bin/varnishtest/vtc.c b/bin/varnishtest/vtc.c index e893be1..fcf89ca 100644 --- a/bin/varnishtest/vtc.c +++ b/bin/varnishtest/vtc.c @@ -60,6 +60,7 @@ volatile sig_atomic_t vtc_error; /* Error encountered */ int vtc_stop; /* Stops current test without error */ pthread_t vtc_thread; static struct vtclog *vltop; +int in_tree = 0; /* Are we running in-tree */ /********************************************************************** * Macro facility @@ -73,8 +74,6 @@ struct macro { static VTAILQ_HEAD(,macro) macro_list = VTAILQ_HEAD_INITIALIZER(macro_list); -struct _extmacro_list extmacro_list = VTAILQ_HEAD_INITIALIZER(extmacro_list); - static pthread_mutex_t macro_mtx; static void @@ -192,6 +191,65 @@ macro_expand(struct vtclog *vl, const char *text) return (vsb); } +/* extmacro is a list of macro's that are defined from the + command line and are applied to the macro list of each test + instance. No locking is required as they are set before any tests + are started. +*/ + +struct extmacro { + VTAILQ_ENTRY(extmacro) list; + char *name; + char *val; +}; + +static VTAILQ_HEAD(, extmacro) extmacro_list = + VTAILQ_HEAD_INITIALIZER(extmacro_list); + +void +extmacro_def(const char *name, const char *fmt, ...) +{ + char buf[256]; + struct extmacro *m; + va_list ap; + + VTAILQ_FOREACH(m, &extmacro_list, list) + if (!strcmp(name, m->name)) + break; + if (m == NULL && fmt != NULL) { + m = calloc(sizeof *m, 1); + AN(m); + REPLACE(m->name, name); + VTAILQ_INSERT_TAIL(&extmacro_list, m, list); + } + if (fmt != NULL) { + AN(m); + va_start(ap, fmt); + free(m->val); + vbprintf(buf, fmt, ap); + va_end(ap); + m->val = strdup(buf); + AN(m->val); + } else if (m != NULL) { + VTAILQ_REMOVE(&extmacro_list, m, list); + free(m->name); + free(m->val); + free(m); + } +} + +const char * +extmacro_get(const char *name) +{ + struct extmacro *m; + + VTAILQ_FOREACH(m, &extmacro_list, list) + if (!strcmp(name, m->name)) + return (m->val); + + return (NULL); +} + /********************************************************************** * Execute a file */ @@ -491,14 +549,10 @@ exec_file(const char *fn, const char *script, const char *tmpdir, VTAILQ_FOREACH(m, &extmacro_list, list) macro_def(vltop, NULL, m->name, m->val); - /* We are still in bin/varnishtest at this point */ + /* Other macro definitions */ cwd = getcwd(NULL, PATH_MAX); - bprintf(topbuild, "%s/%s", cwd, TOP_BUILDDIR); - macro_def(vltop, NULL, "topbuild", topbuild); - - AN(getcwd(topbuild, sizeof topbuild)); - macro_def(vltop, NULL, "pwd", topbuild); - + macro_def(vltop, NULL, "pwd", cwd); + macro_def(vltop, NULL, "topbuild", "%s/%s", cwd, TOP_BUILDDIR); macro_def(vltop, NULL, "bad_ip", "10.255.255.255"); /* Move into our tmpdir */ diff --git a/bin/varnishtest/vtc.h b/bin/varnishtest/vtc.h index 16e27a9..656c0bf 100644 --- a/bin/varnishtest/vtc.h +++ b/bin/varnishtest/vtc.h @@ -49,15 +49,6 @@ struct cmds { cmd_f *cmd; }; -struct extmacro { - VTAILQ_ENTRY(extmacro) list; - char *name; - char *val; -}; - -VTAILQ_HEAD(_extmacro_list, extmacro); -extern struct _extmacro_list extmacro_list; - void parse_string(char *buf, const struct cmds *cmd, void *priv, struct vtclog *vl); @@ -92,3 +83,6 @@ int exec_file(const char *fn, const char *script, const char *tmpdir, void macro_def(struct vtclog *vl, const char *instance, const char *name, const char *fmt, ...); struct vsb *macro_expand(struct vtclog *vl, const char *text); + +void extmacro_def(const char *name, const char *fmt, ...); +const char *extmacro_get(const char *name); diff --git a/bin/varnishtest/vtc_main.c b/bin/varnishtest/vtc_main.c index 3f5d518..94abbf6 100644 --- a/bin/varnishtest/vtc_main.c +++ b/bin/varnishtest/vtc_main.c @@ -97,18 +97,13 @@ static int parse_D_opt(char *arg) { char *p, *q; - struct extmacro *m; p = arg; q = strchr(p, '='); if (!q) return (0); *q++ = '\0'; - m = calloc(sizeof *m, 1); - AN(m); - REPLACE(m->name, p); - REPLACE(m->val, q); - VTAILQ_INSERT_TAIL(&extmacro_list, m, list); + extmacro_def(p, "%s", q); return (1); } @@ -153,6 +148,7 @@ usage(void) fprintf(stderr, "usage: varnishtest [options] file ...\n"); #define FMT " %-28s # %s\n" fprintf(stderr, FMT, "-D name=val", "Define macro for use in scripts"); + fprintf(stderr, FMT, "-i", "Find varnishd in build tree"); fprintf(stderr, FMT, "-j jobs", "Run this many tests in parallel"); fprintf(stderr, FMT, "-k", "Continue on test failure"); fprintf(stderr, FMT, "-l", "Leave /tmp/vtc.* if test fails"); @@ -161,6 +157,9 @@ usage(void) fprintf(stderr, FMT, "-q", "Quiet mode: report only failues"); fprintf(stderr, FMT, "-t duration", "Time tests out after this long"); fprintf(stderr, FMT, "-v", "Verbose mode: always report test log"); + fprintf(stderr, "\n"); + fprintf(stderr, " Overridable macro definitions:\n"); + fprintf(stderr, FMT, "varnishd", "Path to varnishd to use [varnishd]"); exit(1); } @@ -331,9 +330,11 @@ main(int argc, char * const *argv) struct vtc_tst *tp; char *p; + extmacro_def("varnishd", "varnishd"); /* Default to path lookup */ + setbuf(stdout, NULL); setbuf(stderr, NULL); - while ((ch = getopt(argc, argv, "D:j:klLn:qt:v")) != -1) { + while ((ch = getopt(argc, argv, "D:ij:klLn:qt:v")) != -1) { switch (ch) { case 'D': if (!parse_D_opt(optarg)) { @@ -342,6 +343,10 @@ main(int argc, char * const *argv) exit(2); } break; + case 'i': + /* Look for varnishd relative to varnishtest */ + extmacro_def("varnishd", "../varnishd/varnishd"); + break; case 'j': npar = strtoul(optarg, NULL, 0); break; diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c index d416a5b..ad8605d 100644 --- a/bin/varnishtest/vtc_varnish.c +++ b/bin/varnishtest/vtc_varnish.c @@ -251,8 +251,8 @@ varnish_launch(struct varnish *v) vtc_log(v->vl, 2, "Launch"); vsb = vsb_new_auto(); AN(vsb); - vsb_printf(vsb, "cd ${topbuild}/bin/varnishd &&"); - vsb_printf(vsb, " ./varnishd -d -d -n %s", v->workdir); + vsb_printf(vsb, "cd ${pwd} &&"); + vsb_printf(vsb, " ${varnishd} -d -d -n %s", v->workdir); vsb_printf(vsb, " -l 10m,1m,-"); vsb_printf(vsb, " -p auto_restart=off"); vsb_printf(vsb, " -p syslog_cli_traffic=off"); From martin at varnish-cache.org Tue May 31 08:52:06 2011 From: martin at varnish-cache.org (Martin Blix Grydeland) Date: Tue, 31 May 2011 10:52:06 +0200 Subject: [master] 50a77ab Do proper non-blocking reads. Message-ID: commit 50a77ab0a92abf1e686611a0a25d241a2ecd14c0 Author: Martin Blix Grydeland Date: Tue May 31 10:50:30 2011 +0200 Do proper non-blocking reads. Spotted: drwilco Fixes: #914 diff --git a/lib/libvarnish/cli_common.c b/lib/libvarnish/cli_common.c index 4fa7429..0396e2a 100644 --- a/lib/libvarnish/cli_common.c +++ b/lib/libvarnish/cli_common.c @@ -123,12 +123,12 @@ read_tmo(int fd, char *ptr, unsigned len, double tmo) pfd.fd = fd; pfd.events = POLLIN; - i = poll(&pfd, 1, (int)(tmo * 1e3)); - if (i == 0) { - errno = ETIMEDOUT; - return (-1); - } for (j = 0; len > 0; ) { + i = poll(&pfd, 1, (int)(tmo * 1e3)); + if (i == 0) { + errno = ETIMEDOUT; + return (-1); + } i = read(fd, ptr, len); if (i < 0) return (i); From phk at varnish-cache.org Tue May 31 11:15:01 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 31 May 2011 13:15:01 +0200 Subject: [master] 0cfc718 Namespace cleanup FooArgv -> VAV_Foo Message-ID: commit 0cfc71874dc53dc0c7e3d822bee1bd3f2fe49774 Author: Poul-Henning Kamp Date: Tue May 31 07:54:22 2011 +0000 Namespace cleanup FooArgv -> VAV_Foo diff --git a/bin/varnishd/cache_hash.c b/bin/varnishd/cache_hash.c index 0b58581..457095b 100644 --- a/bin/varnishd/cache_hash.c +++ b/bin/varnishd/cache_hash.c @@ -738,7 +738,7 @@ HSH_config(const char *h_arg) const struct hash_slinger *hp; ASSERT_MGT(); - av = ParseArgv(h_arg, NULL, ARGV_COMMA); + av = VAV_Parse(h_arg, NULL, ARGV_COMMA); AN(av); if (av[0] != NULL) diff --git a/bin/varnishd/cache_vrt.c b/bin/varnishd/cache_vrt.c index 19aa575..91f995f 100644 --- a/bin/varnishd/cache_vrt.c +++ b/bin/varnishd/cache_vrt.c @@ -467,10 +467,10 @@ VRT_ban_string(struct sess *sp, const char *str) int i; (void)sp; - av = ParseArgv(str, NULL, ARGV_NOESC); + av = VAV_Parse(str, NULL, ARGV_NOESC); if (av[0] != NULL) { /* XXX: report error how ? */ - FreeArgv(av); + VAV_Free(av); return; } b = BAN_New(); @@ -500,7 +500,7 @@ VRT_ban_string(struct sess *sp, const char *str) BAN_Free(b); else BAN_Insert(b); - FreeArgv(av); + VAV_Free(av); } /*-------------------------------------------------------------------- diff --git a/bin/varnishd/mgt_param.c b/bin/varnishd/mgt_param.c index 7c2ccb1..7810212 100644 --- a/bin/varnishd/mgt_param.c +++ b/bin/varnishd/mgt_param.c @@ -354,7 +354,7 @@ tweak_listen_address(struct cli *cli, const struct parspec *par, return; } - av = ParseArgv(arg, NULL, ARGV_COMMA); + av = VAV_Parse(arg, NULL, ARGV_COMMA); if (av == NULL) { cli_out(cli, "Parse error: out of memory"); cli_result(cli, CLIS_PARAM); @@ -363,13 +363,13 @@ tweak_listen_address(struct cli *cli, const struct parspec *par, if (av[0] != NULL) { cli_out(cli, "Parse error: %s", av[0]); cli_result(cli, CLIS_PARAM); - FreeArgv(av); + VAV_Free(av); return; } if (av[1] == NULL) { cli_out(cli, "Empty listen address"); cli_result(cli, CLIS_PARAM); - FreeArgv(av); + VAV_Free(av); return; } VTAILQ_INIT(&lsh); @@ -395,7 +395,7 @@ tweak_listen_address(struct cli *cli, const struct parspec *par, } free(ta); } - FreeArgv(av); + VAV_Free(av); if (cli != NULL && cli->result != CLIS_OK) { clean_listen_sock_head(&lsh); return; diff --git a/bin/varnishd/mgt_shmem.c b/bin/varnishd/mgt_shmem.c index 81e5a4e..47a91c2 100644 --- a/bin/varnishd/mgt_shmem.c +++ b/bin/varnishd/mgt_shmem.c @@ -206,7 +206,7 @@ mgt_SHM_Init(const char *l_arg) if (l_arg == NULL) l_arg = ""; - av = ParseArgv(l_arg, NULL, ARGV_COMMA); + av = VAV_Parse(l_arg, NULL, ARGV_COMMA); AN(av); if (av[0] != NULL) ARGV_ERR("\t-l ...: %s", av[0]); @@ -253,7 +253,7 @@ mgt_SHM_Init(const char *l_arg) if (*ap != NULL) ARGV_ERR("\t-l ...: Too many sub-args\n"); - FreeArgv(av); + VAV_Free(av); size = s1 + s2; ps = getpagesize(); diff --git a/bin/varnishd/stevedore.c b/bin/varnishd/stevedore.c index dfde531..a14e011 100644 --- a/bin/varnishd/stevedore.c +++ b/bin/varnishd/stevedore.c @@ -438,9 +438,9 @@ STV_Config(const char *spec) p = strchr(spec, '='); q = strchr(spec, ','); if (p != NULL && (q == NULL || q > p)) { - av = ParseArgv(p + 1, NULL, ARGV_COMMA); + av = VAV_Parse(p + 1, NULL, ARGV_COMMA); } else { - av = ParseArgv(spec, NULL, ARGV_COMMA); + av = VAV_Parse(spec, NULL, ARGV_COMMA); p = NULL; } AN(av); diff --git a/bin/varnishd/varnishd.c b/bin/varnishd/varnishd.c index 74f8f3c..6e73d6c 100644 --- a/bin/varnishd/varnishd.c +++ b/bin/varnishd/varnishd.c @@ -185,7 +185,7 @@ tackle_warg(const char *argv) char **av; unsigned int u; - av = ParseArgv(argv, NULL, ARGV_COMMA); + av = VAV_Parse(argv, NULL, ARGV_COMMA); AN(av); if (av[0] != NULL) @@ -210,7 +210,7 @@ tackle_warg(const char *argv) params->wthread_timeout = u; } } - FreeArgv(av); + VAV_Free(av); } /*--------------------------------------------------------------------*/ diff --git a/bin/varnishtest/vtc.c b/bin/varnishtest/vtc.c index 2c54808..d8c98e9 100644 --- a/bin/varnishtest/vtc.c +++ b/bin/varnishtest/vtc.c @@ -244,7 +244,7 @@ parse_string(char *buf, const struct cmds *cmd, void *priv, struct vtclog *vl) if (*p == '"') break; if (*p == '\\') { - p += BackSlash(p, q) - 1; + p += VAV_BackSlash(p, q) - 1; q++; } else { if (*p == '\n') diff --git a/include/argv.h b/include/argv.h index 0aa7cef..4a7e809 100644 --- a/include/argv.h +++ b/include/argv.h @@ -28,10 +28,10 @@ * */ -void FreeArgv(char **argv); -char **ParseArgv(const char *s, int *argc, int flag); -char *BackSlashDecode(const char *s, const char *e); -int BackSlash(const char *s, char *res); +void VAV_Free(char **argv); +char **VAV_Parse(const char *s, int *argc, int flag); +char *VAV_BackSlashDecode(const char *s, const char *e); +int VAV_BackSlash(const char *s, char *res); #define ARGV_COMMENT (1 << 0) #define ARGV_COMMA (1 << 1) #define ARGV_NOESC (1 << 2) diff --git a/lib/libvarnish/argv.c b/lib/libvarnish/argv.c index 7fbf95c..3fb2840 100644 --- a/lib/libvarnish/argv.c +++ b/lib/libvarnish/argv.c @@ -26,13 +26,13 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * const char **ParseArgv(const char *s, int comment) + * const char **VAV_Parse(const char *s, int comment) * Parse a command like line into an argv[] * Index zero contains NULL or an error message * "double quotes" and backslash substitution is handled. * - * void FreeArgv(const char **argv) - * Free the result of ParseArgv() + * void VAV_Free(const char **argv) + * Free the result of VAV_Parse() * */ @@ -46,7 +46,7 @@ #include "libvarnish.h" int -BackSlash(const char *s, char *res) +VAV_BackSlash(const char *s, char *res) { int r; char c; @@ -102,7 +102,7 @@ BackSlash(const char *s, char *res) } char * -BackSlashDecode(const char *s, const char *e) +VAV_BackSlashDecode(const char *s, const char *e) { const char *q; char *p, *r; @@ -119,7 +119,7 @@ BackSlashDecode(const char *s, const char *e) *r++ = *q++; continue; } - i = BackSlash(q, r); + i = VAV_BackSlash(q, r); q += i; r++; } @@ -131,7 +131,7 @@ static char err_invalid_backslash[] = "Invalid backslash sequence"; static char err_missing_quote[] = "Missing '\"'"; char ** -ParseArgv(const char *s, int *argc, int flag) +VAV_Parse(const char *s, int *argc, int flag) { char **argv; const char *p; @@ -163,7 +163,7 @@ ParseArgv(const char *s, int *argc, int flag) } while (1) { if (*s == '\\' && !(flag & ARGV_NOESC)) { - i = BackSlash(s, NULL); + i = VAV_BackSlash(s, NULL); if (i == 0) { argv[0] = err_invalid_backslash; return (argv); @@ -198,7 +198,7 @@ ParseArgv(const char *s, int *argc, int flag) argv[nargv][s - p] = '\0'; nargv++; } else { - argv[nargv++] = BackSlashDecode(p, s); + argv[nargv++] = VAV_BackSlashDecode(p, s); } if (*s != '\0') s++; @@ -210,7 +210,7 @@ ParseArgv(const char *s, int *argc, int flag) } void -FreeArgv(char **argv) +VAV_Free(char **argv) { int i; @@ -224,7 +224,7 @@ FreeArgv(char **argv) #include static void -PrintArgv(char **argv) +VAV_Print(char **argv) { int i; @@ -241,8 +241,8 @@ Test(const char *str) char **av; printf("Test: <%V>\n", str); - av = ParseArgv(str, 0); - PrintArgv(av); + av = VAV_Parse(str, 0); + VAV_Print(av); } int diff --git a/lib/libvarnish/cli_serve.c b/lib/libvarnish/cli_serve.c index c464de1..8dd8503 100644 --- a/lib/libvarnish/cli_serve.c +++ b/lib/libvarnish/cli_serve.c @@ -323,11 +323,11 @@ cls_vlu(void *priv, const char *p) return (0); REPLACE(cli->cmd, p); - av = ParseArgv(p, NULL, 0); + av = VAV_Parse(p, NULL, 0); AN(av); if (av[0] != NULL) { i = cls_vlu2(priv, av); - FreeArgv(av); + VAV_Free(av); free(cli->cmd); cli->cmd = NULL; return (i); @@ -336,7 +336,7 @@ cls_vlu(void *priv, const char *p) continue; if (i < 3 || cli->auth == 0 || strcmp(av[i - 2], "<<")) { i = cls_vlu2(priv, av); - FreeArgv(av); + VAV_Free(av); free(cli->cmd); cli->cmd = NULL; return (i); @@ -363,7 +363,7 @@ cls_vlu(void *priv, const char *p) cfd->argv[cfd->last_idx] = VSB_data(cfd->last_arg); i = cls_vlu2(priv, cfd->argv); cfd->argv[cfd->last_idx] = NULL; - FreeArgv(cfd->argv); + VAV_Free(cfd->argv); cfd->argv = NULL; free(cli->cmd); cli->cmd = NULL; diff --git a/lib/libvarnishapi/vsc.c b/lib/libvarnishapi/vsc.c index d47584f..1187767 100644 --- a/lib/libvarnishapi/vsc.c +++ b/lib/libvarnishapi/vsc.c @@ -123,7 +123,7 @@ vsc_sf_arg(const struct VSM_data *vd, const char *opt) vsc->sf_init = 1; } - av = ParseArgv(opt, NULL, ARGV_COMMA); + av = VAV_Parse(opt, NULL, ARGV_COMMA); AN(av); if (av[0] != NULL) { vd->diag(vd->priv, "Parse error: %s", av[0]); @@ -183,7 +183,7 @@ vsc_sf_arg(const struct VSM_data *vd, const char *opt) } } } - FreeArgv(av); + VAV_Free(av); return (1); } From phk at varnish-cache.org Tue May 31 11:15:02 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 31 May 2011 13:15:02 +0200 Subject: [master] 0bf86e4 Rename argv.h to vav.h Message-ID: commit 0bf86e4bb63ba19b39c4448f6c8bcbc802e2ba38 Author: Poul-Henning Kamp Date: Tue May 31 08:00:48 2011 +0000 Rename argv.h to vav.h diff --git a/include/Makefile.am b/include/Makefile.am index 29ddec3..6835d0f 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -10,7 +10,6 @@ pkginclude_HEADERS = \ varnishapi.h nobase_noinst_HEADERS = \ - argv.h \ ban_vars.h \ binary_heap.h \ cli.h \ @@ -28,6 +27,7 @@ nobase_noinst_HEADERS = \ miniobj.h \ persistent.h \ vas.h \ + vav.h \ vsha256.h \ vqueue.h \ vpf.h \ diff --git a/include/argv.h b/include/argv.h deleted file mode 100644 index 4a7e809..0000000 --- a/include/argv.h +++ /dev/null @@ -1,37 +0,0 @@ -/*- - * Copyright (c) 2006 Verdens Gang AS - * Copyright (c) 2006-2009 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. - * - */ - -void VAV_Free(char **argv); -char **VAV_Parse(const char *s, int *argc, int flag); -char *VAV_BackSlashDecode(const char *s, const char *e); -int VAV_BackSlash(const char *s, char *res); -#define ARGV_COMMENT (1 << 0) -#define ARGV_COMMA (1 << 1) -#define ARGV_NOESC (1 << 2) diff --git a/include/libvarnish.h b/include/libvarnish.h index 039e373..ee20a54 100644 --- a/include/libvarnish.h +++ b/include/libvarnish.h @@ -41,7 +41,7 @@ struct vsb; -#include "argv.h" +#include "vav.h" /* from libvarnish/num.c */ const char *str2bytes(const char *p, uintmax_t *r, uintmax_t rel); diff --git a/include/vav.h b/include/vav.h new file mode 100644 index 0000000..4a7e809 --- /dev/null +++ b/include/vav.h @@ -0,0 +1,37 @@ +/*- + * Copyright (c) 2006 Verdens Gang AS + * Copyright (c) 2006-2009 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. + * + */ + +void VAV_Free(char **argv); +char **VAV_Parse(const char *s, int *argc, int flag); +char *VAV_BackSlashDecode(const char *s, const char *e); +int VAV_BackSlash(const char *s, char *res); +#define ARGV_COMMENT (1 << 0) +#define ARGV_COMMA (1 << 1) +#define ARGV_NOESC (1 << 2) diff --git a/lib/libvarnishapi/vsc.c b/lib/libvarnishapi/vsc.c index 1187767..2902e13 100644 --- a/lib/libvarnishapi/vsc.c +++ b/lib/libvarnishapi/vsc.c @@ -35,9 +35,9 @@ #include #include "vas.h" +#include "vav.h" #include "vsm.h" #include "vsc.h" -#include "argv.h" #include "vqueue.h" #include "miniobj.h" #include "varnishapi.h" From phk at varnish-cache.org Tue May 31 11:15:02 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 31 May 2011 13:15:02 +0200 Subject: [master] 9787e41 Namespace cleanup: vpf_* VPF_* Message-ID: commit 9787e415b0c28ff9b2fd567db23eed6badfbfc7f Author: Poul-Henning Kamp Date: Tue May 31 08:05:59 2011 +0000 Namespace cleanup: vpf_* VPF_* diff --git a/bin/varnishd/varnishd.c b/bin/varnishd/varnishd.c index 6e73d6c..a6030d4 100644 --- a/bin/varnishd/varnishd.c +++ b/bin/varnishd/varnishd.c @@ -354,7 +354,7 @@ main(int argc, char * const *argv) const char *T_arg = NULL; char *p, *vcl = NULL; struct cli cli[1]; - struct pidfh *pfh = NULL; + struct vpf_fh *pfh = NULL; char *dirname; /* @@ -590,7 +590,7 @@ main(int argc, char * const *argv) } /* XXX: should this be relative to the -n arg ? */ - if (P_arg && (pfh = vpf_open(P_arg, 0644, NULL)) == NULL) { + if (P_arg && (pfh = VPF_Open(P_arg, 0644, NULL)) == NULL) { perror(P_arg); exit(1); } @@ -620,7 +620,7 @@ main(int argc, char * const *argv) mgt_SHM_Pid(); - if (pfh != NULL && vpf_write(pfh)) + if (pfh != NULL && VPF_Write(pfh)) fprintf(stderr, "NOTE: Could not write PID file\n"); if (d_flag) @@ -647,6 +647,6 @@ main(int argc, char * const *argv) MGT_Run(); if (pfh != NULL) - (void)vpf_remove(pfh); + (void)VPF_Remove(pfh); exit(exit_status); } diff --git a/bin/varnishlog/varnishlog.c b/bin/varnishlog/varnishlog.c index ddfff39..2064ef9 100644 --- a/bin/varnishlog/varnishlog.c +++ b/bin/varnishlog/varnishlog.c @@ -277,7 +277,7 @@ main(int argc, char * const *argv) int a_flag = 0, D_flag = 0, O_flag = 0, u_flag = 0, m_flag = 0; const char *P_arg = NULL; const char *w_arg = NULL; - struct pidfh *pfh = NULL; + struct vpf_fh *pfh = NULL; struct VSM_data *vd; vd = VSM_New(); @@ -334,7 +334,7 @@ main(int argc, char * const *argv) if (VSL_Open(vd, 1)) exit(1); - if (P_arg && (pfh = vpf_open(P_arg, 0644, NULL)) == NULL) { + if (P_arg && (pfh = VPF_Open(P_arg, 0644, NULL)) == NULL) { perror(P_arg); exit(1); } @@ -342,12 +342,12 @@ main(int argc, char * const *argv) if (D_flag && varnish_daemon(0, 0) == -1) { perror("daemon()"); if (pfh != NULL) - vpf_remove(pfh); + VPF_Remove(pfh); exit(1); } if (pfh != NULL) - vpf_write(pfh); + VPF_Write(pfh); if (w_arg != NULL) do_write(vd, w_arg, a_flag); @@ -366,6 +366,6 @@ main(int argc, char * const *argv) } if (pfh != NULL) - vpf_remove(pfh); + VPF_Remove(pfh); exit(0); } diff --git a/bin/varnishncsa/varnishncsa.c b/bin/varnishncsa/varnishncsa.c index 022d955..26279ff 100644 --- a/bin/varnishncsa/varnishncsa.c +++ b/bin/varnishncsa/varnishncsa.c @@ -722,7 +722,7 @@ main(int argc, char *argv[]) int a_flag = 0, D_flag = 0, format_flag = 0; const char *P_arg = NULL; const char *w_arg = NULL; - struct pidfh *pfh = NULL; + struct vpf_fh *pfh = NULL; FILE *of; format = "%h %l %u %t \"%r\" %s %b \"%{Referer}i\" \"%{User-agent}i\""; @@ -791,7 +791,7 @@ main(int argc, char *argv[]) if (VSL_Open(vd, 1)) exit(1); - if (P_arg && (pfh = vpf_open(P_arg, 0644, NULL)) == NULL) { + if (P_arg && (pfh = VPF_Open(P_arg, 0644, NULL)) == NULL) { perror(P_arg); exit(1); } @@ -799,12 +799,12 @@ main(int argc, char *argv[]) if (D_flag && varnish_daemon(0, 0) == -1) { perror("daemon()"); if (pfh != NULL) - vpf_remove(pfh); + VPF_Remove(pfh); exit(1); } if (pfh != NULL) - vpf_write(pfh); + VPF_Write(pfh); if (w_arg) { of = open_log(w_arg, a_flag); diff --git a/include/vpf.h b/include/vpf.h index 8845ee7..822f2d3 100644 --- a/include/vpf.h +++ b/include/vpf.h @@ -30,11 +30,11 @@ #ifndef VPF_H_INCLUDED #define VPF_H_INCLUDED -struct pidfh; +struct vpf_fh; -struct pidfh *vpf_open(const char *path, mode_t mode, pid_t *pidptr); -int vpf_write(struct pidfh *pfh); -int vpf_close(struct pidfh *pfh); -int vpf_remove(struct pidfh *pfh); +struct vpf_fh *VPF_Open(const char *path, mode_t mode, pid_t *pidptr); +int VPF_Write(struct vpf_fh *pfh); +int VPF_Close(struct vpf_fh *pfh); +int VPF_Remove(struct vpf_fh *pfh); #endif diff --git a/lib/libvarnish/vpf.c b/lib/libvarnish/vpf.c index 641fbb9..c35b3cd 100644 --- a/lib/libvarnish/vpf.c +++ b/lib/libvarnish/vpf.c @@ -43,17 +43,17 @@ #include "flopen.h" #include "vpf.h" -struct pidfh { +struct vpf_fh { int pf_fd; char pf_path[MAXPATHLEN + 1]; dev_t pf_dev; ino_t pf_ino; }; -static int _vpf_remove(struct pidfh *pfh, int freeit); +static int _VPF_Remove(struct vpf_fh *pfh, int freeit); static int -vpf_verify(const struct pidfh *pfh) +vpf_verify(const struct vpf_fh *pfh) { struct stat sb; @@ -93,10 +93,10 @@ vpf_read(const char *path, pid_t *pidptr) return (0); } -struct pidfh * -vpf_open(const char *path, mode_t mode, pid_t *pidptr) +struct vpf_fh * +VPF_Open(const char *path, mode_t mode, pid_t *pidptr) { - struct pidfh *pfh; + struct vpf_fh *pfh; struct stat sb; int error, fd, len; @@ -124,8 +124,8 @@ vpf_open(const char *path, mode_t mode, pid_t *pidptr) /* * Open the PID file and obtain exclusive lock. * We truncate PID file here only to remove old PID immediatelly, - * PID file will be truncated again in vpf_write(), so - * vpf_write() can be called multiple times. + * PID file will be truncated again in VPF_Write(), so + * VPF_Write() can be called multiple times. */ fd = flopen(pfh->pf_path, O_WRONLY | O_CREAT | O_TRUNC | O_NONBLOCK, mode); @@ -139,7 +139,7 @@ vpf_open(const char *path, mode_t mode, pid_t *pidptr) return (NULL); } /* - * Remember file information, so in vpf_write() we are sure we write + * Remember file information, so in VPF_Write() we are sure we write * to the proper descriptor. */ if (fstat(fd, &sb) == -1) { @@ -159,7 +159,7 @@ vpf_open(const char *path, mode_t mode, pid_t *pidptr) } int -vpf_write(struct pidfh *pfh) +VPF_Write(struct vpf_fh *pfh) { char pidstr[16]; int error, fd; @@ -178,11 +178,11 @@ vpf_write(struct pidfh *pfh) fd = pfh->pf_fd; /* - * Truncate PID file, so multiple calls of vpf_write() are allowed. + * Truncate PID file, so multiple calls of VPF_Write() are allowed. */ if (ftruncate(fd, 0) == -1) { error = errno; - (void)_vpf_remove(pfh, 0); + (void)_VPF_Remove(pfh, 0); errno = error; return (-1); } @@ -191,7 +191,7 @@ vpf_write(struct pidfh *pfh) assert(error < sizeof pidstr); if (pwrite(fd, pidstr, strlen(pidstr), 0) != (ssize_t)strlen(pidstr)) { error = errno; - (void)_vpf_remove(pfh, 0); + (void)_VPF_Remove(pfh, 0); errno = error; return (-1); } @@ -200,7 +200,7 @@ vpf_write(struct pidfh *pfh) } int -vpf_close(struct pidfh *pfh) +VPF_Close(struct vpf_fh *pfh) { int error; @@ -221,7 +221,7 @@ vpf_close(struct pidfh *pfh) } static int -_vpf_remove(struct pidfh *pfh, int freeit) +_VPF_Remove(struct vpf_fh *pfh, int freeit) { int error; @@ -249,8 +249,8 @@ _vpf_remove(struct pidfh *pfh, int freeit) } int -vpf_remove(struct pidfh *pfh) +VPF_Remove(struct vpf_fh *pfh) { - return (_vpf_remove(pfh, 1)); + return (_VPF_Remove(pfh, 1)); } From phk at varnish-cache.org Tue May 31 11:15:02 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 31 May 2011 13:15:02 +0200 Subject: [master] e1d2d67 Namespace cleanup: base64_* -> VB64_* Message-ID: commit e1d2d67c9fc94d288d2851c987b59f9016375439 Author: Poul-Henning Kamp Date: Tue May 31 08:14:23 2011 +0000 Namespace cleanup: base64_* -> VB64_* diff --git a/bin/varnishncsa/varnishncsa.c b/bin/varnishncsa/varnishncsa.c index 26279ff..dc2d927 100644 --- a/bin/varnishncsa/varnishncsa.c +++ b/bin/varnishncsa/varnishncsa.c @@ -608,11 +608,11 @@ h_ncsa(void *priv, enum vsl_tag tag, unsigned fd, char *rubuf; size_t rulen; - base64_init(); + VB64_init(); rulen = ((strlen(lp->df_u) + 3) * 4) / 3; rubuf = malloc(rulen); assert(rubuf != NULL); - base64_decode(rubuf, rulen, lp->df_u); + VB64_decode(rubuf, rulen, lp->df_u); q = strchr(rubuf, ':'); if (q != NULL) *q = '\0'; diff --git a/include/varnishapi.h b/include/varnishapi.h index 230bdbb..dbb3931 100644 --- a/include/varnishapi.h +++ b/include/varnishapi.h @@ -264,7 +264,7 @@ extern const char *VSL_tags[256]; /* base64.c */ -void base64_init(void); -int base64_decode(char *d, unsigned dlen, const char *s); +void VB64_init(void); +int VB64_decode(char *d, unsigned dlen, const char *s); #endif diff --git a/lib/libvarnishapi/base64.c b/lib/libvarnishapi/base64.c index f55199d..4ff88ce 100644 --- a/lib/libvarnishapi/base64.c +++ b/lib/libvarnishapi/base64.c @@ -15,7 +15,7 @@ static const char b64[] = static char i64[256]; void -base64_init(void) +VB64_init(void) { int i; const char *p; @@ -28,7 +28,7 @@ base64_init(void) } int -base64_decode(char *d, unsigned dlen, const char *s) +VB64_decode(char *d, unsigned dlen, const char *s) { unsigned u, v, l; int i; @@ -78,9 +78,9 @@ main(int argc, char **argv) (void)argc; (void)argv; - base64_init(); + VB64_init(); l = sizeof buf; - base64_decode(buf, &l, test1); + VB64_decode(buf, &l, test1); printf("%s\n", buf); return (0); } From phk at varnish-cache.org Tue May 31 11:15:02 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 31 May 2011 13:15:02 +0200 Subject: [master] 9192fc9 Namespace cleanup: CLS_ -> VCLS_ Message-ID: commit 9192fc9603ad9ff70d299cdf996009375e38f816 Author: Poul-Henning Kamp Date: Tue May 31 08:18:09 2011 +0000 Namespace cleanup: CLS_ -> VCLS_ diff --git a/bin/varnishd/cache_cli.c b/bin/varnishd/cache_cli.c index 50538d7..3d6ddd2 100644 --- a/bin/varnishd/cache_cli.c +++ b/bin/varnishd/cache_cli.c @@ -75,7 +75,7 @@ CLI_AddFuncs(struct cli_proto *p) AZ(add_check); Lck_Lock(&cli_mtx); - AZ(CLS_AddFunc(cls, 0, p)); + AZ(VCLS_AddFunc(cls, 0, p)); Lck_Unlock(&cli_mtx); } @@ -107,10 +107,10 @@ CLI_Run(void) add_check = 1; - AN(CLS_AddFd(cls, heritage.cli_in, heritage.cli_out, NULL, NULL)); + AN(VCLS_AddFd(cls, heritage.cli_in, heritage.cli_out, NULL, NULL)); do { - i = CLS_Poll(cls, -1); + i = VCLS_Poll(cls, -1); } while(i > 0); VSL(SLT_CLI, 0, "EOF on CLI connection, worker stops"); VCA_Shutdown(); @@ -157,8 +157,8 @@ ccf_panic(struct cli *cli, const char * const *av, void *priv) /*--------------------------------------------------------------------*/ static struct cli_proto master_cmds[] = { - { CLI_PING, "i", CLS_func_ping }, - { CLI_HELP, "i", CLS_func_help }, + { CLI_PING, "i", VCLS_func_ping }, + { CLI_HELP, "i", VCLS_func_help }, { "debug.sizeof", "debug.sizeof", "\tDump sizeof various data structures\n", 0, 0, "d", cli_debug_sizeof }, @@ -179,7 +179,7 @@ CLI_Init(void) Lck_New(&cli_mtx, lck_cli); cli_thread = pthread_self(); - cls = CLS_New(cli_cb_before, cli_cb_after, params->cli_buffer); + cls = VCLS_New(cli_cb_before, cli_cb_after, params->cli_buffer); AN(cls); CLI_AddFuncs(master_cmds); diff --git a/bin/varnishd/cache_vcl.c b/bin/varnishd/cache_vcl.c index e851f06..900f4ea 100644 --- a/bin/varnishd/cache_vcl.c +++ b/bin/varnishd/cache_vcl.c @@ -47,7 +47,7 @@ struct vcls { unsigned magic; -#define VCLS_MAGIC 0x214188f2 +#define VVCLS_MAGIC 0x214188f2 VTAILQ_ENTRY(vcls) list; char *name; void *dlh; @@ -145,7 +145,7 @@ VCL_Load(const char *fn, const char *name, struct cli *cli) return (1); } - ALLOC_OBJ(vcl, VCLS_MAGIC); + ALLOC_OBJ(vcl, VVCLS_MAGIC); XXXAN(vcl); vcl->dlh = dlopen(fn, RTLD_NOW | RTLD_LOCAL); diff --git a/bin/varnishd/mgt_cli.c b/bin/varnishd/mgt_cli.c index d5c7fe0..7923ba4 100644 --- a/bin/varnishd/mgt_cli.c +++ b/bin/varnishd/mgt_cli.c @@ -305,10 +305,10 @@ mcf_auth(struct cli *cli, const char *const *av, void *priv) } static struct cli_proto cli_auth[] = { - { CLI_HELP, "", CLS_func_help, NULL }, - { CLI_PING, "", CLS_func_ping }, + { CLI_HELP, "", VCLS_func_help, NULL }, + { CLI_PING, "", VCLS_func_ping }, { CLI_AUTH, "", mcf_auth, NULL }, - { CLI_QUIT, "", CLS_func_close, NULL}, + { CLI_QUIT, "", VCLS_func_close, NULL}, { NULL } }; @@ -336,13 +336,13 @@ static void mgt_cli_init_cls(void) { - cls = CLS_New(mgt_cli_cb_before, mgt_cli_cb_after, params->cli_buffer); + cls = VCLS_New(mgt_cli_cb_before, mgt_cli_cb_after, params->cli_buffer); AN(cls); - AZ(CLS_AddFunc(cls, MCF_NOAUTH, cli_auth)); - AZ(CLS_AddFunc(cls, MCF_AUTH, cli_proto)); - AZ(CLS_AddFunc(cls, MCF_AUTH, cli_debug)); - AZ(CLS_AddFunc(cls, MCF_AUTH, cli_stv)); - AZ(CLS_AddFunc(cls, MCF_AUTH, cli_askchild)); + AZ(VCLS_AddFunc(cls, MCF_NOAUTH, cli_auth)); + AZ(VCLS_AddFunc(cls, MCF_AUTH, cli_proto)); + AZ(VCLS_AddFunc(cls, MCF_AUTH, cli_debug)); + AZ(VCLS_AddFunc(cls, MCF_AUTH, cli_stv)); + AZ(VCLS_AddFunc(cls, MCF_AUTH, cli_askchild)); } /*-------------------------------------------------------------------- @@ -353,7 +353,7 @@ void mgt_cli_close_all(void) { - CLS_Destroy(&cls); + VCLS_Destroy(&cls); } /*-------------------------------------------------------------------- @@ -367,7 +367,7 @@ mgt_cli_callback2(const struct vev *e, int what) (void)e; (void)what; - i = CLS_PollFd(cls, e->fd, 0); + i = VCLS_PollFd(cls, e->fd, 0); return (i); } @@ -384,7 +384,7 @@ mgt_cli_setup(int fdi, int fdo, int verbose, const char *ident, mgt_cli_close_f if (cls == NULL) mgt_cli_init_cls(); - cli = CLS_AddFd(cls, fdi, fdo, closefunc, priv); + cli = VCLS_AddFd(cls, fdi, fdo, closefunc, priv); cli->ident = strdup(ident); diff --git a/include/cli_serve.h b/include/cli_serve.h index d834b4d..9f6a645 100644 --- a/include/cli_serve.h +++ b/include/cli_serve.h @@ -30,16 +30,16 @@ struct cls; typedef void cls_cb_f(void *priv); typedef void cls_cbc_f(const struct cli*); -struct cls *CLS_New(cls_cbc_f *before, cls_cbc_f *after, unsigned maxlen); -struct cli *CLS_AddFd(struct cls *cs, int fdi, int fdo, cls_cb_f *closefunc, +struct cls *VCLS_New(cls_cbc_f *before, cls_cbc_f *after, unsigned maxlen); +struct cli *VCLS_AddFd(struct cls *cs, int fdi, int fdo, cls_cb_f *closefunc, void *priv); -int CLS_AddFunc(struct cls *cs, unsigned auth, struct cli_proto *clp); -int CLS_Poll(struct cls *cs, int timeout); -int CLS_PollFd(struct cls *cs, int fd, int timeout); -void CLS_Destroy(struct cls **); +int VCLS_AddFunc(struct cls *cs, unsigned auth, struct cli_proto *clp); +int VCLS_Poll(struct cls *cs, int timeout); +int VCLS_PollFd(struct cls *cs, int fd, int timeout); +void VCLS_Destroy(struct cls **); /* From libvarnish/cli.c */ -cli_func_t CLS_func_close; -cli_func_t CLS_func_help; -cli_func_t CLS_func_ping; +cli_func_t VCLS_func_close; +cli_func_t VCLS_func_help; +cli_func_t VCLS_func_ping; diff --git a/lib/libvarnish/cli_serve.c b/lib/libvarnish/cli_serve.c index 8dd8503..86cb893 100644 --- a/lib/libvarnish/cli_serve.c +++ b/lib/libvarnish/cli_serve.c @@ -50,7 +50,7 @@ struct cls_func { unsigned magic; -#define CLS_FUNC_MAGIC 0x7d280c9b +#define VCLS_FUNC_MAGIC 0x7d280c9b VTAILQ_ENTRY(cls_func) list; unsigned auth; struct cli_proto *clp; @@ -58,7 +58,7 @@ struct cls_func { struct cls_fd { unsigned magic; -#define CLS_FD_MAGIC 0x010dbd1e +#define VCLS_FD_MAGIC 0x010dbd1e VTAILQ_ENTRY(cls_fd) list; int fdi, fdo; struct cls *cls; @@ -72,7 +72,7 @@ struct cls_fd { struct cls { unsigned magic; -#define CLS_MAGIC 0x60f044a3 +#define VCLS_MAGIC 0x60f044a3 VTAILQ_HEAD(,cls_fd) fds; unsigned nfd; VTAILQ_HEAD(,cls_func) funcs; @@ -83,7 +83,7 @@ struct cls { /*--------------------------------------------------------------------*/ void -CLS_func_close(struct cli *cli, const char *const *av, void *priv) +VCLS_func_close(struct cli *cli, const char *const *av, void *priv) { (void)av; @@ -95,7 +95,7 @@ CLS_func_close(struct cli *cli, const char *const *av, void *priv) /*--------------------------------------------------------------------*/ void -CLS_func_ping(struct cli *cli, const char * const *av, void *priv) +VCLS_func_ping(struct cli *cli, const char * const *av, void *priv) { time_t t; @@ -108,7 +108,7 @@ CLS_func_ping(struct cli *cli, const char * const *av, void *priv) /*--------------------------------------------------------------------*/ void -CLS_func_help(struct cli *cli, const char * const *av, void *priv) +VCLS_func_help(struct cli *cli, const char * const *av, void *priv) { struct cli_proto *cp; struct cls_func *cfn; @@ -117,7 +117,7 @@ CLS_func_help(struct cli *cli, const char * const *av, void *priv) (void)priv; cs = cli->cls; - CHECK_OBJ_NOTNULL(cs, CLS_MAGIC); + CHECK_OBJ_NOTNULL(cs, VCLS_MAGIC); if (av[2] == NULL) { all = debug = 0; @@ -242,9 +242,9 @@ cls_vlu2(void *priv, char * const *av) struct cli *cli; unsigned na; - CAST_OBJ_NOTNULL(cfd, priv, CLS_FD_MAGIC); + CAST_OBJ_NOTNULL(cfd, priv, VCLS_FD_MAGIC); cs = cfd->cls; - CHECK_OBJ_NOTNULL(cs, CLS_MAGIC); + CHECK_OBJ_NOTNULL(cs, VCLS_MAGIC); cli = cfd->cli; CHECK_OBJ_NOTNULL(cli, CLI_MAGIC); @@ -307,7 +307,7 @@ cls_vlu(void *priv, const char *p) int i; char **av; - CAST_OBJ_NOTNULL(cfd, priv, CLS_FD_MAGIC); + CAST_OBJ_NOTNULL(cfd, priv, VCLS_FD_MAGIC); cli = cfd->cli; CHECK_OBJ_NOTNULL(cli, CLI_MAGIC); @@ -375,11 +375,11 @@ cls_vlu(void *priv, const char *p) } struct cls * -CLS_New(cls_cbc_f *before, cls_cbc_f *after, unsigned maxlen) +VCLS_New(cls_cbc_f *before, cls_cbc_f *after, unsigned maxlen) { struct cls *cs; - ALLOC_OBJ(cs, CLS_MAGIC); + ALLOC_OBJ(cs, VCLS_MAGIC); AN(cs); VTAILQ_INIT(&cs->fds); VTAILQ_INIT(&cs->funcs); @@ -390,14 +390,14 @@ CLS_New(cls_cbc_f *before, cls_cbc_f *after, unsigned maxlen) } struct cli * -CLS_AddFd(struct cls *cs, int fdi, int fdo, cls_cb_f *closefunc, void *priv) +VCLS_AddFd(struct cls *cs, int fdi, int fdo, cls_cb_f *closefunc, void *priv) { struct cls_fd *cfd; - CHECK_OBJ_NOTNULL(cs, CLS_MAGIC); + CHECK_OBJ_NOTNULL(cs, VCLS_MAGIC); assert(fdi >= 0); assert(fdo >= 0); - ALLOC_OBJ(cfd, CLS_FD_MAGIC); + ALLOC_OBJ(cfd, VCLS_FD_MAGIC); AN(cfd); cfd->cls = cs; cfd->fdi = fdi; @@ -418,8 +418,8 @@ static void cls_close_fd(struct cls *cs, struct cls_fd *cfd) { - CHECK_OBJ_NOTNULL(cs, CLS_MAGIC); - CHECK_OBJ_NOTNULL(cfd, CLS_FD_MAGIC); + CHECK_OBJ_NOTNULL(cs, VCLS_MAGIC); + CHECK_OBJ_NOTNULL(cfd, VCLS_FD_MAGIC); VTAILQ_REMOVE(&cs->fds, cfd, list); cs->nfd--; @@ -439,12 +439,12 @@ cls_close_fd(struct cls *cs, struct cls_fd *cfd) int -CLS_AddFunc(struct cls *cs, unsigned auth, struct cli_proto *clp) +VCLS_AddFunc(struct cls *cs, unsigned auth, struct cli_proto *clp) { struct cls_func *cfn; - CHECK_OBJ_NOTNULL(cs, CLS_MAGIC); - ALLOC_OBJ(cfn, CLS_FUNC_MAGIC); + CHECK_OBJ_NOTNULL(cs, VCLS_MAGIC); + ALLOC_OBJ(cfn, VCLS_FUNC_MAGIC); AN(cfn); cfn->clp = clp; cfn->auth = auth; @@ -453,13 +453,13 @@ CLS_AddFunc(struct cls *cs, unsigned auth, struct cli_proto *clp) } int -CLS_PollFd(struct cls *cs, int fd, int timeout) +VCLS_PollFd(struct cls *cs, int fd, int timeout) { struct cls_fd *cfd; struct pollfd pfd[1]; int i, j, k; - CHECK_OBJ_NOTNULL(cs, CLS_MAGIC); + CHECK_OBJ_NOTNULL(cs, VCLS_MAGIC); if (cs->nfd == 0) { errno = 0; return (-1); @@ -477,7 +477,7 @@ CLS_PollFd(struct cls *cs, int fd, int timeout) break; } assert(i == 1); - CHECK_OBJ_NOTNULL(cfd, CLS_FD_MAGIC); + CHECK_OBJ_NOTNULL(cfd, VCLS_FD_MAGIC); j = poll(pfd, 1, timeout); if (j <= 0) @@ -492,12 +492,12 @@ CLS_PollFd(struct cls *cs, int fd, int timeout) } int -CLS_Poll(struct cls *cs, int timeout) +VCLS_Poll(struct cls *cs, int timeout) { struct cls_fd *cfd, *cfd2; int i, j, k; - CHECK_OBJ_NOTNULL(cs, CLS_MAGIC); + CHECK_OBJ_NOTNULL(cs, VCLS_MAGIC); if (cs->nfd == 0) { errno = 0; return (-1); @@ -535,7 +535,7 @@ CLS_Poll(struct cls *cs, int timeout) } void -CLS_Destroy(struct cls **csp) +VCLS_Destroy(struct cls **csp) { struct cls *cs; struct cls_fd *cfd, *cfd2; @@ -543,7 +543,7 @@ CLS_Destroy(struct cls **csp) cs = *csp; *csp = NULL; - CHECK_OBJ_NOTNULL(cs, CLS_MAGIC); + CHECK_OBJ_NOTNULL(cs, VCLS_MAGIC); VTAILQ_FOREACH_SAFE(cfd, &cs->fds, list, cfd2) cls_close_fd(cs, cfd); From phk at varnish-cache.org Tue May 31 11:15:03 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 31 May 2011 13:15:03 +0200 Subject: [master] 50002cc Namespace cleanup: vas_fail -> VAS_Fail Message-ID: commit 50002cc1fcff62d3a0d4366e4a33c93cd8271d58 Author: Poul-Henning Kamp Date: Tue May 31 09:30:47 2011 +0000 Namespace cleanup: vas_fail -> VAS_Fail diff --git a/bin/varnishd/cache_panic.c b/bin/varnishd/cache_panic.c index 66e13c0..22a7fff 100644 --- a/bin/varnishd/cache_panic.c +++ b/bin/varnishd/cache_panic.c @@ -364,7 +364,7 @@ void PAN_Init(void) { - vas_fail = pan_ic; + VAS_Fail = pan_ic; vsp = &vsps; AN(VSB_new(vsp, vsm_head->panicstr, sizeof vsm_head->panicstr, VSB_FIXEDLEN)); diff --git a/bin/varnishd/cache_vrt.c b/bin/varnishd/cache_vrt.c index 91f995f..293b072 100644 --- a/bin/varnishd/cache_vrt.c +++ b/bin/varnishd/cache_vrt.c @@ -386,7 +386,7 @@ VRT_panic(const struct sess *sp, const char *str, ...) va_start(ap, str); b = VRT_String(sp->http->ws, "PANIC: ", str, ap); va_end(ap); - vas_fail("VCL", "", 0, b, 0, 2); + VAS_Fail("VCL", "", 0, b, 0, 2); } /*--------------------------------------------------------------------*/ diff --git a/bin/varnishtest/vtc_log.c b/bin/varnishtest/vtc_log.c index 8ad19e0..c92f13e 100644 --- a/bin/varnishtest/vtc_log.c +++ b/bin/varnishtest/vtc_log.c @@ -274,7 +274,7 @@ vtc_hexdump(struct vtclog *vl, unsigned lvl, const char *pfx, const unsigned cha /**********************************************************************/ static void -vtc_log_vas_fail(const char *func, const char *file, int line, +vtc_log_VAS_Fail(const char *func, const char *file, int line, const char *cond, int err, int xxx) { struct vtclog *vl; @@ -293,4 +293,4 @@ vtc_log_vas_fail(const char *func, const char *file, int line, } } -vas_f *vas_fail = vtc_log_vas_fail; +vas_f *VAS_Fail = vtc_log_VAS_Fail; diff --git a/include/vas.h b/include/vas.h index 6a4891f..dc2a835 100644 --- a/include/vas.h +++ b/include/vas.h @@ -42,7 +42,7 @@ typedef void vas_f(const char *, const char *, int, const char *, int, int); -extern vas_f *vas_fail; +extern vas_f *VAS_Fail; #ifdef WITHOUT_ASSERTS #define assert(e) ((void)(e)) @@ -50,14 +50,14 @@ extern vas_f *vas_fail; #define assert(e) \ do { \ if (!(e)) \ - vas_fail(__func__, __FILE__, __LINE__, #e, errno, 0); \ + VAS_Fail(__func__, __FILE__, __LINE__, #e, errno, 0); \ } while (0) #endif #define xxxassert(e) \ do { \ if (!(e)) \ - vas_fail(__func__, __FILE__, __LINE__, #e, errno, 1); \ + VAS_Fail(__func__, __FILE__, __LINE__, #e, errno, 1); \ } while (0) /* Assert zero return value */ @@ -68,7 +68,7 @@ do { \ #define diagnostic(foo) assert(foo) #define WRONG(expl) \ do { \ - vas_fail(__func__, __FILE__, __LINE__, expl, errno, 3); \ + VAS_Fail(__func__, __FILE__, __LINE__, expl, errno, 3); \ abort(); \ } while (0) diff --git a/lib/libvarnish/assert.c b/lib/libvarnish/assert.c index 2b74e80..9422cfc 100644 --- a/lib/libvarnish/assert.c +++ b/lib/libvarnish/assert.c @@ -38,7 +38,7 @@ #include "libvarnish.h" static void -vas_fail_default(const char *func, const char *file, int line, +VAS_Fail_default(const char *func, const char *file, int line, const char *cond, int err, int xxx) { @@ -59,4 +59,4 @@ vas_fail_default(const char *func, const char *file, int line, abort(); } -vas_f *vas_fail = vas_fail_default; +vas_f *VAS_Fail = VAS_Fail_default; From phk at varnish-cache.org Tue May 31 11:15:04 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 31 May 2011 13:15:04 +0200 Subject: [master] 25ea454 Namespace cleanup: Collect version-related stuff under VCS_ Message-ID: commit 25ea45417a5a96cbb3d4643ac73fdae399a2a303 Author: Poul-Henning Kamp Date: Tue May 31 09:36:36 2011 +0000 Namespace cleanup: Collect version-related stuff under VCS_ diff --git a/bin/varnishd/varnishd.c b/bin/varnishd/varnishd.c index a6030d4..4a216a9 100644 --- a/bin/varnishd/varnishd.c +++ b/bin/varnishd/varnishd.c @@ -495,7 +495,7 @@ main(int argc, char * const *argv) break; case 'V': /* XXX: we should print the ident here */ - varnish_version("varnishd"); + VCS_Message("varnishd"); exit(0); case 'x': #ifdef DIAGNOSTICS diff --git a/bin/varnishhist/varnishhist.c b/bin/varnishhist/varnishhist.c index 5ff237a..5772de6 100644 --- a/bin/varnishhist/varnishhist.c +++ b/bin/varnishhist/varnishhist.c @@ -334,7 +334,7 @@ main(int argc, char **argv) while ((o = getopt(argc, argv, VSL_ARGS "Vw:")) != -1) { switch (o) { case 'V': - varnish_version("varnishhist"); + VCS_Message("varnishhist"); exit(0); case 'w': delay = atoi(optarg); diff --git a/bin/varnishlog/varnishlog.c b/bin/varnishlog/varnishlog.c index 2064ef9..d0e39d0 100644 --- a/bin/varnishlog/varnishlog.c +++ b/bin/varnishlog/varnishlog.c @@ -311,7 +311,7 @@ main(int argc, char * const *argv) u_flag = 1; break; case 'V': - varnish_version("varnishlog"); + VCS_Message("varnishlog"); exit(0); case 'w': w_arg = optarg; diff --git a/bin/varnishncsa/varnishncsa.c b/bin/varnishncsa/varnishncsa.c index dc2d927..39c5cce 100644 --- a/bin/varnishncsa/varnishncsa.c +++ b/bin/varnishncsa/varnishncsa.c @@ -757,7 +757,7 @@ main(int argc, char *argv[]) P_arg = optarg; break; case 'V': - varnish_version("varnishncsa"); + VCS_Message("varnishncsa"); exit(0); case 'w': w_arg = optarg; diff --git a/bin/varnishsizes/varnishsizes.c b/bin/varnishsizes/varnishsizes.c index 29c218b..8d14d3e 100644 --- a/bin/varnishsizes/varnishsizes.c +++ b/bin/varnishsizes/varnishsizes.c @@ -335,7 +335,7 @@ main(int argc, char **argv) while ((o = getopt(argc, argv, VSL_ARGS "Vw:")) != -1) { switch (o) { case 'V': - varnish_version("varnishsizes"); + VCS_Message("varnishsizes"); exit(0); case 'w': delay = atoi(optarg); diff --git a/bin/varnishstat/varnishstat.c b/bin/varnishstat/varnishstat.c index d1c7545..c1408dd 100644 --- a/bin/varnishstat/varnishstat.c +++ b/bin/varnishstat/varnishstat.c @@ -209,7 +209,7 @@ main(int argc, char * const *argv) list_fields(vd); exit(0); case 'V': - varnish_version("varnishstat"); + VCS_Message("varnishstat"); exit(0); case 'w': delay = atoi(optarg); diff --git a/bin/varnishtop/varnishtop.c b/bin/varnishtop/varnishtop.c index c98f154..6b39b85 100644 --- a/bin/varnishtop/varnishtop.c +++ b/bin/varnishtop/varnishtop.c @@ -333,7 +333,7 @@ main(int argc, char **argv) } break; case 'V': - varnish_version("varnishtop"); + VCS_Message("varnishtop"); exit(0); case 'm': fprintf(stderr, "-m is not supported\n"); diff --git a/include/libvarnish.h b/include/libvarnish.h index ee20a54..a1cfaa8 100644 --- a/include/libvarnish.h +++ b/include/libvarnish.h @@ -96,14 +96,14 @@ struct timespec TIM_timespec(double t); struct timeval TIM_timeval(double t); /* from libvarnish/version.c */ -void varnish_version(const char *); +void VCS_Message(const char *); /* from libvarnish/vtmpfile.c */ int vtmpfile(char *); char *vreadfile(const char *pfx, const char *fn, ssize_t *sz); char *vreadfd(int fd, ssize_t *sz); -const char* vcs_version(void); +const char* VCS_Version(void); /* Safe printf into a fixed-size buffer */ #define bprintf(buf, fmt, ...) \ diff --git a/lib/libvarnish/Makefile.am b/lib/libvarnish/Makefile.am index cb6fc37..584a4c3 100644 --- a/lib/libvarnish/Makefile.am +++ b/lib/libvarnish/Makefile.am @@ -49,10 +49,9 @@ vcs_version.c: FORCE echo ' */' ;\ echo '' ;\ echo "#include " ;\ - echo "const char* vcs_version(void)" ;\ + echo "const char* VCS_Version(void)" ;\ echo "{" ;\ - echo " const char* VCS_Version = \"$$V\";" ;\ - echo " return VCS_Version;" ;\ + echo " return (\"$$V\");" ;\ echo "}" ;\ ) > vcs_version.c ; \ fi \ diff --git a/lib/libvarnish/version.c b/lib/libvarnish/version.c index 3e1c5ce..f51166b 100644 --- a/lib/libvarnish/version.c +++ b/lib/libvarnish/version.c @@ -36,10 +36,10 @@ #include "libvarnish.h" void -varnish_version(const char *progname) +VCS_Message(const char *progname) { fprintf(stderr, "%s (%s-%s revision %s)\n", progname, - PACKAGE_TARNAME, PACKAGE_VERSION, vcs_version()); + PACKAGE_TARNAME, PACKAGE_VERSION, VCS_Version()); fprintf(stderr, "Copyright (c) 2006-2009 Linpro AS / Verdens Gang AS\n"); } From phk at varnish-cache.org Tue May 31 11:15:04 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 31 May 2011 13:15:04 +0200 Subject: [master] 9c86e0b Namespace cleanup of the VSM related varnishapi functions Message-ID: commit 9c86e0b0666bb90712071617557df4ae8b7c5a45 Author: Poul-Henning Kamp Date: Tue May 31 10:13:36 2011 +0000 Namespace cleanup of the VSM related varnishapi functions diff --git a/bin/varnishd/cache.h b/bin/varnishd/cache.h index 69cb666..9f071a2 100644 --- a/bin/varnishd/cache.h +++ b/bin/varnishd/cache.h @@ -103,7 +103,7 @@ struct vrt_backend; struct cli_proto; struct ban; struct SHA256Context; -struct vsc_lck; +struct VSC_C_lck; struct waitinglist; struct vef_priv; @@ -787,7 +787,7 @@ const struct sess * THR_GetSession(void); void Lck__Lock(struct lock *lck, const char *p, const char *f, int l); void Lck__Unlock(struct lock *lck, const char *p, const char *f, int l); int Lck__Trylock(struct lock *lck, const char *p, const char *f, int l); -void Lck__New(struct lock *lck, struct vsc_lck *, const char *); +void Lck__New(struct lock *lck, struct VSC_C_lck *, const char *); void Lck__Assert(const struct lock *lck, int held); /* public interface: */ @@ -801,7 +801,7 @@ void Lck_CondWait(pthread_cond_t *cond, struct lock *lck); #define Lck_Trylock(a) Lck__Trylock(a, __func__, __FILE__, __LINE__) #define Lck_AssertHeld(a) Lck__Assert(a, 1) -#define LOCK(nam) extern struct vsc_lck *lck_##nam; +#define LOCK(nam) extern struct VSC_C_lck *lck_##nam; #include "locks.h" #undef LOCK @@ -846,9 +846,9 @@ void *VSM_Alloc(unsigned size, const char *class, const char *type, const char *ident); void VSM_Free(const void *ptr); #ifdef VSL_ENDMARKER -void VSL(enum vsl_tag tag, int id, const char *fmt, ...); -void WSLR(struct worker *w, enum vsl_tag tag, int id, txt t); -void WSL(struct worker *w, enum vsl_tag tag, int id, const char *fmt, ...); +void VSL(enum VSL_tag_e tag, int id, const char *fmt, ...); +void WSLR(struct worker *w, enum VSL_tag_e tag, int id, txt t); +void WSL(struct worker *w, enum VSL_tag_e tag, int id, const char *fmt, ...); void WSL_Flush(struct worker *w, int overflow); #define DSL(flag, tag, id, ...) \ diff --git a/bin/varnishd/cache_acceptor.c b/bin/varnishd/cache_acceptor.c index 264cfc0..275c7e8 100644 --- a/bin/varnishd/cache_acceptor.c +++ b/bin/varnishd/cache_acceptor.c @@ -270,19 +270,19 @@ vca_acct(void *arg) TIM_sleep(pace); i = poll(pfd, heritage.nsocks, 1000); now = TIM_real(); - VSC_main->uptime = (uint64_t)(now - t0); + VSC_C_main->uptime = (uint64_t)(now - t0); u = 0; VTAILQ_FOREACH(ls, &heritage.socks, list) { if (ls->sock < 0) continue; if (pfd[u++].revents == 0) continue; - VSC_main->client_conn++; + VSC_C_main->client_conn++; l = sizeof addr_s; addr = (void*)&addr_s; i = accept(ls->sock, addr, &l); if (i < 0) { - VSC_main->accept_fail++; + VSC_C_main->accept_fail++; switch (errno) { case EAGAIN: case ECONNABORTED: @@ -305,7 +305,7 @@ vca_acct(void *arg) sp = SES_New(); if (sp == NULL) { AZ(close(i)); - VSC_main->client_drop++; + VSC_C_main->client_drop++; pace += params->acceptor_sleep_incr; continue; } @@ -320,7 +320,7 @@ vca_acct(void *arg) sp->step = STP_FIRST; if (WRK_QueueSession(sp)) { - VSC_main->client_drop++; + VSC_C_main->client_drop++; pace += params->acceptor_sleep_incr; } else { pace *= params->acceptor_sleep_decay; @@ -348,7 +348,7 @@ vca_handover(struct sess *sp, int status) case 1: sp->step = STP_START; if (WRK_QueueSession(sp)) - VSC_main->client_drop_late++; + VSC_C_main->client_drop_late++; break; default: INCOMPL(); diff --git a/bin/varnishd/cache_backend.c b/bin/varnishd/cache_backend.c index 8f2ebb8..a523501 100644 --- a/bin/varnishd/cache_backend.c +++ b/bin/varnishd/cache_backend.c @@ -89,7 +89,7 @@ VBE_ReleaseConn(struct vbc *vc) vc->addrlen = 0; vc->recycled = 0; Lck_Lock(&VBE_mtx); - VSC_main->n_vbc--; + VSC_C_main->n_vbc--; Lck_Unlock(&VBE_mtx); FREE_OBJ(vc); } @@ -226,7 +226,7 @@ vbe_NewConn(void) XXXAN(vc); vc->fd = -1; Lck_Lock(&VBE_mtx); - VSC_main->n_vbc++; + VSC_C_main->n_vbc++; Lck_Unlock(&VBE_mtx); return (vc); } @@ -346,14 +346,14 @@ vbe_GetVbe(const struct sess *sp, struct vdi_simple *vs) break; if (vbe_CheckFd(vc->fd)) { /* XXX locking of stats */ - VSC_main->backend_reuse += 1; + VSC_C_main->backend_reuse += 1; WSP(sp, SLT_Backend, "%d %s %s", vc->fd, sp->director->vcl_name, bp->vcl_name); vc->vdis = vs; vc->recycled = 1; return (vc); } - VSC_main->backend_toolate++; + VSC_C_main->backend_toolate++; WSL(sp->wrk, SLT_BackendClose, vc->fd, "%s", bp->vcl_name); /* Checkpoint log to flush all info related to this connection @@ -367,13 +367,13 @@ vbe_GetVbe(const struct sess *sp, struct vdi_simple *vs) } if (!vbe_Healthy(vs, sp)) { - VSC_main->backend_unhealthy++; + VSC_C_main->backend_unhealthy++; return (NULL); } if (vs->vrt->max_connections > 0 && bp->n_conn >= vs->vrt->max_connections) { - VSC_main->backend_busy++; + VSC_C_main->backend_busy++; return (NULL); } @@ -383,11 +383,11 @@ vbe_GetVbe(const struct sess *sp, struct vdi_simple *vs) bes_conn_try(sp, vc, vs); if (vc->fd < 0) { VBE_ReleaseConn(vc); - VSC_main->backend_fail++; + VSC_C_main->backend_fail++; return (NULL); } vc->backend = bp; - VSC_main->backend_conn++; + VSC_C_main->backend_conn++; WSP(sp, SLT_Backend, "%d %s %s", vc->fd, sp->director->vcl_name, bp->vcl_name); vc->vdis = vs; diff --git a/bin/varnishd/cache_backend.h b/bin/varnishd/cache_backend.h index 37796d4..69082d0 100644 --- a/bin/varnishd/cache_backend.h +++ b/bin/varnishd/cache_backend.h @@ -131,7 +131,7 @@ struct backend { unsigned healthy; VTAILQ_HEAD(, trouble) troublelist; - struct vsc_vbe *vsc; + struct VSC_C_vbe *vsc; }; /* cache_backend.c */ diff --git a/bin/varnishd/cache_backend_cfg.c b/bin/varnishd/cache_backend_cfg.c index 2e54fd5..44f5cd8 100644 --- a/bin/varnishd/cache_backend_cfg.c +++ b/bin/varnishd/cache_backend_cfg.c @@ -69,7 +69,7 @@ VBE_Nuke(struct backend *b) free(b->port); VSM_Free(b->vsc); FREE_OBJ(b); - VSC_main->n_backend--; + VSC_C_main->n_backend--; } /*-------------------------------------------------------------------- @@ -234,7 +234,7 @@ VBE_AddBackend(struct cli *cli, const struct vrt_backend *vb) b->healthy = 1; VTAILQ_INSERT_TAIL(&backends, b, list); - VSC_main->n_backend++; + VSC_C_main->n_backend++; return (b); } diff --git a/bin/varnishd/cache_ban.c b/bin/varnishd/cache_ban.c index bde3b5b..a75314c 100644 --- a/bin/varnishd/cache_ban.c +++ b/bin/varnishd/cache_ban.c @@ -156,8 +156,8 @@ ban_CheckLast(void) Lck_AssertHeld(&ban_mtx); b = VTAILQ_LAST(&ban_head, banhead_s); if (b != VTAILQ_FIRST(&ban_head) && b->refcount == 0) { - VSC_main->n_ban--; - VSC_main->n_ban_retire++; + VSC_C_main->n_ban--; + VSC_C_main->n_ban_retire++; VTAILQ_REMOVE(&ban_head, b, list); } else { b = NULL; @@ -398,8 +398,8 @@ BAN_Insert(struct ban *b) Lck_Lock(&ban_mtx); VTAILQ_INSERT_HEAD(&ban_head, b, list); ban_start = b; - VSC_main->n_ban++; - VSC_main->n_ban_add++; + VSC_C_main->n_ban++; + VSC_C_main->n_ban_add++; be = VTAILQ_LAST(&ban_head, banhead_s); if (params->ban_dups && be != b) @@ -428,7 +428,7 @@ BAN_Insert(struct ban *b) } Lck_Lock(&ban_mtx); be->refcount--; - VSC_main->n_ban_dups += pcount; + VSC_C_main->n_ban_dups += pcount; Lck_Unlock(&ban_mtx); } @@ -533,8 +533,8 @@ BAN_Reload(const uint8_t *ban, unsigned len) gone |= BAN_F_GONE; } - VSC_main->n_ban++; - VSC_main->n_ban_add++; + VSC_C_main->n_ban++; + VSC_C_main->n_ban_add++; b2 = BAN_New(); AN(b2); @@ -707,8 +707,8 @@ ban_check_object(struct object *o, const struct sess *sp, int has_req) VTAILQ_INSERT_TAIL(&b0->objcore, oc, ban_list); b0->refcount++; } - VSC_main->n_ban_obj_test++; - VSC_main->n_ban_re_test += tests; + VSC_C_main->n_ban_obj_test++; + VSC_C_main->n_ban_re_test += tests; Lck_Unlock(&ban_mtx); if (b == oc->ban) { /* not banned */ diff --git a/bin/varnishd/cache_center.c b/bin/varnishd/cache_center.c index 9a3749f..59e22d4 100644 --- a/bin/varnishd/cache_center.c +++ b/bin/varnishd/cache_center.c @@ -526,7 +526,7 @@ cnt_fetch(struct sess *sp) * Do a single retry in that case. */ if (i == 1) { - VSC_main->backend_retry++; + VSC_C_main->backend_retry++; i = FetchHdr(sp); } diff --git a/bin/varnishd/cache_cli.c b/bin/varnishd/cache_cli.c index 3d6ddd2..7905c17 100644 --- a/bin/varnishd/cache_cli.c +++ b/bin/varnishd/cache_cli.c @@ -138,7 +138,7 @@ cli_debug_sizeof(struct cli *cli, const char * const *av, void *priv) SZOF(struct objhead); SZOF(struct sess); SZOF(struct vbc); - SZOF(struct vsc_main); + SZOF(struct VSC_C_main); SZOF(struct lock); } diff --git a/bin/varnishd/cache_dir.c b/bin/varnishd/cache_dir.c index f27f4f7..4aa7a8f 100644 --- a/bin/varnishd/cache_dir.c +++ b/bin/varnishd/cache_dir.c @@ -83,7 +83,7 @@ VDI_RecycleFd(struct sess *sp) */ WSL_Flush(sp->wrk, 0); Lck_Lock(&bp->mtx); - VSC_main->backend_recycle++; + VSC_C_main->backend_recycle++; VTAILQ_INSERT_HEAD(&bp->connlist, sp->vbc, list); sp->vbc = NULL; VBE_DropRefLocked(bp); diff --git a/bin/varnishd/cache_dir_dns.c b/bin/varnishd/cache_dir_dns.c index b457d05..244dd2b 100644 --- a/bin/varnishd/cache_dir_dns.c +++ b/bin/varnishd/cache_dir_dns.c @@ -232,7 +232,7 @@ vdi_dns_cache_list_add(const struct sess *sp, struct vdi_dns_hostgroup *new) { if (vs->ncachelist >= VDI_DNS_MAX_CACHE) { - VSC_main->dir_dns_cache_full++; + VSC_C_main->dir_dns_cache_full++; vdi_dns_pop_cache(vs, NULL); } CHECK_OBJ_NOTNULL(new, VDI_DNSDIR_MAGIC); @@ -275,10 +275,10 @@ vdi_dns_cache_add(const struct sess *sp, REPLACE(new->hostname, hostname); error = getaddrinfo(hostname, "80", &hint, &res0); - VSC_main->dir_dns_lookups++; + VSC_C_main->dir_dns_lookups++; if (error) { vdi_dns_cache_list_add(sp, vs, new); - VSC_main->dir_dns_failed++; + VSC_C_main->dir_dns_failed++; return (0); } @@ -332,7 +332,7 @@ vdi_dns_walk_cache(const struct sess *sp, ret = vdi_dns_cache_add(sp, vs, hostname, &backend); AZ(pthread_rwlock_unlock(&vs->rwlock)); } else - VSC_main->dir_dns_hit++; + VSC_C_main->dir_dns_hit++; /* Bank backend == cached a failure, so to speak */ if (backend != NULL) diff --git a/bin/varnishd/cache_esi_parse.c b/bin/varnishd/cache_esi_parse.c index 265cb96..411db43 100644 --- a/bin/varnishd/cache_esi_parse.c +++ b/bin/varnishd/cache_esi_parse.c @@ -184,7 +184,7 @@ vep_error(const struct vep_state *vep, const char *p) { intmax_t l; - VSC_main->esi_errors++; + VSC_C_main->esi_errors++; l = (intmax_t)(vep->ver_p - vep->hack_p); WSP(vep->sp, SLT_ESI_xmlerror, "ERR at %jd %s", l, p); @@ -199,7 +199,7 @@ vep_warn(const struct vep_state *vep, const char *p) { intmax_t l; - VSC_main->esi_warnings++; + VSC_C_main->esi_warnings++; l = (intmax_t)(vep->ver_p - vep->hack_p); printf("WARNING at %jd %s\n", l, p); WSP(vep->sp, SLT_ESI_xmlerror, "WARN at %jd %s", l, p); diff --git a/bin/varnishd/cache_expire.c b/bin/varnishd/cache_expire.c index a8b391f..4a4255f 100644 --- a/bin/varnishd/cache_expire.c +++ b/bin/varnishd/cache_expire.c @@ -268,7 +268,7 @@ EXP_Touch(struct objcore *oc) if (oc->timer_idx != BINHEAP_NOIDX) { VTAILQ_REMOVE(&lru->lru_head, oc, lru_list); VTAILQ_INSERT_TAIL(&lru->lru_head, oc, lru_list); - VSC_main->n_lru_moved++; + VSC_C_main->n_lru_moved++; } Lck_Unlock(&lru->mtx); return (1); @@ -382,7 +382,7 @@ exp_timer(struct sess *sp, void *priv) Lck_Unlock(&exp_mtx); Lck_Unlock(&lru->mtx); - VSC_main->n_expired++; + VSC_C_main->n_expired++; CHECK_OBJ_NOTNULL(oc->objhead, OBJHEAD_MAGIC); (void)HSH_Deref(sp->wrk, oc, NULL); @@ -420,7 +420,7 @@ EXP_NukeOne(const struct sess *sp, struct lru *lru) VTAILQ_REMOVE(&lru->lru_head, oc, lru_list); binheap_delete(exp_heap, oc->timer_idx); assert(oc->timer_idx == BINHEAP_NOIDX); - VSC_main->n_lru_nuked++; + VSC_C_main->n_lru_nuked++; } Lck_Unlock(&exp_mtx); Lck_Unlock(&lru->mtx); diff --git a/bin/varnishd/cache_fetch.c b/bin/varnishd/cache_fetch.c index ddbd3ab..b224146 100644 --- a/bin/varnishd/cache_fetch.c +++ b/bin/varnishd/cache_fetch.c @@ -433,7 +433,7 @@ FetchHdr(struct sess *sp) WSL_Flush(w, 0); /* XXX is this the right place? */ - VSC_main->backend_req++; + VSC_C_main->backend_req++; /* Receive response */ diff --git a/bin/varnishd/cache_gzip.c b/bin/varnishd/cache_gzip.c index 73a185e..e9ae902 100644 --- a/bin/varnishd/cache_gzip.c +++ b/bin/varnishd/cache_gzip.c @@ -161,7 +161,7 @@ VGZ_NewUngzip(struct sess *sp, const char *id) CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); vg = vgz_alloc_vgz(sp, id); vg->dir = VGZ_UN; - VSC_main->n_gunzip++; + VSC_C_main->n_gunzip++; /* * Max memory usage according to zonf.h: @@ -182,7 +182,7 @@ VGZ_NewGzip(struct sess *sp, const char *id) CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); vg = vgz_alloc_vgz(sp, id); vg->dir = VGZ_GZ; - VSC_main->n_gzip++; + VSC_C_main->n_gzip++; /* * From zconf.h: diff --git a/bin/varnishd/cache_hash.c b/bin/varnishd/cache_hash.c index 457095b..98ec9b0 100644 --- a/bin/varnishd/cache_hash.c +++ b/bin/varnishd/cache_hash.c @@ -486,7 +486,7 @@ hsh_rush(struct objhead *oh) * We could not schedule the session, leave the * rest on the busy list. */ - VSC_main->client_drop_late++; + VSC_C_main->client_drop_late++; break; } } diff --git a/bin/varnishd/cache_http.c b/bin/varnishd/cache_http.c index 5dc922a..40237e5 100644 --- a/bin/varnishd/cache_http.c +++ b/bin/varnishd/cache_http.c @@ -57,14 +57,14 @@ LOGMTX2(ax, HTTP_HDR_FIRST, Header), \ } -static const enum vsl_tag logmtx[][HTTP_HDR_FIRST + 1] = { +static const enum VSL_tag_e logmtx[][HTTP_HDR_FIRST + 1] = { [HTTP_Rx] = LOGMTX1(Rx), [HTTP_Tx] = LOGMTX1(Tx), [HTTP_Obj] = LOGMTX1(Obj) }; /*lint -restore */ -static enum vsl_tag +static enum VSL_tag_e http2shmlog(const struct http *hp, int t) { @@ -520,7 +520,7 @@ http_dissect_hdrs(struct worker *w, struct http *hp, int fd, char *p, } if (q - p > htc->maxhdr) { - VSC_main->losthdr++; + VSC_C_main->losthdr++; WSL(w, SLT_LostHeader, fd, "%.*s", q - p, p); return (400); } @@ -545,7 +545,7 @@ http_dissect_hdrs(struct worker *w, struct http *hp, int fd, char *p, WSLH(w, fd, hp, hp->nhd); hp->nhd++; } else { - VSC_main->losthdr++; + VSC_C_main->losthdr++; WSL(w, SLT_LostHeader, fd, "%.*s", q - p, p); return (400); } @@ -787,7 +787,7 @@ http_copyheader(struct worker *w, int fd, struct http *to, to->hdf[to->nhd] = 0; to->nhd++; } else { - VSC_main->losthdr++; + VSC_C_main->losthdr++; WSLR(w, SLT_LostHeader, fd, fm->hd[n]); } } @@ -896,7 +896,7 @@ http_CopyHome(struct worker *w, int fd, const struct http *hp) hp->hd[u].e = p + l; } else { /* XXX This leaves a slot empty */ - VSC_main->losthdr++; + VSC_C_main->losthdr++; WSLR(w, SLT_LostHeader, fd, hp->hd[u]); hp->hd[u].b = NULL; hp->hd[u].e = NULL; @@ -924,7 +924,7 @@ http_SetHeader(struct worker *w, int fd, struct http *to, const char *hdr) CHECK_OBJ_NOTNULL(to, HTTP_MAGIC); if (to->nhd >= to->shd) { - VSC_main->losthdr++; + VSC_C_main->losthdr++; WSL(w, SLT_LostHeader, fd, "%s", hdr); return; } @@ -993,7 +993,7 @@ http_PrintfHeader(struct worker *w, int fd, struct http *to, n = vsnprintf(to->ws->f, l, fmt, ap); va_end(ap); if (n + 1 >= l || to->nhd >= to->shd) { - VSC_main->losthdr++; + VSC_C_main->losthdr++; WSL(w, SLT_LostHeader, fd, "%s", to->ws->f); WS_Release(to->ws, 0); } else { diff --git a/bin/varnishd/cache_lck.c b/bin/varnishd/cache_lck.c index acb173a..6fb35c4 100644 --- a/bin/varnishd/cache_lck.c +++ b/bin/varnishd/cache_lck.c @@ -51,7 +51,7 @@ struct ilck { pthread_t owner; VTAILQ_ENTRY(ilck) list; const char *w; - struct vsc_lck *stat; + struct VSC_C_lck *stat; }; static VTAILQ_HEAD(, ilck) ilck_head = @@ -155,7 +155,7 @@ Lck_CondWait(pthread_cond_t *cond, struct lock *lck) } void -Lck__New(struct lock *lck, struct vsc_lck *st, const char *w) +Lck__New(struct lock *lck, struct VSC_C_lck *st, const char *w) { struct ilck *ilck; @@ -188,7 +188,7 @@ Lck_Delete(struct lock *lck) FREE_OBJ(ilck); } -#define LOCK(nam) struct vsc_lck *lck_##nam; +#define LOCK(nam) struct VSC_C_lck *lck_##nam; #include "locks.h" #undef LOCK @@ -198,7 +198,7 @@ LCK_Init(void) AZ(pthread_mutex_init(&lck_mtx, NULL)); #define LOCK(nam) \ - lck_##nam = VSM_Alloc(sizeof(struct vsc_lck), \ + lck_##nam = VSM_Alloc(sizeof(struct VSC_C_lck), \ VSC_CLASS, VSC_TYPE_LCK, #nam); #include "locks.h" #undef LOCK diff --git a/bin/varnishd/cache_panic.c b/bin/varnishd/cache_panic.c index 22a7fff..fc24607 100644 --- a/bin/varnishd/cache_panic.c +++ b/bin/varnishd/cache_panic.c @@ -338,18 +338,18 @@ pan_ic(const char *func, const char *file, int line, const char *cond, VSB_bcat(vsp, "", 1); /* NUL termination */ if (params->diag_bitmap & 0x4000) - (void)fputs(vsm_head->panicstr, stderr); + (void)fputs(VSM_head->panicstr, stderr); #ifdef HAVE_ABORT2 if (params->diag_bitmap & 0x8000) { void *arg[1]; char *p; - for (p = vsm_head->panicstr; *p; p++) + for (p = VSM_head->panicstr; *p; p++) if (*p == '\n') *p = ' '; - arg[0] = vsm_head->panicstr; - abort2(vsm_head->panicstr, 1, arg); + arg[0] = VSM_head->panicstr; + abort2(VSM_head->panicstr, 1, arg); } #endif if (params->diag_bitmap & 0x1000) @@ -366,6 +366,6 @@ PAN_Init(void) VAS_Fail = pan_ic; vsp = &vsps; - AN(VSB_new(vsp, vsm_head->panicstr, sizeof vsm_head->panicstr, + AN(VSB_new(vsp, VSM_head->panicstr, sizeof VSM_head->panicstr, VSB_FIXEDLEN)); } diff --git a/bin/varnishd/cache_pool.c b/bin/varnishd/cache_pool.c index 816bdbe..9a66f7b 100644 --- a/bin/varnishd/cache_pool.c +++ b/bin/varnishd/cache_pool.c @@ -92,7 +92,7 @@ wrk_sumstat(struct worker *w) Lck_AssertHeld(&wstat_mtx); #define L0(n) -#define L1(n) (VSC_main->n += w->stats.n) +#define L1(n) (VSC_C_main->n += w->stats.n) #define VSC_DO_MAIN #define VSC_F(n, t, l, f, d) L##l(n); #include "vsc_fields.h" @@ -367,7 +367,7 @@ wrk_addpools(const unsigned pools) */ static void -wrk_decimate_flock(struct wq *qp, double t_idle, struct vsc_main *vs) +wrk_decimate_flock(struct wq *qp, double t_idle, struct VSC_C_main *vs) { struct worker *w = NULL; @@ -409,7 +409,7 @@ wrk_herdtimer_thread(void *priv) { volatile unsigned u; double t_idle; - struct vsc_main vsm, *vs; + struct VSC_C_main vsm, *vs; int errno_is_multi_threaded; THR_SetName("wrk_herdtimer"); @@ -452,10 +452,10 @@ wrk_herdtimer_thread(void *priv) for (u = 0; u < nwq; u++) wrk_decimate_flock(wq[u], t_idle, vs); - VSC_main->n_wrk= vs->n_wrk; - VSC_main->n_wrk_lqueue = vs->n_wrk_lqueue; - VSC_main->n_wrk_drop = vs->n_wrk_drop; - VSC_main->n_wrk_queued = vs->n_wrk_queued; + VSC_C_main->n_wrk= vs->n_wrk; + VSC_C_main->n_wrk_lqueue = vs->n_wrk_lqueue; + VSC_C_main->n_wrk_drop = vs->n_wrk_drop; + VSC_C_main->n_wrk_queued = vs->n_wrk_queued; TIM_sleep(params->wthread_purge_delay * 1e-3); } @@ -479,15 +479,15 @@ wrk_breed_flock(struct wq *qp, const pthread_attr_t *tp_attr) (qp->lqueue > params->wthread_add_threshold && /* more needed */ qp->lqueue > qp->last_lqueue)) { /* not getting better since last */ if (qp->nthr >= nthr_max) { - VSC_main->n_wrk_max++; + VSC_C_main->n_wrk_max++; } else if (pthread_create(&tp, tp_attr, wrk_thread, qp)) { VSL(SLT_Debug, 0, "Create worker thread failed %d %s", errno, strerror(errno)); - VSC_main->n_wrk_failed++; + VSC_C_main->n_wrk_failed++; TIM_sleep(params->wthread_fail_delay * 1e-3); } else { AZ(pthread_detach(tp)); - VSC_main->n_wrk_create++; + VSC_C_main->n_wrk_create++; TIM_sleep(params->wthread_add_delay * 1e-3); } } diff --git a/bin/varnishd/cache_response.c b/bin/varnishd/cache_response.c index ad8302c..16993f5 100644 --- a/bin/varnishd/cache_response.c +++ b/bin/varnishd/cache_response.c @@ -259,7 +259,7 @@ res_WriteGunzipObj(struct sess *sp) u += st->len; sp->acct_tmp.bodybytes += st->len; /* XXX ? */ - VSC_main->n_objwrite++; + VSC_C_main->n_objwrite++; i = VGZ_WrwGunzip(sp, vg, st->ptr, st->len, @@ -319,12 +319,12 @@ res_WriteDirObj(struct sess *sp, ssize_t low, ssize_t high) */ if (st->fd >= 0 && st->len >= params->sendfile_threshold) { - VSC_main->n_objsendfile++; + VSC_C_main->n_objsendfile++; WRW_Sendfile(sp->wrk, st->fd, st->where + off, len); continue; } #endif /* SENDFILE_WORKS */ - VSC_main->n_objwrite++; + VSC_C_main->n_objwrite++; (void)WRW_Write(sp->wrk, st->ptr + off, len); } assert(u == sp->obj->len); diff --git a/bin/varnishd/cache_session.c b/bin/varnishd/cache_session.c index 05aaf19..fa478a6 100644 --- a/bin/varnishd/cache_session.c +++ b/bin/varnishd/cache_session.c @@ -105,7 +105,7 @@ ses_sm_alloc(void) volatile unsigned nhttp; unsigned l, hl; - if (VSC_main->n_sess_mem >= params->max_sess) + if (VSC_C_main->n_sess_mem >= params->max_sess) return (NULL); /* * It is not necessary to lock these, but we need to @@ -122,7 +122,7 @@ ses_sm_alloc(void) q = p + l; Lck_Lock(&stat_mtx); - VSC_main->n_sess_mem++; + VSC_C_main->n_sess_mem++; Lck_Unlock(&stat_mtx); /* Don't waste time zeroing the workspace */ @@ -214,7 +214,7 @@ SES_New(void) CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); } - VSC_main->n_sess++; /* XXX: locking ? */ + VSC_C_main->n_sess++; /* XXX: locking ? */ return (sp); } @@ -255,7 +255,7 @@ SES_Delete(struct sess *sp) AZ(sp->obj); AZ(sp->vcl); - VSC_main->n_sess--; /* XXX: locking ? */ + VSC_C_main->n_sess--; /* XXX: locking ? */ assert(!isnan(b->first)); assert(!isnan(sp->t_end)); if (sp->addr == NULL) @@ -268,7 +268,7 @@ SES_Delete(struct sess *sp) b->fetch, b->hdrbytes, b->bodybytes); if (sm->workspace != params->sess_workspace) { Lck_Lock(&stat_mtx); - VSC_main->n_sess_mem--; + VSC_C_main->n_sess_mem--; Lck_Unlock(&stat_mtx); free(sm); } else { @@ -280,7 +280,7 @@ SES_Delete(struct sess *sp) } /* Try to precreate some ses-mem so the acceptor will not have to */ - if (VSC_main->n_sess_mem < VSC_main->n_sess + 10) { + if (VSC_C_main->n_sess_mem < VSC_C_main->n_sess + 10) { sm = ses_sm_alloc(); if (sm != NULL) { ses_setup(sm); diff --git a/bin/varnishd/cache_shmlog.c b/bin/varnishd/cache_shmlog.c index dad28b6..b9f9dc8 100644 --- a/bin/varnishd/cache_shmlog.c +++ b/bin/varnishd/cache_shmlog.c @@ -56,7 +56,7 @@ vsl_w0(uint32_t type, uint32_t length) /*--------------------------------------------------------------------*/ static inline void -vsl_hdr(enum vsl_tag tag, uint32_t *p, unsigned len, unsigned id) +vsl_hdr(enum VSL_tag_e tag, uint32_t *p, unsigned len, unsigned id) { assert(((uintptr_t)p & 0x3) == 0); @@ -83,7 +83,7 @@ vsl_wrap(void) *vsl_ptr = VSL_WRAPMARKER; vsl_ptr = vsl_start + 1; } - VSC_main->shm_cycles++; + VSC_C_main->shm_cycles++; } /*-------------------------------------------------------------------- @@ -97,14 +97,14 @@ vsl_get(unsigned len, unsigned records, unsigned flushes) if (pthread_mutex_trylock(&vsl_mtx)) { AZ(pthread_mutex_lock(&vsl_mtx)); - VSC_main->shm_cont++; + VSC_C_main->shm_cont++; } assert(vsl_ptr < vsl_end); assert(((uintptr_t)vsl_ptr & 0x3) == 0); - VSC_main->shm_writes++; - VSC_main->shm_flushes += flushes; - VSC_main->shm_records += records; + VSC_C_main->shm_writes++; + VSC_C_main->shm_flushes += flushes; + VSC_C_main->shm_records += records; /* Wrap if necessary */ if (VSL_END(vsl_ptr, len) >= vsl_end) @@ -128,7 +128,7 @@ vsl_get(unsigned len, unsigned records, unsigned flushes) */ static void -VSLR(enum vsl_tag tag, int id, const char *b, unsigned len) +VSLR(enum VSL_tag_e tag, int id, const char *b, unsigned len) { uint32_t *p; unsigned mlen; @@ -148,7 +148,7 @@ VSLR(enum vsl_tag tag, int id, const char *b, unsigned len) /*--------------------------------------------------------------------*/ void -VSL(enum vsl_tag tag, int id, const char *fmt, ...) +VSL(enum VSL_tag_e tag, int id, const char *fmt, ...) { va_list ap; unsigned n, mlen = params->shm_reclen; @@ -198,7 +198,7 @@ WSL_Flush(struct worker *w, int overflow) /*--------------------------------------------------------------------*/ void -WSLR(struct worker *w, enum vsl_tag tag, int id, txt t) +WSLR(struct worker *w, enum VSL_tag_e tag, int id, txt t) { unsigned l, mlen; @@ -230,7 +230,7 @@ WSLR(struct worker *w, enum vsl_tag tag, int id, txt t) /*--------------------------------------------------------------------*/ void -WSL(struct worker *w, enum vsl_tag tag, int id, const char *fmt, ...) +WSL(struct worker *w, enum VSL_tag_e tag, int id, const char *fmt, ...) { va_list ap; char *p; @@ -271,7 +271,7 @@ WSL(struct worker *w, enum vsl_tag tag, int id, const char *fmt, ...) void VSL_Init(void) { - struct vsm_chunk *vsc; + struct VSM_chunk *vsc; AZ(pthread_mutex_init(&vsl_mtx, NULL)); AZ(pthread_mutex_init(&vsm_mtx, NULL)); @@ -287,10 +287,10 @@ VSL_Init(void) vsl_ptr = vsl_start + 1; vsl_wrap(); - vsm_head->starttime = (intmax_t)TIM_real(); - vsm_head->panicstr[0] = '\0'; - memset(VSC_main, 0, sizeof *VSC_main); - vsm_head->child_pid = getpid(); + VSM_head->starttime = (intmax_t)TIM_real(); + VSM_head->panicstr[0] = '\0'; + memset(VSC_C_main, 0, sizeof *VSC_C_main); + VSM_head->child_pid = getpid(); } /*--------------------------------------------------------------------*/ diff --git a/bin/varnishd/cache_vcl.c b/bin/varnishd/cache_vcl.c index 900f4ea..9137acd 100644 --- a/bin/varnishd/cache_vcl.c +++ b/bin/varnishd/cache_vcl.c @@ -179,8 +179,8 @@ VCL_Load(const char *fn, const char *name, struct cli *cli) if (vcl_active == NULL) vcl_active = vcl; Lck_Unlock(&vcl_mtx); - VSC_main->n_vcl++; - VSC_main->n_vcl_avail++; + VSC_C_main->n_vcl++; + VSC_C_main->n_vcl_avail++; return (0); } @@ -203,8 +203,8 @@ VCL_Nuke(struct vcls *vcl) free(vcl->name); (void)dlclose(vcl->dlh); FREE_OBJ(vcl); - VSC_main->n_vcl--; - VSC_main->n_vcl_discard--; + VSC_C_main->n_vcl--; + VSC_C_main->n_vcl_discard--; } /*--------------------------------------------------------------------*/ @@ -278,8 +278,8 @@ ccf_config_discard(struct cli *cli, const char * const *av, void *priv) cli_out(cli, "VCL %s is the active VCL", av[2]); return; } - VSC_main->n_vcl_discard++; - VSC_main->n_vcl_avail--; + VSC_C_main->n_vcl_discard++; + VSC_C_main->n_vcl_avail--; vcl->conf->discard = 1; Lck_Unlock(&vcl_mtx); if (vcl->conf->busy == 0) diff --git a/bin/varnishd/cache_vrt_vmod.c b/bin/varnishd/cache_vrt_vmod.c index 4ba4ca8..1afa459 100644 --- a/bin/varnishd/cache_vrt_vmod.c +++ b/bin/varnishd/cache_vrt_vmod.c @@ -77,7 +77,7 @@ VRT_Vmod_Init(void **hdl, void *ptr, int len, const char *nm, const char *path) AN(v); VTAILQ_INSERT_TAIL(&vmods, v, list); - VSC_main->vmods++; + VSC_C_main->vmods++; REPLACE(v->nm, nm); REPLACE(v->path, path); @@ -124,7 +124,7 @@ VRT_Vmod_Fini(void **hdl) free(v->nm); free(v->path); VTAILQ_REMOVE(&vmods, v, list); - VSC_main->vmods--; + VSC_C_main->vmods--; FREE_OBJ(v); } diff --git a/bin/varnishd/common.h b/bin/varnishd/common.h index ae3ec16..45bc894 100644 --- a/bin/varnishd/common.h +++ b/bin/varnishd/common.h @@ -37,7 +37,7 @@ extern pid_t mgt_pid; void VCA_tweak_waiter(struct cli *cli, const char *arg); /* mgt_shmem.c */ -extern struct vsc_main *VSC_main; +extern struct VSC_C_main *VSC_C_main; /* varnishd.c */ struct vsb; @@ -69,8 +69,8 @@ const void *pick(const struct choice *cp, const char *which, const char *kind); #define NEEDLESS_RETURN(foo) return (foo) /* vsm.c */ -extern struct vsm_head *vsm_head; -extern const struct vsm_chunk *vsm_end; +extern struct VSM_head *VSM_head; +extern const struct VSM_chunk *vsm_end; /* * These three should not be called directly, but only through diff --git a/bin/varnishd/hash_critbit.c b/bin/varnishd/hash_critbit.c index a5ad526..0eb426c 100644 --- a/bin/varnishd/hash_critbit.c +++ b/bin/varnishd/hash_critbit.c @@ -429,19 +429,19 @@ hcb_lookup(const struct sess *sp, struct objhead *noh) if (with_lock) { CAST_OBJ_NOTNULL(y, sp->wrk->nhashpriv, HCB_Y_MAGIC); Lck_Lock(&hcb_mtx); - VSC_main->hcb_lock++; + VSC_C_main->hcb_lock++; assert(noh->refcnt == 1); oh = hcb_insert(sp->wrk, &hcb_root, noh, 1); Lck_Unlock(&hcb_mtx); } else { - VSC_main->hcb_nolock++; + VSC_C_main->hcb_nolock++; oh = hcb_insert(sp->wrk, &hcb_root, noh, 0); } if (oh != NULL && oh == noh) { /* Assert that we only muck with the tree with a lock */ assert(with_lock); - VSC_main->hcb_insert++; + VSC_C_main->hcb_insert++; assert(oh->refcnt > 0); return (oh); } diff --git a/bin/varnishd/mgt_child.c b/bin/varnishd/mgt_child.c index 4258af2..863e86b 100644 --- a/bin/varnishd/mgt_child.c +++ b/bin/varnishd/mgt_child.c @@ -424,17 +424,17 @@ static void mgt_report_panic(pid_t r) { - if (vsm_head->panicstr[0] == '\0') + if (VSM_head->panicstr[0] == '\0') return; REPORT(LOG_ERR, "Child (%jd) Panic message: %s", - (intmax_t)r, vsm_head->panicstr); + (intmax_t)r, VSM_head->panicstr); } static void mgt_save_panic(void) { char time_str[30]; - if (vsm_head->panicstr[0] == '\0') + if (VSM_head->panicstr[0] == '\0') return; if (child_panic) @@ -443,7 +443,7 @@ mgt_save_panic(void) XXXAN(child_panic); TIM_format(TIM_real(), time_str); VSB_printf(child_panic, "Last panic at: %s\n", time_str); - VSB_cat(child_panic, vsm_head->panicstr); + VSB_cat(child_panic, VSM_head->panicstr); AZ(VSB_finish(child_panic)); } diff --git a/bin/varnishd/mgt_shmem.c b/bin/varnishd/mgt_shmem.c index 47a91c2..d3d1f87 100644 --- a/bin/varnishd/mgt_shmem.c +++ b/bin/varnishd/mgt_shmem.c @@ -110,7 +110,7 @@ #define MAP_NOSYNC 0 /* XXX Linux */ #endif -struct vsc_main *VSC_main; +struct VSC_C_main *VSC_C_main; static int vsl_fd = -1; @@ -122,7 +122,7 @@ static int vsl_fd = -1; static void vsl_n_check(int fd) { - struct vsm_head slh; + struct VSM_head slh; int i; struct stat st; @@ -157,7 +157,7 @@ vsl_n_check(int fd) static void vsl_buildnew(const char *fn, unsigned size, int fill) { - struct vsm_head slh; + struct VSM_head slh; int i; unsigned u; char buf[64*1024]; @@ -268,26 +268,26 @@ mgt_SHM_Init(const char *l_arg) (void)close(i); vsl_buildnew(VSM_FILENAME, size, fill); - vsm_head = (void *)mmap(NULL, size, + VSM_head = (void *)mmap(NULL, size, PROT_READ|PROT_WRITE, MAP_HASSEMAPHORE | MAP_NOSYNC | MAP_SHARED, vsl_fd, 0); - vsm_head->master_pid = getpid(); - xxxassert(vsm_head != MAP_FAILED); - (void)mlock((void*)vsm_head, size); - - memset(&vsm_head->head, 0, sizeof vsm_head->head); - vsm_head->head.magic = VSM_CHUNK_MAGIC; - vsm_head->head.len = - (uint8_t*)(vsm_head) + size - (uint8_t*)&vsm_head->head; - bprintf(vsm_head->head.class, "%s", VSM_CLASS_FREE); + VSM_head->master_pid = getpid(); + xxxassert(VSM_head != MAP_FAILED); + (void)mlock((void*)VSM_head, size); + + memset(&VSM_head->head, 0, sizeof VSM_head->head); + VSM_head->head.magic = VSM_CHUNK_MAGIC; + VSM_head->head.len = + (uint8_t*)(VSM_head) + size - (uint8_t*)&VSM_head->head; + bprintf(VSM_head->head.class, "%s", VSM_CLASS_FREE); VWMB(); - vsm_end = (void*)((uint8_t*)vsm_head + size); + vsm_end = (void*)((uint8_t*)VSM_head + size); - VSC_main = VSM_Alloc(sizeof *VSC_main, + VSC_C_main = VSM_Alloc(sizeof *VSC_C_main, VSC_CLASS, VSC_TYPE_MAIN, ""); - AN(VSC_main); + AN(VSC_C_main); pp = VSM_Alloc(sizeof *pp, VSM_CLASS_PARAM, "", ""); AN(pp); @@ -306,8 +306,8 @@ mgt_SHM_Init(const char *l_arg) VWMB(); do - vsm_head->alloc_seq = random(); - while (vsm_head->alloc_seq == 0); + VSM_head->alloc_seq = random(); + while (VSM_head->alloc_seq == 0); } @@ -315,5 +315,5 @@ void mgt_SHM_Pid(void) { - vsm_head->master_pid = getpid(); + VSM_head->master_pid = getpid(); } diff --git a/bin/varnishd/stevedore.h b/bin/varnishd/stevedore.h index e284530..cef22ea 100644 --- a/bin/varnishd/stevedore.h +++ b/bin/varnishd/stevedore.h @@ -84,7 +84,7 @@ struct stevedore { void *priv; VTAILQ_ENTRY(stevedore) list; - char ident[16]; /* XXX: match vsm_chunk.ident */ + char ident[16]; /* XXX: match VSM_chunk.ident */ }; struct object *STV_MkObject(struct sess *sp, void *ptr, unsigned ltot, diff --git a/bin/varnishd/storage_file.c b/bin/varnishd/storage_file.c index eca769a..19ce1dd 100644 --- a/bin/varnishd/storage_file.c +++ b/bin/varnishd/storage_file.c @@ -90,7 +90,7 @@ struct smf_sc { unsigned magic; #define SMF_SC_MAGIC 0x52962ee7 struct lock mtx; - struct vsc_smf *stats; + struct VSC_C_smf *stats; const char *filename; int fd; diff --git a/bin/varnishd/storage_malloc.c b/bin/varnishd/storage_malloc.c index 18a9cbf..1d13520 100644 --- a/bin/varnishd/storage_malloc.c +++ b/bin/varnishd/storage_malloc.c @@ -44,7 +44,7 @@ struct sma_sc { #define SMA_SC_MAGIC 0x1ac8a345 struct lock sma_mtx; size_t sma_max; - struct vsc_sma *stats; + struct VSC_C_sma *stats; }; struct sma { diff --git a/bin/varnishd/storage_synth.c b/bin/varnishd/storage_synth.c index 6894e99..b9e53d3 100644 --- a/bin/varnishd/storage_synth.c +++ b/bin/varnishd/storage_synth.c @@ -48,9 +48,9 @@ sms_free(struct storage *sto) CHECK_OBJ_NOTNULL(sto, STORAGE_MAGIC); Lck_Lock(&sms_mtx); - VSC_main->sms_nobj--; - VSC_main->sms_nbytes -= sto->len; - VSC_main->sms_bfree += sto->len; + VSC_C_main->sms_nobj--; + VSC_C_main->sms_nbytes -= sto->len; + VSC_C_main->sms_bfree += sto->len; Lck_Unlock(&sms_mtx); VSB_delete(sto->priv); free(sto); @@ -80,8 +80,8 @@ SMS_Makesynth(struct object *obj) obj->len = 0; Lck_Lock(&sms_mtx); - VSC_main->sms_nreq++; - VSC_main->sms_nobj++; + VSC_C_main->sms_nreq++; + VSC_C_main->sms_nobj++; Lck_Unlock(&sms_mtx); sto = calloc(sizeof *sto, 1); @@ -118,7 +118,7 @@ SMS_Finish(struct object *obj) sto->space = VSB_len(vsb); obj->len = sto->len; Lck_Lock(&sms_mtx); - VSC_main->sms_nbytes += sto->len; - VSC_main->sms_balloc += sto->len; + VSC_C_main->sms_nbytes += sto->len; + VSC_C_main->sms_balloc += sto->len; Lck_Unlock(&sms_mtx); } diff --git a/bin/varnishd/storage_umem.c b/bin/varnishd/storage_umem.c index 016f5c9..37194e3 100644 --- a/bin/varnishd/storage_umem.c +++ b/bin/varnishd/storage_umem.c @@ -58,13 +58,13 @@ smu_alloc(struct stevedore *st, size_t size) struct smu *smu; Lck_Lock(&smu_mtx); - VSC_main->sma_nreq++; - if (VSC_main->sma_nbytes + size > smu_max) + VSC_C_main->sma_nreq++; + if (VSC_C_main->sma_nbytes + size > smu_max) size = 0; else { - VSC_main->sma_nobj++; - VSC_main->sma_nbytes += size; - VSC_main->sma_balloc += size; + VSC_C_main->sma_nobj++; + VSC_C_main->sma_nbytes += size; + VSC_C_main->sma_balloc += size; } Lck_Unlock(&smu_mtx); @@ -95,9 +95,9 @@ smu_free(struct storage *s) smu = s->priv; assert(smu->sz == smu->s.space); Lck_Lock(&smu_mtx); - VSC_main->sma_nobj--; - VSC_main->sma_nbytes -= smu->sz; - VSC_main->sma_bfree += smu->sz; + VSC_C_main->sma_nobj--; + VSC_C_main->sma_nbytes -= smu->sz; + VSC_C_main->sma_bfree += smu->sz; Lck_Unlock(&smu_mtx); umem_free(smu->s.ptr, smu->s.space); umem_free(smu, sizeof *smu); @@ -116,8 +116,8 @@ smu_trim(const struct storage *s, size_t size) memcpy(p, smu->s.ptr, size); umem_free(smu->s.ptr, smu->s.space); Lck_Lock(&smu_mtx); - VSC_main->sma_nbytes -= (smu->sz - size); - VSC_main->sma_bfree += smu->sz - size; + VSC_C_main->sma_nbytes -= (smu->sz - size); + VSC_C_main->sma_bfree += smu->sz - size; smu->sz = size; Lck_Unlock(&smu_mtx); smu->s.ptr = p; diff --git a/bin/varnishd/varnishd.c b/bin/varnishd/varnishd.c index 4a216a9..a3b6fa9 100644 --- a/bin/varnishd/varnishd.c +++ b/bin/varnishd/varnishd.c @@ -557,7 +557,7 @@ main(int argc, char * const *argv) } } - if (vin_n_arg(n_arg, &heritage.name, &dirname, NULL) != 0) { + if (VIN_N_Arg(n_arg, &heritage.name, &dirname, NULL) != 0) { fprintf(stderr, "Invalid instance name: %s\n", strerror(errno)); exit(1); diff --git a/bin/varnishd/vsm.c b/bin/varnishd/vsm.c index 4312d83..cc6b125 100644 --- a/bin/varnishd/vsm.c +++ b/bin/varnishd/vsm.c @@ -58,16 +58,16 @@ #include "vmb.h" /* These two come from beyond (mgt_shmem.c actually) */ -struct vsm_head *vsm_head; -const struct vsm_chunk *vsm_end; +struct VSM_head *VSM_head; +const struct VSM_chunk *vsm_end; static unsigned vsm_mark(void) { unsigned seq; - seq = vsm_head->alloc_seq; - vsm_head->alloc_seq = 0; + seq = VSM_head->alloc_seq; + VSM_head->alloc_seq = 0; VWMB(); return (seq); } @@ -80,8 +80,8 @@ vsm_release(unsigned seq) return; VWMB(); do - vsm_head->alloc_seq = ++seq; - while (vsm_head->alloc_seq == 0); + VSM_head->alloc_seq = ++seq; + while (VSM_head->alloc_seq == 0); } /*--------------------------------------------------------------------*/ @@ -90,10 +90,10 @@ static void vsm_cleanup(void) { unsigned now = (unsigned)TIM_mono(); - struct vsm_chunk *sha, *sha2; + struct VSM_chunk *sha, *sha2; unsigned seq; - CHECK_OBJ_NOTNULL(vsm_head, VSM_HEAD_MAGIC); + CHECK_OBJ_NOTNULL(VSM_head, VSM_HEAD_MAGIC); VSM_ITER(sha) { if (strcmp(sha->class, VSM_CLASS_COOL)) continue; @@ -146,10 +146,10 @@ vsm_cleanup(void) void * VSM__Alloc(unsigned size, const char *class, const char *type, const char *ident) { - struct vsm_chunk *sha, *sha2; + struct VSM_chunk *sha, *sha2; unsigned seq; - CHECK_OBJ_NOTNULL(vsm_head, VSM_HEAD_MAGIC); + CHECK_OBJ_NOTNULL(VSM_head, VSM_HEAD_MAGIC); vsm_cleanup(); @@ -195,10 +195,10 @@ VSM__Alloc(unsigned size, const char *class, const char *type, const char *ident void VSM__Free(const void *ptr) { - struct vsm_chunk *sha; + struct VSM_chunk *sha; unsigned seq; - CHECK_OBJ_NOTNULL(vsm_head, VSM_HEAD_MAGIC); + CHECK_OBJ_NOTNULL(VSM_head, VSM_HEAD_MAGIC); VSM_ITER(sha) if (VSM_PTR(sha) == ptr) break; @@ -216,10 +216,10 @@ VSM__Free(const void *ptr) void VSM__Clean(void) { - struct vsm_chunk *sha; + struct VSM_chunk *sha; unsigned f, seq; - CHECK_OBJ_NOTNULL(vsm_head, VSM_HEAD_MAGIC); + CHECK_OBJ_NOTNULL(VSM_head, VSM_HEAD_MAGIC); f = 0; seq = vsm_mark(); VSM_ITER(sha) { diff --git a/bin/varnishhist/varnishhist.c b/bin/varnishhist/varnishhist.c index 5772de6..948bd57 100644 --- a/bin/varnishhist/varnishhist.c +++ b/bin/varnishhist/varnishhist.c @@ -146,7 +146,7 @@ update(struct VSM_data *vd) } static int -h_hist(void *priv, enum vsl_tag tag, unsigned fd, unsigned len, +h_hist(void *priv, enum VSL_tag_e tag, unsigned fd, unsigned len, unsigned spec, const char *ptr, uint64_t bm) { double b; diff --git a/bin/varnishlog/varnishlog.c b/bin/varnishlog/varnishlog.c index d0e39d0..0a359e0 100644 --- a/bin/varnishlog/varnishlog.c +++ b/bin/varnishlog/varnishlog.c @@ -55,7 +55,7 @@ static int b_flag, c_flag; static struct vsb *ob[65536]; static unsigned char flg[65536]; -static enum vsl_tag last[65536]; +static enum VSL_tag_e last[65536]; static uint64_t bitmap[65536]; #define F_INVCL (1 << 0) @@ -90,7 +90,7 @@ clean_order(struct VSM_data *vd) } static int -h_order(void *priv, enum vsl_tag tag, unsigned fd, unsigned len, +h_order(void *priv, enum VSL_tag_e tag, unsigned fd, unsigned len, unsigned spec, const char *ptr, uint64_t bm) { char type; diff --git a/bin/varnishncsa/varnishncsa.c b/bin/varnishncsa/varnishncsa.c index 39c5cce..20a9958 100644 --- a/bin/varnishncsa/varnishncsa.c +++ b/bin/varnishncsa/varnishncsa.c @@ -208,7 +208,7 @@ clean_logline(struct logline *lp) } static int -collect_backend(struct logline *lp, enum vsl_tag tag, unsigned spec, +collect_backend(struct logline *lp, enum VSL_tag_e tag, unsigned spec, const char *ptr, unsigned len) { const char *end, *next; @@ -322,7 +322,7 @@ collect_backend(struct logline *lp, enum vsl_tag tag, unsigned spec, } static int -collect_client(struct logline *lp, enum vsl_tag tag, unsigned spec, +collect_client(struct logline *lp, enum VSL_tag_e tag, unsigned spec, const char *ptr, unsigned len) { const char *end, *next; @@ -478,7 +478,7 @@ collect_client(struct logline *lp, enum vsl_tag tag, unsigned spec, } static int -h_ncsa(void *priv, enum vsl_tag tag, unsigned fd, +h_ncsa(void *priv, enum VSL_tag_e tag, unsigned fd, unsigned len, unsigned spec, const char *ptr, uint64_t bitmap) { struct logline *lp; diff --git a/bin/varnishreplay/varnishreplay.c b/bin/varnishreplay/varnishreplay.c index 713f125..f0286b1 100644 --- a/bin/varnishreplay/varnishreplay.c +++ b/bin/varnishreplay/varnishreplay.c @@ -90,7 +90,7 @@ isequal(const char *str, const char *reference, const char *end) */ struct message { - enum vsl_tag tag; + enum VSL_tag_e tag; size_t len; char *ptr; VSTAILQ_ENTRY(message) list; @@ -493,7 +493,7 @@ replay_thread(void *arg) char space[1] = " ", crlf[2] = "\r\n"; struct replay_thread *thr = arg; struct message *msg; - enum vsl_tag tag; + enum VSL_tag_e tag; size_t len; char *ptr; const char *next; @@ -635,7 +635,7 @@ clear: } static int -gen_traffic(void *priv, enum vsl_tag tag, unsigned fd, +gen_traffic(void *priv, enum VSL_tag_e tag, unsigned fd, unsigned len, unsigned spec, const char *ptr, uint64_t bitmap) { struct replay_thread *thr; diff --git a/bin/varnishsizes/varnishsizes.c b/bin/varnishsizes/varnishsizes.c index 8d14d3e..f0a51d6 100644 --- a/bin/varnishsizes/varnishsizes.c +++ b/bin/varnishsizes/varnishsizes.c @@ -146,7 +146,7 @@ update(struct VSM_data *vd) } static int -h_hist(void *priv, enum vsl_tag tag, unsigned fd, unsigned len, +h_hist(void *priv, enum VSL_tag_e tag, unsigned fd, unsigned len, unsigned spec, const char *ptr, uint64_t bm) { double b; diff --git a/bin/varnishstat/varnishstat.c b/bin/varnishstat/varnishstat.c index c1408dd..b389175 100644 --- a/bin/varnishstat/varnishstat.c +++ b/bin/varnishstat/varnishstat.c @@ -49,7 +49,7 @@ /*--------------------------------------------------------------------*/ static int -do_xml_cb(void *priv, const struct vsc_point * const pt) +do_xml_cb(void *priv, const struct VSC_point * const pt) { uint64_t val; @@ -92,7 +92,7 @@ struct once_priv { }; static int -do_once_cb(void *priv, const struct vsc_point * const pt) +do_once_cb(void *priv, const struct VSC_point * const pt) { struct once_priv *op; uint64_t val; @@ -118,12 +118,12 @@ do_once_cb(void *priv, const struct vsc_point * const pt) } static void -do_once(struct VSM_data *vd, const struct vsc_main *VSC_main) +do_once(struct VSM_data *vd, const struct VSC_C_main *VSC_C_main) { struct once_priv op; memset(&op, 0, sizeof op); - op.up = VSC_main->uptime; + op.up = VSC_C_main->uptime; op.pad = 18; (void)VSC_Iter(vd, do_once_cb, &op); @@ -132,7 +132,7 @@ do_once(struct VSM_data *vd, const struct vsc_main *VSC_main) /*--------------------------------------------------------------------*/ static int -do_list_cb(void *priv, const struct vsc_point * const pt) +do_list_cb(void *priv, const struct VSC_point * const pt) { int i; @@ -192,7 +192,7 @@ main(int argc, char * const *argv) { int c; struct VSM_data *vd; - const struct vsc_main *VSC_main; + const struct VSC_C_main *VSC_C_main; int delay = 1, once = 0, xml = 0; vd = VSM_New(); @@ -227,14 +227,14 @@ main(int argc, char * const *argv) if (VSC_Open(vd, 1)) exit(1); - VSC_main = VSC_Main(vd); + VSC_C_main = VSC_Main(vd); if (xml) do_xml(vd); else if (once) - do_once(vd, VSC_main); + do_once(vd, VSC_C_main); else - do_curses(vd, VSC_main, delay); + do_curses(vd, VSC_C_main, delay); exit(0); } diff --git a/bin/varnishstat/varnishstat.h b/bin/varnishstat/varnishstat.h index 594eaa8..13d7363 100644 --- a/bin/varnishstat/varnishstat.h +++ b/bin/varnishstat/varnishstat.h @@ -27,4 +27,4 @@ * */ -void do_curses(struct VSM_data *vd, const struct vsc_main *VSC_main, int delay); +void do_curses(struct VSM_data *vd, const struct VSC_C_main *VSC_C_main, int delay); diff --git a/bin/varnishstat/varnishstat_curses.c b/bin/varnishstat/varnishstat_curses.c index 2672255..75fab45 100644 --- a/bin/varnishstat/varnishstat_curses.c +++ b/bin/varnishstat/varnishstat_curses.c @@ -67,7 +67,7 @@ struct pt { static VTAILQ_HEAD(, pt) pthead = VTAILQ_HEAD_INITIALIZER(pthead); static int -do_curses_cb(void *priv, const struct vsc_point * const sp) +do_curses_cb(void *priv, const struct VSC_point * const sp) { struct pt *pt; char buf[128]; @@ -124,7 +124,7 @@ myexp(double *acc, double val, unsigned *n, unsigned nmax) } void -do_curses(struct VSM_data *vd, const struct vsc_main *VSC_main, +do_curses(struct VSM_data *vd, const struct VSC_C_main *VSC_C_main, int delay) { intmax_t ju; @@ -168,7 +168,7 @@ do_curses(struct VSM_data *vd, const struct vsc_main *VSC_main, * Break to outher loop if we need to re-read file. * Only check if it looks like nothing is happening. */ - act = VSC_main->cache_hit + VSC_main->cache_miss + 1; + act = VSC_C_main->cache_hit + VSC_C_main->cache_miss + 1; if (act == lact && VSM_ReOpen(vd, 1)) break; lact = act; @@ -177,15 +177,15 @@ do_curses(struct VSM_data *vd, const struct vsc_main *VSC_main, tt = tv.tv_usec * 1e-6 + tv.tv_sec; lt = tt - lt; - rt = VSC_main->uptime; + rt = VSC_C_main->uptime; up = rt; AC(mvprintw(0, 0, "%*s", COLS - 1, VSM_Name(vd))); AC(mvprintw(0, 0, "%d+%02d:%02d:%02d", rt / 86400, (rt % 86400) / 3600, (rt % 3600) / 60, rt % 60)); - hit = VSC_main->cache_hit; - miss = VSC_main->cache_miss; + hit = VSC_C_main->cache_hit; + miss = VSC_C_main->cache_miss; hr = (hit - lhit) / lt; mr = (miss - lmiss) / lt; lhit = hit; diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c index 52eafab..fb99657 100644 --- a/bin/varnishtest/vtc_varnish.c +++ b/bin/varnishtest/vtc_varnish.c @@ -584,7 +584,7 @@ struct stat_priv { }; static int -do_stat_cb(void *priv, const struct vsc_point * const pt) +do_stat_cb(void *priv, const struct VSC_point * const pt) { struct stat_priv *sp = priv; const char *p = sp->target; diff --git a/include/varnishapi.h b/include/varnishapi.h index dbb3931..6e3529c 100644 --- a/include/varnishapi.h +++ b/include/varnishapi.h @@ -56,9 +56,9 @@ struct VSM_data *VSM_New(void); * Pointer to usable VSL_data handle. */ -typedef void vsm_diag_f(void *priv, const char *fmt, ...); +typedef void VSM_diag_f(void *priv, const char *fmt, ...); -void VSM_Diag(struct VSM_data *vd, vsm_diag_f *func, void *priv); +void VSM_Diag(struct VSM_data *vd, VSM_diag_f *func, void *priv); /* * Set the diagnostics reporting function. * Default is fprintf(stderr, ...) @@ -114,7 +114,7 @@ unsigned VSM_Seq(struct VSM_data *vd); * Return the allocation sequence number */ -struct vsm_head *VSM_Head(const struct VSM_data *vd); +struct VSM_head *VSM_Head(const struct VSM_data *vd); /* * Return the head of the VSM. */ @@ -133,15 +133,15 @@ void VSM_Close(struct VSM_data *vd); * Deallocate all storage (including VSC and VSL allocations) */ -struct vsm_chunk *vsm_iter0(struct VSM_data *vd); -void vsm_itern(const struct VSM_data *vd, struct vsm_chunk **pp); +struct VSM_chunk *VSM_iter0(struct VSM_data *vd); +void VSM_itern(const struct VSM_data *vd, struct VSM_chunk **pp); #define VSM_FOREACH(var, vd) \ - for((var) = vsm_iter0((vd)); (var) != NULL; vsm_itern((vd), &(var))) + for((var) = VSM_iter0((vd)); (var) != NULL; VSM_itern((vd), &(var))) /* * Iterate over all chunks in shared memory - * var = "struct vsm_chunk *" + * var = "struct VSM_chunk *" * vd = "struct VSM_data" */ @@ -173,12 +173,12 @@ int VSC_Open(struct VSM_data *vd, int diag); * args and returns as VSM_Open() */ -struct vsc_main *VSC_Main(struct VSM_data *vd); +struct VSC_C_main *VSC_Main(struct VSM_data *vd); /* * return Main stats structure */ -struct vsc_point { +struct VSC_point { const char *class; /* stat struct type */ const char *ident; /* stat struct ident */ const char *name; /* field name */ @@ -188,7 +188,7 @@ struct vsc_point { const volatile void *ptr; /* field value */ }; -typedef int vsc_iter_f(void *priv, const struct vsc_point *const pt); +typedef int vsc_iter_f(void *priv, const struct VSC_point *const pt); int VSC_Iter(struct VSM_data *vd, vsc_iter_f *func, void *priv); /* @@ -248,16 +248,16 @@ int VSL_Arg(struct VSM_data *vd, int arg, const char *opt); * 1 Handled. */ -typedef int vsl_handler(void *priv, enum vsl_tag tag, unsigned fd, +typedef int VSL_handler_f(void *priv, enum VSL_tag_e tag, unsigned fd, unsigned len, unsigned spec, const char *ptr, uint64_t bitmap); #define VSL_S_CLIENT (1 << 0) #define VSL_S_BACKEND (1 << 1) -vsl_handler VSL_H_Print; +VSL_handler_f VSL_H_Print; struct VSM_data; void VSL_Select(const struct VSM_data *vd, unsigned tag); void VSL_NonBlocking(const struct VSM_data *vd, int nb); -int VSL_Dispatch(struct VSM_data *vd, vsl_handler *func, void *priv); +int VSL_Dispatch(struct VSM_data *vd, VSL_handler_f *func, void *priv); int VSL_NextLog(const struct VSM_data *lh, uint32_t **pp, uint64_t *bitmap); int VSL_Matched(const struct VSM_data *vd, uint64_t bitmap); extern const char *VSL_tags[256]; diff --git a/include/vin.h b/include/vin.h index f0e0d95..17ff389 100644 --- a/include/vin.h +++ b/include/vin.h @@ -32,5 +32,5 @@ #define VIN_H_INCLUDED /* This function lives in both libvarnish and libvarnishapi */ -int vin_n_arg(const char *n_arg, char **name, char **dir, char **vsl); +int VIN_N_Arg(const char *n_arg, char **name, char **dir, char **vsl); #endif diff --git a/include/vsc.h b/include/vsc.h index 1e714c7..498f9df 100644 --- a/include/vsc.h +++ b/include/vsc.h @@ -40,7 +40,7 @@ #define VSC_F(n, t, l, f, e) t n; -#define VSC_DO(u,l,t) struct vsc_##l { +#define VSC_DO(u,l,t) struct VSC_C_##l { #define VSC_DONE(u,l,t) }; #include "vsc_all.h" diff --git a/include/vsl.h b/include/vsl.h index 222167a..24acfa6 100644 --- a/include/vsl.h +++ b/include/vsl.h @@ -65,7 +65,7 @@ * The identifiers in shmlogtag are "SLT_" + XML tag. A script may be run * on this file to extract the table rather than handcode it */ -enum vsl_tag { +enum VSL_tag_e { #define SLTM(foo) SLT_##foo, #include "vsl_tags.h" #undef SLTM diff --git a/include/vsm.h b/include/vsm.h index 0f67b1e..62f3b48 100644 --- a/include/vsm.h +++ b/include/vsm.h @@ -43,7 +43,7 @@ * This structure describes each allocation from the shmlog */ -struct vsm_chunk { +struct VSM_chunk { #define VSM_CHUNK_MAGIC 0x43907b6e /* From /dev/random */ unsigned magic; unsigned len; @@ -56,7 +56,7 @@ struct vsm_chunk { #define VSM_NEXT(sha) ((void*)((uintptr_t)(sha) + (sha)->len)) #define VSM_PTR(sha) ((void*)((uintptr_t)((sha) + 1))) -struct vsm_head { +struct VSM_head { #define VSM_HEAD_MAGIC 4185512502U /* From /dev/random */ unsigned magic; @@ -73,7 +73,7 @@ struct vsm_head { unsigned alloc_seq; /* Must be last element */ - struct vsm_chunk head; + struct VSM_chunk head; }; /* @@ -82,20 +82,20 @@ struct vsm_head { */ #ifdef CHECK_OBJ_NOTNULL -static inline struct vsm_chunk * +static inline struct VSM_chunk * vsm_iter_0(void) { - CHECK_OBJ_NOTNULL(vsm_head, VSM_HEAD_MAGIC); - CHECK_OBJ_NOTNULL(&vsm_head->head, VSM_CHUNK_MAGIC); - return (&vsm_head->head); + CHECK_OBJ_NOTNULL(VSM_head, VSM_HEAD_MAGIC); + CHECK_OBJ_NOTNULL(&VSM_head->head, VSM_CHUNK_MAGIC); + return (&VSM_head->head); } static inline void -vsm_iter_n(struct vsm_chunk **pp) +vsm_iter_n(struct VSM_chunk **pp) { - CHECK_OBJ_NOTNULL(vsm_head, VSM_HEAD_MAGIC); + CHECK_OBJ_NOTNULL(VSM_head, VSM_HEAD_MAGIC); CHECK_OBJ_NOTNULL(*pp, VSM_CHUNK_MAGIC); *pp = VSM_NEXT(*pp); if (*pp >= vsm_end) { diff --git a/lib/libvarnish/vin.c b/lib/libvarnish/vin.c index 8ebd5fd..d05a581 100644 --- a/lib/libvarnish/vin.c +++ b/lib/libvarnish/vin.c @@ -41,7 +41,7 @@ #include "vin.h" int -vin_n_arg(const char *n_arg, char **name, char **dir, char **vsl) +VIN_N_Arg(const char *n_arg, char **name, char **dir, char **vsl) { char nm[PATH_MAX]; char dn[PATH_MAX]; diff --git a/lib/libvarnishapi/vsc.c b/lib/libvarnishapi/vsc.c index 2902e13..907a4d0 100644 --- a/lib/libvarnishapi/vsc.c +++ b/lib/libvarnishapi/vsc.c @@ -85,7 +85,7 @@ VSC_Setup(struct VSM_data *vd) /*--------------------------------------------------------------------*/ void -vsc_delete(struct VSM_data *vd) +VSC_Delete(struct VSM_data *vd) { struct vsc_sf *sf; struct vsc *vsc; @@ -219,15 +219,15 @@ VSC_Open(struct VSM_data *vd, int diag) /*--------------------------------------------------------------------*/ -struct vsc_main * +struct VSC_C_main * VSC_Main(struct VSM_data *vd) { - struct vsm_chunk *sha; + struct VSM_chunk *sha; CHECK_OBJ_NOTNULL(vd, VSM_MAGIC); CHECK_OBJ_NOTNULL(vd->vsc, VSC_MAGIC); - sha = vsm_find_alloc(vd, VSC_CLASS, "", ""); + sha = VSM_find_alloc(vd, VSC_CLASS, "", ""); assert(sha != NULL); return (VSM_PTR(sha)); } @@ -251,7 +251,7 @@ iter_test(const char *s1, const char *s2, int wc) static int iter_call(const struct vsc *vsc, vsc_iter_f *func, void *priv, - const struct vsc_point *const sp) + const struct VSC_point *const sp) { struct vsc_sf *sf; int good; @@ -282,11 +282,11 @@ iter_call(const struct vsc *vsc, vsc_iter_f *func, void *priv, #define VSC_DO(U,l,t) \ static int \ - iter_##l(const struct vsc *vsc, struct vsm_chunk *sha, \ + iter_##l(const struct vsc *vsc, struct VSM_chunk *sha, \ vsc_iter_f *func, void *priv) \ { \ - struct vsc_##l *st; \ - struct vsc_point sp; \ + struct VSC_C_##l *st; \ + struct VSC_point sp; \ int i; \ \ CHECK_OBJ_NOTNULL(vsc, VSC_MAGIC); \ @@ -318,7 +318,7 @@ int VSC_Iter(struct VSM_data *vd, vsc_iter_f *func, void *priv) { struct vsc *vsc; - struct vsm_chunk *sha; + struct VSM_chunk *sha; int i; CHECK_OBJ_NOTNULL(vd, VSM_MAGIC); diff --git a/lib/libvarnishapi/vsl.c b/lib/libvarnishapi/vsl.c index 23d2ff7..e6ba5ae 100644 --- a/lib/libvarnishapi/vsl.c +++ b/lib/libvarnishapi/vsl.c @@ -93,7 +93,7 @@ VSL_Setup(struct VSM_data *vd) /*--------------------------------------------------------------------*/ void -vsl_delete(struct VSM_data *vd) +VSL_Delete(struct VSM_data *vd) { struct vsl *vsl; @@ -279,7 +279,7 @@ VSL_NextLog(const struct VSM_data *vd, uint32_t **pp, uint64_t *mb) /*--------------------------------------------------------------------*/ int -VSL_Dispatch(struct VSM_data *vd, vsl_handler *func, void *priv) +VSL_Dispatch(struct VSM_data *vd, VSL_handler_f *func, void *priv) { struct vsl *vsl; int i; @@ -313,7 +313,7 @@ VSL_Dispatch(struct VSM_data *vd, vsl_handler *func, void *priv) /*--------------------------------------------------------------------*/ int -VSL_H_Print(void *priv, enum vsl_tag tag, unsigned fd, unsigned len, +VSL_H_Print(void *priv, enum VSL_tag_e tag, unsigned fd, unsigned len, unsigned spec, const char *ptr, uint64_t bitmap) { FILE *fo = priv; @@ -344,15 +344,15 @@ VSL_H_Print(void *priv, enum vsl_tag tag, unsigned fd, unsigned len, /*--------------------------------------------------------------------*/ void -vsl_open_cb(struct VSM_data *vd) +VSL_Open_CallBack(struct VSM_data *vd) { struct vsl *vsl; - struct vsm_chunk *sha; + struct VSM_chunk *sha; CHECK_OBJ_NOTNULL(vd, VSM_MAGIC); vsl = vd->vsl; CHECK_OBJ_NOTNULL(vsl, VSL_MAGIC); - sha = vsm_find_alloc(vd, VSL_CLASS, "", ""); + sha = VSM_find_alloc(vd, VSL_CLASS, "", ""); assert(sha != NULL); vsl->log_start = VSM_PTR(sha); diff --git a/lib/libvarnishapi/vsm.c b/lib/libvarnishapi/vsm.c index b0adc96..cb96782 100644 --- a/lib/libvarnishapi/vsm.c +++ b/lib/libvarnishapi/vsm.c @@ -63,7 +63,7 @@ VSM_New(void) ALLOC_OBJ(vd, VSM_MAGIC); AN(vd); - vd->diag = (vsm_diag_f*)fprintf; + vd->diag = (VSM_diag_f*)fprintf; vd->priv = stderr; vd->vsm_fd = -1; @@ -75,12 +75,12 @@ VSM_New(void) /*--------------------------------------------------------------------*/ void -VSM_Diag(struct VSM_data *vd, vsm_diag_f *func, void *priv) +VSM_Diag(struct VSM_data *vd, VSM_diag_f *func, void *priv) { CHECK_OBJ_NOTNULL(vd, VSM_MAGIC); if (func == NULL) - vd->diag = (vsm_diag_f*)getpid; + vd->diag = (VSM_diag_f*)getpid; else vd->diag = func; vd->priv = priv; @@ -95,7 +95,7 @@ VSM_n_Arg(struct VSM_data *vd, const char *opt) CHECK_OBJ_NOTNULL(vd, VSM_MAGIC); REPLACE(vd->n_opt, opt); AN(vd->n_opt); - if (vin_n_arg(vd->n_opt, NULL, NULL, &vd->fname)) { + if (VIN_N_Arg(vd->n_opt, NULL, NULL, &vd->fname)) { vd->diag(vd->priv, "Invalid instance name: %s\n", strerror(errno)); return (-1); @@ -127,9 +127,9 @@ VSM_Delete(struct VSM_data *vd) free(vd->fname); if (vd->vsc != NULL) - vsc_delete(vd); + VSC_Delete(vd); if (vd->vsl != NULL) - vsl_delete(vd); + VSL_Delete(vd); free(vd); } @@ -140,10 +140,10 @@ static int vsm_open(struct VSM_data *vd, int diag) { int i, j; - struct vsm_head slh; + struct VSM_head slh; CHECK_OBJ_NOTNULL(vd, VSM_MAGIC); - AZ(vd->vsm_head); + AZ(vd->VSM_head); AN(vd->fname); vd->vsm_fd = open(vd->fname, O_RDONLY); @@ -182,15 +182,15 @@ vsm_open(struct VSM_data *vd, int diag) return (1); } - vd->vsm_head = (void *)mmap(NULL, slh.shm_size, + vd->VSM_head = (void *)mmap(NULL, slh.shm_size, PROT_READ, MAP_SHARED|MAP_HASSEMAPHORE, vd->vsm_fd, 0); - if (vd->vsm_head == MAP_FAILED) { + if (vd->VSM_head == MAP_FAILED) { if (diag) vd->diag(vd->priv, "Cannot mmap %s: %s\n", vd->fname, strerror(errno)); return (1); } - vd->vsm_end = (uint8_t *)vd->vsm_head + slh.shm_size; + vd->vsm_end = (uint8_t *)vd->VSM_head + slh.shm_size; for (j = 0; j < 20 && slh.alloc_seq == 0; j++) (void)usleep(50000); @@ -198,7 +198,7 @@ vsm_open(struct VSM_data *vd, int diag) if (diag) vd->diag(vd->priv, "File not initialized %s\n", vd->fname); - assert(0 == munmap((void*)vd->vsm_head, slh.shm_size)); + assert(0 == munmap((void*)vd->VSM_head, slh.shm_size)); AZ(close(vd->vsm_fd)); vd->vsm_fd = -1; return (1); @@ -206,7 +206,7 @@ vsm_open(struct VSM_data *vd, int diag) vd->alloc_seq = slh.alloc_seq; if (vd->vsl != NULL) - vsl_open_cb(vd); + VSL_Open_CallBack(vd); return (0); } @@ -218,7 +218,7 @@ VSM_Open(struct VSM_data *vd, int diag) { CHECK_OBJ_NOTNULL(vd, VSM_MAGIC); - AZ(vd->vsm_head); + AZ(vd->VSM_head); if (!vd->n_opt) VSM_n_Arg(vd, ""); return (vsm_open(vd, diag)); @@ -231,10 +231,10 @@ VSM_Close(struct VSM_data *vd) { CHECK_OBJ_NOTNULL(vd, VSM_MAGIC); - if (vd->vsm_head == NULL) + if (vd->VSM_head == NULL) return; - assert(0 == munmap((void*)vd->vsm_head, vd->vsm_head->shm_size)); - vd->vsm_head = NULL; + assert(0 == munmap((void*)vd->VSM_head, vd->VSM_head->shm_size)); + vd->VSM_head = NULL; assert(vd->vsm_fd >= 0); assert(0 == close(vd->vsm_fd)); vd->vsm_fd = -1; @@ -249,7 +249,7 @@ VSM_ReOpen(struct VSM_data *vd, int diag) int i; CHECK_OBJ_NOTNULL(vd, VSM_MAGIC); - AN(vd->vsm_head); + AN(vd->VSM_head); if (stat(vd->fname, &st)) return (0); @@ -269,25 +269,25 @@ VSM_ReOpen(struct VSM_data *vd, int diag) /*--------------------------------------------------------------------*/ -struct vsm_head * +struct VSM_head * VSM_Head(const struct VSM_data *vd) { CHECK_OBJ_NOTNULL(vd, VSM_MAGIC); - AN(vd->vsm_head); - return(vd->vsm_head); + AN(vd->VSM_head); + return(vd->VSM_head); } /*--------------------------------------------------------------------*/ -struct vsm_chunk * -vsm_find_alloc(struct VSM_data *vd, const char *class, const char *type, const char *ident) +struct VSM_chunk * +VSM_find_alloc(struct VSM_data *vd, const char *class, const char *type, const char *ident) { - struct vsm_chunk *sha; + struct VSM_chunk *sha; CHECK_OBJ_NOTNULL(vd, VSM_MAGIC); - AN(vd->vsm_head); + AN(vd->VSM_head); VSM_FOREACH(sha, vd) { CHECK_OBJ_NOTNULL(sha, VSM_CHUNK_MAGIC); if (strcmp(sha->class, class)) @@ -307,10 +307,10 @@ void * VSM_Find_Chunk(struct VSM_data *vd, const char *class, const char *type, const char *ident, unsigned *lenp) { - struct vsm_chunk *sha; + struct VSM_chunk *sha; CHECK_OBJ_NOTNULL(vd, VSM_MAGIC); - sha = vsm_find_alloc(vd, class, type, ident); + sha = VSM_find_alloc(vd, class, type, ident); if (sha == NULL) return (NULL); if (lenp != NULL) @@ -320,26 +320,26 @@ VSM_Find_Chunk(struct VSM_data *vd, const char *class, const char *type, /*--------------------------------------------------------------------*/ -struct vsm_chunk * -vsm_iter0(struct VSM_data *vd) +struct VSM_chunk * +VSM_iter0(struct VSM_data *vd) { CHECK_OBJ_NOTNULL(vd, VSM_MAGIC); - vd->alloc_seq = vd->vsm_head->alloc_seq; + vd->alloc_seq = vd->VSM_head->alloc_seq; while (vd->alloc_seq == 0) { usleep(50000); - vd->alloc_seq = vd->vsm_head->alloc_seq; + vd->alloc_seq = vd->VSM_head->alloc_seq; } - CHECK_OBJ_NOTNULL(&vd->vsm_head->head, VSM_CHUNK_MAGIC); - return (&vd->vsm_head->head); + CHECK_OBJ_NOTNULL(&vd->VSM_head->head, VSM_CHUNK_MAGIC); + return (&vd->VSM_head->head); } void -vsm_itern(const struct VSM_data *vd, struct vsm_chunk **pp) +VSM_itern(const struct VSM_data *vd, struct VSM_chunk **pp) { CHECK_OBJ_NOTNULL(vd, VSM_MAGIC); - if (vd->alloc_seq != vd->vsm_head->alloc_seq) { + if (vd->alloc_seq != vd->VSM_head->alloc_seq) { *pp = NULL; return; } @@ -358,5 +358,5 @@ VSM_Seq(struct VSM_data *vd) { CHECK_OBJ_NOTNULL(vd, VSM_MAGIC); - return (vd->vsm_head->alloc_seq); + return (vd->VSM_head->alloc_seq); } diff --git a/lib/libvarnishapi/vsm_api.h b/lib/libvarnishapi/vsm_api.h index f88e0ee..30f2926 100644 --- a/lib/libvarnishapi/vsm_api.h +++ b/lib/libvarnishapi/vsm_api.h @@ -38,7 +38,7 @@ struct VSM_data { unsigned magic; #define VSM_MAGIC 0x6e3bd69b - vsm_diag_f *diag; + VSM_diag_f *diag; void *priv; char *n_opt; @@ -48,7 +48,7 @@ struct VSM_data { struct stat fstat; int vsm_fd; - struct vsm_head *vsm_head; + struct VSM_head *VSM_head; void *vsm_end; unsigned alloc_seq; @@ -58,9 +58,9 @@ struct VSM_data { struct vsl *vsl; }; -struct vsm_chunk *vsm_find_alloc(struct VSM_data *vd, const char *class, +struct VSM_chunk *VSM_find_alloc(struct VSM_data *vd, const char *class, const char *type, const char *ident); -void vsc_delete(struct VSM_data *vd); -void vsl_delete(struct VSM_data *vd); -void vsl_open_cb(struct VSM_data *vd); +void VSC_Delete(struct VSM_data *vd); +void VSL_Delete(struct VSM_data *vd); +void VSL_Open_CallBack(struct VSM_data *vd); From phk at varnish-cache.org Tue May 31 11:15:05 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 31 May 2011 13:15:05 +0200 Subject: [master] e8c859b Namespace cleanup: TCP_ -> VTCP Message-ID: commit e8c859b8af5e3d7ed5ff13848cc83480e7b98a79 Author: Poul-Henning Kamp Date: Tue May 31 10:22:09 2011 +0000 Namespace cleanup: TCP_ -> VTCP diff --git a/bin/varnishd/cache_acceptor.c b/bin/varnishd/cache_acceptor.c index 275c7e8..74e3359 100644 --- a/bin/varnishd/cache_acceptor.c +++ b/bin/varnishd/cache_acceptor.c @@ -106,7 +106,7 @@ sock_test(int fd) l = sizeof lin; i = getsockopt(fd, SOL_SOCKET, SO_LINGER, &lin, &l); if (i) { - TCP_Assert(i); + VTCP_Assert(i); return; } assert(l == sizeof lin); @@ -117,7 +117,7 @@ sock_test(int fd) l = sizeof tv; i = getsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, &tv, &l); if (i) { - TCP_Assert(i); + VTCP_Assert(i); return; } assert(l == sizeof tv); @@ -133,7 +133,7 @@ sock_test(int fd) l = sizeof tv; i = getsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &tv, &l); if (i) { - TCP_Assert(i); + VTCP_Assert(i); return; } assert(l == sizeof tv); @@ -156,16 +156,16 @@ sock_test(int fd) void VCA_Prep(struct sess *sp) { - char addr[TCP_ADDRBUFSIZE]; - char port[TCP_PORTBUFSIZE]; + char addr[VTCP_ADDRBUFSIZE]; + char port[VTCP_PORTBUFSIZE]; - TCP_name(sp->sockaddr, sp->sockaddrlen, + VTCP_name(sp->sockaddr, sp->sockaddrlen, addr, sizeof addr, port, sizeof port); sp->addr = WS_Dup(sp->ws, addr); sp->port = WS_Dup(sp->ws, port); if (params->log_local_addr) { AZ(getsockname(sp->fd, (void*)sp->mysockaddr, &sp->mysockaddrlen)); - TCP_name(sp->mysockaddr, sp->mysockaddrlen, + VTCP_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); @@ -177,16 +177,16 @@ VCA_Prep(struct sess *sp) if (need_test) sock_test(sp->fd); if (need_linger) - TCP_Assert(setsockopt(sp->fd, SOL_SOCKET, SO_LINGER, + VTCP_Assert(setsockopt(sp->fd, SOL_SOCKET, SO_LINGER, &linger, sizeof linger)); #ifdef SO_SNDTIMEO_WORKS if (need_sndtimeo) - TCP_Assert(setsockopt(sp->fd, SOL_SOCKET, SO_SNDTIMEO, + VTCP_Assert(setsockopt(sp->fd, SOL_SOCKET, SO_SNDTIMEO, &tv_sndtimeo, sizeof tv_sndtimeo)); #endif #ifdef SO_RCVTIMEO_WORKS if (need_rcvtimeo) - TCP_Assert(setsockopt(sp->fd, SOL_SOCKET, SO_RCVTIMEO, + VTCP_Assert(setsockopt(sp->fd, SOL_SOCKET, SO_RCVTIMEO, &tv_rcvtimeo, sizeof tv_rcvtimeo)); #endif } @@ -382,7 +382,7 @@ vca_return_session(struct sess *sp) * Set nonblocking in the worker-thread, before passing to the * acceptor thread, to reduce syscall density of the latter. */ - if (TCP_nonblocking(sp->fd)) + if (VTCP_nonblocking(sp->fd)) vca_close_session(sp, "remote closed"); else if (vca_act->pass == NULL) assert(sizeof sp == write(vca_pipes[1], &sp, sizeof sp)); @@ -427,7 +427,7 @@ ccf_listen_address(struct cli *cli, const char * const *av, void *priv) VTAILQ_FOREACH(ls, &heritage.socks, list) { if (ls->sock < 0) continue; - TCP_myname(ls->sock, h, sizeof h, p, sizeof p); + VTCP_myname(ls->sock, h, sizeof h, p, sizeof p); cli_out(cli, "%s %s\n", h, p); } } diff --git a/bin/varnishd/cache_backend.c b/bin/varnishd/cache_backend.c index a523501..819aac7 100644 --- a/bin/varnishd/cache_backend.c +++ b/bin/varnishd/cache_backend.c @@ -118,8 +118,8 @@ vbe_TryConnect(const struct sess *sp, int pf, const struct sockaddr_storage *sa, { int s, i, tmo; double tmod; - char abuf1[TCP_ADDRBUFSIZE], abuf2[TCP_ADDRBUFSIZE]; - char pbuf1[TCP_PORTBUFSIZE], pbuf2[TCP_PORTBUFSIZE]; + char abuf1[VTCP_ADDRBUFSIZE], abuf2[VTCP_ADDRBUFSIZE]; + char pbuf1[VTCP_PORTBUFSIZE], pbuf2[VTCP_PORTBUFSIZE]; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(vs, VDI_SIMPLE_MAGIC); @@ -132,15 +132,15 @@ vbe_TryConnect(const struct sess *sp, int pf, const struct sockaddr_storage *sa, tmo = (int)(tmod * 1000.0); - i = TCP_connect(s, sa, salen, tmo); + i = VTCP_connect(s, sa, salen, tmo); if (i != 0) { AZ(close(s)); return (-1); } - TCP_myname(s, abuf1, sizeof abuf1, pbuf1, sizeof pbuf1); - TCP_name(sa, salen, abuf2, sizeof abuf2, pbuf2, sizeof pbuf2); + VTCP_myname(s, abuf1, sizeof abuf1, pbuf1, sizeof pbuf1); + VTCP_name(sa, salen, abuf2, sizeof abuf2, pbuf2, sizeof pbuf2); WSL(sp->wrk, SLT_BackendOpen, s, "%s %s %s %s %s", vs->backend->vcl_name, abuf1, pbuf1, abuf2, pbuf2); @@ -360,7 +360,7 @@ vbe_GetVbe(const struct sess *sp, struct vdi_simple *vs) before the OS reuses the FD */ WSL_Flush(sp->wrk, 0); - TCP_close(&vc->fd); + VTCP_close(&vc->fd); VBE_DropRefConn(bp); vc->backend = NULL; VBE_ReleaseConn(vc); diff --git a/bin/varnishd/cache_backend_poll.c b/bin/varnishd/cache_backend_poll.c index 61ed687..ce55e39 100644 --- a/bin/varnishd/cache_backend_poll.c +++ b/bin/varnishd/cache_backend_poll.c @@ -114,10 +114,10 @@ vbp_connect(int pf, const struct sockaddr_storage *sa, socklen_t salen, int tmo) if (s < 0) return (s); - i = TCP_connect(s, sa, salen, tmo); + i = VTCP_connect(s, sa, salen, tmo); if (i == 0) return (s); - TCP_close(&s); + VTCP_close(&s); return (-1); } @@ -166,7 +166,7 @@ vbp_poke(struct vbp_target *vt) } if (tmo <= 0) { /* Spent too long time getting it */ - TCP_close(&s); + VTCP_close(&s); return; } @@ -175,7 +175,7 @@ vbp_poke(struct vbp_target *vt) if (i != vt->req_len) { if (i < 0) vt->err_xmit |= 1; - TCP_close(&s); + VTCP_close(&s); return; } vt->good_xmit |= 1; @@ -189,7 +189,7 @@ vbp_poke(struct vbp_target *vt) if (tmo > 0) i = poll(pfd, 1, tmo); if (i == 0 || tmo <= 0) { - TCP_close(&s); + VTCP_close(&s); return; } if (rlen < sizeof vt->resp_buf) @@ -200,7 +200,7 @@ vbp_poke(struct vbp_target *vt) rlen += i; } while (i > 0); - TCP_close(&s); + VTCP_close(&s); if (i < 0) { vt->err_recv |= 1; diff --git a/bin/varnishd/cache_center.c b/bin/varnishd/cache_center.c index 59e22d4..4f69e47 100644 --- a/bin/varnishd/cache_center.c +++ b/bin/varnishd/cache_center.c @@ -350,7 +350,7 @@ cnt_done(struct sess *sp) * This is an orderly close of the connection; ditch nolinger * before we close, to get queued data transmitted. */ - // XXX: not yet (void)TCP_linger(sp->fd, 0); + // XXX: not yet (void)VTCP_linger(sp->fd, 0); vca_close_session(sp, sp->doclose); } @@ -1497,7 +1497,7 @@ CNT_Session(struct sess *sp) * do the syscall in the worker thread. */ if (sp->step == STP_FIRST || sp->step == STP_START) - (void)TCP_blocking(sp->fd); + (void)VTCP_blocking(sp->fd); /* * NB: Once done is set, we can no longer touch sp! diff --git a/bin/varnishd/cache_dir.c b/bin/varnishd/cache_dir.c index 4aa7a8f..5ec4e11 100644 --- a/bin/varnishd/cache_dir.c +++ b/bin/varnishd/cache_dir.c @@ -54,7 +54,7 @@ VDI_CloseFd(struct sess *sp) before the OS reuses the FD */ WSL_Flush(sp->wrk, 0); - TCP_close(&sp->vbc->fd); + VTCP_close(&sp->vbc->fd); VBE_DropRefConn(bp); sp->vbc->backend = NULL; VBE_ReleaseConn(sp->vbc); diff --git a/bin/varnishd/cache_fetch.c b/bin/varnishd/cache_fetch.c index b224146..1cc9dc2 100644 --- a/bin/varnishd/cache_fetch.c +++ b/bin/varnishd/cache_fetch.c @@ -415,7 +415,7 @@ FetchHdr(struct sess *sp) if (!http_GetHdr(hp, H_Host, &b)) VDI_AddHostHeader(sp); - (void)TCP_blocking(vc->fd); /* XXX: we should timeout instead */ + (void)VTCP_blocking(vc->fd); /* XXX: we should timeout instead */ WRW_Reserve(w, &vc->fd); (void)http_Write(w, hp, 0); /* XXX: stats ? */ @@ -440,7 +440,7 @@ FetchHdr(struct sess *sp) HTC_Init(sp->wrk->htc, sp->wrk->ws, vc->fd, params->http_resp_size, params->http_resp_hdr_len); - TCP_set_read_timeout(vc->fd, vc->first_byte_timeout); + VTCP_set_read_timeout(vc->fd, vc->first_byte_timeout); i = HTC_Rx(sp->wrk->htc); @@ -453,7 +453,7 @@ FetchHdr(struct sess *sp) return (i == -1 ? retry : -1); } - TCP_set_read_timeout(vc->fd, vc->between_bytes_timeout); + VTCP_set_read_timeout(vc->fd, vc->between_bytes_timeout); while (i == 0) { i = HTC_Rx(sp->wrk->htc); diff --git a/bin/varnishd/cache_pipe.c b/bin/varnishd/cache_pipe.c index 73d03e8..2f8c91c 100644 --- a/bin/varnishd/cache_pipe.c +++ b/bin/varnishd/cache_pipe.c @@ -75,7 +75,7 @@ PipeSession(struct sess *sp) if (sp->vbc == NULL) return; vc = sp->vbc; - (void)TCP_blocking(vc->fd); + (void)VTCP_blocking(vc->fd); WRW_Reserve(w, &vc->fd); sp->acct_req.hdrbytes += http_Write(w, sp->wrk->bereq, 0); @@ -96,11 +96,11 @@ PipeSession(struct sess *sp) memset(fds, 0, sizeof fds); - // XXX: not yet (void)TCP_linger(vc->fd, 0); + // XXX: not yet (void)VTCP_linger(vc->fd, 0); fds[0].fd = vc->fd; fds[0].events = POLLIN | POLLERR; - // XXX: not yet (void)TCP_linger(sp->fd, 0); + // XXX: not yet (void)VTCP_linger(sp->fd, 0); fds[1].fd = sp->fd; fds[1].events = POLLIN | POLLERR; diff --git a/bin/varnishd/cache_vrt_var.c b/bin/varnishd/cache_vrt_var.c index ec82a06..6fe7b6c 100644 --- a/bin/varnishd/cache_vrt_var.c +++ b/bin/varnishd/cache_vrt_var.c @@ -269,7 +269,7 @@ VRT_r_beresp_backend_port(const struct sess *sp) CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(sp->vbc, VBC_MAGIC); - return (TCP_port(sp->vbc->addr)); + return (VTCP_port(sp->vbc->addr)); } const char * __match_proto__() @@ -446,7 +446,7 @@ VRT_r_server_ip(struct sess *sp) if (sp->mysockaddr->ss_family == AF_UNSPEC) { i = getsockname(sp->fd, (void*)sp->mysockaddr, &sp->mysockaddrlen); - assert(TCP_Check(i)); + assert(VTCP_Check(i)); } return (sp->mysockaddr); @@ -485,7 +485,7 @@ VRT_r_server_port(struct sess *sp) if (sp->mysockaddr->ss_family == AF_UNSPEC) AZ(getsockname(sp->fd, (void*)sp->mysockaddr, &sp->mysockaddrlen)); - return (TCP_port(sp->mysockaddr)); + return (VTCP_port(sp->mysockaddr)); } /*--------------------------------------------------------------------*/ diff --git a/bin/varnishd/cache_waiter_epoll.c b/bin/varnishd/cache_waiter_epoll.c index 76d06f2..a44f8a0 100644 --- a/bin/varnishd/cache_waiter_epoll.c +++ b/bin/varnishd/cache_waiter_epoll.c @@ -193,7 +193,7 @@ vca_main(void *arg) if (sp->t_open > deadline) break; VTAILQ_REMOVE(&sesshead, sp, list); - // XXX: not yet TCP_linger(sp->fd, 0); + // XXX: not yet VTCP_linger(sp->fd, 0); vca_close_session(sp, "timeout"); SES_Delete(sp); } diff --git a/bin/varnishd/cache_waiter_kqueue.c b/bin/varnishd/cache_waiter_kqueue.c index b185592..246680c 100644 --- a/bin/varnishd/cache_waiter_kqueue.c +++ b/bin/varnishd/cache_waiter_kqueue.c @@ -194,7 +194,7 @@ vca_kqueue_main(void *arg) if (sp->t_open > deadline) break; VTAILQ_REMOVE(&sesshead, sp, list); - // XXX: not yet (void)TCP_linger(sp->fd, 0); + // XXX: not yet (void)VTCP_linger(sp->fd, 0); vca_close_session(sp, "timeout"); SES_Delete(sp); } diff --git a/bin/varnishd/cache_waiter_poll.c b/bin/varnishd/cache_waiter_poll.c index 6635cf2..cef0513 100644 --- a/bin/varnishd/cache_waiter_poll.c +++ b/bin/varnishd/cache_waiter_poll.c @@ -162,7 +162,7 @@ vca_main(void *arg) } else if (sp->t_open <= deadline) { VTAILQ_REMOVE(&sesshead, sp, list); vca_unpoll(fd); - // XXX: not yet (void)TCP_linger(sp->fd, 0); + // XXX: not yet (void)VTCP_linger(sp->fd, 0); vca_close_session(sp, "timeout"); SES_Delete(sp); } diff --git a/bin/varnishd/mgt_child.c b/bin/varnishd/mgt_child.c index 863e86b..4dc5c67 100644 --- a/bin/varnishd/mgt_child.c +++ b/bin/varnishd/mgt_child.c @@ -241,8 +241,8 @@ open_sockets(void) * closes before we call accept(2) and nobody else are in * the listen queue to release us. */ - (void)TCP_nonblocking(ls->sock); - (void)TCP_filter_http(ls->sock); + (void)VTCP_nonblocking(ls->sock); + (void)VTCP_filter_http(ls->sock); good++; } if (!good) diff --git a/bin/varnishd/mgt_cli.c b/bin/varnishd/mgt_cli.c index 7923ba4..360bd03 100644 --- a/bin/varnishd/mgt_cli.c +++ b/bin/varnishd/mgt_cli.c @@ -420,13 +420,13 @@ sock_id(const char *pfx, int fd) { struct vsb *vsb; - char abuf1[TCP_ADDRBUFSIZE], abuf2[TCP_ADDRBUFSIZE]; - char pbuf1[TCP_PORTBUFSIZE], pbuf2[TCP_PORTBUFSIZE]; + char abuf1[VTCP_ADDRBUFSIZE], abuf2[VTCP_ADDRBUFSIZE]; + char pbuf1[VTCP_PORTBUFSIZE], pbuf2[VTCP_PORTBUFSIZE]; vsb = VSB_new_auto(); AN(vsb); - TCP_myname(fd, abuf1, sizeof abuf1, pbuf1, sizeof pbuf1); - TCP_hisname(fd, abuf2, sizeof abuf2, pbuf2, sizeof pbuf2); + VTCP_myname(fd, abuf1, sizeof abuf1, pbuf1, sizeof pbuf1); + VTCP_hisname(fd, abuf2, sizeof abuf2, pbuf2, sizeof pbuf2); VSB_printf(vsb, "%s %s %s %s %s", pfx, abuf2, pbuf2, abuf1, pbuf1); AZ(VSB_finish(vsb)); return (vsb); @@ -528,8 +528,8 @@ mgt_cli_telnet(const char *T_arg) struct telnet *tn; char *p; struct vsb *vsb; - char abuf[TCP_ADDRBUFSIZE]; - char pbuf[TCP_PORTBUFSIZE]; + char abuf[VTCP_ADDRBUFSIZE]; + char pbuf[VTCP_PORTBUFSIZE]; n = VSS_resolve(T_arg, NULL, &ta); if (n == 0) { @@ -543,7 +543,7 @@ mgt_cli_telnet(const char *T_arg) sock = VSS_listen(ta[i], 10); if (sock < 0) continue; - TCP_myname(sock, abuf, sizeof abuf, pbuf, sizeof pbuf); + VTCP_myname(sock, abuf, sizeof abuf, pbuf, sizeof pbuf); VSB_printf(vsb, "%s %s\n", abuf, pbuf); good++; tn = telnet_new(sock); diff --git a/bin/varnishtest/vtc_client.c b/bin/varnishtest/vtc_client.c index 4f3e984..158d044 100644 --- a/bin/varnishtest/vtc_client.c +++ b/bin/varnishtest/vtc_client.c @@ -99,13 +99,13 @@ client_thread(void *priv) if (fd < 0) vtc_log(c->vl, 0, "Failed to open %s", VSB_data(vsb)); assert(fd >= 0); - TCP_blocking(fd); - TCP_myname(fd, mabuf, sizeof mabuf, mpbuf, sizeof mpbuf); + VTCP_blocking(fd); + VTCP_myname(fd, mabuf, sizeof mabuf, mpbuf, sizeof mpbuf); vtc_log(vl, 3, "connected fd %d from %s %s to %s", fd, mabuf, mpbuf, VSB_data(vsb)); http_process(vl, c->spec, fd, -1); vtc_log(vl, 3, "closing fd %d", fd); - TCP_close(&fd); + VTCP_close(&fd); } vtc_log(vl, 2, "Ending"); VSB_delete(vsb); diff --git a/bin/varnishtest/vtc_http.c b/bin/varnishtest/vtc_http.c index ddd0a8a..2e6a945 100644 --- a/bin/varnishtest/vtc_http.c +++ b/bin/varnishtest/vtc_http.c @@ -1029,7 +1029,7 @@ cmd_http_accept(CMD_ARGS) CAST_OBJ_NOTNULL(hp, priv, HTTP_MAGIC); AZ(av[1]); assert(hp->sfd >= 0); - TCP_close(&hp->fd); + VTCP_close(&hp->fd); vtc_log(vl, 4, "Accepting"); hp->fd = accept(hp->sfd, NULL, NULL); if (hp->fd < 0) diff --git a/bin/varnishtest/vtc_server.c b/bin/varnishtest/vtc_server.c index 5f88904..28d3b8f 100644 --- a/bin/varnishtest/vtc_server.c +++ b/bin/varnishtest/vtc_server.c @@ -103,9 +103,9 @@ server_thread(void *priv) http_process(vl, s->spec, fd, s->sock); vtc_log(vl, 3, "shutting fd %d", fd); j = shutdown(fd, SHUT_WR); - if (!TCP_Check(j)) + if (!VTCP_Check(j)) vtc_log(vl, 0, "Shutdown failed: %s", strerror(errno)); - TCP_close(&fd); + VTCP_close(&fd); } vtc_log(vl, 2, "Ending"); return (NULL); @@ -176,7 +176,7 @@ server_start(struct server *s) s->listen, naddr); s->sock = VSS_listen(s->vss_addr[0], s->depth); assert(s->sock >= 0); - TCP_myname(s->sock, s->aaddr, sizeof s->aaddr, + VTCP_myname(s->sock, s->aaddr, sizeof s->aaddr, s->aport, sizeof s->aport); macro_def(s->vl, s->name, "addr", "%s", s->aaddr); macro_def(s->vl, s->name, "port", "%s", s->aport); @@ -206,7 +206,7 @@ server_wait(struct server *s) vtc_log(s->vl, 0, "Server returned \"%p\"", (char *)res); s->tp = 0; - TCP_close(&s->sock); + VTCP_close(&s->sock); s->sock = -1; s->run = 0; } diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c index fb99657..856d872 100644 --- a/bin/varnishtest/vtc_varnish.c +++ b/bin/varnishtest/vtc_varnish.c @@ -203,7 +203,7 @@ varnish_thread(void *priv) int i; CAST_OBJ_NOTNULL(v, priv, VARNISH_MAGIC); - (void)TCP_nonblocking(v->fds[0]); + (void)VTCP_nonblocking(v->fds[0]); while (1) { fds = &fd; memset(fds, 0, sizeof fds); @@ -245,7 +245,7 @@ varnish_launch(struct varnish *v) nap = VSS_resolve("127.0.0.1", "0", &ap); AN(nap); v->cli_fd = VSS_listen(ap[0], 1); - TCP_myname(v->cli_fd, abuf, sizeof abuf, pbuf, sizeof pbuf); + VTCP_myname(v->cli_fd, abuf, sizeof abuf, pbuf, sizeof pbuf); AZ(VSB_finish(v->args)); vtc_log(v->vl, 2, "Launch"); diff --git a/include/libvarnish.h b/include/libvarnish.h index a1cfaa8..fb1241c 100644 --- a/include/libvarnish.h +++ b/include/libvarnish.h @@ -53,36 +53,36 @@ int SUB_run(struct vsb *sb, sub_func_f *func, void *priv, const char *name, /* from libvarnish/tcp.c */ /* NI_MAXHOST and NI_MAXSERV are ridiculously long for numeric format */ -#define TCP_ADDRBUFSIZE 64 -#define TCP_PORTBUFSIZE 16 +#define VTCP_ADDRBUFSIZE 64 +#define VTCP_PORTBUFSIZE 16 #if (defined (__SVR4) && defined (__sun)) || defined (__NetBSD__) /* * Solaris returns EINVAL if the other end unexepectedly reset the * connection. This is a bug in Solaris and documented behaviour on NetBSD. */ -#define TCP_Check(a) ((a) == 0 || errno == ECONNRESET || errno == ENOTCONN \ +#define VTCP_Check(a) ((a) == 0 || errno == ECONNRESET || errno == ENOTCONN \ || errno == EINVAL) #else -#define TCP_Check(a) ((a) == 0 || errno == ECONNRESET || errno == ENOTCONN) +#define VTCP_Check(a) ((a) == 0 || errno == ECONNRESET || errno == ENOTCONN) #endif -#define TCP_Assert(a) assert(TCP_Check(a)) +#define VTCP_Assert(a) assert(VTCP_Check(a)) -void TCP_myname(int sock, char *abuf, unsigned alen, char *pbuf, unsigned plen); -void TCP_hisname(int sock, char *abuf, unsigned alen, char *pbuf, unsigned plen); -int TCP_filter_http(int sock); -int TCP_blocking(int sock); -int TCP_nonblocking(int sock); -int TCP_linger(int sock, int linger); +void VTCP_myname(int sock, char *abuf, unsigned alen, char *pbuf, unsigned plen); +void VTCP_hisname(int sock, char *abuf, unsigned alen, char *pbuf, unsigned plen); +int VTCP_filter_http(int sock); +int VTCP_blocking(int sock); +int VTCP_nonblocking(int sock); +int VTCP_linger(int sock, int linger); #ifdef SOL_SOCKET -int TCP_port(const struct sockaddr_storage *addr); -void TCP_name(const struct sockaddr_storage *addr, unsigned l, char *abuf, +int VTCP_port(const struct sockaddr_storage *addr); +void VTCP_name(const struct sockaddr_storage *addr, unsigned l, char *abuf, unsigned alen, char *pbuf, unsigned plen); -int TCP_connect(int s, const struct sockaddr_storage *name, socklen_t namelen, +int VTCP_connect(int s, const struct sockaddr_storage *name, socklen_t namelen, int msec); -void TCP_close(int *s); -void TCP_set_read_timeout(int s, double seconds); +void VTCP_close(int *s); +void VTCP_set_read_timeout(int s, double seconds); #endif /* from libvarnish/time.c */ diff --git a/lib/libvarnish/tcp.c b/lib/libvarnish/tcp.c index 9e132f3..58c61c6 100644 --- a/lib/libvarnish/tcp.c +++ b/lib/libvarnish/tcp.c @@ -58,7 +58,7 @@ /*--------------------------------------------------------------------*/ int -TCP_port(const struct sockaddr_storage *addr) +VTCP_port(const struct sockaddr_storage *addr) { if (addr->ss_family == AF_INET) { @@ -76,7 +76,7 @@ TCP_port(const struct sockaddr_storage *addr) /*--------------------------------------------------------------------*/ void -TCP_name(const struct sockaddr_storage *addr, unsigned l, +VTCP_name(const struct sockaddr_storage *addr, unsigned l, char *abuf, unsigned alen, char *pbuf, unsigned plen) { int i; @@ -104,26 +104,26 @@ TCP_name(const struct sockaddr_storage *addr, unsigned l, /*--------------------------------------------------------------------*/ void -TCP_myname(int sock, char *abuf, unsigned alen, char *pbuf, unsigned plen) +VTCP_myname(int sock, char *abuf, unsigned alen, char *pbuf, unsigned plen) { struct sockaddr_storage addr_s; socklen_t l; l = sizeof addr_s; AZ(getsockname(sock, (void *)&addr_s, &l)); - TCP_name(&addr_s, l, abuf, alen, pbuf, plen); + VTCP_name(&addr_s, l, abuf, alen, pbuf, plen); } /*--------------------------------------------------------------------*/ void -TCP_hisname(int sock, char *abuf, unsigned alen, char *pbuf, unsigned plen) +VTCP_hisname(int sock, char *abuf, unsigned alen, char *pbuf, unsigned plen) { struct sockaddr_storage addr_s; socklen_t l; l = sizeof addr_s; if (!getpeername(sock, (void*)&addr_s, &l)) - TCP_name(&addr_s, l, abuf, alen, pbuf, plen); + VTCP_name(&addr_s, l, abuf, alen, pbuf, plen); else { (void)snprintf(abuf, alen, ""); (void)snprintf(pbuf, plen, ""); @@ -133,7 +133,7 @@ TCP_hisname(int sock, char *abuf, unsigned alen, char *pbuf, unsigned plen) /*--------------------------------------------------------------------*/ int -TCP_filter_http(int sock) +VTCP_filter_http(int sock) { #ifdef HAVE_ACCEPT_FILTERS struct accept_filter_arg afa; @@ -151,7 +151,7 @@ TCP_filter_http(int sock) return (i); #elif defined(__linux) int defer = 1; - setsockopt(sock, SOL_TCP,TCP_DEFER_ACCEPT,(char *) &defer, sizeof(int)); + setsockopt(sock, SOL_TCP,VTCP_DEFER_ACCEPT,(char *) &defer, sizeof(int)); return (0); #else (void)sock; @@ -169,24 +169,24 @@ TCP_filter_http(int sock) */ int -TCP_blocking(int sock) +VTCP_blocking(int sock) { int i, j; i = 0; j = ioctl(sock, FIONBIO, &i); - TCP_Assert(j); + VTCP_Assert(j); return (j); } int -TCP_nonblocking(int sock) +VTCP_nonblocking(int sock) { int i, j; i = 1; j = ioctl(sock, FIONBIO, &i); - TCP_Assert(j); + VTCP_Assert(j); return (j); } @@ -201,7 +201,7 @@ TCP_nonblocking(int sock) */ int -TCP_connect(int s, const struct sockaddr_storage *name, socklen_t namelen, int msec) +VTCP_connect(int s, const struct sockaddr_storage *name, socklen_t namelen, int msec) { int i, k; socklen_t l; @@ -211,7 +211,7 @@ TCP_connect(int s, const struct sockaddr_storage *name, socklen_t namelen, int m /* Set the socket non-blocking */ if (msec > 0) - (void)TCP_nonblocking(s); + (void)VTCP_nonblocking(s); /* Attempt the connect */ i = connect(s, (const void *)name, namelen); @@ -240,7 +240,7 @@ TCP_connect(int s, const struct sockaddr_storage *name, socklen_t namelen, int m if (k) return (-1); - (void)TCP_blocking(s); + (void)VTCP_blocking(s); return (0); } @@ -250,18 +250,18 @@ TCP_connect(int s, const struct sockaddr_storage *name, socklen_t namelen, int m */ void -TCP_close(int *s) +VTCP_close(int *s) { int i; i = close(*s); - assert (TCP_Check(i)); + assert (VTCP_Check(i)); *s = -1; } void -TCP_set_read_timeout(int s, double seconds) +VTCP_set_read_timeout(int s, double seconds) { struct timeval timeout; timeout.tv_sec = (int)floor(seconds); @@ -278,7 +278,7 @@ TCP_set_read_timeout(int s, double seconds) */ int -TCP_linger(int sock, int linger) +VTCP_linger(int sock, int linger) { struct linger lin; int i; @@ -286,6 +286,6 @@ TCP_linger(int sock, int linger) memset(&lin, 0, sizeof lin); lin.l_onoff = linger; i = setsockopt(sock, SOL_SOCKET, SO_LINGER, &lin, sizeof lin); - TCP_Assert(i); + VTCP_Assert(i); return (i); } diff --git a/lib/libvarnish/vss.c b/lib/libvarnish/vss.c index 43f3e4a..85ec2f3 100644 --- a/lib/libvarnish/vss.c +++ b/lib/libvarnish/vss.c @@ -261,7 +261,7 @@ VSS_connect(const struct vss_addr *va, int nonblock) return (-1); } if (nonblock) - (void)TCP_nonblocking(sd); + (void)VTCP_nonblocking(sd); i = connect(sd, (const void *)&va->va_addr, va->va_addrlen); if (i == 0 || (nonblock && errno == EINPROGRESS)) return (sd); diff --git a/lib/libvmod_std/vmod_std.c b/lib/libvmod_std/vmod_std.c index 5a132ac..10acc5e 100644 --- a/lib/libvmod_std/vmod_std.c +++ b/lib/libvmod_std/vmod_std.c @@ -40,7 +40,7 @@ void __match_proto__() vmod_set_ip_tos(struct sess *sp, int tos) { - TCP_Assert(setsockopt(sp->fd, IPPROTO_IP, IP_TOS, &tos, sizeof(tos))); + VTCP_Assert(setsockopt(sp->fd, IPPROTO_IP, IP_TOS, &tos, sizeof(tos))); } static const char * __match_proto__() From phk at varnish-cache.org Tue May 31 11:15:05 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 31 May 2011 13:15:05 +0200 Subject: [master] 7ea8165 Namespace cleanup: cli -> VCLI and cls -> VCLS Message-ID: commit 7ea81655df8e84d36f939a2d5640a135b83732dc Author: Poul-Henning Kamp Date: Tue May 31 10:30:03 2011 +0000 Namespace cleanup: cli -> VCLI and cls -> VCLS diff --git a/bin/varnishadm/varnishadm.c b/bin/varnishadm/varnishadm.c index f280b31..e460367 100644 --- a/bin/varnishadm/varnishadm.c +++ b/bin/varnishadm/varnishadm.c @@ -96,7 +96,7 @@ cli_sock(const char *T_arg, const char *S_arg) return (-1); } - (void)cli_readres(sock, &status, &answer, timeout); + (void)VCLI_ReadResult(sock, &status, &answer, timeout); if (status == CLIS_AUTH) { if (S_arg == NULL) { fprintf(stderr, "Authentication required\n"); @@ -110,14 +110,14 @@ cli_sock(const char *T_arg, const char *S_arg) AZ(close(sock)); return (-1); } - CLI_response(fd, answer, buf); + VCLI_response(fd, answer, buf); AZ(close(fd)); free(answer); cli_write(sock, "auth "); cli_write(sock, buf); cli_write(sock, "\n"); - (void)cli_readres(sock, &status, &answer, timeout); + (void)VCLI_ReadResult(sock, &status, &answer, timeout); } if (status != CLIS_OK) { fprintf(stderr, "Rejected %u\n%s\n", status, answer); @@ -127,7 +127,7 @@ cli_sock(const char *T_arg, const char *S_arg) free(answer); cli_write(sock, "ping\n"); - (void)cli_readres(sock, &status, &answer, timeout); + (void)VCLI_ReadResult(sock, &status, &answer, timeout); if (status != CLIS_OK || strstr(answer, "PONG") == NULL) { fprintf(stderr, "No pong received from server\n"); AZ(close(sock)); @@ -154,7 +154,7 @@ do_args(int sock, int argc, char * const *argv) } cli_write(sock, "\n"); - (void)cli_readres(sock, &status, &answer, 2000); + (void)VCLI_ReadResult(sock, &status, &answer, 2000); /* XXX: AZ() ? */ (void)close(sock); @@ -221,7 +221,7 @@ pass(int sock) if (fds[0].revents & POLLIN) { /* Get rid of the prompt, kinda hackish */ u = write(1, "\r \r", 13); - u = cli_readres(fds[0].fd, &status, &answer, timeout); + u = VCLI_ReadResult(fds[0].fd, &status, &answer, timeout); if (u) { if (status == CLIS_COMMS) RL_EXIT(0); diff --git a/bin/varnishd/cache_cli.c b/bin/varnishd/cache_cli.c index 7905c17..754788b 100644 --- a/bin/varnishd/cache_cli.c +++ b/bin/varnishd/cache_cli.c @@ -55,7 +55,7 @@ pthread_t cli_thread; static struct lock cli_mtx; static int add_check; -static struct cls *cls; +static struct VCLS *cls; /* * The CLI commandlist is split in three: diff --git a/bin/varnishd/mgt_cli.c b/bin/varnishd/mgt_cli.c index 360bd03..3a3f1da 100644 --- a/bin/varnishd/mgt_cli.c +++ b/bin/varnishd/mgt_cli.c @@ -62,7 +62,7 @@ #include "mgt_cli.h" static int cli_i = -1, cli_o = -1; -static struct cls *cls; +static struct VCLS *cls; static const char *secret_file; #define MCF_NOAUTH 0 /* NB: zero disables here-documents */ @@ -171,7 +171,7 @@ mcf_askchild(struct cli *cli, const char * const *av, void *priv) return; } VSB_delete(vsb); - (void)cli_readres(cli_i, &u, &q, params->cli_timeout); + (void)VCLI_ReadResult(cli_i, &u, &q, params->cli_timeout); cli_result(cli, u); cli_out(cli, "%s", q); free(q); @@ -220,7 +220,7 @@ mgt_cli_askchild(unsigned *status, char **resp, const char *fmt, ...) { return (CLIS_COMMS); } - (void)cli_readres(cli_i, &u, resp, params->cli_timeout); + (void)VCLI_ReadResult(cli_i, &u, resp, params->cli_timeout); if (status != NULL) *status = u; if (u == CLIS_COMMS) @@ -292,7 +292,7 @@ mcf_auth(struct cli *cli, const char *const *av, void *priv) return; } mgt_got_fd(fd); - CLI_response(fd, cli->challenge, buf); + VCLI_response(fd, cli->challenge, buf); AZ(close(fd)); if (strcasecmp(buf, av[2])) { mgt_cli_challenge(cli); @@ -400,7 +400,7 @@ mgt_cli_setup(int fdi, int fdo, int verbose, const char *ident, mgt_cli_close_f mcf_banner(cli, NULL, NULL); } AZ(VSB_finish(cli->sb)); - (void)cli_writeres(fdo, cli); + (void)VCLI_WriteResult(fdo, cli); ev = vev_new(); diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c index 856d872..3cd6431 100644 --- a/bin/varnishtest/vtc_varnish.c +++ b/bin/varnishtest/vtc_varnish.c @@ -85,7 +85,7 @@ static VTAILQ_HEAD(, varnish) varnishes = * Ask a question over CLI */ -static enum cli_status_e +static enum VCLI_status_e varnish_ask_cli(const struct varnish *v, const char *cmd, char **repl) { int i; @@ -99,11 +99,11 @@ varnish_ask_cli(const struct varnish *v, const char *cmd, char **repl) i = write(v->cli_fd, "\n", 1); assert(i == 1); } - i = cli_readres(v->cli_fd, &retval, &r, 20.0); + i = VCLI_ReadResult(v->cli_fd, &retval, &r, 20.0); if (i != 0) { vtc_log(v->vl, 0, "CLI failed (%s) = %d %u %s", cmd, i, retval, r); - return ((enum cli_status_e)retval); + return ((enum VCLI_status_e)retval); } assert(i == 0); vtc_log(v->vl, 3, "CLI RX %u", retval); @@ -112,7 +112,7 @@ varnish_ask_cli(const struct varnish *v, const char *cmd, char **repl) *repl = r; else free(r); - return ((enum cli_status_e)retval); + return ((enum VCLI_status_e)retval); } /********************************************************************** @@ -235,7 +235,7 @@ varnish_launch(struct varnish *v) struct vss_addr **ap; char abuf[128], pbuf[128]; struct pollfd fd[2]; - enum cli_status_e u; + enum VCLI_status_e u; char *r; v->vd = VSM_New(); @@ -341,7 +341,7 @@ varnish_launch(struct varnish *v) assert(sizeof abuf >= CLI_AUTH_RESPONSE_LEN + 6); strcpy(abuf, "auth "); - CLI_response(nfd, r, abuf + 5); + VCLI_response(nfd, r, abuf + 5); AZ(close(nfd)); free(r); strcat(abuf, "\n"); @@ -364,7 +364,7 @@ varnish_launch(struct varnish *v) static void varnish_start(struct varnish *v) { - enum cli_status_e u; + enum VCLI_status_e u; char *resp, *h, *p, *q; if (v->cli_fd < 0) @@ -478,7 +478,7 @@ varnish_wait(struct varnish *v) static void varnish_cli(struct varnish *v, const char *cli, unsigned exp) { - enum cli_status_e u; + enum VCLI_status_e u; if (v->cli_fd < 0) varnish_launch(v); @@ -495,10 +495,10 @@ varnish_cli(struct varnish *v, const char *cli, unsigned exp) */ static void -varnish_vcl(struct varnish *v, const char *vcl, enum cli_status_e expect) +varnish_vcl(struct varnish *v, const char *vcl, enum VCLI_status_e expect) { struct vsb *vsb; - enum cli_status_e u; + enum VCLI_status_e u; if (v->cli_fd < 0) varnish_launch(v); @@ -539,7 +539,7 @@ static void varnish_vclbackend(struct varnish *v, const char *vcl) { struct vsb *vsb, *vsb2; - enum cli_status_e u; + enum VCLI_status_e u; if (v->cli_fd < 0) varnish_launch(v); diff --git a/include/cli.h b/include/cli.h index a82178a..1ee035f 100644 --- a/include/cli.h +++ b/include/cli.h @@ -190,7 +190,7 @@ * Status/return codes in the CLI protocol */ -enum cli_status_e { +enum VCLI_status_e { CLIS_SYNTAX = 100, CLIS_UNKNOWN = 101, CLIS_UNIMPL = 102, diff --git a/include/cli_common.h b/include/cli_common.h index 68e7acd..5041f6d 100644 --- a/include/cli_common.h +++ b/include/cli_common.h @@ -29,25 +29,25 @@ */ struct vlu; -struct cls; +struct VCLS; struct cli { unsigned magic; #define CLI_MAGIC 0x4038d570 struct vsb *sb; - enum cli_status_e result; + enum VCLI_status_e result; char *cmd; unsigned auth; char challenge[34]; char *ident; struct vlu *vlu; - struct cls *cls; + struct VCLS *cls; }; -int cli_writeres(int fd, const struct cli *cli); -int cli_readres(int fd, unsigned *status, char **ptr, double tmo); +int VCLI_WriteResult(int fd, const struct cli *cli); +int VCLI_ReadResult(int fd, unsigned *status, char **ptr, double tmo); #define CLI_AUTH_RESPONSE_LEN 65 /* 64 hex + NUL */ -void CLI_response(int S_fd, const char *challenge, +void VCLI_response(int S_fd, const char *challenge, char reponse[CLI_AUTH_RESPONSE_LEN]); diff --git a/include/cli_serve.h b/include/cli_serve.h index 9f6a645..5874efa 100644 --- a/include/cli_serve.h +++ b/include/cli_serve.h @@ -27,16 +27,16 @@ * */ -struct cls; +struct VCLS; typedef void cls_cb_f(void *priv); typedef void cls_cbc_f(const struct cli*); -struct cls *VCLS_New(cls_cbc_f *before, cls_cbc_f *after, unsigned maxlen); -struct cli *VCLS_AddFd(struct cls *cs, int fdi, int fdo, cls_cb_f *closefunc, +struct VCLS *VCLS_New(cls_cbc_f *before, cls_cbc_f *after, unsigned maxlen); +struct cli *VCLS_AddFd(struct VCLS *cs, int fdi, int fdo, cls_cb_f *closefunc, void *priv); -int VCLS_AddFunc(struct cls *cs, unsigned auth, struct cli_proto *clp); -int VCLS_Poll(struct cls *cs, int timeout); -int VCLS_PollFd(struct cls *cs, int fd, int timeout); -void VCLS_Destroy(struct cls **); +int VCLS_AddFunc(struct VCLS *cs, unsigned auth, struct cli_proto *clp); +int VCLS_Poll(struct VCLS *cs, int timeout); +int VCLS_PollFd(struct VCLS *cs, int fd, int timeout); +void VCLS_Destroy(struct VCLS **); /* From libvarnish/cli.c */ cli_func_t VCLS_func_close; diff --git a/lib/libvarnish/cli_auth.c b/lib/libvarnish/cli_auth.c index b726eba..3d9f44e 100644 --- a/lib/libvarnish/cli_auth.c +++ b/lib/libvarnish/cli_auth.c @@ -39,7 +39,7 @@ void -CLI_response(int S_fd, const char *challenge, +VCLI_response(int S_fd, const char *challenge, char response[CLI_AUTH_RESPONSE_LEN]) { SHA256_CTX ctx; diff --git a/lib/libvarnish/cli_common.c b/lib/libvarnish/cli_common.c index ca47482..84c69c3 100644 --- a/lib/libvarnish/cli_common.c +++ b/lib/libvarnish/cli_common.c @@ -83,7 +83,7 @@ cli_result(struct cli *cli, unsigned res) } int -cli_writeres(int fd, const struct cli *cli) +VCLI_WriteResult(int fd, const struct cli *cli) { int i, l; struct iovec iov[3]; @@ -142,7 +142,7 @@ read_tmo(int fd, char *ptr, unsigned len, double tmo) } int -cli_readres(int fd, unsigned *status, char **ptr, double tmo) +VCLI_ReadResult(int fd, unsigned *status, char **ptr, double tmo) { char res[CLI_LINE0_LEN]; /* For NUL */ int i, j; diff --git a/lib/libvarnish/cli_serve.c b/lib/libvarnish/cli_serve.c index 86cb893..f94494b 100644 --- a/lib/libvarnish/cli_serve.c +++ b/lib/libvarnish/cli_serve.c @@ -48,20 +48,20 @@ #include #include -struct cls_func { +struct VCLS_func { unsigned magic; #define VCLS_FUNC_MAGIC 0x7d280c9b - VTAILQ_ENTRY(cls_func) list; + VTAILQ_ENTRY(VCLS_func) list; unsigned auth; struct cli_proto *clp; }; -struct cls_fd { +struct VCLS_fd { unsigned magic; #define VCLS_FD_MAGIC 0x010dbd1e - VTAILQ_ENTRY(cls_fd) list; + VTAILQ_ENTRY(VCLS_fd) list; int fdi, fdo; - struct cls *cls; + struct VCLS *cls; struct cli *cli, clis; cls_cb_f *closefunc; void *priv; @@ -70,12 +70,12 @@ struct cls_fd { char **argv; }; -struct cls { +struct VCLS { unsigned magic; #define VCLS_MAGIC 0x60f044a3 - VTAILQ_HEAD(,cls_fd) fds; + VTAILQ_HEAD(,VCLS_fd) fds; unsigned nfd; - VTAILQ_HEAD(,cls_func) funcs; + VTAILQ_HEAD(,VCLS_func) funcs; cls_cbc_f *before, *after; unsigned maxlen; }; @@ -111,9 +111,9 @@ void VCLS_func_help(struct cli *cli, const char * const *av, void *priv) { struct cli_proto *cp; - struct cls_func *cfn; + struct VCLS_func *cfn; unsigned all, debug, u, d, h, i, wc; - struct cls *cs; + struct VCLS *cs; (void)priv; cs = cli->cls; @@ -236,9 +236,9 @@ cls_dispatch(struct cli *cli, struct cli_proto *clp, char * const * av, static int cls_vlu2(void *priv, char * const *av) { - struct cls_fd *cfd; - struct cls *cs; - struct cls_func *cfn; + struct VCLS_fd *cfd; + struct VCLS *cs; + struct VCLS_func *cfn; struct cli *cli; unsigned na; @@ -293,7 +293,7 @@ cls_vlu2(void *priv, char * const *av) cli->cls = NULL; - if (cli_writeres(cfd->fdo, cli) || cli->result == CLIS_CLOSE) + if (VCLI_WriteResult(cfd->fdo, cli) || cli->result == CLIS_CLOSE) return (1); return (0); @@ -302,7 +302,7 @@ cls_vlu2(void *priv, char * const *av) static int cls_vlu(void *priv, const char *p) { - struct cls_fd *cfd; + struct VCLS_fd *cfd; struct cli *cli; int i; char **av; @@ -374,10 +374,10 @@ cls_vlu(void *priv, const char *p) } } -struct cls * +struct VCLS * VCLS_New(cls_cbc_f *before, cls_cbc_f *after, unsigned maxlen) { - struct cls *cs; + struct VCLS *cs; ALLOC_OBJ(cs, VCLS_MAGIC); AN(cs); @@ -390,9 +390,9 @@ VCLS_New(cls_cbc_f *before, cls_cbc_f *after, unsigned maxlen) } struct cli * -VCLS_AddFd(struct cls *cs, int fdi, int fdo, cls_cb_f *closefunc, void *priv) +VCLS_AddFd(struct VCLS *cs, int fdi, int fdo, cls_cb_f *closefunc, void *priv) { - struct cls_fd *cfd; + struct VCLS_fd *cfd; CHECK_OBJ_NOTNULL(cs, VCLS_MAGIC); assert(fdi >= 0); @@ -415,7 +415,7 @@ VCLS_AddFd(struct cls *cs, int fdi, int fdo, cls_cb_f *closefunc, void *priv) } static void -cls_close_fd(struct cls *cs, struct cls_fd *cfd) +cls_close_fd(struct VCLS *cs, struct VCLS_fd *cfd) { CHECK_OBJ_NOTNULL(cs, VCLS_MAGIC); @@ -439,9 +439,9 @@ cls_close_fd(struct cls *cs, struct cls_fd *cfd) int -VCLS_AddFunc(struct cls *cs, unsigned auth, struct cli_proto *clp) +VCLS_AddFunc(struct VCLS *cs, unsigned auth, struct cli_proto *clp) { - struct cls_func *cfn; + struct VCLS_func *cfn; CHECK_OBJ_NOTNULL(cs, VCLS_MAGIC); ALLOC_OBJ(cfn, VCLS_FUNC_MAGIC); @@ -453,9 +453,9 @@ VCLS_AddFunc(struct cls *cs, unsigned auth, struct cli_proto *clp) } int -VCLS_PollFd(struct cls *cs, int fd, int timeout) +VCLS_PollFd(struct VCLS *cs, int fd, int timeout) { - struct cls_fd *cfd; + struct VCLS_fd *cfd; struct pollfd pfd[1]; int i, j, k; @@ -492,9 +492,9 @@ VCLS_PollFd(struct cls *cs, int fd, int timeout) } int -VCLS_Poll(struct cls *cs, int timeout) +VCLS_Poll(struct VCLS *cs, int timeout) { - struct cls_fd *cfd, *cfd2; + struct VCLS_fd *cfd, *cfd2; int i, j, k; CHECK_OBJ_NOTNULL(cs, VCLS_MAGIC); @@ -535,11 +535,11 @@ VCLS_Poll(struct cls *cs, int timeout) } void -VCLS_Destroy(struct cls **csp) +VCLS_Destroy(struct VCLS **csp) { - struct cls *cs; - struct cls_fd *cfd, *cfd2; - struct cls_func *cfn; + struct VCLS *cs; + struct VCLS_fd *cfd, *cfd2; + struct VCLS_func *cfn; cs = *csp; *csp = NULL; From phk at varnish-cache.org Tue May 31 11:15:06 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 31 May 2011 13:15:06 +0200 Subject: [master] ab0b3e2 Namespace cleanup: More cli_ -> VCLI_ Message-ID: commit ab0b3e26111677b77624c47a4fb5e4808cd26759 Author: Poul-Henning Kamp Date: Tue May 31 10:44:16 2011 +0000 Namespace cleanup: More cli_ -> VCLI_ diff --git a/bin/varnishd/cache_acceptor.c b/bin/varnishd/cache_acceptor.c index 74e3359..64e3937 100644 --- a/bin/varnishd/cache_acceptor.c +++ b/bin/varnishd/cache_acceptor.c @@ -428,7 +428,7 @@ ccf_listen_address(struct cli *cli, const char * const *av, void *priv) if (ls->sock < 0) continue; VTCP_myname(ls->sock, h, sizeof h, p, sizeof p); - cli_out(cli, "%s %s\n", h, p); + VCLI_Out(cli, "%s %s\n", h, p); } } @@ -474,15 +474,15 @@ VCA_tweak_waiter(struct cli *cli, const char *arg) if (arg == NULL) { if (vca_act == NULL) - cli_out(cli, "default"); + VCLI_Out(cli, "default"); else - cli_out(cli, "%s", vca_act->name); + VCLI_Out(cli, "%s", vca_act->name); - cli_out(cli, " ("); + VCLI_Out(cli, " ("); for (i = 0; vca_waiters[i] != NULL; i++) - cli_out(cli, "%s%s", i == 0 ? "" : ", ", + VCLI_Out(cli, "%s%s", i == 0 ? "" : ", ", vca_waiters[i]->name); - cli_out(cli, ")"); + VCLI_Out(cli, ")"); return; } if (!strcmp(arg, "default")) { @@ -495,6 +495,6 @@ VCA_tweak_waiter(struct cli *cli, const char *arg) return; } } - cli_out(cli, "Unknown waiter"); - cli_result(cli, CLIS_PARAM); + VCLI_Out(cli, "Unknown waiter"); + VCLI_SetResult(cli, CLIS_PARAM); } diff --git a/bin/varnishd/cache_backend_cfg.c b/bin/varnishd/cache_backend_cfg.c index 44f5cd8..68ffcdb 100644 --- a/bin/varnishd/cache_backend_cfg.c +++ b/bin/varnishd/cache_backend_cfg.c @@ -285,7 +285,7 @@ cli_debug_backend(struct cli *cli, const char * const *av, void *priv) ASSERT_CLI(); VTAILQ_FOREACH(b, &backends, list) { CHECK_OBJ_NOTNULL(b, BACKEND_MAGIC); - cli_out(cli, "%p %s(%s,%s,:%s) %d %d\n", + VCLI_Out(cli, "%p %s(%s,%s,:%s) %d %d\n", b, b->vcl_name, b->ipv4_addr, b->ipv6_addr, b->port, b->refcount, b->n_conn); } diff --git a/bin/varnishd/cache_backend_poll.c b/bin/varnishd/cache_backend_poll.c index ce55e39..d6de0fe 100644 --- a/bin/varnishd/cache_backend_poll.c +++ b/bin/varnishd/cache_backend_poll.c @@ -370,12 +370,12 @@ vbp_bitmap(struct cli *cli, char c, uint64_t map, const char *lbl) for (i = 0; i < 64; i++) { if (map & u) - cli_out(cli, "%c", c); + VCLI_Out(cli, "%c", c); else - cli_out(cli, "-"); + VCLI_Out(cli, "-"); map <<= 1; } - cli_out(cli, " %s\n", lbl); + VCLI_Out(cli, " %s\n", lbl); } /*lint -e{506} constant value boolean */ @@ -384,16 +384,16 @@ static void vbp_health_one(struct cli *cli, const struct vbp_target *vt) { - cli_out(cli, "Backend %s is %s\n", + VCLI_Out(cli, "Backend %s is %s\n", vt->backend->vcl_name, vt->backend->healthy ? "Healthy" : "Sick"); - cli_out(cli, "Current states good: %2u threshold: %2u window: %2u\n", + VCLI_Out(cli, "Current states good: %2u threshold: %2u window: %2u\n", vt->good, vt->probe.threshold, vt->probe.window); - cli_out(cli, "Average responsetime of good probes: %.6f\n", vt->avg); - cli_out(cli, + VCLI_Out(cli, "Average responsetime of good probes: %.6f\n", vt->avg); + VCLI_Out(cli, "Oldest " " Newest\n"); - cli_out(cli, + VCLI_Out(cli, "=============================" "===================================\n"); diff --git a/bin/varnishd/cache_ban.c b/bin/varnishd/cache_ban.c index a75314c..28a36cd 100644 --- a/bin/varnishd/cache_ban.c +++ b/bin/varnishd/cache_ban.c @@ -298,8 +298,8 @@ ban_parse_regexp(struct cli *cli, const struct ban *b, const char *a3) re = pcre_compile(a3, 0, &error, &erroroffset, NULL); if (re == NULL) { VSL(SLT_Debug, 0, "REGEX: <%s>", error); - cli_out(cli, "%s", error); - cli_result(cli, CLIS_PARAM); + VCLI_Out(cli, "%s", error); + VCLI_SetResult(cli, CLIS_PARAM); return (-1); } rc = pcre_fullinfo(re, NULL, PCRE_INFO_SIZE, &sz); @@ -325,8 +325,8 @@ BAN_AddTest(struct cli *cli, struct ban *b, const char *a1, const char *a2, if (!strncmp(a1, pv->name, strlen(pv->name))) break; if (pv->name == NULL) { - cli_out(cli, "unknown or unsupported field \"%s\"", a1); - cli_result(cli, CLIS_PARAM); + VCLI_Out(cli, "unknown or unsupported field \"%s\"", a1); + VCLI_SetResult(cli, CLIS_PARAM); return (-1); } @@ -353,9 +353,9 @@ BAN_AddTest(struct cli *cli, struct ban *b, const char *a1, const char *a2, } else if (!strcmp(a2, "!=")) { VSB_putc(b->vsb, BAN_OPER_NEQ); } else { - cli_out(cli, + VCLI_Out(cli, "expected conditional (~, !~, == or !=) got \"%s\"", a2); - cli_result(cli, CLIS_PARAM); + VCLI_SetResult(cli, CLIS_PARAM); return (-1); } return (0); @@ -845,22 +845,22 @@ ccf_ban(struct cli *cli, const char * const *av, void *priv) for (narg = 0; av[narg + 2] != NULL; narg++) continue; if ((narg % 4) != 3) { - cli_out(cli, "Wrong number of arguments"); - cli_result(cli, CLIS_PARAM); + VCLI_Out(cli, "Wrong number of arguments"); + VCLI_SetResult(cli, CLIS_PARAM); return; } for (i = 3; i < narg; i += 4) { if (strcmp(av[i + 2], "&&")) { - cli_out(cli, "Found \"%s\" expected &&", av[i + 2]); - cli_result(cli, CLIS_PARAM); + VCLI_Out(cli, "Found \"%s\" expected &&", av[i + 2]); + VCLI_SetResult(cli, CLIS_PARAM); return; } } b = BAN_New(); if (b == NULL) { - cli_out(cli, "Out of Memory"); - cli_result(cli, CLIS_CANT); + VCLI_Out(cli, "Out of Memory"); + VCLI_SetResult(cli, CLIS_CANT); return; } for (i = 0; i < narg; i += 4) @@ -898,30 +898,30 @@ ban_render(struct cli *cli, const uint8_t *bs) ban_iter(&bs, &bt); switch (bt.arg1) { case BAN_ARG_URL: - cli_out(cli, "req.url"); + VCLI_Out(cli, "req.url"); break; case BAN_ARG_REQHTTP: - cli_out(cli, "req.http.%.*s", + VCLI_Out(cli, "req.http.%.*s", bt.arg1_spec[0] - 1, bt.arg1_spec + 1); break; case BAN_ARG_OBJHTTP: - cli_out(cli, "obj.http.%.*s", + VCLI_Out(cli, "obj.http.%.*s", bt.arg1_spec[0] - 1, bt.arg1_spec + 1); break; default: INCOMPL(); } switch (bt.oper) { - case BAN_OPER_EQ: cli_out(cli, " == "); break; - case BAN_OPER_NEQ: cli_out(cli, " != "); break; - case BAN_OPER_MATCH: cli_out(cli, " ~ "); break; - case BAN_OPER_NMATCH: cli_out(cli, " !~ "); break; + case BAN_OPER_EQ: VCLI_Out(cli, " == "); break; + case BAN_OPER_NEQ: VCLI_Out(cli, " != "); break; + case BAN_OPER_MATCH: VCLI_Out(cli, " ~ "); break; + case BAN_OPER_NMATCH: VCLI_Out(cli, " !~ "); break; default: INCOMPL(); } - cli_out(cli, "%s", bt.arg2); + VCLI_Out(cli, "%s", bt.arg2); if (bs < be) - cli_out(cli, " && "); + VCLI_Out(cli, " && "); } } @@ -939,11 +939,11 @@ ccf_ban_list(struct cli *cli, const char * const *av, void *priv) VTAILQ_FOREACH(b, &ban_head, list) { if (b == bl) break; - cli_out(cli, "%p %10.6f %5u%s\t", b, ban_time(b->spec), + VCLI_Out(cli, "%p %10.6f %5u%s\t", b, ban_time(b->spec), bl == b ? b->refcount - 1 : b->refcount, b->flags & BAN_F_GONE ? "G" : " "); ban_render(cli, b->spec); - cli_out(cli, "\n"); + VCLI_Out(cli, "\n"); } BAN_TailDeref(&bl); diff --git a/bin/varnishd/cache_center.c b/bin/varnishd/cache_center.c index 4f69e47..e2fb980 100644 --- a/bin/varnishd/cache_center.c +++ b/bin/varnishd/cache_center.c @@ -1547,7 +1547,7 @@ 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", xids); + VCLI_Out(cli, "XID is %u", xids); } /* @@ -1564,7 +1564,7 @@ cli_debug_srandom(struct cli *cli, const char * const *av, void *priv) seed = strtoul(av[2], NULL, 0); srandom(seed); srand48(random()); - cli_out(cli, "Random(3) seeded with %lu", seed); + VCLI_Out(cli, "Random(3) seeded with %lu", seed); } static struct cli_proto debug_cmds[] = { diff --git a/bin/varnishd/cache_cli.c b/bin/varnishd/cache_cli.c index 754788b..7ef1bb3 100644 --- a/bin/varnishd/cache_cli.c +++ b/bin/varnishd/cache_cli.c @@ -107,7 +107,7 @@ CLI_Run(void) add_check = 1; - AN(VCLS_AddFd(cls, heritage.cli_in, heritage.cli_out, NULL, NULL)); + AN(VCLS_AddFd(cls, heritage.cli_in, heritage.VCLI_Out, NULL, NULL)); do { i = VCLS_Poll(cls, -1); @@ -124,7 +124,7 @@ cli_debug_sizeof(struct cli *cli, const char * const *av, void *priv) (void)av; (void)priv; -#define SZOF(foo) cli_out(cli, \ +#define SZOF(foo) VCLI_Out(cli, \ "sizeof(%s) = %zd = 0x%zx\n", #foo, sizeof(foo), sizeof(foo)); SZOF(struct ws); SZOF(struct http); diff --git a/bin/varnishd/cache_vcl.c b/bin/varnishd/cache_vcl.c index 9137acd..7777304 100644 --- a/bin/varnishd/cache_vcl.c +++ b/bin/varnishd/cache_vcl.c @@ -141,7 +141,7 @@ VCL_Load(const char *fn, const char *name, struct cli *cli) ASSERT_CLI(); vcl = vcl_find(name); if (vcl != NULL) { - cli_out(cli, "Config '%s' already loaded", name); + VCLI_Out(cli, "Config '%s' already loaded", name); return (1); } @@ -151,13 +151,13 @@ VCL_Load(const char *fn, const char *name, struct cli *cli) vcl->dlh = dlopen(fn, RTLD_NOW | RTLD_LOCAL); if (vcl->dlh == NULL) { - cli_out(cli, "dlopen(%s): %s\n", fn, dlerror()); + VCLI_Out(cli, "dlopen(%s): %s\n", fn, dlerror()); FREE_OBJ(vcl); return (1); } cnf = dlsym(vcl->dlh, "VCL_conf"); if (cnf == NULL) { - cli_out(cli, "Internal error: No VCL_conf symbol\n"); + VCLI_Out(cli, "Internal error: No VCL_conf symbol\n"); (void)dlclose(vcl->dlh); FREE_OBJ(vcl); return (1); @@ -165,14 +165,14 @@ VCL_Load(const char *fn, const char *name, struct cli *cli) memcpy(vcl->conf, cnf, sizeof *cnf); if (vcl->conf->magic != VCL_CONF_MAGIC) { - cli_out(cli, "Wrong VCL_CONF_MAGIC\n"); + VCLI_Out(cli, "Wrong VCL_CONF_MAGIC\n"); (void)dlclose(vcl->dlh); FREE_OBJ(vcl); return (1); } REPLACE(vcl->name, name); VTAILQ_INSERT_TAIL(&vcl_head, vcl, list); - cli_out(cli, "Loaded \"%s\" as \"%s\"", fn , name); + VCLI_Out(cli, "Loaded \"%s\" as \"%s\"", fn , name); vcl->conf->init_vcl(cli); (void)vcl->conf->init_func(NULL); Lck_Lock(&vcl_mtx); @@ -238,7 +238,7 @@ ccf_config_list(struct cli *cli, const char * const *av, void *priv) flg = "discarded"; } else flg = "available"; - cli_out(cli, "%-10s %6u %s\n", + VCLI_Out(cli, "%-10s %6u %s\n", flg, vcl->conf->busy, vcl->name); @@ -253,7 +253,7 @@ ccf_config_load(struct cli *cli, const char * const *av, void *priv) (void)priv; ASSERT_CLI(); if (VCL_Load(av[3], av[2], cli)) - cli_result(cli, CLIS_PARAM); + VCLI_SetResult(cli, CLIS_PARAM); return; } @@ -267,15 +267,15 @@ ccf_config_discard(struct cli *cli, const char * const *av, void *priv) (void)priv; vcl = vcl_find(av[2]); if (vcl == NULL) { - cli_result(cli, CLIS_PARAM); - cli_out(cli, "VCL '%s' unknown", av[2]); + VCLI_SetResult(cli, CLIS_PARAM); + VCLI_Out(cli, "VCL '%s' unknown", av[2]); return; } Lck_Lock(&vcl_mtx); if (vcl == vcl_active) { Lck_Unlock(&vcl_mtx); - cli_result(cli, CLIS_PARAM); - cli_out(cli, "VCL %s is the active VCL", av[2]); + VCLI_SetResult(cli, CLIS_PARAM); + VCLI_Out(cli, "VCL %s is the active VCL", av[2]); return; } VSC_C_main->n_vcl_discard++; @@ -296,8 +296,8 @@ ccf_config_use(struct cli *cli, const char * const *av, void *priv) (void)priv; vcl = vcl_find(av[2]); if (vcl == NULL) { - cli_out(cli, "No VCL named '%s'", av[2]); - cli_result(cli, CLIS_PARAM); + VCLI_Out(cli, "No VCL named '%s'", av[2]); + VCLI_SetResult(cli, CLIS_PARAM); return; } Lck_Lock(&vcl_mtx); diff --git a/bin/varnishd/cache_vrt_vmod.c b/bin/varnishd/cache_vrt_vmod.c index 1afa459..7d03fac 100644 --- a/bin/varnishd/cache_vrt_vmod.c +++ b/bin/varnishd/cache_vrt_vmod.c @@ -139,7 +139,7 @@ ccf_debug_vmod(struct cli *cli, const char * const *av, void *priv) (void)priv; ASSERT_CLI(); VTAILQ_FOREACH(v, &vmods, list) - cli_out(cli, "%5d %s (%s)\n", v->ref, v->nm, v->path); + VCLI_Out(cli, "%5d %s (%s)\n", v->ref, v->nm, v->path); } static struct cli_proto vcl_cmds[] = { diff --git a/bin/varnishd/hash_critbit.c b/bin/varnishd/hash_critbit.c index 0eb426c..4dff8db 100644 --- a/bin/varnishd/hash_critbit.c +++ b/bin/varnishd/hash_critbit.c @@ -309,14 +309,14 @@ dumptree(struct cli *cli, uintptr_t p, int indent) return; if (hcb_is_node(p)) { oh = hcb_l_node(p); - cli_out(cli, "%*.*sN %d r%u <%02x%02x%02x...>\n", + VCLI_Out(cli, "%*.*sN %d r%u <%02x%02x%02x...>\n", indent, indent, "", indent / 2, oh->refcnt, oh->digest[0], oh->digest[1], oh->digest[2]); return; } assert(hcb_is_y(p)); y = hcb_l_y(p); - cli_out(cli, "%*.*sY c %u p %u b %02x i %d\n", + VCLI_Out(cli, "%*.*sY c %u p %u b %02x i %d\n", indent, indent, "", y->critbit, y->ptr, y->bitmask, indent / 2); indent += 2; @@ -330,9 +330,9 @@ hcb_dump(struct cli *cli, const char * const *av, void *priv) (void)priv; (void)av; - cli_out(cli, "HCB dump:\n"); + VCLI_Out(cli, "HCB dump:\n"); dumptree(cli, hcb_root.origo, 0); - cli_out(cli, "Coollist:\n"); + VCLI_Out(cli, "Coollist:\n"); } static struct cli_proto hcb_cmds[] = { diff --git a/bin/varnishd/heritage.h b/bin/varnishd/heritage.h index ad3b363..fb94043 100644 --- a/bin/varnishd/heritage.h +++ b/bin/varnishd/heritage.h @@ -44,7 +44,7 @@ struct heritage { /* Two pipe(2)'s for CLI connection between cache and mgt. */ int cli_in; - int cli_out; + int VCLI_Out; /* File descriptor for stdout/stderr */ int std_fd; diff --git a/bin/varnishd/mgt_child.c b/bin/varnishd/mgt_child.c index 4dc5c67..4397cd3 100644 --- a/bin/varnishd/mgt_child.c +++ b/bin/varnishd/mgt_child.c @@ -61,7 +61,7 @@ pid_t child_pid = -1; static struct vbitmap *fd_map; static int child_cli_in = -1; -static int child_cli_out = -1; +static int child_VCLI_Out = -1; static int child_output = -1; static enum { @@ -282,8 +282,8 @@ start_child(struct cli *cli) if (open_sockets() != 0) { child_state = CH_STOPPED; if (cli != NULL) { - cli_result(cli, CLIS_CANT); - cli_out(cli, "Could not open sockets"); + VCLI_SetResult(cli, CLIS_CANT); + VCLI_Out(cli, "Could not open sockets"); return; } REPORT0(LOG_ERR, @@ -297,12 +297,12 @@ start_child(struct cli *cli) AZ(pipe(cp)); heritage.cli_in = cp[0]; mgt_child_inherit(heritage.cli_in, "cli_in"); - child_cli_out = cp[1]; + child_VCLI_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"); + heritage.VCLI_Out = cp[1]; + mgt_child_inherit(heritage.VCLI_Out, "VCLI_Out"); child_cli_in = cp[0]; /* @@ -354,8 +354,8 @@ start_child(struct cli *cli) mgt_child_inherit(heritage.cli_in, NULL); closex(&heritage.cli_in); - mgt_child_inherit(heritage.cli_out, NULL); - closex(&heritage.cli_out); + mgt_child_inherit(heritage.VCLI_Out, NULL); + closex(&heritage.VCLI_Out); close_sockets(); @@ -382,7 +382,7 @@ start_child(struct cli *cli) ev_poker = e; } - mgt_cli_start_child(child_cli_in, child_cli_out); + mgt_cli_start_child(child_cli_in, child_VCLI_Out); child_pid = pid; if (mgt_push_vcls_and_start(&u, &p)) { REPORT(LOG_ERR, "Pushing vcls failed: %s", p); @@ -414,7 +414,7 @@ mgt_stop_child(void) mgt_cli_stop_child(); /* We tell the child to die gracefully by closing the CLI */ - closex(&child_cli_out); + closex(&child_VCLI_Out); closex(&child_cli_in); } @@ -505,7 +505,7 @@ mgt_sigchld(const struct vev *e, int what) if (child_state == CH_RUNNING) { child_state = CH_DIED; mgt_cli_stop_child(); - closex(&child_cli_out); + closex(&child_VCLI_Out); closex(&child_cli_in); } @@ -619,12 +619,12 @@ mcf_server_startstop(struct cli *cli, const char * const *av, void *priv) if (mgt_has_vcl()) { start_child(cli); } else { - cli_result(cli, CLIS_CANT); - cli_out(cli, "No VCL available"); + VCLI_SetResult(cli, CLIS_CANT); + VCLI_Out(cli, "No VCL available"); } } else { - cli_result(cli, CLIS_CANT); - cli_out(cli, "Child in state %s", ch_state[child_state]); + VCLI_SetResult(cli, CLIS_CANT); + VCLI_Out(cli, "Child in state %s", ch_state[child_state]); } } @@ -635,7 +635,7 @@ mcf_server_status(struct cli *cli, const char * const *av, void *priv) { (void)av; (void)priv; - cli_out(cli, "Child in state %s", ch_state[child_state]); + VCLI_Out(cli, "Child in state %s", ch_state[child_state]); } void @@ -645,12 +645,12 @@ mcf_panic_show(struct cli *cli, const char * const *av, void *priv) (void)priv; if (!child_panic) { - cli_result(cli, CLIS_CANT); - cli_out(cli, "Child has not panicked or panic has been cleared"); + VCLI_SetResult(cli, CLIS_CANT); + VCLI_Out(cli, "Child has not panicked or panic has been cleared"); return; } - cli_out(cli, "%s\n", VSB_data(child_panic)); + VCLI_Out(cli, "%s\n", VSB_data(child_panic)); } void @@ -660,8 +660,8 @@ mcf_panic_clear(struct cli *cli, const char * const *av, void *priv) (void)priv; if (!child_panic) { - cli_result(cli, CLIS_CANT); - cli_out(cli, "No panic to clear"); + VCLI_SetResult(cli, CLIS_CANT); + VCLI_Out(cli, "No panic to clear"); return; } diff --git a/bin/varnishd/mgt_cli.c b/bin/varnishd/mgt_cli.c index 3a3f1da..f155c0f 100644 --- a/bin/varnishd/mgt_cli.c +++ b/bin/varnishd/mgt_cli.c @@ -76,16 +76,16 @@ mcf_banner(struct cli *cli, const char *const *av, void *priv) (void)av; (void)priv; - cli_out(cli, "-----------------------------\n"); - cli_out(cli, "Varnish Cache CLI 1.0\n"); - cli_out(cli, "-----------------------------\n"); - cli_out(cli, "%s\n", VSB_data(vident) + 1); - cli_out(cli, "\n"); - cli_out(cli, "Type 'help' for command list.\n"); - cli_out(cli, "Type 'quit' to close CLI session.\n"); + VCLI_Out(cli, "-----------------------------\n"); + VCLI_Out(cli, "Varnish Cache CLI 1.0\n"); + VCLI_Out(cli, "-----------------------------\n"); + VCLI_Out(cli, "%s\n", VSB_data(vident) + 1); + VCLI_Out(cli, "\n"); + VCLI_Out(cli, "Type 'help' for command list.\n"); + VCLI_Out(cli, "Type 'quit' to close CLI session.\n"); if (child_pid < 0) - cli_out(cli, "Type 'start' to launch worker process.\n"); - cli_result(cli, CLIS_OK); + VCLI_Out(cli, "Type 'start' to launch worker process.\n"); + VCLI_SetResult(cli, CLIS_OK); } /*--------------------------------------------------------------------*/ @@ -145,11 +145,11 @@ mcf_askchild(struct cli *cli, const char * const *av, void *priv) */ if (cli_o <= 0) { if (!strcmp(av[1], "help")) { - cli_out(cli, "No help from child, (not running).\n"); + VCLI_Out(cli, "No help from child, (not running).\n"); return; } - cli_result(cli, CLIS_UNKNOWN); - cli_out(cli, + VCLI_SetResult(cli, CLIS_UNKNOWN); + VCLI_Out(cli, "Unknown request in manager process " "(child not running).\n" "Type 'help' for more info."); @@ -165,15 +165,15 @@ mcf_askchild(struct cli *cli, const char * const *av, void *priv) i = write(cli_o, VSB_data(vsb), VSB_len(vsb)); if (i != VSB_len(vsb)) { VSB_delete(vsb); - cli_result(cli, CLIS_COMMS); - cli_out(cli, "CLI communication error"); + VCLI_SetResult(cli, CLIS_COMMS); + VCLI_Out(cli, "CLI communication error"); MGT_Child_Cli_Fail(); return; } VSB_delete(vsb); (void)VCLI_ReadResult(cli_i, &u, &q, params->cli_timeout); - cli_result(cli, u); - cli_out(cli, "%s", q); + VCLI_SetResult(cli, u); + VCLI_Out(cli, "%s", q); free(q); } @@ -262,9 +262,9 @@ mgt_cli_challenge(struct cli *cli) cli->challenge[i] = (random() % 26) + 'a'; cli->challenge[i++] = '\n'; cli->challenge[i] = '\0'; - cli_out(cli, "%s", cli->challenge); - cli_out(cli, "\nAuthentication required.\n"); - cli_result(cli, CLIS_AUTH); + VCLI_Out(cli, "%s", cli->challenge); + VCLI_Out(cli, "\nAuthentication required.\n"); + VCLI_SetResult(cli, CLIS_AUTH); } /*-------------------------------------------------------------------- @@ -280,15 +280,15 @@ mcf_auth(struct cli *cli, const char *const *av, void *priv) AN(av[2]); (void)priv; if (secret_file == NULL) { - cli_out(cli, "Secret file not configured\n"); - cli_result(cli, CLIS_CANT); + VCLI_Out(cli, "Secret file not configured\n"); + VCLI_SetResult(cli, CLIS_CANT); return; } fd = open(secret_file, O_RDONLY); if (fd < 0) { - cli_out(cli, "Cannot open secret file (%s)\n", + VCLI_Out(cli, "Cannot open secret file (%s)\n", strerror(errno)); - cli_result(cli, CLIS_CANT); + VCLI_SetResult(cli, CLIS_CANT); return; } mgt_got_fd(fd); @@ -300,7 +300,7 @@ mcf_auth(struct cli *cli, const char *const *av, void *priv) } cli->auth = MCF_AUTH; memset(cli->challenge, 0, sizeof cli->challenge); - cli_result(cli, CLIS_OK); + VCLI_SetResult(cli, CLIS_OK); mcf_banner(cli, av, priv); } diff --git a/bin/varnishd/mgt_param.c b/bin/varnishd/mgt_param.c index 7810212..8b82350 100644 --- a/bin/varnishd/mgt_param.c +++ b/bin/varnishd/mgt_param.c @@ -80,13 +80,13 @@ tweak_generic_timeout(struct cli *cli, volatile unsigned *dst, const char *arg) if (arg != NULL) { u = strtoul(arg, NULL, 0); if (u == 0) { - cli_out(cli, "Timeout must be greater than zero\n"); - cli_result(cli, CLIS_PARAM); + VCLI_Out(cli, "Timeout must be greater than zero\n"); + VCLI_SetResult(cli, CLIS_PARAM); return; } *dst = u; } else - cli_out(cli, "%u", *dst); + VCLI_Out(cli, "%u", *dst); } /*--------------------------------------------------------------------*/ @@ -111,22 +111,22 @@ tweak_timeout_double(struct cli *cli, const struct parspec *par, if (arg != NULL) { u = strtod(arg, NULL); if (u < par->min) { - cli_out(cli, + VCLI_Out(cli, "Timeout must be greater or equal to %.g\n", par->min); - cli_result(cli, CLIS_PARAM); + VCLI_SetResult(cli, CLIS_PARAM); return; } if (u > par->max) { - cli_out(cli, + VCLI_Out(cli, "Timeout must be less than or equal to %.g\n", par->max); - cli_result(cli, CLIS_PARAM); + VCLI_SetResult(cli, CLIS_PARAM); return; } *dest = u; } else - cli_out(cli, "%.6f", *dest); + VCLI_Out(cli, "%.6f", *dest); } /*--------------------------------------------------------------------*/ @@ -142,22 +142,22 @@ tweak_generic_double(struct cli *cli, const struct parspec *par, if (arg != NULL) { u = strtod(arg, NULL); if (u < par->min) { - cli_out(cli, + VCLI_Out(cli, "Must be greater or equal to %.g\n", par->min); - cli_result(cli, CLIS_PARAM); + VCLI_SetResult(cli, CLIS_PARAM); return; } if (u > par->max) { - cli_out(cli, + VCLI_Out(cli, "Must be less than or equal to %.g\n", par->max); - cli_result(cli, CLIS_PARAM); + VCLI_SetResult(cli, CLIS_PARAM); return; } *dest = u; } else - cli_out(cli, "%f", *dest); + VCLI_Out(cli, "%f", *dest); } /*--------------------------------------------------------------------*/ @@ -183,12 +183,12 @@ tweak_generic_bool(struct cli *cli, volatile unsigned *dest, const char *arg) else if (!strcasecmp(arg, "true")) *dest = 1; else { - cli_out(cli, "use \"on\" or \"off\"\n"); - cli_result(cli, CLIS_PARAM); + VCLI_Out(cli, "use \"on\" or \"off\"\n"); + VCLI_SetResult(cli, CLIS_PARAM); return; } } else - cli_out(cli, *dest ? "on" : "off"); + VCLI_Out(cli, *dest ? "on" : "off"); } /*--------------------------------------------------------------------*/ @@ -216,20 +216,20 @@ tweak_generic_uint(struct cli *cli, volatile unsigned *dest, const char *arg, else u = strtoul(arg, NULL, 0); if (u < min) { - cli_out(cli, "Must be at least %u\n", min); - cli_result(cli, CLIS_PARAM); + VCLI_Out(cli, "Must be at least %u\n", min); + VCLI_SetResult(cli, CLIS_PARAM); return; } if (u > max) { - cli_out(cli, "Must be no more than %u\n", max); - cli_result(cli, CLIS_PARAM); + VCLI_Out(cli, "Must be no more than %u\n", max); + VCLI_SetResult(cli, CLIS_PARAM); return; } *dest = u; } else if (*dest == UINT_MAX) { - cli_out(cli, "unlimited", *dest); + VCLI_Out(cli, "unlimited", *dest); } else { - cli_out(cli, "%u", *dest); + VCLI_Out(cli, "%u", *dest); } } @@ -269,8 +269,8 @@ tweak_user(struct cli *cli, const struct parspec *par, const char *arg) } else pw = getpwnam(arg); if (pw == NULL) { - cli_out(cli, "Unknown user"); - cli_result(cli, CLIS_PARAM); + VCLI_Out(cli, "Unknown user"); + VCLI_SetResult(cli, CLIS_PARAM); return; } REPLACE(master.user, pw->pw_name); @@ -283,9 +283,9 @@ tweak_user(struct cli *cli, const struct parspec *par, const char *arg) gr->gr_gid == pw->pw_gid) REPLACE(master.group, gr->gr_name); } else if (master.user) { - cli_out(cli, "%s (%d)", master.user, (int)master.uid); + VCLI_Out(cli, "%s (%d)", master.user, (int)master.uid); } else { - cli_out(cli, "%d", (int)master.uid); + VCLI_Out(cli, "%d", (int)master.uid); } } @@ -311,16 +311,16 @@ tweak_group(struct cli *cli, const struct parspec *par, const char *arg) } else gr = getgrnam(arg); if (gr == NULL) { - cli_out(cli, "Unknown group"); - cli_result(cli, CLIS_PARAM); + VCLI_Out(cli, "Unknown group"); + VCLI_SetResult(cli, CLIS_PARAM); return; } REPLACE(master.group, gr->gr_name); master.gid = gr->gr_gid; } else if (master.group) { - cli_out(cli, "%s (%d)", master.group, (int)master.gid); + VCLI_Out(cli, "%s (%d)", master.group, (int)master.gid); } else { - cli_out(cli, "%d", (int)master.gid); + VCLI_Out(cli, "%d", (int)master.gid); } } @@ -350,25 +350,25 @@ tweak_listen_address(struct cli *cli, const struct parspec *par, (void)par; if (arg == NULL) { - cli_quote(cli, master.listen_address); + VCLI_Quote(cli, master.listen_address); return; } av = VAV_Parse(arg, NULL, ARGV_COMMA); if (av == NULL) { - cli_out(cli, "Parse error: out of memory"); - cli_result(cli, CLIS_PARAM); + VCLI_Out(cli, "Parse error: out of memory"); + VCLI_SetResult(cli, CLIS_PARAM); return; } if (av[0] != NULL) { - cli_out(cli, "Parse error: %s", av[0]); - cli_result(cli, CLIS_PARAM); + VCLI_Out(cli, "Parse error: %s", av[0]); + VCLI_SetResult(cli, CLIS_PARAM); VAV_Free(av); return; } if (av[1] == NULL) { - cli_out(cli, "Empty listen address"); - cli_result(cli, CLIS_PARAM); + VCLI_Out(cli, "Empty listen address"); + VCLI_SetResult(cli, CLIS_PARAM); VAV_Free(av); return; } @@ -379,9 +379,9 @@ tweak_listen_address(struct cli *cli, const struct parspec *par, n = VSS_resolve(av[i], "http", &ta); if (n == 0) { - cli_out(cli, "Invalid listen address "); - cli_quote(cli, av[i]); - cli_result(cli, CLIS_PARAM); + VCLI_Out(cli, "Invalid listen address "); + VCLI_Quote(cli, av[i]); + VCLI_SetResult(cli, CLIS_PARAM); break; } for (j = 0; j < n; ++j) { @@ -424,7 +424,7 @@ tweak_string(struct cli *cli, const struct parspec *par, const char *arg) AN(p); /* XXX should have tweak_generic_string */ if (arg == NULL) { - cli_quote(cli, *p); + VCLI_Quote(cli, *p); } else { REPLACE(*p, arg); } @@ -453,7 +453,7 @@ tweak_diag_bitmap(struct cli *cli, const struct parspec *par, const char *arg) u = strtoul(arg, NULL, 0); master.diag_bitmap = u; } else { - cli_out(cli, "0x%x", master.diag_bitmap); + VCLI_Out(cli, "0x%x", master.diag_bitmap); } } @@ -955,7 +955,7 @@ mcf_wrap(struct cli *cli, const char *text) q--; AN(q); } - cli_out(cli, "%*s %.*s\n", margin, "", (int)(q - p), p); + VCLI_Out(cli, "%*s %.*s\n", margin, "", (int)(q - p), p); p = q; if (*p == ' ' || *p == '\n') p++; @@ -978,9 +978,9 @@ mcf_param_show(struct cli *cli, const char * const *av, void *priv) pp = parspec[i]; if (av[2] != NULL && !lfmt && strcmp(pp->name, av[2])) continue; - cli_out(cli, "%-*s ", margin, pp->name); + VCLI_Out(cli, "%-*s ", margin, pp->name); if (pp->func == NULL) { - cli_out(cli, "Not implemented.\n"); + VCLI_Out(cli, "Not implemented.\n"); if (av[2] != NULL && !lfmt) return; else @@ -988,11 +988,11 @@ mcf_param_show(struct cli *cli, const char * const *av, void *priv) } pp->func(cli, pp, NULL); if (pp->units != NULL) - cli_out(cli, " [%s]\n", pp->units); + VCLI_Out(cli, " [%s]\n", pp->units); else - cli_out(cli, "\n"); + VCLI_Out(cli, "\n"); if (av[2] != NULL) { - cli_out(cli, "%-*s Default is %s\n", + VCLI_Out(cli, "%-*s Default is %s\n", margin, "", pp->def); mcf_wrap(cli, pp->descr); if (pp->flags & DELAYED_EFFECT) @@ -1008,12 +1008,12 @@ mcf_param_show(struct cli *cli, const char * const *av, void *priv) if (!lfmt) return; else - cli_out(cli, "\n"); + VCLI_Out(cli, "\n"); } } if (av[2] != NULL && !lfmt) { - cli_result(cli, CLIS_PARAM); - cli_out(cli, "Unknown parameter \"%s\".", av[2]); + VCLI_SetResult(cli, CLIS_PARAM); + VCLI_Out(cli, "Unknown parameter \"%s\".", av[2]); } } @@ -1037,20 +1037,20 @@ MCF_ParamSet(struct cli *cli, const char *param, const char *val) if (pp != NULL) { pp->func(cli, pp, val); if (cli->result != CLIS_OK) { - cli_out(cli, "(attempting to set param %s to %s)\n", + VCLI_Out(cli, "(attempting to set param %s to %s)\n", pp->name, val); } else if (child_pid >= 0 && pp->flags & MUST_RESTART) { - cli_out(cli, "Change will take effect" + VCLI_Out(cli, "Change will take effect" " when child is restarted"); } else if (pp->flags & MUST_RELOAD) { - cli_out(cli, "Change will take effect" + VCLI_Out(cli, "Change will take effect" " when VCL script is reloaded"); } MCF_ParamSync(); return; } - cli_result(cli, CLIS_PARAM); - cli_out(cli, "Unknown parameter \"%s\".", param); + VCLI_SetResult(cli, CLIS_PARAM); + VCLI_Out(cli, "Unknown parameter \"%s\".", param); } @@ -1111,7 +1111,7 @@ MCF_SetDefaults(struct cli *cli) for (i = 0; i < nparspec; i++) { pp = parspec[i]; if (cli != NULL) - cli_out(cli, + VCLI_Out(cli, "Set Default for %s = %s\n", pp->name, pp->def); pp->func(cli, pp, pp->def); if (cli != NULL && cli->result != CLIS_OK) diff --git a/bin/varnishd/mgt_vcc.c b/bin/varnishd/mgt_vcc.c index 2e1c9a5..d793a0e 100644 --- a/bin/varnishd/mgt_vcc.c +++ b/bin/varnishd/mgt_vcc.c @@ -482,25 +482,25 @@ mcf_config_inline(struct cli *cli, const char * const *av, void *priv) vp = mgt_vcc_byname(av[2]); if (vp != NULL) { - cli_out(cli, "Already a VCL program named %s", av[2]); - cli_result(cli, CLIS_PARAM); + VCLI_Out(cli, "Already a VCL program named %s", av[2]); + VCLI_SetResult(cli, CLIS_PARAM); return; } vf = mgt_VccCompile(&sb, av[3], 0); if (VSB_len(sb) > 0) - cli_out(cli, "%s\n", VSB_data(sb)); + VCLI_Out(cli, "%s\n", VSB_data(sb)); VSB_delete(sb); if (vf == NULL) { - cli_out(cli, "VCL compilation failed"); - cli_result(cli, CLIS_PARAM); + VCLI_Out(cli, "VCL compilation failed"); + VCLI_SetResult(cli, CLIS_PARAM); return; } - cli_out(cli, "VCL compiled."); + VCLI_Out(cli, "VCL compiled."); if (child_pid >= 0 && mgt_cli_askchild(&status, &p, "vcl.load %s %s\n", av[2], vf)) { - cli_result(cli, status); - cli_out(cli, "%s", p); + VCLI_SetResult(cli, status); + VCLI_Out(cli, "%s", p); } else { (void)mgt_vcc_add(av[2], vf); } @@ -519,15 +519,15 @@ mcf_config_load(struct cli *cli, const char * const *av, void *priv) (void)priv; vp = mgt_vcc_byname(av[2]); if (vp != NULL) { - cli_out(cli, "Already a VCL program named %s", av[2]); - cli_result(cli, CLIS_PARAM); + VCLI_Out(cli, "Already a VCL program named %s", av[2]); + VCLI_SetResult(cli, CLIS_PARAM); return; } vcl = vreadfile(mgt_vcl_dir, av[3], NULL); if (vcl == NULL) { - cli_out(cli, "Cannot open '%s'", av[3]); - cli_result(cli, CLIS_PARAM); + VCLI_Out(cli, "Cannot open '%s'", av[3]); + VCLI_SetResult(cli, CLIS_PARAM); return; } @@ -535,18 +535,18 @@ mcf_config_load(struct cli *cli, const char * const *av, void *priv) free(vcl); if (VSB_len(sb) > 0) - cli_out(cli, "%s", VSB_data(sb)); + VCLI_Out(cli, "%s", VSB_data(sb)); VSB_delete(sb); if (vf == NULL) { - cli_out(cli, "VCL compilation failed"); - cli_result(cli, CLIS_PARAM); + VCLI_Out(cli, "VCL compilation failed"); + VCLI_SetResult(cli, CLIS_PARAM); return; } - cli_out(cli, "VCL compiled."); + VCLI_Out(cli, "VCL compiled."); if (child_pid >= 0 && mgt_cli_askchild(&status, &p, "vcl.load %s %s\n", av[2], vf)) { - cli_result(cli, status); - cli_out(cli, "%s", p); + VCLI_SetResult(cli, status); + VCLI_Out(cli, "%s", p); } else { (void)mgt_vcc_add(av[2], vf); } @@ -561,8 +561,8 @@ mcf_find_vcl(struct cli *cli, const char *name) vp = mgt_vcc_byname(name); if (vp != NULL) return (vp); - cli_result(cli, CLIS_PARAM); - cli_out(cli, "No configuration named %s known.", name); + VCLI_SetResult(cli, CLIS_PARAM); + VCLI_Out(cli, "No configuration named %s known.", name); return (NULL); } @@ -581,8 +581,8 @@ mcf_config_use(struct cli *cli, const char * const *av, void *priv) return; if (child_pid >= 0 && mgt_cli_askchild(&status, &p, "vcl.use %s\n", av[2])) { - cli_result(cli, status); - cli_out(cli, "%s", p); + VCLI_SetResult(cli, status); + VCLI_Out(cli, "%s", p); } else { vp->active = 2; VTAILQ_FOREACH(vp, &vclhead, list) { @@ -605,14 +605,14 @@ mcf_config_discard(struct cli *cli, const char * const *av, void *priv) (void)priv; vp = mcf_find_vcl(cli, av[2]); if (vp != NULL && vp->active) { - cli_result(cli, CLIS_PARAM); - cli_out(cli, "Cannot discard active VCL program\n"); + VCLI_SetResult(cli, CLIS_PARAM); + VCLI_Out(cli, "Cannot discard active VCL program\n"); } else if (vp != NULL) { if (child_pid >= 0 && mgt_cli_askchild(&status, &p, "vcl.discard %s\n", av[2])) { - cli_result(cli, status); - cli_out(cli, "%s", p); + VCLI_SetResult(cli, status); + VCLI_Out(cli, "%s", p); } else { AZ(mgt_vcc_delbyname(av[2])); } @@ -632,8 +632,8 @@ mcf_config_list(struct cli *cli, const char * const *av, void *priv) (void)priv; if (child_pid >= 0) { if (!mgt_cli_askchild(&status, &p, "vcl.list\n")) { - cli_result(cli, status); - cli_out(cli, "%s", p); + VCLI_SetResult(cli, status); + VCLI_Out(cli, "%s", p); } free(p); } else { @@ -642,7 +642,7 @@ mcf_config_list(struct cli *cli, const char * const *av, void *priv) flg = "active"; } else flg = "available"; - cli_out(cli, "%-10s %6s %s\n", + VCLI_Out(cli, "%-10s %6s %s\n", flg, "N/A", vp->name); } } @@ -663,18 +663,18 @@ mcf_config_show(struct cli *cli, const char * const *av, void *priv) (void)priv; if ((vp = mcf_find_vcl(cli, av[2])) != NULL) { if ((dlh = dlopen(vp->fname, RTLD_NOW | RTLD_LOCAL)) == NULL) { - cli_out(cli, "failed to load %s: %s\n", + VCLI_Out(cli, "failed to load %s: %s\n", vp->name, dlerror()); - cli_result(cli, CLIS_CANT); + VCLI_SetResult(cli, CLIS_CANT); } else if ((sym = dlsym(dlh, "srcbody")) == NULL) { - cli_out(cli, "failed to locate source for %s: %s\n", + VCLI_Out(cli, "failed to locate source for %s: %s\n", vp->name, dlerror()); - cli_result(cli, CLIS_CANT); + VCLI_SetResult(cli, CLIS_CANT); AZ(dlclose(dlh)); } else { src = sym; - cli_out(cli, "%s", src[0]); - /* cli_out(cli, src[1]); */ + VCLI_Out(cli, "%s", src[0]); + /* VCLI_Out(cli, src[1]); */ AZ(dlclose(dlh)); } } diff --git a/bin/varnishd/stevedore.c b/bin/varnishd/stevedore.c index a14e011..256c994 100644 --- a/bin/varnishd/stevedore.c +++ b/bin/varnishd/stevedore.c @@ -526,11 +526,11 @@ stv_cli_list(struct cli *cli, const char * const *av, void *priv) ASSERT_MGT(); (void)av; (void)priv; - cli_out(cli, "Storage devices:\n"); + VCLI_Out(cli, "Storage devices:\n"); stv = stv_transient; - cli_out(cli, "\tstorage.%s = %s\n", stv->ident, stv->name); + VCLI_Out(cli, "\tstorage.%s = %s\n", stv->ident, stv->name); VTAILQ_FOREACH(stv, &stevedores, list) - cli_out(cli, "\tstorage.%s = %s\n", stv->ident, stv->name); + VCLI_Out(cli, "\tstorage.%s = %s\n", stv->ident, stv->name); } /*--------------------------------------------------------------------*/ diff --git a/bin/varnishd/storage_persistent.c b/bin/varnishd/storage_persistent.c index d37ef45..427f687 100644 --- a/bin/varnishd/storage_persistent.c +++ b/bin/varnishd/storage_persistent.c @@ -580,22 +580,22 @@ debug_report_silo(struct cli *cli, const struct smp_sc *sc, int objs) struct smp_seg *sg; struct objcore *oc; - cli_out(cli, "Silo: %s (%s)\n", + VCLI_Out(cli, "Silo: %s (%s)\n", sc->stevedore->ident, sc->filename); VTAILQ_FOREACH(sg, &sc->segments, list) { - cli_out(cli, " Seg: [0x%jx ... +0x%jx]\n", + VCLI_Out(cli, " Seg: [0x%jx ... +0x%jx]\n", (uintmax_t)sg->p.offset, (uintmax_t)sg->p.length); if (sg == sc->cur_seg) - cli_out(cli, + VCLI_Out(cli, " Alloc: [0x%jx ... 0x%jx] = 0x%jx free\n", (uintmax_t)(sc->next_bot), (uintmax_t)(sc->next_top), (uintmax_t)(sc->next_top - sc->next_bot)); - cli_out(cli, " %u nobj, %u alloc, %u lobjlist, %u fixed\n", + VCLI_Out(cli, " %u nobj, %u alloc, %u lobjlist, %u fixed\n", sg->nobj, sg->nalloc, sg->p.lobjlist, sg->nfixed); if (objs) { VTAILQ_FOREACH(oc, &sg->lru->lru_head, lru_list) - cli_out(cli, " OC %p\n", oc); + VCLI_Out(cli, " OC %p\n", oc); } } } @@ -616,8 +616,8 @@ debug_persistent(struct cli *cli, const char * const * av, void *priv) if (!strcmp(av[2], sc->stevedore->ident)) break; if (sc == NULL) { - cli_out(cli, "Silo <%s> not found\n", av[2]); - cli_result(cli, CLIS_PARAM); + VCLI_Out(cli, "Silo <%s> not found\n", av[2]); + VCLI_SetResult(cli, CLIS_PARAM); return; } if (av[3] == NULL) { @@ -631,8 +631,8 @@ debug_persistent(struct cli *cli, const char * const * av, void *priv) } else if (!strcmp(av[3], "dump")) { debug_report_silo(cli, sc, 1); } else { - cli_out(cli, "Unknown operation\n"); - cli_result(cli, CLIS_PARAM); + VCLI_Out(cli, "Unknown operation\n"); + VCLI_SetResult(cli, CLIS_PARAM); } Lck_Unlock(&sc->mtx); } diff --git a/include/cli_priv.h b/include/cli_priv.h index 9d35181..ae0343b 100644 --- a/include/cli_priv.h +++ b/include/cli_priv.h @@ -52,6 +52,6 @@ struct cli_proto { }; /* The implementation must provide these functions */ -void cli_out(struct cli *cli, const char *fmt, ...); -void cli_quote(struct cli *cli, const char *str); -void cli_result(struct cli *cli, unsigned r); +void VCLI_Out(struct cli *cli, const char *fmt, ...); +void VCLI_Quote(struct cli *cli, const char *str); +void VCLI_SetResult(struct cli *cli, unsigned r); diff --git a/lib/libvarnish/cli_common.c b/lib/libvarnish/cli_common.c index 84c69c3..56a849a 100644 --- a/lib/libvarnish/cli_common.c +++ b/lib/libvarnish/cli_common.c @@ -52,7 +52,7 @@ /*lint -e{818} cli could be const */ void -cli_out(struct cli *cli, const char *fmt, ...) +VCLI_Out(struct cli *cli, const char *fmt, ...) { va_list ap; @@ -66,14 +66,14 @@ cli_out(struct cli *cli, const char *fmt, ...) /*lint -e{818} cli could be const */ void -cli_quote(struct cli *cli, const char *s) +VCLI_Quote(struct cli *cli, const char *s) { VSB_quote(cli->sb, s, -1, 0); } void -cli_result(struct cli *cli, unsigned res) +VCLI_SetResult(struct cli *cli, unsigned res) { if (cli != NULL) diff --git a/lib/libvarnish/cli_serve.c b/lib/libvarnish/cli_serve.c index f94494b..3b32866 100644 --- a/lib/libvarnish/cli_serve.c +++ b/lib/libvarnish/cli_serve.c @@ -88,8 +88,8 @@ VCLS_func_close(struct cli *cli, const char *const *av, void *priv) (void)av; (void)priv; - cli_out(cli, "Closing CLI connection"); - cli_result(cli, CLIS_CLOSE); + VCLI_Out(cli, "Closing CLI connection"); + VCLI_SetResult(cli, CLIS_CLOSE); } /*--------------------------------------------------------------------*/ @@ -102,7 +102,7 @@ VCLS_func_ping(struct cli *cli, const char * const *av, void *priv) (void)priv; (void)av; t = time(NULL); - cli_out(cli, "PONG %ld 1.0", t); + VCLI_Out(cli, "PONG %ld 1.0", t); } /*--------------------------------------------------------------------*/ @@ -133,7 +133,7 @@ VCLS_func_help(struct cli *cli, const char * const *av, void *priv) continue; for (cp = cfn->clp; cp->request != NULL; cp++) { if (!strcmp(cp->request, av[2])) { - cli_out(cli, "%s\n%s\n", + VCLI_Out(cli, "%s\n%s\n", cp->syntax, cp->help); return; } @@ -145,8 +145,8 @@ VCLS_func_help(struct cli *cli, const char * const *av, void *priv) } } } - cli_out(cli, "Unknown request.\nType 'help' for more info.\n"); - cli_result(cli, CLIS_UNKNOWN); + VCLI_Out(cli, "Unknown request.\nType 'help' for more info.\n"); + VCLI_SetResult(cli, CLIS_UNKNOWN); return; } VTAILQ_FOREACH(cfn, &cs->funcs, list) { @@ -180,7 +180,7 @@ VCLS_func_help(struct cli *cli, const char * const *av, void *priv) if (h && !all) continue; if (cp->syntax != NULL) - cli_out(cli, "%s\n", cp->syntax); + VCLI_Out(cli, "%s\n", cp->syntax); } } } @@ -206,20 +206,20 @@ cls_dispatch(struct cli *cli, struct cli_proto *clp, char * const * av, return (0); if (cp->func == NULL) { - cli_out(cli, "Unimplemented\n"); - cli_result(cli, CLIS_UNIMPL); + VCLI_Out(cli, "Unimplemented\n"); + VCLI_SetResult(cli, CLIS_UNIMPL); return(1); } if (ac - 1 < cp->minarg) { - cli_out(cli, "Too few parameters\n"); - cli_result(cli, CLIS_TOOFEW); + VCLI_Out(cli, "Too few parameters\n"); + VCLI_SetResult(cli, CLIS_TOOFEW); return(1); } if (ac - 1> cp->maxarg) { - cli_out(cli, "Too many parameters\n"); - cli_result(cli, CLIS_TOOMANY); + VCLI_Out(cli, "Too many parameters\n"); + VCLI_SetResult(cli, CLIS_TOOMANY); return(1); } @@ -254,21 +254,21 @@ cls_vlu2(void *priv, char * const *av) cli->result = CLIS_UNKNOWN; VSB_clear(cli->sb); - cli_out(cli, "Unknown request.\nType 'help' for more info.\n"); + VCLI_Out(cli, "Unknown request.\nType 'help' for more info.\n"); if (cs->before != NULL) cs->before(cli); do { if (av[0] != NULL) { - cli_out(cli, "Syntax Error: %s\n", av[0]); - cli_result(cli, CLIS_SYNTAX); + VCLI_Out(cli, "Syntax Error: %s\n", av[0]); + VCLI_SetResult(cli, CLIS_SYNTAX); break; } if (isupper(av[1][0])) { - cli_out(cli, "all commands are in lower-case.\n"); - cli_result(cli, CLIS_UNKNOWN); + VCLI_Out(cli, "all commands are in lower-case.\n"); + VCLI_SetResult(cli, CLIS_UNKNOWN); break; } From phk at varnish-cache.org Tue May 31 11:15:06 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 31 May 2011 13:15:06 +0200 Subject: [master] 01fbdac Complete namespace cleanup. Message-ID: commit 01fbdaca96e7e94c85fad6d532f8f4a617b40deb Author: Poul-Henning Kamp Date: Tue May 31 11:08:27 2011 +0000 Complete namespace cleanup. Add stuff to libvarnishapi to make it self-sufficient. Remove libvarnish from tools' Makefiles, they should not link against it, to ensure that libvarnishapi is enough for such tasks. Where we need special stuff from libvarnish, like VPF, pull it into tools' Makefile directly. diff --git a/bin/varnishadm/Makefile.am b/bin/varnishadm/Makefile.am index 03fb471..2eb182a 100644 --- a/bin/varnishadm/Makefile.am +++ b/bin/varnishadm/Makefile.am @@ -12,7 +12,6 @@ varnishadm_SOURCES = \ varnishadm_CFLAGS = @LIBEDIT_CFLAGS@ varnishadm_LDADD = \ - $(top_builddir)/lib/libvarnish/libvarnish.la \ $(top_builddir)/lib/libvarnishapi/libvarnishapi.la \ $(top_builddir)/lib/libvarnishcompat/libvarnishcompat.la \ ${PTHREAD_LIBS} ${NET_LIBS} @LIBEDIT_LIBS@ diff --git a/bin/varnishadm/varnishadm.c b/bin/varnishadm/varnishadm.c index e460367..22717de 100644 --- a/bin/varnishadm/varnishadm.c +++ b/bin/varnishadm/varnishadm.c @@ -110,7 +110,7 @@ cli_sock(const char *T_arg, const char *S_arg) AZ(close(sock)); return (-1); } - VCLI_response(fd, answer, buf); + VCLI_AuthResponse(fd, answer, buf); AZ(close(fd)); free(answer); diff --git a/bin/varnishd/mgt_cli.c b/bin/varnishd/mgt_cli.c index f155c0f..70f5828 100644 --- a/bin/varnishd/mgt_cli.c +++ b/bin/varnishd/mgt_cli.c @@ -292,7 +292,7 @@ mcf_auth(struct cli *cli, const char *const *av, void *priv) return; } mgt_got_fd(fd); - VCLI_response(fd, cli->challenge, buf); + VCLI_AuthResponse(fd, cli->challenge, buf); AZ(close(fd)); if (strcasecmp(buf, av[2])) { mgt_cli_challenge(cli); diff --git a/bin/varnishlog/Makefile.am b/bin/varnishlog/Makefile.am index 17474fc..1a359f7 100644 --- a/bin/varnishlog/Makefile.am +++ b/bin/varnishlog/Makefile.am @@ -6,10 +6,12 @@ bin_PROGRAMS = varnishlog dist_man_MANS = varnishlog.1 -varnishlog_SOURCES = varnishlog.c +varnishlog_SOURCES = \ + varnishlog.c \ + $(top_builddir)/lib/libvarnish/flopen.c \ + $(top_builddir)/lib/libvarnish/vpf.c varnishlog_LDADD = \ - $(top_builddir)/lib/libvarnish/libvarnish.la \ $(top_builddir)/lib/libvarnishcompat/libvarnishcompat.la \ $(top_builddir)/lib/libvarnishapi/libvarnishapi.la \ ${PTHREAD_LIBS} diff --git a/bin/varnishncsa/Makefile.am b/bin/varnishncsa/Makefile.am index 69ec4de..e4a2880 100644 --- a/bin/varnishncsa/Makefile.am +++ b/bin/varnishncsa/Makefile.am @@ -6,10 +6,12 @@ bin_PROGRAMS = varnishncsa dist_man_MANS = varnishncsa.1 -varnishncsa_SOURCES = varnishncsa.c +varnishncsa_SOURCES = \ + varnishncsa.c \ + $(top_builddir)/lib/libvarnish/flopen.c \ + $(top_builddir)/lib/libvarnish/vpf.c varnishncsa_LDADD = \ - $(top_builddir)/lib/libvarnish/libvarnish.la \ $(top_builddir)/lib/libvarnishcompat/libvarnishcompat.la \ $(top_builddir)/lib/libvarnishapi/libvarnishapi.la \ ${PTHREAD_LIBS} diff --git a/bin/varnishreplay/Makefile.am b/bin/varnishreplay/Makefile.am index bca6b10..2df4616 100644 --- a/bin/varnishreplay/Makefile.am +++ b/bin/varnishreplay/Makefile.am @@ -10,7 +10,6 @@ varnishreplay_SOURCES = \ varnishreplay.c varnishreplay_LDADD = \ - $(top_builddir)/lib/libvarnish/libvarnish.la \ $(top_builddir)/lib/libvarnishcompat/libvarnishcompat.la \ $(top_builddir)/lib/libvarnishapi/libvarnishapi.la \ ${PTHREAD_LIBS} ${NET_LIBS} diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c index 3cd6431..c706487 100644 --- a/bin/varnishtest/vtc_varnish.c +++ b/bin/varnishtest/vtc_varnish.c @@ -341,7 +341,7 @@ varnish_launch(struct varnish *v) assert(sizeof abuf >= CLI_AUTH_RESPONSE_LEN + 6); strcpy(abuf, "auth "); - VCLI_response(nfd, r, abuf + 5); + VCLI_AuthResponse(nfd, r, abuf + 5); AZ(close(nfd)); free(r); strcat(abuf, "\n"); diff --git a/include/cli_common.h b/include/cli_common.h index 5041f6d..0e8ba8c 100644 --- a/include/cli_common.h +++ b/include/cli_common.h @@ -49,5 +49,5 @@ int VCLI_ReadResult(int fd, unsigned *status, char **ptr, double tmo); #define CLI_AUTH_RESPONSE_LEN 65 /* 64 hex + NUL */ -void VCLI_response(int S_fd, const char *challenge, +void VCLI_AuthResponse(int S_fd, const char *challenge, char reponse[CLI_AUTH_RESPONSE_LEN]); diff --git a/include/varnishapi.h b/include/varnishapi.h index 6e3529c..74ec7a1 100644 --- a/include/varnishapi.h +++ b/include/varnishapi.h @@ -188,9 +188,9 @@ struct VSC_point { const volatile void *ptr; /* field value */ }; -typedef int vsc_iter_f(void *priv, const struct VSC_point *const pt); +typedef int VSC_iter_f(void *priv, const struct VSC_point *const pt); -int VSC_Iter(struct VSM_data *vd, vsc_iter_f *func, void *priv); +int VSC_Iter(struct VSM_data *vd, VSC_iter_f *func, void *priv); /* * Iterate over all statistics counters, calling "func" for * each counter not suppressed by any "-f" arguments. diff --git a/lib/libvarnish/cli_auth.c b/lib/libvarnish/cli_auth.c index 3d9f44e..87e113e 100644 --- a/lib/libvarnish/cli_auth.c +++ b/lib/libvarnish/cli_auth.c @@ -39,7 +39,7 @@ void -VCLI_response(int S_fd, const char *challenge, +VCLI_AuthResponse(int S_fd, const char *challenge, char response[CLI_AUTH_RESPONSE_LEN]) { SHA256_CTX ctx; diff --git a/lib/libvarnishapi/Makefile.am b/lib/libvarnishapi/Makefile.am index d60dd13..24422c1 100644 --- a/lib/libvarnishapi/Makefile.am +++ b/lib/libvarnishapi/Makefile.am @@ -14,9 +14,15 @@ libvarnishapi_la_SOURCES = \ ../libvarnish/argv.c \ ../libvarnish/vcs_version.c \ ../libvarnish/version.c \ + ../libvarnish/cli_common.c \ + ../libvarnish/cli_auth.c \ + ../libvarnish/tcp.c \ ../libvarnish/vin.c \ ../libvarnish/vmb.c \ ../libvarnish/vre.c \ + ../libvarnish/vsb.c \ + ../libvarnish/vsha256.c \ + ../libvarnish/vss.c \ base64.c \ vsm.c \ vsl_arg.c \ @@ -26,4 +32,4 @@ libvarnishapi_la_SOURCES = \ libvarnishapi_la_CFLAGS = \ -DVARNISH_STATE_DIR='"${VARNISH_STATE_DIR}"' -libvarnishapi_la_LIBADD = @PCRE_LIBS@ +libvarnishapi_la_LIBADD = @PCRE_LIBS@ ${LIBM} diff --git a/lib/libvarnishapi/vsc.c b/lib/libvarnishapi/vsc.c index 907a4d0..6e1eea5 100644 --- a/lib/libvarnishapi/vsc.c +++ b/lib/libvarnishapi/vsc.c @@ -250,7 +250,7 @@ iter_test(const char *s1, const char *s2, int wc) } static int -iter_call(const struct vsc *vsc, vsc_iter_f *func, void *priv, +iter_call(const struct vsc *vsc, VSC_iter_f *func, void *priv, const struct VSC_point *const sp) { struct vsc_sf *sf; @@ -283,7 +283,7 @@ iter_call(const struct vsc *vsc, vsc_iter_f *func, void *priv, #define VSC_DO(U,l,t) \ static int \ iter_##l(const struct vsc *vsc, struct VSM_chunk *sha, \ - vsc_iter_f *func, void *priv) \ + VSC_iter_f *func, void *priv) \ { \ struct VSC_C_##l *st; \ struct VSC_point sp; \ @@ -315,7 +315,7 @@ iter_call(const struct vsc *vsc, vsc_iter_f *func, void *priv, #undef VSC_DONE int -VSC_Iter(struct VSM_data *vd, vsc_iter_f *func, void *priv) +VSC_Iter(struct VSM_data *vd, VSC_iter_f *func, void *priv) { struct vsc *vsc; struct VSM_chunk *sha; From phk at varnish-cache.org Tue May 31 11:15:06 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 31 May 2011 13:15:06 +0200 Subject: [master] 230d8f2 Merge branch 'master' of ssh://git.varnish-cache.org/git/varnish-cache Message-ID: commit 230d8f2dcbb00f2bfae62e4d0f44ec0e3e5297c7 Merge: 01fbdac 50a77ab Author: Poul-Henning Kamp Date: Tue May 31 11:14:48 2011 +0000 Merge branch 'master' of ssh://git.varnish-cache.org/git/varnish-cache Conflicts: bin/varnishtest/vtc_varnish.c diff --cc bin/varnishtest/vtc.c index d8c98e9,fcf89ca..d3bd8b2 --- a/bin/varnishtest/vtc.c +++ b/bin/varnishtest/vtc.c @@@ -476,7 -534,7 +534,6 @@@ exec_file(const char *fn, const char *s { unsigned old_err; char *cwd, *p; -- char topbuild[BUFSIZ]; FILE *f; struct extmacro *m; diff --cc bin/varnishtest/vtc_varnish.c index c706487,ad8605d..66ad107 --- a/bin/varnishtest/vtc_varnish.c +++ b/bin/varnishtest/vtc_varnish.c @@@ -245,30 -245,30 +245,30 @@@ varnish_launch(struct varnish *v nap = VSS_resolve("127.0.0.1", "0", &ap); AN(nap); v->cli_fd = VSS_listen(ap[0], 1); - TCP_myname(v->cli_fd, abuf, sizeof abuf, pbuf, sizeof pbuf); + VTCP_myname(v->cli_fd, abuf, sizeof abuf, pbuf, sizeof pbuf); - AZ(vsb_finish(v->args)); + AZ(VSB_finish(v->args)); vtc_log(v->vl, 2, "Launch"); - vsb = vsb_new_auto(); + vsb = VSB_new_auto(); AN(vsb); - VSB_printf(vsb, "cd ${topbuild}/bin/varnishd &&"); - VSB_printf(vsb, " ./varnishd -d -d -n %s", v->workdir); - vsb_printf(vsb, "cd ${pwd} &&"); - vsb_printf(vsb, " ${varnishd} -d -d -n %s", v->workdir); - vsb_printf(vsb, " -l 10m,1m,-"); - vsb_printf(vsb, " -p auto_restart=off"); - vsb_printf(vsb, " -p syslog_cli_traffic=off"); - vsb_printf(vsb, " -a '%s'", "127.0.0.1:0"); - vsb_printf(vsb, " -S %s/_S", v->workdir); - vsb_printf(vsb, " -M '%s %s'", abuf, pbuf); - vsb_printf(vsb, " -P %s/varnishd.pid", v->workdir); - vsb_printf(vsb, " %s", vsb_data(v->storage)); - vsb_printf(vsb, " %s", vsb_data(v->args)); - AZ(vsb_finish(vsb)); - vtc_log(v->vl, 3, "CMD: %s", vsb_data(vsb)); - vsb1 = macro_expand(v->vl, vsb_data(vsb)); ++ VSB_printf(vsb, "cd ${pwd} &&"); ++ VSB_printf(vsb, " ${varnishd} -d -d -n %s", v->workdir); + VSB_printf(vsb, " -l 10m,1m,-"); + VSB_printf(vsb, " -p auto_restart=off"); + VSB_printf(vsb, " -p syslog_cli_traffic=off"); + VSB_printf(vsb, " -a '%s'", "127.0.0.1:0"); + VSB_printf(vsb, " -S %s/_S", v->workdir); + VSB_printf(vsb, " -M '%s %s'", abuf, pbuf); + VSB_printf(vsb, " -P %s/varnishd.pid", v->workdir); + VSB_printf(vsb, " %s", VSB_data(v->storage)); + VSB_printf(vsb, " %s", VSB_data(v->args)); + AZ(VSB_finish(vsb)); + vtc_log(v->vl, 3, "CMD: %s", VSB_data(vsb)); + vsb1 = macro_expand(v->vl, VSB_data(vsb)); AN(vsb1); - vsb_delete(vsb); + VSB_delete(vsb); vsb = vsb1; - vtc_log(v->vl, 3, "CMD: %s", 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(); From phk at varnish-cache.org Tue May 31 11:15:01 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 31 May 2011 13:15:01 +0200 Subject: [master] a5f1147 Prompted by symbols visibility issues with libvarnishapi (#926) we need some long overdue name-space cleanups. Message-ID: commit a5f11476e4a6c13b42fded340ee1626feecb105e Author: Poul-Henning Kamp Date: Tue May 31 07:39:13 2011 +0000 Prompted by symbols visibility issues with libvarnishapi (#926) we need some long overdue name-space cleanups. In general, the idea is that symbols we export are prefixed V[A-Z][A-Z], but some notable exceptions have existed until now, but will now be corrected. Here: vsb_ -> VSB_ diff --git a/bin/varnishd/cache_backend_poll.c b/bin/varnishd/cache_backend_poll.c index 543840a..61ed687 100644 --- a/bin/varnishd/cache_backend_poll.c +++ b/bin/varnishd/cache_backend_poll.c @@ -308,18 +308,18 @@ vbp_build_req(struct vsb *vsb, const struct vbp_vcl *vcl) XXXAN(vsb); XXXAN(vcl); - vsb_clear(vsb); + VSB_clear(vsb); if(vcl->probe.request != NULL) { - vsb_cat(vsb, vcl->probe.request); + VSB_cat(vsb, vcl->probe.request); } else { - vsb_printf(vsb, "GET %s HTTP/1.1\r\n", + VSB_printf(vsb, "GET %s HTTP/1.1\r\n", vcl->probe.url != NULL ? vcl->probe.url : "/"); if (vcl->hosthdr != NULL) - vsb_printf(vsb, "Host: %s\r\n", vcl->hosthdr); - vsb_printf(vsb, "Connection: close\r\n"); - vsb_printf(vsb, "\r\n"); + VSB_printf(vsb, "Host: %s\r\n", vcl->hosthdr); + VSB_printf(vsb, "Connection: close\r\n"); + VSB_printf(vsb, "\r\n"); } - AZ(vsb_finish(vsb)); + AZ(VSB_finish(vsb)); } /*-------------------------------------------------------------------- @@ -345,8 +345,8 @@ vbp_wrk_poll_backend(void *priv) } Lck_Unlock(&vbp_mtx); - vt->req = vsb_data(vt->vsb); - vt->req_len = vsb_len(vt->vsb); + vt->req = VSB_data(vt->vsb); + vt->req_len = VSB_len(vt->vsb); vbp_start_poke(vt); vbp_poke(vt); @@ -484,7 +484,7 @@ VBP_Start(struct backend *b, const struct vrt_backend_probe *p, const char *host XXXAN(vt); VTAILQ_INIT(&vt->vcls); vt->backend = b; - vt->vsb = vsb_new_auto(); + vt->vsb = VSB_new_auto(); XXXAN(vt->vsb); b->probe = vt; startthread = 1; @@ -563,7 +563,7 @@ VBP_Stop(struct backend *b, struct vrt_backend_probe const *p) VTAILQ_REMOVE(&vbp_list, vt, list); b->probe = NULL; - vsb_delete(vt->vsb); + VSB_delete(vt->vsb); FREE_OBJ(vt); } diff --git a/bin/varnishd/cache_ban.c b/bin/varnishd/cache_ban.c index 1fa569a..bde3b5b 100644 --- a/bin/varnishd/cache_ban.c +++ b/bin/varnishd/cache_ban.c @@ -124,7 +124,7 @@ BAN_New(void) ALLOC_OBJ(b, BAN_MAGIC); if (b == NULL) return (b); - b->vsb = vsb_new_auto(); + b->vsb = VSB_new_auto(); if (b->vsb == NULL) { FREE_OBJ(b); return (NULL); @@ -142,7 +142,7 @@ BAN_Free(struct ban *b) assert(VTAILQ_EMPTY(&b->objcore)); if (b->vsb != NULL) - vsb_delete(b->vsb); + VSB_delete(b->vsb); if (b->spec != NULL) free(b->spec); FREE_OBJ(b); @@ -229,8 +229,8 @@ ban_add_lump(const struct ban *b, const void *p, uint32_t len) uint8_t buf[sizeof len]; vbe32enc(buf, len); - vsb_bcat(b->vsb, buf, sizeof buf); - vsb_bcat(b->vsb, p, len); + VSB_bcat(b->vsb, buf, sizeof buf); + VSB_bcat(b->vsb, p, len); } static const void * @@ -278,10 +278,10 @@ ban_parse_http(const struct ban *b, const char *a1) l = strlen(a1) + 1; assert(l <= 127); - vsb_putc(b->vsb, (char)l); - vsb_cat(b->vsb, a1); - vsb_putc(b->vsb, ':'); - vsb_putc(b->vsb, '\0'); + VSB_putc(b->vsb, (char)l); + VSB_cat(b->vsb, a1); + VSB_putc(b->vsb, ':'); + VSB_putc(b->vsb, '\0'); } /*-------------------------------------------------------------------- @@ -333,25 +333,25 @@ BAN_AddTest(struct cli *cli, struct ban *b, const char *a1, const char *a2, if (pv->flag & PVAR_REQ) b->flags |= BAN_F_REQ; - vsb_putc(b->vsb, pv->tag); + VSB_putc(b->vsb, pv->tag); if (pv->flag & PVAR_HTTP) ban_parse_http(b, a1 + strlen(pv->name)); ban_add_lump(b, a3, strlen(a3) + 1); if (!strcmp(a2, "~")) { - vsb_putc(b->vsb, BAN_OPER_MATCH); + VSB_putc(b->vsb, BAN_OPER_MATCH); i = ban_parse_regexp(cli, b, a3); if (i) return (i); } else if (!strcmp(a2, "!~")) { - vsb_putc(b->vsb, BAN_OPER_NMATCH); + VSB_putc(b->vsb, BAN_OPER_NMATCH); i = ban_parse_regexp(cli, b, a3); if (i) return (i); } else if (!strcmp(a2, "==")) { - vsb_putc(b->vsb, BAN_OPER_EQ); + VSB_putc(b->vsb, BAN_OPER_EQ); } else if (!strcmp(a2, "!=")) { - vsb_putc(b->vsb, BAN_OPER_NEQ); + VSB_putc(b->vsb, BAN_OPER_NEQ); } else { cli_out(cli, "expected conditional (~, !~, == or !=) got \"%s\"", a2); @@ -378,8 +378,8 @@ BAN_Insert(struct ban *b) CHECK_OBJ_NOTNULL(b, BAN_MAGIC); - AZ(vsb_finish(b->vsb)); - ln = vsb_len(b->vsb); + AZ(VSB_finish(b->vsb)); + ln = VSB_len(b->vsb); assert(ln >= 0); b->spec = malloc(ln + 13L); /* XXX */ @@ -388,11 +388,11 @@ BAN_Insert(struct ban *b) t0 = TIM_real(); memcpy(b->spec, &t0, sizeof t0); b->spec[12] = (b->flags & BAN_F_REQ) ? 1 : 0; - memcpy(b->spec + 13, vsb_data(b->vsb), ln); + memcpy(b->spec + 13, VSB_data(b->vsb), ln); ln += 13; vbe32enc(b->spec + 8, ln); - vsb_delete(b->vsb); + VSB_delete(b->vsb); b->vsb = NULL; Lck_Lock(&ban_mtx); diff --git a/bin/varnishd/cache_center.c b/bin/varnishd/cache_center.c index 7325f5a..9a3749f 100644 --- a/bin/varnishd/cache_center.c +++ b/bin/varnishd/cache_center.c @@ -730,7 +730,7 @@ cnt_fetchbody(struct sess *sp) CHECK_OBJ_NOTNULL(sp->objcore, OBJCORE_MAGIC); vary = VRY_Create(sp, sp->wrk->beresp); if (vary != NULL) { - varyl = vsb_len(vary); + varyl = VSB_len(vary); assert(varyl > 0); l += varyl; } @@ -773,8 +773,8 @@ cnt_fetchbody(struct sess *sp) sp->obj->vary = (void *)WS_Alloc(sp->obj->http->ws, varyl); AN(sp->obj->vary); - memcpy(sp->obj->vary, vsb_data(vary), varyl); - vsb_delete(vary); + memcpy(sp->obj->vary, VSB_data(vary), varyl); + VSB_delete(vary); } sp->obj->xid = sp->xid; diff --git a/bin/varnishd/cache_cli.c b/bin/varnishd/cache_cli.c index 0ea5ba7..50538d7 100644 --- a/bin/varnishd/cache_cli.c +++ b/bin/varnishd/cache_cli.c @@ -97,7 +97,7 @@ cli_cb_after(const struct cli *cli) ASSERT_CLI(); Lck_Unlock(&cli_mtx); VSL(SLT_CLI, 0, "Wr %03u %u %s", - cli->result, vsb_len(cli->sb), vsb_data(cli->sb)); + cli->result, VSB_len(cli->sb), VSB_data(cli->sb)); } void diff --git a/bin/varnishd/cache_esi_fetch.c b/bin/varnishd/cache_esi_fetch.c index 58b3852..196cf66 100644 --- a/bin/varnishd/cache_esi_fetch.c +++ b/bin/varnishd/cache_esi_fetch.c @@ -367,14 +367,14 @@ vfp_esi_end(struct sess *sp) vsb = VEP_Finish(sp); if (vsb != NULL) { - l = vsb_len(vsb); + l = VSB_len(vsb); assert(l > 0); /* XXX: This is a huge waste of storage... */ sp->obj->esidata = STV_alloc(sp, l); AN(sp->obj->esidata); - memcpy(sp->obj->esidata->ptr, vsb_data(vsb), l); + memcpy(sp->obj->esidata->ptr, VSB_data(vsb), l); sp->obj->esidata->len = l; - vsb_delete(vsb); + VSB_delete(vsb); } if (sp->wrk->vgz_rx != NULL) VGZ_Destroy(&sp->wrk->vgz_rx); diff --git a/bin/varnishd/cache_esi_parse.c b/bin/varnishd/cache_esi_parse.c index 6d30619..265cb96 100644 --- a/bin/varnishd/cache_esi_parse.c +++ b/bin/varnishd/cache_esi_parse.c @@ -251,17 +251,17 @@ vep_emit_len(const struct vep_state *vep, ssize_t l, int m8, int m16, int m64) buf[0] = (uint8_t)m8; buf[1] = (uint8_t)l; assert((ssize_t)buf[1] == l); - vsb_bcat(vep->vsb, buf, 2); + VSB_bcat(vep->vsb, buf, 2); } else if (l < 65536) { buf[0] = (uint8_t)m16; vbe16enc(buf + 1, (uint16_t)l); assert((ssize_t)vbe16dec(buf + 1) == l); - vsb_bcat(vep->vsb, buf, 3); + VSB_bcat(vep->vsb, buf, 3); } else { buf[0] = (uint8_t)m64; vbe64enc(buf + 1, l); assert((ssize_t)vbe64dec(buf + 1) == l); - vsb_bcat(vep->vsb, buf, 9); + VSB_bcat(vep->vsb, buf, 9); } } @@ -287,7 +287,7 @@ vep_emit_verbatim(const struct vep_state *vep, ssize_t l, ssize_t l_crc) if (vep->dogzip) { vep_emit_len(vep, l_crc, VEC_C1, VEC_C2, VEC_C8); vbe32enc(buf, vep->crc); - vsb_bcat(vep->vsb, buf, sizeof buf); + VSB_bcat(vep->vsb, buf, sizeof buf); } } @@ -446,14 +446,14 @@ vep_do_include(struct vep_state *vep, enum dowhat what) Debug("DO_INCLUDE(%d)\n", what); if (what == DO_ATTR) { Debug("ATTR (%s) (%s)\n", vep->match_hit->match, - vsb_data(vep->attr_vsb)); + VSB_data(vep->attr_vsb)); if (vep->include_src != NULL) { vep_error(vep, "ESI 1.0 " "has multiple src= attributes"); vep->state = VEP_TAGERROR; - vsb_delete(vep->attr_vsb); - vsb_delete(vep->include_src); + VSB_delete(vep->attr_vsb); + VSB_delete(vep->include_src); vep->attr_vsb = NULL; vep->include_src = NULL; return; @@ -483,22 +483,22 @@ vep_do_include(struct vep_state *vep, enum dowhat what) */ assert(vep->o_wait == 0 || vep->last_mark == SKIP); /* XXX: what if it contains NUL bytes ?? */ - p = vsb_data(vep->include_src); - l = vsb_len(vep->include_src); + p = VSB_data(vep->include_src); + l = VSB_len(vep->include_src); h = 0; - vsb_printf(vep->vsb, "%c", VEC_INCL); + VSB_printf(vep->vsb, "%c", VEC_INCL); if (l > 7 && !memcmp(p, "http://", 7)) { h = p + 7; p = strchr(h, '/'); AN(p); Debug("HOST <%.*s> PATH <%s>\n", (int)(p-h),h, p); - vsb_printf(vep->vsb, "Host: %.*s%c", + VSB_printf(vep->vsb, "Host: %.*s%c", (int)(p-h), h, 0); } else if (*p == '/') { - vsb_printf(vep->vsb, "%c", 0); + VSB_printf(vep->vsb, "%c", 0); } else { - vsb_printf(vep->vsb, "%c", 0); + VSB_printf(vep->vsb, "%c", 0); url = vep->sp->wrk->bereq->hd[HTTP_HDR_URL]; /* Look for the last / before a '?' */ h = NULL; @@ -510,14 +510,14 @@ vep_do_include(struct vep_state *vep, enum dowhat what) Debug("INCL:: [%.*s]/[%s]\n", (int)(h - url.b), url.b, p); - vsb_printf(vep->vsb, "%.*s/", (int)(h - url.b), url.b); + VSB_printf(vep->vsb, "%.*s/", (int)(h - url.b), url.b); } - l -= (p - vsb_data(vep->include_src)); + l -= (p - VSB_data(vep->include_src)); for (q = p; *q != '\0'; ) { if (*q == '&') { #define R(w,f,r) \ if (q + w <= p + l && !memcmp(q, f, w)) { \ - vsb_printf(vep->vsb, "%c", r); \ + VSB_printf(vep->vsb, "%c", r); \ q += l; \ continue; \ } @@ -527,12 +527,12 @@ vep_do_include(struct vep_state *vep, enum dowhat what) R(4, ">", '>'); R(5, "&", '&'); } - vsb_printf(vep->vsb, "%c", *q++); + VSB_printf(vep->vsb, "%c", *q++); } #undef R - vsb_printf(vep->vsb, "%c", 0); + VSB_printf(vep->vsb, "%c", 0); - vsb_delete(vep->include_src); + VSB_delete(vep->include_src); vep->include_src = NULL; } @@ -846,7 +846,7 @@ VEP_parse(const struct sess *sp, const char *p, size_t l) vep->state = VEP_TAGERROR; } } else if (vep->state == VEP_ATTRGETVAL) { - vep->attr_vsb = vsb_new_auto(); + vep->attr_vsb = VSB_new_auto(); vep->state = VEP_ATTRDELIM; } else if (vep->state == VEP_ATTRDELIM) { AZ(vep->attr_delim); @@ -866,7 +866,7 @@ VEP_parse(const struct sess *sp, const char *p, size_t l) while (p < e && *p != '>' && *p != vep->attr_delim && (vep->attr_delim != ' ' || !vct_issp(*p))) { if (vep->attr_vsb != NULL) - vsb_bcat(vep->attr_vsb, p, 1); + VSB_bcat(vep->attr_vsb, p, 1); p++; } if (p < e && *p == '>') { @@ -875,8 +875,8 @@ VEP_parse(const struct sess *sp, const char *p, size_t l) vep->state = VEP_TAGERROR; vep->attr_delim = 0; if (vep->attr_vsb != NULL) { - AZ(vsb_finish(vep->attr_vsb)); - vsb_delete(vep->attr_vsb); + AZ(VSB_finish(vep->attr_vsb)); + VSB_delete(vep->attr_vsb); vep->attr_vsb = NULL; } } else if (p < e) { @@ -884,7 +884,7 @@ VEP_parse(const struct sess *sp, const char *p, size_t l) p++; vep->state = VEP_INTAG; if (vep->attr_vsb != NULL) { - AZ(vsb_finish(vep->attr_vsb)); + AZ(VSB_finish(vep->attr_vsb)); AN(vep->dostuff); vep->dostuff(vep, DO_ATTR); vep->attr_vsb = NULL; @@ -1005,13 +1005,13 @@ VEP_Init(const struct sess *sp, vep_callback_t *cb) memset(vep, 0, sizeof *vep); vep->magic = VEP_MAGIC; vep->sp = sp; - vep->vsb = vsb_new_auto(); + vep->vsb = VSB_new_auto(); AN(vep->vsb); if (cb != NULL) { vep->dogzip = 1; /* XXX */ - vsb_printf(vep->vsb, "%c", VEC_GZ); + VSB_printf(vep->vsb, "%c", VEC_GZ); vep->cb = cb; } else { vep->cb = vep_default_cb; @@ -1056,11 +1056,11 @@ VEP_Finish(const struct sess *sp) sp->wrk->vep = NULL; - AZ(vsb_finish(vep->vsb)); - l = vsb_len(vep->vsb); + AZ(VSB_finish(vep->vsb)); + l = VSB_len(vep->vsb); if (vep->esi_found && l > 0) return (vep->vsb); - vsb_delete(vep->vsb); + VSB_delete(vep->vsb); return (NULL); } diff --git a/bin/varnishd/cache_hash.c b/bin/varnishd/cache_hash.c index 14e3841..0b58581 100644 --- a/bin/varnishd/cache_hash.c +++ b/bin/varnishd/cache_hash.c @@ -752,7 +752,7 @@ HSH_config(const char *h_arg) hp = pick(hsh_choice, av[1], "hash"); CHECK_OBJ_NOTNULL(hp, SLINGER_MAGIC); - vsb_printf(vident, ",-h%s", av[1]); + VSB_printf(vident, ",-h%s", av[1]); heritage.hash = hp; if (hp->init != NULL) hp->init(ac, av + 2); diff --git a/bin/varnishd/cache_panic.c b/bin/varnishd/cache_panic.c index 08cff86..66e13c0 100644 --- a/bin/varnishd/cache_panic.c +++ b/bin/varnishd/cache_panic.c @@ -63,24 +63,24 @@ static void pan_ws(const struct ws *ws, int indent) { - vsb_printf(vsp, "%*sws = %p { %s\n", indent, "", + VSB_printf(vsp, "%*sws = %p { %s\n", indent, "", ws, ws->overflow ? "overflow" : ""); - vsb_printf(vsp, "%*sid = \"%s\",\n", indent + 2, "", ws->id); - vsb_printf(vsp, "%*s{s,f,r,e} = {%p", indent + 2, "", ws->s); + VSB_printf(vsp, "%*sid = \"%s\",\n", indent + 2, "", ws->id); + VSB_printf(vsp, "%*s{s,f,r,e} = {%p", indent + 2, "", ws->s); if (ws->f > ws->s) - vsb_printf(vsp, ",+%ld", (long) (ws->f - ws->s)); + VSB_printf(vsp, ",+%ld", (long) (ws->f - ws->s)); else - vsb_printf(vsp, ",%p", ws->f); + VSB_printf(vsp, ",%p", ws->f); if (ws->r > ws->s) - vsb_printf(vsp, ",+%ld", (long) (ws->r - ws->s)); + VSB_printf(vsp, ",+%ld", (long) (ws->r - ws->s)); else - vsb_printf(vsp, ",%p", ws->r); + VSB_printf(vsp, ",%p", ws->r); if (ws->e > ws->s) - vsb_printf(vsp, ",+%ld", (long) (ws->e - ws->s)); + VSB_printf(vsp, ",+%ld", (long) (ws->e - ws->s)); else - vsb_printf(vsp, ",%p", ws->e); - vsb_printf(vsp, "},\n"); - vsb_printf(vsp, "%*s},\n", indent, "" ); + VSB_printf(vsp, ",%p", ws->e); + VSB_printf(vsp, "},\n"); + VSB_printf(vsp, "%*s},\n", indent, "" ); } /*--------------------------------------------------------------------*/ @@ -93,9 +93,9 @@ pan_vbc(const struct vbc *vbc) be = vbc->backend; - vsb_printf(vsp, " backend = %p fd = %d {\n", be, vbc->fd); - vsb_printf(vsp, " vcl_name = \"%s\",\n", be->vcl_name); - vsb_printf(vsp, " },\n"); + VSB_printf(vsp, " backend = %p fd = %d {\n", be, vbc->fd); + VSB_printf(vsp, " vcl_name = \"%s\",\n", be->vcl_name); + VSB_printf(vsp, " },\n"); } /*--------------------------------------------------------------------*/ @@ -108,24 +108,24 @@ pan_storage(const struct storage *st) #define MAX_BYTES (4*16) #define show(ch) (((ch) > 31 && (ch) < 127) ? (ch) : '.') - vsb_printf(vsp, " %u {\n", st->len); + VSB_printf(vsp, " %u {\n", st->len); for (i = 0; i < MAX_BYTES && i < st->len; i += 16) { - vsb_printf(vsp, " "); + VSB_printf(vsp, " "); for (j = 0; j < 16; ++j) { if (i + j < st->len) - vsb_printf(vsp, "%02x ", st->ptr[i + j]); + VSB_printf(vsp, "%02x ", st->ptr[i + j]); else - vsb_printf(vsp, " "); + VSB_printf(vsp, " "); } - vsb_printf(vsp, "|"); + VSB_printf(vsp, "|"); for (j = 0; j < 16; ++j) if (i + j < st->len) - vsb_printf(vsp, "%c", show(st->ptr[i + j])); - vsb_printf(vsp, "|\n"); + VSB_printf(vsp, "%c", show(st->ptr[i + j])); + VSB_printf(vsp, "|\n"); } if (st->len > MAX_BYTES) - vsb_printf(vsp, " [%u more]\n", st->len - MAX_BYTES); - vsb_printf(vsp, " },\n"); + VSB_printf(vsp, " [%u more]\n", st->len - MAX_BYTES); + VSB_printf(vsp, " },\n"); #undef show #undef MAX_BYTES @@ -138,17 +138,17 @@ pan_http(const char *id, const struct http *h, int indent) { int i; - vsb_printf(vsp, "%*shttp[%s] = {\n", indent, "", id); - vsb_printf(vsp, "%*sws = %p[%s]\n", indent + 2, "", + VSB_printf(vsp, "%*shttp[%s] = {\n", indent, "", id); + VSB_printf(vsp, "%*sws = %p[%s]\n", indent + 2, "", h->ws, h->ws ? h->ws->id : ""); for (i = 0; i < h->nhd; ++i) { if (h->hd[i].b == NULL && h->hd[i].e == NULL) continue; - vsb_printf(vsp, "%*s\"%.*s\",\n", indent + 4, "", + VSB_printf(vsp, "%*s\"%.*s\",\n", indent + 4, "", (int)(h->hd[i].e - h->hd[i].b), h->hd[i].b); } - vsb_printf(vsp, "%*s},\n", indent, ""); + VSB_printf(vsp, "%*s},\n", indent, ""); } @@ -159,16 +159,16 @@ pan_object(const struct object *o) { const struct storage *st; - vsb_printf(vsp, " obj = %p {\n", o); - vsb_printf(vsp, " xid = %u,\n", o->xid); + VSB_printf(vsp, " obj = %p {\n", o); + VSB_printf(vsp, " xid = %u,\n", o->xid); pan_ws(o->ws_o, 4); pan_http("obj", o->http, 4); - vsb_printf(vsp, " len = %jd,\n", (intmax_t)o->len); - vsb_printf(vsp, " store = {\n"); + VSB_printf(vsp, " len = %jd,\n", (intmax_t)o->len); + VSB_printf(vsp, " store = {\n"); VTAILQ_FOREACH(st, &o->store, list) pan_storage(st); - vsb_printf(vsp, " },\n"); - vsb_printf(vsp, " },\n"); + VSB_printf(vsp, " },\n"); + VSB_printf(vsp, " },\n"); } /*--------------------------------------------------------------------*/ @@ -178,12 +178,12 @@ pan_vcl(const struct VCL_conf *vcl) { int i; - vsb_printf(vsp, " vcl = {\n"); - vsb_printf(vsp, " srcname = {\n"); + VSB_printf(vsp, " vcl = {\n"); + VSB_printf(vsp, " srcname = {\n"); for (i = 0; i < vcl->nsrc; ++i) - vsb_printf(vsp, " \"%s\",\n", vcl->srcname[i]); - vsb_printf(vsp, " },\n"); - vsb_printf(vsp, " },\n"); + VSB_printf(vsp, " \"%s\",\n", vcl->srcname[i]); + VSB_printf(vsp, " },\n"); + VSB_printf(vsp, " },\n"); } @@ -193,7 +193,7 @@ static void pan_wrk(const struct worker *wrk) { - vsb_printf(vsp, " worker = %p {\n", wrk); + VSB_printf(vsp, " worker = %p {\n", wrk); pan_ws(wrk->ws, 4); if (wrk->bereq->ws != NULL) pan_http("bereq", wrk->bereq, 4); @@ -201,7 +201,7 @@ pan_wrk(const struct worker *wrk) pan_http("beresp", wrk->beresp, 4); if (wrk->resp->ws != NULL) pan_http("resp", wrk->resp, 4); - vsb_printf(vsp, " },\n"); + VSB_printf(vsp, " },\n"); } /*--------------------------------------------------------------------*/ @@ -211,10 +211,10 @@ pan_sess(const struct sess *sp) { const char *stp, *hand; - vsb_printf(vsp, "sp = %p {\n", sp); - vsb_printf(vsp, + VSB_printf(vsp, "sp = %p {\n", sp); + VSB_printf(vsp, " fd = %d, id = %d, xid = %u,\n", sp->fd, sp->id, sp->xid); - vsb_printf(vsp, " client = %s %s,\n", + VSB_printf(vsp, " client = %s %s,\n", sp->addr ? sp->addr : "?.?.?.?", sp->port ? sp->port : "?"); switch (sp->step) { @@ -225,19 +225,19 @@ pan_sess(const struct sess *sp) } hand = VCC_Return_Name(sp->handling); if (stp != NULL) - vsb_printf(vsp, " step = %s,\n", stp); + VSB_printf(vsp, " step = %s,\n", stp); else - vsb_printf(vsp, " step = 0x%x,\n", sp->step); + VSB_printf(vsp, " step = 0x%x,\n", sp->step); if (hand != NULL) - vsb_printf(vsp, " handling = %s,\n", hand); + VSB_printf(vsp, " handling = %s,\n", hand); else - vsb_printf(vsp, " handling = 0x%x,\n", sp->handling); + VSB_printf(vsp, " handling = 0x%x,\n", sp->handling); if (sp->err_code) - vsb_printf(vsp, + VSB_printf(vsp, " err_code = %d, err_reason = %s,\n", sp->err_code, sp->err_reason ? sp->err_reason : "(null)"); - vsb_printf(vsp, " restarts = %d, esi_level = %d\n", + VSB_printf(vsp, " restarts = %d, esi_level = %d\n", sp->restarts, sp->esi_level); pan_ws(sp->ws, 2); @@ -255,7 +255,7 @@ pan_sess(const struct sess *sp) if (VALID_OBJ(sp->obj, OBJECT_MAGIC)) pan_object(sp->obj); - vsb_printf(vsp, "},\n"); + VSB_printf(vsp, "},\n"); } /*--------------------------------------------------------------------*/ @@ -270,18 +270,18 @@ pan_backtrace(void) size = backtrace (array, 10); if (size == 0) return; - vsb_printf(vsp, "Backtrace:\n"); + VSB_printf(vsp, "Backtrace:\n"); for (i = 0; i < size; i++) { - vsb_printf (vsp, " "); + VSB_printf (vsp, " "); if (Symbol_Lookup(vsp, array[i]) < 0) { char **strings; strings = backtrace_symbols(&array[i], 1); if (strings != NULL && strings[0] != NULL) - vsb_printf(vsp, "%p: %s", array[i], strings[0]); + VSB_printf(vsp, "%p: %s", array[i], strings[0]); else - vsb_printf(vsp, "%p: (?)", array[i]); + VSB_printf(vsp, "%p: (?)", array[i]); } - vsb_printf (vsp, "\n"); + VSB_printf (vsp, "\n"); } } @@ -296,36 +296,36 @@ pan_ic(const char *func, const char *file, int line, const char *cond, switch(xxx) { case 3: - vsb_printf(vsp, + VSB_printf(vsp, "Wrong turn at %s:%d:\n%s\n", file, line, cond); break; case 2: - vsb_printf(vsp, + VSB_printf(vsp, "Panic from VCL:\n %s\n", cond); break; case 1: - vsb_printf(vsp, + VSB_printf(vsp, "Missing errorhandling code in %s(), %s line %d:\n" " Condition(%s) not true.", func, file, line, cond); break; default: case 0: - vsb_printf(vsp, + VSB_printf(vsp, "Assert error in %s(), %s line %d:\n" " Condition(%s) not true.\n", func, file, line, cond); break; } if (err) - vsb_printf(vsp, "errno = %d (%s)\n", err, strerror(err)); + VSB_printf(vsp, "errno = %d (%s)\n", err, strerror(err)); q = THR_GetName(); if (q != NULL) - vsb_printf(vsp, "thread = (%s)\n", q); + VSB_printf(vsp, "thread = (%s)\n", q); - vsb_printf(vsp, "ident = %s,%s\n", - vsb_data(vident) + 1, VCA_waiter_name()); + VSB_printf(vsp, "ident = %s,%s\n", + VSB_data(vident) + 1, VCA_waiter_name()); pan_backtrace(); @@ -334,8 +334,8 @@ pan_ic(const char *func, const char *file, int line, const char *cond, if (sp != NULL) pan_sess(sp); } - vsb_printf(vsp, "\n"); - vsb_bcat(vsp, "", 1); /* NUL termination */ + VSB_printf(vsp, "\n"); + VSB_bcat(vsp, "", 1); /* NUL termination */ if (params->diag_bitmap & 0x4000) (void)fputs(vsm_head->panicstr, stderr); @@ -366,6 +366,6 @@ PAN_Init(void) vas_fail = pan_ic; vsp = &vsps; - AN(vsb_new(vsp, vsm_head->panicstr, sizeof vsm_head->panicstr, + AN(VSB_new(vsp, vsm_head->panicstr, sizeof vsm_head->panicstr, VSB_FIXEDLEN)); } diff --git a/bin/varnishd/cache_vary.c b/bin/varnishd/cache_vary.c index 28ee29f..034175b 100644 --- a/bin/varnishd/cache_vary.c +++ b/bin/varnishd/cache_vary.c @@ -72,11 +72,11 @@ VRY_Create(const struct sess *sp, const struct http *hp) return (NULL); /* For vary matching string */ - sb = vsb_new_auto(); + sb = VSB_new_auto(); AN(sb); /* For header matching strings */ - sbh = vsb_new_auto(); + sbh = VSB_new_auto(); AN(sbh); if (*v == ':') { @@ -92,15 +92,15 @@ VRY_Create(const struct sess *sp, const struct http *hp) continue; /* Build a header-matching string out of it */ - vsb_clear(sbh); - vsb_printf(sbh, "%c%.*s:%c", + VSB_clear(sbh); + VSB_printf(sbh, "%c%.*s:%c", (char)(1 + (q - p)), (int)(q - p), p, 0); - AZ(vsb_finish(sbh)); + AZ(VSB_finish(sbh)); /* Append to vary matching string */ - vsb_bcat(sb, vsb_data(sbh), vsb_len(sbh)); + VSB_bcat(sb, VSB_data(sbh), VSB_len(sbh)); - if (http_GetHdr(sp->http, vsb_data(sbh), &h)) { + if (http_GetHdr(sp->http, VSB_data(sbh), &h)) { /* Trim leading and trailing space */ while (isspace(*h)) h++; @@ -110,11 +110,11 @@ VRY_Create(const struct sess *sp, const struct http *hp) /* Encode two byte length and contents */ l = e - h; assert(!(l & ~0xffff)); - vsb_printf(sb, "%c%c", (unsigned)l >> 8, l & 0xff); - vsb_bcat(sb, h, e - h); + VSB_printf(sb, "%c%c", (unsigned)l >> 8, l & 0xff); + VSB_bcat(sb, h, e - h); } else { /* Mark as "not present" */ - vsb_printf(sb, "%c%c", 0xff, 0xff); + VSB_printf(sb, "%c%c", 0xff, 0xff); } while (isspace(*q)) @@ -125,10 +125,10 @@ VRY_Create(const struct sess *sp, const struct http *hp) p = q; } /* Terminate vary matching string */ - vsb_printf(sb, "%c", 0); + VSB_printf(sb, "%c", 0); - vsb_delete(sbh); - AZ(vsb_finish(sb)); + VSB_delete(sbh); + AZ(VSB_finish(sb)); return(sb); } diff --git a/bin/varnishd/cache_vrt.c b/bin/varnishd/cache_vrt.c index d66c66c..19aa575 100644 --- a/bin/varnishd/cache_vrt.c +++ b/bin/varnishd/cache_vrt.c @@ -404,13 +404,13 @@ VRT_synth_page(const struct sess *sp, unsigned flags, const char *str, ...) vsb = SMS_Makesynth(sp->obj); AN(vsb); - vsb_cat(vsb, str); + VSB_cat(vsb, str); va_start(ap, str); p = va_arg(ap, const char *); while (p != vrt_magic_string_end) { if (p == NULL) p = "(null)"; - vsb_cat(vsb, p); + VSB_cat(vsb, p); p = va_arg(ap, const char *); } va_end(ap); diff --git a/bin/varnishd/mgt_child.c b/bin/varnishd/mgt_child.c index 3ed569d..4258af2 100644 --- a/bin/varnishd/mgt_child.c +++ b/bin/varnishd/mgt_child.c @@ -438,19 +438,19 @@ mgt_save_panic(void) return; if (child_panic) - vsb_delete(child_panic); - child_panic = vsb_new_auto(); + VSB_delete(child_panic); + child_panic = VSB_new_auto(); XXXAN(child_panic); TIM_format(TIM_real(), time_str); - vsb_printf(child_panic, "Last panic at: %s\n", time_str); - vsb_cat(child_panic, vsm_head->panicstr); - AZ(vsb_finish(child_panic)); + VSB_printf(child_panic, "Last panic at: %s\n", time_str); + VSB_cat(child_panic, vsm_head->panicstr); + AZ(VSB_finish(child_panic)); } static void mgt_clear_panic(void) { - vsb_delete(child_panic); + VSB_delete(child_panic); child_panic = NULL; } @@ -476,26 +476,26 @@ mgt_sigchld(const struct vev *e, int what) if (r == 0 || (r == -1 && errno == ECHILD)) return (0); assert(r == child_pid); - vsb = vsb_new_auto(); + vsb = VSB_new_auto(); XXXAN(vsb); - vsb_printf(vsb, "Child (%d) %s", r, status ? "died" : "ended"); + VSB_printf(vsb, "Child (%d) %s", r, status ? "died" : "ended"); if (!WIFEXITED(status) && WEXITSTATUS(status)) { - vsb_printf(vsb, " status=%d", WEXITSTATUS(status)); + VSB_printf(vsb, " status=%d", WEXITSTATUS(status)); exit_status |= 0x20; } if (WIFSIGNALED(status)) { - vsb_printf(vsb, " signal=%d", WTERMSIG(status)); + VSB_printf(vsb, " signal=%d", WTERMSIG(status)); exit_status |= 0x40; } #ifdef WCOREDUMP if (WCOREDUMP(status)) { - vsb_printf(vsb, " (core dumped)"); + VSB_printf(vsb, " (core dumped)"); exit_status |= 0x80; } #endif - AZ(vsb_finish(vsb)); - REPORT(LOG_INFO, "%s", vsb_data(vsb)); - vsb_delete(vsb); + AZ(VSB_finish(vsb)); + REPORT(LOG_INFO, "%s", VSB_data(vsb)); + VSB_delete(vsb); mgt_report_panic(r); mgt_save_panic(); @@ -650,7 +650,7 @@ mcf_panic_show(struct cli *cli, const char * const *av, void *priv) return; } - cli_out(cli, "%s\n", vsb_data(child_panic)); + cli_out(cli, "%s\n", VSB_data(child_panic)); } void diff --git a/bin/varnishd/mgt_cli.c b/bin/varnishd/mgt_cli.c index 66ee1b4..d5c7fe0 100644 --- a/bin/varnishd/mgt_cli.c +++ b/bin/varnishd/mgt_cli.c @@ -79,7 +79,7 @@ mcf_banner(struct cli *cli, const char *const *av, void *priv) cli_out(cli, "-----------------------------\n"); cli_out(cli, "Varnish Cache CLI 1.0\n"); cli_out(cli, "-----------------------------\n"); - cli_out(cli, "%s\n", vsb_data(vident) + 1); + cli_out(cli, "%s\n", VSB_data(vident) + 1); cli_out(cli, "\n"); cli_out(cli, "Type 'help' for command list.\n"); cli_out(cli, "Type 'quit' to close CLI session.\n"); @@ -155,22 +155,22 @@ mcf_askchild(struct cli *cli, const char * const *av, void *priv) "Type 'help' for more info."); return; } - vsb = vsb_new_auto(); + vsb = VSB_new_auto(); for (i = 1; av[i] != NULL; i++) { - vsb_quote(vsb, av[i], strlen(av[i]), 0); - vsb_putc(vsb, ' '); + VSB_quote(vsb, av[i], strlen(av[i]), 0); + VSB_putc(vsb, ' '); } - vsb_putc(vsb, '\n'); - AZ(vsb_finish(vsb)); - i = write(cli_o, vsb_data(vsb), vsb_len(vsb)); - if (i != vsb_len(vsb)) { - vsb_delete(vsb); + VSB_putc(vsb, '\n'); + AZ(VSB_finish(vsb)); + i = write(cli_o, VSB_data(vsb), VSB_len(vsb)); + if (i != VSB_len(vsb)) { + VSB_delete(vsb); cli_result(cli, CLIS_COMMS); cli_out(cli, "CLI communication error"); MGT_Child_Cli_Fail(); return; } - vsb_delete(vsb); + VSB_delete(vsb); (void)cli_readres(cli_i, &u, &q, params->cli_timeout); cli_result(cli, u); cli_out(cli, "%s", q); @@ -327,7 +327,7 @@ mgt_cli_cb_after(const struct cli *cli) if (params->syslog_cli_traffic) syslog(LOG_NOTICE, "CLI %s Wr %03u %s", - cli->ident, cli->result, vsb_data(cli->sb)); + cli->ident, cli->result, VSB_data(cli->sb)); } /*--------------------------------------------------------------------*/ @@ -399,7 +399,7 @@ mgt_cli_setup(int fdi, int fdo, int verbose, const char *ident, mgt_cli_close_f cli->auth = MCF_AUTH; mcf_banner(cli, NULL, NULL); } - AZ(vsb_finish(cli->sb)); + AZ(VSB_finish(cli->sb)); (void)cli_writeres(fdo, cli); @@ -423,12 +423,12 @@ sock_id(const char *pfx, int fd) char abuf1[TCP_ADDRBUFSIZE], abuf2[TCP_ADDRBUFSIZE]; char pbuf1[TCP_PORTBUFSIZE], pbuf2[TCP_PORTBUFSIZE]; - vsb = vsb_new_auto(); + vsb = VSB_new_auto(); AN(vsb); TCP_myname(fd, abuf1, sizeof abuf1, pbuf1, sizeof pbuf1); TCP_hisname(fd, abuf2, sizeof abuf2, pbuf2, sizeof pbuf2); - vsb_printf(vsb, "%s %s %s %s %s", pfx, abuf2, pbuf2, abuf1, pbuf1); - AZ(vsb_finish(vsb)); + VSB_printf(vsb, "%s %s %s %s %s", pfx, abuf2, pbuf2, abuf1, pbuf1); + AZ(VSB_finish(vsb)); return (vsb); } @@ -482,8 +482,8 @@ telnet_accept(const struct vev *ev, int what) mgt_got_fd(i); tn = telnet_new(i); vsb = sock_id("telnet", i); - mgt_cli_setup(i, i, 0, vsb_data(vsb), telnet_close, tn); - vsb_delete(vsb); + mgt_cli_setup(i, i, 0, VSB_data(vsb), telnet_close, tn); + VSB_delete(vsb); return (0); } @@ -537,14 +537,14 @@ mgt_cli_telnet(const char *T_arg) exit(2); } good = 0; - vsb = vsb_new_auto(); + vsb = VSB_new_auto(); XXXAN(vsb); for (i = 0; i < n; ++i) { sock = VSS_listen(ta[i], 10); if (sock < 0) continue; TCP_myname(sock, abuf, sizeof abuf, pbuf, sizeof pbuf); - vsb_printf(vsb, "%s %s\n", abuf, pbuf); + VSB_printf(vsb, "%s %s\n", abuf, pbuf); good++; tn = telnet_new(sock); tn->ev = vev_new(); @@ -561,12 +561,12 @@ mgt_cli_telnet(const char *T_arg) REPORT(LOG_ERR, "-T %s could not be listened on.", T_arg); exit(2); } - AZ(vsb_finish(vsb)); + AZ(VSB_finish(vsb)); /* Save in shmem */ - p = VSM_Alloc(vsb_len(vsb) + 1, "Arg", "-T", ""); + p = VSM_Alloc(VSB_len(vsb) + 1, "Arg", "-T", ""); AN(p); - strcpy(p, vsb_data(vsb)); - vsb_delete(vsb); + strcpy(p, VSB_data(vsb)); + VSB_delete(vsb); } /* Reverse CLI ("Master") connections --------------------------------*/ @@ -613,8 +613,8 @@ Marg_poker(const struct vev *e, int what) return (1); } vsb = sock_id("master", M_fd); - mgt_cli_setup(M_fd, M_fd, 0, vsb_data(vsb), Marg_closer, NULL); - vsb_delete(vsb); + mgt_cli_setup(M_fd, M_fd, 0, VSB_data(vsb), Marg_closer, NULL); + VSB_delete(vsb); M_poll = 1; return (1); } diff --git a/bin/varnishd/mgt_vcc.c b/bin/varnishd/mgt_vcc.c index a3028ad..2e1c9a5 100644 --- a/bin/varnishd/mgt_vcc.c +++ b/bin/varnishd/mgt_vcc.c @@ -86,35 +86,35 @@ mgt_make_cc_cmd(const char *sf, const char *of) int pct; char *p; - sb = vsb_new_auto(); + sb = VSB_new_auto(); XXXAN(sb); for (p = mgt_cc_cmd, pct = 0; *p; ++p) { if (pct) { switch (*p) { case 's': - vsb_cat(sb, sf); + VSB_cat(sb, sf); break; case 'o': - vsb_cat(sb, of); + VSB_cat(sb, of); break; case '%': - vsb_putc(sb, '%'); + VSB_putc(sb, '%'); break; default: - vsb_putc(sb, '%'); - vsb_putc(sb, *p); + VSB_putc(sb, '%'); + VSB_putc(sb, *p); break; } pct = 0; } else if (*p == '%') { pct = 1; } else { - vsb_putc(sb, *p); + VSB_putc(sb, *p); } } if (pct) - vsb_putc(sb, '%'); - AZ(vsb_finish(sb)); + VSB_putc(sb, '%'); + AZ(VSB_finish(sb)); return (sb); } @@ -138,16 +138,16 @@ run_vcc(void *priv) int fd, i, l; CAST_OBJ_NOTNULL(vp, priv, VCC_PRIV_MAGIC); - sb = vsb_new_auto(); + sb = VSB_new_auto(); XXXAN(sb); VCC_VCL_dir(vcc, mgt_vcl_dir); VCC_VMOD_dir(vcc, mgt_vmod_dir); VCC_Err_Unref(vcc, mgt_vcc_err_unref); csrc = VCC_Compile(vcc, sb, vp->vcl); - AZ(vsb_finish(sb)); - if (vsb_len(sb)) - printf("%s", vsb_data(sb)); - vsb_delete(sb); + AZ(VSB_finish(sb)); + if (VSB_len(sb)) + printf("%s", VSB_data(sb)); + VSB_delete(sb); if (csrc == NULL) exit (1); @@ -236,7 +236,7 @@ mgt_run_cc(const char *vcl, struct vsb *sb, int C_flag) /* Create temporary C source file */ sfd = vtmpfile(sf); if (sfd < 0) { - vsb_printf(sb, "Failed to create %s: %s", sf, strerror(errno)); + VSB_printf(sb, "Failed to create %s: %s", sf, strerror(errno)); return (NULL); } AZ(close(sfd)); @@ -269,10 +269,10 @@ mgt_run_cc(const char *vcl, struct vsb *sb, int C_flag) cmdsb = mgt_make_cc_cmd(sf, of); /* Run the C-compiler in a sub-shell */ - i = SUB_run(sb, run_cc, vsb_data(cmdsb), "C-compiler", 10); + i = SUB_run(sb, run_cc, VSB_data(cmdsb), "C-compiler", 10); (void)unlink(sf); - vsb_delete(cmdsb); + VSB_delete(cmdsb); if (!i) i = SUB_run(sb, run_dlopen, of, "dlopen", 10); @@ -294,10 +294,10 @@ mgt_VccCompile(struct vsb **sb, const char *b, int C_flag) { char *vf; - *sb = vsb_new_auto(); + *sb = VSB_new_auto(); XXXAN(*sb); vf = mgt_run_cc(b, *sb, C_flag); - AZ(vsb_finish(*sb)); + AZ(VSB_finish(*sb)); return (vf); } @@ -387,9 +387,9 @@ mgt_vcc_default(const char *b_arg, const char *f_arg, char *vcl, int C_flag) vf = mgt_VccCompile(&sb, vcl, C_flag); free(vcl); - if (vsb_len(sb) > 0) - fprintf(stderr, "%s", vsb_data(sb)); - vsb_delete(sb); + if (VSB_len(sb) > 0) + fprintf(stderr, "%s", VSB_data(sb)); + VSB_delete(sb); if (C_flag) { if (vf != NULL) AZ(unlink(vf)); @@ -488,9 +488,9 @@ mcf_config_inline(struct cli *cli, const char * const *av, void *priv) } vf = mgt_VccCompile(&sb, av[3], 0); - if (vsb_len(sb) > 0) - cli_out(cli, "%s\n", vsb_data(sb)); - vsb_delete(sb); + if (VSB_len(sb) > 0) + cli_out(cli, "%s\n", VSB_data(sb)); + VSB_delete(sb); if (vf == NULL) { cli_out(cli, "VCL compilation failed"); cli_result(cli, CLIS_PARAM); @@ -534,9 +534,9 @@ mcf_config_load(struct cli *cli, const char * const *av, void *priv) vf = mgt_VccCompile(&sb, vcl, 0); free(vcl); - if (vsb_len(sb) > 0) - cli_out(cli, "%s", vsb_data(sb)); - vsb_delete(sb); + if (VSB_len(sb) > 0) + cli_out(cli, "%s", VSB_data(sb)); + VSB_delete(sb); if (vf == NULL) { cli_out(cli, "VCL compilation failed"); cli_result(cli, CLIS_PARAM); diff --git a/bin/varnishd/stevedore.c b/bin/varnishd/stevedore.c index 51f4422..dfde531 100644 --- a/bin/varnishd/stevedore.c +++ b/bin/varnishd/stevedore.c @@ -458,7 +458,7 @@ STV_Config(const char *spec) AN(stv2); /* Append strategy to ident string */ - vsb_printf(vident, ",-s%s", av[1]); + VSB_printf(vident, ",-s%s", av[1]); av += 2; diff --git a/bin/varnishd/storage_synth.c b/bin/varnishd/storage_synth.c index f21158c..6894e99 100644 --- a/bin/varnishd/storage_synth.c +++ b/bin/varnishd/storage_synth.c @@ -52,7 +52,7 @@ sms_free(struct storage *sto) VSC_main->sms_nbytes -= sto->len; VSC_main->sms_bfree += sto->len; Lck_Unlock(&sms_mtx); - vsb_delete(sto->priv); + VSB_delete(sto->priv); free(sto); } @@ -86,7 +86,7 @@ SMS_Makesynth(struct object *obj) sto = calloc(sizeof *sto, 1); XXXAN(sto); - vsb = vsb_new_auto(); + vsb = VSB_new_auto(); XXXAN(vsb); sto->priv = vsb; sto->len = 0; @@ -111,11 +111,11 @@ SMS_Finish(struct object *obj) sto = VTAILQ_FIRST(&obj->store); assert(sto->stevedore == &sms_stevedore); vsb = sto->priv; - AZ(vsb_finish(vsb)); + AZ(VSB_finish(vsb)); - sto->ptr = (void*)vsb_data(vsb); - sto->len = vsb_len(vsb); - sto->space = vsb_len(vsb); + sto->ptr = (void*)VSB_data(vsb); + sto->len = VSB_len(vsb); + sto->space = VSB_len(vsb); obj->len = sto->len; Lck_Lock(&sms_mtx); VSC_main->sms_nbytes += sto->len; diff --git a/bin/varnishd/varnishd.c b/bin/varnishd/varnishd.c index b36f28c..74f8f3c 100644 --- a/bin/varnishd/varnishd.c +++ b/bin/varnishd/varnishd.c @@ -83,12 +83,12 @@ build_vident(void) { struct utsname uts; - vident = vsb_new_auto(); + vident = VSB_new_auto(); AN(vident); if (!uname(&uts)) { - vsb_printf(vident, ",%s", uts.sysname); - vsb_printf(vident, ",%s", uts.release); - vsb_printf(vident, ",%s", uts.machine); + VSB_printf(vident, ",%s", uts.sysname); + VSB_printf(vident, ",%s", uts.release); + VSB_printf(vident, ",%s", uts.machine); } } @@ -219,11 +219,11 @@ static void cli_check(const struct cli *cli) { if (cli->result == CLIS_OK) { - vsb_clear(cli->sb); + VSB_clear(cli->sb); return; } - AZ(vsb_finish(cli->sb)); - fprintf(stderr, "Error:\n%s\n", vsb_data(cli->sb)); + AZ(VSB_finish(cli->sb)); + fprintf(stderr, "Error:\n%s\n", VSB_data(cli->sb)); exit (2); } @@ -262,7 +262,7 @@ Symbol_Lookup(struct vsb *vsb, void *ptr) } if (s0 == NULL) return (-1); - vsb_printf(vsb, "%p: %s+%jx", ptr, s0->n, (uintmax_t)pp - s0->a); + VSB_printf(vsb, "%p: %s+%jx", ptr, s0->n, (uintmax_t)pp - s0->a); return (0); } @@ -394,7 +394,7 @@ main(int argc, char * const *argv) SHA256_Test(); memset(cli, 0, sizeof cli); - cli[0].sb = vsb_new_auto(); + cli[0].sb = VSB_new_auto(); XXXAN(cli[0].sb); cli[0].result = CLIS_OK; @@ -526,8 +526,8 @@ main(int argc, char * const *argv) /* XXX: we can have multiple CLI actions above, is this enough ? */ if (cli[0].result != CLIS_OK) { fprintf(stderr, "Parameter errors:\n"); - AZ(vsb_finish(cli[0].sb)); - fprintf(stderr, "%s\n", vsb_data(cli[0].sb)); + AZ(VSB_finish(cli[0].sb)); + fprintf(stderr, "%s\n", VSB_data(cli[0].sb)); exit(1); } @@ -613,7 +613,7 @@ main(int argc, char * const *argv) mgt_SHM_Init(l_arg); - AZ(vsb_finish(vident)); + AZ(VSB_finish(vident)); if (!d_flag && !F_flag) AZ(varnish_daemon(1, 0)); @@ -624,8 +624,8 @@ main(int argc, char * const *argv) fprintf(stderr, "NOTE: Could not write PID file\n"); if (d_flag) - fprintf(stderr, "Platform: %s\n", vsb_data(vident) + 1); - syslog(LOG_NOTICE, "Platform: %s\n", vsb_data(vident) + 1); + fprintf(stderr, "Platform: %s\n", VSB_data(vident) + 1); + syslog(LOG_NOTICE, "Platform: %s\n", VSB_data(vident) + 1); /* Do this again after debugstunt and daemon has run */ mgt_pid = getpid(); diff --git a/bin/varnishlog/varnishlog.c b/bin/varnishlog/varnishlog.c index c6373f6..ddfff39 100644 --- a/bin/varnishlog/varnishlog.c +++ b/bin/varnishlog/varnishlog.c @@ -63,12 +63,12 @@ static void h_order_finish(int fd, struct VSM_data *vd) { - AZ(vsb_finish(ob[fd])); - if (vsb_len(ob[fd]) > 1 && VSL_Matched(vd, bitmap[fd])) { - printf("%s", vsb_data(ob[fd])); + AZ(VSB_finish(ob[fd])); + if (VSB_len(ob[fd]) > 1 && VSL_Matched(vd, bitmap[fd])) { + printf("%s", VSB_data(ob[fd])); } bitmap[fd] = 0; - vsb_clear(ob[fd]); + VSB_clear(ob[fd]); } static void @@ -79,13 +79,13 @@ clean_order(struct VSM_data *vd) for (u = 0; u < 65536; u++) { if (ob[u] == NULL) continue; - AZ(vsb_finish(ob[u])); - if (vsb_len(ob[u]) > 1 && VSL_Matched(vd, bitmap[u])) { - printf("%s\n", vsb_data(ob[u])); + AZ(VSB_finish(ob[u])); + if (VSB_len(ob[u]) > 1 && VSL_Matched(vd, bitmap[u])) { + printf("%s\n", VSB_data(ob[u])); } flg[u] = 0; bitmap[u] = 0; - vsb_clear(ob[u]); + VSB_clear(ob[u]); } } @@ -108,7 +108,7 @@ h_order(void *priv, enum vsl_tag tag, unsigned fd, unsigned len, return (0); } if (ob[fd] == NULL) { - ob[fd] = vsb_new_auto(); + ob[fd] = VSB_new_auto(); assert(ob[fd] != NULL); } if ((tag == SLT_BackendOpen || tag == SLT_SessionOpen || @@ -117,14 +117,14 @@ h_order(void *priv, enum vsl_tag tag, unsigned fd, unsigned len, last[fd] != SLT_VCL_acl) || (tag == SLT_BackendXID && last[fd] != SLT_BackendOpen)) && - vsb_len(ob[fd]) != 0) { + VSB_len(ob[fd]) != 0) { /* * This is the start of a new request, yet we haven't seen * the end of the previous one. Spit it out anyway before * starting on the new one. */ if (last[fd] != SLT_SessionClose) - vsb_printf(ob[fd], "%5d %-12s %c %s\n", + VSB_printf(ob[fd], "%5d %-12s %c %s\n", fd, "Interrupted", type, VSL_tags[tag]); h_order_finish(fd, vd); } @@ -134,17 +134,17 @@ h_order(void *priv, enum vsl_tag tag, unsigned fd, unsigned len, switch (tag) { case SLT_VCL_call: if (flg[fd] & F_INVCL) - vsb_cat(ob[fd], "\n"); + VSB_cat(ob[fd], "\n"); else flg[fd] |= F_INVCL; - vsb_printf(ob[fd], "%5d %-12s %c %.*s", + VSB_printf(ob[fd], "%5d %-12s %c %.*s", fd, VSL_tags[tag], type, len, ptr); return (0); case SLT_VCL_trace: case SLT_VCL_return: if (flg[fd] & F_INVCL) { - vsb_cat(ob[fd], " "); - vsb_bcat(ob[fd], ptr, len); + VSB_cat(ob[fd], " "); + VSB_bcat(ob[fd], ptr, len); return (0); } break; @@ -152,10 +152,10 @@ h_order(void *priv, enum vsl_tag tag, unsigned fd, unsigned len, break; } if (flg[fd] & F_INVCL) { - vsb_cat(ob[fd], "\n"); + VSB_cat(ob[fd], "\n"); flg[fd] &= ~F_INVCL; } - vsb_printf(ob[fd], "%5d %-12s %c %.*s\n", + VSB_printf(ob[fd], "%5d %-12s %c %.*s\n", fd, VSL_tags[tag], type, len, ptr); switch (tag) { case SLT_ReqEnd: diff --git a/bin/varnishtest/vtc.c b/bin/varnishtest/vtc.c index e893be1..2c54808 100644 --- a/bin/varnishtest/vtc.c +++ b/bin/varnishtest/vtc.c @@ -161,18 +161,18 @@ macro_expand(struct vtclog *vl, const char *text) const char *p, *q; char *m; - vsb = vsb_new_auto(); + vsb = VSB_new_auto(); AN(vsb); while (*text != '\0') { p = strstr(text, "${"); if (p == NULL) { - vsb_cat(vsb, text); + VSB_cat(vsb, text); break; } - vsb_bcat(vsb, text, p - text); + VSB_bcat(vsb, text, p - text); q = strchr(p, '}'); if (q == NULL) { - vsb_cat(vsb, text); + VSB_cat(vsb, text); break; } assert(p[0] == '$'); @@ -181,14 +181,14 @@ macro_expand(struct vtclog *vl, const char *text) p += 2; m = macro_get(p, q); if (m == NULL) { - vsb_delete(vsb); + VSB_delete(vsb); vtc_log(vl, 0, "Macro ${%s} not found", p); return (NULL); } - vsb_printf(vsb, "%s", m); + VSB_printf(vsb, "%s", m); text = q + 1; } - AZ(vsb_finish(vsb)); + AZ(VSB_finish(vsb)); return (vsb); } @@ -288,7 +288,7 @@ parse_string(char *buf, const struct cmds *cmd, void *priv, struct vtclog *vl) token_exp[tn] = macro_expand(vl, token_s[tn]); if (vtc_error) return; - token_s[tn] = vsb_data(token_exp[tn]); + token_s[tn] = VSB_data(token_exp[tn]); token_e[tn] = strchr(token_s[tn], '\0'); } diff --git a/bin/varnishtest/vtc_client.c b/bin/varnishtest/vtc_client.c index c7a2588..4f3e984 100644 --- a/bin/varnishtest/vtc_client.c +++ b/bin/varnishtest/vtc_client.c @@ -94,21 +94,21 @@ client_thread(void *priv) if (c->repeat != 1) vtc_log(vl, 2, "Started (%u iterations)", c->repeat); for (u = 0; u < c->repeat; u++) { - vtc_log(vl, 3, "Connect to %s", vsb_data(vsb)); - fd = VSS_open(vsb_data(vsb), 10.); + vtc_log(vl, 3, "Connect to %s", VSB_data(vsb)); + fd = VSS_open(VSB_data(vsb), 10.); if (fd < 0) - vtc_log(c->vl, 0, "Failed to open %s", vsb_data(vsb)); + vtc_log(c->vl, 0, "Failed to open %s", VSB_data(vsb)); assert(fd >= 0); TCP_blocking(fd); TCP_myname(fd, mabuf, sizeof mabuf, mpbuf, sizeof mpbuf); vtc_log(vl, 3, "connected fd %d from %s %s to %s", - fd, mabuf, mpbuf, vsb_data(vsb)); + fd, mabuf, mpbuf, VSB_data(vsb)); http_process(vl, c->spec, fd, -1); vtc_log(vl, 3, "closing fd %d", fd); TCP_close(&fd); } vtc_log(vl, 2, "Ending"); - vsb_delete(vsb); + VSB_delete(vsb); free(p); return (NULL); } diff --git a/bin/varnishtest/vtc_http.c b/bin/varnishtest/vtc_http.c index ea12752..ddd0a8a 100644 --- a/bin/varnishtest/vtc_http.c +++ b/bin/varnishtest/vtc_http.c @@ -139,10 +139,10 @@ http_write(const struct http *hp, int lvl, const char *pfx) { int l; - AZ(vsb_finish(hp->vsb)); - vtc_dump(hp->vl, lvl, pfx, vsb_data(hp->vsb), vsb_len(hp->vsb)); - l = write(hp->fd, vsb_data(hp->vsb), vsb_len(hp->vsb)); - if (l != vsb_len(hp->vsb)) + AZ(VSB_finish(hp->vsb)); + vtc_dump(hp->vl, lvl, pfx, VSB_data(hp->vsb), VSB_len(hp->vsb)); + l = write(hp->fd, VSB_data(hp->vsb), VSB_len(hp->vsb)); + if (l != VSB_len(hp->vsb)) vtc_log(hp->vl, 0, "Write failed: %s", strerror(errno)); } @@ -646,7 +646,7 @@ cmd_http_txresp(CMD_ARGS) assert(!strcmp(av[0], "txresp")); av++; - vsb_clear(hp->vsb); + VSB_clear(hp->vsb); /* send a "Content-Length: 0" header unless something else happens */ REPLACE(body, ""); @@ -667,13 +667,13 @@ cmd_http_txresp(CMD_ARGS) break; } - vsb_printf(hp->vsb, "%s %s %s%s", proto, status, msg, nl); + VSB_printf(hp->vsb, "%s %s %s%s", proto, status, msg, nl); for(; *av != NULL; av++) { if (!strcmp(*av, "-nolen")) { nolen = 1; } else if (!strcmp(*av, "-hdr")) { - vsb_printf(hp->vsb, "%s%s", av[1], nl); + VSB_printf(hp->vsb, "%s%s", av[1], nl); av++; } else break; @@ -711,13 +711,13 @@ cmd_http_txresp(CMD_ARGS) assert(body == nullbody); b = synth_body(av[1], 1); gzip_body(hp, b, &body, &bodylen); - vsb_printf(hp->vsb, "Content-Encoding: gzip%s", nl); + VSB_printf(hp->vsb, "Content-Encoding: gzip%s", nl); // vtc_hexdump(hp->vl, 4, "gzip", (void*)body, bodylen); av++; } else if (!strcmp(*av, "-gzipbody")) { assert(body == nullbody); gzip_body(hp, av[1], &body, &bodylen); - vsb_printf(hp->vsb, "Content-Encoding: gzip%s", nl); + VSB_printf(hp->vsb, "Content-Encoding: gzip%s", nl); // vtc_hexdump(hp->vl, 4, "gzip", (void*)body, bodylen); av++; } else @@ -726,10 +726,10 @@ cmd_http_txresp(CMD_ARGS) if (*av != NULL) vtc_log(hp->vl, 0, "Unknown http txresp spec: %s\n", *av); if (body != NULL && !nolen) - vsb_printf(hp->vsb, "Content-Length: %d%s", bodylen, nl); - vsb_cat(hp->vsb, nl); + VSB_printf(hp->vsb, "Content-Length: %d%s", bodylen, nl); + VSB_cat(hp->vsb, nl); if (body != NULL) - vsb_bcat(hp->vsb, body, bodylen); + VSB_bcat(hp->vsb, body, bodylen); http_write(hp, 4, "txresp"); } @@ -833,7 +833,7 @@ cmd_http_txreq(CMD_ARGS) assert(!strcmp(av[0], "txreq")); av++; - vsb_clear(hp->vsb); + VSB_clear(hp->vsb); for(; *av != NULL; av++) { if (!strcmp(*av, "-url")) { @@ -848,10 +848,10 @@ cmd_http_txreq(CMD_ARGS) } else break; } - vsb_printf(hp->vsb, "%s %s %s%s", req, url, proto, nl); + VSB_printf(hp->vsb, "%s %s %s%s", req, url, proto, nl); for(; *av != NULL; av++) { if (!strcmp(*av, "-hdr")) { - vsb_printf(hp->vsb, "%s%s", av[1], nl); + VSB_printf(hp->vsb, "%s%s", av[1], nl); av++; } else break; @@ -871,12 +871,12 @@ cmd_http_txreq(CMD_ARGS) if (*av != NULL) vtc_log(hp->vl, 0, "Unknown http txreq spec: %s\n", *av); if (body != NULL) - vsb_printf(hp->vsb, "Content-Length: %ju%s", + VSB_printf(hp->vsb, "Content-Length: %ju%s", (uintmax_t)strlen(body), nl); - vsb_cat(hp->vsb, nl); + VSB_cat(hp->vsb, nl); if (body != NULL) { - vsb_cat(hp->vsb, body); - vsb_cat(hp->vsb, nl); + VSB_cat(hp->vsb, body); + VSB_cat(hp->vsb, nl); } http_write(hp, 4, "txreq"); } @@ -916,8 +916,8 @@ cmd_http_chunked(CMD_ARGS) CAST_OBJ_NOTNULL(hp, priv, HTTP_MAGIC); AN(av[1]); AZ(av[2]); - vsb_clear(hp->vsb); - vsb_printf(hp->vsb, "%jx%s%s%s", + VSB_clear(hp->vsb); + VSB_printf(hp->vsb, "%jx%s%s%s", (uintmax_t)strlen(av[1]), nl, av[1], nl); http_write(hp, 4, "chunked"); } @@ -935,24 +935,24 @@ cmd_http_chunkedlen(CMD_ARGS) CAST_OBJ_NOTNULL(hp, priv, HTTP_MAGIC); AN(av[1]); AZ(av[2]); - vsb_clear(hp->vsb); + VSB_clear(hp->vsb); len = atoi(av[1]); if (len == 0) { - vsb_printf(hp->vsb, "0%s%s", nl, nl); + VSB_printf(hp->vsb, "0%s%s", nl, nl); } else { for (u = 0; u < sizeof buf; u++) buf[u] = (u & 7) + '0'; - vsb_printf(hp->vsb, "%x%s", len, nl); + VSB_printf(hp->vsb, "%x%s", len, nl); for (u = 0; u < len; u += v) { v = len - u; if (v > sizeof buf) v = sizeof buf; - vsb_bcat(hp->vsb, buf, v); + VSB_bcat(hp->vsb, buf, v); } - vsb_printf(hp->vsb, "%s", nl); + VSB_printf(hp->vsb, "%s", nl); } http_write(hp, 4, "chunked"); } @@ -1101,7 +1101,7 @@ http_process(struct vtclog *vl, const char *spec, int sock, int sfd) hp->fd = sock; hp->timeout = 5000; hp->nrxbuf = 640*1024; - hp->vsb = vsb_new_auto(); + hp->vsb = VSB_new_auto(); hp->rxbuf = malloc(hp->nrxbuf); /* XXX */ hp->sfd = sfd; hp->vl = vl; @@ -1115,7 +1115,7 @@ http_process(struct vtclog *vl, const char *spec, int sock, int sfd) assert(q > s); AN(s); parse_string(s, http_cmds, hp, vl); - vsb_delete(hp->vsb); + VSB_delete(hp->vsb); free(hp->rxbuf); free(hp); } diff --git a/bin/varnishtest/vtc_log.c b/bin/varnishtest/vtc_log.c index ebeb7df..8ad19e0 100644 --- a/bin/varnishtest/vtc_log.c +++ b/bin/varnishtest/vtc_log.c @@ -81,7 +81,7 @@ vtc_logopen(const char *id) ALLOC_OBJ(vl, VTCLOG_MAGIC); AN(vl); vl->id = id; - vl->vsb = vsb_new_auto(); + vl->vsb = VSB_new_auto(); AZ(pthread_mutex_init(&vl->mtx, NULL)); AZ(pthread_setspecific(log_key, vl)); return (vl); @@ -92,7 +92,7 @@ vtc_logclose(struct vtclog *vl) { CHECK_OBJ_NOTNULL(vl, VTCLOG_MAGIC); - vsb_delete(vl->vsb); + VSB_delete(vl->vsb); AZ(pthread_mutex_destroy(&vl->mtx)); FREE_OBJ(vl); } @@ -114,10 +114,10 @@ vtc_log_emit(const struct vtclog *vl, unsigned lvl) if (vtc_stop && lvl == 0) return; - l = vsb_len(vl->vsb); + l = VSB_len(vl->vsb); AZ(pthread_mutex_lock(&vtclog_mtx)); assert(vtclog_left > l); - memcpy(vtclog_buf,vsb_data(vl->vsb), l); + memcpy(vtclog_buf,VSB_data(vl->vsb), l); vtclog_buf += l; *vtclog_buf = '\0'; vtclog_left -= l; @@ -134,18 +134,18 @@ vtc_log(struct vtclog *vl, unsigned lvl, const char *fmt, ...) tx = TIM_mono() - t0; AZ(pthread_mutex_lock(&vl->mtx)); assert(lvl < NLEAD); - vsb_clear(vl->vsb); - vsb_printf(vl->vsb, "%s %-4s %4.1f ", lead[lvl], vl->id, tx); + VSB_clear(vl->vsb); + VSB_printf(vl->vsb, "%s %-4s %4.1f ", lead[lvl], vl->id, tx); va_list ap; va_start(ap, fmt); - (void)vsb_vprintf(vl->vsb, fmt, ap); + (void)VSB_vprintf(vl->vsb, fmt, ap); va_end(ap); - vsb_putc(vl->vsb, '\n'); - AZ(vsb_finish(vl->vsb)); + VSB_putc(vl->vsb, '\n'); + AZ(VSB_finish(vl->vsb)); vtc_log_emit(vl, lvl); - vsb_clear(vl->vsb); + VSB_clear(vl->vsb); AZ(pthread_mutex_unlock(&vl->mtx)); if (lvl == 0) { vtc_error = 1; @@ -170,45 +170,45 @@ vtc_dump(struct vtclog *vl, unsigned lvl, const char *pfx, const char *str, int tx = TIM_mono() - t0; assert(lvl < NLEAD); AZ(pthread_mutex_lock(&vl->mtx)); - vsb_clear(vl->vsb); + VSB_clear(vl->vsb); if (pfx == NULL) pfx = ""; if (str == NULL) - vsb_printf(vl->vsb, "%s %-4s %4.1f %s(null)\n", + VSB_printf(vl->vsb, "%s %-4s %4.1f %s(null)\n", lead[lvl], vl->id, tx, pfx); else { if (len == -1) len = strlen(str); for (l = 0; l < len; l++, str++) { if (l > 512) { - vsb_printf(vl->vsb, "..."); + VSB_printf(vl->vsb, "..."); break; } if (nl) { - vsb_printf(vl->vsb, "%s %-4s %4.1f %s| ", + VSB_printf(vl->vsb, "%s %-4s %4.1f %s| ", lead[lvl], vl->id, tx, pfx); nl = 0; } if (*str == '\r') - vsb_printf(vl->vsb, "\\r"); + VSB_printf(vl->vsb, "\\r"); else if (*str == '\t') - vsb_printf(vl->vsb, "\\t"); + VSB_printf(vl->vsb, "\\t"); else if (*str == '\n') { - vsb_printf(vl->vsb, "\\n\n"); + VSB_printf(vl->vsb, "\\n\n"); nl = 1; } else if (*str < 0x20 || *str > 0x7e) - vsb_printf(vl->vsb, "\\x%02x", (*str) & 0xff); + VSB_printf(vl->vsb, "\\x%02x", (*str) & 0xff); else - vsb_printf(vl->vsb, "%c", *str); + VSB_printf(vl->vsb, "%c", *str); } } if (!nl) - vsb_printf(vl->vsb, "\n"); - AZ(vsb_finish(vl->vsb)); + VSB_printf(vl->vsb, "\n"); + AZ(VSB_finish(vl->vsb)); vtc_log_emit(vl, lvl); - vsb_clear(vl->vsb); + VSB_clear(vl->vsb); AZ(pthread_mutex_unlock(&vl->mtx)); if (lvl == 0) { vtc_error = 1; @@ -232,37 +232,37 @@ vtc_hexdump(struct vtclog *vl, unsigned lvl, const char *pfx, const unsigned cha assert(len >= 0); assert(lvl < NLEAD); AZ(pthread_mutex_lock(&vl->mtx)); - vsb_clear(vl->vsb); + VSB_clear(vl->vsb); if (pfx == NULL) pfx = ""; if (str == NULL) - vsb_printf(vl->vsb, "%s %-4s %s(null)\n", + VSB_printf(vl->vsb, "%s %-4s %s(null)\n", lead[lvl], vl->id, pfx); else { for (l = 0; l < len; l++, str++) { if (l > 512) { - vsb_printf(vl->vsb, "..."); + VSB_printf(vl->vsb, "..."); break; } if (nl) { - vsb_printf(vl->vsb, "%s %-4s %s| ", + VSB_printf(vl->vsb, "%s %-4s %s| ", lead[lvl], vl->id, pfx); nl = 0; } - vsb_printf(vl->vsb, " %02x", *str); + VSB_printf(vl->vsb, " %02x", *str); if ((l & 0xf) == 0xf) { - vsb_printf(vl->vsb, "\n"); + VSB_printf(vl->vsb, "\n"); nl = 1; } } } if (!nl) - vsb_printf(vl->vsb, "\n"); - AZ(vsb_finish(vl->vsb)); + VSB_printf(vl->vsb, "\n"); + AZ(VSB_finish(vl->vsb)); vtc_log_emit(vl, lvl); - vsb_clear(vl->vsb); + VSB_clear(vl->vsb); AZ(pthread_mutex_unlock(&vl->mtx)); if (lvl == 0) { vtc_error = 1; diff --git a/bin/varnishtest/vtc_server.c b/bin/varnishtest/vtc_server.c index a7871bd..5f88904 100644 --- a/bin/varnishtest/vtc_server.c +++ b/bin/varnishtest/vtc_server.c @@ -221,7 +221,7 @@ cmd_server_genvcl(struct vsb *vsb) struct server *s; VTAILQ_FOREACH(s, &servers, list) { - vsb_printf(vsb, + VSB_printf(vsb, "backend %s { .host = \"%s\"; .port = \"%s\"; }\n", s->name, s->aaddr, s->aport); } diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c index d416a5b..52eafab 100644 --- a/bin/varnishtest/vtc_varnish.c +++ b/bin/varnishtest/vtc_varnish.c @@ -137,9 +137,9 @@ varnish_new(const char *name) bprintf(buf, "${tmpdir}/%s", name); vsb = macro_expand(v->vl, buf); AN(vsb); - v->workdir = strdup(vsb_data(vsb)); + v->workdir = strdup(VSB_data(vsb)); AN(v->workdir); - vsb_delete(vsb); + VSB_delete(vsb); bprintf(buf, "rm -rf %s ; mkdir -p %s ; echo ' %ld' > %s/_S", v->workdir, v->workdir, random(), v->workdir); @@ -151,11 +151,11 @@ varnish_new(const char *name) if (*v->name != 'v') vtc_log(v->vl, 0, "Varnish name must start with 'v'"); - v->args = vsb_new_auto(); + v->args = VSB_new_auto(); - v->storage = vsb_new_auto(); - vsb_printf(v->storage, "-sfile,%s,10M", v->workdir); - AZ(vsb_finish(v->storage)); + v->storage = VSB_new_auto(); + VSB_printf(v->storage, "-sfile,%s,10M", v->workdir); + AZ(VSB_finish(v->storage)); v->cli_fd = -1; VTAILQ_INSERT_TAIL(&varnishes, v, list); @@ -247,28 +247,28 @@ varnish_launch(struct varnish *v) v->cli_fd = VSS_listen(ap[0], 1); TCP_myname(v->cli_fd, abuf, sizeof abuf, pbuf, sizeof pbuf); - AZ(vsb_finish(v->args)); + AZ(VSB_finish(v->args)); vtc_log(v->vl, 2, "Launch"); - vsb = vsb_new_auto(); + vsb = VSB_new_auto(); AN(vsb); - vsb_printf(vsb, "cd ${topbuild}/bin/varnishd &&"); - vsb_printf(vsb, " ./varnishd -d -d -n %s", v->workdir); - vsb_printf(vsb, " -l 10m,1m,-"); - vsb_printf(vsb, " -p auto_restart=off"); - vsb_printf(vsb, " -p syslog_cli_traffic=off"); - vsb_printf(vsb, " -a '%s'", "127.0.0.1:0"); - vsb_printf(vsb, " -S %s/_S", v->workdir); - vsb_printf(vsb, " -M '%s %s'", abuf, pbuf); - vsb_printf(vsb, " -P %s/varnishd.pid", v->workdir); - vsb_printf(vsb, " %s", vsb_data(v->storage)); - vsb_printf(vsb, " %s", vsb_data(v->args)); - AZ(vsb_finish(vsb)); - vtc_log(v->vl, 3, "CMD: %s", vsb_data(vsb)); - vsb1 = macro_expand(v->vl, vsb_data(vsb)); + VSB_printf(vsb, "cd ${topbuild}/bin/varnishd &&"); + VSB_printf(vsb, " ./varnishd -d -d -n %s", v->workdir); + VSB_printf(vsb, " -l 10m,1m,-"); + VSB_printf(vsb, " -p auto_restart=off"); + VSB_printf(vsb, " -p syslog_cli_traffic=off"); + VSB_printf(vsb, " -a '%s'", "127.0.0.1:0"); + VSB_printf(vsb, " -S %s/_S", v->workdir); + VSB_printf(vsb, " -M '%s %s'", abuf, pbuf); + VSB_printf(vsb, " -P %s/varnishd.pid", v->workdir); + VSB_printf(vsb, " %s", VSB_data(v->storage)); + VSB_printf(vsb, " %s", VSB_data(v->args)); + AZ(VSB_finish(vsb)); + vtc_log(v->vl, 3, "CMD: %s", VSB_data(vsb)); + vsb1 = macro_expand(v->vl, VSB_data(vsb)); AN(vsb1); - vsb_delete(vsb); + VSB_delete(vsb); vsb = vsb1; - vtc_log(v->vl, 3, "CMD: %s", 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(); @@ -283,7 +283,7 @@ varnish_launch(struct varnish *v) AZ(close(v->fds[3])); for (i = 3; i vl, 3, "PID: %d", v->pid); @@ -292,7 +292,7 @@ varnish_launch(struct varnish *v) AZ(close(v->fds[3])); v->fds[0] = v->fds[2]; v->fds[2] = v->fds[3] = -1; - vsb_delete(vsb); + VSB_delete(vsb); AZ(pthread_create(&v->tp, NULL, varnish_thread, v)); /* Wait for the varnish to call home */ @@ -504,31 +504,31 @@ varnish_vcl(struct varnish *v, const char *vcl, enum cli_status_e expect) varnish_launch(v); if (vtc_error) return; - vsb = vsb_new_auto(); + vsb = VSB_new_auto(); AN(vsb); - vsb_printf(vsb, "vcl.inline vcl%d << %s\n%s\n%s\n", + VSB_printf(vsb, "vcl.inline vcl%d << %s\n%s\n%s\n", ++v->vcl_nbr, NONSENSE, vcl, NONSENSE); - AZ(vsb_finish(vsb)); + AZ(VSB_finish(vsb)); - u = varnish_ask_cli(v, vsb_data(vsb), NULL); + u = varnish_ask_cli(v, VSB_data(vsb), NULL); if (u != expect) { - vsb_delete(vsb); + VSB_delete(vsb); vtc_log(v->vl, 0, "VCL compilation got %u expected %u", u, expect); return; } if (u == CLIS_OK) { - vsb_clear(vsb); - vsb_printf(vsb, "vcl.use vcl%d", v->vcl_nbr); - AZ(vsb_finish(vsb)); - u = varnish_ask_cli(v, vsb_data(vsb), NULL); + VSB_clear(vsb); + VSB_printf(vsb, "vcl.use vcl%d", v->vcl_nbr); + AZ(VSB_finish(vsb)); + u = varnish_ask_cli(v, VSB_data(vsb), NULL); assert(u == CLIS_OK); } else { vtc_log(v->vl, 2, "VCL compilation failed (as expected)"); } - vsb_delete(vsb); + VSB_delete(vsb); } /********************************************************************** @@ -545,33 +545,33 @@ varnish_vclbackend(struct varnish *v, const char *vcl) varnish_launch(v); if (vtc_error) return; - vsb = vsb_new_auto(); + vsb = VSB_new_auto(); AN(vsb); - vsb2 = vsb_new_auto(); + vsb2 = VSB_new_auto(); AN(vsb2); cmd_server_genvcl(vsb2); - AZ(vsb_finish(vsb2)); + AZ(VSB_finish(vsb2)); - vsb_printf(vsb, "vcl.inline vcl%d << %s\n%s\n%s\n%s\n", - ++v->vcl_nbr, NONSENSE, vsb_data(vsb2), vcl, NONSENSE); - AZ(vsb_finish(vsb)); + VSB_printf(vsb, "vcl.inline vcl%d << %s\n%s\n%s\n%s\n", + ++v->vcl_nbr, NONSENSE, VSB_data(vsb2), vcl, NONSENSE); + AZ(VSB_finish(vsb)); - u = varnish_ask_cli(v, vsb_data(vsb), NULL); + u = varnish_ask_cli(v, VSB_data(vsb), NULL); if (u != CLIS_OK) { - vsb_delete(vsb); - vsb_delete(vsb2); + VSB_delete(vsb); + VSB_delete(vsb2); vtc_log(v->vl, 0, "FAIL VCL does not compile"); return; } - vsb_clear(vsb); - vsb_printf(vsb, "vcl.use vcl%d", v->vcl_nbr); - AZ(vsb_finish(vsb)); - u = varnish_ask_cli(v, vsb_data(vsb), NULL); + VSB_clear(vsb); + VSB_printf(vsb, "vcl.use vcl%d", v->vcl_nbr); + AZ(VSB_finish(vsb)); + u = varnish_ask_cli(v, VSB_data(vsb), NULL); assert(u == CLIS_OK); - vsb_delete(vsb); - vsb_delete(vsb2); + VSB_delete(vsb); + VSB_delete(vsb2); } /********************************************************************** @@ -700,17 +700,17 @@ cmd_varnish(CMD_ARGS) if (vtc_error) break; if (!strcmp(*av, "-storage")) { - vsb_clear(v->storage); - vsb_cat(v->storage, av[1]); - AZ(vsb_finish(v->storage)); + VSB_clear(v->storage); + VSB_cat(v->storage, av[1]); + AZ(VSB_finish(v->storage)); av++; continue; } if (!strcmp(*av, "-arg")) { AN(av[1]); AZ(v->pid); - vsb_cat(v->args, " "); - vsb_cat(v->args, av[1]); + VSB_cat(v->args, " "); + VSB_cat(v->args, av[1]); av++; continue; } diff --git a/include/vsb.h b/include/vsb.h index e363a1f..6544cbf 100644 --- a/include/vsb.h +++ b/include/vsb.h @@ -46,7 +46,7 @@ struct vsb { #define VSB_AUTOEXTEND 0x00000001 /* automatically extend buffer */ #define VSB_USRFLAGMSK 0x0000ffff /* mask of flags the user may specify */ #define VSB_DYNAMIC 0x00010000 /* s_buf must be freed */ -#define VSB_FINISHED 0x00020000 /* set by vsb_finish() */ +#define VSB_FINISHED 0x00020000 /* set by VSB_finish() */ #define VSB_DYNSTRUCT 0x00080000 /* vsb must be freed */ int s_flags; /* flags */ }; @@ -61,31 +61,31 @@ extern "C" { /* * API functions */ -struct vsb *vsb_new(struct vsb *, char *, int, int); -#define vsb_new_auto() \ - vsb_new(NULL, NULL, 0, VSB_AUTOEXTEND) -void vsb_clear(struct vsb *); -int vsb_setpos(struct vsb *, ssize_t); -int vsb_bcat(struct vsb *, const void *, size_t); -int vsb_bcpy(struct vsb *, const void *, size_t); -int vsb_cat(struct vsb *, const char *); -int vsb_cpy(struct vsb *, const char *); -int vsb_printf(struct vsb *, const char *, ...) +struct vsb *VSB_new(struct vsb *, char *, int, int); +#define VSB_new_auto() \ + VSB_new(NULL, NULL, 0, VSB_AUTOEXTEND) +void VSB_clear(struct vsb *); +int VSB_setpos(struct vsb *, ssize_t); +int VSB_bcat(struct vsb *, const void *, size_t); +int VSB_bcpy(struct vsb *, const void *, size_t); +int VSB_cat(struct vsb *, const char *); +int VSB_cpy(struct vsb *, const char *); +int VSB_printf(struct vsb *, const char *, ...) __printflike(2, 3); #ifdef va_start -int vsb_vprintf(struct vsb *, const char *, va_list) +int VSB_vprintf(struct vsb *, const char *, va_list) __printflike(2, 0); #endif -int vsb_putc(struct vsb *, int); -int vsb_trim(struct vsb *); -int vsb_error(const struct vsb *); -int vsb_finish(struct vsb *); -char *vsb_data(struct vsb *); -ssize_t vsb_len(struct vsb *); -int vsb_done(const struct vsb *); -void vsb_delete(struct vsb *); -void vsb_quote(struct vsb *s, const char *p, int len, int how); -const char *vsb_unquote(struct vsb *s, const char *p, int len, int how); +int VSB_putc(struct vsb *, int); +int VSB_trim(struct vsb *); +int VSB_error(const struct vsb *); +int VSB_finish(struct vsb *); +char *VSB_data(struct vsb *); +ssize_t VSB_len(struct vsb *); +int VSB_done(const struct vsb *); +void VSB_delete(struct vsb *); +void VSB_quote(struct vsb *s, const char *p, int len, int how); +const char *VSB_unquote(struct vsb *s, const char *p, int len, int how); #ifdef __cplusplus }; #endif diff --git a/lib/libvarnish/cli_common.c b/lib/libvarnish/cli_common.c index 4fa7429..ca47482 100644 --- a/lib/libvarnish/cli_common.c +++ b/lib/libvarnish/cli_common.c @@ -58,7 +58,7 @@ cli_out(struct cli *cli, const char *fmt, ...) va_start(ap, fmt); if (cli != NULL) - (void)vsb_vprintf(cli->sb, fmt, ap); + (void)VSB_vprintf(cli->sb, fmt, ap); else (void)vfprintf(stdout, fmt, ap); va_end(ap); @@ -69,7 +69,7 @@ void cli_quote(struct cli *cli, const char *s) { - vsb_quote(cli->sb, s, -1, 0); + VSB_quote(cli->sb, s, -1, 0); } void @@ -97,14 +97,14 @@ cli_writeres(int fd, const struct cli *cli) assert(cli->result <= 999); /*lint !e650 const out of range */ i = snprintf(res, sizeof res, - "%-3d %-8ld\n", cli->result, (long)vsb_len(cli->sb)); + "%-3d %-8ld\n", cli->result, (long)VSB_len(cli->sb)); assert(i == CLI_LINE0_LEN); iov[0].iov_base = res; iov[0].iov_len = CLI_LINE0_LEN; - iov[1].iov_base = vsb_data(cli->sb); - iov[1].iov_len = vsb_len(cli->sb); + iov[1].iov_base = VSB_data(cli->sb); + iov[1].iov_len = VSB_len(cli->sb); iov[2].iov_base = nl; iov[2].iov_len = 1; diff --git a/lib/libvarnish/cli_serve.c b/lib/libvarnish/cli_serve.c index 6306dff..c464de1 100644 --- a/lib/libvarnish/cli_serve.c +++ b/lib/libvarnish/cli_serve.c @@ -224,7 +224,7 @@ cls_dispatch(struct cli *cli, struct cli_proto *clp, char * const * av, } cli->result = CLIS_OK; - vsb_clear(cli->sb); + VSB_clear(cli->sb); cp->func(cli, (const char * const *)av, cp->priv); return (1); } @@ -253,7 +253,7 @@ cls_vlu2(void *priv, char * const *av) cli->cls = cs; cli->result = CLIS_UNKNOWN; - vsb_clear(cli->sb); + VSB_clear(cli->sb); cli_out(cli, "Unknown request.\nType 'help' for more info.\n"); if (cs->before != NULL) @@ -286,7 +286,7 @@ cls_vlu2(void *priv, char * const *av) } } while (0); - AZ(vsb_finish(cli->sb)); + AZ(VSB_finish(cli->sb)); if (cs->after != NULL) cs->after(cli); @@ -343,7 +343,7 @@ cls_vlu(void *priv, const char *p) } cfd->argv = av; cfd->last_idx = i - 2; - cfd->last_arg = vsb_new_auto(); + cfd->last_arg = VSB_new_auto(); AN(cfd->last_arg); return (0); } else { @@ -351,23 +351,23 @@ cls_vlu(void *priv, const char *p) assert(!strcmp(cfd->argv[cfd->last_idx], "<<")); AN(cfd->argv[cfd->last_idx + 1]); if (strcmp(p, cfd->argv[cfd->last_idx + 1])) { - vsb_cat(cfd->last_arg, p); - vsb_cat(cfd->last_arg, "\n"); + VSB_cat(cfd->last_arg, p); + VSB_cat(cfd->last_arg, "\n"); return (0); } - AZ(vsb_finish(cfd->last_arg)); + AZ(VSB_finish(cfd->last_arg)); free(cfd->argv[cfd->last_idx]); cfd->argv[cfd->last_idx] = NULL; free(cfd->argv[cfd->last_idx + 1]); cfd->argv[cfd->last_idx + 1] = NULL; - cfd->argv[cfd->last_idx] = vsb_data(cfd->last_arg); + cfd->argv[cfd->last_idx] = VSB_data(cfd->last_arg); i = cls_vlu2(priv, cfd->argv); cfd->argv[cfd->last_idx] = NULL; FreeArgv(cfd->argv); cfd->argv = NULL; free(cli->cmd); cli->cmd = NULL; - vsb_delete(cfd->last_arg); + VSB_delete(cfd->last_arg); cfd->last_arg = NULL; cfd->last_idx = 0; return (i); @@ -405,7 +405,7 @@ CLS_AddFd(struct cls *cs, int fdi, int fdo, cls_cb_f *closefunc, void *priv) cfd->cli = &cfd->clis; cfd->cli->magic = CLI_MAGIC; cfd->cli->vlu = VLU_New(cfd, cls_vlu, cs->maxlen); - cfd->cli->sb = vsb_new_auto(); + cfd->cli->sb = VSB_new_auto(); cfd->closefunc = closefunc; cfd->priv = priv; AN(cfd->cli->sb); @@ -424,7 +424,7 @@ cls_close_fd(struct cls *cs, struct cls_fd *cfd) VTAILQ_REMOVE(&cs->fds, cfd, list); cs->nfd--; VLU_Destroy(cfd->cli->vlu); - vsb_delete(cfd->cli->sb); + VSB_delete(cfd->cli->sb); if (cfd->closefunc == NULL) { (void)close(cfd->fdi); if (cfd->fdo != cfd->fdi) diff --git a/lib/libvarnish/subproc.c b/lib/libvarnish/subproc.c index 677405e..e2b4264 100644 --- a/lib/libvarnish/subproc.c +++ b/lib/libvarnish/subproc.c @@ -56,9 +56,9 @@ sub_vlu(void *priv, const char *str) sp = priv; if (!sp->lines++) - vsb_printf(sp->sb, "Message from %s:\n", sp->name); + VSB_printf(sp->sb, "Message from %s:\n", sp->name); if (sp->maxlines < 0 || sp->lines <= sp->maxlines) - vsb_printf(sp->sb, "%s\n", str); + VSB_printf(sp->sb, "%s\n", str); return (0); } @@ -77,14 +77,14 @@ SUB_run(struct vsb *sb, sub_func_f *func, void *priv, const char *name, sp.maxlines = maxlines; if (pipe(p) < 0) { - vsb_printf(sb, "Starting %s: pipe() failed: %s", + VSB_printf(sb, "Starting %s: pipe() failed: %s", name, strerror(errno)); return (-1); } assert(p[0] > STDERR_FILENO); assert(p[1] > STDERR_FILENO); if ((pid = fork()) < 0) { - vsb_printf(sb, "Starting %s: fork() failed: %s", + VSB_printf(sb, "Starting %s: fork() failed: %s", name, strerror(errno)); AZ(close(p[0])); AZ(close(p[1])); @@ -108,25 +108,25 @@ SUB_run(struct vsb *sb, sub_func_f *func, void *priv, const char *name, AZ(close(p[0])); VLU_Destroy(vlu); if (sp.maxlines >= 0 && sp.lines > sp.maxlines) - vsb_printf(sb, "[%d lines truncated]\n", + VSB_printf(sb, "[%d lines truncated]\n", sp.lines - sp.maxlines); do { rv = waitpid(pid, &status, 0); if (rv < 0 && errno != EINTR) { - vsb_printf(sb, "Running %s: waitpid() failed: %s\n", + VSB_printf(sb, "Running %s: waitpid() failed: %s\n", name, strerror(errno)); return (-1); } } while (rv < 0); if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) { - vsb_printf(sb, "Running %s failed", name); + VSB_printf(sb, "Running %s failed", name); if (WIFEXITED(status)) - vsb_printf(sb, ", exit %d", WEXITSTATUS(status)); + VSB_printf(sb, ", exit %d", WEXITSTATUS(status)); if (WIFSIGNALED(status)) - vsb_printf(sb, ", signal %d", WTERMSIG(status)); + VSB_printf(sb, ", signal %d", WTERMSIG(status)); if (WCOREDUMP(status)) - vsb_printf(sb, ", core dumped"); - vsb_printf(sb, "\n"); + VSB_printf(sb, ", core dumped"); + VSB_printf(sb, "\n"); return (-1); } return (0); diff --git a/lib/libvarnish/vsb.c b/lib/libvarnish/vsb.c index 1806416..75414f7 100644 --- a/lib/libvarnish/vsb.c +++ b/lib/libvarnish/vsb.c @@ -76,7 +76,7 @@ __FBSDID("$FreeBSD: head/sys/kern/subr_vsb.c 222004 2011-05-17 06:36:32Z phk $") */ #if !defined(NDEBUG) static void -_assert_vsb_integrity(const char *fun, struct vsb *s) +_assert_VSB_integrity(const char *fun, struct vsb *s) { (void)fun; @@ -92,7 +92,7 @@ _assert_vsb_integrity(const char *fun, struct vsb *s) } static void -_assert_vsb_state(const char *fun, struct vsb *s, int state) +_assert_VSB_state(const char *fun, struct vsb *s, int state) { (void)fun; @@ -102,11 +102,11 @@ _assert_vsb_state(const char *fun, struct vsb *s, int state) ("%s called with %sfinished or corrupt vsb", fun, (state ? "un" : ""))); } -#define assert_vsb_integrity(s) _assert_vsb_integrity(__func__, (s)) -#define assert_vsb_state(s, i) _assert_vsb_state(__func__, (s), (i)) +#define assert_VSB_integrity(s) _assert_VSB_integrity(__func__, (s)) +#define assert_VSB_state(s, i) _assert_VSB_state(__func__, (s), (i)) #else -#define assert_vsb_integrity(s) do { } while (0) -#define assert_vsb_state(s, i) do { } while (0) +#define assert_VSB_integrity(s) do { } while (0) +#define assert_VSB_state(s, i) do { } while (0) #endif #ifdef CTASSERT @@ -116,7 +116,7 @@ CTASSERT(powerof2(VSB_MAXEXTENDINCR)); static int -vsb_extendsize(int size) +VSB_extendsize(int size) { int newsize; @@ -135,14 +135,14 @@ vsb_extendsize(int size) * Extend an vsb. */ static int -vsb_extend(struct vsb *s, int addlen) +VSB_extend(struct vsb *s, int addlen) { char *newbuf; int newsize; if (!VSB_CANEXTEND(s)) return (-1); - newsize = vsb_extendsize(s->s_size + addlen); + newsize = VSB_extendsize(s->s_size + addlen); newbuf = SBMALLOC(newsize); if (newbuf == NULL) return (-1); @@ -162,7 +162,7 @@ vsb_extend(struct vsb *s, int addlen) * big enough to hold at least length characters. */ static struct vsb * -vsb_newbuf(struct vsb *s, char *buf, int length, int flags) +VSB_newbuf(struct vsb *s, char *buf, int length, int flags) { memset(s, 0, sizeof(*s)); @@ -180,7 +180,7 @@ vsb_newbuf(struct vsb *s, char *buf, int length, int flags) return (s); if ((flags & VSB_AUTOEXTEND) != 0) - s->s_size = vsb_extendsize(s->s_size); + s->s_size = VSB_extendsize(s->s_size); s->s_buf = SBMALLOC(s->s_size); if (s->s_buf == NULL) @@ -195,7 +195,7 @@ vsb_newbuf(struct vsb *s, char *buf, int length, int flags) * big enough to hold at least length characters. */ struct vsb * -vsb_new(struct vsb *s, char *buf, int length, int flags) +VSB_new(struct vsb *s, char *buf, int length, int flags) { KASSERT(length >= 0, @@ -205,12 +205,12 @@ vsb_new(struct vsb *s, char *buf, int length, int flags) flags &= VSB_USRFLAGMSK; if (s != NULL) - return (vsb_newbuf(s, buf, length, flags)); + return (VSB_newbuf(s, buf, length, flags)); s = SBMALLOC(sizeof(*s)); if (s == NULL) return (NULL); - if (vsb_newbuf(s, buf, length, flags) == NULL) { + if (VSB_newbuf(s, buf, length, flags) == NULL) { SBFREE(s); return (NULL); } @@ -222,10 +222,10 @@ vsb_new(struct vsb *s, char *buf, int length, int flags) * Clear an vsb and reset its position. */ void -vsb_clear(struct vsb *s) +VSB_clear(struct vsb *s) { - assert_vsb_integrity(s); + assert_VSB_integrity(s); /* don't care if it's finished or not */ VSB_CLEARFLAG(s, VSB_FINISHED); @@ -238,11 +238,11 @@ vsb_clear(struct vsb *s) * Effectively truncates the vsb at the new position. */ int -vsb_setpos(struct vsb *s, ssize_t pos) +VSB_setpos(struct vsb *s, ssize_t pos) { - assert_vsb_integrity(s); - assert_vsb_state(s, 0); + assert_VSB_integrity(s); + assert_VSB_state(s, 0); KASSERT(pos >= 0, ("attempt to seek to a negative position (%jd)", (intmax_t)pos)); @@ -262,16 +262,16 @@ vsb_setpos(struct vsb *s, ssize_t pos) * buffer and marking overflow. */ static void -vsb_put_byte(struct vsb *s, int c) +VSB_put_byte(struct vsb *s, int c) { - assert_vsb_integrity(s); - assert_vsb_state(s, 0); + assert_VSB_integrity(s); + assert_VSB_state(s, 0); if (s->s_error != 0) return; if (VSB_FREESPACE(s) <= 0) { - if (vsb_extend(s, 1) < 0) + if (VSB_extend(s, 1) < 0) s->s_error = ENOMEM; if (s->s_error != 0) return; @@ -283,18 +283,18 @@ vsb_put_byte(struct vsb *s, int c) * Append a byte string to an vsb. */ int -vsb_bcat(struct vsb *s, const void *buf, size_t len) +VSB_bcat(struct vsb *s, const void *buf, size_t len) { const char *str = buf; const char *end = str + len; - assert_vsb_integrity(s); - assert_vsb_state(s, 0); + assert_VSB_integrity(s); + assert_VSB_state(s, 0); if (s->s_error != 0) return (-1); for (; str < end; str++) { - vsb_put_byte(s, *str); + VSB_put_byte(s, *str); if (s->s_error != 0) return (-1); } @@ -305,31 +305,31 @@ vsb_bcat(struct vsb *s, const void *buf, size_t len) * Copy a byte string into an vsb. */ int -vsb_bcpy(struct vsb *s, const void *buf, size_t len) +VSB_bcpy(struct vsb *s, const void *buf, size_t len) { - assert_vsb_integrity(s); - assert_vsb_state(s, 0); + assert_VSB_integrity(s); + assert_VSB_state(s, 0); - vsb_clear(s); - return (vsb_bcat(s, buf, len)); + VSB_clear(s); + return (VSB_bcat(s, buf, len)); } /* * Append a string to an vsb. */ int -vsb_cat(struct vsb *s, const char *str) +VSB_cat(struct vsb *s, const char *str) { - assert_vsb_integrity(s); - assert_vsb_state(s, 0); + assert_VSB_integrity(s); + assert_VSB_state(s, 0); if (s->s_error != 0) return (-1); while (*str != '\0') { - vsb_put_byte(s, *str++); + VSB_put_byte(s, *str++); if (s->s_error != 0) return (-1); } @@ -340,27 +340,27 @@ vsb_cat(struct vsb *s, const char *str) * Copy a string into an vsb. */ int -vsb_cpy(struct vsb *s, const char *str) +VSB_cpy(struct vsb *s, const char *str) { - assert_vsb_integrity(s); - assert_vsb_state(s, 0); + assert_VSB_integrity(s); + assert_VSB_state(s, 0); - vsb_clear(s); - return (vsb_cat(s, str)); + VSB_clear(s); + return (VSB_cat(s, str)); } /* * Format the given argument list and append the resulting string to an vsb. */ int -vsb_vprintf(struct vsb *s, const char *fmt, va_list ap) +VSB_vprintf(struct vsb *s, const char *fmt, va_list ap) { va_list ap_copy; int len; - assert_vsb_integrity(s); - assert_vsb_state(s, 0); + assert_VSB_integrity(s); + assert_VSB_state(s, 0); KASSERT(fmt != NULL, ("%s called with a NULL format string", __func__)); @@ -371,12 +371,12 @@ vsb_vprintf(struct vsb *s, const char *fmt, va_list ap) /* * For the moment, there is no way to get vsnprintf(3) to hand * back a character at a time, to push everything into - * vsb_putc_func() as was done for the kernel. + * VSB_putc_func() as was done for the kernel. * * In userspace, while drains are useful, there's generally * not a problem attempting to malloc(3) on out of space. So * expand a userland vsb if there is not enough room for the - * data produced by vsb_[v]printf(3). + * data produced by VSB_[v]printf(3). */ do { @@ -385,7 +385,7 @@ vsb_vprintf(struct vsb *s, const char *fmt, va_list ap) fmt, ap_copy); va_end(ap_copy); } while (len > VSB_FREESPACE(s) && - vsb_extend(s, len - VSB_FREESPACE(s)) == 0); + VSB_extend(s, len - VSB_FREESPACE(s)) == 0); /* * s->s_len is the length of the string, without the terminating nul. @@ -414,13 +414,13 @@ vsb_vprintf(struct vsb *s, const char *fmt, va_list ap) * Format the given arguments and append the resulting string to an vsb. */ int -vsb_printf(struct vsb *s, const char *fmt, ...) +VSB_printf(struct vsb *s, const char *fmt, ...) { va_list ap; int result; va_start(ap, fmt); - result = vsb_vprintf(s, fmt, ap); + result = VSB_vprintf(s, fmt, ap); va_end(ap); return (result); } @@ -429,10 +429,10 @@ vsb_printf(struct vsb *s, const char *fmt, ...) * Append a character to an vsb. */ int -vsb_putc(struct vsb *s, int c) +VSB_putc(struct vsb *s, int c) { - vsb_put_byte(s, c); + VSB_put_byte(s, c); if (s->s_error != 0) return (-1); return (0); @@ -442,11 +442,11 @@ vsb_putc(struct vsb *s, int c) * Trim whitespace characters from end of an vsb. */ int -vsb_trim(struct vsb *s) +VSB_trim(struct vsb *s) { - assert_vsb_integrity(s); - assert_vsb_state(s, 0); + assert_VSB_integrity(s); + assert_VSB_state(s, 0); if (s->s_error != 0) return (-1); @@ -461,7 +461,7 @@ vsb_trim(struct vsb *s) * Check if an vsb has an error. */ int -vsb_error(const struct vsb *s) +VSB_error(const struct vsb *s) { return (s->s_error); @@ -471,11 +471,11 @@ vsb_error(const struct vsb *s) * Finish off an vsb. */ int -vsb_finish(struct vsb *s) +VSB_finish(struct vsb *s) { - assert_vsb_integrity(s); - assert_vsb_state(s, 0); + assert_VSB_integrity(s); + assert_VSB_state(s, 0); s->s_buf[s->s_len] = '\0'; VSB_SETFLAG(s, VSB_FINISHED); @@ -489,11 +489,11 @@ vsb_finish(struct vsb *s) * Return a pointer to the vsb data. */ char * -vsb_data(struct vsb *s) +VSB_data(struct vsb *s) { - assert_vsb_integrity(s); - assert_vsb_state(s, VSB_FINISHED); + assert_VSB_integrity(s); + assert_VSB_state(s, VSB_FINISHED); return (s->s_buf); } @@ -502,10 +502,10 @@ vsb_data(struct vsb *s) * Return the length of the vsb data. */ ssize_t -vsb_len(struct vsb *s) +VSB_len(struct vsb *s) { - assert_vsb_integrity(s); + assert_VSB_integrity(s); /* don't care if it's finished or not */ if (s->s_error != 0) @@ -517,11 +517,11 @@ vsb_len(struct vsb *s) * Clear an vsb, free its buffer if necessary. */ void -vsb_delete(struct vsb *s) +VSB_delete(struct vsb *s) { int isdyn; - assert_vsb_integrity(s); + assert_VSB_integrity(s); /* don't care if it's finished or not */ if (VSB_ISDYNAMIC(s)) @@ -536,7 +536,7 @@ vsb_delete(struct vsb *s) * Check if an vsb has been finished. */ int -vsb_done(const struct vsb *s) +VSB_done(const struct vsb *s) { return(VSB_ISFINISHED(s)); @@ -546,7 +546,7 @@ vsb_done(const struct vsb *s) * Quote a string */ void -vsb_quote(struct vsb *s, const char *p, int len, int how) +VSB_quote(struct vsb *s, const char *p, int len, int how) { const char *q; int quote = 0; @@ -562,45 +562,45 @@ vsb_quote(struct vsb *s, const char *p, int len, int how) } } if (!quote) { - (void)vsb_bcat(s, p, len); + (void)VSB_bcat(s, p, len); return; } - (void)vsb_putc(s, '"'); + (void)VSB_putc(s, '"'); for (q = p; q < p + len; q++) { switch (*q) { case ' ': - (void)vsb_putc(s, *q); + (void)VSB_putc(s, *q); break; case '\\': case '"': - (void)vsb_putc(s, '\\'); - (void)vsb_putc(s, *q); + (void)VSB_putc(s, '\\'); + (void)VSB_putc(s, *q); break; case '\n': - (void)vsb_cat(s, "\\n"); + (void)VSB_cat(s, "\\n"); break; case '\r': - (void)vsb_cat(s, "\\r"); + (void)VSB_cat(s, "\\r"); break; case '\t': - (void)vsb_cat(s, "\\t"); + (void)VSB_cat(s, "\\t"); break; default: if (isgraph(*q)) - (void)vsb_putc(s, *q); + (void)VSB_putc(s, *q); else - (void)vsb_printf(s, "\\%o", *q & 0xff); + (void)VSB_printf(s, "\\%o", *q & 0xff); break; } } - (void)vsb_putc(s, '"'); + (void)VSB_putc(s, '"'); } /* * Unquote a string */ const char * -vsb_unquote(struct vsb *s, const char *p, int len, int how) +VSB_unquote(struct vsb *s, const char *p, int len, int how) { const char *q; char *r; @@ -614,7 +614,7 @@ vsb_unquote(struct vsb *s, const char *p, int len, int how) for (q = p; q < p + len; q++) { if (*q != '\\') { - (void)vsb_bcat(s, q, 1); + (void)VSB_bcat(s, q, 1); continue; } if (++q >= p + len) @@ -622,13 +622,13 @@ vsb_unquote(struct vsb *s, const char *p, int len, int how) switch(*q) { case 'n': - (void)vsb_bcat(s, "\n", 1); + (void)VSB_bcat(s, "\n", 1); continue; case 'r': - (void)vsb_bcat(s, "\r", 1); + (void)VSB_bcat(s, "\r", 1); continue; case 't': - (void)vsb_bcat(s, "\t", 1); + (void)VSB_bcat(s, "\t", 1); continue; case '0': case '1': @@ -643,11 +643,11 @@ vsb_unquote(struct vsb *s, const char *p, int len, int how) if (errno != 0 || (u & ~0xff)) return ("\\ooo sequence out of range"); c = (char)u; - (void)vsb_bcat(s, &c, 1); + (void)VSB_bcat(s, &c, 1); q = r - 1; continue; default: - (void)vsb_bcat(s, q, 1); + (void)VSB_bcat(s, q, 1); } } return (NULL); diff --git a/lib/libvcl/generate.py b/lib/libvcl/generate.py index 15c1a51..cb9ac40 100755 --- a/lib/libvcl/generate.py +++ b/lib/libvcl/generate.py @@ -564,7 +564,7 @@ def emit_vcl_tnames(fo, tokens): fo.write("};\n") ####################################################################### -# Read a C-source file and spit out code that outputs it with vsb_cat() +# Read a C-source file and spit out code that outputs it with VSB_cat() def emit_file(fo, fn): fi = open(fn) @@ -579,7 +579,7 @@ def emit_file(fo, fn): fo.write("\n\t/* %s */\n\n" % fn) for c in fc: if l == 0: - fo.write("\tvsb_cat(sb, \"") + fo.write("\tVSB_cat(sb, \"") l += 12 x += 12 if x == 0: diff --git a/lib/libvcl/vcc_acl.c b/lib/libvcl/vcc_acl.c index e344d3d..9a0d52c 100644 --- a/lib/libvcl/vcc_acl.c +++ b/lib/libvcl/vcc_acl.c @@ -101,13 +101,13 @@ vcc_acl_add_entry(struct vcc *tl, const struct acl_e *ae, int l, int i; if (fam == PF_INET && ae->mask > 32) { - vsb_printf(tl->sb, + VSB_printf(tl->sb, "Too wide mask (%u) for IPv4 address", ae->mask); vcc_ErrWhere(tl, ae->t_mask); return; } if (fam == PF_INET6 && ae->mask > 128) { - vsb_printf(tl->sb, + VSB_printf(tl->sb, "Too wide mask (%u) for IPv6 address", ae->mask); vcc_ErrWhere(tl, ae->t_mask); return; @@ -134,9 +134,9 @@ vcc_acl_add_entry(struct vcc *tl, const struct acl_e *ae, int l, */ if (aen->not == ae2->not) return; - vsb_printf(tl->sb, "Conflicting ACL entries:\n"); + VSB_printf(tl->sb, "Conflicting ACL entries:\n"); vcc_ErrWhere(tl, ae2->t_addr); - vsb_printf(tl->sb, "vs:\n"); + VSB_printf(tl->sb, "vs:\n"); vcc_ErrWhere(tl, aen->t_addr); return; } @@ -173,7 +173,7 @@ vcc_acl_try_getaddrinfo(struct vcc *tl, struct acl_e *ae) error = getaddrinfo(ae->t_addr->dec, "0", &hint, &res0); if (error) { if (ae->para) { - vsb_printf(tl->sb, + VSB_printf(tl->sb, "Warning: %s ignored\n -- %s\n", ae->t_addr->dec, gai_strerror(error)); Fh(tl, 1, "/* Ignored ACL entry: %s%s", @@ -185,7 +185,7 @@ vcc_acl_try_getaddrinfo(struct vcc *tl, struct acl_e *ae) Fh(tl, 1, " * getaddrinfo: %s */\n", gai_strerror(error)); } else { - vsb_printf(tl->sb, + VSB_printf(tl->sb, "DNS lookup(%s): %s\n", ae->t_addr->dec, gai_strerror(error)); vcc_ErrWhere(tl, ae->t_addr); @@ -217,7 +217,7 @@ vcc_acl_try_getaddrinfo(struct vcc *tl, struct acl_e *ae) vcc_acl_add_entry(tl, ae, 16, u, res->ai_family); break; default: - vsb_printf(tl->sb, + VSB_printf(tl->sb, "Ignoring unknown protocol family (%d) for %.*s\n", res->ai_family, PF(ae->t_addr)); continue; @@ -227,7 +227,7 @@ vcc_acl_try_getaddrinfo(struct vcc *tl, struct acl_e *ae) freeaddrinfo(res0); if (ae->t_mask != NULL && i4 > 0 && i6 > 0) { - vsb_printf(tl->sb, + VSB_printf(tl->sb, "Mask (%u) specified, but string resolves to" " both IPv4 and IPv6 addresses.\n", ae->mask); vcc_ErrWhere(tl, ae->t_mask); @@ -477,7 +477,7 @@ vcc_Acl(struct vcc *tl) i = vcc_AddDef(tl, an, SYM_ACL); if (i > 1) { - vsb_printf(tl->sb, "ACL %.*s redefined\n", PF(an)); + VSB_printf(tl->sb, "ACL %.*s redefined\n", PF(an)); vcc_ErrWhere(tl, an); return; } diff --git a/lib/libvcl/vcc_action.c b/lib/libvcl/vcc_action.c index f90c3b9..c29a749 100644 --- a/lib/libvcl/vcc_action.c +++ b/lib/libvcl/vcc_action.c @@ -164,7 +164,7 @@ parse_unset(struct vcc *tl) ERRCHK(tl); assert(vp != NULL); if (vp->fmt != STRING || vp->http == NULL) { - vsb_printf(tl->sb, + VSB_printf(tl->sb, "Only http header variables can be unset.\n"); vcc_ErrWhere(tl, tl->t); return; @@ -218,7 +218,7 @@ static void parse_new_syntax(struct vcc *tl) { - vsb_printf(tl->sb, "Please change \"%.*s\" to \"return(%.*s)\".\n", + VSB_printf(tl->sb, "Please change \"%.*s\" to \"return(%.*s)\".\n", PF(tl->t), PF(tl->t)); vcc_ErrWhere(tl, tl->t); } @@ -274,7 +274,7 @@ parse_return(struct vcc *tl) #include "vcl_returns.h" #undef VCL_RET_MAC if (!retval) { - vsb_printf(tl->sb, "Expected return action name.\n"); + VSB_printf(tl->sb, "Expected return action name.\n"); vcc_ErrWhere(tl, tl->t); ERRCHK(tl); } diff --git a/lib/libvcl/vcc_backend.c b/lib/libvcl/vcc_backend.c index ab102bb..6b2b932 100644 --- a/lib/libvcl/vcc_backend.c +++ b/lib/libvcl/vcc_backend.c @@ -123,7 +123,7 @@ Emit_Sockaddr(struct vcc *tl, const struct token *t_host, const char *port) hint.ai_socktype = SOCK_STREAM; if (VSS_parse(t_host->dec, &hop, &pop)) { - vsb_printf(tl->sb, + VSB_printf(tl->sb, "Backend host '%.*s': wrong syntax (unbalanced [...] ?)\n", PF(t_host) ); vcc_ErrWhere(tl, t_host); @@ -136,10 +136,10 @@ Emit_Sockaddr(struct vcc *tl, const struct token *t_host, const char *port) free(hop); free(pop); if (error) { - vsb_printf(tl->sb, + VSB_printf(tl->sb, "Backend host '%.*s'" " could not be resolved to an IP address:\n", PF(t_host)); - vsb_printf(tl->sb, + VSB_printf(tl->sb, "\t%s\n" "(Sorry if that error message is gibberish.)\n", gai_strerror(error)); @@ -166,7 +166,7 @@ Emit_Sockaddr(struct vcc *tl, const struct token *t_host, const char *port) continue; if (multiple != NULL) { - vsb_printf(tl->sb, + VSB_printf(tl->sb, "Backend host %.*s: resolves to " "multiple %s addresses.\n" "Only one address is allowed.\n" @@ -178,7 +178,7 @@ Emit_Sockaddr(struct vcc *tl, const struct token *t_host, const char *port) res1->ai_addrlen, hbuf, sizeof hbuf, NULL, 0, NI_NUMERICHOST); AZ(error); - vsb_printf(tl->sb, "\t%s\n", hbuf); + VSB_printf(tl->sb, "\t%s\n", hbuf); } vcc_ErrWhere(tl, t_host); return; @@ -202,7 +202,7 @@ Emit_Sockaddr(struct vcc *tl, const struct token *t_host, const char *port) } freeaddrinfo(res0); if (retval == 0) { - vsb_printf(tl->sb, + VSB_printf(tl->sb, "Backend host '%.*s': resolves to " "neither IPv4 nor IPv6 addresses.\n", PF(t_host) ); @@ -226,26 +226,26 @@ vcc_EmitBeIdent(const struct vcc *tl, struct vsb *v, { assert(first != last); - vsb_printf(v, "\t.ident ="); + VSB_printf(v, "\t.ident ="); if (serial >= 0) { - vsb_printf(v, "\n\t \"%.*s %.*s [%d] \"", + VSB_printf(v, "\n\t \"%.*s %.*s [%d] \"", PF(tl->t_policy), PF(tl->t_dir), serial); } else { - vsb_printf(v, "\n\t \"%.*s %.*s \"", + VSB_printf(v, "\n\t \"%.*s %.*s \"", PF(tl->t_policy), PF(tl->t_dir)); } while (1) { if (first->dec != NULL) - vsb_printf(v, "\n\t \"\\\"\" %.*s \"\\\" \"", + VSB_printf(v, "\n\t \"\\\"\" %.*s \"\\\" \"", PF(first)); else - vsb_printf(v, "\n\t \"%.*s \"", PF(first)); + VSB_printf(v, "\n\t \"%.*s \"", PF(first)); if (first == last) break; first = VTAILQ_NEXT(first, list); AN(first); } - vsb_printf(v, ",\n"); + VSB_printf(v, ",\n"); } /*-------------------------------------------------------------------- @@ -259,9 +259,9 @@ vcc_ProbeRedef(struct vcc *tl, struct token **t_did, /* .url and .request are mutually exclusive */ if (*t_did != NULL) { - vsb_printf(tl->sb, "Probe request redefinition at:\n"); + VSB_printf(tl->sb, "Probe request redefinition at:\n"); vcc_ErrWhere(tl, t_field); - vsb_printf(tl->sb, "Previous definition:\n"); + VSB_printf(tl->sb, "Previous definition:\n"); vcc_ErrWhere(tl, *t_did); return; } @@ -342,7 +342,7 @@ vcc_ParseProbeSpec(struct vcc *tl) } else if (vcc_IdIs(t_field, "expected_response")) { status = vcc_UintVal(tl); if (status < 100 || status > 999) { - vsb_printf(tl->sb, + VSB_printf(tl->sb, "Must specify .status with exactly three " " digits (100 <= x <= 999)\n"); vcc_ErrWhere(tl, tl->t); @@ -365,13 +365,13 @@ vcc_ParseProbeSpec(struct vcc *tl) if (t_threshold != NULL || t_window != NULL) { if (t_threshold == NULL && t_window != NULL) { - vsb_printf(tl->sb, + VSB_printf(tl->sb, "Must specify .threshold with .window\n"); vcc_ErrWhere(tl, t_window); return; } else if (t_threshold != NULL && t_window == NULL) { if (threshold > 64) { - vsb_printf(tl->sb, + VSB_printf(tl->sb, "Threshold must be 64 or less.\n"); vcc_ErrWhere(tl, t_threshold); return; @@ -379,12 +379,12 @@ vcc_ParseProbeSpec(struct vcc *tl) window = threshold + 1; } else if (window > 64) { AN(t_window); - vsb_printf(tl->sb, "Window must be 64 or less.\n"); + VSB_printf(tl->sb, "Window must be 64 or less.\n"); vcc_ErrWhere(tl, t_window); return; } if (threshold > window ) { - vsb_printf(tl->sb, + VSB_printf(tl->sb, "Threshold can not be greater than window.\n"); AN(t_threshold); vcc_ErrWhere(tl, t_threshold); @@ -422,7 +422,7 @@ vcc_ParseProbe(struct vcc *tl) vcc_NextToken(tl); i = vcc_AddDef(tl, t_probe, SYM_PROBE); if (i > 1) { - vsb_printf(tl->sb, "Probe %.*s redefined\n", PF(t_probe)); + VSB_printf(tl->sb, "Probe %.*s redefined\n", PF(t_probe)); vcc_ErrWhere(tl, t_probe); } @@ -466,7 +466,7 @@ vcc_ParseHostDef(struct vcc *tl, int serial, const char *vgcname) SkipToken(tl, '{'); - vsb = vsb_new_auto(); + vsb = VSB_new_auto(); AN(vsb); tl->fb = vsb; @@ -480,12 +480,12 @@ vcc_ParseHostDef(struct vcc *tl, int serial, const char *vgcname) /* Check for old syntax */ if (tl->t->tok == ID && vcc_IdIs(tl->t, "set")) { - vsb_printf(tl->sb, + VSB_printf(tl->sb, "NB: Backend Syntax has changed:\n" "Remove \"set\" and \"backend\" in front" " of backend fields.\n" ); vcc_ErrToken(tl, tl->t); - vsb_printf(tl->sb, " at "); + VSB_printf(tl->sb, " at "); vcc_ErrWhere(tl, tl->t); return; } @@ -541,10 +541,10 @@ vcc_ParseHostDef(struct vcc *tl, int serial, const char *vgcname) * not allowed here. */ if (u == UINT_MAX) { - vsb_printf(tl->sb, + VSB_printf(tl->sb, "Value outside allowed range: "); vcc_ErrToken(tl, tl->t); - vsb_printf(tl->sb, " at\n"); + VSB_printf(tl->sb, " at\n"); vcc_ErrWhere(tl, tl->t); } ERRCHK(tl); @@ -560,10 +560,10 @@ vcc_ParseHostDef(struct vcc *tl, int serial, const char *vgcname) vcc_NextToken(tl); SkipToken(tl, ';'); } else if (vcc_IdIs(t_field, "probe")) { - vsb_printf(tl->sb, + VSB_printf(tl->sb, "Expected '{' or name of probe."); vcc_ErrToken(tl, tl->t); - vsb_printf(tl->sb, " at\n"); + VSB_printf(tl->sb, " at\n"); vcc_ErrWhere(tl, tl->t); return; } else { @@ -604,9 +604,9 @@ vcc_ParseHostDef(struct vcc *tl, int serial, const char *vgcname) vcc_NextToken(tl); tl->fb = NULL; - AZ(vsb_finish(vsb)); - Fh(tl, 0, "%s", vsb_data(vsb)); - vsb_delete(vsb); + AZ(VSB_finish(vsb)); + Fh(tl, 0, "%s", VSB_data(vsb)); + VSB_delete(vsb); Fi(tl, 0, "\tVRT_init_dir(cli, VCL_conf.director, \"simple\",\n" "\t VGC_backend_%s, &vgc_dir_priv_%s);\n", vgcname, vgcname); @@ -641,9 +641,9 @@ vcc_ParseBackendHost(struct vcc *tl, int serial, char **nm) break; } if (h == NULL) { - vsb_printf(tl->sb, "Reference to unknown backend "); + VSB_printf(tl->sb, "Reference to unknown backend "); vcc_ErrToken(tl, tl->t); - vsb_printf(tl->sb, " at\n"); + VSB_printf(tl->sb, " at\n"); vcc_ErrWhere(tl, tl->t); return; } @@ -658,7 +658,7 @@ vcc_ParseBackendHost(struct vcc *tl, int serial, char **nm) vcc_ParseHostDef(tl, serial, vgcname); if (tl->err) { - vsb_printf(tl->sb, + VSB_printf(tl->sb, "\nIn backend host specification starting at:\n"); vcc_ErrWhere(tl, t); } @@ -666,11 +666,11 @@ vcc_ParseBackendHost(struct vcc *tl, int serial, char **nm) return; } else { - vsb_printf(tl->sb, + VSB_printf(tl->sb, "Expected a backend host specification here, " "either by name or by {...}\n"); vcc_ErrToken(tl, tl->t); - vsb_printf(tl->sb, " at\n"); + VSB_printf(tl->sb, " at\n"); vcc_ErrWhere(tl, tl->t); return; } @@ -688,7 +688,7 @@ vcc_DefBackend(struct vcc *tl, const struct token *nm) sym = VCC_GetSymbolTok(tl, nm, SYM_BACKEND); AN(sym); if (sym->ndef > 0) { - vsb_printf(tl->sb, "Backend %.*s redefined\n", PF(tl->t)); + VSB_printf(tl->sb, "Backend %.*s redefined\n", PF(tl->t)); vcc_ErrWhere(tl, nm); return; } @@ -768,9 +768,9 @@ vcc_ParseDirector(struct vcc *tl) if (vcc_IdIs(tl->t_policy, dl->name)) break; if (dl->name == NULL) { - vsb_printf(tl->sb, "Unknown director policy: "); + VSB_printf(tl->sb, "Unknown director policy: "); vcc_ErrToken(tl, tl->t_policy); - vsb_printf(tl->sb, " at\n"); + VSB_printf(tl->sb, " at\n"); vcc_ErrWhere(tl, tl->t_policy); return; } @@ -792,7 +792,7 @@ vcc_ParseDirector(struct vcc *tl) } if (tl->err) { - vsb_printf(tl->sb, + VSB_printf(tl->sb, "\nIn %.*s specification starting at:\n", PF(t_first)); vcc_ErrWhere(tl, t_first); return; diff --git a/lib/libvcl/vcc_backend_util.c b/lib/libvcl/vcc_backend_util.c index 2bde38d..c0c493f 100644 --- a/lib/libvcl/vcc_backend_util.c +++ b/lib/libvcl/vcc_backend_util.c @@ -109,17 +109,17 @@ vcc_IsField(struct vcc *tl, struct token **t, struct fld_spec *fs) fs->found = t_field; return; } - vsb_printf(tl->sb, "Field "); + VSB_printf(tl->sb, "Field "); vcc_ErrToken(tl, t_field); - vsb_printf(tl->sb, " redefined at:\n"); + VSB_printf(tl->sb, " redefined at:\n"); vcc_ErrWhere(tl, t_field); - vsb_printf(tl->sb, "\nFirst defined at:\n"); + VSB_printf(tl->sb, "\nFirst defined at:\n"); vcc_ErrWhere(tl, fs->found); return; } - vsb_printf(tl->sb, "Unknown field: "); + VSB_printf(tl->sb, "Unknown field: "); vcc_ErrToken(tl, t_field); - vsb_printf(tl->sb, " at\n"); + VSB_printf(tl->sb, " at\n"); vcc_ErrWhere(tl, t_field); return; } @@ -130,7 +130,7 @@ vcc_FieldsOk(struct vcc *tl, const struct fld_spec *fs) for (; fs->name != NULL; fs++) { if (*fs->name == '!' && fs->found == NULL) { - vsb_printf(tl->sb, + VSB_printf(tl->sb, "Mandatory field '%s' missing.\n", fs->name + 1); tl->err = 1; } diff --git a/lib/libvcl/vcc_compile.c b/lib/libvcl/vcc_compile.c index e9f85b9..bde3708 100644 --- a/lib/libvcl/vcc_compile.c +++ b/lib/libvcl/vcc_compile.c @@ -154,9 +154,9 @@ Fh(const struct vcc *tl, int indent, const char *fmt, ...) va_list ap; if (indent) - vsb_printf(tl->fh, "%*.*s", tl->hindent, tl->hindent, ""); + VSB_printf(tl->fh, "%*.*s", tl->hindent, tl->hindent, ""); va_start(ap, fmt); - vsb_vprintf(tl->fh, fmt, ap); + VSB_vprintf(tl->fh, fmt, ap); va_end(ap); } @@ -167,9 +167,9 @@ Fb(const struct vcc *tl, int indent, const char *fmt, ...) assert(tl->fb != NULL); if (indent) - vsb_printf(tl->fb, "%*.*s", tl->indent, tl->indent, ""); + VSB_printf(tl->fb, "%*.*s", tl->indent, tl->indent, ""); va_start(ap, fmt); - vsb_vprintf(tl->fb, fmt, ap); + VSB_vprintf(tl->fb, fmt, ap); va_end(ap); } @@ -179,9 +179,9 @@ Fc(const struct vcc *tl, int indent, const char *fmt, ...) va_list ap; if (indent) - vsb_printf(tl->fc, "%*.*s", tl->indent, tl->indent, ""); + VSB_printf(tl->fc, "%*.*s", tl->indent, tl->indent, ""); va_start(ap, fmt); - vsb_vprintf(tl->fc, fmt, ap); + VSB_vprintf(tl->fc, fmt, ap); va_end(ap); } @@ -191,9 +191,9 @@ Fi(const struct vcc *tl, int indent, const char *fmt, ...) va_list ap; if (indent) - vsb_printf(tl->fi, "%*.*s", tl->iindent, tl->iindent, ""); + VSB_printf(tl->fi, "%*.*s", tl->iindent, tl->iindent, ""); va_start(ap, fmt); - vsb_vprintf(tl->fi, fmt, ap); + VSB_vprintf(tl->fi, fmt, ap); va_end(ap); } @@ -203,9 +203,9 @@ Ff(const struct vcc *tl, int indent, const char *fmt, ...) va_list ap; if (indent) - vsb_printf(tl->ff, "%*.*s", tl->findent, tl->findent, ""); + VSB_printf(tl->ff, "%*.*s", tl->findent, tl->findent, ""); va_start(ap, fmt); - vsb_vprintf(tl->ff, fmt, ap); + VSB_vprintf(tl->ff, fmt, ap); va_end(ap); } @@ -218,30 +218,30 @@ EncString(struct vsb *sb, const char *b, const char *e, int mode) if (e == NULL) e = strchr(b, '\0'); - vsb_cat(sb, "\""); + VSB_cat(sb, "\""); for (; b < e; b++) { switch (*b) { case '\\': case '"': - vsb_printf(sb, "\\%c", *b); + VSB_printf(sb, "\\%c", *b); break; case '\n': - vsb_printf(sb, "\\n"); + VSB_printf(sb, "\\n"); if (mode) - vsb_printf(sb, "\"\n\t\""); + VSB_printf(sb, "\"\n\t\""); break; - case '\t': vsb_printf(sb, "\\t"); break; - case '\r': vsb_printf(sb, "\\r"); break; - case ' ': vsb_printf(sb, " "); break; + case '\t': VSB_printf(sb, "\\t"); break; + case '\r': VSB_printf(sb, "\\r"); break; + case ' ': VSB_printf(sb, " "); break; default: if (isgraph(*b)) - vsb_printf(sb, "%c", *b); + VSB_printf(sb, "%c", *b); else - vsb_printf(sb, "\\%03o", *b); + VSB_printf(sb, "\\%03o", *b); break; } } - vsb_cat(sb, "\""); + VSB_cat(sb, "\""); } void @@ -311,8 +311,8 @@ EmitInitFunc(const struct vcc *tl) { Fc(tl, 0, "\nstatic void\nVGC_Init(struct cli *cli)\n{\n\n"); - AZ(vsb_finish(tl->fi)); - vsb_cat(tl->fc, vsb_data(tl->fi)); + AZ(VSB_finish(tl->fi)); + VSB_cat(tl->fc, VSB_data(tl->fi)); Fc(tl, 0, "}\n"); } @@ -330,8 +330,8 @@ EmitFiniFunc(const struct vcc *tl) for (u = 0; u < tl->nvmodpriv; u++) Fc(tl, 0, "\tvmod_priv_fini(&vmod_priv_%u);\n", u); - AZ(vsb_finish(tl->ff)); - vsb_cat(tl->fc, vsb_data(tl->ff)); + AZ(VSB_finish(tl->ff)); + VSB_cat(tl->fc, VSB_data(tl->ff)); Fc(tl, 0, "}\n"); } @@ -420,7 +420,7 @@ vcc_file_source(const struct vcc *tl, struct vsb *sb, const char *fn) f = vreadfile(tl->vcl_dir, fn, NULL); if (f == NULL) { - vsb_printf(sb, "Cannot read file '%s': %s\n", + VSB_printf(sb, "Cannot read file '%s': %s\n", fn, strerror(errno)); return (NULL); } @@ -444,7 +444,7 @@ vcc_resolve_includes(struct vcc *tl) t1 = VTAILQ_NEXT(t, list); assert(t1 != NULL); /* There's always an EOI */ if (t1->tok != CSTR) { - vsb_printf(tl->sb, + VSB_printf(tl->sb, "include not followed by string constant.\n"); vcc_ErrWhere(tl, t1); return; @@ -452,7 +452,7 @@ vcc_resolve_includes(struct vcc *tl) t2 = VTAILQ_NEXT(t1, list); assert(t2 != NULL); /* There's always an EOI */ if (t2->tok != ';') { - vsb_printf(tl->sb, + VSB_printf(tl->sb, "include not followed by semicolon.\n"); vcc_ErrWhere(tl, t1); return; @@ -507,24 +507,24 @@ vcc_NewVcc(const struct vcc *tl0) tl->ndirector = 1; /* General C code */ - tl->fc = vsb_new_auto(); + tl->fc = VSB_new_auto(); assert(tl->fc != NULL); /* Forward decls (.h like) */ - tl->fh = vsb_new_auto(); + tl->fh = VSB_new_auto(); assert(tl->fh != NULL); /* Init C code */ - tl->fi = vsb_new_auto(); + tl->fi = VSB_new_auto(); assert(tl->fi != NULL); /* Finish C code */ - tl->ff = vsb_new_auto(); + tl->ff = VSB_new_auto(); assert(tl->ff != NULL); /* body code of methods */ for (i = 0; i < VCL_MET_MAX; i++) { - tl->fm[i] = vsb_new_auto(); + tl->fm[i] = VSB_new_auto(); assert(tl->fm[i] != NULL); } return (tl); @@ -558,12 +558,12 @@ vcc_DestroyTokenList(struct vcc *tl, char *ret) FREE_OBJ(sym); } - vsb_delete(tl->fh); - vsb_delete(tl->fc); - vsb_delete(tl->fi); - vsb_delete(tl->ff); + VSB_delete(tl->fh); + VSB_delete(tl->fc); + VSB_delete(tl->fi); + VSB_delete(tl->ff); for (i = 0; i < VCL_MET_MAX; i++) - vsb_delete(tl->fm[i]); + VSB_delete(tl->fm[i]); free(tl); return (ret); @@ -644,7 +644,7 @@ vcc_CompileSource(const struct vcc *tl0, struct vsb *sb, struct source *sp) /* Check if we have any backends at all */ if (tl->ndirector == 1) { - vsb_printf(tl->sb, + VSB_printf(tl->sb, "No backends or directors found in VCL program, " "at least one is necessary.\n"); tl->err = 1; @@ -673,9 +673,9 @@ vcc_CompileSource(const struct vcc *tl0, struct vsb *sb, struct source *sp) Fc(tl, 1, "\nstatic int\n"); Fc(tl, 1, "VGC_function_%s (struct sess *sp)\n", method_tab[i].name); - AZ(vsb_finish(tl->fm[i])); + AZ(VSB_finish(tl->fm[i])); Fc(tl, 1, "{\n"); - Fc(tl, 1, "%s", vsb_data(tl->fm[i])); + Fc(tl, 1, "%s", VSB_data(tl->fm[i])); Fc(tl, 1, "}\n"); } @@ -688,11 +688,11 @@ vcc_CompileSource(const struct vcc *tl0, struct vsb *sb, struct source *sp) EmitStruct(tl); /* Combine it all in the fh vsb */ - AZ(vsb_finish(tl->fc)); - vsb_cat(tl->fh, vsb_data(tl->fc)); - AZ(vsb_finish(tl->fh)); + AZ(VSB_finish(tl->fc)); + VSB_cat(tl->fh, VSB_data(tl->fc)); + AZ(VSB_finish(tl->fh)); - of = strdup(vsb_data(tl->fh)); + of = strdup(VSB_data(tl->fh)); AN(of); /* done */ diff --git a/lib/libvcl/vcc_dir_dns.c b/lib/libvcl/vcc_dir_dns.c index 4fff785..303a33a 100644 --- a/lib/libvcl/vcc_dir_dns.c +++ b/lib/libvcl/vcc_dir_dns.c @@ -84,7 +84,7 @@ print_backend(struct vcc *tl, bprintf(strip, "%u.%u.%u.%u", ip[3], ip[2], ip[1], ip[0]); tmptok.dec = strip; bprintf(vgcname, "%.*s_%d", PF(tl->t_dir), serial); - vsb = vsb_new_auto(); + vsb = VSB_new_auto(); AN(vsb); tl->fb = vsb; Fc(tl, 0, "\t{ .host = VGC_backend_%s },\n",vgcname); @@ -117,9 +117,9 @@ print_backend(struct vcc *tl, Fb(tl, 0, "};\n"); tl->fb = NULL; - AZ(vsb_finish(vsb)); - Fh(tl, 0, "%s", vsb_data(vsb)); - vsb_delete(vsb); + AZ(VSB_finish(vsb)); + Fh(tl, 0, "%s", VSB_data(vsb)); + VSB_delete(vsb); Fi(tl, 0, "\tVRT_init_dir(cli, VCL_conf.director, \"simple\",\n" "\t VGC_backend_%s, &vgc_dir_priv_%s);\n", vgcname, vgcname); Ff(tl, 0, "\tVRT_fini_dir(cli, VGCDIR(%s));\n", vgcname); @@ -151,9 +151,9 @@ vcc_dir_dns_makebackend(struct vcc *tl, ip4end = ip4 | ~mask; if (ip4 != (ip4 & mask)) { - vsb_printf(tl->sb, "IP and network mask not compatible: "); + VSB_printf(tl->sb, "IP and network mask not compatible: "); vcc_ErrToken(tl, tl->t); - vsb_printf(tl->sb, " at\n"); + VSB_printf(tl->sb, " at\n"); vcc_ErrWhere(tl, tl->t); ERRCHK(tl); } @@ -228,10 +228,10 @@ vcc_dir_dns_parse_backend_options(struct vcc *tl) * not allowed here. */ if (u == UINT_MAX) { - vsb_printf(tl->sb, + VSB_printf(tl->sb, "Value outside allowed range: "); vcc_ErrToken(tl, tl->t); - vsb_printf(tl->sb, " at\n"); + VSB_printf(tl->sb, " at\n"); vcc_ErrWhere(tl, tl->t); } ERRCHK(tl); @@ -265,9 +265,9 @@ vcc_dir_dns_parse_list(struct vcc *tl, int *serial) ret = sscanf(tl->t->dec, "%hhu.%hhu.%hhu.%hhu", &a[0], &a[1], &a[2], &a[3]); if (ret != 4) { - vsb_printf(tl->sb, "Incomplete IP supplied: "); + VSB_printf(tl->sb, "Incomplete IP supplied: "); vcc_ErrToken(tl, tl->t); - vsb_printf(tl->sb, " at\n"); + VSB_printf(tl->sb, " at\n"); vcc_ErrWhere(tl, tl->t); ERRCHK(tl); } @@ -327,7 +327,7 @@ vcc_ParseDnsDirector(struct vcc *tl) } vcc_FieldsOk(tl, fs); if (tl->err) { - vsb_printf(tl->sb, "\nIn member host" + VSB_printf(tl->sb, "\nIn member host" " specification starting at:\n"); vcc_ErrWhere(tl, t_be); return; diff --git a/lib/libvcl/vcc_dir_random.c b/lib/libvcl/vcc_dir_random.c index 091d4d7..b1aabc2 100644 --- a/lib/libvcl/vcc_dir_random.c +++ b/lib/libvcl/vcc_dir_random.c @@ -100,11 +100,11 @@ vcc_ParseRandomDirector(struct vcc *tl) u = vcc_UintVal(tl); ERRCHK(tl); if (u == 0) { - vsb_printf(tl->sb, + VSB_printf(tl->sb, "The .weight must be higher " "than zero."); vcc_ErrToken(tl, tl->t); - vsb_printf(tl->sb, " at\n"); + VSB_printf(tl->sb, " at\n"); vcc_ErrWhere(tl, tl->t); return; } @@ -117,7 +117,7 @@ vcc_ParseRandomDirector(struct vcc *tl) } vcc_FieldsOk(tl, mfs); if (tl->err) { - vsb_printf(tl->sb, + VSB_printf(tl->sb, "\nIn member host specification starting at:\n"); vcc_ErrWhere(tl, t_be); return; diff --git a/lib/libvcl/vcc_dir_round_robin.c b/lib/libvcl/vcc_dir_round_robin.c index 5292adf..a94a5cc 100644 --- a/lib/libvcl/vcc_dir_round_robin.c +++ b/lib/libvcl/vcc_dir_round_robin.c @@ -83,7 +83,7 @@ vcc_ParseRoundRobinDirector(struct vcc *tl) } vcc_FieldsOk(tl, fs); if (tl->err) { - vsb_printf(tl->sb, + VSB_printf(tl->sb, "\nIn member host specification starting at:\n"); vcc_ErrWhere(tl, t_be); return; diff --git a/lib/libvcl/vcc_expr.c b/lib/libvcl/vcc_expr.c index 8774d8d..5c201b5 100644 --- a/lib/libvcl/vcc_expr.c +++ b/lib/libvcl/vcc_expr.c @@ -79,9 +79,9 @@ vcc_TimeUnit(struct vcc *tl) else if (vcc_IdIs(tl->t, "w")) sc = 60.0 * 60.0 * 24.0 * 7.0; else { - vsb_printf(tl->sb, "Unknown time unit "); + VSB_printf(tl->sb, "Unknown time unit "); vcc_ErrToken(tl, tl->t); - vsb_printf(tl->sb, ". Legal are 's', 'm', 'h' and 'd'\n"); + VSB_printf(tl->sb, ". Legal are 's', 'm', 'h' and 'd'\n"); vcc_ErrWhere(tl, tl->t); return (1.0); } @@ -198,9 +198,9 @@ vcc_ByteVal(struct vcc *tl, double *d) v = vcc_DoubleVal(tl); ERRCHK(tl); if (tl->t->tok != ID) { - vsb_printf(tl->sb, "Expected BYTES unit (B, KB, MB...) got "); + VSB_printf(tl->sb, "Expected BYTES unit (B, KB, MB...) got "); vcc_ErrToken(tl, tl->t); - vsb_printf(tl->sb, "\n"); + VSB_printf(tl->sb, "\n"); vcc_ErrWhere(tl, tl->t); return; } @@ -215,9 +215,9 @@ vcc_ByteVal(struct vcc *tl, double *d) else if (vcc_IdIs(tl->t, "TB")) sc = 1024. * 1024. * 1024. * 1024.; else { - vsb_printf(tl->sb, "Unknown BYTES unit "); + VSB_printf(tl->sb, "Unknown BYTES unit "); vcc_ErrToken(tl, tl->t); - vsb_printf(tl->sb, + VSB_printf(tl->sb, ". Legal are 'B', 'KB', 'MB', 'GB' and 'TB'\n"); vcc_ErrWhere(tl, tl->t); return; @@ -250,7 +250,7 @@ vcc_new_expr(void) /* XXX: use TlAlloc() ? */ ALLOC_OBJ(e, EXPR_MAGIC); AN(e); - e->vsb = vsb_new_auto(); + e->vsb = VSB_new_auto(); e->fmt = VOID; return (e); } @@ -264,9 +264,9 @@ vcc_mk_expr(enum var_type fmt, const char *str, ...) e = vcc_new_expr(); e->fmt = fmt; va_start(ap, str); - vsb_vprintf(e->vsb, str, ap); + VSB_vprintf(e->vsb, str, ap); va_end(ap); - AZ(vsb_finish(e->vsb)); + AZ(VSB_finish(e->vsb)); return (e); } @@ -276,7 +276,7 @@ vcc_delete_expr(struct expr *e) if (e == NULL) return; CHECK_OBJ_NOTNULL(e, EXPR_MAGIC); - vsb_delete(e->vsb); + VSB_delete(e->vsb); FREE_OBJ(e); } /*-------------------------------------------------------------------- @@ -311,29 +311,29 @@ vcc_expr_edit(enum var_type fmt, const char *p, struct expr *e1, while (*p != '\0') { if (*p == '\n') { if (!nl) - vsb_putc(e->vsb, *p); + VSB_putc(e->vsb, *p); nl = 1; p++; continue; } nl = 0; if (*p != '\v') { - vsb_putc(e->vsb, *p); + VSB_putc(e->vsb, *p); p++; continue; } assert(*p == '\v'); p++; switch(*p) { - case '+': vsb_cat(e->vsb, "\v+"); break; - case '-': vsb_cat(e->vsb, "\v-"); break; + case '+': VSB_cat(e->vsb, "\v+"); break; + case '-': VSB_cat(e->vsb, "\v-"); break; case '1': case '2': if (*p == '1') - vsb_cat(e->vsb, vsb_data(e1->vsb)); + VSB_cat(e->vsb, VSB_data(e1->vsb)); else { AN(e2); - vsb_cat(e->vsb, vsb_data(e2->vsb)); + VSB_cat(e->vsb, VSB_data(e2->vsb)); } break; default: @@ -341,7 +341,7 @@ vcc_expr_edit(enum var_type fmt, const char *p, struct expr *e1, } p++; } - AZ(vsb_finish(e->vsb)); + AZ(VSB_finish(e->vsb)); if (e1 != NULL) e->t1 = e1->t1; else if (e2 != NULL) @@ -369,20 +369,20 @@ vcc_expr_fmt(struct vsb *d, int ind, const struct expr *e1) int i; for (i = 0; i < ind; i++) - vsb_cat(d, " "); - p = vsb_data(e1->vsb); + VSB_cat(d, " "); + p = VSB_data(e1->vsb); while (*p != '\0') { if (*p == '\n') { - vsb_putc(d, '\n'); + VSB_putc(d, '\n'); if (p[1] != '\0') { for (i = 0; i < ind; i++) - vsb_cat(d, " "); + VSB_cat(d, " "); } p++; continue; } if (*p != '\v') { - vsb_putc(d, *p); + VSB_putc(d, *p); p++; continue; } @@ -558,10 +558,10 @@ vcc_Eval_Func(struct vcc *tl, struct expr **e, const struct symbol *sym) p += strlen(p) + 1; } while (*p != '\0'); if (*p == '\0') { - vsb_printf(tl->sb, "Wrong enum value."); - vsb_printf(tl->sb, " Expected one of:\n"); + VSB_printf(tl->sb, "Wrong enum value."); + VSB_printf(tl->sb, " Expected one of:\n"); do { - vsb_printf(tl->sb, "\t%s\n", r); + VSB_printf(tl->sb, "\t%s\n", r); r += strlen(r) + 1; } while (*r != '\0'); vcc_ErrWhere(tl, tl->t); @@ -580,20 +580,20 @@ vcc_Eval_Func(struct vcc *tl, struct expr **e, const struct symbol *sym) ERRCHK(tl); SkipToken(tl, ID); if (sym == NULL) { - vsb_printf(tl->sb, "Symbol not found.\n"); + VSB_printf(tl->sb, "Symbol not found.\n"); vcc_ErrWhere(tl, tl->t); return; } vcc_AddUses(tl, tl->t, sym->r_methods, "Not available"); if (sym->kind != SYM_VAR) { - vsb_printf(tl->sb, "Wrong kind of symbol.\n"); + VSB_printf(tl->sb, "Wrong kind of symbol.\n"); vcc_ErrWhere(tl, tl->t); return; } AN(sym->var); v = sym->var; if (v->http == NULL) { - vsb_printf(tl->sb, + VSB_printf(tl->sb, "Variable not an HTTP header.\n"); vcc_ErrWhere(tl, tl->t); return; @@ -605,10 +605,10 @@ vcc_Eval_Func(struct vcc *tl, struct expr **e, const struct symbol *sym) vcc_expr0(tl, &e1, fmt); ERRCHK(tl); if (e1->fmt != fmt) { - vsb_printf(tl->sb, "Wrong argument type."); - vsb_printf(tl->sb, " Expected %s.", + VSB_printf(tl->sb, "Wrong argument type."); + VSB_printf(tl->sb, " Expected %s.", vcc_Type(fmt)); - vsb_printf(tl->sb, " Got %s.\n", + VSB_printf(tl->sb, " Got %s.\n", vcc_Type(e1->fmt)); vcc_ErrWhere2(tl, e1->t1, tl->t); return; @@ -661,9 +661,9 @@ vcc_expr4(struct vcc *tl, struct expr **e, enum var_type fmt) */ sym = VCC_FindSymbol(tl, tl->t, SYM_NONE); if (sym == NULL || sym->eval == NULL) { - vsb_printf(tl->sb, "Symbol not found: "); + VSB_printf(tl->sb, "Symbol not found: "); vcc_ErrToken(tl, tl->t); - vsb_printf(tl->sb, " (expected type %s):\n", + VSB_printf(tl->sb, " (expected type %s):\n", vcc_Type(fmt)); vcc_ErrWhere(tl, tl->t); return; @@ -680,7 +680,7 @@ vcc_expr4(struct vcc *tl, struct expr **e, enum var_type fmt) default: break; } - vsb_printf(tl->sb, + VSB_printf(tl->sb, "Symbol type (%s) can not be used in expression.\n", VCC_SymKind(tl, sym)); vcc_ErrWhere(tl, tl->t); @@ -693,7 +693,7 @@ vcc_expr4(struct vcc *tl, struct expr **e, enum var_type fmt) e1->t1 = tl->t; e1->constant = 1; vcc_NextToken(tl); - AZ(vsb_finish(e1->vsb)); + AZ(VSB_finish(e1->vsb)); *e = e1; break; case CNUM: @@ -722,9 +722,9 @@ vcc_expr4(struct vcc *tl, struct expr **e, enum var_type fmt) *e = e1; break; default: - vsb_printf(tl->sb, "Unknown token "); + VSB_printf(tl->sb, "Unknown token "); vcc_ErrToken(tl, tl->t); - vsb_printf(tl->sb, " when looking for %s\n\n", vcc_Type(fmt)); + VSB_printf(tl->sb, " when looking for %s\n\n", vcc_Type(fmt)); vcc_ErrWhere(tl, tl->t); break; } @@ -755,7 +755,7 @@ vcc_expr_mul(struct vcc *tl, struct expr **e, enum var_type fmt) default: if (tl->t->tok != '*' && tl->t->tok != '/') return; - vsb_printf(tl->sb, "Operator %.*s not possible on type %s.\n", + VSB_printf(tl->sb, "Operator %.*s not possible on type %s.\n", PF(tl->t), vcc_Type(f2)); vcc_ErrWhere(tl, tl->t); return; @@ -826,7 +826,7 @@ vcc_expr_add(struct vcc *tl, struct expr **e, enum var_type fmt) default: if (tl->t->tok != '+' && tl->t->tok != '-') return; - vsb_printf(tl->sb, "Operator %.*s not possible on type %s.\n", + VSB_printf(tl->sb, "Operator %.*s not possible on type %s.\n", PF(tl->t), vcc_Type(f2)); vcc_ErrWhere(tl, tl->t); return; @@ -845,7 +845,7 @@ vcc_expr_add(struct vcc *tl, struct expr **e, enum var_type fmt) (*e)->fmt == BYTES && e2->fmt == BYTES) { /* OK */ } else if (e2->fmt != f2) { - vsb_printf(tl->sb, "%s %.*s %s not possible.\n", + VSB_printf(tl->sb, "%s %.*s %s not possible.\n", vcc_Type((*e)->fmt), PF(tk), vcc_Type(e2->fmt)); vcc_ErrWhere2(tl, tk, tl->t); return; @@ -922,10 +922,10 @@ vcc_expr_cmp(struct vcc *tl, struct expr **e, enum var_type fmt) vcc_expr_add(tl, &e2, (*e)->fmt); ERRCHK(tl); if (e2->fmt != (*e)->fmt) { /* XXX */ - vsb_printf(tl->sb, "Comparison of different types: "); - vsb_printf(tl->sb, "%s ", vcc_Type((*e)->fmt)); + VSB_printf(tl->sb, "Comparison of different types: "); + VSB_printf(tl->sb, "%s ", vcc_Type((*e)->fmt)); vcc_ErrToken(tl, tk); - vsb_printf(tl->sb, " %s\n", vcc_Type(e2->fmt)); + VSB_printf(tl->sb, " %s\n", vcc_Type(e2->fmt)); vcc_ErrWhere(tl, tk); return; } @@ -979,7 +979,7 @@ vcc_expr_cmp(struct vcc *tl, struct expr **e, enum var_type fmt) case T_GEQ: case '~': case T_NOMATCH: - vsb_printf(tl->sb, "Operator %.*s not possible on %s\n", + VSB_printf(tl->sb, "Operator %.*s not possible on %s\n", PF(tl->t), vcc_Type((*e)->fmt)); vcc_ErrWhere(tl, tl->t); return; @@ -1018,8 +1018,8 @@ vcc_expr_not(struct vcc *tl, struct expr **e, enum var_type fmt) *e = vcc_expr_edit(BOOL, "!(\v1)", e2, NULL); return; } - vsb_printf(tl->sb, "'!' must be followed by BOOL, found "); - vsb_printf(tl->sb, "%s.\n", vcc_Type(e2->fmt)); + VSB_printf(tl->sb, "'!' must be followed by BOOL, found "); + VSB_printf(tl->sb, "%s.\n", vcc_Type(e2->fmt)); vcc_ErrWhere2(tl, tk, tl->t); } @@ -1047,9 +1047,9 @@ vcc_expr_cand(struct vcc *tl, struct expr **e, enum var_type fmt) vcc_expr_not(tl, &e2, fmt); ERRCHK(tl); if (e2->fmt != BOOL) { - vsb_printf(tl->sb, + VSB_printf(tl->sb, "'&&' must be followed by BOOL, found "); - vsb_printf(tl->sb, "%s.\n", vcc_Type(e2->fmt)); + VSB_printf(tl->sb, "%s.\n", vcc_Type(e2->fmt)); vcc_ErrWhere2(tl, tk, tl->t); return; } @@ -1082,9 +1082,9 @@ vcc_expr0(struct vcc *tl, struct expr **e, enum var_type fmt) vcc_expr_cand(tl, &e2, fmt); ERRCHK(tl); if (e2->fmt != BOOL) { - vsb_printf(tl->sb, + VSB_printf(tl->sb, "'||' must be followed by BOOL, found "); - vsb_printf(tl->sb, "%s.\n", vcc_Type(e2->fmt)); + VSB_printf(tl->sb, "%s.\n", vcc_Type(e2->fmt)); vcc_ErrWhere2(tl, tk, tl->t); return; } @@ -1114,7 +1114,7 @@ vcc_Expr(struct vcc *tl, enum var_type fmt) if (fmt == STRING || fmt == STRING_LIST) vcc_expr_tostring(&e, fmt); if (!tl->err && fmt != e->fmt) { - vsb_printf(tl->sb, "Expression has type %s, expected %s\n", + VSB_printf(tl->sb, "Expression has type %s, expected %s\n", vcc_Type(e->fmt), vcc_Type(fmt)); tl->err = 1; } @@ -1124,7 +1124,7 @@ vcc_Expr(struct vcc *tl, enum var_type fmt) "\v+\n\v1,\nvrt_magic_string_end\v-", e, NULL); } vcc_expr_fmt(tl->fb, tl->indent, e); - vsb_putc(tl->fb, '\n'); + VSB_putc(tl->fb, '\n'); } else { if (t1 != tl->t) vcc_ErrWhere2(tl, t1, tl->t); @@ -1147,7 +1147,7 @@ vcc_Expr_Call(struct vcc *tl, const struct symbol *sym) vcc_Eval_Func(tl, &e, sym); if (!tl->err) { vcc_expr_fmt(tl->fb, tl->indent, e); - vsb_cat(tl->fb, ";\n"); + VSB_cat(tl->fb, ";\n"); } else if (t1 != tl->t) { vcc_ErrWhere2(tl, t1, tl->t); } diff --git a/lib/libvcl/vcc_parse.c b/lib/libvcl/vcc_parse.c index 34f9c33..bb42709 100644 --- a/lib/libvcl/vcc_parse.c +++ b/lib/libvcl/vcc_parse.c @@ -163,7 +163,7 @@ vcc_Compound(struct vcc *tl) vcc_NextToken(tl); break; case EOI: - vsb_printf(tl->sb, + VSB_printf(tl->sb, "End of input while in compound statement\n"); tl->err = 1; return; @@ -177,7 +177,7 @@ vcc_Compound(struct vcc *tl) /* FALLTHROUGH */ default: /* We deliberately do not mention inline C */ - vsb_printf(tl->sb, + VSB_printf(tl->sb, "Expected an action, 'if', '{' or '}'\n"); vcc_ErrWhere(tl, tl->t); return; @@ -216,7 +216,7 @@ vcc_Function(struct vcc *tl) tl->fb = tl->fc; i = vcc_AddDef(tl, tl->t, SYM_SUB); if (i > 1) { - vsb_printf(tl->sb, + VSB_printf(tl->sb, "Function %.*s redefined\n", PF(tl->t)); vcc_ErrWhere(tl, tl->t); return; @@ -295,17 +295,17 @@ vcc_Parse(struct vcc *tl) /* FALLTHROUGH */ default: /* We deliberately do not mention inline-C */ - vsb_printf(tl->sb, "Expected one of\n\t"); + VSB_printf(tl->sb, "Expected one of\n\t"); for (tp = toplev; tp->name != NULL; tp++) { if (tp[1].name == NULL) - vsb_printf(tl->sb, " or "); - vsb_printf(tl->sb, "'%s'", tp->name); + VSB_printf(tl->sb, " or "); + VSB_printf(tl->sb, "'%s'", tp->name); if (tp[1].name != NULL) - vsb_printf(tl->sb, ", "); + VSB_printf(tl->sb, ", "); } - vsb_printf(tl->sb, "\nFound: "); + VSB_printf(tl->sb, "\nFound: "); vcc_ErrToken(tl, tl->t); - vsb_printf(tl->sb, " at\n"); + VSB_printf(tl->sb, " at\n"); vcc_ErrWhere(tl, tl->t); return; } diff --git a/lib/libvcl/vcc_string.c b/lib/libvcl/vcc_string.c index ed42fa2..707a5d1 100644 --- a/lib/libvcl/vcc_string.c +++ b/lib/libvcl/vcc_string.c @@ -57,7 +57,7 @@ vcc_regexp(struct vcc *tl) memset(&t, 0, sizeof t); t = VRE_compile(tl->t->dec, 0, &error, &erroroffset); if (t == NULL) { - vsb_printf(tl->sb, + VSB_printf(tl->sb, "Regexp compilation error:\n\n%s\n\n", error); vcc_ErrWhere(tl, tl->t); return (NULL); diff --git a/lib/libvcl/vcc_symb.c b/lib/libvcl/vcc_symb.c index 6c457b4..7c5cd1f 100644 --- a/lib/libvcl/vcc_symb.c +++ b/lib/libvcl/vcc_symb.c @@ -49,7 +49,7 @@ VCC_SymKind(struct vcc *tl, const struct symbol *s) #undef VCC_SYMB default: ErrInternal(tl); - vsb_printf(tl->sb, "Symbol Kind 0x%x\n", s->kind); + VSB_printf(tl->sb, "Symbol Kind 0x%x\n", s->kind); return("INTERNALERROR"); } } @@ -67,7 +67,7 @@ vcc_AddSymbol(struct vcc *tl, const char *nb, int l, enum symkind kind) continue; if (kind != sym->kind) continue; - vsb_printf(tl->sb, "Name Collision: <%.*s> <%s>\n", + VSB_printf(tl->sb, "Name Collision: <%.*s> <%s>\n", l, nb, VCC_SymKind(tl, sym)); ErrInternal(tl); return (NULL); diff --git a/lib/libvcl/vcc_token.c b/lib/libvcl/vcc_token.c index 14040b3..bc08427 100644 --- a/lib/libvcl/vcc_token.c +++ b/lib/libvcl/vcc_token.c @@ -49,18 +49,18 @@ vcc_ErrToken(const struct vcc *tl, const struct token *t) { if (t->tok == EOI) - vsb_printf(tl->sb, "end of input"); + VSB_printf(tl->sb, "end of input"); else if (t->tok == CSRC) - vsb_printf(tl->sb, "C{ ... }C"); + VSB_printf(tl->sb, "C{ ... }C"); else - vsb_printf(tl->sb, "'%.*s'", PF(t)); + VSB_printf(tl->sb, "'%.*s'", PF(t)); } void vcc__ErrInternal(struct vcc *tl, const char *func, unsigned line) { - vsb_printf(tl->sb, "VCL compiler internal error at %s():%u\n", + VSB_printf(tl->sb, "VCL compiler internal error at %s():%u\n", func, line); tl->err = 1; } @@ -110,7 +110,7 @@ vcc_icoord(struct vsb *vsb, const struct token *t, int tail) } else pos++; } - vsb_printf(vsb, "('%s' Line %d Pos %d)", t->src->name, lin, pos + 1); + VSB_printf(vsb, "('%s' Line %d Pos %d)", t->src->name, lin, pos + 1); } /*--------------------------------------------------------------------*/ @@ -141,16 +141,16 @@ vcc_quoteline(const struct vcc *tl, const char *l, const char *le) y &= ~7; y += 8; while (x < y) { - vsb_bcat(tl->sb, " ", 1); + VSB_bcat(tl->sb, " ", 1); x++; } } else { x++; y++; - vsb_bcat(tl->sb, p, 1); + VSB_bcat(tl->sb, p, 1); } } - vsb_putc(tl->sb, '\n'); + VSB_putc(tl->sb, '\n'); } /*-------------------------------------------------------------------- @@ -179,11 +179,11 @@ vcc_markline(const struct vcc *tl, const char *l, const char *le, } else y++; while (x < y) { - vsb_putc(tl->sb, c); + VSB_putc(tl->sb, c); x++; } } - vsb_putc(tl->sb, '\n'); + VSB_putc(tl->sb, '\n'); } /*--------------------------------------------------------------------*/ @@ -205,9 +205,9 @@ vcc_ErrWhere2(struct vcc *tl, const struct token *t, const struct token *t2) if (l1 == l2) { vcc_icoord(tl->sb, t, 0); - vsb_cat(tl->sb, " -- "); + VSB_cat(tl->sb, " -- "); vcc_icoord(tl->sb, t2, 1); - vsb_putc(tl->sb, '\n'); + VSB_putc(tl->sb, '\n'); /* Two tokens on same line */ vcc_quoteline(tl, l1, t->src->e); vcc_markline(tl, l1, t->src->e, t->b, t2->e); @@ -218,21 +218,21 @@ vcc_ErrWhere2(struct vcc *tl, const struct token *t, const struct token *t2) /* XXX: t had better be before t2 */ vcc_icoord(tl->sb, t, 0); if (l3 + 1 == l2) { - vsb_cat(tl->sb, " -- "); + VSB_cat(tl->sb, " -- "); vcc_icoord(tl->sb, t2, 1); } - vsb_putc(tl->sb, '\n'); + VSB_putc(tl->sb, '\n'); vcc_quoteline(tl, l1, t->src->e); vcc_markline(tl, l1, t->src->e, t->b, t2->e); if (l3 + 1 != l2) { - vsb_cat(tl->sb, "[...]\n"); + VSB_cat(tl->sb, "[...]\n"); vcc_icoord(tl->sb, t2, 1); - vsb_putc(tl->sb, '\n'); + VSB_putc(tl->sb, '\n'); } vcc_quoteline(tl, l2, t->src->e); vcc_markline(tl, l2, t->src->e, t->b, t2->e); } - vsb_putc(tl->sb, '\n'); + VSB_putc(tl->sb, '\n'); tl->err = 1; } @@ -243,10 +243,10 @@ vcc_ErrWhere(struct vcc *tl, const struct token *t) vcc_iline(t, &l1, 0); vcc_icoord(tl->sb, t, 0); - vsb_putc(tl->sb, '\n'); + VSB_putc(tl->sb, '\n'); vcc_quoteline(tl, l1, t->src->e); vcc_markline(tl, l1, t->src->e, t->b, t->e); - vsb_putc(tl->sb, '\n'); + VSB_putc(tl->sb, '\n'); tl->err = 1; } @@ -258,7 +258,7 @@ vcc_NextToken(struct vcc *tl) tl->t = VTAILQ_NEXT(tl->t, list); if (tl->t == NULL) { - vsb_printf(tl->sb, + VSB_printf(tl->sb, "Ran out of input, something is missing or" " maybe unbalanced (...) or {...}\n"); tl->err = 1; @@ -271,9 +271,9 @@ vcc__Expect(struct vcc *tl, unsigned tok, int line) { if (tl->t->tok == tok) return; - vsb_printf(tl->sb, "Expected %s got ", vcl_tnames[tok]); + VSB_printf(tl->sb, "Expected %s got ", vcl_tnames[tok]); vcc_ErrToken(tl, tl->t); - vsb_printf(tl->sb, "\n(program line %u), at\n", line); + VSB_printf(tl->sb, "\n(program line %u), at\n", line); vcc_ErrWhere(tl, tl->t); } @@ -332,9 +332,9 @@ vcc_ExpectCid(struct vcc *tl) ERRCHK(tl); if (vcc_isCid(tl->t)) return; - vsb_printf(tl->sb, "Identifier "); + VSB_printf(tl->sb, "Identifier "); vcc_ErrToken(tl, tl->t); - vsb_printf(tl->sb, + VSB_printf(tl->sb, " contains illegal characters, use [0-9a-zA-Z_] only.\n"); vcc_ErrWhere(tl, tl->t); } @@ -411,7 +411,7 @@ vcc_Lexer(struct vcc *tl, struct source *sp) if (*p == '/' && p[1] == '*') { for (q = p + 2; q < sp->e; q++) { if (*q == '/' && q[1] == '*') { - vsb_printf(tl->sb, + VSB_printf(tl->sb, "/* ... */ comment contains /*\n"); vcc_AddToken(tl, EOI, p, p + 2); vcc_ErrWhere(tl, tl->t); @@ -427,7 +427,7 @@ vcc_Lexer(struct vcc *tl, struct source *sp) if (q < sp->e) continue; vcc_AddToken(tl, EOI, p, p + 2); - vsb_printf(tl->sb, + VSB_printf(tl->sb, "Unterminated /* ... */ comment, starting at\n"); vcc_ErrWhere(tl, tl->t); return; @@ -453,7 +453,7 @@ vcc_Lexer(struct vcc *tl, struct source *sp) continue; } vcc_AddToken(tl, EOI, p, p + 2); - vsb_printf(tl->sb, + VSB_printf(tl->sb, "Unterminated inline C source, starting at\n"); vcc_ErrWhere(tl, tl->t); return; @@ -478,7 +478,7 @@ vcc_Lexer(struct vcc *tl, struct source *sp) continue; } vcc_AddToken(tl, EOI, p, p + 2); - vsb_printf(tl->sb, + VSB_printf(tl->sb, "Unterminated long-string, starting at\n"); vcc_ErrWhere(tl, tl->t); return; @@ -501,7 +501,7 @@ vcc_Lexer(struct vcc *tl, struct source *sp) } if (*q == '\r' || *q == '\n') { vcc_AddToken(tl, EOI, p, q); - vsb_printf(tl->sb, + VSB_printf(tl->sb, "Unterminated string at\n"); vcc_ErrWhere(tl, tl->t); return; @@ -534,7 +534,7 @@ vcc_Lexer(struct vcc *tl, struct source *sp) continue; } vcc_AddToken(tl, EOI, p, p + 1); - vsb_printf(tl->sb, "Syntax error at\n"); + VSB_printf(tl->sb, "Syntax error at\n"); vcc_ErrWhere(tl, tl->t); return; } diff --git a/lib/libvcl/vcc_var.c b/lib/libvcl/vcc_var.c index cb9054a..51d5fcc 100644 --- a/lib/libvcl/vcc_var.c +++ b/lib/libvcl/vcc_var.c @@ -94,19 +94,19 @@ vcc_FindVar(struct vcc *tl, const struct token *t, int wr_access, AN(v); if (wr_access && v->w_methods == 0) { - vsb_printf(tl->sb, "Variable "); + VSB_printf(tl->sb, "Variable "); vcc_ErrToken(tl, t); - vsb_printf(tl->sb, " is read only."); - vsb_cat(tl->sb, "\nAt: "); + VSB_printf(tl->sb, " is read only."); + VSB_cat(tl->sb, "\nAt: "); vcc_ErrWhere(tl, t); return (NULL); } else if (wr_access) { vcc_AddUses(tl, t, v->w_methods, use); } else if (v->r_methods == 0) { - vsb_printf(tl->sb, "Variable "); + VSB_printf(tl->sb, "Variable "); vcc_ErrToken(tl, t); - vsb_printf(tl->sb, " is write only."); - vsb_cat(tl->sb, "\nAt: "); + VSB_printf(tl->sb, " is write only."); + VSB_cat(tl->sb, "\nAt: "); vcc_ErrWhere(tl, t); return (NULL); } else { @@ -115,9 +115,9 @@ vcc_FindVar(struct vcc *tl, const struct token *t, int wr_access, assert(v->fmt != HEADER); return (v); } - vsb_printf(tl->sb, "Unknown variable "); + VSB_printf(tl->sb, "Unknown variable "); vcc_ErrToken(tl, t); - vsb_cat(tl->sb, "\nAt: "); + VSB_cat(tl->sb, "\nAt: "); vcc_ErrWhere(tl, t); return (NULL); } @@ -141,7 +141,7 @@ vcc_VarVal(struct vcc *tl, const struct var *vp, const struct token *vt) Fb(tl, 0, "%u", vcc_UintVal(tl)); } else { AN(vt); - vsb_printf(tl->sb, + VSB_printf(tl->sb, "Variable has incompatible type.\n"); vcc_ErrWhere(tl, vt); return; diff --git a/lib/libvcl/vcc_vmod.c b/lib/libvcl/vcc_vmod.c index 731b26d..c54a4e3 100644 --- a/lib/libvcl/vcc_vmod.c +++ b/lib/libvcl/vcc_vmod.c @@ -62,16 +62,16 @@ vcc_ParseImport(struct vcc *tl) osym = VCC_FindSymbol(tl, mod, SYM_NONE); if (osym != NULL && osym->kind != SYM_VMOD) { - vsb_printf(tl->sb, "Module %.*s conflics with other symbol.\n", + VSB_printf(tl->sb, "Module %.*s conflics with other symbol.\n", PF(mod)); vcc_ErrWhere2(tl, t1, tl->t); return; } if (osym != NULL) { - vsb_printf(tl->sb, "Module %.*s already imported.\n", + VSB_printf(tl->sb, "Module %.*s already imported.\n", PF(mod)); vcc_ErrWhere2(tl, t1, tl->t); - vsb_printf(tl->sb, "Previous import was here:\n"); + VSB_printf(tl->sb, "Previous import was here:\n"); vcc_ErrWhere2(tl, osym->def_b, osym->def_e); return; } @@ -85,7 +85,7 @@ vcc_ParseImport(struct vcc *tl) if (tl->t->tok == ID) { if (!vcc_IdIs(tl->t, "from")) { - vsb_printf(tl->sb, "Expected 'from path...' at "); + VSB_printf(tl->sb, "Expected 'from path...' at "); vcc_ErrToken(tl, tl->t); vcc_ErrWhere(tl, tl->t); return; @@ -112,7 +112,7 @@ vcc_ParseImport(struct vcc *tl) hdl = dlopen(fn, RTLD_NOW | RTLD_LOCAL); if (hdl == NULL) { - vsb_printf(tl->sb, "Could not load module %.*s\n\t%s\n\t%s\n", + VSB_printf(tl->sb, "Could not load module %.*s\n\t%s\n\t%s\n", PF(mod), fn, dlerror()); vcc_ErrWhere(tl, mod); return; @@ -120,29 +120,29 @@ vcc_ParseImport(struct vcc *tl) modname = dlsym(hdl, "Vmod_Name"); if (modname == NULL) { - vsb_printf(tl->sb, "Could not load module %.*s\n\t%s\n\t%s\n", + VSB_printf(tl->sb, "Could not load module %.*s\n\t%s\n\t%s\n", PF(mod), fn, "Symbol Vmod_Name not found"); vcc_ErrWhere(tl, mod); return; } if (!vcc_IdIs(mod, modname)) { - vsb_printf(tl->sb, "Could not load module %.*s\n\t%s\n", + VSB_printf(tl->sb, "Could not load module %.*s\n\t%s\n", PF(mod), fn); - vsb_printf(tl->sb, "\tModule has wrong name: <%s>\n", modname); + VSB_printf(tl->sb, "\tModule has wrong name: <%s>\n", modname); vcc_ErrWhere(tl, mod); return; } proto = dlsym(hdl, "Vmod_Proto"); if (proto == NULL) { - vsb_printf(tl->sb, "Could not load module %.*s\n\t%s\n\t%s\n", + VSB_printf(tl->sb, "Could not load module %.*s\n\t%s\n\t%s\n", PF(mod), fn, "Symbol Vmod_Proto not found"); vcc_ErrWhere(tl, mod); return; } spec = dlsym(hdl, "Vmod_Spec"); if (spec == NULL) { - vsb_printf(tl->sb, "Could not load module %.*s\n\t%s\n\t%s\n", + VSB_printf(tl->sb, "Could not load module %.*s\n\t%s\n\t%s\n", PF(mod), fn, "Symbol Vmod_Spec not found"); vcc_ErrWhere(tl, mod); return; diff --git a/lib/libvcl/vcc_xref.c b/lib/libvcl/vcc_xref.c index 3cd2627..240555a 100644 --- a/lib/libvcl/vcc_xref.c +++ b/lib/libvcl/vcc_xref.c @@ -105,15 +105,15 @@ vcc_checkref(struct vcc *tl, const struct symbol *sym) { if (sym->ndef == 0 && sym->nref != 0) { - vsb_printf(tl->sb, "Undefined %s %.*s, first reference:\n", + VSB_printf(tl->sb, "Undefined %s %.*s, first reference:\n", VCC_SymKind(tl, sym), PF(sym->def_b)); vcc_ErrWhere(tl, sym->def_b); } else if (sym->ndef != 0 && sym->nref == 0) { - vsb_printf(tl->sb, "Unused %s %.*s, defined:\n", + VSB_printf(tl->sb, "Unused %s %.*s, defined:\n", VCC_SymKind(tl, sym), PF(sym->def_b)); vcc_ErrWhere(tl, sym->def_b); if (!tl->err_unref) { - vsb_printf(tl->sb, "(That was just a warning)\n"); + VSB_printf(tl->sb, "(That was just a warning)\n"); tl->err = 0; } } @@ -211,12 +211,12 @@ vcc_CheckActionRecurse(struct vcc *tl, struct proc *p, unsigned bitmap) struct proccall *pc; if (!p->exists) { - vsb_printf(tl->sb, "Function %.*s does not exist\n", + VSB_printf(tl->sb, "Function %.*s does not exist\n", PF(p->name)); return (1); } if (p->active) { - vsb_printf(tl->sb, "Function recurses on\n"); + VSB_printf(tl->sb, "Function recurses on\n"); vcc_ErrWhere(tl, p->name); return (1); } @@ -225,13 +225,13 @@ vcc_CheckActionRecurse(struct vcc *tl, struct proc *p, unsigned bitmap) #define VCL_RET_MAC(l, U, B) \ if (u & (1 << (VCL_RET_##U))) { \ - vsb_printf(tl->sb, "Invalid return \"" #l "\"\n");\ + VSB_printf(tl->sb, "Invalid return \"" #l "\"\n");\ vcc_ErrWhere(tl, p->return_tok[VCL_RET_##U]); \ } #include "vcl_returns.h" #undef VCL_RET_MAC - vsb_printf(tl->sb, "\n...in subroutine \"%.*s\"\n", + VSB_printf(tl->sb, "\n...in subroutine \"%.*s\"\n", PF(p->name)); vcc_ErrWhere(tl, p->name); return (1); @@ -239,7 +239,7 @@ vcc_CheckActionRecurse(struct vcc *tl, struct proc *p, unsigned bitmap) p->active = 1; VTAILQ_FOREACH(pc, &p->calls, list) { if (vcc_CheckActionRecurse(tl, pc->p, bitmap)) { - vsb_printf(tl->sb, "\n...called from \"%.*s\"\n", + VSB_printf(tl->sb, "\n...called from \"%.*s\"\n", PF(p->name)); vcc_ErrWhere(tl, pc->t); return (1); @@ -266,16 +266,16 @@ vcc_checkaction1(struct vcc *tl, const struct symbol *sym) return; m = method_tab + i; if (vcc_CheckActionRecurse(tl, p, m->ret_bitmap)) { - vsb_printf(tl->sb, + VSB_printf(tl->sb, "\n...which is the \"%s\" method\n", m->name); - vsb_printf(tl->sb, "Legal returns are:"); + VSB_printf(tl->sb, "Legal returns are:"); #define VCL_RET_MAC(l, U, B) \ if (m->ret_bitmap & ((1 << VCL_RET_##U))) \ - vsb_printf(tl->sb, " \"%s\"", #l); + VSB_printf(tl->sb, " \"%s\"", #l); #include "vcl_returns.h" #undef VCL_RET_MAC - vsb_printf(tl->sb, "\n"); + VSB_printf(tl->sb, "\n"); tl->err = 1; } @@ -291,10 +291,10 @@ vcc_checkaction2(struct vcc *tl, const struct symbol *sym) if (p->called) return; - vsb_printf(tl->sb, "Function unused\n"); + VSB_printf(tl->sb, "Function unused\n"); vcc_ErrWhere(tl, p->name); if (!tl->err_unref) { - vsb_printf(tl->sb, "(That was just a warning)\n"); + VSB_printf(tl->sb, "(That was just a warning)\n"); tl->err = 0; } } @@ -332,18 +332,18 @@ vcc_CheckUseRecurse(struct vcc *tl, const struct proc *p, pu = vcc_FindIllegalUse(p, m); if (pu != NULL) { - vsb_printf(tl->sb, + VSB_printf(tl->sb, "'%.*s': %s from method '%.*s'.\n", PF(pu->t), pu->use, PF(p->name)); vcc_ErrWhere(tl, pu->t); - vsb_printf(tl->sb, "\n...in subroutine \"%.*s\"\n", + VSB_printf(tl->sb, "\n...in subroutine \"%.*s\"\n", PF(p->name)); vcc_ErrWhere(tl, p->name); return (1); } VTAILQ_FOREACH(pc, &p->calls, list) { if (vcc_CheckUseRecurse(tl, pc->p, m)) { - vsb_printf(tl->sb, "\n...called from \"%.*s\"\n", + VSB_printf(tl->sb, "\n...called from \"%.*s\"\n", PF(p->name)); vcc_ErrWhere(tl, pc->t); return (1); @@ -369,15 +369,15 @@ vcc_checkuses(struct vcc *tl, const struct symbol *sym) m = method_tab + i; pu = vcc_FindIllegalUse(p, m); if (pu != NULL) { - vsb_printf(tl->sb, + VSB_printf(tl->sb, "'%.*s': %s in method '%.*s'.", PF(pu->t), pu->use, PF(p->name)); - vsb_cat(tl->sb, "\nAt: "); + VSB_cat(tl->sb, "\nAt: "); vcc_ErrWhere(tl, pu->t); return; } if (vcc_CheckUseRecurse(tl, p, m)) { - vsb_printf(tl->sb, + VSB_printf(tl->sb, "\n...which is the \"%s\" method\n", m->name); return; } From phk at varnish-cache.org Tue May 31 11:36:39 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 31 May 2011 13:36:39 +0200 Subject: [master] 7a226eb Don't add vss and vtcp to libvarnishapi, pull them directly in varnishadm and varnishreplay instead. Message-ID: commit 7a226ebd12958d31734535b4b2362b7ed0013ec4 Author: Poul-Henning Kamp Date: Tue May 31 11:36:12 2011 +0000 Don't add vss and vtcp to libvarnishapi, pull them directly in varnishadm and varnishreplay instead. diff --git a/bin/varnishadm/Makefile.am b/bin/varnishadm/Makefile.am index 2eb182a..3ab6f03 100644 --- a/bin/varnishadm/Makefile.am +++ b/bin/varnishadm/Makefile.am @@ -7,14 +7,16 @@ bin_PROGRAMS = varnishadm dist_man_MANS = varnishadm.1 varnishadm_SOURCES = \ - varnishadm.c + varnishadm.c \ + $(top_builddir)/lib/libvarnish/tcp.c \ + $(top_builddir)/lib/libvarnish/vss.c varnishadm_CFLAGS = @LIBEDIT_CFLAGS@ varnishadm_LDADD = \ $(top_builddir)/lib/libvarnishapi/libvarnishapi.la \ $(top_builddir)/lib/libvarnishcompat/libvarnishcompat.la \ - ${PTHREAD_LIBS} ${NET_LIBS} @LIBEDIT_LIBS@ + ${PTHREAD_LIBS} ${NET_LIBS} @LIBEDIT_LIBS@ ${LIBM} varnishadm.1: $(top_srcdir)/doc/sphinx/reference/varnishadm.rst if HAVE_RST2MAN diff --git a/bin/varnishreplay/Makefile.am b/bin/varnishreplay/Makefile.am index 2df4616..38c8be9 100644 --- a/bin/varnishreplay/Makefile.am +++ b/bin/varnishreplay/Makefile.am @@ -7,12 +7,14 @@ bin_PROGRAMS = varnishreplay dist_man_MANS = varnishreplay.1 varnishreplay_SOURCES = \ - varnishreplay.c + varnishreplay.c \ + $(top_builddir)/lib/libvarnish/tcp.c \ + $(top_builddir)/lib/libvarnish/vss.c varnishreplay_LDADD = \ $(top_builddir)/lib/libvarnishcompat/libvarnishcompat.la \ $(top_builddir)/lib/libvarnishapi/libvarnishapi.la \ - ${PTHREAD_LIBS} ${NET_LIBS} + ${PTHREAD_LIBS} ${NET_LIBS} ${LIBM} varnishreplay.1: $(top_srcdir)/doc/sphinx/reference/varnishreplay.rst if HAVE_RST2MAN diff --git a/lib/libvarnishapi/Makefile.am b/lib/libvarnishapi/Makefile.am index 24422c1..0dff413 100644 --- a/lib/libvarnishapi/Makefile.am +++ b/lib/libvarnishapi/Makefile.am @@ -16,13 +16,11 @@ libvarnishapi_la_SOURCES = \ ../libvarnish/version.c \ ../libvarnish/cli_common.c \ ../libvarnish/cli_auth.c \ - ../libvarnish/tcp.c \ ../libvarnish/vin.c \ ../libvarnish/vmb.c \ ../libvarnish/vre.c \ ../libvarnish/vsb.c \ ../libvarnish/vsha256.c \ - ../libvarnish/vss.c \ base64.c \ vsm.c \ vsl_arg.c \ @@ -32,4 +30,4 @@ libvarnishapi_la_SOURCES = \ libvarnishapi_la_CFLAGS = \ -DVARNISH_STATE_DIR='"${VARNISH_STATE_DIR}"' -libvarnishapi_la_LIBADD = @PCRE_LIBS@ ${LIBM} +libvarnishapi_la_LIBADD = @PCRE_LIBS@ From phk at varnish-cache.org Tue May 31 11:41:36 2011 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 31 May 2011 13:41:36 +0200 Subject: [master] b2c617d Don't muck about with Linux #defines Message-ID: commit b2c617d7be6745d8ba0d96b190a1e99fdf1eafd1 Author: Poul-Henning Kamp Date: Tue May 31 11:41:24 2011 +0000 Don't muck about with Linux #defines diff --git a/lib/libvarnish/tcp.c b/lib/libvarnish/tcp.c index 58c61c6..6c892a0 100644 --- a/lib/libvarnish/tcp.c +++ b/lib/libvarnish/tcp.c @@ -151,7 +151,7 @@ VTCP_filter_http(int sock) return (i); #elif defined(__linux) int defer = 1; - setsockopt(sock, SOL_TCP,VTCP_DEFER_ACCEPT,(char *) &defer, sizeof(int)); + setsockopt(sock, SOL_TCP,TCP_DEFER_ACCEPT,(char *) &defer, sizeof(int)); return (0); #else (void)sock;