From fgsch at lodoss.net Wed Feb 1 03:10:05 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Wed, 01 Feb 2017 04:10:05 +0100 Subject: [master] ca42915 Always call va_end() Message-ID: commit ca42915cf8bd1b58424b3643d8ab8c04140c952b Author: Federico G. Schwindt Date: Wed Feb 1 02:45:48 2017 +0000 Always call va_end() diff --git a/lib/libvarnish/vsb.c b/lib/libvarnish/vsb.c index bc72919..93fb65b 100644 --- a/lib/libvarnish/vsb.c +++ b/lib/libvarnish/vsb.c @@ -355,11 +355,11 @@ VSB_vprintf(struct vsb *s, const char *fmt, va_list ap) va_copy(ap_copy, ap); len = vsnprintf(&s->s_buf[s->s_len], VSB_FREESPACE(s) + 1, fmt, ap_copy); + va_end(ap_copy); if (len < 0) { s->s_error = errno; return (-1); } - va_end(ap_copy); } while (len > VSB_FREESPACE(s) && VSB_extend(s, len - VSB_FREESPACE(s)) == 0); From guillaume at varnish-software.com Wed Feb 1 10:09:05 2017 From: guillaume at varnish-software.com (Guillaume Quintard) Date: Wed, 01 Feb 2017 11:09:05 +0100 Subject: [master] 9c4e8c8 Make vdir_remove_backend return void Message-ID: commit 9c4e8c8d048df442f969b5e7c865556c4581638b Author: Guillaume Quintard Date: Fri Jan 27 14:32:29 2017 +0100 Make vdir_remove_backend return void diff --git a/lib/libvmod_directors/fall_back.c b/lib/libvmod_directors/fall_back.c index a54807b..c45e539 100644 --- a/lib/libvmod_directors/fall_back.c +++ b/lib/libvmod_directors/fall_back.c @@ -123,7 +123,7 @@ vmod_fallback_remove_backend(VRT_CTX, { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(fb, VMOD_DIRECTORS_FALLBACK_MAGIC); - (void)vdir_remove_backend(fb->vd, be); + vdir_remove_backend(fb->vd, be); } VCL_BACKEND __match_proto__() diff --git a/lib/libvmod_directors/hash.c b/lib/libvmod_directors/hash.c index 299c950..b117d56 100644 --- a/lib/libvmod_directors/hash.c +++ b/lib/libvmod_directors/hash.c @@ -91,7 +91,7 @@ vmod_hash_remove_backend(VRT_CTX, CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(rr, VMOD_DIRECTORS_HASH_MAGIC); - (void)vdir_remove_backend(rr->vd, be); + vdir_remove_backend(rr->vd, be); } VCL_BACKEND __match_proto__() diff --git a/lib/libvmod_directors/random.c b/lib/libvmod_directors/random.c index d964473..314c9eb 100644 --- a/lib/libvmod_directors/random.c +++ b/lib/libvmod_directors/random.c @@ -118,7 +118,7 @@ VCL_VOID vmod_random_remove_backend(VRT_CTX, { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(rr, VMOD_DIRECTORS_RANDOM_MAGIC); - (void)vdir_remove_backend(rr->vd, be); + vdir_remove_backend(rr->vd, be); } VCL_BACKEND __match_proto__() diff --git a/lib/libvmod_directors/round_robin.c b/lib/libvmod_directors/round_robin.c index c6c9c9b..ef63bca 100644 --- a/lib/libvmod_directors/round_robin.c +++ b/lib/libvmod_directors/round_robin.c @@ -127,7 +127,7 @@ vmod_round_robin_remove_backend(VRT_CTX, { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(rr, VMOD_DIRECTORS_ROUND_ROBIN_MAGIC); - (void)vdir_remove_backend(rr->vd, be); + vdir_remove_backend(rr->vd, be); } VCL_BACKEND __match_proto__() diff --git a/lib/libvmod_directors/vdir.c b/lib/libvmod_directors/vdir.c index ddcd1f7..c94b2ed 100644 --- a/lib/libvmod_directors/vdir.c +++ b/lib/libvmod_directors/vdir.c @@ -133,14 +133,14 @@ vdir_add_backend(struct vdir *vd, VCL_BACKEND be, double weight) return (u); } -unsigned +void vdir_remove_backend(struct vdir *vd, VCL_BACKEND be) { unsigned u, n; CHECK_OBJ_NOTNULL(vd, VDIR_MAGIC); if (be == NULL) - return (vd->n_backend); + return; CHECK_OBJ(be, DIRECTOR_MAGIC); vdir_wrlock(vd); for (u = 0; u < vd->n_backend; u++) @@ -148,7 +148,7 @@ vdir_remove_backend(struct vdir *vd, VCL_BACKEND be) break; if (u == vd->n_backend) { vdir_unlock(vd); - return (vd->n_backend); + return; } vd->total_weight -= vd->weight[u]; n = (vd->n_backend - u) - 1; @@ -156,7 +156,6 @@ vdir_remove_backend(struct vdir *vd, VCL_BACKEND be) memmove(&vd->weight[u], &vd->weight[u+1], n * sizeof(vd->weight[0])); vd->n_backend--; vdir_unlock(vd); - return (vd->n_backend); } unsigned diff --git a/lib/libvmod_directors/vdir.h b/lib/libvmod_directors/vdir.h index aaac9e5..eb4c6a8 100644 --- a/lib/libvmod_directors/vdir.h +++ b/lib/libvmod_directors/vdir.h @@ -48,7 +48,7 @@ void vdir_rdlock(struct vdir *vd); void vdir_wrlock(struct vdir *vd); void vdir_unlock(struct vdir *vd); unsigned vdir_add_backend(struct vdir *, VCL_BACKEND be, double weight); -unsigned vdir_remove_backend(struct vdir *, VCL_BACKEND be); +void vdir_remove_backend(struct vdir *, VCL_BACKEND be); unsigned vdir_any_healthy(struct vdir *, const struct busyobj *, double *changed); VCL_BACKEND vdir_pick_be(struct vdir *, double w, const struct busyobj *); From guillaume at varnish-software.com Wed Feb 1 10:09:05 2017 From: guillaume at varnish-software.com (Guillaume Quintard) Date: Wed, 01 Feb 2017 11:09:05 +0100 Subject: [master] 2f05442 Let remove_backend tell if the current dir changed Message-ID: commit 2f0544222347302607348a8a59fb39f592f74885 Author: Guillaume Quintard Date: Fri Jan 27 14:38:05 2017 +0100 Let remove_backend tell if the current dir changed diff --git a/lib/libvmod_directors/fall_back.c b/lib/libvmod_directors/fall_back.c index c45e539..7a44938 100644 --- a/lib/libvmod_directors/fall_back.c +++ b/lib/libvmod_directors/fall_back.c @@ -123,7 +123,7 @@ vmod_fallback_remove_backend(VRT_CTX, { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(fb, VMOD_DIRECTORS_FALLBACK_MAGIC); - vdir_remove_backend(fb->vd, be); + vdir_remove_backend(fb->vd, be, NULL); } VCL_BACKEND __match_proto__() diff --git a/lib/libvmod_directors/hash.c b/lib/libvmod_directors/hash.c index b117d56..71a4366 100644 --- a/lib/libvmod_directors/hash.c +++ b/lib/libvmod_directors/hash.c @@ -91,7 +91,7 @@ vmod_hash_remove_backend(VRT_CTX, CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(rr, VMOD_DIRECTORS_HASH_MAGIC); - vdir_remove_backend(rr->vd, be); + vdir_remove_backend(rr->vd, be, NULL); } VCL_BACKEND __match_proto__() diff --git a/lib/libvmod_directors/random.c b/lib/libvmod_directors/random.c index 314c9eb..10e6f53 100644 --- a/lib/libvmod_directors/random.c +++ b/lib/libvmod_directors/random.c @@ -118,7 +118,7 @@ VCL_VOID vmod_random_remove_backend(VRT_CTX, { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(rr, VMOD_DIRECTORS_RANDOM_MAGIC); - vdir_remove_backend(rr->vd, be); + vdir_remove_backend(rr->vd, be, NULL); } VCL_BACKEND __match_proto__() diff --git a/lib/libvmod_directors/round_robin.c b/lib/libvmod_directors/round_robin.c index ef63bca..59f7332 100644 --- a/lib/libvmod_directors/round_robin.c +++ b/lib/libvmod_directors/round_robin.c @@ -127,7 +127,7 @@ vmod_round_robin_remove_backend(VRT_CTX, { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(rr, VMOD_DIRECTORS_ROUND_ROBIN_MAGIC); - vdir_remove_backend(rr->vd, be); + vdir_remove_backend(rr->vd, be, NULL); } VCL_BACKEND __match_proto__() diff --git a/lib/libvmod_directors/vdir.c b/lib/libvmod_directors/vdir.c index c94b2ed..28f28f9 100644 --- a/lib/libvmod_directors/vdir.c +++ b/lib/libvmod_directors/vdir.c @@ -134,7 +134,7 @@ vdir_add_backend(struct vdir *vd, VCL_BACKEND be, double weight) } void -vdir_remove_backend(struct vdir *vd, VCL_BACKEND be) +vdir_remove_backend(struct vdir *vd, VCL_BACKEND be, unsigned *cur) { unsigned u, n; @@ -155,6 +155,15 @@ vdir_remove_backend(struct vdir *vd, VCL_BACKEND be) memmove(&vd->backend[u], &vd->backend[u+1], n * sizeof(vd->backend[0])); memmove(&vd->weight[u], &vd->weight[u+1], n * sizeof(vd->weight[0])); vd->n_backend--; + + if (cur) { + assert(*cur >= 0); + assert(*cur <= vd->n_backend); + if (u < *cur) + (*cur)--; + else if (*cur == vd->n_backend) + *cur = 0; + } vdir_unlock(vd); } diff --git a/lib/libvmod_directors/vdir.h b/lib/libvmod_directors/vdir.h index eb4c6a8..0bdfb04 100644 --- a/lib/libvmod_directors/vdir.h +++ b/lib/libvmod_directors/vdir.h @@ -48,7 +48,7 @@ void vdir_rdlock(struct vdir *vd); void vdir_wrlock(struct vdir *vd); void vdir_unlock(struct vdir *vd); unsigned vdir_add_backend(struct vdir *, VCL_BACKEND be, double weight); -void vdir_remove_backend(struct vdir *, VCL_BACKEND be); +void vdir_remove_backend(struct vdir *, VCL_BACKEND be, unsigned *cur); unsigned vdir_any_healthy(struct vdir *, const struct busyobj *, double *changed); VCL_BACKEND vdir_pick_be(struct vdir *, double w, const struct busyobj *); From guillaume at varnish-software.com Wed Feb 1 10:09:05 2017 From: guillaume at varnish-software.com (Guillaume Quintard) Date: Wed, 01 Feb 2017 11:09:05 +0100 Subject: [master] c5966cb Add optional sticky arg to fb director Message-ID: commit c5966cb74d4a23e629409303bd31931f2c9eb261 Author: Guillaume Quintard Date: Fri Jan 27 14:39:52 2017 +0100 Add optional sticky arg to fb director diff --git a/lib/libvmod_directors/fall_back.c b/lib/libvmod_directors/fall_back.c index 7a44938..80ea3aa 100644 --- a/lib/libvmod_directors/fall_back.c +++ b/lib/libvmod_directors/fall_back.c @@ -42,6 +42,8 @@ struct vmod_directors_fallback { unsigned magic; #define VMOD_DIRECTORS_FALLBACK_MAGIC 0xad4e26ba struct vdir *vd; + VCL_BOOL st; + unsigned cur; }; static unsigned __match_proto__(vdi_healthy) @@ -66,12 +68,16 @@ vmod_fallback_resolve(const struct director *dir, struct worker *wrk, CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); CAST_OBJ_NOTNULL(rr, dir->priv, VMOD_DIRECTORS_FALLBACK_MAGIC); - vdir_rdlock(rr->vd); + vdir_wrlock(rr->vd); + if (!rr->st) + rr->cur = 0; for (u = 0; u < rr->vd->n_backend; u++) { - be = rr->vd->backend[u]; + be = rr->vd->backend[rr->cur]; CHECK_OBJ_NOTNULL(be, DIRECTOR_MAGIC); if (be->healthy(be, bo, NULL)) break; + if (++rr->cur == rr->vd->n_backend) + rr->cur = 0; } vdir_unlock(rr->vd); if (u == rr->vd->n_backend) @@ -81,7 +87,7 @@ vmod_fallback_resolve(const struct director *dir, struct worker *wrk, VCL_VOID __match_proto__() vmod_fallback__init(VRT_CTX, - struct vmod_directors_fallback **rrp, const char *vcl_name) + struct vmod_directors_fallback **rrp, const char *vcl_name, VCL_BOOL sticky) { struct vmod_directors_fallback *rr; @@ -93,6 +99,7 @@ vmod_fallback__init(VRT_CTX, *rrp = rr; vdir_new(&rr->vd, "fallback", vcl_name, vmod_fallback_healthy, vmod_fallback_resolve, rr); + rr->st = sticky; } VCL_VOID __match_proto__() @@ -123,7 +130,7 @@ vmod_fallback_remove_backend(VRT_CTX, { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(fb, VMOD_DIRECTORS_FALLBACK_MAGIC); - vdir_remove_backend(fb->vd, be, NULL); + vdir_remove_backend(fb->vd, be, &fb->cur); } VCL_BACKEND __match_proto__() diff --git a/lib/libvmod_directors/vmod.vcc b/lib/libvmod_directors/vmod.vcc index c0fd1b8..cce8acb 100644 --- a/lib/libvmod_directors/vmod.vcc +++ b/lib/libvmod_directors/vmod.vcc @@ -95,7 +95,7 @@ Example set req.backend_hint = vdir.backend(); -$Object fallback() +$Object fallback(BOOL sticky = 0) Description Create a fallback director. @@ -103,6 +103,10 @@ Description A fallback director will try each of the added backends in turn, and return the first one that is healthy. + If ``sticky`` is set to true, the director will keep using the healthy + backend, even if a higher-priority backend becomes available. Once the + whole backend list is exhausted, it'll start over at the beginning. + Example new vdir = directors.fallback(); From guillaume at varnish-software.com Wed Feb 1 10:09:05 2017 From: guillaume at varnish-software.com (Guillaume Quintard) Date: Wed, 01 Feb 2017 11:09:05 +0100 Subject: [master] af3657e Sticky fallback directors vtc Message-ID: commit af3657e4ff95e05975780d9371d207a5ee0e6f89 Author: Guillaume Quintard Date: Thu Jan 26 13:12:52 2017 +0100 Sticky fallback directors vtc diff --git a/bin/varnishtest/tests/d00027.vtc b/bin/varnishtest/tests/d00027.vtc new file mode 100644 index 0000000..476e85f --- /dev/null +++ b/bin/varnishtest/tests/d00027.vtc @@ -0,0 +1,72 @@ +varnishtest "Sticky fallback director" + +server s1 { + rxreq + expect req.url == "/qux" + txresp +} -start + +server s2 { + rxreq + expect req.url == "/foo" + txresp +} -start + +server s3 { + rxreq + expect req.url == "/bar" + txresp + + rxreq + expect req.url == "/baz" + txresp +} -start + +varnish v1 -vcl+backend { + import directors; + + sub vcl_init { + new vd = directors.fallback(sticky = true); + vd.add_backend(s1); + vd.add_backend(s2); + vd.add_backend(s3); + } + + sub vcl_recv { + set req.backend_hint = vd.backend(); + return(pass); + } + +} -start + +varnish v1 -cliok "backend.set_health s1 sick" + +client c1 { + txreq -url /foo + rxresp + expect resp.status == 200 +} -run + +varnish v1 -cliok "backend.set_health s2 sick" + +client c1 { + txreq -url /bar + rxresp + expect resp.status == 200 +} -run + +varnish v1 -cliok "backend.set_health s1 healthy" + +client c1 { + txreq -url /baz + rxresp + expect resp.status == 200 +} -run + +varnish v1 -cliok "backend.set_health s3 sick" + +client c1 { + txreq -url /qux + rxresp + expect resp.status == 200 +} -run diff --git a/bin/varnishtest/tests/d00028.vtc b/bin/varnishtest/tests/d00028.vtc new file mode 100644 index 0000000..07d188c --- /dev/null +++ b/bin/varnishtest/tests/d00028.vtc @@ -0,0 +1,85 @@ +varnishtest "Sticky fallback director, removing backends" + +server s1 { + rxreq + expect req.url == "/foo" + txresp +} -start + +server s2 {} + +server s3 { + rxreq + expect req.url == "/bar" + txresp + + rxreq + expect req.url == "/baz" + txresp + + rxreq + expect req.url == "/qux" + txresp +} -start + +server s4 {} + +varnish v1 -vcl+backend { + import directors; + + sub vcl_init { + new vd = directors.fallback(sticky = true); + vd.add_backend(s1); + vd.add_backend(s2); + vd.add_backend(s3); + vd.add_backend(s4); + } + + sub vcl_recv { + set req.backend_hint = vd.backend(); + return(pass); + } + + sub vcl_deliver { + if (req.url == "/bar") { + vd.remove_backend(s2); + } else if (req.url == "/baz") { + vd.remove_backend(s4); + } else if (req.url == "/qux") { + vd.remove_backend(s3); + } + } +} -start + +varnish v1 -cliok "backend.set_health s1 sick" +varnish v1 -cliok "backend.set_health s2 sick" + +client c1 { + txreq -url /bar + rxresp + expect resp.status == 200 +} -run + +varnish v1 -cliok "backend.set_health s2 healthy" + +client c1 { + txreq -url /baz + rxresp + expect resp.status == 200 + + txreq -url /qux + rxresp + expect resp.status == 200 + + txreq + rxresp + expect resp.status == 503 +} -run + +varnish v1 -cliok "backend.set_health s1 healthy" + +client c1 { + txreq -url /foo + rxresp + expect resp.status == 200 +} -run From guillaume at varnish-software.com Wed Feb 1 10:09:05 2017 From: guillaume at varnish-software.com (Guillaume Quintard) Date: Wed, 01 Feb 2017 11:09:05 +0100 Subject: [master] ddb2125 Rename fallback variables Message-ID: commit ddb2125ffbb7b931315947981fed528123eb82f5 Author: Guillaume Quintard Date: Fri Jan 27 15:11:57 2017 +0100 Rename fallback variables diff --git a/lib/libvmod_directors/fall_back.c b/lib/libvmod_directors/fall_back.c index 80ea3aa..3e1794f 100644 --- a/lib/libvmod_directors/fall_back.c +++ b/lib/libvmod_directors/fall_back.c @@ -50,78 +50,79 @@ static unsigned __match_proto__(vdi_healthy) vmod_fallback_healthy(const struct director *dir, const struct busyobj *bo, double *changed) { - struct vmod_directors_fallback *rr; + struct vmod_directors_fallback *fb; - CAST_OBJ_NOTNULL(rr, dir->priv, VMOD_DIRECTORS_FALLBACK_MAGIC); - return (vdir_any_healthy(rr->vd, bo, changed)); + CAST_OBJ_NOTNULL(fb, dir->priv, VMOD_DIRECTORS_FALLBACK_MAGIC); + return (vdir_any_healthy(fb->vd, bo, changed)); } static const struct director * __match_proto__(vdi_resolve_f) vmod_fallback_resolve(const struct director *dir, struct worker *wrk, struct busyobj *bo) { - struct vmod_directors_fallback *rr; + struct vmod_directors_fallback *fb; unsigned u; VCL_BACKEND be = NULL; CHECK_OBJ_NOTNULL(dir, DIRECTOR_MAGIC); CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); - CAST_OBJ_NOTNULL(rr, dir->priv, VMOD_DIRECTORS_FALLBACK_MAGIC); - vdir_wrlock(rr->vd); - if (!rr->st) - rr->cur = 0; - for (u = 0; u < rr->vd->n_backend; u++) { - be = rr->vd->backend[rr->cur]; + CAST_OBJ_NOTNULL(fb, dir->priv, VMOD_DIRECTORS_FALLBACK_MAGIC); + + vdir_wrlock(fb->vd); + if (!fb->st) + fb->cur = 0; + for (u = 0; u < fb->vd->n_backend; u++) { + be = fb->vd->backend[fb->cur]; CHECK_OBJ_NOTNULL(be, DIRECTOR_MAGIC); if (be->healthy(be, bo, NULL)) break; - if (++rr->cur == rr->vd->n_backend) - rr->cur = 0; + if (++fb->cur == fb->vd->n_backend) + fb->cur = 0; } - vdir_unlock(rr->vd); - if (u == rr->vd->n_backend) + vdir_unlock(fb->vd); + if (u == fb->vd->n_backend) be = NULL; return (be); } VCL_VOID __match_proto__() vmod_fallback__init(VRT_CTX, - struct vmod_directors_fallback **rrp, const char *vcl_name, VCL_BOOL sticky) + struct vmod_directors_fallback **fbp, const char *vcl_name, VCL_BOOL sticky) { - struct vmod_directors_fallback *rr; + struct vmod_directors_fallback *fb; CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); - AN(rrp); - AZ(*rrp); - ALLOC_OBJ(rr, VMOD_DIRECTORS_FALLBACK_MAGIC); - AN(rr); - *rrp = rr; - vdir_new(&rr->vd, "fallback", vcl_name, vmod_fallback_healthy, - vmod_fallback_resolve, rr); - rr->st = sticky; + AN(fbp); + AZ(*fbp); + ALLOC_OBJ(fb, VMOD_DIRECTORS_FALLBACK_MAGIC); + AN(fb); + *fbp = fb; + vdir_new(&fb->vd, "fallback", vcl_name, vmod_fallback_healthy, + vmod_fallback_resolve, fb); + fb->st = sticky; } VCL_VOID __match_proto__() -vmod_fallback__fini(struct vmod_directors_fallback **rrp) +vmod_fallback__fini(struct vmod_directors_fallback **fbp) { - struct vmod_directors_fallback *rr; + struct vmod_directors_fallback *fb; - rr = *rrp; - *rrp = NULL; - CHECK_OBJ_NOTNULL(rr, VMOD_DIRECTORS_FALLBACK_MAGIC); - vdir_delete(&rr->vd); - FREE_OBJ(rr); + fb = *fbp; + *fbp = NULL; + CHECK_OBJ_NOTNULL(fb, VMOD_DIRECTORS_FALLBACK_MAGIC); + vdir_delete(&fb->vd); + FREE_OBJ(fb); } VCL_VOID __match_proto__() vmod_fallback_add_backend(VRT_CTX, - struct vmod_directors_fallback *rr, VCL_BACKEND be) + struct vmod_directors_fallback *fb, VCL_BACKEND be) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); - CHECK_OBJ_NOTNULL(rr, VMOD_DIRECTORS_FALLBACK_MAGIC); - (void)vdir_add_backend(rr->vd, be, 0.0); + CHECK_OBJ_NOTNULL(fb, VMOD_DIRECTORS_FALLBACK_MAGIC); + (void)vdir_add_backend(fb->vd, be, 0.0); } VCL_VOID __match_proto__() @@ -135,9 +136,9 @@ vmod_fallback_remove_backend(VRT_CTX, VCL_BACKEND __match_proto__() vmod_fallback_backend(VRT_CTX, - struct vmod_directors_fallback *rr) + struct vmod_directors_fallback *fb) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); - CHECK_OBJ_NOTNULL(rr, VMOD_DIRECTORS_FALLBACK_MAGIC); - return (rr->vd->dir); + CHECK_OBJ_NOTNULL(fb, VMOD_DIRECTORS_FALLBACK_MAGIC); + return (fb->vd->dir); } From guillaume at varnish-software.com Wed Feb 1 10:09:05 2017 From: guillaume at varnish-software.com (Guillaume Quintard) Date: Wed, 01 Feb 2017 11:09:05 +0100 Subject: [master] c9fcdf2 Create new changelog section Message-ID: commit c9fcdf2bd10642b8fda3402ca8f9656554504103 Author: Guillaume Quintard Date: Wed Feb 1 11:07:29 2017 +0100 Create new changelog section diff --git a/doc/changes.rst b/doc/changes.rst index dc77a7d..d07c595 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -1,4 +1,11 @@ ================================ +Varnish Cache 5.1.0 (unreleased) +================================ + +* The fallback director has now an extra, optional parameter to keep using the + current backend until it falls sick. + +================================ Varnish Cache 5.0.0 (2016-09-15) ================================ From dridi.boukelmoune at gmail.com Wed Feb 1 12:24:05 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 01 Feb 2017 13:24:05 +0100 Subject: [master] d5d5637 Redundant assert Message-ID: commit d5d5637d2fa3b0be05464c579893bc7806831081 Author: Dridi Boukelmoune Date: Wed Feb 1 13:22:55 2017 +0100 Redundant assert It actually fails to build with recent enough GCC or Clang. diff --git a/lib/libvmod_directors/vdir.c b/lib/libvmod_directors/vdir.c index 28f28f9..1581346 100644 --- a/lib/libvmod_directors/vdir.c +++ b/lib/libvmod_directors/vdir.c @@ -157,7 +157,6 @@ vdir_remove_backend(struct vdir *vd, VCL_BACKEND be, unsigned *cur) vd->n_backend--; if (cur) { - assert(*cur >= 0); assert(*cur <= vd->n_backend); if (u < *cur) (*cur)--; From guillaume at varnish-software.com Wed Feb 1 16:01:05 2017 From: guillaume at varnish-software.com (Guillaume Quintard) Date: Wed, 01 Feb 2017 17:01:05 +0100 Subject: [master] d7c6036 Start inactive server Message-ID: commit d7c6036d029f256ed519773c4428de988e4ad811 Author: Guillaume Quintard Date: Wed Feb 1 16:59:20 2017 +0100 Start inactive server Varnish doesn't like empty hosts in backend definitions diff --git a/bin/varnishtest/tests/d00028.vtc b/bin/varnishtest/tests/d00028.vtc index 07d188c..c297641 100644 --- a/bin/varnishtest/tests/d00028.vtc +++ b/bin/varnishtest/tests/d00028.vtc @@ -6,7 +6,7 @@ server s1 { txresp } -start -server s2 {} +server s2 {} -start server s3 { rxreq @@ -22,7 +22,7 @@ server s3 { txresp } -start -server s4 {} +server s4 {} -start varnish v1 -vcl+backend { import directors; From nils.goroll at uplex.de Wed Feb 1 16:10:06 2017 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 01 Feb 2017 17:10:06 +0100 Subject: [master] 272fc95 give some advise on adjusting vsl_buffer Message-ID: commit 272fc9578abab4a0eab0e82240e24b6bbd1bc3a6 Author: Nils Goroll Date: Wed Feb 1 16:49:45 2017 +0100 give some advise on adjusting vsl_buffer I'd really like to come back to https://lists.gt.net/varnish/dev/39240 somewhen. We should not leave the workspace sizing calculations to the admin based on incomplete information. The admin should only need to set the "space available to VCL". diff --git a/include/tbl/params.h b/include/tbl/params.h index a1d52db..71552ee 100644 --- a/include/tbl/params.h +++ b/include/tbl/params.h @@ -1466,6 +1466,8 @@ PARAM( /* s-text */ "Bytes of (req-/backend-)workspace dedicated to buffering VSL " "records.\n" + "When this parameter is adjusted, most likely workspace_client " + "and workspace_backend will have to be adjusted by the same amount.\n\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\n" From phk at FreeBSD.org Wed Feb 1 20:58:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 01 Feb 2017 21:58:05 +0100 Subject: [master] 03602d9 Don't panic if people send us HTTP2.0 when it is not enabled. Message-ID: commit 03602d9fb9e89379c648ad95df11bcc69dd1d004 Author: Poul-Henning Kamp Date: Wed Feb 1 20:56:20 2017 +0000 Don't panic if people send us HTTP2.0 when it is not enabled. Explains some of #2117 and friends diff --git a/bin/varnishd/http1/cache_http1_fsm.c b/bin/varnishd/http1/cache_http1_fsm.c index 094294c..06eb34b 100644 --- a/bin/varnishd/http1/cache_http1_fsm.c +++ b/bin/varnishd/http1/cache_http1_fsm.c @@ -401,10 +401,7 @@ HTTP1_Session(struct worker *wrk, struct req *req) if (H2_prism_complete(req->htc) == HTC_S_COMPLETE) { if (!FEATURE(FEATURE_HTTP2)) { - VSLb(req->vsl, SLT_Debug, - "H2 attempt"); - assert(req->doclose > 0); - SES_Close(req->sp, req->doclose); + SES_Close(req->sp, SC_REQ_HTTP20); http1_setstate(sp, H1CLEANUP); continue; } @@ -412,8 +409,7 @@ HTTP1_Session(struct worker *wrk, struct req *req) "H2 Prior Knowledge Upgrade"); http1_setstate(sp, NULL); req->err_code = 1; - SES_SetTransport(wrk, sp, req, - &H2_transport); + SES_SetTransport(wrk, sp, req, &H2_transport); return; } diff --git a/include/tbl/sess_close.h b/include/tbl/sess_close.h index e1b4872..0dcbcbc 100644 --- a/include/tbl/sess_close.h +++ b/include/tbl/sess_close.h @@ -44,7 +44,8 @@ SESS_CLOSE(TX_EOF, tx_eof, 0, "EOF transmission") SESS_CLOSE(RESP_CLOSE, resp_close, 0, "Backend/VCL requested close") SESS_CLOSE(OVERLOAD, overload, 1, "Out of some resource") SESS_CLOSE(PIPE_OVERFLOW, pipe_overflow,1, "Session pipe overflow") -SESS_CLOSE(RANGE_SHORT, range_short, 1, "Insufficient data for range") +SESS_CLOSE(RANGE_SHORT, range_short, 1, "Insufficient data for range") +SESS_CLOSE(REQ_HTTP20, req_http20, 1, "HTTP2 not accepted") #undef SESS_CLOSE /*lint -restore */ From phk at FreeBSD.org Thu Feb 2 08:22:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 02 Feb 2017 09:22:05 +0100 Subject: [master] c7e611c Log the details of the vcl-poker fails to set state in the worker process. Message-ID: commit c7e611ce56023042eda326d7ce171734708fbd01 Author: Poul-Henning Kamp Date: Thu Feb 2 08:21:11 2017 +0000 Log the details of the vcl-poker fails to set state in the worker process. diff --git a/bin/varnishd/mgt/mgt_vcl.c b/bin/varnishd/mgt/mgt_vcl.c index 9d22352..b8ac355 100644 --- a/bin/varnishd/mgt/mgt_vcl.c +++ b/bin/varnishd/mgt/mgt_vcl.c @@ -298,13 +298,15 @@ mgt_vcl_setstate(struct cli *cli, struct vclprog *vp, const char *vs) i = mgt_cli_askchild(&status, &p, "vcl.state %s %d%s\n", vp->name, vp->warm, vp->state); - if (i) { - AN(cli); - XXXAN(vp->warm); /* XXX: should restart child instead */ + if (i && cli != NULL) { VCLI_SetResult(cli, status); VCLI_Out(cli, "%s", p); + } else if (i) { + MGT_Complain(C_ERR, + "Please file ticket: VCL poker problem: " + "'vcl.state %s %d%s' -> %03d '%s'", + vp->name, vp->warm, vp->state, i, p); } - free(p); return (i); } From phk at FreeBSD.org Thu Feb 2 09:01:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 02 Feb 2017 10:01:05 +0100 Subject: [master] 0d400c3 Don't double backslash-escape panic messages, and be more generous with their length. Message-ID: commit 0d400c38a1800d875296775b315eb9c46a7a7cef Author: Poul-Henning Kamp Date: Thu Feb 2 08:49:59 2017 +0000 Don't double backslash-escape panic messages, and be more generous with their length. diff --git a/bin/varnishtest/vtc_log.c b/bin/varnishtest/vtc_log.c index c2ebbf6..0dd2b82 100644 --- a/bin/varnishtest/vtc_log.c +++ b/bin/varnishtest/vtc_log.c @@ -200,6 +200,8 @@ vtc_log(struct vtclog *vl, int lvl, const char *fmt, ...) * Dump a string */ +#define MAX_DUMP 8192 + void vtc_dump(struct vtclog *vl, int lvl, const char *pfx, const char *str, int len) { @@ -214,10 +216,11 @@ vtc_dump(struct vtclog *vl, int lvl, const char *pfx, const char *str, int len) lead[lvl < 0 ? 1: lvl], vl->id, vl->tx, pfx); if (len < 0) len = strlen(str); - VSB_quote_pfx(vl->vsb, buf, str,len > 1024 ? 1024 : len, - VSB_QUOTE_NONL); - if (len > 1024) - VSB_printf(vl->vsb, "%s [...] (%d)", buf, len - 1024); + VSB_quote_pfx(vl->vsb, buf, str, + len > MAX_DUMP ? MAX_DUMP : len, VSB_QUOTE_UNSAFE); + if (len > MAX_DUMP) + VSB_printf(vl->vsb, "%s [...] (%d)\n", + buf, len - MAX_DUMP); } REL_VL(vl); if (lvl == 0) diff --git a/include/vsb.h b/include/vsb.h index 0f5bfdc..3f66897 100644 --- a/include/vsb.h +++ b/include/vsb.h @@ -76,10 +76,11 @@ char *VSB_data(const struct vsb *); ssize_t VSB_len(const struct vsb *); void VSB_delete(struct vsb *); void VSB_destroy(struct vsb **); -#define VSB_QUOTE_NONL 1 -#define VSB_QUOTE_JSON 2 -#define VSB_QUOTE_HEX 4 -#define VSB_QUOTE_CSTR 8 +#define VSB_QUOTE_NONL 1 +#define VSB_QUOTE_JSON 2 +#define VSB_QUOTE_HEX 4 +#define VSB_QUOTE_CSTR 8 +#define VSB_QUOTE_UNSAFE 16 void VSB_quote_pfx(struct vsb *, const char*, const void *, int len, int how); void VSB_quote(struct vsb *, const void *, int len, int how); diff --git a/lib/libvarnish/vsb.c b/lib/libvarnish/vsb.c index 93fb65b..cc9e4d0 100644 --- a/lib/libvarnish/vsb.c +++ b/lib/libvarnish/vsb.c @@ -567,13 +567,14 @@ VSB_quote_pfx(struct vsb *s, const char *pfx, const void *v, int len, int how) break; case '\\': case '"': - (void)VSB_putc(s, '\\'); + if (!(how & VSB_QUOTE_UNSAFE)) + (void)VSB_putc(s, '\\'); (void)VSB_putc(s, *q); break; case '\n': if (how & VSB_QUOTE_CSTR) { (void)VSB_printf(s, "\\n\"\n%s\t\"", pfx); - } else if (how & VSB_QUOTE_NONL) { + } else if (how & (VSB_QUOTE_NONL|VSB_QUOTE_UNSAFE)) { (void)VSB_printf(s, "\n"); nl = 1; } else { From phk at FreeBSD.org Thu Feb 2 09:01:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 02 Feb 2017 10:01:05 +0100 Subject: [master] a3756e2 Don't forget final NL Message-ID: commit a3756e2ed9fbf0796c693dc13563de9b2ac4a258 Author: Poul-Henning Kamp Date: Thu Feb 2 08:53:59 2017 +0000 Don't forget final NL diff --git a/lib/libvarnish/vsb.c b/lib/libvarnish/vsb.c index cc9e4d0..2f32acb 100644 --- a/lib/libvarnish/vsb.c +++ b/lib/libvarnish/vsb.c @@ -598,7 +598,7 @@ VSB_quote_pfx(struct vsb *s, const char *pfx, const void *v, int len, int how) } if (how & VSB_QUOTE_CSTR) (void)VSB_putc(s, '"'); - if ((how & VSB_QUOTE_NONL) && !nl) + if ((how & (VSB_QUOTE_NONL|VSB_QUOTE_UNSAFE)) && !nl) (void)VSB_putc(s, '\n'); } From phk at FreeBSD.org Thu Feb 2 09:01:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 02 Feb 2017 10:01:05 +0100 Subject: [master] 7347e93 beresp.backend.ip is only available while the connection is open, which means not in vcl_backend_error{} Message-ID: commit 7347e93abca65fe08dec924fce3a2e17b3329923 Author: Poul-Henning Kamp Date: Thu Feb 2 08:58:05 2017 +0000 beresp.backend.ip is only available while the connection is open, which means not in vcl_backend_error{} Fixes: #1865 diff --git a/lib/libvcc/generate.py b/lib/libvcc/generate.py index 8e046e5..d4bd61c 100755 --- a/lib/libvcc/generate.py +++ b/lib/libvcc/generate.py @@ -638,7 +638,7 @@ sp_variables = [ ), ('beresp.backend.ip', 'IP', - ('backend_response', 'backend_error'), + ('backend_response',), (), """ IP of the backend this response was fetched from. """ From phk at FreeBSD.org Thu Feb 2 10:38:04 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 02 Feb 2017 11:38:04 +0100 Subject: [master] 21c215f Always initialize ctx->handling to zero, and try to avoid setting it more than once. Message-ID: commit 21c215fac90827731b822859198acea84d39ca7c Author: Poul-Henning Kamp Date: Thu Feb 2 10:36:37 2017 +0000 Always initialize ctx->handling to zero, and try to avoid setting it more than once. diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c index ba7f296..1ddfb0c 100644 --- a/bin/varnishd/cache/cache_vcl.c +++ b/bin/varnishd/cache/cache_vcl.c @@ -107,6 +107,7 @@ vcl_get_ctx(unsigned method, int msg) { AZ(ctx_cli.handling); INIT_OBJ(&ctx_cli, VRT_CTX_MAGIC); + handling_cli = 0; ctx_cli.handling = &handling_cli; ctx_cli.method = method; if (msg) { @@ -148,6 +149,7 @@ vcl_send_event(VRT_CTX, enum vcl_event_e ev) ev == VCL_EVENT_COLD || ev == VCL_EVENT_DISCARD); AN(ctx->handling); + *ctx->handling = 0; AN(ctx->ws); if (ev == VCL_EVENT_LOAD || ev == VCL_EVENT_WARM) @@ -713,6 +715,7 @@ vcl_cancel_load(VRT_CTX, struct cli *cli, const char *name, const char *step) VCLI_Out(cli, "VCL \"%s\" Failed %s", name, step); if (VSB_len(ctx->msg)) VCLI_Out(cli, "\nMessage:\n\t%s", VSB_data(ctx->msg)); + *ctx->handling = 0; AZ(vcl->conf->event_vcl(ctx, VCL_EVENT_DISCARD)); vcl_KillBackends(vcl); VCL_Close(&vcl); @@ -753,6 +756,7 @@ vcl_load(struct cli *cli, struct vrt_ctx *ctx, vcl_cancel_load(ctx, cli, name, "initialization"); return; } + assert(*ctx->handling == VCL_RET_OK); VSB_clear(ctx->msg); i = vcl_set_state(ctx, state); if (i) { @@ -761,7 +765,6 @@ vcl_load(struct cli *cli, struct vrt_ctx *ctx, return; } bprintf(vcl->state, "%s", state + 1); - assert(*ctx->handling == VCL_RET_OK); VCLI_Out(cli, "Loaded \"%s\" as \"%s\"", fn , name); VTAILQ_INSERT_TAIL(&vcl_head, vcl, list); Lck_Lock(&vcl_mtx); @@ -1041,9 +1044,9 @@ vcl_call_method(struct worker *wrk, struct req *req, struct busyobj *bo, ctx.vsl = vsl; ctx.specific = specific; ctx.method = method; + wrk->handling = 0; ctx.handling = &wrk->handling; aws = WS_Snapshot(wrk->aws); - wrk->handling = 0; wrk->cur_method = method; wrk->seen_methods |= method; AN(vsl); diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c index 1abf5b7..55d759f 100644 --- a/bin/varnishd/cache/cache_vrt.c +++ b/bin/varnishd/cache/cache_vrt.c @@ -252,7 +252,9 @@ VRT_handling(VRT_CTX, unsigned hand) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + assert(hand > 0); assert(hand < VCL_RET_MAX); + // XXX:NOTYET assert(*ctx->handling == 0); *ctx->handling = hand; } diff --git a/bin/varnishtest/tests/b00014.vtc b/bin/varnishtest/tests/b00014.vtc index a6f08f3..eb75dfb 100644 --- a/bin/varnishtest/tests/b00014.vtc +++ b/bin/varnishtest/tests/b00014.vtc @@ -1,6 +1,5 @@ varnishtest "Check -f command line arg" - server s1 { rxreq expect req.url == "/foo" diff --git a/lib/libvcc/vcc_compile.c b/lib/libvcc/vcc_compile.c index a7dc484..9de5eac 100644 --- a/lib/libvcc/vcc_compile.c +++ b/lib/libvcc/vcc_compile.c @@ -311,6 +311,8 @@ EmitInitFini(const struct vcc *tl) } Fc(tl, 0, "\t(void)VGC_function_vcl_init(ctx);\n"); + Fc(tl, 0, "\tif (*ctx->handling == 0)\n"); + Fc(tl, 0, "\t\tVRT_handling(ctx, VCL_RET_OK);\n"); Fc(tl, 0, "\treturn (*ctx->handling == VCL_RET_OK ? 0: -1);\n"); Fc(tl, 0, "}\n"); @@ -655,8 +657,6 @@ vcc_CompileSource(struct vcc *tl, struct source *sp) * in members called from vcl_init, so set OK up front * and return with whatever was set last. */ - if (method_tab[i].bitval == VCL_MET_INIT) - Fc(tl, 1, " VRT_handling(ctx, VCL_RET_OK);\n"); Fc(tl, 1, "%s", VSB_data(tl->fm[i])); if (method_tab[i].bitval == VCL_MET_INIT) Fc(tl, 1, " return (1);\n"); From hermunn at varnish-software.com Thu Feb 2 13:12:04 2017 From: hermunn at varnish-software.com (Pål Hermunn Johansen) Date: Thu, 02 Feb 2017 14:12:04 +0100 Subject: [4.1] 51cbf50 Prepare for 4.1.5-beta1 release Message-ID: commit 51cbf502ef5d365104df032f2e104830c82e77a3 Author: P?l Hermunn Johansen Date: Thu Feb 2 14:11:05 2017 +0100 Prepare for 4.1.5-beta1 release diff --git a/configure.ac b/configure.ac index d0f2727..18a47fe 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ AC_PREREQ(2.59) AC_COPYRIGHT([Copyright (c) 2006 Verdens Gang AS Copyright (c) 2006-2016 Varnish Software]) AC_REVISION([$Id$]) -AC_INIT([Varnish], [4.1.4], [varnish-dev at varnish-cache.org]) +AC_INIT([Varnish], [4.1.5-beta1], [varnish-dev at varnish-cache.org]) AC_CONFIG_SRCDIR(include/miniobj.h) AC_CONFIG_HEADERS([config.h]) AC_CONFIG_MACRO_DIR([m4]) diff --git a/doc/changes.rst b/doc/changes.rst index b15ba9a..c322a2e 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -1,6 +1,6 @@ -================================ -Varnish Cache 4.1.5 (unreleased) -================================ +====================================== +Varnish Cache 4.1.5-beta1 (2017-02-02) +====================================== Changes since 4.1.4: From phk at FreeBSD.org Fri Feb 3 09:45:06 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 03 Feb 2017 10:45:06 +0100 Subject: [master] 778dbd1 VSB_quote() is getting too complex, I'll need to revisit that... Message-ID: commit 778dbd1db17ee589dc3b45c5f03eef194dfc120f Author: Poul-Henning Kamp Date: Fri Feb 3 09:06:12 2017 +0000 VSB_quote() is getting too complex, I'll need to revisit that... diff --git a/lib/libvarnish/vsb.c b/lib/libvarnish/vsb.c index 2f32acb..d950608 100644 --- a/lib/libvarnish/vsb.c +++ b/lib/libvarnish/vsb.c @@ -544,7 +544,8 @@ VSB_quote_pfx(struct vsb *s, const char *pfx, const void *v, int len, int how) } if (!quote && !(how & (VSB_QUOTE_JSON|VSB_QUOTE_CSTR))) { (void)VSB_bcat(s, p, len); - if ((how & VSB_QUOTE_NONL) && p[len-1] != '\n') + if ((how & (VSB_QUOTE_UNSAFE|VSB_QUOTE_NONL)) + && p[len-1] != '\n') (void)VSB_putc(s, '\n'); return; } From phk at FreeBSD.org Fri Feb 3 09:45:06 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 03 Feb 2017 10:45:06 +0100 Subject: [master] aedc4d6 Also enable VCL_trace in vcl_init/fini which doesn't have buffered vsl. Message-ID: commit aedc4d68cfeb660a296684862f8e82e8b5364a0a Author: Poul-Henning Kamp Date: Fri Feb 3 09:37:18 2017 +0000 Also enable VCL_trace in vcl_init/fini which doesn't have buffered vsl. diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c index 1ddfb0c..a380256 100644 --- a/bin/varnishd/cache/cache_vcl.c +++ b/bin/varnishd/cache/cache_vcl.c @@ -521,6 +521,9 @@ VRT_count(VRT_CTX, unsigned u) if (ctx->vsl != NULL) VSLb(ctx->vsl, SLT_VCL_trace, "%u %u.%u", u, ctx->vcl->conf->ref[u].line, ctx->vcl->conf->ref[u].pos); + else + VSL(SLT_VCL_trace, 0, "%u %u.%u", u, + ctx->vcl->conf->ref[u].line, ctx->vcl->conf->ref[u].pos); } VCL_VCL From phk at FreeBSD.org Fri Feb 3 09:45:06 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 03 Feb 2017 10:45:06 +0100 Subject: [master] 9849fd0 Fall out of compiled VCL code if any statement sets ctx->handling non-zero. Message-ID: commit 9849fd067da128cb46cc8a35ec8312323e53cc25 Author: Poul-Henning Kamp Date: Fri Feb 3 09:43:03 2017 +0000 Fall out of compiled VCL code if any statement sets ctx->handling non-zero. Right now this only affects failures in vcl_init{} diff --git a/bin/varnishtest/tests/m00022.vtc b/bin/varnishtest/tests/m00022.vtc index 8b3a249..a9863d6 100644 --- a/bin/varnishtest/tests/m00022.vtc +++ b/bin/varnishtest/tests/m00022.vtc @@ -7,19 +7,33 @@ server s1 { varnish v1 -vcl+backend { } -start +logexpect l1 -v v1 -g raw { + expect * 0 VCL_Log "Should happen first" + expect 0 0 VCL_Log "Should happen second" + +} -start + varnish v1 -errvcl "Planned failure in vcl_init" { import debug; + import std; backend default { .host = "${s1_addr}"; } sub vcl_init { + std.log("Should happen first"); debug.init_fail(); + std.log("Should not happen"); + } + sub vcl_fini { + std.log("Should happen second"); } } +logexpect l1 -wait + varnish v1 -cliok "param.set nuke_limit 42" varnish v1 -errvcl "nuke_limit is not the answer." { diff --git a/lib/libvcc/vcc_parse.c b/lib/libvcc/vcc_parse.c index 53bc29e..ff7334c 100644 --- a/lib/libvcc/vcc_parse.c +++ b/lib/libvcc/vcc_parse.c @@ -196,6 +196,7 @@ vcc_Compound(struct vcc *tl) vcc_ErrWhere(tl, tl->t); return; } + Fb(tl, 1, "if (*ctx->handling) return(1);\n"); } } From phk at FreeBSD.org Fri Feb 3 10:20:06 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 03 Feb 2017 11:20:06 +0100 Subject: [master] 3bd4f51 Now that we fall out of VCL the moment ctx->handling gets set, we can ditch the bogus return values and some decorations. Message-ID: commit 3bd4f5165f4a6d97a76c17392254be59abfa098b Author: Poul-Henning Kamp Date: Fri Feb 3 10:18:39 2017 +0000 Now that we fall out of VCL the moment ctx->handling gets set, we can ditch the bogus return values and some decorations. diff --git a/bin/varnishd/builtin.vcl b/bin/varnishd/builtin.vcl index 2ccbf4c..a01094d 100644 --- a/bin/varnishd/builtin.vcl +++ b/bin/varnishd/builtin.vcl @@ -186,6 +186,7 @@ sub vcl_backend_error { # Housekeeping sub vcl_init { + return (ok); } sub vcl_fini { diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c index a380256..967c563 100644 --- a/bin/varnishd/cache/cache_vcl.c +++ b/bin/varnishd/cache/cache_vcl.c @@ -755,7 +755,7 @@ vcl_load(struct cli *cli, struct vrt_ctx *ctx, VSB_clear(ctx->msg); i = vcl_send_event(ctx, VCL_EVENT_LOAD); - if (i) { + if (i || *ctx->handling != VCL_RET_OK) { vcl_cancel_load(ctx, cli, name, "initialization"); return; } @@ -1054,7 +1054,7 @@ vcl_call_method(struct worker *wrk, struct req *req, struct busyobj *bo, wrk->seen_methods |= method; AN(vsl); VSLb(vsl, SLT_VCL_call, "%s", VCL_Method_Name(method)); - (void)func(&ctx); + func(&ctx); VSLb(vsl, SLT_VCL_return, "%s", VCL_Return_Name(wrk->handling)); wrk->cur_method |= 1; // Magic marker diff --git a/lib/libvcc/generate.py b/lib/libvcc/generate.py index d4bd61c..c71fc1b 100755 --- a/lib/libvcc/generate.py +++ b/lib/libvcc/generate.py @@ -1102,7 +1102,7 @@ enum vcl_event_e { typedef int vcl_event_f(VRT_CTX, enum vcl_event_e); typedef int vcl_init_f(VRT_CTX); typedef void vcl_fini_f(VRT_CTX); -typedef int vcl_func_f(VRT_CTX); +typedef void vcl_func_f(VRT_CTX); """) diff --git a/lib/libvcc/vcc_action.c b/lib/libvcc/vcc_action.c index 9e45f58..fb8d97b 100644 --- a/lib/libvcc/vcc_action.c +++ b/lib/libvcc/vcc_action.c @@ -47,8 +47,7 @@ parse_call(struct vcc *tl) ExpectErr(tl, ID); vcc_AddCall(tl, tl->t); vcc_AddRef(tl, tl->t, SYM_SUB); - Fb(tl, 1, "if (VGC_function_%.*s(ctx))\n", PF(tl->t)); - Fb(tl, 1, "\treturn (1);\n"); + Fb(tl, 1, "VGC_function_%.*s(ctx);\n", PF(tl->t)); vcc_NextToken(tl); } @@ -325,7 +324,6 @@ parse_return(struct vcc *tl) } ERRCHK(tl); Fb(tl, 1, "VRT_handling(ctx, VCL_RET_%s);\n", h); - Fb(tl, 1, "return (1);\n"); ExpectErr(tl, ')'); vcc_NextToken(tl); } diff --git a/lib/libvcc/vcc_compile.c b/lib/libvcc/vcc_compile.c index 9de5eac..16a29d1 100644 --- a/lib/libvcc/vcc_compile.c +++ b/lib/libvcc/vcc_compile.c @@ -310,10 +310,7 @@ EmitInitFini(const struct vcc *tl) has_event = 1; } - Fc(tl, 0, "\t(void)VGC_function_vcl_init(ctx);\n"); - Fc(tl, 0, "\tif (*ctx->handling == 0)\n"); - Fc(tl, 0, "\t\tVRT_handling(ctx, VCL_RET_OK);\n"); - Fc(tl, 0, "\treturn (*ctx->handling == VCL_RET_OK ? 0: -1);\n"); + Fc(tl, 0, "\treturn(0);\n"); Fc(tl, 0, "}\n"); /* @@ -321,8 +318,6 @@ EmitInitFini(const struct vcc *tl) */ Fc(tl, 0, "\nstatic int\nVGC_Discard(VRT_CTX)\n{\n\n"); - Fc(tl, 0, "\t(void)VGC_function_vcl_fini(ctx);\n\n"); - Fc(tl, 0, "\tswitch (vgc_inistep) {\n\n"); VTAILQ_FOREACH_REVERSE(p, &tl->inifin, inifinhead, list) { AZ(VSB_finish(p->fin)); @@ -336,7 +331,7 @@ EmitInitFini(const struct vcc *tl) } VSB_destroy(&p->fin); } - Fc(tl, 0, "\t}\n\n"); + Fc(tl, 0, "\t}\n"); Fc(tl, 0, "\treturn (0);\n"); Fc(tl, 0, "}\n"); @@ -558,6 +553,7 @@ vcc_CompileSource(struct vcc *tl, struct source *sp) struct symbol *sym; const struct var *v; struct vsb *vsb; + struct inifin *ifp; int i; vcc_Expr_Init(tl); @@ -639,14 +635,19 @@ vcc_CompileSource(struct vcc *tl, struct source *sp) if (vcc_CheckUses(tl) || tl->err) return (NULL); + /* Tie vcl_init/fini in */ + ifp = New_IniFin(tl); + VSB_printf(ifp->ini, "\tVGC_function_vcl_init(ctx);"); + VSB_printf(ifp->fin, "\t\tVGC_function_vcl_fini(ctx);"); + /* Emit method functions */ Fh(tl, 1, "\n"); for (i = 1; i < VCL_MET_MAX; i++) { Fh(tl, 1, - "int __match_proto__(vcl_func_f) " + "void __match_proto__(vcl_func_f) " "VGC_function_%s(VRT_CTX);\n", method_tab[i].name); - Fc(tl, 1, "\nint __match_proto__(vcl_func_f)\n"); + Fc(tl, 1, "\nvoid __match_proto__(vcl_func_f)\n"); Fc(tl, 1, "VGC_function_%s(VRT_CTX)\n", method_tab[i].name); @@ -659,7 +660,7 @@ vcc_CompileSource(struct vcc *tl, struct source *sp) */ Fc(tl, 1, "%s", VSB_data(tl->fm[i])); if (method_tab[i].bitval == VCL_MET_INIT) - Fc(tl, 1, " return (1);\n"); + Fc(tl, 1, " return;\n"); Fc(tl, 1, "}\n"); } diff --git a/lib/libvcc/vcc_parse.c b/lib/libvcc/vcc_parse.c index ff7334c..6e28970 100644 --- a/lib/libvcc/vcc_parse.c +++ b/lib/libvcc/vcc_parse.c @@ -196,7 +196,7 @@ vcc_Compound(struct vcc *tl) vcc_ErrWhere(tl, tl->t); return; } - Fb(tl, 1, "if (*ctx->handling) return(1);\n"); + Fb(tl, 1, "if (*ctx->handling) return;\n"); } } @@ -246,9 +246,8 @@ vcc_ParseFunction(struct vcc *tl) return; } tl->curproc = vcc_AddProc(tl, tl->t); - Fh(tl, 0, "int VGC_function_%.*s " - "(VRT_CTX);\n", PF(tl->t)); - Fc(tl, 1, "\nint __match_proto__(vcl_func_t)\n"); + Fh(tl, 0, "void VGC_function_%.*s(VRT_CTX);\n", PF(tl->t)); + Fc(tl, 1, "\nvoid __match_proto__(vcl_func_t)\n"); Fc(tl, 1, "VGC_function_%.*s(VRT_CTX)\n", PF(tl->t)); } @@ -256,13 +255,6 @@ vcc_ParseFunction(struct vcc *tl) tl->indent += INDENT; Fb(tl, 1, "{\n"); L(tl, vcc_Compound(tl)); - if (m == -1) { - /* - * non-method subroutines must have an explicit non-action - * return in case they just fall through the bottom. - */ - Fb(tl, 1, " return(0);\n"); - } Fb(tl, 1, "}\n"); tl->indent -= INDENT; tl->fb = NULL; diff --git a/lib/libvcc/vcc_vmod.c b/lib/libvcc/vcc_vmod.c index c2c4742..c6e08c1 100644 --- a/lib/libvcc/vcc_vmod.c +++ b/lib/libvcc/vcc_vmod.c @@ -237,7 +237,7 @@ vcc_ParseImport(struct vcc *tl) p, PF(mod)); VSB_printf(ifp->fin, "\t\t(void)%s(ctx, &vmod_priv_%.*s,\n" - "\t\t VCL_EVENT_DISCARD);\n", p, PF(mod)); + "\t\t\t VCL_EVENT_DISCARD);\n", p, PF(mod)); VSB_printf(ifp->event, "\t%s(ctx, &vmod_priv_%.*s, ev)", p, PF(mod)); } else if (!strcmp(p, "$FUNC")) { From nils.goroll at uplex.de Fri Feb 3 11:53:04 2017 From: nils.goroll at uplex.de (Nils Goroll) Date: Fri, 03 Feb 2017 12:53:04 +0100 Subject: [master] 403c75e Bring back STRING + DURATION Message-ID: commit 403c75e8a515896a708bd59f50b14bc7529d6eb8 Author: Nils Goroll Date: Fri Feb 3 12:49:12 2017 +0100 Bring back STRING + DURATION This is an (intentional) regression from 6f9595e6563cf53118048bcb5d1591a6b631b84c, but I don't see why we should prevent stringifications of DURATION. Related to #2101 #2102 diff --git a/bin/varnishtest/tests/v00020.vtc b/bin/varnishtest/tests/v00020.vtc index e7c0bb5..352809f 100644 --- a/bin/varnishtest/tests/v00020.vtc +++ b/bin/varnishtest/tests/v00020.vtc @@ -141,6 +141,9 @@ varnish v1 -vcl { else if (4) { } else { } } + sub vcl_backend_response { + set beresp.http.buzz = "ttl=" + beresp.ttl; + } } # XXX: not the most clear error message @@ -214,13 +217,6 @@ varnish v1 -errvcl {DURATION + STRING not possible.} { } } -varnish v1 -errvcl {STRING + DURATION not possible.} { - backend b { .host = "127.0.0.1"; } - sub vcl_recv { - set req.http.foo = "foo" + 1s; - } -} - varnish v1 -errvcl {DURATION + INT not possible.} { backend b { .host = "127.0.0.1"; } sub vcl_recv { diff --git a/lib/libvcc/vcc_expr.c b/lib/libvcc/vcc_expr.c index 974a80f..680ebd6 100644 --- a/lib/libvcc/vcc_expr.c +++ b/lib/libvcc/vcc_expr.c @@ -1027,7 +1027,6 @@ static const struct adds { { '+', DURATION, REAL, VOID }, { '+', DURATION, TIME, VOID }, { '+', DURATION, STRING, VOID }, - { '+', STRING, DURATION, VOID }, { EOI, VOID, VOID, VOID } }; From dridi.boukelmoune at gmail.com Fri Feb 3 16:39:05 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 03 Feb 2017 17:39:05 +0100 Subject: [master] 06108a1 Test what logexpect can't Message-ID: commit 06108a1930009b7186f776ba279a81d3ad3399e3 Author: Dridi Boukelmoune Date: Fri Feb 3 15:36:49 2017 +0100 Test what logexpect can't We also don't want the test to pass if varnishlog failed. diff --git a/bin/varnishtest/tests/m00022.vtc b/bin/varnishtest/tests/m00022.vtc index a9863d6..11ba4cf 100644 --- a/bin/varnishtest/tests/m00022.vtc +++ b/bin/varnishtest/tests/m00022.vtc @@ -34,6 +34,12 @@ varnish v1 -errvcl "Planned failure in vcl_init" { logexpect l1 -wait +shell { + set -e + varnishlog -n ${v1_name} -d -g raw >v1.log + ! grep "Should not happen" v1.log +} + varnish v1 -cliok "param.set nuke_limit 42" varnish v1 -errvcl "nuke_limit is not the answer." { From dridi.boukelmoune at gmail.com Fri Feb 3 16:39:05 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 03 Feb 2017 17:39:05 +0100 Subject: [master] 1706409 Half of #2088 is solved Message-ID: commit 1706409325fed0d464f50add5c72acb5d8e35c6b Author: Dridi Boukelmoune Date: Fri Feb 3 15:57:01 2017 +0100 Half of #2088 is solved See 9849fd0 for how it was solved. diff --git a/bin/varnishtest/tests/m00027.vtc b/bin/varnishtest/tests/m00027.vtc new file mode 100644 index 0000000..92cd417 --- /dev/null +++ b/bin/varnishtest/tests/m00027.vtc @@ -0,0 +1,25 @@ +varnishtest "Test object initialization failure" + +server s1 { } -start + +varnish v1 -vcl+backend { } -start + +varnish v1 -errvcl "Missing dynamic backend address or port" { + import debug; + import std; + + backend be { + .host = "${bad_backend}"; + } + + sub vcl_init { + new obj = debug.dyn("", ""); + std.log("Should not happen"); + } +} + +shell -err { + set -e + varnishlog -n ${v1_name} -d -g raw >v1.log + ! grep "Should not happen" v1.log +} diff --git a/lib/libvmod_debug/vmod.vcc b/lib/libvmod_debug/vmod.vcc index ca61e45..a9d7d57 100644 --- a/lib/libvmod_debug/vmod.vcc +++ b/lib/libvmod_debug/vmod.vcc @@ -153,7 +153,7 @@ Sleep the current worker thread. $Object dyn(STRING addr, STRING port) -Dynamically create a single-backend director +Dynamically create a single-backend director, addr and port must not be empty. $Method BACKEND .backend() diff --git a/lib/libvmod_debug/vmod_debug_dyn.c b/lib/libvmod_debug/vmod_debug_dyn.c index 03610ee..b2d87f6 100644 --- a/lib/libvmod_debug/vmod_debug_dyn.c +++ b/lib/libvmod_debug/vmod_debug_dyn.c @@ -117,6 +117,14 @@ vmod_dyn__init(VRT_CTX, struct vmod_debug_dyn **dynp, AZ(*dynp); AN(vcl_name); + if (*addr == '\0' || *port == '\0') { + AN(ctx->handling); + AZ(*ctx->handling); + VSB_printf(ctx->msg, "Missing dynamic backend address or port"); + VRT_handling(ctx, VCL_RET_FAIL); + return; + } + ALLOC_OBJ(dyn, VMOD_DEBUG_DYN_MAGIC); AN(dyn); REPLACE(dyn->vcl_name, vcl_name); @@ -134,6 +142,9 @@ vmod_dyn__fini(struct vmod_debug_dyn **dynp) struct vmod_debug_dyn *dyn; AN(dynp); + if (*dynp == NULL) + return; /* failed initialization */ + CAST_OBJ_NOTNULL(dyn, *dynp, VMOD_DEBUG_DYN_MAGIC); /* at this point all backends will be deleted by the vcl */ free(dyn->vcl_name); From dridi.boukelmoune at gmail.com Fri Feb 3 16:39:05 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 03 Feb 2017 17:39:05 +0100 Subject: [master] 0d63862 Include vcl.use in varnish -vcl failure detection Message-ID: commit 0d6386265d2e7bdc4259d793fa6692983a5a5da8 Author: Dridi Boukelmoune Date: Fri Feb 3 17:18:42 2017 +0100 Include vcl.use in varnish -vcl failure detection Instead of crashing the varnishtest sub-process with an assert, check that both `vcl.load` and `vcl.use` pass or fail when running the varnish command for `-vcl` and `-errvcl`. `vcl.use` may fail the warmup step. diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c index 7a2e710..745312e 100644 --- a/bin/varnishtest/vtc_varnish.c +++ b/bin/varnishtest/vtc_varnish.c @@ -732,21 +732,19 @@ varnish_vcl(struct varnish *v, const char *vcl, int fail, char **resp) AZ(VSB_finish(vsb)); u = varnish_ask_cli(v, VSB_data(vsb), resp); - if (u == CLIS_OK && fail) { - VSB_destroy(&vsb); - vtc_fatal(v->vl, - "VCL compilation succeeded expected failure"); - } else if (u == CLIS_OK) { + if (u == CLIS_OK) { VSB_clear(vsb); VSB_printf(vsb, "vcl.use vcl%d", v->vcl_nbr); AZ(VSB_finish(vsb)); u = varnish_ask_cli(v, VSB_data(vsb), NULL); - assert(u == CLIS_OK); - } else if (!fail) { + } + if (u == CLIS_OK && fail) { VSB_destroy(&vsb); - vtc_fatal(v->vl, - "VCL compilation failed expected success"); - } else { + vtc_fatal(v->vl, "VCL compilation succeeded expected failure"); + } else if (u != CLIS_OK && !fail) { + VSB_destroy(&vsb); + vtc_fatal(v->vl, "VCL compilation failed expected success"); + } else if (fail) { vtc_log(v->vl, 2, "VCL compilation failed (as expected)"); } VSB_destroy(&vsb); From dridi.boukelmoune at gmail.com Fri Feb 3 16:54:05 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 03 Feb 2017 17:54:05 +0100 Subject: [master] 24da967 Forgot to remove -err Message-ID: commit 24da967b48d074fa7b9c3f067319ba4d1b2be37d Author: Dridi Boukelmoune Date: Fri Feb 3 17:50:28 2017 +0100 Forgot to remove -err The original test was: shell -err { varnishlog -n ${v1_name} -d -g raw | grep "Should not happen" } But it wouldn't catch errors, like for example varnishlog failing to connect to the shmlog. diff --git a/bin/varnishtest/tests/m00027.vtc b/bin/varnishtest/tests/m00027.vtc index 92cd417..daadeab 100644 --- a/bin/varnishtest/tests/m00027.vtc +++ b/bin/varnishtest/tests/m00027.vtc @@ -18,7 +18,7 @@ varnish v1 -errvcl "Missing dynamic backend address or port" { } } -shell -err { +shell { set -e varnishlog -n ${v1_name} -d -g raw >v1.log ! grep "Should not happen" v1.log From fgsch at lodoss.net Fri Feb 3 23:42:06 2017 From: fgsch at lodoss.net (Federico Schwindt) Date: Fri, 3 Feb 2017 23:42:06 +0000 Subject: [master] 06108a1 Test what logexpect can't In-Reply-To: References: Message-ID: Why not simply: shell -match "^$" { varnishlog -n ${v1_name} -d -g raw -I "Should not happen" } ? Same with m00027.vtc On Fri, Feb 3, 2017 at 4:39 PM, Dridi Boukelmoune < dridi.boukelmoune at gmail.com> wrote: > > commit 06108a1930009b7186f776ba279a81d3ad3399e3 > Author: Dridi Boukelmoune > Date: Fri Feb 3 15:36:49 2017 +0100 > > Test what logexpect can't > > We also don't want the test to pass if varnishlog failed. > > diff --git a/bin/varnishtest/tests/m00022.vtc b/bin/varnishtest/tests/ > m00022.vtc > index a9863d6..11ba4cf 100644 > --- a/bin/varnishtest/tests/m00022.vtc > +++ b/bin/varnishtest/tests/m00022.vtc > @@ -34,6 +34,12 @@ varnish v1 -errvcl "Planned failure in vcl_init" { > > logexpect l1 -wait > > +shell { > + set -e > + varnishlog -n ${v1_name} -d -g raw >v1.log > + ! grep "Should not happen" v1.log > +} > + > varnish v1 -cliok "param.set nuke_limit 42" > > varnish v1 -errvcl "nuke_limit is not the answer." { > > _______________________________________________ > varnish-commit mailing list > varnish-commit at varnish-cache.org > https://www.varnish-cache.org/lists/mailman/listinfo/varnish-commit > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dridi at varni.sh Fri Feb 3 23:47:48 2017 From: dridi at varni.sh (Dridi Boukelmoune) Date: Sat, 4 Feb 2017 00:47:48 +0100 Subject: [master] 06108a1 Test what logexpect can't In-Reply-To: References: Message-ID: On Sat, Feb 4, 2017 at 12:42 AM, Federico Schwindt wrote: > Why not simply: > > shell -match "^$" { > varnishlog -n ${v1_name} -d -g raw -I "Should not happen" > } > > ? > > Same with m00027.vtc As you may have guessed I'm not happy with the (slightly convoluted) outcome. At least I was satisfied with knowing that "should not happen" did not happen. I thought about trying a "negative" -match but gave up. I must say I like your trick better, it even fits in a single line: shell -match "^$" {varnishlog -n ${v1_name} -d -g raw -I "Should not happen"} Feel free to amend the tests. Cheers From dridi.boukelmoune at gmail.com Sat Feb 4 08:50:05 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Sat, 04 Feb 2017 09:50:05 +0100 Subject: [master] e300b98 Assume an error when terminated by a signal Message-ID: commit e300b9816a264ada1304ecc57a6b2a252951ada5 Author: Dridi Boukelmoune Date: Sat Feb 4 00:30:28 2017 +0100 Assume an error when terminated by a signal While working on libvarnishapi I couldn't get the VUTs to fail on an INCOMPL() statement, this was caused by the recent changes to the `shell` command. diff --git a/bin/varnishtest/vtc.c b/bin/varnishtest/vtc.c index 64ed594..483acff 100644 --- a/bin/varnishtest/vtc.c +++ b/bin/varnishtest/vtc.c @@ -503,7 +503,8 @@ cmd_shell_engine(struct vtclog *vl, int ok, const char *cmd, vtc_log(vl, 4, "shell_status = 0x%04x", WEXITSTATUS(r)); if (WIFSIGNALED(r)) vtc_log(vl, 4, "shell_signal = %d", WTERMSIG(r)); - if (ok < 0 && !WEXITSTATUS(r)) + + if (ok < 0 && !WEXITSTATUS(r) && !WIFSIGNALED(r)) vtc_fatal(vl, "shell did not fail as expected"); else if (ok >= 0 && WEXITSTATUS(r) != ok) { vtc_fatal(vl, From dridi.boukelmoune at gmail.com Sat Feb 4 08:50:05 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Sat, 04 Feb 2017 09:50:05 +0100 Subject: [master] e5edb7c Simplify "Should not happen" checks Message-ID: commit e5edb7ccebad52b7e03c399ec2bd4c8ced04ccb3 Author: Dridi Boukelmoune Date: Sat Feb 4 09:45:52 2017 +0100 Simplify "Should not happen" checks Suggested by Federico. diff --git a/bin/varnishtest/tests/m00022.vtc b/bin/varnishtest/tests/m00022.vtc index 11ba4cf..7a2299a 100644 --- a/bin/varnishtest/tests/m00022.vtc +++ b/bin/varnishtest/tests/m00022.vtc @@ -34,11 +34,7 @@ varnish v1 -errvcl "Planned failure in vcl_init" { logexpect l1 -wait -shell { - set -e - varnishlog -n ${v1_name} -d -g raw >v1.log - ! grep "Should not happen" v1.log -} +shell -match "^$" {varnishlog -n ${v1_name} -d -g raw -I "Should not happen"} varnish v1 -cliok "param.set nuke_limit 42" diff --git a/bin/varnishtest/tests/m00027.vtc b/bin/varnishtest/tests/m00027.vtc index daadeab..d419b78 100644 --- a/bin/varnishtest/tests/m00027.vtc +++ b/bin/varnishtest/tests/m00027.vtc @@ -18,8 +18,4 @@ varnish v1 -errvcl "Missing dynamic backend address or port" { } } -shell { - set -e - varnishlog -n ${v1_name} -d -g raw >v1.log - ! grep "Should not happen" v1.log -} +shell -match "^$" {varnishlog -n ${v1_name} -d -g raw -I "Should not happen"} From dridi.boukelmoune at gmail.com Sat Feb 4 09:04:05 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Sat, 04 Feb 2017 10:04:05 +0100 Subject: [master] cca7700 Boolean 101 Message-ID: commit cca77006b7787bfcd122d76f033656a5f965ffea Author: Dridi Boukelmoune Date: Sat Feb 4 10:01:07 2017 +0100 Boolean 101 Sometimes it's not a good idea to fix things after midnight. diff --git a/bin/varnishtest/vtc.c b/bin/varnishtest/vtc.c index 483acff..0f501ca 100644 --- a/bin/varnishtest/vtc.c +++ b/bin/varnishtest/vtc.c @@ -504,7 +504,7 @@ cmd_shell_engine(struct vtclog *vl, int ok, const char *cmd, if (WIFSIGNALED(r)) vtc_log(vl, 4, "shell_signal = %d", WTERMSIG(r)); - if (ok < 0 && !WEXITSTATUS(r) && !WIFSIGNALED(r)) + if (ok < 0 && (!WEXITSTATUS(r) || WIFSIGNALED(r))) vtc_fatal(vl, "shell did not fail as expected"); else if (ok >= 0 && WEXITSTATUS(r) != ok) { vtc_fatal(vl, From dridi.boukelmoune at gmail.com Sat Feb 4 09:10:05 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Sat, 04 Feb 2017 10:10:05 +0100 Subject: [master] 03f65b1 Revert "Boolean 101" Message-ID: commit 03f65b10995fc2c308e58782f94ee9ca911a789d Author: Dridi Boukelmoune Date: Sat Feb 4 10:08:12 2017 +0100 Revert "Boolean 101" This reverts commit cca77006b7787bfcd122d76f033656a5f965ffea. Sometimes it's not a good idea to fix things before having coffee. diff --git a/bin/varnishtest/vtc.c b/bin/varnishtest/vtc.c index 0f501ca..483acff 100644 --- a/bin/varnishtest/vtc.c +++ b/bin/varnishtest/vtc.c @@ -504,7 +504,7 @@ cmd_shell_engine(struct vtclog *vl, int ok, const char *cmd, if (WIFSIGNALED(r)) vtc_log(vl, 4, "shell_signal = %d", WTERMSIG(r)); - if (ok < 0 && (!WEXITSTATUS(r) || WIFSIGNALED(r))) + if (ok < 0 && !WEXITSTATUS(r) && !WIFSIGNALED(r)) vtc_fatal(vl, "shell did not fail as expected"); else if (ok >= 0 && WEXITSTATUS(r) != ok) { vtc_fatal(vl, From dridi.boukelmoune at gmail.com Sat Feb 4 17:27:04 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Sat, 04 Feb 2017 18:27:04 +0100 Subject: [master] 4d446f4 Don't logexpect partial regular expressions Message-ID: commit 4d446f4347e6bfe273eb7d27e5fec690b995e862 Author: Dridi Boukelmoune Date: Sat Feb 4 17:22:19 2017 +0100 Don't logexpect partial regular expressions It turns out some of the tests weren't completely checked. diff --git a/bin/varnishtest/tests/b00002.vtc b/bin/varnishtest/tests/b00002.vtc index 3c0fce5..4426904 100644 --- a/bin/varnishtest/tests/b00002.vtc +++ b/bin/varnishtest/tests/b00002.vtc @@ -18,10 +18,10 @@ varnish v1 -vcl+backend { # last header and VCL_return b deliver logexpect l1 -v v1 -g request { expect * 1002 Begin - expect * = BerespHeader ^Date: - expect 0 = VCL_call ^BACKEND_RESPONSE - expect 0 = BerespHeader ^x-ttl: 0.000 - expect 0 = VCL_return ^deliver + expect * = BerespHeader {^Date:} + expect 0 = VCL_call {^BACKEND_RESPONSE} + expect 0 = BerespHeader {^x-ttl: 0.000} + expect 0 = VCL_return {^deliver} } -start client c1 { diff --git a/bin/varnishtest/tests/r01441.vtc b/bin/varnishtest/tests/r01441.vtc index 455663c..454a5e9 100644 --- a/bin/varnishtest/tests/r01441.vtc +++ b/bin/varnishtest/tests/r01441.vtc @@ -19,15 +19,15 @@ varnish v1 -vcl+backend { } -start -cliok "param.set debug +syncvsl" logexpect l1 -v v1 -g session { - expect 0 1000 Begin sess 0 HTTP/1 + expect 0 1000 Begin {sess 0 HTTP/1} expect * = End - expect 0 1001 Begin req 1000 rxreq + expect 0 1001 Begin {req 1000 rxreq} expect * = End - expect 0 1002 Begin bereq 1001 fetch + expect 0 1002 Begin {bereq 1001 fetch} expect * = End - expect 0 1003 Begin req 1001 esi + expect 0 1003 Begin {req 1001 esi} expect * = End - expect 0 1004 Begin bereq 1003 fetch + expect 0 1004 Begin {bereq 1003 fetch} expect * = End } -start diff --git a/bin/varnishtest/tests/s00004.vtc b/bin/varnishtest/tests/s00004.vtc index 2f10563..675a0c8 100644 --- a/bin/varnishtest/tests/s00004.vtc +++ b/bin/varnishtest/tests/s00004.vtc @@ -39,7 +39,7 @@ logexpect l1 -v v1 -g request { expect * = Timestamp {Beresp: \S+ 1\.\d+ [01]\.\d+} expect * = Timestamp {BerespBody: \S+ 2\.\d+ 1\.\d+} expect * = End - expect 0 1003 Begin req 1001 restart + expect 0 1003 Begin {req 1001 restart} expect * = Timestamp {Start: \S+ 2\.\d+ 0\.\d+} expect * = Timestamp {Process: \S+ 2\.\d+ 0\.\d+} expect * = Timestamp {Resp: \S+ 2\.\d+ 0\.\d+} diff --git a/bin/varnishtest/vtc_logexp.c b/bin/varnishtest/vtc_logexp.c index b564151..3f205fb 100644 --- a/bin/varnishtest/vtc_logexp.c +++ b/bin/varnishtest/vtc_logexp.c @@ -101,8 +101,10 @@ * Tag to match against * * regex: - * regular expression to match against (optional) ('*' is anything, '=' - * is the value of the last matched record) + * regular expression to match against (optional) + * + * For skip, vxid and tag, '*' matches anything, '=' expects the value of the + * previous matched record. */ #include "config.h" @@ -433,6 +435,9 @@ cmd_logexp_expect(CMD_ARGS) if (av[1] == NULL || av[2] == NULL || av[3] == NULL) vtc_fatal(vl, "Syntax error"); + if (av[4] != NULL && av[5] != NULL) + vtc_fatal(vl, "Syntax error"); + if (!strcmp(av[1], "*")) skip_max = LE_ANY; else { From dridi.boukelmoune at gmail.com Sat Feb 4 17:27:04 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Sat, 04 Feb 2017 18:27:04 +0100 Subject: [master] 412961a Polish shell usage in test cases Message-ID: commit 412961ab472cf3c3c2fdb7c99fc5376e47108c4d Author: Dridi Boukelmoune Date: Sat Feb 4 18:24:22 2017 +0100 Polish shell usage in test cases Make use of the ${v*_name} macro and retire redundant redirections. diff --git a/bin/varnishtest/tests/b00041.vtc b/bin/varnishtest/tests/b00041.vtc index 7c004e7..2fd2690 100644 --- a/bin/varnishtest/tests/b00041.vtc +++ b/bin/varnishtest/tests/b00041.vtc @@ -2,4 +2,4 @@ varnishtest "Test varnishadm and the Telnet CLI" varnish v1 -vcl {backend foo { .host = "127.0.0.1"; } } -start -shell "varnishadm -n ${tmpdir}/v1 help > /dev/null" +shell "varnishadm -n ${v1_name} help > /dev/null" diff --git a/bin/varnishtest/tests/b00045.vtc b/bin/varnishtest/tests/b00045.vtc index 74d18f3..8863bad 100644 --- a/bin/varnishtest/tests/b00045.vtc +++ b/bin/varnishtest/tests/b00045.vtc @@ -15,4 +15,4 @@ client c1 { delay .2 shell -err -expect {Could not open pid/lock} \ - "varnishd -P ${tmpdir}/v1/varnishd.pid -b 127.0.0.1:80 -a :0 -n ${tmpdir} 2>&1" + "varnishd -P ${v1_name}/varnishd.pid -b 127.0.0.1:80 -a :0 -n ${tmpdir}" diff --git a/bin/varnishtest/tests/j00003.vtc b/bin/varnishtest/tests/j00003.vtc index e67589e..596ce41 100644 --- a/bin/varnishtest/tests/j00003.vtc +++ b/bin/varnishtest/tests/j00003.vtc @@ -2,11 +2,11 @@ varnishtest "-junix bad subarg handling" feature root -shell -err -expect "unknown sub-argument" "varnishd -junix,bla=foo -f '' 2>&1" -shell -err -expect "user not found" "varnishd -junix,user=/// -f '' 2>&1" -shell -err -expect "user not found" "varnishd -junix,workuser=/// -f '' 2>&1" -shell -err -expect "group not found" "varnishd -junix,ccgroup=/// -f '' 2>&1" +shell -err -expect "unknown sub-argument" "varnishd -junix,bla=foo -f ''" +shell -err -expect "user not found" "varnishd -junix,user=/// -f ''" +shell -err -expect "user not found" "varnishd -junix,workuser=/// -f ''" +shell -err -expect "group not found" "varnishd -junix,ccgroup=/// -f ''" feature user_varnish -shell -err -expect "have different login groups" "varnishd -junix,workuser=root -f '' 2>&1" +shell -err -expect "have different login groups" "varnishd -junix,workuser=root -f ''" diff --git a/bin/varnishtest/tests/u00003.vtc b/bin/varnishtest/tests/u00003.vtc index 2f4e188..cab8750 100644 --- a/bin/varnishtest/tests/u00003.vtc +++ b/bin/varnishtest/tests/u00003.vtc @@ -67,7 +67,7 @@ client c1 { delay 1 -shell "mv ${tmpdir}/ncsa.log ${tmpdir}/ncsa.old.log >/dev/null 2>&1" +shell "mv ${tmpdir}/ncsa.log ${tmpdir}/ncsa.old.log" shell "kill -HUP `cat ${tmpdir}/ncsa.pid`" client c1 { diff --git a/bin/varnishtest/tests/u00006.vtc b/bin/varnishtest/tests/u00006.vtc index 9b6f83f..1514a87 100644 --- a/bin/varnishtest/tests/u00006.vtc +++ b/bin/varnishtest/tests/u00006.vtc @@ -52,7 +52,7 @@ client c1 { delay 1 -shell "mv ${tmpdir}/vlog.bin ${tmpdir}/vlog.bin~ >/dev/null 2>&1" +shell "mv ${tmpdir}/vlog.bin ${tmpdir}/vlog.bin~" shell "kill -HUP `cat ${tmpdir}/vlog.pid`" client c1 { From dridi.boukelmoune at gmail.com Sat Feb 4 17:27:04 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Sat, 04 Feb 2017 18:27:04 +0100 Subject: [master] 45190d6 Code style polish mostly around vtc_fatal Message-ID: commit 45190d60d373c5402b90851672e9a39864832bf5 Author: Dridi Boukelmoune Date: Sat Feb 4 18:25:49 2017 +0100 Code style polish mostly around vtc_fatal diff --git a/bin/varnishtest/vtc.c b/bin/varnishtest/vtc.c index 483acff..7ec5caf 100644 --- a/bin/varnishtest/vtc.c +++ b/bin/varnishtest/vtc.c @@ -379,10 +379,9 @@ parse_string(const char *spec, const struct cmds *cmd, void *priv, for (cp = cmd; cp->name != NULL; cp++) if (!strcmp(token_s[0], cp->name)) break; - if (cp->name == NULL) { + + if (cp->name == NULL) vtc_fatal(vl, "Unknown command: \"%s\"", token_s[0]); - NEEDLESS(return); - } assert(cp->cmd != NULL); cp->cmd(token_s, priv, cmd, vl); @@ -506,11 +505,10 @@ cmd_shell_engine(struct vtclog *vl, int ok, const char *cmd, if (ok < 0 && !WEXITSTATUS(r) && !WIFSIGNALED(r)) vtc_fatal(vl, "shell did not fail as expected"); - else if (ok >= 0 && WEXITSTATUS(r) != ok) { - vtc_fatal(vl, - "shell_exit not as expected: got 0x%04x wanted 0x%04x", - WEXITSTATUS(r), ok); - } + else if (ok >= 0 && WEXITSTATUS(r) != ok) + vtc_fatal(vl, "shell_exit not as expected: " + "got 0x%04x wanted 0x%04x", WEXITSTATUS(r), ok); + if (expect != NULL) { if (strstr(VSB_data(vsb), expect) == NULL) vtc_fatal(vl, @@ -709,9 +707,8 @@ cmd_feature(CMD_ARGS) #endif } else if (!strcmp(*av, "cmd")) { av++; - if (*av == NULL) { + if (*av == NULL) vtc_fatal(vl, "Missing the command-line"); - } r = system(*av); if (WEXITSTATUS(r) == 0) good = 1; @@ -721,13 +718,11 @@ cmd_feature(CMD_ARGS) if (good) continue; - if (!vtc_stop) { - vtc_fatal(vl, - "FAIL test, unknown feature: %s", *av); - } else { + if (!vtc_stop) + vtc_fatal(vl, "FAIL test, unknown feature: %s", *av); + else vtc_log(vl, 1, "SKIPPING test, lacking feature: %s", *av); - } return; } } diff --git a/bin/varnishtest/vtc_http.c b/bin/varnishtest/vtc_http.c index f7f61a5..9266bdc 100644 --- a/bin/varnishtest/vtc_http.c +++ b/bin/varnishtest/vtc_http.c @@ -1114,8 +1114,7 @@ cmd_http_rxreq(CMD_ARGS) http_rxhdr(hp); http_splitheader(hp, 1); if (http_count_header(hp->req, "Content-Length") > 1) - vtc_fatal(vl, - "Multiple Content-Length headers.\n"); + vtc_fatal(vl, "Multiple Content-Length headers.\n"); http_swallow_body(hp, hp->req, 0); vtc_log(vl, 4, "bodylen = %s", hp->bodylen); } @@ -1142,8 +1141,7 @@ cmd_http_rxreqhdrs(CMD_ARGS) http_rxhdr(hp); http_splitheader(hp, 1); if (http_count_header(hp->req, "Content-Length") > 1) - vtc_fatal(hp->vl, - "Multiple Content-Length headers.\n"); + vtc_fatal(hp->vl, "Multiple Content-Length headers.\n"); } /* SECTION: client-server.spec.rxreqbody @@ -1666,9 +1664,8 @@ cmd_http_fatal(CMD_ARGS) hp->fatal = 0; else if (!strcmp(av[0], "non_fatal")) hp->fatal = -1; - else { + else vtc_fatal(vl, "XXX: fatal %s", cmd->name); - } } #define cmd_http_non_fatal cmd_http_fatal @@ -1764,8 +1761,8 @@ cmd_http_settings(CMD_ARGS) if (!strcmp(*av, "-dectbl")) { n = strtoul(av[1], &p, 0); if (*p != '\0') - vtc_fatal(hp->vl, "-dectbl takes an integer as" - " argument (found %s)", av[1]); + vtc_fatal(hp->vl, "-dectbl takes an integer as " + "argument (found %s)", av[1]); HPK_ResizeTbl(hp->decctx, n); av++; } else diff --git a/bin/varnishtest/vtc_http2.c b/bin/varnishtest/vtc_http2.c index 12a84f3..f7f0e34 100644 --- a/bin/varnishtest/vtc_http2.c +++ b/bin/varnishtest/vtc_http2.c @@ -596,7 +596,8 @@ parse_settings(const struct stream *s, struct frame *f) CAST_OBJ_NOTNULL(hp, s->hp, HTTP_MAGIC);; if (f->size % 6) - vtc_fatal(hp->vl, "Size should be a multiple of 6, but isn't (%d)", f->size); + vtc_fatal(hp->vl, + "Size should be a multiple of 6, but isn't (%d)", f->size); for (i = 0; i <= SETTINGS_MAX; i++) f->md.settings[i] = NAN; @@ -650,9 +651,11 @@ parse_goaway(const struct stream *s, struct frame *f) CAST_OBJ_NOTNULL(hp, s->hp, HTTP_MAGIC);; if (f->size < 8) - vtc_fatal(hp->vl, "Size should be at least 8, but isn't (%d)", f->size); + vtc_fatal(hp->vl, + "Size should be at least 8, but isn't (%d)", f->size); if (f->data[0] & (1<<7)) - vtc_fatal(hp->vl, "First bit of data is reserved and should be 0"); + vtc_fatal(hp->vl, + "First bit of data is reserved and should be 0"); stid = vbe32dec(f->data); err = vbe32dec(f->data + 4); @@ -690,7 +693,8 @@ parse_winup(const struct stream *s, struct frame *f) if (f->size != 4) vtc_fatal(hp->vl, "Size should be 4, but isn't (%d)", f->size); if (f->data[0] & (1<<7)) - vtc_log(hp->vl, s->hp->fatal, "First bit of data is reserved and should be 0"); + vtc_log(hp->vl, s->hp->fatal, + "First bit of data is reserved and should be 0"); size = vbe32dec(f->data); f->md.winup_size = size; @@ -748,10 +752,9 @@ receive_frame(void *priv) AZ(pthread_mutex_lock(&hp->mtx)); s = NULL; while (!s) { - VTAILQ_FOREACH(s, &hp->streams, list) { + VTAILQ_FOREACH(s, &hp->streams, list) if (s->id == f->stid) break; - } if (!s) AZ(pthread_cond_wait(&hp->cond, &hp->mtx)); if (!hp->h2) { @@ -762,10 +765,10 @@ receive_frame(void *priv) } AZ(pthread_mutex_unlock(&hp->mtx)); - if (expect_cont && (f->type != TYPE_CONTINUATION || - expect_cont != s->id)) - vtc_fatal(hp->vl, "Expected CONTINUATION frame for" - " stream %u", expect_cont); + if (expect_cont && + (f->type != TYPE_CONTINUATION || expect_cont != s->id)) + vtc_fatal(hp->vl, "Expected CONTINUATION frame for " + "stream %u", expect_cont); /* parse the frame according to it type, and fill the metada */ switch (f->type) { @@ -1028,15 +1031,12 @@ cmd_var_resolve(const struct stream *s, const char *spec, char *buf) spec += 7; CHECK_LAST_FRAME(GOAWAY); - if (!strcmp(spec, "err")) { + if (!strcmp(spec, "err")) RETURN_BUFFED(f->md.goaway.err); - } - else if (!strcmp(spec, "laststream")) { + else if (!strcmp(spec, "laststream")) RETURN_BUFFED(f->md.goaway.stream); - } - else if (!strcmp(spec, "debug")) { + else if (!strcmp(spec, "debug")) return (f->md.goaway.debug); - } } /* SECTION: stream.spec.zexpect.zframe Generic frame * frame.data @@ -1093,17 +1093,15 @@ cmd_var_resolve(const struct stream *s, const char *spec, char *buf) if (s->id) { snprintf(buf, 20, "%d", s->weight); return (buf); - } else { - return NULL; - } + } else + return (NULL); } else if (!strcmp(spec, "stream.dependency")) { if (s->id) { snprintf(buf, 20, "%d", s->dependency); return (buf); - } else { - return NULL; - } + } else + return (NULL); } /* SECTION: stream.spec.zexpect.ztable Index tables * tbl.dec.size / tbl.enc.size @@ -1123,8 +1121,7 @@ cmd_var_resolve(const struct stream *s, const char *spec, char *buf) * Value of the header at index INT of the decoding/encoding * table. */ - else if (!strncmp(spec, "tbl.dec", 7) || - !strncmp(spec, "tbl.enc", 7)) { + else if (!strncmp(spec, "tbl.dec", 7) || !strncmp(spec, "tbl.enc", 7)) { if (spec[4] == 'd') ctx = s->hp->decctx; else @@ -1141,15 +1138,12 @@ cmd_var_resolve(const struct stream *s, const char *spec, char *buf) h = HPK_GetHdr(ctx, idx + 61); return (h ? h->value.ptr : NULL); } - else if (!strcmp(spec, ".size")) { + else if (!strcmp(spec, ".size")) RETURN_BUFFED(HPK_GetTblSize(ctx)); - } - else if (!strcmp(spec, ".maxsize")) { + else if (!strcmp(spec, ".maxsize")) RETURN_BUFFED(HPK_GetTblMaxSize(ctx)); - } - else if (!strcmp(spec, ".length")) { + else if (!strcmp(spec, ".length")) RETURN_BUFFED(HPK_GetTblLength(ctx)); - } } /* SECTION: stream.spec.zexpect.zre Request and response * @@ -1483,11 +1477,10 @@ cmd_tx11obj(CMD_ARGS) else if (AV_IS("never")) { hdr.t = hpk_never; } else vtc_fatal(vl, "first -litidxHdr arg can be " - "inc, not, never (got: %s)", - *av); + "inc, not, never (got: %s)", *av); STRTOU32_CHECK(hdr.i, av, p, vl, - "second -litidxHdr arg", 0); + "second -litidxHdr arg", 0); hdr.key.ptr = NULL; hdr.key.len = 0; @@ -1501,7 +1494,7 @@ cmd_tx11obj(CMD_ARGS) else if (AV_IS("never")) { hdr.t = hpk_never; } else vtc_fatal(vl, "first -litHdr arg can be inc, " - "not, never (got: %s)", *av); + "not, never (got: %s)", *av); STR_ENC(av, key, "second -litHdr"); STR_ENC(av, value, "fourth -litHdr"); @@ -1869,8 +1862,7 @@ cmd_txsettings(CMD_ARGS) vbe32enc(cursor, 1); else vtc_fatal(vl, "Push parameter is either " - "\"true\" or \"false\", not %s", - *av); + "\"true\" or \"false\", not %s", *av); cursor += sizeof(uint32_t); f.size += 6; } @@ -1878,24 +1870,21 @@ cmd_txsettings(CMD_ARGS) PUT_KV(av, vl, hdrtbl, val, 0x1); HPK_ResizeTbl(s->hp->decctx, val); } - else if (!strcmp(*av, "-maxstreams")) { + else if (!strcmp(*av, "-maxstreams")) PUT_KV(av, vl, maxstreams, val, 0x3); - } else if (!strcmp(*av, "-winsize")) { PUT_KV(av, vl, winsize, val, 0x4); VTAILQ_FOREACH(_s, &hp->streams, list) _s->ws += (val - hp->iws); hp->iws = val; } - else if (!strcmp(*av, "-framesize")) { + else if (!strcmp(*av, "-framesize")) PUT_KV(av, vl, framesize, val, 0x5); - } - else if (!strcmp(*av, "-hdrsize")){ + else if (!strcmp(*av, "-hdrsize")) PUT_KV(av, vl, hdrsize, val, 0x6); - } - else if (!strcmp(*av, "-ack")) { + else if (!strcmp(*av, "-ack")) f.flags |= 1; - } else + else break; } if (*av != NULL) @@ -1935,9 +1924,9 @@ cmd_txping(CMD_ARGS) if (strlen(*av) != 8) vtc_fatal(vl, "data must be a 8-char string, found (%s)", *av); f.data = *av; - } else if (!strcmp(*av, "-ack")) { + } else if (!strcmp(*av, "-ack")) f.flags |= 1; - } else + else break; } if (*av != NULL) @@ -1984,10 +1973,9 @@ cmd_txgoaway(CMD_ARGS) while (*++av) { if (!strcmp(*av, "-err")) { ++av; - for (err=0; h2_errs[err]; err++) { + for (err=0; h2_errs[err]; err++) if (!strcmp(h2_errs[err], *av)) break; - } if (h2_errs[err]) continue; @@ -2045,12 +2033,11 @@ cmd_txwinup(CMD_ARGS) INIT_FRAME(f, WINDOW_UPDATE, 4, s->id, 0); f.data = buf; - while (*++av) { + while (*++av) if (!strcmp(*av, "-size")) { STRTOU32_CHECK(size, av, p, vl, "-size", 0); } else break; - } if (*av != NULL) vtc_fatal(vl, "Unknown txwinup spec: %s\n", *av); @@ -2095,10 +2082,10 @@ rxstuff(struct stream *s) do { \ if (rt != wt) \ vtc_fatal(vl, "Frame #%d for %s was of type %s (%d) " \ - "instead of %s (%d)", \ - rcv, func, \ - rt < TYPE_MAX ? h2_types[rt] : "?", rt, \ - wt < TYPE_MAX ? h2_types[wt] : "?", wt); \ + "instead of %s (%d)", \ + rcv, func, \ + rt < TYPE_MAX ? h2_types[rt] : "?", rt, \ + wt < TYPE_MAX ? h2_types[wt] : "?", wt); \ } while (0); /* SECTION: stream.spec.data_11 rxhdrs @@ -2131,9 +2118,9 @@ cmd_rxhdrs(CMD_ARGS) if (!strcmp(*av, "-some")) { STRTOU32_CHECK(times, av, p, vl, "-some", 0); AN(times); - } else if (!strcmp(*av, "-all")) { + } else if (!strcmp(*av, "-all")) loop = 1; - } else + else break; } if (*av != NULL) @@ -2163,14 +2150,13 @@ cmd_rxcont(CMD_ARGS) (void)av; CAST_OBJ_NOTNULL(s, priv, STREAM_MAGIC); - while (*++av) { - if (!strcmp(*av, "-some")) { + while (*++av) + if (!strcmp(*av, "-some")) STRTOU32_CHECK(times, av, p, vl, "-some", 0); - } else if (!strcmp(*av, "-all")) { + else if (!strcmp(*av, "-all")) loop = 1; - } else + else break; - } if (*av != NULL) vtc_fatal(vl, "Unknown rxcont spec: %s\n", *av); @@ -2211,14 +2197,13 @@ cmd_rxdata(CMD_ARGS) (void)av; CAST_OBJ_NOTNULL(s, priv, STREAM_MAGIC); - while (*++av) { - if (!strcmp(*av, "-some")) { + while (*++av) + if (!strcmp(*av, "-some")) STRTOU32_CHECK(times, av, p, vl, "-some", 0); - } else if (!strcmp(*av, "-all")) { + else if (!strcmp(*av, "-all")) loop = 1; - } else + else break; - } if (*av != NULL) vtc_fatal(vl, "Unknown rxdata spec: %s\n", *av); @@ -2339,11 +2324,11 @@ cmd_rxpush(CMD_ARGS) (void)av; \ CAST_OBJ_NOTNULL(s, priv, STREAM_MAGIC); \ if ((s->frame = rxstuff(s))) \ - return; \ + return; \ if (s->frame->type != TYPE_ ## upctype) \ vtc_fatal(vl, "Received frame of type %d " \ - "is invalid for %s", \ - s->frame->type, "rx ## lctype"); \ + "is invalid for %s", \ + s->frame->type, "rx ## lctype"); \ } /* SECTION: stream.spec.prio_rxprio rxprio @@ -2572,7 +2557,7 @@ stream_new(const char *name, struct http *h) STRTOU32(s->id, name, p, h->vl, "stream"); if (s->id & (1U << 31)) vtc_fatal(h->vl, "Stream id must be a 31-bits integer " - "(found %s)", name); + "(found %s)", name); CHECK_OBJ_NOTNULL(h, HTTP_MAGIC); s->hp = h; @@ -2624,7 +2609,7 @@ stream_wait(struct stream *s) AZ(pthread_join(s->tp, &res)); if (res != NULL) vtc_fatal(s->hp->vl, "Stream %u returned \"%s\"", s->id, - (char *)res); + (char *)res); VTAILQ_FOREACH_SAFE(f, &s->fq, list, f2) clean_frame(&f); @@ -2752,27 +2737,27 @@ b64_settings(const struct http *hp, const char *s) while (*s) { v = 0; for (shift = 42; shift >= 0; shift -= 6) { - if (*s >= 'A' && *s <= 'Z') { + if (*s >= 'A' && *s <= 'Z') v |= (uint64_t)(*s - 'A') << shift; - } else if (*s >= 'a' && *s <= 'z') { + else if (*s >= 'a' && *s <= 'z') v |= (uint64_t)(*s - 'a' + 26) << shift; - } else if (*s >= '0' && *s <= '9') { + else if (*s >= '0' && *s <= '9') v |= (uint64_t)(*s - '0' + 52) << shift; - } else if (*s == '-') + else if (*s == '-') v |= (uint64_t)62 << shift; - else if (*s == '_') { + else if (*s == '_') v |= (uint64_t)63 << shift; - } else - vtc_fatal(hp->vl, "Bad \"HTTP2-Settings\" " - "header"); + else + vtc_fatal(hp->vl, + "Bad \"HTTP2-Settings\" header"); s++; } i = v >> 32; v &= 0xffff; - if (i <= SETTINGS_MAX) { + if (i <= SETTINGS_MAX) buf = h2_settings[i]; - } else + else buf = "unknown"; if (v == 1) { diff --git a/bin/varnishtest/vtc_log.c b/bin/varnishtest/vtc_log.c index 0dd2b82..cee5df2 100644 --- a/bin/varnishtest/vtc_log.c +++ b/bin/varnishtest/vtc_log.c @@ -281,10 +281,9 @@ vtc_log_VAS_Fail(const char *func, const char *file, int line, "Assert error in %s(), %s line %d:\n" " Condition(%s) not true.\n", func, file, line, cond); - } else { + } else vtc_fatal(vl, "Assert error in %s(), %s line %d:" " Condition(%s) not true.\n", func, file, line, cond); - } abort(); } diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c index 745312e..ec63d1d 100644 --- a/bin/varnishtest/vtc_varnish.c +++ b/bin/varnishtest/vtc_varnish.c @@ -744,9 +744,8 @@ varnish_vcl(struct varnish *v, const char *vcl, int fail, char **resp) } else if (u != CLIS_OK && !fail) { VSB_destroy(&vsb); vtc_fatal(v->vl, "VCL compilation failed expected success"); - } else if (fail) { + } else if (fail) vtc_log(v->vl, 2, "VCL compilation failed (as expected)"); - } VSB_destroy(&vsb); } @@ -957,9 +956,8 @@ varnish_expect(const struct varnish *v, char * const *av) else if (!strcmp(av[1], "<")) { if (sp.val < ref) good = 1; } else if (!strcmp(av[1], ">=")) { if (sp.val >= ref) good = 1; } else if (!strcmp(av[1], "<=")) { if (sp.val <= ref) good = 1; } - else { + else vtc_fatal(v->vl, "comparison %s unknown", av[1]); - } if (good) break; } From phk at FreeBSD.org Mon Feb 6 09:24:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 06 Feb 2017 10:24:05 +0100 Subject: [master] 52e49f1 Rename debug.init_fail() to debug.fail() and make it general purpose. Message-ID: commit 52e49f19898d00aab139acb504ec62e38803b34c Author: Poul-Henning Kamp Date: Mon Feb 6 08:31:58 2017 +0000 Rename debug.init_fail() to debug.fail() and make it general purpose. diff --git a/bin/varnishtest/tests/m00022.vtc b/bin/varnishtest/tests/m00022.vtc index 7a2299a..ce60baa 100644 --- a/bin/varnishtest/tests/m00022.vtc +++ b/bin/varnishtest/tests/m00022.vtc @@ -13,7 +13,7 @@ logexpect l1 -v v1 -g raw { } -start -varnish v1 -errvcl "Planned failure in vcl_init" { +varnish v1 -errvcl "Forced failure" { import debug; import std; @@ -24,7 +24,7 @@ varnish v1 -errvcl "Planned failure in vcl_init" { sub vcl_init { std.log("Should happen first"); - debug.init_fail(); + debug.fail(); std.log("Should not happen"); } sub vcl_fini { diff --git a/bin/varnishtest/tests/m00023.vtc b/bin/varnishtest/tests/m00023.vtc index 75970d3..919f3cb 100644 --- a/bin/varnishtest/tests/m00023.vtc +++ b/bin/varnishtest/tests/m00023.vtc @@ -19,7 +19,7 @@ varnish v1 -vcl+backend { sub vcl_init { if (!debug.match_acl(loopback, "127.0.0.127")) { - debug.init_fail(); + debug.fail(); } } diff --git a/lib/libvmod_debug/vmod.vcc b/lib/libvmod_debug/vmod.vcc index a9d7d57..4fe903f 100644 --- a/lib/libvmod_debug/vmod.vcc +++ b/lib/libvmod_debug/vmod.vcc @@ -143,9 +143,9 @@ $Function VOID register_obj_events(PRIV_VCL) Register the vmod to receive expiry callbacks -$Function VOID init_fail() +$Function VOID fail() -Function to fail vcl_init{} +Function to fail vcl code. (See also: RFC748) $Function VOID sleep(DURATION) diff --git a/lib/libvmod_debug/vmod_debug.c b/lib/libvmod_debug/vmod_debug.c index 023cdc3..8e857fd 100644 --- a/lib/libvmod_debug/vmod_debug.c +++ b/lib/libvmod_debug/vmod_debug.c @@ -253,11 +253,13 @@ vmod_register_obj_events(VRT_CTX, struct vmod_priv *priv) } VCL_VOID __match_proto__() -vmod_init_fail(VRT_CTX) +vmod_fail(VRT_CTX) { - AN(ctx->msg); - VSB_printf(ctx->msg, "Planned failure in vcl_init{}"); + if(ctx->msg != NULL) + VSB_printf(ctx->msg, "Forced failure"); + else if (ctx->vsl != NULL) + VSLb(ctx->vsl, SLT_Debug, "Forced failure"); VRT_handling(ctx, VCL_RET_FAIL); } From phk at FreeBSD.org Mon Feb 6 09:24:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 06 Feb 2017 10:24:05 +0100 Subject: [master] 61a15cb Implement premature VCL failure in vcl_recv{} and vcl_synth{} Message-ID: commit 61a15cbffe1141c13b87e30d48ce1402f84433bf Author: Poul-Henning Kamp Date: Mon Feb 6 09:22:52 2017 +0000 Implement premature VCL failure in vcl_recv{} and vcl_synth{} diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index e70fec3..b24159b 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -140,6 +140,26 @@ cnt_deliver(struct worker *wrk, struct req *req) } /*-------------------------------------------------------------------- + * VCL failed, die horribly + */ + +static enum req_fsm_nxt +cnt_vclfail(const struct worker *wrk, struct req *req) +{ + + CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); + CHECK_OBJ_NOTNULL(req, REQ_MAGIC); + + HTTP_Copy(req->http, req->http0); + WS_Reset(req->ws, req->ws_req); + req->err_code = 503; + req->err_reason = "VCL failed"; + req->req_step = R_STP_SYNTH; + req->doclose = SC_VCL_FAILURE; + return (REQ_FSM_MORE); +} + +/*-------------------------------------------------------------------- * Emit a synthetic response */ @@ -177,14 +197,19 @@ cnt_synth(struct worker *wrk, struct req *req) AZ(VSB_finish(synth_body)); - http_Unset(h, H_Content_Length); - http_PrintfHeader(req->resp, "Content-Length: %zd", - VSB_len(synth_body)); - - /* Discard any lingering request body before delivery */ - (void)VRB_Ignore(req); + if (wrk->handling == VCL_RET_FAIL) { + VSB_destroy(&synth_body); + req->doclose = SC_VCL_FAILURE; + VSLb_ts_req(req, "Resp", W_TIM_real(wrk)); + http_Teardown(req->resp); + return (REQ_FSM_DONE); + } if (wrk->handling == VCL_RET_RESTART) { + /* + * XXX: Should we reset req->doclose = SC_VCL_FAILURE + * XXX: If so, to what ? + */ HTTP_Setup(h, req->ws, req->vsl, SLT_RespMethod); VSB_destroy(&synth_body); req->req_step = R_STP_RESTART; @@ -192,6 +217,13 @@ cnt_synth(struct worker *wrk, struct req *req) } assert(wrk->handling == VCL_RET_DELIVER); + http_Unset(h, H_Content_Length); + http_PrintfHeader(req->resp, "Content-Length: %zd", + VSB_len(synth_body)); + + /* Discard any lingering request body before delivery */ + (void)VRB_Ignore(req); + req->objcore = HSH_Private(wrk); CHECK_OBJ_NOTNULL(req->objcore, OBJCORE_MAGIC); szl = -1; @@ -754,6 +786,9 @@ cnt_recv(struct worker *wrk, struct req *req) case VCL_RET_SYNTH: req->req_step = R_STP_SYNTH; return (REQ_FSM_MORE); + case VCL_RET_FAIL: + req->req_step = R_STP_VCLFAIL; + return (REQ_FSM_MORE); default: WRONG("Illegal return from vcl_recv{}"); } diff --git a/bin/varnishtest/tests/v00051.vtc b/bin/varnishtest/tests/v00051.vtc new file mode 100644 index 0000000..8800896 --- /dev/null +++ b/bin/varnishtest/tests/v00051.vtc @@ -0,0 +1,87 @@ +varnishtest "Test VCL failures" + +server s1 { + rxreq + txresp +} -start + +varnish v1 -vcl+backend { + import debug; + sub vcl_recv { + if (req.http.foo == "bar") { + return(synth(748)); + } + if (req.restarts == 0) { + debug.fail(); + } + } + sub vcl_synth { + if (resp.status == 748) { + debug.fail(); + } + if (req.restarts == 0 && req.http.foo == "foo") { + return (restart); + } + } +} -start + +####################################################################### +# Fail in vcl_recv, no handling in vcl_synth + +logexpect l1 -v v1 -g raw { + expect * 1001 VCL_call "RECV" + expect 0 1001 Debug "Forced failure" + expect 0 1001 VCL_return "fail" +} -start + +client c1 { + txreq + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" +} -run + +varnish v1 -expect sc_vcl_failure == 1 + +logexpect l1 -wait + +####################################################################### +# Fail in vcl_recv, vcl_synth restarts successfully + +logexpect l1 -v v1 -g raw { + expect * 1003 VCL_call "RECV" + expect 0 1003 Debug "Forced failure" + expect 0 1003 VCL_return "fail" + expect * 1003 VCL_call "SYNTH" + expect 0 1003 VCL_return "restart" +} -start + +client c1 { + txreq -hdr "foo: foo" + rxresp + expect resp.status == 200 + expect resp.reason == "OK" +} -run + +# NB: This is correct, req->doclose = SC_VCL_FAILURE latches +varnish v1 -expect sc_vcl_failure == 2 + +logexpect l1 -wait + +####################################################################### +# Fail in vcl_synth + +logexpect l1 -v v1 -g raw { + expect * 1007 VCL_call "SYNTH" + expect * 1007 Debug "Forced failure" + expect 0 1007 VCL_return "fail" +} -start + +client c1 { + txreq -hdr "foo: bar" + expect_close +} -run + +varnish v1 -expect sc_vcl_failure == 3 + +logexpect l1 -wait diff --git a/include/tbl/sess_close.h b/include/tbl/sess_close.h index 0dcbcbc..c20e71c 100644 --- a/include/tbl/sess_close.h +++ b/include/tbl/sess_close.h @@ -46,6 +46,7 @@ SESS_CLOSE(OVERLOAD, overload, 1, "Out of some resource") SESS_CLOSE(PIPE_OVERFLOW, pipe_overflow,1, "Session pipe overflow") SESS_CLOSE(RANGE_SHORT, range_short, 1, "Insufficient data for range") SESS_CLOSE(REQ_HTTP20, req_http20, 1, "HTTP2 not accepted") +SESS_CLOSE(VCL_FAILURE, vcl_failure, 1, "VCL failure") #undef SESS_CLOSE /*lint -restore */ diff --git a/include/tbl/steps.h b/include/tbl/steps.h index 10d8f9f..ab8d742 100644 --- a/include/tbl/steps.h +++ b/include/tbl/steps.h @@ -40,6 +40,7 @@ REQ_STEP(miss, MISS, (wrk, req)) REQ_STEP(fetch, FETCH, (wrk, req)) REQ_STEP(deliver, DELIVER, (wrk, req)) + REQ_STEP(vclfail, VCLFAIL, (wrk, req)) REQ_STEP(synth, SYNTH, (wrk, req)) REQ_STEP(transmit, TRANSMIT, (wrk, req)) #undef REQ_STEP diff --git a/lib/libvcc/generate.py b/lib/libvcc/generate.py index c71fc1b..ecf4e3f 100755 --- a/lib/libvcc/generate.py +++ b/lib/libvcc/generate.py @@ -90,7 +90,7 @@ returns = ( ('recv', "C", - ('synth', 'pass', 'pipe', 'hash', 'purge', 'vcl') + ('fail', 'synth', 'pass', 'pipe', 'hash', 'purge', 'vcl') ), ('pipe', "C", @@ -122,7 +122,7 @@ returns = ( ), ('synth', "C", - ('restart', 'deliver',) + ('fail', 'restart', 'deliver',) ), ############################################################### From phk at FreeBSD.org Mon Feb 6 10:42:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 06 Feb 2017 11:42:05 +0100 Subject: [master] e5efc2c Implement failure in vcl_hash{} Message-ID: commit e5efc2c8dc0d003e5f0fa1a30b598f5949112897 Author: Poul-Henning Kamp Date: Mon Feb 6 10:41:16 2017 +0000 Implement failure in vcl_hash{} diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index b24159b..30fecde 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -752,7 +752,10 @@ cnt_recv(struct worker *wrk, struct req *req) SHA256_Init(&sha256ctx); VCL_hash_method(req->vcl, wrk, req, NULL, &sha256ctx); - assert(wrk->handling == VCL_RET_LOOKUP); + if (wrk->handling == VCL_RET_FAIL) + recv_handling = wrk->handling; + else + assert(wrk->handling == VCL_RET_LOOKUP); SHA256_Final(req->digest, &sha256ctx); switch(recv_handling) { diff --git a/bin/varnishtest/tests/v00051.vtc b/bin/varnishtest/tests/v00051.vtc index 8800896..d9303c2 100644 --- a/bin/varnishtest/tests/v00051.vtc +++ b/bin/varnishtest/tests/v00051.vtc @@ -15,6 +15,11 @@ varnish v1 -vcl+backend { debug.fail(); } } + sub vcl_hash { + if (req.http.foo == "hash") { + debug.fail(); + } + } sub vcl_synth { if (resp.status == 748) { debug.fail(); @@ -85,3 +90,24 @@ client c1 { varnish v1 -expect sc_vcl_failure == 3 logexpect l1 -wait + +####################################################################### +# Fail in vcl_hash, no handling in vcl_synth + +logexpect l1 -v v1 -g raw { + expect * 1009 VCL_call "HASH" + expect 0 1009 Debug "Forced failure" + expect 0 1009 VCL_return "fail" +} -start + +client c1 { + txreq -hdr "foo: hash" + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" +} -run + +varnish v1 -expect sc_vcl_failure == 4 + +logexpect l1 -wait + diff --git a/lib/libvcc/generate.py b/lib/libvcc/generate.py index ecf4e3f..ef77858 100755 --- a/lib/libvcc/generate.py +++ b/lib/libvcc/generate.py @@ -102,7 +102,7 @@ returns = ( ), ('hash', "C", - ('lookup',) + ('fail', 'lookup',) ), ('purge', "C", From phk at FreeBSD.org Mon Feb 6 11:56:04 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 06 Feb 2017 12:56:04 +0100 Subject: [master] 851be37 Add a canary in case of failure-failure. Message-ID: commit 851be37d2a9e956efbb246af730b0b21f550a687 Author: Poul-Henning Kamp Date: Mon Feb 6 11:25:20 2017 +0000 Add a canary in case of failure-failure. diff --git a/bin/varnishtest/tests/v00051.vtc b/bin/varnishtest/tests/v00051.vtc index d9303c2..334d919 100644 --- a/bin/varnishtest/tests/v00051.vtc +++ b/bin/varnishtest/tests/v00051.vtc @@ -13,16 +13,19 @@ varnish v1 -vcl+backend { } if (req.restarts == 0) { debug.fail(); + set req.http.not = "Should not happen"; } } sub vcl_hash { if (req.http.foo == "hash") { debug.fail(); + set req.http.not = "Should not happen"; } } sub vcl_synth { if (resp.status == 748) { debug.fail(); + set req.http.not = "Should not happen"; } if (req.restarts == 0 && req.http.foo == "foo") { return (restart); From phk at FreeBSD.org Mon Feb 6 11:56:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 06 Feb 2017 12:56:05 +0100 Subject: [master] ba54dc9 add failure handling to vcl_pipe{} Message-ID: commit ba54dc919076b1ddb85434d886ce82a6553d926b Author: Poul-Henning Kamp Date: Mon Feb 6 11:55:04 2017 +0000 add failure handling to vcl_pipe{} diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 30fecde..e50d132 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -601,6 +601,10 @@ cnt_pipe(struct worker *wrk, struct req *req) VCL_pipe_method(req->vcl, wrk, req, bo, NULL); switch (wrk->handling) { + case VCL_RET_FAIL: + req->req_step = R_STP_VCLFAIL; + nxt = REQ_FSM_MORE; + break; case VCL_RET_SYNTH: req->req_step = R_STP_SYNTH; nxt = REQ_FSM_MORE; diff --git a/bin/varnishtest/tests/v00051.vtc b/bin/varnishtest/tests/v00051.vtc index 334d919..3a04517 100644 --- a/bin/varnishtest/tests/v00051.vtc +++ b/bin/varnishtest/tests/v00051.vtc @@ -8,6 +8,9 @@ server s1 { varnish v1 -vcl+backend { import debug; sub vcl_recv { + if (req.http.foo == "pipe") { + return(pipe); + } if (req.http.foo == "bar") { return(synth(748)); } @@ -22,6 +25,12 @@ varnish v1 -vcl+backend { set req.http.not = "Should not happen"; } } + sub vcl_pipe { + if (req.http.foo == "pipe") { + debug.fail(); + set req.http.not = "Should not happen"; + } + } sub vcl_synth { if (resp.status == 748) { debug.fail(); @@ -114,3 +123,25 @@ varnish v1 -expect sc_vcl_failure == 4 logexpect l1 -wait +####################################################################### +# Fail in vcl_pipe, no handling in vcl_synth + +logexpect l1 -v v1 -g raw { + expect * 1012 VCL_call "PIPE" + expect 0 1012 Debug "Forced failure" + expect 0 1012 VCL_return "fail" +} -start + +client c1 { + txreq -hdr "foo: pipe" + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" +} -run + +delay 1 + +varnish v1 -expect sc_vcl_failure == 5 + +logexpect l1 -wait + diff --git a/lib/libvcc/generate.py b/lib/libvcc/generate.py index ef77858..14e50a1 100755 --- a/lib/libvcc/generate.py +++ b/lib/libvcc/generate.py @@ -94,7 +94,7 @@ returns = ( ), ('pipe', "C", - ('synth', 'pipe',) + ('fail', 'synth', 'pipe',) ), ('pass', "C", From phk at FreeBSD.org Mon Feb 6 21:45:06 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 06 Feb 2017 22:45:06 +0100 Subject: [master] 6f50a00 Implement fail in vcl_(miss|pass|pipe|purge){} Message-ID: commit 6f50a00f80c7f74b2a8b18bb80593f58b74816fd Author: Poul-Henning Kamp Date: Mon Feb 6 21:43:30 2017 +0000 Implement fail in vcl_(miss|pass|pipe|purge){} diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index e50d132..5463e56 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -519,6 +519,9 @@ cnt_miss(struct worker *wrk, struct req *req) (void)HSH_DerefObjCore(wrk, &req->stale_oc, 0); req->req_step = R_STP_FETCH; return (REQ_FSM_MORE); + case VCL_RET_FAIL: + req->req_step = R_STP_VCLFAIL; + break; case VCL_RET_SYNTH: req->req_step = R_STP_SYNTH; break; @@ -553,6 +556,9 @@ cnt_pass(struct worker *wrk, struct req *req) VCL_pass_method(req->vcl, wrk, req, NULL, NULL); switch (wrk->handling) { + case VCL_RET_FAIL: + req->req_step = R_STP_VCLFAIL; + break; case VCL_RET_SYNTH: req->req_step = R_STP_SYNTH; break; @@ -837,6 +843,9 @@ cnt_purge(struct worker *wrk, struct req *req) case VCL_RET_RESTART: req->req_step = R_STP_RESTART; break; + case VCL_RET_FAIL: + req->req_step = R_STP_VCLFAIL; + break; case VCL_RET_SYNTH: req->req_step = R_STP_SYNTH; break; diff --git a/bin/varnishtest/tests/v00051.vtc b/bin/varnishtest/tests/v00051.vtc index 3a04517..308ad55 100644 --- a/bin/varnishtest/tests/v00051.vtc +++ b/bin/varnishtest/tests/v00051.vtc @@ -8,9 +8,10 @@ server s1 { varnish v1 -vcl+backend { import debug; sub vcl_recv { - if (req.http.foo == "pipe") { - return(pipe); - } + if (req.http.foo == "pipe") { return(pipe); } + if (req.http.foo == "pass") { return(pass); } + if (req.http.foo == "purge") { return(purge); } + if (req.http.foo == "miss") { return(hash); } if (req.http.foo == "bar") { return(synth(748)); } @@ -25,12 +26,30 @@ varnish v1 -vcl+backend { set req.http.not = "Should not happen"; } } + sub vcl_miss { + if (req.http.foo == "miss") { + debug.fail(); + set req.http.not = "Should not happen"; + } + } sub vcl_pipe { if (req.http.foo == "pipe") { debug.fail(); set req.http.not = "Should not happen"; } } + sub vcl_pass { + if (req.http.foo == "pass") { + debug.fail(); + set req.http.not = "Should not happen"; + } + } + sub vcl_purge { + if (req.http.foo == "purge") { + debug.fail(); + set req.http.not = "Should not happen"; + } + } sub vcl_synth { if (resp.status == 748) { debug.fail(); @@ -139,9 +158,69 @@ client c1 { expect resp.reason == "VCL failed" } -run +varnish v1 -expect sc_vcl_failure == 5 + +logexpect l1 -wait + +####################################################################### +# Fail in vcl_pass, no handling in vcl_synth + +logexpect l1 -v v1 -g raw { + expect * 1014 VCL_call "PASS" + expect 0 1014 Debug "Forced failure" + expect 0 1014 VCL_return "fail" +} -start + +client c1 { + txreq -hdr "foo: pass" + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" +} -run + +varnish v1 -expect sc_vcl_failure == 6 + +logexpect l1 -wait + +####################################################################### +# Fail in vcl_purge, no handling in vcl_synth + +logexpect l1 -v v1 -g raw { + expect * 1016 VCL_call "PURGE" + expect 0 1016 Debug "Forced failure" + expect 0 1016 VCL_return "fail" +} -start + +client c1 { + txreq -hdr "foo: purge" + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" +} -run + +varnish v1 -expect sc_vcl_failure == 7 + +logexpect l1 -wait + +####################################################################### +# Fail in vcl_miss, no handling in vcl_synth + +logexpect l1 -v v1 -g raw { + expect * 1018 VCL_call "MISS" + expect 0 1018 Debug "Forced failure" + expect 0 1018 VCL_return "fail" +} -start + +client c1 { + txreq -url /x -hdr "foo: miss" + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" +} -run + delay 1 -varnish v1 -expect sc_vcl_failure == 5 +varnish v1 -expect sc_vcl_failure == 8 logexpect l1 -wait diff --git a/lib/libvcc/generate.py b/lib/libvcc/generate.py index 14e50a1..285f126 100755 --- a/lib/libvcc/generate.py +++ b/lib/libvcc/generate.py @@ -98,7 +98,7 @@ returns = ( ), ('pass', "C", - ('synth', 'restart', 'fetch',) + ('fail', 'synth', 'restart', 'fetch',) ), ('hash', "C", @@ -106,11 +106,11 @@ returns = ( ), ('purge', "C", - ('synth', 'restart',) + ('fail', 'synth', 'restart',) ), ('miss', "C", - ('synth', 'restart', 'pass', 'fetch',) + ('fail', 'synth', 'restart', 'pass', 'fetch',) ), ('hit', "C", From phk at FreeBSD.org Mon Feb 6 22:29:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 06 Feb 2017 23:29:05 +0100 Subject: [master] 1567375 Untangle the VCL per test-case Message-ID: commit 1567375b81e0bb33ff5263b5672faea376b734dd Author: Poul-Henning Kamp Date: Mon Feb 6 22:22:37 2017 +0000 Untangle the VCL per test-case diff --git a/bin/varnishtest/tests/v00051.vtc b/bin/varnishtest/tests/v00051.vtc index 308ad55..4e486dd 100644 --- a/bin/varnishtest/tests/v00051.vtc +++ b/bin/varnishtest/tests/v00051.vtc @@ -2,67 +2,27 @@ varnishtest "Test VCL failures" server s1 { rxreq + expect req.url == /hit txresp } -start varnish v1 -vcl+backend { import debug; sub vcl_recv { - if (req.http.foo == "pipe") { return(pipe); } - if (req.http.foo == "pass") { return(pass); } - if (req.http.foo == "purge") { return(purge); } - if (req.http.foo == "miss") { return(hash); } - if (req.http.foo == "bar") { - return(synth(748)); - } if (req.restarts == 0) { debug.fail(); set req.http.not = "Should not happen"; } } - sub vcl_hash { - if (req.http.foo == "hash") { - debug.fail(); - set req.http.not = "Should not happen"; - } - } - sub vcl_miss { - if (req.http.foo == "miss") { - debug.fail(); - set req.http.not = "Should not happen"; - } - } - sub vcl_pipe { - if (req.http.foo == "pipe") { - debug.fail(); - set req.http.not = "Should not happen"; - } - } - sub vcl_pass { - if (req.http.foo == "pass") { - debug.fail(); - set req.http.not = "Should not happen"; - } - } - sub vcl_purge { - if (req.http.foo == "purge") { - debug.fail(); - set req.http.not = "Should not happen"; - } - } sub vcl_synth { - if (resp.status == 748) { - debug.fail(); - set req.http.not = "Should not happen"; - } - if (req.restarts == 0 && req.http.foo == "foo") { + if (req.restarts == 0 && req.http.foo == "restart") { return (restart); } } } -start ####################################################################### -# Fail in vcl_recv, no handling in vcl_synth +# Fail in vcl_recv logexpect l1 -v v1 -g raw { expect * 1001 VCL_call "RECV" @@ -93,7 +53,7 @@ logexpect l1 -v v1 -g raw { } -start client c1 { - txreq -hdr "foo: foo" + txreq -url /hit -hdr "foo: restart" rxresp expect resp.status == 200 expect resp.reason == "OK" @@ -107,6 +67,21 @@ logexpect l1 -wait ####################################################################### # Fail in vcl_synth +varnish v1 -vcl+backend { + import debug; + sub vcl_recv { + if (req.http.foo == "synth") { + return(synth(748)); + } + } + sub vcl_synth { + if (resp.status == 748) { + debug.fail(); + set req.http.not = "Should not happen"; + } + } +} + logexpect l1 -v v1 -g raw { expect * 1007 VCL_call "SYNTH" expect * 1007 Debug "Forced failure" @@ -114,7 +89,7 @@ logexpect l1 -v v1 -g raw { } -start client c1 { - txreq -hdr "foo: bar" + txreq -hdr "foo: synth" expect_close } -run @@ -123,7 +98,17 @@ varnish v1 -expect sc_vcl_failure == 3 logexpect l1 -wait ####################################################################### -# Fail in vcl_hash, no handling in vcl_synth +# Fail in vcl_hash + +varnish v1 -vcl+backend { + import debug; + sub vcl_hash { + if (req.http.foo == "hash") { + debug.fail(); + set req.http.not = "Should not happen"; + } + } +} logexpect l1 -v v1 -g raw { expect * 1009 VCL_call "HASH" @@ -143,7 +128,21 @@ varnish v1 -expect sc_vcl_failure == 4 logexpect l1 -wait ####################################################################### -# Fail in vcl_pipe, no handling in vcl_synth +# Fail in vcl_pipe + +varnish v1 -vcl+backend { + import debug; + sub vcl_recv { + if (req.http.foo == "pipe") { return(pipe); } + } + sub vcl_pipe { + if (req.http.foo == "pipe") { + debug.fail(); + set req.http.not = "Should not happen"; + } + } +} + logexpect l1 -v v1 -g raw { expect * 1012 VCL_call "PIPE" @@ -165,6 +164,19 @@ logexpect l1 -wait ####################################################################### # Fail in vcl_pass, no handling in vcl_synth +varnish v1 -vcl+backend { + import debug; + sub vcl_recv { + if (req.http.foo == "pass") { return(pass); } + } + sub vcl_pass { + if (req.http.foo == "pass") { + debug.fail(); + set req.http.not = "Should not happen"; + } + } +} + logexpect l1 -v v1 -g raw { expect * 1014 VCL_call "PASS" expect 0 1014 Debug "Forced failure" @@ -183,7 +195,20 @@ varnish v1 -expect sc_vcl_failure == 6 logexpect l1 -wait ####################################################################### -# Fail in vcl_purge, no handling in vcl_synth +# Fail in vcl_purge + +varnish v1 -vcl+backend { + import debug; + sub vcl_recv { + if (req.http.foo == "purge") { return(purge); } + } + sub vcl_purge { + if (req.http.foo == "purge") { + debug.fail(); + set req.http.not = "Should not happen"; + } + } +} logexpect l1 -v v1 -g raw { expect * 1016 VCL_call "PURGE" @@ -203,7 +228,20 @@ varnish v1 -expect sc_vcl_failure == 7 logexpect l1 -wait ####################################################################### -# Fail in vcl_miss, no handling in vcl_synth +# Fail in vcl_miss + +varnish v1 -vcl+backend { + import debug; + sub vcl_recv { + if (req.http.foo == "miss") { return(hash); } + } + sub vcl_miss { + if (req.http.foo == "miss") { + debug.fail(); + set req.http.not = "Should not happen"; + } + } +} logexpect l1 -v v1 -g raw { expect * 1018 VCL_call "MISS" @@ -218,8 +256,6 @@ client c1 { expect resp.reason == "VCL failed" } -run -delay 1 - varnish v1 -expect sc_vcl_failure == 8 logexpect l1 -wait From phk at FreeBSD.org Mon Feb 6 22:29:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 06 Feb 2017 23:29:05 +0100 Subject: [master] b881699 Implement fail in vcl_hit{} and vcl_deliver{} Message-ID: commit b8816994cfab58261d8000ea8e6941cb5de640fa Author: Poul-Henning Kamp Date: Mon Feb 6 22:27:43 2017 +0000 Implement fail in vcl_hit{} and vcl_deliver{} diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 5463e56..0f6f88e 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -117,6 +117,9 @@ cnt_deliver(struct worker *wrk, struct req *req) case VCL_RET_RESTART: req->req_step = R_STP_RESTART; break; + case VCL_RET_FAIL: + req->req_step = R_STP_VCLFAIL; + break; case VCL_RET_SYNTH: req->req_step = R_STP_SYNTH; break; @@ -474,6 +477,9 @@ cnt_lookup(struct worker *wrk, struct req *req) case VCL_RET_RESTART: req->req_step = R_STP_RESTART; break; + case VCL_RET_FAIL: + req->req_step = R_STP_VCLFAIL; + break; case VCL_RET_SYNTH: req->req_step = R_STP_SYNTH; break; diff --git a/bin/varnishtest/tests/v00051.vtc b/bin/varnishtest/tests/v00051.vtc index 4e486dd..8a36d61 100644 --- a/bin/varnishtest/tests/v00051.vtc +++ b/bin/varnishtest/tests/v00051.vtc @@ -232,9 +232,6 @@ logexpect l1 -wait varnish v1 -vcl+backend { import debug; - sub vcl_recv { - if (req.http.foo == "miss") { return(hash); } - } sub vcl_miss { if (req.http.foo == "miss") { debug.fail(); @@ -250,7 +247,7 @@ logexpect l1 -v v1 -g raw { } -start client c1 { - txreq -url /x -hdr "foo: miss" + txreq -url /miss -hdr "foo: miss" rxresp expect resp.status == 503 expect resp.reason == "VCL failed" @@ -260,3 +257,63 @@ varnish v1 -expect sc_vcl_failure == 8 logexpect l1 -wait +####################################################################### +# Fail in vcl_hit + +varnish v1 -vcl+backend { + import debug; + sub vcl_hit { + if (req.http.foo == "hit") { + debug.fail(); + set req.http.not = "Should not happen"; + } + } +} + +logexpect l1 -v v1 -g raw { + expect * 1020 VCL_call "HIT" + expect 0 1020 Debug "Forced failure" + expect 0 1020 VCL_return "fail" +} -start + +client c1 { + txreq -url /hit -hdr "foo: hit" + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" +} -run + +varnish v1 -expect sc_vcl_failure == 9 + +logexpect l1 -wait + +####################################################################### +# Fail in vcl_deliver + +varnish v1 -vcl+backend { + import debug; + sub vcl_deliver { + if (req.http.foo == "deliver") { + debug.fail(); + set req.http.not = "Should not happen"; + } + } +} + +logexpect l1 -v v1 -g raw { + expect * 1022 VCL_call "DELIVER" + expect 0 1022 Debug "Forced failure" + expect 0 1022 VCL_return "fail" +} -start + +client c1 { + txreq -url /hit -hdr "foo: deliver" + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" +} -run + +varnish v1 -expect sc_vcl_failure == 10 + +logexpect l1 -wait + diff --git a/lib/libvcc/generate.py b/lib/libvcc/generate.py index 285f126..7dcafc3 100755 --- a/lib/libvcc/generate.py +++ b/lib/libvcc/generate.py @@ -114,11 +114,11 @@ returns = ( ), ('hit', "C", - ('synth', 'restart', 'pass', 'miss', 'deliver',) + ('fail', 'synth', 'restart', 'pass', 'miss', 'deliver',) ), ('deliver', "C", - ('synth', 'restart', 'deliver',) + ('fail', 'synth', 'restart', 'deliver',) ), ('synth', "C", From phk at FreeBSD.org Mon Feb 6 23:24:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 07 Feb 2017 00:24:05 +0100 Subject: [master] 365c745 Add failure handing in vcl_backend_*{}. Message-ID: commit 365c745f0f216c5b9da613ee3f1f0c93bf501953 Author: Poul-Henning Kamp Date: Mon Feb 6 23:22:46 2017 +0000 Add failure handing in vcl_backend_*{}. Add a new global counter 'vcl_fail' which counts all VCL_RET_FAIL. diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 05ad0bf..9433bcf 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -280,7 +280,7 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo) VCL_backend_fetch_method(bo->vcl, wrk, NULL, bo, NULL); bo->uncacheable = bo->do_pass; - if (wrk->handling == VCL_RET_ABANDON) + if (wrk->handling == VCL_RET_ABANDON || wrk->handling == VCL_RET_FAIL) return (F_STP_FAIL); assert (wrk->handling == VCL_RET_FETCH); @@ -442,7 +442,7 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo) VCL_backend_response_method(bo->vcl, wrk, NULL, bo, NULL); - if (wrk->handling == VCL_RET_ABANDON) { + if (wrk->handling == VCL_RET_ABANDON || wrk->handling == VCL_RET_FAIL) { bo->htc->doclose = SC_RESP_CLOSE; VDI_Finish(bo->wrk, bo); return (F_STP_FAIL); @@ -859,7 +859,7 @@ vbf_stp_error(struct worker *wrk, struct busyobj *bo) AZ(VSB_finish(synth_body)); - if (wrk->handling == VCL_RET_ABANDON) { + if (wrk->handling == VCL_RET_ABANDON || wrk->handling == VCL_RET_FAIL) { VSB_destroy(&synth_body); return (F_STP_FAIL); } diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c index 967c563..b950a96 100644 --- a/bin/varnishd/cache/cache_vcl.c +++ b/bin/varnishd/cache/cache_vcl.c @@ -1057,6 +1057,8 @@ vcl_call_method(struct worker *wrk, struct req *req, struct busyobj *bo, func(&ctx); VSLb(vsl, SLT_VCL_return, "%s", VCL_Return_Name(wrk->handling)); wrk->cur_method |= 1; // Magic marker + if (wrk->handling == VCL_RET_FAIL) + wrk->stats->vcl_fail++; /* * VCL/Vmods are not allowed to make permanent allocations from diff --git a/bin/varnishtest/tests/v00051.vtc b/bin/varnishtest/tests/v00051.vtc index 8a36d61..56eee1e 100644 --- a/bin/varnishtest/tests/v00051.vtc +++ b/bin/varnishtest/tests/v00051.vtc @@ -37,6 +37,7 @@ client c1 { expect resp.reason == "VCL failed" } -run +varnish v1 -expect vcl_fail == 1 varnish v1 -expect sc_vcl_failure == 1 logexpect l1 -wait @@ -59,6 +60,7 @@ client c1 { expect resp.reason == "OK" } -run +varnish v1 -expect vcl_fail == 2 # NB: This is correct, req->doclose = SC_VCL_FAILURE latches varnish v1 -expect sc_vcl_failure == 2 @@ -93,6 +95,7 @@ client c1 { expect_close } -run +varnish v1 -expect vcl_fail == 3 varnish v1 -expect sc_vcl_failure == 3 logexpect l1 -wait @@ -123,6 +126,7 @@ client c1 { expect resp.reason == "VCL failed" } -run +varnish v1 -expect vcl_fail == 4 varnish v1 -expect sc_vcl_failure == 4 logexpect l1 -wait @@ -157,6 +161,7 @@ client c1 { expect resp.reason == "VCL failed" } -run +varnish v1 -expect vcl_fail == 5 varnish v1 -expect sc_vcl_failure == 5 logexpect l1 -wait @@ -190,6 +195,7 @@ client c1 { expect resp.reason == "VCL failed" } -run +varnish v1 -expect vcl_fail == 6 varnish v1 -expect sc_vcl_failure == 6 logexpect l1 -wait @@ -223,6 +229,7 @@ client c1 { expect resp.reason == "VCL failed" } -run +varnish v1 -expect vcl_fail == 7 varnish v1 -expect sc_vcl_failure == 7 logexpect l1 -wait @@ -253,6 +260,7 @@ client c1 { expect resp.reason == "VCL failed" } -run +varnish v1 -expect vcl_fail == 8 varnish v1 -expect sc_vcl_failure == 8 logexpect l1 -wait @@ -283,6 +291,7 @@ client c1 { expect resp.reason == "VCL failed" } -run +varnish v1 -expect vcl_fail == 9 varnish v1 -expect sc_vcl_failure == 9 logexpect l1 -wait @@ -313,6 +322,105 @@ client c1 { expect resp.reason == "VCL failed" } -run +varnish v1 -expect vcl_fail == 10 +varnish v1 -expect sc_vcl_failure == 10 + +logexpect l1 -wait + +####################################################################### +# Fail in vcl_backend_fetch + +varnish v1 -vcl+backend { + import debug; + sub vcl_backend_fetch { + debug.fail(); + set bereq.http.not = "Should not happen"; + } +} + +logexpect l1 -v v1 -g raw { + expect * 1025 VCL_call "BACKEND_FETCH" + expect 0 1025 Debug "Forced failure" + expect 0 1025 VCL_return "fail" +} -start + +client c1 { + txreq -url /backend_fetch + rxresp + expect resp.status == 503 + expect resp.reason == "Service Unavailable" +} -run + +varnish v1 -expect vcl_fail == 11 +varnish v1 -expect sc_vcl_failure == 10 + +logexpect l1 -wait + +####################################################################### +# Fail in vcl_backend_error + +server s1 { + rxreq + expect req.url == /backend_error +} -start + +varnish v1 -vcl+backend { + import debug; + sub vcl_backend_error { + debug.fail(); + set bereq.http.not = "Should not happen"; + } +} + +logexpect l1 -v v1 -g raw { + expect * 1028 VCL_call "BACKEND_ERROR" + expect 0 1028 Debug "Forced failure" + expect 0 1028 VCL_return "fail" +} -start + +client c1 { + txreq -url /backend_error + rxresp + expect resp.status == 503 + expect resp.reason == "Service Unavailable" +} -run + +varnish v1 -expect vcl_fail == 12 +varnish v1 -expect sc_vcl_failure == 10 + +logexpect l1 -wait + +####################################################################### +# Fail in vcl_backend_response + +server s1 { + rxreq + expect req.url == /backend_response + txresp +} -start + +varnish v1 -vcl+backend { + import debug; + sub vcl_backend_response { + debug.fail(); + set bereq.http.not = "Should not happen"; + } +} + +logexpect l1 -v v1 -g raw { + expect * 1031 VCL_call "BACKEND_RESPONSE" + expect 0 1031 Debug "Forced failure" + expect 0 1031 VCL_return "fail" +} -start + +client c1 { + txreq -url /backend_response + rxresp + expect resp.status == 503 + expect resp.reason == "Service Unavailable" +} -run + +varnish v1 -expect vcl_fail == 13 varnish v1 -expect sc_vcl_failure == 10 logexpect l1 -wait diff --git a/include/tbl/vsc_f_main.h b/include/tbl/vsc_f_main.h index 97e25ef..c81d858 100644 --- a/include/tbl/vsc_f_main.h +++ b/include/tbl/vsc_f_main.h @@ -495,6 +495,11 @@ VSC_FF(n_vcl_discard, uint64_t, 0, 'c', 'i', diag, "" ) +VSC_FF(vcl_fail, uint64_t, 1, 'c', 'i', info, + "VCL failures", + "Count of failures which prevented VCL from completing." +) + /*--------------------------------------------------------------------*/ VSC_FF(bans, uint64_t, 0, 'g', 'i', info, diff --git a/lib/libvcc/generate.py b/lib/libvcc/generate.py index 7dcafc3..a9ff86b 100755 --- a/lib/libvcc/generate.py +++ b/lib/libvcc/generate.py @@ -130,15 +130,15 @@ returns = ( ('backend_fetch', "B", - ('fetch', 'abandon') + ('fail', 'fetch', 'abandon') ), ('backend_response', "B", - ('deliver', 'retry', 'abandon') + ('fail', 'deliver', 'retry', 'abandon') ), ('backend_error', "B", - ('deliver', 'retry', 'abandon') + ('fail', 'deliver', 'retry', 'abandon') ), ############################################################### From phk at FreeBSD.org Tue Feb 7 10:14:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 07 Feb 2017 11:14:05 +0100 Subject: [master] 81bc4ce Make sure we always see vdef.h before vrt.h Message-ID: commit 81bc4cef2a5e651a9e34ae5400672a88663db7ef Author: Poul-Henning Kamp Date: Tue Feb 7 09:44:30 2017 +0000 Make sure we always see vdef.h before vrt.h diff --git a/lib/libvarnish/vsa.c b/lib/libvarnish/vsa.c index 299deb7..3909e81 100644 --- a/lib/libvarnish/vsa.c +++ b/lib/libvarnish/vsa.c @@ -38,10 +38,10 @@ #include #include +#include "vdef.h" #include "vas.h" #include "vsa.h" #include "vrt.h" -#include "vdef.h" #include "miniobj.h" /* diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py index a6db988..a9e09ae 100755 --- a/lib/libvcc/vmodtool.py +++ b/lib/libvcc/vmodtool.py @@ -785,7 +785,7 @@ class vcc(object): fn2 = fn + ".tmp2" - for i in ["config", "vcl", "vrt", self.pfx, "vmod_abi"]: + for i in ["config", "vdef", "vcl", "vrt", self.pfx, "vmod_abi"]: fo.write('#include "%s.h"\n' % i) fo.write("\n") diff --git a/lib/libvmod_debug/vmod_debug_dyn.c b/lib/libvmod_debug/vmod_debug_dyn.c index b2d87f6..eecfb7f 100644 --- a/lib/libvmod_debug/vmod_debug_dyn.c +++ b/lib/libvmod_debug/vmod_debug_dyn.c @@ -31,10 +31,11 @@ #include #include +#include "cache/cache.h" + #include "vcl.h" #include "vrt.h" -#include "cache/cache.h" #include "cache/cache_director.h" #include "cache/cache_backend.h" diff --git a/lib/libvmod_std/vmod_std.c b/lib/libvmod_std/vmod_std.c index 5b458d3..94baed2 100644 --- a/lib/libvmod_std/vmod_std.c +++ b/lib/libvmod_std/vmod_std.c @@ -34,13 +34,14 @@ #include #include +#include "cache/cache.h" + #include "vrnd.h" #include "vrt.h" #include "vtcp.h" #include "vsa.h" #include "vtim.h" -#include "cache/cache.h" #include "cache/cache_director.h" #include "vcc_if.h" diff --git a/lib/libvmod_std/vmod_std_querysort.c b/lib/libvmod_std/vmod_std_querysort.c index 6f6a90b..024b42d 100644 --- a/lib/libvmod_std/vmod_std_querysort.c +++ b/lib/libvmod_std/vmod_std_querysort.c @@ -30,10 +30,10 @@ #include -#include "vrt.h" - #include "cache/cache.h" +#include "vrt.h" + #include "vcc_if.h" static int From phk at FreeBSD.org Tue Feb 7 10:14:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 07 Feb 2017 11:14:05 +0100 Subject: [master] 25c9e9b Pull in to maximize chance of finding platform __printflike() Message-ID: commit 25c9e9b4d9fb0a7763c77af97830b01e82d28f96 Author: Poul-Henning Kamp Date: Tue Feb 7 10:01:59 2017 +0000 Pull in to maximize chance of finding platform __printflike() diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py index a9e09ae..477486e 100755 --- a/lib/libvcc/vmodtool.py +++ b/lib/libvcc/vmodtool.py @@ -785,6 +785,7 @@ class vcc(object): fn2 = fn + ".tmp2" + fo.write('#include \n') for i in ["config", "vdef", "vcl", "vrt", self.pfx, "vmod_abi"]: fo.write('#include "%s.h"\n' % i) From phk at FreeBSD.org Tue Feb 7 10:14:06 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 07 Feb 2017 11:14:06 +0100 Subject: [master] ebfcb92 Introduce VRT_fail() which fails VCL processing with a single-line message which either goes into CLI (vcl_init{}) or VSL (all others). Message-ID: commit ebfcb92b8d3054967fbf3c615e0c37153057b654 Author: Poul-Henning Kamp Date: Tue Feb 7 10:11:55 2017 +0000 Introduce VRT_fail() which fails VCL processing with a single-line message which either goes into CLI (vcl_init{}) or VSL (all others). diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c index 55d759f..d865891 100644 --- a/bin/varnishd/cache/cache_vrt.c +++ b/bin/varnishd/cache/cache_vrt.c @@ -258,6 +258,26 @@ VRT_handling(VRT_CTX, unsigned hand) *ctx->handling = hand; } +/*--------------------------------------------------------------------*/ + +void +VRT_fail(VRT_CTX, const char *fmt, ...) +{ + va_list ap; + + assert(ctx->vsl != NULL || ctx->msg != NULL); + AZ(strchr(fmt, '\n')); + va_start(ap, fmt); + if (ctx->vsl != NULL) + VSLbv(ctx->vsl, SLT_VCL_Error, fmt, ap); + else { + VSB_vprintf(ctx->msg, fmt, ap); + VSB_putc(ctx->msg, '\n'); + } + va_end(ap); + VRT_handling(ctx, VCL_RET_FAIL); +} + /*-------------------------------------------------------------------- * Feed data into the hash calculation */ diff --git a/bin/varnishtest/tests/v00051.vtc b/bin/varnishtest/tests/v00051.vtc index 56eee1e..664af71 100644 --- a/bin/varnishtest/tests/v00051.vtc +++ b/bin/varnishtest/tests/v00051.vtc @@ -26,7 +26,7 @@ varnish v1 -vcl+backend { logexpect l1 -v v1 -g raw { expect * 1001 VCL_call "RECV" - expect 0 1001 Debug "Forced failure" + expect 0 1001 VCL_Error "Forced failure" expect 0 1001 VCL_return "fail" } -start @@ -47,7 +47,7 @@ logexpect l1 -wait logexpect l1 -v v1 -g raw { expect * 1003 VCL_call "RECV" - expect 0 1003 Debug "Forced failure" + expect 0 1003 VCL_Error "Forced failure" expect 0 1003 VCL_return "fail" expect * 1003 VCL_call "SYNTH" expect 0 1003 VCL_return "restart" @@ -86,7 +86,7 @@ varnish v1 -vcl+backend { logexpect l1 -v v1 -g raw { expect * 1007 VCL_call "SYNTH" - expect * 1007 Debug "Forced failure" + expect * 1007 VCL_Error "Forced failure" expect 0 1007 VCL_return "fail" } -start @@ -115,7 +115,7 @@ varnish v1 -vcl+backend { logexpect l1 -v v1 -g raw { expect * 1009 VCL_call "HASH" - expect 0 1009 Debug "Forced failure" + expect 0 1009 VCL_Error "Forced failure" expect 0 1009 VCL_return "fail" } -start @@ -150,7 +150,7 @@ varnish v1 -vcl+backend { logexpect l1 -v v1 -g raw { expect * 1012 VCL_call "PIPE" - expect 0 1012 Debug "Forced failure" + expect 0 1012 VCL_Error "Forced failure" expect 0 1012 VCL_return "fail" } -start @@ -184,7 +184,7 @@ varnish v1 -vcl+backend { logexpect l1 -v v1 -g raw { expect * 1014 VCL_call "PASS" - expect 0 1014 Debug "Forced failure" + expect 0 1014 VCL_Error "Forced failure" expect 0 1014 VCL_return "fail" } -start @@ -218,7 +218,7 @@ varnish v1 -vcl+backend { logexpect l1 -v v1 -g raw { expect * 1016 VCL_call "PURGE" - expect 0 1016 Debug "Forced failure" + expect 0 1016 VCL_Error "Forced failure" expect 0 1016 VCL_return "fail" } -start @@ -249,7 +249,7 @@ varnish v1 -vcl+backend { logexpect l1 -v v1 -g raw { expect * 1018 VCL_call "MISS" - expect 0 1018 Debug "Forced failure" + expect 0 1018 VCL_Error "Forced failure" expect 0 1018 VCL_return "fail" } -start @@ -280,7 +280,7 @@ varnish v1 -vcl+backend { logexpect l1 -v v1 -g raw { expect * 1020 VCL_call "HIT" - expect 0 1020 Debug "Forced failure" + expect 0 1020 VCL_Error "Forced failure" expect 0 1020 VCL_return "fail" } -start @@ -311,7 +311,7 @@ varnish v1 -vcl+backend { logexpect l1 -v v1 -g raw { expect * 1022 VCL_call "DELIVER" - expect 0 1022 Debug "Forced failure" + expect 0 1022 VCL_Error "Forced failure" expect 0 1022 VCL_return "fail" } -start @@ -340,7 +340,7 @@ varnish v1 -vcl+backend { logexpect l1 -v v1 -g raw { expect * 1025 VCL_call "BACKEND_FETCH" - expect 0 1025 Debug "Forced failure" + expect 0 1025 VCL_Error "Forced failure" expect 0 1025 VCL_return "fail" } -start @@ -374,7 +374,7 @@ varnish v1 -vcl+backend { logexpect l1 -v v1 -g raw { expect * 1028 VCL_call "BACKEND_ERROR" - expect 0 1028 Debug "Forced failure" + expect 0 1028 VCL_Error "Forced failure" expect 0 1028 VCL_return "fail" } -start @@ -409,7 +409,7 @@ varnish v1 -vcl+backend { logexpect l1 -v v1 -g raw { expect * 1031 VCL_call "BACKEND_RESPONSE" - expect 0 1031 Debug "Forced failure" + expect 0 1031 VCL_Error "Forced failure" expect 0 1031 VCL_return "fail" } -start diff --git a/include/vrt.h b/include/vrt.h index b6915d7..d3aee0b 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -293,6 +293,7 @@ struct http *VRT_selecthttp(VRT_CTX, enum gethdr_e); const char *VRT_GetHdr(VRT_CTX, const struct gethdr_s *); void VRT_SetHdr(VRT_CTX, const struct gethdr_s *, const char *, ...); void VRT_handling(VRT_CTX, unsigned hand); +void VRT_fail(VRT_CTX, const char *fmt, ...) __v_printflike(2,3); void VRT_hashdata(VRT_CTX, const char *str, ...); diff --git a/lib/libvmod_debug/vmod_debug.c b/lib/libvmod_debug/vmod_debug.c index 8e857fd..8cae9f3 100644 --- a/lib/libvmod_debug/vmod_debug.c +++ b/lib/libvmod_debug/vmod_debug.c @@ -256,11 +256,7 @@ VCL_VOID __match_proto__() vmod_fail(VRT_CTX) { - if(ctx->msg != NULL) - VSB_printf(ctx->msg, "Forced failure"); - else if (ctx->vsl != NULL) - VSLb(ctx->vsl, SLT_Debug, "Forced failure"); - VRT_handling(ctx, VCL_RET_FAIL); + VRT_fail(ctx, "Forced failure"); } static void __match_proto__(vmod_priv_free_f) From phk at FreeBSD.org Tue Feb 7 10:24:04 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 07 Feb 2017 11:24:04 +0100 Subject: [master] e9e1373 Fail VCL if attempts are made to set any of the top-line fields (url, proto, reason, status etc.) to an empty string. Message-ID: commit e9e1373b66164f1fecb2ff20c7242381854d0c54 Author: Poul-Henning Kamp Date: Tue Feb 7 10:22:41 2017 +0000 Fail VCL if attempts are made to set any of the top-line fields (url, proto, reason, status etc.) to an empty string. Fixes #1856 diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index 34be2a2..d731f6e 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -45,7 +45,7 @@ static char vrt_hostname[255] = ""; */ static void -vrt_do_string(const struct http *hp, int fld, +vrt_do_string(VRT_CTX, const struct http *hp, int fld, const char *err, const char *p, va_list ap) { const char *b; @@ -53,11 +53,15 @@ vrt_do_string(const struct http *hp, int fld, CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC); b = VRT_String(hp->ws, NULL, p, ap); - if (b == NULL || *b == '\0') { - VSLb(hp->vsl, SLT_LostHeader, "%s", err); + if (b == NULL) { + VRT_fail(ctx, "Workspace overflow (%s)", err); WS_MarkOverflow(hp->ws); return; } + if (*b == '\0') { + VRT_fail(ctx, "Setting %s to empty string", err); + return; + } http_SetH(hp, fld, b); } @@ -69,7 +73,7 @@ VRT_l_##obj##_##hdr(VRT_CTX, const char *p, ...) \ \ CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); \ va_start(ap, p); \ - vrt_do_string(ctx->http_##obj, fld, #obj "." #hdr, p, ap); \ + vrt_do_string(ctx, ctx->http_##obj, fld, #obj "." #hdr, p, ap); \ va_end(ap); \ } diff --git a/bin/varnishtest/tests/r01856.vtc b/bin/varnishtest/tests/r01856.vtc new file mode 100644 index 0000000..d6cdd17 --- /dev/null +++ b/bin/varnishtest/tests/r01856.vtc @@ -0,0 +1,24 @@ +varnishtest "setting empty strings in line1 fields" + +server s1 { + rxreq + txresp +} -start + +varnish v1 -vcl+backend { + sub vcl_recv { + set req.url = ""; + } +} -start + +logexpect l1 -v v1 -g raw { + expect * 1001 VCL_Error "Setting req.url to empty string" +} -start + +client c1 { + txreq + rxresp + expect resp.reason == "VCL failed" +} -run + +logexpect l1 -wait From phk at FreeBSD.org Tue Feb 7 11:06:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 07 Feb 2017 12:06:05 +0100 Subject: [master] 23705c4 Use VRT_fail in case silly HTTP status numbers are set, and test that. Message-ID: commit 23705c43713e7cff1d87e28702ed92a56650f6bb Author: Poul-Henning Kamp Date: Tue Feb 7 11:04:51 2017 +0000 Use VRT_fail in case silly HTTP status numbers are set, and test that. diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index d731f6e..a603ecc 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -97,17 +97,14 @@ VRT_l_##obj##_status(VRT_CTX, long num) \ \ CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); \ CHECK_OBJ_NOTNULL(ctx->http_##obj, HTTP_MAGIC); \ - if (num > 65535) { \ - VSLb(ctx->vsl, SLT_VCL_Error, \ - "%s.status > 65535", #obj); \ - WS_MarkOverflow(ctx->http_##obj->ws); \ - } else if ((num % 1000) < 100) { \ - VSLb(ctx->vsl, SLT_VCL_Error, \ - "illegal %s.status (..0##)", #obj); \ - WS_MarkOverflow(ctx->http_##obj->ws); \ - } else { \ + if (num < 0) \ + VRT_fail(ctx, "%s.status (%ld) is negative", #obj, num); \ + else if (num > 65535) \ + VRT_fail(ctx, "%s.status (%ld) > 65535", #obj, num); \ + else if ((num % 1000) < 100) \ + VRT_fail(ctx, "illegal %s.status (%ld) (..0##)", #obj, num); \ + else \ http_SetStatus(ctx->http_##obj, (uint16_t)num); \ - } \ } #define VRT_STATUS_R(obj) \ diff --git a/bin/varnishtest/tests/v00050.vtc b/bin/varnishtest/tests/v00050.vtc index c880c7b..f4ab7ac 100644 --- a/bin/varnishtest/tests/v00050.vtc +++ b/bin/varnishtest/tests/v00050.vtc @@ -91,6 +91,15 @@ varnish v1 -vcl+backend { return (synth(400)); } } + if (req.http.huge == "yes") { + set resp.status = 65536; + } + if (req.http.small == "yes") { + set resp.status = 99; + } + if (req.http.negative == "yes") { + set resp.status = -200; + } } sub vcl_recv { @@ -100,6 +109,9 @@ varnish v1 -vcl+backend { } sub vcl_synth { + if (resp.reason == "VCL failed") { + return (deliver); + } std.log("synth " + resp.status + " " + resp.reason); if (resp.status != 22301) { set resp.status = 501; @@ -148,10 +160,35 @@ client c1 { rxresp expect resp.status == 302 expect resp.reason == "Wrong Postcode" -} +} -run + +logexpect l1 -v v1 { + expect * * VCL_Error "illegal resp.status .99. ...0##." + expect * * VCL_Error "resp.status .65536. > 65535" + expect * * VCL_Error "resp.status .-200. is negative" +} -start -client c1 -run +client c1 { + txreq -url "/a" -hdr "Small: yes" + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" + + expect_close +} -run + +client c1 { + txreq -url "/a" -hdr "Huge: yes" + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" +} -run -server s1 -wait +client c1 { + txreq -url "/a" -hdr "Negative: yes" + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" +} -run -varnish v1 -stop +logexpect l1 -wait From fgsch at lodoss.net Wed Feb 8 05:09:05 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Wed, 08 Feb 2017 06:09:05 +0100 Subject: [master] a7ceb25 Support IP + STRING Message-ID: commit a7ceb252895274b8640e731f22d5073132bfd178 Author: Federico G. Schwindt Date: Wed Feb 8 05:03:04 2017 +0000 Support IP + STRING Fixes #2205. diff --git a/bin/varnishtest/tests/v00020.vtc b/bin/varnishtest/tests/v00020.vtc index 352809f..7100e11 100644 --- a/bin/varnishtest/tests/v00020.vtc +++ b/bin/varnishtest/tests/v00020.vtc @@ -108,6 +108,10 @@ varnish v1 -vcl { set req.http.foo = req.http.foo + "bar" ~ "bar"; set req.http.foo = req.http.foo + "bar" !~ "bar"; + set req.http.foo = "foo" + req.ttl; + + set req.http.foo = client.ip + ", " + server.ip; + set req.ttl = 1s; set req.ttl *= 1.5; set req.ttl = 1.5 s * 2.5; @@ -141,9 +145,6 @@ varnish v1 -vcl { else if (4) { } else { } } - sub vcl_backend_response { - set beresp.http.buzz = "ttl=" + beresp.ttl; - } } # XXX: not the most clear error message @@ -238,6 +239,13 @@ varnish v1 -errvcl {DURATION + STRING not possible.} { } } +varnish v1 -errvcl {IP + IP not possible.} { + backend b { .host = "127.0.0.1"; } + sub vcl_recv { + set req.ttl = client.ip + server.ip; + } +} + varnish v1 -errvcl {Name of function, 'foo-bar', contains illegal character '-'} { backend b { .host = "127.0.0.1"; } sub foo-bar { diff --git a/lib/libvcc/vcc_expr.c b/lib/libvcc/vcc_expr.c index 680ebd6..729873b 100644 --- a/lib/libvcc/vcc_expr.c +++ b/lib/libvcc/vcc_expr.c @@ -1019,14 +1019,15 @@ static const struct adds { { '-', INT, REAL, REAL }, /* Error */ - { '+', TIME, INT, VOID }, - { '+', TIME, REAL, VOID }, - { '+', INT, DURATION, VOID }, - { '+', REAL, DURATION, VOID }, { '+', DURATION, INT, VOID }, { '+', DURATION, REAL, VOID }, { '+', DURATION, TIME, VOID }, { '+', DURATION, STRING, VOID }, + { '+', INT, DURATION, VOID }, + { '+', IP, IP, VOID }, + { '+', REAL, DURATION, VOID }, + { '+', TIME, INT, VOID }, + { '+', TIME, REAL, VOID }, { EOI, VOID, VOID, VOID } }; @@ -1050,6 +1051,8 @@ vcc_expr_add(struct vcc *tl, struct expr **e, vcc_type_t fmt) vcc_NextToken(tl); if (f2 == TIME) vcc_expr_mul(tl, &e2, DURATION); + else if (f2 == IP) + vcc_expr_mul(tl, &e2, STRING); else vcc_expr_mul(tl, &e2, f2); ERRCHK(tl); From phk at phk.freebsd.dk Wed Feb 8 07:24:10 2017 From: phk at phk.freebsd.dk (Poul-Henning Kamp) Date: Wed, 08 Feb 2017 07:24:10 +0000 Subject: [master] a7ceb25 Support IP + STRING In-Reply-To: References: Message-ID: <15304.1486538650@critter.freebsd.dk> -------- In message , Federico G. Schwin dt writes: >commit a7ceb252895274b8640e731f22d5073132bfd178 >Author: Federico G. Schwindt >Date: Wed Feb 8 05:03:04 2017 +0000 > > Support IP + STRING > >+ { '+', IP, IP, VOID }, This looks very wrong to me. -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk at FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence. From phk at FreeBSD.org Wed Feb 8 09:02:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 08 Feb 2017 10:02:05 +0100 Subject: [master] d25ce0b Rather than add to a never ending list of things we cannot add/subtract, examine the list of things we can handle, and if not, and we are looking for strings anyway, convert to string right away. Message-ID: commit d25ce0b57ae73e8163e8c3376e91996242a135dd Author: Poul-Henning Kamp Date: Wed Feb 8 09:00:15 2017 +0000 Rather than add to a never ending list of things we cannot add/subtract, examine the list of things we can handle, and if not, and we are looking for strings anyway, convert to string right away. Really fixes #2205 diff --git a/bin/varnishtest/tests/v00020.vtc b/bin/varnishtest/tests/v00020.vtc index 7100e11..5f734fc 100644 --- a/bin/varnishtest/tests/v00020.vtc +++ b/bin/varnishtest/tests/v00020.vtc @@ -77,6 +77,7 @@ varnish v1 -vcl { set req.http.foo = now - 1s; set req.http.foo = now - now; + set req.http.foo = 1 + 1s; set req.http.foo = 1 + 1; set req.http.foo = 1 - 1; @@ -169,13 +170,6 @@ varnish v1 -errvcl {TIME + TIME not possible.} { } } -varnish v1 -errvcl {TIME + INT not possible.} { - backend b { .host = "127.0.0.1"; } - sub vcl_recv { - set req.http.foo = now + 1; - } -} - varnish v1 -errvcl {INT + STRING not possible.} { backend b { .host = "127.0.0.1"; } sub vcl_backend_response { @@ -190,34 +184,6 @@ varnish v1 -errvcl {INT + TIME not possible.} { } } -varnish v1 -errvcl {INT + DURATION not possible.} { - backend b { .host = "127.0.0.1"; } - sub vcl_recv { - set req.http.foo = 1 + 1s; - } -} - -varnish v1 -errvcl {DURATION + INT not possible.} { - backend b { .host = "127.0.0.1"; } - sub vcl_recv { - set req.http.foo = 1s + 1; - } -} - -varnish v1 -errvcl {DURATION + TIME not possible.} { - backend b { .host = "127.0.0.1"; } - sub vcl_recv { - set req.http.foo = 1s + now; - } -} - -varnish v1 -errvcl {DURATION + STRING not possible.} { - backend b { .host = "127.0.0.1"; } - sub vcl_recv { - set req.http.foo = 1s + "foo"; - } -} - varnish v1 -errvcl {DURATION + INT not possible.} { backend b { .host = "127.0.0.1"; } sub vcl_recv { diff --git a/lib/libvcc/vcc_expr.c b/lib/libvcc/vcc_expr.c index 729873b..ce6395d 100644 --- a/lib/libvcc/vcc_expr.c +++ b/lib/libvcc/vcc_expr.c @@ -376,10 +376,11 @@ vcc_expr_tostring(struct vcc *tl, struct expr **e, vcc_type_t fmt) uint8_t constant = EXPR_VAR; CHECK_OBJ_NOTNULL(*e, EXPR_MAGIC); - AN(fmt == STRING || fmt == STRING_LIST); - AZ(fmt == (*e)->fmt); + assert(fmt == STRING || fmt == STRING_LIST); + assert(fmt != (*e)->fmt); - if ((*e)->fmt == STRING || ((*e)->fmt == STRING_LIST && vcc_isconst(*e))) { + if ((*e)->fmt == STRING || + ((*e)->fmt == STRING_LIST && vcc_isconst(*e))) { (*e)->fmt = fmt; return; } @@ -1018,17 +1019,6 @@ static const struct adds { { '+', INT, REAL, REAL }, { '-', INT, REAL, REAL }, - /* Error */ - { '+', DURATION, INT, VOID }, - { '+', DURATION, REAL, VOID }, - { '+', DURATION, TIME, VOID }, - { '+', DURATION, STRING, VOID }, - { '+', INT, DURATION, VOID }, - { '+', IP, IP, VOID }, - { '+', REAL, DURATION, VOID }, - { '+', TIME, INT, VOID }, - { '+', TIME, REAL, VOID }, - { EOI, VOID, VOID, VOID } }; @@ -1044,15 +1034,27 @@ vcc_expr_add(struct vcc *tl, struct expr **e, vcc_type_t fmt) *e = NULL; vcc_expr_mul(tl, e, fmt); ERRCHK(tl); + + if (tl->t->tok != '+' && tl->t->tok != '-') + return; + f2 = (*e)->fmt; + for (ap = vcc_adds; ap->op != EOI; ap++) + if (ap->a == f2 && ap->op == tl->t->tok) + break; + + if (ap->op == EOI && + (fmt == STRING || fmt == STRING_LIST) && + f2 != STRING && f2 != STRING_LIST) { + vcc_expr_tostring(tl, e, fmt); + f2 = (*e)->fmt; + } while (tl->t->tok == '+' || tl->t->tok == '-') { tk = tl->t; vcc_NextToken(tl); if (f2 == TIME) vcc_expr_mul(tl, &e2, DURATION); - else if (f2 == IP) - vcc_expr_mul(tl, &e2, STRING); else vcc_expr_mul(tl, &e2, f2); ERRCHK(tl); From hermunn at varnish-software.com Wed Feb 8 09:27:05 2017 From: hermunn at varnish-software.com (Pål Hermunn Johansen) Date: Wed, 08 Feb 2017 10:27:05 +0100 Subject: [4.1] 5661746 Mention the join character Message-ID: commit 56617468eda2ab4f7f8a0dc1f655cf4d92a88cbf Author: Federico G. Schwindt Date: Thu Feb 25 13:01:27 2016 +0000 Mention the join character diff --git a/lib/libvmod_std/vmod.vcc b/lib/libvmod_std/vmod.vcc index cc2506e..bb69945 100644 --- a/lib/libvmod_std/vmod.vcc +++ b/lib/libvmod_std/vmod.vcc @@ -108,6 +108,7 @@ $Function VOID collect(HEADER hdr) Description Collapses multiple *hdr* headers into one long header. + The header values are joined with a comma (","). Care should be taken when collapsing headers. In particular collapsing Set-Cookie will lead to unexpected results on the From hermunn at varnish-software.com Wed Feb 8 09:27:05 2017 From: hermunn at varnish-software.com (Pål Hermunn Johansen) Date: Wed, 08 Feb 2017 10:27:05 +0100 Subject: [4.1] efc000f Allow INT and REAL to be negative. Message-ID: commit efc000f59027769c8b3ae41df761e7dede79a564 Author: Poul-Henning Kamp Date: Fri Jan 13 11:34:58 2017 +0000 Allow INT and REAL to be negative. Fixes: #2167 Conflicts: bin/varnishtest/tests/m00019.vtc lib/libvcc/vcc_expr.c diff --git a/bin/varnishtest/tests/m00019.vtc b/bin/varnishtest/tests/m00019.vtc index 89ad9b0..3115cb8 100644 --- a/bin/varnishtest/tests/m00019.vtc +++ b/bin/varnishtest/tests/m00019.vtc @@ -10,9 +10,9 @@ varnish v1 -vcl+backend { sub vcl_deliver { set resp.http.foo1 = debug.argtest("1", 2.0, "3"); - set resp.http.foo2 = debug.argtest("1", two=2.0, three="3"); + set resp.http.foo2 = debug.argtest("1", two=-2.0, three="3"); set resp.http.foo3 = debug.argtest("1", three="3", two=2.0); - set resp.http.foo4 = debug.argtest("1", 2.0, three="3"); + set resp.http.foo4 = debug.argtest("1", 2.0, three="-3"); set resp.http.foo5 = debug.argtest("1", 2.0); set resp.http.foo6 = debug.argtest("1"); } @@ -23,9 +23,9 @@ client c1 { rxresp expect resp.bodylen == "6" expect resp.http.foo1 == "1 2 3 ," - expect resp.http.foo2 == "1 2 3 ," + expect resp.http.foo2 == "1 -2 3 ," expect resp.http.foo3 == "1 2 3 ," - expect resp.http.foo4 == "1 2 3 ," + expect resp.http.foo4 == "1 2 -3 ," expect resp.http.foo5 == "1 2 3 ," expect resp.http.foo6 == "1 2 3 ," } -run diff --git a/lib/libvcc/vcc_expr.c b/lib/libvcc/vcc_expr.c index 65bd7a4..09d20f2 100644 --- a/lib/libvcc/vcc_expr.c +++ b/lib/libvcc/vcc_expr.c @@ -904,7 +904,7 @@ vcc_expr4(struct vcc *tl, struct expr **e, enum var_type fmt) e1->constant = EXPR_CONST; vcc_NextToken(tl); *e = e1; - break; + return; case CNUM: /* * XXX: %g may not have enough decimals by default @@ -935,14 +935,31 @@ vcc_expr4(struct vcc *tl, struct expr **e, enum var_type fmt) } e1->constant = EXPR_CONST; *e = e1; + return; + case '-': + if (fmt == INT || fmt == REAL) { + vcc_NextToken(tl); + ExpectErr(tl, CNUM); + if (fmt == INT) { + e1 = vcc_mk_expr(INT, "-%.*s", PF(tl->t)); + vcc_NextToken(tl); + } else { + e1 = vcc_mk_expr(REAL, "-%f", + vcc_DoubleVal(tl)); + } + ERRCHK(tl); + e1->constant = EXPR_CONST; + *e = e1; + return; + } break; default: - VSB_printf(tl->sb, "Unknown token "); - vcc_ErrToken(tl, tl->t); - VSB_printf(tl->sb, " when looking for %s\n\n", vcc_Type(fmt)); - vcc_ErrWhere(tl, tl->t); break; } + VSB_printf(tl->sb, "Unknown token "); + vcc_ErrToken(tl, tl->t); + VSB_printf(tl->sb, " when looking for %s\n\n", vcc_Type(fmt)); + vcc_ErrWhere(tl, tl->t); } /*-------------------------------------------------------------------- From hermunn at varnish-software.com Wed Feb 8 09:27:05 2017 From: hermunn at varnish-software.com (Pål Hermunn Johansen) Date: Wed, 08 Feb 2017 10:27:05 +0100 Subject: [4.1] 9920174 Increment fetch_failed for all causes Message-ID: commit 9920174ed39f42eff8f49fa2918b180828b52814 Author: Federico G. Schwindt Date: Sun Jan 15 20:11:48 2017 +0000 Increment fetch_failed for all causes IOW if we ended up in vcl_backend_error{} or failed after returning delivery in vcl_backend_response{} (e.g. we did not receive enough bytes) we will bump this counter. Conflicts: bin/varnishd/cache/cache_fetch.c bin/varnishtest/tests/r01624.vtc include/tbl/vsc_f_main.h diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 98336ed..8cb14fe 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -687,6 +687,7 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) // XXX: doclose = ? return (F_STP_ERROR); } else { + wrk->stats->fetch_failed++; return (F_STP_FAIL); } } @@ -763,6 +764,7 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo) (void)VFP_Error(bo->vfc, "Template object failed"); if (bo->vfc->failed) { VDI_Finish(bo->wrk, bo); + wrk->stats->fetch_failed++; return (F_STP_FAIL); } @@ -799,6 +801,8 @@ vbf_stp_error(struct worker *wrk, struct busyobj *bo) AN(bo->fetch_objcore->flags & OC_F_BUSY); assert(bo->director_state == DIR_S_NULL); + wrk->stats->fetch_failed++; + now = W_TIM_real(wrk); VSLb_ts_busyobj(bo, "Error", now); @@ -899,7 +903,6 @@ vbf_stp_fail(struct worker *wrk, struct busyobj *bo) EXP_Rearm(bo->fetch_objcore, bo->fetch_objcore->exp.t_origin, 0, 0, 0); } - wrk->stats->fetch_failed++; VBO_setstate(bo, BOS_FAILED); return (F_STP_DONE); } diff --git a/bin/varnishtest/tests/b00020.vtc b/bin/varnishtest/tests/b00020.vtc index 8427742..80353a7 100644 --- a/bin/varnishtest/tests/b00020.vtc +++ b/bin/varnishtest/tests/b00020.vtc @@ -46,4 +46,4 @@ client c1 { varnish v1 -expect n_object == 1 varnish v1 -expect n_objectcore == 1 - +varnish v1 -expect fetch_failed == 1 diff --git a/bin/varnishtest/tests/b00023.vtc b/bin/varnishtest/tests/b00023.vtc index 7685f66..d418904 100644 --- a/bin/varnishtest/tests/b00023.vtc +++ b/bin/varnishtest/tests/b00023.vtc @@ -17,7 +17,6 @@ client c1 { expect resp.status == 503 } -run - server s1 { rxreq delay 0.5 @@ -29,3 +28,5 @@ client c1 { rxresp expect resp.status == 200 } -run + +varnish v1 -expect fetch_failed == 1 diff --git a/bin/varnishtest/tests/b00038.vtc b/bin/varnishtest/tests/b00038.vtc index b963b4f..871ce93 100644 --- a/bin/varnishtest/tests/b00038.vtc +++ b/bin/varnishtest/tests/b00038.vtc @@ -35,3 +35,5 @@ client c1 { rxresp expect resp.status == 503 } -run + +varnish v1 -expect fetch_failed == 1 diff --git a/bin/varnishtest/tests/c00061.vtc b/bin/varnishtest/tests/c00061.vtc index b22f259..4c38f0e 100644 --- a/bin/varnishtest/tests/c00061.vtc +++ b/bin/varnishtest/tests/c00061.vtc @@ -22,3 +22,6 @@ client c1 { rxresp expect resp.status == 504 } -run + +varnish v1 -expect backend_fail == 3 +varnish v1 -expect fetch_failed == 3 diff --git a/bin/varnishtest/tests/r01624.vtc b/bin/varnishtest/tests/r01624.vtc index 23fefc0..e1dadb0 100644 --- a/bin/varnishtest/tests/r01624.vtc +++ b/bin/varnishtest/tests/r01624.vtc @@ -25,9 +25,10 @@ varnish v1 -vcl+backend {} -start client c1 { txreq + rxresphdrs + expect resp.status == 200 non-fatal - timeout 3 - rxresp + rxrespbody } -run delay .2 @@ -38,3 +39,5 @@ client c1 { rxresp expect resp.bodylen == 7 } -run + +varnish v1 -expect fetch_failed == 1 diff --git a/bin/varnishtest/tests/r01648.vtc b/bin/varnishtest/tests/r01648.vtc index de0c364..7de0d00 100644 --- a/bin/varnishtest/tests/r01648.vtc +++ b/bin/varnishtest/tests/r01648.vtc @@ -73,3 +73,5 @@ client c3 { expect resp.status == 200 expect resp.body == "abcdef" } -run + +varnish v1 -expect fetch_failed == 2 diff --git a/include/tbl/vsc_f_main.h b/include/tbl/vsc_f_main.h index 9d05eff..ab926d9 100644 --- a/include/tbl/vsc_f_main.h +++ b/include/tbl/vsc_f_main.h @@ -184,7 +184,7 @@ VSC_F(fetch_304, uint64_t, 1, 'c', 'i', info, "beresp with no body because of 304 response." ) VSC_F(fetch_failed, uint64_t, 1, 'c', 'i', info, - "Fetch failed (all causes), where we do get hold of the backend.", + "Fetch failed (all causes)", "beresp fetch failed." ) VSC_F(fetch_no_thread, uint64_t, 1, 'c', 'i', info, From hermunn at varnish-software.com Wed Feb 8 09:27:05 2017 From: hermunn at varnish-software.com (Pål Hermunn Johansen) Date: Wed, 08 Feb 2017 10:27:05 +0100 Subject: [4.1] e3e91d0 Insert space around '+' and '-' in generated C code. Message-ID: commit e3e91d0e2e967dde9539b65bff45aaf8823d280a Author: P?l Hermunn Johansen Date: Tue Feb 7 14:58:53 2017 +0100 Insert space around '+' and '-' in generated C code. This is an adaptation of 86ae6dcfa2 to the 4.1 branch. The point is to avoid accidential ++ and -- in generated code. diff --git a/lib/libvcc/vcc_expr.c b/lib/libvcc/vcc_expr.c index 09d20f2..e72dcc7 100644 --- a/lib/libvcc/vcc_expr.c +++ b/lib/libvcc/vcc_expr.c @@ -1001,9 +1001,9 @@ vcc_expr_mul(struct vcc *tl, struct expr **e, enum var_type fmt) ERRCHK(tl); assert(e2->fmt == f2); if (tk->tok == '*') - *e = vcc_expr_edit(f3, "(\v1*\v2)", *e, e2); + *e = vcc_expr_edit(f3, "(\v1 * \v2)", *e, e2); else - *e = vcc_expr_edit(f3, "(\v1/\v2)", *e, e2); + *e = vcc_expr_edit(f3, "(\v1 / \v2)", *e, e2); } } @@ -1113,11 +1113,11 @@ vcc_expr_add(struct vcc *tl, struct expr **e, enum var_type fmt) return; } if (tk->tok == '+') - *e = vcc_expr_edit(f2, "(\v1+\v2)", *e, e2); + *e = vcc_expr_edit(f2, "(\v1 + \v2)", *e, e2); else if (f2 == TIME && e2->fmt == TIME) - *e = vcc_expr_edit(DURATION, "(\v1-\v2)", *e, e2); + *e = vcc_expr_edit(DURATION, "(\v1 - \v2)", *e, e2); else - *e = vcc_expr_edit(f2, "(\v1-\v2)", *e, e2); + *e = vcc_expr_edit(f2, "(\v1 - \v2)", *e, e2); } } From hermunn at varnish-software.com Wed Feb 8 09:27:06 2017 From: hermunn at varnish-software.com (Pål Hermunn Johansen) Date: Wed, 08 Feb 2017 10:27:06 +0100 Subject: [4.1] 9a5afcf Update devicedetect.vcl to current upstream Message-ID: commit 9a5afcf65a9de891200caf5b656aed1a36315ca0 Author: Dridi Boukelmoune Date: Mon Sep 12 12:47:16 2016 +0200 Update devicedetect.vcl to current upstream diff --git a/etc/devicedetect.vcl b/etc/devicedetect.vcl index 6c7e659..1910743 100644 --- a/etc/devicedetect.vcl +++ b/etc/devicedetect.vcl @@ -40,7 +40,8 @@ sub devicedetect { if (req.http.Cookie ~ "^ *$") { unset req.http.Cookie; } } else { if (req.http.User-Agent ~ "\(compatible; Googlebot-Mobile/2.1; \+http://www.google.com/bot.html\)" || - (req.http.User-Agent ~ "iPhone" && req.http.User-Agent ~ "\(compatible; Googlebot/2.1; \+http://www.google.com/bot.html")) { + (req.http.User-Agent ~ "(Android|iPhone)" && req.http.User-Agent ~ "\(compatible.?; Googlebot/2.1.?; \+http://www.google.com/bot.html") || + (req.http.User-Agent ~ "(iPhone|Windows Phone)" && req.http.User-Agent ~ "\(compatible; bingbot/2.0; \+http://www.bing.com/bingbot.htm")) { set req.http.X-UA-Device = "mobile-bot"; } elsif (req.http.User-Agent ~ "(?i)(ads|google|bing|msn|yandex|baidu|ro|career|seznam|)bot" || req.http.User-Agent ~ "(?i)(baidu|jike|symantec)spider" || From hermunn at varnish-software.com Wed Feb 8 09:27:06 2017 From: hermunn at varnish-software.com (Pål Hermunn Johansen) Date: Wed, 08 Feb 2017 10:27:06 +0100 Subject: [4.1] 0c4c164 beresp.backend.ip is only available while the connection is open, which means not in vcl_backend_error{} Message-ID: commit 0c4c164823244b6042eb9822d1bc8f030dc630f5 Author: Poul-Henning Kamp Date: Thu Feb 2 08:58:05 2017 +0000 beresp.backend.ip is only available while the connection is open, which means not in vcl_backend_error{} Fixes: #1865 Conflicts: lib/libvcc/generate.py diff --git a/lib/libvcc/generate.py b/lib/libvcc/generate.py index 7c09ba6..4c1645e 100755 --- a/lib/libvcc/generate.py +++ b/lib/libvcc/generate.py @@ -587,7 +587,7 @@ sp_variables = [ ), ('beresp.backend.ip', 'IP', - ( 'backend_response', 'backend_error'), + ( 'backend_response', ), ( ), """ IP of the backend this response was fetched from. """ From hermunn at varnish-software.com Wed Feb 8 09:27:06 2017 From: hermunn at varnish-software.com (Pål Hermunn Johansen) Date: Wed, 08 Feb 2017 10:27:06 +0100 Subject: [4.1] 1c80c8f Document workuser and minor improvements Message-ID: commit 1c80c8ff7513cdb6aa5f0d8157c34c3dec20bbce Author: Federico G. Schwindt Date: Fri Nov 18 05:10:35 2016 +0000 Document workuser and minor improvements diff --git a/doc/sphinx/reference/varnishd.rst b/doc/sphinx/reference/varnishd.rst index 78a285b..4da80a7 100644 --- a/doc/sphinx/reference/varnishd.rst +++ b/doc/sphinx/reference/varnishd.rst @@ -72,8 +72,8 @@ OPTIONS -h - Specifies the hash algorithm. See `Hash Algorithm Options`_ for a - list of supported algorithms. + Specifies the hash algorithm. See `Hash Algorithm`_ section for a list + of supported algorithms. -i identity @@ -82,7 +82,7 @@ OPTIONS -j - Specify the jailing technology to use. + Specify the jailing mechanism to use. See `Jail`_ section. -l @@ -131,7 +131,7 @@ OPTIONS -s <[name=]type[,options]> - Use the specified storage backend, see `Storage Backend Options`_. + Use the specified storage backend. See `Storage Backend`_ section. This option can be used multiple times to specify multiple storage files. Names are referenced in logs, VCL, statistics, etc. @@ -156,8 +156,8 @@ OPTIONS .. _opt_h: -Hash Algorithm Options ----------------------- +Hash Algorithm +-------------- The following hash algorithms are available: @@ -183,8 +183,8 @@ The following hash algorithms are available: .. _ref-varnishd-opt_s: -Storage Backend Options ------------------------ +Storage Backend +--------------- The following storage types are available: @@ -218,8 +218,8 @@ The following storage types are available: .. _ref-varnishd-opt_j: -Jail Options ------------- +Jail +---- Varnish jails are a generalization over various platform specific methods to reduce the privileges of varnish processes. They may have @@ -231,24 +231,27 @@ specific options. Available jails are: required set. Only available on platforms which have the setppriv(2) call. --j +-j - Default on all other platforms if `varnishd` is either started with + Default on all other platforms when `varnishd` is either started with an effective uid of 0 ("as root") or as user ``varnish``. - With the ``unix`` jail technology activated, varnish will switch to + With the ``unix`` jail mechanism activated, varnish will switch to an alternative user for subprocesses and change the effective uid of the master process whenever possible. The optional `user` argument specifies which alternative user to - use. It defaults to ``varnish`` + use. It defaults to ``varnish``. The optional `ccgroup` argument specifies a group to add to varnish subprocesses requiring access to a c-compiler. There is no default. + The optional `workuser` argument specifies an alternative user to use + for the worker process. It defaults to ``vcache``. + -j none - last resort jail choice: With jail technology ``none``, varnish will + last resort jail choice: With jail mechanism ``none``, varnish will run all processes with the privileges it was started with. From hermunn at varnish-software.com Wed Feb 8 10:47:05 2017 From: hermunn at varnish-software.com (Pål Hermunn Johansen) Date: Wed, 08 Feb 2017 11:47:05 +0100 Subject: [4.1] dd27061 Update changelog Message-ID: commit dd270619effbf18cd27d8925783a56624df91089 Author: P?l Hermunn Johansen Date: Wed Feb 8 11:45:32 2017 +0100 Update changelog diff --git a/doc/changes.rst b/doc/changes.rst index c322a2e..da9730a 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -1,4 +1,26 @@ ====================================== +Varnish Cache 4.1.5-beta2 (unreleased) +====================================== + +Changes since 4.1.5-beta1: + +* Update devicedetect.vcl + +Bugs fixed +---------- +* 1704_ - Reverted the docfix and made the fech_failed counter do +what the documentation sais it should do +* 1865_ - Panic accessing beresp.backend.ip in vcl_backend_error +* 2167_ - VCC will not parse a literal negative number where INT is + expected +* 2184_ - Cannot subtract a negative number #2184 + +.. _1704: https://github.com/varnishcache/varnish-cache/issues/1704 +.. _1865: https://github.com/varnishcache/varnish-cache/issues/1865 +.. _2167: https://github.com/varnishcache/varnish-cache/issues/2167 +.. _2184: https://github.com/varnishcache/varnish-cache/issues/2184 + +====================================== Varnish Cache 4.1.5-beta1 (2017-02-02) ====================================== From nils.goroll at uplex.de Wed Feb 8 10:48:05 2017 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 08 Feb 2017 11:48:05 +0100 Subject: [master] 978d0a8 include config.h first Message-ID: commit 978d0a8662084ed70e1619cc72d0e2b2a924e8af Author: Nils Goroll Date: Wed Feb 8 11:47:30 2017 +0100 include config.h first diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py index 477486e..cbe06b9 100755 --- a/lib/libvcc/vmodtool.py +++ b/lib/libvcc/vmodtool.py @@ -785,8 +785,9 @@ class vcc(object): fn2 = fn + ".tmp2" + fo.write('#include "config.h"\n') fo.write('#include \n') - for i in ["config", "vdef", "vcl", "vrt", self.pfx, "vmod_abi"]: + for i in ["vdef", "vcl", "vrt", self.pfx, "vmod_abi"]: fo.write('#include "%s.h"\n' % i) fo.write("\n") From hermunn at varnish-software.com Wed Feb 8 12:35:06 2017 From: hermunn at varnish-software.com (Pål Hermunn Johansen) Date: Wed, 08 Feb 2017 13:35:06 +0100 Subject: [4.1] 411fb55 Repair formatting mistake Message-ID: commit 411fb55b95e3bb5fb38dec91d01aa8b3fda206ce Author: P?l Hermunn Johansen Date: Wed Feb 8 13:32:15 2017 +0100 Repair formatting mistake The previous changelog update contained a formatting mistake which is corrected here. diff --git a/doc/changes.rst b/doc/changes.rst index da9730a..eb02323 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -9,7 +9,7 @@ Changes since 4.1.5-beta1: Bugs fixed ---------- * 1704_ - Reverted the docfix and made the fech_failed counter do -what the documentation sais it should do + what the documentation sais it should do * 1865_ - Panic accessing beresp.backend.ip in vcl_backend_error * 2167_ - VCC will not parse a literal negative number where INT is expected From hermunn at varnish-software.com Wed Feb 8 12:55:06 2017 From: hermunn at varnish-software.com (Pål Hermunn Johansen) Date: Wed, 08 Feb 2017 13:55:06 +0100 Subject: [4.1] 47df804 Prepare for 4.1.5-beta2 release Message-ID: commit 47df80469a2846b56075e3b01a3dd26243cb01ba Author: P?l Hermunn Johansen Date: Wed Feb 8 13:38:44 2017 +0100 Prepare for 4.1.5-beta2 release diff --git a/configure.ac b/configure.ac index 18a47fe..9103fa8 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ AC_PREREQ(2.59) AC_COPYRIGHT([Copyright (c) 2006 Verdens Gang AS Copyright (c) 2006-2016 Varnish Software]) AC_REVISION([$Id$]) -AC_INIT([Varnish], [4.1.5-beta1], [varnish-dev at varnish-cache.org]) +AC_INIT([Varnish], [4.1.5-beta2], [varnish-dev at varnish-cache.org]) AC_CONFIG_SRCDIR(include/miniobj.h) AC_CONFIG_HEADERS([config.h]) AC_CONFIG_MACRO_DIR([m4]) diff --git a/doc/changes.rst b/doc/changes.rst index eb02323..a1b2a7a 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -1,5 +1,5 @@ ====================================== -Varnish Cache 4.1.5-beta2 (unreleased) +Varnish Cache 4.1.5-beta2 (2017-02-08) ====================================== Changes since 4.1.5-beta1: From hermunn at varnish-software.com Thu Feb 9 13:08:05 2017 From: hermunn at varnish-software.com (Pål Hermunn Johansen) Date: Thu, 09 Feb 2017 14:08:05 +0100 Subject: [4.1] 2c82b1c Prepare for 4.1.5 release Message-ID: commit 2c82b1c9d7f01fea89a8f94003eee94e8a305509 Author: P?l Hermunn Johansen Date: Thu Feb 9 14:01:29 2017 +0100 Prepare for 4.1.5 release diff --git a/configure.ac b/configure.ac index 9103fa8..a145726 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ AC_PREREQ(2.59) AC_COPYRIGHT([Copyright (c) 2006 Verdens Gang AS Copyright (c) 2006-2016 Varnish Software]) AC_REVISION([$Id$]) -AC_INIT([Varnish], [4.1.5-beta2], [varnish-dev at varnish-cache.org]) +AC_INIT([Varnish], [4.1.5], [varnish-dev at varnish-cache.org]) AC_CONFIG_SRCDIR(include/miniobj.h) AC_CONFIG_HEADERS([config.h]) AC_CONFIG_MACRO_DIR([m4]) diff --git a/doc/changes.rst b/doc/changes.rst index a1b2a7a..43b4072 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -1,3 +1,9 @@ +================================ +Varnish Cache 4.1.5 (2017-02-09) +================================ + +* No code changes since 4.1.5-beta2. + ====================================== Varnish Cache 4.1.5-beta2 (2017-02-08) ====================================== From dridi.boukelmoune at gmail.com Thu Feb 9 13:26:05 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 09 Feb 2017 14:26:05 +0100 Subject: [master] 8f34e3a Remove duplicated word to improve reading pleasure Message-ID: commit 8f34e3ace226aeabd5720cde126dfa56ce671a22 Author: Matthias Viehweger Date: Thu Feb 9 14:16:15 2017 +0100 Remove duplicated word to improve reading pleasure diff --git a/doc/sphinx/users-guide/run_security.rst b/doc/sphinx/users-guide/run_security.rst index 5340e6c..5159ef3 100644 --- a/doc/sphinx/users-guide/run_security.rst +++ b/doc/sphinx/users-guide/run_security.rst @@ -162,7 +162,7 @@ Furthermore you may want to look at and lock down: :ref:`ref_param_vmod_path` The directory (or colon separated list of directories) where - Varnish will will look for modules. This could potentially be + Varnish will look for modules. This could potentially be used to load rogue modules into Varnish. The CLI interface From hermunn at varnish-software.com Thu Feb 9 14:05:06 2017 From: hermunn at varnish-software.com (Pål Hermunn Johansen) Date: Thu, 09 Feb 2017 15:05:06 +0100 Subject: [4.1] 1ff9df8 Minor changelog fix Message-ID: commit 1ff9df83bb02e393ce2b80932de33a7244c84176 Author: P?l Hermunn Johansen Date: Thu Feb 9 15:03:56 2017 +0100 Minor changelog fix Fix the description of #2184 in the changelog. diff --git a/doc/changes.rst b/doc/changes.rst index 43b4072..f1166fd 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -19,7 +19,7 @@ Bugs fixed * 1865_ - Panic accessing beresp.backend.ip in vcl_backend_error * 2167_ - VCC will not parse a literal negative number where INT is expected -* 2184_ - Cannot subtract a negative number #2184 +* 2184_ - Cannot subtract a negative number .. _1704: https://github.com/varnishcache/varnish-cache/issues/1704 .. _1865: https://github.com/varnishcache/varnish-cache/issues/1865 From fgsch at lodoss.net Thu Feb 9 14:26:05 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Thu, 09 Feb 2017 15:26:05 +0100 Subject: [master] f4b367e Ensure VFP is correctly set when unbusy'ing Message-ID: commit f4b367e15301ce04abd8ad13376b45964595abd1 Author: Federico G. Schwindt Date: Thu Feb 9 13:54:20 2017 +0000 Ensure VFP is correctly set when unbusy'ing Fixes #2104. diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 0f6f88e..43d87ca 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -726,9 +726,6 @@ cnt_recv(struct worker *wrk, struct req *req) http_CollectHdr(req->http, H_Cache_Control); - VFP_Setup(req->vfc); - req->vfc->http = req->http; - req->vfc->wrk = wrk; if (req->transport->req_body != NULL) { req->transport->req_body(req); @@ -899,6 +896,10 @@ CNT_Request(struct worker *wrk, struct req *req) req->wrk = wrk; wrk->vsl = req->vsl; + VFP_Setup(req->vfc); + req->vfc->http = req->http; + req->vfc->wrk = wrk; + for (nxt = REQ_FSM_MORE; nxt == REQ_FSM_MORE; ) { /* * This is a good place to be paranoid about the various From fgsch at lodoss.net Thu Feb 9 14:35:06 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Thu, 09 Feb 2017 15:35:06 +0100 Subject: [master] 95d8b34 Document VRT_ipcmp wrt bumping VRT API version Message-ID: commit 95d8b34eb403746700870813efe40731a8a0c63e Author: Federico G. Schwindt Date: Thu Feb 9 14:29:32 2017 +0000 Document VRT_ipcmp wrt bumping VRT API version diff --git a/include/vrt.h b/include/vrt.h index d3aee0b..88884d4 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -46,10 +46,11 @@ * 3.2: * vrt_backend grew .proxy_header field * vrt_ctx grew .sp field. - * * older version: + * * Bump VRT_MINOR_VERSION due to: * - VCL_ACL type added + * - VRT_ipcmp() added * Bump VRT_MAJOR_VERSION due to: * - VRT_CacheReqBody changed signature * From fgsch at lodoss.net Fri Feb 10 02:47:05 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Fri, 10 Feb 2017 03:47:05 +0100 Subject: [master] 8dfa782 Dump loaded VMODs and related details under panic Message-ID: commit 8dfa782a5901279f73b19d9d055f26b3250ec8b5 Author: Federico G. Schwindt Date: Fri Feb 10 02:37:40 2017 +0000 Dump loaded VMODs and related details under panic diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index 8338490..216fdff 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -398,6 +398,7 @@ pan_busyobj(struct vsb *vsb, const struct busyobj *bo) if (bo->stale_oc) pan_objcore(vsb, "ims", bo->stale_oc); VCL_Panic(vsb, bo->vcl); + VMOD_Panic(vsb); VSB_indent(vsb, -2); VSB_printf(vsb, "},\n"); } @@ -462,6 +463,7 @@ pan_req(struct vsb *vsb, const struct req *req) pan_http(vsb, "resp", req->resp); VCL_Panic(vsb, req->vcl); + VMOD_Panic(vsb); if (req->body_oc != NULL) pan_objcore(vsb, "BODY", req->body_oc); @@ -622,7 +624,8 @@ pan_ic(const char *func, const char *file, int line, const char *cond, if (q != NULL) VSB_printf(pan_vsb, "thread = (%s)\n", q); - VSB_printf(pan_vsb, "version = %s\n", VCS_version); + VSB_printf(pan_vsb, "version = %s, vrt api = %d.%d\n", + VCS_version, VRT_MAJOR_VERSION, VRT_MINOR_VERSION); VSB_printf(pan_vsb, "ident = %s,%s\n", VSB_data(vident) + 1, Waiter_GetName()); VSB_printf(pan_vsb, "now = %f (mono), %f (real)\n", diff --git a/bin/varnishd/cache/cache_priv.h b/bin/varnishd/cache/cache_priv.h index 460d01e..dd88025 100644 --- a/bin/varnishd/cache/cache_priv.h +++ b/bin/varnishd/cache/cache_priv.h @@ -120,6 +120,7 @@ void VRTPRIV_dynamic_kill(struct vrt_privs *privs, uintptr_t id); /* cache_vrt_vmod.c */ void VMOD_Init(void); +void VMOD_Panic(struct vsb *); /* http1/cache_http1_pipe.c */ void V1P_Init(void); diff --git a/bin/varnishd/cache/cache_vrt_vmod.c b/bin/varnishd/cache/cache_vrt_vmod.c index f64cb33..05bd49e 100644 --- a/bin/varnishd/cache/cache_vrt_vmod.c +++ b/bin/varnishd/cache/cache_vrt_vmod.c @@ -61,6 +61,9 @@ struct vmod { void *hdl; const void *funcs; int funclen; + const char *abi; + int vrt_major; + int vrt_minor; }; static VTAILQ_HEAD(,vmod) vmods = VTAILQ_HEAD_INITIALIZER(vmods); @@ -179,6 +182,9 @@ VRT_Vmod_Init(VRT_CTX, struct vmod **hdl, void *ptr, int len, const char *nm, v->funclen = d->func_len; v->funcs = d->func; + v->abi = d->abi; + v->vrt_major = d->vrt_major; + v->vrt_minor = d->vrt_minor; REPLACE(v->nm, nm); REPLACE(v->path, path); @@ -223,6 +229,20 @@ VRT_Vmod_Fini(struct vmod **hdl) FREE_OBJ(v); } +void +VMOD_Panic(struct vsb *vsb) +{ + struct vmod *v; + + VSB_printf(vsb, "vmods = {\n"); + VSB_indent(vsb, 2); + VTAILQ_FOREACH(v, &vmods, list) + VSB_printf(vsb, "%s = {%s, %d.%d},\n", + v->nm, v->abi, v->vrt_major, v->vrt_minor); + VSB_indent(vsb, -2); + VSB_printf(vsb, "},\n"); +} + /*---------------------------------------------------------------------*/ static void From fgsch at lodoss.net Fri Feb 10 02:47:05 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Fri, 10 Feb 2017 03:47:05 +0100 Subject: [master] b907f30 More consistent panic output Message-ID: commit b907f30c4d82d13401f81db3ed6e4de1c417a3dc Author: Federico G. Schwindt Date: Fri Feb 10 02:39:05 2017 +0000 More consistent panic output diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index 216fdff..9e19c1b 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -275,7 +275,7 @@ pan_objcore(struct vsb *vsb, const char *typ, const struct objcore *oc) VSB_printf(vsb, "},\n"); if (oc->boc != NULL) pan_boc(vsb, oc->boc); - VSB_printf(vsb, "exp = {%f, %f, %f, %f}\n", + VSB_printf(vsb, "exp = {%f, %f, %f, %f},\n", oc->t_origin, oc->ttl, oc->grace, oc->keep); VSB_printf(vsb, "objhead = %p,\n", oc->objhead); VSB_printf(vsb, "stevedore = %p", oc->stobj->stevedore); diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c index b950a96..70de663 100644 --- a/bin/varnishd/cache/cache_vcl.c +++ b/bin/varnishd/cache/cache_vcl.c @@ -193,8 +193,8 @@ VCL_Panic(struct vsb *vsb, const struct vcl *vcl) VSB_printf(vsb, "vcl = {\n"); VSB_indent(vsb, 2); PAN_CheckMagic(vsb, vcl, VCL_MAGIC); - VSB_printf(vsb, "name = \"%s\"\n", vcl->loaded_name); - VSB_printf(vsb, "busy = %u\n", vcl->busy); + VSB_printf(vsb, "name = \"%s\",\n", vcl->loaded_name); + VSB_printf(vsb, "busy = %u,\n", vcl->busy); VSB_printf(vsb, "discard = %u,\n", vcl->discard); VSB_printf(vsb, "state = %s,\n", vcl->state); VSB_printf(vsb, "temp = %s,\n", (const volatile char *)vcl->temp); diff --git a/bin/varnishd/storage/storage_simple.c b/bin/varnishd/storage/storage_simple.c index 011b9ec..0ad45f7 100644 --- a/bin/varnishd/storage/storage_simple.c +++ b/bin/varnishd/storage/storage_simple.c @@ -642,7 +642,7 @@ const struct obj_methods SML_methods = { static void sml_panic_st(struct vsb *vsb, const char *hd, const struct storage *st) { - VSB_printf(vsb, "%s %p {priv=%p, ptr=%p, len=%u, space=%u}\n", + VSB_printf(vsb, "%s = %p {priv=%p, ptr=%p, len=%u, space=%u},\n", hd, st, st->priv, st->ptr, st->len, st->space); } @@ -652,7 +652,7 @@ SML_panic(struct vsb *vsb, const struct objcore *oc) struct object *o; struct storage *st; - VSB_printf(vsb, "Simple = %p\n", oc->stobj->priv); + VSB_printf(vsb, "Simple = %p,\n", oc->stobj->priv); if (oc->stobj->priv == NULL) return; CAST_OBJ_NOTNULL(o, oc->stobj->priv, OBJECT_MAGIC); @@ -661,10 +661,10 @@ SML_panic(struct vsb *vsb, const struct objcore *oc) #define OBJ_FIXATTR(U, l, sz) \ VSB_printf(vsb, "%s = ", #U); \ VSB_quote(vsb, (const void*)o->fa_##l, sz, VSB_QUOTE_HEX); \ - VSB_printf(vsb, "\n"); + VSB_printf(vsb, ",\n"); #define OBJ_VARATTR(U, l) \ - VSB_printf(vsb, "%s = {len=%u, ptr=%p}\n", \ + VSB_printf(vsb, "%s = {len=%u, ptr=%p},\n", \ #U, o->va_##l##_len, o->va_##l); #define OBJ_AUXATTR(U, l) \ From phk at FreeBSD.org Sat Feb 11 12:33:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Sat, 11 Feb 2017 13:33:05 +0100 Subject: [master] 5337a9a Finally nail the race which made H2 tests randomly "just not work": Message-ID: commit 5337a9a98f2c5ad1d37330f738c1aa0bd4859660 Author: Poul-Henning Kamp Date: Sat Feb 11 12:29:14 2017 +0000 Finally nail the race which made H2 tests randomly "just not work": One cannot use a counter as boolean when you have both waiters and read ahead, if one frame heas been read ahead and one stream is waiting for another frame, the counter will be zero indicating no frames should be read. diff --git a/bin/varnishtest/vtc_http2.c b/bin/varnishtest/vtc_http2.c index f7f0e34..542f2db 100644 --- a/bin/varnishtest/vtc_http2.c +++ b/bin/varnishtest/vtc_http2.c @@ -103,6 +103,7 @@ struct stream { pthread_t tp; struct http *hp; int64_t ws; + int wf; VTAILQ_HEAD(, frame) fq; @@ -720,6 +721,7 @@ receive_frame(void *priv) AZ(pthread_mutex_lock(&hp->mtx)); while (hp->h2) { /*no wanted frames? */ + assert(hp->wf >= 0); if (hp->wf == 0) { AZ(pthread_cond_wait(&hp->cond, &hp->mtx)); continue; @@ -824,8 +826,12 @@ receive_frame(void *priv) AZ(pthread_mutex_lock(&hp->mtx)); VTAILQ_INSERT_HEAD(&s->fq, f, list); - hp->wf--; - AZ(pthread_cond_signal(&s->cond)); + if (s->wf) { + assert(hp->wf > 0); + hp->wf--; + s->wf = 0; + AZ(pthread_cond_signal(&s->cond)); + } continue; } AZ(pthread_mutex_unlock(&hp->mtx)); @@ -2060,8 +2066,10 @@ rxstuff(struct stream *s) CHECK_OBJ_NOTNULL(s, STREAM_MAGIC); AZ(pthread_mutex_lock(&s->hp->mtx)); - s->hp->wf++; if (VTAILQ_EMPTY(&s->fq)) { + assert(s->hp->wf >= 0); + s->hp->wf++; + s->wf = 1; AZ(pthread_cond_signal(&s->hp->cond)); AZ(pthread_cond_wait(&s->cond, &s->hp->mtx)); } From fgsch at lodoss.net Mon Feb 13 01:32:05 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Mon, 13 Feb 2017 02:32:05 +0100 Subject: [master] f0085ce Make this test less time sensitive Message-ID: commit f0085ce26bcf7fbf5ba5d40c9992d7a36b94dc50 Author: Federico G. Schwindt Date: Mon Feb 13 01:28:38 2017 +0000 Make this test less time sensitive diff --git a/bin/varnishtest/tests/u00003.vtc b/bin/varnishtest/tests/u00003.vtc index cab8750..d799a51 100644 --- a/bin/varnishtest/tests/u00003.vtc +++ b/bin/varnishtest/tests/u00003.vtc @@ -83,7 +83,7 @@ shell "grep -q /foo ${tmpdir}/ncsa.old.log" shell "grep -q /bar ${tmpdir}/ncsa.log" shell {echo "%{VSL:Begin}x %{Varnish:vxid}x %{VCL_Log:foo}x %D %T %{Varnish:handling}x %{%Z}t" >${tmpdir}/format} -shell -match "^req 1000 rxreq 1001 [0-9]{5} 0 miss [A-Z]{3,}" \ +shell -match "^req 1000 rxreq 1001 [0-9]+ 0 miss [A-Z]{3,}" \ {varnishncsa -n ${v1_name} -d -f ${tmpdir}/format} -shell -match "^bereq 1001 fetch 1002 qux [0-9]{5} 0 - [A-Z]{3,}" \ +shell -match "^bereq 1001 fetch 1002 qux [0-9]+ 0 - [A-Z]{3,}" \ {varnishncsa -n ${v1_name} -d -f ${tmpdir}/format -b} From phk at FreeBSD.org Mon Feb 13 09:08:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 13 Feb 2017 10:08:05 +0100 Subject: [master] 175e711 Version numbers are unsigned Message-ID: commit 175e7116fa881bf44913136a9e27591618bb4953 Author: Poul-Henning Kamp Date: Mon Feb 13 08:38:54 2017 +0000 Version numbers are unsigned diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index 9e19c1b..11390b6 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -624,7 +624,7 @@ pan_ic(const char *func, const char *file, int line, const char *cond, if (q != NULL) VSB_printf(pan_vsb, "thread = (%s)\n", q); - VSB_printf(pan_vsb, "version = %s, vrt api = %d.%d\n", + VSB_printf(pan_vsb, "version = %s, vrt api = %u.%u\n", VCS_version, VRT_MAJOR_VERSION, VRT_MINOR_VERSION); VSB_printf(pan_vsb, "ident = %s,%s\n", VSB_data(vident) + 1, Waiter_GetName()); From phk at FreeBSD.org Mon Feb 13 11:21:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 13 Feb 2017 12:21:05 +0100 Subject: [master] 4f03022 Avoid sideeffects in assert Message-ID: commit 4f03022ff35124a44cbde4f72181203575898720 Author: Poul-Henning Kamp Date: Mon Feb 13 11:11:27 2017 +0000 Avoid sideeffects in assert Spotted by: Coverity diff --git a/bin/varnishd/cache/cache_shmlog.c b/bin/varnishd/cache/cache_shmlog.c index cc3345d..c9776ab 100644 --- a/bin/varnishd/cache/cache_shmlog.c +++ b/bin/varnishd/cache/cache_shmlog.c @@ -401,7 +401,8 @@ VSLb_bin(struct vsl_log *vsl, enum VSL_tag_e tag, ssize_t len, const void *ptr) assert(VSL_END(vsl->wlp, len * 2 + 1) < vsl->wle); p = VSL_DATA(vsl->wlp); for (ll = 0; ll < len; ll++) { - assert(snprintf(p, 3, "%02x", *pp++) == 2); + assert(snprintf(p, 3, "%02x", *pp) == 2); + pp++; p += 2; } if (suff) From phk at FreeBSD.org Mon Feb 13 11:21:06 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 13 Feb 2017 12:21:06 +0100 Subject: [master] d76e051 Plug a harmless resource leak to silence Coverity Message-ID: commit d76e051c3f67f897f17175f6ef6eac25a87db6eb Author: Poul-Henning Kamp Date: Mon Feb 13 11:19:53 2017 +0000 Plug a harmless resource leak to silence Coverity diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c index ec63d1d..76a78d4 100644 --- a/bin/varnishtest/vtc_varnish.c +++ b/bin/varnishtest/vtc_varnish.c @@ -696,8 +696,11 @@ varnish_cli(struct varnish *v, const char *cli, unsigned exp, const char *re) } if (v->cli_fd < 0) varnish_launch(v); - if (vtc_error) + if (vtc_error) { + if (vre != NULL) + VRE_free(&vre); return; + } u = varnish_ask_cli(v, cli, &resp); vtc_log(v->vl, 2, "CLI %03u <%s>", u, cli); if (exp != 0 && exp != (unsigned)u) From fgsch at lodoss.net Mon Feb 13 12:02:05 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Mon, 13 Feb 2017 13:02:05 +0100 Subject: [master] 9ab3376 More version numbers are unsigned Message-ID: commit 9ab3376e21e8f628beb93530316eb9d5e8d39203 Author: Federico G. Schwindt Date: Mon Feb 13 11:52:53 2017 +0000 More version numbers are unsigned diff --git a/bin/varnishd/cache/cache_vrt_vmod.c b/bin/varnishd/cache/cache_vrt_vmod.c index 05bd49e..009da54 100644 --- a/bin/varnishd/cache/cache_vrt_vmod.c +++ b/bin/varnishd/cache/cache_vrt_vmod.c @@ -62,8 +62,8 @@ struct vmod { const void *funcs; int funclen; const char *abi; - int vrt_major; - int vrt_minor; + unsigned vrt_major; + unsigned vrt_minor; }; static VTAILQ_HEAD(,vmod) vmods = VTAILQ_HEAD_INITIALIZER(vmods); @@ -237,7 +237,7 @@ VMOD_Panic(struct vsb *vsb) VSB_printf(vsb, "vmods = {\n"); VSB_indent(vsb, 2); VTAILQ_FOREACH(v, &vmods, list) - VSB_printf(vsb, "%s = {%s, %d.%d},\n", + VSB_printf(vsb, "%s = {%s, %u.%u},\n", v->nm, v->abi, v->vrt_major, v->vrt_minor); VSB_indent(vsb, -2); VSB_printf(vsb, "},\n"); From phk at FreeBSD.org Mon Feb 13 14:05:06 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 13 Feb 2017 15:05:06 +0100 Subject: [master] e914a75 CLI errors are not fatal if we are in shutdown Message-ID: commit e914a75073582c3b504c8705a636e854001d57bd Author: Poul-Henning Kamp Date: Mon Feb 13 12:06:33 2017 +0000 CLI errors are not fatal if we are in shutdown diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c index 76a78d4..6fcf683 100644 --- a/bin/varnishtest/vtc_varnish.c +++ b/bin/varnishtest/vtc_varnish.c @@ -116,7 +116,7 @@ varnish_ask_cli(const struct varnish *v, const char *cmd, char **repl) cmd, errno, strerror(errno)); } i = VCLI_ReadResult(v->cli_fd, &retval, &r, vtc_maxdur); - if (i != 0) + if (i != 0 && !vtc_stop) vtc_fatal(v->vl, "CLI failed (%s) = %d %u %s", cmd, i, retval, r); AZ(i); From phk at FreeBSD.org Mon Feb 13 14:05:06 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 13 Feb 2017 15:05:06 +0100 Subject: [master] 6ab7447 This assert is no longer valid Message-ID: commit 6ab744783e0ed0f7480b53fe226f4e84909cbb88 Author: Poul-Henning Kamp Date: Mon Feb 13 14:01:43 2017 +0000 This assert is no longer valid diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c index 6fcf683..3ee8dc0 100644 --- a/bin/varnishtest/vtc_varnish.c +++ b/bin/varnishtest/vtc_varnish.c @@ -119,7 +119,6 @@ varnish_ask_cli(const struct varnish *v, const char *cmd, char **repl) if (i != 0 && !vtc_stop) vtc_fatal(v->vl, "CLI failed (%s) = %d %u %s", cmd, i, retval, r); - AZ(i); vtc_log(v->vl, 3, "CLI RX %u", retval); vtc_dump(v->vl, 4, "CLI RX", r, -1); if (repl != NULL) From phk at FreeBSD.org Mon Feb 13 14:30:07 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 13 Feb 2017 15:30:07 +0100 Subject: [master] b722682 Make it clear to coverity that we are not doing anything untoward with the frame length. Message-ID: commit b72268214e2a58a8ed251c4fbf5e59ff71ab1384 Author: Poul-Henning Kamp Date: Mon Feb 13 14:28:58 2017 +0000 Make it clear to coverity that we are not doing anything untoward with the frame length. diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index 27872e7..5acf8a6 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -260,8 +260,6 @@ h2_vsl_frame(const struct h2_sess *h2, const void *ptr, size_t len) if (len > 9) VSLb_bin(h2->vsl, SLT_H2RxBody, len - 9, b + 9); - u = vbe32dec(b) >> 8; - vsb = VSB_new_auto(); AN(vsb); p = h2_framename((enum h2frame)b[3]); @@ -269,13 +267,15 @@ h2_vsl_frame(const struct h2_sess *h2, const void *ptr, size_t len) VSB_cat(vsb, p); else VSB_quote(vsb, b + 3, 1, VSB_QUOTE_HEX); + + u = vbe32dec(b) >> 8; VSB_printf(vsb, "[%u] ", u); VSB_quote(vsb, b + 4, 1, VSB_QUOTE_HEX); VSB_putc(vsb, ' '); VSB_quote(vsb, b + 5, 4, VSB_QUOTE_HEX); if (u > 0) { VSB_putc(vsb, ' '); - VSB_quote(vsb, b + 9, u, VSB_QUOTE_HEX); + VSB_quote(vsb, b + 9, len - 9, VSB_QUOTE_HEX); } AZ(VSB_finish(vsb)); VSLb(h2->vsl, SLT_Debug, "H2RXF %s", VSB_data(vsb)); From hermunn at varnish-software.com Mon Feb 13 16:52:05 2017 From: hermunn at varnish-software.com (Pål Hermunn Johansen) Date: Mon, 13 Feb 2017 17:52:05 +0100 Subject: [master] afeb1a2 Update changes.rst to include info on 4.1 releases Message-ID: commit afeb1a20b456054e643b261c8974859282515766 Author: P?l Hermunn Johansen Date: Thu Feb 9 15:42:58 2017 +0100 Update changes.rst to include info on 4.1 releases diff --git a/doc/changes.rst b/doc/changes.rst index d07c595..54a42c6 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -75,6 +75,182 @@ News for Vmod Authors * PRIV_* now also work for object methods with unchanged scope. +================================ +Varnish Cache 4.1.5 (2017-02-09) +================================ + +* No code changes since 4.1.5-beta2. + +====================================== +Varnish Cache 4.1.5-beta2 (2017-02-08) +====================================== + +Changes since 4.1.5-beta1: + +* Update devicedetect.vcl + +Bugs fixed +---------- +* 1704_ - Reverted the docfix and made the fech_failed counter do + what the documentation says it should do +* 1865_ - Panic accessing beresp.backend.ip in vcl_backend_error +* 2167_ - VCC will not parse a literal negative number where INT is + expected +* 2184_ - Cannot subtract a negative number + +.. _1704: https://github.com/varnishcache/varnish-cache/issues/1704 +.. _1865: https://github.com/varnishcache/varnish-cache/issues/1865 +.. _2167: https://github.com/varnishcache/varnish-cache/issues/2167 +.. _2184: https://github.com/varnishcache/varnish-cache/issues/2184 + +====================================== +Varnish Cache 4.1.5-beta1 (2017-02-02) +====================================== + +Changes since 4.1.4: + +Bugs fixed +---------- + +* 1704_ - (docfix) Clarify description of fetch_failed counter +* 1834_ - Panic in workspace exhaustion conditions +* 2106_ - 4.1.3: Varnish crashes with "Assert error in CNT_Request(), + cache/cache_req_fsm.c line 820" +* 2134_ - Disable Nagle's +* 2148_ - varnishncsa cannot decode Authorization header if the + format is incorrect. +* 2168_ - Compare 'bereq.backend' / 'req.backend_hint' + myDirector.backend() does not work +* 2178_ - 4.1 branch does not compile on FreeBSD +* 2188_ - Fix vsm_free (never incremented) +* 2190_ - (docfix)varnishncsa: The %r formatter is NOT equivalent to... +* 2197_ - ESI parser panic on malformed src URL + +.. _1704: https://github.com/varnishcache/varnish-cache/issues/1704 +.. _1834: https://github.com/varnishcache/varnish-cache/issues/1834 +.. _2106: https://github.com/varnishcache/varnish-cache/issues/2106 +.. _2134: https://github.com/varnishcache/varnish-cache/issues/2134 +.. _2148: https://github.com/varnishcache/varnish-cache/issues/2148 +.. _2168: https://github.com/varnishcache/varnish-cache/issues/2168 +.. _2178: https://github.com/varnishcache/varnish-cache/issues/2178 +.. _2188: https://github.com/varnishcache/varnish-cache/pull/2188 +.. _2190: https://github.com/varnishcache/varnish-cache/issues/2190 +.. _2197: https://github.com/varnishcache/varnish-cache/issues/2197 + +================================ +Varnish Cache 4.1.4 (2016-12-01) +================================ + +Changes since 4.1.4-beta3: + +Bugs fixed +---------- + +* 2035_ - varnishd stalls with two consecutive Range requests using + HTTP persistent connections + +.. _2035: https://github.com/varnishcache/varnish-cache/issues/2035 + +====================================== +Varnish Cache 4.1.4-beta3 (2016-11-24) +====================================== + +Changes since 4.1.4-beta2: + +* Include the current time of the panic in the panic output +* Keep a reserve of idle threads for vital tasks + +Bugs fixed +---------- + +* 1874_ - clock-step related crash +* 1889_ - (docfix) What does -p flag for backend.list command means +* 2115_ - VSM temporary files are not always deleted +* 2129_ - (docfix) stack overflow with >4 level esi + +.. _1874: https://github.com/varnishcache/varnish-cache/issues/1874 +.. _1889: https://github.com/varnishcache/varnish-cache/issues/1889 +.. _2115: https://github.com/varnishcache/varnish-cache/issues/2115 +.. _2129: https://github.com/varnishcache/varnish-cache/issues/2129 + +====================================== +Varnish Cache 4.1.4-beta2 (2016-10-13) +====================================== + +Bugs fixed +---------- + +* 1830_ - VSL API: "duplicate link" errors in request grouping when + vsl_buffer is increased +* 2010_ - varnishadm CLI behaving weirdly +* 2017_ - varnishncsa docfix: "%r" field is wrong +* 2107_ - (docfix) HEAD requestes changed to GET + +.. _1830: https://github.com/varnishcache/varnish-cache/issues/1830 +.. _2010: https://github.com/varnishcache/varnish-cache/issues/2010 +.. _2017: https://github.com/varnishcache/varnish-cache/issues/2017 +.. _2107: https://github.com/varnishcache/varnish-cache/issues/2107 + +====================================== +Varnish Cache 4.1.4-beta1 (2016-09-14) +====================================== + +Changes since 4.1.3: + +* [varnishhist] Various improvements +* [varnishtest] A `cmd` feature for custom shell-based checks +* Documentation improvements (do_stream, sess_herd, timeout_linger, thread_pools) +* [varnishtop] Documented behavior when both -p and -1 are specified + +Bugs fixed +---------- + +* 2027_ - Racy backend selection +* 2024_ - panic vmod_rr_resolve() round_robin.c line 75 (be) != NULL +* 2011_ - VBE.*.conn (concurrent connections to backend) not working as expected +* 2008_ - Assert error in VBE_Delete() +* 2007_ - Update documentation part about CLI/management port authentication paramater +* 1881_ - std.cache_req_body() w/ return(pipe) is broken + +.. _2027: https://github.com/varnishcache/varnish-cache/issues/2027 +.. _2024: https://github.com/varnishcache/varnish-cache/issues/2024 +.. _2011: https://github.com/varnishcache/varnish-cache/issues/2011 +.. _2008: https://github.com/varnishcache/varnish-cache/issues/2008 +.. _2007: https://github.com/varnishcache/varnish-cache/issues/2007 +.. _1881: https://github.com/varnishcache/varnish-cache/issues/1881 + +================================ +Varnish Cache 4.1.3 (2016-07-06) +================================ + +Changes since 4.1.3-beta2: + +* Be stricter when parsing request headers to harden against smuggling attacks. + +====================================== +Varnish Cache 4.1.3-beta2 (2016-06-28) +====================================== + +Changes since 4.1.3-beta1: + +* New parameter `vsm_free_cooldown`. Specifies how long freed VSM + memory (shared log) will be kept around before actually being freed. + +* varnishncsa now accepts `-L` argument to configure the limit on incomplete + transactions kept. (Issue 1994_) + +Bugs fixed +---------- + +* 1984_ - Make the counter vsm_cooling act according to spec +* 1963_ - Avoid abort when changing to a VCL name which is a path +* 1933_ - Don't trust dlopen refcounting + +.. _1994: https://github.com/varnishcache/varnish-cache/issues/1994 +.. _1984: https://github.com/varnishcache/varnish-cache/issues/1984 +.. _1963: https://github.com/varnishcache/varnish-cache/issues/1963 +.. _1933: https://github.com/varnishcache/varnish-cache/issues/1933 + ====================================== Varnish Cache 4.1.3-beta1 (2016-06-15) ====================================== From hermunn at varnish-software.com Mon Feb 13 16:52:05 2017 From: hermunn at varnish-software.com (Pål Hermunn Johansen) Date: Mon, 13 Feb 2017 17:52:05 +0100 Subject: [master] f4dfdb0 No more "changes since" in the changelog Message-ID: commit f4dfdb0600c3095103ad045bc0e0f2dec78a48a4 Author: P?l Hermunn Johansen Date: Mon Feb 13 17:24:31 2017 +0100 No more "changes since" in the changelog Headings starting with "Changes since" looked redundant, and has been removed. The result is a slightly more consistent changelog. diff --git a/doc/changes.rst b/doc/changes.rst index 54a42c6..9d9b091 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -85,8 +85,6 @@ Varnish Cache 4.1.5 (2017-02-09) Varnish Cache 4.1.5-beta2 (2017-02-08) ====================================== -Changes since 4.1.5-beta1: - * Update devicedetect.vcl Bugs fixed @@ -107,8 +105,6 @@ Bugs fixed Varnish Cache 4.1.5-beta1 (2017-02-02) ====================================== -Changes since 4.1.4: - Bugs fixed ---------- @@ -141,8 +137,6 @@ Bugs fixed Varnish Cache 4.1.4 (2016-12-01) ================================ -Changes since 4.1.4-beta3: - Bugs fixed ---------- @@ -155,8 +149,6 @@ Bugs fixed Varnish Cache 4.1.4-beta3 (2016-11-24) ====================================== -Changes since 4.1.4-beta2: - * Include the current time of the panic in the panic output * Keep a reserve of idle threads for vital tasks @@ -195,8 +187,6 @@ Bugs fixed Varnish Cache 4.1.4-beta1 (2016-09-14) ====================================== -Changes since 4.1.3: - * [varnishhist] Various improvements * [varnishtest] A `cmd` feature for custom shell-based checks * Documentation improvements (do_stream, sess_herd, timeout_linger, thread_pools) @@ -223,16 +213,12 @@ Bugs fixed Varnish Cache 4.1.3 (2016-07-06) ================================ -Changes since 4.1.3-beta2: - * Be stricter when parsing request headers to harden against smuggling attacks. ====================================== Varnish Cache 4.1.3-beta2 (2016-06-28) ====================================== -Changes since 4.1.3-beta1: - * New parameter `vsm_free_cooldown`. Specifies how long freed VSM memory (shared log) will be kept around before actually being freed. @@ -255,8 +241,6 @@ Bugs fixed Varnish Cache 4.1.3-beta1 (2016-06-15) ====================================== -Changes since 4.1.2: - * varnishncsa can now access and log backend requests. (PR #1905) * [varnishncsa] New output formatters %{Varnish:vxid}x and %{VSL:Tag}x. @@ -432,8 +416,6 @@ Bugs fixed Varnish Cache 4.1.1-beta1 (2016-01-15) ====================================== -Changes since 4.1.0: - - Format of "ban.list" has changed slightly. - [varnishncsa] -w is now required when running deamonized. - [varnishncsa] Log format can now be read from file. @@ -487,8 +469,6 @@ Bugs fixed Varnish Cache 4.1.0 (2015-09-30) ================================ -Changes since 4.1.0-beta1: - - Documentation updates. - Stabilization fixes on testcase p00005.vtc. - Avoid compiler warning in zlib. @@ -501,8 +481,6 @@ Changes since 4.1.0-beta1: Varnish Cache 4.1.0-beta1 (2015-09-11) ====================================== -Changes since 4.1.0-tp1: - - Redhat packaging files are now separate from the normal tree. - Client workspace overflow should now result in a 500 response instead of panic. @@ -565,8 +543,6 @@ Bugs fixed Changes from 4.0.3-rc1 to 4.0.3-rc2 (2015-01-28) ================================================ -Changes since 4.0.3-rc1: - - Assorted documentation updates. Bugs fixed @@ -594,8 +570,6 @@ Bugs fixed Changes from 4.0.2 to 4.0.3-rc1 (2015-01-15) ============================================ -Changes since 4.0.2: - - Support older autoconf (< 2.63b) (el5) - A lot of minor documentation fixes. - bereq.uncacheable is now read-only. From hermunn at varnish-software.com Mon Feb 13 16:52:05 2017 From: hermunn at varnish-software.com (Pål Hermunn Johansen) Date: Mon, 13 Feb 2017 17:52:05 +0100 Subject: [master] e3ef0db Update links Message-ID: commit e3ef0db30bab1b57ddd2a92448200a43212d86ba Author: P?l Hermunn Johansen Date: Mon Feb 13 17:41:14 2017 +0100 Update links Links to on the form https://www.varnish-cache.org/trac/ticket/ are now https://github.com/varnishcache/varnish-cache/issues/, at least near the top. diff --git a/doc/changes.rst b/doc/changes.rst index 9d9b091..5f5afde 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -31,11 +31,11 @@ Issues fixed: * 2008_ - Panic: Assert error in VBE_Delete() * 1800_ - PRIV_TASK in vcl_init/fini -.. _2086: https://www.varnish-cache.org/trac/ticket/2086 -.. _2054: https://www.varnish-cache.org/trac/ticket/2054 -.. _2022: https://www.varnish-cache.org/trac/ticket/2022 -.. _2008: https://www.varnish-cache.org/trac/ticket/2008 -.. _1800: https://www.varnish-cache.org/trac/ticket/1800 +.. _2086: https://github.com/varnishcache/varnish-cache/issues/2086 +.. _2054: https://github.com/varnishcache/varnish-cache/issues/2054 +.. _2022: https://github.com/varnishcache/varnish-cache/issues/2022 +.. _2008: https://github.com/varnishcache/varnish-cache/issues/2008 +.. _1800: https://github.com/varnishcache/varnish-cache/issues/1800 ====================================== From phk at FreeBSD.org Mon Feb 13 19:16:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 13 Feb 2017 20:16:05 +0100 Subject: [master] c2b0624 Clarify that usage() doesn't return for Coverity. Message-ID: commit c2b06248db1dca5af2e697116debde0f6eec0d09 Author: Poul-Henning Kamp Date: Mon Feb 13 19:14:42 2017 +0000 Clarify that usage() doesn't return for Coverity. diff --git a/bin/varnishlog/varnishlog.c b/bin/varnishlog/varnishlog.c index f4415a1..6fd36b4 100644 --- a/bin/varnishlog/varnishlog.c +++ b/bin/varnishlog/varnishlog.c @@ -62,7 +62,7 @@ static struct log { FILE *fo; } LOG; -static void +static void __attribute__((__noreturn__)) usage(int status) { const char **opt; From phk at FreeBSD.org Mon Feb 13 19:28:06 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 13 Feb 2017 20:28:06 +0100 Subject: [master] e2090b4 This cannot overflow the buffer, but Coverity can't guess that. Message-ID: commit e2090b492848b262ba6206d2f24cfcdb0ea1a5f6 Author: Poul-Henning Kamp Date: Mon Feb 13 19:27:20 2017 +0000 This cannot overflow the buffer, but Coverity can't guess that. diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c index 3ee8dc0..e45e29a 100644 --- a/bin/varnishtest/vtc_varnish.c +++ b/bin/varnishtest/vtc_varnish.c @@ -822,12 +822,10 @@ do_stat_dump_cb(void *priv, const struct VSC_point * const pt) u = *(const volatile uint64_t*)pt->ptr; strcpy(buf, pt->section->type); - if (pt->section->ident[0] != '\0') { - strcat(buf, "."); - strcat(buf, pt->section->ident); - } - strcat(buf, "."); - strcat(buf, pt->desc->name); + if (pt->section->ident[0] != '\0') + bprintf(buf, ".%s.%s", pt->section->ident, pt->desc->name); + else + bprintf(buf, ".%s", pt->desc->name); if (strcmp(dp->arg, "*")) { if (fnmatch(dp->arg, buf, 0)) From fgsch at lodoss.net Mon Feb 13 20:26:05 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Mon, 13 Feb 2017 21:26:05 +0100 Subject: [master] 929254c Polish Message-ID: commit 929254c7f901cf5fc696f639f8252fd3aebf04aa Author: Federico G. Schwindt Date: Mon Feb 13 12:55:07 2017 +0000 Polish diff --git a/lib/libvcc/vcc_expr.c b/lib/libvcc/vcc_expr.c index ce6395d..5ec79cc 100644 --- a/lib/libvcc/vcc_expr.c +++ b/lib/libvcc/vcc_expr.c @@ -1002,22 +1002,21 @@ static const struct adds { vcc_type_t b; vcc_type_t fmt; } vcc_adds[] = { - /* OK */ - { '-', TIME, TIME, DURATION }, - { '+', TIME, DURATION, TIME }, - { '-', TIME, DURATION, TIME }, - { '+', DURATION, DURATION, DURATION }, - { '-', DURATION, DURATION, DURATION }, { '+', BYTES, BYTES, BYTES }, { '-', BYTES, BYTES, BYTES }, + { '+', DURATION, DURATION, DURATION }, + { '-', DURATION, DURATION, DURATION }, { '+', INT, INT, INT }, { '-', INT, INT, INT }, - { '+', REAL, REAL, REAL }, - { '-', REAL, REAL, REAL }, - { '+', REAL, INT, REAL }, - { '-', REAL, INT, REAL }, { '+', INT, REAL, REAL }, { '-', INT, REAL, REAL }, + { '+', REAL, INT, REAL }, + { '-', REAL, INT, REAL }, + { '+', REAL, REAL, REAL }, + { '-', REAL, REAL, REAL }, + { '-', TIME, TIME, DURATION }, + { '+', TIME, DURATION, TIME }, + { '-', TIME, DURATION, TIME }, { EOI, VOID, VOID, VOID } }; @@ -1053,10 +1052,7 @@ vcc_expr_add(struct vcc *tl, struct expr **e, vcc_type_t fmt) while (tl->t->tok == '+' || tl->t->tok == '-') { tk = tl->t; vcc_NextToken(tl); - if (f2 == TIME) - vcc_expr_mul(tl, &e2, DURATION); - else - vcc_expr_mul(tl, &e2, f2); + vcc_expr_mul(tl, &e2, f2); ERRCHK(tl); for (ap = vcc_adds; ap->op != EOI; ap++) { From fgsch at lodoss.net Mon Feb 13 20:26:05 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Mon, 13 Feb 2017 21:26:05 +0100 Subject: [master] baee057 Consistency Message-ID: commit baee05738d042b0a98e02d0d725f43a4a941dfdd Author: Federico G. Schwindt Date: Mon Feb 13 20:23:04 2017 +0000 Consistency diff --git a/bin/varnishncsa/varnishncsa.c b/bin/varnishncsa/varnishncsa.c index 2e0f14e..bec05e5 100644 --- a/bin/varnishncsa/varnishncsa.c +++ b/bin/varnishncsa/varnishncsa.c @@ -1217,10 +1217,10 @@ main(int argc, char * const *argv) openout(CTX.a_opt); AN(CTX.fo); if (VUT.D_opt) - VUT.sighup_f = &rotateout; + VUT.sighup_f = rotateout; } else CTX.fo = stdout; - VUT.idle_f = &flushout; + VUT.idle_f = flushout; VUT_Setup(); VUT_Main(); diff --git a/lib/libvarnishapi/vut.c b/lib/libvarnishapi/vut.c index 3d724c4..0783f7d 100644 --- a/lib/libvarnishapi/vut.c +++ b/lib/libvarnishapi/vut.c @@ -363,7 +363,7 @@ VUT_Main(void) if (VUT.sighup && VUT.sighup_f) { /* sighup callback */ VUT.sighup = 0; - i = (VUT.sighup_f)(); + i = VUT.sighup_f(); if (i) break; } @@ -402,7 +402,7 @@ VUT_Main(void) else if (i == 0) { /* Nothing to do but wait */ if (VUT.idle_f) { - i = (VUT.idle_f)(); + i = VUT.idle_f(); if (i) break; } From guillaume at varnish-software.com Tue Feb 14 09:56:05 2017 From: guillaume at varnish-software.com (Guillaume Quintard) Date: Tue, 14 Feb 2017 10:56:05 +0100 Subject: [master] 9a8279b Assert on the right variable Message-ID: commit 9a8279b7e6c0f784dd4f9742b38032d12dd556d6 Author: Guillaume Quintard Date: Tue Feb 14 09:56:46 2017 +0100 Assert on the right variable diff --git a/bin/varnishtest/vtc_http2.c b/bin/varnishtest/vtc_http2.c index 542f2db..614f197 100644 --- a/bin/varnishtest/vtc_http2.c +++ b/bin/varnishtest/vtc_http2.c @@ -1654,7 +1654,7 @@ cmd_txdata(CMD_ARGS) av++; body = strdup(*av); } else if (!strcmp(*av, "-datalen")) { - AZ(data); + AZ(body); av++; body = synth_body(*av, 0); } else if (!strcmp(*av, "-pad")) { From guillaume at varnish-software.com Tue Feb 14 09:56:05 2017 From: guillaume at varnish-software.com (Guillaume Quintard) Date: Tue, 14 Feb 2017 10:56:05 +0100 Subject: [master] 607e189 -some must have a non-zero arg Message-ID: commit 607e189039187c878b364338626e993d40c03e19 Author: Guillaume Quintard Date: Tue Feb 14 10:13:29 2017 +0100 -some must have a non-zero arg diff --git a/bin/varnishtest/vtc_http2.c b/bin/varnishtest/vtc_http2.c index 614f197..aef46dd 100644 --- a/bin/varnishtest/vtc_http2.c +++ b/bin/varnishtest/vtc_http2.c @@ -2159,9 +2159,12 @@ cmd_rxcont(CMD_ARGS) CAST_OBJ_NOTNULL(s, priv, STREAM_MAGIC); while (*++av) - if (!strcmp(*av, "-some")) - STRTOU32_CHECK(times, av, p, vl, "-some", 0); - else if (!strcmp(*av, "-all")) + if (!strcmp(*av, "-some")) { + STRTOU32(times, *av, p, vl, "-some"); + if (time <= 0) + vtc_fatal(vl, "-some argument must be more" + "than 0 (found \"%s\")\n", *av); + } else if (!strcmp(*av, "-all")) loop = 1; else break; From guillaume at varnish-software.com Tue Feb 14 09:56:05 2017 From: guillaume at varnish-software.com (Guillaume Quintard) Date: Tue, 14 Feb 2017 10:56:05 +0100 Subject: [master] eaca897 Check pthread_cond_init's return Message-ID: commit eaca897b57404855b2145007ee2e0b06417c1eff Author: Guillaume Quintard Date: Tue Feb 14 10:14:13 2017 +0100 Check pthread_cond_init's return diff --git a/bin/varnishtest/vtc_http2.c b/bin/varnishtest/vtc_http2.c index aef46dd..26af037 100644 --- a/bin/varnishtest/vtc_http2.c +++ b/bin/varnishtest/vtc_http2.c @@ -2556,7 +2556,7 @@ stream_new(const char *name, struct http *h) ALLOC_OBJ(s, STREAM_MAGIC); AN(s); - pthread_cond_init(&s->cond, NULL); + AZ(pthread_cond_init(&s->cond, NULL)); REPLACE(s->name, name); AN(name); VTAILQ_INIT(&s->fq); From guillaume at varnish-software.com Tue Feb 14 09:56:05 2017 From: guillaume at varnish-software.com (Guillaume Quintard) Date: Tue, 14 Feb 2017 10:56:05 +0100 Subject: [master] 82ad97a Make sure we ask for at least one frame Message-ID: commit 82ad97ab60f873514b06d2296c147f01ac2272dc Author: Guillaume Quintard Date: Tue Feb 14 10:17:36 2017 +0100 Make sure we ask for at least one frame diff --git a/bin/varnishtest/vtc_http2.c b/bin/varnishtest/vtc_http2.c index 26af037..a692953 100644 --- a/bin/varnishtest/vtc_http2.c +++ b/bin/varnishtest/vtc_http2.c @@ -2209,9 +2209,12 @@ cmd_rxdata(CMD_ARGS) CAST_OBJ_NOTNULL(s, priv, STREAM_MAGIC); while (*++av) - if (!strcmp(*av, "-some")) - STRTOU32_CHECK(times, av, p, vl, "-some", 0); - else if (!strcmp(*av, "-all")) + if (!strcmp(*av, "-some")) { + STRTOU32(times, *av, p, vl, "-some"); + if (time <= 0) + vtc_fatal(vl, "-some argument must be more" + "than 0 (found \"%s\")\n", *av); + } else if (!strcmp(*av, "-all")) loop = 1; else break; From guillaume at varnish-software.com Tue Feb 14 09:56:05 2017 From: guillaume at varnish-software.com (Guillaume Quintard) Date: Tue, 14 Feb 2017 10:56:05 +0100 Subject: [master] 8e4be28 Remove useless memcpy Message-ID: commit 8e4be28310e11a67ca65561286537e02e0e6d7a9 Author: Guillaume Quintard Date: Tue Feb 14 10:28:29 2017 +0100 Remove useless memcpy diff --git a/bin/varnishtest/vtc_h2_hpack.c b/bin/varnishtest/vtc_h2_hpack.c index 695d2d7..a0b14d0 100644 --- a/bin/varnishtest/vtc_h2_hpack.c +++ b/bin/varnishtest/vtc_h2_hpack.c @@ -266,7 +266,6 @@ str_decode(struct hpk_iter *iter, struct txt *t) /* XXX: do we care? */ t->ptr = realloc(t->ptr, num + 1L); AN(t->ptr); - memcpy(t->ptr, t->ptr, num); } else { /* literal string */ t->huff = 0; t->ptr = malloc(num + 1L); From guillaume at varnish-software.com Tue Feb 14 09:56:05 2017 From: guillaume at varnish-software.com (Guillaume Quintard) Date: Tue, 14 Feb 2017 10:56:05 +0100 Subject: [master] 13716ff Silent coverity Message-ID: commit 13716ffbe76e7139960f9bbca0f974ab79b3d78d Author: Guillaume Quintard Date: Tue Feb 14 10:33:45 2017 +0100 Silent coverity diff --git a/bin/varnishtest/vtc_h2_hpack.c b/bin/varnishtest/vtc_h2_hpack.c index a0b14d0..447d59a 100644 --- a/bin/varnishtest/vtc_h2_hpack.c +++ b/bin/varnishtest/vtc_h2_hpack.c @@ -88,6 +88,7 @@ huff_decode(char *str, int nm, struct hpk_iter *iter, int ilen) if (sym->csm == 0 || pl < sym->csm) return (0); + assert(sym->csm <= 8); pack <<= sym->csm; assert(sym->csm <= pl); pl -= sym->csm; From guillaume at varnish-software.com Tue Feb 14 14:10:06 2017 From: guillaume at varnish-software.com (Guillaume Quintard) Date: Tue, 14 Feb 2017 15:10:06 +0100 Subject: [master] d1d1b78 calloc instead malloc to calm coverity Message-ID: commit d1d1b78059cddf3d27986759af9d57575c77ea4a Author: Guillaume Quintard Date: Tue Feb 14 15:07:55 2017 +0100 calloc instead malloc to calm coverity diff --git a/bin/varnishtest/vtc_http.c b/bin/varnishtest/vtc_http.c index 9266bdc..77a545e 100644 --- a/bin/varnishtest/vtc_http.c +++ b/bin/varnishtest/vtc_http.c @@ -1415,7 +1415,7 @@ cmd_http_sendhex(CMD_ARGS) AN(av[1]); AZ(av[2]); l = strlen(av[1]) / 2; - p = malloc(l); + p = calloc(1, l); AN(p); q = av[1]; for (i = 0; i < l; i++) { From guillaume at varnish-software.com Tue Feb 14 14:10:06 2017 From: guillaume at varnish-software.com (Guillaume Quintard) Date: Tue, 14 Feb 2017 15:10:06 +0100 Subject: [master] 6017d5f Fix typo Message-ID: commit 6017d5f53d932b24eaa16a2f9e4314a081ca1c20 Author: Guillaume Quintard Date: Tue Feb 14 15:09:08 2017 +0100 Fix typo diff --git a/bin/varnishtest/vtc_http2.c b/bin/varnishtest/vtc_http2.c index a692953..ed4a9de 100644 --- a/bin/varnishtest/vtc_http2.c +++ b/bin/varnishtest/vtc_http2.c @@ -2161,7 +2161,7 @@ cmd_rxcont(CMD_ARGS) while (*++av) if (!strcmp(*av, "-some")) { STRTOU32(times, *av, p, vl, "-some"); - if (time <= 0) + if (times <= 0) vtc_fatal(vl, "-some argument must be more" "than 0 (found \"%s\")\n", *av); } else if (!strcmp(*av, "-all")) @@ -2211,7 +2211,7 @@ cmd_rxdata(CMD_ARGS) while (*++av) if (!strcmp(*av, "-some")) { STRTOU32(times, *av, p, vl, "-some"); - if (time <= 0) + if (times <= 0) vtc_fatal(vl, "-some argument must be more" "than 0 (found \"%s\")\n", *av); } else if (!strcmp(*av, "-all")) From guillaume at varnish-software.com Tue Feb 14 14:18:05 2017 From: guillaume at varnish-software.com (Guillaume Quintard) Date: Tue, 14 Feb 2017 15:18:05 +0100 Subject: [master] 280da2d times are unsigned long, not int Message-ID: commit 280da2d6723cdd6193d7428399848f963c5c462e Author: Guillaume Quintard Date: Tue Feb 14 15:17:49 2017 +0100 times are unsigned long, not int diff --git a/bin/varnishtest/vtc_http2.c b/bin/varnishtest/vtc_http2.c index ed4a9de..d40bbfa 100644 --- a/bin/varnishtest/vtc_http2.c +++ b/bin/varnishtest/vtc_http2.c @@ -2115,7 +2115,7 @@ cmd_rxhdrs(CMD_ARGS) struct frame *f = NULL; char *p; int loop = 0; - int times = 1; + unsigned long int times = 1; int rcv = 0; enum h2_type expect = TYPE_HEADERS; @@ -2125,7 +2125,9 @@ cmd_rxhdrs(CMD_ARGS) while (*++av) { if (!strcmp(*av, "-some")) { STRTOU32_CHECK(times, av, p, vl, "-some", 0); - AN(times); + if (!times) + vtc_fatal(vl, "-some argument must be more" + "than 0 (found \"%s\")\n", *av); } else if (!strcmp(*av, "-all")) loop = 1; else @@ -2151,7 +2153,7 @@ cmd_rxcont(CMD_ARGS) struct frame *f = NULL; char *p; int loop = 0; - int times = 1; + unsigned long int times = 1; int rcv = 0; (void)cmd; @@ -2161,7 +2163,7 @@ cmd_rxcont(CMD_ARGS) while (*++av) if (!strcmp(*av, "-some")) { STRTOU32(times, *av, p, vl, "-some"); - if (times <= 0) + if (!times) vtc_fatal(vl, "-some argument must be more" "than 0 (found \"%s\")\n", *av); } else if (!strcmp(*av, "-all")) @@ -2201,7 +2203,7 @@ cmd_rxdata(CMD_ARGS) struct frame *f = NULL; char *p; int loop = 0; - int times = 1; + unsigned long int times = 1; int rcv = 0; (void)cmd; @@ -2211,7 +2213,7 @@ cmd_rxdata(CMD_ARGS) while (*++av) if (!strcmp(*av, "-some")) { STRTOU32(times, *av, p, vl, "-some"); - if (times <= 0) + if (!times) vtc_fatal(vl, "-some argument must be more" "than 0 (found \"%s\")\n", *av); } else if (!strcmp(*av, "-all")) @@ -2301,7 +2303,7 @@ cmd_rxpush(CMD_ARGS) struct frame *f = NULL; char *p; int loop = 0; - int times = 1; + unsigned long int times = 1; int rcv = 0; enum h2_type expect = TYPE_PUSH_PROMISE; @@ -2311,7 +2313,9 @@ cmd_rxpush(CMD_ARGS) while (*++av) { if (!strcmp(*av, "-some")) { STRTOU32_CHECK(times, av, p, vl, "-some", 0); - AN(times); + if (!times) + vtc_fatal(vl, "-some argument must be more" + "than 0 (found \"%s\")\n", *av); } else if (!strcmp(*av, "-all")) { loop = 1; } else From guillaume at varnish-software.com Tue Feb 14 14:50:06 2017 From: guillaume at varnish-software.com (Guillaume Quintard) Date: Tue, 14 Feb 2017 15:50:06 +0100 Subject: [master] 14be194 Use do/while to reassure coverity Message-ID: commit 14be19463659016c0369de0ac525c22f1fbe2dc1 Author: Guillaume Quintard Date: Tue Feb 14 15:49:54 2017 +0100 Use do/while to reassure coverity diff --git a/bin/varnishtest/vtc_http2.c b/bin/varnishtest/vtc_http2.c index d40bbfa..5b6b9c2 100644 --- a/bin/varnishtest/vtc_http2.c +++ b/bin/varnishtest/vtc_http2.c @@ -2136,13 +2136,14 @@ cmd_rxhdrs(CMD_ARGS) if (*av != NULL) vtc_fatal(vl, "Unknown rxhdrs spec: %s\n", *av); - while (rcv++ < times || (loop && !(f->flags & END_HEADERS))) { + do { f = rxstuff(s); if (!f) return; + rcv++; CHKFRAME(f->type, expect, rcv, "rxhdrs"); expect = TYPE_CONTINUATION; - } + } while (rcv < times || (loop && !(f->flags & END_HEADERS))); s->frame = f; } @@ -2173,12 +2174,13 @@ cmd_rxcont(CMD_ARGS) if (*av != NULL) vtc_fatal(vl, "Unknown rxcont spec: %s\n", *av); - while (rcv++ < times || (loop && !(f->flags & END_HEADERS))) { + do { f = rxstuff(s); if (!f) return; + rcv++; CHKFRAME(f->type, TYPE_CONTINUATION, rcv, "rxcont"); - } + } while (rcv < times || (loop && !(f->flags & END_HEADERS))); s->frame = f; } @@ -2223,12 +2225,13 @@ cmd_rxdata(CMD_ARGS) if (*av != NULL) vtc_fatal(vl, "Unknown rxdata spec: %s\n", *av); - while (rcv++ < times || (loop && !(f->flags & END_STREAM))) { + do { f = rxstuff(s); if (!f) return; + rcv++; CHKFRAME(f->type, TYPE_DATA, rcv, "rxhdata"); - } + } while (rcv < times || (loop && !(f->flags & END_STREAM))); s->frame = f; } @@ -2324,13 +2327,14 @@ cmd_rxpush(CMD_ARGS) if (*av != NULL) vtc_fatal(vl, "Unknown rxpush spec: %s\n", *av); - while (rcv++ < times || (loop && !(f->flags & END_HEADERS))) { + do { f = rxstuff(s); if (!f) return; + rcv++; CHKFRAME(f->type, expect, rcv, "rxpush"); expect = TYPE_CONTINUATION; - } + } while (rcv < times || (loop && !(f->flags & END_HEADERS))); s->frame = f; } From fgsch at lodoss.net Wed Feb 15 00:46:04 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Wed, 15 Feb 2017 01:46:04 +0100 Subject: [master] e012464 Whitespace Message-ID: commit e0124640756e7d296de8d00ce9ce352d44e36fc7 Author: Federico G. Schwindt Date: Mon Feb 13 20:44:20 2017 +0000 Whitespace diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c index e45e29a..9616260 100644 --- a/bin/varnishtest/vtc_varnish.c +++ b/bin/varnishtest/vtc_varnish.c @@ -822,7 +822,7 @@ do_stat_dump_cb(void *priv, const struct VSC_point * const pt) u = *(const volatile uint64_t*)pt->ptr; strcpy(buf, pt->section->type); - if (pt->section->ident[0] != '\0') + if (pt->section->ident[0] != '\0') bprintf(buf, ".%s.%s", pt->section->ident, pt->desc->name); else bprintf(buf, ".%s", pt->desc->name); From fgsch at lodoss.net Wed Feb 15 00:46:04 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Wed, 15 Feb 2017 01:46:04 +0100 Subject: [master] 89619ad Instead of exiting tell the loop we are quitting Message-ID: commit 89619adbb995f4d397500304a1068f0aabac462b Author: Federico G. Schwindt Date: Wed Feb 15 00:36:38 2017 +0000 Instead of exiting tell the loop we are quitting While here rearrange variables to be more consistent. diff --git a/bin/varnishhist/varnishhist.c b/bin/varnishhist/varnishhist.c index 4c22994..edb9044 100644 --- a/bin/varnishhist/varnishhist.c +++ b/bin/varnishhist/varnishhist.c @@ -131,6 +131,8 @@ profiles[] = { static struct profile *active_profile; +volatile sig_atomic_t quit = 0; + static void update(void) { @@ -369,7 +371,8 @@ accumulate(struct VSL_data *vsl, struct VSL_transaction * const pt[], static int __match_proto__(VUT_cb_f) sighup(void) { - exit(1); + quit = 1; + return (1); } static void * @@ -385,7 +388,7 @@ do_curses(void *arg) intrflush(stdscr, FALSE); curs_set(0); erase(); - for (;;) { + while (!quit) { AZ(pthread_mutex_lock(&mtx)); update(); AZ(pthread_mutex_unlock(&mtx)); @@ -414,7 +417,7 @@ do_curses(void *arg) case 'q': raise(SIGINT); endwin(); - pthread_exit(NULL); + return (NULL); case '0': case '1': case '2': @@ -458,7 +461,8 @@ do_curses(void *arg) AZ(pthread_mutex_unlock(&mtx)); } } - NEEDLESS(pthread_exit(NULL)); + endwin(); + return (NULL); } /*--------------------------------------------------------------------*/ diff --git a/bin/varnishtop/varnishtop.c b/bin/varnishtop/varnishtop.c index 7addb28..0c08e02 100644 --- a/bin/varnishtop/varnishtop.c +++ b/bin/varnishtop/varnishtop.c @@ -61,10 +61,6 @@ #define AC(x) x #endif -static const char progname[] = "varnishtop"; -static float period = 60; /* seconds */ -static int end_of_file = 0; - struct top { uint8_t tag; const char *rec_data; @@ -76,6 +72,16 @@ struct top { double count; }; +static const char progname[] = "varnishtop"; +static float period = 60; /* seconds */ +static int end_of_file = 0; +static unsigned ntop; +static pthread_mutex_t mtx = PTHREAD_MUTEX_INITIALIZER; +static int f_flag = 0; +static unsigned maxfieldlen = 0; + +volatile sig_atomic_t quit = 0; + static VRB_HEAD(t_order, top) h_order = VRB_INITIALIZER(&h_order); static VRB_HEAD(t_key, top) h_key = VRB_INITIALIZER(&h_key); @@ -101,14 +107,6 @@ cmp_order(const struct top *a, const struct top *b) return (cmp_key(a, b)); } -static unsigned ntop; - -static pthread_mutex_t mtx = PTHREAD_MUTEX_INITIALIZER; - -static int f_flag = 0; - -static unsigned maxfieldlen = 0; - VRB_PROTOTYPE_STATIC(t_order, top, e_order, cmp_order) VRB_GENERATE_STATIC(t_order, top, e_order, cmp_order) VRB_PROTOTYPE_STATIC(t_key, top, e_key, cmp_key) @@ -183,7 +181,8 @@ accumulate(struct VSL_data *vsl, struct VSL_transaction * const pt[], static int __match_proto__(VUT_cb_f) sighup(void) { - exit (1); + quit = 1; + return (1); } static void @@ -258,7 +257,7 @@ do_curses(void *arg) AC(intrflush(stdscr, FALSE)); (void)curs_set(0); AC(erase()); - for (;;) { + while (!quit) { AZ(pthread_mutex_lock(&mtx)); update(period); AZ(pthread_mutex_unlock(&mtx)); @@ -287,13 +286,14 @@ do_curses(void *arg) case 'q': AZ(raise(SIGINT)); AC(endwin()); - return NULL; + return (NULL); default: AC(beep()); break; } } - NEEDLESS(return NULL); + AC(endwin()); + return (NULL); } static void From fgsch at lodoss.net Wed Feb 15 00:57:05 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Wed, 15 Feb 2017 01:57:05 +0100 Subject: [master] bb79466 Remove dead code Message-ID: commit bb79466d1c8675ec22385d36394ebaa209f01232 Author: Federico G. Schwindt Date: Wed Feb 15 00:55:23 2017 +0000 Remove dead code Spotted by coverity. diff --git a/bin/varnishd/http2/cache_http2_hpack.c b/bin/varnishd/http2/cache_http2_hpack.c index 16bf33c..59d9468 100644 --- a/bin/varnishd/http2/cache_http2_hpack.c +++ b/bin/varnishd/http2/cache_http2_hpack.c @@ -94,8 +94,7 @@ h2h_addhdr(struct http *hp, char *b, size_t namelen, size_t len) assert(namelen <= len); if (len > UINT_MAX) { /* XXX: cache_param max header size */ - VSLb(hp->vsl, SLT_BogoHeader, "Header too large: %.*s", - (int)(len > 20 ? 20 : len), b); + VSLb(hp->vsl, SLT_BogoHeader, "Header too large: %.20s", b); return (H2E_ENHANCE_YOUR_CALM); } From phk at FreeBSD.org Wed Feb 15 11:54:04 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 15 Feb 2017 12:54:04 +0100 Subject: [master] c1cf8d3 Turn the snapshot tokens from WS into uintptr_t to make it very clear that you are not supposed to use them as pointers. Message-ID: commit c1cf8d37ee0f07890e9c763de838130862a71c5f Author: Poul-Henning Kamp Date: Wed Feb 15 09:21:33 2017 +0000 Turn the snapshot tokens from WS into uintptr_t to make it very clear that you are not supposed to use them as pointers. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index ddecdf6..cf6e317 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -468,7 +468,7 @@ struct busyobj { struct vfp_ctx vfc[1]; struct ws ws[1]; - char *ws_bo; + uintptr_t ws_bo; struct http *bereq0; struct http *bereq; struct http *beresp; @@ -558,7 +558,7 @@ struct req { const struct director *director_hint; struct vcl *vcl; - char *ws_req; /* WS above request data */ + uintptr_t ws_req; /* WS above request data */ /* Timestamps */ double t_first; /* First timestamp logged */ @@ -1062,10 +1062,10 @@ void WS_MarkOverflow(struct ws *ws); void WS_Release(struct ws *ws, unsigned bytes); void WS_ReleaseP(struct ws *ws, char *ptr); void WS_Assert(const struct ws *ws); -void WS_Reset(struct ws *ws, char *p); +void WS_Reset(struct ws *ws, uintptr_t); void *WS_Alloc(struct ws *ws, unsigned bytes); void *WS_Copy(struct ws *ws, const void *str, int len); -char *WS_Snapshot(struct ws *ws); +uintptr_t WS_Snapshot(struct ws *ws); int WS_Overflowed(const struct ws *ws); void *WS_Printf(struct ws *ws, const char *fmt, ...) __v_printflike(2, 3); diff --git a/bin/varnishd/cache/cache_req.c b/bin/varnishd/cache/cache_req.c index fe1598b..0a73e33 100644 --- a/bin/varnishd/cache/cache_req.c +++ b/bin/varnishd/cache/cache_req.c @@ -201,8 +201,8 @@ Req_Cleanup(struct sess *sp, struct worker *wrk, struct req *req) return (1); } - WS_Reset(req->ws, NULL); - WS_Reset(wrk->aws, NULL); + WS_Reset(req->ws, 0); + WS_Reset(wrk->aws, 0); return (0); } diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c index 70de663..4c2e2c6 100644 --- a/bin/varnishd/cache/cache_vcl.c +++ b/bin/varnishd/cache/cache_vcl.c @@ -98,7 +98,7 @@ static struct vcl *vcl_active; /* protected by vcl_mtx */ static struct vrt_ctx ctx_cli; static unsigned handling_cli; static struct ws ws_cli; -static char *ws_snapshot_cli; +static uintptr_t ws_snapshot_cli; /*--------------------------------------------------------------------*/ @@ -1011,7 +1011,7 @@ static void vcl_call_method(struct worker *wrk, struct req *req, struct busyobj *bo, void *specific, unsigned method, vcl_func_f *func) { - char *aws; + uintptr_t aws; struct vsl_log *vsl = NULL; struct vrt_ctx ctx; diff --git a/bin/varnishd/cache/cache_wrk.c b/bin/varnishd/cache/cache_wrk.c index 47b3fd7..e28d993 100644 --- a/bin/varnishd/cache/cache_wrk.c +++ b/bin/varnishd/cache/cache_wrk.c @@ -311,7 +311,7 @@ Pool_Work_Thread(struct pool *pp, struct worker *wrk) CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - WS_Reset(wrk->aws, NULL); + WS_Reset(wrk->aws, 0); AZ(wrk->vsl); if (pp->nidle < pool_reserve()) diff --git a/bin/varnishd/cache/cache_ws.c b/bin/varnishd/cache/cache_ws.c index bc416c9..be68575 100644 --- a/bin/varnishd/cache/cache_ws.c +++ b/bin/varnishd/cache/cache_ws.c @@ -106,10 +106,12 @@ ws_ClearOverflow(struct ws *ws) */ void -WS_Reset(struct ws *ws, char *p) +WS_Reset(struct ws *ws, uintptr_t pp) { + char *p; WS_Assert(ws); + p = (char *)pp; DSL(DBG_WORKSPACE, 0, "WS_Reset(%p, %p)", ws, p); assert(ws->r == NULL); if (p == NULL) @@ -191,14 +193,14 @@ WS_Printf(struct ws *ws, const char *fmt, ...) return (p); } -char * +uintptr_t WS_Snapshot(struct ws *ws) { WS_Assert(ws); assert(ws->r == NULL); DSL(DBG_WORKSPACE, 0, "WS_Snapshot(%p) = %p", ws, ws->f); - return (ws->f); + return ((uintptr_t)ws->f); } unsigned diff --git a/bin/varnishd/http1/cache_http1_line.c b/bin/varnishd/http1/cache_http1_line.c index 8267fca..756fe81 100644 --- a/bin/varnishd/http1/cache_http1_line.c +++ b/bin/varnishd/http1/cache_http1_line.c @@ -60,7 +60,7 @@ struct v1l { struct vsl_log *vsl; ssize_t cnt; /* Flushed byte count */ struct ws *ws; - void *res; + uintptr_t res; }; /*-------------------------------------------------------------------- @@ -72,7 +72,7 @@ V1L_Reserve(struct worker *wrk, struct ws *ws, int *fd, struct vsl_log *vsl, { struct v1l *v1l; unsigned u; - void *res; + uintptr_t res; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); AZ(wrk->v1l); diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index 5acf8a6..82e4f8a 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -690,7 +690,7 @@ h2_new_session(struct worker *wrk, void *arg) struct sess *sp; struct h2_sess *h2; struct h2_req *r2, *r22; - char *wsp; + uintptr_t wsp; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CAST_OBJ_NOTNULL(req, arg, REQ_MAGIC); diff --git a/lib/libvmod_debug/vmod_debug.c b/lib/libvmod_debug/vmod_debug.c index 8cae9f3..78dc111 100644 --- a/lib/libvmod_debug/vmod_debug.c +++ b/lib/libvmod_debug/vmod_debug.c @@ -442,7 +442,7 @@ vmod_workspace_overflowed(VRT_CTX, VCL_ENUM which) return (WS_Overflowed(ws)); } -static char *debug_ws_snap; +static uintptr_t debug_ws_snap; void vmod_workspace_snap(VRT_CTX, VCL_ENUM which) From phk at FreeBSD.org Wed Feb 15 11:54:04 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 15 Feb 2017 12:54:04 +0100 Subject: [master] 92e77b8 Introduce WS_Inside() to reduce the amount of grubbing around inside struct ws. Message-ID: commit 92e77b873d0a0744bfc9fd1e0ba83545c226e750 Author: Poul-Henning Kamp Date: Wed Feb 15 11:22:00 2017 +0000 Introduce WS_Inside() to reduce the amount of grubbing around inside struct ws. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index cf6e317..6bd88e4 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -1068,6 +1068,7 @@ void *WS_Copy(struct ws *ws, const void *str, int len); uintptr_t WS_Snapshot(struct ws *ws); int WS_Overflowed(const struct ws *ws); void *WS_Printf(struct ws *ws, const char *fmt, ...) __v_printflike(2, 3); +int WS_Inside(const struct ws *, const void *, const void *); /* cache_rfc2616.c */ void RFC2616_Ttl(struct busyobj *, double now, double *t_origin, diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c index 23bad44..873bd8a 100644 --- a/bin/varnishd/cache/cache_http.c +++ b/bin/varnishd/cache/cache_http.c @@ -1097,7 +1097,7 @@ http_CopyHome(const struct http *hp) assert(u < HTTP_HDR_FIRST); continue; } - if (hp->hd[u].b >= hp->ws->s && hp->hd[u].e <= hp->ws->e) + if (WS_Inside(hp->ws, hp->hd[u].b, hp->hd[u].e)) continue; l = Tlen(hp->hd[u]); diff --git a/bin/varnishd/cache/cache_ws.c b/bin/varnishd/cache/cache_ws.c index be68575..ec6b2bc 100644 --- a/bin/varnishd/cache/cache_ws.c +++ b/bin/varnishd/cache/cache_ws.c @@ -59,6 +59,21 @@ WS_Assert(const struct ws *ws) assert(*ws->e == 0x15); } +int +WS_Inside(const struct ws *ws, const void *bb, const void *ee) +{ + const char *b = bb; + const char *e = ee; + + WS_Assert(ws); + if (b < ws->s || b >= ws->e) + return (0); + if (e != NULL && (e < b || e > ws->e)) + return (0); + return (1); +} + + /* * NB: The id must be max 3 char and lower-case. * (upper-case the first char to indicate overflow) diff --git a/bin/varnishd/http2/cache_http2_deliver.c b/bin/varnishd/http2/cache_http2_deliver.c index b69b45d..f21631c 100644 --- a/bin/varnishd/http2/cache_http2_deliver.c +++ b/bin/varnishd/http2/cache_http2_deliver.c @@ -137,7 +137,7 @@ h2_deliver(struct req *req, struct boc *boc, int sendbody) hp = req->resp; for (u = HTTP_HDR_FIRST; u < hp->nhd; u++) { - assert((char*)p < req->ws->e); + assert(WS_Inside(req->ws, p, NULL)); r = strchr(hp->hd[u].b, ':'); AN(r); @@ -194,7 +194,7 @@ h2_deliver(struct req *req, struct boc *boc, int sendbody) memcpy(p, r, sz); p += sz; - assert((char*)p < req->ws->e); + assert(WS_Inside(req->ws, p, NULL)); } sz = (char*)p - req->ws->f; From phk at FreeBSD.org Wed Feb 15 11:54:04 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 15 Feb 2017 12:54:04 +0100 Subject: [master] 4e0004e Eliminate some grubbing around inside struct ws Message-ID: commit 4e0004eaa456654975aa0e0a32d51ad57bafd616 Author: Poul-Henning Kamp Date: Wed Feb 15 11:28:15 2017 +0000 Eliminate some grubbing around inside struct ws diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 43d87ca..b2a58a1 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -915,7 +915,7 @@ CNT_Request(struct worker *wrk, struct req *req) * empty on state-transitions. */ WS_Assert(wrk->aws); - assert(wrk->aws->s == wrk->aws->f); + AZ(WS_Snapshot(wrk->aws)); switch (req->req_step) { #define REQ_STEP(l,u,arg) \ diff --git a/bin/varnishd/cache/cache_ws.c b/bin/varnishd/cache/cache_ws.c index ec6b2bc..c4d64cb 100644 --- a/bin/varnishd/cache/cache_ws.c +++ b/bin/varnishd/cache/cache_ws.c @@ -215,7 +215,7 @@ WS_Snapshot(struct ws *ws) WS_Assert(ws); assert(ws->r == NULL); DSL(DBG_WORKSPACE, 0, "WS_Snapshot(%p) = %p", ws, ws->f); - return ((uintptr_t)ws->f); + return (ws->f == ws->s ? 0 : (uintptr_t)ws->f); } unsigned diff --git a/lib/libvmod_debug/vmod_debug.c b/lib/libvmod_debug/vmod_debug.c index 78dc111..76519f7 100644 --- a/lib/libvmod_debug/vmod_debug.c +++ b/lib/libvmod_debug/vmod_debug.c @@ -420,14 +420,17 @@ VCL_INT vmod_workspace_free(VRT_CTX, VCL_ENUM which) { struct ws *ws; + unsigned u; + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); ws = wsfind(ctx, which); WS_Assert(ws); - AZ(ws->r); + u = WS_Reserve(ws, 0); + WS_Release(ws, 0); - return (pdiff(ws->f, ws->e)); + return (u); } VCL_BOOL From phk at FreeBSD.org Wed Feb 15 11:54:04 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 15 Feb 2017 12:54:04 +0100 Subject: [master] 6440798 Introduce WS_ReserveLumps() to allocate an array of something. Message-ID: commit 64407985441e1732cd9ee99f4300b872de71f3a0 Author: Poul-Henning Kamp Date: Wed Feb 15 11:52:43 2017 +0000 Introduce WS_ReserveLumps() to allocate an array of something. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 6bd88e4..d6a5544 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -1058,6 +1058,7 @@ void WRK_BgThread(pthread_t *thr, const char *name, bgthread_t *func, void WS_Init(struct ws *ws, const char *id, void *space, unsigned len); unsigned WS_Reserve(struct ws *ws, unsigned bytes); +unsigned WS_ReserveLumps(struct ws *ws, size_t sz); void WS_MarkOverflow(struct ws *ws); void WS_Release(struct ws *ws, unsigned bytes); void WS_ReleaseP(struct ws *ws, char *ptr); diff --git a/bin/varnishd/cache/cache_ws.c b/bin/varnishd/cache/cache_ws.c index c4d64cb..b2f312e 100644 --- a/bin/varnishd/cache/cache_ws.c +++ b/bin/varnishd/cache/cache_ws.c @@ -241,6 +241,16 @@ WS_Reserve(struct ws *ws, unsigned bytes) return (pdiff(ws->f, ws->r)); } +unsigned +WS_ReserveLumps(struct ws *ws, size_t sz) +{ + unsigned u; + + u = WS_Reserve(ws, 0); + u /= sz; + return (u); +} + void WS_Release(struct ws *ws, unsigned bytes) { diff --git a/bin/varnishd/http1/cache_http1_line.c b/bin/varnishd/http1/cache_http1_line.c index 756fe81..a1b7537 100644 --- a/bin/varnishd/http1/cache_http1_line.c +++ b/bin/varnishd/http1/cache_http1_line.c @@ -88,16 +88,15 @@ V1L_Reserve(struct worker *wrk, struct ws *ws, int *fd, struct vsl_log *vsl, v1l->ws = ws; v1l->res = res; - u = WS_Reserve(ws, 0); - u = PRNDDN(u); - u /= sizeof(struct iovec); + u = WS_ReserveLumps(ws, sizeof(struct iovec)); if (u == 0) { WS_Release(ws, 0); WS_MarkOverflow(ws); return; - } else if (u > IOV_MAX) + } + if (u > IOV_MAX) u = IOV_MAX; - v1l->iov = (void*)PRNDUP(ws->f); + v1l->iov = (void*)ws->f; v1l->siov = u; v1l->ciov = u; v1l->werr = 0; diff --git a/lib/libvmod_std/vmod_std_querysort.c b/lib/libvmod_std/vmod_std_querysort.c index 024b42d..2fae3a1 100644 --- a/lib/libvmod_std/vmod_std_querysort.c +++ b/lib/libvmod_std/vmod_std_querysort.c @@ -56,6 +56,7 @@ vmod_querysort(VRT_CTX, VCL_STRING url) char *p, *r; const char **pp; const char **pe; + unsigned u; int np; int i; @@ -78,16 +79,14 @@ vmod_querysort(VRT_CTX, VCL_STRING url) if (r == NULL) return (url); - (void)WS_Reserve(ctx->ws, 0); - /* We trust cache_ws.c to align sensibly */ + u = WS_ReserveLumps(ctx->ws, sizeof(const char **)); pp = (const char**)(void*)(ctx->ws->f); - pe = (const char**)(void*)(ctx->ws->e); - - if (pp + 4 > pe) { + if (u < 4) { WS_Release(ctx->ws, 0); WS_MarkOverflow(ctx->ws); return (url); } + pe = pp + u; /* Collect params as pointer pairs */ np = 0; From phk at FreeBSD.org Wed Feb 15 14:03:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 15 Feb 2017 15:03:05 +0100 Subject: [master] a6696fc Fix an off-by one causing extremely rare asserts: We must have two free slots, one for the data we want to write and one for the end of chunk bits. Message-ID: commit a6696fc0813c8a8c1519a4ebceea25720f8f7836 Author: Poul-Henning Kamp Date: Wed Feb 15 13:58:34 2017 +0000 Fix an off-by one causing extremely rare asserts: We must have two free slots, one for the data we want to write and one for the end of chunk bits. Fixes: #2207 diff --git a/bin/varnishd/http1/cache_http1_line.c b/bin/varnishd/http1/cache_http1_line.c index a1b7537..2565b05 100644 --- a/bin/varnishd/http1/cache_http1_line.c +++ b/bin/varnishd/http1/cache_http1_line.c @@ -239,7 +239,7 @@ V1L_Write(const struct worker *wrk, const void *ptr, ssize_t len) return (0); if (len == -1) len = strlen(ptr); - if (v1l->niov >= v1l->siov - (v1l->ciov < v1l->siov ? 1 : 0)) + if (v1l->niov >= v1l->siov - (v1l->ciov < v1l->siov ? 2 : 0)) (void)V1L_Flush(wrk); v1l->iov[v1l->niov].iov_base = TRUST_ME(ptr); v1l->iov[v1l->niov].iov_len = len; From varnish-commit at varnish-cache.org Fri Feb 17 00:26:42 2017 From: varnish-commit at varnish-cache.org (=?utf-8?B?5rKD5Yaw5p2+?=) Date: Fri, 17 Feb 2017 08:26:42 +0800 Subject: =?utf-8?B?dmFybmlzaC1jb21taXQ65aaC5L2V5aSE55CG5ZGY?= =?utf-8?B?5bel6L+d57qq6Zeu6aKYPyBxZXhnbWo=?= Message-ID: <20170217082649540423@ecfalc.org> varnish-commit: ?? 1.???????????????????????????? 2.?????????????????? 3.???????????????????????? 4.?????????????????????????? 5.?????????????? 6.?????????????????????????? 7.?????????????????????????? 8.??????????????????? 9.??????????????????????? ??????????????????? ???????????????????? 2017-2-178:26:48 ??? -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: ??????????????????????.docx Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document Size: 27224 bytes Desc: not available URL: From phk at FreeBSD.org Fri Feb 17 11:36:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 17 Feb 2017 12:36:05 +0100 Subject: [master] 77cab36 Start hammering away on H2 again Message-ID: commit 77cab3676155ac3f45db4176795f5621e12be8e6 Author: Poul-Henning Kamp Date: Thu Feb 16 10:06:39 2017 +0000 Start hammering away on H2 again diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index 82e4f8a..04fc842 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -400,7 +400,6 @@ h2_rx_headers(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) * read frames and proper error handling. */ - xxxassert(h2->rxf_stream & 1); xxxassert(r2->state == H2_S_IDLE); r2->state = H2_S_OPEN; @@ -429,7 +428,11 @@ h2_rx_headers(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) /* XXX: Error handling */ p = h2->rxf_data; l = h2->rxf_len; - if (h2->rxf_flags & 0x20) { + if (h2->rxf_flags & H2FF_HEADERS_PADDED) { + l -= 1 + *p; + p += 1; + } + if (h2->rxf_flags & H2FF_HEADERS_PRIORITY) { p += 5; l -= 5; } @@ -518,6 +521,15 @@ h2_rxframe(struct worker *wrk, struct h2_sess *h2) h2_vsl_frame(h2, h2->htc->rxbuf_b, 9L + h2->rxf_len); + if (h2->rxf_stream != 0 && !(h2->rxf_stream & 1)) { + /* We don't do push, so all streams must be zero or odd# */ + Lck_Lock(&h2->sess->mtx); + VSLb(h2->vsl, SLT_Debug, "H2: illegal stream (=%u)", + h2->rxf_stream); + Lck_Unlock(&h2->sess->mtx); + return (0); + } + Lck_Lock(&h2->sess->mtx); VTAILQ_FOREACH(r2, &h2->streams, list) if (r2->stream == h2->rxf_stream) @@ -544,7 +556,10 @@ h2_rxframe(struct worker *wrk, struct h2_sess *h2) break; #include "tbl/h2_frames.h" default: - INCOMPL(); + VSLb(h2->vsl, SLT_Debug, "H2: Bad frame type 0x%02x on ", + h2->htc->rxbuf_b[3]); + Lck_Unlock(&h2->sess->mtx); + return (0); } Lck_Unlock(&h2->sess->mtx); return (1); diff --git a/bin/varnishtest/tests/t02000.vtc b/bin/varnishtest/tests/t02000.vtc index 7ebf4b3..2cd7610 100644 --- a/bin/varnishtest/tests/t02000.vtc +++ b/bin/varnishtest/tests/t02000.vtc @@ -13,7 +13,7 @@ varnish v1 -cliok "param.set debug +syncvsl" client c1 { stream 1 { - txprio -weight 10 -stream 0 + txprio -weight 10 -stream 0 } -run stream 3 { txprio -weight 10 -stream 0 @@ -22,7 +22,7 @@ client c1 { txprio -weight 10 -stream 2 } -run stream 7 { - txreq -hdr :authority foo.bar + txreq -hdr :authority foo.bar -pad cotton rxresp expect resp.status == 200 } -start From phk at FreeBSD.org Fri Feb 17 11:36:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 17 Feb 2017 12:36:05 +0100 Subject: [master] 3f46e4f Add a field which says if H2 error is stream and/or connection error. Message-ID: commit 3f46e4f890914a54d091077a368ae9337b4f62c2 Author: Poul-Henning Kamp Date: Thu Feb 16 15:39:12 2017 +0000 Add a field which says if H2 error is stream and/or connection error. diff --git a/bin/varnishd/http2/cache_http2.h b/bin/varnishd/http2/cache_http2.h index 2fe1c23..d9a231f 100644 --- a/bin/varnishd/http2/cache_http2.h +++ b/bin/varnishd/http2/cache_http2.h @@ -33,7 +33,7 @@ struct h2_sess; enum h2_error_e { H2E__DUMMY = -1, -#define H2_ERROR(NAME, val, desc) \ +#define H2_ERROR(NAME, val, sc, desc) \ H2E_##NAME = val, #include "tbl/h2_error.h" }; diff --git a/bin/varnishtest/tests/t02000.vtc b/bin/varnishtest/tests/t02000.vtc index 2cd7610..2bdfac9 100644 --- a/bin/varnishtest/tests/t02000.vtc +++ b/bin/varnishtest/tests/t02000.vtc @@ -13,7 +13,7 @@ varnish v1 -cliok "param.set debug +syncvsl" client c1 { stream 1 { - txprio -weight 10 -stream 0 + txprio -weight 10 -stream 0 } -run stream 3 { txprio -weight 10 -stream 0 diff --git a/bin/varnishtest/vtc_http2.c b/bin/varnishtest/vtc_http2.c index 5b6b9c2..e87fd88 100644 --- a/bin/varnishtest/vtc_http2.c +++ b/bin/varnishtest/vtc_http2.c @@ -56,7 +56,7 @@ #define BUF_SIZE (1024*2048) static const char *const h2_errs[] = { -#define H2_ERROR(n,v,t) [v] = #n, +#define H2_ERROR(n,v,sc,t) [v] = #n, #include NULL }; diff --git a/include/tbl/h2_error.h b/include/tbl/h2_error.h index c946454..2e157f7 100644 --- a/include/tbl/h2_error.h +++ b/include/tbl/h2_error.h @@ -26,24 +26,26 @@ * SUCH DAMAGE. * * RFC7540 section 11.4 + * + * Fields: Upper, value, conn=1|stream=2, description */ /*lint -save -e525 -e539 */ -H2_ERROR(NO_ERROR, 0x0, "Graceful shutdown") -H2_ERROR(PROTOCOL_ERROR, 0x1, "Protocol error detected") -H2_ERROR(INTERNAL_ERROR, 0x2, "Implementation fault") -H2_ERROR(FLOW_CONTROL_ERROR, 0x3, "Flow-control limits exceeded") -H2_ERROR(SETTINGS_TIMEOUT, 0x4, "Settings not acknowledged") -H2_ERROR(STREAM_CLOSED, 0x5, "Frame received for closed stream") -H2_ERROR(FRAME_SIZE_ERROR, 0x6, "Frame size incorrect") -H2_ERROR(REFUSED_STREAM, 0x7, "Stream not processed") -H2_ERROR(CANCEL, 0x8, "Stream cancelled") -H2_ERROR(COMPRESSION_ERROR, 0x9, "Compression state not updated") -H2_ERROR(CONNECT_ERROR, 0xa, "TCP connection error for CONNECT method") -H2_ERROR(ENHANCE_YOUR_CALM, 0xb, "Processing capacity exceeded") -H2_ERROR(INADEQUATE_SECURITY, 0xc, "Negotiated TLS parameters not acceptable") -H2_ERROR(HTTP_1_1_REQUIRED, 0xd, "Use HTTP/1.1 for the request") +H2_ERROR(NO_ERROR, 0x0,0, "Graceful shutdown") +H2_ERROR(PROTOCOL_ERROR, 0x1,3, "Protocol error detected") +H2_ERROR(INTERNAL_ERROR, 0x2,3, "Implementation fault") +H2_ERROR(FLOW_CONTROL_ERROR, 0x3,3, "Flow-control limits exceeded") +H2_ERROR(SETTINGS_TIMEOUT, 0x4,1, "Settings not acknowledged") +H2_ERROR(STREAM_CLOSED, 0x5,2, "Frame received for closed stream") +H2_ERROR(FRAME_SIZE_ERROR, 0x6,3, "Frame size incorrect") +H2_ERROR(REFUSED_STREAM, 0x7,2, "Stream not processed") +H2_ERROR(CANCEL, 0x8,2, "Stream cancelled") +H2_ERROR(COMPRESSION_ERROR, 0x9,1, "Compression state not updated") +H2_ERROR(CONNECT_ERROR, 0xa,2, "TCP connection error for CONNECT method") +H2_ERROR(ENHANCE_YOUR_CALM, 0xb,3, "Processing capacity exceeded") +H2_ERROR(INADEQUATE_SECURITY,0xc,1, "Negotiated TLS parameters not acceptable") +H2_ERROR(HTTP_1_1_REQUIRED, 0xd,1, "Use HTTP/1.1 for the request") #undef H2_ERROR /*lint -restore */ From phk at FreeBSD.org Fri Feb 17 11:36:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 17 Feb 2017 12:36:05 +0100 Subject: [master] a62435b Introduce a selfdescribing h2_error struct Message-ID: commit a62435b33d1f445fdda131e3e41c0b4a6d7da2a9 Author: Poul-Henning Kamp Date: Thu Feb 16 18:31:00 2017 +0000 Introduce a selfdescribing h2_error struct diff --git a/bin/varnishd/http2/cache_http2.h b/bin/varnishd/http2/cache_http2.h index d9a231f..67ed786 100644 --- a/bin/varnishd/http2/cache_http2.h +++ b/bin/varnishd/http2/cache_http2.h @@ -31,13 +31,26 @@ struct h2_sess; #include "hpack/vhp.h" -enum h2_error_e { - H2E__DUMMY = -1, -#define H2_ERROR(NAME, val, sc, desc) \ - H2E_##NAME = val, -#include "tbl/h2_error.h" +struct h2_error_s { + const char *name; + const char *txt; + uint32_t val; + int stream; + int connection; }; +typedef const struct h2_error_s *h2_error; + +#define H2EC0(U,v,d) +#define H2EC1(U,v,d) extern const struct h2_error_s H2E_C_##U[1]; +#define H2EC2(U,v,d) extern const struct h2_error_s H2E_S_##U[1]; +#define H2EC3(U,v,d) H2EC1(U,v,d) H2EC2(U,v,d) +#define H2_ERROR(NAME, val, sc, desc) H2EC##sc(NAME, val, desc) +#include "tbl/h2_error.h" +#undef H2EC1 +#undef H2EC2 +#undef H2EC3 + enum h2_frame_e { H2_FRAME__DUMMY = -1, #define H2_FRAME(l,u,t,f) H2_FRAME_##u = t, @@ -118,7 +131,7 @@ struct h2h_decode { unsigned magic; #define H2H_DECODE_MAGIC 0xd092bde4 - int error; + h2_error error; enum vhd_ret_e vhd_ret; char *out; char *reset; @@ -129,8 +142,8 @@ struct h2h_decode { }; void h2h_decode_init(const struct h2_sess *h2, struct h2h_decode *d); -int h2h_decode_fini(const struct h2_sess *h2, struct h2h_decode *d); -int h2h_decode_bytes(struct h2_sess *h2, struct h2h_decode *d, +h2_error h2h_decode_fini(const struct h2_sess *h2, struct h2h_decode *d); +h2_error h2h_decode_bytes(struct h2_sess *h2, struct h2h_decode *d, const uint8_t *ptr, size_t len); int H2_Send_Frame(struct worker *, const struct h2_sess *, diff --git a/bin/varnishd/http2/cache_http2_hpack.c b/bin/varnishd/http2/cache_http2_hpack.c index 59d9468..ecf8e37 100644 --- a/bin/varnishd/http2/cache_http2_hpack.c +++ b/bin/varnishd/http2/cache_http2_hpack.c @@ -37,7 +37,7 @@ #include "http2/cache_http2.h" #include "vct.h" -static int +static h2_error h2h_checkhdr(const struct http *hp, const char *b, size_t namelen, size_t len) { const char *p; @@ -49,7 +49,7 @@ h2h_checkhdr(const struct http *hp, const char *b, size_t namelen, size_t len) if (namelen == 2) { VSLb(hp->vsl, SLT_BogoHeader, "Empty name"); - return (H2E_PROTOCOL_ERROR); + return (H2E_C_PROTOCOL_ERROR); } for (p = b; p < b + len; p++) { @@ -64,7 +64,7 @@ h2h_checkhdr(const struct http *hp, const char *b, size_t namelen, size_t len) VSLb(hp->vsl, SLT_BogoHeader, "Illegal header name: %.*s", (int)(len > 20 ? 20 : len), b); - return (H2E_PROTOCOL_ERROR); + return (H2E_C_PROTOCOL_ERROR); } else if (p < b + namelen) { /* ': ' added by us */ assert(*p == ':' || *p == ' '); @@ -75,14 +75,14 @@ h2h_checkhdr(const struct http *hp, const char *b, size_t namelen, size_t len) VSLb(hp->vsl, SLT_BogoHeader, "Illegal header value: %.*s", (int)(len > 20 ? 20 : len), b); - return (H2E_PROTOCOL_ERROR); + return (H2E_C_PROTOCOL_ERROR); } } return (0); } -static int +static h2_error h2h_addhdr(struct http *hp, char *b, size_t namelen, size_t len) { /* XXX: This might belong in cache/cache_http.c */ @@ -95,7 +95,7 @@ h2h_addhdr(struct http *hp, char *b, size_t namelen, size_t len) if (len > UINT_MAX) { /* XXX: cache_param max header size */ VSLb(hp->vsl, SLT_BogoHeader, "Header too large: %.20s", b); - return (H2E_ENHANCE_YOUR_CALM); + return (H2E_S_ENHANCE_YOUR_CALM); } if (b[0] == ':') { @@ -127,7 +127,7 @@ h2h_addhdr(struct http *hp, char *b, size_t namelen, size_t len) VSLb(hp->vsl, SLT_BogoHeader, "Unknown pseudo-header: %.*s", (int)(len > 20 ? 20 : len), b); - return (H2E_PROTOCOL_ERROR); + return (H2E_S_PROTOCOL_ERROR); } } else n = hp->nhd; @@ -138,14 +138,14 @@ h2h_addhdr(struct http *hp, char *b, size_t namelen, size_t len) VSLb(hp->vsl, SLT_BogoHeader, "Duplicate pseudo-header: %.*s", (int)(len > 20 ? 20 : len), b); - return (H2E_PROTOCOL_ERROR); + return (H2E_S_PROTOCOL_ERROR); } } else { /* Check for space in struct http */ if (n >= hp->shd) { VSLb(hp->vsl, SLT_LostHeader, "Too many headers: %.*s", (int)(len > 20 ? 20 : len), b); - return (H2E_ENHANCE_YOUR_CALM); + return (H2E_S_ENHANCE_YOUR_CALM); } hp->nhd++; } @@ -181,10 +181,10 @@ h2h_decode_init(const struct h2_sess *h2, struct h2h_decode *d) * H2E_ENHANCE_YOUR_CALM: Ran out of workspace or http header space. This * is a stream level error. */ -int +h2_error h2h_decode_fini(const struct h2_sess *h2, struct h2h_decode *d) { - int ret; + h2_error ret; CHECK_OBJ_NOTNULL(h2, H2_SESS_MAGIC); CHECK_OBJ_NOTNULL(h2->new_req, REQ_MAGIC); @@ -195,7 +195,7 @@ h2h_decode_fini(const struct h2_sess *h2, struct h2h_decode *d) boundary */ VSLb(h2->new_req->http->vsl, SLT_BogoHeader, "HPACK compression error (%s)", VHD_Error(d->vhd_ret)); - ret = H2E_COMPRESSION_ERROR; + ret = H2E_C_COMPRESSION_ERROR; } else ret = d->error; d->magic = 0; @@ -209,7 +209,7 @@ h2h_decode_fini(const struct h2_sess *h2, struct h2h_decode *d) * * H2E_PROTOCOL_ERROR: Malformed header or duplicate pseudo-header. */ -int +h2_error h2h_decode_bytes(struct h2_sess *h2, struct h2h_decode *d, const uint8_t *in, size_t in_l) { @@ -227,7 +227,7 @@ h2h_decode_bytes(struct h2_sess *h2, struct h2h_decode *d, /* Only H2E_ENHANCE_YOUR_CALM indicates that we should continue processing. Other errors should have been returned and handled by the caller. */ - assert(d->error == 0 || d->error == H2E_ENHANCE_YOUR_CALM); + assert(d->error == 0 || d->error == H2E_S_ENHANCE_YOUR_CALM); while (1) { AN(d->out); @@ -239,14 +239,14 @@ h2h_decode_bytes(struct h2_sess *h2, struct h2h_decode *d, VSLb(hp->vsl, SLT_BogoHeader, "HPACK compression error (%s)", VHD_Error(d->vhd_ret)); - d->error = H2E_COMPRESSION_ERROR; + d->error = H2E_C_COMPRESSION_ERROR; break; } else if (d->vhd_ret == VHD_OK || d->vhd_ret == VHD_MORE) { assert(in_u == in_l); break; } - if (d->error == H2E_ENHANCE_YOUR_CALM) { + if (d->error == H2E_S_ENHANCE_YOUR_CALM) { d->out_u = 0; assert(d->out_u < d->out_l); continue; @@ -258,7 +258,7 @@ h2h_decode_bytes(struct h2_sess *h2, struct h2h_decode *d, case VHD_NAME: assert(d->namelen == 0); if (d->out_l - d->out_u < 2) { - d->error = H2E_ENHANCE_YOUR_CALM; + d->error = H2E_S_ENHANCE_YOUR_CALM; break; } d->out[d->out_u++] = ':'; @@ -271,7 +271,7 @@ h2h_decode_bytes(struct h2_sess *h2, struct h2h_decode *d, case VHD_VALUE: assert(d->namelen > 0); if (d->out_l - d->out_u < 1) { - d->error = H2E_ENHANCE_YOUR_CALM; + d->error = H2E_S_ENHANCE_YOUR_CALM; break; } d->error = h2h_checkhdr(hp, d->out, d->namelen, @@ -289,7 +289,7 @@ h2h_decode_bytes(struct h2_sess *h2, struct h2h_decode *d, break; case VHD_BUF: - d->error = H2E_ENHANCE_YOUR_CALM; + d->error = H2E_S_ENHANCE_YOUR_CALM; break; default: @@ -297,7 +297,7 @@ h2h_decode_bytes(struct h2_sess *h2, struct h2h_decode *d, break; } - if (d->error == H2E_ENHANCE_YOUR_CALM) { + if (d->error == H2E_S_ENHANCE_YOUR_CALM) { http_Teardown(hp); d->out = d->reset; d->out_l = hp->ws->r - d->out; @@ -307,7 +307,7 @@ h2h_decode_bytes(struct h2_sess *h2, struct h2h_decode *d, break; } - if (d->error == H2E_ENHANCE_YOUR_CALM) + if (d->error == H2E_S_ENHANCE_YOUR_CALM) return (0); /* Stream error, delay reporting until h2h_decode_fini so that we can process the complete header block */ diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index 04fc842..9a03cae 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -40,6 +40,16 @@ #include "vtcp.h" #include "vtim.h" +#define H2EC0(U,v,d) +#define H2EC1(U,v,d) const struct h2_error_s H2E_C_##U[1] = {{#U,d,v,0,1}}; +#define H2EC2(U,v,d) const struct h2_error_s H2E_S_##U[1] = {{#U,d,v,1,0}}; +#define H2EC3(U,v,d) H2EC1(U,v,d) H2EC2(U,v,d) +#define H2_ERROR(NAME, val, sc, desc) H2EC##sc(NAME, val, desc) +#include "tbl/h2_error.h" +#undef H2EC1 +#undef H2EC2 +#undef H2EC3 + enum h2frame { #define H2_FRAME(l,u,t,f) H2F_##u = t, #include "tbl/h2_frames.h" @@ -189,7 +199,7 @@ h2_new_req(const struct worker *wrk, struct h2_sess *h2, } static void -h2_del_req(struct worker *wrk, struct h2_req *r2, enum h2_error_e err) +h2_del_req(struct worker *wrk, struct h2_req *r2, h2_error err) { struct h2_sess *h2; struct sess *sp; @@ -384,7 +394,7 @@ h2_do_req(struct worker *wrk, void *priv) VSL(SLT_Debug, 0, "H2REQ CNT done"); /* XXX clean up req */ r2->state = H2_S_CLOSED; - h2_del_req(wrk, r2, H2E_NO_ERROR); + h2_del_req(wrk, r2, H2E_S_NO_ERROR); } void __match_proto__(h2_frame_f) @@ -394,7 +404,6 @@ h2_rx_headers(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) struct h2h_decode d[1]; const uint8_t *p; size_t l; - int i; /* XXX: This still lacks support for CONTINUATION frames, half * read frames and proper error handling. @@ -436,14 +445,8 @@ h2_rx_headers(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) p += 5; l -= 5; } - i = h2h_decode_bytes(h2, d, p, l); - if (i) - VSLb(h2->vsl, SLT_Debug, "H2H_decode_bytes = %d", i); - XXXAZ(i); - i = h2h_decode_fini(h2, d); - if (i) - VSLb(h2->vsl, SLT_Debug, "H2H_decode_fini = %d", i); - XXXAZ(i); + XXXAZ(h2h_decode_bytes(h2, d, p, l)); + XXXAZ(h2h_decode_fini(h2, d)); VSLb_ts_req(req, "Req", req->t_req); http_SetH(req->http, HTTP_HDR_PROTO, "HTTP/2.0"); @@ -762,7 +765,7 @@ h2_new_session(struct worker *wrk, void *arg) /* Delete all idle streams */ VTAILQ_FOREACH_SAFE(r2, &h2->streams, list, r22) { if (r2->state == H2_S_IDLE) - h2_del_req(wrk, r2, H2E_NO_ERROR); + h2_del_req(wrk, r2, H2E_S_NO_ERROR); } } diff --git a/include/tbl/h2_error.h b/include/tbl/h2_error.h index 2e157f7..d9bd166 100644 --- a/include/tbl/h2_error.h +++ b/include/tbl/h2_error.h @@ -32,7 +32,7 @@ /*lint -save -e525 -e539 */ -H2_ERROR(NO_ERROR, 0x0,0, "Graceful shutdown") +H2_ERROR(NO_ERROR, 0x0,3, "Graceful shutdown") H2_ERROR(PROTOCOL_ERROR, 0x1,3, "Protocol error detected") H2_ERROR(INTERNAL_ERROR, 0x2,3, "Implementation fault") H2_ERROR(FLOW_CONTROL_ERROR, 0x3,3, "Flow-control limits exceeded") From phk at FreeBSD.org Fri Feb 17 11:36:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 17 Feb 2017 12:36:05 +0100 Subject: [master] 7144af0 More compact H2 error names Message-ID: commit 7144af0e8fa2a5c354b7cd79baf70b8bf5e333d6 Author: Poul-Henning Kamp Date: Fri Feb 17 08:01:34 2017 +0000 More compact H2 error names diff --git a/bin/varnishd/http2/cache_http2.h b/bin/varnishd/http2/cache_http2.h index 67ed786..453f3d3 100644 --- a/bin/varnishd/http2/cache_http2.h +++ b/bin/varnishd/http2/cache_http2.h @@ -42,8 +42,8 @@ struct h2_error_s { typedef const struct h2_error_s *h2_error; #define H2EC0(U,v,d) -#define H2EC1(U,v,d) extern const struct h2_error_s H2E_C_##U[1]; -#define H2EC2(U,v,d) extern const struct h2_error_s H2E_S_##U[1]; +#define H2EC1(U,v,d) extern const struct h2_error_s H2CE_##U[1]; +#define H2EC2(U,v,d) extern const struct h2_error_s H2SE_##U[1]; #define H2EC3(U,v,d) H2EC1(U,v,d) H2EC2(U,v,d) #define H2_ERROR(NAME, val, sc, desc) H2EC##sc(NAME, val, desc) #include "tbl/h2_error.h" diff --git a/bin/varnishd/http2/cache_http2_hpack.c b/bin/varnishd/http2/cache_http2_hpack.c index ecf8e37..ea9a2b5 100644 --- a/bin/varnishd/http2/cache_http2_hpack.c +++ b/bin/varnishd/http2/cache_http2_hpack.c @@ -49,7 +49,7 @@ h2h_checkhdr(const struct http *hp, const char *b, size_t namelen, size_t len) if (namelen == 2) { VSLb(hp->vsl, SLT_BogoHeader, "Empty name"); - return (H2E_C_PROTOCOL_ERROR); + return (H2CE_PROTOCOL_ERROR); } for (p = b; p < b + len; p++) { @@ -64,7 +64,7 @@ h2h_checkhdr(const struct http *hp, const char *b, size_t namelen, size_t len) VSLb(hp->vsl, SLT_BogoHeader, "Illegal header name: %.*s", (int)(len > 20 ? 20 : len), b); - return (H2E_C_PROTOCOL_ERROR); + return (H2CE_PROTOCOL_ERROR); } else if (p < b + namelen) { /* ': ' added by us */ assert(*p == ':' || *p == ' '); @@ -75,7 +75,7 @@ h2h_checkhdr(const struct http *hp, const char *b, size_t namelen, size_t len) VSLb(hp->vsl, SLT_BogoHeader, "Illegal header value: %.*s", (int)(len > 20 ? 20 : len), b); - return (H2E_C_PROTOCOL_ERROR); + return (H2CE_PROTOCOL_ERROR); } } @@ -95,7 +95,7 @@ h2h_addhdr(struct http *hp, char *b, size_t namelen, size_t len) if (len > UINT_MAX) { /* XXX: cache_param max header size */ VSLb(hp->vsl, SLT_BogoHeader, "Header too large: %.20s", b); - return (H2E_S_ENHANCE_YOUR_CALM); + return (H2SE_ENHANCE_YOUR_CALM); } if (b[0] == ':') { @@ -127,7 +127,7 @@ h2h_addhdr(struct http *hp, char *b, size_t namelen, size_t len) VSLb(hp->vsl, SLT_BogoHeader, "Unknown pseudo-header: %.*s", (int)(len > 20 ? 20 : len), b); - return (H2E_S_PROTOCOL_ERROR); + return (H2SE_PROTOCOL_ERROR); } } else n = hp->nhd; @@ -138,14 +138,14 @@ h2h_addhdr(struct http *hp, char *b, size_t namelen, size_t len) VSLb(hp->vsl, SLT_BogoHeader, "Duplicate pseudo-header: %.*s", (int)(len > 20 ? 20 : len), b); - return (H2E_S_PROTOCOL_ERROR); + return (H2SE_PROTOCOL_ERROR); } } else { /* Check for space in struct http */ if (n >= hp->shd) { VSLb(hp->vsl, SLT_LostHeader, "Too many headers: %.*s", (int)(len > 20 ? 20 : len), b); - return (H2E_S_ENHANCE_YOUR_CALM); + return (H2SE_ENHANCE_YOUR_CALM); } hp->nhd++; } @@ -195,7 +195,7 @@ h2h_decode_fini(const struct h2_sess *h2, struct h2h_decode *d) boundary */ VSLb(h2->new_req->http->vsl, SLT_BogoHeader, "HPACK compression error (%s)", VHD_Error(d->vhd_ret)); - ret = H2E_C_COMPRESSION_ERROR; + ret = H2CE_COMPRESSION_ERROR; } else ret = d->error; d->magic = 0; @@ -227,7 +227,7 @@ h2h_decode_bytes(struct h2_sess *h2, struct h2h_decode *d, /* Only H2E_ENHANCE_YOUR_CALM indicates that we should continue processing. Other errors should have been returned and handled by the caller. */ - assert(d->error == 0 || d->error == H2E_S_ENHANCE_YOUR_CALM); + assert(d->error == 0 || d->error == H2SE_ENHANCE_YOUR_CALM); while (1) { AN(d->out); @@ -239,14 +239,14 @@ h2h_decode_bytes(struct h2_sess *h2, struct h2h_decode *d, VSLb(hp->vsl, SLT_BogoHeader, "HPACK compression error (%s)", VHD_Error(d->vhd_ret)); - d->error = H2E_C_COMPRESSION_ERROR; + d->error = H2CE_COMPRESSION_ERROR; break; } else if (d->vhd_ret == VHD_OK || d->vhd_ret == VHD_MORE) { assert(in_u == in_l); break; } - if (d->error == H2E_S_ENHANCE_YOUR_CALM) { + if (d->error == H2SE_ENHANCE_YOUR_CALM) { d->out_u = 0; assert(d->out_u < d->out_l); continue; @@ -258,7 +258,7 @@ h2h_decode_bytes(struct h2_sess *h2, struct h2h_decode *d, case VHD_NAME: assert(d->namelen == 0); if (d->out_l - d->out_u < 2) { - d->error = H2E_S_ENHANCE_YOUR_CALM; + d->error = H2SE_ENHANCE_YOUR_CALM; break; } d->out[d->out_u++] = ':'; @@ -271,7 +271,7 @@ h2h_decode_bytes(struct h2_sess *h2, struct h2h_decode *d, case VHD_VALUE: assert(d->namelen > 0); if (d->out_l - d->out_u < 1) { - d->error = H2E_S_ENHANCE_YOUR_CALM; + d->error = H2SE_ENHANCE_YOUR_CALM; break; } d->error = h2h_checkhdr(hp, d->out, d->namelen, @@ -289,7 +289,7 @@ h2h_decode_bytes(struct h2_sess *h2, struct h2h_decode *d, break; case VHD_BUF: - d->error = H2E_S_ENHANCE_YOUR_CALM; + d->error = H2SE_ENHANCE_YOUR_CALM; break; default: @@ -297,7 +297,7 @@ h2h_decode_bytes(struct h2_sess *h2, struct h2h_decode *d, break; } - if (d->error == H2E_S_ENHANCE_YOUR_CALM) { + if (d->error == H2SE_ENHANCE_YOUR_CALM) { http_Teardown(hp); d->out = d->reset; d->out_l = hp->ws->r - d->out; @@ -307,7 +307,7 @@ h2h_decode_bytes(struct h2_sess *h2, struct h2h_decode *d, break; } - if (d->error == H2E_S_ENHANCE_YOUR_CALM) + if (d->error == H2SE_ENHANCE_YOUR_CALM) return (0); /* Stream error, delay reporting until h2h_decode_fini so that we can process the complete header block */ diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index 9a03cae..625dade 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -41,8 +41,8 @@ #include "vtim.h" #define H2EC0(U,v,d) -#define H2EC1(U,v,d) const struct h2_error_s H2E_C_##U[1] = {{#U,d,v,0,1}}; -#define H2EC2(U,v,d) const struct h2_error_s H2E_S_##U[1] = {{#U,d,v,1,0}}; +#define H2EC1(U,v,d) const struct h2_error_s H2CE_##U[1] = {{#U,d,v,0,1}}; +#define H2EC2(U,v,d) const struct h2_error_s H2SE_##U[1] = {{#U,d,v,1,0}}; #define H2EC3(U,v,d) H2EC1(U,v,d) H2EC2(U,v,d) #define H2_ERROR(NAME, val, sc, desc) H2EC##sc(NAME, val, desc) #include "tbl/h2_error.h" @@ -394,7 +394,7 @@ h2_do_req(struct worker *wrk, void *priv) VSL(SLT_Debug, 0, "H2REQ CNT done"); /* XXX clean up req */ r2->state = H2_S_CLOSED; - h2_del_req(wrk, r2, H2E_S_NO_ERROR); + h2_del_req(wrk, r2, H2SE_NO_ERROR); } void __match_proto__(h2_frame_f) @@ -765,7 +765,7 @@ h2_new_session(struct worker *wrk, void *arg) /* Delete all idle streams */ VTAILQ_FOREACH_SAFE(r2, &h2->streams, list, r22) { if (r2->state == H2_S_IDLE) - h2_del_req(wrk, r2, H2E_S_NO_ERROR); + h2_del_req(wrk, r2, H2SE_NO_ERROR); } } From phk at FreeBSD.org Fri Feb 17 11:36:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 17 Feb 2017 12:36:05 +0100 Subject: [master] 7a834f4 Have frame-rx functions return an error Message-ID: commit 7a834f42c4c350d1806b893b70ca4e6a8d255ed2 Author: Poul-Henning Kamp Date: Fri Feb 17 08:10:04 2017 +0000 Have frame-rx functions return an error diff --git a/bin/varnishd/http2/cache_http2.h b/bin/varnishd/http2/cache_http2.h index 453f3d3..dafcfdc 100644 --- a/bin/varnishd/http2/cache_http2.h +++ b/bin/varnishd/http2/cache_http2.h @@ -153,7 +153,7 @@ int H2_Send_Frame(struct worker *, const struct h2_sess *, int H2_Send(struct worker *, struct h2_req *, int flush, enum h2_frame_e type, uint8_t flags, uint32_t len, const void *); -typedef void h2_frame_f(struct worker *, struct h2_sess *, +typedef h2_error h2_frame_f(struct worker *, struct h2_sess *, struct h2_req *); #define H2_FRAME(l,u,t,f) h2_frame_f h2_rx_##l ; #include "tbl/h2_frames.h" diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index 625dade..40ff6ad 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -104,7 +104,7 @@ static const uint8_t H2_settings[] = { /**********************************************************************/ #define DUMMY_FRAME(l) \ - void \ + h2_error __match_proto__(h2_frame_f) \ h2_rx_##l(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) \ __match_proto__(h2_frame_f) \ { (void)wrk; (void)r2; VSLb(h2->vsl, SLT_Debug, "XXX implement " #l); INCOMPL(); } @@ -296,7 +296,7 @@ h2_vsl_frame(const struct h2_sess *h2, const void *ptr, size_t len) /********************************************************************** */ -void __match_proto__(h2_frame_f) +h2_error __match_proto__(h2_frame_f) h2_rx_ping(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) { (void)r2; @@ -305,12 +305,13 @@ h2_rx_ping(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) xxxassert(h2->rxf_stream == 0); H2_Send_Frame(wrk, h2, H2_FRAME_PING, H2FF_PING_ACK, 8, 0, h2->rxf_data); + return (0); } /********************************************************************** */ -void __match_proto__(h2_frame_f) +h2_error __match_proto__(h2_frame_f) h2_rx_goaway(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) { uint32_t error; @@ -321,9 +322,10 @@ h2_rx_goaway(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) error = vbe32dec(h2->rxf_data + 4); /*XXX*/(void)error; h2->go_away = 1; + return (0); } -void __match_proto__(h2_frame_f) +h2_error __match_proto__(h2_frame_f) h2_rx_window_update(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) { uint32_t wu; @@ -335,26 +337,28 @@ h2_rx_window_update(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) xxxassert(wu != 0); // stream PROTOCOL_ERROR r2->window += wu; xxxassert(r2->window < (1LLU<<32)); // FLOW_CONTROL_ERROR + return (0); } /********************************************************************** * Incoming PRIORITY, possibly an ACK of one we sent. */ -void __match_proto__(h2_frame_f) +h2_error __match_proto__(h2_frame_f) h2_rx_priority(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) { (void)wrk; (void)h2; xxxassert(r2->stream & 1); + return (0); } /********************************************************************** * Incoming SETTINGS, possibly an ACK of one we sent. */ -void __match_proto__(h2_frame_f) +h2_error __match_proto__(h2_frame_f) h2_rx_settings(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) { const uint8_t *p = h2->rxf_data; @@ -376,6 +380,7 @@ h2_rx_settings(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) } else { WRONG("SETTINGS FRAME"); } + return (0); } /********************************************************************** @@ -397,7 +402,7 @@ h2_do_req(struct worker *wrk, void *priv) h2_del_req(wrk, r2, H2SE_NO_ERROR); } -void __match_proto__(h2_frame_f) +h2_error __match_proto__(h2_frame_f) h2_rx_headers(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) { struct req *req; @@ -459,6 +464,7 @@ h2_rx_headers(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) req->task.func = h2_do_req; req->task.priv = req; XXXAZ(Pool_Task(wrk->pool, &req->task, TASK_QUEUE_REQ)); + return (0); } /**********************************************************************/ @@ -548,7 +554,7 @@ h2_rxframe(struct worker *wrk, struct h2_sess *h2) #define H2_FRAME(l,u,t,f) \ case H2F_##u: \ if (!(h2->rxf_flags & ~f)) { \ - h2_rx_##l(wrk, h2, r2); \ + (void)h2_rx_##l(wrk, h2, r2); \ } else { \ VSLb(h2->vsl, SLT_Debug, \ "H2: Bad flags 0x%02x on " #u, \ From phk at FreeBSD.org Fri Feb 17 11:36:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 17 Feb 2017 12:36:05 +0100 Subject: [master] b167b52 Use table based dispatch for H2 rx Message-ID: commit b167b52b42e4ce60a2f982e1dcacd4f59dd36efb Author: Poul-Henning Kamp Date: Fri Feb 17 08:56:13 2017 +0000 Use table based dispatch for H2 rx diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index 40ff6ad..b647262 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -501,12 +501,25 @@ h2_frame_complete(struct http_conn *htc) return (HTC_S_COMPLETE); } +struct h2flist_s { + const char *name; + h2_frame_f *func; + uint8_t flags; +}; + +static const struct h2flist_s h2flist[] = { +#define H2_FRAME(l,U,t,f) [t] = { #U, h2_rx_##l, f }, +#include "tbl/h2_frames.h" +}; + +#define H2FMAX (sizeof(h2flist) / sizeof(h2flist[0])) + static int h2_rxframe(struct worker *wrk, struct h2_sess *h2) { enum htc_status_e hs; - enum h2frame ft; struct h2_req *r2 = NULL; + const struct h2flist_s *h2f; (void)VTCP_blocking(*h2->htc->rfd); h2->sess->t_idle = VTIM_real(); @@ -549,27 +562,22 @@ h2_rxframe(struct worker *wrk, struct h2_sess *h2) r2 = h2_new_req(wrk, h2, h2->rxf_stream, NULL); } - ft = (enum h2frame)h2->htc->rxbuf_b[3]; - switch (ft) { -#define H2_FRAME(l,u,t,f) \ - case H2F_##u: \ - if (!(h2->rxf_flags & ~f)) { \ - (void)h2_rx_##l(wrk, h2, r2); \ - } else { \ - VSLb(h2->vsl, SLT_Debug, \ - "H2: Bad flags 0x%02x on " #u, \ - h2->rxf_flags); \ - Lck_Unlock(&h2->sess->mtx); \ - return (0); \ - } \ - break; -#include "tbl/h2_frames.h" - default: - VSLb(h2->vsl, SLT_Debug, "H2: Bad frame type 0x%02x on ", - h2->htc->rxbuf_b[3]); + if (h2->htc->rxbuf_b[3] >= H2FMAX) { + VSLb(h2->vsl, SLT_Debug, + "H2: Unknown Frame %d", h2->htc->rxbuf_b[3]); + Lck_Unlock(&h2->sess->mtx); + return (0); + } + h2f = h2flist + h2->htc->rxbuf_b[3]; + AN(h2f->name); + if (h2->rxf_flags & ~h2f->flags) { + VSLb(h2->vsl, SLT_Debug, "H2: Bad flags 0x%02x on %s", + h2->rxf_flags, h2f->name); Lck_Unlock(&h2->sess->mtx); return (0); } + (void)h2f->func(wrk, h2, r2); + Lck_Unlock(&h2->sess->mtx); return (1); } From phk at FreeBSD.org Fri Feb 17 11:36:06 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 17 Feb 2017 12:36:06 +0100 Subject: [master] 9a13765 Start working on systematic error handling Message-ID: commit 9a13765b824301e8de10bae1a0309e6992a64f5c Author: Poul-Henning Kamp Date: Fri Feb 17 09:29:31 2017 +0000 Start working on systematic error handling diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index b647262..0ad87ed 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -299,10 +299,13 @@ h2_vsl_frame(const struct h2_sess *h2, const void *ptr, size_t len) h2_error __match_proto__(h2_frame_f) h2_rx_ping(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) { + (void)r2; - xxxassert(h2->rxf_len == 8); - xxxassert(h2->rxf_flags == 0); - xxxassert(h2->rxf_stream == 0); + if (h2->rxf_len != 8) + return (H2CE_FRAME_SIZE_ERROR); + if (h2->rxf_stream != 0) + return (H2CE_PROTOCOL_ERROR); + xxxassert(h2->rxf_flags == 0); // XXX: we never send pings H2_Send_Frame(wrk, h2, H2_FRAME_PING, H2FF_PING_ACK, 8, 0, h2->rxf_data); return (0); @@ -332,11 +335,14 @@ h2_rx_window_update(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) (void)wrk; Lck_AssertHeld(&h2->sess->mtx); - xxxassert(h2->rxf_len == 4); // conn FRAME_SIZE_ERROR - wu = vbe32dec(h2->rxf_data); - xxxassert(wu != 0); // stream PROTOCOL_ERROR + if (h2->rxf_len != 4) + return (H2CE_FRAME_SIZE_ERROR); + wu = vbe32dec(h2->rxf_data) & ~(1LU<<31); + if (wu == 0) + return (H2SE_PROTOCOL_ERROR); r2->window += wu; - xxxassert(r2->window < (1LLU<<32)); // FLOW_CONTROL_ERROR + if (r2->window >= (1LLU << 31)) + return (H2SE_FLOW_CONTROL_ERROR); return (0); } @@ -514,45 +520,20 @@ static const struct h2flist_s h2flist[] = { #define H2FMAX (sizeof(h2flist) / sizeof(h2flist[0])) -static int -h2_rxframe(struct worker *wrk, struct h2_sess *h2) +static h2_error +h2_procframe(struct worker *wrk, struct h2_sess *h2) { - enum htc_status_e hs; struct h2_req *r2 = NULL; const struct h2flist_s *h2f; - - (void)VTCP_blocking(*h2->htc->rfd); - h2->sess->t_idle = VTIM_real(); - hs = HTC_RxStuff(h2->htc, h2_frame_complete, - NULL, NULL, NAN, - h2->sess->t_idle + cache_param->timeout_idle + 100, - 1024); - if (hs != HTC_S_COMPLETE) { - Lck_Lock(&h2->sess->mtx); - VSLb(h2->vsl, SLT_Debug, "H2: No frame (hs=%d)", hs); - Lck_Unlock(&h2->sess->mtx); - return (0); - } - - h2->rxf_len = vbe32dec(h2->htc->rxbuf_b) >> 8; - h2->rxf_flags = h2->htc->rxbuf_b[4]; - h2->rxf_stream = vbe32dec(h2->htc->rxbuf_b + 5); - h2->rxf_data = (void*)(h2->htc->rxbuf_b + 9); - /* XXX: later full DATA will not be rx'ed yet. */ - HTC_RxPipeline(h2->htc, h2->htc->rxbuf_b + h2->rxf_len + 9); - - h2_vsl_frame(h2, h2->htc->rxbuf_b, 9L + h2->rxf_len); + h2_error h2e; if (h2->rxf_stream != 0 && !(h2->rxf_stream & 1)) { /* We don't do push, so all streams must be zero or odd# */ - Lck_Lock(&h2->sess->mtx); VSLb(h2->vsl, SLT_Debug, "H2: illegal stream (=%u)", h2->rxf_stream); - Lck_Unlock(&h2->sess->mtx); return (0); } - Lck_Lock(&h2->sess->mtx); VTAILQ_FOREACH(r2, &h2->streams, list) if (r2->stream == h2->rxf_stream) break; @@ -565,7 +546,6 @@ h2_rxframe(struct worker *wrk, struct h2_sess *h2) if (h2->htc->rxbuf_b[3] >= H2FMAX) { VSLb(h2->vsl, SLT_Debug, "H2: Unknown Frame %d", h2->htc->rxbuf_b[3]); - Lck_Unlock(&h2->sess->mtx); return (0); } h2f = h2flist + h2->htc->rxbuf_b[3]; @@ -573,12 +553,46 @@ h2_rxframe(struct worker *wrk, struct h2_sess *h2) if (h2->rxf_flags & ~h2f->flags) { VSLb(h2->vsl, SLT_Debug, "H2: Bad flags 0x%02x on %s", h2->rxf_flags, h2f->name); + return (0); + } + h2e = h2f->func(wrk, h2, r2); + XXXAZ(h2e); + return (0); +} + +static int +h2_rxframe(struct worker *wrk, struct h2_sess *h2) +{ + enum htc_status_e hs; + h2_error h2e; + + (void)VTCP_blocking(*h2->htc->rfd); + h2->sess->t_idle = VTIM_real(); + hs = HTC_RxStuff(h2->htc, h2_frame_complete, + NULL, NULL, NAN, + h2->sess->t_idle + cache_param->timeout_idle + 100, + 1024); + if (hs != HTC_S_COMPLETE) { + Lck_Lock(&h2->sess->mtx); + VSLb(h2->vsl, SLT_Debug, "H2: No frame (hs=%d)", hs); Lck_Unlock(&h2->sess->mtx); return (0); } - (void)h2f->func(wrk, h2, r2); + h2->rxf_len = vbe32dec(h2->htc->rxbuf_b) >> 8; + h2->rxf_flags = h2->htc->rxbuf_b[4]; + h2->rxf_stream = vbe32dec(h2->htc->rxbuf_b + 5); + h2->rxf_data = (void*)(h2->htc->rxbuf_b + 9); + /* XXX: later full DATA will not be rx'ed yet. */ + HTC_RxPipeline(h2->htc, h2->htc->rxbuf_b + h2->rxf_len + 9); + + h2_vsl_frame(h2, h2->htc->rxbuf_b, 9L + h2->rxf_len); + + Lck_Lock(&h2->sess->mtx); + h2e = h2_procframe(wrk, h2); Lck_Unlock(&h2->sess->mtx); + if (h2e) + return (0); return (1); } From phk at FreeBSD.org Fri Feb 17 11:36:06 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 17 Feb 2017 12:36:06 +0100 Subject: [master] bdf117b More error-handling work Message-ID: commit bdf117b9176f2d65bb5d3179d298b719b310a158 Author: Poul-Henning Kamp Date: Fri Feb 17 11:35:26 2017 +0000 More error-handling work diff --git a/bin/varnishd/http2/cache_http2.h b/bin/varnishd/http2/cache_http2.h index dafcfdc..bf9604c 100644 --- a/bin/varnishd/http2/cache_http2.h +++ b/bin/varnishd/http2/cache_http2.h @@ -94,6 +94,7 @@ struct h2_sess { struct sess *sess; int refcnt; uint32_t highest_stream; + int bogosity; struct h2_req_s streams; diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index 0ad87ed..c799a80 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -528,34 +528,49 @@ h2_procframe(struct worker *wrk, struct h2_sess *h2) h2_error h2e; if (h2->rxf_stream != 0 && !(h2->rxf_stream & 1)) { - /* We don't do push, so all streams must be zero or odd# */ + /* No even streams, we don't do PUSH_PROMISE */ VSLb(h2->vsl, SLT_Debug, "H2: illegal stream (=%u)", h2->rxf_stream); - return (0); + return (H2CE_PROTOCOL_ERROR); // rfc7540 5.1.1 } VTAILQ_FOREACH(r2, &h2->streams, list) if (r2->stream == h2->rxf_stream) break; if (r2 == NULL) { - xxxassert(h2->rxf_stream > h2->highest_stream); + if (h2->rxf_stream <= h2->highest_stream) + return (H2CE_PROTOCOL_ERROR); // rfc7540 5.1.1 h2->highest_stream = h2->rxf_stream; r2 = h2_new_req(wrk, h2, h2->rxf_stream, NULL); + AN(r2); } if (h2->htc->rxbuf_b[3] >= H2FMAX) { + h2->bogosity++; VSLb(h2->vsl, SLT_Debug, - "H2: Unknown Frame %d", h2->htc->rxbuf_b[3]); - return (0); + "H2: Unknown Frame 0x%02x", h2->htc->rxbuf_b[3]); + return (0); // rfc7540 4.1 } h2f = h2flist + h2->htc->rxbuf_b[3]; - AN(h2f->name); + if (h2f->name == NULL || h2f->func == NULL) { + h2->bogosity++; + VSLb(h2->vsl, SLT_Debug, + "H2: Unimplemented Frame 0x%02x", h2->htc->rxbuf_b[3]); + return (0); // rfc7540 4.1 + } if (h2->rxf_flags & ~h2f->flags) { + h2->bogosity++; VSLb(h2->vsl, SLT_Debug, "H2: Bad flags 0x%02x on %s", h2->rxf_flags, h2f->name); - return (0); + h2->rxf_flags &= h2f->flags; // rfc7540 4.1 } h2e = h2f->func(wrk, h2, r2); + if (h2e == 0) + return (0); + if (h2->rxf_stream == 0 || h2e->connection) + return (h2e); // Connection errors one level up + + /* XXX handle stream error */ XXXAZ(h2e); return (0); } From dridi.boukelmoune at gmail.com Fri Feb 17 16:52:05 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 17 Feb 2017 17:52:05 +0100 Subject: [master] 7a75565 GC obsolete function detection Message-ID: commit 7a755654be28f3aaff12f50aede7c755d4419ea2 Author: Dridi Boukelmoune Date: Fri Feb 17 17:49:38 2017 +0100 GC obsolete function detection diff --git a/config.phk b/config.phk index ae7bc93..7356757 100644 --- a/config.phk +++ b/config.phk @@ -283,7 +283,6 @@ exit 0 # HAVE_BACKTRACE + # HAVE_CLOCK_GETTIME + # HAVE_DAEMON + -# HAVE_DLADDR + # HAVE_KQUEUE + # HAVE_NANOSLEEP + # HAVE_PTHREAD_SET_NAME_NP + diff --git a/configure.ac b/configure.ac index f4d8ec3..7c46d40 100644 --- a/configure.ac +++ b/configure.ac @@ -191,7 +191,6 @@ AC_CHECK_HEADERS([pthread_np.h], [], [], [#include ]) AC_CHECK_HEADERS([priv.h]) # Checks for library functions. -AC_CHECK_FUNCS([dladdr]) AC_CHECK_FUNCS([nanosleep]) AC_CHECK_FUNCS([setppriv]) AC_CHECK_FUNCS([fallocate]) From phk at FreeBSD.org Fri Feb 17 22:48:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 17 Feb 2017 23:48:05 +0100 Subject: [master] d8efa56 Unify sendhex and fix at least one bug therein. Message-ID: commit d8efa56adcc504f36a9fded104e99b6bfc457733 Author: Poul-Henning Kamp Date: Fri Feb 17 21:54:47 2017 +0000 Unify sendhex and fix at least one bug therein. diff --git a/bin/varnishtest/Makefile.am b/bin/varnishtest/Makefile.am index 636edd4..3710cf9 100644 --- a/bin/varnishtest/Makefile.am +++ b/bin/varnishtest/Makefile.am @@ -47,6 +47,7 @@ varnishtest_SOURCES = \ vtc_process.c \ vtc_proxy.c \ vtc_server.c \ + vtc_subr.c \ vtc_varnish.c varnishtest_LDADD = \ diff --git a/bin/varnishtest/vtc.h b/bin/varnishtest/vtc.h index a25d4ff..34460ce 100644 --- a/bin/varnishtest/vtc.h +++ b/bin/varnishtest/vtc.h @@ -124,3 +124,6 @@ void cmd_stream(CMD_ARGS); void start_h2(struct http *hp); void stop_h2(struct http *hp); void b64_settings(const struct http *hp, const char *s); + +/* vtc_subr.c */ +struct vsb *vtc_hex_to_bin(struct vtclog *vl, const char *arg); diff --git a/bin/varnishtest/vtc_http.c b/bin/varnishtest/vtc_http.c index 77a545e..d9a233d 100644 --- a/bin/varnishtest/vtc_http.c +++ b/bin/varnishtest/vtc_http.c @@ -1404,38 +1404,20 @@ cmd_http_send_urgent(CMD_ARGS) static void cmd_http_sendhex(CMD_ARGS) { + struct vsb *vsb; struct http *hp; - char buf[3], *q; - uint8_t *p; - int i, j, l; + int j; (void)cmd; (void)vl; CAST_OBJ_NOTNULL(hp, priv, HTTP_MAGIC); AN(av[1]); AZ(av[2]); - l = strlen(av[1]) / 2; - p = calloc(1, l); - AN(p); - q = av[1]; - for (i = 0; i < l; i++) { - while (vct_issp(*q)) - q++; - if (*q == '\0') - break; - memcpy(buf, q, 2); - q += 2; - buf[2] = '\0'; - if (!vct_ishex(buf[0]) || !vct_ishex(buf[1])) - vtc_fatal(hp->vl, "Illegal Hex char \"%c%c\"", - buf[0], buf[1]); - p[i] = (uint8_t)strtoul(buf, NULL, 16); - } - vtc_hexdump(hp->vl, 4, "sendhex", (void*)p, i); - j = write(hp->fd, p, i); - assert(j == i); - free(p); - + vsb = vtc_hex_to_bin(hp->vl, av[1]); + vtc_hexdump(hp->vl, 4, "sendhex", VSB_data(vsb), VSB_len(vsb)); + j = write(hp->fd, VSB_data(vsb), VSB_len(vsb)); + assert(j == VSB_len(vsb)); + VSB_destroy(&vsb); } /* SECTION: client-server.spec.chunked diff --git a/bin/varnishtest/vtc_http2.c b/bin/varnishtest/vtc_http2.c index e87fd88..cbd3281 100644 --- a/bin/varnishtest/vtc_http2.c +++ b/bin/varnishtest/vtc_http2.c @@ -1225,41 +1225,20 @@ cmd_sendhex(CMD_ARGS) { struct http *hp; struct stream *s; - char *q; - char *buf; - char tmp[3]; - int i; - unsigned size = 0; - (void)cmd; + struct vsb *vsb; + (void)cmd; + (void)vl; CAST_OBJ_NOTNULL(s, priv, STREAM_MAGIC); CAST_OBJ_NOTNULL(hp, s->hp, HTTP_MAGIC); AN(av[1]); AZ(av[2]); - - q = av[1]; - size = strlen(q)/2; - buf = malloc(size); - AN(buf); - for (i = 0; i < size; i++) { - while (vct_issp(*q)) - q++; - if (*q == '\0') - break; - memcpy(tmp, q, 2); - q += 2; - tmp[2] = '\0'; - if (!vct_ishex(tmp[0]) || !vct_ishex(tmp[1])) - vtc_fatal(vl, "Illegal Hex char \"%c%c\"", - tmp[0], tmp[1]); - buf[i] = (uint8_t)strtoul(tmp, NULL, 16); - } + vsb = vtc_hex_to_bin(hp->vl, av[1]); + vtc_hexdump(hp->vl, 4, "sendhex", VSB_data(vsb), VSB_len(vsb)); AZ(pthread_mutex_lock(&hp->mtx)); - http_write(hp, 4, buf, i, "sendhex"); - + http_write(hp, 4, VSB_data(vsb), VSB_len(vsb), "sendhex"); AZ(pthread_mutex_unlock(&hp->mtx)); - vtc_hexdump(vl, 4, "sendhex", (void *)buf, size); - free(buf); + VSB_destroy(&vsb); } #define ENC(hdr, k, v) \ diff --git a/bin/varnishtest/vtc_subr.c b/bin/varnishtest/vtc_subr.c new file mode 100644 index 0000000..6a8f1b7 --- /dev/null +++ b/bin/varnishtest/vtc_subr.c @@ -0,0 +1,66 @@ +/*- + * Copyright (c) 2008-2017 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. + */ + +#include "config.h" + +#include "vtc.h" + +#include "vct.h" + +struct vsb * +vtc_hex_to_bin(struct vtclog *vl, const char *arg) +{ + struct vsb *vsb; + unsigned sh = 4; + unsigned c, b = 0; + + vsb = VSB_new_auto(); + AN(vsb); + for (; *arg != '\0'; arg++) { + if (vct_issp(*arg)) + continue; + c = (uint8_t)*arg; + if (c >= '0' && c <= '9') + b |= (c - 48U) << sh; + else if (c >= 'A' && c <= 'F') + b |= (c - 55U) << sh; + else if (c >= 'a' && c <= 'f') + b |= (c - 87U) << sh; + else + vtc_fatal(vl,"Illegal hex string"); + sh = 4 - sh; + if (sh == 4) { + VSB_putc(vsb, b); + b = 0; + } + } + if (sh != 4) + VSB_putc(vsb, b); + AZ(VSB_finish(vsb)); + return (vsb); +} From phk at FreeBSD.org Fri Feb 17 22:48:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 17 Feb 2017 23:48:05 +0100 Subject: [master] 9d4797a Allow use of symbolic H2 error names in expect rst.err == BLA Message-ID: commit 9d4797a088358ac81cef27d2d8887d1063230003 Author: Poul-Henning Kamp Date: Fri Feb 17 22:14:31 2017 +0000 Allow use of symbolic H2 error names in expect rst.err == BLA diff --git a/bin/varnishtest/vtc_http2.c b/bin/varnishtest/vtc_http2.c index cbd3281..ee6f9c3 100644 --- a/bin/varnishtest/vtc_http2.c +++ b/bin/varnishtest/vtc_http2.c @@ -1207,6 +1207,9 @@ cmd_var_resolve(const struct stream *s, const char *spec, char *buf) else return (NULL); } +#define H2_ERROR(U,v,sc,t) \ + else if (!strcmp(spec, #U)) { return (#v); } +#include "tbl/h2_error.h" else return (spec); return(NULL); diff --git a/include/tbl/h2_error.h b/include/tbl/h2_error.h index d9bd166..02044db 100644 --- a/include/tbl/h2_error.h +++ b/include/tbl/h2_error.h @@ -32,20 +32,20 @@ /*lint -save -e525 -e539 */ -H2_ERROR(NO_ERROR, 0x0,3, "Graceful shutdown") -H2_ERROR(PROTOCOL_ERROR, 0x1,3, "Protocol error detected") -H2_ERROR(INTERNAL_ERROR, 0x2,3, "Implementation fault") -H2_ERROR(FLOW_CONTROL_ERROR, 0x3,3, "Flow-control limits exceeded") -H2_ERROR(SETTINGS_TIMEOUT, 0x4,1, "Settings not acknowledged") -H2_ERROR(STREAM_CLOSED, 0x5,2, "Frame received for closed stream") -H2_ERROR(FRAME_SIZE_ERROR, 0x6,3, "Frame size incorrect") -H2_ERROR(REFUSED_STREAM, 0x7,2, "Stream not processed") -H2_ERROR(CANCEL, 0x8,2, "Stream cancelled") -H2_ERROR(COMPRESSION_ERROR, 0x9,1, "Compression state not updated") -H2_ERROR(CONNECT_ERROR, 0xa,2, "TCP connection error for CONNECT method") -H2_ERROR(ENHANCE_YOUR_CALM, 0xb,3, "Processing capacity exceeded") -H2_ERROR(INADEQUATE_SECURITY,0xc,1, "Negotiated TLS parameters not acceptable") -H2_ERROR(HTTP_1_1_REQUIRED, 0xd,1, "Use HTTP/1.1 for the request") +H2_ERROR(NO_ERROR, 0,3, "Graceful shutdown") +H2_ERROR(PROTOCOL_ERROR, 1,3, "Protocol error detected") +H2_ERROR(INTERNAL_ERROR, 2,3, "Implementation fault") +H2_ERROR(FLOW_CONTROL_ERROR, 3,3, "Flow-control limits exceeded") +H2_ERROR(SETTINGS_TIMEOUT, 4,1, "Settings not acknowledged") +H2_ERROR(STREAM_CLOSED, 5,2, "Frame received for closed stream") +H2_ERROR(FRAME_SIZE_ERROR, 6,3, "Frame size incorrect") +H2_ERROR(REFUSED_STREAM, 7,2, "Stream not processed") +H2_ERROR(CANCEL, 8,2, "Stream cancelled") +H2_ERROR(COMPRESSION_ERROR, 9,1, "Compression state not updated") +H2_ERROR(CONNECT_ERROR, 10,2, "TCP connection error for CONNECT method") +H2_ERROR(ENHANCE_YOUR_CALM, 11,3, "Processing capacity exceeded") +H2_ERROR(INADEQUATE_SECURITY, 12,1, "Negotiated TLS parameters not acceptable") +H2_ERROR(HTTP_1_1_REQUIRED, 13,1, "Use HTTP/1.1 for the request") #undef H2_ERROR /*lint -restore */ From phk at FreeBSD.org Fri Feb 17 22:48:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 17 Feb 2017 23:48:05 +0100 Subject: [master] 142e918 Send RST_STREAM and GOAWAY, and add a testcase to see that it works. Message-ID: commit 142e918b03d6ceb83b917837e76c298076891240 Author: Poul-Henning Kamp Date: Fri Feb 17 22:46:52 2017 +0000 Send RST_STREAM and GOAWAY, and add a testcase to see that it works. diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index c799a80..966658b 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -199,14 +199,13 @@ h2_new_req(const struct worker *wrk, struct h2_sess *h2, } static void -h2_del_req(struct worker *wrk, struct h2_req *r2, h2_error err) +h2_del_req(struct worker *wrk, struct h2_req *r2) { struct h2_sess *h2; struct sess *sp; struct req *req; int r; - (void)err; h2 = r2->h2sess; sp = h2->sess; Lck_Lock(&sp->mtx); @@ -405,7 +404,7 @@ h2_do_req(struct worker *wrk, void *priv) VSL(SLT_Debug, 0, "H2REQ CNT done"); /* XXX clean up req */ r2->state = H2_S_CLOSED; - h2_del_req(wrk, r2, H2SE_NO_ERROR); + h2_del_req(wrk, r2); } h2_error __match_proto__(h2_frame_f) @@ -526,6 +525,7 @@ h2_procframe(struct worker *wrk, struct h2_sess *h2) struct h2_req *r2 = NULL; const struct h2flist_s *h2f; h2_error h2e; + char b[4]; if (h2->rxf_stream != 0 && !(h2->rxf_stream & 1)) { /* No even streams, we don't do PUSH_PROMISE */ @@ -570,8 +570,14 @@ h2_procframe(struct worker *wrk, struct h2_sess *h2) if (h2->rxf_stream == 0 || h2e->connection) return (h2e); // Connection errors one level up - /* XXX handle stream error */ - XXXAZ(h2e); + VSLb(h2->vsl, SLT_Debug, "H2: stream %u: %s", + h2->rxf_stream, h2e->txt); + vbe32enc(b, h2e->val); + (void)H2_Send_Frame(wrk, h2, H2_FRAME_RST_STREAM, + 0, sizeof b, h2->rxf_stream, b); + Lck_Unlock(&h2->sess->mtx); + h2_del_req(wrk, r2); + Lck_Lock(&h2->sess->mtx); return (0); } @@ -580,6 +586,7 @@ h2_rxframe(struct worker *wrk, struct h2_sess *h2) { enum htc_status_e hs; h2_error h2e; + char b[8]; (void)VTCP_blocking(*h2->htc->rfd); h2->sess->t_idle = VTIM_real(); @@ -605,10 +612,15 @@ h2_rxframe(struct worker *wrk, struct h2_sess *h2) Lck_Lock(&h2->sess->mtx); h2e = h2_procframe(wrk, h2); + if (h2e) { + VSLb(h2->vsl, SLT_Debug, "H2: stream 0: %s", h2e->txt); + vbe32enc(b, h2->highest_stream); + vbe32enc(b + 4, h2e->val); + (void)H2_Send_Frame(wrk, h2, H2_FRAME_GOAWAY, + 0, sizeof b, 0, b); + } Lck_Unlock(&h2->sess->mtx); - if (h2e) - return (0); - return (1); + return (h2e ? 0 : 1); } @@ -808,7 +820,7 @@ h2_new_session(struct worker *wrk, void *arg) /* Delete all idle streams */ VTAILQ_FOREACH_SAFE(r2, &h2->streams, list, r22) { if (r2->state == H2_S_IDLE) - h2_del_req(wrk, r2, H2SE_NO_ERROR); + h2_del_req(wrk, r2); } } diff --git a/bin/varnishtest/tests/a02002.vtc b/bin/varnishtest/tests/a02002.vtc index 6907426..0ebd23e 100644 --- a/bin/varnishtest/tests/a02002.vtc +++ b/bin/varnishtest/tests/a02002.vtc @@ -5,7 +5,7 @@ server s1 { stream 1 { rxreq expect req.http.foo == - txgoaway -laststream 0 -err 9 -debug "COMPRESSION_ERROR" + txgoaway -laststream 0 -err 9 -debug "compression_error" } -run } -start @@ -15,6 +15,6 @@ client c1 -connect ${s1_sock} { rxgoaway expect goaway.err == 9 expect goaway.laststream == 0 - expect goaway.debug == "COMPRESSION_ERROR" + expect goaway.debug == "compression_error" } -run } -run diff --git a/bin/varnishtest/tests/t02003.vtc b/bin/varnishtest/tests/t02003.vtc new file mode 100644 index 0000000..64f9358 --- /dev/null +++ b/bin/varnishtest/tests/t02003.vtc @@ -0,0 +1,45 @@ +varnishtest "H2 Stream error conditions" + +server s1 { + rxreq + txresp +} -start + +varnish v1 -vcl+backend {} -start + +varnish v1 -cliok "param.set feature +http2" +varnish v1 -cliok "param.set debug +syncvsl" + +# Test WINDOW_UPDATE error conditions + +client c1 { + stream 1 { + txwinup -size 0 + rxrst + expect rst.err == PROTOCOL_ERROR + } -run + stream 3 { + txwinup -size 0x40000000 + txwinup -size 0x40000000 + rxrst + expect rst.err == FLOW_CONTROL_ERROR + } -run + stream 0 { + rxgoaway + expect goaway.laststream == 5 + expect goaway.err == FRAME_SIZE_ERROR + } -start + stream 5 { + sendhex "000003 08 00 00000005 010203" + } -run + stream 0 -wait +} -run +client c1 { + stream 0 { + txwinup -size 0x40000000 + txwinup -size 0x40000000 + rxgoaway + expect goaway.laststream == 0 + expect goaway.err == FLOW_CONTROL_ERROR + } -run +} -run From fgsch at lodoss.net Fri Feb 17 23:45:05 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sat, 18 Feb 2017 00:45:05 +0100 Subject: [master] 8723d4f Add missing header Message-ID: commit 8723d4fe5eb808c2e239d6091308e1bad7f4a415 Author: Federico G. Schwindt Date: Fri Feb 17 23:42:09 2017 +0000 Add missing header diff --git a/bin/varnishtest/vtc_subr.c b/bin/varnishtest/vtc_subr.c index 6a8f1b7..a898b12 100644 --- a/bin/varnishtest/vtc_subr.c +++ b/bin/varnishtest/vtc_subr.c @@ -28,6 +28,8 @@ #include "config.h" +#include + #include "vtc.h" #include "vct.h" From fgsch at lodoss.net Sat Feb 18 00:12:05 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sat, 18 Feb 2017 01:12:05 +0100 Subject: [master] 950439f Correct prototype Message-ID: commit 950439fdb4268f2d2f9fc57c122475853e1f54fc Author: Federico G. Schwindt Date: Sat Feb 18 00:08:29 2017 +0000 Correct prototype diff --git a/bin/varnishtest/vtc.h b/bin/varnishtest/vtc.h index 34460ce..5919913 100644 --- a/bin/varnishtest/vtc.h +++ b/bin/varnishtest/vtc.h @@ -102,7 +102,7 @@ void vtc_fatal(struct vtclog *vl, const char *, ...) void vtc_dump(struct vtclog *vl, int lvl, const char *pfx, const char *str, int len); void vtc_hexdump(struct vtclog *vl, int lvl, const char *pfx, - const unsigned char *str, int len); + const char *str, int len); int vtc_send_proxy(int fd, int version, const struct suckaddr *sac, const struct suckaddr *sas); diff --git a/bin/varnishtest/vtc_log.c b/bin/varnishtest/vtc_log.c index cee5df2..ae15e7e 100644 --- a/bin/varnishtest/vtc_log.c +++ b/bin/varnishtest/vtc_log.c @@ -233,7 +233,7 @@ vtc_dump(struct vtclog *vl, int lvl, const char *pfx, const char *str, int len) void vtc_hexdump(struct vtclog *vl, int lvl, const char *pfx, - const unsigned char *str, int len) + const char *str, int len) { int nl = 1; unsigned l; From phk at FreeBSD.org Sat Feb 18 09:09:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Sat, 18 Feb 2017 10:09:05 +0100 Subject: [master] e223671 Handle NULL pointer structs with pan_already() Message-ID: commit e22367142f00e222b237b63f7a2d97870d747c5b Author: Poul-Henning Kamp Date: Sat Feb 18 09:04:43 2017 +0000 Handle NULL pointer structs with pan_already() Say so if feature +short_panic supresses output. diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index 11390b6..bc21304 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -127,6 +127,10 @@ pan_already(struct vsb *vsb, const void *ptr) { int i; + if (ptr == NULL) { + VSB_printf(vsb, "},\n"); + return (1); + } for (i = 0; i < already_idx; i++) { if (already_list[i] == ptr) { VSB_printf(vsb, " [Already dumped, see above]\n"); @@ -635,15 +639,18 @@ pan_ic(const char *func, const char *file, int line, const char *cond, if (!FEATURE(FEATURE_SHORT_PANIC)) { req = THR_GetRequest(); - if (req != NULL) { - pan_req(pan_vsb, req); + VSB_cat(pan_vsb, "thr."); + pan_req(pan_vsb, req); + if (req != NULL) VSL_Flush(req->vsl, 0); - } bo = THR_GetBusyobj(); - if (bo != NULL) { - pan_busyobj(pan_vsb, bo); + VSB_cat(pan_vsb, "thr."); + pan_busyobj(pan_vsb, bo); + if (bo != NULL) VSL_Flush(bo->vsl, 0); - } + } else { + VSB_printf(pan_vsb, + "Feature short panic supressed details.\n"); } VSB_printf(pan_vsb, "\n"); VSB_putc(pan_vsb, '\0'); /* NUL termination */ diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index 966658b..00fda7c 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -400,7 +400,9 @@ h2_do_req(struct worker *wrk, void *priv) CAST_OBJ_NOTNULL(req, priv, REQ_MAGIC); CAST_OBJ_NOTNULL(r2, req->transport_priv, H2_REQ_MAGIC); + THR_SetRequest(req); assert(CNT_Request(wrk, req) != REQ_FSM_DISEMBARK); + THR_SetRequest(NULL); VSL(SLT_Debug, 0, "H2REQ CNT done"); /* XXX clean up req */ r2->state = H2_S_CLOSED; @@ -772,7 +774,6 @@ h2_new_session(struct worker *wrk, void *arg) assert(req->transport == &H2_transport); - THR_SetRequest(req); wsp = WS_Snapshot(wrk->aws); switch(req->err_code) { From phk at FreeBSD.org Sat Feb 18 09:09:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Sat, 18 Feb 2017 10:09:05 +0100 Subject: [master] 5455830 More H2 coverage Message-ID: commit 5455830d9361be8d4e9d97cb2ebaa12487f9cad4 Author: Poul-Henning Kamp Date: Sat Feb 18 09:07:04 2017 +0000 More H2 coverage diff --git a/bin/varnishtest/tests/t02003.vtc b/bin/varnishtest/tests/t02003.vtc index 64f9358..f2e26db 100644 --- a/bin/varnishtest/tests/t02003.vtc +++ b/bin/varnishtest/tests/t02003.vtc @@ -10,6 +10,37 @@ varnish v1 -vcl+backend {} -start varnish v1 -cliok "param.set feature +http2" varnish v1 -cliok "param.set debug +syncvsl" +# Test Even stream numbers + +client c1 { + stream 0 { + rxgoaway + expect goaway.laststream == 0 + expect goaway.err == PROTOCOL_ERROR + } -start + stream 2 { + txwinup -size 1 + } -run + stream 0 -wait +} -run + +# Test reverse order stream numbers + +client c1 { + stream 0 { + rxgoaway + expect goaway.laststream == 3 + expect goaway.err == PROTOCOL_ERROR + } -start + stream 3 { + txwinup -size 1 + } -run + stream 1 { + txwinup -size 1 + } -run + stream 0 -wait +} -run + # Test WINDOW_UPDATE error conditions client c1 { diff --git a/bin/varnishtest/tests/t02004.vtc b/bin/varnishtest/tests/t02004.vtc new file mode 100644 index 0000000..cfb5c4d --- /dev/null +++ b/bin/varnishtest/tests/t02004.vtc @@ -0,0 +1,24 @@ +varnishtest "H2 panic" + +server s1 { + rxreq + txresp +} -start + +varnish v1 -vcl+backend { + import debug; + + sub vcl_recv { + debug.panic("H2 panic"); + } +} -start + +varnish v1 -cliok "param.set feature +http2" +varnish v1 -cliok "param.set debug +syncvsl" + +client c1 { + stream 1 { + txreq -hdr :authority foo.bar -pad cotton + delay 3 + } -run +} -run From phk at FreeBSD.org Sat Feb 18 22:17:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Sat, 18 Feb 2017 23:17:05 +0100 Subject: [master] 4dbe1de Try to ensure the core dump happens before the test ends Message-ID: commit 4dbe1de2aaf8928bcdf943886c0b837db65d96c2 Author: Poul-Henning Kamp Date: Sat Feb 18 22:16:37 2017 +0000 Try to ensure the core dump happens before the test ends diff --git a/bin/varnishtest/tests/t02004.vtc b/bin/varnishtest/tests/t02004.vtc index cfb5c4d..27442ca 100644 --- a/bin/varnishtest/tests/t02004.vtc +++ b/bin/varnishtest/tests/t02004.vtc @@ -19,6 +19,8 @@ varnish v1 -cliok "param.set debug +syncvsl" client c1 { stream 1 { txreq -hdr :authority foo.bar -pad cotton - delay 3 } -run + expect_close } -run + +varnish v1 -wait-stopped From phk at FreeBSD.org Sun Feb 19 09:23:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Sun, 19 Feb 2017 10:23:05 +0100 Subject: [master] 614156b Don't dump core in files testing the panic code, to steals our gcov numbers. Message-ID: commit 614156b6eba32339a30ca4f5cc65d2eb0408253f Author: Poul-Henning Kamp Date: Sun Feb 19 09:22:28 2017 +0000 Don't dump core in files testing the panic code, to steals our gcov numbers. diff --git a/bin/varnishtest/tests/t02004.vtc b/bin/varnishtest/tests/t02004.vtc index 27442ca..b757660 100644 --- a/bin/varnishtest/tests/t02004.vtc +++ b/bin/varnishtest/tests/t02004.vtc @@ -14,6 +14,7 @@ varnish v1 -vcl+backend { } -start varnish v1 -cliok "param.set feature +http2" +varnish v1 -cliok "param.set feature +no_coredump" varnish v1 -cliok "param.set debug +syncvsl" client c1 { From varnish-commit at varnish-cache.org Mon Feb 20 05:06:10 2017 From: varnish-commit at varnish-cache.org (ks) Date: Mon, 20 Feb 2017 13:06:10 +0800 Subject: =?utf-8?B?dmFybmlzaC1jb21taXTvvJrkurrlipvotYTmupDmlYg=?= =?utf-8?B?6IO95pa556iL5byPIDQ1NzQz?= Message-ID: <20170220130616013265@jfhpfp.org> ????????? ?????? 2017?3?10-11?? 4?14,15??? 6?9,10??? ??????4980?/??????????????????? ?????? HR????????????????????????????? ?????? ???? + ???? + ???? +???? + ???? + ???? ?????? 021-31006787, 13381601000 (???) ?QQ/???320588808 ?????? 1??????HR?????????? 2?????????????????? 3??????HR??????HR??????HR?????? 4??????HR?????????? 5??????????HR????????????? ?????? 1?HR????????????????????????????????? 2?HR????????????????????????????? 3?HR????????????????????????????????? 4?HR??????????????????????????KPI????? 5?HR????????????????????????? ????? ??1?HR????? ??2?????????? ??3???????HR???? ??4?HR??????? ??5?????? ??6? HR??? ?????? ??1????????HR?????? ??2????????HR?????? ??3??????????HR?????? ??4??????????HR??? ??5????????HR?????? ??6????????????? ?????? ???? ?????HR?????????????0.5??? ??????HR???? ??????HR???? ??1?HR????? ???? HR??? ??????? 2.5??+?????2??? ????? ???HR?????????-??1????????????? ??2?????????? ????1????????HR?????? ???HR???????? ????2????????HR?????? ??2???????????????? ????? ???????????HR?????????? ????????HR???????????? 1?HR?????????? ????3??????????HR?????? 2????HR?????????????? ????4??????????HR??? ?????????HR???????????????????? ??3????ROE?28.6%???9.82%???????????????HR????????? ??5????????HR?????? ???? HR??????????2??+?????2??? ????? ???HR??????HR??????? ?IT??????????39%???8%???????55%? ??4????????????????3?? ???HR??????HR??????? 1?HR???????????????????????? ??5?????????8.3%????9.2%??????????????????????? 2?????????? ??4? HR??????? ????? ???HR???? 1????????????????5?---??????????? 2?KPI????????????? 3???????????????? ???HR???? ???? HR??????????1.5??????????????? ????? ???HR?? ??6?HR?????????? ??????? ??5?????? ????? ??7??????????????????50%????????80%????????20%? ???? HR"?"?????????1.5??? ?????HR??? ??6? HR??? ???????? ????????????? ????????????????? ???????????????? ????????????? ?????????????? ????Bel Fuse Inc.?????????????? ????500???????????? ??????????????? ???? ???20??HR??????????????????????????500????????500?????????????????????????????????????????????????????? ??????????????????????????????????????IPO???????????????????????? ?????????????????????HR??????????????????HR????????????????????????????????????????????????????????????????????????????? ???? ???????????????????HR???????????????????????????????????? ?????????????????????????smart?????????? -------------- next part -------------- An HTML attachment was scrubbed... URL: From varnish-commit at varnish-cache.org Mon Feb 20 12:38:16 2017 From: varnish-commit at varnish-cache.org (ud) Date: Mon, 20 Feb 2017 20:38:16 +0800 Subject: =?utf-8?B?dmFybmlzaC1jb21taXTvvJrouqvnu4/nmb7miJjnmoQ=?= =?utf-8?B?5aW55Li65LuA5LmI5Lya5aSx6LSl77yfIDEzOTYy?= Message-ID: <20170220203822685454@wlrjs.net> varnish-commit???? ????????????????????????? 2017/2/20 ???20:38:21 ??? -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: ????2??????.docx Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document Size: 19876 bytes Desc: not available URL: From nils.goroll at uplex.de Mon Feb 20 14:02:06 2017 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 20 Feb 2017 15:02:06 +0100 Subject: [master] bfab0a1 check for python >= 2.7 Message-ID: commit bfab0a1ffa174b8c59ac5ed2f3f38a18ee7afe61 Author: Nils Goroll Date: Mon Feb 20 15:00:00 2017 +0100 check for python >= 2.7 a29fca70f7ccc75964bcfffb8c8ab1617fcf2bba requires subprocess.check_output which was added with Python 2.7 diff --git a/configure.ac b/configure.ac index 7c46d40..3f057e3 100644 --- a/configure.ac +++ b/configure.ac @@ -345,11 +345,20 @@ else fi AM_MISSING_HAS_RUN -AC_CHECK_PROGS(PYTHON, [python3 python3.1 python3.2 python2.7 python2.6 python2.5 python2 python], "no") +AC_CHECK_PROGS(PYTHON, [python3 python3.1 python3.2 python2.7 python2 python], "no") if test "x$PYTHON" = "xno"; then - AC_MSG_ERROR([Python is needed to build Varnish, please install python.]) + AC_MSG_ERROR([Python is needed to build Varnish, please install python 2.7 or later.]) fi +py_ver=`"$PYTHON" -V 2>&1` +case "$py_ver" in +Python?3.* | Python?2.[7-9].*) + ;; +*) + AC_MSG_ERROR([Python >= 2.7 is required]) + ;; +esac + AC_CHECK_DECL([SO_ACCEPTFILTER], AC_DEFINE(HAVE_ACCEPT_FILTERS,1,[Define to 1 if you have accept filters]), , From dridi.boukelmoune at gmail.com Mon Feb 20 14:17:05 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 20 Feb 2017 15:17:05 +0100 Subject: [master] 39551cd Check for python >= 2.7 Message-ID: commit 39551cdc91e6de1b93c47a4988a3e2bfaca55913 Author: Dridi Boukelmoune Date: Mon Feb 20 15:16:16 2017 +0100 Check for python >= 2.7 diff --git a/configure.ac b/configure.ac index 3f057e3..4413e92 100644 --- a/configure.ac +++ b/configure.ac @@ -345,19 +345,10 @@ else fi AM_MISSING_HAS_RUN -AC_CHECK_PROGS(PYTHON, [python3 python3.1 python3.2 python2.7 python2 python], "no") -if test "x$PYTHON" = "xno"; then - AC_MSG_ERROR([Python is needed to build Varnish, please install python 2.7 or later.]) -fi -py_ver=`"$PYTHON" -V 2>&1` -case "$py_ver" in -Python?3.* | Python?2.[7-9].*) - ;; -*) - AC_MSG_ERROR([Python >= 2.7 is required]) - ;; -esac +AM_PATH_PYTHON([2.7], [], [ + AC_MSG_ERROR([Python 2.7 or later is needed to build Varnish.]) +]) AC_CHECK_DECL([SO_ACCEPTFILTER], AC_DEFINE(HAVE_ACCEPT_FILTERS,1,[Define to 1 if you have accept filters]), diff --git a/varnish.m4 b/varnish.m4 index f3894ce..874c055 100644 --- a/varnish.m4 +++ b/varnish.m4 @@ -114,8 +114,8 @@ AC_DEFUN([_VARNISH_VMOD_CONFIG], [ AC_REQUIRE([AC_PROG_CPP]) AC_REQUIRE([AC_PROG_CPP_WERROR]) - AM_PATH_PYTHON([2.6], [], [ - AC_MSG_ERROR([Python is needed to build VMODs.]) + AM_PATH_PYTHON([2.7], [], [ + AC_MSG_ERROR([Python 2.7 or later is needed to build VMODs.]) ]) AS_IF([test -z "$RST2MAN"], [ From hermunn at varnish-software.com Mon Feb 20 15:08:05 2017 From: hermunn at varnish-software.com (Pål Hermunn Johansen) Date: Mon, 20 Feb 2017 16:08:05 +0100 Subject: [4.1] b9a6cf5 Remove duplicated word to improve reading pleasure Message-ID: commit b9a6cf56858ddecda828ef78e17e87a719eea545 Author: Matthias Viehweger Date: Thu Feb 9 14:16:15 2017 +0100 Remove duplicated word to improve reading pleasure diff --git a/doc/sphinx/users-guide/run_security.rst b/doc/sphinx/users-guide/run_security.rst index 2beb4aa..c4a89d9 100644 --- a/doc/sphinx/users-guide/run_security.rst +++ b/doc/sphinx/users-guide/run_security.rst @@ -160,8 +160,7 @@ Furthermore you may want to look at and lock down: :ref:`ref_param_vcc_unsafe_path` Restrict VCL/VMODS to :ref:`ref_param_vcl_dir` and :ref:`ref_param_vmod_dir` -:ref:`ref_param_vmod_dir` - The directory where Varnish will will look + The directory where Varnish will look for modules. This could potentially be used to load rouge modules into Varnish. From hermunn at varnish-software.com Mon Feb 20 15:13:05 2017 From: hermunn at varnish-software.com (Pål Hermunn Johansen) Date: Mon, 20 Feb 2017 16:13:05 +0100 Subject: [4.1] 3e4cd0b Fix my previous cherry-pick Message-ID: commit 3e4cd0b2844421f0c6eb0e849d9f22c0e336d1d0 Author: P?l Hermunn Johansen Date: Mon Feb 20 16:11:07 2017 +0100 Fix my previous cherry-pick The previous cherry-pick was bad. This should fix it. diff --git a/doc/sphinx/users-guide/run_security.rst b/doc/sphinx/users-guide/run_security.rst index c4a89d9..83d036b 100644 --- a/doc/sphinx/users-guide/run_security.rst +++ b/doc/sphinx/users-guide/run_security.rst @@ -160,6 +160,7 @@ Furthermore you may want to look at and lock down: :ref:`ref_param_vcc_unsafe_path` Restrict VCL/VMODS to :ref:`ref_param_vcl_dir` and :ref:`ref_param_vmod_dir` +:ref:`ref_param_vmod_dir` The directory where Varnish will look for modules. This could potentially be used to load rouge modules into Varnish. From phk at FreeBSD.org Mon Feb 20 23:06:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 21 Feb 2017 00:06:05 +0100 Subject: [master] 656982a Some experiemental code to deconfigure a thread pool. Message-ID: commit 656982a5cf7042a8576c2e9d48defcd25d749fbd Author: Poul-Henning Kamp Date: Mon Feb 20 23:03:35 2017 +0000 Some experiemental code to deconfigure a thread pool. The fundamental problem still exists, in that we have no way to tickle the threads stuck in accept(2), so for now this remains a debugging feature. If this (=c00080.vtc) explodes on some platform, start looking at the Waiter_Destroy() implementation. diff --git a/bin/varnishd/cache/cache_acceptor.c b/bin/varnishd/cache/cache_acceptor.c index d764d1b..b570db2 100644 --- a/bin/varnishd/cache/cache_acceptor.c +++ b/bin/varnishd/cache/cache_acceptor.c @@ -68,6 +68,7 @@ struct wrk_accept { struct poolsock { unsigned magic; #define POOLSOCK_MAGIC 0x1b0a2d38 + VTAILQ_ENTRY(poolsock) list; struct listen_sock *lsock; struct pool_task task; struct pool *pool; @@ -402,7 +403,7 @@ vca_accept_task(struct worker *wrk, void *arg) while (!pool_accepting) VTIM_sleep(.1); - while (1) { + while (!ps->pool->die) { INIT_OBJ(&wa, WRK_ACCEPT_MAGIC); wa.acceptlsock = ls; @@ -414,6 +415,12 @@ vca_accept_task(struct worker *wrk, void *arg) &wa.acceptaddrlen); } while (i < 0 && errno == EAGAIN); + if (i < 0 && ps->pool->die) { + VSL(SLT_Debug, 0, "XXX Accept thread dies %p", ps); + FREE_OBJ(ps); + return; + } + if (i < 0 && ls->sock == -2) { /* Shut down in progress */ sleep(2); @@ -454,7 +461,9 @@ vca_accept_task(struct worker *wrk, void *arg) * must reschedule the listening task so it will be * taken up by another thread again. */ - AZ(Pool_Task(wrk->pool, &ps->task, TASK_QUEUE_VCA)); + if (!ps->pool->die) + AZ(Pool_Task(wrk->pool, &ps->task, + TASK_QUEUE_VCA)); return; } @@ -485,10 +494,22 @@ VCA_NewPool(struct pool *pp) ps->task.func = vca_accept_task; ps->task.priv = ps; ps->pool = pp; + VTAILQ_INSERT_TAIL(&pp->poolsocks, ps, list); AZ(Pool_Task(pp, &ps->task, TASK_QUEUE_VCA)); } } +void +VCA_DestroyPool(struct pool *pp) +{ + struct poolsock *ps; + + while (!VTAILQ_EMPTY(&pp->poolsocks)) { + ps = VTAILQ_FIRST(&pp->poolsocks); + VTAILQ_REMOVE(&pp->poolsocks, ps, list); + } +} + /*--------------------------------------------------------------------*/ static void * diff --git a/bin/varnishd/cache/cache_pool.c b/bin/varnishd/cache/cache_pool.c index be26db4..57b7e8d 100644 --- a/bin/varnishd/cache/cache_pool.c +++ b/bin/varnishd/cache/cache_pool.c @@ -161,6 +161,7 @@ pool_mkpool(unsigned pool_no) Lck_New(&pp->mtx, lck_wq); VTAILQ_INIT(&pp->idle_queue); + VTAILQ_INIT(&pp->poolsocks); for (i = 0; i < TASK_QUEUE_END; i++) VTAILQ_INIT(&pp->queues[i]); AZ(pthread_cond_init(&pp->herder_cond, NULL)); @@ -187,8 +188,9 @@ static void * pool_poolherder(void *priv) { unsigned nwq; - struct pool *pp; + struct pool *pp, *ppx; uint64_t u; + void *rvp; THR_SetName("pool_poolherder"); (void)priv; @@ -205,23 +207,42 @@ pool_poolherder(void *priv) nwq++; continue; } - } - /* XXX: remove pools */ - if (0) { + } else if (nwq > cache_param->wthread_pools && + DO_DEBUG(DBG_DROP_POOLS)) { Lck_Lock(&pool_mtx); pp = VTAILQ_FIRST(&pools); + AN(pp); VTAILQ_REMOVE(&pools, pp, list); + VTAILQ_INSERT_TAIL(&pools, pp, list); + if (!pp->die) + nwq--; Lck_Unlock(&pool_mtx); - AN(pp); - MPL_Destroy(&pp->mpl_sess); - MPL_Destroy(&pp->mpl_req); - INCOMPL(); + if (!pp->die) { + VSL(SLT_Debug, 0, "XXX Kill Pool %p", pp); + pp->die = 1; + VCA_DestroyPool(pp); + AZ(pthread_cond_signal(&pp->herder_cond)); + } } (void)sleep(1); u = 0; + ppx = NULL; Lck_Lock(&pool_mtx); - VTAILQ_FOREACH(pp, &pools, list) + VTAILQ_FOREACH(pp, &pools, list) { + if (pp->die && pp->nthr == 0) + ppx = pp; u += pp->lqueue; + } + if (ppx != NULL) { + VTAILQ_REMOVE(&pools, ppx, list); + AZ(pthread_join(ppx->herder_thr, &rvp)); + AZ(pthread_cond_destroy(&ppx->herder_cond)); + free(ppx->a_stat); + free(ppx->b_stat); + SES_DestroyPool(ppx); + FREE_OBJ(ppx); + VSC_C_main->pools--; + } Lck_Unlock(&pool_mtx); VSC_C_main->thread_queue_len = u; } diff --git a/bin/varnishd/cache/cache_pool.h b/bin/varnishd/cache/cache_pool.h index 83359ce..98e43ca 100644 --- a/bin/varnishd/cache/cache_pool.h +++ b/bin/varnishd/cache/cache_pool.h @@ -31,11 +31,15 @@ VTAILQ_HEAD(taskhead, pool_task); +struct poolsock; + struct pool { unsigned magic; #define POOL_MAGIC 0x606658fa VTAILQ_ENTRY(pool) list; + VTAILQ_HEAD(,poolsock) poolsocks; + int die; pthread_cond_t herder_cond; pthread_t herder_thr; @@ -59,4 +63,5 @@ struct pool { void *pool_herder(void*); task_func_t pool_stat_summ; extern struct lock pool_mtx; -void VCA_NewPool(struct pool *pp); +void VCA_NewPool(struct pool *); +void VCA_DestroyPool(struct pool *); diff --git a/bin/varnishd/cache/cache_priv.h b/bin/varnishd/cache/cache_priv.h index dd88025..abf5e7f 100644 --- a/bin/varnishd/cache/cache_priv.h +++ b/bin/varnishd/cache/cache_priv.h @@ -99,6 +99,7 @@ task_func_t VPX_Proto_Sess; /* cache_session.c */ void SES_NewPool(struct pool *, unsigned pool_no); +void SES_DestroyPool(struct pool *); /* cache_shmlog.c */ void VSM_Init(void); diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c index dc671ea..1c0c6d7 100644 --- a/bin/varnishd/cache/cache_session.c +++ b/bin/varnishd/cache/cache_session.c @@ -600,3 +600,11 @@ SES_NewPool(struct pool *pp, unsigned pool_no) pp->waiter = Waiter_New(); } + +void +SES_DestroyPool(struct pool *pp) +{ + MPL_Destroy(&pp->mpl_req); + MPL_Destroy(&pp->mpl_sess); + Waiter_Destroy(&pp->waiter); +} diff --git a/bin/varnishd/cache/cache_wrk.c b/bin/varnishd/cache/cache_wrk.c index e28d993..f3dfc3b 100644 --- a/bin/varnishd/cache/cache_wrk.c +++ b/bin/varnishd/cache/cache_wrk.c @@ -465,14 +465,17 @@ pool_herder(void *priv) struct pool_task *pt; double t_idle; struct worker *wrk; - int delay, wthread_min; + double delay; + int wthread_min; CAST_OBJ_NOTNULL(pp, priv, POOL_MAGIC); THR_SetName("pool_herder"); - while (1) { + while (!pp->die || pp->nthr > 0) { wthread_min = cache_param->wthread_min; + if (pp->die) + wthread_min = 0; /* Make more threads if needed and allowed */ if (pp->nthr < wthread_min || @@ -501,7 +504,7 @@ pool_herder(void *priv) AZ(pt->func); CAST_OBJ_NOTNULL(wrk, pt->priv, WORKER_MAGIC); - if (wrk->lastused < t_idle || + if (pp->die || wrk->lastused < t_idle || pp->nthr > cache_param->wthread_max) { /* Give it a kiss on the cheek... */ VTAILQ_REMOVE(&pp->idle_queue, @@ -527,6 +530,14 @@ pool_herder(void *priv) delay = cache_param->wthread_destroy_delay; } + if (pp->die) { + if (delay < 2) + delay = 10e-3; + else + delay = 1; + VTIM_sleep(delay); + continue; + } Lck_Lock(&pp->mtx); if (!pp->dry) { (void)Lck_CondWait(&pp->herder_cond, &pp->mtx, @@ -538,5 +549,5 @@ pool_herder(void *priv) } Lck_Unlock(&pp->mtx); } - NEEDLESS(return NULL); + return (NULL); } diff --git a/bin/varnishtest/tests/c00080.vtc b/bin/varnishtest/tests/c00080.vtc new file mode 100644 index 0000000..ce96a55 --- /dev/null +++ b/bin/varnishtest/tests/c00080.vtc @@ -0,0 +1,36 @@ +varnishtest "Deconfigure thread pool" + +server s1 { + rxreq + txresp +} -start + +varnish v1 -vcl+backend {} -start + +varnish v1 -cliok "param.set debug +drop_pools" +varnish v1 -cliok "param.set thread_pools 1" + +delay 2 + +client c1 { + txreq + rxresp +} -run + +varnish v1 -vsc *poo* + +delay 2 + +client c1 { + txreq + rxresp +} -run + +varnish v1 -vsc *poo* +varnish v1 -expect MAIN.pools == 1 + +client c1 { + txreq + rxresp +} -run + diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c index 9616260..e0dce91 100644 --- a/bin/varnishtest/vtc_varnish.c +++ b/bin/varnishtest/vtc_varnish.c @@ -823,9 +823,9 @@ do_stat_dump_cb(void *priv, const struct VSC_point * const pt) strcpy(buf, pt->section->type); if (pt->section->ident[0] != '\0') - bprintf(buf, ".%s.%s", pt->section->ident, pt->desc->name); + bprintf(buf, "%s.%s", pt->section->ident, pt->desc->name); else - bprintf(buf, ".%s", pt->desc->name); + bprintf(buf, "MAIN.%s", pt->desc->name); if (strcmp(dp->arg, "*")) { if (fnmatch(dp->arg, buf, 0)) From phk at FreeBSD.org Mon Feb 20 23:09:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 21 Feb 2017 00:09:05 +0100 Subject: [master] f8ea87c Forgot this in previous commit. Message-ID: commit f8ea87cb22347ca00fda5d0fcf5b82ed8ff1b2e8 Author: Poul-Henning Kamp Date: Mon Feb 20 23:08:07 2017 +0000 Forgot this in previous commit. diff --git a/include/tbl/debug_bits.h b/include/tbl/debug_bits.h index b354921..ea6bf35 100644 --- a/include/tbl/debug_bits.h +++ b/include/tbl/debug_bits.h @@ -44,6 +44,7 @@ DEBUG_BIT(FLUSH_HEAD, flush_head, "Flush after http1 head") DEBUG_BIT(VTC_MODE, vtc_mode, "Varnishtest Mode") DEBUG_BIT(WITNESS, witness, "Emit WITNESS lock records") DEBUG_BIT(VSM_KEEP, vsm_keep, "Keep the VSM file on restart") +DEBUG_BIT(DROP_POOLS, drop_pools, "Drop thread pools (testing)") #undef DEBUG_BIT /*lint -restore */ From dridi.boukelmoune at gmail.com Tue Feb 21 08:17:04 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 21 Feb 2017 09:17:04 +0100 Subject: [master] d437198 Dogfooding Message-ID: commit d43719819face735e43eb30bfbc5c06e0f5cd6a6 Author: Dridi Boukelmoune Date: Tue Feb 21 09:09:41 2017 +0100 Dogfooding It could also probably be improved further, we've been detecting python _after_ looking for python-based tools rst2*. Or we can keep unrelated checks, I don't think it hurts. diff --git a/configure.ac b/configure.ac index 4413e92..84afb95 100644 --- a/configure.ac +++ b/configure.ac @@ -67,7 +67,10 @@ AC_ARG_WITH([dot], fi]) AM_CONDITIONAL(HAVE_DOT,[test "x$DOT" != "xno"]) -# Checks for libraries. +# Check for python. +_VARNISH_CHECK_PYTHON + +# Check for libraries. _VARNISH_SEARCH_LIBS(pthread, pthread_create, [thr pthread c_r]) _VARNISH_CHECK_LIB(rt, clock_gettime) _VARNISH_CHECK_LIB(dl, dlopen) @@ -346,10 +349,6 @@ fi AM_MISSING_HAS_RUN -AM_PATH_PYTHON([2.7], [], [ - AC_MSG_ERROR([Python 2.7 or later is needed to build Varnish.]) -]) - AC_CHECK_DECL([SO_ACCEPTFILTER], AC_DEFINE(HAVE_ACCEPT_FILTERS,1,[Define to 1 if you have accept filters]), , diff --git a/varnish.m4 b/varnish.m4 index 874c055..efb3c3b 100644 --- a/varnish.m4 +++ b/varnish.m4 @@ -101,6 +101,16 @@ AC_DEFUN([_VARNISH_CHECK_DEVEL], [ [CPPFLAGS=$_orig_cppflags] ]) +# _VARNISH_CHECK_PYTHON +# --------------------- +AC_DEFUN([_VARNISH_CHECK_PYTHON], [ + + AM_PATH_PYTHON([2.7], [], [ + AC_MSG_ERROR([Python >= 2.7 is required.]) + ]) + +]) + # _VARNISH_VMOD_CONFIG # -------------------- AC_DEFUN([_VARNISH_VMOD_CONFIG], [ @@ -114,9 +124,7 @@ AC_DEFUN([_VARNISH_VMOD_CONFIG], [ AC_REQUIRE([AC_PROG_CPP]) AC_REQUIRE([AC_PROG_CPP_WERROR]) - AM_PATH_PYTHON([2.7], [], [ - AC_MSG_ERROR([Python 2.7 or later is needed to build VMODs.]) - ]) + _VARNISH_CHECK_PYTHON AS_IF([test -z "$RST2MAN"], [ AC_MSG_ERROR([rst2man is needed to build VMOD manuals.]) From nils.goroll at uplex.de Tue Feb 21 12:35:06 2017 From: nils.goroll at uplex.de (Nils Goroll) Date: Tue, 21 Feb 2017 13:35:06 +0100 Subject: [master] aef7f5c try to stabilize this test Message-ID: commit aef7f5cd0304acf42101d1d41a2c9d6029a1a2f6 Author: Nils Goroll Date: Tue Feb 21 13:34:26 2017 +0100 try to stabilize this test diff --git a/bin/varnishtest/tests/c00080.vtc b/bin/varnishtest/tests/c00080.vtc index ce96a55..6a53959 100644 --- a/bin/varnishtest/tests/c00080.vtc +++ b/bin/varnishtest/tests/c00080.vtc @@ -27,6 +27,15 @@ client c1 { } -run varnish v1 -vsc *poo* + +delay 2 + +client c1 { + txreq + rxresp +} -run + +varnish v1 -vsc *poo* varnish v1 -expect MAIN.pools == 1 client c1 { From dridi.boukelmoune at gmail.com Tue Feb 21 12:43:05 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 21 Feb 2017 13:43:05 +0100 Subject: [master] 276f021 Revert "Document VRT_ipcmp wrt bumping VRT API version" Message-ID: commit 276f021ce066dd336cbd93b64bb2aa1ce3680600 Author: Dridi Boukelmoune Date: Tue Feb 21 13:31:59 2017 +0100 Revert "Document VRT_ipcmp wrt bumping VRT API version" This reverts commit 95d8b34eb403746700870813efe40731a8a0c63e, this symbol is not "old". Refs #2142 #2145 diff --git a/include/vrt.h b/include/vrt.h index 88884d4..d3aee0b 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -46,11 +46,10 @@ * 3.2: * vrt_backend grew .proxy_header field * vrt_ctx grew .sp field. - * older version: * + * older version: * Bump VRT_MINOR_VERSION due to: * - VCL_ACL type added - * - VRT_ipcmp() added * Bump VRT_MAJOR_VERSION due to: * - VRT_CacheReqBody changed signature * From dridi.boukelmoune at gmail.com Tue Feb 21 12:43:05 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 21 Feb 2017 13:43:05 +0100 Subject: [master] b5a5122 Move "older version" VRT changes where they belong Message-ID: commit b5a51221ddf21ba3a930a36709ca47d343b51c89 Author: Dridi Boukelmoune Date: Fri Nov 25 00:31:02 2016 +0100 Move "older version" VRT changes where they belong Originally from #2145 diff --git a/include/vrt.h b/include/vrt.h index d3aee0b..6fdb18e 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -43,16 +43,11 @@ * Varnish 5.0 release "better safe than sorry" bump * 4.0: * VCL_BYTES changed to long long + * VRT_CacheReqBody changed signature * 3.2: * vrt_backend grew .proxy_header field * vrt_ctx grew .sp field. - * - * older version: - * Bump VRT_MINOR_VERSION due to: - * - VCL_ACL type added - * Bump VRT_MAJOR_VERSION due to: - * - VRT_CacheReqBody changed signature - * + * vrt_acl type added */ #define VRT_MAJOR_VERSION 5U From dridi.boukelmoune at gmail.com Tue Feb 21 12:43:05 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 21 Feb 2017 13:43:05 +0100 Subject: [master] c0a6194 Inaugurate ongoing VRT changes after 5.0 Message-ID: commit c0a61945271606b36b482dbf289c3b0918dcfd32 Author: Dridi Boukelmoune Date: Fri Nov 25 00:32:48 2016 +0100 Inaugurate ongoing VRT changes after 5.0 Originally from #2145 diff --git a/include/vrt.h b/include/vrt.h index 6fdb18e..e4354a2 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -39,6 +39,12 @@ * binary/load-time compatible, increment MAJOR version * * + * 6.0 (unreleased): + * VRT_ipcmp added + * WS_Reset and WS_Snapshot signatures changed + * WS_Front added + * WS_ReserveLumps added + * WS_Inside added * 5.0: * Varnish 5.0 release "better safe than sorry" bump * 4.0: @@ -50,7 +56,7 @@ * vrt_acl type added */ -#define VRT_MAJOR_VERSION 5U +#define VRT_MAJOR_VERSION 6U #define VRT_MINOR_VERSION 0U From dridi.boukelmoune at gmail.com Tue Feb 21 13:06:05 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 21 Feb 2017 14:06:05 +0100 Subject: [master] 6db7d75 Use closefd() throughout, take 2 Message-ID: commit 6db7d750d1340f7c28d1102d2d24ac1a3f290a38 Author: Dridi Boukelmoune Date: Tue Feb 21 13:58:17 2017 +0100 Use closefd() throughout, take 2 This patch was created using Coccinelle and the following steps: $ cat >closefd.cocci <name, strerror(errno), errno); @@ -193,7 +193,7 @@ barrier_sock_thread(void *priv) i = accept(sock, NULL, NULL); if (i < 0) { - AZ(close(sock)); + closefd(&sock); vtc_fatal(vl, "Barrier(%s) accept fails: %s (errno=%d)", b->name, strerror(errno), errno); @@ -212,7 +212,7 @@ barrier_sock_thread(void *priv) vtc_log(vl, 4, "Barrier(%s) wake %u", b->name, b->expected); for (i = 0; i < b->expected; i++) - AZ(close(conns[i])); + closefd(&conns[i]); if (b->cyclic) b->waiters = 0; @@ -223,7 +223,7 @@ barrier_sock_thread(void *priv) macro_undef(vl, b->name, "addr"); macro_undef(vl, b->name, "port"); macro_undef(vl, b->name, "sock"); - AZ(close(sock)); + closefd(&sock); free(conns); return (NULL); @@ -324,7 +324,7 @@ barrier_sock_sync(struct barrier *b, struct vtclog *vl) AZ(pthread_mutex_lock(&b->mtx)); i = errno; - AZ(close(sock)); + closefd(&sock); if (sz < 0) vtc_fatal(vl, "Barrier(%s) read failed: %s (errno=%d)", diff --git a/bin/varnishtest/vtc_main.c b/bin/varnishtest/vtc_main.c index c18f355..f4ed03e 100644 --- a/bin/varnishtest/vtc_main.c +++ b/bin/varnishtest/vtc_main.c @@ -45,6 +45,7 @@ #include "vtc.h" +#include "vdef.h" #include "vev.h" #include "vfil.h" #include "vnum.h" @@ -312,7 +313,7 @@ start_test(void) jp->tmpdir, jp->buf, jp->bufsiz); exit(retval); } - AZ(close(p[1])); + closefd(&p[1]); jp->ev = vev_new(); AN(jp->ev); diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c index e0dce91..54ec8b8 100644 --- a/bin/varnishtest/vtc_varnish.c +++ b/bin/varnishtest/vtc_varnish.c @@ -445,10 +445,10 @@ varnish_launch(struct varnish *v) AZ(dup2(v->fds[0], 0)); assert(dup2(v->fds[3], 1) == 1); assert(dup2(1, 2) == 2); - AZ(close(v->fds[0])); - AZ(close(v->fds[1])); - AZ(close(v->fds[2])); - AZ(close(v->fds[3])); + closefd(&v->fds[0]); + closefd(&v->fds[1]); + closefd(&v->fds[2]); + closefd(&v->fds[3]); VSUB_closefrom(STDERR_FILENO + 1); AZ(execl("/bin/sh", "/bin/sh", "-c", VSB_data(vsb), (char*)0)); exit(1); @@ -457,8 +457,8 @@ varnish_launch(struct varnish *v) macro_def(v->vl, v->name, "pid", "%ld", (long)v->pid); macro_def(v->vl, v->name, "name", "%s", v->workdir); } - AZ(close(v->fds[0])); - AZ(close(v->fds[3])); + closefd(&v->fds[0]); + closefd(&v->fds[3]); v->fds[0] = v->fds[2]; v->fds[2] = v->fds[3] = -1; VSB_destroy(&vsb); @@ -482,12 +482,12 @@ varnish_launch(struct varnish *v) vtc_fatal(v->vl, "FAIL CLI connection wait failure"); nfd = accept(v->cli_fd, NULL, NULL); if (nfd < 0) { - AZ(close(v->cli_fd)); + closefd(&v->cli_fd); v->cli_fd = -1; vtc_fatal(v->vl, "FAIL no CLI connection accepted"); } - AZ(close(v->cli_fd)); + closefd(&v->cli_fd); v->cli_fd = nfd; vtc_log(v->vl, 3, "CLI connection fd = %d", v->cli_fd); @@ -507,7 +507,7 @@ varnish_launch(struct varnish *v) assert(sizeof abuf >= CLI_AUTH_RESPONSE_LEN + 7); strcpy(abuf, "auth "); VCLI_AuthResponse(nfd, r, abuf + 5); - AZ(close(nfd)); + closefd(&nfd); free(r); r = NULL; strcat(abuf, "\n"); @@ -619,15 +619,15 @@ varnish_cleanup(struct varnish *v) (void)usleep(200000); /* Close the CLI connection */ - AZ(close(v->cli_fd)); + closefd(&v->cli_fd); v->cli_fd = -1; /* Close the STDIN connection. */ - AZ(close(v->fds[1])); + closefd(&v->fds[1]); /* Wait until STDOUT+STDERR closes */ AZ(pthread_join(v->tp, &p)); - AZ(close(v->fds[0])); + closefd(&v->fds[0]); r = wait4(v->pid, &status, 0, &ru); v->pid = 0; diff --git a/lib/libvarnish/vfil.c b/lib/libvarnish/vfil.c index ac39aff..55da29f 100644 --- a/lib/libvarnish/vfil.c +++ b/lib/libvarnish/vfil.c @@ -71,7 +71,7 @@ VFIL_null_fd(int target) fd = open("/dev/null", O_RDWR); assert(fd >= 0); assert(dup2(fd, target) == target); - AZ(close(fd)); + closefd(&fd); } static char * @@ -143,7 +143,7 @@ VFIL_readfile(const char *pfx, const char *fn, ssize_t *sz) return (NULL); r = vfil_readfd(fd, sz); err = errno; - AZ(close(fd)); + closefd(&fd); errno = err; return (r); } @@ -159,7 +159,7 @@ VFIL_writefile(const char *pfx, const char *fn, const char *buf, size_t sz) return (fd); r = vfil_writefd(fd, buf, sz); err = errno; - AZ(close(fd)); + closefd(&fd); errno = err; return (r); } diff --git a/lib/libvarnish/vrnd.c b/lib/libvarnish/vrnd.c index d586b08..e38f0a7 100644 --- a/lib/libvarnish/vrnd.c +++ b/lib/libvarnish/vrnd.c @@ -41,6 +41,7 @@ #include #include "vas.h" +#include "vdef.h" #include "vrnd.h" /********************************************************************** @@ -158,7 +159,7 @@ VRND_RandomCrypto(void *ptr, size_t len) if (l != 1) break; } - AZ(close(fd)); + closefd(&fd); return (len == 0 ? 0 : -1); } diff --git a/lib/libvarnish/vsub.c b/lib/libvarnish/vsub.c index 57b40b8..ea86699 100644 --- a/lib/libvarnish/vsub.c +++ b/lib/libvarnish/vsub.c @@ -109,8 +109,8 @@ VSUB_run(struct vsb *sb, vsub_func_f *func, void *priv, const char *name, if ((pid = fork()) < 0) { VSB_printf(sb, "Starting %s: fork() failed: %s", name, strerror(errno)); - AZ(close(p[0])); - AZ(close(p[1])); + closefd(&p[0]); + closefd(&p[1]); return (1); } if (pid == 0) { @@ -127,11 +127,11 @@ VSUB_run(struct vsb *sb, vsub_func_f *func, void *priv, const char *name, */ _exit(4); } - AZ(close(p[1])); + closefd(&p[1]); vlu = VLU_New(&sp, vsub_vlu, 0); while (!VLU_Fd(p[0], vlu)) continue; - AZ(close(p[0])); + closefd(&p[0]); VLU_Destroy(vlu); if (sp.maxlines >= 0 && sp.lines > sp.maxlines) VSB_printf(sb, "[%d lines truncated]\n", diff --git a/lib/libvarnish/vtcp.c b/lib/libvarnish/vtcp.c index d28b99c..67be8a0 100644 --- a/lib/libvarnish/vtcp.c +++ b/lib/libvarnish/vtcp.c @@ -262,7 +262,7 @@ VTCP_connected(int s) /* An error means no connection established */ errno = k; if (k) { - AZ(close(s)); + closefd(&s); return (-1); } @@ -302,7 +302,7 @@ VTCP_connect(const struct suckaddr *name, int msec) if (i == 0) return (s); if (errno != EINPROGRESS) { - AZ(close(s)); + closefd(&s); return (-1); } @@ -323,7 +323,7 @@ VTCP_connect(const struct suckaddr *name, int msec) if (i == 0) { /* Timeout, close and give up */ - AZ(close(s)); + closefd(&s); errno = ETIMEDOUT; return (-1); } @@ -430,7 +430,7 @@ VTCP_bind(const struct suckaddr *sa, const char **errp) if (errp != NULL) *errp = "setsockopt(SO_REUSEADDR, 1)"; e = errno; - AZ(close(sd)); + closefd(&sd); errno = e; return (-1); } @@ -442,7 +442,7 @@ VTCP_bind(const struct suckaddr *sa, const char **errp) if (errp != NULL) *errp = "setsockopt(IPV6_V6ONLY, 1)"; e = errno; - AZ(close(sd)); + closefd(&sd); errno = e; return (-1); } @@ -452,7 +452,7 @@ VTCP_bind(const struct suckaddr *sa, const char **errp) if (errp != NULL) *errp = "bind(2)"; e = errno; - AZ(close(sd)); + closefd(&sd); errno = e; return (-1); } @@ -476,7 +476,7 @@ VTCP_listen(const struct suckaddr *sa, int depth, const char **errp) if (sd >= 0) { if (listen(sd, depth) != 0) { e = errno; - AZ(close(sd)); + closefd(&sd); errno = e; if (errp != NULL) *errp = "listen(2)"; diff --git a/lib/libvarnishapi/daemon.c b/lib/libvarnishapi/daemon.c index 93e3bef..2ac2697 100644 --- a/lib/libvarnishapi/daemon.c +++ b/lib/libvarnishapi/daemon.c @@ -55,7 +55,7 @@ vfil_null_fd(int target) fd = open("/dev/null", O_RDWR); assert(fd >= 0); assert(dup2(fd, target) == target); - AZ(close(fd)); + closefd(&fd); } int diff --git a/lib/libvarnishapi/vsm.c b/lib/libvarnishapi/vsm.c index f3fd9f4..250bdab 100644 --- a/lib/libvarnishapi/vsm.c +++ b/lib/libvarnishapi/vsm.c @@ -239,7 +239,7 @@ VSM_Open(struct VSM_data *vd) AZ(fstat(vd->vsm_fd, &vd->fstat)); if (!S_ISREG(vd->fstat.st_mode)) { - AZ(close(vd->vsm_fd)); + closefd(&vd->vsm_fd); vd->vsm_fd = -1; return (vsm_diag(vd, "%s is not a regular file", vd->fname)); @@ -247,20 +247,20 @@ VSM_Open(struct VSM_data *vd) i = read(vd->vsm_fd, &slh, sizeof slh); if (i != sizeof slh) { - AZ(close(vd->vsm_fd)); + closefd(&vd->vsm_fd); vd->vsm_fd = -1; return (vsm_diag(vd, "Cannot read %s: %s", vd->fname, strerror(errno))); } if (memcmp(slh.marker, VSM_HEAD_MARKER, sizeof slh.marker)) { - AZ(close(vd->vsm_fd)); + closefd(&vd->vsm_fd); vd->vsm_fd = -1; return (vsm_diag(vd, "Not a VSM file %s", vd->fname)); } if (!vd->N_opt && slh.alloc_seq == 0) { - AZ(close(vd->vsm_fd)); + closefd(&vd->vsm_fd); vd->vsm_fd = -1; return (vsm_diag(vd, "Abandoned VSM file (Varnish not running?) %s", @@ -270,7 +270,7 @@ VSM_Open(struct VSM_data *vd) v = mmap(NULL, slh.shm_size, PROT_READ, MAP_SHARED|MAP_HASSEMAPHORE, vd->vsm_fd, 0); if (v == MAP_FAILED) { - AZ(close(vd->vsm_fd)); + closefd(&vd->vsm_fd); vd->vsm_fd = -1; return (vsm_diag(vd, "Cannot mmap %s: %s", vd->fname, strerror(errno))); @@ -310,7 +310,7 @@ VSM_Close(struct VSM_data *vd) vd->b = NULL; vd->e = NULL; vd->head = NULL; - AZ(close(vd->vsm_fd)); + closefd(&vd->vsm_fd); vd->vsm_fd = -1; } diff --git a/lib/libvmod_debug/vmod_debug.c b/lib/libvmod_debug/vmod_debug.c index 76519f7..fe07219 100644 --- a/lib/libvmod_debug/vmod_debug.c +++ b/lib/libvmod_debug/vmod_debug.c @@ -524,7 +524,7 @@ vmod_barrier_sync(VRT_CTX, VCL_STRING addr) sz = read(sock, buf, sizeof buf); i = errno; - AZ(close(sock)); + closefd(&sock); if (sz == 0) return (1); if (sz < 0) From dridi.boukelmoune at gmail.com Tue Feb 21 13:15:06 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 21 Feb 2017 14:15:06 +0100 Subject: [master] 97c1722 Restore regression test for #2184 Message-ID: commit 97c1722e7f73d98a106d5e5a442723e4405f04ad Author: Dridi Boukelmoune Date: Tue Feb 21 14:09:26 2017 +0100 Restore regression test for #2184 Introduced in 7c9916a, its precise syntax got lost in polishing. diff --git a/bin/varnishtest/tests/v00020.vtc b/bin/varnishtest/tests/v00020.vtc index 5f734fc..faf25f0 100644 --- a/bin/varnishtest/tests/v00020.vtc +++ b/bin/varnishtest/tests/v00020.vtc @@ -83,6 +83,7 @@ varnish v1 -vcl { set req.http.foo = 1 - 1; set req.http.foo = 1 + -1; set req.http.foo = 1 - -1; + set req.http.foo = 1- -1; # regression test for #2184 set req.http.foo = 3 * 2; set req.http.foo = 3 / 2; set req.http.foo = 3 * -2; From dridi.boukelmoune at gmail.com Tue Feb 21 13:20:06 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 21 Feb 2017 14:20:06 +0100 Subject: [master] 62219a5 Restore missing newline (follow up to 497b076) Message-ID: commit 62219a516de3ca7366566cc53e2369c56070b29a Author: Dridi Boukelmoune Date: Tue Feb 21 14:18:03 2017 +0100 Restore missing newline (follow up to 497b076) diff --git a/bin/varnishd/mgt/mgt_vcc.c b/bin/varnishd/mgt/mgt_vcc.c index fbb5027..087078a 100644 --- a/bin/varnishd/mgt/mgt_vcc.c +++ b/bin/varnishd/mgt/mgt_vcc.c @@ -79,7 +79,7 @@ static const char * const builtin_vcl = void mgt_DumpBuiltin(void) { - printf("%s", builtin_vcl); + printf("%s\n", builtin_vcl); } /*-------------------------------------------------------------------- From dridi.boukelmoune at gmail.com Tue Feb 21 13:29:05 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 21 Feb 2017 14:29:05 +0100 Subject: [master] bad5e55 Attempt a succinct explanation of test gunzip Message-ID: commit bad5e55939e0369039da4e75e80ab7d081b554ba Author: Dridi Boukelmoune Date: Tue Feb 21 14:26:27 2017 +0100 Attempt a succinct explanation of test gunzip diff --git a/include/tbl/vsc_f_main.h b/include/tbl/vsc_f_main.h index c81d858..2651435 100644 --- a/include/tbl/vsc_f_main.h +++ b/include/tbl/vsc_f_main.h @@ -669,7 +669,9 @@ VSC_FF(n_gunzip, uint64_t, 0, 'c', 'i', info, VSC_FF(n_test_gunzip, uint64_t, 0, 'c', 'i', info, "Test gunzip operations", - "" + "Those operations occur when Varnish receives a compressed" + " object from a backend. They are done to verify the gzip" + " stream while it's inserted in storage." ) /*--------------------------------------------------------------------*/ From phk at phk.freebsd.dk Tue Feb 21 14:37:37 2017 From: phk at phk.freebsd.dk (Poul-Henning Kamp) Date: Tue, 21 Feb 2017 14:37:37 +0000 Subject: [master] 6db7d75 Use closefd() throughout, take 2 In-Reply-To: References: Message-ID: <69100.1487687857@critter.freebsd.dk> -------- In message , Dridi Boukelmoune writes: > This patch was created using Coccinelle and the following steps: > > $ cat >closefd.cocci < @@ > expression fd; > @@ > > - AZ(close(fd)); > + closefd(&fd); > EOF > $ spatch --dir . --in-place --sp-file closefd.cocci So I'm all for tools, but the resulting changes shouls always be stared at manually to catch stuff like this: >@@ -482,12 +482,12 @@ varnish_launch(struct varnish *v) > vtc_fatal(v->vl, "FAIL CLI connection wait failure"); > nfd = accept(v->cli_fd, NULL, NULL); > if (nfd < 0) { >- AZ(close(v->cli_fd)); >+ closefd(&v->cli_fd); > v->cli_fd = -1; > vtc_fatal(v->vl, "FAIL no CLI connection accepted"); > } -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk at FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence. From dridi at varni.sh Tue Feb 21 14:45:22 2017 From: dridi at varni.sh (Dridi Boukelmoune) Date: Tue, 21 Feb 2017 15:45:22 +0100 Subject: [master] 6db7d75 Use closefd() throughout, take 2 In-Reply-To: <69100.1487687857@critter.freebsd.dk> References: <69100.1487687857@critter.freebsd.dk> Message-ID: > So I'm all for tools, but the resulting changes shouls always be > stared at manually to catch stuff like this: This is very embarrassing because I did review them, because I never bulk-add in git and always work incrementally. So I checked them in one at the time and missed it. Allow me to throw more tooling at this and push a fix. Dridi From dridi.boukelmoune at gmail.com Tue Feb 21 14:51:05 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 21 Feb 2017 15:51:05 +0100 Subject: [master] 89a3f0e Use closefd() throughout, take 3 Message-ID: commit 89a3f0ee213772162ce9eabd437c1701c9398c75 Author: Dridi Boukelmoune Date: Tue Feb 21 15:48:09 2017 +0100 Use closefd() throughout, take 3 New semantic patch, follow-up to 6db7d75: @@ expression fd; @@ closefd(&fd); -fd = -1; Spotted by phk. diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c index 54ec8b8..7c5a7a0 100644 --- a/bin/varnishtest/vtc_varnish.c +++ b/bin/varnishtest/vtc_varnish.c @@ -483,7 +483,6 @@ varnish_launch(struct varnish *v) nfd = accept(v->cli_fd, NULL, NULL); if (nfd < 0) { closefd(&v->cli_fd); - v->cli_fd = -1; vtc_fatal(v->vl, "FAIL no CLI connection accepted"); } @@ -620,7 +619,6 @@ varnish_cleanup(struct varnish *v) /* Close the CLI connection */ closefd(&v->cli_fd); - v->cli_fd = -1; /* Close the STDIN connection. */ closefd(&v->fds[1]); diff --git a/lib/libvarnishapi/vsm.c b/lib/libvarnishapi/vsm.c index 250bdab..ae0ace8 100644 --- a/lib/libvarnishapi/vsm.c +++ b/lib/libvarnishapi/vsm.c @@ -240,7 +240,6 @@ VSM_Open(struct VSM_data *vd) AZ(fstat(vd->vsm_fd, &vd->fstat)); if (!S_ISREG(vd->fstat.st_mode)) { closefd(&vd->vsm_fd); - vd->vsm_fd = -1; return (vsm_diag(vd, "%s is not a regular file", vd->fname)); } @@ -248,20 +247,17 @@ VSM_Open(struct VSM_data *vd) i = read(vd->vsm_fd, &slh, sizeof slh); if (i != sizeof slh) { closefd(&vd->vsm_fd); - vd->vsm_fd = -1; return (vsm_diag(vd, "Cannot read %s: %s", vd->fname, strerror(errno))); } if (memcmp(slh.marker, VSM_HEAD_MARKER, sizeof slh.marker)) { closefd(&vd->vsm_fd); - vd->vsm_fd = -1; return (vsm_diag(vd, "Not a VSM file %s", vd->fname)); } if (!vd->N_opt && slh.alloc_seq == 0) { closefd(&vd->vsm_fd); - vd->vsm_fd = -1; return (vsm_diag(vd, "Abandoned VSM file (Varnish not running?) %s", vd->fname)); @@ -271,7 +267,6 @@ VSM_Open(struct VSM_data *vd) PROT_READ, MAP_SHARED|MAP_HASSEMAPHORE, vd->vsm_fd, 0); if (v == MAP_FAILED) { closefd(&vd->vsm_fd); - vd->vsm_fd = -1; return (vsm_diag(vd, "Cannot mmap %s: %s", vd->fname, strerror(errno))); } @@ -311,7 +306,6 @@ VSM_Close(struct VSM_data *vd) vd->e = NULL; vd->head = NULL; closefd(&vd->vsm_fd); - vd->vsm_fd = -1; } /*--------------------------------------------------------------------*/ From dridi at varni.sh Tue Feb 21 14:51:12 2017 From: dridi at varni.sh (Dridi Boukelmoune) Date: Tue, 21 Feb 2017 15:51:12 +0100 Subject: [master] 6db7d75 Use closefd() throughout, take 2 In-Reply-To: References: <69100.1487687857@critter.freebsd.dk> Message-ID: > Allow me to throw more tooling at this and push a fix. https://github.com/varnishcache/varnish-cache/commit/89a3f0e From dridi.boukelmoune at gmail.com Tue Feb 21 17:06:05 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 21 Feb 2017 18:06:05 +0100 Subject: [master] 983555d Introduce a ZERO_OBJ macro similar to bzero Message-ID: commit 983555d79f8e3372ae4cfa173b4ad3d964994d00 Author: Dridi Boukelmoune Date: Fri Feb 17 18:06:39 2017 +0100 Introduce a ZERO_OBJ macro similar to bzero It uses `explicit_bzero` when available and falls back to `memset` otherwise. diff --git a/configure.ac b/configure.ac index 84afb95..b9463f6 100644 --- a/configure.ac +++ b/configure.ac @@ -194,6 +194,7 @@ AC_CHECK_HEADERS([pthread_np.h], [], [], [#include ]) AC_CHECK_HEADERS([priv.h]) # Checks for library functions. +AC_CHECK_FUNCS([explicit_bzero]) AC_CHECK_FUNCS([nanosleep]) AC_CHECK_FUNCS([setppriv]) AC_CHECK_FUNCS([fallocate]) diff --git a/include/miniobj.h b/include/miniobj.h index 901143f..75093ce 100644 --- a/include/miniobj.h +++ b/include/miniobj.h @@ -5,6 +5,12 @@ * */ +#if HAVE_EXPLICIT_BZERO +# define ZERO_OBJ(to, sz) explicit_bzero(to, sz) +#else +# define ZERO_OBJ(to, sz) (void)memset(to, 0, sz) +#endif + #define INIT_OBJ(to, type_magic) \ do { \ (void)memset(to, 0, sizeof *to); \ @@ -20,7 +26,7 @@ #define FREE_OBJ(to) \ do { \ - (to)->magic = (0); \ + ZERO_OBJ(&(to)->magic, sizeof (to)->magic); \ free(to); \ to = NULL; \ } while (0) From dridi.boukelmoune at gmail.com Tue Feb 21 17:09:05 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 21 Feb 2017 18:09:05 +0100 Subject: [master] 9230b61 Polish Message-ID: commit 9230b6156cd070b4f2fbd9ffe83421130ad15e7a Author: Dridi Boukelmoune Date: Tue Feb 21 18:06:47 2017 +0100 Polish diff --git a/include/miniobj.h b/include/miniobj.h index 75093ce..952a068 100644 --- a/include/miniobj.h +++ b/include/miniobj.h @@ -13,7 +13,7 @@ #define INIT_OBJ(to, type_magic) \ do { \ - (void)memset(to, 0, sizeof *to); \ + (void)memset(to, 0, sizeof *(to)); \ (to)->magic = (type_magic); \ } while (0) From dridi.boukelmoune at gmail.com Tue Feb 21 18:54:05 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 21 Feb 2017 19:54:05 +0100 Subject: [master] 227920a Keep track of WS_Assert_Allocated Message-ID: commit 227920a5a6716716a931c223bf11973a43bd7d12 Author: Dridi Boukelmoune Date: Tue Feb 21 19:51:47 2017 +0100 Keep track of WS_Assert_Allocated diff --git a/include/vrt.h b/include/vrt.h index e4354a2..8d1a0d5 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -45,6 +45,7 @@ * WS_Front added * WS_ReserveLumps added * WS_Inside added + * WS_Assert_Allocated added * 5.0: * Varnish 5.0 release "better safe than sorry" bump * 4.0: From phk at FreeBSD.org Tue Feb 21 21:03:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 21 Feb 2017 22:03:05 +0100 Subject: [master] 5f0bc82 Make this test less sensitive to scheduling order. Message-ID: commit 5f0bc825bcacc64d5e3054b7e0a93cdc0686f59c Author: Poul-Henning Kamp Date: Tue Feb 21 21:01:51 2017 +0000 Make this test less sensitive to scheduling order. diff --git a/bin/varnishtest/tests/r01927.vtc b/bin/varnishtest/tests/r01927.vtc index 9286188..10626cb 100644 --- a/bin/varnishtest/tests/r01927.vtc +++ b/bin/varnishtest/tests/r01927.vtc @@ -57,6 +57,8 @@ client c1 { barrier b1 sync + delay 0.1 + # Get new object, from cache txreq -req "POST" -body "foo" rxresp From phk at FreeBSD.org Wed Feb 22 08:32:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 22 Feb 2017 09:32:05 +0100 Subject: [master] b00cbb2 Allow user defined sub{}'s to return without specifing a handling. Message-ID: commit b00cbb23b67d98bc563f0bad9ea4c10c37bf5bf7 Author: Poul-Henning Kamp Date: Wed Feb 22 08:30:59 2017 +0000 Allow user defined sub{}'s to return without specifing a handling. diff --git a/bin/varnishtest/tests/v00034.vtc b/bin/varnishtest/tests/v00034.vtc index b4d526f..4367444 100644 --- a/bin/varnishtest/tests/v00034.vtc +++ b/bin/varnishtest/tests/v00034.vtc @@ -24,3 +24,26 @@ varnish v1 -errvcl {Probe 'p1' redefined} { probe p1 { } backend s1 { .host = "127.0.0.1"; .probe = p1;} } + +varnish v1 -errvcl {Expected '(' got ';'} { + backend s1 { .host = "127.0.0.1"; } + sub vcl_recv { return; } +} + +varnish v1 -vcl+backend { + + sub foobar { + set resp.http.foo = "foo"; + return; + set resp.http.foo = "bar"; + } + sub vcl_deliver { + call foobar; + } +} + +client c1 { + txreq + rxresp + expect resp.http.foo == "foo" +} -run diff --git a/lib/libvcc/vcc_action.c b/lib/libvcc/vcc_action.c index fb8d97b..39cabe1 100644 --- a/lib/libvcc/vcc_action.c +++ b/lib/libvcc/vcc_action.c @@ -284,6 +284,11 @@ parse_return(struct vcc *tl) const char *h; vcc_NextToken(tl); + if (tl->t->tok == ';' && tl->fb == tl->fc) { + /* fb == fc means we're in a subroutine */ + Fb(tl, 1, "return;\n"); + return; + } ExpectErr(tl, '('); vcc_NextToken(tl); ExpectErr(tl, ID); From phk at FreeBSD.org Wed Feb 22 13:04:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 22 Feb 2017 14:04:05 +0100 Subject: [master] cbe8047 Reintroduce hit-for-pass with new and better syntax: Message-ID: commit cbe804760d78b917fbbb8a1d69b2236a2d98a028 Author: Poul-Henning Kamp Date: Wed Feb 22 10:40:58 2017 +0000 Reintroduce hit-for-pass with new and better syntax: sub vcl_backend_response { return (pass(2s)); } diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 9433bcf..2b89ff4 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -471,6 +471,11 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo) if (bo->do_esi) bo->do_stream = 0; + if (wrk->handling == VCL_RET_PASS) { + bo->fetch_objcore->flags |= OC_F_HFP; + bo->uncacheable = 1; + wrk->handling = VCL_RET_DELIVER; + } if (bo->do_pass || bo->uncacheable) bo->fetch_objcore->flags |= OC_F_PASS; diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index 51423f3..d5eeff7 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -436,7 +436,10 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp, /* If still valid, use it */ assert(oh->refcnt > 1); assert(oc->objhead == oh); - if (oc->flags & OC_F_PASS) { + if (oc->flags & OC_F_HFP) { + wrk->stats->cache_hitpass++; + oc = NULL; + } else if (oc->flags & OC_F_PASS) { wrk->stats->cache_hitpass++; oc = NULL; *bocp = hsh_insert_busyobj(wrk, oh); diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index b2a58a1..0e9b72f 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -427,10 +427,13 @@ cnt_lookup(struct worker *wrk, struct req *req) if (lr == HSH_MISS) { /* Found nothing */ AZ(oc); - AN(busy); - AN(busy->flags & OC_F_BUSY); - req->objcore = busy; - req->req_step = R_STP_MISS; + if (busy != NULL) { + AN(busy->flags & OC_F_BUSY); + req->objcore = busy; + req->req_step = R_STP_MISS; + } else { + req->req_step = R_STP_PASS; + } return (REQ_FSM_MORE); } diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c index d865891..efc877f 100644 --- a/bin/varnishd/cache/cache_vrt.c +++ b/bin/varnishd/cache/cache_vrt.c @@ -85,6 +85,21 @@ VRT_acl_match(VRT_CTX, VCL_ACL acl, VCL_IP ip) return (acl->match(ctx, ip)); } +void +VRT_hit_for_pass(VRT_CTX, VCL_DURATION d) +{ + struct objcore *oc; + + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC); + oc = ctx->bo->fetch_objcore; + oc->ttl = d; + oc->grace = 0.0; + oc->keep = 0.0; + VSLb(ctx->vsl, SLT_TTL, "HFP %.0f %.0f %.0f %.0f", + oc->ttl, oc->grace, oc->keep, oc->t_origin); +} + /*--------------------------------------------------------------------*/ struct http * diff --git a/bin/varnishtest/tests/c00081.vtc b/bin/varnishtest/tests/c00081.vtc new file mode 100644 index 0000000..f119570 --- /dev/null +++ b/bin/varnishtest/tests/c00081.vtc @@ -0,0 +1,46 @@ +varnishtest "Hit-for-pass (mk II)" + +server s1 { + rxreq + txresp -hdr "foo: 1" + rxreq + txresp -hdr "foo: 2" + rxreq + txresp -hdr "foo: 3" +} -start + +varnish v1 -vcl+backend { + + sub vcl_miss { + set req.http.miss = "True"; + } + sub vcl_pass { + set req.http.pass = "True"; + } + + sub vcl_backend_response { + return (pass(2s)); + } + + sub vcl_deliver { + set resp.http.miss = req.http.miss; + set resp.http.pass = req.http.pass; + } + +} -start + +client c1 { + txreq + rxresp + expect resp.http.miss == True + + txreq + rxresp + expect resp.http.pass == True + + delay 3 + + txreq + rxresp + expect resp.http.miss == True +} -run diff --git a/include/tbl/oc_flags.h b/include/tbl/oc_flags.h index 2e231c7..78059aa 100644 --- a/include/tbl/oc_flags.h +++ b/include/tbl/oc_flags.h @@ -30,6 +30,7 @@ OC_FLAG(BUSY, busy, (1<<1)) OC_FLAG(PASS, pass, (1<<2)) +OC_FLAG(HFP, hfp, (1<<3)) OC_FLAG(ABANDON, abandon, (1<<4)) OC_FLAG(PRIVATE, private, (1<<5)) OC_FLAG(FAILED, failed, (1<<6)) diff --git a/lib/libvcc/generate.py b/lib/libvcc/generate.py index a9ff86b..604970e 100755 --- a/lib/libvcc/generate.py +++ b/lib/libvcc/generate.py @@ -134,7 +134,7 @@ returns = ( ), ('backend_response', "B", - ('fail', 'deliver', 'retry', 'abandon') + ('fail', 'deliver', 'retry', 'abandon', 'pass') ), ('backend_error', "B", From dridi.boukelmoune at gmail.com Wed Feb 22 13:08:06 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 22 Feb 2017 14:08:06 +0100 Subject: [master] 1e75419 Track VRT_hit_for_pass Message-ID: commit 1e75419225c56215e1ec867bfa2e7cd73dcd56b3 Author: Dridi Boukelmoune Date: Wed Feb 22 14:06:53 2017 +0100 Track VRT_hit_for_pass diff --git a/include/vrt.h b/include/vrt.h index 8d1a0d5..0e86013 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -40,6 +40,7 @@ * * * 6.0 (unreleased): + * VRT_hit_for_pass added * VRT_ipcmp added * WS_Reset and WS_Snapshot signatures changed * WS_Front added From phk at FreeBSD.org Thu Feb 23 08:55:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 23 Feb 2017 09:55:05 +0100 Subject: [master] 09f96b5 Add a couple of (needless) asserts for Coveritys sake. Message-ID: commit 09f96b5e64e80db5aa3d3eef6f37895da065e926 Author: Poul-Henning Kamp Date: Thu Feb 23 08:54:13 2017 +0000 Add a couple of (needless) asserts for Coveritys sake. diff --git a/bin/varnishtest/vtc_http.c b/bin/varnishtest/vtc_http.c index d9a233d..60af496 100644 --- a/bin/varnishtest/vtc_http.c +++ b/bin/varnishtest/vtc_http.c @@ -1414,6 +1414,7 @@ cmd_http_sendhex(CMD_ARGS) AN(av[1]); AZ(av[2]); vsb = vtc_hex_to_bin(hp->vl, av[1]); + assert(VSB_len(vsb) >= 0); vtc_hexdump(hp->vl, 4, "sendhex", VSB_data(vsb), VSB_len(vsb)); j = write(hp->fd, VSB_data(vsb), VSB_len(vsb)); assert(j == VSB_len(vsb)); diff --git a/bin/varnishtest/vtc_http2.c b/bin/varnishtest/vtc_http2.c index ee6f9c3..5f6701c 100644 --- a/bin/varnishtest/vtc_http2.c +++ b/bin/varnishtest/vtc_http2.c @@ -1237,6 +1237,7 @@ cmd_sendhex(CMD_ARGS) AN(av[1]); AZ(av[2]); vsb = vtc_hex_to_bin(hp->vl, av[1]); + assert(VSB_len(vsb) >= 0); vtc_hexdump(hp->vl, 4, "sendhex", VSB_data(vsb), VSB_len(vsb)); AZ(pthread_mutex_lock(&hp->mtx)); http_write(hp, 4, VSB_data(vsb), VSB_len(vsb), "sendhex"); From dridi.boukelmoune at gmail.com Thu Feb 23 13:55:06 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 23 Feb 2017 14:55:06 +0100 Subject: [master] b28c352 Introduce a `vxid` LHS for VSL queries Message-ID: commit b28c35238f3ec65cab0d9c22ef14afe8e6599b57 Author: Dridi Boukelmoune Date: Thu Feb 2 11:04:37 2017 +0100 Introduce a `vxid` LHS for VSL queries It shares a lot of parsing infrastructure with log records, but doesn't support the taglist syntax. Only a verbatim `vxid` token can be used as the LHS, and only integer operators are supported. diff --git a/bin/varnishtest/tests/b00050.vtc b/bin/varnishtest/tests/b00050.vtc new file mode 100644 index 0000000..399df82 --- /dev/null +++ b/bin/varnishtest/tests/b00050.vtc @@ -0,0 +1,61 @@ +varnishtest "VXID log filtering" + +server s1 { + rxreq + txresp +} -start + +varnish v1 -arg "-p thread_pools=1" -vcl+backend { } -start + +logexpect l1 -v v1 -q "vxid == 1001" { + expect 0 1001 Begin "req 1000 rxreq" +} -start + +client c1 { + txreq + rxresp +} -run + +logexpect -wait + +# vxid only supports integer operations + +shell -err -expect "Expected vxid operator got '~'" { + varnishlog -n ${v1_name} -d -q 'vxid ~ 1001' +} + +shell -err -expect "Expected vxid operator got '!~'" { + varnishlog -n ${v1_name} -d -q 'vxid !~ 1001' +} + +shell -err -expect "Expected vxid operator got 'eq'" { + varnishlog -n ${v1_name} -d -q 'vxid eq 1001' +} + +shell -err -expect "Expected vxid operator got 'ne'" { + varnishlog -n ${v1_name} -d -q 'vxid ne 1001' +} + +# vxid only supports integer operands + +shell -err -expect "Expected integer got '1001.5'" { + varnishlog -n ${v1_name} -d -q 'vxid != 1001.5' +} + +# vxid doesn't support taglist selection + +shell -err -expect "Unexpected taglist selection for vxid" { + varnishlog -n ${v1_name} -d -q 'vxid[1] >= 1001' +} + +shell -err -expect "Unexpected taglist selection for vxid" { + varnishlog -n ${v1_name} -d -q '{1}vxid <= 1001' +} + +shell -err -expect "Unexpected taglist selection for vxid" { + varnishlog -n ${v1_name} -d -q 'vxid,Link > 1001' +} + +shell -err -expect "Unexpected taglist selection for vxid" { + varnishlog -n ${v1_name} -d -q 'vxid,vxid < 1001' +} diff --git a/lib/libvarnishapi/generate.py b/lib/libvarnishapi/generate.py index b796fde..447c60f 100755 --- a/lib/libvarnishapi/generate.py +++ b/lib/libvarnishapi/generate.py @@ -71,6 +71,7 @@ tokens = { # Special "T_TRUE": None, + "VXID": "vxid", } ####################################################################### diff --git a/lib/libvarnishapi/vsl_query.c b/lib/libvarnishapi/vsl_query.c index 48042cb..dd69eec 100644 --- a/lib/libvarnishapi/vsl_query.c +++ b/lib/libvarnishapi/vsl_query.c @@ -74,6 +74,48 @@ struct vslq_query { } static int +vslq_test_vxid(const struct vex *vex, const struct VSL_transaction *trans) +{ + const struct vex_rhs *rhs; + + AN(vex); + AN(trans); + + rhs = vex->rhs; + CHECK_OBJ_NOTNULL(rhs, VEX_RHS_MAGIC); + + /* Prepare */ + switch (vex->tok) { + case T_EQ: /* == */ + case T_NEQ: /* != */ + case '<': + case '>': + case T_LEQ: /* <= */ + case T_GEQ: /* >= */ + if (rhs->type != VEX_INT) + WRONG("Wrong RHS type for vxid"); + /* FALLTHROUGH */ + default: + break; + } + + /* Compare */ + switch (vex->tok) { + #define VXID_TEST_NUMOP(OP) return (trans->vxid OP rhs->val_int); + case T_EQ: VXID_TEST_NUMOP(==); + case T_NEQ: VXID_TEST_NUMOP(!=); + case '<': VXID_TEST_NUMOP(<); + case '>': VXID_TEST_NUMOP(>); + case T_LEQ: VXID_TEST_NUMOP(<=); + case T_GEQ: VXID_TEST_NUMOP(>=); + #undef VXID_TEST_NUMOP + default: WRONG("Bad vxid expression token"); + } + + NEEDLESS(return (0)); +} + +static int vslq_test_rec(const struct vex *vex, const struct VSLC_ptr *rec) { const struct vex_rhs *rhs; @@ -226,6 +268,17 @@ vslq_test(const struct vex *vex, struct VSL_transaction * const ptrans[]) CHECK_OBJ_NOTNULL(vex, VEX_MAGIC); CHECK_OBJ_NOTNULL(vex->lhs, VEX_LHS_MAGIC); AN(vex->lhs->tags); + assert(vex->lhs->vxid <= 1); + + if (vex->lhs->vxid) { + AZ(vex->lhs->taglist); + for (t = ptrans[0]; t != NULL; t = *++ptrans) + if (vslq_test_vxid(vex, t)) + return (1); + return (0); + } + + AN(vex->lhs->taglist); for (t = ptrans[0]; t != NULL; t = *++ptrans) { if (vex->lhs->level >= 0) { diff --git a/lib/libvarnishapi/vxp.h b/lib/libvarnishapi/vxp.h index afed0d0..c7a0981 100644 --- a/lib/libvarnishapi/vxp.h +++ b/lib/libvarnishapi/vxp.h @@ -86,6 +86,8 @@ struct vex_lhs { int field; int level; int level_pm; + unsigned taglist; + unsigned vxid; }; enum vex_rhs_e { diff --git a/lib/libvarnishapi/vxp_parse.c b/lib/libvarnishapi/vxp_parse.c index 7ec0d4f..d39cdd7 100644 --- a/lib/libvarnishapi/vxp_parse.c +++ b/lib/libvarnishapi/vxp_parse.c @@ -112,14 +112,19 @@ vxp_expr_lhs(struct vxp *vxp, struct vex_lhs **plhs) while (1) { /* The tags this expression applies to */ - if (vxp->t->tok != VAL) { + if (vxp->t->tok == VXID) { + (*plhs)->vxid++; + i = 0; + } else if (vxp->t->tok != VAL) { VSB_printf(vxp->sb, "Expected VSL tag name got '%.*s' ", PF(vxp->t)); vxp_ErrWhere(vxp, vxp->t, -1); return; + } else { + (*plhs)->taglist++; + i = VSL_Glob2Tags(vxp->t->dec, -1, vsl_vbm_bitset, + (*plhs)->tags); } - i = VSL_Glob2Tags(vxp->t->dec, -1, vsl_vbm_bitset, - (*plhs)->tags); if (i == -1) { VSB_printf(vxp->sb, "Tag name matches zero tags "); vxp_ErrWhere(vxp, vxp->t, -1); @@ -135,7 +140,7 @@ vxp_expr_lhs(struct vxp *vxp, struct vex_lhs **plhs) vxp_ErrWhere(vxp, vxp->t, -1); return; } - assert(i > 0); + assert(i > 0 || vxp->t->tok == VXID); vxp_NextToken(vxp); if (vxp->t->tok != ',') break; @@ -177,10 +182,20 @@ vxp_expr_lhs(struct vxp *vxp, struct vex_lhs **plhs) ExpectErr(vxp, ']'); vxp_NextToken(vxp); } + + if ((*plhs)->vxid == 0) + return; + + if ((*plhs)->vxid > 1 || (*plhs)->level >= 0 || + (*plhs)->field > 0 || (*plhs)->prefixlen > 0 || + (*plhs)->taglist > 0) { + VSB_printf(vxp->sb, "Unexpected taglist selection for vxid "); + vxp_ErrWhere(vxp, vxp->t, -1); + } } static void -vxp_expr_num(struct vxp *vxp, struct vex_rhs **prhs) +vxp_expr_num(struct vxp *vxp, struct vex_rhs **prhs, int vxid) { char *endptr; @@ -213,6 +228,12 @@ vxp_expr_num(struct vxp *vxp, struct vex_rhs **prhs) return; } } + if (vxid && (*prhs)->type != VEX_INT) { + VSB_printf(vxp->sb, "Expected integer got '%.*s' ", + PF(vxp->t)); + vxp_ErrWhere(vxp, vxp->t, 0); + return; + } vxp_NextToken(vxp); } @@ -269,6 +290,28 @@ vxp_expr_regex(struct vxp *vxp, struct vex_rhs **prhs) vxp_NextToken(vxp); } +static void +vxp_vxid_cmp(struct vxp *vxp) +{ + + switch (vxp->t->tok) { + /* Valid operators */ + case T_EQ: /* == */ + case '<': /* < */ + case '>': /* > */ + case T_GEQ: /* >= */ + case T_LEQ: /* <= */ + case T_NEQ: /* != */ + break; + + /* Error */ + default: + VSB_printf(vxp->sb, "Expected vxid operator got '%.*s' ", + PF(vxp->t)); + vxp_ErrWhere(vxp, vxp->t, -1); + } +} + /* * SYNTAX: * expr_cmp: @@ -287,6 +330,11 @@ vxp_expr_cmp(struct vxp *vxp, struct vex **pvex) vxp_expr_lhs(vxp, &(*pvex)->lhs); ERRCHK(vxp); + if ((*pvex)->lhs->vxid) { + vxp_vxid_cmp(vxp); + ERRCHK(vxp); + } + /* Test operator */ switch (vxp->t->tok) { @@ -333,7 +381,7 @@ vxp_expr_cmp(struct vxp *vxp, struct vex **pvex) case T_GEQ: /* >= */ case T_LEQ: /* <= */ case T_NEQ: /* != */ - vxp_expr_num(vxp, &(*pvex)->rhs); + vxp_expr_num(vxp, &(*pvex)->rhs, (*pvex)->lhs->vxid); break; case T_SEQ: /* eq */ case T_SNEQ: /* ne */ From dridi.boukelmoune at gmail.com Thu Feb 23 13:55:06 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 23 Feb 2017 14:55:06 +0100 Subject: [master] 0930c1e s/VXID/vxid/ Message-ID: commit 0930c1e6d05f3085c23a8224a230c18cf5de59ef Author: Dridi Boukelmoune Date: Thu Feb 23 14:06:41 2017 +0100 s/VXID/vxid/ diff --git a/doc/sphinx/reference/vsl-query.rst b/doc/sphinx/reference/vsl-query.rst index e757285..8f72a07 100644 --- a/doc/sphinx/reference/vsl-query.rst +++ b/doc/sphinx/reference/vsl-query.rst @@ -52,22 +52,22 @@ The grouping modes are: together. Client connections are open ended when using HTTP keep-alives, so it is undefined when the session will be reported. If the transaction timeout period is exceeded an - incomplete session will be reported. Non-transactional data (VXID + incomplete session will be reported. Non-transactional data (vxid == 0) is not reported. * Request Transactions are grouped by request, where the set will include the request itself as well as any backend requests or ESI-subrequests. - Session data and non-transactional data (VXID == 0) is not + Session data and non-transactional data (vxid == 0) is not reported. * VXID - Transactions are not grouped, so each VXID is reported in it's + Transactions are not grouped, so each vxid is reported in it's entirety. Sessions, requests, ESI-requests and backend requests are all reported individually. Non-transactional data is not reported - (VXID == 0). This is the default. + (vxid == 0). This is the default. * Raw From dridi.boukelmoune at gmail.com Thu Feb 23 13:55:06 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 23 Feb 2017 14:55:06 +0100 Subject: [master] 936c339 Use code litterals for the grouping modes Message-ID: commit 936c3393e460466e4d0fe36ecc73afd0868a74d8 Author: Dridi Boukelmoune Date: Thu Feb 23 14:08:49 2017 +0100 Use code litterals for the grouping modes diff --git a/doc/sphinx/reference/vsl-query.rst b/doc/sphinx/reference/vsl-query.rst index 8f72a07..8f47156 100644 --- a/doc/sphinx/reference/vsl-query.rst +++ b/doc/sphinx/reference/vsl-query.rst @@ -46,7 +46,7 @@ be 0. The grouping modes are: -* Session +* ``session`` All transactions initiated by a client connection are reported together. Client connections are open ended when using HTTP @@ -55,21 +55,21 @@ The grouping modes are: incomplete session will be reported. Non-transactional data (vxid == 0) is not reported. -* Request +* ``request`` Transactions are grouped by request, where the set will include the request itself as well as any backend requests or ESI-subrequests. Session data and non-transactional data (vxid == 0) is not reported. -* VXID +* ``vxid`` Transactions are not grouped, so each vxid is reported in it's entirety. Sessions, requests, ESI-requests and backend requests are all reported individually. Non-transactional data is not reported (vxid == 0). This is the default. -* Raw +* ``raw`` Every log record will make up a transaction of it's own. All data, including non-transactional data will be reported. From dridi.boukelmoune at gmail.com Thu Feb 23 13:55:06 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 23 Feb 2017 14:55:06 +0100 Subject: [master] 83cbb7f Document vxid VSL queries Message-ID: commit 83cbb7f8c9e68e9fca97d4af7c39fc2a2ceb9db9 Author: Dridi Boukelmoune Date: Thu Feb 23 14:45:18 2017 +0100 Document vxid VSL queries diff --git a/doc/sphinx/reference/vsl-query.rst b/doc/sphinx/reference/vsl-query.rst index 8f47156..a91d404 100644 --- a/doc/sphinx/reference/vsl-query.rst +++ b/doc/sphinx/reference/vsl-query.rst @@ -30,6 +30,8 @@ A query is run on a group of transactions. A query expression is true if there is a log record within the group that satisfies the condition. It is false only if none of the log records satisfies the condition. Query expressions can be combined using boolean functions. +In addition to log records, it is possible to query transaction ids +(vxid) in query. GROUPING ======== @@ -119,6 +121,16 @@ records. :: +Additionally, a query expression can occur on the transaction +itself rather than log records belonging to the transaction. :: + + vxid + +A ``vxid`` query allows you to directly target a specific transacion, +whose id can be obtained from an ``X-Varnish`` HTTP header, the +default "guru meditation" error page, or ``Begin`` and ``Link`` log +records. + Record selection criteria ------------------------- @@ -273,6 +285,10 @@ QUERY EXPRESSION EXAMPLES BerespStatus >= 500 or {2+}Timestamp:Process[2] > 1. +* Log non-transactional errors. (Assumes raw grouping mode). :: + + vxid == 0 and Error + HISTORY ======= From phk at FreeBSD.org Thu Feb 23 15:54:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 23 Feb 2017 16:54:05 +0100 Subject: [master] d8cadd6 Ignore HUB and PIPE signals before starting child Message-ID: commit d8cadd69dffe0df77e48b1edb9fc707cecdbeea2 Author: Poul-Henning Kamp Date: Thu Feb 23 15:53:18 2017 +0000 Ignore HUB and PIPE signals before starting child Fixes #2203 diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index 286c025..7932b24 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -807,6 +807,13 @@ main(int argc, char * const *argv) if (!d_flag && !mgt_has_vcl() && !novcl) MGT_Complain(C_ERR, "No VCL loaded yet"); + memset(&sac, 0, sizeof sac); + sac.sa_handler = SIG_IGN; + sac.sa_flags = SA_RESTART; + + AZ(sigaction(SIGPIPE, &sac, NULL)); + AZ(sigaction(SIGHUP, &sac, NULL)); + u = MCH_Init(d_flag || novcl ? 0 : 1); if (eric_fd >= 0) @@ -841,12 +848,6 @@ main(int argc, char * const *argv) e->name = "mgt_sigint"; AZ(vev_add(mgt_evb, e)); - memset(&sac, 0, sizeof sac); - sac.sa_handler = SIG_IGN; - sac.sa_flags = SA_RESTART; - - AZ(sigaction(SIGPIPE, &sac, NULL)); - AZ(sigaction(SIGHUP, &sac, NULL)); o = vev_schedule(mgt_evb); if (o != 0) From dridi.boukelmoune at gmail.com Thu Feb 23 16:13:05 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 23 Feb 2017 17:13:05 +0100 Subject: [master] 4522084 Typo Message-ID: commit 45220845497091e42386cf676176a86d9f3d9b2b Author: Dridi Boukelmoune Date: Thu Feb 23 16:53:32 2017 +0100 Typo It begs a question: why didn't it fail? diff --git a/bin/varnishtest/tests/a00009.vtc b/bin/varnishtest/tests/a00009.vtc index 12cb05c..fff39dc 100644 --- a/bin/varnishtest/tests/a00009.vtc +++ b/bin/varnishtest/tests/a00009.vtc @@ -57,7 +57,7 @@ shell -expect {active auto/warm - vcl1} { varnishadm -n ${tmpdir}/v0 vcl.list } -shell {varnishadm -n ${tmpdir}/v0 start}} +shell {varnishadm -n ${tmpdir}/v0 start} shell {varnishadm -n ${tmpdir}/v0 debug.listen_address} From dridi.boukelmoune at gmail.com Thu Feb 23 16:13:05 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 23 Feb 2017 17:13:05 +0100 Subject: [master] 7d4b4b0 Rename t.vcl to bad.vcl Message-ID: commit 7d4b4b064c88fd43b147d1f19654c6fa48bb120e Author: Dridi Boukelmoune Date: Thu Feb 23 16:57:02 2017 +0100 Rename t.vcl to bad.vcl diff --git a/bin/varnishtest/tests/a00009.vtc b/bin/varnishtest/tests/a00009.vtc index fff39dc..db41d5a 100644 --- a/bin/varnishtest/tests/a00009.vtc +++ b/bin/varnishtest/tests/a00009.vtc @@ -6,12 +6,12 @@ shell "varnishd -x dumprstvsl > ${tmpdir}/_.vsl" shell "varnishd -x dumprstcli > ${tmpdir}/_.cli" shell "varnishd -x dumpbuiltin > ${tmpdir}/_.builtin" shell -err -expect {VCL version declaration missing} { - echo 'bad vcl' > ${tmpdir}/t.vcl - varnishd -f ${tmpdir}/t.vcl -n ${tmpdir} + echo 'bad vcl' > ${tmpdir}/bad.vcl + varnishd -f ${tmpdir}/bad.vcl -n ${tmpdir} } shell -err -expect {VCL version declaration missing} { - echo 'bad vcl' > ${tmpdir}/t.vcl - varnishd -C -f ${tmpdir}/t.vcl -n ${tmpdir} + echo 'bad vcl' > ${tmpdir}/bad.vcl + varnishd -C -f ${tmpdir}/bad.vcl -n ${tmpdir} } shell -err -expect {-spersistent has been deprecated} "varnishd -spersistent -f '' " shell -err -expect {Unknown jail method "xyz"} "varnishd -jxyz -f '' " From dridi.boukelmoune at gmail.com Thu Feb 23 16:13:05 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 23 Feb 2017 17:13:05 +0100 Subject: [master] 4a98171 Test multiple -f options for varnishd Message-ID: commit 4a98171a5d72af99dda7cecb258868131392e22f Author: Dridi Boukelmoune Date: Thu Feb 23 16:59:49 2017 +0100 Test multiple -f options for varnishd diff --git a/bin/varnishtest/tests/a00009.vtc b/bin/varnishtest/tests/a00009.vtc index db41d5a..ce0b210 100644 --- a/bin/varnishtest/tests/a00009.vtc +++ b/bin/varnishtest/tests/a00009.vtc @@ -62,3 +62,32 @@ shell {varnishadm -n ${tmpdir}/v0 start} shell {varnishadm -n ${tmpdir}/v0 debug.listen_address} process p1 -stop -wait + +# Test multiple -f options + +shell { + cat >${tmpdir}/ok1 <<-EOF + vcl 4.0; + backend ok1 { + .host="${bad_backend}"; + } + EOF + + cat >${tmpdir}/ok2 <<-EOF + vcl 4.0; + backend ok2 { + .host="${bad_backend}"; + } + EOF +} + +process p2 { + exec varnishd -n ${tmpdir}/v0 -F -a :0 -l2m,3m -f ${tmpdir}/ok1 \ + -f ${tmpdir}/ok2 +} -log -start + +delay 1 +shell -match "available.*boot0" {varnishadm -n ${tmpdir}/v0 vcl.list} +shell -match "active.*boot" {varnishadm -n ${tmpdir}/v0 vcl.list} + +process p2 -stop -wait From dridi.boukelmoune at gmail.com Thu Feb 23 16:13:05 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 23 Feb 2017 17:13:05 +0100 Subject: [master] c58b30e Test multiple -f options with a bad VCL Message-ID: commit c58b30efcfa93d30bc3a06815fa434fc994a7b7b Author: Dridi Boukelmoune Date: Thu Feb 23 17:02:41 2017 +0100 Test multiple -f options with a bad VCL diff --git a/bin/varnishtest/tests/a00009.vtc b/bin/varnishtest/tests/a00009.vtc index ce0b210..4aef8e1 100644 --- a/bin/varnishtest/tests/a00009.vtc +++ b/bin/varnishtest/tests/a00009.vtc @@ -91,3 +91,15 @@ shell -match "available.*boot0" {varnishadm -n ${tmpdir}/v0 vcl.list} shell -match "active.*boot" {varnishadm -n ${tmpdir}/v0 vcl.list} process p2 -stop -wait + +# Test multiple -f options with a bad VCL + +shell -err { + exec varnishd -n ${tmpdir}/v0 -F -a :0 -l2m,3m -f ${tmpdir}/ok1 \ + -f ${tmpdir}/ok2 -f ${tmpdir}/bad +} + +shell -err { + exec varnishd -n ${tmpdir}/v0 -F -a :0 -l2m,3m -f ${tmpdir}/ok1 \ + -f ${tmpdir}/bad -f ${tmpdir}/ok2 +} From dridi.boukelmoune at gmail.com Thu Feb 23 16:13:05 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 23 Feb 2017 17:13:05 +0100 Subject: [master] 917773a Test multiple -f options with an empty value Message-ID: commit 917773a3e8d0589cc03c2135edbaf27c0fed167f Author: Dridi Boukelmoune Date: Thu Feb 23 17:06:48 2017 +0100 Test multiple -f options with an empty value A case probably overlooked in d306f91 and something that needs some pondering. diff --git a/bin/varnishtest/tests/a00009.vtc b/bin/varnishtest/tests/a00009.vtc index 4aef8e1..5016cef 100644 --- a/bin/varnishtest/tests/a00009.vtc +++ b/bin/varnishtest/tests/a00009.vtc @@ -103,3 +103,16 @@ shell -err { exec varnishd -n ${tmpdir}/v0 -F -a :0 -l2m,3m -f ${tmpdir}/ok1 \ -f ${tmpdir}/bad -f ${tmpdir}/ok2 } + +# Test multiple -f options with an empty value +# XXX: two conflicting features, probably not what we want + +process p3 { + exec varnishd -n ${tmpdir}/v0 -F -a :0 -l2m,3m -f ${tmpdir}/ok1 \ + -f '' -f ${tmpdir}/ok2 +} -log -start + +delay 1 +shell -match "stopped" {varnishadm -n ${tmpdir}/v0 status} + +process p3 -stop -wait From nils.goroll at uplex.de Thu Feb 23 16:46:05 2017 From: nils.goroll at uplex.de (Nils Goroll) Date: Thu, 23 Feb 2017 17:46:05 +0100 Subject: [master] 5a0817d Move minimal reponses to the transport level and use them for H1 100/400/417 Message-ID: commit 5a0817d1446c64467745e50fb9d9ab0e791e9bec Author: Nils Goroll Date: Thu Feb 23 17:44:26 2017 +0100 Move minimal reponses to the transport level and use them for H1 100/400/417 Also log such resposenses diff --git a/bin/varnishd/cache/cache_transport.h b/bin/varnishd/cache/cache_transport.h index 2633cfe..447c427 100644 --- a/bin/varnishd/cache/cache_transport.h +++ b/bin/varnishd/cache/cache_transport.h @@ -42,6 +42,7 @@ typedef void vtr_sess_panic_f (struct vsb *, const struct sess *); typedef void vtr_req_panic_f (struct vsb *, const struct req *); typedef void vtr_req_fail_f (struct req *, enum sess_close); typedef void vtr_reembark_f (struct worker *, struct req *); +typedef int vtr_minimal_response_f (struct req *, uint16_t status); struct transport { unsigned magic; @@ -60,6 +61,7 @@ struct transport { vtr_sess_panic_f *sess_panic; vtr_req_panic_f *req_panic; vtr_reembark_f *reembark; + vtr_minimal_response_f *minimal_response; VTAILQ_ENTRY(transport) list; }; diff --git a/bin/varnishd/http1/cache_http1_fsm.c b/bin/varnishd/http1/cache_http1_fsm.c index 06eb34b..1dfe146 100644 --- a/bin/varnishd/http1/cache_http1_fsm.c +++ b/bin/varnishd/http1/cache_http1_fsm.c @@ -202,6 +202,41 @@ http1_reembark(struct worker *wrk, struct req *req) usleep(10000); } +static int __match_proto__(vtr_minimal_response_f) +http1_minimal_response(struct req *req, uint16_t status) +{ + size_t wl, l, spc = 80; + char buf[spc]; + const char *reason; + + assert(status >= 100); + assert(status < 1000); + + reason = http_Status2Reason(status, NULL); + + l = snprintf(buf, spc, + "HTTP/1.1 %03d %s\r\n\r\n", status, reason); + assert (l < spc); + + VSLb(req->vsl, SLT_RespProtocol, "HTTP/1.1"); + VSLb(req->vsl, SLT_RespStatus, "%03d", status); + VSLb(req->vsl, SLT_RespReason, "%s", reason); + + if (status >= 400) + req->err_code = status; + wl = write(req->sp->fd, buf, l); + + if (wl > 0) + req->acct.resp_hdrbytes += wl; + if (wl != l) { + VTCP_Assert(1); + if (! req->doclose) + req->doclose = SC_REM_CLOSE; + return (-1); + } + return (0); +} + struct transport HTTP1_transport = { .name = "HTTP/1", .magic = TRANSPORT_MAGIC, @@ -213,19 +248,25 @@ struct transport HTTP1_transport = { .sess_panic = http1_sess_panic, .req_panic = http1_req_panic, .reembark = http1_reembark, + .minimal_response = http1_minimal_response, }; /*---------------------------------------------------------------------- */ +static inline void +http1_abort(struct req *req, unsigned status) +{ + AN(req->doclose); + assert(status >= 400); + (void) http1_minimal_response(req, status); + return; +} + static int http1_dissect(struct worker *wrk, struct req *req) { - const char *r_100 = "HTTP/1.1 100 Continue\r\n\r\n"; - const char *r_400 = "HTTP/1.1 400 Bad Request\r\n\r\n"; - const char *r_417 = "HTTP/1.1 417 Expectation Failed\r\n\r\n"; const char *p; - ssize_t r; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(req, REQ_MAGIC); @@ -256,10 +297,8 @@ http1_dissect(struct worker *wrk, struct req *req) (int)(req->htc->rxbuf_e - req->htc->rxbuf_b), req->htc->rxbuf_b); wrk->stats->client_req_400++; - r = write(req->sp->fd, r_400, strlen(r_400)); - if (r > 0) - req->acct.resp_hdrbytes += r; req->doclose = SC_RX_JUNK; + http1_abort(req, 400); return (-1); } @@ -284,21 +323,14 @@ http1_dissect(struct worker *wrk, struct req *req) if (http_GetHdr(req->http, H_Expect, &p)) { if (strcasecmp(p, "100-continue")) { - wrk->stats->client_req_417++; - req->err_code = 417; - r = write(req->sp->fd, r_417, strlen(r_417)); - if (r > 0) - req->acct.resp_hdrbytes += r; req->doclose = SC_RX_JUNK; + http1_abort(req, 417); + wrk->stats->client_req_417++; return (-1); } - r = write(req->sp->fd, r_100, strlen(r_100)); - if (r > 0) - req->acct.resp_hdrbytes += r; - if (r != strlen(r_100)) { - req->doclose = SC_REM_CLOSE; + http1_simple_response(req, R_100); + if (req->doclose) return (-1); - } http_Unset(req->http, H_Expect); } @@ -310,9 +342,7 @@ http1_dissect(struct worker *wrk, struct req *req) req->doclose = http_DoConnection(req->http); if (req->doclose == SC_RX_BAD) { - r = write(req->sp->fd, r_400, strlen(r_400)); - if (r > 0) - req->acct.resp_hdrbytes += r; + http1_abort(req, 400); return (-1); } diff --git a/bin/varnishd/http2/cache_http2.h b/bin/varnishd/http2/cache_http2.h index bf9604c..a9a44ef 100644 --- a/bin/varnishd/http2/cache_http2.h +++ b/bin/varnishd/http2/cache_http2.h @@ -125,6 +125,7 @@ vtr_sess_panic_f h2_sess_panic; /* http2/cache_http2_deliver.c */ #ifdef TRANSPORT_MAGIC vtr_deliver_f h2_deliver; +vtr_minimal_response_f h2_minimal_response; #endif /* TRANSPORT_MAGIC */ /* http2/cache_http2_hpack.c */ diff --git a/bin/varnishd/http2/cache_http2_deliver.c b/bin/varnishd/http2/cache_http2_deliver.c index f21631c..a589428 100644 --- a/bin/varnishd/http2/cache_http2_deliver.c +++ b/bin/varnishd/http2/cache_http2_deliver.c @@ -92,6 +92,61 @@ h2_bytes(struct req *req, enum vdp_action act, void **priv, return (0); } +static inline size_t +h2_status(uint8_t *p, uint16_t status) { + size_t l = 1; + + switch (status) { + case 200: *p = 0x80 | 8; break; + case 204: *p = 0x80 | 9; break; + case 206: *p = 0x80 | 10; break; + case 304: *p = 0x80 | 11; break; + case 400: *p = 0x80 | 12; break; + case 404: *p = 0x80 | 13; break; + case 500: *p = 0x80 | 14; break; + default: + *p++ = 0x18; + *p++ = 0x03; + l = 2; + + l += snprintf((char*)p, 4, "%03d", status); + assert(l == 5); + break; + } + + return (l); +} + +int __match_proto__(vtr_minimal_response_f) +h2_minimal_response(struct req *req, uint16_t status) +{ + struct h2_req *r2; + const size_t spc = 6; + size_t l; + uint8_t buf[spc]; + + CHECK_OBJ_NOTNULL(req, REQ_MAGIC); + CAST_OBJ_NOTNULL(r2, req->transport_priv, H2_REQ_MAGIC); + + assert(status >= 100); + assert(status < 1000); + + l = h2_status(buf, status); + assert(l < spc); + + VSLb(req->vsl, SLT_RespProtocol, "HTTP/2.0"); + VSLb(req->vsl, SLT_RespStatus, "%03d", status); + VSLb(req->vsl, SLT_RespReason, "%s", http_Status2Reason(status, NULL)); + + if (status >= 400) + req->err_code = status; + + H2_Send(req->wrk, r2, 1, + H2_FRAME_HEADERS, H2FF_HEADERS_END_HEADERS, + l, buf); + return (0); +} + void __match_proto__(vtr_deliver_f) h2_deliver(struct req *req, struct boc *boc, int sendbody) { @@ -118,22 +173,7 @@ h2_deliver(struct req *req, struct boc *boc, int sendbody) (void)WS_Reserve(req->ws, 0); p = (void*)req->ws->f; - switch (req->resp->status) { - case 200: *p++ = 0x80 | 8; break; - case 204: *p++ = 0x80 | 9; break; - case 206: *p++ = 0x80 | 10; break; - case 304: *p++ = 0x80 | 11; break; - case 400: *p++ = 0x80 | 12; break; - case 404: *p++ = 0x80 | 13; break; - case 500: *p++ = 0x80 | 14; break; - default: - *p++ = 0x18; - *p++ = 0x03; - - assert(snprintf((char*)p, 4, "%03d", req->resp->status) == 3); - p += 3; - break; - } + p += h2_status(p, req->resp->status); hp = req->resp; for (u = HTTP_HDR_FIRST; u < hp->nhd; u++) { diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index 00fda7c..26a0347 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -831,4 +831,5 @@ struct transport H2_transport = { .new_session = h2_new_session, .sess_panic = h2_sess_panic, .deliver = h2_deliver, + .minimal_response = h2_minimal_response, }; diff --git a/include/tbl/http_response.h b/include/tbl/http_response.h index eaa74c4..0e21d00 100644 --- a/include/tbl/http_response.h +++ b/include/tbl/http_response.h @@ -30,6 +30,7 @@ /*lint -save -e525 -e539 */ +HTTP_RESP(100, "Continue") HTTP_RESP(101, "Switching Protocols") HTTP_RESP(200, "OK") HTTP_RESP(201, "Created") From nils.goroll at uplex.de Thu Feb 23 16:46:05 2017 From: nils.goroll at uplex.de (Nils Goroll) Date: Thu, 23 Feb 2017 17:46:05 +0100 Subject: [master] 70ba8e0 Send 100-continue after vcl_recv or when caching the request body Message-ID: commit 70ba8e03d8f2ba9986756abb5cc6fb50857dbea5 Author: Nils Goroll Date: Thu Feb 23 17:44:35 2017 +0100 Send 100-continue after vcl_recv or when caching the request body whichever comes first diff --git a/bin/varnishd/cache/cache_req_body.c b/bin/varnishd/cache/cache_req_body.c index 275260f..2036094 100644 --- a/bin/varnishd/cache/cache_req_body.c +++ b/bin/varnishd/cache/cache_req_body.c @@ -37,6 +37,7 @@ #include "vtim.h" #include "hash/hash_slinger.h" #include "storage/storage.h" +#include "cache_transport.h" /*---------------------------------------------------------------------- * Pull the req.body in via/into a objcore @@ -84,6 +85,10 @@ vrb_pull(struct req *req, ssize_t maxsize, objiterate_f *func, void *priv) AZ(req->req_bodybytes); AN(req->htc); yet = req->htc->content_length; + if (yet != 0 && req->want100cont) { + req->want100cont = 0; + (void) req->transport->minimal_response(req, 100); + } if (yet < 0) yet = 0; do { diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 0e9b72f..821a1e7 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -747,6 +747,12 @@ cnt_recv(struct worker *wrk, struct req *req) VCL_recv_method(req->vcl, wrk, req, NULL, NULL); } + if (req->want100cont) { + req->want100cont = 0; + if (req->transport->minimal_response(req, 100)) + return (-1); + } + /* Attempts to cache req.body may fail */ if (req->req_body_status == REQ_BODY_FAIL) { req->doclose = SC_RX_BODY; diff --git a/bin/varnishd/http1/cache_http1_fsm.c b/bin/varnishd/http1/cache_http1_fsm.c index 1dfe146..faad72e 100644 --- a/bin/varnishd/http1/cache_http1_fsm.c +++ b/bin/varnishd/http1/cache_http1_fsm.c @@ -328,9 +328,7 @@ http1_dissect(struct worker *wrk, struct req *req) wrk->stats->client_req_417++; return (-1); } - http1_simple_response(req, R_100); - if (req->doclose) - return (-1); + req->want100cont = 1; http_Unset(req->http, H_Expect); } diff --git a/include/tbl/req_flags.h b/include/tbl/req_flags.h index f743649..fba8943 100644 --- a/include/tbl/req_flags.h +++ b/include/tbl/req_flags.h @@ -35,6 +35,7 @@ REQ_FLAG(hash_ignore_busy, 1, 1, "") REQ_FLAG(hash_always_miss, 1, 1, "") REQ_FLAG(is_hit, 0, 0, "") REQ_FLAG(waitinglist, 0, 0, "") +REQ_FLAG(want100cont, 0, 0, "") #undef REQ_FLAG /*lint -restore */ From nils.goroll at uplex.de Thu Feb 23 16:46:05 2017 From: nils.goroll at uplex.de (Nils Goroll) Date: Thu, 23 Feb 2017 17:46:05 +0100 Subject: [master] 5af2605 Fix cases when we do not want to send a 100 Continue Message-ID: commit 5af2605607a28f62efbc70203f65cc5fb154fbdc Author: Nils Goroll Date: Thu Feb 23 17:44:39 2017 +0100 Fix cases when we do not want to send a 100 Continue - when we already started reading the body - for HTTP Versions less than 1.1 diff --git a/bin/varnishd/http1/cache_http1_fsm.c b/bin/varnishd/http1/cache_http1_fsm.c index faad72e..b880367 100644 --- a/bin/varnishd/http1/cache_http1_fsm.c +++ b/bin/varnishd/http1/cache_http1_fsm.c @@ -328,7 +328,8 @@ http1_dissect(struct worker *wrk, struct req *req) wrk->stats->client_req_417++; return (-1); } - req->want100cont = 1; + if (req->http->protover >= 11 && req->htc->pipeline_b == NULL) + req->want100cont = 1; http_Unset(req->http, H_Expect); } diff --git a/bin/varnishtest/tests/c00018.vtc b/bin/varnishtest/tests/c00018.vtc index 4351748..d5fc0e6 100644 --- a/bin/varnishtest/tests/c00018.vtc +++ b/bin/varnishtest/tests/c00018.vtc @@ -1,18 +1,27 @@ -varnishtest "Check Expect headers" +varnishtest "Check Expect headers / 100 Continue" server s1 { rxreq txresp + rxreq + txresp } -start varnish v1 -vcl+backend { } -start client c1 { - txreq -url "/" -req POST -hdr "Expect: 100-continue " -body "foo" + txreq -url "/" -req POST -hdr "Expect: 100-continue " \ + -hdr "Content-Length: 20" rxresp expect resp.status == 100 + send "01234567890123456789" + rxresp + expect resp.status == 200 + + txreq -url "/" -req POST -hdr "Expect: 100-continue " -body "foo" rxresp expect resp.status == 200 + txreq -url "/" -req POST -hdr "Expect: 101-continue" -body "foo" rxresp expect resp.status == 417 From nils.goroll at uplex.de Thu Feb 23 16:46:05 2017 From: nils.goroll at uplex.de (Nils Goroll) Date: Thu, 23 Feb 2017 17:46:05 +0100 Subject: [master] 88d1d1d Add std.late_100_continue to postpone sending a 100 Continue response Message-ID: commit 88d1d1dce4426584003c6b690436c96c3c3f28fa Author: Nils Goroll Date: Thu Feb 23 17:44:43 2017 +0100 Add std.late_100_continue to postpone sending a 100 Continue response When postponing, - re-create the Expect header for pipe mode - For synth content, close the connection by default, but allow VCL to veto this behavior Prevent drain-reading the body if the connection is closed anyway Respect Connection: close from vcl_synth diff --git a/bin/varnishd/cache/cache_req_body.c b/bin/varnishd/cache/cache_req_body.c index 2036094..f92dbba 100644 --- a/bin/varnishd/cache/cache_req_body.c +++ b/bin/varnishd/cache/cache_req_body.c @@ -238,6 +238,8 @@ VRB_Ignore(struct req *req) CHECK_OBJ_NOTNULL(req, REQ_MAGIC); + if (req->doclose) + return (0); if (req->req_body_status == REQ_BODY_WITH_LEN || req->req_body_status == REQ_BODY_WITHOUT_LEN) (void)VRB_Iterate(req, httpq_req_body_discard, NULL); diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 821a1e7..459ef6f 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -193,6 +193,15 @@ cnt_synth(struct worker *wrk, struct req *req) http_PrintfHeader(req->resp, "X-Varnish: %u", VXID(req->vsl->wid)); http_PutResponse(h, "HTTP/1.1", req->err_code, req->err_reason); + /* + * For late 100-continue, we suggest to VCL to close the connection to + * neither send a 100-continue nor drain-read the request. But VCL has + * the option to veto by removing Connection: close + */ + if (req->want100cont) { + http_SetHeader(h, "Connection: close"); + } + synth_body = VSB_new_auto(); AN(synth_body); @@ -224,6 +233,9 @@ cnt_synth(struct worker *wrk, struct req *req) http_PrintfHeader(req->resp, "Content-Length: %zd", VSB_len(synth_body)); + if (!req->doclose && http_HdrIs(req->resp, H_Connection, "close")) + req->doclose = SC_RESP_CLOSE; + /* Discard any lingering request body before delivery */ (void)VRB_Ignore(req); @@ -613,6 +625,11 @@ cnt_pipe(struct worker *wrk, struct req *req) http_PrintfHeader(bo->bereq, "X-Varnish: %u", VXID(req->vsl->wid)); http_SetHeader(bo->bereq, "Connection: close"); + if (req->want100cont) { + http_SetHeader(bo->bereq, "Expect: 100-continue"); + req->want100cont = 0; + } + VCL_pipe_method(req->vcl, wrk, req, bo, NULL); switch (wrk->handling) { @@ -747,7 +764,7 @@ cnt_recv(struct worker *wrk, struct req *req) VCL_recv_method(req->vcl, wrk, req, NULL, NULL); } - if (req->want100cont) { + if (req->want100cont && !req->late100cont) { req->want100cont = 0; if (req->transport->minimal_response(req, 100)) return (-1); diff --git a/bin/varnishd/http2/cache_http2_deliver.c b/bin/varnishd/http2/cache_http2_deliver.c index a589428..ef45943 100644 --- a/bin/varnishd/http2/cache_http2_deliver.c +++ b/bin/varnishd/http2/cache_http2_deliver.c @@ -141,6 +141,7 @@ h2_minimal_response(struct req *req, uint16_t status) if (status >= 400) req->err_code = status; + /* XXX return code checking once H2_Send returns anything but 0 */ H2_Send(req->wrk, r2, 1, H2_FRAME_HEADERS, H2FF_HEADERS_END_HEADERS, l, buf); diff --git a/bin/varnishtest/tests/c00018.vtc b/bin/varnishtest/tests/c00018.vtc index d5fc0e6..f61b6c5 100644 --- a/bin/varnishtest/tests/c00018.vtc +++ b/bin/varnishtest/tests/c00018.vtc @@ -5,11 +5,146 @@ server s1 { txresp rxreq txresp + rxreq + txresp + rxreq + txresp + rxreq + txresp +} -start + +varnish v1 -vcl+backend { + import std; + + sub vcl_recv { + if (req.url == "/") { + return (pass); + } + + std.late_100_continue(true); + + if (req.url ~ "^/err") { + return (synth(405)); + } + + if (req.url ~ "^/synthnocl") { + return (synth(200)); + } + + if (req.url == "/latecache") { + std.cache_req_body(1KB); + } + return (pass); + + } + sub vcl_synth { + if (req.url == "/synthnocl") { + unset resp.http.Connection; + } + } + +} -start + +logexpect l1 -v v1 -g raw { + # base case: bad Expect + expect * 1001 RespStatus 417 + + # base case: Immediate 100-continue + expect * 1003 ReqUnset {^Expect: 100-continue$} + expect 0 1003 ReqStart {^.} + expect 0 1003 ReqMethod {^POST$} + expect 0 1003 ReqURL {^/$} + expect 0 1003 ReqProtocol {^HTTP/1.1$} + expect 0 1003 ReqHeader {^Content-Length: 20$} + expect 0 1003 ReqHeader {^X-Forwarded-For:} + expect 0 1003 VCL_call {^RECV$} + expect 0 1003 VCL_return {^pass$} + expect 0 1003 RespProtocol {^HTTP/1.1$} + expect 0 1003 RespStatus {^100$} + expect 0 1003 RespReason {^Continue$} + expect 0 1003 VCL_call {^HASH$} + + # no 100 if client has already sent body (and it fits) + expect * 1005 ReqUnset {^Expect: 100-continue$} + expect 0 1005 ReqStart {^.} + expect 0 1005 ReqMethod {^POST$} + expect 0 1005 ReqURL {^/$} + expect 0 1005 ReqProtocol {^HTTP/1.1$} + expect 0 1005 ReqHeader {^Content-Length: 3$} + expect 0 1005 ReqHeader {^X-Forwarded-For:} + expect 0 1005 VCL_call {^RECV$} + expect 0 1005 VCL_return {^pass$} + expect 0 1005 VCL_call {^HASH$} + + # late no cache + expect * 1007 ReqUnset {^Expect: 100-continue$} + expect 0 1007 ReqStart {^.} + expect 0 1007 ReqMethod {^POST$} + expect 0 1007 ReqURL {^/late$} + expect 0 1007 ReqProtocol {^HTTP/1.1$} + expect 0 1007 ReqHeader {^Content-Length: 20$} + expect 0 1007 ReqHeader {^X-Forwarded-For:} + expect 0 1007 VCL_call {^RECV$} + expect 0 1007 VCL_return {^pass$} + expect 0 1007 VCL_call {^HASH$} + expect 0 1007 VCL_return {^lookup$} + expect 0 1007 VCL_call {^PASS$} + expect 0 1007 VCL_return {^fetch$} + expect 0 1007 Link {^bereq 1008 pass$} + expect 0 1007 Storage {^malloc Transient$} + expect 0 1007 RespProtocol {^HTTP/1.1$} + expect 0 1007 RespStatus {^100$} + expect 0 1007 RespReason {^Continue$} + expect 0 1007 Timestamp {^ReqBody:} + expect 0 1007 Timestamp {^Fetch:} + + # late cache + expect * 1009 ReqUnset {^Expect: 100-continue$} + expect 0 1009 ReqStart {^.} + expect 0 1009 ReqMethod {^POST$} + expect 0 1009 ReqURL {^/latecache$} + expect 0 1009 ReqProtocol {^HTTP/1.1$} + expect 0 1009 ReqHeader {^Content-Length: 20$} + expect 0 1009 ReqHeader {^X-Forwarded-For:} + expect 0 1009 VCL_call {^RECV$} + expect 0 1009 Storage {^malloc Transient$} + expect 0 1009 RespProtocol {^HTTP/1.1$} + expect 0 1009 RespStatus {^100$} + expect 0 1009 RespReason {^Continue$} + expect 0 1009 Timestamp {^ReqBody:} + expect 0 1009 VCL_return {^pass$} + expect 0 1009 VCL_call {^HASH$} + + # err + expect * 1011 ReqUnset {^Expect: 100-continue$} + expect 0 1011 ReqStart {^.} + expect 0 1011 ReqMethod {^POST$} + expect 0 1011 ReqURL {^/err$} + expect 0 1011 ReqProtocol {^HTTP/1.1$} + expect 0 1011 ReqHeader {^Content-Length: 20$} + expect 0 1011 ReqHeader {^X-Forwarded-For:} + expect 0 1011 VCL_call {^RECV$} + expect 0 1011 VCL_return {^synth$} + expect 0 1011 VCL_call {^HASH$} + expect 0 1011 VCL_return {^lookup$} + expect 0 1011 Timestamp {^Process:} + expect 0 1011 RespHeader {^Date:} + expect 0 1011 RespHeader {^Server: Varnish$} + expect 0 1011 RespHeader {^X-Varnish: 1011$} + expect 0 1011 RespProtocol {^HTTP/1.1$} + expect 0 1011 RespStatus {^405$} + } -start -varnish v1 -vcl+backend { } -start +client c1 { + # base case: bad Expect + txreq -url "/" -req POST -hdr "Expect: 101-continue" -body "foo" + rxresp + expect resp.status == 417 +} -run client c1 { + # base case: Immediate 100-continue txreq -url "/" -req POST -hdr "Expect: 100-continue " \ -hdr "Content-Length: 20" rxresp @@ -18,11 +153,67 @@ client c1 { rxresp expect resp.status == 200 + # no 100 if client has already sent body (and it fits) txreq -url "/" -req POST -hdr "Expect: 100-continue " -body "foo" rxresp expect resp.status == 200 - txreq -url "/" -req POST -hdr "Expect: 101-continue" -body "foo" + # late no cache + txreq -url "/late" -req POST -hdr "Expect: 100-continue " \ + -hdr "Content-Length: 20" rxresp - expect resp.status == 417 + expect resp.status == 100 + send "01234567890123456789" + rxresp + expect resp.status == 200 + + # late cache + txreq -url "/latecache" -req POST -hdr "Expect: 100-continue " \ + -hdr "Content-Length: 20" + rxresp + expect resp.status == 100 + send "01234567890123456789" + rxresp + expect resp.status == 200 + + # err + txreq -url "/err" -req POST -hdr "Expect: 100-continue " \ + -hdr "Content-Length: 20" + rxresp + expect resp.status == 405 + expect_close } -run + +client c1 { + # Immediate 100-continue with Client Connection: close + txreq -url "/" -req POST -hdr "Expect: 100-continue " \ + -hdr "Content-Length: 20" \ + -hdr "Connection: close" + rxresp + expect resp.status == 100 + send "01234567890123456789" + rxresp + expect resp.status == 200 + expect_close +} -run + +client c1 { + # vcl vetoing the Connection: close in synth + txreq -url "/synthnocl" -req POST -hdr "Expect: 100-continue " \ + -hdr "Content-Length: 20" + rxresp + expect resp.status == 100 + send "01234567890123456789" + rxresp + expect resp.status == 200 + + # vcl vetoing the Connection: close in synth but client close + txreq -url "/synthnocl" -req POST -hdr "Expect: 100-continue " \ + -hdr "Content-Length: 20" \ + -hdr "Connection: close" + rxresp + expect resp.status == 200 + expect_close +} -run + +logexpect l1 -wait diff --git a/include/tbl/req_flags.h b/include/tbl/req_flags.h index fba8943..e23b9c1 100644 --- a/include/tbl/req_flags.h +++ b/include/tbl/req_flags.h @@ -36,6 +36,7 @@ REQ_FLAG(hash_always_miss, 1, 1, "") REQ_FLAG(is_hit, 0, 0, "") REQ_FLAG(waitinglist, 0, 0, "") REQ_FLAG(want100cont, 0, 0, "") +REQ_FLAG(late100cont, 0, 0, "") #undef REQ_FLAG /*lint -restore */ diff --git a/lib/libvmod_std/vmod.vcc b/lib/libvmod_std/vmod.vcc index 7caa2c0..9917e0f 100644 --- a/lib/libvmod_std/vmod.vcc +++ b/lib/libvmod_std/vmod.vcc @@ -283,6 +283,31 @@ Description Example | set req.http.My-Env = getenv("MY_ENV"); +$Function VOID late_100_continue(BOOL late) + +Description + Controls when varnish reacts to an `Expect: 100-continue` client + request header. + + Varnish always generates a `100 Continue` response if + requested by the by the client trough the `Expect: + 100-continue` header when waiting for request body data. + + But, by default, the `100 Continue` response is already + generated immediately after `vcl_recv` returns to reduce + latencies under the assumption that the request body will be + read eventually. + + Calling `std.late_100_continue(true)` in `vcl_recv` will cause + the `100 Continue` response to only be sent when needed. This + may cause additional latencies for processing request bodies, + but is the correct behavior by strict interpretation of + RFC7231. + + This function has no effect outside `vcl_recv` and after + calling `std.cache_req_body()` or any other function consuming + the request body. + SEE ALSO ======== diff --git a/lib/libvmod_std/vmod_std.c b/lib/libvmod_std/vmod_std.c index 94baed2..81e49f7 100644 --- a/lib/libvmod_std/vmod_std.c +++ b/lib/libvmod_std/vmod_std.c @@ -41,6 +41,7 @@ #include "vtcp.h" #include "vsa.h" #include "vtim.h" +#include "vcl.h" #include "cache/cache_director.h" @@ -255,3 +256,24 @@ vmod_getenv(VRT_CTX, VCL_STRING name) return (NULL); return (getenv(name)); } + +VCL_VOID __match_proto__(td_std_late_100_continue) +vmod_late_100_continue(VRT_CTX, VCL_BOOL late) +{ + struct req *req; + + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + if (ctx->method != VCL_MET_RECV) { + VSLb(ctx->vsl, SLT_VCL_Error, + "std.late_100_continue() only valid in vcl_recv{}"); + return; + } + + req = ctx->req; + CHECK_OBJ_NOTNULL(req, REQ_MAGIC); + + if (! req->want100cont) + return; + + req->late100cont = !!late; +} From dridi.boukelmoune at gmail.com Fri Feb 24 00:35:06 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 24 Feb 2017 01:35:06 +0100 Subject: [master] 296d83b Plug leak Message-ID: commit 296d83b21db5e856d50003943011fd1e1c0c845a Author: Dridi Boukelmoune Date: Fri Feb 24 01:30:26 2017 +0100 Plug leak Not doing anything for the -C case, since even FREE_OBJ was omitted. Do we care since varnishd immediately exits once -C is done? Refs #2232 diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index 7932b24..fc24024 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -765,6 +765,7 @@ main(int argc, char * const *argv) VTAILQ_EMPTY(&f_args) ? "boot" : NULL, fa->farg, 0); cli_check(cli); + free(fa->farg); free(fa->src); FREE_OBJ(fa); } From dridi.boukelmoune at gmail.com Fri Feb 24 10:53:05 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 24 Feb 2017 11:53:05 +0100 Subject: [master] cdb2edf Give more room to slower platforms Message-ID: commit cdb2edf782e3a11c3e36696f8eedde375baee65f Author: Dridi Boukelmoune Date: Fri Feb 24 11:51:58 2017 +0100 Give more room to slower platforms diff --git a/bin/varnishtest/tests/a00009.vtc b/bin/varnishtest/tests/a00009.vtc index 5016cef..9ec53b6 100644 --- a/bin/varnishtest/tests/a00009.vtc +++ b/bin/varnishtest/tests/a00009.vtc @@ -86,7 +86,7 @@ process p2 { -f ${tmpdir}/ok2 } -log -start -delay 1 +delay 2 shell -match "available.*boot0" {varnishadm -n ${tmpdir}/v0 vcl.list} shell -match "active.*boot" {varnishadm -n ${tmpdir}/v0 vcl.list} @@ -112,7 +112,7 @@ process p3 { -f '' -f ${tmpdir}/ok2 } -log -start -delay 1 +delay 2 shell -match "stopped" {varnishadm -n ${tmpdir}/v0 status} process p3 -stop -wait From fgsch at lodoss.net Sat Feb 25 19:29:05 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sat, 25 Feb 2017 20:29:05 +0100 Subject: [master] 6bc3cb8 Uneeded returns are unneeded Message-ID: commit 6bc3cb8735fc4c81d9f9866bfd5ee61d9691be9a Author: Federico G. Schwindt Date: Sat Feb 25 19:27:44 2017 +0000 Uneeded returns are unneeded diff --git a/bin/varnishd/cache/cache_obj.c b/bin/varnishd/cache/cache_obj.c index 344525d..4dcedd5 100644 --- a/bin/varnishd/cache/cache_obj.c +++ b/bin/varnishd/cache/cache_obj.c @@ -340,7 +340,6 @@ ObjTrimStore(struct worker *wrk, struct objcore *oc) if (om->objtrimstore != NULL) om->objtrimstore(wrk, oc); - return; } /*==================================================================== diff --git a/bin/varnishd/http1/cache_http1_fsm.c b/bin/varnishd/http1/cache_http1_fsm.c index b880367..8195094 100644 --- a/bin/varnishd/http1/cache_http1_fsm.c +++ b/bin/varnishd/http1/cache_http1_fsm.c @@ -259,8 +259,7 @@ http1_abort(struct req *req, unsigned status) { AN(req->doclose); assert(status >= 400); - (void) http1_minimal_response(req, status); - return; + (void)http1_minimal_response(req, status); } static int diff --git a/lib/libvmod_directors/shard_cfg.c b/lib/libvmod_directors/shard_cfg.c index 20e9b32..7114cae 100644 --- a/lib/libvmod_directors/shard_cfg.c +++ b/lib/libvmod_directors/shard_cfg.c @@ -411,7 +411,6 @@ shardcfg_backend_add(struct backend_reconfig *re, re->shardd->n_backend++; shardcfg_backend_copyin(&bb[i], b); - return; } static void From phk at FreeBSD.org Sat Feb 25 19:51:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Sat, 25 Feb 2017 20:51:05 +0100 Subject: [master] 436426e Also add more delay for the first varnishd Message-ID: commit 436426e0ccf815ea1362c33da67c42d291b7090a Author: Poul-Henning Kamp Date: Sat Feb 25 19:49:57 2017 +0000 Also add more delay for the first varnishd diff --git a/bin/varnishtest/tests/a00009.vtc b/bin/varnishtest/tests/a00009.vtc index 9ec53b6..28ad895 100644 --- a/bin/varnishtest/tests/a00009.vtc +++ b/bin/varnishtest/tests/a00009.vtc @@ -38,7 +38,7 @@ shell -err -expect {Neither -b nor -f given} { varnishd -n ${tmpdir}/v0 } process p1 "exec varnishd -n ${tmpdir}/v0 -F -f '' -a :0 -l2m,3m" -log -start -delay 1 +delay 2 shell { ( From phk at FreeBSD.org Sat Feb 25 21:57:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Sat, 25 Feb 2017 22:57:05 +0100 Subject: [master] 9577a7a Add missing newline, move thread/errno info after backtrace. Message-ID: commit 9577a7a63c153c303c590153372eba42d8829708 Author: Poul-Henning Kamp Date: Sat Feb 25 20:30:18 2017 +0000 Add missing newline, move thread/errno info after backtrace. diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index bc21304..f6446af 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -605,7 +605,7 @@ pan_ic(const char *func, const char *file, int line, const char *cond, case VAS_MISSING: VSB_printf(pan_vsb, "Missing errorhandling code in %s(), %s line %d:\n" - " Condition(%s) not true.", + " Condition(%s) not true.\n", func, file, line, cond); break; case VAS_INCOMPLETE: @@ -621,13 +621,6 @@ pan_ic(const char *func, const char *file, int line, const char *cond, func, file, line, cond); break; } - if (err) - VSB_printf(pan_vsb, "errno = %d (%s)\n", err, strerror(err)); - - q = THR_GetName(); - if (q != NULL) - VSB_printf(pan_vsb, "thread = (%s)\n", q); - VSB_printf(pan_vsb, "version = %s, vrt api = %u.%u\n", VCS_version, VRT_MAJOR_VERSION, VRT_MINOR_VERSION); VSB_printf(pan_vsb, "ident = %s,%s\n", @@ -637,6 +630,13 @@ pan_ic(const char *func, const char *file, int line, const char *cond, pan_backtrace(pan_vsb); + if (err) + VSB_printf(pan_vsb, "errno = %d (%s)\n", err, strerror(err)); + + q = THR_GetName(); + if (q != NULL) + VSB_printf(pan_vsb, "thread = (%s)\n", q); + if (!FEATURE(FEATURE_SHORT_PANIC)) { req = THR_GetRequest(); VSB_cat(pan_vsb, "thr."); From phk at FreeBSD.org Sat Feb 25 21:57:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Sat, 25 Feb 2017 22:57:05 +0100 Subject: [master] 7388e70 Point out upper-case characters, I'm sure this will be a common mistake. Message-ID: commit 7388e7053bbd6b3cad59c5748cd33b3472795ef0 Author: Poul-Henning Kamp Date: Sat Feb 25 20:47:49 2017 +0000 Point out upper-case characters, I'm sure this will be a common mistake. diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index 26a0347..f3e1893 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -414,6 +414,7 @@ h2_rx_headers(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) { struct req *req; struct h2h_decode d[1]; + h2_error h2e; const uint8_t *p; size_t l; @@ -457,8 +458,16 @@ h2_rx_headers(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) p += 5; l -= 5; } - XXXAZ(h2h_decode_bytes(h2, d, p, l)); - XXXAZ(h2h_decode_fini(h2, d)); + h2e = h2h_decode_bytes(h2, d, p, l); + if (h2e != NULL) { + VSL(SLT_Debug, 0, "H2H_DECODE_BYTES %s", h2e->name); + return (h2e); + } + h2e = h2h_decode_fini(h2, d); + if (h2e != NULL) { + VSL(SLT_Debug, 0, "H2H_DECODE_FINI %s", h2e->name); + return (h2e); + } VSLb_ts_req(req, "Req", req->t_req); http_SetH(req->http, HTTP_HDR_PROTO, "HTTP/2.0"); From phk at FreeBSD.org Sat Feb 25 21:57:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Sat, 25 Feb 2017 22:57:05 +0100 Subject: [master] 1b7e1d6 Forgot this part of last commit. Message-ID: commit 1b7e1d64ddd128c4e3dbb4a185a4a057653adbfc Author: Poul-Henning Kamp Date: Sat Feb 25 20:48:22 2017 +0000 Forgot this part of last commit. diff --git a/bin/varnishd/http2/cache_http2_hpack.c b/bin/varnishd/http2/cache_http2_hpack.c index ea9a2b5..ef3496b 100644 --- a/bin/varnishd/http2/cache_http2_hpack.c +++ b/bin/varnishd/http2/cache_http2_hpack.c @@ -57,10 +57,17 @@ h2h_checkhdr(const struct http *hp, const char *b, size_t namelen, size_t len) /* Check valid name characters */ if (p == b && *p == ':') continue; /* pseudo-header */ - if (vct_istchar(*p) && (!isupper(*p))) + if (isupper(*p)) { + VSLb(hp->vsl, SLT_BogoHeader, + "Illegal header name (upper-case): %.*s", + (int)(len > 20 ? 20 : len), b); + return (H2CE_PROTOCOL_ERROR); + } + if (vct_istchar(*p)) { /* XXX: vct should have a proper class for this avoiding two checks */ continue; + } VSLb(hp->vsl, SLT_BogoHeader, "Illegal header name: %.*s", (int)(len > 20 ? 20 : len), b); From phk at FreeBSD.org Sat Feb 25 21:57:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Sat, 25 Feb 2017 22:57:05 +0100 Subject: [master] 0690efa Remove duplicated asserts Message-ID: commit 0690efa6b39ec1eb2e3660d273c9f5fa1701b419 Author: Poul-Henning Kamp Date: Sat Feb 25 21:52:04 2017 +0000 Remove duplicated asserts diff --git a/bin/varnishd/http1/cache_http1_vfp.c b/bin/varnishd/http1/cache_http1_vfp.c index d287fa5..f1d85a8 100644 --- a/bin/varnishd/http1/cache_http1_vfp.c +++ b/bin/varnishd/http1/cache_http1_vfp.c @@ -109,8 +109,6 @@ v1f_pull_chunked(struct vfp_ctx *vc, struct vfp_entry *vfe, void *ptr, AN(ptr); AN(lp); - AN(ptr); - AN(lp); l = *lp; *lp = 0; if (vfe->priv2 == -1) { From phk at FreeBSD.org Sat Feb 25 21:57:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Sat, 25 Feb 2017 22:57:05 +0100 Subject: [master] 987d090 Ignore upper/lower case when comparing header names Message-ID: commit 987d090a2bcd9961f8085baeae2416c1d8c71e34 Author: Poul-Henning Kamp Date: Sat Feb 25 21:55:36 2017 +0000 Ignore upper/lower case when comparing header names diff --git a/bin/varnishtest/vtc_http2.c b/bin/varnishtest/vtc_http2.c index 5f6701c..745490c 100644 --- a/bin/varnishtest/vtc_http2.c +++ b/bin/varnishtest/vtc_http2.c @@ -884,7 +884,7 @@ find_header(const struct hpk_hdr *h, const char *k) int kl = strlen(k); while (h->t) { - if (kl == h->key.len && !memcmp(h->key.ptr, k, kl)) + if (kl == h->key.len && !strncasecmp(h->key.ptr, k, kl)) return h->value.ptr; h++; } From phk at FreeBSD.org Sat Feb 25 21:57:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Sat, 25 Feb 2017 22:57:05 +0100 Subject: [master] b4a959a Make a hole through H2 POST. Message-ID: commit b4a959acdedf7346a67be5ff9cd2cca3ea2c891d Author: Poul-Henning Kamp Date: Sat Feb 25 21:56:06 2017 +0000 Make a hole through H2 POST. diff --git a/bin/varnishd/http2/cache_http2.h b/bin/varnishd/http2/cache_http2.h index a9a44ef..f832e80 100644 --- a/bin/varnishd/http2/cache_http2.h +++ b/bin/varnishd/http2/cache_http2.h @@ -91,6 +91,9 @@ struct h2_sess { unsigned magic; #define H2_SESS_MAGIC 0xa16f7e4b + struct h2_req *mailcall; + pthread_cond_t *cond; + struct sess *sess; int refcnt; uint32_t highest_stream; diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index f3e1893..abca18d 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -34,6 +34,7 @@ #include #include "cache/cache_transport.h" +#include "cache/cache_filter.h" #include "http2/cache_http2.h" #include "vend.h" @@ -109,7 +110,6 @@ static const uint8_t H2_settings[] = { __match_proto__(h2_frame_f) \ { (void)wrk; (void)r2; VSLb(h2->vsl, SLT_Debug, "XXX implement " #l); INCOMPL(); } -DUMMY_FRAME(data) DUMMY_FRAME(rst_stream) DUMMY_FRAME(push_promise) DUMMY_FRAME(continuation) @@ -471,7 +471,10 @@ h2_rx_headers(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) VSLb_ts_req(req, "Req", req->t_req); http_SetH(req->http, HTTP_HDR_PROTO, "HTTP/2.0"); - req->req_body_status = REQ_BODY_NONE; + if (h2->rxf_flags & H2FF_HEADERS_END_STREAM) + req->req_body_status = REQ_BODY_NONE; + else + req->req_body_status = REQ_BODY_WITHOUT_LEN; wrk->stats->client_req++; wrk->stats->s_req++; req->ws_req = WS_Snapshot(req->ws); @@ -485,6 +488,78 @@ h2_rx_headers(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) /**********************************************************************/ +h2_error __match_proto__(h2_frame_f) +h2_rx_data(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) +{ + (void)wrk; + Lck_AssertHeld(&h2->sess->mtx); + AZ(h2->mailcall); + h2->mailcall = r2; + AZ(pthread_cond_broadcast(h2->cond)); + while (h2->mailcall != NULL) + AZ(Lck_CondWait(h2->cond, &h2->sess->mtx, 0)); + return (0); +} + +static enum vfp_status __match_proto__(vfp_pull_f) +h2_vfp_body(struct vfp_ctx *vc, struct vfp_entry *vfe, void *ptr, ssize_t *lp) +{ + struct h2_req *r2; + struct h2_sess *h2; + unsigned l; + enum vfp_status retval = VFP_OK; + + CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC); + CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC); + CAST_OBJ_NOTNULL(r2, vfe->priv1, H2_REQ_MAGIC); + h2 = r2->h2sess; + + AN(ptr); + AN(lp); + l = *lp; + *lp = 0; + + Lck_Lock(&h2->sess->mtx); + while (h2->mailcall != r2) + AZ(Lck_CondWait(h2->cond, &h2->sess->mtx, 0)); + if (l > h2->rxf_len) + l = h2->rxf_len; + if (l > 0) { + memcpy(ptr, h2->rxf_data, l); + h2->rxf_data += l; + h2->rxf_len -= l; + } + *lp = l; + if (h2->rxf_len == 0) { + if (h2->rxf_flags & H2FF_DATA_END_STREAM) + retval = VFP_END; + h2->mailcall = NULL; + AZ(pthread_cond_broadcast(h2->cond)); + } + Lck_Unlock(&h2->sess->mtx); + return (retval); +} + +static const struct vfp h2_body = { + .name = "H2_BODY", + .pull = h2_vfp_body, +}; + +static void __match_proto__(vtr_req_body_t) +h2_req_body(struct req *req) +{ + struct h2_req *r2; + struct vfp_entry *vfe; + + CHECK_OBJ(req, REQ_MAGIC); + CAST_OBJ_NOTNULL(r2, req->transport_priv, H2_REQ_MAGIC); + vfe = VFP_Push(req->vfc, &h2_body, 0); + AN(vfe); + vfe->priv1 = r2; +} + +/**********************************************************************/ + enum htc_status_e __match_proto__(htc_complete_f) H2_prism_complete(struct http_conn *htc) { @@ -820,6 +895,7 @@ h2_new_session(struct worker *wrk, void *arg) H2_FRAME_SETTINGS, H2FF_NONE, sizeof H2_settings, 0, H2_settings); /* and off we go... */ + h2->cond = &wrk->cond; Lck_Unlock(&h2->sess->mtx); while (h2_rxframe(wrk, h2)) { @@ -832,6 +908,7 @@ h2_new_session(struct worker *wrk, void *arg) if (r2->state == H2_S_IDLE) h2_del_req(wrk, r2); } + h2->cond = NULL; } struct transport H2_transport = { @@ -840,5 +917,6 @@ struct transport H2_transport = { .new_session = h2_new_session, .sess_panic = h2_sess_panic, .deliver = h2_deliver, + .req_body = h2_req_body, .minimal_response = h2_minimal_response, }; diff --git a/bin/varnishtest/tests/t02005.vtc b/bin/varnishtest/tests/t02005.vtc new file mode 100644 index 0000000..e13c0e7 --- /dev/null +++ b/bin/varnishtest/tests/t02005.vtc @@ -0,0 +1,24 @@ +varnishtest "H2 POST" + +server s1 { + rxreq + txresp -hdr "Content-Type: text/plain" -body response +} -start + +varnish v1 -vcl+backend {} -cliok "param.set feature +http2" -start +varnish v1 -cliok "param.set debug +syncvsl" + +client c1 { + stream 1 { + txreq -req POST -hdr content-type text/plain -hdr content-length 7 -body request + + # First, HTTP checks + rxresp + expect resp.http.content-Type == "text/plain" + + # Then, payload checks + write_body resp.txt + shell {grep -q response resp.txt} + } -run +} -run + From phk at FreeBSD.org Sat Feb 25 22:16:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Sat, 25 Feb 2017 23:16:05 +0100 Subject: [master] a8b56df Add a debug option to slow down acceptor threads so that we can stabilize test c00080. Message-ID: commit a8b56df31e7f4b5a711e08603fa6f0f577e3ca57 Author: Poul-Henning Kamp Date: Sat Feb 25 22:15:24 2017 +0000 Add a debug option to slow down acceptor threads so that we can stabilize test c00080. diff --git a/bin/varnishd/cache/cache_acceptor.c b/bin/varnishd/cache/cache_acceptor.c index b570db2..2f28418 100644 --- a/bin/varnishd/cache/cache_acceptor.c +++ b/bin/varnishd/cache/cache_acceptor.c @@ -466,6 +466,8 @@ vca_accept_task(struct worker *wrk, void *arg) TASK_QUEUE_VCA)); return; } + if (!ps->pool->die && DO_DEBUG(DBG_SLOW_ACCEPTOR)) + VTIM_sleep(2.0); /* * We were able to hand off, so release this threads VCL diff --git a/bin/varnishtest/tests/c00080.vtc b/bin/varnishtest/tests/c00080.vtc index 6a53959..b231b69 100644 --- a/bin/varnishtest/tests/c00080.vtc +++ b/bin/varnishtest/tests/c00080.vtc @@ -8,33 +8,19 @@ server s1 { varnish v1 -vcl+backend {} -start varnish v1 -cliok "param.set debug +drop_pools" +varnish v1 -cliok "param.set debug +slow_acceptor" varnish v1 -cliok "param.set thread_pools 1" delay 2 -client c1 { +client c1 -repeat 2 { txreq rxresp } -run -varnish v1 -vsc *poo* - delay 2 -client c1 { - txreq - rxresp -} -run - -varnish v1 -vsc *poo* - -delay 2 - -client c1 { - txreq - rxresp -} -run - +varnish v1 -vsc *thr* varnish v1 -vsc *poo* varnish v1 -expect MAIN.pools == 1 diff --git a/include/tbl/debug_bits.h b/include/tbl/debug_bits.h index ea6bf35..1db9db8 100644 --- a/include/tbl/debug_bits.h +++ b/include/tbl/debug_bits.h @@ -45,6 +45,7 @@ DEBUG_BIT(VTC_MODE, vtc_mode, "Varnishtest Mode") DEBUG_BIT(WITNESS, witness, "Emit WITNESS lock records") DEBUG_BIT(VSM_KEEP, vsm_keep, "Keep the VSM file on restart") DEBUG_BIT(DROP_POOLS, drop_pools, "Drop thread pools (testing)") +DEBUG_BIT(SLOW_ACCEPTOR, slow_acceptor, "Slow down Acceptor") #undef DEBUG_BIT /*lint -restore */ From fgsch at lodoss.net Sat Feb 25 23:05:06 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sun, 26 Feb 2017 00:05:06 +0100 Subject: [master] 20c5f37 Polish Message-ID: commit 20c5f379fd0ee18288dac4b501a0c30c7069a4fa Author: Federico G. Schwindt Date: Sat Feb 25 22:56:45 2017 +0000 Polish diff --git a/bin/varnishd/http1/cache_http1_fsm.c b/bin/varnishd/http1/cache_http1_fsm.c index 8195094..526ebb3 100644 --- a/bin/varnishd/http1/cache_http1_fsm.c +++ b/bin/varnishd/http1/cache_http1_fsm.c @@ -205,8 +205,8 @@ http1_reembark(struct worker *wrk, struct req *req) static int __match_proto__(vtr_minimal_response_f) http1_minimal_response(struct req *req, uint16_t status) { - size_t wl, l, spc = 80; - char buf[spc]; + size_t wl, l; + char buf[80]; const char *reason; assert(status >= 100); @@ -214,9 +214,9 @@ http1_minimal_response(struct req *req, uint16_t status) reason = http_Status2Reason(status, NULL); - l = snprintf(buf, spc, + l = snprintf(buf, sizeof(buf), "HTTP/1.1 %03d %s\r\n\r\n", status, reason); - assert (l < spc); + assert (l < sizeof(buf)); VSLb(req->vsl, SLT_RespProtocol, "HTTP/1.1"); VSLb(req->vsl, SLT_RespStatus, "%03d", status); diff --git a/bin/varnishd/http1/cache_http1_vfp.c b/bin/varnishd/http1/cache_http1_vfp.c index f1d85a8..f987e3c 100644 --- a/bin/varnishd/http1/cache_http1_vfp.c +++ b/bin/varnishd/http1/cache_http1_vfp.c @@ -96,7 +96,6 @@ v1f_pull_chunked(struct vfp_ctx *vc, struct vfp_entry *vfe, void *ptr, ssize_t *lp) { struct http_conn *htc; - int i; char buf[20]; /* XXX: 20 is arbitrary */ char *q; unsigned u; @@ -171,8 +170,7 @@ v1f_pull_chunked(struct vfp_ctx *vc, struct vfp_entry *vfe, void *ptr, return (VFP_OK); } AZ(vfe->priv2); - i = v1f_read(vc, htc, buf, 1); - if (i <= 0) + if (v1f_read(vc, htc, buf, 1) <= 0) return (VFP_Error(vc, "chunked read err")); if (buf[0] == '\r' && v1f_read(vc, htc, buf, 1) <= 0) return (VFP_Error(vc, "chunked read err")); diff --git a/bin/varnishd/http2/cache_http2_deliver.c b/bin/varnishd/http2/cache_http2_deliver.c index ef45943..7682a31 100644 --- a/bin/varnishd/http2/cache_http2_deliver.c +++ b/bin/varnishd/http2/cache_http2_deliver.c @@ -121,9 +121,8 @@ int __match_proto__(vtr_minimal_response_f) h2_minimal_response(struct req *req, uint16_t status) { struct h2_req *r2; - const size_t spc = 6; size_t l; - uint8_t buf[spc]; + uint8_t buf[6]; CHECK_OBJ_NOTNULL(req, REQ_MAGIC); CAST_OBJ_NOTNULL(r2, req->transport_priv, H2_REQ_MAGIC); @@ -132,7 +131,7 @@ h2_minimal_response(struct req *req, uint16_t status) assert(status < 1000); l = h2_status(buf, status); - assert(l < spc); + assert(l < sizeof(buf)); VSLb(req->vsl, SLT_RespProtocol, "HTTP/2.0"); VSLb(req->vsl, SLT_RespStatus, "%03d", status); From phk at FreeBSD.org Sat Feb 25 23:52:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Sun, 26 Feb 2017 00:52:05 +0100 Subject: [master] 09df260 Allow and ignore a leading '-' on cli commands. Message-ID: commit 09df2607c0acc409e4f68f20badb175c5853d3a7 Author: Poul-Henning Kamp Date: Sat Feb 25 23:21:51 2017 +0000 Allow and ignore a leading '-' on cli commands. diff --git a/bin/varnishtest/tests/b00008.vtc b/bin/varnishtest/tests/b00008.vtc index 19bc2d9..e536a81 100644 --- a/bin/varnishtest/tests/b00008.vtc +++ b/bin/varnishtest/tests/b00008.vtc @@ -4,6 +4,8 @@ varnish v1 -arg "-b ${bad_ip}:9080" varnish v1 -cliok "help" +varnish v1 -cliok "-help" + varnish v1 -cliok "help -a" varnish v1 -cliok "help -d" diff --git a/include/vcli_serve.h b/include/vcli_serve.h index 1d7d5f9..994de9d 100644 --- a/include/vcli_serve.h +++ b/include/vcli_serve.h @@ -70,6 +70,7 @@ struct cli_proto { struct cli { unsigned magic; #define CLI_MAGIC 0x4038d570 + void *priv; struct vsb *sb; enum VCLI_status_e result; char *cmd; diff --git a/lib/libvarnish/vcli_serve.c b/lib/libvarnish/vcli_serve.c index 9a6cf3e..b501d96 100644 --- a/lib/libvarnish/vcli_serve.c +++ b/lib/libvarnish/vcli_serve.c @@ -344,7 +344,10 @@ cls_vlu(void *priv, const char *p) return (0); REPLACE(cli->cmd, p); - av = VAV_Parse(p, NULL, 0); + if (p[0] == '-') + av = VAV_Parse(p + 1, NULL, 0); + else + av = VAV_Parse(p, NULL, 0); AN(av); if (av[0] != NULL) { i = cls_vlu2(priv, av); @@ -429,6 +432,7 @@ VCLS_AddFd(struct VCLS *cs, int fdi, int fdo, cls_cb_f *closefunc, void *priv) cfd->cli->vlu = VLU_New(cfd, cls_vlu, *cs->maxlen); cfd->cli->sb = VSB_new_auto(); cfd->cli->limit = cs->limit; + cfd->cli->priv = priv; cfd->closefunc = closefunc; cfd->priv = priv; AN(cfd->cli->sb); From phk at FreeBSD.org Sat Feb 25 23:52:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Sun, 26 Feb 2017 00:52:05 +0100 Subject: [master] 9e27227 Implement varnishd -I Message-ID: commit 9e27227550179cb2cc0e8619fc507079efe29130 Author: Poul-Henning Kamp Date: Sat Feb 25 23:41:35 2017 +0000 Implement varnishd -I The CLI commands in the file are executed before the worker process is started, and the output is sent to stderr. CLI failures (!= 200) are fatal, unless the command is prefixed with a '-' in the file. You can now do things like: $ cat I.file vcl.load vcl1 /foo/bar1.vcl vcl.load vcl2 /foo/bar2.vcl vcl.load vcl3 /foo/bar3.vcl start $ varnishd -f '' -I I.file -a :80 [...] diff --git a/bin/varnishd/mgt/mgt.h b/bin/varnishd/mgt/mgt.h index d2dc522..041dba4 100644 --- a/bin/varnishd/mgt/mgt.h +++ b/bin/varnishd/mgt/mgt.h @@ -62,7 +62,7 @@ void MCH_Cli_Fail(void); /* mgt_cli.c */ typedef void mgt_cli_close_f(void *priv); -void mgt_cli_setup(int fdi, int fdo, int verbose, const char *ident, +void mgt_cli_setup(int fdi, int fdo, int auth, const char *ident, mgt_cli_close_f *close_func, void *priv); int mgt_cli_askchild(unsigned *status, char **resp, const char *fmt, ...) __v_printflike(3, 4); diff --git a/bin/varnishd/mgt/mgt_cli.c b/bin/varnishd/mgt/mgt_cli.c index e6a187f..1eb3ce8 100644 --- a/bin/varnishd/mgt/mgt_cli.c +++ b/bin/varnishd/mgt/mgt_cli.c @@ -329,6 +329,8 @@ static void mgt_cli_cb_before(const struct cli *cli) { + if (cli->priv == stderr) + fprintf(stderr, "> %s\n", cli->cmd); MGT_Complain(C_CLI, "CLI %s Rd %s", cli->ident, cli->cmd); } @@ -338,6 +340,12 @@ mgt_cli_cb_after(const struct cli *cli) MGT_Complain(C_CLI, "CLI %s Wr %03u %s", cli->ident, cli->result, VSB_data(cli->sb)); + if (cli->priv == stderr && + cli->result != CLIS_OK && cli->cmd[0] != '-') { + MGT_Complain(C_ERR, "-I file CLI command failed (%d)\n%s\n", + cli->result, VSB_data(cli->sb)); + exit(2); + } } /*--------------------------------------------------------------------*/ @@ -384,20 +392,17 @@ mgt_cli_callback2(const struct vev *e, int what) /*--------------------------------------------------------------------*/ void -mgt_cli_setup(int fdi, int fdo, int verbose, const char *ident, +mgt_cli_setup(int fdi, int fdo, int auth, const char *ident, mgt_cli_close_f *closefunc, void *priv) { struct cli *cli; struct vev *ev; - (void)ident; - (void)verbose; - cli = VCLS_AddFd(mgt_cls, fdi, fdo, closefunc, priv); - cli->ident = strdup(ident); + REPLACE(cli->ident, ident); - if (fdi != 0 && secret_file != NULL) { + if (!auth && secret_file != NULL) { cli->auth = MCF_NOAUTH; mgt_cli_challenge(cli); } else { @@ -407,7 +412,6 @@ mgt_cli_setup(int fdi, int fdo, int verbose, const char *ident, AZ(VSB_finish(cli->sb)); (void)VCLI_WriteResult(fdo, cli->result, VSB_data(cli->sb)); - ev = vev_new(); AN(ev); ev->name = cli->ident; diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index fc24024..538ba17 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -66,6 +66,7 @@ int exit_status = 0; struct vsb *vident; struct VSC_C_mgt static_VSC_C_mgt; struct VSC_C_mgt *VSC_C_mgt; +static int I_fd = -1; static struct vpf_fh *pfh = NULL; @@ -73,7 +74,7 @@ int optreset; // Some has it, some doesn't. Cheaper than auto* /*--------------------------------------------------------------------*/ -static void +static void __attribute__((__noreturn__)) usage(void) { #define FMT " %-28s # %s\n" @@ -97,6 +98,7 @@ usage(void) fprintf(stderr, FMT, "", " -h classic"); fprintf(stderr, FMT, "", " -h classic,"); fprintf(stderr, FMT, "-i identity", "Identity of varnish instance"); + fprintf(stderr, FMT, "-I file", "Initialization CLI commands"); fprintf(stderr, FMT, "-j jail[,jailoptions]", "Jail specification"); #ifdef HAVE_SETPPRIV fprintf(stderr, FMT, "", " -j solaris"); @@ -420,6 +422,16 @@ mgt_uptime(const struct vev *e, int what) /*--------------------------------------------------------------------*/ +static void +mgt_I_close(void *priv) +{ + (void)priv; + fprintf(stderr, "END of -I file processing\n"); + closefd(&I_fd); +} + +/*--------------------------------------------------------------------*/ + struct f_arg { unsigned magic; #define F_ARG_MAGIC 0x840649a8 @@ -428,6 +440,8 @@ struct f_arg { VTAILQ_ENTRY(f_arg) list; }; +static const char opt_spec[] = "a:b:Cdf:Fh:i:I:j:l:M:n:P:p:r:S:s:T:t:VW:x:"; + int main(int argc, char * const *argv) { @@ -455,7 +469,6 @@ main(int argc, char * const *argv) char *dirname; char **av; char Cn_arg[] = "/tmp/varnishd_C_XXXXXXX"; - const char * opt_spec = "a:b:Cdf:Fh:i:j:l:M:n:P:p:r:S:s:T:t:VW:x:"; unsigned u; struct sigaction sac; struct vev *e; @@ -478,6 +491,7 @@ main(int argc, char * const *argv) switch (o) { case '?': usage(); + break; case 'b': b_arg = optarg; break; @@ -626,6 +640,14 @@ main(int argc, char * const *argv) case 'i': i_arg = optarg; break; + case 'I': + if (I_fd >= 0) + ARGV_ERR("\tOnly one -I allowed\n"); + I_fd = open(optarg, O_RDONLY); + if (I_fd < 0) + ARGV_ERR("\tCant open %s: %s\n", + optarg, strerror(errno)); + break; case 'l': av = VAV_Parse(optarg, NULL, ARGV_COMMA); AN(av); @@ -817,6 +839,17 @@ main(int argc, char * const *argv) u = MCH_Init(d_flag || novcl ? 0 : 1); + if (I_fd >= 0) { + fprintf(stderr, "BEGIN of -I file processing\n"); + mgt_cli_setup(I_fd, 2, 1, "-I file", mgt_I_close, stderr); + while (I_fd >= 0) { + o = vev_schedule_one(mgt_evb); + if (o != 1) + MGT_Complain(C_ERR, + "vev_schedule_one() = %d", o); + } + } + if (eric_fd >= 0) mgt_eric_im_done(eric_fd, u); @@ -849,7 +882,6 @@ main(int argc, char * const *argv) e->name = "mgt_sigint"; AZ(vev_add(mgt_evb, e)); - o = vev_schedule(mgt_evb); if (o != 0) MGT_Complain(C_ERR, "vev_schedule() = %d", o); diff --git a/lib/libvarnish/vcli_serve.c b/lib/libvarnish/vcli_serve.c index b501d96..e80d1b7 100644 --- a/lib/libvarnish/vcli_serve.c +++ b/lib/libvarnish/vcli_serve.c @@ -343,7 +343,9 @@ cls_vlu(void *priv, const char *p) if (*p == '\0') return (0); REPLACE(cli->cmd, p); + AN(p); /* for FlexeLint */ + /* We ignore a single leading '-' (for -I cli_file) */ if (p[0] == '-') av = VAV_Parse(p + 1, NULL, 0); else From phk at FreeBSD.org Sat Feb 25 23:52:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Sun, 26 Feb 2017 00:52:05 +0100 Subject: [master] 7c43a11 Add test case for -I cli_file Message-ID: commit 7c43a1107a260a5683fa50fb1171d4399fd9f92a Author: Poul-Henning Kamp Date: Sat Feb 25 23:51:07 2017 +0000 Add test case for -I cli_file diff --git a/bin/varnishtest/tests/a00016.vtc b/bin/varnishtest/tests/a00016.vtc new file mode 100644 index 0000000..963210f --- /dev/null +++ b/bin/varnishtest/tests/a00016.vtc @@ -0,0 +1,13 @@ +varnishtest "Test -I argument" + +shell -err -expect {Only one -I allowed} { + touch foo bar + varnishd -f '' -I foo -I bar -n ${tmpdir}/v0 -a :0 +} + +shell -err -expect {Error: -I file CLI command failed (104)} { + echo "vcl.list" > foo + echo "-foobar" >> foo + echo "vcl.load" >> foo + varnishd -f '' -I foo -n ${tmpdir}/v0 -a :0 +} From phk at FreeBSD.org Sun Feb 26 00:06:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Sun, 26 Feb 2017 01:06:05 +0100 Subject: [master] f885344 Use different workdirs to avoid old SHMfiles confusing varnishadm Message-ID: commit f8853446bf49e3df70e658846bba68e5e8c0af96 Author: Poul-Henning Kamp Date: Sun Feb 26 00:05:14 2017 +0000 Use different workdirs to avoid old SHMfiles confusing varnishadm diff --git a/bin/varnishtest/tests/a00009.vtc b/bin/varnishtest/tests/a00009.vtc index 28ad895..05a4649 100644 --- a/bin/varnishtest/tests/a00009.vtc +++ b/bin/varnishtest/tests/a00009.vtc @@ -36,7 +36,7 @@ shell -err -expect {Neither -b nor -f given} { varnishd -n ${tmpdir}/v0 } # Test -F mode with no VCL loaded -process p1 "exec varnishd -n ${tmpdir}/v0 -F -f '' -a :0 -l2m,3m" -log -start +process p1 "exec varnishd -n ${tmpdir}/v1 -F -f '' -a :0 -l2m,3m" -log -start delay 2 @@ -50,16 +50,16 @@ shell { } shell -expect {VCL compiled.} { - varnishadm -n ${tmpdir}/v0 vcl.load vcl1 ${tmpdir}/vcl + varnishadm -n ${tmpdir}/v1 vcl.load vcl1 ${tmpdir}/vcl } shell -expect {active auto/warm - vcl1} { - varnishadm -n ${tmpdir}/v0 vcl.list + varnishadm -n ${tmpdir}/v1 vcl.list } -shell {varnishadm -n ${tmpdir}/v0 start} +shell {varnishadm -n ${tmpdir}/v1 start} -shell {varnishadm -n ${tmpdir}/v0 debug.listen_address} +shell {varnishadm -n ${tmpdir}/v1 debug.listen_address} process p1 -stop -wait @@ -82,13 +82,13 @@ shell { } process p2 { - exec varnishd -n ${tmpdir}/v0 -F -a :0 -l2m,3m -f ${tmpdir}/ok1 \ + exec varnishd -n ${tmpdir}/v2 -F -a :0 -l2m,3m -f ${tmpdir}/ok1 \ -f ${tmpdir}/ok2 } -log -start delay 2 -shell -match "available.*boot0" {varnishadm -n ${tmpdir}/v0 vcl.list} -shell -match "active.*boot" {varnishadm -n ${tmpdir}/v0 vcl.list} +shell -match "available.*boot0" {varnishadm -n ${tmpdir}/v2 vcl.list} +shell -match "active.*boot" {varnishadm -n ${tmpdir}/v2 vcl.list} process p2 -stop -wait @@ -108,11 +108,11 @@ shell -err { # XXX: two conflicting features, probably not what we want process p3 { - exec varnishd -n ${tmpdir}/v0 -F -a :0 -l2m,3m -f ${tmpdir}/ok1 \ + exec varnishd -n ${tmpdir}/v3 -F -a :0 -l2m,3m -f ${tmpdir}/ok1 \ -f '' -f ${tmpdir}/ok2 } -log -start delay 2 -shell -match "stopped" {varnishadm -n ${tmpdir}/v0 status} +shell -match "stopped" {varnishadm -n ${tmpdir}/v3 status} process p3 -stop -wait From phk at FreeBSD.org Sun Feb 26 07:17:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Sun, 26 Feb 2017 08:17:05 +0100 Subject: [master] 42dc406 Don't start varnishd's with shell if we can avoid it, the required delays are execessive (The varnish testdriver already has code to deal with this) Message-ID: commit 42dc406117168b1498b607c1325d32fbbe03c582 Author: Poul-Henning Kamp Date: Sun Feb 26 07:15:05 2017 +0000 Don't start varnishd's with shell if we can avoid it, the required delays are execessive (The varnish testdriver already has code to deal with this) diff --git a/bin/varnishtest/tests/a00009.vtc b/bin/varnishtest/tests/a00009.vtc index 05a4649..2281600 100644 --- a/bin/varnishtest/tests/a00009.vtc +++ b/bin/varnishtest/tests/a00009.vtc @@ -36,7 +36,7 @@ shell -err -expect {Neither -b nor -f given} { varnishd -n ${tmpdir}/v0 } # Test -F mode with no VCL loaded -process p1 "exec varnishd -n ${tmpdir}/v1 -F -f '' -a :0 -l2m,3m" -log -start +process p1 "exec varnishd -n ${tmpdir}/v1 -F -f '' -a :0 -l2m,3m -s malloc,1m" -log -start delay 2 @@ -81,38 +81,19 @@ shell { EOF } -process p2 { - exec varnishd -n ${tmpdir}/v2 -F -a :0 -l2m,3m -f ${tmpdir}/ok1 \ - -f ${tmpdir}/ok2 -} -log -start - -delay 2 -shell -match "available.*boot0" {varnishadm -n ${tmpdir}/v2 vcl.list} -shell -match "active.*boot" {varnishadm -n ${tmpdir}/v2 vcl.list} - -process p2 -stop -wait +varnish v2 -arg "-f ${tmpdir}/ok1" -arg "-f ${tmpdir}/ok2" -start +varnish v2 -cliexpect {available *auto/warm *0 boot0} "vcl.list" +varnish v2 -cliexpect {active *auto/warm *0 boot} "vcl.list" +varnish v2 -stop -wait # Test multiple -f options with a bad VCL -shell -err { +shell -err -expect {Cannot read -f file} { exec varnishd -n ${tmpdir}/v0 -F -a :0 -l2m,3m -f ${tmpdir}/ok1 \ -f ${tmpdir}/ok2 -f ${tmpdir}/bad } -shell -err { +shell -err -expect {Cannot read -f file} { exec varnishd -n ${tmpdir}/v0 -F -a :0 -l2m,3m -f ${tmpdir}/ok1 \ -f ${tmpdir}/bad -f ${tmpdir}/ok2 } - -# Test multiple -f options with an empty value -# XXX: two conflicting features, probably not what we want - -process p3 { - exec varnishd -n ${tmpdir}/v3 -F -a :0 -l2m,3m -f ${tmpdir}/ok1 \ - -f '' -f ${tmpdir}/ok2 -} -log -start - -delay 2 -shell -match "stopped" {varnishadm -n ${tmpdir}/v3 status} - -process p3 -stop -wait From fgsch at lodoss.net Sun Feb 26 18:56:05 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sun, 26 Feb 2017 19:56:05 +0100 Subject: [master] f9348e4 Whitespace OCD Message-ID: commit f9348e45da476e0993ab995acb0311aac681e969 Author: Federico G. Schwindt Date: Sun Feb 26 18:25:49 2017 +0000 Whitespace OCD diff --git a/bin/varnishd/cache/cache_acceptor.c b/bin/varnishd/cache/cache_acceptor.c index 2f28418..1cb34f1 100644 --- a/bin/varnishd/cache/cache_acceptor.c +++ b/bin/varnishd/cache/cache_acceptor.c @@ -599,7 +599,7 @@ ccf_listen_address(struct cli *cli, const char * const *av, void *priv) * a race where varnishtest::client would attempt to connect(2) * before listen(2) has been called. */ - while(!pool_accepting) + while (!pool_accepting) VTIM_sleep(.1); VTAILQ_FOREACH(ls, &heritage.socks, list) { diff --git a/bin/varnishd/cache/cache_backend_probe.c b/bin/varnishd/cache/cache_backend_probe.c index 22a5d98..1d743f8 100644 --- a/bin/varnishd/cache/cache_backend_probe.c +++ b/bin/varnishd/cache/cache_backend_probe.c @@ -235,7 +235,7 @@ vbp_poke(struct vbp_target *vt) i = VSA_Get_Proto(sa); if (i == AF_INET) vt->good_ipv4 |= 1; - else if(i == AF_INET6) + else if (i == AF_INET6) vt->good_ipv6 |= 1; else WRONG("Wrong probe protocol family"); @@ -455,7 +455,7 @@ vbp_build_req(struct vbp_target *vt, const struct vrt_backend_probe *vbp, vsb = VSB_new_auto(); AN(vsb); VSB_clear(vsb); - if(vbp->request != NULL) { + if (vbp->request != NULL) { VSB_cat(vsb, vbp->request); } else { VSB_printf(vsb, "GET %s HTTP/1.1\r\n", diff --git a/bin/varnishd/cache/cache_ban_lurker.c b/bin/varnishd/cache/cache_ban_lurker.c index f236b2c..638298c 100644 --- a/bin/varnishd/cache/cache_ban_lurker.c +++ b/bin/varnishd/cache/cache_ban_lurker.c @@ -288,7 +288,7 @@ ban_lurker_work(struct worker *wrk, struct vsl_log *vsl) dt = 49.62; // Random, non-magic if (cache_param->ban_lurker_sleep == 0) { - (void) ban_cleantail(NULL); + (void)ban_cleantail(NULL); return (dt); } diff --git a/bin/varnishd/cache/cache_cli.c b/bin/varnishd/cache/cache_cli.c index fa8aba8..905dee5 100644 --- a/bin/varnishd/cache/cache_cli.c +++ b/bin/varnishd/cache/cache_cli.c @@ -100,7 +100,7 @@ CLI_Run(void) do { i = VCLS_Poll(cls, -1); - } while(i > 0); + } while (i > 0); VSL(SLT_CLI, 0, "EOF on CLI connection, worker stops"); } diff --git a/bin/varnishd/cache/cache_expire.c b/bin/varnishd/cache/cache_expire.c index b93cc59..cfe2122 100644 --- a/bin/varnishd/cache/cache_expire.c +++ b/bin/varnishd/cache/cache_expire.c @@ -150,7 +150,7 @@ EXP_Rearm(struct objcore *oc, double now, double ttl, double grace, double keep) CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); assert(oc->refcnt > 0); - if (! (oc->exp_flags & OC_EF_REFD)) + if (!(oc->exp_flags & OC_EF_REFD)) return; if (!isnan(ttl)) diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 2b89ff4..2b701d4 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -829,7 +829,7 @@ vbf_stp_error(struct worker *wrk, struct busyobj *bo) now = W_TIM_real(wrk); VSLb_ts_busyobj(bo, "Error", now); - if(bo->fetch_objcore->stobj->stevedore != NULL) + if (bo->fetch_objcore->stobj->stevedore != NULL) ObjFreeObj(bo->wrk, bo->fetch_objcore); // XXX: reset all beresp flags ? diff --git a/bin/varnishd/cache/cache_fetch_proc.c b/bin/varnishd/cache/cache_fetch_proc.c index cb094fd..afa8959 100644 --- a/bin/varnishd/cache/cache_fetch_proc.c +++ b/bin/varnishd/cache/cache_fetch_proc.c @@ -120,7 +120,7 @@ VFP_Close(struct vfp_ctx *vc) struct vfp_entry *vfe; VTAILQ_FOREACH(vfe, &vc->vfp, list) { - if(vfe->vfp->fini != NULL) + if (vfe->vfp->fini != NULL) vfe->vfp->fini(vc, vfe); VSLb(vc->wrk->vsl, SLT_VfpAcct, "%s %ju %ju", vfe->vfp->name, (uintmax_t)vfe->calls, (uintmax_t)vfe->bytes_out); diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index d5eeff7..5e08fc8 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -564,7 +564,7 @@ hsh_rush2(struct worker *wrk, struct rush *r) CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(r, RUSH_MAGIC); - while(!VTAILQ_EMPTY(&r->reqs)) { + while (!VTAILQ_EMPTY(&r->reqs)) { req = VTAILQ_FIRST(&r->reqs); CHECK_OBJ_NOTNULL(req, REQ_MAGIC); VTAILQ_REMOVE(&r->reqs, req, w_list); diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c index 873bd8a..d1396bf 100644 --- a/bin/varnishd/cache/cache_http.c +++ b/bin/varnishd/cache/cache_http.c @@ -507,7 +507,7 @@ http_GetHdrToken(const struct http *hp, const char *hdr, return (0); AN(h); - while(http_split(&h, NULL, ",", &b, &e)) + while (http_split(&h, NULL, ",", &b, &e)) if (http_istoken(&b, e, token)) break; if (b == NULL) @@ -543,7 +543,7 @@ http_GetHdrQ(const struct http *hp, const char *hdr, const char *field) if (hb == NULL) return (1.); - while(http_split(&hb, he, ";", &b, &e)) { + while (http_split(&hb, he, ";", &b, &e)) { if (*b != 'q') continue; for (b++; b < e && vct_issp(*b); b++) diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index f6446af..009c587 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -372,7 +372,7 @@ pan_busyobj(struct vsb *vsb, const struct busyobj *bo) p = ""; /*lint -save -esym(438,p) */ #define BO_FLAG(l, r, w, d) \ - if(bo->l) { VSB_printf(vsb, "%s" #l, p); p = ", "; } + if (bo->l) { VSB_printf(vsb, "%s" #l, p); p = ", "; } #include "tbl/bo_flags.h" /*lint -restore */ VSB_printf(vsb, "},\n"); @@ -476,7 +476,7 @@ pan_req(struct vsb *vsb, const struct req *req) VSB_printf(vsb, "flags = {\n"); VSB_indent(vsb, 2); -#define REQ_FLAG(l, r, w, d) if(req->l) VSB_printf(vsb, #l ",\n"); +#define REQ_FLAG(l, r, w, d) if (req->l) VSB_printf(vsb, #l ",\n"); #include "tbl/req_flags.h" VSB_indent(vsb, -2); VSB_printf(vsb, "},\n"); @@ -555,7 +555,7 @@ pan_backtrace(struct vsb *vsb) p += strlen(buf); if (*p == ':') p++; - while(*p == ' ') + while (*p == ' ') p++; } VSB_printf(vsb, "%s", p); diff --git a/bin/varnishd/cache/cache_req_body.c b/bin/varnishd/cache/cache_req_body.c index f92dbba..935a9fc 100644 --- a/bin/varnishd/cache/cache_req_body.c +++ b/bin/varnishd/cache/cache_req_body.c @@ -87,7 +87,7 @@ vrb_pull(struct req *req, ssize_t maxsize, objiterate_f *func, void *priv) yet = req->htc->content_length; if (yet != 0 && req->want100cont) { req->want100cont = 0; - (void) req->transport->minimal_response(req, 100); + (void)req->transport->minimal_response(req, 100); } if (yet < 0) yet = 0; diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index a603ecc..000ae75 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -474,7 +474,7 @@ VRT_l_req_esi(VRT_CTX, unsigned process_esi) * Only allow you to turn of esi in the main request * else everything gets confused */ - if(ctx->req->esi_level == 0) + if (ctx->req->esi_level == 0) ctx->req->disable_esi = !process_esi; } diff --git a/bin/varnishd/hash/hash_critbit.c b/bin/varnishd/hash/hash_critbit.c index 97fa154..f29a815 100644 --- a/bin/varnishd/hash/hash_critbit.c +++ b/bin/varnishd/hash/hash_critbit.c @@ -210,7 +210,7 @@ hcb_insert(struct worker *wrk, struct hcb_root *root, const uint8_t *digest, return (oh2); } - while(hcb_is_y(pp)) { + while (hcb_is_y(pp)) { y = hcb_l_y(pp); CHECK_OBJ_NOTNULL(y, HCB_Y_MAGIC); assert(y->ptr < DIGEST_LEN); @@ -253,7 +253,7 @@ hcb_insert(struct worker *wrk, struct hcb_root *root, const uint8_t *digest, p = &root->origo; AN(*p); - while(hcb_is_y(*p)) { + while (hcb_is_y(*p)) { y = hcb_l_y(*p); CHECK_OBJ_NOTNULL(y, HCB_Y_MAGIC); assert(y->critbit != y2->critbit); @@ -287,7 +287,7 @@ hcb_delete(struct hcb_root *r, struct objhead *oh) assert(hcb_is_y(*p)); y = NULL; - while(1) { + while (1) { assert(hcb_is_y(*p)); y = hcb_l_y(*p); assert(y->ptr < DIGEST_LEN); diff --git a/bin/varnishd/http1/cache_http1_fsm.c b/bin/varnishd/http1/cache_http1_fsm.c index 526ebb3..a197cc5 100644 --- a/bin/varnishd/http1/cache_http1_fsm.c +++ b/bin/varnishd/http1/cache_http1_fsm.c @@ -230,7 +230,7 @@ http1_minimal_response(struct req *req, uint16_t status) req->acct.resp_hdrbytes += wl; if (wl != l) { VTCP_Assert(1); - if (! req->doclose) + if (!req->doclose) req->doclose = SC_REM_CLOSE; return (-1); } diff --git a/bin/varnishd/http1/cache_http1_vfp.c b/bin/varnishd/http1/cache_http1_vfp.c index f987e3c..50a2123 100644 --- a/bin/varnishd/http1/cache_http1_vfp.c +++ b/bin/varnishd/http1/cache_http1_vfp.c @@ -137,7 +137,7 @@ v1f_pull_chunked(struct vfp_ctx *vc, struct vfp_entry *vfe, void *ptr, return (VFP_Error(vc, "chunked header too long")); /* Skip trailing white space */ - while(vct_islws(buf[u]) && buf[u] != '\n') { + while (vct_islws(buf[u]) && buf[u] != '\n') { lr = v1f_read(vc, htc, buf + u, 1); if (lr <= 0) return (VFP_Error(vc, "chunked read err")); @@ -152,7 +152,7 @@ v1f_pull_chunked(struct vfp_ctx *vc, struct vfp_entry *vfe, void *ptr, if (q == NULL || *q != '\0') return (VFP_Error(vc, "chunked header number syntax")); cl = (ssize_t)cll; - if((uintmax_t)cl != cll) + if ((uintmax_t)cl != cll) return (VFP_Error(vc, "bogusly large chunk size")); vfe->priv2 = cl; diff --git a/bin/varnishd/http2/cache_http2_deliver.c b/bin/varnishd/http2/cache_http2_deliver.c index 7682a31..dfe2aed 100644 --- a/bin/varnishd/http2/cache_http2_deliver.c +++ b/bin/varnishd/http2/cache_http2_deliver.c @@ -216,12 +216,12 @@ h2_deliver(struct req *req, struct boc *boc, int sendbody) *p++ = (uint8_t)sz - 0x7f; } - for(sz1 = 0; sz1 < sz; sz1++) + for (sz1 = 0; sz1 < sz; sz1++) *p++ = (uint8_t)tolower(hp->hd[u].b[sz1]); } - while(vct_islws(*++r)) + while (vct_islws(*++r)) continue; sz = hp->hd[u].e - r; assert(sz <= 254); diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index abca18d..0c5a5e9 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -740,7 +740,7 @@ h2_b64url_settings(struct h2_sess *h2, struct req *req) n = 0; x = 0; up = u; - for(;*p; p++) { + for (;*p; p++) { q = strchr(s, *p); if (q == NULL) return (-1); diff --git a/bin/varnishd/mgt/mgt_jail_solaris.c b/bin/varnishd/mgt/mgt_jail_solaris.c index 96d1cba..55d8b3b 100644 --- a/bin/varnishd/mgt/mgt_jail_solaris.c +++ b/bin/varnishd/mgt/mgt_jail_solaris.c @@ -255,7 +255,7 @@ jail_master_gen(enum jail_master_e e) static int __match_proto__(jail_init_f) vjs_init(char **args) { - (void) args; + (void)args; return 0; } @@ -390,7 +390,7 @@ vjs_setup(enum jail_gen_e jge) { priv_set_t *priv_all; - if (! (priv_all = priv_allocset())) { + if (!(priv_all = priv_allocset())) { MGT_Complain(C_SECURITY, "Solaris Jail warning: " " vjs_setup - priv_allocset failed: errno=%d (%s)", diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index 538ba17..4ce28e0 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -780,7 +780,7 @@ main(int argc, char * const *argv) (void)rmdir(Cn_arg); exit(cli->result == CLIS_OK ? 0 : 2); } else { - while(!VTAILQ_EMPTY(&f_args)) { + while (!VTAILQ_EMPTY(&f_args)) { fa = VTAILQ_FIRST(&f_args); VTAILQ_REMOVE(&f_args, fa, list); mgt_vcl_startup(cli, fa->src, diff --git a/bin/varnishd/mgt/mgt_param_tweak.c b/bin/varnishd/mgt/mgt_param_tweak.c index 643563a..12a7a52 100644 --- a/bin/varnishd/mgt/mgt_param_tweak.c +++ b/bin/varnishd/mgt/mgt_param_tweak.c @@ -420,7 +420,7 @@ tweak_poolparam(struct vsb *vsb, const struct parspec *par, const char *arg) break; } *pp = px; - } while(0); + } while (0); VAV_Free(av); } return (retval); diff --git a/bin/varnishd/mgt/mgt_util.c b/bin/varnishd/mgt/mgt_util.c index 0870089..4c59a9e 100644 --- a/bin/varnishd/mgt/mgt_util.c +++ b/bin/varnishd/mgt/mgt_util.c @@ -147,7 +147,7 @@ const void * MGT_Pick(const struct choice *cp, const char *which, const char *kind) { - for(; cp->name != NULL; cp++) { + for (; cp->name != NULL; cp++) { if (!strcmp(cp->name, which)) return (cp->ptr); } diff --git a/bin/varnishd/mgt/mgt_vcl.c b/bin/varnishd/mgt/mgt_vcl.c index b8ac355..7d9e52e 100644 --- a/bin/varnishd/mgt/mgt_vcl.c +++ b/bin/varnishd/mgt/mgt_vcl.c @@ -445,7 +445,7 @@ mgt_push_vcls_and_start(struct cli *cli, unsigned *status, char **p) free(*p); *p = NULL; } - } while(!done); + } while (!done); if (mgt_cli_askchild(status, p, "vcl.use \"%s\"\n", active_vcl->name)) return (1); diff --git a/bin/varnishd/storage/stevedore_utils.c b/bin/varnishd/storage/stevedore_utils.c index dcf5e95..6225112 100644 --- a/bin/varnishd/storage/stevedore_utils.c +++ b/bin/varnishd/storage/stevedore_utils.c @@ -189,7 +189,7 @@ STV_FileSize(int fd, const char *size, unsigned *granularity, const char *ctx) * just add OFF_MAX to ... */ i = 0; - while(1) { + while (1) { o = l; if (o == l && o > 0) break; diff --git a/bin/varnishd/storage/storage.h b/bin/varnishd/storage/storage.h index 2c842d0..2b7ae53 100644 --- a/bin/varnishd/storage/storage.h +++ b/bin/varnishd/storage/storage.h @@ -127,7 +127,7 @@ extern struct stevedore *stv_transient; /*--------------------------------------------------------------------*/ -#define STV_Foreach(arg) for(arg = NULL; STV__iter(&arg);) +#define STV_Foreach(arg) for (arg = NULL; STV__iter(&arg);) int STV__iter(struct stevedore ** const ); diff --git a/bin/varnishd/storage/storage_file.c b/bin/varnishd/storage/storage_file.c index 1b8e364..143ab9d 100644 --- a/bin/varnishd/storage/storage_file.c +++ b/bin/varnishd/storage/storage_file.c @@ -379,7 +379,7 @@ smf_open_chunk(struct smf_sc *sc, off_t sz, off_t off, off_t *fail, off_t *sum) p = mmap(NULL, sz, PROT_READ|PROT_WRITE, MAP_NOCORE | MAP_NOSYNC | MAP_SHARED, sc->fd, off); if (p != MAP_FAILED) { - (void) madvise(p, sz, sc->advice); + (void)madvise(p, sz, sc->advice); (*sum) += sz; new_smf(sc, p, off, sz); return; diff --git a/bin/varnishd/storage/storage_persistent.c b/bin/varnishd/storage/storage_persistent.c index fa0504d..ad2d2a1 100644 --- a/bin/varnishd/storage/storage_persistent.c +++ b/bin/varnishd/storage/storage_persistent.c @@ -232,7 +232,7 @@ smp_open_segs(struct smp_sc *sc, struct smp_signspace *spc) sg1 = NULL; sg2 = NULL; - for(; ss <= se; ss++) { + for (; ss <= se; ss++) { ALLOC_OBJ(sg, SMP_SEG_MAGIC); AN(sg); VTAILQ_INIT(&sg->objcores); diff --git a/bin/varnishd/storage/storage_persistent_silo.c b/bin/varnishd/storage/storage_persistent_silo.c index 1ee1c1d..5061188 100644 --- a/bin/varnishd/storage/storage_persistent_silo.c +++ b/bin/varnishd/storage/storage_persistent_silo.c @@ -440,7 +440,7 @@ smp_sml_getobj(struct worker *wrk, struct objcore *oc) if (l != vbe64dec(o->fa_len)) bad |= 0x100; - if(bad) { + if (bad) { EXP_ZERO(oc); EXP_ZERO(so); } diff --git a/bin/varnishd/waiter/cache_waiter_epoll.c b/bin/varnishd/waiter/cache_waiter_epoll.c index 0a59592..23684b6 100644 --- a/bin/varnishd/waiter/cache_waiter_epoll.c +++ b/bin/varnishd/waiter/cache_waiter_epoll.c @@ -128,7 +128,7 @@ vwe_thread(void *priv) Lck_Lock(&vwe->mtx); active = Wait_HeapDelete(w, wp); Lck_Unlock(&vwe->mtx); - if (! active) { + if (!active) { VSL(SLT_Debug, wp->fd, "epoll: spurious event"); continue; } diff --git a/bin/varnishd/waiter/cache_waiter_ports.c b/bin/varnishd/waiter/cache_waiter_ports.c index a7b2e47..b7259bf 100644 --- a/bin/varnishd/waiter/cache_waiter_ports.c +++ b/bin/varnishd/waiter/cache_waiter_ports.c @@ -110,7 +110,7 @@ static inline void vws_port_ev(struct vws *vws, struct waiter *w, port_event_t *ev, double now) { struct waited *wp; - if(ev->portev_source == PORT_SOURCE_USER) { + if (ev->portev_source == PORT_SOURCE_USER) { CAST_OBJ_NOTNULL(wp, ev->portev_user, WAITED_MAGIC); assert(wp->fd >= 0); vws->nwaited++; diff --git a/bin/varnishtest/tests/d00015.vtc b/bin/varnishtest/tests/d00015.vtc index c3aec0c..8e3aab6 100644 --- a/bin/varnishtest/tests/d00015.vtc +++ b/bin/varnishtest/tests/d00015.vtc @@ -21,33 +21,33 @@ varnish v1 -vcl+backend { vd.debug(3); std.log("-- invalid replicas"); - if (! vd.reconfigure(replicas=0)) { + if (!vd.reconfigure(replicas=0)) { std.log("reconfigure failed"); } std.log("-- no changes - no debug output"); - if (! vd.reconfigure(replicas=25)) { + if (!vd.reconfigure(replicas=25)) { std.log("reconfigure failed"); } std.log("-- no backends"); - if (! vd.clear()) { + if (!vd.clear()) { std.log("clear failed"); } - if (! vd.reconfigure(replicas=25)) { + if (!vd.reconfigure(replicas=25)) { std.log("reconfigure failed"); } std.log("-- one backend"); - if (! vd.add_backend(s1)) { + if (!vd.add_backend(s1)) { std.log("add s1 failed"); } - if (! vd.reconfigure(replicas=1)) { + if (!vd.reconfigure(replicas=1)) { std.log("reconfigure failed"); } std.log("-- no change - no output"); - if (! vd.reconfigure(replicas=1)) { + if (!vd.reconfigure(replicas=1)) { std.log("reconfigure failed"); } @@ -59,7 +59,7 @@ varnish v1 -vcl+backend { vd.add_backend(s1); vd.add_backend(s2); vd.clear(); - if (! vd.reconfigure()) { + if (!vd.reconfigure()) { std.log("reconfigure failed"); } @@ -68,7 +68,7 @@ varnish v1 -vcl+backend { vd.add_backend(s1); vd.add_backend(s2); vd.add_backend(s1); - if (! vd.reconfigure(replicas=1)) { + if (!vd.reconfigure(replicas=1)) { std.log("reconfigure failed"); } @@ -81,19 +81,19 @@ varnish v1 -vcl+backend { vd.add_backend(s2, ident="s1"); vd.add_backend(s2, ident="s1_1"); vd.add_backend(s2, ident="s1_2"); - if (! vd.reconfigure(replicas=1)) { + if (!vd.reconfigure(replicas=1)) { std.log("reconfigure failed"); } std.log("-- remove s1_2 specifically"); vd.remove_backend(ident="s1_2"); - if (! vd.reconfigure(replicas=1)) { + if (!vd.reconfigure(replicas=1)) { std.log("reconfigure failed"); } std.log("-- remove all instances of s1"); vd.remove_backend(s1); - if (! vd.reconfigure(replicas=1)) { + if (!vd.reconfigure(replicas=1)) { std.log("reconfigure failed"); } @@ -109,19 +109,19 @@ varnish v1 -vcl+backend { vd.add_backend(s3, "7"); vd.add_backend(s3, "8"); vd.add_backend(s3, "9"); - if (! vd.reconfigure(replicas=1)) { + if (!vd.reconfigure(replicas=1)) { std.log("reconfigure failed"); } std.log("-- remove second-last"); vd.remove_backend(ident="8"); - if (! vd.reconfigure(replicas=1)) { + if (!vd.reconfigure(replicas=1)) { std.log("reconfigure failed"); } std.log("-- remove last"); vd.remove_backend(ident="9"); - if (! vd.reconfigure(replicas=1)) { + if (!vd.reconfigure(replicas=1)) { std.log("reconfigure failed"); } diff --git a/bin/varnishtest/tests/d00016.vtc b/bin/varnishtest/tests/d00016.vtc index 2e5406d..b58ea29 100644 --- a/bin/varnishtest/tests/d00016.vtc +++ b/bin/varnishtest/tests/d00016.vtc @@ -23,33 +23,33 @@ varnish v1 -vcl+backend { sub vcl_recv { std.log("-- invalid replicas"); - if (! vd.reconfigure(replicas=0)) { + if (!vd.reconfigure(replicas=0)) { std.log("reconfigure failed"); } std.log("-- no changes - no debug output"); - if (! vd.reconfigure(replicas=25)) { + if (!vd.reconfigure(replicas=25)) { std.log("reconfigure failed"); } std.log("-- no backends"); - if (! vd.clear()) { + if (!vd.clear()) { std.log("clear failed"); } - if (! vd.reconfigure(replicas=25)) { + if (!vd.reconfigure(replicas=25)) { std.log("reconfigure failed"); } std.log("-- one backend"); - if (! vd.add_backend(s1)) { + if (!vd.add_backend(s1)) { std.log("add s1 failed"); } - if (! vd.reconfigure(replicas=1)) { + if (!vd.reconfigure(replicas=1)) { std.log("reconfigure failed"); } std.log("-- no change - no output"); - if (! vd.reconfigure(replicas=1)) { + if (!vd.reconfigure(replicas=1)) { std.log("reconfigure failed"); } @@ -61,7 +61,7 @@ varnish v1 -vcl+backend { vd.add_backend(s1); vd.add_backend(s2); vd.clear(); - if (! vd.reconfigure()) { + if (!vd.reconfigure()) { std.log("reconfigure failed"); } @@ -70,7 +70,7 @@ varnish v1 -vcl+backend { vd.add_backend(s1); vd.add_backend(s2); vd.add_backend(s1); - if (! vd.reconfigure(replicas=1)) { + if (!vd.reconfigure(replicas=1)) { std.log("reconfigure failed"); } @@ -83,19 +83,19 @@ varnish v1 -vcl+backend { vd.add_backend(s2, ident="s1"); vd.add_backend(s2, ident="s1_1"); vd.add_backend(s2, ident="s1_2"); - if (! vd.reconfigure(replicas=1)) { + if (!vd.reconfigure(replicas=1)) { std.log("reconfigure failed"); } std.log("-- remove s1_2 specifically"); vd.remove_backend(ident="s1_2"); - if (! vd.reconfigure(replicas=1)) { + if (!vd.reconfigure(replicas=1)) { std.log("reconfigure failed"); } std.log("-- remove all instances of s1"); vd.remove_backend(s1); - if (! vd.reconfigure(replicas=1)) { + if (!vd.reconfigure(replicas=1)) { std.log("reconfigure failed"); } @@ -111,19 +111,19 @@ varnish v1 -vcl+backend { vd.add_backend(s3, "7"); vd.add_backend(s3, "8"); vd.add_backend(s3, "9"); - if (! vd.reconfigure(replicas=1)) { + if (!vd.reconfigure(replicas=1)) { std.log("reconfigure failed"); } std.log("-- remove second-last"); vd.remove_backend(ident="8"); - if (! vd.reconfigure(replicas=1)) { + if (!vd.reconfigure(replicas=1)) { std.log("reconfigure failed"); } std.log("-- remove last"); vd.remove_backend(ident="9"); - if (! vd.reconfigure(replicas=1)) { + if (!vd.reconfigure(replicas=1)) { std.log("reconfigure failed"); } diff --git a/bin/varnishtest/tests/d00017.vtc b/bin/varnishtest/tests/d00017.vtc index 808e23b..4d49563 100644 --- a/bin/varnishtest/tests/d00017.vtc +++ b/bin/varnishtest/tests/d00017.vtc @@ -29,16 +29,16 @@ varnish v1 -vcl+backend { sub vcl_init { new vd = directors.shard(); vd.debug(3); - if (! vd.add_backend(s1)) { + if (!vd.add_backend(s1)) { std.log("add s1 failed"); } - if (! vd.add_backend(s2)) { + if (!vd.add_backend(s2)) { std.log("add s2 failed"); } - if (! vd.add_backend(s3)) { + if (!vd.add_backend(s3)) { std.log("add s3 failed"); } - if (! vd.reconfigure(replicas=25)) { + if (!vd.reconfigure(replicas=25)) { std.log("reconfigure failed"); } } diff --git a/bin/varnishtest/tests/d00018.vtc b/bin/varnishtest/tests/d00018.vtc index 3ca77be..a3f02e0 100644 --- a/bin/varnishtest/tests/d00018.vtc +++ b/bin/varnishtest/tests/d00018.vtc @@ -21,28 +21,28 @@ varnish v1 -vcl+backend { sub vcl_init { new vd = directors.shard(); - if (! vd.add_backend(s1)) { + if (!vd.add_backend(s1)) { std.log("add s1 failed"); } - if (! vd.add_backend(s2)) { + if (!vd.add_backend(s2)) { std.log("add s2 failed"); } - if (! vd.add_backend(s3)) { + if (!vd.add_backend(s3)) { std.log("add s3 failed"); } - if (! vd.reconfigure(replicas=25)) { + if (!vd.reconfigure(replicas=25)) { std.log("reconfigure failed"); } } sub vcl_recv { - if(req.url == "/1") { + if (req.url == "/1") { set req.backend_hint = vd.backend(by=KEY, key=1); } - if(req.url == "/2") { + if (req.url == "/2") { set req.backend_hint = vd.backend(by=KEY, key=2147483647); } - if(req.url == "/3") { + if (req.url == "/3") { set req.backend_hint = vd.backend(by=KEY, key=4294967295); } return(pass); diff --git a/bin/varnishtest/tests/d00021.vtc b/bin/varnishtest/tests/d00021.vtc index 9258abb..627f717 100644 --- a/bin/varnishtest/tests/d00021.vtc +++ b/bin/varnishtest/tests/d00021.vtc @@ -36,7 +36,7 @@ varnish v1 -vcl+backend { } sub vcl_recv { - if(req.url == "/1") { + if (req.url == "/1") { set req.backend_hint = vd.backend(by=KEY, key=vd.key(alg=CRC32, string="/eishoSu2")); } else if (req.url == "/2") { diff --git a/bin/varnishtest/tests/d00022.vtc b/bin/varnishtest/tests/d00022.vtc index 0aa1fad..3d0e9e1 100644 --- a/bin/varnishtest/tests/d00022.vtc +++ b/bin/varnishtest/tests/d00022.vtc @@ -44,17 +44,17 @@ varnish v1 -vcl+backend { alt=req.restarts, healthy=ALL); - if(req.url == "/2" && req.restarts > 0) { + if (req.url == "/2" && req.restarts > 0) { unset req.http.vrstart; } - if(req.url == "/3" && req.restarts > 1) { + if (req.url == "/3" && req.restarts > 1) { unset req.http.vrstart; } return(pass); } sub vcl_deliver { - if(req.http.vrstart) { + if (req.http.vrstart) { return(restart); } } diff --git a/bin/varnishtest/tests/e00015.vtc b/bin/varnishtest/tests/e00015.vtc index f5a948b..7d09441 100644 --- a/bin/varnishtest/tests/e00015.vtc +++ b/bin/varnishtest/tests/e00015.vtc @@ -24,7 +24,7 @@ server s1 { varnish v1 -vcl+backend { sub vcl_recv { - if(req.url == "/") { + if (req.url == "/") { set req.esi = false; } } diff --git a/bin/varnishtest/tests/e00016.vtc b/bin/varnishtest/tests/e00016.vtc index b760284..d256c28 100644 --- a/bin/varnishtest/tests/e00016.vtc +++ b/bin/varnishtest/tests/e00016.vtc @@ -32,7 +32,7 @@ varnish v1 -vcl+backend { } sub vcl_deliver { set req.esi = true; - if(req.url == "/body") { + if (req.url == "/body") { set req.esi = false; } } diff --git a/bin/varnishtest/tests/r01494.vtc b/bin/varnishtest/tests/r01494.vtc index 38880c5..713ceb9 100644 --- a/bin/varnishtest/tests/r01494.vtc +++ b/bin/varnishtest/tests/r01494.vtc @@ -13,7 +13,7 @@ server s1 { varnish v1 -vcl+backend { sub vcl_backend_response { - if(bereq.retries == 0) { + if (bereq.retries == 0) { return(retry); } } diff --git a/bin/varnishtest/vtc_h2_tbl.c b/bin/varnishtest/vtc_h2_tbl.c index ae2ceca..209fa47 100644 --- a/bin/varnishtest/vtc_h2_tbl.c +++ b/bin/varnishtest/vtc_h2_tbl.c @@ -285,7 +285,7 @@ void HPK_FreeCtx(struct hpk_ctx *ctx) { - while(!VTAILQ_EMPTY(&ctx->dyntbl)) + while (!VTAILQ_EMPTY(&ctx->dyntbl)) pop_header(ctx); free(ctx); } diff --git a/bin/varnishtest/vtc_http.c b/bin/varnishtest/vtc_http.c index 60af496..b81bb70 100644 --- a/bin/varnishtest/vtc_http.c +++ b/bin/varnishtest/vtc_http.c @@ -595,13 +595,13 @@ http_rxchunk(struct http *hp) l = hp->prxbuf; if (http_rxchar(hp, 2, 0) < 0) return (-1); - if(!vct_iscrlf(hp->rxbuf + l)) { + if (!vct_iscrlf(hp->rxbuf + l)) { vtc_log(hp->vl, hp->fatal, "Wrong chunk tail[0] = %02x", hp->rxbuf[l] & 0xff); return (-1); } - if(!vct_iscrlf(hp->rxbuf + l + 1)) { + if (!vct_iscrlf(hp->rxbuf + l + 1)) { vtc_log(hp->vl, hp->fatal, "Wrong chunk tail[1] = %02x", hp->rxbuf[l + 1] & 0xff); @@ -708,7 +708,7 @@ cmd_http_rxresp(CMD_ARGS) AZ(strcmp(av[0], "rxresp")); av++; - for(; *av != NULL; av++) + for (; *av != NULL; av++) if (!strcmp(*av, "-no_obj")) has_obj = 0; else @@ -745,7 +745,7 @@ cmd_http_rxresphdrs(CMD_ARGS) AZ(strcmp(av[0], "rxresphdrs")); av++; - for(; *av != NULL; av++) + for (; *av != NULL; av++) vtc_fatal(hp->vl, "Unknown http rxresp spec: %s\n", *av); http_rxhdr(hp); http_splitheader(hp, 0); @@ -876,7 +876,7 @@ http_tx_parse_args(char * const *av, struct vtclog *vl, struct http *hp, (void)vl; nullbody = body; - for(; *av != NULL; av++) { + for (; *av != NULL; av++) { if (!strcmp(*av, "-nolen")) { nolen = 1; } else if (!strcmp(*av, "-hdr")) { @@ -885,7 +885,7 @@ http_tx_parse_args(char * const *av, struct vtclog *vl, struct http *hp, } else break; } - for(; *av != NULL; av++) { + for (; *av != NULL; av++) { if (!strcmp(*av, "-body")) { assert(body == nullbody); REPLACE(body, av[1]); @@ -894,9 +894,9 @@ http_tx_parse_args(char * const *av, struct vtclog *vl, struct http *hp, av++; bodylen = strlen(body); for (b = body; *b != '\0'; b++) { - if(*b == '\\' && b[1] == '0') { + if (*b == '\\' && b[1] == '0') { *b = '\0'; - for(c = b+1; *c != '\0'; c++) { + for (c = b+1; *c != '\0'; c++) { *c = c[1]; } b++; @@ -1022,7 +1022,7 @@ cmd_http_txresp(CMD_ARGS) VSB_clear(hp->vsb); - for(; *av != NULL; av++) { + for (; *av != NULL; av++) { if (!strcmp(*av, "-proto")) { proto = av[1]; av++; @@ -1109,7 +1109,7 @@ cmd_http_rxreq(CMD_ARGS) AZ(strcmp(av[0], "rxreq")); av++; - for(; *av != NULL; av++) + for (; *av != NULL; av++) vtc_fatal(vl, "Unknown http rxreq spec: %s\n", *av); http_rxhdr(hp); http_splitheader(hp, 1); @@ -1136,7 +1136,7 @@ cmd_http_rxreqhdrs(CMD_ARGS) AZ(strcmp(av[0], "rxreqhdrs")); av++; - for(; *av != NULL; av++) + for (; *av != NULL; av++) vtc_fatal(hp->vl, "Unknown http rxreq spec: %s\n", *av); http_rxhdr(hp); http_splitheader(hp, 1); @@ -1162,7 +1162,7 @@ cmd_http_rxreqbody(CMD_ARGS) AZ(strcmp(av[0], "rxreqbody")); av++; - for(; *av != NULL; av++) + for (; *av != NULL; av++) vtc_fatal(hp->vl, "Unknown http rxreq spec: %s\n", *av); http_swallow_body(hp, hp->req, 0); vtc_log(hp->vl, 4, "bodylen = %s", hp->bodylen); @@ -1186,7 +1186,7 @@ cmd_http_rxrespbody(CMD_ARGS) AZ(strcmp(av[0], "rxrespbody")); av++; - for(; *av != NULL; av++) + for (; *av != NULL; av++) vtc_fatal(hp->vl, "Unknown http rxrespbody spec: %s\n", *av); http_swallow_body(hp, hp->resp, 0); vtc_log(hp->vl, 4, "bodylen = %s", hp->bodylen); @@ -1240,7 +1240,7 @@ cmd_http_txreq(CMD_ARGS) VSB_clear(hp->vsb); - for(; *av != NULL; av++) { + for (; *av != NULL; av++) { if (!strcmp(*av, "-url")) { url = av[1]; av++; @@ -1740,7 +1740,7 @@ cmd_http_settings(CMD_ARGS) CAST_OBJ_NOTNULL(hp, priv, HTTP_MAGIC); - for(; *av != NULL; av++) { + for (; *av != NULL; av++) { if (!strcmp(*av, "-dectbl")) { n = strtoul(av[1], &p, 0); if (*p != '\0') @@ -1946,7 +1946,7 @@ xxx(void) memset(&vz, 0, sizeof vz); - for(n = 0; n < 999999999; n++) { + for (n = 0; n < 999999999; n++) { *ibuf = 0; for (j = 0; j < 7; j++) { snprintf(strchr(ibuf, 0), 5, "%x", diff --git a/bin/varnishtest/vtc_http2.c b/bin/varnishtest/vtc_http2.c index 745490c..15fe757 100644 --- a/bin/varnishtest/vtc_http2.c +++ b/bin/varnishtest/vtc_http2.c @@ -1775,7 +1775,7 @@ cmd_txprio(CMD_ARGS) s->weight = weight & 0xff; s->dependency = stid; - if(exclusive) + if (exclusive) exclusive_stream_dependency(s); vbe32enc(buf, (stid | exclusive)); diff --git a/bin/varnishtest/vtc_main.c b/bin/varnishtest/vtc_main.c index f4ed03e..f8057f5 100644 --- a/bin/varnishtest/vtc_main.c +++ b/bin/varnishtest/vtc_main.c @@ -666,7 +666,7 @@ main(int argc, char * const *argv) vb = vev_new_base(); i = 0; - while(!VTAILQ_EMPTY(&tst_head) || i) { + while (!VTAILQ_EMPTY(&tst_head) || i) { if (!VTAILQ_EMPTY(&tst_head) && njob < npar) { start_test(); njob++; diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c index 7c5a7a0..544a63c 100644 --- a/bin/varnishtest/vtc_varnish.c +++ b/bin/varnishtest/vtc_varnish.c @@ -227,7 +227,7 @@ varnishlog_thread(void *priv) opt = VSL_COPT_TAIL; - while(1) { + while (1) { i = VSL_Next(c); if (i != 1) break; @@ -815,7 +815,7 @@ do_stat_dump_cb(void *priv, const struct VSC_point * const pt) dp = priv; v = dp->v; - if(strcmp(pt->desc->ctype, "uint64_t")) + if (strcmp(pt->desc->ctype, "uint64_t")) return (0); u = *(const volatile uint64_t*)pt->ptr; diff --git a/include/vapi/vsm.h b/include/vapi/vsm.h index 4aebe1f..18d809b 100644 --- a/include/vapi/vsm.h +++ b/include/vapi/vsm.h @@ -160,7 +160,7 @@ void VSM__iter0(const struct VSM_data *vd, struct VSM_fantom *vf); int VSM__itern(const struct VSM_data *vd, struct VSM_fantom *vf); #define VSM_FOREACH(vf, vd) \ - for(VSM__iter0((vd), (vf)); VSM__itern((vd), (vf));) + for (VSM__iter0((vd), (vf)); VSM__itern((vd), (vf));) /* * Iterate over all chunks in shared memory * vf = "struct VSM_fantom *" diff --git a/include/vtree.h b/include/vtree.h index b88d9d2..777f234 100644 --- a/include/vtree.h +++ b/include/vtree.h @@ -170,7 +170,7 @@ name##_VSPLAY_INSERT(struct name *head, struct type *elm) \ int __comp; \ name##_VSPLAY(head, elm); \ __comp = (cmp)(elm, (head)->sph_root); \ - if(__comp < 0) { \ + if (__comp < 0) { \ VSPLAY_LEFT(elm, field) = VSPLAY_LEFT((head)->sph_root, field);\ VSPLAY_RIGHT(elm, field) = (head)->sph_root; \ VSPLAY_LEFT((head)->sph_root, field) = NULL; \ diff --git a/lib/libvarnish/vcli_proto.c b/lib/libvarnish/vcli_proto.c index ee36362..8027fa6 100644 --- a/lib/libvarnish/vcli_proto.c +++ b/lib/libvarnish/vcli_proto.c @@ -64,7 +64,7 @@ VCLI_AuthResponse(int S_fd, const char *challenge, SHA256_Update(&ctx, challenge, 32); SHA256_Update(&ctx, "\n", 1); SHA256_Final(buf, &ctx); - for(i = 0; i < SHA256_LEN; i++) + for (i = 0; i < SHA256_LEN; i++) assert(snprintf(response + 2 * i, 3, "%02x", buf[i]) == 2); } @@ -189,7 +189,7 @@ VCLI_ReadResult(int fd, unsigned *status, char **ptr, double tmo) else *ptr = p; return (0); - } while(0); + } while (0); free(p); *status = CLIS_COMMS; diff --git a/lib/libvarnish/vev.c b/lib/libvarnish/vev.c index e124ba3..e4ad629 100644 --- a/lib/libvarnish/vev.c +++ b/lib/libvarnish/vev.c @@ -431,7 +431,7 @@ vev_schedule_one(struct vev_base *evb) } k = 0; - for(j = 1; j < evb->lpfd; j++) { + for (j = 1; j < evb->lpfd; j++) { evb->pev[j]->fd_events = evb->pfd[j].revents; if (evb->pev[j]->fd_events) k++; @@ -440,7 +440,7 @@ vev_schedule_one(struct vev_base *evb) DBG(evb, "EVENTS %d\n", i); while (i > 0) { - for(j = BINHEAP_NOIDX + 1; j < evb->lpfd; j++) { + for (j = BINHEAP_NOIDX + 1; j < evb->lpfd; j++) { e = evb->pev[j]; if (e->fd_events == 0) continue; diff --git a/lib/libvarnish/vtim.c b/lib/libvarnish/vtim.c index 1af791c..0c06f41 100644 --- a/lib/libvarnish/vtim.c +++ b/lib/libvarnish/vtim.c @@ -193,7 +193,7 @@ VTIM_format(double t, char *p) #define WEEKDAY() \ do { \ int i; \ - for(i = 0; i < 7; i++) { \ + for (i = 0; i < 7; i++) { \ if (!memcmp(p, weekday_name[i], 3)) { \ weekday = i; \ break; \ @@ -208,7 +208,7 @@ VTIM_format(double t, char *p) #define MONTH() \ do { \ int i; \ - for(i = 0; i < 12; i++) { \ + for (i = 0; i < 12; i++) { \ if (!memcmp(p, month_name[i], 3)) { \ month = i + 1; \ break; \ diff --git a/lib/libvcc/vcc_acl.c b/lib/libvcc/vcc_acl.c index 532d1bf..27614fc 100644 --- a/lib/libvcc/vcc_acl.c +++ b/lib/libvcc/vcc_acl.c @@ -198,7 +198,7 @@ vcc_acl_try_getaddrinfo(struct vcc *tl, struct acl_e *ae) } i4 = i6 = 0; - for(res = res0; res != NULL; res = res->ai_next) { + for (res = res0; res != NULL; res = res->ai_next) { switch(res->ai_family) { case PF_INET: assert(PF_INET < 256); diff --git a/lib/libvcc/vcc_action.c b/lib/libvcc/vcc_action.c index 39cabe1..924e3ed 100644 --- a/lib/libvcc/vcc_action.c +++ b/lib/libvcc/vcc_action.c @@ -385,7 +385,7 @@ vcc_ParseAction(struct vcc *tl) at = tl->t; assert(at->tok == ID); - for(atp = action_table; atp->name != NULL; atp++) { + for (atp = action_table; atp->name != NULL; atp++) { if (vcc_IdIs(at, atp->name)) { if (atp->bitmask != 0) vcc_AddUses(tl, at, atp->bitmask, diff --git a/lib/libvcc/vcc_storage.c b/lib/libvcc/vcc_storage.c index ba2f33f..442f02e 100644 --- a/lib/libvcc/vcc_storage.c +++ b/lib/libvcc/vcc_storage.c @@ -93,7 +93,7 @@ vcc_stevedore(struct vcc *vcc, const char *stv_name) sym->rname = TlDup(vcc, buf); sym->r_methods = ~0; - for(sv = stvars; sv->name != NULL; sv++) { + for (sv = stvars; sv->name != NULL; sv++) { bprintf(buf, "storage.%s.%s", stv_name, sv->name); sym = VCC_Symbol(vcc, NULL, buf, NULL, SYM_VAR, 1); AN(sym); diff --git a/lib/libvmod_debug/vmod_debug_obj.c b/lib/libvmod_debug/vmod_debug_obj.c index f503943..ea758ed 100644 --- a/lib/libvmod_debug/vmod_debug_obj.c +++ b/lib/libvmod_debug/vmod_debug_obj.c @@ -125,27 +125,27 @@ VCL_VOID __match_proto__() vmod_obj_test_priv_call(VRT_CTX, struct vmod_debug_obj *o, struct vmod_priv *priv) { - (void) o; + (void)o; vmod_test_priv_call(ctx, priv); } VCL_VOID __match_proto__() vmod_obj_test_priv_vcl(VRT_CTX, struct vmod_debug_obj *o, struct vmod_priv *priv) { - (void) o; + (void)o; vmod_test_priv_vcl(ctx, priv); } VCL_STRING __match_proto__() vmod_obj_test_priv_task(VRT_CTX, struct vmod_debug_obj *o, struct vmod_priv *priv, VCL_STRING s) { - (void) o; + (void)o; return (vmod_test_priv_task(ctx, priv, s)); } VCL_STRING __match_proto__() vmod_obj_test_priv_top(VRT_CTX, struct vmod_debug_obj *o, struct vmod_priv *priv, VCL_STRING s) { - (void) o; + (void)o; return (vmod_test_priv_top(ctx, priv, s)); } diff --git a/lib/libvmod_directors/shard_cfg.c b/lib/libvmod_directors/shard_cfg.c index 7114cae..7db0f88 100644 --- a/lib/libvmod_directors/shard_cfg.c +++ b/lib/libvmod_directors/shard_cfg.c @@ -353,7 +353,7 @@ shardcfg_backend_lookup(const struct backend_reconfig *re, const struct shard_backend *bb = re->shardd->backend; for (i = 0; i < max; i++) - if (! shardcfg_backend_cmp(b, &bb[i])) + if (!shardcfg_backend_cmp(b, &bb[i])) return &bb[i]; return NULL; @@ -400,7 +400,7 @@ shardcfg_backend_add(struct backend_reconfig *re, i = re->shardd->n_backend; } else { do { - if (! bb[re->hole_i].backend) + if (!bb[re->hole_i].backend) break; } while (++(re->hole_i) < re->shardd->n_backend + re->hole_n); assert(re->hole_i < re->shardd->n_backend + re->hole_n); @@ -464,7 +464,7 @@ shardcfg_backend_finalize(struct backend_reconfig *re) assert(re->hole_i < i); do { - if (! bb[re->hole_i].backend) + if (!bb[re->hole_i].backend) break; } while (++(re->hole_i) <= i); diff --git a/lib/libvmod_directors/shard_dir.c b/lib/libvmod_directors/shard_dir.c index f801798..3388dd2 100644 --- a/lib/libvmod_directors/shard_dir.c +++ b/lib/libvmod_directors/shard_dir.c @@ -139,7 +139,7 @@ shard_next(struct shard_state *state, VCL_INT skip, VCL_BOOL healthy) c = state->shardd->hashcircle[state->idx].host; - if (! vbit_test(state->picklist, c)) { + if (!vbit_test(state->picklist, c)) { vbit_set(state->picklist, c); state->pickcount++; @@ -303,7 +303,7 @@ sharddir_pick_be(VRT_CTX, struct sharddir *shardd, init_state(&state, ctx, shardd, vbit_init(picklist_spc, picklist_sz)); sharddir_rdlock(shardd); - if(shardd->n_backend == 0) { + if (shardd->n_backend == 0) { shard_err0(ctx, shardd, "no backends"); goto err; } @@ -369,7 +369,7 @@ sharddir_pick_be(VRT_CTX, struct sharddir *shardd, * - no change if alternative host is also in rampup or the dice * has rolled in favour of the chosen host */ - if (! rampup || + if (!rampup || ctx->now - state.last.changed < alt_r || VRND_RandomTestableDouble() * chosen_r < (ctx->now - state.previous.changed)) diff --git a/lib/libvmod_directors/shard_hash.c b/lib/libvmod_directors/shard_hash.c index 27dd7b4..365f86b 100644 --- a/lib/libvmod_directors/shard_hash.c +++ b/lib/libvmod_directors/shard_hash.c @@ -96,7 +96,7 @@ shard_hash_rs(VCL_STRING s) static uint32_t __match_proto__(hash_func) _shard_hash_invalid(VCL_STRING s) { - (void) s; + (void)s; WRONG("invalid hash fp _ALG_E_ENVALID"); NEEDLESS(return(0)); } diff --git a/lib/libvmod_directors/vmod_shard.c b/lib/libvmod_directors/vmod_shard.c index 25ad12d..8765ef9 100644 --- a/lib/libvmod_directors/vmod_shard.c +++ b/lib/libvmod_directors/vmod_shard.c @@ -62,7 +62,7 @@ vmod_shard__init(VRT_CTX, struct vmod_directors_shard **vshardp, t2b = (uint32_t)t1; assert(t2a == t2b); - (void) ctx; + (void)ctx; AN(vshardp); AZ(*vshardp); ALLOC_OBJ(vshard, VMOD_SHARD_SHARD_MAGIC); @@ -95,8 +95,8 @@ VCL_INT __match_proto__(td_directors_shard_key) enum alg_e alg = parse_alg_e(alg_s); hash_func hash_fp = shard_hash_f[alg]; - (void) ctx; - (void) vshard;; + (void)ctx; + (void)vshard;; return (VCL_INT)hash_fp(s ? s : ""); } @@ -118,7 +118,7 @@ VCL_VOID __match_proto__(td_directors_set_rampup) vmod_shard_set_rampup(VRT_CTX, struct vmod_directors_shard *vshard, VCL_DURATION duration) { - (void) ctx; + (void)ctx; CHECK_OBJ_NOTNULL(vshard, VMOD_SHARD_SHARD_MAGIC); shardcfg_set_rampup(vshard->shardd, duration); } @@ -270,6 +270,6 @@ vmod_shard_debug(VRT_CTX, struct vmod_directors_shard *vshard, { CHECK_OBJ_NOTNULL(vshard, VMOD_SHARD_SHARD_MAGIC); - (void) ctx; + (void)ctx; sharddir_debug(vshard->shardd, i & UINT32_MAX); } diff --git a/lib/libvmod_std/vmod_std_conversions.c b/lib/libvmod_std/vmod_std_conversions.c index bd746bd..7fb736c 100644 --- a/lib/libvmod_std/vmod_std_conversions.c +++ b/lib/libvmod_std/vmod_std_conversions.c @@ -53,7 +53,7 @@ vmod_duration(VRT_CTX, VCL_STRING p, VCL_DURATION d) if (p == NULL) return (d); - while(isspace(*p)) + while (isspace(*p)) p++; if (*p != '+' && *p != '-' && !isdigit(*p)) @@ -66,7 +66,7 @@ vmod_duration(VRT_CTX, VCL_STRING p, VCL_DURATION d) if (isnan(r) || e == NULL) return (d); - while(isspace(*e)) + while (isspace(*e)) e++; /* NB: Keep this list synchronized with VCC */ @@ -87,7 +87,7 @@ vmod_duration(VRT_CTX, VCL_STRING p, VCL_DURATION d) return (d); } - while(isspace(*e)) + while (isspace(*e)) e++; if (*e != '\0') diff --git a/lib/libvmod_std/vmod_std_querysort.c b/lib/libvmod_std/vmod_std_querysort.c index 2fae3a1..1d7f5af 100644 --- a/lib/libvmod_std/vmod_std_querysort.c +++ b/lib/libvmod_std/vmod_std_querysort.c @@ -43,7 +43,7 @@ compa(const void *a, const void *b) const char * const *pb = b; const char *a1, *b1; - for(a1 = pa[0], b1 = pb[0]; a1 < pa[1] && b1 < pb[1]; a1++, b1++) + for (a1 = pa[0], b1 = pb[0]; a1 < pa[1] && b1 < pb[1]; a1++, b1++) if (*a1 != *b1) return (*a1 - *b1); return (0); @@ -100,7 +100,7 @@ vmod_querysort(VRT_CTX, VCL_STRING url) } pp[np++] = cq; /* Skip trivially empty params */ - while(cq[1] == '&') + while (cq[1] == '&') cq++; pp[np++] = cq + 1; } From fgsch at lodoss.net Sun Feb 26 18:56:05 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sun, 26 Feb 2017 19:56:05 +0100 Subject: [master] bfaa16e Simplify Message-ID: commit bfaa16e862af4fc3231447ec5bdba553458f3171 Author: Federico G. Schwindt Date: Sun Feb 26 18:53:24 2017 +0000 Simplify NB: this was not lost during polishing, it was simply redundant. diff --git a/bin/varnishtest/tests/t02005.vtc b/bin/varnishtest/tests/t02005.vtc index e13c0e7..55647ff 100644 --- a/bin/varnishtest/tests/t02005.vtc +++ b/bin/varnishtest/tests/t02005.vtc @@ -17,8 +17,7 @@ client c1 { expect resp.http.content-Type == "text/plain" # Then, payload checks - write_body resp.txt - shell {grep -q response resp.txt} + expect resp.body == response } -run } -run diff --git a/bin/varnishtest/tests/v00020.vtc b/bin/varnishtest/tests/v00020.vtc index faf25f0..5f734fc 100644 --- a/bin/varnishtest/tests/v00020.vtc +++ b/bin/varnishtest/tests/v00020.vtc @@ -83,7 +83,6 @@ varnish v1 -vcl { set req.http.foo = 1 - 1; set req.http.foo = 1 + -1; set req.http.foo = 1 - -1; - set req.http.foo = 1- -1; # regression test for #2184 set req.http.foo = 3 * 2; set req.http.foo = 3 / 2; set req.http.foo = 3 * -2; From fgsch at lodoss.net Sun Feb 26 19:18:04 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sun, 26 Feb 2017 20:18:04 +0100 Subject: [master] 8f22397 Correct check when parsing the query string. Message-ID: commit 8f22397129b114e6d0d0513685be9908a565f71f Author: Federico G. Schwindt Date: Sun Feb 26 19:16:22 2017 +0000 Correct check when parsing the query string. Fixes #2233. diff --git a/bin/varnishtest/tests/r02233.vtc b/bin/varnishtest/tests/r02233.vtc new file mode 100644 index 0000000..1f9b8e2 --- /dev/null +++ b/bin/varnishtest/tests/r02233.vtc @@ -0,0 +1,24 @@ +varnishtest "Fail earlier if we cannot fit the query string" + +server s1 { + rxreq + txresp +} -start + +varnish v1 -arg "-p workspace_client=9k" -vcl+backend { + import std; + + sub vcl_recv { + set req.url = std.querysort(req.url); + } +} -start + +client c1 { + send "GET /?a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1" + send "&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1" + send "&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1" + send " HTTP/1.1\r\n" + send "Host: foo\r\n\r\n" + rxresp + expect resp.status == 500 +} -run diff --git a/lib/libvmod_std/vmod_std_querysort.c b/lib/libvmod_std/vmod_std_querysort.c index 1d7f5af..2180ff9 100644 --- a/lib/libvmod_std/vmod_std_querysort.c +++ b/lib/libvmod_std/vmod_std_querysort.c @@ -93,7 +93,7 @@ vmod_querysort(VRT_CTX, VCL_STRING url) pp[np++] = 1 + cu; for (cq = 1 + cu; *cq != '\0'; cq++) { if (*cq == '&') { - if (pp + 3 > pe) { + if (pp + np + 3 > pe) { WS_Release(ctx->ws, 0); WS_MarkOverflow(ctx->ws); return (url); From fgsch at lodoss.net Sun Feb 26 19:44:04 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sun, 26 Feb 2017 20:44:04 +0100 Subject: [master] 2285711 Accommodate for 32 bits archs Message-ID: commit 228571195ee42c81edc6db89dbf3cedbe3e1f320 Author: Federico G. Schwindt Date: Sun Feb 26 19:41:35 2017 +0000 Accommodate for 32 bits archs diff --git a/bin/varnishtest/tests/r02233.vtc b/bin/varnishtest/tests/r02233.vtc index 1f9b8e2..a17a701 100644 --- a/bin/varnishtest/tests/r02233.vtc +++ b/bin/varnishtest/tests/r02233.vtc @@ -17,6 +17,16 @@ client c1 { send "GET /?a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1" send "&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1" send "&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1" + send "&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1" + send "&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1" + send "&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1" + send "&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1" + send "&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1" + send "&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1" + send "&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1" + send "&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1" + send "&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1" + send "&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1" send " HTTP/1.1\r\n" send "Host: foo\r\n\r\n" rxresp From phk at FreeBSD.org Sun Feb 26 21:23:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Sun, 26 Feb 2017 22:23:05 +0100 Subject: [master] 1910640 Encapsulate Expect: and Connection: processing in a transport agnostic function. Message-ID: commit 1910640d368caabf00d5577b4443bf15be50b8db Author: Poul-Henning Kamp Date: Sun Feb 26 21:01:14 2017 +0000 Encapsulate Expect: and Connection: processing in a transport agnostic function. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index e440578..c1c2f97 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -940,6 +940,7 @@ void VRB_Free(struct req *); /* cache_req_fsm.c [CNT] */ enum req_fsm_nxt CNT_Request(struct worker *, struct req *); void CNT_AcctLogCharge(struct dstat *, struct req *); +int CNT_GotReq(struct worker *, struct req *); /* cache_session.c [SES] */ struct sess *SES_New(struct pool *); diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c index d1396bf..6642ea9 100644 --- a/bin/varnishd/cache/cache_http.c +++ b/bin/varnishd/cache/cache_http.c @@ -664,13 +664,12 @@ http_DoConnection(struct http *hp) retval = SC_NULL; /* Refuse removal of well-known-headers if they would pass. */ -/*lint -save -e506 */ +/*lint -save -e506 [constant value boolean] */ #define HTTPH(a, x, c) \ if (!((c) & HTTPH_R_PASS) && \ strlen(a) == u && !strncasecmp(a, b, u)) \ return (SC_RX_BAD); #include "tbl/http_headers.h" - /*lint -restore */ v = http_findhdr(hp, u, b); diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 459ef6f..d22dad3 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -50,6 +50,51 @@ #include "vtim.h" /*-------------------------------------------------------------------- + * Handle "Expect:" and "Connection:" on incoming request + */ + +int +CNT_GotReq(struct worker *wrk, struct req *req) +{ + const char *p; + + CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); + CHECK_OBJ_NOTNULL(req, REQ_MAGIC); + CHECK_OBJ_NOTNULL(req->http, HTTP_MAGIC); + CHECK_OBJ_NOTNULL(req->transport, TRANSPORT_MAGIC); + AN(req->transport->minimal_response); + + if (http_GetHdr(req->http, H_Expect, &p)) { + if (strcasecmp(p, "100-continue")) { + req->doclose = SC_RX_JUNK; + (void)req->transport->minimal_response(req, 417); + wrk->stats->client_req_417++; + return (-1); + } + if (req->http->protover >= 11 && req->htc->pipeline_b == NULL) + req->want100cont = 1; + http_Unset(req->http, H_Expect); + } + + wrk->stats->client_req++; + wrk->stats->s_req++; + + AZ(req->err_code); + req->ws_req = WS_Snapshot(req->ws); + + req->doclose = http_DoConnection(req->http); + if (req->doclose == SC_RX_BAD) { + (void)req->transport->minimal_response(req, 400); + return (-1); + } + + assert(req->req_body_status != REQ_BODY_INIT); + + HTTP_Copy(req->http0, req->http); // For ESI & restart + return (0); +} + +/*-------------------------------------------------------------------- * Deliver an object to client */ @@ -766,8 +811,10 @@ cnt_recv(struct worker *wrk, struct req *req) if (req->want100cont && !req->late100cont) { req->want100cont = 0; - if (req->transport->minimal_response(req, 100)) - return (-1); + if (req->transport->minimal_response(req, 100)) { + req->doclose = SC_REM_CLOSE; + return (REQ_FSM_DONE); + } } /* Attempts to cache req.body may fail */ diff --git a/bin/varnishd/http1/cache_http1_fsm.c b/bin/varnishd/http1/cache_http1_fsm.c index a197cc5..7fe90ef 100644 --- a/bin/varnishd/http1/cache_http1_fsm.c +++ b/bin/varnishd/http1/cache_http1_fsm.c @@ -255,7 +255,7 @@ struct transport HTTP1_transport = { */ static inline void -http1_abort(struct req *req, unsigned status) +http1_abort(struct req *req, uint16_t status) { AN(req->doclose); assert(status >= 400); @@ -265,7 +265,6 @@ http1_abort(struct req *req, unsigned status) static int http1_dissect(struct worker *wrk, struct req *req) { - const char *p; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(req, REQ_MAGIC); @@ -320,35 +319,7 @@ http1_dissect(struct worker *wrk, struct req *req) WRONG("Unknown req_body_status situation"); } - if (http_GetHdr(req->http, H_Expect, &p)) { - if (strcasecmp(p, "100-continue")) { - req->doclose = SC_RX_JUNK; - http1_abort(req, 417); - wrk->stats->client_req_417++; - return (-1); - } - if (req->http->protover >= 11 && req->htc->pipeline_b == NULL) - req->want100cont = 1; - http_Unset(req->http, H_Expect); - } - - wrk->stats->client_req++; - wrk->stats->s_req++; - - AZ(req->err_code); - req->ws_req = WS_Snapshot(req->ws); - - req->doclose = http_DoConnection(req->http); - if (req->doclose == SC_RX_BAD) { - http1_abort(req, 400); - return (-1); - } - - assert(req->req_body_status != REQ_BODY_INIT); - - HTTP_Copy(req->http0, req->http); // For ESI & restart - - return (0); + return (CNT_GotReq(wrk, req)); } /*---------------------------------------------------------------------- From phk at FreeBSD.org Sun Feb 26 21:23:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Sun, 26 Feb 2017 22:23:05 +0100 Subject: [master] 876d42b Make sure the req always has a transport Message-ID: commit 876d42b99619a75b1356af87b795ea16a9a0f871 Author: Poul-Henning Kamp Date: Sun Feb 26 21:17:06 2017 +0000 Make sure the req always has a transport diff --git a/bin/varnishd/cache/cache_req.c b/bin/varnishd/cache/cache_req.c index 0a73e33..d0b4c3a 100644 --- a/bin/varnishd/cache/cache_req.c +++ b/bin/varnishd/cache/cache_req.c @@ -175,7 +175,6 @@ Req_Cleanup(struct sess *sp, struct worker *wrk, struct req *req) } req->req_bodybytes = 0; - if (!isnan(req->t_prev) && req->t_prev > 0.) sp->t_idle = req->t_prev; else diff --git a/bin/varnishd/http1/cache_http1_fsm.c b/bin/varnishd/http1/cache_http1_fsm.c index 7fe90ef..d386840 100644 --- a/bin/varnishd/http1/cache_http1_fsm.c +++ b/bin/varnishd/http1/cache_http1_fsm.c @@ -268,6 +268,7 @@ http1_dissect(struct worker *wrk, struct req *req) CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(req, REQ_MAGIC); + CHECK_OBJ_NOTNULL(req->transport, TRANSPORT_MAGIC); /* Allocate a new vxid now that we know we'll need it. */ AZ(req->vsl->wid); @@ -353,9 +354,12 @@ HTTP1_Session(struct worker *wrk, struct req *req) return; } + req->transport = &HTTP1_transport; + while (1) { st = http1_getstate(sp); if (st == H1NEWREQ) { + CHECK_OBJ_NOTNULL(req->transport, TRANSPORT_MAGIC); assert(isnan(req->t_prev)); assert(isnan(req->t_req)); AZ(req->vcl); @@ -441,6 +445,7 @@ HTTP1_Session(struct worker *wrk, struct req *req) req->req_step = R_STP_RECV; http1_setstate(sp, H1PROC); } else if (st == H1BUSY) { + CHECK_OBJ_NOTNULL(req->transport, TRANSPORT_MAGIC); /* * Return from waitinglist. * Check to see if the remote has left. @@ -456,12 +461,10 @@ HTTP1_Session(struct worker *wrk, struct req *req) } http1_setstate(sp, H1PROC); } else if (st == H1PROC) { - req->transport = &HTTP1_transport; req->task.func = http1_req; req->task.priv = req; if (CNT_Request(wrk, req) == REQ_FSM_DISEMBARK) return; - req->transport = NULL; req->task.func = NULL; req->task.priv = NULL; http1_setstate(sp, H1CLEANUP); From phk at FreeBSD.org Sun Feb 26 22:20:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Sun, 26 Feb 2017 23:20:05 +0100 Subject: [master] 7910232 Reset the headers when we get a HEADERS frame Message-ID: commit 791023296fcce9c5ca50b0f9e6e70a2b2ec5ad49 Author: Poul-Henning Kamp Date: Sun Feb 26 22:17:40 2017 +0000 Reset the headers when we get a HEADERS frame diff --git a/bin/varnishtest/vtc_http2.c b/bin/varnishtest/vtc_http2.c index 15fe757..6b8f7d7 100644 --- a/bin/varnishtest/vtc_http2.c +++ b/bin/varnishtest/vtc_http2.c @@ -787,6 +787,7 @@ receive_frame(void *priv) else hdrs = s->resp; } + hdrs[0].t = 0; AZ(vsb); vsb = VSB_new_auto(); /*FALLTHROUGH*/ From phk at FreeBSD.org Sun Feb 26 22:20:06 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Sun, 26 Feb 2017 23:20:06 +0100 Subject: [master] bdd84ff Make 100-continuation work in H2 Message-ID: commit bdd84ffc5300c25ca8c13b3aefa71e05cad99d26 Author: Poul-Henning Kamp Date: Sun Feb 26 22:18:54 2017 +0000 Make 100-continuation work in H2 diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index d22dad3..54df7c4 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -62,16 +62,18 @@ CNT_GotReq(struct worker *wrk, struct req *req) CHECK_OBJ_NOTNULL(req, REQ_MAGIC); CHECK_OBJ_NOTNULL(req->http, HTTP_MAGIC); CHECK_OBJ_NOTNULL(req->transport, TRANSPORT_MAGIC); + assert(req->req_body_status != REQ_BODY_INIT); AN(req->transport->minimal_response); if (http_GetHdr(req->http, H_Expect, &p)) { - if (strcasecmp(p, "100-continue")) { + if (strcasecmp(p, "100-continue") || + req->http->protover < 11) { req->doclose = SC_RX_JUNK; (void)req->transport->minimal_response(req, 417); wrk->stats->client_req_417++; return (-1); } - if (req->http->protover >= 11 && req->htc->pipeline_b == NULL) + if (req->htc->pipeline_b == NULL) // XXX: HTTP1 vs 2 ? req->want100cont = 1; http_Unset(req->http, H_Expect); } @@ -88,8 +90,6 @@ CNT_GotReq(struct worker *wrk, struct req *req) return (-1); } - assert(req->req_body_status != REQ_BODY_INIT); - HTTP_Copy(req->http0, req->http); // For ESI & restart return (0); } diff --git a/bin/varnishd/http2/cache_http2_deliver.c b/bin/varnishd/http2/cache_http2_deliver.c index dfe2aed..27ce4b3 100644 --- a/bin/varnishd/http2/cache_http2_deliver.c +++ b/bin/varnishd/http2/cache_http2_deliver.c @@ -142,7 +142,9 @@ h2_minimal_response(struct req *req, uint16_t status) /* XXX return code checking once H2_Send returns anything but 0 */ H2_Send(req->wrk, r2, 1, - H2_FRAME_HEADERS, H2FF_HEADERS_END_HEADERS, + H2_FRAME_HEADERS, + H2FF_HEADERS_END_HEADERS | + (status < 200 ? 0 : H2FF_HEADERS_END_STREAM), l, buf); return (0); } diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index 0c5a5e9..c2ab7f1 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -401,7 +401,8 @@ h2_do_req(struct worker *wrk, void *priv) CAST_OBJ_NOTNULL(req, priv, REQ_MAGIC); CAST_OBJ_NOTNULL(r2, req->transport_priv, H2_REQ_MAGIC); THR_SetRequest(req); - assert(CNT_Request(wrk, req) != REQ_FSM_DISEMBARK); + if (!CNT_GotReq(wrk, req)) + assert(CNT_Request(wrk, req) != REQ_FSM_DISEMBARK); THR_SetRequest(NULL); VSL(SLT_Debug, 0, "H2REQ CNT done"); /* XXX clean up req */ @@ -470,15 +471,12 @@ h2_rx_headers(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) } VSLb_ts_req(req, "Req", req->t_req); http_SetH(req->http, HTTP_HDR_PROTO, "HTTP/2.0"); + req->http->protover = 20; if (h2->rxf_flags & H2FF_HEADERS_END_STREAM) req->req_body_status = REQ_BODY_NONE; else req->req_body_status = REQ_BODY_WITHOUT_LEN; - wrk->stats->client_req++; - wrk->stats->s_req++; - req->ws_req = WS_Snapshot(req->ws); - HTTP_Copy(req->http0, req->http); req->task.func = h2_do_req; req->task.priv = req; diff --git a/bin/varnishtest/tests/t02006.vtc b/bin/varnishtest/tests/t02006.vtc new file mode 100644 index 0000000..d8354b9 --- /dev/null +++ b/bin/varnishtest/tests/t02006.vtc @@ -0,0 +1,27 @@ +varnishtest "H2 POST w/ 100 Continue" + +server s1 { + rxreq + txresp -hdr "Content-Type: text/plain" -body response +} -start + +varnish v1 -vcl+backend {} -cliok "param.set feature +http2" -start +varnish v1 -cliok "param.set debug +syncvsl" + +client c1 { + stream 1 { + txreq -req POST -hdr expect 100-continue -hdr content-type text/plain -hdr content-length 7 -body request + + rxhdrs + expect resp.status == 100 + + rxresp + expect resp.status == 200 + expect resp.http.content-Type == "text/plain" + + # Then, payload checks + write_body resp.txt + shell {grep -q response resp.txt} + } -run +} -run + From daghf at varnish-software.com Mon Feb 27 09:27:05 2017 From: daghf at varnish-software.com (Dag Haavi Finstad) Date: Mon, 27 Feb 2017 10:27:05 +0100 Subject: [master] dcdb250 Add a setenv command to varnishtest Message-ID: commit dcdb2504e5c0607022328ef21eaebebe89c33e41 Author: Dag Haavi Finstad Date: Fri Feb 17 16:34:13 2017 +0100 Add a setenv command to varnishtest This lets you set or change environment variables in a test case. Usage is setenv FOO "bar baz" The above will set the environment variable $FOO to the value provided. There is also an ``-ifunset`` argument which will only set the value if the the environment variable does not already exist: setenv -ifunset FOO quux The ifunset argument corresponds to passing zero as the third argument to setenv(3). diff --git a/bin/varnishtest/tests/m00028.vtc b/bin/varnishtest/tests/m00028.vtc new file mode 100644 index 0000000..8d6c1a0 --- /dev/null +++ b/bin/varnishtest/tests/m00028.vtc @@ -0,0 +1,73 @@ +varnishtest "Test setenv" + +setenv FOO "BAR BAZ" + +varnish v1 -vcl { + import std from "${topbuild}/lib/libvmod_std/.libs/"; + + backend dummy { .host = "${bad_ip}"; .port = "9080"; } + + sub vcl_recv { + return(synth(200)); + } + + sub vcl_synth { + set resp.http.X-FOO = std.getenv("FOO"); + } +} -start + +client c1 { + txreq + rxresp + expect resp.http.X-FOO == "BAR BAZ" +} -run + +varnish v1 -stop + +setenv -ifunset FOO QUUX + +varnish v2 -vcl { + import std from "${topbuild}/lib/libvmod_std/.libs/"; + + backend dummy { .host = "${bad_ip}"; .port = "9080"; } + + sub vcl_recv { + return(synth(200)); + } + + sub vcl_synth { + set resp.http.X-FOO = std.getenv("FOO"); + } +} -start + +client c2 -connect ${v2_sock} { + txreq + rxresp + expect resp.http.X-FOO == "BAR BAZ" +} -run + +varnish v2 -stop + +setenv FOO QUUX + +varnish v3 -vcl { + import std from "${topbuild}/lib/libvmod_std/.libs/"; + + backend dummy { .host = "${bad_ip}"; .port = "9080"; } + + sub vcl_recv { + return(synth(200)); + } + + sub vcl_synth { + set resp.http.X-FOO = std.getenv("FOO"); + } +} -start + +client c3 -connect ${v3_sock} { + txreq + rxresp + expect resp.http.X-FOO == "QUUX" +} -run + +varnish v2 -stop diff --git a/bin/varnishtest/vtc.c b/bin/varnishtest/vtc.c index 7ec5caf..cf5e051 100644 --- a/bin/varnishtest/vtc.c +++ b/bin/varnishtest/vtc.c @@ -594,6 +594,47 @@ cmd_err_shell(CMD_ARGS) cmd_shell_engine(vl, -1, av[2], av[1], NULL); } +/* SECTION: setenv setenv + * + * Set or change an environment variable:: + * + * setenv FOO "bar baz" + * + * The above will set the environment variable $FOO to the value + * provided. There is also an ``-ifunset`` argument which will only + * set the value if the the environment variable does not already + * exist:: + * + * setenv -ifunset FOO quux + */ +static void +cmd_setenv(CMD_ARGS) +{ + int r; + int force; + + (void)priv; + (void)cmd; + + if (av == NULL) + return; + AN(av[1]); + AN(av[2]); + + force = 1; + if (strcmp("-ifunset", av[1]) == 0) { + force = 0; + av++; + AN(av[2]); + } + if (av[3] != NULL) + vtc_log(vl, 0, "CMD setenv: Unexpected argument '%s'", av[3]); + r = setenv(av[1], av[2], force); + if (r != 0) + vtc_log(vl, 0, "CMD setenv %s=\"%s\" failed: %s", + av[1], av[2], strerror(errno)); +} + /* SECTION: delay delay * * Sleep for the number of seconds specified in the argument. The number @@ -744,6 +785,7 @@ static const struct cmds cmds[] = { CMD(feature) CMD(logexpect) CMD(process) + CMD(setenv) #undef CMD { NULL, NULL } }; From nils.goroll at uplex.de Mon Feb 27 09:30:07 2017 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 27 Feb 2017 10:30:07 +0100 Subject: [master] 341fd85 Back to Expect handling according to rfc7231 Message-ID: commit 341fd85259c26fbca6a6c1ded85f85184d8069f4 Author: Nils Goroll Date: Mon Feb 27 10:21:17 2017 +0100 Back to Expect handling according to rfc7231 Revert a regressive nit from bdd84ffc5300c25ca8c13b3aefa71e05cad99d26 which has nothing to do with H/2 https://tools.ietf.org/html/rfc7231#section-5.1.1 Requirements for servers: o A server that receives a 100-continue expectation in an HTTP/1.0 request MUST ignore that expectation. So if Expect exists but is not "100-continue", we send the 417 irrespective of the protocol version. But if is is 100-continue and the protocol is HTTP/1.0 or below, we ignore the header. diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 54df7c4..cb9a545 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -66,14 +66,14 @@ CNT_GotReq(struct worker *wrk, struct req *req) AN(req->transport->minimal_response); if (http_GetHdr(req->http, H_Expect, &p)) { - if (strcasecmp(p, "100-continue") || - req->http->protover < 11) { + if (strcasecmp(p, "100-continue")) { req->doclose = SC_RX_JUNK; (void)req->transport->minimal_response(req, 417); wrk->stats->client_req_417++; return (-1); } - if (req->htc->pipeline_b == NULL) // XXX: HTTP1 vs 2 ? + if (req->http->protover >= 11 && + req->htc->pipeline_b == NULL) // XXX: HTTP1 vs 2 ? req->want100cont = 1; http_Unset(req->http, H_Expect); } From phk at FreeBSD.org Mon Feb 27 09:44:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 27 Feb 2017 10:44:05 +0100 Subject: [master] bd0ce36 Silence flexelint a bit Message-ID: commit bd0ce368c04d39318dd6e2d1a189cc0ae3c5d4f1 Author: Poul-Henning Kamp Date: Sun Feb 26 22:46:28 2017 +0000 Silence flexelint a bit diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index 009c587..84c78ea 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -265,6 +265,8 @@ pan_objcore(struct vsb *vsb, const char *typ, const struct objcore *oc) PAN_CheckMagic(vsb, oc, OBJCORE_MAGIC); VSB_printf(vsb, "refcnt = %d,\n", oc->refcnt); VSB_printf(vsb, "flags = {"); + +/*lint -save -esym(438,p) -esym(838,p) -e539 */ p = ""; #define OC_FLAG(U, l, v) \ if (oc->flags & v) { VSB_printf(vsb, "%s" #l, p); p = ", "; } @@ -275,8 +277,9 @@ pan_objcore(struct vsb *vsb, const char *typ, const struct objcore *oc) #define OC_EXP_FLAG(U, l, v) \ if (oc->exp_flags & v) { VSB_printf(vsb, "%s" #l, p); p = ", "; } #include "tbl/oc_exp_flags.h" - +/*lint -restore */ VSB_printf(vsb, "},\n"); + if (oc->boc != NULL) pan_boc(vsb, oc->boc); VSB_printf(vsb, "exp = {%f, %f, %f, %f},\n", @@ -370,11 +373,11 @@ pan_busyobj(struct vsb *vsb, const struct busyobj *bo) VSB_printf(vsb, "failed = %d, ", bo->vfc->failed); VSB_printf(vsb, "flags = {"); p = ""; - /*lint -save -esym(438,p) */ +/*lint -save -esym(438,p) -e539 */ #define BO_FLAG(l, r, w, d) \ if (bo->l) { VSB_printf(vsb, "%s" #l, p); p = ", "; } #include "tbl/bo_flags.h" - /*lint -restore */ +/*lint -restore */ VSB_printf(vsb, "},\n"); if (VALID_OBJ(bo->htc, HTTP_CONN_MAGIC)) From phk at FreeBSD.org Mon Feb 27 09:44:06 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 27 Feb 2017 10:44:06 +0100 Subject: [master] 1289746 Tighten asserts related to pipelined rxbuf. Message-ID: commit 12897464bb1e97469b50d639e1ba2b107185353a Author: Poul-Henning Kamp Date: Mon Feb 27 09:03:30 2017 +0000 Tighten asserts related to pipelined rxbuf. diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c index 1c0c6d7..5bf7d81 100644 --- a/bin/varnishd/cache/cache_session.c +++ b/bin/varnishd/cache/cache_session.c @@ -192,6 +192,8 @@ HTC_RxInit(struct http_conn *htc, struct ws *ws) htc->rxbuf_b = ws->f; htc->rxbuf_e = ws->f; if (htc->pipeline_b != NULL) { + AN(htc->pipeline_e); + assert(WS_Inside(ws, htc->pipeline_b, htc->pipeline_e)); l = htc->pipeline_e - htc->pipeline_b; assert(l > 0); assert(l <= ws->r - htc->rxbuf_b); @@ -210,12 +212,12 @@ HTC_RxPipeline(struct http_conn *htc, void *p) if (p == NULL || (char*)p == htc->rxbuf_e) { htc->pipeline_b = NULL; htc->pipeline_e = NULL; - return; + } else { + assert((char*)p >= htc->rxbuf_b); + assert((char*)p < htc->rxbuf_e); + htc->pipeline_b = p; + htc->pipeline_e = htc->rxbuf_e; } - assert((char*)p >= htc->rxbuf_b); - assert((char*)p < htc->rxbuf_e); - htc->pipeline_b = p; - htc->pipeline_e = htc->rxbuf_e; } /*---------------------------------------------------------------------- From phk at FreeBSD.org Mon Feb 27 09:44:06 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 27 Feb 2017 10:44:06 +0100 Subject: [master] 9d73cd1 Make param::nuke_limit a total count of nukes allowed for each object creation. Message-ID: commit 9d73cd1a369f35be867138a81fae2f4d737c9b6c Author: Poul-Henning Kamp Date: Mon Feb 27 09:41:37 2017 +0000 Make param::nuke_limit a total count of nukes allowed for each object creation. Fixes #1764 diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index c1c2f97..c9fda21 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -321,6 +321,7 @@ struct worker { struct pool_task task; double lastused; + int strangelove; struct v1l *v1l; diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 2b701d4..1287f08 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -82,8 +82,7 @@ vbf_allocobj(struct busyobj *bo, unsigned l) oc->ttl = cache_param->shortlived; oc->grace = 0.0; oc->keep = 0.0; - return (STV_NewObject(bo->wrk, bo->fetch_objcore, - stv_transient, l)); + return (STV_NewObject(bo->wrk, bo->fetch_objcore, stv_transient, l)); } /*-------------------------------------------------------------------- diff --git a/bin/varnishd/storage/stevedore.c b/bin/varnishd/storage/stevedore.c index ba9001e..48a3c7b 100644 --- a/bin/varnishd/storage/stevedore.c +++ b/bin/varnishd/storage/stevedore.c @@ -84,8 +84,9 @@ STV_NewObject(struct worker *wrk, struct objcore *oc, CHECK_OBJ_NOTNULL(stv, STEVEDORE_MAGIC); assert(wsl > 0); + wrk->strangelove = cache_param->nuke_limit; AN(stv->allocobj); - if (stv->allocobj(wrk, stv, oc, wsl, cache_param->nuke_limit) == 0) + if (stv->allocobj(wrk, stv, oc, wsl) == 0) return (0); wrk->stats->n_object++; diff --git a/bin/varnishd/storage/storage.h b/bin/varnishd/storage/storage.h index 2b7ae53..8b78326 100644 --- a/bin/varnishd/storage/storage.h +++ b/bin/varnishd/storage/storage.h @@ -65,7 +65,7 @@ struct storage { typedef void storage_init_f(struct stevedore *, int ac, char * const *av); typedef void storage_open_f(struct stevedore *); typedef int storage_allocobj_f(struct worker *, const struct stevedore *, - struct objcore *, unsigned, int); + struct objcore *, unsigned); typedef void storage_close_f(const struct stevedore *, int pass); typedef int storage_baninfo_f(const struct stevedore *, enum baninfo event, const uint8_t *ban, unsigned len); diff --git a/bin/varnishd/storage/storage_lru.c b/bin/varnishd/storage/storage_lru.c index 2d650c7..f3588b1 100644 --- a/bin/varnishd/storage/storage_lru.c +++ b/bin/varnishd/storage/storage_lru.c @@ -171,6 +171,11 @@ LRU_NukeOne(struct worker *wrk, struct lru *lru) CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(lru, LRU_MAGIC); + if (wrk->strangelove-- <= 0) { + VSLb(wrk->vsl, SLT_ExpKill, "LRU_Exhausted"); + return (0); + } + /* Find the first currently unused object on the LRU. */ Lck_Lock(&lru->mtx); VTAILQ_FOREACH_SAFE(oc, &lru->lru_head, lru_list, oc2) { diff --git a/bin/varnishd/storage/storage_persistent.c b/bin/varnishd/storage/storage_persistent.c index ad2d2a1..9bdf536 100644 --- a/bin/varnishd/storage/storage_persistent.c +++ b/bin/varnishd/storage/storage_persistent.c @@ -505,7 +505,7 @@ smp_allocx(const struct stevedore *st, size_t min_size, size_t max_size, static int __match_proto__(storage_allocobj_f) smp_allocobj(struct worker *wrk, const struct stevedore *stv, - struct objcore *oc, unsigned wsl, int nuke_limit) + struct objcore *oc, unsigned wsl) { struct object *o; struct storage *st; @@ -518,7 +518,6 @@ smp_allocobj(struct worker *wrk, const struct stevedore *stv, CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); CAST_OBJ_NOTNULL(sc, stv->priv, SMP_SC_MAGIC); - assert(nuke_limit >= 0); /* Don't entertain already dead objects */ if (oc->flags & OC_F_DYING) @@ -535,17 +534,16 @@ smp_allocobj(struct worker *wrk, const struct stevedore *stv, sg = NULL; so = NULL; objidx = 0; - for (; nuke_limit >= 0; nuke_limit--) { + + do { st = smp_allocx(stv, ltot, ltot, &so, &objidx, &sg); if (st != NULL && st->space < ltot) { stv->sml_free(st); // NOP st = NULL; } - if (st != NULL) - break; - if (!nuke_limit || !LRU_NukeOne(wrk, stv->lru)) - return (0); - } + } while (st == NULL && LRU_NukeOne(wrk, stv->lru)); + if (st == NULL) + return (0); AN(st); AN(sg); diff --git a/bin/varnishd/storage/storage_simple.c b/bin/varnishd/storage/storage_simple.c index 0ad45f7..c3bffe9 100644 --- a/bin/varnishd/storage/storage_simple.c +++ b/bin/varnishd/storage/storage_simple.c @@ -130,7 +130,7 @@ SML_MkObject(const struct stevedore *stv, struct objcore *oc, void *ptr) int __match_proto__(storage_allocobj_f) SML_allocobj(struct worker *wrk, const struct stevedore *stv, - struct objcore *oc, unsigned wsl, int nuke_limit) + struct objcore *oc, unsigned wsl) { struct object *o; struct storage *st = NULL; @@ -141,20 +141,19 @@ SML_allocobj(struct worker *wrk, const struct stevedore *stv, CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); AN(stv->sml_alloc); - assert(nuke_limit >= 0); ltot = sizeof(struct object) + PRNDUP(wsl); - for (; nuke_limit >= 0; nuke_limit--) { + + do { st = stv->sml_alloc(stv, ltot); if (st != NULL && st->space < ltot) { stv->sml_free(st); st = NULL; } - if (st != NULL) - break; - if (!nuke_limit || !LRU_NukeOne(wrk, stv->lru)) - return (0); - } + } while (st == NULL && LRU_NukeOne(wrk, stv->lru)); + if (st == NULL) + return (0); + CHECK_OBJ_NOTNULL(st, STORAGE_MAGIC); o = SML_MkObject(stv, oc, st->ptr); CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); @@ -342,7 +341,6 @@ objallocwithnuke(struct worker *wrk, const struct stevedore *stv, size_t size, int flags) { struct storage *st = NULL; - unsigned fail; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(stv, STEVEDORE_MAGIC); @@ -355,7 +353,7 @@ objallocwithnuke(struct worker *wrk, const struct stevedore *stv, size_t size, assert(size <= UINT_MAX); /* field limit in struct storage */ - for (fail = 0; fail <= cache_param->nuke_limit; fail++) { + do { /* try to allocate from it */ st = sml_stv_alloc(stv, size, flags); if (st != NULL) @@ -364,10 +362,8 @@ objallocwithnuke(struct worker *wrk, const struct stevedore *stv, size_t size, /* no luck; try to free some space and keep trying */ if (stv->lru == NULL) break; - if (fail < cache_param->nuke_limit && - !LRU_NukeOne(wrk, stv->lru)) - break; - } + } while (LRU_NukeOne(wrk, stv->lru)); + CHECK_OBJ_ORNULL(st, STORAGE_MAGIC); return (st); } diff --git a/bin/varnishtest/tests/r01764.vtc b/bin/varnishtest/tests/r01764.vtc new file mode 100644 index 0000000..e5b8211 --- /dev/null +++ b/bin/varnishtest/tests/r01764.vtc @@ -0,0 +1,54 @@ +varnishtest "Test nuke_limit" + +server s1 { + # First consume (almost) all of the storage + rxreq + expect req.url == /url1 + txresp -bodylen 200000 + + rxreq + expect req.url == /url2 + txresp -bodylen 200000 + + rxreq + expect req.url == /url3 + txresp -bodylen 200000 + + rxreq + expect req.url == /url4 + txresp -bodylen 200000 + + non_fatal + rxreq + expect req.url == /url5 + txresp -bodylen 1000000 +} -start + +varnish v1 -arg "-smalloc,1M" -arg "-p nuke_limit=1" -vcl+backend { + sub vcl_backend_response { + set beresp.do_stream = false; + } +} -start + + +client c1 { + txreq -url /url1 + rxresp + expect resp.status == 200 + + txreq -url /url2 + rxresp + expect resp.status == 200 + + txreq -url /url3 + rxresp + expect resp.status == 200 + + txreq -url /url4 + rxresp + expect resp.status == 200 + + txreq -url /url5 + rxresp + expect resp.status == 503 +} -run From phk at FreeBSD.org Mon Feb 27 10:15:06 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 27 Feb 2017 11:15:06 +0100 Subject: [master] 0b7b8e7 Comment out premature assert, I had forgotten the XXX over in H2 Message-ID: commit 0b7b8e7716ba5913d5b40fb42d73a4873fe3afca Author: Poul-Henning Kamp Date: Mon Feb 27 10:13:43 2017 +0000 Comment out premature assert, I had forgotten the XXX over in H2 diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c index 5bf7d81..e36c9e3 100644 --- a/bin/varnishd/cache/cache_session.c +++ b/bin/varnishd/cache/cache_session.c @@ -193,7 +193,7 @@ HTC_RxInit(struct http_conn *htc, struct ws *ws) htc->rxbuf_e = ws->f; if (htc->pipeline_b != NULL) { AN(htc->pipeline_e); - assert(WS_Inside(ws, htc->pipeline_b, htc->pipeline_e)); + // assert(WS_Inside(ws, htc->pipeline_b, htc->pipeline_e)); l = htc->pipeline_e - htc->pipeline_b; assert(l > 0); assert(l <= ws->r - htc->rxbuf_b); diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index c2ab7f1..1a11609 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -821,6 +821,7 @@ h2_new_ou_session(struct worker *wrk, struct h2_sess *h2, req->task.priv = req; req->err_code = 0; http_SetH(req->http, HTTP_HDR_PROTO, "HTTP/2.0"); + req->http->protover = 20; XXXAZ(Pool_Task(wrk->pool, &req->task, TASK_QUEUE_REQ)); /* Wait for PRISM response */ From nils.goroll at uplex.de Mon Feb 27 17:11:04 2017 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 27 Feb 2017 18:11:04 +0100 Subject: [master] 4073a4b Parameter ban_cutoff to limit the number of active (incomplete) bans Message-ID: commit 4073a4b65e9757f4218bcf750f0740127e53f283 Author: Nils Goroll Date: Mon Feb 27 17:24:52 2017 +0100 Parameter ban_cutoff to limit the number of active (incomplete) bans Expurge long tail content from the cache to keep the number of bans below this value. 0 disables. This is a safety net to avoid bad response times due to bans being tested at lookup time. Setting a cutoff trades response time for cache efficiency. The recommended value is proportional to rate(bans_lurker_tests_tested) / n_objects while the ban lurker is working, which is the number of bans the system can sustain. The additional latency due to request ban testing is in the order of ban_cutoff / rate(bans_lurker_tests_tested). For example, for rate(bans_lurker_tests_tested) = 2M/s and a tolerable latency of 100ms, a good value for ban_cutoff may be 200K. Merges #2131 diff --git a/bin/varnishd/cache/cache_ban_lurker.c b/bin/varnishd/cache/cache_ban_lurker.c index 638298c..9a5b43b 100644 --- a/bin/varnishd/cache/cache_ban_lurker.c +++ b/bin/varnishd/cache/cache_ban_lurker.c @@ -196,7 +196,7 @@ ban_lurker_getfirst(struct vsl_log *vsl, struct ban *bt) static void ban_lurker_test_ban(struct worker *wrk, struct vsl_log *vsl, struct ban *bt, - struct banhead_s *obans, struct ban *bd) + struct banhead_s *obans, struct ban *bd, int kill) { struct ban *bl, *bln; struct objcore *oc; @@ -238,16 +238,30 @@ ban_lurker_test_ban(struct worker *wrk, struct vsl_log *vsl, struct ban *bt, VTAILQ_REMOVE(obans, bl, l_list); continue; } - AZ(bl->flags & BANS_FLAG_REQ); - tests = 0; - i = ban_evaluate(wrk, bl->spec, oc, NULL, &tests); - VSC_C_main->bans_lurker_tested++; - VSC_C_main->bans_lurker_tests_tested += tests; + if (kill == 1) + i = 1; + else { + AZ(bl->flags & BANS_FLAG_REQ); + tests = 0; + i = ban_evaluate(wrk, bl->spec, oc, NULL, + &tests); + VSC_C_main->bans_lurker_tested++; + VSC_C_main->bans_lurker_tests_tested += tests; + } if (i) { - VSLb(vsl, SLT_ExpBan, "%u banned by lurker", - ObjGetXID(wrk, oc)); + if (kill) { + VSLb(vsl, SLT_ExpBan, + "%u killed for lurker cutoff", + ObjGetXID(wrk, oc)); + VSC_C_main-> + bans_lurker_obj_killed_cutoff++; + } else { + VSLb(vsl, SLT_ExpBan, + "%u banned by lurker", + ObjGetXID(wrk, oc)); + VSC_C_main->bans_lurker_obj_killed++; + } HSH_Kill(oc); - VSC_C_main->bans_lurker_obj_killed++; break; } } @@ -285,12 +299,15 @@ ban_lurker_work(struct worker *wrk, struct vsl_log *vsl) struct ban *b, *bd; struct banhead_s obans; double d, dt, n; + unsigned count = 0, cutoff = UINT_MAX; dt = 49.62; // Random, non-magic if (cache_param->ban_lurker_sleep == 0) { (void)ban_cleantail(NULL); return (dt); } + if (cache_param->ban_cutoff > 0) + cutoff = cache_param->ban_cutoff; Lck_Lock(&ban_mtx); b = ban_start; @@ -300,14 +317,17 @@ ban_lurker_work(struct worker *wrk, struct vsl_log *vsl) VTAILQ_INIT(&obans); for (; b != NULL; b = VTAILQ_NEXT(b, list)) { if (bd != NULL && bd != b) - ban_lurker_test_ban(wrk, vsl, b, &obans, bd); + ban_lurker_test_ban(wrk, vsl, b, &obans, bd, + count > cutoff); if (b->flags & BANS_FLAG_COMPLETED) continue; - if (b->flags & BANS_FLAG_REQ) { + if (b->flags & BANS_FLAG_REQ && + count <= cutoff) { if (bd != NULL) bd = VTAILQ_NEXT(b, list); continue; } + count++; n = ban_time(b->spec) - d; if (n < 0) { VTAILQ_INSERT_TAIL(&obans, b, l_list); diff --git a/bin/varnishtest/tests/c00049.vtc b/bin/varnishtest/tests/c00049.vtc index 43f9e1b..9ff05d7 100644 --- a/bin/varnishtest/tests/c00049.vtc +++ b/bin/varnishtest/tests/c00049.vtc @@ -188,3 +188,38 @@ varnish v1 -expect bans_lurker_obj_killed == 4 varnish v1 -expect bans_dups == 0 varnish v1 -expect n_object == 3 + +# adding more bans than the cutoff purges all untested objects +# (here: all objects) + +varnish v1 -cliok "param.set ban_lurker_age 2" +varnish v1 -cliok "param.set ban_cutoff 4" + +varnish v1 -cliok "ban.list" +varnish v1 -cliok "ban obj.http.nomatch == 1" +varnish v1 -cliok "ban obj.http.nomatch == 2" +varnish v1 -cliok "ban obj.http.nomatch == 3" +varnish v1 -cliok "ban obj.http.nomatch == 4" +varnish v1 -cliok "ban obj.http.nomatch == 5" +varnish v1 -cliok "ban.list" +varnish v1 -cliok "param.set ban_lurker_age .1" +delay 3 + +varnish v1 -cliok "ban.list" + +varnish v1 -expect bans == 1 +varnish v1 -expect bans_completed == 1 +varnish v1 -expect bans_req == 0 +varnish v1 -expect bans_obj == 1 +varnish v1 -expect bans_added == 11 +varnish v1 -expect bans_deleted == 10 +varnish v1 -expect bans_tested == 2 +varnish v1 -expect bans_tests_tested == 2 +varnish v1 -expect bans_obj_killed == 1 +varnish v1 -expect bans_lurker_tested == 8 +varnish v1 -expect bans_lurker_tests_tested == 9 +varnish v1 -expect bans_lurker_obj_killed == 4 +varnish v1 -expect bans_lurker_obj_killed_cutoff == 3 +varnish v1 -expect bans_dups == 0 + +varnish v1 -expect n_object == 0 diff --git a/include/tbl/params.h b/include/tbl/params.h index 71552ee..49f77ac 100644 --- a/include/tbl/params.h +++ b/include/tbl/params.h @@ -137,6 +137,30 @@ PARAM( ) PARAM( + /* name */ ban_cutoff, + /* typ */ uint, + /* min */ "0", + /* max */ NULL, + /* default */ "0", + /* units */ "bans", + /* flags */ EXPERIMENTAL, + /* s-text */ + "Expurge long tail content from the cache to keep the number of bans " + "below this value. 0 disables.\n" + "This is a safety net to avoid bad response times due to bans being " + "tested at lookup time. Setting a cutoff trades response time for " + "cache efficiency. The recommended value is proportional to " + "rate(bans_lurker_tests_tested) / n_objects while the ban lurker is " + "working, which is the number of bans the system can sustain. The " + "additional latency due to request ban testing is in the order of " + "ban_cutoff / rate(bans_lurker_tests_tested). For example, for " + "rate(bans_lurker_tests_tested) = 2M/s and a tolerable latency of " + "100ms, a good value for ban_cutoff may be 200K.", + /* l-text */ "", + /* func */ NULL +) + +PARAM( /* name */ ban_lurker_age, /* typ */ timeout, /* min */ "0", diff --git a/include/tbl/vsc_f_main.h b/include/tbl/vsc_f_main.h index 2651435..b1dbb17 100644 --- a/include/tbl/vsc_f_main.h +++ b/include/tbl/vsc_f_main.h @@ -571,7 +571,13 @@ VSC_FF(bans_lurker_tests_tested, uint64_t, 0, 'c', 'i', diag, VSC_FF(bans_lurker_obj_killed, uint64_t, 0, 'c', 'i', diag, "Objects killed by bans (lurker)", - "Number of objects killed by ban-lurker." + "Number of objects killed by the ban-lurker." +) + +VSC_FF(bans_lurker_obj_killed_cutoff, uint64_t, 0, 'c', 'i', diag, + "Objects killed by bans for cutoff (lurker)", + "Number of objects killed by the ban-lurker to keep the number of" + " bans below ban_cutoff." ) VSC_FF(bans_dups, uint64_t, 0, 'c', 'i', diag, From phk at FreeBSD.org Mon Feb 27 22:39:08 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 27 Feb 2017 23:39:08 +0100 Subject: [master] f146f86 Start remodelling the argument parsing (again) so that special mode arguments (-V, -x and later -C) break free early. Message-ID: commit f146f863e38a07f7b3faac4cda9b9b4a13e6c189 Author: Poul-Henning Kamp Date: Mon Feb 27 22:36:58 2017 +0000 Start remodelling the argument parsing (again) so that special mode arguments (-V, -x and later -C) break free early. diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index 4ce28e0..e0c77ff 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -74,7 +74,7 @@ int optreset; // Some has it, some doesn't. Cheaper than auto* /*--------------------------------------------------------------------*/ -static void __attribute__((__noreturn__)) +static void usage(void) { #define FMT " %-28s # %s\n" @@ -449,7 +449,6 @@ main(int argc, char * const *argv) unsigned C_flag = 0; unsigned f_flag = 0; unsigned F_flag = 0; - unsigned V_flag = 0; const char *b_arg = NULL; const char *i_arg = NULL; const char *j_arg = NULL; @@ -460,7 +459,6 @@ main(int argc, char * const *argv) const char *S_arg = NULL; const char *s_arg = "malloc,100m"; const char *W_arg = NULL; - const char *x_arg = NULL; int s_arg_given = 0; int novcl = 0; const char *T_arg = "localhost:0"; @@ -483,15 +481,34 @@ main(int argc, char * const *argv) mgt_initialize(cli); - /* - * First pass over arguments, to determine what we will be doing - * and what process configuration we will use for it. - */ - while ((o = getopt(argc, argv, opt_spec)) != -1) { + /* Check if first argument is a special flag */ + + o = getopt(argc, argv, opt_spec); + switch (o) { + case '?': + usage(); + exit(1); + case 'x': + if (argc != 3) + ARGV_ERR("Too many arguments for -x\n"); + mgt_x_arg(optarg); + exit(0); + case 'V': + if (argc != 2) + ARGV_ERR("Too many arguments for -V\n"); + VCS_Message("varnishd"); + exit(0); + default: + break; + } + + /* First pass over arguments to determine overall configuration */ + + do { switch (o) { case '?': usage(); - break; + exit(1); case 'b': b_arg = optarg; break; @@ -511,32 +528,18 @@ main(int argc, char * const *argv) j_arg = optarg; break; case 'V': - V_flag = 1; - break; case 'x': - x_arg = optarg; + ARGV_ERR("-%c must be the first argument\n", o); break; default: break; } - } + o = getopt(argc, argv, opt_spec); + } while (o != -1); if (argc != optind) ARGV_ERR("Too many arguments (%s...)\n", argv[optind]); - if (V_flag) { - if (argc != 2) - ARGV_ERR("-V is incompatible with everything else\n"); - VCS_Message("varnishd"); - exit(0); - } - if (x_arg != NULL) { - if (argc != 3) - ARGV_ERR("-x is incompatible with everything else\n"); - mgt_x_arg(x_arg); - exit(0); - } - if (b_arg != NULL && f_flag) ARGV_ERR("Only one of -b or -f can be specified\n"); @@ -597,7 +600,6 @@ main(int argc, char * const *argv) case 'd': case 'F': case 'j': - case 'V': case 'x': /* Handled in first pass */ break; @@ -674,8 +676,10 @@ main(int argc, char * const *argv) break; case 'p': p = strchr(optarg, '='); - if (p == NULL) + if (p == NULL) { usage(); + exit(2); + } AN(p); *p++ = '\0'; MCF_ParamSet(cli, optarg, p); @@ -706,7 +710,7 @@ main(int argc, char * const *argv) W_arg = optarg; break; default: - usage(); + WRONG("Error in argument parsing"); } } assert(argc == optind); diff --git a/bin/varnishtest/tests/a00009.vtc b/bin/varnishtest/tests/a00009.vtc index 2281600..12daa47 100644 --- a/bin/varnishtest/tests/a00009.vtc +++ b/bin/varnishtest/tests/a00009.vtc @@ -1,10 +1,6 @@ varnishtest "Code coverage of mgt_main, (VCL compiler and RSTdump etc)" shell "varnishd -b 127.0.0.1:80 -C 2> ${tmpdir}/_.c" -shell "varnishd -x dumprstparam > ${tmpdir}/_.param" -shell "varnishd -x dumprstvsl > ${tmpdir}/_.vsl" -shell "varnishd -x dumprstcli > ${tmpdir}/_.cli" -shell "varnishd -x dumpbuiltin > ${tmpdir}/_.builtin" shell -err -expect {VCL version declaration missing} { echo 'bad vcl' > ${tmpdir}/bad.vcl varnishd -f ${tmpdir}/bad.vcl -n ${tmpdir} @@ -15,8 +11,19 @@ shell -err -expect {VCL version declaration missing} { } shell -err -expect {-spersistent has been deprecated} "varnishd -spersistent -f '' " shell -err -expect {Unknown jail method "xyz"} "varnishd -jxyz -f '' " -shell -err -expect {-x is incompatible with everything else} "varnishd -d -x foo " + +shell -err -expect {-x must be the first argument} "varnishd -d -x foo " +shell -err -expect {Too many arguments for -x} "varnishd -x foo bar" shell -err -expect {Invalid -x argument} "varnishd -x foo " +shell "varnishd -x dumprstparam > ${tmpdir}/_.param" +shell "varnishd -x dumprstvsl > ${tmpdir}/_.vsl" +shell "varnishd -x dumprstcli > ${tmpdir}/_.cli" +shell "varnishd -x dumpbuiltin > ${tmpdir}/_.builtin" + +shell -err -expect {-V must be the first argument} "varnishd -d -V foo " +shell -err -expect {Too many arguments for -V} "varnishd -V -V" +shell -expect {Copyright (c) 2006} "varnishd -V" + shell -err -expect {Too many arguments} "varnishd foo " shell -err -expect {Only one of -d or -F can be specified} "varnishd -d -F " shell -err -expect {Only one of -b or -f can be specified} "varnishd -b a -f b " @@ -27,7 +34,6 @@ shell -err -expect {-F makes no sense with -C} "varnishd -C -b 127.0.0.1:80 -F " shell -err -expect {usage: varnishd [options]} "varnishd -? " shell -err -expect {Invalid backslash sequence} {varnishd -l 'xyz\kk,xyz\foo' -f '' } shell -err -expect {Invalid backslash sequence} {varnishd -l 'ab\8cd' -f '' } -shell -err -expect {Copyright (c) 2006} "varnishd -V ; exit 1" shell -err -expect {usage: varnishd [options]} "varnishd -A " shell -err -expect {Cannot open -S file} { varnishd -S ${tmpdir}/nonexistent -n ${tmpdir}/v0 -f '' From phk at FreeBSD.org Tue Feb 28 10:19:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 28 Feb 2017 11:19:05 +0100 Subject: [master] ac9a479 Renovate varnishd's usage message, and don't emit it until asked for it. Message-ID: commit ac9a4790d2acd04af8c8582db1b878b48149ab75 Author: Poul-Henning Kamp Date: Tue Feb 28 10:16:33 2017 +0000 Renovate varnishd's usage message, and don't emit it until asked for it. Instead of alphabetical, sort the options by category. Pull -x out of the shadows, despite the RST markup, the output satisfies "instruction at the point of need". diff --git a/bin/varnishd/Makefile.phk b/bin/varnishd/Makefile.phk index 28d8e85..f018d00 100644 --- a/bin/varnishd/Makefile.phk +++ b/bin/varnishd/Makefile.phk @@ -126,7 +126,7 @@ include $(TOPDIR)/Makefile.inc.phk $(PARST): $(PROGNAME) -ls -l $(PARST) $(PROGNAME) mkdir -p $(TOPDIR)/doc/sphinx/include - ./varnishd -x dumprstparam > $(PARST) + ./varnishd -x parameter > $(PARST) # # Turn the builtin.vcl file into a C-string we can include in the program. diff --git a/bin/varnishd/common/common.h b/bin/varnishd/common/common.h index 27da283..0c302c2 100644 --- a/bin/varnishd/common/common.h +++ b/bin/varnishd/common/common.h @@ -66,6 +66,7 @@ void MCH_Fd_Inherit(int fd, const char *what); #define ARGV_ERR(...) \ do { \ fprintf(stderr, "Error: " __VA_ARGS__); \ + fprintf(stderr, "(-? gives usage)\n"); \ exit(2); \ } while (0) diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index e0c77ff..1eadebf 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -74,66 +74,80 @@ int optreset; // Some has it, some doesn't. Cheaper than auto* /*--------------------------------------------------------------------*/ -static void +static void usage(void) { -#define FMT " %-28s # %s\n" - - fprintf(stderr, "usage: varnishd [options]\n"); - fprintf(stderr, FMT, "-a address[:port][,proto]", - "HTTP listen address and port (default: *:80)"); - fprintf(stderr, FMT, "", " address: defaults to loopback"); - fprintf(stderr, FMT, "", " port: port or service (default: 80)"); - fprintf(stderr, FMT, "", " proto: HTTP/1 (default), PROXY"); - fprintf(stderr, FMT, "-b address[:port]", "backend address and port"); - fprintf(stderr, FMT, "", " address: hostname or IP"); - fprintf(stderr, FMT, "", " port: port or service (default: 80)"); - fprintf(stderr, FMT, "-C", "print VCL code compiled to C language"); - fprintf(stderr, FMT, "-d", "debug"); - fprintf(stderr, FMT, "-F", "Run in foreground"); - fprintf(stderr, FMT, "-f file", "VCL script"); - fprintf(stderr, FMT, "-h kind[,hashoptions]", "Hash specification"); - fprintf(stderr, FMT, "", " -h critbit [default]"); - fprintf(stderr, FMT, "", " -h simple_list"); - fprintf(stderr, FMT, "", " -h classic"); - fprintf(stderr, FMT, "", " -h classic,"); - fprintf(stderr, FMT, "-i identity", "Identity of varnish instance"); - fprintf(stderr, FMT, "-I file", "Initialization CLI commands"); - fprintf(stderr, FMT, "-j jail[,jailoptions]", "Jail specification"); +#define FMT " %-28s # %s\n" + + printf( "Usage: varnishd [options]\n"); + + printf("\nBasic options:\n"); + + printf(FMT, "-a address[:port][,proto]", + "HTTP listen address and port"); + printf(FMT, "", "Can be specified multiple times."); + printf(FMT, "", " default: \":80,HTTP/1\""); + printf(FMT, "-b address[:port]", "Backend address and port"); + printf(FMT, "", " default: \":80\""); + printf(FMT, "-f vclfile", "VCL program"); + printf(FMT, "", "Can be specified multiple times."); + printf(FMT, "-n dir", "Working directory"); + + printf("\n-b can be used only once, and not together with -f\n"); + + printf("\nDocumentation options:\n"); + printf(FMT, "-?", "Prints this usage message"); + printf(FMT, "-x parameter", "Parameter documentation"); + printf(FMT, "-x vsl", "VSL record documentation"); + printf(FMT, "-x cli", "CLI command documentation"); + printf(FMT, "-x builtin", "Builtin VCL program"); + + printf("\nOperations options:\n"); + + printf(FMT, "-F", "Run in foreground"); + printf(FMT, "-T address[:port]", "CLI address"); + printf(FMT, "", "Can be specified multiple times."); + printf(FMT, "-M address:port", "Reverse CLI destination"); + printf(FMT, "", "Can be specified multiple times."); + printf(FMT, "-P file", "PID file"); + printf(FMT, "-i identity", "Identity of varnish instance"); + printf(FMT, "-I clifile", "Initialization CLI commands"); + + printf("\nTuning options:\n"); + + printf(FMT, "-t TTL", "Default TTL"); + printf(FMT, "-p param=value", "set parameter"); + printf(FMT, "", "Can be specified multiple times."); + + printf(FMT, "-s [name=]kind[,options]", "Storage specification"); + printf(FMT, "", "Can be specified multiple times."); + printf(FMT, "", " -s malloc"); + printf(FMT, "", " -s file"); + + printf(FMT, "-l vsl[,vsm]", "Size of shared memory file"); + printf(FMT, "", " vsl: space for VSL records [80m]"); + printf(FMT, "", " vsm: space for stats counters [1m]"); + + printf("\nSecurity options:\n"); + + printf(FMT, "-r param[,param...]", "Set parameters read-only from CLI"); + printf(FMT, "", "Can be specified multiple times."); + printf(FMT, "-S secret-file", "Secret file for CLI authentication"); + printf(FMT, "-j jail[,options]", "Jail specification"); #ifdef HAVE_SETPPRIV - fprintf(stderr, FMT, "", " -j solaris"); + printf(FMT, "", " -j solaris"); #endif - fprintf(stderr, FMT, "", " -j unix[,user=][,ccgroup=]"); - fprintf(stderr, FMT, "", " -j none"); - fprintf(stderr, FMT, "-l vsl[,vsm]", "Size of shared memory file"); - fprintf(stderr, FMT, "", " vsl: space for VSL records [80m]"); - fprintf(stderr, FMT, "", " vsm: space for stats counters [1m]"); - fprintf(stderr, FMT, "-M address:port", "Reverse CLI destination"); - fprintf(stderr, FMT, "-n dir", "varnishd working directory"); - fprintf(stderr, FMT, "-P file", "PID file"); - fprintf(stderr, FMT, "-p param=value", "set parameter"); - fprintf(stderr, FMT, - "-r param[,param...]", "make parameter read-only"); - fprintf(stderr, FMT, "-S secret-file", - "Secret file for CLI authentication"); - fprintf(stderr, FMT, - "-s [name=]kind[,options]", "Backend storage specification"); - fprintf(stderr, FMT, "", " -s malloc[,]"); - fprintf(stderr, FMT, "", " -s file,"); - fprintf(stderr, FMT, "", " -s file,,"); - fprintf(stderr, FMT, "", - " -s file,,,"); - fprintf(stderr, FMT, "", - " -s file,,,,"); - fprintf(stderr, FMT, "", " -s persistent (experimental)"); - fprintf(stderr, FMT, "-T address:port", - "Telnet listen address and port"); - fprintf(stderr, FMT, "-t TTL", "Default TTL"); - fprintf(stderr, FMT, "-V", "version"); - fprintf(stderr, FMT, "-W waiter", "Waiter implementation"); -#define WAITER(nm) fprintf(stderr, FMT, "", " -W " #nm); -#include "tbl/waiters.h" - exit(1); + printf(FMT, "", " -j unix"); + printf(FMT, "", " -j none"); + + printf("\nAdvanced/Dev/Debug options:\n"); + + printf(FMT, "-d", "debug mode"); + printf(FMT, "", "Stay in forground, CLI on stdin."); + printf(FMT, "-C", "Output VCL code compiled to C language"); + printf(FMT, "-V", "version"); + printf(FMT, "-h kind[,options]", "Hash specification"); + printf(FMT, "-W waiter", "Waiter implementation"); } /*--------------------------------------------------------------------*/ @@ -323,13 +337,13 @@ mgt_initialize(struct cli *cli) static void mgt_x_arg(const char *x_arg) { - if (!strcmp(x_arg, "dumprstparam")) + if (!strcmp(x_arg, "parameter")) MCF_DumpRstParam(); - else if (!strcmp(x_arg, "dumprstvsl")) + else if (!strcmp(x_arg, "vsl")) mgt_DumpRstVsl(); - else if (!strcmp(x_arg, "dumprstcli")) + else if (!strcmp(x_arg, "cli")) mgt_DumpRstCli(); - else if (!strcmp(x_arg, "dumpbuiltin")) + else if (!strcmp(x_arg, "builtin")) mgt_DumpBuiltin(); else ARGV_ERR("Invalid -x argument\n"); @@ -485,9 +499,6 @@ main(int argc, char * const *argv) o = getopt(argc, argv, opt_spec); switch (o) { - case '?': - usage(); - exit(1); case 'x': if (argc != 3) ARGV_ERR("Too many arguments for -x\n"); @@ -507,8 +518,16 @@ main(int argc, char * const *argv) do { switch (o) { case '?': - usage(); - exit(1); + if (optopt == '?') { + usage(); + exit(1); + } + ARGV_ERR("Option '%c' unknown.\n", + optopt); + case 'V': + case 'x': + ARGV_ERR("-%c must be the first argument\n", o); + break; case 'b': b_arg = optarg; break; @@ -527,10 +546,6 @@ main(int argc, char * const *argv) case 'j': j_arg = optarg; break; - case 'V': - case 'x': - ARGV_ERR("-%c must be the first argument\n", o); - break; default: break; } @@ -600,7 +615,6 @@ main(int argc, char * const *argv) case 'd': case 'F': case 'j': - case 'x': /* Handled in first pass */ break; case 'a': @@ -676,10 +690,8 @@ main(int argc, char * const *argv) break; case 'p': p = strchr(optarg, '='); - if (p == NULL) { - usage(); - exit(2); - } + if (p == NULL) + ARGV_ERR("\t-p lacks '='\n"); AN(p); *p++ = '\0'; MCF_ParamSet(cli, optarg, p); diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c index f10d312..e74cc57 100644 --- a/bin/varnishd/mgt/mgt_param.c +++ b/bin/varnishd/mgt/mgt_param.c @@ -552,7 +552,7 @@ MCF_DumpRstParam(void) int j; printf("\n.. The following is the autogenerated " - "output from varnishd -x dumprstparam\n\n"); + "output from varnishd -x parameter\n\n"); VTAILQ_FOREACH(pl, &phead, list) { pp = pl->spec; printf(".. _ref_param_%s:\n\n", pp->name); diff --git a/bin/varnishd/mgt/mgt_util.c b/bin/varnishd/mgt/mgt_util.c index 4c59a9e..9e63ef7 100644 --- a/bin/varnishd/mgt/mgt_util.c +++ b/bin/varnishd/mgt/mgt_util.c @@ -66,7 +66,7 @@ mgt_DumpRstVsl(void) printf( "\n.. The following is autogenerated output from " - "varnishd -x dumprstvsl\n\n"); + "varnishd -x vsl\n\n"); #define SLTM(tag, flags, sdesc, ldesc) mgt_sltm(#tag, sdesc, ldesc); #include "tbl/vsl_tags.h" diff --git a/bin/varnishtest/tests/a00009.vtc b/bin/varnishtest/tests/a00009.vtc index 12daa47..ca0f299 100644 --- a/bin/varnishtest/tests/a00009.vtc +++ b/bin/varnishtest/tests/a00009.vtc @@ -15,10 +15,10 @@ shell -err -expect {Unknown jail method "xyz"} "varnishd -jxyz -f '' " shell -err -expect {-x must be the first argument} "varnishd -d -x foo " shell -err -expect {Too many arguments for -x} "varnishd -x foo bar" shell -err -expect {Invalid -x argument} "varnishd -x foo " -shell "varnishd -x dumprstparam > ${tmpdir}/_.param" -shell "varnishd -x dumprstvsl > ${tmpdir}/_.vsl" -shell "varnishd -x dumprstcli > ${tmpdir}/_.cli" -shell "varnishd -x dumpbuiltin > ${tmpdir}/_.builtin" +shell "varnishd -x parameter > ${tmpdir}/_.param" +shell "varnishd -x vsl > ${tmpdir}/_.vsl" +shell "varnishd -x cli > ${tmpdir}/_.cli" +shell "varnishd -x builtin > ${tmpdir}/_.builtin" shell -err -expect {-V must be the first argument} "varnishd -d -V foo " shell -err -expect {Too many arguments for -V} "varnishd -V -V" @@ -31,10 +31,10 @@ shell -err -expect {-C needs either -b or -f } \ "varnishd -C " shell -err -expect {-d makes no sense with -C} "varnishd -C -b 127.0.0.1:80 -d " shell -err -expect {-F makes no sense with -C} "varnishd -C -b 127.0.0.1:80 -F " -shell -err -expect {usage: varnishd [options]} "varnishd -? " +shell -err -expect {Usage: varnishd [options]} "varnishd -? " shell -err -expect {Invalid backslash sequence} {varnishd -l 'xyz\kk,xyz\foo' -f '' } shell -err -expect {Invalid backslash sequence} {varnishd -l 'ab\8cd' -f '' } -shell -err -expect {usage: varnishd [options]} "varnishd -A " +shell -err -expect {Option 'A' unknown.} "varnishd -A " shell -err -expect {Cannot open -S file} { varnishd -S ${tmpdir}/nonexistent -n ${tmpdir}/v0 -f '' } diff --git a/doc/sphinx/Makefile.am b/doc/sphinx/Makefile.am index 6968535..255ce4e 100644 --- a/doc/sphinx/Makefile.am +++ b/doc/sphinx/Makefile.am @@ -126,11 +126,11 @@ distclean-local: rm -rf $(BUILDDIR) include/cli.rst: $(top_builddir)/bin/varnishd/varnishd - $(top_builddir)/bin/varnishd/varnishd -x dumprstcli > $@ + $(top_builddir)/bin/varnishd/varnishd -x cli > $@ BUILT_SOURCES = include/cli.rst include/params.rst: $(top_builddir)/bin/varnishd/varnishd - $(top_builddir)/bin/varnishd/varnishd -x dumprstparam > $@ + $(top_builddir)/bin/varnishd/varnishd -x parameter > $@ BUILT_SOURCES += include/params.rst include/counters.rst: $(top_builddir)/bin/varnishstat/vsc2rst diff --git a/doc/sphinx/Makefile.phk b/doc/sphinx/Makefile.phk index f04a711..ba77075 100644 --- a/doc/sphinx/Makefile.phk +++ b/doc/sphinx/Makefile.phk @@ -201,7 +201,7 @@ distclean-local: # XXX: here be dragons include/params.rst: ../../bin/varnishd/varnishd - ../../bin/varnishd/varnishd -x dumprstparam > $@ + ../../bin/varnishd/varnishd -x parameter > $@ # only sphinx needs the opt2rst stuff anyway From nils.goroll at uplex.de Tue Feb 28 17:49:04 2017 From: nils.goroll at uplex.de (Nils Goroll) Date: Tue, 28 Feb 2017 18:49:04 +0100 Subject: [master] 2a8398c For OC_EF_REMOVE, clear OC_EF_REFD under the lock to prevent a race with exp_mail_it Message-ID: commit 2a8398c11bdff02970cf79601cae931de02d6e9d Author: Nils Goroll Date: Tue Feb 28 18:40:22 2017 +0100 For OC_EF_REMOVE, clear OC_EF_REFD under the lock to prevent a race with exp_mail_it Previously, objcores to be removed remained flagged as referenced, so exp_mail_it could change the flags again. Fixes #2143 diff --git a/bin/varnishd/cache/cache_expire.c b/bin/varnishd/cache/cache_expire.c index cfe2122..f0ca523 100644 --- a/bin/varnishd/cache/cache_expire.c +++ b/bin/varnishd/cache/cache_expire.c @@ -190,7 +190,6 @@ exp_inbox(struct exp_priv *ep, struct objcore *oc, unsigned flags) binheap_delete(ep->heap, oc->timer_idx); } assert(oc->timer_idx == BINHEAP_NOIDX); - oc->exp_flags &= ~OC_EF_REFD; assert(oc->refcnt > 0); AZ(oc->exp_flags); ObjSendEvent(ep->wrk, oc, OEV_EXPIRE); @@ -326,7 +325,10 @@ exp_thread(struct worker *wrk, void *priv) VSC_C_main->exp_received++; tnext = 0; flags = oc->exp_flags; - oc->exp_flags &= OC_EF_REFD; + if (flags & OC_EF_REMOVE) + oc->exp_flags = 0; + else + oc->exp_flags &= OC_EF_REFD; } else if (tnext > t) { VSL_Flush(&ep->vsl, 0); Pool_Sumstat(wrk); From phk at FreeBSD.org Tue Feb 28 23:04:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 01 Mar 2017 00:04:05 +0100 Subject: [master] b2f32cd Try to get http->protover into some kind of consistent state so we do not send HTTP/2.0 headers to backends on pass from HTTP/2.0 clients Message-ID: commit b2f32cd82111a9e6f388af0e459b9c1511bcae07 Author: Poul-Henning Kamp Date: Tue Feb 28 23:03:17 2017 +0000 Try to get http->protover into some kind of consistent state so we do not send HTTP/2.0 headers to backends on pass from HTTP/2.0 clients diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index c9fda21..fba8763 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -761,9 +761,10 @@ void http_ForceHeader(struct http *to, const char *hdr, const char *val); void http_PrintfHeader(struct http *to, const char *fmt, ...) __v_printflike(2, 3); void http_TimeHeader(struct http *to, const char *fmt, double now); +void http_Proto(struct http *to); void http_SetHeader(struct http *to, const char *hdr); -void http_SetH(const struct http *to, unsigned n, const char *fm); -void http_ForceField(const struct http *to, unsigned n, const char *t); +void http_SetH(struct http *to, unsigned n, const char *fm); +void http_ForceField(struct http *to, unsigned n, const char *t); void HTTP_Setup(struct http *, struct ws *, struct vsl_log *, enum VSL_tag_e); void http_Teardown(struct http *ht); int http_GetHdr(const struct http *hp, const char *hdr, const char **ptr); diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 1287f08..4aa3dd2 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -185,9 +185,12 @@ vbf_stp_mkbereq(struct worker *wrk, struct busyobj *bo) http_ForceField(bo->bereq0, HTTP_HDR_PROTO, "HTTP/1.1"); if (cache_param->http_gzip_support) http_ForceHeader(bo->bereq0, H_Accept_Encoding, "gzip"); - http_CopyHome(bo->bereq0); - } else + } else { AZ(bo->stale_oc); + if (bo->bereq0->protover > 11) + http_ForceField(bo->bereq0, HTTP_HDR_PROTO, "HTTP/1.1"); + } + http_CopyHome(bo->bereq0); if (bo->stale_oc != NULL && ObjCheckFlag(bo->wrk, bo->stale_oc, OF_IMSCAND) && diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c index 6642ea9..c200e24 100644 --- a/bin/varnishd/cache/cache_http.c +++ b/bin/varnishd/cache/cache_http.c @@ -199,12 +199,37 @@ HTTP_Copy(struct http *to, const struct http * const fm) memcpy(&to->nhd, &fm->nhd, sizeof *to - offsetof(struct http, nhd)); memcpy(to->hd, fm->hd, fm->nhd * sizeof *to->hd); memcpy(to->hdf, fm->hdf, fm->nhd * sizeof *to->hdf); + to->protover = fm->protover; } /*--------------------------------------------------------------------*/ void -http_SetH(const struct http *to, unsigned n, const char *fm) +http_Proto(struct http *to) +{ + const char *fm; + + fm = to->hd[HTTP_HDR_PROTO].b; + + if ((fm[0] == 'H' || fm[0] == 'h') && + (fm[1] == 'T' || fm[0] == 't') && + (fm[2] == 'T' || fm[0] == 't') && + (fm[3] == 'P' || fm[0] == 'p') && + fm[4] == '/' && + vct_isdigit(fm[5]) && + fm[6] == '.' && + vct_isdigit(fm[7]) && + fm[8] == '\0') { + to->protover = 10 * (fm[5] - '0') + (fm[7] - '0'); + } else { + to->protover = 0; + } +} + +/*--------------------------------------------------------------------*/ + +void +http_SetH(struct http *to, unsigned n, const char *fm) { assert(n < to->nhd); @@ -213,12 +238,14 @@ http_SetH(const struct http *to, unsigned n, const char *fm) to->hd[n].e = strchr(to->hd[n].b, '\0'); to->hdf[n] = 0; http_VSLH(to, n); + if (n == HTTP_HDR_PROTO) + http_Proto(to); } /*--------------------------------------------------------------------*/ static void -http_PutField(const struct http *to, int field, const char *string) +http_PutField(struct http *to, int field, const char *string) { char *p; @@ -233,6 +260,8 @@ http_PutField(const struct http *to, int field, const char *string) to->hd[field].e = strchr(p, '\0'); to->hdf[field] = 0; http_VSLH(to, field); + if (field == HTTP_HDR_PROTO) + http_Proto(to); } /*--------------------------------------------------------------------*/ @@ -759,7 +788,7 @@ http_GetMethod(const struct http *hp) */ void -http_ForceField(const struct http *to, unsigned n, const char *t) +http_ForceField(struct http *to, unsigned n, const char *t) { int i; @@ -1077,6 +1106,7 @@ http_FilterReq(struct http *to, const struct http *fm, unsigned how) http_linkh(to, fm, HTTP_HDR_METHOD); http_linkh(to, fm, HTTP_HDR_URL); http_linkh(to, fm, HTTP_HDR_PROTO); + to->protover = fm->protover; http_filterfields(to, fm, how); } diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index 000ae75..d0380a8 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -45,7 +45,7 @@ static char vrt_hostname[255] = ""; */ static void -vrt_do_string(VRT_CTX, const struct http *hp, int fld, +vrt_do_string(VRT_CTX, struct http *hp, int fld, const char *err, const char *p, va_list ap) { const char *b; diff --git a/bin/varnishd/http1/cache_http1_proto.c b/bin/varnishd/http1/cache_http1_proto.c index e788ed6..05d23b3 100644 --- a/bin/varnishd/http1/cache_http1_proto.c +++ b/bin/varnishd/http1/cache_http1_proto.c @@ -285,6 +285,8 @@ http1_splitline(struct http *hp, struct http_conn *htc, const int *hf, *p = '\0'; p += i; + http_Proto(hp); + return (http1_dissect_hdrs(hp, p, htc, maxhdr)); } @@ -340,19 +342,6 @@ http1_body_status(const struct http *hp, struct http_conn *htc, int request) /*--------------------------------------------------------------------*/ -static int8_t -http1_proto_ver(const struct http *hp) -{ - if (!strcasecmp(hp->hd[HTTP_HDR_PROTO].b, "HTTP/1.0")) - return (10); - else if (!strcasecmp(hp->hd[HTTP_HDR_PROTO].b, "HTTP/1.1")) - return (11); - else - return (0); -} - -/*--------------------------------------------------------------------*/ - uint16_t HTTP1_DissectRequest(struct http_conn *htc, struct http *hp) { @@ -367,8 +356,8 @@ HTTP1_DissectRequest(struct http_conn *htc, struct http *hp) HTTP1_Req, cache_param->http_req_hdr_len); if (retval != 0) return (retval); - hp->protover = http1_proto_ver(hp); - if (hp->protover == 0) + + if (hp->protover < 10 || hp->protover > 11) return (400); if (http_CountHdr(hp, H_Host) > 1) @@ -418,29 +407,24 @@ HTTP1_DissectRequest(struct http_conn *htc, struct http *hp) uint16_t HTTP1_DissectResponse(struct http_conn *htc, struct http *hp, - const struct http *req) + const struct http *rhttp) { uint16_t retval = 0; const char *p; - int8_t rv; - CHECK_OBJ_NOTNULL(htc, HTTP_CONN_MAGIC); CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC); - CHECK_OBJ_NOTNULL(req, HTTP_MAGIC); + CHECK_OBJ_NOTNULL(rhttp, HTTP_MAGIC); if (http1_splitline(hp, htc, HTTP1_Resp, cache_param->http_resp_hdr_len)) retval = 503; - if (retval == 0) { - hp->protover = http1_proto_ver(hp); - if (hp->protover == 0) - retval = 503; - rv = http1_proto_ver(req); - if (hp->protover > rv) - hp->protover = rv; - } + if (retval == 0 && hp->protover < 10) + retval = 503; + + if (retval == 0 && hp->protover > rhttp->protover) + http_SetH(hp, HTTP_HDR_PROTO, rhttp->hd[HTTP_HDR_PROTO].b); if (retval == 0 && Tlen(hp->hd[HTTP_HDR_STATUS]) != 3) retval = 503; diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index 1a11609..3148751 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -471,7 +471,6 @@ h2_rx_headers(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) } VSLb_ts_req(req, "Req", req->t_req); http_SetH(req->http, HTTP_HDR_PROTO, "HTTP/2.0"); - req->http->protover = 20; if (h2->rxf_flags & H2FF_HEADERS_END_STREAM) req->req_body_status = REQ_BODY_NONE; @@ -821,7 +820,6 @@ h2_new_ou_session(struct worker *wrk, struct h2_sess *h2, req->task.priv = req; req->err_code = 0; http_SetH(req->http, HTTP_HDR_PROTO, "HTTP/2.0"); - req->http->protover = 20; XXXAZ(Pool_Task(wrk->pool, &req->task, TASK_QUEUE_REQ)); /* Wait for PRISM response */ diff --git a/bin/varnishtest/tests/t02006.vtc b/bin/varnishtest/tests/t02006.vtc index d8354b9..1fd54e1 100644 --- a/bin/varnishtest/tests/t02006.vtc +++ b/bin/varnishtest/tests/t02006.vtc @@ -2,6 +2,7 @@ varnishtest "H2 POST w/ 100 Continue" server s1 { rxreq + expect req.proto == HTTP/1.1 txresp -hdr "Content-Type: text/plain" -body response } -start From phk at FreeBSD.org Tue Feb 28 23:31:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 01 Mar 2017 00:31:05 +0100 Subject: [master] 213939a Don't issue Unset VSL records for the three top-line fields. Message-ID: commit 213939a3cf03172b896e4705dcec2e486da5bc5a Author: Poul-Henning Kamp Date: Tue Feb 28 23:30:01 2017 +0000 Don't issue Unset VSL records for the three top-line fields. diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c index c200e24..0c1487d 100644 --- a/bin/varnishd/cache/cache_http.c +++ b/bin/varnishd/cache/cache_http.c @@ -798,7 +798,8 @@ http_ForceField(struct http *to, unsigned n, const char *t) if (to->hd[n].b == NULL || strcmp(to->hd[n].b, t)) { i = (HTTP_HDR_UNSET - HTTP_HDR_METHOD); i += to->logtag; - VSLbt(to->vsl, (enum VSL_tag_e)i, to->hd[n]); + if (n >= HTTP_HDR_FIRST) + VSLbt(to->vsl, (enum VSL_tag_e)i, to->hd[n]); http_SetH(to, n, t); } } diff --git a/bin/varnishtest/tests/r01662.vtc b/bin/varnishtest/tests/r01662.vtc index 84d4800..d8eb01c 100644 --- a/bin/varnishtest/tests/r01662.vtc +++ b/bin/varnishtest/tests/r01662.vtc @@ -13,9 +13,7 @@ varnish v1 -vcl+backend { logexpect l1 -v v1 -g request { expect * 1001 ReqMethod "HEAD" expect * = ReqProtocol "HTTP/1.0" - expect * 1002 BereqUnset "HEAD" - expect 0 = BereqMethod "GET" - expect * = BereqUnset "HTTP/1.0" + expect * 1002 BereqMethod "GET" expect 0 = BereqProtocol "HTTP/1.1" } -start