From phk at FreeBSD.org Wed Jul 2 21:04:22 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 02 Jul 2014 23:04:22 +0200 Subject: [master] a9d4a49 Wrap a structure around fetch filters, and move the filter API to a separate #include file. Message-ID: commit a9d4a4978a2bf7fe42b75d13d63b7a2da9faf0ac Author: Poul-Henning Kamp Date: Wed Jul 2 21:03:50 2014 +0000 Wrap a structure around fetch filters, and move the filter API to a separate #include file. diff --git a/bin/varnishd/Makefile.am b/bin/varnishd/Makefile.am index 402cd0d..bcfe989 100644 --- a/bin/varnishd/Makefile.am +++ b/bin/varnishd/Makefile.am @@ -103,6 +103,7 @@ noinst_HEADERS = \ pkgdataincludedir = $(pkgdatadir)/include nobase_pkgdatainclude_HEADERS = \ cache/cache.h \ + cache/cache_filter.h \ cache/cache_backend.h \ common/common.h \ common/params.h diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 038510d..b9e13fa 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -36,6 +36,7 @@ #include "common/common.h" +#include "cache/cache_filter.h" #include "vapi/vsl_int.h" #include @@ -253,32 +254,6 @@ struct dstat { #undef L0 #undef L1 -/* Fetch processors --------------------------------------------------*/ - -enum vfp_status { - VFP_ERROR = -1, - VFP_OK = 0, - VFP_END = 1, -}; -typedef enum vfp_status - vfp_pull_f(struct busyobj *bo, void *p, ssize_t *len, intptr_t *priv); - -extern vfp_pull_f vfp_gunzip_pull; -extern vfp_pull_f vfp_gzip_pull; -extern vfp_pull_f vfp_testgunzip_pull; -extern vfp_pull_f vfp_esi_pull; -extern vfp_pull_f vfp_esi_gzip_pull; - -/* Deliver processors ------------------------------------------------*/ - -enum vdp_action { - VDP_NULL, - VDP_FLUSH, - VDP_FINISH, -}; -typedef int vdp_bytes(struct req *, enum vdp_action, const void *ptr, - ssize_t len); - /*--------------------------------------------------------------------*/ struct exp { @@ -487,7 +462,7 @@ struct busyobj { uint8_t *vary; #define N_VFPS 5 - vfp_pull_f *vfps[N_VFPS]; + const struct vfp *vfps[N_VFPS]; intptr_t vfps_priv[N_VFPS]; int vfp_nxt; @@ -901,7 +876,7 @@ enum vfp_status VFP_Error(struct busyobj *, const char *fmt, ...) __printflike(2, 3); void VFP_Init(void); void VFP_Fetch_Body(struct busyobj *bo, ssize_t est); -void VFP_Push(struct busyobj *, vfp_pull_f *func, intptr_t priv); +void VFP_Push(struct busyobj *, const struct vfp *, intptr_t priv); enum vfp_status VFP_Suck(struct busyobj *, void *p, ssize_t *lp); extern char vfp_init[]; extern char vfp_fini[]; diff --git a/bin/varnishd/cache/cache_esi_fetch.c b/bin/varnishd/cache/cache_esi_fetch.c index 41bea3b..9424399 100644 --- a/bin/varnishd/cache/cache_esi_fetch.c +++ b/bin/varnishd/cache/cache_esi_fetch.c @@ -141,7 +141,7 @@ vfp_esi_end(struct busyobj *bo, struct vef_priv *vef, enum vfp_status retval) return (retval); } -enum vfp_status __match_proto__(vfp_pull_f) +static enum vfp_status __match_proto__(vfp_pull_f) vfp_esi_gzip_pull(struct busyobj *bo, void *p, ssize_t *lp, intptr_t *priv) { enum vfp_status vp; @@ -202,7 +202,7 @@ vfp_esi_gzip_pull(struct busyobj *bo, void *p, ssize_t *lp, intptr_t *priv) return (vp); } -enum vfp_status __match_proto__(vfp_pull_f) +static enum vfp_status __match_proto__(vfp_pull_f) vfp_esi_pull(struct busyobj *bo, void *p, ssize_t *lp, intptr_t *priv) { enum vfp_status vp; @@ -241,3 +241,11 @@ vfp_esi_pull(struct busyobj *bo, void *p, ssize_t *lp, intptr_t *priv) } return (vp); } + +const struct vfp vfp_esi = { + .pull = vfp_esi_pull, +}; + +const struct vfp vfp_esi_gzip = { + .pull = vfp_esi_gzip_pull, +}; diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 0980c64..b2665e2 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -468,22 +468,22 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) if (bo->do_gunzip || (bo->is_gzip && bo->do_esi)) { RFC2616_Weaken_Etag(bo->beresp); - VFP_Push(bo, vfp_gunzip_pull, 0); + VFP_Push(bo, &vfp_gunzip, 0); } if (bo->do_esi && bo->do_gzip) { - VFP_Push(bo, vfp_esi_gzip_pull, 0); + VFP_Push(bo, &vfp_esi_gzip, 0); RFC2616_Weaken_Etag(bo->beresp); } else if (bo->do_esi && bo->is_gzip && !bo->do_gunzip) { - VFP_Push(bo, vfp_esi_gzip_pull, 0); + VFP_Push(bo, &vfp_esi_gzip, 0); RFC2616_Weaken_Etag(bo->beresp); } else if (bo->do_esi) { - VFP_Push(bo, vfp_esi_pull, 0); + VFP_Push(bo, &vfp_esi, 0); } else if (bo->do_gzip) { - VFP_Push(bo, vfp_gzip_pull, 0); + VFP_Push(bo, &vfp_gzip, 0); RFC2616_Weaken_Etag(bo->beresp); } else if (bo->is_gzip && !bo->do_gunzip) { - VFP_Push(bo, vfp_testgunzip_pull, 0); + VFP_Push(bo, &vfp_testgunzip, 0); } if (bo->fetch_objcore->flags & OC_F_PRIVATE) diff --git a/bin/varnishd/cache/cache_fetch_proc.c b/bin/varnishd/cache/cache_fetch_proc.c index 0666c45..7e1b30b 100644 --- a/bin/varnishd/cache/cache_fetch_proc.c +++ b/bin/varnishd/cache/cache_fetch_proc.c @@ -114,8 +114,8 @@ VFP_GetStorage(struct busyobj *bo, ssize_t sz) static enum vfp_status vfp_call(struct busyobj *bo, int nbr, void *p, ssize_t *lp) { - AN(bo->vfps[nbr]); - return (bo->vfps[nbr](bo, p, lp, &bo->vfps_priv[nbr])); + AN(bo->vfps[nbr]->pull); + return (bo->vfps[nbr]->pull(bo, p, lp, &bo->vfps_priv[nbr])); } static void @@ -250,12 +250,12 @@ VFP_Fetch_Body(struct busyobj *bo, ssize_t est) } void -VFP_Push(struct busyobj *bo, vfp_pull_f *func, intptr_t priv) +VFP_Push(struct busyobj *bo, const struct vfp *vfp, intptr_t priv) { CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); bo->vfps_priv[bo->vfp_nxt] = priv; - bo->vfps[bo->vfp_nxt] = func; + bo->vfps[bo->vfp_nxt] = vfp; bo->vfp_nxt++; } diff --git a/bin/varnishd/cache/cache_filter.h b/bin/varnishd/cache/cache_filter.h new file mode 100644 index 0000000..d2b0cf1 --- /dev/null +++ b/bin/varnishd/cache/cache_filter.h @@ -0,0 +1,62 @@ +/*- + * Copyright (c) 2013-2014 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. + * + */ + +struct busyobj; +struct req; + +/* Fetch processors --------------------------------------------------*/ + +enum vfp_status { + VFP_ERROR = -1, + VFP_OK = 0, + VFP_END = 1, +}; +typedef enum vfp_status + vfp_pull_f(struct busyobj *bo, void *p, ssize_t *len, intptr_t *priv); + +struct vfp { + vfp_pull_f *pull; +}; + +extern const struct vfp vfp_gunzip; +extern const struct vfp vfp_gzip; +extern const struct vfp vfp_testgunzip; +extern const struct vfp vfp_esi; +extern const struct vfp vfp_esi_gzip; + + +/* Deliver processors ------------------------------------------------*/ + +enum vdp_action { + VDP_NULL, + VDP_FLUSH, + VDP_FINISH, +}; +typedef int vdp_bytes(struct req *, enum vdp_action, const void *ptr, + ssize_t len); diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c index bdbf229..2e3528b 100644 --- a/bin/varnishd/cache/cache_gzip.c +++ b/bin/varnishd/cache/cache_gzip.c @@ -450,7 +450,7 @@ VGZ_Destroy(struct vgz **vgp) * A VFP for gunzip'ing an object as we receive it from the backend */ -enum vfp_status __match_proto__(vfp_pull_f) +static enum vfp_status __match_proto__(vfp_pull_f) vfp_gunzip_pull(struct busyobj *bo, void *p, ssize_t *lp, intptr_t *priv) { ssize_t l; @@ -513,13 +513,18 @@ vfp_gunzip_pull(struct busyobj *bo, void *p, ssize_t *lp, intptr_t *priv) return (vp); } +const struct vfp vfp_gunzip = { + .pull = vfp_gunzip_pull, +}; + + /*-------------------------------------------------------------------- * VFP_GZIP * * A VFP for gzip'ing an object as we receive it from the backend */ -enum vfp_status __match_proto__(vfp_pull_f) +static enum vfp_status __match_proto__(vfp_pull_f) vfp_gzip_pull(struct busyobj *bo, void *p, ssize_t *lp, intptr_t *priv) { ssize_t l; @@ -583,6 +588,10 @@ vfp_gzip_pull(struct busyobj *bo, void *p, ssize_t *lp, intptr_t *priv) return (VFP_END); } +const struct vfp vfp_gzip = { + .pull = vfp_gzip_pull, +}; + /*-------------------------------------------------------------------- * VFP_TESTGZIP * @@ -590,7 +599,7 @@ vfp_gzip_pull(struct busyobj *bo, void *p, ssize_t *lp, intptr_t *priv) * collecting the magic bits while we're at it. */ -enum vfp_status __match_proto__(vfp_pull_f) +static enum vfp_status __match_proto__(vfp_pull_f) vfp_testgunzip_pull(struct busyobj *bo, void *p, ssize_t *lp, intptr_t *priv) { struct vgz *vg; @@ -641,3 +650,7 @@ vfp_testgunzip_pull(struct busyobj *bo, void *p, ssize_t *lp, intptr_t *priv) } return (vp); } + +const struct vfp vfp_testgunzip = { + .pull = vfp_testgunzip_pull, +}; diff --git a/bin/varnishd/cache/cache_http1_fetch.c b/bin/varnishd/cache/cache_http1_fetch.c index b6d72dd..65c2591 100644 --- a/bin/varnishd/cache/cache_http1_fetch.c +++ b/bin/varnishd/cache/cache_http1_fetch.c @@ -100,6 +100,10 @@ v1f_pull_straight(struct busyobj *bo, void *p, ssize_t *lp, intptr_t *priv) return (VFP_OK); } +static const struct vfp v1f_straight = { + .pull = v1f_pull_straight, +}; + /*-------------------------------------------------------------------- * Read a chunked HTTP object. * @@ -133,6 +137,10 @@ v1f_pull_chunked(struct busyobj *bo, void *p, ssize_t *lp, intptr_t *priv) } } +static const struct vfp v1f_chunked = { + .pull = v1f_pull_chunked, +}; + /*--------------------------------------------------------------------*/ static enum vfp_status __match_proto__(vfp_pull_f) @@ -160,6 +168,11 @@ v1f_pull_eof(struct busyobj *bo, void *p, ssize_t *lp, intptr_t *priv) return (VFP_OK); } +static const struct vfp v1f_eof = { + .pull = v1f_pull_eof, +}; + + /*-------------------------------------------------------------------- */ @@ -176,14 +189,14 @@ V1F_Setup_Fetch(struct busyobj *bo) switch(htc->body_status) { case BS_EOF: - VFP_Push(bo, v1f_pull_eof, 0); + VFP_Push(bo, &v1f_eof, 0); return(-1); case BS_LENGTH: cl = vbf_fetch_number(bo->h_content_length, 10); - VFP_Push(bo, v1f_pull_straight, cl); + VFP_Push(bo, &v1f_straight, cl); return (cl); case BS_CHUNKED: - VFP_Push(bo, v1f_pull_chunked, -1); + VFP_Push(bo, &v1f_chunked, -1); return (-1); default: break; From phk at FreeBSD.org Thu Jul 3 20:13:24 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 03 Jul 2014 22:13:24 +0200 Subject: [master] f77700f Allocate a small instance structure for each VFP pushed from the bo's workspace and eliminate the hardcoded limit of 5 VFPs. Message-ID: commit f77700f067a2b43c2a000c80b704caf2e15ebb98 Author: Poul-Henning Kamp Date: Thu Jul 3 20:12:29 2014 +0000 Allocate a small instance structure for each VFP pushed from the bo's workspace and eliminate the hardcoded limit of 5 VFPs. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index b9e13fa..d0137fe 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -444,6 +444,15 @@ enum busyobj_state_e { BOS_FAILED, /* something went wrong */ }; +struct vfp_entry { + unsigned magic; +#define VFP_ENTRY_MAGIC 0xbe32a027 + const struct vfp *vfp; + // void *priv1; + intptr_t priv2; + VTAILQ_ENTRY(vfp_entry) list; +}; + struct busyobj { unsigned magic; #define BUSYOBJ_MAGIC 0x23b95567 @@ -461,10 +470,8 @@ struct busyobj { uint8_t *vary; -#define N_VFPS 5 - const struct vfp *vfps[N_VFPS]; - intptr_t vfps_priv[N_VFPS]; - int vfp_nxt; + VTAILQ_HEAD(,vfp_entry) vfp; + struct vfp_entry *vfp_nxt; int failed; enum busyobj_state_e state; diff --git a/bin/varnishd/cache/cache_busyobj.c b/bin/varnishd/cache/cache_busyobj.c index 45e2845..0483579 100644 --- a/bin/varnishd/cache/cache_busyobj.c +++ b/bin/varnishd/cache/cache_busyobj.c @@ -147,6 +147,7 @@ VBO_GetBusyObj(struct worker *wrk, const struct req *req) bo->director = req->director_hint; bo->vcl = req->vcl; VCL_Ref(bo->vcl); + VTAILQ_INIT(&bo->vfp); bo->t_first = bo->t_prev = NAN; diff --git a/bin/varnishd/cache/cache_fetch_proc.c b/bin/varnishd/cache/cache_fetch_proc.c index 7e1b30b..20e5d09 100644 --- a/bin/varnishd/cache/cache_fetch_proc.c +++ b/bin/varnishd/cache/cache_fetch_proc.c @@ -112,20 +112,20 @@ VFP_GetStorage(struct busyobj *bo, ssize_t sz) */ static enum vfp_status -vfp_call(struct busyobj *bo, int nbr, void *p, ssize_t *lp) +vfp_call(struct busyobj *bo, struct vfp_entry *vfe, void *p, ssize_t *lp) { - AN(bo->vfps[nbr]->pull); - return (bo->vfps[nbr]->pull(bo, p, lp, &bo->vfps_priv[nbr])); + AN(vfe->vfp->pull); + return (vfe->vfp->pull(bo, p, lp, &vfe->priv2)); } static void vfp_suck_fini(struct busyobj *bo) { - int i; + struct vfp_entry *vfe; - for (i = 0; i < bo->vfp_nxt; i++) { - if(bo->vfps[i] != NULL) - (void)vfp_call(bo, i, vfp_fini, NULL); + VTAILQ_FOREACH(vfe, &bo->vfp, list) { + if(vfe->vfp != NULL) + (void)vfp_call(bo, vfe, vfp_fini, NULL); } } @@ -133,10 +133,10 @@ static enum vfp_status vfp_suck_init(struct busyobj *bo) { enum vfp_status retval = VFP_ERROR; - int i; + struct vfp_entry *vfe; - for (i = 0; i < bo->vfp_nxt; i++) { - retval = vfp_call(bo, i, vfp_init, NULL); + VTAILQ_FOREACH(vfe, &bo->vfp, list) { + retval = vfp_call(bo, vfe, vfp_init, NULL); if (retval != VFP_OK) { vfp_suck_fini(bo); break; @@ -155,24 +155,29 @@ enum vfp_status VFP_Suck(struct busyobj *bo, void *p, ssize_t *lp) { enum vfp_status vp; + struct vfp_entry *vfe; CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); AN(p); AN(lp); - assert(bo->vfp_nxt > 0); - bo->vfp_nxt--; - if (bo->vfps[bo->vfp_nxt] == NULL) { + vfe = bo->vfp_nxt; + CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC); + bo->vfp_nxt = VTAILQ_NEXT(vfe, list); + + if (vfe->vfp == NULL) { *lp = 0; - vp = (enum vfp_status)bo->vfps_priv[bo->vfp_nxt]; + vp = (enum vfp_status)vfe->priv2; + bo->vfp_nxt = vfe; + return (vp); } else { - vp = vfp_call(bo, bo->vfp_nxt, p, lp); + vp = vfp_call(bo, vfe, p, lp); if (vp != VFP_OK) { - (void)vfp_call(bo, bo->vfp_nxt, vfp_fini, NULL); - bo->vfps[bo->vfp_nxt] = NULL; - bo->vfps_priv[bo->vfp_nxt] = vp; + (void)vfp_call(bo, vfe, vfp_fini, NULL); + vfe->vfp = NULL; + vfe->priv2 = vp; } } - bo->vfp_nxt++; + bo->vfp_nxt = vfe; return (vp); } @@ -252,11 +257,16 @@ VFP_Fetch_Body(struct busyobj *bo, ssize_t est) void VFP_Push(struct busyobj *bo, const struct vfp *vfp, intptr_t priv) { + struct vfp_entry *vfe; CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); - bo->vfps_priv[bo->vfp_nxt] = priv; - bo->vfps[bo->vfp_nxt] = vfp; - bo->vfp_nxt++; + vfe = (void*)WS_Alloc(bo->ws, sizeof *vfe); + AN(vfe); + vfe->magic = VFP_ENTRY_MAGIC; + vfe->vfp = vfp; + vfe->priv2 = priv; + VTAILQ_INSERT_HEAD(&bo->vfp, vfe, list); + bo->vfp_nxt = vfe; } /*-------------------------------------------------------------------- From lkarsten at varnish-software.com Fri Jul 4 13:12:05 2014 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Fri, 04 Jul 2014 15:12:05 +0200 Subject: [master] 5f01946 Split BuildRequires into multiple lines. Message-ID: commit 5f0194694d9cec5b7dfb045abe8b2e7df3e748c7 Author: Lasse Karstensen Date: Fri Jul 4 15:11:26 2014 +0200 Split BuildRequires into multiple lines. Adhere to Fedora packaging standard. diff --git a/redhat/varnish.spec b/redhat/varnish.spec index b541d91..1c5e739 100644 --- a/redhat/varnish.spec +++ b/redhat/varnish.spec @@ -17,7 +17,11 @@ 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 #BuildRequires: automake autoconf libtool -BuildRequires: ncurses-devel groff pcre-devel pkgconfig libedit-devel jemalloc-devel +BuildRequires: ncurses-devel +BuildRequires: pcre-devel +BuildRequires: pkgconfig +BuildRequires: libedit-devel +BuildRequires: jemalloc-devel BuildRequires: python-docutils >= 0.6 Requires: varnish-libs = %{version}-%{release} Requires: logrotate From lkarsten at varnish-software.com Fri Jul 4 13:28:30 2014 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Fri, 04 Jul 2014 15:28:30 +0200 Subject: [3.0] ac7f10c Add Travis-CI configuration file. Message-ID: commit ac7f10cd9081990c406bf53b18fbe352384adb14 Author: Lasse Karstensen Date: Fri Jul 4 15:22:31 2014 +0200 Add Travis-CI configuration file. diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..f55a37b --- /dev/null +++ b/.travis.yml @@ -0,0 +1,6 @@ +--- +script: 'make -j3 check' +before_install: + - sudo apt-get install python-docutils + - ./autogen.sh + - ./configure From fgsch at lodoss.net Fri Jul 4 16:05:45 2014 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Fri, 04 Jul 2014 18:05:45 +0200 Subject: [master] b459c8d Typo in BAN configuration Message-ID: commit b459c8d5dd91ca272926a1492267c5ac6f67f2a7 Author: Federico G. Schwindt Date: Fri Jul 4 17:02:05 2014 +0100 Typo in BAN configuration Submitted by: Clement Gautier via github diff --git a/doc/sphinx/users-guide/purging.rst b/doc/sphinx/users-guide/purging.rst index 17b02ee..70fb415 100644 --- a/doc/sphinx/users-guide/purging.rst +++ b/doc/sphinx/users-guide/purging.rst @@ -103,7 +103,7 @@ You can also add bans to Varnish via HTTP. Doing so requires a bit of VCL:: return(synth(403, "Not allowed.")); } ban("req.http.host == " + req.http.host + - "&& req.url == " + req.url); + " && req.url == " + req.url); # Throw a synthetic page so the # request won't go to the backend. From fgsch at lodoss.net Fri Jul 4 16:07:40 2014 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Fri, 04 Jul 2014 18:07:40 +0200 Subject: [3.0] e6f2b52 Typo in BAN configuration Message-ID: commit e6f2b5260badf2b0f9680b467565f99b4617ee70 Author: Federico G. Schwindt Date: Fri Jul 4 17:06:39 2014 +0100 Typo in BAN configuration Submitted by: Clement Gautier via github diff --git a/doc/sphinx/tutorial/purging.rst b/doc/sphinx/tutorial/purging.rst index 422f9f4..dade55d 100644 --- a/doc/sphinx/tutorial/purging.rst +++ b/doc/sphinx/tutorial/purging.rst @@ -116,7 +116,7 @@ You can also add bans to Varnish via HTTP. Doing so requires a bit of VCL:: error 405 "Not allowed."; } ban("req.http.host == " + req.http.host + - "&& req.url == " + req.url); + " && req.url == " + req.url); # Throw a synthetic page so the # request won't go to the backend. From phk at FreeBSD.org Mon Jul 7 09:50:54 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 07 Jul 2014 11:50:54 +0200 Subject: [master] 40d5594 Pass struct vfp_entry * to the vfps. Message-ID: commit 40d5594de5a55bb649bd1d46d897ec80525b4d1c Author: Poul-Henning Kamp Date: Mon Jul 7 08:16:50 2014 +0000 Pass struct vfp_entry * to the vfps. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index d0137fe..996d3dc 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -448,7 +448,7 @@ struct vfp_entry { unsigned magic; #define VFP_ENTRY_MAGIC 0xbe32a027 const struct vfp *vfp; - // void *priv1; + void *priv1; intptr_t priv2; VTAILQ_ENTRY(vfp_entry) list; }; diff --git a/bin/varnishd/cache/cache_esi_fetch.c b/bin/varnishd/cache/cache_esi_fetch.c index 9424399..5b5f9ce 100644 --- a/bin/varnishd/cache/cache_esi_fetch.c +++ b/bin/varnishd/cache/cache_esi_fetch.c @@ -142,13 +142,15 @@ vfp_esi_end(struct busyobj *bo, struct vef_priv *vef, enum vfp_status retval) } static enum vfp_status __match_proto__(vfp_pull_f) -vfp_esi_gzip_pull(struct busyobj *bo, void *p, ssize_t *lp, intptr_t *priv) +vfp_esi_gzip_pull(struct busyobj *bo, void *p, ssize_t *lp, + struct vfp_entry *vfe) { enum vfp_status vp; ssize_t d, l; struct vef_priv *vef; CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC); if (p == vfp_init) { ALLOC_OBJ(vef, VEF_MAGIC); XXXAN(vef); @@ -159,20 +161,19 @@ vfp_esi_gzip_pull(struct busyobj *bo, void *p, ssize_t *lp, intptr_t *priv) XXXAN(vef->ibuf); vef->ibuf_i = vef->ibuf; vef->ibuf_o = vef->ibuf; - *priv = (uintptr_t)vef; + vfe->priv1 = vef; return (VFP_OK); } if (p == vfp_fini) { - if (*priv) - (void)vfp_esi_end(bo, (void*)*priv, VFP_ERROR); - *priv = 0; + if (vfe->priv1 != NULL) + (void)vfp_esi_end(bo, vfe->priv1, VFP_ERROR); + vfe->priv1 = NULL; return (VFP_ERROR); } AN(p); AN(lp); *lp = 0; - AN(priv); - CAST_OBJ_NOTNULL(vef, (void*)*priv, VEF_MAGIC); + CAST_OBJ_NOTNULL(vef, vfe->priv1, VEF_MAGIC); l = vef->ibuf_sz - (vef->ibuf_i - vef->ibuf); if (DO_DEBUG(DBG_ESI_CHOP)) { d = (random() & 3) + 1; @@ -197,36 +198,36 @@ vfp_esi_gzip_pull(struct busyobj *bo, void *p, ssize_t *lp, intptr_t *priv) } if (vp == VFP_END) { vp = vfp_esi_end(bo, vef, vp); - *priv = 0; + vfe->priv1 = NULL; } return (vp); } static enum vfp_status __match_proto__(vfp_pull_f) -vfp_esi_pull(struct busyobj *bo, void *p, ssize_t *lp, intptr_t *priv) +vfp_esi_pull(struct busyobj *bo, void *p, ssize_t *lp, struct vfp_entry *vfe) { enum vfp_status vp; ssize_t d; struct vef_priv *vef; CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC); if (p == vfp_init) { ALLOC_OBJ(vef, VEF_MAGIC); XXXAN(vef); vef->vep = VEP_Init(bo, NULL, NULL); - *priv = (uintptr_t)vef; + vfe->priv1 = vef; return (VFP_OK); } if (p == vfp_fini) { - if (*priv) - (void)vfp_esi_end(bo, (void*)*priv, VFP_ERROR); - *priv = 0; + if (vfe->priv1 != NULL) + (void)vfp_esi_end(bo, vfe->priv1, VFP_ERROR); + vfe->priv1 = NULL; return (VFP_ERROR); } AN(p); AN(lp); - AN(priv); - CAST_OBJ_NOTNULL(vef, (void*)*priv, VEF_MAGIC); + CAST_OBJ_NOTNULL(vef, vfe->priv1, VEF_MAGIC); if (DO_DEBUG(DBG_ESI_CHOP)) { d = (random() & 3) + 1; if (d < *lp) @@ -237,7 +238,7 @@ vfp_esi_pull(struct busyobj *bo, void *p, ssize_t *lp, intptr_t *priv) VEP_Parse(vef->vep, bo, p, *lp); if (vp == VFP_END) { vp = vfp_esi_end(bo, vef, vp); - *priv = 0; + vfe->priv1 = NULL; } return (vp); } diff --git a/bin/varnishd/cache/cache_fetch_proc.c b/bin/varnishd/cache/cache_fetch_proc.c index 20e5d09..eae386d 100644 --- a/bin/varnishd/cache/cache_fetch_proc.c +++ b/bin/varnishd/cache/cache_fetch_proc.c @@ -115,7 +115,7 @@ static enum vfp_status vfp_call(struct busyobj *bo, struct vfp_entry *vfe, void *p, ssize_t *lp) { AN(vfe->vfp->pull); - return (vfe->vfp->pull(bo, p, lp, &vfe->priv2)); + return (vfe->vfp->pull(bo, p, lp, vfe)); } static void diff --git a/bin/varnishd/cache/cache_filter.h b/bin/varnishd/cache/cache_filter.h index d2b0cf1..0d0c670 100644 --- a/bin/varnishd/cache/cache_filter.h +++ b/bin/varnishd/cache/cache_filter.h @@ -29,6 +29,7 @@ struct busyobj; struct req; +struct vfp_entry; /* Fetch processors --------------------------------------------------*/ @@ -38,7 +39,7 @@ enum vfp_status { VFP_END = 1, }; typedef enum vfp_status - vfp_pull_f(struct busyobj *bo, void *p, ssize_t *len, intptr_t *priv); + vfp_pull_f(struct busyobj *, void *ptr, ssize_t *len, struct vfp_entry *); struct vfp { vfp_pull_f *pull; diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c index 2e3528b..bbae538 100644 --- a/bin/varnishd/cache/cache_gzip.c +++ b/bin/varnishd/cache/cache_gzip.c @@ -451,7 +451,7 @@ VGZ_Destroy(struct vgz **vgp) */ static enum vfp_status __match_proto__(vfp_pull_f) -vfp_gunzip_pull(struct busyobj *bo, void *p, ssize_t *lp, intptr_t *priv) +vfp_gunzip_pull(struct busyobj *bo, void *p, ssize_t *lp, struct vfp_entry *vfe) { ssize_t l; struct vgz *vg; @@ -461,27 +461,27 @@ vfp_gunzip_pull(struct busyobj *bo, void *p, ssize_t *lp, intptr_t *priv) enum vfp_status vp = VFP_OK; CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC); if (p == vfp_init) { vg = VGZ_NewUngzip(bo->vsl, "U F -"); XXXAZ(vgz_getmbuf(vg)); - *priv = (uintptr_t)vg; + vfe->priv1 = vg; VGZ_Ibuf(vg, vg->m_buf, 0); AZ(vg->m_len); return (VFP_OK); } if (p == vfp_fini) { - if (*priv != 0) { - CAST_OBJ_NOTNULL(vg, (void*)(*priv), VGZ_MAGIC); - *priv = 0; + if (vfe->priv1 != NULL) { + CAST_OBJ_NOTNULL(vg, vfe->priv1, VGZ_MAGIC); + vfe->priv1 = NULL; (void)VGZ_Destroy(&vg); } - *priv = 0; + vfe->priv1 = NULL; return (VFP_ERROR); } AN(p); AN(lp); - AN(priv); - CAST_OBJ_NOTNULL(vg, (void*)(*priv), VGZ_MAGIC); + CAST_OBJ_NOTNULL(vg, vfe->priv1, VGZ_MAGIC); l = *lp; *lp = 0; VGZ_Obuf(vg, p, l); @@ -525,7 +525,7 @@ const struct vfp vfp_gunzip = { */ static enum vfp_status __match_proto__(vfp_pull_f) -vfp_gzip_pull(struct busyobj *bo, void *p, ssize_t *lp, intptr_t *priv) +vfp_gzip_pull(struct busyobj *bo, void *p, ssize_t *lp, struct vfp_entry *vfe) { ssize_t l; struct vgz *vg; @@ -535,27 +535,27 @@ vfp_gzip_pull(struct busyobj *bo, void *p, ssize_t *lp, intptr_t *priv) enum vfp_status vp = VFP_ERROR; CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC); if (p == vfp_init) { vg = VGZ_NewGzip(bo->vsl, "G F -"); XXXAZ(vgz_getmbuf(vg)); - *priv = (uintptr_t)vg; + vfe->priv1 = vg; VGZ_Ibuf(vg, vg->m_buf, 0); AZ(vg->m_len); vg->flag = VGZ_NORMAL; return (VFP_OK); } if (p == vfp_fini) { - if (*priv != 0) { - CAST_OBJ_NOTNULL(vg, (void*)(*priv), VGZ_MAGIC); - *priv = 0; + if (vfe->priv1 != NULL) { + CAST_OBJ_NOTNULL(vg, vfe->priv1, VGZ_MAGIC); + vfe->priv1 = NULL; (void)VGZ_Destroy(&vg); } return (VFP_ERROR); } AN(p); AN(lp); - AN(priv); - CAST_OBJ_NOTNULL(vg, (void*)(*priv), VGZ_MAGIC); + CAST_OBJ_NOTNULL(vg, vfe->priv1, VGZ_MAGIC); l = *lp; *lp = 0; VGZ_Obuf(vg, p, l); @@ -600,7 +600,8 @@ const struct vfp vfp_gzip = { */ static enum vfp_status __match_proto__(vfp_pull_f) -vfp_testgunzip_pull(struct busyobj *bo, void *p, ssize_t *lp, intptr_t *priv) +vfp_testgunzip_pull(struct busyobj *bo, void *p, ssize_t *lp, + struct vfp_entry *vfe) { struct vgz *vg; enum vgzret_e vr = VGZ_ERROR; @@ -609,25 +610,25 @@ vfp_testgunzip_pull(struct busyobj *bo, void *p, ssize_t *lp, intptr_t *priv) enum vfp_status vp; CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC); if (p == vfp_init) { vg = VGZ_NewUngzip(bo->vsl, "u F -"); XXXAZ(vgz_getmbuf(vg)); - *priv = (uintptr_t)vg; + vfe->priv1 = vg; AZ(vg->m_len); return (VFP_OK); } if (p == vfp_fini) { - if (*priv != 0) { - CAST_OBJ_NOTNULL(vg, (void*)(*priv), VGZ_MAGIC); - *priv = 0; + if (vfe->priv1 != NULL) { + CAST_OBJ_NOTNULL(vg, vfe->priv1, VGZ_MAGIC); + vfe->priv1 = NULL; (void)VGZ_Destroy(&vg); } return (VFP_ERROR); } AN(p); AN(lp); - AN(priv); - CAST_OBJ_NOTNULL(vg, (void*)(*priv), VGZ_MAGIC); + CAST_OBJ_NOTNULL(vg, vfe->priv1, VGZ_MAGIC); vp = VFP_Suck(bo, p, lp); if (vp == VFP_ERROR) return (vp); diff --git a/bin/varnishd/cache/cache_http1_fetch.c b/bin/varnishd/cache/cache_http1_fetch.c index 65c2591..9fa7258 100644 --- a/bin/varnishd/cache/cache_http1_fetch.c +++ b/bin/varnishd/cache/cache_http1_fetch.c @@ -69,33 +69,35 @@ vbf_fetch_number(const char *nbr, int radix) /*--------------------------------------------------------------------*/ static enum vfp_status __match_proto__(vfp_pull_f) -v1f_pull_straight(struct busyobj *bo, void *p, ssize_t *lp, intptr_t *priv) +v1f_pull_straight(struct busyobj *bo, void *p, ssize_t *lp, + struct vfp_entry *vfe) { ssize_t l, lr; CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC); + if (p == vfp_init) return (VFP_OK); if (p == vfp_fini) return (VFP_ERROR); AN(p); AN(lp); - AN(priv); l = *lp; *lp = 0; - if (!*priv) // XXX: Optimize Content-Len: 0 out earlier + if (vfe->priv2 == 0) // XXX: Optimize Content-Len: 0 out earlier return (VFP_END); - if (*priv < l) - l = *priv; + if (vfe->priv2 < l) + l = vfe->priv2; lr = HTTP1_Read(&bo->htc, p, l); bo->acct.beresp_bodybytes += lr; if (lr <= 0) return (VFP_Error(bo, "straight insufficient bytes")); *lp = lr; - *priv -= lr; - if (*priv == 0) + vfe->priv2 -= lr; + if (vfe->priv2 == 0) return (VFP_END); return (VFP_OK); } @@ -111,20 +113,22 @@ static const struct vfp v1f_straight = { */ static enum vfp_status __match_proto__(vfp_pull_f) -v1f_pull_chunked(struct busyobj *bo, void *p, ssize_t *lp, intptr_t *priv) +v1f_pull_chunked(struct busyobj *bo, void *p, ssize_t *lp, + struct vfp_entry *vfe) { const char *err; CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC); + if (p == vfp_init) return (VFP_OK); if (p == vfp_fini) return (VFP_ERROR); AN(p); AN(lp); - AN(priv); - switch (HTTP1_Chunked(&bo->htc, priv, &err, + switch (HTTP1_Chunked(&bo->htc, &vfe->priv2, &err, &bo->acct.beresp_bodybytes, p, lp)) { case H1CR_ERROR: return (VFP_Error(bo, "%s", err)); @@ -144,18 +148,18 @@ static const struct vfp v1f_chunked = { /*--------------------------------------------------------------------*/ static enum vfp_status __match_proto__(vfp_pull_f) -v1f_pull_eof(struct busyobj *bo, void *p, ssize_t *lp, intptr_t *priv) +v1f_pull_eof(struct busyobj *bo, void *p, ssize_t *lp, struct vfp_entry *vfe) { ssize_t l, lr; CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC); if (p == vfp_init) return (VFP_OK); if (p == vfp_fini) return (VFP_ERROR); AN(p); AN(lp); - AN(priv); l = *lp; *lp = 0; From phk at FreeBSD.org Mon Jul 7 09:50:54 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 07 Jul 2014 11:50:54 +0200 Subject: [master] 0783808 Split the init and fini functions out for VFP's. Message-ID: commit 0783808a49d0f4fdcc6d5b35eec0f510c85b1108 Author: Poul-Henning Kamp Date: Mon Jul 7 09:35:19 2014 +0000 Split the init and fini functions out for VFP's. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 996d3dc..a83ae19 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -885,8 +885,6 @@ void VFP_Init(void); void VFP_Fetch_Body(struct busyobj *bo, ssize_t est); void VFP_Push(struct busyobj *, const struct vfp *, intptr_t priv); enum vfp_status VFP_Suck(struct busyobj *, void *p, ssize_t *lp); -extern char vfp_init[]; -extern char vfp_fini[]; /* cache_gzip.c */ struct vgz; diff --git a/bin/varnishd/cache/cache_esi_fetch.c b/bin/varnishd/cache/cache_esi_fetch.c index 5b5f9ce..49f2e3d 100644 --- a/bin/varnishd/cache/cache_esi_fetch.c +++ b/bin/varnishd/cache/cache_esi_fetch.c @@ -141,6 +141,29 @@ vfp_esi_end(struct busyobj *bo, struct vef_priv *vef, enum vfp_status retval) return (retval); } +static enum vfp_status __match_proto__(vfp_init_f) +vfp_esi_gzip_init(struct busyobj *bo, struct vfp_entry *vfe) +{ + struct vef_priv *vef; + + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC); + ALLOC_OBJ(vef, VEF_MAGIC); + if (vef == NULL) + return (VFP_ERROR); + vef->vgz = VGZ_NewGzip(bo->vsl, "G F E"); + vef->vep = VEP_Init(bo, vfp_vep_callback, vef); + vef->ibuf_sz = cache_param->gzip_buffer; + vef->ibuf = calloc(1L, vef->ibuf_sz); + if (vef->ibuf == NULL) + return (vfp_esi_end(bo, vef, VFP_ERROR)); + XXXAN(vef->ibuf); + vef->ibuf_i = vef->ibuf; + vef->ibuf_o = vef->ibuf; + vfe->priv1 = vef; + return (VFP_OK); +} + static enum vfp_status __match_proto__(vfp_pull_f) vfp_esi_gzip_pull(struct busyobj *bo, void *p, ssize_t *lp, struct vfp_entry *vfe) @@ -151,29 +174,10 @@ vfp_esi_gzip_pull(struct busyobj *bo, void *p, ssize_t *lp, CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC); - if (p == vfp_init) { - ALLOC_OBJ(vef, VEF_MAGIC); - XXXAN(vef); - vef->vgz = VGZ_NewGzip(bo->vsl, "G F E"); - vef->vep = VEP_Init(bo, vfp_vep_callback, vef); - vef->ibuf_sz = cache_param->gzip_buffer; - vef->ibuf = calloc(1L, vef->ibuf_sz); - XXXAN(vef->ibuf); - vef->ibuf_i = vef->ibuf; - vef->ibuf_o = vef->ibuf; - vfe->priv1 = vef; - return (VFP_OK); - } - if (p == vfp_fini) { - if (vfe->priv1 != NULL) - (void)vfp_esi_end(bo, vfe->priv1, VFP_ERROR); - vfe->priv1 = NULL; - return (VFP_ERROR); - } + CAST_OBJ_NOTNULL(vef, vfe->priv1, VEF_MAGIC); AN(p); AN(lp); *lp = 0; - CAST_OBJ_NOTNULL(vef, vfe->priv1, VEF_MAGIC); l = vef->ibuf_sz - (vef->ibuf_i - vef->ibuf); if (DO_DEBUG(DBG_ESI_CHOP)) { d = (random() & 3) + 1; @@ -203,6 +207,19 @@ vfp_esi_gzip_pull(struct busyobj *bo, void *p, ssize_t *lp, return (vp); } +static enum vfp_status __match_proto__(vfp_init_f) +vfp_esi_init(struct busyobj *bo, struct vfp_entry *vfe) +{ + struct vef_priv *vef; + + ALLOC_OBJ(vef, VEF_MAGIC); + if (vef == NULL) + return (VFP_ERROR); + vef->vep = VEP_Init(bo, NULL, NULL); + vfe->priv1 = vef; + return (VFP_OK); +} + static enum vfp_status __match_proto__(vfp_pull_f) vfp_esi_pull(struct busyobj *bo, void *p, ssize_t *lp, struct vfp_entry *vfe) { @@ -212,22 +229,9 @@ vfp_esi_pull(struct busyobj *bo, void *p, ssize_t *lp, struct vfp_entry *vfe) CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC); - if (p == vfp_init) { - ALLOC_OBJ(vef, VEF_MAGIC); - XXXAN(vef); - vef->vep = VEP_Init(bo, NULL, NULL); - vfe->priv1 = vef; - return (VFP_OK); - } - if (p == vfp_fini) { - if (vfe->priv1 != NULL) - (void)vfp_esi_end(bo, vfe->priv1, VFP_ERROR); - vfe->priv1 = NULL; - return (VFP_ERROR); - } + CAST_OBJ_NOTNULL(vef, vfe->priv1, VEF_MAGIC); AN(p); AN(lp); - CAST_OBJ_NOTNULL(vef, vfe->priv1, VEF_MAGIC); if (DO_DEBUG(DBG_ESI_CHOP)) { d = (random() & 3) + 1; if (d < *lp) @@ -243,10 +247,27 @@ vfp_esi_pull(struct busyobj *bo, void *p, ssize_t *lp, struct vfp_entry *vfe) return (vp); } +static void __match_proto__(vfp_fini_f) +vfp_esi_fini(struct busyobj *bo, struct vfp_entry *vfe) +{ + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC); + + if (vfe->priv1 != NULL) + (void)vfp_esi_end(bo, vfe->priv1, VFP_ERROR); + vfe->priv1 = NULL; +} + const struct vfp vfp_esi = { + .name = "ESI", + .init = vfp_esi_init, .pull = vfp_esi_pull, + .fini = vfp_esi_fini, }; const struct vfp vfp_esi_gzip = { + .name = "ESI_GZIP", + .init = vfp_esi_gzip_init, .pull = vfp_esi_gzip_pull, + .fini = vfp_esi_fini, }; diff --git a/bin/varnishd/cache/cache_fetch_proc.c b/bin/varnishd/cache/cache_fetch_proc.c index eae386d..ca3b172 100644 --- a/bin/varnishd/cache/cache_fetch_proc.c +++ b/bin/varnishd/cache/cache_fetch_proc.c @@ -43,9 +43,6 @@ static unsigned fetchfrag; -char vfp_init[] = ""; -char vfp_fini[] = ""; - /*-------------------------------------------------------------------- * We want to issue the first error we encounter on fetching and * supress the rest. This function does that. @@ -111,35 +108,33 @@ VFP_GetStorage(struct busyobj *bo, ssize_t sz) /********************************************************************** */ -static enum vfp_status -vfp_call(struct busyobj *bo, struct vfp_entry *vfe, void *p, ssize_t *lp) -{ - AN(vfe->vfp->pull); - return (vfe->vfp->pull(bo, p, lp, vfe)); -} - static void vfp_suck_fini(struct busyobj *bo) { struct vfp_entry *vfe; VTAILQ_FOREACH(vfe, &bo->vfp, list) { - if(vfe->vfp != NULL) - (void)vfp_call(bo, vfe, vfp_fini, NULL); + if(vfe->vfp != NULL && vfe->vfp->fini != NULL) + vfe->vfp->fini(bo, vfe); } } static enum vfp_status vfp_suck_init(struct busyobj *bo) { - enum vfp_status retval = VFP_ERROR; + enum vfp_status retval = VFP_OK; struct vfp_entry *vfe; VTAILQ_FOREACH(vfe, &bo->vfp, list) { - retval = vfp_call(bo, vfe, vfp_init, NULL); + if (vfe->vfp->init == NULL) + continue; + retval = vfe->vfp->init(bo, vfe); if (retval != VFP_OK) { + (void)VFP_Error(bo, + "Fetch filter %s failed to initialize", + vfe->vfp->name); vfp_suck_fini(bo); - break; + return (retval); } } return (retval); @@ -170,9 +165,13 @@ VFP_Suck(struct busyobj *bo, void *p, ssize_t *lp) bo->vfp_nxt = vfe; return (vp); } else { - vp = vfp_call(bo, vfe, p, lp); + vp = vfe->vfp->pull(bo, p, lp, vfe); + if (vp == VFP_ERROR) + (void)VFP_Error(bo, "Fetch filter %s returned %d", + vfe->vfp->name, vp); if (vp != VFP_OK) { - (void)vfp_call(bo, vfe, vfp_fini, NULL); + if (vfe->vfp->fini != NULL) + vfe->vfp->fini(bo, vfe); vfe->vfp = NULL; vfe->priv2 = vp; } diff --git a/bin/varnishd/cache/cache_filter.h b/bin/varnishd/cache/cache_filter.h index 0d0c670..2f0ce3c 100644 --- a/bin/varnishd/cache/cache_filter.h +++ b/bin/varnishd/cache/cache_filter.h @@ -38,11 +38,19 @@ enum vfp_status { VFP_OK = 0, VFP_END = 1, }; + +typedef enum vfp_status vfp_init_f(struct busyobj *, struct vfp_entry *); typedef enum vfp_status vfp_pull_f(struct busyobj *, void *ptr, ssize_t *len, struct vfp_entry *); +typedef void vfp_fini_f(struct busyobj *, struct vfp_entry *); struct vfp { + const char *name; + vfp_init_f *init; vfp_pull_f *pull; + vfp_fini_f *fini; + const void *priv1; + intptr_t priv2; }; extern const struct vfp vfp_gunzip; diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c index bbae538..7653630 100644 --- a/bin/varnishd/cache/cache_gzip.c +++ b/bin/varnishd/cache/cache_gzip.c @@ -444,6 +444,30 @@ VGZ_Destroy(struct vgz **vgp) return (vr); } +/*--------------------------------------------------------------------*/ + +static enum vfp_status __match_proto__(vfp_init_f) +vfp_gzip_init(struct busyobj *bo, struct vfp_entry *vfe) +{ + struct vgz *vg; + + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC); + + if (vfe->vfp->priv2) + vg = VGZ_NewGzip(bo->vsl, vfe->vfp->priv1); + else + vg = VGZ_NewUngzip(bo->vsl, vfe->vfp->priv1); + if (vg == NULL) + return (VFP_ERROR); + if (vgz_getmbuf(vg)) + return (VFP_ERROR); + vfe->priv1 = vg; + VGZ_Ibuf(vg, vg->m_buf, 0); + AZ(vg->m_len); + return (VFP_OK); +} + /*-------------------------------------------------------------------- * VFP_GUNZIP * @@ -462,26 +486,9 @@ vfp_gunzip_pull(struct busyobj *bo, void *p, ssize_t *lp, struct vfp_entry *vfe) CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC); - if (p == vfp_init) { - vg = VGZ_NewUngzip(bo->vsl, "U F -"); - XXXAZ(vgz_getmbuf(vg)); - vfe->priv1 = vg; - VGZ_Ibuf(vg, vg->m_buf, 0); - AZ(vg->m_len); - return (VFP_OK); - } - if (p == vfp_fini) { - if (vfe->priv1 != NULL) { - CAST_OBJ_NOTNULL(vg, vfe->priv1, VGZ_MAGIC); - vfe->priv1 = NULL; - (void)VGZ_Destroy(&vg); - } - vfe->priv1 = NULL; - return (VFP_ERROR); - } + CAST_OBJ_NOTNULL(vg, vfe->priv1, VGZ_MAGIC); AN(p); AN(lp); - CAST_OBJ_NOTNULL(vg, vfe->priv1, VGZ_MAGIC); l = *lp; *lp = 0; VGZ_Obuf(vg, p, l); @@ -513,10 +520,6 @@ vfp_gunzip_pull(struct busyobj *bo, void *p, ssize_t *lp, struct vfp_entry *vfe) return (vp); } -const struct vfp vfp_gunzip = { - .pull = vfp_gunzip_pull, -}; - /*-------------------------------------------------------------------- * VFP_GZIP @@ -536,26 +539,9 @@ vfp_gzip_pull(struct busyobj *bo, void *p, ssize_t *lp, struct vfp_entry *vfe) CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC); - if (p == vfp_init) { - vg = VGZ_NewGzip(bo->vsl, "G F -"); - XXXAZ(vgz_getmbuf(vg)); - vfe->priv1 = vg; - VGZ_Ibuf(vg, vg->m_buf, 0); - AZ(vg->m_len); - vg->flag = VGZ_NORMAL; - return (VFP_OK); - } - if (p == vfp_fini) { - if (vfe->priv1 != NULL) { - CAST_OBJ_NOTNULL(vg, vfe->priv1, VGZ_MAGIC); - vfe->priv1 = NULL; - (void)VGZ_Destroy(&vg); - } - return (VFP_ERROR); - } + CAST_OBJ_NOTNULL(vg, vfe->priv1, VGZ_MAGIC); AN(p); AN(lp); - CAST_OBJ_NOTNULL(vg, vfe->priv1, VGZ_MAGIC); l = *lp; *lp = 0; VGZ_Obuf(vg, p, l); @@ -588,10 +574,6 @@ vfp_gzip_pull(struct busyobj *bo, void *p, ssize_t *lp, struct vfp_entry *vfe) return (VFP_END); } -const struct vfp vfp_gzip = { - .pull = vfp_gzip_pull, -}; - /*-------------------------------------------------------------------- * VFP_TESTGZIP * @@ -611,21 +593,7 @@ vfp_testgunzip_pull(struct busyobj *bo, void *p, ssize_t *lp, CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC); - if (p == vfp_init) { - vg = VGZ_NewUngzip(bo->vsl, "u F -"); - XXXAZ(vgz_getmbuf(vg)); - vfe->priv1 = vg; - AZ(vg->m_len); - return (VFP_OK); - } - if (p == vfp_fini) { - if (vfe->priv1 != NULL) { - CAST_OBJ_NOTNULL(vg, vfe->priv1, VGZ_MAGIC); - vfe->priv1 = NULL; - (void)VGZ_Destroy(&vg); - } - return (VFP_ERROR); - } + CAST_OBJ_NOTNULL(vg, vfe->priv1, VGZ_MAGIC); AN(p); AN(lp); CAST_OBJ_NOTNULL(vg, vfe->priv1, VGZ_MAGIC); @@ -652,6 +620,46 @@ vfp_testgunzip_pull(struct busyobj *bo, void *p, ssize_t *lp, return (vp); } +/*--------------------------------------------------------------------*/ + +static void __match_proto__(vfp_fini_f) +vfp_gzip_fini(struct busyobj *bo, struct vfp_entry *vfe) +{ + struct vgz *vg; + + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC); + + if (vfe->priv1 != NULL) { + CAST_OBJ_NOTNULL(vg, vfe->priv1, VGZ_MAGIC); + vfe->priv1 = NULL; + (void)VGZ_Destroy(&vg); + } +} + +/*--------------------------------------------------------------------*/ + +const struct vfp vfp_gunzip = { + .name = "GUNZIP", + .init = vfp_gzip_init, + .pull = vfp_gunzip_pull, + .fini = vfp_gzip_fini, + .priv1 = "U F -", +}; + +const struct vfp vfp_gzip = { + .name = "GZIP", + .init = vfp_gzip_init, + .pull = vfp_gzip_pull, + .fini = vfp_gzip_fini, + .priv1 = "G F -", + .priv2 = 1, +}; + const struct vfp vfp_testgunzip = { + .name = "TESTGUNZIP", + .init = vfp_gzip_init, .pull = vfp_testgunzip_pull, + .fini = vfp_gzip_fini, + .priv1 = "u F -", }; diff --git a/bin/varnishd/cache/cache_http1_fetch.c b/bin/varnishd/cache/cache_http1_fetch.c index 9fa7258..4fe1855 100644 --- a/bin/varnishd/cache/cache_http1_fetch.c +++ b/bin/varnishd/cache/cache_http1_fetch.c @@ -77,10 +77,6 @@ v1f_pull_straight(struct busyobj *bo, void *p, ssize_t *lp, CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC); - if (p == vfp_init) - return (VFP_OK); - if (p == vfp_fini) - return (VFP_ERROR); AN(p); AN(lp); @@ -103,6 +99,7 @@ v1f_pull_straight(struct busyobj *bo, void *p, ssize_t *lp, } static const struct vfp v1f_straight = { + .name = "V1F_STRAIGHT", .pull = v1f_pull_straight, }; @@ -121,10 +118,6 @@ v1f_pull_chunked(struct busyobj *bo, void *p, ssize_t *lp, CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC); - if (p == vfp_init) - return (VFP_OK); - if (p == vfp_fini) - return (VFP_ERROR); AN(p); AN(lp); @@ -142,6 +135,7 @@ v1f_pull_chunked(struct busyobj *bo, void *p, ssize_t *lp, } static const struct vfp v1f_chunked = { + .name = "V1F_CHUNKED", .pull = v1f_pull_chunked, }; @@ -154,10 +148,6 @@ v1f_pull_eof(struct busyobj *bo, void *p, ssize_t *lp, struct vfp_entry *vfe) CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC); - if (p == vfp_init) - return (VFP_OK); - if (p == vfp_fini) - return (VFP_ERROR); AN(p); AN(lp); @@ -173,6 +163,7 @@ v1f_pull_eof(struct busyobj *bo, void *p, ssize_t *lp, struct vfp_entry *vfe) } static const struct vfp v1f_eof = { + .name = "V1F_EOF", .pull = v1f_pull_eof, }; diff --git a/bin/varnishd/flint.lnt b/bin/varnishd/flint.lnt index be84816..d394f75 100644 --- a/bin/varnishd/flint.lnt +++ b/bin/varnishd/flint.lnt @@ -113,6 +113,7 @@ -sem(EXP_Inject, custodial(1)) -sem(WS_Init, custodial(2)) -sem(http_Setup, custodial(2)) +-sem(vfp_esi_end, custodial(2)) -sem(vdi_dns_cache_list_add, custodial(3)) From phk at FreeBSD.org Mon Jul 7 09:50:54 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 07 Jul 2014 11:50:54 +0200 Subject: [master] b97fdbf Flip the order of arguments to make more sense. Message-ID: commit b97fdbfd3329c36cd528bee50e045c42344b5332 Author: Poul-Henning Kamp Date: Mon Jul 7 09:50:37 2014 +0000 Flip the order of arguments to make more sense. diff --git a/bin/varnishd/cache/cache_esi_fetch.c b/bin/varnishd/cache/cache_esi_fetch.c index 49f2e3d..ba8c065 100644 --- a/bin/varnishd/cache/cache_esi_fetch.c +++ b/bin/varnishd/cache/cache_esi_fetch.c @@ -165,8 +165,8 @@ vfp_esi_gzip_init(struct busyobj *bo, struct vfp_entry *vfe) } static enum vfp_status __match_proto__(vfp_pull_f) -vfp_esi_gzip_pull(struct busyobj *bo, void *p, ssize_t *lp, - struct vfp_entry *vfe) +vfp_esi_gzip_pull(struct busyobj *bo, struct vfp_entry *vfe, void *p, + ssize_t *lp) { enum vfp_status vp; ssize_t d, l; @@ -221,7 +221,7 @@ vfp_esi_init(struct busyobj *bo, struct vfp_entry *vfe) } static enum vfp_status __match_proto__(vfp_pull_f) -vfp_esi_pull(struct busyobj *bo, void *p, ssize_t *lp, struct vfp_entry *vfe) +vfp_esi_pull(struct busyobj *bo, struct vfp_entry *vfe, void *p, ssize_t *lp) { enum vfp_status vp; ssize_t d; diff --git a/bin/varnishd/cache/cache_fetch_proc.c b/bin/varnishd/cache/cache_fetch_proc.c index ca3b172..e3585fe 100644 --- a/bin/varnishd/cache/cache_fetch_proc.c +++ b/bin/varnishd/cache/cache_fetch_proc.c @@ -165,7 +165,7 @@ VFP_Suck(struct busyobj *bo, void *p, ssize_t *lp) bo->vfp_nxt = vfe; return (vp); } else { - vp = vfe->vfp->pull(bo, p, lp, vfe); + vp = vfe->vfp->pull(bo, vfe, p, lp); if (vp == VFP_ERROR) (void)VFP_Error(bo, "Fetch filter %s returned %d", vfe->vfp->name, vp); diff --git a/bin/varnishd/cache/cache_filter.h b/bin/varnishd/cache/cache_filter.h index 2f0ce3c..a5716a4 100644 --- a/bin/varnishd/cache/cache_filter.h +++ b/bin/varnishd/cache/cache_filter.h @@ -41,7 +41,7 @@ enum vfp_status { typedef enum vfp_status vfp_init_f(struct busyobj *, struct vfp_entry *); typedef enum vfp_status - vfp_pull_f(struct busyobj *, void *ptr, ssize_t *len, struct vfp_entry *); + vfp_pull_f(struct busyobj *, struct vfp_entry *, void *ptr, ssize_t *len); typedef void vfp_fini_f(struct busyobj *, struct vfp_entry *); struct vfp { diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c index 7653630..f189785 100644 --- a/bin/varnishd/cache/cache_gzip.c +++ b/bin/varnishd/cache/cache_gzip.c @@ -475,7 +475,8 @@ vfp_gzip_init(struct busyobj *bo, struct vfp_entry *vfe) */ static enum vfp_status __match_proto__(vfp_pull_f) -vfp_gunzip_pull(struct busyobj *bo, void *p, ssize_t *lp, struct vfp_entry *vfe) +vfp_gunzip_pull(struct busyobj *bo, struct vfp_entry *vfe, void *p, + ssize_t *lp) { ssize_t l; struct vgz *vg; @@ -528,7 +529,8 @@ vfp_gunzip_pull(struct busyobj *bo, void *p, ssize_t *lp, struct vfp_entry *vfe) */ static enum vfp_status __match_proto__(vfp_pull_f) -vfp_gzip_pull(struct busyobj *bo, void *p, ssize_t *lp, struct vfp_entry *vfe) +vfp_gzip_pull(struct busyobj *bo, struct vfp_entry *vfe, void *p, + ssize_t *lp) { ssize_t l; struct vgz *vg; @@ -582,8 +584,8 @@ vfp_gzip_pull(struct busyobj *bo, void *p, ssize_t *lp, struct vfp_entry *vfe) */ static enum vfp_status __match_proto__(vfp_pull_f) -vfp_testgunzip_pull(struct busyobj *bo, void *p, ssize_t *lp, - struct vfp_entry *vfe) +vfp_testgunzip_pull(struct busyobj *bo, struct vfp_entry *vfe, void *p, + ssize_t *lp) { struct vgz *vg; enum vgzret_e vr = VGZ_ERROR; diff --git a/bin/varnishd/cache/cache_http1_fetch.c b/bin/varnishd/cache/cache_http1_fetch.c index 4fe1855..22d801a 100644 --- a/bin/varnishd/cache/cache_http1_fetch.c +++ b/bin/varnishd/cache/cache_http1_fetch.c @@ -69,8 +69,8 @@ vbf_fetch_number(const char *nbr, int radix) /*--------------------------------------------------------------------*/ static enum vfp_status __match_proto__(vfp_pull_f) -v1f_pull_straight(struct busyobj *bo, void *p, ssize_t *lp, - struct vfp_entry *vfe) +v1f_pull_straight(struct busyobj *bo, struct vfp_entry *vfe, void *p, + ssize_t *lp) { ssize_t l, lr; @@ -110,8 +110,8 @@ static const struct vfp v1f_straight = { */ static enum vfp_status __match_proto__(vfp_pull_f) -v1f_pull_chunked(struct busyobj *bo, void *p, ssize_t *lp, - struct vfp_entry *vfe) +v1f_pull_chunked(struct busyobj *bo, struct vfp_entry *vfe, void *p, + ssize_t *lp) { const char *err; @@ -142,7 +142,8 @@ static const struct vfp v1f_chunked = { /*--------------------------------------------------------------------*/ static enum vfp_status __match_proto__(vfp_pull_f) -v1f_pull_eof(struct busyobj *bo, void *p, ssize_t *lp, struct vfp_entry *vfe) +v1f_pull_eof(struct busyobj *bo, struct vfp_entry *vfe, void *p, + ssize_t *lp) { ssize_t l, lr; From fgsch at lodoss.net Tue Jul 8 10:00:23 2014 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Tue, 08 Jul 2014 12:00:23 +0200 Subject: [master] 953d31c Correct AC_CHECK_PROGS usage Message-ID: commit 953d31ce6554781b1157aec8f2fe773a4006a388 Author: Federico G. Schwindt Date: Tue Jul 8 10:59:20 2014 +0100 Correct AC_CHECK_PROGS usage diff --git a/configure.ac b/configure.ac index 118f743..ced8495 100644 --- a/configure.ac +++ b/configure.ac @@ -321,7 +321,10 @@ else fi AM_MISSING_HAS_RUN -AC_CHECK_PROGS(PYTHON, [python3 python3.1 python3.2 python2.7 python2.6 python2.5 python2 python], [AC_MSG_ERROR([Python is needed to build Varnish, please install python.])]) +AC_CHECK_PROGS(PYTHON, [python3 python3.1 python3.2 python2.7 python2.6 python2.5 python2 python], "no") +if test "x$PYTHON" = "xno"; then + AC_MSG_ERROR([Python is needed to build Varnish, please install python.]) +fi AC_CHECK_DECL([SO_ACCEPTFILTER], AC_DEFINE(HAVE_ACCEPT_FILTERS,1,[Define to 1 if you have accept filters]), From fgsch at lodoss.net Tue Jul 8 10:16:11 2014 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Tue, 08 Jul 2014 12:16:11 +0200 Subject: [3.0] a18deaf Correct AC_CHECK_PROGS usage Message-ID: commit a18deafe61fd6964474de705c5a240edaf7074c4 Author: Federico G. Schwindt Date: Tue Jul 8 10:59:20 2014 +0100 Correct AC_CHECK_PROGS usage diff --git a/configure.ac b/configure.ac index 427b230..04c0096 100644 --- a/configure.ac +++ b/configure.ac @@ -369,7 +369,10 @@ else fi AM_MISSING_HAS_RUN -AC_CHECK_PROGS(PYTHON, [python3 python3.1 python3.2 python2.7 python2.6 python2.5 python2 python], [AC_MSG_ERROR([Python is needed to build Varnish, please install python.])]) +AC_CHECK_PROGS(PYTHON, [python3 python3.1 python3.2 python2.7 python2.6 python2.5 python2 python], "no") +if test "x$PYTHON" = "xno"; then + AC_MSG_ERROR([Python is needed to build Varnish, please install python.]) +fi # Older Solaris versions define SO_{RCV,SND}TIMEO, but do not # implement them. From fgsch at lodoss.net Tue Jul 8 20:54:11 2014 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Tue, 08 Jul 2014 22:54:11 +0200 Subject: [master] 3615621 Fix backends and vhosts example Message-ID: commit 361562168e94f62a8c0f67a69689269a4c8a4a85 Author: Federico G. Schwindt Date: Tue Jul 8 21:50:56 2014 +0100 Fix backends and vhosts example Submitted by: nublaii via github diff --git a/doc/sphinx/users-guide/vcl-backends.rst b/doc/sphinx/users-guide/vcl-backends.rst index ecb8b31..5d31e77 100644 --- a/doc/sphinx/users-guide/vcl-backends.rst +++ b/doc/sphinx/users-guide/vcl-backends.rst @@ -100,7 +100,7 @@ this example this is intentional but you might want it to be a bit more tight, maybe relying on the ``==`` operator in stead, like this::: sub vcl_recv { - if (req.http.host == "foo.com" or req.http.host == "www.foo.com") { + if (req.http.host == "foo.com" || req.http.host == "www.foo.com") { set req.backend_hint = foo; } } From phk at FreeBSD.org Wed Jul 9 08:18:02 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 09 Jul 2014 10:18:02 +0200 Subject: [master] 18bf07a Report VFPs in panics Message-ID: commit 18bf07adc1d271ce97e264a4aa7aad004c3d54c0 Author: Poul-Henning Kamp Date: Wed Jul 9 08:16:38 2014 +0000 Report VFPs in panics diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index a83ae19..bdc9554 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -450,6 +450,7 @@ struct vfp_entry { const struct vfp *vfp; void *priv1; intptr_t priv2; + enum vfp_status closed; VTAILQ_ENTRY(vfp_entry) list; }; diff --git a/bin/varnishd/cache/cache_fetch_proc.c b/bin/varnishd/cache/cache_fetch_proc.c index e3585fe..8a58fe1 100644 --- a/bin/varnishd/cache/cache_fetch_proc.c +++ b/bin/varnishd/cache/cache_fetch_proc.c @@ -114,7 +114,7 @@ vfp_suck_fini(struct busyobj *bo) struct vfp_entry *vfe; VTAILQ_FOREACH(vfe, &bo->vfp, list) { - if(vfe->vfp != NULL && vfe->vfp->fini != NULL) + if(vfe->closed == VFP_OK && vfe->vfp->fini != NULL) vfe->vfp->fini(bo, vfe); } } @@ -134,6 +134,7 @@ vfp_suck_init(struct busyobj *bo) "Fetch filter %s failed to initialize", vfe->vfp->name); vfp_suck_fini(bo); + vfe->closed = retval; return (retval); } } @@ -159,12 +160,7 @@ VFP_Suck(struct busyobj *bo, void *p, ssize_t *lp) CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC); bo->vfp_nxt = VTAILQ_NEXT(vfe, list); - if (vfe->vfp == NULL) { - *lp = 0; - vp = (enum vfp_status)vfe->priv2; - bo->vfp_nxt = vfe; - return (vp); - } else { + if (vfe->closed == VFP_OK) { vp = vfe->vfp->pull(bo, vfe, p, lp); if (vp == VFP_ERROR) (void)VFP_Error(bo, "Fetch filter %s returned %d", @@ -172,9 +168,12 @@ VFP_Suck(struct busyobj *bo, void *p, ssize_t *lp) if (vp != VFP_OK) { if (vfe->vfp->fini != NULL) vfe->vfp->fini(bo, vfe); - vfe->vfp = NULL; - vfe->priv2 = vp; + vfe->closed = vp; } + } else { + /* Already closed filter */ + *lp = 0; + vp = vfe->closed; } bo->vfp_nxt = vfe; return (vp); @@ -264,6 +263,7 @@ VFP_Push(struct busyobj *bo, const struct vfp *vfp, intptr_t priv) vfe->magic = VFP_ENTRY_MAGIC; vfe->vfp = vfp; vfe->priv2 = priv; + vfe->closed = VFP_OK; VTAILQ_INSERT_HEAD(&bo->vfp, vfe, list); bo->vfp_nxt = vfe; } diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index 7294439..d7f1182 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -288,6 +288,7 @@ pan_wrk(const struct worker *wrk) static void pan_busyobj(const struct busyobj *bo) { + struct vfp_entry *vfe; VSB_printf(pan_vsp, " busyobj = %p {\n", bo); pan_ws(bo->ws, 4); @@ -301,6 +302,13 @@ pan_busyobj(const struct busyobj *bo) VSB_printf(pan_vsp, " bodystatus = %d (%s),\n", bo->htc.body_status, body_status_2str(bo->htc.body_status)); + if (!VTAILQ_EMPTY(&bo->vfp)) { + VSB_printf(pan_vsp, " filters ="); + VTAILQ_FOREACH(vfe, &bo->vfp, list) + VSB_printf(pan_vsp, " %s=%d", + vfe->vfp->name, (int)vfe->closed); + VSB_printf(pan_vsp, "\n"); + } VSB_printf(pan_vsp, " },\n"); if (VALID_OBJ(bo->vbc, BACKEND_MAGIC)) pan_vbc(bo->vbc); From lkarsten at varnish-software.com Wed Jul 9 09:53:59 2014 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Wed, 09 Jul 2014 11:53:59 +0200 Subject: [master] 1f19803 Update list of required packages. Message-ID: commit 1f198039f07b5057cfbb23eeedb72c1c5ddf6caa Author: Lasse Karstensen Date: Wed Jul 9 11:52:06 2014 +0200 Update list of required packages. We don't need groff any more, but we do not python-sphinx to build the documentation. Fixes: #1534 (for debs) diff --git a/control b/control index dd20a99..ba45133 100644 --- a/control +++ b/control @@ -12,14 +12,13 @@ Build-Depends: automake, autotools-dev, debhelper (>= 7.0.50~), - groff-base, libedit-dev, libncurses-dev, libpcre3-dev, libtool, pkg-config, python-docutils, - xsltproc, + python-sphinx, Vcs-Browser: http://git.debian.org/?p=pkg-varnish/pkg-varnish.git;a=summary Vcs-Git: git://git.debian.org/pkg-varnish/pkg-varnish.git Homepage: http://varnish-cache.org/ From lkarsten at varnish-software.com Wed Jul 9 09:54:54 2014 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Wed, 09 Jul 2014 11:54:54 +0200 Subject: [3.0] f15044c Update list of required packages. Message-ID: commit f15044c2f36bd5a216328d0b59da5b81e63af707 Author: Lasse Karstensen Date: Wed Jul 9 11:52:06 2014 +0200 Update list of required packages. We don't need groff any more, but we do not python-sphinx to build the documentation. Fixes: #1534 (for debs) diff --git a/control b/control index 75b6111..3d9965e 100644 --- a/control +++ b/control @@ -12,14 +12,13 @@ Build-Depends: automake, autotools-dev, debhelper (>= 7.0.50~), - groff-base, libedit-dev, libncurses-dev, libpcre3-dev, libtool, pkg-config, python-docutils, - xsltproc, + python-sphinx, Vcs-Browser: http://git.debian.org/?p=pkg-varnish/pkg-varnish.git;a=summary Vcs-Git: git://git.debian.org/pkg-varnish/pkg-varnish.git Homepage: http://varnish-cache.org/ From lkarsten at varnish-software.com Wed Jul 9 09:57:31 2014 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Wed, 09 Jul 2014 11:57:31 +0200 Subject: [master] 49010b3 Require libjemalloc-dev when building. Message-ID: commit 49010b3fbf84b7d7d89e9adf6b6b0097ff05659f Author: Lasse Karstensen Date: Wed Jul 9 11:56:20 2014 +0200 Require libjemalloc-dev when building. Fixes: #1537 diff --git a/control b/control index ba45133..81f4f78 100644 --- a/control +++ b/control @@ -13,6 +13,7 @@ Build-Depends: autotools-dev, debhelper (>= 7.0.50~), libedit-dev, + libjemalloc-dev, libncurses-dev, libpcre3-dev, libtool, From phk at FreeBSD.org Wed Jul 9 10:14:46 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 09 Jul 2014 12:14:46 +0200 Subject: [master] e19208d Now that HTTP/2 seems to have confirmed they will not make Content-Length part of the transport protocol (don't even get me started!) we need to lift it out of HTTP/1 space and into the RFC processing. Message-ID: commit e19208d9091dbe453cf4b81bdf6c9e85c85ba513 Author: Poul-Henning Kamp Date: Wed Jul 9 10:13:26 2014 +0000 Now that HTTP/2 seems to have confirmed they will not make Content-Length part of the transport protocol (don't even get me started!) we need to lift it out of HTTP/1 space and into the RFC processing. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index bdc9554..0efc30e 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -490,7 +490,7 @@ struct busyobj { struct pool_task fetch_task; - char *h_content_length; + ssize_t content_length; #define BO_FLAG(l, r, w, d) unsigned l:1; #include "tbl/bo_flags.h" @@ -780,7 +780,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); -ssize_t V1F_Setup_Fetch(struct busyobj *bo); +void V1F_Setup_Fetch(struct busyobj *bo); /* cache_http1_fsm.c [HTTP1] */ typedef int (req_body_iter_f)(struct req *, void *priv, void *ptr, size_t); @@ -883,7 +883,7 @@ struct storage *VFP_GetStorage(struct busyobj *, ssize_t sz); enum vfp_status VFP_Error(struct busyobj *, const char *fmt, ...) __printflike(2, 3); void VFP_Init(void); -void VFP_Fetch_Body(struct busyobj *bo, ssize_t est); +void VFP_Fetch_Body(struct busyobj *bo); void VFP_Push(struct busyobj *, const struct vfp *, intptr_t priv); enum vfp_status VFP_Suck(struct busyobj *, void *p, ssize_t *lp); diff --git a/bin/varnishd/cache/cache_busyobj.c b/bin/varnishd/cache/cache_busyobj.c index 0483579..e49b88e 100644 --- a/bin/varnishd/cache/cache_busyobj.c +++ b/bin/varnishd/cache/cache_busyobj.c @@ -150,6 +150,7 @@ VBO_GetBusyObj(struct worker *wrk, const struct req *req) VTAILQ_INIT(&bo->vfp); bo->t_first = bo->t_prev = NAN; + bo->content_length = -1; return (bo); } diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index b2665e2..64ae86e 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -343,7 +343,7 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo) if (bo->htc.body_status == BS_ERROR) { AN (bo->vbc); VDI_CloseFd(&bo->vbc, &bo->acct); - VSLb(bo->vsl, SLT_VCL_Error, "Body cannot be fetched"); + VSLb(bo->vsl, SLT_Error, "Body cannot be fetched"); return (F_STP_ERROR); } @@ -403,7 +403,6 @@ static enum fetch_step vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) { struct object *obj; - ssize_t est; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); @@ -421,7 +420,6 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) * no Content-Encoding --> object is not gzip'ed. * anything else --> do nothing wrt gzip * - * XXX: BS_NONE/cl==0 should avoid gzip/gunzip */ /* We do nothing unless the param is set */ @@ -444,9 +442,10 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) bo->do_gzip = 0; AN(bo->vbc); - est = V1F_Setup_Fetch(bo); + if (bo->htc.body_status != BS_NONE) + V1F_Setup_Fetch(bo); - if (est == 0) { + if (bo->content_length == 0) { /* * If the length is known to be zero, it's not gziped. * A similar issue exists for chunked encoding but we @@ -529,8 +528,8 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) bo->do_stream ? "stream" : "-"); if (bo->htc.body_status != BS_NONE) { - assert(bo->htc.body_status != BS_ERROR); - VFP_Fetch_Body(bo, est); + assert(bo->htc.body_status != BS_ERROR); + VFP_Fetch_Body(bo); } if (bo->failed && !bo->do_stream) { diff --git a/bin/varnishd/cache/cache_fetch_proc.c b/bin/varnishd/cache/cache_fetch_proc.c index 8a58fe1..a6d6df1 100644 --- a/bin/varnishd/cache/cache_fetch_proc.c +++ b/bin/varnishd/cache/cache_fetch_proc.c @@ -183,16 +183,18 @@ VFP_Suck(struct busyobj *bo, void *p, ssize_t *lp) */ void -VFP_Fetch_Body(struct busyobj *bo, ssize_t est) +VFP_Fetch_Body(struct busyobj *bo) { ssize_t l; enum vfp_status vfps = VFP_ERROR; struct storage *st = NULL; + ssize_t est; CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); AN(bo->vfp_nxt); + est = bo->content_length; if (est < 0) est = 0; diff --git a/bin/varnishd/cache/cache_http1_fetch.c b/bin/varnishd/cache/cache_http1_fetch.c index 22d801a..3a381af 100644 --- a/bin/varnishd/cache/cache_http1_fetch.c +++ b/bin/varnishd/cache/cache_http1_fetch.c @@ -29,7 +29,6 @@ #include "config.h" -#include #include #include #include @@ -43,29 +42,6 @@ #include "vtcp.h" #include "vtim.h" -/*-------------------------------------------------------------------- - * Convert a string to a size_t safely - */ - -static ssize_t -vbf_fetch_number(const char *nbr, int radix) -{ - uintmax_t cll; - ssize_t cl; - char *q; - - if (*nbr == '\0') - return (-1); - cll = strtoumax(nbr, &q, radix); - if (q == NULL || *q != '\0') - return (-1); - - cl = (ssize_t)cll; - if((uintmax_t)cl != cll) /* Protect against bogusly large values */ - return (-1); - return (cl); -} - /*--------------------------------------------------------------------*/ static enum vfp_status __match_proto__(vfp_pull_f) @@ -172,11 +148,10 @@ static const struct vfp v1f_eof = { /*-------------------------------------------------------------------- */ -ssize_t +void V1F_Setup_Fetch(struct busyobj *bo) { struct http_conn *htc; - ssize_t cl; CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); htc = &bo->htc; @@ -185,19 +160,22 @@ V1F_Setup_Fetch(struct busyobj *bo) switch(htc->body_status) { case BS_EOF: + assert(bo->content_length == -1); VFP_Push(bo, &v1f_eof, 0); - return(-1); + break; case BS_LENGTH: - cl = vbf_fetch_number(bo->h_content_length, 10); - VFP_Push(bo, &v1f_straight, cl); - return (cl); + assert(bo->content_length > 0); + VFP_Push(bo, &v1f_straight, bo->content_length); + break; case BS_CHUNKED: + assert(bo->content_length == -1); VFP_Push(bo, &v1f_chunked, -1); - return (-1); + break; default: + WRONG("Wrong body_status"); break; } - return (-1); + return; } /*-------------------------------------------------------------------- diff --git a/bin/varnishd/cache/cache_rfc2616.c b/bin/varnishd/cache/cache_rfc2616.c index 8ada968..7969769 100644 --- a/bin/varnishd/cache/cache_rfc2616.c +++ b/bin/varnishd/cache/cache_rfc2616.c @@ -35,6 +35,7 @@ #include "cache.h" #include "vtim.h" +#include "vct.h" /*-------------------------------------------------------------------- * TTL and Age calculation in Varnish @@ -192,6 +193,7 @@ RFC2616_Body(struct busyobj *bo, struct dstat *stats) { struct http *hp; char *b; + ssize_t cll; hp = bo->beresp; @@ -245,13 +247,42 @@ RFC2616_Body(struct busyobj *bo, struct dstat *stats) } if (http_GetHdr(hp, H_Transfer_Encoding, &b)) { + VSLb(bo->vsl, SLT_Error, "Illegal Transfer-Encoding:"); stats->fetch_bad++; return (BS_ERROR); } - if (http_GetHdr(hp, H_Content_Length, &bo->h_content_length)) { + if (http_GetHdr(hp, H_Content_Length, &b)) { + bo->content_length = 0; + if (!vct_isdigit(*b)) { + VSLb(bo->vsl, SLT_Error, "Empty Content-Length:"); + stats->fetch_bad++; + return (BS_ERROR); + } + for (;vct_isdigit(*b); b++) { + cll = bo->content_length; + bo->content_length *= 10; + bo->content_length += *b - '0'; + if (cll > bo->content_length) { + VSLb(bo->vsl, SLT_Error, + "Content-Length: too large"); + stats->fetch_bad++; + return (BS_ERROR); + } + } + while (vct_islws(*b)) + b++; + if (*b != '\0') { + VSLb(bo->vsl, SLT_Error, + "Illegal Content-Length: (0x%02x)", *b); + stats->fetch_bad++; + return (BS_ERROR); + } stats->fetch_length++; - return (BS_LENGTH); + if (bo->content_length == 0) + return (BS_NONE); + else + return (BS_LENGTH); } if (http_HdrIs(hp, H_Connection, "keep-alive")) { From phk at FreeBSD.org Wed Jul 9 10:25:41 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 09 Jul 2014 12:25:41 +0200 Subject: [master] ac632fd Make it possible to push VFPs both on top and bottom of the stack and put the V1F VFPs after all the gzip/esi etc. have been pushed. Message-ID: commit ac632fdf4553beda4c44333295a9460cac797b11 Author: Poul-Henning Kamp Date: Wed Jul 9 10:24:48 2014 +0000 Make it possible to push VFPs both on top and bottom of the stack and put the V1F VFPs after all the gzip/esi etc. have been pushed. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 0efc30e..ef6423d 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -884,7 +884,6 @@ enum vfp_status VFP_Error(struct busyobj *, const char *fmt, ...) __printflike(2, 3); void VFP_Init(void); void VFP_Fetch_Body(struct busyobj *bo); -void VFP_Push(struct busyobj *, const struct vfp *, intptr_t priv); enum vfp_status VFP_Suck(struct busyobj *, void *p, ssize_t *lp); /* cache_gzip.c */ diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 64ae86e..afab80c 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -442,8 +442,6 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) bo->do_gzip = 0; AN(bo->vbc); - if (bo->htc.body_status != BS_NONE) - V1F_Setup_Fetch(bo); if (bo->content_length == 0) { /* @@ -467,22 +465,22 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) if (bo->do_gunzip || (bo->is_gzip && bo->do_esi)) { RFC2616_Weaken_Etag(bo->beresp); - VFP_Push(bo, &vfp_gunzip, 0); + VFP_Push(bo, &vfp_gunzip, 0, 1); } if (bo->do_esi && bo->do_gzip) { - VFP_Push(bo, &vfp_esi_gzip, 0); + VFP_Push(bo, &vfp_esi_gzip, 0, 1); RFC2616_Weaken_Etag(bo->beresp); } else if (bo->do_esi && bo->is_gzip && !bo->do_gunzip) { - VFP_Push(bo, &vfp_esi_gzip, 0); + VFP_Push(bo, &vfp_esi_gzip, 0, 1); RFC2616_Weaken_Etag(bo->beresp); } else if (bo->do_esi) { - VFP_Push(bo, &vfp_esi, 0); + VFP_Push(bo, &vfp_esi, 0, 1); } else if (bo->do_gzip) { - VFP_Push(bo, &vfp_gzip, 0); + VFP_Push(bo, &vfp_gzip, 0, 1); RFC2616_Weaken_Etag(bo->beresp); } else if (bo->is_gzip && !bo->do_gunzip) { - VFP_Push(bo, &vfp_testgunzip, 0); + VFP_Push(bo, &vfp_testgunzip, 0, 1); } if (bo->fetch_objcore->flags & OC_F_PRIVATE) @@ -508,6 +506,9 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) if (bo->do_gzip || bo->do_gunzip) obj->changed_gzip = 1; + if (bo->htc.body_status != BS_NONE) + V1F_Setup_Fetch(bo); + /* * Ready to fetch the body */ diff --git a/bin/varnishd/cache/cache_fetch_proc.c b/bin/varnishd/cache/cache_fetch_proc.c index a6d6df1..7b95617 100644 --- a/bin/varnishd/cache/cache_fetch_proc.c +++ b/bin/varnishd/cache/cache_fetch_proc.c @@ -255,7 +255,7 @@ VFP_Fetch_Body(struct busyobj *bo) } void -VFP_Push(struct busyobj *bo, const struct vfp *vfp, intptr_t priv) +VFP_Push(struct busyobj *bo, const struct vfp *vfp, intptr_t priv, int top) { struct vfp_entry *vfe; @@ -266,8 +266,12 @@ VFP_Push(struct busyobj *bo, const struct vfp *vfp, intptr_t priv) vfe->vfp = vfp; vfe->priv2 = priv; vfe->closed = VFP_OK; - VTAILQ_INSERT_HEAD(&bo->vfp, vfe, list); - bo->vfp_nxt = vfe; + if (top) + VTAILQ_INSERT_HEAD(&bo->vfp, vfe, list); + else + VTAILQ_INSERT_TAIL(&bo->vfp, vfe, list); + if (VTAILQ_FIRST(&bo->vfp) == vfe) + bo->vfp_nxt = vfe; } /*-------------------------------------------------------------------- diff --git a/bin/varnishd/cache/cache_filter.h b/bin/varnishd/cache/cache_filter.h index a5716a4..933d2e7 100644 --- a/bin/varnishd/cache/cache_filter.h +++ b/bin/varnishd/cache/cache_filter.h @@ -59,6 +59,8 @@ extern const struct vfp vfp_testgunzip; extern const struct vfp vfp_esi; extern const struct vfp vfp_esi_gzip; +void VFP_Push(struct busyobj *, const struct vfp *, intptr_t priv, int top); + /* Deliver processors ------------------------------------------------*/ diff --git a/bin/varnishd/cache/cache_http1_fetch.c b/bin/varnishd/cache/cache_http1_fetch.c index 3a381af..47b5029 100644 --- a/bin/varnishd/cache/cache_http1_fetch.c +++ b/bin/varnishd/cache/cache_http1_fetch.c @@ -161,15 +161,15 @@ V1F_Setup_Fetch(struct busyobj *bo) switch(htc->body_status) { case BS_EOF: assert(bo->content_length == -1); - VFP_Push(bo, &v1f_eof, 0); + VFP_Push(bo, &v1f_eof, 0, 0); break; case BS_LENGTH: assert(bo->content_length > 0); - VFP_Push(bo, &v1f_straight, bo->content_length); + VFP_Push(bo, &v1f_straight, bo->content_length, 0); break; case BS_CHUNKED: assert(bo->content_length == -1); - VFP_Push(bo, &v1f_chunked, -1); + VFP_Push(bo, &v1f_chunked, -1, 0); break; default: WRONG("Wrong body_status"); From lkarsten at varnish-software.com Wed Jul 9 11:03:08 2014 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Wed, 09 Jul 2014 13:03:08 +0200 Subject: [master] 177a2ee Sort the list of build requirements. Message-ID: commit 177a2eeb4e4c4be68072604490273da387462004 Author: Lasse Karstensen Date: Wed Jul 9 12:54:21 2014 +0200 Sort the list of build requirements. diff --git a/redhat/varnish.spec b/redhat/varnish.spec index 1c5e739..1926cce 100644 --- a/redhat/varnish.spec +++ b/redhat/varnish.spec @@ -14,21 +14,21 @@ URL: http://www.varnish-cache.org/ 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 -#BuildRequires: automake autoconf libtool +BuildRequires: automake +BuildRequires: autoconf +BuildRequires: jemalloc-devel +BuildRequires: libedit-devel +BuildRequires: libtool BuildRequires: ncurses-devel BuildRequires: pcre-devel BuildRequires: pkgconfig -BuildRequires: libedit-devel -BuildRequires: jemalloc-devel BuildRequires: python-docutils >= 0.6 -Requires: varnish-libs = %{version}-%{release} +Requires: jemalloc +Requires: libedit Requires: logrotate Requires: ncurses Requires: pcre -Requires: libedit -Requires: jemalloc +Requires: varnish-libs = %{version}-%{release} Requires(pre): shadow-utils Requires(post): /sbin/chkconfig, /usr/bin/uuidgen Requires(preun): /sbin/chkconfig From lkarsten at varnish-software.com Wed Jul 9 11:03:08 2014 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Wed, 09 Jul 2014 13:03:08 +0200 Subject: [master] 381ec8a Update list of documented build requirements. Message-ID: commit 381ec8adbc8d692e192cc63c79b3c3192c590356 Author: Lasse Karstensen Date: Wed Jul 9 12:59:37 2014 +0200 Update list of documented build requirements. The list of documented build requirement have not been updated for a while, and was outdated. Update the lists with recent data. Added (commented-out) commands that extracts and formats this information directly from the packaging files. Reported by: frakt diff --git a/doc/sphinx/installation/install.rst b/doc/sphinx/installation/install.rst index 883cbf9..c9dd0c5 100644 --- a/doc/sphinx/installation/install.rst +++ b/doc/sphinx/installation/install.rst @@ -76,21 +76,21 @@ Build dependencies on Debian / Ubuntu In order to build Varnish from source you need a number of packages installed. On a Debian or Ubuntu system these are: -* `autoconf` -* `automake1.1` +.. grep-dctrl -n -sBuild-Depends -r ^ ../../../../varnish-cache-debian/control | tr -d '\n' | awk -F,\ '{ for (i = 0; ++i <= NF;) { sub (/ .*/, "", $i); print "* `" $i "`"; }}' + +* `automake` * `autotools-dev` -* `groff-base` -* `make` +* `debhelper` * `libedit-dev` +* `libjemalloc-dev` * `libncurses-dev` * `libpcre3-dev` +* `libreadline-dev` * `libtool` * `pkg-config` * `python-docutils` +* `python-sphinx` -If you're building from git, you also need the following: - -* `python-sphinx` (optional, if you want to build the documentation) Build dependencies on Red Hat / CentOS -------------------------------------- @@ -98,19 +98,19 @@ Build dependencies on Red Hat / CentOS To build Varnish on a Red Hat or CentOS system you need the following packages installed: -* `automake` +.. gawk '/^BuildRequires/ {print "* `" $2 "`"}' ../../../redhat/varnish.spec | sort | uniq + * `autoconf` -* `groff` +* `automake` +* `jemalloc-devel` * `libedit-devel` * `libtool` * `ncurses-devel` * `pcre-devel` * `pkgconfig` * `python-docutils` +* `systemd-units` -If you're building from git, you also need the following: - -* `python-sphinx` (optional, if you want to build the documentation) Compiling Varnish ----------------- From phk at FreeBSD.org Wed Jul 9 11:56:22 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 09 Jul 2014 13:56:22 +0200 Subject: [master] c580ff5 Make this less magical and more readable. Message-ID: commit c580ff5ebb8233125257cd138ddb7d5dcaf8d7a8 Author: Poul-Henning Kamp Date: Wed Jul 9 11:47:14 2014 +0000 Make this less magical and more readable. diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c index f189785..526e91d 100644 --- a/bin/varnishd/cache/cache_gzip.c +++ b/bin/varnishd/cache/cache_gzip.c @@ -446,6 +446,10 @@ VGZ_Destroy(struct vgz **vgp) /*--------------------------------------------------------------------*/ +#define VFP_GUNZIP 0 +#define VFP_GZIP 1 +#define VFP_TESTGUNZIP 2 + static enum vfp_status __match_proto__(vfp_init_f) vfp_gzip_init(struct busyobj *bo, struct vfp_entry *vfe) { @@ -454,7 +458,7 @@ vfp_gzip_init(struct busyobj *bo, struct vfp_entry *vfe) CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC); - if (vfe->vfp->priv2) + if (vfe->vfp->priv2 == VFP_GZIP) vg = VGZ_NewGzip(bo->vsl, vfe->vfp->priv1); else vg = VGZ_NewUngzip(bo->vsl, vfe->vfp->priv1); @@ -647,6 +651,7 @@ const struct vfp vfp_gunzip = { .pull = vfp_gunzip_pull, .fini = vfp_gzip_fini, .priv1 = "U F -", + .priv2 = VFP_GUNZIP, }; const struct vfp vfp_gzip = { @@ -655,7 +660,7 @@ const struct vfp vfp_gzip = { .pull = vfp_gzip_pull, .fini = vfp_gzip_fini, .priv1 = "G F -", - .priv2 = 1, + .priv2 = VFP_GZIP, }; const struct vfp vfp_testgunzip = { @@ -664,4 +669,5 @@ const struct vfp vfp_testgunzip = { .pull = vfp_testgunzip_pull, .fini = vfp_gzip_fini, .priv1 = "u F -", + .priv2 = VFP_TESTGUNZIP, }; From phk at FreeBSD.org Wed Jul 9 12:26:24 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 09 Jul 2014 14:26:24 +0200 Subject: [master] 62bdefe Introduce VFP_NULL as a possible return from vfp->init() to mean "ignore me". Message-ID: commit 62bdefe0887ad1d32c26904a4fa2980f55599801 Author: Poul-Henning Kamp Date: Wed Jul 9 12:25:27 2014 +0000 Introduce VFP_NULL as a possible return from vfp->init() to mean "ignore me". diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index afab80c..7824e26 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -443,17 +443,6 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) AN(bo->vbc); - if (bo->content_length == 0) { - /* - * If the length is known to be zero, it's not gziped. - * A similar issue exists for chunked encoding but we - * don't handle that. See #1320. - */ - http_Unset(bo->beresp, H_Content_Encoding); - bo->is_gzip = 0; - bo->is_gunzip = 1; - } - /* But we can't do both at the same time */ assert(bo->do_gzip == 0 || bo->do_gunzip == 0); diff --git a/bin/varnishd/cache/cache_fetch_proc.c b/bin/varnishd/cache/cache_fetch_proc.c index 7b95617..72f2a81 100644 --- a/bin/varnishd/cache/cache_fetch_proc.c +++ b/bin/varnishd/cache/cache_fetch_proc.c @@ -113,32 +113,29 @@ vfp_suck_fini(struct busyobj *bo) { struct vfp_entry *vfe; - VTAILQ_FOREACH(vfe, &bo->vfp, list) { + VTAILQ_FOREACH(vfe, &bo->vfp, list) if(vfe->closed == VFP_OK && vfe->vfp->fini != NULL) vfe->vfp->fini(bo, vfe); - } } static enum vfp_status vfp_suck_init(struct busyobj *bo) { - enum vfp_status retval = VFP_OK; struct vfp_entry *vfe; VTAILQ_FOREACH(vfe, &bo->vfp, list) { if (vfe->vfp->init == NULL) continue; - retval = vfe->vfp->init(bo, vfe); - if (retval != VFP_OK) { + vfe->closed = vfe->vfp->init(bo, vfe); + if (vfe->closed != VFP_OK && vfe->closed != VFP_NULL) { (void)VFP_Error(bo, "Fetch filter %s failed to initialize", vfe->vfp->name); vfp_suck_fini(bo); - vfe->closed = retval; - return (retval); + return (vfe->closed); } } - return (retval); + return (VFP_OK); } /********************************************************************** @@ -160,16 +157,17 @@ VFP_Suck(struct busyobj *bo, void *p, ssize_t *lp) CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC); bo->vfp_nxt = VTAILQ_NEXT(vfe, list); - if (vfe->closed == VFP_OK) { + if (vfe->closed == VFP_NULL) { + vp = VFP_Suck(bo, p, lp); + } else if (vfe->closed == VFP_OK) { vp = vfe->vfp->pull(bo, vfe, p, lp); - if (vp == VFP_ERROR) - (void)VFP_Error(bo, "Fetch filter %s returned %d", - vfe->vfp->name, vp); - if (vp != VFP_OK) { + if (vp == VFP_END || vp == VFP_ERROR) { if (vfe->vfp->fini != NULL) vfe->vfp->fini(bo, vfe); vfe->closed = vp; - } + } else if (vp != VFP_OK) + (void)VFP_Error(bo, "Fetch filter %s returned %d", + vfe->vfp->name, vp); } else { /* Already closed filter */ *lp = 0; diff --git a/bin/varnishd/cache/cache_filter.h b/bin/varnishd/cache/cache_filter.h index 933d2e7..8fae76a 100644 --- a/bin/varnishd/cache/cache_filter.h +++ b/bin/varnishd/cache/cache_filter.h @@ -37,6 +37,7 @@ enum vfp_status { VFP_ERROR = -1, VFP_OK = 0, VFP_END = 1, + VFP_NULL = 2, }; typedef enum vfp_status vfp_init_f(struct busyobj *, struct vfp_entry *); diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c index 526e91d..d020bc0 100644 --- a/bin/varnishd/cache/cache_gzip.c +++ b/bin/varnishd/cache/cache_gzip.c @@ -458,6 +458,9 @@ vfp_gzip_init(struct busyobj *bo, struct vfp_entry *vfe) CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC); + if (bo->content_length == 0) + return (VFP_NULL); + if (vfe->vfp->priv2 == VFP_GZIP) vg = VGZ_NewGzip(bo->vsl, vfe->vfp->priv1); else From lkarsten at varnish-software.com Wed Jul 9 12:59:07 2014 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Wed, 09 Jul 2014 14:59:07 +0200 Subject: [master] 210093c Filter the list and add forgotten python-sphinx. Message-ID: commit 210093c60d17b37cea5e0c3b0b5f627526e81985 Author: Lasse Karstensen Date: Wed Jul 9 14:56:07 2014 +0200 Filter the list and add forgotten python-sphinx. We only need debhelper when building the debian packages, and the systemd-units is within a conditional that awk ignores. Updated the commands to not include these in the future, and also the Redhat spec file so it should work on a fresh installation. Noticed by: fgs diff --git a/doc/sphinx/installation/install.rst b/doc/sphinx/installation/install.rst index c9dd0c5..d93e2b5 100644 --- a/doc/sphinx/installation/install.rst +++ b/doc/sphinx/installation/install.rst @@ -76,11 +76,10 @@ Build dependencies on Debian / Ubuntu In order to build Varnish from source you need a number of packages installed. On a Debian or Ubuntu system these are: -.. grep-dctrl -n -sBuild-Depends -r ^ ../../../../varnish-cache-debian/control | tr -d '\n' | awk -F,\ '{ for (i = 0; ++i <= NF;) { sub (/ .*/, "", $i); print "* `" $i "`"; }}' +.. grep-dctrl -n -sBuild-Depends -r ^ ../../../../varnish-cache-debian/control | tr -d '\n' | awk -F,\ '{ for (i = 0; ++i <= NF;) { sub (/ .*/, "", $i); print "* `" $i "`"; }}' | egrep -v '(debhelper)' * `automake` * `autotools-dev` -* `debhelper` * `libedit-dev` * `libjemalloc-dev` * `libncurses-dev` @@ -98,7 +97,7 @@ Build dependencies on Red Hat / CentOS To build Varnish on a Red Hat or CentOS system you need the following packages installed: -.. gawk '/^BuildRequires/ {print "* `" $2 "`"}' ../../../redhat/varnish.spec | sort | uniq +.. gawk '/^BuildRequires/ {print "* `" $2 "`"}' ../../../redhat/varnish.spec | sort | uniq | egrep -v '(systemd)' * `autoconf` * `automake` @@ -109,7 +108,7 @@ packages installed: * `pcre-devel` * `pkgconfig` * `python-docutils` -* `systemd-units` +* `python-sphinx` Compiling Varnish diff --git a/redhat/varnish.spec b/redhat/varnish.spec index 1926cce..de0208e 100644 --- a/redhat/varnish.spec +++ b/redhat/varnish.spec @@ -23,6 +23,7 @@ BuildRequires: ncurses-devel BuildRequires: pcre-devel BuildRequires: pkgconfig BuildRequires: python-docutils >= 0.6 +BuildRequires: python-sphinx Requires: jemalloc Requires: libedit Requires: logrotate From lkarsten at varnish-software.com Wed Jul 9 13:20:23 2014 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Wed, 09 Jul 2014 15:20:23 +0200 Subject: [master] 5ad5762 Readline does not belong on this list. Message-ID: commit 5ad57621cb7dc51134146d7157d16b33ac85ae9a Author: Lasse Karstensen Date: Wed Jul 9 15:12:29 2014 +0200 Readline does not belong on this list. This reflects the debian build files, editline will suffice. diff --git a/doc/sphinx/installation/install.rst b/doc/sphinx/installation/install.rst index d93e2b5..bbae1e6 100644 --- a/doc/sphinx/installation/install.rst +++ b/doc/sphinx/installation/install.rst @@ -84,7 +84,6 @@ installed. On a Debian or Ubuntu system these are: * `libjemalloc-dev` * `libncurses-dev` * `libpcre3-dev` -* `libreadline-dev` * `libtool` * `pkg-config` * `python-docutils` From phk at FreeBSD.org Wed Jul 9 13:58:26 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 09 Jul 2014 15:58:26 +0200 Subject: [master] e5813c0 Open the VFP pipe before we start streaming, and change the open order to bottom up, so that header modifications happen in the sensible order. Message-ID: commit e5813c05866224815ec23431eb5cf29ef7533360 Author: Poul-Henning Kamp Date: Wed Jul 9 13:56:48 2014 +0000 Open the VFP pipe before we start streaming, and change the open order to bottom up, so that header modifications happen in the sensible order. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index ef6423d..dc781b6 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -454,6 +454,8 @@ struct vfp_entry { VTAILQ_ENTRY(vfp_entry) list; }; +VTAILQ_HEAD(vfp_entry_s, vfp_entry); + struct busyobj { unsigned magic; #define BUSYOBJ_MAGIC 0x23b95567 @@ -471,7 +473,7 @@ struct busyobj { uint8_t *vary; - VTAILQ_HEAD(,vfp_entry) vfp; + struct vfp_entry_s vfp; struct vfp_entry *vfp_nxt; int failed; diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 7824e26..22cfac6 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -481,7 +481,7 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) if (vbf_beresp2obj(bo)) { (void)VFP_Error(bo, "Could not get storage"); - VDI_CloseFd(&bo->vbc, &bo->acct); + bo->should_close = 1; return (F_STP_ERROR); } @@ -508,6 +508,12 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) assert (bo->state == BOS_REQ_DONE); + if (VFP_Open(bo)) { + (void)VFP_Error(bo, "Fetch Pipeline failed to open"); + bo->should_close = 1; + return (F_STP_ERROR); + } + if (bo->do_stream) { HSH_Unbusy(&wrk->stats, obj->objcore); VBO_setstate(bo, BOS_STREAM); diff --git a/bin/varnishd/cache/cache_fetch_proc.c b/bin/varnishd/cache/cache_fetch_proc.c index 72f2a81..a60269a 100644 --- a/bin/varnishd/cache/cache_fetch_proc.c +++ b/bin/varnishd/cache/cache_fetch_proc.c @@ -118,24 +118,24 @@ vfp_suck_fini(struct busyobj *bo) vfe->vfp->fini(bo, vfe); } -static enum vfp_status -vfp_suck_init(struct busyobj *bo) +int +VFP_Open(struct busyobj *bo) { struct vfp_entry *vfe; - VTAILQ_FOREACH(vfe, &bo->vfp, list) { + VTAILQ_FOREACH_REVERSE(vfe, &bo->vfp, vfp_entry_s, list) { if (vfe->vfp->init == NULL) continue; vfe->closed = vfe->vfp->init(bo, vfe); if (vfe->closed != VFP_OK && vfe->closed != VFP_NULL) { (void)VFP_Error(bo, - "Fetch filter %s failed to initialize", + "Fetch filter %s failed to open", vfe->vfp->name); vfp_suck_fini(bo); - return (vfe->closed); + return (-1); } } - return (VFP_OK); + return (0); } /********************************************************************** @@ -196,12 +196,6 @@ VFP_Fetch_Body(struct busyobj *bo) if (est < 0) est = 0; - if (vfp_suck_init(bo) != VFP_OK) { - (void)VFP_Error(bo, "Fetch Pipeline failed to initialize"); - bo->should_close = 1; - return; - } - do { if (bo->abandon) { /* diff --git a/bin/varnishd/cache/cache_filter.h b/bin/varnishd/cache/cache_filter.h index 8fae76a..fdded29 100644 --- a/bin/varnishd/cache/cache_filter.h +++ b/bin/varnishd/cache/cache_filter.h @@ -61,6 +61,7 @@ extern const struct vfp vfp_esi; extern const struct vfp vfp_esi_gzip; void VFP_Push(struct busyobj *, const struct vfp *, intptr_t priv, int top); +int VFP_Open(struct busyobj *bo); /* Deliver processors ------------------------------------------------*/ From phk at FreeBSD.org Wed Jul 9 15:57:28 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 09 Jul 2014 17:57:28 +0200 Subject: [master] 920e1d3 Don't call any VFP->fini until we call all VFP->fini, and always call it, no matter what. Message-ID: commit 920e1d3626884509fd7d0b5744328e5a7f696444 Author: Poul-Henning Kamp Date: Wed Jul 9 15:56:39 2014 +0000 Don't call any VFP->fini until we call all VFP->fini, and always call it, no matter what. diff --git a/bin/varnishd/cache/cache_fetch_proc.c b/bin/varnishd/cache/cache_fetch_proc.c index a60269a..35d4bc2 100644 --- a/bin/varnishd/cache/cache_fetch_proc.c +++ b/bin/varnishd/cache/cache_fetch_proc.c @@ -114,7 +114,7 @@ vfp_suck_fini(struct busyobj *bo) struct vfp_entry *vfe; VTAILQ_FOREACH(vfe, &bo->vfp, list) - if(vfe->closed == VFP_OK && vfe->vfp->fini != NULL) + if(vfe->vfp->fini != NULL) vfe->vfp->fini(bo, vfe); } @@ -162,8 +162,6 @@ VFP_Suck(struct busyobj *bo, void *p, ssize_t *lp) } else if (vfe->closed == VFP_OK) { vp = vfe->vfp->pull(bo, vfe, p, lp); if (vp == VFP_END || vp == VFP_ERROR) { - if (vfe->vfp->fini != NULL) - vfe->vfp->fini(bo, vfe); vfe->closed = vp; } else if (vp != VFP_OK) (void)VFP_Error(bo, "Fetch filter %s returned %d", From phk at FreeBSD.org Wed Jul 9 16:12:35 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 09 Jul 2014 18:12:35 +0200 Subject: [master] c4298f9 Make sure to not leak memory, even when we're out of it. Message-ID: commit c4298f9fc20deb6ef7254f70044e478bf9fd40de Author: Poul-Henning Kamp Date: Wed Jul 9 16:12:14 2014 +0000 Make sure to not leak memory, even when we're out of it. diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c index d020bc0..c0f2859 100644 --- a/bin/varnishd/cache/cache_gzip.c +++ b/bin/varnishd/cache/cache_gzip.c @@ -467,9 +467,9 @@ vfp_gzip_init(struct busyobj *bo, struct vfp_entry *vfe) vg = VGZ_NewUngzip(bo->vsl, vfe->vfp->priv1); if (vg == NULL) return (VFP_ERROR); + vfe->priv1 = vg; if (vgz_getmbuf(vg)) return (VFP_ERROR); - vfe->priv1 = vg; VGZ_Ibuf(vg, vg->m_buf, 0); AZ(vg->m_len); return (VFP_OK); From phk at FreeBSD.org Wed Jul 9 17:58:23 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 09 Jul 2014 19:58:23 +0200 Subject: [master] 780e52f Don't emit output duing init/open Message-ID: commit 780e52f312f8a2c5759ab545c8f6adcd934e5b6e Author: Poul-Henning Kamp Date: Wed Jul 9 17:57:51 2014 +0000 Don't emit output duing init/open diff --git a/bin/varnishd/cache/cache_esi_parse.c b/bin/varnishd/cache/cache_esi_parse.c index 66d3420..e17ac52 100644 --- a/bin/varnishd/cache/cache_esi_parse.c +++ b/bin/varnishd/cache/cache_esi_parse.c @@ -578,9 +578,20 @@ VEP_Parse(struct vep_state *vep, const struct busyobj *bo, const char *p, CHECK_OBJ_NOTNULL(vep, VEP_MAGIC); assert(l > 0); - /* XXX: Really need to fix this */ - if (vep->hack_p == NULL) + if (vep->startup) { + /* + * We must force the GZIP header out as a SKIP string, + * otherwise an object starting with ver_p = ""; + vep->last_mark = SKIP; + vep_mark_common(vep, vep->ver_p, VERBATIM); + vep->startup = 0; + AZ(vep->hack_p); vep->hack_p = p; + } vep->ver_p = p; @@ -1059,16 +1070,7 @@ VEP_Init(struct busyobj *bo, vep_callback_t *cb, void *cb_priv) vep->crc = crc32(0L, Z_NULL, 0); vep->crcp = crc32(0L, Z_NULL, 0); - /* - * We must force the GZIP header out as a SKIP string, otherwise - * an object starting with startup = 1; - vep->ver_p = ""; - vep->last_mark = SKIP; - vep_mark_common(vep, vep->ver_p, VERBATIM); - vep->startup = 0; return (vep); } From phk at FreeBSD.org Wed Jul 9 17:58:23 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 09 Jul 2014 19:58:23 +0200 Subject: [master] 8fb7bf0 Run VFP open before beresp->obj copy Message-ID: commit 8fb7bf02f247b5d5d7f518e113f3b6ed2d1cbd09 Author: Poul-Henning Kamp Date: Wed Jul 9 17:58:06 2014 +0000 Run VFP open before beresp->obj copy diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 22cfac6..b31e2e2 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -479,6 +479,12 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) if (bo->htc.body_status == BS_NONE) bo->do_stream = 0; + if (VFP_Open(bo)) { + (void)VFP_Error(bo, "Fetch Pipeline failed to open"); + bo->should_close = 1; + return (F_STP_ERROR); + } + if (vbf_beresp2obj(bo)) { (void)VFP_Error(bo, "Could not get storage"); bo->should_close = 1; @@ -508,12 +514,6 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) assert (bo->state == BOS_REQ_DONE); - if (VFP_Open(bo)) { - (void)VFP_Error(bo, "Fetch Pipeline failed to open"); - bo->should_close = 1; - return (F_STP_ERROR); - } - if (bo->do_stream) { HSH_Unbusy(&wrk->stats, obj->objcore); VBO_setstate(bo, BOS_STREAM); From phk at FreeBSD.org Wed Jul 9 18:53:30 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 09 Jul 2014 20:53:30 +0200 Subject: [master] e0e89a6 Move the header-munging to the VFP's that require it. Message-ID: commit e0e89a69d93ed004174318f37a5bda960a9d3ebd Author: Poul-Henning Kamp Date: Wed Jul 9 18:52:58 2014 +0000 Move the header-munging to the VFP's that require it. diff --git a/bin/varnishd/cache/cache_esi_fetch.c b/bin/varnishd/cache/cache_esi_fetch.c index ba8c065..3601cf8 100644 --- a/bin/varnishd/cache/cache_esi_fetch.c +++ b/bin/varnishd/cache/cache_esi_fetch.c @@ -157,10 +157,15 @@ vfp_esi_gzip_init(struct busyobj *bo, struct vfp_entry *vfe) vef->ibuf = calloc(1L, vef->ibuf_sz); if (vef->ibuf == NULL) return (vfp_esi_end(bo, vef, VFP_ERROR)); - XXXAN(vef->ibuf); vef->ibuf_i = vef->ibuf; vef->ibuf_o = vef->ibuf; vfe->priv1 = vef; + + RFC2616_Weaken_Etag(bo->beresp); + http_Unset(bo->beresp, H_Content_Length); + http_Unset(bo->beresp, H_Content_Encoding); + http_SetHeader(bo->beresp, "Content-Encoding: gzip"); + return (VFP_OK); } diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index b31e2e2..cf1da26 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -446,28 +446,17 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) /* But we can't do both at the same time */ assert(bo->do_gzip == 0 || bo->do_gunzip == 0); - /* Fix Content-Encoding, as appropriate */ - if (bo->do_gzip) - http_SetHeader(bo->beresp, "Content-Encoding: gzip"); - else if (bo->do_gunzip) - http_Unset(bo->beresp, H_Content_Encoding); - - if (bo->do_gunzip || (bo->is_gzip && bo->do_esi)) { - RFC2616_Weaken_Etag(bo->beresp); + if (bo->do_gunzip || (bo->is_gzip && bo->do_esi)) VFP_Push(bo, &vfp_gunzip, 0, 1); - } if (bo->do_esi && bo->do_gzip) { VFP_Push(bo, &vfp_esi_gzip, 0, 1); - RFC2616_Weaken_Etag(bo->beresp); } else if (bo->do_esi && bo->is_gzip && !bo->do_gunzip) { VFP_Push(bo, &vfp_esi_gzip, 0, 1); - RFC2616_Weaken_Etag(bo->beresp); } else if (bo->do_esi) { VFP_Push(bo, &vfp_esi, 0, 1); } else if (bo->do_gzip) { VFP_Push(bo, &vfp_gzip, 0, 1); - RFC2616_Weaken_Etag(bo->beresp); } else if (bo->is_gzip && !bo->do_gunzip) { VFP_Push(bo, &vfp_testgunzip, 0, 1); } diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c index c0f2859..e684089 100644 --- a/bin/varnishd/cache/cache_gzip.c +++ b/bin/varnishd/cache/cache_gzip.c @@ -458,13 +458,20 @@ vfp_gzip_init(struct busyobj *bo, struct vfp_entry *vfe) CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC); - if (bo->content_length == 0) + if (bo->content_length == 0) { + http_Unset(bo->beresp, H_Content_Encoding); return (VFP_NULL); + } - if (vfe->vfp->priv2 == VFP_GZIP) + if (vfe->vfp->priv2 == VFP_GZIP) { + if (http_GetHdr(bo->beresp, H_Content_Encoding, NULL)) + return (VFP_NULL); vg = VGZ_NewGzip(bo->vsl, vfe->vfp->priv1); - else + } else { + if (!http_HdrIs(bo->beresp, H_Content_Encoding, "gzip")) + return (VFP_NULL); vg = VGZ_NewUngzip(bo->vsl, vfe->vfp->priv1); + } if (vg == NULL) return (VFP_ERROR); vfe->priv1 = vg; @@ -472,6 +479,16 @@ vfp_gzip_init(struct busyobj *bo, struct vfp_entry *vfe) return (VFP_ERROR); VGZ_Ibuf(vg, vg->m_buf, 0); AZ(vg->m_len); + + if (vfe->vfp->priv2 == VFP_GUNZIP || vfe->vfp->priv2 == VFP_GZIP) { + http_Unset(bo->beresp, H_Content_Encoding); + http_Unset(bo->beresp, H_Content_Length); + RFC2616_Weaken_Etag(bo->beresp); + } + + if (vfe->vfp->priv2 == VFP_GZIP) + http_SetHeader(bo->beresp, "Content-Encoding: gzip"); + return (VFP_OK); } From phk at FreeBSD.org Mon Jul 14 11:19:32 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 14 Jul 2014 13:19:32 +0200 Subject: [master] 4339ecb The HTTP/2 draft -13 seems pretty final with respect to the Connection: header being a HTTP/1.x thing only. Message-ID: commit 4339ecb8b1f3d6ac65fc462996cca72f4f193f86 Author: Poul-Henning Kamp Date: Mon Jul 14 11:16:35 2014 +0000 The HTTP/2 draft -13 seems pretty final with respect to the Connection: header being a HTTP/1.x thing only. Move the handling accordingly diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index dc781b6..e7b4ad6 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -946,9 +946,10 @@ void http_SetStatus(struct http *to, uint16_t status); const char *http_GetReq(const struct http *hp); int http_HdrIs(const struct http *hp, const char *hdr, const char *val); int http_IsHdr(const txt *hh, const char *hdr); -enum sess_close http_DoConnection(const struct http *); void http_CopyHome(const struct http *hp); void http_Unset(struct http *hp, const char *hdr); +void http_MarkHeader(const struct http *, const char *hdr, unsigned hdrlen, + uint8_t flag); void http_CollectHdr(struct http *hp, const char *hdr); void http_VSL_log(const struct http *hp); void http_Merge(const struct http *fm, struct http *to, int not_ce); @@ -971,6 +972,7 @@ ssize_t HTTP1_Read(struct http_conn *htc, void *d, size_t len); enum htc_status_e HTTP1_Complete(struct http_conn *htc); uint16_t HTTP1_DissectRequest(struct req *); uint16_t HTTP1_DissectResponse(struct http *sp, const struct http_conn *htc); +enum sess_close HTTP1_DoConnection(const struct http *); unsigned HTTP1_Write(const struct worker *w, const struct http *hp, const int*); #define HTTPH(a, b, c) extern char b[]; diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c index ec1afae..f7d9477 100644 --- a/bin/varnishd/cache/cache_http.c +++ b/bin/varnishd/cache/cache_http.c @@ -264,6 +264,23 @@ http_findhdr(const struct http *hp, unsigned l, const char *hdr) } /*-------------------------------------------------------------------- + */ + +void +http_MarkHeader(const struct http *hp, const char *hdr, unsigned hdrlen, + uint8_t flag) +{ + unsigned u; + + CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC); + + u = http_findhdr(hp, hdrlen, hdr); + if (u == 0) + return; + hp->hdf[u] |= flag; +} + +/*-------------------------------------------------------------------- * This function collapses multiple headerlines of the same name. * The lines are joined with a comma, according to [rfc2616, 4.2bot, p32] */ @@ -489,45 +506,6 @@ http_GetHdrField(const struct http *hp, const char *hdr, return (i); } -/*-------------------------------------------------------------------- - * XXX: redo with http_GetHdrField() ? - */ - -enum sess_close -http_DoConnection(const struct http *hp) -{ - char *p, *q; - enum sess_close ret; - unsigned u; - - if (!http_GetHdr(hp, H_Connection, &p)) { - if (hp->protover < 11) - return (SC_REQ_HTTP10); - return (SC_NULL); - } - ret = SC_NULL; - AN(p); - for (; *p; p++) { - if (vct_issp(*p)) - continue; - if (*p == ',') - continue; - for (q = p + 1; *q; q++) - if (*q == ',' || vct_issp(*q)) - break; - u = pdiff(p, q); - if (u == 5 && !strncasecmp(p, "close", u)) - ret = SC_REQ_CLOSE; - u = http_findhdr(hp, u, p); - if (u != 0) - hp->hdf[u] |= HDF_FILTER; - if (!*q) - break; - p = q; - } - return (ret); -} - /*--------------------------------------------------------------------*/ int diff --git a/bin/varnishd/cache/cache_http1_fsm.c b/bin/varnishd/cache/cache_http1_fsm.c index 454ec28..8475511 100644 --- a/bin/varnishd/cache/cache_http1_fsm.c +++ b/bin/varnishd/cache/cache_http1_fsm.c @@ -380,7 +380,7 @@ http1_dissect(struct worker *wrk, struct req *req) AZ(req->err_code); req->ws_req = WS_Snapshot(req->ws); - req->doclose = http_DoConnection(req->http); + req->doclose = HTTP1_DoConnection(req->http); http_Unset(req->http, H_Expect); diff --git a/bin/varnishd/cache/cache_http1_proto.c b/bin/varnishd/cache/cache_http1_proto.c index f0a1abc..99564b3 100644 --- a/bin/varnishd/cache/cache_http1_proto.c +++ b/bin/varnishd/cache/cache_http1_proto.c @@ -411,8 +411,6 @@ htc_proto_ver(struct http *hp) /*--------------------------------------------------------------------*/ -#include - uint16_t HTTP1_DissectRequest(struct req *req) { @@ -506,6 +504,42 @@ HTTP1_DissectResponse(struct http *hp, const struct http_conn *htc) return (retval); } +/*-------------------------------------------------------------------- + */ + +enum sess_close +HTTP1_DoConnection(const struct http *hp) +{ + char *p, *q; + enum sess_close ret; + unsigned u; + + if (!http_GetHdr(hp, H_Connection, &p)) { + if (hp->protover < 11) + return (SC_REQ_HTTP10); + return (SC_NULL); + } + ret = SC_NULL; + AN(p); + for (; *p; p++) { + if (vct_issp(*p)) + continue; + if (*p == ',') + continue; + for (q = p + 1; *q; q++) + if (*q == ',' || vct_issp(*q)) + break; + u = pdiff(p, q); + if (u == 5 && !strncasecmp(p, "close", u)) + ret = SC_REQ_CLOSE; + http_MarkHeader(hp, p, u, HDF_FILTER); + if (!*q) + break; + p = q; + } + return (ret); +} + /*--------------------------------------------------------------------*/ unsigned From phk at FreeBSD.org Mon Jul 14 11:25:00 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 14 Jul 2014 13:25:00 +0200 Subject: [master] c5fa269 Be pendatically correct and Collect multiple Connection headers. Message-ID: commit c5fa269a69cf2c72cee7b3a274b6138afd2f6b50 Author: Poul-Henning Kamp Date: Mon Jul 14 11:24:44 2014 +0000 Be pendatically correct and Collect multiple Connection headers. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index e7b4ad6..e1b37a4 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -972,7 +972,7 @@ ssize_t HTTP1_Read(struct http_conn *htc, void *d, size_t len); enum htc_status_e HTTP1_Complete(struct http_conn *htc); uint16_t HTTP1_DissectRequest(struct req *); uint16_t HTTP1_DissectResponse(struct http *sp, const struct http_conn *htc); -enum sess_close HTTP1_DoConnection(const struct http *); +enum sess_close HTTP1_DoConnection(struct http *); unsigned HTTP1_Write(const struct worker *w, const struct http *hp, const int*); #define HTTPH(a, b, c) extern char b[]; diff --git a/bin/varnishd/cache/cache_http1_proto.c b/bin/varnishd/cache/cache_http1_proto.c index 99564b3..1fe77ba 100644 --- a/bin/varnishd/cache/cache_http1_proto.c +++ b/bin/varnishd/cache/cache_http1_proto.c @@ -508,12 +508,13 @@ HTTP1_DissectResponse(struct http *hp, const struct http_conn *htc) */ enum sess_close -HTTP1_DoConnection(const struct http *hp) +HTTP1_DoConnection(struct http *hp) { char *p, *q; enum sess_close ret; unsigned u; + http_CollectHdr(hp, H_Connection); if (!http_GetHdr(hp, H_Connection, &p)) { if (hp->protover < 11) return (SC_REQ_HTTP10); From phk at FreeBSD.org Mon Jul 14 12:32:47 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 14 Jul 2014 14:32:47 +0200 Subject: [master] db403d9 Unify the handling of the Connection: header between client/backend Message-ID: commit db403d956980f60c49ac7753152b34162df51192 Author: Poul-Henning Kamp Date: Mon Jul 14 12:32:26 2014 +0000 Unify the handling of the Connection: header between client/backend diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index e1b37a4..586181e 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -494,6 +494,8 @@ struct busyobj { ssize_t content_length; + enum sess_close doclose; + #define BO_FLAG(l, r, w, d) unsigned l:1; #include "tbl/bo_flags.h" #undef BO_FLAG diff --git a/bin/varnishd/cache/cache_busyobj.c b/bin/varnishd/cache/cache_busyobj.c index e49b88e..4ebfdc4 100644 --- a/bin/varnishd/cache/cache_busyobj.c +++ b/bin/varnishd/cache/cache_busyobj.c @@ -151,6 +151,7 @@ VBO_GetBusyObj(struct worker *wrk, const struct req *req) bo->t_first = bo->t_prev = NAN; bo->content_length = -1; + bo->doclose = SC_NULL; return (bo); } diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index cf1da26..536eece 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -187,7 +187,7 @@ vbf_stp_mkbereq(const struct worker *wrk, struct busyobj *bo) assert(bo->state == BOS_INVALID); AZ(bo->vbc); - AZ(bo->should_close); + assert(bo->doclose == SC_NULL); AZ(bo->storage_hint); HTTP_Setup(bo->bereq0, bo->ws, bo->vsl, SLT_BereqMethod); @@ -261,7 +261,7 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo) CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); AZ(bo->vbc); - AZ(bo->should_close); + assert(bo->doclose == SC_NULL); AZ(bo->storage_hint); if (bo->do_pass) @@ -375,7 +375,7 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo) if (wrk->handling == VCL_RET_RETRY) { AN (bo->vbc); VDI_CloseFd(&bo->vbc, &bo->acct); - bo->should_close = 0; + bo->doclose = SC_NULL; bo->retries++; if (bo->retries <= cache_param->max_retries) return (F_STP_RETRY); @@ -470,13 +470,13 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) if (VFP_Open(bo)) { (void)VFP_Error(bo, "Fetch Pipeline failed to open"); - bo->should_close = 1; + bo->doclose = SC_RX_BODY; return (F_STP_ERROR); } if (vbf_beresp2obj(bo)) { (void)VFP_Error(bo, "Could not get storage"); - bo->should_close = 1; + bo->doclose = SC_RX_BODY; return (F_STP_ERROR); } @@ -538,7 +538,7 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) /* Recycle the backend connection before setting BOS_FINISHED to give predictable backend reuse behavior for varnishtest */ - if (bo->vbc != NULL && !(bo->should_close)) { + if (bo->vbc != NULL && bo->doclose == SC_NULL) { VDI_RecycleFd(&bo->vbc, &bo->acct); AZ(bo->vbc); } @@ -642,7 +642,7 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo) /* Recycle the backend connection before setting BOS_FINISHED to give predictable backend reuse behavior for varnishtest */ - if (bo->vbc != NULL && !(bo->should_close)) { + if (bo->vbc != NULL && bo->doclose == SC_NULL) { VDI_RecycleFd(&bo->vbc, &bo->acct); AZ(bo->vbc); } @@ -774,6 +774,7 @@ vbf_fetch_thread(struct worker *wrk, void *priv) THR_SetBusyobj(bo); stp = F_STP_MKBEREQ; + assert(bo->doclose == SC_NULL); assert(isnan(bo->t_first)); assert(isnan(bo->t_prev)); VSLb_ts_busyobj(bo, "Start", W_TIM_real(wrk)); @@ -799,7 +800,7 @@ vbf_fetch_thread(struct worker *wrk, void *priv) bo->stats = NULL; if (bo->vbc != NULL) { - if (bo->should_close) + if (bo->doclose != SC_NULL) VDI_CloseFd(&bo->vbc, &bo->acct); else VDI_RecycleFd(&bo->vbc, &bo->acct); diff --git a/bin/varnishd/cache/cache_fetch_proc.c b/bin/varnishd/cache/cache_fetch_proc.c index 35d4bc2..054b279 100644 --- a/bin/varnishd/cache/cache_fetch_proc.c +++ b/bin/varnishd/cache/cache_fetch_proc.c @@ -205,7 +205,7 @@ VFP_Fetch_Body(struct busyobj *bo) VSLb(bo->vsl, SLT_FetchError, "Pass delivery abandoned"); vfps = VFP_END; - bo->should_close = 1; + bo->doclose = SC_RX_BODY; break; } AZ(bo->failed); @@ -214,7 +214,7 @@ VFP_Fetch_Body(struct busyobj *bo) est = 0; } if (st == NULL) { - bo->should_close = 1; + bo->doclose = SC_RX_BODY; (void)VFP_Error(bo, "Out of storage"); break; } @@ -235,7 +235,7 @@ VFP_Fetch_Body(struct busyobj *bo) if (vfps == VFP_ERROR) { AN(bo->failed); (void)VFP_Error(bo, "Fetch Pipeline failed to process"); - bo->should_close = 1; + bo->doclose = SC_RX_BODY; } vfp_suck_fini(bo); diff --git a/bin/varnishd/cache/cache_http1_fetch.c b/bin/varnishd/cache/cache_http1_fetch.c index 47b5029..57fc5d5 100644 --- a/bin/varnishd/cache/cache_http1_fetch.c +++ b/bin/varnishd/cache/cache_http1_fetch.c @@ -370,5 +370,7 @@ V1F_fetch_hdr(struct worker *wrk, struct busyobj *bo, struct req *req) /* XXX: other cleanup ? */ return (-1); } + + bo->doclose = HTTP1_DoConnection(hp); return (0); } diff --git a/bin/varnishd/cache/cache_http1_proto.c b/bin/varnishd/cache/cache_http1_proto.c index 1fe77ba..6abd62e 100644 --- a/bin/varnishd/cache/cache_http1_proto.c +++ b/bin/varnishd/cache/cache_http1_proto.c @@ -511,16 +511,17 @@ enum sess_close HTTP1_DoConnection(struct http *hp) { char *p, *q; - enum sess_close ret; + enum sess_close retval; unsigned u; + if (hp->protover < 11) + retval = SC_REQ_HTTP10; + else + retval = SC_NULL;; + http_CollectHdr(hp, H_Connection); - if (!http_GetHdr(hp, H_Connection, &p)) { - if (hp->protover < 11) - return (SC_REQ_HTTP10); - return (SC_NULL); - } - ret = SC_NULL; + if (!http_GetHdr(hp, H_Connection, &p)) + return (retval); AN(p); for (; *p; p++) { if (vct_issp(*p)) @@ -532,13 +533,15 @@ HTTP1_DoConnection(struct http *hp) break; u = pdiff(p, q); if (u == 5 && !strncasecmp(p, "close", u)) - ret = SC_REQ_CLOSE; + retval = SC_REQ_CLOSE; + if (u == 10 && !strncasecmp(p, "keep-alive", u)) + retval = SC_NULL; http_MarkHeader(hp, p, u, HDF_FILTER); if (!*q) break; p = q; } - return (ret); + return (retval); } /*--------------------------------------------------------------------*/ diff --git a/bin/varnishd/cache/cache_rfc2616.c b/bin/varnishd/cache/cache_rfc2616.c index 7969769..1b8f891 100644 --- a/bin/varnishd/cache/cache_rfc2616.c +++ b/bin/varnishd/cache/cache_rfc2616.c @@ -197,13 +197,6 @@ RFC2616_Body(struct busyobj *bo, struct dstat *stats) hp = bo->beresp; - if (hp->protover < 11 && !http_HdrIs(hp, H_Connection, "keep-alive")) - bo->should_close = 1; - else if (http_HdrIs(hp, H_Connection, "close")) - bo->should_close = 1; - else - bo->should_close = 0; - if (!strcasecmp(http_GetReq(bo->bereq), "head")) { /* * A HEAD request can never have a body in the reply, diff --git a/include/tbl/bo_flags.h b/include/tbl/bo_flags.h index ac52ef7..bc01dbe 100644 --- a/include/tbl/bo_flags.h +++ b/include/tbl/bo_flags.h @@ -39,6 +39,5 @@ BO_FLAG(uncacheable, 0, 0, "") BO_FLAG(abandon, 0, 0, "") BO_FLAG(is_gzip, 0, 0, "") BO_FLAG(is_gunzip, 0, 0, "") -BO_FLAG(should_close, 0, 0, "") /*lint -restore */ From phk at FreeBSD.org Mon Jul 14 13:24:54 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 14 Jul 2014 15:24:54 +0200 Subject: [master] 40ec4a6 The chunk-counter is http/1 specific Message-ID: commit 40ec4a6b267450cea951e4edbeedc172f0b526e8 Author: Poul-Henning Kamp Date: Mon Jul 14 13:24:37 2014 +0000 The chunk-counter is http/1 specific diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 586181e..7579b35 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -582,6 +582,7 @@ struct req { struct { ssize_t bytes_done; ssize_t bytes_yet; + intptr_t chunk_ctr; } h1; /* HTTP1 specific */ /* The busy objhead we sleep on */ @@ -599,7 +600,6 @@ struct req { unsigned char wantbody; uint64_t req_bodybytes; /* Parsed req bodybytes */ - intptr_t chunk_ctr; /* Parsed req bodybytes */ uint64_t resp_hdrbytes; /* Scheduled resp hdrbytes */ uint64_t resp_bodybytes; /* Scheduled resp bodybytes */ diff --git a/bin/varnishd/cache/cache_http1_fsm.c b/bin/varnishd/cache/cache_http1_fsm.c index 8475511..30f212a 100644 --- a/bin/varnishd/cache/cache_http1_fsm.c +++ b/bin/varnishd/cache/cache_http1_fsm.c @@ -286,7 +286,7 @@ http1_req_body_status(struct req *req) return (REQ_BODY_PRESENT); } if (http_HdrIs(req->http, H_Transfer_Encoding, "chunked")) { - req->chunk_ctr = -1; + req->h1.chunk_ctr = -1; return (REQ_BODY_CHUNKED); } if (http_GetHdr(req->http, H_Transfer_Encoding, NULL)) @@ -511,7 +511,7 @@ http1_iter_req_body(struct req *req, enum req_body_state_e bs, req->acct.req_bodybytes += len; return (len); } else if (bs == REQ_BODY_CHUNKED) { - switch (HTTP1_Chunked(req->htc, &req->chunk_ctr, &err, + switch (HTTP1_Chunked(req->htc, &req->h1.chunk_ctr, &err, &req->acct.req_bodybytes, buf, &len)) { case H1CR_ERROR: VSLb(req->vsl, SLT_Debug, "CHUNKERR: %s", err); From phk at FreeBSD.org Mon Jul 14 14:58:18 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 14 Jul 2014 16:58:18 +0200 Subject: [master] cb87982 Make Connection: handling an entirely internal http1 issue. Message-ID: commit cb879824e2114a711111d830377e3327098de836 Author: Poul-Henning Kamp Date: Mon Jul 14 14:57:54 2014 +0000 Make Connection: handling an entirely internal http1 issue. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 7579b35..7cea69d 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -198,6 +198,7 @@ struct http { uint16_t status; uint8_t protover; uint8_t conds; /* If-* headers present */ + enum sess_close doclose; }; /*-------------------------------------------------------------------- @@ -958,7 +959,7 @@ void http_Merge(const struct http *fm, struct http *to, int not_ce); /* cache_http1_proto.c */ -enum htc_status_e { +enum http1_status_e { HTTP1_ALL_WHITESPACE = -3, HTTP1_OVERFLOW = -2, HTTP1_ERROR_EOF = -1, @@ -968,13 +969,12 @@ enum htc_status_e { void HTTP1_Init(struct http_conn *htc, struct ws *ws, int fd, struct vsl_log *, unsigned maxbytes, unsigned maxhdr); -enum htc_status_e HTTP1_Reinit(struct http_conn *htc); -enum htc_status_e HTTP1_Rx(struct http_conn *htc); +enum http1_status_e HTTP1_Reinit(struct http_conn *htc); +enum http1_status_e HTTP1_Rx(struct http_conn *htc); ssize_t HTTP1_Read(struct http_conn *htc, void *d, size_t len); -enum htc_status_e HTTP1_Complete(struct http_conn *htc); +enum http1_status_e HTTP1_Complete(struct http_conn *htc); uint16_t HTTP1_DissectRequest(struct req *); uint16_t HTTP1_DissectResponse(struct http *sp, const struct http_conn *htc); -enum sess_close HTTP1_DoConnection(struct http *); unsigned HTTP1_Write(const struct worker *w, const struct http *hp, const int*); #define HTTPH(a, b, c) extern char b[]; diff --git a/bin/varnishd/cache/cache_http1_fetch.c b/bin/varnishd/cache/cache_http1_fetch.c index 57fc5d5..a36cc70 100644 --- a/bin/varnishd/cache/cache_http1_fetch.c +++ b/bin/varnishd/cache/cache_http1_fetch.c @@ -238,7 +238,7 @@ V1F_fetch_hdr(struct worker *wrk, struct busyobj *bo, struct req *req) { struct vbc *vc; struct http *hp; - enum htc_status_e hs; + enum http1_status_e hs; int retry = -1; int i, j, first; struct http_conn *htc; @@ -371,6 +371,6 @@ V1F_fetch_hdr(struct worker *wrk, struct busyobj *bo, struct req *req) return (-1); } - bo->doclose = HTTP1_DoConnection(hp); + bo->doclose = hp->doclose; return (0); } diff --git a/bin/varnishd/cache/cache_http1_fsm.c b/bin/varnishd/cache/cache_http1_fsm.c index 30f212a..b6f08be 100644 --- a/bin/varnishd/cache/cache_http1_fsm.c +++ b/bin/varnishd/cache/cache_http1_fsm.c @@ -92,7 +92,7 @@ http1_wait(struct sess *sp, struct worker *wrk, struct req *req) struct pollfd pfd[1]; double now, when; enum sess_close why = SC_NULL; - enum htc_status_e hs; + enum http1_status_e hs; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); @@ -380,7 +380,7 @@ http1_dissect(struct worker *wrk, struct req *req) AZ(req->err_code); req->ws_req = WS_Snapshot(req->ws); - req->doclose = HTTP1_DoConnection(req->http); + req->doclose = req->http->doclose; http_Unset(req->http, H_Expect); diff --git a/bin/varnishd/cache/cache_http1_proto.c b/bin/varnishd/cache/cache_http1_proto.c index 6abd62e..40af2cf 100644 --- a/bin/varnishd/cache/cache_http1_proto.c +++ b/bin/varnishd/cache/cache_http1_proto.c @@ -88,7 +88,7 @@ HTTP1_Init(struct http_conn *htc, struct ws *ws, int fd, struct vsl_log *vsl, * the ws somewhere, because WS_Reset only fiddles pointers. */ -enum htc_status_e +enum http1_status_e HTTP1_Reinit(struct http_conn *htc) { unsigned l; @@ -112,7 +112,7 @@ HTTP1_Reinit(struct http_conn *htc) * Check if we have a complete HTTP request or response yet */ -enum htc_status_e +enum http1_status_e HTTP1_Complete(struct http_conn *htc) { char *p; @@ -159,7 +159,7 @@ HTTP1_Complete(struct http_conn *htc) * Receive more HTTP protocol bytes */ -enum htc_status_e +enum http1_status_e HTTP1_Rx(struct http_conn *htc) { int i; @@ -228,7 +228,7 @@ HTTP1_Read(struct http_conn *htc, void *d, size_t len) */ static uint16_t -htc_dissect_hdrs(struct http *hp, char *p, const struct http_conn *htc) +http1_dissect_hdrs(struct http *hp, char *p, const struct http_conn *htc) { char *q, *r; txt t = htc->rxbuf; @@ -304,7 +304,7 @@ htc_dissect_hdrs(struct http *hp, char *p, const struct http_conn *htc) */ static uint16_t -htc_splitline(struct http *hp, const struct http_conn *htc, const int *hf) +http1_splitline(struct http *hp, const struct http_conn *htc, const int *hf) { char *p; @@ -369,16 +369,17 @@ htc_splitline(struct http *hp, const struct http_conn *htc, const int *hf) *hp->hd[hf[1]].e = '\0'; *hp->hd[hf[2]].e = '\0'; - return (htc_dissect_hdrs(hp, p, htc)); + return (http1_dissect_hdrs(hp, p, htc)); } /*--------------------------------------------------------------------*/ static uint16_t -htc_request_check_host_hdr(const struct http *hp) +http1_request_check_host_hdr(const struct http *hp) { int u; int seen_host = 0; + for (u = HTTP_HDR_FIRST; u < hp->nhd; u++) { if (hp->hd[u].b == NULL) continue; @@ -399,7 +400,7 @@ htc_request_check_host_hdr(const struct http *hp) /*--------------------------------------------------------------------*/ static void -htc_proto_ver(struct http *hp) +http1_proto_ver(struct http *hp) { if (!strcasecmp(hp->hd[HTTP_HDR_PROTO].b, "HTTP/1.0")) hp->protover = 10; @@ -409,6 +410,47 @@ htc_proto_ver(struct http *hp) hp->protover = 9; } +/*-------------------------------------------------------------------- + */ + +static enum sess_close +http1_DoConnection(struct http *hp) +{ + char *p, *q; + enum sess_close retval; + unsigned u; + + if (hp->protover < 11) + retval = SC_REQ_HTTP10; + else + retval = SC_NULL;; + + http_CollectHdr(hp, H_Connection); + if (!http_GetHdr(hp, H_Connection, &p)) + return (retval); + AN(p); + for (; *p; p++) { + if (vct_issp(*p)) + continue; + if (*p == ',') + continue; + for (q = p + 1; *q; q++) + if (*q == ',' || vct_issp(*q)) + break; + u = pdiff(p, q); + if (u == 5 && !strncasecmp(p, "close", u)) + retval = SC_REQ_CLOSE; + if (u == 10 && !strncasecmp(p, "keep-alive", u)) + retval = SC_NULL; + http_MarkHeader(hp, p, u, HDF_FILTER); + if (!*q) + break; + p = q; + } + return (retval); +} + + /*--------------------------------------------------------------------*/ uint16_t @@ -425,14 +467,14 @@ HTTP1_DissectRequest(struct req *req) hp = req->http; CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC); - retval = htc_splitline(hp, htc, HTTP1_Req); + retval = http1_splitline(hp, htc, HTTP1_Req); if (retval != 0) { VSLbt(req->vsl, SLT_HttpGarbage, htc->rxbuf); return (retval); } - htc_proto_ver(hp); + http1_proto_ver(hp); - retval = htc_request_check_host_hdr(hp); + retval = http1_request_check_host_hdr(hp); if (retval != 0) { return (retval); } @@ -449,6 +491,8 @@ HTTP1_DissectRequest(struct req *req) } } + hp->doclose = http1_DoConnection(hp); + return (retval); } @@ -464,11 +508,11 @@ HTTP1_DissectResponse(struct http *hp, const struct http_conn *htc) CHECK_OBJ_NOTNULL(htc, HTTP_CONN_MAGIC); CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC); - if (htc_splitline(hp, htc, HTTP1_Resp)) + if (http1_splitline(hp, htc, HTTP1_Resp)) retval = 503; if (retval == 0) { - htc_proto_ver(hp); + http1_proto_ver(hp); if (hp->protover != 10 && hp->protover != 11) retval = 503; } @@ -501,46 +545,8 @@ HTTP1_DissectResponse(struct http *hp, const struct http_conn *htc) !Tlen(hp->hd[HTTP_HDR_REASON])) http_SetH(hp, HTTP_HDR_REASON, http_Status2Reason(hp->status)); - return (retval); -} - -/*-------------------------------------------------------------------- - */ - -enum sess_close -HTTP1_DoConnection(struct http *hp) -{ - char *p, *q; - enum sess_close retval; - unsigned u; - - if (hp->protover < 11) - retval = SC_REQ_HTTP10; - else - retval = SC_NULL;; + hp->doclose = http1_DoConnection(hp); - http_CollectHdr(hp, H_Connection); - if (!http_GetHdr(hp, H_Connection, &p)) - return (retval); - AN(p); - for (; *p; p++) { - if (vct_issp(*p)) - continue; - if (*p == ',') - continue; - for (q = p + 1; *q; q++) - if (*q == ',' || vct_issp(*q)) - break; - u = pdiff(p, q); - if (u == 5 && !strncasecmp(p, "close", u)) - retval = SC_REQ_CLOSE; - if (u == 10 && !strncasecmp(p, "keep-alive", u)) - retval = SC_NULL; - http_MarkHeader(hp, p, u, HDF_FILTER); - if (!*q) - break; - p = q; - } return (retval); } From phk at FreeBSD.org Mon Jul 14 17:01:02 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 14 Jul 2014 19:01:02 +0200 Subject: [master] f706571 Fix comments Message-ID: commit f7065719ea818e6d78d8246708ec83ead7114ef0 Author: Poul-Henning Kamp Date: Mon Jul 14 17:00:47 2014 +0000 Fix comments diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 7cea69d..ddb99a3 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -174,10 +174,9 @@ struct ws { }; /*-------------------------------------------------------------------- - * Ban info event types + * */ -/* NB: remember to update http_Copy() if you add fields */ struct http { unsigned magic; #define HTTP_MAGIC 0x6428b5c9 From phk at FreeBSD.org Mon Jul 14 19:24:59 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 14 Jul 2014 21:24:59 +0200 Subject: [master] f400cf1 Remove unused member of struct http_conn Message-ID: commit f400cf17452de872ded0e8f6682d843d6b2f6e0d Author: Poul-Henning Kamp Date: Mon Jul 14 19:22:17 2014 +0000 Remove unused member of struct http_conn diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index ddb99a3..fe060dd 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -108,7 +108,6 @@ struct busyobj; struct cli; struct cli_proto; struct director; -struct http_conn; struct iovec; struct mempool; struct objcore; @@ -174,7 +173,7 @@ struct ws { }; /*-------------------------------------------------------------------- - * + * */ struct http { @@ -208,12 +207,9 @@ struct http { * */ -typedef ssize_t htc_read(struct http_conn *, void *, size_t); - struct http_conn { unsigned magic; #define HTTP_CONN_MAGIC 0x3e19edd1 - htc_read *read; int fd; struct vsl_log *vsl; diff --git a/bin/varnishd/cache/cache_http1_proto.c b/bin/varnishd/cache/cache_http1_proto.c index 40af2cf..03563fd 100644 --- a/bin/varnishd/cache/cache_http1_proto.c +++ b/bin/varnishd/cache/cache_http1_proto.c @@ -72,7 +72,6 @@ HTTP1_Init(struct http_conn *htc, struct ws *ws, int fd, struct vsl_log *vsl, htc->vsl = vsl; htc->maxbytes = maxbytes; htc->maxhdr = maxhdr; - htc->read = HTTP1_Read; (void)WS_Reserve(htc->ws, htc->maxbytes); htc->rxbuf.b = ws->f; From phk at FreeBSD.org Tue Jul 15 07:28:50 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 15 Jul 2014 09:28:50 +0200 Subject: [master] 7a7d36b Make setting of vfe->priv* fields something callers of VFP_Push() does. Message-ID: commit 7a7d36bd82b128fd771fbd1365aaef8c6f05f80e Author: Poul-Henning Kamp Date: Tue Jul 15 07:28:16 2014 +0000 Make setting of vfe->priv* fields something callers of VFP_Push() does. diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 536eece..1942765 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -447,18 +447,18 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) assert(bo->do_gzip == 0 || bo->do_gunzip == 0); if (bo->do_gunzip || (bo->is_gzip && bo->do_esi)) - VFP_Push(bo, &vfp_gunzip, 0, 1); + (void)VFP_Push(bo, &vfp_gunzip, 1); if (bo->do_esi && bo->do_gzip) { - VFP_Push(bo, &vfp_esi_gzip, 0, 1); + (void)VFP_Push(bo, &vfp_esi_gzip, 1); } else if (bo->do_esi && bo->is_gzip && !bo->do_gunzip) { - VFP_Push(bo, &vfp_esi_gzip, 0, 1); + (void)VFP_Push(bo, &vfp_esi_gzip, 1); } else if (bo->do_esi) { - VFP_Push(bo, &vfp_esi, 0, 1); + (void)VFP_Push(bo, &vfp_esi, 1); } else if (bo->do_gzip) { - VFP_Push(bo, &vfp_gzip, 0, 1); + (void)VFP_Push(bo, &vfp_gzip, 1); } else if (bo->is_gzip && !bo->do_gunzip) { - VFP_Push(bo, &vfp_testgunzip, 0, 1); + (void)VFP_Push(bo, &vfp_testgunzip, 1); } if (bo->fetch_objcore->flags & OC_F_PRIVATE) diff --git a/bin/varnishd/cache/cache_fetch_proc.c b/bin/varnishd/cache/cache_fetch_proc.c index 054b279..67039f0 100644 --- a/bin/varnishd/cache/cache_fetch_proc.c +++ b/bin/varnishd/cache/cache_fetch_proc.c @@ -244,8 +244,8 @@ VFP_Fetch_Body(struct busyobj *bo) ObjTrimStore(bo->fetch_objcore, bo->stats); } -void -VFP_Push(struct busyobj *bo, const struct vfp *vfp, intptr_t priv, int top) +struct vfp_entry * +VFP_Push(struct busyobj *bo, const struct vfp *vfp, int top) { struct vfp_entry *vfe; @@ -254,7 +254,6 @@ VFP_Push(struct busyobj *bo, const struct vfp *vfp, intptr_t priv, int top) AN(vfe); vfe->magic = VFP_ENTRY_MAGIC; vfe->vfp = vfp; - vfe->priv2 = priv; vfe->closed = VFP_OK; if (top) VTAILQ_INSERT_HEAD(&bo->vfp, vfe, list); @@ -262,6 +261,7 @@ VFP_Push(struct busyobj *bo, const struct vfp *vfp, intptr_t priv, int top) VTAILQ_INSERT_TAIL(&bo->vfp, vfe, list); if (VTAILQ_FIRST(&bo->vfp) == vfe) bo->vfp_nxt = vfe; + return (vfe); } /*-------------------------------------------------------------------- diff --git a/bin/varnishd/cache/cache_filter.h b/bin/varnishd/cache/cache_filter.h index fdded29..ab0c351 100644 --- a/bin/varnishd/cache/cache_filter.h +++ b/bin/varnishd/cache/cache_filter.h @@ -60,7 +60,7 @@ extern const struct vfp vfp_testgunzip; extern const struct vfp vfp_esi; extern const struct vfp vfp_esi_gzip; -void VFP_Push(struct busyobj *, const struct vfp *, intptr_t priv, int top); +struct vfp_entry *VFP_Push(struct busyobj *bo, const struct vfp *vfp, int top); int VFP_Open(struct busyobj *bo); diff --git a/bin/varnishd/cache/cache_http1_fetch.c b/bin/varnishd/cache/cache_http1_fetch.c index a36cc70..8ec3553 100644 --- a/bin/varnishd/cache/cache_http1_fetch.c +++ b/bin/varnishd/cache/cache_http1_fetch.c @@ -49,10 +49,11 @@ v1f_pull_straight(struct busyobj *bo, struct vfp_entry *vfe, void *p, ssize_t *lp) { ssize_t l, lr; + struct http_conn *htc; CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC); - + CAST_OBJ_NOTNULL(htc, vfe->priv1, HTTP_CONN_MAGIC); AN(p); AN(lp); @@ -63,7 +64,7 @@ v1f_pull_straight(struct busyobj *bo, struct vfp_entry *vfe, void *p, return (VFP_END); if (vfe->priv2 < l) l = vfe->priv2; - lr = HTTP1_Read(&bo->htc, p, l); + lr = HTTP1_Read(htc, p, l); bo->acct.beresp_bodybytes += lr; if (lr <= 0) return (VFP_Error(bo, "straight insufficient bytes")); @@ -90,14 +91,15 @@ v1f_pull_chunked(struct busyobj *bo, struct vfp_entry *vfe, void *p, ssize_t *lp) { const char *err; + struct http_conn *htc; CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC); - + CAST_OBJ_NOTNULL(htc, vfe->priv1, HTTP_CONN_MAGIC); AN(p); AN(lp); - switch (HTTP1_Chunked(&bo->htc, &vfe->priv2, &err, + switch (HTTP1_Chunked(htc, &vfe->priv2, &err, &bo->acct.beresp_bodybytes, p, lp)) { case H1CR_ERROR: return (VFP_Error(bo, "%s", err)); @@ -122,15 +124,17 @@ v1f_pull_eof(struct busyobj *bo, struct vfp_entry *vfe, void *p, ssize_t *lp) { ssize_t l, lr; + struct http_conn *htc; CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC); + CAST_OBJ_NOTNULL(htc, vfe->priv1, HTTP_CONN_MAGIC); AN(p); AN(lp); l = *lp; *lp = 0; - lr = HTTP1_Read(&bo->htc, p, l); + lr = HTTP1_Read(htc, p, l); if (lr < 0) return (VFP_Error(bo,"eof socket fail")); if (lr == 0) @@ -152,6 +156,7 @@ void V1F_Setup_Fetch(struct busyobj *bo) { struct http_conn *htc; + struct vfp_entry *vfe; CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); htc = &bo->htc; @@ -161,15 +166,21 @@ V1F_Setup_Fetch(struct busyobj *bo) switch(htc->body_status) { case BS_EOF: assert(bo->content_length == -1); - VFP_Push(bo, &v1f_eof, 0, 0); + vfe = VFP_Push(bo, &v1f_eof, 0); + vfe->priv1 = &bo->htc; + vfe->priv2 = 0; break; case BS_LENGTH: assert(bo->content_length > 0); - VFP_Push(bo, &v1f_straight, bo->content_length, 0); + vfe = VFP_Push(bo, &v1f_straight, 0); + vfe->priv1 = &bo->htc; + vfe->priv2 = bo->content_length; break; case BS_CHUNKED: assert(bo->content_length == -1); - VFP_Push(bo, &v1f_chunked, -1, 0); + vfe = VFP_Push(bo, &v1f_chunked, 0); + vfe->priv1 = &bo->htc; + vfe->priv2 = -1; break; default: WRONG("Wrong body_status"); From phk at FreeBSD.org Tue Jul 15 08:31:43 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 15 Jul 2014 10:31:43 +0200 Subject: [master] 1452756 Introduce a vfp_ctx structure to hold the context for fetch-filters. Message-ID: commit 1452756537bf60ee601d1de2e6aaadece005463a Author: Poul-Henning Kamp Date: Tue Jul 15 08:31:20 2014 +0000 Introduce a vfp_ctx structure to hold the context for fetch-filters. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index fe060dd..5215775 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -452,6 +452,15 @@ struct vfp_entry { VTAILQ_HEAD(vfp_entry_s, vfp_entry); +struct vfp_ctx { + unsigned magic; +#define VFP_CTX_MAGIC 0x61d9d3e5 + struct busyobj *bo; + + struct vfp_entry_s vfp; + struct vfp_entry *vfp_nxt; +}; + struct busyobj { unsigned magic; #define BUSYOBJ_MAGIC 0x23b95567 @@ -469,8 +478,7 @@ struct busyobj { uint8_t *vary; - struct vfp_entry_s vfp; - struct vfp_entry *vfp_nxt; + struct vfp_ctx vfc; int failed; enum busyobj_state_e state; @@ -880,11 +888,8 @@ void VBF_Fetch(struct worker *wrk, struct req *req, /* cache_fetch_proc.c */ struct storage *VFP_GetStorage(struct busyobj *, ssize_t sz); -enum vfp_status VFP_Error(struct busyobj *, const char *fmt, ...) - __printflike(2, 3); void VFP_Init(void); void VFP_Fetch_Body(struct busyobj *bo); -enum vfp_status VFP_Suck(struct busyobj *, void *p, ssize_t *lp); /* cache_gzip.c */ struct vgz; diff --git a/bin/varnishd/cache/cache_busyobj.c b/bin/varnishd/cache/cache_busyobj.c index 4ebfdc4..f4b4296 100644 --- a/bin/varnishd/cache/cache_busyobj.c +++ b/bin/varnishd/cache/cache_busyobj.c @@ -147,7 +147,6 @@ VBO_GetBusyObj(struct worker *wrk, const struct req *req) bo->director = req->director_hint; bo->vcl = req->vcl; VCL_Ref(bo->vcl); - VTAILQ_INIT(&bo->vfp); bo->t_first = bo->t_prev = NAN; bo->content_length = -1; diff --git a/bin/varnishd/cache/cache_esi_fetch.c b/bin/varnishd/cache/cache_esi_fetch.c index 3601cf8..3c367be 100644 --- a/bin/varnishd/cache/cache_esi_fetch.c +++ b/bin/varnishd/cache/cache_esi_fetch.c @@ -101,28 +101,30 @@ vfp_vep_callback(struct busyobj *bo, void *priv, ssize_t l, enum vgz_flag flg) } static enum vfp_status -vfp_esi_end(struct busyobj *bo, struct vef_priv *vef, enum vfp_status retval) +vfp_esi_end(const struct vfp_ctx *vc, struct vef_priv *vef, + enum vfp_status retval) { struct vsb *vsb; ssize_t l; - CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC); + CHECK_OBJ_NOTNULL(vc->bo, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(vef, VEF_MAGIC); - vsb = VEP_Finish(vef->vep, bo); + vsb = VEP_Finish(vef->vep, vc->bo); if (vsb != NULL) { if (retval == VFP_END) { l = VSB_len(vsb); assert(l > 0); /* XXX: This is a huge waste of storage... */ - bo->fetch_obj->esidata = STV_alloc(bo, l); - if (bo->fetch_obj->esidata != NULL) { - memcpy(bo->fetch_obj->esidata->ptr, + vc->bo->fetch_obj->esidata = STV_alloc(vc->bo, l); + if (vc->bo->fetch_obj->esidata != NULL) { + memcpy(vc->bo->fetch_obj->esidata->ptr, VSB_data(vsb), l); - bo->fetch_obj->esidata->len = l; + vc->bo->fetch_obj->esidata->len = l; } else { - retval = VFP_Error(bo, + retval = VFP_Error(vc, "Could not allocate storage for esidata"); } } @@ -130,9 +132,9 @@ vfp_esi_end(struct busyobj *bo, struct vef_priv *vef, enum vfp_status retval) } if (vef->vgz != NULL) { - VGZ_UpdateObj(vef->vgz, bo->fetch_obj); + VGZ_UpdateObj(vef->vgz, vc->bo->fetch_obj); if (VGZ_Destroy(&vef->vgz) != VGZ_END) - retval = VFP_Error(bo, + retval = VFP_Error(vc, "ESI+Gzip Failed at the very end"); } if (vef->ibuf != NULL) @@ -142,42 +144,44 @@ vfp_esi_end(struct busyobj *bo, struct vef_priv *vef, enum vfp_status retval) } static enum vfp_status __match_proto__(vfp_init_f) -vfp_esi_gzip_init(struct busyobj *bo, struct vfp_entry *vfe) +vfp_esi_gzip_init(struct vfp_ctx *vc, struct vfp_entry *vfe) { struct vef_priv *vef; - CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC); + CHECK_OBJ_NOTNULL(vc->bo, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC); ALLOC_OBJ(vef, VEF_MAGIC); if (vef == NULL) return (VFP_ERROR); - vef->vgz = VGZ_NewGzip(bo->vsl, "G F E"); - vef->vep = VEP_Init(bo, vfp_vep_callback, vef); + vef->vgz = VGZ_NewGzip(vc->bo->vsl, "G F E"); + vef->vep = VEP_Init(vc->bo, vfp_vep_callback, vef); vef->ibuf_sz = cache_param->gzip_buffer; vef->ibuf = calloc(1L, vef->ibuf_sz); if (vef->ibuf == NULL) - return (vfp_esi_end(bo, vef, VFP_ERROR)); + return (vfp_esi_end(vc, vef, VFP_ERROR)); vef->ibuf_i = vef->ibuf; vef->ibuf_o = vef->ibuf; vfe->priv1 = vef; - RFC2616_Weaken_Etag(bo->beresp); - http_Unset(bo->beresp, H_Content_Length); - http_Unset(bo->beresp, H_Content_Encoding); - http_SetHeader(bo->beresp, "Content-Encoding: gzip"); + RFC2616_Weaken_Etag(vc->bo->beresp); + http_Unset(vc->bo->beresp, H_Content_Length); + http_Unset(vc->bo->beresp, H_Content_Encoding); + http_SetHeader(vc->bo->beresp, "Content-Encoding: gzip"); return (VFP_OK); } static enum vfp_status __match_proto__(vfp_pull_f) -vfp_esi_gzip_pull(struct busyobj *bo, struct vfp_entry *vfe, void *p, +vfp_esi_gzip_pull(struct vfp_ctx *vc, struct vfp_entry *vfe, void *p, ssize_t *lp) { enum vfp_status vp; ssize_t d, l; struct vef_priv *vef; - CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC); + CHECK_OBJ_NOTNULL(vc->bo, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC); CAST_OBJ_NOTNULL(vef, vfe->priv1, VEF_MAGIC); AN(p); @@ -189,10 +193,10 @@ vfp_esi_gzip_pull(struct busyobj *bo, struct vfp_entry *vfe, void *p, if (d < l) l = d; } - vp = VFP_Suck(bo, vef->ibuf_i, &l); + vp = VFP_Suck(vc, vef->ibuf_i, &l); if (l > 0) { - VEP_Parse(vef->vep, bo, vef->ibuf_i, l); + VEP_Parse(vef->vep, vc->bo, vef->ibuf_i, l); vef->ibuf_i += l; assert(vef->ibuf_o >= vef->ibuf && vef->ibuf_o <= vef->ibuf_i); if (vef->error) { @@ -206,33 +210,36 @@ vfp_esi_gzip_pull(struct busyobj *bo, struct vfp_entry *vfe, void *p, vef->ibuf_i = vef->ibuf + l; } if (vp == VFP_END) { - vp = vfp_esi_end(bo, vef, vp); + vp = vfp_esi_end(vc, vef, vp); vfe->priv1 = NULL; } return (vp); } static enum vfp_status __match_proto__(vfp_init_f) -vfp_esi_init(struct busyobj *bo, struct vfp_entry *vfe) +vfp_esi_init(struct vfp_ctx *vc, struct vfp_entry *vfe) { struct vef_priv *vef; + CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC); + CHECK_OBJ_NOTNULL(vc->bo, BUSYOBJ_MAGIC); ALLOC_OBJ(vef, VEF_MAGIC); if (vef == NULL) return (VFP_ERROR); - vef->vep = VEP_Init(bo, NULL, NULL); + vef->vep = VEP_Init(vc->bo, NULL, NULL); vfe->priv1 = vef; return (VFP_OK); } static enum vfp_status __match_proto__(vfp_pull_f) -vfp_esi_pull(struct busyobj *bo, struct vfp_entry *vfe, void *p, ssize_t *lp) +vfp_esi_pull(struct vfp_ctx *vc, struct vfp_entry *vfe, void *p, ssize_t *lp) { enum vfp_status vp; ssize_t d; struct vef_priv *vef; - CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC); + CHECK_OBJ_NOTNULL(vc->bo, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC); CAST_OBJ_NOTNULL(vef, vfe->priv1, VEF_MAGIC); AN(p); @@ -242,24 +249,24 @@ vfp_esi_pull(struct busyobj *bo, struct vfp_entry *vfe, void *p, ssize_t *lp) if (d < *lp) *lp = d; } - vp = VFP_Suck(bo, p, lp); + vp = VFP_Suck(vc, p, lp); if (vp != VFP_ERROR && *lp > 0) - VEP_Parse(vef->vep, bo, p, *lp); + VEP_Parse(vef->vep, vc->bo, p, *lp); if (vp == VFP_END) { - vp = vfp_esi_end(bo, vef, vp); + vp = vfp_esi_end(vc, vef, vp); vfe->priv1 = NULL; } return (vp); } static void __match_proto__(vfp_fini_f) -vfp_esi_fini(struct busyobj *bo, struct vfp_entry *vfe) +vfp_esi_fini(struct vfp_ctx *vc, struct vfp_entry *vfe) { - CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC); CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC); if (vfe->priv1 != NULL) - (void)vfp_esi_end(bo, vfe->priv1, VFP_ERROR); + (void)vfp_esi_end(vc, vfe->priv1, VFP_ERROR); vfe->priv1 = NULL; } diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 1942765..d3153a9 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -367,6 +367,10 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo) } else do_ims = 0; + bo->vfc.magic = VFP_CTX_MAGIC; + VTAILQ_INIT(&bo->vfc.vfp); + bo->vfc.bo = bo; + VCL_backend_response_method(bo->vcl, wrk, NULL, bo, bo->beresp->ws); if (wrk->handling == VCL_RET_ABANDON) @@ -447,18 +451,18 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) assert(bo->do_gzip == 0 || bo->do_gunzip == 0); if (bo->do_gunzip || (bo->is_gzip && bo->do_esi)) - (void)VFP_Push(bo, &vfp_gunzip, 1); + (void)VFP_Push(&bo->vfc, &vfp_gunzip, 1); if (bo->do_esi && bo->do_gzip) { - (void)VFP_Push(bo, &vfp_esi_gzip, 1); + (void)VFP_Push(&bo->vfc, &vfp_esi_gzip, 1); } else if (bo->do_esi && bo->is_gzip && !bo->do_gunzip) { - (void)VFP_Push(bo, &vfp_esi_gzip, 1); + (void)VFP_Push(&bo->vfc, &vfp_esi_gzip, 1); } else if (bo->do_esi) { - (void)VFP_Push(bo, &vfp_esi, 1); + (void)VFP_Push(&bo->vfc, &vfp_esi, 1); } else if (bo->do_gzip) { - (void)VFP_Push(bo, &vfp_gzip, 1); + (void)VFP_Push(&bo->vfc, &vfp_gzip, 1); } else if (bo->is_gzip && !bo->do_gunzip) { - (void)VFP_Push(bo, &vfp_testgunzip, 1); + (void)VFP_Push(&bo->vfc, &vfp_testgunzip, 1); } if (bo->fetch_objcore->flags & OC_F_PRIVATE) @@ -468,14 +472,14 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) if (bo->htc.body_status == BS_NONE) bo->do_stream = 0; - if (VFP_Open(bo)) { - (void)VFP_Error(bo, "Fetch Pipeline failed to open"); + if (VFP_Open(&bo->vfc)) { + (void)VFP_Error(&bo->vfc, "Fetch Pipeline failed to open"); bo->doclose = SC_RX_BODY; return (F_STP_ERROR); } if (vbf_beresp2obj(bo)) { - (void)VFP_Error(bo, "Could not get storage"); + (void)VFP_Error(&bo->vfc, "Could not get storage"); bo->doclose = SC_RX_BODY; return (F_STP_ERROR); } diff --git a/bin/varnishd/cache/cache_fetch_proc.c b/bin/varnishd/cache/cache_fetch_proc.c index 67039f0..10525b2 100644 --- a/bin/varnishd/cache/cache_fetch_proc.c +++ b/bin/varnishd/cache/cache_fetch_proc.c @@ -53,17 +53,18 @@ static unsigned fetchfrag; */ enum vfp_status -VFP_Error(struct busyobj *bo, const char *fmt, ...) +VFP_Error(const struct vfp_ctx *vc, const char *fmt, ...) { va_list ap; - CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); - assert(bo->state >= BOS_REQ_DONE); - if (!bo->failed) { + CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC); + CHECK_OBJ_NOTNULL(vc->bo, BUSYOBJ_MAGIC); + assert(vc->bo->state >= BOS_REQ_DONE); + if (!vc->bo->failed) { va_start(ap, fmt); - VSLbv(bo->vsl, SLT_FetchError, fmt, ap); + VSLbv(vc->bo->vsl, SLT_FetchError, fmt, ap); va_end(ap); - bo->failed = 1; + vc->bo->failed = 1; } return (VFP_ERROR); } @@ -95,7 +96,7 @@ VFP_GetStorage(struct busyobj *bo, ssize_t sz) l = cache_param->fetch_chunksize; st = STV_alloc(bo, l); if (st == NULL) { - (void)VFP_Error(bo, "Could not get storage"); + (void)VFP_Error(&bo->vfc, "Could not get storage"); } else { AZ(st->len); Lck_Lock(&bo->mtx); @@ -109,29 +110,29 @@ VFP_GetStorage(struct busyobj *bo, ssize_t sz) */ static void -vfp_suck_fini(struct busyobj *bo) +vfp_suck_fini(struct vfp_ctx *vc) { struct vfp_entry *vfe; - VTAILQ_FOREACH(vfe, &bo->vfp, list) + VTAILQ_FOREACH(vfe, &vc->vfp, list) if(vfe->vfp->fini != NULL) - vfe->vfp->fini(bo, vfe); + vfe->vfp->fini(vc, vfe); } int -VFP_Open(struct busyobj *bo) +VFP_Open(struct vfp_ctx *vc) { struct vfp_entry *vfe; - VTAILQ_FOREACH_REVERSE(vfe, &bo->vfp, vfp_entry_s, list) { + CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC); + VTAILQ_FOREACH_REVERSE(vfe, &vc->vfp, vfp_entry_s, list) { if (vfe->vfp->init == NULL) continue; - vfe->closed = vfe->vfp->init(bo, vfe); + vfe->closed = vfe->vfp->init(vc, vfe); if (vfe->closed != VFP_OK && vfe->closed != VFP_NULL) { - (void)VFP_Error(bo, - "Fetch filter %s failed to open", + (void)VFP_Error(vc, "Fetch filter %s failed to open", vfe->vfp->name); - vfp_suck_fini(bo); + vfp_suck_fini(vc); return (-1); } } @@ -145,33 +146,34 @@ VFP_Open(struct busyobj *bo) */ enum vfp_status -VFP_Suck(struct busyobj *bo, void *p, ssize_t *lp) +VFP_Suck(struct vfp_ctx *vc, void *p, ssize_t *lp) { enum vfp_status vp; struct vfp_entry *vfe; - CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC); + CHECK_OBJ_NOTNULL(vc->bo, BUSYOBJ_MAGIC); AN(p); AN(lp); - vfe = bo->vfp_nxt; + vfe = vc->vfp_nxt; CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC); - bo->vfp_nxt = VTAILQ_NEXT(vfe, list); + vc->vfp_nxt = VTAILQ_NEXT(vfe, list); if (vfe->closed == VFP_NULL) { - vp = VFP_Suck(bo, p, lp); + vp = VFP_Suck(vc, p, lp); } else if (vfe->closed == VFP_OK) { - vp = vfe->vfp->pull(bo, vfe, p, lp); + vp = vfe->vfp->pull(vc, vfe, p, lp); if (vp == VFP_END || vp == VFP_ERROR) { vfe->closed = vp; } else if (vp != VFP_OK) - (void)VFP_Error(bo, "Fetch filter %s returned %d", + (void)VFP_Error(vc, "Fetch filter %s returned %d", vfe->vfp->name, vp); } else { /* Already closed filter */ *lp = 0; vp = vfe->closed; } - bo->vfp_nxt = vfe; + vc->vfp_nxt = vfe; return (vp); } @@ -188,7 +190,7 @@ VFP_Fetch_Body(struct busyobj *bo) CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); - AN(bo->vfp_nxt); + AN(bo->vfc.vfp_nxt); est = bo->content_length; if (est < 0) @@ -215,7 +217,7 @@ VFP_Fetch_Body(struct busyobj *bo) } if (st == NULL) { bo->doclose = SC_RX_BODY; - (void)VFP_Error(bo, "Out of storage"); + (void)VFP_Error(&bo->vfc, "Out of storage"); break; } @@ -223,7 +225,7 @@ VFP_Fetch_Body(struct busyobj *bo) assert(st == VTAILQ_LAST(&bo->fetch_obj->store, storagehead)); l = st->space - st->len; AZ(bo->failed); - vfps = VFP_Suck(bo, st->ptr + st->len, &l); + vfps = VFP_Suck(&bo->vfc, st->ptr + st->len, &l); if (l > 0 && vfps != VFP_ERROR) { AZ(VTAILQ_EMPTY(&bo->fetch_obj->store)); VBO_extend(bo, l); @@ -234,33 +236,33 @@ VFP_Fetch_Body(struct busyobj *bo) if (vfps == VFP_ERROR) { AN(bo->failed); - (void)VFP_Error(bo, "Fetch Pipeline failed to process"); + (void)VFP_Error(&bo->vfc, "Fetch Pipeline failed to process"); bo->doclose = SC_RX_BODY; } - vfp_suck_fini(bo); + vfp_suck_fini(&bo->vfc); if (!bo->do_stream) ObjTrimStore(bo->fetch_objcore, bo->stats); } struct vfp_entry * -VFP_Push(struct busyobj *bo, const struct vfp *vfp, int top) +VFP_Push(struct vfp_ctx *vc, const struct vfp *vfp, int top) { struct vfp_entry *vfe; - CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); - vfe = (void*)WS_Alloc(bo->ws, sizeof *vfe); + CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC); + vfe = (void*)WS_Alloc(vc->bo->ws, sizeof *vfe); AN(vfe); vfe->magic = VFP_ENTRY_MAGIC; vfe->vfp = vfp; vfe->closed = VFP_OK; if (top) - VTAILQ_INSERT_HEAD(&bo->vfp, vfe, list); + VTAILQ_INSERT_HEAD(&vc->vfp, vfe, list); else - VTAILQ_INSERT_TAIL(&bo->vfp, vfe, list); - if (VTAILQ_FIRST(&bo->vfp) == vfe) - bo->vfp_nxt = vfe; + VTAILQ_INSERT_TAIL(&vc->vfp, vfe, list); + if (VTAILQ_FIRST(&vc->vfp) == vfe) + vc->vfp_nxt = vfe; return (vfe); } diff --git a/bin/varnishd/cache/cache_filter.h b/bin/varnishd/cache/cache_filter.h index ab0c351..9ef68ea 100644 --- a/bin/varnishd/cache/cache_filter.h +++ b/bin/varnishd/cache/cache_filter.h @@ -30,6 +30,7 @@ struct busyobj; struct req; struct vfp_entry; +struct vfp_ctx; /* Fetch processors --------------------------------------------------*/ @@ -40,10 +41,10 @@ enum vfp_status { VFP_NULL = 2, }; -typedef enum vfp_status vfp_init_f(struct busyobj *, struct vfp_entry *); +typedef enum vfp_status vfp_init_f(struct vfp_ctx *, struct vfp_entry *); typedef enum vfp_status - vfp_pull_f(struct busyobj *, struct vfp_entry *, void *ptr, ssize_t *len); -typedef void vfp_fini_f(struct busyobj *, struct vfp_entry *); + vfp_pull_f(struct vfp_ctx *, struct vfp_entry *, void *ptr, ssize_t *len); +typedef void vfp_fini_f(struct vfp_ctx *, struct vfp_entry *); struct vfp { const char *name; @@ -60,9 +61,11 @@ extern const struct vfp vfp_testgunzip; extern const struct vfp vfp_esi; extern const struct vfp vfp_esi_gzip; -struct vfp_entry *VFP_Push(struct busyobj *bo, const struct vfp *vfp, int top); -int VFP_Open(struct busyobj *bo); - +struct vfp_entry *VFP_Push(struct vfp_ctx *, const struct vfp *, int top); +int VFP_Open(struct vfp_ctx *bo); +enum vfp_status VFP_Suck(struct vfp_ctx *, void *p, ssize_t *lp); +enum vfp_status VFP_Error(const struct vfp_ctx *, const char *fmt, ...) + __printflike(2, 3); /* Deliver processors ------------------------------------------------*/ diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c index e684089..48da134 100644 --- a/bin/varnishd/cache/cache_gzip.c +++ b/bin/varnishd/cache/cache_gzip.c @@ -451,26 +451,27 @@ VGZ_Destroy(struct vgz **vgp) #define VFP_TESTGUNZIP 2 static enum vfp_status __match_proto__(vfp_init_f) -vfp_gzip_init(struct busyobj *bo, struct vfp_entry *vfe) +vfp_gzip_init(struct vfp_ctx *vc, struct vfp_entry *vfe) { struct vgz *vg; - CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC); + CHECK_OBJ_NOTNULL(vc->bo, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC); - if (bo->content_length == 0) { - http_Unset(bo->beresp, H_Content_Encoding); + if (vc->bo->content_length == 0) { + http_Unset(vc->bo->beresp, H_Content_Encoding); return (VFP_NULL); } if (vfe->vfp->priv2 == VFP_GZIP) { - if (http_GetHdr(bo->beresp, H_Content_Encoding, NULL)) + if (http_GetHdr(vc->bo->beresp, H_Content_Encoding, NULL)) return (VFP_NULL); - vg = VGZ_NewGzip(bo->vsl, vfe->vfp->priv1); + vg = VGZ_NewGzip(vc->bo->vsl, vfe->vfp->priv1); } else { - if (!http_HdrIs(bo->beresp, H_Content_Encoding, "gzip")) + if (!http_HdrIs(vc->bo->beresp, H_Content_Encoding, "gzip")) return (VFP_NULL); - vg = VGZ_NewUngzip(bo->vsl, vfe->vfp->priv1); + vg = VGZ_NewUngzip(vc->bo->vsl, vfe->vfp->priv1); } if (vg == NULL) return (VFP_ERROR); @@ -481,13 +482,13 @@ vfp_gzip_init(struct busyobj *bo, struct vfp_entry *vfe) AZ(vg->m_len); if (vfe->vfp->priv2 == VFP_GUNZIP || vfe->vfp->priv2 == VFP_GZIP) { - http_Unset(bo->beresp, H_Content_Encoding); - http_Unset(bo->beresp, H_Content_Length); - RFC2616_Weaken_Etag(bo->beresp); + http_Unset(vc->bo->beresp, H_Content_Encoding); + http_Unset(vc->bo->beresp, H_Content_Length); + RFC2616_Weaken_Etag(vc->bo->beresp); } if (vfe->vfp->priv2 == VFP_GZIP) - http_SetHeader(bo->beresp, "Content-Encoding: gzip"); + http_SetHeader(vc->bo->beresp, "Content-Encoding: gzip"); return (VFP_OK); } @@ -499,7 +500,7 @@ vfp_gzip_init(struct busyobj *bo, struct vfp_entry *vfe) */ static enum vfp_status __match_proto__(vfp_pull_f) -vfp_gunzip_pull(struct busyobj *bo, struct vfp_entry *vfe, void *p, +vfp_gunzip_pull(struct vfp_ctx *vc, struct vfp_entry *vfe, void *p, ssize_t *lp) { ssize_t l; @@ -509,7 +510,7 @@ vfp_gunzip_pull(struct busyobj *bo, struct vfp_entry *vfe, void *p, size_t dl; enum vfp_status vp = VFP_OK; - CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC); CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC); CAST_OBJ_NOTNULL(vg, vfe->priv1, VGZ_MAGIC); AN(p); @@ -520,7 +521,7 @@ vfp_gunzip_pull(struct busyobj *bo, struct vfp_entry *vfe, void *p, do { if (VGZ_IbufEmpty(vg)) { l = vg->m_sz; - vp = VFP_Suck(bo, vg->m_buf, &l); + vp = VFP_Suck(vc, vg->m_buf, &l); if (vp == VFP_ERROR) return (vp); VGZ_Ibuf(vg, vg->m_buf, l); @@ -528,9 +529,9 @@ vfp_gunzip_pull(struct busyobj *bo, struct vfp_entry *vfe, void *p, if (!VGZ_IbufEmpty(vg) || vp == VFP_END) { vr = VGZ_Gunzip(vg, &dp, &dl); if (vr == VGZ_END && !VGZ_IbufEmpty(vg)) - return(VFP_Error(bo, "Junk after gzip data")); + return(VFP_Error(vc, "Junk after gzip data")); if (vr < VGZ_OK) - return (VFP_Error(bo, + return (VFP_Error(vc, "Invalid Gzip data: %s", vg->vz.msg)); if (dl > 0) { *lp = dl; @@ -541,7 +542,7 @@ vfp_gunzip_pull(struct busyobj *bo, struct vfp_entry *vfe, void *p, AN(VGZ_IbufEmpty(vg)); } while (vp == VFP_OK); if (vr != VGZ_END) - return(VFP_Error(bo, "Gunzip error at the very end")); + return(VFP_Error(vc, "Gunzip error at the very end")); return (vp); } @@ -553,7 +554,7 @@ vfp_gunzip_pull(struct busyobj *bo, struct vfp_entry *vfe, void *p, */ static enum vfp_status __match_proto__(vfp_pull_f) -vfp_gzip_pull(struct busyobj *bo, struct vfp_entry *vfe, void *p, +vfp_gzip_pull(struct vfp_ctx *vc, struct vfp_entry *vfe, void *p, ssize_t *lp) { ssize_t l; @@ -563,7 +564,8 @@ vfp_gzip_pull(struct busyobj *bo, struct vfp_entry *vfe, void *p, size_t dl; enum vfp_status vp = VFP_ERROR; - CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC); + CHECK_OBJ_NOTNULL(vc->bo, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC); CAST_OBJ_NOTNULL(vg, vfe->priv1, VGZ_MAGIC); AN(p); @@ -574,7 +576,7 @@ vfp_gzip_pull(struct busyobj *bo, struct vfp_entry *vfe, void *p, do { if (VGZ_IbufEmpty(vg)) { l = vg->m_sz; - vp = VFP_Suck(bo, vg->m_buf, &l); + vp = VFP_Suck(vc, vg->m_buf, &l); if (vp == VFP_ERROR) break; if (vp == VFP_END) @@ -584,7 +586,7 @@ vfp_gzip_pull(struct busyobj *bo, struct vfp_entry *vfe, void *p, if (!VGZ_IbufEmpty(vg) || vg->flag == VGZ_FINISH) { vr = VGZ_Gzip(vg, &dp, &dl, vg->flag); if (vr < VGZ_OK) - return (VFP_Error(bo, "Gzip failed")); + return (VFP_Error(vc, "Gzip failed")); if (dl > 0) { *lp = dl; assert(dp == p); @@ -595,8 +597,8 @@ vfp_gzip_pull(struct busyobj *bo, struct vfp_entry *vfe, void *p, } while (vg->flag != VGZ_FINISH); if (vr != VGZ_END) - return (VFP_Error(bo, "Gzip failed")); - VGZ_UpdateObj(vg, bo->fetch_obj); + return (VFP_Error(vc, "Gzip failed")); + VGZ_UpdateObj(vg, vc->bo->fetch_obj); return (VFP_END); } @@ -608,7 +610,7 @@ vfp_gzip_pull(struct busyobj *bo, struct vfp_entry *vfe, void *p, */ static enum vfp_status __match_proto__(vfp_pull_f) -vfp_testgunzip_pull(struct busyobj *bo, struct vfp_entry *vfe, void *p, +vfp_testgunzip_pull(struct vfp_ctx *vc, struct vfp_entry *vfe, void *p, ssize_t *lp) { struct vgz *vg; @@ -617,13 +619,14 @@ vfp_testgunzip_pull(struct busyobj *bo, struct vfp_entry *vfe, void *p, size_t dl; enum vfp_status vp; - CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC); + CHECK_OBJ_NOTNULL(vc->bo, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC); CAST_OBJ_NOTNULL(vg, vfe->priv1, VGZ_MAGIC); AN(p); AN(lp); CAST_OBJ_NOTNULL(vg, vfe->priv1, VGZ_MAGIC); - vp = VFP_Suck(bo, p, lp); + vp = VFP_Suck(vc, p, lp); if (vp == VFP_ERROR) return (vp); if (*lp > 0 || vp == VFP_END) { @@ -632,16 +635,16 @@ vfp_testgunzip_pull(struct busyobj *bo, struct vfp_entry *vfe, void *p, VGZ_Obuf(vg, vg->m_buf, vg->m_sz); vr = VGZ_Gunzip(vg, &dp, &dl); if (vr == VGZ_END && !VGZ_IbufEmpty(vg)) - return(VFP_Error(bo, "Junk after gzip data")); + return(VFP_Error(vc, "Junk after gzip data")); if (vr < VGZ_OK) - return (VFP_Error(bo, + return (VFP_Error(vc, "Invalid Gzip data: %s", vg->vz.msg)); } while (!VGZ_IbufEmpty(vg)); } if (vp == VFP_END) { if (vr != VGZ_END) - return (VFP_Error(bo, "tGunzip failed")); - VGZ_UpdateObj(vg, bo->fetch_obj); + return (VFP_Error(vc, "tGunzip failed")); + VGZ_UpdateObj(vg, vc->bo->fetch_obj); } return (vp); } @@ -649,11 +652,11 @@ vfp_testgunzip_pull(struct busyobj *bo, struct vfp_entry *vfe, void *p, /*--------------------------------------------------------------------*/ static void __match_proto__(vfp_fini_f) -vfp_gzip_fini(struct busyobj *bo, struct vfp_entry *vfe) +vfp_gzip_fini(struct vfp_ctx *vc, struct vfp_entry *vfe) { struct vgz *vg; - CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC); CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC); if (vfe->priv1 != NULL) { diff --git a/bin/varnishd/cache/cache_http1_fetch.c b/bin/varnishd/cache/cache_http1_fetch.c index 8ec3553..233267c 100644 --- a/bin/varnishd/cache/cache_http1_fetch.c +++ b/bin/varnishd/cache/cache_http1_fetch.c @@ -45,13 +45,14 @@ /*--------------------------------------------------------------------*/ static enum vfp_status __match_proto__(vfp_pull_f) -v1f_pull_straight(struct busyobj *bo, struct vfp_entry *vfe, void *p, +v1f_pull_straight(struct vfp_ctx *vc, struct vfp_entry *vfe, void *p, ssize_t *lp) { ssize_t l, lr; struct http_conn *htc; - CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC); + CHECK_OBJ_NOTNULL(vc->bo, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC); CAST_OBJ_NOTNULL(htc, vfe->priv1, HTTP_CONN_MAGIC); AN(p); @@ -65,9 +66,9 @@ v1f_pull_straight(struct busyobj *bo, struct vfp_entry *vfe, void *p, if (vfe->priv2 < l) l = vfe->priv2; lr = HTTP1_Read(htc, p, l); - bo->acct.beresp_bodybytes += lr; + vc->bo->acct.beresp_bodybytes += lr; if (lr <= 0) - return (VFP_Error(bo, "straight insufficient bytes")); + return (VFP_Error(vc, "straight insufficient bytes")); *lp = lr; vfe->priv2 -= lr; if (vfe->priv2 == 0) @@ -87,22 +88,23 @@ static const struct vfp v1f_straight = { */ static enum vfp_status __match_proto__(vfp_pull_f) -v1f_pull_chunked(struct busyobj *bo, struct vfp_entry *vfe, void *p, +v1f_pull_chunked(struct vfp_ctx *vc, struct vfp_entry *vfe, void *p, ssize_t *lp) { const char *err; struct http_conn *htc; - CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC); + CHECK_OBJ_NOTNULL(vc->bo, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC); CAST_OBJ_NOTNULL(htc, vfe->priv1, HTTP_CONN_MAGIC); AN(p); AN(lp); switch (HTTP1_Chunked(htc, &vfe->priv2, &err, - &bo->acct.beresp_bodybytes, p, lp)) { + &vc->bo->acct.beresp_bodybytes, p, lp)) { case H1CR_ERROR: - return (VFP_Error(bo, "%s", err)); + return (VFP_Error(vc, "%s", err)); case H1CR_MORE: return (VFP_OK); case H1CR_END: @@ -120,23 +122,26 @@ static const struct vfp v1f_chunked = { /*--------------------------------------------------------------------*/ static enum vfp_status __match_proto__(vfp_pull_f) -v1f_pull_eof(struct busyobj *bo, struct vfp_entry *vfe, void *p, +v1f_pull_eof(struct vfp_ctx *vc, struct vfp_entry *vfe, void *p, ssize_t *lp) { ssize_t l, lr; struct http_conn *htc; - CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC); CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC); CAST_OBJ_NOTNULL(htc, vfe->priv1, HTTP_CONN_MAGIC); AN(p); + + // XXX: update vc->bo->acct.beresp_bodybytes ? + AN(lp); l = *lp; *lp = 0; lr = HTTP1_Read(htc, p, l); if (lr < 0) - return (VFP_Error(bo,"eof socket fail")); + return (VFP_Error(vc, "eof socket fail")); if (lr == 0) return (VFP_END); *lp = lr; @@ -166,19 +171,19 @@ V1F_Setup_Fetch(struct busyobj *bo) switch(htc->body_status) { case BS_EOF: assert(bo->content_length == -1); - vfe = VFP_Push(bo, &v1f_eof, 0); + vfe = VFP_Push(&bo->vfc, &v1f_eof, 0); vfe->priv1 = &bo->htc; vfe->priv2 = 0; break; case BS_LENGTH: assert(bo->content_length > 0); - vfe = VFP_Push(bo, &v1f_straight, 0); + vfe = VFP_Push(&bo->vfc, &v1f_straight, 0); vfe->priv1 = &bo->htc; vfe->priv2 = bo->content_length; break; case BS_CHUNKED: assert(bo->content_length == -1); - vfe = VFP_Push(bo, &v1f_chunked, 0); + vfe = VFP_Push(&bo->vfc, &v1f_chunked, 0); vfe->priv1 = &bo->htc; vfe->priv2 = -1; break; diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index d7f1182..88dc9f5 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -302,9 +302,9 @@ pan_busyobj(const struct busyobj *bo) VSB_printf(pan_vsp, " bodystatus = %d (%s),\n", bo->htc.body_status, body_status_2str(bo->htc.body_status)); - if (!VTAILQ_EMPTY(&bo->vfp)) { + if (!VTAILQ_EMPTY(&bo->vfc.vfp)) { VSB_printf(pan_vsp, " filters ="); - VTAILQ_FOREACH(vfe, &bo->vfp, list) + VTAILQ_FOREACH(vfe, &bo->vfc.vfp, list) VSB_printf(pan_vsp, " %s=%d", vfe->vfp->name, (int)vfe->closed); VSB_printf(pan_vsp, "\n"); From phk at FreeBSD.org Tue Jul 15 09:07:32 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 15 Jul 2014 11:07:32 +0200 Subject: [master] 6ed750d Eliminate some trival VFP uses of busyobj. Message-ID: commit 6ed750d674871e41248281468e572fa75804e564 Author: Poul-Henning Kamp Date: Tue Jul 15 09:07:11 2014 +0000 Eliminate some trival VFP uses of busyobj. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 5215775..b8ca57f 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -459,6 +459,10 @@ struct vfp_ctx { struct vfp_entry_s vfp; struct vfp_entry *vfp_nxt; + + struct vsl_log *vsl; + struct http *http; + uint64_t bodybytes; }; struct busyobj { diff --git a/bin/varnishd/cache/cache_esi_fetch.c b/bin/varnishd/cache/cache_esi_fetch.c index 3c367be..cc5f8d6 100644 --- a/bin/varnishd/cache/cache_esi_fetch.c +++ b/bin/varnishd/cache/cache_esi_fetch.c @@ -154,7 +154,7 @@ vfp_esi_gzip_init(struct vfp_ctx *vc, struct vfp_entry *vfe) ALLOC_OBJ(vef, VEF_MAGIC); if (vef == NULL) return (VFP_ERROR); - vef->vgz = VGZ_NewGzip(vc->bo->vsl, "G F E"); + vef->vgz = VGZ_NewGzip(vc->vsl, "G F E"); vef->vep = VEP_Init(vc->bo, vfp_vep_callback, vef); vef->ibuf_sz = cache_param->gzip_buffer; vef->ibuf = calloc(1L, vef->ibuf_sz); @@ -164,10 +164,10 @@ vfp_esi_gzip_init(struct vfp_ctx *vc, struct vfp_entry *vfe) vef->ibuf_o = vef->ibuf; vfe->priv1 = vef; - RFC2616_Weaken_Etag(vc->bo->beresp); - http_Unset(vc->bo->beresp, H_Content_Length); - http_Unset(vc->bo->beresp, H_Content_Encoding); - http_SetHeader(vc->bo->beresp, "Content-Encoding: gzip"); + RFC2616_Weaken_Etag(vc->http); + http_Unset(vc->http, H_Content_Length); + http_Unset(vc->http, H_Content_Encoding); + http_SetHeader(vc->http, "Content-Encoding: gzip"); return (VFP_OK); } diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index d3153a9..32cd3da 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -367,9 +367,10 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo) } else do_ims = 0; - bo->vfc.magic = VFP_CTX_MAGIC; - VTAILQ_INIT(&bo->vfc.vfp); + VFP_Setup(&bo->vfc); bo->vfc.bo = bo; + bo->vfc.http = bo->beresp; + bo->vfc.vsl = bo->vsl; VCL_backend_response_method(bo->vcl, wrk, NULL, bo, bo->beresp->ws); @@ -519,6 +520,7 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) if (bo->htc.body_status != BS_NONE) { assert(bo->htc.body_status != BS_ERROR); VFP_Fetch_Body(bo); + bo->acct.beresp_bodybytes = bo->vfc.bodybytes; } if (bo->failed && !bo->do_stream) { diff --git a/bin/varnishd/cache/cache_fetch_proc.c b/bin/varnishd/cache/cache_fetch_proc.c index 10525b2..a49a58a 100644 --- a/bin/varnishd/cache/cache_fetch_proc.c +++ b/bin/varnishd/cache/cache_fetch_proc.c @@ -62,7 +62,7 @@ VFP_Error(const struct vfp_ctx *vc, const char *fmt, ...) assert(vc->bo->state >= BOS_REQ_DONE); if (!vc->bo->failed) { va_start(ap, fmt); - VSLbv(vc->bo->vsl, SLT_FetchError, fmt, ap); + VSLbv(vc->vsl, SLT_FetchError, fmt, ap); va_end(ap); vc->bo->failed = 1; } @@ -109,6 +109,17 @@ VFP_GetStorage(struct busyobj *bo, ssize_t sz) /********************************************************************** */ +void +VFP_Setup(struct vfp_ctx *vc) +{ + memset(vc, 0, sizeof *vc); + vc->magic = VFP_CTX_MAGIC; + VTAILQ_INIT(&vc->vfp); +} + +/********************************************************************** + */ + static void vfp_suck_fini(struct vfp_ctx *vc) { diff --git a/bin/varnishd/cache/cache_filter.h b/bin/varnishd/cache/cache_filter.h index 9ef68ea..4065cc7 100644 --- a/bin/varnishd/cache/cache_filter.h +++ b/bin/varnishd/cache/cache_filter.h @@ -62,6 +62,7 @@ extern const struct vfp vfp_esi; extern const struct vfp vfp_esi_gzip; struct vfp_entry *VFP_Push(struct vfp_ctx *, const struct vfp *, int top); +void VFP_Setup(struct vfp_ctx *vc); int VFP_Open(struct vfp_ctx *bo); enum vfp_status VFP_Suck(struct vfp_ctx *, void *p, ssize_t *lp); enum vfp_status VFP_Error(const struct vfp_ctx *, const char *fmt, ...) diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c index 48da134..5abefbb 100644 --- a/bin/varnishd/cache/cache_gzip.c +++ b/bin/varnishd/cache/cache_gzip.c @@ -460,18 +460,18 @@ vfp_gzip_init(struct vfp_ctx *vc, struct vfp_entry *vfe) CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC); if (vc->bo->content_length == 0) { - http_Unset(vc->bo->beresp, H_Content_Encoding); + http_Unset(vc->http, H_Content_Encoding); return (VFP_NULL); } if (vfe->vfp->priv2 == VFP_GZIP) { - if (http_GetHdr(vc->bo->beresp, H_Content_Encoding, NULL)) + if (http_GetHdr(vc->http, H_Content_Encoding, NULL)) return (VFP_NULL); - vg = VGZ_NewGzip(vc->bo->vsl, vfe->vfp->priv1); + vg = VGZ_NewGzip(vc->vsl, vfe->vfp->priv1); } else { - if (!http_HdrIs(vc->bo->beresp, H_Content_Encoding, "gzip")) + if (!http_HdrIs(vc->http, H_Content_Encoding, "gzip")) return (VFP_NULL); - vg = VGZ_NewUngzip(vc->bo->vsl, vfe->vfp->priv1); + vg = VGZ_NewUngzip(vc->vsl, vfe->vfp->priv1); } if (vg == NULL) return (VFP_ERROR); @@ -482,13 +482,13 @@ vfp_gzip_init(struct vfp_ctx *vc, struct vfp_entry *vfe) AZ(vg->m_len); if (vfe->vfp->priv2 == VFP_GUNZIP || vfe->vfp->priv2 == VFP_GZIP) { - http_Unset(vc->bo->beresp, H_Content_Encoding); - http_Unset(vc->bo->beresp, H_Content_Length); - RFC2616_Weaken_Etag(vc->bo->beresp); + http_Unset(vc->http, H_Content_Encoding); + http_Unset(vc->http, H_Content_Length); + RFC2616_Weaken_Etag(vc->http); } if (vfe->vfp->priv2 == VFP_GZIP) - http_SetHeader(vc->bo->beresp, "Content-Encoding: gzip"); + http_SetHeader(vc->http, "Content-Encoding: gzip"); return (VFP_OK); } diff --git a/bin/varnishd/cache/cache_http1_fetch.c b/bin/varnishd/cache/cache_http1_fetch.c index 233267c..1f53747 100644 --- a/bin/varnishd/cache/cache_http1_fetch.c +++ b/bin/varnishd/cache/cache_http1_fetch.c @@ -52,7 +52,6 @@ v1f_pull_straight(struct vfp_ctx *vc, struct vfp_entry *vfe, void *p, struct http_conn *htc; CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC); - CHECK_OBJ_NOTNULL(vc->bo, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC); CAST_OBJ_NOTNULL(htc, vfe->priv1, HTTP_CONN_MAGIC); AN(p); @@ -66,7 +65,7 @@ v1f_pull_straight(struct vfp_ctx *vc, struct vfp_entry *vfe, void *p, if (vfe->priv2 < l) l = vfe->priv2; lr = HTTP1_Read(htc, p, l); - vc->bo->acct.beresp_bodybytes += lr; + vc->bodybytes += lr; if (lr <= 0) return (VFP_Error(vc, "straight insufficient bytes")); *lp = lr; @@ -95,14 +94,12 @@ v1f_pull_chunked(struct vfp_ctx *vc, struct vfp_entry *vfe, void *p, struct http_conn *htc; CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC); - CHECK_OBJ_NOTNULL(vc->bo, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC); CAST_OBJ_NOTNULL(htc, vfe->priv1, HTTP_CONN_MAGIC); AN(p); AN(lp); - switch (HTTP1_Chunked(htc, &vfe->priv2, &err, - &vc->bo->acct.beresp_bodybytes, p, lp)) { + switch (HTTP1_Chunked(htc, &vfe->priv2, &err, &vc->bodybytes, p, lp)) { case H1CR_ERROR: return (VFP_Error(vc, "%s", err)); case H1CR_MORE: @@ -133,8 +130,6 @@ v1f_pull_eof(struct vfp_ctx *vc, struct vfp_entry *vfe, void *p, CAST_OBJ_NOTNULL(htc, vfe->priv1, HTTP_CONN_MAGIC); AN(p); - // XXX: update vc->bo->acct.beresp_bodybytes ? - AN(lp); l = *lp; @@ -145,6 +140,7 @@ v1f_pull_eof(struct vfp_ctx *vc, struct vfp_entry *vfe, void *p, if (lr == 0) return (VFP_END); *lp = lr; + vc->bodybytes += lr; return (VFP_OK); } @@ -153,7 +149,6 @@ static const struct vfp v1f_eof = { .pull = v1f_pull_eof, }; - /*-------------------------------------------------------------------- */ From phk at FreeBSD.org Tue Jul 15 09:30:24 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 15 Jul 2014 11:30:24 +0200 Subject: [master] ace9bce Don't rely on busyobj for cheap optimization Message-ID: commit ace9bce68363f3fc2759e37268ded2b30c71ae34 Author: Poul-Henning Kamp Date: Tue Jul 15 09:24:47 2014 +0000 Don't rely on busyobj for cheap optimization diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c index 5abefbb..904d26d 100644 --- a/bin/varnishd/cache/cache_gzip.c +++ b/bin/varnishd/cache/cache_gzip.c @@ -456,10 +456,9 @@ vfp_gzip_init(struct vfp_ctx *vc, struct vfp_entry *vfe) struct vgz *vg; CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC); - CHECK_OBJ_NOTNULL(vc->bo, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC); - if (vc->bo->content_length == 0) { + if (http_HdrIs(vc->http, H_Content_Length, "0")) { http_Unset(vc->http, H_Content_Encoding); return (VFP_NULL); } From phk at FreeBSD.org Tue Jul 15 09:30:25 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 15 Jul 2014 11:30:25 +0200 Subject: [master] dbbaea9 An OCD a day keeps the white-space away... Message-ID: commit dbbaea9f5ae9b73524d5d336c138b54871f60450 Author: Poul-Henning Kamp Date: Tue Jul 15 09:30:04 2014 +0000 An OCD a day keeps the white-space away... diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index ee1b0e5..924a22a 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -553,7 +553,7 @@ ESI_DeliverChild(struct req *req) case 5: /* xxxxx000 00000000 00000000 11111111 11111111 */ dbits[1] = cc | 0x00; dbits[2] = 0x00; dbits[3] = 0x00; - dbits[4] = 0xff; dbits[5] = 0xff; + dbits[4] = 0xff; dbits[5] = 0xff; lpad = 5; break; case 2: /* xx010000 00000100 00000001 00000000 */ @@ -578,7 +578,7 @@ ESI_DeliverChild(struct req *req) dbits[1] = cc | 0x00; dbits[2] = 0x00; dbits[3] = 0x00; dbits[4] = 0x00; - dbits[5] = 0xff; dbits[6] = 0xff; + dbits[5] = 0xff; dbits[6] = 0xff; lpad = 6; break; default: diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c index 904d26d..66e0845 100644 --- a/bin/varnishd/cache/cache_gzip.c +++ b/bin/varnishd/cache/cache_gzip.c @@ -455,7 +455,7 @@ vfp_gzip_init(struct vfp_ctx *vc, struct vfp_entry *vfe) { struct vgz *vg; - CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC); + CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC); CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC); if (http_HdrIs(vc->http, H_Content_Length, "0")) { @@ -502,18 +502,18 @@ static enum vfp_status __match_proto__(vfp_pull_f) vfp_gunzip_pull(struct vfp_ctx *vc, struct vfp_entry *vfe, void *p, ssize_t *lp) { - ssize_t l; + ssize_t l; struct vgz *vg; enum vgzret_e vr = VGZ_ERROR; const void *dp; size_t dl; enum vfp_status vp = VFP_OK; - CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC); + CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC); CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC); CAST_OBJ_NOTNULL(vg, vfe->priv1, VGZ_MAGIC); - AN(p); - AN(lp); + AN(p); + AN(lp); l = *lp; *lp = 0; VGZ_Obuf(vg, p, l); @@ -556,19 +556,19 @@ static enum vfp_status __match_proto__(vfp_pull_f) vfp_gzip_pull(struct vfp_ctx *vc, struct vfp_entry *vfe, void *p, ssize_t *lp) { - ssize_t l; + ssize_t l; struct vgz *vg; enum vgzret_e vr = VGZ_ERROR; const void *dp; size_t dl; enum vfp_status vp = VFP_ERROR; - CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC); - CHECK_OBJ_NOTNULL(vc->bo, BUSYOBJ_MAGIC); + CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC); + CHECK_OBJ_NOTNULL(vc->bo, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC); CAST_OBJ_NOTNULL(vg, vfe->priv1, VGZ_MAGIC); - AN(p); - AN(lp); + AN(p); + AN(lp); l = *lp; *lp = 0; VGZ_Obuf(vg, p, l); @@ -618,12 +618,12 @@ vfp_testgunzip_pull(struct vfp_ctx *vc, struct vfp_entry *vfe, void *p, size_t dl; enum vfp_status vp; - CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC); - CHECK_OBJ_NOTNULL(vc->bo, BUSYOBJ_MAGIC); + CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC); + CHECK_OBJ_NOTNULL(vc->bo, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC); CAST_OBJ_NOTNULL(vg, vfe->priv1, VGZ_MAGIC); - AN(p); - AN(lp); + AN(p); + AN(lp); CAST_OBJ_NOTNULL(vg, vfe->priv1, VGZ_MAGIC); vp = VFP_Suck(vc, p, lp); if (vp == VFP_ERROR) @@ -655,7 +655,7 @@ vfp_gzip_fini(struct vfp_ctx *vc, struct vfp_entry *vfe) { struct vgz *vg; - CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC); + CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC); CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC); if (vfe->priv1 != NULL) { diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 161c5e8..927abc4 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -907,7 +907,7 @@ CNT_Request(struct worker *wrk, struct req *req) if (DO_DEBUG(DBG_REQ_STATE)) \ cnt_diag(req, #u); \ nxt = cnt_##l arg; \ - break; + break; #include "tbl/steps.h" #undef REQ_STEP default: diff --git a/bin/varnishd/mgt/mgt_param_tbl.c b/bin/varnishd/mgt/mgt_param_tbl.c index be862e2..90c37fc 100644 --- a/bin/varnishd/mgt/mgt_param_tbl.c +++ b/bin/varnishd/mgt/mgt_param_tbl.c @@ -203,7 +203,7 @@ struct parspec mgt_parspec[] = { "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" + "seconds the session is closed.\n" "See setsockopt(2) under SO_SNDTIMEO for more information.", DELAYED_EFFECT, "600", "seconds" }, @@ -211,7 +211,7 @@ struct parspec mgt_parspec[] = { "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" + "seconds the session is closed.\n" "See setsockopt(2) under SO_SNDTIMEO for more information.", DELAYED_EFFECT, "60", "seconds" }, @@ -500,7 +500,7 @@ struct parspec mgt_parspec[] = { "8", ""}, { "gzip_buffer", tweak_bytes_u, &mgt_param.gzip_buffer, - "2048", NULL, + "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." diff --git a/bin/varnishd/mgt/mgt_sandbox_solaris.c b/bin/varnishd/mgt/mgt_sandbox_solaris.c index 255b99c..9ead087 100644 --- a/bin/varnishd/mgt/mgt_sandbox_solaris.c +++ b/bin/varnishd/mgt/mgt_sandbox_solaris.c @@ -202,7 +202,7 @@ setppriv_check(int a) { * * > 0t_PID_::pid2proc | ::print proc_t p_flag | >a * > ( commit 7f698adeb7e7c9d88f5d3f60f54877ec46090d88 Author: Poul-Henning Kamp Date: Tue Jul 15 10:50:52 2014 +0000 Wrap the list of storage segments in a "struct body" diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index b8ca57f..cc91eae 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -537,6 +537,11 @@ struct busyobj { VTAILQ_HEAD(storagehead, storage); +struct body { + struct stevedore *stevedore; + struct storagehead list; +}; + struct object { unsigned magic; #define OBJECT_MAGIC 0x32851d42 @@ -561,7 +566,7 @@ struct object { struct http *http; - struct storagehead store; + struct body body[1]; struct storage *esidata; @@ -585,7 +590,7 @@ struct req { VTAILQ_ENTRY(req) w_list; volatile enum req_body_state_e req_body_status; - struct storagehead body; + struct body body[1]; struct { ssize_t bytes_done; diff --git a/bin/varnishd/cache/cache_busyobj.c b/bin/varnishd/cache/cache_busyobj.c index f4b4296..d0ec1d2 100644 --- a/bin/varnishd/cache/cache_busyobj.c +++ b/bin/varnishd/cache/cache_busyobj.c @@ -228,7 +228,7 @@ 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 = VTAILQ_LAST(&bo->fetch_obj->body->list, storagehead); CHECK_OBJ_NOTNULL(st, STORAGE_MAGIC); st->len += l; bo->fetch_obj->len += l; diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index 924a22a..19326e9 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -309,7 +309,7 @@ ESI_Deliver(struct req *req) AZ(dl); } - st = VTAILQ_FIRST(&req->obj->store); + st = VTAILQ_FIRST(&req->obj->body->list); off = 0; while (p < e) { @@ -467,7 +467,7 @@ ved_deliver_byterange(struct req *req, ssize_t low, ssize_t high) u_char *p; lx = 0; - VTAILQ_FOREACH(st, &req->obj->store, list) { + VTAILQ_FOREACH(st, &req->obj->body->list, list) { p = st->ptr; l = st->len; if (lx + l < low) { @@ -509,7 +509,7 @@ ESI_DeliverChild(struct req *req) CHECK_OBJ_NOTNULL(req, REQ_MAGIC); if (!req->obj->gziped) { - VTAILQ_FOREACH(st, &req->obj->store, list) + VTAILQ_FOREACH(st, &req->obj->body->list, list) ved_pretend_gzip(req, st->ptr, st->len); return; } @@ -588,7 +588,7 @@ ESI_DeliverChild(struct req *req) req->resp_bodybytes += WRW_Write(req->wrk, dbits + 1, lpad); /* We need the entire tail, but it may not be in one storage segment */ - st = VTAILQ_LAST(&req->obj->store, storagehead); + st = VTAILQ_LAST(&req->obj->body->list, storagehead); for (i = sizeof tailbuf; i > 0; i -= j) { j = st->len; if (j > i) diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 32cd3da..8f967e2 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -826,7 +826,7 @@ vbf_fetch_thread(struct worker *wrk, void *priv) struct storage *st; uu = 0; - VTAILQ_FOREACH(st, &bo->fetch_obj->store, list) + VTAILQ_FOREACH(st, &bo->fetch_obj->body->list, list) uu += st->len; if (bo->do_stream) /* Streaming might have started freeing stuff */ diff --git a/bin/varnishd/cache/cache_fetch_proc.c b/bin/varnishd/cache/cache_fetch_proc.c index a49a58a..80952c7 100644 --- a/bin/varnishd/cache/cache_fetch_proc.c +++ b/bin/varnishd/cache/cache_fetch_proc.c @@ -84,7 +84,7 @@ VFP_GetStorage(struct busyobj *bo, ssize_t sz) CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); obj = bo->fetch_obj; CHECK_OBJ_NOTNULL(obj, OBJECT_MAGIC); - st = VTAILQ_LAST(&obj->store, storagehead); + st = VTAILQ_LAST(&obj->body->list, storagehead); if (st != NULL && st->len < st->space) return (st); @@ -100,7 +100,7 @@ VFP_GetStorage(struct busyobj *bo, ssize_t sz) } else { AZ(st->len); Lck_Lock(&bo->mtx); - VTAILQ_INSERT_TAIL(&obj->store, st, list); + VTAILQ_INSERT_TAIL(&obj->body->list, st, list); Lck_Unlock(&bo->mtx); } return (st); @@ -233,12 +233,13 @@ VFP_Fetch_Body(struct busyobj *bo) } CHECK_OBJ_NOTNULL(st, STORAGE_MAGIC); - assert(st == VTAILQ_LAST(&bo->fetch_obj->store, storagehead)); + assert(st == VTAILQ_LAST(&bo->fetch_obj->body->list, + storagehead)); l = st->space - st->len; AZ(bo->failed); vfps = VFP_Suck(&bo->vfc, st->ptr + st->len, &l); if (l > 0 && vfps != VFP_ERROR) { - AZ(VTAILQ_EMPTY(&bo->fetch_obj->store)); + AZ(VTAILQ_EMPTY(&bo->fetch_obj->body->list)); VBO_extend(bo, l); } if (st->len == st->space) diff --git a/bin/varnishd/cache/cache_http1_fsm.c b/bin/varnishd/cache/cache_http1_fsm.c index b6f08be..049ca68 100644 --- a/bin/varnishd/cache/cache_http1_fsm.c +++ b/bin/varnishd/cache/cache_http1_fsm.c @@ -548,7 +548,7 @@ HTTP1_IterateReqBody(struct req *req, req_body_iter_f *func, void *priv) switch(req->req_body_status) { case REQ_BODY_CACHED: - VTAILQ_FOREACH(st, &req->body, list) { + VTAILQ_FOREACH(st, &req->body->list, list) { i = func(req, priv, st->ptr, st->len); if (i) return (i); @@ -677,7 +677,7 @@ HTTP1_CacheReqBody(struct req *req, ssize_t maxsize) l = -1; break; } else { - VTAILQ_INSERT_TAIL(&req->body, st, list); + VTAILQ_INSERT_TAIL(&req->body->list, st, list); } } diff --git a/bin/varnishd/cache/cache_obj.c b/bin/varnishd/cache/cache_obj.c index adb35f6..00d5bc9 100644 --- a/bin/varnishd/cache/cache_obj.c +++ b/bin/varnishd/cache/cache_obj.c @@ -74,7 +74,7 @@ ObjIter(struct objiter *oi, void **p, ssize_t *l) if (oi->bo == NULL) { if (oi->st == NULL) - oi->st = VTAILQ_FIRST(&oi->obj->store); + oi->st = VTAILQ_FIRST(&oi->obj->body->list); else oi->st = VTAILQ_NEXT(oi->st, list); if (oi->st != NULL) { @@ -95,8 +95,8 @@ 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) { + AZ(VTAILQ_EMPTY(&oi->obj->body->list)); + VTAILQ_FOREACH(oi->st, &oi->obj->body->list, list) { if (oi->st->len > ol) { *p = oi->st->ptr + ol; *l = oi->st->len - ol; @@ -158,11 +158,11 @@ ObjTrimStore(struct objcore *oc, struct dstat *ds) CHECK_OBJ_NOTNULL(stv, STEVEDORE_MAGIC); o = ObjGetObj(oc, ds); CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); - st = VTAILQ_LAST(&o->store, storagehead); + st = VTAILQ_LAST(&o->body->list, storagehead); if (st == NULL) return; if (st->len == 0) { - VTAILQ_REMOVE(&o->store, st, list); + VTAILQ_REMOVE(&o->body->list, st, list); STV_free(st); } else if (st->len < st->space) { STV_trim(st, st->len, 1); diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index 88dc9f5..d59333b 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -219,7 +219,7 @@ pan_object(const char *typ, const struct object *o) pan_http("obj", o->http, 4); VSB_printf(pan_vsp, " len = %jd,\n", (intmax_t)o->len); VSB_printf(pan_vsp, " store = {\n"); - VTAILQ_FOREACH(st, &o->store, list) + VTAILQ_FOREACH(st, &o->body->list, list) pan_storage(st); VSB_printf(pan_vsp, " },\n"); VSB_printf(pan_vsp, " },\n"); diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 927abc4..ebace03 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -922,9 +922,9 @@ CNT_Request(struct worker *wrk, struct req *req) VSLb(req->vsl, SLT_ESI_BodyBytes, "%ju", (uintmax_t)req->resp_bodybytes); - while (!VTAILQ_EMPTY(&req->body)) { - st = VTAILQ_FIRST(&req->body); - VTAILQ_REMOVE(&req->body, st, list); + while (!VTAILQ_EMPTY(&req->body->list)) { + st = VTAILQ_FIRST(&req->body->list); + VTAILQ_REMOVE(&req->body->list, st, list); STV_free(st); } req->wrk = NULL; diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c index c938b98..5b8a843 100644 --- a/bin/varnishd/cache/cache_session.c +++ b/bin/varnishd/cache/cache_session.c @@ -378,7 +378,7 @@ SES_GetReq(struct worker *wrk, struct sess *sp) req->t_prev = NAN; req->t_req = NAN; - VTAILQ_INIT(&req->body); + VTAILQ_INIT(&req->body->list); return (req); } diff --git a/bin/varnishd/storage/stevedore.c b/bin/varnishd/storage/stevedore.c index c9520f8..44ed2b6 100644 --- a/bin/varnishd/storage/stevedore.c +++ b/bin/varnishd/storage/stevedore.c @@ -207,7 +207,7 @@ stv_alloc_obj(struct busyobj *bo, size_t size) CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); obj = bo->fetch_obj; CHECK_OBJ_NOTNULL(obj, OBJECT_MAGIC); - stv = obj->objstore->stevedore; + stv = obj->body->stevedore; CHECK_OBJ_NOTNULL(stv, STEVEDORE_MAGIC); if (size > cache_param->fetch_maxchunksize) @@ -285,11 +285,12 @@ STV_MkObject(struct stevedore *stv, struct busyobj *bo, HTTP_Setup(o->http, bo->ws_o, bo->vsl, SLT_ObjMethod); o->http->magic = HTTP_MAGIC; - VTAILQ_INIT(&o->store); + VTAILQ_INIT(&o->body->list); o->objcore = bo->fetch_objcore; o->objcore->stevedore = stv; + o->body->stevedore = stv; AN(stv->methods); o->objcore->priv = o; o->objcore->priv2 = (uintptr_t)stv; @@ -399,9 +400,9 @@ STV_Freestore(struct object *o) STV_free(o->esidata); o->esidata = NULL; } - VTAILQ_FOREACH_SAFE(st, &o->store, list, stn) { + VTAILQ_FOREACH_SAFE(st, &o->body->list, list, stn) { CHECK_OBJ_NOTNULL(st, STORAGE_MAGIC); - VTAILQ_REMOVE(&o->store, st, list); + VTAILQ_REMOVE(&o->body->list, st, list); STV_free(st); } } diff --git a/bin/varnishd/storage/storage_persistent_silo.c b/bin/varnishd/storage/storage_persistent_silo.c index 5119467..9e747ce 100644 --- a/bin/varnishd/storage/storage_persistent_silo.c +++ b/bin/varnishd/storage/storage_persistent_silo.c @@ -454,7 +454,7 @@ smp_oc_getobj(struct dstat *ds, struct objcore *oc) bad = 0; l = 0; - VTAILQ_FOREACH(st, &o->store, list) { + VTAILQ_FOREACH(st, &o->body->list, list) { bad |= smp_loaded_st(sg->sc, sg, st); if (bad) break; From lkarsten at varnish-software.com Tue Jul 15 12:31:05 2014 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Tue, 15 Jul 2014 14:31:05 +0200 Subject: [master] c55468d Remove nitpicking mode (-n) for sphinx-build. Message-ID: commit c55468d7e619091006b5cbc04836bababcd4fb5b Author: Lasse Karstensen Date: Tue Jul 15 14:28:12 2014 +0200 Remove nitpicking mode (-n) for sphinx-build. sphinx-build v0.6.6 which is on RHEL6/CentOS6 does not know about -n, so we'll have to do without it for now. Reported in: #1535 diff --git a/doc/sphinx/Makefile.am b/doc/sphinx/Makefile.am index f1b9bfc..0d681e8 100644 --- a/doc/sphinx/Makefile.am +++ b/doc/sphinx/Makefile.am @@ -3,7 +3,7 @@ # You can set these variables from the command line. SPHINXOPTS = -SPHINXBUILD = sphinx-build -W -N -n +SPHINXBUILD = sphinx-build -W -N PAPER = a4 BUILDDIR = build From phk at FreeBSD.org Wed Jul 16 09:59:11 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 16 Jul 2014 11:59:11 +0200 Subject: [master] 5eeabe7 BAN_CheckObject() can pretty far with a struct objcore, so postpone the object instantiation until needed. Message-ID: commit 5eeabe7d0313b2b383c7dea8873663ff244da5ed Author: Poul-Henning Kamp Date: Wed Jul 16 09:58:30 2014 +0000 BAN_CheckObject() can pretty far with a struct objcore, so postpone the object instantiation until needed. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index cc91eae..cded88d 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -776,7 +776,7 @@ void BAN_Init(void); void BAN_Shutdown(void); void BAN_NewObjCore(struct objcore *oc); void BAN_DestroyObj(struct objcore *oc); -int BAN_CheckObject(const struct object *o, struct req *sp); +int BAN_CheckObject(struct worker *, struct objcore *, struct req *); void BAN_Reload(const uint8_t *ban, unsigned len); struct ban *BAN_TailRef(void); void BAN_Compile(void); diff --git a/bin/varnishd/cache/cache_ban.c b/bin/varnishd/cache/cache_ban.c index 7388acb..e6c3ced 100644 --- a/bin/varnishd/cache/cache_ban.c +++ b/bin/varnishd/cache/cache_ban.c @@ -899,19 +899,20 @@ ban_evaluate(const uint8_t *bs, const struct http *objhttp, * 1 Ban matched, object removed from ban list. */ -static int -ban_check_object(const struct object *o, struct vsl_log *vsl, - const struct http *req_http) +int +BAN_CheckObject(struct worker *wrk, struct objcore *oc, struct req *req) { struct ban *b; - struct objcore *oc; + struct vsl_log *vsl; + struct object *o; struct ban * volatile b0; unsigned tests; - CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); - CHECK_OBJ_NOTNULL(req_http, HTTP_MAGIC); - oc = o->objcore; CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); + CHECK_OBJ_NOTNULL(req, REQ_MAGIC); + + vsl = req->vsl; + CHECK_OBJ_NOTNULL(oc->ban, BAN_MAGIC); /* First do an optimistic unlocked check */ @@ -929,6 +930,10 @@ ban_check_object(const struct object *o, struct vsl_log *vsl, if (b0 == oc->ban) return (0); + /* Now we need the object */ + o = ObjGetObj(oc, &wrk->stats); + CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); + /* * This loop is safe without locks, because we know we hold * a refcount on a ban somewhere in the list and we do not @@ -939,7 +944,7 @@ ban_check_object(const struct object *o, struct vsl_log *vsl, CHECK_OBJ_NOTNULL(b, BAN_MAGIC); if (b->flags & BANS_FLAG_COMPLETED) continue; - if (ban_evaluate(b->spec, o->http, req_http, &tests)) + if (ban_evaluate(b->spec, o->http, req->http, &tests)) break; } @@ -969,13 +974,6 @@ ban_check_object(const struct object *o, struct vsl_log *vsl, } } -int -BAN_CheckObject(const struct object *o, struct req *req) -{ - - return (ban_check_object(o, req->vsl, req->http) > 0); -} - static void ban_cleantail(void) { diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index c626117..68e0ae1 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -423,11 +423,12 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp, if (oc->exp.ttl <= 0.) continue; + if (BAN_CheckObject(wrk, oc, req)) + continue; + o = ObjGetObj(oc, &wrk->stats); CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); - if (BAN_CheckObject(o, req)) - continue; if (o->vary != NULL && !VRY_Match(req, o->vary)) continue; From phk at FreeBSD.org Thu Jul 17 11:14:11 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 17 Jul 2014 13:14:11 +0200 Subject: [master] f79746c Move bo->failed to the vfp_ctx. Message-ID: commit f79746c9f5ae3b6920b6150af1af5ea975c2d1de Author: Poul-Henning Kamp Date: Thu Jul 17 11:13:25 2014 +0000 Move bo->failed to the vfp_ctx. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index cded88d..a6c7006 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -457,6 +457,8 @@ struct vfp_ctx { #define VFP_CTX_MAGIC 0x61d9d3e5 struct busyobj *bo; + int failed; + struct vfp_entry_s vfp; struct vfp_entry *vfp_nxt; @@ -482,9 +484,8 @@ struct busyobj { uint8_t *vary; - struct vfp_ctx vfc; + struct vfp_ctx vfc[1]; - int failed; enum busyobj_state_e state; struct ws ws[1]; diff --git a/bin/varnishd/cache/cache_esi_fetch.c b/bin/varnishd/cache/cache_esi_fetch.c index cc5f8d6..786d638 100644 --- a/bin/varnishd/cache/cache_esi_fetch.c +++ b/bin/varnishd/cache/cache_esi_fetch.c @@ -101,7 +101,7 @@ vfp_vep_callback(struct busyobj *bo, void *priv, ssize_t l, enum vgz_flag flg) } static enum vfp_status -vfp_esi_end(const struct vfp_ctx *vc, struct vef_priv *vef, +vfp_esi_end(struct vfp_ctx *vc, struct vef_priv *vef, enum vfp_status retval) { struct vsb *vsb; diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 8f967e2..70efc36 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -367,10 +367,10 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo) } else do_ims = 0; - VFP_Setup(&bo->vfc); - bo->vfc.bo = bo; - bo->vfc.http = bo->beresp; - bo->vfc.vsl = bo->vsl; + VFP_Setup(bo->vfc); + bo->vfc->bo = bo; + bo->vfc->http = bo->beresp; + bo->vfc->vsl = bo->vsl; VCL_backend_response_method(bo->vcl, wrk, NULL, bo, bo->beresp->ws); @@ -452,18 +452,18 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) assert(bo->do_gzip == 0 || bo->do_gunzip == 0); if (bo->do_gunzip || (bo->is_gzip && bo->do_esi)) - (void)VFP_Push(&bo->vfc, &vfp_gunzip, 1); + (void)VFP_Push(bo->vfc, &vfp_gunzip, 1); if (bo->do_esi && bo->do_gzip) { - (void)VFP_Push(&bo->vfc, &vfp_esi_gzip, 1); + (void)VFP_Push(bo->vfc, &vfp_esi_gzip, 1); } else if (bo->do_esi && bo->is_gzip && !bo->do_gunzip) { - (void)VFP_Push(&bo->vfc, &vfp_esi_gzip, 1); + (void)VFP_Push(bo->vfc, &vfp_esi_gzip, 1); } else if (bo->do_esi) { - (void)VFP_Push(&bo->vfc, &vfp_esi, 1); + (void)VFP_Push(bo->vfc, &vfp_esi, 1); } else if (bo->do_gzip) { - (void)VFP_Push(&bo->vfc, &vfp_gzip, 1); + (void)VFP_Push(bo->vfc, &vfp_gzip, 1); } else if (bo->is_gzip && !bo->do_gunzip) { - (void)VFP_Push(&bo->vfc, &vfp_testgunzip, 1); + (void)VFP_Push(bo->vfc, &vfp_testgunzip, 1); } if (bo->fetch_objcore->flags & OC_F_PRIVATE) @@ -473,14 +473,14 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) if (bo->htc.body_status == BS_NONE) bo->do_stream = 0; - if (VFP_Open(&bo->vfc)) { - (void)VFP_Error(&bo->vfc, "Fetch Pipeline failed to open"); + if (VFP_Open(bo->vfc)) { + (void)VFP_Error(bo->vfc, "Fetch Pipeline failed to open"); bo->doclose = SC_RX_BODY; return (F_STP_ERROR); } if (vbf_beresp2obj(bo)) { - (void)VFP_Error(&bo->vfc, "Could not get storage"); + (void)VFP_Error(bo->vfc, "Could not get storage"); bo->doclose = SC_RX_BODY; return (F_STP_ERROR); } @@ -520,10 +520,10 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) if (bo->htc.body_status != BS_NONE) { assert(bo->htc.body_status != BS_ERROR); VFP_Fetch_Body(bo); - bo->acct.beresp_bodybytes = bo->vfc.bodybytes; + bo->acct.beresp_bodybytes = bo->vfc->bodybytes; } - if (bo->failed && !bo->do_stream) { + if (bo->vfc->failed && !bo->do_stream) { assert(bo->state < BOS_STREAM); if (bo->fetch_obj != NULL) { ObjFreeObj(bo->fetch_objcore, bo->stats); @@ -532,7 +532,7 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) return (F_STP_ERROR); } - if (bo->failed) + if (bo->vfc->failed) return (F_STP_FAIL); if (bo->do_stream) @@ -633,9 +633,9 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo) if (st->len == st->space) st = NULL; } - } while (!bo->failed && (ois == OIS_DATA || ois == OIS_STREAM)); + } while (!bo->vfc->failed && (ois == OIS_DATA || ois == OIS_STREAM)); ObjIterEnd(&oi); - if (bo->failed) + if (bo->vfc->failed) return (F_STP_FAIL); if (!bo->do_stream) diff --git a/bin/varnishd/cache/cache_fetch_proc.c b/bin/varnishd/cache/cache_fetch_proc.c index 80952c7..e72d74f 100644 --- a/bin/varnishd/cache/cache_fetch_proc.c +++ b/bin/varnishd/cache/cache_fetch_proc.c @@ -53,18 +53,17 @@ static unsigned fetchfrag; */ enum vfp_status -VFP_Error(const struct vfp_ctx *vc, const char *fmt, ...) +VFP_Error(struct vfp_ctx *vc, const char *fmt, ...) { va_list ap; CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC); - CHECK_OBJ_NOTNULL(vc->bo, BUSYOBJ_MAGIC); assert(vc->bo->state >= BOS_REQ_DONE); - if (!vc->bo->failed) { + if (!vc->failed) { va_start(ap, fmt); VSLbv(vc->vsl, SLT_FetchError, fmt, ap); va_end(ap); - vc->bo->failed = 1; + vc->failed = 1; } return (VFP_ERROR); } @@ -96,7 +95,7 @@ VFP_GetStorage(struct busyobj *bo, ssize_t sz) l = cache_param->fetch_chunksize; st = STV_alloc(bo, l); if (st == NULL) { - (void)VFP_Error(&bo->vfc, "Could not get storage"); + (void)VFP_Error(bo->vfc, "Could not get storage"); } else { AZ(st->len); Lck_Lock(&bo->mtx); @@ -201,7 +200,7 @@ VFP_Fetch_Body(struct busyobj *bo) CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); - AN(bo->vfc.vfp_nxt); + AN(bo->vfc->vfp_nxt); est = bo->content_length; if (est < 0) @@ -221,14 +220,14 @@ VFP_Fetch_Body(struct busyobj *bo) bo->doclose = SC_RX_BODY; break; } - AZ(bo->failed); + AZ(bo->vfc->failed); if (st == NULL) { st = VFP_GetStorage(bo, est); est = 0; } if (st == NULL) { bo->doclose = SC_RX_BODY; - (void)VFP_Error(&bo->vfc, "Out of storage"); + (void)VFP_Error(bo->vfc, "Out of storage"); break; } @@ -236,8 +235,8 @@ VFP_Fetch_Body(struct busyobj *bo) assert(st == VTAILQ_LAST(&bo->fetch_obj->body->list, storagehead)); l = st->space - st->len; - AZ(bo->failed); - vfps = VFP_Suck(&bo->vfc, st->ptr + st->len, &l); + AZ(bo->vfc->failed); + vfps = VFP_Suck(bo->vfc, st->ptr + st->len, &l); if (l > 0 && vfps != VFP_ERROR) { AZ(VTAILQ_EMPTY(&bo->fetch_obj->body->list)); VBO_extend(bo, l); @@ -247,12 +246,12 @@ VFP_Fetch_Body(struct busyobj *bo) } while (vfps == VFP_OK); if (vfps == VFP_ERROR) { - AN(bo->failed); - (void)VFP_Error(&bo->vfc, "Fetch Pipeline failed to process"); + AN(bo->vfc->failed); + (void)VFP_Error(bo->vfc, "Fetch Pipeline failed to process"); bo->doclose = SC_RX_BODY; } - vfp_suck_fini(&bo->vfc); + vfp_suck_fini(bo->vfc); if (!bo->do_stream) ObjTrimStore(bo->fetch_objcore, bo->stats); diff --git a/bin/varnishd/cache/cache_filter.h b/bin/varnishd/cache/cache_filter.h index 4065cc7..584bf77 100644 --- a/bin/varnishd/cache/cache_filter.h +++ b/bin/varnishd/cache/cache_filter.h @@ -65,7 +65,7 @@ struct vfp_entry *VFP_Push(struct vfp_ctx *, const struct vfp *, int top); void VFP_Setup(struct vfp_ctx *vc); int VFP_Open(struct vfp_ctx *bo); enum vfp_status VFP_Suck(struct vfp_ctx *, void *p, ssize_t *lp); -enum vfp_status VFP_Error(const struct vfp_ctx *, const char *fmt, ...) +enum vfp_status VFP_Error(struct vfp_ctx *, const char *fmt, ...) __printflike(2, 3); /* Deliver processors ------------------------------------------------*/ diff --git a/bin/varnishd/cache/cache_http1_fetch.c b/bin/varnishd/cache/cache_http1_fetch.c index 1f53747..b622c3c 100644 --- a/bin/varnishd/cache/cache_http1_fetch.c +++ b/bin/varnishd/cache/cache_http1_fetch.c @@ -166,19 +166,19 @@ V1F_Setup_Fetch(struct busyobj *bo) switch(htc->body_status) { case BS_EOF: assert(bo->content_length == -1); - vfe = VFP_Push(&bo->vfc, &v1f_eof, 0); + vfe = VFP_Push(bo->vfc, &v1f_eof, 0); vfe->priv1 = &bo->htc; vfe->priv2 = 0; break; case BS_LENGTH: assert(bo->content_length > 0); - vfe = VFP_Push(&bo->vfc, &v1f_straight, 0); + vfe = VFP_Push(bo->vfc, &v1f_straight, 0); vfe->priv1 = &bo->htc; vfe->priv2 = bo->content_length; break; case BS_CHUNKED: assert(bo->content_length == -1); - vfe = VFP_Push(&bo->vfc, &v1f_chunked, 0); + vfe = VFP_Push(bo->vfc, &v1f_chunked, 0); vfe->priv1 = &bo->htc; vfe->priv2 = -1; break; diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index d59333b..9eed031 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -294,7 +294,7 @@ pan_busyobj(const struct busyobj *bo) pan_ws(bo->ws, 4); VSB_printf(pan_vsp, " refcnt = %u\n", bo->refcount); VSB_printf(pan_vsp, " retries = %d\n", bo->retries); - VSB_printf(pan_vsp, " failed = %d\n", bo->failed); + VSB_printf(pan_vsp, " failed = %d\n", bo->vfc->failed); VSB_printf(pan_vsp, " state = %d\n", (int)bo->state); #define BO_FLAG(l, r, w, d) if(bo->l) VSB_printf(pan_vsp, " is_" #l "\n"); #include "tbl/bo_flags.h" @@ -302,9 +302,9 @@ pan_busyobj(const struct busyobj *bo) VSB_printf(pan_vsp, " bodystatus = %d (%s),\n", bo->htc.body_status, body_status_2str(bo->htc.body_status)); - if (!VTAILQ_EMPTY(&bo->vfc.vfp)) { + if (!VTAILQ_EMPTY(&bo->vfc->vfp)) { VSB_printf(pan_vsp, " filters ="); - VTAILQ_FOREACH(vfe, &bo->vfc.vfp, list) + VTAILQ_FOREACH(vfe, &bo->vfc->vfp, list) VSB_printf(pan_vsp, " %s=%d", vfe->vfp->name, (int)vfe->closed); VSB_printf(pan_vsp, "\n"); From fgsch at lodoss.net Fri Jul 18 18:25:52 2014 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Fri, 18 Jul 2014 20:25:52 +0200 Subject: [master] 87995e4 systemd support for rhel7 Message-ID: commit 87995e47eb0cb78dd95c4f010cacf17d9351ed31 Author: Federico G. Schwindt Date: Fri Jul 18 19:22:29 2014 +0100 systemd support for rhel7 Submitted by: Gauthier Delacroix via github diff --git a/redhat/varnish.spec b/redhat/varnish.spec index de0208e..8b8eaff 100644 --- a/redhat/varnish.spec +++ b/redhat/varnish.spec @@ -37,7 +37,7 @@ Requires(preun): /sbin/service %if %{undefined suse_version} Requires(preun): initscripts %endif -%if 0%{?fedora} >= 17 +%if 0%{?fedora} >= 17 || 0%{?rhel} >= 7 Requires(post): systemd-units Requires(post): systemd-sysv Requires(preun): systemd-units @@ -168,7 +168,7 @@ install -D -m 0644 etc/example.vcl %{buildroot}%{_sysconfdir}/varnish/default.vc install -D -m 0644 redhat/varnish.logrotate %{buildroot}%{_sysconfdir}/logrotate.d/varnish # systemd support -%if 0%{?fedora} >= 17 +%if 0%{?fedora} >= 17 || 0%{?rhel} >= 7 mkdir -p %{buildroot}%{_unitdir} install -D -m 0644 redhat/varnish.service %{buildroot}%{_unitdir}/varnish.service install -D -m 0644 redhat/varnish.params %{buildroot}%{_sysconfdir}/varnish/varnish.params @@ -204,8 +204,8 @@ rm -rf %{buildroot} %config(noreplace) %{_sysconfdir}/varnish/default.vcl %config(noreplace) %{_sysconfdir}/logrotate.d/varnish -# systemd from fedora 17 -%if 0%{?fedora} >= 17 +# systemd from fedora 17 and rhel 7 +%if 0%{?fedora} >= 17 || 0%{?rhel} >= 7 %{_unitdir}/varnish.service %{_unitdir}/varnishncsa.service %{_unitdir}/varnishlog.service @@ -259,7 +259,7 @@ getent passwd varnish >/dev/null || \ exit 0 %post -%if 0%{?fedora} >= 17 +%if 0%{?fedora} >= 17 || 0%{?rhel} >= 7 /bin/systemctl daemon-reload >/dev/null 2>&1 || : %else /sbin/chkconfig --add varnish @@ -284,7 +284,7 @@ test -f /etc/varnish/secret || (uuidgen > /etc/varnish/secret && chmod 0600 /etc %preun if [ $1 -lt 1 ]; then # Package removal, not upgrade - %if 0%{?fedora} >= 17 + %if 0%{?fedora} >= 17 || 0%{?rhel} >= 7 /bin/systemctl --no-reload disable varnish.service > /dev/null 2>&1 || : /bin/systemctl stop varnish.service > /dev/null 2>&1 || : %else From lkarsten at varnish-software.com Tue Jul 22 09:31:36 2014 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Tue, 22 Jul 2014 11:31:36 +0200 Subject: [master] 1213e32 Purge has changed. Message-ID: commit 1213e32235d81bab209a493319528c7c852c6254 Author: Lasse Karstensen Date: Tue Jul 22 11:31:13 2014 +0200 Purge has changed. diff --git a/doc/sphinx/whats-new/upgrading.rst b/doc/sphinx/whats-new/upgrading.rst index 2eeb2f1..cb36b08 100644 --- a/doc/sphinx/whats-new/upgrading.rst +++ b/doc/sphinx/whats-new/upgrading.rst @@ -136,6 +136,12 @@ client.port, and server.port replaced by respectively std.port(client.ip) and st as an IP address by default. You need to use the `std.port()` function to get the port number. +Invalidation with purge +~~~~~~~~~~~~~~~~~~~~~~~ + +Cache invalidation with purges is now done via `return(purge)` from `vcl_recv`. +The `purge;` keyword has been retired. + obj is now read-only ~~~~~~~~~~~~~~~~~~~~ From lkarsten at varnish-software.com Tue Jul 22 09:31:36 2014 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Tue, 22 Jul 2014 11:31:36 +0200 Subject: [master] 5e5d254 Document the new return(retry). Message-ID: commit 5e5d25470863490365c791f13233bb546daab4c6 Author: Lasse Karstensen Date: Tue Jul 22 11:28:22 2014 +0200 Document the new return(retry). Backend restarts are now return(retry). Fixes: #1503 diff --git a/doc/sphinx/whats-new/upgrading.rst b/doc/sphinx/whats-new/upgrading.rst index f48548f..2eeb2f1 100644 --- a/doc/sphinx/whats-new/upgrading.rst +++ b/doc/sphinx/whats-new/upgrading.rst @@ -158,6 +158,18 @@ following has changed: - `vcl_hash` must now return `lookup` instead of `hash` - `vcl_pass` must now return `fetch` instead of `pass` + +Backend restarts are now retry +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +In 3.0 it was possible to do `return(restart)` after noticing that +the backend response was wrong, to change to a different backend. + +This is now called `return(retry)`, and jumps back up to `vcl_backend_fetch`. + +This only influences the backend fetch thread, client-side handling is not affected. + + default/builtin VCL changes ~~~~~~~~~~~~~~~~~~~~~~~~~~~ From lkarsten at varnish-software.com Tue Jul 22 11:13:23 2014 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Tue, 22 Jul 2014 13:13:23 +0200 Subject: [master] 81e52dc Non-breaking space broke the control sequence. Message-ID: commit 81e52dcdf442a4c932ddb2c7af2da85d68ab32f0 Author: Lasse Karstensen Date: Tue Jul 22 13:10:42 2014 +0200 Non-breaking space broke the control sequence. diff --git a/redhat/varnish.initrc b/redhat/varnish.initrc index 0db3ab6..082c770 100755 --- a/redhat/varnish.initrc +++ b/redhat/varnish.initrc @@ -61,7 +61,7 @@ start() { ulimit -u ${NPROCS:-unlimited} # If defined, set maximum core size. - if [ -n?"${DAEMON_COREFILE_LIMIT}" ] + if [ -n "${DAEMON_COREFILE_LIMIT}" ] then ulimit -c ${DAEMON_COREFILE_LIMIT} fi From phk at FreeBSD.org Tue Jul 22 13:46:08 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 22 Jul 2014 15:46:08 +0200 Subject: [master] cfb309c Add a VXID() macro to strip client/backend bit from VXIDs. Message-ID: commit cfb309cad60e0239bc7168082d73b4ab6b53744a Author: Poul-Henning Kamp Date: Tue Jul 22 13:45:45 2014 +0000 Add a VXID() macro to strip client/backend bit from VXIDs. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index a6c7006..45f2713 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -992,6 +992,7 @@ unsigned HTTP1_Write(const struct worker *w, const struct http *hp, const int*); #undef HTTPH /* cache_main.c */ +#define VXID(u) ((u) & VSL_IDENTMASK) uint32_t VXID_Get(struct vxid_pool *v); extern volatile struct params * cache_param; void THR_SetName(const char *name); diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index 19326e9..0d72714 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -63,8 +63,8 @@ ved_include(struct req *preq, const char *src, const char *host) req = SES_GetReq(wrk, preq->sp); req->req_body_status = REQ_BODY_NONE; AN(req->vsl->wid & VSL_CLIENTMARKER); - VSLb(req->vsl, SLT_Begin, "req %u esi", preq->vsl->wid & VSL_IDENTMASK); - VSLb(preq->vsl, SLT_Link, "req %u esi", req->vsl->wid & VSL_IDENTMASK); + VSLb(req->vsl, SLT_Begin, "req %u esi", VXID(preq->vsl->wid)); + VSLb(preq->vsl, SLT_Link, "req %u esi", VXID(req->vsl->wid)); req->esi_level = preq->esi_level + 1; HTTP_Copy(req->http0, preq->http0); diff --git a/bin/varnishd/cache/cache_expire.c b/bin/varnishd/cache/cache_expire.c index dd3ed1a..6cea948 100644 --- a/bin/varnishd/cache/cache_expire.c +++ b/bin/varnishd/cache/cache_expire.c @@ -340,8 +340,7 @@ EXP_NukeOne(struct busyobj *bo, struct lru *lru) exp_mail_it(oc); - VSLb(bo->vsl, SLT_ExpKill, "LRU x=%u", - ObjGetXID(oc, bo->stats) & VSL_IDENTMASK); + VSLb(bo->vsl, SLT_ExpKill, "LRU x=%u", VXID(ObjGetXID(oc, bo->stats))); AN(bo->stats); AN(oc); (void)HSH_DerefObjCore(bo->stats, &oc); @@ -473,7 +472,7 @@ exp_expire(struct exp_priv *ep, double now) o = ObjGetObj(oc, &ep->wrk->stats); CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); VSLb(&ep->vsl, SLT_ExpKill, "EXP_Expired x=%u t=%.0f", - ObjGetXID(oc, &ep->wrk->stats) & VSL_IDENTMASK, + VXID(ObjGetXID(oc, &ep->wrk->stats)), EXP_Ttl(NULL, &oc->exp) - now); (void)HSH_DerefObjCore(&ep->wrk->stats, &oc); return (0); diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 70efc36..1db32b4 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -238,7 +238,7 @@ vbf_stp_retry(struct worker *wrk, struct busyobj *bo) VSLb(bo->vsl, SLT_Link, "bereq %u retry", wid); VSLb(bo->vsl, SLT_End, "%s", ""); VSL_Flush(bo->vsl, 0); - owid = bo->vsl->wid & VSL_IDENTMASK; + owid = VXID(bo->vsl->wid); bo->vsl->wid = wid | VSL_BACKENDMARKER; VSLb(bo->vsl, SLT_Begin, "bereq %u retry", owid); VSLb_ts_busyobj(bo, "Start", bo->t_prev); @@ -272,8 +272,7 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo) HTTP_Setup(bo->bereq, bo->ws, bo->vsl, SLT_BereqMethod); HTTP_Copy(bo->bereq, bo->bereq0); - http_PrintfHeader(bo->bereq, - "X-Varnish: %u", bo->vsl->wid & VSL_IDENTMASK); + http_PrintfHeader(bo->bereq, "X-Varnish: %u", VXID(bo->vsl->wid)); VCL_backend_fetch_method(bo->vcl, wrk, NULL, bo, bo->bereq->ws); @@ -871,10 +870,8 @@ VBF_Fetch(struct worker *wrk, struct req *req, struct objcore *oc, default: WRONG("Wrong fetch mode"); } - VSLb(bo->vsl, SLT_Begin, "bereq %u %s ", - req->vsl->wid & VSL_IDENTMASK, how); - VSLb(req->vsl, SLT_Link, "bereq %u %s ", - bo->vsl->wid & VSL_IDENTMASK, how); + VSLb(bo->vsl, SLT_Begin, "bereq %u %s ", VXID(req->vsl->wid), how); + VSLb(req->vsl, SLT_Link, "bereq %u %s ", VXID(bo->vsl->wid), how); bo->refcount = 2; diff --git a/bin/varnishd/cache/cache_http1_fsm.c b/bin/varnishd/cache/cache_http1_fsm.c index 049ca68..6fd2a8d 100644 --- a/bin/varnishd/cache/cache_http1_fsm.c +++ b/bin/varnishd/cache/cache_http1_fsm.c @@ -246,10 +246,9 @@ http1_cleanup(struct sess *sp, struct worker *wrk, struct req *req) if (HTTP1_Reinit(req->htc) == HTTP1_COMPLETE) { AZ(req->vsl->wid); req->vsl->wid = VXID_Get(&wrk->vxid_pool) | VSL_CLIENTMARKER; - VSLb(req->vsl, SLT_Begin, "req %u rxreq", - req->sp->vxid & VSL_IDENTMASK); + VSLb(req->vsl, SLT_Begin, "req %u rxreq", VXID(req->sp->vxid)); VSL(SLT_Link, req->sp->vxid, "req %u rxreq", - req->vsl->wid & VSL_IDENTMASK); + VXID(req->vsl->wid)); VSLb_ts_req(req, "Start", sp->t_idle); VSLb_ts_req(req, "Req", sp->t_idle); req->t_req = req->t_prev; @@ -318,10 +317,9 @@ http1_dissect(struct worker *wrk, struct req *req) */ if (req->vsl->wid == 0) { req->vsl->wid = VXID_Get(&wrk->vxid_pool) | VSL_CLIENTMARKER; - VSLb(req->vsl, SLT_Begin, "req %u rxreq", - req->sp->vxid & VSL_IDENTMASK); + VSLb(req->vsl, SLT_Begin, "req %u rxreq", VXID(req->sp->vxid)); VSL(SLT_Link, req->sp->vxid, "req %u rxreq", - req->vsl->wid & VSL_IDENTMASK); + VXID(req->vsl->wid)); } /* Borrow VCL reference from worker thread */ diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index 9eed031..7d7d10b 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -391,7 +391,7 @@ pan_sess(const struct sess *sp) VSB_printf(pan_vsp, " sp = %p {\n", sp); VSB_printf(pan_vsp, " fd = %d, vxid = %u,\n", - sp->fd, sp->vxid & VSL_IDENTMASK); + sp->fd, VXID(sp->vxid)); VSB_printf(pan_vsp, " client = %s %s,\n", sp->client_addr_str, sp->client_port_str); switch (sp->sess_step) { diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index ebace03..c00559b 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -108,11 +108,11 @@ cnt_deliver(struct worker *wrk, struct req *req) if (req->wrk->stats.cache_hit) http_PrintfHeader(req->resp, - "X-Varnish: %u %u", req->vsl->wid & VSL_IDENTMASK, - req->obj->vxid & VSL_IDENTMASK); + "X-Varnish: %u %u", VXID(req->vsl->wid), + VXID(req->obj->vxid)); else http_PrintfHeader(req->resp, - "X-Varnish: %u", req->vsl->wid & VSL_IDENTMASK); + "X-Varnish: %u", VXID(req->vsl->wid)); /* We base Age calculation upon the last timestamp taken during client request processing. This gives some inaccuracy, but @@ -221,8 +221,7 @@ cnt_synth(struct worker *wrk, struct req *req) VTIM_format(now, date); http_PrintfHeader(h, "Date: %s", date); http_SetHeader(h, "Server: Varnish"); - http_PrintfHeader(req->resp, - "X-Varnish: %u", req->vsl->wid & VSL_IDENTMASK); + http_PrintfHeader(req->resp, "X-Varnish: %u", VXID(req->vsl->wid)); http_PutResponse(h, "HTTP/1.1", req->err_code, req->err_reason); AZ(req->synth_body); @@ -599,10 +598,9 @@ cnt_pipe(struct worker *wrk, struct req *req) wrk->stats.s_pipe++; bo = VBO_GetBusyObj(wrk, req); HTTP_Setup(bo->bereq, bo->ws, bo->vsl, SLT_BereqMethod); - VSLb(bo->vsl, SLT_Begin, "bereq %u pipe", req->vsl->wid & VSL_IDENTMASK); + VSLb(bo->vsl, SLT_Begin, "bereq %u pipe", VXID(req->vsl->wid)); http_FilterReq(bo->bereq, req->http, 0); // XXX: 0 ? - http_PrintfHeader(bo->bereq, - "X-Varnish: %u", req->vsl->wid & VSL_IDENTMASK); + http_PrintfHeader(bo->bereq, "X-Varnish: %u", VXID(req->vsl->wid)); http_SetHeader(bo->bereq, "Connection: close"); VCL_pipe_method(req->vcl, wrk, req, bo, req->http->ws); @@ -611,7 +609,7 @@ cnt_pipe(struct worker *wrk, struct req *req) INCOMPL(); assert(wrk->handling == VCL_RET_PIPE); - VSLb(req->vsl, SLT_Link, "bereq %u pipe", bo->vsl->wid & VSL_IDENTMASK); + VSLb(req->vsl, SLT_Link, "bereq %u pipe", VXID(bo->vsl->wid)); PipeRequest(req, bo); assert(WRW_IsReleased(wrk)); http_Teardown(bo->bereq); diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c index 5b8a843..786a26e 100644 --- a/bin/varnishd/cache/cache_session.c +++ b/bin/varnishd/cache/cache_session.c @@ -134,8 +134,8 @@ ses_sess_pool_task(struct worker *wrk, void *arg) req = SES_GetReq(wrk, sp); CHECK_OBJ_NOTNULL(req, REQ_MAGIC); AN(req->vsl->wid & VSL_CLIENTMARKER); - VSLb(req->vsl, SLT_Begin, "req %u rxreq", sp->vxid & VSL_IDENTMASK); - VSL(SLT_Link, sp->vxid, "req %u rxreq", req->vsl->wid & VSL_IDENTMASK); + VSLb(req->vsl, SLT_Begin, "req %u rxreq", VXID(sp->vxid)); + VSL(SLT_Link, sp->vxid, "req %u rxreq", VXID(req->vsl->wid)); sp->sess_step = S_STP_NEWREQ; ses_req_pool_task(wrk, req); diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index 28b131f..6796d8c 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -504,8 +504,7 @@ VRT_r_req_xid(const struct vrt_ctx *ctx) CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); - return (WS_Printf(ctx->req->http->ws, "%u", - ctx->req->vsl->wid & VSL_IDENTMASK)); + return (WS_Printf(ctx->req->http->ws, "%u", VXID(ctx->req->vsl->wid))); } const char * @@ -515,8 +514,7 @@ VRT_r_bereq_xid(const struct vrt_ctx *ctx) CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC); - return (WS_Printf(ctx->bo->bereq->ws, "%u", - ctx->bo->vsl->wid & VSL_IDENTMASK)); + return (WS_Printf(ctx->bo->bereq->ws, "%u", VXID(ctx->bo->vsl->wid))); } /*--------------------------------------------------------------------*/ From phk at FreeBSD.org Tue Jul 22 13:57:33 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 22 Jul 2014 15:57:33 +0200 Subject: [master] 787795e Add VSL_End() function to make closedown of cached VSLs consistent Message-ID: commit 787795e5fe795a39ac576ce91b34fc8f9bd11361 Author: Poul-Henning Kamp Date: Tue Jul 22 13:57:12 2014 +0000 Add VSL_End() function to make closedown of cached VSLs consistent diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 45f2713..833e8a0 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -1097,6 +1097,7 @@ void VSM_Init(void); void *VSM_Alloc(unsigned size, const char *class, const char *type, const char *ident); void VSL_Setup(struct vsl_log *vsl, void *ptr, size_t len); +void VSL_End(struct vsl_log *vsl); void VSM_Free(void *ptr); #ifdef VSL_ENDMARKER void VSL(enum VSL_tag_e tag, uint32_t vxid, const char *fmt, ...) diff --git a/bin/varnishd/cache/cache_busyobj.c b/bin/varnishd/cache/cache_busyobj.c index d0ec1d2..a3fc0b9 100644 --- a/bin/varnishd/cache/cache_busyobj.c +++ b/bin/varnishd/cache/cache_busyobj.c @@ -195,8 +195,7 @@ VBO_DerefBusyObj(struct worker *wrk, struct busyobj **pbo) (uintmax_t)bo->acct.beresp_bodybytes, (uintmax_t)(bo->acct.beresp_hdrbytes + bo->acct.beresp_bodybytes)); - VSLb(bo->vsl, SLT_End, "%s", ""); - VSL_Flush(bo->vsl, 0); + VSL_End(bo->vsl); if (bo->fetch_objcore != NULL) { AN(wrk); diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index 0d72714..df87210 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -126,11 +126,7 @@ ved_include(struct req *preq, const char *src, const char *host) } AN(WRW_IsReleased(wrk)); - /* Flush and release the log */ - AN(req->vsl->wid); - VSLb(req->vsl, SLT_End, "%s", ""); - VSL_Flush(req->vsl, 0); - req->vsl->wid = 0; + VSL_End(req->vsl); /* Charge the transmitted body byte counts to the parent request */ preq->acct.resp_bodybytes += req->acct.resp_bodybytes; diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 1db32b4..859a53c 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -236,9 +236,8 @@ vbf_stp_retry(struct worker *wrk, struct busyobj *bo) // XXX: BereqEnd + BereqAcct ? wid = VXID_Get(&wrk->vxid_pool); VSLb(bo->vsl, SLT_Link, "bereq %u retry", wid); - VSLb(bo->vsl, SLT_End, "%s", ""); - VSL_Flush(bo->vsl, 0); owid = VXID(bo->vsl->wid); + VSL_End(bo->vsl); bo->vsl->wid = wid | VSL_BACKENDMARKER; VSLb(bo->vsl, SLT_Begin, "bereq %u retry", owid); VSLb_ts_busyobj(bo, "Start", bo->t_prev); diff --git a/bin/varnishd/cache/cache_http1_fsm.c b/bin/varnishd/cache/cache_http1_fsm.c index 6fd2a8d..031be54 100644 --- a/bin/varnishd/cache/cache_http1_fsm.c +++ b/bin/varnishd/cache/cache_http1_fsm.c @@ -210,11 +210,7 @@ http1_cleanup(struct sess *sp, struct worker *wrk, struct req *req) req->resp_hdrbytes = 0; req->resp_bodybytes = 0; - /* Nuke the VXID. http1_dissect() will allocate a new one when - necessary */ - VSLb(req->vsl, SLT_End, "%s", ""); - VSL_Flush(req->vsl, 0); - req->vsl->wid = 0; + VSL_End(req->vsl); if (!isnan(req->t_prev) && req->t_prev > 0.) sp->t_idle = req->t_prev; diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index c00559b..146661f 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -649,9 +649,8 @@ cnt_restart(struct worker *wrk, struct req *req) // XXX: ReqEnd + ReqAcct ? VSLb_ts_req(req, "Restart", W_TIM_real(wrk)); VSLb(req->vsl, SLT_Link, "req %u restart", wid); - VSLb(req->vsl, SLT_End, "%s", ""); - VSL_Flush(req->vsl, 0); owid = req->vsl->wid & VSL_IDENTMASK; + VSL_End(req->vsl); req->vsl->wid = wid | VSL_CLIENTMARKER; VSLb(req->vsl, SLT_Begin, "req %u restart", owid); VSLb_ts_req(req, "Start", req->t_prev); diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c index 786a26e..a58aa24 100644 --- a/bin/varnishd/cache/cache_session.c +++ b/bin/varnishd/cache/cache_session.c @@ -398,6 +398,7 @@ SES_ReleaseReq(struct req *req) #undef ACCT AZ(req->vcl); + AZ(req->vsl->wid); sp = req->sp; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); pp = sp->sesspool; @@ -405,9 +406,6 @@ SES_ReleaseReq(struct req *req) AN(pp->pool); CHECK_OBJ_NOTNULL(req, REQ_MAGIC); MPL_AssertSane(req); - if (req->vsl->wid != 0) - /* Non-released VXID - assume it was from a req */ - VSLb(req->vsl, SLT_End, "%s", ""); VSL_Flush(req->vsl, 0); req->sp = NULL; MPL_Free(pp->mpl_req, req); diff --git a/bin/varnishd/cache/cache_shmlog.c b/bin/varnishd/cache/cache_shmlog.c index d0733d7..eb70686 100644 --- a/bin/varnishd/cache/cache_shmlog.c +++ b/bin/varnishd/cache/cache_shmlog.c @@ -388,6 +388,22 @@ VSL_Setup(struct vsl_log *vsl, void *ptr, size_t len) /*--------------------------------------------------------------------*/ +void +VSL_End(struct vsl_log *vsl) +{ + txt t; + char p[] = ""; + + AN(vsl->wid); + t.b = p; + t.e = p; + VSLbt(vsl, SLT_End, t); + VSL_Flush(vsl, 0); + vsl->wid = 0; +} + +/*--------------------------------------------------------------------*/ + static void * vsm_cleaner(void *priv) { From phk at FreeBSD.org Tue Jul 22 14:15:10 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 22 Jul 2014 16:15:10 +0200 Subject: [master] 47d948d Add VSL_ChgId() to do the VSL dance and song for restart/retry Message-ID: commit 47d948d04e78aea4d8fb948057a5d79340a2d4a8 Author: Poul-Henning Kamp Date: Tue Jul 22 14:14:41 2014 +0000 Add VSL_ChgId() to do the VSL dance and song for restart/retry diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 833e8a0..84f8c51 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -1097,6 +1097,8 @@ void VSM_Init(void); void *VSM_Alloc(unsigned size, const char *class, const char *type, const char *ident); void VSL_Setup(struct vsl_log *vsl, void *ptr, size_t len); +void VSL_ChgId(struct vsl_log *vsl, const char *typ, const char *why, + uint32_t vxid); void VSL_End(struct vsl_log *vsl); void VSM_Free(void *ptr); #ifdef VSL_ENDMARKER diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 859a53c..c06b1ec 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -226,7 +226,6 @@ vbf_stp_mkbereq(const struct worker *wrk, struct busyobj *bo) static enum fetch_step vbf_stp_retry(struct worker *wrk, struct busyobj *bo) { - unsigned owid, wid; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); @@ -234,12 +233,8 @@ vbf_stp_retry(struct worker *wrk, struct busyobj *bo) VSLb_ts_busyobj(bo, "Retry", W_TIM_real(wrk)); // XXX: BereqEnd + BereqAcct ? - wid = VXID_Get(&wrk->vxid_pool); - VSLb(bo->vsl, SLT_Link, "bereq %u retry", wid); - owid = VXID(bo->vsl->wid); - VSL_End(bo->vsl); - bo->vsl->wid = wid | VSL_BACKENDMARKER; - VSLb(bo->vsl, SLT_Begin, "bereq %u retry", owid); + VSL_ChgId(bo->vsl, "bereq", "retry", + VXID_Get(&wrk->vxid_pool) | VSL_BACKENDMARKER); VSLb_ts_busyobj(bo, "Start", bo->t_prev); return (F_STP_STARTFETCH); diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 146661f..f613c5c 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -634,7 +634,6 @@ DOT err_restart [label="SYNTH",shape=plaintext] static enum req_fsm_nxt cnt_restart(struct worker *wrk, struct req *req) { - unsigned wid, owid; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(req, REQ_MAGIC); @@ -645,14 +644,10 @@ cnt_restart(struct worker *wrk, struct req *req) req->err_code = 503; req->req_step = R_STP_SYNTH; } else { - wid = VXID_Get(&wrk->vxid_pool); // XXX: ReqEnd + ReqAcct ? VSLb_ts_req(req, "Restart", W_TIM_real(wrk)); - VSLb(req->vsl, SLT_Link, "req %u restart", wid); - owid = req->vsl->wid & VSL_IDENTMASK; - VSL_End(req->vsl); - req->vsl->wid = wid | VSL_CLIENTMARKER; - VSLb(req->vsl, SLT_Begin, "req %u restart", owid); + VSL_ChgId(req->vsl, "req", "restart", + VXID_Get(&wrk->vxid_pool) | VSL_CLIENTMARKER); VSLb_ts_req(req, "Start", req->t_prev); req->err_code = 0; req->req_step = R_STP_RECV; diff --git a/bin/varnishd/cache/cache_shmlog.c b/bin/varnishd/cache/cache_shmlog.c index eb70686..7eba6ac 100644 --- a/bin/varnishd/cache/cache_shmlog.c +++ b/bin/varnishd/cache/cache_shmlog.c @@ -389,6 +389,20 @@ VSL_Setup(struct vsl_log *vsl, void *ptr, size_t len) /*--------------------------------------------------------------------*/ void +VSL_ChgId(struct vsl_log *vsl, const char *typ, const char *why, uint32_t vxid) +{ + uint32_t ovxid; + + ovxid = vsl->wid; + VSLb(vsl, SLT_Link, "%s %u %s", typ, VXID(vxid), why); + VSL_End(vsl); + vsl->wid = vxid; + VSLb(vsl, SLT_Begin, "%s %u %s", typ, VXID(ovxid), why); +} + +/*--------------------------------------------------------------------*/ + +void VSL_End(struct vsl_log *vsl) { txt t; From phk at FreeBSD.org Tue Jul 22 14:36:55 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 22 Jul 2014 16:36:55 +0200 Subject: [master] 3469a4c Improve args to VXID_Get() Message-ID: commit 3469a4c1296d70525d5e88c423acdcb6e9eb7154 Author: Poul-Henning Kamp Date: Tue Jul 22 14:36:41 2014 +0000 Improve args to VXID_Get() diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 84f8c51..53b7c78 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -993,7 +993,7 @@ unsigned HTTP1_Write(const struct worker *w, const struct http *hp, const int*); /* cache_main.c */ #define VXID(u) ((u) & VSL_IDENTMASK) -uint32_t VXID_Get(struct vxid_pool *v); +uint32_t VXID_Get(struct worker *, uint32_t marker); extern volatile struct params * cache_param; void THR_SetName(const char *name); const char* THR_GetName(void); diff --git a/bin/varnishd/cache/cache_busyobj.c b/bin/varnishd/cache/cache_busyobj.c index a3fc0b9..17874f1 100644 --- a/bin/varnishd/cache/cache_busyobj.c +++ b/bin/varnishd/cache/cache_busyobj.c @@ -135,7 +135,7 @@ VBO_GetBusyObj(struct worker *wrk, const struct req *req) sz = cache_param->vsl_buffer; VSL_Setup(bo->vsl, p, sz); - bo->vsl->wid = VXID_Get(&wrk->vxid_pool) | VSL_BACKENDMARKER; + bo->vsl->wid = VXID_Get(wrk, VSL_BACKENDMARKER); p += sz; p = (void*)PRNDUP(p); assert(p < bo->end); diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index c06b1ec..11b15f5 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -233,8 +233,7 @@ vbf_stp_retry(struct worker *wrk, struct busyobj *bo) VSLb_ts_busyobj(bo, "Retry", W_TIM_real(wrk)); // XXX: BereqEnd + BereqAcct ? - VSL_ChgId(bo->vsl, "bereq", "retry", - VXID_Get(&wrk->vxid_pool) | VSL_BACKENDMARKER); + VSL_ChgId(bo->vsl, "bereq", "retry", VXID_Get(wrk, VSL_BACKENDMARKER)); VSLb_ts_busyobj(bo, "Start", bo->t_prev); return (F_STP_STARTFETCH); diff --git a/bin/varnishd/cache/cache_http1_fsm.c b/bin/varnishd/cache/cache_http1_fsm.c index 031be54..4139bca 100644 --- a/bin/varnishd/cache/cache_http1_fsm.c +++ b/bin/varnishd/cache/cache_http1_fsm.c @@ -241,7 +241,7 @@ http1_cleanup(struct sess *sp, struct worker *wrk, struct req *req) if (HTTP1_Reinit(req->htc) == HTTP1_COMPLETE) { AZ(req->vsl->wid); - req->vsl->wid = VXID_Get(&wrk->vxid_pool) | VSL_CLIENTMARKER; + req->vsl->wid = VXID_Get(wrk, VSL_CLIENTMARKER); VSLb(req->vsl, SLT_Begin, "req %u rxreq", VXID(req->sp->vxid)); VSL(SLT_Link, req->sp->vxid, "req %u rxreq", VXID(req->vsl->wid)); @@ -312,7 +312,7 @@ http1_dissect(struct worker *wrk, struct req *req) * Allocate a new one only now that we know will need it. */ if (req->vsl->wid == 0) { - req->vsl->wid = VXID_Get(&wrk->vxid_pool) | VSL_CLIENTMARKER; + req->vsl->wid = VXID_Get(wrk, VSL_CLIENTMARKER); VSLb(req->vsl, SLT_Begin, "req %u rxreq", VXID(req->sp->vxid)); VSL(SLT_Link, req->sp->vxid, "req %u rxreq", VXID(req->vsl->wid)); diff --git a/bin/varnishd/cache/cache_main.c b/bin/varnishd/cache/cache_main.c index 31d167d..665a024 100644 --- a/bin/varnishd/cache/cache_main.c +++ b/bin/varnishd/cache/cache_main.c @@ -116,8 +116,13 @@ static uint32_t vxid_chunk = 32768; static struct lock vxid_lock; uint32_t -VXID_Get(struct vxid_pool *v) +VXID_Get(struct worker *wrk, uint32_t mask) { + struct vxid_pool *v; + + CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); + v = &wrk->vxid_pool; + AZ(VXID(mask)); do { if (v->count == 0) { Lck_Lock(&vxid_lock); @@ -129,7 +134,7 @@ VXID_Get(struct vxid_pool *v) v->count--; v->next++; } while (v->next == 0); - return (v->next); + return (v->next | mask); } /*-------------------------------------------------------------------- diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index f613c5c..4987bda 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -647,7 +647,7 @@ cnt_restart(struct worker *wrk, struct req *req) // XXX: ReqEnd + ReqAcct ? VSLb_ts_req(req, "Restart", W_TIM_real(wrk)); VSL_ChgId(req->vsl, "req", "restart", - VXID_Get(&wrk->vxid_pool) | VSL_CLIENTMARKER); + VXID_Get(wrk, VSL_CLIENTMARKER)); VSLb_ts_req(req, "Start", req->t_prev); req->err_code = 0; req->req_step = R_STP_RECV; diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c index a58aa24..2aaf632 100644 --- a/bin/varnishd/cache/cache_session.c +++ b/bin/varnishd/cache/cache_session.c @@ -207,7 +207,7 @@ SES_pool_accept_task(struct worker *wrk, void *arg) sp->t_open = VTIM_real(); sp->t_idle = sp->t_open; - sp->vxid = VXID_Get(&wrk->vxid_pool) | VSL_CLIENTMARKER; + sp->vxid = VXID_Get(wrk, VSL_CLIENTMARKER); lsockname = VCA_SetupSess(wrk, sp); ses_vsl_socket(sp, lsockname); @@ -362,7 +362,7 @@ SES_GetReq(struct worker *wrk, struct sess *sp) sz = cache_param->vsl_buffer; VSL_Setup(req->vsl, p, sz); - req->vsl->wid = VXID_Get(&wrk->vxid_pool) | VSL_CLIENTMARKER; + req->vsl->wid = VXID_Get(wrk, VSL_CLIENTMARKER); p += sz; p = (void*)PRNDUP(p); From phk at FreeBSD.org Tue Jul 22 14:49:18 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 22 Jul 2014 16:49:18 +0200 Subject: [master] e8641aa Add some missing housekeeping for pipe Message-ID: commit e8641aaca3ab966421e2b37c9f91b12211fa7f2d Author: Poul-Henning Kamp Date: Tue Jul 22 14:49:04 2014 +0000 Add some missing housekeeping for pipe diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 11b15f5..97718bf 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -852,9 +852,6 @@ VBF_Fetch(struct worker *wrk, struct req *req, struct objcore *oc, CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); CHECK_OBJ_ORNULL(oldobj, OBJECT_MAGIC); - bo = VBO_GetBusyObj(wrk, req); - CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); - THR_SetBusyobj(bo); switch(mode) { case VBF_PASS: how = "pass"; break; @@ -863,9 +860,13 @@ VBF_Fetch(struct worker *wrk, struct req *req, struct objcore *oc, default: WRONG("Wrong fetch mode"); } + bo = VBO_GetBusyObj(wrk, req); + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); VSLb(bo->vsl, SLT_Begin, "bereq %u %s ", VXID(req->vsl->wid), how); VSLb(req->vsl, SLT_Link, "bereq %u %s ", VXID(bo->vsl->wid), how); + THR_SetBusyobj(bo); + bo->refcount = 2; oc->busyobj = bo; diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 4987bda..8542b31 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -597,11 +597,16 @@ cnt_pipe(struct worker *wrk, struct req *req) wrk->stats.s_pipe++; bo = VBO_GetBusyObj(wrk, req); - HTTP_Setup(bo->bereq, bo->ws, bo->vsl, SLT_BereqMethod); + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); VSLb(bo->vsl, SLT_Begin, "bereq %u pipe", VXID(req->vsl->wid)); + VSLb(req->vsl, SLT_Link, "bereq %u pipe", VXID(bo->vsl->wid)); + THR_SetBusyobj(bo); + + HTTP_Setup(bo->bereq, bo->ws, bo->vsl, SLT_BereqMethod); http_FilterReq(bo->bereq, req->http, 0); // XXX: 0 ? http_PrintfHeader(bo->bereq, "X-Varnish: %u", VXID(req->vsl->wid)); http_SetHeader(bo->bereq, "Connection: close"); + VCL_pipe_method(req->vcl, wrk, req, bo, req->http->ws); @@ -613,6 +618,7 @@ cnt_pipe(struct worker *wrk, struct req *req) PipeRequest(req, bo); assert(WRW_IsReleased(wrk)); http_Teardown(bo->bereq); + THR_SetBusyobj(NULL); VBO_DerefBusyObj(wrk, &bo); return (REQ_FSM_DONE); } From phk at FreeBSD.org Tue Jul 22 15:13:25 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 22 Jul 2014 17:13:25 +0200 Subject: [master] 108276a Strip marker bits from vxids Message-ID: commit 108276a12963b2a8de7ff16a821c83dda6c76835 Author: Poul-Henning Kamp Date: Tue Jul 22 15:08:41 2014 +0000 Strip marker bits from vxids diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index 7d7d10b..4e11fe6 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -215,7 +215,7 @@ pan_object(const char *typ, const struct object *o) const struct storage *st; VSB_printf(pan_vsp, " obj (%s) = %p {\n", typ, o); - VSB_printf(pan_vsp, " vxid = %u,\n", o->vxid); + VSB_printf(pan_vsp, " vxid = %u,\n", VXID(o->vxid)); pan_http("obj", o->http, 4); VSB_printf(pan_vsp, " len = %jd,\n", (intmax_t)o->len); VSB_printf(pan_vsp, " store = {\n"); @@ -335,7 +335,8 @@ pan_req(const struct req *req) VSB_printf(pan_vsp, "req = %p {\n", req); - VSB_printf(pan_vsp, " sp = %p, vxid = %u,", req->sp, req->vsl->wid); + VSB_printf(pan_vsp, " sp = %p, vxid = %u,", + req->sp, VXID(req->vsl->wid)); switch (req->req_step) { #define REQ_STEP(l, u, arg) case R_STP_##u: stp = "R_STP_" #u; break; From phk at FreeBSD.org Tue Jul 22 15:13:25 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 22 Jul 2014 17:13:25 +0200 Subject: [master] ac4e79e Move some args from busyobj to vfp_ctx Message-ID: commit ac4e79e5ec3d037bfe0c009dd53d266368d1108d Author: Poul-Henning Kamp Date: Tue Jul 22 15:09:03 2014 +0000 Move some args from busyobj to vfp_ctx diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 53b7c78..8a3d0ae 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -897,7 +897,7 @@ void VBF_Fetch(struct worker *wrk, struct req *req, struct objcore *oc, struct object *oldobj, enum vbf_fetch_mode_e); /* cache_fetch_proc.c */ -struct storage *VFP_GetStorage(struct busyobj *, ssize_t sz); +struct storage *VFP_GetStorage(struct vfp_ctx *, ssize_t sz); void VFP_Init(void); void VFP_Fetch_Body(struct busyobj *bo); @@ -1211,7 +1211,7 @@ void RFC2616_Weaken_Etag(struct http *hp); /* stevedore.c */ struct object *STV_NewObject(struct busyobj *, const char *hint, unsigned len, uint16_t nhttp); -struct storage *STV_alloc(struct busyobj *, size_t size); +struct storage *STV_alloc(const struct vfp_ctx *, size_t size); void STV_trim(struct storage *st, size_t size, int move_ok); void STV_free(struct storage *st); void STV_open(void); diff --git a/bin/varnishd/cache/cache_esi_fetch.c b/bin/varnishd/cache/cache_esi_fetch.c index 786d638..c4bcef9 100644 --- a/bin/varnishd/cache/cache_esi_fetch.c +++ b/bin/varnishd/cache/cache_esi_fetch.c @@ -83,7 +83,7 @@ vfp_vep_callback(struct busyobj *bo, void *priv, ssize_t l, enum vgz_flag flg) VGZ_Ibuf(vef->vgz, vef->ibuf_o, l); do { - st = VFP_GetStorage(bo, 0); + st = VFP_GetStorage(bo->vfc, 0); if (st == NULL) { vef->error = ENOMEM; vef->tot += l; @@ -118,7 +118,7 @@ vfp_esi_end(struct vfp_ctx *vc, struct vef_priv *vef, l = VSB_len(vsb); assert(l > 0); /* XXX: This is a huge waste of storage... */ - vc->bo->fetch_obj->esidata = STV_alloc(vc->bo, l); + vc->bo->fetch_obj->esidata = STV_alloc(vc, l); if (vc->bo->fetch_obj->esidata != NULL) { memcpy(vc->bo->fetch_obj->esidata->ptr, VSB_data(vsb), l); diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 97718bf..ad0c168 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -582,7 +582,7 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo) if (bo->ims_obj->esidata != NULL) { sl = bo->ims_obj->esidata->len; - obj->esidata = STV_alloc(bo, sl); + obj->esidata = STV_alloc(bo->vfc, sl); if (obj->esidata == NULL || obj->esidata->space < sl) { VSLb(bo->vsl, SLT_Error, "No space for %zd bytes of ESI data", sl); @@ -611,7 +611,8 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo) ois = ObjIter(oi, &sp, &sl); while (sl > 0) { if (st == NULL) - st = VFP_GetStorage(bo, bo->ims_obj->len - al); + st = VFP_GetStorage(bo->vfc, + bo->ims_obj->len - al); if (st == NULL) break; tl = sl; @@ -702,12 +703,17 @@ vbf_stp_error(struct worker *wrk, struct busyobj *bo) assert(wrk->handling == VCL_RET_DELIVER); + VFP_Setup(bo->vfc); + bo->vfc->bo = bo; + bo->vfc->http = bo->beresp; + bo->vfc->vsl = bo->vsl; + if (vbf_beresp2obj(bo)) return (F_STP_FAIL); l = VSB_len(bo->synth_body); if (l > 0) { - st = VFP_GetStorage(bo, l); + st = VFP_GetStorage(bo->vfc, l); if (st != NULL) { if (st->space < l) { VSLb(bo->vsl, SLT_Error, diff --git a/bin/varnishd/cache/cache_fetch_proc.c b/bin/varnishd/cache/cache_fetch_proc.c index e72d74f..87d3b6d 100644 --- a/bin/varnishd/cache/cache_fetch_proc.c +++ b/bin/varnishd/cache/cache_fetch_proc.c @@ -74,33 +74,34 @@ VFP_Error(struct vfp_ctx *vc, const char *fmt, ...) */ struct storage * -VFP_GetStorage(struct busyobj *bo, ssize_t sz) +VFP_GetStorage(struct vfp_ctx *vc, ssize_t sz) { ssize_t l; struct storage *st; struct object *obj; - CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); - obj = bo->fetch_obj; + CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC); + CHECK_OBJ_NOTNULL(vc->bo, BUSYOBJ_MAGIC); + obj = vc->bo->fetch_obj; CHECK_OBJ_NOTNULL(obj, OBJECT_MAGIC); st = VTAILQ_LAST(&obj->body->list, storagehead); if (st != NULL && st->len < st->space) return (st); - AN(bo->stats); + AN(vc->bo->stats); l = fetchfrag; if (l == 0) l = sz; if (l == 0) l = cache_param->fetch_chunksize; - st = STV_alloc(bo, l); + st = STV_alloc(vc, l); if (st == NULL) { - (void)VFP_Error(bo->vfc, "Could not get storage"); + (void)VFP_Error(vc, "Could not get storage"); } else { AZ(st->len); - Lck_Lock(&bo->mtx); + Lck_Lock(&vc->bo->mtx); VTAILQ_INSERT_TAIL(&obj->body->list, st, list); - Lck_Unlock(&bo->mtx); + Lck_Unlock(&vc->bo->mtx); } return (st); } @@ -222,7 +223,7 @@ VFP_Fetch_Body(struct busyobj *bo) } AZ(bo->vfc->failed); if (st == NULL) { - st = VFP_GetStorage(bo, est); + st = VFP_GetStorage(bo->vfc, est); est = 0; } if (st == NULL) { diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 8542b31..c982235 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -606,7 +606,6 @@ cnt_pipe(struct worker *wrk, struct req *req) http_FilterReq(bo->bereq, req->http, 0); // XXX: 0 ? http_PrintfHeader(bo->bereq, "X-Varnish: %u", VXID(req->vsl->wid)); http_SetHeader(bo->bereq, "Connection: close"); - VCL_pipe_method(req->vcl, wrk, req, bo, req->http->ws); diff --git a/bin/varnishd/storage/stevedore.c b/bin/varnishd/storage/stevedore.c index 44ed2b6..ad2106b 100644 --- a/bin/varnishd/storage/stevedore.c +++ b/bin/varnishd/storage/stevedore.c @@ -192,7 +192,7 @@ stv_alloc(struct stevedore *stv, size_t size) /*-------------------------------------------------------------------*/ static struct storage * -stv_alloc_obj(struct busyobj *bo, size_t size) +stv_alloc_obj(const struct vfp_ctx *vc, size_t size) { struct storage *st = NULL; struct stevedore *stv; @@ -203,9 +203,10 @@ stv_alloc_obj(struct busyobj *bo, size_t size) * Always use the stevedore which allocated the object in order to * keep an object inside the same stevedore. */ - AN(bo->stats); - CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); - obj = bo->fetch_obj; + CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC); + CHECK_OBJ_NOTNULL(vc->bo, BUSYOBJ_MAGIC); + AN(vc->bo->stats); + obj = vc->bo->fetch_obj; CHECK_OBJ_NOTNULL(obj, OBJECT_MAGIC); stv = obj->body->stevedore; CHECK_OBJ_NOTNULL(stv, STEVEDORE_MAGIC); @@ -224,7 +225,7 @@ stv_alloc_obj(struct busyobj *bo, size_t size) /* no luck; try to free some space and keep trying */ if (fail < cache_param->nuke_limit && - EXP_NukeOne(bo, stv->lru) == -1) + EXP_NukeOne(vc->bo, stv->lru) == -1) break; } CHECK_OBJ_ORNULL(st, STORAGE_MAGIC); @@ -410,10 +411,10 @@ STV_Freestore(struct object *o) /*-------------------------------------------------------------------*/ struct storage * -STV_alloc(struct busyobj *bo, size_t size) +STV_alloc(const struct vfp_ctx *vc, size_t size) { - return (stv_alloc_obj(bo, size)); + return (stv_alloc_obj(vc, size)); } struct storage * From phk at FreeBSD.org Wed Jul 23 09:38:25 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 23 Jul 2014 11:38:25 +0200 Subject: [master] 5d1770e Put the struct body in vfp_ctx Message-ID: commit 5d1770e1d082a443476d18b3e3c72efbaf0860fc Author: Poul-Henning Kamp Date: Wed Jul 23 09:38:12 2014 +0000 Put the struct body in vfp_ctx diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 8a3d0ae..f711959 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -104,6 +104,7 @@ enum { struct SHA256Context; struct VSC_C_lck; struct ban; +struct body; struct busyobj; struct cli; struct cli_proto; @@ -113,6 +114,7 @@ struct mempool; struct objcore; struct object; struct objhead; +struct objiter; struct pool; struct poolparam; struct req; @@ -124,7 +126,6 @@ struct vsb; struct waitinglist; struct worker; struct wrw; -struct objiter; #define DIGEST_LEN 32 @@ -464,6 +465,7 @@ struct vfp_ctx { struct vsl_log *vsl; struct http *http; + struct body *body; uint64_t bodybytes; }; diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index ad0c168..e0320fc 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -480,6 +480,7 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) assert(WRW_IsReleased(wrk)); obj = bo->fetch_obj; + bo->vfc->body = obj->body; if (bo->do_gzip || (bo->is_gzip && !bo->do_gunzip)) obj->gziped = 1; @@ -579,6 +580,7 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo) AZ(vbf_beresp2obj(bo)); obj = bo->fetch_obj; + bo->vfc->body = obj->body; if (bo->ims_obj->esidata != NULL) { sl = bo->ims_obj->esidata->len; @@ -711,6 +713,8 @@ vbf_stp_error(struct worker *wrk, struct busyobj *bo) if (vbf_beresp2obj(bo)) return (F_STP_FAIL); + bo->vfc->body = bo->fetch_obj->body; + l = VSB_len(bo->synth_body); if (l > 0) { st = VFP_GetStorage(bo->vfc, l); diff --git a/bin/varnishd/cache/cache_fetch_proc.c b/bin/varnishd/cache/cache_fetch_proc.c index 87d3b6d..14b26f2 100644 --- a/bin/varnishd/cache/cache_fetch_proc.c +++ b/bin/varnishd/cache/cache_fetch_proc.c @@ -78,13 +78,11 @@ VFP_GetStorage(struct vfp_ctx *vc, ssize_t sz) { ssize_t l; struct storage *st; - struct object *obj; CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC); CHECK_OBJ_NOTNULL(vc->bo, BUSYOBJ_MAGIC); - obj = vc->bo->fetch_obj; - CHECK_OBJ_NOTNULL(obj, OBJECT_MAGIC); - st = VTAILQ_LAST(&obj->body->list, storagehead); + AN(vc->body); + st = VTAILQ_LAST(&vc->body->list, storagehead); if (st != NULL && st->len < st->space) return (st); @@ -100,7 +98,7 @@ VFP_GetStorage(struct vfp_ctx *vc, ssize_t sz) } else { AZ(st->len); Lck_Lock(&vc->bo->mtx); - VTAILQ_INSERT_TAIL(&obj->body->list, st, list); + VTAILQ_INSERT_TAIL(&vc->body->list, st, list); Lck_Unlock(&vc->bo->mtx); } return (st); From phk at FreeBSD.org Wed Jul 23 14:08:30 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 23 Jul 2014 16:08:30 +0200 Subject: [master] 5e14a9d I accidentally duplicated this SLT_Link yesterday. Message-ID: commit 5e14a9df04141aa25c058ae81fdc6983e8983098 Author: Poul-Henning Kamp Date: Wed Jul 23 14:07:42 2014 +0000 I accidentally duplicated this SLT_Link yesterday. diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index c982235..afc5e4d 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -613,7 +613,6 @@ cnt_pipe(struct worker *wrk, struct req *req) INCOMPL(); assert(wrk->handling == VCL_RET_PIPE); - VSLb(req->vsl, SLT_Link, "bereq %u pipe", VXID(bo->vsl->wid)); PipeRequest(req, bo); assert(WRW_IsReleased(wrk)); http_Teardown(bo->bereq); From phk at FreeBSD.org Wed Jul 23 14:08:30 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 23 Jul 2014 16:08:30 +0200 Subject: [master] 2b9d23d We have a number of weird session error cases that still fail out here and need a SLT_End record. Message-ID: commit 2b9d23d586777d3f38df45d54ba6a5614ac4cce5 Author: Poul-Henning Kamp Date: Wed Jul 23 14:07:59 2014 +0000 We have a number of weird session error cases that still fail out here and need a SLT_End record. diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c index 2aaf632..3b22ce7 100644 --- a/bin/varnishd/cache/cache_session.c +++ b/bin/varnishd/cache/cache_session.c @@ -398,7 +398,8 @@ SES_ReleaseReq(struct req *req) #undef ACCT AZ(req->vcl); - AZ(req->vsl->wid); + if (req->vsl->wid) + VSL_End(req->vsl); sp = req->sp; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); pp = sp->sesspool; From phk at FreeBSD.org Thu Jul 24 07:04:42 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 24 Jul 2014 09:04:42 +0200 Subject: [master] dd1b997 Give the CLI command vcl.show a -v flag which outputs all the source files involved in a given VCL. Message-ID: commit dd1b9971fd95e9eb4927bc35e186b7c1b02b06ce Author: Poul-Henning Kamp Date: Thu Jul 24 07:00:26 2014 +0000 Give the CLI command vcl.show a -v flag which outputs all the source files involved in a given VCL. When using -v, the individual source files are output like this: // VCL.SHOW %d %d %s\n%s\n First field is the source file index [0...]. Second field is the number of bytes in the source file. Third field is the name of the source file. Fourth field is the source file content. Inspired by a patch from daghf diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c index 7e73cfb..1678ea3 100644 --- a/bin/varnishd/cache/cache_vcl.c +++ b/bin/varnishd/cache/cache_vcl.c @@ -372,6 +372,40 @@ ccf_config_use(struct cli *cli, const char * const *av, void *priv) VBE_UseHealth(vcl->conf->director[i]); } +static void +ccf_config_show(struct cli *cli, const char * const *av, void *priv) +{ + struct vcls *vcl; + int verbose = 0; + int i; + + (void)priv; + if (!strcmp(av[2], "-v")) { + verbose = 1; + vcl = vcl_find(av[3]); + } else if (av[3] != NULL) { + VCLI_Out(cli, "Unknown options '%s'", av[2]); + VCLI_SetResult(cli, CLIS_PARAM); + return; + } else + vcl = vcl_find(av[2]); + + if (vcl == NULL) { + VCLI_Out(cli, "No VCL named '%s'", av[2]); + VCLI_SetResult(cli, CLIS_PARAM); + return; + } + if (verbose) { + for (i = 0; i < vcl->conf->nsrc; i++) + VCLI_Out(cli, "// VCL.SHOW %d %zd %s\n%s\n", + i, strlen(vcl->conf->srcbody[i]), + vcl->conf->srcname[i], + vcl->conf->srcbody[i]); + } else { + VCLI_Out(cli, "%s", vcl->conf->srcbody[0]); + } +} + /*-------------------------------------------------------------------- * Method functions to call into VCL programs. * @@ -452,6 +486,7 @@ static struct cli_proto vcl_cmds[] = { { CLI_VCL_LIST, "i", ccf_config_list }, { CLI_VCL_DISCARD, "i", ccf_config_discard }, { CLI_VCL_USE, "i", ccf_config_use }, + { CLI_VCL_SHOW, "i", ccf_config_show }, { NULL } }; diff --git a/bin/varnishd/mgt/mgt_cli.c b/bin/varnishd/mgt/mgt_cli.c index 3d71a14..e7d7aa2 100644 --- a/bin/varnishd/mgt/mgt_cli.c +++ b/bin/varnishd/mgt/mgt_cli.c @@ -99,7 +99,6 @@ static struct cli_proto cli_proto[] = { { CLI_VCL_USE, "", mcf_config_use, NULL }, { CLI_VCL_DISCARD, "", mcf_config_discard, NULL }, { CLI_VCL_LIST, "", mcf_config_list, NULL }, - { CLI_VCL_SHOW, "", mcf_config_show, NULL }, { CLI_PARAM_SHOW, "", mcf_param_show, NULL }, { CLI_PARAM_SET, "", mcf_param_set, NULL }, { CLI_PANIC_SHOW, "", mcf_panic_show, NULL }, diff --git a/bin/varnishd/mgt/mgt_cli.h b/bin/varnishd/mgt/mgt_cli.h index 5d3ce8b..4d04535 100644 --- a/bin/varnishd/mgt/mgt_cli.h +++ b/bin/varnishd/mgt/mgt_cli.h @@ -44,7 +44,6 @@ cli_func_t mcf_config_inline; cli_func_t mcf_config_use; cli_func_t mcf_config_discard; cli_func_t mcf_config_list; -cli_func_t mcf_config_show; /* stevedore.c */ extern struct cli_proto cli_stv[]; diff --git a/bin/varnishd/mgt/mgt_vcc.c b/bin/varnishd/mgt/mgt_vcc.c index 2c2ffd9..4d97de6 100644 --- a/bin/varnishd/mgt/mgt_vcc.c +++ b/bin/varnishd/mgt/mgt_vcc.c @@ -672,35 +672,3 @@ mcf_config_list(struct cli *cli, const char * const *av, void *priv) } } } - -/* - * XXX: This should take an option argument to show all (include) files - * XXX: This violates the principle of not loading VCL's in the master - * XXX: process. - */ -void -mcf_config_show(struct cli *cli, const char * const *av, void *priv) -{ - struct vclprog *vp; - void *dlh, *sym; - const char **src; - - (void)priv; - if ((vp = mcf_find_vcl(cli, av[2])) != NULL) { - if ((dlh = dlopen(vp->fname, RTLD_NOW | RTLD_LOCAL)) == NULL) { - VCLI_Out(cli, "failed to load %s: %s\n", - vp->name, dlerror()); - VCLI_SetResult(cli, CLIS_CANT); - } else if ((sym = dlsym(dlh, "srcbody")) == NULL) { - VCLI_Out(cli, "failed to locate source for %s: %s\n", - vp->name, dlerror()); - VCLI_SetResult(cli, CLIS_CANT); - AZ(dlclose(dlh)); - } else { - src = sym; - VCLI_Out(cli, "%s", src[0]); - /* VCLI_Out(cli, src[1]); */ - AZ(dlclose(dlh)); - } - } -} diff --git a/bin/varnishtest/tests/c00015.vtc b/bin/varnishtest/tests/c00015.vtc index 5b09c8d..63edd3c 100644 --- a/bin/varnishtest/tests/c00015.vtc +++ b/bin/varnishtest/tests/c00015.vtc @@ -50,5 +50,6 @@ client c3 { } -run varnish v1 -cli "vcl.show vcl2" +varnish v1 -cli "vcl.show -v vcl2" varnish v1 -cli "vcl.discard vcl2" varnish v1 -cli "vcl.list" diff --git a/include/vcli.h b/include/vcli.h index 3294dd7..f6b75da 100644 --- a/include/vcli.h +++ b/include/vcli.h @@ -99,7 +99,7 @@ "vcl.show", \ "vcl.show ", \ "\tDisplay the source code for the specified configuration.", \ - 1, 1 + 1, 2 #define CLI_VCL_USE \ "vcl.use", \ From phk at FreeBSD.org Thu Jul 24 07:34:35 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 24 Jul 2014 09:34:35 +0200 Subject: [master] e03e1e8 Un-copy&paste leading whitespace in test-cases Message-ID: commit e03e1e8cc7d352018f99de043d034e3a750a506c Author: Poul-Henning Kamp Date: Thu Jul 24 07:28:20 2014 +0000 Un-copy&paste leading whitespace in test-cases diff --git a/bin/varnishtest/tests/a00010.vtc b/bin/varnishtest/tests/a00010.vtc index 60b0234..ce6b819 100644 --- a/bin/varnishtest/tests/a00010.vtc +++ b/bin/varnishtest/tests/a00010.vtc @@ -1,7 +1,7 @@ varnishtest "simply test that the framework support \0" server s1 { - rxreq + rxreq expect req.url == "/" txresp -body {a\0bc} } diff --git a/bin/varnishtest/tests/a00012.vtc b/bin/varnishtest/tests/a00012.vtc index 07e51c1..9b044fc 100644 --- a/bin/varnishtest/tests/a00012.vtc +++ b/bin/varnishtest/tests/a00012.vtc @@ -1,13 +1,13 @@ varnishtest "Ensure that we can test non-existence of headers (#1062)" server s1 { - rxreq - txresp + rxreq + txresp } -start client c1 -connect ${s1_sock} { - txreq - rxresp - expect resp.http.X-Test == + txreq + rxresp + expect resp.http.X-Test == } -run diff --git a/bin/varnishtest/tests/c00020.vtc b/bin/varnishtest/tests/c00020.vtc index ec54fe3..91fcd12 100644 --- a/bin/varnishtest/tests/c00020.vtc +++ b/bin/varnishtest/tests/c00020.vtc @@ -1,67 +1,67 @@ varnishtest "Test -h critbit a bit" server s1 { - rxreq + rxreq expect req.url == "/" - txresp -hdr "ID: slash" -hdr "Connection: close" -body "012345\n" + txresp -hdr "ID: slash" -hdr "Connection: close" -body "012345\n" } -start varnish v1 -arg "-hcritbit" -vcl+backend { } -start client c1 { - txreq -url "/" - rxresp - expect resp.status == 200 - expect resp.http.X-Varnish == "1001" - expect resp.http.ID == "slash" + txreq -url "/" + rxresp + expect resp.status == 200 + expect resp.http.X-Varnish == "1001" + expect resp.http.ID == "slash" } -run delay .1 client c2 { - txreq -url "/" - rxresp - expect resp.status == 200 - expect resp.http.X-Varnish == "1004 1002" - expect resp.http.ID == "slash" + txreq -url "/" + rxresp + expect resp.status == 200 + expect resp.http.X-Varnish == "1004 1002" + expect resp.http.ID == "slash" } -run delay .1 server s1 { - rxreq + rxreq expect req.url == "/foo" - txresp -hdr "ID: foo" -body "012345\n" - rxreq + txresp -hdr "ID: foo" -body "012345\n" + rxreq expect req.url == "/bar" - txresp -hdr "ID: bar" -body "012345\n" + txresp -hdr "ID: bar" -body "012345\n" } -start client c1 { - txreq -url "/foo" - rxresp - expect resp.status == 200 - expect resp.http.X-Varnish == "1006" - expect resp.http.ID == "foo" + txreq -url "/foo" + rxresp + expect resp.status == 200 + expect resp.http.X-Varnish == "1006" + expect resp.http.ID == "foo" delay .1 - txreq -url "/" - rxresp - expect resp.status == 200 - expect resp.http.X-Varnish == "1008 1002" - expect resp.http.ID == "slash" + txreq -url "/" + rxresp + expect resp.status == 200 + expect resp.http.X-Varnish == "1008 1002" + expect resp.http.ID == "slash" delay .1 - txreq -url "/bar" - rxresp - expect resp.status == 200 - expect resp.http.X-Varnish == "1009" - expect resp.http.ID == "bar" + txreq -url "/bar" + rxresp + expect resp.status == 200 + expect resp.http.X-Varnish == "1009" + expect resp.http.ID == "bar" delay .1 - txreq -url "/foo" - rxresp - expect resp.status == 200 - expect resp.http.X-Varnish == "1011 1007" - expect resp.http.ID == "foo" + txreq -url "/foo" + rxresp + expect resp.status == 200 + expect resp.http.X-Varnish == "1011 1007" + expect resp.http.ID == "foo" } -run varnish v1 -expect sess_conn == 3 diff --git a/bin/varnishtest/tests/c00023.vtc b/bin/varnishtest/tests/c00023.vtc index 11e8c72..f8b6a84 100644 --- a/bin/varnishtest/tests/c00023.vtc +++ b/bin/varnishtest/tests/c00023.vtc @@ -1,149 +1,149 @@ varnishtest "Test -h critbit for digest edges" server s1 { - rxreq + rxreq expect req.url == "/1" - txresp -body "\n" - rxreq + txresp -body "\n" + rxreq expect req.url == "/2" - txresp -body "x\n" - rxreq + txresp -body "x\n" + rxreq expect req.url == "/3" - txresp -body "xx\n" - rxreq + txresp -body "xx\n" + rxreq expect req.url == "/4" - txresp -body "xxx\n" - rxreq + txresp -body "xxx\n" + rxreq expect req.url == "/5" - txresp -body "xxxx\n" - rxreq + txresp -body "xxxx\n" + rxreq expect req.url == "/6" - txresp -body "xxxxx\n" - rxreq + txresp -body "xxxxx\n" + rxreq expect req.url == "/7" - txresp -body "xxxxxx\n" - rxreq + txresp -body "xxxxxx\n" + rxreq expect req.url == "/8" - txresp -body "xxxxxxx\n" - rxreq + txresp -body "xxxxxxx\n" + rxreq expect req.url == "/9" - txresp -body "xxxxxxxx\n" + txresp -body "xxxxxxxx\n" } -start varnish v1 -arg "-hcritbit" -vcl+backend { } -start varnish v1 -cliok "param.set debug +hashedge" client c1 { - txreq -url "/1" - rxresp - expect resp.status == 200 - expect resp.bodylen == 1 - expect resp.http.X-Varnish == "1001" - - txreq -url "/2" - rxresp - expect resp.bodylen == 2 - expect resp.status == 200 - expect resp.http.X-Varnish == "1003" - - txreq -url "/3" - rxresp - expect resp.bodylen == 3 - expect resp.status == 200 - expect resp.http.X-Varnish == "1005" - - txreq -url "/4" - rxresp - expect resp.bodylen == 4 - expect resp.status == 200 - expect resp.http.X-Varnish == "1007" - - txreq -url "/5" - rxresp - expect resp.bodylen == 5 - expect resp.status == 200 - expect resp.http.X-Varnish == "1009" - - txreq -url "/6" - rxresp - expect resp.bodylen == 6 - expect resp.status == 200 - expect resp.http.X-Varnish == "1011" - - txreq -url "/7" - rxresp - expect resp.bodylen == 7 - expect resp.status == 200 - expect resp.http.X-Varnish == "1013" - - txreq -url "/8" - rxresp - expect resp.bodylen == 8 - expect resp.status == 200 - expect resp.http.X-Varnish == "1015" - - txreq -url "/9" - rxresp - expect resp.bodylen == 9 - expect resp.status == 200 - expect resp.http.X-Varnish == "1017" + txreq -url "/1" + rxresp + expect resp.status == 200 + expect resp.bodylen == 1 + expect resp.http.X-Varnish == "1001" + + txreq -url "/2" + rxresp + expect resp.bodylen == 2 + expect resp.status == 200 + expect resp.http.X-Varnish == "1003" + + txreq -url "/3" + rxresp + expect resp.bodylen == 3 + expect resp.status == 200 + expect resp.http.X-Varnish == "1005" + + txreq -url "/4" + rxresp + expect resp.bodylen == 4 + expect resp.status == 200 + expect resp.http.X-Varnish == "1007" + + txreq -url "/5" + rxresp + expect resp.bodylen == 5 + expect resp.status == 200 + expect resp.http.X-Varnish == "1009" + + txreq -url "/6" + rxresp + expect resp.bodylen == 6 + expect resp.status == 200 + expect resp.http.X-Varnish == "1011" + + txreq -url "/7" + rxresp + expect resp.bodylen == 7 + expect resp.status == 200 + expect resp.http.X-Varnish == "1013" + + txreq -url "/8" + rxresp + expect resp.bodylen == 8 + expect resp.status == 200 + expect resp.http.X-Varnish == "1015" + + txreq -url "/9" + rxresp + expect resp.bodylen == 9 + expect resp.status == 200 + expect resp.http.X-Varnish == "1017" } -run client c1 { - txreq -url "/1" - rxresp - expect resp.status == 200 - expect resp.bodylen == 1 - expect resp.http.X-Varnish == "1020 1002" - - txreq -url "/2" - rxresp - expect resp.bodylen == 2 - expect resp.status == 200 - expect resp.http.X-Varnish == "1021 1004" - - txreq -url "/3" - rxresp - expect resp.bodylen == 3 - expect resp.status == 200 - expect resp.http.X-Varnish == "1022 1006" - - txreq -url "/4" - rxresp - expect resp.bodylen == 4 - expect resp.status == 200 - expect resp.http.X-Varnish == "1023 1008" - - txreq -url "/5" - rxresp - expect resp.bodylen == 5 - expect resp.status == 200 - expect resp.http.X-Varnish == "1024 1010" - - txreq -url "/6" - rxresp - expect resp.bodylen == 6 - expect resp.status == 200 - expect resp.http.X-Varnish == "1025 1012" - - txreq -url "/7" - rxresp - expect resp.bodylen == 7 - expect resp.status == 200 - expect resp.http.X-Varnish == "1026 1014" - - txreq -url "/8" - rxresp - expect resp.bodylen == 8 - expect resp.status == 200 - expect resp.http.X-Varnish == "1027 1016" - - txreq -url "/9" - rxresp - expect resp.bodylen == 9 - expect resp.status == 200 - expect resp.http.X-Varnish == "1028 1018" + txreq -url "/1" + rxresp + expect resp.status == 200 + expect resp.bodylen == 1 + expect resp.http.X-Varnish == "1020 1002" + + txreq -url "/2" + rxresp + expect resp.bodylen == 2 + expect resp.status == 200 + expect resp.http.X-Varnish == "1021 1004" + + txreq -url "/3" + rxresp + expect resp.bodylen == 3 + expect resp.status == 200 + expect resp.http.X-Varnish == "1022 1006" + + txreq -url "/4" + rxresp + expect resp.bodylen == 4 + expect resp.status == 200 + expect resp.http.X-Varnish == "1023 1008" + + txreq -url "/5" + rxresp + expect resp.bodylen == 5 + expect resp.status == 200 + expect resp.http.X-Varnish == "1024 1010" + + txreq -url "/6" + rxresp + expect resp.bodylen == 6 + expect resp.status == 200 + expect resp.http.X-Varnish == "1025 1012" + + txreq -url "/7" + rxresp + expect resp.bodylen == 7 + expect resp.status == 200 + expect resp.http.X-Varnish == "1026 1014" + + txreq -url "/8" + rxresp + expect resp.bodylen == 8 + expect resp.status == 200 + expect resp.http.X-Varnish == "1027 1016" + + txreq -url "/9" + rxresp + expect resp.bodylen == 9 + expect resp.status == 200 + expect resp.http.X-Varnish == "1028 1018" } -run varnish v1 -cliok "hcb.dump" diff --git a/bin/varnishtest/tests/c00024.vtc b/bin/varnishtest/tests/c00024.vtc index 80b3c59..0fd0034 100644 --- a/bin/varnishtest/tests/c00024.vtc +++ b/bin/varnishtest/tests/c00024.vtc @@ -1,8 +1,8 @@ varnishtest "Test restart in vcl_synth" server s1 { - rxreq - txresp + rxreq + txresp } -start varnish v1 -vcl+backend { @@ -21,7 +21,7 @@ varnish v1 -vcl+backend { } -start client c1 { - txreq -url "/" - rxresp - expect resp.status == 200 + txreq -url "/" + rxresp + expect resp.status == 200 } -run diff --git a/bin/varnishtest/tests/c00028.vtc b/bin/varnishtest/tests/c00028.vtc index 0ad1466..10caf43 100644 --- a/bin/varnishtest/tests/c00028.vtc +++ b/bin/varnishtest/tests/c00028.vtc @@ -14,7 +14,7 @@ varnish v1 -vcl { } -start client c1 { - txreq -url "/" - rxresp - expect resp.status == 503 + txreq -url "/" + rxresp + expect resp.status == 503 } -run diff --git a/bin/varnishtest/tests/c00037.vtc b/bin/varnishtest/tests/c00037.vtc index 48ea499..019ed0b 100644 --- a/bin/varnishtest/tests/c00037.vtc +++ b/bin/varnishtest/tests/c00037.vtc @@ -1,10 +1,10 @@ varnishtest "Test req.hash_always_miss in vcl_recv" server s1 { - rxreq - txresp -hdr "Inc: 1" - rxreq - txresp -hdr "Inc: 2" + rxreq + txresp -hdr "Inc: 1" + rxreq + txresp -hdr "Inc: 2" } -start varnish v1 -vcl+backend { diff --git a/bin/varnishtest/tests/e00008.vtc b/bin/varnishtest/tests/e00008.vtc index e72ec56..0345844 100644 --- a/bin/varnishtest/tests/e00008.vtc +++ b/bin/varnishtest/tests/e00008.vtc @@ -28,7 +28,7 @@ server s1 { 23 25 + > 25 26 27 28 diff --git a/bin/varnishtest/tests/e00012.vtc b/bin/varnishtest/tests/e00012.vtc index afc23c6..cb0a9e4 100644 --- a/bin/varnishtest/tests/e00012.vtc +++ b/bin/varnishtest/tests/e00012.vtc @@ -1,45 +1,45 @@ varnishtest "ESI includes for pre HTTP/1.1 cannot used chunked encoding" server s1 { - rxreq - expect req.url == "/foo/bar" - txresp -body { - - Before include - - After include - } - rxreq - expect req.url == "/foo/body" - txresp -body { - Included file - } + rxreq + expect req.url == "/foo/bar" + txresp -body { + + Before include + + After include + } + rxreq + expect req.url == "/foo/body" + txresp -body { + Included file + } } -start varnish v1 -vcl+backend { - sub vcl_backend_response { - set beresp.do_esi = true; - } + sub vcl_backend_response { + set beresp.do_esi = true; + } } -start client c1 { - txreq -url /foo/bar -proto HTTP/1.1 - rxresp - expect resp.status == 200 - expect resp.bodylen == 151 + txreq -url /foo/bar -proto HTTP/1.1 + rxresp + expect resp.status == 200 + expect resp.bodylen == 67 } -run client c1 { - txreq -url /foo/bar -proto HTTP/1.0 - rxresp - expect resp.status == 200 - expect resp.bodylen == 151 + txreq -url /foo/bar -proto HTTP/1.0 + rxresp + expect resp.status == 200 + expect resp.bodylen == 67 } -run client c1 { - txreq -url /foo/bar -proto "" - rxresp - expect resp.status == 200 - expect resp.bodylen == 151 + txreq -url /foo/bar -proto "" + rxresp + expect resp.status == 200 + expect resp.bodylen == 67 } -run varnish v1 -expect esi_errors == 0 diff --git a/bin/varnishtest/tests/e00013.vtc b/bin/varnishtest/tests/e00013.vtc index a8a6028..d6db08c 100644 --- a/bin/varnishtest/tests/e00013.vtc +++ b/bin/varnishtest/tests/e00013.vtc @@ -1,23 +1,23 @@ varnishtest "All white-space object, in multiple storage segments" server s1 { - rxreq - expect req.url == "/foo" - txresp -nolen -hdr "Connection: close" - send { } + rxreq + expect req.url == "/foo" + txresp -nolen -hdr "Connection: close" + send { } } -start varnish v1 -vcl+backend { - sub vcl_backend_response { - set beresp.do_esi = true; - } + sub vcl_backend_response { + set beresp.do_esi = true; + } } -start varnish v1 -cliok "debug.fragfetch 4" client c1 { - txreq -url /foo - rxresp + txreq -url /foo + rxresp } -run varnish v1 -expect esi_errors == 0 diff --git a/bin/varnishtest/tests/e00014.vtc b/bin/varnishtest/tests/e00014.vtc index ec6d16b..0097f13 100644 --- a/bin/varnishtest/tests/e00014.vtc +++ b/bin/varnishtest/tests/e00014.vtc @@ -1,25 +1,25 @@ varnishtest "Check } + send { } } -start varnish v1 -vcl+backend { - sub vcl_backend_response { - set beresp.do_esi = true; - } + sub vcl_backend_response { + set beresp.do_esi = true; + } } -start varnish v1 -cliok "debug.fragfetch 4" client c1 { - txreq -url /foo - rxresp + txreq -url /foo + rxresp expect resp.bodylen == 49 } -run diff --git a/bin/varnishtest/tests/e00015.vtc b/bin/varnishtest/tests/e00015.vtc index 3a41237..f5a948b 100644 --- a/bin/varnishtest/tests/e00015.vtc +++ b/bin/varnishtest/tests/e00015.vtc @@ -34,7 +34,7 @@ varnish v1 -vcl+backend { } -start client c1 { - txreq + txreq rxresp expect resp.bodylen == 73 expect resp.status == 200 diff --git a/bin/varnishtest/tests/e00016.vtc b/bin/varnishtest/tests/e00016.vtc index 7f0a71b..b760284 100644 --- a/bin/varnishtest/tests/e00016.vtc +++ b/bin/varnishtest/tests/e00016.vtc @@ -39,7 +39,7 @@ varnish v1 -vcl+backend { } -start client c1 { - txreq + txreq rxresp expect resp.bodylen == 105 expect resp.status == 200 diff --git a/bin/varnishtest/tests/r00878.vtc b/bin/varnishtest/tests/r00878.vtc index 8df049a..5725393 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 ${vmod_debug}; + 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 ${vmod_debug}; + 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 ${vmod_debug}; + import ${vmod_debug}; sub vcl_deliver { set resp.http.who = debug.author(kristian); } diff --git a/bin/varnishtest/tests/r00965.vtc b/bin/varnishtest/tests/r00965.vtc index e094e3b..7ef8bc7 100644 --- a/bin/varnishtest/tests/r00965.vtc +++ b/bin/varnishtest/tests/r00965.vtc @@ -10,7 +10,7 @@ varnish v1 -vcl+backend { if (req.http.X-Banned == "check") { unset req.http.X-Banned; } elseif (req.restarts == 0) { - set req.http.X-Banned = "check"; + set req.http.X-Banned = "check"; if (req.http.x-pass) { return (pass); } else { diff --git a/bin/varnishtest/tests/r01145.vtc b/bin/varnishtest/tests/r01145.vtc index f87238d..cb26a2f 100644 --- a/bin/varnishtest/tests/r01145.vtc +++ b/bin/varnishtest/tests/r01145.vtc @@ -18,7 +18,7 @@ varnish v1 -vcl+backend { import ${vmod_std}; sub vcl_deliver { - set resp.http.foo = std.fileread("${tmpdir}" + req.url); + set resp.http.foo = std.fileread("${tmpdir}" + req.url); } } -start diff --git a/bin/varnishtest/tests/r01184.vtc b/bin/varnishtest/tests/r01184.vtc index 6eb07ed..8cfb741 100644 --- a/bin/varnishtest/tests/r01184.vtc +++ b/bin/varnishtest/tests/r01184.vtc @@ -9,21 +9,21 @@ server s1 { -hdr "Content-Encoding: gzip" \ -hdr "Transfer-Encoding: Chunked" send "ed\r\n" - sendhex " 1f 8b 08 00 c2 39 33 50 02 03 45 90 4d 6a 03 31" - sendhex " 0c 85 f7 73 8a 47 2e 10 d9 f2 9f ca 34 d0 c2 64" - sendhex " 5b 08 bd 80 2d cb 10 28 5d 34 f4 fe f5 30 d0 68" - sendhex " 25 89 a7 f7 3e b4 be 6f d7 8f db 76 59 e8 28 d8" - sendhex " 10 45 f3 a9 83 b8 18 1c 7b c2 30 55 04 17 13 c4" - sendhex " 0f 07 5f 7a 38 f4 8e 50 b3 37 d4 3a 32 4a 34 07" - sendhex " 8a 9c d1 92 77 48 d4 0a 72 ea 06 5f b3 1c fa dd" - sendhex " 2b b9 88 20 99 e6 9a 3c 84 7c 85 8e 50 e0 59 2a" - sendhex " 42 b0 8a 34 0f 96 d5 1e f7 97 fb b7 7e fd 4e 87" - sendhex " c7 8f be 9e ce fb 74 3a 3f 51 89 a3 9b 7e b2 43" - sendhex " a4 86 a2 55 90 b9 29 4c 4b 83 b8 99 5f b5 bb 27" - sendhex " 6a d4 86 18 22 83 8a 26 f4 11 1a 5c eb 34 3b ca" - sendhex " 20 31 9e 12 29 ff a8 92 78 a2 e6 ec 61 55 12 fc" - sendhex " 68 84 6c 12 41 b9 cf 2f 30 3b f0 10 5e d6 b7 eb" - sendhex " e7 76 bb 2c 7f 8c 90 4a 14 4c 01 00 00" + sendhex " 1f 8b 08 00 c2 39 33 50 02 03 45 90 4d 6a 03 31" + sendhex " 0c 85 f7 73 8a 47 2e 10 d9 f2 9f ca 34 d0 c2 64" + sendhex " 5b 08 bd 80 2d cb 10 28 5d 34 f4 fe f5 30 d0 68" + sendhex " 25 89 a7 f7 3e b4 be 6f d7 8f db 76 59 e8 28 d8" + sendhex " 10 45 f3 a9 83 b8 18 1c 7b c2 30 55 04 17 13 c4" + sendhex " 0f 07 5f 7a 38 f4 8e 50 b3 37 d4 3a 32 4a 34 07" + sendhex " 8a 9c d1 92 77 48 d4 0a 72 ea 06 5f b3 1c fa dd" + sendhex " 2b b9 88 20 99 e6 9a 3c 84 7c 85 8e 50 e0 59 2a" + sendhex " 42 b0 8a 34 0f 96 d5 1e f7 97 fb b7 7e fd 4e 87" + sendhex " c7 8f be 9e ce fb 74 3a 3f 51 89 a3 9b 7e b2 43" + sendhex " a4 86 a2 55 90 b9 29 4c 4b 83 b8 99 5f b5 bb 27" + sendhex " 6a d4 86 18 22 83 8a 26 f4 11 1a 5c eb 34 3b ca" + sendhex " 20 31 9e 12 29 ff a8 92 78 a2 e6 ec 61 55 12 fc" + sendhex " 68 84 6c 12 41 b9 cf 2f 30 3b f0 10 5e d6 b7 eb" + sendhex " e7 76 bb 2c 7f 8c 90 4a 14 4c 01 00 00" send "\r\n" chunkedlen 0 rxreq @@ -53,13 +53,13 @@ server s1 { -hdr "Content-Encoding: gzip" \ -hdr "Transfer-Encoding: Chunked" send "70\r\n" - sendhex " 1f 8b 08 00 c2 39 33 50 02 03 45 90 4d 6a 03 31" - sendhex " 0c 85 f7 73 8a 47 2e 10 d9 f2 9f ca 34 d0 c2 64" - sendhex " 5b 08 bd 80 2d cb 10 28 5d 34 f4 fe f5 30 d0 68" - sendhex " 25 89 a7 f7 3e b4 be 6f d7 8f db 76 59 e8 28 d8" - sendhex " 10 45 f3 a9 83 b8 18 1c 7b c2 30 55 04 17 13 c4" - sendhex " 0f 07 5f 7a 38 f4 8e 50 b3 37 d4 3a 32 4a 34 07" - sendhex " FF FF FF FF FF FF FF FF 72 ea 06 5f b3 1c fa dd" + sendhex " 1f 8b 08 00 c2 39 33 50 02 03 45 90 4d 6a 03 31" + sendhex " 0c 85 f7 73 8a 47 2e 10 d9 f2 9f ca 34 d0 c2 64" + sendhex " 5b 08 bd 80 2d cb 10 28 5d 34 f4 fe f5 30 d0 68" + sendhex " 25 89 a7 f7 3e b4 be 6f d7 8f db 76 59 e8 28 d8" + sendhex " 10 45 f3 a9 83 b8 18 1c 7b c2 30 55 04 17 13 c4" + sendhex " 0f 07 5f 7a 38 f4 8e 50 b3 37 d4 3a 32 4a 34 07" + sendhex " FF FF FF FF FF FF FF FF 72 ea 06 5f b3 1c fa dd" expect_close } -start @@ -84,13 +84,13 @@ server s1 { -hdr "Content-Encoding: gzip" \ -hdr "Transfer-Encoding: Chunked" send "70\r\n" - sendhex " 1f 8b 08 00 c2 39 33 50 02 03 45 90 4d 6a 03 31" - sendhex " 0c 85 f7 73 8a 47 2e 10 d9 f2 9f ca 34 d0 c2 64" - sendhex " 5b 08 bd 80 2d cb 10 28 5d 34 f4 fe f5 30 d0 68" - sendhex " 25 89 a7 f7 3e b4 be 6f d7 8f db 76 59 e8 28 d8" - sendhex " 10 45 f3 a9 83 b8 18 1c 7b c2 30 55 04 17 13 c4" - sendhex " 0f 07 5f 7a 38 f4 8e 50 b3 37 d4 3a 32 4a 34 07" - sendhex " FF FF FF FF FF FF FF FF 72 ea 06 5f b3 1c fa dd" + sendhex " 1f 8b 08 00 c2 39 33 50 02 03 45 90 4d 6a 03 31" + sendhex " 0c 85 f7 73 8a 47 2e 10 d9 f2 9f ca 34 d0 c2 64" + sendhex " 5b 08 bd 80 2d cb 10 28 5d 34 f4 fe f5 30 d0 68" + sendhex " 25 89 a7 f7 3e b4 be 6f d7 8f db 76 59 e8 28 d8" + sendhex " 10 45 f3 a9 83 b8 18 1c 7b c2 30 55 04 17 13 c4" + sendhex " 0f 07 5f 7a 38 f4 8e 50 b3 37 d4 3a 32 4a 34 07" + sendhex " FF FF FF FF FF FF FF FF 72 ea 06 5f b3 1c fa dd" expect_close } -start diff --git a/bin/varnishtest/tests/v00016.vtc b/bin/varnishtest/tests/v00016.vtc index dfe69ae..3198e89 100644 --- a/bin/varnishtest/tests/v00016.vtc +++ b/bin/varnishtest/tests/v00016.vtc @@ -31,9 +31,9 @@ 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 - if else elseif elsif + error lookup hash pipe pass fetch deliver discard keep restart + include + if else elseif elsif ++ -- && || <= == != >= >> << += -= *= /= { } ( ) * + - / % > < = ; ! & . | ~ , } diff --git a/bin/varnishtest/tests/v00036.vtc b/bin/varnishtest/tests/v00036.vtc index 7bb1be8..2a7009c 100644 --- a/bin/varnishtest/tests/v00036.vtc +++ b/bin/varnishtest/tests/v00036.vtc @@ -1,18 +1,18 @@ varnishtest "Test fallback director" server s1 { - rxreq - txresp -hdr "Foo: 1" + rxreq + txresp -hdr "Foo: 1" } -start server s2 { - rxreq - txresp -hdr "Foo: 2" + rxreq + txresp -hdr "Foo: 2" } -start server s3 { - rxreq - txresp -hdr "Foo: 3" + rxreq + txresp -hdr "Foo: 3" } -start varnish v1 -vcl+backend { @@ -25,12 +25,12 @@ varnish v1 -vcl+backend { fb1.add_backend(s3); } - sub vcl_recv { - return (pass); - } - sub vcl_backend_fetch { - set bereq.backend = fb1.backend(); - } + sub vcl_recv { + return (pass); + } + sub vcl_backend_fetch { + set bereq.backend = fb1.backend(); + } } -start @@ -38,24 +38,24 @@ varnish v1 -cliok "backend.set_health s1 sick" varnish v1 -cliok "backend.set_health s2 sick" client c1 { - # s1 & s2 are both sick, expect response from s3 - txreq - rxresp - expect resp.http.foo == "3" + # s1 & s2 are both sick, expect response from s3 + txreq + rxresp + expect resp.http.foo == "3" } -run varnish v1 -cliok "backend.set_health s2 healthy" client c1 { - txreq - rxresp - expect resp.http.foo == "2" + txreq + rxresp + expect resp.http.foo == "2" } -run varnish v1 -cliok "backend.set_health s1 healthy" client c1 { - txreq - rxresp - expect resp.http.foo == "1" + txreq + rxresp + expect resp.http.foo == "1" } -run From phk at FreeBSD.org Thu Jul 24 08:04:30 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 24 Jul 2014 10:04:30 +0200 Subject: [master] f1b1c2d White space copy&paste fixups Message-ID: commit f1b1c2d7cc540bad9f63681d3b1a8a590167a4ce Author: Poul-Henning Kamp Date: Thu Jul 24 08:01:56 2014 +0000 White space copy&paste fixups diff --git a/include/tbl/vsc_f_main.h b/include/tbl/vsc_f_main.h index a88a12d..845fbcb 100644 --- a/include/tbl/vsc_f_main.h +++ b/include/tbl/vsc_f_main.h @@ -573,11 +573,11 @@ VSC_F(bans_lurker_contention, uint64_t, 0, 'c', diag, ) VSC_F(bans_persisted_bytes, uint64_t, 0, 'g', diag, "Bytes used by the persisted ban lists", - "Number of bytes used by the persisted ban lists." + "Number of bytes used by the persisted ban lists." ) VSC_F(bans_persisted_fragmentation, uint64_t, 0, 'g', diag, "Extra bytes in persisted ban lists due to fragmentation", - "Number of extra bytes accumulated through dropped and" + "Number of extra bytes accumulated through dropped and" " completed bans in the persistent ban lists." ) diff --git a/include/vapi/vsl.h b/include/vapi/vsl.h index 45c1aaf..a4f1b27 100644 --- a/include/vapi/vsl.h +++ b/include/vapi/vsl.h @@ -268,8 +268,8 @@ void VSL_ResetError(struct VSL_data *vsl); struct VSL_cursor *VSL_CursorVSM(struct VSL_data *vsl, struct VSM_data *vsm, unsigned options); /* - * Set the cursor pointed to by cursor up as a raw cursor in the - * log. Cursor points at the current log head. + * Set the cursor pointed to by cursor up as a raw cursor in the + * log. Cursor points at the current log head. * * Options: * VSL_COPT_TAIL Start cursor at log tail @@ -279,7 +279,7 @@ struct VSL_cursor *VSL_CursorVSM(struct VSL_data *vsl, struct VSM_data *vsm, * Return values: * non-NULL: Pointer to cursor * NULL: Error, see VSL_Error - */ + */ struct VSL_cursor *VSL_CursorFile(struct VSL_data *vsl, const char *name, unsigned options); diff --git a/include/vqueue.h b/include/vqueue.h index 8ffd820..f725f96 100644 --- a/include/vqueue.h +++ b/include/vqueue.h @@ -240,7 +240,7 @@ struct { \ #define VSTAILQ_LAST(head, type, field) \ (VSTAILQ_EMPTY((head)) ? \ NULL : \ - ((struct type *)(void *) \ + ((struct type *)(void *) \ ((char *)((head)->vstqh_last) - \ __offsetof(struct type, field)))) diff --git a/include/vtree.h b/include/vtree.h index cf4e061..d251d62 100644 --- a/include/vtree.h +++ b/include/vtree.h @@ -150,7 +150,7 @@ static __inline struct type * \ name##_VSPLAY_MIN_MAX(struct name *head, int val) \ { \ name##_VSPLAY_MINMAX(head, val); \ - return (VSPLAY_ROOT(head)); \ + return (VSPLAY_ROOT(head)); \ } /* Main splay operation. From phk at FreeBSD.org Thu Jul 24 08:04:30 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 24 Jul 2014 10:04:30 +0200 Subject: [master] 77aec39 White-space copy&paste fixups Message-ID: commit 77aec396c68513f98b257ebe30d005c158f2573f Author: Poul-Henning Kamp Date: Thu Jul 24 08:03:00 2014 +0000 White-space copy&paste fixups diff --git a/lib/libvarnish/vtcp.c b/lib/libvarnish/vtcp.c index 2109f20..26191fe 100644 --- a/lib/libvarnish/vtcp.c +++ b/lib/libvarnish/vtcp.c @@ -324,5 +324,5 @@ VTCP_check_hup(int sock) if (poll(&pfd, 1, 0) == 1 && pfd.revents & POLLHUP) return (1); - return (0); + return (0); } diff --git a/lib/libvcc/vcc_expr.c b/lib/libvcc/vcc_expr.c index 0d39073..c2f9818 100644 --- a/lib/libvcc/vcc_expr.c +++ b/lib/libvcc/vcc_expr.c @@ -1025,7 +1025,7 @@ vcc_expr_cmp(struct vcc *tl, struct expr **e, enum var_type fmt) } if ((*e)->fmt == STRING && (tl->t->tok == '~' || tl->t->tok == T_NOMATCH)) { - not = tl->t->tok == '~' ? "" : "!"; + not = tl->t->tok == '~' ? "" : "!"; vcc_NextToken(tl); ExpectErr(tl, CSTR); re = vcc_regexp(tl); @@ -1037,7 +1037,7 @@ vcc_expr_cmp(struct vcc *tl, struct expr **e, enum var_type fmt) } if ((*e)->fmt == IP && (tl->t->tok == '~' || tl->t->tok == T_NOMATCH)) { - not = tl->t->tok == '~' ? "" : "!"; + not = tl->t->tok == '~' ? "" : "!"; vcc_NextToken(tl); ExpectErr(tl, ID); vcc_AddRef(tl, tl->t, SYM_ACL); diff --git a/lib/libvmod_debug/vmod_debug.c b/lib/libvmod_debug/vmod_debug.c index b2f3313..744b10d 100644 --- a/lib/libvmod_debug/vmod_debug.c +++ b/lib/libvmod_debug/vmod_debug.c @@ -93,7 +93,7 @@ vmod_test_priv_vcl(const struct vrt_ctx *ctx, struct vmod_priv *priv) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); - assert(!strcmp(priv->priv, "FOO")); + assert(!strcmp(priv->priv, "FOO")); } VCL_BLOB From phk at FreeBSD.org Thu Jul 24 08:16:08 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 24 Jul 2014 10:16:08 +0200 Subject: [master] e389bc8 Update from FreeBSD's sys/queue.h Message-ID: commit e389bc8e3dbb0ead7047da439ad7d9b46ae40801 Author: Poul-Henning Kamp Date: Thu Jul 24 08:15:48 2014 +0000 Update from FreeBSD's sys/queue.h diff --git a/include/vqueue.h b/include/vqueue.h index f725f96..55bc23c 100644 --- a/include/vqueue.h +++ b/include/vqueue.h @@ -27,12 +27,14 @@ * SUCH DAMAGE. * * @(#)queue.h 8.5 (Berkeley) 8/20/94 - * $FreeBSD: src/sys/sys/queue.h,v 1.68 2006/10/24 11:20:29 ru Exp $ + * $FreeBSD: head/sys/sys/queue.h 251887 2013-06-18 02:57:56Z lstewart $ */ #ifndef VARNISH_QUEUE_H #define VARNISH_QUEUE_H +#include + /* * This file defines four types of data structures: singly-linked lists, * singly-linked tail queues, lists and tail queues. @@ -63,7 +65,7 @@ * so that an arbitrary element can be removed without a need to * traverse the list. New elements can be added to the list before * or after an existing element or at the head of the list. A list - * may only be traversed in the forward direction. + * may be traversed in either direction. * * A tail queue is headed by a pair of pointers, one to the head of the * list and the other to the tail of the list. The elements are doubly @@ -83,21 +85,30 @@ * _EMPTY + + + + * _FIRST + + + + * _NEXT + + + + - * _PREV - - - + + * _PREV - + - + * _LAST - - + + * _FOREACH + + + + + * _FOREACH_FROM + + + + * _FOREACH_SAFE + + + + + * _FOREACH_FROM_SAFE + + + + * _FOREACH_REVERSE - - - + + * _FOREACH_REVERSE_FROM - - - + * _FOREACH_REVERSE_SAFE - - - + + * _FOREACH_REVERSE_FROM_SAFE - - - + * _INSERT_HEAD + + + + * _INSERT_BEFORE - + - + * _INSERT_AFTER + + + + * _INSERT_TAIL - - + + * _CONCAT - - + + + * _REMOVE_AFTER + - + - * _REMOVE_HEAD + - + - * _REMOVE + + + + + * _SWAP + + + + * */ +#define TRACEBUF +#define TRACEBUF_INITIALIZER +#define TRASHIT(x) /* * Singly-linked List declarations. @@ -127,11 +138,21 @@ struct { \ (var); \ (var) = VSLIST_NEXT((var), field)) +#define VSLIST_FOREACH_FROM(var, head, field) \ + for ((var) = ((var) ? (var) : VSLIST_FIRST((head))); \ + (var); \ + (var) = VSLIST_NEXT((var), field)) + #define VSLIST_FOREACH_SAFE(var, head, field, tvar) \ for ((var) = VSLIST_FIRST((head)); \ (var) && ((tvar) = VSLIST_NEXT((var), field), 1); \ (var) = (tvar)) +#define VSLIST_FOREACH_FROM_SAFE(var, head, field, tvar) \ + for ((var) = ((var) ? (var) : VSLIST_FIRST((head))); \ + (var) && ((tvar) = VSLIST_NEXT((var), field), 1); \ + (var) = (tvar)) + #define VSLIST_FOREACH_PREVPTR(var, varp, head, field) \ for ((varp) = &VSLIST_FIRST((head)); \ ((var) = *(varp)) != NULL; \ @@ -161,15 +182,26 @@ struct { \ struct type *curelm = VSLIST_FIRST((head)); \ while (VSLIST_NEXT(curelm, field) != (elm)) \ curelm = VSLIST_NEXT(curelm, field); \ - VSLIST_NEXT(curelm, field) = \ - VSLIST_NEXT(VSLIST_NEXT(curelm, field), field); \ + VSLIST_REMOVE_AFTER(curelm, field); \ } \ + TRASHIT(*oldnext); \ +} while (0) + +#define VSLIST_REMOVE_AFTER(elm, field) do { \ + VSLIST_NEXT(elm, field) = \ + VSLIST_NEXT(VSLIST_NEXT(elm, field), field); \ } while (0) #define VSLIST_REMOVE_HEAD(head, field) do { \ VSLIST_FIRST((head)) = VSLIST_NEXT(VSLIST_FIRST((head)), field);\ } while (0) +#define VSLIST_SWAP(head1, head2, type) do { \ + struct type *swap_first = VSLIST_FIRST(head1); \ + VSLIST_FIRST(head1) = VSLIST_FIRST(head2); \ + VSLIST_FIRST(head2) = swap_first; \ +} while (0) + /* * Singly-linked Tail queue declarations. */ @@ -207,20 +239,28 @@ struct { \ (var); \ (var) = VSTAILQ_NEXT((var), field)) +#define VSTAILQ_FOREACH_FROM(var, head, field) \ + for ((var) = ((var) ? (var) : VSTAILQ_FIRST((head))); \ + (var); \ + (var) = VSTAILQ_NEXT((var), field)) #define VSTAILQ_FOREACH_SAFE(var, head, field, tvar) \ for ((var) = VSTAILQ_FIRST((head)); \ (var) && ((tvar) = VSTAILQ_NEXT((var), field), 1); \ (var) = (tvar)) +#define VSTAILQ_FOREACH_FROM_SAFE(var, head, field, tvar) \ + for ((var) = ((var) ? (var) : VSTAILQ_FIRST((head))); \ + (var) && ((tvar) = VSTAILQ_NEXT((var), field), 1); \ + (var) = (tvar)) + #define VSTAILQ_INIT(head) do { \ VSTAILQ_FIRST((head)) = NULL; \ (head)->vstqh_last = &VSTAILQ_FIRST((head)); \ } while (0) #define VSTAILQ_INSERT_AFTER(head, tqelm, elm, field) do { \ - if ((VSTAILQ_NEXT((elm), field) = \ - VSTAILQ_NEXT((tqelm), field)) == NULL) \ + if ((VSTAILQ_NEXT((elm), field) = VSTAILQ_NEXT((tqelm), field)) == NULL)\ (head)->vstqh_last = &VSTAILQ_NEXT((elm), field); \ VSTAILQ_NEXT((tqelm), field) = (elm); \ } while (0) @@ -238,11 +278,8 @@ struct { \ } while (0) #define VSTAILQ_LAST(head, type, field) \ - (VSTAILQ_EMPTY((head)) ? \ - NULL : \ - ((struct type *)(void *) \ - ((char *)((head)->vstqh_last) - \ - __offsetof(struct type, field)))) + (VSTAILQ_EMPTY((head)) ? NULL : \ + __containerof((head)->vstqh_last, struct type, field.vstqe_next)) #define VSTAILQ_NEXT(elm, field) ((elm)->field.vstqe_next) @@ -254,10 +291,15 @@ struct { \ struct type *curelm = VSTAILQ_FIRST((head)); \ while (VSTAILQ_NEXT(curelm, field) != (elm)) \ curelm = VSTAILQ_NEXT(curelm, field); \ - if ((VSTAILQ_NEXT(curelm, field) = \ - VSTAILQ_NEXT(VSTAILQ_NEXT(curelm, field), field)) == NULL)\ - (head)->vstqh_last = &VSTAILQ_NEXT((curelm), field);\ + VSTAILQ_REMOVE_AFTER(head, curelm, field); \ } \ + TRASHIT(*oldnext); \ +} while (0) + +#define VSTAILQ_REMOVE_AFTER(head, elm, field) do { \ + if ((VSTAILQ_NEXT(elm, field) = \ + VSTAILQ_NEXT(VSTAILQ_NEXT(elm, field), field)) == NULL) \ + (head)->vstqh_last = &VSTAILQ_NEXT((elm), field); \ } while (0) #define VSTAILQ_REMOVE_HEAD(head, field) do { \ @@ -266,6 +308,20 @@ struct { \ (head)->vstqh_last = &VSTAILQ_FIRST((head)); \ } while (0) +#define VSTAILQ_SWAP(head1, head2, type) do { \ + struct type *swap_first = VSTAILQ_FIRST(head1); \ + struct type **swap_last = (head1)->vstqh_last; \ + VSTAILQ_FIRST(head1) = VSTAILQ_FIRST(head2); \ + (head1)->vstqh_last = (head2)->vstqh_last; \ + VSTAILQ_FIRST(head2) = swap_first; \ + (head2)->vstqh_last = swap_last; \ + if (VSTAILQ_EMPTY(head1)) \ + (head1)->vstqh_last = &VSTAILQ_FIRST(head1); \ + if (VSTAILQ_EMPTY(head2)) \ + (head2)->vstqh_last = &VSTAILQ_FIRST(head2); \ +} while (0) + + /* * List declarations. */ @@ -286,6 +342,8 @@ struct { \ /* * List functions. */ + + #define VLIST_EMPTY(head) ((head)->vlh_first == NULL) #define VLIST_FIRST(head) ((head)->vlh_first) @@ -295,11 +353,21 @@ struct { \ (var); \ (var) = VLIST_NEXT((var), field)) +#define VLIST_FOREACH_FROM(var, head, field) \ + for ((var) = ((var) ? (var) : VLIST_FIRST((head))); \ + (var); \ + (var) = VLIST_NEXT((var), field)) + #define VLIST_FOREACH_SAFE(var, head, field, tvar) \ for ((var) = VLIST_FIRST((head)); \ (var) && ((tvar) = VLIST_NEXT((var), field), 1); \ (var) = (tvar)) +#define VLIST_FOREACH_FROM_SAFE(var, head, field, tvar) \ + for ((var) = ((var) ? (var) : VLIST_FIRST((head))); \ + (var) && ((tvar) = VLIST_NEXT((var), field), 1); \ + (var) = (tvar)) + #define VLIST_INIT(head) do { \ VLIST_FIRST((head)) = NULL; \ } while (0) @@ -321,19 +389,34 @@ struct { \ #define VLIST_INSERT_HEAD(head, elm, field) do { \ if ((VLIST_NEXT((elm), field) = VLIST_FIRST((head))) != NULL) \ - VLIST_FIRST((head))->field.vle_prev = \ - &VLIST_NEXT((elm), field); \ + VLIST_FIRST((head))->field.vle_prev = &VLIST_NEXT((elm), field);\ VLIST_FIRST((head)) = (elm); \ (elm)->field.vle_prev = &VLIST_FIRST((head)); \ } while (0) #define VLIST_NEXT(elm, field) ((elm)->field.vle_next) +#define VLIST_PREV(elm, head, type, field) \ + ((elm)->field.vle_prev == &VLIST_FIRST((head)) ? NULL : \ + __containerof((elm)->field.vle_prev, struct type, field.vle_next)) + #define VLIST_REMOVE(elm, field) do { \ if (VLIST_NEXT((elm), field) != NULL) \ VLIST_NEXT((elm), field)->field.vle_prev = \ (elm)->field.vle_prev; \ *(elm)->field.vle_prev = VLIST_NEXT((elm), field); \ + TRASHIT(*oldnext); \ + TRASHIT(*oldprev); \ +} while (0) + +#define VLIST_SWAP(head1, head2, type, field) do { \ + struct type *swap_tmp = VLIST_FIRST((head1)); \ + VLIST_FIRST((head1)) = VLIST_FIRST((head2)); \ + VLIST_FIRST((head2)) = swap_tmp; \ + if ((swap_tmp = VLIST_FIRST((head1))) != NULL) \ + swap_tmp->field.vle_prev = &VLIST_FIRST((head1)); \ + if ((swap_tmp = VLIST_FIRST((head2))) != NULL) \ + swap_tmp->field.vle_prev = &VLIST_FIRST((head2)); \ } while (0) /* @@ -343,20 +426,23 @@ struct { \ struct name { \ struct type *vtqh_first; /* first element */ \ struct type **vtqh_last; /* addr of last next element */ \ + TRACEBUF \ } #define VTAILQ_HEAD_INITIALIZER(head) \ - { NULL, &(head).vtqh_first } + { NULL, &(head).vtqh_first, TRACEBUF_INITIALIZER } #define VTAILQ_ENTRY(type) \ struct { \ struct type *vtqe_next; /* next element */ \ struct type **vtqe_prev; /* address of previous next element */\ + TRACEBUF \ } /* * Tail queue functions. */ + #define VTAILQ_CONCAT(head1, head2, field) do { \ if (!VTAILQ_EMPTY(head2)) { \ *(head1)->vtqh_last = (head2)->vtqh_first; \ @@ -375,29 +461,48 @@ struct { \ (var); \ (var) = VTAILQ_NEXT((var), field)) +#define VTAILQ_FOREACH_FROM(var, head, field) \ + for ((var) = ((var) ? (var) : VTAILQ_FIRST((head))); \ + (var); \ + (var) = VTAILQ_NEXT((var), field)) + #define VTAILQ_FOREACH_SAFE(var, head, field, tvar) \ for ((var) = VTAILQ_FIRST((head)); \ (var) && ((tvar) = VTAILQ_NEXT((var), field), 1); \ (var) = (tvar)) +#define VTAILQ_FOREACH_FROM_SAFE(var, head, field, tvar) \ + for ((var) = ((var) ? (var) : VTAILQ_FIRST((head))); \ + (var) && ((tvar) = VTAILQ_NEXT((var), field), 1); \ + (var) = (tvar)) + #define VTAILQ_FOREACH_REVERSE(var, head, headname, field) \ for ((var) = VTAILQ_LAST((head), headname); \ (var); \ (var) = VTAILQ_PREV((var), headname, field)) +#define VTAILQ_FOREACH_REVERSE_FROM(var, head, headname, field) \ + for ((var) = ((var) ? (var) : VTAILQ_LAST((head), headname)); \ + (var); \ + (var) = VTAILQ_PREV((var), headname, field)) + #define VTAILQ_FOREACH_REVERSE_SAFE(var, head, headname, field, tvar) \ for ((var) = VTAILQ_LAST((head), headname); \ (var) && ((tvar) = VTAILQ_PREV((var), headname, field), 1); \ (var) = (tvar)) +#define VTAILQ_FOREACH_REVERSE_FROM_SAFE(var, head, headname, field, tvar) \ + for ((var) = ((var) ? (var) : VTAILQ_LAST((head), headname)); \ + (var) && ((tvar) = VTAILQ_PREV((var), headname, field), 1); \ + (var) = (tvar)) + #define VTAILQ_INIT(head) do { \ VTAILQ_FIRST((head)) = NULL; \ (head)->vtqh_last = &VTAILQ_FIRST((head)); \ } while (0) #define VTAILQ_INSERT_AFTER(head, listelm, elm, field) do { \ - if ((VTAILQ_NEXT((elm), field) = \ - VTAILQ_NEXT((listelm), field)) != NULL) \ + if ((VTAILQ_NEXT((elm), field) = VTAILQ_NEXT((listelm), field)) != NULL)\ VTAILQ_NEXT((elm), field)->field.vtqe_prev = \ &VTAILQ_NEXT((elm), field); \ else { \ @@ -447,52 +552,25 @@ struct { \ (head)->vtqh_last = (elm)->field.vtqe_prev; \ } \ *(elm)->field.vtqe_prev = VTAILQ_NEXT((elm), field); \ + TRASHIT(*oldnext); \ + TRASHIT(*oldprev); \ } while (0) - -#ifdef _KERNEL - -/* - * XXX insque() and remque() are an old way of handling certain queues. - * They bogusly assumes that all queue heads look alike. - */ - -struct quehead { - struct quehead *qh_link; - struct quehead *qh_rlink; -}; - -#ifdef __CC_SUPPORTS___INLINE - -static __inline void -insque(void *a, void *b) -{ - struct quehead *element = (struct quehead *)a, - *head = (struct quehead *)b; - - element->qh_link = head->qh_link; - element->qh_rlink = head; - head->qh_link = element; - element->qh_link->qh_rlink = element; -} - -static __inline void -remque(void *a) -{ - struct quehead *element = (struct quehead *)a; - - element->qh_link->qh_rlink = element->qh_rlink; - element->qh_rlink->qh_link = element->qh_link; - element->qh_rlink = 0; -} - -#else /* !__CC_SUPPORTS___INLINE */ - -void insque(void *a, void *b); -void remque(void *a); - -#endif /* __CC_SUPPORTS___INLINE */ - -#endif /* _KERNEL */ +#define VTAILQ_SWAP(head1, head2, type, field) do { \ + struct type *swap_first = (head1)->vtqh_first; \ + struct type **swap_last = (head1)->vtqh_last; \ + (head1)->vtqh_first = (head2)->vtqh_first; \ + (head1)->vtqh_last = (head2)->vtqh_last; \ + (head2)->vtqh_first = swap_first; \ + (head2)->vtqh_last = swap_last; \ + if ((swap_first = (head1)->vtqh_first) != NULL) \ + swap_first->field.vtqe_prev = &(head1)->vtqh_first; \ + else \ + (head1)->vtqh_last = &(head1)->vtqh_first; \ + if ((swap_first = (head2)->vtqh_first) != NULL) \ + swap_first->field.vtqe_prev = &(head2)->vtqh_first; \ + else \ + (head2)->vtqh_last = &(head2)->vtqh_first; \ +} while (0) #endif /* !VARNISH_QUEUE_H */ From phk at FreeBSD.org Thu Jul 24 08:42:42 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 24 Jul 2014 10:42:42 +0200 Subject: [master] a7da0ca Make it possible to return synth from vcl_deliver{} Message-ID: commit a7da0caab86ef32861c5109080ab07777281828b Author: Poul-Henning Kamp Date: Thu Jul 24 08:40:02 2014 +0000 Make it possible to return synth from vcl_deliver{} This is now possible because synth responses do not go through deliver any more, as error responses used to. Patch by: Nils Goroll Much appreciated diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index afc5e4d..e630160 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -137,11 +137,22 @@ cnt_deliver(struct worker *wrk, struct req *req) if (req->restarts >= cache_param->max_restarts) wrk->handling = VCL_RET_DELIVER; - if (wrk->handling == VCL_RET_RESTART) { + if (wrk->handling != VCL_RET_DELIVER) { (void)HSH_DerefObj(&wrk->stats, &req->obj); AZ(req->obj); http_Teardown(req->resp); - req->req_step = R_STP_RESTART; + + switch (wrk->handling) { + case VCL_RET_RESTART: + req->req_step = R_STP_RESTART; + break; + case VCL_RET_SYNTH: + req->req_step = R_STP_SYNTH; + break; + default: + INCOMPL(); + } + return (REQ_FSM_MORE); } diff --git a/bin/varnishtest/tests/c00068.vtc b/bin/varnishtest/tests/c00068.vtc new file mode 100644 index 0000000..817ec32 --- /dev/null +++ b/bin/varnishtest/tests/c00068.vtc @@ -0,0 +1,60 @@ +varnishtest "synth in deliver" + +server s1 { + rxreq + txresp -status 200 + rxreq + txresp -status 200 + rxreq + txresp -status 200 +} -start + +varnish v1 -vcl+backend { + sub vcl_deliver { + if (req.url == "/332") { + return (synth(332, "FOO")); + } else if (req.url == "/333") { + return (synth(333, "FOO")); + } else { + return (synth(334, "BAR")); + } + } + + sub vcl_synth { + if (resp.status == 333) { + set resp.http.connection = "close"; + } else if (resp.status == 332) { + if (req.restarts == 0) { + return (restart); + } else { + set resp.http.restarts = req.restarts; + synthetic(req.restarts); + } + } + return (deliver); + } +} -start + +client c1 { + txreq -url /334 + rxresp + expect resp.status == 334 + + # cache hit + txreq -url /334 + rxresp + expect resp.status == 334 + + txreq -url /333 + rxresp + expect resp.status == 333 + expect_close +} -run + +client c2 { + txreq -url /332 + rxresp + expect resp.status == 332 + expect resp.http.restarts == 1 + expect resp.bodylen == 1 +} -run diff --git a/bin/varnishtest/tests/r01027.vtc b/bin/varnishtest/tests/r01027.vtc deleted file mode 100644 index 716e6f0..0000000 --- a/bin/varnishtest/tests/r01027.vtc +++ /dev/null @@ -1,9 +0,0 @@ -varnishtest "Test if you can error in vcl_deliver" - -varnish v1 -errvcl {Invalid return "synth"} { - backend b { .host = "127.0.0.1"; } - sub vcl_deliver { - return (synth(201,"ok")); - } -} - diff --git a/lib/libvcc/generate.py b/lib/libvcc/generate.py index a1fd2d7..2906588 100755 --- a/lib/libvcc/generate.py +++ b/lib/libvcc/generate.py @@ -112,7 +112,7 @@ returns =( ), ('deliver', "C", - ('restart', 'deliver',) + ('synth', 'restart', 'deliver',) ), ('synth', "C", From phk at FreeBSD.org Thu Jul 24 11:01:09 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 24 Jul 2014 13:01:09 +0200 Subject: [master] 584cb9d Add a VCC variable type "HTTP" to refer to an entire HTTP message. Presently supported "req", "bereq", "resp", "beresp". Message-ID: commit 584cb9d0622a562ccaf19b618f30bf6fd7944841 Author: Poul-Henning Kamp Date: Thu Jul 24 11:00:10 2014 +0000 Add a VCC variable type "HTTP" to refer to an entire HTTP message. Presently supported "req", "bereq", "resp", "beresp". diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index 6796d8c..ab5590a 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -606,3 +606,19 @@ VRT_r_obj_uncacheable(const struct vrt_ctx *ctx) CHECK_OBJ_NOTNULL(ctx->req->obj, OBJECT_MAGIC); return (ctx->req->obj->objcore->flags & OC_F_PASS ? 1 : 0); } + +/*--------------------------------------------------------------------*/ + +#define HTTP_VAR(x) \ +struct http * \ +VRT_r_##x(const struct vrt_ctx *ctx) \ +{ \ + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); \ + CHECK_OBJ_NOTNULL(ctx->http_##x, HTTP_MAGIC); \ + return (ctx->http_##x); \ +} + +HTTP_VAR(req) +HTTP_VAR(resp) +HTTP_VAR(bereq) +HTTP_VAR(beresp) diff --git a/bin/varnishtest/tests/m00000.vtc b/bin/varnishtest/tests/m00000.vtc index 5704a1f..b3ac748 100644 --- a/bin/varnishtest/tests/m00000.vtc +++ b/bin/varnishtest/tests/m00000.vtc @@ -2,6 +2,7 @@ varnishtest "Test std & debug vmod" server s1 { rxreq + expect req.http.encrypted == "ROT52" txresp -hdr "foo: bAr" -hdr "bar: fOo" -bodylen 4 } -start @@ -9,6 +10,10 @@ varnish v1 -vcl+backend { import ${vmod_std}; import ${vmod_debug}; + sub vcl_recv { + debug.rot52(req); + } + sub vcl_deliver { set resp.http.foo = std.toupper(resp.http.foo); set resp.http.bar = std.tolower(resp.http.bar); @@ -17,6 +22,7 @@ varnish v1 -vcl+backend { debug.test_priv_vcl(); std.log("VCL initiated log"); std.syslog(8 + 7, "Somebody runs varnishtest"); + debug.rot52(resp); } } -start @@ -27,6 +33,7 @@ client c1 { expect resp.bodylen == "4" expect resp.http.foo == "BAR" expect resp.http.bar == "foo" + expect resp.http.encrypted == "ROT52" } -run varnish v1 -errvcl {Wrong enum value. Expected one of:} { diff --git a/include/vrt.h b/include/vrt.h index 066d6c8..efc9c94 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -41,7 +41,7 @@ #define VRT_MAJOR_VERSION 1U -#define VRT_MINOR_VERSION 1U +#define VRT_MINOR_VERSION 2U /***********************************************************************/ @@ -59,21 +59,23 @@ struct suckaddr; /*********************************************************************** * This is the central definition of the mapping from VCL types to * C-types. The python scripts read these from here. + * (alphabetic order) */ typedef struct director * VCL_BACKEND; +typedef const struct vmod_priv * VCL_BLOB; typedef unsigned VCL_BOOL; typedef double VCL_BYTES; typedef double VCL_DURATION; typedef const char * VCL_ENUM; typedef const struct gethdr_s * VCL_HEADER; +typedef struct http * VCL_HTTP; typedef long VCL_INT; typedef const struct suckaddr * VCL_IP; typedef double VCL_REAL; typedef const char * VCL_STRING; typedef double VCL_TIME; typedef void VCL_VOID; -typedef const struct vmod_priv * VCL_BLOB; /*********************************************************************** * This is the composite argument we pass to compiled VCL and VRT diff --git a/lib/libvcc/generate.py b/lib/libvcc/generate.py index 2906588..21173c4 100755 --- a/lib/libvcc/generate.py +++ b/lib/libvcc/generate.py @@ -197,6 +197,13 @@ sp_variables = [ specified by the -n parameter. """ ), + ('req', + 'HTTP', + ( 'client',), + ( ), """ + The entire request HTTP data structure + """ + ), ('req.method', 'STRING', ( 'client',), @@ -294,6 +301,13 @@ sp_variables = [ always (re)fetch from the backend. """ ), + ('bereq', + 'HTTP', + ( 'backend',), + ( ), """ + The entire backend request HTTP data structure + """ + ), ('bereq.xid', 'STRING', ( 'backend',), @@ -370,6 +384,13 @@ sp_variables = [ backend. Not available in pipe mode. """ ), + ('beresp', + 'HTTP', + ( 'backend_response', 'backend_error'), + ( ), """ + The entire backend response HTTP data structure + """ + ), ('beresp.proto', 'STRING', ( 'backend_response', 'backend_error'), @@ -553,6 +574,13 @@ sp_variables = [ ( ), """ """ ), + ('resp', + 'HTTP', + ( 'deliver', 'synth'), + ( ), """ + The entire response HTTP data structure + """ + ), ('resp.proto', 'STRING', ( 'deliver', 'synth', ), @@ -597,17 +625,17 @@ aliases = [ stv_variables = ( ('free_space', 'BYTES', "0.", 'storage..free_space', """ - Free space available in the named stevedore. Only available for - the malloc stevedore. - """), + Free space available in the named stevedore. Only available for + the malloc stevedore. + """), ('used_space', 'BYTES', "0.", 'storage..used_space', """ - Used space in the named stevedore. Only available for the malloc - stevedore. - """), + Used space in the named stevedore. Only available for the malloc + stevedore. + """), ('happy', 'BOOL', "0", 'storage..happy', """ - Health status for the named stevedore. Not available in any of the - current stevedores. - """), + Health status for the named stevedore. Not available in any of the + current stevedores. + """), ) ####################################################################### @@ -1188,11 +1216,11 @@ hdr="storage" fp_vclvar.write("\n" + hdr + "\n"); fp_vclvar.write("~" * len(hdr) + "\n"); for i in stv_variables: - fp_vclvar.write("\n" + i[3] + "\n\n") - fp_vclvar.write("\tType: " + i[1] + "\n\n") - fp_vclvar.write("\tReadable from: client, backend\n\n") - for j in i[4].split("\n"): - fp_vclvar.write("\t%s\n" % j.strip()) + fp_vclvar.write("\n" + i[3] + "\n\n") + fp_vclvar.write("\tType: " + i[1] + "\n\n") + fp_vclvar.write("\tReadable from: client, backend\n\n") + for j in i[4].split("\n"): + fp_vclvar.write("\t%s\n" % j.strip()) fp_vclvar.close() diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py index 21c6c6d..25a901f 100755 --- a/lib/libvcc/vmodtool.py +++ b/lib/libvcc/vmodtool.py @@ -47,10 +47,12 @@ from pprint import pprint, pformat ctypes = { 'BACKEND': "VCL_BACKEND", + 'BLOB': "VCL_BLOB", 'BOOL': "VCL_BOOL", 'DURATION': "VCL_DURATION", 'ENUM': "VCL_ENUM", 'HEADER': "VCL_HEADER", + 'HTTP': "VCL_HTTP", 'INT': "VCL_INT", 'IP': "VCL_IP", 'PRIV_CALL': "struct vmod_priv *", @@ -60,7 +62,6 @@ ctypes = { 'STRING_LIST': "const char *, ...", 'TIME': "VCL_TIME", 'VOID': "VCL_VOID", - 'BLOB': "VCL_BLOB", } ####################################################################### diff --git a/lib/libvmod_debug/vmod.vcc b/lib/libvmod_debug/vmod.vcc index 8667298..ca1b307 100644 --- a/lib/libvmod_debug/vmod.vcc +++ b/lib/libvmod_debug/vmod.vcc @@ -80,3 +80,8 @@ Foo indeed. $Method TIME .date() You never know when you need a date. + +$Function VOID rot52(HTTP) + +Encrypt the HTTP header with quad-ROT13 encryption, +(this is approx 33% better than triple-DES). diff --git a/lib/libvmod_debug/vmod_debug.c b/lib/libvmod_debug/vmod_debug.c index 744b10d..b952f64 100644 --- a/lib/libvmod_debug/vmod_debug.c +++ b/lib/libvmod_debug/vmod_debug.c @@ -138,3 +138,12 @@ vmod_no_backend(const struct vrt_ctx *ctx) return (NULL); } +VCL_VOID __match_proto__(td_debug_rot52) +vmod_rot52(const struct vrt_ctx *ctx, VCL_HTTP hp) +{ + + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC); + + http_PrintfHeader(hp, "Encrypted: ROT52"); +} From nils.goroll at uplex.de Fri Jul 25 13:31:32 2014 From: nils.goroll at uplex.de (Nils Goroll) Date: Fri, 25 Jul 2014 15:31:32 +0200 Subject: [master] 7812674 really bail out if no usable readline found Message-ID: commit 78126742bfa3831959b3cbb3e8ff58e45ff49dd6 Author: Nils Goroll Date: Fri Jul 25 15:31:04 2014 +0200 really bail out if no usable readline found Fixes #1555 diff --git a/configure.ac b/configure.ac index ced8495..3c35abd 100644 --- a/configure.ac +++ b/configure.ac @@ -142,7 +142,7 @@ AC_SUBST(PCRE_LIBS) PKG_CHECK_MODULES([LIBEDIT], [libedit], [AC_DEFINE([HAVE_LIBEDIT], [1], [Define we have libedit])], [AX_LIB_READLINE]) -if test "$ac_cv_have_readline" = no; then +if test "x$ac_cv_have_readline" != xyes; then AC_MSG_ERROR([libedit or readline not found]) fi From fgsch at lodoss.net Fri Jul 25 15:06:09 2014 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Fri, 25 Jul 2014 17:06:09 +0200 Subject: [master] fc32d37 Revert "really bail out if no usable readline found" Message-ID: commit fc32d379c4721b189ac2ead9b6b0f7319248a63c Author: Federico G. Schwindt Date: Fri Jul 25 15:44:42 2014 +0100 Revert "really bail out if no usable readline found" This reverts commit 78126742 since it broke master. diff --git a/configure.ac b/configure.ac index 3c35abd..ced8495 100644 --- a/configure.ac +++ b/configure.ac @@ -142,7 +142,7 @@ AC_SUBST(PCRE_LIBS) PKG_CHECK_MODULES([LIBEDIT], [libedit], [AC_DEFINE([HAVE_LIBEDIT], [1], [Define we have libedit])], [AX_LIB_READLINE]) -if test "x$ac_cv_have_readline" != xyes; then +if test "$ac_cv_have_readline" = no; then AC_MSG_ERROR([libedit or readline not found]) fi From phk at FreeBSD.org Mon Jul 28 08:00:09 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 28 Jul 2014 10:00:09 +0200 Subject: [master] 358fb47 Remove a couple of #ifdefs that serve no purpose anymore. Message-ID: commit 358fb4790f977eba5ef910879607cb7ce507eb7a Author: Poul-Henning Kamp Date: Mon Jul 28 07:27:56 2014 +0000 Remove a couple of #ifdefs that serve no purpose anymore. diff --git a/bin/varnishd/mgt/mgt_param_tbl.c b/bin/varnishd/mgt/mgt_param_tbl.c index 90c37fc..5df87bb 100644 --- a/bin/varnishd/mgt/mgt_param_tbl.c +++ b/bin/varnishd/mgt/mgt_param_tbl.c @@ -534,21 +534,13 @@ struct parspec mgt_parspec[] = { "Directory from which relative VCL filenames (vcl.load and " "include) are opened.", 0, -#ifdef VARNISH_VCL_DIR VARNISH_VCL_DIR, -#else - ".", -#endif NULL }, { "vmod_dir", tweak_string, &mgt_vmod_dir, NULL, NULL, "Directory where VCL modules are to be found.", 0, -#ifdef VARNISH_VMOD_DIR VARNISH_VMOD_DIR, -#else - ".", -#endif NULL }, { "vcc_err_unref", tweak_bool, &mgt_vcc_err_unref, From phk at FreeBSD.org Mon Jul 28 08:00:09 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 28 Jul 2014 10:00:09 +0200 Subject: [master] b05810b Define VARNISH_VMOD_DIR and VARNISH_VCL_DIR Message-ID: commit b05810baa15b46f8ffc66701d41dbbc8807ee251 Author: Poul-Henning Kamp Date: Mon Jul 28 07:53:32 2014 +0000 Define VARNISH_VMOD_DIR and VARNISH_VCL_DIR diff --git a/bin/varnishd/flint.sh b/bin/varnishd/flint.sh index 63b406d..4f471cf 100755 --- a/bin/varnishd/flint.sh +++ b/bin/varnishd/flint.sh @@ -16,6 +16,8 @@ flexelint \ -I../.. \ -I/usr/local/include \ -DVARNISH_STATE_DIR=\"foo\" \ + -DVARNISH_VMOD_DIR=\"foo\" \ + -DVARNISH_VCL_DIR=\"foo\" \ cache/*.c \ common/*.c \ storage/*.c \ From phk at FreeBSD.org Mon Jul 28 08:00:10 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 28 Jul 2014 10:00:10 +0200 Subject: [master] ea1e9ab Rename shm_reclen to vsl_reclen for consistency. Message-ID: commit ea1e9ab8c451b33a2e3c2b5d9fbfd4bdc4bbf825 Author: Poul-Henning Kamp Date: Mon Jul 28 07:57:33 2014 +0000 Rename shm_reclen to vsl_reclen for consistency. Leave shm_reclen as a parameter alias for now. Parameter vsl_buffer must be 12 bytes larger than vsl_reclen in order to avoid a panic when we try to put 12 pounds of VSL into a 5 pound vsl_buffer sack. Tweak the opposite parameter Minimum or Maximum value when we set one of of these parameters. Fixes #1547 diff --git a/bin/varnishd/cache/cache_shmlog.c b/bin/varnishd/cache/cache_shmlog.c index 7eba6ac..74b11d7 100644 --- a/bin/varnishd/cache/cache_shmlog.c +++ b/bin/varnishd/cache/cache_shmlog.c @@ -179,7 +179,7 @@ vslr(enum VSL_tag_e tag, uint32_t vxid, const char *b, unsigned len) uint32_t *p; unsigned mlen; - mlen = cache_param->shm_reclen; + mlen = cache_param->vsl_reclen; /* Truncate */ if (len > mlen) @@ -209,7 +209,7 @@ void VSL(enum VSL_tag_e tag, uint32_t vxid, const char *fmt, ...) { va_list ap; - unsigned n, mlen = cache_param->shm_reclen; + unsigned n, mlen = cache_param->vsl_reclen; char buf[mlen]; AN(fmt); @@ -267,7 +267,7 @@ VSLbt(struct vsl_log *vsl, enum VSL_tag_e tag, txt t) Tcheck(t); if (vsl_tag_is_masked(tag)) return; - mlen = cache_param->shm_reclen; + mlen = cache_param->vsl_reclen; /* Truncate */ l = Tlen(t); @@ -321,7 +321,7 @@ VSLbv(struct vsl_log *vsl, enum VSL_tag_e tag, const char *fmt, va_list ap) return; } - mlen = cache_param->shm_reclen; + mlen = cache_param->vsl_reclen; /* Flush if we cannot fit a full size record */ if (VSL_END(vsl->wlp, mlen + 1) >= vsl->wle) diff --git a/bin/varnishd/common/params.h b/bin/varnishd/common/params.h index 7e208af..35c0a7a 100644 --- a/bin/varnishd/common/params.h +++ b/bin/varnishd/common/params.h @@ -103,7 +103,7 @@ struct params { unsigned http_resp_hdr_len; unsigned http_max_hdr; - unsigned shm_reclen; + unsigned vsl_reclen; double timeout_linger; double timeout_idle; diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c index b5aec87..e8a1763 100644 --- a/bin/varnishd/mgt/mgt_param.c +++ b/bin/varnishd/mgt/mgt_param.c @@ -484,6 +484,7 @@ MCF_SetMinimum(const char *param, const char *new_min) { struct parspec *pp; + AN(new_min); pp = mcf_findpar(param); AN(pp); pp->min = new_min; @@ -495,6 +496,7 @@ MCF_SetMaximum(const char *param, const char *new_max) { struct parspec *pp; + AN(new_max); pp = mcf_findpar(param); AN(pp); pp->max = new_max; diff --git a/bin/varnishd/mgt/mgt_param.h b/bin/varnishd/mgt/mgt_param.h index 3263537..f60180b 100644 --- a/bin/varnishd/mgt/mgt_param.h +++ b/bin/varnishd/mgt/mgt_param.h @@ -63,6 +63,8 @@ tweak_t tweak_timeout; tweak_t tweak_uint; tweak_t tweak_user; tweak_t tweak_waiter; +tweak_t tweak_vsl_buffer; +tweak_t tweak_vsl_reclen; int tweak_generic_uint(struct vsb *vsb, volatile unsigned *dest, const char *arg, const char *min, const char *max); diff --git a/bin/varnishd/mgt/mgt_param_tbl.c b/bin/varnishd/mgt/mgt_param_tbl.c index 5df87bb..6651a93 100644 --- a/bin/varnishd/mgt/mgt_param_tbl.c +++ b/bin/varnishd/mgt/mgt_param_tbl.c @@ -160,23 +160,27 @@ struct parspec mgt_parspec[] = { 0, "64", "header lines" }, { "vsl_buffer", - tweak_bytes_u, &mgt_param.vsl_buffer, + tweak_vsl_buffer, &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" - " the longest HTTP header to be logged.\n" "Setting this too high costs memory, setting it too low" " will cause more VSL flushes and likely increase" - " lock-contention on the VSL mutex.\n" - "Minimum is 1k bytes.", + " lock-contention on the VSL mutex.\n\n" + "The minimum tracks the vsl_reclen parameter + 12 bytes.", 0, "4k", "bytes" }, + { "vsl_reclen", + tweak_vsl_reclen, &mgt_param.vsl_reclen, + "16", "65535", + "Maximum number of bytes in SHM log record.\n\n" + "The maximum tracks the vsl_buffer parameter - 12 bytes.", + 0, + "255", "bytes" }, { "shm_reclen", - tweak_bytes_u, &mgt_param.shm_reclen, + tweak_vsl_reclen, &mgt_param.vsl_reclen, "16", "65535", - "Maximum number of bytes in SHM log record.\n" - "Maximum is 65535 bytes.", + "Old name for vsl_reclen, use that instead.", 0, "255", "bytes" }, { "timeout_idle", tweak_timeout, &mgt_param.timeout_idle, diff --git a/bin/varnishd/mgt/mgt_param_tweak.c b/bin/varnishd/mgt/mgt_param_tweak.c index 4e2645f..7d9fb4f 100644 --- a/bin/varnishd/mgt/mgt_param_tweak.c +++ b/bin/varnishd/mgt/mgt_param_tweak.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -330,6 +331,45 @@ tweak_bytes_u(struct vsb *vsb, const struct parspec *par, const char *arg) } /*-------------------------------------------------------------------- + * vsl_buffer and vsl_reclen have dependencies. + */ + +int +tweak_vsl_buffer(struct vsb *vsb, const struct parspec *par, const char *arg) +{ + volatile unsigned *d1; + volatile ssize_t dest; + char buf[20]; + + d1 = par->priv; + dest = *d1; + if (tweak_generic_bytes(vsb, &dest, arg, par->min, par->max)) + return (-1); + *d1 = dest; + bprintf(buf, "%u", *d1 - 12); + MCF_SetMaximum("vsl_reclen", strdup(buf)); + MCF_SetMaximum("shm_reclen", strdup(buf)); + return (0); +} + +int +tweak_vsl_reclen(struct vsb *vsb, const struct parspec *par, const char *arg) +{ + volatile unsigned *d1; + volatile ssize_t dest; + char buf[20]; + + d1 = par->priv; + dest = *d1; + if (tweak_generic_bytes(vsb, &dest, arg, par->min, par->max)) + return (-1); + *d1 = dest; + bprintf(buf, "%u", *d1 + 12); + MCF_SetMinimum("vsl_buffer", strdup(buf)); + return (0); +} + +/*-------------------------------------------------------------------- * 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 From phk at FreeBSD.org Mon Jul 28 08:04:51 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 28 Jul 2014 10:04:51 +0200 Subject: [master] aa01242 Un-copy&paste all the spaces back into TABs Message-ID: commit aa01242a2ea879bdab99444c29555cd6e9e2f70d Author: Poul-Henning Kamp Date: Mon Jul 28 08:04:28 2014 +0000 Un-copy&paste all the spaces back into TABs diff --git a/lib/libvarnishapi/generate.py b/lib/libvarnishapi/generate.py index f8cc671..82f7c59 100755 --- a/lib/libvarnishapi/generate.py +++ b/lib/libvarnishapi/generate.py @@ -37,121 +37,121 @@ import copy srcroot = "../.." buildroot = "../.." if len(sys.argv) == 3: - srcroot = sys.argv[1] - buildroot = sys.argv[2] + srcroot = sys.argv[1] + buildroot = sys.argv[2] ####################################################################### # These are our tokens tokens = { - # Numerical comparisons - "T_EQ": "==", - "T_NEQ": "!=", - "T_LEQ": "<=", - "T_GEQ": ">=", + # Numerical comparisons + "T_EQ": "==", + "T_NEQ": "!=", + "T_LEQ": "<=", + "T_GEQ": ">=", - # String comparisons - "T_SEQ": "eq", - "T_SNEQ": "ne", + # String comparisons + "T_SEQ": "eq", + "T_SNEQ": "ne", - # Regular expression matching - "T_NOMATCH": "!~", + # Regular expression matching + "T_NOMATCH": "!~", - # Boolean operators - "T_AND": "and", - "T_OR": "or", - "T_NOT": "not", + # Boolean operators + "T_AND": "and", + "T_OR": "or", + "T_NOT": "not", - # Miscellaneous - None: "<>~[]{}():,", + # Miscellaneous + None: "<>~[]{}():,", - # These have handwritten recognizers - "VAL": None, - "EOI": None, + # These have handwritten recognizers + "VAL": None, + "EOI": None, - # Special - "T_TRUE": None, + # Special + "T_TRUE": None, } ####################################################################### # Emit a function to recognize tokens in a string def emit_vxp_fixed_token(fo, tokens): - recog = list() - emit = dict() - for i in tokens: - j = tokens[i] - if (j != None): - recog.append(j) - emit[j] = i - - recog.sort() - rrecog = copy.copy(recog) - rrecog.sort(key = lambda x: -len(x)) - - fo.write(""" + recog = list() + emit = dict() + for i in tokens: + j = tokens[i] + if (j != None): + recog.append(j) + emit[j] = i + + recog.sort() + rrecog = copy.copy(recog) + rrecog.sort(key = lambda x: -len(x)) + + fo.write(""" unsigned vxp_fixed_token(const char *p, const char **q) { \tswitch (p[0]) { """) - last_initial = None - for i in recog: - if (i[0] == last_initial): - continue - last_initial = i[0] - fo.write("\tcase '%s':\n" % last_initial) - for j in rrecog: - if (j[0] != last_initial): - continue - - fo.write("\t\tif (") - k = 1 - l = len(j) - while (k < l): - fo.write("p[%d] == '%s'" % (k, j[k])) - fo.write(" &&\n\t\t ") - k += 1 - fo.write("(isword(p[%d]) ? !isword(p[%d]) : 1)) {\n" % - (l - 1, l)) - fo.write("\t\t\t*q = p + %d;\n" % l) - fo.write("\t\t\treturn (%s);\n" % emit[j]) - fo.write("\t\t}\n"); - fo.write("\t\treturn (0);\n") - - fo.write("\tdefault:\n\t\treturn (0);\n\t}\n}\n") + last_initial = None + for i in recog: + if (i[0] == last_initial): + continue + last_initial = i[0] + fo.write("\tcase '%s':\n" % last_initial) + for j in rrecog: + if (j[0] != last_initial): + continue + + fo.write("\t\tif (") + k = 1 + l = len(j) + while (k < l): + fo.write("p[%d] == '%s'" % (k, j[k])) + fo.write(" &&\n\t\t ") + k += 1 + fo.write("(isword(p[%d]) ? !isword(p[%d]) : 1)) {\n" % + (l - 1, l)) + fo.write("\t\t\t*q = p + %d;\n" % l) + fo.write("\t\t\treturn (%s);\n" % emit[j]) + fo.write("\t\t}\n"); + fo.write("\t\treturn (0);\n") + + fo.write("\tdefault:\n\t\treturn (0);\n\t}\n}\n") ####################################################################### # Emit the vxp_tnames (token->string) conversion array def emit_vxp_tnames(fo, tokens): - fo.write("\nconst char * const vxp_tnames[256] = {\n") - l = list(tokens.keys()) - l.sort() - for i in l: - j = tokens[i] - if j == None: - j = i - if i[0] == "'": - j = i - fo.write("\t[%s] = \"%s\",\n" % (i, j)) - fo.write("};\n") + fo.write("\nconst char * const vxp_tnames[256] = {\n") + l = list(tokens.keys()) + l.sort() + for i in l: + j = tokens[i] + if j == None: + j = i + if i[0] == "'": + j = i + fo.write("\t[%s] = \"%s\",\n" % (i, j)) + fo.write("};\n") ####################################################################### def polish_tokens(tokens): - # Expand single char tokens - st = tokens[None] - del tokens[None] + # Expand single char tokens + st = tokens[None] + del tokens[None] - for i in st: - tokens["'" + i + "'"] = i + for i in st: + tokens["'" + i + "'"] = i ####################################################################### def file_header(fo): - fo.write("""/* + fo.write("""/* * NB: This file is machine generated, DO NOT EDIT! * * Edit and run generate.py instead @@ -170,11 +170,11 @@ j = 128 l = list(tokens.keys()) l.sort() for i in l: - if i[0] == "'": - continue - fo.write("#define\t%s %d\n" % (i, j)) - j += 1 - assert j < 256 + if i[0] == "'": + continue + fo.write("#define\t%s %d\n" % (i, j)) + j += 1 + assert j < 256 fo.close() From phk at FreeBSD.org Mon Jul 28 09:09:01 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 28 Jul 2014 11:09:01 +0200 Subject: [master] ad6bf9c Varnishd needs to run the systems C-compiler to compile the VCL code. Message-ID: commit ad6bf9c0e51954cc45fee92d484e95c666d99685 Author: Poul-Henning Kamp Date: Mon Jul 28 09:03:06 2014 +0000 Varnishd needs to run the systems C-compiler to compile the VCL code. For security reasons, we run the C-compiler in a sandbox process which by default uses the same (non-)privileges as the other sandboxes (VCL compiler, test-loader process and the worker process). On some systems access to the C-compiler is limited, also for reasons of security, and varnishd will fail to compile VCL code, unless all the sandboxes are given access to the C-compiler. Add a new parameter "group_cc" which adds a single gid to the grouplist of the sandbox which executes the cc_command, for the benefit of such systems. Do some slightly related polishing of the docs/help-texts in this area while here anyway. Fixes #1521 diff --git a/bin/varnishd/common/params.h b/bin/varnishd/common/params.h index 35c0a7a..2ce95c6 100644 --- a/bin/varnishd/common/params.h +++ b/bin/varnishd/common/params.h @@ -63,6 +63,10 @@ struct params { char *group; gid_t gid; + /* Extra group for compiler access */ + char *group_cc; + gid_t gid_cc; + /* TTL used for lack of anything better */ double default_ttl; diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c index e8a1763..9feea1a 100644 --- a/bin/varnishd/mgt/mgt_param.c +++ b/bin/varnishd/mgt/mgt_param.c @@ -90,6 +90,10 @@ static const char PROTECTED_TEXT[] = "\n\n" "NB: This parameter is protected and can not be changed."; +static const char ONLY_ROOT_TEXT[] = + "\n\n" + "NB: This parameter only works of varnishd is run as root."; + /*--------------------------------------------------------------------*/ @@ -265,6 +269,8 @@ 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 (pp->flags & ONLY_ROOT) + mcf_wrap(cli, ONLY_ROOT_TEXT); VCLI_Out(cli, "\n\n"); } } @@ -556,6 +562,10 @@ MCF_DumpRstParam(void) printf("%swizard", q); q = ", "; } + if (pp->flags & ONLY_ROOT) { + printf("%sonly_root", q); + q = ", "; + } printf("\n"); } printf("\n"); diff --git a/bin/varnishd/mgt/mgt_param.h b/bin/varnishd/mgt/mgt_param.h index f60180b..1b8204a 100644 --- a/bin/varnishd/mgt/mgt_param.h +++ b/bin/varnishd/mgt/mgt_param.h @@ -47,6 +47,7 @@ struct parspec { #define WIZARD (1<<4) #define PROTECTED (1<<5) #define OBJ_STICKY (1<<6) +#define ONLY_ROOT (1<<7) const char *def; const char *units; }; @@ -56,6 +57,7 @@ tweak_t tweak_bytes; tweak_t tweak_bytes_u; tweak_t tweak_double; tweak_t tweak_group; +tweak_t tweak_group_cc; tweak_t tweak_listen_address; tweak_t tweak_poolparam; tweak_t tweak_string; diff --git a/bin/varnishd/mgt/mgt_param_tbl.c b/bin/varnishd/mgt/mgt_param_tbl.c index 6651a93..bcab043 100644 --- a/bin/varnishd/mgt/mgt_param_tbl.c +++ b/bin/varnishd/mgt/mgt_param_tbl.c @@ -53,11 +53,19 @@ struct parspec mgt_parspec[] = { { "user", tweak_user, NULL, NULL, NULL, "The unprivileged user to run as.", - MUST_RESTART, + MUST_RESTART | ONLY_ROOT, "" }, { "group", tweak_group, NULL, NULL, NULL, "The unprivileged group to run as.", - MUST_RESTART, + MUST_RESTART | ONLY_ROOT, + "" }, + { "group_cc", tweak_group_cc, NULL, NULL, NULL, + "On some systems the C-compiler is restricted so not" + " everybody can run it. This parameter makes it possible" + " to add an extra group to the sandbox process which runs the" + " cc_command, in order to gain access to such a restricted" + " c-compiler.", + ONLY_ROOT, "" }, { "default_ttl", tweak_timeout, &mgt_param.default_ttl, "0", NULL, diff --git a/bin/varnishd/mgt/mgt_param_tweak.c b/bin/varnishd/mgt/mgt_param_tweak.c index 7d9fb4f..e757ec6 100644 --- a/bin/varnishd/mgt/mgt_param_tweak.c +++ b/bin/varnishd/mgt/mgt_param_tweak.c @@ -433,6 +433,38 @@ tweak_group(struct vsb *vsb, const struct parspec *par, const char *arg) return (0); } +/*-------------------------------------------------------------------- + * XXX: see comment for tweak_user, same thing here. + */ + +int +tweak_group_cc(struct vsb *vsb, const struct parspec *par, const char *arg) +{ + struct group *gr; + + (void)par; + if (arg != NULL) { + if (*arg != '\0') { + gr = getgrnam(arg); + if (gr == NULL) { + VSB_printf(vsb, "Unknown group"); + return(-1); + } + REPLACE(mgt_param.group_cc, gr->gr_name); + mgt_param.gid_cc = gr->gr_gid; + } else { + REPLACE(mgt_param.group_cc, ""); + mgt_param.gid_cc = 0; + } + } else if (strlen(mgt_param.group_cc) > 0) { + VSB_printf(vsb, "%s (%d)", + mgt_param.group_cc, (int)mgt_param.gid_cc); + } else { + VSB_printf(vsb, ""); + } + return (0); +} + /*--------------------------------------------------------------------*/ static void diff --git a/bin/varnishd/mgt/mgt_sandbox.c b/bin/varnishd/mgt/mgt_sandbox.c index 83a2aeb..973ec83 100644 --- a/bin/varnishd/mgt/mgt_sandbox.c +++ b/bin/varnishd/mgt/mgt_sandbox.c @@ -51,6 +51,7 @@ #include #include #include +#include #include #include "mgt/mgt.h" @@ -62,14 +63,27 @@ static void __match_proto__(mgt_sandbox_f) mgt_sandbox_unix(enum sandbox_e who) { - (void)who; - if (geteuid() == 0) { - XXXAZ(setgid(mgt_param.gid)); - XXXAZ(initgroups(mgt_param.user, mgt_param.gid)); - XXXAZ(setuid(mgt_param.uid)); - } else { +#define NGID 10 + gid_t gid_list[NGID]; + int i; + + if (geteuid() != 0) { REPORT0(LOG_INFO, "Not running as root, no priv-sep"); + return; } + + XXXAZ(setgid(mgt_param.gid)); + XXXAZ(initgroups(mgt_param.user, mgt_param.gid)); + + if (who == SANDBOX_CC && strlen(mgt_param.group_cc) > 0) { + /* Add the optional extra group for the C-compiler access */ + i = getgroups(NGID, gid_list); + assert(i >= 0); + gid_list[i++] = mgt_param.gid_cc; + XXXAZ(setgroups(i, gid_list)); + } + + XXXAZ(setuid(mgt_param.uid)); } #endif diff --git a/bin/varnishtest/tests/r01518.vtc b/bin/varnishtest/tests/r01518.vtc new file mode 100644 index 0000000..11791ae --- /dev/null +++ b/bin/varnishtest/tests/r01518.vtc @@ -0,0 +1,30 @@ +varnishtest "304 body handling with ESI" + +server s1 { + rxreq + txresp -hdr "Last-Modified: Wed, 04 Jun 2014 08:48:52 GMT" \ + -body {} + + rxreq + expect req.url == "/bar" + txresp -body {} + +} -start + +varnish v1 -vcl+backend { + sub vcl_backend_response { + set beresp.do_esi = true; + } +} -start + +client c1 { + txreq + rxresp + expect resp.bodylen == 12 + expect resp.status == 200 + + txreq -hdr "If-Modified-Since: Wed, 04 Jun 2014 08:48:52 GMT" + rxresp + expect resp.status == 304 + expect resp.bodylen == 0 +} -run diff --git a/doc/sphinx/reference/varnishd.rst b/doc/sphinx/reference/varnishd.rst index 633ea43..e1d02bb 100644 --- a/doc/sphinx/reference/varnishd.rst +++ b/doc/sphinx/reference/varnishd.rst @@ -226,6 +226,15 @@ restart reload The VCL programs must be reloaded for this parameter to take effect. +experimental + We're not really sure about this parameter, tell us what you find. + +wizard + Do not touch unless you *really* know what you're doing. + +only_root + Only works if varnishd is running as root. + Here is a list of all parameters, current as of last time we remembered to update the manual page. This text is produced from the same text you will find in the CLI if you use the param.show command, From phk at FreeBSD.org Mon Jul 28 09:12:54 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 28 Jul 2014 11:12:54 +0200 Subject: [master] 4b9b71b Remove a comment overtaken by events. Message-ID: commit 4b9b71b65109857a239a2df32dee1fa970376f3f Author: Poul-Henning Kamp Date: Mon Jul 28 09:12:42 2014 +0000 Remove a comment overtaken by events. diff --git a/bin/varnishd/mgt/mgt_param_tbl.c b/bin/varnishd/mgt/mgt_param_tbl.c index bcab043..55889bc 100644 --- a/bin/varnishd/mgt/mgt_param_tbl.c +++ b/bin/varnishd/mgt/mgt_param_tbl.c @@ -44,12 +44,6 @@ "\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. - * XXX: we should generate the relevant section of varnishd.1 from here. - */ - struct parspec mgt_parspec[] = { { "user", tweak_user, NULL, NULL, NULL, "The unprivileged user to run as.", @@ -64,7 +58,7 @@ struct parspec mgt_parspec[] = { " everybody can run it. This parameter makes it possible" " to add an extra group to the sandbox process which runs the" " cc_command, in order to gain access to such a restricted" - " c-compiler.", + " C-compiler.", ONLY_ROOT, "" }, { "default_ttl", tweak_timeout, &mgt_param.default_ttl, From phk at FreeBSD.org Mon Jul 28 10:01:44 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 28 Jul 2014 12:01:44 +0200 Subject: [master] 53687f5 If workspace_thread is not be big enough to hold all the objcore pointers that need to be purged we iterate until done. Message-ID: commit 53687f5b1e0fca2d5ad0a5deb271b2be7703aa49 Author: Poul-Henning Kamp Date: Mon Jul 28 10:00:15 2014 +0000 If workspace_thread is not be big enough to hold all the objcore pointers that need to be purged we iterate until done. Fixes #1551 diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index 68e0ae1..ad1b874 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -561,44 +561,55 @@ HSH_Purge(struct worker *wrk, struct objhead *oh, double ttl, double grace, double keep) { struct objcore *oc, **ocp; - unsigned spc, nobj, n; + unsigned spc, ospc, nobj, n; + int more = 0; double now; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC); - spc = WS_Reserve(wrk->aws, 0); - ocp = (void*)wrk->aws->f; - Lck_Lock(&oh->mtx); - assert(oh->refcnt > 0); - nobj = 0; - now = VTIM_real(); - VTAILQ_FOREACH(oc, &oh->objcs, list) { - CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); - assert(oc->objhead == oh); - if (oc->flags & OC_F_BUSY) { - /* - * We cannot purge busy objects here, because their - * owners have special rights to them, and may nuke - * them without concern for the refcount, which by - * definition always must be one, so they don't check. - */ - continue; + ospc = WS_Reserve(wrk->aws, 0); + assert(ospc >= sizeof *ocp); + do { + more = 0; + spc = ospc; + nobj = 0; + ocp = (void*)wrk->aws->f; + Lck_Lock(&oh->mtx); + assert(oh->refcnt > 0); + now = VTIM_real(); + VTAILQ_FOREACH(oc, &oh->objcs, list) { + CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); + assert(oc->objhead == oh); + if (oc->flags & OC_F_BUSY) { + /* + * We cannot purge busy objects here, because + * their owners have special rights to them, + * and may nuke them without concern for the + * refcount, which by definition always must + * be one, so they don't check. + */ + continue; + } + if (oc->exp_flags & OC_EF_DYING) + continue; + if (spc < sizeof *ocp) { + /* Iterate if aws is not big enough */ + more = 1; + break; + } + oc->refcnt++; + spc -= sizeof *ocp; + ocp[nobj++] = oc; } - if (oc->exp_flags & OC_EF_DYING) - continue; - xxxassert(spc >= sizeof *ocp); - oc->refcnt++; - spc -= sizeof *ocp; - ocp[nobj++] = oc; - } - Lck_Unlock(&oh->mtx); + Lck_Unlock(&oh->mtx); - for (n = 0; n < nobj; n++) { - oc = ocp[n]; - CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); - EXP_Rearm(oc, now, ttl, grace, keep); - (void)HSH_DerefObjCore(&wrk->stats, &oc); - } + for (n = 0; n < nobj; n++) { + oc = ocp[n]; + CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); + EXP_Rearm(oc, now, ttl, grace, keep); + (void)HSH_DerefObjCore(&wrk->stats, &oc); + } + } while (more); WS_Release(wrk->aws, 0); Pool_PurgeStat(nobj); } From phk at FreeBSD.org Mon Jul 28 10:41:31 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 28 Jul 2014 12:41:31 +0200 Subject: [master] 36bde61 Remove a FreeBSD specific #include that does not apply to our copy of vqueue.h Message-ID: commit 36bde61a224ba8b217b910a1a0e5e36adf5fc1d5 Author: Poul-Henning Kamp Date: Mon Jul 28 10:40:55 2014 +0000 Remove a FreeBSD specific #include that does not apply to our copy of vqueue.h diff --git a/include/vqueue.h b/include/vqueue.h index 55bc23c..a8b248d 100644 --- a/include/vqueue.h +++ b/include/vqueue.h @@ -33,8 +33,6 @@ #ifndef VARNISH_QUEUE_H #define VARNISH_QUEUE_H -#include - /* * This file defines four types of data structures: singly-linked lists, * singly-linked tail queues, lists and tail queues. From phk at FreeBSD.org Mon Jul 28 11:31:42 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 28 Jul 2014 13:31:42 +0200 Subject: [master] 380c935 Tweak these two test cases for 32 bit systems Message-ID: commit 380c9351fc9226afab41d4338e4b8f4d30d3883d Author: Poul-Henning Kamp Date: Mon Jul 28 11:31:23 2014 +0000 Tweak these two test cases for 32 bit systems diff --git a/bin/varnishtest/tests/c00044.vtc b/bin/varnishtest/tests/c00044.vtc index 091e8a8..587bf38 100644 --- a/bin/varnishtest/tests/c00044.vtc +++ b/bin/varnishtest/tests/c00044.vtc @@ -42,7 +42,7 @@ 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.s1.g_bytes > 1000000 -varnish v1 -expect SMA.s1.g_space < 180 +varnish v1 -expect SMA.s1.g_space < 200 varnish v1 -expect SMA.s2.g_bytes == 0 varnish v1 -expect SMA.s2.g_space > 1000000 @@ -57,9 +57,9 @@ 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.s1.g_bytes > 1000000 -varnish v1 -expect SMA.s1.g_space < 180 +varnish v1 -expect SMA.s1.g_space < 200 varnish v1 -expect SMA.s2.g_bytes > 1000000 -varnish v1 -expect SMA.s2.g_space < 180 +varnish v1 -expect SMA.s2.g_space < 200 client c1 { txreq -url /burp @@ -70,11 +70,11 @@ client c1 { varnish v1 -expect SMA.Transient.g_bytes == 0 varnish v1 -expect SMA.s0.g_bytes > 1000000 -varnish v1 -expect SMA.s0.g_space < 180 +varnish v1 -expect SMA.s0.g_space < 200 varnish v1 -expect SMA.s1.g_bytes > 1000000 -varnish v1 -expect SMA.s1.g_space < 180 +varnish v1 -expect SMA.s1.g_space < 200 varnish v1 -expect SMA.s2.g_bytes > 1000000 -varnish v1 -expect SMA.s2.g_space < 180 +varnish v1 -expect SMA.s2.g_space < 200 client c1 { txreq -url /foo1 diff --git a/bin/varnishtest/tests/c00045.vtc b/bin/varnishtest/tests/c00045.vtc index 33b7b9e..77425cb 100644 --- a/bin/varnishtest/tests/c00045.vtc +++ b/bin/varnishtest/tests/c00045.vtc @@ -48,7 +48,7 @@ client c1 { varnish v1 -expect n_lru_nuked == 1 varnish v1 -expect SMA.Transient.g_bytes == 0 varnish v1 -expect SMA.s0.g_bytes > 1000000 -varnish v1 -expect SMA.s0.g_space < 1180 +varnish v1 -expect SMA.s0.g_space < 1190 varnish v1 -expect SMA.s1.g_bytes == 0 varnish v1 -expect SMA.s1.g_space > 1000000 varnish v1 -expect SMA.s2.g_bytes == 0 @@ -64,7 +64,7 @@ client c1 { varnish v1 -expect n_lru_nuked == 2 varnish v1 -expect SMA.Transient.g_bytes == 0 varnish v1 -expect SMA.s0.g_bytes > 1000000 -varnish v1 -expect SMA.s0.g_space < 1182 +varnish v1 -expect SMA.s0.g_space < 1192 varnish v1 -expect SMA.s1.g_bytes == 0 varnish v1 -expect SMA.s1.g_space > 1000000 varnish v1 -expect SMA.s2.g_bytes == 0 From phk at FreeBSD.org Mon Jul 28 12:15:31 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 28 Jul 2014 14:15:31 +0200 Subject: [master] 215a1c8 Ensure that smp_object always are a multiple of 8 bytes. Message-ID: commit 215a1c887d70f0fe4b2dc26f2e8a75d9560b8ce5 Author: Poul-Henning Kamp Date: Mon Jul 28 12:14:55 2014 +0000 Ensure that smp_object always are a multiple of 8 bytes. diff --git a/bin/varnishd/storage/storage_persistent.h b/bin/varnishd/storage/storage_persistent.h index 7d423e1..68f969d 100644 --- a/bin/varnishd/storage/storage_persistent.h +++ b/bin/varnishd/storage/storage_persistent.h @@ -145,6 +145,7 @@ struct smp_segptr { struct smp_object { uint8_t hash[32]; /* really: DIGEST_LEN */ struct exp exp; + uint32_t __filler__; /* -> align/8 on 32bit */ double ban; uint64_t ptr; /* rel to silo */ }; diff --git a/bin/varnishd/storage/storage_persistent_mgt.c b/bin/varnishd/storage/storage_persistent_mgt.c index f99a6ae..33f41e0 100644 --- a/bin/varnishd/storage/storage_persistent_mgt.c +++ b/bin/varnishd/storage/storage_persistent_mgt.c @@ -136,6 +136,10 @@ smp_mgt_init(struct stevedore *parent, int ac, char * const *av) ASSERT_MGT(); AZ(av[ac]); + + /* Necessary alignment. See also smp_object::__filler__ */ + assert(sizeof(struct smp_object) % 8 == 0); + #define SIZOF(foo) fprintf(stderr, \ "sizeof(%s) = %zu = 0x%zx\n", #foo, sizeof(foo), sizeof(foo)); SIZOF(struct smp_ident); From fgsch at lodoss.net Mon Jul 28 15:40:20 2014 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Mon, 28 Jul 2014 17:40:20 +0200 Subject: [master] 4ff36a6 Typo Message-ID: commit 4ff36a6ee595260fcc277dcb12ede0d6bc98930d Author: Federico G. Schwindt Date: Mon Jul 28 14:03:22 2014 +0100 Typo diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c index 9feea1a..500916e 100644 --- a/bin/varnishd/mgt/mgt_param.c +++ b/bin/varnishd/mgt/mgt_param.c @@ -92,7 +92,7 @@ static const char PROTECTED_TEXT[] = static const char ONLY_ROOT_TEXT[] = "\n\n" - "NB: This parameter only works of varnishd is run as root."; + "NB: This parameter only works if varnishd is run as root."; /*--------------------------------------------------------------------*/ From fgsch at lodoss.net Mon Jul 28 15:40:20 2014 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Mon, 28 Jul 2014 17:40:20 +0200 Subject: [master] bda503f Zap space Message-ID: commit bda503f712a8d930a66c5b10b5d9af933474cfd0 Author: Federico G. Schwindt Date: Mon Jul 28 14:03:41 2014 +0100 Zap space diff --git a/bin/varnishd/cache/cache_rfc2616.c b/bin/varnishd/cache/cache_rfc2616.c index 1b8f891..a58f282 100644 --- a/bin/varnishd/cache/cache_rfc2616.c +++ b/bin/varnishd/cache/cache_rfc2616.c @@ -235,7 +235,7 @@ RFC2616_Body(struct busyobj *bo, struct dstat *stats) } if (http_HdrIs(hp, H_Transfer_Encoding, "chunked")) { - stats->fetch_chunked++; + stats->fetch_chunked++; return (BS_CHUNKED); } From fgsch at lodoss.net Mon Jul 28 15:40:20 2014 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Mon, 28 Jul 2014 17:40:20 +0200 Subject: [master] 8c8de70 Remove text - it no longer applies in V4 Message-ID: commit 8c8de70449da9da530fe6fcb61ab68fe5855318f Author: Federico G. Schwindt Date: Mon Jul 28 14:04:04 2014 +0100 Remove text - it no longer applies in V4 diff --git a/lib/libvcc/generate.py b/lib/libvcc/generate.py index 21173c4..4a3e820 100755 --- a/lib/libvcc/generate.py +++ b/lib/libvcc/generate.py @@ -436,8 +436,6 @@ sp_variables = [ 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', From phk at FreeBSD.org Tue Jul 29 11:22:55 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 29 Jul 2014 13:22:55 +0200 Subject: [master] 0d6629b Correctly fail bad reads in req.body Message-ID: commit 0d6629b1574e0f01c1cc72bc3a550ec132a92301 Author: Poul-Henning Kamp Date: Tue Jul 29 11:22:16 2014 +0000 Correctly fail bad reads in req.body Spotted and fixed by: Nils Goroll Fixes #1562 diff --git a/bin/varnishd/cache/cache_http1_fsm.c b/bin/varnishd/cache/cache_http1_fsm.c index 4139bca..66063be 100644 --- a/bin/varnishd/cache/cache_http1_fsm.c +++ b/bin/varnishd/cache/cache_http1_fsm.c @@ -558,6 +558,10 @@ HTTP1_IterateReqBody(struct req *req, req_body_iter_f *func, void *priv) VSLb(req->vsl, SLT_VCL_Error, "Uncached req.body can only be consumed once."); return (-1); + case REQ_BODY_FAIL: + VSLb(req->vsl, SLT_FetchError, + "Had failed reading req.body before."); + return (-1); default: WRONG("Wrong req_body_status in HTTP1_IterateReqBody()"); } diff --git a/bin/varnishtest/tests/r01562.vtc b/bin/varnishtest/tests/r01562.vtc new file mode 100644 index 0000000..af979ab --- /dev/null +++ b/bin/varnishtest/tests/r01562.vtc @@ -0,0 +1,49 @@ +varnishtest "retrying a short client body read should not panic varnish" + +server s1 { + non-fatal + rxreq + txresp -status 200 -hdr "Foo: BAR" -body "1234" +} -start + +server s2 { + non-fatal + rxreq + txresp -status 200 -hdr "Foo: Foo" -body "56" +} -start + +varnish v1 -cliok "param.set vcc_allow_inline_c true" -vcl+backend { + sub vcl_recv { + return (pass); + } + sub vcl_backend_fetch { + if (bereq.retries >= 1) { + set bereq.backend = s2; + } else { + set bereq.backend = s1; + } + } + sub vcl_backend_error { + return (retry); + } +} -start + +varnish v1 -cliok "param.set debug +syncvsl" + +client c1 { + txreq -req "POST" -nolen -hdr "Content-Length: 10000" -bodylen 9999 +} -run + +delay .4 + +server s1 { + rxreq + txresp -status 200 -bodylen 11 +} -start + +client c1 { + txreq + rxresp + expect resp.status == 200 + expect resp.bodylen == 11 +} -run From phk at FreeBSD.org Tue Jul 29 17:34:03 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 29 Jul 2014 19:34:03 +0200 Subject: [master] 66f4529 Rearrange some deck-chairs so panic messages can get better. Message-ID: commit 66f4529244063c83b11c8607ed2c5a50e3a13d06 Author: Poul-Henning Kamp Date: Tue Jul 29 17:09:17 2014 +0000 Rearrange some deck-chairs so panic messages can get better. diff --git a/lib/libvcc/generate.py b/lib/libvcc/generate.py index 4a3e820..a2947c6 100755 --- a/lib/libvcc/generate.py +++ b/lib/libvcc/generate.py @@ -911,15 +911,19 @@ typedef void vcl_fini_f(struct cli *); typedef int vcl_func_f(const struct vrt_ctx *ctx); """) +def tbl40(a, b): + while len(a.expandtabs()) < 40: + a += "\t" + return a + b fo.write("\n/* VCL Methods */\n") -n = 0 +n = 1 for i in returns: - fo.write("#define VCL_MET_%s\t\t(1U << %d)\n" % (i[0].upper(), n)) + fo.write(tbl40("#define VCL_MET_%s" % i[0].upper(), "(1U << %d)\n" % n)) n += 1 -fo.write("\n#define VCL_MET_MAX\t\t%d\n" % n) -fo.write("\n#define VCL_MET_MASK\t\t0x%x\n" % ((1 << n) - 1)) +fo.write("\n" + tbl40("#define VCL_MET_MAX", "%d\n" % n)) +fo.write("\n" + tbl40("#define VCL_MET_MASK", "0x%x\n" % ((1 << n) - 1))) fo.write("\n/* VCL Returns */\n") @@ -927,10 +931,10 @@ n = 0 l = list(rets.keys()) l.sort() for i in l: - fo.write("#define VCL_RET_%s\t\t%d\n" % (i.upper(), n)) + fo.write(tbl40("#define VCL_RET_%s" % i.upper(), "%d\n" % n)) n += 1 -fo.write("\n#define VCL_RET_MAX\t\t%d\n" % n) +fo.write("\n" + tbl40("#define VCL_RET_MAX", "%d\n" % n)) fo.write(""" diff --git a/lib/libvcc/vcc_compile.c b/lib/libvcc/vcc_compile.c index 31212aa..4077c1c 100644 --- a/lib/libvcc/vcc_compile.c +++ b/lib/libvcc/vcc_compile.c @@ -65,6 +65,7 @@ #include "vfil.h" struct method method_tab[] = { + { "none", 0U, 0}, #define VCL_MET_MAC(l,U,m) { "vcl_"#l, m, VCL_MET_##U }, #include "tbl/vcl_returns.h" #undef VCL_MET_MAC @@ -666,7 +667,7 @@ vcc_CompileSource(const struct vcc *tl0, struct vsb *sb, struct source *sp) return (vcc_DestroyTokenList(tl, NULL)); /* Emit method functions */ - for (i = 0; i < VCL_MET_MAX; i++) { + for (i = 1; i < VCL_MET_MAX; i++) { Fh(tl, 1, "\nint __match_proto__(vcl_func_f)\n"); Fh(tl, 1, "VGC_function_%s(const struct vrt_ctx *ctx);\n", From phk at FreeBSD.org Tue Jul 29 17:34:04 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 29 Jul 2014 19:34:04 +0200 Subject: [master] 6002065 Improve panic reporting of VCL methods: a '*' indicates that we are currently in the method. Message-ID: commit 60020658a83bd6d55dea1b307efd085b6ac57c68 Author: Poul-Henning Kamp Date: Tue Jul 29 17:33:20 2014 +0000 Improve panic reporting of VCL methods: a '*' indicates that we are currently in the method. Also add a list of methods we have previously called. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index f711959..315ec4c 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -332,6 +332,7 @@ struct worker { struct vxid_pool vxid_pool; unsigned cur_method; + unsigned seen_methods; unsigned handling; }; diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index 4e11fe6..9b9a7a9 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -268,21 +268,42 @@ static void pan_wrk(const struct worker *wrk) { const char *hand; + unsigned m, u; + const char *p; VSB_printf(pan_vsp, " worker = %p {\n", wrk); pan_ws(wrk->aws, 4); - hand = VCL_Method_Name(wrk->cur_method); + m = wrk->cur_method; + VSB_printf(pan_vsp, " VCL::method = "); + if (m == 0) { + VSB_printf(pan_vsp, "none,\n"); + return; + } + if (!(m & 1)) + VSB_printf(pan_vsp, "*"); + m &= ~1; + hand = VCL_Method_Name(m); if (hand != NULL) - VSB_printf(pan_vsp, " VCL::method = %s,\n", hand); + VSB_printf(pan_vsp, "%s,\n", hand); else - VSB_printf(pan_vsp, " VCL::method = 0x%x,\n", wrk->cur_method); + VSB_printf(pan_vsp, "0x%x,\n", m); hand = VCL_Return_Name(wrk->handling); if (hand != NULL) VSB_printf(pan_vsp, " VCL::return = %s,\n", hand); else VSB_printf(pan_vsp, " VCL::return = 0x%x,\n", wrk->handling); - VSB_printf(pan_vsp, " },\n"); + VSB_printf(pan_vsp, " VCL::methods = {"); + m = wrk->seen_methods; + p = ""; + for (u = 1; m ; u <<= 1) { + if (m & u) { + VSB_printf(pan_vsp, "%s%s", p, VCL_Method_Name(u)); + m &= ~u; + p = ", "; + } + } + VSB_printf(pan_vsp, "},\n },\n"); } static void diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c index 1678ea3..7e48a86 100644 --- a/bin/varnishd/cache/cache_vcl.c +++ b/bin/varnishd/cache/cache_vcl.c @@ -450,11 +450,12 @@ vcl_call_method(struct worker *wrk, struct req *req, struct busyobj *bo, aws = WS_Snapshot(wrk->aws); wrk->handling = 0; wrk->cur_method = method; + wrk->seen_methods |= method; AN(vsl); VSLb(vsl, SLT_VCL_call, "%s", VCL_Method_Name(method)); (void)func(&ctx); VSLb(vsl, SLT_VCL_return, "%s", VCL_Return_Name(wrk->handling)); - wrk->cur_method = 0; + wrk->cur_method |= 1; // Magic marker /* * VCL/Vmods are not allowed to make permanent allocations from From phk at FreeBSD.org Tue Jul 29 18:47:24 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 29 Jul 2014 20:47:24 +0200 Subject: [master] 398d7c6 Ensure that we never call a VDP with a zero length unless we are done. Message-ID: commit 398d7c6e3b2abf5ccc3b1def91a862636058fa6e Author: Poul-Henning Kamp Date: Tue Jul 29 18:44:17 2014 +0000 Ensure that we never call a VDP with a zero length unless we are done. Fixes #1561 diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 315ec4c..37bc660 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -833,6 +833,7 @@ VDP_bytes(struct req *req, enum vdp_action act, const void *ptr, ssize_t len) CHECK_OBJ_NOTNULL(req, REQ_MAGIC); + assert(act > VDP_NULL || len > 0); /* Call the present layer, while pointing to the next layer down */ i = req->vdp_nxt--; assert(i >= 0 && i < N_VDPS); diff --git a/bin/varnishd/cache/cache_obj.c b/bin/varnishd/cache/cache_obj.c index 00d5bc9..ba0979b 100644 --- a/bin/varnishd/cache/cache_obj.c +++ b/bin/varnishd/cache/cache_obj.c @@ -77,9 +77,12 @@ ObjIter(struct objiter *oi, void **p, ssize_t *l) oi->st = VTAILQ_FIRST(&oi->obj->body->list); else oi->st = VTAILQ_NEXT(oi->st, list); + while(oi->st != NULL && oi->st->len == 0) + oi->st = VTAILQ_NEXT(oi->st, list); if (oi->st != NULL) { *p = oi->st->ptr; *l = oi->st->len; + assert(*l > 0); return (OIS_DATA); } return (OIS_DONE); From phk at FreeBSD.org Tue Jul 29 19:09:46 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 29 Jul 2014 21:09:46 +0200 Subject: [master] a309f19 Make a dedicated cleanup function for req->vary_? to match the dedicated setup function we have. Message-ID: commit a309f194b7c0cb74652da9f01fbde513c807ce33 Author: Poul-Henning Kamp Date: Tue Jul 29 19:09:09 2014 +0000 Make a dedicated cleanup function for req->vary_? to match the dedicated setup function we have. Fixes #1553 diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 37bc660..ceaf2e6 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -1143,6 +1143,7 @@ int VRY_Create(struct busyobj *bo, struct vsb **psb); int VRY_Match(struct req *, const uint8_t *vary); unsigned VRY_Validate(const uint8_t *vary); void VRY_Prep(struct req *); +void VRY_Clear(struct req *); enum vry_finish_flag { KEEP, DISCARD }; void VRY_Finish(struct req *req, enum vry_finish_flag); diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index e630160..9cb5c34 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -469,8 +469,7 @@ cnt_lookup(struct worker *wrk, struct req *req) if (boc != NULL) { (void)HSH_DerefObjCore(&wrk->stats, &boc); - free(req->vary_b); - req->vary_b = NULL; + VRY_Clear(req); } return (REQ_FSM_MORE); @@ -524,7 +523,7 @@ cnt_miss(struct worker *wrk, struct req *req) default: WRONG("Illegal return from vcl_miss{}"); } - free(req->vary_b); + VRY_Clear(req); if (o != NULL) (void)HSH_DerefObj(&wrk->stats, &o); AZ(HSH_DerefObjCore(&wrk->stats, &req->objcore)); diff --git a/bin/varnishd/cache/cache_vary.c b/bin/varnishd/cache/cache_vary.c index 4baa65a..e4a7628 100644 --- a/bin/varnishd/cache/cache_vary.c +++ b/bin/varnishd/cache/cache_vary.c @@ -238,6 +238,18 @@ VRY_Prep(struct req *req) req->vary_b[2] = '\0'; } +void +VRY_Clear(struct req *req) +{ + + CHECK_OBJ_NOTNULL(req, REQ_MAGIC); + if (req->vary_b != NULL) + free(req->vary_b); + req->vary_b = NULL; + AZ(req->vary_e); + AZ(req->vary_l); +} + /********************************************************************** * Finish predictive vary processing */ From phk at FreeBSD.org Wed Jul 30 08:31:03 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 30 Jul 2014 10:31:03 +0200 Subject: [master] 5020806 Make VBF_Fetch() take an objcore* to the ims-candidate. Message-ID: commit 5020806aec860bfe608c8f520643104f5768bbcf Author: Poul-Henning Kamp Date: Wed Jul 30 08:30:05 2014 +0000 Make VBF_Fetch() take an objcore* to the ims-candidate. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index ceaf2e6..1e5cc3e 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -898,7 +898,7 @@ enum vbf_fetch_mode_e { VBF_BACKGROUND = 2, }; void VBF_Fetch(struct worker *wrk, struct req *req, - struct objcore *oc, struct object *oldobj, enum vbf_fetch_mode_e); + struct objcore *oc, struct objcore *oldoc, enum vbf_fetch_mode_e); /* cache_fetch_proc.c */ struct storage *VFP_GetStorage(struct vfp_ctx *, ssize_t sz); diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index e0320fc..4f6d78a 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -852,17 +852,21 @@ vbf_fetch_thread(struct worker *wrk, void *priv) void VBF_Fetch(struct worker *wrk, struct req *req, struct objcore *oc, - struct object *oldobj, enum vbf_fetch_mode_e mode) + struct objcore *oldoc, enum vbf_fetch_mode_e mode) { struct busyobj *bo; const char *how; + struct object *oldobj = NULL; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(req, REQ_MAGIC); CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); - CHECK_OBJ_ORNULL(oldobj, OBJECT_MAGIC); + CHECK_OBJ_ORNULL(oldoc, OBJCORE_MAGIC); + if (oldoc != NULL) + oldobj = ObjGetObj(oldoc, &wrk->stats); + switch(mode) { case VBF_PASS: how = "pass"; break; case VBF_NORMAL: how = "fetch"; break; diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 9cb5c34..3e17779 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -426,7 +426,7 @@ cnt_lookup(struct worker *wrk, struct req *req) AZ(oc->flags & (OC_F_FAILED|OC_F_PASS)); AZ(oc->exp_flags & OC_EF_DYING); AZ(boc->busyobj); - VBF_Fetch(wrk, req, boc, o, VBF_BACKGROUND); + VBF_Fetch(wrk, req, boc, oc, VBF_BACKGROUND); } else { (void)HTTP1_DiscardReqBody(req);// XXX: handle err } @@ -506,7 +506,7 @@ cnt_miss(struct worker *wrk, struct req *req) switch (wrk->handling) { case VCL_RET_FETCH: wrk->stats.cache_miss++; - VBF_Fetch(wrk, req, req->objcore, o, VBF_NORMAL); + VBF_Fetch(wrk, req, req->objcore, o == NULL ? NULL : o->objcore, VBF_NORMAL); req->req_step = R_STP_FETCH; if (o != NULL) (void)HSH_DerefObj(&wrk->stats, &o); From phk at FreeBSD.org Wed Jul 30 08:43:36 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 30 Jul 2014 10:43:36 +0200 Subject: [master] ce0cd5e Put a parallel ims_oc next to ims_obj. Message-ID: commit ce0cd5e6765b15e263bcf48e23b231bd975732fe Author: Poul-Henning Kamp Date: Wed Jul 30 08:43:08 2014 +0000 Put a parallel ims_oc next to ims_obj. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 1e5cc3e..c142c07 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -497,6 +497,7 @@ struct busyobj { struct http *bereq; struct http *beresp; struct object *ims_obj; + struct objcore *ims_oc; struct objcore *fetch_objcore; struct object *fetch_obj; diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 4f6d78a..f6c93c7 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -545,8 +545,7 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) VBO_setstate(bo, BOS_FINISHED); VSLb_ts_busyobj(bo, "BerespBody", W_TIM_real(wrk)); if (bo->ims_obj != NULL) - EXP_Rearm(bo->ims_obj->objcore, - bo->ims_obj->objcore->exp.t_origin, 0, 0, 0); + EXP_Rearm(bo->ims_oc, bo->ims_oc->exp.t_origin, 0, 0, 0); return (F_STP_DONE); } @@ -638,8 +637,7 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo) assert(al == bo->ims_obj->len); assert(obj->len == al); - EXP_Rearm(bo->ims_obj->objcore, - bo->ims_obj->objcore->exp.t_origin, 0, 0, 0); + EXP_Rearm(bo->ims_oc, bo->ims_oc->exp.t_origin, 0, 0, 0); /* Recycle the backend connection before setting BOS_FINISHED to give predictable backend reuse behavior for varnishtest */ @@ -840,8 +838,10 @@ vbf_fetch_thread(struct worker *wrk, void *priv) } AZ(bo->fetch_objcore->busyobj); - if (bo->ims_obj != NULL) - (void)HSH_DerefObj(&wrk->stats, &bo->ims_obj); + if (bo->ims_oc != NULL) { + (void)HSH_DerefObjCore(&wrk->stats, &bo->ims_oc); + bo->ims_obj = NULL; + } VBO_DerefBusyObj(wrk, &bo); THR_SetBusyobj(NULL); @@ -864,9 +864,6 @@ VBF_Fetch(struct worker *wrk, struct req *req, struct objcore *oc, CHECK_OBJ_ORNULL(oldoc, OBJCORE_MAGIC); - if (oldoc != NULL) - oldobj = ObjGetObj(oldoc, &wrk->stats); - switch(mode) { case VBF_PASS: how = "pass"; break; case VBF_NORMAL: how = "fetch"; break; @@ -898,12 +895,17 @@ VBF_Fetch(struct worker *wrk, struct req *req, struct objcore *oc, bo->fetch_objcore = oc; AZ(bo->ims_obj); - if (oldobj != NULL) { + AZ(bo->ims_oc); + if (oldoc != NULL) { + oldobj = ObjGetObj(oldoc, &wrk->stats); + CHECK_OBJ_NOTNULL(oldobj, OBJECT_MAGIC); + if (http_GetHdr(oldobj->http, H_Last_Modified, NULL) || http_GetHdr(oldobj->http, H_ETag, NULL)) { - assert(oldobj->objcore->refcnt > 0); - HSH_Ref(oldobj->objcore); + assert(oldoc->refcnt > 0); + HSH_Ref(oldoc); bo->ims_obj = oldobj; + bo->ims_oc = oldoc; } } From apj at mutt.dk Wed Jul 30 08:55:43 2014 From: apj at mutt.dk (Andreas Plesner) Date: Wed, 30 Jul 2014 10:55:43 +0200 Subject: [master] 2323cab Use SI case for modifiers, fix spelling of (E)xa Message-ID: commit 2323cab770c9d60b36a1933528d01de473bb3077 Author: Andreas Plesner Date: Wed Jul 30 10:55:22 2014 +0200 Use SI case for modifiers, fix spelling of (E)xa diff --git a/doc/sphinx/reference/varnishd.rst b/doc/sphinx/reference/varnishd.rst index e1d02bb..dbe5db8 100644 --- a/doc/sphinx/reference/varnishd.rst +++ b/doc/sphinx/reference/varnishd.rst @@ -76,10 +76,10 @@ OPTIONS -l shl[,free[,fill]] Specifies size of shmlog file. shl is the store for the - shared memory log records [80m], free is the store for other - allocations [1m] and fill determines how the log is [+]. - Scaling suffixes like 'k', 'm' can be used up to - (e)tabytes. Default is 80 Megabytes. + shared memory log records [80M], free is the store for other + allocations [1M] and fill determines how the log is [+]. + Scaling suffixes like 'k', 'M' can be used up to + (E)xabytes. Default is 80 Megabytes. -M address:port Connect to this port and offer the command line interface. From phk at FreeBSD.org Wed Jul 30 09:11:51 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 30 Jul 2014 11:11:51 +0200 Subject: [master] 3790d27 Add table of (future) object attributes Message-ID: commit 3790d27321381919ea78ccabd955ac131704857d Author: Poul-Henning Kamp Date: Wed Jul 30 09:11:22 2014 +0000 Add table of (future) object attributes diff --git a/include/Makefile.am b/include/Makefile.am index 2091ab5..766eb9a 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -13,6 +13,7 @@ nobase_pkginclude_HEADERS = \ tbl/http_headers.h \ tbl/http_response.h \ tbl/locks.h \ + tbl/obj_attr.h \ tbl/req_body.h \ tbl/sess_close.h \ tbl/steps.h \ diff --git a/include/tbl/obj_attr.h b/include/tbl/obj_attr.h new file mode 100644 index 0000000..c1f2d10 --- /dev/null +++ b/include/tbl/obj_attr.h @@ -0,0 +1,42 @@ +/*- + * Copyright (c) 2014 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. + * + */ + +/*lint -save -e525 -e539 */ + +/* upper, lower */ +OBJ_ATTR(VXID, vxid) +OBJ_ATTR(EXP, exp) +OBJ_ATTR(VARY, vary) +OBJ_ATTR(HEADERS, headers) +OBJ_ATTR(GZIPED, gziped) +OBJ_ATTR(CHGGZIPED, chggziped) +OBJ_ATTR(GZIPBITS, gzipbits) +OBJ_ATTR(ESIDATA, esidata) + +/*lint -restore */ From phk at FreeBSD.org Wed Jul 30 09:34:59 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 30 Jul 2014 11:34:59 +0200 Subject: [master] 4fdc58e Implement a first erzats version of ObjGetattr() Message-ID: commit 4fdc58eed9fe491b0532c8a30f479680ef682eda Author: Poul-Henning Kamp Date: Wed Jul 30 09:34:27 2014 +0000 Implement a first erzats version of ObjGetattr() diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index c142c07..38fff60 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -374,14 +374,12 @@ struct storage { */ typedef struct object *getobj_f(struct dstat *ds, struct objcore *oc); -typedef unsigned getxid_f(struct dstat *ds, struct objcore *oc); typedef void updatemeta_f(struct objcore *oc); typedef void freeobj_f(struct dstat *ds, struct objcore *oc); typedef struct lru *getlru_f(const struct objcore *oc); struct objcore_methods { getobj_f *getobj; - getxid_f *getxid; updatemeta_f *updatemeta; freeobj_f *freeobj; getlru_f *getlru; @@ -547,6 +545,12 @@ struct body { struct storagehead list; }; +enum obj_attr { +#define OBJ_ATTR(U, l) OA_##U, +#include "tbl/obj_attr.h" +#undef OBJ_ATTR +}; + struct object { unsigned magic; #define OBJECT_MAGIC 0x32851d42 @@ -1055,6 +1059,8 @@ struct object *ObjGetObj(struct objcore *, struct dstat *); void ObjUpdateMeta(struct objcore *); void ObjFreeObj(struct objcore *, struct dstat *); struct lru *ObjGetLRU(const struct objcore *); +ssize_t ObjGetattr(struct objcore *oc, struct dstat *ds, enum obj_attr attr, + void *ptr, ssize_t len); /* cache_panic.c */ void PAN_Init(void); diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index f6c93c7..df5b906 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -544,7 +544,7 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) VBO_setstate(bo, BOS_FINISHED); VSLb_ts_busyobj(bo, "BerespBody", W_TIM_real(wrk)); - if (bo->ims_obj != NULL) + if (bo->ims_oc != NULL) EXP_Rearm(bo->ims_oc, bo->ims_oc->exp.t_origin, 0, 0, 0); return (F_STP_DONE); } diff --git a/bin/varnishd/cache/cache_obj.c b/bin/varnishd/cache/cache_obj.c index ba0979b..b138fd1 100644 --- a/bin/varnishd/cache/cache_obj.c +++ b/bin/varnishd/cache/cache_obj.c @@ -172,15 +172,6 @@ ObjTrimStore(struct objcore *oc, struct dstat *ds) } } -unsigned -ObjGetXID(struct objcore *oc, struct dstat *ds) -{ - const struct objcore_methods *m = obj_getmethods(oc); - - AN(ds); - AN(m->getxid); - return (m->getxid(ds, oc)); -} struct object * ObjGetObj(struct objcore *oc, struct dstat *ds) @@ -221,3 +212,32 @@ ObjGetLRU(const struct objcore *oc) AN(m->getlru); return (m->getlru(oc)); } + +ssize_t +ObjGetattr(struct objcore *oc, struct dstat *ds, enum obj_attr attr, + void *ptr, ssize_t len) +{ + struct object *o; + + CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); + o = ObjGetObj(oc, ds); + CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); + switch (attr) { + case OA_VXID: + assert(len == sizeof o->vxid); + memcpy(ptr, &o->vxid, sizeof o->vxid); + return (sizeof o->vxid); + default: + break; + } + WRONG("Unsupported OBJ_ATTR"); +} + +unsigned +ObjGetXID(struct objcore *oc, struct dstat *ds) +{ + uint32_t u; + + assert(ObjGetattr(oc, ds, OA_VXID, &u, sizeof u) == sizeof u); + return (u); +} diff --git a/bin/varnishd/storage/stevedore.c b/bin/varnishd/storage/stevedore.c index ad2106b..751c0a3 100644 --- a/bin/varnishd/storage/stevedore.c +++ b/bin/varnishd/storage/stevedore.c @@ -48,15 +48,6 @@ static const struct stevedore * volatile stv_next; * Default objcore methods */ -static unsigned __match_proto__(getxid_f) -default_oc_getxid(struct dstat *ds, struct objcore *oc) -{ - struct object *o; - - o = ObjGetObj(oc, ds); - return (o->vxid); -} - static struct object * __match_proto__(getobj_f) default_oc_getobj(struct dstat *ds, struct objcore *oc) { @@ -97,7 +88,6 @@ default_oc_getlru(const struct objcore *oc) const struct objcore_methods default_oc_methods = { .getobj = default_oc_getobj, - .getxid = default_oc_getxid, .freeobj = default_oc_freeobj, .getlru = default_oc_getlru, }; diff --git a/bin/varnishd/storage/storage_persistent_silo.c b/bin/varnishd/storage/storage_persistent_silo.c index 9e747ce..ba56ddc 100644 --- a/bin/varnishd/storage/storage_persistent_silo.c +++ b/bin/varnishd/storage/storage_persistent_silo.c @@ -379,35 +379,6 @@ smp_loaded_st(const struct smp_sc *sc, const struct smp_seg *sg, * objcore methods for persistent objects */ -static unsigned __match_proto__(getxid_f) -smp_oc_getxid(struct dstat *ds, struct objcore *oc) -{ - struct object *o; - struct smp_seg *sg; - struct smp_object *so; - - (void)ds; - CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); - - CAST_OBJ_NOTNULL(sg, oc->priv, SMP_SEG_MAGIC); - so = smp_find_so(sg, oc->priv2); - - o = (void*)(sg->sc->base + so->ptr); - /* - * The object may not be in this segment since we allocate it - * In a separate operation than the smp_object. We could check - * that it is in a later segment, but that would be complicated. - * XXX: For now, be happy if it is inside th silo - */ - ASSERT_PTR_IN_SILO(sg->sc, o); - CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); - return (o->vxid); -} - -/*--------------------------------------------------------------------- - * objcore methods for persistent objects - */ - static struct object * smp_oc_getobj(struct dstat *ds, struct objcore *oc) { @@ -548,7 +519,6 @@ smp_oc_getlru(const struct objcore *oc) } const struct objcore_methods smp_oc_methods = { - .getxid = smp_oc_getxid, .getobj = smp_oc_getobj, .updatemeta = smp_oc_updatemeta, .freeobj = smp_oc_freeobj, From phk at FreeBSD.org Wed Jul 30 09:55:23 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 30 Jul 2014 11:55:23 +0200 Subject: [master] 3aff0b4 Use ObjGetattr() for OA_ESIDATA Message-ID: commit 3aff0b4f04b5cc82e57d4e362a698228ad9f5198 Author: Poul-Henning Kamp Date: Wed Jul 30 09:55:06 2014 +0000 Use ObjGetattr() for OA_ESIDATA diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 38fff60..9952289 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -1060,7 +1060,7 @@ void ObjUpdateMeta(struct objcore *); void ObjFreeObj(struct objcore *, struct dstat *); struct lru *ObjGetLRU(const struct objcore *); ssize_t ObjGetattr(struct objcore *oc, struct dstat *ds, enum obj_attr attr, - void *ptr, ssize_t len); + void **ptr); /* cache_panic.c */ void PAN_Init(void); diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index df87210..b985efc 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -252,6 +252,7 @@ void ESI_Deliver(struct req *req) { struct storage *st; + void *vp; uint8_t *p, *e, *q, *r; unsigned off; ssize_t l, l2, l_icrc = 0; @@ -264,11 +265,10 @@ ESI_Deliver(struct req *req) int i; CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - st = req->obj->esidata; - AN(st); - - p = st->ptr; - e = st->ptr + st->len; + l = ObjGetattr(req->obj->objcore, &req->wrk->stats, OA_ESIDATA, &vp); + assert(l > 0); + p = vp; + e = p + l; if (*p == VEC_GZ) { isgzip = 1; diff --git a/bin/varnishd/cache/cache_obj.c b/bin/varnishd/cache/cache_obj.c index b138fd1..d393411 100644 --- a/bin/varnishd/cache/cache_obj.c +++ b/bin/varnishd/cache/cache_obj.c @@ -214,19 +214,26 @@ ObjGetLRU(const struct objcore *oc) } ssize_t -ObjGetattr(struct objcore *oc, struct dstat *ds, enum obj_attr attr, - void *ptr, ssize_t len) +ObjGetattr(struct objcore *oc, struct dstat *ds, enum obj_attr attr, void **ptr) { struct object *o; + void *dummy; CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); + AN(ds); + if (ptr == NULL) + ptr = &dummy; o = ObjGetObj(oc, ds); CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); switch (attr) { case OA_VXID: - assert(len == sizeof o->vxid); - memcpy(ptr, &o->vxid, sizeof o->vxid); + *ptr = &o->vxid; return (sizeof o->vxid); + case OA_ESIDATA: + if (o->esidata == NULL) + return (-1); + *ptr = o->esidata->ptr; + return (o->esidata->len); default: break; } @@ -236,8 +243,10 @@ ObjGetattr(struct objcore *oc, struct dstat *ds, enum obj_attr attr, unsigned ObjGetXID(struct objcore *oc, struct dstat *ds) { + void *p; uint32_t u; - assert(ObjGetattr(oc, ds, OA_VXID, &u, sizeof u) == sizeof u); + assert(ObjGetattr(oc, ds, OA_VXID, &p) == sizeof u); + memcpy(&u, p, sizeof u); return (u); } From phk at FreeBSD.org Wed Jul 30 10:33:47 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 30 Jul 2014 12:33:47 +0200 Subject: [master] 6a5fff0 Use ObjGetattr() for OA_ESIBITS Message-ID: commit 6a5fff085e796a2a57c73c0bc89b2ccabe4849dc Author: Poul-Henning Kamp Date: Wed Jul 30 10:33:32 2014 +0000 Use ObjGetattr() for OA_ESIBITS diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 9952289..8ea97d8 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -564,9 +564,7 @@ struct object { unsigned changed_gzip:1; /* Bit positions in the gzip stream */ - ssize_t gzip_start; - ssize_t gzip_last; - ssize_t gzip_stop; + ssize_t gzip_bits[3]; ssize_t len; diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index b985efc..d74371a 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -496,6 +496,8 @@ ESI_DeliverChild(struct req *req) struct storage *st; struct object *obj; ssize_t start, last, stop, lpad; + void *vp; + ssize_t l, gzip_bits[3]; u_char cc; uint32_t icrc; uint32_t ilen; @@ -519,9 +521,12 @@ ESI_DeliverChild(struct req *req) AN(dbits); obj = req->obj; CHECK_OBJ_NOTNULL(obj, OBJECT_MAGIC); - start = obj->gzip_start; - last = obj->gzip_last; - stop = obj->gzip_stop; + l = ObjGetattr(obj->objcore, &req->wrk->stats, OA_GZIPBITS, &vp); + assert(l == sizeof gzip_bits); + memcpy(gzip_bits, vp, l); + start = gzip_bits[0]; + last = gzip_bits[1]; + stop = gzip_bits[2]; assert(start > 0 && start < obj->len * 8); assert(last > 0 && last < obj->len * 8); assert(stop > 0 && stop < obj->len * 8); diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index df5b906..2430b16 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -594,9 +594,7 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo) } obj->gziped = bo->ims_obj->gziped; - obj->gzip_start = bo->ims_obj->gzip_start; - obj->gzip_last = bo->ims_obj->gzip_last; - obj->gzip_stop = bo->ims_obj->gzip_stop; + memcpy(obj->gzip_bits, bo->ims_obj->gzip_bits, sizeof obj->gzip_bits); AZ(WS_Overflowed(bo->ws_o)); if (bo->do_stream) { diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c index 66e0845..0521a5f 100644 --- a/bin/varnishd/cache/cache_gzip.c +++ b/bin/varnishd/cache/cache_gzip.c @@ -395,9 +395,9 @@ VGZ_UpdateObj(const struct vgz *vg, struct object *obj) CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC); CHECK_OBJ_NOTNULL(obj, OBJECT_MAGIC); - obj->gzip_start = vg->vz.start_bit; - obj->gzip_last = vg->vz.last_bit; - obj->gzip_stop = vg->vz.stop_bit; + obj->gzip_bits[0] = vg->vz.start_bit; + obj->gzip_bits[1] = vg->vz.last_bit; + obj->gzip_bits[2] = vg->vz.stop_bit; } /*-------------------------------------------------------------------- diff --git a/bin/varnishd/cache/cache_obj.c b/bin/varnishd/cache/cache_obj.c index d393411..e9c0812 100644 --- a/bin/varnishd/cache/cache_obj.c +++ b/bin/varnishd/cache/cache_obj.c @@ -229,6 +229,9 @@ ObjGetattr(struct objcore *oc, struct dstat *ds, enum obj_attr attr, void **ptr) case OA_VXID: *ptr = &o->vxid; return (sizeof o->vxid); + case OA_GZIPBITS: + *ptr = o->gzip_bits; + return (sizeof o->gzip_bits); case OA_ESIDATA: if (o->esidata == NULL) return (-1); From phk at FreeBSD.org Wed Jul 30 11:23:35 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 30 Jul 2014 13:23:35 +0200 Subject: [master] 02671fe Fully convert obj->vxid to an obj_attr Message-ID: commit 02671fe4708e85df21f57a45533bc88ca2f80633 Author: Poul-Henning Kamp Date: Wed Jul 30 11:23:19 2014 +0000 Fully convert obj->vxid to an obj_attr diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 8ea97d8..b13e997 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -554,7 +554,7 @@ enum obj_attr { struct object { unsigned magic; #define OBJECT_MAGIC 0x32851d42 - uint32_t vxid; + char oa_vxid[4]; struct storage *objstore; struct objcore *objcore; @@ -1059,6 +1059,8 @@ void ObjFreeObj(struct objcore *, struct dstat *); struct lru *ObjGetLRU(const struct objcore *); ssize_t ObjGetattr(struct objcore *oc, struct dstat *ds, enum obj_attr attr, void **ptr); +void *ObjSetattr(struct objcore *oc, struct dstat *ds, enum obj_attr attr, + ssize_t len); /* cache_panic.c */ void PAN_Init(void); diff --git a/bin/varnishd/cache/cache_ban.c b/bin/varnishd/cache/cache_ban.c index e6c3ced..552b67a 100644 --- a/bin/varnishd/cache/cache_ban.c +++ b/bin/varnishd/cache/cache_ban.c @@ -967,7 +967,8 @@ BAN_CheckObject(struct worker *wrk, struct objcore *oc, struct req *req) return (0); } else { oc->ban = NULL; - VSLb(vsl, SLT_ExpBan, "%u banned lookup", o->vxid); + VSLb(vsl, SLT_ExpBan, "%u banned lookup", + VXID(ObjGetXID(oc, &wrk->stats))); VSC_C_main->bans_obj_killed++; EXP_Rearm(oc, oc->exp.t_origin, 0, 0, 0); // XXX fake now return (1); @@ -1102,7 +1103,8 @@ ban_lurker_test_ban(struct worker *wrk, struct vsl_log *vsl, struct ban *bt, break; } if (i) { - VSLb(vsl, SLT_ExpBan, "%u banned by lurker", o->vxid); + VSLb(vsl, SLT_ExpBan, "%u banned by lurker", + VXID(ObjGetXID(oc, &wrk->stats))); EXP_Rearm(oc, oc->exp.t_origin, 0, 0, 0); // XXX fake now VSC_C_main->bans_lurker_obj_killed++; } diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 2430b16..a169e38 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -35,6 +35,7 @@ #include #include "cache.h" +#include "vend.h" #include "hash/hash_slinger.h" #include "vcl.h" #include "vtim.h" @@ -101,6 +102,7 @@ vbf_beresp2obj(struct busyobj *bo) uint16_t nhttp; struct object *obj; struct http *hp, *hp2; + void *vp; l = 0; @@ -150,7 +152,8 @@ vbf_beresp2obj(struct busyobj *bo) VSB_delete(vary); } - obj->vxid = bo->vsl->wid; + vp = ObjSetattr(bo->fetch_objcore, bo->stats, OA_VXID, 4); + vbe32enc(vp, bo->vsl->wid); WS_Assert(bo->ws_o); /* Filter into object */ diff --git a/bin/varnishd/cache/cache_obj.c b/bin/varnishd/cache/cache_obj.c index e9c0812..47fd31b 100644 --- a/bin/varnishd/cache/cache_obj.c +++ b/bin/varnishd/cache/cache_obj.c @@ -31,6 +31,7 @@ #include #include "cache.h" +#include "vend.h" #include "storage/storage.h" #include "hash/hash_slinger.h" @@ -227,8 +228,8 @@ ObjGetattr(struct objcore *oc, struct dstat *ds, enum obj_attr attr, void **ptr) CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); switch (attr) { case OA_VXID: - *ptr = &o->vxid; - return (sizeof o->vxid); + *ptr = o->oa_vxid; + return (sizeof o->oa_vxid); case OA_GZIPBITS: *ptr = o->gzip_bits; return (sizeof o->gzip_bits); @@ -243,13 +244,31 @@ ObjGetattr(struct objcore *oc, struct dstat *ds, enum obj_attr attr, void **ptr) WRONG("Unsupported OBJ_ATTR"); } +void * +ObjSetattr(struct objcore *oc, struct dstat *ds, enum obj_attr attr, + ssize_t len) +{ + struct object *o; + CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); + AN(ds); + o = ObjGetObj(oc, ds); + CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); + switch (attr) { + case OA_VXID: + assert(len == sizeof o->oa_vxid); + return (o->oa_vxid); + default: + break; + } + WRONG("Unsupported OBJ_ATTR"); +} + + unsigned ObjGetXID(struct objcore *oc, struct dstat *ds) { void *p; - uint32_t u; - assert(ObjGetattr(oc, ds, OA_VXID, &p) == sizeof u); - memcpy(&u, p, sizeof u); - return (u); + assert(ObjGetattr(oc, ds, OA_VXID, &p) == 4); + return (vbe32dec(p)); } diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index 9b9a7a9..111e8c5 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -39,6 +39,7 @@ #include #include "cache.h" +#include "vend.h" #include "common/heritage.h" #include "cache_backend.h" @@ -215,7 +216,7 @@ pan_object(const char *typ, const struct object *o) const struct storage *st; VSB_printf(pan_vsp, " obj (%s) = %p {\n", typ, o); - VSB_printf(pan_vsp, " vxid = %u,\n", VXID(o->vxid)); + VSB_printf(pan_vsp, " vxid = %u,\n", VXID(vbe32dec(o->oa_vxid))); pan_http("obj", o->http, 4); VSB_printf(pan_vsp, " len = %jd,\n", (intmax_t)o->len); VSB_printf(pan_vsp, " store = {\n"); diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 3e17779..7b4b2f5 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -109,7 +109,7 @@ cnt_deliver(struct worker *wrk, struct req *req) if (req->wrk->stats.cache_hit) http_PrintfHeader(req->resp, "X-Varnish: %u %u", VXID(req->vsl->wid), - VXID(req->obj->vxid)); + VXID(ObjGetXID(req->obj->objcore, &wrk->stats))); else http_PrintfHeader(req->resp, "X-Varnish: %u", VXID(req->vsl->wid)); @@ -404,7 +404,8 @@ cnt_lookup(struct worker *wrk, struct req *req) if (oc->flags & OC_F_PASS) { /* Found a hit-for-pass */ VSLb(req->vsl, SLT_Debug, "XXXX HIT-FOR-PASS"); - VSLb(req->vsl, SLT_HitPass, "%u", req->obj->vxid); + VSLb(req->vsl, SLT_HitPass, "%u", + VXID(ObjGetXID(req->obj->objcore, &wrk->stats))); AZ(boc); (void)HSH_DerefObj(&wrk->stats, &req->obj); req->objcore = NULL; @@ -416,7 +417,8 @@ cnt_lookup(struct worker *wrk, struct req *req) oh = oc->objhead; CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC); - VSLb(req->vsl, SLT_Hit, "%u", req->obj->vxid); + VSLb(req->vsl, SLT_Hit, "%u", + VXID(ObjGetXID(req->obj->objcore, &wrk->stats))); VCL_hit_method(req->vcl, wrk, req, NULL, req->http->ws); From phk at FreeBSD.org Wed Jul 30 12:10:11 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 30 Jul 2014 14:10:11 +0200 Subject: [master] 612d9de Make obj->gzip_bits a full OA also Message-ID: commit 612d9de41d27e712b9da3c0853459afa48e58046 Author: Poul-Henning Kamp Date: Wed Jul 30 12:09:47 2014 +0000 Make obj->gzip_bits a full OA also diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index b13e997..6674100 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -564,7 +564,7 @@ struct object { unsigned changed_gzip:1; /* Bit positions in the gzip stream */ - ssize_t gzip_bits[3]; + char oa_gzipbits[24]; ssize_t len; @@ -928,7 +928,7 @@ int VGZ_ObufFull(const struct vgz *vg); enum vgzret_e VGZ_Gzip(struct vgz *, const void **, size_t *len, enum vgz_flag); enum vgzret_e VGZ_Gunzip(struct vgz *, const void **, size_t *len); enum vgzret_e VGZ_Destroy(struct vgz **); -void VGZ_UpdateObj(const struct vgz*, struct object *); +void VGZ_UpdateObj(struct dstat *ds, const struct vgz*, struct objcore *); vdp_bytes VDP_gunzip; int VGZ_WrwInit(struct vgz *vg); @@ -1057,10 +1057,12 @@ struct object *ObjGetObj(struct objcore *, struct dstat *); void ObjUpdateMeta(struct objcore *); void ObjFreeObj(struct objcore *, struct dstat *); struct lru *ObjGetLRU(const struct objcore *); -ssize_t ObjGetattr(struct objcore *oc, struct dstat *ds, enum obj_attr attr, - void **ptr); +void *ObjGetattr(struct objcore *oc, struct dstat *ds, enum obj_attr attr, + ssize_t *len); void *ObjSetattr(struct objcore *oc, struct dstat *ds, enum obj_attr attr, ssize_t len); +int ObjCopyAttr(struct objcore *ocd, struct objcore *ocs, struct dstat *ds, + enum obj_attr attr); /* cache_panic.c */ void PAN_Init(void); diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index d74371a..3266ade 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -252,7 +252,6 @@ void ESI_Deliver(struct req *req) { struct storage *st; - void *vp; uint8_t *p, *e, *q, *r; unsigned off; ssize_t l, l2, l_icrc = 0; @@ -265,9 +264,9 @@ ESI_Deliver(struct req *req) int i; CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - l = ObjGetattr(req->obj->objcore, &req->wrk->stats, OA_ESIDATA, &vp); + p = ObjGetattr(req->obj->objcore, &req->wrk->stats, OA_ESIDATA, &l); + AN(p); assert(l > 0); - p = vp; e = p + l; if (*p == VEC_GZ) { @@ -496,8 +495,8 @@ ESI_DeliverChild(struct req *req) struct storage *st; struct object *obj; ssize_t start, last, stop, lpad; - void *vp; - ssize_t l, gzip_bits[3]; + ssize_t l; + char *p; u_char cc; uint32_t icrc; uint32_t ilen; @@ -521,12 +520,12 @@ ESI_DeliverChild(struct req *req) AN(dbits); obj = req->obj; CHECK_OBJ_NOTNULL(obj, OBJECT_MAGIC); - l = ObjGetattr(obj->objcore, &req->wrk->stats, OA_GZIPBITS, &vp); - assert(l == sizeof gzip_bits); - memcpy(gzip_bits, vp, l); - start = gzip_bits[0]; - last = gzip_bits[1]; - stop = gzip_bits[2]; + p = ObjGetattr(obj->objcore, &req->wrk->stats, OA_GZIPBITS, &l); + AN(p); + assert(l == 24); + start = vbe64dec(p); + last = vbe64dec(p + 8); + stop = vbe64dec(p + 16); assert(start > 0 && start < obj->len * 8); assert(last > 0 && last < obj->len * 8); assert(stop > 0 && stop < obj->len * 8); diff --git a/bin/varnishd/cache/cache_esi_fetch.c b/bin/varnishd/cache/cache_esi_fetch.c index c4bcef9..8014ca9 100644 --- a/bin/varnishd/cache/cache_esi_fetch.c +++ b/bin/varnishd/cache/cache_esi_fetch.c @@ -132,7 +132,7 @@ vfp_esi_end(struct vfp_ctx *vc, struct vef_priv *vef, } if (vef->vgz != NULL) { - VGZ_UpdateObj(vef->vgz, vc->bo->fetch_obj); + VGZ_UpdateObj(vc->bo->stats, vef->vgz, vc->bo->fetch_objcore); if (VGZ_Destroy(&vef->vgz) != VGZ_END) retval = VFP_Error(vc, "ESI+Gzip Failed at the very end"); diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index a169e38..44bd58e 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -597,7 +597,8 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo) } obj->gziped = bo->ims_obj->gziped; - memcpy(obj->gzip_bits, bo->ims_obj->gzip_bits, sizeof obj->gzip_bits); + + AZ(ObjCopyAttr(bo->fetch_objcore, bo->ims_oc, bo->stats, OA_GZIPBITS)); AZ(WS_Overflowed(bo->ws_o)); if (bo->do_stream) { diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c index 0521a5f..e8112e8 100644 --- a/bin/varnishd/cache/cache_gzip.c +++ b/bin/varnishd/cache/cache_gzip.c @@ -42,6 +42,7 @@ #include #include "cache.h" +#include "vend.h" #include "vgz.h" @@ -390,14 +391,17 @@ VGZ_WrwFlush(struct req *req, struct vgz *vg) /*--------------------------------------------------------------------*/ void -VGZ_UpdateObj(const struct vgz *vg, struct object *obj) +VGZ_UpdateObj(struct dstat *ds, const struct vgz *vg, struct objcore *oc) { + char *p; CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC); - CHECK_OBJ_NOTNULL(obj, OBJECT_MAGIC); - obj->gzip_bits[0] = vg->vz.start_bit; - obj->gzip_bits[1] = vg->vz.last_bit; - obj->gzip_bits[2] = vg->vz.stop_bit; + CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); + p = ObjSetattr(oc, ds, OA_GZIPBITS, 24); + AN(p); + vbe64enc(p, vg->vz.start_bit); + vbe64enc(p + 8, vg->vz.last_bit); + vbe64enc(p + 16, vg->vz.stop_bit); } /*-------------------------------------------------------------------- @@ -597,7 +601,7 @@ vfp_gzip_pull(struct vfp_ctx *vc, struct vfp_entry *vfe, void *p, if (vr != VGZ_END) return (VFP_Error(vc, "Gzip failed")); - VGZ_UpdateObj(vg, vc->bo->fetch_obj); + VGZ_UpdateObj(vc->bo->stats, vg, vc->bo->fetch_objcore); return (VFP_END); } @@ -643,7 +647,7 @@ vfp_testgunzip_pull(struct vfp_ctx *vc, struct vfp_entry *vfe, void *p, if (vp == VFP_END) { if (vr != VGZ_END) return (VFP_Error(vc, "tGunzip failed")); - VGZ_UpdateObj(vg, vc->bo->fetch_obj); + VGZ_UpdateObj(vc->bo->stats, vg, vc->bo->fetch_objcore); } return (vp); } diff --git a/bin/varnishd/cache/cache_obj.c b/bin/varnishd/cache/cache_obj.c index 47fd31b..5ad3e4c 100644 --- a/bin/varnishd/cache/cache_obj.c +++ b/bin/varnishd/cache/cache_obj.c @@ -214,30 +214,29 @@ ObjGetLRU(const struct objcore *oc) return (m->getlru(oc)); } -ssize_t -ObjGetattr(struct objcore *oc, struct dstat *ds, enum obj_attr attr, void **ptr) +void * +ObjGetattr(struct objcore *oc, struct dstat *ds, enum obj_attr attr, + ssize_t *len) { struct object *o; - void *dummy; CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); AN(ds); - if (ptr == NULL) - ptr = &dummy; + AN(len); o = ObjGetObj(oc, ds); CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); switch (attr) { case OA_VXID: - *ptr = o->oa_vxid; - return (sizeof o->oa_vxid); + *len = sizeof o->oa_vxid; + return (o->oa_vxid); case OA_GZIPBITS: - *ptr = o->gzip_bits; - return (sizeof o->gzip_bits); + *len = sizeof o->oa_gzipbits; + return (o->oa_gzipbits); case OA_ESIDATA: if (o->esidata == NULL) - return (-1); - *ptr = o->esidata->ptr; - return (o->esidata->len); + return (NULL); + *len = o->esidata->len; + return (o->esidata->ptr); default: break; } @@ -257,18 +256,41 @@ ObjSetattr(struct objcore *oc, struct dstat *ds, enum obj_attr attr, case OA_VXID: assert(len == sizeof o->oa_vxid); return (o->oa_vxid); + case OA_GZIPBITS: + assert(len == sizeof o->oa_gzipbits); + return (o->oa_gzipbits); default: break; } WRONG("Unsupported OBJ_ATTR"); } +int +ObjCopyAttr(struct objcore *ocd, struct objcore *ocs, struct dstat *ds, + enum obj_attr attr) +{ + void *vps, *vpd; + ssize_t l; + + vps = ObjGetattr(ocs, ds, attr, &l); + // XXX: later we want to have zero-length OA's too + if (vps == NULL || l <= 0) + return (-1); + vpd = ObjSetattr(ocd, ds, attr, l); + if (vpd == NULL) + return (-1); + memcpy(vpd, vps, l); + return (0); +} unsigned ObjGetXID(struct objcore *oc, struct dstat *ds) { + ssize_t l; void *p; - assert(ObjGetattr(oc, ds, OA_VXID, &p) == 4); + p = ObjGetattr(oc, ds, OA_VXID, &l); + AN(p); + assert(l == 4); return (vbe32dec(p)); } From phk at FreeBSD.org Wed Jul 30 12:44:39 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 30 Jul 2014 14:44:39 +0200 Subject: [master] 24303d3 Make obj->last_modified an object_attribute Message-ID: commit 24303d3adaf38a17541f6cd502e003b896db3ba8 Author: Poul-Henning Kamp Date: Wed Jul 30 12:44:19 2014 +0000 Make obj->last_modified an object_attribute diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 6674100..f21c57d 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -569,7 +569,7 @@ struct object { ssize_t len; /* VCL only variables */ - double last_modified; + char oa_lastmodified[8]; struct http *http; @@ -1063,6 +1063,8 @@ void *ObjSetattr(struct objcore *oc, struct dstat *ds, enum obj_attr attr, ssize_t len); int ObjCopyAttr(struct objcore *ocd, struct objcore *ocs, struct dstat *ds, enum obj_attr attr); +int ObjSetLastModified(struct objcore *oc, struct dstat *ds, double t); +double ObjGetLastModified(struct objcore *oc, struct dstat *ds); /* cache_panic.c */ void PAN_Init(void); diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 44bd58e..1e45392 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -165,9 +165,11 @@ vbf_beresp2obj(struct busyobj *bo) http_CopyHome(hp2); if (http_GetHdr(hp, H_Last_Modified, &b)) - obj->last_modified = VTIM_parse(b); + AZ(ObjSetLastModified(bo->fetch_objcore, bo->stats, + VTIM_parse(b))); else - obj->last_modified = floor(bo->fetch_objcore->exp.t_origin); + AZ(ObjSetLastModified(bo->fetch_objcore, bo->stats, + floor(bo->fetch_objcore->exp.t_origin))); /* Disassociate the obj from the bo's workspace */ hp2->ws = NULL; diff --git a/bin/varnishd/cache/cache_obj.c b/bin/varnishd/cache/cache_obj.c index 5ad3e4c..b5a0faa 100644 --- a/bin/varnishd/cache/cache_obj.c +++ b/bin/varnishd/cache/cache_obj.c @@ -229,6 +229,9 @@ ObjGetattr(struct objcore *oc, struct dstat *ds, enum obj_attr attr, case OA_VXID: *len = sizeof o->oa_vxid; return (o->oa_vxid); + case OA_LASTMODIFIED: + *len = sizeof o->oa_lastmodified; + return (o->oa_lastmodified); case OA_GZIPBITS: *len = sizeof o->oa_gzipbits; return (o->oa_gzipbits); @@ -259,6 +262,9 @@ ObjSetattr(struct objcore *oc, struct dstat *ds, enum obj_attr attr, case OA_GZIPBITS: assert(len == sizeof o->oa_gzipbits); return (o->oa_gzipbits); + case OA_LASTMODIFIED: + assert(len == sizeof o->oa_lastmodified); + return (o->oa_lastmodified); default: break; } @@ -294,3 +300,38 @@ ObjGetXID(struct objcore *oc, struct dstat *ds) assert(l == 4); return (vbe32dec(p)); } + +/*-------------------------------------------------------------------- + * NB: Copying double <--> uint64_t for endian encoding is unverified + */ + +int +ObjSetLastModified(struct objcore *oc, struct dstat *ds, double t) +{ + void *vp; + uint64_t u; + + assert(sizeof t == sizeof u); + memcpy(&u, &t, sizeof u); + vp = ObjSetattr(oc, ds, OA_LASTMODIFIED, sizeof u); + if (vp == NULL) + return (-1); + vbe64enc(vp, u); + return (0); +} + +double +ObjGetLastModified(struct objcore *oc, struct dstat *ds) +{ + void *vp; + uint64_t u; + double d; + ssize_t l; + + vp = ObjGetattr(oc, ds, OA_LASTMODIFIED, &l); + AN(vp); + assert(l == sizeof u); + u = vbe64dec(vp); + memcpy(&d, &u, sizeof d); + return (d); +} diff --git a/bin/varnishd/cache/cache_rfc2616.c b/bin/varnishd/cache/cache_rfc2616.c index a58f282..1c26641 100644 --- a/bin/varnishd/cache/cache_rfc2616.c +++ b/bin/varnishd/cache/cache_rfc2616.c @@ -345,19 +345,18 @@ int RFC2616_Do_Cond(const struct req *req) { char *p, *e; - double ims; + double ims, lm; int do_cond = 0; /* RFC 2616 13.3.4 states we need to match both ETag and If-Modified-Since if present*/ if (http_GetHdr(req->http, H_If_Modified_Since, &p) ) { - if (!req->obj->last_modified) - return (0); ims = VTIM_parse(p); if (ims > req->t_req) /* [RFC2616 14.25] */ return (0); - if (req->obj->last_modified > ims) + lm = ObjGetLastModified(req->obj->objcore, &req->wrk->stats); + if (lm > ims) return (0); do_cond = 1; } diff --git a/include/tbl/obj_attr.h b/include/tbl/obj_attr.h index c1f2d10..860fc5c 100644 --- a/include/tbl/obj_attr.h +++ b/include/tbl/obj_attr.h @@ -34,9 +34,9 @@ OBJ_ATTR(VXID, vxid) OBJ_ATTR(EXP, exp) OBJ_ATTR(VARY, vary) OBJ_ATTR(HEADERS, headers) -OBJ_ATTR(GZIPED, gziped) -OBJ_ATTR(CHGGZIPED, chggziped) +OBJ_ATTR(GZIPFLAGS, gzipflags) OBJ_ATTR(GZIPBITS, gzipbits) OBJ_ATTR(ESIDATA, esidata) +OBJ_ATTR(LASTMODIFIED, lastmodified) /*lint -restore */ From phk at FreeBSD.org Wed Jul 30 16:39:56 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 30 Jul 2014 18:39:56 +0200 Subject: [master] 134f273 Restrict charset used for file_id. Message-ID: commit 134f273bd4a1c1e04b700ae5e15c812d45992171 Author: Poul-Henning Kamp Date: Wed Jul 30 16:39:37 2014 +0000 Restrict charset used for file_id. Suggested by: scoof diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py index 25a901f..0553015 100755 --- a/lib/libvcc/vmodtool.py +++ b/lib/libvcc/vmodtool.py @@ -239,7 +239,7 @@ class Vmod(object): # fo.write("\t.file_id = \"") for i in range(32): - fo.write("%c" % random.randint(0x23,0x5b)) + fo.write("%c" % random.randint(0x40,0x5a)) fo.write("\",\n") fo.write("};\n") From fgsch at lodoss.net Thu Jul 31 00:16:48 2014 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Thu, 31 Jul 2014 02:16:48 +0200 Subject: [master] d4f2fd6 Update description Message-ID: commit d4f2fd670fd9eea92e64625fe2377c2b202bd334 Author: Federico G. Schwindt Date: Wed Jul 30 23:36:23 2014 +0100 Update description obj.{grace,ttl} are read-only. diff --git a/lib/libvcc/generate.py b/lib/libvcc/generate.py index a2947c6..3d56bc5 100755 --- a/lib/libvcc/generate.py +++ b/lib/libvcc/generate.py @@ -550,14 +550,13 @@ sp_variables = [ ( 'hit', ), ( ), """ The object's remaining time to live, in seconds. - obj.ttl is writable. """ ), ('obj.grace', 'DURATION', ( 'hit', ), ( ), """ - The object's grace period in seconds. obj.grace is writable. + The object's grace period in seconds. """ ), ('obj.keep', From phk at FreeBSD.org Thu Jul 31 09:17:31 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 31 Jul 2014 11:17:31 +0200 Subject: [master] c79c30b Fix printf formats for MacOS 10.9.4 Message-ID: commit c79c30bcdb9b29c6bec346e3d071611f2dea60fc Author: Poul-Henning Kamp Date: Thu Jul 31 09:16:58 2014 +0000 Fix printf formats for MacOS 10.9.4 Reported by: Meng Zhang diff --git a/bin/varnishd/cache/cache_http1_fsm.c b/bin/varnishd/cache/cache_http1_fsm.c index 66063be..4290c47 100644 --- a/bin/varnishd/cache/cache_http1_fsm.c +++ b/bin/varnishd/cache/cache_http1_fsm.c @@ -705,12 +705,12 @@ HTTP1_CacheReqBody(struct req *req, ssize_t maxsize) http_Unset(req->http0, H_Content_Length); http_Unset(req->http0, H_Transfer_Encoding); http_PrintfHeader(req->http0, "Content-Length: %ju", - req->req_bodybytes); + (uintmax_t)req->req_bodybytes); http_Unset(req->http, H_Content_Length); http_Unset(req->http, H_Transfer_Encoding); http_PrintfHeader(req->http, "Content-Length: %ju", - req->req_bodybytes); + (uintmax_t)req->req_bodybytes); req->req_body_status = REQ_BODY_CACHED; } From phk at FreeBSD.org Thu Jul 31 09:48:35 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 31 Jul 2014 11:48:35 +0200 Subject: [master] 2be788a Bump the limit on how many groups we can deal with. Message-ID: commit 2be788a9420bf9fdc3da2daa9cbfaffb8242faf2 Author: Poul-Henning Kamp Date: Thu Jul 31 09:48:11 2014 +0000 Bump the limit on how many groups we can deal with. diff --git a/bin/varnishd/mgt/mgt_sandbox.c b/bin/varnishd/mgt/mgt_sandbox.c index 973ec83..69ce5fa 100644 --- a/bin/varnishd/mgt/mgt_sandbox.c +++ b/bin/varnishd/mgt/mgt_sandbox.c @@ -63,9 +63,9 @@ static void __match_proto__(mgt_sandbox_f) mgt_sandbox_unix(enum sandbox_e who) { -#define NGID 10 - gid_t gid_list[NGID]; +#define NGID 2000 int i; + gid_t gid_list[NGID]; if (geteuid() != 0) { REPORT0(LOG_INFO, "Not running as root, no priv-sep"); From phk at FreeBSD.org Thu Jul 31 09:49:42 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 31 Jul 2014 11:49:42 +0200 Subject: [master] 9bce25d Default the http timeout to half of the total testduration. Message-ID: commit 9bce25d60fa66c0697309a5e7135d32cc7e469c0 Author: Poul-Henning Kamp Date: Thu Jul 31 09:49:04 2014 +0000 Default the http timeout to half of the total testduration. Fixes #1563 diff --git a/bin/varnishtest/vtc_http.c b/bin/varnishtest/vtc_http.c index 28b7340..f2998d4 100644 --- a/bin/varnishtest/vtc_http.c +++ b/bin/varnishtest/vtc_http.c @@ -1227,7 +1227,7 @@ http_process(struct vtclog *vl, const char *spec, int sock, int *sfd) ALLOC_OBJ(hp, HTTP_MAGIC); AN(hp); hp->fd = sock; - hp->timeout = 15000; + hp->timeout = vtc_maxdur * 1000 / 2; hp->nrxbuf = 2048*1024; hp->vsb = VSB_new_auto(); hp->rxbuf = malloc(hp->nrxbuf); /* XXX */ From fgsch at lodoss.net Thu Jul 31 11:14:17 2014 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Thu, 31 Jul 2014 13:14:17 +0200 Subject: [master] d847200 Fix breakage Message-ID: commit d8472004de754162e5885e688fde1f291843469a Author: Federico G. Schwindt Date: Thu Jul 31 12:12:33 2014 +0100 Fix breakage Un-static-fy vtc_maxdur diff --git a/bin/varnishtest/vtc.c b/bin/varnishtest/vtc.c index a31c83f..c70b267 100644 --- a/bin/varnishtest/vtc.c +++ b/bin/varnishtest/vtc.c @@ -52,6 +52,7 @@ volatile sig_atomic_t vtc_error; /* Error encountered */ int vtc_stop; /* Stops current test without error */ pthread_t vtc_thread; static struct vtclog *vltop; +unsigned vtc_maxdur; /* Max duration of any test */ /********************************************************************** * Macro facility diff --git a/bin/varnishtest/vtc.h b/bin/varnishtest/vtc.h index 6c56926..b877e26 100644 --- a/bin/varnishtest/vtc.h +++ b/bin/varnishtest/vtc.h @@ -69,6 +69,7 @@ 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; +extern unsigned vtc_maxdur; void init_sema(void); diff --git a/bin/varnishtest/vtc_main.c b/bin/varnishtest/vtc_main.c index de08003..823a0a2 100644 --- a/bin/varnishtest/vtc_main.c +++ b/bin/varnishtest/vtc_main.c @@ -73,12 +73,12 @@ struct vtc_job { }; int iflg = 0; +unsigned vtc_maxdur = 60; static VTAILQ_HEAD(, vtc_tst) tst_head = VTAILQ_HEAD_INITIALIZER(tst_head); static struct vev_base *vb; static int njob = 0; static int npar = 1; /* Number of parallel tests */ -static unsigned vtc_maxdur = 60; /* Max duration of any test */ static int vtc_continue; /* Continue on error */ static int vtc_verbosity = 1; /* Verbosity Level */ static int vtc_good; From fgsch at lodoss.net Thu Jul 31 11:55:11 2014 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Thu, 31 Jul 2014 13:55:11 +0200 Subject: [master] 3446fb1 Ensure bereq changes are not lost across vcl_backend_xxx methods Message-ID: commit 3446fb1c563357054c6aa93a08c946ce080c26f1 Author: Federico G. Schwindt Date: Thu Jul 31 12:48:03 2014 +0100 Ensure bereq changes are not lost across vcl_backend_xxx methods Add std.rollback() to rollback req or bereq and mark the builtin rollback as deprecated. Original diff by Nils Goroll. Tweaks and reworked after phk comments by me. Fixes #1512 diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index f21c57d..e171d66 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -490,6 +490,7 @@ struct busyobj { enum busyobj_state_e state; struct ws ws[1]; + char *ws_bo; struct vbc *vbc; struct http *bereq0; struct http *bereq; diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 1e45392..70f467a 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -220,6 +220,10 @@ vbf_stp_mkbereq(const struct worker *wrk, struct busyobj *bo) } } + HTTP_Setup(bo->bereq, bo->ws, bo->vsl, SLT_BereqMethod); + bo->ws_bo = WS_Snapshot(bo->ws); + HTTP_Copy(bo->bereq, bo->bereq0); + VBO_setstate(bo, BOS_REQ_DONE); return (F_STP_STARTFETCH); } @@ -267,9 +271,6 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo) else AZ(bo->req); - HTTP_Setup(bo->bereq, bo->ws, bo->vsl, SLT_BereqMethod); - HTTP_Copy(bo->bereq, bo->bereq0); - http_PrintfHeader(bo->bereq, "X-Varnish: %u", VXID(bo->vsl->wid)); VCL_backend_fetch_method(bo->vcl, wrk, NULL, bo, bo->bereq->ws); diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c index 4038693..edfa2a5 100644 --- a/bin/varnishd/cache/cache_vrt.c +++ b/bin/varnishd/cache/cache_vrt.c @@ -357,13 +357,22 @@ VRT_BOOL_string(unsigned val) /*--------------------------------------------------------------------*/ void -VRT_Rollback(const struct vrt_ctx *ctx) +VRT_Rollback(const struct vrt_ctx *ctx, const struct http *hp) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); - CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); - HTTP_Copy(ctx->req->http, ctx->req->http0); - WS_Reset(ctx->req->ws, ctx->req->ws_req); + CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC); + if (hp == ctx->http_req) { + CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); + HTTP_Copy(ctx->req->http, ctx->req->http0); + WS_Reset(ctx->req->ws, ctx->req->ws_req); + } else if (hp == ctx->http_bereq) { + CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC); + HTTP_Copy(ctx->bo->bereq, ctx->bo->bereq0); + WS_Reset(ctx->bo->bereq->ws, ctx->bo->ws_bo); + WS_Reset(ctx->bo->ws, ctx->bo->ws_bo); + } else + WRONG("VRT_Rollback 'hp' invalid"); } /*--------------------------------------------------------------------*/ diff --git a/bin/varnishtest/tests/m00017.vtc b/bin/varnishtest/tests/m00017.vtc new file mode 100644 index 0000000..5622ec0 --- /dev/null +++ b/bin/varnishtest/tests/m00017.vtc @@ -0,0 +1,69 @@ +varnishtest "Test std.rollback" + +server s1 { + rxreq + expect req.url == "/foo" + expect req.http.foobar == "bar" + txresp -status 400 + accept + rxreq + expect req.url == "/bar" + expect req.http.foobar == "foo" + txresp + accept + rxreq + expect req.url == "/baz" + expect req.http.foobar == "qux" + txresp -status 400 + accept + rxreq + expect req.url == "/qux" + expect req.http.foobar == "baz" + txresp +} -start + +varnish v1 -vcl+backend { + import ${vmod_std}; + + sub vcl_recv { + if (req.url == "/foo") { + set req.http.foobar = "bar"; + } + } + + sub vcl_deliver { + if (resp.status == 400) { + std.rollback(req); + set req.url = "/bar"; + return (restart); + } + } +} -start + +client c1 { + txreq -url "/foo" -hdr "foobar: foo" + rxresp +} -run + +varnish v1 -vcl+backend { + import ${vmod_std}; + + sub vcl_backend_fetch { + if (bereq.url == "/baz") { + set bereq.http.foobar = "qux"; + } + } + + sub vcl_backend_response { + if (beresp.status == 400) { + std.rollback(bereq); + set bereq.url = "/qux"; + return (retry); + } + } +} + +client c1 { + txreq -url "/baz" -hdr "foobar: baz" + rxresp +} -run diff --git a/bin/varnishtest/tests/r01512.vtc b/bin/varnishtest/tests/r01512.vtc new file mode 100644 index 0000000..71496a2 --- /dev/null +++ b/bin/varnishtest/tests/r01512.vtc @@ -0,0 +1,56 @@ +varnishtest "Regression test for #1512" + +# First test bereq changes across v_b_r and v_b_f + +server s1 { + rxreq + txresp -status 700 +} -start + +varnish v1 -vcl+backend { + sub vcl_backend_fetch { + if (bereq.http.x-abandon == "1") { + return (abandon); + } + } + sub vcl_backend_response { + if (beresp.status == 700) { + set bereq.http.x-abandon = "1"; + return (retry); + } + } + sub vcl_synth { + set resp.status = 701; + } +} -start + +client c1 { + txreq + rxresp + expect resp.status == 701 +} -run + +# Then across v_b_e and v_b_f + +varnish v1 -vcl { + backend bad { .host = "${bad_ip}"; } + sub vcl_backend_fetch { + set bereq.backend = bad; + if (bereq.http.x-abandon == "2") { + return (abandon); + } + } + sub vcl_backend_error { + set bereq.http.x-abandon = "2"; + return (retry); + } + sub vcl_synth { + set resp.status = 702; + } +} + +client c1 { + txreq + rxresp + expect resp.status == 702 +} -run diff --git a/doc/sphinx/reference/vcl.rst b/doc/sphinx/reference/vcl.rst index 743689e..6828f99 100644 --- a/doc/sphinx/reference/vcl.rst +++ b/doc/sphinx/reference/vcl.rst @@ -369,7 +369,8 @@ return() in the request handling state machine. rollback() - Restore request HTTP headers to their original state. + Restore *req* HTTP headers to their original state. This function is + deprecated. Use std.rollback() instead. synthetic(STRING) Prepare a synthetic response body containing the STRING. Available in diff --git a/include/vrt.h b/include/vrt.h index efc9c94..ead55d3 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -249,7 +249,7 @@ void VRT_hashdata(const struct vrt_ctx *, const char *str, ...); int VRT_strcmp(const char *s1, const char *s2); void VRT_memmove(void *dst, const void *src, unsigned len); -void VRT_Rollback(const struct vrt_ctx *); +void VRT_Rollback(const struct vrt_ctx *, const struct http *); /* Synthetic pages */ void VRT_synth_page(const struct vrt_ctx *, const char *, ...); diff --git a/lib/libvcc/vcc_action.c b/lib/libvcc/vcc_action.c index 9b1d22d..1b0c4b2 100644 --- a/lib/libvcc/vcc_action.c +++ b/lib/libvcc/vcc_action.c @@ -376,7 +376,7 @@ parse_rollback(struct vcc *tl) { vcc_NextToken(tl); - Fb(tl, 1, "VRT_Rollback(ctx);\n"); + Fb(tl, 1, "VRT_Rollback(ctx, VRT_r_req(ctx));\n"); } /*--------------------------------------------------------------------*/ diff --git a/lib/libvmod_std/vmod.vcc b/lib/libvmod_std/vmod.vcc index fbee007..5bcc403 100644 --- a/lib/libvmod_std/vmod.vcc +++ b/lib/libvmod_std/vmod.vcc @@ -174,6 +174,13 @@ $Function INT port(IP) Description Returns the port number of an IP address. +$Function VOID rollback(HTTP) + +Description + Restore *h* HTTP headers to their original state. +Example + std.rollback(bereq); + $Function VOID timestamp(STRING) Description diff --git a/lib/libvmod_std/vmod_std.c b/lib/libvmod_std/vmod_std.c index 718fb71..c5d0cfe 100644 --- a/lib/libvmod_std/vmod_std.c +++ b/lib/libvmod_std/vmod_std.c @@ -205,6 +205,12 @@ vmod_port(const struct vrt_ctx *ctx, VCL_IP ip) return (VSA_Port(ip)); } +VCL_VOID __match_proto__(td_std_rollback) +vmod_rollback(const struct vrt_ctx *ctx, VCL_HTTP hp) +{ + VRT_Rollback(ctx, hp); +} + VCL_VOID __match_proto__(td_std_timestamp) vmod_timestamp(const struct vrt_ctx *ctx, VCL_STRING label) { From phk at FreeBSD.org Thu Jul 31 14:58:50 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 31 Jul 2014 16:58:50 +0200 Subject: [master] 0d86ae3 More coverage of VRT variables Message-ID: commit 0d86ae31e20cd31df28c83e59162c4756cdc652a Author: Poul-Henning Kamp Date: Thu Jul 31 14:58:32 2014 +0000 More coverage of VRT variables diff --git a/bin/varnishtest/tests/v00025.vtc b/bin/varnishtest/tests/v00025.vtc index 1be49af..67ac41a 100644 --- a/bin/varnishtest/tests/v00025.vtc +++ b/bin/varnishtest/tests/v00025.vtc @@ -5,16 +5,29 @@ server s1 { txresp } -start -varnish v1 -vcl+backend { +varnish v1 -arg "-i J.F.Nobody" -vcl+backend { import ${vmod_std}; + sub vcl_recv { + set client.identity = "Samuel B. Nobody"; + } + sub vcl_deliver { set resp.http.server_port = std.port(server.ip); + set resp.http.id = server.identity; + set resp.http.esi = req.esi; + set resp.http.be = req.backend_hint; + set resp.http.c_id = client.identity; } sub vcl_backend_response { set beresp.http.backend = bereq.backend; + set beresp.http.keep = beresp.keep; + set beresp.http.hint = beresp.storage_hint; + set beresp.http.be_ip = beresp.backend.ip; + set beresp.http.be_nm = beresp.backend.name; + set beresp.http.unc = bereq.uncacheable; if (beresp.ttl > 3 s) { set beresp.http.ttl = "long"; } else { @@ -23,6 +36,10 @@ varnish v1 -vcl+backend { } sub vcl_hit { + if (obj.proto) { } + if (obj.reason) { } + if (obj.uncacheable) { } + if (obj.keep > 1m) { } if (obj.grace < 3m) { return (deliver); } @@ -32,6 +49,7 @@ varnish v1 -vcl+backend { } sub vcl_backend_fetch { + set bereq.uncacheable = false; if (bereq.between_bytes_timeout < 10s) { set bereq.http.quick = "please"; }