From phk at FreeBSD.org Mon Jul 1 07:24:09 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 1 Jul 2019 07:24:09 +0000 (UTC) Subject: [master] 4110be9a2 Make SETTINGS_MAX automatically track the settings we have implemented Message-ID: <20190701072409.4A7D0640DD@lists.varnish-cache.org> commit 4110be9a23eedede734101670cc62c5cb5dac08d Author: Poul-Henning Kamp Date: Mon Jul 1 07:22:39 2019 +0000 Make SETTINGS_MAX automatically track the settings we have implemented Not really spotted by: Coverity diff --git a/bin/varnishtest/vtc_http2.c b/bin/varnishtest/vtc_http2.c index 41baa8803..74cea13bb 100644 --- a/bin/varnishtest/vtc_http2.c +++ b/bin/varnishtest/vtc_http2.c @@ -61,8 +61,6 @@ static const char *const h2_types[] = { NULL }; -#define SETTINGS_MAX 0x06 - static const char * const h2_settings[] = { [0] = "unknown", #define H2_SETTING(U,l,v,...) [v] = #U, @@ -70,6 +68,9 @@ static const char * const h2_settings[] = { NULL }; +#define SETTINGS_MAX (sizeof(h2_settings)/sizeof(h2_settings[0]) - 1U) + + enum h2_type { #define H2_FRAME(l,u,t,f,...) TYPE_##u = t, #include @@ -569,8 +570,8 @@ static void parse_settings(const struct stream *s, struct frame *f) { struct http *hp; - int t, v; - unsigned u; + int v; + unsigned u, t; const char *buf; enum hpk_result r; CHECK_OBJ_NOTNULL(f, FRAME_MAGIC); @@ -600,7 +601,7 @@ parse_settings(const struct stream *s, struct frame *f) assert(r == hpk_done); } - vtc_log(hp->vl, 4, "settings->%s (%d): %d", buf, t, v); + vtc_log(hp->vl, 4, "settings->%s (%u): %d", buf, t, v); } } From fgsch at lodoss.net Mon Jul 1 11:06:07 2019 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Mon, 1 Jul 2019 11:06:07 +0000 (UTC) Subject: [master] 33c9692f1 Polish Message-ID: <20190701110607.E775593793@lists.varnish-cache.org> commit 33c9692f11128c8df03c9284ac599f9f725a5ecf Author: Federico G. Schwindt Date: Mon Jul 1 11:15:54 2019 +0100 Polish diff --git a/bin/varnishtest/vtc_main.c b/bin/varnishtest/vtc_main.c index a65c26df9..ac21b1000 100644 --- a/bin/varnishtest/vtc_main.c +++ b/bin/varnishtest/vtc_main.c @@ -569,8 +569,8 @@ ip_magic(void) sa = VSS_ResolveOne(NULL, "127.0.0.1", "0", 0, SOCK_STREAM, 0); AN(sa); bad_backend_fd = VTCP_bind(sa, NULL); - free(sa); assert(bad_backend_fd >= 0); + free(sa); VTCP_myname(bad_backend_fd, abuf, sizeof abuf, pbuf, sizeof(pbuf)); extmacro_def("localhost", "%s", abuf); From fgsch at lodoss.net Mon Jul 1 11:06:08 2019 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Mon, 1 Jul 2019 11:06:08 +0000 (UTC) Subject: [master] bb8e3ec75 Adjust for other OS Message-ID: <20190701110608.0A1AD93799@lists.varnish-cache.org> commit bb8e3ec75924264ee1e417540bf4f1a387c7301b Author: Federico G. Schwindt Date: Mon Jul 1 11:16:05 2019 +0100 Adjust for other OS diff --git a/.envrc b/.envrc index ff965d222..79286502e 100644 --- a/.envrc +++ b/.envrc @@ -1,4 +1,5 @@ -export ASAN_OPTIONS=abort_on_error=1,detect_odr_violation=1,detect_leaks=0,detect_stack_use_after_return=1,detect_invalid_pointer_pairs=1,handle_segv=0,handle_sigbus=0,use_sigaltstack=0,disable_coredump=0 +DETECT_LEAKS=$(test $(uname) = "Darwin"; echo $?) +export ASAN_OPTIONS=abort_on_error=1,detect_odr_violation=1,detect_leaks=$DETECT_LEAKS,detect_stack_use_after_return=1,detect_invalid_pointer_pairs=1,handle_segv=0,handle_sigbus=0,use_sigaltstack=0,disable_coredump=0 export LSAN_OPTIONS=abort_on_error=1,use_sigaltstack=0,suppressions=$(pwd)/tools/lsan.suppr export TSAN_OPTIONS=abort_on_error=1,halt_on_error=1,use_sigaltstack=0,suppressions=$(pwd)/tools/tsan.suppr export UBSAN_OPTIONS=halt_on_error=1,print_stacktrace=1,use_sigaltstack=0,suppressions=$(pwd)/tools/ubsan.suppr From dridi.boukelmoune at gmail.com Tue Jul 2 14:04:07 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 2 Jul 2019 14:04:07 +0000 (UTC) Subject: [master] 64c0e1aec Ensure that we always log h2 idle_send_timeout Message-ID: <20190702140408.048AA61F90@lists.varnish-cache.org> commit 64c0e1aec5145dd1c977f6e53e84e54288447855 Author: Dridi Boukelmoune Date: Thu Jun 27 09:49:27 2019 +0200 Ensure that we always log h2 idle_send_timeout diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index e9e626ac1..527fb8e61 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -975,11 +975,17 @@ h2_stream_tmo(struct h2_sess *h2, const struct h2_req *r2, vtim_real now) CHECK_OBJ_NOTNULL(r2, H2_REQ_MAGIC); Lck_AssertHeld(&h2->sess->mtx); + /* NB: when now is NAN, it means that idle_send_timeout was hit + * on a lock condwait operation. + */ + if (isnan(now)) + AN(r2->t_winupd); + if (r2->t_winupd == 0 && r2->t_send == 0) return (0); - if (r2->t_winupd != 0 && - now - r2->t_winupd > cache_param->idle_send_timeout) { + if (isnan(now) || (r2->t_winupd != 0 && + now - r2->t_winupd > cache_param->idle_send_timeout)) { VSLb(h2->vsl, SLT_Debug, "H2: stream %u: Hit idle_send_timeout waiting for" " WINDOW_UPDATE", r2->stream); diff --git a/bin/varnishd/http2/cache_http2_send.c b/bin/varnishd/http2/cache_http2_send.c index 6b2a34935..87b3ceb00 100644 --- a/bin/varnishd/http2/cache_http2_send.c +++ b/bin/varnishd/http2/cache_http2_send.c @@ -58,21 +58,29 @@ h2_cond_wait(pthread_cond_t *cond, struct h2_sess *h2, struct h2_req *r2) when = now + cache_param->idle_send_timeout; r = Lck_CondWait(cond, &h2->sess->mtx, when); + assert(r == 0 || r == ETIMEDOUT); now = VTIM_real(); + /* NB: when we grab idle_send_timeout before acquiring the session * lock we may time out, but once we wake up both send_timeout and * idle_send_timeout may have changed meanwhile. For this reason - * h2_stream_tmo() may not log what timed out and we need to check - * both conditions to decide whether we cancel the stream or not. + * h2_stream_tmo() may not log what timed out and we need to call + * again with a magic NAN "now" that indicates to h2_stream_tmo() + * that the stream reached the idle_send_timeout via the lock and + * force it to log it. */ - if (h2_stream_tmo(h2, r2, now) || r == ETIMEDOUT) { + if (h2_stream_tmo(h2, r2, now)) + r = ETIMEDOUT; + else if (r == ETIMEDOUT) + AN(h2_stream_tmo(h2, r2, NAN)); + + if (r == ETIMEDOUT) { if (r2->error == NULL) r2->error = H2SE_CANCEL; return (-1); } - AZ(r); return (0); } diff --git a/bin/varnishtest/tests/t02016.vtc b/bin/varnishtest/tests/t02016.vtc index 05ad99616..29ffea354 100644 --- a/bin/varnishtest/tests/t02016.vtc +++ b/bin/varnishtest/tests/t02016.vtc @@ -8,6 +8,8 @@ server s1 { varnish v1 -cliok "param.set feature +http2" varnish v1 -vcl+backend "" -start +# coverage for send_timeout with c1 + varnish v1 -cliok "param.set send_timeout 1" logexpect l1 -v v1 { @@ -42,6 +44,8 @@ client c1 { logexpect l1 -wait +# coverage for idle_send_timeout with c2 + varnish v1 -cliok "param.set idle_send_timeout 1" varnish v1 -cliok "param.reset send_timeout" @@ -74,3 +78,42 @@ client c2 { } -run logexpect l2 -wait + +# coverage for idle_send_timeout change with c3 + +barrier b3 cond 2 + +logexpect l3 -v v1 { + expect * * Debug "Hit idle_send_timeout" +} -start + +client c3 { + txpri + + stream 0 { + rxsettings + expect settings.ack == false + txsettings -ack + txsettings -winsize 1000 + rxsettings + expect settings.ack == true + } -run + + stream 1 { + txreq + rxhdrs + rxdata + # keep the stream idle for 2 seconds + barrier b3 sync + delay 2 + rxrst + expect rst.err == CANCEL + } -run + +} -start + +barrier b3 sync +varnish v1 -cliok "param.reset idle_send_timeout" + +client c3 -wait +logexpect l3 -wait From dridi.boukelmoune at gmail.com Wed Jul 3 10:20:11 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 3 Jul 2019 10:20:11 +0000 (UTC) Subject: [master] b69cbd09f Be more inclusive, 6.0 has strands too Message-ID: <20190703102011.8E270AFD18@lists.varnish-cache.org> commit b69cbd09f6336db5cf5c7d3d34584e53afa91da7 Author: Dridi Boukelmoune Date: Wed Jul 3 12:18:13 2019 +0200 Be more inclusive, 6.0 has strands too diff --git a/doc/sphinx/reference/vmod.rst b/doc/sphinx/reference/vmod.rst index f069d10b1..d2340cfc5 100644 --- a/doc/sphinx/reference/vmod.rst +++ b/doc/sphinx/reference/vmod.rst @@ -398,7 +398,7 @@ STEVEDORE STRING_LIST C-type: ``const char *, ...`` - `Notice: New vmod developments for 6.1 and later must + `Notice: New vmod developments for 6.0 LTS and later must use STRANDS instead of STRING_LIST, which is going away.` A multi-component text-string. We try very hard to avoid From dridi.boukelmoune at gmail.com Wed Jul 3 14:40:10 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 3 Jul 2019 14:40:10 +0000 (UTC) Subject: [6.0] ca63271d6 Add VRT functions for STRANDS. Message-ID: <20190703144010.485C67FE1@lists.varnish-cache.org> commit ca63271d6b862ec33c03c41e64f971eb89c6469a Author: Geoff Simmons Date: Thu Jul 19 17:03:30 2018 +0200 Add VRT functions for STRANDS. Re-implementations of the current functions for STRING_LIST. Closes #2733 Conflicts: include/vrt.h lib/libvmod_debug/vmod.vcc lib/libvmod_debug/vmod_debug.c This introduces VRT 7.1 for the 6.0 releases. diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c index 4ff427f35..28ca3d8fd 100644 --- a/bin/varnishd/cache/cache_vrt.c +++ b/bin/varnishd/cache/cache_vrt.c @@ -344,6 +344,117 @@ VRT_CollectString(VRT_CTX, const char *p, ...) return (b); } +/*-------------------------------------------------------------------- + * Collapse STRANDS into the space provided, or return NULL + */ + +char * +VRT_Strands(char *d, size_t dl, VCL_STRANDS s) +{ + char *b; + const char *e; + unsigned x; + + AN(d); + AN(s); + b = d; + e = b + dl; + for (int i = 0; i < s->n && b < e; i++) + if (s->p[i] != NULL && *s->p[i] != '\0') { + x = strlen(s->p[i]); + if (b + x < e) + memcpy(b, s->p[i], x); + b += x; + } + if (b >= e) + return (NULL); + *b++ = '\0'; + return (b); +} + +/*-------------------------------------------------------------------- + * Copy and merge STRANDS into a workspace. + */ + +VCL_STRING +VRT_StrandsWS(struct ws *ws, const char *h, VCL_STRANDS s) +{ + char *b; + const char *q = NULL, *e; + VCL_STRING r; + unsigned u, x; + int i; + + AN(s); + u = WS_Reserve(ws, 0); + + for (i = 0; i < s->n; i++) + if (s->p[i] != NULL && *s->p[i] != '\0') { + q = s->p[i]; + break; + } + + if (h != NULL && q == NULL && WS_Inside(ws, h, NULL)) { + WS_Release(ws, 0); + return (h); + } + + if (h == NULL) { + if (q == NULL) { + WS_Release(ws, 0); + return (""); + } + if (WS_Inside(ws, q, NULL)) { + for (i++; i < s->n; i++) + if (s->p[i] != NULL && *s->p[i] != '\0') + break; + if (i == s->n) { + WS_Release(ws, 0); + return (q); + } + } + } + + b = WS_Front(ws); + e = b + u; + + if (h != NULL) { + x = strlen(h); + if (b + x < e) + memcpy(b, h, x); + b += x; + if (b < e) + *b = ' '; + b++; + } + r = VRT_Strands(b, e > b ? e - b : 0, s); + if (r == NULL || r == e) { + WS_MarkOverflow(ws); + WS_Release(ws, 0); + return (NULL); + } + b = WS_Front(ws); + WS_Release(ws, r - b); + return (b); +} + +/*-------------------------------------------------------------------- + * Copy and merge STRANDS on the current workspace + */ + +VCL_STRING +VRT_CollectStrands(VRT_CTX, VCL_STRANDS s) +{ + const char *b; + + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + CHECK_OBJ_NOTNULL(ctx->ws, WS_MAGIC); + b = VRT_StrandsWS(ctx->ws, NULL, s); + if (b == NULL) + VRT_fail(ctx, "Workspace overflow"); + return (b); +} + /*--------------------------------------------------------------------*/ VCL_VOID diff --git a/bin/varnishtest/tests/v00058.vtc b/bin/varnishtest/tests/v00058.vtc new file mode 100644 index 000000000..d76e3d397 --- /dev/null +++ b/bin/varnishtest/tests/v00058.vtc @@ -0,0 +1,167 @@ +varnishtest "Test VRT STRANDS functions" + +varnish v1 -arg "-i foobar" -vcl { + import debug; + backend b { .host = "${bad_ip}"; } + + sub vcl_init { + # tests VRT_Strands() + new c = debug.concat(server.identity + server.hostname + now); + new e = debug.concat("" + server.identity + ""); + } + + sub vcl_recv { + return (synth(200)); + } + + sub vcl_synth { + set resp.http.C = c.get(); + set resp.http.E = e.get(); + + set req.http.Foo = "foo"; + set req.http.Bar = "bar"; + set req.http.Baz = "baz"; + + # test VRT_StrandsWS() + set resp.http.Concat-1 + = debug.concatenate(req.http.Foo + req.http.Bar + + req.http.Baz); + set resp.http.Concat-2 + = debug.concatenate("" + req.http.Unset + req.http.Foo + + req.http.Unset + "" + + req.http.Bar + "" + + req.http.Unset + "" + + req.http.Baz + "" + + req.http.Unset); + set resp.http.Concat-3 + = debug.concatenate(req.http.Foo + req.http.Unset + ""); + set resp.http.Concat-4 + = debug.concatenate(req.http.Unset + "" + req.http.Foo); + set resp.http.Concat-5 + = debug.concatenate(req.http.Foo + req.http.Unset + + req.http.Bar); + set resp.http.Concat-6 = debug.concatenate(req.http.Foo); + set resp.http.Concat-7 = debug.concatenate(req.http.Unset); + + # test VRT_StrandsCollect() + set resp.http.Collect-1 + = debug.collect(req.http.Foo + req.http.Bar + + req.http.Baz); + set resp.http.Collect-2 + = debug.collect("" + req.http.Unset + req.http.Foo + + req.http.Unset + "" + req.http.Bar + + "" + req.http.Unset + "" + + req.http.Baz + "" + req.http.Unset); + set resp.http.Collect-3 + = debug.collect(req.http.Foo + req.http.Unset + ""); + set resp.http.Collect-4 + = debug.collect(req.http.Unset + "" + req.http.Foo); + set resp.http.Collect-5 + = debug.collect(req.http.Foo + req.http.Unset + + req.http.Bar); + set resp.http.Collect-6 = debug.collect(req.http.Foo); + set resp.http.Collect-7 = debug.collect(req.http.Unset); + + # test a STRANDS version of VRT_SetHdr() + debug.sethdr(resp.http.Hdr-1, req.http.Foo + req.http.Bar + + req.http.Baz); + debug.sethdr(resp.http.Hdr-2, + "" + req.http.Unset + req.http.Foo + + req.http.Unset + "" + req.http.Bar + "" + + req.http.Unset + "" + req.http.Baz + "" + + req.http.Unset); + debug.sethdr(resp.http.Hdr-3, + req.http.Foo + req.http.Unset + ""); + debug.sethdr(resp.http.Hdr-4, + req.http.Unset + "" + req.http.Foo); + debug.sethdr(resp.http.Hdr-5, + req.http.Foo + req.http.Unset + req.http.Bar); + debug.sethdr(resp.http.Hdr-6, req.http.Foo); + debug.sethdr(resp.http.Hdr-7, req.http.Unset); + } +} -start + +client c1 { + txreq + rxresp + expect resp.status == 200 + expect resp.http.C ~ "^foobar" + expect resp.http.E == "foobar" + expect resp.http.Concat-1 == "foobarbaz" + expect resp.http.Concat-2 == "foobarbaz" + expect resp.http.Concat-3 == "foo" + expect resp.http.Concat-4 == "foo" + expect resp.http.Concat-5 == "foobar" + expect resp.http.Concat-6 == "foo" + expect resp.http.Concat-7 == "" + expect resp.http.Collect-1 == "foobarbaz" + expect resp.http.Collect-2 == "foobarbaz" + expect resp.http.Collect-3 == "foo" + expect resp.http.Collect-4 == "foo" + expect resp.http.Collect-5 == "foobar" + expect resp.http.Collect-6 == "foo" + expect resp.http.Collect-7 == "" + expect resp.http.Hdr-1 == "foobarbaz" + expect resp.http.Hdr-2 == "foobarbaz" + expect resp.http.Hdr-3 == "foo" + expect resp.http.Hdr-4 == "foo" + expect resp.http.Hdr-5 == "foobar" + expect resp.http.Hdr-6 == "foo" + expect resp.http.Hdr-7 == "" +} -run + +# out of workspace +server s1 { + rxreq + expect req.http.Foo == "foo" + expect req.http.Bar == "bar" + expect req.http.Baz == "baz" + expect req.http.Quux == "quux" + expect req.http.Result == + txresp +} -start + +varnish v1 -vcl+backend { + import debug; + import vtc; + + sub vcl_recv { + set req.http.Foo = "foo"; + set req.http.Bar = "bar"; + set req.http.Baz = "baz"; + set req.http.Quux = "quux"; + + vtc.workspace_alloc(client, -12); + + if (req.url == "/1") { + # VRT_StrandsWS() marks the WS as overflowed, + # returns NULL, but does not invoke VCL failure. + # Out-of-workspace doesn't happen until delivery. + set req.http.Result + = debug.concatenate(req.http.Foo + req.http.Bar + + req.http.Baz + + req.http.Quux); + } + elsif (req.url == "/2") { + # VRT_CollectStrands() invokes VCL failure. + set req.http.Result + = debug.collect(req.http.Foo + req.http.Bar + + req.http.Baz + + req.http.Quux); + } + } +} + +client c1 { + txreq -url "/1" + rxresp + expect resp.status == 500 + expect resp.reason == "Internal Server Error" +} -run + +client c1 { + txreq -url "/2" + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" +} -run diff --git a/include/vrt.h b/include/vrt.h index 53c4b773d..f48df152e 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -52,6 +52,11 @@ * binary/load-time compatible, increment MAJOR version * * + * 7.1 (unreleased) + * VRT_Strands() added + * VRT_StrandsWS() added + * VRT_CollectStrands() added + * VRT_STRANDS_string() removed from vrt.h (never implemented) * 7.0 (2018-03-15) * lots of stuff moved from cache.h to cache_varnishd.h * (ie: from "$Abi vrt" to "$Abi strict") @@ -100,7 +105,7 @@ #define VRT_MAJOR_VERSION 7U -#define VRT_MINOR_VERSION 0U +#define VRT_MINOR_VERSION 1U /***********************************************************************/ @@ -458,6 +463,9 @@ VCL_STEVEDORE VRT_stevedore(const char *nm); VCL_STRANDS VRT_BundleStrands(int, struct strands *, char const **, const char *f, ...); int VRT_CompareStrands(VCL_STRANDS a, VCL_STRANDS b); +char *VRT_Strands(char *, size_t, VCL_STRANDS); +VCL_STRING VRT_StrandsWS(struct ws *, const char *, VCL_STRANDS); +VCL_STRING VRT_CollectStrands(VRT_CTX, VCL_STRANDS); VCL_STRING VRT_BACKEND_string(VCL_BACKEND); VCL_STRING VRT_BOOL_string(VCL_BOOL); @@ -466,7 +474,6 @@ VCL_STRING VRT_INT_string(VRT_CTX, VCL_INT); VCL_STRING VRT_IP_string(VRT_CTX, VCL_IP); VCL_STRING VRT_REAL_string(VRT_CTX, VCL_REAL); VCL_STRING VRT_STEVEDORE_string(VCL_STEVEDORE); -VCL_STRING VRT_STRANDS_string(VCL_STRANDS); VCL_STRING VRT_TIME_string(VRT_CTX, VCL_TIME); #ifdef va_start // XXX: hackish diff --git a/lib/libvmod_debug/vmod.vcc b/lib/libvmod_debug/vmod.vcc index 969d38265..234be9e06 100644 --- a/lib/libvmod_debug/vmod.vcc +++ b/lib/libvmod_debug/vmod.vcc @@ -184,6 +184,29 @@ $Function VOID vsc_destroy() Remove a vsc +$Object concat(STRANDS) + +Create an object that returns the string formed by concatenating the +given strings. + +$Method STRING .get() + +Return the string formed from the concatenation in the constructor. + +$Function STRING concatenate(STRANDS) + +Return the string formed by concatenating the given strings. +(Uses VRT_StrandsWS().) + +$Function STRING collect(STRANDS) + +Return the string formed by concatenating the given strings. +(Uses VRT_CollectStrands().) + +$Function VOID sethdr(HEADER, STRANDS) + +Set the given header with the concatenation of the given strings. + $Object obj_opt(PRIV_CALL, PRIV_VCL, PRIV_TASK, [STRING s], [BOOL b]) diff --git a/lib/libvmod_debug/vmod_debug.c b/lib/libvmod_debug/vmod_debug.c index 75e310d54..ebc26f38d 100644 --- a/lib/libvmod_debug/vmod_debug.c +++ b/lib/libvmod_debug/vmod_debug.c @@ -415,6 +415,113 @@ xyzzy_vsc_destroy(VRT_CTX) AZ(pthread_mutex_unlock(&vsc_mtx)); } +struct xyzzy_debug_concat { + unsigned magic; +#define CONCAT_MAGIC 0x6b746493 + VCL_STRING s; +}; + +VCL_VOID +xyzzy_concat__init(VRT_CTX, struct xyzzy_debug_concat **concatp, + const char *vcl_name, VCL_STRANDS s) +{ + struct xyzzy_debug_concat *concat; + size_t sz = 0; + char *p; + + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + AN(concatp); + AZ(*concatp); + AN(vcl_name); + + ALLOC_OBJ(concat, CONCAT_MAGIC); + AN(concat); + *concatp = concat; + + for (int i = 0; i < s->n; i++) + if (s->p[i] != NULL) + sz += strlen(s->p[i]); + p = malloc(sz + 1); + AN(p); + (void)VRT_Strands(p, sz + 1, s); + concat->s = p; +} + +VCL_VOID +xyzzy_concat__fini(struct xyzzy_debug_concat **concatp) +{ + struct xyzzy_debug_concat *concat; + void *p; + + if (concatp == NULL || *concatp == NULL) + return; + CHECK_OBJ(*concatp, CONCAT_MAGIC); + concat = *concatp; + *concatp = NULL; + p = TRUST_ME(concat->s); + free(p); + FREE_OBJ(concat); +} + +VCL_STRING +xyzzy_concat_get(VRT_CTX, struct xyzzy_debug_concat *concat) +{ + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + CHECK_OBJ_NOTNULL(concat, CONCAT_MAGIC); + return (concat->s); +} + +VCL_STRING +xyzzy_concatenate(VRT_CTX, VCL_STRANDS s) +{ + VCL_STRING r; + + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + r = VRT_StrandsWS(ctx->ws, NULL, s); + if (r != NULL && *r != '\0') + WS_Assert_Allocated(ctx->ws, r, strlen(r) + 1); + return (r); +} + +VCL_STRING +xyzzy_collect(VRT_CTX, VCL_STRANDS s) +{ + VCL_STRING r; + + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + r = VRT_CollectStrands(ctx, s); + if (r != NULL && *r != '\0') + WS_Assert_Allocated(ctx->ws, r, strlen(r) + 1); + return (r); +} + +/* cf. VRT_SetHdr() */ +VCL_VOID +xyzzy_sethdr(VRT_CTX, VCL_HEADER hs, VCL_STRANDS s) +{ + struct http *hp; + const char *b; + + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + AN(hs); + AN(hs->what); + hp = VRT_selecthttp(ctx, hs->where); + CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC); + if (s->n == 0) { + http_Unset(hp, hs->what); + } else { + b = VRT_StrandsWS(hp->ws, hs->what + 1, s); + if (b == NULL) { + VSLb(ctx->vsl, SLT_LostHeader, "%s", hs->what + 1); + } else { + if (*b != '\0') + WS_Assert_Allocated(hp->ws, b, strlen(b) + 1); + http_Unset(hp, hs->what); + http_SetHeader(hp, b); + } + } +} + VCL_VOID xyzzy_store_ip(VRT_CTX, struct vmod_priv *priv, VCL_IP ip) { From dridi.boukelmoune at gmail.com Wed Jul 3 14:40:10 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 3 Jul 2019 14:40:10 +0000 (UTC) Subject: [6.0] 4f17aa8c8 VMOD blob uses STRANDS instead of STRING_LIST. Message-ID: <20190703144010.5F2EE7FE4@lists.varnish-cache.org> commit 4f17aa8c8076e84f7a43eda42b348b6b6552a3e6 Author: Geoff Simmons Date: Thu Aug 16 22:09:18 2018 +0200 VMOD blob uses STRANDS instead of STRING_LIST. Conflicts: lib/libvmod_blob/hex.c diff --git a/lib/libvmod_blob/base64.c b/lib/libvmod_blob/base64.c index 201702962..3bea94871 100644 --- a/lib/libvmod_blob/base64.c +++ b/lib/libvmod_blob/base64.c @@ -29,12 +29,12 @@ #include "config.h" #include -#include "base64.h" - #include "vdef.h" #include "vrt.h" #include "vas.h" +#include "base64.h" + #define base64_l(l) (((l) << 2) / 3) size_t @@ -133,7 +133,7 @@ base64_encode(const enum encoding enc, const enum case_e kase, ssize_t base64_decode(const enum encoding dec, char *restrict const buf, const size_t buflen, ssize_t inlen, - const char *const p, va_list ap) + const struct strands *restrict const strings) { const struct b64_alphabet *alpha = &b64_alphabet[dec]; char *dest = buf; @@ -143,12 +143,14 @@ base64_decode(const enum encoding dec, char *restrict const buf, AN(buf); AN(alpha); + AN(strings); if (inlen >= 0) len = inlen; - for (const char *s = p; len > 0 && s != vrt_magic_string_end; - s = va_arg(ap, const char *)) { + for (int i = 0; len > 0 && i < strings->n; i++) { + const char *s = strings->p[i]; + if (s == NULL) continue; if (*s && term) { diff --git a/lib/libvmod_blob/hex.c b/lib/libvmod_blob/hex.c index 614404d9e..adcf94b24 100644 --- a/lib/libvmod_blob/hex.c +++ b/lib/libvmod_blob/hex.c @@ -30,13 +30,14 @@ #include #include -#include "vmod_blob.h" #include "hex.h" #include "vdef.h" #include "vrt.h" #include "vas.h" +#include "vmod_blob.h" + const char hex_alphabet[][16] = { "0123456789abcdef", "0123456789ABCDEF" @@ -103,20 +104,20 @@ hex_encode(const enum encoding enc, const enum case_e kase, ssize_t hex_decode(const enum encoding dec, char *restrict const buf, const size_t buflen, ssize_t n, - const char *restrict const p, va_list ap) + const struct strands *restrict const strings) { char *dest = buf; const char *b; unsigned char extranib = 0; - size_t len = 0; - va_list ap2; + ssize_t len = 0; AN(buf); + AN(strings); assert(dec == HEX); - va_copy(ap2, ap); - for (const char *s = p; s != vrt_magic_string_end; - s = va_arg(ap2, const char *)) { + for (int i = 0; i < strings->n; i++) { + const char *s = strings->p[i]; + if (s == NULL) continue; b = s; @@ -128,7 +129,6 @@ hex_decode(const enum encoding dec, char *restrict const buf, } len += s - b; } - va_end(ap2); if (len == 0) return 0; @@ -144,8 +144,9 @@ hex_decode(const enum encoding dec, char *restrict const buf, len++; } - for (const char *s = p; len > 0 && s != vrt_magic_string_end; - s = va_arg(ap, const char *)) { + for (int i = 0; len > 0 && i < strings->n; i++) { + const char *s = strings->p[i]; + if (s == NULL || *s == '\0') continue; if (extranib) { diff --git a/lib/libvmod_blob/id.c b/lib/libvmod_blob/id.c index d10e64250..1164e983d 100644 --- a/lib/libvmod_blob/id.c +++ b/lib/libvmod_blob/id.c @@ -30,12 +30,12 @@ #include #include -#include "vmod_blob.h" - #include "vdef.h" #include "vrt.h" #include "vas.h" +#include "vmod_blob.h" + size_t id_encode_l(size_t l) { @@ -69,20 +69,21 @@ id_encode(const enum encoding enc, const enum case_e kase, ssize_t id_decode(const enum encoding enc, char *restrict const buf, const size_t buflen, - ssize_t n, const char *restrict const p, va_list ap) + ssize_t n, const struct strands *restrict const strings) { char *dest = buf; size_t outlen = 0, c = SIZE_MAX; (void) enc; AN(buf); + AN(strings); if (n >= 0) c = n; - for (const char *s = p; c > 0 && s != vrt_magic_string_end; - s = va_arg(ap, const char *)) { + for (int i = 0; c > 0 && i < strings->n; i++) { size_t len; + const char *s = strings->p[i]; if (s == NULL || *s == '\0') continue; diff --git a/lib/libvmod_blob/url.c b/lib/libvmod_blob/url.c index 84f5d0f22..acb55a6bb 100644 --- a/lib/libvmod_blob/url.c +++ b/lib/libvmod_blob/url.c @@ -29,13 +29,14 @@ #include "config.h" #include -#include "vmod_blob.h" #include "hex.h" #include "vdef.h" #include "vrt.h" #include "vas.h" +#include "vmod_blob.h" + /* Decoder states */ enum state_e { NORMAL, @@ -115,8 +116,8 @@ url_encode(const enum encoding enc, const enum case_e kase, ssize_t url_decode(const enum encoding dec, char *restrict const buf, - const size_t buflen, ssize_t n, const char *restrict const p, - va_list ap) + const size_t buflen, ssize_t n, + const struct strands *restrict const strings) { char *dest = buf; const char * const end = buf + buflen; @@ -125,13 +126,15 @@ url_decode(const enum encoding dec, char *restrict const buf, enum state_e state = NORMAL; AN(buf); + AN(strings); assert(dec == URL); if (n >= 0 && (size_t)n < len) len = n; - for (const char *s = p; len > 0 && s != vrt_magic_string_end; - s = va_arg(ap, const char *)) { + for (int i = 0; len > 0 && i < strings->n; i++) { + const char *s = strings->p[i]; + if (s == NULL || *s == '\0') continue; while (*s && len) { diff --git a/lib/libvmod_blob/vmod.vcc b/lib/libvmod_blob/vmod.vcc index 798989b52..1ea3716d4 100644 --- a/lib/libvmod_blob/vmod.vcc +++ b/lib/libvmod_blob/vmod.vcc @@ -176,7 +176,7 @@ affect alphabetic characters that are not percent-encoded. $Function BLOB decode(ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, HEX, URL} decoding="IDENTITY", INT length=0, - STRING_LIST encoded) + STRANDS encoded) Returns the BLOB derived from the string ``encoded`` according to the scheme specified by ``decoding``. @@ -231,7 +231,7 @@ $Function STRING transcode(ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, HEX, URL} encoding="IDENTITY", ENUM {LOWER, UPPER, DEFAULT} case="DEFAULT", - INT length=0, STRING_LIST encoded) + INT length=0, STRANDS encoded) Translates from one encoding to another, by first decoding the string ``encoded`` according to the scheme ``decoding``, and then returning @@ -300,7 +300,7 @@ BLOB. $Object blob(ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, HEX, URL} decoding="IDENTITY", - STRING_LIST encoded) + STRANDS encoded) Creates an object that contains the BLOB derived from the string ``encoded`` according to the scheme ``decoding``. diff --git a/lib/libvmod_blob/vmod_blob.c b/lib/libvmod_blob/vmod_blob.c index 08fd2ddf8..dfb03cafa 100644 --- a/lib/libvmod_blob/vmod_blob.c +++ b/lib/libvmod_blob/vmod_blob.c @@ -133,16 +133,15 @@ parse_case(VCL_ENUM e) static inline size_t -decode_l_va(enum encoding dec, const char * const p, va_list ap) +decode_l(enum encoding dec, VCL_STRANDS s) { size_t len = 0; AENC(dec); - for (const char *s = p; s != vrt_magic_string_end; - s = va_arg(ap, const char *)) - if (s != NULL && *s != '\0') - len += strlen(s); + for (int i = 0; i < s->n; i++) + if (s->p[i] != NULL && *s->p[i] != '\0') + len += strlen(s->p[i]); return(func[dec].decode_l(len)); } @@ -185,11 +184,10 @@ check_enc_case(VRT_CTX, VCL_ENUM encs, VCL_ENUM case_s, enum encoding enc, VCL_VOID v_matchproto_(td_blob_blob__init) vmod_blob__init(VRT_CTX, struct vmod_blob_blob **blobp, const char *vcl_name, - VCL_ENUM decs, const char *p, ...) + VCL_ENUM decs, VCL_STRANDS strings) { struct vmod_blob_blob *b; enum encoding dec = parse_encoding(decs); - va_list ap; ssize_t len; CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); @@ -197,6 +195,7 @@ vmod_blob__init(VRT_CTX, struct vmod_blob_blob **blobp, const char *vcl_name, AZ(*blobp); AN(vcl_name); AENC(dec); + AN(strings); ALLOC_OBJ(b, VMOD_BLOB_MAGIC); AN(b); @@ -204,9 +203,7 @@ vmod_blob__init(VRT_CTX, struct vmod_blob_blob **blobp, const char *vcl_name, b->blob.free = NULL; AZ(pthread_mutex_init(&b->lock, NULL)); - va_start(ap, p); - len = decode_l_va(dec, p, ap); - va_end(ap); + len = decode_l(dec, strings); if (len == 0) { b->blob.len = 0; b->blob.priv = NULL; @@ -220,17 +217,15 @@ vmod_blob__init(VRT_CTX, struct vmod_blob_blob **blobp, const char *vcl_name, return; } - va_start(ap, p); errno = 0; - len = func[dec].decode(dec, b->blob.priv, len, -1, p, ap); - va_end(ap); + len = func[dec].decode(dec, b->blob.priv, len, -1, strings); if (len == -1) { assert(errno == EINVAL); free(b->blob.priv); b->blob.priv = NULL; VERR(ctx, "cannot create blob %s, illegal encoding beginning " - "with \"%s\"", vcl_name, p); + "with \"%s\"", vcl_name, strings->p[0]); return; } if (len == 0) { @@ -331,31 +326,10 @@ vmod_blob__fini(struct vmod_blob_blob **blobp) /* Functions */ -static inline const char * -find_nonempty_va(const char *restrict *p, va_list ap) -{ - const char *q; - - /* find first non-empty vararg */ - for (; *p == vrt_magic_string_end || *p == NULL || **p == '\0'; - *p = va_arg(ap, char *)) - if (*p == vrt_magic_string_end) - return (vrt_magic_string_end); - - /* find next non-empty vararg */ - for (q = va_arg(ap, const char *); - q != vrt_magic_string_end && (q == NULL || *q == '\0'); - q = va_arg(ap, const char *)) - ; - - return (q); -} - VCL_BLOB v_matchproto_(td_blob_decode) -vmod_decode(VRT_CTX, VCL_ENUM decs, VCL_INT length, const char *p, ...) +vmod_decode(VRT_CTX, VCL_ENUM decs, VCL_INT length, VCL_STRANDS strings) { enum encoding dec = parse_encoding(decs); - va_list ap; struct vmod_priv *b; char *buf; uintptr_t snap; @@ -364,6 +338,7 @@ vmod_decode(VRT_CTX, VCL_ENUM decs, VCL_INT length, const char *p, ...) CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); AENC(dec); + AN(strings); CHECK_OBJ_NOTNULL(ctx->ws, WS_MAGIC); snap = WS_Snapshot(ctx->ws); @@ -377,13 +352,11 @@ vmod_decode(VRT_CTX, VCL_ENUM decs, VCL_INT length, const char *p, ...) if (length <= 0) length = -1; - va_start(ap, p); errno = 0; - len = func[dec].decode(dec, buf, space, length, p, ap); - va_end(ap); + len = func[dec].decode(dec, buf, space, length, strings); if (len == -1) { - err_decode(ctx, p); + err_decode(ctx, strings->p[0]); WS_Release(ctx->ws, 0); WS_Reset(ctx->ws, snap); return NULL; @@ -450,17 +423,17 @@ vmod_encode(VRT_CTX, VCL_ENUM encs, VCL_ENUM case_s, VCL_BLOB b) VCL_STRING v_matchproto_(td_blob_transcode) vmod_transcode(VRT_CTX, VCL_ENUM decs, VCL_ENUM encs, VCL_ENUM case_s, - VCL_INT length, const char *p, ...) + VCL_INT length, VCL_STRANDS strings) { enum encoding dec = parse_encoding(decs); enum encoding enc = parse_encoding(encs); enum case_e kase = parse_case(case_s); - va_list ap; struct vmod_priv b; VCL_STRING r; CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(ctx->ws, WS_MAGIC); + AN(strings); AENC(dec); AENC(enc); @@ -472,9 +445,7 @@ vmod_transcode(VRT_CTX, VCL_ENUM decs, VCL_ENUM encs, VCL_ENUM case_s, * Allocate space for the decoded blob on the stack * ignoring the limitation imposed by n */ - va_start(ap, p); - size_t l = decode_l_va(dec, p, ap); - va_end(ap); + size_t l = decode_l(dec, strings); if (l == 0) return ""; /* XXX: handle stack overflow? */ @@ -484,39 +455,28 @@ vmod_transcode(VRT_CTX, VCL_ENUM decs, VCL_ENUM encs, VCL_ENUM case_s, if (length <= 0) length = -1; - va_start(ap, p); errno = 0; - b.len = func[dec].decode(dec, buf, l, length, p, ap); - va_end(ap); + b.len = func[dec].decode(dec, buf, l, length, strings); if (b.len == -1) { - err_decode(ctx, p); + err_decode(ctx, strings->p[0]); return NULL; } /* * If the encoding and decoding are the same, and the decoding was - * legal, just return the string, if there was only one in the - * STRING_LIST, or else the concatenated string. + * legal, just return the concatenated string. * For encodings with hex digits, we cannot assume the same result. * since the call may specify upper- or lower-case that differs * from the encoded string. */ - if (length == -1 && enc == dec && !encodes_hex(enc)) { - const char *q, *pp = p; - va_start(ap, p); - q = find_nonempty_va(&pp, ap); - va_end(ap); - - if (pp == vrt_magic_string_end) - return ""; - - if (q == vrt_magic_string_end) - return pp; - - r = VRT_String(ctx->ws, NULL, p, ap); - return r; - } + if (length == -1 && enc == dec && !encodes_hex(enc)) + /* + * Returns NULL and invokes VCL failure on workspace + * overflow. If there is only one string already in the + * workspace, then it is re-used. + */ + return (VRT_CollectStrands(ctx, strings)); r = encode(ctx, enc, kase, &b); return (r); diff --git a/lib/libvmod_blob/vmod_blob.h b/lib/libvmod_blob/vmod_blob.h index e47dff8e7..032f59986 100644 --- a/lib/libvmod_blob/vmod_blob.h +++ b/lib/libvmod_blob/vmod_blob.h @@ -26,8 +26,9 @@ * */ +/* vrt.h must be included before this header (for struct strands). */ + #include -#include #include enum encoding { @@ -86,19 +87,18 @@ ssize_t encode_f(const enum encoding enc, const enum case_e kase, /* * General interface for a decoder: decode the concatenation of strings - * in p and ap (obtained from a STRING_LIST) into buf, and return the - * length of decoded data. + * (obtained from STRANDS) into buf, and return the length of decoded + * data. * * dec: decoding enum (from parse_encoding.h) * buf: destination of the decoded data * buflen: maximum length available at buf * inlen: maximum length to read or -1 to read up to \0 - * p, ap: strings obtained from a VCL STRING_LIST + * strings: strings obtained from VCL STRANDS * - * The regions pointed to by buf and any of the strings in p or ap MUST - * NOT overlap (per restrict). - * Note that the p,ap list is terminated by vrt_magic_string_end, and - * any member of the list may be NULL or empty. + * The regions pointed to by buf and strings MUST NOT overlap (per + * restrict). + * Note that any member of the strings list may be NULL or empty. * * Returns: * -1, if there is insufficient space at buf, or if the decoding is @@ -110,7 +110,7 @@ ssize_t encode_f(const enum encoding enc, const enum case_e kase, typedef ssize_t decode_f(const enum encoding dec, char *restrict const buf, const size_t buflen, const ssize_t inlen, - const char *restrict const p, va_list ap); + const struct strands *restrict const strings); /* id.c */ len_f id_encode_l; From dridi.boukelmoune at gmail.com Wed Jul 3 14:40:10 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 3 Jul 2019 14:40:10 +0000 (UTC) Subject: [6.0] 8b34d1372 Fix showing STRANDS as STRING in the docs. Message-ID: <20190703144010.7A1D37FE7@lists.varnish-cache.org> commit 8b34d1372a564aeaa7d3af2a2d23db26787a45a0 Author: Geoff Simmons Date: Fri Aug 17 07:13:22 2018 +0200 Fix showing STRANDS as STRING in the docs. diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py index 92863055f..32d4e6f2e 100755 --- a/lib/libvcc/vmodtool.py +++ b/lib/libvcc/vmodtool.py @@ -246,14 +246,14 @@ class CType(object): assert w == "," def vcl(self): - if self.vt in ("STRING_LIST", "STRAND"): + if self.vt in ("STRING_LIST", "STRANDS"): return "STRING" if self.spec is None: return self.vt return self.vt + " {" + ", ".join(self.spec) + "}" def synopsis(self): - if self.vt in ("STRING_LIST", "STRAND"): + if self.vt in ("STRING_LIST", "STRANDS"): return "STRING" return self.vt From dridi.boukelmoune at gmail.com Wed Jul 3 14:40:10 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 3 Jul 2019 14:40:10 +0000 (UTC) Subject: [6.0] d231464fc more on STRANDS Message-ID: <20190703144010.9A85C7FEC@lists.varnish-cache.org> commit d231464fcd5f450fe8d1be0a381d304fd3ad51d5 Author: Nils Goroll Date: Wed Sep 12 11:32:04 2018 +0200 more on STRANDS diff --git a/doc/sphinx/reference/vmod.rst b/doc/sphinx/reference/vmod.rst index f314527a6..8978ca4f2 100644 --- a/doc/sphinx/reference/vmod.rst +++ b/doc/sphinx/reference/vmod.rst @@ -390,6 +390,10 @@ STEVEDORE STRING_LIST C-type: ``const char *, ...`` + `Notice: New vmod developments for 6.1 and higher should + consider STRANDS as a better alternative to STRING_LIST, which + will eventually be replaced entirely.` + A multi-component text-string. We try very hard to avoid doing text-processing in Varnish, and this is one way we to avoid that, by not editing separate pieces of a string @@ -415,12 +419,8 @@ STRING_LIST NULL, as described under STRING, that is why we do not use NULL as the terminator. - Right now we only support STRING_LIST being the last argument to - a function, we may relax that at a latter time. - - If you don't want to bother with STRING_LIST, just use STRING - and make sure your workspace_client and workspace_backend params - are big enough. + STRING_LIST must be the last argument to a function and the + function must not contain optional arguments. STRANDS C-Type: ``const struct strands *`` From dridi.boukelmoune at gmail.com Wed Jul 3 14:40:10 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 3 Jul 2019 14:40:10 +0000 (UTC) Subject: [6.0] 9f72469f2 Make VCC not fail if you try to pass STRANDS to STRING_LIST. Message-ID: <20190703144010.BB9727FF0@lists.varnish-cache.org> commit 9f72469f249d13aa968c2a928f97490ed3d40544 Author: Poul-Henning Kamp Date: Fri Jan 4 10:15:59 2019 +0000 Make VCC not fail if you try to pass STRANDS to STRING_LIST. Strenghen the case against STRING_LIST in the docs. See also: #2873 Conflicts: lib/libvmod_debug/vmod.vcc diff --git a/bin/varnishtest/tests/m00000.vtc b/bin/varnishtest/tests/m00000.vtc index 355bb3c56..e7f1d4ad1 100644 --- a/bin/varnishtest/tests/m00000.vtc +++ b/bin/varnishtest/tests/m00000.vtc @@ -120,3 +120,10 @@ varnish v1 -errvcl {Expression has type STRING, expected REAL} { set resp.http.who = std.random("foo", "bar"); } } + +varnish v1 -errvcl {Cannot convert type STRING(STRANDS) to STRING(STRING_LIST)} { + import debug; + sub vcl_deliver { + set resp.http.who = debug.return_strands(req.url + "bar"); + } +} diff --git a/doc/sphinx/reference/vmod.rst b/doc/sphinx/reference/vmod.rst index 8978ca4f2..1897029ad 100644 --- a/doc/sphinx/reference/vmod.rst +++ b/doc/sphinx/reference/vmod.rst @@ -390,9 +390,8 @@ STEVEDORE STRING_LIST C-type: ``const char *, ...`` - `Notice: New vmod developments for 6.1 and higher should - consider STRANDS as a better alternative to STRING_LIST, which - will eventually be replaced entirely.` + `Notice: New vmod developments for 6.1 and later must + use STRANDS instead of STRING_LIST, which is going away.` A multi-component text-string. We try very hard to avoid doing text-processing in Varnish, and this is one way we diff --git a/lib/libvcc/vcc_expr.c b/lib/libvcc/vcc_expr.c index 2b3602bcb..61dca8e19 100644 --- a/lib/libvcc/vcc_expr.c +++ b/lib/libvcc/vcc_expr.c @@ -1312,7 +1312,14 @@ vcc_expr0(struct vcc *tl, struct expr **e, vcc_type_t fmt) else vcc_expr_cor(tl, e, fmt); ERRCHK(tl); - assert(!(*e)->fmt->stringform); + + if ((*e)->fmt->stringform) { + VSB_printf(tl->sb, "Cannot convert type %s(%s) to %s(%s)\n", + vcc_utype((*e)->fmt), (*e)->fmt->name, + vcc_utype(fmt), fmt->name); + vcc_ErrWhere2(tl, t1, tl->t); + return; + } if ((*e)->fmt != STRINGS && fmt->stringform) vcc_expr_tostring(tl, e, STRINGS); diff --git a/lib/libvmod_debug/vmod.vcc b/lib/libvmod_debug/vmod.vcc index 234be9e06..04d0088d9 100644 --- a/lib/libvmod_debug/vmod.vcc +++ b/lib/libvmod_debug/vmod.vcc @@ -217,6 +217,8 @@ $Method STRING .meth_opt(PRIV_CALL, PRIV_VCL, PRIV_TASK, Test object method with all the fancy stuff. +$Function STRANDS return_strands(STRANDS strand) + $Function VOID store_ip(PRIV_TASK, IP) Store an IP address to be later found by ``debug.get_ip()`` in the same diff --git a/lib/libvmod_debug/vmod_debug.c b/lib/libvmod_debug/vmod_debug.c index ebc26f38d..2ed000d64 100644 --- a/lib/libvmod_debug/vmod_debug.c +++ b/lib/libvmod_debug/vmod_debug.c @@ -548,3 +548,11 @@ xyzzy_get_ip(VRT_CTX, struct vmod_priv *priv) return (ip); } + +VCL_STRANDS +xyzzy_return_strands(VRT_CTX, VCL_STRANDS strand) +{ + + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + return (strand); +} From dridi.boukelmoune at gmail.com Wed Jul 3 14:40:10 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 3 Jul 2019 14:40:10 +0000 (UTC) Subject: [6.0] 272e043e3 Be more inclusive, 6.0 has strands too Message-ID: <20190703144010.DC99B7FF4@lists.varnish-cache.org> commit 272e043e3a6df2698f7af402785e783f4dd21e5e Author: Dridi Boukelmoune Date: Wed Jul 3 12:18:13 2019 +0200 Be more inclusive, 6.0 has strands too diff --git a/doc/sphinx/reference/vmod.rst b/doc/sphinx/reference/vmod.rst index 1897029ad..5630d625d 100644 --- a/doc/sphinx/reference/vmod.rst +++ b/doc/sphinx/reference/vmod.rst @@ -390,7 +390,7 @@ STEVEDORE STRING_LIST C-type: ``const char *, ...`` - `Notice: New vmod developments for 6.1 and later must + `Notice: New vmod developments for 6.0 LTS and later must use STRANDS instead of STRING_LIST, which is going away.` A multi-component text-string. We try very hard to avoid From dridi.boukelmoune at gmail.com Wed Jul 3 14:40:11 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 3 Jul 2019 14:40:11 +0000 (UTC) Subject: [6.0] 7388d4c13 Implement stringifcation of STRANDS via a workspace allocation. Message-ID: <20190703144011.099917FF8@lists.varnish-cache.org> commit 7388d4c1322b34ac71db812fe9666b7e8b4dcd74 Author: Poul-Henning Kamp Date: Wed Jan 9 10:44:55 2019 +0000 Implement stringifcation of STRANDS via a workspace allocation. When a VMOD returns a STRANDS, it is a requirement that the storage be stable, but that is not really different from any other type of return value. Completes #2873 diff --git a/bin/varnishtest/tests/m00000.vtc b/bin/varnishtest/tests/m00000.vtc index e7f1d4ad1..355bb3c56 100644 --- a/bin/varnishtest/tests/m00000.vtc +++ b/bin/varnishtest/tests/m00000.vtc @@ -120,10 +120,3 @@ varnish v1 -errvcl {Expression has type STRING, expected REAL} { set resp.http.who = std.random("foo", "bar"); } } - -varnish v1 -errvcl {Cannot convert type STRING(STRANDS) to STRING(STRING_LIST)} { - import debug; - sub vcl_deliver { - set resp.http.who = debug.return_strands(req.url + "bar"); - } -} diff --git a/bin/varnishtest/tests/v00058.vtc b/bin/varnishtest/tests/v00058.vtc index d76e3d397..1a3f9cbd8 100644 --- a/bin/varnishtest/tests/v00058.vtc +++ b/bin/varnishtest/tests/v00058.vtc @@ -78,6 +78,13 @@ varnish v1 -arg "-i foobar" -vcl { req.http.Foo + req.http.Unset + req.http.Bar); debug.sethdr(resp.http.Hdr-6, req.http.Foo); debug.sethdr(resp.http.Hdr-7, req.http.Unset); + + set resp.http.Hdr-8 = + debug.return_strands( + debug.return_strands( + req.url + "<-->" + req.url + ) + ); } } -start @@ -108,6 +115,7 @@ client c1 { expect resp.http.Hdr-5 == "foobar" expect resp.http.Hdr-6 == "foo" expect resp.http.Hdr-7 == "" + expect resp.http.Hdr-8 == "/<-->/" } -run # out of workspace @@ -141,8 +149,7 @@ varnish v1 -vcl+backend { = debug.concatenate(req.http.Foo + req.http.Bar + req.http.Baz + req.http.Quux); - } - elsif (req.url == "/2") { + } elsif (req.url == "/2") { # VRT_CollectStrands() invokes VCL failure. set req.http.Result = debug.collect(req.http.Foo + req.http.Bar diff --git a/lib/libvcc/vcc_expr.c b/lib/libvcc/vcc_expr.c index 61dca8e19..00b6ca700 100644 --- a/lib/libvcc/vcc_expr.c +++ b/lib/libvcc/vcc_expr.c @@ -186,8 +186,8 @@ vcc_expr_edit(struct vcc *tl, vcc_type_t fmt, const char *p, struct expr *e1, " const char * strs_%u_s[%d];\n", tl->unique, tl->unique, e3->nstr); VSB_printf(e->vsb, - "\v+\nVRT_BundleStrands(%d, &strs_%u_a, strs_%u_s," - "\v+\n%s,\nvrt_magic_string_end)\v-\v-", + "VRT_BundleStrands(%d, &strs_%u_a, strs_%u_s," + "\v+\n%s,\nvrt_magic_string_end\v-\n)", e3->nstr, tl->unique, tl->unique, VSB_data(e3->vsb)); tl->unique++; @@ -1313,6 +1313,12 @@ vcc_expr0(struct vcc *tl, struct expr **e, vcc_type_t fmt) vcc_expr_cor(tl, e, fmt); ERRCHK(tl); + if ((*e)->fmt == fmt) + return; + + if ((*e)->fmt != STRINGS && fmt->stringform) + vcc_expr_tostring(tl, e, STRINGS); + if ((*e)->fmt->stringform) { VSB_printf(tl->sb, "Cannot convert type %s(%s) to %s(%s)\n", vcc_utype((*e)->fmt), (*e)->fmt->name, @@ -1321,9 +1327,6 @@ vcc_expr0(struct vcc *tl, struct expr **e, vcc_type_t fmt) return; } - if ((*e)->fmt != STRINGS && fmt->stringform) - vcc_expr_tostring(tl, e, STRINGS); - if ((*e)->fmt == STRINGS && fmt->stringform) { if (fmt == STRING_LIST) (*e)->fmt = STRING_LIST; diff --git a/lib/libvcc/vcc_types.c b/lib/libvcc/vcc_types.c index 2e5660994..2d9208c64 100644 --- a/lib/libvcc/vcc_types.c +++ b/lib/libvcc/vcc_types.c @@ -138,6 +138,7 @@ const struct type STRANDS[1] = {{ .magic = TYPE_MAGIC, .name = "STRANDS", .stringform = 1, + .tostring = "VRT_CollectStrands(ctx,\v+\n\v1\v-\n)", }}; const struct type STRINGS[1] = {{ From dridi.boukelmoune at gmail.com Wed Jul 3 16:50:08 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 3 Jul 2019 16:50:08 +0000 (UTC) Subject: [master] 9c5e11fcd Code style OCD Message-ID: <20190703165008.E3C8D630F7@lists.varnish-cache.org> commit 9c5e11fcde41b83c9983905c0725f051eb929f7c Author: Dridi Boukelmoune Date: Wed Jul 3 17:55:02 2019 +0200 Code style OCD diff --git a/lib/libvmod_blob/base64.c b/lib/libvmod_blob/base64.c index 1ced6472f..d8ddd12c4 100644 --- a/lib/libvmod_blob/base64.c +++ b/lib/libvmod_blob/base64.c @@ -56,7 +56,7 @@ base64_decode_l(size_t l) static inline int decode(char *restrict *restrict dest, const char *restrict const buf, - const size_t buflen, unsigned u, const int n) + const size_t buflen, unsigned u, const int n) { char *d; @@ -79,8 +79,8 @@ decode(char *restrict *restrict dest, const char *restrict const buf, ssize_t base64_encode(const enum encoding enc, const enum case_e kase, - char *restrict const buf, const size_t buflen, - const char *restrict const inbuf, const size_t inlength) + char *restrict const buf, const size_t buflen, + const char *restrict const inbuf, const size_t inlength) { const struct b64_alphabet *alpha = &b64_alphabet[enc]; char *p = buf; @@ -131,8 +131,7 @@ base64_encode(const enum encoding enc, const enum case_e kase, ssize_t base64_decode(const enum encoding dec, char *restrict const buf, - const size_t buflen, ssize_t inlen, - const struct strands *restrict const strings) + const size_t buflen, ssize_t inlen, VCL_STRANDS strings) { const struct b64_alphabet *alpha = &b64_alphabet[dec]; char *dest = buf; diff --git a/lib/libvmod_blob/hex.c b/lib/libvmod_blob/hex.c index 79a44feb9..a06e3da22 100644 --- a/lib/libvmod_blob/hex.c +++ b/lib/libvmod_blob/hex.c @@ -27,9 +27,8 @@ */ #include "config.h" -#include -#include "hex.h" +#include #include "vdef.h" #include "vrt.h" @@ -37,6 +36,8 @@ #include "vmod_blob.h" +#include "hex.h" + const char hex_alphabet[][16] = { "0123456789abcdef", "0123456789ABCDEF" @@ -48,12 +49,12 @@ const char hex_alphabet[][16] = { * into 55 bytes (cacheline friendly). */ const uint8_t nibble[] = { - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, - ILL, ILL, ILL, ILL, ILL, ILL, ILL, 10, 11, 12, - 13, 14, 15, ILL, ILL, ILL, ILL, ILL, ILL, ILL, - ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, - ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, 10, - 11, 12, 13, 14, 15 + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, + ILL, ILL, ILL, ILL, ILL, ILL, ILL, 10, 11, 12, + 13, 14, 15, ILL, ILL, ILL, ILL, ILL, ILL, ILL, + ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, + ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, ILL, 10, + 11, 12, 13, 14, 15 }; size_t @@ -76,11 +77,12 @@ hex2byte(const unsigned char hi, const unsigned char lo) ssize_t hex_encode(const enum encoding enc, const enum case_e kase, - char *restrict const buf, const size_t buflen, - const char *restrict const in, const size_t inlen) + char *restrict const buf, const size_t buflen, + const char *restrict const in, const size_t inlen) { char *p = buf; const char *alphabet = hex_alphabet[0]; + int i; AN(buf); assert(enc == HEX); @@ -92,7 +94,7 @@ hex_encode(const enum encoding enc, const enum case_e kase, if (kase == UPPER) alphabet = hex_alphabet[1]; - for (int i = 0; i < inlen; i++) { + for (i = 0; i < inlen; i++) { *p++ = alphabet[(in[i] & 0xf0) >> 4]; *p++ = alphabet[in[i] & 0x0f]; } @@ -102,20 +104,20 @@ hex_encode(const enum encoding enc, const enum case_e kase, ssize_t hex_decode(const enum encoding dec, char *restrict const buf, - const size_t buflen, ssize_t n, - const struct strands *restrict const strings) + const size_t buflen, ssize_t n, VCL_STRANDS strings) { char *dest = buf; - const char *b; + const char *b, *s; unsigned char extranib = 0; size_t len = 0; + int i; AN(buf); AN(strings); assert(dec == HEX); - for (int i = 0; i < strings->n; i++) { - const char *s = strings->p[i]; + for (i = 0; i < strings->n; i++) { + s = strings->p[i]; if (s == NULL) continue; @@ -143,8 +145,8 @@ hex_decode(const enum encoding dec, char *restrict const buf, len++; } - for (int i = 0; len > 0 && i < strings->n; i++) { - const char *s = strings->p[i]; + for (i = 0; len > 0 && i < strings->n; i++) { + s = strings->p[i]; if (s == NULL || *s == '\0') continue; diff --git a/lib/libvmod_blob/id.c b/lib/libvmod_blob/id.c index e429db3ac..cc5efab4b 100644 --- a/lib/libvmod_blob/id.c +++ b/lib/libvmod_blob/id.c @@ -27,6 +27,7 @@ */ #include "config.h" + #include #include "vdef.h" @@ -49,8 +50,8 @@ id_decode_l(size_t l) ssize_t id_encode(const enum encoding enc, const enum case_e kase, - char *restrict const buf, const size_t buflen, - const char *restrict const in, const size_t inlen) + char *restrict const buf, const size_t buflen, + const char *restrict const in, const size_t inlen) { (void) enc; (void) kase; @@ -66,12 +67,12 @@ id_encode(const enum encoding enc, const enum case_e kase, } ssize_t -id_decode(const enum encoding enc, - char *restrict const buf, const size_t buflen, - ssize_t n, const struct strands *restrict const strings) +id_decode(const enum encoding enc, char *restrict const buf, + const size_t buflen, ssize_t n, VCL_STRANDS strings) { + const char *s; char *dest = buf; - size_t outlen = 0, c = SIZE_MAX; + size_t len, outlen = 0, c = SIZE_MAX; (void) enc; AN(buf); @@ -81,9 +82,7 @@ id_decode(const enum encoding enc, c = n; for (int i = 0; c > 0 && i < strings->n; i++) { - size_t len; - const char *s = strings->p[i]; - + s = strings->p[i]; if (s == NULL || *s == '\0') continue; len = strlen(s); diff --git a/lib/libvmod_blob/url.c b/lib/libvmod_blob/url.c index fd7245bb7..b038a556d 100644 --- a/lib/libvmod_blob/url.c +++ b/lib/libvmod_blob/url.c @@ -28,14 +28,14 @@ #include "config.h" -#include "hex.h" - #include "vdef.h" #include "vrt.h" #include "vas.h" #include "vmod_blob.h" +#include "hex.h" + /* Decoder states */ enum state_e { NORMAL, @@ -60,10 +60,10 @@ url_decode_l(size_t l) * (locale-independent and cacheline friendly) */ static const uint8_t unreserved[] = { - 0x0, 0x0, 0x0, 0x0, 0x0, 0x60, 0xff, 0x3, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0xff, 0x03, 0xfe, 0xff, 0xff, 0x87, 0xfe, 0xff, 0xff, 0x47, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; static inline int @@ -80,12 +80,13 @@ isoutofrange(const uint8_t c) ssize_t url_encode(const enum encoding enc, const enum case_e kase, - char *restrict const buf, const size_t buflen, - const char *restrict const in, const size_t inlen) + char *restrict const buf, const size_t buflen, + const char *restrict const in, const size_t inlen) { char *p = buf; const char * const end = buf + buflen; const char *alphabet = hex_alphabet[0]; + int i; AN(buf); assert(enc == URL); @@ -95,7 +96,7 @@ url_encode(const enum encoding enc, const enum case_e kase, if (kase == UPPER) alphabet = hex_alphabet[1]; - for (int i = 0; i < inlen; i++) { + for (i = 0; i < inlen; i++) { if (isunreserved(in[i])) { if (p == end) return (-1); @@ -115,14 +116,15 @@ url_encode(const enum encoding enc, const enum case_e kase, ssize_t url_decode(const enum encoding dec, char *restrict const buf, - const size_t buflen, ssize_t n, - const struct strands *restrict const strings) + const size_t buflen, ssize_t n, VCL_STRANDS strings) { char *dest = buf; const char * const end = buf + buflen; + const char *s; size_t len = SIZE_MAX; - uint8_t nib = 0; + uint8_t nib = 0, nib2; enum state_e state = NORMAL; + int i; AN(buf); AN(strings); @@ -131,14 +133,12 @@ url_decode(const enum encoding dec, char *restrict const buf, if (n >= 0) len = n; - for (int i = 0; len > 0 && i < strings->n; i++) { - const char *s = strings->p[i]; + for (i = 0; len > 0 && i < strings->n; i++) { + s = strings->p[i]; if (s == NULL || *s == '\0') continue; while (*s && len) { - uint8_t nib2; - switch (state) { case NORMAL: if (*s == '%') diff --git a/lib/libvmod_blob/vmod_blob.h b/lib/libvmod_blob/vmod_blob.h index 3b027480a..ad9f0c1f7 100644 --- a/lib/libvmod_blob/vmod_blob.h +++ b/lib/libvmod_blob/vmod_blob.h @@ -107,10 +107,8 @@ ssize_t encode_f(const enum encoding enc, const enum case_e kase, * a static constant empty BLOB * otherwise, the number of bytes written */ -typedef -ssize_t decode_f(const enum encoding dec, char *restrict const buf, - const size_t buflen, const ssize_t inlen, - const struct strands *restrict const strings); +typedef ssize_t decode_f(const enum encoding dec, char *restrict const buf, + const size_t buflen, const ssize_t inlen, VCL_STRANDS strings); /* id.c */ len_f id_encode_l; From dridi.boukelmoune at gmail.com Wed Jul 3 16:50:09 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 3 Jul 2019 16:50:09 +0000 (UTC) Subject: [master] bbf53b883 Simplify base64 decoding by killing a nested loop Message-ID: <20190703165009.06D6E630F9@lists.varnish-cache.org> commit bbf53b8839de37459264d0a99e9c6e6a4714e2d6 Author: Dridi Boukelmoune Date: Wed Jul 3 18:12:15 2019 +0200 Simplify base64 decoding by killing a nested loop With bonus code style OCD fixes. Better diff with the --ignore-all-space option. diff --git a/lib/libvmod_blob/base64.c b/lib/libvmod_blob/base64.c index d8ddd12c4..f900cbb76 100644 --- a/lib/libvmod_blob/base64.c +++ b/lib/libvmod_blob/base64.c @@ -134,11 +134,12 @@ base64_decode(const enum encoding dec, char *restrict const buf, const size_t buflen, ssize_t inlen, VCL_STRANDS strings) { const struct b64_alphabet *alpha = &b64_alphabet[dec]; + const char *s; char *dest = buf; unsigned u = 0, term = 0; - int n = 0; size_t len = SIZE_MAX; - const char *s; + int n = 0, i; + char b; AN(buf); AN(alpha); @@ -147,7 +148,7 @@ base64_decode(const enum encoding dec, char *restrict const buf, if (inlen >= 0) len = inlen; - for (int i = 0; len > 0 && i < strings->n; i++) { + for (i = 0; len > 0 && i < strings->n; i++) { s = strings->p[i]; if (s == NULL) @@ -157,24 +158,20 @@ base64_decode(const enum encoding dec, char *restrict const buf, return (-1); } while (*s && len) { - while (n < 4) { - char b = alpha->i64[(uint8_t) *s++]; - u <<= 6; - if (b == ILL) { - errno = EINVAL; - return (-1); - } - n++; - if (b == PAD) { - term++; - continue; - } - u |= (uint8_t) b; - if (--len == 0) - break; - if (!*s) - break; + b = alpha->i64[(uint8_t)*s]; + s++; + len--; + u <<= 6; + if (b == ILL) { + errno = EINVAL; + return (-1); + } + n++; + if (b == PAD) { + term++; + continue; } + u |= (uint8_t)b; if (n == 4) { if (decode(&dest, buf, buflen, u, n-term) < 0) return (-1); From dridi.boukelmoune at gmail.com Wed Jul 3 16:50:09 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 3 Jul 2019 16:50:09 +0000 (UTC) Subject: [master] 8790bec16 Move vtc.panic to STRANDS Message-ID: <20190703165009.322AC630FE@lists.varnish-cache.org> commit 8790bec16d68c2098dc99d9ed27819d24759648c Author: Dridi Boukelmoune Date: Wed Jul 3 17:57:12 2019 +0200 Move vtc.panic to STRANDS diff --git a/lib/libvmod_vtc/vmod.vcc b/lib/libvmod_vtc/vmod.vcc index ccff7b654..51154f366 100644 --- a/lib/libvmod_vtc/vmod.vcc +++ b/lib/libvmod_vtc/vmod.vcc @@ -70,7 +70,7 @@ $Function IP no_ip() Returns a null IP address, not even a bogo_ip. -$Function VOID panic(STRING_LIST) +$Function VOID panic(STRANDS) It can be useful to crash the child process in order to test the robustness of a VMOD. diff --git a/lib/libvmod_vtc/vmod_vtc.c b/lib/libvmod_vtc/vmod_vtc.c index c67b115eb..d349e565f 100644 --- a/lib/libvmod_vtc/vmod_vtc.c +++ b/lib/libvmod_vtc/vmod_vtc.c @@ -99,16 +99,13 @@ vmod_no_ip(VRT_CTX) /*--------------------------------------------------------------------*/ VCL_VOID v_matchproto_(td_vtc_panic) -vmod_panic(VRT_CTX, const char *str, ...) +vmod_panic(VRT_CTX, VCL_STRANDS str) { - va_list ap; const char *b; CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); - va_start(ap, str); - b = VRT_String(ctx->ws, "PANIC: ", str, ap); - va_end(ap); + b = VRT_StrandsWS(ctx->ws, "PANIC:", str); VAS_Fail("VCL", "", 0, b, VAS_VCL); } From dridi.boukelmoune at gmail.com Wed Jul 3 16:50:09 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 3 Jul 2019 16:50:09 +0000 (UTC) Subject: [master] 189a598eb Move directors.hash::backend to STRANDS Message-ID: <20190703165009.50F6263103@lists.varnish-cache.org> commit 189a598ebf1e78436a95678d7255c4d399458b26 Author: Dridi Boukelmoune Date: Wed Jul 3 18:45:02 2019 +0200 Move directors.hash::backend to STRANDS diff --git a/lib/libvmod_directors/hash.c b/lib/libvmod_directors/hash.c index a82e19fe3..897c5a567 100644 --- a/lib/libvmod_directors/hash.c +++ b/lib/libvmod_directors/hash.c @@ -108,29 +108,25 @@ vmod_hash_remove_backend(VRT_CTX, } VCL_BACKEND v_matchproto_() -vmod_hash_backend(VRT_CTX, struct vmod_directors_hash *rr, - const char *arg, ...) +vmod_hash_backend(VRT_CTX, struct vmod_directors_hash *rr, VCL_STRANDS s) { struct VSHA256Context sha_ctx; - va_list ap; const char *p; unsigned char sha256[VSHA256_LEN]; VCL_BACKEND be; double r; + int i; CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_ORNULL(ctx->bo, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(rr, VMOD_DIRECTORS_HASH_MAGIC); VSHA256_Init(&sha_ctx); - va_start(ap, arg); - p = arg; - while (p != vrt_magic_string_end) { + for (i = 0; i < s->n; i++) { + p = s->p[i]; if (p != NULL && *p != '\0') VSHA256_Update(&sha_ctx, p, strlen(p)); - p = va_arg(ap, const char *); } - va_end(ap); VSHA256_Final(sha256, &sha_ctx); r = vbe32dec(sha256); diff --git a/lib/libvmod_directors/vmod.vcc b/lib/libvmod_directors/vmod.vcc index 5bb6837f9..bafab18d6 100644 --- a/lib/libvmod_directors/vmod.vcc +++ b/lib/libvmod_directors/vmod.vcc @@ -217,7 +217,7 @@ Remove a backend from the director. Example:: vdir.remove_backend(backend1); -$Method BACKEND .backend(STRING_LIST) +$Method BACKEND .backend(STRANDS) Pick a backend from the backend director. From dridi.boukelmoune at gmail.com Thu Jul 4 10:21:09 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 4 Jul 2019 10:21:09 +0000 (UTC) Subject: [master] e006b1d65 Properly document SLT_Debug is masked by default Message-ID: <20190704102109.6AE79A5B14@lists.varnish-cache.org> commit e006b1d65357c4d70f2382fc886b04d77fb2064e Author: Dridi Boukelmoune Date: Thu Jul 4 11:47:03 2019 +0200 Properly document SLT_Debug is masked by default diff --git a/include/tbl/vsl_tags.h b/include/tbl/vsl_tags.h index 54e4c3f58..35e8221d2 100644 --- a/include/tbl/vsl_tags.h +++ b/include/tbl/vsl_tags.h @@ -53,6 +53,7 @@ SLTM(Debug, SLT_F_UNSAFE, "Debug messages", " be explicitly enabled with parameters.\n\n" "Debug messages may be added, changed or removed without" " prior notice and shouldn't be considered stable.\n\n" + NODEF_NOTICE ) SLTM(Error, 0, "Error messages", From dridi.boukelmoune at gmail.com Thu Jul 4 10:21:09 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 4 Jul 2019 10:21:09 +0000 (UTC) Subject: [master] 1737d15d7 Introduce a notice for past and future VSL records Message-ID: <20190704102109.8449BA5B17@lists.varnish-cache.org> commit 1737d15d7fa13002e8bcc7c1078e5b8bb7f98f9f Author: Dridi Boukelmoune Date: Thu Jul 4 11:51:26 2019 +0200 Introduce a notice for past and future VSL records diff --git a/include/tbl/vsl_tags.h b/include/tbl/vsl_tags.h index 35e8221d2..e54b06d99 100644 --- a/include/tbl/vsl_tags.h +++ b/include/tbl/vsl_tags.h @@ -47,6 +47,11 @@ #define NODEF_NOTICE \ "NB: This log record is masked by default.\n\n" +#define NOSUP_NOTICE \ + "\tNOTE: This tag is currently not in use in the Varnish log.\n" \ + "\tIt is mentioned here to document legacy versions of the log,\n" \ + "\tor reserved for possible use in future versions.\n\n" + SLTM(Debug, SLT_F_UNSAFE, "Debug messages", "Debug messages can normally be ignored, but are sometimes" " helpful during trouble-shooting. Most debug messages must" From dridi.boukelmoune at gmail.com Thu Jul 4 10:21:09 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 4 Jul 2019 10:21:09 +0000 (UTC) Subject: [master] 927b4633a Mark retired SLTs as not supported Message-ID: <20190704102109.A5745A5B1A@lists.varnish-cache.org> commit 927b4633ab597569bc0487234fd36158eb88d319 Author: Dridi Boukelmoune Date: Thu Jul 4 11:52:13 2019 +0200 Mark retired SLTs as not supported diff --git a/include/tbl/vsl_tags.h b/include/tbl/vsl_tags.h index e54b06d99..cb2c5ec76 100644 --- a/include/tbl/vsl_tags.h +++ b/include/tbl/vsl_tags.h @@ -47,6 +47,10 @@ #define NODEF_NOTICE \ "NB: This log record is masked by default.\n\n" +/* + * REL_20190915 remove after VSLng + * kept for now for VSL binary compatibility + */ #define NOSUP_NOTICE \ "\tNOTE: This tag is currently not in use in the Varnish log.\n" \ "\tIt is mentioned here to document legacy versions of the log,\n" \ @@ -157,10 +161,6 @@ SLTM(ProxyGarbage, 0, "Unparseable PROXY request", "A PROXY protocol header was unparseable.\n\n" ) -/* - * REL_20190915 remove after VSLng - * kept for now for VSL binary compatibility - */ SLTM(Backend, 0, "Backend selected", "Logged when a connection is selected for handling a backend" " request.\n\n" @@ -170,11 +170,8 @@ SLTM(Backend, 0, "Backend selected", "\t| | +- Backend display name\n" "\t| +---- VCL name\n" "\t+------- Connection file descriptor\n" - "\t\n" - "\tNOTE: This tag is currently not in use in the Varnish log.\n" - "\tIt is mentioned here to document legacy versions of the log,\n" - "\tand reserved for possible use in future versions.\n" "\n" + NOSUP_NOTICE ) SLTM(Length, 0, "Size of object body", @@ -602,11 +599,17 @@ SLTM(Witness, 0, "Lock order witness records", "Diagnostic recording of locking order.\n" ) -/* - * REL_20190915 remove after VSLng - * kept for now for VSL binary compatibility - */ -SLTM(BackendStart, 0, "(retired)", "") +SLTM(BackendStart, 0, "Backend request start", + "Start of backend processing. Logs the backend IP address and port" + " number.\n\n" + "The format is::\n\n" + "\t%s %s\n" + "\t| |\n" + "\t| +- Backend Port number\n" + "\t+---- Backend IP4/6 address\n" + "\n" + NOSUP_NOTICE +) SLTM(H2RxHdr, SLT_F_BINARY, "Received HTTP2 frame header", "Binary data" From dridi.boukelmoune at gmail.com Thu Jul 4 10:21:09 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 4 Jul 2019 10:21:09 +0000 (UTC) Subject: [master] 4126ed560 Make man make targets silent-able Message-ID: <20190704102109.C3F96A5B1F@lists.varnish-cache.org> commit 4126ed5603da394ca8b675e67d0dac5bff0d005a Author: Dridi Boukelmoune Date: Thu Jul 4 12:13:29 2019 +0200 Make man make targets silent-able diff --git a/man/Makefile.am b/man/Makefile.am index 0e35dc5bf..0226e7299 100644 --- a/man/Makefile.am +++ b/man/Makefile.am @@ -27,86 +27,88 @@ CLEANFILES = $(dist_man_MANS) RST2ANY_FLAGS = --halt=2 +BUILD_MAN = $(AM_V_GEN) $(RST2MAN) $(RST2ANY_FLAGS) + varnish-cli.7: $(top_builddir)/doc/sphinx/reference/varnish-cli.rst - ${RST2MAN} $(RST2ANY_FLAGS) $(top_srcdir)/doc/sphinx/reference/varnish-cli.rst $@ + $(BUILD_MAN) $(top_srcdir)/doc/sphinx/reference/varnish-cli.rst $@ varnish-counters.7: $(top_builddir)/doc/sphinx/reference/varnish-counters.rst - ${RST2MAN} $(RST2ANY_FLAGS) $(top_srcdir)/doc/sphinx/reference/varnish-counters.rst $@ + $(BUILD_MAN) $(top_srcdir)/doc/sphinx/reference/varnish-counters.rst $@ vcl.7: $(top_builddir)/doc/sphinx/reference/vcl.rst \ $(top_builddir)/bin/varnishd/builtin.vcl - ${RST2MAN} $(RST2ANY_FLAGS) $(top_srcdir)/doc/sphinx/reference/vcl.rst $@ + $(BUILD_MAN) $(top_srcdir)/doc/sphinx/reference/vcl.rst $@ vsl.7: $(top_builddir)/doc/sphinx/reference/vsl.rst \ $(top_builddir)/doc/sphinx/include/vsl-tags.rst - ${RST2MAN} $(RST2ANY_FLAGS) $(top_srcdir)/doc/sphinx/reference/vsl.rst $@ + $(BUILD_MAN) $(top_srcdir)/doc/sphinx/reference/vsl.rst $@ vsl-query.7: $(top_builddir)/doc/sphinx/reference/vsl-query.rst - ${RST2MAN} $(RST2ANY_FLAGS) $(top_srcdir)/doc/sphinx/reference/vsl-query.rst $@ + $(BUILD_MAN) $(top_srcdir)/doc/sphinx/reference/vsl-query.rst $@ varnishadm.1: $(top_builddir)/doc/sphinx/reference/varnishadm.rst - ${RST2MAN} $(RST2ANY_FLAGS) $(top_srcdir)/doc/sphinx/reference/varnishadm.rst $@ + $(BUILD_MAN) $(top_srcdir)/doc/sphinx/reference/varnishadm.rst $@ varnishd.1: \ $(top_builddir)/doc/sphinx/reference/varnishd.rst \ $(top_builddir)/doc/sphinx/include/params.rst - ${RST2MAN} $(RST2ANY_FLAGS) $(top_srcdir)/doc/sphinx/reference/varnishd.rst $@ + $(BUILD_MAN) $(top_srcdir)/doc/sphinx/reference/varnishd.rst $@ varnishncsa.1: \ $(top_builddir)/doc/sphinx/reference/varnishncsa.rst \ $(top_builddir)/doc/sphinx/include/varnishncsa_options.rst \ $(top_builddir)/doc/sphinx/include/varnishncsa_synopsis.rst - ${RST2MAN} $(RST2ANY_FLAGS) $(top_srcdir)/doc/sphinx/reference/varnishncsa.rst $@ + $(BUILD_MAN) $(top_srcdir)/doc/sphinx/reference/varnishncsa.rst $@ varnishlog.1: \ $(top_builddir)/doc/sphinx/reference/varnishlog.rst \ $(top_builddir)/doc/sphinx/include/varnishlog_options.rst \ $(top_builddir)/doc/sphinx/include/varnishlog_synopsis.rst - ${RST2MAN} $(RST2ANY_FLAGS) $(top_srcdir)/doc/sphinx/reference/varnishlog.rst $@ + $(BUILD_MAN) $(top_srcdir)/doc/sphinx/reference/varnishlog.rst $@ varnishstat.1: $(top_builddir)/doc/sphinx/reference/varnishstat.rst \ $(top_builddir)/doc/sphinx/include/varnishstat_options.rst \ $(top_builddir)/doc/sphinx/include/varnishstat_synopsis.rst - ${RST2MAN} $(RST2ANY_FLAGS) $(top_srcdir)/doc/sphinx/reference/varnishstat.rst $@ + $(BUILD_MAN) $(top_srcdir)/doc/sphinx/reference/varnishstat.rst $@ varnishtest.1: $(top_builddir)/doc/sphinx/reference/varnishtest.rst - ${RST2MAN} $(RST2ANY_FLAGS) $(top_srcdir)/doc/sphinx/reference/varnishtest.rst $@ + $(BUILD_MAN) $(top_srcdir)/doc/sphinx/reference/varnishtest.rst $@ vtc.7: $(top_builddir)/doc/sphinx/reference/vtc.rst \ $(top_builddir)/doc/sphinx/include/vtc-syntax.rst - ${RST2MAN} $(RST2ANY_FLAGS) $(top_srcdir)/doc/sphinx/reference/vtc.rst $@ + $(BUILD_MAN) $(top_srcdir)/doc/sphinx/reference/vtc.rst $@ varnishtop.1: \ $(top_builddir)/doc/sphinx/reference/varnishtop.rst \ $(top_builddir)/doc/sphinx/include/varnishtop_options.rst \ $(top_builddir)/doc/sphinx/include/varnishtop_synopsis.rst - ${RST2MAN} $(RST2ANY_FLAGS) $(top_srcdir)/doc/sphinx/reference/varnishtop.rst $@ + $(BUILD_MAN) $(top_srcdir)/doc/sphinx/reference/varnishtop.rst $@ varnishhist.1: \ $(top_builddir)/doc/sphinx/reference/varnishhist.rst \ $(top_builddir)/doc/sphinx/include/varnishhist_options.rst \ $(top_builddir)/doc/sphinx/include/varnishhist_synopsis.rst - ${RST2MAN} $(RST2ANY_FLAGS) $(top_srcdir)/doc/sphinx/reference/varnishhist.rst $@ + $(BUILD_MAN) $(top_srcdir)/doc/sphinx/reference/varnishhist.rst $@ vmod_directors.3: $(top_builddir)/lib/libvmod_directors/vmod_directors.man.rst - ${RST2MAN} $(RST2ANY_FLAGS) $? $@ + $(BUILD_MAN) $? $@ vmod_purge.3: $(top_builddir)/lib/libvmod_purge/vmod_purge.man.rst - ${RST2MAN} $(RST2ANY_FLAGS) $? $@ + $(BUILD_MAN) $? $@ vmod_std.3: $(top_builddir)/lib/libvmod_std/vmod_std.man.rst - ${RST2MAN} $(RST2ANY_FLAGS) $? $@ + $(BUILD_MAN) $? $@ vmod_vtc.3: $(top_builddir)/lib/libvmod_vtc/vmod_vtc.man.rst - ${RST2MAN} $(RST2ANY_FLAGS) $? $@ + $(BUILD_MAN) $? $@ vmod_blob.3: $(top_builddir)/lib/libvmod_blob/vmod_blob.man.rst - ${RST2MAN} $(RST2ANY_FLAGS) $? $@ + $(BUILD_MAN) $? $@ vmod_unix.3: $(top_builddir)/lib/libvmod_unix/vmod_unix.man.rst - ${RST2MAN} $(RST2ANY_FLAGS) $? $@ + $(BUILD_MAN) $? $@ vmod_proxy.3: $(top_builddir)/lib/libvmod_proxy/vmod_proxy.man.rst - ${RST2MAN} $(RST2ANY_FLAGS) $? $@ + $(BUILD_MAN) $? $@ .NOPATH: $(dist_man_MANS) From dridi.boukelmoune at gmail.com Thu Jul 4 10:24:08 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 4 Jul 2019 10:24:08 +0000 (UTC) Subject: [master] 0b81e558c Kill stale comment, we don't Message-ID: <20190704102408.AEBFAA6185@lists.varnish-cache.org> commit 0b81e558cc52e6816d784df10cc322d16f4d28b4 Author: Dridi Boukelmoune Date: Thu Jul 4 12:21:44 2019 +0200 Kill stale comment, we don't And we have a goal of making the VSL self-documenting so reordering anything is pointless. We already reorder SLTs in the documentation where sorting really matters to end users. diff --git a/include/tbl/vsl_tags.h b/include/tbl/vsl_tags.h index cb2c5ec76..6b1ca4ef4 100644 --- a/include/tbl/vsl_tags.h +++ b/include/tbl/vsl_tags.h @@ -33,7 +33,6 @@ * page) whenever this list changes. * * XXX: Please add new entries a the end to not break saved log-segments. - * XXX: we can resort them when we have a major release. * * Arguments: * Tag-Name From dridi.boukelmoune at gmail.com Thu Jul 4 10:34:07 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 4 Jul 2019 10:34:07 +0000 (UTC) Subject: [master] ffee88def Missing #undef Message-ID: <20190704103407.9B60EA65D4@lists.varnish-cache.org> commit ffee88defea9fd48e472e719f7e1ce5f799a3c84 Author: Dridi Boukelmoune Date: Thu Jul 4 12:32:55 2019 +0200 Missing #undef diff --git a/include/tbl/vsl_tags.h b/include/tbl/vsl_tags.h index 6b1ca4ef4..f7f47dceb 100644 --- a/include/tbl/vsl_tags.h +++ b/include/tbl/vsl_tags.h @@ -665,6 +665,7 @@ SLTM(VCL_use, 0, "VCL in use", "\n" ) +#undef NOSUP_NOTICE #undef NODEF_NOTICE #undef SLTM From fgsch at lodoss.net Fri Jul 5 10:02:08 2019 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Fri, 5 Jul 2019 10:02:08 +0000 (UTC) Subject: [master] 54e7d45b7 Fix test temporarily Message-ID: <20190705100208.619E59AF27@lists.varnish-cache.org> commit 54e7d45b7553791ea64fcf8376e23afd1034bc8e Author: Federico G. Schwindt Date: Fri Jul 5 11:00:57 2019 +0100 Fix test temporarily diff --git a/bin/varnishtest/tests/v00016.vtc b/bin/varnishtest/tests/v00016.vtc index 7da6152ea..56ba92c4f 100644 --- a/bin/varnishtest/tests/v00016.vtc +++ b/bin/varnishtest/tests/v00016.vtc @@ -85,7 +85,7 @@ varnish v1 -errvcl {Regexp compilation error:} { varnish v1 -errvcl {resolves to too many addresses} { backend b { .host = "127.0.0.1"; } sub vcl_recv { - if (remote.ip == "r.freebsd.dk") {} + if (remote.ip == "www.varnish-cache.org") {} } } From phk at phk.freebsd.dk Fri Jul 5 10:13:11 2019 From: phk at phk.freebsd.dk (Poul-Henning Kamp) Date: Fri, 05 Jul 2019 10:13:11 +0000 Subject: [master] 54e7d45b7 Fix test temporarily In-Reply-To: <20190705100208.619E59AF27@lists.varnish-cache.org> References: <20190705100208.619E59AF27@lists.varnish-cache.org> Message-ID: <18300.1562321591@critter.freebsd.dk> -------- In message <20190705100208.619E59AF27 at lists.varnish-cache.org>, Federico G. Sch windt writes: >- if (remote.ip == "r.freebsd.dk") {} >+ if (remote.ip == "www.varnish-cache.org") {} Yeah, sorry, I did some server/DNS work while I was stuck and forgot about this one. I think it is a better idea to use "dns-canary.freebsd.dk" because that is the one we use for the "feature dns" check in VTEST. -- 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 fgsch at lodoss.net Mon Jul 8 09:39:07 2019 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Mon, 8 Jul 2019 09:39:07 +0000 (UTC) Subject: [master] 9488a2ad9 Update to mention STRANDS and reword Message-ID: <20190708093907.E6980AC3E1@lists.varnish-cache.org> commit 9488a2ad93de5d1c97944615da5059bdb65106f3 Author: Federico G. Schwindt Date: Mon Jul 8 10:37:19 2019 +0100 Update to mention STRANDS and reword diff --git a/doc/sphinx/reference/vmod.rst b/doc/sphinx/reference/vmod.rst index d2340cfc5..1c5e2ee4d 100644 --- a/doc/sphinx/reference/vmod.rst +++ b/doc/sphinx/reference/vmod.rst @@ -50,35 +50,36 @@ data structures that do all the hard work. The std VMODs vmod.vcc file looks somewhat like this:: - $Module std 3 $ABI strict + $Module std 3 "Varnish Standard Module" $Event event_function - $Function STRING toupper(STRING_LIST) - $Function STRING tolower(STRING_LIST) + $Function STRING toupper(STRANDS s) + $Function STRING tolower(STRANDS s) $Function VOID set_ip_tos(INT) -The first line gives the name of the module and the manual section where -the documentation will reside. +The ``$ABI`` line is optional. Possible values are ``strict`` +(default) and ``vrt``. It allows to specify that a vmod is integrating +with the blessed ``vrt`` interface provided by ``varnishd`` or go +deeper in the stack. -The ``$ABI`` line is optional (possible values ``strict`` (default) -and ``vrt``) and allows to specify that a vmod is integrating with the -blessed ``vrt`` interface provided by ``varnishd`` or go deeper in the -stack. As a general rule of thumb you are considered "on your own" if -your VMOD uses more than the VRT (Varnish RunTime), in which case it -needs to be built for the exact Varnish version. +As a rule of thumb you, if the VMOD uses more than the VRT (Varnish +RunTime), in which case it needs to be built for the exact Varnish +version, use ``strict``. If it complies to the VRT and only needs +to be rebuilt when breaking changes are introduced to the VRT API, +use ``vrt``. -``$ABI vrt`` means that a module complies to the VRT and only needs to -be rebuilt when breaking changes are introduced to the VRT API. +The ``$Module`` line gives the name of the module, the manual section +where the documentation will reside, and the description. -The third line specifies an optional "Event" function, which will be -called whenever a VCL program which imports this VMOD is loaded or -transitions to any of the warm, active, cold or discarded states. -More on this below. +The ``$Event`` line specifies an optional "Event" function, which +will be called whenever a VCL program which imports this VMOD is +loaded or transitions to any of the warm, active, cold or discarded +states. More on this below. -The next three lines define three functions in the VMOD, along with the -types of the arguments, and that is probably where the hardest bit of -writing a VMOD is to be found, so we will talk about that at length in -a moment. +The ``$Function`` lines define three functions in the VMOD, along +with the types of the arguments, and that is probably where the +hardest bit of writing a VMOD is to be found, so we will talk about +that at length in a moment. Notice that the third function returns VOID, that makes it a "procedure" in VCL lingo, meaning that it cannot be used in expressions, right side @@ -102,10 +103,8 @@ the functions you want to export to VCL. For the std VMOD, the compiled vcc_if.h file looks like this:: - struct vmod_priv; - - VCL_STRING vmod_toupper(VRT_CTX, const char *, ...); - VCL_STRING vmod_tolower(VRT_CTX, const char *, ...); + VCL_STRING vmod_toupper(VRT_CTX, VCL_STRANDS); + VCL_STRING vmod_tolower(VRT_CTX, VCL_STRANDS); VCL_VOID vmod_set_ip_tos(VRT_CTX, VCL_INT); vmod_event_f event_function; From dridi.boukelmoune at gmail.com Wed Jul 10 07:42:08 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 10 Jul 2019 07:42:08 +0000 (UTC) Subject: [6.0] 6f25ee3b8 Introduce a notice for past and future VSL records Message-ID: <20190710074208.9B44D91106@lists.varnish-cache.org> commit 6f25ee3b8c0c17a9de6eb8f1dfded84fee513b17 Author: Dridi Boukelmoune Date: Thu Jul 4 11:51:26 2019 +0200 Introduce a notice for past and future VSL records diff --git a/include/tbl/vsl_tags.h b/include/tbl/vsl_tags.h index 80e57eae4..b5cc017eb 100644 --- a/include/tbl/vsl_tags.h +++ b/include/tbl/vsl_tags.h @@ -47,6 +47,11 @@ #define NODEF_NOTICE \ "NB: This log record is masked by default.\n\n" +#define NOSUP_NOTICE \ + "\tNOTE: This tag is currently not in use in the Varnish log.\n" \ + "\tIt is mentioned here to document legacy versions of the log,\n" \ + "\tor reserved for possible use in future versions.\n\n" + SLTM(Debug, SLT_F_UNSAFE, "Debug messages", "Debug messages can normally be ignored, but are sometimes" " helpful during trouble-shooting. Most debug messages must" From dridi.boukelmoune at gmail.com Wed Jul 10 07:42:08 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 10 Jul 2019 07:42:08 +0000 (UTC) Subject: [6.0] e7c64230c Kill stale comment, we don't Message-ID: <20190710074208.AF41B91109@lists.varnish-cache.org> commit e7c64230c793419f75d7ab4e4c34ce210cfa572c Author: Dridi Boukelmoune Date: Thu Jul 4 12:21:44 2019 +0200 Kill stale comment, we don't And we have a goal of making the VSL self-documenting so reordering anything is pointless. We already reorder SLTs in the documentation where sorting really matters to end users. diff --git a/include/tbl/vsl_tags.h b/include/tbl/vsl_tags.h index b5cc017eb..e1f48ef2d 100644 --- a/include/tbl/vsl_tags.h +++ b/include/tbl/vsl_tags.h @@ -33,7 +33,6 @@ * page) whenever this list changes. * * XXX: Please add new entries a the end to not break saved log-segments. - * XXX: we can resort them when we have a major release. * * Arguments: * Tag-Name From dridi.boukelmoune at gmail.com Wed Jul 10 07:42:08 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 10 Jul 2019 07:42:08 +0000 (UTC) Subject: [6.0] 46921d19d Introduce VCL_use SLT which tells us which VCL we're running in Message-ID: <20190710074208.C83BE9110C@lists.varnish-cache.org> commit 46921d19dd24f2e39e384e1361b0e599a0d73278 Author: Poul-Henning Kamp Date: Mon Jan 14 11:19:47 2019 +0000 Introduce VCL_use SLT which tells us which VCL we're running in Conflicts: bin/varnishd/cache/cache_req_fsm.c include/tbl/vsl_tags.h Other SLTs were back-ported as well, but marked as not supported, to ensure binary forward compatibility up to 6.2 releases. diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index a5701ec8e..9101cc568 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -962,6 +962,7 @@ VBF_Fetch(struct worker *wrk, struct req *req, struct objcore *oc, bo = VBO_GetBusyObj(wrk, req); CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + AN(bo->vcl); boc = HSH_RefBoc(oc); CHECK_OBJ_NOTNULL(boc, BOC_MAGIC); @@ -983,6 +984,7 @@ VBF_Fetch(struct worker *wrk, struct req *req, struct objcore *oc, } VSLb(bo->vsl, SLT_Begin, "bereq %u %s", VXID(req->vsl->wid), how); + VSLb(bo->vsl, SLT_VCL_use, "%s", VCL_Name(bo->vcl)); VSLb(req->vsl, SLT_Link, "bereq %u %s", VXID(bo->vsl->wid), how); THR_SetBusyobj(bo); @@ -990,8 +992,6 @@ VBF_Fetch(struct worker *wrk, struct req *req, struct objcore *oc, bo->sp = req->sp; SES_Ref(bo->sp); - AN(bo->vcl); - oc->boc->vary = req->vary_b; req->vary_b = NULL; diff --git a/bin/varnishd/cache/cache_vcl_vrt.c b/bin/varnishd/cache/cache_vcl_vrt.c index 40cb78430..a63161b81 100644 --- a/bin/varnishd/cache/cache_vcl_vrt.c +++ b/bin/varnishd/cache/cache_vcl_vrt.c @@ -264,8 +264,8 @@ VRT_vcl_select(VRT_CTX, VCL_VCL vcl) VCL_TaskLeave(req->vcl, req->privs); VCL_Rel(&req->vcl); vcl_get(&req->vcl, vcl); - /* XXX: better logging */ - VSLb(ctx->req->vsl, SLT_Debug, "Now using %s VCL", vcl->loaded_name); + VSLb(ctx->req->vsl, SLT_VCL_use, "%s via %s", + req->vcl->loaded_name, vcl->loaded_name); VCL_TaskEnter(req->vcl, req->privs); } diff --git a/bin/varnishtest/tests/u00010.vtc b/bin/varnishtest/tests/u00010.vtc index dd37a15d0..329f92567 100644 --- a/bin/varnishtest/tests/u00010.vtc +++ b/bin/varnishtest/tests/u00010.vtc @@ -20,7 +20,7 @@ client c1 { varnish v1 -vsl_catchup -process p1 -expect-text 1 1 {list length 64} +process p1 -expect-text 1 1 {list length 65} process p1 -writehex 0c diff --git a/doc/sphinx/Makefile.am b/doc/sphinx/Makefile.am index d9be207ac..0ff57bd96 100644 --- a/doc/sphinx/Makefile.am +++ b/doc/sphinx/Makefile.am @@ -192,7 +192,7 @@ include/varnishstat_synopsis.rst: $(top_builddir)/bin/varnishstat/varnishstat BUILT_SOURCES += include/varnishstat_options.rst \ include/varnishstat_synopsis.rst -include/vsl-tags.rst: $(top_builddir)/lib/libvarnishapi/vsl2rst +include/vsl-tags.rst: $(top_builddir)/lib/libvarnishapi/vsl2rst $(top_builddir)/lib/libvarnishapi/vsl2rst > ${@}_ mv ${@}_ ${@} BUILT_SOURCES += include/vsl-tags.rst diff --git a/include/tbl/vsl_tags.h b/include/tbl/vsl_tags.h index e1f48ef2d..b50b1f0c7 100644 --- a/include/tbl/vsl_tags.h +++ b/include/tbl/vsl_tags.h @@ -628,6 +628,35 @@ SLTM(HitMiss, 0, "Hit for miss object in cache.", "\n" ) +SLTM(Filters, 0, "Body filters", + "List of filters applied to the body.\n\n" + NOSUP_NOTICE +) + +SLTM(SessError, 0, "Client connection accept failed", + "Accepting a client connection has failed.\n\n" + "The format is::\n\n" + "\t%s %s %s %d %d %s\n" + "\t| | | | | |\n" + "\t| | | | | +- Detailed error message\n" + "\t| | | | +---- Error Number (errno) from accept(2)\n" + "\t| | | +------- File descriptor number\n" + "\t| | +---------- Local TCP port / 0 for UDS\n" + "\t| +------------- Local IPv4/6 address / 0.0.0.0 for UDS\n" + "\t+---------------- Socket name (from -a argument)\n" + "\n" + NOSUP_NOTICE +) + +SLTM(VCL_use, 0, "VCL in use", + "Records the name of the VCL being used.\n\n" + "The format is::\n\n" + "\t%s [via %s]\n" + "\t| |\n" + "\t| +- Name of label used to find it (optional)\n" + "\t+--------- Name of VCL put in use\n" +) + #undef NODEF_NOTICE #undef SLTM From dridi.boukelmoune at gmail.com Wed Jul 10 07:42:08 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 10 Jul 2019 07:42:08 +0000 (UTC) Subject: [6.0] 0f2724926 Clarify this is a 3-fields tag Message-ID: <20190710074208.DFB0491111@lists.varnish-cache.org> commit 0f2724926fda02a039ab7d83c6bea04835226179 Author: Federico G. Schwindt Date: Mon Jan 14 15:55:31 2019 +0000 Clarify this is a 3-fields tag diff --git a/include/tbl/vsl_tags.h b/include/tbl/vsl_tags.h index b50b1f0c7..dd284890a 100644 --- a/include/tbl/vsl_tags.h +++ b/include/tbl/vsl_tags.h @@ -651,10 +651,12 @@ SLTM(SessError, 0, "Client connection accept failed", SLTM(VCL_use, 0, "VCL in use", "Records the name of the VCL being used.\n\n" "The format is::\n\n" - "\t%s [via %s]\n" - "\t| |\n" - "\t| +- Name of label used to find it (optional)\n" + "\t%s [ %s %s ]\n" + "\t| | |\n" + "\t| | +- Name of label used to find it\n" + "\t| +---- \"via\"\n" "\t+--------- Name of VCL put in use\n" + "\n" ) #undef NODEF_NOTICE From dridi.boukelmoune at gmail.com Wed Jul 10 07:42:09 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 10 Jul 2019 07:42:09 +0000 (UTC) Subject: [6.0] 98f594e68 Missing #undef Message-ID: <20190710074209.03A6991114@lists.varnish-cache.org> commit 98f594e681b52aaa7f552563fa73def4d50a5941 Author: Dridi Boukelmoune Date: Thu Jul 4 12:32:55 2019 +0200 Missing #undef diff --git a/include/tbl/vsl_tags.h b/include/tbl/vsl_tags.h index dd284890a..698807b17 100644 --- a/include/tbl/vsl_tags.h +++ b/include/tbl/vsl_tags.h @@ -659,6 +659,7 @@ SLTM(VCL_use, 0, "VCL in use", "\n" ) +#undef NOSUP_NOTICE #undef NODEF_NOTICE #undef SLTM From dridi.boukelmoune at gmail.com Wed Jul 10 07:42:09 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 10 Jul 2019 07:42:09 +0000 (UTC) Subject: [6.0] 6c0c01811 Add a -m ("Miss") argument which also logs the records which do not match Message-ID: <20190710074209.1E3FA91119@lists.varnish-cache.org> commit 6c0c01811d4e654d71829a1b3def9209d3c876da Author: Poul-Henning Kamp Date: Tue Jan 15 12:50:09 2019 +0000 Add a -m ("Miss") argument which also logs the records which do not match diff --git a/bin/varnishtest/vtc_logexp.c b/bin/varnishtest/vtc_logexp.c index 43e300acf..521c9ae3b 100644 --- a/bin/varnishtest/vtc_logexp.c +++ b/bin/varnishtest/vtc_logexp.c @@ -65,6 +65,8 @@ * \-q query * Filter records using a query expression, see ``man vsl-query`` for * more information. + * \-m + * Also emit log records for misses (only for debugging) * * \-start * Start the logexpect thread in the background. @@ -153,6 +155,7 @@ struct logexp { int vxid_last; int tag_last; + int m_arg; int d_arg; enum VSL_grouping_e g_arg; char *query; @@ -308,6 +311,8 @@ logexp_dispatch(struct VSL_data *vsl, struct VSL_transaction * const pt[], if (ok) legend = "match"; + else if (skip && le->m_arg) + legend = "miss"; else if (skip) legend = NULL; else @@ -597,6 +602,10 @@ cmd_logexpect(CMD_ARGS) av++; continue; } + if (!strcmp(*av, "-m")) { + le->m_arg = !le->m_arg; + continue; + } if (!strcmp(*av, "-start")) { logexp_start(le); continue; From dridi.boukelmoune at gmail.com Wed Jul 10 07:42:09 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 10 Jul 2019 07:42:09 +0000 (UTC) Subject: [6.0] 3d8716d28 Sync with VTEST Message-ID: <20190710074209.3731191121@lists.varnish-cache.org> commit 3d8716d28b7fa4d5f34759d960de03e42a9ea5a1 Author: Poul-Henning Kamp Date: Tue Jan 15 13:32:16 2019 +0000 Sync with VTEST diff --git a/bin/varnishtest/Makefile.am b/bin/varnishtest/Makefile.am index 357ef9269..b9c1def06 100644 --- a/bin/varnishtest/Makefile.am +++ b/bin/varnishtest/Makefile.am @@ -69,6 +69,8 @@ varnishtest_LDADD = \ varnishtest_CFLAGS = \ @SAN_CFLAGS@ \ + -DVTEST_WITH_VTC_LOGEXPECT \ + -DVTEST_WITH_VTC_VARNISH \ -DTOP_BUILDDIR='"${top_builddir}"' EXTRA_DIST = $(top_srcdir)/bin/varnishtest/tests/*.vtc \ diff --git a/bin/varnishtest/cmds.h b/bin/varnishtest/cmds.h index fd140efe2..8eb2fa4f1 100644 --- a/bin/varnishtest/cmds.h +++ b/bin/varnishtest/cmds.h @@ -44,12 +44,16 @@ CMD_TOP(client) CMD_TOP(err_shell) CMD_TOP(feature) CMD_TOP(haproxy) +#ifdef VTEST_WITH_VTC_LOGEXPECT CMD_TOP(logexpect) +#endif CMD_TOP(process) CMD_TOP(server) CMD_TOP(setenv) CMD_TOP(syslog) +#ifdef VTEST_WITH_VTC_VARNISH CMD_TOP(varnish) +#endif CMD_TOP(varnishtest) CMD_TOP(vtest) #undef CMD_TOP diff --git a/bin/varnishtest/vtc_logexp.c b/bin/varnishtest/vtc_logexp.c index 521c9ae3b..11f046f95 100644 --- a/bin/varnishtest/vtc_logexp.c +++ b/bin/varnishtest/vtc_logexp.c @@ -26,6 +26,8 @@ * SUCH DAMAGE. */ +#ifdef VTEST_WITH_VTC_LOGEXPECT + /* SECTION: logexpect logexpect * * Reads the VSL and looks for records matching a given specification. It will @@ -628,3 +630,5 @@ cmd_logexpect(CMD_ARGS) logexp_spec(le, *av); } } + +#endif /* VTEST_WITH_VTC_LOGEXPECT */ diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c index 0c7b3f5a3..099a1abae 100644 --- a/bin/varnishtest/vtc_varnish.c +++ b/bin/varnishtest/vtc_varnish.c @@ -26,6 +26,8 @@ * SUCH DAMAGE. */ +#ifdef VTEST_WITH_VTC_VARNISH + #include "config.h" #include @@ -1238,3 +1240,5 @@ cmd_varnish(CMD_ARGS) vtc_fatal(v->vl, "Unknown varnish argument: %s", *av); } } + +#endif /* VTEST_WITH_VTC_VARNISH */ From dridi.boukelmoune at gmail.com Wed Jul 10 07:42:09 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 10 Jul 2019 07:42:09 +0000 (UTC) Subject: [6.0] 7d1189bd4 Sync with VTEST Message-ID: <20190710074209.4F44F91125@lists.varnish-cache.org> commit 7d1189bd4a76fc662425c8bb68db9f0d36a6f395 Author: Poul-Henning Kamp Date: Tue Jan 15 13:45:27 2019 +0000 Sync with VTEST diff --git a/bin/varnishtest/vtc_haproxy.c b/bin/varnishtest/vtc_haproxy.c index 0ff037f6d..f8e973701 100644 --- a/bin/varnishtest/vtc_haproxy.c +++ b/bin/varnishtest/vtc_haproxy.c @@ -481,7 +481,7 @@ haproxy_new(const char *name) h->cli = haproxy_cli_new(h); AN(h->cli); - bprintf(buf, "rm -rf %s ; mkdir -p %s", h->workdir, h->workdir); + bprintf(buf, "rm -rf \"%s\" ; mkdir -p \"%s\"", h->workdir, h->workdir); AZ(system(buf)); VTAILQ_INSERT_TAIL(&haproxies, h, list); @@ -502,7 +502,7 @@ haproxy_delete(struct haproxy *h) vtc_logclose(h->vl); if (!leave_temp) { - bprintf(buf, "rm -rf %s", h->workdir); + bprintf(buf, "rm -rf \"%s\"", h->workdir); AZ(system(buf)); } @@ -552,7 +552,7 @@ haproxy_start(struct haproxy *h) vsb = VSB_new_auto(); AN(vsb); - VSB_printf(vsb, "exec %s", h->filename); + VSB_printf(vsb, "exec \"%s\"", h->filename); if (h->opt_check_mode) VSB_printf(vsb, " -c"); else if (h->opt_daemon) @@ -565,13 +565,13 @@ haproxy_start(struct haproxy *h) VSB_printf(vsb, " %s", VSB_data(h->args)); - VSB_printf(vsb, " -f %s ", h->cfg_fn); + VSB_printf(vsb, " -f \"%s\" ", h->cfg_fn); if (h->opt_worker || h->opt_daemon) { bprintf(buf, "%s/pid", h->workdir); h->pid_fn = strdup(buf); AN(h->pid_fn); - VSB_printf(vsb, " -p %s", h->pid_fn); + VSB_printf(vsb, " -p \"%s\"", h->pid_fn); } AZ(VSB_finish(vsb)); @@ -758,7 +758,7 @@ haproxy_write_conf(const struct haproxy *h, const char *cfg, int auto_be) vsb2 = VSB_new_auto(); AN(vsb2); - VSB_printf(vsb, " global\n\tstats socket %s " + VSB_printf(vsb, " global\n\tstats socket \"%s\" " "level admin mode 600\n", h->cli_fn); VSB_printf(vsb, " stats socket \"fd@${cli}\" level admin\n"); AZ(VSB_cat(vsb, cfg)); diff --git a/bin/varnishtest/vtc_http.c b/bin/varnishtest/vtc_http.c index 03aa7f7e5..616cb459e 100644 --- a/bin/varnishtest/vtc_http.c +++ b/bin/varnishtest/vtc_http.c @@ -797,8 +797,11 @@ cmd_http_gunzip(CMD_ARGS) static void gzip_body(const struct http *hp, const char *txt, char **body, int *bodylen) { - int l, i; + int l; z_stream vz; +#ifdef VGZ_EXTENSIONS + int i; +#endif memset(&vz, 0, sizeof vz); From dridi.boukelmoune at gmail.com Wed Jul 10 07:42:09 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 10 Jul 2019 07:42:09 +0000 (UTC) Subject: [6.0] 43815427c Synchronize with VTEST Message-ID: <20190710074209.68BE29112B@lists.varnish-cache.org> commit 43815427c92c87c1be0484771b7448148d9bcd22 Author: Poul-Henning Kamp Date: Tue Jan 15 13:45:58 2019 +0000 Synchronize with VTEST diff --git a/lib/libvarnish/vfil.c b/lib/libvarnish/vfil.c index 345096a7c..29650175a 100644 --- a/lib/libvarnish/vfil.c +++ b/lib/libvarnish/vfil.c @@ -50,7 +50,7 @@ #ifdef HAVE_SYS_VFS_H # include #endif -#if defined(__linux__) && defined(HAVE_FALLOCATE) +#ifdef HAVE_FALLOCATE # include #endif From dridi.boukelmoune at gmail.com Wed Jul 10 07:42:09 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 10 Jul 2019 07:42:09 +0000 (UTC) Subject: [6.0] 7fb6cbcd3 Remove a wrong vintage 2010 optimization (5f7d80c5034c3ce) Message-ID: <20190710074209.806DB9112F@lists.varnish-cache.org> commit 7fb6cbcd33623a763a901dac4063512703016815 Author: Poul-Henning Kamp Date: Tue Jan 15 21:47:17 2019 +0000 Remove a wrong vintage 2010 optimization (5f7d80c5034c3ce) Solaris, (remember Solaris?) will return connection related errnos on fd metadata operations such as ioctl(2), [gs]etsockopt(2) etc. We propagated these errors up from VTC_(non)blocking() which could, theoretically, bail out earlier than it would otherwise have done. This complicated code far more than it speeded anything up. Instead just ensure that any errors returned are indeed connection related, and then ignore them, and let Solaris deal with the broken connection same way as other operating systems. diff --git a/lib/libvarnish/vtcp.c b/lib/libvarnish/vtcp.c index 696753b00..759be1f64 100644 --- a/lib/libvarnish/vtcp.c +++ b/lib/libvarnish/vtcp.c @@ -214,9 +214,11 @@ VTCP_fastopen(int sock, int depth) * us to do two syscalls, one to get and one to set, the latter of * which mucks about a bit before it ends up calling ioctl(FIONBIO), * at least on FreeBSD. + * On Solaris ioctl(FIONBIO) can fail with connection related errnos, + * but as long as that is how they fail, we're fine. */ -int +void VTCP_blocking(int sock) { int i, j; @@ -224,10 +226,9 @@ VTCP_blocking(int sock) i = 0; j = ioctl(sock, FIONBIO, &i); VTCP_Assert(j); - return (j); } -int +void VTCP_nonblocking(int sock) { int i, j; @@ -235,7 +236,6 @@ VTCP_nonblocking(int sock) i = 1; j = ioctl(sock, FIONBIO, &i); VTCP_Assert(j); - return (j); } /*-------------------------------------------------------------------- From dridi.boukelmoune at gmail.com Wed Jul 10 07:42:09 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 10 Jul 2019 07:42:09 +0000 (UTC) Subject: [6.0] 713d99976 The rest of previous commit. Message-ID: <20190710074209.9B87D91141@lists.varnish-cache.org> commit 713d99976bed0f84ef0d78b59cdfd0b3bff24d72 Author: Poul-Henning Kamp Date: Tue Jan 15 22:14:43 2019 +0000 The rest of previous commit. diff --git a/bin/varnishd/cache/cache_acceptor.c b/bin/varnishd/cache/cache_acceptor.c index fb37ad574..1e56ab5f6 100644 --- a/bin/varnishd/cache/cache_acceptor.c +++ b/bin/varnishd/cache/cache_acceptor.c @@ -370,12 +370,7 @@ vca_make_session(struct worker *wrk, void *arg) CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CAST_OBJ_NOTNULL(wa, arg, WRK_ACCEPT_MAGIC); - if (VTCP_blocking(wa->acceptsock)) { - closefd(&wa->acceptsock); - wrk->stats->sess_drop++; // XXX Better counter ? - WS_Release(wrk->aws, 0); - return; - } + VTCP_blocking(wa->acceptsock); /* Turn accepted socket into a session */ AN(wrk->aws->r); diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c index 4141dfa21..2402b10b5 100644 --- a/bin/varnishd/cache/cache_session.c +++ b/bin/varnishd/cache/cache_session.c @@ -441,10 +441,7 @@ SES_Wait(struct sess *sp, const struct transport *xp) * XXX: waiter_epoll prevents us from zeroing the struct because * XXX: it keeps state across calls. */ - if (VTCP_nonblocking(sp->fd)) { - SES_Delete(sp, SC_REM_CLOSE, NAN); - return; - } + VTCP_nonblocking(sp->fd); /* * put struct waited on the workspace diff --git a/bin/varnishd/http1/cache_http1_fsm.c b/bin/varnishd/http1/cache_http1_fsm.c index b339339f5..fad043e84 100644 --- a/bin/varnishd/http1/cache_http1_fsm.c +++ b/bin/varnishd/http1/cache_http1_fsm.c @@ -177,30 +177,6 @@ http1_req_fail(struct req *req, enum sess_close reason) SES_Close(req->sp, reason); } -/*---------------------------------------------------------------------- - */ - -static int -http1_req_cleanup(struct sess *sp, struct worker *wrk, struct req *req) -{ - AZ(wrk->aws->r); - AZ(req->ws->r); - Req_Cleanup(sp, wrk, req); - - if (sp->fd >= 0 && req->doclose != SC_NULL) - SES_Close(sp, req->doclose); - - if (sp->fd < 0) { - wrk->stats->sess_closed++; - AZ(req->vcl); - Req_Release(req); - SES_Delete(sp, SC_NULL, NAN); - return (1); - } - - return (0); -} - static int v_matchproto_(vtr_minimal_response_f) http1_minimal_response(struct req *req, uint16_t status) { @@ -342,18 +318,9 @@ HTTP1_Session(struct worker *wrk, struct req *req) * Whenever we come in from the acceptor or waiter, we need to set * blocking mode. It would be simpler to do this in the acceptor * or waiter, but we'd rather do the syscall in the worker thread. - * On systems which return errors for ioctl, we close early */ - if (http1_getstate(sp) == H1NEWREQ && VTCP_blocking(sp->fd)) { - AN(req->htc->ws->r); - if (errno == ECONNRESET) - SES_Close(sp, SC_REM_CLOSE); - else - SES_Close(sp, SC_TX_ERROR); - WS_Release(req->htc->ws, 0); - AN(http1_req_cleanup(sp, wrk, req)); - return; - } + if (http1_getstate(sp) == H1NEWREQ) + VTCP_blocking(sp->fd); req->transport = &HTTP1_transport; @@ -455,8 +422,22 @@ HTTP1_Session(struct worker *wrk, struct req *req) AZ(wrk->aws->r); http1_setstate(sp, H1CLEANUP); } else if (st == H1CLEANUP) { - if (http1_req_cleanup(sp, wrk, req)) + + AZ(wrk->aws->r); + AZ(req->ws->r); + + if (sp->fd >= 0 && req->doclose != SC_NULL) + SES_Close(sp, req->doclose); + + if (sp->fd < 0) { + wrk->stats->sess_closed++; + Req_Cleanup(sp, wrk, req); + Req_Release(req); + SES_Delete(sp, SC_NULL, NAN); return; + } + + Req_Cleanup(sp, wrk, req); HTC_RxInit(req->htc, req->ws); if (req->htc->rxbuf_e != req->htc->rxbuf_b) wrk->stats->sess_readahead++; diff --git a/include/vtcp.h b/include/vtcp.h index 29f83cb75..a5431aba6 100644 --- a/include/vtcp.h +++ b/include/vtcp.h @@ -45,8 +45,8 @@ void VTCP_hisname(int sock, char *abuf, unsigned alen, char *pbuf, unsigned plen); int VTCP_filter_http(int sock); int VTCP_fastopen(int sock, int depth); -int VTCP_blocking(int sock); -int VTCP_nonblocking(int sock); +void VTCP_blocking(int sock); +void VTCP_nonblocking(int sock); int VTCP_linger(int sock, int linger); int VTCP_check_hup(int sock); From dridi.boukelmoune at gmail.com Wed Jul 10 07:42:09 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 10 Jul 2019 07:42:09 +0000 (UTC) Subject: [6.0] 555b329a5 Flexelinting Message-ID: <20190710074209.ACE0D91152@lists.varnish-cache.org> commit 555b329a5f26e36aad12f72ecdef5d360d0fe18b Author: Poul-Henning Kamp Date: Wed Jan 16 09:56:57 2019 +0000 Flexelinting diff --git a/lib/libvcc/vcc_vmod.c b/lib/libvcc/vcc_vmod.c index 8b308c03f..00f0cb0d0 100644 --- a/lib/libvcc/vcc_vmod.c +++ b/lib/libvcc/vcc_vmod.c @@ -394,9 +394,11 @@ vcc_Act_New(struct vcc *tl, struct token *t, struct symbol *sym) vf = VTAILQ_NEXT(vf, list); buf = VSB_new_auto(); + AN(buf); VSB_printf(buf, ", &%s, \"%s\"", sy1->rname, sy1->name); AZ(VSB_finish(buf)); vcc_Eval_Func(tl, vf, VSB_data(buf), sy2); + VSB_destroy(&buf); ERRCHK(tl); SkipToken(tl, ';'); sy1->def_e = tl->t; @@ -413,7 +415,8 @@ vcc_Act_New(struct vcc *tl, struct token *t, struct symbol *sym) VSB_printf(ifp->fin, "\t\t%s(&%s);", vf->value, sy1->rname); /* Instantiate symbols for the methods */ - VSB_clear(buf); + buf = VSB_new_auto(); + AN(buf); VSB_printf(buf, ", %s", sy1->rname); AZ(VSB_finish(buf)); p = TlDup(tl, VSB_data(buf)); From dridi.boukelmoune at gmail.com Wed Jul 10 07:42:09 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 10 Jul 2019 07:42:09 +0000 (UTC) Subject: [6.0] f7598a0c9 Use the vdp priv as intended Message-ID: <20190710074209.C45759115D@lists.varnish-cache.org> commit f7598a0c9b14182556166e9eab93b54b14734bbc Author: Poul-Henning Kamp Date: Wed Jan 16 20:58:15 2019 +0000 Use the vdp priv as intended diff --git a/bin/varnishd/http2/cache_http2_deliver.c b/bin/varnishd/http2/cache_http2_deliver.c index c40124e40..10b9021c4 100644 --- a/bin/varnishd/http2/cache_http2_deliver.c +++ b/bin/varnishd/http2/cache_http2_deliver.c @@ -72,17 +72,25 @@ V2D_Init(void) /**********************************************************************/ +static int v_matchproto_(vdp_init_f) +h2_init(struct req *req, void **priv) +{ + + *priv = req->transport_priv; + return (0); +} + static int v_matchproto_(vdp_fini_f) h2_fini(struct req *req, void **priv) { struct h2_req *r2; CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - (void)priv; - CAST_OBJ_NOTNULL(r2, req->transport_priv, H2_REQ_MAGIC); + CAST_OBJ_NOTNULL(r2, *priv, H2_REQ_MAGIC); H2_Send_Get(req->wrk, r2->h2sess, r2); H2_Send(req->wrk, r2, H2_F_DATA, H2FF_DATA_END_STREAM, 0, ""); H2_Send_Rel(r2->h2sess, r2); + *priv = NULL; return (0); } @@ -93,9 +101,8 @@ h2_bytes(struct req *req, enum vdp_action act, void **priv, struct h2_req *r2; CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - CAST_OBJ_NOTNULL(r2, req->transport_priv, H2_REQ_MAGIC); + CAST_OBJ_NOTNULL(r2, *priv, H2_REQ_MAGIC); (void)act; - (void)priv; if ((r2->h2sess->error || r2->error)) return (-1); @@ -108,6 +115,7 @@ h2_bytes(struct req *req, enum vdp_action act, void **priv, static const struct vdp h2_vdp = { .name = "H2B", + .init = h2_init, .bytes = h2_bytes, .fini = h2_fini, }; From dridi.boukelmoune at gmail.com Wed Jul 10 07:42:09 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 10 Jul 2019 07:42:09 +0000 (UTC) Subject: [6.0] e401850c6 Assert priv is not null before dereferencing it Message-ID: <20190710074209.DB00A91176@lists.varnish-cache.org> commit e401850c6f89d0f6c1870a1d00e9141c3272dbb1 Author: Dridi Boukelmoune Date: Wed Apr 17 18:56:30 2019 +0200 Assert priv is not null before dereferencing it And make it clear that we steal the reference at this point. diff --git a/bin/varnishd/http2/cache_http2_deliver.c b/bin/varnishd/http2/cache_http2_deliver.c index 10b9021c4..1a1de05be 100644 --- a/bin/varnishd/http2/cache_http2_deliver.c +++ b/bin/varnishd/http2/cache_http2_deliver.c @@ -86,11 +86,10 @@ h2_fini(struct req *req, void **priv) struct h2_req *r2; CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - CAST_OBJ_NOTNULL(r2, *priv, H2_REQ_MAGIC); + TAKE_OBJ_NOTNULL(r2, priv, H2_REQ_MAGIC); H2_Send_Get(req->wrk, r2->h2sess, r2); H2_Send(req->wrk, r2, H2_F_DATA, H2FF_DATA_END_STREAM, 0, ""); H2_Send_Rel(r2->h2sess, r2); - *priv = NULL; return (0); } From dridi.boukelmoune at gmail.com Wed Jul 10 07:42:09 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 10 Jul 2019 07:42:09 +0000 (UTC) Subject: [6.0] db74b4c1a No return value from VTCP_[non]blocking() to throw away Message-ID: <20190710074209.F3B5D91192@lists.varnish-cache.org> commit db74b4c1ac4f50e3556ab90fad78f8e92264120d Author: Poul-Henning Kamp Date: Wed Jan 16 21:57:34 2019 +0000 No return value from VTCP_[non]blocking() to throw away diff --git a/bin/varnishd/cache/cache_acceptor.c b/bin/varnishd/cache/cache_acceptor.c index 1e56ab5f6..f5f102075 100644 --- a/bin/varnishd/cache/cache_acceptor.c +++ b/bin/varnishd/cache/cache_acceptor.c @@ -382,7 +382,7 @@ vca_make_session(struct worker *wrk, void *arg) * to send an intelligent message back. */ vca_pace_bad(); - (void)VTCP_nonblocking(wa->acceptsock); + VTCP_nonblocking(wa->acceptsock); closefd(&wa->acceptsock); wrk->stats->sess_drop++; WS_Release(wrk->aws, 0); diff --git a/bin/varnishd/http1/cache_http1_fetch.c b/bin/varnishd/http1/cache_http1_fetch.c index 2ddc58142..c937d741e 100644 --- a/bin/varnishd/http1/cache_http1_fetch.c +++ b/bin/varnishd/http1/cache_http1_fetch.c @@ -98,7 +98,7 @@ V1F_SendReq(struct worker *wrk, struct busyobj *bo, uint64_t *ctr_hdrbytes, VSLb(bo->vsl, SLT_BackendStart, "%s %s", abuf, pbuf); - (void)VTCP_blocking(*htc->rfd); /* XXX: we should timeout instead */ + VTCP_blocking(*htc->rfd); /* XXX: we should timeout instead */ V1L_Open(wrk, wrk->aws, htc->rfd, bo->vsl, bo->t_prev, 0); hdrbytes = HTTP1_Write(wrk, hp, HTTP1_Req); diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index 7d040b7d0..194f225c5 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -1076,7 +1076,7 @@ h2_rxframe(struct worker *wrk, struct h2_sess *h2) char b[8]; ASSERT_RXTHR(h2); - (void)VTCP_blocking(*h2->htc->rfd); + VTCP_blocking(*h2->htc->rfd); h2->sess->t_idle = VTIM_real(); hs = HTC_RxStuff(h2->htc, h2_frame_complete, NULL, NULL, NAN, diff --git a/bin/varnishtest/vtc_barrier.c b/bin/varnishtest/vtc_barrier.c index 7f2f0c1ce..c3238bef6 100644 --- a/bin/varnishtest/vtc_barrier.c +++ b/bin/varnishtest/vtc_barrier.c @@ -147,7 +147,7 @@ barrier_sock_thread(void *priv) b->name, err, strerror(errno), errno); } assert(sock > 0); - (void)VTCP_nonblocking(sock); + VTCP_nonblocking(sock); VTCP_myname(sock, abuf, sizeof abuf, pbuf, sizeof pbuf); macro_def(vl, b->name, "addr", "%s", abuf); diff --git a/bin/varnishtest/vtc_client.c b/bin/varnishtest/vtc_client.c index d0962e5bc..ed81203a9 100644 --- a/bin/varnishtest/vtc_client.c +++ b/bin/varnishtest/vtc_client.c @@ -140,7 +140,7 @@ uds_open(void *priv, const struct sockaddr_un *uds) if (s < 0) return (s); - (void) VTCP_nonblocking(s); + VTCP_nonblocking(s); i = connect(s, (const void*)uds, sl); if (i == 0) return(s); @@ -221,7 +221,7 @@ client_thread(void *priv) vtc_fatal(c->vl, "Failed to open %s: %s", VSB_data(vsb), err); /* VTCP_blocking does its own checks, trust it */ - (void)VTCP_blocking(fd); + VTCP_blocking(fd); if (c->proxy_spec != NULL) client_proxy(vl, fd, c->proxy_version, c->proxy_spec); if (! c->keepalive) diff --git a/bin/varnishtest/vtc_haproxy.c b/bin/varnishtest/vtc_haproxy.c index f8e973701..55e986f57 100644 --- a/bin/varnishtest/vtc_haproxy.c +++ b/bin/varnishtest/vtc_haproxy.c @@ -303,7 +303,7 @@ haproxy_cli_thread(void *priv) if (fd < 0) vtc_fatal(hc->vl, "CLI failed to open %s: %s", VSB_data(vsb), err); - (void)VTCP_blocking(fd); + VTCP_blocking(fd); hc->sock = fd; parse_string(hc->spec, haproxy_cli_cmds, hc, hc->vl); vtc_log(hc->vl, 2, "CLI ending"); diff --git a/bin/varnishtest/vtc_subr.c b/bin/varnishtest/vtc_subr.c index b3584a964..6f6e11eea 100644 --- a/bin/varnishtest/vtc_subr.c +++ b/bin/varnishtest/vtc_subr.c @@ -193,7 +193,7 @@ vtc_record(struct vtclog *vl, int fd, struct vsb *vsb) struct pollfd fds[1]; int i; - (void)VTCP_nonblocking(fd); + VTCP_nonblocking(fd); while (1) { memset(fds, 0, sizeof fds); fds->fd = fd; diff --git a/lib/libvarnish/vtcp.c b/lib/libvarnish/vtcp.c index 759be1f64..85bac3979 100644 --- a/lib/libvarnish/vtcp.c +++ b/lib/libvarnish/vtcp.c @@ -265,7 +265,7 @@ VTCP_connected(int s) return (-1); } - (void)VTCP_blocking(s); + VTCP_blocking(s); return (s); } @@ -292,7 +292,7 @@ VTCP_connect(const struct suckaddr *name, int msec) /* Set the socket non-blocking */ if (msec != 0) - (void)VTCP_nonblocking(s); + VTCP_nonblocking(s); val = 1; AZ(setsockopt(s, IPPROTO_TCP, TCP_NODELAY, &val, sizeof val)); diff --git a/lib/libvarnish/vus.c b/lib/libvarnish/vus.c index f233c5f8f..f3c380920 100644 --- a/lib/libvarnish/vus.c +++ b/lib/libvarnish/vus.c @@ -119,7 +119,7 @@ VUS_connect(const char *path, int msec) /* Set the socket non-blocking */ if (msec != 0) - (void)VTCP_nonblocking(s); + VTCP_nonblocking(s); i = connect(s, (const void*)&uds, sl); if (i == 0) From dridi.boukelmoune at gmail.com Wed Jul 10 07:42:10 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 10 Jul 2019 07:42:10 +0000 (UTC) Subject: [6.0] 15ed6cc87 Fail VCL loading if VMOD objects are left uninitialized. Message-ID: <20190710074210.18B01911A7@lists.varnish-cache.org> commit 15ed6cc87a98648a115c11e25a84d4e51f2315c0 Author: Poul-Henning Kamp Date: Tue Feb 5 10:58:36 2019 +0000 Fail VCL loading if VMOD objects are left uninitialized. Allow VMOD writers to permit with NULL_OK flag. Only call object destructor on initialized objects. Fixes #2839 Conflicts: lib/libvmod_debug/vmod.vcc diff --git a/bin/varnishtest/tests/r02839.vtc b/bin/varnishtest/tests/r02839.vtc new file mode 100644 index 000000000..16525a833 --- /dev/null +++ b/bin/varnishtest/tests/r02839.vtc @@ -0,0 +1,32 @@ +varnishtest "Test uninitialized vmod objects" + +server s1 { + rxreq + txresp +} -start + +varnish v1 -vcl+backend "" -start + +varnish v1 -errvcl "Object vo_null not initialized" { + import debug; + + backend default { .host = "127.0.0.1"; } + + sub vcl_init { + if (false) { + new null = debug.obj(); + } + } +} + +varnish v1 -vcl { + import debug; + + backend default { .host = "127.0.0.1"; } + + sub vcl_init { + if (false) { + new null = debug.obj_opt(); + } + } +} diff --git a/lib/libvcc/vcc_compile.c b/lib/libvcc/vcc_compile.c index 71016bc89..50288c6ef 100644 --- a/lib/libvcc/vcc_compile.c +++ b/lib/libvcc/vcc_compile.c @@ -294,6 +294,7 @@ EmitInitFini(const struct vcc *tl) { struct inifin *p, *q = NULL; unsigned has_event = 0; + struct symbol *sy; Fh(tl, 0, "\n"); Fh(tl, 0, "static unsigned vgc_inistep;\n"); @@ -318,6 +319,13 @@ EmitInitFini(const struct vcc *tl) if (VSB_len(p->event)) has_event = 1; } + VTAILQ_FOREACH(sy, &tl->sym_objects, sideways) { + Fc(tl, 0, "\tif (!%s) {\n", sy->rname); + Fc(tl, 0, "\t\tVRT_fail(ctx, " + "\"Object %s not initialized\");\n" , sy->rname); + Fc(tl, 0, "\t\treturn(1);\n"); + Fc(tl, 0, "\t}\n"); + } Fc(tl, 0, "\treturn(0);\n"); Fc(tl, 0, "}\n"); @@ -745,6 +753,7 @@ VCC_New(void) VTAILQ_INIT(&tl->tokens); VTAILQ_INIT(&tl->sources); VTAILQ_INIT(&tl->procs); + VTAILQ_INIT(&tl->sym_objects); tl->nsources = 0; diff --git a/lib/libvcc/vcc_compile.h b/lib/libvcc/vcc_compile.h index 3a98c76e0..52e0dd282 100644 --- a/lib/libvcc/vcc_compile.h +++ b/lib/libvcc/vcc_compile.h @@ -134,6 +134,7 @@ struct symbol { unsigned magic; #define SYMBOL_MAGIC 0x3368c9fb VTAILQ_ENTRY(symbol) list; + VTAILQ_ENTRY(symbol) sideways; VTAILQ_HEAD(,symbol) children; char *name; @@ -255,6 +256,8 @@ struct vcc { const char *default_director; const char *default_probe; + VTAILQ_HEAD(, symbol) sym_objects; + unsigned unique; unsigned vmod_count; }; diff --git a/lib/libvcc/vcc_vmod.c b/lib/libvcc/vcc_vmod.c index 00f0cb0d0..04537f161 100644 --- a/lib/libvcc/vcc_vmod.c +++ b/lib/libvcc/vcc_vmod.c @@ -353,6 +353,7 @@ vcc_Act_New(struct vcc *tl, struct token *t, struct symbol *sym) struct vsb *buf; const struct vjsn_val *vv, *vf; const char *p; + int null_ok = 0; (void)sym; ExpectErr(tl, ID); @@ -380,8 +381,19 @@ vcc_Act_New(struct vcc *tl, struct token *t, struct symbol *sym) } CAST_OBJ_NOTNULL(vv, sy2->eval_priv, VJSN_VAL_MAGIC); + // vv = object name vv = VTAILQ_NEXT(vv, list); + // vv = flags + assert(vv->type == VJSN_OBJECT); + VTAILQ_FOREACH(vf, &vv->children, list) + if (!strcmp(vf->name, "NULL_OK") && vf->type == VJSN_TRUE) + null_ok = 1; + if (!null_ok) + VTAILQ_INSERT_TAIL(&tl->sym_objects, sy1, sideways); + + vv = VTAILQ_NEXT(vv, list); + // vv = struct name Fh(tl, 0, "static %s *%s;\n\n", vv->value, sy1->rname); vv = VTAILQ_NEXT(vv, list); @@ -412,7 +424,8 @@ vcc_Act_New(struct vcc *tl, struct token *t, struct symbol *sym) vf = VTAILQ_FIRST(&vf->children); vf = VTAILQ_NEXT(vf, list); ifp = New_IniFin(tl); - VSB_printf(ifp->fin, "\t\t%s(&%s);", vf->value, sy1->rname); + VSB_printf(ifp->fin, "\t\tif (%s)\n", sy1->rname); + VSB_printf(ifp->fin, "\t\t\t\t%s(&%s);", vf->value, sy1->rname); /* Instantiate symbols for the methods */ buf = VSB_new_auto(); diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py index 32d4e6f2e..e92cf521e 100755 --- a/lib/libvcc/vmodtool.py +++ b/lib/libvcc/vmodtool.py @@ -500,6 +500,7 @@ class Stanza(object): self.doc = doc self.vcc = vcc self.rstlbl = None + self.null_ok = False self.methods = None self.proto = None self.parse() @@ -720,6 +721,9 @@ class FunctionStanza(Stanza): class ObjectStanza(Stanza): def parse(self): + if self.toks[1] == "NULL_OK": + self.toks.pop(1) + self.null_ok = True self.proto = ProtoType(self, retval=False) self.proto.obj = "x" + self.proto.name @@ -778,6 +782,7 @@ class ObjectStanza(Stanza): ll = [ "$OBJ", self.proto.name, + { "NULL_OK": self.null_ok }, "struct %s%s_%s" % (self.vcc.sympfx, self.vcc.modname, self.proto.name), ] diff --git a/lib/libvmod_debug/vmod.vcc b/lib/libvmod_debug/vmod.vcc index 04d0088d9..12f309f38 100644 --- a/lib/libvmod_debug/vmod.vcc +++ b/lib/libvmod_debug/vmod.vcc @@ -207,7 +207,7 @@ $Function VOID sethdr(HEADER, STRANDS) Set the given header with the concatenation of the given strings. -$Object obj_opt(PRIV_CALL, PRIV_VCL, PRIV_TASK, +$Object NULL_OK obj_opt(PRIV_CALL, PRIV_VCL, PRIV_TASK, [STRING s], [BOOL b]) Test object constructor with all the fancy stuff. diff --git a/lib/libvmod_debug/vmod_debug_obj.c b/lib/libvmod_debug/vmod_debug_obj.c index 9038bcb81..3388fab4e 100644 --- a/lib/libvmod_debug/vmod_debug_obj.c +++ b/lib/libvmod_debug/vmod_debug_obj.c @@ -68,7 +68,6 @@ xyzzy_obj__fini(struct xyzzy_debug_obj **op) AN(op); AN(*op); FREE_OBJ(*op); - *op = NULL; } VCL_VOID v_matchproto_() @@ -202,8 +201,7 @@ xyzzy_obj_opt__fini(struct xyzzy_debug_obj_opt **op) struct xyzzy_debug_obj_opt *o; AN(op); - if (*op == NULL) - return; /* init has failed */ + AN(*op); TAKE_OBJ_NOTNULL(o, op, VMOD_DEBUG_OBJ_OPT_MAGIC); From dridi.boukelmoune at gmail.com Wed Jul 10 10:00:13 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 10 Jul 2019 10:00:13 +0000 (UTC) Subject: [master] 5e98a8d4c Explain how r02976.vtc works Message-ID: <20190710100013.D376B957C4@lists.varnish-cache.org> commit 5e98a8d4ce24eb69f0d5ef19738758661884adc5 Author: Dridi Boukelmoune Date: Wed Jul 10 11:55:28 2019 +0200 Explain how r02976.vtc works It's really not obvious, and if it weren't for other tests covering probes it wouldn't be enough by itself to verify what it needs to. diff --git a/bin/varnishtest/tests/r02976.vtc b/bin/varnishtest/tests/r02976.vtc index fdfe50fdf..e03383069 100644 --- a/bin/varnishtest/tests/r02976.vtc +++ b/bin/varnishtest/tests/r02976.vtc @@ -1,5 +1,9 @@ varnishtest "Detect probe interval inversion" +# For lack of a better mechanism this test passes by not timing out. +# This is not enough to guarantee that there wasn't a bug in probe +# scheduling but it's enough to avoid running into #2976 again. + server s1 -repeat 5 { # probe requests rxreq txresp From dridi.boukelmoune at gmail.com Thu Jul 11 09:35:10 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 11 Jul 2019 09:35:10 +0000 (UTC) Subject: [6.0] 5c37624f8 wake up vbp_thread after a probe is done Message-ID: <20190711093510.B9F8161C9A@lists.varnish-cache.org> commit 5c37624f84bcd594d55bf117b0ab710b3874afe9 Author: Nils Goroll Date: Wed Apr 17 10:36:45 2019 +0200 wake up vbp_thread after a probe is done The due time of the probe which has just finished may be earlier than the previously earliest due time, so vbp_thread needs to be woken up to update the nxt value Fixes #2976 diff --git a/bin/varnishd/cache/cache_backend_probe.c b/bin/varnishd/cache/cache_backend_probe.c index f632af865..9ed6e515c 100644 --- a/bin/varnishd/cache/cache_backend_probe.c +++ b/bin/varnishd/cache/cache_backend_probe.c @@ -439,6 +439,7 @@ vbp_task(struct worker *wrk, void *priv) vt->due = VTIM_real() + vt->interval; binheap_delete(vbp_heap, vt->heap_idx); binheap_insert(vbp_heap, vt); + AZ(pthread_cond_signal(&vbp_cond)); } } Lck_Unlock(&vbp_mtx); From dridi.boukelmoune at gmail.com Thu Jul 11 09:35:10 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 11 Jul 2019 09:35:10 +0000 (UTC) Subject: [6.0] 2fdb50bae Add test case by @rezan for #2976. Message-ID: <20190711093510.D21C461C9C@lists.varnish-cache.org> commit 2fdb50bae533c0c04c3916bfcbb83d22766d768e Author: Martin Blix Grydeland Date: Tue Apr 23 15:32:00 2019 +0200 Add test case by @rezan for #2976. diff --git a/bin/varnishtest/tests/r02976.vtc b/bin/varnishtest/tests/r02976.vtc new file mode 100644 index 000000000..421cb3fe9 --- /dev/null +++ b/bin/varnishtest/tests/r02976.vtc @@ -0,0 +1,53 @@ +varnishtest "Detect probe interval inversion" + +barrier bprobe cond 2 + +server s1 { + # 5 probe requests + rxreq + txresp + close + accept + rxreq + txresp + close + accept + rxreq + txresp + close + accept + rxreq + txresp + close + accept + rxreq + txresp + close + accept + barrier bprobe sync +} -start + +varnish v1 -vcl { + backend b1 { + .host = "${s1_addr}"; + .port = "${s1_port}"; + .probe = { + .interval = 1s; + } + } + + backend b2 { + .host = "${bad_ip}"; + .probe = { + .interval = 24h; + } + } + + sub vcl_recv { + if (!req.url) { + set req.backend_hint = b2; + } + } +} -start + +barrier bprobe sync \ No newline at end of file From dridi.boukelmoune at gmail.com Thu Jul 11 09:35:10 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 11 Jul 2019 09:35:10 +0000 (UTC) Subject: [6.0] 5ac1172f2 Polish Message-ID: <20190711093510.F1FD461C9F@lists.varnish-cache.org> commit 5ac1172f23b89c427ec376f9da50e664e499abe0 Author: Dridi Boukelmoune Date: Mon Jun 24 10:16:10 2019 +0200 Polish diff --git a/bin/varnishtest/tests/r02976.vtc b/bin/varnishtest/tests/r02976.vtc index 421cb3fe9..218c027f5 100644 --- a/bin/varnishtest/tests/r02976.vtc +++ b/bin/varnishtest/tests/r02976.vtc @@ -37,7 +37,7 @@ varnish v1 -vcl { } backend b2 { - .host = "${bad_ip}"; + .host = "${bad_backend}"; .probe = { .interval = 24h; } @@ -50,4 +50,4 @@ varnish v1 -vcl { } } -start -barrier bprobe sync \ No newline at end of file +barrier bprobe sync From dridi.boukelmoune at gmail.com Thu Jul 11 09:35:11 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 11 Jul 2019 09:35:11 +0000 (UTC) Subject: [6.0] e732dd37c Make b1 and b2 look similar, and more compact Message-ID: <20190711093511.21A8D61CA5@lists.varnish-cache.org> commit e732dd37c6a9e50b6d61a08e08358ced7fe41dac Author: Dridi Boukelmoune Date: Mon Jun 24 13:59:49 2019 +0200 Make b1 and b2 look similar, and more compact diff --git a/bin/varnishtest/tests/r02976.vtc b/bin/varnishtest/tests/r02976.vtc index 218c027f5..6fbb57e03 100644 --- a/bin/varnishtest/tests/r02976.vtc +++ b/bin/varnishtest/tests/r02976.vtc @@ -29,18 +29,13 @@ server s1 { varnish v1 -vcl { backend b1 { - .host = "${s1_addr}"; - .port = "${s1_port}"; - .probe = { - .interval = 1s; - } + .host = "${s1_sock}"; + .probe = { .interval = 1s; } } backend b2 { .host = "${bad_backend}"; - .probe = { - .interval = 24h; - } + .probe = { .interval = 24h; } } sub vcl_recv { From dridi.boukelmoune at gmail.com Thu Jul 11 09:35:11 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 11 Jul 2019 09:35:11 +0000 (UTC) Subject: [6.0] 456f5546a Simplify r02976.vtc further Message-ID: <20190711093511.41CD361CA9@lists.varnish-cache.org> commit 456f5546a443473fbdf2f2767b8bfdc9dba828de Author: Dridi Boukelmoune Date: Mon Jun 24 14:08:28 2019 +0200 Simplify r02976.vtc further This time, once and for all. diff --git a/bin/varnishtest/tests/r02976.vtc b/bin/varnishtest/tests/r02976.vtc index 6fbb57e03..f3a7aa2ce 100644 --- a/bin/varnishtest/tests/r02976.vtc +++ b/bin/varnishtest/tests/r02976.vtc @@ -27,6 +27,8 @@ server s1 { barrier bprobe sync } -start +varnish v1 -cliok {param.set vcc_err_unref off} + varnish v1 -vcl { backend b1 { .host = "${s1_sock}"; @@ -37,12 +39,6 @@ varnish v1 -vcl { .host = "${bad_backend}"; .probe = { .interval = 24h; } } - - sub vcl_recv { - if (!req.url) { - set req.backend_hint = b2; - } - } } -start barrier bprobe sync From dridi.boukelmoune at gmail.com Thu Jul 11 09:35:11 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 11 Jul 2019 09:35:11 +0000 (UTC) Subject: [6.0] 7561e59bc Simplify r02976.vtc furtherer Message-ID: <20190711093511.6466561CAE@lists.varnish-cache.org> commit 7561e59bc33958e5cbd79ba276ab280afe9fff9f Author: Dridi Boukelmoune Date: Mon Jun 24 18:09:48 2019 +0200 Simplify r02976.vtc furtherer I was wrong, or I lied. This is the final cleanup. diff --git a/bin/varnishtest/tests/r02976.vtc b/bin/varnishtest/tests/r02976.vtc index f3a7aa2ce..fdfe50fdf 100644 --- a/bin/varnishtest/tests/r02976.vtc +++ b/bin/varnishtest/tests/r02976.vtc @@ -1,30 +1,8 @@ varnishtest "Detect probe interval inversion" -barrier bprobe cond 2 - -server s1 { - # 5 probe requests - rxreq - txresp - close - accept - rxreq - txresp - close - accept - rxreq - txresp - close - accept - rxreq - txresp - close - accept +server s1 -repeat 5 { # probe requests rxreq txresp - close - accept - barrier bprobe sync } -start varnish v1 -cliok {param.set vcc_err_unref off} @@ -41,4 +19,4 @@ varnish v1 -vcl { } } -start -barrier bprobe sync +server s1 -wait From dridi.boukelmoune at gmail.com Thu Jul 11 09:35:11 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 11 Jul 2019 09:35:11 +0000 (UTC) Subject: [6.0] 9950f763a Explain how r02976.vtc works Message-ID: <20190711093511.844B861CBA@lists.varnish-cache.org> commit 9950f763ab6f9da64682a71ab28f226742640324 Author: Dridi Boukelmoune Date: Wed Jul 10 11:55:28 2019 +0200 Explain how r02976.vtc works It's really not obvious, and if it weren't for other tests covering probes it wouldn't be enough by itself to verify what it needs to. diff --git a/bin/varnishtest/tests/r02976.vtc b/bin/varnishtest/tests/r02976.vtc index fdfe50fdf..e03383069 100644 --- a/bin/varnishtest/tests/r02976.vtc +++ b/bin/varnishtest/tests/r02976.vtc @@ -1,5 +1,9 @@ varnishtest "Detect probe interval inversion" +# For lack of a better mechanism this test passes by not timing out. +# This is not enough to guarantee that there wasn't a bug in probe +# scheduling but it's enough to avoid running into #2976 again. + server s1 -repeat 5 { # probe requests rxreq txresp From dridi.boukelmoune at gmail.com Thu Jul 11 09:35:11 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 11 Jul 2019 09:35:11 +0000 (UTC) Subject: [6.0] 75cc65021 Make clear that the second field is actually 2 Message-ID: <20190711093511.A63FB61CDC@lists.varnish-cache.org> commit 75cc650214954fd0d1d9f412e78669ce320176bc Author: Federico G. Schwindt Date: Thu Jan 17 12:02:49 2019 +0000 Make clear that the second field is actually 2 Addresses the doc part of #2872. diff --git a/include/tbl/vsl_tags.h b/include/tbl/vsl_tags.h index 698807b17..dc3a7a668 100644 --- a/include/tbl/vsl_tags.h +++ b/include/tbl/vsl_tags.h @@ -417,17 +417,18 @@ SLTM(Hash, SLT_F_UNSAFE, "Value added to hash", SLTM(Backend_health, 0, "Backend health check", "The result of a backend health probe.\n\n" "The format is::\n\n" - "\t%s %s %s %u %u %u %f %f %s\n" - "\t| | | | | | | | |\n" - "\t| | | | | | | | +- Probe HTTP response / error information\n" - "\t| | | | | | | +---- Average response time\n" - "\t| | | | | | +------- Response time\n" - "\t| | | | | +---------- Probe window size\n" - "\t| | | | +------------- Probe threshold level\n" - "\t| | | +---------------- Number of good probes in window\n" - "\t| | +------------------- Probe window bits\n" - "\t| +---------------------- Status message\n" - "\t+------------------------- Backend name\n" + "\t%s %s %s %s %u %u %u %f %f %s\n" + "\t| | | | | | | | | |\n" + "\t| | | | | | | | | +- Probe HTTP response / error information\n" + "\t| | | | | | | | +---- Average response time\n" + "\t| | | | | | | +------- Response time\n" + "\t| | | | | | +---------- Probe window size\n" + "\t| | | | | +------------- Probe threshold level\n" + "\t| | | | +---------------- Number of good probes in window\n" + "\t| | | +------------------- Probe window bits\n" + "\t| | +---------------------- \"healthy\" or \"sick\"\n" + "\t| +------------------------- \"Back\", \"Still\" or \"Went\"\n" + "\t+---------------------------- Backend name\n" "\n" "Probe window bits are::\n\n" From dridi.boukelmoune at gmail.com Thu Jul 11 09:35:11 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 11 Jul 2019 09:35:11 +0000 (UTC) Subject: [6.0] 4c10ca243 Whitespace Message-ID: <20190711093511.C7E3461CFB@lists.varnish-cache.org> commit 4c10ca24309529a40f3c29a17a3e2832251fec95 Author: Federico G. Schwindt Date: Thu Jan 17 12:04:51 2019 +0000 Whitespace diff --git a/doc/sphinx/Makefile.am b/doc/sphinx/Makefile.am index 0ff57bd96..d9be207ac 100644 --- a/doc/sphinx/Makefile.am +++ b/doc/sphinx/Makefile.am @@ -192,7 +192,7 @@ include/varnishstat_synopsis.rst: $(top_builddir)/bin/varnishstat/varnishstat BUILT_SOURCES += include/varnishstat_options.rst \ include/varnishstat_synopsis.rst -include/vsl-tags.rst: $(top_builddir)/lib/libvarnishapi/vsl2rst +include/vsl-tags.rst: $(top_builddir)/lib/libvarnishapi/vsl2rst $(top_builddir)/lib/libvarnishapi/vsl2rst > ${@}_ mv ${@}_ ${@} BUILT_SOURCES += include/vsl-tags.rst diff --git a/doc/sphinx/phk/lucky.rst b/doc/sphinx/phk/lucky.rst index 328f66e6a..6a4393c97 100644 --- a/doc/sphinx/phk/lucky.rst +++ b/doc/sphinx/phk/lucky.rst @@ -96,7 +96,7 @@ Varnish Moral License --------------------- I want to thank the companies who have paid for a `Varnish -Moral License `_: +Moral License `_: * Fastly @@ -176,4 +176,4 @@ Good luck! .. [#f2] And it does not feel any less awful if the loved ones left behind tries to fill the blanks by asking you how you knew each other and if you have any memories you could share with them. - + From dridi.boukelmoune at gmail.com Thu Jul 11 09:35:11 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 11 Jul 2019 09:35:11 +0000 (UTC) Subject: [6.0] 66572d219 Monday morning flexelinting Message-ID: <20190711093511.EBA8261D05@lists.varnish-cache.org> commit 66572d219cc36b8f598fa50f0c843b0cc550b3d8 Author: Poul-Henning Kamp Date: Mon Jan 21 09:16:46 2019 +0000 Monday morning flexelinting diff --git a/bin/varnishadm/varnishadm.c b/bin/varnishadm/varnishadm.c index 750f5ddf7..7a09edf6a 100644 --- a/bin/varnishadm/varnishadm.c +++ b/bin/varnishadm/varnishadm.c @@ -73,7 +73,7 @@ } while (0) -static double timeout = 5; +static double timeout = 5; // XXX should be settable by arg ? static void cli_write(int sock, const char *s) @@ -192,7 +192,7 @@ send_line(char *l) cli_write(_line_sock, l); cli_write(_line_sock, "\n"); if (*l) - add_history(l); + AZ(add_history(l)); rl_callback_handler_install("varnish> ", send_line); } else { RL_EXIT(0); @@ -234,6 +234,29 @@ varnishadm_completion (const char *text, int start, int end) return (matches); } +static void +pass_answer(int fd) +{ + unsigned u, status; + char *answer = NULL; + + u = VCLI_ReadResult(fd, &status, &answer, timeout); + if (u) { + if (status == CLIS_COMMS) + RL_EXIT(0); + if (answer) + fprintf(stderr, "%s\n", answer); + RL_EXIT(1); + } + + printf("%u\n", status); + if (answer) { + printf("%s\n", answer); + free(answer); + } + (void)fflush(stdout); +} + /* * No arguments given, simply pass bytes on stdin/stdout and CLI socket * Send a "banner" to varnish, to provoke a welcome message. @@ -242,7 +265,6 @@ static void interactive(int sock) { struct pollfd fds[2]; - char buf[1024]; int i; char *answer = NULL; unsigned u, status; @@ -293,25 +315,8 @@ interactive(int sock) assert(i > 0); if (fds[0].revents & POLLIN) { /* Get rid of the prompt, kinda hackish */ - u = write(1, "\r \r", 13); - u = VCLI_ReadResult(fds[0].fd, &status, &answer, - timeout); - if (u) { - if (status == CLIS_COMMS) - RL_EXIT(0); - if (answer) - fprintf(stderr, "%s\n", answer); - RL_EXIT(1); - } - - bprintf(buf, "%u\n", status); - u = write(1, buf, strlen(buf)); - if (answer) { - u = write(1, answer, strlen(answer)); - u = write(1, "\n", 1); - free(answer); - answer = NULL; - } + printf("\r \r"); + pass_answer(fds[0].fd); rl_forced_update_display(); } if (fds[1].revents & POLLIN) { @@ -329,8 +334,6 @@ pass(int sock) struct pollfd fds[2]; char buf[1024]; int i; - char *answer = NULL; - unsigned u, status; ssize_t n; fds[0].fd = sock; @@ -343,26 +346,8 @@ pass(int sock) continue; } assert(i > 0); - if (fds[0].revents & POLLIN) { - u = VCLI_ReadResult(fds[0].fd, &status, &answer, - timeout); - if (u) { - if (status == CLIS_COMMS) - RL_EXIT(0); - if (answer) - fprintf(stderr, "%s\n", answer); - RL_EXIT(1); - } - - bprintf(buf, "%u\n", status); - u = write(1, buf, strlen(buf)); - if (answer) { - u = write(1, answer, strlen(answer)); - u = write(1, "\n", 1); - free(answer); - answer = NULL; - } - } + if (fds[0].revents & POLLIN) + pass_answer(fds[0].fd); if (fds[1].revents & POLLIN || fds[1].revents & POLLHUP) { n = read(fds[1].fd, buf, sizeof buf - 1); if (n == 0) { @@ -392,8 +377,8 @@ usage(int status) static int n_arg_sock(const char *n_arg, const char *t_arg) { - char *T_arg = NULL, *T_start = NULL; - char *S_arg = NULL; + char *T_arg, *T_start; + char *S_arg; struct vsm *vsm; char *p; int sock; diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index 4c999c350..95bc5f2ed 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -784,7 +784,9 @@ ved_stripgzip(struct req *req, const struct boc *boc) ecx->l_crc += ilen; } -/*--------------------------------------------------------------------*/ +/*-------------------------------------------------------------------- + * Straight through without processing. + */ static int v_matchproto_(vdp_fini_f) ved_vdp_fini(struct req *req, void **priv) diff --git a/lib/libvmod_blob/base64.c b/lib/libvmod_blob/base64.c index 3bea94871..20a4ac877 100644 --- a/lib/libvmod_blob/base64.c +++ b/lib/libvmod_blob/base64.c @@ -140,6 +140,7 @@ base64_decode(const enum encoding dec, char *restrict const buf, unsigned u = 0, term = 0; int n = 0; size_t len = SIZE_MAX; + const char *s; AN(buf); AN(alpha); @@ -149,7 +150,7 @@ base64_decode(const enum encoding dec, char *restrict const buf, len = inlen; for (int i = 0; len > 0 && i < strings->n; i++) { - const char *s = strings->p[i]; + s = strings->p[i]; if (s == NULL) continue; @@ -159,7 +160,7 @@ base64_decode(const enum encoding dec, char *restrict const buf, } while (*s && len) { while (n < 4) { - char b = alpha->i64[(unsigned) *s++]; + char b = alpha->i64[(uint8_t) *s++]; u <<= 6; if (b == ILL) { errno = EINVAL; @@ -170,7 +171,7 @@ base64_decode(const enum encoding dec, char *restrict const buf, term++; continue; } - u |= (unsigned) b; + u |= (uint8_t) b; if (--len == 0) break; if (!*s) diff --git a/lib/libvmod_debug/vmod_debug_obj.c b/lib/libvmod_debug/vmod_debug_obj.c index 3388fab4e..82bc00389 100644 --- a/lib/libvmod_debug/vmod_debug_obj.c +++ b/lib/libvmod_debug/vmod_debug_obj.c @@ -181,6 +181,8 @@ xyzzy_obj_opt__init(VRT_CTX, if (args->valid_s) AN(args->s); + (void)args->valid_b; + (void)args->b; AN(op); AZ(*op); diff --git a/lib/libvmod_directors/shard_dir.h b/lib/libvmod_directors/shard_dir.h index eeb17df64..e3a8b3128 100644 --- a/lib/libvmod_directors/shard_dir.h +++ b/lib/libvmod_directors/shard_dir.h @@ -42,10 +42,8 @@ enum healthy_e { }; enum resolve_e { - _RESOLVE_E_INVALID = 0, #define VMODENUM(x) x, #include "tbl_resolve.h" - _RESOLVE_E_MAX }; struct vbitmap; From dridi.boukelmoune at gmail.com Thu Jul 11 09:35:12 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 11 Jul 2019 09:35:12 +0000 (UTC) Subject: [6.0] 50a1d7a8a add_history() has variant definitions Message-ID: <20190711093512.1913B61D14@lists.varnish-cache.org> commit 50a1d7a8acf63479de032a81f9fac11926e0630b Author: Poul-Henning Kamp Date: Mon Jan 21 09:34:18 2019 +0000 add_history() has variant definitions diff --git a/bin/varnishadm/varnishadm.c b/bin/varnishadm/varnishadm.c index 7a09edf6a..13c9d7c8d 100644 --- a/bin/varnishadm/varnishadm.c +++ b/bin/varnishadm/varnishadm.c @@ -192,7 +192,7 @@ send_line(char *l) cli_write(_line_sock, l); cli_write(_line_sock, "\n"); if (*l) - AZ(add_history(l)); + add_history(l); rl_callback_handler_install("varnish> ", send_line); } else { RL_EXIT(0); diff --git a/flint.lnt b/flint.lnt index 0a9d6e9f0..11169b612 100644 --- a/flint.lnt +++ b/flint.lnt @@ -193,6 +193,11 @@ -esym(785,VSL_tags) // Sparse array +/////////////////////////////////////////////////////////////////////// +// readline etc. + +-esym(534, add_history) + /////////////////////////////////////////////////////////////////////// // -lcurses -esym(534, beep) From dridi.boukelmoune at gmail.com Thu Jul 11 09:35:12 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 11 Jul 2019 09:35:12 +0000 (UTC) Subject: [6.0] 28c249cdb Document disuse of SLT_Backend. Message-ID: <20190711093512.3A8AE61D27@lists.varnish-cache.org> commit 28c249cdb6801d550f80ade30368dfba97570238 Author: Geoff Simmons Date: Mon Jan 21 10:29:59 2019 +0100 Document disuse of SLT_Backend. Closes #2870 Conflicts: include/tbl/vsl_tags.h We can use the NOSUP_NOTICE instead. diff --git a/include/tbl/vsl_tags.h b/include/tbl/vsl_tags.h index dc3a7a668..a99fe9fcf 100644 --- a/include/tbl/vsl_tags.h +++ b/include/tbl/vsl_tags.h @@ -165,6 +165,7 @@ SLTM(Backend, 0, "Backend selected", "\t| +---- VCL name\n" "\t+------- Connection file descriptor\n" "\n" + NOSUP_NOTICE ) SLTM(Length, 0, "Size of object body", From dridi.boukelmoune at gmail.com Thu Jul 11 09:35:12 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 11 Jul 2019 09:35:12 +0000 (UTC) Subject: [6.0] 8bdc88de0 Define VTEST_WITH_ macros Message-ID: <20190711093512.5881F61D32@lists.varnish-cache.org> commit 8bdc88de08e5a22d670648b57f722d9c53a9c5ab Author: Poul-Henning Kamp Date: Mon Jan 21 09:31:00 2019 +0000 Define VTEST_WITH_ macros diff --git a/bin/varnishtest/flint.sh b/bin/varnishtest/flint.sh index 49f5e2db8..2512c7e04 100755 --- a/bin/varnishtest/flint.sh +++ b/bin/varnishtest/flint.sh @@ -1,6 +1,8 @@ #!/bin/sh FLOPS=' + -DVTEST_WITH_VTC_LOGEXPECT + -DVTEST_WITH_VTC_VARNISH -DTOP_BUILDDIR="foo" -I../../lib/libvgz *.c From dridi.boukelmoune at gmail.com Thu Jul 11 09:35:12 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 11 Jul 2019 09:35:12 +0000 (UTC) Subject: [6.0] 74819fb07 Ignore a curses function return value Message-ID: <20190711093512.75A4461D48@lists.varnish-cache.org> commit 74819fb07587e9dda0da975c8792956ab804983e Author: Poul-Henning Kamp Date: Mon Jan 21 09:50:02 2019 +0000 Ignore a curses function return value diff --git a/flint.lnt b/flint.lnt index 11169b612..fc6666be4 100644 --- a/flint.lnt +++ b/flint.lnt @@ -209,6 +209,7 @@ -esym(534, intrflush) -esym(534, keypad) -esym(534, mvprintw) +-esym(534, waddnstr) -esym(534, mvwprintw) -esym(534, nodelay) -esym(534, noecho) From dridi.boukelmoune at gmail.com Thu Jul 11 09:35:12 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 11 Jul 2019 09:35:12 +0000 (UTC) Subject: [6.0] d83e25bd7 Test more of the fallback director Message-ID: <20190711093512.911EC61D57@lists.varnish-cache.org> commit d83e25bd7402818191872b089c3c4f30c3657c3b Author: Poul-Henning Kamp Date: Mon Jan 21 09:50:17 2019 +0000 Test more of the fallback director diff --git a/bin/varnishtest/tests/d00001.vtc b/bin/varnishtest/tests/d00001.vtc index 405147615..1ebae04d2 100644 --- a/bin/varnishtest/tests/d00001.vtc +++ b/bin/varnishtest/tests/d00001.vtc @@ -16,6 +16,7 @@ server s3 { } -start varnish v1 -vcl+backend { + import std; import directors; sub vcl_init { @@ -33,11 +34,17 @@ varnish v1 -vcl+backend { return (pass); } + sub vcl_deliver { + set resp.http.health = std.healthy(fb1.backend()); + } + sub vcl_backend_fetch { set bereq.backend = fb1.backend(); } } -start +varnish v1 -cliok "param.set debug +vclrel" + varnish v1 -cliok "backend.set_health s1 sick" varnish v1 -cliok "backend.set_health s2 sick" @@ -48,6 +55,8 @@ client c1 { expect resp.http.foo == "3" } -run +varnish v1 -vsl_catchup + varnish v1 -cliok "backend.set_health s2 healthy" client c1 { @@ -56,6 +65,8 @@ client c1 { expect resp.http.foo == "2" } -run +varnish v1 -vsl_catchup + varnish v1 -cliok "backend.set_health s1 healthy" client c1 { @@ -64,6 +75,8 @@ client c1 { expect resp.http.foo == "1" } -run +varnish v1 -vsl_catchup + varnish v1 -cliok "backend.set_health s1 sick" server s3 -start @@ -75,3 +88,15 @@ client c1 { rxresp expect resp.http.foo == "3" } -run + +varnish v1 -vsl_catchup + +varnish v1 -vcl+backend { + sub vcl_recv { + set req.backend_hint = s1; + set req.backend_hint = s2; + set req.backend_hint = s3; + } +} +varnish v1 -cliok "vcl.discard vcl1" +varnish v1 -cliok "vcl.list" From dridi.boukelmoune at gmail.com Thu Jul 11 09:35:12 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 11 Jul 2019 09:35:12 +0000 (UTC) Subject: [6.0] 68b59c51f improve vmod_blob description Message-ID: <20190711093512.AD4D561D64@lists.varnish-cache.org> commit 68b59c51f61e9e6d55e84c5156cfee3d56916df7 Author: Nils Goroll Date: Tue Jan 22 07:00:47 2019 +0100 improve vmod_blob description Encoding and decoding are as much a function as handling blobs, in particular with transcode(). diff --git a/lib/libvmod_blob/vmod.vcc b/lib/libvmod_blob/vmod.vcc index 1ea3716d4..a5b6ae4fd 100644 --- a/lib/libvmod_blob/vmod.vcc +++ b/lib/libvmod_blob/vmod.vcc @@ -6,7 +6,7 @@ # Geoffrey Simmons # -$Module blob 3 "Utilities for the VCL blob type" +$Module blob 3 "Utilities for the VCL blob type, encoding and decoding" $ABI strict From dridi.boukelmoune at gmail.com Thu Jul 11 09:35:12 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 11 Jul 2019 09:35:12 +0000 (UTC) Subject: [6.0] 81c726aec Document the link between varnishd -l and -p Message-ID: <20190711093512.C7B8061D79@lists.varnish-cache.org> commit 81c726aec60ecf758b8df7eadb2a4d3f0e124c1d Author: Dridi Boukelmoune Date: Tue Jan 22 08:33:48 2019 +0100 Document the link between varnishd -l and -p diff --git a/doc/sphinx/reference/varnishd.rst b/doc/sphinx/reference/varnishd.rst index 57c657711..9f6f8fb77 100644 --- a/doc/sphinx/reference/varnishd.rst +++ b/doc/sphinx/reference/varnishd.rst @@ -207,9 +207,9 @@ Tuning options -l - Specifies size of the space for the VSL records. - Scaling suffixes like 'K' and 'M' can be used up to (G)igabytes. - Default is 80 Megabytes. + Specifies size of the space for the VSL records, shorthand for + ``-p vsl_space=``. Scaling suffixes like 'K' and 'M' can be + used up to (G)igabytes. See `vsl_space`_ for more information. Security options ---------------- From dridi.boukelmoune at gmail.com Thu Jul 11 09:35:12 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 11 Jul 2019 09:35:12 +0000 (UTC) Subject: [6.0] 1c15989ac Better coverage of random director Message-ID: <20190711093512.E558E61D84@lists.varnish-cache.org> commit 1c15989ac1c74bf585fd982ea00adc0eb4605e16 Author: Poul-Henning Kamp Date: Tue Jan 22 07:30:41 2019 +0000 Better coverage of random director diff --git a/bin/varnishtest/tests/d00002.vtc b/bin/varnishtest/tests/d00002.vtc index b13518ca1..a5ed1aeb2 100644 --- a/bin/varnishtest/tests/d00002.vtc +++ b/bin/varnishtest/tests/d00002.vtc @@ -9,6 +9,7 @@ server s1 { varnish v1 -vcl+backend { import directors; + import std; sub vcl_init { new foo = directors.random(); @@ -22,6 +23,7 @@ varnish v1 -vcl+backend { sub vcl_backend_response { set beresp.http.where = bereq.backend + "-->" + beresp.backend; + set beresp.http.health = std.healthy(foo.backend()); } } -start From dridi.boukelmoune at gmail.com Thu Jul 11 11:54:08 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 11 Jul 2019 11:54:08 +0000 (UTC) Subject: [master] 4cec396d7 Polish Message-ID: <20190711115408.15C4E6E0CF@lists.varnish-cache.org> commit 4cec396d78cd4b8e5361196e1c705410d14b09e7 Author: Dridi Boukelmoune Date: Thu Jul 11 13:53:36 2019 +0200 Polish diff --git a/lib/libvmod_debug/vmod_debug.c b/lib/libvmod_debug/vmod_debug.c index 8ded76669..2606ae274 100644 --- a/lib/libvmod_debug/vmod_debug.c +++ b/lib/libvmod_debug/vmod_debug.c @@ -603,11 +603,7 @@ xyzzy_concat__fini(struct xyzzy_debug_concat **concatp) struct xyzzy_debug_concat *concat; void *p; - if (concatp == NULL || *concatp == NULL) - return; - CHECK_OBJ(*concatp, CONCAT_MAGIC); - concat = *concatp; - *concatp = NULL; + TAKE_OBJ_NOTNULL(concat, concatp, CONCAT_MAGIC); p = TRUST_ME(concat->s); free(p); FREE_OBJ(concat); From dridi.boukelmoune at gmail.com Mon Jul 15 16:56:08 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 15 Jul 2019 16:56:08 +0000 (UTC) Subject: [master] 6a969b2c0 A more friendly overrun panic for VSL consumers Message-ID: <20190715165608.0C90394C30@lists.varnish-cache.org> commit 6a969b2c0309c639e2ba5410d5f1733c9e4ad64c Author: Dridi Boukelmoune Date: Mon Jul 15 18:50:34 2019 +0200 A more friendly overrun panic for VSL consumers diff --git a/lib/libvarnishapi/vsl_dispatch.c b/lib/libvarnishapi/vsl_dispatch.c index 4bef6b233..e563ef751 100644 --- a/lib/libvarnishapi/vsl_dispatch.c +++ b/lib/libvarnishapi/vsl_dispatch.c @@ -274,6 +274,7 @@ vslc_vtx_next(const struct VSL_cursor *cursor) { struct vslc_vtx *c; const uint32_t *ptr; + unsigned overrun; CAST_OBJ_NOTNULL(c, cursor->priv_data, VSLC_VTX_MAGIC); assert(&c->cursor == cursor); @@ -287,7 +288,8 @@ vslc_vtx_next(const struct VSL_cursor *cursor) c->cursor.rec.ptr = c->synth->data; c->synth = VTAILQ_NEXT(c->synth, list); } else { - assert(c->offset <= c->vtx->len); + overrun = c->offset > c->vtx->len; + AZ(overrun); if (c->offset == c->vtx->len) return (vsl_end); From fgsch at lodoss.net Fri Jul 19 10:50:08 2019 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Fri, 19 Jul 2019 10:50:08 +0000 (UTC) Subject: [master] 215fe8eb8 Update device detection VCL Message-ID: <20190719105008.8B08060234@lists.varnish-cache.org> commit 215fe8eb8c47450d1e67e35603c8e28f128ffaf6 Author: Federico G. Schwindt Date: Thu Jul 18 00:41:38 2019 +0100 Update device detection VCL diff --git a/etc/devicedetect.vcl b/etc/devicedetect.vcl index 1910743f4..cabc16a45 100644 --- a/etc/devicedetect.vcl +++ b/etc/devicedetect.vcl @@ -1,4 +1,6 @@ -# Copyright (c) 2012-2014 Varnish Software AS +# +# Copyright (c) 2016-2018 Varnish Cache project +# Copyright (c) 2012-2016 Varnish Software AS # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions @@ -24,7 +26,7 @@ # detectdevice.vcl - regex based device detection for Varnish # https://github.com/varnishcache/varnish-devicedetect/ # -# Author: Lasse Karstensen +# Original author: Lasse Karstensen sub devicedetect { unset req.http.X-UA-Device; @@ -45,7 +47,10 @@ sub devicedetect { 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" || + req.http.User-Agent ~ "(?i)pingdom" || + req.http.User-Agent ~ "(?i)facebookexternalhit" || req.http.User-Agent ~ "(?i)scanner" || + req.http.User-Agent ~ "(?i)slurp" || req.http.User-Agent ~ "(?i)(web)crawler") { set req.http.X-UA-Device = "bot"; } elsif (req.http.User-Agent ~ "(?i)ipad") { set req.http.X-UA-Device = "tablet-ipad"; } @@ -94,8 +99,6 @@ sub devicedetect { req.http.User-Agent ~ "(?i)playstation portable" || req.http.User-Agent ~ "(?i)portalmmm" || req.http.User-Agent ~ "(?i)proxinet" || - req.http.User-Agent ~ "(?i)sonyericsson" || - req.http.User-Agent ~ "(?i)symbian" || req.http.User-Agent ~ "(?i)windows\ ?ce" || req.http.User-Agent ~ "(?i)winwap" || req.http.User-Agent ~ "(?i)eudoraweb" || From phk at FreeBSD.org Wed Jul 31 09:00:18 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 31 Jul 2019 09:00:18 +0000 (UTC) Subject: [master] 11b7ba303 Close socket on server -break Message-ID: <20190731090018.4914C2B4F@lists.varnish-cache.org> commit 11b7ba303bc48ec01a08248fde39d15364e4231a Author: Poul-Henning Kamp Date: Mon Jul 29 11:12:44 2019 +0000 Close socket on server -break Submitted by: Frederic Lecaille diff --git a/bin/varnishtest/vtc_server.c b/bin/varnishtest/vtc_server.c index 5b05f19cc..160e165d7 100644 --- a/bin/varnishtest/vtc_server.c +++ b/bin/varnishtest/vtc_server.c @@ -376,6 +376,7 @@ server_break(struct server *s) vtc_log(s->vl, 2, "Breaking for server"); (void)pthread_cancel(s->tp); AZ(pthread_join(s->tp, &res)); + VTCP_close(&s->sock); s->tp = 0; s->run = 0; } From phk at FreeBSD.org Wed Jul 31 09:00:18 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 31 Jul 2019 09:00:18 +0000 (UTC) Subject: [master] 4c381b27d Use VLU to parse the VSM _.index file Message-ID: <20190731090018.613352B55@lists.varnish-cache.org> commit 4c381b27df4d505597c5769aa95d5cab545885f0 Author: Poul-Henning Kamp Date: Wed Jul 31 08:59:13 2019 +0000 Use VLU to parse the VSM _.index file diff --git a/lib/libvarnish/vlu.c b/lib/libvarnish/vlu.c index 718ac3b86..536b792d4 100644 --- a/lib/libvarnish/vlu.c +++ b/lib/libvarnish/vlu.c @@ -120,7 +120,9 @@ VLU_Fd(struct vlu *l, int fd) CHECK_OBJ_NOTNULL(l, LINEUP_MAGIC); i = read(fd, l->buf + l->bufp, l->bufl - l->bufp); - if (i <= 0) + if (i == 0) + return (-2); + if (i < 0) return (-1); l->bufp += i; return (LineUpProcess(l)); diff --git a/lib/libvarnishapi/Makefile.am b/lib/libvarnishapi/Makefile.am index 59ac166b0..6f109374c 100644 --- a/lib/libvarnishapi/Makefile.am +++ b/lib/libvarnishapi/Makefile.am @@ -25,6 +25,7 @@ libvarnishapi_la_SOURCES = \ ../libvarnish/vfl.c \ ../libvarnish/vin.c \ ../libvarnish/vjsn.c \ + ../libvarnish/vlu.c \ ../libvarnish/vmb.c \ ../libvarnish/vpf.c \ ../libvarnish/vre.c \ diff --git a/lib/libvarnishapi/vsm.c b/lib/libvarnishapi/vsm.c index 8c133a61e..364ad3aee 100644 --- a/lib/libvarnishapi/vsm.c +++ b/lib/libvarnishapi/vsm.c @@ -50,6 +50,7 @@ #include "vav.h" #include "vin.h" +#include "vlu.h" #include "vsb.h" #include "vsm_priv.h" #include "vqueue.h" @@ -96,6 +97,7 @@ struct vsm_set { unsigned magic; #define VSM_SET_MAGIC 0xdee401b8 const char *dname; + struct vsm *vsm; VTAILQ_HEAD(,vsm_seg) segs; VTAILQ_HEAD(,vsm_seg) stale; VTAILQ_HEAD(,vsm_seg) clusters; @@ -107,6 +109,10 @@ struct vsm_set { struct stat fst; uintmax_t id1, id2; + + // _.index reading state + unsigned retval; + struct vsm_seg *vg; }; struct vsm { @@ -291,6 +297,8 @@ VSM_New(void) vd->mgt = vsm_newset(VSM_MGT_DIRNAME); vd->child = vsm_newset(VSM_CHILD_DIRNAME); + vd->mgt->vsm = vd; + vd->child->vsm = vd; vd->dfd = -1; vd->patience = 5; if (getenv("VSM_NOPID") != NULL) @@ -418,21 +426,110 @@ vsm_findcluster(const struct vsm_seg *vga) return (NULL); } -static unsigned -vsm_refresh_set2(struct vsm *vd, struct vsm_set *vs, struct vsb *vsb) +static int +vsm_vlu_hash(struct vsm *vd, struct vsm_set *vs, const char *line) { - unsigned retval = 0; - struct stat st; - char buf[BUFSIZ]; - ssize_t sz; - int i, ac; - char *p, *e; + int i; uintmax_t id1, id2; + + i = sscanf(line, "# %ju %ju", &id1, &id2); + if (i != 2) { + vs->retval |= VSM_MGT_RESTARTED | VSM_MGT_CHANGED; + return (0); + } + if (vd->couldkill >= 0 && !kill(id1, 0)) { + vd->couldkill = 1; + } else if (vd->couldkill > 0 && errno == ESRCH) { + vs->retval |= VSM_MGT_RESTARTED | VSM_MGT_CHANGED; + return (0); + } + vs->retval |= VSM_MGT_RUNNING; + if (id1 != vs->id1 || id2 != vs->id2) { + vs->retval |= VSM_MGT_RESTARTED | VSM_MGT_CHANGED; + vs->id1 = id1; + vs->id2 = id2; + } + return (0); +} + +static int +vsm_vlu_plus(struct vsm *vd, struct vsm_set *vs, const char *line) +{ char **av; - struct vsm_seg *vg, *vg2; + int ac; + struct vsm_seg *vg2; + + av = VAV_Parse(line, &ac, 0); + + if (av[0] != NULL || ac < 4 || ac > 6) { + (void)(vsm_diag(vd, + "vsm_refresh_set2: bad index (%d/%s)", + ac, av[0])); + VAV_Free(av); + return(-1); + } + + if (vs->vg == NULL) { + ALLOC_OBJ(vg2, VSM_SEG_MAGIC); + AN(vg2); + vg2->av = av; + vg2->set = vs; + vg2->flags = VSM_FLAG_MARKSCAN; + vg2->serial = ++vd->serial; + if (ac == 4) { + vg2->flags |= VSM_FLAG_CLUSTER; + VTAILQ_INSERT_TAIL(&vs->clusters, vg2, list); + } else { + VTAILQ_INSERT_TAIL(&vs->segs, vg2, list); + vg2->cluster = vsm_findcluster(vg2); + } + } else { + while (vs->vg != NULL && vsm_cmp_av(&vs->vg->av[1], &av[1])) + vs->vg = VTAILQ_NEXT(vs->vg, list); + VAV_Free(av); + if (vs->vg != NULL) { + /* entry compared equal, so it survives */ + vs->vg->flags |= VSM_FLAG_MARKSCAN; + vs->vg = VTAILQ_NEXT(vs->vg, list); + } + } + return (0); +} + +static int v_matchproto_(vlu_f) +vsm_vlu_func(void *priv, const char *line) +{ + struct vsm *vd; + struct vsm_set *vs; + int i = -1; + + CAST_OBJ_NOTNULL(vs, priv, VSM_SET_MAGIC); + vd = vs->vsm; + CHECK_OBJ_NOTNULL(vd, VSM_MAGIC); + AN(line); + + if (line[0] == '#') { + i = vsm_vlu_hash(vd, vs, line); + VTAILQ_FOREACH(vs->vg, &vs->segs, list) + vs->vg->flags &= ~VSM_FLAG_MARKSCAN; + if (!(vs->retval & VSM_MGT_RESTARTED)) + vs->vg = VTAILQ_FIRST(&vs->segs); + } else { + i = vsm_vlu_plus(vd, vs, line); + } + return (i); +} + +static unsigned +vsm_refresh_set2(struct vsm *vd, struct vsm_set *vs) +{ + struct stat st; + int i; + struct vlu *vlu; CHECK_OBJ_NOTNULL(vd, VSM_MAGIC); CHECK_OBJ_NOTNULL(vs, VSM_SET_MAGIC); + vs->retval = 0; if (vs->dfd >= 0) { if (fstatat(vd->dfd, vs->dname, &st, AT_SYMLINK_NOFOLLOW)) { closefd(&vs->dfd); @@ -451,10 +548,10 @@ vsm_refresh_set2(struct vsm *vd, struct vsm_set *vs, struct vsb *vsb) if (vs->fd >= 0) closefd(&vs->fd); vs->dfd = openat(vd->dfd, vs->dname, O_RDONLY); - retval |= VSM_MGT_RESTARTED; + vs->retval |= VSM_MGT_RESTARTED; if (vs->dfd < 0) { vs->id1 = vs->id2 = 0; - return (retval|VSM_NUKE_ALL); + return (vs->retval|VSM_NUKE_ALL); } AZ(fstat(vs->dfd, &vs->dst)); } @@ -472,123 +569,36 @@ vsm_refresh_set2(struct vsm *vd, struct vsm_set *vs, struct vsb *vsb) if (vs->fd >= 0) { if (vd->couldkill < 1 || !kill(vs->id1, 0)) - retval |= VSM_MGT_RUNNING; - return (retval); + vs->retval |= VSM_MGT_RUNNING; + return (vs->retval); } - retval |= VSM_MGT_CHANGED; + vs->retval |= VSM_MGT_CHANGED; vs->fd = openat(vs->dfd, "_.index", O_RDONLY); if (vs->fd < 0) - return (retval|VSM_MGT_RESTARTED); + return (vs->retval|VSM_MGT_RESTARTED); AZ(fstat(vs->fd, &vs->fst)); - VSB_clear(vsb); - do { - sz = read(vs->fd, buf, sizeof buf); - if (sz > 0) - VSB_bcat(vsb, buf, sz); - } while (sz > 0); - AZ(VSB_finish(vsb)); - - vs->fst.st_size = VSB_len(vsb); - - if (VSB_len(vsb) == 0) - return (retval|VSM_NUKE_ALL); - - /* - * First line is ident comment - */ - i = sscanf(VSB_data(vsb), "# %ju %ju\n%n", &id1, &id2, &ac); - if (i != 2) { - retval |= VSM_MGT_RESTARTED | VSM_MGT_CHANGED; - return (retval); - } - if (vd->couldkill >= 0 && !kill(id1, 0)) { - vd->couldkill = 1; - } else if (vd->couldkill > 0 && errno == ESRCH) { - retval |= VSM_MGT_RESTARTED | VSM_MGT_CHANGED; - return (retval); - } - retval |= VSM_MGT_RUNNING; - if (id1 != vs->id1 || id2 != vs->id2) { - retval |= VSM_MGT_RESTARTED | VSM_MGT_CHANGED; - vs->id1 = id1; - vs->id2 = id2; - } - p = VSB_data(vsb) + ac; + vlu = VLU_New(vsm_vlu_func, vs, 0); + AN(vlu); - VTAILQ_FOREACH(vg, &vs->segs, list) - vg->flags &= ~VSM_FLAG_MARKSCAN; - - /* - * Efficient comparison by walking the two lists side-by-side because - * segment inserts always happen at the tail (VSMW_Allocv()). So, as - * soon as vg is exhausted, we only insert. - * - * For restarts, we require a tabula rasa - */ - - if (retval & VSM_MGT_RESTARTED) - vg = NULL; - else - vg = VTAILQ_FIRST(&vs->segs); - - while (p != NULL && *p != '\0') { - e = strchr(p, '\n'); - if (e == NULL) - break; - *e = '\0'; - av = VAV_Parse(p, &ac, 0); - p = e + 1; - - if (av[0] != NULL || ac < 4 || ac > 6) { - (void)(vsm_diag(vd, - "vsm_refresh_set2: bad index (%d/%s)", - ac, av[0])); - VAV_Free(av); - break; - } - - if (vg == NULL) { - ALLOC_OBJ(vg2, VSM_SEG_MAGIC); - AN(vg2); - vg2->av = av; - vg2->set = vs; - vg2->flags = VSM_FLAG_MARKSCAN; - vg2->serial = ++vd->serial; - if (ac == 4) { - vg2->flags |= VSM_FLAG_CLUSTER; - VTAILQ_INSERT_TAIL(&vs->clusters, vg2, list); - } else { - VTAILQ_INSERT_TAIL(&vs->segs, vg2, list); - vg2->cluster = vsm_findcluster(vg2); - } - continue; - } - - while (vg != NULL && vsm_cmp_av(&vg->av[1], &av[1])) - vg = VTAILQ_NEXT(vg, list); - - VAV_Free(av); - - if (vg == NULL) - continue; - - /* entry compared equal, so it survives */ - vg->flags |= VSM_FLAG_MARKSCAN; - vg = VTAILQ_NEXT(vg, list); - } - return (retval); + vs->vg = NULL; + do { + i = VLU_Fd(vlu, vs->fd); + } while (!i); + assert(i == -2); + VLU_Destroy(&vlu); + return (vs->retval); } static unsigned -vsm_refresh_set(struct vsm *vd, struct vsm_set *vs, struct vsb *vsb) +vsm_refresh_set(struct vsm *vd, struct vsm_set *vs) { unsigned retval; struct vsm_seg *vg, *vg2; - retval = vsm_refresh_set2(vd, vs, vsb); + retval = vsm_refresh_set2(vd, vs); if (retval & VSM_NUKE_ALL) retval |= VSM_MGT_CHANGED; VTAILQ_FOREACH_SAFE(vg, &vs->segs, list, vg2) { @@ -614,7 +624,6 @@ VSM_Status(struct vsm *vd) { unsigned retval = 0, u; struct stat st; - struct vsb *vsb; CHECK_OBJ_NOTNULL(vd, VSM_MAGIC); @@ -641,14 +650,10 @@ VSM_Status(struct vsm *vd) AZ(fstat(vd->dfd, &vd->dst)); } - vsb = VSB_new_auto(); - AN(vsb); - - u = vsm_refresh_set(vd, vd->mgt, vsb); + u = vsm_refresh_set(vd, vd->mgt); retval |= u; if (u & VSM_MGT_RUNNING) - retval |= vsm_refresh_set(vd, vd->child, vsb) << 8; - VSB_destroy(&vsb); + retval |= vsm_refresh_set(vd, vd->child) << 8; return (retval); }