From tfheen at varnish-cache.org Fri Nov 1 12:34:22 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Fri, 01 Nov 2013 13:34:22 +0100 Subject: [master] 7b69a1d Make RPM Provide: $varnishabi Message-ID: commit 7b69a1dec56c1834a001cbbd72b94f7e12ab2daf Author: Tollef Fog Heen Date: Fri Nov 1 13:33:38 2013 +0100 Make RPM Provide: $varnishabi We want VMODs to depend on the right ABI, so we need to provide something they can depend on. Do so, and hook that up with the RPM build process. diff --git a/redhat/Makefile.am b/redhat/Makefile.am index 16ff9d6..ceac128 100644 --- a/redhat/Makefile.am +++ b/redhat/Makefile.am @@ -13,4 +13,5 @@ EXTRA_DIST = \ varnish.params \ varnish.service \ varnishncsa.service \ - varnishlog.service + varnishlog.service \ + find-provides diff --git a/redhat/find-provides b/redhat/find-provides new file mode 100755 index 0000000..bf3ed59 --- /dev/null +++ b/redhat/find-provides @@ -0,0 +1,13 @@ +#! /bin/sh + +# This script is used to inject the Varnish ABI into the provides. + +set -x + +if [ -x /usr/lib/rpm/find-requires ]; then + /usr/lib/rpm/find-requires "$@" +fi + +cd $(dirname $0)/.. + +printf '#include "vmod_abi.h"\nVMOD_ABI_Version' | cpp - -Iinclude | sed '/^#/D;s/"//g;s/\([A-Z]\)/\L\1/g;s/[^a-z0-9.]/-/g;s/varnish/varnishabi/' diff --git a/redhat/varnish.spec b/redhat/varnish.spec index a489486..e12da5a 100644 --- a/redhat/varnish.spec +++ b/redhat/varnish.spec @@ -1,6 +1,7 @@ %define v_rc %define vd_rc %{?v_rc:-%{?v_rc}} - +%define _use_internal_dependency_generator 0 +%define __find_provides %{_builddir}/varnish-%{version}%{?v_rc:-%{?v_rc}}/redhat/find-provides Summary: High-performance HTTP accelerator Name: varnish Version: 4.0.0 From phk at varnish-cache.org Mon Nov 4 11:29:12 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 04 Nov 2013 12:29:12 +0100 Subject: [master] 744c5ad Fix two issues in our backtrace code: Message-ID: commit 744c5ad3e02b3a440be0e0e2b009b369e5d3172f Author: Poul-Henning Kamp Date: Mon Nov 4 11:22:36 2013 +0000 Fix two issues in our backtrace code: use "nm -an", not "nm -agn" which supresses local symbols. Let backtrace_symbols() handle anything past _end. diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index e3368df..fd64b2f 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -237,7 +237,9 @@ 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); + if (!strcmp(s0->n, "_end")) + return (-1); + VSB_printf(vsb, "%p: %s+0x%jx", ptr, s0->n, (uintmax_t)pp - s0->a); return (0); } @@ -249,7 +251,7 @@ Symbol_hack(const char *a0) uintptr_t a; struct symbols *s; - bprintf(buf, "nm -agn %s 2>/dev/null", a0); + bprintf(buf, "nm -an %s 2>/dev/null", a0); fi = popen(buf, "r"); if (fi == NULL) return; From phk at varnish-cache.org Mon Nov 4 11:38:09 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 04 Nov 2013 12:38:09 +0100 Subject: [master] 69455be Unhide the functions we emit, so they appear in a backtrace. Message-ID: commit 69455becb50a2e168bffe41825194335ebd74352 Author: Poul-Henning Kamp Date: Mon Nov 4 11:37:53 2013 +0000 Unhide the functions we emit, so they appear in a backtrace. diff --git a/lib/libvcc/vcc_compile.c b/lib/libvcc/vcc_compile.c index 41b8ede..70f976a 100644 --- a/lib/libvcc/vcc_compile.c +++ b/lib/libvcc/vcc_compile.c @@ -694,7 +694,11 @@ vcc_CompileSource(const struct vcc *tl0, struct vsb *sb, struct source *sp) /* Emit method functions */ for (i = 0; i < VCL_MET_MAX; i++) { - Fc(tl, 1, "\nstatic int __match_proto__(vcl_func_f)\n"); + Fh(tl, 1, "\nint __match_proto__(vcl_func_f)\n"); + Fh(tl, 1, + "VGC_function_%s(const struct vrt_ctx *ctx);\n", + method_tab[i].name); + Fc(tl, 1, "\nint __match_proto__(vcl_func_f)\n"); Fc(tl, 1, "VGC_function_%s(const struct vrt_ctx *ctx)\n", method_tab[i].name); diff --git a/lib/libvcc/vcc_parse.c b/lib/libvcc/vcc_parse.c index e161b89..500f87e 100644 --- a/lib/libvcc/vcc_parse.c +++ b/lib/libvcc/vcc_parse.c @@ -250,9 +250,9 @@ vcc_ParseFunction(struct vcc *tl) return; } tl->curproc = vcc_AddProc(tl, tl->t); - Fh(tl, 0, "static int VGC_function_%.*s " + Fh(tl, 0, "int VGC_function_%.*s " "(const struct vrt_ctx *ctx);\n", PF(tl->t)); - Fc(tl, 1, "\nstatic int __match_proto__(vcl_func_t)\n"); + Fc(tl, 1, "\nint __match_proto__(vcl_func_t)\n"); Fc(tl, 1, "VGC_function_%.*s(const struct vrt_ctx *ctx)\n", PF(tl->t)); } From phk at varnish-cache.org Tue Nov 5 08:23:20 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 05 Nov 2013 09:23:20 +0100 Subject: [master] 6d86cd1 Don't hand objects over to EXP until we have fetched the body. Message-ID: commit 6d86cd16afaddf546ef1d6e362a9b80e30c642f6 Author: Poul-Henning Kamp Date: Tue Nov 5 08:22:26 2013 +0000 Don't hand objects over to EXP until we have fetched the body. This closes (some of) a race where EXP would start to dismantle an object while it was still being streamed. Also spotted by: jw diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 6a177b5..49ea75f 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -422,13 +422,8 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) assert(bo->refcount >= 1); AZ(bo->ws_o->overflow); - if (bo->do_stream) { + if (bo->do_stream) HSH_Unbusy(&wrk->stats, obj->objcore); - if (!(obj->objcore->flags & OC_F_PRIVATE)) { - EXP_Insert(obj->objcore); - AN(obj->objcore->ban); - } - } if (bo->vfp == NULL) bo->vfp = &VFP_nop; @@ -437,13 +432,14 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) VBO_setstate(bo, BOS_FETCHING); V1F_fetch_body(wrk, bo); - if (!bo->do_stream && bo->state != BOS_FAILED) { + if (!bo->do_stream && bo->state != BOS_FAILED) HSH_Unbusy(&wrk->stats, obj->objcore); - if (!(bo->fetch_obj->objcore->flags & OC_F_PRIVATE)) { - EXP_Insert(obj->objcore); - AN(obj->objcore->ban); - } + + if (bo->state != BOS_FAILED && !(obj->objcore->flags & OC_F_PRIVATE)) { + EXP_Insert(obj->objcore); + AN(obj->objcore->ban); } + HSH_Complete(obj->objcore); assert(bo->refcount >= 1); diff --git a/bin/varnishd/cache/cache_obj.c b/bin/varnishd/cache/cache_obj.c index 95862ae..b7bd8d8 100644 --- a/bin/varnishd/cache/cache_obj.c +++ b/bin/varnishd/cache/cache_obj.c @@ -94,6 +94,7 @@ ObjIter(struct objiter *oi, void **p, ssize_t *l) return (OIS_ERROR); } Lck_Lock(&oi->bo->mtx); + AZ(VTAILQ_EMPTY(&oi->obj->store)); VTAILQ_FOREACH(oi->st, &oi->obj->store, list) { if (oi->st->len > ol) { *p = oi->st->ptr + ol; @@ -104,6 +105,7 @@ ObjIter(struct objiter *oi, void **p, ssize_t *l) ol -= oi->st->len; nl -= oi->st->len; } + CHECK_OBJ_NOTNULL(oi->st, STORAGE_MAGIC); oi->st = VTAILQ_NEXT(oi->st, list); if (oi->st != NULL && oi->st->len == 0) oi->st = NULL; diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 37ec19e..9218584 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -105,7 +105,8 @@ cnt_deliver(struct worker *wrk, struct req *req) req->t_resp = W_TIM_real(wrk); if (!(req->obj->objcore->flags & OC_F_PRIVATE)) { - if ((req->t_resp - req->obj->objcore->last_lru) > + if (req->obj->objcore->busyobj == NULL && + (req->t_resp - req->obj->objcore->last_lru) > cache_param->lru_timeout && EXP_Touch(req->obj->objcore)) req->obj->objcore->last_lru = req->t_resp; } From phk at varnish-cache.org Tue Nov 5 15:54:14 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 05 Nov 2013 16:54:14 +0100 Subject: [master] 97351b9 Add an assert for clarity. Message-ID: commit 97351b93562199f491d54358c1c99f362416fef4 Author: Poul-Henning Kamp Date: Tue Nov 5 15:54:02 2013 +0000 Add an assert for clarity. diff --git a/lib/libvarnish/cli_serve.c b/lib/libvarnish/cli_serve.c index 43c4ecf..3ea59d6 100644 --- a/lib/libvarnish/cli_serve.c +++ b/lib/libvarnish/cli_serve.c @@ -328,6 +328,7 @@ cls_vlu(void *priv, const char *p) char **av; CAST_OBJ_NOTNULL(cfd, priv, VCLS_FD_MAGIC); + AN(p); cli = cfd->cli; CHECK_OBJ_NOTNULL(cli, CLI_MAGIC); From phk at varnish-cache.org Tue Nov 5 21:18:02 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 05 Nov 2013 22:18:02 +0100 Subject: [master] d72f3bb Add more paranoia. Message-ID: commit d72f3bbbafa32ca90d5d95d71785bf6973f1cdd9 Author: Poul-Henning Kamp Date: Tue Nov 5 21:17:52 2013 +0000 Add more paranoia. diff --git a/bin/varnishd/cache/cache_http1_fetch.c b/bin/varnishd/cache/cache_http1_fetch.c index 57384f3..bd1cc47 100644 --- a/bin/varnishd/cache/cache_http1_fetch.c +++ b/bin/varnishd/cache/cache_http1_fetch.c @@ -421,7 +421,6 @@ V1F_fetch_body(struct worker *wrk, struct busyobj *bo) if (bo->state == BOS_FAILED) { wrk->stats.fetch_failed++; - obj->len = 0; } else { assert(bo->state == BOS_FETCHING); diff --git a/bin/varnishd/cache/cache_obj.c b/bin/varnishd/cache/cache_obj.c index b7bd8d8..739d7ab 100644 --- a/bin/varnishd/cache/cache_obj.c +++ b/bin/varnishd/cache/cache_obj.c @@ -65,6 +65,7 @@ ObjIter(struct objiter *oi, void **p, ssize_t *l) ssize_t nl; CHECK_OBJ_NOTNULL(oi, OBJITER_MAGIC); + CHECK_OBJ_NOTNULL(oi->obj, OBJECT_MAGIC); AN(p); AN(l); *p = NULL; @@ -105,6 +106,7 @@ ObjIter(struct objiter *oi, void **p, ssize_t *l) ol -= oi->st->len; nl -= oi->st->len; } + CHECK_OBJ_NOTNULL(oi->obj, OBJECT_MAGIC); CHECK_OBJ_NOTNULL(oi->st, STORAGE_MAGIC); oi->st = VTAILQ_NEXT(oi->st, list); if (oi->st != NULL && oi->st->len == 0) @@ -121,6 +123,7 @@ ObjIterEnd(struct objiter **oi) AN(oi); CHECK_OBJ_NOTNULL((*oi), OBJITER_MAGIC); + CHECK_OBJ_NOTNULL((*oi)->obj, OBJECT_MAGIC); if ((*oi)->bo != NULL) VBO_DerefBusyObj((*oi)->wrk, &(*oi)->bo); FREE_OBJ((*oi)); diff --git a/bin/varnishd/storage/stevedore.c b/bin/varnishd/storage/stevedore.c index aa5d7eb..5d91630 100644 --- a/bin/varnishd/storage/stevedore.c +++ b/bin/varnishd/storage/stevedore.c @@ -77,6 +77,7 @@ default_oc_freeobj(struct objcore *oc) CAST_OBJ_NOTNULL(o, oc->priv, OBJECT_MAGIC); oc->priv = NULL; oc->methods = NULL; + o->magic = 0; STV_Freestore(o); STV_free(o->objstore); From phk at varnish-cache.org Tue Nov 5 22:05:05 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 05 Nov 2013 23:05:05 +0100 Subject: [master] 27c7ff0 Snapshot obj->st->len so it staus consistent in the loop. Message-ID: commit 27c7ff03ceb4a00811bfa546ee7e176bb880b182 Author: Poul-Henning Kamp Date: Tue Nov 5 22:04:38 2013 +0000 Snapshot obj->st->len so it staus consistent in the loop. diff --git a/bin/varnishd/cache/cache_obj.c b/bin/varnishd/cache/cache_obj.c index 739d7ab..5b3dab9 100644 --- a/bin/varnishd/cache/cache_obj.c +++ b/bin/varnishd/cache/cache_obj.c @@ -63,6 +63,7 @@ ObjIter(struct objiter *oi, void **p, ssize_t *l) { ssize_t ol; ssize_t nl; + volatile unsigned u; CHECK_OBJ_NOTNULL(oi, OBJITER_MAGIC); CHECK_OBJ_NOTNULL(oi->obj, OBJECT_MAGIC); @@ -97,14 +98,15 @@ ObjIter(struct objiter *oi, void **p, ssize_t *l) Lck_Lock(&oi->bo->mtx); AZ(VTAILQ_EMPTY(&oi->obj->store)); VTAILQ_FOREACH(oi->st, &oi->obj->store, list) { - if (oi->st->len > ol) { + u = (volatile unsigned)(oi->st->len); + if (u > ol) { *p = oi->st->ptr + ol; - *l = oi->st->len - ol; + *l = u - ol; oi->len += *l; break; } - ol -= oi->st->len; - nl -= oi->st->len; + ol -= u; + nl -= u; } CHECK_OBJ_NOTNULL(oi->obj, OBJECT_MAGIC); CHECK_OBJ_NOTNULL(oi->st, STORAGE_MAGIC); From phk at varnish-cache.org Tue Nov 5 22:36:45 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 05 Nov 2013 23:36:45 +0100 Subject: [master] 23c608f Update st->len inside the bo->mtx in VBO_extend() so that it is always synchronized with obj->len. Message-ID: commit 23c608f75f895ec4c2e5b9a306b3683d5526216e Author: Poul-Henning Kamp Date: Tue Nov 5 22:36:07 2013 +0000 Update st->len inside the bo->mtx in VBO_extend() so that it is always synchronized with obj->len. diff --git a/bin/varnishd/cache/cache_busyobj.c b/bin/varnishd/cache/cache_busyobj.c index 3891156..38da061 100644 --- a/bin/varnishd/cache/cache_busyobj.c +++ b/bin/varnishd/cache/cache_busyobj.c @@ -212,6 +212,7 @@ VBO_DerefBusyObj(struct worker *wrk, struct busyobj **pbo) void VBO_extend(struct busyobj *bo, ssize_t l) { + struct storage *st; CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(bo->fetch_obj, OBJECT_MAGIC); @@ -219,6 +220,8 @@ VBO_extend(struct busyobj *bo, ssize_t l) return; assert(l > 0); Lck_Lock(&bo->mtx); + st = VTAILQ_LAST(&bo->fetch_obj->store, storagehead); + st->len += l; bo->fetch_obj->len += l; AZ(pthread_cond_signal(&bo->cond)); Lck_Unlock(&bo->mtx); diff --git a/bin/varnishd/cache/cache_esi_fetch.c b/bin/varnishd/cache/cache_esi_fetch.c index c3274b1..6218cc2 100644 --- a/bin/varnishd/cache/cache_esi_fetch.c +++ b/bin/varnishd/cache/cache_esi_fetch.c @@ -101,7 +101,6 @@ vfp_esi_bytes_uu(struct busyobj *bo, const struct vef_priv *vef, if (wl <= 0) return (wl); VEP_Parse(bo, (const char *)st->ptr + st->len, wl); - st->len += wl; VBO_extend(bo, wl); bytes -= wl; } diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 49ea75f..ce74d35 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -541,7 +541,6 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo) if (tl > st->space - st->len) tl = st->space - st->len; memcpy(st->ptr + st->len, sp, tl); - st->len += tl; al += tl; sp = (char *)sp + tl; sl -= tl; diff --git a/bin/varnishd/cache/cache_fetch_proc.c b/bin/varnishd/cache/cache_fetch_proc.c index b1da1db..97a35c2 100644 --- a/bin/varnishd/cache/cache_fetch_proc.c +++ b/bin/varnishd/cache/cache_fetch_proc.c @@ -129,7 +129,6 @@ vfp_nop_bytes(struct busyobj *bo, struct http_conn *htc, ssize_t bytes) wl = HTTP1_Read(htc, st->ptr + st->len, l); if (wl <= 0) return (wl); - st->len += wl; VBO_extend(bo, wl); bytes -= wl; } diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c index a95c4d4..4c8f9e2 100644 --- a/bin/varnishd/cache/cache_gzip.c +++ b/bin/varnishd/cache/cache_gzip.c @@ -55,8 +55,6 @@ struct vgz { char *tmp_snapshot; int last_i; - struct storage *st_obuf; - /* Wrw stuff */ char *m_buf; ssize_t m_sz; @@ -210,7 +208,6 @@ VGZ_ObufStorage(struct busyobj *bo, struct vgz *vg) if (st == NULL) return (-1); - vg->st_obuf = st; VGZ_Obuf(vg, st->ptr + st->len, st->space - st->len); return (0); @@ -237,8 +234,6 @@ VGZ_Gunzip(struct vgz *vg, const void **pptr, size_t *plen) *pptr = before; l = (const uint8_t *)vg->vz.next_out - before; *plen = l; - if (vg->st_obuf != NULL) - vg->st_obuf->len += l; } vg->last_i = i; if (i == Z_OK) @@ -280,8 +275,6 @@ VGZ_Gzip(struct vgz *vg, const void **pptr, size_t *plen, enum vgz_flag flags) *pptr = before; l = (const uint8_t *)vg->vz.next_out - before; *plen = l; - if (vg->st_obuf != NULL) - vg->st_obuf->len += l; } vg->last_i = i; if (i == Z_OK) @@ -683,7 +676,6 @@ vfp_testgzip_bytes(struct busyobj *bo, struct http_conn *htc, ssize_t bytes) return (wl); bytes -= wl; VGZ_Ibuf(vg, st->ptr + st->len, wl); - st->len += wl; VBO_extend(bo, wl); while (!VGZ_IbufEmpty(vg)) { diff --git a/bin/varnishd/cache/cache_obj.c b/bin/varnishd/cache/cache_obj.c index 5b3dab9..c59ebf9 100644 --- a/bin/varnishd/cache/cache_obj.c +++ b/bin/varnishd/cache/cache_obj.c @@ -63,7 +63,6 @@ ObjIter(struct objiter *oi, void **p, ssize_t *l) { ssize_t ol; ssize_t nl; - volatile unsigned u; CHECK_OBJ_NOTNULL(oi, OBJITER_MAGIC); CHECK_OBJ_NOTNULL(oi->obj, OBJECT_MAGIC); @@ -98,15 +97,16 @@ ObjIter(struct objiter *oi, void **p, ssize_t *l) Lck_Lock(&oi->bo->mtx); AZ(VTAILQ_EMPTY(&oi->obj->store)); VTAILQ_FOREACH(oi->st, &oi->obj->store, list) { - u = (volatile unsigned)(oi->st->len); - if (u > ol) { + if (oi->st->len > ol) { *p = oi->st->ptr + ol; - *l = u - ol; + *l = oi->st->len - ol; oi->len += *l; break; } - ol -= u; - nl -= u; + ol -= oi->st->len; + assert(ol >= 0); + nl -= oi->st->len; + assert(nl > 0); } CHECK_OBJ_NOTNULL(oi->obj, OBJECT_MAGIC); CHECK_OBJ_NOTNULL(oi->st, STORAGE_MAGIC); From phk at varnish-cache.org Thu Nov 7 15:04:35 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Thu, 07 Nov 2013 16:04:35 +0100 Subject: [master] c09887a Trains are good for writing documentation :-) Message-ID: commit c09887aef3b4d816eea59a8cce962ec35186e72e Author: Poul-Henning Kamp Date: Thu Nov 7 15:04:03 2013 +0000 Trains are good for writing documentation :-) diff --git a/doc/sphinx/users-guide/command-line.rst b/doc/sphinx/users-guide/command-line.rst index 2bf7e2d..d3b5240 100644 --- a/doc/sphinx/users-guide/command-line.rst +++ b/doc/sphinx/users-guide/command-line.rst @@ -3,46 +3,94 @@ Typical command line options ---------------------------- -On a modern Linux distro the various options that are used when -starting up Varnish are stored in /etc/default/varnish (Debian, Ubuntu) or -/etc/sysconfig/varnish (Red Hat, Centos). +If you run Varnish out of a package for your operating system, +you will find the default options here: -There are quite a few options you can tweak but most of you will only -need to change a few them. +* Debian, Ubuntu: /etc/default/varnish +* Red Hat, Centos: /etc/sysconfig/varnish +* FreeBSD: /etc/rc.conf (See also: /usr/local/etc/rc.d/varnishd) -The typical command line options you want to change are: +There some command line options you will simply have choose values for: -a *listen_address* - What address should Varnish listen to. The default is to listen to - all IP adresses and stick to port 80. ":80" will ask Varnish to - listen to all adresses, both IPv4 and IPv6 and is probably a - sensible thing. +^^^^^^^^^^^^^^^^^^^ + +What address should Varnish listen to and service HTTP requests on. + +You will most likely want to set this to ":80" which is the Well +Known Port for HTTP. + +You can specify multiple addresses separated by a comma, and you +can use numeric or host/service names as you like, varnish will try +to open and service as many of them as possible, but if none of them +can be opened, varnishd will not start. + +Here are some examples:: + + -a :80 + -a localhost:80 + -a 192.168.1.100:8080 + -a '[fe80::1]:80' + -a '0.0.0.0:8080,[::]:8081' + +If your webserver runs on the same computer, you will have to move +it to another port number first. --f *config file* - The -f options specifies what VCL file Varnish should use as the default. - --s *storage options* - - This is probably the most important one. The default is to use - the memory storage backend and to allocate a small amount of - memory. On a small site this might suffice. If you have dedicated - Varnish Cache server you most definitivly want to increase - the memory allocated or consider another backend. - Please note that in addition to the memory allocated by the - storage engine itself Varnish also has internal data structures - that consume memory. More or less 1kb per object. - See also :ref:`guide-storage`. - --T *listen address* - Varnish has a built-in text-based administration - interface. Activating the interface makes Varnish manageble - without stopping it. You can specify what interface the - management interface should listen to. Make sure you don't expose - the management interface to the world as you can easily gain root - access to a system via the Varnish management interface. I - recommend tieing it to localhost. If you have users on your - system that you don't fully trust, use firewall rules to restrict - access to the interface to root only. +-f *VCL-file* or -b *backend* +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Varnish needs to know where to find the HTTP server it is caching for. +You can either specify it with -b and use the default VCL code, or you +can put it in your own VCL file. + +Using -b is a quick way to get started:: + + -b localhost:81 + -b thatotherserver.example.com:80 + -b 192.168.1.2:80 + +Notice that if you specify a name, it can at most resolve to one IPv4 +*and* one IPv6 address. + +If you go with -f, you can start with a VCL file containing just:: + + backend default { + .host = "localhost:81"; + } + +which is exactly what -b does. + +-s *storage-options* +^^^^^^^^^^^^^^^^^^^^ + +This is probably the most important one. The default is to use +the memory storage backend and to allocate a small amount of +memory. On a small site this might suffice. If you have dedicated +Varnish Cache server you most definitivly want to increase +the memory allocated or consider another backend. +Please note that in addition to the memory allocated by the +storage engine itself Varnish also has internal data structures +that consume memory. More or less 1kb per object. +See also :ref:`guide-storage`. + +-T *CLI-listen-address* +^^^^^^^^^^^^^^^^^^^^^^^ + +Varnish has a built-in text-based administration +interface. Activating the interface makes Varnish manageble +without stopping it. You can specify what interface the +management interface should listen to. Make sure you don't expose +the management interface to the world as you can easily gain root +access to a system via the Varnish management interface. I +recommend tieing it to localhost. If you have users on your +system that you don't fully trust, use firewall rules to restrict +access to the interface to root only. + +-S *CLI-secret-file* +^^^^^^^^^^^^^^^^^^^^ + +This file stores a secret you must know, in order to get +access to the CLI. For a complete list of the command line parameters please see :ref:`ref-varnishd-options`. diff --git a/doc/sphinx/users-guide/run_security.rst b/doc/sphinx/users-guide/run_security.rst index 4267a93..080bb80 100644 --- a/doc/sphinx/users-guide/run_security.rst +++ b/doc/sphinx/users-guide/run_security.rst @@ -80,14 +80,17 @@ and give remote users access via a secure connection to the local machine (ssh, VPN, etc. etc.) It is also possible to configure varnishd for "reverse mode", using -the '-M' argument, - -In this case varnishd will attempt to open a TCP connection to the -specified address, and initiate a CLI connection on it. +the '-M' argument. In that case varnishd will attempt to open a +TCP connection to the specified address, and initiate a CLI connection +to your central varnish management facility. The connection is also in this case without secrecy, but if configured the remote end must still satisfy -S/PSK authentication. +Finally, if you run varnishd with the '-d' option, you get a CLI +command on stdin/stdout, but since you started the process, it +would be hard to prevent you getting CLI access, wouldn't it ? + Parameters ^^^^^^^^^^ @@ -130,7 +133,7 @@ We do not currently have a way to restrict specific CLI commands to specific CLI connections. One way to get such an effect is to "wrap" all CLI access in pre-approved scripts which use varnishadm(1) to submit the sanitized CLI commands, and restrict a remote user -to only those scripts in sshd(8)'s configuration. +to only those scripts, for instance using sshd(8)'s configuration. VCL programs ------------ @@ -151,7 +154,7 @@ lower the privilege of a child process... Inline-C is disabled by default starting with Varnish 4, so unless you enable it, you don't have to worry about it. -The params mentioned above can restrict VMOD so they can only +The parameters mentioned above can restrict VMOD, so they can only be imported from a designated directory, restricting VCL wranglers to a pre-approved subset of VMODs. @@ -171,7 +174,7 @@ to do exactly stupid things to them, including opening youself up to various kinds of attacks and subversive activities. If you have "administrative" HTTP requests, for instance PURGE -requests, we recommend that you restrict them to trusted IP -numbers/nets using VCL's Access Control Lists. +requests, we strongly recommend that you restrict them to trusted +IP numbers/nets using VCL's Access Control Lists. (XXX: missing ref to ACL) From phk at varnish-cache.org Thu Nov 7 16:10:27 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Thu, 07 Nov 2013 17:10:27 +0100 Subject: [master] 909a1ef Change -S semantics a bit. Message-ID: commit 909a1efbea8be8276e89dd8a1ceba28d87125c90 Author: Poul-Henning Kamp Date: Thu Nov 7 16:08:43 2013 +0000 Change -S semantics a bit. If you specify no -S file, one will be made for you. If you truly want no authentication of CLI connections, give an empty -S argument (-S "") and live with the warning that causes. Use arc4random() for challenges and secrets, we want crypto strength. diff --git a/bin/varnishd/mgt/mgt_cli.c b/bin/varnishd/mgt/mgt_cli.c index 3e43709..6233c79 100644 --- a/bin/varnishd/mgt/mgt_cli.c +++ b/bin/varnishd/mgt/mgt_cli.c @@ -260,7 +260,7 @@ mgt_cli_challenge(struct cli *cli) int i; for (i = 0; i + 2L < sizeof cli->challenge; i++) - cli->challenge[i] = (random() % 26) + 'a'; + cli->challenge[i] = (arc4random() % 26) + 'a'; cli->challenge[i++] = '\n'; cli->challenge[i] = '\0'; VCLI_Out(cli, "%s", cli->challenge); @@ -499,7 +499,6 @@ mgt_cli_secret(const char *S_arg) /* Save in shmem */ mgt_SHM_static_alloc(S_arg, strlen(S_arg) + 1L, "Arg", "-S", ""); - srandomdev(); /* XXX: why here ??? */ fd = open(S_arg, O_RDONLY); if (fd < 0) { fprintf(stderr, "Can not open secret-file \"%s\"\n", S_arg); diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index fd64b2f..bcffbda 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -311,6 +311,29 @@ cli_stdin_close(void *priv) /*--------------------------------------------------------------------*/ +static const char * +make_secret(const char *dirname) +{ + char *fn; + int fd; + char buf[256]; + + assert(asprintf(&fn, "%s/_.secret", dirname) > 0); + + fd = open(fn, O_RDWR|O_CREAT|O_TRUNC, 0600); + if (fd < 0) { + fprintf(stderr, "Cannot create secret-file in %s (%s)\n", + dirname, strerror(errno)); + exit(1); + } + arc4random_buf(buf, sizeof buf); + assert(sizeof buf == write(fd, buf, sizeof buf)); + AZ(close(fd)); + return (fn); +} + +/*--------------------------------------------------------------------*/ + int main(int argc, char * const *argv) { @@ -538,14 +561,18 @@ main(int argc, char * const *argv) fprintf(stderr, "Only one of -b or -f can be specified\n"); usage(); } - if (S_arg == NULL && T_arg == NULL && d_flag == 0 && b_arg == NULL && + if (T_arg == NULL && d_flag == 0 && b_arg == NULL && f_arg == NULL && M_arg == NULL) { fprintf(stderr, - "At least one of -d, -b, -f, -M, -S or -T " + "At least one of -d, -b, -f, -M or -T " "must be specified\n"); usage(); } + if (S_arg != NULL && *S_arg == '\0') + fprintf(stderr, + "Warning: Empty -S argument, no CLI authentication.\n"); + if (f_arg != NULL) { vcl = VFIL_readfile(NULL, f_arg, NULL); if (vcl == NULL) { @@ -651,8 +678,14 @@ main(int argc, char * const *argv) if (d_flag) mgt_cli_setup(0, 1, 1, "debug", cli_stdin_close, NULL); - if (S_arg != NULL) + + if (S_arg == NULL) + S_arg = make_secret(dirname); + AN(S_arg); + + if (*S_arg != '\0') mgt_cli_secret(S_arg); + if (M_arg != NULL) mgt_cli_master(M_arg); if (T_arg != NULL) From phk at varnish-cache.org Thu Nov 7 16:16:40 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Thu, 07 Nov 2013 17:16:40 +0100 Subject: [master] 82dab3a Rely on the new default -S argument Message-ID: commit 82dab3a952a8aaf54f63cf9a5c88f29a580e0589 Author: Poul-Henning Kamp Date: Thu Nov 7 16:16:28 2013 +0000 Rely on the new default -S argument diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c index 12b6dd3..e5a520c 100644 --- a/bin/varnishtest/vtc_varnish.c +++ b/bin/varnishtest/vtc_varnish.c @@ -277,8 +277,7 @@ varnish_new(const char *name) AN(v->workdir); VSB_delete(vsb); - bprintf(buf, "rm -rf %s ; mkdir -p %s ; echo ' %ld' > %s/_S", - v->workdir, v->workdir, random(), v->workdir); + bprintf(buf, "rm -rf %s ; mkdir -p %s", v->workdir, v->workdir); AZ(system(buf)); if (*v->name != 'v') @@ -390,7 +389,6 @@ varnish_launch(struct varnish *v) 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)); @@ -470,7 +468,7 @@ varnish_launch(struct varnish *v) if (u != CLIS_AUTH) vtc_log(v->vl, 0, "CLI auth demand expected: %u %s", u, r); - bprintf(abuf, "%s/_S", v->workdir); + bprintf(abuf, "%s/_.secret", v->workdir); nfd = open(abuf, O_RDONLY); assert(nfd >= 0); From phk at varnish-cache.org Thu Nov 7 18:42:00 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Thu, 07 Nov 2013 19:42:00 +0100 Subject: [master] a4997b9 OK, now I remember why we don't use arc4random(). Message-ID: commit a4997b9bde66fcad8468a770e6cbfdd442d3885b Author: Poul-Henning Kamp Date: Thu Nov 7 18:41:34 2013 +0000 OK, now I remember why we don't use arc4random(). diff --git a/bin/varnishd/mgt/mgt_cli.c b/bin/varnishd/mgt/mgt_cli.c index 6233c79..e19241f 100644 --- a/bin/varnishd/mgt/mgt_cli.c +++ b/bin/varnishd/mgt/mgt_cli.c @@ -259,8 +259,9 @@ mgt_cli_challenge(struct cli *cli) { int i; + srandomdev(); for (i = 0; i + 2L < sizeof cli->challenge; i++) - cli->challenge[i] = (arc4random() % 26) + 'a'; + cli->challenge[i] = (random() % 26) + 'a'; cli->challenge[i++] = '\n'; cli->challenge[i] = '\0'; VCLI_Out(cli, "%s", cli->challenge); diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index bcffbda..5debd26 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -316,6 +316,7 @@ make_secret(const char *dirname) { char *fn; int fd; + int i; char buf[256]; assert(asprintf(&fn, "%s/_.secret", dirname) > 0); @@ -326,7 +327,9 @@ make_secret(const char *dirname) dirname, strerror(errno)); exit(1); } - arc4random_buf(buf, sizeof buf); + srandomdev(); + for (i = 0; i < sizeof buf; i++) + buf[i] = random(); assert(sizeof buf == write(fd, buf, sizeof buf)); AZ(close(fd)); return (fn); From phk at varnish-cache.org Fri Nov 8 10:43:30 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Fri, 08 Nov 2013 11:43:30 +0100 Subject: [master] 857cdae White-space cleanup of test-cases Message-ID: commit 857cdaebc929ebbcf36c8805c94a2ea6a0268669 Author: Poul-Henning Kamp Date: Fri Nov 8 10:43:14 2013 +0000 White-space cleanup of test-cases diff --git a/bin/varnishtest/tests.disabled/r00693.vtc b/bin/varnishtest/tests.disabled/r00693.vtc index ff99ca7..bf94f6b 100644 --- a/bin/varnishtest/tests.disabled/r00693.vtc +++ b/bin/varnishtest/tests.disabled/r00693.vtc @@ -20,7 +20,7 @@ server s1 { varnish v1 -arg "-p workspace_client=3072" -vcl+backend { sub vcl_recv { - set req.http.foo = + set req.http.foo = req.http.bar + "0123456789abcdef" + "0123456789abcdef" + "0123456789abcdef" + "0123456789abcdef" + @@ -47,18 +47,18 @@ varnish v1 -arg "-p workspace_client=3072" -vcl+backend { client c1 { # This should soak up all bytes but the last in the workspace - txreq -hdr "foo: x" -hdr "bar: A" + txreq -hdr "foo: x" -hdr "bar: A" rxresp expect resp.status == 201 # This should soak up all bytes in the workspace - txreq -hdr "foo: x" -hdr "bar: AB" + txreq -hdr "foo: x" -hdr "bar: AB" rxresp expect resp.status == 202 # This overcommits the workspace, failing the "bar" set, # Thus allowing the "baz" set to work. - txreq -hdr "foo: x" -hdr "bar: ABC" + txreq -hdr "foo: x" -hdr "bar: ABC" rxresp expect resp.status == 203 diff --git a/bin/varnishtest/tests.disabled/r00980.vtc b/bin/varnishtest/tests.disabled/r00980.vtc index f14113f..006de3e 100644 --- a/bin/varnishtest/tests.disabled/r00980.vtc +++ b/bin/varnishtest/tests.disabled/r00980.vtc @@ -22,7 +22,7 @@ client c1 { gunzip expect resp.bodylen == 43 - txreq -url /foobar + txreq -url /foobar rxresp expect resp.http.content-encoding == expect resp.bodylen == 43 diff --git a/bin/varnishtest/tests.disabled/t00000.vtc b/bin/varnishtest/tests.disabled/t00000.vtc index cc47769..7dd5818 100644 --- a/bin/varnishtest/tests.disabled/t00000.vtc +++ b/bin/varnishtest/tests.disabled/t00000.vtc @@ -1,7 +1,7 @@ varnishtest "Ticket #873" server s1 { - rxreq + rxreq txresp -nolen -hdr "Transfer-encoding: chunked" chunked "<1>------------------------<1>\n" sema r1 sync 2 @@ -18,7 +18,7 @@ varnish v1 -vcl+backend { sub vcl_backend_response { set beresp.do_stream = true; } -} -start +} -start varnish v1 -cliok "param.set debug +req_state" diff --git a/bin/varnishtest/tests.disabled/t00001.vtc b/bin/varnishtest/tests.disabled/t00001.vtc index f6a3944..4250b1a 100644 --- a/bin/varnishtest/tests.disabled/t00001.vtc +++ b/bin/varnishtest/tests.disabled/t00001.vtc @@ -31,20 +31,20 @@ varnish v1 -vcl+backend { } set beresp.do_stream = true; } -} -start +} -start client c1 { txreq -url /bar - rxresp + rxresp expect resp.http.content-length == 6 expect resp.bodylen == 6 txreq -url /bla - rxresp + rxresp expect resp.bodylen == 9 txreq -url /foo - rxresp + rxresp expect resp.bodylen == 5 txreq -url /barf - rxresp + rxresp expect resp.bodylen == 21 } -run diff --git a/bin/varnishtest/tests/a00000.vtc b/bin/varnishtest/tests/a00000.vtc index d368014..ca02903 100644 --- a/bin/varnishtest/tests/a00000.vtc +++ b/bin/varnishtest/tests/a00000.vtc @@ -2,13 +2,13 @@ varnishtest "basic default HTTP transactions" server s1 { rxreq - txresp + txresp } -server s1 -start +server s1 -start client c1 -connect ${s1_sock} { - txreq + txreq rxresp } diff --git a/bin/varnishtest/tests/a00001.vtc b/bin/varnishtest/tests/a00001.vtc index 0fc6de9..04106fe 100644 --- a/bin/varnishtest/tests/a00001.vtc +++ b/bin/varnishtest/tests/a00001.vtc @@ -5,13 +5,13 @@ server s1 { expect req.method == GET expect req.proto == HTTP/1.1 expect req.url == "/" - txresp + txresp } -server s1 -start +server s1 -start client c1 -connect ${s1_sock} { - txreq + txreq rxresp expect resp.proto == HTTP/1.1 expect resp.status == 200 diff --git a/bin/varnishtest/tests/a00002.vtc b/bin/varnishtest/tests/a00002.vtc index 4d0f3df..39b8334 100644 --- a/bin/varnishtest/tests/a00002.vtc +++ b/bin/varnishtest/tests/a00002.vtc @@ -8,7 +8,7 @@ server s1 { txresp -proto HTTP/1.2 -status 201 -msg Foo } -server s1 -start +server s1 -start client c1 -connect ${s1_sock} { txreq -req PUT -proto HTTP/1.0 -url /foo diff --git a/bin/varnishtest/tests/a00003.vtc b/bin/varnishtest/tests/a00003.vtc index 4982730..f928a42 100644 --- a/bin/varnishtest/tests/a00003.vtc +++ b/bin/varnishtest/tests/a00003.vtc @@ -13,11 +13,11 @@ server s2 { expect req.method == GET expect req.proto == HTTP/1.1 expect req.url == "/" - txresp + txresp } -server s1 -start -server s2 -start +server s1 -start +server s2 -start client c1 -connect ${s1_sock} { txreq -req PUT -proto HTTP/1.0 -url /foo @@ -28,7 +28,7 @@ client c1 -connect ${s1_sock} { } client c2 -connect ${s2_sock} { - txreq + txreq rxresp expect resp.proto == HTTP/1.1 expect resp.status == 200 diff --git a/bin/varnishtest/tests/a00004.vtc b/bin/varnishtest/tests/a00004.vtc index 7fbe476..85659ac 100644 --- a/bin/varnishtest/tests/a00004.vtc +++ b/bin/varnishtest/tests/a00004.vtc @@ -8,7 +8,7 @@ server s1 -repeat 2 { txresp -proto HTTP/1.2 -status 201 -msg Foo } -server s1 -start +server s1 -start client c1 -connect ${s1_sock} { txreq -req PUT -proto HTTP/1.0 -url /foo diff --git a/bin/varnishtest/tests/a00005.vtc b/bin/varnishtest/tests/a00005.vtc index 38ae1cf..fcf4e58 100644 --- a/bin/varnishtest/tests/a00005.vtc +++ b/bin/varnishtest/tests/a00005.vtc @@ -13,11 +13,11 @@ server s2 { expect req.method == GET expect req.proto == HTTP/1.1 expect req.url == "/" - txresp + txresp } -server s1 -start -server s2 -start +server s1 -start +server s2 -start client c1 -connect ${s1_sock} { txreq -req PUT -proto HTTP/1.0 -url /foo @@ -30,7 +30,7 @@ client c1 -connect ${s1_sock} { client c1 -run client c1 -connect ${s2_sock} { - txreq + txreq rxresp expect resp.proto == HTTP/1.1 expect resp.status == 200 diff --git a/bin/varnishtest/tests/a00006.vtc b/bin/varnishtest/tests/a00006.vtc index bcd272f..f8a928e 100644 --- a/bin/varnishtest/tests/a00006.vtc +++ b/bin/varnishtest/tests/a00006.vtc @@ -9,7 +9,7 @@ server s1 { -body "987654321\n" } -server s1 -start +server s1 -start client c1 -connect ${s1_sock} { txreq -req PUT -proto HTTP/1.0 -url /foo \ diff --git a/bin/varnishtest/tests/a00007.vtc b/bin/varnishtest/tests/a00007.vtc index 81d80af..5c7312d 100644 --- a/bin/varnishtest/tests/a00007.vtc +++ b/bin/varnishtest/tests/a00007.vtc @@ -9,7 +9,7 @@ server s1 { txresp -body "987654321\n" } -server s1 -start +server s1 -start client c1 -connect ${s1_sock} { txreq -url "/1" -req "POST" -body "abcdefghi\n" diff --git a/bin/varnishtest/tests/a00010.vtc b/bin/varnishtest/tests/a00010.vtc index 1200a69..60b0234 100644 --- a/bin/varnishtest/tests/a00010.vtc +++ b/bin/varnishtest/tests/a00010.vtc @@ -4,16 +4,16 @@ server s1 { rxreq expect req.url == "/" txresp -body {a\0bc} -} +} -server s1 -start +server s1 -start client c1 -connect ${s1_sock} { txreq rxresp expect resp.bodylen == 4 -} +} client c1 -run diff --git a/bin/varnishtest/tests/b00000.vtc b/bin/varnishtest/tests/b00000.vtc index 2e6d5ce..f514f2b 100644 --- a/bin/varnishtest/tests/b00000.vtc +++ b/bin/varnishtest/tests/b00000.vtc @@ -1,7 +1,7 @@ varnishtest "Does anything get through at all ?" server s1 { - rxreq + rxreq txresp -body "012345\n" } -start diff --git a/bin/varnishtest/tests/b00001.vtc b/bin/varnishtest/tests/b00001.vtc index edec601..d48b9a0 100644 --- a/bin/varnishtest/tests/b00001.vtc +++ b/bin/varnishtest/tests/b00001.vtc @@ -1,7 +1,7 @@ varnishtest "Check that a pipe transaction works" server s1 -repeat 1 { - rxreq + rxreq txresp -body "012345\n" } -start diff --git a/bin/varnishtest/tests/b00002.vtc b/bin/varnishtest/tests/b00002.vtc index 8bb7ad3..efa656a 100644 --- a/bin/varnishtest/tests/b00002.vtc +++ b/bin/varnishtest/tests/b00002.vtc @@ -1,7 +1,7 @@ varnishtest "Check that a pass transaction works" server s1 { - rxreq + rxreq txresp -hdr "Connection: close" -body "012345\n" } -start diff --git a/bin/varnishtest/tests/b00003.vtc b/bin/varnishtest/tests/b00003.vtc index 55442b3..77b6972 100644 --- a/bin/varnishtest/tests/b00003.vtc +++ b/bin/varnishtest/tests/b00003.vtc @@ -1,11 +1,11 @@ varnishtest "Check that a cache fetch + hit transaction works" server s1 { - rxreq + rxreq txresp -hdr "Connection: close" -body "012345\n" } -start -varnish v1 -vcl+backend { } -start +varnish v1 -vcl+backend { } -start client c1 { txreq -url "/" diff --git a/bin/varnishtest/tests/b00004.vtc b/bin/varnishtest/tests/b00004.vtc index 2a13a84..ec5cf76 100644 --- a/bin/varnishtest/tests/b00004.vtc +++ b/bin/varnishtest/tests/b00004.vtc @@ -4,7 +4,7 @@ server s1 { rxreq } -start -varnish v1 -vcl+backend { } +varnish v1 -vcl+backend { } varnish v1 -start varnish v1 -stop diff --git a/bin/varnishtest/tests/b00005.vtc b/bin/varnishtest/tests/b00005.vtc index 2824fc2..4f83cdc 100644 --- a/bin/varnishtest/tests/b00005.vtc +++ b/bin/varnishtest/tests/b00005.vtc @@ -1,11 +1,13 @@ varnishtest "Check that -s works" server s1 { - rxreq + rxreq txresp -hdr "Connection: close" -body "012345\n" } -start -varnish v1 -arg "-s file,${tmpdir}/varnishtest_backing,10M" -vcl+backend {} -start +varnish v1 \ + -arg "-s file,${tmpdir}/varnishtest_backing,10M" \ + -vcl+backend {} -start client c1 { txreq -url "/" diff --git a/bin/varnishtest/tests/b00006.vtc b/bin/varnishtest/tests/b00006.vtc index aea0494..b7d1c8b 100644 --- a/bin/varnishtest/tests/b00006.vtc +++ b/bin/varnishtest/tests/b00006.vtc @@ -1,7 +1,7 @@ varnishtest "Check that -s malloc works" server s1 { - rxreq + rxreq txresp -hdr "Connection: close" -body "012345\n" } -start diff --git a/bin/varnishtest/tests/b00007.vtc b/bin/varnishtest/tests/b00007.vtc index a07ae9e..a48fa3f 100644 --- a/bin/varnishtest/tests/b00007.vtc +++ b/bin/varnishtest/tests/b00007.vtc @@ -1,7 +1,7 @@ varnishtest "Check chunked encoding from backend works" server s1 { - rxreq + rxreq expect req.url == "/bar" send "HTTP/1.1 200 Ok\r\n" send "Transfer-encoding: chunked\r\n" @@ -10,7 +10,7 @@ server s1 { send "00000000\r\n" send "\r\n" - rxreq + rxreq expect req.url == "/foo" send "HTTP/1.1 200 Ok\r\n" send "Transfer-encoding: chunked\r\n" diff --git a/bin/varnishtest/tests/b00008.vtc b/bin/varnishtest/tests/b00008.vtc index 1ce9b64..dbadb1b 100644 --- a/bin/varnishtest/tests/b00008.vtc +++ b/bin/varnishtest/tests/b00008.vtc @@ -1,6 +1,6 @@ varnishtest "Test CLI help and parameter functions" -varnish v1 -arg "-b ${bad_ip}:9080" +varnish v1 -arg "-b ${bad_ip}:9080" varnish v1 -cliok "help" diff --git a/bin/varnishtest/tests/b00009.vtc b/bin/varnishtest/tests/b00009.vtc index 02a0b57..f30fd01 100644 --- a/bin/varnishtest/tests/b00009.vtc +++ b/bin/varnishtest/tests/b00009.vtc @@ -1,7 +1,7 @@ varnishtest "Check poll acceptor" server s1 { - rxreq + rxreq txresp -hdr "Connection: close" -body "012345\n" } -start diff --git a/bin/varnishtest/tests/b00010.vtc b/bin/varnishtest/tests/b00010.vtc index 05b9e91..d3654dc 100644 --- a/bin/varnishtest/tests/b00010.vtc +++ b/bin/varnishtest/tests/b00010.vtc @@ -1,7 +1,7 @@ varnishtest "Check simple list hasher" server s1 { - rxreq + rxreq txresp -hdr "Connection: close" -body "012345\n" } -start diff --git a/bin/varnishtest/tests/b00011.vtc b/bin/varnishtest/tests/b00011.vtc index 1e9ee74..bbd8cb3 100644 --- a/bin/varnishtest/tests/b00011.vtc +++ b/bin/varnishtest/tests/b00011.vtc @@ -1,9 +1,9 @@ varnishtest "Check HTTP/1.0 EOF transmission" server s1 { - rxreq + rxreq send "HTTP/1.1 200 Ok\n" - send "Connection: close\n" + send "Connection: close\n" send "\n" send "Body line 1\n" send "Body line 2\n" diff --git a/bin/varnishtest/tests/b00012.vtc b/bin/varnishtest/tests/b00012.vtc index 0aa9cec..81113b5 100644 --- a/bin/varnishtest/tests/b00012.vtc +++ b/bin/varnishtest/tests/b00012.vtc @@ -1,13 +1,13 @@ varnishtest "Check pipelining" server s1 { - rxreq + rxreq expect req.url == "/foo" txresp -body "foo" - rxreq + rxreq expect req.url == "/bar" txresp -body "foobar" -} -start +} -start varnish v1 -vcl+backend {} -start diff --git a/bin/varnishtest/tests/b00013.vtc b/bin/varnishtest/tests/b00013.vtc index d0b957a..d48cd5a 100644 --- a/bin/varnishtest/tests/b00013.vtc +++ b/bin/varnishtest/tests/b00013.vtc @@ -1,13 +1,13 @@ varnishtest "Check read-head / partial pipelining" server s1 { - rxreq + rxreq expect req.url == "/foo" txresp -body "foo" - rxreq + rxreq expect req.url == "/bar" txresp -body "foobar" -} -start +} -start varnish v1 -arg "-p accept_filter=false" -vcl+backend {} -start diff --git a/bin/varnishtest/tests/b00014.vtc b/bin/varnishtest/tests/b00014.vtc index 8c5822e..a6f08f3 100644 --- a/bin/varnishtest/tests/b00014.vtc +++ b/bin/varnishtest/tests/b00014.vtc @@ -2,15 +2,15 @@ varnishtest "Check -f command line arg" server s1 { - rxreq + rxreq expect req.url == "/foo" txresp -body "foo" - rxreq + rxreq expect req.url == "/bar" txresp -body "bar" } -start -shell "echo 'vcl 4.0; backend foo { .host = \"${s1_addr}\"; .port = \"${s1_port}\"; }' > ${tmpdir}/_b00014.vcl" +shell "echo 'vcl 4.0; backend foo { .host = \"${s1_addr}\"; .port = \"${s1_port}\"; }' > ${tmpdir}/_b00014.vcl" varnish v1 -arg "-f ${tmpdir}/_b00014.vcl" -start client c1 { diff --git a/bin/varnishtest/tests/b00015.vtc b/bin/varnishtest/tests/b00015.vtc index 3626284..029f782 100644 --- a/bin/varnishtest/tests/b00015.vtc +++ b/bin/varnishtest/tests/b00015.vtc @@ -2,7 +2,7 @@ varnishtest "Check synthetic error page caching" # First test that an internally generated error is not cached -varnish v1 -vcl { +varnish v1 -vcl { backend foo { .host = "${bad_ip}"; .port = "9080"; } @@ -26,7 +26,7 @@ client c1 { delay .1 -# Then check that a cacheable error from the backend is +# Then check that a cacheable error from the backend is varnish v1 -cliok "ban req.url ~ .*" @@ -35,7 +35,7 @@ server s1 { txresp -status 302 } -start -varnish v1 -vcl+backend { +varnish v1 -vcl+backend { sub vcl_backend_response { set beresp.http.ttl = beresp.ttl; set beresp.http.uncacheable = beresp.uncacheable; diff --git a/bin/varnishtest/tests/b00016.vtc b/bin/varnishtest/tests/b00016.vtc index 56bbd33..17fef23 100644 --- a/bin/varnishtest/tests/b00016.vtc +++ b/bin/varnishtest/tests/b00016.vtc @@ -1,6 +1,6 @@ varnishtest "Check naming of backends" -varnish v1 -vcl { +varnish v1 -vcl { backend foo { .host = "${bad_ip}"; .port = "9080"; } @@ -20,7 +20,7 @@ client c1 { expect resp.http.X-Backend-Name == "foo" } -run -varnish v1 -vcl { +varnish v1 -vcl { import directors from "${topbuild}/lib/libvmod_directors/.libs/libvmod_directors.so" ; backend b1 { @@ -47,7 +47,7 @@ client c1 { expect resp.http.X-Backend-Name == "bar" } -run -varnish v1 -vcl { +varnish v1 -vcl { import directors from "${topbuild}/lib/libvmod_directors/.libs/libvmod_directors.so" ; backend b1 { .host = "${bad_ip}"; .port = "9080"; diff --git a/bin/varnishtest/tests/b00017.vtc b/bin/varnishtest/tests/b00017.vtc index 053fffd..633e6e1 100644 --- a/bin/varnishtest/tests/b00017.vtc +++ b/bin/varnishtest/tests/b00017.vtc @@ -1,6 +1,6 @@ varnishtest "Check that we close one error" -varnish v1 -vcl { +varnish v1 -vcl { backend foo { .host = "${bad_ip}"; .port = "9080"; } diff --git a/bin/varnishtest/tests/b00018.vtc b/bin/varnishtest/tests/b00018.vtc index 2ad8cd2..3989b57 100644 --- a/bin/varnishtest/tests/b00018.vtc +++ b/bin/varnishtest/tests/b00018.vtc @@ -1,11 +1,11 @@ varnishtest "Check that synth response in vcl_backend_response works" server s1 { - rxreq + rxreq txresp -body "012345\n" } -start -varnish v1 -vcl+backend { +varnish v1 -vcl+backend { sub vcl_backend_response { set beresp.http.Foo = "bar"; set beresp.status = 523; diff --git a/bin/varnishtest/tests/b00019.vtc b/bin/varnishtest/tests/b00019.vtc index 5566723..6b33702 100644 --- a/bin/varnishtest/tests/b00019.vtc +++ b/bin/varnishtest/tests/b00019.vtc @@ -28,13 +28,13 @@ varnish v1 -vcl+backend { sub vcl_error { if (req.restarts == 2) { set obj.status = 200; - set obj.response = "restart=2"; + set obj.response = "restart=2"; } elsif (req.restarts > 2) { set obj.status = 501; - set obj.response = "restart>2"; + set obj.response = "restart>2"; } elsif (req.restarts < 2) { set obj.status = 500; - set obj.response = "restart<2"; + set obj.response = "restart<2"; } } } -start diff --git a/bin/varnishtest/tests/b00024.vtc b/bin/varnishtest/tests/b00024.vtc index 30f0466..1a55153 100644 --- a/bin/varnishtest/tests/b00024.vtc +++ b/bin/varnishtest/tests/b00024.vtc @@ -10,7 +10,7 @@ server s1 { varnish v1 -vcl+backend { sub vcl_backend_fetch { - set bereq.first_byte_timeout = 1s; + set bereq.first_byte_timeout = 1s; } } -start diff --git a/bin/varnishtest/tests/b00026.vtc b/bin/varnishtest/tests/b00026.vtc index 14293cc..b094b0a 100644 --- a/bin/varnishtest/tests/b00026.vtc +++ b/bin/varnishtest/tests/b00026.vtc @@ -5,7 +5,7 @@ feature SO_RCVTIMEO_WORKS server s1 { rxreq expect req.url == "from_backend" - delay 1; + delay 1; txresp } -start server s2 { diff --git a/bin/varnishtest/tests/b00033.vtc b/bin/varnishtest/tests/b00033.vtc index 4077047..90c1431 100644 --- a/bin/varnishtest/tests/b00033.vtc +++ b/bin/varnishtest/tests/b00033.vtc @@ -31,7 +31,7 @@ client c1 { } -run varnish v1 -cliok "ban req.url ~ ." - + client c1 { txreq -url /1 rxresp diff --git a/bin/varnishtest/tests/c00001.vtc b/bin/varnishtest/tests/c00001.vtc index 7497ec3..e301e4d 100644 --- a/bin/varnishtest/tests/c00001.vtc +++ b/bin/varnishtest/tests/c00001.vtc @@ -1,14 +1,14 @@ varnishtest "Test VCL regsub()" server s1 { - rxreq + rxreq txresp \ -hdr "Foobar: _barf_" \ -hdr "Connection: close" \ -body "012345\n" } -start -varnish v1 -vcl+backend { +varnish v1 -vcl+backend { sub vcl_backend_response { set beresp.http.Snafu1 = regsub(beresp.http.Foobar, "ar", "\0\0"); set beresp.http.Snafu2 = @@ -24,7 +24,7 @@ varnish v1 -vcl+backend { set beresp.http.Snafu7 = regsub(beresp.http.Foobar, "ar", bereq.http.nosuchheader); } -} -start +} -start client c1 { txreq -url "/" diff --git a/bin/varnishtest/tests/c00002.vtc b/bin/varnishtest/tests/c00002.vtc index 5351fec..22cf464 100644 --- a/bin/varnishtest/tests/c00002.vtc +++ b/bin/varnishtest/tests/c00002.vtc @@ -1,11 +1,14 @@ varnishtest "Check that all thread pools all get started and get minimum threads" server s1 { - rxreq + rxreq txresp -hdr "Connection: close" -body "012345\n" } -start -varnish v1 -arg "-p thread_pool_min=10 -p thread_pool_max=10 -p thread_pools=2" +varnish v1 \ + -arg "-p thread_pool_min=10" \ + -arg "-p thread_pool_max=10" \ + -arg "-p thread_pools=2" varnish v1 -vcl+backend {} -start diff --git a/bin/varnishtest/tests/c00003.vtc b/bin/varnishtest/tests/c00003.vtc index e0c5afa..0327873 100644 --- a/bin/varnishtest/tests/c00003.vtc +++ b/bin/varnishtest/tests/c00003.vtc @@ -1,7 +1,7 @@ varnishtest "Check that we start if at least one listen address works" server s1 { - rxreq + rxreq txresp -hdr "Connection: close" -body "012345\n" } -start diff --git a/bin/varnishtest/tests/c00004.vtc b/bin/varnishtest/tests/c00004.vtc index 3074eb8..56af641 100644 --- a/bin/varnishtest/tests/c00004.vtc +++ b/bin/varnishtest/tests/c00004.vtc @@ -35,7 +35,7 @@ client c1 { expect resp.http.X-Varnish == "1005" expect resp.http.snafu == "3" - txreq + txreq rxresp expect resp.status == 200 expect resp.http.X-Varnish == "1007" diff --git a/bin/varnishtest/tests/c00006.vtc b/bin/varnishtest/tests/c00006.vtc index 83c3ea2..7486271 100644 --- a/bin/varnishtest/tests/c00006.vtc +++ b/bin/varnishtest/tests/c00006.vtc @@ -16,7 +16,7 @@ client c1 { rxresp expect resp.status == 200 expect resp.bodylen == 5 -} +} client c1 -run diff --git a/bin/varnishtest/tests/c00007.vtc b/bin/varnishtest/tests/c00007.vtc index d9cd46f..4edff4f 100644 --- a/bin/varnishtest/tests/c00007.vtc +++ b/bin/varnishtest/tests/c00007.vtc @@ -1,3 +1,5 @@ varnishtest "Test banning a hash" -varnish v1 -arg "-b 127.0.0.1:80 -a 127.0.0.1:0" -start -clierr 101 "ban.hash foo" +varnish v1 \ + -arg "-b 127.0.0.1:80 -a 127.0.0.1:0" \ + -start -clierr 101 "ban.hash foo" diff --git a/bin/varnishtest/tests/c00008.vtc b/bin/varnishtest/tests/c00008.vtc index e41e0b2..64762f6 100644 --- a/bin/varnishtest/tests/c00008.vtc +++ b/bin/varnishtest/tests/c00008.vtc @@ -34,7 +34,7 @@ client c1 { rxresp -no_obj expect resp.status == 304 expect resp.http.etag == "foo" -} +} client c1 -run diff --git a/bin/varnishtest/tests/c00009.vtc b/bin/varnishtest/tests/c00009.vtc index 7e881ab..3d43334 100644 --- a/bin/varnishtest/tests/c00009.vtc +++ b/bin/varnishtest/tests/c00009.vtc @@ -3,7 +3,7 @@ varnishtest "Test restarts" server s1 { rxreq expect req.url == "/foo" - txresp -status 404 + txresp -status 404 } -start server s2 { @@ -12,7 +12,7 @@ server s2 { txresp -body "foobar" } -start -varnish v1 -vcl+backend { +varnish v1 -vcl+backend { sub vcl_recv { if (req.restarts == 0) { set req.backend = s1; @@ -40,6 +40,6 @@ client c1 { rxresp expect resp.status == 200 expect resp.bodylen == 6 -} +} client c1 -run diff --git a/bin/varnishtest/tests/c00010.vtc b/bin/varnishtest/tests/c00010.vtc index 238dada..18e364b 100644 --- a/bin/varnishtest/tests/c00010.vtc +++ b/bin/varnishtest/tests/c00010.vtc @@ -9,7 +9,7 @@ server s1 { txresp -body foobar1 } -start -varnish v1 -vcl+backend { +varnish v1 -vcl+backend { sub vcl_hit { return(pass); } @@ -26,6 +26,6 @@ client c1 { expect resp.status == 200 expect resp.bodylen == 7 expect resp.http.x-varnish == "1003 1004" -} +} client c1 -run diff --git a/bin/varnishtest/tests/c00011.vtc b/bin/varnishtest/tests/c00011.vtc index fc0af3d..be9aeb2 100644 --- a/bin/varnishtest/tests/c00011.vtc +++ b/bin/varnishtest/tests/c00011.vtc @@ -9,7 +9,7 @@ server s1 { txresp -body foobar1 } -start -varnish v1 -vcl+backend { +varnish v1 -vcl+backend { sub vcl_backend_response { set beresp.uncacheable = true; } @@ -26,6 +26,6 @@ client c1 { expect resp.status == 200 expect resp.bodylen == 7 expect resp.http.x-varnish == "1003" -} +} client c1 -run diff --git a/bin/varnishtest/tests/c00012.vtc b/bin/varnishtest/tests/c00012.vtc index 570fc93..fda9f4d 100644 --- a/bin/varnishtest/tests/c00012.vtc +++ b/bin/varnishtest/tests/c00012.vtc @@ -9,7 +9,7 @@ server s1 { txresp -body foobar1 } -start -varnish v1 -vcl+backend { +varnish v1 -vcl+backend { sub vcl_miss { return(pass); } @@ -26,6 +26,6 @@ client c1 { expect resp.status == 200 expect resp.bodylen == 7 expect resp.http.x-varnish == "1003" -} +} client c1 -run diff --git a/bin/varnishtest/tests/c00014.vtc b/bin/varnishtest/tests/c00014.vtc index 61654e1..a8b2d03 100644 --- a/bin/varnishtest/tests/c00014.vtc +++ b/bin/varnishtest/tests/c00014.vtc @@ -13,7 +13,7 @@ server s1 { txresp -body "foobar" } -start -varnish v1 -vcl+backend { +varnish v1 -vcl+backend { sub vcl_backend_response { set beresp.uncacheable = true; } diff --git a/bin/varnishtest/tests/c00015.vtc b/bin/varnishtest/tests/c00015.vtc index cbf5cca..5b09c8d 100644 --- a/bin/varnishtest/tests/c00015.vtc +++ b/bin/varnishtest/tests/c00015.vtc @@ -9,14 +9,14 @@ server s1 { txresp -body "foobar1" } -start -varnish v1 -vcl+backend { +varnish v1 -vcl+backend { } -start varnish v1 -vcl+backend { sub vcl_recv { return (pass); } -} +} varnish v1 -cli "vcl.list" varnish v1 -cli "vcl.use vcl1" diff --git a/bin/varnishtest/tests/c00016.vtc b/bin/varnishtest/tests/c00016.vtc index 99e9c53..83c9527 100644 --- a/bin/varnishtest/tests/c00016.vtc +++ b/bin/varnishtest/tests/c00016.vtc @@ -4,12 +4,12 @@ server s1 { rxreq expect req.url == "/foo" expect req.http.Foo == "bar" - txresp -hdr "Bar: foo" -body "foobar" + txresp -hdr "Bar: foo" -body "foobar" rxreq expect req.url == "/bar" expect req.http.Foo == - txresp -hdr "Bar: fnry,glyf, FOO ,brok" -hdr "Connection: bar" -body "foobar" + txresp -hdr "Bar: fnry,glyf, FOO ,brok" -hdr "Connection: bar" -body "foobar" } -start varnish v1 -vcl+backend { } -start diff --git a/bin/varnishtest/tests/c00017.vtc b/bin/varnishtest/tests/c00017.vtc index 7e6f11f..2ad090e 100644 --- a/bin/varnishtest/tests/c00017.vtc +++ b/bin/varnishtest/tests/c00017.vtc @@ -1,31 +1,31 @@ varnishtest "Test Backend Polling" server s1 { - # Probes + # Probes loop 8 { rxreq expect req.url == "/" - txresp -hdr "Bar: foo" -body "foobar" + txresp -hdr "Bar: foo" -body "foobar" accept } loop 3 { rxreq expect req.url == "/" - txresp -status 404 -hdr "Bar: foo" -body "foobar" + txresp -status 404 -hdr "Bar: foo" -body "foobar" accept } loop 2 { rxreq expect req.url == "/" - txresp -proto "FROBOZ" -status 200 -hdr "Bar: foo" -body "foobar" + txresp -proto "FROBOZ" -status 200 -hdr "Bar: foo" -body "foobar" accept } sema r1 sync 2 } -start -varnish v1 -vcl { +varnish v1 -vcl { backend foo { .host = "${s1_addr}"; @@ -35,7 +35,7 @@ varnish v1 -vcl { .interval = 0.1 s; } } - + } -start sema r1 sync 2 diff --git a/bin/varnishtest/tests/c00020.vtc b/bin/varnishtest/tests/c00020.vtc index 3713951..509d6ee 100644 --- a/bin/varnishtest/tests/c00020.vtc +++ b/bin/varnishtest/tests/c00020.vtc @@ -1,12 +1,12 @@ varnishtest "Test -h critbit a bit" server s1 { - rxreq + rxreq expect req.url == "/" txresp -hdr "Connection: close" -body "012345\n" } -start -varnish v1 -arg "-hcritbit" -vcl+backend { } -start +varnish v1 -arg "-hcritbit" -vcl+backend { } -start client c1 { txreq -url "/" @@ -23,10 +23,10 @@ client c2 { } -run server s1 { - rxreq + rxreq expect req.url == "/foo" txresp -body "012345\n" - rxreq + rxreq expect req.url == "/bar" txresp -body "012345\n" } -start diff --git a/bin/varnishtest/tests/c00021.vtc b/bin/varnishtest/tests/c00021.vtc index c8bcbe5..c4a5ef5 100644 --- a/bin/varnishtest/tests/c00021.vtc +++ b/bin/varnishtest/tests/c00021.vtc @@ -102,7 +102,7 @@ varnish v1 -cliok "ban req.http.foo == barcheck" varnish v1 -cliok "ban.list" client c1 { - txreq -url "/foo" -hdr "foo: barcheck" + txreq -url "/foo" -hdr "foo: barcheck" rxresp expect resp.status == 200 expect resp.http.foo == bar8 diff --git a/bin/varnishtest/tests/c00022.vtc b/bin/varnishtest/tests/c00022.vtc index 328ef92..841d2cf 100644 --- a/bin/varnishtest/tests/c00022.vtc +++ b/bin/varnishtest/tests/c00022.vtc @@ -18,7 +18,7 @@ server s1 { txresp -hdr "foo: bar8" -body "1111111\n" } -start -varnish v1 -vcl+backend { +varnish v1 -vcl+backend { sub vcl_recv { if (req.method == "PURGE") { ban ("req.url == " + req.url); @@ -65,7 +65,7 @@ client c1 { } -run varnish v1 -cliok "ban.list" -# New obj +# New obj client c1 { txreq -url "/foo" rxresp @@ -135,7 +135,7 @@ client c1 { varnish v1 -cliok "ban.list" client c1 { - txreq -url "/foo" -hdr "foo: barcheck" + txreq -url "/foo" -hdr "foo: barcheck" rxresp expect resp.status == 200 expect resp.http.foo == bar8 diff --git a/bin/varnishtest/tests/c00023.vtc b/bin/varnishtest/tests/c00023.vtc index 0e6aff1..11e8c72 100644 --- a/bin/varnishtest/tests/c00023.vtc +++ b/bin/varnishtest/tests/c00023.vtc @@ -1,36 +1,36 @@ varnishtest "Test -h critbit for digest edges" server s1 { - rxreq + rxreq expect req.url == "/1" txresp -body "\n" - rxreq + rxreq expect req.url == "/2" txresp -body "x\n" - rxreq + rxreq expect req.url == "/3" txresp -body "xx\n" - rxreq + rxreq expect req.url == "/4" txresp -body "xxx\n" - rxreq + rxreq expect req.url == "/5" txresp -body "xxxx\n" - rxreq + rxreq expect req.url == "/6" txresp -body "xxxxx\n" - rxreq + rxreq expect req.url == "/7" txresp -body "xxxxxx\n" - rxreq + rxreq expect req.url == "/8" txresp -body "xxxxxxx\n" - rxreq + rxreq expect req.url == "/9" txresp -body "xxxxxxxx\n" } -start -varnish v1 -arg "-hcritbit" -vcl+backend { } -start +varnish v1 -arg "-hcritbit" -vcl+backend { } -start varnish v1 -cliok "param.set debug +hashedge" client c1 { diff --git a/bin/varnishtest/tests/c00024.vtc b/bin/varnishtest/tests/c00024.vtc index 31ebc8b..2a1e542 100644 --- a/bin/varnishtest/tests/c00024.vtc +++ b/bin/varnishtest/tests/c00024.vtc @@ -1,24 +1,24 @@ varnishtest "Test restart in vcl_error" server s1 { - rxreq - txresp + rxreq + txresp } -start -varnish v1 -vcl+backend { +varnish v1 -vcl+backend { sub vcl_recv { if (req.restarts == 0) { return (error(701, "FOO")); } } - sub vcl_error { - if (req.restarts < 1) { - return (restart); - } else { - set obj.status = 201; + sub vcl_error { + if (req.restarts < 1) { + return (restart); + } else { + set obj.status = 201; } } - } -start + } -start client c1 { txreq -url "/" diff --git a/bin/varnishtest/tests/c00025.vtc b/bin/varnishtest/tests/c00025.vtc index 4432918..d1a55f3 100644 --- a/bin/varnishtest/tests/c00025.vtc +++ b/bin/varnishtest/tests/c00025.vtc @@ -24,7 +24,7 @@ client c1 { -hdr "If-None-Match: 123456789" rxresp -no_obj expect resp.status == 304 -} +} client c1 -run diff --git a/bin/varnishtest/tests/c00026.vtc b/bin/varnishtest/tests/c00026.vtc index 9f8c168..7d5c32c 100644 --- a/bin/varnishtest/tests/c00026.vtc +++ b/bin/varnishtest/tests/c00026.vtc @@ -44,7 +44,7 @@ client c1 { rxresp -no_obj expect resp.status == 304 -} +} client c1 -run diff --git a/bin/varnishtest/tests/c00027.vtc b/bin/varnishtest/tests/c00027.vtc index 88b4217..d9c7e8e 100644 --- a/bin/varnishtest/tests/c00027.vtc +++ b/bin/varnishtest/tests/c00027.vtc @@ -19,8 +19,8 @@ server s1 { } -start varnish v1 -arg "-s malloc,1M" -vcl+backend { - sub vcl_backend_response { - set beresp.ttl = 10m; + sub vcl_backend_response { + set beresp.ttl = 10m; } } -start diff --git a/bin/varnishtest/tests/c00028.vtc b/bin/varnishtest/tests/c00028.vtc index 7e2224f..4f8a0ff 100644 --- a/bin/varnishtest/tests/c00028.vtc +++ b/bin/varnishtest/tests/c00028.vtc @@ -1,17 +1,17 @@ varnishtest "Test that we can't recurse restarts forever" -varnish v1 -vcl { - backend bad { +varnish v1 -vcl { + backend bad { .host = "${bad_ip}"; .port = "9090"; } sub vcl_recv { set req.backend = bad; } - sub vcl_error { + sub vcl_error { return (restart); } - } -start + } -start client c1 { txreq -url "/" diff --git a/bin/varnishtest/tests/c00031.vtc b/bin/varnishtest/tests/c00031.vtc index 1dd8213..de30c6d 100644 --- a/bin/varnishtest/tests/c00031.vtc +++ b/bin/varnishtest/tests/c00031.vtc @@ -1,7 +1,7 @@ varnishtest "Worker thread stack size setting" server s1 { - rxreq + rxreq txresp } -start diff --git a/bin/varnishtest/tests/c00036.vtc b/bin/varnishtest/tests/c00036.vtc index 9f2544c..4e26467 100644 --- a/bin/varnishtest/tests/c00036.vtc +++ b/bin/varnishtest/tests/c00036.vtc @@ -1,10 +1,10 @@ varnishtest "Backend close retry" server s1 -repeat 1 { - rxreq + rxreq txresp -bodylen 5 - rxreq + rxreq accept rxreq @@ -19,12 +19,12 @@ varnish v1 -vcl+backend { } -start client c1 { - txreq + txreq rxresp expect resp.status == 200 expect resp.bodylen == 5 - txreq + txreq rxresp expect resp.status == 200 expect resp.bodylen == 6 diff --git a/bin/varnishtest/tests/c00037.vtc b/bin/varnishtest/tests/c00037.vtc index e26be5b..48ea499 100644 --- a/bin/varnishtest/tests/c00037.vtc +++ b/bin/varnishtest/tests/c00037.vtc @@ -1,19 +1,19 @@ varnishtest "Test req.hash_always_miss in vcl_recv" server s1 { - rxreq + rxreq txresp -hdr "Inc: 1" - rxreq + rxreq txresp -hdr "Inc: 2" } -start -varnish v1 -vcl+backend { +varnish v1 -vcl+backend { sub vcl_recv { if (req.http.x-missit == "1") { set req.hash_always_miss = true; } } - } -start + } -start client c1 { txreq -url "/" diff --git a/bin/varnishtest/tests/c00038.vtc b/bin/varnishtest/tests/c00038.vtc index ee396db..0764e85 100644 --- a/bin/varnishtest/tests/c00038.vtc +++ b/bin/varnishtest/tests/c00038.vtc @@ -1,7 +1,7 @@ varnishtest "Test req.hash_ignore_busy in vcl_recv" server s1 { - rxreq + rxreq sema r1 sync 2 delay 1 txresp -hdr "Server: 1" @@ -12,7 +12,7 @@ server s2 { txresp -hdr "Server: 2" } -start -varnish v1 -vcl+backend { +varnish v1 -vcl+backend { sub vcl_recv { if (req.http.x-ignorebusy == "1") { set req.hash_ignore_busy = true; @@ -24,7 +24,7 @@ varnish v1 -vcl+backend { set req.backend = s2; } } -} -start +} -start client c1 { txreq -url "/" -hdr "x-client: 1" diff --git a/bin/varnishtest/tests/c00039.vtc b/bin/varnishtest/tests/c00039.vtc index a9d35d8..6afb2eb 100644 --- a/bin/varnishtest/tests/c00039.vtc +++ b/bin/varnishtest/tests/c00039.vtc @@ -42,7 +42,7 @@ client c1 { -hdr "1...5: ..0....5\n ..0....5....0....5....0" \ -hdr "1...5: ..0....5\n ..0....5....0....5....0" \ -hdr "1...5: ..0....5\n ..0....5....0....5....0" \ - -hdr "1...5: ..0....5\n ..0...." + -hdr "1...5: ..0....5\n ..0...." rxresp expect resp.status == 200 @@ -52,6 +52,6 @@ client c1 { -hdr "1...5: ..0....5\n ..0....5....0....5....0" \ -hdr "1...5: ..0....5\n ..0....5....0....5....0" \ -hdr "1...5: ..0....5\n ..0....5....0....5....0" \ - -hdr "1...5: ..0....5\n ..0....5" + -hdr "1...5: ..0....5\n ..0....5" expect_close } -run diff --git a/bin/varnishtest/tests/c00040.vtc b/bin/varnishtest/tests/c00040.vtc index b6af9e2..f1efc96 100644 --- a/bin/varnishtest/tests/c00040.vtc +++ b/bin/varnishtest/tests/c00040.vtc @@ -22,7 +22,7 @@ server s1 { txresp \ -hdr "1...5: ..0....5....0\n ..5....0....5....0." \ -bodylen 4 - + accept rxreq expect req.url == "/5" @@ -55,7 +55,7 @@ varnish v1 -cliok "param.set http_resp_size 256" varnish v1 -cliok "param.set http_resp_hdr_len 40" client c1 { - txreq -url "/1" + txreq -url "/1" rxresp expect resp.status == 200 txreq -url "/2" diff --git a/bin/varnishtest/tests/c00041.vtc b/bin/varnishtest/tests/c00041.vtc index c51cf53..24a7871 100644 --- a/bin/varnishtest/tests/c00041.vtc +++ b/bin/varnishtest/tests/c00041.vtc @@ -95,4 +95,4 @@ client c1 { varnish v1 -errvcl {'purge': not a valid action in method 'vcl_recv'.} { backend s1 { .host = "${s1_addr}"; } sub vcl_recv { if (req.http.purge == "yes") { purge; } } -} +} diff --git a/bin/varnishtest/tests/c00042.vtc b/bin/varnishtest/tests/c00042.vtc index 7de613d..390f574 100644 --- a/bin/varnishtest/tests/c00042.vtc +++ b/bin/varnishtest/tests/c00042.vtc @@ -19,12 +19,12 @@ varnish v1 -vcl+backend { } -start client c1 { - txreq -url "/1" + txreq -url "/1" rxresp expect resp.status == 200 expect resp.bodylen == 1 - txreq -url "/1" + txreq -url "/1" rxresp expect resp.status == 200 expect resp.bodylen == 1 @@ -34,7 +34,7 @@ client c1 { expect resp.status == 200 expect resp.bodylen == 2 - txreq -url "/1" + txreq -url "/1" rxresp expect resp.status == 200 expect resp.bodylen == 2 diff --git a/bin/varnishtest/tests/c00044.vtc b/bin/varnishtest/tests/c00044.vtc index f325ae8..8d4078b 100644 --- a/bin/varnishtest/tests/c00044.vtc +++ b/bin/varnishtest/tests/c00044.vtc @@ -34,11 +34,11 @@ client c1 { varnish v1 -expect SMA.Transient.g_bytes == 0 varnish v1 -expect SMA.s0.g_bytes == 0 -varnish v1 -expect SMA.s0.g_space > 1000000 +varnish v1 -expect SMA.s0.g_space > 1000000 varnish v1 -expect SMA.s1.g_bytes > 1000000 varnish v1 -expect SMA.s1.g_space < 170 varnish v1 -expect SMA.s2.g_bytes == 0 -varnish v1 -expect SMA.s2.g_space > 1000000 +varnish v1 -expect SMA.s2.g_space > 1000000 client c1 { txreq -url /bar @@ -49,7 +49,7 @@ client c1 { varnish v1 -expect SMA.Transient.g_bytes == 0 varnish v1 -expect SMA.s0.g_bytes == 0 -varnish v1 -expect SMA.s0.g_space > 1000000 +varnish v1 -expect SMA.s0.g_space > 1000000 varnish v1 -expect SMA.s1.g_bytes > 1000000 varnish v1 -expect SMA.s1.g_space < 170 varnish v1 -expect SMA.s2.g_bytes > 1000000 diff --git a/bin/varnishtest/tests/c00045.vtc b/bin/varnishtest/tests/c00045.vtc index bfb71c7..9168158 100644 --- a/bin/varnishtest/tests/c00045.vtc +++ b/bin/varnishtest/tests/c00045.vtc @@ -30,7 +30,7 @@ varnish v1 -expect SMA.s0.g_space < 170 varnish v1 -expect SMA.s1.g_bytes == 0 varnish v1 -expect SMA.s1.g_space > 1000000 varnish v1 -expect SMA.s2.g_bytes == 0 -varnish v1 -expect SMA.s2.g_space > 1000000 +varnish v1 -expect SMA.s2.g_space > 1000000 client c1 { txreq -url /bar @@ -46,7 +46,7 @@ varnish v1 -expect SMA.s0.g_space < 1171 varnish v1 -expect SMA.s1.g_bytes == 0 varnish v1 -expect SMA.s1.g_space > 1000000 varnish v1 -expect SMA.s2.g_bytes == 0 -varnish v1 -expect SMA.s2.g_space > 1000000 +varnish v1 -expect SMA.s2.g_space > 1000000 client c1 { txreq -url /foo @@ -62,4 +62,4 @@ varnish v1 -expect SMA.s0.g_space < 1172 varnish v1 -expect SMA.s1.g_bytes == 0 varnish v1 -expect SMA.s1.g_space > 1000000 varnish v1 -expect SMA.s2.g_bytes == 0 -varnish v1 -expect SMA.s2.g_space > 1000000 +varnish v1 -expect SMA.s2.g_space > 1000000 diff --git a/bin/varnishtest/tests/c00046.vtc b/bin/varnishtest/tests/c00046.vtc index ad2b701..8982a92 100644 --- a/bin/varnishtest/tests/c00046.vtc +++ b/bin/varnishtest/tests/c00046.vtc @@ -29,7 +29,7 @@ varnish v1 -expect SMA.s0.g_space < 100000 varnish v1 -expect SMA.s1.g_bytes == 0 varnish v1 -expect SMA.s1.g_space > 1000000 varnish v1 -expect SMA.s2.g_bytes == 0 -varnish v1 -expect SMA.s2.g_space > 1000000 +varnish v1 -expect SMA.s2.g_space > 1000000 client c1 { txreq -url /bar @@ -45,7 +45,7 @@ varnish v1 -expect SMA.s0.g_space < 100000 varnish v1 -expect SMA.s1.g_bytes == 0 varnish v1 -expect SMA.s1.g_space > 1000000 varnish v1 -expect SMA.s2.g_bytes == 0 -varnish v1 -expect SMA.s2.g_space > 1000000 +varnish v1 -expect SMA.s2.g_space > 1000000 client c1 { txreq -url /foo @@ -61,4 +61,4 @@ varnish v1 -expect SMA.s0.g_space < 100000 varnish v1 -expect SMA.s1.g_bytes == 0 varnish v1 -expect SMA.s1.g_space > 1000000 varnish v1 -expect SMA.s2.g_bytes == 0 -varnish v1 -expect SMA.s2.g_space > 1000000 +varnish v1 -expect SMA.s2.g_space > 1000000 diff --git a/bin/varnishtest/tests/c00047.vtc b/bin/varnishtest/tests/c00047.vtc index e2ec54e..e25d912 100644 --- a/bin/varnishtest/tests/c00047.vtc +++ b/bin/varnishtest/tests/c00047.vtc @@ -1,13 +1,13 @@ varnishtest "Test VCL regsuball()" server s1 { - rxreq + rxreq txresp \ -hdr "foo: barbar" \ -hdr "bar: bbbar" } -start -varnish v1 -vcl+backend { +varnish v1 -vcl+backend { sub vcl_backend_response { set beresp.http.baz1 = regsuball(beresp.http.foo, "barb", "zz"); set beresp.http.baz2 = regsuball(beresp.http.foo, "ar", "zz"); @@ -17,7 +17,7 @@ varnish v1 -vcl+backend { set beresp.http.baz6 = regsuball(beresp.http.foo, "^b*", "z"); set beresp.http.baz7 = regsuball(beresp.http.foo, "ping", "pong"); } -} -start +} -start client c1 { txreq -url "/" diff --git a/bin/varnishtest/tests/c00051.vtc b/bin/varnishtest/tests/c00051.vtc index 78fdc81..91184d1 100644 --- a/bin/varnishtest/tests/c00051.vtc +++ b/bin/varnishtest/tests/c00051.vtc @@ -1,6 +1,6 @@ varnishtest "test parameter protection" -varnish v1 -arg "-r cli_timeout" +varnish v1 -arg "-r cli_timeout" varnish v1 -cliok "param.show cli_timeout" varnish v1 -clierr 107 "param.set cli_timeout 1m" diff --git a/bin/varnishtest/tests/c00052.vtc b/bin/varnishtest/tests/c00052.vtc index 2ab6c1a..6ff5815 100644 --- a/bin/varnishtest/tests/c00052.vtc +++ b/bin/varnishtest/tests/c00052.vtc @@ -5,13 +5,13 @@ server s1 { txresp } -start -varnish v1 +varnish v1 varnish v1 -cliok "param.set vcc_allow_inline_c true" varnish v1 -vcl+backend { C{ getpid(); }C -} +} varnish v1 -cliok "param.set vcc_allow_inline_c false" diff --git a/bin/varnishtest/tests/c00053.vtc b/bin/varnishtest/tests/c00053.vtc index a5c2264..76c9bd2 100644 --- a/bin/varnishtest/tests/c00053.vtc +++ b/bin/varnishtest/tests/c00053.vtc @@ -1,7 +1,7 @@ varnishtest "Test inclide vs. unsafe_path" server s1 { - rxreq + rxreq txresp -hdr "foo: bAr" -hdr "bar: fOo" -bodylen 4 } -start diff --git a/bin/varnishtest/tests/c00058.vtc b/bin/varnishtest/tests/c00058.vtc index 9811b79..440bbf3 100644 --- a/bin/varnishtest/tests/c00058.vtc +++ b/bin/varnishtest/tests/c00058.vtc @@ -8,7 +8,7 @@ server s1 { sema r2 sync 2 } -start -varnish v1 -vcl+backend { +varnish v1 -vcl+backend { sub vcl_backend_response { set beresp.ttl = 0.5s; set beresp.grace = 10s; diff --git a/bin/varnishtest/tests/e00000.vtc b/bin/varnishtest/tests/e00000.vtc index 157dea5..e17338f 100644 --- a/bin/varnishtest/tests/e00000.vtc +++ b/bin/varnishtest/tests/e00000.vtc @@ -2,7 +2,7 @@ varnishtest "ESI test with no ESI content" server s1 { - rxreq + rxreq txresp -body { -This is a test: Hello world } @@ -15,7 +15,7 @@ varnish v1 -vcl+backend { } -start client c1 { - txreq + txreq rxresp expect resp.status == 200 expect resp.bodylen == 33 diff --git a/bin/varnishtest/tests/e00001.vtc b/bin/varnishtest/tests/e00001.vtc index 42a0c24..660637d 100644 --- a/bin/varnishtest/tests/e00001.vtc +++ b/bin/varnishtest/tests/e00001.vtc @@ -2,7 +2,7 @@ varnishtest "ESI:remove" server s1 { - rxreq + rxreq txresp -body { This is a test: Unseen University @@ -17,10 +17,10 @@ varnish v1 -vcl+backend { sub vcl_backend_response { set beresp.do_esi = true; } -} -start +} -start client c1 { - txreq + txreq rxresp expect resp.status == 200 expect resp.bodylen == 40 diff --git a/bin/varnishtest/tests/e00002.vtc b/bin/varnishtest/tests/e00002.vtc index ebebf62..244d4bc 100644 --- a/bin/varnishtest/tests/e00002.vtc +++ b/bin/varnishtest/tests/e00002.vtc @@ -2,7 +2,7 @@ varnishtest "ESI CDATA" server s1 { - rxreq + rxreq txresp -body { ]]> @@ -19,7 +19,7 @@ varnish v1 -vcl+backend { } -start client c1 { - txreq + txreq rxresp expect resp.status == 200 expect resp.bodylen == 35 diff --git a/bin/varnishtest/tests/e00003.vtc b/bin/varnishtest/tests/e00003.vtc index a79ac57..bf61f4f 100644 --- a/bin/varnishtest/tests/e00003.vtc +++ b/bin/varnishtest/tests/e00003.vtc @@ -2,14 +2,14 @@ varnishtest "ESI include" server s1 { - rxreq + rxreq txresp -body { Before include After include } - rxreq + rxreq expect req.url == "/body1" txresp -body { Included file @@ -28,12 +28,12 @@ varnish v1 -vcl+backend { } -start client c1 { - txreq + txreq rxresp expect resp.bodylen == 65 expect resp.status == 200 # test that there is no difference on miss/hit - txreq + txreq rxresp expect resp.bodylen == 65 expect resp.status == 200 diff --git a/bin/varnishtest/tests/e00004.vtc b/bin/varnishtest/tests/e00004.vtc index e6ae26f..7326cb5 100644 --- a/bin/varnishtest/tests/e00004.vtc +++ b/bin/varnishtest/tests/e00004.vtc @@ -2,14 +2,14 @@ varnishtest "ESI commented include" server s1 { - rxreq + rxreq txresp -body { Before include After include } - rxreq + rxreq expect req.url == "/body" txresp -body { Included file @@ -23,7 +23,7 @@ varnish v1 -vcl+backend { } -start client c1 { - txreq + txreq rxresp expect resp.status == 200 expect resp.bodylen == 67 diff --git a/bin/varnishtest/tests/e00005.vtc b/bin/varnishtest/tests/e00005.vtc index 441362c..76a82ab 100644 --- a/bin/varnishtest/tests/e00005.vtc +++ b/bin/varnishtest/tests/e00005.vtc @@ -2,7 +2,7 @@ varnishtest "ESI relative include" server s1 { - rxreq + rxreq expect req.url == "/foo/bar" txresp -body { @@ -10,7 +10,7 @@ server s1 { After include } - rxreq + rxreq expect req.url == "/foo/body" txresp -body { Included file diff --git a/bin/varnishtest/tests/e00006.vtc b/bin/varnishtest/tests/e00006.vtc index 1bd6cf3..79382fc 100644 --- a/bin/varnishtest/tests/e00006.vtc +++ b/bin/varnishtest/tests/e00006.vtc @@ -2,7 +2,7 @@ varnishtest "ESI include with http://" server s1 { - rxreq + rxreq expect req.url == "/foo/bar" txresp -body { diff --git a/bin/varnishtest/tests/e00007.vtc b/bin/varnishtest/tests/e00007.vtc index 729ff84..0f5d86a 100644 --- a/bin/varnishtest/tests/e00007.vtc +++ b/bin/varnishtest/tests/e00007.vtc @@ -14,7 +14,7 @@ varnishtest "ESI spanning storage bits" # NB! 7 Debug c "d%0a%09" server s1 { - rxreq + rxreq expect req.url == "/foo/bar" send "HTTP/1.1 200 Ok\n" send "Connection: close\n" diff --git a/bin/varnishtest/tests/e00008.vtc b/bin/varnishtest/tests/e00008.vtc index e99dac9..e72ec56 100644 --- a/bin/varnishtest/tests/e00008.vtc +++ b/bin/varnishtest/tests/e00008.vtc @@ -1,7 +1,7 @@ varnishtest "ESI parsing errors" server s1 { - rxreq + rxreq txresp -body { 1 Before include 2 @@ -39,14 +39,14 @@ server s1 { bar } - rxreq + rxreq txresp -body { Before include @@ -24,13 +24,13 @@ varnish v1 -vcl+backend { } -start client c1 { - txreq + txreq rxresp expect resp.status == 200 expect resp.bodylen == 57 } -run -varnish v1 -cli "param.set feature +esi_disable_xml_check" +varnish v1 -cli "param.set feature +esi_disable_xml_check" client c1 { txreq -url bar diff --git a/bin/varnishtest/tests/e00010.vtc b/bin/varnishtest/tests/e00010.vtc index 0fccc41..feffe01 100644 --- a/bin/varnishtest/tests/e00010.vtc +++ b/bin/varnishtest/tests/e00010.vtc @@ -1,7 +1,7 @@ varnishtest "Ignoring non esi elements" server s1 { - rxreq + rxreq txresp -body { @@ -18,7 +18,7 @@ varnish v1 -vcl+backend { } -start -cli "param.set feature +esi_ignore_other_elements" client c1 { - txreq + txreq rxresp expect resp.status == 200 expect resp.bodylen == 21 diff --git a/bin/varnishtest/tests/e00011.vtc b/bin/varnishtest/tests/e00011.vtc index 7dd2d14..0e655fc 100644 --- a/bin/varnishtest/tests/e00011.vtc +++ b/bin/varnishtest/tests/e00011.vtc @@ -1,7 +1,7 @@ varnishtest "Make sure that PASS'ed ESI requests use GET for includes" server s1 { - rxreq + rxreq expect req.method == POST expect req.url == /foobar txresp -body { @@ -20,7 +20,7 @@ varnish v1 -vcl+backend { set beresp.uncacheable = true; set beresp.do_esi = true; } -} -start +} -start client c1 { txreq -req POST -url /foobar -body { diff --git a/bin/varnishtest/tests/e00012.vtc b/bin/varnishtest/tests/e00012.vtc index 3cd8db6..afc23c6 100644 --- a/bin/varnishtest/tests/e00012.vtc +++ b/bin/varnishtest/tests/e00012.vtc @@ -1,7 +1,7 @@ varnishtest "ESI includes for pre HTTP/1.1 cannot used chunked encoding" server s1 { - rxreq + rxreq expect req.url == "/foo/bar" txresp -body { @@ -9,7 +9,7 @@ server s1 { After include } - rxreq + rxreq expect req.url == "/foo/body" txresp -body { Included file diff --git a/bin/varnishtest/tests/e00015.vtc b/bin/varnishtest/tests/e00015.vtc index 7126f6c..3a41237 100644 --- a/bin/varnishtest/tests/e00015.vtc +++ b/bin/varnishtest/tests/e00015.vtc @@ -1,21 +1,21 @@ varnishtest "ESI requests turned off" server s1 { - rxreq + rxreq txresp -body { Before include After include } - rxreq + rxreq txresp -body { Before include After include } - rxreq + rxreq expect req.url == "/body" txresp -body { Included file @@ -24,8 +24,8 @@ server s1 { varnish v1 -vcl+backend { sub vcl_recv { - if(req.url == "/") { - set req.esi = false; + if(req.url == "/") { + set req.esi = false; } } sub vcl_backend_response { diff --git a/bin/varnishtest/tests/e00016.vtc b/bin/varnishtest/tests/e00016.vtc index 3871915..7f0a71b 100644 --- a/bin/varnishtest/tests/e00016.vtc +++ b/bin/varnishtest/tests/e00016.vtc @@ -1,7 +1,7 @@ varnishtest "ESI request can't be turned off midstream" server s1 { - rxreq + rxreq txresp -body { Before include @@ -9,7 +9,7 @@ server s1 { After include } - rxreq + rxreq expect req.url == "/body" txresp -body { @@ -31,10 +31,10 @@ varnish v1 -vcl+backend { set beresp.do_esi = true; } sub vcl_deliver { - set req.esi = true; - if(req.url == "/body") { - set req.esi = false; - } + set req.esi = true; + if(req.url == "/body") { + set req.esi = false; + } } } -start diff --git a/bin/varnishtest/tests/e00017.vtc b/bin/varnishtest/tests/e00017.vtc index 121662e..1ced505 100644 --- a/bin/varnishtest/tests/e00017.vtc +++ b/bin/varnishtest/tests/e00017.vtc @@ -2,7 +2,7 @@ varnishtest "Aggressive use of ESI include" server s1 { - rxreq + rxreq txresp -body { Before include @@ -28,45 +28,45 @@ server s1 { After include } - rxreq + rxreq txresp -body { Included file 00 } - rxreq + rxreq txresp -body { Included file 01 } - rxreq + rxreq txresp -body { Included file 02 } - rxreq + rxreq txresp -body { Included file 03 } - rxreq + rxreq txresp -body { Included file 04 } - rxreq + rxreq txresp -body { Included file 05 } - rxreq + rxreq txresp -body { Included file 06 } rxreq txresp -body { Included file 07 } - rxreq + rxreq txresp -body { Included file 08 } - rxreq + rxreq txresp -body { Included file 09 } - rxreq + rxreq txresp -body { Included file 10 } - rxreq + rxreq txresp -body { Included file 11 } - rxreq + rxreq txresp -body { Included file 12 } - rxreq + rxreq txresp -body { Included file 13 } - rxreq + rxreq txresp -body { Included file 14 } - rxreq + rxreq txresp -body { Included file 15 } - rxreq + rxreq txresp -body { Included file 16 } rxreq txresp -body { Included file 17 } - rxreq + rxreq txresp -body { Included file 18 } - rxreq + rxreq txresp -body { Included file 19 } } -start @@ -77,7 +77,7 @@ varnish v1 -vcl+backend { } -start client c1 { - txreq + txreq rxresp expect resp.status == 200 } diff --git a/bin/varnishtest/tests/e00019.vtc b/bin/varnishtest/tests/e00019.vtc index 374bb18..1aeaa06 100644 --- a/bin/varnishtest/tests/e00019.vtc +++ b/bin/varnishtest/tests/e00019.vtc @@ -1,7 +1,7 @@ varnishtest "Push corners in new ESI parser" server s1 { - rxreq + rxreq txresp -nolen -hdr "Transfer-encoding: chunked" chunked {<1><1>} chunked {<2><2>} @@ -34,7 +34,7 @@ varnish v1 -vcl+backend { set beresp.do_esi = true; } } -} -start +} -start varnish v1 -cliok "param.set debug +esi_chop" varnish v1 -cliok "param.set debug +syncvsl" diff --git a/bin/varnishtest/tests/e00020.vtc b/bin/varnishtest/tests/e00020.vtc index 121c80e..9913e33 100644 --- a/bin/varnishtest/tests/e00020.vtc +++ b/bin/varnishtest/tests/e00020.vtc @@ -2,7 +2,7 @@ varnishtest "ESI:remove" server s1 { - rxreq + rxreq txresp -gzipbody { This is a test: Unseen University @@ -18,12 +18,12 @@ varnish v1 -vcl+backend { set beresp.do_esi = true; set beresp.do_gunzip = true; } -} -start +} -start varnish v1 -cliok "param.set http_gzip_support true" client c1 { - txreq + txreq rxresp expect resp.status == 200 expect resp.bodylen == 40 diff --git a/bin/varnishtest/tests/e00021.vtc b/bin/varnishtest/tests/e00021.vtc index 9a0ead2..dc8f1cf 100644 --- a/bin/varnishtest/tests/e00021.vtc +++ b/bin/varnishtest/tests/e00021.vtc @@ -2,7 +2,7 @@ varnishtest "ESI ability to stitch gzip files together" server s1 { - rxreq + rxreq txresp -body { This is a test: Unseen University @@ -21,7 +21,7 @@ varnish v1 -vcl+backend { set beresp.do_esi = true; set beresp.do_gzip = true; } -} -start +} -start varnish v1 -cliok "param.set debug +esi_chop" varnish v1 -cliok "param.set http_gzip_support true" diff --git a/bin/varnishtest/tests/e00022.vtc b/bin/varnishtest/tests/e00022.vtc index bc5b259..ecc606b 100644 --- a/bin/varnishtest/tests/e00022.vtc +++ b/bin/varnishtest/tests/e00022.vtc @@ -2,7 +2,7 @@ varnishtest "ESI ability to stitch gzip files together" server s1 { - rxreq + rxreq expect req.http.accept-encoding == gzip txresp -gzipbody { @@ -21,7 +21,7 @@ varnish v1 -arg "-p thread_pool_stack=262144" -vcl+backend { sub vcl_backend_response { set beresp.do_esi = true; } -} -start +} -start varnish v1 -cliok "param.set debug +esi_chop" varnish v1 -cliok "param.set http_gzip_support true" diff --git a/bin/varnishtest/tests/e00023.vtc b/bin/varnishtest/tests/e00023.vtc index 893fdf9..7d4aeaa 100644 --- a/bin/varnishtest/tests/e00023.vtc +++ b/bin/varnishtest/tests/e00023.vtc @@ -1,7 +1,7 @@ varnishtest "Include gzip'ed and ungzip'ed (ESI) objects in a gzip'ed ESI object" server s1 { - rxreq + rxreq expect req.http.accept-encoding == gzip txresp -gzipbody { 1 @@ -39,11 +39,11 @@ varnish v1 -vcl+backend { sub vcl_backend_response { set beresp.do_esi = true; } -} -start +} -start varnish v1 -cliok "param.set http_gzip_support true" -varnish v1 -cliok "param.set debug +esi_chop" -varnish v1 -cliok "param.set feature +esi_disable_xml_check" +varnish v1 -cliok "param.set debug +esi_chop" +varnish v1 -cliok "param.set feature +esi_disable_xml_check" varnish v1 -cliok "param.set debug +syncvsl" diff --git a/bin/varnishtest/tests/e00024.vtc b/bin/varnishtest/tests/e00024.vtc index 2ae231e..1849360 100644 --- a/bin/varnishtest/tests/e00024.vtc +++ b/bin/varnishtest/tests/e00024.vtc @@ -1,7 +1,7 @@ varnishtest "Test all 8 gzip stopbit residuals" server s1 { - rxreq + rxreq expect req.http.accept-encoding == gzip txresp -gzipbody { 1 @@ -65,10 +65,10 @@ varnish v1 -vcl+backend { set beresp.do_esi = true; } } -} -start +} -start varnish v1 -cliok "param.set http_gzip_support true" -varnish v1 -cliok "param.set debug +esi_chop" +varnish v1 -cliok "param.set debug +esi_chop" varnish v1 -cliok "param.set debug +syncvsl" client c1 { @@ -79,7 +79,7 @@ client c1 { expect resp.status == 200 expect resp.bodylen == 252 - txreq + txreq rxresp expect resp.http.content-encoding == expect resp.status == 200 diff --git a/bin/varnishtest/tests/e00025.vtc b/bin/varnishtest/tests/e00025.vtc index 5e8a12b..e208dc8 100644 --- a/bin/varnishtest/tests/e00025.vtc +++ b/bin/varnishtest/tests/e00025.vtc @@ -1,7 +1,7 @@ varnishtest "Test that esi+gzip correctly bypasses Vary: accept-encoding" server s1 { - rxreq + rxreq expect req.http.accept-encoding == gzip txresp -hdr "Vary: Accept-encoding" -gzipbody {FOO} } -start @@ -16,7 +16,7 @@ client c1 { gunzip expect resp.bodylen == 3 - txreq + txreq rxresp expect resp.http.content-encoding == expect resp.status == 200 diff --git a/bin/varnishtest/tests/e00026.vtc b/bin/varnishtest/tests/e00026.vtc index 22e04fc..2e5c06f 100644 --- a/bin/varnishtest/tests/e00026.vtc +++ b/bin/varnishtest/tests/e00026.vtc @@ -5,22 +5,22 @@ server s1 { expect req.url == "/foo" txresp -gzipbody {

/////

} - rxreq + rxreq expect req.url == "/1" expect req.http.accept-encoding == gzip txresp -gzipbody {BA} - rxreq + rxreq expect req.url == "/2" expect req.http.accept-encoding == gzip txresp -gzipbody {B} - rxreq + rxreq expect req.url == "/3" expect req.http.accept-encoding == gzip txresp -gzipbody {A} - rxreq + rxreq expect req.url == "/4" expect req.http.accept-encoding == gzip txresp -gzipbody {} @@ -33,7 +33,7 @@ varnish v1 -vcl+backend { set beresp.do_esi = true; } } -} -start +} -start varnish v1 -cliok "param.set feature +esi_disable_xml_check" diff --git a/bin/varnishtest/tests/e00027.vtc b/bin/varnishtest/tests/e00027.vtc index eac20d3..3e6388d 100644 --- a/bin/varnishtest/tests/e00027.vtc +++ b/bin/varnishtest/tests/e00027.vtc @@ -14,12 +14,12 @@ varnish v1 -vcl+backend { } -start client c1 { - txreq -url "/1" - rxresp + txreq -url "/1" + rxresp expect resp.status == 200 expect resp.bodylen == 1 - txreq -req "HEAD" -url "/1" + txreq -req "HEAD" -url "/1" rxresp -no_obj expect resp.status == 200 } -run diff --git a/bin/varnishtest/tests/g00000.vtc b/bin/varnishtest/tests/g00000.vtc index b3631b0..fa8a4bb 100644 --- a/bin/varnishtest/tests/g00000.vtc +++ b/bin/varnishtest/tests/g00000.vtc @@ -6,7 +6,7 @@ server s1 { } -start -varnish v1 -vcl+backend { +varnish v1 -vcl+backend { sub vcl_deliver { set resp.http.gzip = req.can_gzip; } diff --git a/bin/varnishtest/tests/g00001.vtc b/bin/varnishtest/tests/g00001.vtc index e10b743..ccdc39e 100644 --- a/bin/varnishtest/tests/g00001.vtc +++ b/bin/varnishtest/tests/g00001.vtc @@ -10,7 +10,7 @@ varnish v1 -cliok "param.set http_gzip_support true" -vcl+backend { } -start client c1 { - txreq + txreq rxresp expect resp.bodylen == "3" expect resp.http.content-encoding == diff --git a/bin/varnishtest/tests/g00003.vtc b/bin/varnishtest/tests/g00003.vtc index db4ed17..6fdae5c 100644 --- a/bin/varnishtest/tests/g00003.vtc +++ b/bin/varnishtest/tests/g00003.vtc @@ -44,7 +44,7 @@ client c1 { gunzip expect resp.bodylen == 43 - txreq -url /foobar + txreq -url /foobar rxresp expect resp.http.content-encoding == expect resp.bodylen == 43 diff --git a/bin/varnishtest/tests/g00004.vtc b/bin/varnishtest/tests/g00004.vtc index 703cacc..9453720 100644 --- a/bin/varnishtest/tests/g00004.vtc +++ b/bin/varnishtest/tests/g00004.vtc @@ -24,9 +24,9 @@ varnish v1 \ if (bereq.url == "/gunzip") { set beresp.do_gunzip = true; - } + } } -} +} varnish v1 -cliok "param.set debug +syncvsl" diff --git a/bin/varnishtest/tests/g00005.vtc b/bin/varnishtest/tests/g00005.vtc index 9917937..158a264 100644 --- a/bin/varnishtest/tests/g00005.vtc +++ b/bin/varnishtest/tests/g00005.vtc @@ -10,7 +10,7 @@ varnish v1 -cliok "param.set http_gzip_support true" -vcl+backend { } -start client c1 { - txreq + txreq rxresp expect resp.bodylen == "10" expect resp.http.content-encoding == diff --git a/bin/varnishtest/tests/m00000.vtc b/bin/varnishtest/tests/m00000.vtc index 9233628..c4f1286 100644 --- a/bin/varnishtest/tests/m00000.vtc +++ b/bin/varnishtest/tests/m00000.vtc @@ -1,7 +1,7 @@ varnishtest "Test std & debug vmod" server s1 { - rxreq + rxreq txresp -hdr "foo: bAr" -hdr "bar: fOo" -bodylen 4 } -start diff --git a/bin/varnishtest/tests/m00001.vtc b/bin/varnishtest/tests/m00001.vtc index 5d07b97..59b8e0b 100644 --- a/bin/varnishtest/tests/m00001.vtc +++ b/bin/varnishtest/tests/m00001.vtc @@ -1,7 +1,7 @@ varnishtest "Test std vmod" server s1 { - rxreq + rxreq txresp -hdr "foo: bAr" -hdr "bar: fOo" -bodylen 4 } -start diff --git a/bin/varnishtest/tests/m00002.vtc b/bin/varnishtest/tests/m00002.vtc index f95bee8..09b5c78 100644 --- a/bin/varnishtest/tests/m00002.vtc +++ b/bin/varnishtest/tests/m00002.vtc @@ -24,7 +24,7 @@ varnish v1 -vcl+backend { varnish v1 -cliok "debug.srandom 1" client c1 { - txreq + txreq rxresp expect resp.http.rnd1 == 0.388 expect resp.http.rnd2 == 7.478 diff --git a/bin/varnishtest/tests/m00003.vtc b/bin/varnishtest/tests/m00003.vtc index d1e36c2..9e93f6e 100644 --- a/bin/varnishtest/tests/m00003.vtc +++ b/bin/varnishtest/tests/m00003.vtc @@ -1,7 +1,7 @@ varnishtest "Test vmod_dir param" server s1 { - rxreq + rxreq txresp -hdr "foo: bAr" -hdr "bar: fOo" -bodylen 4 } -start diff --git a/bin/varnishtest/tests/m00004.vtc b/bin/varnishtest/tests/m00004.vtc index 232428b..6a23bde 100644 --- a/bin/varnishtest/tests/m00004.vtc +++ b/bin/varnishtest/tests/m00004.vtc @@ -65,7 +65,7 @@ varnish v1 -vcl+backend { set resp.http.three = std.fileread("${tmpdir}/m00004_file_three"); } } -} +} varnish v1 -cli "vcl.list" varnish v1 -cli "vcl.use vcl2" diff --git a/bin/varnishtest/tests/m00006.vtc b/bin/varnishtest/tests/m00006.vtc index 740ba38..f9ce764 100644 --- a/bin/varnishtest/tests/m00006.vtc +++ b/bin/varnishtest/tests/m00006.vtc @@ -31,7 +31,7 @@ varnish v1 -vcl+backend { client c1 { txreq -url "/1" -hdr "Foo: 1" -hdr "Foo: 2" - rxresp + rxresp expect resp.http.bar == "a, b" expect resp.status == 200 expect resp.bodylen == 1 diff --git a/bin/varnishtest/tests/m00007.vtc b/bin/varnishtest/tests/m00007.vtc index 68ee347..2b1c43a 100644 --- a/bin/varnishtest/tests/m00007.vtc +++ b/bin/varnishtest/tests/m00007.vtc @@ -26,7 +26,7 @@ client c1 { 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 diff --git a/bin/varnishtest/tests/m00008.vtc b/bin/varnishtest/tests/m00008.vtc index c9d2bd8..c1bdd6b 100644 --- a/bin/varnishtest/tests/m00008.vtc +++ b/bin/varnishtest/tests/m00008.vtc @@ -1,7 +1,7 @@ varnishtest "Test std vmod vs. unsafe_path" server s1 { - rxreq + rxreq txresp -hdr "foo: bAr" -hdr "bar: fOo" -bodylen 4 } -start diff --git a/bin/varnishtest/tests/p00000.vtc b/bin/varnishtest/tests/p00000.vtc index 745abf5..461da5f 100644 --- a/bin/varnishtest/tests/p00000.vtc +++ b/bin/varnishtest/tests/p00000.vtc @@ -1,8 +1,8 @@ varnishtest "Test Basic persistence" server s1 { - rxreq - txresp + rxreq + txresp } -start shell "rm -f ${tmpdir}/_.per" @@ -10,7 +10,7 @@ shell "rm -f ${tmpdir}/_.per" varnish v1 \ -arg "-pfeature=+wait_silo" \ -storage "-spersistent,${tmpdir}/_.per,10m" \ - -vcl+backend { } -start + -vcl+backend { } -start varnish v1 -stop diff --git a/bin/varnishtest/tests/p00001.vtc b/bin/varnishtest/tests/p00001.vtc index e8c4aa5..626b47d 100644 --- a/bin/varnishtest/tests/p00001.vtc +++ b/bin/varnishtest/tests/p00001.vtc @@ -3,7 +3,7 @@ varnishtest "Change TTL on persistent object" shell "rm -f ${tmpdir}/_.per" server s1 { - rxreq + rxreq txresp -hdr "Foo: foo" } -start @@ -11,7 +11,7 @@ varnish v1 \ -arg "-pfeature=+wait_silo" \ -arg "-pban_lurker_sleep=0" \ -storage "-spersistent,${tmpdir}/_.per,10m" \ - -vcl+backend { } -start + -vcl+backend { } -start varnish v1 -cliok "param.set default_grace 0" varnish v1 -cliok "param.set default_keep 0" @@ -48,7 +48,7 @@ client c1 { varnish v1 -stop server s1 { - rxreq + rxreq txresp -hdr "Foo: bar" } -start diff --git a/bin/varnishtest/tests/p00002.vtc b/bin/varnishtest/tests/p00002.vtc index 53bf892..4475918 100644 --- a/bin/varnishtest/tests/p00002.vtc +++ b/bin/varnishtest/tests/p00002.vtc @@ -3,7 +3,7 @@ varnishtest "Ban a persistent object" shell "rm -f ${tmpdir}/_.per[12]" server s1 { - rxreq + rxreq txresp -hdr "Foo: foo" } -start @@ -11,7 +11,7 @@ varnish v1 \ -arg "-pfeature=+wait_silo" \ -arg "-pban_lurker_sleep=0" \ -storage "-spersistent,${tmpdir}/_.per1,10m -spersistent,${tmpdir}/_.per2,10m" \ - -vcl+backend { } -start + -vcl+backend { } -start client c1 { txreq -url "/" @@ -26,7 +26,7 @@ varnish v1 -stop server s1 -wait server s1 { - rxreq + rxreq txresp -hdr "Foo: bar" } -start diff --git a/bin/varnishtest/tests/p00003.vtc b/bin/varnishtest/tests/p00003.vtc index 4af3b14..573c8fe 100644 --- a/bin/varnishtest/tests/p00003.vtc +++ b/bin/varnishtest/tests/p00003.vtc @@ -3,7 +3,7 @@ varnishtest "Ban a persistent object" shell "rm -f ${tmpdir}/_.per" server s1 { - rxreq + rxreq txresp -hdr "Foo: foo" } -start @@ -11,7 +11,7 @@ varnish v1 \ -arg "-pfeature=+wait_silo" \ -storage "-spersistent,${tmpdir}/_.per,10m" \ -arg "-pban_lurker_sleep=0" \ - -vcl+backend { } -start + -vcl+backend { } -start varnish v1 -cliok ban.list @@ -29,7 +29,7 @@ varnish v1 -stop server s1 -wait server s1 { - rxreq + rxreq txresp -hdr "Foo: bar" } -start diff --git a/bin/varnishtest/tests/p00004.vtc b/bin/varnishtest/tests/p00004.vtc index f1e4368..21ceaef 100644 --- a/bin/varnishtest/tests/p00004.vtc +++ b/bin/varnishtest/tests/p00004.vtc @@ -3,9 +3,9 @@ varnishtest "Check object references" shell "rm -f ${tmpdir}/_.per" server s1 { - rxreq + rxreq txresp -hdr "Foo: foo" - rxreq + rxreq txresp -hdr "Bar: bar" } -start @@ -13,7 +13,7 @@ varnish v1 \ -arg "-pfeature=+wait_silo" \ -storage "-spersistent,${tmpdir}/_.per,10m" \ -arg "-pban_lurker_sleep=0" \ - -vcl+backend { } -start + -vcl+backend { } -start client c1 { txreq -url "/foo" @@ -36,7 +36,7 @@ client c1 { varnish v1 -expect n_object == 2 varnish v1 -stop -varnish v1 -start +varnish v1 -start varnish v1 -cliok "debug.xid 1999" varnish v1 -expect n_vampireobject == 2 diff --git a/bin/varnishtest/tests/p00005.vtc b/bin/varnishtest/tests/p00005.vtc index a3d7051..f9a3682 100644 --- a/bin/varnishtest/tests/p00005.vtc +++ b/bin/varnishtest/tests/p00005.vtc @@ -3,18 +3,18 @@ varnishtest "Check expiry of non-instantiated object" shell "rm -f ${tmpdir}/_.per" server s1 { - rxreq + rxreq txresp -hdr "Foo: foo1" } -start varnish v1 \ -storage "-spersistent,${tmpdir}/_.per,10m" \ -arg "-pban_lurker_sleep=0" \ - -vcl+backend { + -vcl+backend { sub vcl_backend_response { set beresp.ttl = 3s; } - } -start + } -start varnish v1 -cliok "param.set debug +syncvsl" varnish v1 -cliok "param.set feature +wait_silo" @@ -32,7 +32,7 @@ varnish v1 -expect n_object == 1 varnish v1 -stop server s1 -wait { - rxreq + rxreq txresp -hdr "Foo: foo2" } -start diff --git a/bin/varnishtest/tests/p00006.vtc b/bin/varnishtest/tests/p00006.vtc index 0adb67b..09b88e0 100644 --- a/bin/varnishtest/tests/p00006.vtc +++ b/bin/varnishtest/tests/p00006.vtc @@ -3,9 +3,9 @@ varnishtest "Check that Vary headers are stored" shell "rm -f ${tmpdir}/_.per" server s1 { - rxreq + rxreq txresp -hdr "Foo: foo1" -hdr "Vary: foo, bar" - rxreq + rxreq txresp -hdr "Foo: foo2" -hdr "Vary: foo, bar" } -start @@ -13,7 +13,7 @@ server s1 { varnish v1 \ -storage "-spersistent,${tmpdir}/_.per,10m" \ -arg "-pban_lurker_sleep=0" \ - -vcl+backend { } -start + -vcl+backend { } -start client c1 { txreq -url "/foo" -hdr "foo: 1" -hdr "bar: 2" diff --git a/bin/varnishtest/tests/p00008.vtc b/bin/varnishtest/tests/p00008.vtc index d72c627..4ac6f8b 100644 --- a/bin/varnishtest/tests/p00008.vtc +++ b/bin/varnishtest/tests/p00008.vtc @@ -24,7 +24,7 @@ varnish v1 \ set beresp.storage = "per2"; } } - } -start + } -start client c1 { txreq -url "/silo1" rxresp @@ -63,7 +63,7 @@ varnish v3 -stop # Only silo 2 # Check that /silo2 is banned server s1 { - rxreq + rxreq expect req.url == "/silo2" txresp -hdr "X-Foo: bar" } -start diff --git a/bin/varnishtest/tests/p00009.vtc b/bin/varnishtest/tests/p00009.vtc index 36196d7..a3dcf7b 100644 --- a/bin/varnishtest/tests/p00009.vtc +++ b/bin/varnishtest/tests/p00009.vtc @@ -38,7 +38,7 @@ varnish v1 -expect bans_dups == 1 # Expect ban_magic plus our 1 dup to be marked gone varnish v1 -expect bans_gone == 2 -# Restart +# Restart varnish v1 -stop varnish v1 -start varnish v1 -cliok "ban.list" diff --git a/bin/varnishtest/tests/r00102.vtc b/bin/varnishtest/tests/r00102.vtc index 8c0b784..cf8a1bb 100644 --- a/bin/varnishtest/tests/r00102.vtc +++ b/bin/varnishtest/tests/r00102.vtc @@ -1,19 +1,19 @@ varnishtest "Test POST->GET conversion" server s1 { - rxreq + rxreq txresp \ -hdr "Connection: close" \ -body "012345\n" } -start -varnish v1 -vcl+backend { +varnish v1 -vcl+backend { sub vcl_recv { if (req.method == "POST") { set req.method = "GET"; } } -} -start +} -start client c1 { txreq -req POST -url "/" \ diff --git a/bin/varnishtest/tests/r00251.vtc b/bin/varnishtest/tests/r00251.vtc index a337cce..0b3c741 100644 --- a/bin/varnishtest/tests/r00251.vtc +++ b/bin/varnishtest/tests/r00251.vtc @@ -1,21 +1,21 @@ varnishtest "Regression test for #251: segfault on regsub on missing http header" server s1 { - rxreq + rxreq txresp \ -hdr "Foobar: _barf_" \ -hdr "Connection: close" \ -body "012345\n" } -start -varnish v1 -vcl+backend { +varnish v1 -vcl+backend { sub vcl_backend_response { set beresp.http.Snafu1 = "zoom" + regsub(beresp.http.Foomble, "ar", "\0\0") + "box"; } -} -start +} -start client c1 { txreq -url "/" diff --git a/bin/varnishtest/tests/r00255.vtc b/bin/varnishtest/tests/r00255.vtc index 3a897d7..1aedcc1 100644 --- a/bin/varnishtest/tests/r00255.vtc +++ b/bin/varnishtest/tests/r00255.vtc @@ -1,7 +1,7 @@ varnishtest "Regression test for #255: Segfault on header token separation" server s1 { - rxreq + rxreq txresp \ -hdr "Date: Thu, 19 Jun 2008 21:14:49 GMT" \ -hdr "Expires: Thu, 19 Jun 2008 21:14:49 GMT" \ @@ -10,7 +10,7 @@ server s1 { -body "012345\n" } -start -varnish v1 -vcl+backend { sub vcl_recv {set req.backend = s1;} } -start +varnish v1 -vcl+backend { sub vcl_recv {set req.backend = s1;} } -start client c1 { txreq -url "/" diff --git a/bin/varnishtest/tests/r00262.vtc b/bin/varnishtest/tests/r00262.vtc index 09ed730..b5a9efc 100644 --- a/bin/varnishtest/tests/r00262.vtc +++ b/bin/varnishtest/tests/r00262.vtc @@ -1,13 +1,13 @@ varnishtest "Test that inter-request whitespace trimming works" server s1 { - rxreq + rxreq txresp \ -hdr "Connection: close" \ -body "012345\n" } -start -varnish v1 -arg "-p timeout_linger=20" -vcl+backend { } -start +varnish v1 -arg "-p timeout_linger=20" -vcl+backend { } -start client c1 { send "GET / HTTP/1.1\r\n\r\n\r\n" diff --git a/bin/varnishtest/tests/r00263.vtc b/bin/varnishtest/tests/r00263.vtc index 8ae4bd7..aad4784 100644 --- a/bin/varnishtest/tests/r00263.vtc +++ b/bin/varnishtest/tests/r00263.vtc @@ -19,6 +19,6 @@ varnish v1 -vcl { sub vcl_recv { set req.backend = cluster.backend(); } -} -start +} -start varnish v1 -wait diff --git a/bin/varnishtest/tests/r00292.vtc b/bin/varnishtest/tests/r00292.vtc index 7739e85..f6bc807 100644 --- a/bin/varnishtest/tests/r00292.vtc +++ b/bin/varnishtest/tests/r00292.vtc @@ -15,7 +15,7 @@ server s1 { txresp -body "foobar" } -start -varnish v1 -vcl+backend { +varnish v1 -vcl+backend { sub vcl_recv { remove req.http.hdr1; diff --git a/bin/varnishtest/tests/r00318.vtc b/bin/varnishtest/tests/r00318.vtc index a30bdab..f677a1c 100644 --- a/bin/varnishtest/tests/r00318.vtc +++ b/bin/varnishtest/tests/r00318.vtc @@ -1,7 +1,7 @@ varnishtest "ESI with no body in response" server s1 { - rxreq + rxreq txresp -status 302 } -start @@ -13,7 +13,7 @@ varnish v1 -vcl+backend { } -start client c1 { - txreq + txreq rxresp expect resp.status == 302 } -run diff --git a/bin/varnishtest/tests/r00326.vtc b/bin/varnishtest/tests/r00326.vtc index 09cd013..00ac603 100644 --- a/bin/varnishtest/tests/r00326.vtc +++ b/bin/varnishtest/tests/r00326.vtc @@ -1,9 +1,9 @@ varnishtest "No zerolength verbatim before " server s1 { - rxreq + rxreq txresp -body {} - rxreq + rxreq txresp -body "FOO\n" } -start @@ -14,7 +14,7 @@ varnish v1 -vcl+backend { } -start client c1 { - txreq + txreq rxresp expect resp.status == 200 expect resp.bodylen == 8 diff --git a/bin/varnishtest/tests/r00345.vtc b/bin/varnishtest/tests/r00345.vtc index b6c819a..8ce2d53 100644 --- a/bin/varnishtest/tests/r00345.vtc +++ b/bin/varnishtest/tests/r00345.vtc @@ -1,9 +1,9 @@ varnishtest "#345, ESI waitinglist trouble" server s1 { - rxreq + rxreq txresp -body {} - rxreq + rxreq sema r1 sync 2 delay 1 txresp -body {DATA} diff --git a/bin/varnishtest/tests/r00365.vtc b/bin/varnishtest/tests/r00365.vtc index dc1d590..43c76b3 100644 --- a/bin/varnishtest/tests/r00365.vtc +++ b/bin/varnishtest/tests/r00365.vtc @@ -9,7 +9,7 @@ server s1 { txresp -status 200 -body "22" } -start -varnish v1 -vcl+backend { +varnish v1 -vcl+backend { sub vcl_hit { set obj.ttl = 0s; return (restart); diff --git a/bin/varnishtest/tests/r00386.vtc b/bin/varnishtest/tests/r00386.vtc index 3d43b5a..946d14c 100644 --- a/bin/varnishtest/tests/r00386.vtc +++ b/bin/varnishtest/tests/r00386.vtc @@ -4,7 +4,7 @@ server s1 { rxreq expect req.url == "/body" txresp -hdr "Last-Modified: Tue, 25 Nov 2008 00:00:00 GMT" -body "BODY" - rxreq + rxreq expect req.url == "/" txresp -body {} } -start diff --git a/bin/varnishtest/tests/r00411.vtc b/bin/varnishtest/tests/r00411.vtc index 98c478e..775cd68 100644 --- a/bin/varnishtest/tests/r00411.vtc +++ b/bin/varnishtest/tests/r00411.vtc @@ -10,7 +10,7 @@ server s1 { txresp -status 200 -body "1" } -start -varnish v1 -vcl+backend { +varnish v1 -vcl+backend { sub vcl_hit { if (obj.http.X-Magic-Redirect == "1") { set req.url = obj.http.Location; diff --git a/bin/varnishtest/tests/r00412.vtc b/bin/varnishtest/tests/r00412.vtc index 4cb988b..628dc0f 100644 --- a/bin/varnishtest/tests/r00412.vtc +++ b/bin/varnishtest/tests/r00412.vtc @@ -3,7 +3,7 @@ varnishtest "Regression test for ticket 412" server s1 { rxreq expect req.url == "/" - txresp -status 303 -hdr "Location: /foo" + txresp -status 303 -hdr "Location: /foo" accept rxreq expect req.url == "/foo" diff --git a/bin/varnishtest/tests/r00427.vtc b/bin/varnishtest/tests/r00427.vtc index aa7d6ae..a75247b 100644 --- a/bin/varnishtest/tests/r00427.vtc +++ b/bin/varnishtest/tests/r00427.vtc @@ -6,7 +6,7 @@ server s1 { - } + } rxreq expect req.url == "/foo" diff --git a/bin/varnishtest/tests/r00445.vtc b/bin/varnishtest/tests/r00445.vtc index 137ab15..1d6be3b 100644 --- a/bin/varnishtest/tests/r00445.vtc +++ b/bin/varnishtest/tests/r00445.vtc @@ -6,7 +6,7 @@ server s1 { txresp -body {} rxreq expect req.url == "/bar" - txresp + txresp } -start varnish v1 -vcl+backend { diff --git a/bin/varnishtest/tests/r00466.vtc b/bin/varnishtest/tests/r00466.vtc index e509de8..b672681 100644 --- a/bin/varnishtest/tests/r00466.vtc +++ b/bin/varnishtest/tests/r00466.vtc @@ -1,14 +1,14 @@ varnishtest "Check Range forwarding to backend" server s1 { - rxreq + rxreq expect req.url == "/foo" expect req.http.range == txresp \ -hdr "Foobar: _barf_" \ -body "012345\n" - rxreq + rxreq expect req.url == "/bar" expect req.http.range == "200-300" txresp \ @@ -17,7 +17,7 @@ server s1 { -body "012345\n" } -start -varnish v1 -vcl+backend { +varnish v1 -vcl+backend { sub vcl_recv { if (req.url ~ "bar") { return(pass); diff --git a/bin/varnishtest/tests/r00476.vtc b/bin/varnishtest/tests/r00476.vtc index 976d434..9804d2f 100644 --- a/bin/varnishtest/tests/r00476.vtc +++ b/bin/varnishtest/tests/r00476.vtc @@ -6,7 +6,7 @@ server s1 { txresp -body {\0c} rxreq expect req.url == "/bar" - txresp + txresp rxreq expect req.url == "/comment" txresp -body {\0c} @@ -22,7 +22,7 @@ varnish v1 -vcl+backend { } -start client c1 { - txreq + txreq rxresp expect resp.bodylen == 8 txreq -url /comment diff --git a/bin/varnishtest/tests/r00495.vtc b/bin/varnishtest/tests/r00495.vtc index 76ed867..694c4b2 100644 --- a/bin/varnishtest/tests/r00495.vtc +++ b/bin/varnishtest/tests/r00495.vtc @@ -30,13 +30,13 @@ client c1 { txreq rxresp expect resp.status == 201 - txreq + txreq rxresp expect resp.status == 202 - txreq + txreq rxresp expect resp.status == 203 - txreq + txreq rxresp expect resp.status == 205 } -run diff --git a/bin/varnishtest/tests/r00498.vtc b/bin/varnishtest/tests/r00498.vtc index efdb93a..c9f2520 100644 --- a/bin/varnishtest/tests/r00498.vtc +++ b/bin/varnishtest/tests/r00498.vtc @@ -12,7 +12,7 @@ varnish v1 -vcl+backend { varnish v1 -cliok "param.set http_resp_hdr_len 32768" client c1 { - txreq + txreq rxresp expect resp.bodylen == 3 } -run diff --git a/bin/varnishtest/tests/r00524.vtc b/bin/varnishtest/tests/r00524.vtc index 46445a8..5fbd1f5 100644 --- a/bin/varnishtest/tests/r00524.vtc +++ b/bin/varnishtest/tests/r00524.vtc @@ -4,9 +4,9 @@ server s1 { rxreq expect req.url == "/" txresp -body { - + - + } rxreq @@ -27,5 +27,5 @@ client c1 { txreq -proto HTTP/1.0 -hdr "Connection: kEep-alive" rxresp expect resp.status == 200 - expect resp.bodylen == 18 + expect resp.bodylen == 16 } -run diff --git a/bin/varnishtest/tests/r00561.vtc b/bin/varnishtest/tests/r00561.vtc index 0a273b0..1efc0a7 100644 --- a/bin/varnishtest/tests/r00561.vtc +++ b/bin/varnishtest/tests/r00561.vtc @@ -17,6 +17,6 @@ client c1 { } -run client c1 { - txreq + txreq rxresp } -run diff --git a/bin/varnishtest/tests/r00590.vtc b/bin/varnishtest/tests/r00590.vtc index 960ebd1..ce16ba5 100644 --- a/bin/varnishtest/tests/r00590.vtc +++ b/bin/varnishtest/tests/r00590.vtc @@ -4,50 +4,50 @@ server s1 { rxreq expect req.url == "/" txresp -body { - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + } @@ -69,5 +69,5 @@ client c1 { txreq rxresp expect resp.status == 200 - expect resp.bodylen == 184 + expect resp.bodylen == 140 } -run diff --git a/bin/varnishtest/tests/r00641.vtc b/bin/varnishtest/tests/r00641.vtc index 7fefc8e..a9ad147 100644 --- a/bin/varnishtest/tests/r00641.vtc +++ b/bin/varnishtest/tests/r00641.vtc @@ -4,9 +4,9 @@ server s1 { rxreq expect req.url == "/" txresp -proto HTTP/1.0 -body { - + <_esi:include src="/foo"/> - + } } -start @@ -25,5 +25,5 @@ client c1 { rxresp # XXX this is the problem: expect resp.proto == HTTP/1.1 expect resp.status == 200 - expect resp.bodylen == 39 + expect resp.bodylen == 37 } -run diff --git a/bin/varnishtest/tests/r00679.vtc b/bin/varnishtest/tests/r00679.vtc index ba5ca68..46af597 100644 --- a/bin/varnishtest/tests/r00679.vtc +++ b/bin/varnishtest/tests/r00679.vtc @@ -3,7 +3,7 @@ varnishtest "pass + HEAD" server s1 { rxreq expect req.method == "HEAD" - txresp + txresp } -start varnish v1 -vcl+backend {} -start diff --git a/bin/varnishtest/tests/r00686.vtc b/bin/varnishtest/tests/r00686.vtc index 2163ce4..1813819 100644 --- a/bin/varnishtest/tests/r00686.vtc +++ b/bin/varnishtest/tests/r00686.vtc @@ -5,7 +5,7 @@ server s1 { txresp -hdr "Cache-Control: foo" -hdr "Cache-control: bar" -bodylen 4 } -start -varnish v1 -vcl+backend { +varnish v1 -vcl+backend { sub vcl_deliver { set resp.http.Foo = req.http.cache-control; } diff --git a/bin/varnishtest/tests/r00730.vtc b/bin/varnishtest/tests/r00730.vtc index 4e4fe24..bb416e8 100644 --- a/bin/varnishtest/tests/r00730.vtc +++ b/bin/varnishtest/tests/r00730.vtc @@ -27,7 +27,7 @@ varnish v1 -vcl+backend { sub vcl_backend_response { set beresp.do_stream = false; } -} +} client c1 { txreq -req HEAD diff --git a/bin/varnishtest/tests/r00742.vtc b/bin/varnishtest/tests/r00742.vtc index 008f2f7..1a4dbb5 100644 --- a/bin/varnishtest/tests/r00742.vtc +++ b/bin/varnishtest/tests/r00742.vtc @@ -1,7 +1,7 @@ varnishtest "% escapes in VCL source and vcl.show" server s1 { - rxreq + rxreq txresp } -start diff --git a/bin/varnishtest/tests/r00776.vtc b/bin/varnishtest/tests/r00776.vtc index 53cc37e..530168d 100644 --- a/bin/varnishtest/tests/r00776.vtc +++ b/bin/varnishtest/tests/r00776.vtc @@ -12,6 +12,6 @@ varnish v1 \ -arg "-s malloc,1m" -vcl+backend { } -start client c1 { - txreq + txreq rxresp } -run diff --git a/bin/varnishtest/tests/r00781.vtc b/bin/varnishtest/tests/r00781.vtc index 120c363..2c3562a 100644 --- a/bin/varnishtest/tests/r00781.vtc +++ b/bin/varnishtest/tests/r00781.vtc @@ -15,6 +15,6 @@ varnish v1 -vcl+backend { } -start client c1 { - txreq + txreq rxresp } -run diff --git a/bin/varnishtest/tests/r00795.vtc b/bin/varnishtest/tests/r00795.vtc index 0abfc29..e6aacd4 100644 --- a/bin/varnishtest/tests/r00795.vtc +++ b/bin/varnishtest/tests/r00795.vtc @@ -16,7 +16,7 @@ varnish v1 -vcl+backend { } -start # First load the objects into cache client c1 { - txreq + txreq rxresp expect resp.status == 200 expect resp.bodylen == 3 diff --git a/bin/varnishtest/tests/r00801.vtc b/bin/varnishtest/tests/r00801.vtc index 5800662..f538d7f 100644 --- a/bin/varnishtest/tests/r00801.vtc +++ b/bin/varnishtest/tests/r00801.vtc @@ -17,7 +17,7 @@ varnish v1 -vcl+backend { } -start client c1 { - txreq + txreq rxresp expect resp.http.content-length == "10" } -run diff --git a/bin/varnishtest/tests/r00803.vtc b/bin/varnishtest/tests/r00803.vtc index 50b25fb..467f66f 100644 --- a/bin/varnishtest/tests/r00803.vtc +++ b/bin/varnishtest/tests/r00803.vtc @@ -14,7 +14,7 @@ varnish v1 -vcl+backend { } -start client c1 { - txreq + txreq rxresp -no_obj expect resp.status == 304 } -run diff --git a/bin/varnishtest/tests/r00806.vtc b/bin/varnishtest/tests/r00806.vtc index f5ee9e3..25567b5 100644 --- a/bin/varnishtest/tests/r00806.vtc +++ b/bin/varnishtest/tests/r00806.vtc @@ -19,7 +19,7 @@ varnish v1 -vcl+backend { } -start client c1 { - txreq + txreq rxresp -no_obj expect resp.status == 304 expect resp.http.cl == 100 diff --git a/bin/varnishtest/tests/r00861.vtc b/bin/varnishtest/tests/r00861.vtc index 45a624d..682f3b0 100644 --- a/bin/varnishtest/tests/r00861.vtc +++ b/bin/varnishtest/tests/r00861.vtc @@ -11,7 +11,7 @@ server s1 { expect req.url == "/bar" txresp -body - rxreq + rxreq expect req.url == "/barf" txresp -body {[{"program":true,"id":972389,"vendorId":"15451701","starttime":1297777500000,"endtime":1297783500000,"title":"Swimming Pool","oTitle":"true","genre":"0x10x0","timeshiftEnabled":true},{"program":true,"id":972391,"vendorId":"15451702","starttime":1297783500000,"endtime":1297785000000,"title":"Fashion -Trends","oTitle":null,"genre":"0x30x0","timeshiftEnabled":true},{"program":true,"id":972384,"vendorId":"15451703","starttime":1297785000000,"endtime":1297786500000,"title":"Fashion - m?nd","oTitle":null,"genre":"0x30x0","timeshiftEnabled":true},{"program":true,"id":972388,"vendorId":"15451704","starttime":1297786500000,"endtime":1297789800000,"title":"The Day Before","oTitle":"true","genre":"0x30x0","timeshiftEnabled":true},{"program":true,"id":972393,"vendorId":"15451705","starttime":1297789800000,"endtime":1297793100000,"title":"Kessels ?je","oTitle":null,"genre":"0x20x3","timeshiftEnabled":true}]} diff --git a/bin/varnishtest/tests/r00873.vtc b/bin/varnishtest/tests/r00873.vtc index 7612ad4..8eeb305 100644 --- a/bin/varnishtest/tests/r00873.vtc +++ b/bin/varnishtest/tests/r00873.vtc @@ -1,7 +1,7 @@ varnishtest "Ticket #873" server s1 { - rxreq + rxreq txresp -nolen -hdr "Transfer-encoding: chunked" chunked {} chunked {} @@ -13,7 +13,7 @@ varnish v1 -vcl+backend { set beresp.do_esi = true; set beresp.do_gzip = true; } -} -start +} -start client c1 { txreq -hdr "Accept-Encoding: gzip" diff --git a/bin/varnishtest/tests/r00878.vtc b/bin/varnishtest/tests/r00878.vtc index 55106c9..a7ed048 100644 --- a/bin/varnishtest/tests/r00878.vtc +++ b/bin/varnishtest/tests/r00878.vtc @@ -1,7 +1,7 @@ varnishtest "Loading vmods in subsequent VCLs" server s1 { - rxreq + rxreq txresp -bodylen 4 } -start diff --git a/bin/varnishtest/tests/r00887.vtc b/bin/varnishtest/tests/r00887.vtc index fb9843c..627e2c5 100644 --- a/bin/varnishtest/tests/r00887.vtc +++ b/bin/varnishtest/tests/r00887.vtc @@ -1,20 +1,20 @@ varnishtest "Ticket #887" server s1 { - rxreq + rxreq txresp -hdr "Cache-control: max-age=-1000" -body "FOO" - rxreq + rxreq txresp -body "FOOBAR" } -start varnish v1 -vcl+backend { -} -start +} -start client c1 { - txreq + txreq rxresp expect resp.bodylen == 3 - txreq + txreq rxresp expect resp.bodylen == 6 } -run diff --git a/bin/varnishtest/tests/r00894.vtc b/bin/varnishtest/tests/r00894.vtc index 39b8fba..04a793d 100644 --- a/bin/varnishtest/tests/r00894.vtc +++ b/bin/varnishtest/tests/r00894.vtc @@ -1,7 +1,7 @@ varnishtest "Ticket #894" server s1 { - rxreq + rxreq txresp -body {} } -start @@ -9,10 +9,10 @@ varnish v1 -vcl+backend { sub vcl_backend_response { set beresp.do_esi = true; } -} -start +} -start client c1 { - txreq + txreq rxresp expect resp.bodylen == 10 } -run diff --git a/bin/varnishtest/tests/r00896.vtc b/bin/varnishtest/tests/r00896.vtc index b559075..c713a59 100644 --- a/bin/varnishtest/tests/r00896.vtc +++ b/bin/varnishtest/tests/r00896.vtc @@ -1,7 +1,7 @@ varnishtest "Ticket #896, strings over 256 bytes" server s1 { - rxreq + rxreq txresp } -start @@ -11,10 +11,10 @@ varnish v1 -vcl+backend { return (error(500,"not ok")); } } -} -start +} -start client c1 { - txreq + txreq rxresp expect resp.status == 200 } -run diff --git a/bin/varnishtest/tests/r00902.vtc b/bin/varnishtest/tests/r00902.vtc index 8caf652..c125061 100644 --- a/bin/varnishtest/tests/r00902.vtc +++ b/bin/varnishtest/tests/r00902.vtc @@ -1,7 +1,7 @@ varnishtest "Ticket #902 http_CollectHdr() failure on consequitive headers" server s1 { - rxreq + rxreq txresp \ -hdr "Server: Microsoft-IIS/5.0" \ -hdr "Cache-Control: A" \ @@ -13,13 +13,13 @@ server s1 { } -start varnish v1 -vcl+backend { -} -start +} -start varnish v1 -cliok "param.set debug +req_state" client c1 { txreq -hdr "foo: /foo" - rxresp + rxresp expect resp.http.cache-control == "A, B, C, D" expect resp.http.foo == "bar" } -run diff --git a/bin/varnishtest/tests/r00907.vtc b/bin/varnishtest/tests/r00907.vtc index 679dab2..8bb1139 100644 --- a/bin/varnishtest/tests/r00907.vtc +++ b/bin/varnishtest/tests/r00907.vtc @@ -1,7 +1,7 @@ varnishtest "Ticket #907 200/304 handling with Etags + Last-Modified" server s1 { - rxreq + rxreq txresp \ -hdr "ETag: saengei1Ohshicich4iteesu" \ -hdr "Last-Modified: Tue, 20 Sep 2011 18:55:00 GMT" @@ -11,7 +11,7 @@ varnish v1 -vcl+backend { sub vcl_deliver { set resp.http.x-timestamp = now; } -} -start +} -start client c1 { txreq -hdr "If-None-Match: saengei1Ohshicich4iteesu" diff --git a/bin/varnishtest/tests/r00911.vtc b/bin/varnishtest/tests/r00911.vtc index 5663421..7f87421 100644 --- a/bin/varnishtest/tests/r00911.vtc +++ b/bin/varnishtest/tests/r00911.vtc @@ -6,7 +6,7 @@ server s1 { txresp -body "foobar" } -start -varnish v1 -arg "-p vcc_err_unref=false" -vcl+backend { +varnish v1 -arg "-p vcc_err_unref=false" -vcl+backend { sub foobar { set req.http.foobar = "foobar"; } @@ -14,6 +14,6 @@ varnish v1 -arg "-p vcc_err_unref=false" -vcl+backend { client c1 { txreq -url /bar - rxresp + rxresp expect resp.bodylen == 6 } -run diff --git a/bin/varnishtest/tests/r00913.vtc b/bin/varnishtest/tests/r00913.vtc index 3e8672d..4f08396 100644 --- a/bin/varnishtest/tests/r00913.vtc +++ b/bin/varnishtest/tests/r00913.vtc @@ -16,7 +16,7 @@ varnish v1 -vcl+backend { client c1 { txreq -url /bar - rxresp + rxresp expect resp.bodylen == 6 expect resp.http.foo == "XXX" } -run diff --git a/bin/varnishtest/tests/r00915.vtc b/bin/varnishtest/tests/r00915.vtc index bcb1510..e66cdc6 100644 --- a/bin/varnishtest/tests/r00915.vtc +++ b/bin/varnishtest/tests/r00915.vtc @@ -1,8 +1,8 @@ varnishtest "error object allocation with persistent" server s1 { - rxreq - txresp + rxreq + txresp } -start shell "rm -f ${tmpdir}/_.per" @@ -10,7 +10,7 @@ shell "rm -f ${tmpdir}/_.per" varnish v1 \ -arg "-pfeature=+wait_silo" \ -storage "-spersistent,${tmpdir}/_.per,10m" \ - -vcl+backend { + -vcl+backend { sub vcl_backend_response { set beresp.uncacheable = false; @@ -18,7 +18,7 @@ varnish v1 \ set beresp.status = 751; return (deliver); } -} -start +} -start client c1 { txreq -url "/" diff --git a/bin/varnishtest/tests/r00917.vtc b/bin/varnishtest/tests/r00917.vtc index 689d952..588513f 100644 --- a/bin/varnishtest/tests/r00917.vtc +++ b/bin/varnishtest/tests/r00917.vtc @@ -10,7 +10,7 @@ varnish v1 -vcl+backend { } -start client c1 { txreq -url /bar - rxresp + rxresp expect resp.bodylen == 6 } -run diff --git a/bin/varnishtest/tests/r00921.vtc b/bin/varnishtest/tests/r00921.vtc index d3e643d..e207c18 100644 --- a/bin/varnishtest/tests/r00921.vtc +++ b/bin/varnishtest/tests/r00921.vtc @@ -1,18 +1,18 @@ varnishtest "VCC type issue in regsub arg 1" server s1 { - rxreq + rxreq expect req.http.foo == "127.0.0.1" expect req.http.bar == "127.0.0.1" - txresp + txresp } -start -varnish v1 -vcl+backend { +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 +} -start client c1 { txreq -url "/" diff --git a/bin/varnishtest/tests/r00942.vtc b/bin/varnishtest/tests/r00942.vtc index e6c45b0..f4c808a 100644 --- a/bin/varnishtest/tests/r00942.vtc +++ b/bin/varnishtest/tests/r00942.vtc @@ -29,7 +29,7 @@ varnish v1 \ sub vcl_backend_response { set beresp.do_stream = false; } -} +} varnish v1 -cliok "param.set debug +syncvsl" varnish v1 -start diff --git a/bin/varnishtest/tests/r00962.vtc b/bin/varnishtest/tests/r00962.vtc index 21f01a8..22ebbc1 100644 --- a/bin/varnishtest/tests/r00962.vtc +++ b/bin/varnishtest/tests/r00962.vtc @@ -4,8 +4,8 @@ varnishtest "Test address remapping" feature not-OSX server s1 { - rxreq - txresp + rxreq + txresp } -start shell "rm -f ${tmpdir}/_.per?" @@ -13,11 +13,11 @@ shell "rm -f ${tmpdir}/_.per?" varnish v1 \ -arg "-pfeature=+wait_silo" \ -storage "-spersistent,${tmpdir}/_.per1,10m -spersistent,${tmpdir}/_.per2,10m" \ - -vcl+backend { + -vcl+backend { sub vcl_backend_response { set beresp.storage = "s0"; } -} -start +} -start varnish v1 -stop @@ -36,7 +36,7 @@ varnish v1 -cliok "debug.persistent s0 sync" varnish v1 -stop server s1 { - rxreq + rxreq txresp -status 400 -msg "Persistent Object Not Found" } -start @@ -44,7 +44,7 @@ server s1 { varnish v2 \ -arg "-pfeature=+wait_silo" \ -storage "-spersistent,${tmpdir}/_.per2,10m -spersistent,${tmpdir}/_.per1,10m" \ - -vcl+backend { } -start + -vcl+backend { } -start client c1 -connect ${v2_sock} { txreq -url "/" diff --git a/bin/varnishtest/tests/r01073.vtc b/bin/varnishtest/tests/r01073.vtc index b9f0e87..58d8ae6 100644 --- a/bin/varnishtest/tests/r01073.vtc +++ b/bin/varnishtest/tests/r01073.vtc @@ -1,7 +1,7 @@ varnishtest "Test that hash_always_miss also implies hash_ignore_busy. Ticket #1073." server s1 { - rxreq + rxreq sema r1 sync 2 sema r2 sync 2 delay 1 @@ -14,7 +14,7 @@ server s2 { txresp -hdr "Server: 2" } -start -varnish v1 -vcl+backend { +varnish v1 -vcl+backend { sub vcl_recv { if (req.http.x-hash-always-miss == "1") { set req.hash_always_miss = true; @@ -26,7 +26,7 @@ varnish v1 -vcl+backend { set req.backend = s2; } } -} -start +} -start client c1 { txreq -url "/" -hdr "x-client: 1" diff --git a/bin/varnishtest/tests/r01092.vtc b/bin/varnishtest/tests/r01092.vtc index 7248e49..7512ea4 100644 --- a/bin/varnishtest/tests/r01092.vtc +++ b/bin/varnishtest/tests/r01092.vtc @@ -22,7 +22,7 @@ varnish v1 -vcl+backend { sub vcl_backend_response { set beresp.do_esi = true; } -} -start +} -start client c1 { txreq diff --git a/bin/varnishtest/tests/r01109.vtc b/bin/varnishtest/tests/r01109.vtc index 46ef404..9fb4153 100644 --- a/bin/varnishtest/tests/r01109.vtc +++ b/bin/varnishtest/tests/r01109.vtc @@ -21,7 +21,11 @@ server s1 { txresp -bodylen 4074 } -start -varnish v1 -arg "-pfetch_chunksize=4k" -arg "-pgzip_level=0" -arg "-pthread_pool_stack=131072" -vcl+backend { +varnish v1 \ + -arg "-pfetch_chunksize=4k" \ + -arg "-pgzip_level=0" \ + -arg "-pthread_pool_stack=131072" \ + -vcl+backend { sub vcl_backend_response { if (bereq.url ~ "/test") { set beresp.do_esi = true; diff --git a/bin/varnishtest/tests/r01140.vtc b/bin/varnishtest/tests/r01140.vtc index 98abc61..688181b 100644 --- a/bin/varnishtest/tests/r01140.vtc +++ b/bin/varnishtest/tests/r01140.vtc @@ -19,7 +19,7 @@ server s1 { } -start varnish v1 -arg "-p nuke_limit=0 -p shortlived=0" \ - -storage "-smalloc,1m" -vcl+backend { + -storage "-smalloc,1m" -vcl+backend { sub vcl_backend_response { set beresp.do_stream = false; } diff --git a/bin/varnishtest/tests/r01164.vtc b/bin/varnishtest/tests/r01164.vtc index 43c0996..b9072e1 100644 --- a/bin/varnishtest/tests/r01164.vtc +++ b/bin/varnishtest/tests/r01164.vtc @@ -7,7 +7,7 @@ varnish v1 -vcl { sub vcl_recv { set req.backend = storage_foo; - } + } } varnish v1 -vcl { @@ -17,7 +17,7 @@ varnish v1 -vcl { sub vcl_recv { set req.backend = storagefoo; - } + } } diff --git a/bin/varnishtest/tests/r01225.vtc b/bin/varnishtest/tests/r01225.vtc index 5ae42b3..3338d75 100644 --- a/bin/varnishtest/tests/r01225.vtc +++ b/bin/varnishtest/tests/r01225.vtc @@ -3,7 +3,7 @@ varnishtest "Test bans_req counter on persistent reload - #1225" shell "rm -f ${tmpdir}/_.per" server s1 { - rxreq + rxreq expect req.url == "/" txresp -hdr "Foo: foo" } -start @@ -12,7 +12,7 @@ varnish v1 \ -arg "-pfeature=+wait_silo" \ -storage "-spersistent,${tmpdir}/_.per,10m" \ -arg "-pban_lurker_sleep=0.01" \ - -vcl+backend { } -start + -vcl+backend { } -start varnish v1 -cliok ban.list @@ -35,7 +35,7 @@ varnish v1 -stop server s1 -wait server s1 { - rxreq + rxreq expect req.url == "/" txresp -hdr "Foo: bar" } -start diff --git a/bin/varnishtest/tests/r01283.vtc b/bin/varnishtest/tests/r01283.vtc index fab7ee2..e193e58 100644 --- a/bin/varnishtest/tests/r01283.vtc +++ b/bin/varnishtest/tests/r01283.vtc @@ -5,7 +5,10 @@ server s1 { txresp -bodylen 1048198 } -start -varnish v1 -arg "-p nuke_limit=0" -storage "-sTransient=malloc,1m" -vcl+backend { +varnish v1 \ + -arg "-p nuke_limit=0" \ + -storage "-sTransient=malloc,1m" \ + -vcl+backend { sub vcl_recv { if (req.http.x-do-error) { return (error(500)); diff --git a/bin/varnishtest/tests/r01284.vtc b/bin/varnishtest/tests/r01284.vtc index 92c1a51..5407685 100644 --- a/bin/varnishtest/tests/r01284.vtc +++ b/bin/varnishtest/tests/r01284.vtc @@ -9,7 +9,10 @@ server s1 { txresp -hdr "Long: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" -hdr "Long2: aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" } -start -varnish v1 -arg "-p nuke_limit=0" -storage "-sTransient=malloc,1m" -vcl+backend { +varnish v1 \ + -arg "-p nuke_limit=0" \ + -storage "-sTransient=malloc,1m" \ + -vcl+backend { sub vcl_backend_response { set beresp.do_stream = false; set beresp.storage = "Transient"; diff --git a/bin/varnishtest/tests/r01356.vtc b/bin/varnishtest/tests/r01356.vtc index f0c00b2..1aaa337 100644 --- a/bin/varnishtest/tests/r01356.vtc +++ b/bin/varnishtest/tests/r01356.vtc @@ -31,7 +31,7 @@ server s1 { } -start client c1 { - txreq + txreq rxresp expect resp.status == 200 } -run diff --git a/bin/varnishtest/tests/r01367.vtc b/bin/varnishtest/tests/r01367.vtc index cb2b1f8..3a57258 100644 --- a/bin/varnishtest/tests/r01367.vtc +++ b/bin/varnishtest/tests/r01367.vtc @@ -5,7 +5,7 @@ server s1 { txresp } -start -varnish v1 -vcl+backend { +varnish v1 -vcl+backend { sub vcl_error { return (restart); } diff --git a/bin/varnishtest/tests/s00002.vtc b/bin/varnishtest/tests/s00002.vtc index f4cca57..10049c0 100644 --- a/bin/varnishtest/tests/s00002.vtc +++ b/bin/varnishtest/tests/s00002.vtc @@ -35,21 +35,21 @@ server s1 { } -start varnish v1 -vcl { - backend b { - .host = "${s1_addr}"; - .port = "${s1_port}"; - .probe = { - .url = "/"; - .timeout = 30ms; - .interval = 1s; - .window = 2; - .threshold = 1; + backend b { + .host = "${s1_addr}"; + .port = "${s1_port}"; + .probe = { + .url = "/"; + .timeout = 30ms; + .interval = 1s; + .window = 2; + .threshold = 1; .initial = 0; - } + } } - sub vcl_backend_response { - set beresp.ttl = 1s; - set beresp.grace = 1m; + sub vcl_backend_response { + set beresp.ttl = 1s; + set beresp.grace = 1m; } } -start diff --git a/bin/varnishtest/tests/v00000.vtc b/bin/varnishtest/tests/v00000.vtc index b2676b6..fc22294 100644 --- a/bin/varnishtest/tests/v00000.vtc +++ b/bin/varnishtest/tests/v00000.vtc @@ -2,11 +2,11 @@ varnishtest "VCL/VRT: req.grace, obj.ttl and obj.grace" server s1 { - rxreq + rxreq txresp -hdr "Connection: close" -body "012345\n" } -server s1 -start +server s1 -start varnish v1 -vcl+backend { sub vcl_recv { diff --git a/bin/varnishtest/tests/v00001.vtc b/bin/varnishtest/tests/v00001.vtc index ebe802b..4f77f25 100644 --- a/bin/varnishtest/tests/v00001.vtc +++ b/bin/varnishtest/tests/v00001.vtc @@ -2,11 +2,11 @@ varnishtest "VCL/VRT: url/request/proto/response/status" server s1 { - rxreq + rxreq txresp -hdr "Connection: close" -body "012345\n" } -server s1 -start +server s1 -start varnish v1 -vcl+backend { sub vcl_recv { diff --git a/bin/varnishtest/tests/v00005.vtc b/bin/varnishtest/tests/v00005.vtc index 0b4b780..4e37653 100644 --- a/bin/varnishtest/tests/v00005.vtc +++ b/bin/varnishtest/tests/v00005.vtc @@ -25,7 +25,7 @@ varnish v1 -vcl { backend b1 { .host = "127.0.0.1"; .probe = { - .request = + .request = "GET / HTTP/1.1" "Host: foo.bar" ; } @@ -38,7 +38,7 @@ varnish v1 -errvcl {Probe request redefinition at:} { .host = "127.0.0.1"; .probe = { .url = "/"; - .request = + .request = "GET / HTTP/1.1" "Host: foo.bar" ; } @@ -50,7 +50,7 @@ varnish v1 -errvcl {Probe request redefinition at:} { backend b1 { .host = "127.0.0.1"; .probe = { - .request = + .request = "GET / HTTP/1.1" "Host: foo.bar" ; .url = "/"; diff --git a/bin/varnishtest/tests/v00008.vtc b/bin/varnishtest/tests/v00008.vtc index 9cd01eb..add54ef 100644 --- a/bin/varnishtest/tests/v00008.vtc +++ b/bin/varnishtest/tests/v00008.vtc @@ -34,7 +34,7 @@ varnish v1 -vcl { .port = "${s2_port}"; .host_header = "FOObar"; } -} +} client c1 { txreq -url "/barf" diff --git a/bin/varnishtest/tests/v00011.vtc b/bin/varnishtest/tests/v00011.vtc index b815127..d9fad31 100644 --- a/bin/varnishtest/tests/v00011.vtc +++ b/bin/varnishtest/tests/v00011.vtc @@ -8,7 +8,7 @@ server s1 { txresp -body "foo" } -start -varnish v1 -vcl+backend { +varnish v1 -vcl+backend { sub vcl_recv { if (req.method == "PURGE") { ban("req.url ~ ^/$"); @@ -19,7 +19,7 @@ varnish v1 -vcl+backend { } -start client c1 { - txreq + txreq rxresp expect resp.http.X-Varnish == "1001" } -run diff --git a/bin/varnishtest/tests/v00013.vtc b/bin/varnishtest/tests/v00013.vtc index 882342f..fa3afda 100644 --- a/bin/varnishtest/tests/v00013.vtc +++ b/bin/varnishtest/tests/v00013.vtc @@ -41,4 +41,4 @@ client c1 { expect resp.status == 200 expect resp.http.foo == 2 expect resp.http.bar >= 0.100 -} -run +} -run diff --git a/bin/varnishtest/tests/v00015.vtc b/bin/varnishtest/tests/v00015.vtc index c5441d0..1838a08 100644 --- a/bin/varnishtest/tests/v00015.vtc +++ b/bin/varnishtest/tests/v00015.vtc @@ -5,7 +5,7 @@ server s1 { expect req.url == "/" expect req.http.foobar == "snafu" txresp -body "slash" -} -start +} -start varnish v1 -vcl+backend { diff --git a/bin/varnishtest/tests/v00016.vtc b/bin/varnishtest/tests/v00016.vtc index 2d323b0..a155dd0 100644 --- a/bin/varnishtest/tests/v00016.vtc +++ b/bin/varnishtest/tests/v00016.vtc @@ -32,7 +32,7 @@ varnish v1 -vcl { varnish v1 -errvcl {include not followed by string constant.} { /* token test */ error lookup hash pipe pass fetch deliver discard keep restart - include + include if else elseif elsif ++ -- && || <= == != >= >> << += -= *= /= { } ( ) * + - / % > < = ; ! & . | ~ , @@ -70,7 +70,7 @@ varnish v1 -vcl { set beresp.ttl = 1h; } } - + } varnish v1 -errvcl {Unknown time unit 'k'. Legal are 's', 'm', 'h' and 'd'} { diff --git a/bin/varnishtest/tests/v00017.vtc b/bin/varnishtest/tests/v00017.vtc index ba0c8e4..1e6cce0 100644 --- a/bin/varnishtest/tests/v00017.vtc +++ b/bin/varnishtest/tests/v00017.vtc @@ -57,9 +57,9 @@ varnish v1 -errvcl {Expected ';' got ')'} { varnish v1 -vcl { backend b { .host = "127.0.0.1"; } acl a { - ! "10.1.3"; - ("...com" / 22); - (!"...com"); + ! "10.1.3"; + ("...com" / 22); + (!"...com"); } sub vcl_recv { if (client.ip ~ a) { return(pass); } } } @@ -78,12 +78,12 @@ varnish v1 -errvcl {Operator > not possible on IP} { varnish v1 -vcl { backend b { .host = "127.0.0.1"; } acl a { - "10.1.1"/25; - "10.1.3"/26; - "10.1.3"/25; - "10.1.2"/25; - "10.1.2"/26; - "10.1.4"/25; + "10.1.1"/25; + "10.1.3"/26; + "10.1.3"/25; + "10.1.2"/25; + "10.1.2"/26; + "10.1.4"/25; "10.2.66"/23; ! "10.2.64"/23; "10.2.68"/23; diff --git a/bin/varnishtest/tests/v00022.vtc b/bin/varnishtest/tests/v00022.vtc index 5bfb1fe..e6c2c0b 100644 --- a/bin/varnishtest/tests/v00022.vtc +++ b/bin/varnishtest/tests/v00022.vtc @@ -54,34 +54,34 @@ varnish v1 -vcl+backend { varnish v1 -cliok "debug.srandom 1" client c1 { - txreq + txreq rxresp expect resp.bodylen == 2 - txreq + txreq rxresp expect resp.bodylen == 4 - txreq + txreq rxresp expect resp.bodylen == 4 - txreq + txreq rxresp expect resp.bodylen == 4 - txreq + txreq rxresp expect resp.bodylen == 1 - txreq + txreq rxresp expect resp.bodylen == 2 - txreq + txreq rxresp expect resp.bodylen == 4 - txreq + txreq rxresp expect resp.bodylen == 2 - txreq + txreq rxresp expect resp.bodylen == 3 - txreq + txreq rxresp expect resp.bodylen == 2 } -run diff --git a/bin/varnishtest/tests/v00023.vtc b/bin/varnishtest/tests/v00023.vtc index ca36194..e96585a 100644 --- a/bin/varnishtest/tests/v00023.vtc +++ b/bin/varnishtest/tests/v00023.vtc @@ -9,7 +9,7 @@ server s1 { txresp -status 200 -body "22" } -start -varnish v1 -vcl+backend { +varnish v1 -vcl+backend { sub vcl_hit { set obj.ttl = 0s; return (restart); diff --git a/bin/varnishtest/tests/v00024.vtc b/bin/varnishtest/tests/v00024.vtc index 5ef311a..f112559 100644 --- a/bin/varnishtest/tests/v00024.vtc +++ b/bin/varnishtest/tests/v00024.vtc @@ -6,7 +6,7 @@ server s1 { txresp -status 200 -body "1" } -start -varnish v1 -vcl+backend { +varnish v1 -vcl+backend { sub vcl_recv { if (req.http.etag == req.http.if-none-match) { return(error(400,"FOO")); diff --git a/bin/varnishtest/tests/v00027.vtc b/bin/varnishtest/tests/v00027.vtc index 42cb312..72a7030 100644 --- a/bin/varnishtest/tests/v00027.vtc +++ b/bin/varnishtest/tests/v00027.vtc @@ -12,7 +12,7 @@ server s2 { varnish v1 -vcl { backend s1 { - .host = "${s1_addr}"; + .host = "${s1_addr}"; .port = "${s1_port}"; } backend default { From phk at varnish-cache.org Fri Nov 8 10:47:02 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Fri, 08 Nov 2013 11:47:02 +0100 Subject: [master] 09f5878 Use unsigned chars when creating the secret file, in order to not annoy FlexeLint. Message-ID: commit 09f58783a3f0ebc1f0421e1712b49d32a8385683 Author: Poul-Henning Kamp Date: Fri Nov 8 10:46:23 2013 +0000 Use unsigned chars when creating the secret file, in order to not annoy FlexeLint. diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index 5debd26..d21324f 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -317,7 +317,7 @@ make_secret(const char *dirname) char *fn; int fd; int i; - char buf[256]; + unsigned char buf[256]; assert(asprintf(&fn, "%s/_.secret", dirname) > 0); @@ -329,7 +329,7 @@ make_secret(const char *dirname) } srandomdev(); for (i = 0; i < sizeof buf; i++) - buf[i] = random(); + buf[i] = random() & 0xff; assert(sizeof buf == write(fd, buf, sizeof buf)); AZ(close(fd)); return (fn); From phk at varnish-cache.org Fri Nov 8 11:01:16 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Fri, 08 Nov 2013 12:01:16 +0100 Subject: [master] 457708d Change default storage to "-smalloc,100m" Message-ID: commit 457708df7d926be7d65e5e58260d00a2d70063e3 Author: Poul-Henning Kamp Date: Fri Nov 8 11:00:02 2013 +0000 Change default storage to "-smalloc,100m" Reflect this change in varnishtest, and retire the "-storage" keyword, storage settings can now be done with -arg. diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index d21324f..739d441 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -166,8 +166,8 @@ usage(void) fprintf(stderr, FMT, "-p param=value", "set parameter"); fprintf(stderr, FMT, "-r param[,param...]", "make parameter read-only"); fprintf(stderr, FMT, - "-s kind[,storageoptions]", "Backend storage specification"); - fprintf(stderr, FMT, "", " -s malloc"); + "-s [name=]kind[,options]", "Backend storage specification"); + fprintf(stderr, FMT, "", " -s malloc[,]"); #ifdef HAVE_LIBUMEM fprintf(stderr, FMT, "", " -s umem"); #endif @@ -351,7 +351,7 @@ main(int argc, char * const *argv) const char *n_arg = NULL; const char *P_arg = NULL; const char *S_arg = NULL; - const char *s_arg = "file"; + const char *s_arg = "malloc,100m"; int s_arg_given = 0; const char *T_arg = NULL; char *p, *vcl = NULL; diff --git a/bin/varnishtest/tests/b00000.vtc b/bin/varnishtest/tests/b00000.vtc index f514f2b..2e34a13 100644 --- a/bin/varnishtest/tests/b00000.vtc +++ b/bin/varnishtest/tests/b00000.vtc @@ -5,7 +5,7 @@ server s1 { txresp -body "012345\n" } -start -varnish v1 -storage "-smalloc,1m" -vcl+backend {} -start +varnish v1 -vcl+backend {} -start varnish v1 -cliok "param.set debug +workspace" diff --git a/bin/varnishtest/tests/c00044.vtc b/bin/varnishtest/tests/c00044.vtc index 8d4078b..f7b4f38 100644 --- a/bin/varnishtest/tests/c00044.vtc +++ b/bin/varnishtest/tests/c00044.vtc @@ -17,7 +17,11 @@ server s1 { txresp -bodylen 1047194 } -start -varnish v1 -storage "-smalloc,1m -smalloc,1m, -smalloc,1m" -vcl+backend { +varnish v1 \ + -arg "-smalloc,1m" \ + -arg "-smalloc,1m" \ + -arg "-smalloc,1m" \ + -vcl+backend { sub vcl_backend_response { set beresp.do_stream = false; set beresp.storage = "invalid"; diff --git a/bin/varnishtest/tests/c00045.vtc b/bin/varnishtest/tests/c00045.vtc index 9168158..23967fa 100644 --- a/bin/varnishtest/tests/c00045.vtc +++ b/bin/varnishtest/tests/c00045.vtc @@ -9,7 +9,11 @@ server s1 { txresp -bodylen 1047190 } -start -varnish v1 -storage "-smalloc,1m -smalloc,1m, -smalloc,1m" -vcl+backend { +varnish v1 \ + -arg "-smalloc,1m" \ + -arg "-smalloc,1m" \ + -arg "-smalloc,1m" \ + -vcl+backend { sub vcl_backend_response { set beresp.do_stream = false; set beresp.storage = "s0"; diff --git a/bin/varnishtest/tests/c00046.vtc b/bin/varnishtest/tests/c00046.vtc index 8982a92..a2e1d2b 100644 --- a/bin/varnishtest/tests/c00046.vtc +++ b/bin/varnishtest/tests/c00046.vtc @@ -9,7 +9,11 @@ server s1 { txresp -bodylen 1000002 } -start -varnish v1 -storage "-smalloc,1m -smalloc,1m, -smalloc,1m" -vcl+backend { +varnish v1 \ + -arg "-smalloc,1m" \ + -arg "-smalloc,1m" \ + -arg "-smalloc,1m" \ + -vcl+backend { sub vcl_backend_response { set beresp.storage = "s0"; } diff --git a/bin/varnishtest/tests/e00007.vtc b/bin/varnishtest/tests/e00007.vtc index 0f5d86a..519759c 100644 --- a/bin/varnishtest/tests/e00007.vtc +++ b/bin/varnishtest/tests/e00007.vtc @@ -31,7 +31,7 @@ server s1 { } } -start -varnish v1 -storage "-smalloc,2m" -vcl+backend { +varnish v1 -arg "-smalloc,2m" -vcl+backend { sub vcl_backend_response { set beresp.do_esi = true; } diff --git a/bin/varnishtest/tests/g00002.vtc b/bin/varnishtest/tests/g00002.vtc index 5605b25..6c1597c 100644 --- a/bin/varnishtest/tests/g00002.vtc +++ b/bin/varnishtest/tests/g00002.vtc @@ -12,7 +12,7 @@ server s1 { } -start varnish v1 \ - -storage "-smalloc,2m" \ + -arg "-smalloc,2m" \ -cliok "param.set http_gzip_support true" \ -cliok "param.set gzip_memlevel 1" \ -vcl+backend { diff --git a/bin/varnishtest/tests/p00000.vtc b/bin/varnishtest/tests/p00000.vtc index 461da5f..ab59ccf 100644 --- a/bin/varnishtest/tests/p00000.vtc +++ b/bin/varnishtest/tests/p00000.vtc @@ -9,7 +9,7 @@ shell "rm -f ${tmpdir}/_.per" varnish v1 \ -arg "-pfeature=+wait_silo" \ - -storage "-spersistent,${tmpdir}/_.per,10m" \ + -arg "-spersistent,${tmpdir}/_.per,10m" \ -vcl+backend { } -start varnish v1 -stop diff --git a/bin/varnishtest/tests/p00001.vtc b/bin/varnishtest/tests/p00001.vtc index 626b47d..8c38715 100644 --- a/bin/varnishtest/tests/p00001.vtc +++ b/bin/varnishtest/tests/p00001.vtc @@ -10,7 +10,7 @@ server s1 { varnish v1 \ -arg "-pfeature=+wait_silo" \ -arg "-pban_lurker_sleep=0" \ - -storage "-spersistent,${tmpdir}/_.per,10m" \ + -arg "-spersistent,${tmpdir}/_.per,10m" \ -vcl+backend { } -start varnish v1 -cliok "param.set default_grace 0" diff --git a/bin/varnishtest/tests/p00002.vtc b/bin/varnishtest/tests/p00002.vtc index 4475918..1e04ebc 100644 --- a/bin/varnishtest/tests/p00002.vtc +++ b/bin/varnishtest/tests/p00002.vtc @@ -10,7 +10,8 @@ server s1 { varnish v1 \ -arg "-pfeature=+wait_silo" \ -arg "-pban_lurker_sleep=0" \ - -storage "-spersistent,${tmpdir}/_.per1,10m -spersistent,${tmpdir}/_.per2,10m" \ + -arg "-spersistent,${tmpdir}/_.per1,10m" \ + -arg "-spersistent,${tmpdir}/_.per2,10m" \ -vcl+backend { } -start client c1 { diff --git a/bin/varnishtest/tests/p00003.vtc b/bin/varnishtest/tests/p00003.vtc index 573c8fe..0e8eec7 100644 --- a/bin/varnishtest/tests/p00003.vtc +++ b/bin/varnishtest/tests/p00003.vtc @@ -9,7 +9,7 @@ server s1 { varnish v1 \ -arg "-pfeature=+wait_silo" \ - -storage "-spersistent,${tmpdir}/_.per,10m" \ + -arg "-spersistent,${tmpdir}/_.per,10m" \ -arg "-pban_lurker_sleep=0" \ -vcl+backend { } -start diff --git a/bin/varnishtest/tests/p00004.vtc b/bin/varnishtest/tests/p00004.vtc index 21ceaef..c3aea98 100644 --- a/bin/varnishtest/tests/p00004.vtc +++ b/bin/varnishtest/tests/p00004.vtc @@ -11,7 +11,7 @@ server s1 { varnish v1 \ -arg "-pfeature=+wait_silo" \ - -storage "-spersistent,${tmpdir}/_.per,10m" \ + -arg "-spersistent,${tmpdir}/_.per,10m" \ -arg "-pban_lurker_sleep=0" \ -vcl+backend { } -start diff --git a/bin/varnishtest/tests/p00005.vtc b/bin/varnishtest/tests/p00005.vtc index f9a3682..dc95677 100644 --- a/bin/varnishtest/tests/p00005.vtc +++ b/bin/varnishtest/tests/p00005.vtc @@ -8,7 +8,7 @@ server s1 { } -start varnish v1 \ - -storage "-spersistent,${tmpdir}/_.per,10m" \ + -arg "-spersistent,${tmpdir}/_.per,10m" \ -arg "-pban_lurker_sleep=0" \ -vcl+backend { sub vcl_backend_response { diff --git a/bin/varnishtest/tests/p00006.vtc b/bin/varnishtest/tests/p00006.vtc index 09b88e0..96f4d17 100644 --- a/bin/varnishtest/tests/p00006.vtc +++ b/bin/varnishtest/tests/p00006.vtc @@ -11,7 +11,7 @@ server s1 { varnish v1 \ - -storage "-spersistent,${tmpdir}/_.per,10m" \ + -arg "-spersistent,${tmpdir}/_.per,10m" \ -arg "-pban_lurker_sleep=0" \ -vcl+backend { } -start diff --git a/bin/varnishtest/tests/p00007.vtc b/bin/varnishtest/tests/p00007.vtc index 7dc2e68..ca6d04d 100644 --- a/bin/varnishtest/tests/p00007.vtc +++ b/bin/varnishtest/tests/p00007.vtc @@ -24,7 +24,7 @@ server s1 { txresp -bodylen 48 } -start -varnish v1 -storage "-spersistent,${tmpdir}/_.per,10m" \ +varnish v1 -arg "-spersistent,${tmpdir}/_.per,10m" \ -vcl+backend {} -start varnish v1 -cliok "debug.fragfetch 32" diff --git a/bin/varnishtest/tests/p00008.vtc b/bin/varnishtest/tests/p00008.vtc index 4ac6f8b..411c4b4 100644 --- a/bin/varnishtest/tests/p00008.vtc +++ b/bin/varnishtest/tests/p00008.vtc @@ -16,7 +16,8 @@ server s1 { varnish v1 \ -arg "-pfeature=+wait_silo" \ -arg "-pban_lurker_sleep=0" \ - -storage "-sper1=persistent,${tmpdir}/_.per1,10m -sper2=persistent,${tmpdir}/_.per2,10m" \ + -arg "-sper1=persistent,${tmpdir}/_.per1,10m" \ + -arg "-sper2=persistent,${tmpdir}/_.per2,10m" \ -vcl+backend { sub vcl_backend_response { set beresp.storage = "per1"; @@ -44,7 +45,7 @@ server s1 -wait varnish v2 \ -arg "-pfeature=+wait_silo" \ -arg "-pban_lurker_sleep=0" \ - -storage "-spersistent,${tmpdir}/_.per1,10m" \ + -arg "-spersistent,${tmpdir}/_.per1,10m" \ -vcl+backend { } -start varnish v2 -cliok "ban obj.http.x-foo == foo" varnish v2 -cliok "ban.list" @@ -55,7 +56,8 @@ varnish v2 -stop varnish v3 \ -arg "-pfeature=+wait_silo" \ -arg "-pban_lurker_sleep=0" \ - -storage "-spersistent,${tmpdir}/_.per1,10m -spersistent,${tmpdir}/_.per2,10m" \ + -arg "-spersistent,${tmpdir}/_.per1,10m" \ + -arg "-spersistent,${tmpdir}/_.per2,10m" \ -vcl+backend { } -start varnish v3 -cliok "ban.list" varnish v3 -stop @@ -70,7 +72,7 @@ server s1 { varnish v4 \ -arg "-pfeature=+wait_silo" \ -arg "-pban_lurker_sleep=0" \ - -storage "-spersistent,${tmpdir}/_.per2,10m" \ + -arg "-spersistent,${tmpdir}/_.per2,10m" \ -vcl+backend { } -start client c1 -connect ${v4_sock} { txreq -url "/silo2" diff --git a/bin/varnishtest/tests/p00009.vtc b/bin/varnishtest/tests/p00009.vtc index a3dcf7b..47f216d 100644 --- a/bin/varnishtest/tests/p00009.vtc +++ b/bin/varnishtest/tests/p00009.vtc @@ -14,7 +14,8 @@ server s1 { varnish v1 \ -arg "-pfeature=+wait_silo" \ -arg "-pban_lurker_sleep=0" \ - -storage "-sper1=persistent,${tmpdir}/_.per1,10m -sper2=persistent,${tmpdir}/_.per2,10m" \ + -arg "-sper1=persistent,${tmpdir}/_.per1,10m" \ + -arg "-sper2=persistent,${tmpdir}/_.per2,10m" \ -vcl+backend { } varnish v1 -start diff --git a/bin/varnishtest/tests/r00915.vtc b/bin/varnishtest/tests/r00915.vtc index e66cdc6..607d6db 100644 --- a/bin/varnishtest/tests/r00915.vtc +++ b/bin/varnishtest/tests/r00915.vtc @@ -9,7 +9,7 @@ shell "rm -f ${tmpdir}/_.per" varnish v1 \ -arg "-pfeature=+wait_silo" \ - -storage "-spersistent,${tmpdir}/_.per,10m" \ + -arg "-spersistent,${tmpdir}/_.per,10m" \ -vcl+backend { sub vcl_backend_response { diff --git a/bin/varnishtest/tests/r00962.vtc b/bin/varnishtest/tests/r00962.vtc index 22ebbc1..9cae4cf 100644 --- a/bin/varnishtest/tests/r00962.vtc +++ b/bin/varnishtest/tests/r00962.vtc @@ -12,7 +12,8 @@ shell "rm -f ${tmpdir}/_.per?" varnish v1 \ -arg "-pfeature=+wait_silo" \ - -storage "-spersistent,${tmpdir}/_.per1,10m -spersistent,${tmpdir}/_.per2,10m" \ + -arg "-spersistent,${tmpdir}/_.per1,10m" \ + -arg "-spersistent,${tmpdir}/_.per2,10m" \ -vcl+backend { sub vcl_backend_response { set beresp.storage = "s0"; @@ -43,7 +44,8 @@ server s1 { varnish v2 \ -arg "-pfeature=+wait_silo" \ - -storage "-spersistent,${tmpdir}/_.per2,10m -spersistent,${tmpdir}/_.per1,10m" \ + -arg "-spersistent,${tmpdir}/_.per2,10m" \ + -arg "-spersistent,${tmpdir}/_.per1,10m" \ -vcl+backend { } -start client c1 -connect ${v2_sock} { diff --git a/bin/varnishtest/tests/r01140.vtc b/bin/varnishtest/tests/r01140.vtc index 688181b..e38e304 100644 --- a/bin/varnishtest/tests/r01140.vtc +++ b/bin/varnishtest/tests/r01140.vtc @@ -19,7 +19,7 @@ server s1 { } -start varnish v1 -arg "-p nuke_limit=0 -p shortlived=0" \ - -storage "-smalloc,1m" -vcl+backend { + -arg "-smalloc,1m" -vcl+backend { sub vcl_backend_response { set beresp.do_stream = false; } diff --git a/bin/varnishtest/tests/r01175.vtc b/bin/varnishtest/tests/r01175.vtc index e7c05bf..5539b20 100644 --- a/bin/varnishtest/tests/r01175.vtc +++ b/bin/varnishtest/tests/r01175.vtc @@ -5,7 +5,7 @@ server s1 { txresp -nolen -hdr "Content-Length: 1048576" } -start -varnish v1 -storage "-s test=malloc,1M" -vcl+backend { +varnish v1 -arg "-s test=malloc,1M" -vcl+backend { sub vcl_backend_response { set beresp.storage = "test"; set beresp.do_stream = false; diff --git a/bin/varnishtest/tests/r01176.vtc b/bin/varnishtest/tests/r01176.vtc index d9a0a99..0af3a5f 100644 --- a/bin/varnishtest/tests/r01176.vtc +++ b/bin/varnishtest/tests/r01176.vtc @@ -5,7 +5,7 @@ server s1 { txresp } -start -varnish v1 -storage "-s Transient=malloc" -vcl+backend {} -start +varnish v1 -arg "-s Transient=malloc" -vcl+backend {} -start client c1 { txreq diff --git a/bin/varnishtest/tests/r01225.vtc b/bin/varnishtest/tests/r01225.vtc index 3338d75..23d0253 100644 --- a/bin/varnishtest/tests/r01225.vtc +++ b/bin/varnishtest/tests/r01225.vtc @@ -10,7 +10,7 @@ server s1 { varnish v1 \ -arg "-pfeature=+wait_silo" \ - -storage "-spersistent,${tmpdir}/_.per,10m" \ + -arg "-spersistent,${tmpdir}/_.per,10m" \ -arg "-pban_lurker_sleep=0.01" \ -vcl+backend { } -start diff --git a/bin/varnishtest/tests/r01266.vtc b/bin/varnishtest/tests/r01266.vtc index 49f2c67..04e3cb9 100644 --- a/bin/varnishtest/tests/r01266.vtc +++ b/bin/varnishtest/tests/r01266.vtc @@ -12,7 +12,7 @@ server s1 { varnish v1 \ -arg "-pfeature=+wait_silo" \ -arg "-pban_lurker_sleep=0.01" \ - -storage "-sper1=persistent,${tmpdir}/_.per1,10m" \ + -arg "-sper1=persistent,${tmpdir}/_.per1,10m" \ -vcl+backend { } varnish v1 -start diff --git a/bin/varnishtest/tests/r01283.vtc b/bin/varnishtest/tests/r01283.vtc index e193e58..015b2fa 100644 --- a/bin/varnishtest/tests/r01283.vtc +++ b/bin/varnishtest/tests/r01283.vtc @@ -7,7 +7,7 @@ server s1 { varnish v1 \ -arg "-p nuke_limit=0" \ - -storage "-sTransient=malloc,1m" \ + -arg "-sTransient=malloc,1m" \ -vcl+backend { sub vcl_recv { if (req.http.x-do-error) { diff --git a/bin/varnishtest/tests/r01284.vtc b/bin/varnishtest/tests/r01284.vtc index 5407685..68dc456 100644 --- a/bin/varnishtest/tests/r01284.vtc +++ b/bin/varnishtest/tests/r01284.vtc @@ -11,7 +11,7 @@ server s1 { varnish v1 \ -arg "-p nuke_limit=0" \ - -storage "-sTransient=malloc,1m" \ + -arg "-sTransient=malloc,1m" \ -vcl+backend { sub vcl_backend_response { set beresp.do_stream = false; diff --git a/bin/varnishtest/tests/v00010.vtc b/bin/varnishtest/tests/v00010.vtc index c5f8fa5..58afdac 100644 --- a/bin/varnishtest/tests/v00010.vtc +++ b/bin/varnishtest/tests/v00010.vtc @@ -21,7 +21,7 @@ server s1 { txresp -hdr "Foo: foo" -body "abcdef\n" } -start -varnish v1 -storage "-smalloc,1m" -vcl+backend { +varnish v1 -arg "-smalloc,1m" -vcl+backend { import debug from "${topbuild}/lib/libvmod_debug/.libs/libvmod_debug.so"; diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c index e5a520c..a958fb0 100644 --- a/bin/varnishtest/vtc_varnish.c +++ b/bin/varnishtest/vtc_varnish.c @@ -57,8 +57,6 @@ struct varnish { struct vtclog *vl; VTAILQ_ENTRY(varnish) list; - struct vsb *storage; - struct vsb *args; int fds[4]; pid_t pid; @@ -285,10 +283,6 @@ varnish_new(const char *name) 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->cli_fd = -1; VTAILQ_INSERT_TAIL(&varnishes, v, list); @@ -391,7 +385,6 @@ varnish_launch(struct varnish *v) VSB_printf(vsb, " -a '%s'", "127.0.0.1:0"); VSB_printf(vsb, " -M '%s %s'", abuf, pbuf); VSB_printf(vsb, " -P %s/varnishd.pid", v->workdir); - VSB_printf(vsb, " %s", VSB_data(v->storage)); VSB_printf(vsb, " %s", VSB_data(v->args)); AZ(VSB_finish(vsb)); vtc_log(v->vl, 3, "CMD: %s", VSB_data(vsb)); @@ -854,13 +847,6 @@ cmd_varnish(CMD_ARGS) for (; *av != NULL; av++) { if (vtc_error) break; - if (!strcmp(*av, "-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); From phk at varnish-cache.org Fri Nov 8 11:41:27 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Fri, 08 Nov 2013 12:41:27 +0100 Subject: [master] 14bb031 Update the security section to reflect that -S is default now. Message-ID: commit 14bb03120021e847f33b9e2f8f58fe84d2246ce1 Author: Poul-Henning Kamp Date: Fri Nov 8 11:41:08 2013 +0000 Update the security section to reflect that -S is default now. diff --git a/doc/sphinx/users-guide/run_security.rst b/doc/sphinx/users-guide/run_security.rst index 080bb80..29862b3 100644 --- a/doc/sphinx/users-guide/run_security.rst +++ b/doc/sphinx/users-guide/run_security.rst @@ -42,55 +42,91 @@ The important decisions to make are: CLI interface access ^^^^^^^^^^^^^^^^^^^^ -The most important of these is the CLI interface: Should it be -accessible only on the local machine, or should it be accessible -also from across the network ? +The command line interface can be accessed three ways. -No matter what you do, you should always protect the CLI with a -Pre-Shared-Key (The -S argument). - -The way -S/PSK works is really simple: You specify -S and filename, -and only somebody who knows the exact contents of that file can -access the CLI. By protecting the secret file with suitable UNIX -permissions, you can restrict CLI access - -The varnishadm(8) program knows how to do the -S/PSK protocol, -both locally and remote. - -(XXX ref: user-guide: setting up -S) - -The CLI port is a TCP socket, and it can be bound to any IP -number+socket combination the kernel will accept:: +Varnishd can be told til listen and offer CLI connections +on a TCP socket. You can bind the socket to pretty +much anything the kernel will accept:: -T 127.0.0.1:631 -T localhost:9999 -T 192.168.1.1:34 -T '[fe80::1]:8082' -If you want to be able to use the CLI remotely, you can do it -two ways. +By using a "localhost" address, you can restrict CLI access +to the local machine. + +You can also bind the CLI port to an IP number reachable across +the net, and let other computers connect directly. -You can bind the CLI port to a reachable IP number, and connect -directly. This gives you no secrecy, ie, the CLI commands will +This gives you no secrecy, ie, the CLI commands will go across the network as ASCII text with no encryption, but -using the -S option, you will get authentication. +the -S/PSK authentication requires the remote end to know +the shared secret. Alternatively you can bind the CLI port to a 'localhost' address, and give remote users access via a secure connection to the local -machine (ssh, VPN, etc. etc.) +machine, using ssh/VPN or similar. + +If you use ssh you can restrict which commands each user can execute to +just varnishadm, or even to wrapper scripts around varnishadm, which +only allow specific CLI commands. It is also possible to configure varnishd for "reverse mode", using the '-M' argument. In that case varnishd will attempt to open a TCP connection to the specified address, and initiate a CLI connection to your central varnish management facility. -The connection is also in this case without secrecy, but if configured +The connection is also in this case without secrecy, but the remote end must still satisfy -S/PSK authentication. Finally, if you run varnishd with the '-d' option, you get a CLI command on stdin/stdout, but since you started the process, it would be hard to prevent you getting CLI access, wouldn't it ? +CLI interface authentication +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +By default the CLI interface is protected with a simple, yet +strong "Pre Shared Key" authentication method, which do not provide +secrecy (ie: The CLI commands and responses are not encrypted). + +The way -S/PSK works is really simple: During startup a file is +created with a random content and the file is only accessible to +the user who started varnishd (or the superuser). + +To authenticate and use a CLI connection, you need to know the +contents of that file, in order to answer the cryptographic +challenge varnishd issues. (XXX: xref to algo in refman) + +The varnishadm program knows all about this, it will just work, +provided it can read the secret file. + +If you want to allow other users on the local system or remote +users, to be able to access CLI connections, you must create your +own secret file and make it possible for (only!) these users to +read it. + +A good way to create the secret file is:: + + dd if=/dev/random of=/etc/varnish_secret count=1 + +When you start varnishd, you specify the filename with -S, and +it goes without saying that the varnishd master process needs +to be able to read the file too. + +You can change the contents of the secret file while varnishd +runs, it is read every time a CLI connection is authenticated. + +On the local system, varnishadm can find the filename from +shared memory, but on remote systems, you need to give it +a copy of the secret file, with the -S argument. + +If you want to disable -S/PSK authentication, specify -S with +an empty argument to varnishd:: + + varnishd [...] -S "" [...] + Parameters ^^^^^^^^^^ From phk at varnish-cache.org Fri Nov 8 20:18:44 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Fri, 08 Nov 2013 21:18:44 +0100 Subject: [master] ba20559 Add a coverage test for -sfile Message-ID: commit ba20559c952a011bb322a93c26e81e8590c2dd4e Author: Poul-Henning Kamp Date: Fri Nov 8 20:18:25 2013 +0000 Add a coverage test for -sfile diff --git a/bin/varnishtest/tests/s00003.vtc b/bin/varnishtest/tests/s00003.vtc new file mode 100644 index 0000000..c9a5e9f --- /dev/null +++ b/bin/varnishtest/tests/s00003.vtc @@ -0,0 +1,41 @@ +varnishtest "Coverage test for -sfile" + +server s1 { + rxreq + txresp -nolen -hdr "Transfer-encoding: chunked" + chunkedlen 65536 + chunkedlen 65536 + chunkedlen 65536 + chunkedlen 65536 + chunkedlen 1 + chunkedlen 0 + + rxreq + txresp -nolen -hdr "Transfer-encoding: chunked" + chunkedlen 262 + chunkedlen 0 +} -start + +varnish v1 \ + -arg "-sfile,${tmpdir}/_.file,10m" \ + -vcl+backend { + sub vcl_backend_response { + set beresp.do_stream = false; + set beresp.ttl = 0.1s; + set beresp.grace = 0.1s; + set beresp.keep = 0.1s; + } + } \ + -start + +client c1 { + txreq + rxresp + expect resp.bodylen == 262145 + + delay 2 + + txreq + rxresp + expect resp.bodylen == 262 +} -run From phk at varnish-cache.org Sun Nov 10 08:39:15 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Sun, 10 Nov 2013 09:39:15 +0100 Subject: [master] dc55fe1 Add a VSL tag "Storage" which tells us which stevedore the object went into. Message-ID: commit dc55fe108e7633c478e8150e741d44ee6c64a561 Author: Poul-Henning Kamp Date: Sun Nov 10 08:38:27 2013 +0000 Add a VSL tag "Storage" which tells us which stevedore the object went into. diff --git a/bin/varnishd/storage/stevedore.c b/bin/varnishd/storage/stevedore.c index 5d91630..dd9d7d3 100644 --- a/bin/varnishd/storage/stevedore.c +++ b/bin/varnishd/storage/stevedore.c @@ -296,6 +296,7 @@ STV_MkObject(struct stevedore *stv, struct busyobj *bo, o->objcore->methods = &default_oc_methods; o->objcore->priv = o; o->objcore->priv2 = (uintptr_t)stv; + VSLb(bo->vsl, SLT_Storage, "%s %s", stv->name, stv->ident); return (o); } diff --git a/include/tbl/vsl_tags.h b/include/tbl/vsl_tags.h index 8ee6b2a..f4e5b2f 100644 --- a/include/tbl/vsl_tags.h +++ b/include/tbl/vsl_tags.h @@ -451,4 +451,13 @@ SLTM(VSL, 0, "VSL API warnings and error message", " reading the shared memory log.\n\n" ) +SLTM(Storage, 0, "Where object is stored", + "Type and name of stevedore object is stored in.\n\n" + "The format is::\n\n" + "\t%s %s\n" + "\t| |\n" + "\t| +- Name of stevedore\n" + "\t+---- Type (\"malloc\", \"file\", \"persistent\" etc.)\n" + "\n" +) #undef NODEF_NOTICE From phk at varnish-cache.org Sun Nov 10 08:39:15 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Sun, 10 Nov 2013 09:39:15 +0100 Subject: [master] 7dd89f8 Force the object into the -sfile storage Message-ID: commit 7dd89f87ecb05f9b77d246f6748b6823881cf79a Author: Poul-Henning Kamp Date: Sun Nov 10 08:38:55 2013 +0000 Force the object into the -sfile storage diff --git a/bin/varnishtest/tests/s00003.vtc b/bin/varnishtest/tests/s00003.vtc index c9a5e9f..35cc252 100644 --- a/bin/varnishtest/tests/s00003.vtc +++ b/bin/varnishtest/tests/s00003.vtc @@ -17,7 +17,7 @@ server s1 { } -start varnish v1 \ - -arg "-sfile,${tmpdir}/_.file,10m" \ + -arg "-sTransient=file,${tmpdir}/_.file,10m" \ -vcl+backend { sub vcl_backend_response { set beresp.do_stream = false; From phk at varnish-cache.org Mon Nov 11 07:59:46 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 11 Nov 2013 08:59:46 +0100 Subject: [master] 56234c1 Move the EXP_Touch() logic into EXP_Touch(). Message-ID: commit 56234c12da25fdeeb8299c9ae574da25c4d2ae53 Author: Poul-Henning Kamp Date: Mon Nov 11 07:59:14 2013 +0000 Move the EXP_Touch() logic into EXP_Touch(). diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 17f7f1f..e7bffde 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -915,7 +915,7 @@ void EXP_Inject(struct objcore *oc, struct lru *lru, double when); void EXP_Init(void); void EXP_Rearm(struct object *o, double now, double ttl, double grace, double keep); -int EXP_Touch(struct objcore *oc); +void EXP_Touch(struct objcore *oc, double now); int EXP_NukeOne(struct busyobj *, struct lru *lru); void EXP_NukeLRU(struct worker *wrk, struct vsl_log *vsl, struct lru *lru); diff --git a/bin/varnishd/cache/cache_expire.c b/bin/varnishd/cache/cache_expire.c index 40f9c33..e3feee9 100644 --- a/bin/varnishd/cache/cache_expire.c +++ b/bin/varnishd/cache/cache_expire.c @@ -177,13 +177,19 @@ EXP_Insert(struct objcore *oc) * This optimization obviously leaves the LRU list imperfectly sorted. */ -int -EXP_Touch(struct objcore *oc) +void +EXP_Touch(struct objcore *oc, double now) { struct lru *lru; CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); + if (oc->busyobj != NULL) + return; + + if (now - oc->last_lru < cache_param->lru_timeout) + return; + lru = oc_getlru(oc); CHECK_OBJ_NOTNULL(lru, LRU_MAGIC); @@ -192,21 +198,21 @@ EXP_Touch(struct objcore *oc) * objects on the lru list, since LRU doesn't really help much. */ if (lru->flags & LRU_F_DONTMOVE) - return (0); + return; if (Lck_Trylock(&lru->mtx)) - return (0); + return; AN(oc->flags & OC_F_EXP); if (!(oc->flags & OC_F_OFFLRU)) { - /* Can only it while it's actually on the LRU list */ + /* Can only touch it while it's actually on the LRU list */ VTAILQ_REMOVE(&lru->lru_head, oc, lru_list); VTAILQ_INSERT_TAIL(&lru->lru_head, oc, lru_list); VSC_C_main->n_lru_moved++; } + oc->last_lru = now; Lck_Unlock(&lru->mtx); - return (1); } /*-------------------------------------------------------------------- diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 9218584..bab3b61 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -104,12 +104,8 @@ cnt_deliver(struct worker *wrk, struct req *req) assert(req->obj->objcore->refcnt > 0); req->t_resp = W_TIM_real(wrk); - if (!(req->obj->objcore->flags & OC_F_PRIVATE)) { - if (req->obj->objcore->busyobj == NULL && - (req->t_resp - req->obj->objcore->last_lru) > - cache_param->lru_timeout && EXP_Touch(req->obj->objcore)) - req->obj->objcore->last_lru = req->t_resp; - } + if (!(req->obj->objcore->flags & OC_F_PRIVATE)) + EXP_Touch(req->obj->objcore, req->t_resp); HTTP_Setup(req->resp, req->ws, req->vsl, HTTP_Resp); From phk at varnish-cache.org Mon Nov 11 08:28:19 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 11 Nov 2013 09:28:19 +0100 Subject: [master] 630711d Now that we have -S as default, also make "-T localhost:0" the default. Message-ID: commit 630711dba22be5efd9be2bc74896cefaa4d99dfa Author: Poul-Henning Kamp Date: Mon Nov 11 08:26:47 2013 +0000 Now that we have -S as default, also make "-T localhost:0" the default. This picks a random port number, possibly two, one for IPv4 and one for IPv6, and varnishadm() can find those in VSM. diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index 739d441..8b6fd82 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -353,7 +353,7 @@ main(int argc, char * const *argv) const char *S_arg = NULL; const char *s_arg = "malloc,100m"; int s_arg_given = 0; - const char *T_arg = NULL; + const char *T_arg = "localhost:0"; char *p, *vcl = NULL; struct cli cli[1]; struct vpf_fh *pfh = NULL; @@ -511,7 +511,10 @@ main(int argc, char * const *argv) S_arg = optarg; break; case 'T': - T_arg = optarg; + if (*optarg != '\0') + T_arg = optarg; + else + T_arg = NULL; break; case 'u': MCF_ParamSet(cli, "user", optarg); From phk at varnish-cache.org Mon Nov 11 08:44:44 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 11 Nov 2013 09:44:44 +0100 Subject: [master] 6e7b2b2 Align documentation with new defaults. Message-ID: commit 6e7b2b22b1ea01a0db173cbbcd1c28672b2823a4 Author: Poul-Henning Kamp Date: Mon Nov 11 08:44:21 2013 +0000 Align documentation with new defaults. diff --git a/doc/sphinx/users-guide/command-line.rst b/doc/sphinx/users-guide/command-line.rst index d3b5240..ea44323 100644 --- a/doc/sphinx/users-guide/command-line.rst +++ b/doc/sphinx/users-guide/command-line.rst @@ -1,27 +1,30 @@ .. _users-guide-command-line: -Typical command line options ----------------------------- +Important command line arguments +-------------------------------- -If you run Varnish out of a package for your operating system, -you will find the default options here: +There a two command line arguments you will simply have choose +values for, what TCP port serve HTTP from and where the backend +server can be contacted. + +If you run Varnish from a package for your operating system, +you will find the startup options here: * Debian, Ubuntu: /etc/default/varnish * Red Hat, Centos: /etc/sysconfig/varnish * FreeBSD: /etc/rc.conf (See also: /usr/local/etc/rc.d/varnishd) -There some command line options you will simply have choose values for: -a *listen_address* ^^^^^^^^^^^^^^^^^^^ -What address should Varnish listen to and service HTTP requests on. +What address should Varnish listen to, and service HTTP requests from. You will most likely want to set this to ":80" which is the Well Known Port for HTTP. You can specify multiple addresses separated by a comma, and you -can use numeric or host/service names as you like, varnish will try +can use numeric or host/service names if you like, varnish will try to open and service as many of them as possible, but if none of them can be opened, varnishd will not start. @@ -40,8 +43,7 @@ it to another port number first. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Varnish needs to know where to find the HTTP server it is caching for. -You can either specify it with -b and use the default VCL code, or you -can put it in your own VCL file. +You can either specify it with -b, or you can put it in your own VCL file. Using -b is a quick way to get started:: @@ -60,38 +62,26 @@ If you go with -f, you can start with a VCL file containing just:: which is exactly what -b does. --s *storage-options* -^^^^^^^^^^^^^^^^^^^^ - -This is probably the most important one. The default is to use -the memory storage backend and to allocate a small amount of -memory. On a small site this might suffice. If you have dedicated -Varnish Cache server you most definitivly want to increase -the memory allocated or consider another backend. -Please note that in addition to the memory allocated by the -storage engine itself Varnish also has internal data structures -that consume memory. More or less 1kb per object. -See also :ref:`guide-storage`. - --T *CLI-listen-address* -^^^^^^^^^^^^^^^^^^^^^^^ - -Varnish has a built-in text-based administration -interface. Activating the interface makes Varnish manageble -without stopping it. You can specify what interface the -management interface should listen to. Make sure you don't expose -the management interface to the world as you can easily gain root -access to a system via the Varnish management interface. I -recommend tieing it to localhost. If you have users on your -system that you don't fully trust, use firewall rules to restrict -access to the interface to root only. - --S *CLI-secret-file* -^^^^^^^^^^^^^^^^^^^^ - -This file stores a secret you must know, in order to get -access to the CLI. +In both cases the default VCL code is appended. + +Other options +^^^^^^^^^^^^^ + +Varnish has more command line arguments you can and maybe want +to tweak, but to get started, the above will be sufficient. + +By default Varnish will use 100 megabytes of malloc(3) storage +for caching objects, if you want to cache more than that, you +should look at the '-s' argument. + +If you run a really big site, you may want to tune the size of +the tread-pools and other parameters with the '-p' argument, +but we generally advice not to do that, unless you need to. + +Before you go into production, you may also want to re-visit the +chapter +:ref:`run_security` to see if you need to partition administrative +privileges. For a complete list of the command line parameters please see :ref:`ref-varnishd-options`. - diff --git a/doc/sphinx/users-guide/run_security.rst b/doc/sphinx/users-guide/run_security.rst index 29862b3..7eda18e 100644 --- a/doc/sphinx/users-guide/run_security.rst +++ b/doc/sphinx/users-guide/run_security.rst @@ -53,7 +53,11 @@ much anything the kernel will accept:: -T 192.168.1.1:34 -T '[fe80::1]:8082' -By using a "localhost" address, you can restrict CLI access +The default is '-T localhost:0' which will pick a random +port number, which varnishadm(8) can learn in the shared +memory. + +By using a "localhost" address, you restrict CLI access to the local machine. You can also bind the CLI port to an IP number reachable across From phk at varnish-cache.org Mon Nov 11 11:23:58 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 11 Nov 2013 12:23:58 +0100 Subject: [master] 0e1c5d1 Allow the /mask to be inside the "....." in ACLs. Message-ID: commit 0e1c5d10d0d30b04ff572294ea06563b7d92f46c Author: Poul-Henning Kamp Date: Mon Nov 11 11:23:36 2013 +0000 Allow the /mask to be inside the "....." in ACLs. diff --git a/bin/varnishtest/tests/v00017.vtc b/bin/varnishtest/tests/v00017.vtc index 1e6cce0..49eec50 100644 --- a/bin/varnishtest/tests/v00017.vtc +++ b/bin/varnishtest/tests/v00017.vtc @@ -90,3 +90,19 @@ varnish v1 -vcl { } sub vcl_recv { if (client.ip ~ a) { return(pass); } } } + +varnish v1 -errvcl {.../mask is not numeric.} { + backend b { .host = "127.0.0.1"; } + acl a { + "10.0.1.0/1bc"; + } + sub vcl_recv { if (client.ip ~ a) { return(pass); } } +} + +varnish v1 -errvcl {/mask only allowed once} { + backend b { .host = "127.0.0.1"; } + acl a { + "10.0.1.0/22" / 22; + } + sub vcl_recv { if (client.ip ~ a) { return(pass); } } +} diff --git a/lib/libvcc/vcc_acl.c b/lib/libvcc/vcc_acl.c index 182dbec..6f473e9 100644 --- a/lib/libvcc/vcc_acl.c +++ b/lib/libvcc/vcc_acl.c @@ -37,6 +37,7 @@ #include #include #include +#include #include #include "vcc_compile.h" @@ -49,6 +50,7 @@ struct acl_e { unsigned mask; unsigned not; unsigned para; + char *addr; struct token *t_addr; struct token *t_mask; }; @@ -171,12 +173,12 @@ vcc_acl_try_getaddrinfo(struct vcc *tl, struct acl_e *ae) memset(&hint, 0, sizeof hint); hint.ai_family = PF_UNSPEC; hint.ai_socktype = SOCK_STREAM; - error = getaddrinfo(ae->t_addr->dec, "0", &hint, &res0); + error = getaddrinfo(ae->addr, "0", &hint, &res0); if (error) { if (ae->para) { VSB_printf(tl->sb, "Warning: %s ignored\n -- %s\n", - ae->t_addr->dec, gai_strerror(error)); + ae->addr, gai_strerror(error)); Fh(tl, 1, "/* Ignored ACL entry: %s%s", ae->para ? "\"(\" " : "", ae->not ? "\"!\" " : ""); EncToken(tl->fh, ae->t_addr); @@ -188,7 +190,7 @@ vcc_acl_try_getaddrinfo(struct vcc *tl, struct acl_e *ae) } else { VSB_printf(tl->sb, "DNS lookup(%s): %s\n", - ae->t_addr->dec, gai_strerror(error)); + ae->addr, gai_strerror(error)); vcc_ErrWhere(tl, ae->t_addr); } return; @@ -252,7 +254,7 @@ vcc_acl_try_netnotation(struct vcc *tl, struct acl_e *ae) const char *p; memset(b, 0, sizeof b); - p = ae->t_addr->dec; + p = ae->addr; for (i = 0; i < 4; i++) { j = sscanf(p, "%u%n", &u, &k); if (j != 1) @@ -276,6 +278,7 @@ static void vcc_acl_entry(struct vcc *tl) { struct acl_e *ae; + char *sl, *e; ae = TlAlloc(tl, sizeof *ae); AN(ae); @@ -297,9 +300,28 @@ vcc_acl_entry(struct vcc *tl) ExpectErr(tl, CSTR); ae->t_addr = tl->t; + ae->addr = strdup(ae->t_addr->dec); + AN(ae->addr); vcc_NextToken(tl); - if (tl->t->tok == '/') { + if (strchr(ae->t_addr->dec, '/') != NULL) { + sl = strchr(ae->addr, '/'); + AN(sl); + *sl++ = '\0'; + e = NULL; + ae->mask = strtoul(sl, &e, 10); + if (*e != '\0') { + VSB_printf(tl->sb, ".../mask is not numeric.\n"); + vcc_ErrWhere(tl, ae->t_addr); + return; + } + ae->t_mask = ae->t_addr; + if (tl->t->tok == '/') { + VSB_printf(tl->sb, "/mask only allowed once.\n"); + vcc_ErrWhere(tl, tl->t); + return; + } + } else if (tl->t->tok == '/') { vcc_NextToken(tl); ae->t_mask = tl->t; ExpectErr(tl, CNUM); @@ -327,6 +349,7 @@ vcc_acl_emit(const struct vcc *tl, const char *acln, int anon) int depth, l, m, i; unsigned at[VRT_ACL_MAXADDR + 1]; const char *oc; + struct token *t; Fh(tl, 0, "\nstatic int\n"); Fh(tl, 0, "match_acl_%s_%s(const struct vrt_ctx *ctx, const VCL_IP p)\n", @@ -391,9 +414,19 @@ vcc_acl_emit(const struct vcc *tl, const char *acln, int anon) if (!anon) { Fh(tl, 0, "\t%*sVRT_acl_log(ctx, \"%sMATCH %s \" ", -i, "", ae->not ? "NEG_" : "", acln); - EncToken(tl->fh, ae->t_addr); - if (ae->t_mask != NULL) - Fh(tl, 0, " \"/%.*s\" ", PF(ae->t_mask)); + t = ae->t_addr; + do { + if (t->tok == CSTR) { + Fh(tl, 0, " \"\\\"\" " ); + EncToken(tl->fh, t); + Fh(tl, 0, " \"\\\"\" " ); + } else + Fh(tl, 0, " \"%.*s\"", PF(t)); + if (t == ae->t_mask) + break; + t = VTAILQ_NEXT(t, list); + AN(t); + } while (ae->t_mask != NULL); Fh(tl, 0, ");\n"); } From phk at varnish-cache.org Mon Nov 11 12:16:39 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 11 Nov 2013 13:16:39 +0100 Subject: [master] bf34388 A user-guide section about bossing varnishd around with the CLI Message-ID: commit bf3438809acd85ec2047888ee2f521ae18e4e759 Author: Poul-Henning Kamp Date: Mon Nov 11 12:16:22 2013 +0000 A user-guide section about bossing varnishd around with the CLI diff --git a/doc/sphinx/users-guide/run_cli.rst b/doc/sphinx/users-guide/run_cli.rst new file mode 100644 index 0000000..2b5509a --- /dev/null +++ b/doc/sphinx/users-guide/run_cli.rst @@ -0,0 +1,167 @@ +.. _run_cli: + +CLI - bossing Varnish around +============================ + +Once varnishd is started, you can control it using the command line +interface. + +The easiest way to do this, is using the varnishadm program on the +same machine as varnishd is running:: + + varnishadm help + +If you want to run varnishadm from a remote system, you can do it +two ways. + +You can ssh into the varnishd computer and run varnishadm:: + + ssh $http_front_end varnishadm help + +But you can also configure varnishd to accept remote CLI connections +(using the -T and -S arguments):: + + varnishd -T :6082 -S /etc/varnish_secret + +And then on the remote system run varnishadm:: + + varnishadm -T $http_front_end -S /etc/copy_of_varnish_secret help + +but as you can see, ssh is much more convenient. + +If you run varnishadm without arguments, it will read CLI commands from +stdin, if you give it arguments, it will treat those as the single +CLI command to execute. + +The CLI always returns a status code to tell how it went: '200' +means OK, anything else means there were some kind of trouble. + +Varnishadm will exit with status 1 and print the status code on +standard error if it is not 200. + +What can you do with the CLI +---------------------------- + +The CLI gives you almost total control over varnishd: + +* load/use/discard VCL programs +* ban cache content +* change parameters +* start/stop worker process + +We will discuss each of these briefly below. + +Load, use and discard VCL programs +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +All caching and policy decisions are made by VCL programs. + +You can have multiple VCL programs loaded, but one of them +is designated the "active" VCL program, and this is where +all new requests start out. + +To load new VCL program:: + + varnish> vcl.load some_name some_filename + +Loading will read the VCL program from the file, and compile it. If +the compilation fails, you will get an error messages:: + + .../mask is not numeric. + ('input' Line 4 Pos 17) + "192.168.2.0/24x", + ----------------#################- + + Running VCC-compiler failed, exit 1 + VCL compilation failed + +If compilation succeeds, the VCL program is loaded, and you can +now make it the active VCL, whenever you feel like it:: + + varnish> vcl.use some_name + +If you find out that was a really bad idea, you can switch back +to the previous VCL program again:: + + varnish> vcl.use old_name + +The switch is instantaneous, all new requests will start using the +VCL you activated right away, but for consistency, the requests +currently being processed, complete using whatever VCL they started +with. + +It is good idea to design an emergency-VCL before you need it, +and always have it loaded, so you can switch to it with a single +vcl.use command. + +Ban cache content +^^^^^^^^^^^^^^^^^ + +Varnish offers "purges" to remove things from cache, provided that +you know exactly what they are. + +But sometimes it is useful to be able to throw things out of cache +without having an exact list of what to throw out. + +Imagine for instance that the company logo changed and now you need +to get all versions of it out of the cache:: + + varnish> ban req.url ~ "logo.*[.]png" + +should do that, and yes, that is a regular expression. + +We call this "banning" because the objects are still in the cache, +but they are banned from delivery. + +Instead of checking each and every cached object right away, we +test each object against the regular expression only if and when +some requests decides to deliver it. + +Banning stuff is much cheaper than restarting Varnish to get rid +of wronly cached content. + +In addition to handling such special occations, banning can be used +in many creative ways to keep the cache up to date, more about +that in: (XXX: xref) + +Change parameters +^^^^^^^^^^^^^^^^^ + +Parameters can be set on the command line with the '-p' argument, +but they can also be examined and changed on the fly from the CLI:: + + varnish> param.show perfer_ipv6 + 200 + prefer_ipv6 off [bool] + Default is off + Prefer IPv6 address when connecting to backends + which have both IPv4 and IPv6 addresses. + + varnish> param.set prefer_ipv6 true + 200 + +In general it is not a good idea to modify parameters unless you +have a good reason, such as performance tuning or security configuration. + +Most parameters will take effect instantly, or with a natural delay +of some duration, but a few of them requires you to restart the +child process before they take effect. This is always noted in the +description of the parameter. + +Starting and stopping the worker process +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +In general you should just leave the worker process running, but +if you need to stop and/or start it, the obvious commands work:: + + varnish> stop + +and:: + + varnish> start + +If you start varnishd with the '-d' (debugging) argument, you will +always need to start the child process explicitly. + +Should the child process die, the master process will automatically +restart it, but you can disable that with the 'auto_restart' parameter. diff --git a/doc/sphinx/users-guide/running.rst b/doc/sphinx/users-guide/running.rst index bb6e18c..2b49147 100644 --- a/doc/sphinx/users-guide/running.rst +++ b/doc/sphinx/users-guide/running.rst @@ -13,6 +13,7 @@ securing and protecting Varnish against attacks. run_security command-line + run_cli storage-backends params sizing-your-cache From tfheen at varnish-cache.org Mon Nov 11 13:27:22 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Mon, 11 Nov 2013 14:27:22 +0100 Subject: [master] 079e68b Search for backtrace function in libexecinfo Message-ID: commit 079e68bae34b303abdff49722d656b12f620a0b3 Author: Tollef Fog Heen Date: Mon Nov 11 14:26:25 2013 +0100 Search for backtrace function in libexecinfo diff --git a/configure.ac b/configure.ac index 0e73cf3..cea8ebc 100644 --- a/configure.ac +++ b/configure.ac @@ -257,7 +257,7 @@ AC_SUBST(LIBUMEM) # are not available AC_CHECK_FUNCS([setproctitle]) AC_CHECK_FUNCS([srandomdev]) -AC_CHECK_FUNCS([backtrace]) +AC_SEARCH_LIBS(backtrace, [execinfo],[AC_DEFINE([HAVE_BACKTRACE],[1],[Define to 1 if the backtrace function exists])]) # white lie - we don't actually test it AC_MSG_CHECKING([whether daemon() works]) case $target in From phk at varnish-cache.org Mon Nov 11 22:15:01 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 11 Nov 2013 23:15:01 +0100 Subject: [master] f2bccc2 Renovate varnishtest a bit. Message-ID: commit f2bccc2bde6f303aa6a1851e85ef5874c605e608 Author: Poul-Henning Kamp Date: Mon Nov 11 21:44:46 2013 +0000 Renovate varnishtest a bit. Define a macro for all programs, so they can be overwritten from the command line. Change '-i' to mean "You're in a source tree": Find top of build-tree by reading Makefile Set $PATH which can find all programs diff --git a/bin/varnishtest/programs.h b/bin/varnishtest/programs.h new file mode 100644 index 0000000..f7ffbf9 --- /dev/null +++ b/bin/varnishtest/programs.h @@ -0,0 +1,35 @@ +/*- + * Copyright (c) 2013 Varnish Software 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. + * + */ + +VTC_PROG(varnishd) +VTC_PROG(varnishadm) +VTC_PROG(varnishstat) +VTC_PROG(varnishhist) +VTC_PROG(varnishlog) +VTC_PROG(varnishncsa) diff --git a/bin/varnishtest/tests/a00009.vtc b/bin/varnishtest/tests/a00009.vtc index 7a2cee2..34a56f0 100644 --- a/bin/varnishtest/tests/a00009.vtc +++ b/bin/varnishtest/tests/a00009.vtc @@ -1,5 +1,5 @@ varnishtest "Code coverage of VCL compiler and RSTdump" -shell "cd ${topbuild}/bin/varnishd && ./varnishd -b 127.0.0.1:80 -C -n ${tmpdir} > /dev/null 2>&1" -shell "cd ${topbuild}/bin/varnishd && ./varnishd -x dumprstparam > /dev/null 2>&1" -shell "cd ${topbuild}/bin/varnishd && ./varnishd -x dumprstvsl > /dev/null 2>&1" +shell "${varnishd} -b 127.0.0.1:80 -C -n ${tmpdir} > /dev/null 2>&1" +shell "${varnishd} -x dumprstparam > /dev/null 2>&1" +shell "${varnishd} -x dumprstvsl > /dev/null 2>&1" diff --git a/bin/varnishtest/tests/b00041.vtc b/bin/varnishtest/tests/b00041.vtc new file mode 100644 index 0000000..f299c1b --- /dev/null +++ b/bin/varnishtest/tests/b00041.vtc @@ -0,0 +1,5 @@ +varnishtest "Test varnishadm and the Telnet CLI" + +varnish v1 -vcl {backend foo { .host = "127.0.0.1"; } } -start + +shell "${varnishadm} -n ${tmpdir}/v1 help > /dev/null" diff --git a/bin/varnishtest/vtc.c b/bin/varnishtest/vtc.c index 0aa4769..687e52f 100644 --- a/bin/varnishtest/vtc.c +++ b/bin/varnishtest/vtc.c @@ -545,7 +545,7 @@ exec_file(const char *fn, const char *script, const char *tmpdir, char *logbuf, unsigned loglen) { unsigned old_err; - char *cwd, *p; + char *p; FILE *f; struct extmacro *m; @@ -562,11 +562,6 @@ exec_file(const char *fn, const char *script, const char *tmpdir, VTAILQ_FOREACH(m, &extmacro_list, list) macro_def(vltop, NULL, m->name, "%s", m->val); - /* Other macro definitions */ - cwd = getcwd(NULL, PATH_MAX); - macro_def(vltop, NULL, "pwd", "%s", cwd); - macro_def(vltop, NULL, "topbuild", "%s/%s", cwd, TOP_BUILDDIR); - /* * We need an IP number which will not repond, ever, and that is a * lot harder than it sounds. This IP# is from RFC5737 and a diff --git a/bin/varnishtest/vtc_main.c b/bin/varnishtest/vtc_main.c index c4ef35c..ff3cae1 100644 --- a/bin/varnishtest/vtc_main.c +++ b/bin/varnishtest/vtc_main.c @@ -86,6 +86,7 @@ static int vtc_good; static int vtc_fail; static int leave_temp; static char *tmppath; +static char *cwd = NULL; /********************************************************************** * Parse a -D option argument into a name/val pair, and insert @@ -147,7 +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, "-D name=val", "Define macro"); 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"); @@ -158,8 +159,6 @@ usage(void) 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); } @@ -323,6 +322,76 @@ start_test(void) } /********************************************************************** + * i-mode = "we're inside a src-tree" + * + * Find the abs path to top of source dir from Makefile + * + * Set path to all programs build directories + * + */ + +static void +i_mode(void) +{ + const char *sep; + struct vsb *vsb; + char *p; + char *topbuild; + + /* + * This code has a rather intimate knowledge of auto* generated + * makefiles. + */ + + p = read_file("Makefile"); + if (p == NULL) { + fprintf(stderr, "No Makefile for -i flag\n"); + exit(2); + } + p = strstr(p, "\nabs_top_builddir"); + if (p == NULL) { + fprintf(stderr, + "could not find 'abs_top_builddir' in Makefile\n"); + exit(2); + } + topbuild = strchr(p + 1, '\n'); + if (topbuild == NULL) { + fprintf(stderr, + "No NL after 'abs_top_builddir' in Makefile\n"); + exit(2); + } + *topbuild = '\0'; + topbuild = strchr(p, '/'); + if (topbuild == NULL) { + fprintf(stderr, + "No '/' after 'abs_top_builddir' in Makefile\n"); + exit(2); + } + + extmacro_def("topbuild", "%s", topbuild); + + /* + * Build $PATH which can find all programs in the build tree + */ + vsb = VSB_new_auto(); + AN(vsb); + VSB_printf(vsb, "PATH="); + sep = ""; +#define VTC_PROG(l) \ + do { \ + VSB_printf(vsb, "%s%s/bin/%s/", sep, topbuild, #l); \ + sep = ":"; \ + } while (0); +#include "programs.h" +#undef VTC_PROG + VSB_printf(vsb, ":%s", getenv("PATH")); + AZ(VSB_finish(vsb)); + + AZ(putenv(strdup(VSB_data(vsb)))); + VSB_delete(vsb); +} + +/********************************************************************** * Main */ @@ -333,13 +402,21 @@ main(int argc, char * const *argv) int ntest = 1; /* Run tests this many times */ struct vtc_tst *tp; char *p; + int iflg = 0; + + /* Default names of programs */ +#define VTC_PROG(l) extmacro_def(#l, #l); +#include "programs.h" +#undef VTC_PROG - extmacro_def("varnishd", "varnishd"); /* Default to path lookup */ if (getenv("TMPDIR") != NULL) tmppath = strdup(getenv("TMPDIR")); else tmppath = strdup("/tmp"); + cwd = getcwd(NULL, PATH_MAX); + extmacro_def("pwd", "%s", cwd); + setbuf(stdout, NULL); setbuf(stderr, NULL); while ((ch = getopt(argc, argv, "D:ij:klLn:qt:v")) != -1) { @@ -352,8 +429,7 @@ main(int argc, char * const *argv) } break; case 'i': - /* Look for varnishd relative to varnishtest */ - extmacro_def("varnishd", "../varnishd/varnishd"); + iflg = 1; break; case 'j': npar = strtoul(optarg, NULL, 0); @@ -405,6 +481,9 @@ main(int argc, char * const *argv) VTAILQ_INSERT_TAIL(&tst_head, tp, list); } + if (iflg) + i_mode(); + vb = vev_new_base(); i = 0; From phk at varnish-cache.org Mon Nov 11 22:15:01 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 11 Nov 2013 23:15:01 +0100 Subject: [master] 687c340 Define a "vmod_xxx" macro for each vmod and redefine it suitably when -i is given. Message-ID: commit 687c340d554813ade74a75da227235b893942caf Author: Poul-Henning Kamp Date: Mon Nov 11 22:12:35 2013 +0000 Define a "vmod_xxx" macro for each vmod and redefine it suitably when -i is given. This allows the testcases to be written: import ${vmod_directors}; Add a feature for ${topbuild} and test it in the remaining to tests which use ${topbuild}. I don't see any obvious way to write those two cases without needing ${topbuild}. I belive we are now very close to being able to run our testcases out of tree. diff --git a/bin/varnishtest/flint.lnt b/bin/varnishtest/flint.lnt index 3b39af7..8f22c47 100644 --- a/bin/varnishtest/flint.lnt +++ b/bin/varnishtest/flint.lnt @@ -28,3 +28,5 @@ -e786 // String concatenation within initializer -e788 // enum value not used in defaulted switch +-efile(451, vmods.h) +-efile(451, programs.h) diff --git a/bin/varnishtest/tests/b00016.vtc b/bin/varnishtest/tests/b00016.vtc index 17fef23..fc2478e 100644 --- a/bin/varnishtest/tests/b00016.vtc +++ b/bin/varnishtest/tests/b00016.vtc @@ -21,7 +21,7 @@ client c1 { } -run varnish v1 -vcl { - import directors from "${topbuild}/lib/libvmod_directors/.libs/libvmod_directors.so" ; + import ${vmod_directors}; backend b1 { .host = "${bad_ip}"; .port = "9080"; @@ -48,7 +48,7 @@ client c1 { } -run varnish v1 -vcl { - import directors from "${topbuild}/lib/libvmod_directors/.libs/libvmod_directors.so" ; + import ${vmod_directors}; backend b1 { .host = "${bad_ip}"; .port = "9080"; } diff --git a/bin/varnishtest/tests/c00044.vtc b/bin/varnishtest/tests/c00044.vtc index f7b4f38..fb415eb 100644 --- a/bin/varnishtest/tests/c00044.vtc +++ b/bin/varnishtest/tests/c00044.vtc @@ -21,7 +21,7 @@ varnish v1 \ -arg "-smalloc,1m" \ -arg "-smalloc,1m" \ -arg "-smalloc,1m" \ - -vcl+backend { + -vcl+backend { sub vcl_backend_response { set beresp.do_stream = false; set beresp.storage = "invalid"; diff --git a/bin/varnishtest/tests/m00000.vtc b/bin/varnishtest/tests/m00000.vtc index c4f1286..5704a1f 100644 --- a/bin/varnishtest/tests/m00000.vtc +++ b/bin/varnishtest/tests/m00000.vtc @@ -6,8 +6,8 @@ server s1 { } -start varnish v1 -vcl+backend { - import std from "${topbuild}/lib/libvmod_std/.libs/libvmod_std.so" ; - import debug from "${topbuild}/lib/libvmod_debug/.libs/libvmod_debug.so" ; + import ${vmod_std}; + import ${vmod_debug}; sub vcl_deliver { set resp.http.foo = std.toupper(resp.http.foo); @@ -30,14 +30,14 @@ client c1 { } -run varnish v1 -errvcl {Wrong enum value. Expected one of:} { - import debug from "${topbuild}/lib/libvmod_debug/.libs/libvmod_debug.so" ; + import ${vmod_debug}; sub vcl_deliver { set resp.http.who = debug.author(jfk); } } varnish v1 -errvcl {Wrong argument type. Expected REAL. Got STRING.} { - import std from "${topbuild}/lib/libvmod_std/.libs/libvmod_std.so" ; + import ${vmod_std}; sub vcl_deliver { set resp.http.who = std.random("foo", "bar"); } diff --git a/bin/varnishtest/tests/m00001.vtc b/bin/varnishtest/tests/m00001.vtc index 59b8e0b..1e0b45f 100644 --- a/bin/varnishtest/tests/m00001.vtc +++ b/bin/varnishtest/tests/m00001.vtc @@ -6,7 +6,7 @@ server s1 { } -start varnish v1 -arg "-pthread_pools=1" -vcl+backend { - import std from "${topbuild}/lib/libvmod_std/.libs/libvmod_std.so" ; + import ${vmod_std}; sub vcl_deliver { set resp.http.foo = std.toupper(resp.http.foo); @@ -48,12 +48,12 @@ varnish v1 -cliok "vcl.list" varnish v1 -cliok "debug.vmod" varnish v1 -errvcl {Module std already imported.} { - import std from "${topbuild}/lib/libvmod_std/.libs/libvmod_std.so" ; - import std from "${topbuild}/lib/libvmod_std/.libs/libvmod_std.so" ; + import ${vmod_std}; + import ${vmod_std}; } varnish v1 -errvcl {Symbol not found: 'std' (expected type BOOL):} { - import std from "${topbuild}/lib/libvmod_std/.libs/libvmod_std.so" ; + import ${vmod_std}; sub vcl_recv { if (std == 2) { diff --git a/bin/varnishtest/tests/m00002.vtc b/bin/varnishtest/tests/m00002.vtc index 09b5c78..b0c3ebe 100644 --- a/bin/varnishtest/tests/m00002.vtc +++ b/bin/varnishtest/tests/m00002.vtc @@ -9,7 +9,7 @@ server s1 { } -start varnish v1 -vcl+backend { - import std from "${topbuild}/lib/libvmod_std/.libs/libvmod_std.so" ; + import ${vmod_std}; sub vcl_backend_response { set beresp.http.rnd1 = std.random(0,1); diff --git a/bin/varnishtest/tests/m00003.vtc b/bin/varnishtest/tests/m00003.vtc index 9e93f6e..c0a5aeb 100644 --- a/bin/varnishtest/tests/m00003.vtc +++ b/bin/varnishtest/tests/m00003.vtc @@ -1,5 +1,7 @@ varnishtest "Test vmod_dir param" +feature topbuild + server s1 { rxreq txresp -hdr "foo: bAr" -hdr "bar: fOo" -bodylen 4 diff --git a/bin/varnishtest/tests/m00004.vtc b/bin/varnishtest/tests/m00004.vtc index 6a23bde..80300ff 100644 --- a/bin/varnishtest/tests/m00004.vtc +++ b/bin/varnishtest/tests/m00004.vtc @@ -14,10 +14,9 @@ server s1 { } -start varnish v1 \ - -arg "-pvmod_dir=${topbuild}/lib/libvmod_std/.libs/" \ -arg "-pthread_pools=1" \ -vcl+backend { - import std; + import ${vmod_std}; sub vcl_deliver { if (req.url == "/one") { @@ -54,7 +53,7 @@ client c1 { } -run varnish v1 -vcl+backend { - import std; + import ${vmod_std}; sub vcl_deliver { if (req.url == "/one") { diff --git a/bin/varnishtest/tests/m00005.vtc b/bin/varnishtest/tests/m00005.vtc index ec04a3f..2ea397a 100644 --- a/bin/varnishtest/tests/m00005.vtc +++ b/bin/varnishtest/tests/m00005.vtc @@ -8,7 +8,7 @@ server s1 { } -start varnish v1 -vcl+backend { - import std from "${topbuild}/lib/libvmod_std/.libs/libvmod_std.so" ; + import ${vmod_std}; sub vcl_recv { set req.ttl = 1000000s + std.duration(req.http.ttl, 1s); diff --git a/bin/varnishtest/tests/m00006.vtc b/bin/varnishtest/tests/m00006.vtc index f9ce764..0d33e73 100644 --- a/bin/varnishtest/tests/m00006.vtc +++ b/bin/varnishtest/tests/m00006.vtc @@ -13,7 +13,7 @@ server s1 { } -start varnish v1 -vcl+backend { - import std from "${topbuild}/lib/libvmod_std/.libs/libvmod_std.so" ; + import ${vmod_std}; sub vcl_recv { std.collect(req.http.foo); @@ -44,7 +44,7 @@ client c1 { } -run varnish v1 -errvcl {'beresp.http.bar': Not available in method 'vcl_recv'} { - import std from "${topbuild}/lib/libvmod_std/.libs/libvmod_std.so" ; + import ${vmod_std}; backend b { .host = "127.0.0.1"; } diff --git a/bin/varnishtest/tests/m00007.vtc b/bin/varnishtest/tests/m00007.vtc index 2b1c43a..a99ac10 100644 --- a/bin/varnishtest/tests/m00007.vtc +++ b/bin/varnishtest/tests/m00007.vtc @@ -8,7 +8,7 @@ server s1 { } -start varnish v1 -vcl+backend { - import std from "${topbuild}/lib/libvmod_std/.libs/libvmod_std.so" ; + import ${vmod_std}; sub vcl_deliver { set resp.http.biggerthanzero = (std.integer(req.http.foo,0) > 0); diff --git a/bin/varnishtest/tests/m00008.vtc b/bin/varnishtest/tests/m00008.vtc index c1bdd6b..232d3c0 100644 --- a/bin/varnishtest/tests/m00008.vtc +++ b/bin/varnishtest/tests/m00008.vtc @@ -1,19 +1,21 @@ varnishtest "Test std vmod vs. unsafe_path" +feature topbuild + server s1 { rxreq txresp -hdr "foo: bAr" -hdr "bar: fOo" -bodylen 4 } -start varnish v1 -vcl+backend { - import std from "${topbuild}/lib/libvmod_std/.libs/libvmod_std.so" ; + import ${vmod_std}; } varnish v1 -cliok "param.set vcc_unsafe_path off" varnish v1 -errvcl {'import ... from path ...' not allowed.} { backend default { .host = "${s1_sock}"; } - import std from "${topbuild}/lib/libvmod_std/.libs/libvmod_std.so" ; + import ${vmod_std}; } varnish v1 -cliok "param.set vmod_dir ${topbuild}/lib/libvmod_std/.libs/" diff --git a/bin/varnishtest/tests/m00009.vtc b/bin/varnishtest/tests/m00009.vtc index cad9b96..4e97863 100644 --- a/bin/varnishtest/tests/m00009.vtc +++ b/bin/varnishtest/tests/m00009.vtc @@ -25,7 +25,7 @@ server s4 { varnish v1 -vcl+backend { - import directors from "${topbuild}/lib/libvmod_directors/.libs/libvmod_directors.so" ; + import ${vmod_directors}; sub vcl_init { new rr = directors.round_robin(); rr.add_backend(s1); diff --git a/bin/varnishtest/tests/m00010.vtc b/bin/varnishtest/tests/m00010.vtc index c4c1b3d..db2a07f 100644 --- a/bin/varnishtest/tests/m00010.vtc +++ b/bin/varnishtest/tests/m00010.vtc @@ -23,7 +23,7 @@ server s4 { } -start varnish v1 -errvcl {Names of VCL objects cannot contain '-'} { - import directors from "${topbuild}/lib/libvmod_directors/.libs/libvmod_directors.so" ; + import ${vmod_directors}; backend b1 { .host = "127.0.0.1"; .port = "8080";} sub vcl_init { new rr1-xx = directors.round_robin(); @@ -32,7 +32,7 @@ varnish v1 -errvcl {Names of VCL objects cannot contain '-'} { varnish v1 -vcl+backend { - import directors from "${topbuild}/lib/libvmod_directors/.libs/libvmod_directors.so" ; + import ${vmod_directors}; sub vcl_init { new rr1 = directors.round_robin(); rr1.add_backend(s1); diff --git a/bin/varnishtest/tests/m00011.vtc b/bin/varnishtest/tests/m00011.vtc index 0a7e517..9f17dfe 100644 --- a/bin/varnishtest/tests/m00011.vtc +++ b/bin/varnishtest/tests/m00011.vtc @@ -9,7 +9,7 @@ server s1 { varnish v1 -vcl+backend { - import std from "${topbuild}/lib/libvmod_std/.libs/libvmod_std.so" ; + import ${vmod_std}; sub vcl_deliver { set resp.http.foo0 = std.ip("8.8.8.*", client.ip); set resp.http.foo1 = std.ip("9.9.9.*", server.ip); diff --git a/bin/varnishtest/tests/r00263.vtc b/bin/varnishtest/tests/r00263.vtc index aad4784..39f1ef5 100644 --- a/bin/varnishtest/tests/r00263.vtc +++ b/bin/varnishtest/tests/r00263.vtc @@ -3,7 +3,7 @@ varnishtest "Test refcounting backends from director" # XXX: This test is probably not relevant with VMOD.directors varnish v1 -vcl { - import directors from "${topbuild}/lib/libvmod_directors/.libs/libvmod_directors.so" ; + import ${vmod_directors}; backend node1 { .host = "10.0.0.1"; .port = "80"; } backend node2 { .host = "10.0.0.2"; .port = "80"; } diff --git a/bin/varnishtest/tests/r00306.vtc b/bin/varnishtest/tests/r00306.vtc index c00badb..9e85b25 100644 --- a/bin/varnishtest/tests/r00306.vtc +++ b/bin/varnishtest/tests/r00306.vtc @@ -19,7 +19,7 @@ server s2 { varnish v1 -vcl { - import directors from "${topbuild}/lib/libvmod_directors/.libs/libvmod_directors.so" ; + import ${vmod_directors}; backend s1 { .host = "${s1_addr}"; .port = "${s1_port}"; diff --git a/bin/varnishtest/tests/r00722.vtc b/bin/varnishtest/tests/r00722.vtc index 2e41814..ef7268c 100644 --- a/bin/varnishtest/tests/r00722.vtc +++ b/bin/varnishtest/tests/r00722.vtc @@ -6,7 +6,7 @@ server s1 { } -start varnish v1 -vcl+backend { - import directors from "${topbuild}/lib/libvmod_directors/.libs/libvmod_directors.so" ; + import ${vmod_directors}; backend b2 { .host = "${s1_addr}"; .port = "${s1_port}"; diff --git a/bin/varnishtest/tests/r00878.vtc b/bin/varnishtest/tests/r00878.vtc index a7ed048..8df049a 100644 --- a/bin/varnishtest/tests/r00878.vtc +++ b/bin/varnishtest/tests/r00878.vtc @@ -6,7 +6,7 @@ server s1 { } -start varnish v1 -vcl+backend { - import debug from "${topbuild}/lib/libvmod_debug/.libs/libvmod_debug.so" ; + import ${vmod_debug}; sub vcl_deliver { set resp.http.who = debug.author(phk); } @@ -18,7 +18,7 @@ client c1 { rxresp } -run varnish v1 -vcl+backend { - import debug from "${topbuild}/lib/libvmod_debug/.libs/libvmod_debug.so" ; + import ${vmod_debug}; sub vcl_deliver { set resp.http.who = debug.author(des); } @@ -30,7 +30,7 @@ client c1 { } -run varnish v1 -vcl+backend { - import debug from "${topbuild}/lib/libvmod_debug/.libs/libvmod_debug.so" ; + import ${vmod_debug}; sub vcl_deliver { set resp.http.who = debug.author(kristian); } diff --git a/bin/varnishtest/tests/r01002.vtc b/bin/varnishtest/tests/r01002.vtc index 12eb636..2697d77 100644 --- a/bin/varnishtest/tests/r01002.vtc +++ b/bin/varnishtest/tests/r01002.vtc @@ -1,7 +1,7 @@ varnishtest "Real relational comparisons" varnish v1 -vcl { - import std from "${topbuild}/lib/libvmod_std/.libs/libvmod_std.so" ; + import ${vmod_std}; backend foo { .host = "${bad_ip}"; } sub vcl_recv { diff --git a/bin/varnishtest/tests/r01145.vtc b/bin/varnishtest/tests/r01145.vtc index 2a2502e..f87238d 100644 --- a/bin/varnishtest/tests/r01145.vtc +++ b/bin/varnishtest/tests/r01145.vtc @@ -15,7 +15,7 @@ server s1 { varnish v1 -vcl+backend { - import std from "${topbuild}/lib/libvmod_std/.libs/libvmod_std.so" ; + import ${vmod_std}; sub vcl_deliver { set resp.http.foo = std.fileread("${tmpdir}" + req.url); diff --git a/bin/varnishtest/tests/r01212.vtc b/bin/varnishtest/tests/r01212.vtc index ca8d5379..a1e91ee 100644 --- a/bin/varnishtest/tests/r01212.vtc +++ b/bin/varnishtest/tests/r01212.vtc @@ -1,7 +1,7 @@ varnishtest "#1212 - Vmod with HEADER argument given a STRING asserts the VCL compiler" varnish v1 -errvcl {Wrong argument type. Expected HEADER. Got STRING.} { - import std from "${topbuild}/lib/libvmod_std/.libs/libvmod_std.so"; + import ${vmod_std}; backend b { .host = "127.0.0.1"; } sub vcl_recv { std.collect("foo"); diff --git a/bin/varnishtest/tests/r01332.vtc b/bin/varnishtest/tests/r01332.vtc index 062e334..518c558 100644 --- a/bin/varnishtest/tests/r01332.vtc +++ b/bin/varnishtest/tests/r01332.vtc @@ -6,7 +6,7 @@ server s1 { } -start varnish v1 -vcl+backend { - import debug from "${topbuild}/lib/libvmod_debug/.libs/libvmod_debug.so"; + import ${vmod_debug}; sub vcl_init { new obj = debug.obj("don't care"); diff --git a/bin/varnishtest/tests/v00007.vtc b/bin/varnishtest/tests/v00007.vtc index d0c37f8..313d970 100644 --- a/bin/varnishtest/tests/v00007.vtc +++ b/bin/varnishtest/tests/v00007.vtc @@ -8,7 +8,7 @@ server s1 { } -start varnish v1 -vcl+backend { - import directors from "${topbuild}/lib/libvmod_directors/.libs/libvmod_directors.so"; + import ${vmod_directors}; sub vcl_init { new foo = directors.random(); diff --git a/bin/varnishtest/tests/v00009.vtc b/bin/varnishtest/tests/v00009.vtc index 53e569b..a356a51 100644 --- a/bin/varnishtest/tests/v00009.vtc +++ b/bin/varnishtest/tests/v00009.vtc @@ -23,7 +23,7 @@ server s4 { varnish v1 -vcl+backend { - import directors from "${topbuild}/lib/libvmod_directors/.libs/libvmod_directors.so" ; + import ${vmod_directors}; sub vcl_init { new batman = directors.round_robin(); diff --git a/bin/varnishtest/tests/v00010.vtc b/bin/varnishtest/tests/v00010.vtc index 58afdac..30bae3a 100644 --- a/bin/varnishtest/tests/v00010.vtc +++ b/bin/varnishtest/tests/v00010.vtc @@ -23,7 +23,7 @@ server s1 { varnish v1 -arg "-smalloc,1m" -vcl+backend { - import debug from "${topbuild}/lib/libvmod_debug/.libs/libvmod_debug.so"; + import ${vmod_debug}; sub vcl_backend_response { if (beresp.http.panic == "fetch") { diff --git a/bin/varnishtest/tests/v00022.vtc b/bin/varnishtest/tests/v00022.vtc index e6c2c0b..10f4c9f 100644 --- a/bin/varnishtest/tests/v00022.vtc +++ b/bin/varnishtest/tests/v00022.vtc @@ -32,7 +32,7 @@ server s4 { } -start varnish v1 -vcl+backend { - import directors from "${topbuild}/lib/libvmod_directors/.libs/libvmod_directors.so" ; + import ${vmod_directors}; sub vcl_init { new foo = directors.random(); diff --git a/bin/varnishtest/tests/v00026.vtc b/bin/varnishtest/tests/v00026.vtc index d859658..40d3b33 100644 --- a/bin/varnishtest/tests/v00026.vtc +++ b/bin/varnishtest/tests/v00026.vtc @@ -16,7 +16,7 @@ server s2 { varnish v1 -vcl+backend { - import directors from "${topbuild}/lib/libvmod_directors/.libs/libvmod_directors.so" ; + import ${vmod_directors}; sub vcl_init { new h1 = directors.hash(); diff --git a/bin/varnishtest/tests/v00036.vtc b/bin/varnishtest/tests/v00036.vtc index 6bf1f1b..42e9123 100644 --- a/bin/varnishtest/tests/v00036.vtc +++ b/bin/varnishtest/tests/v00036.vtc @@ -16,7 +16,7 @@ server s3 { } -start varnish v1 -vcl+backend { - import directors from "${topbuild}/lib/libvmod_directors/.libs/libvmod_directors.so" ; + import ${vmod_directors}; sub vcl_init { new fb1 = directors.fallback(); diff --git a/bin/varnishtest/vmods.h b/bin/varnishtest/vmods.h new file mode 100644 index 0000000..f951b22 --- /dev/null +++ b/bin/varnishtest/vmods.h @@ -0,0 +1,32 @@ +/*- + * Copyright (c) 2013 Varnish Software 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. + * + */ + +VTC_VMOD(std) +VTC_VMOD(debug) +VTC_VMOD(directors) diff --git a/bin/varnishtest/vtc.c b/bin/varnishtest/vtc.c index 687e52f..bedd463 100644 --- a/bin/varnishtest/vtc.c +++ b/bin/varnishtest/vtc.c @@ -515,6 +515,8 @@ cmd_feature(CMD_ARGS) continue; #endif } + if (!strcmp(av[i], "topbuild") && iflg) + continue; vtc_log(vl, 1, "SKIPPING test, missing feature: %s", av[i]); vtc_stop = 1; diff --git a/bin/varnishtest/vtc.h b/bin/varnishtest/vtc.h index 85763df..6c56926 100644 --- a/bin/varnishtest/vtc.h +++ b/bin/varnishtest/vtc.h @@ -68,6 +68,7 @@ cmd_f cmd_logexp; extern volatile sig_atomic_t vtc_error; /* Error, bail out */ extern int vtc_stop; /* Abandon current test, no error */ extern pthread_t vtc_thread; +extern int iflg; void init_sema(void); diff --git a/bin/varnishtest/vtc_main.c b/bin/varnishtest/vtc_main.c index ff3cae1..951dc17 100644 --- a/bin/varnishtest/vtc_main.c +++ b/bin/varnishtest/vtc_main.c @@ -75,6 +75,8 @@ struct vtc_job { double t0; }; +int iflg = 0; + static VTAILQ_HEAD(, vtc_tst) tst_head = VTAILQ_HEAD_INITIALIZER(tst_head); static struct vev_base *vb; static int njob = 0; @@ -363,7 +365,7 @@ i_mode(void) *topbuild = '\0'; topbuild = strchr(p, '/'); if (topbuild == NULL) { - fprintf(stderr, + fprintf(stderr, "No '/' after 'abs_top_builddir' in Makefile\n"); exit(2); } @@ -377,10 +379,10 @@ i_mode(void) AN(vsb); VSB_printf(vsb, "PATH="); sep = ""; -#define VTC_PROG(l) \ +#define VTC_PROG(l) \ do { \ - VSB_printf(vsb, "%s%s/bin/%s/", sep, topbuild, #l); \ - sep = ":"; \ + VSB_printf(vsb, "%s%s/bin/%s/", sep, topbuild, #l); \ + sep = ":"; \ } while (0); #include "programs.h" #undef VTC_PROG @@ -388,6 +390,21 @@ i_mode(void) AZ(VSB_finish(vsb)); AZ(putenv(strdup(VSB_data(vsb)))); + + /* + * Redefine VMOD macros + */ +#define VTC_VMOD(l) \ + do { \ + VSB_clear(vsb); \ + VSB_printf(vsb, \ + "%s from \"%s/lib/libvmod_%s/.libs/libvmod_%s.so\"", \ + #l, topbuild, #l, #l); \ + AZ(VSB_finish(vsb)); \ + extmacro_def("vmod_" #l, "%s", VSB_data(vsb)); \ + } while (0); +#include "vmods.h" +#undef VTC_VMOD VSB_delete(vsb); } @@ -402,13 +419,17 @@ main(int argc, char * const *argv) int ntest = 1; /* Run tests this many times */ struct vtc_tst *tp; char *p; - int iflg = 0; /* Default names of programs */ #define VTC_PROG(l) extmacro_def(#l, #l); #include "programs.h" #undef VTC_PROG + /* Default import spec of vmods */ +#define VTC_VMOD(l) extmacro_def("vmod_" #l, #l); +#include "vmods.h" +#undef VTC_VMOD + if (getenv("TMPDIR") != NULL) tmppath = strdup(getenv("TMPDIR")); else From phk at varnish-cache.org Tue Nov 12 10:02:09 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 12 Nov 2013 11:02:09 +0100 Subject: [master] a502ab3 Renovate the parameter/cli code. Message-ID: commit a502ab3cef61095c85a3495b78c80ce161999153 Author: Poul-Henning Kamp Date: Tue Nov 12 09:58:04 2013 +0000 Renovate the parameter/cli code. Certain of our parameter names are so long that they have shoved the "long" param.show output all the way to the right. Break the line after the param name and use most of the width again. Also add support for two column tables using TAB chars, for descriptions of params like "debug", "feature" etc. The width autosizes, and lines wrap as expected in the second column. Eliminate the 'pad' field in the tbl includes. Move all the "tweak" functions to a separate source file. Clean up white-space in param descriptions. diff --git a/bin/varnishd/Makefile.am b/bin/varnishd/Makefile.am index 680deb1..6980404 100644 --- a/bin/varnishd/Makefile.am +++ b/bin/varnishd/Makefile.am @@ -64,6 +64,7 @@ varnishd_SOURCES = \ mgt/mgt_param.c \ mgt/mgt_param_tbl.c \ mgt/mgt_param_bits.c \ + mgt/mgt_param_tweak.c \ mgt/mgt_pool.c \ mgt/mgt_sandbox.c \ mgt/mgt_sandbox_solaris.c \ diff --git a/bin/varnishd/common/params.h b/bin/varnishd/common/params.h index 4a16304..28c4500 100644 --- a/bin/varnishd/common/params.h +++ b/bin/varnishd/common/params.h @@ -36,14 +36,14 @@ #define VSM_CLASS_PARAM "Params" enum debug_bits { -#define DEBUG_BIT(U, l, p, d) DBG_##U, +#define DEBUG_BIT(U, l, d) DBG_##U, #include "tbl/debug_bits.h" #undef DEBUG_BIT DBG_Reserved }; enum feature_bits { -#define FEATURE_BIT(U, l, p, d, ld) FEATURE_##U, +#define FEATURE_BIT(U, l, d, ld) FEATURE_##U, #include "tbl/feature_bits.h" #undef FEATURE_BIT FEATURE_Reserved diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c index 8284a14..bd858ad 100644 --- a/bin/varnishd/mgt/mgt_param.c +++ b/bin/varnishd/mgt/mgt_param.c @@ -29,6 +29,7 @@ #include "config.h" +#include #include #include #include @@ -48,630 +49,159 @@ #include "vcli.h" #include "vcli_common.h" #include "vcli_priv.h" -#include "vnum.h" -#include "vss.h" #include "mgt_cli.h" struct params mgt_param; static int nparspec; static struct parspec const ** parspecs; -static int margin; +static const int margin1 = 8; +static int margin2 = 0; +static const int wrap_at = 72; +static const int tab0 = 3; /*--------------------------------------------------------------------*/ -static const struct parspec * -mcf_findpar(const char *name) -{ - int i; - - for (i = 0; i < nparspec; i++) - if (!strcmp(parspecs[i]->name, name)) - return (parspecs[i]); - return (NULL); -} - -/*--------------------------------------------------------------------*/ - -static void -tweak_generic_timeout(struct cli *cli, volatile unsigned *dst, const char *arg) -{ - unsigned u; - - if (arg != NULL) { - u = strtoul(arg, NULL, 0); - if (u == 0) { - VCLI_Out(cli, "Timeout must be greater than zero\n"); - VCLI_SetResult(cli, CLIS_PARAM); - return; - } - *dst = u; - } else - VCLI_Out(cli, "%u", *dst); -} - -/*--------------------------------------------------------------------*/ +static const char OBJ_STICKY_TEXT[] = + "\n\nNB: This parameter is evaluated only when objects are created." + "To change it for all objects, restart or ban everything."; -void -tweak_timeout(struct cli *cli, const struct parspec *par, const char *arg) -{ - volatile unsigned *dest; - - dest = par->priv; - tweak_generic_timeout(cli, dest, arg); -} +static const char DELAYED_EFFECT_TEXT[] = + "\n\nNB: This parameter may take quite some time to take (full) effect."; -/*--------------------------------------------------------------------*/ +static const char MUST_RESTART_TEXT[] = + "\n\nNB: This parameter will not take any effect until the " + "child process has been restarted."; -static int -tweak_generic_timeout_double(struct cli *cli, volatile double *dest, - const char *arg, double min, double max) -{ - double u; - char *p; - - if (arg != NULL) { - p = NULL; - u = strtod(arg, &p); - if (*arg == '\0' || *p != '\0') { - VCLI_Out(cli, "Not a number(%s)\n", arg); - VCLI_SetResult(cli, CLIS_PARAM); - return (-1); - } - if (u < min) { - VCLI_Out(cli, - "Timeout must be greater or equal to %.g\n", min); - VCLI_SetResult(cli, CLIS_PARAM); - return (-1); - } - if (u > max) { - VCLI_Out(cli, - "Timeout must be less than or equal to %.g\n", max); - VCLI_SetResult(cli, CLIS_PARAM); - return (-1); - } - *dest = u; - } else - VCLI_Out(cli, "%.6f", *dest); - return (0); -} +static const char MUST_RELOAD_TEXT[] = + "\n\nNB: This parameter will not take any effect until the " + "VCL programs have been reloaded."; -void -tweak_timeout_double(struct cli *cli, const struct parspec *par, - const char *arg) -{ - volatile double *dest; +static const char EXPERIMENTAL_TEXT[] = + "\n\nNB: We do not know yet if it is a good idea to change " + "this parameter, or if the default value is even sensible. " + "Caution is advised, and feedback is most welcome."; - dest = par->priv; - (void)tweak_generic_timeout_double(cli, dest, arg, par->min, par->max); -} +static const char WIZARD_TEXT[] = + "\n\nNB: Do not change this parameter, unless a developer tell " + "you to do so."; -/*--------------------------------------------------------------------*/ +static const char PROTECTED_TEXT[] = + "\n\nNB: This parameter is protected and can not be changed."; -void -tweak_generic_double(struct cli *cli, const struct parspec *par, - const char *arg) -{ - volatile double *dest; - char *p; - double u; - - dest = par->priv; - if (arg != NULL) { - p = NULL; - u = strtod(arg, &p); - if (*p != '\0') { - VCLI_Out(cli, - "Not a number (%s)\n", arg); - VCLI_SetResult(cli, CLIS_PARAM); - return; - } - if (u < par->min) { - VCLI_Out(cli, - "Must be greater or equal to %.g\n", - par->min); - VCLI_SetResult(cli, CLIS_PARAM); - return; - } - if (u > par->max) { - VCLI_Out(cli, - "Must be less than or equal to %.g\n", - par->max); - VCLI_SetResult(cli, CLIS_PARAM); - return; - } - *dest = u; - } else - VCLI_Out(cli, "%f", *dest); -} /*--------------------------------------------------------------------*/ -void -tweak_bool(struct cli *cli, const struct parspec *par, const char *arg) -{ - volatile unsigned *dest; - int mode = 0; - - if (!strcmp(par->def, "off") || !strcmp(par->def, "on")) - mode = 1; - - dest = par->priv; - if (arg != NULL) { - if (!strcasecmp(arg, "off")) - *dest = 0; - else if (!strcasecmp(arg, "disable")) - *dest = 0; - else if (!strcasecmp(arg, "no")) - *dest = 0; - else if (!strcasecmp(arg, "false")) - *dest = 0; - else if (!strcasecmp(arg, "on")) - *dest = 1; - else if (!strcasecmp(arg, "enable")) - *dest = 1; - else if (!strcasecmp(arg, "yes")) - *dest = 1; - else if (!strcasecmp(arg, "true")) - *dest = 1; - else { - VCLI_Out(cli, - mode ? - "use \"on\" or \"off\"\n" : - "use \"true\" or \"false\"\n"); - VCLI_SetResult(cli, CLIS_PARAM); - return; - } - } else if (mode) { - VCLI_Out(cli, *dest ? "on" : "off"); - } else { - VCLI_Out(cli, *dest ? "true" : "false"); - } -} - -/*--------------------------------------------------------------------*/ - -int -tweak_generic_uint(struct cli *cli, volatile unsigned *dest, const char *arg, - unsigned min, unsigned max) -{ - unsigned u; - char *p; - - if (arg != NULL) { - p = NULL; - if (!strcasecmp(arg, "unlimited")) - u = UINT_MAX; - else { - u = strtoul(arg, &p, 0); - if (*arg == '\0' || *p != '\0') { - VCLI_Out(cli, "Not a number (%s)\n", arg); - VCLI_SetResult(cli, CLIS_PARAM); - return (-1); - } - } - if (u < min) { - VCLI_Out(cli, "Must be at least %u\n", min); - VCLI_SetResult(cli, CLIS_PARAM); - return (-1); - } - if (u > max) { - VCLI_Out(cli, "Must be no more than %u\n", max); - VCLI_SetResult(cli, CLIS_PARAM); - return (-1); - } - *dest = u; - } else if (*dest == UINT_MAX) { - VCLI_Out(cli, "unlimited"); - } else { - VCLI_Out(cli, "%u", *dest); - } - return (0); -} - -/*--------------------------------------------------------------------*/ - -void -tweak_uint(struct cli *cli, const struct parspec *par, const char *arg) -{ - volatile unsigned *dest; - - dest = par->priv; - (void)tweak_generic_uint(cli, dest, arg, - (uint)par->min, (uint)par->max); -} - -/*--------------------------------------------------------------------*/ - -static void -fmt_bytes(struct cli *cli, uintmax_t t) +static const struct parspec * +mcf_findpar(const char *name, int *idx) { - const char *p; - - if (t & 0xff) { - VCLI_Out(cli, "%jub", t); - return; - } - for (p = "kMGTPEZY"; *p; p++) { - if (t & 0x300) { - VCLI_Out(cli, "%.2f%c", t / 1024.0, *p); - return; - } - t /= 1024; - if (t & 0x0ff) { - VCLI_Out(cli, "%ju%c", t, *p); - return; - } - } - VCLI_Out(cli, "(bogus number)"); -} + int i; -static void -tweak_generic_bytes(struct cli *cli, volatile ssize_t *dest, const char *arg, - double min, double max) -{ - uintmax_t r; - const char *p; - - if (arg != NULL) { - p = VNUM_2bytes(arg, &r, 0); - if (p != NULL) { - VCLI_Out(cli, "Could not convert to bytes.\n"); - VCLI_Out(cli, "%s\n", p); - VCLI_Out(cli, - " Try something like '80k' or '120M'\n"); - VCLI_SetResult(cli, CLIS_PARAM); - return; - } - if ((uintmax_t)((ssize_t)r) != r) { - fmt_bytes(cli, r); - VCLI_Out(cli, " is too large for this architecture.\n"); - VCLI_SetResult(cli, CLIS_PARAM); - return; - } - if (max != 0. && r > max) { - VCLI_Out(cli, "Must be no more than "); - fmt_bytes(cli, (uintmax_t)max); - VCLI_Out(cli, "\n"); - VCLI_SetResult(cli, CLIS_PARAM); - return; - } - if (r < min) { - VCLI_Out(cli, "Must be at least "); - fmt_bytes(cli, (uintmax_t)min); - VCLI_Out(cli, "\n"); - VCLI_SetResult(cli, CLIS_PARAM); - return; + AN(name); + for (i = 0; i < nparspec; i++) + if (!strcmp(parspecs[i]->name, name)) { + if (idx != NULL) + *idx = i; + return (parspecs[i]); } - *dest = r; - } else { - fmt_bytes(cli, *dest); - } -} - -/*--------------------------------------------------------------------*/ - -void -tweak_bytes(struct cli *cli, const struct parspec *par, const char *arg) -{ - volatile ssize_t *dest; - - assert(par->min >= 0); - dest = par->priv; - tweak_generic_bytes(cli, dest, arg, par->min, par->max); -} - - -/*--------------------------------------------------------------------*/ - -void -tweak_bytes_u(struct cli *cli, const struct parspec *par, const char *arg) -{ - volatile unsigned *d1; - volatile ssize_t dest; - - assert(par->max <= UINT_MAX); - assert(par->min >= 0); - d1 = par->priv; - dest = *d1; - tweak_generic_bytes(cli, &dest, arg, par->min, par->max); - *d1 = dest; + if (idx != NULL) + *idx = -1; + return (NULL); } /*-------------------------------------------------------------------- - * XXX: slightly magic. We want to initialize to "nobody" (XXX: shouldn't - * XXX: that be something autocrap found for us ?) but we don't want to - * XXX: fail initialization if that user doesn't exists, even though we - * XXX: do want to fail it, in subsequent sets. - * XXX: The magic init string is a hack for this. + * Wrap the text nicely. + * Lines are allowed to contain to TABS and we render that as a table + * taking the width of the first column into account. */ -void -tweak_user(struct cli *cli, const struct parspec *par, const char *arg) -{ - struct passwd *pw; - - (void)par; - if (arg != NULL) { - if (*arg != '\0') { - pw = getpwnam(arg); - if (pw == NULL) { - VCLI_Out(cli, "Unknown user"); - VCLI_SetResult(cli, CLIS_PARAM); - return; - } - REPLACE(mgt_param.user, pw->pw_name); - mgt_param.uid = pw->pw_uid; +static void +mcf_wrap_line(struct cli *cli, const char *b, const char *e, int tabs, int m0) +{ + int n, hadtabs = 0; + const char *w; + + n = m0; + VCLI_Out(cli, "%*s", n, ""); + + while (b < e) { + if (!isspace(*b)) { + VCLI_Out(cli, "%c", *b); + b++; + n++; + } else if (*b == '\t') { + assert(tabs); + assert(hadtabs < 2); + do { + VCLI_Out(cli, " "); + n++; + } while ((n % tabs) != (m0 + tab0) % tabs); + b++; + hadtabs++; } else { - mgt_param.uid = getuid(); - } - } else if (mgt_param.user) { - VCLI_Out(cli, "%s (%d)", mgt_param.user, (int)mgt_param.uid); - } else { - VCLI_Out(cli, "UID %d", (int)mgt_param.uid); - } -} - -/*-------------------------------------------------------------------- - * XXX: see comment for tweak_user, same thing here. - */ - -void -tweak_group(struct cli *cli, const struct parspec *par, const char *arg) -{ - struct group *gr; - - (void)par; - if (arg != NULL) { - if (*arg != '\0') { - gr = getgrnam(arg); - if (gr == NULL) { - VCLI_Out(cli, "Unknown group"); - VCLI_SetResult(cli, CLIS_PARAM); + assert (*b == ' '); + for (w = b + 1; w < e; w++) + if (isspace(*w)) + break; + if (n + (w - b) < wrap_at) { + VCLI_Out(cli, "%.*s", (int)(w - b), b); + n += (w - b); + b = w; + } else { + assert(hadtabs == 0 || hadtabs == 2); + VCLI_Out(cli, "\n"); + mcf_wrap_line(cli, b + 1, e, 0, + hadtabs ? m0 + tab0 + tabs : m0); return; } - REPLACE(mgt_param.group, gr->gr_name); - mgt_param.gid = gr->gr_gid; - } else { - mgt_param.gid = getgid(); } - } else if (mgt_param.group) { - VCLI_Out(cli, "%s (%d)", mgt_param.group, (int)mgt_param.gid); - } else { - VCLI_Out(cli, "GID %d", (int)mgt_param.gid); } + assert(b == e); } -/*--------------------------------------------------------------------*/ - static void -clean_listen_sock_head(struct listen_sock_head *lsh) -{ - struct listen_sock *ls, *ls2; - - VTAILQ_FOREACH_SAFE(ls, lsh, list, ls2) { - CHECK_OBJ_NOTNULL(ls, LISTEN_SOCK_MAGIC); - VTAILQ_REMOVE(lsh, ls, list); - free(ls->name); - free(ls->addr); - FREE_OBJ(ls); - } -} - -void -tweak_listen_address(struct cli *cli, const struct parspec *par, - const char *arg) -{ - char **av; - int i; - struct listen_sock *ls; - struct listen_sock_head lsh; - - (void)par; - if (arg == NULL) { - VCLI_Quote(cli, mgt_param.listen_address); - return; - } - - av = VAV_Parse(arg, NULL, ARGV_COMMA); - if (av == NULL) { - VCLI_Out(cli, "Parse error: out of memory"); - VCLI_SetResult(cli, CLIS_PARAM); - return; - } - if (av[0] != NULL) { - VCLI_Out(cli, "Parse error: %s", av[0]); - VCLI_SetResult(cli, CLIS_PARAM); - VAV_Free(av); - return; - } - if (av[1] == NULL) { - VCLI_Out(cli, "Empty listen address"); - VCLI_SetResult(cli, CLIS_PARAM); - VAV_Free(av); - return; - } - VTAILQ_INIT(&lsh); - for (i = 1; av[i] != NULL; i++) { - struct vss_addr **ta; - int j, n; - - n = VSS_resolve(av[i], "http", &ta); - if (n == 0) { - VCLI_Out(cli, "Invalid listen address "); - VCLI_Quote(cli, av[i]); - VCLI_SetResult(cli, CLIS_PARAM); - break; - } - for (j = 0; j < n; ++j) { - ALLOC_OBJ(ls, LISTEN_SOCK_MAGIC); - AN(ls); - ls->sock = -1; - ls->addr = ta[j]; - ls->name = strdup(av[i]); - AN(ls->name); - VTAILQ_INSERT_TAIL(&lsh, ls, list); - } - free(ta); - } - VAV_Free(av); - if (cli != NULL && cli->result != CLIS_OK) { - clean_listen_sock_head(&lsh); - return; - } - - REPLACE(mgt_param.listen_address, arg); - - clean_listen_sock_head(&heritage.socks); - heritage.nsocks = 0; - - while (!VTAILQ_EMPTY(&lsh)) { - ls = VTAILQ_FIRST(&lsh); - VTAILQ_REMOVE(&lsh, ls, list); - CHECK_OBJ_NOTNULL(ls, LISTEN_SOCK_MAGIC); - VTAILQ_INSERT_TAIL(&heritage.socks, ls, list); - heritage.nsocks++; - } -} - -/*--------------------------------------------------------------------*/ - -void -tweak_string(struct cli *cli, const struct parspec *par, const char *arg) -{ - char **p = TRUST_ME(par->priv); - - AN(p); - /* XXX should have tweak_generic_string */ - if (arg == NULL) { - VCLI_Quote(cli, *p); - } else { - REPLACE(*p, arg); - } -} - -/*--------------------------------------------------------------------*/ - -void -tweak_waiter(struct cli *cli, const struct parspec *par, const char *arg) -{ - - /* XXX should have tweak_generic_string */ - (void)par; - WAIT_tweak_waiter(cli, arg); -} - -/*--------------------------------------------------------------------*/ - -void -tweak_poolparam(struct cli *cli, const struct parspec *par, const char *arg) +mcf_wrap(struct cli *cli, const char *text) { - volatile struct poolparam *pp, px; - char **av; + const char *p, *q, *r; + int tw = 0; - pp = par->priv; - if (arg == NULL) { - VCLI_Out(cli, "%u,%u,%g", - pp->min_pool, pp->max_pool, pp->max_age); - } else { - av = VAV_Parse(arg, NULL, ARGV_COMMA); - do { - if (av[0] != NULL) { - VCLI_Out(cli, "Parse error: %s", av[0]); - VCLI_SetResult(cli, CLIS_PARAM); - break; - } - if (av[1] == NULL || av[2] == NULL || av[3] == NULL) { - VCLI_Out(cli, - "Three fields required:" - " min_pool, max_pool and max_age\n"); - VCLI_SetResult(cli, CLIS_PARAM); - break; - } - px = *pp; - if (tweak_generic_uint(cli, &px.min_pool, av[1], - (uint)par->min, (uint)par->max)) - break; - if (tweak_generic_uint(cli, &px.max_pool, av[2], - (uint)par->min, (uint)par->max)) - break; - if (tweak_generic_timeout_double(cli, &px.max_age, - av[3], 0, 1e6)) - break; - if (px.min_pool > px.max_pool) { - VCLI_Out(cli, - "min_pool cannot be larger" - " than max_pool\n"); - VCLI_SetResult(cli, CLIS_PARAM); + if (strchr(text, '\t') != NULL) { + for (p = text; *p != '\0'; ) { + q = strstr(p, "\n\t"); + if (q == NULL) break; + q += 2; + r = strchr(q, '\t'); + if (r == NULL) { + fprintf(stderr, + "LINE with just one TAB: <%s>\n", text); + exit(2); } - *pp = px; - } while(0); - VAV_Free(av); + if (r - q > tw) + tw = r - q; + p = q; + } + tw += 2; + if (tw < 20) + tw = 20; } -} - -/*--------------------------------------------------------------------*/ -/* - * Make sure to end all lines with either a space or newline of the - * formatting will go haywire. - */ - -#define OBJ_STICKY_TEXT \ - "\nNB: This parameter is evaluated only when objects are created." \ - "To change it for all objects, restart or ban everything." - -#define DELAYED_EFFECT_TEXT \ - "\nNB: This parameter may take quite some time to take (full) effect." - -#define MUST_RESTART_TEXT \ - "\nNB: This parameter will not take any effect until the " \ - "child process has been restarted." - -#define MUST_RELOAD_TEXT \ - "\nNB: This parameter will not take any effect until the " \ - "VCL programs have been reloaded." - -#define EXPERIMENTAL_TEXT \ - "\nNB: We do not know yet if it is a good idea to change " \ - "this parameter, or if the default value is even sensible. " \ - "Caution is advised, and feedback is most welcome." - -#define WIZARD_TEXT \ - "\nNB: Do not change this parameter, unless a developer tell " \ - "you to do so." - -#define PROTECTED_TEXT \ - "\nNB: This parameter is protected and can not be changed." - -/*--------------------------------------------------------------------*/ - -#define WIDTH 76 - -static void -mcf_wrap(struct cli *cli, const char *text) -{ - const char *p, *q; - - /* Format text to COLUMNS width */ for (p = text; *p != '\0'; ) { + if (*p == '\n') { + VCLI_Out(cli, "\n"); + p++; + continue; + } q = strchr(p, '\n'); if (q == NULL) q = strchr(p, '\0'); - if (q > p + WIDTH - margin) { - q = p + WIDTH - margin; - while (q > p && *q != ' ') - q--; - AN(q); - } - VCLI_Out(cli, "%*s %.*s\n", margin, "", (int)(q - p), p); + mcf_wrap_line(cli, p, q, tw, margin1); p = q; - if (*p == ' ' || *p == '\n') - p++; } } +/*--------------------------------------------------------------------*/ + void mcf_param_show(struct cli *cli, const char * const *av, void *priv) { @@ -680,7 +210,7 @@ mcf_param_show(struct cli *cli, const char * const *av, void *priv) int lfmt; (void)priv; - if (av[2] == NULL || strcmp(av[2], "-l")) + if (av[2] == NULL) lfmt = 0; else lfmt = 1; @@ -688,13 +218,11 @@ mcf_param_show(struct cli *cli, const char * const *av, void *priv) pp = parspecs[i]; if (av[2] != NULL && !lfmt && strcmp(pp->name, av[2])) continue; - VCLI_Out(cli, "%-*s ", margin, pp->name); - if (pp->func == NULL) { - VCLI_Out(cli, "Not implemented.\n"); - if (av[2] != NULL && !lfmt) - return; - else - continue; + if (lfmt) { + VCLI_Out(cli, "%s\n", pp->name); + VCLI_Out(cli, "%-*sValue is: ", margin1, " "); + } else { + VCLI_Out(cli, "%-*s", margin2, pp->name); } pp->func(cli, pp, NULL); if (pp->units != NULL && *pp->units != '\0') @@ -702,8 +230,8 @@ mcf_param_show(struct cli *cli, const char * const *av, void *priv) else VCLI_Out(cli, "\n"); if (av[2] != NULL) { - VCLI_Out(cli, "%-*s Default is %s\n", - margin, "", pp->def); + VCLI_Out(cli, "%-*sDefault is: %s\n\n", + margin1, "", pp->def); mcf_wrap(cli, pp->descr); if (pp->flags & OBJ_STICKY) mcf_wrap(cli, OBJ_STICKY_TEXT); @@ -722,7 +250,7 @@ mcf_param_show(struct cli *cli, const char * const *av, void *priv) if (!lfmt) return; else - VCLI_Out(cli, "\n"); + VCLI_Out(cli, "\n\n"); } } if (av[2] != NULL && !lfmt) { @@ -750,17 +278,14 @@ MCF_ParamProtect(struct cli *cli, const char *args) return; } for (i = 1; av[i] != NULL; i++) { - for (j = 0; j < nparspec; j++) - if (!strcmp(parspecs[j]->name, av[i])) - break; - if (j == nparspec) { + if (mcf_findpar(av[i], &j) == NULL) { VCLI_Out(cli, "Unknown parameter %s", av[i]); VCLI_SetResult(cli, CLIS_PARAM); VAV_Free(av); return; } pp = calloc(sizeof *pp, 1L); - XXXAN(pp); + AN(pp); memcpy(pp, parspecs[j], sizeof *pp); pp->flags |= PROTECTED; parspecs[j] = pp; @@ -775,7 +300,7 @@ MCF_ParamSet(struct cli *cli, const char *param, const char *val) { const struct parspec *pp; - pp = mcf_findpar(param); + pp = mcf_findpar(param, NULL); if (pp == NULL) { VCLI_SetResult(cli, CLIS_PARAM); VCLI_Out(cli, "Unknown parameter \"%s\".", param); @@ -819,7 +344,7 @@ mcf_param_set(struct cli *cli, const char * const *av, void *priv) */ static int -parspec_cmp(const void *a, const void *b) +mcf_parspec_cmp(const void *a, const void *b) { struct parspec * const * pa = a; struct parspec * const * pb = b; @@ -830,14 +355,24 @@ static void MCF_AddParams(const struct parspec *ps) { const struct parspec *pp; + const char *s; int n; n = 0; for (pp = ps; pp->name != NULL; pp++) { - if (mcf_findpar(pp->name) != NULL) + AN(pp->func); + s = strchr(pp->descr, '\0'); + if (isspace(s[-1])) { + fprintf(stderr, + "Param->descr has trailing space: %s\n", pp->name); + exit(2); + } + if (mcf_findpar(pp->name, NULL) != NULL) { fprintf(stderr, "Duplicate param: %s\n", pp->name); - if (strlen(pp->name) + 1 > margin) - margin = strlen(pp->name) + 1; + exit(2); + } + if (strlen(pp->name) + 1 > margin2) + margin2 = strlen(pp->name) + 1; n++; } parspecs = realloc(parspecs, (1L + nparspec + n) * sizeof *parspecs); @@ -845,7 +380,7 @@ MCF_AddParams(const struct parspec *ps) for (pp = ps; pp->name != NULL; pp++) parspecs[nparspec++] = pp; parspecs[nparspec] = NULL; - qsort (parspecs, nparspec, sizeof parspecs[0], parspec_cmp); + qsort (parspecs, nparspec, sizeof parspecs[0], mcf_parspec_cmp); } /*-------------------------------------------------------------------- diff --git a/bin/varnishd/mgt/mgt_param.h b/bin/varnishd/mgt/mgt_param.h index 64fccf1..61c4e0e 100644 --- a/bin/varnishd/mgt/mgt_param.h +++ b/bin/varnishd/mgt/mgt_param.h @@ -82,5 +82,5 @@ extern const struct parspec WRK_parspec[]; "The three numbers are:\n" \ " min_pool -- minimum size of free pool.\n" \ " max_pool -- maximum size of free pool.\n" \ - " max_age -- max age of free element.\n" + " max_age -- max age of free element." diff --git a/bin/varnishd/mgt/mgt_param_bits.c b/bin/varnishd/mgt/mgt_param_bits.c index 247eeea..5d8e7cf 100644 --- a/bin/varnishd/mgt/mgt_param_bits.c +++ b/bin/varnishd/mgt/mgt_param_bits.c @@ -158,7 +158,7 @@ tweak_vsl_mask(struct cli *cli, const struct parspec *par, const char *arg) */ static const char * const debug_tags[] = { -# define DEBUG_BIT(U,l,p,d) [DBG_##U] = #l, +# define DEBUG_BIT(U, l, d) [DBG_##U] = #l, # include "tbl/debug_bits.h" # undef DEBUG_BIT NULL @@ -197,7 +197,7 @@ tweak_debug(struct cli *cli, const struct parspec *par, const char *arg) */ static const char * const feature_tags[] = { -# define FEATURE_BIT(U,l,p,d, ld) [FEATURE_##U] = #l, +# define FEATURE_BIT(U, l, d, ld) [FEATURE_##U] = #l, # include "tbl/feature_bits.h" # undef FEATURE_BIT NULL @@ -239,23 +239,23 @@ tweak_feature(struct cli *cli, const struct parspec *par, const char *arg) const struct parspec VSL_parspec[] = { { "vsl_mask", tweak_vsl_mask, NULL, 0, 0, "Mask individual VSL messages from being logged.\n" - "\tdefault\tSet default value\n\n" + "\tdefault\tSet default value\n" "Use +/- prefixe in front of VSL tag name, to mask/unmask " "individual VSL messages.", 0, "default", "" }, { "debug", tweak_debug, NULL, 0, 0, "Enable/Disable various kinds of debugging.\n" - "\tnone\t\tDisable all debugging\n\n" - "Use +/- prefix to set/reset individual bits:\n" -#define DEBUG_BIT(U, l, p, d) "\t" #l "\t" p d "\n" + "\tnone\tDisable all debugging\n\n" + "Use +/- prefix to set/reset individual bits:" +#define DEBUG_BIT(U, l, d) "\n\t" #l "\t" d #include "tbl/debug_bits.h" #undef DEBUG_BIT , 0, "none", "" }, { "feature", tweak_feature, NULL, 0, 0, "Enable/Disable various minor features.\n" - "\tnone\t\tDisable all features.\n\n" - "Use +/- prefix to enable/disable individual feature:\n" -#define FEATURE_BIT(U, l, p, d, ld) "\t" #l "\t" p d "\n" + "\tnone\tDisable all features.\n\n" + "Use +/- prefix to enable/disable individual feature:" +#define FEATURE_BIT(U, l, d, ld) "\n\t" #l "\t" d #include "tbl/feature_bits.h" #undef FEATURE_BIT , 0, "none", "" }, diff --git a/bin/varnishd/mgt/mgt_param_tbl.c b/bin/varnishd/mgt/mgt_param_tbl.c index f123661..12bc84e 100644 --- a/bin/varnishd/mgt/mgt_param_tbl.c +++ b/bin/varnishd/mgt/mgt_param_tbl.c @@ -56,14 +56,14 @@ const struct parspec mgt_parspec[] = { { "default_ttl", tweak_timeout_double, &mgt_param.default_ttl, 0, UINT_MAX, "The TTL assigned to objects if neither the backend nor " - "the VCL code assigns one.\n", + "the VCL code assigns one.", OBJ_STICKY, "120", "seconds" }, { "default_grace", tweak_timeout_double, &mgt_param.default_grace, 0, UINT_MAX, "Default grace period. We will deliver an object " "this long after it has expired, provided another thread " - "is attempting to get a new copy.\n", + "is attempting to get a new copy.", OBJ_STICKY, "10", "seconds" }, { "default_keep", tweak_timeout_double, &mgt_param.default_keep, @@ -95,14 +95,14 @@ const struct parspec mgt_parspec[] = { "One use is for the io-vectors for writing requests and" " responses to sockets, having too little space will" " result in more writev(2) system calls, having too much" - " just wastes the space.\n", + " just wastes the space.", DELAYED_EFFECT, "2048", "bytes" }, { "http_req_hdr_len", tweak_bytes_u, &mgt_param.http_req_hdr_len, 40, UINT_MAX, "Maximum length of any HTTP client request header we will " - "allow. The limit is inclusive its continuation lines.\n", + "allow. The limit is inclusive its continuation lines.", 0, "8k", "bytes" }, { "http_req_size", @@ -120,7 +120,7 @@ const struct parspec mgt_parspec[] = { tweak_bytes_u, &mgt_param.http_resp_hdr_len, 40, UINT_MAX, "Maximum length of any HTTP backend response header we will " - "allow. The limit is inclusive its continuation lines.\n", + "allow. The limit is inclusive its continuation lines.", 0, "8k", "bytes" }, { "http_resp_size", @@ -139,7 +139,7 @@ const struct parspec mgt_parspec[] = { "{req|resp|bereq|beresp}.http " "(obj.http is autosized to the exact number of headers).\n" "Cheap, ~20 bytes, in terms of workspace memory.\n" - "Note that the first line occupies five header lines.\n", + "Note that the first line occupies five header lines.", 0, "64", "header lines" }, { "vsl_buffer", @@ -176,7 +176,7 @@ const struct parspec mgt_parspec[] = { { "pipe_timeout", tweak_timeout, &mgt_param.pipe_timeout, 0, 0, "Idle timeout for PIPE sessions. " "If nothing have been received in either direction for " - "this many seconds, the session is closed.\n", + "this many seconds, the session is closed.", 0, "60", "seconds" }, { "send_timeout", tweak_timeout, &mgt_param.send_timeout, 0, 0, @@ -220,7 +220,7 @@ const struct parspec mgt_parspec[] = { "5", "seconds" }, #endif { "auto_restart", tweak_bool, &mgt_param.auto_restart, 0, 0, - "Restart child process automatically if it dies.\n", + "Restart child process automatically if it dies.", 0, "on", "bool" }, { "nuke_limit", @@ -244,7 +244,7 @@ const struct parspec mgt_parspec[] = { &mgt_param.fetch_maxchunksize, 64 * 1024, UINT_MAX, "The maximum chunksize we attempt to allocate from storage. " "Making this too large may cause delays and storage " - "fragmentation.\n", + "fragmentation.", EXPERIMENTAL, "256m", "bytes" }, { "accept_filter", tweak_bool, &mgt_param.accept_filter, 0, 0, @@ -266,7 +266,7 @@ const struct parspec mgt_parspec[] = { "Size of buffer for CLI command input." "\nYou may need to increase this if you have big VCL files " "and use the vcl.inline CLI command.\n" - "NB: Must be specified with -p to have effect.\n", + "NB: Must be specified with -p to have effect.", 0, "8k", "bytes" }, { "cli_limit", @@ -305,16 +305,16 @@ const struct parspec mgt_parspec[] = { { "max_restarts", tweak_uint, &mgt_param.max_restarts, 0, UINT_MAX, "Upper limit on how many times a request can restart." "\nBe aware that restarts are likely to cause a hit against " - "the backend, so don't increase thoughtlessly.\n", + "the backend, so don't increase thoughtlessly.", 0, "4", "restarts" }, { "max_retries", tweak_uint, &mgt_param.max_retries, 0, UINT_MAX, - "Upper limit on how many times a backend fetch can retry.\n", + "Upper limit on how many times a backend fetch can retry.", 0, "4", "retries" }, { "max_esi_depth", tweak_uint, &mgt_param.max_esi_depth, 0, UINT_MAX, - "Maximum depth of esi:include processing.\n", + "Maximum depth of esi:include processing.", 0, "5", "levels" }, { "connect_timeout", tweak_timeout_double, @@ -386,7 +386,7 @@ const struct parspec mgt_parspec[] = { "before just dropping connections.\n" "This is mostly an anti-DoS measure, and setting it plenty " "high should not hurt, as long as you have the memory for " - "it.\n", + "it.", 0, "100000", "sessions" }, { "timeout_linger", tweak_timeout_double, &mgt_param.timeout_linger, @@ -405,19 +405,19 @@ const struct parspec mgt_parspec[] = { "Log the local address on the TCP connection in the " "SessionOpen VSL record.\n" "Disabling this saves a getsockname(2) system call " - "per TCP connection.\n", + "per TCP connection.", 0, "on", "bool" }, { "waiter", tweak_waiter, NULL, 0, 0, - "Select the waiter kernel interface.\n", + "Select the waiter kernel interface.", WIZARD | MUST_RESTART, WAITER_DEFAULT, NULL }, { "ban_dups", tweak_bool, &mgt_param.ban_dups, 0, 0, - "Detect and eliminate duplicate bans.\n", + "Detect and eliminate duplicate bans.", 0, "on", "bool" }, { "syslog_cli_traffic", tweak_bool, &mgt_param.syslog_cli_traffic, 0, 0, - "Log all CLI traffic to syslog(LOG_INFO).\n", + "Log all CLI traffic to syslog(LOG_INFO).", 0, "on", "bool" }, { "ban_lurker_sleep", tweak_timeout_double, @@ -429,7 +429,7 @@ const struct parspec mgt_parspec[] = { 0, "0.01", "s" }, { "http_range_support", tweak_bool, &mgt_param.http_range_support, 0, 0, - "Enable support for HTTP Range headers.\n", + "Enable support for HTTP Range headers.", 0, "on", "bool" }, { "http_gzip_support", tweak_bool, &mgt_param.http_gzip_support, 0, 0, @@ -469,18 +469,18 @@ const struct parspec mgt_parspec[] = { { "shortlived", tweak_timeout_double, &mgt_param.shortlived, 0, UINT_MAX, "Objects created with TTL shorter than this are always " - "put in transient storage.\n", + "put in transient storage.", 0, "10.0", "s" }, { "critbit_cooloff", tweak_timeout_double, &mgt_param.critbit_cooloff, 60, 254, "How long time the critbit hasher keeps deleted objheads " - "on the cooloff list.\n", + "on the cooloff list.", WIZARD, "180.0", "s" }, { "sigsegv_handler", tweak_bool, &mgt_param.sigsegv_handler, 0, 0, "Install a signal handler which tries to dump debug information " - "on segmentation faults.\n", + "on segmentation faults.", MUST_RESTART, "off", "bool" }, { "vcl_dir", tweak_string, &mgt_vcl_dir, 0, 0, @@ -504,18 +504,18 @@ const struct parspec mgt_parspec[] = { NULL }, { "vcc_err_unref", tweak_bool, &mgt_vcc_err_unref, 0, 0, - "Unreferenced VCL objects result in error.\n", + "Unreferenced VCL objects result in error.", 0, "on", "bool" }, { "vcc_allow_inline_c", tweak_bool, &mgt_vcc_allow_inline_c, 0, 0, - "Allow inline C code in VCL.\n", + "Allow inline C code in VCL.", 0, "off", "bool" }, { "vcc_unsafe_path", tweak_bool, &mgt_vcc_unsafe_path, 0, 0, "Allow '/' in vmod & include paths.\n" - "Allow 'import ... from ...'.\n", + "Allow 'import ... from ...'.", 0, "on", "bool" }, @@ -559,7 +559,7 @@ const struct parspec mgt_parspec[] = { &mgt_param.bo_cache, 0, 0, "Cache free busyobj per worker thread. " "Disable this if you have very high hitrates and want " - "to save the memory of one busyobj per worker thread. ", + "to save the memory of one busyobj per worker thread.", 0, "off", "bool"}, diff --git a/bin/varnishd/mgt/mgt_param_tweak.c b/bin/varnishd/mgt/mgt_param_tweak.c new file mode 100644 index 0000000..ec5ef05 --- /dev/null +++ b/bin/varnishd/mgt/mgt_param_tweak.c @@ -0,0 +1,597 @@ +/*- + * Copyright (c) 2006 Verdens Gang AS + * Copyright (c) 2006-2011 Varnish Software 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. + * + * Functions for tweaking parameters + * + */ + +#include "config.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "mgt/mgt.h" +#include "common/heritage.h" +#include "common/params.h" + +#include "mgt/mgt_param.h" +#include "waiter/waiter.h" +#include "vav.h" +#include "vcli.h" +#include "vcli_common.h" +#include "vcli_priv.h" +#include "vnum.h" +#include "vss.h" + +#include "mgt_cli.h" + +/*--------------------------------------------------------------------*/ + +static void +tweak_generic_timeout(struct cli *cli, volatile unsigned *dst, const char *arg) +{ + unsigned u; + + if (arg != NULL) { + u = strtoul(arg, NULL, 0); + if (u == 0) { + VCLI_Out(cli, "Timeout must be greater than zero\n"); + VCLI_SetResult(cli, CLIS_PARAM); + return; + } + *dst = u; + } else + VCLI_Out(cli, "%u", *dst); +} + +/*--------------------------------------------------------------------*/ + +void +tweak_timeout(struct cli *cli, const struct parspec *par, const char *arg) +{ + volatile unsigned *dest; + + dest = par->priv; + tweak_generic_timeout(cli, dest, arg); +} + +/*--------------------------------------------------------------------*/ + +static int +tweak_generic_timeout_double(struct cli *cli, volatile double *dest, + const char *arg, double min, double max) +{ + double u; + char *p; + + if (arg != NULL) { + p = NULL; + u = strtod(arg, &p); + if (*arg == '\0' || *p != '\0') { + VCLI_Out(cli, "Not a number(%s)\n", arg); + VCLI_SetResult(cli, CLIS_PARAM); + return (-1); + } + if (u < min) { + VCLI_Out(cli, + "Timeout must be greater or equal to %.g\n", min); + VCLI_SetResult(cli, CLIS_PARAM); + return (-1); + } + if (u > max) { + VCLI_Out(cli, + "Timeout must be less than or equal to %.g\n", max); + VCLI_SetResult(cli, CLIS_PARAM); + return (-1); + } + *dest = u; + } else + VCLI_Out(cli, "%.6f", *dest); + return (0); +} + +void +tweak_timeout_double(struct cli *cli, const struct parspec *par, + const char *arg) +{ + volatile double *dest; + + dest = par->priv; + (void)tweak_generic_timeout_double(cli, dest, arg, par->min, par->max); +} + +/*--------------------------------------------------------------------*/ + +void +tweak_generic_double(struct cli *cli, const struct parspec *par, + const char *arg) +{ + volatile double *dest; + char *p; + double u; + + dest = par->priv; + if (arg != NULL) { + p = NULL; + u = strtod(arg, &p); + if (*p != '\0') { + VCLI_Out(cli, + "Not a number (%s)\n", arg); + VCLI_SetResult(cli, CLIS_PARAM); + return; + } + if (u < par->min) { + VCLI_Out(cli, + "Must be greater or equal to %.g\n", + par->min); + VCLI_SetResult(cli, CLIS_PARAM); + return; + } + if (u > par->max) { + VCLI_Out(cli, + "Must be less than or equal to %.g\n", + par->max); + VCLI_SetResult(cli, CLIS_PARAM); + return; + } + *dest = u; + } else + VCLI_Out(cli, "%f", *dest); +} + +/*--------------------------------------------------------------------*/ + +void +tweak_bool(struct cli *cli, const struct parspec *par, const char *arg) +{ + volatile unsigned *dest; + int mode = 0; + + if (!strcmp(par->def, "off") || !strcmp(par->def, "on")) + mode = 1; + + dest = par->priv; + if (arg != NULL) { + if (!strcasecmp(arg, "off")) + *dest = 0; + else if (!strcasecmp(arg, "disable")) + *dest = 0; + else if (!strcasecmp(arg, "no")) + *dest = 0; + else if (!strcasecmp(arg, "false")) + *dest = 0; + else if (!strcasecmp(arg, "on")) + *dest = 1; + else if (!strcasecmp(arg, "enable")) + *dest = 1; + else if (!strcasecmp(arg, "yes")) + *dest = 1; + else if (!strcasecmp(arg, "true")) + *dest = 1; + else { + VCLI_Out(cli, + mode ? + "use \"on\" or \"off\"\n" : + "use \"true\" or \"false\"\n"); + VCLI_SetResult(cli, CLIS_PARAM); + return; + } + } else if (mode) { + VCLI_Out(cli, *dest ? "on" : "off"); + } else { + VCLI_Out(cli, *dest ? "true" : "false"); + } +} + +/*--------------------------------------------------------------------*/ + +int +tweak_generic_uint(struct cli *cli, volatile unsigned *dest, const char *arg, + unsigned min, unsigned max) +{ + unsigned u; + char *p; + + if (arg != NULL) { + p = NULL; + if (!strcasecmp(arg, "unlimited")) + u = UINT_MAX; + else { + u = strtoul(arg, &p, 0); + if (*arg == '\0' || *p != '\0') { + VCLI_Out(cli, "Not a number (%s)\n", arg); + VCLI_SetResult(cli, CLIS_PARAM); + return (-1); + } + } + if (u < min) { + VCLI_Out(cli, "Must be at least %u\n", min); + VCLI_SetResult(cli, CLIS_PARAM); + return (-1); + } + if (u > max) { + VCLI_Out(cli, "Must be no more than %u\n", max); + VCLI_SetResult(cli, CLIS_PARAM); + return (-1); + } + *dest = u; + } else if (*dest == UINT_MAX) { + VCLI_Out(cli, "unlimited"); + } else { + VCLI_Out(cli, "%u", *dest); + } + return (0); +} + +/*--------------------------------------------------------------------*/ + +void +tweak_uint(struct cli *cli, const struct parspec *par, const char *arg) +{ + volatile unsigned *dest; + + dest = par->priv; + (void)tweak_generic_uint(cli, dest, arg, + (uint)par->min, (uint)par->max); +} + +/*--------------------------------------------------------------------*/ + +static void +fmt_bytes(struct cli *cli, uintmax_t t) +{ + const char *p; + + if (t & 0xff) { + VCLI_Out(cli, "%jub", t); + return; + } + for (p = "kMGTPEZY"; *p; p++) { + if (t & 0x300) { + VCLI_Out(cli, "%.2f%c", t / 1024.0, *p); + return; + } + t /= 1024; + if (t & 0x0ff) { + VCLI_Out(cli, "%ju%c", t, *p); + return; + } + } + VCLI_Out(cli, "(bogus number)"); +} + +static void +tweak_generic_bytes(struct cli *cli, volatile ssize_t *dest, const char *arg, + double min, double max) +{ + uintmax_t r; + const char *p; + + if (arg != NULL) { + p = VNUM_2bytes(arg, &r, 0); + if (p != NULL) { + VCLI_Out(cli, "Could not convert to bytes.\n"); + VCLI_Out(cli, "%s\n", p); + VCLI_Out(cli, + " Try something like '80k' or '120M'\n"); + VCLI_SetResult(cli, CLIS_PARAM); + return; + } + if ((uintmax_t)((ssize_t)r) != r) { + fmt_bytes(cli, r); + VCLI_Out(cli, " is too large for this architecture.\n"); + VCLI_SetResult(cli, CLIS_PARAM); + return; + } + if (max != 0. && r > max) { + VCLI_Out(cli, "Must be no more than "); + fmt_bytes(cli, (uintmax_t)max); + VCLI_Out(cli, "\n"); + VCLI_SetResult(cli, CLIS_PARAM); + return; + } + if (r < min) { + VCLI_Out(cli, "Must be at least "); + fmt_bytes(cli, (uintmax_t)min); + VCLI_Out(cli, "\n"); + VCLI_SetResult(cli, CLIS_PARAM); + return; + } + *dest = r; + } else { + fmt_bytes(cli, *dest); + } +} + +/*--------------------------------------------------------------------*/ + +void +tweak_bytes(struct cli *cli, const struct parspec *par, const char *arg) +{ + volatile ssize_t *dest; + + assert(par->min >= 0); + dest = par->priv; + tweak_generic_bytes(cli, dest, arg, par->min, par->max); +} + + +/*--------------------------------------------------------------------*/ + +void +tweak_bytes_u(struct cli *cli, const struct parspec *par, const char *arg) +{ + volatile unsigned *d1; + volatile ssize_t dest; + + assert(par->max <= UINT_MAX); + assert(par->min >= 0); + d1 = par->priv; + dest = *d1; + tweak_generic_bytes(cli, &dest, arg, par->min, par->max); + *d1 = dest; +} + +/*-------------------------------------------------------------------- + * XXX: slightly magic. We want to initialize to "nobody" (XXX: shouldn't + * XXX: that be something autocrap found for us ?) but we don't want to + * XXX: fail initialization if that user doesn't exists, even though we + * XXX: do want to fail it, in subsequent sets. + * XXX: The magic init string is a hack for this. + */ + +void +tweak_user(struct cli *cli, const struct parspec *par, const char *arg) +{ + struct passwd *pw; + + (void)par; + if (arg != NULL) { + if (*arg != '\0') { + pw = getpwnam(arg); + if (pw == NULL) { + VCLI_Out(cli, "Unknown user"); + VCLI_SetResult(cli, CLIS_PARAM); + return; + } + REPLACE(mgt_param.user, pw->pw_name); + mgt_param.uid = pw->pw_uid; + } else { + mgt_param.uid = getuid(); + } + } else if (mgt_param.user) { + VCLI_Out(cli, "%s (%d)", mgt_param.user, (int)mgt_param.uid); + } else { + VCLI_Out(cli, "UID %d", (int)mgt_param.uid); + } +} + +/*-------------------------------------------------------------------- + * XXX: see comment for tweak_user, same thing here. + */ + +void +tweak_group(struct cli *cli, const struct parspec *par, const char *arg) +{ + struct group *gr; + + (void)par; + if (arg != NULL) { + if (*arg != '\0') { + gr = getgrnam(arg); + if (gr == NULL) { + VCLI_Out(cli, "Unknown group"); + VCLI_SetResult(cli, CLIS_PARAM); + return; + } + REPLACE(mgt_param.group, gr->gr_name); + mgt_param.gid = gr->gr_gid; + } else { + mgt_param.gid = getgid(); + } + } else if (mgt_param.group) { + VCLI_Out(cli, "%s (%d)", mgt_param.group, (int)mgt_param.gid); + } else { + VCLI_Out(cli, "GID %d", (int)mgt_param.gid); + } +} + +/*--------------------------------------------------------------------*/ + +static void +clean_listen_sock_head(struct listen_sock_head *lsh) +{ + struct listen_sock *ls, *ls2; + + VTAILQ_FOREACH_SAFE(ls, lsh, list, ls2) { + CHECK_OBJ_NOTNULL(ls, LISTEN_SOCK_MAGIC); + VTAILQ_REMOVE(lsh, ls, list); + free(ls->name); + free(ls->addr); + FREE_OBJ(ls); + } +} + +void +tweak_listen_address(struct cli *cli, const struct parspec *par, + const char *arg) +{ + char **av; + int i; + struct listen_sock *ls; + struct listen_sock_head lsh; + + (void)par; + if (arg == NULL) { + VCLI_Quote(cli, mgt_param.listen_address); + return; + } + + av = VAV_Parse(arg, NULL, ARGV_COMMA); + if (av == NULL) { + VCLI_Out(cli, "Parse error: out of memory"); + VCLI_SetResult(cli, CLIS_PARAM); + return; + } + if (av[0] != NULL) { + VCLI_Out(cli, "Parse error: %s", av[0]); + VCLI_SetResult(cli, CLIS_PARAM); + VAV_Free(av); + return; + } + if (av[1] == NULL) { + VCLI_Out(cli, "Empty listen address"); + VCLI_SetResult(cli, CLIS_PARAM); + VAV_Free(av); + return; + } + VTAILQ_INIT(&lsh); + for (i = 1; av[i] != NULL; i++) { + struct vss_addr **ta; + int j, n; + + n = VSS_resolve(av[i], "http", &ta); + if (n == 0) { + VCLI_Out(cli, "Invalid listen address "); + VCLI_Quote(cli, av[i]); + VCLI_SetResult(cli, CLIS_PARAM); + break; + } + for (j = 0; j < n; ++j) { + ALLOC_OBJ(ls, LISTEN_SOCK_MAGIC); + AN(ls); + ls->sock = -1; + ls->addr = ta[j]; + ls->name = strdup(av[i]); + AN(ls->name); + VTAILQ_INSERT_TAIL(&lsh, ls, list); + } + free(ta); + } + VAV_Free(av); + if (cli != NULL && cli->result != CLIS_OK) { + clean_listen_sock_head(&lsh); + return; + } + + REPLACE(mgt_param.listen_address, arg); + + clean_listen_sock_head(&heritage.socks); + heritage.nsocks = 0; + + while (!VTAILQ_EMPTY(&lsh)) { + ls = VTAILQ_FIRST(&lsh); + VTAILQ_REMOVE(&lsh, ls, list); + CHECK_OBJ_NOTNULL(ls, LISTEN_SOCK_MAGIC); + VTAILQ_INSERT_TAIL(&heritage.socks, ls, list); + heritage.nsocks++; + } +} + +/*--------------------------------------------------------------------*/ + +void +tweak_string(struct cli *cli, const struct parspec *par, const char *arg) +{ + char **p = TRUST_ME(par->priv); + + AN(p); + /* XXX should have tweak_generic_string */ + if (arg == NULL) { + VCLI_Quote(cli, *p); + } else { + REPLACE(*p, arg); + } +} + +/*--------------------------------------------------------------------*/ + +void +tweak_waiter(struct cli *cli, const struct parspec *par, const char *arg) +{ + + /* XXX should have tweak_generic_string */ + (void)par; + WAIT_tweak_waiter(cli, arg); +} + +/*--------------------------------------------------------------------*/ + +void +tweak_poolparam(struct cli *cli, const struct parspec *par, const char *arg) +{ + volatile struct poolparam *pp, px; + char **av; + + pp = par->priv; + if (arg == NULL) { + VCLI_Out(cli, "%u,%u,%g", + pp->min_pool, pp->max_pool, pp->max_age); + } else { + av = VAV_Parse(arg, NULL, ARGV_COMMA); + do { + if (av[0] != NULL) { + VCLI_Out(cli, "Parse error: %s", av[0]); + VCLI_SetResult(cli, CLIS_PARAM); + break; + } + if (av[1] == NULL || av[2] == NULL || av[3] == NULL) { + VCLI_Out(cli, + "Three fields required:" + " min_pool, max_pool and max_age\n"); + VCLI_SetResult(cli, CLIS_PARAM); + break; + } + px = *pp; + if (tweak_generic_uint(cli, &px.min_pool, av[1], + (uint)par->min, (uint)par->max)) + break; + if (tweak_generic_uint(cli, &px.max_pool, av[2], + (uint)par->min, (uint)par->max)) + break; + if (tweak_generic_timeout_double(cli, &px.max_age, + av[3], 0, 1e6)) + break; + if (px.min_pool > px.max_pool) { + VCLI_Out(cli, + "min_pool cannot be larger" + " than max_pool\n"); + VCLI_SetResult(cli, CLIS_PARAM); + break; + } + *pp = px; + } while(0); + VAV_Free(av); + } +} diff --git a/bin/varnishd/mgt/mgt_pool.c b/bin/varnishd/mgt/mgt_pool.c index 385a500..1bfa994 100644 --- a/bin/varnishd/mgt/mgt_pool.c +++ b/bin/varnishd/mgt/mgt_pool.c @@ -161,7 +161,7 @@ const struct parspec WRK_parspec[] = { "Set this to a few milliseconds if you see the " "'threads_failed' counter grow too much.\n" "\n" - "Setting this too high results in insuffient worker threads.\n", + "Setting this too high results in insuffient worker threads.", EXPERIMENTAL, "0", "seconds" }, { "thread_pool_fail_delay", @@ -180,7 +180,7 @@ const struct parspec WRK_parspec[] = { "\n" "It may also help to increase thread_pool_timeout and " "thread_pool_min, to reduce the rate at which treads are " - "destroyed and later recreated.\n", + "destroyed and later recreated.", EXPERIMENTAL, "0.2", "seconds" }, { "thread_stats_rate", @@ -190,7 +190,7 @@ const struct parspec WRK_parspec[] = { "finish a request.\n" "This parameters defines the maximum number of requests " "a worker thread may handle, before it is forced to dump " - "its accumulated stats into the global counters.\n", + "its accumulated stats into the global counters.", EXPERIMENTAL, "10", "requests" }, { "thread_queue_limit", tweak_uint, &mgt_param.wthread_queue_limit, @@ -199,7 +199,7 @@ const struct parspec WRK_parspec[] = { "\n" "This sets the number of requests we will queue, waiting " "for an available thread. Above this limit sessions will " - "be dropped instead of queued.\n", + "be dropped instead of queued.", EXPERIMENTAL, "20", "" }, { "rush_exponent", tweak_uint, &mgt_param.rush_exponent, 2, UINT_MAX, @@ -214,7 +214,7 @@ const struct parspec WRK_parspec[] = { tweak_stack_size, &mgt_param.wthread_stacksize, 0, UINT_MAX, "Worker thread stack size.\n" "This is likely rounded up to a multiple of 4k by the kernel.\n" - "The kernel/OS has a lower limit which will be enforced.\n", + "The kernel/OS has a lower limit which will be enforced.", EXPERIMENTAL, "48k", "bytes" }, { NULL, NULL, NULL } diff --git a/include/tbl/debug_bits.h b/include/tbl/debug_bits.h index 7c6a655..59bc64e 100644 --- a/include/tbl/debug_bits.h +++ b/include/tbl/debug_bits.h @@ -29,12 +29,12 @@ * */ -DEBUG_BIT(REQ_STATE, req_state, "", "VSL Request state engine") -DEBUG_BIT(WORKSPACE, workspace, "", "VSL Workspace operations") -DEBUG_BIT(WAITER, waiter, "\t","VSL Waiter internals") -DEBUG_BIT(WAITINGLIST, waitinglist, "", "VSL Waitinglist events") -DEBUG_BIT(SYNCVSL, syncvsl, "\t","Make VSL synchronous") -DEBUG_BIT(HASHEDGE, hashedge, "", "Edge cases in Hash") -DEBUG_BIT(VCLREL, vclrel, "\t","Rapid VCL release") -DEBUG_BIT(LURKER, lurker, "\t","VSL Ban lurker") -DEBUG_BIT(ESI_CHOP, esi_chop, "", "Chop ESI fetch to bits") +DEBUG_BIT(REQ_STATE, req_state, "VSL Request state engine") +DEBUG_BIT(WORKSPACE, workspace, "VSL Workspace operations") +DEBUG_BIT(WAITER, waiter, "VSL Waiter internals") +DEBUG_BIT(WAITINGLIST, waitinglist, "VSL Waitinglist events") +DEBUG_BIT(SYNCVSL, syncvsl, "Make VSL synchronous") +DEBUG_BIT(HASHEDGE, hashedge, "Edge cases in Hash") +DEBUG_BIT(VCLREL, vclrel, "Rapid VCL release") +DEBUG_BIT(LURKER, lurker, "VSL Ban lurker") +DEBUG_BIT(ESI_CHOP, esi_chop, "Chop ESI fetch to bits") diff --git a/include/tbl/feature_bits.h b/include/tbl/feature_bits.h index 2f30e58..388f9da 100644 --- a/include/tbl/feature_bits.h +++ b/include/tbl/feature_bits.h @@ -29,31 +29,31 @@ * */ -FEATURE_BIT(SHORT_PANIC, short_panic, "", +FEATURE_BIT(SHORT_PANIC, short_panic, "Short panic message.", "Reduce level of detail for panic messages." ) -FEATURE_BIT(WAIT_SILO, wait_silo, "", +FEATURE_BIT(WAIT_SILO, wait_silo, "Wait for persistent silo.", "Wait for persistent silos to load completely before serving requests." ) -FEATURE_BIT(NO_COREDUMP, no_coredump, "", +FEATURE_BIT(NO_COREDUMP, no_coredump, "No coredumps.", "Don't attempt to coredump child process on panics." ) -FEATURE_BIT(ESI_IGNORE_HTTPS, esi_ignore_https, "", +FEATURE_BIT(ESI_IGNORE_HTTPS, esi_ignore_https, "Treat HTTPS as HTTP in ESI:includes", "Convert commit d5d43ea225207494619a5fdd0b1678033993ca69 Author: Poul-Henning Kamp Date: Tue Nov 12 10:36:57 2013 +0000 Renovate the parameter table in the sphinx doc. diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c index bd858ad..7fd361f 100644 --- a/bin/varnishd/mgt/mgt_param.c +++ b/bin/varnishd/mgt/mgt_param.c @@ -457,7 +457,7 @@ void MCF_DumpRstParam(void) { const struct parspec *pp; - const char *p, *q; + const char *p, *q, *t1, *t2; int i, j; printf("\n.. The following is the autogenerated " @@ -470,15 +470,15 @@ MCF_DumpRstParam(void) printf("~"); printf("\n"); if (pp->units != NULL && *pp->units != '\0') - printf("\t- Units: %s\n", pp->units); - printf("\t- Default: %s\n", pp->def); + printf("\t* Units: %s\n", pp->units); + printf("\t* Default: %s\n", pp->def); /* * XXX: we should mark the params with one/two flags * XXX: that say if ->min/->max are valid, so we * XXX: can emit those also in help texts. */ if (pp->flags) { - printf("\t- Flags: "); + printf("\t* Flags: "); q = ""; if (pp->flags & DELAYED_EFFECT) { printf("%sdelayed", q); @@ -502,24 +502,27 @@ MCF_DumpRstParam(void) } printf("\n"); } - printf("\n\t"); - for (p = pp->descr; *p; p++) { - if (*p == '\n' && p[1] =='\0') - break; - if (*p == '\n' && p[1] =='\n') { - printf("\n\n\t"); + printf("\n"); + p = pp->descr; + while (*p != '\0') { + q = strchr(p, '\n'); + if (q == NULL) + q = strchr(p, '\0'); + t1 = strchr(p, '\t'); + if (t1 != NULL && t1 < q) { + t2 = strchr(t1 + 1, '\t'); + printf("\n\t*"); + (void)fwrite(t1 + 1, (t2 - 1) - t1, 1, stdout); + printf("*\n\t\t"); + p = t2 + 1; + } + (void)fwrite(p, q - p, 1, stdout); + p = q; + if (*p == '\n') { + printf("\n"); p++; - } else if (*p == '\n') { - printf("\n\t"); - } else if (*p == ':' && p[1] == '\n') { - /* - * Start of definition list, - * use RSTs code mode for this - */ - printf("::\n"); - } else { - printf("%c", *p); } + continue; } printf("\n\n"); } diff --git a/bin/varnishd/mgt/mgt_param.h b/bin/varnishd/mgt/mgt_param.h index 61c4e0e..70d4351 100644 --- a/bin/varnishd/mgt/mgt_param.h +++ b/bin/varnishd/mgt/mgt_param.h @@ -77,10 +77,3 @@ extern const struct parspec VSL_parspec[]; /* mgt_pool.c */ extern const struct parspec WRK_parspec[]; - -#define MEMPOOL_TEXT \ - "The three numbers are:\n" \ - " min_pool -- minimum size of free pool.\n" \ - " max_pool -- maximum size of free pool.\n" \ - " max_age -- max age of free element." - diff --git a/bin/varnishd/mgt/mgt_param_bits.c b/bin/varnishd/mgt/mgt_param_bits.c index 5d8e7cf..cda1154 100644 --- a/bin/varnishd/mgt/mgt_param_bits.c +++ b/bin/varnishd/mgt/mgt_param_bits.c @@ -240,7 +240,7 @@ const struct parspec VSL_parspec[] = { { "vsl_mask", tweak_vsl_mask, NULL, 0, 0, "Mask individual VSL messages from being logged.\n" "\tdefault\tSet default value\n" - "Use +/- prefixe in front of VSL tag name, to mask/unmask " + "\nUse +/- prefixe in front of VSL tag name, to mask/unmask " "individual VSL messages.", 0, "default", "" }, { "debug", tweak_debug, NULL, 0, 0, diff --git a/bin/varnishd/mgt/mgt_param_tbl.c b/bin/varnishd/mgt/mgt_param_tbl.c index 12bc84e..d93914d 100644 --- a/bin/varnishd/mgt/mgt_param_tbl.c +++ b/bin/varnishd/mgt/mgt_param_tbl.c @@ -38,6 +38,13 @@ #include "mgt/mgt_param.h" #include "waiter/waiter.h" + +#define MEMPOOL_TEXT \ + "The three numbers are:\n" \ + "\tmin_pool\tminimum size of free pool.\n" \ + "\tmax_pool\tmaximum size of free pool.\n" \ + "\tmax_age\tmax age of free element." + /* * Remember to update varnishd.1 whenever you add / remove a parameter or * change its default value. diff --git a/doc/sphinx/Makefile.am b/doc/sphinx/Makefile.am index ed24bae..48e752b 100644 --- a/doc/sphinx/Makefile.am +++ b/doc/sphinx/Makefile.am @@ -175,3 +175,6 @@ dist-hook: distclean-local: rm -rf $(BUILDDIR) + +reference/params.rst: $(top_builddir)/bin/varnishd/varnishd + $(top_builddir)/bin/varnishd/varnishd -x dumprstparam > reference/params.rst diff --git a/doc/sphinx/reference/params.rst b/doc/sphinx/reference/params.rst index d11a63c..98d563e 100644 --- a/doc/sphinx/reference/params.rst +++ b/doc/sphinx/reference/params.rst @@ -5,965 +5,1010 @@ accept_filter ~~~~~~~~~~~~~ - - Units: bool - - Default: on - - Flags: must_restart + * Units: bool + * Default: on + * Flags: must_restart - Enable kernel accept-filters, if supported by the kernel. +Enable kernel accept-filters, if supported by the kernel. .. _ref_param_acceptor_sleep_decay: acceptor_sleep_decay ~~~~~~~~~~~~~~~~~~~~ - - Default: 0.900 - - Flags: experimental + * Default: 0.900 + * Flags: experimental - If we run out of resources, such as file descriptors or worker threads, the acceptor will sleep between accepts. - This parameter (multiplicatively) reduce the sleep duration for each succesfull accept. (ie: 0.9 = reduce by 10%) +If we run out of resources, such as file descriptors or worker threads, the acceptor will sleep between accepts. +This parameter (multiplicatively) reduce the sleep duration for each succesfull accept. (ie: 0.9 = reduce by 10%) .. _ref_param_acceptor_sleep_incr: acceptor_sleep_incr ~~~~~~~~~~~~~~~~~~~ - - Units: s - - Default: 0.001 - - Flags: experimental + * Units: s + * Default: 0.001 + * Flags: experimental - If we run out of resources, such as file descriptors or worker threads, the acceptor will sleep between accepts. - This parameter control how much longer we sleep, each time we fail to accept a new connection. +If we run out of resources, such as file descriptors or worker threads, the acceptor will sleep between accepts. +This parameter control how much longer we sleep, each time we fail to accept a new connection. .. _ref_param_acceptor_sleep_max: acceptor_sleep_max ~~~~~~~~~~~~~~~~~~ - - Units: s - - Default: 0.050 - - Flags: experimental + * Units: s + * Default: 0.050 + * Flags: experimental - If we run out of resources, such as file descriptors or worker threads, the acceptor will sleep between accepts. - This parameter limits how long it can sleep between attempts to accept new connections. +If we run out of resources, such as file descriptors or worker threads, the acceptor will sleep between accepts. +This parameter limits how long it can sleep between attempts to accept new connections. .. _ref_param_auto_restart: auto_restart ~~~~~~~~~~~~ - - Units: bool - - Default: on + * Units: bool + * Default: on - Restart child process automatically if it dies. +Restart child process automatically if it dies. .. _ref_param_ban_dups: ban_dups ~~~~~~~~ - - Units: bool - - Default: on + * Units: bool + * Default: on - Detect and eliminate duplicate bans. +Detect and eliminate duplicate bans. .. _ref_param_ban_lurker_sleep: ban_lurker_sleep ~~~~~~~~~~~~~~~~ - - Units: s - - Default: 0.01 + * Units: s + * Default: 0.01 - How long time does the ban lurker thread sleeps between successful attempts to push the last item up the ban list. It always sleeps a second when nothing can be done. - A value of zero disables the ban lurker. +How long time does the ban lurker thread sleeps between successful attempts to push the last item up the ban list. It always sleeps a second when nothing can be done. +A value of zero disables the ban lurker. .. _ref_param_between_bytes_timeout: between_bytes_timeout ~~~~~~~~~~~~~~~~~~~~~ - - Units: s - - Default: 60 + * Units: s + * Default: 60 - Default timeout between bytes when receiving data from backend. We only wait for this many seconds between bytes before giving up. A value of 0 means it will never time out. VCL can override this default value for each backend request and backend request. This parameter does not apply to pipe. +Default timeout between bytes when receiving data from backend. We only wait for this many seconds between bytes before giving up. A value of 0 means it will never time out. VCL can override this default value for each backend request and backend request. This parameter does not apply to pipe. .. _ref_param_busyobj_worker_cache: busyobj_worker_cache ~~~~~~~~~~~~~~~~~~~~ - - Units: bool - - Default: off + * Units: bool + * Default: off - Cache free busyobj per worker thread. Disable this if you have very high hitrates and want to save the memory of one busyobj per worker thread. +Cache free busyobj per worker thread. Disable this if you have very high hitrates and want to save the memory of one busyobj per worker thread. .. _ref_param_cc_command: cc_command ~~~~~~~~~~ - - Default: exec clang -std=gnu99 -Qunused-arguments -D_THREAD_SAFE -pthread -fpic -shared -Wl,-x -o %o %s - - Flags: must_reload + * Default: exec clang -std=gnu99 -Qunused-arguments -D_THREAD_SAFE -pthread -fpic -shared -Wl,-x -o %o %s + * Flags: must_reload - Command used for compiling the C source code to a dlopen(3) loadable object. Any occurrence of %s in the string will be replaced with the source file name, and %o will be replaced with the output file name. +Command used for compiling the C source code to a dlopen(3) loadable object. Any occurrence of %s in the string will be replaced with the source file name, and %o will be replaced with the output file name. .. _ref_param_cli_buffer: cli_buffer ~~~~~~~~~~ - - Units: bytes - - Default: 8k + * Units: bytes + * Default: 8k - Size of buffer for CLI command input. - You may need to increase this if you have big VCL files and use the vcl.inline CLI command. - NB: Must be specified with -p to have effect. +Size of buffer for CLI command input. +You may need to increase this if you have big VCL files and use the vcl.inline CLI command. +NB: Must be specified with -p to have effect. .. _ref_param_cli_limit: cli_limit ~~~~~~~~~ - - Units: bytes - - Default: 48k + * Units: bytes + * Default: 48k - Maximum size of CLI response. If the response exceeds this limit, the reponse code will be 201 instead of 200 and the last line will indicate the truncation. +Maximum size of CLI response. If the response exceeds this limit, the reponse code will be 201 instead of 200 and the last line will indicate the truncation. .. _ref_param_cli_timeout: cli_timeout ~~~~~~~~~~~ - - Units: seconds - - Default: 10 + * Units: seconds + * Default: 10 - Timeout for the childs replies to CLI requests from the mgt_param. +Timeout for the childs replies to CLI requests from the mgt_param. .. _ref_param_clock_skew: clock_skew ~~~~~~~~~~ - - Units: s - - Default: 10 + * Units: s + * Default: 10 - How much clockskew we are willing to accept between the backend and our own clock. +How much clockskew we are willing to accept between the backend and our own clock. .. _ref_param_connect_timeout: connect_timeout ~~~~~~~~~~~~~~~ - - Units: s - - Default: 3.5 + * Units: s + * Default: 3.5 - Default connection timeout for backend connections. We only try to connect to the backend for this many seconds before giving up. VCL can override this default value for each backend and backend request. +Default connection timeout for backend connections. We only try to connect to the backend for this many seconds before giving up. VCL can override this default value for each backend and backend request. .. _ref_param_critbit_cooloff: critbit_cooloff ~~~~~~~~~~~~~~~ - - Units: s - - Default: 180.0 - - Flags: wizard + * Units: s + * Default: 180.0 + * Flags: wizard - How long time the critbit hasher keeps deleted objheads on the cooloff list. +How long time the critbit hasher keeps deleted objheads on the cooloff list. .. _ref_param_debug: debug ~~~~~ - - Default: none + * Default: none - Enable/Disable various kinds of debugging. - none Disable all debugging +Enable/Disable various kinds of debugging. - Use +/- prefix to set/reset individual bits:: + *none* + Disable all debugging - req_state VSL Request state engine - workspace VSL Workspace operations - waiter VSL Waiter internals - waitinglist VSL Waitinglist events - syncvsl Make VSL synchronous - hashedge Edge cases in Hash - vclrel Rapid VCL release - lurker VSL Ban lurker - esi_chop Chop ESI fetch to bits +Use +/- prefix to set/reset individual bits: + + *req_state* + VSL Request state engine + + *workspace* + VSL Workspace operations + + *waiter* + VSL Waiter internals + + *waitinglist* + VSL Waitinglist events + + *syncvsl* + Make VSL synchronous + + *hashedge* + Edge cases in Hash + + *vclrel* + Rapid VCL release + + *lurker* + VSL Ban lurker + + *esi_chop* + Chop ESI fetch to bits .. _ref_param_default_grace: default_grace ~~~~~~~~~~~~~ - - Units: seconds - - Default: 10 - - Flags: delayed + * Units: seconds + * Default: 10 + * Flags: - Default grace period. We will deliver an object this long after it has expired, provided another thread is attempting to get a new copy. - Objects already cached will not be affected by changes made until they are fetched from the backend again. +Default grace period. We will deliver an object this long after it has expired, provided another thread is attempting to get a new copy. .. _ref_param_default_keep: default_keep ~~~~~~~~~~~~ - - Units: seconds - - Default: 0 - - Flags: delayed + * Units: seconds + * Default: 0 + * Flags: - Default keep period. We will keep a useless object around this long, making it available for conditional backend fetches. That means that the object will be removed from the cache at the end of ttl+grace+keep. +Default keep period. We will keep a useless object around this long, making it available for conditional backend fetches. That means that the object will be removed from the cache at the end of ttl+grace+keep. .. _ref_param_default_ttl: default_ttl ~~~~~~~~~~~ - - Units: seconds - - Default: 120 - - The TTL assigned to objects if neither the backend nor the VCL code assigns one. - Objects already cached will not be affected by changes made until they are fetched from the backend again. - To force an immediate effect at the expense of a total flush of the cache use "ban obj.http.date ~ ." + * Units: seconds + * Default: 120 + * Flags: -.. _ref_param_expiry_sleep: - -expiry_sleep -~~~~~~~~~~~~ - - Units: seconds - - Default: 1 - - How long the expiry thread sleeps when there is nothing for it to do. +The TTL assigned to objects if neither the backend nor the VCL code assigns one. .. _ref_param_feature: feature ~~~~~~~ - - Default: none + * Default: none + +Enable/Disable various minor features. + + *none* + Disable all features. - Enable/Disable various minor features. - none Disable all features. +Use +/- prefix to enable/disable individual feature: - Use +/- prefix to enable/disable individual feature:: + *short_panic* + Short panic message. - short_panic Short panic message. - wait_silo Wait for persistent silo. - no_coredump No coredumps. - esi_ignore_https Treat HTTPS as HTTP in ESI:includes - esi_disable_xml_check Don't check of body looks like XML - esi_ignore_other_elements Ignore non-esi XML-elements + *wait_silo* + Wait for persistent silo. + + *no_coredump* + No coredumps. + + *esi_ignore_https* + Treat HTTPS as HTTP in ESI:includes + + *esi_disable_xml_check* + Don't check of body looks like XML + + *esi_ignore_other_elements* + Ignore non-esi XML-elements + + *esi_remove_bom* + Remove UTF-8 BOM .. _ref_param_fetch_chunksize: fetch_chunksize ~~~~~~~~~~~~~~~ - - Units: bytes - - Default: 128k - - Flags: experimental + * Units: bytes + * Default: 128k + * Flags: experimental - The default chunksize used by fetcher. This should be bigger than the majority of objects with short TTLs. - Internal limits in the storage_file module makes increases above 128kb a dubious idea. +The default chunksize used by fetcher. This should be bigger than the majority of objects with short TTLs. +Internal limits in the storage_file module makes increases above 128kb a dubious idea. .. _ref_param_fetch_maxchunksize: fetch_maxchunksize ~~~~~~~~~~~~~~~~~~ - - Units: bytes - - Default: 256m - - Flags: experimental + * Units: bytes + * Default: 256m + * Flags: experimental - The maximum chunksize we attempt to allocate from storage. Making this too large may cause delays and storage fragmentation. +The maximum chunksize we attempt to allocate from storage. Making this too large may cause delays and storage fragmentation. .. _ref_param_first_byte_timeout: first_byte_timeout ~~~~~~~~~~~~~~~~~~ - - Units: s - - Default: 60 + * Units: s + * Default: 60 - Default timeout for receiving first byte from backend. We only wait for this many seconds for the first byte before giving up. A value of 0 means it will never time out. VCL can override this default value for each backend and backend request. This parameter does not apply to pipe. +Default timeout for receiving first byte from backend. We only wait for this many seconds for the first byte before giving up. A value of 0 means it will never time out. VCL can override this default value for each backend and backend request. This parameter does not apply to pipe. .. _ref_param_group: group ~~~~~ - - Default: nogroup - - Flags: must_restart + * Default: nogroup + * Flags: must_restart - The unprivileged group to run as. +The unprivileged group to run as. .. _ref_param_gzip_buffer: gzip_buffer ~~~~~~~~~~~ - - Units: bytes - - Default: 32k - - Flags: experimental + * Units: bytes + * Default: 32k + * Flags: experimental - Size of malloc buffer used for gzip processing. - These buffers are used for in-transit data, for instance gunzip'ed data being sent to a client.Making this space to small results in more overhead, writes to sockets etc, making it too big is probably just a waste of memory. +Size of malloc buffer used for gzip processing. +These buffers are used for in-transit data, for instance gunzip'ed data being sent to a client.Making this space to small results in more overhead, writes to sockets etc, making it too big is probably just a waste of memory. .. _ref_param_gzip_level: gzip_level ~~~~~~~~~~ - - Default: 6 + * Default: 6 - Gzip compression level: 0=debug, 1=fast, 9=best +Gzip compression level: 0=debug, 1=fast, 9=best .. _ref_param_gzip_memlevel: gzip_memlevel ~~~~~~~~~~~~~ - - Default: 8 + * Default: 8 - Gzip memory level 1=slow/least, 9=fast/most compression. - Memory impact is 1=1k, 2=2k, ... 9=256k. +Gzip memory level 1=slow/least, 9=fast/most compression. +Memory impact is 1=1k, 2=2k, ... 9=256k. .. _ref_param_http_gzip_support: http_gzip_support ~~~~~~~~~~~~~~~~~ - - Units: bool - - Default: on - - Enable gzip support. When enabled Varnish request compressed objects from the backend and store them compressed. If a client does not support gzip encoding Varnish will uncompress compressed objects on demand. Varnish will also rewrite the Accept-Encoding header of clients indicating support for gzip to:: + * Units: bool + * Default: on - Accept-Encoding: gzip +Enable gzip support. When enabled Varnish request compressed objects from the backend and store them compressed. If a client does not support gzip encoding Varnish will uncompress compressed objects on demand. Varnish will also rewrite the Accept-Encoding header of clients indicating support for gzip to: + Accept-Encoding: gzip - 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. +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. .. _ref_param_http_max_hdr: http_max_hdr ~~~~~~~~~~~~ - - Units: header lines - - Default: 64 + * Units: header lines + * Default: 64 - Maximum number of HTTP header lines we allow in {req|resp|bereq|beresp}.http (obj.http is autosized to the exact number of headers). - Cheap, ~20 bytes, in terms of workspace memory. - Note that the first line occupies five header lines. +Maximum number of HTTP header lines we allow in {req|resp|bereq|beresp}.http (obj.http is autosized to the exact number of headers). +Cheap, ~20 bytes, in terms of workspace memory. +Note that the first line occupies five header lines. .. _ref_param_http_range_support: http_range_support ~~~~~~~~~~~~~~~~~~ - - Units: bool - - Default: on + * Units: bool + * Default: on - Enable support for HTTP Range headers. +Enable support for HTTP Range headers. .. _ref_param_http_req_hdr_len: http_req_hdr_len ~~~~~~~~~~~~~~~~ - - Units: bytes - - Default: 8k + * Units: bytes + * Default: 8k - Maximum length of any HTTP client request header we will allow. The limit is inclusive its continuation lines. +Maximum length of any HTTP client request header we will allow. The limit is inclusive its continuation lines. .. _ref_param_http_req_size: http_req_size ~~~~~~~~~~~~~ - - Units: bytes - - Default: 32k + * Units: bytes + * Default: 32k - Maximum number of bytes of HTTP client request we will deal with. This is a limit on all bytes up to the double blank line which ends the HTTP request. - The memory for the request is allocated from the client workspace (param: workspace_client) and this parameter limits how much of that the request is allowed to take up. +Maximum number of bytes of HTTP client request we will deal with. This is a limit on all bytes up to the double blank line which ends the HTTP request. +The memory for the request is allocated from the client workspace (param: workspace_client) and this parameter limits how much of that the request is allowed to take up. .. _ref_param_http_resp_hdr_len: http_resp_hdr_len ~~~~~~~~~~~~~~~~~ - - Units: bytes - - Default: 8k + * Units: bytes + * Default: 8k - Maximum length of any HTTP backend response header we will allow. The limit is inclusive its continuation lines. +Maximum length of any HTTP backend response header we will allow. The limit is inclusive its continuation lines. .. _ref_param_http_resp_size: http_resp_size ~~~~~~~~~~~~~~ - - Units: bytes - - Default: 32k + * Units: bytes + * Default: 32k - Maximum number of bytes of HTTP backend resonse we will deal with. This is a limit on all bytes up to the double blank line which ends the HTTP request. - The memory for the request is allocated from the worker workspace (param: thread_pool_workspace) and this parameter limits how much of that the request is allowed to take up. +Maximum number of bytes of HTTP backend resonse we will deal with. This is a limit on all bytes up to the double blank line which ends the HTTP request. +The memory for the request is allocated from the worker workspace (param: thread_pool_workspace) and this parameter limits how much of that the request is allowed to take up. .. _ref_param_idle_send_timeout: idle_send_timeout ~~~~~~~~~~~~~~~~~ - - Units: seconds - - Default: 60 - - Flags: delayed + * Units: seconds + * Default: 60 + * Flags: delayed - Time to wait with no data sent. If no data has been transmitted in this many - seconds the session is closed. - See setsockopt(2) under SO_SNDTIMEO for more information. +Time to wait with no data sent. If no data has been transmitted in this many +seconds the session is closed. +See setsockopt(2) under SO_SNDTIMEO for more information. .. _ref_param_listen_address: listen_address ~~~~~~~~~~~~~~ - - Default: :80 - - Flags: must_restart + * Default: :80 + * Flags: must_restart - Whitespace separated list of network endpoints where Varnish will accept requests. - Possible formats: host, host:port, :port +Whitespace separated list of network endpoints where Varnish will accept requests. +Possible formats: host, host:port, :port .. _ref_param_listen_depth: listen_depth ~~~~~~~~~~~~ - - Units: connections - - Default: 1024 - - Flags: must_restart + * Units: connections + * Default: 1024 + * Flags: must_restart - Listen queue depth. +Listen queue depth. .. _ref_param_log_local_address: log_local_address ~~~~~~~~~~~~~~~~~ - - Units: bool - - Default: on + * Units: bool + * Default: on - Log the local address on the TCP connection in the SessionOpen VSL record. - Disabling this saves a getsockname(2) system call per TCP connection. +Log the local address on the TCP connection in the SessionOpen VSL record. +Disabling this saves a getsockname(2) system call per TCP connection. .. _ref_param_lru_interval: lru_interval ~~~~~~~~~~~~ - - Units: seconds - - Default: 2 - - Flags: experimental + * Units: seconds + * Default: 2 + * Flags: experimental - Grace period before object moves on LRU list. - Objects are only moved to the front of the LRU list if they have not been moved there already inside this timeout period. This reduces the amount of lock operations necessary for LRU list access. +Grace period before object moves on LRU list. +Objects are only moved to the front of the LRU list if they have not been moved there already inside this timeout period. This reduces the amount of lock operations necessary for LRU list access. .. _ref_param_max_esi_depth: max_esi_depth ~~~~~~~~~~~~~ - - Units: levels - - Default: 5 + * Units: levels + * Default: 5 - Maximum depth of esi:include processing. +Maximum depth of esi:include processing. .. _ref_param_max_restarts: max_restarts ~~~~~~~~~~~~ - - Units: restarts - - Default: 4 + * Units: restarts + * Default: 4 - Upper limit on how many times a request can restart. - Be aware that restarts are likely to cause a hit against the backend, so don't increase thoughtlessly. +Upper limit on how many times a request can restart. +Be aware that restarts are likely to cause a hit against the backend, so don't increase thoughtlessly. .. _ref_param_max_retries: max_retries ~~~~~~~~~~~ - - Units: retries - - Default: 4 + * Units: retries + * Default: 4 - Upper limit on how many times a backend fetch can retry. +Upper limit on how many times a backend fetch can retry. .. _ref_param_nuke_limit: nuke_limit ~~~~~~~~~~ - - Units: allocations - - Default: 50 - - Flags: experimental + * Units: allocations + * Default: 50 + * Flags: experimental - Maximum number of objects we attempt to nuke in orderto make space for a object body. +Maximum number of objects we attempt to nuke in orderto make space for a object body. .. _ref_param_pcre_match_limit: pcre_match_limit ~~~~~~~~~~~~~~~~ - - Default: 10000 + * Default: 10000 - The limit for the number of internal matching function calls in a pcre_exec() execution. +The limit for the number of internal matching function calls in a pcre_exec() execution. .. _ref_param_pcre_match_limit_recursion: pcre_match_limit_recursion ~~~~~~~~~~~~~~~~~~~~~~~~~~ - - Default: 10000 + * Default: 10000 - The limit for the number of internal matching function recursions in a pcre_exec() execution. +The limit for the number of internal matching function recursions in a pcre_exec() execution. .. _ref_param_ping_interval: ping_interval ~~~~~~~~~~~~~ - - Units: seconds - - Default: 3 - - Flags: must_restart + * Units: seconds + * Default: 3 + * Flags: must_restart - Interval between pings from parent to child. - Zero will disable pinging entirely, which makes it possible to attach a debugger to the child. +Interval between pings from parent to child. +Zero will disable pinging entirely, which makes it possible to attach a debugger to the child. .. _ref_param_pipe_timeout: pipe_timeout ~~~~~~~~~~~~ - - Units: seconds - - Default: 60 + * Units: seconds + * Default: 60 - Idle timeout for PIPE sessions. If nothing have been received in either direction for this many seconds, the session is closed. +Idle timeout for PIPE sessions. If nothing have been received in either direction for this many seconds, the session is closed. .. _ref_param_pool_req: pool_req ~~~~~~~~ - - Default: 10,100,10 + * Default: 10,100,10 + +Parameters for per worker pool request memory pool. +The three numbers are: + + *min_pool* + minimum size of free pool. - Parameters for per worker pool request memory pool. - The three numbers are:: + *max_pool* + maximum size of free pool. - min_pool -- minimum size of free pool. - max_pool -- maximum size of free pool. - max_age -- max age of free element. + *max_age* + max age of free element. .. _ref_param_pool_sess: pool_sess ~~~~~~~~~ - - Default: 10,100,10 + * Default: 10,100,10 - Parameters for per worker pool session memory pool. - The three numbers are:: +Parameters for per worker pool session memory pool. +The three numbers are: - min_pool -- minimum size of free pool. - max_pool -- maximum size of free pool. - max_age -- max age of free element. + *min_pool* + minimum size of free pool. + + *max_pool* + maximum size of free pool. + + *max_age* + max age of free element. .. _ref_param_pool_vbc: pool_vbc ~~~~~~~~ - - Default: 10,100,10 + * Default: 10,100,10 + +Parameters for backend connection memory pool. +The three numbers are: + + *min_pool* + minimum size of free pool. - Parameters for backend connection memory pool. - The three numbers are:: + *max_pool* + maximum size of free pool. - min_pool -- minimum size of free pool. - max_pool -- maximum size of free pool. - max_age -- max age of free element. + *max_age* + max age of free element. .. _ref_param_pool_vbo: pool_vbo ~~~~~~~~ - - Default: 10,100,10 + * Default: 10,100,10 - Parameters for backend object fetch memory pool. - The three numbers are:: +Parameters for backend object fetch memory pool. +The three numbers are: - min_pool -- minimum size of free pool. - max_pool -- maximum size of free pool. - max_age -- max age of free element. + *min_pool* + minimum size of free pool. + + *max_pool* + maximum size of free pool. + + *max_age* + max age of free element. .. _ref_param_prefer_ipv6: prefer_ipv6 ~~~~~~~~~~~ - - Units: bool - - Default: off + * Units: bool + * Default: off - Prefer IPv6 address when connecting to backends which have both IPv4 and IPv6 addresses. +Prefer IPv6 address when connecting to backends which have both IPv4 and IPv6 addresses. .. _ref_param_rush_exponent: rush_exponent ~~~~~~~~~~~~~ - - Units: requests per request - - Default: 3 - - Flags: experimental + * Units: requests per request + * Default: 3 + * Flags: experimental - How many parked request we start for each completed request on the object. - NB: Even with the implict delay of delivery, this parameter controls an exponential increase in number of worker threads. +How many parked request we start for each completed request on the object. +NB: Even with the implict delay of delivery, this parameter controls an exponential increase in number of worker threads. .. _ref_param_send_timeout: send_timeout ~~~~~~~~~~~~ - - Units: seconds - - Default: 600 - - Flags: delayed + * Units: seconds + * Default: 600 + * Flags: delayed - Send timeout for client connections. If the HTTP response hasn't been transmitted in this many - seconds the session is closed. - See setsockopt(2) under SO_SNDTIMEO for more information. +Send timeout for client connections. If the HTTP response hasn't been transmitted in this many +seconds the session is closed. +See setsockopt(2) under SO_SNDTIMEO for more information. .. _ref_param_session_max: session_max ~~~~~~~~~~~ - - Units: sessions - - Default: 100000 + * Units: sessions + * Default: 100000 - Maximum number of sessions we will allocate from one pool before just dropping connections. - This is mostly an anti-DoS measure, and setting it plenty high should not hurt, as long as you have the memory for it. +Maximum number of sessions we will allocate from one pool before just dropping connections. +This is mostly an anti-DoS measure, and setting it plenty high should not hurt, as long as you have the memory for it. .. _ref_param_shm_reclen: shm_reclen ~~~~~~~~~~ - - Units: bytes - - Default: 255 + * Units: bytes + * Default: 255 - Maximum number of bytes in SHM log record. - Maximum is 65535 bytes. +Maximum number of bytes in SHM log record. +Maximum is 65535 bytes. .. _ref_param_shortlived: shortlived ~~~~~~~~~~ - - Units: s - - Default: 10.0 + * Units: s + * Default: 10.0 - Objects created with TTL shorter than this are always put in transient storage. +Objects created with TTL shorter than this are always put in transient storage. .. _ref_param_sigsegv_handler: sigsegv_handler ~~~~~~~~~~~~~~~ - - Units: bool - - Default: off - - Flags: must_restart + * Units: bool + * Default: off + * Flags: must_restart - Install a signal handler which tries to dump debug information on segmentation faults. +Install a signal handler which tries to dump debug information on segmentation faults. .. _ref_param_syslog_cli_traffic: syslog_cli_traffic ~~~~~~~~~~~~~~~~~~ - - Units: bool - - Default: on + * Units: bool + * Default: on - Log all CLI traffic to syslog(LOG_INFO). +Log all CLI traffic to syslog(LOG_INFO). .. _ref_param_tcp_keepalive_intvl: tcp_keepalive_intvl ~~~~~~~~~~~~~~~~~~~ - - Units: seconds - - Default: 5 - - Flags: experimental + * Units: seconds + * Default: 5 + * Flags: experimental - The number of seconds between TCP keep-alive probes. Note that this setting will only take effect when it is less thanthe system default. +The number of seconds between TCP keep-alive probes. Note that this setting will only take effect when it is less thanthe system default. .. _ref_param_tcp_keepalive_probes: tcp_keepalive_probes ~~~~~~~~~~~~~~~~~~~~ - - Units: probes - - Default: 5 - - Flags: experimental + * Units: probes + * Default: 5 + * Flags: experimental - The maximum number of TCP keep-alive probes to send before giving up and killing the connection if no response is obtained from the other end. Note that this setting will only take effect when it is less than the system default. +The maximum number of TCP keep-alive probes to send before giving up and killing the connection if no response is obtained from the other end. Note that this setting will only take effect when it is less than the system default. .. _ref_param_tcp_keepalive_time: tcp_keepalive_time ~~~~~~~~~~~~~~~~~~ - - Units: seconds - - Default: 600 - - Flags: experimental + * Units: seconds + * Default: 600 + * Flags: experimental - The number of seconds a connection needs to be idle before TCP begins sending out keep-alive probes. Note that this setting will only take effect when it is less than the system default. +The number of seconds a connection needs to be idle before TCP begins sending out keep-alive probes. Note that this setting will only take effect when it is less than the system default. .. _ref_param_thread_pool_add_delay: thread_pool_add_delay ~~~~~~~~~~~~~~~~~~~~~ - - Units: seconds - - Default: 0 - - Flags: experimental + * Units: seconds + * Default: 0 + * Flags: experimental - Wait at least this long after creating a thread. +Wait at least this long after creating a thread. - Some (buggy) systems may need a short (sub-second) delay between creating threads. - Set this to a few milliseconds if you see the 'threads_failed' counter grow too much. +Some (buggy) systems may need a short (sub-second) delay between creating threads. +Set this to a few milliseconds if you see the 'threads_failed' counter grow too much. - Setting this too high results in insuffient worker threads. +Setting this too high results in insuffient worker threads. .. _ref_param_thread_pool_destroy_delay: thread_pool_destroy_delay ~~~~~~~~~~~~~~~~~~~~~~~~~ - - Units: seconds - - Default: 1 - - Flags: delayed, experimental + * Units: seconds + * Default: 1 + * Flags: delayed, experimental - Wait this long after destroying a thread. +Wait this long after destroying a thread. - This controls the decay of thread pools when idle(-ish). +This controls the decay of thread pools when idle(-ish). - Minimum is 0.01 second. +Minimum is 0.01 second. .. _ref_param_thread_pool_fail_delay: thread_pool_fail_delay ~~~~~~~~~~~~~~~~~~~~~~ - - Units: seconds - - Default: 0.2 - - Flags: experimental + * Units: seconds + * Default: 0.2 + * Flags: experimental - Wait at least this long after a failed thread creation before trying to create another thread. +Wait at least this long after a failed thread creation before trying to create another thread. - Failure to create a worker thread is often a sign that the end is near, because the process is running out of some resource. This delay tries to not rush the end on needlessly. +Failure to create a worker thread is often a sign that the end is near, because the process is running out of some resource. This delay tries to not rush the end on needlessly. - If thread creation failures are a problem, check that thread_pool_max is not too high. +If thread creation failures are a problem, check that thread_pool_max is not too high. - It may also help to increase thread_pool_timeout and thread_pool_min, to reduce the rate at which treads are destroyed and later recreated. +It may also help to increase thread_pool_timeout and thread_pool_min, to reduce the rate at which treads are destroyed and later recreated. .. _ref_param_thread_pool_max: thread_pool_max ~~~~~~~~~~~~~~~ - - Units: threads - - Default: 5000 - - Flags: delayed + * Units: threads + * Default: 5000 + * Flags: delayed - The maximum number of worker threads in each pool. +The maximum number of worker threads in each pool. - Do not set this higher than you have to, since excess worker threads soak up RAM and CPU and generally just get in the way of getting work done. +Do not set this higher than you have to, since excess worker threads soak up RAM and CPU and generally just get in the way of getting work done. - Minimum is 10 threads. +Minimum is 10 threads. .. _ref_param_thread_pool_min: thread_pool_min ~~~~~~~~~~~~~~~ - - Units: threads - - Default: 100 - - Flags: delayed + * Units: threads + * Default: 100 + * Flags: delayed - The minimum number of worker threads in each pool. +The minimum number of worker threads in each pool. - Increasing this may help ramp up faster from low load situations or when threads have expired. +Increasing this may help ramp up faster from low load situations or when threads have expired. - Minimum is 10 threads. +Minimum is 10 threads. .. _ref_param_thread_pool_stack: thread_pool_stack ~~~~~~~~~~~~~~~~~ - - Units: bytes - - Default: 48k - - Flags: experimental + * Units: bytes + * Default: 48k + * Flags: experimental - Worker thread stack size. - This is likely rounded up to a multiple of 4k by the kernel. - The kernel/OS has a lower limit which will be enforced. +Worker thread stack size. +This is likely rounded up to a multiple of 4k by the kernel. +The kernel/OS has a lower limit which will be enforced. .. _ref_param_thread_pool_timeout: thread_pool_timeout ~~~~~~~~~~~~~~~~~~~ - - Units: seconds - - Default: 300 - - Flags: delayed, experimental + * Units: seconds + * Default: 300 + * Flags: delayed, experimental - Thread idle threshold. +Thread idle threshold. - Threads in excess of thread_pool_min, which have been idle for at least this long, will be destroyed. +Threads in excess of thread_pool_min, which have been idle for at least this long, will be destroyed. - Minimum is 10 seconds. +Minimum is 10 seconds. .. _ref_param_thread_pools: thread_pools ~~~~~~~~~~~~ - - Units: pools - - Default: 2 - - Flags: delayed, experimental + * Units: pools + * Default: 2 + * Flags: delayed, experimental - Number of worker thread pools. +Number of worker thread pools. - Increasing number of worker pools decreases lock contention. +Increasing number of worker pools decreases lock contention. - Too many pools waste CPU and RAM resources, and more than one pool for each CPU is probably detrimal to performance. +Too many pools waste CPU and RAM resources, and more than one pool for each CPU is probably detrimal to performance. - Can be increased on the fly, but decreases require a restart to take effect. +Can be increased on the fly, but decreases require a restart to take effect. .. _ref_param_thread_queue_limit: thread_queue_limit ~~~~~~~~~~~~~~~~~~ - - Default: 20 - - Flags: experimental + * Default: 20 + * Flags: experimental - Permitted queue length per thread-pool. +Permitted queue length per thread-pool. - This sets the number of requests we will queue, waiting for an available thread. Above this limit sessions will be dropped instead of queued. +This sets the number of requests we will queue, waiting for an available thread. Above this limit sessions will be dropped instead of queued. .. _ref_param_thread_stats_rate: thread_stats_rate ~~~~~~~~~~~~~~~~~ - - Units: requests - - Default: 10 - - Flags: experimental + * Units: requests + * Default: 10 + * Flags: experimental - Worker threads accumulate statistics, and dump these into the global stats counters if the lock is free when they finish a request. - This parameters defines the maximum number of requests a worker thread may handle, before it is forced to dump its accumulated stats into the global counters. +Worker threads accumulate statistics, and dump these into the global stats counters if the lock is free when they finish a request. +This parameters defines the maximum number of requests a worker thread may handle, before it is forced to dump its accumulated stats into the global counters. .. _ref_param_timeout_idle: timeout_idle ~~~~~~~~~~~~ - - Units: seconds - - Default: 5 + * Units: seconds + * Default: 5 - Idle timeout for client connections. - A connection is considered idle, until we receive a non-white-space character on it. +Idle timeout for client connections. +A connection is considered idle, until we receive a non-white-space character on it. .. _ref_param_timeout_linger: timeout_linger ~~~~~~~~~~~~~~ - - Units: seconds - - Default: 0.050 - - Flags: experimental + * Units: seconds + * Default: 0.050 + * Flags: experimental - How long time the workerthread lingers on an idle session before handing it over to the waiter. - When sessions are reused, as much as half of all reuses happen within the first 100 msec of the previous request completing. - Setting this too high results in worker threads not doing anything for their keep, setting it too low just means that more sessions take a detour around the waiter. +How long time the workerthread lingers on an idle session before handing it over to the waiter. +When sessions are reused, as much as half of all reuses happen within the first 100 msec of the previous request completing. +Setting this too high results in worker threads not doing anything for their keep, setting it too low just means that more sessions take a detour around the waiter. .. _ref_param_timeout_req: timeout_req ~~~~~~~~~~~ - - Units: seconds - - Default: 2 + * Units: seconds + * Default: 2 - Max time to receive clients request header, measured from first non-white-space character to double CRNL. +Max time to receive clients request header, measured from first non-white-space character to double CRNL. .. _ref_param_user: user ~~~~ - - Default: nobody - - Flags: must_restart + * Default: nobody + * Flags: must_restart - The unprivileged user to run as. +The unprivileged user to run as. .. _ref_param_vcc_allow_inline_c: vcc_allow_inline_c ~~~~~~~~~~~~~~~~~~ - - Units: bool - - Default: off + * Units: bool + * Default: off - Allow inline C code in VCL. +Allow inline C code in VCL. .. _ref_param_vcc_err_unref: vcc_err_unref ~~~~~~~~~~~~~ - - Units: bool - - Default: on + * Units: bool + * Default: on - Unreferenced VCL objects result in error. +Unreferenced VCL objects result in error. .. _ref_param_vcc_unsafe_path: vcc_unsafe_path ~~~~~~~~~~~~~~~ - - Units: bool - - Default: on + * Units: bool + * Default: on - Allow '/' in vmod & include paths. - Allow 'import ... from ...'. +Allow '/' in vmod & include paths. +Allow 'import ... from ...'. .. _ref_param_vcl_dir: vcl_dir ~~~~~~~ - - Default: /opt/varnish/etc/varnish + * Default: /opt/varnish/etc/varnish - Directory from which relative VCL filenames (vcl.load and include) are opened. +Directory from which relative VCL filenames (vcl.load and include) are opened. .. _ref_param_vmod_dir: vmod_dir ~~~~~~~~ - - Default: /opt/varnish/lib/varnish/vmods + * Default: /opt/varnish/lib/varnish/vmods - Directory where VCL modules are to be found. +Directory where VCL modules are to be found. .. _ref_param_vsl_buffer: vsl_buffer ~~~~~~~~~~ - - Units: bytes - - Default: 4k + * Units: bytes + * Default: 4k - Bytes of (req-/backend-)workspace dedicated to buffering VSL records. - At a bare minimum, this must be longer than the longest HTTP header to be logged. - Setting this too high costs memory, setting it too low will cause more VSL flushes and likely increase lock-contention on the VSL mutex. - Minimum is 1k bytes. +Bytes of (req-/backend-)workspace dedicated to buffering VSL records. +At a bare minimum, this must be longer than the longest HTTP header to be logged. +Setting this too high costs memory, setting it too low will cause more VSL flushes and likely increase lock-contention on the VSL mutex. +Minimum is 1k bytes. .. _ref_param_vsl_mask: vsl_mask ~~~~~~~~ - - Default: default + * Default: default + +Mask individual VSL messages from being logged. - Mask individual VSL messages from being logged. - default Set default value + *default* + Set default value - Use +/- prefixe in front of VSL tag name, to mask/unmask individual VSL messages. +Use +/- prefixe in front of VSL tag name, to mask/unmask individual VSL messages. .. _ref_param_vsl_space: vsl_space ~~~~~~~~~ - - Units: bytes - - Default: 80M - - Flags: must_restart + * Units: bytes + * Default: 80M + * Flags: must_restart - The amount of space to allocate for the VSL fifo buffer in the VSM memory segment. If you make this too small, varnish{ncsa|log} etc will not be able to keep up. Making it too large just costs memory resources. +The amount of space to allocate for the VSL fifo buffer in the VSM memory segment. If you make this too small, varnish{ncsa|log} etc will not be able to keep up. Making it too large just costs memory resources. .. _ref_param_vsm_space: vsm_space ~~~~~~~~~ - - Units: bytes - - Default: 1M - - Flags: must_restart + * Units: bytes + * Default: 1M + * Flags: must_restart - The amount of space to allocate for stats counters in the VSM memory segment. If you make this too small, some counters will be invisible. Making it too large just costs memory resources. +The amount of space to allocate for stats counters in the VSM memory segment. If you make this too small, some counters will be invisible. Making it too large just costs memory resources. .. _ref_param_waiter: waiter ~~~~~~ - - Default: platform dependent - - Flags: must_restart, wizard + * Default: platform dependent + * Flags: must_restart, wizard - Select the waiter kernel interface. +Select the waiter kernel interface. .. _ref_param_workspace_backend: workspace_backend ~~~~~~~~~~~~~~~~~ - - Units: bytes - - Default: 64k - - Flags: delayed + * Units: bytes + * Default: 64k + * Flags: delayed - Bytes of HTTP protocol workspace for backend HTTP req/resp. If larger than 4k, use a multiple of 4k for VM efficiency. +Bytes of HTTP protocol workspace for backend HTTP req/resp. If larger than 4k, use a multiple of 4k for VM efficiency. .. _ref_param_workspace_client: workspace_client ~~~~~~~~~~~~~~~~ - - Units: bytes - - Default: 64k - - Flags: delayed + * Units: bytes + * Default: 64k + * Flags: delayed - Bytes of HTTP protocol workspace for clients HTTP req/resp. If larger than 4k, use a multiple of 4k for VM efficiency. +Bytes of HTTP protocol workspace for clients HTTP req/resp. If larger than 4k, use a multiple of 4k for VM efficiency. .. _ref_param_workspace_thread: workspace_thread ~~~~~~~~~~~~~~~~ - - Units: bytes - - Default: 2048 - - Flags: delayed + * Units: bytes + * Default: 2048 + * Flags: delayed - Bytes of auxillary workspace per thread. - This workspace is used for certain temporary data structures during the operation of a worker thread. - One use is for the io-vectors for writing requests and responses to sockets, having too little space will result in more writev(2) system calls, having too much just wastes the space. +Bytes of auxillary workspace per thread. +This workspace is used for certain temporary data structures during the operation of a worker thread. +One use is for the io-vectors for writing requests and responses to sockets, having too little space will result in more writev(2) system calls, having too much just wastes the space. From phk at varnish-cache.org Tue Nov 12 10:45:13 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 12 Nov 2013 11:45:13 +0100 Subject: [master] 78fd62b And fix "param.show $param_name" which I just broke. Message-ID: commit 78fd62b70911be5a21511633053562b58d98c4d9 Author: Poul-Henning Kamp Date: Tue Nov 12 10:45:01 2013 +0000 And fix "param.show $param_name" which I just broke. diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c index 7fd361f..dcab5a2 100644 --- a/bin/varnishd/mgt/mgt_param.c +++ b/bin/varnishd/mgt/mgt_param.c @@ -216,7 +216,9 @@ mcf_param_show(struct cli *cli, const char * const *av, void *priv) lfmt = 1; for (i = 0; i < nparspec; i++) { pp = parspecs[i]; - if (av[2] != NULL && !lfmt && strcmp(pp->name, av[2])) + if (av[2] != NULL && + strcmp(pp->name, av[2]) && + strcmp("-l", av[2])) continue; if (lfmt) { VCLI_Out(cli, "%s\n", pp->name); From phk at varnish-cache.org Tue Nov 12 11:38:49 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 12 Nov 2013 12:38:49 +0100 Subject: [master] 817b7f6 Move the defaults for ${user} and ${group} over with the other run-time determined defaults. Message-ID: commit 817b7f6033e45ae6b3012b70c9d1c26f624c7bdf Author: Poul-Henning Kamp Date: Tue Nov 12 11:38:22 2013 +0000 Move the defaults for ${user} and ${group} over with the other run-time determined defaults. diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index 8b6fd82..820552f 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -36,6 +36,8 @@ #include #include +#include +#include #include #include #include @@ -415,6 +417,12 @@ main(int argc, char * const *argv) MCF_CollectParams(); + /* If we have nobody/nogroup, use them as defaults */ + if (getpwnam("nobody") != NULL) + MCF_SetDefault("user", "nobody"); + if (getgrnam("nogroup") != NULL) + MCF_SetDefault("group", "nogroup"); + if (sizeof(void *) < 8) { /* * Adjust default parameters for 32 bit systems to conserve diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c index dcab5a2..131c70e 100644 --- a/bin/varnishd/mgt/mgt_param.c +++ b/bin/varnishd/mgt/mgt_param.c @@ -30,10 +30,7 @@ #include "config.h" #include -#include -#include #include -#include #include #include #include @@ -415,12 +412,6 @@ MCF_CollectParams(void) MCF_AddParams(mgt_parspec); MCF_AddParams(WRK_parspec); MCF_AddParams(VSL_parspec); - - /* If we have nobody/nogroup, use them as defaults */ - if (getpwnam("nobody") != NULL) - MCF_SetDefault("user", "nobody"); - if (getgrnam("nogroup") != NULL) - MCF_SetDefault("group", "nogroup"); } /*--------------------------------------------------------------------*/ From phk at varnish-cache.org Tue Nov 12 13:04:28 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 12 Nov 2013 14:04:28 +0100 Subject: [master] 8a69328 Make tweakers return an int, rather than calling VCLI_SetResult() directly. Message-ID: commit 8a69328946f99e95f71c4d60b4e3525ca297272a Author: Poul-Henning Kamp Date: Tue Nov 12 13:03:51 2013 +0000 Make tweakers return an int, rather than calling VCLI_SetResult() directly. diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c index 131c70e..e2a0297 100644 --- a/bin/varnishd/mgt/mgt_param.c +++ b/bin/varnishd/mgt/mgt_param.c @@ -223,7 +223,8 @@ mcf_param_show(struct cli *cli, const char * const *av, void *priv) } else { VCLI_Out(cli, "%-*s", margin2, pp->name); } - pp->func(cli, pp, NULL); + if (pp->func(cli, pp, NULL)) + VCLI_SetResult(cli, CLIS_PARAM); if (pp->units != NULL && *pp->units != '\0') VCLI_Out(cli, " [%s]\n", pp->units); else @@ -310,7 +311,8 @@ MCF_ParamSet(struct cli *cli, const char *param, const char *val) VCLI_Out(cli, "parameter \"%s\" is protected.", param); return; } - pp->func(cli, pp, val); + if (pp->func(cli, pp, val)) + VCLI_SetResult(cli, CLIS_PARAM); if (cli->result == CLIS_OK && heritage.param != NULL) *heritage.param = mgt_param; @@ -397,7 +399,8 @@ MCF_SetDefaults(struct cli *cli) if (cli != NULL) VCLI_Out(cli, "Set Default for %s = %s\n", pp->name, pp->def); - pp->func(cli, pp, pp->def); + if (pp->func(cli, pp, pp->def)) + VCLI_SetResult(cli, CLIS_PARAM); if (cli != NULL && cli->result != CLIS_OK) return; } diff --git a/bin/varnishd/mgt/mgt_param.h b/bin/varnishd/mgt/mgt_param.h index 70d4351..b0bba39 100644 --- a/bin/varnishd/mgt/mgt_param.h +++ b/bin/varnishd/mgt/mgt_param.h @@ -30,7 +30,7 @@ struct parspec; -typedef void tweak_t(struct cli *, const struct parspec *, const char *arg); +typedef int tweak_t(struct cli *, const struct parspec *, const char *arg); struct parspec { const char *name; @@ -51,23 +51,22 @@ struct parspec { const char *units; }; -tweak_t tweak_user; -tweak_t tweak_group; -tweak_t tweak_string; tweak_t tweak_bool; -tweak_t tweak_waiter; +tweak_t tweak_bytes; tweak_t tweak_bytes_u; -tweak_t tweak_listen_address; -tweak_t tweak_timeout; tweak_t tweak_generic_double; +tweak_t tweak_group; +tweak_t tweak_listen_address; tweak_t tweak_poolparam; +tweak_t tweak_string; +tweak_t tweak_timeout; +tweak_t tweak_timeout_double; +tweak_t tweak_uint; +tweak_t tweak_user; +tweak_t tweak_waiter; int tweak_generic_uint(struct cli *cli, volatile unsigned *dest, const char *arg, unsigned min, unsigned max); -void tweak_uint(struct cli *cli, const struct parspec *par, const char *arg); -void tweak_timeout_double(struct cli *cli, - const struct parspec *par, const char *arg); -void tweak_bytes(struct cli *cli, const struct parspec *par, const char *arg); /* mgt_param_tbl.c */ extern const struct parspec mgt_parspec[]; diff --git a/bin/varnishd/mgt/mgt_param_bits.c b/bin/varnishd/mgt/mgt_param_bits.c index cda1154..24276f1 100644 --- a/bin/varnishd/mgt/mgt_param_bits.c +++ b/bin/varnishd/mgt/mgt_param_bits.c @@ -66,7 +66,7 @@ bit(uint8_t *p, unsigned no, enum bit_do act) /*-------------------------------------------------------------------- */ -static void +static int bit_tweak(struct cli *cli, uint8_t *p, unsigned l, const char *arg, const char * const *tags, const char *desc, const char *sign) { @@ -78,17 +78,15 @@ bit_tweak(struct cli *cli, uint8_t *p, unsigned l, const char *arg, av = VAV_Parse(arg, &n, ARGV_COMMA); if (av[0] != NULL) { VCLI_Out(cli, "Cannot parse: %s\n", av[0]); - VCLI_SetResult(cli, CLIS_PARAM); VAV_Free(av); - return; + return (-1); } for (i = 1; av[i] != NULL; i++) { s = av[i]; if (*s != '-' && *s != '+') { VCLI_Out(cli, "Missing '+' or '-' (%s)\n", s); - VCLI_SetResult(cli, CLIS_PARAM); VAV_Free(av); - return; + return (-1); } for (j = 0; j < l; j++) { if (tags[j] != NULL && !strcasecmp(s + 1, tags[j])) @@ -96,9 +94,8 @@ bit_tweak(struct cli *cli, uint8_t *p, unsigned l, const char *arg, } if (tags[j] == NULL) { VCLI_Out(cli, "Unknown %s (%s)\n", desc, s); - VCLI_SetResult(cli, CLIS_PARAM); VAV_Free(av); - return; + return (-1); } assert(j < l); if (s[0] == *sign) @@ -107,6 +104,7 @@ bit_tweak(struct cli *cli, uint8_t *p, unsigned l, const char *arg, (void)bit(p, j, BCLR); } VAV_Free(av); + return (0); } @@ -121,7 +119,7 @@ static const char * const VSL_tags[256] = { NULL }; -static void +static int tweak_vsl_mask(struct cli *cli, const struct parspec *par, const char *arg) { unsigned j; @@ -136,9 +134,9 @@ tweak_vsl_mask(struct cli *cli, const struct parspec *par, const char *arg) (void)bit(mgt_param.vsl_mask, SLT_WorkThread, BSET); (void)bit(mgt_param.vsl_mask, SLT_Hash, BSET); } else { - bit_tweak(cli, mgt_param.vsl_mask, + return (bit_tweak(cli, mgt_param.vsl_mask, SLT__Reserved, arg, VSL_tags, - "VSL tag", "-"); + "VSL tag", "-")); } } else { s = ""; @@ -151,6 +149,7 @@ tweak_vsl_mask(struct cli *cli, const struct parspec *par, const char *arg) if (*s == '\0') VCLI_Out(cli, "(all enabled)"); } + return (0); } /*-------------------------------------------------------------------- @@ -164,7 +163,7 @@ static const char * const debug_tags[] = { NULL }; -static void +static int tweak_debug(struct cli *cli, const struct parspec *par, const char *arg) { const char *s; @@ -176,8 +175,8 @@ tweak_debug(struct cli *cli, const struct parspec *par, const char *arg) memset(mgt_param.debug_bits, 0, sizeof mgt_param.debug_bits); } else { - bit_tweak(cli, mgt_param.debug_bits, - DBG_Reserved, arg, debug_tags, "debug bit", "+"); + return (bit_tweak(cli, mgt_param.debug_bits, + DBG_Reserved, arg, debug_tags, "debug bit", "+")); } } else { s = ""; @@ -190,6 +189,7 @@ tweak_debug(struct cli *cli, const struct parspec *par, const char *arg) if (*s == '\0') VCLI_Out(cli, "none"); } + return (0); } /*-------------------------------------------------------------------- @@ -203,7 +203,7 @@ static const char * const feature_tags[] = { NULL }; -static void +static int tweak_feature(struct cli *cli, const struct parspec *par, const char *arg) { const char *s; @@ -215,9 +215,9 @@ tweak_feature(struct cli *cli, const struct parspec *par, const char *arg) memset(mgt_param.feature_bits, 0, sizeof mgt_param.feature_bits); } else { - bit_tweak(cli, mgt_param.feature_bits, + return (bit_tweak(cli, mgt_param.feature_bits, FEATURE_Reserved, arg, feature_tags, - "feature bit", "+"); + "feature bit", "+")); } } else { s = ""; @@ -230,6 +230,7 @@ tweak_feature(struct cli *cli, const struct parspec *par, const char *arg) if (*s == '\0') VCLI_Out(cli, "none"); } + return (0); } /*-------------------------------------------------------------------- diff --git a/bin/varnishd/mgt/mgt_param_tweak.c b/bin/varnishd/mgt/mgt_param_tweak.c index ec5ef05..ee30f54 100644 --- a/bin/varnishd/mgt/mgt_param_tweak.c +++ b/bin/varnishd/mgt/mgt_param_tweak.c @@ -58,7 +58,7 @@ /*--------------------------------------------------------------------*/ -static void +static int tweak_generic_timeout(struct cli *cli, volatile unsigned *dst, const char *arg) { unsigned u; @@ -67,23 +67,23 @@ tweak_generic_timeout(struct cli *cli, volatile unsigned *dst, const char *arg) u = strtoul(arg, NULL, 0); if (u == 0) { VCLI_Out(cli, "Timeout must be greater than zero\n"); - VCLI_SetResult(cli, CLIS_PARAM); - return; + return (-1); } *dst = u; } else VCLI_Out(cli, "%u", *dst); + return (0); } /*--------------------------------------------------------------------*/ -void +int tweak_timeout(struct cli *cli, const struct parspec *par, const char *arg) { volatile unsigned *dest; dest = par->priv; - tweak_generic_timeout(cli, dest, arg); + return (tweak_generic_timeout(cli, dest, arg)); } /*--------------------------------------------------------------------*/ @@ -100,19 +100,16 @@ tweak_generic_timeout_double(struct cli *cli, volatile double *dest, u = strtod(arg, &p); if (*arg == '\0' || *p != '\0') { VCLI_Out(cli, "Not a number(%s)\n", arg); - VCLI_SetResult(cli, CLIS_PARAM); return (-1); } if (u < min) { VCLI_Out(cli, "Timeout must be greater or equal to %.g\n", min); - VCLI_SetResult(cli, CLIS_PARAM); return (-1); } if (u > max) { VCLI_Out(cli, "Timeout must be less than or equal to %.g\n", max); - VCLI_SetResult(cli, CLIS_PARAM); return (-1); } *dest = u; @@ -121,19 +118,20 @@ tweak_generic_timeout_double(struct cli *cli, volatile double *dest, return (0); } -void +int tweak_timeout_double(struct cli *cli, const struct parspec *par, const char *arg) { volatile double *dest; dest = par->priv; - (void)tweak_generic_timeout_double(cli, dest, arg, par->min, par->max); + return (tweak_generic_timeout_double(cli, dest, arg, + par->min, par->max)); } /*--------------------------------------------------------------------*/ -void +int tweak_generic_double(struct cli *cli, const struct parspec *par, const char *arg) { @@ -148,31 +146,29 @@ tweak_generic_double(struct cli *cli, const struct parspec *par, if (*p != '\0') { VCLI_Out(cli, "Not a number (%s)\n", arg); - VCLI_SetResult(cli, CLIS_PARAM); - return; + return (-1); } if (u < par->min) { VCLI_Out(cli, "Must be greater or equal to %.g\n", par->min); - VCLI_SetResult(cli, CLIS_PARAM); - return; + return (-1); } if (u > par->max) { VCLI_Out(cli, "Must be less than or equal to %.g\n", par->max); - VCLI_SetResult(cli, CLIS_PARAM); - return; + return (-1); } *dest = u; } else VCLI_Out(cli, "%f", *dest); + return (0); } /*--------------------------------------------------------------------*/ -void +int tweak_bool(struct cli *cli, const struct parspec *par, const char *arg) { volatile unsigned *dest; @@ -204,14 +200,14 @@ tweak_bool(struct cli *cli, const struct parspec *par, const char *arg) mode ? "use \"on\" or \"off\"\n" : "use \"true\" or \"false\"\n"); - VCLI_SetResult(cli, CLIS_PARAM); - return; + return (-1); } } else if (mode) { VCLI_Out(cli, *dest ? "on" : "off"); } else { VCLI_Out(cli, *dest ? "true" : "false"); } + return (0); } /*--------------------------------------------------------------------*/ @@ -231,18 +227,15 @@ tweak_generic_uint(struct cli *cli, volatile unsigned *dest, const char *arg, u = strtoul(arg, &p, 0); if (*arg == '\0' || *p != '\0') { VCLI_Out(cli, "Not a number (%s)\n", arg); - VCLI_SetResult(cli, CLIS_PARAM); return (-1); } } if (u < min) { VCLI_Out(cli, "Must be at least %u\n", min); - VCLI_SetResult(cli, CLIS_PARAM); return (-1); } if (u > max) { VCLI_Out(cli, "Must be no more than %u\n", max); - VCLI_SetResult(cli, CLIS_PARAM); return (-1); } *dest = u; @@ -256,7 +249,7 @@ tweak_generic_uint(struct cli *cli, volatile unsigned *dest, const char *arg, /*--------------------------------------------------------------------*/ -void +int tweak_uint(struct cli *cli, const struct parspec *par, const char *arg) { volatile unsigned *dest; @@ -264,6 +257,7 @@ tweak_uint(struct cli *cli, const struct parspec *par, const char *arg) dest = par->priv; (void)tweak_generic_uint(cli, dest, arg, (uint)par->min, (uint)par->max); + return (0); } /*--------------------------------------------------------------------*/ @@ -291,7 +285,7 @@ fmt_bytes(struct cli *cli, uintmax_t t) VCLI_Out(cli, "(bogus number)"); } -static void +static int tweak_generic_bytes(struct cli *cli, volatile ssize_t *dest, const char *arg, double min, double max) { @@ -305,51 +299,48 @@ tweak_generic_bytes(struct cli *cli, volatile ssize_t *dest, const char *arg, VCLI_Out(cli, "%s\n", p); VCLI_Out(cli, " Try something like '80k' or '120M'\n"); - VCLI_SetResult(cli, CLIS_PARAM); - return; + return (-1); } if ((uintmax_t)((ssize_t)r) != r) { fmt_bytes(cli, r); VCLI_Out(cli, " is too large for this architecture.\n"); - VCLI_SetResult(cli, CLIS_PARAM); - return; + return (-1); } if (max != 0. && r > max) { VCLI_Out(cli, "Must be no more than "); fmt_bytes(cli, (uintmax_t)max); VCLI_Out(cli, "\n"); - VCLI_SetResult(cli, CLIS_PARAM); - return; + return (-1); } if (r < min) { VCLI_Out(cli, "Must be at least "); fmt_bytes(cli, (uintmax_t)min); VCLI_Out(cli, "\n"); - VCLI_SetResult(cli, CLIS_PARAM); - return; + return (-1); } *dest = r; } else { fmt_bytes(cli, *dest); } + return (0); } /*--------------------------------------------------------------------*/ -void +int tweak_bytes(struct cli *cli, const struct parspec *par, const char *arg) { volatile ssize_t *dest; assert(par->min >= 0); dest = par->priv; - tweak_generic_bytes(cli, dest, arg, par->min, par->max); + return (tweak_generic_bytes(cli, dest, arg, par->min, par->max)); } /*--------------------------------------------------------------------*/ -void +int tweak_bytes_u(struct cli *cli, const struct parspec *par, const char *arg) { volatile unsigned *d1; @@ -359,8 +350,10 @@ tweak_bytes_u(struct cli *cli, const struct parspec *par, const char *arg) assert(par->min >= 0); d1 = par->priv; dest = *d1; - tweak_generic_bytes(cli, &dest, arg, par->min, par->max); + if (tweak_generic_bytes(cli, &dest, arg, par->min, par->max)) + return (-1); *d1 = dest; + return (0); } /*-------------------------------------------------------------------- @@ -371,7 +364,7 @@ tweak_bytes_u(struct cli *cli, const struct parspec *par, const char *arg) * XXX: The magic init string is a hack for this. */ -void +int tweak_user(struct cli *cli, const struct parspec *par, const char *arg) { struct passwd *pw; @@ -382,8 +375,7 @@ tweak_user(struct cli *cli, const struct parspec *par, const char *arg) pw = getpwnam(arg); if (pw == NULL) { VCLI_Out(cli, "Unknown user"); - VCLI_SetResult(cli, CLIS_PARAM); - return; + return(-1); } REPLACE(mgt_param.user, pw->pw_name); mgt_param.uid = pw->pw_uid; @@ -395,13 +387,14 @@ tweak_user(struct cli *cli, const struct parspec *par, const char *arg) } else { VCLI_Out(cli, "UID %d", (int)mgt_param.uid); } + return (0); } /*-------------------------------------------------------------------- * XXX: see comment for tweak_user, same thing here. */ -void +int tweak_group(struct cli *cli, const struct parspec *par, const char *arg) { struct group *gr; @@ -412,8 +405,7 @@ tweak_group(struct cli *cli, const struct parspec *par, const char *arg) gr = getgrnam(arg); if (gr == NULL) { VCLI_Out(cli, "Unknown group"); - VCLI_SetResult(cli, CLIS_PARAM); - return; + return(-1); } REPLACE(mgt_param.group, gr->gr_name); mgt_param.gid = gr->gr_gid; @@ -425,6 +417,7 @@ tweak_group(struct cli *cli, const struct parspec *par, const char *arg) } else { VCLI_Out(cli, "GID %d", (int)mgt_param.gid); } + return (0); } /*--------------------------------------------------------------------*/ @@ -443,38 +436,35 @@ clean_listen_sock_head(struct listen_sock_head *lsh) } } -void +int tweak_listen_address(struct cli *cli, const struct parspec *par, const char *arg) { char **av; - int i; + int i, retval = 0; struct listen_sock *ls; struct listen_sock_head lsh; (void)par; if (arg == NULL) { VCLI_Quote(cli, mgt_param.listen_address); - return; + return (0); } av = VAV_Parse(arg, NULL, ARGV_COMMA); if (av == NULL) { VCLI_Out(cli, "Parse error: out of memory"); - VCLI_SetResult(cli, CLIS_PARAM); - return; + return(-1); } if (av[0] != NULL) { VCLI_Out(cli, "Parse error: %s", av[0]); - VCLI_SetResult(cli, CLIS_PARAM); VAV_Free(av); - return; + return(-1); } if (av[1] == NULL) { VCLI_Out(cli, "Empty listen address"); - VCLI_SetResult(cli, CLIS_PARAM); VAV_Free(av); - return; + return(-1); } VTAILQ_INIT(&lsh); for (i = 1; av[i] != NULL; i++) { @@ -485,7 +475,7 @@ tweak_listen_address(struct cli *cli, const struct parspec *par, if (n == 0) { VCLI_Out(cli, "Invalid listen address "); VCLI_Quote(cli, av[i]); - VCLI_SetResult(cli, CLIS_PARAM); + retval = -1; break; } for (j = 0; j < n; ++j) { @@ -500,9 +490,9 @@ tweak_listen_address(struct cli *cli, const struct parspec *par, free(ta); } VAV_Free(av); - if (cli != NULL && cli->result != CLIS_OK) { + if (retval) { clean_listen_sock_head(&lsh); - return; + return (-1); } REPLACE(mgt_param.listen_address, arg); @@ -517,11 +507,12 @@ tweak_listen_address(struct cli *cli, const struct parspec *par, VTAILQ_INSERT_TAIL(&heritage.socks, ls, list); heritage.nsocks++; } + return (0); } /*--------------------------------------------------------------------*/ -void +int tweak_string(struct cli *cli, const struct parspec *par, const char *arg) { char **p = TRUST_ME(par->priv); @@ -533,26 +524,28 @@ tweak_string(struct cli *cli, const struct parspec *par, const char *arg) } else { REPLACE(*p, arg); } + return (0); } /*--------------------------------------------------------------------*/ -void +int tweak_waiter(struct cli *cli, const struct parspec *par, const char *arg) { /* XXX should have tweak_generic_string */ (void)par; - WAIT_tweak_waiter(cli, arg); + return (WAIT_tweak_waiter(cli, arg)); } /*--------------------------------------------------------------------*/ -void +int tweak_poolparam(struct cli *cli, const struct parspec *par, const char *arg) { volatile struct poolparam *pp, px; char **av; + int retval = 0; pp = par->priv; if (arg == NULL) { @@ -563,35 +556,39 @@ tweak_poolparam(struct cli *cli, const struct parspec *par, const char *arg) do { if (av[0] != NULL) { VCLI_Out(cli, "Parse error: %s", av[0]); - VCLI_SetResult(cli, CLIS_PARAM); + retval = -1; break; } if (av[1] == NULL || av[2] == NULL || av[3] == NULL) { VCLI_Out(cli, "Three fields required:" " min_pool, max_pool and max_age\n"); - VCLI_SetResult(cli, CLIS_PARAM); + retval = -1; break; } px = *pp; - if (tweak_generic_uint(cli, &px.min_pool, av[1], - (uint)par->min, (uint)par->max)) + retval = tweak_generic_uint(cli, &px.min_pool, av[1], + (uint)par->min, (uint)par->max); + if (retval) break; - if (tweak_generic_uint(cli, &px.max_pool, av[2], - (uint)par->min, (uint)par->max)) + retval = tweak_generic_uint(cli, &px.max_pool, av[2], + (uint)par->min, (uint)par->max); + if (retval) break; - if (tweak_generic_timeout_double(cli, &px.max_age, - av[3], 0, 1e6)) + retval = tweak_generic_timeout_double(cli, + &px.max_age, av[3], 0, 1e6); + if (retval) break; if (px.min_pool > px.max_pool) { VCLI_Out(cli, "min_pool cannot be larger" " than max_pool\n"); - VCLI_SetResult(cli, CLIS_PARAM); + retval = -1; break; } *pp = px; } while(0); VAV_Free(av); } + return (retval); } diff --git a/bin/varnishd/mgt/mgt_pool.c b/bin/varnishd/mgt/mgt_pool.c index 1bfa994..8096170 100644 --- a/bin/varnishd/mgt/mgt_pool.c +++ b/bin/varnishd/mgt/mgt_pool.c @@ -54,13 +54,13 @@ /*--------------------------------------------------------------------*/ -static void +static int tweak_thread_pool_min(struct cli *cli, const struct parspec *par, const char *arg) { - (void)tweak_generic_uint(cli, &mgt_param.wthread_min, arg, - (unsigned)par->min, mgt_param.wthread_max); + return (tweak_generic_uint(cli, &mgt_param.wthread_min, arg, + (unsigned)par->min, mgt_param.wthread_max)); } /*-------------------------------------------------------------------- @@ -69,7 +69,7 @@ tweak_thread_pool_min(struct cli *cli, const struct parspec *par, * XXX: "32bit" is a magic marker for 32bit systems. */ -static void +static int tweak_stack_size(struct cli *cli, const struct parspec *par, const char *arg) { @@ -77,21 +77,23 @@ tweak_stack_size(struct cli *cli, const struct parspec *par, low = sysconf(_SC_THREAD_STACK_MIN); - tweak_bytes(cli, par, arg); + if (tweak_bytes(cli, par, arg)) + return (-1); if (mgt_param.wthread_stacksize < low) mgt_param.wthread_stacksize = low; + return (0); } /*--------------------------------------------------------------------*/ -static void +static int tweak_thread_pool_max(struct cli *cli, const struct parspec *par, const char *arg) { (void)par; - (void)tweak_generic_uint(cli, &mgt_param.wthread_max, arg, - mgt_param.wthread_min, UINT_MAX); + return (tweak_generic_uint(cli, &mgt_param.wthread_max, arg, + mgt_param.wthread_min, UINT_MAX)); } /*--------------------------------------------------------------------*/ diff --git a/bin/varnishd/waiter/mgt_waiter.c b/bin/varnishd/waiter/mgt_waiter.c index 94d90ea..0d841a1 100644 --- a/bin/varnishd/waiter/mgt_waiter.c +++ b/bin/varnishd/waiter/mgt_waiter.c @@ -36,7 +36,6 @@ #include "common/common.h" #include "waiter/waiter.h" -#include "vcli.h" #include "vcli_priv.h" static const struct waiter *const vca_waiters[] = { @@ -55,7 +54,7 @@ static const struct waiter *const vca_waiters[] = { struct waiter const *waiter; -void +int WAIT_tweak_waiter(struct cli *cli, const char *arg) { int i; @@ -73,18 +72,18 @@ WAIT_tweak_waiter(struct cli *cli, const char *arg) VCLI_Out(cli, "%s%s", i == 0 ? "" : ", ", vca_waiters[i]->name); VCLI_Out(cli, ")"); - return; + return(0); } if (!strcmp(arg, WAITER_DEFAULT)) { waiter = vca_waiters[0]; - return; + return(0); } for (i = 0; vca_waiters[i]; i++) { if (!strcmp(arg, vca_waiters[i]->name)) { waiter = vca_waiters[i]; - return; + return(0); } } VCLI_Out(cli, "Unknown waiter"); - VCLI_SetResult(cli, CLIS_PARAM); + return (-1); } diff --git a/bin/varnishd/waiter/waiter.h b/bin/varnishd/waiter/waiter.h index ce46e4d..5f1a546 100644 --- a/bin/varnishd/waiter/waiter.h +++ b/bin/varnishd/waiter/waiter.h @@ -43,7 +43,7 @@ struct waiter { /* mgt_waiter.c */ extern struct waiter const * waiter; -void WAIT_tweak_waiter(struct cli *cli, const char *arg); +int WAIT_tweak_waiter(struct cli *cli, const char *arg); #if defined(HAVE_EPOLL_CTL) extern const struct waiter waiter_epoll; From phk at varnish-cache.org Tue Nov 12 13:32:40 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 12 Nov 2013 14:32:40 +0100 Subject: [master] 6d0c94c Wean param tweakers from the CLI interface and just give them a VSB instead. Message-ID: commit 6d0c94c34c0e471b12982b207857934ec4e6ea57 Author: Poul-Henning Kamp Date: Tue Nov 12 13:32:20 2013 +0000 Wean param tweakers from the CLI interface and just give them a VSB instead. diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c index e2a0297..8c32bcd 100644 --- a/bin/varnishd/mgt/mgt_param.c +++ b/bin/varnishd/mgt/mgt_param.c @@ -223,7 +223,7 @@ mcf_param_show(struct cli *cli, const char * const *av, void *priv) } else { VCLI_Out(cli, "%-*s", margin2, pp->name); } - if (pp->func(cli, pp, NULL)) + if (pp->func(cli->sb, pp, NULL)) VCLI_SetResult(cli, CLIS_PARAM); if (pp->units != NULL && *pp->units != '\0') VCLI_Out(cli, " [%s]\n", pp->units); @@ -311,7 +311,7 @@ MCF_ParamSet(struct cli *cli, const char *param, const char *val) VCLI_Out(cli, "parameter \"%s\" is protected.", param); return; } - if (pp->func(cli, pp, val)) + if (pp->func(cli->sb, pp, val)) VCLI_SetResult(cli, CLIS_PARAM); if (cli->result == CLIS_OK && heritage.param != NULL) @@ -388,22 +388,37 @@ MCF_AddParams(const struct parspec *ps) * Set defaults for all parameters */ -static void -MCF_SetDefaults(struct cli *cli) +void +MCF_InitParams(struct cli *cli) { const struct parspec *pp; - int i; - - for (i = 0; i < nparspec; i++) { - pp = parspecs[i]; - if (cli != NULL) - VCLI_Out(cli, - "Set Default for %s = %s\n", pp->name, pp->def); - if (pp->func(cli, pp, pp->def)) - VCLI_SetResult(cli, CLIS_PARAM); - if (cli != NULL && cli->result != CLIS_OK) - return; + int i, j, err; + struct vsb *vsb; + + /* + * We try to set the default twice, and only failures the + * second time around are fatal. This allows for trivial + * interdependencies. + */ + vsb = VSB_new_auto(); + AN(vsb); + for (j = 0; j < 2; j++) { + err = 0; + for (i = 0; i < nparspec; i++) { + pp = parspecs[i]; + VSB_clear(vsb); + VSB_printf(vsb, + "FAILED to set default for param %s = %s\n", + pp->name, pp->def); + err = pp->func(vsb, pp, pp->def); + AZ(VSB_finish(vsb)); + if (err && j) { + VCLI_Out(cli, "%s", VSB_data(vsb)); + VCLI_SetResult(cli, CLIS_CANT); + } + } } + VSB_delete(vsb); } /*--------------------------------------------------------------------*/ @@ -420,17 +435,6 @@ MCF_CollectParams(void) /*--------------------------------------------------------------------*/ void -MCF_InitParams(struct cli *cli) -{ - - /* XXX: We do this twice, to get past any interdependencies */ - MCF_SetDefaults(NULL); - MCF_SetDefaults(cli); -} - -/*--------------------------------------------------------------------*/ - -void MCF_SetDefault(const char *param, const char *def) { struct parspec *pn; diff --git a/bin/varnishd/mgt/mgt_param.h b/bin/varnishd/mgt/mgt_param.h index b0bba39..c30394f 100644 --- a/bin/varnishd/mgt/mgt_param.h +++ b/bin/varnishd/mgt/mgt_param.h @@ -30,7 +30,7 @@ struct parspec; -typedef int tweak_t(struct cli *, const struct parspec *, const char *arg); +typedef int tweak_t(struct vsb *, const struct parspec *, const char *arg); struct parspec { const char *name; @@ -65,7 +65,7 @@ tweak_t tweak_uint; tweak_t tweak_user; tweak_t tweak_waiter; -int tweak_generic_uint(struct cli *cli, +int tweak_generic_uint(struct vsb *vsb, volatile unsigned *dest, const char *arg, unsigned min, unsigned max); /* mgt_param_tbl.c */ diff --git a/bin/varnishd/mgt/mgt_param_bits.c b/bin/varnishd/mgt/mgt_param_bits.c index 24276f1..57b26ce 100644 --- a/bin/varnishd/mgt/mgt_param_bits.c +++ b/bin/varnishd/mgt/mgt_param_bits.c @@ -38,9 +38,6 @@ #include "mgt/mgt_param.h" #include "vav.h" -#include "vcli.h" -#include "vcli_common.h" -#include "vcli_priv.h" #include "vapi/vsl_int.h" @@ -67,7 +64,7 @@ bit(uint8_t *p, unsigned no, enum bit_do act) */ static int -bit_tweak(struct cli *cli, uint8_t *p, unsigned l, const char *arg, +bit_tweak(struct vsb *vsb, uint8_t *p, unsigned l, const char *arg, const char * const *tags, const char *desc, const char *sign) { int i, n; @@ -77,14 +74,14 @@ bit_tweak(struct cli *cli, uint8_t *p, unsigned l, const char *arg, av = VAV_Parse(arg, &n, ARGV_COMMA); if (av[0] != NULL) { - VCLI_Out(cli, "Cannot parse: %s\n", av[0]); + VSB_printf(vsb, "Cannot parse: %s\n", av[0]); VAV_Free(av); return (-1); } for (i = 1; av[i] != NULL; i++) { s = av[i]; if (*s != '-' && *s != '+') { - VCLI_Out(cli, "Missing '+' or '-' (%s)\n", s); + VSB_printf(vsb, "Missing '+' or '-' (%s)\n", s); VAV_Free(av); return (-1); } @@ -93,7 +90,7 @@ bit_tweak(struct cli *cli, uint8_t *p, unsigned l, const char *arg, break; } if (tags[j] == NULL) { - VCLI_Out(cli, "Unknown %s (%s)\n", desc, s); + VSB_printf(vsb, "Unknown %s (%s)\n", desc, s); VAV_Free(av); return (-1); } @@ -120,7 +117,7 @@ static const char * const VSL_tags[256] = { }; static int -tweak_vsl_mask(struct cli *cli, const struct parspec *par, const char *arg) +tweak_vsl_mask(struct vsb *vsb, const struct parspec *par, const char *arg) { unsigned j; const char *s; @@ -134,7 +131,7 @@ tweak_vsl_mask(struct cli *cli, const struct parspec *par, const char *arg) (void)bit(mgt_param.vsl_mask, SLT_WorkThread, BSET); (void)bit(mgt_param.vsl_mask, SLT_Hash, BSET); } else { - return (bit_tweak(cli, mgt_param.vsl_mask, + return (bit_tweak(vsb, mgt_param.vsl_mask, SLT__Reserved, arg, VSL_tags, "VSL tag", "-")); } @@ -142,12 +139,12 @@ tweak_vsl_mask(struct cli *cli, const struct parspec *par, const char *arg) s = ""; for (j = 0; j < (unsigned)SLT__Reserved; j++) { if (bit(mgt_param.vsl_mask, j, BTST)) { - VCLI_Out(cli, "%s-%s", s, VSL_tags[j]); + VSB_printf(vsb, "%s-%s", s, VSL_tags[j]); s = ","; } } if (*s == '\0') - VCLI_Out(cli, "(all enabled)"); + VSB_printf(vsb, "(all enabled)"); } return (0); } @@ -164,7 +161,7 @@ static const char * const debug_tags[] = { }; static int -tweak_debug(struct cli *cli, const struct parspec *par, const char *arg) +tweak_debug(struct vsb *vsb, const struct parspec *par, const char *arg) { const char *s; unsigned j; @@ -175,19 +172,19 @@ tweak_debug(struct cli *cli, const struct parspec *par, const char *arg) memset(mgt_param.debug_bits, 0, sizeof mgt_param.debug_bits); } else { - return (bit_tweak(cli, mgt_param.debug_bits, + return (bit_tweak(vsb, mgt_param.debug_bits, DBG_Reserved, arg, debug_tags, "debug bit", "+")); } } else { s = ""; for (j = 0; j < (unsigned)DBG_Reserved; j++) { if (bit(mgt_param.debug_bits, j, BTST)) { - VCLI_Out(cli, "%s+%s", s, debug_tags[j]); + VSB_printf(vsb, "%s+%s", s, debug_tags[j]); s = ","; } } if (*s == '\0') - VCLI_Out(cli, "none"); + VSB_printf(vsb, "none"); } return (0); } @@ -204,7 +201,7 @@ static const char * const feature_tags[] = { }; static int -tweak_feature(struct cli *cli, const struct parspec *par, const char *arg) +tweak_feature(struct vsb *vsb, const struct parspec *par, const char *arg) { const char *s; unsigned j; @@ -215,7 +212,7 @@ tweak_feature(struct cli *cli, const struct parspec *par, const char *arg) memset(mgt_param.feature_bits, 0, sizeof mgt_param.feature_bits); } else { - return (bit_tweak(cli, mgt_param.feature_bits, + return (bit_tweak(vsb, mgt_param.feature_bits, FEATURE_Reserved, arg, feature_tags, "feature bit", "+")); } @@ -223,12 +220,12 @@ tweak_feature(struct cli *cli, const struct parspec *par, const char *arg) s = ""; for (j = 0; j < (unsigned)FEATURE_Reserved; j++) { if (bit(mgt_param.feature_bits, j, BTST)) { - VCLI_Out(cli, "%s+%s", s, feature_tags[j]); + VSB_printf(vsb, "%s+%s", s, feature_tags[j]); s = ","; } } if (*s == '\0') - VCLI_Out(cli, "none"); + VSB_printf(vsb, "none"); } return (0); } diff --git a/bin/varnishd/mgt/mgt_param_tbl.c b/bin/varnishd/mgt/mgt_param_tbl.c index d93914d..d6247d7 100644 --- a/bin/varnishd/mgt/mgt_param_tbl.c +++ b/bin/varnishd/mgt/mgt_param_tbl.c @@ -65,7 +65,7 @@ const struct parspec mgt_parspec[] = { "The TTL assigned to objects if neither the backend nor " "the VCL code assigns one.", OBJ_STICKY, - "120", "seconds" }, + "20", "seconds" }, { "default_grace", tweak_timeout_double, &mgt_param.default_grace, 0, UINT_MAX, "Default grace period. We will deliver an object " diff --git a/bin/varnishd/mgt/mgt_param_tweak.c b/bin/varnishd/mgt/mgt_param_tweak.c index ee30f54..fa2e866 100644 --- a/bin/varnishd/mgt/mgt_param_tweak.c +++ b/bin/varnishd/mgt/mgt_param_tweak.c @@ -59,37 +59,37 @@ /*--------------------------------------------------------------------*/ static int -tweak_generic_timeout(struct cli *cli, volatile unsigned *dst, const char *arg) +tweak_generic_timeout(struct vsb *vsb, volatile unsigned *dst, const char *arg) { unsigned u; if (arg != NULL) { u = strtoul(arg, NULL, 0); if (u == 0) { - VCLI_Out(cli, "Timeout must be greater than zero\n"); + VSB_printf(vsb, "Timeout must be greater than zero\n"); return (-1); } *dst = u; } else - VCLI_Out(cli, "%u", *dst); + VSB_printf(vsb, "%u", *dst); return (0); } /*--------------------------------------------------------------------*/ int -tweak_timeout(struct cli *cli, const struct parspec *par, const char *arg) +tweak_timeout(struct vsb *vsb, const struct parspec *par, const char *arg) { volatile unsigned *dest; dest = par->priv; - return (tweak_generic_timeout(cli, dest, arg)); + return (tweak_generic_timeout(vsb, dest, arg)); } /*--------------------------------------------------------------------*/ static int -tweak_generic_timeout_double(struct cli *cli, volatile double *dest, +tweak_generic_timeout_double(struct vsb *vsb, volatile double *dest, const char *arg, double min, double max) { double u; @@ -99,40 +99,40 @@ tweak_generic_timeout_double(struct cli *cli, volatile double *dest, p = NULL; u = strtod(arg, &p); if (*arg == '\0' || *p != '\0') { - VCLI_Out(cli, "Not a number(%s)\n", arg); + VSB_printf(vsb, "Not a number(%s)\n", arg); return (-1); } if (u < min) { - VCLI_Out(cli, + VSB_printf(vsb, "Timeout must be greater or equal to %.g\n", min); return (-1); } if (u > max) { - VCLI_Out(cli, + VSB_printf(vsb, "Timeout must be less than or equal to %.g\n", max); return (-1); } *dest = u; } else - VCLI_Out(cli, "%.6f", *dest); + VSB_printf(vsb, "%.6f", *dest); return (0); } int -tweak_timeout_double(struct cli *cli, const struct parspec *par, +tweak_timeout_double(struct vsb *vsb, const struct parspec *par, const char *arg) { volatile double *dest; dest = par->priv; - return (tweak_generic_timeout_double(cli, dest, arg, + return (tweak_generic_timeout_double(vsb, dest, arg, par->min, par->max)); } /*--------------------------------------------------------------------*/ int -tweak_generic_double(struct cli *cli, const struct parspec *par, +tweak_generic_double(struct vsb *vsb, const struct parspec *par, const char *arg) { volatile double *dest; @@ -144,32 +144,32 @@ tweak_generic_double(struct cli *cli, const struct parspec *par, p = NULL; u = strtod(arg, &p); if (*p != '\0') { - VCLI_Out(cli, + VSB_printf(vsb, "Not a number (%s)\n", arg); return (-1); } if (u < par->min) { - VCLI_Out(cli, + VSB_printf(vsb, "Must be greater or equal to %.g\n", par->min); return (-1); } if (u > par->max) { - VCLI_Out(cli, + VSB_printf(vsb, "Must be less than or equal to %.g\n", par->max); return (-1); } *dest = u; } else - VCLI_Out(cli, "%f", *dest); + VSB_printf(vsb, "%f", *dest); return (0); } /*--------------------------------------------------------------------*/ int -tweak_bool(struct cli *cli, const struct parspec *par, const char *arg) +tweak_bool(struct vsb *vsb, const struct parspec *par, const char *arg) { volatile unsigned *dest; int mode = 0; @@ -196,16 +196,16 @@ tweak_bool(struct cli *cli, const struct parspec *par, const char *arg) else if (!strcasecmp(arg, "true")) *dest = 1; else { - VCLI_Out(cli, + VSB_printf(vsb, "%s", mode ? "use \"on\" or \"off\"\n" : "use \"true\" or \"false\"\n"); return (-1); } } else if (mode) { - VCLI_Out(cli, *dest ? "on" : "off"); + VSB_printf(vsb, "%s", *dest ? "on" : "off"); } else { - VCLI_Out(cli, *dest ? "true" : "false"); + VSB_printf(vsb, "%s", *dest ? "true" : "false"); } return (0); } @@ -213,7 +213,7 @@ tweak_bool(struct cli *cli, const struct parspec *par, const char *arg) /*--------------------------------------------------------------------*/ int -tweak_generic_uint(struct cli *cli, volatile unsigned *dest, const char *arg, +tweak_generic_uint(struct vsb *vsb, volatile unsigned *dest, const char *arg, unsigned min, unsigned max) { unsigned u; @@ -226,23 +226,23 @@ tweak_generic_uint(struct cli *cli, volatile unsigned *dest, const char *arg, else { u = strtoul(arg, &p, 0); if (*arg == '\0' || *p != '\0') { - VCLI_Out(cli, "Not a number (%s)\n", arg); + VSB_printf(vsb, "Not a number (%s)\n", arg); return (-1); } } if (u < min) { - VCLI_Out(cli, "Must be at least %u\n", min); + VSB_printf(vsb, "Must be at least %u\n", min); return (-1); } if (u > max) { - VCLI_Out(cli, "Must be no more than %u\n", max); + VSB_printf(vsb, "Must be no more than %u\n", max); return (-1); } *dest = u; } else if (*dest == UINT_MAX) { - VCLI_Out(cli, "unlimited"); + VSB_printf(vsb, "unlimited"); } else { - VCLI_Out(cli, "%u", *dest); + VSB_printf(vsb, "%u", *dest); } return (0); } @@ -250,12 +250,12 @@ tweak_generic_uint(struct cli *cli, volatile unsigned *dest, const char *arg, /*--------------------------------------------------------------------*/ int -tweak_uint(struct cli *cli, const struct parspec *par, const char *arg) +tweak_uint(struct vsb *vsb, const struct parspec *par, const char *arg) { volatile unsigned *dest; dest = par->priv; - (void)tweak_generic_uint(cli, dest, arg, + (void)tweak_generic_uint(vsb, dest, arg, (uint)par->min, (uint)par->max); return (0); } @@ -263,30 +263,30 @@ tweak_uint(struct cli *cli, const struct parspec *par, const char *arg) /*--------------------------------------------------------------------*/ static void -fmt_bytes(struct cli *cli, uintmax_t t) +fmt_bytes(struct vsb *vsb, uintmax_t t) { const char *p; if (t & 0xff) { - VCLI_Out(cli, "%jub", t); + VSB_printf(vsb, "%jub", t); return; } for (p = "kMGTPEZY"; *p; p++) { if (t & 0x300) { - VCLI_Out(cli, "%.2f%c", t / 1024.0, *p); + VSB_printf(vsb, "%.2f%c", t / 1024.0, *p); return; } t /= 1024; if (t & 0x0ff) { - VCLI_Out(cli, "%ju%c", t, *p); + VSB_printf(vsb, "%ju%c", t, *p); return; } } - VCLI_Out(cli, "(bogus number)"); + VSB_printf(vsb, "(bogus number)"); } static int -tweak_generic_bytes(struct cli *cli, volatile ssize_t *dest, const char *arg, +tweak_generic_bytes(struct vsb *vsb, volatile ssize_t *dest, const char *arg, double min, double max) { uintmax_t r; @@ -295,32 +295,32 @@ tweak_generic_bytes(struct cli *cli, volatile ssize_t *dest, const char *arg, if (arg != NULL) { p = VNUM_2bytes(arg, &r, 0); if (p != NULL) { - VCLI_Out(cli, "Could not convert to bytes.\n"); - VCLI_Out(cli, "%s\n", p); - VCLI_Out(cli, + VSB_printf(vsb, "Could not convert to bytes.\n"); + VSB_printf(vsb, "%s\n", p); + VSB_printf(vsb, " Try something like '80k' or '120M'\n"); return (-1); } if ((uintmax_t)((ssize_t)r) != r) { - fmt_bytes(cli, r); - VCLI_Out(cli, " is too large for this architecture.\n"); + fmt_bytes(vsb, r); + VSB_printf(vsb, " is too large for this architecture.\n"); return (-1); } if (max != 0. && r > max) { - VCLI_Out(cli, "Must be no more than "); - fmt_bytes(cli, (uintmax_t)max); - VCLI_Out(cli, "\n"); + VSB_printf(vsb, "Must be no more than "); + fmt_bytes(vsb, (uintmax_t)max); + VSB_printf(vsb, "\n"); return (-1); } if (r < min) { - VCLI_Out(cli, "Must be at least "); - fmt_bytes(cli, (uintmax_t)min); - VCLI_Out(cli, "\n"); + VSB_printf(vsb, "Must be at least "); + fmt_bytes(vsb, (uintmax_t)min); + VSB_printf(vsb, "\n"); return (-1); } *dest = r; } else { - fmt_bytes(cli, *dest); + fmt_bytes(vsb, *dest); } return (0); } @@ -328,20 +328,20 @@ tweak_generic_bytes(struct cli *cli, volatile ssize_t *dest, const char *arg, /*--------------------------------------------------------------------*/ int -tweak_bytes(struct cli *cli, const struct parspec *par, const char *arg) +tweak_bytes(struct vsb *vsb, const struct parspec *par, const char *arg) { volatile ssize_t *dest; assert(par->min >= 0); dest = par->priv; - return (tweak_generic_bytes(cli, dest, arg, par->min, par->max)); + return (tweak_generic_bytes(vsb, dest, arg, par->min, par->max)); } /*--------------------------------------------------------------------*/ int -tweak_bytes_u(struct cli *cli, const struct parspec *par, const char *arg) +tweak_bytes_u(struct vsb *vsb, const struct parspec *par, const char *arg) { volatile unsigned *d1; volatile ssize_t dest; @@ -350,7 +350,7 @@ tweak_bytes_u(struct cli *cli, const struct parspec *par, const char *arg) assert(par->min >= 0); d1 = par->priv; dest = *d1; - if (tweak_generic_bytes(cli, &dest, arg, par->min, par->max)) + if (tweak_generic_bytes(vsb, &dest, arg, par->min, par->max)) return (-1); *d1 = dest; return (0); @@ -365,7 +365,7 @@ tweak_bytes_u(struct cli *cli, const struct parspec *par, const char *arg) */ int -tweak_user(struct cli *cli, const struct parspec *par, const char *arg) +tweak_user(struct vsb *vsb, const struct parspec *par, const char *arg) { struct passwd *pw; @@ -374,7 +374,7 @@ tweak_user(struct cli *cli, const struct parspec *par, const char *arg) if (*arg != '\0') { pw = getpwnam(arg); if (pw == NULL) { - VCLI_Out(cli, "Unknown user"); + VSB_printf(vsb, "Unknown user"); return(-1); } REPLACE(mgt_param.user, pw->pw_name); @@ -383,9 +383,9 @@ tweak_user(struct cli *cli, const struct parspec *par, const char *arg) mgt_param.uid = getuid(); } } else if (mgt_param.user) { - VCLI_Out(cli, "%s (%d)", mgt_param.user, (int)mgt_param.uid); + VSB_printf(vsb, "%s (%d)", mgt_param.user, (int)mgt_param.uid); } else { - VCLI_Out(cli, "UID %d", (int)mgt_param.uid); + VSB_printf(vsb, "UID %d", (int)mgt_param.uid); } return (0); } @@ -395,7 +395,7 @@ tweak_user(struct cli *cli, const struct parspec *par, const char *arg) */ int -tweak_group(struct cli *cli, const struct parspec *par, const char *arg) +tweak_group(struct vsb *vsb, const struct parspec *par, const char *arg) { struct group *gr; @@ -404,7 +404,7 @@ tweak_group(struct cli *cli, const struct parspec *par, const char *arg) if (*arg != '\0') { gr = getgrnam(arg); if (gr == NULL) { - VCLI_Out(cli, "Unknown group"); + VSB_printf(vsb, "Unknown group"); return(-1); } REPLACE(mgt_param.group, gr->gr_name); @@ -413,9 +413,9 @@ tweak_group(struct cli *cli, const struct parspec *par, const char *arg) mgt_param.gid = getgid(); } } else if (mgt_param.group) { - VCLI_Out(cli, "%s (%d)", mgt_param.group, (int)mgt_param.gid); + VSB_printf(vsb, "%s (%d)", mgt_param.group, (int)mgt_param.gid); } else { - VCLI_Out(cli, "GID %d", (int)mgt_param.gid); + VSB_printf(vsb, "GID %d", (int)mgt_param.gid); } return (0); } @@ -437,7 +437,7 @@ clean_listen_sock_head(struct listen_sock_head *lsh) } int -tweak_listen_address(struct cli *cli, const struct parspec *par, +tweak_listen_address(struct vsb *vsb, const struct parspec *par, const char *arg) { char **av; @@ -447,22 +447,22 @@ tweak_listen_address(struct cli *cli, const struct parspec *par, (void)par; if (arg == NULL) { - VCLI_Quote(cli, mgt_param.listen_address); + VSB_quote(vsb, mgt_param.listen_address, -1, 0); return (0); } av = VAV_Parse(arg, NULL, ARGV_COMMA); if (av == NULL) { - VCLI_Out(cli, "Parse error: out of memory"); + VSB_printf(vsb, "Parse error: out of memory"); return(-1); } if (av[0] != NULL) { - VCLI_Out(cli, "Parse error: %s", av[0]); + VSB_printf(vsb, "Parse error: %s", av[0]); VAV_Free(av); return(-1); } if (av[1] == NULL) { - VCLI_Out(cli, "Empty listen address"); + VSB_printf(vsb, "Empty listen address"); VAV_Free(av); return(-1); } @@ -473,8 +473,8 @@ tweak_listen_address(struct cli *cli, const struct parspec *par, n = VSS_resolve(av[i], "http", &ta); if (n == 0) { - VCLI_Out(cli, "Invalid listen address "); - VCLI_Quote(cli, av[i]); + VSB_printf(vsb, "Invalid listen address "); + VSB_quote(vsb, av[i], -1, 0); retval = -1; break; } @@ -513,14 +513,14 @@ tweak_listen_address(struct cli *cli, const struct parspec *par, /*--------------------------------------------------------------------*/ int -tweak_string(struct cli *cli, const struct parspec *par, const char *arg) +tweak_string(struct vsb *vsb, const struct parspec *par, const char *arg) { char **p = TRUST_ME(par->priv); AN(p); /* XXX should have tweak_generic_string */ if (arg == NULL) { - VCLI_Quote(cli, *p); + VSB_quote(vsb, *p, -1, 0); } else { REPLACE(*p, arg); } @@ -530,18 +530,18 @@ tweak_string(struct cli *cli, const struct parspec *par, const char *arg) /*--------------------------------------------------------------------*/ int -tweak_waiter(struct cli *cli, const struct parspec *par, const char *arg) +tweak_waiter(struct vsb *vsb, const struct parspec *par, const char *arg) { /* XXX should have tweak_generic_string */ (void)par; - return (WAIT_tweak_waiter(cli, arg)); + return (WAIT_tweak_waiter(vsb, arg)); } /*--------------------------------------------------------------------*/ int -tweak_poolparam(struct cli *cli, const struct parspec *par, const char *arg) +tweak_poolparam(struct vsb *vsb, const struct parspec *par, const char *arg) { volatile struct poolparam *pp, px; char **av; @@ -549,38 +549,38 @@ tweak_poolparam(struct cli *cli, const struct parspec *par, const char *arg) pp = par->priv; if (arg == NULL) { - VCLI_Out(cli, "%u,%u,%g", + VSB_printf(vsb, "%u,%u,%g", pp->min_pool, pp->max_pool, pp->max_age); } else { av = VAV_Parse(arg, NULL, ARGV_COMMA); do { if (av[0] != NULL) { - VCLI_Out(cli, "Parse error: %s", av[0]); + VSB_printf(vsb, "Parse error: %s", av[0]); retval = -1; break; } if (av[1] == NULL || av[2] == NULL || av[3] == NULL) { - VCLI_Out(cli, + VSB_printf(vsb, "Three fields required:" " min_pool, max_pool and max_age\n"); retval = -1; break; } px = *pp; - retval = tweak_generic_uint(cli, &px.min_pool, av[1], + retval = tweak_generic_uint(vsb, &px.min_pool, av[1], (uint)par->min, (uint)par->max); if (retval) break; - retval = tweak_generic_uint(cli, &px.max_pool, av[2], + retval = tweak_generic_uint(vsb, &px.max_pool, av[2], (uint)par->min, (uint)par->max); if (retval) break; - retval = tweak_generic_timeout_double(cli, + retval = tweak_generic_timeout_double(vsb, &px.max_age, av[3], 0, 1e6); if (retval) break; if (px.min_pool > px.max_pool) { - VCLI_Out(cli, + VSB_printf(vsb, "min_pool cannot be larger" " than max_pool\n"); retval = -1; diff --git a/bin/varnishd/mgt/mgt_pool.c b/bin/varnishd/mgt/mgt_pool.c index 8096170..61b8425 100644 --- a/bin/varnishd/mgt/mgt_pool.c +++ b/bin/varnishd/mgt/mgt_pool.c @@ -55,11 +55,11 @@ /*--------------------------------------------------------------------*/ static int -tweak_thread_pool_min(struct cli *cli, const struct parspec *par, +tweak_thread_pool_min(struct vsb *vsb, const struct parspec *par, const char *arg) { - return (tweak_generic_uint(cli, &mgt_param.wthread_min, arg, + return (tweak_generic_uint(vsb, &mgt_param.wthread_min, arg, (unsigned)par->min, mgt_param.wthread_max)); } @@ -70,14 +70,14 @@ tweak_thread_pool_min(struct cli *cli, const struct parspec *par, */ static int -tweak_stack_size(struct cli *cli, const struct parspec *par, +tweak_stack_size(struct vsb *vsb, const struct parspec *par, const char *arg) { ssize_t low; low = sysconf(_SC_THREAD_STACK_MIN); - if (tweak_bytes(cli, par, arg)) + if (tweak_bytes(vsb, par, arg)) return (-1); if (mgt_param.wthread_stacksize < low) mgt_param.wthread_stacksize = low; @@ -87,12 +87,12 @@ tweak_stack_size(struct cli *cli, const struct parspec *par, /*--------------------------------------------------------------------*/ static int -tweak_thread_pool_max(struct cli *cli, const struct parspec *par, +tweak_thread_pool_max(struct vsb *vsb, const struct parspec *par, const char *arg) { (void)par; - return (tweak_generic_uint(cli, &mgt_param.wthread_max, arg, + return (tweak_generic_uint(vsb, &mgt_param.wthread_max, arg, mgt_param.wthread_min, UINT_MAX)); } diff --git a/bin/varnishd/waiter/mgt_waiter.c b/bin/varnishd/waiter/mgt_waiter.c index 0d841a1..c36e089 100644 --- a/bin/varnishd/waiter/mgt_waiter.c +++ b/bin/varnishd/waiter/mgt_waiter.c @@ -36,7 +36,6 @@ #include "common/common.h" #include "waiter/waiter.h" -#include "vcli_priv.h" static const struct waiter *const vca_waiters[] = { #if defined(HAVE_KQUEUE) @@ -55,7 +54,7 @@ static const struct waiter *const vca_waiters[] = { struct waiter const *waiter; int -WAIT_tweak_waiter(struct cli *cli, const char *arg) +WAIT_tweak_waiter(struct vsb *vsb, const char *arg) { int i; @@ -63,15 +62,15 @@ WAIT_tweak_waiter(struct cli *cli, const char *arg) if (arg == NULL) { if (waiter == NULL) - VCLI_Out(cli, "default"); + VSB_printf(vsb, "default"); else - VCLI_Out(cli, "%s", waiter->name); + VSB_printf(vsb, "%s", waiter->name); - VCLI_Out(cli, " (possible values: "); + VSB_printf(vsb, " (possible values: "); for (i = 0; vca_waiters[i] != NULL; i++) - VCLI_Out(cli, "%s%s", i == 0 ? "" : ", ", + VSB_printf(vsb, "%s%s", i == 0 ? "" : ", ", vca_waiters[i]->name); - VCLI_Out(cli, ")"); + VSB_printf(vsb, ")"); return(0); } if (!strcmp(arg, WAITER_DEFAULT)) { @@ -84,6 +83,6 @@ WAIT_tweak_waiter(struct cli *cli, const char *arg) return(0); } } - VCLI_Out(cli, "Unknown waiter"); + VSB_printf(vsb, "Unknown waiter"); return (-1); } diff --git a/bin/varnishd/waiter/waiter.h b/bin/varnishd/waiter/waiter.h index 5f1a546..5e8e56b 100644 --- a/bin/varnishd/waiter/waiter.h +++ b/bin/varnishd/waiter/waiter.h @@ -43,7 +43,7 @@ struct waiter { /* mgt_waiter.c */ extern struct waiter const * waiter; -int WAIT_tweak_waiter(struct cli *cli, const char *arg); +int WAIT_tweak_waiter(struct vsb *vsb, const char *arg); #if defined(HAVE_EPOLL_CTL) extern const struct waiter waiter_epoll; From phk at varnish-cache.org Tue Nov 12 13:48:47 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 12 Nov 2013 14:48:47 +0100 Subject: [master] d36344d De-const the parspec structs and modify them directly to avoid various pointless malloc'ing. Message-ID: commit d36344d35957ee964a6674f16df7142980e991c8 Author: Poul-Henning Kamp Date: Tue Nov 12 13:48:20 2013 +0000 De-const the parspec structs and modify them directly to avoid various pointless malloc'ing. diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c index 8c32bcd..b4ec68a 100644 --- a/bin/varnishd/mgt/mgt_param.c +++ b/bin/varnishd/mgt/mgt_param.c @@ -51,7 +51,7 @@ struct params mgt_param; static int nparspec; -static struct parspec const ** parspecs; +static struct parspec ** parspecs; static const int margin1 = 8; static int margin2 = 0; static const int wrap_at = 72; @@ -89,7 +89,7 @@ static const char PROTECTED_TEXT[] = /*--------------------------------------------------------------------*/ -static const struct parspec * +static struct parspec * mcf_findpar(const char *name, int *idx) { int i; @@ -278,17 +278,14 @@ MCF_ParamProtect(struct cli *cli, const char *args) return; } for (i = 1; av[i] != NULL; i++) { - if (mcf_findpar(av[i], &j) == NULL) { + pp = mcf_findpar(av[i], &j); + if (pp == NULL) { VCLI_Out(cli, "Unknown parameter %s", av[i]); VCLI_SetResult(cli, CLIS_PARAM); VAV_Free(av); return; } - pp = calloc(sizeof *pp, 1L); - AN(pp); - memcpy(pp, parspecs[j], sizeof *pp); pp->flags |= PROTECTED; - parspecs[j] = pp; } VAV_Free(av); } @@ -353,9 +350,9 @@ mcf_parspec_cmp(const void *a, const void *b) } static void -MCF_AddParams(const struct parspec *ps) +MCF_AddParams(struct parspec *ps) { - const struct parspec *pp; + struct parspec *pp; const char *s; int n; @@ -437,18 +434,11 @@ MCF_CollectParams(void) void MCF_SetDefault(const char *param, const char *def) { - struct parspec *pn; - int i; + struct parspec *pp; - for (i = 0; i < nparspec; i++) - if (!strcmp(parspecs[i]->name, param)) - break; - assert(i < nparspec); - pn = malloc(sizeof *pn); - AN(pn); - *pn = *(parspecs[i]); - pn->def = def; - parspecs[i] = pn; + pp = mcf_findpar(param, NULL); + AN(pp); + pp->def = def; } /*--------------------------------------------------------------------*/ diff --git a/bin/varnishd/mgt/mgt_param.h b/bin/varnishd/mgt/mgt_param.h index c30394f..6a9319b 100644 --- a/bin/varnishd/mgt/mgt_param.h +++ b/bin/varnishd/mgt/mgt_param.h @@ -69,10 +69,10 @@ int tweak_generic_uint(struct vsb *vsb, volatile unsigned *dest, const char *arg, unsigned min, unsigned max); /* mgt_param_tbl.c */ -extern const struct parspec mgt_parspec[]; +extern struct parspec mgt_parspec[]; /* mgt_param_vsl.c */ -extern const struct parspec VSL_parspec[]; +extern struct parspec VSL_parspec[]; /* mgt_pool.c */ -extern const struct parspec WRK_parspec[]; +extern struct parspec WRK_parspec[]; diff --git a/bin/varnishd/mgt/mgt_param_bits.c b/bin/varnishd/mgt/mgt_param_bits.c index 57b26ce..86b6f80 100644 --- a/bin/varnishd/mgt/mgt_param_bits.c +++ b/bin/varnishd/mgt/mgt_param_bits.c @@ -234,7 +234,7 @@ tweak_feature(struct vsb *vsb, const struct parspec *par, const char *arg) * The parameter table itself */ -const struct parspec VSL_parspec[] = { +struct parspec VSL_parspec[] = { { "vsl_mask", tweak_vsl_mask, NULL, 0, 0, "Mask individual VSL messages from being logged.\n" "\tdefault\tSet default value\n" diff --git a/bin/varnishd/mgt/mgt_param_tbl.c b/bin/varnishd/mgt/mgt_param_tbl.c index d6247d7..a8c1e4e 100644 --- a/bin/varnishd/mgt/mgt_param_tbl.c +++ b/bin/varnishd/mgt/mgt_param_tbl.c @@ -51,7 +51,7 @@ * XXX: we should generate the relevant section of varnishd.1 from here. */ -const struct parspec mgt_parspec[] = { +struct parspec mgt_parspec[] = { { "user", tweak_user, NULL, 0, 0, "The unprivileged user to run as.", MUST_RESTART, diff --git a/bin/varnishd/mgt/mgt_pool.c b/bin/varnishd/mgt/mgt_pool.c index 61b8425..8b3fe7e 100644 --- a/bin/varnishd/mgt/mgt_pool.c +++ b/bin/varnishd/mgt/mgt_pool.c @@ -98,7 +98,7 @@ tweak_thread_pool_max(struct vsb *vsb, const struct parspec *par, /*--------------------------------------------------------------------*/ -const struct parspec WRK_parspec[] = { +struct parspec WRK_parspec[] = { { "thread_pools", tweak_uint, &mgt_param.wthread_pools, 1, UINT_MAX, "Number of worker thread pools.\n" From tfheen at varnish-cache.org Tue Nov 12 14:07:13 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Tue, 12 Nov 2013 15:07:13 +0100 Subject: [3.0] 33d6063 Make RPM Provide: $varnishabi Message-ID: commit 33d6063ce82113c3edd4e8606d83247f54313c09 Author: Tollef Fog Heen Date: Fri Nov 1 13:33:38 2013 +0100 Make RPM Provide: $varnishabi We want VMODs to depend on the right ABI, so we need to provide something they can depend on. Do so, and hook that up with the RPM build process. diff --git a/redhat/Makefile.am b/redhat/Makefile.am index 86ddfd4..48294d7 100644 --- a/redhat/Makefile.am +++ b/redhat/Makefile.am @@ -9,4 +9,5 @@ EXTRA_DIST = \ varnish.spec \ varnish.sysconfig \ varnishlog.initrc \ - varnishncsa.initrc + varnishncsa.initrc \ + find-provides diff --git a/redhat/find-provides b/redhat/find-provides new file mode 100755 index 0000000..bf3ed59 --- /dev/null +++ b/redhat/find-provides @@ -0,0 +1,13 @@ +#! /bin/sh + +# This script is used to inject the Varnish ABI into the provides. + +set -x + +if [ -x /usr/lib/rpm/find-requires ]; then + /usr/lib/rpm/find-requires "$@" +fi + +cd $(dirname $0)/.. + +printf '#include "vmod_abi.h"\nVMOD_ABI_Version' | cpp - -Iinclude | sed '/^#/D;s/"//g;s/\([A-Z]\)/\L\1/g;s/[^a-z0-9.]/-/g;s/varnish/varnishabi/' diff --git a/redhat/varnish.spec b/redhat/varnish.spec index 0f69cc6..5ede7fd 100644 --- a/redhat/varnish.spec +++ b/redhat/varnish.spec @@ -1,3 +1,5 @@ +%define _use_internal_dependency_generator 0 +%define __find_provides %{_builddir}/varnish-%{version}%{?v_rc:-%{?v_rc}}/redhat/find-provides Summary: High-performance HTTP accelerator Name: varnish Version: 3.0.4 From tfheen at varnish-cache.org Tue Nov 12 14:07:13 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Tue, 12 Nov 2013 15:07:13 +0100 Subject: [3.0] c05055f Correct typo in vmod_std example Message-ID: commit c05055f88035b363af82c192c117d9a05fbb2cc8 Author: Stig Sandbeck Mathisen Date: Fri Aug 9 10:47:16 2013 +0200 Correct typo in vmod_std example diff --git a/doc/sphinx/reference/vmod_std.rst b/doc/sphinx/reference/vmod_std.rst index 984331e..fb48a3b 100644 --- a/doc/sphinx/reference/vmod_std.rst +++ b/doc/sphinx/reference/vmod_std.rst @@ -63,7 +63,7 @@ Description utilize it. Example | if (req.url ~ ^/slow/) { - | std.set_up_tos(0x0); + | std.set_ip_tos(0x0); | } random From tfheen at varnish-cache.org Tue Nov 12 14:07:13 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Tue, 12 Nov 2013 15:07:13 +0100 Subject: [3.0] 0d2a072 Import latest version from github.com/varnish/varnish-devicedetect/ Message-ID: commit 0d2a0725544ebd6480f0d3e170713024b5001ecd Author: Lasse Karstensen Date: Mon Aug 12 16:24:02 2013 +0200 Import latest version from github.com/varnish/varnish-devicedetect/ diff --git a/etc/devicedetect.vcl b/etc/devicedetect.vcl index ed5b39d..e7aecbf 100644 --- a/etc/devicedetect.vcl +++ b/etc/devicedetect.vcl @@ -5,65 +5,68 @@ # Author: Lasse Karstensen sub devicedetect { - unset req.http.X-UA-Device; - set req.http.X-UA-Device = "pc"; + unset req.http.X-UA-Device; + set req.http.X-UA-Device = "pc"; - if (req.http.User-Agent ~ "(?i)(ads|google|bing|msn|yandex|baidu|ro|career|)bot" || - req.http.User-Agent ~ "(?i)(baidu|symantec)spider" || - req.http.User-Agent ~ "(?i)scanner" || - req.http.User-Agent ~ "(?i)(web)crawler") { - set req.http.X-UA-Device = "bot"; } - elsif (req.http.User-Agent ~ "(?i)ip(hone|od)") { set req.http.X-UA-Device = "mobile-iphone"; } - elsif (req.http.User-Agent ~ "(?i)ipad") { set req.http.X-UA-Device = "tablet-ipad"; } - # how do we differ between an android phone and an android tablet? - # http://stackoverflow.com/questions/5341637/how-do-detect-android-tablets-in-general-useragent - elsif (req.http.User-Agent ~ "(?i)android.*(mobile|mini)") { set req.http.X-UA-Device = "mobile-android"; } - # android 3/honeycomb was just about tablet-only, and any phones will probably handle a bigger page layout. - elsif (req.http.User-Agent ~ "(?i)android 3") { set req.http.X-UA-Device = "tablet-android"; } - # may very well give false positives towards android tablets. Suggestions welcome. - elsif (req.http.User-Agent ~ "(?i)android") { set req.http.X-UA-Device = "tablet-android"; } - - elsif (req.http.User-Agent ~ "^HTC" || - req.http.User-Agent ~ "Fennec" || - req.http.User-Agent ~ "IEMobile" || - req.http.User-Agent ~ "BlackBerry" || - req.http.User-Agent ~ "SymbianOS.*AppleWebKit" || - req.http.User-Agent ~ "Opera Mobi") { - set req.http.X-UA-Device = "mobile-smartphone"; - } - elsif (req.http.User-Agent ~ "(?i)symbian" || - req.http.User-Agent ~ "(?i)^sonyericsson" || - req.http.User-Agent ~ "(?i)^nokia" || - req.http.User-Agent ~ "(?i)^samsung" || - req.http.User-Agent ~ "(?i)^lg" || - req.http.User-Agent ~ "(?i)bada" || - req.http.User-Agent ~ "(?i)blazer" || - req.http.User-Agent ~ "(?i)cellphone" || - req.http.User-Agent ~ "(?i)iemobile" || - req.http.User-Agent ~ "(?i)midp-2.0" || - req.http.User-Agent ~ "(?i)u990" || - req.http.User-Agent ~ "(?i)netfront" || - req.http.User-Agent ~ "(?i)opera mini" || - req.http.User-Agent ~ "(?i)palm" || - req.http.User-Agent ~ "(?i)nintendo wii" || - req.http.User-Agent ~ "(?i)playstation portable" || - req.http.User-Agent ~ "(?i)portalmmm" || - req.http.User-Agent ~ "(?i)proxinet" || - req.http.User-Agent ~ "(?i)sonyericsson" || - req.http.User-Agent ~ "(?i)symbian" || - req.http.User-Agent ~ "(?i)windows\ ?ce" || - req.http.User-Agent ~ "(?i)winwap" || - req.http.User-Agent ~ "(?i)eudoraweb" || - req.http.User-Agent ~ "(?i)htc" || - req.http.User-Agent ~ "(?i)240x320" || - req.http.User-Agent ~ "(?i)avantgo") { - set req.http.X-UA-Device = "mobile-generic"; - } - # handle overrides - if (req.http.Cookie ~ "(i?)X-UA-Device-force") { - # ;?? means zero or one ;, non-greedy to match the first. - set req.http.X-UA-Device = regsub(req.http.Cookie, "(?i).*X-UA-Device-force=([^;]+);??.*", "\1"); - } + # Handle that a cookie may override the detection alltogether. + if (req.http.Cookie ~ "(?i)X-UA-Device-force") { + /* ;?? means zero or one ;, non-greedy to match the first. */ + set req.http.X-UA-Device = regsub(req.http.Cookie, "(?i).*X-UA-Device-force=([^;]+);??.*", "\1"); + /* Clean up our mess in the cookie header */ + set req.http.Cookie = regsuball(req.http.Cookie, "(^|; ) *X-UA-Device-force=[^;]+;? *", "\1"); + /* If the cookie header is now empty, or just whitespace, unset it. */ + if (req.http.Cookie ~ "^ *$") { unset req.http.Cookie; } + } else { + if (req.http.User-Agent ~ "(?i)(ads|google|bing|msn|yandex|baidu|ro|career|)bot" || + req.http.User-Agent ~ "(?i)(baidu|jike|symantec)spider" || + req.http.User-Agent ~ "(?i)scanner" || + req.http.User-Agent ~ "(?i)(web)crawler") { + set req.http.X-UA-Device = "bot"; } + elsif (req.http.User-Agent ~ "(?i)ipad") { set req.http.X-UA-Device = "tablet-ipad"; } + elsif (req.http.User-Agent ~ "(?i)ip(hone|od)") { set req.http.X-UA-Device = "mobile-iphone"; } + /* how do we differ between an android phone and an android tablet? + http://stackoverflow.com/questions/5341637/how-do-detect-android-tablets-in-general-useragent */ + elsif (req.http.User-Agent ~ "(?i)android.*(mobile|mini)") { set req.http.X-UA-Device = "mobile-android"; } + // android 3/honeycomb was just about tablet-only, and any phones will probably handle a bigger page layout. + elsif (req.http.User-Agent ~ "(?i)android 3") { set req.http.X-UA-Device = "tablet-android"; } + // May very well give false positives towards android tablets. Suggestions welcome. + elsif (req.http.User-Agent ~ "(?i)android") { set req.http.X-UA-Device = "tablet-android"; } + elsif (req.http.User-Agent ~ "Mobile.+Firefox") { set req.http.X-UA-Device = "mobile-firefoxos"; } + elsif (req.http.User-Agent ~ "^HTC" || + req.http.User-Agent ~ "Fennec" || + req.http.User-Agent ~ "IEMobile" || + req.http.User-Agent ~ "BlackBerry" || + req.http.User-Agent ~ "SymbianOS.*AppleWebKit" || + req.http.User-Agent ~ "Opera Mobi") { + set req.http.X-UA-Device = "mobile-smartphone"; + } + elsif (req.http.User-Agent ~ "(?i)symbian" || + req.http.User-Agent ~ "(?i)^sonyericsson" || + req.http.User-Agent ~ "(?i)^nokia" || + req.http.User-Agent ~ "(?i)^samsung" || + req.http.User-Agent ~ "(?i)^lg" || + req.http.User-Agent ~ "(?i)bada" || + req.http.User-Agent ~ "(?i)blazer" || + req.http.User-Agent ~ "(?i)cellphone" || + req.http.User-Agent ~ "(?i)iemobile" || + req.http.User-Agent ~ "(?i)midp-2.0" || + req.http.User-Agent ~ "(?i)u990" || + req.http.User-Agent ~ "(?i)netfront" || + req.http.User-Agent ~ "(?i)opera mini" || + req.http.User-Agent ~ "(?i)palm" || + req.http.User-Agent ~ "(?i)nintendo wii" || + req.http.User-Agent ~ "(?i)playstation portable" || + req.http.User-Agent ~ "(?i)portalmmm" || + req.http.User-Agent ~ "(?i)proxinet" || + req.http.User-Agent ~ "(?i)sonyericsson" || + req.http.User-Agent ~ "(?i)symbian" || + req.http.User-Agent ~ "(?i)windows\ ?ce" || + req.http.User-Agent ~ "(?i)winwap" || + req.http.User-Agent ~ "(?i)eudoraweb" || + req.http.User-Agent ~ "(?i)htc" || + req.http.User-Agent ~ "(?i)240x320" || + req.http.User-Agent ~ "(?i)avantgo") { + set req.http.X-UA-Device = "mobile-generic"; + } + } } - -# vim: sw=4:tw=120 # meh From tfheen at varnish-cache.org Tue Nov 12 14:07:13 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Tue, 12 Nov 2013 15:07:13 +0100 Subject: [3.0] 4b58c3e Use exit() rather than _exit() so we can dump gcov info. Message-ID: commit 4b58c3e622e0912f8d964a7377da894a4d2e640c Author: Poul-Henning Kamp Date: Thu Oct 10 09:43:51 2013 +0000 Use exit() rather than _exit() so we can dump gcov info. diff --git a/bin/varnishtest/vtc_main.c b/bin/varnishtest/vtc_main.c index 01a5fe2..76fe2b2 100644 --- a/bin/varnishtest/vtc_main.c +++ b/bin/varnishtest/vtc_main.c @@ -300,7 +300,7 @@ start_test(void) (void)close(sfd); retval = exec_file(jp->tst->filename, jp->tst->script, jp->tmpdir, jp->buf, jp->bufsiz); - _exit(retval); + exit(retval); } AZ(close(p[1])); From tfheen at varnish-cache.org Tue Nov 12 14:07:13 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Tue, 12 Nov 2013 15:07:13 +0100 Subject: [3.0] dc30f89 Update README to point out how to contribute patches and bug reports. Message-ID: commit dc30f896d29356c5c3c84ac0e09d452f743bf072 Author: Tollef Fog Heen Date: Mon Oct 21 11:37:06 2013 +0200 Update README to point out how to contribute patches and bug reports. Thanks to James Pearson for the suggestion. diff --git a/README b/README index 2538063..3ce0b45 100644 --- a/README +++ b/README @@ -1,10 +1,12 @@ This is Varnish Cache, the high-performance HTTP accelerator. Documentation and additional information about Varnish is available on -http://www.varnish-cache.org/ +https://www.varnish-cache.org/ Technical questions about Varnish and this release should be addressed -to . +to . Please see +https://www.varnish-cache.org/trac/wiki/Contributing for how to +contribute patches and report bugs. Questions about commercial support and services related to Varnish should be addressed to . From tfheen at varnish-cache.org Tue Nov 12 14:07:13 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Tue, 12 Nov 2013 15:07:13 +0100 Subject: [3.0] 64eb4e4 Fix two issues in our backtrace code: Message-ID: commit 64eb4e4850d675e45007eb8e6bd96b086025b5f1 Author: Poul-Henning Kamp Date: Mon Nov 4 11:22:36 2013 +0000 Fix two issues in our backtrace code: use "nm -an", not "nm -agn" which supresses local symbols. Let backtrace_symbols() handle anything past _end. diff --git a/bin/varnishd/varnishd.c b/bin/varnishd/varnishd.c index 2f88409..36c7af2 100644 --- a/bin/varnishd/varnishd.c +++ b/bin/varnishd/varnishd.c @@ -262,7 +262,9 @@ 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); + if (!strcmp(s0->n, "_end")) + return (-1); + VSB_printf(vsb, "%p: %s+0x%jx", ptr, s0->n, (uintmax_t)pp - s0->a); return (0); } @@ -274,7 +276,7 @@ Symbol_hack(const char *a0) uintptr_t a; struct symbols *s; - bprintf(buf, "nm -agn %s 2>/dev/null", a0); + bprintf(buf, "nm -an %s 2>/dev/null", a0); fi = popen(buf, "r"); if (fi == NULL) return; From tfheen at varnish-cache.org Tue Nov 12 14:07:13 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Tue, 12 Nov 2013 15:07:13 +0100 Subject: [3.0] f851486 Unhide the functions we emit, so they appear in a backtrace. Message-ID: commit f851486c7de9d0617dda35663c4adae244074b7b Author: Poul-Henning Kamp Date: Mon Nov 4 11:37:53 2013 +0000 Unhide the functions we emit, so they appear in a backtrace. diff --git a/lib/libvcl/vcc_compile.c b/lib/libvcl/vcc_compile.c index f4a85a0..4bc29c7 100644 --- a/lib/libvcl/vcc_compile.c +++ b/lib/libvcl/vcc_compile.c @@ -671,8 +671,13 @@ vcc_CompileSource(const struct vcc *tl0, struct vsb *sb, struct source *sp) /* Emit method functions */ for (i = 0; i < VCL_MET_MAX; i++) { - Fc(tl, 1, "\nstatic int\n"); - Fc(tl, 1, "VGC_function_%s (struct sess *sp)\n", + Fh(tl, 1, "\nint\n"); + Fh(tl, 1, + "VGC_function_%s(struct sess *sp);\n", + method_tab[i].name); + Fc(tl, 1, "\nint\n"); + Fc(tl, 1, + "VGC_function_%s(struct sess *sp)\n", method_tab[i].name); AZ(VSB_finish(tl->fm[i])); Fc(tl, 1, "{\n"); diff --git a/lib/libvcl/vcc_parse.c b/lib/libvcl/vcc_parse.c index c616c3c..4a242e5 100644 --- a/lib/libvcl/vcc_parse.c +++ b/lib/libvcl/vcc_parse.c @@ -222,9 +222,11 @@ vcc_Function(struct vcc *tl) return; } tl->curproc = vcc_AddProc(tl, tl->t); - Fh(tl, 0, "static int VGC_function_%.*s (struct sess *sp);\n", + Fh(tl, 0, "int VGC_function_%.*s " + "(struct sess *sp);\n", PF(tl->t)); + Fc(tl, 1, "int VGC_function_%.*s(struct sess *sp);\n", PF(tl->t)); - Fc(tl, 1, "\nstatic int\n"); + Fc(tl, 1, "\nint\n"); Fc(tl, 1, "VGC_function_%.*s (struct sess *sp)\n", PF(tl->t)); } vcc_NextToken(tl); From tfheen at varnish-cache.org Tue Nov 12 14:07:13 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Tue, 12 Nov 2013 15:07:13 +0100 Subject: [3.0] a6a7d29 Bump version numbers in preparation for 3.0.5 Message-ID: commit a6a7d29213b4b472a84473b54477bd699a3e5063 Author: Tollef Fog Heen Date: Tue Nov 12 15:07:09 2013 +0100 Bump version numbers in preparation for 3.0.5 diff --git a/configure.ac b/configure.ac index 72d144f..5a454ef 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ AC_PREREQ(2.59) AC_COPYRIGHT([Copyright (c) 2006 Verdens Gang AS Copyright (c) 2006-2011 Varnish Software AS]) AC_REVISION([$Id$]) -AC_INIT([Varnish], [3.0.4], [varnish-dev at varnish-cache.org]) +AC_INIT([Varnish], [3.0.5-rc1], [varnish-dev at varnish-cache.org]) AC_CONFIG_SRCDIR(include/varnishapi.h) AM_CONFIG_HEADER(config.h) diff --git a/redhat/varnish.spec b/redhat/varnish.spec index 5ede7fd..aecf4f6 100644 --- a/redhat/varnish.spec +++ b/redhat/varnish.spec @@ -1,9 +1,10 @@ +%define v_rc rc1 %define _use_internal_dependency_generator 0 %define __find_provides %{_builddir}/varnish-%{version}%{?v_rc:-%{?v_rc}}/redhat/find-provides Summary: High-performance HTTP accelerator Name: varnish -Version: 3.0.4 -Release: 1%{?dist} +Version: 3.0.5 +Release: 0.rc1%{?dist} License: BSD Group: System Environment/Daemons URL: http://www.varnish-cache.org/ From phk at varnish-cache.org Tue Nov 12 15:19:10 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 12 Nov 2013 16:19:10 +0100 Subject: [master] 6519159 Change how min/max/default values for parameters are managed. Message-ID: commit 6519159aebf47da9e2b60eba668e6fd831d1257e Author: Poul-Henning Kamp Date: Tue Nov 12 15:15:53 2013 +0000 Change how min/max/default values for parameters are managed. Make min/max values strings, and test-convert them along with the default value during startup, to see that we can. At the same time normalize the strings with the parameters tweak function. List min/max values in .rst doc. param.show will flag default values. (Better the other way around ?) Add a new feature: param.show changed will only list parameters with non-default values (in short format) diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c index b4ec68a..b2691d5 100644 --- a/bin/varnishd/mgt/mgt_param.c +++ b/bin/varnishd/mgt/mgt_param.c @@ -204,34 +204,51 @@ mcf_param_show(struct cli *cli, const char * const *av, void *priv) { int i; const struct parspec *pp; - int lfmt; + int lfmt = 0, chg = 0; + struct vsb *vsb; + vsb = VSB_new_auto(); (void)priv; - if (av[2] == NULL) - lfmt = 0; - else + + if (av[2] != NULL && !strcmp(av[2], "changed")) + chg = 1; + else if (av[2] != NULL) lfmt = 1; + for (i = 0; i < nparspec; i++) { pp = parspecs[i]; - if (av[2] != NULL && - strcmp(pp->name, av[2]) && - strcmp("-l", av[2])) + if (lfmt && strcmp(pp->name, av[2]) && strcmp("-l", av[2])) continue; + + VSB_clear(vsb); + if (pp->func(vsb, pp, NULL)) + VCLI_SetResult(cli, CLIS_PARAM); + AZ(VSB_finish(vsb)); + if (chg && pp->def != NULL && !strcmp(pp->def, VSB_data(vsb))) + continue; + if (lfmt) { VCLI_Out(cli, "%s\n", pp->name); VCLI_Out(cli, "%-*sValue is: ", margin1, " "); } else { VCLI_Out(cli, "%-*s", margin2, pp->name); } - if (pp->func(cli->sb, pp, NULL)) - VCLI_SetResult(cli, CLIS_PARAM); + VCLI_Out(cli, "%s", VSB_data(vsb)); if (pp->units != NULL && *pp->units != '\0') - VCLI_Out(cli, " [%s]\n", pp->units); - else - VCLI_Out(cli, "\n"); - if (av[2] != NULL) { - VCLI_Out(cli, "%-*sDefault is: %s\n\n", + VCLI_Out(cli, " [%s]", pp->units); + if (pp->def != NULL && !strcmp(pp->def, VSB_data(vsb))) + VCLI_Out(cli, " (default)"); + VCLI_Out(cli, "\n"); + if (lfmt) { + VCLI_Out(cli, "%-*sDefault is: %s\n", margin1, "", pp->def); + if (pp->min != NULL) + VCLI_Out(cli, "%-*sMinimum is: %s\n", + margin1, "", pp->min); + if (pp->max != NULL) + VCLI_Out(cli, "%-*sMaximum is: %s\n", + margin1, "", pp->max); + VCLI_Out(cli, "\n"); mcf_wrap(cli, pp->descr); if (pp->flags & OBJ_STICKY) mcf_wrap(cli, OBJ_STICKY_TEXT); @@ -247,16 +264,14 @@ mcf_param_show(struct cli *cli, const char * const *av, void *priv) mcf_wrap(cli, WIZARD_TEXT); if (pp->flags & PROTECTED) mcf_wrap(cli, PROTECTED_TEXT); - if (!lfmt) - return; - else - VCLI_Out(cli, "\n\n"); + VCLI_Out(cli, "\n\n"); } } - if (av[2] != NULL && !lfmt) { + if (av[2] != NULL && !lfmt && !chg) { VCLI_SetResult(cli, CLIS_PARAM); VCLI_Out(cli, "Unknown parameter \"%s\".", av[2]); } + VSB_delete(vsb); } /*-------------------------------------------------------------------- @@ -381,39 +396,60 @@ MCF_AddParams(struct parspec *ps) qsort (parspecs, nparspec, sizeof parspecs[0], mcf_parspec_cmp); } + /*-------------------------------------------------------------------- - * Set defaults for all parameters + * Wash a min/max/default value + */ + +static void +mcf_wash_param(struct cli *cli, const struct parspec *pp, const char **val, + const char *name, struct vsb *vsb) +{ + int err; + + AN(*val); + VSB_clear(vsb); + VSB_printf(vsb, "FAILED to set %s for param %s = %s\n", + name, pp->name, *val); + err = pp->func(vsb, pp, *val); + AZ(VSB_finish(vsb)); + if (err) { + VCLI_Out(cli, "%s", VSB_data(vsb)); + VCLI_SetResult(cli, CLIS_CANT); + return; + } + VSB_clear(vsb); + err = pp->func(vsb, pp, NULL); + AZ(err); + AZ(VSB_finish(vsb)); + if (strcmp(*val, VSB_data(vsb))) { + *val = strdup(VSB_data(vsb)); + AN(*val); + } +} + +/*-------------------------------------------------------------------- + * Wash the min/max/default values, and leave the default set. */ void MCF_InitParams(struct cli *cli) { - const struct parspec *pp; - int i, j, err; + struct parspec *pp; + int i; struct vsb *vsb; - /* - * We try to set the default twice, and only failures the - * second time around are fatal. This allows for trivial - * interdependencies. - */ vsb = VSB_new_auto(); AN(vsb); - for (j = 0; j < 2; j++) { - err = 0; - for (i = 0; i < nparspec; i++) { - pp = parspecs[i]; - VSB_clear(vsb); - VSB_printf(vsb, - "FAILED to set default for param %s = %s\n", - pp->name, pp->def); - err = pp->func(vsb, pp, pp->def); - AZ(VSB_finish(vsb)); - if (err && j) { - VCLI_Out(cli, "%s", VSB_data(vsb)); - VCLI_SetResult(cli, CLIS_CANT); - } - } + for (i = 0; i < nparspec; i++) { + pp = parspecs[i]; + + if (pp->min != NULL) + mcf_wash_param(cli, pp, &pp->min, "Minimum", vsb); + if (pp->max != NULL) + mcf_wash_param(cli, pp, &pp->max, "Maximum", vsb); + AN(pp->def); + mcf_wash_param(cli, pp, &pp->def, "Default", vsb); } VSB_delete(vsb); } @@ -462,6 +498,10 @@ MCF_DumpRstParam(void) if (pp->units != NULL && *pp->units != '\0') printf("\t* Units: %s\n", pp->units); printf("\t* Default: %s\n", pp->def); + if (pp->min != NULL) + printf("\t* Minimum: %s\n", pp->min); + if (pp->max != NULL) + printf("\t* Maximum: %s\n", pp->max); /* * XXX: we should mark the params with one/two flags * XXX: that say if ->min/->max are valid, so we diff --git a/bin/varnishd/mgt/mgt_param.h b/bin/varnishd/mgt/mgt_param.h index 6a9319b..d98b573 100644 --- a/bin/varnishd/mgt/mgt_param.h +++ b/bin/varnishd/mgt/mgt_param.h @@ -36,8 +36,8 @@ struct parspec { const char *name; tweak_t *func; volatile void *priv; - double min; - double max; + const char *min; + const char *max; const char *descr; int flags; #define DELAYED_EFFECT (1<<0) @@ -54,7 +54,7 @@ struct parspec { tweak_t tweak_bool; tweak_t tweak_bytes; tweak_t tweak_bytes_u; -tweak_t tweak_generic_double; +tweak_t tweak_double; tweak_t tweak_group; tweak_t tweak_listen_address; tweak_t tweak_poolparam; @@ -65,8 +65,8 @@ tweak_t tweak_uint; tweak_t tweak_user; tweak_t tweak_waiter; -int tweak_generic_uint(struct vsb *vsb, - volatile unsigned *dest, const char *arg, unsigned min, unsigned max); +int tweak_generic_uint(struct vsb *vsb, volatile unsigned *dest, + const char *arg, const char *min, const char *max); /* mgt_param_tbl.c */ extern struct parspec mgt_parspec[]; diff --git a/bin/varnishd/mgt/mgt_param_bits.c b/bin/varnishd/mgt/mgt_param_bits.c index 86b6f80..270ed1f 100644 --- a/bin/varnishd/mgt/mgt_param_bits.c +++ b/bin/varnishd/mgt/mgt_param_bits.c @@ -235,13 +235,13 @@ tweak_feature(struct vsb *vsb, const struct parspec *par, const char *arg) */ struct parspec VSL_parspec[] = { - { "vsl_mask", tweak_vsl_mask, NULL, 0, 0, + { "vsl_mask", tweak_vsl_mask, NULL, NULL, NULL, "Mask individual VSL messages from being logged.\n" "\tdefault\tSet default value\n" "\nUse +/- prefixe in front of VSL tag name, to mask/unmask " "individual VSL messages.", 0, "default", "" }, - { "debug", tweak_debug, NULL, 0, 0, + { "debug", tweak_debug, NULL, NULL, NULL, "Enable/Disable various kinds of debugging.\n" "\tnone\tDisable all debugging\n\n" "Use +/- prefix to set/reset individual bits:" @@ -249,7 +249,7 @@ struct parspec VSL_parspec[] = { #include "tbl/debug_bits.h" #undef DEBUG_BIT , 0, "none", "" }, - { "feature", tweak_feature, NULL, 0, 0, + { "feature", tweak_feature, NULL, NULL, NULL, "Enable/Disable various minor features.\n" "\tnone\tDisable all features.\n\n" "Use +/- prefix to enable/disable individual feature:" diff --git a/bin/varnishd/mgt/mgt_param_tbl.c b/bin/varnishd/mgt/mgt_param_tbl.c index a8c1e4e..169f521 100644 --- a/bin/varnishd/mgt/mgt_param_tbl.c +++ b/bin/varnishd/mgt/mgt_param_tbl.c @@ -29,7 +29,6 @@ #include "config.h" -#include #include #include "mgt/mgt.h" @@ -52,29 +51,29 @@ */ struct parspec mgt_parspec[] = { - { "user", tweak_user, NULL, 0, 0, + { "user", tweak_user, NULL, NULL, NULL, "The unprivileged user to run as.", MUST_RESTART, "" }, - { "group", tweak_group, NULL, 0, 0, + { "group", tweak_group, NULL, NULL, NULL, "The unprivileged group to run as.", MUST_RESTART, "" }, { "default_ttl", tweak_timeout_double, &mgt_param.default_ttl, - 0, UINT_MAX, + "0", NULL, "The TTL assigned to objects if neither the backend nor " "the VCL code assigns one.", OBJ_STICKY, "20", "seconds" }, { "default_grace", tweak_timeout_double, &mgt_param.default_grace, - 0, UINT_MAX, + "0", NULL, "Default grace period. We will deliver an object " "this long after it has expired, provided another thread " "is attempting to get a new copy.", OBJ_STICKY, "10", "seconds" }, { "default_keep", tweak_timeout_double, &mgt_param.default_keep, - 0, UINT_MAX, + "0", NULL, "Default keep period. We will keep a useless object " "around this long, making it available for conditional " "backend fetches. " @@ -83,19 +82,22 @@ struct parspec mgt_parspec[] = { OBJ_STICKY, "0", "seconds" }, { "workspace_client", - tweak_bytes_u, &mgt_param.workspace_client, 3072, UINT_MAX, + tweak_bytes_u, &mgt_param.workspace_client, + "3072", NULL, "Bytes of HTTP protocol workspace for clients HTTP req/resp." " If larger than 4k, use a multiple of 4k for VM efficiency.", DELAYED_EFFECT, "64k", "bytes" }, { "workspace_backend", - tweak_bytes_u, &mgt_param.workspace_backend, 1024, UINT_MAX, + tweak_bytes_u, &mgt_param.workspace_backend, + "1024", NULL, "Bytes of HTTP protocol workspace for backend HTTP req/resp." " If larger than 4k, use a multiple of 4k for VM efficiency.", DELAYED_EFFECT, "64k", "bytes" }, { "workspace_thread", - tweak_bytes_u, &mgt_param.workspace_thread, 256, 8192, + tweak_bytes_u, &mgt_param.workspace_thread, + "256", "8192", "Bytes of auxillary workspace per thread.\n" "This workspace is used for certain temporary data structures" " during the operation of a worker thread.\n" @@ -107,14 +109,14 @@ struct parspec mgt_parspec[] = { "2048", "bytes" }, { "http_req_hdr_len", tweak_bytes_u, &mgt_param.http_req_hdr_len, - 40, UINT_MAX, + "40", NULL, "Maximum length of any HTTP client request header we will " "allow. The limit is inclusive its continuation lines.", 0, "8k", "bytes" }, { "http_req_size", tweak_bytes_u, &mgt_param.http_req_size, - 256, UINT_MAX, + "256", NULL, "Maximum number of bytes of HTTP client request we will deal " "with. This is a limit on all bytes up to the double blank " "line which ends the HTTP request.\n" @@ -125,14 +127,14 @@ struct parspec mgt_parspec[] = { "32k", "bytes" }, { "http_resp_hdr_len", tweak_bytes_u, &mgt_param.http_resp_hdr_len, - 40, UINT_MAX, + "40", NULL, "Maximum length of any HTTP backend response header we will " "allow. The limit is inclusive its continuation lines.", 0, "8k", "bytes" }, { "http_resp_size", tweak_bytes_u, &mgt_param.http_resp_size, - 256, UINT_MAX, + "256", NULL, "Maximum number of bytes of HTTP backend resonse we will deal " "with. This is a limit on all bytes up to the double blank " "line which ends the HTTP request.\n" @@ -141,7 +143,8 @@ struct parspec mgt_parspec[] = { "limits how much of that the request is allowed to take up.", 0, "32k", "bytes" }, - { "http_max_hdr", tweak_uint, &mgt_param.http_max_hdr, 32, 65535, + { "http_max_hdr", tweak_uint, &mgt_param.http_max_hdr, + "32", "65535", "Maximum number of HTTP header lines we allow in " "{req|resp|bereq|beresp}.http " "(obj.http is autosized to the exact number of headers).\n" @@ -150,7 +153,8 @@ struct parspec mgt_parspec[] = { 0, "64", "header lines" }, { "vsl_buffer", - tweak_bytes_u, &mgt_param.vsl_buffer, 1024, UINT_MAX, + tweak_bytes_u, &mgt_param.vsl_buffer, + "1024", NULL, "Bytes of (req-/backend-)workspace dedicated to buffering" " VSL records.\n" "At a bare minimum, this must be longer than" @@ -162,31 +166,34 @@ struct parspec mgt_parspec[] = { 0, "4k", "bytes" }, { "shm_reclen", - tweak_bytes_u, &mgt_param.shm_reclen, 16, 65535, + tweak_bytes_u, &mgt_param.shm_reclen, + "16", "65535", "Maximum number of bytes in SHM log record.\n" "Maximum is 65535 bytes.", 0, "255", "bytes" }, { "timeout_idle", tweak_timeout_double, &mgt_param.timeout_idle, - 0, UINT_MAX, + "0", NULL, "Idle timeout for client connections.\n" "A connection is considered idle, until we receive" " a non-white-space character on it.", 0, "5", "seconds" }, { "timeout_req", tweak_timeout_double, &mgt_param.timeout_req, - 0, UINT_MAX, + "0", NULL, "Max time to receive clients request header, measured" " from first non-white-space character to double CRNL.", 0, "2", "seconds" }, - { "pipe_timeout", tweak_timeout, &mgt_param.pipe_timeout, 0, 0, + { "pipe_timeout", tweak_timeout, &mgt_param.pipe_timeout, + "0", NULL, "Idle timeout for PIPE sessions. " "If nothing have been received in either direction for " "this many seconds, the session is closed.", 0, "60", "seconds" }, - { "send_timeout", tweak_timeout, &mgt_param.send_timeout, 0, 0, + { "send_timeout", tweak_timeout, &mgt_param.send_timeout, + "0", NULL, "Send timeout for client connections. " "If the HTTP response hasn't been transmitted in this many\n" "seconds the session is closed.\n" @@ -194,7 +201,7 @@ struct parspec mgt_parspec[] = { DELAYED_EFFECT, "600", "seconds" }, { "idle_send_timeout", tweak_timeout, &mgt_param.idle_send_timeout, - 0, 0, + "0", NULL, "Time to wait with no data sent. " "If no data has been transmitted in this many\n" "seconds the session is closed.\n" @@ -203,7 +210,7 @@ struct parspec mgt_parspec[] = { "60", "seconds" }, #ifdef HAVE_TCP_KEEP { "tcp_keepalive_time", tweak_timeout, &mgt_param.tcp_keepalive_time, - 1, 7200, + "1", "7200", "The number of seconds a connection needs to be idle before " "TCP begins sending out keep-alive probes. Note that this " "setting will only take effect when it is less than the " @@ -211,7 +218,7 @@ struct parspec mgt_parspec[] = { EXPERIMENTAL, "600", "seconds" }, { "tcp_keepalive_probes", tweak_uint, &mgt_param.tcp_keepalive_probes, - 1, 100, + "1", "100", "The maximum number of TCP keep-alive probes to send before " "giving up and killing the connection if no response is " "obtained from the other end. Note that this setting will " @@ -219,26 +226,28 @@ struct parspec mgt_parspec[] = { EXPERIMENTAL, "5", "probes" }, { "tcp_keepalive_intvl", tweak_timeout, &mgt_param.tcp_keepalive_intvl, - 1, 100, + "1", "100", "The number of seconds between TCP keep-alive probes. Note " "that this setting will only take effect when it is less than" "the system default.", EXPERIMENTAL, "5", "seconds" }, #endif - { "auto_restart", tweak_bool, &mgt_param.auto_restart, 0, 0, + { "auto_restart", tweak_bool, &mgt_param.auto_restart, + NULL, NULL, "Restart child process automatically if it dies.", 0, "on", "bool" }, { "nuke_limit", - tweak_uint, &mgt_param.nuke_limit, 0, UINT_MAX, + tweak_uint, &mgt_param.nuke_limit, + "0", NULL, "Maximum number of objects we attempt to nuke in order" "to make space for a object body.", EXPERIMENTAL, "50", "allocations" }, { "fetch_chunksize", - tweak_bytes, - &mgt_param.fetch_chunksize, 4 * 1024, UINT_MAX, + tweak_bytes, &mgt_param.fetch_chunksize, + "4096", NULL, "The default chunksize used by fetcher. " "This should be bigger than the majority of objects with " "short TTLs.\n" @@ -247,29 +256,33 @@ struct parspec mgt_parspec[] = { EXPERIMENTAL, "128k", "bytes" }, { "fetch_maxchunksize", - tweak_bytes, - &mgt_param.fetch_maxchunksize, 64 * 1024, UINT_MAX, + tweak_bytes, &mgt_param.fetch_maxchunksize, + "65536", NULL, "The maximum chunksize we attempt to allocate from storage. " "Making this too large may cause delays and storage " "fragmentation.", EXPERIMENTAL, "256m", "bytes" }, - { "accept_filter", tweak_bool, &mgt_param.accept_filter, 0, 0, + { "accept_filter", tweak_bool, &mgt_param.accept_filter, + NULL, NULL, "Enable kernel accept-filters, if supported by the kernel.", MUST_RESTART, "on", "bool" }, - { "listen_address", tweak_listen_address, NULL, 0, 0, + { "listen_address", tweak_listen_address, NULL, + NULL, NULL, "Whitespace separated list of network endpoints where " "Varnish will accept requests.\n" "Possible formats: host, host:port, :port", MUST_RESTART, ":80" }, - { "listen_depth", tweak_uint, &mgt_param.listen_depth, 0, UINT_MAX, + { "listen_depth", tweak_uint, &mgt_param.listen_depth, + "0", NULL, "Listen queue depth.", MUST_RESTART, "1024", "connections" }, { "cli_buffer", - tweak_bytes_u, &mgt_param.cli_buffer, 4096, UINT_MAX, + tweak_bytes_u, &mgt_param.cli_buffer, + "4096", NULL, "Size of buffer for CLI command input." "\nYou may need to increase this if you have big VCL files " "and use the vcl.inline CLI command.\n" @@ -277,24 +290,28 @@ struct parspec mgt_parspec[] = { 0, "8k", "bytes" }, { "cli_limit", - tweak_bytes_u, &mgt_param.cli_limit, 128, 99999999, + tweak_bytes_u, &mgt_param.cli_limit, + "128", "99999999", "Maximum size of CLI response. If the response exceeds" " this limit, the reponse code will be 201 instead of" " 200 and the last line will indicate the truncation.", 0, "48k", "bytes" }, - { "cli_timeout", tweak_timeout, &mgt_param.cli_timeout, 0, 0, + { "cli_timeout", tweak_timeout, &mgt_param.cli_timeout, + "0", NULL, "Timeout for the childs replies to CLI requests from " "the mgt_param.", 0, "10", "seconds" }, - { "ping_interval", tweak_uint, &mgt_param.ping_interval, 0, UINT_MAX, + { "ping_interval", tweak_uint, &mgt_param.ping_interval, + "0", NULL, "Interval between pings from parent to child.\n" "Zero will disable pinging entirely, which makes " "it possible to attach a debugger to the child.", MUST_RESTART, "3", "seconds" }, - { "lru_interval", tweak_timeout, &mgt_param.lru_timeout, 0, 0, + { "lru_interval", tweak_timeout, &mgt_param.lru_timeout, + "0", NULL, "Grace period before object moves on LRU list.\n" "Objects are only moved to the front of the LRU " "list if they have not been moved there already inside " @@ -302,30 +319,33 @@ struct parspec mgt_parspec[] = { "operations necessary for LRU list access.", EXPERIMENTAL, "2", "seconds" }, - { "cc_command", tweak_string, &mgt_cc_cmd, 0, 0, + { "cc_command", tweak_string, &mgt_cc_cmd, + NULL, NULL, "Command used for compiling the C source code to a " "dlopen(3) loadable object. Any occurrence of %s in " "the string will be replaced with the source file name, " "and %o will be replaced with the output file name.", MUST_RELOAD, VCC_CC , NULL }, - { "max_restarts", tweak_uint, &mgt_param.max_restarts, 0, UINT_MAX, + { "max_restarts", tweak_uint, &mgt_param.max_restarts, + "0", NULL, "Upper limit on how many times a request can restart." "\nBe aware that restarts are likely to cause a hit against " "the backend, so don't increase thoughtlessly.", 0, "4", "restarts" }, - { "max_retries", tweak_uint, &mgt_param.max_retries, 0, UINT_MAX, + { "max_retries", tweak_uint, &mgt_param.max_retries, + "0", NULL, "Upper limit on how many times a backend fetch can retry.", 0, "4", "retries" }, - { "max_esi_depth", - tweak_uint, &mgt_param.max_esi_depth, 0, UINT_MAX, + { "max_esi_depth", tweak_uint, &mgt_param.max_esi_depth, + "0", NULL, "Maximum depth of esi:include processing.", 0, "5", "levels" }, - { "connect_timeout", tweak_timeout_double, - &mgt_param.connect_timeout,0, UINT_MAX, + { "connect_timeout", tweak_timeout_double, &mgt_param.connect_timeout, + "0", NULL, "Default connection timeout for backend connections. " "We only try to connect to the backend for this many " "seconds before giving up. " @@ -334,7 +354,8 @@ struct parspec mgt_parspec[] = { 0, "3.5", "s" }, { "first_byte_timeout", tweak_timeout_double, - &mgt_param.first_byte_timeout,0, UINT_MAX, + &mgt_param.first_byte_timeout, + "0", NULL, "Default timeout for receiving first byte from backend. " "We only wait for this many seconds for the first " "byte before giving up. A value of 0 means it will never time " @@ -344,7 +365,8 @@ struct parspec mgt_parspec[] = { 0, "60", "s" }, { "between_bytes_timeout", tweak_timeout_double, - &mgt_param.between_bytes_timeout,0, UINT_MAX, + &mgt_param.between_bytes_timeout, + "0", NULL, "Default timeout between bytes when receiving data from " "backend. " "We only wait for this many seconds between bytes " @@ -354,7 +376,8 @@ struct parspec mgt_parspec[] = { 0, "60", "s" }, { "acceptor_sleep_max", tweak_timeout_double, - &mgt_param.acceptor_sleep_max, 0, 10, + &mgt_param.acceptor_sleep_max, + "0", "10", "If we run out of resources, such as file descriptors or " "worker threads, the acceptor will sleep between accepts.\n" "This parameter limits how long it can sleep between " @@ -362,33 +385,38 @@ struct parspec mgt_parspec[] = { EXPERIMENTAL, "0.050", "s" }, { "acceptor_sleep_incr", tweak_timeout_double, - &mgt_param.acceptor_sleep_incr, 0, 1, + &mgt_param.acceptor_sleep_incr, + "0", "1", "If we run out of resources, such as file descriptors or " "worker threads, the acceptor will sleep between accepts.\n" "This parameter control how much longer we sleep, each time " "we fail to accept a new connection.", EXPERIMENTAL, "0.001", "s" }, - { "acceptor_sleep_decay", tweak_generic_double, - &mgt_param.acceptor_sleep_decay, 0, 1, + { "acceptor_sleep_decay", tweak_double, + &mgt_param.acceptor_sleep_decay, + "0", "1", "If we run out of resources, such as file descriptors or " "worker threads, the acceptor will sleep between accepts.\n" "This parameter (multiplicatively) reduce the sleep duration " "for each succesfull accept. (ie: 0.9 = reduce by 10%)", EXPERIMENTAL, "0.900", "" }, - { "clock_skew", tweak_uint, &mgt_param.clock_skew, 0, UINT_MAX, + { "clock_skew", tweak_uint, &mgt_param.clock_skew, + "0", NULL, "How much clockskew we are willing to accept between the " "backend and our own clock.", 0, "10", "s" }, - { "prefer_ipv6", tweak_bool, &mgt_param.prefer_ipv6, 0, 0, + { "prefer_ipv6", tweak_bool, &mgt_param.prefer_ipv6, + NULL, NULL, "Prefer IPv6 address when connecting to backends which " "have both IPv4 and IPv6 addresses.", 0, "off", "bool" }, { "session_max", tweak_uint, - &mgt_param.max_sess, 1000, UINT_MAX, + &mgt_param.max_sess, + "1000", NULL, "Maximum number of sessions we will allocate from one pool " "before just dropping connections.\n" "This is mostly an anti-DoS measure, and setting it plenty " @@ -397,7 +425,7 @@ struct parspec mgt_parspec[] = { 0, "100000", "sessions" }, { "timeout_linger", tweak_timeout_double, &mgt_param.timeout_linger, - 0, UINT_MAX, + "0", NULL, "How long time the workerthread lingers on an idle session " "before handing it over to the waiter.\n" "When sessions are reused, as much as half of all reuses " @@ -408,38 +436,45 @@ struct parspec mgt_parspec[] = { "more sessions take a detour around the waiter.", EXPERIMENTAL, "0.050", "seconds" }, - { "log_local_address", tweak_bool, &mgt_param.log_local_addr, 0, 0, + { "log_local_address", tweak_bool, &mgt_param.log_local_addr, + NULL, NULL, "Log the local address on the TCP connection in the " "SessionOpen VSL record.\n" "Disabling this saves a getsockname(2) system call " "per TCP connection.", 0, "on", "bool" }, - { "waiter", tweak_waiter, NULL, 0, 0, + { "waiter", tweak_waiter, NULL, + NULL, NULL, "Select the waiter kernel interface.", WIZARD | MUST_RESTART, WAITER_DEFAULT, NULL }, - { "ban_dups", tweak_bool, &mgt_param.ban_dups, 0, 0, + { "ban_dups", tweak_bool, &mgt_param.ban_dups, + NULL, NULL, "Detect and eliminate duplicate bans.", 0, "on", "bool" }, - { "syslog_cli_traffic", tweak_bool, &mgt_param.syslog_cli_traffic, 0, 0, + { "syslog_cli_traffic", tweak_bool, &mgt_param.syslog_cli_traffic, + NULL, NULL, "Log all CLI traffic to syslog(LOG_INFO).", 0, "on", "bool" }, { "ban_lurker_sleep", tweak_timeout_double, - &mgt_param.ban_lurker_sleep, 0, UINT_MAX, + &mgt_param.ban_lurker_sleep, + "0", NULL, "How long time does the ban lurker thread sleeps between " "successful attempts to push the last item up the ban " " list. It always sleeps a second when nothing can be done.\n" "A value of zero disables the ban lurker.", 0, "0.01", "s" }, - { "http_range_support", tweak_bool, &mgt_param.http_range_support, 0, 0, + { "http_range_support", tweak_bool, &mgt_param.http_range_support, + NULL, NULL, "Enable support for HTTP Range headers.", 0, "on", "bool" }, - { "http_gzip_support", tweak_bool, &mgt_param.http_gzip_support, 0, 0, + { "http_gzip_support", tweak_bool, &mgt_param.http_gzip_support, + NULL, NULL, "Enable gzip support. When enabled Varnish request compressed " "objects from the backend and store them compressed. " "If a client does not support gzip encoding Varnish will " @@ -453,18 +488,20 @@ struct parspec mgt_parspec[] = { "Varnish reference.", 0, "on", "bool" }, - { "gzip_level", tweak_uint, &mgt_param.gzip_level, 0, 9, + { "gzip_level", tweak_uint, &mgt_param.gzip_level, + "0", "9", "Gzip compression level: 0=debug, 1=fast, 9=best", 0, "6", ""}, - { "gzip_memlevel", tweak_uint, &mgt_param.gzip_memlevel, 1, 9, + { "gzip_memlevel", tweak_uint, &mgt_param.gzip_memlevel, + "1", "9", "Gzip memory level 1=slow/least, 9=fast/most compression.\n" "Memory impact is 1=1k, 2=2k, ... 9=256k.", 0, "8", ""}, { "gzip_buffer", tweak_bytes_u, &mgt_param.gzip_buffer, - 2048, UINT_MAX, + "2048", NULL, "Size of malloc buffer used for gzip processing.\n" "These buffers are used for in-transit data," " for instance gunzip'ed data being sent to a client." @@ -474,23 +511,27 @@ struct parspec mgt_parspec[] = { EXPERIMENTAL, "32k", "bytes" }, { "shortlived", tweak_timeout_double, - &mgt_param.shortlived, 0, UINT_MAX, + &mgt_param.shortlived, + "0", NULL, "Objects created with TTL shorter than this are always " "put in transient storage.", 0, "10.0", "s" }, { "critbit_cooloff", tweak_timeout_double, - &mgt_param.critbit_cooloff, 60, 254, + &mgt_param.critbit_cooloff, + "60", "254", "How long time the critbit hasher keeps deleted objheads " "on the cooloff list.", WIZARD, "180.0", "s" }, - { "sigsegv_handler", tweak_bool, &mgt_param.sigsegv_handler, 0, 0, - "Install a signal handler which tries to dump debug information " - "on segmentation faults.", + { "sigsegv_handler", tweak_bool, &mgt_param.sigsegv_handler, + NULL, NULL, + "Install a signal handler which tries to dump debug " + "information on segmentation faults.", MUST_RESTART, "off", "bool" }, - { "vcl_dir", tweak_string, &mgt_vcl_dir, 0, 0, + { "vcl_dir", tweak_string, &mgt_vcl_dir, + NULL, NULL, "Directory from which relative VCL filenames (vcl.load and " "include) are opened.", 0, @@ -500,7 +541,8 @@ struct parspec mgt_parspec[] = { ".", #endif NULL }, - { "vmod_dir", tweak_string, &mgt_vmod_dir, 0, 0, + { "vmod_dir", tweak_string, &mgt_vmod_dir, + NULL, NULL, "Directory where VCL modules are to be found.", 0, #ifdef VARNISH_VMOD_DIR @@ -510,17 +552,20 @@ struct parspec mgt_parspec[] = { #endif NULL }, - { "vcc_err_unref", tweak_bool, &mgt_vcc_err_unref, 0, 0, + { "vcc_err_unref", tweak_bool, &mgt_vcc_err_unref, + NULL, NULL, "Unreferenced VCL objects result in error.", 0, "on", "bool" }, - { "vcc_allow_inline_c", tweak_bool, &mgt_vcc_allow_inline_c, 0, 0, + { "vcc_allow_inline_c", tweak_bool, &mgt_vcc_allow_inline_c, + NULL, NULL, "Allow inline C code in VCL.", 0, "off", "bool" }, - { "vcc_unsafe_path", tweak_bool, &mgt_vcc_unsafe_path, 0, 0, + { "vcc_unsafe_path", tweak_bool, &mgt_vcc_unsafe_path, + NULL, NULL, "Allow '/' in vmod & include paths.\n" "Allow 'import ... from ...'.", 0, @@ -528,7 +573,7 @@ struct parspec mgt_parspec[] = { { "pcre_match_limit", tweak_uint, &mgt_param.vre_limits.match, - 1, UINT_MAX, + "1", NULL, "The limit for the number of internal matching function" " calls in a pcre_exec() execution.", 0, @@ -536,14 +581,15 @@ struct parspec mgt_parspec[] = { { "pcre_match_limit_recursion", tweak_uint, &mgt_param.vre_limits.match_recursion, - 1, UINT_MAX, + "1", NULL, "The limit for the number of internal matching function" " recursions in a pcre_exec() execution.", 0, "10000", ""}, { "vsl_space", tweak_bytes, - &mgt_param.vsl_space, 1024*1024, 0, + &mgt_param.vsl_space, + "1M", NULL, "The amount of space to allocate for the VSL fifo buffer" " in the VSM memory segment." " If you make this too small, varnish{ncsa|log} etc will" @@ -553,7 +599,8 @@ struct parspec mgt_parspec[] = { "80M", "bytes"}, { "vsm_space", tweak_bytes, - &mgt_param.vsm_space, 1024*1024, 0, + &mgt_param.vsm_space, + "1M", NULL, "The amount of space to allocate for stats counters" " in the VSM memory segment." " If you make this too small, some counters will be" @@ -563,30 +610,35 @@ struct parspec mgt_parspec[] = { "1M", "bytes"}, { "busyobj_worker_cache", tweak_bool, - &mgt_param.bo_cache, 0, 0, + &mgt_param.bo_cache, + NULL, NULL, "Cache free busyobj per worker thread. " "Disable this if you have very high hitrates and want " "to save the memory of one busyobj per worker thread.", 0, "off", "bool"}, - { "pool_vbc", tweak_poolparam, &mgt_param.vbc_pool, 0, 10000, + { "pool_vbc", tweak_poolparam, &mgt_param.vbc_pool, + NULL, NULL, "Parameters for backend connection memory pool.\n" MEMPOOL_TEXT, 0, "10,100,10", ""}, - { "pool_req", tweak_poolparam, &mgt_param.req_pool, 0, 10000, + { "pool_req", tweak_poolparam, &mgt_param.req_pool, + NULL, NULL, "Parameters for per worker pool request memory pool.\n" MEMPOOL_TEXT, 0, "10,100,10", ""}, - { "pool_sess", tweak_poolparam, &mgt_param.sess_pool, 0, 10000, + { "pool_sess", tweak_poolparam, &mgt_param.sess_pool, + NULL, NULL, "Parameters for per worker pool session memory pool.\n" MEMPOOL_TEXT, 0, "10,100,10", ""}, - { "pool_vbo", tweak_poolparam, &mgt_param.vbo_pool, 0, 10000, + { "pool_vbo", tweak_poolparam, &mgt_param.vbo_pool, + NULL, NULL, "Parameters for backend object fetch memory pool.\n" MEMPOOL_TEXT, 0, diff --git a/bin/varnishd/mgt/mgt_param_tweak.c b/bin/varnishd/mgt/mgt_param_tweak.c index fa2e866..7800db0 100644 --- a/bin/varnishd/mgt/mgt_param_tweak.c +++ b/bin/varnishd/mgt/mgt_param_tweak.c @@ -56,68 +56,77 @@ #include "mgt_cli.h" -/*--------------------------------------------------------------------*/ +/*-------------------------------------------------------------------- + * Generic handling of double typed parameters + */ static int -tweak_generic_timeout(struct vsb *vsb, volatile unsigned *dst, const char *arg) +tweak_generic_double(struct vsb *vsb, volatile double *dest, + const char *arg, const char *min, const char *max, const char *fmt) { - unsigned u; + double u, minv = 0, maxv = 0; + char *p; if (arg != NULL) { - u = strtoul(arg, NULL, 0); - if (u == 0) { - VSB_printf(vsb, "Timeout must be greater than zero\n"); - return (-1); + if (min != NULL) { + p = NULL; + minv = strtod(min, &p); + if (*arg == '\0' || *p != '\0') { + VSB_printf(vsb, "Illegal Min: %s\n", min); + return (-1); + } + } + if (max != NULL) { + p = NULL; + maxv = strtod(max, &p); + if (*arg == '\0' || *p != '\0') { + VSB_printf(vsb, "Illegal Max: %s\n", max); + return (-1); + } } - *dst = u; - } else - VSB_printf(vsb, "%u", *dst); - return (0); -} - -/*--------------------------------------------------------------------*/ - -int -tweak_timeout(struct vsb *vsb, const struct parspec *par, const char *arg) -{ - volatile unsigned *dest; - - dest = par->priv; - return (tweak_generic_timeout(vsb, dest, arg)); -} - -/*--------------------------------------------------------------------*/ - -static int -tweak_generic_timeout_double(struct vsb *vsb, volatile double *dest, - const char *arg, double min, double max) -{ - double u; - char *p; - if (arg != NULL) { p = NULL; u = strtod(arg, &p); if (*arg == '\0' || *p != '\0') { VSB_printf(vsb, "Not a number(%s)\n", arg); return (-1); } - if (u < min) { + if (min != NULL && u < minv) { VSB_printf(vsb, - "Timeout must be greater or equal to %.g\n", min); + "Timeout must be greater or equal to %s\n", min); return (-1); } - if (u > max) { + if (max != NULL && u > maxv) { VSB_printf(vsb, - "Timeout must be less than or equal to %.g\n", max); + "Timeout must be less than or equal to %s\n", max); return (-1); } *dest = u; } else - VSB_printf(vsb, "%.6f", *dest); + VSB_printf(vsb, fmt, *dest); return (0); } +/*--------------------------------------------------------------------*/ + +int +tweak_timeout(struct vsb *vsb, const struct parspec *par, const char *arg) +{ + int i; + double d; + volatile unsigned *dest; + + dest = par->priv; + d = *dest; + i = tweak_generic_double(vsb, &d, arg, par->min, par->max, "%.0f"); + if (!i) { + *dest = (unsigned)ceil(d); + } + return (i); +} + +/*--------------------------------------------------------------------*/ + int tweak_timeout_double(struct vsb *vsb, const struct parspec *par, const char *arg) @@ -125,45 +134,20 @@ tweak_timeout_double(struct vsb *vsb, const struct parspec *par, volatile double *dest; dest = par->priv; - return (tweak_generic_timeout_double(vsb, dest, arg, - par->min, par->max)); + return (tweak_generic_double(vsb, dest, arg, + par->min, par->max, "%.3f")); } /*--------------------------------------------------------------------*/ int -tweak_generic_double(struct vsb *vsb, const struct parspec *par, - const char *arg) +tweak_double(struct vsb *vsb, const struct parspec *par, const char *arg) { volatile double *dest; - char *p; - double u; dest = par->priv; - if (arg != NULL) { - p = NULL; - u = strtod(arg, &p); - if (*p != '\0') { - VSB_printf(vsb, - "Not a number (%s)\n", arg); - return (-1); - } - if (u < par->min) { - VSB_printf(vsb, - "Must be greater or equal to %.g\n", - par->min); - return (-1); - } - if (u > par->max) { - VSB_printf(vsb, - "Must be less than or equal to %.g\n", - par->max); - return (-1); - } - *dest = u; - } else - VSB_printf(vsb, "%f", *dest); - return (0); + return (tweak_generic_double(vsb, dest, arg, + par->min, par->max, "%g")); } /*--------------------------------------------------------------------*/ @@ -214,12 +198,28 @@ tweak_bool(struct vsb *vsb, const struct parspec *par, const char *arg) int tweak_generic_uint(struct vsb *vsb, volatile unsigned *dest, const char *arg, - unsigned min, unsigned max) + const char *min, const char *max) { - unsigned u; + unsigned u, minv = 0, maxv = 0; char *p; if (arg != NULL) { + if (min != NULL) { + p = NULL; + minv = strtoul(min, &p, 0); + if (*arg == '\0' || *p != '\0') { + VSB_printf(vsb, "Illegal Min: %s\n", min); + return (-1); + } + } + if (max != NULL) { + p = NULL; + maxv = strtoul(max, &p, 0); + if (*arg == '\0' || *p != '\0') { + VSB_printf(vsb, "Illegal Max: %s\n", max); + return (-1); + } + } p = NULL; if (!strcasecmp(arg, "unlimited")) u = UINT_MAX; @@ -230,12 +230,12 @@ tweak_generic_uint(struct vsb *vsb, volatile unsigned *dest, const char *arg, return (-1); } } - if (u < min) { - VSB_printf(vsb, "Must be at least %u\n", min); + if (min != NULL && u < minv) { + VSB_printf(vsb, "Must be at least %s\n", min); return (-1); } - if (u > max) { - VSB_printf(vsb, "Must be no more than %u\n", max); + if (max != NULL && u > maxv) { + VSB_printf(vsb, "Must be no more than %s\n", max); return (-1); } *dest = u; @@ -255,9 +255,7 @@ tweak_uint(struct vsb *vsb, const struct parspec *par, const char *arg) volatile unsigned *dest; dest = par->priv; - (void)tweak_generic_uint(vsb, dest, arg, - (uint)par->min, (uint)par->max); - return (0); + return (tweak_generic_uint(vsb, dest, arg, par->min, par->max)); } /*--------------------------------------------------------------------*/ @@ -287,12 +285,26 @@ fmt_bytes(struct vsb *vsb, uintmax_t t) static int tweak_generic_bytes(struct vsb *vsb, volatile ssize_t *dest, const char *arg, - double min, double max) + const char *min, const char *max) { - uintmax_t r; + uintmax_t r, rmin = 0, rmax = 0; const char *p; if (arg != NULL) { + if (min != NULL) { + p = VNUM_2bytes(min, &rmin, 0); + if (p != NULL) { + VSB_printf(vsb, "Invalid min-val: %s\n", min); + return (-1); + } + } + if (max != NULL) { + p = VNUM_2bytes(max, &rmax, 0); + if (p != NULL) { + VSB_printf(vsb, "Invalid max-val: %s\n", max); + return (-1); + } + } p = VNUM_2bytes(arg, &r, 0); if (p != NULL) { VSB_printf(vsb, "Could not convert to bytes.\n"); @@ -303,19 +315,17 @@ tweak_generic_bytes(struct vsb *vsb, volatile ssize_t *dest, const char *arg, } if ((uintmax_t)((ssize_t)r) != r) { fmt_bytes(vsb, r); - VSB_printf(vsb, " is too large for this architecture.\n"); + VSB_printf(vsb, + " is too large for this architecture.\n"); return (-1); } - if (max != 0. && r > max) { - VSB_printf(vsb, "Must be no more than "); - fmt_bytes(vsb, (uintmax_t)max); + if (max != NULL && r > rmax) { + VSB_printf(vsb, "Must be no more than %s\n", max); VSB_printf(vsb, "\n"); return (-1); } - if (r < min) { - VSB_printf(vsb, "Must be at least "); - fmt_bytes(vsb, (uintmax_t)min); - VSB_printf(vsb, "\n"); + if (min != NULL && r < rmin) { + VSB_printf(vsb, "Must be at least %s\n", min); return (-1); } *dest = r; @@ -332,12 +342,10 @@ tweak_bytes(struct vsb *vsb, const struct parspec *par, const char *arg) { volatile ssize_t *dest; - assert(par->min >= 0); dest = par->priv; return (tweak_generic_bytes(vsb, dest, arg, par->min, par->max)); } - /*--------------------------------------------------------------------*/ int @@ -346,8 +354,6 @@ tweak_bytes_u(struct vsb *vsb, const struct parspec *par, const char *arg) volatile unsigned *d1; volatile ssize_t dest; - assert(par->max <= UINT_MAX); - assert(par->min >= 0); d1 = par->priv; dest = *d1; if (tweak_generic_bytes(vsb, &dest, arg, par->min, par->max)) @@ -568,15 +574,15 @@ tweak_poolparam(struct vsb *vsb, const struct parspec *par, const char *arg) } px = *pp; retval = tweak_generic_uint(vsb, &px.min_pool, av[1], - (uint)par->min, (uint)par->max); + par->min, par->max); if (retval) break; retval = tweak_generic_uint(vsb, &px.max_pool, av[2], - (uint)par->min, (uint)par->max); + par->min, par->max); if (retval) break; - retval = tweak_generic_timeout_double(vsb, - &px.max_age, av[3], 0, 1e6); + retval = tweak_generic_double(vsb, + &px.max_age, av[3], "0", "1e6", "%.0f"); if (retval) break; if (px.min_pool > px.max_pool) { diff --git a/bin/varnishd/mgt/mgt_pool.c b/bin/varnishd/mgt/mgt_pool.c index 8b3fe7e..8096ed6 100644 --- a/bin/varnishd/mgt/mgt_pool.c +++ b/bin/varnishd/mgt/mgt_pool.c @@ -42,7 +42,6 @@ #include "config.h" -#include #include #include #include @@ -60,7 +59,8 @@ tweak_thread_pool_min(struct vsb *vsb, const struct parspec *par, { return (tweak_generic_uint(vsb, &mgt_param.wthread_min, arg, - (unsigned)par->min, mgt_param.wthread_max)); + // par->min, mgt_param.wthread_max)); + par->min, NULL)); } /*-------------------------------------------------------------------- @@ -93,14 +93,15 @@ tweak_thread_pool_max(struct vsb *vsb, const struct parspec *par, (void)par; return (tweak_generic_uint(vsb, &mgt_param.wthread_max, arg, - mgt_param.wthread_min, UINT_MAX)); + //mgt_param.wthread_min, NULL)); + NULL, NULL)); } /*--------------------------------------------------------------------*/ struct parspec WRK_parspec[] = { { "thread_pools", tweak_uint, &mgt_param.wthread_pools, - 1, UINT_MAX, + "1", NULL, "Number of worker thread pools.\n" "\n" "Increasing number of worker pools decreases lock " @@ -113,7 +114,8 @@ struct parspec WRK_parspec[] = { "restart to take effect.", EXPERIMENTAL | DELAYED_EFFECT, "2", "pools" }, - { "thread_pool_max", tweak_thread_pool_max, NULL, 10, 0, + { "thread_pool_max", tweak_thread_pool_max, NULL, + "10", NULL, "The maximum number of worker threads in each pool.\n" "\n" "Do not set this higher than you have to, since excess " @@ -123,7 +125,8 @@ struct parspec WRK_parspec[] = { "Minimum is 10 threads.", DELAYED_EFFECT, "5000", "threads" }, - { "thread_pool_min", tweak_thread_pool_min, NULL, 10, 0, + { "thread_pool_min", tweak_thread_pool_min, NULL, + "10", NULL, "The minimum number of worker threads in each pool.\n" "\n" "Increasing this may help ramp up faster from low load " @@ -134,7 +137,7 @@ struct parspec WRK_parspec[] = { "100", "threads" }, { "thread_pool_timeout", tweak_timeout_double, &mgt_param.wthread_timeout, - 10, UINT_MAX, + "10", NULL, "Thread idle threshold.\n" "\n" "Threads in excess of thread_pool_min, which have been idle " @@ -145,7 +148,7 @@ struct parspec WRK_parspec[] = { "300", "seconds" }, { "thread_pool_destroy_delay", tweak_timeout_double, &mgt_param.wthread_destroy_delay, - 0.01, UINT_MAX, + "0.01", NULL, "Wait this long after destroying a thread.\n" "\n" "This controls the decay of thread pools when idle(-ish).\n" @@ -155,7 +158,7 @@ struct parspec WRK_parspec[] = { "1", "seconds" }, { "thread_pool_add_delay", tweak_timeout_double, &mgt_param.wthread_add_delay, - 0, UINT_MAX, + "0", NULL, "Wait at least this long after creating a thread.\n" "\n" "Some (buggy) systems may need a short (sub-second) " @@ -168,7 +171,7 @@ struct parspec WRK_parspec[] = { "0", "seconds" }, { "thread_pool_fail_delay", tweak_timeout_double, &mgt_param.wthread_fail_delay, - 10e-3, UINT_MAX, + "10e-3", NULL, "Wait at least this long after a failed thread creation " "before trying to create another thread.\n" "\n" @@ -186,7 +189,8 @@ struct parspec WRK_parspec[] = { EXPERIMENTAL, "0.2", "seconds" }, { "thread_stats_rate", - tweak_uint, &mgt_param.wthread_stats_rate, 0, UINT_MAX, + tweak_uint, &mgt_param.wthread_stats_rate, + "0", NULL, "Worker threads accumulate statistics, and dump these into " "the global stats counters if the lock is free when they " "finish a request.\n" @@ -196,7 +200,7 @@ struct parspec WRK_parspec[] = { EXPERIMENTAL, "10", "requests" }, { "thread_queue_limit", tweak_uint, &mgt_param.wthread_queue_limit, - 0, UINT_MAX, + "0", NULL, "Permitted queue length per thread-pool.\n" "\n" "This sets the number of requests we will queue, waiting " @@ -204,7 +208,8 @@ struct parspec WRK_parspec[] = { "be dropped instead of queued.", EXPERIMENTAL, "20", "" }, - { "rush_exponent", tweak_uint, &mgt_param.rush_exponent, 2, UINT_MAX, + { "rush_exponent", tweak_uint, &mgt_param.rush_exponent, + "2", NULL, "How many parked request we start for each completed " "request on the object.\n" "NB: Even with the implict delay of delivery, " @@ -213,7 +218,8 @@ struct parspec WRK_parspec[] = { EXPERIMENTAL, "3", "requests per request" }, { "thread_pool_stack", - tweak_stack_size, &mgt_param.wthread_stacksize, 0, UINT_MAX, + tweak_stack_size, &mgt_param.wthread_stacksize, + "0", NULL, "Worker thread stack size.\n" "This is likely rounded up to a multiple of 4k by the kernel.\n" "The kernel/OS has a lower limit which will be enforced.", diff --git a/doc/sphinx/reference/params.rst b/doc/sphinx/reference/params.rst index 98d563e..e4e3e48 100644 --- a/doc/sphinx/reference/params.rst +++ b/doc/sphinx/reference/params.rst @@ -15,7 +15,9 @@ Enable kernel accept-filters, if supported by the kernel. acceptor_sleep_decay ~~~~~~~~~~~~~~~~~~~~ - * Default: 0.900 + * Default: 0.9 + * Minimum: 0 + * Maximum: 1 * Flags: experimental If we run out of resources, such as file descriptors or worker threads, the acceptor will sleep between accepts. @@ -26,7 +28,9 @@ This parameter (multiplicatively) reduce the sleep duration for each succesfull acceptor_sleep_incr ~~~~~~~~~~~~~~~~~~~ * Units: s - * Default: 0.001 + * Default: 0.001000 + * Minimum: 0.000000 + * Maximum: 1.000000 * Flags: experimental If we run out of resources, such as file descriptors or worker threads, the acceptor will sleep between accepts. @@ -37,7 +41,9 @@ This parameter control how much longer we sleep, each time we fail to accept a n acceptor_sleep_max ~~~~~~~~~~~~~~~~~~ * Units: s - * Default: 0.050 + * Default: 0.050000 + * Minimum: 0.000000 + * Maximum: 10.000000 * Flags: experimental If we run out of resources, such as file descriptors or worker threads, the acceptor will sleep between accepts. @@ -66,7 +72,8 @@ Detect and eliminate duplicate bans. ban_lurker_sleep ~~~~~~~~~~~~~~~~ * Units: s - * Default: 0.01 + * Default: 0.010000 + * Minimum: 0.000000 How long time does the ban lurker thread sleeps between successful attempts to push the last item up the ban list. It always sleeps a second when nothing can be done. A value of zero disables the ban lurker. @@ -76,7 +83,8 @@ A value of zero disables the ban lurker. between_bytes_timeout ~~~~~~~~~~~~~~~~~~~~~ * Units: s - * Default: 60 + * Default: 60.000000 + * Minimum: 0.000000 Default timeout between bytes when receiving data from backend. We only wait for this many seconds between bytes before giving up. A value of 0 means it will never time out. VCL can override this default value for each backend request and backend request. This parameter does not apply to pipe. @@ -93,7 +101,7 @@ Cache free busyobj per worker thread. Disable this if you have very high hitrate cc_command ~~~~~~~~~~ - * Default: exec clang -std=gnu99 -Qunused-arguments -D_THREAD_SAFE -pthread -fpic -shared -Wl,-x -o %o %s + * Default: "exec clang -std=gnu99 -Qunused-arguments -D_THREAD_SAFE -pthread -fpic -shared -Wl,-x -o %o %s" * Flags: must_reload Command used for compiling the C source code to a dlopen(3) loadable object. Any occurrence of %s in the string will be replaced with the source file name, and %o will be replaced with the output file name. @@ -104,6 +112,7 @@ cli_buffer ~~~~~~~~~~ * Units: bytes * Default: 8k + * Minimum: 4k Size of buffer for CLI command input. You may need to increase this if you have big VCL files and use the vcl.inline CLI command. @@ -115,6 +124,8 @@ cli_limit ~~~~~~~~~ * Units: bytes * Default: 48k + * Minimum: 128b + * Maximum: 99999999b Maximum size of CLI response. If the response exceeds this limit, the reponse code will be 201 instead of 200 and the last line will indicate the truncation. @@ -124,6 +135,7 @@ cli_timeout ~~~~~~~~~~~ * Units: seconds * Default: 10 + * Minimum: 0 Timeout for the childs replies to CLI requests from the mgt_param. @@ -133,6 +145,7 @@ clock_skew ~~~~~~~~~~ * Units: s * Default: 10 + * Minimum: 0 How much clockskew we are willing to accept between the backend and our own clock. @@ -141,7 +154,8 @@ How much clockskew we are willing to accept between the backend and our own cloc connect_timeout ~~~~~~~~~~~~~~~ * Units: s - * Default: 3.5 + * Default: 3.500000 + * Minimum: 0.000000 Default connection timeout for backend connections. We only try to connect to the backend for this many seconds before giving up. VCL can override this default value for each backend and backend request. @@ -150,7 +164,9 @@ Default connection timeout for backend connections. We only try to connect to th critbit_cooloff ~~~~~~~~~~~~~~~ * Units: s - * Default: 180.0 + * Default: 180.000000 + * Minimum: 60.000000 + * Maximum: 254.000000 * Flags: wizard How long time the critbit hasher keeps deleted objheads on the cooloff list. @@ -200,7 +216,8 @@ Use +/- prefix to set/reset individual bits: default_grace ~~~~~~~~~~~~~ * Units: seconds - * Default: 10 + * Default: 10.000000 + * Minimum: 0.000000 * Flags: Default grace period. We will deliver an object this long after it has expired, provided another thread is attempting to get a new copy. @@ -210,7 +227,8 @@ Default grace period. We will deliver an object this long after it has expired, default_keep ~~~~~~~~~~~~ * Units: seconds - * Default: 0 + * Default: 0.000000 + * Minimum: 0.000000 * Flags: Default keep period. We will keep a useless object around this long, making it available for conditional backend fetches. That means that the object will be removed from the cache at the end of ttl+grace+keep. @@ -220,7 +238,8 @@ Default keep period. We will keep a useless object around this long, making it default_ttl ~~~~~~~~~~~ * Units: seconds - * Default: 120 + * Default: 20.000000 + * Minimum: 0.000000 * Flags: The TTL assigned to objects if neither the backend nor the VCL code assigns one. @@ -265,6 +284,7 @@ fetch_chunksize ~~~~~~~~~~~~~~~ * Units: bytes * Default: 128k + * Minimum: 4k * Flags: experimental The default chunksize used by fetcher. This should be bigger than the majority of objects with short TTLs. @@ -275,7 +295,8 @@ Internal limits in the storage_file module makes increases above 128kb a dubious fetch_maxchunksize ~~~~~~~~~~~~~~~~~~ * Units: bytes - * Default: 256m + * Default: 0.25G + * Minimum: 64k * Flags: experimental The maximum chunksize we attempt to allocate from storage. Making this too large may cause delays and storage fragmentation. @@ -285,7 +306,8 @@ The maximum chunksize we attempt to allocate from storage. Making this too large first_byte_timeout ~~~~~~~~~~~~~~~~~~ * Units: s - * Default: 60 + * Default: 60.000000 + * Minimum: 0.000000 Default timeout for receiving first byte from backend. We only wait for this many seconds for the first byte before giving up. A value of 0 means it will never time out. VCL can override this default value for each backend and backend request. This parameter does not apply to pipe. @@ -293,7 +315,7 @@ Default timeout for receiving first byte from backend. We only wait for this man group ~~~~~ - * Default: nogroup + * Default: nogroup (65533) * Flags: must_restart The unprivileged group to run as. @@ -304,6 +326,7 @@ gzip_buffer ~~~~~~~~~~~ * Units: bytes * Default: 32k + * Minimum: 2k * Flags: experimental Size of malloc buffer used for gzip processing. @@ -314,6 +337,8 @@ These buffers are used for in-transit data, for instance gunzip'ed data being se gzip_level ~~~~~~~~~~ * Default: 6 + * Minimum: 0 + * Maximum: 9 Gzip compression level: 0=debug, 1=fast, 9=best @@ -322,6 +347,8 @@ Gzip compression level: 0=debug, 1=fast, 9=best gzip_memlevel ~~~~~~~~~~~~~ * Default: 8 + * Minimum: 1 + * Maximum: 9 Gzip memory level 1=slow/least, 9=fast/most compression. Memory impact is 1=1k, 2=2k, ... 9=256k. @@ -344,6 +371,8 @@ http_max_hdr ~~~~~~~~~~~~ * Units: header lines * Default: 64 + * Minimum: 32 + * Maximum: 65535 Maximum number of HTTP header lines we allow in {req|resp|bereq|beresp}.http (obj.http is autosized to the exact number of headers). Cheap, ~20 bytes, in terms of workspace memory. @@ -364,6 +393,7 @@ http_req_hdr_len ~~~~~~~~~~~~~~~~ * Units: bytes * Default: 8k + * Minimum: 40b Maximum length of any HTTP client request header we will allow. The limit is inclusive its continuation lines. @@ -373,6 +403,7 @@ http_req_size ~~~~~~~~~~~~~ * Units: bytes * Default: 32k + * Minimum: 0.25k Maximum number of bytes of HTTP client request we will deal with. This is a limit on all bytes up to the double blank line which ends the HTTP request. The memory for the request is allocated from the client workspace (param: workspace_client) and this parameter limits how much of that the request is allowed to take up. @@ -383,6 +414,7 @@ http_resp_hdr_len ~~~~~~~~~~~~~~~~~ * Units: bytes * Default: 8k + * Minimum: 40b Maximum length of any HTTP backend response header we will allow. The limit is inclusive its continuation lines. @@ -392,6 +424,7 @@ http_resp_size ~~~~~~~~~~~~~~ * Units: bytes * Default: 32k + * Minimum: 0.25k Maximum number of bytes of HTTP backend resonse we will deal with. This is a limit on all bytes up to the double blank line which ends the HTTP request. The memory for the request is allocated from the worker workspace (param: thread_pool_workspace) and this parameter limits how much of that the request is allowed to take up. @@ -402,6 +435,7 @@ idle_send_timeout ~~~~~~~~~~~~~~~~~ * Units: seconds * Default: 60 + * Minimum: 0 * Flags: delayed Time to wait with no data sent. If no data has been transmitted in this many @@ -424,6 +458,7 @@ listen_depth ~~~~~~~~~~~~ * Units: connections * Default: 1024 + * Minimum: 0 * Flags: must_restart Listen queue depth. @@ -444,6 +479,7 @@ lru_interval ~~~~~~~~~~~~ * Units: seconds * Default: 2 + * Minimum: 0 * Flags: experimental Grace period before object moves on LRU list. @@ -455,6 +491,7 @@ max_esi_depth ~~~~~~~~~~~~~ * Units: levels * Default: 5 + * Minimum: 0 Maximum depth of esi:include processing. @@ -464,6 +501,7 @@ max_restarts ~~~~~~~~~~~~ * Units: restarts * Default: 4 + * Minimum: 0 Upper limit on how many times a request can restart. Be aware that restarts are likely to cause a hit against the backend, so don't increase thoughtlessly. @@ -474,6 +512,7 @@ max_retries ~~~~~~~~~~~ * Units: retries * Default: 4 + * Minimum: 0 Upper limit on how many times a backend fetch can retry. @@ -483,6 +522,7 @@ nuke_limit ~~~~~~~~~~ * Units: allocations * Default: 50 + * Minimum: 0 * Flags: experimental Maximum number of objects we attempt to nuke in orderto make space for a object body. @@ -492,6 +532,7 @@ Maximum number of objects we attempt to nuke in orderto make space for a object pcre_match_limit ~~~~~~~~~~~~~~~~ * Default: 10000 + * Minimum: 1 The limit for the number of internal matching function calls in a pcre_exec() execution. @@ -500,6 +541,7 @@ The limit for the number of internal matching function calls in a pcre_exec() e pcre_match_limit_recursion ~~~~~~~~~~~~~~~~~~~~~~~~~~ * Default: 10000 + * Minimum: 1 The limit for the number of internal matching function recursions in a pcre_exec() execution. @@ -509,6 +551,7 @@ ping_interval ~~~~~~~~~~~~~ * Units: seconds * Default: 3 + * Minimum: 0 * Flags: must_restart Interval between pings from parent to child. @@ -520,6 +563,7 @@ pipe_timeout ~~~~~~~~~~~~ * Units: seconds * Default: 60 + * Minimum: 0 Idle timeout for PIPE sessions. If nothing have been received in either direction for this many seconds, the session is closed. @@ -610,6 +654,7 @@ rush_exponent ~~~~~~~~~~~~~ * Units: requests per request * Default: 3 + * Minimum: 2 * Flags: experimental How many parked request we start for each completed request on the object. @@ -621,6 +666,7 @@ send_timeout ~~~~~~~~~~~~ * Units: seconds * Default: 600 + * Minimum: 0 * Flags: delayed Send timeout for client connections. If the HTTP response hasn't been transmitted in this many @@ -633,6 +679,7 @@ session_max ~~~~~~~~~~~ * Units: sessions * Default: 100000 + * Minimum: 1000 Maximum number of sessions we will allocate from one pool before just dropping connections. This is mostly an anti-DoS measure, and setting it plenty high should not hurt, as long as you have the memory for it. @@ -642,7 +689,9 @@ This is mostly an anti-DoS measure, and setting it plenty high should not hurt, shm_reclen ~~~~~~~~~~ * Units: bytes - * Default: 255 + * Default: 255b + * Minimum: 16b + * Maximum: 65535b Maximum number of bytes in SHM log record. Maximum is 65535 bytes. @@ -652,7 +701,8 @@ Maximum is 65535 bytes. shortlived ~~~~~~~~~~ * Units: s - * Default: 10.0 + * Default: 10.000000 + * Minimum: 0.000000 Objects created with TTL shorter than this are always put in transient storage. @@ -681,6 +731,8 @@ tcp_keepalive_intvl ~~~~~~~~~~~~~~~~~~~ * Units: seconds * Default: 5 + * Minimum: 1 + * Maximum: 100 * Flags: experimental The number of seconds between TCP keep-alive probes. Note that this setting will only take effect when it is less thanthe system default. @@ -691,6 +743,8 @@ tcp_keepalive_probes ~~~~~~~~~~~~~~~~~~~~ * Units: probes * Default: 5 + * Minimum: 1 + * Maximum: 100 * Flags: experimental The maximum number of TCP keep-alive probes to send before giving up and killing the connection if no response is obtained from the other end. Note that this setting will only take effect when it is less than the system default. @@ -701,6 +755,8 @@ tcp_keepalive_time ~~~~~~~~~~~~~~~~~~ * Units: seconds * Default: 600 + * Minimum: 1 + * Maximum: 7200 * Flags: experimental The number of seconds a connection needs to be idle before TCP begins sending out keep-alive probes. Note that this setting will only take effect when it is less than the system default. @@ -710,7 +766,8 @@ The number of seconds a connection needs to be idle before TCP begins sending ou thread_pool_add_delay ~~~~~~~~~~~~~~~~~~~~~ * Units: seconds - * Default: 0 + * Default: 0.000000 + * Minimum: 0.000000 * Flags: experimental Wait at least this long after creating a thread. @@ -725,7 +782,8 @@ Setting this too high results in insuffient worker threads. thread_pool_destroy_delay ~~~~~~~~~~~~~~~~~~~~~~~~~ * Units: seconds - * Default: 1 + * Default: 1.000000 + * Minimum: 0.010000 * Flags: delayed, experimental Wait this long after destroying a thread. @@ -739,7 +797,8 @@ Minimum is 0.01 second. thread_pool_fail_delay ~~~~~~~~~~~~~~~~~~~~~~ * Units: seconds - * Default: 0.2 + * Default: 0.200000 + * Minimum: 0.010000 * Flags: experimental Wait at least this long after a failed thread creation before trying to create another thread. @@ -756,6 +815,7 @@ thread_pool_max ~~~~~~~~~~~~~~~ * Units: threads * Default: 5000 + * Minimum: 10 * Flags: delayed The maximum number of worker threads in each pool. @@ -770,6 +830,7 @@ thread_pool_min ~~~~~~~~~~~~~~~ * Units: threads * Default: 100 + * Minimum: 10 * Flags: delayed The minimum number of worker threads in each pool. @@ -784,6 +845,7 @@ thread_pool_stack ~~~~~~~~~~~~~~~~~ * Units: bytes * Default: 48k + * Minimum: 2k * Flags: experimental Worker thread stack size. @@ -795,7 +857,8 @@ The kernel/OS has a lower limit which will be enforced. thread_pool_timeout ~~~~~~~~~~~~~~~~~~~ * Units: seconds - * Default: 300 + * Default: 300.000000 + * Minimum: 10.000000 * Flags: delayed, experimental Thread idle threshold. @@ -810,6 +873,7 @@ thread_pools ~~~~~~~~~~~~ * Units: pools * Default: 2 + * Minimum: 1 * Flags: delayed, experimental Number of worker thread pools. @@ -825,6 +889,7 @@ Can be increased on the fly, but decreases require a restart to take effect. thread_queue_limit ~~~~~~~~~~~~~~~~~~ * Default: 20 + * Minimum: 0 * Flags: experimental Permitted queue length per thread-pool. @@ -837,6 +902,7 @@ thread_stats_rate ~~~~~~~~~~~~~~~~~ * Units: requests * Default: 10 + * Minimum: 0 * Flags: experimental Worker threads accumulate statistics, and dump these into the global stats counters if the lock is free when they finish a request. @@ -847,7 +913,8 @@ This parameters defines the maximum number of requests a worker thread may handl timeout_idle ~~~~~~~~~~~~ * Units: seconds - * Default: 5 + * Default: 5.000000 + * Minimum: 0.000000 Idle timeout for client connections. A connection is considered idle, until we receive a non-white-space character on it. @@ -857,7 +924,8 @@ A connection is considered idle, until we receive a non-white-space character on timeout_linger ~~~~~~~~~~~~~~ * Units: seconds - * Default: 0.050 + * Default: 0.050000 + * Minimum: 0.000000 * Flags: experimental How long time the workerthread lingers on an idle session before handing it over to the waiter. @@ -869,7 +937,8 @@ Setting this too high results in worker threads not doing anything for their kee timeout_req ~~~~~~~~~~~ * Units: seconds - * Default: 2 + * Default: 2.000000 + * Minimum: 0.000000 Max time to receive clients request header, measured from first non-white-space character to double CRNL. @@ -877,7 +946,7 @@ Max time to receive clients request header, measured from first non-white-space user ~~~~ - * Default: nobody + * Default: nobody (65534) * Flags: must_restart The unprivileged user to run as. @@ -932,6 +1001,7 @@ vsl_buffer ~~~~~~~~~~ * Units: bytes * Default: 4k + * Minimum: 1k Bytes of (req-/backend-)workspace dedicated to buffering VSL records. At a bare minimum, this must be longer than the longest HTTP header to be logged. @@ -942,7 +1012,7 @@ Minimum is 1k bytes. vsl_mask ~~~~~~~~ - * Default: default + * Default: -VCL_trace,-WorkThread,-Hash Mask individual VSL messages from being logged. @@ -957,6 +1027,7 @@ vsl_space ~~~~~~~~~ * Units: bytes * Default: 80M + * Minimum: 1M * Flags: must_restart The amount of space to allocate for the VSL fifo buffer in the VSM memory segment. If you make this too small, varnish{ncsa|log} etc will not be able to keep up. Making it too large just costs memory resources. @@ -967,6 +1038,7 @@ vsm_space ~~~~~~~~~ * Units: bytes * Default: 1M + * Minimum: 1M * Flags: must_restart The amount of space to allocate for stats counters in the VSM memory segment. If you make this too small, some counters will be invisible. Making it too large just costs memory resources. @@ -975,7 +1047,7 @@ The amount of space to allocate for stats counters in the VSM memory segment. I waiter ~~~~~~ - * Default: platform dependent + * Default: kqueue (possible values: kqueue, poll) * Flags: must_restart, wizard Select the waiter kernel interface. @@ -986,6 +1058,7 @@ workspace_backend ~~~~~~~~~~~~~~~~~ * Units: bytes * Default: 64k + * Minimum: 1k * Flags: delayed Bytes of HTTP protocol workspace for backend HTTP req/resp. If larger than 4k, use a multiple of 4k for VM efficiency. @@ -996,6 +1069,7 @@ workspace_client ~~~~~~~~~~~~~~~~ * Units: bytes * Default: 64k + * Minimum: 3k * Flags: delayed Bytes of HTTP protocol workspace for clients HTTP req/resp. If larger than 4k, use a multiple of 4k for VM efficiency. @@ -1005,7 +1079,9 @@ Bytes of HTTP protocol workspace for clients HTTP req/resp. If larger than 4k, workspace_thread ~~~~~~~~~~~~~~~~ * Units: bytes - * Default: 2048 + * Default: 2k + * Minimum: 0.25k + * Maximum: 8k * Flags: delayed Bytes of auxillary workspace per thread. From phk at varnish-cache.org Tue Nov 12 15:30:14 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 12 Nov 2013 16:30:14 +0100 Subject: [master] ea2c5b4 Comment out auto-generation of .rst docs from varnishd until we find out how that can work. Message-ID: commit ea2c5b4d2104133341d7fd6ecb4865dac6d45bee Author: Poul-Henning Kamp Date: Tue Nov 12 15:29:44 2013 +0000 Comment out auto-generation of .rst docs from varnishd until we find out how that can work. diff --git a/doc/sphinx/Makefile.am b/doc/sphinx/Makefile.am index 48e752b..217d49f 100644 --- a/doc/sphinx/Makefile.am +++ b/doc/sphinx/Makefile.am @@ -176,5 +176,6 @@ dist-hook: distclean-local: rm -rf $(BUILDDIR) -reference/params.rst: $(top_builddir)/bin/varnishd/varnishd - $(top_builddir)/bin/varnishd/varnishd -x dumprstparam > reference/params.rst +# XXX: doesn't work... +#reference/params.rst: $(top_builddir)/bin/varnishd/varnishd +# $(top_builddir)/bin/varnishd/varnishd -x dumprstparam > reference/params.rst From phk at varnish-cache.org Tue Nov 12 16:11:42 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 12 Nov 2013 17:11:42 +0100 Subject: [master] 6083540 Minor polish and a test-case to get out in the corners of param-tweaking Message-ID: commit 60835401b77a9d7b0570c486d707602219edd9e2 Author: Poul-Henning Kamp Date: Tue Nov 12 16:11:20 2013 +0000 Minor polish and a test-case to get out in the corners of param-tweaking diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c index b2691d5..8f90bd2 100644 --- a/bin/varnishd/mgt/mgt_param.c +++ b/bin/varnishd/mgt/mgt_param.c @@ -330,14 +330,14 @@ MCF_ParamSet(struct cli *cli, const char *param, const char *val) *heritage.param = mgt_param; if (cli->result != CLIS_OK) { - VCLI_Out(cli, "(attempting to set param %s to %s)\n", + VCLI_Out(cli, "\n(attempting to set param %s to %s)", pp->name, val); } else if (child_pid >= 0 && pp->flags & MUST_RESTART) { - VCLI_Out(cli, "Change will take effect" - " when child is restarted"); + VCLI_Out(cli, + "\nChange will take effect when child is restarted"); } else if (pp->flags & MUST_RELOAD) { - VCLI_Out(cli, "Change will take effect" - " when VCL script is reloaded"); + VCLI_Out(cli, + "\nChange will take effect when VCL script is reloaded"); } } diff --git a/bin/varnishd/mgt/mgt_param_tweak.c b/bin/varnishd/mgt/mgt_param_tweak.c index 7800db0..4b22bc3 100644 --- a/bin/varnishd/mgt/mgt_param_tweak.c +++ b/bin/varnishd/mgt/mgt_param_tweak.c @@ -93,12 +93,12 @@ tweak_generic_double(struct vsb *vsb, volatile double *dest, } if (min != NULL && u < minv) { VSB_printf(vsb, - "Timeout must be greater or equal to %s\n", min); + "Must be greater or equal to %s\n", min); return (-1); } if (max != NULL && u > maxv) { VSB_printf(vsb, - "Timeout must be less than or equal to %s\n", max); + "Must be less than or equal to %s\n", max); return (-1); } *dest = u; diff --git a/bin/varnishtest/tests/b00042.vtc b/bin/varnishtest/tests/b00042.vtc new file mode 100644 index 0000000..1a6f947 --- /dev/null +++ b/bin/varnishtest/tests/b00042.vtc @@ -0,0 +1,28 @@ +varnishtest "param edge cases" + +varnish v1 -vcl {backend foo {.host = "127.0.0.1";}} -start + + +varnish v1 -clierr "106" "param.set default_ttl -1" +varnish v1 -clierr "106" "param.set acceptor_sleep_max 20" +varnish v1 -clierr "200" "param.set prefer_ipv6 off" +varnish v1 -clierr "200" "param.set prefer_ipv6 no" +varnish v1 -clierr "200" "param.set prefer_ipv6 disable" +varnish v1 -clierr "200" "param.set prefer_ipv6 false" +varnish v1 -clierr "200" "param.set prefer_ipv6 on" +varnish v1 -clierr "200" "param.set prefer_ipv6 yes" +varnish v1 -clierr "200" "param.set prefer_ipv6 enable" +varnish v1 -clierr "200" "param.set prefer_ipv6 true" +varnish v1 -clierr "106" "param.set prefer_ipv6 foobar" +varnish v1 -clierr "106" "param.set http_max_hdr 0" +varnish v1 -clierr "106" "param.set http_max_hdr 1000000" +varnish v1 -clierr "106" "param.set workspace_thread 1b" +varnish v1 -clierr "106" "param.set workspace_thread 1b" +varnish v1 -clierr "106" "param.set workspace_thread 1x" +varnish v1 -clierr "106" "param.set workspace_thread x" +varnish v1 -clierr "106" "param.set user ///" +varnish v1 -clierr "106" "param.set user ///" +varnish v1 -clierr "106" {param.set listen_address ""} +varnish v1 -clierr "106" {param.set listen_address ",,"} +varnish v1 -clierr "106" {param.set listen_address "\""} +varnish v1 -clierr "106" {param.set pool_sess "\""} From phk at varnish-cache.org Tue Nov 12 16:20:04 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 12 Nov 2013 17:20:04 +0100 Subject: [master] bea84b3 Forgot to list new .h files. Message-ID: commit bea84b35ed6c80106ce5e1bd16e01b89a69b8376 Author: Poul-Henning Kamp Date: Tue Nov 12 16:19:43 2013 +0000 Forgot to list new .h files. diff --git a/bin/varnishtest/Makefile.am b/bin/varnishtest/Makefile.am index 2ea62f5..b51d822 100644 --- a/bin/varnishtest/Makefile.am +++ b/bin/varnishtest/Makefile.am @@ -24,6 +24,8 @@ dist_man_MANS = varnishtest.1 varnishtest_SOURCES = \ vtc.c \ vtc.h \ + vmods.h \ + programs.h \ vtc_client.c \ vtc_http.c \ vtc_main.c \ From phk at varnish-cache.org Tue Nov 12 18:11:44 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 12 Nov 2013 19:11:44 +0100 Subject: [master] 9008a85 More parameter code polishing. Message-ID: commit 9008a85aedf337a8cebc7e61a85e4b8dfa8ebf01 Author: Poul-Henning Kamp Date: Tue Nov 12 18:11:31 2013 +0000 More parameter code polishing. diff --git a/bin/varnishd/mgt/mgt.h b/bin/varnishd/mgt/mgt.h index eb729de..a7ca900 100644 --- a/bin/varnishd/mgt/mgt.h +++ b/bin/varnishd/mgt/mgt.h @@ -75,6 +75,8 @@ const void *pick(const struct choice *cp, const char *which, const char *kind); void MCF_InitParams(struct cli *); void MCF_CollectParams(void); void MCF_SetDefault(const char *param, const char *def); +void MCF_SetMinimum(const char *param, const char *def); +void MCF_SetMaximum(const char *param, const char *def); void MCF_ParamSet(struct cli *, const char *param, const char *val); void MCF_ParamProtect(struct cli *, const char *arg); void MCF_DumpRstParam(void); diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index 820552f..d8299cc 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -339,6 +339,42 @@ make_secret(const char *dirname) /*--------------------------------------------------------------------*/ +static char stackmin[20]; + +static void +init_params(struct cli *cli) +{ + ssize_t low; + + MCF_CollectParams(); + + /* If we have nobody/nogroup, use them as defaults */ + if (getpwnam("nobody") != NULL) + MCF_SetDefault("user", "nobody"); + if (getgrnam("nogroup") != NULL) + MCF_SetDefault("group", "nogroup"); + + if (sizeof(void *) < 8) { + /* + * Adjust default parameters for 32 bit systems to conserve + * VM space. + */ + MCF_SetDefault("workspace_client", "24k"); + MCF_SetDefault("workspace_backend", "16k"); + MCF_SetDefault("http_resp_size", "8k"); + MCF_SetDefault("http_req_size", "12k"); + MCF_SetDefault("gzip_buffer", "4k"); + } + + low = sysconf(_SC_THREAD_STACK_MIN); + bprintf(stackmin, "%jd", (intmax_t)low); + MCF_SetMinimum("thread_pool_stack", stackmin); + + MCF_InitParams(cli); +} + +/*--------------------------------------------------------------------*/ + int main(int argc, char * const *argv) { @@ -388,6 +424,7 @@ main(int argc, char * const *argv) /* for ASSERT_MGT() */ mgt_pid = getpid(); + /* * Run in UTC timezone, on the off-chance that this operating * system does not have a timegm() function, and translates @@ -415,28 +452,7 @@ main(int argc, char * const *argv) VTAILQ_INIT(&heritage.socks); - MCF_CollectParams(); - - /* If we have nobody/nogroup, use them as defaults */ - if (getpwnam("nobody") != NULL) - MCF_SetDefault("user", "nobody"); - if (getgrnam("nogroup") != NULL) - MCF_SetDefault("group", "nogroup"); - - if (sizeof(void *) < 8) { - /* - * Adjust default parameters for 32 bit systems to conserve - * VM space. - */ - MCF_SetDefault("workspace_client", "24k"); - MCF_SetDefault("workspace_backend", "16k"); - MCF_SetDefault("http_resp_size", "8k"); - MCF_SetDefault("http_req_size", "12k"); - MCF_SetDefault("gzip_buffer", "4k"); - } - - MCF_InitParams(cli); - + init_params(cli); cli_check(cli); while ((o = getopt(argc, argv, diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c index 8f90bd2..05c8820 100644 --- a/bin/varnishd/mgt/mgt_param.c +++ b/bin/varnishd/mgt/mgt_param.c @@ -30,18 +30,15 @@ #include "config.h" #include -#include #include #include #include -#include #include "mgt/mgt.h" #include "common/heritage.h" #include "common/params.h" #include "mgt/mgt_param.h" -#include "waiter/waiter.h" #include "vav.h" #include "vcli.h" #include "vcli_common.h" @@ -468,13 +465,36 @@ MCF_CollectParams(void) /*--------------------------------------------------------------------*/ void -MCF_SetDefault(const char *param, const char *def) +MCF_SetDefault(const char *param, const char *new_def) { struct parspec *pp; pp = mcf_findpar(param, NULL); AN(pp); - pp->def = def; + pp->def = new_def; + AN(pp->def); +} + +void +MCF_SetMinimum(const char *param, const char *new_min) +{ + struct parspec *pp; + + pp = mcf_findpar(param, NULL); + AN(pp); + pp->min = new_min; + AN(pp->min); +} + +void +MCF_SetMaximum(const char *param, const char *new_max) +{ + struct parspec *pp; + + pp = mcf_findpar(param, NULL); + AN(pp); + pp->max = new_max; + AN(pp->max); } /*--------------------------------------------------------------------*/ diff --git a/bin/varnishd/mgt/mgt_param_tweak.c b/bin/varnishd/mgt/mgt_param_tweak.c index 4b22bc3..55520f4 100644 --- a/bin/varnishd/mgt/mgt_param_tweak.c +++ b/bin/varnishd/mgt/mgt_param_tweak.c @@ -36,7 +36,6 @@ #include #include #include -#include #include #include #include @@ -48,14 +47,9 @@ #include "mgt/mgt_param.h" #include "waiter/waiter.h" #include "vav.h" -#include "vcli.h" -#include "vcli_common.h" -#include "vcli_priv.h" #include "vnum.h" #include "vss.h" -#include "mgt_cli.h" - /*-------------------------------------------------------------------- * Generic handling of double typed parameters */ @@ -156,10 +150,6 @@ int tweak_bool(struct vsb *vsb, const struct parspec *par, const char *arg) { volatile unsigned *dest; - int mode = 0; - - if (!strcmp(par->def, "off") || !strcmp(par->def, "on")) - mode = 1; dest = par->priv; if (arg != NULL) { @@ -180,16 +170,11 @@ tweak_bool(struct vsb *vsb, const struct parspec *par, const char *arg) else if (!strcasecmp(arg, "true")) *dest = 1; else { - VSB_printf(vsb, "%s", - mode ? - "use \"on\" or \"off\"\n" : - "use \"true\" or \"false\"\n"); + VSB_printf(vsb, "use \"on\" or \"off\"\n"); return (-1); } - } else if (mode) { - VSB_printf(vsb, "%s", *dest ? "on" : "off"); } else { - VSB_printf(vsb, "%s", *dest ? "true" : "false"); + VSB_printf(vsb, "%s", *dest ? "on" : "off"); } return (0); } diff --git a/bin/varnishd/mgt/mgt_pool.c b/bin/varnishd/mgt/mgt_pool.c index 8096ed6..91c0982 100644 --- a/bin/varnishd/mgt/mgt_pool.c +++ b/bin/varnishd/mgt/mgt_pool.c @@ -43,58 +43,48 @@ #include "config.h" #include -#include -#include #include "mgt/mgt.h" #include "common/params.h" #include "mgt/mgt_param.h" -/*--------------------------------------------------------------------*/ - -static int -tweak_thread_pool_min(struct vsb *vsb, const struct parspec *par, - const char *arg) -{ - - return (tweak_generic_uint(vsb, &mgt_param.wthread_min, arg, - // par->min, mgt_param.wthread_max)); - par->min, NULL)); -} - /*-------------------------------------------------------------------- - * This is utterly ridiculous: POSIX does not guarantee that the - * minimum thread stack size is a compile time constant. - * XXX: "32bit" is a magic marker for 32bit systems. + * The min/max values automatically update the opposites appropriate + * limit, so they don't end up crossing. */ +static char min_val[20]; +static char max_val[20]; + static int -tweak_stack_size(struct vsb *vsb, const struct parspec *par, +tweak_thread_pool_min(struct vsb *vsb, const struct parspec *par, const char *arg) { - ssize_t low; - - low = sysconf(_SC_THREAD_STACK_MIN); + struct vsb v2; - if (tweak_bytes(vsb, par, arg)) + if (tweak_generic_uint(vsb, par->priv, arg, par->min, par->max)) return (-1); - if (mgt_param.wthread_stacksize < low) - mgt_param.wthread_stacksize = low; + AN(VSB_new(&v2, min_val, sizeof min_val, 0)); + AZ(tweak_generic_uint(&v2, &mgt_param.wthread_min, NULL, NULL, NULL)); + AZ(VSB_finish(&v2)); + MCF_SetMinimum("thread_pool_max", min_val); return (0); } -/*--------------------------------------------------------------------*/ - static int tweak_thread_pool_max(struct vsb *vsb, const struct parspec *par, const char *arg) { + struct vsb v2; - (void)par; - return (tweak_generic_uint(vsb, &mgt_param.wthread_max, arg, - //mgt_param.wthread_min, NULL)); - NULL, NULL)); + if (tweak_generic_uint(vsb, par->priv, arg, par->min, par->max)) + return (-1); + AN(VSB_new(&v2, max_val, sizeof max_val, 0)); + AZ(tweak_generic_uint(&v2, &mgt_param.wthread_max, NULL, NULL, NULL)); + AZ(VSB_finish(&v2)); + MCF_SetMaximum("thread_pool_min", max_val); + return (0); } /*--------------------------------------------------------------------*/ @@ -114,8 +104,8 @@ struct parspec WRK_parspec[] = { "restart to take effect.", EXPERIMENTAL | DELAYED_EFFECT, "2", "pools" }, - { "thread_pool_max", tweak_thread_pool_max, NULL, - "10", NULL, + { "thread_pool_max", tweak_thread_pool_max, &mgt_param.wthread_max, + NULL, NULL, "The maximum number of worker threads in each pool.\n" "\n" "Do not set this higher than you have to, since excess " @@ -125,8 +115,8 @@ struct parspec WRK_parspec[] = { "Minimum is 10 threads.", DELAYED_EFFECT, "5000", "threads" }, - { "thread_pool_min", tweak_thread_pool_min, NULL, - "10", NULL, + { "thread_pool_min", tweak_thread_pool_min, &mgt_param.wthread_min, + NULL, NULL, "The minimum number of worker threads in each pool.\n" "\n" "Increasing this may help ramp up faster from low load " @@ -218,11 +208,11 @@ struct parspec WRK_parspec[] = { EXPERIMENTAL, "3", "requests per request" }, { "thread_pool_stack", - tweak_stack_size, &mgt_param.wthread_stacksize, - "0", NULL, + tweak_bytes, &mgt_param.wthread_stacksize, + NULL, NULL, "Worker thread stack size.\n" - "This is likely rounded up to a multiple of 4k by the kernel.\n" - "The kernel/OS has a lower limit which will be enforced.", + "This will likely be rounded up to a multiple of 4k" + " (or whatever the page_size might be) by the kernel.", EXPERIMENTAL, "48k", "bytes" }, { NULL, NULL, NULL } diff --git a/bin/varnishtest/tests/b00042.vtc b/bin/varnishtest/tests/b00042.vtc index 1a6f947..1aeb4a4 100644 --- a/bin/varnishtest/tests/b00042.vtc +++ b/bin/varnishtest/tests/b00042.vtc @@ -17,12 +17,17 @@ varnish v1 -clierr "106" "param.set prefer_ipv6 foobar" varnish v1 -clierr "106" "param.set http_max_hdr 0" varnish v1 -clierr "106" "param.set http_max_hdr 1000000" varnish v1 -clierr "106" "param.set workspace_thread 1b" -varnish v1 -clierr "106" "param.set workspace_thread 1b" +varnish v1 -clierr "106" "param.set workspace_thread 1m" varnish v1 -clierr "106" "param.set workspace_thread 1x" varnish v1 -clierr "106" "param.set workspace_thread x" varnish v1 -clierr "106" "param.set user ///" varnish v1 -clierr "106" "param.set user ///" varnish v1 -clierr "106" {param.set listen_address ""} -varnish v1 -clierr "106" {param.set listen_address ",,"} +varnish v1 -clierr "106" {param.set listen_address "&&"} varnish v1 -clierr "106" {param.set listen_address "\""} varnish v1 -clierr "106" {param.set pool_sess "\""} +varnish v1 -clierr "200" {param.set thread_pool_max 110} +varnish v1 -clierr "106" {param.set thread_pool_min 111} +varnish v1 -clierr "200" {param.set thread_pool_min 51} +varnish v1 -clierr "106" {param.set thread_pool_max 50} +varnish v1 -clierr "200" {param.set thread_pool_max 51} From phk at varnish-cache.org Tue Nov 12 18:53:55 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 12 Nov 2013 19:53:55 +0100 Subject: [master] 50c826e More param code polishing Message-ID: commit 50c826ecb75cbbd4b16025834e709dfaacac70ce Author: Poul-Henning Kamp Date: Tue Nov 12 18:53:46 2013 +0000 More param code polishing diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c index 05c8820..8294332 100644 --- a/bin/varnishd/mgt/mgt_param.c +++ b/bin/varnishd/mgt/mgt_param.c @@ -87,19 +87,14 @@ static const char PROTECTED_TEXT[] = /*--------------------------------------------------------------------*/ static struct parspec * -mcf_findpar(const char *name, int *idx) +mcf_findpar(const char *name) { int i; AN(name); for (i = 0; i < nparspec; i++) - if (!strcmp(parspecs[i]->name, name)) { - if (idx != NULL) - *idx = i; + if (!strcmp(parspecs[i]->name, name)) return (parspecs[i]); - } - if (idx != NULL) - *idx = -1; return (NULL); } @@ -199,7 +194,7 @@ mcf_wrap(struct cli *cli, const char *text) void mcf_param_show(struct cli *cli, const char * const *av, void *priv) { - int i; + int i, n; const struct parspec *pp; int lfmt = 0, chg = 0; struct vsb *vsb; @@ -212,10 +207,12 @@ mcf_param_show(struct cli *cli, const char * const *av, void *priv) else if (av[2] != NULL) lfmt = 1; + n = 0; for (i = 0; i < nparspec; i++) { pp = parspecs[i]; if (lfmt && strcmp(pp->name, av[2]) && strcmp("-l", av[2])) continue; + n++; VSB_clear(vsb); if (pp->func(vsb, pp, NULL)) @@ -264,7 +261,7 @@ mcf_param_show(struct cli *cli, const char * const *av, void *priv) VCLI_Out(cli, "\n\n"); } } - if (av[2] != NULL && !lfmt && !chg) { + if (av[2] != NULL && lfmt && strcmp(av[2], "-l") && n == 0) { VCLI_SetResult(cli, CLIS_PARAM); VCLI_Out(cli, "Unknown parameter \"%s\".", av[2]); } @@ -280,7 +277,7 @@ MCF_ParamProtect(struct cli *cli, const char *args) { char **av; struct parspec *pp; - int i, j; + int i; av = VAV_Parse(args, NULL, ARGV_COMMA); if (av[0] != NULL) { @@ -290,7 +287,7 @@ MCF_ParamProtect(struct cli *cli, const char *args) return; } for (i = 1; av[i] != NULL; i++) { - pp = mcf_findpar(av[i], &j); + pp = mcf_findpar(av[i]); if (pp == NULL) { VCLI_Out(cli, "Unknown parameter %s", av[i]); VCLI_SetResult(cli, CLIS_PARAM); @@ -309,7 +306,7 @@ MCF_ParamSet(struct cli *cli, const char *param, const char *val) { const struct parspec *pp; - pp = mcf_findpar(param, NULL); + pp = mcf_findpar(param); if (pp == NULL) { VCLI_SetResult(cli, CLIS_PARAM); VCLI_Out(cli, "Unknown parameter \"%s\".", param); @@ -377,7 +374,7 @@ MCF_AddParams(struct parspec *ps) "Param->descr has trailing space: %s\n", pp->name); exit(2); } - if (mcf_findpar(pp->name, NULL) != NULL) { + if (mcf_findpar(pp->name) != NULL) { fprintf(stderr, "Duplicate param: %s\n", pp->name); exit(2); } @@ -469,7 +466,7 @@ MCF_SetDefault(const char *param, const char *new_def) { struct parspec *pp; - pp = mcf_findpar(param, NULL); + pp = mcf_findpar(param); AN(pp); pp->def = new_def; AN(pp->def); @@ -480,7 +477,7 @@ MCF_SetMinimum(const char *param, const char *new_min) { struct parspec *pp; - pp = mcf_findpar(param, NULL); + pp = mcf_findpar(param); AN(pp); pp->min = new_min; AN(pp->min); @@ -491,7 +488,7 @@ MCF_SetMaximum(const char *param, const char *new_max) { struct parspec *pp; - pp = mcf_findpar(param, NULL); + pp = mcf_findpar(param); AN(pp); pp->max = new_max; AN(pp->max); diff --git a/bin/varnishtest/tests/b00042.vtc b/bin/varnishtest/tests/b00042.vtc index 1aeb4a4..0c48a17 100644 --- a/bin/varnishtest/tests/b00042.vtc +++ b/bin/varnishtest/tests/b00042.vtc @@ -31,3 +31,8 @@ varnish v1 -clierr "106" {param.set thread_pool_min 111} varnish v1 -clierr "200" {param.set thread_pool_min 51} varnish v1 -clierr "106" {param.set thread_pool_max 50} varnish v1 -clierr "200" {param.set thread_pool_max 51} +varnish v1 -clierr "200" {param.set thread_pool_max unlimited} +varnish v1 -clierr "106" {param.show fofofofo} +varnish v1 -cliok "param.show changed" +varnish v1 -cliok "param.show " +varnish v1 -cliok "param.show -l" From phk at varnish-cache.org Tue Nov 12 19:05:49 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 12 Nov 2013 20:05:49 +0100 Subject: [master] e1e7651 The "good" inline-C we use should not make the compiler whine. Message-ID: commit e1e7651eeffbdfdadebd293338041629ce90d5e4 Author: Poul-Henning Kamp Date: Tue Nov 12 19:05:13 2013 +0000 The "good" inline-C we use should not make the compiler whine. diff --git a/bin/varnishtest/tests/c00052.vtc b/bin/varnishtest/tests/c00052.vtc index 6ff5815..6453a80 100644 --- a/bin/varnishtest/tests/c00052.vtc +++ b/bin/varnishtest/tests/c00052.vtc @@ -10,7 +10,7 @@ varnish v1 varnish v1 -cliok "param.set vcc_allow_inline_c true" varnish v1 -vcl+backend { - C{ getpid(); }C + C{ /*...*/ }C } varnish v1 -cliok "param.set vcc_allow_inline_c false" @@ -19,7 +19,7 @@ varnish v1 -errvcl {Inline-C not allowed} { backend default { .host = "${s1_sock}"; } - C{ getpid(); }C + C{ /*...*/ }C } varnish v1 -errvcl {Inline-C not allowed} { @@ -27,7 +27,7 @@ varnish v1 -errvcl {Inline-C not allowed} { .host = "${s1_sock}"; } sub vcl_recv { - C{ getpid(); }C + C{ /*...*/ }C } } @@ -35,12 +35,12 @@ varnish v1 -cliok "param.set vcc_allow_inline_c true" varnish v1 -vcl+backend { sub vcl_recv { - C{ getpid(); }C + C{ /*...*/ }C } } varnish v1 -vcl+backend { - C{ extern int getpid(); }C + C{ /*...*/ }C } varnish v1 -start diff --git a/bin/varnishtest/tests/c00057.vtc b/bin/varnishtest/tests/c00057.vtc index 55c478e..1aebac1 100644 --- a/bin/varnishtest/tests/c00057.vtc +++ b/bin/varnishtest/tests/c00057.vtc @@ -11,6 +11,7 @@ varnish v1 -vcl+backend { C{ #include #include +#include }C sub vcl_recv { C{ raise(SIGSEGV); sleep(2); }C } } -start diff --git a/bin/varnishtest/tests/r00742.vtc b/bin/varnishtest/tests/r00742.vtc index 1a4dbb5..91421a3 100644 --- a/bin/varnishtest/tests/r00742.vtc +++ b/bin/varnishtest/tests/r00742.vtc @@ -7,6 +7,7 @@ server s1 { varnish v1 -cliok "param.set vcc_allow_inline_c true" -vcl+backend { C{ + #include void foo(void) { printf("%s %s %s", "foo", "bar", "barf"); From phk at varnish-cache.org Tue Nov 12 19:18:12 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 12 Nov 2013 20:18:12 +0100 Subject: [master] e95740a Fix an issue in the VCC generated code related to constant IP#. Message-ID: commit e95740ad86926292ba8965c54b9efd17f0e36f89 Author: Poul-Henning Kamp Date: Tue Nov 12 19:17:45 2013 +0000 Fix an issue in the VCC generated code related to constant IP#. diff --git a/lib/libvcc/vcc_utils.c b/lib/libvcc/vcc_utils.c index e756360..9a9ed2a 100644 --- a/lib/libvcc/vcc_utils.c +++ b/lib/libvcc/vcc_utils.c @@ -108,17 +108,19 @@ vcc_sockaddr(struct vcc *tl, const void *sa, unsigned sal) sua = VSA_Malloc(sa, sal); AN(sua); - p = TlAlloc(tl, 20); - AN(p); - sprintf(p, "sockaddr_%u", tl->unique++); - Fh(tl, 0, "static const unsigned long long"); - Fh(tl, 0, " %s[%d] = {\n", p, n); + Fh(tl, 0, " sockaddr_%u[%d] = {\n", tl->unique, n); memcpy(b, sua, vsa_suckaddr_len); free(sua); for (len = 0; len < n; len++) Fh(tl, 0, "%s 0x%016llx", len ? ",\n" : "", b[len]); Fh(tl, 0, "\n};\n"); + + p = TlAlloc(tl, 40); + AN(p); + sprintf(p, "(const void*)sockaddr_%u", tl->unique); + + tl->unique++; return (p); } @@ -229,7 +231,7 @@ Resolve_Sockaddr(struct vcc *tl, } pp->l = res->ai_addrlen; - assert(pp->l < sizeof(struct sockaddr_storage)); + assert(pp->l <= sizeof(struct sockaddr_storage)); memcpy(&pp->sa, res->ai_addr, pp->l); error = getnameinfo(res->ai_addr, res->ai_addrlen, @@ -238,9 +240,8 @@ Resolve_Sockaddr(struct vcc *tl, Fh(tl, 0, "\n/* \"%s\" -> %s */\n", host, hbuf); *(pp->dst) = vcc_sockaddr(tl, &pp->sa, pp->l); - if (pp->dst_ascii != NULL) { + if (pp->dst_ascii != NULL) *pp->dst_ascii = TlDup(tl, hbuf); - } retval++; } if (p_ascii != NULL) { From phk at varnish-cache.org Tue Nov 12 19:23:56 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 12 Nov 2013 20:23:56 +0100 Subject: [master] f5679bb Fix another inline-C case which tripped up compiler. Message-ID: commit f5679bbf90f19a48c25336abb84ce8cb288f31fc Author: Poul-Henning Kamp Date: Tue Nov 12 19:22:34 2013 +0000 Fix another inline-C case which tripped up compiler. diff --git a/bin/varnishtest/tests/r00742.vtc b/bin/varnishtest/tests/r00742.vtc index 91421a3..ea34610 100644 --- a/bin/varnishtest/tests/r00742.vtc +++ b/bin/varnishtest/tests/r00742.vtc @@ -8,11 +8,12 @@ server s1 { varnish v1 -cliok "param.set vcc_allow_inline_c true" -vcl+backend { C{ #include - void foo(void) - { + }C + sub vcl_recv { + C{ printf("%s %s %s", "foo", "bar", "barf"); + }C } - }C } -start client c1 { From phk at varnish-cache.org Tue Nov 12 19:23:56 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 12 Nov 2013 20:23:56 +0100 Subject: [master] d842198 Make --enable-developer-warnings also put the VCC backend C-compiler into nitpicking mode, so the test-cases reveal if the VCC outputs anything bogus or suspect. Message-ID: commit d842198de2da59220efd15d58946aba5f23ee322 Author: Poul-Henning Kamp Date: Tue Nov 12 19:23:06 2013 +0000 Make --enable-developer-warnings also put the VCC backend C-compiler into nitpicking mode, so the test-cases reveal if the VCC outputs anything bogus or suspect. diff --git a/configure.ac b/configure.ac index cea8ebc..ba8cf01 100644 --- a/configure.ac +++ b/configure.ac @@ -55,7 +55,7 @@ AC_ARG_WITH([rst2man], [RST2MAN="$withval"], [AC_CHECK_PROGS(RST2MAN, [rst2man rst2man.py], "no") if test "x$RST2MAN" = "xno"; then - AC_MSG_WARN([rst2man not found ? not building man pages]) + AC_MSG_WARN([rst2man not found - not building man pages]) fi]) AM_CONDITIONAL(HAVE_RST2MAN,[test "x$RST2MAN" != "xno"]) @@ -65,7 +65,7 @@ AC_ARG_WITH([rst2html], [RST2HTML="$withval"], [AC_CHECK_PROGS(RST2HTML, [rst2html rst2html.py], "no") if test "x$RST2HTML" = "xno"; then - AC_MSG_WARN([rst2html not found ? not building changelog]) + AC_MSG_WARN([rst2html not found - not building changelog]) fi]) AM_CONDITIONAL(HAVE_RST2HTML,[test "x$RST2HTML" != "xno"]) @@ -458,7 +458,8 @@ EXTRA_DEVELOPER_CFLAGS="-Wextra -Wno-missing-field-initializers -Wno-sign-compar # --enable-developer-warnings AC_ARG_ENABLE(developer-warnings, AS_HELP_STRING([--enable-developer-warnings],[enable strict warnings (default is NO)]), - CFLAGS="${CFLAGS} ${DEVELOPER_CFLAGS}") + CFLAGS="${CFLAGS} ${DEVELOPER_CFLAGS}"; + OCFLAGS="${OCFLAGS} ${DEVELOPER_CFLAGS} -Werror") # --enable-debugging-symbols AC_ARG_ENABLE(debugging-symbols, From phk at varnish-cache.org Tue Nov 12 20:22:10 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 12 Nov 2013 21:22:10 +0100 Subject: [master] d4c1a50 Eliminate --enable-diagnostics, we havn't used DIAGNOSTICS for years. Message-ID: commit d4c1a5036437f4b7fd4771ebdf477a30832737b6 Author: Poul-Henning Kamp Date: Tue Nov 12 19:35:45 2013 +0000 Eliminate --enable-diagnostics, we havn't used DIAGNOSTICS for years. diff --git a/autogen.des b/autogen.des index aeb74d5..d46adc9 100755 --- a/autogen.des +++ b/autogen.des @@ -27,7 +27,6 @@ export CONFIG_SHELL=/bin/sh --enable-developer-warnings \ --enable-debugging-symbols \ --enable-dependency-tracking \ - --enable-diagnostics \ --enable-extra-developer-warnings \ --enable-stack-protector \ --enable-tests \ diff --git a/configure.ac b/configure.ac index ba8cf01..5ad95a0 100644 --- a/configure.ac +++ b/configure.ac @@ -466,11 +466,6 @@ AC_ARG_ENABLE(debugging-symbols, AS_HELP_STRING([--enable-debugging-symbols],[enable debugging symbols (default is NO)]), CFLAGS="${CFLAGS} -O0 -g -fno-inline") -# --enable-diagnostics -AC_ARG_ENABLE(diagnostics, - AS_HELP_STRING([--enable-diagnostics],[enable run-time diagnostics (default is NO)]), - CFLAGS="${CFLAGS} -DDIAGNOSTICS") - # --enable-extra-developer-warnings AC_ARG_ENABLE(extra-developer-warnings, AS_HELP_STRING([--enable-extra-developer-warnings],[enable even stricter warnings (default is NO)]), From phk at varnish-cache.org Tue Nov 12 20:22:10 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 12 Nov 2013 21:22:10 +0100 Subject: [master] 84fcb2e Make the compile-time initialized suckaddr emmiting code sizeof(unsigned long long) agnostic. Message-ID: commit 84fcb2e8bbd64e33b66a98df9230bbec1006907f Author: Poul-Henning Kamp Date: Tue Nov 12 20:21:22 2013 +0000 Make the compile-time initialized suckaddr emmiting code sizeof(unsigned long long) agnostic. diff --git a/lib/libvcc/vcc_utils.c b/lib/libvcc/vcc_utils.c index 9a9ed2a..c340cde 100644 --- a/lib/libvcc/vcc_utils.c +++ b/lib/libvcc/vcc_utils.c @@ -95,13 +95,13 @@ vcc_regexp(struct vcc *tl) static const char * vcc_sockaddr(struct vcc *tl, const void *sa, unsigned sal) { - unsigned n = (vsa_suckaddr_len + 7) / 8, len; + const int sz = sizeof(unsigned long long); + const unsigned n = (vsa_suckaddr_len + sz - 1) / sz; + unsigned len; unsigned long long b[n]; struct suckaddr *sua; char *p; - assert(sizeof(unsigned long long) == 8); - AN(sa); AN(sal); @@ -113,7 +113,7 @@ vcc_sockaddr(struct vcc *tl, const void *sa, unsigned sal) memcpy(b, sua, vsa_suckaddr_len); free(sua); for (len = 0; len < n; len++) - Fh(tl, 0, "%s 0x%016llx", len ? ",\n" : "", b[len]); + Fh(tl, 0, "%s 0x%0*llx", len ? ",\n" : "", sz * 2, b[len]); Fh(tl, 0, "\n};\n"); p = TlAlloc(tl, 40); From phk at varnish-cache.org Tue Nov 12 22:58:44 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 12 Nov 2013 23:58:44 +0100 Subject: [master] 9c27209 Add 'extern' entries for these two copyrights, to make it patently obvious that we want the to stick around, even if unused. Message-ID: commit 9c27209064322c85851bacd10c408a73625cdbfd Author: Poul-Henning Kamp Date: Tue Nov 12 22:05:50 2013 +0000 Add 'extern' entries for these two copyrights, to make it patently obvious that we want the to stick around, even if unused. diff --git a/lib/libvgz/deflate.c b/lib/libvgz/deflate.c index f6de44a..24cfb77 100644 --- a/lib/libvgz/deflate.c +++ b/lib/libvgz/deflate.c @@ -51,6 +51,7 @@ #include "deflate.h" +extern const char deflate_copyright[]; const char deflate_copyright[] = " deflate 1.2.8 Copyright 1995-2013 Jean-loup Gailly and Mark Adler "; /* diff --git a/lib/libvgz/inftrees.c b/lib/libvgz/inftrees.c index 44d89cf..9d75fd2 100644 --- a/lib/libvgz/inftrees.c +++ b/lib/libvgz/inftrees.c @@ -8,6 +8,7 @@ #define MAXBITS 15 +extern const char inflate_copyright[]; const char inflate_copyright[] = " inflate 1.2.8 Copyright 1995-2013 Mark Adler "; /* From phk at varnish-cache.org Tue Nov 12 22:58:44 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 12 Nov 2013 23:58:44 +0100 Subject: [master] 0113f8b Static-ize test-list. Message-ID: commit 0113f8bb327733c1f310649a21ea20ee226b4c9b Author: Poul-Henning Kamp Date: Tue Nov 12 22:06:58 2013 +0000 Static-ize test-list. diff --git a/lib/libvarnish/vnum.c b/lib/libvarnish/vnum.c index 605947e..7c27821 100644 --- a/lib/libvarnish/vnum.c +++ b/lib/libvarnish/vnum.c @@ -113,7 +113,7 @@ VNUM_2bytes(const char *p, uintmax_t *r, uintmax_t rel) #ifdef NUM_C_TEST /* Compile with: "cc -o foo -DNUM_C_TEST -I../.. -I../../include num.c -lm" */ -struct test_case { +static struct test_case { const char *str; uintmax_t rel; uintmax_t val; From phk at varnish-cache.org Tue Nov 12 22:58:45 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 12 Nov 2013 23:58:45 +0100 Subject: [master] c0ca4a0 Mark a needless return Message-ID: commit c0ca4a07e02ccb444ea33a52bc884661af963299 Author: Poul-Henning Kamp Date: Tue Nov 12 22:11:28 2013 +0000 Mark a needless return diff --git a/bin/varnishd/waiter/cache_waiter_kqueue.c b/bin/varnishd/waiter/cache_waiter_kqueue.c index 1c51399..ce9beb7 100644 --- a/bin/varnishd/waiter/cache_waiter_kqueue.c +++ b/bin/varnishd/waiter/cache_waiter_kqueue.c @@ -205,6 +205,7 @@ vwk_thread(void *priv) SES_Delete(sp, SC_RX_TIMEOUT, now); } } + NEEDLESS_RETURN(NULL); } /*--------------------------------------------------------------------*/ From phk at varnish-cache.org Tue Nov 12 22:58:45 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 12 Nov 2013 23:58:45 +0100 Subject: [master] 7dcb1b2 Fix #includs for proper visibility Message-ID: commit 7dcb1b29d067e355aacac1996a37d6ddb6619573 Author: Poul-Henning Kamp Date: Tue Nov 12 22:19:13 2013 +0000 Fix #includs for proper visibility diff --git a/bin/varnishd/storage/stevedore_mgt.c b/bin/varnishd/storage/stevedore_mgt.c index fd0cbec..53bfb07 100644 --- a/bin/varnishd/storage/stevedore_mgt.c +++ b/bin/varnishd/storage/stevedore_mgt.c @@ -39,10 +39,11 @@ #include #include "mgt/mgt.h" +#include "vcli_priv.h" +#include "mgt/mgt_cli.h" #include "storage/storage.h" #include "vav.h" -#include "vcli_priv.h" struct stevedore_head stv_stevedores = VTAILQ_HEAD_INITIALIZER(stv_stevedores); From phk at varnish-cache.org Tue Nov 12 22:58:45 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 12 Nov 2013 23:58:45 +0100 Subject: [master] 6114af8 Straighten out #include vsc_int.h visibility Message-ID: commit 6114af8384040d27efd6757cc4399ba83c2175ed Author: Poul-Henning Kamp Date: Tue Nov 12 22:24:59 2013 +0000 Straighten out #include vsc_int.h visibility diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index e7bffde..ddf9fa2 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -36,7 +36,6 @@ #include "common/common.h" -#include "vapi/vsc_int.h" #include "vapi/vsl_int.h" #include diff --git a/bin/varnishd/common/common.h b/bin/varnishd/common/common.h index 43af1c3..f72056a 100644 --- a/bin/varnishd/common/common.h +++ b/bin/varnishd/common/common.h @@ -39,6 +39,7 @@ #include "vdef.h" #include "vqueue.h" #include "vsb.h" +#include "vapi/vsc_int.h" /* * Enums cannot be forward declared (any more...) so put it here diff --git a/bin/varnishd/common/common_vsc.c b/bin/varnishd/common/common_vsc.c index 7078595..acc8fdd 100644 --- a/bin/varnishd/common/common_vsc.c +++ b/bin/varnishd/common/common_vsc.c @@ -28,7 +28,9 @@ * */ +#include "common.h" + /* Build the static vsc type names */ -#define VSC_TYPE_F(n,t,l,e,d) const char *VSC_type_##n = t; +#define VSC_TYPE_F(n,t,l,e,d) const char *VSC_type_##n = t; #include "tbl/vsc_types.h" #undef VSC_TYPE_F diff --git a/bin/varnishd/common/common_vsm.c b/bin/varnishd/common/common_vsm.c index 6f7f5a3..90863c3 100644 --- a/bin/varnishd/common/common_vsm.c +++ b/bin/varnishd/common/common_vsm.c @@ -43,7 +43,6 @@ #include "common.h" #include "vapi/vsm_int.h" -#include "vapi/vsc_int.h" #include "vmb.h" #include "vtim.h" diff --git a/bin/varnishd/mgt/mgt.h b/bin/varnishd/mgt/mgt.h index a7ca900..68efbeb 100644 --- a/bin/varnishd/mgt/mgt.h +++ b/bin/varnishd/mgt/mgt.h @@ -30,7 +30,6 @@ #include -#include "vapi/vsc_int.h" #include "common/common.h" struct cli; From phk at varnish-cache.org Tue Nov 12 22:58:45 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 12 Nov 2013 23:58:45 +0100 Subject: [master] 1474cf3 Mark stuff we export in shlibs with "extern". Message-ID: commit 1474cf378ca7aae8fdc95e0b984f1c0dd012c682 Author: Poul-Henning Kamp Date: Tue Nov 12 22:41:28 2013 +0000 Mark stuff we export in shlibs with "extern". diff --git a/lib/libvcc/vcc_compile.c b/lib/libvcc/vcc_compile.c index 70f976a..a1d3b9b 100644 --- a/lib/libvcc/vcc_compile.c +++ b/lib/libvcc/vcc_compile.c @@ -355,6 +355,7 @@ EmitStruct(const struct vcc *tl) { struct source *sp; + Fc(tl, 0, "\nextern const char *srcname[];\n"); Fc(tl, 0, "\nconst char *srcname[%u] = {\n", tl->nsources); VTAILQ_FOREACH(sp, &tl->sources, list) { Fc(tl, 0, "\t"); @@ -363,6 +364,7 @@ EmitStruct(const struct vcc *tl) } Fc(tl, 0, "};\n"); + Fc(tl, 0, "\nextern const char *srcbody[];\n"); Fc(tl, 0, "\nconst char *srcbody[%u] = {\n", tl->nsources); VTAILQ_FOREACH(sp, &tl->sources, list) { Fc(tl, 0, " /* "); diff --git a/lib/libvcc/vcc_expr.c b/lib/libvcc/vcc_expr.c index 95e4a7a..c868656 100644 --- a/lib/libvcc/vcc_expr.c +++ b/lib/libvcc/vcc_expr.c @@ -547,7 +547,7 @@ vcc_func(struct vcc *tl, struct expr **e, const char *cfunc, p += strlen(p) + 1; } else if (fmt == VOID && !strcmp(p, "PRIV_CALL")) { bprintf(buf, "vmod_priv_%u", tl->nvmodpriv++); - Fh(tl, 0, "struct vmod_priv %s;\n", buf); + Fh(tl, 0, "static struct vmod_priv %s;\n", buf); e2 = vcc_mk_expr(VOID, "&%s", buf); p += strlen(p) + 1; } else if (fmt == ENUM) { diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py index 2b6db42..6d62bce 100755 --- a/lib/libvcc/vmodtool.py +++ b/lib/libvcc/vmodtool.py @@ -145,31 +145,40 @@ class vmod(object): fo.write(i + "\n") def c_vmod(self, fo): + fo.write('extern const char Vmod_' + self.nam + '_Name[];\n') fo.write('const char Vmod_' + self.nam + '_Name[] =') fo.write(' \"' + self.nam + '";\n') fo.write("\n") cs = self.c_struct() - fo.write("const " + cs + ' Vmod_' + self.nam + '_Func = ') + fo.write(cs + ';\n') + + vfn = 'Vmod_' + self.nam + '_Func'; + + fo.write("extern const struct " + vfn + " " + vfn + ';\n') + fo.write("const struct " + vfn + " " + vfn + ' =') fo.write(self.c_initializer()) fo.write("\n") fo.write("\n") + fo.write("extern const int Vmod_" + self.nam + '_Len;\n') fo.write("const int Vmod_" + self.nam + '_Len =') fo.write(" sizeof(Vmod_" + self.nam + "_Func);\n") fo.write("\n") + fo.write("extern const char Vmod_" + self.nam + "_Proto[];\n") fo.write("const char Vmod_" + self.nam + "_Proto[] =\n") for t in self.c_typedefs_(): fo.write('\t"' + t + '\\n"\n') fo.write('\t"\\n"\n') - for i in (cs + " Vmod_" + self.nam + '_Func;').split("\n"): + for i in (cs + ";").split("\n"): fo.write('\n\t"' + i + '\\n"') - fo.write(";\n\n") + fo.write('\n\t"static struct ' + vfn + " " + vfn + ';";\n\n') fo.write(self.c_strspec()) fo.write("\n") + fo.write('extern const char Vmod_' + self.nam + '_ABI[];\n') fo.write('const char Vmod_' + self.nam + '_ABI[] =') fo.write(' VMOD_ABI_Version;\n') #fo.write("\n") @@ -208,7 +217,8 @@ class vmod(object): return s def c_strspec(self): - s = "const char * const Vmod_" + self.nam + "_Spec[] = {\n" + s = "const char * const Vmod_" + self.nam + "_Spec[]" + s = "extern " + s + ";\n" + s + " = {\n" for o in self.objs: s += o.c_strspec(self.nam) From phk at varnish-cache.org Tue Nov 12 22:58:45 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 12 Nov 2013 23:58:45 +0100 Subject: [master] e8cd406 Fix a couple of K&R style argumentless functions Message-ID: commit e8cd406ba84f2c0729b62eeb799168601c7b175a Author: Poul-Henning Kamp Date: Tue Nov 12 22:58:25 2013 +0000 Fix a couple of K&R style argumentless functions diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c index b342f43..97e760d 100644 --- a/bin/varnishd/cache/cache_vcl.c +++ b/bin/varnishd/cache/cache_vcl.c @@ -455,7 +455,7 @@ static struct cli_proto vcl_cmds[] = { }; void -VCL_Init() +VCL_Init(void) { CLI_AddFuncs(vcl_cmds); diff --git a/bin/varnishd/mgt/mgt_vcc.c b/bin/varnishd/mgt/mgt_vcc.c index 4df7b0f..d3e81de 100644 --- a/bin/varnishd/mgt/mgt_vcc.c +++ b/bin/varnishd/mgt/mgt_vcc.c @@ -431,7 +431,7 @@ mgt_vcc_default(const char *b_arg, const char *f_arg, char *vcl, int C_flag) /*--------------------------------------------------------------------*/ int -mgt_has_vcl() +mgt_has_vcl(void) { return (!VTAILQ_EMPTY(&vclhead)); From phk at varnish-cache.org Tue Nov 12 23:03:19 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Wed, 13 Nov 2013 00:03:19 +0100 Subject: [master] d9492da Simplify and modernize our compiler warnings Message-ID: commit d9492da540430103b9dcd6844eb59b508c061d66 Author: Poul-Henning Kamp Date: Tue Nov 12 23:01:22 2013 +0000 Simplify and modernize our compiler warnings -Wall -Werror is always on, at least until all of Jenkins turns red. All developer warnings have been collected under --enable-developer-warnings and several auxillary developer options have been absorbed or otherwise eliminated. diff --git a/autogen.des b/autogen.des index d46adc9..d546bc7 100755 --- a/autogen.des +++ b/autogen.des @@ -9,12 +9,7 @@ make -k distclean > /dev/null 2>&1 || true # Prefer CLANG if we have it, and have not given preferences if [ -f /usr/bin/clang -a "x${CC}" = "x" ] ; then CC=clang - CFLAGS="${CFLAGS} -Qunused-arguments" - - # XXX: clang complains about -g in linker invocations - # XXX: so fall back to gcc for now... - # CC=gcc - export CC CFLAGS + export CC fi rm -f configure @@ -27,10 +22,7 @@ export CONFIG_SHELL=/bin/sh --enable-developer-warnings \ --enable-debugging-symbols \ --enable-dependency-tracking \ - --enable-extra-developer-warnings \ - --enable-stack-protector \ --enable-tests \ - --enable-werror \ --prefix=/opt/varnish \ --mandir=/opt/varnish/man \ "$@" diff --git a/configure.ac b/configure.ac index 5ad95a0..b4ffa1f 100644 --- a/configure.ac +++ b/configure.ac @@ -446,60 +446,41 @@ AC_SUBST(varnishconfdir) # Check for linker script support gl_LD_VERSION_SCRIPT +####################################################################### # Now that we're done using the compiler to look for functions and # libraries, set CFLAGS to what we want them to be for our own code +# This is a test to see how much havoc Jenkins exposes +CFLAGS="${CFLAGS} -Wall -Werror" +OCFLAGS="${OCFLAGS} -Wall -Werror" + # This corresponds to FreeBSD's WARNS level 6 -DEVELOPER_CFLAGS="-Wall -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wshadow -Wcast-align -Wunused-parameter -Wchar-subscripts -Winline -Wnested-externs -Wredundant-decls -Wformat" +DEVELOPER_CFLAGS="-fstack-protector -Wsystem-headers -Werror -Wall -Wno-format-y2k -W -Wno-unused-parameter -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wshadow -Wunused-parameter -Wcast-align -Wchar-subscripts -Winline -Wnested-externs -Wno-pointer-sign -Wno-empty-body -Wextra -Wno-missing-field-initializers -Wno-sign-compare" + +# These are not compliable yet +DEVELOPER_GCC_CFLAGS="-Wold-style-definition -Wredundant-decls " +#DEVELOPER_CFLAGS="${DEVELOPER_CFLAGS} ${DEVELOPER_GCC_CFLAGS}" -# Additional flags for GCC 4 -EXTRA_DEVELOPER_CFLAGS="-Wextra -Wno-missing-field-initializers -Wno-sign-compare" +# These are compilable +DEVELOPER_CLANG_CFLAGS="-Wmissing-variable-declarations -Wno-string-plus-int" +#DEVELOPER_CFLAGS="${DEVELOPER_CFLAGS} ${DEVELOPER_CLANG_CFLAGS}" # --enable-developer-warnings AC_ARG_ENABLE(developer-warnings, AS_HELP_STRING([--enable-developer-warnings],[enable strict warnings (default is NO)]), - CFLAGS="${CFLAGS} ${DEVELOPER_CFLAGS}"; - OCFLAGS="${OCFLAGS} ${DEVELOPER_CFLAGS} -Werror") + [], + [enable_developer_warnings=no]) + +if test "x$enable_developer_warnings" != "xno"; then + CFLAGS="${CFLAGS} ${DEVELOPER_CFLAGS}" + OCFLAGS="${OCFLAGS} ${DEVELOPER_CFLAGS}" +fi # --enable-debugging-symbols AC_ARG_ENABLE(debugging-symbols, AS_HELP_STRING([--enable-debugging-symbols],[enable debugging symbols (default is NO)]), CFLAGS="${CFLAGS} -O0 -g -fno-inline") -# --enable-extra-developer-warnings -AC_ARG_ENABLE(extra-developer-warnings, - AS_HELP_STRING([--enable-extra-developer-warnings],[enable even stricter warnings (default is NO)]), - [], - [enable_extra_developer_warnings=no]) - -if test "x$enable_stack_protector" != "xno"; then - save_CFLAGS="$CFLAGS" - CFLAGS="${CFLAGS} ${EXTRA_DEVELOPER_CFLAGS}" - AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM([],[],[])], - [], - [AC_MSG_WARN([All of ${EXTRA_DEVELOPER_CFLAGS} not supported, disabling]) - CFLAGS="$save_CFLAGS"]) -fi - -# --enable-stack-protector -AC_ARG_ENABLE(stack-protector, - AS_HELP_STRING([--enable-stack-protector],[enable stack protector (default is NO)]), - [], - [enable_stack_protector=no]) - -if test "x$enable_stack_protector" != "xno"; then - save_CFLAGS="$CFLAGS" - CFLAGS="${CFLAGS} -fstack-protector-all" - save_AM_LT_LDFLAGS="$AM_LT_LDFLAGS" - AM_LT_LDFLAGS="${AM_LT_LDFLAGS} -Wc,-fstack-protector" - AC_COMPILE_IFELSE( - [AC_LANG_PROGRAM([],[],[])], - [], - [AC_MSG_WARN([-fstack-protector not supported, disabling]) - CFLAGS="$save_CFLAGS"] - AM_LT_LDFLAGS="$save_AM_LT_LDFLAGS") -fi AC_SUBST(AM_LT_LDFLAGS) # --enable-tests @@ -507,11 +488,6 @@ AC_ARG_ENABLE(tests, AS_HELP_STRING([--enable-tests],[build test programs (default is NO)])) AM_CONDITIONAL([ENABLE_TESTS], [test x$enable_tests = xyes]) -# --enable-werror -AC_ARG_ENABLE(werror, - AS_HELP_STRING([--enable-werror],[use -Werror (default is NO)]), - CFLAGS="${CFLAGS} -Werror") - # Command line for compiling VCL code. I wish there were a simple way # to figure this out dynamically without introducing a run-time # dependency on libtool. From phk at varnish-cache.org Tue Nov 12 23:32:10 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Wed, 13 Nov 2013 00:32:10 +0100 Subject: [master] 1294c21 Eliminate inline-C #include Message-ID: commit 1294c210f88b7c747992f649f9a6c796f8daf8bc Author: Poul-Henning Kamp Date: Tue Nov 12 23:31:56 2013 +0000 Eliminate inline-C #include diff --git a/bin/varnishtest/tests/c00057.vtc b/bin/varnishtest/tests/c00057.vtc index 1aebac1..fe8e78e 100644 --- a/bin/varnishtest/tests/c00057.vtc +++ b/bin/varnishtest/tests/c00057.vtc @@ -10,7 +10,6 @@ varnish v1 -cliok "param.set sigsegv_handler on" varnish v1 -vcl+backend { C{ #include -#include #include }C sub vcl_recv { C{ raise(SIGSEGV); sleep(2); }C } From phk at varnish-cache.org Wed Nov 13 07:50:07 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Wed, 13 Nov 2013 08:50:07 +0100 Subject: [master] 4ff840e Remove obsoleted options Message-ID: commit 4ff840e566794be96e5361184ffb717deacc3849 Author: Poul-Henning Kamp Date: Wed Nov 13 07:49:51 2013 +0000 Remove obsoleted options diff --git a/Makefile.am b/Makefile.am index dabe7c8..66c9e03 100644 --- a/Makefile.am +++ b/Makefile.am @@ -17,10 +17,7 @@ DISTCHECK_CONFIGURE_FLAGS = \ --enable-developer-warnings \ --enable-debugging-symbols \ --enable-dependency-tracking \ - --enable-diagnostics \ - --enable-extra-developer-warnings \ - --enable-tests \ - --enable-werror + --enable-tests install-data-local: $(install_sh) -d -m 0755 $(DESTDIR)$(localstatedir)/varnish From phk at varnish-cache.org Wed Nov 13 08:09:54 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Wed, 13 Nov 2013 09:09:54 +0100 Subject: [master] e4f2b84 Various nit-pickery necessary for OS/X Message-ID: commit e4f2b84b245c07b2c39fc42dfbde7c086c88fbc4 Author: Poul-Henning Kamp Date: Wed Nov 13 08:09:38 2013 +0000 Various nit-pickery necessary for OS/X diff --git a/lib/libvarnishtools/vut.c b/lib/libvarnishtools/vut.c index e8d022d..b7e9c90 100644 --- a/lib/libvarnishtools/vut.c +++ b/lib/libvarnishtools/vut.c @@ -43,7 +43,6 @@ #include "compat/daemon.h" #include "vpf.h" #include "vapi/vsm.h" -#include "vapi/vsc.h" #include "vapi/vsl.h" #include "vtim.h" #include "vas.h" @@ -256,7 +255,7 @@ VUT_Setup(void) /* Write PID and setup exit handler */ if (VUT.pfh != NULL) { VPF_Write(VUT.pfh); - AZ(atexit(&vut_vpf_remove)); + AZ(atexit(vut_vpf_remove)); } } @@ -286,7 +285,7 @@ int VUT_Main(VSLQ_dispatch_f *func, void *priv) { struct VSL_cursor *c; - int i; + int i = -1; AN(VUT.vslq); diff --git a/lib/libvcc/vcc_utils.c b/lib/libvcc/vcc_utils.c index c340cde..88edc2d 100644 --- a/lib/libvcc/vcc_utils.c +++ b/lib/libvcc/vcc_utils.c @@ -113,7 +113,8 @@ vcc_sockaddr(struct vcc *tl, const void *sa, unsigned sal) memcpy(b, sua, vsa_suckaddr_len); free(sua); for (len = 0; len < n; len++) - Fh(tl, 0, "%s 0x%0*llx", len ? ",\n" : "", sz * 2, b[len]); + Fh(tl, 0, "%s 0x%0*llxLL", + len ? ",\n" : "", sz * 2, b[len]); Fh(tl, 0, "\n};\n"); p = TlAlloc(tl, 40); From phk at varnish-cache.org Wed Nov 13 08:25:58 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Wed, 13 Nov 2013 09:25:58 +0100 Subject: [master] a2d535e Improve our symbol hack a bit for OS/X Message-ID: commit a2d535ee082b792db38d803fc551ba36e700e03f Author: Poul-Henning Kamp Date: Wed Nov 13 08:25:46 2013 +0000 Improve our symbol hack a bit for OS/X diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index d8299cc..4292e7f 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -268,6 +268,8 @@ Symbol_hack(const char *a0) continue; if (*p++ != ' ') continue; + if (*p == '-') + continue; p++; if (*p++ != ' ') continue; From phk at varnish-cache.org Wed Nov 13 08:33:05 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Wed, 13 Nov 2013 09:33:05 +0100 Subject: [master] 9254b12 OS/X's kqueue can return zero events. Message-ID: commit 9254b1281b71f773ac028392eca21d5def912d49 Author: Poul-Henning Kamp Date: Wed Nov 13 08:32:47 2013 +0000 OS/X's kqueue can return zero events. diff --git a/bin/varnishd/waiter/cache_waiter_kqueue.c b/bin/varnishd/waiter/cache_waiter_kqueue.c index ce9beb7..fb82e99 100644 --- a/bin/varnishd/waiter/cache_waiter_kqueue.c +++ b/bin/varnishd/waiter/cache_waiter_kqueue.c @@ -170,7 +170,12 @@ vwk_thread(void *priv) dotimer = 0; n = kevent(vwk->kq, vwk->ki, vwk->nki, ke, NKEV, NULL); now = VTIM_real(); - assert(n >= 1 && n <= NKEV); + assert(n <= NKEV); + if (n == 0) { + /* This happens on OSX in m00011.vtc */ + dotimer = 1; + (void)usleep(10000); + } vwk->nki = 0; for (kp = ke, j = 0; j < n; j++, kp++) { if (kp->filter == EVFILT_TIMER) { From tfheen at varnish-cache.org Wed Nov 13 09:37:49 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Wed, 13 Nov 2013 10:37:49 +0100 Subject: [master] 367ce68 Put build scripts in build-aux Message-ID: commit 367ce6813a8969ac509fa61d020006ceba69fbf6 Author: Tollef Fog Heen Date: Wed Nov 13 10:37:24 2013 +0100 Put build scripts in build-aux diff --git a/configure.ac b/configure.ac index b4ffa1f..cba0359 100644 --- a/configure.ac +++ b/configure.ac @@ -6,6 +6,7 @@ AC_INIT([Varnish], [trunk], [varnish-dev at varnish-cache.org]) AC_CONFIG_SRCDIR(include/miniobj.h) AC_CONFIG_HEADERS([config.h]) AC_CONFIG_MACRO_DIR([m4]) +AC_CONFIG_AUX_DIR([build-aux]) AC_USE_SYSTEM_EXTENSIONS # save command line CFLAGS for use in VCC_CC (to pass through things like -m64) From phk at varnish-cache.org Wed Nov 13 10:09:38 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Wed, 13 Nov 2013 11:09:38 +0100 Subject: [master] c6dd10c Go over the vmod_std reference page. Message-ID: commit c6dd10c32b3d4f559fbaf419d0ea57c4ccda141b Author: Poul-Henning Kamp Date: Wed Nov 13 10:09:10 2013 +0000 Go over the vmod_std reference page. Fixes: #1359 diff --git a/doc/sphinx/reference/index.rst b/doc/sphinx/reference/index.rst index 13f7458..1537fb4 100644 --- a/doc/sphinx/reference/index.rst +++ b/doc/sphinx/reference/index.rst @@ -5,7 +5,7 @@ The Varnish Reference Manual %%%%%%%%%%%%%%%%%%%%%%%%%%%% .. toctree:: - :maxdepth: 4 + :maxdepth: 2 vcl.rst varnish-cli.rst diff --git a/doc/sphinx/reference/vmod_std.rst b/doc/sphinx/reference/vmod_std.rst index d310986..c0b6c6e 100644 --- a/doc/sphinx/reference/vmod_std.rst +++ b/doc/sphinx/reference/vmod_std.rst @@ -15,14 +15,21 @@ Varnish Standard Module SYNOPSIS ======== -import std +import std [from "path"] ; 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. +Vmod_std contains basic functions which are part and parcel of Varnish, +but which for reasons of architecture fit better in a VMOD. + +One specific class of functions in vmod_std is the conversions functions +which all have the form:: + + TYPE type(STRING, TYPE) + +These functions attempt to convert STRING to the TYPE, and if that fails, +they return the second argument, which must have the given TYPE. FUNCTIONS ========= @@ -31,9 +38,7 @@ toupper ------- Prototype - toupper(STRING s) -Return value - String + STRING toupper(STRING s) Description Converts the string *s* to upper case. Example @@ -42,9 +47,7 @@ Example tolower ------- Prototype - tolower(STRING s) -Return value - String + STRING tolower(STRING s) Description Converts the string *s* to lower case. Example @@ -53,9 +56,7 @@ Example set_ip_tos ---------- Prototype - set_ip_tos(INT i) -Return value - Void + VOID set_ip_tos(INT i) 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 @@ -69,9 +70,7 @@ Example random ------ Prototype - random(REAL a, REAL b) -Return value - Real + REAL random(REAL a, REAL b) Description Returns a random REAL number between *a* and *b*. Example @@ -80,20 +79,16 @@ Example log --- Prototype - log(STRING string) -Return value - Void + VOID log(STRING string) Description - Logs *string* to the shared memory log. + Logs *string* to the shared memory log, using VSL tag *SLT_VCL_Log*. Example std.log("Something fishy is going on with the vhost " + req.host); syslog ------ Prototype - syslog(INT priority, STRING string) -Return value - Void + VOID syslog(INT priority, STRING string) Description Logs *string* to syslog marked with *priority*. See your system's syslog.h file for the legal values of *priority*. @@ -103,9 +98,7 @@ Example fileread -------- Prototype - fileread(STRING filename) -Return value - String + STRING fileread(STRING filename) Description Reads a file and returns a string with the content. Please note that it is not recommended to send variables to this @@ -114,44 +107,54 @@ Description Example set beresp.http.x-served-by = std.fileread("/etc/hostname"); +collect +------- +Prototype + VOID collect(HEADER header) +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. + + +CONVERSION FUNCTIONS +==================== + duration -------- Prototype - duration(STRING s, DURATION fallback) -Return value - Duration + DURATION duration(STRING s, DURATION fallback) 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 *s* fails to parse, *fallback* will be used. + (weeks) units. If *s* fails to parse, *fallback* will be returned. Example set beresp.ttl = std.duration("1w", 3600s); integer -------- Prototype - integer(STRING s, INT fallback) -Return value - Int + INT integer(STRING s, INT fallback) Description Converts the string *s* to an integer. If *s* fails to parse, - *fallback* will be used + *fallback* will be returned. Example if (std.integer(beresp.http.x-foo, 0) > 5) { ... } -collect -------- +ip +-- Prototype - collect(HEADER header) -Return value - Void + IP ip(STRING s, IP fallback) 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. + Converts string *s* to the first IP number returned by + the system library function getaddrinfo(3). If conversion + fails, *fallback* will be returned. +Example: + if (std.ip(req.http.X-forwarded-for, "0.0.0.0") ~ my_acl) { ... } + SEE ALSO ======== From phk at varnish-cache.org Wed Nov 13 10:09:38 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Wed, 13 Nov 2013 11:09:38 +0100 Subject: [master] 96ac627 Merge branch 'master' of ssh://git.varnish-cache.org/git/varnish-cache Message-ID: commit 96ac6271c5285bdf4c6fd60370139f19384cb36b Merge: c6dd10c 367ce68 Author: Poul-Henning Kamp Date: Wed Nov 13 10:09:31 2013 +0000 Merge branch 'master' of ssh://git.varnish-cache.org/git/varnish-cache From phk at varnish-cache.org Wed Nov 13 10:39:17 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Wed, 13 Nov 2013 11:39:17 +0100 Subject: [master] 7aef7a7 Fix the typedef for VCL_HEADER Message-ID: commit 7aef7a73d49833fa27091a357b01980b0225f0a5 Author: Poul-Henning Kamp Date: Wed Nov 13 10:38:38 2013 +0000 Fix the typedef for VCL_HEADER diff --git a/include/vrt.h b/include/vrt.h index cab38de..fa512dd 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -54,7 +54,7 @@ typedef unsigned VCL_BOOL; typedef double VCL_BYTES; typedef double VCL_DURATION; typedef const char * VCL_ENUM; -typedef const char * VCL_HEADER; +typedef const struct gethdr_s * VCL_HEADER; typedef long VCL_INT; typedef const struct suckaddr * VCL_IP; typedef double VCL_REAL; diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py index 6d62bce..3190185 100755 --- a/lib/libvcc/vmodtool.py +++ b/lib/libvcc/vmodtool.py @@ -50,7 +50,7 @@ ctypes = { 'BOOL': "VCL_BOOL", 'DURATION': "VCL_DURATION", 'ENUM': "VCL_ENUM", - 'HEADER': "const struct gethdr_s *", + 'HEADER': "VCL_HEADER", 'INT': "VCL_INT", 'IP': "VCL_IP", 'PRIV_CALL': "struct vmod_priv *", diff --git a/lib/libvmod_std/vmod_std.c b/lib/libvmod_std/vmod_std.c index 8926d3d..c865494 100644 --- a/lib/libvmod_std/vmod_std.c +++ b/lib/libvmod_std/vmod_std.c @@ -169,7 +169,7 @@ vmod_syslog(const struct vrt_ctx *ctx, VCL_INT fac, const char *fmt, ...) } VCL_VOID __match_proto__(td_std_collect) -vmod_collect(const struct vrt_ctx *ctx, const struct gethdr_s *hdr) +vmod_collect(const struct vrt_ctx *ctx, VCL_HEADER hdr) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); From phk at varnish-cache.org Wed Nov 13 10:39:17 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Wed, 13 Nov 2013 11:39:17 +0100 Subject: [master] fe01da5 Go through the VMOD reference page Message-ID: commit fe01da5ce66e721745c1ee3f2f4f196478419376 Author: Poul-Henning Kamp Date: Wed Nov 13 10:38:51 2013 +0000 Go through the VMOD reference page diff --git a/doc/sphinx/reference/vmod.rst b/doc/sphinx/reference/vmod.rst index 1cfaf25..62803e5 100644 --- a/doc/sphinx/reference/vmod.rst +++ b/doc/sphinx/reference/vmod.rst @@ -101,8 +101,9 @@ VCL and C data types VCL data types are targeted at the job, so for instance, we have data types like "DURATION" and "HEADER", but they all have some kind of C -language representation. Here is a description of them, from simple -to nasty. +language representation. Here is a description of them. + +All but the STRING_LIST type have typedefs: VCL_INT, VCL_REAL etc. INT C-type: ``int`` @@ -144,7 +145,7 @@ STRING When used as a return value, the producing function is responsible for arranging memory management. Either by freeing the string later by whatever means available or - by using storage allocated from the session or worker + by using storage allocated from the client or backend workspaces. STRING_LIST @@ -152,8 +153,8 @@ STRING_LIST A multi-component text-string. We try very hard to avoid doing text-processing in Varnish, and this is one way we - do that, by not editing separate pieces of a sting together - to one string, until we need to. + to avoid that, by not editing separate pieces of a sting + together to one string, unless we have to. Consider this contrived example:: @@ -179,7 +180,8 @@ STRING_LIST a function, we may relax that at a latter time. If you don't want to bother with STRING_LIST, just use STRING - and make sure your thread_pool_workspace param is big enough. + and make sure your workspace_client and workspace_backend params + are big enough. PRIV_VCL See below @@ -194,12 +196,22 @@ VOID procedure. HEADER - C-type: ``enum gethdr_e, const char *`` + C-type: ``const struct gethdr_s *'' + + These are VCL compiler generated constants referencing + a particular header in a particular HTTP entity, for instance + ``req.http.cookie'' or ``beresp.http.last-modified'' + +IP + C-type: ``const struct suckaddr *'' + + This is an opaque type, see the ``include/vsa.h`` file for + which primitives we support on this type. - XXX: explain me +BOOL + C-type: ``unsigned'' -IP, BOOL - XXX: these types are not released for use in vmods yet. + Zero means false, anything else means true. Private Pointers @@ -243,7 +255,24 @@ pointer points to. When a VCL program is discarded, all private pointers are checked to see if both the "priv" and "free" elements are non-NULL, and if they are, the "free" function will be called with the "priv" pointer -as only argument. +as the only argument. + +In the common case where a private data structure is allocated with +malloc would look like this:: + + if (priv->priv == NULL) { + priv->priv = calloc(sizeof(struct myfoo), 1); + AN(priv->priv); + priv->priv = free; /* free(3) */ + mystate = priv->priv; + mystate->foo = 21; + ... + } else { + mystate = priv->priv; + } + if (foo > 25) { + ... + } The per-call vmod_privs are freed before the per-vcl vmod_priv. @@ -251,15 +280,15 @@ Init functions ============== VMODs can have an "init" method which is called when a VCL -which imports the VMOD is initialized. +which imports the VMOD is loaded. The first argument to the init function is the vmod_priv specific to this particular VCL, and if necessary, a VCL specific VMOD "fini" function can be attached to its "free" hook. -(The second argument is a pointer to the VCL's config structure, -it is not at all obvious what you can use this for in practice, -but we provide it just in case.) +The second argument is a pointer to the VCL's config structure, +which allows you to tell different VCLs which import this module +apart. Please notice that there is no "global" fini method. @@ -275,11 +304,14 @@ When to lock, and when not to lock Varnish is heavily multithreaded, so by default VMODs must implement their own locking to protect shared resources. -When a VCL is loaded or unloaded, the initialization and teardown -is run sequentially in a single thread, and there is guaranteed +When a VCL is loaded or unloaded, the init and priv->free are +run sequentially all in a single thread, and there is guaranteed to be no other activity related to this particular VCL, nor are there init/fini activity in any other VCL or VMOD at this time. That means that the VMOD init, and any object init/fini functions are already serialized in sensible order, and won't need any locking, unless they access VMOD specific global state, shared with other VCLs. + +Trafic in other VCLs which also import this VMOD, will be happening +while housekeeping is going on. From phk at varnish-cache.org Wed Nov 13 10:41:15 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Wed, 13 Nov 2013 11:41:15 +0100 Subject: [master] 5cd1e7d Remove mention of --enable-werror Message-ID: commit 5cd1e7d70883ba3de416f796ce05f4f3b7ae48b0 Author: Poul-Henning Kamp Date: Wed Nov 13 10:41:07 2013 +0000 Remove mention of --enable-werror diff --git a/INSTALL b/INSTALL index 97b2502..4f2227f 100644 --- a/INSTALL +++ b/INSTALL @@ -17,4 +17,3 @@ Additional configure options of interest: enable strict warnings (default is NO) --enable-debugging-symbols enable debugging symbols (default is NO) - --enable-werror use -Werror (default is NO) From phk at varnish-cache.org Wed Nov 13 10:45:15 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Wed, 13 Nov 2013 11:45:15 +0100 Subject: [master] 8143d06 Always test-compile your RST changes... Message-ID: commit 8143d06c8c7182d9a85f7067fecad75b494f7ee0 Author: Poul-Henning Kamp Date: Wed Nov 13 10:45:03 2013 +0000 Always test-compile your RST changes... diff --git a/doc/sphinx/reference/vmod.rst b/doc/sphinx/reference/vmod.rst index 62803e5..88a511d 100644 --- a/doc/sphinx/reference/vmod.rst +++ b/doc/sphinx/reference/vmod.rst @@ -35,7 +35,7 @@ VMOD Directory The VMOD directory is an up-to-date compilation of maintained extensions written for Varnish Cache: - https://www.varnish-cache.org/vmods +https://www.varnish-cache.org/vmods The vmod.vcc file ================= @@ -196,20 +196,25 @@ VOID procedure. HEADER - C-type: ``const struct gethdr_s *'' + C-type: ``const struct gethdr_s *`` These are VCL compiler generated constants referencing a particular header in a particular HTTP entity, for instance - ``req.http.cookie'' or ``beresp.http.last-modified'' + ``req.http.cookie`` or ``beresp.http.last-modified``. + By passing a reference to the header, the VMOD code can + both read and write the header in question. + + If the header was passed as STRING, the VMOD code only sees + the value, but not where it came from. IP - C-type: ``const struct suckaddr *'' + C-type: ``const struct suckaddr *`` This is an opaque type, see the ``include/vsa.h`` file for which primitives we support on this type. BOOL - C-type: ``unsigned'' + C-type: ``unsigned`` Zero means false, anything else means true. From phk at varnish-cache.org Wed Nov 13 13:05:44 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Wed, 13 Nov 2013 14:05:44 +0100 Subject: [master] 88ba3b3 We don't want to -W check system headers. Message-ID: commit 88ba3b35a53b453a2d85444052c7e50743c8df86 Author: Poul-Henning Kamp Date: Wed Nov 13 13:05:07 2013 +0000 We don't want to -W check system headers. Detectived by: scn diff --git a/configure.ac b/configure.ac index cba0359..42a427c 100644 --- a/configure.ac +++ b/configure.ac @@ -456,7 +456,7 @@ CFLAGS="${CFLAGS} -Wall -Werror" OCFLAGS="${OCFLAGS} -Wall -Werror" # This corresponds to FreeBSD's WARNS level 6 -DEVELOPER_CFLAGS="-fstack-protector -Wsystem-headers -Werror -Wall -Wno-format-y2k -W -Wno-unused-parameter -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wshadow -Wunused-parameter -Wcast-align -Wchar-subscripts -Winline -Wnested-externs -Wno-pointer-sign -Wno-empty-body -Wextra -Wno-missing-field-initializers -Wno-sign-compare" +DEVELOPER_CFLAGS="-fstack-protector -Werror -Wall -Wno-format-y2k -W -Wno-unused-parameter -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wshadow -Wunused-parameter -Wcast-align -Wchar-subscripts -Winline -Wnested-externs -Wno-pointer-sign -Wno-empty-body -Wextra -Wno-missing-field-initializers -Wno-sign-compare" # These are not compliable yet DEVELOPER_GCC_CFLAGS="-Wold-style-definition -Wredundant-decls " From phk at varnish-cache.org Wed Nov 13 19:36:10 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Wed, 13 Nov 2013 20:36:10 +0100 Subject: [master] 499a1ea This is a dirty hack so I can find out from Jenkins if there are parts of config.h we don't need anymore Message-ID: commit 499a1ea859efec74474ca66b0503cd289e12b9c3 Author: Poul-Henning Kamp Date: Wed Nov 13 19:35:39 2013 +0000 This is a dirty hack so I can find out from Jenkins if there are parts of config.h we don't need anymore diff --git a/include/Makefile.am b/include/Makefile.am index 5b75aca..728fec3 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -91,6 +91,9 @@ tbl/vrt_stv_var.h tbl/vcl_returns.h tbl/vcc_types.h vcl.h vrt_obj.h: $(top_srcdi BUILT_SOURCES = vcs_version.h vmod_abi.h MAINTAINERCLEANFILES = vcs_version.h vcs_version.h: FORCE + @echo "PHK HACK BEGIN" + - at grep '^[ ]*#[ ]*define $(top_srcdir)/config.h + @echo "PHK HACK END" @if [ -d "$(top_srcdir)/.git" ]; then \ V="$$(git show -s --pretty=format:%h)" \ H="$$(head -n 1 vcs_version.h 2>/dev/null || true)"; \ From phk at varnish-cache.org Wed Nov 13 19:45:35 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Wed, 13 Nov 2013 20:45:35 +0100 Subject: [master] b7675c6 Typo Message-ID: commit b7675c6f016d8a53996578b87c92696cd3084cd9 Author: Poul-Henning Kamp Date: Wed Nov 13 19:45:20 2013 +0000 Typo diff --git a/include/Makefile.am b/include/Makefile.am index 728fec3..174f447 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -92,7 +92,7 @@ BUILT_SOURCES = vcs_version.h vmod_abi.h MAINTAINERCLEANFILES = vcs_version.h vcs_version.h: FORCE @echo "PHK HACK BEGIN" - - at grep '^[ ]*#[ ]*define $(top_srcdir)/config.h + - at grep '^[ ]*#[ ]*define' $(top_srcdir)/config.h @echo "PHK HACK END" @if [ -d "$(top_srcdir)/.git" ]; then \ V="$$(git show -s --pretty=format:%h)" \ From phk at varnish-cache.org Wed Nov 13 21:51:39 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Wed, 13 Nov 2013 22:51:39 +0100 Subject: [master] 0e75dec Remove this hack again Message-ID: commit 0e75decce9b9d0d45dbe7c93a647c694f966ed19 Author: Poul-Henning Kamp Date: Wed Nov 13 21:51:28 2013 +0000 Remove this hack again diff --git a/include/Makefile.am b/include/Makefile.am index 174f447..5b75aca 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -91,9 +91,6 @@ tbl/vrt_stv_var.h tbl/vcl_returns.h tbl/vcc_types.h vcl.h vrt_obj.h: $(top_srcdi BUILT_SOURCES = vcs_version.h vmod_abi.h MAINTAINERCLEANFILES = vcs_version.h vcs_version.h: FORCE - @echo "PHK HACK BEGIN" - - at grep '^[ ]*#[ ]*define' $(top_srcdir)/config.h - @echo "PHK HACK END" @if [ -d "$(top_srcdir)/.git" ]; then \ V="$$(git show -s --pretty=format:%h)" \ H="$$(head -n 1 vcs_version.h 2>/dev/null || true)"; \ From phk at varnish-cache.org Thu Nov 14 08:45:57 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Thu, 14 Nov 2013 09:45:57 +0100 Subject: [master] 6d3fe4d Keep a fall-back for -i, if we don't have a Makefile Message-ID: commit 6d3fe4da961022259b71e741380a1a8e4e965b30 Author: Poul-Henning Kamp Date: Thu Nov 14 08:45:42 2013 +0000 Keep a fall-back for -i, if we don't have a Makefile diff --git a/bin/varnishtest/vtc_main.c b/bin/varnishtest/vtc_main.c index 951dc17..d6169e6 100644 --- a/bin/varnishtest/vtc_main.c +++ b/bin/varnishtest/vtc_main.c @@ -326,7 +326,8 @@ start_test(void) /********************************************************************** * i-mode = "we're inside a src-tree" * - * Find the abs path to top of source dir from Makefile + * Find the abs path to top of source dir from Makefile, if that + * fails, fall back on "../../" * * Set path to all programs build directories * @@ -337,7 +338,7 @@ i_mode(void) { const char *sep; struct vsb *vsb; - char *p; + char *p, *q; char *topbuild; /* @@ -345,37 +346,45 @@ i_mode(void) * makefiles. */ - p = read_file("Makefile"); - if (p == NULL) { - fprintf(stderr, "No Makefile for -i flag\n"); - exit(2); - } - p = strstr(p, "\nabs_top_builddir"); + vsb = VSB_new_auto(); + + q = p = read_file("Makefile_"); if (p == NULL) { - fprintf(stderr, - "could not find 'abs_top_builddir' in Makefile\n"); - exit(2); - } - topbuild = strchr(p + 1, '\n'); - if (topbuild == NULL) { - fprintf(stderr, - "No NL after 'abs_top_builddir' in Makefile\n"); - exit(2); - } - *topbuild = '\0'; - topbuild = strchr(p, '/'); - if (topbuild == NULL) { - fprintf(stderr, - "No '/' after 'abs_top_builddir' in Makefile\n"); - exit(2); - } + fprintf(stderr, "No Makefile to search for -i flag.\n"); + VSB_printf(vsb, "%s/../..", cwd); + AZ(VSB_finish(vsb)); + topbuild = strdup(VSB_data(vsb)); + VSB_clear(vsb); + } else { + p = strstr(p, "\nabs_top_builddir"); + if (p == NULL) { + fprintf(stderr, + "could not find 'abs_top_builddir' in Makefile\n"); + exit(2); + } + topbuild = strchr(p + 1, '\n'); + if (topbuild == NULL) { + fprintf(stderr, + "No NL after 'abs_top_builddir' in Makefile\n"); + exit(2); + } + *topbuild = '\0'; + topbuild = strchr(p, '/'); + if (topbuild == NULL) { + fprintf(stderr, + "No '/' after 'abs_top_builddir' in Makefile\n"); + exit(2); + } + topbuild = strdup(topbuild); + free(q); + } + AN(topbuild); extmacro_def("topbuild", "%s", topbuild); /* * Build $PATH which can find all programs in the build tree */ - vsb = VSB_new_auto(); AN(vsb); VSB_printf(vsb, "PATH="); sep = ""; From phk at varnish-cache.org Fri Nov 15 07:42:42 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Fri, 15 Nov 2013 08:42:42 +0100 Subject: [master] 18fd12a Make idle workers give up their VCL after a minute without work Message-ID: commit 18fd12a2fd6c6aca506f699140c1b842cca24a84 Author: Poul-Henning Kamp Date: Thu Nov 14 22:57:22 2013 +0000 Make idle workers give up their VCL after a minute without work Inspired by: An old patch from Mithrandir I found in my mailbox diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index ddf9fa2..a4a8e99 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -1047,7 +1047,7 @@ void Lck__Assert(const struct lock *lck, int held); /* public interface: */ void LCK_Init(void); void Lck_Delete(struct lock *lck); -int Lck_CondWait(pthread_cond_t *cond, struct lock *lck, struct timespec *ts); +int Lck_CondWait(pthread_cond_t *cond, struct lock *lck, double); #define Lck_New(a, b) Lck__New(a, b, #b) #define Lck_Lock(a) Lck__Lock(a, __func__, __FILE__, __LINE__) diff --git a/bin/varnishd/cache/cache_busyobj.c b/bin/varnishd/cache/cache_busyobj.c index 38da061..1e735b2 100644 --- a/bin/varnishd/cache/cache_busyobj.c +++ b/bin/varnishd/cache/cache_busyobj.c @@ -235,7 +235,7 @@ VBO_waitlen(struct busyobj *bo, ssize_t l) while (1) { if (bo->fetch_obj->len > l || bo->state >= BOS_FINISHED) break; - (void)Lck_CondWait(&bo->cond, &bo->mtx, NULL); + (void)Lck_CondWait(&bo->cond, &bo->mtx, 0); } l = bo->fetch_obj->len; Lck_Unlock(&bo->mtx); @@ -260,7 +260,7 @@ VBO_waitstate(struct busyobj *bo, enum busyobj_state_e want) while (1) { if (bo->state >= want) break; - (void)Lck_CondWait(&bo->cond, &bo->mtx, NULL); + (void)Lck_CondWait(&bo->cond, &bo->mtx, 0); } Lck_Unlock(&bo->mtx); } diff --git a/bin/varnishd/cache/cache_expire.c b/bin/varnishd/cache/cache_expire.c index e3feee9..88d49fb 100644 --- a/bin/varnishd/cache/cache_expire.c +++ b/bin/varnishd/cache/cache_expire.c @@ -564,7 +564,6 @@ exp_thread(struct worker *wrk, void *priv) struct objcore *oc; double t = 0, tnext = 0; struct exp_priv *ep; - struct timespec ts; CAST_OBJ_NOTNULL(ep, priv, EXP_PRIV_MAGIC); ep->wrk = wrk; @@ -581,9 +580,7 @@ exp_thread(struct worker *wrk, void *priv) } else if (tnext > t) { VSL_Flush(&ep->vsl, 0); WRK_SumStat(wrk); - ts.tv_nsec = (long)(modf(tnext, &t) * 1e9); - ts.tv_sec = (long)t; - (void)Lck_CondWait(&ep->condvar, &ep->mtx, &ts); + (void)Lck_CondWait(&ep->condvar, &ep->mtx, tnext); } Lck_Unlock(&ep->mtx); diff --git a/bin/varnishd/cache/cache_lck.c b/bin/varnishd/cache/cache_lck.c index 9b8444c..54203af 100644 --- a/bin/varnishd/cache/cache_lck.c +++ b/bin/varnishd/cache/cache_lck.c @@ -36,6 +36,7 @@ #include "config.h" #include +#include #include "cache.h" @@ -139,19 +140,23 @@ Lck__Assert(const struct lock *lck, int held) } int __match_proto__() -Lck_CondWait(pthread_cond_t *cond, struct lock *lck, struct timespec *ts) +Lck_CondWait(pthread_cond_t *cond, struct lock *lck, double when) { struct ilck *ilck; int retval = 0; + struct timespec ts; + double t; CAST_OBJ_NOTNULL(ilck, lck->priv, ILCK_MAGIC); AN(ilck->held); assert(pthread_equal(ilck->owner, pthread_self())); ilck->held = 0; - if (ts == NULL) { + if (when == 0) { AZ(pthread_cond_wait(cond, &ilck->mtx)); } else { - retval = pthread_cond_timedwait(cond, &ilck->mtx, ts); + ts.tv_nsec = (long)(modf(when, &t) * 1e9); + ts.tv_sec = (long)t; + retval = pthread_cond_timedwait(cond, &ilck->mtx, &ts); assert(retval == 0 || retval == ETIMEDOUT); } AZ(ilck->held); diff --git a/bin/varnishd/cache/cache_pool.c b/bin/varnishd/cache/cache_pool.c index 4308fb3..b22fe09 100644 --- a/bin/varnishd/cache/cache_pool.c +++ b/bin/varnishd/cache/cache_pool.c @@ -246,6 +246,7 @@ Pool_Work_Thread(void *priv, struct worker *wrk) struct pool *pp; int stats_clean; struct pool_task *tp; + int i; CAST_OBJ_NOTNULL(pp, priv, POOL_MAGIC); wrk->pool = pp; @@ -277,7 +278,12 @@ Pool_Work_Thread(void *priv, struct worker *wrk) VTAILQ_INSERT_HEAD(&pp->idle_queue, &wrk->task, list); if (!stats_clean) WRK_SumStat(wrk); - (void)Lck_CondWait(&wrk->cond, &pp->mtx, NULL); + do { + i = Lck_CondWait(&wrk->cond, &pp->mtx, + wrk->vcl == NULL ? 0 : wrk->lastused+60.); + if (i == ETIMEDOUT) + VCL_Rel(&wrk->vcl); + } while (i); tp = &wrk->task; } Lck_Unlock(&pp->mtx); @@ -405,7 +411,7 @@ pool_herder(void *priv) Lck_Lock(&pp->mtx); if (!pp->dry) { - (void)Lck_CondWait(&pp->herder_cond, &pp->mtx, NULL); + (void)Lck_CondWait(&pp->herder_cond, &pp->mtx, 0); } else { /* XXX: unsafe counters */ VSC_C_main->threads_limited++; From phk at varnish-cache.org Fri Nov 15 07:42:42 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Fri, 15 Nov 2013 08:42:42 +0100 Subject: [master] e928e75 Cleanup varnishd arguments, usage() and argument diagnostics. Message-ID: commit e928e75a202e57a33887b46564b65e8f1c6863eb Author: Poul-Henning Kamp Date: Thu Nov 14 23:33:39 2013 +0000 Cleanup varnishd arguments, usage() and argument diagnostics. diff --git a/bin/varnishd/common/common.h b/bin/varnishd/common/common.h index f72056a..7c98526 100644 --- a/bin/varnishd/common/common.h +++ b/bin/varnishd/common/common.h @@ -94,7 +94,7 @@ void mgt_child_inherit(int fd, const char *what); do { \ fprintf(stderr, "Error: " __VA_ARGS__); \ exit(2); \ - } while (0); + } while (0) #define NEEDLESS_RETURN(foo) return (foo) diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index 4292e7f..ae60029 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -152,6 +152,7 @@ usage(void) fprintf(stderr, FMT, "-d", "debug"); fprintf(stderr, FMT, "-f file", "VCL script"); fprintf(stderr, FMT, "-F", "Run in foreground"); + fprintf(stderr, FMT, "-g group", "Privilege separation group id"); fprintf(stderr, FMT, "-h kind[,hashoptions]", "Hash specification"); fprintf(stderr, FMT, "", " -h critbit [default]"); fprintf(stderr, FMT, "", " -h simple_list"); @@ -458,7 +459,7 @@ main(int argc, char * const *argv) cli_check(cli); while ((o = getopt(argc, argv, - "a:b:Cdf:Fg:h:i:l:L:M:n:P:p:r:S:s:T:t:u:Vx:w:")) != -1) + "a:b:Cdf:Fg:h:i:l:M:n:P:p:r:S:s:T:u:Vx:")) != -1) switch (o) { case 'a': MCF_ParamSet(cli, "listen_address", optarg); @@ -560,8 +561,6 @@ main(int argc, char * const *argv) } usage(); break; - case 'w': - ARGV_ERR("-w has been removed, use -p instead\n"); default: usage(); } @@ -571,97 +570,79 @@ main(int argc, char * const *argv) mgt_vcc_init(); - if (argc != 0) { - fprintf(stderr, "Too many arguments (%s...)\n", argv[0]); - usage(); - } + if (argc != 0) + ARGV_ERR("Too many arguments (%s...)\n", argv[0]); /* 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)); - exit(1); + ARGV_ERR("Failed parameter creation:\n%s\n", + VSB_data(cli[0].sb)); } - if (d_flag && F_flag) { - fprintf(stderr, "Only one of -d or -F can be specified\n"); - usage(); - } + if (d_flag && F_flag) + ARGV_ERR("Only one of -d or -F can be specified\n"); + + if (b_arg != NULL && f_arg != NULL) + ARGV_ERR("Only one of -b or -f can be specified\n"); - if (b_arg != NULL && f_arg != NULL) { - fprintf(stderr, "Only one of -b or -f can be specified\n"); - usage(); - } if (T_arg == NULL && d_flag == 0 && b_arg == NULL && - f_arg == NULL && M_arg == NULL) { - fprintf(stderr, - "At least one of -d, -b, -f, -M or -T " + f_arg == NULL && M_arg == NULL) + ARGV_ERR("At least one of -d, -b, -f, -M or -T " "must be specified\n"); - usage(); - } if (S_arg != NULL && *S_arg == '\0') fprintf(stderr, "Warning: Empty -S argument, no CLI authentication.\n"); + else if (S_arg != NULL) { + o = open(S_arg, O_RDONLY, 0); + if (o < 0) + ARGV_ERR("Cannot open -S file (%s): %s\n", + S_arg, strerror(errno)); + AZ(close(o)); + } if (f_arg != NULL) { vcl = VFIL_readfile(NULL, f_arg, NULL); - if (vcl == NULL) { - fprintf(stderr, "Cannot read '%s': %s\n", + if (vcl == NULL) + ARGV_ERR("Cannot read -f file (%s): %s\n", f_arg, strerror(errno)); - exit(1); - } } - if (VIN_N_Arg(n_arg, &heritage.name, &dirname, NULL) != 0) { - fprintf(stderr, "Invalid instance name: %s\n", - strerror(errno)); - exit(1); - } + if (VIN_N_Arg(n_arg, &heritage.name, &dirname, NULL) != 0) + ARGV_ERR("Invalid instance (-n) name: %s\n", strerror(errno)); - if (i_arg != NULL) { - if (snprintf(heritage.identity, sizeof heritage.identity, - "%s", i_arg) > sizeof heritage.identity) { - fprintf(stderr, "Invalid identity name: %s\n", - strerror(ENAMETOOLONG)); - exit(1); - } - } + if (i_arg != NULL && + snprintf(heritage.identity, sizeof heritage.identity, "%s", i_arg) + > sizeof heritage.identity) + ARGV_ERR("Invalid identity (-i) name: %s\n", + strerror(ENAMETOOLONG)); if (n_arg != NULL) openlog(n_arg, LOG_PID, LOG_LOCAL0); /* XXX: i_arg ? */ else openlog("varnishd", LOG_PID, LOG_LOCAL0); - if (mkdir(dirname, 0755) < 0 && errno != EEXIST) { - fprintf(stderr, "Cannot create working directory '%s': %s\n", + if (mkdir(dirname, 0755) < 0 && errno != EEXIST) + ARGV_ERR("Cannot create working directory '%s': %s\n", dirname, strerror(errno)); - exit(1); - } - if (chdir(dirname) < 0) { - fprintf(stderr, "Cannot change to working directory '%s': %s\n", + if (chdir(dirname) < 0) + ARGV_ERR("Cannot change to working directory '%s': %s\n", dirname, strerror(errno)); - exit(1); - } fd = open("_.testfile", O_RDWR|O_CREAT|O_EXCL, 0600); - if (fd < 0) { - fprintf(stderr, "Cannot create test-file in %s (%s)\n", + if (fd < 0) + ARGV_ERR("Error: Cannot create test-file in %s (%s)\n" + "Check permissions (or delete old directory)\n", dirname, strerror(errno)); - fprintf(stderr, - "Check permissions (or delete old directory)\n"); - exit(1); - } AZ(close(fd)); AZ(unlink("_.testfile")); /* XXX: should this be relative to the -n arg ? */ - if (P_arg && (pfh = VPF_Open(P_arg, 0644, NULL)) == NULL) { - perror(P_arg); - exit(1); - } + if (P_arg && (pfh = VPF_Open(P_arg, 0644, NULL)) == NULL) + ARGV_ERR("Could not open pid/lock (-P) file (%s): %s\n", + P_arg, strerror(errno)); if (b_arg != NULL || f_arg != NULL) if (mgt_vcc_default(b_arg, f_arg, vcl, C_flag)) @@ -671,11 +652,8 @@ main(int argc, char * const *argv) exit (0); if (!d_flag) { - if (MGT_open_sockets()) { - fprintf(stderr, - "Failed to open (any) accept sockets.\n"); - exit(1); - } + if (MGT_open_sockets()) + ARGV_ERR("Failed to open (any) accept sockets.\n"); MGT_close_sockets(); } @@ -695,15 +673,17 @@ main(int argc, char * const *argv) if (!d_flag && !F_flag) AZ(varnish_daemon(1, 0)); - if (pfh != NULL && VPF_Write(pfh)) - fprintf(stderr, "NOTE: Could not write PID file\n"); + /************************************************************** + * After this point diagnostics will only be seen with -d + */ + + assert(pfh == NULL || !VPF_Write(pfh)); if (d_flag) 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(); + mgt_pid = getpid(); /* daemon() changed this */ mgt_evb = vev_new_base(); XXXAN(mgt_evb); From phk at varnish-cache.org Fri Nov 15 07:42:42 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Fri, 15 Nov 2013 08:42:42 +0100 Subject: [master] 53cc831 Don't break -t just because it was unsorted, sort it instead. Message-ID: commit 53cc8318c63355c0f0e17b22a118ec92d6f762b6 Author: Poul-Henning Kamp Date: Fri Nov 15 07:42:25 2013 +0000 Don't break -t just because it was unsorted, sort it instead. diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index ae60029..cdd7ca6 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -180,13 +180,13 @@ usage(void) fprintf(stderr, FMT, "", " -s persist{experimenta}"); fprintf(stderr, FMT, "", " -s file,,,"); - fprintf(stderr, FMT, "-t", "Default TTL"); fprintf(stderr, FMT, "-S secret-file", "Secret file for CLI authentication"); fprintf(stderr, FMT, "-T address:port", "Telnet listen address and port"); - fprintf(stderr, FMT, "-V", "version"); + fprintf(stderr, FMT, "-t", "Default TTL"); fprintf(stderr, FMT, "-u user", "Privilege separation user id"); + fprintf(stderr, FMT, "-V", "version"); #undef FMT exit(1); } @@ -459,7 +459,7 @@ main(int argc, char * const *argv) cli_check(cli); while ((o = getopt(argc, argv, - "a:b:Cdf:Fg:h:i:l:M:n:P:p:r:S:s:T:u:Vx:")) != -1) + "a:b:Cdf:Fg:h:i:l:M:n:P:p:r:S:s:T:t:u:Vx:")) != -1) switch (o) { case 'a': MCF_ParamSet(cli, "listen_address", optarg); @@ -580,7 +580,7 @@ main(int argc, char * const *argv) VSB_data(cli[0].sb)); } - if (d_flag && F_flag) + if (d_flag && F_flag) ARGV_ERR("Only one of -d or -F can be specified\n"); if (b_arg != NULL && f_arg != NULL) From tfheen at varnish-cache.org Fri Nov 15 10:23:04 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Fri, 15 Nov 2013 11:23:04 +0100 Subject: [3.0] dc5fdf9 Document changes for 3.0.5 rc Message-ID: commit dc5fdf9ac38d24647118c14302af070928871d48 Author: Tollef Fog Heen Date: Fri Nov 15 11:22:58 2013 +0100 Document changes for 3.0.5 rc diff --git a/doc/changes.rst b/doc/changes.rst index f8d2d39..99a9f66 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -1,4 +1,41 @@ ================================ +Changes from 3.0.4 to 3.0.5 rc 1 +================================ + +varnishd +-------- + +- Stop printing error messages on ESI parse errors +- Fix a problem where Varnish would segfault if the first part of a + synthetic page was NULL. `Bug #1287` +- If streaming was used, you could in some cases end up with duplicate + content headers being sent to clients. `Bug #1272` +- If we receive a completely garbled request, don't pass through + vcl_error, since we could then end up in vcl_recv through a restart + and things would go downhill from there. `Bug #1367` +- Prettify backtraces on panic slightly. + +.. _bug #1287: http://varnish-cache.org/trac/ticket/1287 +.. _bug #1272: http://varnish-cache.org/trac/ticket/1272 +.. _bug #1367: http://varnish-cache.org/trac/ticket/1367 + +varnishlog +---------- + +- Correct an error where -m, -c and -b would interact badly, leading + to lack of matches. Also, emit BackendXID to signify the start of a + transaction. `Bug #1325` + +.. _bug #1325: http://varnish-cache.org/trac/ticket/1325 + +varnishadm +---------- + +- Handle input from stdin properly. `Bug #1314` + +.. _bug #1314: http://varnish-cache.org/trac/ticket/1314 + +================================ Changes from 3.0.4 rc 1 to 3.0.4 ================================ From phk at varnish-cache.org Mon Nov 18 20:21:04 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Mon, 18 Nov 2013 21:21:04 +0100 Subject: [master] fed96be Weaken the Etag whenever processing means that we do not deliver the exact same byte sequence from the backend, Gzip, Gunzip or ESI expansion. Message-ID: commit fed96be07b7d7bcc29ef46bb76001431e6ec80ff Author: Poul-Henning Kamp Date: Mon Nov 18 20:14:57 2013 +0000 Weaken the Etag whenever processing means that we do not deliver the exact same byte sequence from the backend, Gzip, Gunzip or ESI expansion. (See also: #940) diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index a4a8e99..5ed30c4 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -1206,6 +1206,8 @@ void RFC2616_Ttl(struct busyobj *); enum body_status RFC2616_Body(struct busyobj *, struct dstat *); unsigned RFC2616_Req_Gzip(const struct http *); int RFC2616_Do_Cond(const struct req *sp); +void RFC2616_Weaken_Etag(struct http *hp); + /* stevedore.c */ struct object *STV_NewObject(struct busyobj *, diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index ce74d35..914217e 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -308,14 +308,24 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) assert(bo->do_gzip == 0 || bo->do_gunzip == 0); /* ESI takes precedence and handles gzip/gunzip itself */ - if (bo->do_esi) + if (bo->do_esi) { bo->vfp = &vfp_esi; - else if (bo->do_gunzip) + /* + * The one case were we do not weaken Etag is where + * incoming obj is not gzip'ed and we don't gzip either + * If we ESI expand it on deliver, we weaken there. + */ + if (bo->is_gzip || bo->do_gzip | bo->do_gunzip) + RFC2616_Weaken_Etag(bo->beresp); + } else if (bo->do_gunzip) { bo->vfp = &vfp_gunzip; - else if (bo->do_gzip) + RFC2616_Weaken_Etag(bo->beresp); + } else if (bo->do_gzip) { bo->vfp = &vfp_gzip; - else if (bo->is_gzip) + RFC2616_Weaken_Etag(bo->beresp); + } else if (bo->is_gzip) { bo->vfp = &vfp_testgzip; + } if (bo->fetch_objcore->flags & OC_F_PRIVATE) AN(bo->uncacheable); diff --git a/bin/varnishd/cache/cache_http1_deliver.c b/bin/varnishd/cache/cache_http1_deliver.c index baf33d5..dc78078 100644 --- a/bin/varnishd/cache/cache_http1_deliver.c +++ b/bin/varnishd/cache/cache_http1_deliver.c @@ -261,6 +261,9 @@ V1D_Deliver(struct req *req) v1d_dorange(req, r); } + if (req->res_mode & RES_ESI) + RFC2616_Weaken_Etag(req->resp); + WRW_Reserve(req->wrk, &req->sp->fd, req->vsl, req->t_resp); /* diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index bab3b61..5502a4b 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -129,6 +129,10 @@ cnt_deliver(struct worker *wrk, struct req *req) http_SetHeader(req->resp, "Via: 1.1 varnish"); + if (cache_param->http_gzip_support && req->obj->gziped && + !RFC2616_Req_Gzip(req->http)) + RFC2616_Weaken_Etag(req->resp); + VCL_deliver_method(req->vcl, wrk, req, NULL, req->http->ws); /* Stop the insanity before it turns "Hotel California" on us */ diff --git a/bin/varnishd/cache/cache_rfc2616.c b/bin/varnishd/cache/cache_rfc2616.c index 66724ab..4bd45ca 100644 --- a/bin/varnishd/cache/cache_rfc2616.c +++ b/bin/varnishd/cache/cache_rfc2616.c @@ -346,3 +346,21 @@ RFC2616_Do_Cond(const struct req *req) return (do_cond); } + +/*--------------------------------------------------------------------*/ + +void +RFC2616_Weaken_Etag(struct http *hp) +{ + char *p; + + CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC); + + if (!http_GetHdr(hp, H_ETag, &p)) + return; + AN(p); + if (p[0] == 'W' && p[1] == '/') + return; + http_Unset(hp, H_ETag); + http_PrintfHeader(hp, "ETag: W/%s", p); +} diff --git a/bin/varnishtest/tests/r00940.vtc b/bin/varnishtest/tests/r00940.vtc new file mode 100644 index 0000000..0d41b38 --- /dev/null +++ b/bin/varnishtest/tests/r00940.vtc @@ -0,0 +1,96 @@ +varnishtest "GZIP, ESI and etags" + +server s1 { + rxreq + expect req.url == /1 + expect req.http.accept-encoding == "gzip" + txresp -hdr {ETag: "foo"} -gziplen 41 + + rxreq + expect req.url == /2 + txresp -hdr {ETag: "foo2"} -bodylen 42 + + rxreq + expect req.url == /3 + txresp -hdr {ETag: "foo3"} -body {

foo

} + + rxreq + expect req.url == /4 + txresp -hdr {ETag: "foo4"} -gzipbody { foo } +} -start + +varnish v1 -vcl+backend { + sub vcl_backend_response { + if (bereq.url == "/2") { + set beresp.do_gzip = true; + } + if (bereq.url == "/3" || bereq.url == "/4") { + set beresp.do_esi = true; + } + } + sub vcl_deliver { + if (req.http.foo == "noesi") { + set req.esi = false; + } + } +} -start + +client c1 { + # Straight through gzip, strong etag survives + txreq -url /1 -hdr "Accept-Encoding: gzip" + rxresp + expect resp.http.etag == {"foo"} + gunzip + expect resp.bodylen == 41 + + delay .2 + + # gzip in, gunzip out, weak etag + txreq -url /1 + rxresp + expect resp.http.etag == {W/"foo"} + expect resp.bodylen == 41 + + delay .2 + + # Gzip on input, weak etag + txreq -url /2 -hdr "Accept-Encoding: gzip" + rxresp + expect resp.http.etag == {W/"foo2"} + gunzip + expect resp.bodylen == 42 + + delay .2 + + # Gzip on input, gunzip on output, weak etag + txreq -url /2 + rxresp + expect resp.http.etag == {W/"foo2"} + expect resp.bodylen == 42 + + delay .2 + + # ESI expansion, weak etag + txreq -url /3 + rxresp + expect resp.http.etag == {W/"foo3"} + expect resp.bodylen == 8 + + delay .2 + + # ESI parse, but no expansion, strong etag + txreq -url /3 -hdr "foo: noesi" + rxresp + expect resp.http.etag == {"foo3"} + expect resp.bodylen == 38 + + delay .2 + + # ESI parse, no expansion, but re-gzipping, weak etag + txreq -url /4 -hdr "foo: noesi" -hdr "Accept-Encoding: gzip" + rxresp + expect resp.http.etag == {W/"foo4"} + gunzip + expect resp.bodylen == 40 + +} -run From martin at varnish-cache.org Tue Nov 19 16:37:57 2013 From: martin at varnish-cache.org (Martin Blix Grydeland) Date: Tue, 19 Nov 2013 17:37:57 +0100 Subject: [master] b5fa8c5 Move all output handling from VUT to the individual utilities. Message-ID: commit b5fa8c5fb3103514900194adf9314c6413b03c4d Author: Martin Blix Grydeland Date: Wed Nov 6 10:32:46 2013 +0100 Move all output handling from VUT to the individual utilities. diff --git a/bin/varnishlog/varnishlog.c b/bin/varnishlog/varnishlog.c index 571c7d7..2c216df 100644 --- a/bin/varnishlog/varnishlog.c +++ b/bin/varnishlog/varnishlog.c @@ -49,9 +49,20 @@ #include "vsb.h" #include "vtim.h" #include "vut.h" +#include "miniobj.h" static const char progname[] = "varnishlog"; +struct log { + /* Options */ + int a_opt; + int B_opt; + char *w_arg; + + /* State */ + FILE *fo; +} LOG; + static void usage(int status) { @@ -63,17 +74,68 @@ usage(int status) exit(status); } +static void +openout(int append) +{ + + AN(LOG.w_arg); + if (LOG.B_opt) + LOG.fo = VSL_WriteOpen(VUT.vsl, LOG.w_arg, append, VUT.u_opt); + else + LOG.fo = fopen(LOG.w_arg, append ? "a" : "w"); + if (LOG.fo == NULL) + VUT_Error(1, "Can't open output file (%s)", + LOG.B_opt ? VSL_Error(VUT.vsl) : strerror(errno)); + VUT.dispatch_priv = LOG.fo; +} + +static int __match_proto__(VUT_cb_f) +rotateout(void) +{ + + AN(LOG.w_arg); + AN(LOG.fo); + fclose(LOG.fo); + openout(0); + AN(LOG.fo); + return (0); +} + +static int __match_proto__(VUT_cb_f) +flushout(void) +{ + + AN(LOG.fo); + if (fflush(LOG.fo)) + return (-5); + return (0); +} + int main(int argc, char * const *argv) { char opt; + memset(&LOG, 0, sizeof LOG); VUT_Init(progname); while ((opt = getopt(argc, argv, vopt_optstring)) != -1) { switch (opt) { + case 'a': + /* Append to file */ + LOG.a_opt = 1; + break; + case 'B': + /* Binary output */ + LOG.B_opt = 1; + break; case 'h': + /* Usage help */ usage(0); + case 'w': + /* Write to file */ + REPLACE(LOG.w_arg, optarg); + break; default: if (!VUT_Arg(opt, optarg)) usage(1); @@ -83,9 +145,24 @@ main(int argc, char * const *argv) if (optind != argc) usage(1); + /* Setup output */ + if (LOG.B_opt) + VUT.dispatch_f = &VSL_WriteTransactions; + else + VUT.dispatch_f = &VSL_PrintTransactions; + if (LOG.w_arg) { + openout(LOG.a_opt); + AN(LOG.fo); + VUT.sighup_f = &rotateout; + } else + LOG.fo = stdout; + VUT.idle_f = &flushout; + VUT_Setup(); - VUT_Main(NULL, NULL); + VUT_Main(); VUT_Fini(); + (void)flushout(); + exit(0); } diff --git a/bin/varnishlog/varnishlog_options.h b/bin/varnishlog/varnishlog_options.h index b1e4c67..676edde 100644 --- a/bin/varnishlog/varnishlog_options.h +++ b/bin/varnishlog/varnishlog_options.h @@ -30,8 +30,28 @@ #include "vapi/vapi_options.h" #include "vut_options.h" -VUT_OPT_a +#define LOG_OPT_a \ + VOPT("a", "[-a]", "Append to file", \ + "When writing output to a file, append to it rather than" \ + " overwrite it." \ + ) + +#define LOG_OPT_B \ + VOPT("B", "[-B]", "Binary output", \ + "Output binary data suitable for reading with -r." \ + ) + +#define LOG_OPT_w \ + VOPT("w:", "[-w filename]", "Output filename", \ + "Redirect output to file. The file will be overwritten" \ + " unless the -a option was specified. If the application" \ + " receives a SIGHUP the file will be reopened allowing" \ + " the old one to be rotated away." \ + ) + +LOG_OPT_a VSL_OPT_b +LOG_OPT_B VSL_OPT_c VSL_OPT_C VUT_OPT_d @@ -50,6 +70,6 @@ VSL_OPT_T VUT_OPT_u VSL_OPT_v VUT_OPT_V -VUT_OPT_w +LOG_OPT_w VSL_OPT_x VSL_OPT_X diff --git a/include/vut.h b/include/vut.h index 5ba134b..4ddecc1 100644 --- a/include/vut.h +++ b/include/vut.h @@ -31,11 +31,12 @@ #include "vdef.h" +typedef int VUT_cb_f(void); + struct VUT { const char *progname; /* Options */ - int a_opt; int d_opt; int D_opt; int g_arg; @@ -43,17 +44,21 @@ struct VUT { char *q_arg; char *r_arg; int u_opt; - char *w_arg; /* State */ struct VSL_data *vsl; struct VSM_data *vsm; struct VSLQ *vslq; - FILE *fo; struct vpf_fh *pfh; int sighup; int sigint; int sigusr1; + + /* Callback functions */ + VUT_cb_f *idle_f; + VUT_cb_f *sighup_f; + VSLQ_dispatch_f *dispatch_f; + void *dispatch_priv; }; extern struct VUT VUT; @@ -71,4 +76,4 @@ void VUT_Init(const char *progname); void VUT_Fini(void); -int VUT_Main(VSLQ_dispatch_f *func, void *priv); +int VUT_Main(void); diff --git a/include/vut_options.h b/include/vut_options.h index 3437305..53a1e56 100644 --- a/include/vut_options.h +++ b/include/vut_options.h @@ -29,12 +29,6 @@ /* VUT options */ -#define VUT_OPT_a \ - VOPT("a", "[-a]", "Append binary file output", \ - "When writing binary output to a file, append to it rather" \ - " than overwrite it." \ - ) - #define VUT_OPT_d \ VOPT("d", "[-d]", "Process old log entries on startup", \ "Start processing log records at the head of the log" \ @@ -93,12 +87,3 @@ VOPT("V", "[-V]", "Version", \ "Print version information and exit." \ ) - -#define VUT_OPT_w \ - VOPT("w:", "[-w filename]", "Binary output filename", \ - "Write log entries to this file instead of displaying" \ - " them. The file will be overwritten unless the -a option" \ - " was specified. If the application receives a SIGHUP" \ - " while writing to a file, it will reopen the file" \ - " allowing the old one to be rotated away." \ - ) diff --git a/lib/libvarnishtools/vut.c b/lib/libvarnishtools/vut.c index b7e9c90..54c35c6 100644 --- a/lib/libvarnishtools/vut.c +++ b/lib/libvarnishtools/vut.c @@ -116,10 +116,6 @@ VUT_Arg(int opt, const char *arg) int i; switch (opt) { - case 'a': - /* Binary file append */ - VUT.a_opt = 1; - return (1); case 'd': /* Head */ VUT.d_opt = 1; @@ -168,10 +164,6 @@ VUT_Arg(int opt, const char *arg) /* Print version number and exit */ VCS_Message(VUT.progname); exit(1); - case 'w': - /* Binary file output */ - REPLACE(VUT.w_arg, arg); - return (1); default: AN(VUT.vsl); i = VSL_Arg(VUT.vsl, opt, arg); @@ -218,16 +210,6 @@ VUT_Setup(void) if (c == NULL) VUT_Error(1, "Can't open log (%s)", VSL_Error(VUT.vsl)); - /* Output */ - if (VUT.w_arg) { - VUT.fo = VSL_WriteOpen(VUT.vsl, VUT.w_arg, VUT.a_opt, - VUT.u_opt); - if (VUT.fo == NULL) - VUT_Error(1, "Can't open output file (%s)", - VSL_Error(VUT.vsl)); - } else - VUT.fo = stdout; - /* Create query */ VUT.vslq = VSLQ_New(VUT.vsl, &c, VUT.g_arg, VUT.q_arg); if (VUT.vslq == NULL) @@ -265,9 +247,6 @@ VUT_Fini(void) free(VUT.r_arg); free(VUT.P_arg); - if (VUT.fo != NULL) - fflush(VUT.fo); - vut_vpf_remove(); AZ(VUT.pfh); @@ -282,40 +261,28 @@ VUT_Fini(void) } int -VUT_Main(VSLQ_dispatch_f *func, void *priv) +VUT_Main(void) { struct VSL_cursor *c; int i = -1; AN(VUT.vslq); - if (func == NULL) { - if (VUT.w_arg) - func = VSL_WriteTransactions; - else - func = VSL_PrintTransactions; - AN(VUT.fo); - priv = VUT.fo; - } - while (!VUT.sigint) { - if (VUT.w_arg && VUT.sighup) { - /* Rotate log */ + if (VUT.sighup && VUT.sighup_f) { + /* sighup callback */ VUT.sighup = 0; - AN(VUT.fo); - fclose(VUT.fo); - VUT.fo = VSL_WriteOpen(VUT.vsl, VUT.w_arg, 0, - VUT.u_opt); - if (VUT.fo == NULL) - VUT_Error(1, "Can't open output file (%s)", - VSL_Error(VUT.vsl)); + i = (VUT.sighup_f)(); + if (i) + break; } if (VUT.sigusr1) { /* Flush and report any incomplete records */ VUT.sigusr1 = 0; if (VUT.vslq != NULL) - VSLQ_Flush(VUT.vslq, func, priv); + VSLQ_Flush(VUT.vslq, VUT.dispatch_f, + VUT.dispatch_priv); } if (VUT.vslq == NULL) { @@ -340,14 +307,17 @@ VUT_Main(VSLQ_dispatch_f *func, void *priv) VUT_Error(0, "Log reaquired"); } - i = VSLQ_Dispatch(VUT.vslq, func, priv); + i = VSLQ_Dispatch(VUT.vslq, VUT.dispatch_f, VUT.dispatch_priv); if (i == 1) /* Call again */ continue; else if (i == 0) { /* Nothing to do but wait */ - if (VUT.fo) - fflush(VUT.fo); + if (VUT.idle_f) { + i = (VUT.idle_f)(); + if (i) + break; + } VTIM_sleep(0.01); continue; } else if (i == -1) { @@ -360,7 +330,7 @@ VUT_Main(VSLQ_dispatch_f *func, void *priv) /* XXX: Make continuation optional */ - VSLQ_Flush(VUT.vslq, func, priv); + VSLQ_Flush(VUT.vslq, VUT.dispatch_f, VUT.dispatch_priv); VSLQ_Delete(&VUT.vslq); AZ(VUT.vslq); @@ -374,8 +344,5 @@ VUT_Main(VSLQ_dispatch_f *func, void *priv) } } - if (VUT.fo) - fflush(VUT.fo); - return (i); } From martin at varnish-cache.org Tue Nov 19 16:37:57 2013 From: martin at varnish-cache.org (Martin Blix Grydeland) Date: Tue, 19 Nov 2013 17:37:57 +0100 Subject: [master] ee9fbf5 Remove -u (unbuffered output) option. Message-ID: commit ee9fbf50434343ff15bdead47c943866c92c96d3 Author: Martin Blix Grydeland Date: Wed Nov 6 10:35:59 2013 +0100 Remove -u (unbuffered output) option. With proper flushing happening on idle, this option is obsolete. diff --git a/bin/varnishlog/varnishlog.c b/bin/varnishlog/varnishlog.c index 2c216df..b17cf6e 100644 --- a/bin/varnishlog/varnishlog.c +++ b/bin/varnishlog/varnishlog.c @@ -80,7 +80,7 @@ openout(int append) AN(LOG.w_arg); if (LOG.B_opt) - LOG.fo = VSL_WriteOpen(VUT.vsl, LOG.w_arg, append, VUT.u_opt); + LOG.fo = VSL_WriteOpen(VUT.vsl, LOG.w_arg, append, 0); else LOG.fo = fopen(LOG.w_arg, append ? "a" : "w"); if (LOG.fo == NULL) diff --git a/bin/varnishlog/varnishlog_options.h b/bin/varnishlog/varnishlog_options.h index 676edde..a70793b 100644 --- a/bin/varnishlog/varnishlog_options.h +++ b/bin/varnishlog/varnishlog_options.h @@ -67,7 +67,6 @@ VUT_OPT_P VUT_OPT_q VUT_OPT_r VSL_OPT_T -VUT_OPT_u VSL_OPT_v VUT_OPT_V LOG_OPT_w diff --git a/include/vut.h b/include/vut.h index 4ddecc1..4def288 100644 --- a/include/vut.h +++ b/include/vut.h @@ -43,7 +43,6 @@ struct VUT { char *P_arg; char *q_arg; char *r_arg; - int u_opt; /* State */ struct VSL_data *vsl; diff --git a/include/vut_options.h b/include/vut_options.h index 53a1e56..1d942ed 100644 --- a/include/vut_options.h +++ b/include/vut_options.h @@ -78,11 +78,6 @@ "Read log in binary file format from this file." \ ) -#define VUT_OPT_u \ - VOPT("u", "[-u]", "Binary file output unbuffered", \ - "Unbuffered binary file output mode." \ - ) - #define VUT_OPT_V \ VOPT("V", "[-V]", "Version", \ "Print version information and exit." \ diff --git a/lib/libvarnishtools/vut.c b/lib/libvarnishtools/vut.c index 54c35c6..4cf04fe 100644 --- a/lib/libvarnishtools/vut.c +++ b/lib/libvarnishtools/vut.c @@ -156,10 +156,6 @@ VUT_Arg(int opt, const char *arg) /* Binary file input */ REPLACE(VUT.r_arg, arg); return (1); - case 'u': - /* Unbuffered binary output */ - VUT.u_opt = 1; - return (1); case 'V': /* Print version number and exit */ VCS_Message(VUT.progname); From martin at varnish-cache.org Tue Nov 19 16:37:57 2013 From: martin at varnish-cache.org (Martin Blix Grydeland) Date: Tue, 19 Nov 2013 17:37:57 +0100 Subject: [master] 26647ab Export a grouping mode to string array from the API Message-ID: commit 26647ab038dbf4916c88ffd6a2d316ee9de12a27 Author: Martin Blix Grydeland Date: Fri Nov 15 16:24:37 2013 +0100 Export a grouping mode to string array from the API diff --git a/include/vapi/vsl.h b/include/vapi/vsl.h index 8fb008e..6d1308b 100644 --- a/include/vapi/vsl.h +++ b/include/vapi/vsl.h @@ -79,6 +79,7 @@ enum VSL_grouping_e { VSL_g_vxid, VSL_g_request, VSL_g_session, + VSL_g__MAX, }; typedef int VSLQ_dispatch_f(struct VSL_data *vsl, @@ -170,6 +171,11 @@ int VSL_List2Tags(const char *list, int l, VSL_tagfind_f *func, void *priv); * -3: Syntax error */ +extern const char *VSLQ_grouping[VSL_g__MAX]; + /* + * Grouping mode to string array. + */ + int VSLQ_Name2Grouping(const char *name, int l); /* * Convert string to grouping (= enum VSL_grouping_e) diff --git a/lib/libvarnishapi/libvarnishapi.map b/lib/libvarnishapi/libvarnishapi.map index 34f3851..2abb178 100644 --- a/lib/libvarnishapi/libvarnishapi.map +++ b/lib/libvarnishapi/libvarnishapi.map @@ -119,4 +119,5 @@ LIBVARNISHAPI_1.3 { VSL_List2Tags; VSM_N_Arg; # Variables: + VSLQ_grouping; } LIBVARNISHAPI_1.0; diff --git a/lib/libvarnishapi/vsl_arg.c b/lib/libvarnishapi/vsl_arg.c index eb0eda1..880ac44 100644 --- a/lib/libvarnishapi/vsl_arg.c +++ b/lib/libvarnishapi/vsl_arg.c @@ -183,7 +183,7 @@ VSL_List2Tags(const char *list, int l, VSL_tagfind_f *func, void *priv) return (t); } -static const char * const vsl_grouping[] = { +const char *VSLQ_grouping[VSL_g__MAX] = { [VSL_g_raw] = "raw", [VSL_g_vxid] = "vxid", [VSL_g_request] = "request", @@ -198,9 +198,9 @@ VSLQ_Name2Grouping(const char *name, int l) if (l == -1) l = strlen(name); n = -1; - for (i = 0; i < sizeof vsl_grouping / sizeof vsl_grouping[0]; i++) { - if (!strncasecmp(name, vsl_grouping[i], l)) { - if (strlen(vsl_grouping[i]) == l) { + for (i = 0; i < VSL_g__MAX; i++) { + if (!strncasecmp(name, VSLQ_grouping[i], l)) { + if (strlen(VSLQ_grouping[i]) == l) { /* Exact match */ return (i); } From martin at varnish-cache.org Tue Nov 19 16:37:57 2013 From: martin at varnish-cache.org (Martin Blix Grydeland) Date: Tue, 19 Nov 2013 17:37:57 +0100 Subject: [master] 1dfd93b Give error message on -f filter parse errors for VSC (and varnishstat) Message-ID: commit 1dfd93b14146425619682739fbcc2256337b3f99 Author: Martin Blix Grydeland Date: Mon Nov 18 14:20:57 2013 +0100 Give error message on -f filter parse errors for VSC (and varnishstat) diff --git a/bin/varnishstat/varnishstat.c b/bin/varnishstat/varnishstat.c index 72ad021..a11a44a 100644 --- a/bin/varnishstat/varnishstat.c +++ b/bin/varnishstat/varnishstat.c @@ -296,6 +296,7 @@ main(int argc, char * const *argv) default: if (VSC_Arg(vd, c, optarg) > 0) break; + fprintf(stderr, "%s\n", VSM_Error(vd)); usage(); } } diff --git a/lib/libvarnishapi/vsc.c b/lib/libvarnishapi/vsc.c index c617520..2df4d9e 100644 --- a/lib/libvarnishapi/vsc.c +++ b/lib/libvarnishapi/vsc.c @@ -226,6 +226,9 @@ vsc_f_arg(struct VSM_data *vd, const char *opt) if (q != NULL && q[1] == '\0') { *q = '\0'; sf->flags |= VSC_SF_TY_WC; + } else if (q != NULL) { + i = -1; + break; } } if (sf->ident != NULL) { @@ -233,6 +236,9 @@ vsc_f_arg(struct VSM_data *vd, const char *opt) if (q != NULL && q[1] == '\0') { *q = '\0'; sf->flags |= VSC_SF_ID_WC; + } else if (q != NULL) { + i = -1; + break; } } if (sf->name != NULL) { @@ -240,11 +246,18 @@ vsc_f_arg(struct VSM_data *vd, const char *opt) if (q != NULL && q[1] == '\0') { *q = '\0'; sf->flags |= VSC_SF_NM_WC; + } else if (q != NULL) { + i = -1; + break; } } } + if (i < 0) + i = vsm_diag(vd, "Wildcard error: %s", opt); + else + i = 1; VAV_Free(av); - return (1); + return (i); } /*--------------------------------------------------------------------*/ From martin at varnish-cache.org Tue Nov 19 16:37:57 2013 From: martin at varnish-cache.org (Martin Blix Grydeland) Date: Tue, 19 Nov 2013 17:37:57 +0100 Subject: [master] 154aea3 Fix parsing of -f arguments in varnishstat (and vsc) Message-ID: commit 154aea3248aa7465878f8261ef3b528c111d882e Author: Martin Blix Grydeland Date: Tue Nov 19 15:23:48 2013 +0100 Fix parsing of -f arguments in varnishstat (and vsc) Removed the comma-separated delimiting of this option parsing, as that conflicted with comma characters often used in backend names. Use multiple arguments to have several filters. Parser honors backslash escapes. This makes it possible to list names containing '.' (also common with backend names). Fixes: #957 diff --git a/bin/varnishstat/varnishstat.c b/bin/varnishstat/varnishstat.c index a11a44a..543b0e3 100644 --- a/bin/varnishstat/varnishstat.c +++ b/bin/varnishstat/varnishstat.c @@ -242,8 +242,7 @@ usage(void) VSC_n_USAGE " " "[-w delay]\n"); fprintf(stderr, FMT, "-1", "Print the statistics to stdout."); - fprintf(stderr, FMT, "-f field_list", - "Comma separated list of fields to display. "); + fprintf(stderr, FMT, "-f field_list", "Field inclusion glob"); fprintf(stderr, FMT, "", "If it starts with '^' it is used as an exclusion list"); fprintf(stderr, FMT, "-l", diff --git a/doc/sphinx/reference/varnishstat.rst b/doc/sphinx/reference/varnishstat.rst index 703df32..c27af28 100644 --- a/doc/sphinx/reference/varnishstat.rst +++ b/doc/sphinx/reference/varnishstat.rst @@ -30,8 +30,13 @@ The following options are available: -1 Instead of presenting of a continuously updated display, print the statistics to stdout. --f A comma separated list of the fields to display. If it starts with '^' it is used as an exclusion - list. +-f Field inclusion glob. A field glob consists of three + parts, type, ident and name, where ident is optional. Each + part can contain a '*' character at the end to match a + prefix. Use backslash to escape characters. If the + argument starts with '^' it is used as an exclusion + glob. Multiple -f arguments may be given, and they will be + applied in order. -l Lists the available fields to use with the -f option. diff --git a/lib/libvarnishapi/vsc.c b/lib/libvarnishapi/vsc.c index 2df4d9e..1ea0348 100644 --- a/lib/libvarnishapi/vsc.c +++ b/lib/libvarnishapi/vsc.c @@ -33,6 +33,7 @@ #include #include +#include #include #include #include @@ -44,7 +45,6 @@ #include "vapi/vsc.h" #include "vapi/vsm.h" #include "vapi/vsm_int.h" -#include "vav.h" #include "vqueue.h" #include "vsm_api.h" @@ -179,85 +179,106 @@ vsc_f_arg(struct VSM_data *vd, const char *opt) { struct vsc *vsc = vsc_setup(vd); struct vsc_sf *sf; - char **av, *q, *p; + const char *error = NULL; + const char *p, *q; + char *r; int i; + int flags = 0; + char *parts[3]; + + AN(vd); + AN(opt); - av = VAV_Parse(opt, NULL, ARGV_COMMA); - AN(av); - if (av[0] != NULL) { - i = vsm_diag(vd, "Parse error: %s", av[0]); - VAV_Free(av); - return (i); + if (opt[0] == '^') { + flags |= VSC_SF_EXCL; + opt++; } - for (i = 1; av[i] != NULL; i++) { - ALLOC_OBJ(sf, VSC_SF_MAGIC); - AN(sf); - VTAILQ_INSERT_TAIL(&vsc->sf_list, sf, list); - - p = av[i]; - if (*p == '^') { - sf->flags |= VSC_SF_EXCL; - p++; - } - q = strchr(p, '.'); - if (q != NULL) { - *q++ = '\0'; - if (*p != '\0') - REPLACE(sf->type, p); - p = q; - if (*p != '\0') { - q = strchr(p, '.'); - if (q != NULL) { - *q++ = '\0'; - if (*p != '\0') - REPLACE(sf->ident, p); - p = q; - } + /* Split on '.' */ + memset(parts, 0, sizeof parts); + for (i = 0, p = opt; *p != '\0'; i++) { + for (q = p; *q != '\0' && *q != '.'; q++) + if (*q == '\\') + q++; + if (i < 3) { + parts[i] = strndup(p, q - p); + AN(parts[i]); + p = r = parts[i]; + + /* Unescape */ + while (1) { + if (*p == '\\') + p++; + if (*p == '\0') + break; + *r++ = *p++; } + *r = '\0'; } - if (*p != '\0') { - REPLACE(sf->name, p); - } + p = q; + if (*p == '.') + p++; + } + if (i < 1 || i > 3) { + (void)vsm_diag(vd, "-f: Wrong number of elements"); + for (i = 0; i < 3; i++) + free(parts[i]); + return (-1); + } - /* Check for wildcards */ - if (sf->type != NULL) { - q = strchr(sf->type, '*'); - if (q != NULL && q[1] == '\0') { - *q = '\0'; - sf->flags |= VSC_SF_TY_WC; - } else if (q != NULL) { - i = -1; - break; - } - } - if (sf->ident != NULL) { - q = strchr(sf->ident, '*'); - if (q != NULL && q[1] == '\0') { - *q = '\0'; - sf->flags |= VSC_SF_ID_WC; - } else if (q != NULL) { - i = -1; - break; - } - } - if (sf->name != NULL) { - q = strchr(sf->name, '*'); - if (q != NULL && q[1] == '\0') { - *q = '\0'; - sf->flags |= VSC_SF_NM_WC; - } else if (q != NULL) { - i = -1; - break; - } - } + /* Set fields */ + ALLOC_OBJ(sf, VSC_SF_MAGIC); + AN(sf); + sf->flags = flags; + AN(parts[0]); + sf->type = parts[0]; + if (i == 2) { + AN(parts[1]); + sf->name = parts[1]; + } else if (i == 3) { + AN(parts[1]); + sf->ident = parts[1]; + AN(parts[2]); + sf->name = parts[2]; } - if (i < 0) - i = vsm_diag(vd, "Wildcard error: %s", opt); - else - i = 1; - VAV_Free(av); - return (i); + + /* Check for wildcards */ + if (sf->type != NULL) { + r = strchr(sf->type, '*'); + if (r != NULL && r[1] == '\0') { + *r = '\0'; + sf->flags |= VSC_SF_TY_WC; + } else if (r != NULL) + error = "-f: Wildcard not last"; + } + if (sf->ident != NULL) { + r = strchr(sf->ident, '*'); + if (r != NULL && r[1] == '\0') { + *r = '\0'; + sf->flags |= VSC_SF_ID_WC; + } else if (r != NULL) + error = "-f: Wildcard not last"; + } + if (sf->name != NULL) { + r = strchr(sf->name, '*'); + if (r != NULL && r[1] == '\0') { + *r = '\0'; + sf->flags |= VSC_SF_NM_WC; + } else if (r != NULL) + error = "-f: Wildcard not last"; + } + + if (error != NULL) { + (void)vsm_diag(vd, "%s", error); + free(sf->type); + free(sf->ident); + free(sf->name); + FREE_OBJ(sf); + return (-1); + } + + VTAILQ_INSERT_TAIL(&vsc->sf_list, sf, list); + return (1); } /*--------------------------------------------------------------------*/ From martin at varnish-cache.org Tue Nov 19 16:37:57 2013 From: martin at varnish-cache.org (Martin Blix Grydeland) Date: Tue, 19 Nov 2013 17:37:57 +0100 Subject: [master] 488e39e VarnishNCSA base64 implementation now takes a start and end ptr Message-ID: commit 488e39efbb8c83e547f34041da09af1ea44d9b14 Author: Martin Blix Grydeland Date: Tue Nov 19 16:26:28 2013 +0100 VarnishNCSA base64 implementation now takes a start and end ptr diff --git a/bin/varnishncsa/base64.c b/bin/varnishncsa/base64.c index 1c0979a..d7b2b89 100644 --- a/bin/varnishncsa/base64.c +++ b/bin/varnishncsa/base64.c @@ -6,6 +6,9 @@ #include "config.h" +#include +#include + #include "base64.h" static const char b64[] = @@ -27,17 +30,17 @@ VB64_init(void) } int -VB64_decode(char *d, unsigned dlen, const char *s) +VB64_decode(char *d, unsigned dlen, const char *s, const char *e) { unsigned u, v, l; int i; + if (e == NULL) + e = s + strlen(s); u = 0; l = 0; - while (*s) { - for (v = 0; v < 4; v++) { - if (!*s) - break; + while (s < e) { + for (v = 0; s < e && v < 4; v++) { i = i64[(int)*s++]; if (i < 0) return (-1); @@ -80,7 +83,7 @@ main(int argc, char **argv) VB64_init(); l = sizeof buf; - VB64_decode(buf, &l, test1); + VB64_decode(buf, l, test1, NULL); printf("%s\n", buf); return (0); } diff --git a/bin/varnishncsa/base64.h b/bin/varnishncsa/base64.h index 31b166c..526ae19 100644 --- a/bin/varnishncsa/base64.h +++ b/bin/varnishncsa/base64.h @@ -29,4 +29,4 @@ */ void VB64_init(void); -int VB64_decode(char *d, unsigned dlen, const char *s); +int VB64_decode(char *d, unsigned dlen, const char *s, const char *e); From martin at varnish-cache.org Tue Nov 19 16:37:57 2013 From: martin at varnish-cache.org (Martin Blix Grydeland) Date: Tue, 19 Nov 2013 17:37:57 +0100 Subject: [master] 4a0eee1 Beginnings of new varnishncsa Message-ID: commit 4a0eee12f23c65f3ff275e81ef630e8611a91ecd Author: Martin Blix Grydeland Date: Fri Nov 1 18:35:02 2013 +0100 Beginnings of new varnishncsa diff --git a/bin/Makefile.am b/bin/Makefile.am index 0700f27..124cb98 100644 --- a/bin/Makefile.am +++ b/bin/Makefile.am @@ -3,7 +3,7 @@ # Disabling building of the tools while api is in flux #SUBDIRS = varnishadm varnishd varnishlog varnishncsa varnishreplay varnishtest -SUBDIRS = varnishadm varnishd varnishlog varnishtest +SUBDIRS = varnishadm varnishd varnishlog varnishtest varnishncsa if VARNISH_CURSES #SUBDIRS += varnishhist varnishstat varnishtop diff --git a/bin/varnishncsa/Makefile.am b/bin/varnishncsa/Makefile.am index 7db8e89..9912d4c 100644 --- a/bin/varnishncsa/Makefile.am +++ b/bin/varnishncsa/Makefile.am @@ -8,18 +8,22 @@ dist_man_MANS = varnishncsa.1 varnishncsa_SOURCES = \ varnishncsa.c \ - base64.c \ + varnishncsa_options.h \ + varnishncsa_options.c \ base64.h \ - $(top_builddir)/lib/libvarnish/vas.c \ - $(top_builddir)/lib/libvarnish/flopen.c \ - $(top_builddir)/lib/libvarnish/version.c \ - $(top_builddir)/lib/libvarnish/vsb.c \ - $(top_builddir)/lib/libvarnish/vpf.c + base64.c \ + $(top_srcdir)/lib/libvarnishtools/vut.c \ + $(top_srcdir)/lib/libvarnish/vas.c \ + $(top_srcdir)/lib/libvarnish/flopen.c \ + $(top_srcdir)/lib/libvarnish/version.c \ + $(top_srcdir)/lib/libvarnish/vpf.c \ + $(top_srcdir)/lib/libvarnish/vtim.c \ + $(top_srcdir)/lib/libvarnish/vsb.c varnishncsa_LDADD = \ $(top_builddir)/lib/libvarnishcompat/libvarnishcompat.la \ $(top_builddir)/lib/libvarnishapi/libvarnishapi.la \ - ${RT_LIBS} ${LIBM} ${PTHREAD_LIBS} + ${RT_LIBS} ${LIBM} varnishncsa.1: $(top_srcdir)/doc/sphinx/reference/varnishncsa.rst if HAVE_RST2MAN diff --git a/bin/varnishncsa/varnishncsa.c b/bin/varnishncsa/varnishncsa.c index 4674974..43412fc 100644 --- a/bin/varnishncsa/varnishncsa.c +++ b/bin/varnishncsa/varnishncsa.c @@ -6,6 +6,7 @@ * Author: Anders Berg * Author: Poul-Henning Kamp * Author: Tollef Fog Heen + * Author: Martin Blix Grydeland * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -54,957 +55,860 @@ * %q Query string * %H Protocol version * - * TODO: - Maybe rotate/compress log */ #include "config.h" -#include -#include -#include -#include -#include #include +#include +#include #include -#include +#include +#include +#include +#include #include -#include #include "base64.h" -#include "vapi/vsl.h" #include "vapi/vsm.h" +#include "vapi/vsl.h" +#include "vapi/voptget.h" #include "vas.h" #include "vcs.h" -#include "vpf.h" -#include "vqueue.h" #include "vsb.h" +#include "vut.h" +#include "vqueue.h" +#include "miniobj.h" + +#define TIME_FMT "[%d/%b/%Y:%T %z]" +#define FORMAT "%h %l %u %t \"%r\" %s %b \"%{Referer}i\" \"%{User-agent}i\"" +static const char progname[] = "varnishncsa2"; + +struct format; +struct fragment; + +enum e_frag { + F_H, /* %H Proto */ + F_U, /* %U URL path */ + F_q, /* %q Query string */ + F_b, /* %b Bytes */ + F_h, /* %h Host name / IP Address */ + F_m, /* %m Method */ + F_s, /* %s Status */ + F_tstart, /* Time start */ + F_tend, /* Time end */ + F_ttfb, /* %{Varnish:time_firstbyte}x */ + F_host, /* Host header */ + F_auth, /* Authorization header */ + F__MAX, +}; -#include "compat/daemon.h" +struct fragment { + unsigned gen; + const char *b, *e; +}; + +typedef int format_f(const struct format *format); -static volatile sig_atomic_t reopen; +struct format { + unsigned magic; +#define FORMAT_MAGIC 0xC3119CDA -struct hdr { - char *key; - char *value; - VTAILQ_ENTRY(hdr) list; + VTAILQ_ENTRY(format) list; + format_f *func; + struct fragment *frag; + char *string; + const char *const *strptr; + char time_type; + char *time_fmt; }; -static struct logline { - char *df_H; /* %H, Protocol version */ - char *df_U; /* %U, URL path */ - char *df_q; /* %q, query string */ - char *df_b; /* %b, Bytes */ - char *df_h; /* %h (host name / IP adress)*/ - char *df_m; /* %m, Request method*/ - char *df_s; /* %s, Status */ - struct tm df_t; /* %t, Date and time, received */ - char *df_u; /* %u, Remote user */ - char *df_ttfb; /* Time to first byte */ - double df_D; /* %D, time taken to serve the request, - in microseconds, also used for %T */ - const char *df_hitmiss; /* Whether this is a hit or miss */ - 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 */ - uint64_t bitmap; /* Bitmap for regex matches */ - VTAILQ_HEAD(, hdr) req_headers; /* Request headers */ - VTAILQ_HEAD(, hdr) resp_headers; /* Response headers */ - VTAILQ_HEAD(, hdr) vcl_log; /* VLC_Log entries */ -} **ll; - -static struct VSM_data *vd; - -static size_t nll; - -static int m_flag = 0; - -static const char *c_format; -static const char *b_format; +struct watch { + unsigned magic; +#define WATCH_MAGIC 0xA7D4005C -static int -isprefix(const char *str, const char *prefix, const char *end, - const char **next) -{ - - while (str < end && *str && *prefix && - tolower((int)*str) == tolower((int)*prefix)) - ++str, ++prefix; - if (*str && *str != ' ') - return (0); - if (next) { - while (str < end && *str && *str == ' ') - ++str; - *next = str; - } - return (1); -} + VTAILQ_ENTRY(watch) list; + char *key; + unsigned keylen; + struct fragment frag; +}; +VTAILQ_HEAD(watch_head, watch); + +struct ctx { + /* Options */ + int a_opt; + char *w_arg; + + FILE *fo; + struct vsb *vsb; + unsigned gen; + VTAILQ_HEAD(,format) format; + + /* State */ + struct watch_head watch_vcl_log; + struct watch_head watch_reqhdr; + struct watch_head watch_resphdr; + struct fragment frag[F__MAX]; + const char *hitmiss; + const char *handling; +} CTX; -/* - * Returns a copy of the first consecutive sequence of non-space - * characters in the string in dst. dst will be free'd first if non-NULL. - */ static void -trimfield(char **dst, const char *str, const char *end) +usage(int status) { - size_t len; - - /* free if already set */ - if (*dst != NULL) { - free(*dst); - *dst = NULL; - } - - /* skip leading space */ - while (str < end && *str && *str == ' ') - ++str; + const char **opt; - /* seek to end of field */ - for (len = 0; &str[len] < end && str[len]; ++len) - if (str[len] == ' ') - break; - - /* copy and return */ - *dst = malloc(len + 1); - assert(*dst != NULL); - memcpy(*dst, str, len); - (*dst)[len] = '\0'; + fprintf(stderr, "Usage: %s \n\n", progname); + fprintf(stderr, "Options:\n"); + for (opt = vopt_usage; *opt != NULL; opt += 2) + fprintf(stderr, " %-25s %s\n", *opt, *(opt + 1)); + exit(status); } -/* - * Returns a copy of the entire string with leading and trailing spaces - * trimmed in dst. dst will be free'd first if non-NULL. - */ static void -trimline(char **dst, const char *str, const char *end) +openout(int append) { - size_t len; - - /* free if already set */ - if (*dst != NULL) { - free(*dst); - *dst = NULL; - } - /* skip leading space */ - while (str < end && *str && *str == ' ') - ++str; - - /* seek to end of string */ - for (len = 0; &str[len] < end && str[len]; ++len) - /* nothing */ ; - - /* trim trailing space */ - while (len && str[len - 1] == ' ') - --len; - - /* copy and return */ - *dst = malloc(len + 1); - assert(*dst != NULL); - memcpy(*dst, str, len); - (*dst)[len] = '\0'; + AN(CTX.w_arg); + CTX.fo = fopen(CTX.w_arg, append ? "a" : "w"); + if (CTX.fo == NULL) + VUT_Error(1, "Can't open output file (%s)", strerror(errno)); } -static char * -req_header(struct logline *l, const char *name) +static int __match_proto__(VUT_cb_f) +rotateout(void) { - struct hdr *h; - VTAILQ_FOREACH(h, &l->req_headers, list) { - if (strcasecmp(h->key, name) == 0) { - return (h->value); - } - } - return (NULL); -} -static char * -resp_header(struct logline *l, const char *name) -{ - struct hdr *h; - VTAILQ_FOREACH(h, &l->resp_headers, list) { - if (strcasecmp(h->key, name) == 0) { - return (h->value); - } - } - return (NULL); + AN(CTX.w_arg); + AN(CTX.fo); + fclose(CTX.fo); + openout(0); + AN(CTX.fo); + return (0); } -static char * -vcl_log(struct logline *l, const char *name) +static int __match_proto__(VUT_cb_f) +flushout(void) { - struct hdr *h; - VTAILQ_FOREACH(h, &l->vcl_log, list) { - if (strcasecmp(h->key, name) == 0) { - return (h->value); - } - } - return (NULL); + + AN(CTX.fo); + if (fflush(CTX.fo)) + return (-5); + return (0); } -static void -clean_logline(struct logline *lp) +static inline int +vsb_fcat(struct vsb *vsb, const struct fragment *f, const char *dflt) { - struct hdr *h, *h2; -#define freez(x) do { if (x) free(x); x = NULL; } while (0); - freez(lp->df_H); - freez(lp->df_U); - freez(lp->df_q); - freez(lp->df_b); - freez(lp->df_h); - freez(lp->df_m); - freez(lp->df_s); - freez(lp->df_u); - freez(lp->df_ttfb); - VTAILQ_FOREACH_SAFE(h, &lp->req_headers, list, h2) { - VTAILQ_REMOVE(&lp->req_headers, h, list); - freez(h->key); - freez(h->value); - freez(h); - } - VTAILQ_FOREACH_SAFE(h, &lp->resp_headers, list, h2) { - VTAILQ_REMOVE(&lp->resp_headers, h, list); - freez(h->key); - freez(h->value); - freez(h); - } - VTAILQ_FOREACH_SAFE(h, &lp->vcl_log, list, h2) { - VTAILQ_REMOVE(&lp->vcl_log, h, list); - freez(h->key); - freez(h->value); - freez(h); + + if (f->gen == CTX.gen) { + assert(f->b <= f->e); + return (VSB_bcat(vsb, f->b, f->e - f->b)); } -#undef freez - memset(lp, 0, sizeof *lp); + if (dflt) + return (VSB_cat(vsb, dflt)); + return (-1); } -static int -collect_backend(struct logline *lp, enum VSL_tag_e tag, unsigned spec, - const char *ptr, unsigned len) +static int __match_proto__(format_f) +format_string(const struct format *format) { - const char *end, *next, *split; - struct hdr *h; - size_t l; - - assert(spec & VSL_S_BACKEND); - end = ptr + len; - - switch (tag) { - case SLT_BackendOpen: - if (lp->active || lp->df_h != NULL) { - /* New start for active line, - clean it and start from scratch */ - clean_logline(lp); - } - lp->active = 1; - if (isprefix(ptr, "default", end, &next)) - trimfield(&lp->df_h, next, end); - else - trimfield(&lp->df_h, ptr, end); - break; - - case SLT_BereqMethod: - if (!lp->active) - break; - if (lp->df_m != NULL) { - clean_logline(lp); - break; - } - trimline(&lp->df_m, ptr, end); - break; - case SLT_BereqURL: { - char *qs; + CHECK_OBJ_NOTNULL(format, FORMAT_MAGIC); + AN(format->string); + AZ(VSB_cat(CTX.vsb, format->string)); + return (1); +} - if (!lp->active) - break; - if (lp->df_U != NULL || lp->df_q != NULL) { - clean_logline(lp); - break; - } - qs = memchr(ptr, '?', len); - if (qs) { - trimline(&lp->df_U, ptr, qs); - trimline(&lp->df_q, qs, end); - } else { - trimline(&lp->df_U, ptr, end); - } - break; - } +static int __match_proto__(format_f) +format_strptr(const struct format *format) +{ - case SLT_BereqProtocol: - if (!lp->active) - break; - if (lp->df_H != NULL) { - clean_logline(lp); - break; - } - trimline(&lp->df_H, ptr, end); - break; + CHECK_OBJ_NOTNULL(format, FORMAT_MAGIC); + AN(format->strptr); + AN(*format->strptr); + AZ(VSB_cat(CTX.vsb, *format->strptr)); + return (1); +} - case SLT_BerespStatus: - if (!lp->active) - break; - if (lp->df_s != NULL) { - clean_logline(lp); - break; - } - trimline(&lp->df_s, ptr, end); - break; +static int __match_proto__(format_f) +format_fragment(const struct format *format) +{ - case SLT_BereqHeader: - case SLT_BerespHeader: - if (!lp->active) - break; - split = memchr(ptr, ':', len); - if (split == NULL) - break; - if (tag == SLT_BerespHeader) { - if (isprefix(ptr, "content-length:", end, &next)) - trimline(&lp->df_b, next, end); - else if (isprefix(ptr, "date:", end, &next) && - strptime(next, "%a, %d %b %Y %T", &lp->df_t) == NULL) { - clean_logline(lp); - } - } else { - if (isprefix(ptr, "authorization:", end, &next) && - isprefix(next, "basic", end, &next)) { - trimline(&lp->df_u, next, end); - } - } - h = calloc(1, sizeof(struct hdr)); - AN(h); - AN(split); - l = strlen(split); - trimline(&h->key, ptr, split-1); - trimline(&h->value, split+1, split+l-1); - if (tag == SLT_BereqHeader) - VTAILQ_INSERT_HEAD(&lp->req_headers, h, list); - else - VTAILQ_INSERT_HEAD(&lp->resp_headers, h, list); - - case SLT_BackendReuse: - case SLT_BackendClose: - if (!lp->active) - break; - /* got it all */ - lp->complete = 1; - break; + CHECK_OBJ_NOTNULL(format, FORMAT_MAGIC); + AN(format->frag); - default: - break; + if (format->frag->gen != CTX.gen) { + if (format->string == NULL) + return (-1); + AZ(VSB_cat(CTX.vsb, format->string)); + return (0); } + AZ(vsb_fcat(CTX.vsb, format->frag, NULL)); return (1); } -static int -collect_client(struct logline *lp, enum VSL_tag_e tag, unsigned spec, - const char *ptr, unsigned len) +static int __match_proto__(format_f) +format_time(const struct format *format) { - const char *end, *next, *split; + double t_start, t_end; + char *p; + char buf[64]; time_t t; + struct tm tm; + + CHECK_OBJ_NOTNULL(format, FORMAT_MAGIC); + if (CTX.frag[F_tstart].gen != CTX.gen || + CTX.frag[F_tend].gen != CTX.gen) { + if (format->string == NULL) + return (-1); + AZ(VSB_cat(CTX.vsb, format->string)); + return (0); + } - assert(spec & VSL_S_CLIENT); - end = ptr + len; + t_start = strtod(CTX.frag[F_tstart].b, &p); + if (p != CTX.frag[F_tstart].e) + return (-1); + t_end = strtod(CTX.frag[F_tend].b, &p); + if (p != CTX.frag[F_tend].e) + return (-1); - switch (tag) { - case SLT_ReqStart: - if (lp->active || lp->df_h != NULL) { - /* New start for active line, - clean it and start from scratch */ - clean_logline(lp); - } - lp->active = 1; - trimfield(&lp->df_h, ptr, end); + switch (format->time_type) { + case 'D': + AZ(VSB_printf(CTX.vsb, "%f", t_end - t_start)); break; - - case SLT_ReqMethod: - if (!lp->active) - break; - if (lp->df_m != NULL) { - clean_logline(lp); - break; - } - trimline(&lp->df_m, ptr, end); + case 't': + AN(format->time_fmt); + t = t_start; + localtime_r(&t, &tm); + strftime(buf, sizeof buf, format->time_fmt, &tm); + AZ(VSB_cat(CTX.vsb, buf)); break; - - case SLT_ReqURL: { - char *qs; - - if (!lp->active) - break; - if (lp->df_U != NULL || lp->df_q != NULL) { - clean_logline(lp); - break; - } - qs = memchr(ptr, '?', len); - if (qs) { - trimline(&lp->df_U, ptr, qs); - trimline(&lp->df_q, qs, end); - } else { - trimline(&lp->df_U, ptr, end); - } + case 'T': + AZ(VSB_printf(CTX.vsb, "%d", (int)(t_end - t_start))); break; + default: + WRONG("Time format specifier"); } - case SLT_ReqProtocol: - if (!lp->active) - break; - if (lp->df_H != NULL) { - clean_logline(lp); - break; - } - trimline(&lp->df_H, ptr, end); - break; - - case SLT_ObjStatus: - if (!lp->active) - break; - if (lp->df_s != NULL) - clean_logline(lp); - else - trimline(&lp->df_s, ptr, end); - break; - - case SLT_ObjHeader: - case SLT_ReqHeader: - if (!lp->active) - break; - split = memchr(ptr, ':', len); - if (split == NULL) - break; - if (tag == SLT_ReqHeader && - isprefix(ptr, "authorization:", end, &next) && - isprefix(next, "basic", end, &next)) { - trimline(&lp->df_u, next, end); - } else { - struct hdr *h; - h = calloc(1, sizeof(struct hdr)); - AN(h); - AN(split); - trimline(&h->key, ptr, split); - trimline(&h->value, split+1, end); - if (tag == SLT_ReqHeader) - VTAILQ_INSERT_HEAD(&lp->req_headers, h, list); - else - VTAILQ_INSERT_HEAD(&lp->resp_headers, h, list); - } - break; - - case SLT_VCL_Log: - if(!lp->active) - break; - - split = memchr(ptr, ':', len); - if (split == NULL) - break; + return (1); +} - struct hdr *h; - h = calloc(1, sizeof(struct hdr)); - AN(h); - AN(split); +static int __match_proto__(format_f) +format_requestline(const struct format *format) +{ - trimline(&h->key, ptr, split); - trimline(&h->value, split+1, end); + (void)format; + AZ(vsb_fcat(CTX.vsb, &CTX.frag[F_m], "-")); + AZ(VSB_putc(CTX.vsb, ' ')); + if (CTX.frag[F_host].gen == CTX.gen) { + if (strncmp(CTX.frag[F_host].b, "http://", 7)) + AZ(VSB_cat(CTX.vsb, "http://")); + AZ(vsb_fcat(CTX.vsb, &CTX.frag[F_host], NULL)); + } else + AZ(VSB_cat(CTX.vsb, "http://localhost")); + AZ(vsb_fcat(CTX.vsb, &CTX.frag[F_U], "-")); + AZ(vsb_fcat(CTX.vsb, &CTX.frag[F_q], "")); + AZ(VSB_putc(CTX.vsb, ' ')); + AZ(vsb_fcat(CTX.vsb, &CTX.frag[F_H], "HTTP/1.0")); + return (1); +} - VTAILQ_INSERT_HEAD(&lp->vcl_log, h, list); - break; +static int __match_proto__(format_f) +format_auth(const struct format *format) +{ + char buf[128]; + char *q; + + if (CTX.frag[F_auth].gen != CTX.gen || + VB64_decode(buf, sizeof buf, CTX.frag[F_auth].b, + CTX.frag[F_auth].e)) { + if (format->string == NULL) + return (-1); + AZ(VSB_cat(CTX.vsb, format->string)); + return (0); + } + q = strchr(buf, ':'); + if (q != NULL) + *q = '\0'; + AZ(VSB_cat(CTX.vsb, buf)); + return (1); +} - case SLT_VCL_call: - if(!lp->active) - break; - if (strncmp(ptr, "hit", len) == 0) { - lp->df_hitmiss = "hit"; - lp->df_handling = "hit"; - } else if (strncmp(ptr, "miss", len) == 0) { - lp->df_hitmiss = "miss"; - lp->df_handling = "miss"; - } else if (strncmp(ptr, "pass", len) == 0) { - lp->df_hitmiss = "miss"; - lp->df_handling = "pass"; - } else if (strncmp(ptr, "error", len) == 0) { - /* Arguably, error isn't a hit or a miss, but - miss is less wrong */ - lp->df_hitmiss = "miss"; - lp->df_handling = "error"; - } else if (strncmp(ptr, "pipe", len) == 0) { - /* Just skip piped requests, since we can't - * print their status code */ - clean_logline(lp); - break; - } - break; +static int +print(void) +{ + const struct format *f; + int i, r = 1; + + VSB_clear(CTX.vsb); + VTAILQ_FOREACH(f, &CTX.format, list) { + i = (f->func)(f); + if (r > i) + r = i; + } + AZ(VSB_putc(CTX.vsb, '\n')); + AZ(VSB_finish(CTX.vsb)); + if (r >= 0) { + i = fwrite(VSB_data(CTX.vsb), 1, VSB_len(CTX.vsb), CTX.fo); + if (i != VSB_len(CTX.vsb)) + return (-5); + } + return (0); +} - case SLT_Length: - if (!lp->active) - break; - if (lp->df_b != NULL) { - clean_logline(lp); - break; - } - trimline(&lp->df_b, ptr, end); - break; +static void +addf_string(const char *str) +{ + struct format *f; + + AN(str); + ALLOC_OBJ(f, FORMAT_MAGIC); + AN(f); + f->func = &format_string; + f->string = strdup(str); + AN(f->string); + VTAILQ_INSERT_TAIL(&CTX.format, f, list); +} - case SLT_SessClose: - if (!lp->active) - break; - if (strncmp(ptr, "TX_PIPE", len) == 0 || - strncmp(ptr, "TX_ERROR", len) == 0) { - clean_logline(lp); - break; - } - break; +static void +addf_strptr(const char *const *strptr) +{ + struct format *f; + + AN(strptr); + ALLOC_OBJ(f, FORMAT_MAGIC); + AN(f); + f->func = &format_strptr; + f->strptr = strptr; + VTAILQ_INSERT_TAIL(&CTX.format, f, list); +} - case SLT_ReqEnd: - { - char ttfb[64]; - double t_start, t_end; - if (!lp->active) - break; - if (lp->df_ttfb != NULL || - sscanf(ptr, "%*u %lf %lf %*u.%*u %s", &t_start, &t_end, ttfb) - != 3) { - clean_logline(lp); - break; - } - if (lp->df_ttfb != NULL) - free(lp->df_ttfb); - lp->df_ttfb = strdup(ttfb); - lp->df_D = t_end - t_start; - t = t_start; - localtime_r(&t, &lp->df_t); - /* got it all */ - lp->complete = 1; - break; +static void +addf_fragment(struct fragment *frag, const char *str) +{ + struct format *f; + + AN(frag); + ALLOC_OBJ(f, FORMAT_MAGIC); + AN(f); + f->func = &format_fragment; + f->frag = frag; + if (str != NULL) { + f->string = strdup(str); + AN(f->string); } + VTAILQ_INSERT_TAIL(&CTX.format, f, list); +} - default: - break; +static void +addf_time(char type, const char *fmt, const char *str) +{ + struct format *f; + + ALLOC_OBJ(f, FORMAT_MAGIC); + AN(f); + f->func = &format_time; + f->time_type = type; + if (fmt != NULL) { + f->time_fmt = strdup(fmt); + AN(f->time_fmt); } + if (str != NULL) { + f->string = strdup(str); + AN(f->string); + } + VTAILQ_INSERT_TAIL(&CTX.format, f, list); +} - return (1); +static void +addf_requestline(void) +{ + struct format *f; + + ALLOC_OBJ(f, FORMAT_MAGIC); + AN(f); + f->func = &format_requestline; + VTAILQ_INSERT_TAIL(&CTX.format, f, list); } -static int -h_ncsa(void *priv, enum VSL_tag_e tag, unsigned fd, - unsigned len, unsigned spec, const char *ptr, uint64_t bitmap) +static void +addf_vcl_log(const char *key, const char *str) { - struct logline *lp; - FILE *fo = priv; - char *q, tbuf[64]; - const char *p; - struct vsb *os; - const char *format; - - /* XXX: Ignore fd's outside 65536 */ - if (fd >= 65536) - return (reopen); - - if (fd >= nll) { - struct logline **newll = ll; - size_t newnll = nll; - - while (fd >= newnll) - newnll += newnll + 1; - newll = realloc(newll, newnll * sizeof *newll); - assert(newll != NULL); - memset(newll + nll, 0, (newnll - nll) * sizeof *newll); - ll = newll; - nll = newnll; - } - if (ll[fd] == NULL) { - ll[fd] = calloc(sizeof *ll[fd], 1); - assert(ll[fd] != NULL); - } - lp = ll[fd]; - if (spec & VSL_S_BACKEND) { - collect_backend(lp, tag, spec, ptr, len); - format = b_format; - } else if (spec & VSL_S_CLIENT) { - collect_client(lp, tag, spec, ptr, len); - format = c_format; - } else { - /* huh? */ - return (reopen); + struct watch *w; + struct format *f; + + AN(key); + ALLOC_OBJ(w, WATCH_MAGIC); + AN(w); + w->key = strdup(key); + AN(w->key); + w->keylen = strlen(w->key); + VTAILQ_INSERT_TAIL(&CTX.watch_vcl_log, w, list); + + ALLOC_OBJ(f, FORMAT_MAGIC); + AN(f); + f->func = &format_fragment; + f->frag = &w->frag; + if (str != NULL) { + f->string = strdup(str); + AN(f->string); } + VTAILQ_INSERT_TAIL(&CTX.format, f, list); +} - lp->bitmap |= bitmap; - - if (!lp->complete) - return (reopen); +static void +addf_hdr(struct watch_head *head, const char *key, const char *str) +{ + struct watch *w; + struct format *f; + + AN(head); + AN(key); + ALLOC_OBJ(w, WATCH_MAGIC); + AN(w); + w->key = strdup(key); + AN(w->key); + w->keylen = strlen(w->key); + VTAILQ_INSERT_TAIL(head, w, list); + + ALLOC_OBJ(f, FORMAT_MAGIC); + AN(f); + f->func = &format_fragment; + f->frag = &w->frag; + if (str != NULL) { + f->string = strdup(str); + AN(f->string); + } + VTAILQ_INSERT_TAIL(&CTX.format, f, list); +} - if (m_flag && !VSL_Matched(vd, lp->bitmap)) - /* -o is in effect matching rule failed. Don't display */ - return (reopen); +static void +addf_auth(const char *str) +{ + struct format *f; -#if 0 - /* non-optional fields */ - if (!lp->df_m || !lp->df_U || !lp->df_H || !lp->df_s) { - clean_logline(lp); - return (reopen); + ALLOC_OBJ(f, FORMAT_MAGIC); + f->func = &format_auth; + if (str != NULL) { + f->string = strdup(str); + AN(f->string); } -#endif + VTAILQ_INSERT_TAIL(&CTX.format, f, list); +} - /* We have a complete data set - log a line */ +static void +parse_format(const char *format) +{ + const char *p, *q; + struct vsb *vsb; + char buf[256]; - fo = priv; - os = VSB_new_auto(); + vsb = VSB_new_auto(); + AN(vsb); for (p = format; *p != '\0'; p++) { - /* allow the most essential escape sequences in format. */ + /* Allow the most essential escape sequences in format */ if (*p == '\\') { p++; - if (*p == 't') VSB_putc(os, '\t'); - if (*p == 'n') VSB_putc(os, '\n'); + if (*p == 't') + AZ(VSB_putc(vsb, '\t')); + else if (*p == 'n') + AZ(VSB_putc(vsb, '\n')); + else if (*p != '\0') + AZ(VSB_putc(vsb, *p)); continue; } if (*p != '%') { - VSB_putc(os, *p); + AZ(VSB_putc(vsb, *p)); continue; } - p++; - switch (*p) { - case 'b': - /* %b */ - VSB_cat(os, lp->df_b ? lp->df_b : "-"); - break; + if (VSB_len(vsb) > 0) { + AZ(VSB_finish(vsb)); + addf_string(VSB_data(vsb)); + VSB_clear(vsb); + } - case 'D': - /* %D */ - VSB_printf(os, "%f", lp->df_D); + p++; + switch (*p) { + case 'b': /* Bytes */ + addf_fragment(&CTX.frag[F_b], "-"); break; - - case 'H': - VSB_cat(os, lp->df_H ? lp->df_H : "HTTP/1.0"); + case 'D': /* Float request time */ + addf_time(*p, NULL, NULL); break; - - case 'h': - if (!lp->df_h && spec & VSL_S_BACKEND) - VSB_cat(os, "127.0.0.1"); - else - VSB_cat(os, lp->df_h ? lp->df_h : "-"); + case 'h': /* Client host name / IP Address */ + addf_fragment(&CTX.frag[F_h], "-"); break; - case 'l': - VSB_putc(os, '-'); + case 'H': /* Protocol */ + addf_fragment(&CTX.frag[F_H], "HTTP/1.0"); break; - - case 'm': - VSB_cat(os, lp->df_m ? lp->df_m : "-"); + case 'l': /* Client user ID (identd) always '-' */ + AZ(VSB_putc(vsb, '-')); break; - - case 'q': - VSB_cat(os, lp->df_q ? lp->df_q : ""); + case 'm': /* Method */ + addf_fragment(&CTX.frag[F_m], "-"); break; - - case 'r': - /* - * Fake "%r". This would be a lot easier if Varnish - * normalized the request URL. - */ - VSB_cat(os, lp->df_m ? lp->df_m : "-"); - VSB_putc(os, ' '); - if (req_header(lp, "Host")) { - if (strncmp(req_header(lp, "Host"), - "http://", 7) != 0) - VSB_cat(os, "http://"); - VSB_cat(os, req_header(lp, "Host")); - } else { - VSB_cat(os, "http://localhost"); - } - VSB_cat(os, lp->df_U ? lp->df_U : "-"); - VSB_cat(os, lp->df_q ? lp->df_q : ""); - VSB_putc(os, ' '); - VSB_cat(os, lp->df_H ? lp->df_H : "HTTP/1.0"); + case 'q': /* Query string */ + addf_fragment(&CTX.frag[F_q], ""); break; - - case 's': - /* %s */ - VSB_cat(os, lp->df_s ? lp->df_s : ""); + case 'r': /* Request line */ + addf_requestline(); break; - - case 't': - /* %t */ - strftime(tbuf, sizeof tbuf, - "[%d/%b/%Y:%T %z]", &lp->df_t); - VSB_cat(os, tbuf); + case 's': /* Status code */ + addf_fragment(&CTX.frag[F_s], ""); break; - - case 'T': - /* %T */ - VSB_printf(os, "%d", (int)lp->df_D); + case 't': /* strftime */ + addf_time(*p, TIME_FMT, NULL); break; - - case 'U': - VSB_cat(os, lp->df_U ? lp->df_U : "-"); + case 'T': /* Int request time */ + addf_time(*p, NULL, NULL); break; - case 'u': - /* %u: decode authorization string */ - if (lp->df_u != NULL) { - char *rubuf; - size_t rulen; - - VB64_init(); - rulen = ((strlen(lp->df_u) + 3) * 4) / 3; - rubuf = malloc(rulen); - assert(rubuf != NULL); - VB64_decode(rubuf, rulen, lp->df_u); - q = strchr(rubuf, ':'); - if (q != NULL) - *q = '\0'; - VSB_cat(os, rubuf); - free(rubuf); - } else { - VSB_putc(os, '-'); - } + addf_auth("-"); break; - - case '{': { - const char *h, *tmp; - char fname[100], type; - tmp = p; - type = 0; - while (*tmp != '\0' && *tmp != '}') - tmp++; - if (*tmp == '}') { - tmp++; - type = *tmp; - memcpy(fname, p+1, tmp-p-2); - fname[tmp-p-2] = 0; - } - - switch (type) { + case 'U': /* URL */ + addf_fragment(&CTX.frag[F_U], "-"); + break; + case '{': + p++; + q = p; + while (*q && *q != '}') + q++; + if (!*q) + VUT_Error(1, "Unmatched bracket at: %s", p - 2); + assert(q - p < sizeof buf - 1); + strncpy(buf, p, q - p); + buf[q - p] = '\0'; + q++; + switch (*q) { case 'i': - h = req_header(lp, fname); - VSB_cat(os, h ? h : "-"); - p = tmp; + strcat(buf, ":"); + addf_hdr(&CTX.watch_reqhdr, buf, "-"); break; case 'o': - h = resp_header(lp, fname); - VSB_cat(os, h ? h : "-"); - p = tmp; + strcat(buf, ":"); + addf_hdr(&CTX.watch_resphdr, buf, "-"); break; case 't': - strftime(tbuf, sizeof tbuf, fname, &lp->df_t); - VSB_cat(os, tbuf); - p = tmp; + addf_time(*q, buf, NULL); break; case 'x': - if (!strcmp(fname, "Varnish:time_firstbyte")) { - VSB_cat(os, lp->df_ttfb); - p = tmp; + if (!strcmp(buf, "Varnish:time_firstbyte")) { + addf_fragment(&CTX.frag[F_ttfb], ""); break; - } else if (!strcmp(fname, "Varnish:hitmiss")) { - VSB_cat(os, (lp->df_hitmiss ? - lp->df_hitmiss : "-")); - p = tmp; + } + if (!strcmp(buf, "Varnish:hitmiss")) { + addf_strptr(&CTX.hitmiss); break; - } else if (!strcmp(fname, "Varnish:handling")) { - VSB_cat(os, (lp->df_handling ? - lp->df_handling : "-")); - p = tmp; + } + if (!strcmp(buf, "Varnish:handling")) { + addf_strptr(&CTX.handling); break; - } else if (!strncmp(fname, "VCL_Log:", 8)) { - // support pulling entries logged - // with std.log() into output. - // Format: %{VCL_Log:keyname}x - // Logging: std.log("keyname:value") - h = vcl_log(lp, fname+8); - VSB_cat(os, h ? h : "-"); - p = tmp; + } + if (!strncmp(buf, "VCL_Log:", 8)) { + addf_vcl_log(buf + 8, ""); break; } /* FALLTHROUGH */ default: - fprintf(stderr, - "Unknown format starting at: %s\n", --p); - exit(1); + VUT_Error(1, "Unknown format specifier at: %s", + p - 2); } + p = q; break; - } - /* Fall through if we haven't handled something */ - /* FALLTHROUGH*/ default: - fprintf(stderr, - "Unknown format starting at: %s\n", --p); - exit(1); + VUT_Error(1, "Unknown format specifier at: %s", p - 1); } } - VSB_putc(os, '\n'); - /* flush the stream */ - VSB_finish(os); - fprintf(fo, "%s", VSB_data(os)); - fflush(fo); + if (VSB_len(vsb) > 0) { + /* Add any remaining static */ + AZ(VSB_finish(vsb)); + addf_string(VSB_data(vsb)); + VSB_clear(vsb); + } - /* clean up */ - clean_logline(lp); - VSB_delete(os); - return (reopen); + VSB_delete(vsb); } -/*--------------------------------------------------------------------*/ - -static void -sighup(int sig) +static int +isprefix(const char *str, const char *prefix, const char *end, + const char **next) { - (void)sig; - reopen = 1; + while (str < end && *str && *prefix && + tolower((int)*str) == tolower((int)*prefix)) + ++str, ++prefix; + if (*str && *str != ' ') + return (0); + if (next) { + while (str < end && *str && *str == ' ') + ++str; + *next = str; + } + return (1); } -static FILE * -open_log(const char *ofn, int append) +static void +frag_fields(const char *b, const char *e, ...) { - FILE *of; - - if ((of = fopen(ofn, append ? "a" : "w")) == NULL) { - perror(ofn); - exit(1); + va_list ap; + const char *p, *q; + int n, field; + struct fragment *frag; + + AN(b); + AN(e); + va_start(ap, e); + + field = va_arg(ap, int); + frag = va_arg(ap, struct fragment *); + for (n = 1, q = b; q < e; n++) { + assert(field > 0); + AN(frag); + + p = q; + /* Skip WS */ + while (p < e && isspace(*p)) + p++; + q = p; + /* Skip non-WS */ + while (q < e && !isspace(*q)) + q++; + + if (field == n) { + frag->gen = CTX.gen; + frag->b = p; + frag->e = q; + field = va_arg(ap, int); + if (field == 0) + break; + frag = va_arg(ap, struct fragment *); + } } - return (of); + va_end(ap); } -/*--------------------------------------------------------------------*/ +static void +frag_line(const char *b, const char *e, struct fragment *f) +{ + + /* Skip leading space */ + while (b < e && isspace(*b)) + ++b; + + /* Skip trailing space */ + while (e > b && isspace(*(e - 1))) + --e; + + f->gen = CTX.gen; + f->b = b; + f->e = e; +} static void -usage(void) +process_hdr(const struct watch_head *head, const char *b, const char *e) { + struct watch *w; - fprintf(stderr, - "usage: varnishncsa %s [-afDV] [-n varnish_name] " - "[-P file] [-w file] [-F format] \n", VSL_USAGE); - exit(1); + VTAILQ_FOREACH(w, head, list) { + if (strncasecmp(b, w->key, w->keylen)) + continue; + frag_line(b + w->keylen, e, &w->frag); + } } -int -main(int argc, char *argv[]) +static int __match_proto__(VSLQ_dispatch_f) +dispatch_f(struct VSL_data *vsl, struct VSL_transaction * const pt[], + void *priv) { - int c; - int a_flag = 0, D_flag = 0, format_flag = 0, b_flag = 0; - const char *P_arg = NULL; - const char *w_arg = NULL; - struct vpf_fh *pfh = NULL; - FILE *of; - c_format = "%h %l %u %t \"%r\" %s %b \"%{Referer}i\" \"%{User-agent}i\""; - b_format = "%h %l %u %t \"%r\" %s %b \"%{Referer}i\" \"%{User-agent}i\""; - - vd = VSM_New(); - - while ((c = getopt(argc, argv, VSL_ARGS "aDP:Vw:fF:B:C:")) != -1) { - switch (c) { - case 'a': - a_flag = 1; - break; - case 'f': - case 'F': - if (format_flag) { - fprintf(stderr, - "-f, -F, -B or -C can not be combined\n"); - exit(1); - } - format_flag = 1; - switch (c) { - case 'f': - b_format = c_format = - "%{X-Forwarded-For}i %l %u %t \"%r\"" - " %s %b \"%{Referer}i\" \"%{User-agent}i\""; + struct VSL_transaction *t; + unsigned tag; + const char *b, *e, *p; + struct watch *w; + int i; + + (void)vsl; + (void)priv; + + for (t = pt[0]; t != NULL; t = *++pt) { + CTX.gen++; + if (t->type != VSL_t_req) + continue; + CTX.hitmiss = "-"; + CTX.handling = "-"; + while ((1 == VSL_Next(t->c))) { + tag = VSL_TAG(t->c->rec.ptr); + b = VSL_CDATA(t->c->rec.ptr); + e = b + VSL_LEN(t->c->rec.ptr); + + switch (tag) { + case SLT_ReqStart: + frag_fields(b, e, 1, &CTX.frag[F_h], 0, NULL); + break; + case SLT_ReqMethod: + frag_line(b, e, &CTX.frag[F_m]); + break; + case SLT_ReqURL: + p = memchr(b, '?', e - b); + if (p == NULL) + p = e; + frag_line(b, e, &CTX.frag[F_U]); + frag_line(b, e, &CTX.frag[F_q]); + break; + case SLT_ReqProtocol: + frag_line(b, e, &CTX.frag[F_H]); + break; + case SLT_RespStatus: + frag_line(b, e, &CTX.frag[F_s]); + break; + case SLT_Length: + frag_line(b, e, &CTX.frag[F_b]); break; - case 'F': - b_format = c_format = optarg; + case SLT_ReqEnd: + frag_fields(b, e, 1, &CTX.frag[F_tstart], + 2, &CTX.frag[F_tend], 3, &CTX.frag[F_ttfb], + 0, NULL); break; - case 'B': - b_format = optarg; + case SLT_ReqHeader: + if (isprefix(b, e, "Host:", &p)) + frag_line(p, e, &CTX.frag[F_host]); + else if (isprefix(b, "Authorization:", e, &p) && + isprefix(p, "basic", e, &p)) + frag_line(p, e, &CTX.frag[F_auth]); break; - case 'C': - c_format = optarg; + case SLT_VCL_call: + if (!strcasecmp(b, "recv")) { + CTX.hitmiss = "-"; + CTX.handling = "-"; + } else if (!strcasecmp(b, "hit")) { + CTX.hitmiss = "hit"; + CTX.handling = "hit"; + } else if (!strcasecmp(b, "miss")) { + CTX.hitmiss = "miss"; + CTX.handling = "miss"; + } else if (!strcasecmp(b, "pass")) { + CTX.hitmiss = "miss"; + CTX.handling = "pass"; + } else if (!strcasecmp(b, "error")) { + /* Arguably, error isn't a hit or + a miss, but miss is less + wrong */ + CTX.hitmiss = "miss"; + CTX.handling = "error"; + } else if (!strcasecmp(b, "pipe")) { + CTX.hitmiss = "miss"; + CTX.handling = "pipe"; + } + break; + default: break; } + + if (tag == SLT_VCL_Log) { + VTAILQ_FOREACH(w, &CTX.watch_vcl_log, list) { + CHECK_OBJ_NOTNULL(w, WATCH_MAGIC); + if (strncmp(b, w->key, w->keylen)) + continue; + p = b + w->keylen; + if (*p != ':') + continue; + p++; + if (p > e) + continue; + frag_line(p, e, &w->frag); + } + } + if (tag == SLT_ReqHeader) + process_hdr(&CTX.watch_reqhdr, b, e); + if (tag == SLT_RespHeader) + process_hdr(&CTX.watch_resphdr, b, e); + } + i = print(); + if (i) + return (i); + } + + return (0); +} + +int +main(int argc, char * const *argv) +{ + char opt; + char *format = NULL; + + memset(&CTX, 0, sizeof CTX); + VTAILQ_INIT(&CTX.format); + VTAILQ_INIT(&CTX.watch_vcl_log); + VTAILQ_INIT(&CTX.watch_reqhdr); + VTAILQ_INIT(&CTX.watch_resphdr); + CTX.vsb = VSB_new_auto(); + AN(CTX.vsb); + VB64_init(); + VUT_Init(progname); + + while ((opt = getopt(argc, argv, vopt_optstring)) != -1) { + switch (opt) { + case 'a': + /* Append to file */ + CTX.a_opt = 1; break; - case 'D': - D_flag = 1; - break; - case 'P': - P_arg = optarg; + case 'F': + /* Format string */ + if (format != NULL) + free(format); + format = strdup(optarg); + AN(format); break; - case 'V': - VCS_Message("varnishncsa"); - exit(0); + case 'h': + /* Usage help */ + usage(0); case 'w': - w_arg = optarg; - break; - case 'b': - b_flag = 1; - if (VSL_Arg(vd, c, optarg) > 0) - break; - usage(); - break; - case 'i': - fprintf(stderr, "-i is not valid for varnishncsa\n"); - exit(1); - break; - case 'I': - fprintf(stderr, "-I is not valid for varnishncsa\n"); - exit(1); + /* Write to file */ + REPLACE(CTX.w_arg, optarg); break; - case 'c': - /* XXX: Silently ignored: it's required anyway */ - break; - case 'm': - m_flag = 1; - /* FALLTHOUGH */ default: - if (VSL_Arg(vd, c, optarg) > 0) - break; - usage(); + if (!VUT_Arg(opt, optarg)) + usage(1); } } - if (! b_flag) - VSL_Arg(vd, 'c', optarg); - - if (VSM_Open(vd)) { - fprintf(stderr, "%s\n", VSM_Error(vd)); - return (-1); - } - - if (P_arg && (pfh = VPF_Open(P_arg, 0644, NULL)) == NULL) { - perror(P_arg); - exit(1); - } - - if (D_flag && varnish_daemon(0, 0) == -1) { - perror("daemon()"); - if (pfh != NULL) - VPF_Remove(pfh); - exit(1); - } - - if (pfh != NULL) - VPF_Write(pfh); - - if (w_arg) { - of = open_log(w_arg, a_flag); - signal(SIGHUP, sighup); - } else { - w_arg = "stdout"; - of = stdout; - } - - while (VSL_Dispatch(vd, h_ncsa, of) >= 0) { - if (fflush(of) != 0) { - perror(w_arg); - exit(1); - } - if (reopen && of != stdout) { - fclose(of); - of = open_log(w_arg, a_flag); - reopen = 0; - } - } + if (optind != argc) + usage(1); + + /* Check for valid grouping mode */ + assert(VUT.g_arg < VSL_g__MAX); + if (VUT.g_arg != VSL_g_vxid && VUT.g_arg != VSL_g_request) + VUT_Error(1, "Invalid grouping mode: %s", + VSLQ_grouping[VUT.g_arg]); + + /* Prepare output format */ + if (format == NULL) + format = strdup(FORMAT); + parse_format(format); + free(format); + format = NULL; + + /* Setup output */ + VUT.dispatch_f = &dispatch_f; + VUT.dispatch_priv = NULL; + if (CTX.w_arg) { + openout(CTX.a_opt); + AN(CTX.fo); + VUT.sighup_f = &rotateout; + } else + CTX.fo = stdout; + VUT.idle_f = &flushout; + + VUT_Setup(); + VUT_Main(); + VUT_Fini(); exit(0); } diff --git a/bin/varnishncsa/varnishncsa_options.c b/bin/varnishncsa/varnishncsa_options.c new file mode 100644 index 0000000..91fb2e0 --- /dev/null +++ b/bin/varnishncsa/varnishncsa_options.c @@ -0,0 +1,34 @@ +/*- + * Copyright (c) 2013 Varnish Software AS + * All rights reserved. + * + * Author: Martin Blix Grydeland + * + * 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. + * + * Option definitions for varnishlog + */ + +#include +#define VOPT_DEFINITION +#define VOPT_INC "varnishncsa_options.h" +#include "vapi/voptget.h" diff --git a/bin/varnishncsa/varnishncsa_options.h b/bin/varnishncsa/varnishncsa_options.h new file mode 100644 index 0000000..346b7fc --- /dev/null +++ b/bin/varnishncsa/varnishncsa_options.h @@ -0,0 +1,69 @@ +/*- + * Copyright (c) 2013 Varnish Software AS + * All rights reserved. + * + * Author: Martin Blix Grydeland + * + * 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 "vapi/vapi_options.h" +#include "vut_options.h" + +#define NCSA_OPT_a \ + VOPT("a", "[-a]", "Append to file", \ + "When writing output to a file, append to it rather than" \ + " overwrite it." \ + ) + +#define NCSA_OPT_F \ + VOPT("F:", "[-F format]", "Set output format", \ + "Set the output log format string." \ + ) + +#define NCSA_OPT_g \ + VOPT("g:", "[-g ]", "Grouping mode", \ + "The grouping of the log records. The default is to group" \ + " by vxid." \ + ) + +#define NCSA_OPT_w \ + VOPT("w:", "[-w filename]", "Output filename", \ + "Redirect output to file. The file will be overwritten" \ + " unless the -a option was specified. If the application" \ + " receives a SIGHUP the file will be reopened allowing" \ + " the old one to be rotated away." \ + ) + +NCSA_OPT_a +VSL_OPT_C +VUT_OPT_d +VUT_OPT_D +NCSA_OPT_F +NCSA_OPT_g +VUT_OPT_h +VUT_OPT_n +VUT_OPT_N +VUT_OPT_P +VUT_OPT_q +VUT_OPT_V +NCSA_OPT_w diff --git a/configure.ac b/configure.ac index 42a427c..905d131 100644 --- a/configure.ac +++ b/configure.ac @@ -543,6 +543,7 @@ AC_CONFIG_FILES([ bin/varnishlog/Makefile bin/varnishstat/Makefile bin/varnishtest/Makefile + bin/varnishncsa/Makefile doc/Makefile doc/sphinx/Makefile doc/sphinx/conf.py From martin at varnish-cache.org Tue Nov 19 16:37:57 2013 From: martin at varnish-cache.org (Martin Blix Grydeland) Date: Tue, 19 Nov 2013 17:37:57 +0100 Subject: [master] ff64843 Varnishncsa updated documentation Message-ID: commit ff6484327ec12e45bff8c0caa7738de2c4a647b5 Author: Martin Blix Grydeland Date: Tue Nov 19 16:57:05 2013 +0100 Varnishncsa updated documentation diff --git a/bin/varnishncsa/Makefile.am b/bin/varnishncsa/Makefile.am index 9912d4c..6f3a7f9 100644 --- a/bin/varnishncsa/Makefile.am +++ b/bin/varnishncsa/Makefile.am @@ -25,9 +25,31 @@ varnishncsa_LDADD = \ $(top_builddir)/lib/libvarnishapi/libvarnishapi.la \ ${RT_LIBS} ${LIBM} -varnishncsa.1: $(top_srcdir)/doc/sphinx/reference/varnishncsa.rst +noinst_PROGRAMS = varnishncsa_opt2rst +varnishncsa_opt2rst_SOURCES = \ + varnishncsa_options.h \ + varnishncsa_options.c \ + $(top_srcdir)/lib/libvarnishtools/opt2rst.c + +BUILT_SOURCES = varnishncsa_options.rst varnishncsa_synopsis.rst +EXTRA_DIST = $(BUILT_SOURCES) +MAINTAINERCLEANFILES = $(EXTRA_DIST) + +varnishncsa_options.rst: + ./varnishncsa_opt2rst options > $@ +varnishncsa_synopsis.rst: + ./varnishncsa_opt2rst synopsis > $@ + +if HAVE_RST2MAN +varnishncsa_options.rst varnishncsa_synopsis.rst: varnishncsa_opt2rst +endif + +varnishncsa.1: \ + $(top_srcdir)/doc/sphinx/reference/varnishncsa.rst \ + varnishncsa_options.rst \ + varnishncsa_synopsis.rst if HAVE_RST2MAN - ${RST2MAN} $? $@ + ${RST2MAN} $(top_srcdir)/doc/sphinx/reference/varnishncsa.rst $@ else @echo "========================================" @echo "You need rst2man installed to make dist" diff --git a/doc/sphinx/reference/varnishncsa.rst b/doc/sphinx/reference/varnishncsa.rst index 3acac45..13b9c10 100644 --- a/doc/sphinx/reference/varnishncsa.rst +++ b/doc/sphinx/reference/varnishncsa.rst @@ -7,6 +7,7 @@ Display Varnish logs in Apache / NCSA combined log format --------------------------------------------------------- :Author: Dag-Erling Sm?rgrav +:Author: Martin Blix Grydeland :Date: 2010-05-31 :Version: 1.0 :Manual section: 1 @@ -15,10 +16,8 @@ Display Varnish logs in Apache / NCSA combined log format SYNOPSIS ======== -varnishncsa [-a] [-C] [-D] [-d] [-f] [-F format] [-I regex] -[-i tag] [-n varnish_name] [-m tag:regex ...] [-P file] [-r file] [-V] [-w file] -[-X regex] [-x tag] - +.. include:: ../../../bin/varnishncsa/varnishncsa_synopsis.rst +varnishncsa |synopsis| DESCRIPTION =========== @@ -28,142 +27,107 @@ presents them in the Apache / NCSA "combined" log format. The following options are available: --a When writing to a file, append to it rather than overwrite it. - --C Ignore case when matching regular expressions. - --D Daemonize. +.. include:: ../../../bin/varnishncsa/varnishncsa_options.rst --d Process old log entries on startup. Normally, varnishncsa - will only process entries which are written to the log - after it starts. +FORMAT +====== --f Prefer the X-Forwarded-For HTTP header over client.ip in - the log output. +Specify the log format used. If no format is specified the default log +format is used. --F format Specify the log format used. If no format is specified the - default log format is used. Currently it is: +The default log format is:: - %h %l %u %t "%r" %s %b "%{Referer}i" "%{User-agent}i" + %h %l %u %t "%r" %s %b "%{Referer}i" "%{User-agent}i" - Escape sequences \\n and \\t are supported. +Escape sequences \\n and \\t are supported. - Supported formatters are: +Supported formatters are: - %b - Size of response in bytes, excluding HTTP headers. - In CLF format, i.e. a '-' rather than a 0 when no - bytes are sent. +%b + Size of response in bytes, excluding HTTP headers. In CLF format, + i.e. a '-' rather than a 0 when no bytes are sent. - %D - Time taken to serve the request, in microseconds. +%D + Time taken to serve the request, in microseconds. - %H - The request protocol. Defaults to HTTP/1.0 if not - known. +%H + The request protocol. Defaults to HTTP/1.0 if not known. - %h - Remote host. Defaults to '-' if not known. - Defaults to 127.0.0.1 for backend requests. +%h + Remote host. Defaults to '-' if not known. - %{X}i - The contents of request header X. +%{X}i + The contents of request header X. - %l - Remote logname (always '-') +%l + Remote logname (always '-') - %m - Request method. Defaults to '-' if not known. +%m + Request method. Defaults to '-' if not known. - %q - The query string, if no query string exists, an - empty string. +%q + The query string, if no query string exists, an empty string. - %{X}o - The contents of response header X. +%{X}o + The contents of response header X. - %r - The first line of the request. Synthesized from other - fields, so it may not be the request verbatim. +%r + The first line of the request. Synthesized from other fields, so it + may not be the request verbatim. - %s - Status sent to the client +%s + Status sent to the client - %t - Time when the request was received, in HTTP date/time - format. +%t + Time when the request was received, in HTTP date/time format. - %{X}t - Time when the request was received, in the format - specified by X. The time specification format is the - same as for strftime(3). +%{X}t + Time when the request was received, in the format specified + by X. The time specification format is the same as for strftime(3). - %T - Time taken to serve the request, in seconds. +%T + Time taken to serve the request, in seconds. - %U - The request URL without any query string. Defaults to - '-' if not known. +%U + The request URL without any query string. Defaults to '-' if not + known. - %u - Remote user from auth +%u + Remote user from auth - %{X}x - Extended variables. Supported variables are: +%{X}x + Extended variables. Supported variables are: - Varnish:time_firstbyte - Time from when the request processing starts - until the first byte is sent to the client. + Varnish:time_firstbyte + Time from when the request processing starts until the first byte + is sent to the client. - Varnish:hitmiss - Whether the request was a cache hit or miss. Pipe - and pass are considered misses. + Varnish:hitmiss + Whether the request was a cache hit or miss. Pipe and pass are + considered misses. - Varnish:handling - How the request was handled, whether it was a - cache hit, miss, pass, pipe or error. + Varnish:handling + How the request was handled, whether it was a cache hit, miss, + pass, pipe or error. - VCL_Log:key - Output value set by std.log("key:value") in VCL. - - --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. - --P file Write the process's PID to the specified file. + VCL_Log:key + Output value set by std.log("key:value") in VCL. --r file Read log entries from file instead of shared memory. - --V Display the version number and exit. - --w file Write log entries to file instead of displaying them. - The file will be overwritten unless the -a - option was specified. - - If varnishncsa receives a SIGHUP while writing to a file, - it will reopen the file, allowing the old one to be - rotated away. - --X regex Exclude log entries which match the specified - regular expression. +SIGNALS +======= --x tag Exclude log entries with the specified tag. +SIGHUP + Rotate the log file (see -w option) -If the -o option was specified, a tag and a regex argument must be given. -varnishncsa will then only log for request groups which include that tag -and the regular expression matches on that tag. +SIGUSR1 + Flush any outstanding transactions SEE ALSO ======== -* varnishd(1) -* varnishhist(1) -* varnishlog(1) -* varnishstat(1) -* varnishtop(1) +varnishd(1) +varnishlog(1) +varnishstat(1) HISTORY ======= @@ -172,7 +136,6 @@ The varnishncsa utility was developed by Poul-Henning Kamp in cooperation with Verdens Gang AS and Varnish Software AS. This manual page was written by Dag-Erling Sm?rgrav ?des at des.no?. - COPYRIGHT ========= @@ -180,4 +143,4 @@ This document is licensed under the same licence as Varnish itself. See LICENCE for details. * Copyright (c) 2006 Verdens Gang AS -* Copyright (c) 2006-2011 Varnish Software AS +* Copyright (c) 2006-2013 Varnish Software AS From tfheen at varnish-cache.org Wed Nov 20 12:10:25 2013 From: tfheen at varnish-cache.org (Tollef Fog Heen) Date: Wed, 20 Nov 2013 13:10:25 +0100 Subject: [3.0] 7ae505a Use find-provides, not find-requires Message-ID: commit 7ae505a4af92cccc7f19da2112df264391b94515 Author: Tollef Fog Heen Date: Wed Nov 20 13:10:21 2013 +0100 Use find-provides, not find-requires diff --git a/redhat/find-provides b/redhat/find-provides index bf3ed59..da84416 100755 --- a/redhat/find-provides +++ b/redhat/find-provides @@ -4,8 +4,8 @@ set -x -if [ -x /usr/lib/rpm/find-requires ]; then - /usr/lib/rpm/find-requires "$@" +if [ -x /usr/lib/rpm/find-provides ]; then + /usr/lib/rpm/find-provides "$@" fi cd $(dirname $0)/.. From phk at varnish-cache.org Fri Nov 22 09:07:31 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Fri, 22 Nov 2013 10:07:31 +0100 Subject: [master] 9662a1b Reduce developer warnings to make jenkins happy Message-ID: commit 9662a1b3e931acd9128bceb9bc920ffa175379e0 Author: Poul-Henning Kamp Date: Fri Nov 22 09:07:16 2013 +0000 Reduce developer warnings to make jenkins happy diff --git a/configure.ac b/configure.ac index 905d131..6fdd780 100644 --- a/configure.ac +++ b/configure.ac @@ -456,7 +456,7 @@ CFLAGS="${CFLAGS} -Wall -Werror" OCFLAGS="${OCFLAGS} -Wall -Werror" # This corresponds to FreeBSD's WARNS level 6 -DEVELOPER_CFLAGS="-fstack-protector -Werror -Wall -Wno-format-y2k -W -Wno-unused-parameter -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wshadow -Wunused-parameter -Wcast-align -Wchar-subscripts -Winline -Wnested-externs -Wno-pointer-sign -Wno-empty-body -Wextra -Wno-missing-field-initializers -Wno-sign-compare" +DEVELOPER_CFLAGS="-fstack-protector -Werror -Wall -Wno-format-y2k -W -Wno-unused-parameter -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wshadow -Wunused-parameter -Wcast-align -Wchar-subscripts -Winline -Wnested-externs -Wno-pointer-sign -Wextra -Wno-missing-field-initializers -Wno-sign-compare" # These are not compliable yet DEVELOPER_GCC_CFLAGS="-Wold-style-definition -Wredundant-decls " @@ -464,6 +464,7 @@ DEVELOPER_GCC_CFLAGS="-Wold-style-definition -Wredundant-decls " # These are compilable DEVELOPER_CLANG_CFLAGS="-Wmissing-variable-declarations -Wno-string-plus-int" +# -Wno-empty-body #DEVELOPER_CFLAGS="${DEVELOPER_CFLAGS} ${DEVELOPER_CLANG_CFLAGS}" # --enable-developer-warnings From phk at varnish-cache.org Fri Nov 22 09:51:23 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Fri, 22 Nov 2013 10:51:23 +0100 Subject: [master] 180e785 Always pull the local address of the socket out right away and log it. Parallel use of sockets would force us to add locking and that's simply not worth it. Message-ID: commit 180e785d8aaaac7abb1f47645ae4691b6ac8357a Author: Poul-Henning Kamp Date: Fri Nov 22 09:50:16 2013 +0000 Always pull the local address of the socket out right away and log it. Parallel use of sockets would force us to add locking and that's simply not worth it. Also: Fixes #1376 diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 5ed30c4..77a109a 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -766,8 +766,8 @@ struct sess { /* Session related fields ------------------------------------*/ - struct suckaddr *their_addr; - struct suckaddr *our_addr; + struct suckaddr *remote_addr; + struct suckaddr *local_addr; /* formatted ascii client address */ char addr[ADDR_BUFSIZE]; @@ -1114,7 +1114,6 @@ struct req *SES_GetReq(struct worker *, struct sess *); void SES_Handle(struct sess *sp, double now); void SES_ReleaseReq(struct req *); pool_func_t SES_pool_accept_task; -void SES_Get_Our_Addr(struct sess *sp); /* cache_shmlog.c */ diff --git a/bin/varnishd/cache/cache_acceptor.c b/bin/varnishd/cache/cache_acceptor.c index 17fe100..ba203c9 100644 --- a/bin/varnishd/cache/cache_acceptor.c +++ b/bin/varnishd/cache/cache_acceptor.c @@ -352,8 +352,7 @@ VCA_SetupSess(struct worker *wrk, struct sess *sp) wa->acceptsock = -1; retval = wa->acceptlsock->name; assert(wa->acceptaddrlen <= vsa_suckaddr_len); - sp->their_addr = VSA_Build(sp->their_addr, - &wa->acceptaddr, wa->acceptaddrlen); + AN(VSA_Build(sp->remote_addr, &wa->acceptaddr, wa->acceptaddrlen)); vca_pace_good(); wrk->stats.sess_conn++; WS_Release(wrk->aws, 0); diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c index cdfcc9d..ad0f537 100644 --- a/bin/varnishd/cache/cache_session.c +++ b/bin/varnishd/cache/cache_session.c @@ -91,6 +91,11 @@ SES_Charge(struct worker *wrk, struct req *req) /*-------------------------------------------------------------------- * Get a new session, preferably by recycling an already ready one + * + * Layout is: + * struct sess + * struct vsa (local_addr) + * struct vsa (remote_addr) */ static struct sess * @@ -107,15 +112,19 @@ ses_new(struct sesspool *pp) s = (char *)sp; s += sizeof *sp; + + memset(s, 0, vsa_suckaddr_len); + sp->local_addr = (void*)s; s += vsa_suckaddr_len; + memset(s, 0, vsa_suckaddr_len); - sp->their_addr = (void*)s; + sp->remote_addr = (void*)s; s += vsa_suckaddr_len; + assert((char *)sp + sz == s); sp->t_open = NAN; sp->t_idle = NAN; - sp->our_addr = NULL; Lck_New(&sp->mtx, lck_sess); CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); return (sp); @@ -165,29 +174,6 @@ ses_sess_pool_task(struct worker *wrk, void *arg) } /*-------------------------------------------------------------------- - * Get the local socket address - */ - -void -SES_Get_Our_Addr(struct sess *sp) -{ - char *s; - struct sockaddr_storage ss; - socklen_t sl; - - CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); - if (sp->our_addr != NULL) - return; - - sl = sizeof ss; - AZ(getsockname(sp->fd, (void*)&ss, &sl)); - s = (char *)sp; - s += sizeof *sp; - sp->our_addr = VSA_Build(s, &ss, sl); - assert(VSA_Sane(sp->our_addr)); -} - -/*-------------------------------------------------------------------- * VSL log the endpoints of the TCP connection. * * We use VSL() to get the sessions vxid and to make sure tha this @@ -200,22 +186,23 @@ SES_Get_Our_Addr(struct sess *sp) static void ses_vsl_socket(struct sess *sp, const char *lsockname) { + struct sockaddr_storage ss; + socklen_t sl; char laddr[ADDR_BUFSIZE]; char lport[PORT_BUFSIZE]; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); AN(lsockname); - VTCP_name(sp->their_addr, + AN(sp->local_addr); + sl = sizeof ss; + AZ(getsockname(sp->fd, (void*)&ss, &sl)); + AN(VSA_Build(sp->local_addr, &ss, sl)); + assert(VSA_Sane(sp->local_addr)); + + VTCP_name(sp->remote_addr, sp->addr, sizeof sp->addr, sp->port, sizeof sp->port); - if (cache_param->log_local_addr) { - SES_Get_Our_Addr(sp); - VTCP_name(sp->our_addr, - laddr, sizeof laddr, lport, sizeof lport); - } else { - strcpy(laddr, "-"); - strcpy(lport, "-"); - } + VTCP_name(sp->local_addr, laddr, sizeof laddr, lport, sizeof lport); VSL(SLT_Begin, sp->vxid, "sess"); VSL(SLT_SessOpen, sp->vxid, "%s %s %s %s %s %.6f %d", sp->addr, sp->port, lsockname, laddr, lport, sp->t_open, sp->fd); diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index 0ef4a05..2555f24 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -540,7 +540,7 @@ VRT_r_client_ip(const struct vrt_ctx *ctx) CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); - return (ctx->req->sp->their_addr); + return (ctx->req->sp->remote_addr); } VCL_IP @@ -549,8 +549,8 @@ VRT_r_server_ip(const struct vrt_ctx *ctx) CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); - SES_Get_Our_Addr(ctx->req->sp); - return (ctx->req->sp->our_addr); + AN(ctx->req->sp->local_addr); + return (ctx->req->sp->local_addr); } const char* @@ -584,8 +584,8 @@ VRT_r_server_port(const struct vrt_ctx *ctx) CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); - SES_Get_Our_Addr(ctx->req->sp); - return (VSA_Port(ctx->req->sp->our_addr)); + AN(ctx->req->sp->local_addr); + return (VSA_Port(ctx->req->sp->local_addr)); } /*--------------------------------------------------------------------*/ diff --git a/bin/varnishd/common/params.h b/bin/varnishd/common/params.h index 28c4500..7a69119 100644 --- a/bin/varnishd/common/params.h +++ b/bin/varnishd/common/params.h @@ -165,9 +165,6 @@ struct params { /* CLI buffer size */ unsigned cli_buffer; - /* Log local socket address to shm */ - unsigned log_local_addr; - /* Prefer IPv6 connections to backend*/ unsigned prefer_ipv6; diff --git a/bin/varnishd/mgt/mgt_param_tbl.c b/bin/varnishd/mgt/mgt_param_tbl.c index 169f521..4bb6592 100644 --- a/bin/varnishd/mgt/mgt_param_tbl.c +++ b/bin/varnishd/mgt/mgt_param_tbl.c @@ -436,14 +436,6 @@ struct parspec mgt_parspec[] = { "more sessions take a detour around the waiter.", EXPERIMENTAL, "0.050", "seconds" }, - { "log_local_address", tweak_bool, &mgt_param.log_local_addr, - NULL, NULL, - "Log the local address on the TCP connection in the " - "SessionOpen VSL record.\n" - "Disabling this saves a getsockname(2) system call " - "per TCP connection.", - 0, - "on", "bool" }, { "waiter", tweak_waiter, NULL, NULL, NULL, "Select the waiter kernel interface.", diff --git a/bin/varnishtest/tests/c00003.vtc b/bin/varnishtest/tests/c00003.vtc index 0327873..9e811b6 100644 --- a/bin/varnishtest/tests/c00003.vtc +++ b/bin/varnishtest/tests/c00003.vtc @@ -8,7 +8,6 @@ server s1 { # This requires non-local binds to be disabled. If you see this fail # and are on Linux, ensure /proc/net/ipv4/ip_nonlocal_bind is set to 0. varnish v1 -cliok "param.set listen_address ${bad_ip}:0" -varnish v1 -cliok "param.set log_local_address off" varnish v1 -vcl+backend {} -clierr 300 start varnish v1 -cliok "param.set listen_address 127.0.0.1:0,${bad_ip}:9082" From phk at varnish-cache.org Fri Nov 22 10:10:30 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Fri, 22 Nov 2013 11:10:30 +0100 Subject: [master] b4138ae White-space nit Message-ID: commit b4138aee2b5d103ffecb3a861af0728b49f63d56 Author: Poul-Henning Kamp Date: Fri Nov 22 10:10:22 2013 +0000 White-space nit diff --git a/bin/varnishtest/tests/r00940.vtc b/bin/varnishtest/tests/r00940.vtc index 0d41b38..4e4711d 100644 --- a/bin/varnishtest/tests/r00940.vtc +++ b/bin/varnishtest/tests/r00940.vtc @@ -19,7 +19,7 @@ server s1 { txresp -hdr {ETag: "foo4"} -gzipbody { foo } } -start -varnish v1 -vcl+backend { +varnish v1 -vcl+backend { sub vcl_backend_response { if (bereq.url == "/2") { set beresp.do_gzip = true; From phk at varnish-cache.org Fri Nov 22 10:58:43 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Fri, 22 Nov 2013 11:58:43 +0100 Subject: [master] 0b952fd Document the VCL variables where we define them in generate.py. Message-ID: commit 0b952fdc12355d853bc81fd389369b6eb221812d Author: Poul-Henning Kamp Date: Fri Nov 22 10:57:19 2013 +0000 Document the VCL variables where we define them in generate.py. Initial doc pulled from vcl.rst Generate doc/sphinx/reference/vcl_var.rst based on this. diff --git a/lib/libvcc/generate.py b/lib/libvcc/generate.py index f0224e3..a12fe24 100755 --- a/lib/libvcc/generate.py +++ b/lib/libvcc/generate.py @@ -105,322 +105,476 @@ sp_variables = [ ('client.ip', 'IP', ( 'both',), - ( ), + ( ), """ +The client's IP address. +""" ), ('client.identity', 'STRING', ( 'both',), - ( 'both',), + ( 'both',), """ + Identification of the client, used to load balance + in the client director. + """ ), ('server.ip', 'IP', ( 'client',), - ( ), + ( ), """ + The IP address of the socket on which the client + connection was received. + """ ), ('server.hostname', 'STRING', ( 'client',), - ( ), + ( ), """ + The host name of the server. + """ ), ('server.identity', 'STRING', ( 'client',), - ( ), + ( ), """ + The identity of the server, as set by the -i + parameter. If the -i parameter is not passed to varnishd, + server.identity will be set to the name of the instance, as + specified by the -n parameter. + """ ), ('server.port', 'INT', ( 'client',), - ( ), + ( ), """ + The port number of the socket on which the client + connection was received. + """ ), ('req.method', 'STRING', ( 'client',), - ( 'client',), + ( 'client',), """ + The request type (e.g. "GET", "HEAD"). + """ ), ('req.request', 'STRING', ( 'client',), - ( 'client',), + ( 'client',), """ + utdated way to spell req.method. (XXX: remove) + """ ), ('req.url', 'STRING', ( 'client',), - ( 'client',), + ( 'client',), """ + The requested URL. + """ ), ('req.proto', 'STRING', ( 'client',), - ( 'client',), + ( 'client',), """ + The HTTP protocol version used by the client. + """ ), ('req.http.', 'HEADER', ( 'client',), - ( 'client',), + ( 'client',), """ + The corresponding HTTP header. + """ ), ('req.restarts', 'INT', ( 'client',), - ( ), + ( ), """ + A count of how many times this request has been restarted. + """ ), ('req.esi_level', 'INT', ( 'client',), - ( ), + ( ), """ + A count of how many levels of ESI requests we're currently at. + """ ), ('req.ttl', 'DURATION', ( 'client',), - ( 'client',), + ( 'client',), """ + """ ), ('req.xid', 'STRING', ( 'client',), - ( ), + ( ), """ + Unique ID of this request. + """ ), ('req.esi', 'BOOL', ( 'recv', 'backend_response', 'deliver', 'error',), - ( 'recv', 'backend_response', 'deliver', 'error',), + ( 'recv', 'backend_response', 'deliver', 'error',), """ + Boolean. Set to false to disable ESI processing + regardless of any value in beresp.do_esi. Defaults + to true. This variable is subject to change in + future versions, you should avoid using it. + """ ), ('req.can_gzip', 'BOOL', ( 'client',), - ( ), + ( ), """ + Does the client accept the gzip transfer encoding. + """ ), ('req.backend', 'BACKEND', ( 'client',), - ( 'client',), + ( 'client',), """ + The backend to use to service the request. + """ ), ('req.backend.healthy', 'BOOL', ( 'client',), - ( ), + ( ), """ + XXX: remove: foo.healthy() + """ ), ('req.hash_ignore_busy', 'BOOL', ( 'recv',), - ( 'recv',), + ( 'recv',), """ + Ignore any busy object during cache lookup. You + would want to do this if you have two server looking + up content from each other to avoid potential deadlocks. + """ ), ('req.hash_always_miss', 'BOOL', ( 'recv',), - ( 'recv',), + ( 'recv',), """ + Force a cache miss for this request. If set to true + Varnish will disregard any existing objects and + always (re)fetch from the backend. + """ ), ('bereq.retries', 'INT', ( 'backend',), - ( ), + ( ), """ + """ ), ('bereq.backend', 'BACKEND', ( 'pipe', 'backend', ), - ( 'pipe', 'backend', ), + ( 'pipe', 'backend', ), """ + """ ), ('bereq.backend.healthy', 'BOOL', ( 'pipe', 'backend', ), - ( ), + ( ), """ + XXX: remove: foo.healthy() + """ ), ('bereq.method', 'STRING', ( 'pipe', 'backend', ), - ( 'pipe', 'backend', ), + ( 'pipe', 'backend', ), """ + The request type (e.g. "GET", "HEAD"). + """ ), ('bereq.request', 'STRING', ( 'pipe', 'backend', ), - ( 'pipe', 'backend', ), + ( 'pipe', 'backend', ), """ + XXX: remove + """ ), ('bereq.url', 'STRING', ( 'pipe', 'backend', ), - ( 'pipe', 'backend', ), + ( 'pipe', 'backend', ), """ + The requested URL. + """ ), ('bereq.proto', 'STRING', ( 'pipe', 'backend', ), - ( 'pipe', 'backend', ), + ( 'pipe', 'backend', ), """ + The HTTP protocol version used to talk to the server. + """ ), ('bereq.http.', 'HEADER', ( 'pipe', 'backend', ), - ( 'pipe', 'backend', ), + ( 'pipe', 'backend', ), """ + The corresponding HTTP header. + """ ), ('bereq.uncacheable', 'BOOL', ( 'backend', ), - ( 'backend', ), + ( 'backend', ), """ + """ ), ('bereq.connect_timeout', 'DURATION', ( 'pipe', 'backend', ), - ( 'pipe', 'backend', ), + ( 'pipe', 'backend', ), """ + The time in seconds to wait for a backend connection. + """ ), ('bereq.first_byte_timeout', 'DURATION', ( 'pipe', 'backend', ), - ( 'pipe', 'backend', ), + ( 'pipe', 'backend', ), """ + The time in seconds to wait for the first byte from + the backend. Not available in pipe mode. + """ ), ('bereq.between_bytes_timeout', 'DURATION', ( 'pipe', 'backend', ), - ( 'pipe', 'backend', ), + ( 'pipe', 'backend', ), """ + The time in seconds to wait between each received byte from the + backend. Not available in pipe mode. + """ ), ('beresp.proto', 'STRING', ( 'backend_response',), - ( 'backend_response',), + ( 'backend_response',), """ + The HTTP protocol version used the backend replied with. + """ ), ('beresp.status', 'INT', ( 'backend_response',), - ( 'backend_response',), + ( 'backend_response',), """ + The HTTP status code returned by the server. + """ ), ('beresp.response', 'STRING', ( 'backend_response',), - ( 'backend_response',), + ( 'backend_response',), """ + The HTTP status message returned by the server. + """ ), ('beresp.http.', 'HEADER', ( 'backend_response',), - ( 'backend_response',), + ( 'backend_response',), """ + The corresponding HTTP header. + """ ), ('beresp.do_esi', 'BOOL', ( 'backend_response',), - ( 'backend_response',), + ( 'backend_response',), """ + Boolean. ESI-process the object after fetching it. + Defaults to false. Set it to true to parse the + object for ESI directives. Will only be honored if + req.esi is true. + """ ), ('beresp.do_stream', 'BOOL', ( 'backend_response',), - ( 'backend_response',), + ( 'backend_response',), """ + Deliver the object to the client directly without + fetching the whole object into varnish. If this + request is pass'ed it will not be stored in memory. + As of Varnish Cache 3.0 the object will marked as busy + as it is delivered so only client can access the object. + """ ), ('beresp.do_gzip', 'BOOL', ( 'backend_response',), - ( 'backend_response',), + ( 'backend_response',), """ + Boolean. Gzip the object before storing it. Defaults + to false. When http_gzip_support is on Varnish will + request already compressed content from the backend + and as such compression in Varnish is not needed. + """ ), ('beresp.do_gunzip', 'BOOL', ( 'backend_response',), - ( 'backend_response',), + ( 'backend_response',), """ + Boolean. Unzip the object before storing it in the + cache. Defaults to false. + """ ), ('beresp.uncacheable', 'BOOL', ( 'backend_response',), - ( 'backend_response',), + ( 'backend_response',), """ + """ ), ('beresp.ttl', 'DURATION', ( 'backend_response',), - ( 'backend_response',), + ( 'backend_response',), """ + The object's remaining time to live, in seconds. + beresp.ttl is writable. + """ ), ('beresp.grace', 'DURATION', ( 'backend_response',), - ( 'backend_response',), + ( 'backend_response',), """ + Set to a period to enable grace. + """ ), ('beresp.keep', 'DURATION', ( 'backend_response',), - ( 'backend_response',), + ( 'backend_response',), """ + """ ), ('beresp.backend.name', 'STRING', ( 'backend_response',), - ( ), + ( ), """ + Name of the backend this response was fetched from. + """ ), ('beresp.backend.ip', 'IP', ( 'backend_response',), - ( ), + ( ), """ + IP of the backend this response was fetched from. + """ ), ('beresp.backend.port', 'INT', ( 'backend_response',), - ( ), + ( ), """ + Port of the backend this response was fetched from. + """ ), ('beresp.storage', 'STRING', ( 'backend_response',), - ( 'backend_response',), + ( 'backend_response',), """ + Set to force Varnish to save this object to a + particular storage backend. + """ ), ('obj.proto', 'STRING', ( 'hit', 'error',), - ( 'hit', 'error',), + ( 'hit', 'error',), """ + The HTTP protocol version used when the object was retrieved. + """ ), ('obj.status', 'INT', ( 'error',), - ( 'error',), + ( 'error',), """ + The HTTP status code returned by the server. + """ ), ('obj.response', 'STRING', ( 'error',), - ( 'error',), + ( 'error',), """ + The HTTP status message returned by the server. + """ ), ('obj.hits', 'INT', ( 'hit', 'deliver',), - ( 'hit', 'deliver',), + ( 'hit', 'deliver',), """ + The approximate number of times the object has been + delivered. A value of 0 indicates a cache miss. + This variable is also available in vcl_deliver. + """ ), ('obj.http.', 'HEADER', ( 'hit', 'error',), - ( 'error',), # XXX ? + ( 'error',), """ + The corresponding HTTP header. + """ ), ('obj.ttl', 'DURATION', ( 'hit', 'error',), - ( 'hit', 'error',), + ( 'hit', 'error',), """ + The object's remaining time to live, in seconds. + obj.ttl is writable. + """ ), ('obj.grace', 'DURATION', ( 'hit', 'error',), - ( 'hit', 'error',), + ( 'hit', 'error',), """ + The object's grace period in seconds. obj.grace is writable. + """ ), ('obj.keep', 'DURATION', ( 'hit', 'error',), - ( 'hit', 'error',), + ( 'hit', 'error',), """ + """ ), ('obj.last_use', 'TIME', ( 'hit', 'deliver',), - ( 'hit', 'deliver',), + ( 'hit', 'deliver',), """ + The approximate time elapsed since the object was + last requests, in seconds. This variable is also + available in vcl_deliver. + """ ), ('obj.uncacheable', 'BOOL', ( 'hit', 'deliver', 'error',), - ( ), + ( ), """ + """ ), ('resp.proto', 'STRING', ( 'deliver',), - ( 'deliver',), + ( 'deliver',), """ + The HTTP protocol version to use for the response. + """ ), ('resp.status', 'INT', ( 'deliver',), - ( 'deliver',), + ( 'deliver',), """ + The HTTP status code that will be returned. + """ ), ('resp.response', 'STRING', ( 'deliver',), - ( 'deliver',), + ( 'deliver',), """ + The HTTP status message that will be returned. + """ ), ('resp.http.', 'HEADER', ( 'deliver',), - ( 'deliver',), + ( 'deliver',), """ + The corresponding HTTP header. + """ ), ('now', 'TIME', ( 'all',), - ( ), + ( ), """ + The current time, in seconds since the epoch. When + used in string context it returns a formatted string. + """ ), ] @@ -945,3 +1099,50 @@ fo.write(""" """) fo.close + +####################################################################### + +fo = open(buildroot + "/doc/sphinx/reference/vcl_var.rst", "w") + +l = list() +for i in sp_variables: + l.append(i) + +l.sort() + +def rst_where(fo, h, l): + ll = list() + if len(l) == 0: + return + fo.write("\t" + h) + s = "" + for j in l: + if j == "both": + ll.append("client") + ll.append("backend") + elif j == "client": + ll.append(j) + elif j == "backend": + ll.append(j) + else: + ll.append("vcl_" + j) + for j in ll: + fo.write(s + j) + s = ", " + fo.write("\n\n") + +hdr="" +for i in l: + j = i[0].split(".") + if j[0] != hdr: + fo.write("\n" + j[0] + "\n") + fo.write("~" * len(j[0]) + "\n") + hdr = j[0] + fo.write("\n" + i[0] + "\n\n") + fo.write("\tType: " + i[1] + "\n\n") + rst_where(fo, "Readable from: ", i[2]) + rst_where(fo, "Writeable frome: ", i[3]) + for j in i[4].split("\n"): + fo.write("\t" + j.strip() + "\n") + +fo.close() From phk at varnish-cache.org Fri Nov 22 10:58:43 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Fri, 22 Nov 2013 11:58:43 +0100 Subject: [master] 6e2a07d Pull in vcl_var.rst generated by generate.py Message-ID: commit 6e2a07dfe6041d40e0a942b35c3ae7b53cf0b192 Author: Poul-Henning Kamp Date: Fri Nov 22 10:58:28 2013 +0000 Pull in vcl_var.rst generated by generate.py diff --git a/doc/sphinx/reference/index.rst b/doc/sphinx/reference/index.rst index 1537fb4..e8377f0 100644 --- a/doc/sphinx/reference/index.rst +++ b/doc/sphinx/reference/index.rst @@ -24,6 +24,7 @@ The Varnish Reference Manual vmod_std.rst vsl.rst vsl-query.rst + vcl_var.rst .. todo:: The programs: From phk at varnish-cache.org Fri Nov 22 11:36:20 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Fri, 22 Nov 2013 12:36:20 +0100 Subject: [master] 3e3619d Add a simple facility for having variables alias each other and use it to rename {beresp, resp, obj}.response to *.reason while still keeping the old ones working. Message-ID: commit 3e3619da01f3582866390a11967d31986ad92c08 Author: Poul-Henning Kamp Date: Fri Nov 22 11:34:57 2013 +0000 Add a simple facility for having variables alias each other and use it to rename {beresp,resp,obj}.response to *.reason while still keeping the old ones working. Use it to also eliminate the already duplicated req.request and bereq.request (now: *.method) diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index 2555f24..250cb85 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -103,22 +103,20 @@ VRT_r_##obj##_status(const struct vrt_ctx *ctx) \ } VRT_DO_HDR(req, method, HTTP_HDR_METHOD) -VRT_DO_HDR(req, request, HTTP_HDR_METHOD) VRT_DO_HDR(req, url, HTTP_HDR_URL) VRT_DO_HDR(req, proto, HTTP_HDR_PROTO) VRT_DO_HDR(obj, proto, HTTP_HDR_PROTO) -VRT_DO_HDR(obj, response, HTTP_HDR_RESPONSE) +VRT_DO_HDR(obj, reason, HTTP_HDR_RESPONSE) VRT_DO_STATUS(obj) VRT_DO_HDR(resp, proto, HTTP_HDR_PROTO) -VRT_DO_HDR(resp, response, HTTP_HDR_RESPONSE) +VRT_DO_HDR(resp, reason, HTTP_HDR_RESPONSE) VRT_DO_STATUS(resp) VRT_DO_HDR(bereq, method, HTTP_HDR_METHOD) -VRT_DO_HDR(bereq, request, HTTP_HDR_METHOD) VRT_DO_HDR(bereq, url, HTTP_HDR_URL) VRT_DO_HDR(bereq, proto, HTTP_HDR_PROTO) VRT_DO_HDR(beresp, proto, HTTP_HDR_PROTO) -VRT_DO_HDR(beresp, response, HTTP_HDR_RESPONSE) +VRT_DO_HDR(beresp, reason, HTTP_HDR_RESPONSE) VRT_DO_STATUS(beresp) /*--------------------------------------------------------------------*/ diff --git a/lib/libvcc/generate.py b/lib/libvcc/generate.py index a12fe24..9a00c37 100755 --- a/lib/libvcc/generate.py +++ b/lib/libvcc/generate.py @@ -157,13 +157,6 @@ The client's IP address. The request type (e.g. "GET", "HEAD"). """ ), - ('req.request', - 'STRING', - ( 'client',), - ( 'client',), """ - utdated way to spell req.method. (XXX: remove) - """ - ), ('req.url', 'STRING', ( 'client',), @@ -287,13 +280,6 @@ The client's IP address. The request type (e.g. "GET", "HEAD"). """ ), - ('bereq.request', - 'STRING', - ( 'pipe', 'backend', ), - ( 'pipe', 'backend', ), """ - XXX: remove - """ - ), ('bereq.url', 'STRING', ( 'pipe', 'backend', ), @@ -358,7 +344,7 @@ The client's IP address. The HTTP status code returned by the server. """ ), - ('beresp.response', + ('beresp.reason', 'STRING', ( 'backend_response',), ( 'backend_response',), """ @@ -481,7 +467,7 @@ The client's IP address. The HTTP status code returned by the server. """ ), - ('obj.response', + ('obj.reason', 'STRING', ( 'error',), ( 'error',), """ @@ -554,7 +540,7 @@ The client's IP address. The HTTP status code that will be returned. """ ), - ('resp.response', + ('resp.reason', 'STRING', ( 'deliver',), ( 'deliver',), """ @@ -578,6 +564,15 @@ The client's IP address. ), ] +# Backwards compatibility: +aliases = [ + ('req.request', 'req.method'), + ('bereq.request', 'bereq.method'), + ('beresp.response', 'beresp.reason'), + ('resp.response', 'resp.reason'), + ('obj.response', 'obj.reason'), +] + stv_variables = ( ('free_space', 'BYTES', "0."), ('used_space', 'BYTES', "0."), @@ -967,43 +962,55 @@ fo.write(""" const struct var vcc_vars[] = { """) -sp_variables.sort() -for i in sp_variables: +def one_var(nm, spec): fh.write("\n") - typ = i[1] + typ = spec[1] cnam = i[0].replace(".", "_") ctyp = vcltypes[typ] - fo.write("\t{ \"%s\", %s, %d,\n" % (i[0], typ, len(i[0]))) + fo.write("\t{ \"%s\", %s, %d,\n" % (nm, typ, len(nm))) - if len(i[2]) == 0: + if len(spec[2]) == 0: fo.write('\t NULL,\t/* No reads allowed */\n') elif typ == "HEADER": fo.write('\t "HDR_') - fo.write(i[0].split(".")[0].upper()) + fo.write(nm.split(".")[0].upper()) fo.write('",\n') else: fo.write('\t "VRT_r_%s(ctx)",\n' % cnam) - fh.write("VCL_" + typ + " VRT_r_%s(const struct vrt_ctx *);\n" % cnam ) - restrict(fo, i[2]) + if nm == i[0]: + fh.write("VCL_" + typ + + " VRT_r_%s(const struct vrt_ctx *);\n" % cnam ) + restrict(fo, spec[2]) - if len(i[3]) == 0: + if len(spec[3]) == 0: fo.write('\t NULL,\t/* No writes allowed */\n') elif typ == "HEADER": fo.write('\t "HDR_') - fo.write(i[0].split(".")[0].upper()) + fo.write(nm.split(".")[0].upper()) fo.write('",\n') else: fo.write('\t "VRT_l_%s(ctx, ",\n' % cnam) - fh.write("void VRT_l_%s(const struct vrt_ctx *, " % cnam) - if typ != "STRING": - fh.write("VCL_" + typ + ");\n") - else: - fh.write(ctyp + ", ...);\n") - restrict(fo, i[3]) + if nm == i[0]: + fh.write( + "void VRT_l_%s(const struct vrt_ctx *, " % cnam) + if typ != "STRING": + fh.write("VCL_" + typ + ");\n") + else: + fh.write(ctyp + ", ...);\n") + restrict(fo, spec[3]) fo.write("\t},\n") + +sp_variables.sort() +aliases.sort() +for i in sp_variables: + one_var(i[0], i) + for j in aliases: + if j[1] == i[0]: + one_var(j[0], i) + fo.write("\t{ NULL }\n};\n") fh.write("\n") From martin at varnish-cache.org Fri Nov 22 11:54:56 2013 From: martin at varnish-cache.org (Martin Blix Grydeland) Date: Fri, 22 Nov 2013 12:54:56 +0100 Subject: [3.0] 6d74c0e Always pull the local address of the socket out right away. Message-ID: commit 6d74c0e41d01d58d38550ce1652c257268719eb3 Author: Martin Blix Grydeland Date: Wed Nov 20 13:52:00 2013 +0100 Always pull the local address of the socket out right away. Fixes: #1376 diff --git a/bin/varnishd/cache_acceptor.c b/bin/varnishd/cache_acceptor.c index 790ed62..c307b7b 100644 --- a/bin/varnishd/cache_acceptor.c +++ b/bin/varnishd/cache_acceptor.c @@ -178,8 +178,8 @@ VCA_Prep(struct sess *sp) addr, sizeof addr, port, sizeof port); sp->addr = WS_Dup(sp->ws, addr); sp->port = WS_Dup(sp->ws, port); + AZ(getsockname(sp->fd, (void*)sp->mysockaddr, &sp->mysockaddrlen)); if (params->log_local_addr) { - AZ(getsockname(sp->fd, (void*)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", diff --git a/bin/varnishd/cache_vrt_var.c b/bin/varnishd/cache_vrt_var.c index 189d8e9..780a1e0 100644 --- a/bin/varnishd/cache_vrt_var.c +++ b/bin/varnishd/cache_vrt_var.c @@ -466,12 +466,6 @@ VRT_r_client_ip(const struct sess *sp) struct sockaddr_storage * VRT_r_server_ip(struct sess *sp) { - int i; - - if (sp->mysockaddr->ss_family == AF_UNSPEC) { - i = getsockname(sp->fd, (void*)sp->mysockaddr, &sp->mysockaddrlen); - assert(VTCP_Check(i)); - } return (sp->mysockaddr); } diff --git a/bin/varnishtest/tests/r01376.vtc b/bin/varnishtest/tests/r01376.vtc new file mode 100644 index 0000000..9bc3d30 --- /dev/null +++ b/bin/varnishtest/tests/r01376.vtc @@ -0,0 +1,46 @@ +varnishtest "#1376 - server.ip initialization and ESI child" + +server s1 { + rxreq + txresp -body {} + + rxreq + expect req.url == "/foo" + sema r1 sync 2 + # Send large body to closed socket. This should cause a write error, + # closing the socket also in the varnishd end + txresp -bodylen 1048576 + + rxreq + expect req.url == "/bar" + txresp -body "[bar]" +} -start + +varnish v1 -vcl+backend { + sub vcl_recv { + if (req.url == "/bar") { + # Test getting the server ip on a closed socket + set req.http.test = server.ip; + } + } + sub vcl_fetch { + if (req.url == "/") { + set beresp.do_esi = true; + } + } +} -start + +client c1 { + txreq -hdr "Host: foo" + rxresp -no_obj + # Closes connection +} -run + +sema r1 sync 2 + +# Try again to make sure varnishd didn't die +client c1 { + txreq -hdr "Host: foo" + rxresp + expect resp.status == 200 +} -run From phk at varnish-cache.org Fri Nov 22 14:21:12 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Fri, 22 Nov 2013 15:21:12 +0100 Subject: [master] 351e100 Add BOOL std.healthy(BACKEND) which can check if any backend is healthy, rather than have hardcoded variables for req.backend and bereq.backend's health. Message-ID: commit 351e100e084fae8dd0db2c46badc9be38c48bd1b Author: Poul-Henning Kamp Date: Fri Nov 22 14:20:09 2013 +0000 Add BOOL std.healthy(BACKEND) which can check if any backend is healthy, rather than have hardcoded variables for req.backend and bereq.backend's health. diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index 250cb85..5a80ff0 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -328,22 +328,6 @@ REQ_VAR_R(backend, director, struct director *) REQ_VAR_L(ttl, d_ttl, double, if (!(arg>0.0)) arg = 0;) REQ_VAR_R(ttl, d_ttl, double) -unsigned -VRT_r_req_backend_healthy(const struct vrt_ctx *ctx) -{ - - CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); - CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); - /* - * XXX: Not optimal, but we do not have a backend in vcl_deliver - * XXX: and we have to return something. - */ - if (ctx->req->director == NULL) - return (0); - CHECK_OBJ_NOTNULL(ctx->req->director, DIRECTOR_MAGIC); - return (VDI_Healthy(ctx->req->director)); -} - /*--------------------------------------------------------------------*/ void @@ -366,16 +350,6 @@ VRT_r_bereq_backend(const struct vrt_ctx *ctx) return (ctx->bo->director); } -unsigned -VRT_r_bereq_backend_healthy(const struct vrt_ctx *ctx) -{ - - CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); - CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC); - CHECK_OBJ_NOTNULL(ctx->bo->director, DIRECTOR_MAGIC); - return (VDI_Healthy(ctx->bo->director)); -} - /*--------------------------------------------------------------------*/ void diff --git a/bin/varnishtest/tests/r01228.vcl b/bin/varnishtest/tests/r01228.vcl index 55d5689..1cb7e01 100644 --- a/bin/varnishtest/tests/r01228.vcl +++ b/bin/varnishtest/tests/r01228.vcl @@ -6,8 +6,11 @@ server s1 { } -start varnish v1 -vcl+backend { + + import ${vmod_std}; + sub vcl_deliver { - set resp.http.x-foo = req.backend.healthy; + set resp.http.x-foo = std.healthy(req.backend); } } -start diff --git a/bin/varnishtest/tests/v00014.vtc b/bin/varnishtest/tests/v00014.vtc index 5477a98..67d3431 100644 --- a/bin/varnishtest/tests/v00014.vtc +++ b/bin/varnishtest/tests/v00014.vtc @@ -8,6 +8,8 @@ server s1 { varnish v1 -vcl { + import ${vmod_std}; + probe foo { .url = "/"; .timeout = 1s; @@ -25,7 +27,7 @@ varnish v1 -vcl { } sub vcl_recv { - if (req.backend.healthy) { + if (std.healthy(req.backend)) { return(error(200,"Backend healthy")); } else { return(error(500,"Backend sick")); diff --git a/lib/libvcc/generate.py b/lib/libvcc/generate.py index 9a00c37..a41c246 100755 --- a/lib/libvcc/generate.py +++ b/lib/libvcc/generate.py @@ -229,13 +229,6 @@ The client's IP address. The backend to use to service the request. """ ), - ('req.backend.healthy', - 'BOOL', - ( 'client',), - ( ), """ - XXX: remove: foo.healthy() - """ - ), ('req.hash_ignore_busy', 'BOOL', ( 'recv',), @@ -266,13 +259,6 @@ The client's IP address. ( 'pipe', 'backend', ), """ """ ), - ('bereq.backend.healthy', - 'BOOL', - ( 'pipe', 'backend', ), - ( ), """ - XXX: remove: foo.healthy() - """ - ), ('bereq.method', 'STRING', ( 'pipe', 'backend', ), diff --git a/lib/libvmod_std/vmod.vcc b/lib/libvmod_std/vmod.vcc index 1f4e33e..f07b8c2 100644 --- a/lib/libvmod_std/vmod.vcc +++ b/lib/libvmod_std/vmod.vcc @@ -37,3 +37,4 @@ Function DURATION duration(STRING, DURATION) Function INT integer(STRING, INT) Function VOID collect(HEADER) Function IP ip(STRING, IP) +Function BOOL healthy(BACKEND) diff --git a/lib/libvmod_std/vmod_std.c b/lib/libvmod_std/vmod_std.c index c865494..9d20b95 100644 --- a/lib/libvmod_std/vmod_std.c +++ b/lib/libvmod_std/vmod_std.c @@ -42,6 +42,7 @@ #include "vtcp.h" #include "cache/cache.h" +#include "cache/cache_backend.h" #include "vcc_if.h" @@ -183,3 +184,13 @@ vmod_collect(const struct vrt_ctx *ctx, VCL_HEADER hdr) http_CollectHdr(ctx->http_resp, hdr->what); } } + +VCL_BOOL __match_proto__(td_std_healthy) +vmod_healthy(const struct vrt_ctx *ctx, VCL_BACKEND be) +{ + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + if (be == NULL) + return (0); + CHECK_OBJ_NOTNULL(be, DIRECTOR_MAGIC); + return (VDI_Healthy(be)); +} From phk at varnish-cache.org Fri Nov 22 15:38:00 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Fri, 22 Nov 2013 16:38:00 +0100 Subject: [master] 2267706 Add INT std.port(IP) which extracts the TCP port number. Message-ID: commit 2267706254f63894d3735707a90b85c7e5b69fe5 Author: Poul-Henning Kamp Date: Fri Nov 22 15:35:58 2013 +0000 Add INT std.port(IP) which extracts the TCP port number. By default IP renders as STRING with just the IP number, so if you want to get the port number there too, you have to do something like: set resp.http.where = client.ip + ":" + std.port(client.ip); Not too elegant, but it will do. Remove the "hard-coded" "foo.port" VCL variables. diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index 5a80ff0..5e67e76 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -40,7 +40,6 @@ #include "cache_backend.h" #include "vrt.h" #include "vrt_obj.h" -#include "vsa.h" static char vrt_hostname[255] = ""; @@ -265,16 +264,6 @@ VRT_r_beresp_backend_ip(const struct vrt_ctx *ctx) return(ctx->bo->vbc->addr); } -long -VRT_r_beresp_backend_port(const struct vrt_ctx *ctx) -{ - - CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); - CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC); - CHECK_OBJ_NOTNULL(ctx->bo->vbc, VBC_MAGIC); - return (VSA_Port(ctx->bo->vbc->addr)); -} - const char * VRT_r_beresp_storage(const struct vrt_ctx *ctx) { @@ -546,20 +535,6 @@ VRT_r_server_hostname(const struct vrt_ctx *ctx) return (vrt_hostname); } -/*-------------------------------------------------------------------- - * XXX: This is pessimistically silly - */ - -long -VRT_r_server_port(const struct vrt_ctx *ctx) -{ - - CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); - CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); - AN(ctx->req->sp->local_addr); - return (VSA_Port(ctx->req->sp->local_addr)); -} - /*--------------------------------------------------------------------*/ #define VOBJ_L(type, field) \ diff --git a/bin/varnishtest/tests/v00018.vtc b/bin/varnishtest/tests/v00018.vtc index 748e92f..c264cca 100644 --- a/bin/varnishtest/tests/v00018.vtc +++ b/bin/varnishtest/tests/v00018.vtc @@ -12,9 +12,9 @@ varnish v1 -vcl { sub vcl_hit { return(error(100,"the butter please")); } } -varnish v1 -errvcl {Variable 'server.port' is read only.} { +varnish v1 -errvcl {Variable 'now' is read only.} { backend b { .host = "127.0.0.1"; } - sub vcl_miss { set server.port = 1000; } + sub vcl_miss { set now = 1000; } } varnish v1 -vcl { @@ -34,7 +34,7 @@ varnish v1 -errvcl {Expected '=' got '+='} { varnish v1 -errvcl {Expected '=' got '+='} { backend b { .host = "127.0.0.1"; } - sub vcl_recv { set req.url += server.port; } + sub vcl_recv { set req.url += now; } } varnish v1 -errvcl {Expected ';' got 'if'} { diff --git a/bin/varnishtest/tests/v00025.vtc b/bin/varnishtest/tests/v00025.vtc index 23c2530..b090502 100644 --- a/bin/varnishtest/tests/v00025.vtc +++ b/bin/varnishtest/tests/v00025.vtc @@ -7,8 +7,10 @@ server s1 { varnish v1 -vcl+backend { + import ${vmod_std}; + sub vcl_deliver { - set resp.http.server_port = server.port; + set resp.http.server_port = std.port(server.ip); } sub vcl_backend_response { diff --git a/lib/libvcc/generate.py b/lib/libvcc/generate.py index a41c246..d7b0de9 100755 --- a/lib/libvcc/generate.py +++ b/lib/libvcc/generate.py @@ -142,14 +142,6 @@ The client's IP address. specified by the -n parameter. """ ), - ('server.port', - 'INT', - ( 'client',), - ( ), """ - The port number of the socket on which the client - connection was received. - """ - ), ('req.method', 'STRING', ( 'client',), @@ -424,13 +416,6 @@ The client's IP address. IP of the backend this response was fetched from. """ ), - ('beresp.backend.port', - 'INT', - ( 'backend_response',), - ( ), """ - Port of the backend this response was fetched from. - """ - ), ('beresp.storage', 'STRING', ( 'backend_response',), diff --git a/lib/libvmod_std/vmod.vcc b/lib/libvmod_std/vmod.vcc index f07b8c2..7db1ab0 100644 --- a/lib/libvmod_std/vmod.vcc +++ b/lib/libvmod_std/vmod.vcc @@ -38,3 +38,4 @@ Function INT integer(STRING, INT) Function VOID collect(HEADER) Function IP ip(STRING, IP) Function BOOL healthy(BACKEND) +Function INT port(IP) diff --git a/lib/libvmod_std/vmod_std.c b/lib/libvmod_std/vmod_std.c index 9d20b95..d0ec3d3 100644 --- a/lib/libvmod_std/vmod_std.c +++ b/lib/libvmod_std/vmod_std.c @@ -40,6 +40,7 @@ #include "vrt.h" #include "vtcp.h" +#include "vsa.h" #include "cache/cache.h" #include "cache/cache_backend.h" @@ -194,3 +195,12 @@ vmod_healthy(const struct vrt_ctx *ctx, VCL_BACKEND be) CHECK_OBJ_NOTNULL(be, DIRECTOR_MAGIC); return (VDI_Healthy(be)); } + +VCL_INT __match_proto__(td_std_port) +vmod_port(const struct vrt_ctx *ctx, VCL_IP ip) +{ + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + if (ip == NULL) + return (0); + return (VSA_Port(ip)); +} From phk at varnish-cache.org Tue Nov 26 15:58:10 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 26 Nov 2013 16:58:10 +0100 Subject: [master] 17ed3e9 white space nits Message-ID: commit 17ed3e94857eb20065d5707cf2e749f6e1c4524d Author: Poul-Henning Kamp Date: Tue Nov 26 07:40:06 2013 +0000 white space nits diff --git a/bin/varnishd/cache/cache_fetch_proc.c b/bin/varnishd/cache/cache_fetch_proc.c index 97a35c2..317afbb 100644 --- a/bin/varnishd/cache/cache_fetch_proc.c +++ b/bin/varnishd/cache/cache_fetch_proc.c @@ -90,6 +90,7 @@ VFP_Error(struct busyobj *bo, const char *error) * 'estimate' is the estimate of the number of bytes we expect to receive, * as seen on the socket, or zero if unknown. */ + static void __match_proto__(vfp_begin_f) vfp_nop_begin(struct busyobj *bo, size_t estimate) { diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c index 4c8f9e2..8b46bbd 100644 --- a/bin/varnishd/cache/cache_gzip.c +++ b/bin/varnishd/cache/cache_gzip.c @@ -349,7 +349,6 @@ VDP_gunzip(struct req *req, enum vdp_action act, const void *ptr, ssize_t len) return (0); } - /*-------------------------------------------------------------------- * Gunzip ibuf into outb, if it runs full, emit it with WRW. * Leave flushing to caller, more data may be coming. From phk at varnish-cache.org Tue Nov 26 15:58:10 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 26 Nov 2013 16:58:10 +0100 Subject: [master] 499bde9 Constify the vfp structs Message-ID: commit 499bde928f8e86a6f05e3e52d6cffcfd47cc721c Author: Poul-Henning Kamp Date: Tue Nov 26 13:27:38 2013 +0000 Constify the vfp structs diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 77a109a..8cb3a4d 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -270,10 +270,10 @@ struct vfp { vfp_end_f *end; }; -extern struct vfp vfp_gunzip; -extern struct vfp vfp_gzip; -extern struct vfp vfp_testgzip; -extern struct vfp vfp_esi; +extern const struct vfp vfp_gunzip; +extern const struct vfp vfp_gzip; +extern const struct vfp vfp_testgzip; +extern const struct vfp vfp_esi; /* Deliver processors ------------------------------------------------*/ @@ -540,7 +540,7 @@ struct busyobj { unsigned is_gzip; unsigned is_gunzip; - struct vfp *vfp; + const struct vfp *vfp; struct vep_state *vep; enum busyobj_state_e state; struct vgz *vgz_rx; @@ -932,7 +932,7 @@ struct storage *VFP_GetStorage(struct busyobj *, ssize_t sz); int VFP_Error2(struct busyobj *, const char *error, const char *more); int VFP_Error(struct busyobj *, const char *error); void VFP_Init(void); -extern struct vfp VFP_nop; +extern const struct vfp VFP_nop; /* cache_gzip.c */ struct vgz; diff --git a/bin/varnishd/cache/cache_esi_fetch.c b/bin/varnishd/cache/cache_esi_fetch.c index 6218cc2..6cf8dbd 100644 --- a/bin/varnishd/cache/cache_esi_fetch.c +++ b/bin/varnishd/cache/cache_esi_fetch.c @@ -415,7 +415,7 @@ vfp_esi_end(struct busyobj *bo) return (retval); } -struct vfp vfp_esi = { +const struct vfp vfp_esi = { .begin = vfp_esi_begin, .bytes = vfp_esi_bytes, .end = vfp_esi_end, diff --git a/bin/varnishd/cache/cache_fetch_proc.c b/bin/varnishd/cache/cache_fetch_proc.c index 317afbb..9021e6b 100644 --- a/bin/varnishd/cache/cache_fetch_proc.c +++ b/bin/varnishd/cache/cache_fetch_proc.c @@ -153,7 +153,7 @@ vfp_nop_end(struct busyobj *bo) return (0); } -struct vfp VFP_nop = { +const struct vfp VFP_nop = { .begin = vfp_nop_begin, .bytes = vfp_nop_bytes, .end = vfp_nop_end, diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c index 8b46bbd..4c845aa 100644 --- a/bin/varnishd/cache/cache_gzip.c +++ b/bin/varnishd/cache/cache_gzip.c @@ -540,7 +540,7 @@ vfp_gunzip_end(struct busyobj *bo) return (0); } -struct vfp vfp_gunzip = { +const struct vfp vfp_gunzip = { .begin = vfp_gunzip_begin, .bytes = vfp_gunzip_bytes, .end = vfp_gunzip_end, @@ -625,7 +625,7 @@ vfp_gzip_end(struct busyobj *bo) return (0); } -struct vfp vfp_gzip = { +const struct vfp vfp_gzip = { .begin = vfp_gzip_begin, .bytes = vfp_gzip_bytes, .end = vfp_gzip_end, @@ -710,7 +710,7 @@ vfp_testgzip_end(struct busyobj *bo) return (0); } -struct vfp vfp_testgzip = { +const struct vfp vfp_testgzip = { .begin = vfp_testgzip_begin, .bytes = vfp_testgzip_bytes, .end = vfp_testgzip_end, From phk at varnish-cache.org Tue Nov 26 15:58:10 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 26 Nov 2013 16:58:10 +0100 Subject: [master] 36e9a06 Move some non-protocol specific body-fetch code back to cache_fetch.c Message-ID: commit 36e9a06fe5af4e72a56f7118419b463e1c500ec0 Author: Poul-Henning Kamp Date: Tue Nov 26 13:40:22 2013 +0000 Move some non-protocol specific body-fetch code back to cache_fetch.c diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 914217e..37449a5 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -442,6 +442,39 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) VBO_setstate(bo, BOS_FETCHING); V1F_fetch_body(wrk, bo); + + bo->vfp = NULL; + + VSLb(bo->vsl, SLT_Fetch_Body, "%u(%s)", + bo->htc.body_status, body_status_2str(bo->htc.body_status)); + + http_Teardown(bo->bereq); + http_Teardown(bo->beresp); + + if (bo->state == BOS_FAILED) { + wrk->stats.fetch_failed++; + } else { + assert(bo->state == BOS_FETCHING); + + VSLb(bo->vsl, SLT_Length, "%zd", obj->len); + + { + /* Sanity check fetch methods accounting */ + ssize_t uu; + struct storage *st; + + uu = 0; + VTAILQ_FOREACH(st, &obj->store, list) + uu += st->len; + if (bo->do_stream) + /* Streaming might have started freeing stuff */ + assert(uu <= obj->len); + + else + assert(uu == obj->len); + } + } + if (!bo->do_stream && bo->state != BOS_FAILED) HSH_Unbusy(&wrk->stats, obj->objcore); diff --git a/bin/varnishd/cache/cache_http1_fetch.c b/bin/varnishd/cache/cache_http1_fetch.c index bd1cc47..3f36be2 100644 --- a/bin/varnishd/cache/cache_http1_fetch.c +++ b/bin/varnishd/cache/cache_http1_fetch.c @@ -403,14 +403,6 @@ V1F_fetch_body(struct worker *wrk, struct busyobj *bo) } } - bo->vfp = NULL; - - VSLb(bo->vsl, SLT_Fetch_Body, "%u(%s) cls %d", - htc->body_status, body_status_2str(htc->body_status), cls); - - http_Teardown(bo->bereq); - http_Teardown(bo->beresp); - if (bo->vbc != NULL) { if (cls) VDI_CloseFd(&bo->vbc); @@ -419,27 +411,5 @@ V1F_fetch_body(struct worker *wrk, struct busyobj *bo) } AZ(bo->vbc); - if (bo->state == BOS_FAILED) { - wrk->stats.fetch_failed++; - } else { - assert(bo->state == BOS_FETCHING); - - VSLb(bo->vsl, SLT_Length, "%zd", obj->len); - - { - /* Sanity check fetch methods accounting */ - ssize_t uu; - - uu = 0; - VTAILQ_FOREACH(st, &obj->store, list) - uu += st->len; - if (bo->do_stream) - /* Streaming might have started freeing stuff */ - assert(uu <= obj->len); - - else - assert(uu == obj->len); - } - } bo->stats = NULL; } From phk at varnish-cache.org Tue Nov 26 18:51:11 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 26 Nov 2013 19:51:11 +0100 Subject: [master] 41f7a35 Fix an oversight when we closed #942: The exact same condition can happen if we gunzip on fetch. Message-ID: commit 41f7a356e2be38f03428589710d163bd4110d9fd Author: Poul-Henning Kamp Date: Tue Nov 26 18:50:39 2013 +0000 Fix an oversight when we closed #942: The exact same condition can happen if we gunzip on fetch. diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c index 4c845aa..09f1594 100644 --- a/bin/varnishd/cache/cache_gzip.c +++ b/bin/varnishd/cache/cache_gzip.c @@ -516,6 +516,8 @@ vfp_gunzip_bytes(struct busyobj *bo, struct http_conn *htc, ssize_t bytes) i = VGZ_Gunzip(vg, &dp, &dl); if (i != VGZ_OK && i != VGZ_END) return(VFP_Error(bo, "Gunzip data error")); + if (i == VGZ_END && !VGZ_IbufEmpty(vg)) + return(VFP_Error(bo, "Junk after gzip data")); VBO_extend(bo, dl); } assert(i == Z_OK || i == Z_STREAM_END); diff --git a/bin/varnishtest/tests/r00942.vtc b/bin/varnishtest/tests/r00942.vtc index f4c808a..171ceb3 100644 --- a/bin/varnishtest/tests/r00942.vtc +++ b/bin/varnishtest/tests/r00942.vtc @@ -1,9 +1,10 @@ varnishtest "#942 junk after gzip from backend" -server s1 { +server s1 -repeat 2 { rxreq txresp -nolen \ -hdr "Content-Encoding: gzip" \ + -hdr "Connection: close" \ -hdr "Transfer-Encoding: Chunked" send "14\r\n" # An empty gzip file: @@ -21,13 +22,17 @@ server s1 { chunked "FOOBAR" chunkedlen 0 - + expect_close + accept } -start varnish v1 \ -vcl+backend { sub vcl_backend_response { set beresp.do_stream = false; + if (bereq.http.foo == "foo") { + set beresp.do_gunzip = true; + } } } @@ -35,7 +40,13 @@ varnish v1 -cliok "param.set debug +syncvsl" varnish v1 -start client c1 { - txreq + txreq -url /1 + rxresp + expect resp.status == 503 +} -run + +client c1 { + txreq -url /2 -hdr "Foo: foo" rxresp expect resp.status == 503 } -run From phk at varnish-cache.org Tue Nov 26 19:50:26 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 26 Nov 2013 20:50:26 +0100 Subject: [master] 6070418 De-fluff Message-ID: commit 6070418bb7cd13627e68936457930f4efd83a818 Author: Poul-Henning Kamp Date: Tue Nov 26 19:50:11 2013 +0000 De-fluff diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 8cb3a4d..8983e18 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -844,7 +844,7 @@ void VBO_waitstate(struct busyobj *bo, enum busyobj_state_e want); /* cache_http1_fetch.c [V1F] */ int V1F_fetch_hdr(struct worker *wrk, struct busyobj *bo, struct req *req); -void V1F_fetch_body(struct worker *wrk, struct busyobj *bo); +void V1F_fetch_body(struct busyobj *bo); /* cache_http1_fsm.c [HTTP1] */ typedef int (req_body_iter_f)(struct req *, void *priv, void *ptr, size_t); diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 37449a5..001cb61 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -441,7 +441,7 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) assert(bo->state == BOS_REQ_DONE); VBO_setstate(bo, BOS_FETCHING); - V1F_fetch_body(wrk, bo); + V1F_fetch_body(bo); bo->vfp = NULL; diff --git a/bin/varnishd/cache/cache_http1_fetch.c b/bin/varnishd/cache/cache_http1_fetch.c index 3f36be2..0b25437 100644 --- a/bin/varnishd/cache/cache_http1_fetch.c +++ b/bin/varnishd/cache/cache_http1_fetch.c @@ -317,15 +317,13 @@ V1F_fetch_hdr(struct worker *wrk, struct busyobj *bo, struct req *req) */ void -V1F_fetch_body(struct worker *wrk, struct busyobj *bo) +V1F_fetch_body(struct busyobj *bo) { - int cls; struct storage *st; ssize_t cl; struct http_conn *htc; struct object *obj; - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); htc = &bo->htc; CHECK_OBJ_ORNULL(bo->vbc, VBC_MAGIC); @@ -335,20 +333,12 @@ V1F_fetch_body(struct worker *wrk, struct busyobj *bo) assert(bo->state == BOS_FETCHING); - /* - * XXX: The busyobj needs a dstat, but it is not obvious which one - * XXX: it should be (own/borrowed). For now borrow the wrk's. - */ - AZ(bo->stats); - bo->stats = &wrk->stats; - AN(bo->vfp); AZ(bo->vgz_rx); assert(VTAILQ_EMPTY(&obj->store)); /* XXX: pick up estimate from objdr ? */ cl = 0; - cls = bo->should_close; switch (htc->body_status) { case BS_NONE: break; @@ -359,14 +349,14 @@ V1F_fetch_body(struct worker *wrk, struct busyobj *bo) bo->vfp->begin(bo, cl); if (bo->state == BOS_FETCHING && cl > 0) - cls |= vbf_fetch_straight(bo, htc, cl); + bo->should_close |= vbf_fetch_straight(bo, htc, cl); if (bo->vfp->end(bo)) assert(bo->state == BOS_FAILED); break; case BS_CHUNKED: bo->vfp->begin(bo, cl > 0 ? cl : 0); if (bo->state == BOS_FETCHING) - cls |= vbf_fetch_chunked(bo, htc); + bo->should_close |= vbf_fetch_chunked(bo, htc); if (bo->vfp->end(bo)) assert(bo->state == BOS_FAILED); break; @@ -374,12 +364,13 @@ V1F_fetch_body(struct worker *wrk, struct busyobj *bo) bo->vfp->begin(bo, cl > 0 ? cl : 0); if (bo->state == BOS_FETCHING) vbf_fetch_eof(bo, htc); - cls = 1; + bo->should_close = 1; if (bo->vfp->end(bo)) assert(bo->state == BOS_FAILED); break; case BS_ERROR: - cls |= VFP_Error(bo, "error incompatible Transfer-Encoding"); + bo->should_close |= + VFP_Error(bo, "error incompatible Transfer-Encoding"); break; default: INCOMPL(); @@ -404,12 +395,10 @@ V1F_fetch_body(struct worker *wrk, struct busyobj *bo) } if (bo->vbc != NULL) { - if (cls) + if (bo->should_close) VDI_CloseFd(&bo->vbc); else VDI_RecycleFd(&bo->vbc); } AZ(bo->vbc); - - bo->stats = NULL; } From phk at varnish-cache.org Tue Nov 26 20:24:37 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Tue, 26 Nov 2013 21:24:37 +0100 Subject: [master] eef05a8 Eliminate BS_ZERO, it's same as BS_NONE. Message-ID: commit eef05a8a013adc21116991f2b7c7311c1351164c Author: Poul-Henning Kamp Date: Tue Nov 26 20:24:09 2013 +0000 Eliminate BS_ZERO, it's same as BS_NONE. Explicitly set BS_NONE for synth 503. diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 001cb61..576fffc 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -199,6 +199,8 @@ vbf_stp_fetchhdr(struct worker *wrk, struct busyobj *bo) * NB: Also sets other wrk variables */ bo->htc.body_status = RFC2616_Body(bo, &wrk->stats); + if (i && bo->htc.body_status == BS_LENGTH) + bo->htc.body_status = BS_NONE; bo->err_code = http_GetStatus(bo->beresp); diff --git a/bin/varnishd/cache/cache_http1_fetch.c b/bin/varnishd/cache/cache_http1_fetch.c index 0b25437..f236053 100644 --- a/bin/varnishd/cache/cache_http1_fetch.c +++ b/bin/varnishd/cache/cache_http1_fetch.c @@ -342,8 +342,6 @@ V1F_fetch_body(struct busyobj *bo) switch (htc->body_status) { case BS_NONE: break; - case BS_ZERO: - break; case BS_LENGTH: cl = vbf_fetch_number(bo->h_content_length, 10); diff --git a/bin/varnishd/cache/cache_rfc2616.c b/bin/varnishd/cache/cache_rfc2616.c index 4bd45ca..dcf4c55 100644 --- a/bin/varnishd/cache/cache_rfc2616.c +++ b/bin/varnishd/cache/cache_rfc2616.c @@ -259,7 +259,7 @@ RFC2616_Body(struct busyobj *bo, struct dstat *stats) * We assume a zero length body. */ stats->fetch_zero++; - return (BS_ZERO); + return (BS_NONE); } if (http_HdrIs(hp, H_Connection, "close")) { diff --git a/include/tbl/body_status.h b/include/tbl/body_status.h index 33803f9..5f6031f 100644 --- a/include/tbl/body_status.h +++ b/include/tbl/body_status.h @@ -30,7 +30,6 @@ /*lint -save -e525 -e539 */ BODYSTATUS(NONE, none) -BODYSTATUS(ZERO, zero) BODYSTATUS(ERROR, error) BODYSTATUS(CHUNKED, chunked) BODYSTATUS(LENGTH, length) From phk at varnish-cache.org Tue Nov 26 23:26:04 2013 From: phk at varnish-cache.org (Poul-Henning Kamp) Date: Wed, 27 Nov 2013 00:26:04 +0100 Subject: [master] 779406a Shuffle more stuff between proto-specific and generic fetch code. Message-ID: commit 779406a61d90ad988ac3b85c9a408e5c1042355d Author: Poul-Henning Kamp Date: Tue Nov 26 23:25:21 2013 +0000 Shuffle more stuff between proto-specific and generic fetch code. diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 576fffc..8a738cc 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -443,7 +443,31 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) assert(bo->state == BOS_REQ_DONE); VBO_setstate(bo, BOS_FETCHING); - V1F_fetch_body(bo); + switch (bo->htc.body_status) { + case BS_NONE: + break; + case BS_ERROR: + /* XXX: Why not earlier ? */ + bo->should_close |= + VFP_Error(bo, "error incompatible Transfer-Encoding"); + break; + default: + if (bo->vbc == NULL) + (void)VFP_Error(bo, "Backend connection gone"); + else + V1F_fetch_body(bo); + break; + } + + bo->t_body = VTIM_mono(); + + if (bo->vbc != NULL) { + if (bo->should_close) + VDI_CloseFd(&bo->vbc); + else + VDI_RecycleFd(&bo->vbc); + AZ(bo->vbc); + } bo->vfp = NULL; diff --git a/bin/varnishd/cache/cache_http1_fetch.c b/bin/varnishd/cache/cache_http1_fetch.c index f236053..3e16bcb 100644 --- a/bin/varnishd/cache/cache_http1_fetch.c +++ b/bin/varnishd/cache/cache_http1_fetch.c @@ -330,6 +330,7 @@ V1F_fetch_body(struct busyobj *bo) obj = bo->fetch_obj; CHECK_OBJ_NOTNULL(obj, OBJECT_MAGIC); CHECK_OBJ_NOTNULL(obj->http, HTTP_MAGIC); + AN(bo->vbc); assert(bo->state == BOS_FETCHING); @@ -340,8 +341,6 @@ V1F_fetch_body(struct busyobj *bo) /* XXX: pick up estimate from objdr ? */ cl = 0; switch (htc->body_status) { - case BS_NONE: - break; case BS_LENGTH: cl = vbf_fetch_number(bo->h_content_length, 10); @@ -366,14 +365,9 @@ V1F_fetch_body(struct busyobj *bo) if (bo->vfp->end(bo)) assert(bo->state == BOS_FAILED); break; - case BS_ERROR: - bo->should_close |= - VFP_Error(bo, "error incompatible Transfer-Encoding"); - break; default: - INCOMPL(); + WRONG("Wrong body_status"); } - bo->t_body = VTIM_mono(); AZ(bo->vgz_rx); /* @@ -391,12 +385,4 @@ V1F_fetch_body(struct busyobj *bo) STV_trim(st, st->len, 1); } } - - if (bo->vbc != NULL) { - if (bo->should_close) - VDI_CloseFd(&bo->vbc); - else - VDI_RecycleFd(&bo->vbc); - } - AZ(bo->vbc); } From git at varnish-cache.org Wed Nov 27 14:37:43 2013 From: git at varnish-cache.org (git at varnish-cache.org) Date: Wed, 27 Nov 2013 15:37:43 +0100 Subject: [master] 32fc2d8 improve documentation wording Message-ID: commit 32fc2d8a19494992f0fa9f8c00a262470275d1ba Author: Nils Goroll Date: Wed Nov 27 15:20:14 2013 +0100 improve documentation wording (as a test push) diff --git a/doc/sphinx/reference/params.rst b/doc/sphinx/reference/params.rst index e4e3e48..e475158 100644 --- a/doc/sphinx/reference/params.rst +++ b/doc/sphinx/reference/params.rst @@ -21,7 +21,7 @@ acceptor_sleep_decay * Flags: experimental If we run out of resources, such as file descriptors or worker threads, the acceptor will sleep between accepts. -This parameter (multiplicatively) reduce the sleep duration for each succesfull accept. (ie: 0.9 = reduce by 10%) +This parameter (multiplicatively) reduces the sleep duration for each succesfull accept. (ie: 0.9 = reduce by 10%) .. _ref_param_acceptor_sleep_incr: @@ -34,7 +34,7 @@ acceptor_sleep_incr * Flags: experimental If we run out of resources, such as file descriptors or worker threads, the acceptor will sleep between accepts. -This parameter control how much longer we sleep, each time we fail to accept a new connection. +This parameter control how much longer we sleep, each time we fail to accept a new connection in succession. .. _ref_param_acceptor_sleep_max: @@ -56,7 +56,7 @@ auto_restart * Units: bool * Default: on -Restart child process automatically if it dies. +Restart child process automatically if it dies. This is not related to restarts in VCL. .. _ref_param_ban_dups: @@ -75,7 +75,7 @@ ban_lurker_sleep * Default: 0.010000 * Minimum: 0.000000 -How long time does the ban lurker thread sleeps between successful attempts to push the last item up the ban list. It always sleeps a second when nothing can be done. +How long time does the ban lurker thread sleep between successful attempts to push the last item up the ban list. It always sleeps a second when nothing can be done. A value of zero disables the ban lurker. .. _ref_param_between_bytes_timeout: @@ -86,7 +86,7 @@ between_bytes_timeout * Default: 60.000000 * Minimum: 0.000000 -Default timeout between bytes when receiving data from backend. We only wait for this many seconds between bytes before giving up. A value of 0 means it will never time out. VCL can override this default value for each backend request and backend request. This parameter does not apply to pipe. +Default timeout between bytes when receiving data from backend. We only wait for this many seconds between bytes before giving up. A value of 0 means it will never time out. VCL can override this default value for each backend request and backend request. This parameter does not apply to pipe mode. .. _ref_param_busyobj_worker_cache: @@ -116,7 +116,7 @@ cli_buffer Size of buffer for CLI command input. You may need to increase this if you have big VCL files and use the vcl.inline CLI command. -NB: Must be specified with -p to have effect. +NB: Must be specified with -p to have an effect. .. _ref_param_cli_limit: @@ -137,7 +137,7 @@ cli_timeout * Default: 10 * Minimum: 0 -Timeout for the childs replies to CLI requests from the mgt_param. +Timeout for CLI requests from the parent to the child process. If this timeout expires before the child responds, the master process will terminate the child process. The setting of auto_restart determines if it will get restarted automatically. .. _ref_param_clock_skew: From git at varnish-cache.org Wed Nov 27 14:41:00 2013 From: git at varnish-cache.org (git at varnish-cache.org) Date: Wed, 27 Nov 2013 15:41:00 +0100 Subject: [master] 74b49b8 Fix dependencies for Debian/Ubuntu Message-ID: commit 74b49b84c3d4962495eae6915a7a3746e615680f Author: Andreas Plesner Jacobsen Date: Wed Nov 27 15:34:35 2013 +0100 Fix dependencies for Debian/Ubuntu diff --git a/doc/sphinx/installation/install.rst b/doc/sphinx/installation/install.rst index e0b0ceb..e8b0ff7 100644 --- a/doc/sphinx/installation/install.rst +++ b/doc/sphinx/installation/install.rst @@ -29,7 +29,7 @@ CentOS/RedHat ------------- We try to keep the latest version available as prebuilt RPMs (el5 and el6) -on `repo.varnish-cache.org `. See the +on `repo.varnish-cache.org `_. See the `RedHat installation instructions `_ for more information. @@ -76,13 +76,15 @@ In order to build Varnish from source you need a number of packages installed. On a Debian or Ubuntu system these are: * autotools-dev -* automake1.9 +* automake1.11 * libtool * autoconf * libncurses-dev * groff-base * libpcre3-dev * pkg-config +* make +* libedit-dev Build dependencies on Red Hat / CentOS -------------------------------------- From git at varnish-cache.org Wed Nov 27 15:49:30 2013 From: git at varnish-cache.org (git at varnish-cache.org) Date: Wed, 27 Nov 2013 16:49:30 +0100 Subject: [master] b69efc2 Fix rst syntax Message-ID: commit b69efc247c473bf585b0db3ebfa5e640cf9b09bc Author: Andreas Plesner Jacobsen Date: Wed Nov 27 16:49:13 2013 +0100 Fix rst syntax diff --git a/doc/sphinx/reference/vmod_std.rst b/doc/sphinx/reference/vmod_std.rst index c0b6c6e..d80cb5b 100644 --- a/doc/sphinx/reference/vmod_std.rst +++ b/doc/sphinx/reference/vmod_std.rst @@ -151,8 +151,7 @@ Description Converts string *s* to the first IP number returned by the system library function getaddrinfo(3). If conversion fails, *fallback* will be returned. -Example: - +Example if (std.ip(req.http.X-forwarded-for, "0.0.0.0") ~ my_acl) { ... } From tfheen at varnish-software.com Thu Nov 28 07:51:02 2013 From: tfheen at varnish-software.com (Tollef Fog Heen) Date: Thu, 28 Nov 2013 08:51:02 +0100 Subject: [master] ade0181 Disable -Werror for warn_unused_result. Message-ID: commit ade01815deceebaa2107fa9aea2847b8a54e51ee Author: Tollef Fog Heen Date: Thu Nov 28 08:49:09 2013 +0100 Disable -Werror for warn_unused_result. There is no way to disable warn_unused_result and glibc (or the gcc fortification patches) add that to write in higher optimisation levels. We'll take the warning, but not make it fatal. See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25509 for the relevant gcc bug report. diff --git a/configure.ac b/configure.ac index 6fdd780..6b3fcd4 100644 --- a/configure.ac +++ b/configure.ac @@ -451,9 +451,13 @@ gl_LD_VERSION_SCRIPT # Now that we're done using the compiler to look for functions and # libraries, set CFLAGS to what we want them to be for our own code -# This is a test to see how much havoc Jenkins exposes -CFLAGS="${CFLAGS} -Wall -Werror" -OCFLAGS="${OCFLAGS} -Wall -Werror" +# This is a test to see how much havoc Jenkins exposes. +# +# The reason for -Wno-error=unused-result is a glibc/gcc interaction +# idiocy where write is marked as warn_unused_result, causing build +# failures. +CFLAGS="${CFLAGS} -Wall -Werror -Wno-error=unused-result" +OCFLAGS="${OCFLAGS} -Wall -Werror -Wno-error=unused-result" # This corresponds to FreeBSD's WARNS level 6 DEVELOPER_CFLAGS="-fstack-protector -Werror -Wall -Wno-format-y2k -W -Wno-unused-parameter -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wshadow -Wunused-parameter -Wcast-align -Wchar-subscripts -Winline -Wnested-externs -Wno-pointer-sign -Wextra -Wno-missing-field-initializers -Wno-sign-compare" From tfheen at varnish-software.com Thu Nov 28 09:47:18 2013 From: tfheen at varnish-software.com (Tollef Fog Heen) Date: Thu, 28 Nov 2013 10:47:18 +0100 Subject: [master] d6cc53d Only use -Wno-error=unused-result if the compiler supports it Message-ID: commit d6cc53d9839ccdcfe1c9e53d84150ae985f59d01 Author: Tollef Fog Heen Date: Thu Nov 28 10:46:57 2013 +0100 Only use -Wno-error=unused-result if the compiler supports it Yay, gcc. Or something. diff --git a/configure.ac b/configure.ac index 6b3fcd4..5d01ee9 100644 --- a/configure.ac +++ b/configure.ac @@ -456,8 +456,13 @@ gl_LD_VERSION_SCRIPT # The reason for -Wno-error=unused-result is a glibc/gcc interaction # idiocy where write is marked as warn_unused_result, causing build # failures. -CFLAGS="${CFLAGS} -Wall -Werror -Wno-error=unused-result" -OCFLAGS="${OCFLAGS} -Wall -Werror -Wno-error=unused-result" +CFLAGS="${CFLAGS} -Wall -Werror" +OCFLAGS="${OCFLAGS} -Wall -Werror" +AX_CHECK_COMPILE_FLAG([-Wno-error=unused-result], + [CFLAGS="${CFLAGS} -Wno-error=warn-unused-result + OCFLAGS="${OCFLAGS} -Wno-error=warn-unused-result], + [CFLAGS="${CFLAGS} -Wno-unused-result" + OCFLAGS="${OCFLAGS} -Wno-unused-result"]) # This corresponds to FreeBSD's WARNS level 6 DEVELOPER_CFLAGS="-fstack-protector -Werror -Wall -Wno-format-y2k -W -Wno-unused-parameter -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wshadow -Wunused-parameter -Wcast-align -Wchar-subscripts -Winline -Wnested-externs -Wno-pointer-sign -Wextra -Wno-missing-field-initializers -Wno-sign-compare" diff --git a/m4/ax_check_compile_flag.m4 b/m4/ax_check_compile_flag.m4 new file mode 100644 index 0000000..c3a8d69 --- /dev/null +++ b/m4/ax_check_compile_flag.m4 @@ -0,0 +1,72 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS]) +# +# DESCRIPTION +# +# Check whether the given FLAG works with the current language's compiler +# or gives an error. (Warnings, however, are ignored) +# +# ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on +# success/failure. +# +# If EXTRA-FLAGS is defined, it is added to the current language's default +# flags (e.g. CFLAGS) when the check is done. The check is thus made with +# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to +# force the compiler to issue an error when a bad flag is given. +# +# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this +# macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG. +# +# LICENSE +# +# Copyright (c) 2008 Guido U. Draheim +# Copyright (c) 2011 Maarten Bosmans +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation, either version 3 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 2 + +AC_DEFUN([AX_CHECK_COMPILE_FLAG], +[AC_PREREQ(2.59)dnl for _AC_LANG_PREFIX +AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl +AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [ + ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS + _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM()], + [AS_VAR_SET(CACHEVAR,[yes])], + [AS_VAR_SET(CACHEVAR,[no])]) + _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags]) +AS_IF([test x"AS_VAR_GET(CACHEVAR)" = xyes], + [m4_default([$2], :)], + [m4_default([$3], :)]) +AS_VAR_POPDEF([CACHEVAR])dnl +])dnl AX_CHECK_COMPILE_FLAGS From tfheen at varnish-software.com Thu Nov 28 11:33:23 2013 From: tfheen at varnish-software.com (Tollef Fog Heen) Date: Thu, 28 Nov 2013 12:33:23 +0100 Subject: [master] 7cf7224 Typos-r-us Message-ID: commit 7cf7224e82b9ec682dffcee6e7d9f87aafefb0f1 Author: Tollef Fog Heen Date: Thu Nov 28 12:33:19 2013 +0100 Typos-r-us diff --git a/configure.ac b/configure.ac index 5d01ee9..ea7adc9 100644 --- a/configure.ac +++ b/configure.ac @@ -459,8 +459,8 @@ gl_LD_VERSION_SCRIPT CFLAGS="${CFLAGS} -Wall -Werror" OCFLAGS="${OCFLAGS} -Wall -Werror" AX_CHECK_COMPILE_FLAG([-Wno-error=unused-result], - [CFLAGS="${CFLAGS} -Wno-error=warn-unused-result - OCFLAGS="${OCFLAGS} -Wno-error=warn-unused-result], + [CFLAGS="${CFLAGS} -Wno-error=unused-result" + OCFLAGS="${OCFLAGS} -Wno-error=unused-result"], [CFLAGS="${CFLAGS} -Wno-unused-result" OCFLAGS="${OCFLAGS} -Wno-unused-result"]) From tfheen at varnish-software.com Thu Nov 28 12:03:50 2013 From: tfheen at varnish-software.com (Tollef Fog Heen) Date: Thu, 28 Nov 2013 13:03:50 +0100 Subject: [master] b9226c1 Only add -Wno-unused-result if supported. Message-ID: commit b9226c1f7ed85f0f277f7a11b4dbbc6deb4d4e26 Author: Tollef Fog Heen Date: Thu Nov 28 13:03:41 2013 +0100 Only add -Wno-unused-result if supported. diff --git a/configure.ac b/configure.ac index ea7adc9..10ed5d1 100644 --- a/configure.ac +++ b/configure.ac @@ -461,8 +461,9 @@ OCFLAGS="${OCFLAGS} -Wall -Werror" AX_CHECK_COMPILE_FLAG([-Wno-error=unused-result], [CFLAGS="${CFLAGS} -Wno-error=unused-result" OCFLAGS="${OCFLAGS} -Wno-error=unused-result"], - [CFLAGS="${CFLAGS} -Wno-unused-result" - OCFLAGS="${OCFLAGS} -Wno-unused-result"]) + [AX_CHECK_COMPILE_FLAG([-Wno-unused-result], + [CFLAGS="${CFLAGS} -Wno-unused-result" + OCFLAGS="${OCFLAGS} -Wno-unused-result"])]) # This corresponds to FreeBSD's WARNS level 6 DEVELOPER_CFLAGS="-fstack-protector -Werror -Wall -Wno-format-y2k -W -Wno-unused-parameter -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Wreturn-type -Wcast-qual -Wwrite-strings -Wswitch -Wshadow -Wunused-parameter -Wcast-align -Wchar-subscripts -Winline -Wnested-externs -Wno-pointer-sign -Wextra -Wno-missing-field-initializers -Wno-sign-compare" From apj at mutt.dk Fri Nov 29 11:13:07 2013 From: apj at mutt.dk (Andreas Plesner Jacobsen) Date: Fri, 29 Nov 2013 12:13:07 +0100 Subject: [master] 81564ae Update dependencies. Be more specific about building from git Message-ID: commit 81564ae79f2423479b5589201f6e338b479ceb22 Author: Andreas Plesner Jacobsen Date: Fri Nov 29 12:12:41 2013 +0100 Update dependencies. Be more specific about building from git diff --git a/doc/sphinx/installation/install.rst b/doc/sphinx/installation/install.rst index e8b0ff7..a5d1294 100644 --- a/doc/sphinx/installation/install.rst +++ b/doc/sphinx/installation/install.rst @@ -86,6 +86,11 @@ installed. On a Debian or Ubuntu system these are: * make * libedit-dev +If you're building from git, you also need the following: + +* python-docutils +* python-sphinx (optional, if you want the HTML docs built) + Build dependencies on Red Hat / CentOS -------------------------------------- @@ -99,6 +104,12 @@ packages installed: * groff * pcre-devel * pkgconfig +* libedit-devel + +If you're building from git, you also need the following: + +* docutils +* python-sphinx (optional, if you want the HTML docs built) Configuring and compiling ------------------------- From apj at mutt.dk Fri Nov 29 11:53:00 2013 From: apj at mutt.dk (Andreas Plesner Jacobsen) Date: Fri, 29 Nov 2013 12:53:00 +0100 Subject: [master] 6fdbb2c Add introduction and seealso Message-ID: commit 6fdbb2c02c9c93a8dcc5bb14a64158fbe8b8a559 Author: Andreas Plesner Jacobsen Date: Fri Nov 29 12:52:20 2013 +0100 Add introduction and seealso diff --git a/doc/sphinx/reference/vsl.rst b/doc/sphinx/reference/vsl.rst index e254719..7f79209 100644 --- a/doc/sphinx/reference/vsl.rst +++ b/doc/sphinx/reference/vsl.rst @@ -14,7 +14,21 @@ Shared Memory Logging :Version: 1.0 :Manual section: 7 +OVERVIEW +======== + +This document describes the format and content of all the Varnish shared memory +logging tags. These tags are used by the varnishlog(1), varnishtop(1), etc. +logging tools supplied with Varnish. + VSL tags ~~~~~~~~ .. include:: ../../../lib/libvarnishapi/vsl-tags.rst + +SEE ALSO +======== +* varnishlog(1) +* varnishhist(1) +* varnishncsa(1) +* varnishtop(1) From apj at mutt.dk Fri Nov 29 12:05:10 2013 From: apj at mutt.dk (Andreas Plesner Jacobsen) Date: Fri, 29 Nov 2013 13:05:10 +0100 Subject: [master] f548d78 Build vsl-query.7 Message-ID: commit f548d78a2bac867109f0c887a7178f0c3520c6a7 Author: Andreas Plesner Jacobsen Date: Fri Nov 29 13:04:54 2013 +0100 Build vsl-query.7 diff --git a/man/Makefile.am b/man/Makefile.am index 878e7f4..56b0a52 100644 --- a/man/Makefile.am +++ b/man/Makefile.am @@ -8,7 +8,7 @@ vsc2rst_SOURCES = vsc2rst.c \ AM_CPPFLAGS = -I$(top_srcdir)/include -dist_man_MANS = vcl.7 varnish-cli.7 varnish-counters.7 vsl.7 +dist_man_MANS = vcl.7 varnish-cli.7 varnish-counters.7 vsl.7 vsl-query.7 MAINTAINERCLEANFILES = $(dist_man_MANS) vcl.7: $(top_srcdir)/doc/sphinx/reference/vcl.rst \ @@ -53,3 +53,13 @@ else @echo "========================================" @false endif + +vsl-query.7: $(top_srcdir)/doc/sphinx/reference/vsl-query.rst +if HAVE_RST2MAN + ${RST2MAN} $(top_srcdir)/doc/sphinx/reference/vsl-query.rst $@ +else + @echo "========================================" + @echo "You need rst2man installed to make dist" + @echo "========================================" + @false +endif From tfheen at varnish-software.com Fri Nov 29 12:56:20 2013 From: tfheen at varnish-software.com (Tollef Fog Heen) Date: Fri, 29 Nov 2013 13:56:20 +0100 Subject: [master] 78203c1 Check for -Wfoo rather than -Wno-foo, since gcc ignores the latter Message-ID: commit 78203c1cd83377f07e70e6bea125eef67ab19d70 Author: Tollef Fog Heen Date: Fri Nov 29 13:54:58 2013 +0100 Check for -Wfoo rather than -Wno-foo, since gcc ignores the latter diff --git a/configure.ac b/configure.ac index 10ed5d1..98f7113 100644 --- a/configure.ac +++ b/configure.ac @@ -458,10 +458,10 @@ gl_LD_VERSION_SCRIPT # failures. CFLAGS="${CFLAGS} -Wall -Werror" OCFLAGS="${OCFLAGS} -Wall -Werror" -AX_CHECK_COMPILE_FLAG([-Wno-error=unused-result], +AX_CHECK_COMPILE_FLAG([-Werror=unused-result], [CFLAGS="${CFLAGS} -Wno-error=unused-result" OCFLAGS="${OCFLAGS} -Wno-error=unused-result"], - [AX_CHECK_COMPILE_FLAG([-Wno-unused-result], + [AX_CHECK_COMPILE_FLAG([-Wunused-result], [CFLAGS="${CFLAGS} -Wno-unused-result" OCFLAGS="${OCFLAGS} -Wno-unused-result"])]) From tfheen at varnish-software.com Fri Nov 29 12:56:20 2013 From: tfheen at varnish-software.com (Tollef Fog Heen) Date: Fri, 29 Nov 2013 13:56:20 +0100 Subject: [master] 7d73643 Get ready for 4.0.0-tp1 Message-ID: commit 7d73643772f628932348fe1cb8ca43e398b4ce41 Author: Tollef Fog Heen Date: Fri Nov 29 13:55:54 2013 +0100 Get ready for 4.0.0-tp1 diff --git a/configure.ac b/configure.ac index 98f7113..51baa8d 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ AC_PREREQ(2.59) AC_COPYRIGHT([Copyright (c) 2006 Verdens Gang AS Copyright (c) 2006-2013 Varnish Software AS]) AC_REVISION([$Id$]) -AC_INIT([Varnish], [trunk], [varnish-dev at varnish-cache.org]) +AC_INIT([Varnish], [4.0.0-tp1], [varnish-dev at varnish-cache.org]) AC_CONFIG_SRCDIR(include/miniobj.h) AC_CONFIG_HEADERS([config.h]) AC_CONFIG_MACRO_DIR([m4]) diff --git a/redhat/varnish.spec b/redhat/varnish.spec index 194340b..362edcd 100644 --- a/redhat/varnish.spec +++ b/redhat/varnish.spec @@ -1,17 +1,17 @@ -%define v_rc +%define v_rc tp1 %define vd_rc %{?v_rc:-%{?v_rc}} %define _use_internal_dependency_generator 0 %define __find_provides %{_builddir}/varnish-%{version}%{?v_rc:-%{?v_rc}}/redhat/find-provides Summary: High-performance HTTP accelerator Name: varnish Version: 4.0.0 -Release: 0.20131014%{?v_rc}%{?dist} +Release: 0.20131129%{?v_rc}%{?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}-%{version}%{?vd_rc}.tar.gz -Source0: %{name}-trunk.tar.gz +Source0: %{name}-%{version}%{?vd_rc}.tar.gz +#Source0: %{name}-trunk.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 @@ -83,8 +83,8 @@ Documentation files for %name #Varnish Cache is a high-performance HTTP accelerator %prep -#%setup -q -n varnish-%{version}%{?vd_rc} -%setup -q -n varnish-trunk +%setup -n varnish-%{version}%{?vd_rc} +#%setup -q -n varnish-trunk mkdir examples cp bin/varnishd/default.vcl etc/zope-plone.vcl examples From tfheen at varnish-software.com Fri Nov 29 12:56:20 2013 From: tfheen at varnish-software.com (Tollef Fog Heen) Date: Fri, 29 Nov 2013 13:56:20 +0100 Subject: [master] a5ec345 Set -D_FORTIFY_SOURCE=0 since RHEL has too old gcc for -Wno-error=warn_unused_result Message-ID: commit a5ec34570e93cc523ec63332c8dd48bea6c2f600 Author: Tollef Fog Heen Date: Fri Nov 29 13:55:36 2013 +0100 Set -D_FORTIFY_SOURCE=0 since RHEL has too old gcc for -Wno-error=warn_unused_result diff --git a/redhat/varnish.spec b/redhat/varnish.spec index e12da5a..194340b 100644 --- a/redhat/varnish.spec +++ b/redhat/varnish.spec @@ -96,6 +96,8 @@ cp bin/varnishd/default.vcl etc/zope-plone.vcl examples export PCRE_LIBS="`pcre-config --libs`" %endif +export CFLAGS="$CFLAGS -Wp,-D_FORTIFY_SOURCE=0" + # Remove "--disable static" if you want to build static libraries # jemalloc is not compatible with Red Hat's ppc64 RHEL kernel :-( %ifarch ppc64 ppc From apj at mutt.dk Fri Nov 29 13:29:13 2013 From: apj at mutt.dk (Andreas Plesner Jacobsen) Date: Fri, 29 Nov 2013 14:29:13 +0100 Subject: [master] ba2142c Doc updates, some spotted by Tin Message-ID: commit ba2142ca6decfd67080cdb97b99ec35a08798228 Author: Andreas Plesner Jacobsen Date: Fri Nov 29 14:28:50 2013 +0100 Doc updates, some spotted by Tin diff --git a/include/tbl/vsl_tags.h b/include/tbl/vsl_tags.h index 5695784..85b0343 100644 --- a/include/tbl/vsl_tags.h +++ b/include/tbl/vsl_tags.h @@ -42,7 +42,7 @@ * Long Description (in RST "definition list" format) */ -#define NODEF_NOTICE "Note: This log record is masked by default\n\n" +#define NODEF_NOTICE "Note: This log record is masked by default and must be explicitly enabled\n\n" SLTM(Debug, SLT_F_BINARY, "Debug messages", "Debug messages can normally be ignored, but are sometimes" @@ -55,11 +55,11 @@ SLTM(Error, 0, "Error messages", ) SLTM(CLI, 0, "CLI communication", - "CLI communication between master and child process.\n\n" + "CLI communication between varnishd master and child process.\n\n" ) SLTM(ReqEnd, 0, "Client request end", - "Marks the end of client request.\n\n" + "Marks the end of a client request.\n\n" "The format is::\n\n" "\t%f %f %f %f %f\n" "\t| | | | |\n" @@ -218,11 +218,11 @@ SLTM(FetchError, 0, "Error while fetching object", SLTM(BogoHeader, 0, "Bogus HTTP received", "Contains the first 20 characters of received HTTP headers we could" - " not make sense of. Applies to both req.http and beres.http.\n\n" + " not make sense of. Applies to both req.http and beresp.http.\n\n" ) SLTM(LostHeader, 0, "Failed attempt to set HTTP header", "Logs the header name of a failed HTTP header operation due to" - " resource exhaustion.\n\n" + " resource exhaustion or configured limits.\n\n" ) SLTM(TTL, 0, "TTL set on object", @@ -303,7 +303,7 @@ SLTM(Hit, 0, "Hit object in cache", "Object looked up in cache. Shows the VXID of the object.\n\n" ) -SLTM(HitPass, 0, "Hit for pass object in cache.\n\n", +SLTM(HitPass, 0, "Hit for pass object in cache.", "Hit-for-pass object looked up in cache. Shows the VXID of the" " hit-for-pass object.\n\n" ) @@ -452,11 +452,11 @@ SLTM(VSL, 0, "VSL API warnings and error message", ) SLTM(Storage, 0, "Where object is stored", - "Type and name of stevedore object is stored in.\n\n" + "Type and name of the storage backend the object is stored in.\n\n" "The format is::\n\n" "\t%s %s\n" "\t| |\n" - "\t| +- Name of stevedore\n" + "\t| +- Name of storage backend\n" "\t+---- Type (\"malloc\", \"file\", \"persistent\" etc.)\n" "\n" ) From martin at varnish-software.com Fri Nov 29 13:44:11 2013 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Fri, 29 Nov 2013 14:44:11 +0100 Subject: [master] 0c84225 Add some missing API exports to the .map file Message-ID: commit 0c842250665f54d5dec23b44218c0c4380bbe9e9 Author: Martin Blix Grydeland Date: Fri Nov 29 14:43:25 2013 +0100 Add some missing API exports to the .map file diff --git a/lib/libvarnishapi/libvarnishapi.map b/lib/libvarnishapi/libvarnishapi.map index 2abb178..9c3ba18 100644 --- a/lib/libvarnishapi/libvarnishapi.map +++ b/lib/libvarnishapi/libvarnishapi.map @@ -118,6 +118,9 @@ LIBVARNISHAPI_1.3 { VSL_Glob2Tags; VSL_List2Tags; VSM_N_Arg; + VSL_Check; + VSL_ResetCursor; # Variables: VSLQ_grouping; + VSL_tagflags; } LIBVARNISHAPI_1.0; From apj at mutt.dk Fri Nov 29 15:26:04 2013 From: apj at mutt.dk (Andreas Plesner Jacobsen) Date: Fri, 29 Nov 2013 16:26:04 +0100 Subject: [master] 9314939 Language nit courtesy of Tin Message-ID: commit 93149399d0d10ea6f52cdcb51a105bfc03d47167 Author: Andreas Plesner Jacobsen Date: Fri Nov 29 16:25:31 2013 +0100 Language nit courtesy of Tin diff --git a/doc/sphinx/reference/vsl-query.rst b/doc/sphinx/reference/vsl-query.rst index 5aa5793..6f4a41f 100644 --- a/doc/sphinx/reference/vsl-query.rst +++ b/doc/sphinx/reference/vsl-query.rst @@ -17,22 +17,22 @@ Varnish shared memory log, and perform queries on the transactions before reporting matches. A transaction is a set of log lines that belongs together, e.g. a -client request. The API monitors the log, and collects all log records -that make up a transaction before reporting on that -transaction. Transactions can also be grouped, meaning backend +client request or a backend request. The API monitors the log, and +collects all log records that make up a transaction before reporting +on that transaction. Transactions can also be grouped, meaning backend transactions are reported together with the client transaction that initiated it. A query is run on a group of transactions. A query expression is true if there is a log record within the group that satisfies the -condition. It is false only if none of the log records satisfied the +condition. It is false only if none of the log records satisfies the condition. Query expressions can be combined using boolean functions. GROUPING ======== When grouping transactions, there is a hierarchy structure showing -which transaction initiated what. The level increases by one by a +which transaction initiated what. The level increases by one by an 'initiated by' relation, so for example a backend transaction will have one higher level than the client transaction that initiated it on a cache miss. Levels start counting at 1, except when using raw where @@ -42,7 +42,7 @@ The grouping modes are: * Session - All transactions initiated by a client connection is reported + All transactions initiated by a client connection are reported together. All log data is buffered until the client connection is closed, which can cause session grouping mode to potentially consume a lot of memory. @@ -50,8 +50,8 @@ The grouping modes are: * Request Transactions are grouped by request, where the set will include the - request itself, and any backend requests or ESI-subrequests. Session - data is not reported. This is the default. + request itself as well as any backend requests or ESI-subrequests. + Session data is not reported. This is the default. * VXID @@ -79,7 +79,7 @@ Example transaction hierarchy :: QUERY LANGUAGE ============== -A query expression consists of a record selection criteria, and +A query expression consists of record selection criteria, and optionally an operator and a value to match against the selected records. :: @@ -96,23 +96,23 @@ transaction group the expression applies to. Syntax: :: Taglist is mandatory, the other components are optional. The level limits the expression to a transaction at that level. If -left unspecified the expression is applied to transactions at all +left unspecified, the expression is applied to transactions at all levels. Level is a positive integer or zero. If level is followed by a '+' character, it expresses greater than or equal. If level is followed by a '-', it expresses less than or equal. The taglist is a comma-separated list of VSL record tags that this -expression should be applied against. Each list element can be a tag +expression should be checked against. Each list element can be a tag name or a tag glob. Globs allow a '*' either in the beginning of the name or at the end, and will select all tags that match either the prefix or subscript. A single '*' will select all tags. -The record prefix will further limit the record set matched against to -those records that has this prefix as it's first part of the record -content followed by a colon. The part of the log record matched -against will then be limited to what follows the prefix and -colon. This is useful when matching against specific HTTP headers. The -record prefix matching is done case insensitive. +The record prefix will further limit the matches to those records that +has this prefix as it's first part of the record content followed by a +colon. The part of the log record matched against will then be limited +to what follows the prefix and colon. This is useful when matching +against specific HTTP headers. The record prefix matching is done case +insensitive. The field will, if present, treat the log record as a white space separated list of fields, and only the nth part of the record will be @@ -230,7 +230,7 @@ QUERY EXPRESSION EXAMPLES ReqStatus == 304 and not ReqHeader:if-modified-since -* Transactions that has backend failures or long delivery time on +* Transactions that have had backend failures or long delivery time on their ESI subrequests. (Assumes request grouping mode). :: BerespStatus >= 500 or {2+}ReqEnd[5] > 1. From phk at FreeBSD.org Fri Nov 29 11:34:25 2013 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 29 Nov 2013 12:34:25 +0100 Subject: [master] df5e9b8 More minor flexelintery Message-ID: commit df5e9b8750e33c7a4a482de55ce48b389176a64d Author: Poul-Henning Kamp Date: Fri Nov 29 11:34:08 2013 +0000 More minor flexelintery diff --git a/lib/libvarnishapi/vsl_dispatch.c b/lib/libvarnishapi/vsl_dispatch.c index c5e7d4f..802b525 100644 --- a/lib/libvarnishapi/vsl_dispatch.c +++ b/lib/libvarnishapi/vsl_dispatch.c @@ -652,7 +652,7 @@ vtx_set_parent(struct vtx *parent, struct vtx *child) parent->n_child++; do parent->n_descend += 1 + child->n_descend; - while ((parent = parent->parent)); + while ((parent = parent->parent) != NULL); } /* Parse a begin or link record. Returns the number of elements that was @@ -1150,7 +1150,7 @@ vslq_shmref_check(struct VSLQ *vslq) struct chunk *chunk; int i; - while ((chunk = VTAILQ_FIRST(&vslq->shmrefs))) { + while ((chunk = VTAILQ_FIRST(&vslq->shmrefs)) != NULL) { CHECK_OBJ_NOTNULL(chunk, CHUNK_MAGIC); assert(chunk->type == chunk_t_shm); i = VSL_Check(vslq->c, &chunk->shm.start); From phk at FreeBSD.org Fri Nov 29 11:30:55 2013 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 29 Nov 2013 12:30:55 +0100 Subject: [master] c3f84bf Minor flexelintery Message-ID: commit c3f84bf41d7e50cf714cde595dc03ab50b1e32cc Author: Poul-Henning Kamp Date: Fri Nov 29 11:30:37 2013 +0000 Minor flexelintery diff --git a/bin/varnishlog/flint.lnt b/bin/varnishlog/flint.lnt index c0d43d8..c90f53b 100644 --- a/bin/varnishlog/flint.lnt +++ b/bin/varnishlog/flint.lnt @@ -16,5 +16,3 @@ -e788 // enum constant '___' not used within defaulted switch -e641 // Converting enum '___' to '___' - --esym(785,VSL_tags) // Sparse array diff --git a/bin/varnishlog/varnishlog.c b/bin/varnishlog/varnishlog.c index 02c476d..d0589d6 100644 --- a/bin/varnishlog/varnishlog.c +++ b/bin/varnishlog/varnishlog.c @@ -112,7 +112,7 @@ flushout(void) int main(int argc, char * const *argv) { - char opt; + int opt; memset(&LOG, 0, sizeof LOG); VUT_Init(progname); @@ -130,6 +130,7 @@ main(int argc, char * const *argv) case 'h': /* Usage help */ usage(0); + break; case 'w': /* Write to file */ REPLACE(LOG.w_arg, optarg); diff --git a/bin/varnishtest/flint.lnt b/bin/varnishtest/flint.lnt index 8f22c47..79575ee 100644 --- a/bin/varnishtest/flint.lnt +++ b/bin/varnishtest/flint.lnt @@ -1,6 +1,5 @@ -esym(850, av) --esym(785, VSL_tags) -esym(528, iter_call) // Flexelint bug -e712 // 14 Info 712 Loss of precision (___) (___ to ___) diff --git a/bin/varnishtest/flint.sh b/bin/varnishtest/flint.sh index 3a67bd7..bb3f5c7 100755 --- a/bin/varnishtest/flint.sh +++ b/bin/varnishtest/flint.sh @@ -7,6 +7,7 @@ flexelint \ -I../../include \ -I../../lib/libvgz \ -I../.. \ + ../../flint.lnt \ ../flint.lnt \ flint.lnt \ *.c \ diff --git a/flint.lnt b/flint.lnt index 2dc8c91..2ccd107 100644 --- a/flint.lnt +++ b/flint.lnt @@ -3,3 +3,5 @@ */ -efile(451, "tbl/*.h") // No include guard +-esym(785,VSL_tags) // Sparse array + From phk at FreeBSD.org Fri Nov 29 11:24:43 2013 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 29 Nov 2013 12:24:43 +0100 Subject: [master] 194ea52 Eliminate '&' which are surplus to requirements Message-ID: commit 194ea520cda351f3bd9ede8879cd6296a7098ee0 Author: Poul-Henning Kamp Date: Fri Nov 29 11:24:21 2013 +0000 Eliminate '&' which are surplus to requirements diff --git a/bin/varnishlog/varnishlog.c b/bin/varnishlog/varnishlog.c index 17cbdbe..02c476d 100644 --- a/bin/varnishlog/varnishlog.c +++ b/bin/varnishlog/varnishlog.c @@ -145,16 +145,16 @@ main(int argc, char * const *argv) /* Setup output */ if (LOG.B_opt) - VUT.dispatch_f = &VSL_WriteTransactions; + VUT.dispatch_f = VSL_WriteTransactions; else - VUT.dispatch_f = &VSL_PrintTransactions; + VUT.dispatch_f = VSL_PrintTransactions; if (LOG.w_arg) { openout(LOG.a_opt); AN(LOG.fo); - VUT.sighup_f = &rotateout; + VUT.sighup_f = rotateout; } else LOG.fo = stdout; - VUT.idle_f = &flushout; + VUT.idle_f = flushout; VUT_Setup(); VUT_Main(); diff --git a/lib/libvarnishapi/vsl2rst.c b/lib/libvarnishapi/vsl2rst.c index bfbabb5..6992420 100644 --- a/lib/libvarnishapi/vsl2rst.c +++ b/lib/libvarnishapi/vsl2rst.c @@ -93,7 +93,7 @@ main(int argc, char *argv[]) for (i = 0; i < SLT__MAX; i++) ptags[i] = &tags[i]; - qsort(&ptags, SLT__MAX, sizeof *ptags, &ptag_cmp); + qsort(ptags, SLT__MAX, sizeof *ptags, ptag_cmp); for (i = 0; i < SLT__MAX; i++) { if (ptags[i]->name == NULL || !strcmp(ptags[i]->name, "")) diff --git a/lib/libvarnishapi/vsl_query.c b/lib/libvarnishapi/vsl_query.c index 4beface..495e00b 100644 --- a/lib/libvarnishapi/vsl_query.c +++ b/lib/libvarnishapi/vsl_query.c @@ -150,6 +150,8 @@ vslq_test_rec(const struct vex *vex, const struct VSLC_ptr *rec) WRONG("Wrong RHS type"); } break; + default: + break; } /* Compare */ From phk at FreeBSD.org Fri Nov 29 11:21:19 2013 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 29 Nov 2013 12:21:19 +0100 Subject: [master] 59902e0 Don't return void returning function call Message-ID: commit 59902e0ef39c77938bef2be1abe48fa8ab2fe1d3 Author: Poul-Henning Kamp Date: Fri Nov 29 11:21:07 2013 +0000 Don't return void returning function call diff --git a/lib/libvarnishapi/vsl_dispatch.c b/lib/libvarnishapi/vsl_dispatch.c index a9303f2..c5e7d4f 100644 --- a/lib/libvarnishapi/vsl_dispatch.c +++ b/lib/libvarnishapi/vsl_dispatch.c @@ -835,8 +835,8 @@ vtx_scan(struct VSLQ *vslq, struct vtx *vtx) case SLT_End: vtx->flags |= VTX_F_END; - return (vtx_mark_complete(vslq, vtx)); - + vtx_mark_complete(vslq, vtx); + break; default: break; } From phk at FreeBSD.org Fri Nov 29 11:15:37 2013 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 29 Nov 2013 12:15:37 +0100 Subject: [master] 82c7746 Constification Message-ID: commit 82c7746437cc6d0f2677e3b28f940e790e84ca0b Author: Poul-Henning Kamp Date: Fri Nov 29 11:08:28 2013 +0000 Constification diff --git a/include/vapi/vsl.h b/include/vapi/vsl.h index 6d1308b..ace0122 100644 --- a/include/vapi/vsl.h +++ b/include/vapi/vsl.h @@ -245,12 +245,12 @@ struct VSL_cursor *VSL_CursorFile(struct VSL_data *vsl, const char *name, * NULL: Error, see VSL_Error */ -void VSL_DeleteCursor(struct VSL_cursor *c); +void VSL_DeleteCursor(const struct VSL_cursor *c); /* * Delete the cursor pointed to by c */ -int VSL_ResetCursor(struct VSL_cursor *c); +int VSL_ResetCursor(const struct VSL_cursor *c); /* * Reset the cursor position to the head, so that the next call to * VSL_Next returns the first record. For VSM cursor, it will @@ -273,7 +273,7 @@ int VSL_Check(const struct VSL_cursor *c, const struct VSLC_ptr *ptr); * 2: Valid */ -int VSL_Next(struct VSL_cursor *c); +int VSL_Next(const struct VSL_cursor *c); /* * Return raw pointer to next VSL record. * @@ -333,7 +333,7 @@ int VSL_PrintTerse(const struct VSL_data *vsl, const struct VSL_cursor *c, * -5: I/O write error - see errno */ -int VSL_PrintAll(struct VSL_data *vsl, struct VSL_cursor *c, void *fo); +int VSL_PrintAll(struct VSL_data *vsl, const struct VSL_cursor *c, void *fo); /* * Calls VSL_Next on c until c is exhausted. In turn calls * VSL_Print on all records where VSL_Match returns true. @@ -393,7 +393,7 @@ int VSL_Write(const struct VSL_data *vsl, const struct VSL_cursor *c, void *fo); * -5: I/O error - see VSL_Error */ -int VSL_WriteAll(struct VSL_data *vsl, struct VSL_cursor *c, void *fo); +int VSL_WriteAll(struct VSL_data *vsl, const struct VSL_cursor *c, void *fo); /* * Calls VSL_Next on c until c is exhausted. In turn calls * VSL_Write on all records where VSL_Match returns true. diff --git a/lib/libvarnishapi/vsl.c b/lib/libvarnishapi/vsl.c index 8375a2c..dd17839 100644 --- a/lib/libvarnishapi/vsl.c +++ b/lib/libvarnishapi/vsl.c @@ -302,7 +302,7 @@ VSL_PrintTerse(const struct VSL_data *vsl, const struct VSL_cursor *c, void *fo) } int -VSL_PrintAll(struct VSL_data *vsl, struct VSL_cursor *c, void *fo) +VSL_PrintAll(struct VSL_data *vsl, const struct VSL_cursor *c, void *fo) { int i; @@ -436,7 +436,7 @@ VSL_Write(const struct VSL_data *vsl, const struct VSL_cursor *c, void *fo) } int -VSL_WriteAll(struct VSL_data *vsl, struct VSL_cursor *c, void *fo) +VSL_WriteAll(struct VSL_data *vsl, const struct VSL_cursor *c, void *fo) { int i; diff --git a/lib/libvarnishapi/vsl_api.h b/lib/libvarnishapi/vsl_api.h index c7996a9..b3199bb 100644 --- a/lib/libvarnishapi/vsl_api.h +++ b/lib/libvarnishapi/vsl_api.h @@ -42,9 +42,9 @@ int vsl_diag(struct VSL_data *vsl, const char *fmt, ...) void vsl_vbm_bitset(int bit, void *priv); void vsl_vbm_bitclr(int bit, void *priv); -typedef void vslc_delete_f(struct VSL_cursor *); -typedef int vslc_next_f(struct VSL_cursor *); -typedef int vslc_reset_f(struct VSL_cursor *); +typedef void vslc_delete_f(const struct VSL_cursor *); +typedef int vslc_next_f(const struct VSL_cursor *); +typedef int vslc_reset_f(const struct VSL_cursor *); typedef int vslc_check_f(const struct VSL_cursor *, const struct VSLC_ptr *); struct vslc_tbl { diff --git a/lib/libvarnishapi/vsl_cursor.c b/lib/libvarnishapi/vsl_cursor.c index de545c7..ea9633c 100644 --- a/lib/libvarnishapi/vsl_cursor.c +++ b/lib/libvarnishapi/vsl_cursor.c @@ -64,7 +64,7 @@ struct vslc_vsm { }; static void -vslc_vsm_delete(struct VSL_cursor *cursor) +vslc_vsm_delete(const struct VSL_cursor *cursor) { struct vslc_vsm *c; @@ -114,7 +114,7 @@ vslc_vsm_check(const struct VSL_cursor *cursor, const struct VSLC_ptr *ptr) } static int -vslc_vsm_next(struct VSL_cursor *cursor) +vslc_vsm_next(const struct VSL_cursor *cursor) { struct vslc_vsm *c; int i; @@ -189,7 +189,7 @@ vslc_vsm_next(struct VSL_cursor *cursor) } static int -vslc_vsm_reset(struct VSL_cursor *cursor) +vslc_vsm_reset(const struct VSL_cursor *cursor) { struct vslc_vsm *c; unsigned segment; @@ -290,7 +290,7 @@ struct vslc_file { }; static void -vslc_file_delete(struct VSL_cursor *cursor) +vslc_file_delete(const struct VSL_cursor *cursor) { struct vslc_file *c; @@ -320,7 +320,7 @@ vslc_file_readn(int fd, void *buf, size_t n) } static int -vslc_file_next(struct VSL_cursor *cursor) +vslc_file_next(const struct VSL_cursor *cursor) { struct vslc_file *c; ssize_t i; @@ -363,7 +363,7 @@ vslc_file_next(struct VSL_cursor *cursor) } static int -vslc_file_reset(struct VSL_cursor *cursor) +vslc_file_reset(const struct VSL_cursor *cursor) { (void)cursor; /* XXX: Implement me */ @@ -439,7 +439,7 @@ VSL_CursorFile(struct VSL_data *vsl, const char *name, unsigned options) } void -VSL_DeleteCursor(struct VSL_cursor *cursor) +VSL_DeleteCursor(const struct VSL_cursor *cursor) { const struct vslc_tbl *tbl; @@ -450,7 +450,7 @@ VSL_DeleteCursor(struct VSL_cursor *cursor) } int -VSL_ResetCursor(struct VSL_cursor *cursor) +VSL_ResetCursor(const struct VSL_cursor *cursor) { const struct vslc_tbl *tbl; @@ -461,7 +461,7 @@ VSL_ResetCursor(struct VSL_cursor *cursor) } int -VSL_Next(struct VSL_cursor *cursor) +VSL_Next(const struct VSL_cursor *cursor) { const struct vslc_tbl *tbl; diff --git a/lib/libvarnishapi/vsl_dispatch.c b/lib/libvarnishapi/vsl_dispatch.c index ed1d0f4..a9303f2 100644 --- a/lib/libvarnishapi/vsl_dispatch.c +++ b/lib/libvarnishapi/vsl_dispatch.c @@ -209,7 +209,7 @@ VRB_PROTOTYPE_STATIC(vtx_tree, vtx_key, entry, vtx_keycmp) VRB_GENERATE_STATIC(vtx_tree, vtx_key, entry, vtx_keycmp) static int -vslc_raw_next(struct VSL_cursor *cursor) +vslc_raw_next(const struct VSL_cursor *cursor) { struct vslc_raw *c; @@ -227,7 +227,7 @@ vslc_raw_next(struct VSL_cursor *cursor) } static int -vslc_raw_reset(struct VSL_cursor *cursor) +vslc_raw_reset(const struct VSL_cursor *cursor) { struct vslc_raw *c; @@ -249,7 +249,7 @@ static const struct vslc_tbl vslc_raw_tbl = { }; static int -vslc_vtx_next(struct VSL_cursor *cursor) +vslc_vtx_next(const struct VSL_cursor *cursor) { struct vslc_vtx *c; const uint32_t *ptr; @@ -300,7 +300,7 @@ vslc_vtx_next(struct VSL_cursor *cursor) } static int -vslc_vtx_reset(struct VSL_cursor *cursor) +vslc_vtx_reset(const struct VSL_cursor *cursor) { struct vslc_vtx *c; @@ -573,7 +573,7 @@ vtx_retire(struct VSLQ *vslq, struct vtx **pvtx) /* Lookup a vtx by vxid from the managed list */ static struct vtx * -vtx_lookup(struct VSLQ *vslq, unsigned vxid) +vtx_lookup(const struct VSLQ *vslq, unsigned vxid) { struct vtx_key lkey, *key; struct vtx *vtx; diff --git a/lib/libvarnishapi/vsl_glob_test.c b/lib/libvarnishapi/vsl_glob_test.c index 6bf0ddd..6aac16a 100644 --- a/lib/libvarnishapi/vsl_glob_test.c +++ b/lib/libvarnishapi/vsl_glob_test.c @@ -44,7 +44,7 @@ cb(int tag, void *priv) } int -main(int argc, char *argv[]) +main(int argc, char * const *argv) { int i; diff --git a/lib/libvarnishapi/vxp.c b/lib/libvarnishapi/vxp.c index 75a7614..b1c8c2f 100644 --- a/lib/libvarnishapi/vxp.c +++ b/lib/libvarnishapi/vxp.c @@ -53,7 +53,8 @@ vxp_ErrToken(const struct vxp *vxp, const struct token *t) } static void -vxp_Pos(struct vxp *vxp, struct vsb *vsb, const struct token *t, int tokoff) +vxp_Pos(const struct vxp *vxp, struct vsb *vsb, const struct token *t, + int tokoff) { unsigned pos; @@ -68,7 +69,7 @@ vxp_Pos(struct vxp *vxp, struct vsb *vsb, const struct token *t, int tokoff) } static void -vxp_quote(struct vxp *vxp, const char *b, const char *e, int tokoff) +vxp_quote(const struct vxp *vxp, const char *b, const char *e, int tokoff) { const char *p; char c; diff --git a/lib/libvarnishapi/vxp_parse.c b/lib/libvarnishapi/vxp_parse.c index 01f5272..6fc726b 100644 --- a/lib/libvarnishapi/vxp_parse.c +++ b/lib/libvarnishapi/vxp_parse.c @@ -50,7 +50,7 @@ static void vxp_expr_or(struct vxp *vxp, struct vex **pvex); static struct vex * -vex_alloc(struct vxp *vxp) +vex_alloc(const struct vxp *vxp) { struct vex *vex; diff --git a/lib/libvarnishapi/vxp_test.c b/lib/libvarnishapi/vxp_test.c index 1104039..89437f1 100644 --- a/lib/libvarnishapi/vxp_test.c +++ b/lib/libvarnishapi/vxp_test.c @@ -17,7 +17,7 @@ usage(void) } int -main(int argc, char **argv) +main(int argc, char * const *argv) { struct vsb *vsb; struct vex *vex; From phk at FreeBSD.org Fri Nov 29 10:43:39 2013 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 29 Nov 2013 11:43:39 +0100 Subject: [master] 24f1c4e Improve ESI error messages Message-ID: commit 24f1c4e6e721b985688a193c869240b45cb43830 Author: Poul-Henning Kamp Date: Fri Nov 29 10:36:56 2013 +0000 Improve ESI error messages Suggested by: scoof diff --git a/bin/varnishd/cache/cache_esi_parse.c b/bin/varnishd/cache/cache_esi_parse.c index 48482c9..1c900f6 100644 --- a/bin/varnishd/cache/cache_esi_parse.c +++ b/bin/varnishd/cache/cache_esi_parse.c @@ -626,13 +626,17 @@ VEP_Parse(const struct busyobj *bo, const char *p, size_t l) vep->state = VEP_STARTTAG; } else if (p < e && *p == '\xeb') { VSLb(vep->bo->vsl, SLT_ESI_xmlerror, - "No ESI processing, first char not '<'" - " (BOM? see feature esi_remove_bom)" + "No ESI processing, " + "first char not '<' but BOM." + " (See feature esi_remove_bom)" ); vep->state = VEP_NOTXML; } else if (p < e) { VSLb(vep->bo->vsl, SLT_ESI_xmlerror, - "No ESI processing, first char not '<'"); + "No ESI processing, " + "first char not '<'." + " (See feature esi_disable_xml_check)" + ); vep->state = VEP_NOTXML; } } else if (vep->state == VEP_NOTXML) { From phk at FreeBSD.org Fri Nov 29 09:28:34 2013 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 29 Nov 2013 10:28:34 +0100 Subject: [master] 38e761d Expect status 400 Message-ID: commit 38e761de794218d4326acea72ee463c3752e48cf Author: Poul-Henning Kamp Date: Fri Nov 29 09:19:47 2013 +0000 Expect status 400 diff --git a/bin/varnishtest/tests/r00416.vtc b/bin/varnishtest/tests/r00416.vtc index 3ad2a86..7ecf011 100644 --- a/bin/varnishtest/tests/r00416.vtc +++ b/bin/varnishtest/tests/r00416.vtc @@ -155,6 +155,7 @@ client c1 { -hdr hdr68=68 \ -hdr hdr69=69 rxresp + expect resp.status == 400 } -run client c1 { From phk at FreeBSD.org Fri Nov 29 09:46:08 2013 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 29 Nov 2013 10:46:08 +0100 Subject: [master] d6fc838 Assert that we got storage Message-ID: commit d6fc838c4903b502e5b8d9e41564dddf7a0f8bfd Author: Poul-Henning Kamp Date: Fri Nov 29 09:39:16 2013 +0000 Assert that we got storage diff --git a/lib/libvarnishapi/vsl_dispatch.c b/lib/libvarnishapi/vsl_dispatch.c index 43a8243..ed1d0f4 100644 --- a/lib/libvarnishapi/vsl_dispatch.c +++ b/lib/libvarnishapi/vsl_dispatch.c @@ -331,6 +331,7 @@ chunk_newbuf(struct vtx *vtx, const uint32_t *ptr, size_t len) struct chunk *chunk; ALLOC_OBJ(chunk, CHUNK_MAGIC); + XXXAN(chunk); chunk->type = chunk_t_buf; chunk->vtx = vtx; chunk->buf.space = VTX_BUFSIZE_MIN; From phk at FreeBSD.org Fri Nov 29 09:46:09 2013 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 29 Nov 2013 10:46:09 +0100 Subject: [master] 7be39f2 Assert allocation success Message-ID: commit 7be39f2d16cabb96c58610529c6c9e606ae4cb4c Author: Poul-Henning Kamp Date: Fri Nov 29 09:43:35 2013 +0000 Assert allocation success diff --git a/lib/libvarnishapi/vsl_query.c b/lib/libvarnishapi/vsl_query.c index 5cddbde..4beface 100644 --- a/lib/libvarnishapi/vsl_query.c +++ b/lib/libvarnishapi/vsl_query.c @@ -312,6 +312,7 @@ vslq_newquery(struct VSL_data *vsl, enum VSL_grouping_e grouping, vsl_diag(vsl, "%s", VSB_data(vsb)); else { ALLOC_OBJ(query, VSLQ_QUERY_MAGIC); + XXXAN(query); query->vex = vex; } VSB_delete(vsb); From phk at FreeBSD.org Fri Nov 29 09:46:09 2013 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 29 Nov 2013 10:46:09 +0100 Subject: [master] 1d7dd2a remove unused #includes Message-ID: commit 1d7dd2ab79c3fdebd05a31b44ed5f005215e2278 Author: Poul-Henning Kamp Date: Fri Nov 29 09:45:01 2013 +0000 remove unused #includes diff --git a/bin/varnishlog/varnishlog.c b/bin/varnishlog/varnishlog.c index b17cf6e..17cbdbe 100644 --- a/bin/varnishlog/varnishlog.c +++ b/bin/varnishlog/varnishlog.c @@ -44,10 +44,8 @@ #include "vapi/vsl.h" #include "vapi/voptget.h" #include "vas.h" -#include "vcs.h" #include "vpf.h" #include "vsb.h" -#include "vtim.h" #include "vut.h" #include "miniobj.h" diff --git a/lib/libvarnishapi/vsl2rst.c b/lib/libvarnishapi/vsl2rst.c index eacc79b..bfbabb5 100644 --- a/lib/libvarnishapi/vsl2rst.c +++ b/lib/libvarnishapi/vsl2rst.c @@ -33,7 +33,6 @@ #include #include #include -#include #include "vapi/vsl.h" From phk at FreeBSD.org Fri Nov 29 09:46:09 2013 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 29 Nov 2013 10:46:09 +0100 Subject: [master] eec5e98 Replace strndup(), OS/X doesn't have it. Message-ID: commit eec5e98e73fcbd3816e27dc0ac568a57e6106e3d Author: Poul-Henning Kamp Date: Fri Nov 29 09:45:22 2013 +0000 Replace strndup(), OS/X doesn't have it. diff --git a/lib/libvarnishapi/vsc.c b/lib/libvarnishapi/vsc.c index 1ea0348..5cce3e9 100644 --- a/lib/libvarnishapi/vsc.c +++ b/lib/libvarnishapi/vsc.c @@ -201,8 +201,10 @@ vsc_f_arg(struct VSM_data *vd, const char *opt) if (*q == '\\') q++; if (i < 3) { - parts[i] = strndup(p, q - p); + parts[i] = malloc(1 + q - p); AN(parts[i]); + memcpy(parts[i], p, q - p); + parts[i][q - p] = '\0'; p = r = parts[i]; /* Unescape */ From phk at FreeBSD.org Fri Nov 29 09:46:09 2013 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 29 Nov 2013 10:46:09 +0100 Subject: [master] 377a38c Remove unused #includes Message-ID: commit 377a38c47a47b784bc44ff869d640d5b37386566 Author: Poul-Henning Kamp Date: Fri Nov 29 09:45:52 2013 +0000 Remove unused #includes diff --git a/lib/libvarnishapi/vsl_cursor.c b/lib/libvarnishapi/vsl_cursor.c index d37a454..de545c7 100644 --- a/lib/libvarnishapi/vsl_cursor.c +++ b/lib/libvarnishapi/vsl_cursor.c @@ -41,7 +41,6 @@ #include "vas.h" #include "miniobj.h" -#include "vdef.h" #include "vapi/vsm.h" #include "vsm_api.h" #include "vapi/vsl.h" diff --git a/lib/libvarnishapi/vsl_glob_test.c b/lib/libvarnishapi/vsl_glob_test.c index 87bb6fa..6bf0ddd 100644 --- a/lib/libvarnishapi/vsl_glob_test.c +++ b/lib/libvarnishapi/vsl_glob_test.c @@ -31,10 +31,8 @@ #include #include #include -#include #include -#include "vas.h" #include "vapi/vsl.h" static void From phk at FreeBSD.org Fri Nov 29 10:01:12 2013 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 29 Nov 2013 11:01:12 +0100 Subject: [master] caa4fe1 Start a global flint.lnt file Message-ID: commit caa4fe17ecce9f2fce7952aebd5710984a1d2bf2 Author: Poul-Henning Kamp Date: Fri Nov 29 09:52:07 2013 +0000 Start a global flint.lnt file diff --git a/bin/varnishd/flint.lnt b/bin/varnishd/flint.lnt index bfa3ccb..0c8c7d6 100644 --- a/bin/varnishd/flint.lnt +++ b/bin/varnishd/flint.lnt @@ -89,7 +89,6 @@ ////////////// -efunc(1791, pdiff) // return last on line ////////////// --efile(451, "tbl/*.h") // No include guard -efile(451, "vcc_types.h") // No include guard -efile(451, "symbol_kind.h") // No include guard -efile(451, "config.h") // No include guard diff --git a/bin/varnishd/flint.sh b/bin/varnishd/flint.sh index b616a29..63b406d 100755 --- a/bin/varnishd/flint.sh +++ b/bin/varnishd/flint.sh @@ -7,6 +7,7 @@ if [ "x$1" = "x-ok" -a -f _.fl ] ; then fi flexelint \ + ../../flint.lnt \ ../flint.lnt \ flint.lnt \ -I. \ diff --git a/bin/varnishlog/flint.lnt b/bin/varnishlog/flint.lnt index 7669aca..c0d43d8 100644 --- a/bin/varnishlog/flint.lnt +++ b/bin/varnishlog/flint.lnt @@ -1,4 +1,3 @@ --efile(451, "../../include/vsc_all.h") -e835 // A zero has been given as ___ argument to operator '___' (<<) -e712 // 14 Info 712 Loss of precision (___) (___ to ___) -e747 // 16 Info 747 Significant prototype coercion (___) ___ to ___ diff --git a/bin/varnishlog/flint.sh b/bin/varnishlog/flint.sh index dc9e9ba..26e0fa3 100755 --- a/bin/varnishlog/flint.sh +++ b/bin/varnishlog/flint.sh @@ -7,6 +7,7 @@ if [ "x$1" = "x-ok" -a -f _.fl ] ; then fi flexelint \ + ../../flint.lnt \ ../flint.lnt \ flint.lnt \ -I. \ diff --git a/flint.lnt b/flint.lnt new file mode 100644 index 0000000..2dc8c91 --- /dev/null +++ b/flint.lnt @@ -0,0 +1,5 @@ +/* + * Toplevel control file for FlexeLint + */ + +-efile(451, "tbl/*.h") // No include guard From phk at FreeBSD.org Fri Nov 29 10:43:39 2013 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 29 Nov 2013 11:43:39 +0100 Subject: [master] 6a21288 remove unused struct member. Message-ID: commit 6a21288d2f9669bdaf0afa1aeaefde836b89988e Author: Poul-Henning Kamp Date: Fri Nov 29 10:36:08 2013 +0000 remove unused struct member. diff --git a/bin/varnishd/common/params.h b/bin/varnishd/common/params.h index 7a69119..b4129eb 100644 --- a/bin/varnishd/common/params.h +++ b/bin/varnishd/common/params.h @@ -149,9 +149,6 @@ struct params { /* Maximum esi:include depth allowed */ unsigned max_esi_depth; - /* ESI parser hints */ - unsigned esi_syntax; - /* Rush exponent */ unsigned rush_exponent; From phk at FreeBSD.org Fri Nov 29 10:43:39 2013 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 29 Nov 2013 11:43:39 +0100 Subject: [master] 0dd4b7a Put macro-arg in (...) Message-ID: commit 0dd4b7ac4cbdea5d02c756c4f9bf79e6c442ae9f Author: Poul-Henning Kamp Date: Fri Nov 29 10:36:40 2013 +0000 Put macro-arg in (...) diff --git a/include/tbl/vsl_tags.h b/include/tbl/vsl_tags.h index f4e5b2f..5695784 100644 --- a/include/tbl/vsl_tags.h +++ b/include/tbl/vsl_tags.h @@ -189,30 +189,30 @@ SLTM(FetchError, 0, "Error while fetching object", ) #define SLTH(tag, ind, req, resp, sdesc, ldesc) \ - SLTM(Req##tag, req ? 0 : SLT_F_UNUSED, "Client request " sdesc, ldesc) + SLTM(Req##tag, (req ? 0 : SLT_F_UNUSED), "Client request " sdesc, ldesc) #include "tbl/vsl_tags_http.h" #undef SLTH #define SLTH(tag, ind, req, resp, sdesc, ldesc) \ - SLTM(Resp##tag, resp ? 0 : SLT_F_UNUSED, "Client response " sdesc, \ + SLTM(Resp##tag, (resp ? 0 : SLT_F_UNUSED), "Client response " sdesc, \ ldesc) #include "tbl/vsl_tags_http.h" #undef SLTH #define SLTH(tag, ind, req, resp, sdesc, ldesc) \ - SLTM(Bereq##tag, req ? 0 : SLT_F_UNUSED, "Backend request " sdesc, \ + SLTM(Bereq##tag, (req ? 0 : SLT_F_UNUSED), "Backend request " sdesc, \ ldesc) #include "tbl/vsl_tags_http.h" #undef SLTH #define SLTH(tag, ind, req, resp, sdesc, ldesc) \ - SLTM(Beresp##tag, resp ? 0 : SLT_F_UNUSED, "Backend response " sdesc, \ + SLTM(Beresp##tag, (resp ? 0 : SLT_F_UNUSED), "Backend response " sdesc, \ ldesc) #include "tbl/vsl_tags_http.h" #undef SLTH #define SLTH(tag, ind, req, resp, sdesc, ldesc) \ - SLTM(Obj##tag, resp ? 0 : SLT_F_UNUSED, "Object " sdesc, ldesc) + SLTM(Obj##tag, (resp ? 0 : SLT_F_UNUSED), "Object " sdesc, ldesc) #include "tbl/vsl_tags_http.h" #undef SLTH