From guillaume at varnish-software.com Fri Feb 1 19:06:09 2019 From: guillaume at varnish-software.com (Guillaume Quintard) Date: Fri, 1 Feb 2019 19:06:09 +0000 (UTC) Subject: [master] fd9e40dba stricter magic checks Message-ID: <20190201190609.1D747AD81E@lists.varnish-cache.org> commit fd9e40dba9470c8e4242428a2c5ce774f754ccea Author: Guillaume Quintard Date: Thu Jan 31 14:22:20 2019 -0800 stricter magic checks diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index 9b4f5fedb..76adf6ef6 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -429,6 +429,10 @@ VRT_r_obj_storage(VRT_CTX) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); + CHECK_OBJ_NOTNULL(ctx->req->objcore, OBJCORE_MAGIC); + AN(ctx->req->objcore->stobj); + CHECK_OBJ_NOTNULL(ctx->req->objcore->stobj->stevedore, + STEVEDORE_MAGIC); return (ctx->req->objcore->stobj->stevedore); } @@ -673,6 +677,8 @@ VRT_r_req_xid(VRT_CTX) CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); + CHECK_OBJ_NOTNULL(ctx->req->http, HTTP_MAGIC); + AN(ctx->req->vsl); return (WS_Printf(ctx->req->http->ws, "%u", VXID(ctx->req->vsl->wid))); @@ -684,6 +690,8 @@ VRT_r_bereq_xid(VRT_CTX) CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC); + CHECK_OBJ_NOTNULL(ctx->bo->bereq, HTTP_MAGIC); + AN(ctx->bo->vsl); return (WS_Printf(ctx->bo->bereq->ws, "%u", VXID(ctx->bo->vsl->wid))); @@ -692,15 +700,26 @@ VRT_r_bereq_xid(VRT_CTX) VCL_STRING VRT_r_sess_xid(VRT_CTX) { + struct sess *sp; + struct http *http; + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); - if (VALID_OBJ(ctx->req, REQ_MAGIC)) - return (WS_Printf(ctx->req->http->ws, "%u", - VXID(ctx->req->sp->vxid))); + if (ctx->req) { + CHECK_OBJ(ctx->req, REQ_MAGIC); + CHECK_OBJ_NOTNULL(ctx->req->http, HTTP_MAGIC); + sp = ctx->req->sp; + http = ctx->req->http; + } else { + CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC); + CHECK_OBJ_NOTNULL(ctx->bo->bereq, HTTP_MAGIC); + sp = ctx->bo->sp; + http = ctx->bo->bereq; + } - CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC); - return (WS_Printf(ctx->bo->bereq->ws, "%u", - VXID(ctx->bo->sp->vxid))); + CHECK_OBJ_NOTNULL(http, HTTP_MAGIC); + CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + return (WS_Printf(http->ws, "%u", VXID(sp->vxid))); } /*-------------------------------------------------------------------- @@ -763,9 +782,10 @@ VRT_r_local_##var(VRT_CTX) \ struct sess *sp; \ \ CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); \ - if (VALID_OBJ(ctx->req, REQ_MAGIC)) \ + if (ctx->req) { \ + CHECK_OBJ(ctx->req, REQ_MAGIC); \ sp = ctx->req->sp; \ - else { \ + } else { \ CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC); \ sp = ctx->bo->sp; \ } \ diff --git a/lib/libvmod_unix/vmod_unix.c b/lib/libvmod_unix/vmod_unix.c index 59bbb2d8e..4388d58d4 100644 --- a/lib/libvmod_unix/vmod_unix.c +++ b/lib/libvmod_unix/vmod_unix.c @@ -67,9 +67,12 @@ get_sp(VRT_CTX) { struct sess *sp; - if (VALID_OBJ(ctx->req, REQ_MAGIC)) + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + + if (ctx->req) { + CHECK_OBJ(ctx->req, REQ_MAGIC); sp = ctx->req->sp; - else { + } else { CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC); sp = ctx->bo->sp; } From slink at schokola.de Sat Feb 2 13:28:23 2019 From: slink at schokola.de (Nils Goroll) Date: Sat, 2 Feb 2019 14:28:23 +0100 Subject: [master] fd9e40dba stricter magic checks In-Reply-To: <20190201190609.1D747AD81E@lists.varnish-cache.org> References: <20190201190609.1D747AD81E@lists.varnish-cache.org> Message-ID: On 01/02/2019 20:06, Guillaume Quintard wrote: > > commit fd9e40dba9470c8e4242428a2c5ce774f754ccea > Author: Guillaume Quintard > Date: Thu Jan 31 14:22:20 2019 -0800 > ... > @@ -692,15 +700,26 @@ VRT_r_bereq_xid(VRT_CTX) > VCL_STRING > VRT_r_sess_xid(VRT_CTX) > { > + struct sess *sp; > + struct http *http; > + > CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); > > - if (VALID_OBJ(ctx->req, REQ_MAGIC)) > - return (WS_Printf(ctx->req->http->ws, "%u", > - VXID(ctx->req->sp->vxid))); > + if (ctx->req) { > + CHECK_OBJ(ctx->req, REQ_MAGIC); > + CHECK_OBJ_NOTNULL(ctx->req->http, HTTP_MAGIC); > + sp = ctx->req->sp; > + http = ctx->req->http; > + } else { > + CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC); > + CHECK_OBJ_NOTNULL(ctx->bo->bereq, HTTP_MAGIC); > + sp = ctx->bo->sp; > + http = ctx->bo->bereq; > + } > > - CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC); > - return (WS_Printf(ctx->bo->bereq->ws, "%u", > - VXID(ctx->bo->sp->vxid))); > + CHECK_OBJ_NOTNULL(http, HTTP_MAGIC); > + CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); > + return (WS_Printf(http->ws, "%u", VXID(sp->vxid))); > } Why the de-tour via http->ws and not just use ctx->ws ? Nils From nils.goroll at uplex.de Sat Feb 2 13:50:09 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Sat, 2 Feb 2019 13:50:09 +0000 (UTC) Subject: [master] 406c701b5 sort the current changes into the usual sections Message-ID: <20190202135009.B887995A82@lists.varnish-cache.org> commit 406c701b5a0aa443666df1705a8827e5012a7159 Author: Nils Goroll Date: Sat Feb 2 14:49:19 2019 +0100 sort the current changes into the usual sections diff --git a/doc/changes.rst b/doc/changes.rst index 37b7dfbba..740906e32 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -32,10 +32,6 @@ Varnish Cache trunk (ongoing) * Extend JSON support in the CLI (2783_) -* fixed ``varnishhist`` display error (2780_) - -* ``libvarnish``: ``VRT_VSA_GetPtr`` renamed to ``VSA_GetPtr`` - * Improve accuracy of statistics (VSC) * In ``Error: out of workspace`` log entries, the workspace name is @@ -48,24 +44,43 @@ Varnish Cache trunk (ongoing) * fix ``varnishd -I`` (2782_) -* fix ``varnishstat -f`` in curses mode (interactively, without - ``-1``, 2787_) - -* Handle an out-of-workspace condition in HTTP/2 delivery more - gracefully (2589_) - * added a thread pool watchdog which will restart the worker process if scheduling tasks onto worker threads appears stuck. The new parameter ``thread_pool_watchdog`` configures it. (2418_) +* Changed ``ExpKill`` log tags to emit microsecond-precision + timestamps instead of nanoseconds (2792_) + +* Changed the default of the ``thread_pool_watchdog`` parameter + to 60 seconds to match the ``cli_timeout`` default + +* VSB quoted output has been unified to three-digit octal, + VSB_QUOTE_ESCHEX has been added to prefer hex over octal quoting + +* retired long deprecated parameters (VIP16_). Replacement mapping is: + ``shm_reclen`` -> ``vsl_reclen`` + ``vcl_dir`` -> ``vcl_path`` + ``vmod_dir`` -> ``vmod_path`` + +VCL +--- + +* added ``req.is_hitmiss`` and ``req.is_hitpass`` (2743_) + + +bundled tools +------------- + * Improved varnish log client performance (2788_) -* Fixed regression introduced just before 6.1.0 release which caused - an unnecessary incompatibility with VSL files written by previous - versions. (2790_) +* For ``varnishtest -L``, also keep VCL C source files -* Changed ``ExpKill`` log tags to emit microsecond-precision - timestamps instead of nanoseconds (2792_) +* Add ``param.reset`` command to ``varnishadm`` + +C APIs (for vmod and utility authors) +------------------------------------- + +* ``libvarnish``: ``VRT_VSA_GetPtr`` renamed to ``VSA_GetPtr`` * Included ``vtree.h`` in the distribution for vmods and renamed the red/black tree macros from ``VRB_*`` to ``VRBT_*`` @@ -75,42 +90,42 @@ Varnish Cache trunk (ongoing) ``PRIV_TOP`` from a list to a red/black tree) for performance. (2813_) -* Changed the default of the ``thread_pool_watchdog`` parameter - to 60 seconds to match the ``cli_timeout`` default - -* Fix warmup/rampup of the shard director (2823_) +* Vmod developers are advised that anything returned by a vmod + function/method is assumed to be immutable. In other words, a vmod + `must not` modify any data which was previously returned. * Added ``vstrerror()`` as a safe wrapper for ``strerror()`` to avoid a NULL pointer dereference under rare conditions where the latter could return NULL. (2815_) -* Fix VRT_priv_task for calls from vcl_pipe {} (2820_) +* Varnish-based tools using the VUT interface should now consider + using the ``VUT_Usage()`` function for consistency -* For ``varnishtest -L``, also keep VCL C source files -* Fix assinging == (2809_) +Fixed bugs +---------- -* Fix vmod object constructor documentation in the ``vmodtool.py`` - - generated RST files +* fixed ``varnishhist`` display error (2780_) -* Vmod developers are advised that anything returned by a vmod - function/method is assumed to be immutable. In other words, a vmod - `must not` modify any data which was previously returned. +* fix ``varnishstat -f`` in curses mode (interactively, without + ``-1``, 2787_) -* VSB quoted output has been unified to three-digit octal, - VSB_QUOTE_ESCHEX has been added to prefer hex over octal quoting +* Handle an out-of-workspace condition in HTTP/2 delivery more + gracefully (2589_) -* Varnish-based tools using the VUT interface should now consider - using the ``VUT_Usage()`` function for consistency +* Fixed regression introduced just before 6.1.0 release which caused + an unnecessary incompatibility with VSL files written by previous + versions. (2790_) -* retired long deprecated parameters (VIP16_). Replacement mapping is: - ``shm_reclen`` -> ``vsl_reclen`` - ``vcl_dir`` -> ``vcl_path`` - ``vmod_dir`` -> ``vmod_path`` +* Fix warmup/rampup of the shard director (2823_) -* added ``req.is_hitmiss`` and ``req.is_hitpass`` (2743_) +* Fix VRT_priv_task for calls from vcl_pipe {} (2820_) + +* Fix assinging == (2809_) + +* Fix vmod object constructor documentation in the ``vmodtool.py`` - + generated RST files -* Add ``param.reset`` command to ``varnishadm`` .. _2809: https://github.com/varnishcache/varnish-cache/issues/2809 .. _2820: https://github.com/varnishcache/varnish-cache/issues/2820 From nils.goroll at uplex.de Sat Feb 2 13:53:06 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Sat, 2 Feb 2019 13:53:06 +0000 (UTC) Subject: [master] 7767fc32a document event_function change Message-ID: <20190202135306.E6E0795D4D@lists.varnish-cache.org> commit 7767fc32a368439915086f26ef99cf6aae578484 Author: Nils Goroll Date: Sat Feb 2 14:51:44 2019 +0100 document event_function change Ref d8ae26b5a0b4a1102360a61a145e4730e52d68bc diff --git a/doc/changes.rst b/doc/changes.rst index 740906e32..c7c690b1c 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -101,6 +101,10 @@ C APIs (for vmod and utility authors) * Varnish-based tools using the VUT interface should now consider using the ``VUT_Usage()`` function for consistency +* The `event_function` callback for VCL events in vmods used to have + the fixed name ``event_function`` and has now been renamed to + `$Prefix`\ ``event_function`` if `$Prefix` is defined in the + ``.vcc`` files or ``vmod_event_function`` by default Fixed bugs ---------- From nils.goroll at uplex.de Sat Feb 2 14:01:07 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Sat, 2 Feb 2019 14:01:07 +0000 (UTC) Subject: [master] ae98a60fd correctly document event_function change Message-ID: <20190202140107.8853996162@lists.varnish-cache.org> commit ae98a60fd09c83e85d76c0f2eaadc705816f57d9 Author: Nils Goroll Date: Sat Feb 2 14:59:29 2019 +0100 correctly document event_function change my previous commit 7767fc32a368439915086f26ef99cf6aae578484 was incaccurate Ref d8ae26b5a0b4a1102360a61a145e4730e52d68bc diff --git a/doc/changes.rst b/doc/changes.rst index c7c690b1c..fca592c34 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -101,10 +101,13 @@ C APIs (for vmod and utility authors) * Varnish-based tools using the VUT interface should now consider using the ``VUT_Usage()`` function for consistency -* The `event_function` callback for VCL events in vmods used to have - the fixed name ``event_function`` and has now been renamed to - `$Prefix`\ ``event_function`` if `$Prefix` is defined in the - ``.vcc`` files or ``vmod_event_function`` by default +* The name of the `event_function` callback for VCL events in vmods is + now prefixed by `$Prefix`\ ``_``\ ` if `$Prefix` is defined in the + ``.vcc`` file, or ``vmod_`` by default. + + So, for example, with ``$Event foo`` and no `$Prefix`, the event + function will be called ``vmod_foo`` and with ``$Prefix bar`` it + will be called ``bar_foo``. Fixed bugs ---------- From nils.goroll at uplex.de Sat Feb 2 14:30:12 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Sat, 2 Feb 2019 14:30:12 +0000 (UTC) Subject: [master] 9023b9924 Document vmod rst anchor name change Message-ID: <20190202143012.D1F7396CA1@lists.varnish-cache.org> commit 9023b99241650baba5987b075d5e054528c30989 Author: Nils Goroll Date: Sat Feb 2 15:28:08 2019 +0100 Document vmod rst anchor name change Ref c09032032700f91fcf06e3018d206cbb730d1772 diff --git a/doc/changes.rst b/doc/changes.rst index fca592c34..a702698f5 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -109,6 +109,18 @@ C APIs (for vmod and utility authors) function will be called ``vmod_foo`` and with ``$Prefix bar`` it will be called ``bar_foo``. +* in the `vmodtool`\ -generated ReStructuredText documentation, + anchors have been renamed + + * from ``obj_``\ `class` to `vmodname`\ ``.``\ `class` for + constructors and + * from ``func_``\ `class` to `vmodname`\ ``.``\ `function` for functions and + * from ``func_``\ `class` to `vmodname`\ ``.``\ `class`\ ``.``\ + `method` for methods, + + repsectively. In short, the anchor is now named equal to VCL syntax + for constructors and functions and similarly to VCL syntax for methods. + Fixed bugs ---------- From guillaume at varnish-software.com Sat Feb 2 17:27:06 2019 From: guillaume at varnish-software.com (Guillaume Quintard) Date: Sat, 2 Feb 2019 17:27:06 +0000 (UTC) Subject: [master] f3f8aa163 Directly use ctx->ws (thanks Nils) Message-ID: <20190202172706.E6DE2A08F0@lists.varnish-cache.org> commit f3f8aa1632d8caf6cb555088294816c86f31f2a9 Author: Guillaume Quintard Date: Sat Feb 2 09:25:29 2019 -0800 Directly use ctx->ws (thanks Nils) diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index 76adf6ef6..7cfa27eeb 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -690,10 +690,9 @@ VRT_r_bereq_xid(VRT_CTX) CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC); - CHECK_OBJ_NOTNULL(ctx->bo->bereq, HTTP_MAGIC); AN(ctx->bo->vsl); - return (WS_Printf(ctx->bo->bereq->ws, "%u", + return (WS_Printf(ctx->ws, "%u", VXID(ctx->bo->vsl->wid))); } @@ -701,25 +700,19 @@ VCL_STRING VRT_r_sess_xid(VRT_CTX) { struct sess *sp; - struct http *http; CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); if (ctx->req) { CHECK_OBJ(ctx->req, REQ_MAGIC); - CHECK_OBJ_NOTNULL(ctx->req->http, HTTP_MAGIC); sp = ctx->req->sp; - http = ctx->req->http; } else { CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC); - CHECK_OBJ_NOTNULL(ctx->bo->bereq, HTTP_MAGIC); sp = ctx->bo->sp; - http = ctx->bo->bereq; } - CHECK_OBJ_NOTNULL(http, HTTP_MAGIC); CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); - return (WS_Printf(http->ws, "%u", VXID(sp->vxid))); + return (WS_Printf(ctx->ws, "%u", VXID(sp->vxid))); } /*-------------------------------------------------------------------- From phk at FreeBSD.org Mon Feb 4 13:44:09 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 4 Feb 2019 13:44:09 +0000 (UTC) Subject: [master] d4180b6a3 Make the VMOD.file_id depend only on the $... lines, so people can freely update comments and documentation. Message-ID: <20190204134409.2932AAF282@lists.varnish-cache.org> commit d4180b6a39adedd90fb2c58d8e394f987237e15d Author: Poul-Henning Kamp Date: Mon Feb 4 09:14:20 2019 +0000 Make the VMOD.file_id depend only on the $... lines, so people can freely update comments and documentation. diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py index 1e92145e4..1f02696d2 100755 --- a/lib/libvcc/vmodtool.py +++ b/lib/libvcc/vmodtool.py @@ -850,13 +850,14 @@ class vcc(object): global inputline b = open(self.inputfile, "rb").read() a = "\n" + b.decode("utf-8") - self.file_id = hashlib.sha256(b).hexdigest() + h = hashlib.sha256() s = a.split("\n$") self.copyright = s.pop(0).strip() while s: ss = re.split('\n([^\t ])', s.pop(0), maxsplit=1) toks = self.tokenize(ss[0]) inputline = '$' + ' '.join(toks) + h.update((inputline + '\n').encode('utf-8')) docstr = "".join(ss[1:]) stanzaclass = DISPATCH.get(toks[0]) if stanzaclass is None: @@ -864,6 +865,7 @@ class vcc(object): stanzaclass(self, toks, docstr) inputline = None self.csn = "Vmod_%s%s_Func" % (self.sympfx, self.modname) + self.file_id = h.hexdigest() def tokenize(self, txt, seps=None, quotes=None): if seps is None: From phk at FreeBSD.org Mon Feb 4 13:44:09 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 4 Feb 2019 13:44:09 +0000 (UTC) Subject: [master] 0fca8adf1 Add VARGS() macro for vmod argument structures. Message-ID: <20190204134409.436A5AF286@lists.varnish-cache.org> commit 0fca8adf15a0a024fc03d40eeb61534187fb623d Author: Poul-Henning Kamp Date: Mon Feb 4 13:41:55 2019 +0000 Add VARGS() macro for vmod argument structures. Change name for enums and args to have "enum_" and "arg_" prefixes. Minimal changes to the vmods to react to these changes. diff --git a/bin/varnishd/flint.lnt b/bin/varnishd/flint.lnt index 4664df7ff..88e89b36d 100644 --- a/bin/varnishd/flint.lnt +++ b/bin/varnishd/flint.lnt @@ -67,6 +67,12 @@ -emacro(845, HTTPH) // Info 845: The left argument to operator '&&' is certain to be 0 -esym(773, PCRE_DATE) // Expression-like macro '___' not parenthesized + +////////////// +// Macros defined differently in each VMOD +-esym(767, VPFX) // macro '___' was defined differently in another module +-esym(767, VARGS) // macro '___' was defined differently in another module +-esym(767, VENUM) // macro '___' was defined differently in another module ////////////// -efunc(1791, pdiff) // return last on line ////////////// diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py index 1f02696d2..310f4a43f 100755 --- a/lib/libvcc/vmodtool.py +++ b/lib/libvcc/vmodtool.py @@ -31,6 +31,7 @@ Read the vmod.vcc file (inputvcc) and produce: vmod_if.h -- Prototypes for the implementation vmod_if.c -- Magic glue & datastructures to make things a VMOD. vmod_${name}.rst -- Extracted documentation + vmod_${name}.man.rst -- Extracted documentation (rst2man input) """ # This script should work with both Python 2 and Python 3. @@ -129,10 +130,14 @@ def unquote(txt): def fmt_cstruct(fo, a, b): ''' Output line in vmod struct ''' - t = "\t%s\t" % a + t = '\t%s' % a + if len(t.expandtabs()) > 40: + t += '\n\t\t\t\t\t' + else: + t += '\t' while len(t.expandtabs()) < 40: - t += "\t" - fo.write("%s%s\n" % (t, b)) + t += '\t' + fo.write('%s%s\n' % (t, b)) ####################################################################### @@ -430,7 +435,7 @@ class ProtoType(object): return "typedef " + self.proto(args, name=self.typedef_name()) def argstructname(self): - return "struct %s_arg" % self.cname(True) + return "struct VARGS(%s)" % self.cname(False) def argstructure(self): s = "\n" + self.argstructname() + " {\n" @@ -471,7 +476,8 @@ class ProtoType(object): self.retval.jsonproto(ll) ll.append('%s.%s' % (self.st.vcc.csn, cfunc)) if self.argstruct: - ll.append(self.argstructname()) + # We cannot use VARGS() here, we are after the #undef + ll.append('struct arg_%s' % self.cname(True)) else: ll.append("") for i in self.args: @@ -662,8 +668,7 @@ class EventStanza(Stanza): def cstuff(self, fo, where): if where == 'h': - fo.write("vmod_event_f %s%s;\n" % - (self.vcc.sympfx, self.event_func)) + fo.write("vmod_event_f VPFX(%s);\n" % self.event_func) def cstruct(self, fo, define): if define: @@ -741,7 +746,7 @@ class ObjectStanza(Stanza): fo.write(' :ref:`%s`\n \n' % i.rstlbl) def cstuff(self, fo, w): - sn = self.vcc.sympfx + self.vcc.modname + "_" + self.proto.name + sn = 'VPFX(' + self.vcc.modname + '_' + self.proto.name + ')' fo.write("struct %s;\n" % sn) fo.write(self.init.cproto( @@ -952,8 +957,17 @@ class vcc(object): fo.write("#endif\n") fo.write("\n") + fo.write('#define VPFX(a) %s##a\n' % self.sympfx) + fo.write('#define VARGS(a) arg_%s##a\n' % self.sympfx) + fo.write('#define VENUM(a) enum_%s##a\n' % self.sympfx) + fo.write('\n') + for j in sorted(self.enums): - fo.write("extern VCL_ENUM %senum_%s;\n" % (self.sympfx, j)) + fo.write("extern VCL_ENUM VENUM(%s);\n" % j) + fo.write("\n") + for j in sorted(self.enums): + fo.write("//lint -esym(759, enum_%s%s)\n" % (self.sympfx, j)) + fo.write("//lint -esym(765, enum_%s%s)\n" % (self.sympfx, j)) fo.write("\n") for j in self.contents: @@ -974,7 +988,7 @@ class vcc(object): j.cstruct(fo, False) fo.write("\n") for j in sorted(self.enums): - fo.write("\t&%senum_%s,\n" % (self.sympfx, j)) + fmt_cstruct(fo, '.enum_%s =' % j, '&VENUM(%s),' % j) fo.write("};\n") def json(self, fo): @@ -1026,6 +1040,11 @@ class vcc(object): write_c_file_warning(fo) + fx.write('#define VPFX(a) %s##a\n' % self.sympfx) + fx.write('#define VARGS(a) arg_%s##a\n' % self.sympfx) + fx.write('#define VENUM(a) enum_%s##a\n' % self.sympfx) + fx.write('\n') + fo.write('#include "config.h"\n') fo.write('#include \n') for i in ["vdef", "vrt", self.pfx, "vmod_abi"]: @@ -1033,7 +1052,7 @@ class vcc(object): fo.write("\n") for j in sorted(self.enums): - fo.write('VCL_ENUM %senum_%s = "%s";\n' % (self.sympfx, j, j)) + fo.write('VCL_ENUM VENUM(%s) = "%s";\n' % (j, j)) fo.write("\n") for i in self.contents: @@ -1053,6 +1072,10 @@ class vcc(object): fo.write("\n/*lint -esym(754, " + self.csn + "::*) */\n") self.cstruct_init(fo) + fx.write('#undef VPFX\n') + fx.write('#undef VARGS\n') + fx.write('#undef VENUM\n') + fx.close() fo.write("\nstatic const char Vmod_Proto[] =\n") diff --git a/lib/libvmod_blob/vmod_blob.c b/lib/libvmod_blob/vmod_blob.c index 66b9f4e24..d032a439b 100644 --- a/lib/libvmod_blob/vmod_blob.c +++ b/lib/libvmod_blob/vmod_blob.c @@ -118,7 +118,7 @@ static const struct vrt_blob null_blob[1] = {{ static enum encoding parse_encoding(VCL_ENUM e) { -#define VMODENUM(n) if (e == vmod_enum_ ## n) return(n); +#define VMODENUM(n) if (e == VENUM(n)) return(n); #include "tbl_encodings.h" WRONG("illegal encoding enum"); } @@ -126,7 +126,7 @@ parse_encoding(VCL_ENUM e) static enum case_e parse_case(VCL_ENUM e) { -#define VMODENUM(n) if (e == vmod_enum_ ## n) return(n); +#define VMODENUM(n) if (e == VENUM(n)) return(n); #include "tbl_case.h" WRONG("illegal case enum"); } diff --git a/lib/libvmod_debug/vmod_debug.c b/lib/libvmod_debug/vmod_debug.c index 43e203262..c62b3e85e 100644 --- a/lib/libvmod_debug/vmod_debug.c +++ b/lib/libvmod_debug/vmod_debug.c @@ -94,16 +94,16 @@ xyzzy_author(VRT_CTX, VCL_ENUM person, VCL_ENUM someone) (void)someone; CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); - if (person == xyzzy_enum_phk) + if (person == VENUM(phk)) return ("Poul-Henning"); assert(strcmp(person, "phk")); - if (person == xyzzy_enum_des) + if (person == VENUM(des)) return ("Dag-Erling"); assert(strcmp(person, "des")); - if (person == xyzzy_enum_kristian) + if (person == VENUM(kristian)) return ("Kristian"); assert(strcmp(person, "kristian")); - if (person == xyzzy_enum_mithrandir) + if (person == VENUM(mithrandir)) return ("Tollef"); assert(strcmp(person, "mithrandir")); WRONG("Illegal VMOD enum"); @@ -194,7 +194,7 @@ xyzzy_rot52(VRT_CTX, VCL_HTTP hp) } VCL_STRING v_matchproto_(td_debug_argtest) -xyzzy_argtest(VRT_CTX, struct xyzzy_argtest_arg *arg) +xyzzy_argtest(VRT_CTX, struct VARGS(argtest) *arg) { char buf[100]; diff --git a/lib/libvmod_debug/vmod_debug_obj.c b/lib/libvmod_debug/vmod_debug_obj.c index 4e716dae4..0dea592a3 100644 --- a/lib/libvmod_debug/vmod_debug_obj.c +++ b/lib/libvmod_debug/vmod_debug_obj.c @@ -157,17 +157,17 @@ xyzzy_obj_test_priv_top(VRT_CTX, * obj_opt (optional arguments and privs) */ struct xyzzy_debug_obj_opt { - unsigned magic; -#define VMOD_DEBUG_OBJ_OPT_MAGIC 0xccbd9b78 - char *name; - struct xyzzy_obj_opt_meth_opt_arg args; - void *freeptr; + unsigned magic; +#define VMOD_DEBUG_OBJ_OPT_MAGIC 0xccbd9b78 + char *name; + struct VARGS(obj_opt_meth_opt) args; + void *freeptr; }; VCL_VOID v_matchproto_() xyzzy_obj_opt__init(VRT_CTX, struct xyzzy_debug_obj_opt **op, const char *vcl_name, - struct xyzzy_obj_opt__init_arg *args) + struct VARGS(obj_opt__init) *args) { struct xyzzy_debug_obj_opt *o; @@ -221,7 +221,7 @@ xyzzy_obj_opt__fini(struct xyzzy_debug_obj_opt **op) VCL_STRING v_matchproto_() xyzzy_obj_opt_meth_opt(VRT_CTX, struct xyzzy_debug_obj_opt *o, - struct xyzzy_obj_opt_meth_opt_arg *args) + struct VARGS(obj_opt_meth_opt) *args) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(o, VMOD_DEBUG_OBJ_OPT_MAGIC); diff --git a/lib/libvmod_directors/vmod_shard.c b/lib/libvmod_directors/vmod_shard.c index 9e8abcbc0..4495474d3 100644 --- a/lib/libvmod_directors/vmod_shard.c +++ b/lib/libvmod_directors/vmod_shard.c @@ -182,7 +182,7 @@ struct vmod_directors_shard { static enum by_e parse_by_e(VCL_ENUM e) { -#define VMODENUM(n) if (e == vmod_enum_ ## n) return(BY_ ## n); +#define VMODENUM(n) if (e == VENUM(n)) return(BY_ ## n); #include "tbl_by.h" WRONG("illegal by enum"); } @@ -190,7 +190,7 @@ parse_by_e(VCL_ENUM e) static enum healthy_e parse_healthy_e(VCL_ENUM e) { -#define VMODENUM(n) if (e == vmod_enum_ ## n) return(n); +#define VMODENUM(n) if (e == VENUM(n)) return(n); #include "tbl_healthy.h" WRONG("illegal healthy enum"); } @@ -198,7 +198,7 @@ parse_healthy_e(VCL_ENUM e) static enum resolve_e parse_resolve_e(VCL_ENUM e) { -#define VMODENUM(n) if (e == vmod_enum_ ## n) return(n); +#define VMODENUM(n) if (e == VENUM(n)) return(n); #include "tbl_resolve.h" WRONG("illegal resolve enum"); } @@ -343,7 +343,7 @@ vmod_shard_associate(VRT_CTX, VCL_BOOL v_matchproto_(td_directors_shard_add_backend) vmod_shard_add_backend(VRT_CTX, struct vmod_directors_shard *vshard, - struct vmod_shard_add_backend_arg *args) + struct VARGS(shard_add_backend) *args) { CHECK_OBJ_NOTNULL(vshard, VMOD_SHARD_SHARD_MAGIC); @@ -361,7 +361,7 @@ vmod_shard_add_backend(VRT_CTX, struct vmod_directors_shard *vshard, VCL_BOOL v_matchproto_(td_directors_shard_remove_backend) vmod_shard_remove_backend(VRT_CTX, struct vmod_directors_shard *vshard, - struct vmod_shard_remove_backend_arg *args) + struct VARGS(shard_remove_backend) *args) { VCL_BACKEND be = args->valid_backend ? args->backend : NULL; VCL_STRING ident = args->valid_ident ? args->ident : NULL; @@ -498,7 +498,7 @@ shard_blob_key(VCL_BLOB key_blob) #define tobit(args, name) ((args)->valid_##name ? arg_##name : 0) static uint32_t -shard_backend_arg_mask(const struct vmod_shard_backend_arg * const a) +shard_backend_arg_mask(const struct VARGS(shard_backend) * const a) { return (tobit(a, by) | tobit(a, key) | @@ -511,7 +511,7 @@ shard_backend_arg_mask(const struct vmod_shard_backend_arg * const a) tobit(a, resolve)); } static uint32_t -shard_param_set_mask(const struct vmod_shard_param_set_arg * const a) +shard_param_set_mask(const struct VARGS(shard_param_set) * const a) { return (tobit(a, by) | tobit(a, key) | @@ -640,7 +640,7 @@ shard_param_args(VRT_CTX, VCL_BACKEND v_matchproto_(td_directors_shard_backend) vmod_shard_backend(VRT_CTX, struct vmod_directors_shard *vshard, - struct vmod_shard_backend_arg *a) + struct VARGS(shard_backend) *a) { struct vmod_directors_shard_param pstk; struct vmod_directors_shard_param *pp = NULL; @@ -884,7 +884,7 @@ shard_param_prep(VRT_CTX, struct vmod_directors_shard_param *p, VCL_VOID v_matchproto_(td_directors_shard_param_set) vmod_shard_param_set(VRT_CTX, struct vmod_directors_shard_param *p, - struct vmod_shard_param_set_arg *a) + struct VARGS(shard_param_set) *a) { uint32_t args = shard_param_set_mask(a); From nils.goroll at uplex.de Mon Feb 4 13:52:09 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 4 Feb 2019 13:52:09 +0000 (UTC) Subject: [master] 0c041817c changelog tlc Message-ID: <20190204135209.6F855AF7E3@lists.varnish-cache.org> commit 0c041817c7e45b4258b657f33cd806a045951b89 Author: Nils Goroll Date: Mon Feb 4 14:51:08 2019 +0100 changelog tlc diff --git a/doc/changes.rst b/doc/changes.rst index a702698f5..7d1b59252 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -121,6 +121,33 @@ C APIs (for vmod and utility authors) repsectively. In short, the anchor is now named equal to VCL syntax for constructors and functions and similarly to VCL syntax for methods. +* VRT API has been updated to 9.0 + + * ``HTTP_Copy()`` was removed, ``HTTP_Dup()`` and ``HTTP_Clone()`` were added + + * Previously, ``VCL_BLOB`` was implemented as ``struct vmod_priv``, + which had the following shortcomings: + + * blobs are immutable, but that was not reflected by the ``priv`` + pointer + + * the existence of a free pointer suggested automatic memory + management, which did never and will not exist for blobs. + + The ``VCL_BLOB`` type is now implemented as ``struct vrt_blob``, + with the ``blob`` member replacing the former ``priv`` pointer and + the ``free`` pointer removed. + + A ``type`` member was added for lightweight type checking similar + to the miniobject ``magic`` member, but in contrast to it, + ``type`` should never be asserted upon. + + ``VRT_blob()`` was updated accordingly. + + * ``req->req_bodybytes`` was removed. Replacement code snippet:: + + AZ(ObjGetU64(req->wrk, req->body_oc, OA_LEN, &u)); + Fixed bugs ---------- From nils.goroll at uplex.de Mon Feb 4 14:11:09 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 4 Feb 2019 14:11:09 +0000 (UTC) Subject: [master] 03f1a2148 Output correct director health in CLI Message-ID: <20190204141109.6B296AFEA5@lists.varnish-cache.org> commit 03f1a214828c7c250fa4a4edfe9011bcfc864860 Author: Nils Goroll Date: Fri Jan 25 17:47:20 2019 +0100 Output correct director health in CLI As VRT_Healthy needs a VRT_CTX, we move vcl_get_ctx and vcl_rel_ctx to cache_varnishd.h scope as VCL_Get_CliCtx and VCL_Rel_CliCtx. It has been discussed before if all varnishd cli commands should have a VRT_CTX, so the natural solution would seem to add one in or close to VCLS_Poll(), yet CLI commands need specific ctxes (e.g. vcl.load needs VCL_MET_INIT), so (for now) it appears sensible to limit the ctx' scope to individual backend method calls. Fixes #2887 diff --git a/bin/varnishd/cache/cache_director.c b/bin/varnishd/cache/cache_director.c index ed1309db3..9bb13a444 100644 --- a/bin/varnishd/cache/cache_director.c +++ b/bin/varnishd/cache/cache_director.c @@ -277,6 +277,20 @@ struct list_args { const char *jsep; }; +static const char * +cli_health(struct director *d) +{ + struct vrt_ctx *ctx; + VCL_BOOL healthy; + + ctx = VCL_Get_CliCtx(0,0); + healthy = VRT_Healthy(ctx, d, NULL); + VCL_Rel_CliCtx(&ctx); + AZ(ctx); + + return (healthy ? "healthy" : "sick"); +} + static int v_matchproto_(vcl_be_func) do_list(struct cli *cli, struct director *d, void *priv) { @@ -295,7 +309,7 @@ do_list(struct cli *cli, struct director *d, void *priv) if (d->vdir->methods->list != NULL) d->vdir->methods->list(d, cli->sb, 0, 0, 0); else - VCLI_Out(cli, "%-10s", d->sick ? "sick" : "healthy"); + VCLI_Out(cli, "%-10s", cli_health(d)); VTIM_format(d->vdir->health_changed, time_str); VCLI_Out(cli, " %s", time_str); @@ -327,7 +341,7 @@ do_list_json(struct cli *cli, struct director *d, void *priv) if (d->vdir->methods->list != NULL) d->vdir->methods->list(d, cli->sb, 0, 0, 1); else - VCLI_Out(cli, "\"%s\"", d->sick ? "sick" : "healthy"); + VCLI_Out(cli, "\"%s\"", cli_health(d)); VCLI_Out(cli, ",\n"); if ((la->p || la->v) && d->vdir->methods->list != NULL) { diff --git a/bin/varnishd/cache/cache_varnishd.h b/bin/varnishd/cache/cache_varnishd.h index 38ca918a7..07fd45969 100644 --- a/bin/varnishd/cache/cache_varnishd.h +++ b/bin/varnishd/cache/cache_varnishd.h @@ -389,6 +389,8 @@ const char *VCL_Return_Name(unsigned); const char *VCL_Method_Name(unsigned); void VCL_Bo2Ctx(struct vrt_ctx *, struct busyobj *); void VCL_Req2Ctx(struct vrt_ctx *, struct req *); +struct vrt_ctx *VCL_Get_CliCtx(unsigned, int); +void VCL_Rel_CliCtx(struct vrt_ctx **); #define VCL_MET_MAC(l,u,t,b) \ void VCL_##l##_method(struct vcl *, struct worker *, struct req *, \ diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c index 270452132..ed89868d7 100644 --- a/bin/varnishd/cache/cache_vcl.c +++ b/bin/varnishd/cache/cache_vcl.c @@ -106,8 +106,8 @@ VCL_Req2Ctx(struct vrt_ctx *ctx, struct req *req) /*--------------------------------------------------------------------*/ -static struct vrt_ctx * -vcl_get_ctx(unsigned method, int msg) +struct vrt_ctx * +VCL_Get_CliCtx(unsigned method, int msg) { ASSERT_CLI(); @@ -126,8 +126,8 @@ vcl_get_ctx(unsigned method, int msg) return (&ctx_cli); } -static void -vcl_rel_ctx(struct vrt_ctx **ctx) +void +VCL_Rel_CliCtx(struct vrt_ctx **ctx) { ASSERT_CLI(); @@ -614,7 +614,7 @@ VCL_Poll(void) struct vcl *vcl, *vcl2; ASSERT_CLI(); - ctx = vcl_get_ctx(0, 0); + ctx = VCL_Get_CliCtx(0, 0); VTAILQ_FOREACH_SAFE(vcl, &vcl_head, list, vcl2) { if (vcl->temp == VCL_TEMP_BUSY || vcl->temp == VCL_TEMP_COOLING) { @@ -639,7 +639,7 @@ VCL_Poll(void) VSC_C_main->n_vcl_discard--; } } - vcl_rel_ctx(&ctx); + VCL_Rel_CliCtx(&ctx); } /*--------------------------------------------------------------------*/ @@ -730,9 +730,9 @@ vcl_cli_load(struct cli *cli, const char * const *av, void *priv) AZ(priv); ASSERT_CLI(); - ctx = vcl_get_ctx(VCL_MET_INIT, 1); + ctx = VCL_Get_CliCtx(VCL_MET_INIT, 1); vcl_load(cli, ctx, av[2], av[3], av[4]); - vcl_rel_ctx(&ctx); + VCL_Rel_CliCtx(&ctx); } static void v_matchproto_(cli_func_t) @@ -744,7 +744,7 @@ vcl_cli_state(struct cli *cli, const char * const *av, void *priv) ASSERT_CLI(); AN(av[2]); AN(av[3]); - ctx = vcl_get_ctx(0, 1); + ctx = VCL_Get_CliCtx(0, 1); ctx->vcl = vcl_find(av[2]); AN(ctx->vcl); // MGT ensures this if (vcl_set_state(ctx, av[3])) { @@ -755,7 +755,7 @@ vcl_cli_state(struct cli *cli, const char * const *av, void *priv) if (VSB_len(ctx->msg)) VCLI_Out(cli, "\nMessage:\n\t%s", VSB_data(ctx->msg)); } - vcl_rel_ctx(&ctx); + VCL_Rel_CliCtx(&ctx); } static void v_matchproto_(cli_func_t) From nils.goroll at uplex.de Mon Feb 4 14:38:09 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 4 Feb 2019 14:38:09 +0000 (UTC) Subject: [master] 7bc370950 improve backend.list documentation Message-ID: <20190204143809.871E4B0831@lists.varnish-cache.org> commit 7bc37095037539eec9570e72f2c4fb13518434a9 Author: Nils Goroll Date: Mon Feb 4 15:31:05 2019 +0100 improve backend.list documentation * move -p documentation from CLI "help backend.list" to sphinx * Add note on the fact that the health state as seen from VCL may differ diff --git a/include/tbl/cli_cmds.h b/include/tbl/cli_cmds.h index 57efeaab6..6c020f072 100644 --- a/include/tbl/cli_cmds.h +++ b/include/tbl/cli_cmds.h @@ -257,8 +257,13 @@ CLI_CMD(DEBUG_LISTEN_ADDRESS, CLI_CMD(BACKEND_LIST, "backend.list", "backend.list [-j] [-p] []", - "List backends. -p also shows probe status.", - "``-j`` specifies JSON output.", + "List backends.\n", + " ``-p`` also shows probe status.\n\n" + " ``-j`` specifies JSON output.\n\n" + " The health state reported here is generic. A backend's health " + "may also depend on the context it is being used in (e.g. " + "the object's hash), so the actual health state as visible " + "from VCL (e.g. using std.healthy()) may differ.", 0, 2 ) From nils.goroll at uplex.de Mon Feb 4 14:38:09 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 4 Feb 2019 14:38:09 +0000 (UTC) Subject: [master] 820bafa42 fix varnish-cli(7) indentation of cli command docs Message-ID: <20190204143809.9AD7FB0834@lists.varnish-cache.org> commit 820bafa4200d7a80b2d48023573631ab41c16fb4 Author: Nils Goroll Date: Mon Feb 4 15:36:32 2019 +0100 fix varnish-cli(7) indentation of cli command docs diff --git a/include/tbl/cli_cmds.h b/include/tbl/cli_cmds.h index 6c020f072..5c28ed5c8 100644 --- a/include/tbl/cli_cmds.h +++ b/include/tbl/cli_cmds.h @@ -43,7 +43,7 @@ CLI_CMD(BAN, "ban", "ban [&& ...]", "Mark obsolete all objects where all the conditions match.", - "See :ref:`vcl(7)_ban` for details", + " See :ref:`vcl(7)_ban` for details", 3, -1 ) @@ -52,7 +52,7 @@ CLI_CMD(BAN_LIST, "ban.list [-j]", "List the active bans.", - " Unless ``-j`` is specified (for JSON output), " + " Unless ``-j`` is specified (for JSON output), " " the output format is:\n\n" " * Time the ban was issued.\n\n" " * Objects referencing this ban.\n\n" @@ -105,7 +105,7 @@ CLI_CMD(VCL_LIST, "vcl.list", "vcl.list [-j]", "List all loaded configuration.", - "``-j`` specifies JSON output.", + " ``-j`` specifies JSON output.", 0, 0 ) @@ -146,7 +146,7 @@ CLI_CMD(PARAM_SHOW, "param.show [-l|-j] [|changed]", "Show parameters and their values.", - "The long form with ``-l`` shows additional information, including" + " The long form with ``-l`` shows additional information, including" " documentation and minimum, maximum and default values, if defined" " for the parameter. JSON output is specified with ``-j``, in which" " the information for the long form is included; only one of ``-l`` or" @@ -184,7 +184,7 @@ CLI_CMD(PING, "ping", "ping [-j] []", "Keep connection alive.", - "The response is formatted as JSON if ``-j`` is specified.", + " The response is formatted as JSON if ``-j`` is specified.", 0, 1 ) @@ -192,7 +192,7 @@ CLI_CMD(HELP, "help", "help [-j] []", "Show command/protocol help.", - "``-j`` specifies JSON output.", + " ``-j`` specifies JSON output.", 0, 1 ) @@ -208,7 +208,7 @@ CLI_CMD(SERVER_STATUS, "status", "status [-j]", "Check status of Varnish cache process.", - "``-j`` specifies JSON output.", + " ``-j`` specifies JSON output.", 0, 0 ) @@ -232,7 +232,7 @@ CLI_CMD(PANIC_SHOW, "panic.show", "panic.show [-j]", "Return the last panic, if any.", - "``-j`` specifies JSON output -- the panic message is returned as an" + " ``-j`` specifies JSON output -- the panic message is returned as an" " unstructured JSON string.", 0, 0 ) @@ -339,7 +339,7 @@ CLI_CMD(STORAGE_LIST, "storage.list", "storage.list [-j]", "List storage devices.", - "``-j`` specifies JSON output.", + " ``-j`` specifies JSON output.", 0, 0 ) From phk at FreeBSD.org Mon Feb 4 15:32:10 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 4 Feb 2019 15:32:10 +0000 (UTC) Subject: [master] 0d6803d29 Quench flexelint noise Message-ID: <20190204153210.46BD2B19CA@lists.varnish-cache.org> commit 0d6803d293420dc655c14a9b06450e26f3e73476 Author: Poul-Henning Kamp Date: Mon Feb 4 15:26:31 2019 +0000 Quench flexelint noise diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py index 310f4a43f..94a9f5a71 100755 --- a/lib/libvcc/vmodtool.py +++ b/lib/libvcc/vmodtool.py @@ -960,6 +960,9 @@ class vcc(object): fo.write('#define VPFX(a) %s##a\n' % self.sympfx) fo.write('#define VARGS(a) arg_%s##a\n' % self.sympfx) fo.write('#define VENUM(a) enum_%s##a\n' % self.sympfx) + fo.write('//lint -esym(755, VPFX)\n') + fo.write('//lint -esym(755, VARGS)\n') + fo.write('//lint -esym(755, VENUM)\n') fo.write('\n') for j in sorted(self.enums): From nils.goroll at uplex.de Mon Feb 4 18:39:08 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 4 Feb 2019 18:39:08 +0000 (UTC) Subject: [master] bc5f754f2 Also add a ctx to vdi_list_f (director list callback) Message-ID: <20190204183908.49DD563A9@lists.varnish-cache.org> commit bc5f754f2c153650ac3b3f10ec7397c14bfbb203 Author: Nils Goroll Date: Mon Feb 4 19:24:26 2019 +0100 Also add a ctx to vdi_list_f (director list callback) ... to bring "more nuance" (quote phk) to the director health state output, the list callback needs to be able to query VRT_Health() of the director's backends, so, in turn, we also need a CTX here. Ref https://github.com/varnishcache/varnish-cache/pull/2888#issuecomment-460258147 Of the following out-of-tree vmods, none uses the .list callback, so I expect minimal vmod author uprise: - saintmode (varnish-modules) - all_healthy - dynamic - cluster - weightadjust (someome(tm) needs to update to vdi_methods) diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c index f1426f618..2c8ce70f8 100644 --- a/bin/varnishd/cache/cache_backend.c +++ b/bin/varnishd/cache/cache_backend.c @@ -445,12 +445,14 @@ vbe_panic(const struct director *d, struct vsb *vsb) /*-------------------------------------------------------------------- */ -static void -vbe_list(const struct director *d, struct vsb *vsb, int vflag, int pflag, - int jflag) +static void v_matchproto_(vdi_list_f) +vbe_list(VRT_CTX, const struct director *d, struct vsb *vsb, int vflag, + int pflag, int jflag) { struct backend *bp; + (void)ctx; + CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); CAST_OBJ_NOTNULL(bp, d->priv, BACKEND_MAGIC); diff --git a/bin/varnishd/cache/cache_director.c b/bin/varnishd/cache/cache_director.c index 9bb13a444..152418d55 100644 --- a/bin/varnishd/cache/cache_director.c +++ b/bin/varnishd/cache/cache_director.c @@ -278,15 +278,9 @@ struct list_args { }; static const char * -cli_health(struct director *d) +cli_health(VRT_CTX, struct director *d) { - struct vrt_ctx *ctx; - VCL_BOOL healthy; - - ctx = VCL_Get_CliCtx(0,0); - healthy = VRT_Healthy(ctx, d, NULL); - VCL_Rel_CliCtx(&ctx); - AZ(ctx); + VCL_BOOL healthy = VRT_Healthy(ctx, d, NULL); return (healthy ? "healthy" : "sick"); } @@ -296,6 +290,7 @@ do_list(struct cli *cli, struct director *d, void *priv) { char time_str[VTIM_FORMAT_SIZE]; struct list_args *la; + struct vrt_ctx *ctx; CAST_OBJ_NOTNULL(la, priv, LIST_ARGS_MAGIC); CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); @@ -303,18 +298,24 @@ do_list(struct cli *cli, struct director *d, void *priv) if (d->vdir->admin_health == VDI_AH_DELETED) return (0); + ctx = VCL_Get_CliCtx(0,0); + // XXX admin health "probe" for the no-probe case is confusing VCLI_Out(cli, "\n%-30s %-7s ", d->vdir->cli_name, VDI_Ahealth(d)); if (d->vdir->methods->list != NULL) - d->vdir->methods->list(d, cli->sb, 0, 0, 0); + d->vdir->methods->list(ctx, d, cli->sb, 0, 0, 0); else - VCLI_Out(cli, "%-10s", cli_health(d)); + VCLI_Out(cli, "%-10s", cli_health(ctx, d)); VTIM_format(d->vdir->health_changed, time_str); VCLI_Out(cli, " %s", time_str); if ((la->p || la->v) && d->vdir->methods->list != NULL) - d->vdir->methods->list(d, cli->sb, la->p, la->v, 0); + d->vdir->methods->list(ctx, d, cli->sb, la->p, la->v, 0); + + VCL_Rel_CliCtx(&ctx); + AZ(ctx); + return (0); } @@ -322,6 +323,7 @@ static int v_matchproto_(vcl_be_func) do_list_json(struct cli *cli, struct director *d, void *priv) { struct list_args *la; + struct vrt_ctx *ctx; CAST_OBJ_NOTNULL(la, priv, LIST_ARGS_MAGIC); CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); @@ -329,6 +331,8 @@ do_list_json(struct cli *cli, struct director *d, void *priv) if (d->vdir->admin_health == VDI_AH_DELETED) return (0); + ctx = VCL_Get_CliCtx(0,0); + VCLI_Out(cli, "%s", la->jsep); la->jsep = ",\n"; // XXX admin health "probe" for the no-probe case is confusing @@ -339,18 +343,22 @@ do_list_json(struct cli *cli, struct director *d, void *priv) VCLI_Out(cli, "\"admin_health\": \"%s\",\n", VDI_Ahealth(d)); VCLI_Out(cli, "\"probe_message\": "); if (d->vdir->methods->list != NULL) - d->vdir->methods->list(d, cli->sb, 0, 0, 1); + d->vdir->methods->list(ctx, d, cli->sb, 0, 0, 1); else - VCLI_Out(cli, "\"%s\"", cli_health(d)); + VCLI_Out(cli, "\"%s\"", cli_health(ctx, d)); VCLI_Out(cli, ",\n"); if ((la->p || la->v) && d->vdir->methods->list != NULL) { VCLI_Out(cli, "\"probe_details\": "); - d->vdir->methods->list(d, cli->sb, la->p, la->v, 1); + d->vdir->methods->list(ctx, d, cli->sb, la->p, la->v, 1); } VCLI_Out(cli, "\"last_change\": %.3f\n", d->vdir->health_changed); VSB_indent(cli->sb, -2); VCLI_Out(cli, "}"); + + VCL_Rel_CliCtx(&ctx); + AZ(ctx); + return (0); } diff --git a/include/vrt.h b/include/vrt.h index 9cbf6a6d7..4b547e839 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -60,6 +60,7 @@ * changed VRT_blob() * req->req_bodybytes removed * use: AZ(ObjGetU64(req->wrk, req->body_oc, OA_LEN, &u)); + * struct vdi_methods .list callback signature changed * 8.0 (2018-09-15) * VRT_Strands() added * VRT_StrandsWS() added @@ -476,7 +477,7 @@ typedef enum sess_close vdi_http1pipe_f(VRT_CTX, VCL_BACKEND); typedef void vdi_event_f(VCL_BACKEND, enum vcl_event_e); typedef void vdi_destroy_f(VCL_BACKEND); typedef void vdi_panic_f(VCL_BACKEND, struct vsb *); -typedef void vdi_list_f(VCL_BACKEND, struct vsb *, int, int, int); +typedef void vdi_list_f(VRT_CTX, VCL_BACKEND, struct vsb *, int, int, int); struct vdi_methods { unsigned magic; From phk at FreeBSD.org Tue Feb 5 06:36:10 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 5 Feb 2019 06:36:10 +0000 (UTC) Subject: [master] 9b0b9fa39 Constify Message-ID: <20190205063610.7751597F2E@lists.varnish-cache.org> commit 9b0b9fa3956e2010759f1161bd22e2beb12dd52c Author: Poul-Henning Kamp Date: Tue Feb 5 06:32:23 2019 +0000 Constify diff --git a/bin/varnishd/cache/cache_director.c b/bin/varnishd/cache/cache_director.c index 152418d55..a94c36ab5 100644 --- a/bin/varnishd/cache/cache_director.c +++ b/bin/varnishd/cache/cache_director.c @@ -278,7 +278,7 @@ struct list_args { }; static const char * -cli_health(VRT_CTX, struct director *d) +cli_health(VRT_CTX, const struct director *d) { VCL_BOOL healthy = VRT_Healthy(ctx, d, NULL); From phk at FreeBSD.org Tue Feb 5 06:36:10 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 5 Feb 2019 06:36:10 +0000 (UTC) Subject: [master] 40460fe90 Change the 'len' field in vmod_priv and vrt_blob to a 'long' Message-ID: <20190205063610.8C6FB97F32@lists.varnish-cache.org> commit 40460fe90aa27b3aea93e7bd560c3ebe11f3f9ec Author: Poul-Henning Kamp Date: Tue Feb 5 06:33:34 2019 +0000 Change the 'len' field in vmod_priv and vrt_blob to a 'long' We have code which relies on it being able to contain negative values as error indications, but 'ssize_t' from unistd.h is a bridge too far for vrt.h which is meant to be _incredibly_ portable to avoid problems at compile time. diff --git a/bin/varnishd/cache/cache_vrt_priv.c b/bin/varnishd/cache/cache_vrt_priv.c index 13ab454e2..fe9da5d77 100644 --- a/bin/varnishd/cache/cache_vrt_priv.c +++ b/bin/varnishd/cache/cache_vrt_priv.c @@ -68,7 +68,7 @@ pan_privs(struct vsb *vsb, const struct vrt_privs *privs) VRBT_FOREACH(vp, vrt_priv_tree, &privs->privs) { PAN_CheckMagic(vsb, vp, VRT_PRIV_MAGIC); VSB_printf(vsb, - "priv {p %p l %d f %p} vmod %jx\n", + "priv {p %p l %ld f %p} vmod %jx\n", vp->priv->priv, vp->priv->len, vp->priv->free, diff --git a/include/vrt.h b/include/vrt.h index 4b547e839..2e4ed2301 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -53,6 +53,7 @@ * * * 9.0 (scheduled for 2019-03-15) + * Make 'len' in vmod_priv and vrt_blob a 'long' * HTTP_Copy() removed * HTTP_Dup() added * HTTP_Clone() added @@ -177,7 +178,7 @@ struct strands { struct vrt_blob { unsigned type; - size_t len; + long len; const void *blob; }; @@ -531,7 +532,7 @@ typedef int vmod_event_f(VRT_CTX, struct vmod_priv *, enum vcl_event_e); typedef void vmod_priv_free_f(void *); struct vmod_priv { void *priv; - int len; + long len; vmod_priv_free_f *free; }; From phk at FreeBSD.org Tue Feb 5 06:40:08 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 5 Feb 2019 06:40:08 +0000 (UTC) Subject: [master] 731c2182a Adjust printf to suit previous commit Message-ID: <20190205064008.741739B304@lists.varnish-cache.org> commit 731c2182a7afe20eb22931ff224041c4b96a6a82 Author: Poul-Henning Kamp Date: Tue Feb 5 06:39:39 2019 +0000 Adjust printf to suit previous commit diff --git a/lib/libvmod_blob/vmod_blob.c b/lib/libvmod_blob/vmod_blob.c index d032a439b..75e691794 100644 --- a/lib/libvmod_blob/vmod_blob.c +++ b/lib/libvmod_blob/vmod_blob.c @@ -527,7 +527,7 @@ vmod_sub(VRT_CTX, VCL_BLOB b, VCL_BYTES n, VCL_BYTES off) if (off + n > b->len) { VERR(ctx, "size %jd from offset %jd requires more bytes than " - "blob length %zd in blob.sub()", + "blob length %ld in blob.sub()", (intmax_t)n, (intmax_t)off, b->len); return NULL; } From phk at FreeBSD.org Tue Feb 5 07:08:07 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 5 Feb 2019 07:08:07 +0000 (UTC) Subject: [master] ebbbad964 Flexelinting Message-ID: <20190205070807.D22F29BD35@lists.varnish-cache.org> commit ebbbad96484f2ec6823911f460ad5a1107c8a9c3 Author: Poul-Henning Kamp Date: Tue Feb 5 07:07:42 2019 +0000 Flexelinting diff --git a/bin/varnishadm/varnishadm.c b/bin/varnishadm/varnishadm.c index db16284f6..19e3463b3 100644 --- a/bin/varnishadm/varnishadm.c +++ b/bin/varnishadm/varnishadm.c @@ -73,7 +73,7 @@ } while (0) -static double timeout = 5; // XXX should be settable by arg ? +static const double timeout = 5; // XXX should be settable by arg ? static void cli_write(int sock, const char *s) diff --git a/bin/varnishd/cache/cache_objhead.h b/bin/varnishd/cache/cache_objhead.h index e12463981..41b7781a5 100644 --- a/bin/varnishd/cache/cache_objhead.h +++ b/bin/varnishd/cache/cache_objhead.h @@ -66,7 +66,6 @@ void HSH_DeleteObjHead(const struct worker *, struct objhead *); int HSH_DerefObjCore(struct worker *, struct objcore **, int rushmax); #define HSH_RUSH_POLICY -1 -#define HSH_RUSH_ALL INT_MAX enum lookup_e HSH_Lookup(struct req *, struct objcore **, struct objcore **); void HSH_Ref(struct objcore *o); diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c index ed89868d7..a524a7981 100644 --- a/bin/varnishd/cache/cache_vcl.c +++ b/bin/varnishd/cache/cache_vcl.c @@ -50,7 +50,9 @@ const char * const VCL_TEMP_COLD = "cold"; const char * const VCL_TEMP_WARM = "warm"; const char * const VCL_TEMP_BUSY = "busy"; const char * const VCL_TEMP_COOLING = "cooling"; -const char * const VCL_TEMP_LABEL = "label"; + +// not really a state +static const char * const VCL_TEMP_LABEL = "label"; /* * XXX: Presently all modifications to this list happen from the diff --git a/bin/varnishd/cache/cache_vcl.h b/bin/varnishd/cache/cache_vcl.h index e9d99a710..aa530cb5b 100644 --- a/bin/varnishd/cache/cache_vcl.h +++ b/bin/varnishd/cache/cache_vcl.h @@ -75,7 +75,6 @@ extern const char * const VCL_TEMP_COLD; extern const char * const VCL_TEMP_WARM; extern const char * const VCL_TEMP_BUSY; extern const char * const VCL_TEMP_COOLING; -extern const char * const VCL_TEMP_LABEL; /* * NB: The COOLING temperature is neither COLD nor WARM. diff --git a/bin/varnishd/flint.lnt b/bin/varnishd/flint.lnt index 88e89b36d..238dec743 100644 --- a/bin/varnishd/flint.lnt +++ b/bin/varnishd/flint.lnt @@ -72,7 +72,8 @@ // Macros defined differently in each VMOD -esym(767, VPFX) // macro '___' was defined differently in another module -esym(767, VARGS) // macro '___' was defined differently in another module --esym(767, VENUM) // macro '___' was defined differently in another module +-esym(767, VENUM) // macro '___' was defined differently in another module +-esym(14, enum_vmod*) // Symbol '___' previously defined (___) ////////////// -efunc(1791, pdiff) // return last on line ////////////// diff --git a/lib/libvmod_blob/vmod_blob.h b/lib/libvmod_blob/vmod_blob.h index 032f59986..3b027480a 100644 --- a/lib/libvmod_blob/vmod_blob.h +++ b/lib/libvmod_blob/vmod_blob.h @@ -32,13 +32,13 @@ #include enum encoding { - _INVALID = 0, + __INVALID_ENCODING = 0, #define VMODENUM(x) x, #include "tbl_encodings.h" __MAX_ENCODING }; -#define AENC(enc) assert((enc) > _INVALID && (enc) < __MAX_ENCODING) +#define AENC(enc) assert((enc) > __INVALID_ENCODING && (enc) < __MAX_ENCODING) /* * The enums MUST appear in this order, since LOWER and UPPER are used to diff --git a/lib/libvmod_directors/shard_cfg.c b/lib/libvmod_directors/shard_cfg.c index d8ac65109..154595e8f 100644 --- a/lib/libvmod_directors/shard_cfg.c +++ b/lib/libvmod_directors/shard_cfg.c @@ -41,7 +41,7 @@ /*lint -esym(749, shard_change_task_e::*) */ enum shard_change_task_e { - _INVALID = 0, + _SHARD_TASK_E_INVALID = 0, CLEAR, ADD_BE, REMOVE_BE, From phk at FreeBSD.org Tue Feb 5 08:04:07 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 5 Feb 2019 08:04:07 +0000 (UTC) Subject: [master] 51542bef0 Filter all but the interface symbol out of vmod shlibs. Message-ID: <20190205080407.8D504A0C4A@lists.varnish-cache.org> commit 51542bef0fce998fded3899e53745e075a22bb39 Author: Poul-Henning Kamp Date: Tue Feb 5 08:03:22 2019 +0000 Filter all but the interface symbol out of vmod shlibs. Use boilerplate for vmod_debug diff --git a/.gitignore b/.gitignore index 37b62a9fa..6a6eb8f57 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ Makefile Makefile.in # ... +_* .deps/ .libs/ *.o diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py index 94a9f5a71..f7886920c 100755 --- a/lib/libvcc/vmodtool.py +++ b/lib/libvcc/vmodtool.py @@ -66,6 +66,7 @@ libvmod_XXX_la_CFLAGS = \\ \t at SAN_CFLAGS@ libvmod_XXX_la_LDFLAGS = \\ +\t-export-symbols-regex 'Vmod_XXX_Data' \\ \t$(AM_LDFLAGS) \\ \t$(VMOD_LDFLAGS) \\ \t at SAN_LDFLAGS@ diff --git a/lib/libvmod_blob/automake_boilerplate.am b/lib/libvmod_blob/automake_boilerplate.am index e9346968e..5bad5e10a 100644 --- a/lib/libvmod_blob/automake_boilerplate.am +++ b/lib/libvmod_blob/automake_boilerplate.am @@ -18,6 +18,7 @@ libvmod_blob_la_CFLAGS = \ @SAN_CFLAGS@ libvmod_blob_la_LDFLAGS = \ + -export-symbols-regex 'Vmod_blob_Data' \ $(AM_LDFLAGS) \ $(VMOD_LDFLAGS) \ @SAN_LDFLAGS@ diff --git a/lib/libvmod_debug/Makefile.am b/lib/libvmod_debug/Makefile.am index edb074cce..4823e1b4d 100644 --- a/lib/libvmod_debug/Makefile.am +++ b/lib/libvmod_debug/Makefile.am @@ -5,42 +5,10 @@ libvmod_debug_la_SOURCES = \ vmod_debug_obj.c \ vmod_debug_dyn.c -# Boilerplate, do not change +include $(srcdir)/automake_boilerplate.am -AM_LDFLAGS = $(AM_LT_LDFLAGS) - -AM_CPPFLAGS = \ - -I$(top_srcdir)/include \ - -I$(top_srcdir)/bin/varnishd \ - -I$(top_builddir)/include - -vmoddir = $(pkglibdir)/vmods -vmod_srcdir = $(top_srcdir)/lib/libvmod_debug -vmodtool = $(top_srcdir)/lib/libvcc/vmodtool.py -vmodtoolargs = - - -noinst_LTLIBRARIES = libvmod_debug.la - -libvmod_debug_la_CFLAGS = \ - @SAN_CFLAGS@ - -libvmod_debug_la_LDFLAGS = \ - $(AM_LDFLAGS) \ - $(VMOD_LDFLAGS) \ - -rpath /nowhere - @SAN_LDFLAGS@ - -nodist_libvmod_debug_la_SOURCES = \ - vcc_if.c \ - vcc_if.h - -$(libvmod_debug_la_OBJECTS): vcc_if.h - -vcc_if.h vmod_debug.rst vmod_debug.man.rst: vcc_if.c - -vcc_if.c: $(vmodtool) $(vmod_srcdir)/vmod.vcc - @PYTHON@ $(vmodtool) $(vmodtoolargs) $(vmod_srcdir)/vmod.vcc +# not --strict +vmodtoolargs = --boilerplate .vsc.c: $(PYTHON) $(top_srcdir)/lib/libvcc/vsctool.py -ch $< @@ -49,14 +17,7 @@ VSC_SRC = VSC_debug.vsc VSC_GEN_C = VSC_debug.c VSC_GEN_H = VSC_debug.h +CLEANFILES += $(VSC_GEN_C) $(VSC_GEN_H) + BUILT_SOURCES = $(VSC_GEN_C) libvmod_debug_la_SOURCES += $(VSC_SRC) - -$(VSC_GEN_C): $(top_srcdir)/lib/libvcc/vsctool.py - -EXTRA_DIST = vmod.vcc - -CLEANFILES = $(builddir)/vcc_if.c $(builddir)/vcc_if.h \ - $(builddir)/vmod_debug.rst \ - $(builddir)/vmod_debug.man.rst \ - $(VSC_GEN_C) $(VSC_GEN_H) diff --git a/lib/libvmod_debug/automake_boilerplate.am b/lib/libvmod_debug/automake_boilerplate.am new file mode 100644 index 000000000..fd3aaea3a --- /dev/null +++ b/lib/libvmod_debug/automake_boilerplate.am @@ -0,0 +1,40 @@ + +# Boilerplate generated by vmodtool.py - changes will be overwritten + +AM_LDFLAGS = $(AM_LT_LDFLAGS) + +AM_CPPFLAGS = \ + -I$(top_srcdir)/include \ + -I$(top_srcdir)/bin/varnishd \ + -I$(top_builddir)/include + +vmoddir = $(pkglibdir)/vmods +vmodtool = $(top_srcdir)/lib/libvcc/vmodtool.py +vmodtoolargs = --strict --boilerplate + +vmod_LTLIBRARIES = libvmod_debug.la + +libvmod_debug_la_CFLAGS = \ + @SAN_CFLAGS@ + +libvmod_debug_la_LDFLAGS = \ + -export-symbols-regex 'Vmod_debug_Data' \ + $(AM_LDFLAGS) \ + $(VMOD_LDFLAGS) \ + @SAN_LDFLAGS@ + +nodist_libvmod_debug_la_SOURCES = vcc_if.c vcc_if.h + +$(libvmod_debug_la_OBJECTS): vcc_if.h + +vcc_if.h vmod_debug.rst vmod_debug.man.rst: vcc_if.c + +vcc_if.c: $(vmodtool) $(srcdir)/vmod.vcc + @PYTHON@ $(vmodtool) $(vmodtoolargs) $(srcdir)/vmod.vcc + +EXTRA_DIST = vmod.vcc automake_boilerplate.am + +CLEANFILES = $(builddir)/vcc_if.c $(builddir)/vcc_if.h \ + $(builddir)/vmod_debug.rst \ + $(builddir)/vmod_debug.man.rst + diff --git a/lib/libvmod_directors/automake_boilerplate.am b/lib/libvmod_directors/automake_boilerplate.am index df54f452c..2c0b9b5b9 100644 --- a/lib/libvmod_directors/automake_boilerplate.am +++ b/lib/libvmod_directors/automake_boilerplate.am @@ -18,6 +18,7 @@ libvmod_directors_la_CFLAGS = \ @SAN_CFLAGS@ libvmod_directors_la_LDFLAGS = \ + -export-symbols-regex 'Vmod_directors_Data' \ $(AM_LDFLAGS) \ $(VMOD_LDFLAGS) \ @SAN_LDFLAGS@ diff --git a/lib/libvmod_proxy/automake_boilerplate.am b/lib/libvmod_proxy/automake_boilerplate.am index 64f3c5a0a..4ee1e5abd 100644 --- a/lib/libvmod_proxy/automake_boilerplate.am +++ b/lib/libvmod_proxy/automake_boilerplate.am @@ -18,6 +18,7 @@ libvmod_proxy_la_CFLAGS = \ @SAN_CFLAGS@ libvmod_proxy_la_LDFLAGS = \ + -export-symbols-regex 'Vmod_proxy_Data' \ $(AM_LDFLAGS) \ $(VMOD_LDFLAGS) \ @SAN_LDFLAGS@ diff --git a/lib/libvmod_purge/automake_boilerplate.am b/lib/libvmod_purge/automake_boilerplate.am index b400cdb3c..d107999e3 100644 --- a/lib/libvmod_purge/automake_boilerplate.am +++ b/lib/libvmod_purge/automake_boilerplate.am @@ -18,6 +18,7 @@ libvmod_purge_la_CFLAGS = \ @SAN_CFLAGS@ libvmod_purge_la_LDFLAGS = \ + -export-symbols-regex 'Vmod_purge_Data' \ $(AM_LDFLAGS) \ $(VMOD_LDFLAGS) \ @SAN_LDFLAGS@ diff --git a/lib/libvmod_std/automake_boilerplate.am b/lib/libvmod_std/automake_boilerplate.am index c1d6e3d42..e744db0c6 100644 --- a/lib/libvmod_std/automake_boilerplate.am +++ b/lib/libvmod_std/automake_boilerplate.am @@ -18,6 +18,7 @@ libvmod_std_la_CFLAGS = \ @SAN_CFLAGS@ libvmod_std_la_LDFLAGS = \ + -export-symbols-regex 'Vmod_std_Data' \ $(AM_LDFLAGS) \ $(VMOD_LDFLAGS) \ @SAN_LDFLAGS@ diff --git a/lib/libvmod_unix/automake_boilerplate.am b/lib/libvmod_unix/automake_boilerplate.am index b71674a0e..18d06b8cd 100644 --- a/lib/libvmod_unix/automake_boilerplate.am +++ b/lib/libvmod_unix/automake_boilerplate.am @@ -18,6 +18,7 @@ libvmod_unix_la_CFLAGS = \ @SAN_CFLAGS@ libvmod_unix_la_LDFLAGS = \ + -export-symbols-regex 'Vmod_unix_Data' \ $(AM_LDFLAGS) \ $(VMOD_LDFLAGS) \ @SAN_LDFLAGS@ diff --git a/lib/libvmod_vtc/automake_boilerplate.am b/lib/libvmod_vtc/automake_boilerplate.am index d7bd77ea1..063ab92ba 100644 --- a/lib/libvmod_vtc/automake_boilerplate.am +++ b/lib/libvmod_vtc/automake_boilerplate.am @@ -18,6 +18,7 @@ libvmod_vtc_la_CFLAGS = \ @SAN_CFLAGS@ libvmod_vtc_la_LDFLAGS = \ + -export-symbols-regex 'Vmod_vtc_Data' \ $(AM_LDFLAGS) \ $(VMOD_LDFLAGS) \ @SAN_LDFLAGS@ From phk at FreeBSD.org Tue Feb 5 08:36:08 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 5 Feb 2019 08:36:08 +0000 (UTC) Subject: [master] 5de84f39d slink assures me that blobs can use size_t for ->len, and that this one <= 0 test is an oversight. Message-ID: <20190205083608.D9291A1824@lists.varnish-cache.org> commit 5de84f39dc715ade7e08d63466294663adc47eee Author: Poul-Henning Kamp Date: Tue Feb 5 08:35:08 2019 +0000 slink assures me that blobs can use size_t for ->len, and that this one <= 0 test is an oversight. diff --git a/include/vrt.h b/include/vrt.h index 2e4ed2301..d3d055945 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -178,7 +178,7 @@ struct strands { struct vrt_blob { unsigned type; - long len; + size_t len; const void *blob; }; diff --git a/lib/libvmod_directors/vmod_shard.c b/lib/libvmod_directors/vmod_shard.c index 4495474d3..e709e9cf0 100644 --- a/lib/libvmod_directors/vmod_shard.c +++ b/lib/libvmod_directors/vmod_shard.c @@ -571,7 +571,7 @@ shard_param_args(VRT_CTX, who, p->vcl_name, by_s); return (NULL); } - if (key_blob == NULL || key_blob->len <= 0 || + if (key_blob == NULL || key_blob->len == 0 || key_blob->blob == NULL) { sharddir_err(ctx, SLT_Error, "%s %s: " "by=BLOB but no or empty key_blob " From phk at FreeBSD.org Tue Feb 5 08:41:08 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 5 Feb 2019 08:41:08 +0000 (UTC) Subject: [master] 2a57aeaf0 Revert printf format to match size_t Message-ID: <20190205084108.68696A1B53@lists.varnish-cache.org> commit 2a57aeaf04f874e68b461a2891177a3dbc99081d Author: Poul-Henning Kamp Date: Tue Feb 5 08:40:39 2019 +0000 Revert printf format to match size_t diff --git a/lib/libvmod_blob/vmod_blob.c b/lib/libvmod_blob/vmod_blob.c index 75e691794..d032a439b 100644 --- a/lib/libvmod_blob/vmod_blob.c +++ b/lib/libvmod_blob/vmod_blob.c @@ -527,7 +527,7 @@ vmod_sub(VRT_CTX, VCL_BLOB b, VCL_BYTES n, VCL_BYTES off) if (off + n > b->len) { VERR(ctx, "size %jd from offset %jd requires more bytes than " - "blob length %ld in blob.sub()", + "blob length %zd in blob.sub()", (intmax_t)n, (intmax_t)off, b->len); return NULL; } From nils.goroll at uplex.de Tue Feb 5 10:04:10 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Tue, 5 Feb 2019 10:04:10 +0000 (UTC) Subject: [master] 69dc99d33 fix cli backend.list -p / backend.list -p -j Message-ID: <20190205100410.5797AA52D7@lists.varnish-cache.org> commit 69dc99d33b8073e55c1ed4f26caa1b8fd249499e Author: Nils Goroll Date: Tue Feb 5 11:01:33 2019 +0100 fix cli backend.list -p / backend.list -p -j $ /tmp/bin/varnishadm backend.list -p Backend name Admin Probe Last change boot.a1 probe healthy Tue, 05 Feb 2019 09:58:23 GMT $ /tmp/bin/varnishadm backend.list -pj [ 2, ["backend.list", "-pj"], 1549360935.584, { "boot.a1": { "type": "backend", "admin_health": "probe", "probe_message": "healthy", "probe_details": {}, "last_change": 1549360703.515 }, Fixes #2894 diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c index 2c8ce70f8..039871fc0 100644 --- a/bin/varnishd/cache/cache_backend.c +++ b/bin/varnishd/cache/cache_backend.c @@ -458,8 +458,12 @@ vbe_list(VRT_CTX, const struct director *d, struct vsb *vsb, int vflag, if (bp->probe != NULL) VBP_Status(vsb, bp, vflag | pflag, jflag); - else if ((vflag | pflag) == 0 && jflag) + else if (jflag && (vflag | pflag)) + VSB_printf(vsb, "{},\n"); + else if (jflag) VSB_printf(vsb, "\"%s\"", d->sick ? "sick" : "healthy"); + else if (vflag | pflag) + return; else VSB_printf(vsb, "%-10s", d->sick ? "sick" : "healthy"); } From nils.goroll at uplex.de Tue Feb 5 10:09:09 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Tue, 5 Feb 2019 10:09:09 +0000 (UTC) Subject: [master] 2669a2f6a sync vrt changelog Message-ID: <20190205100909.185F9A55CB@lists.varnish-cache.org> commit 2669a2f6a9c23697d211b5e51cf9eba15e78efa4 Author: Nils Goroll Date: Tue Feb 5 11:08:25 2019 +0100 sync vrt changelog diff --git a/include/vrt.h b/include/vrt.h index d3d055945..24d0373c3 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -53,7 +53,7 @@ * * * 9.0 (scheduled for 2019-03-15) - * Make 'len' in vmod_priv and vrt_blob a 'long' + * Make 'len' in vmod_priv 'long' * HTTP_Copy() removed * HTTP_Dup() added * HTTP_Clone() added From nils.goroll at uplex.de Tue Feb 5 10:39:08 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Tue, 5 Feb 2019 10:39:08 +0000 (UTC) Subject: [master] b71ceaa65 centralize definition of backend.list fields width Message-ID: <20190205103908.38C3CA610E@lists.varnish-cache.org> commit b71ceaa65886e06b1987d1ed5425b8d82377fee6 Author: Nils Goroll Date: Tue Feb 5 11:28:29 2019 +0100 centralize definition of backend.list fields width Yes, this is fugly, yet formatting of the backend.list output is spread all over the place (including vmods via the vdi_list_f callback), so until we decide it is worth spending time on separating formatting from content, I see no other option than making the field widths known to all vrt. The route ahead will likely be to only generate json and make varnishadm reponsible for formatting plain text output. diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c index 039871fc0..36f036fdc 100644 --- a/bin/varnishd/cache/cache_backend.c +++ b/bin/varnishd/cache/cache_backend.c @@ -465,7 +465,8 @@ vbe_list(VRT_CTX, const struct director *d, struct vsb *vsb, int vflag, else if (vflag | pflag) return; else - VSB_printf(vsb, "%-10s", d->sick ? "sick" : "healthy"); + VSB_printf(vsb, "%-*s", VDI_LIST_W_PROBE, + d->sick ? "sick" : "healthy"); } /*-------------------------------------------------------------------- diff --git a/bin/varnishd/cache/cache_backend_probe.c b/bin/varnishd/cache/cache_backend_probe.c index 3f478db38..19719fca3 100644 --- a/bin/varnishd/cache/cache_backend_probe.c +++ b/bin/varnishd/cache/cache_backend_probe.c @@ -515,7 +515,7 @@ void VBP_Status(struct vsb *vsb, const struct backend *be, int details, int json) { struct vbp_target *vt; - char buf[12]; + char buf[VDI_LIST_W_PROBE + 2]; CHECK_OBJ_NOTNULL(be, BACKEND_MAGIC); vt = be->probe; @@ -527,7 +527,7 @@ VBP_Status(struct vsb *vsb, const struct backend *be, int details, int json) if (json) VSB_printf(vsb, "\"%s\"", buf); else - VSB_printf(vsb, "%-10s", buf); + VSB_printf(vsb, "%-*s", VDI_LIST_W_PROBE, buf); return; } diff --git a/bin/varnishd/cache/cache_director.c b/bin/varnishd/cache/cache_director.c index a94c36ab5..3b21903f4 100644 --- a/bin/varnishd/cache/cache_director.c +++ b/bin/varnishd/cache/cache_director.c @@ -301,12 +301,14 @@ do_list(struct cli *cli, struct director *d, void *priv) ctx = VCL_Get_CliCtx(0,0); // XXX admin health "probe" for the no-probe case is confusing - VCLI_Out(cli, "\n%-30s %-7s ", d->vdir->cli_name, VDI_Ahealth(d)); + VCLI_Out(cli, "\n%-*s %-*s ", + VDI_LIST_W_NAME, d->vdir->cli_name, + VDI_LIST_W_ADMIN, VDI_Ahealth(d)); if (d->vdir->methods->list != NULL) d->vdir->methods->list(ctx, d, cli->sb, 0, 0, 0); else - VCLI_Out(cli, "%-10s", cli_health(ctx, d)); + VCLI_Out(cli, "%-*s", VDI_LIST_W_PROBE, cli_health(ctx, d)); VTIM_format(d->vdir->health_changed, time_str); VCLI_Out(cli, " %s", time_str); @@ -402,8 +404,11 @@ cli_backend_list(struct cli *cli, const char * const *av, void *priv) VCLI_Out(cli, "}"); VCLI_JSON_end(cli); } else { - VCLI_Out(cli, "%-30s %-7s %-10s %s", - "Backend name", "Admin", "Probe", "Last change"); + VCLI_Out(cli, "%-*s %-*s %-*s %s", + VDI_LIST_W_NAME, "Backend name", + VDI_LIST_W_ADMIN, "Admin", + VDI_LIST_W_PROBE, "Probe", + "Last change"); (void)VCL_IterDirector(cli, av[i], do_list, la); } } diff --git a/include/vrt.h b/include/vrt.h index 24d0373c3..b4c77462b 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -496,6 +496,11 @@ struct vdi_methods { vdi_list_f *list; }; +/* width of fields in "backend.list" */ +#define VDI_LIST_W_NAME 30 +#define VDI_LIST_W_ADMIN 7 +#define VDI_LIST_W_PROBE 10 + struct vcldir; struct director { From nils.goroll at uplex.de Tue Feb 5 10:47:08 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Tue, 5 Feb 2019 10:47:08 +0000 (UTC) Subject: [master] 5cb568af8 widen the Probe field of the backend.list CLI command Message-ID: <20190205104708.722B3A6588@lists.varnish-cache.org> commit 5cb568af895d22229bebbc8731f8c5869db75e37 Author: Nils Goroll Date: Tue Feb 5 11:45:51 2019 +0100 widen the Probe field of the backend.list CLI command diff --git a/doc/changes.rst b/doc/changes.rst index 7d1b59252..a83fe8e84 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -62,6 +62,12 @@ Varnish Cache trunk (ongoing) ``vcl_dir`` -> ``vcl_path`` ``vmod_dir`` -> ``vmod_path`` +* Changed the width of the `Probe` column of the ``backend.list`` + cli command from 10 to 14 characters + + For best forward compatibility, we recommend that scripts parse JSON + output as obtained using the ``-j`` option. + VCL --- diff --git a/include/vrt.h b/include/vrt.h index b4c77462b..091508dda 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -499,7 +499,7 @@ struct vdi_methods { /* width of fields in "backend.list" */ #define VDI_LIST_W_NAME 30 #define VDI_LIST_W_ADMIN 7 -#define VDI_LIST_W_PROBE 10 +#define VDI_LIST_W_PROBE 14 struct vcldir; From nils.goroll at uplex.de Tue Feb 5 10:52:09 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Tue, 5 Feb 2019 10:52:09 +0000 (UTC) Subject: [master] 70693bee0 do we want to retire backend.list -v ? Message-ID: <20190205105209.13FE3A72E4@lists.varnish-cache.org> commit 70693bee053043f696b221cb5daba8f040b9b06e Author: Nils Goroll Date: Tue Feb 5 11:51:34 2019 +0100 do we want to retire backend.list -v ? diff --git a/bin/varnishd/cache/cache_director.c b/bin/varnishd/cache/cache_director.c index 3b21903f4..bff135a1f 100644 --- a/bin/varnishd/cache/cache_director.c +++ b/bin/varnishd/cache/cache_director.c @@ -371,6 +371,10 @@ cli_backend_list(struct cli *cli, const char * const *av, void *priv) struct list_args la[1]; int i; + /* + * XXX for all cases in varnish-cache, -v is synonymous to + * -p and -v is not documented. Retire? + */ (void)priv; ASSERT_CLI(); INIT_OBJ(la, LIST_ARGS_MAGIC); From phk at FreeBSD.org Tue Feb 5 11:00:16 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 5 Feb 2019 11:00:16 +0000 (UTC) Subject: [master] 9ceeed8aa Fail VCL loading if VMOD objects are left uninitialized. Message-ID: <20190205110016.D4320A7913@lists.varnish-cache.org> commit 9ceeed8aa880bdb3eb0378aee1ace3d2dc6fca0f 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 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 d9bc4f84b..09c1d4704 100644 --- a/lib/libvcc/vcc_compile.c +++ b/lib/libvcc/vcc_compile.c @@ -293,6 +293,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"); @@ -317,6 +318,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"); @@ -744,6 +752,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 4e7e94c05..ece13c662 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 678821429..483411010 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 f7886920c..3ad485273 100755 --- a/lib/libvcc/vmodtool.py +++ b/lib/libvcc/vmodtool.py @@ -502,6 +502,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() @@ -708,6 +709,9 @@ class ObjectStanza(Stanza): ''' $Object TYPE class ( ARGUMENTS ) ''' 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 @@ -768,6 +772,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 65464fd32..016bca407 100644 --- a/lib/libvmod_debug/vmod.vcc +++ b/lib/libvmod_debug/vmod.vcc @@ -218,7 +218,7 @@ in nanoseconds. For comparable results, a higher size run should called first and discarded. -$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 0dea592a3..34eacca75 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_() @@ -204,8 +203,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 phk at FreeBSD.org Tue Feb 5 14:10:11 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 5 Feb 2019 14:10:11 +0000 (UTC) Subject: [master] 8471010e3 Report the VCL name of the uninitialized object. Message-ID: <20190205141011.6FF54AF499@lists.varnish-cache.org> commit 8471010e394f2d45ff2b2afbb6b3216734265587 Author: Poul-Henning Kamp Date: Tue Feb 5 14:09:36 2019 +0000 Report the VCL name of the uninitialized object. diff --git a/bin/varnishtest/tests/r02839.vtc b/bin/varnishtest/tests/r02839.vtc index 16525a833..275d934ff 100644 --- a/bin/varnishtest/tests/r02839.vtc +++ b/bin/varnishtest/tests/r02839.vtc @@ -7,14 +7,14 @@ server s1 { varnish v1 -vcl+backend "" -start -varnish v1 -errvcl "Object vo_null not initialized" { +varnish v1 -errvcl "Object nullobj not initialized" { import debug; backend default { .host = "127.0.0.1"; } sub vcl_init { if (false) { - new null = debug.obj(); + new nullobj = debug.obj(); } } } diff --git a/lib/libvcc/vcc_compile.c b/lib/libvcc/vcc_compile.c index 09c1d4704..13994eb6b 100644 --- a/lib/libvcc/vcc_compile.c +++ b/lib/libvcc/vcc_compile.c @@ -321,7 +321,7 @@ EmitInitFini(const struct vcc *tl) 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); + "\"Object %s not initialized\");\n" , sy->name); Fc(tl, 0, "\t\treturn(1);\n"); Fc(tl, 0, "\t}\n"); } From nils.goroll at uplex.de Tue Feb 5 14:23:08 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Tue, 5 Feb 2019 14:23:08 +0000 (UTC) Subject: [master] 03047de64 fix vmodtool generated RST headers Message-ID: <20190205142308.ECFECAF9BB@lists.varnish-cache.org> commit 03047de644276f13fdf4c10fa65f0828b97f4bed Author: Nils Goroll Date: Tue Feb 5 15:19:41 2019 +0100 fix vmodtool generated RST headers Neither the vmod_ default $Prefix not an author-supplied $Prefix has got anything to do with the actual name of the vmod. diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py index 3ad485273..e31da1f7b 100755 --- a/lib/libvcc/vmodtool.py +++ b/lib/libvcc/vmodtool.py @@ -585,7 +585,7 @@ class ModuleStanza(Stanza): def rsthead(self, fo, man): if man: - write_rst_hdr(fo, self.vcc.sympfx + self.vcc.modname, "=", "=") + write_rst_hdr(fo, "VMOD " + self.vcc.modname, "=", "=") write_rst_hdr(fo, self.vcc.moddesc, "-", "-") fo.write("\n") fo.write(":Manual section: " + self.vcc.mansection + "\n") @@ -593,7 +593,7 @@ class ModuleStanza(Stanza): if self.rstlbl: fo.write('\n.. _' + self.rstlbl + ':\n') write_rst_hdr(fo, - self.vcc.sympfx + self.vcc.modname + + "VMOD " + self.vcc.modname + ' - ' + self.vcc.moddesc, "=", "=") From nils.goroll at uplex.de Tue Feb 5 15:02:08 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Tue, 5 Feb 2019 15:02:08 +0000 (UTC) Subject: [master] 6412b84c3 test that structural tags are included in a (-w)ritten log Message-ID: <20190205150208.E4956B0661@lists.varnish-cache.org> commit 6412b84c3d37ef887c58262b4a7346d415a41771 Author: Nils Goroll Date: Tue Feb 5 16:00:21 2019 +0100 test that structural tags are included in a (-w)ritten log Tests #2852 Sorry, not the big overhaul of u6 yet... diff --git a/bin/varnishtest/tests/u00006.vtc b/bin/varnishtest/tests/u00006.vtc index 55b2fe909..b263af36c 100644 --- a/bin/varnishtest/tests/u00006.vtc +++ b/bin/varnishtest/tests/u00006.vtc @@ -12,7 +12,8 @@ process p1 { } -start shell { exec varnishlog -n ${v1_name} -D -P ${tmpdir}/vlog.pid \ - -w ${tmpdir}/vlog.bin -R 10/s + -w ${tmpdir}/vlog.bin -R 10/s \ + -i RespStatus -i ReqURL -i BereqURL } shell -match "Usage: .*varnishlog " \ From nils.goroll at uplex.de Tue Feb 5 15:11:09 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Tue, 5 Feb 2019 15:11:09 +0000 (UTC) Subject: [master] bd70a2039 Test that director with sick backends only is shown as sick Message-ID: <20190205151109.6E193B0FBD@lists.varnish-cache.org> commit bd70a20395e9df742a5526f255da8d5ad26422cf Author: Nils Goroll Date: Tue Feb 5 16:10:10 2019 +0100 Test that director with sick backends only is shown as sick Tests #2887 diff --git a/bin/varnishtest/tests/r02887.vtc b/bin/varnishtest/tests/r02887.vtc new file mode 100644 index 000000000..52fbf7a81 --- /dev/null +++ b/bin/varnishtest/tests/r02887.vtc @@ -0,0 +1,20 @@ +varnishtest "Test that director with sick backends only is shown as sick" + +varnish v1 -vcl { + + import directors; + + probe p { .url = "/foo"; } + backend b1 { .host = "${bad_backend}"; .probe = p;} + backend b2 { .host = "${bad_backend}"; .probe = p;} + backend b3 { .host = "${bad_backend}"; .probe = p;} + + sub vcl_init { + new foo = directors.random(); + foo.add_backend(b1, 1); + foo.add_backend(b2, 1); + foo.add_backend(b3, 1); + } +} -start + +varnish v1 -cliexpect "foo.*sick" "backend.list" From nils.goroll at uplex.de Tue Feb 5 15:28:09 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Tue, 5 Feb 2019 15:28:09 +0000 (UTC) Subject: [master] 69574c5af doc tlc Message-ID: <20190205152809.E903FB28FD@lists.varnish-cache.org> commit 69574c5aff714d34904837a5eae188797ff78961 Author: Nils Goroll Date: Tue Feb 5 16:27:29 2019 +0100 doc tlc diff --git a/doc/changes.rst b/doc/changes.rst index a83fe8e84..d8fb2404c 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -154,6 +154,20 @@ C APIs (for vmod and utility authors) AZ(ObjGetU64(req->wrk, req->body_oc, OA_LEN, &u)); +* vmodtool has been changed significantly to avoid various name + clashes. Rather than using literal prefixes/suffixes, vmod authors + should now (and might have to for making existing code continue to + compile) use the following macros + + * ``VPFX(name)`` to prepend the vmod prefix (``vmod_`` by default) + + * ``VARGS(name)`` as the name of a function/method's argument + struct, e.g.:: + + VCL_VOID vmod_test(VRT_CTX, struct VARGS(test) *args) { ... + + * ``VENUM(name)`` to access the enum by the name `name` + Fixed bugs ---------- diff --git a/doc/sphinx/reference/vmod.rst b/doc/sphinx/reference/vmod.rst index 36ef2b51c..574da32dc 100644 --- a/doc/sphinx/reference/vmod.rst +++ b/doc/sphinx/reference/vmod.rst @@ -324,6 +324,10 @@ ENUM Allows values from a set of constant strings. `Note` that the C-type is a string, not a C enum. + Enums will be passed as fixed pointers, so instead of string + comparisons, also pointer comparisons with ``VENUM(name)`` are + possible. + HEADER C-type: ``const struct gethdr_s *`` From dridi.boukelmoune at gmail.com Tue Feb 5 16:30:15 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 5 Feb 2019 16:30:15 +0000 (UTC) Subject: [6.0] 7cf202583 promote vtree.h to vmod include Message-ID: <20190205163015.DB85EBEC30@lists.varnish-cache.org> commit 7cf202583c4e012405766e945042a35af76f8089 Author: Nils Goroll Date: Tue Nov 6 11:47:11 2018 +0100 promote vtree.h to vmod include Now that we include it in cache.h, it is required by vmods Ref #2813 diff --git a/include/Makefile.am b/include/Makefile.am index 98050fd78..01755e09d 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -71,6 +71,7 @@ nobase_pkginclude_HEADERS += \ vsha256.h \ vtcp.h \ vtim.h \ + vtree.h \ vrnd.h # Private headers @@ -98,7 +99,6 @@ nobase_noinst_HEADERS = \ vsub.h \ vss.h \ vtcp.h \ - vtree.h \ vus.h ## keep in sync with lib/libvcc/Makefile.am From dridi.boukelmoune at gmail.com Tue Feb 5 16:30:16 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 5 Feb 2019 16:30:16 +0000 (UTC) Subject: [6.0] d2ef8217e lost commit from ee9e0f6e7259580f17bcba83158c2cc9b79c13f3 Message-ID: <20190205163016.0D4E7BEC33@lists.varnish-cache.org> commit d2ef8217eaa1a6b884d73658e34d28006bf4cd55 Author: Nils Goroll Date: Tue Nov 6 11:54:50 2018 +0100 lost commit from ee9e0f6e7259580f17bcba83158c2cc9b79c13f3 diff --git a/tools/include_wash.py b/tools/include_wash.py index 4df6eeaf3..973d5d6ad 100644 --- a/tools/include_wash.py +++ b/tools/include_wash.py @@ -33,7 +33,7 @@ def check(fn): if i in l: for i in ("stddef.h", "stdint.h", "vrt.h", "math.h", "pthread.h", "stdarg.h", "sys/types.h", - "vdef.h", "miniobj.h", "vas.h", "vqueue.h"): + "vdef.h", "miniobj.h", "vas.h", "vqueue.h", "vtree.h"): if i in l: print(fn, i + " included with cache.h") From dridi.boukelmoune at gmail.com Tue Feb 5 16:30:16 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 5 Feb 2019 16:30:16 +0000 (UTC) Subject: [6.0] 0e3bcf7d9 changelog tlc Message-ID: <20190205163016.2FECABEC37@lists.varnish-cache.org> commit 0e3bcf7d9d2d464ceb599644c4e124dfe0af9979 Author: Nils Goroll Date: Tue Nov 6 12:25:00 2018 +0100 changelog tlc will continue looking backwards from 79687f1344387a26d5e3b0a3b0454ac917db76de Conflicts: doc/changes.rst diff --git a/doc/changes.rst b/doc/changes.rst index 624d4a43c..5ac9da18f 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -26,6 +26,14 @@ http://varnish-cache.org/docs/trunk/whats-new/index.html and via individual releases. These documents are updated as part of the release process. +================================ +Varnish Cache 6.0.3 (unreleased) +================================ + +* Included ``vtree.h`` in the distribution for vmods and + renamed the red/black tree macros from ``VRB_*`` to ``VRBT_*`` + to disambiguate from the acronym for Varnish Request Body. + ================================ Varnish Cache 6.0.2 (2018-11-07) ================================ @@ -70,6 +78,28 @@ Varnish Cache 6.0.2 (2018-11-07) * Fix ``varnishstat -f`` in curses mode (interactively, without ``-1``, 2787_) +* Changed the default of the ``thread_pool_watchdog`` parameter + to 60 seconds to match the ``cli_timeout`` default + +* Fix warmup/rampup of the shard director (2823_) + +* Fix VRT_priv_task for calls from vcl_pipe {} (2820_) + +* Fix vmod object constructor documentation in the ``vmodtool.py`` - + generated RST files + +* Vmod developers are advised that anything returned by a vmod + function/method is assumed to be immutable. In other words, a vmod + `must not` modify any data which was previously returned. + +* ``Content-Length`` header is not rewritten in response to a HEAD + request, allows responses to HEAD requests to be cached + independently from GET responses. + +* ``return(fail("mumble"))`` can have a string argument that is + emitted by VCC as an error message if the VCL load fails due to the + return. (2694_) + * Handle an out-of-workspace condition in HTTP/2 delivery more gracefully (2589_) @@ -104,6 +134,7 @@ Varnish Cache 6.0.2 (2018-11-07) .. _2694: https://github.com/varnishcache/varnish-cache/issues/2694 .. _2696: https://github.com/varnishcache/varnish-cache/issues/2696 .. _2708: https://github.com/varnishcache/varnish-cache/issues/2708 +.. _2713: https://github.com/varnishcache/varnish-cache/issues/2713 .. _2744: https://github.com/varnishcache/varnish-cache/pull/2744 .. _2745: https://github.com/varnishcache/varnish-cache/issues/2745 .. _2746: https://github.com/varnishcache/varnish-cache/issues/2746 From dridi.boukelmoune at gmail.com Tue Feb 5 16:30:16 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 5 Feb 2019 16:30:16 +0000 (UTC) Subject: [6.0] 5fdbd0957 polish blob.same and blob.equal Message-ID: <20190205163016.4B8A2BEC3B@lists.varnish-cache.org> commit 5fdbd0957eae0accf1dc10657db30e3766260654 Author: Nils Goroll Date: Mon Nov 12 17:37:24 2018 +0100 polish blob.same and blob.equal If two blob pointers compare equal, the blobs are both the same and equal - both being NULL is implied. diff --git a/lib/libvmod_blob/vmod_blob.c b/lib/libvmod_blob/vmod_blob.c index 632580e91..08fd2ddf8 100644 --- a/lib/libvmod_blob/vmod_blob.c +++ b/lib/libvmod_blob/vmod_blob.c @@ -527,7 +527,7 @@ vmod_same(VRT_CTX, VCL_BLOB b1, VCL_BLOB b2) { (void) ctx; - if (b1 == NULL && b2 == NULL) + if (b1 == b2) return 1; if (b1 == NULL || b2 == NULL) return 0; @@ -539,7 +539,7 @@ vmod_equal(VRT_CTX, VCL_BLOB b1, VCL_BLOB b2) { (void) ctx; - if (b1 == NULL && b2 == NULL) + if (b1 == b2) return 1; if (b1 == NULL || b2 == NULL) return 0; From dridi.boukelmoune at gmail.com Tue Feb 5 16:30:16 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 5 Feb 2019 16:30:16 +0000 (UTC) Subject: [6.0] 06425c23a Improve argstruct test coverage Message-ID: <20190205163016.7025BBEC3F@lists.varnish-cache.org> commit 06425c23a46440e7deb14e4d13a6d1d55c8e4c47 Author: Nils Goroll Date: Tue Nov 13 12:35:53 2018 +0100 Improve argstruct test coverage Related to #2810 Conflicts: lib/libvmod_debug/vmod.vcc diff --git a/bin/varnishtest/tests/m00019.vtc b/bin/varnishtest/tests/m00019.vtc index b2c9d666f..edc0e3ab7 100644 --- a/bin/varnishtest/tests/m00019.vtc +++ b/bin/varnishtest/tests/m00019.vtc @@ -15,6 +15,10 @@ varnish v1 -vcl+backend { new obj3 = debug.obj(string="s_two", number=two); new obj4 = debug.obj(number=three, string="s_three"); new obj5 = debug.obj(number=three); + + new oo0 = debug.obj_opt(); + new oo1 = debug.obj_opt(s="string"); + new oo2 = debug.obj_opt(b=true); } sub vcl_deliver { @@ -32,6 +36,10 @@ varnish v1 -vcl+backend { set resp.http.obj3 = obj3.string() + ", " + obj3.number(); set resp.http.obj4 = obj4.string() + ", " + obj4.number(); set resp.http.obj5 = obj5.string() + ", " + obj5.number(); + + set resp.http.oo0 = oo0.meth_opt(s="s1"); + set resp.http.oo1 = oo1.meth_opt(b=false); + set resp.http.oo2 = oo2.meth_opt(); } } -start @@ -53,6 +61,11 @@ client c1 { expect resp.http.obj3 == "s_two, two" expect resp.http.obj4 == "s_three, three" expect resp.http.obj5 == "default, three" + + expect resp.http.oo0 == "obj oo0 obj_s *undef* obj_b *undef* met_s s1 met_b *undef*" + expect resp.http.oo1 == "obj oo1 obj_s string obj_b *undef* met_s *undef* met_b false" + expect resp.http.oo2 == "obj oo2 obj_s *undef* obj_b true met_s *undef* met_b *undef*" + } -run delay .1 diff --git a/lib/libvmod_debug/vmod.vcc b/lib/libvmod_debug/vmod.vcc index 2b56f2e35..27f601ffa 100644 --- a/lib/libvmod_debug/vmod.vcc +++ b/lib/libvmod_debug/vmod.vcc @@ -178,3 +178,13 @@ Update counter $Function VOID vsc_destroy() Remove a vsc + +$Object obj_opt(PRIV_CALL, PRIV_VCL, PRIV_TASK, + [STRING s], [BOOL b]) + +Test object constructor with all the fancy stuff. + +$Method STRING .meth_opt(PRIV_CALL, PRIV_VCL, PRIV_TASK, + [STRING s], [BOOL b]) + +Test object method with all the fancy stuff. diff --git a/lib/libvmod_debug/vmod_debug_obj.c b/lib/libvmod_debug/vmod_debug_obj.c index fcf74a740..9038bcb81 100644 --- a/lib/libvmod_debug/vmod_debug_obj.c +++ b/lib/libvmod_debug/vmod_debug_obj.c @@ -152,3 +152,94 @@ xyzzy_obj_test_priv_top(VRT_CTX, (void)o; return (xyzzy_test_priv_top(ctx, priv, s)); } + +/* ---------------------------------------------------------------------------- + * obj_opt (optional arguments and privs) + */ +struct xyzzy_debug_obj_opt { + unsigned magic; +#define VMOD_DEBUG_OBJ_OPT_MAGIC 0xccbd9b78 + char *name; + struct xyzzy_obj_opt_meth_opt_arg args; + void *freeptr; +}; + +VCL_VOID v_matchproto_() +xyzzy_obj_opt__init(VRT_CTX, + struct xyzzy_debug_obj_opt **op, const char *vcl_name, + struct xyzzy_obj_opt__init_arg *args) +{ + struct xyzzy_debug_obj_opt *o; + + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + AN(args); + + AN(args->arg1); // priv_call + AN(args->arg2); // priv_vcl + AN(args->arg3); // priv_task + assert(args->arg1 != args->arg2); + assert(args->arg2 != args->arg3); + + if (args->valid_s) + AN(args->s); + + AN(op); + AZ(*op); + ALLOC_OBJ(o, VMOD_DEBUG_OBJ_OPT_MAGIC); + AN(o); + *op = o; + REPLACE(o->name, vcl_name); + memcpy(&o->args, args, sizeof o->args); + if (args->valid_s) { + REPLACE(o->freeptr, args->s); + o->args.s = o->freeptr; + } +} + +VCL_VOID v_matchproto_() +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 */ + + TAKE_OBJ_NOTNULL(o, op, VMOD_DEBUG_OBJ_OPT_MAGIC); + + REPLACE(o->name, NULL); + if (o->freeptr) { + AN(o->args.valid_s); + REPLACE(o->freeptr, NULL); + } + FREE_OBJ(o); + AZ(o); +} + +VCL_STRING v_matchproto_() +xyzzy_obj_opt_meth_opt(VRT_CTX, + struct xyzzy_debug_obj_opt *o, + struct xyzzy_obj_opt_meth_opt_arg *args) +{ + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + CHECK_OBJ_NOTNULL(o, VMOD_DEBUG_OBJ_OPT_MAGIC); + + AN(args); + AN(args->arg1); // priv_call + AN(args->arg2); // priv_vcl + AN(args->arg3); // priv_task + assert(args->arg1 != args->arg2); + assert(args->arg2 != args->arg3); + + return (VRT_CollectString(ctx, + "obj ", o->name, + " obj_s ", (o->args.valid_s ? o->args.s : "*undef*"), + " obj_b ", (o->args.valid_b + ? (o->args.b ? "true" : "false" ) + : "*undef*"), + " met_s ", (args->valid_s ? args->s : "*undef*"), + " met_b ", (args->valid_b + ? (args->b ? "true" : "false" ) + : "*undef*"), + vrt_magic_string_end)); +} From dridi.boukelmoune at gmail.com Tue Feb 5 16:30:16 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 5 Feb 2019 16:30:16 +0000 (UTC) Subject: [6.0] 16033c289 Allow BOOL [!=]= BOOL comparisons Message-ID: <20190205163016.8D069BEC43@lists.varnish-cache.org> commit 16033c289e47507870ee48cf9935f9f22aa10230 Author: Poul-Henning Kamp Date: Mon Oct 29 11:59:44 2018 +0000 Allow BOOL [!=]= BOOL comparisons Fixes: #2809 diff --git a/lib/libvcc/vcc_expr.c b/lib/libvcc/vcc_expr.c index 1f0699e19..780befa0c 100644 --- a/lib/libvcc/vcc_expr.c +++ b/lib/libvcc/vcc_expr.c @@ -1111,6 +1111,8 @@ static const struct cmps vcc_cmps[] = { IDENT_REL(SUB), IDENT_REL(INSTANCE), + {BOOL, T_EQ, cmp_simple, "((!(\v1)) == (!(\v2)))" }, + {BOOL, T_NEQ, cmp_simple, "((!(\v1)) != (!(\v2)))" }, {IP, T_EQ, cmp_simple, "!VRT_ipcmp(\v1, \v2)" }, {IP, T_NEQ, cmp_simple, "VRT_ipcmp(\v1, \v2)" }, @@ -1144,9 +1146,6 @@ vcc_expr_cmp(struct vcc *tl, struct expr **e, vcc_type_t fmt) ERRCHK(tl); tk = tl->t; - if ((*e)->fmt == BOOL) - return; - for (cp = vcc_cmps; cp->fmt != VOID; cp++) { if ((*e)->fmt == cp->fmt && tl->t->tok == cp->token) { AN(cp->func); From dridi.boukelmoune at gmail.com Tue Feb 5 16:30:16 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 5 Feb 2019 16:30:16 +0000 (UTC) Subject: [6.0] d4ff5c553 improve busyobj panic Message-ID: <20190205163016.AB83BBEC47@lists.varnish-cache.org> commit d4ff5c553a5fbf0dd816969c80e04a9e0bbd3289 Author: Nils Goroll Date: Tue Nov 13 17:43:41 2018 +0100 improve busyobj panic For backend requests, we do not have the thread local storage of the client thread available, so trq.req will normally be (nil). Dump the busyobj back pointers to req/sess/wrk to maximize the usefulness of panics. Also reorder the panic by struct busyobj and add some more members which may or may not be useful (but when we find out, it is likely too late). Also move the vmod list dump to the top level. Noticed when trying to understand if #2667 was also a stack overflow in the context of #2817 Conflicts: bin/varnishd/cache/cache_panic.c diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index 8282ed814..d75e0b23f 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -61,6 +61,7 @@ static struct vsb pan_vsb_storage, *pan_vsb; static pthread_mutex_t panicstr_mtx; static void pan_sess(struct vsb *, const struct sess *); +static void pan_req(struct vsb *, const struct req *); /*--------------------------------------------------------------------*/ @@ -400,8 +401,37 @@ pan_busyobj(struct vsb *vsb, const struct busyobj *bo) return; VSB_indent(vsb, 2); PAN_CheckMagic(vsb, bo, BUSYOBJ_MAGIC); + VSB_printf(vsb, "end = %p,\n", bo->end); + VSB_printf(vsb, "retries = %d,\n", bo->retries); + + if (bo->req != NULL) + pan_req(vsb, bo->req); + if (bo->sp != NULL) + pan_sess(vsb, bo->sp); + if (bo->wrk != NULL) + pan_wrk(vsb, bo->wrk); + + if (bo->vfc != NULL) + pan_vfp(vsb, bo->vfc); + pan_ws(vsb, bo->ws); - VSB_printf(vsb, "retries = %d, ", bo->retries); + VSB_printf(vsb, "ws_bo = %p,\n", (void *)bo->ws_bo); + + // bereq0 left out + if (bo->bereq != NULL && bo->bereq->ws != NULL) + pan_http(vsb, "bereq", bo->bereq); + if (bo->beresp != NULL && bo->beresp->ws != NULL) + pan_http(vsb, "beresp", bo->beresp); + if (bo->stale_oc) + pan_objcore(vsb, "stale_oc", bo->stale_oc); + if (bo->fetch_objcore) + pan_objcore(vsb, "fetch", bo->fetch_objcore); + + if (VALID_OBJ(bo->htc, HTTP_CONN_MAGIC)) + pan_htc(vsb, bo->htc); + + // fetch_task left out + VSB_printf(vsb, "flags = {"); p = ""; /*lint -save -esym(438,p) -e539 */ @@ -411,27 +441,14 @@ pan_busyobj(struct vsb *vsb, const struct busyobj *bo) /*lint -restore */ VSB_printf(vsb, "},\n"); - if (VALID_OBJ(bo->htc, HTTP_CONN_MAGIC)) - pan_htc(vsb, bo->htc); - - if (bo->vfc) - pan_vfp(vsb, bo->vfc); + // timeouts/timers/acct/storage left out VDI_Panic(bo->director_req, vsb, "director_req"); if (bo->director_resp == bo->director_req) VSB_printf(vsb, "director_resp = director_req,\n"); else VDI_Panic(bo->director_resp, vsb, "director_resp"); - if (bo->bereq != NULL && bo->bereq->ws != NULL) - pan_http(vsb, "bereq", bo->bereq); - if (bo->beresp != NULL && bo->beresp->ws != NULL) - pan_http(vsb, "beresp", bo->beresp); - if (bo->fetch_objcore) - pan_objcore(vsb, "fetch", bo->fetch_objcore); - if (bo->stale_oc) - pan_objcore(vsb, "ims", bo->stale_oc); VCL_Panic(vsb, bo->vcl); - VMOD_Panic(vsb); VSB_indent(vsb, -2); VSB_printf(vsb, "},\n"); } @@ -496,7 +513,6 @@ pan_req(struct vsb *vsb, const struct req *req) pan_http(vsb, "resp", req->resp); VCL_Panic(vsb, req->vcl); - VMOD_Panic(vsb); if (req->body_oc != NULL) pan_objcore(vsb, "BODY", req->body_oc); @@ -684,6 +700,7 @@ pan_ic(const char *func, const char *file, int line, const char *cond, pan_busyobj(pan_vsb, bo); if (bo != NULL) VSL_Flush(bo->vsl, 0); + VMOD_Panic(pan_vsb); } else { VSB_printf(pan_vsb, "Feature short panic supressed details.\n"); From dridi.boukelmoune at gmail.com Tue Feb 5 16:30:16 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 5 Feb 2019 16:30:16 +0000 (UTC) Subject: [6.0] 33fcdd966 Add missing include Message-ID: <20190205163016.DA63CBEC4C@lists.varnish-cache.org> commit 33fcdd966aa11ea4f933b9415141e19048459790 Author: Federico G. Schwindt Date: Wed Nov 14 06:55:09 2018 +0900 Add missing include diff --git a/bin/varnishadm/varnishadm.c b/bin/varnishadm/varnishadm.c index 69f319509..750f5ddf7 100644 --- a/bin/varnishadm/varnishadm.c +++ b/bin/varnishadm/varnishadm.c @@ -53,6 +53,7 @@ #include #include #include +#include #include #include #include From dridi.boukelmoune at gmail.com Tue Feb 5 16:30:16 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 5 Feb 2019 16:30:16 +0000 (UTC) Subject: [6.0] 63ae1b0bd Make FlexeLint a little bit happier Message-ID: <20190205163016.F236EBEC4F@lists.varnish-cache.org> commit 63ae1b0bde381184a20078b032f9cfdcb8964e5e Author: Poul-Henning Kamp Date: Wed Nov 14 08:35:15 2018 +0000 Make FlexeLint a little bit happier diff --git a/lib/libvmod_debug/vmod_debug_obj.c b/lib/libvmod_debug/vmod_debug_obj.c index 9038bcb81..3ecf33d0c 100644 --- a/lib/libvmod_debug/vmod_debug_obj.c +++ b/lib/libvmod_debug/vmod_debug_obj.c @@ -183,6 +183,9 @@ xyzzy_obj_opt__init(VRT_CTX, if (args->valid_s) AN(args->s); + if (args->valid_b) + AN(args->b); + AN(op); AZ(*op); ALLOC_OBJ(o, VMOD_DEBUG_OBJ_OPT_MAGIC); From phk at FreeBSD.org Tue Feb 5 18:08:09 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 5 Feb 2019 18:08:09 +0000 (UTC) Subject: [master] 9b39b5bfa Properly prefix the arg structures. Message-ID: <20190205180809.6704D66F2@lists.varnish-cache.org> commit 9b39b5bfa753efa06d8034898652cef6a817c80e Author: Poul-Henning Kamp Date: Tue Feb 5 18:06:35 2019 +0000 Properly prefix the arg structures. Spotted by: Nils diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py index e31da1f7b..5a80fdaac 100755 --- a/lib/libvcc/vmodtool.py +++ b/lib/libvcc/vmodtool.py @@ -478,7 +478,8 @@ class ProtoType(object): ll.append('%s.%s' % (self.st.vcc.csn, cfunc)) if self.argstruct: # We cannot use VARGS() here, we are after the #undef - ll.append('struct arg_%s' % self.cname(True)) + ll.append('struct arg_%s%s_%s' % + (self.st.vcc.sympfx, self.st.vcc.modname, self.cname(False))) else: ll.append("") for i in self.args: @@ -950,6 +951,17 @@ class vcc(object): fo.write(AMBOILERPLATE.replace("XXX", self.modname)) fo.close() + def mkdefs(self, fo): + fo.write('#define VPFX(a) %s##a\n' % self.sympfx) + fo.write('#define VARGS(a) arg_%s%s_##a\n' % + (self.sympfx, self.modname)) + fo.write('#define VENUM(a) enum_%s%s_##a\n' % + (self.sympfx, self.modname)) + fo.write('//lint -esym(755, VPFX)\n') + fo.write('//lint -esym(755, VARGS)\n') + fo.write('//lint -esym(755, VENUM)\n') + fo.write('\n') + def mkhfile(self): ''' Produce vcc_if.h file ''' fn = self.pfx + ".h" @@ -963,13 +975,7 @@ class vcc(object): fo.write("#endif\n") fo.write("\n") - fo.write('#define VPFX(a) %s##a\n' % self.sympfx) - fo.write('#define VARGS(a) arg_%s##a\n' % self.sympfx) - fo.write('#define VENUM(a) enum_%s##a\n' % self.sympfx) - fo.write('//lint -esym(755, VPFX)\n') - fo.write('//lint -esym(755, VARGS)\n') - fo.write('//lint -esym(755, VENUM)\n') - fo.write('\n') + self.mkdefs(fo); for j in sorted(self.enums): fo.write("extern VCL_ENUM VENUM(%s);\n" % j) @@ -1049,10 +1055,7 @@ class vcc(object): write_c_file_warning(fo) - fx.write('#define VPFX(a) %s##a\n' % self.sympfx) - fx.write('#define VARGS(a) arg_%s##a\n' % self.sympfx) - fx.write('#define VENUM(a) enum_%s##a\n' % self.sympfx) - fx.write('\n') + self.mkdefs(fx); fo.write('#include "config.h"\n') fo.write('#include \n') From phk at FreeBSD.org Tue Feb 5 19:01:08 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 5 Feb 2019 19:01:08 +0000 (UTC) Subject: [master] 0203b3d37 Flexelinting Message-ID: <20190205190109.03B127A4B@lists.varnish-cache.org> commit 0203b3d377f9ace1f735f47b299b07d7809eb320 Author: Poul-Henning Kamp Date: Tue Feb 5 19:00:02 2019 +0000 Flexelinting diff --git a/bin/varnishd/flint.lnt b/bin/varnishd/flint.lnt index 238dec743..42a40290f 100644 --- a/bin/varnishd/flint.lnt +++ b/bin/varnishd/flint.lnt @@ -70,10 +70,9 @@ ////////////// // Macros defined differently in each VMOD --esym(767, VPFX) // macro '___' was defined differently in another module --esym(767, VARGS) // macro '___' was defined differently in another module --esym(767, VENUM) // macro '___' was defined differently in another module --esym(14, enum_vmod*) // Symbol '___' previously defined (___) +// -esym(767, VPFX) // macro '___' was defined differently in another module +// -esym(767, VARGS) // macro '___' was defined differently in another module +// -esym(767, VENUM) // macro '___' was defined differently in another module ////////////// -efunc(1791, pdiff) // return last on line ////////////// diff --git a/flint.lnt b/flint.lnt index 1a0b88caf..6c98c5c94 100644 --- a/flint.lnt +++ b/flint.lnt @@ -91,9 +91,9 @@ /////////////////////////////////////////////////////////////////////// // Vmod/vmodtool.py --esym(14, vmod_enum_*) // Symbol '___' previously defined (___) --esym(759, vmod_enum_*) // header declaration for symbol '___' defined at (___) --esym(765, vmod_enum_*) // external '___' (___) could be made static +//-esym(14, vmod_enum_*) // Symbol '___' previously defined (___) +//-esym(759, vmod_enum_*) // header declaration for symbol '___' defined at (___) +//-esym(765, vmod_enum_*) // external '___' (___) could be made static /////////////////////////////////////////////////////////////////////// // diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py index 5a80fdaac..2a88c2ab4 100755 --- a/lib/libvcc/vmodtool.py +++ b/lib/libvcc/vmodtool.py @@ -957,7 +957,9 @@ class vcc(object): (self.sympfx, self.modname)) fo.write('#define VENUM(a) enum_%s%s_##a\n' % (self.sympfx, self.modname)) - fo.write('//lint -esym(755, VPFX)\n') + for a in ('VPFX', 'VARGS', 'VENUM'): + for b in (755, 767): + fo.write('//lint -esym(%d, %s)\n' % (b, a)) fo.write('//lint -esym(755, VARGS)\n') fo.write('//lint -esym(755, VENUM)\n') fo.write('\n') @@ -981,8 +983,12 @@ class vcc(object): fo.write("extern VCL_ENUM VENUM(%s);\n" % j) fo.write("\n") for j in sorted(self.enums): - fo.write("//lint -esym(759, enum_%s%s)\n" % (self.sympfx, j)) - fo.write("//lint -esym(765, enum_%s%s)\n" % (self.sympfx, j)) + fo.write("//lint -esym(14, enum_%s%s_%s)\n" % + (self.sympfx, self.modname, j)) + fo.write("//lint -esym(759, enum_%s%s_%s)\n" % + (self.sympfx, self.modname, j)) + fo.write("//lint -esym(765, enum_%s%s_%s)\n" % + (self.sympfx, self.modname, j)) fo.write("\n") for j in self.contents: From dridi.boukelmoune at gmail.com Wed Feb 6 08:40:12 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 6 Feb 2019 08:40:12 +0000 (UTC) Subject: [6.0] 767cb7a1c Try to straighten out resp.body processing. Message-ID: <20190206084012.87B409BDBB@lists.varnish-cache.org> commit 767cb7a1c3bed127138aebed1323b918af9f55e4 Author: Poul-Henning Kamp Date: Wed Nov 14 11:01:58 2018 +0000 Try to straighten out resp.body processing. Conflicts: bin/varnishd/cache/cache_req_fsm.c diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index b29f484e1..f81891207 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -350,70 +350,66 @@ cnt_transmit(struct worker *wrk, struct req *req) CHECK_OBJ_NOTNULL(req->transport, TRANSPORT_MAGIC); CHECK_OBJ_NOTNULL(req->objcore, OBJCORE_MAGIC); AZ(req->stale_oc); + AZ(req->res_mode); - /* Grab a ref to the bo if there is one */ + /* Grab a ref to the bo if there is one (=streaming) */ boc = HSH_RefBoc(req->objcore); - clval = http_GetContentLength(req->resp); + /* RFC 7230, 3.3.3 */ + status = http_GetStatus(req->resp); + head = !strcmp(req->http0->hd[HTTP_HDR_METHOD].b, "HEAD"); + err = 0; + if (boc != NULL) req->resp_len = clval; else req->resp_len = ObjGetLen(req->wrk, req->objcore); - req->res_mode = 0; - - /* RFC 7230, 3.3.3 */ - status = http_GetStatus(req->resp); - head = !strcmp(req->http0->hd[HTTP_HDR_METHOD].b, "HEAD"); - if (head) { - if (req->objcore->flags & OC_F_PASS) - sendbody = -1; - else - sendbody = 0; - } else if (status < 200 || status == 204 || status == 304) { - req->resp_len = -1; - sendbody = 0; - } else + if (head || status < 200 || status == 204 || status == 304) + sendbody = 0; /* rfc7230,l,1748,1752 */ + else sendbody = 1; - err = 0; - if (sendbody >= 0) { - if (!req->disable_esi && req->resp_len != 0 && - ObjHasAttr(wrk, req->objcore, OA_ESIDATA) && - VDP_push(req, &VDP_esi, NULL, 0) < 0) - err++; - - if (cache_param->http_gzip_support && - ObjCheckFlag(req->wrk, req->objcore, OF_GZIPED) && - !RFC2616_Req_Gzip(req->http) && - VDP_push(req, &VDP_gunzip, NULL, 1) < 0) - err++; - - if (cache_param->http_range_support && - http_IsStatus(req->resp, 200)) { - http_ForceHeader(req->resp, H_Accept_Ranges, "bytes"); - if (sendbody && http_GetHdr(req->http, H_Range, &r)) - VRG_dorange(req, r); - } - } + if (!req->disable_esi && req->resp_len != 0 && + ObjHasAttr(wrk, req->objcore, OA_ESIDATA) && + VDP_push(req, &VDP_esi, NULL, 0) < 0) + err++; - if (sendbody < 0 || head) { - /* Don't touch HEAD C-L */ - sendbody = 0; - } else if (clval >= 0 && clval == req->resp_len) { - /* Reuse C-L header */ - } else { - http_Unset(req->resp, H_Content_Length); - if (req->resp_len >= 0 && sendbody) - http_PrintfHeader(req->resp, - "Content-Length: %jd", req->resp_len); + if (cache_param->http_gzip_support && + ObjCheckFlag(req->wrk, req->objcore, OF_GZIPED) && + !RFC2616_Req_Gzip(req->http) && + VDP_push(req, &VDP_gunzip, NULL, 1) < 0) + err++; + + if (cache_param->http_range_support && status == 200) { + http_ForceHeader(req->resp, H_Accept_Ranges, "bytes"); + if (http_GetHdr(req->http, H_Range, &r)) + VRG_dorange(req, r); } - if (err == 0) - req->transport->deliver(req, boc, sendbody); - else { + if (err) { VSLb(req->vsl, SLT_Error, "Failure to push processors"); req->doclose = SC_OVERLOAD; + } else { + if (status < 200 || status == 204) { + // rfc7230,l,1691,1695 + http_Unset(req->resp, H_Content_Length); + } else if (status == 304) { + // rfc7230,l,1675,1677 + http_Unset(req->resp, H_Content_Length); + } else if (clval >= 0 && clval == req->resp_len) { + /* Reuse C-L header */ + } else if (head && req->objcore->flags & OC_F_PASS) { + /* Don't touch C-L header */ + } else { + http_Unset(req->resp, H_Content_Length); + if (req->resp_len >= 0) + http_PrintfHeader(req->resp, + "Content-Length: %jd", req->resp_len); + } + if (req->resp_len == 0) + sendbody = 0; + req->transport->deliver(req, boc, sendbody); } VSLb_ts_req(req, "Resp", W_TIM_real(wrk)); @@ -434,6 +430,7 @@ cnt_transmit(struct worker *wrk, struct req *req) (void)HSH_DerefObjCore(wrk, &req->objcore, HSH_RUSH_POLICY); http_Teardown(req->resp); + req->res_mode = 0; return (REQ_FSM_DONE); } diff --git a/bin/varnishtest/tests/b00065.vtc b/bin/varnishtest/tests/b00065.vtc index 5eb86d8d9..daf030659 100644 --- a/bin/varnishtest/tests/b00065.vtc +++ b/bin/varnishtest/tests/b00065.vtc @@ -1,20 +1,33 @@ -varnishtest "Test that C-L on HEAD request aren't nuked" +varnishtest "Check that HEAD+pass returns Content-Length if backend provides it" server s1 { + rxreq + expect req.method == "GET" + txresp -bodylen 5 rxreq expect req.method == "HEAD" - txresp -nolen -hdr "content-length: 17" + txresp -nolen -hdr "Content-Length: 6" } -start varnish v1 -vcl+backend { - sub vcl_backend_fetch { - set bereq.method = "HEAD"; + sub vcl_recv { + if (req.url == "/2") { + return (pass); + } + } + sub vcl_backend_response { + set beresp.do_stream = false; } } -start client c1 { - txreq -req HEAD -hdr "connection: close" - rxresphdrs - expect resp.http.content-length == 17 - expect_close + txreq -req HEAD + rxresp -no_obj + expect resp.http.content-length == 5 +} -run + +client c1 { + txreq -req HEAD -url /2 + rxresp -no_obj + expect resp.http.content-length == 6 } -run diff --git a/bin/varnishtest/tests/r00730.vtc b/bin/varnishtest/tests/r00730.vtc deleted file mode 100644 index e28c8c912..000000000 --- a/bin/varnishtest/tests/r00730.vtc +++ /dev/null @@ -1,31 +0,0 @@ -varnishtest "Check that HEAD returns Content-Length if backend provides it" - -server s1 { - rxreq - txresp -bodylen 5 - rxreq - txresp -nolen -hdr "Content-Length: 6" -} -start - -varnish v1 -vcl+backend { - sub vcl_recv { - if (req.url == "/2") { - return (pass); - } - } - sub vcl_backend_response { - set beresp.do_stream = false; - } -} -start - -client c1 { - txreq -req HEAD - rxresp -no_obj - expect resp.http.content-length == 5 -} -run - -client c1 { - txreq -req HEAD -url /2 - rxresp -no_obj - expect resp.http.content-length == 6 -} -run From dridi.boukelmoune at gmail.com Wed Feb 6 08:40:12 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 6 Feb 2019 08:40:12 +0000 (UTC) Subject: [6.0] 24a589604 Get the RFC comment right Message-ID: <20190206084012.9B9589BDBD@lists.varnish-cache.org> commit 24a5896047fc5345f21f4fa0f587283da4219d01 Author: Poul-Henning Kamp Date: Wed Nov 14 11:05:50 2018 +0000 Get the RFC comment right diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index f81891207..864a4eb26 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -365,10 +365,12 @@ cnt_transmit(struct worker *wrk, struct req *req) else req->resp_len = ObjGetLen(req->wrk, req->objcore); - if (head || status < 200 || status == 204 || status == 304) - sendbody = 0; /* rfc7230,l,1748,1752 */ - else + if (head || status < 200 || status == 204 || status == 304) { + // rfc7230,l,1748,1752 + sendbody = 0; + } else { sendbody = 1; + } if (!req->disable_esi && req->resp_len != 0 && ObjHasAttr(wrk, req->objcore, OA_ESIDATA) && From dridi.boukelmoune at gmail.com Wed Feb 6 08:40:12 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 6 Feb 2019 08:40:12 +0000 (UTC) Subject: [6.0] 78886a10a Revert "Make FlexeLint a little bit happier" Message-ID: <20190206084012.BBC5B9BDC2@lists.varnish-cache.org> commit 78886a10ab88ef7e5d62168fb000d6112ffa26f9 Author: Nils Goroll Date: Wed Nov 14 12:43:41 2018 +0100 Revert "Make FlexeLint a little bit happier" The fact that a boolean argument is present does not imply that it's true. This reverts commit 57cd74cf51b63a54df68600a573eb0e20e2a6c7a. I promise to look after this once I got my Flexelint config back, which, unfortunately, I lost during a reinstall. Yes, I do have a backup, but cannot access it easily at the moment. diff --git a/lib/libvmod_debug/vmod_debug_obj.c b/lib/libvmod_debug/vmod_debug_obj.c index 3ecf33d0c..9038bcb81 100644 --- a/lib/libvmod_debug/vmod_debug_obj.c +++ b/lib/libvmod_debug/vmod_debug_obj.c @@ -183,9 +183,6 @@ xyzzy_obj_opt__init(VRT_CTX, if (args->valid_s) AN(args->s); - if (args->valid_b) - AN(args->b); - AN(op); AZ(*op); ALLOC_OBJ(o, VMOD_DEBUG_OBJ_OPT_MAGIC); From dridi.boukelmoune at gmail.com Wed Feb 6 08:40:12 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 6 Feb 2019 08:40:12 +0000 (UTC) Subject: [6.0] 2d133bc7a work around older libedit which fails to append rl_completion_append_character Message-ID: <20190206084012.D5D509BDD2@lists.varnish-cache.org> commit 2d133bc7ab472881640623d8cc8fee6c43f98cb6 Author: Nils Goroll Date: Thu Nov 15 16:25:04 2018 +0100 work around older libedit which fails to append rl_completion_append_character I failed to find any issue in varnish and failed to find a workaround for the code, so change the test to add an additional space after the tab-completion. If anyone has a better solution, please go head. Otherwise I feel this is not worth any more time. The test change, though not being ideal, should not cause any harm at least. Closes #2833 diff --git a/bin/varnishtest/tests/u00011.vtc b/bin/varnishtest/tests/u00011.vtc index d6e8098dd..b53a9ba7b 100644 --- a/bin/varnishtest/tests/u00011.vtc +++ b/bin/varnishtest/tests/u00011.vtc @@ -26,7 +26,7 @@ process p1 -write "vcl.li\t\r" process p1 -expect-text 0 1 "active auto/warm" -process p1 -write "vcl.s\t\th\tvcl1\r" +process p1 -write "vcl.s\t\th\t vcl1\r" process p1 -expect-text 0 1 "backend s1" From dridi.boukelmoune at gmail.com Wed Feb 6 08:40:12 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 6 Feb 2019 08:40:12 +0000 (UTC) Subject: [6.0] 104679274 vtc: array not needed for token expansion Message-ID: <20190206084012.EEF1E9BDD9@lists.varnish-cache.org> commit 10467927428b0c913220e76ef0cbeec002a5d988 Author: Nils Goroll Date: Sat Nov 17 12:15:44 2018 +0100 vtc: array not needed for token expansion diff --git a/bin/varnishtest/vtc.c b/bin/varnishtest/vtc.c index 2b98596a8..9d4a899d2 100644 --- a/bin/varnishtest/vtc.c +++ b/bin/varnishtest/vtc.c @@ -302,7 +302,7 @@ parse_string(const char *spec, const struct cmds *cmd, void *priv, struct vtclog *vl) { char *token_s[MAX_TOKENS], *token_e[MAX_TOKENS]; - struct vsb *token_exp[MAX_TOKENS]; + struct vsb *token_exp; char *e, *p, *q, *f, *buf; int nest_brace; int tn; @@ -401,14 +401,13 @@ parse_string(const char *spec, const struct cmds *cmd, void *priv, assert(tn < MAX_TOKENS); token_s[tn] = NULL; for (tn = 0; token_s[tn] != NULL; tn++) { - token_exp[tn] = NULL; AN(token_e[tn]); /*lint !e771 */ *token_e[tn] = '\0'; /*lint !e771 */ if (NULL != strstr(token_s[tn], "${")) { - token_exp[tn] = macro_expand(vl, token_s[tn]); + token_exp = macro_expand(vl, token_s[tn]); if (vtc_error) return; - token_s[tn] = VSB_data(token_exp[tn]); + token_s[tn] = VSB_data(token_exp); token_e[tn] = strchr(token_s[tn], '\0'); } } From dridi.boukelmoune at gmail.com Wed Feb 6 08:40:13 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 6 Feb 2019 08:40:13 +0000 (UTC) Subject: [6.0] c1a72221c vtc: zero the token arrays for each command Message-ID: <20190206084013.144209BDE1@lists.varnish-cache.org> commit c1a72221cbc5d3e0a32385f8fa19dede6cc53fa4 Author: Nils Goroll Date: Sat Nov 17 12:17:18 2018 +0100 vtc: zero the token arrays for each command arguments could leak from one vtc command to the next where NULL arguments do not necessarily denote the end of arguments, eg. in varnish_expect diff --git a/bin/varnishtest/vtc.c b/bin/varnishtest/vtc.c index 9d4a899d2..c7350df0a 100644 --- a/bin/varnishtest/vtc.c +++ b/bin/varnishtest/vtc.c @@ -339,6 +339,8 @@ parse_string(const char *spec, const struct cmds *cmd, void *priv, vtc_log(vl, 2, "=== %.*s", (int)(q - p), p); /* First content on line, collect tokens */ + memset(token_s, 0, sizeof token_s); + memset(token_e, 0, sizeof token_e); tn = 0; f = p; while (p < e) { From dridi.boukelmoune at gmail.com Wed Feb 6 08:40:13 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 6 Feb 2019 08:40:13 +0000 (UTC) Subject: [6.0] 72f249e42 fix vcl temperature after failing warmup event Message-ID: <20190206084013.2FC249BDE6@lists.varnish-cache.org> commit 72f249e427a5e02e3750a95988ed8276211e31ae Author: Nils Goroll Date: Sat Nov 17 15:06:41 2018 +0100 fix vcl temperature after failing warmup event Fixes #2835 diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c index ae846e0a6..1d3583612 100644 --- a/bin/varnishd/cache/cache_vcl.c +++ b/bin/varnishd/cache/cache_vcl.c @@ -504,10 +504,12 @@ vcl_set_state(VRT_CTX, const char *state) else { vcl->temp = VCL_TEMP_WARM; i = vcl_send_event(ctx, VCL_EVENT_WARM); - if (i == 0) + if (i == 0) { vcl_BackendEvent(vcl, VCL_EVENT_WARM); - else - AZ(vcl->conf->event_vcl(ctx, VCL_EVENT_COLD)); + break; + } + AZ(vcl->conf->event_vcl(ctx, VCL_EVENT_COLD)); + vcl->temp = VCL_TEMP_COLD; } break; default: diff --git a/bin/varnishtest/tests/v00003.vtc b/bin/varnishtest/tests/v00003.vtc index ff218f28c..6236f28f1 100644 --- a/bin/varnishtest/tests/v00003.vtc +++ b/bin/varnishtest/tests/v00003.vtc @@ -88,6 +88,8 @@ varnish v1 -expect !VBE.vcl1.default.happy varnish v1 -cliok "param.set max_esi_depth 42" varnish v1 -clierr 300 "vcl.state vcl1 warm" +varnish v1 -cliexpect "available *cold/cold *[0-9]+ *vcl1\\s+active *warm/warm *[0-9]+ *vcl2" "vcl.list" + # A warm-up failure can also fail a child start varnish v1 -cliok stop varnish v1 -cliok "vcl.state vcl1 warm" From dridi.boukelmoune at gmail.com Wed Feb 6 08:40:13 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 6 Feb 2019 08:40:13 +0000 (UTC) Subject: [6.0] 0f8e21002 centralize vcl state symbols / strings in the manager Message-ID: <20190206084013.4CD269BE07@lists.varnish-cache.org> commit 0f8e21002c086a485dc978e7e8240940ab835388 Author: Nils Goroll Date: Wed Nov 14 18:37:27 2018 +0100 centralize vcl state symbols / strings in the manager The actual benefit of this will be in follow-up commits Conflicts: bin/varnishd/mgt/mgt_vcl.c diff --git a/bin/varnishd/mgt/mgt_vcl.c b/bin/varnishd/mgt/mgt_vcl.c index 8c05c5215..0cb29e44c 100644 --- a/bin/varnishd/mgt/mgt_vcl.c +++ b/bin/varnishd/mgt/mgt_vcl.c @@ -48,9 +48,10 @@ #include "vev.h" #include "vtim.h" -static const char * const VCL_STATE_COLD = "cold"; -static const char * const VCL_STATE_WARM = "warm"; -static const char * const VCL_STATE_AUTO = "auto"; +#define VCL_STATE(sym, str) \ + static const char * const VCL_STATE_ ## sym = str; +#include "tbl/vcl_states.h" + static const char * const VCL_STATE_LABEL = "label"; struct vclprog; @@ -106,6 +107,18 @@ static int mgt_vcl_setstate(struct cli *, struct vclprog *, const char *); /*--------------------------------------------------------------------*/ +static const char * +mcf_vcl_parse_state(const char *s) +{ + if (s == NULL || *s == '\0') + return (NULL); +#define VCL_STATE(sym, str) \ + if (!strcmp(s, VCL_STATE_ ## sym)) \ + return (VCL_STATE_ ## sym); +#include "tbl/vcl_states.h" + return (NULL); +} + static struct vclprog * mcf_vcl_byname(const char *name) { @@ -171,7 +184,7 @@ mcf_find_no_vcl(struct cli *cli, const char *name) static int mcf_is_label(const struct vclprog *vp) { - return (!strcmp(vp->state, VCL_STATE_LABEL)); + return (vp->state == VCL_STATE_LABEL); } /*--------------------------------------------------------------------*/ @@ -469,13 +482,10 @@ mgt_new_vcl(struct cli *cli, const char *vclname, const char *vclsrc, if (state == NULL) state = VCL_STATE_AUTO; - else if (!strcmp(state, VCL_STATE_AUTO)) - state = VCL_STATE_AUTO; - else if (!strcmp(state, VCL_STATE_COLD)) - state = VCL_STATE_COLD; - else if (!strcmp(state, VCL_STATE_WARM)) - state = VCL_STATE_WARM; - else { + else + state = mcf_vcl_parse_state(state); + + if (state == NULL) { VCLI_Out(cli, "State must be one of auto, cold or warm."); VCLI_SetResult(cli, CLIS_PARAM); return; @@ -507,7 +517,7 @@ mgt_new_vcl(struct cli *cli, const char *vclname, const char *vclsrc, } free(p); - if (vp->warm && !strcmp(vp->state, "auto")) + if (vp->warm && vp->state == VCL_STATE_AUTO) vp->go_cold = VTIM_mono(); } @@ -626,6 +636,7 @@ mcf_vcl_load(struct cli *cli, const char * const *av, void *priv) static void v_matchproto_(cli_func_t) mcf_vcl_state(struct cli *cli, const char * const *av, void *priv) { + const char *state; struct vclprog *vp; (void)priv; @@ -638,22 +649,30 @@ mcf_vcl_state(struct cli *cli, const char * const *av, void *priv) VCLI_SetResult(cli, CLIS_PARAM); return; } + + state = mcf_vcl_parse_state(av[3]); + if (state == NULL) { + VCLI_Out(cli, "State must be one of auto, cold or warm."); + VCLI_SetResult(cli, CLIS_PARAM); + return; + } + if (!VTAILQ_EMPTY(&vp->dto)) { - AN(strcmp(vp->state, "cold")); - if (!strcmp(av[3], "cold")) { + assert(vp->state != VCL_STATE_COLD); + if (state == VCL_STATE_COLD) { VCLI_Out(cli, "A labeled VCL cannot be set cold"); VCLI_SetResult(cli, CLIS_CANT); return; } } - if (!strcmp(vp->state, av[3])) + if (vp->state == state) return; - if (!strcmp(av[3], VCL_STATE_AUTO)) { + if (state == VCL_STATE_AUTO) { vp->state = VCL_STATE_AUTO; (void)mgt_vcl_setstate(cli, vp, VCL_STATE_AUTO); - } else if (!strcmp(av[3], VCL_STATE_COLD)) { + } else if (state == VCL_STATE_COLD) { if (vp == active_vcl) { VCLI_Out(cli, "Cannot set the active VCL cold."); VCLI_SetResult(cli, CLIS_CANT); @@ -661,7 +680,7 @@ mcf_vcl_state(struct cli *cli, const char * const *av, void *priv) } vp->state = VCL_STATE_AUTO; (void)mgt_vcl_setstate(cli, vp, VCL_STATE_COLD); - } else if (!strcmp(av[3], VCL_STATE_WARM)) { + } else if (state == VCL_STATE_WARM) { if (mgt_vcl_setstate(cli, vp, VCL_STATE_WARM) == 0) vp->state = VCL_STATE_WARM; } else { diff --git a/include/tbl/vcl_states.h b/include/tbl/vcl_states.h new file mode 100644 index 000000000..6fe74dad1 --- /dev/null +++ b/include/tbl/vcl_states.h @@ -0,0 +1,8 @@ +/*lint -save -e525 -e539 */ +VCL_STATE(COLD, "cold") +VCL_STATE(WARM, "warm") +VCL_STATE(AUTO, "auto") +#undef VCL_STATE +// LABEL is private to mgt_vcl.c + +/*lint -restore */ From dridi.boukelmoune at gmail.com Wed Feb 6 08:40:13 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 6 Feb 2019 08:40:13 +0000 (UTC) Subject: [6.0] 63ec3aec3 centralize updating the vcl->state in vcl_set_state Message-ID: <20190206084013.6D5919BE27@lists.varnish-cache.org> commit 63ec3aec31971c950a7a2d31dae83d258de4e156 Author: Nils Goroll Date: Sat Nov 17 14:13:51 2018 +0100 centralize updating the vcl->state in vcl_set_state Allow calling it for this purpose only (stop asserting if the temperature has not changed) diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c index 1d3583612..fd364dcc5 100644 --- a/bin/varnishd/cache/cache_vcl.c +++ b/bin/varnishd/cache/cache_vcl.c @@ -476,9 +476,9 @@ vcl_set_state(VRT_CTX, const char *state) switch (state[0]) { case '0': - assert(vcl->temp != VCL_TEMP_COLD); + if (vcl->temp == VCL_TEMP_COLD) + break; if (vcl->busy == 0 && VCL_WARM(vcl)) { - vcl->temp = VTAILQ_EMPTY(&vcl->ref_list) ? VCL_TEMP_COLD : VCL_TEMP_COOLING; AZ(vcl_send_event(ctx, VCL_EVENT_COLD)); @@ -492,7 +492,8 @@ vcl_set_state(VRT_CTX, const char *state) vcl->temp = VCL_TEMP_COOLING; break; case '1': - assert(vcl->temp != VCL_TEMP_WARM); + if (vcl->temp == VCL_TEMP_WARM) + break; /* The warm VCL hasn't seen a cold event yet */ if (vcl->temp == VCL_TEMP_BUSY) vcl->temp = VCL_TEMP_WARM; @@ -515,6 +516,8 @@ vcl_set_state(VRT_CTX, const char *state) default: WRONG("Wrong enum state"); } + if (i == 0 && state[1]) + bprintf(vcl->state, "%s", state + 1); AZ(errno=pthread_rwlock_unlock(&vcl->temp_rwl)); return (i); @@ -583,7 +586,6 @@ vcl_load(struct cli *cli, struct vrt_ctx *ctx, vcl_cancel_load(ctx, cli, name, "warmup"); return; } - bprintf(vcl->state, "%s", state + 1); VCLI_Out(cli, "Loaded \"%s\" as \"%s\"", fn , name); VTAILQ_INSERT_TAIL(&vcl_head, vcl, list); Lck_Lock(&vcl_mtx); @@ -736,9 +738,7 @@ vcl_cli_state(struct cli *cli, const char * const *av, void *priv) ctx = vcl_get_ctx(0, 1); ctx->vcl = vcl_find(av[2]); AN(ctx->vcl); // MGT ensures this - if (vcl_set_state(ctx, av[3]) == 0) { - bprintf(ctx->vcl->state, "%s", av[3] + 1); - } else { + if (vcl_set_state(ctx, av[3])) { AZ(VSB_finish(ctx->msg)); VCLI_SetResult(cli, CLIS_CANT); VCLI_Out(cli, "Failed ", ctx->vcl->loaded_name, From dridi.boukelmoune at gmail.com Wed Feb 6 08:40:13 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 6 Feb 2019 08:40:13 +0000 (UTC) Subject: [6.0] c8faf7ec8 forgotten file in dist Message-ID: <20190206084013.8AD399BE31@lists.varnish-cache.org> commit c8faf7ec8e451b90fef3cd0e8ac77ef6f4cab7e2 Author: Nils Goroll Date: Sat Nov 17 19:41:44 2018 +0100 forgotten file in dist diff --git a/include/Makefile.am b/include/Makefile.am index 01755e09d..8ac8c2086 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -32,6 +32,7 @@ nobase_pkginclude_HEADERS = \ tbl/symbol_kind.h \ tbl/vcc_types.h \ tbl/vcl_returns.h \ + tbl/vcl_states.h \ tbl/vhd_fsm.h \ tbl/vhd_fsm_funcs.h \ tbl/vhd_return.h \ From dridi.boukelmoune at gmail.com Wed Feb 6 08:40:13 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 6 Feb 2019 08:40:13 +0000 (UTC) Subject: [6.0] 63ecfe6ac Add error handling for STV_NewObject() in vrb_pull Message-ID: <20190206084013.ACFE89BE42@lists.varnish-cache.org> commit 63ecfe6ac4cc4554a2454dfa90a409377d8ec009 Author: Dag Haavi Finstad Date: Wed Nov 14 13:39:46 2018 +0100 Add error handling for STV_NewObject() in vrb_pull Fixes: #2831 diff --git a/bin/varnishd/cache/cache_req_body.c b/bin/varnishd/cache/cache_req_body.c index d170bbce6..40f698be3 100644 --- a/bin/varnishd/cache/cache_req_body.c +++ b/bin/varnishd/cache/cache_req_body.c @@ -73,7 +73,14 @@ vrb_pull(struct req *req, ssize_t maxsize, objiterate_f *func, void *priv) req->storage = NULL; - XXXAN(STV_NewObject(req->wrk, req->body_oc, stv, 8)); + if (STV_NewObject(req->wrk, req->body_oc, stv, 8) == 0) { + req->req_body_status = REQ_BODY_FAIL; + HSH_DerefBoc(req->wrk, req->body_oc); + AZ(HSH_DerefObjCore(req->wrk, &req->body_oc, 0)); + (void)VFP_Error(vfc, "Object allocation failed:" + " Ran out of space in %s", stv->vclname); + return (-1); + } vfc->oc = req->body_oc; diff --git a/bin/varnishtest/tests/r02831.vtc b/bin/varnishtest/tests/r02831.vtc new file mode 100644 index 000000000..0a7e85239 --- /dev/null +++ b/bin/varnishtest/tests/r02831.vtc @@ -0,0 +1,57 @@ +varnishtest "#2831: Out of storage in cache_req_body" + +server s1 { + rxreq + expect req.url == "/obj1" + txresp -bodylen 1048400 +} -start + +varnish v1 \ + -arg "-p nuke_limit=0" \ + -arg "-sTransient=default,1m" \ + -syntax 4.0 \ + -vcl+backend { + import std; + sub vcl_recv { + if (req.method == "POST") { + std.cache_req_body(1KB); + } + } + sub vcl_backend_response { + set beresp.do_stream = false; + set beresp.storage = storage.Transient; + # Unset Date header to not change the object sizes + unset beresp.http.Date; + } +} -start + +varnish v1 -cliok "param.set debug +syncvsl" + +delay .1 + +client c1 { + # Fill transient + txreq -url "/obj1" + rxresp + expect resp.status == 200 +} -run + +delay .1 + +varnish v1 -expect SM?.Transient.g_bytes > 1048400 +varnish v1 -expect SM?.Transient.g_space < 100 + +client c1 { + # No space for caching this req.body + txreq -req "POST" -body "foobar" + delay 1 +} -run + +varnish v1 -expect SMA.Transient.c_fail == 1 + +client c1 { + # Check that Varnish is still alive + txreq -url "/obj1" + rxresp + expect resp.status == 200 +} -run From dridi.boukelmoune at gmail.com Wed Feb 6 08:40:13 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 6 Feb 2019 08:40:13 +0000 (UTC) Subject: [6.0] cab89fbd9 Fix test case: 'SMA'->'SM?' Message-ID: <20190206084013.CD15C9BE62@lists.varnish-cache.org> commit cab89fbd9878060647263de1c77d3b8d06892803 Author: Dag Haavi Finstad Date: Mon Nov 19 13:14:27 2018 +0100 Fix test case: 'SMA'->'SM?' diff --git a/bin/varnishtest/tests/r02831.vtc b/bin/varnishtest/tests/r02831.vtc index 0a7e85239..6f5e87ac5 100644 --- a/bin/varnishtest/tests/r02831.vtc +++ b/bin/varnishtest/tests/r02831.vtc @@ -47,7 +47,7 @@ client c1 { delay 1 } -run -varnish v1 -expect SMA.Transient.c_fail == 1 +varnish v1 -expect SM?.Transient.c_fail == 1 client c1 { # Check that Varnish is still alive From dridi.boukelmoune at gmail.com Wed Feb 6 08:40:13 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 6 Feb 2019 08:40:13 +0000 (UTC) Subject: [6.0] ff86df680 minor vtim-ification Message-ID: <20190206084013.EB7019BE71@lists.varnish-cache.org> commit ff86df6808dbca2c449fdcdf88c5d1b838814e99 Author: Nils Goroll Date: Mon Nov 19 14:28:14 2018 +0100 minor vtim-ification diff --git a/lib/libvarnish/vnum.c b/lib/libvarnish/vnum.c index 6caf931a1..b619199c6 100644 --- a/lib/libvarnish/vnum.c +++ b/lib/libvarnish/vnum.c @@ -110,11 +110,12 @@ VNUM(const char *p) /**********************************************************************/ -double +vtim_dur VNUM_duration(const char *p) { const char *t; - double r, sc = 1.0; + vtim_dur r; + double sc = 1.0; if (p == NULL) return (nan("")); From dridi.boukelmoune at gmail.com Wed Feb 6 08:40:14 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 6 Feb 2019 08:40:14 +0000 (UTC) Subject: [6.0] 033dcd798 Clarify reasoning with comment Message-ID: <20190206084014.12E879BE7C@lists.varnish-cache.org> commit 033dcd798045683c97716e289547155caa9e45f7 Author: Poul-Henning Kamp Date: Mon Nov 19 11:44:12 2018 +0000 Clarify reasoning with comment diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 864a4eb26..0ca6714c1 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -367,7 +367,7 @@ cnt_transmit(struct worker *wrk, struct req *req) if (head || status < 200 || status == 204 || status == 304) { // rfc7230,l,1748,1752 - sendbody = 0; + sendbody = 0; } else { sendbody = 1; } @@ -402,7 +402,14 @@ cnt_transmit(struct worker *wrk, struct req *req) } else if (clval >= 0 && clval == req->resp_len) { /* Reuse C-L header */ } else if (head && req->objcore->flags & OC_F_PASS) { - /* Don't touch C-L header */ + /* + * Don't touch C-L header (debatable) + * + * The only way to do it correctly would be to GET + * to the backend, and discard the body once the + * filters have had a chance to chew on it, but that + * would negate the "pass for huge objects" use case. + */ } else { http_Unset(req->resp, H_Content_Length); if (req->resp_len >= 0) From phk at FreeBSD.org Wed Feb 6 08:52:08 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 6 Feb 2019 08:52:08 +0000 (UTC) Subject: [master] 32d2c8657 Park issue #2332 in a XXX comment, pending API renovation. Message-ID: <20190206085208.4D0E3A04A1@lists.varnish-cache.org> commit 32d2c86570cbf3bcb8a14c8c12b88d853e54e8cb Author: Poul-Henning Kamp Date: Wed Feb 6 08:51:21 2019 +0000 Park issue #2332 in a XXX comment, pending API renovation. diff --git a/bin/varnishd/http1/cache_http1_fetch.c b/bin/varnishd/http1/cache_http1_fetch.c index c5ccee3b0..f1b0ac3cb 100644 --- a/bin/varnishd/http1/cache_http1_fetch.c +++ b/bin/varnishd/http1/cache_http1_fetch.c @@ -111,6 +111,15 @@ V1F_SendReq(struct worker *wrk, struct busyobj *bo, uint64_t *ctr_hdrbytes, i = VRB_Iterate(bo->req, vbf_iter_req_body, bo); if (bo->req->req_body_status == REQ_BODY_FAIL) { + /* + * XXX: (#2332) We should test to see if the backend + * XXX: sent us some headers explaining why. + * XXX: This is hard because of the mistaken API split + * XXX: between cache_backend.c and V1F, and therefore + * XXX: Parked in this comment, pending renovation of + * XXX: the VDI/backend-protocol API to allow non-H1 + * XXX: backends. + */ assert(i < 0); VSLb(bo->vsl, SLT_FetchError, "req.body read error: %d (%s)", From dridi.boukelmoune at gmail.com Wed Feb 6 10:11:09 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 6 Feb 2019 10:11:09 +0000 (UTC) Subject: [6.0] 02052778b Split INIT/FINI into separate VDP methods Message-ID: <20190206101109.45FE6A214D@lists.varnish-cache.org> commit 02052778b8f87c2c4c2064f5b4b7f387491cee72 Author: Poul-Henning Kamp Date: Wed Oct 10 09:01:11 2018 +0000 Split INIT/FINI into separate VDP methods diff --git a/bin/varnishd/cache/cache_deliver_proc.c b/bin/varnishd/cache/cache_deliver_proc.c index e3cdcee5c..6d603ad77 100644 --- a/bin/varnishd/cache/cache_deliver_proc.c +++ b/bin/varnishd/cache/cache_deliver_proc.c @@ -66,7 +66,7 @@ VDP_bytes(struct req *req, enum vdp_action act, const void *ptr, ssize_t len) assert(act > VDP_NULL || len > 0); /* Call the present layer, while pointing to the next layer down */ - retval = vdpe->vdp->func(req, act, &vdpe->priv, ptr, len); + retval = vdpe->vdp->bytes(req, act, &vdpe->priv, ptr, len); if (retval && (vdc->retval == 0 || retval < vdc->retval)) vdc->retval = retval; /* Latch error value */ vdc->nxt = vdpe; @@ -83,7 +83,7 @@ VDP_push(struct req *req, const struct vdp *vdp, void *priv, int bottom) vdc = req->vdc; AN(vdp); AN(vdp->name); - AN(vdp->func); + AN(vdp->bytes); if (vdc->retval) return (vdc->retval); @@ -107,7 +107,8 @@ VDP_push(struct req *req, const struct vdp *vdp, void *priv, int bottom) vdc->nxt = VTAILQ_FIRST(&vdc->vdp); AZ(vdc->retval); - vdc->retval = vdpe->vdp->func(req, VDP_INIT, &vdpe->priv, NULL, 0); + if (vdpe->vdp->init != NULL) + vdc->retval = vdpe->vdp->init(req, &vdpe->priv); return (vdc->retval); } @@ -126,8 +127,8 @@ VDP_close(struct req *req) if (vdpe != NULL) { CHECK_OBJ_NOTNULL(vdpe, VDP_ENTRY_MAGIC); VTAILQ_REMOVE(&vdc->vdp, vdpe, list); - AZ(vdpe->vdp->func(req, VDP_FINI, &vdpe->priv, - NULL, 0)); + if (vdpe->vdp->fini != NULL) + AZ(vdpe->vdp->fini(req, &vdpe->priv)); AZ(vdpe->priv); } vdc->nxt = VTAILQ_FIRST(&vdc->vdp); diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index 1ce7ea4ca..e73663896 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -251,8 +251,38 @@ ved_decode_len(struct req *req, const uint8_t **pp) /*--------------------------------------------------------------------- */ -static int v_matchproto_(vdp_bytes) -ved_vdp(struct req *req, enum vdp_action act, void **priv, +static int v_matchproto_(vdp_init_f) +ved_vdp_esi_init(struct req *req, void **priv) +{ + struct ecx *ecx; + + AZ(*priv); + ALLOC_OBJ(ecx, ECX_MAGIC); + AN(ecx); + assert(sizeof gzip_hdr == 10); + ecx->preq = req; + *priv = ecx; + RFC2616_Weaken_Etag(req->resp); + req->res_mode |= RES_ESI; + if (req->resp_len != 0) + req->resp_len = -1; + return (0); +} + +static int v_matchproto_(vdp_fini_f) +ved_vdp_esi_fini(struct req *req, void **priv) +{ + struct ecx *ecx; + + (void)req; + CAST_OBJ_NOTNULL(ecx, *priv, ECX_MAGIC); + FREE_OBJ(ecx); + *priv = NULL; + return (0); +} + +static int v_matchproto_(vdp_bytes_f) +ved_vdp_esi_bytes(struct req *req, enum vdp_action act, void **priv, const void *ptr, ssize_t len) { uint8_t *q, *r; @@ -263,25 +293,7 @@ ved_vdp(struct req *req, enum vdp_action act, void **priv, struct ecx *ecx, *pecx = NULL; int retval = 0; - if (act == VDP_INIT) { - AZ(*priv); - ALLOC_OBJ(ecx, ECX_MAGIC); - AN(ecx); - assert(sizeof gzip_hdr == 10); - ecx->preq = req; - *priv = ecx; - RFC2616_Weaken_Etag(req->resp); - req->res_mode |= RES_ESI; - if (req->resp_len != 0) - req->resp_len = -1; - return (0); - } CAST_OBJ_NOTNULL(ecx, *priv, ECX_MAGIC); - if (act == VDP_FINI) { - FREE_OBJ(ecx); - *priv = NULL; - return (0); - } pp = ptr; if (req->esi_level > 0) { @@ -435,7 +447,9 @@ ved_vdp(struct req *req, enum vdp_action act, void **priv, const struct vdp VDP_esi = { .name = "esi", - .func = ved_vdp, + .init = ved_vdp_esi_init, + .bytes = ved_vdp_esi_bytes, + .fini = ved_vdp_esi_fini, }; /* @@ -468,8 +482,16 @@ ved_bytes(struct req *req, struct req *preq, enum vdp_action act, * the stream with a bit more overhead. */ -static int v_matchproto_(vdp_bytes) -ved_pretend_gzip(struct req *req, enum vdp_action act, void **priv, +static int v_matchproto_(vdp_fini_f) +ved_pretend_gzip_fini(struct req *req, void **priv) +{ + (void)req; + *priv = NULL; + return (0); +} + +static int v_matchproto_(vdp_bytes_f) +ved_pretend_gzip_bytes(struct req *req, enum vdp_action act, void **priv, const void *pv, ssize_t l) { uint8_t buf1[5], buf2[5]; @@ -483,12 +505,6 @@ ved_pretend_gzip(struct req *req, enum vdp_action act, void **priv, preq = ecx->preq; (void)priv; - if (act == VDP_INIT) - return (0); - if (act == VDP_FINI) { - *priv = NULL; - return (0); - } if (l == 0) return (ved_bytes(req, ecx->preq, act, pv, l)); @@ -527,7 +543,8 @@ ved_pretend_gzip(struct req *req, enum vdp_action act, void **priv, static const struct vdp ved_vdp_pgz = { .name = "PGZ", - .func = ved_pretend_gzip, + .bytes = ved_pretend_gzip_bytes, + .fini = ved_pretend_gzip_fini, }; /*--------------------------------------------------------------------- @@ -769,26 +786,29 @@ ved_stripgzip(struct req *req, const struct boc *boc) /*--------------------------------------------------------------------*/ -static int v_matchproto_(vdp_bytes) +static int v_matchproto_(vdp_fini_f) +ved_vdp_fini(struct req *req, void **priv) +{ + (void)req; + *priv = NULL; + return (0); +} + +static int v_matchproto_(vdp_bytes_f) ved_vdp_bytes(struct req *req, enum vdp_action act, void **priv, const void *ptr, ssize_t len) { struct req *preq; CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - if (act == VDP_INIT) - return (0); - if (act == VDP_FINI) { - *priv = NULL; - return (0); - } CAST_OBJ_NOTNULL(preq, *priv, REQ_MAGIC); return (ved_bytes(req, preq, act, ptr, len)); } static const struct vdp ved_ved = { .name = "VED", - .func = ved_vdp_bytes, + .bytes = ved_vdp_bytes, + .fini = ved_vdp_fini, }; /*--------------------------------------------------------------------*/ diff --git a/bin/varnishd/cache/cache_filter.h b/bin/varnishd/cache/cache_filter.h index 0bf90732d..2c31a3c7b 100644 --- a/bin/varnishd/cache/cache_filter.h +++ b/bin/varnishd/cache/cache_filter.h @@ -92,18 +92,20 @@ enum vfp_status VFP_Error(struct vfp_ctx *, const char *fmt, ...) /* Deliver processors ------------------------------------------------*/ enum vdp_action { - VDP_INIT, /* Happens on VDP_push() */ - VDP_FINI, /* Happens on VDP_pop() */ VDP_NULL, /* Input buffer valid after call */ VDP_FLUSH, /* Input buffer will be invalidated */ }; -typedef int vdp_bytes(struct req *, enum vdp_action, void **priv, +typedef int vdp_init_f(struct req *, void **priv); +typedef int vdp_fini_f(struct req *, void **priv); +typedef int vdp_bytes_f(struct req *, enum vdp_action, void **priv, const void *ptr, ssize_t len); struct vdp { const char *name; - vdp_bytes *func; + vdp_init_f *init; + vdp_bytes_f *bytes; + vdp_fini_f *fini; }; struct vdp_entry { diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c index d5d256d56..bfe2f6279 100644 --- a/bin/varnishd/cache/cache_gzip.c +++ b/bin/varnishd/cache/cache_gzip.c @@ -284,62 +284,73 @@ VGZ_Gzip(struct vgz *vg, const void **pptr, ssize_t *plen, enum vgz_flag flags) * VDP for gunzip'ing */ -static int v_matchproto_(vdp_bytes) -vdp_gunzip(struct req *req, enum vdp_action act, void **priv, - const void *ptr, ssize_t len) +static int v_matchproto_(vdp_init_f) +vdp_gunzip_init(struct req *req, void **priv) { - enum vgzret_e vr; - ssize_t dl; - const void *dp; - struct worker *wrk; struct vgz *vg; const char *p; + ssize_t dl; uint64_t u; - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - wrk = req->wrk; - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - - if (act == VDP_INIT) { - vg = VGZ_NewGunzip(req->vsl, "U D -"); - AN(vg); - if (vgz_getmbuf(vg)) { - (void)VGZ_Destroy(&vg); - return (-1); - } + vg = VGZ_NewGunzip(req->vsl, "U D -"); + AN(vg); + if (vgz_getmbuf(vg)) { + (void)VGZ_Destroy(&vg); + return (-1); + } - req->res_mode |= RES_GUNZIP; - VGZ_Obuf(vg, vg->m_buf, vg->m_sz); - *priv = vg; + req->res_mode |= RES_GUNZIP; + VGZ_Obuf(vg, vg->m_buf, vg->m_sz); + *priv = vg; - http_Unset(req->resp, H_Content_Encoding); + http_Unset(req->resp, H_Content_Encoding); - req->resp_len = -1; + req->resp_len = -1; - p = ObjGetAttr(req->wrk, req->objcore, OA_GZIPBITS, &dl); - if (p != NULL && dl == 32) { - u = vbe64dec(p + 24); - /* - * If the size is non-zero AND we are the top VDP - * (ie: no ESI), we know what size the output will be. - */ - if (u != 0 && - VTAILQ_FIRST(&req->vdc->vdp)->vdp == &VDP_gunzip) - req->resp_len = u; - } - return (0); + p = ObjGetAttr(req->wrk, req->objcore, OA_GZIPBITS, &dl); + if (p != NULL && dl == 32) { + u = vbe64dec(p + 24); + /* + * If the size is non-zero AND we are the top VDP + * (ie: no ESI), we know what size the output will be. + */ + if (u != 0 && + VTAILQ_FIRST(&req->vdc->vdp)->vdp == &VDP_gunzip) + req->resp_len = u; } + return (0); +} + +static int v_matchproto_(vdp_fini_f) +vdp_gunzip_fini(struct req *req, void **priv) +{ + struct vgz *vg; + (void)req; CAST_OBJ_NOTNULL(vg, *priv, VGZ_MAGIC); AN(vg->m_buf); + (void)VGZ_Destroy(&vg); + *priv = NULL; + return (0); +} - if (act == VDP_FINI) { - /* NB: Gunzip'ing may or may not have completed successfully. */ - AZ(len); - (void)VGZ_Destroy(&vg); - *priv = NULL; - return (0); - } +static int v_matchproto_(vdp_bytes_f) +vdp_gunzip_bytes(struct req *req, enum vdp_action act, void **priv, + const void *ptr, ssize_t len) +{ + enum vgzret_e vr; + ssize_t dl; + const void *dp; + struct worker *wrk; + struct vgz *vg; + + CHECK_OBJ_NOTNULL(req, REQ_MAGIC); + wrk = req->wrk; + CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); + (void)act; + + CAST_OBJ_NOTNULL(vg, *priv, VGZ_MAGIC); + AN(vg->m_buf); if (len == 0) return (0); @@ -363,7 +374,9 @@ vdp_gunzip(struct req *req, enum vdp_action act, void **priv, const struct vdp VDP_gunzip = { .name = "gunzip", - .func = vdp_gunzip, + .init = vdp_gunzip_init, + .bytes = vdp_gunzip_bytes, + .fini = vdp_gunzip_fini, }; /*--------------------------------------------------------------------*/ diff --git a/bin/varnishd/cache/cache_range.c b/bin/varnishd/cache/cache_range.c index 373d1f676..c6cf1fd3c 100644 --- a/bin/varnishd/cache/cache_range.c +++ b/bin/varnishd/cache/cache_range.c @@ -44,7 +44,20 @@ struct vrg_priv { ssize_t range_off; }; -static int v_matchproto_(vdp_bytes) +static int v_matchproto_(vdp_fini_f) +vrg_range_fini(struct req *req, void **priv) +{ + struct vrg_priv *vrg_priv; + + CHECK_OBJ_NOTNULL(req, REQ_MAGIC); + CAST_OBJ_NOTNULL(vrg_priv, *priv, VRG_PRIV_MAGIC); + if (vrg_priv->range_off < vrg_priv->range_high) + Req_Fail(req, SC_RANGE_SHORT); + *priv = NULL; /* struct on ws, no need to free */ + return (0); +} + +static int v_matchproto_(vdp_bytes_f) vrg_range_bytes(struct req *req, enum vdp_action act, void **priv, const void *ptr, ssize_t len) { @@ -54,15 +67,7 @@ vrg_range_bytes(struct req *req, enum vdp_action act, void **priv, struct vrg_priv *vrg_priv; CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - if (act == VDP_INIT) - return (0); CAST_OBJ_NOTNULL(vrg_priv, *priv, VRG_PRIV_MAGIC); - if (act == VDP_FINI) { - if (vrg_priv->range_off < vrg_priv->range_high) - Req_Fail(req, SC_RANGE_SHORT); - *priv = NULL; /* struct on ws, no need to free */ - return (0); - } l = vrg_priv->range_low - vrg_priv->range_off; if (l > 0) { @@ -86,7 +91,8 @@ vrg_range_bytes(struct req *req, enum vdp_action act, void **priv, static const struct vdp vrg_vdp = { .name = "RNG", - .func = vrg_range_bytes, + .bytes = vrg_range_bytes, + .fini = vrg_range_fini, }; /*--------------------------------------------------------------------*/ diff --git a/bin/varnishd/http1/cache_http1_deliver.c b/bin/varnishd/http1/cache_http1_deliver.c index 88447b5a6..03c5f3ba8 100644 --- a/bin/varnishd/http1/cache_http1_deliver.c +++ b/bin/varnishd/http1/cache_http1_deliver.c @@ -35,7 +35,7 @@ /*--------------------------------------------------------------------*/ -static int v_matchproto_(vdp_bytes) +static int v_matchproto_(vdp_bytes_f) v1d_bytes(struct req *req, enum vdp_action act, void **priv, const void *ptr, ssize_t len) { @@ -43,8 +43,6 @@ v1d_bytes(struct req *req, enum vdp_action act, void **priv, CHECK_OBJ_NOTNULL(req, REQ_MAGIC); (void)priv; - if (act == VDP_INIT || act == VDP_FINI) - return (0); AZ(req->vdc->nxt); /* always at the bottom of the pile */ @@ -59,7 +57,7 @@ v1d_bytes(struct req *req, enum vdp_action act, void **priv, static const struct vdp v1d_vdp = { .name = "V1B", - .func = v1d_bytes, + .bytes = v1d_bytes, }; static void diff --git a/bin/varnishd/http2/cache_http2_deliver.c b/bin/varnishd/http2/cache_http2_deliver.c index 2ec67a60b..60d35bc40 100644 --- a/bin/varnishd/http2/cache_http2_deliver.c +++ b/bin/varnishd/http2/cache_http2_deliver.c @@ -72,7 +72,21 @@ V2D_Init(void) /**********************************************************************/ -static int v_matchproto_(vdp_bytes) +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); + 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); + return (0); +} + +static int v_matchproto_(vdp_bytes_f) h2_bytes(struct req *req, enum vdp_action act, void **priv, const void *ptr, ssize_t len) { @@ -80,17 +94,13 @@ h2_bytes(struct req *req, enum vdp_action act, void **priv, CHECK_OBJ_NOTNULL(req, REQ_MAGIC); CAST_OBJ_NOTNULL(r2, req->transport_priv, H2_REQ_MAGIC); + (void)act; (void)priv; - if (act == VDP_INIT) - return (0); - if ((r2->h2sess->error || r2->error) && act != VDP_FINI) + if ((r2->h2sess->error || r2->error)) return (-1); H2_Send_Get(req->wrk, r2->h2sess, r2); - H2_Send(req->wrk, r2, - H2_F_DATA, - act == VDP_FINI ? H2FF_DATA_END_STREAM : H2FF_NONE, - len, ptr); + H2_Send(req->wrk, r2, H2_F_DATA, H2FF_NONE, len, ptr); H2_Send_Rel(r2->h2sess, r2); req->acct.resp_bodybytes += len; return (0); @@ -98,7 +108,8 @@ h2_bytes(struct req *req, enum vdp_action act, void **priv, static const struct vdp h2_vdp = { .name = "H2B", - .func = h2_bytes, + .bytes = h2_bytes, + .fini = h2_fini, }; static inline size_t From dridi.boukelmoune at gmail.com Wed Feb 6 10:11:09 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 6 Feb 2019 10:11:09 +0000 (UTC) Subject: [6.0] 5882d268f Start registering VDPs Message-ID: <20190206101109.5AD56A2150@lists.varnish-cache.org> commit 5882d268fc481a7a697d6f219ce5feb299b25ab2 Author: Poul-Henning Kamp Date: Thu Oct 11 10:13:04 2018 +0000 Start registering VDPs Conflicts: bin/varnishd/cache/cache_vcl.c bin/varnishd/cache/cache_vcl.h bin/varnishd/cache/cache_vrt_filter.c It was possible to back-port this change without bringing beresp.filters and changing the VRT interface. So we get the benefits of this change and more that will follow and leave the possibility to minor-bump VRT to back-port beresp.filters in the future if that doesn't break. This clearly breaks $ABI strict VMODs, but that's part of the deal. diff --git a/bin/varnishd/cache/cache_filter.h b/bin/varnishd/cache/cache_filter.h index 2c31a3c7b..30af823e4 100644 --- a/bin/varnishd/cache/cache_filter.h +++ b/bin/varnishd/cache/cache_filter.h @@ -128,3 +128,5 @@ struct vdp_ctx { int VDP_bytes(struct req *, enum vdp_action act, const void *ptr, ssize_t len); int VDP_push(struct req *, const struct vdp *, void *priv, int bottom); +void VRT_AddVDP(VRT_CTX, const struct vdp *); +void VRT_RemoveVDP(VRT_CTX, const struct vdp *); diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c index fd364dcc5..d7a891802 100644 --- a/bin/varnishd/cache/cache_vcl.c +++ b/bin/varnishd/cache/cache_vcl.c @@ -406,6 +406,8 @@ VCL_Close(struct vcl **vclp) CHECK_OBJ_NOTNULL(*vclp, VCL_MAGIC); vcl = *vclp; *vclp = NULL; + assert(VTAILQ_EMPTY(&vcl->vfps)); + assert(VTAILQ_EMPTY(&vcl->vdps)); AZ(dlclose(vcl->dlh)); AZ(errno=pthread_rwlock_destroy(&vcl->temp_rwl)); FREE_OBJ(vcl); @@ -567,6 +569,8 @@ vcl_load(struct cli *cli, struct vrt_ctx *ctx, XXXAN(vcl->loaded_name); VTAILQ_INIT(&vcl->director_list); VTAILQ_INIT(&vcl->ref_list); + VTAILQ_INIT(&vcl->vfps); + VTAILQ_INIT(&vcl->vdps); vcl->temp = VCL_TEMP_INIT; diff --git a/bin/varnishd/cache/cache_vcl.h b/bin/varnishd/cache/cache_vcl.h index 87433afe3..c49f4817e 100644 --- a/bin/varnishd/cache/cache_vcl.h +++ b/bin/varnishd/cache/cache_vcl.h @@ -28,6 +28,11 @@ * */ +struct vfilter; + +VTAILQ_HEAD(vfilter_head, vfilter); + + struct vcl { unsigned magic; #define VCL_MAGIC 0x214188f2 @@ -45,6 +50,8 @@ struct vcl { int nrefs; struct vcl *label; int nlabels; + struct vfilter_head vfps; + struct vfilter_head vdps; }; struct vclref { From dridi.boukelmoune at gmail.com Wed Feb 6 10:11:09 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 6 Feb 2019 10:11:09 +0000 (UTC) Subject: [6.0] 44464a7fa Allow VDP->init to say "no thanks, but do go on delivering." Message-ID: <20190206101109.74E73A2153@lists.varnish-cache.org> commit 44464a7fa0ecbaa7495f772f94782394954e9215 Author: Poul-Henning Kamp Date: Mon Nov 19 12:21:26 2018 +0000 Allow VDP->init to say "no thanks, but do go on delivering." diff --git a/bin/varnishd/cache/cache_deliver_proc.c b/bin/varnishd/cache/cache_deliver_proc.c index 6d603ad77..f943d3f53 100644 --- a/bin/varnishd/cache/cache_deliver_proc.c +++ b/bin/varnishd/cache/cache_deliver_proc.c @@ -78,6 +78,7 @@ VDP_push(struct req *req, const struct vdp *vdp, void *priv, int bottom) { struct vdp_entry *vdpe; struct vdp_ctx *vdc; + uintptr_t sn; CHECK_OBJ_NOTNULL(req, REQ_MAGIC); vdc = req->vdc; @@ -91,6 +92,7 @@ VDP_push(struct req *req, const struct vdp *vdp, void *priv, int bottom) if (DO_DEBUG(DBG_PROCESSORS)) VSLb(req->vsl, SLT_Debug, "VDP_push(%s)", vdp->name); + sn = WS_Snapshot(req->ws); vdpe = WS_Alloc(req->ws, sizeof *vdpe); if (vdpe == NULL) { AZ(vdc->retval); @@ -109,6 +111,12 @@ VDP_push(struct req *req, const struct vdp *vdp, void *priv, int bottom) AZ(vdc->retval); if (vdpe->vdp->init != NULL) vdc->retval = vdpe->vdp->init(req, &vdpe->priv); + if (vdc->retval > 0) { + VTAILQ_REMOVE(&vdc->vdp, vdpe, list); + vdc->nxt = VTAILQ_FIRST(&vdc->vdp); + WS_Reset(req->ws, sn); + vdc->retval = 0; + } return (vdc->retval); } diff --git a/bin/varnishd/cache/cache_filter.h b/bin/varnishd/cache/cache_filter.h index 30af823e4..6c2c04b70 100644 --- a/bin/varnishd/cache/cache_filter.h +++ b/bin/varnishd/cache/cache_filter.h @@ -97,6 +97,13 @@ enum vdp_action { }; typedef int vdp_init_f(struct req *, void **priv); +/* + * Return value: + * negative: Error - abandon delivery + * zero: OK + * positive: Don't push this VDP anyway + */ + typedef int vdp_fini_f(struct req *, void **priv); typedef int vdp_bytes_f(struct req *, enum vdp_action, void **priv, const void *ptr, ssize_t len); From dridi.boukelmoune at gmail.com Wed Feb 6 10:11:09 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 6 Feb 2019 10:11:09 +0000 (UTC) Subject: [6.0] 55ef1bcdf Remove VDP_push's "bottom" argument, we always build VDP stacks from the top down. Message-ID: <20190206101109.8EEE2A2158@lists.varnish-cache.org> commit 55ef1bcdf4fd776230145f30a25e0f39c600aa3d Author: Poul-Henning Kamp Date: Fri Oct 12 11:45:57 2018 +0000 Remove VDP_push's "bottom" argument, we always build VDP stacks from the top down. Conflicts: bin/varnishd/cache/cache_req_fsm.c The conflict was just the result of cherry-picking changes out of order, nothing to be worried about. diff --git a/bin/varnishd/cache/cache_deliver_proc.c b/bin/varnishd/cache/cache_deliver_proc.c index f943d3f53..99b2c8318 100644 --- a/bin/varnishd/cache/cache_deliver_proc.c +++ b/bin/varnishd/cache/cache_deliver_proc.c @@ -74,7 +74,7 @@ VDP_bytes(struct req *req, enum vdp_action act, const void *ptr, ssize_t len) } int -VDP_push(struct req *req, const struct vdp *vdp, void *priv, int bottom) +VDP_Push(struct req *req, const struct vdp *vdp, void *priv) { struct vdp_entry *vdpe; struct vdp_ctx *vdc; @@ -102,10 +102,7 @@ VDP_push(struct req *req, const struct vdp *vdp, void *priv, int bottom) INIT_OBJ(vdpe, VDP_ENTRY_MAGIC); vdpe->vdp = vdp; vdpe->priv = priv; - if (bottom) - VTAILQ_INSERT_TAIL(&vdc->vdp, vdpe, list); - else - VTAILQ_INSERT_HEAD(&vdc->vdp, vdpe, list); + VTAILQ_INSERT_TAIL(&vdc->vdp, vdpe, list); vdc->nxt = VTAILQ_FIRST(&vdc->vdp); AZ(vdc->retval); diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index e73663896..bed475be0 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -837,9 +837,9 @@ ved_deliver(struct req *req, struct boc *boc, int wantbody) ved_stripgzip(req, boc); } else { if (ecx->isgzip && !i) - (void)VDP_push(req, &ved_vdp_pgz, ecx, 1); + (void)VDP_Push(req, &ved_vdp_pgz, ecx); else - (void)VDP_push(req, &ved_ved, ecx->preq, 1); + (void)VDP_Push(req, &ved_ved, ecx->preq); (void)VDP_DeliverObj(req); (void)VDP_bytes(req, VDP_FLUSH, NULL, 0); } diff --git a/bin/varnishd/cache/cache_filter.h b/bin/varnishd/cache/cache_filter.h index 6c2c04b70..778236994 100644 --- a/bin/varnishd/cache/cache_filter.h +++ b/bin/varnishd/cache/cache_filter.h @@ -134,6 +134,6 @@ struct vdp_ctx { }; int VDP_bytes(struct req *, enum vdp_action act, const void *ptr, ssize_t len); -int VDP_push(struct req *, const struct vdp *, void *priv, int bottom); +int VDP_Push(struct req *, const struct vdp *, void *priv); void VRT_AddVDP(VRT_CTX, const struct vdp *); void VRT_RemoveVDP(VRT_CTX, const struct vdp *); diff --git a/bin/varnishd/cache/cache_range.c b/bin/varnishd/cache/cache_range.c index c6cf1fd3c..8bcec96d4 100644 --- a/bin/varnishd/cache/cache_range.c +++ b/bin/varnishd/cache/cache_range.c @@ -181,7 +181,7 @@ vrg_dorange(struct req *req, const char *r) vrg_priv->range_off = 0; vrg_priv->range_low = low; vrg_priv->range_high = high + 1; - if (VDP_push(req, &vrg_vdp, vrg_priv, 1)) + if (VDP_Push(req, &vrg_vdp, vrg_priv)) return ("WS too small"); http_PutResponse(req->resp, "HTTP/1.1", 206, NULL); return (NULL); diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 0ca6714c1..cd01c2976 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -374,13 +374,13 @@ cnt_transmit(struct worker *wrk, struct req *req) if (!req->disable_esi && req->resp_len != 0 && ObjHasAttr(wrk, req->objcore, OA_ESIDATA) && - VDP_push(req, &VDP_esi, NULL, 0) < 0) + VDP_Push(req, &VDP_esi, NULL) < 0) err++; if (cache_param->http_gzip_support && ObjCheckFlag(req->wrk, req->objcore, OF_GZIPED) && !RFC2616_Req_Gzip(req->http) && - VDP_push(req, &VDP_gunzip, NULL, 1) < 0) + VDP_Push(req, &VDP_gunzip, NULL) < 0) err++; if (cache_param->http_range_support && status == 200) { diff --git a/bin/varnishd/http1/cache_http1_deliver.c b/bin/varnishd/http1/cache_http1_deliver.c index 03c5f3ba8..12bcaa545 100644 --- a/bin/varnishd/http1/cache_http1_deliver.c +++ b/bin/varnishd/http1/cache_http1_deliver.c @@ -127,7 +127,7 @@ V1D_Deliver(struct req *req, struct boc *boc, int sendbody) if (req->resp_len == 0) sendbody = 0; - if (sendbody && VDP_push(req, &v1d_vdp, NULL, 1)) { + if (sendbody && VDP_Push(req, &v1d_vdp, NULL)) { v1d_error(req, "workspace_thread overflow"); AZ(req->wrk->v1l); return; diff --git a/bin/varnishd/http2/cache_http2_deliver.c b/bin/varnishd/http2/cache_http2_deliver.c index 60d35bc40..c40124e40 100644 --- a/bin/varnishd/http2/cache_http2_deliver.c +++ b/bin/varnishd/http2/cache_http2_deliver.c @@ -306,7 +306,7 @@ h2_deliver(struct req *req, struct boc *boc, int sendbody) /* XXX someone into H2 please add appropriate error handling */ if (sendbody) { - if (!VDP_push(req, &h2_vdp, NULL, 1)) + if (!VDP_Push(req, &h2_vdp, NULL)) (void)VDP_DeliverObj(req); } From dridi.boukelmoune at gmail.com Wed Feb 6 10:11:09 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 6 Feb 2019 10:11:09 +0000 (UTC) Subject: [6.0] 8f56db74c Rearrange range code to ponder life in VDP->init() Message-ID: <20190206101109.A9B58A215C@lists.varnish-cache.org> commit 8f56db74c280633f53ce7bd572fed9790fbe769a Author: Poul-Henning Kamp Date: Mon Nov 19 20:57:47 2018 +0000 Rearrange range code to ponder life in VDP->init() diff --git a/bin/varnishd/cache/cache_range.c b/bin/varnishd/cache/cache_range.c index 8bcec96d4..37e4d84e7 100644 --- a/bin/varnishd/cache/cache_range.c +++ b/bin/varnishd/cache/cache_range.c @@ -89,16 +89,10 @@ vrg_range_bytes(struct req *req, enum vdp_action act, void **priv, vrg_priv->range_off >= vrg_priv->range_high ? 1 : 0); } -static const struct vdp vrg_vdp = { - .name = "RNG", - .bytes = vrg_range_bytes, - .fini = vrg_range_fini, -}; - /*--------------------------------------------------------------------*/ static const char * -vrg_dorange(struct req *req, const char *r) +vrg_dorange(struct req *req, const char *r, void **priv) { ssize_t low, high, has_low, has_high, t; struct vrg_priv *vrg_priv; @@ -181,35 +175,47 @@ vrg_dorange(struct req *req, const char *r) vrg_priv->range_off = 0; vrg_priv->range_low = low; vrg_priv->range_high = high + 1; - if (VDP_Push(req, &vrg_vdp, vrg_priv)) - return ("WS too small"); + *priv = vrg_priv; http_PutResponse(req->resp, "HTTP/1.1", 206, NULL); return (NULL); } +static int v_matchproto_(vdp_init_f) +vrg_range_init(struct req *req, void **priv) +{ + const char *r; + const char *err; + + assert(http_GetHdr(req->http, H_Range, &r)); + err = vrg_dorange(req, r, priv); + if (err == NULL) + return (*priv == NULL ? 1 : 0); + + VSLb(req->vsl, SLT_Debug, "RANGE_FAIL %s", err); + if (req->resp_len >= 0) + http_PrintfHeader(req->resp, + "Content-Range: bytes */%jd", + (intmax_t)req->resp_len); + http_PutResponse(req->resp, "HTTP/1.1", 416, NULL); + /* + * XXX: We ought to produce a body explaining things. + * XXX: That really calls for us to hit vcl_synth{} + */ + req->resp_len = 0; + return (1); +} + +static const struct vdp vrg_vdp = { + .name = "range", + .init = vrg_range_init, + .bytes = vrg_range_bytes, + .fini = vrg_range_fini, +}; + void VRG_dorange(struct req *req, const char *r) { - const char *err; - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - CHECK_OBJ_NOTNULL(req->objcore, OBJCORE_MAGIC); - assert(http_IsStatus(req->resp, 200)); - - /* We must snapshot the length if we're streaming from the backend */ - - err = vrg_dorange(req, r); - if (err != NULL) { - VSLb(req->vsl, SLT_Debug, "RANGE_FAIL %s", err); - if (req->resp_len >= 0) - http_PrintfHeader(req->resp, - "Content-Range: bytes */%jd", - (intmax_t)req->resp_len); - http_PutResponse(req->resp, "HTTP/1.1", 416, NULL); - /* - * XXX: We ought to produce a body explaining things. - * XXX: That really calls for us to hit vcl_synth{} - */ - req->resp_len = 0; - } + (void)r; + AZ(VDP_Push(req, &vrg_vdp, NULL)); } From dridi.boukelmoune at gmail.com Wed Feb 6 10:11:09 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 6 Feb 2019 10:11:09 +0000 (UTC) Subject: [6.0] ce2c70916 Use vsl_catchup instead of delay .1 Message-ID: <20190206101109.C2BBFA2161@lists.varnish-cache.org> commit ce2c70916db98b7691140a404fa93a12977cb00b Author: Poul-Henning Kamp Date: Mon Nov 19 21:20:00 2018 +0000 Use vsl_catchup instead of delay .1 diff --git a/bin/varnishtest/tests/c00034.vtc b/bin/varnishtest/tests/c00034.vtc index 1344fe2a6..3fbe5fefd 100644 --- a/bin/varnishtest/tests/c00034.vtc +++ b/bin/varnishtest/tests/c00034.vtc @@ -22,6 +22,8 @@ client c1 { varnish v1 -expect s_resp_bodybytes == 100 +varnish v1 -vsl_catchup + varnish v1 -cliok "param.set http_range_support on" client c1 { @@ -72,7 +74,8 @@ client c1 { } -run varnish v1 -expect s_resp_bodybytes == 100 -delay .1 + +varnish v1 -vsl_catchup client c1 { # Valid range requests @@ -122,6 +125,8 @@ client c1 { varnish v1 -expect s_resp_bodybytes == 501 +varnish v1 -vsl_catchup + # Test Range streaming with streaming objects with C-L server s1 { @@ -174,7 +179,7 @@ client c1 { expect_close } -run -delay .1 +varnish v1 -vsl_catchup client c1 { # Closed C-L because we cannot use C-L From dridi.boukelmoune at gmail.com Wed Feb 6 10:11:09 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 6 Feb 2019 10:11:09 +0000 (UTC) Subject: [6.0] 41c1eeb2a Don't reset the workspace on pointless VDP_Push(), things might still have been happening on the workspace (See: VRG) Message-ID: <20190206101109.DDBABA2166@lists.varnish-cache.org> commit 41c1eeb2a06283edf44487a79b887c5b1abc16fb Author: Poul-Henning Kamp Date: Mon Nov 19 21:26:48 2018 +0000 Don't reset the workspace on pointless VDP_Push(), things might still have been happening on the workspace (See: VRG) diff --git a/bin/varnishd/cache/cache_deliver_proc.c b/bin/varnishd/cache/cache_deliver_proc.c index 99b2c8318..fa3392f5f 100644 --- a/bin/varnishd/cache/cache_deliver_proc.c +++ b/bin/varnishd/cache/cache_deliver_proc.c @@ -78,7 +78,6 @@ VDP_Push(struct req *req, const struct vdp *vdp, void *priv) { struct vdp_entry *vdpe; struct vdp_ctx *vdc; - uintptr_t sn; CHECK_OBJ_NOTNULL(req, REQ_MAGIC); vdc = req->vdc; @@ -92,7 +91,6 @@ VDP_Push(struct req *req, const struct vdp *vdp, void *priv) if (DO_DEBUG(DBG_PROCESSORS)) VSLb(req->vsl, SLT_Debug, "VDP_push(%s)", vdp->name); - sn = WS_Snapshot(req->ws); vdpe = WS_Alloc(req->ws, sizeof *vdpe); if (vdpe == NULL) { AZ(vdc->retval); @@ -111,7 +109,6 @@ VDP_Push(struct req *req, const struct vdp *vdp, void *priv) if (vdc->retval > 0) { VTAILQ_REMOVE(&vdc->vdp, vdpe, list); vdc->nxt = VTAILQ_FIRST(&vdc->vdp); - WS_Reset(req->ws, sn); vdc->retval = 0; } return (vdc->retval); From dridi.boukelmoune at gmail.com Wed Feb 6 10:11:10 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 6 Feb 2019 10:11:10 +0000 (UTC) Subject: [6.0] 0d563d407 gc stray comment Message-ID: <20190206101110.02678A216A@lists.varnish-cache.org> commit 0d563d4076b2a35baffb273b06d37d0c0252696c Author: Nils Goroll Date: Wed Nov 21 19:12:47 2018 +0100 gc stray comment Ref 3c0b8768afda0cc657fb902d1d390bdd0e8b7ce5 diff --git a/bin/varnishd/cache/cache_tcp_pool.c b/bin/varnishd/cache/cache_tcp_pool.c index 5a04eb5aa..dbc12c685 100644 --- a/bin/varnishd/cache/cache_tcp_pool.c +++ b/bin/varnishd/cache/cache_tcp_pool.c @@ -413,7 +413,6 @@ VCP_Open(struct conn_pool *cp, double tmo, const void **privp, int *err) h = 0; - /* stats access unprotected */ switch (errno) { case EACCES: case EPERM: From dridi.boukelmoune at gmail.com Wed Feb 6 10:11:10 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 6 Feb 2019 10:11:10 +0000 (UTC) Subject: [6.0] 03a2102bf assert that -I file processing has finished and closed the fd Message-ID: <20190206101110.1B741A216F@lists.varnish-cache.org> commit 03a2102bf1237c11586fdf0ce82d5ba9d3c596e0 Author: Nils Goroll Date: Thu Nov 22 10:28:43 2018 +0100 assert that -I file processing has finished and closed the fd diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index 237fb0f7f..2e0ee14f5 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -870,6 +870,7 @@ main(int argc, char * const *argv) "VEV_Once() = %d", o); } } + assert(I_fd == -1); if (!d_flag && !mgt_has_vcl() && !novcl) MGT_Complain(C_ERR, "No VCL loaded yet"); From dridi.boukelmoune at gmail.com Wed Feb 6 10:11:10 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 6 Feb 2019 10:11:10 +0000 (UTC) Subject: [6.0] d94c7f8db fix insignificant off-by-one in child file descriptor close code Message-ID: <20190206101110.33A77A2175@lists.varnish-cache.org> commit d94c7f8db1b6ae5692acc52ddeeebf8b4dd876f9 Author: Nils Goroll Date: Thu Nov 22 13:21:24 2018 +0100 fix insignificant off-by-one in child file descriptor close code The name CLOSE_FD_UP_TO implies that the value is included. Also this is the semantics of MCH_TrackHighFd() and relevant for #define CLOSE_FD_UP_TO mgt_max_fd diff --git a/bin/varnishd/mgt/mgt_child.c b/bin/varnishd/mgt/mgt_child.c index 16050b33a..c5487d94e 100644 --- a/bin/varnishd/mgt/mgt_child.c +++ b/bin/varnishd/mgt/mgt_child.c @@ -344,7 +344,7 @@ mgt_launch_child(struct cli *cli) */ closelog(); - for (i = STDERR_FILENO + 1; i < CLOSE_FD_UP_TO; i++) { + for (i = STDERR_FILENO + 1; i <= CLOSE_FD_UP_TO; i++) { if (vbit_test(fd_map, i)) continue; if (close(i) == 0) From dridi.boukelmoune at gmail.com Wed Feb 6 10:11:10 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 6 Feb 2019 10:11:10 +0000 (UTC) Subject: [6.0] 8564c979f Gain more confidence that our file descriptor tracking works Message-ID: <20190206101110.4F68CA217A@lists.varnish-cache.org> commit 8564c979f2379e33ec94162f12046382dd544ccd Author: Nils Goroll Date: Thu Nov 22 13:14:19 2018 +0100 Gain more confidence that our file descriptor tracking works Side note #define CLOSE_FD_UP_TO mgt_max_fd exposes that we are currently missing to track some fds. diff --git a/bin/varnishd/mgt/mgt_child.c b/bin/varnishd/mgt/mgt_child.c index c5487d94e..3e1abc9f3 100644 --- a/bin/varnishd/mgt/mgt_child.c +++ b/bin/varnishd/mgt/mgt_child.c @@ -183,11 +183,15 @@ mch_cli_panic_clear(struct cli *cli, const char * const *av, void *priv) * This is likely to a bit on the low side, as libc and other libraries * has a tendency to cache file descriptors (syslog, resolver, etc.) * so we add a margin of 100 fds. + * + * for added safety, we check that we see no file descriptor open for + * another margin above the limit for which we close by design */ static int mgt_max_fd; #define CLOSE_FD_UP_TO (mgt_max_fd + 100) +#define CHECK_FD_UP_TO (CLOSE_FD_UP_TO + 100) void MCH_TrackHighFd(int fd) @@ -350,6 +354,10 @@ mgt_launch_child(struct cli *cli) if (close(i) == 0) VFIL_null_fd(i); } + for (i = CLOSE_FD_UP_TO + 1; i <= CHECK_FD_UP_TO; i++) { + assert(close(i) == -1); + assert(errno == EBADF); + } mgt_ProcTitle("Child"); From dridi.boukelmoune at gmail.com Wed Feb 6 10:11:10 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 6 Feb 2019 10:11:10 +0000 (UTC) Subject: [6.0] ca76ef579 fix the missing high fd tracking Message-ID: <20190206101110.68773A217E@lists.varnish-cache.org> commit ca76ef579f34394078ce281955b835958d3d8dfe Author: Nils Goroll Date: Thu Nov 22 13:44:50 2018 +0100 fix the missing high fd tracking diff --git a/bin/varnishd/mgt/mgt_child.c b/bin/varnishd/mgt/mgt_child.c index 3e1abc9f3..8e2494ac8 100644 --- a/bin/varnishd/mgt/mgt_child.c +++ b/bin/varnishd/mgt/mgt_child.c @@ -191,6 +191,8 @@ mch_cli_panic_clear(struct cli *cli, const char * const *av, void *priv) static int mgt_max_fd; #define CLOSE_FD_UP_TO (mgt_max_fd + 100) +// XXX should work now - engage? +//#define CLOSE_FD_UP_TO mgt_max_fd #define CHECK_FD_UP_TO (CLOSE_FD_UP_TO + 100) void @@ -215,6 +217,7 @@ MCH_Fd_Inherit(int fd, const char *what) { assert(fd >= 0); + MCH_TrackHighFd(fd); if (fd_map == NULL) fd_map = vbit_new(128); AN(fd_map); From dridi.boukelmoune at gmail.com Wed Feb 6 10:11:10 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 6 Feb 2019 10:11:10 +0000 (UTC) Subject: [6.0] 1524d95d2 Fix regression from 6bead571da6a2027a518af81e14d87a247f38156 Message-ID: <20190206101110.828FBA218A@lists.varnish-cache.org> commit 1524d95d2f4f8409d7b6507fb93f46b3b4ba46c6 Author: Nils Goroll Date: Thu Nov 22 17:22:19 2018 +0100 Fix regression from 6bead571da6a2027a518af81e14d87a247f38156 Seen once, and failed to reprocuce (yet), needs to be understood better from vmod_blobdigest tests/usage.vtc: **** v1 1.8 CLI RX|No panic to clear *** v1 1.8 debug|Info: manager stopping child *** v1 1.8 debug|Debug: Stopping Child **** v1 1.9 vsl| 0 CLI - EOF on CLI connection, worker stops *** v1 2.8 debug|Info: Child (174227) ended *** v1 2.8 debug|Info: Child (174227) said Child dies *** v1 2.8 debug|Debug: Child cleanup complete *** v1 2.8 debug|Assert error in MCH_TrackHighFd(), mgt/mgt_child.c line 203: *** v1 2.8 debug| Condition(fd > 0) not true. **** v1 2.9 STDOUT poll 0x10 ** v1 2.9 WAIT4 pid=174215 status=0x0086 (user 0.914949 sys 0.567445) * v1 2.9 Expected exit: 0x0 signal: 0 core: 0 ---- v1 2.9 Bad exit status: 0x0086 exit 0x0 signal 6 core 128 * top 2.9 failure during reset On the 6.0 branch the regression appeared in ca76ef579 instead. diff --git a/bin/varnishd/mgt/mgt_child.c b/bin/varnishd/mgt/mgt_child.c index 8e2494ac8..fdcdfd830 100644 --- a/bin/varnishd/mgt/mgt_child.c +++ b/bin/varnishd/mgt/mgt_child.c @@ -217,7 +217,9 @@ MCH_Fd_Inherit(int fd, const char *what) { assert(fd >= 0); - MCH_TrackHighFd(fd); + // XXX why? + if (fd > 0) + MCH_TrackHighFd(fd); if (fd_map == NULL) fd_map = vbit_new(128); AN(fd_map); From dridi.boukelmoune at gmail.com Wed Feb 6 10:11:10 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 6 Feb 2019 10:11:10 +0000 (UTC) Subject: [6.0] e6c5d636f More double to vtim_* conversions Message-ID: <20190206101110.9DD1DA219F@lists.varnish-cache.org> commit e6c5d636f4bc9a8bd901df0b06e85dacb8b2e44f Author: Dridi Boukelmoune Date: Sat Nov 24 01:07:09 2018 +0100 More double to vtim_* conversions This may break out of tree code not respecting include order of vdef.h first (or via cache/cache.h). It's trivial to fix and forces consumers to follow the tracks. Refs #2791 diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index d75e0b23f..ef6234374 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -35,9 +35,6 @@ #include #include -#include "vtim.h" -#include "vcs.h" - #include "cache_varnishd.h" #include "cache_transport.h" @@ -47,6 +44,8 @@ #include "storage/storage.h" #include "vcli_serve.h" +#include "vtim.h" +#include "vcs.h" /* * The panic string is constructed in memory, then copied to the diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c index fede8e0ae..b6faa8222 100644 --- a/bin/varnishd/cache/cache_session.c +++ b/bin/varnishd/cache/cache_session.c @@ -255,8 +255,8 @@ enum htc_status_e HTC_RxStuff(struct http_conn *htc, htc_complete_f *func, double *t1, double *t2, double ti, double tn, int maxbytes) { - double tmo; - double now; + vtim_dur tmo; + vtim_real now; enum htc_status_e hs; ssize_t z; @@ -381,7 +381,7 @@ SES_New(struct pool *pp) */ static void v_matchproto_(waiter_handle_f) -ses_handle(struct waited *wp, enum wait_event ev, double now) +ses_handle(struct waited *wp, enum wait_event ev, vtim_real now) { struct sess *sp; struct pool *pp; @@ -518,7 +518,7 @@ SES_Close(struct sess *sp, enum sess_close reason) */ void -SES_Delete(struct sess *sp, enum sess_close reason, double now) +SES_Delete(struct sess *sp, enum sess_close reason, vtim_real now) { CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); diff --git a/bin/varnishd/cache/cache_varnishd.h b/bin/varnishd/cache/cache_varnishd.h index 011ebafe7..365b821fc 100644 --- a/bin/varnishd/cache/cache_varnishd.h +++ b/bin/varnishd/cache/cache_varnishd.h @@ -75,8 +75,8 @@ struct http_conn { void *priv; /* Timeouts */ - double first_byte_timeout; - double between_bytes_timeout; + vtim_dur first_byte_timeout; + vtim_dur between_bytes_timeout; }; typedef enum htc_status_e htc_complete_f(struct http_conn *); diff --git a/bin/varnishtest/vtc_haproxy.c b/bin/varnishtest/vtc_haproxy.c index 157d0e67c..22f5eb2fe 100644 --- a/bin/varnishtest/vtc_haproxy.c +++ b/bin/varnishtest/vtc_haproxy.c @@ -106,7 +106,7 @@ struct haproxy_cli { size_t rxbuf_sz; char *rxbuf; - double timeout; + vtim_dur timeout; }; /********************************************************************** @@ -114,7 +114,7 @@ struct haproxy_cli { */ static int -haproxy_cli_tcp_connect(struct vtclog *vl, const char *addr, double tmo, +haproxy_cli_tcp_connect(struct vtclog *vl, const char *addr, vtim_dur tmo, const char **errp) { int fd; diff --git a/bin/varnishtest/vtc_logexp.c b/bin/varnishtest/vtc_logexp.c index 4735472e2..43e300acf 100644 --- a/bin/varnishtest/vtc_logexp.c +++ b/bin/varnishtest/vtc_logexp.c @@ -116,11 +116,12 @@ #include "vapi/vsm.h" #include "vapi/vsl.h" -#include "vtim.h" -#include "vre.h" #include "vtc.h" +#include "vtim.h" +#include "vre.h" + #define LE_ANY (-1) #define LE_LAST (-2) diff --git a/bin/varnishtest/vtc_syslog.c b/bin/varnishtest/vtc_syslog.c index f91014c9a..666b82d3c 100644 --- a/bin/varnishtest/vtc_syslog.c +++ b/bin/varnishtest/vtc_syslog.c @@ -37,13 +37,13 @@ #include #include +#include "vtc.h" + #include "vsa.h" #include "vss.h" #include "vtcp.h" #include "vre.h" -#include "vtc.h" - struct syslog_srv { unsigned magic; #define SYSLOG_SRV_MAGIC 0xbf28a692 @@ -63,7 +63,7 @@ struct syslog_srv { ssize_t rxbuf_left; size_t rxbuf_sz; char *rxbuf; - double timeout; + vtim_dur timeout; }; static pthread_mutex_t syslog_mtx; diff --git a/include/vrt.h b/include/vrt.h index 3db7c0438..53c4b773d 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -142,7 +142,7 @@ typedef const struct vmod_priv * VCL_BLOB; typedef const char * VCL_BODY; typedef unsigned VCL_BOOL; typedef int64_t VCL_BYTES; -typedef double VCL_DURATION; +typedef vtim_dur VCL_DURATION; typedef const char * VCL_ENUM; typedef const struct gethdr_s * VCL_HEADER; typedef struct http * VCL_HTTP; @@ -154,7 +154,7 @@ typedef double VCL_REAL; typedef const struct stevedore * VCL_STEVEDORE; typedef const struct strands * VCL_STRANDS; typedef const char * VCL_STRING; -typedef double VCL_TIME; +typedef vtim_real VCL_TIME; typedef struct vcl * VCL_VCL; typedef void VCL_VOID; @@ -197,7 +197,7 @@ struct vrt_ctx { struct http *http_bereq; struct http *http_beresp; - double now; + vtim_real now; /* * method specific argument: @@ -260,9 +260,9 @@ extern const void * const vrt_magic_string_unset; rigid char *port; \ rigid char *path; \ rigid char *hosthdr; \ - double connect_timeout; \ - double first_byte_timeout; \ - double between_bytes_timeout; \ + vtim_dur connect_timeout; \ + vtim_dur first_byte_timeout; \ + vtim_dur between_bytes_timeout; \ unsigned max_connections; \ unsigned proxy_header; @@ -291,8 +291,8 @@ struct vrt_backend { }; #define VRT_BACKEND_PROBE_FIELDS(rigid) \ - double timeout; \ - double interval; \ + vtim_dur timeout; \ + vtim_dur interval; \ unsigned exp_status; \ unsigned window; \ unsigned threshold; \ diff --git a/include/vtcp.h b/include/vtcp.h index 293759392..29f83cb75 100644 --- a/include/vtcp.h +++ b/include/vtcp.h @@ -55,13 +55,13 @@ void VTCP_name(const struct suckaddr *addr, char *abuf, unsigned alen, char *pbuf, unsigned plen); int VTCP_connected(int s); int VTCP_connect(const struct suckaddr *name, int msec); -int VTCP_open(const char *addr, const char *def_port, double timeout, +int VTCP_open(const char *addr, const char *def_port, vtim_dur timeout, const char **err); void VTCP_close(int *s); int VTCP_bind(const struct suckaddr *addr, const char **errp); int VTCP_listen(const struct suckaddr *addr, int depth, const char **errp); int VTCP_listen_on(const char *addr, const char *def_port, int depth, const char **errp); -void VTCP_set_read_timeout(int s, double seconds); -int VTCP_read(int fd, void *ptr, size_t len, double tmo); +void VTCP_set_read_timeout(int s, vtim_dur seconds); +int VTCP_read(int fd, void *ptr, size_t len, vtim_dur tmo); // #endif diff --git a/include/vtim.h b/include/vtim.h index 9c2e6ccfc..1968bc568 100644 --- a/include/vtim.h +++ b/include/vtim.h @@ -33,8 +33,8 @@ extern unsigned VTIM_postel; #define VTIM_FORMAT_SIZE 30 void VTIM_format(double t, char *p); double VTIM_parse(const char *p); -double VTIM_mono(void); -double VTIM_real(void); -void VTIM_sleep(double t); -struct timespec VTIM_timespec(double t); -struct timeval VTIM_timeval(double t); +vtim_mono VTIM_mono(void); +vtim_real VTIM_real(void); +void VTIM_sleep(vtim_dur t); +struct timespec VTIM_timespec(vtim_dur t); +struct timeval VTIM_timeval(vtim_dur t); diff --git a/lib/libvarnish/vev.c b/lib/libvarnish/vev.c index 0254a9cf7..771abf88b 100644 --- a/lib/libvarnish/vev.c +++ b/lib/libvarnish/vev.c @@ -354,7 +354,7 @@ VEV_Loop(struct vev_root *evb) /*--------------------------------------------------------------------*/ static int -vev_sched_timeout(struct vev_root *evb, struct vev *e, double t) +vev_sched_timeout(struct vev_root *evb, struct vev *e, vtim_mono t) { int i; diff --git a/lib/libvarnish/vtcp.c b/lib/libvarnish/vtcp.c index 93c2fce4a..00f7f63af 100644 --- a/lib/libvarnish/vtcp.c +++ b/lib/libvarnish/vtcp.c @@ -52,6 +52,7 @@ #include "vsa.h" #include "vss.h" #include "vtcp.h" +#include "vtim.h" /*--------------------------------------------------------------------*/ static void @@ -346,12 +347,10 @@ VTCP_close(int *s) } void -VTCP_set_read_timeout(int s, double seconds) +VTCP_set_read_timeout(int s, vtim_dur seconds) { #ifdef SO_RCVTIMEO_WORKS - struct timeval timeout; - timeout.tv_sec = (int)floor(seconds); - timeout.tv_usec = (int)(1e6 * (seconds - timeout.tv_sec)); + struct timeval timeout = VTIM_timeval(seconds); /* * Solaris bug (present at least in snv_151 and older): If this fails * with EINVAL, the socket is half-closed (SS_CANTSENDMORE) and the @@ -372,13 +371,14 @@ VTCP_set_read_timeout(int s, double seconds) static int v_matchproto_(vss_resolved_f) vtcp_open_callback(void *priv, const struct suckaddr *sa) { + /* XXX: vtim_dur? */ double *p = priv; return (VTCP_connect(sa, (int)floor(*p * 1e3))); } int -VTCP_open(const char *addr, const char *def_port, double timeout, +VTCP_open(const char *addr, const char *def_port, vtim_dur timeout, const char **errp) { int error; @@ -593,7 +593,7 @@ VTCP_Check(int a) */ int -VTCP_read(int fd, void *ptr, size_t len, double tmo) +VTCP_read(int fd, void *ptr, size_t len, vtim_dur tmo) { struct pollfd pfd[1]; int i, j; From dridi.boukelmoune at gmail.com Wed Feb 6 10:11:10 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 6 Feb 2019 10:11:10 +0000 (UTC) Subject: [6.0] 5ccd4b219 Fix VRT_fail for 'if'/'elseif' conditional expressions Message-ID: <20190206101110.B7A8DA21B8@lists.varnish-cache.org> commit 5ccd4b21925116227e3e5006473108046b3f8712 Author: Dag Haavi Finstad Date: Thu Nov 22 15:43:14 2018 +0100 Fix VRT_fail for 'if'/'elseif' conditional expressions This adds a ctx->handling test at the beginning of any compound statement, to catch the cases where VRT_fail was invoked as part of an if test condition. Fixes: #2840 diff --git a/bin/varnishtest/tests/v00051.vtc b/bin/varnishtest/tests/v00051.vtc index 664af71f7..a12d23ade 100644 --- a/bin/varnishtest/tests/v00051.vtc +++ b/bin/varnishtest/tests/v00051.vtc @@ -425,3 +425,32 @@ varnish v1 -expect sc_vcl_failure == 10 logexpect l1 -wait +####################################################################### +# Fail in vmod call used in an if test + +varnish v1 -vcl+backend { + import debug; + sub vcl_recv { + if (debug.fail2()) { + return (hash); + } + } +} + +logexpect l1 -v v1 -g raw { + expect * 1033 VCL_call "RECV" + expect 0 1033 VCL_Error "Forced failure" + expect 0 1033 VCL_return "fail" +} -start + +client c1 { + txreq + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" +} -run + +varnish v1 -expect vcl_fail == 14 +varnish v1 -expect sc_vcl_failure == 11 + +logexpect l1 -wait diff --git a/lib/libvcc/vcc_parse.c b/lib/libvcc/vcc_parse.c index ee8830859..2b5075358 100644 --- a/lib/libvcc/vcc_parse.c +++ b/lib/libvcc/vcc_parse.c @@ -149,6 +149,7 @@ vcc_Compound(struct vcc *tl) Fb(tl, 1, "{\n"); tl->indent += INDENT; C(tl, ";"); + Fb(tl, 1, "if (*ctx->handling) return;\n"); while (1) { ERRCHK(tl); t = tl->t; diff --git a/lib/libvmod_debug/vmod.vcc b/lib/libvmod_debug/vmod.vcc index 27f601ffa..6398d226d 100644 --- a/lib/libvmod_debug/vmod.vcc +++ b/lib/libvmod_debug/vmod.vcc @@ -130,6 +130,10 @@ $Function VOID fail() Function to fail vcl code. (See also: RFC748) +$Function BOOL fail2() + +Function to fail vcl code. Always returns true. + $Object dyn(STRING addr, STRING port, PROBE probe=0) Dynamically create a single-backend director, addr and port must not be empty. diff --git a/lib/libvmod_debug/vmod_debug.c b/lib/libvmod_debug/vmod_debug.c index 61a18c9ed..10c9bde96 100644 --- a/lib/libvmod_debug/vmod_debug.c +++ b/lib/libvmod_debug/vmod_debug.c @@ -221,6 +221,14 @@ xyzzy_fail(VRT_CTX) VRT_fail(ctx, "Forced failure"); } +VCL_BOOL v_matchproto_(td_debug_fail2) +xyzzy_fail2(VRT_CTX) +{ + + VRT_fail(ctx, "Forced failure"); + return (1); +} + static void v_matchproto_(vmod_priv_free_f) priv_vcl_free(void *priv) { From phk at FreeBSD.org Wed Feb 6 13:48:08 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 6 Feb 2019 13:48:08 +0000 (UTC) Subject: [master] 23c918ed8 Test that NULL-object handling also copes with 2297 Message-ID: <20190206134808.83F1FA7C0D@lists.varnish-cache.org> commit 23c918ed85a621aad78513d0c6923ed54649bbab Author: Poul-Henning Kamp Date: Wed Feb 6 13:46:22 2019 +0000 Test that NULL-object handling also copes with 2297 Fixes: #2297 diff --git a/bin/varnishtest/tests/m00000.vtc b/bin/varnishtest/tests/m00000.vtc index 355bb3c56..45262850b 100644 --- a/bin/varnishtest/tests/m00000.vtc +++ b/bin/varnishtest/tests/m00000.vtc @@ -120,3 +120,12 @@ varnish v1 -errvcl {Expression has type STRING, expected REAL} { set resp.http.who = std.random("foo", "bar"); } } + +varnish v1 -errvcl {Failed initialization} { + import debug; + backend default { .host = "127.0.0.1"; } + sub vcl_init { + return (fail); + new xyz = debug.obj(); + } +} From dridi.boukelmoune at gmail.com Wed Feb 6 13:49:09 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 6 Feb 2019 13:49:09 +0000 (UTC) Subject: [master] 2ce13cf28 Kill redundant redundant null checks Message-ID: <20190206134909.1DB4AA7DD8@lists.varnish-cache.org> commit 2ce13cf28b099bdc56889de15998c237ba25e267 Author: Dridi Boukelmoune Date: Tue Feb 21 13:58:17 2017 +0100 Kill redundant redundant null checks I caught one during a review and figured I might as well sweep the whole tree, so this patch was created using Coccinelle and the following steps: $ cat >check_obj.cocci <retval >= 0) AN(vdpe); if (vdpe != NULL) { - CHECK_OBJ_NOTNULL(vdpe, VDP_ENTRY_MAGIC); + CHECK_OBJ(vdpe, VDP_ENTRY_MAGIC); VTAILQ_REMOVE(&vdc->vdp, vdpe, list); if (vdpe->vdp->fini != NULL) AZ(vdpe->vdp->fini(req, &vdpe->priv)); diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index 7cfa27eeb..afd0d475a 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -503,7 +503,7 @@ VRT_u_bereq_body(VRT_CTX) CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC); if (ctx->bo->req != NULL) { - CHECK_OBJ_NOTNULL(ctx->bo->req, REQ_MAGIC); + CHECK_OBJ(ctx->bo->req, REQ_MAGIC); ctx->bo->req = NULL; ObjSetState(ctx->bo->wrk, ctx->bo->fetch_objcore, BOS_REQ_DONE); diff --git a/bin/varnishd/cache/cache_vrt_vcl.c b/bin/varnishd/cache/cache_vrt_vcl.c index c6eb3a927..c17c80e5d 100644 --- a/bin/varnishd/cache/cache_vrt_vcl.c +++ b/bin/varnishd/cache/cache_vrt_vcl.c @@ -436,7 +436,7 @@ vcl_call_method(struct worker *wrk, struct req *req, struct busyobj *bo, CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); INIT_OBJ(&ctx, VRT_CTX_MAGIC); if (req != NULL) { - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); + CHECK_OBJ(req, REQ_MAGIC); CHECK_OBJ_NOTNULL(req->sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(req->vcl, VCL_MAGIC); VCL_Req2Ctx(&ctx, req); diff --git a/lib/libvarnish/vev.c b/lib/libvarnish/vev.c index e6459bc7d..7869f700f 100644 --- a/lib/libvarnish/vev.c +++ b/lib/libvarnish/vev.c @@ -413,7 +413,7 @@ VEV_Once(struct vev_root *evb) tmo = INFTIM; e = binheap_root(evb->binheap); if (e != NULL) { - CHECK_OBJ_NOTNULL(e, VEV_MAGIC); + CHECK_OBJ(e, VEV_MAGIC); assert(e->__binheap_idx == BINHEAP_NOIDX + 1); t = VTIM_mono(); if (e->__when <= t) diff --git a/lib/libvarnishapi/vxp_parse.c b/lib/libvarnishapi/vxp_parse.c index a37faec57..e6db240c5 100644 --- a/lib/libvarnishapi/vxp_parse.c +++ b/lib/libvarnishapi/vxp_parse.c @@ -629,7 +629,7 @@ vex_print(const struct vex *vex, int indent) fprintf(stderr, "%*s%s", indent, "", vxp_tnames[vex->tok]); if (vex->lhs != NULL) { - CHECK_OBJ_NOTNULL(vex->lhs, VEX_LHS_MAGIC); + CHECK_OBJ(vex->lhs, VEX_LHS_MAGIC); AN(vex->lhs->tags); fprintf(stderr, " lhs="); if (vex->lhs->level >= 0) diff --git a/lib/libvmod_directors/vmod_shard.c b/lib/libvmod_directors/vmod_shard.c index e709e9cf0..5360f3aac 100644 --- a/lib/libvmod_directors/vmod_shard.c +++ b/lib/libvmod_directors/vmod_shard.c @@ -402,7 +402,7 @@ shard_get_key(VRT_CTX, const struct vmod_directors_shard_param *p) switch (p->by) { case BY_HASH: if (ctx->bo) { - CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC); + CHECK_OBJ(ctx->bo, BUSYOBJ_MAGIC); return (vbe32dec(ctx->bo->digest)); } /* FALLTHROUGH */ From phk at FreeBSD.org Wed Feb 6 14:04:09 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 6 Feb 2019 14:04:09 +0000 (UTC) Subject: [master] 0cf47b5ac Reduce close-margin over highest known filedescriptor. Message-ID: <20190206140409.9805DA8395@lists.varnish-cache.org> commit 0cf47b5acbc42eba48b262fc3c4070c406970d30 Author: Poul-Henning Kamp Date: Wed Feb 6 13:57:45 2019 +0000 Reduce close-margin over highest known filedescriptor. Fixes: #2844 diff --git a/bin/varnishd/mgt/mgt_child.c b/bin/varnishd/mgt/mgt_child.c index e6fd7c514..92a6313ca 100644 --- a/bin/varnishd/mgt/mgt_child.c +++ b/bin/varnishd/mgt/mgt_child.c @@ -180,18 +180,16 @@ mch_cli_panic_clear(struct cli *cli, const char * const *av, void *priv) * * This is likely to a bit on the low side, as libc and other libraries * has a tendency to cache file descriptors (syslog, resolver, etc.) - * so we add a margin of 100 fds. + * so we add a margin of 10 fds. * - * for added safety, we check that we see no file descriptor open for + * For added safety, we check that we see no file descriptor open for * another margin above the limit for which we close by design */ static int mgt_max_fd; -#define CLOSE_FD_UP_TO (mgt_max_fd + 100) -// XXX should work now - engage? -//#define CLOSE_FD_UP_TO mgt_max_fd -#define CHECK_FD_UP_TO (CLOSE_FD_UP_TO + 100) +#define CLOSE_FD_UP_TO (mgt_max_fd + 10) +#define CHECK_FD_UP_TO (CLOSE_FD_UP_TO + 10) void MCH_TrackHighFd(int fd) From dridi.boukelmoune at gmail.com Wed Feb 6 17:25:10 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 6 Feb 2019 17:25:10 +0000 (UTC) Subject: [master] d6b13ddef Null check Message-ID: <20190206172510.7DF73AE09B@lists.varnish-cache.org> commit d6b13ddef9557e3269f2cc4c014d47487447ef31 Author: Dridi Boukelmoune Date: Wed Feb 6 18:23:36 2019 +0100 Null check diff --git a/bin/varnishd/cache/cache_range.c b/bin/varnishd/cache/cache_range.c index c59fe857f..156e50e6f 100644 --- a/bin/varnishd/cache/cache_range.c +++ b/bin/varnishd/cache/cache_range.c @@ -67,6 +67,7 @@ vrg_range_bytes(struct req *req, enum vdp_action act, void **priv, struct vrg_priv *vrg_priv; CHECK_OBJ_NOTNULL(req, REQ_MAGIC); + AN(priv); CAST_OBJ_NOTNULL(vrg_priv, *priv, VRG_PRIV_MAGIC); l = vrg_priv->range_low - vrg_priv->range_off; From dridi.boukelmoune at gmail.com Wed Feb 6 17:34:09 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 6 Feb 2019 17:34:09 +0000 (UTC) Subject: [master] 8a7f5ab50 Null check Message-ID: <20190206173409.24BDDAE505@lists.varnish-cache.org> commit 8a7f5ab5070549681a3c32bd2ad7ee69c38d01f5 Author: Dridi Boukelmoune Date: Wed Feb 6 18:33:21 2019 +0100 Null check diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index 1462832a1..22d0b0855 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -254,6 +254,7 @@ ved_vdp_esi_init(struct req *req, void **priv) { struct ecx *ecx; + AN(priv); AZ(*priv); ALLOC_OBJ(ecx, ECX_MAGIC); AN(ecx); From dridi.boukelmoune at gmail.com Wed Feb 6 17:37:08 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 6 Feb 2019 17:37:08 +0000 (UTC) Subject: [master] e50a4a3cb Null check, hat trick Message-ID: <20190206173708.4128BAE71D@lists.varnish-cache.org> commit e50a4a3cbfa87c5b923c0b18c9ed3fbf88dc3553 Author: Dridi Boukelmoune Date: Wed Feb 6 18:35:43 2019 +0100 Null check, hat trick diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index 22d0b0855..59a138bb2 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -282,6 +282,7 @@ ved_vdp_esi_fini(struct req *req, void **priv) struct ecx *ecx; (void)req; + AN(priv); CAST_OBJ_NOTNULL(ecx, *priv, ECX_MAGIC); FREE_OBJ(ecx); *priv = NULL; From dridi.boukelmoune at gmail.com Wed Feb 6 17:41:09 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 6 Feb 2019 17:41:09 +0000 (UTC) Subject: [master] dfc31fda4 Null check Message-ID: <20190206174109.D9C03AEA6E@lists.varnish-cache.org> commit dfc31fda49ff0bcf49d6602d9c0040bc3377073b Author: Dridi Boukelmoune Date: Wed Feb 6 18:39:33 2019 +0100 Null check Apologies for the spam, I didn't think this would be a recurring pattern. diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index 59a138bb2..eeb4d1e79 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -301,6 +301,7 @@ ved_vdp_esi_bytes(struct req *req, enum vdp_action act, void **priv, struct ecx *ecx; int retval = 0; + AN(priv); CAST_OBJ_NOTNULL(ecx, *priv, ECX_MAGIC); pp = ptr; From phk at FreeBSD.org Wed Feb 6 21:08:08 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 6 Feb 2019 21:08:08 +0000 (UTC) Subject: [master] 260d0ecc5 Report what we did get, if we EOF while receiving header. Message-ID: <20190206210808.49EC6B2561@lists.varnish-cache.org> commit 260d0ecc5b4b9702f6d53cd2a6854c373384ea51 Author: Poul-Henning Kamp Date: Wed Feb 6 20:57:49 2019 +0000 Report what we did get, if we EOF while receiving header. diff --git a/bin/varnishtest/vtc_http.c b/bin/varnishtest/vtc_http.c index a8461530d..815dd8a11 100644 --- a/bin/varnishtest/vtc_http.c +++ b/bin/varnishtest/vtc_http.c @@ -633,7 +633,7 @@ http_swallow_body(struct http *hp, char * const *hh, int body) static void http_rxhdr(struct http *hp) { - int i; + int i, j; char *p; CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC); @@ -641,7 +641,7 @@ http_rxhdr(struct http *hp) hp->body = NULL; bprintf(hp->bodylen, "%s", ""); while (1) { - (void)http_rxchar(hp, 1, 0); + j = http_rxchar(hp, 1, 1); p = hp->rxbuf + hp->prxbuf - 1; for (i = 0; p > hp->rxbuf; p--) { if (*p != '\n') @@ -651,12 +651,14 @@ http_rxhdr(struct http *hp) if (++i == 2) break; } - if (i == 2) + if (i == 2 || !j) break; } vtc_dump(hp->vl, 4, "rxhdr", hp->rxbuf, -1); vtc_log(hp->vl, 4, "rxhdrlen = %zd", strlen(hp->rxbuf)); hp->body = hp->rxbuf + hp->prxbuf; + if (!j) + vtc_fatal(hp->vl, "EOF timeout=%d", hp->timeout); } /* SECTION: client-server.spec.rxresp From phk at FreeBSD.org Wed Feb 6 21:08:08 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 6 Feb 2019 21:08:08 +0000 (UTC) Subject: [master] c21f58dfa Make this test more resistant to machine overload, but also make it fail faster when appropriate Message-ID: <20190206210808.5FEE7B2564@lists.varnish-cache.org> commit c21f58dfa634ae760e77f2f8f47f9b140ff8c1a0 Author: Poul-Henning Kamp Date: Wed Feb 6 21:02:03 2019 +0000 Make this test more resistant to machine overload, but also make it fail faster when appropriate diff --git a/bin/varnishtest/tests/c00094.vtc b/bin/varnishtest/tests/c00094.vtc index 546efb08f..ad7a06a4e 100644 --- a/bin/varnishtest/tests/c00094.vtc +++ b/bin/varnishtest/tests/c00094.vtc @@ -3,7 +3,11 @@ varnishtest "Test Backend Polling with a backend listening at a UDS" barrier b1 cond 2 server s1 -listen "${tmpdir}/s1.sock" { + timeout 3 + fatal + # Probes + loop 8 { rxreq expect req.url == "/" @@ -39,7 +43,7 @@ varnish v1 -vcl { .path = "${s1_sock}"; .probe = { .timeout = 1 s; - .interval = 0.1 s; + .interval = 0.5 s; } } @@ -47,5 +51,5 @@ varnish v1 -vcl { barrier b1 sync -varnish v1 -cliexpect "^CLI RX| -+U+ Good UNIX" "backend.list -p" +varnish v1 -cliexpect "^CLI RX| -+U+-{0,5} Good UNIX" "backend.list -p" varnish v1 -cliexpect "^CLI RX| -+H{10}-{5}H{2}-{0,5} Happy" "backend.list -p" From phk at FreeBSD.org Wed Feb 6 21:59:08 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 6 Feb 2019 21:59:08 +0000 (UTC) Subject: [master] 72d1d4d77 Allow non-fatal (usually server) rxhdrs to fail silently, also when nothing has been received. Message-ID: <20190206215908.CAE9646F3@lists.varnish-cache.org> commit 72d1d4d77d77913fcb5151bfe2b8203b21d59c19 Author: Poul-Henning Kamp Date: Wed Feb 6 21:57:00 2019 +0000 Allow non-fatal (usually server) rxhdrs to fail silently, also when nothing has been received. diff --git a/bin/varnishtest/vtc_http.c b/bin/varnishtest/vtc_http.c index 815dd8a11..0c136cfd1 100644 --- a/bin/varnishtest/vtc_http.c +++ b/bin/varnishtest/vtc_http.c @@ -420,6 +420,10 @@ http_splitheader(struct http *hp, int req) n = 0; p = hp->rxbuf; + if (*p == '\0') { + vtc_log(hp->vl, 4, "No headers"); + return; + } /* REQ/PROTO */ while (vct_islws(*p)) @@ -638,6 +642,7 @@ http_rxhdr(struct http *hp) CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC); hp->prxbuf = 0; + hp->rxbuf[0] = '\0'; hp->body = NULL; bprintf(hp->bodylen, "%s", ""); while (1) { @@ -654,11 +659,11 @@ http_rxhdr(struct http *hp) if (i == 2 || !j) break; } - vtc_dump(hp->vl, 4, "rxhdr", hp->rxbuf, -1); - vtc_log(hp->vl, 4, "rxhdrlen = %zd", strlen(hp->rxbuf)); - hp->body = hp->rxbuf + hp->prxbuf; + vtc_dump(hp->vl, 4, "rxhdr", hp->rxbuf, hp->prxbuf); + vtc_log(hp->vl, 4, "rxhdrlen = %d", hp->prxbuf); if (!j) - vtc_fatal(hp->vl, "EOF timeout=%d", hp->timeout); + vtc_log(hp->vl, hp->fatal, "EOF timeout=%d", hp->timeout); + hp->body = hp->rxbuf + hp->prxbuf; } /* SECTION: client-server.spec.rxresp From phk at FreeBSD.org Wed Feb 6 21:59:08 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 6 Feb 2019 21:59:08 +0000 (UTC) Subject: [master] 009297d52 Stabilize this test under heavy system loads Message-ID: <20190206215908.DFE8846F6@lists.varnish-cache.org> commit 009297d522be4199e70500ce370c29c87c4c8c7c Author: Poul-Henning Kamp Date: Wed Feb 6 21:58:23 2019 +0000 Stabilize this test under heavy system loads diff --git a/bin/varnishtest/tests/c00088.vtc b/bin/varnishtest/tests/c00088.vtc index b39171f9a..d95477eae 100644 --- a/bin/varnishtest/tests/c00088.vtc +++ b/bin/varnishtest/tests/c00088.vtc @@ -1,8 +1,13 @@ varnishtest "Dropping polling of a backend that listens at UDS" -server s1 -listen "${tmpdir}/s1.sock" -repeat 40 { - rxreq - txresp +server s1 -listen "${tmpdir}/s1.sock" { + non_fatal + timeout 3 + loop 40 { + rxreq + txresp + accept + } } -start varnish v1 -vcl { From dridi.boukelmoune at gmail.com Fri Feb 8 09:19:09 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 8 Feb 2019 09:19:09 +0000 (UTC) Subject: [master] b588404ab Show VDPs if present during a panic Message-ID: <20190208091909.EC262620E@lists.varnish-cache.org> commit b588404ab8da52b2b9a2b7e8f77af091cdaba965 Author: Dridi Boukelmoune Date: Fri Feb 8 10:08:50 2019 +0100 Show VDPs if present during a panic And get a chance to catch vdp->fini() failures with the offending VDP still present in the list of filters. diff --git a/bin/varnishd/cache/cache_deliver_proc.c b/bin/varnishd/cache/cache_deliver_proc.c index 44b0e4668..c956c93a0 100644 --- a/bin/varnishd/cache/cache_deliver_proc.c +++ b/bin/varnishd/cache/cache_deliver_proc.c @@ -128,10 +128,10 @@ VDP_close(struct req *req) AN(vdpe); if (vdpe != NULL) { CHECK_OBJ(vdpe, VDP_ENTRY_MAGIC); - VTAILQ_REMOVE(&vdc->vdp, vdpe, list); if (vdpe->vdp->fini != NULL) AZ(vdpe->vdp->fini(req, &vdpe->priv)); AZ(vdpe->priv); + VTAILQ_REMOVE(&vdc->vdp, vdpe, list); } vdc->nxt = VTAILQ_FIRST(&vdc->vdp); } diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index bf4f9dfaf..3a4fae5f4 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -360,6 +360,7 @@ pan_vfp(struct vsb *vsb, const struct vfp_ctx *vfc) VSB_printf(vsb, "vfc = %p {\n", vfc); VSB_indent(vsb, 2); + PAN_CheckMagic(vsb, vfc, VFP_CTX_MAGIC); VSB_printf(vsb, "failed = %d,\n", vfc->failed); VSB_printf(vsb, "req = %p,\n", vfc->req); VSB_printf(vsb, "resp = %p,\n", vfc->resp); @@ -370,8 +371,7 @@ pan_vfp(struct vsb *vsb, const struct vfp_ctx *vfc) VSB_printf(vsb, "filters = {\n"); VSB_indent(vsb, 2); VTAILQ_FOREACH(vfe, &vfc->vfp, list) { - VSB_printf(vsb, "%s = %p {\n", - vfe->vfp->name, vfe); + VSB_printf(vsb, "%s = %p {\n", vfe->vfp->name, vfe); VSB_indent(vsb, 2); VSB_printf(vsb, "priv1 = %p,\n", vfe->priv1); VSB_printf(vsb, "priv2 = %zd,\n", vfe->priv2); @@ -388,6 +388,30 @@ pan_vfp(struct vsb *vsb, const struct vfp_ctx *vfc) VSB_printf(vsb, "},\n"); } +static void +pan_vdp(struct vsb *vsb, const struct vdp_ctx *vdc) +{ + struct vdp_entry *vde; + + VSB_printf(vsb, "vdc = %p {\n", vdc); + VSB_indent(vsb, 2); + PAN_CheckMagic(vsb, vdc, VDP_CTX_MAGIC); + VSB_printf(vsb, "nxt = %p,\n", vdc->nxt); + VSB_printf(vsb, "retval = %d,\n", vdc->retval); + + if (!VTAILQ_EMPTY(&vdc->vdp)) { + VSB_printf(vsb, "filters = {\n"); + VSB_indent(vsb, 2); + VTAILQ_FOREACH(vde, &vdc->vdp, list) + VSB_printf(vsb, "%s = %p { priv = %p }\n", + vde->vdp->name, vde, vde->priv); + VSB_indent(vsb, -2); + VSB_printf(vsb, "},\n"); + } + + VSB_indent(vsb, -2); + VSB_printf(vsb, "},\n"); +} static void pan_busyobj(struct vsb *vsb, const struct busyobj *bo) @@ -511,6 +535,8 @@ pan_req(struct vsb *vsb, const struct req *req) pan_http(vsb, "req", req->http); if (req->resp->ws != NULL) pan_http(vsb, "resp", req->resp); + if (req->vdc != NULL) + pan_vdp(vsb, req->vdc); VCL_Panic(vsb, "vcl", req->vcl); VCL_Panic(vsb, "vcl0", req->vcl0); From dridi.boukelmoune at gmail.com Fri Feb 8 09:23:08 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 8 Feb 2019 09:23:08 +0000 (UTC) Subject: [master] 832d6da2d Guard all the VDP_Push calls Message-ID: <20190208092308.C889E64F2@lists.varnish-cache.org> commit 832d6da2d732636b42a78920980a84b3e33bda9b Author: Dridi Boukelmoune Date: Fri Feb 8 10:21:41 2019 +0100 Guard all the VDP_Push calls Two of them have no init step, and the third one is fail-safe. diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index eeb4d1e79..9279baaa7 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -833,14 +833,14 @@ ved_deliver(struct req *req, struct boc *boc, int wantbody) INIT_OBJ(foo, VED_FOO_MAGIC); foo->ecx = ecx; - (void)VDP_Push(req, &ved_gzgz, foo); + AZ(VDP_Push(req, &ved_gzgz, foo)); } else if (ecx->isgzip && !i) { /* Non-Gzip'ed include in gzip'ed parent */ - (void)VDP_Push(req, &ved_pretend_gz, ecx); + AZ(VDP_Push(req, &ved_pretend_gz, ecx)); } else { /* Anything else goes straight through */ - (void)VDP_Push(req, &ved_ved, ecx); + AZ(VDP_Push(req, &ved_ved, ecx)); } (void)VDP_DeliverObj(req); (void)VDP_bytes(req, VDP_FLUSH, NULL, 0); From phk at FreeBSD.org Fri Feb 8 10:24:08 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 8 Feb 2019 10:24:08 +0000 (UTC) Subject: [master] bef8b6cf0 Consume less random bits, and don't pace after ramp-up Message-ID: <20190208102408.BE5CF7A2F@lists.varnish-cache.org> commit bef8b6cf0f1a8887484f1bbaba660478444d206e Author: Poul-Henning Kamp Date: Fri Feb 8 10:01:42 2019 +0000 Consume less random bits, and don't pace after ramp-up diff --git a/bin/varnishtest/vtc_main.c b/bin/varnishtest/vtc_main.c index 4b7fe2a4a..ac6c98ec4 100644 --- a/bin/varnishtest/vtc_main.c +++ b/bin/varnishtest/vtc_main.c @@ -275,7 +275,6 @@ start_test(void) assert(jp->buf != MAP_FAILED); memset(jp->buf, 0, jp->bufsiz); - VRND_SeedAll(); bprintf(tmpdir, "%s/vtc.%d.%08x", tmppath, (int)getpid(), (unsigned)random()); AZ(mkdir(tmpdir, 0711)); @@ -541,6 +540,7 @@ main(int argc, char * const *argv) { int ch, i; int ntest = 1; /* Run tests this many times */ + int nstart = 0; uintmax_t bufsiz; const char *p; @@ -568,6 +568,7 @@ main(int argc, char * const *argv) if (p != NULL) vtc_maxdur = atoi(p); + VRND_SeedAll(); setbuf(stdout, NULL); setbuf(stderr, NULL); while ((ch = getopt(argc, argv, "b:D:hij:kLln:p:qt:vW")) != -1) { @@ -660,7 +661,7 @@ main(int argc, char * const *argv) start_test(); njob++; /* Stagger ramp-up */ - if (njob < npar) + if (nstart++ < npar) (void)usleep(random() % 100000L); i = 1; continue; From phk at FreeBSD.org Fri Feb 8 10:24:08 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 8 Feb 2019 10:24:08 +0000 (UTC) Subject: [master] 15c72cf4a Optimize varnishtests central scheduler Message-ID: <20190208102408.D88B77A32@lists.varnish-cache.org> commit 15c72cf4aac1174cddc5a204d2eb3f762178d961 Author: Poul-Henning Kamp Date: Fri Feb 8 10:22:57 2019 +0000 Optimize varnishtests central scheduler diff --git a/bin/varnishtest/vtc_main.c b/bin/varnishtest/vtc_main.c index ac6c98ec4..a20a9f6fb 100644 --- a/bin/varnishtest/vtc_main.c +++ b/bin/varnishtest/vtc_main.c @@ -53,6 +53,17 @@ static const char *argv0; +struct buf { + unsigned magic; +#define BUF_MAGIC 0x39d1258a + VTAILQ_ENTRY(buf) list; + char *buf; + struct vsb *diag; + size_t bufsiz; +}; + +static VTAILQ_HEAD(, buf) free_bufs = VTAILQ_HEAD_INITIALIZER(free_bufs); + struct vtc_tst { unsigned magic; #define TST_MAGIC 0x618d8b88 @@ -69,14 +80,13 @@ struct vtc_job { pid_t child; struct vev *ev; struct vev *evt; - char *buf; + struct buf *bp; char *tmpdir; - unsigned bufsiz; double t0; - struct vsb *diag; int killed; }; + int iflg = 0; unsigned vtc_maxdur = 60; static unsigned vtc_bufsiz = 1024 * 1024; @@ -96,6 +106,40 @@ char *vmod_path = NULL; struct vsb *params_vsb = NULL; int leave_temp; int vtc_witness = 0; +static struct vsb *cbvsb; + +static struct buf * +get_buf(void) +{ + struct buf *bp; + + bp = VTAILQ_FIRST(&free_bufs); + CHECK_OBJ_ORNULL(bp, BUF_MAGIC); + if (bp != NULL) { + VTAILQ_REMOVE(&free_bufs, bp, list); + VSB_clear(bp->diag); + } else { + ALLOC_OBJ(bp, BUF_MAGIC); + AN(bp); + bp->bufsiz = vtc_bufsiz; + bp->buf = mmap(NULL, bp->bufsiz, PROT_READ|PROT_WRITE, + MAP_ANON | MAP_SHARED, -1, 0); + assert(bp->buf != MAP_FAILED); + bp->diag = VSB_new_auto(); + AN(bp->diag); + } + memset(bp->buf, 0, bp->bufsiz); + return (bp); +} + +static void +rel_buf(struct buf **bp) +{ + CHECK_OBJ_NOTNULL(*bp, BUF_MAGIC); + + VTAILQ_INSERT_HEAD(&free_bufs, (*bp), list); + *bp = NULL; +} /********************************************************************** * Parse a -D option argument into a name/val pair, and insert @@ -158,7 +202,6 @@ tst_cb(const struct vev *ve, int what) double t; FILE *f; char *p; - struct vsb *v; CAST_OBJ_NOTNULL(jp, ve->priv, JOB_MAGIC); @@ -173,8 +216,9 @@ tst_cb(const struct vev *ve, int what) *buf = '\0'; i = read(ve->fd, buf, sizeof buf); if (i > 0) - VSB_bcat(jp->diag, buf, i); + VSB_bcat(jp->bp->diag, buf, i); if (i == 0) { + njob--; px = wait4(jp->child, &stx, 0, NULL); assert(px == jp->child); @@ -185,21 +229,20 @@ tst_cb(const struct vev *ve, int what) if (ecode == 0) ecode = WEXITSTATUS(stx); - AZ(VSB_finish(jp->diag)); - v = VSB_new_auto(); - AN(v); - VSB_cat(v, jp->buf); - p = strchr(jp->buf, '\0'); - if (p > jp->buf && p[-1] != '\n') - VSB_putc(v, '\n'); - VSB_quote_pfx(v, "* diag 0.0 ", - VSB_data(jp->diag), -1, VSB_QUOTE_NONL); - AZ(VSB_finish(v)); - VSB_destroy(&jp->diag); - AZ(munmap(jp->buf, jp->bufsiz)); + AZ(VSB_finish(jp->bp->diag)); + + VSB_clear(cbvsb); + VSB_cat(cbvsb, jp->bp->buf); + p = strchr(jp->bp->buf, '\0'); + if (p > jp->bp->buf && p[-1] != '\n') + VSB_putc(cbvsb, '\n'); + VSB_quote_pfx(cbvsb, "* diag 0.0 ", + VSB_data(jp->bp->diag), -1, VSB_QUOTE_NONL); + AZ(VSB_finish(cbvsb)); + rel_buf(&jp->bp); if ((ecode > 1 && vtc_verbosity) || vtc_verbosity > 1) - printf("%s", VSB_data(v)); + printf("%s", VSB_data(cbvsb)); if (!ecode) vtc_good++; @@ -215,11 +258,10 @@ tst_cb(const struct vev *ve, int what) bprintf(buf, "%s/LOG", jp->tmpdir); f = fopen(buf, "w"); AN(f); - (void)fprintf(f, "%s\n", VSB_data(v)); + (void)fprintf(f, "%s\n", VSB_data(cbvsb)); AZ(fclose(f)); } free(jp->tmpdir); - VSB_destroy(&v); if (jp->killed) printf("# top TEST %s TIMED OUT (kill -9)\n", @@ -265,15 +307,7 @@ start_test(void) ALLOC_OBJ(jp, JOB_MAGIC); AN(jp); - jp->diag = VSB_new_auto(); - AN(jp->diag); - - jp->bufsiz = vtc_bufsiz; - - jp->buf = mmap(NULL, jp->bufsiz, PROT_READ|PROT_WRITE, - MAP_ANON | MAP_SHARED, -1, 0); - assert(jp->buf != MAP_FAILED); - memset(jp->buf, 0, jp->bufsiz); + jp->bp = get_buf(); bprintf(tmpdir, "%s/vtc.%d.%08x", tmppath, (int)getpid(), (unsigned)random()); @@ -284,7 +318,7 @@ start_test(void) AN(tp->ntodo); tp->ntodo--; VTAILQ_REMOVE(&tst_head, tp, list); - if (tp->ntodo >0) + if (tp->ntodo > 0) VTAILQ_INSERT_TAIL(&tst_head, tp, list); jp->tst = tp; @@ -304,7 +338,7 @@ start_test(void) assert(dup2(p[1], STDERR_FILENO) == STDERR_FILENO); VSUB_closefrom(STDERR_FILENO + 1); retval = exec_file(jp->tst->filename, jp->tst->script, - jp->tmpdir, jp->buf, jp->bufsiz); + jp->tmpdir, jp->bp->buf, jp->bp->bufsiz); exit(retval); } closefd(&p[1]); @@ -569,6 +603,8 @@ main(int argc, char * const *argv) vtc_maxdur = atoi(p); VRND_SeedAll(); + cbvsb = VSB_new_auto(); + AN(cbvsb); setbuf(stdout, NULL); setbuf(stderr, NULL); while ((ch = getopt(argc, argv, "b:D:hij:kLln:p:qt:vW")) != -1) { From phk at FreeBSD.org Fri Feb 8 12:11:08 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 8 Feb 2019 12:11:08 +0000 (UTC) Subject: [master] cb61c369e Implement an optional high performance "cleaner" Message-ID: <20190208121108.4CC6B60F3B@lists.varnish-cache.org> commit cb61c369ee6902909c01a92e07b3e8d898176cb4 Author: Poul-Henning Kamp Date: Fri Feb 8 12:08:24 2019 +0000 Implement an optional high performance "cleaner" When running really massive runs, "-j180 -n10000" kind of things, the "rm -rf" of the tmpdir becomes the limiting factor. The new -C option sends that int nice(1)'ed child process. diff --git a/bin/varnishtest/vtc_main.c b/bin/varnishtest/vtc_main.c index a20a9f6fb..196dd9202 100644 --- a/bin/varnishtest/vtc_main.c +++ b/bin/varnishtest/vtc_main.c @@ -108,6 +108,9 @@ int leave_temp; int vtc_witness = 0; static struct vsb *cbvsb; +static int cleaner_fd = -1; +static pid_t cleaner_pid; + static struct buf * get_buf(void) { @@ -172,6 +175,7 @@ usage(void) #define FMT " %-28s # %s\n" fprintf(stderr, FMT, "-b size", "Set internal buffer size (default: 1M)"); + fprintf(stderr, FMT, "-C", "Use cleaner subprocess"); fprintf(stderr, FMT, "-D name=val", "Define macro"); fprintf(stderr, FMT, "-i", "Find varnish binaries in build tree"); fprintf(stderr, FMT, "-j jobs", "Run this many tests in parallel"); @@ -187,6 +191,86 @@ usage(void) exit(1); } +/********************************************************************** + * When running many tests, cleaning the tmpdir with "rm -rf" becomes + * chore which limits our performance. + * When the number of tests are above 100, we spawn a child-process + * to do that for us. + */ + +static void +cleaner_do(const char *dirname) +{ + char buf[BUFSIZ]; + + AZ(memcmp(dirname, tmppath, strlen(tmppath))); + if (cleaner_pid > 0) { + bprintf(buf, "%s\n", dirname); + assert(write(cleaner_fd, buf, strlen(buf)) == strlen(buf)); + return; + } + bprintf(buf, "exec /bin/rm -rf %s\n", dirname); + AZ(system(buf)); +} + +static void +cleaner_setup(void) +{ + int p[2], st; + char buf[BUFSIZ]; + char *q; + pid_t pp; + + AZ(pipe(p)); + assert(p[0] > STDERR_FILENO); + assert(p[1] > STDERR_FILENO); + cleaner_pid = fork(); + assert(cleaner_pid >= 0); + if (cleaner_pid == 0) { + closefd(&p[1]); + AZ(nice(1)); + setbuf(stdin, NULL); + AZ(dup2(p[0], STDIN_FILENO)); + while (fgets(buf, sizeof buf, stdin)) { + AZ(memcmp(buf, tmppath, strlen(tmppath))); + q = buf + strlen(buf); + assert(q > buf); + assert(q[-1] == '\n'); + q[-1] = '\0'; + + /* Dont expend a shell on running /bin/rm */ + pp = fork(); + assert(pp >= 0); + if (pp == 0) + exit(execl("/bin/rm", "rm", "-rf", buf, NULL)); + assert(waitpid(pp, &st, 0) == pp); + AZ(st); + } + exit(0); + } + closefd(&p[0]); + cleaner_fd = p[1]; +} + +static void +cleaner_neuter(void) +{ + if (cleaner_pid > 0) + closefd(&cleaner_fd); +} + +static void +cleaner_finish(void) +{ + int st; + + if (cleaner_pid > 0) { + closefd(&cleaner_fd); + assert(waitpid(cleaner_pid, &st, 0) == cleaner_pid); + AZ(st); + } +} + /********************************************************************** * CallBack */ @@ -252,8 +336,7 @@ tst_cb(const struct vev *ve, int what) vtc_fail++; if (leave_temp == 0 || (leave_temp == 1 && ecode <= 1)) { - bprintf(buf, "rm -rf %s", jp->tmpdir); - AZ(system(buf)); + cleaner_do(jp->tmpdir); } else { bprintf(buf, "%s/LOG", jp->tmpdir); f = fopen(buf, "w"); @@ -332,6 +415,7 @@ start_test(void) jp->child = fork(); assert(jp->child >= 0); if (jp->child == 0) { + cleaner_neuter(); // Too dangerous to have around AZ(setpgid(getpid(), 0)); VFIL_null_fd(STDIN_FILENO); assert(dup2(p[1], STDOUT_FILENO) == STDOUT_FILENO); @@ -575,6 +659,7 @@ main(int argc, char * const *argv) int ch, i; int ntest = 1; /* Run tests this many times */ int nstart = 0; + int use_cleaner = 0; uintmax_t bufsiz; const char *p; @@ -607,7 +692,7 @@ main(int argc, char * const *argv) AN(cbvsb); setbuf(stdout, NULL); setbuf(stderr, NULL); - while ((ch = getopt(argc, argv, "b:D:hij:kLln:p:qt:vW")) != -1) { + while ((ch = getopt(argc, argv, "b:CD:hij:kLln:p:qt:vW")) != -1) { switch (ch) { case 'b': if (VNUM_2bytes(optarg, &bufsiz, 0)) { @@ -622,6 +707,9 @@ main(int argc, char * const *argv) } vtc_bufsiz = (unsigned)bufsiz; break; + case 'C': + use_cleaner = !use_cleaner; + break; case 'D': if (!parse_D_opt(optarg)) { fprintf(stderr, "Cannot parse D opt '%s'\n", @@ -691,6 +779,9 @@ main(int argc, char * const *argv) vb = VEV_New(); + if (use_cleaner) + cleaner_setup(); + i = 0; while (!VTAILQ_EMPTY(&tst_head) || i) { if (!VTAILQ_EMPTY(&tst_head) && njob < npar) { @@ -704,6 +795,7 @@ main(int argc, char * const *argv) } i = VEV_Once(vb); } + cleaner_finish(); if (vtc_continue) fprintf(stderr, "%d tests failed, %d tests skipped, %d tests passed\n", From phk at FreeBSD.org Fri Feb 8 12:18:08 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 8 Feb 2019 12:18:08 +0000 (UTC) Subject: [master] 5ec2db924 The GCC people are getting ridiculous. Message-ID: <20190208121808.8736561363@lists.varnish-cache.org> commit 5ec2db924defb1c3c53700c457de34e072aee238 Author: Poul-Henning Kamp Date: Fri Feb 8 12:17:04 2019 +0000 The GCC people are getting ridiculous. diff --git a/bin/varnishtest/vtc_main.c b/bin/varnishtest/vtc_main.c index 196dd9202..1a7fa98a2 100644 --- a/bin/varnishtest/vtc_main.c +++ b/bin/varnishtest/vtc_main.c @@ -242,7 +242,8 @@ cleaner_setup(void) pp = fork(); assert(pp >= 0); if (pp == 0) - exit(execl("/bin/rm", "rm", "-rf", buf, NULL)); + exit(execl( + "/bin/rm", "rm", "-rf", buf, (char*)0)); assert(waitpid(pp, &st, 0) == pp); AZ(st); } From dridi.boukelmoune at gmail.com Fri Feb 8 12:31:10 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 8 Feb 2019 12:31:10 +0000 (UTC) Subject: [6.0] 860bddc23 Add VSL rate limiting Message-ID: <20190208123110.4ABA5618C5@lists.varnish-cache.org> commit 860bddc23f7572798d494c15fec8dd46f5689139 Author: Dag Haavi Finstad Date: Tue Nov 20 11:16:51 2018 +0100 Add VSL rate limiting This adds rate limiting to varnishncsa and varnishlog. Rate limiting is done on a per-transaction basis, respective to the grouping mode selected. I.e. for -g request the limit will apply on a per-request basis, -g raw on a per-record basis, etc. Rate limit is specified as -R [/duration]. Default period if not specified is seconds ('s'). diff --git a/bin/varnishlog/varnishlog_options.h b/bin/varnishlog/varnishlog_options.h index 417b76432..ea0b4c698 100644 --- a/bin/varnishlog/varnishlog_options.h +++ b/bin/varnishlog/varnishlog_options.h @@ -70,6 +70,7 @@ VUT_OPT_n VUT_GLOBAL_OPT_P VUT_OPT_q VUT_OPT_r +VSL_OPT_R VUT_OPT_t VSL_OPT_T VSL_OPT_v diff --git a/bin/varnishncsa/varnishncsa_options.h b/bin/varnishncsa/varnishncsa_options.h index 16bcdb1cd..73765083f 100644 --- a/bin/varnishncsa/varnishncsa_options.h +++ b/bin/varnishncsa/varnishncsa_options.h @@ -88,6 +88,7 @@ VUT_OPT_n VUT_GLOBAL_OPT_P VUT_OPT_q VUT_OPT_r +VSL_OPT_R VUT_OPT_t VUT_GLOBAL_OPT_V NCSA_OPT_w diff --git a/include/vapi/vapi_options.h b/include/vapi/vapi_options.h index 3d95c3123..a357abd28 100644 --- a/include/vapi/vapi_options.h +++ b/include/vapi/vapi_options.h @@ -77,6 +77,22 @@ " running queries. Defaults to 1000 transactions." \ ) +#define VSL_OPT_R \ + VOPT("R:", "[-R ]", "Output rate limit", \ + "Restrict the output to the specified limit." \ + " Transactions exceeding the limit will be suppressed." \ + " The limit is specified as the maximum number of" \ + " transactions (with respect to the chosen grouping" \ + " method) and an optional time period. If no duration" \ + " is specified, a default of ``s`` is used. The duration" \ + " field can be formatted as in VCL (e.g. ``-R 10/2m``) or" \ + " as a simple time period without the prefix (e.g." \ + " ``-R 5/m``)." \ + " When in ``-g raw`` grouping mode, this setting can" \ + " not be used alongside ``-i``, ``-I``, ``-x`` or " \ + "``-X``, and we advise using ``-q`` instead." \ + ) + #define VSL_OPT_T \ VOPT("T:", "[-T ]", "Transaction end timeout", \ "Sets the transaction timeout in seconds. This defines the" \ diff --git a/lib/libvarnishapi/vsl_api.h b/lib/libvarnishapi/vsl_api.h index 0e265c0b1..8817aa8fe 100644 --- a/lib/libvarnishapi/vsl_api.h +++ b/lib/libvarnishapi/vsl_api.h @@ -84,6 +84,8 @@ struct VSL_data { int c_opt; int C_opt; int L_opt; + int R_opt_l; + vtim_dur R_opt_p; double T_opt; int v_opt; }; diff --git a/lib/libvarnishapi/vsl_arg.c b/lib/libvarnishapi/vsl_arg.c index b4bef5adb..2929b4ccf 100644 --- a/lib/libvarnishapi/vsl_arg.c +++ b/lib/libvarnishapi/vsl_arg.c @@ -300,6 +300,41 @@ vsl_IX_arg(struct VSL_data *vsl, int opt, const char *arg) return (1); } +static int +vsl_R_arg(struct VSL_data *vsl, const char *arg) +{ + char buf[32] = ""; + char *p; + long l; + + AN(arg); + CHECK_OBJ_NOTNULL(vsl, VSL_MAGIC); + + l = strtol(arg, &p, 0); + if (l <= 0 || l > INT_MAX) + return (vsl_diag(vsl, "-R: Range error")); + vsl->R_opt_l = l; + assert(p != arg); + AN(p); + if (*p == '\0') { + vsl->R_opt_p = 1.0; + return (1); + } + if (*p != '/' || p[1] == '\0') + return (vsl_diag(vsl, "-R: Syntax error")); + p++; + if (strlen(p) > sizeof(buf) - 2) + return (vsl_diag(vsl, "-R: Syntax error")); + if (!isdigit(*p)) + strcat(buf, "1"); + strcat(buf, p); + vsl->R_opt_p = VNUM_duration(buf); + if (isnan(vsl->R_opt_p) || vsl->R_opt_p <= 0.0) + return (vsl_diag(vsl, + "-R: Syntax error: Invalid duration")); + return (1); +} + int VSL_Arg(struct VSL_data *vsl, int opt, const char *arg) { @@ -334,6 +369,8 @@ VSL_Arg(struct VSL_data *vsl, int opt, const char *arg) return (vsl_diag(vsl, "-L: Range error")); vsl->L_opt = (int)l; return (1); + case 'R': + return (vsl_R_arg(vsl, arg)); case 'T': AN(arg); d = VNUM(arg); diff --git a/lib/libvarnishapi/vsl_dispatch.c b/lib/libvarnishapi/vsl_dispatch.c index 6e786d4f7..0075e2322 100644 --- a/lib/libvarnishapi/vsl_dispatch.c +++ b/lib/libvarnishapi/vsl_dispatch.c @@ -194,6 +194,10 @@ struct VSLQ { VTAILQ_HEAD(,vtx) cache; unsigned n_cache; + /* Rate limiting */ + double credits; + vtim_mono last_use; + /* Raw mode */ struct { struct vslc_raw c; @@ -908,10 +912,33 @@ vtx_force(struct VSLQ *vslq, struct vtx *vtx, const char *reason) AN(vtx->flags & VTX_F_COMPLETE); } +static int +vslq_ratelimit(struct VSLQ *vslq) +{ + vtim_mono now; + vtim_dur delta; + + CHECK_OBJ_NOTNULL(vslq, VSLQ_MAGIC); + CHECK_OBJ_NOTNULL(vslq->vsl, VSL_MAGIC); + + now = VTIM_mono(); + delta = now - vslq->last_use; + vslq->credits += (delta / vslq->vsl->R_opt_p) * vslq->vsl->R_opt_l; + if (vslq->credits > vslq->vsl->R_opt_l) + vslq->credits = vslq->vsl->R_opt_l; + vslq->last_use = now; + + if (vslq->credits < 1.0) + return (0); + + vslq->credits -= 1.0; + return (1); +} + /* Build transaction array, do the query and callback. Returns 0 or the return value from func */ static int -vslq_callback(const struct VSLQ *vslq, struct vtx *vtx, VSLQ_dispatch_f *func, +vslq_callback(struct VSLQ *vslq, struct vtx *vtx, VSLQ_dispatch_f *func, void *priv) { unsigned n = vtx->n_descend + 1; @@ -973,6 +1000,9 @@ vslq_callback(const struct VSLQ *vslq, struct vtx *vtx, VSLQ_dispatch_f *func, if (vslq->query != NULL && !vslq_runquery(vslq->query, ptrans)) return (0); + if (vslq->vsl->R_opt_l != 0 && !vslq_ratelimit(vslq)) + return (0); + /* Callback */ return ((func)(vslq->vsl, ptrans, priv)); } @@ -1078,6 +1108,10 @@ VSLQ_New(struct VSL_data *vsl, struct VSL_cursor **cp, } vslq->grouping = grouping; vslq->query = query; + if (vslq->vsl->R_opt_l != 0) { + vslq->last_use = VTIM_mono(); + vslq->credits = 1; + } /* Setup normal mode */ VRB_INIT(&vslq->tree); @@ -1195,6 +1229,9 @@ vslq_raw(struct VSLQ *vslq, VSLQ_dispatch_f *func, void *priv) !vslq_runquery(vslq->query, vslq->raw.ptrans)) return (r); + if (vslq->vsl->R_opt_l != 0 && !vslq_ratelimit(vslq)) + return (r); + i = (func)(vslq->vsl, vslq->raw.ptrans, priv); if (i) return (i); From dridi.boukelmoune at gmail.com Fri Feb 8 12:31:10 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 8 Feb 2019 12:31:10 +0000 (UTC) Subject: [6.0] d30f1a015 Add a real tokenizer (only little use yet) Message-ID: <20190208123110.723C2618C9@lists.varnish-cache.org> commit d30f1a01589aa80dda6dcdfd647c68dad972fbba Author: Poul-Henning Kamp Date: Tue Nov 27 13:21:32 2018 +0000 Add a real tokenizer (only little use yet) Make reporting syntax errors easier. diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py index e58041266..4989e299b 100755 --- a/lib/libvcc/vmodtool.py +++ b/lib/libvcc/vmodtool.py @@ -527,7 +527,8 @@ class ProtoType(object): class stanza(object): - def __init__(self, l0, doc, vcc): + def __init__(self, toks, l0, doc, vcc): + self.toks = toks self.line = l0 while doc and doc[0] == '': doc.pop(0) @@ -543,6 +544,12 @@ class stanza(object): def dump(self): print(type(self), self.line) + def syntax(self): + err("Syntax error.\n" + + "\tShould be: " + self.__doc__.strip() + "\n" + + "\tIs: " + " ".join(self.toks) + "\n", + warn=False) + def rstfile(self, fo, man): if self.rstlbl is not None: fo.write(".. _" + self.rstlbl + ":\n\n") @@ -640,17 +647,31 @@ class s_module(stanza): class s_abi(stanza): + + ''' $ABI [strict|vrt] ''' + def parse(self): - if self.line[1] not in ('strict', 'vrt'): + if len(self.toks) != 2: + self.syntax() + valid = { + 'strict': True, + 'vrt': False, + } + self.vcc.strict_abi = valid.get(self.toks[1]) + if self.vcc.strict_abi is None: err("Valid ABI types are 'strict' or 'vrt', got '%s'\n" % - self.line[1]) - self.vcc.strict_abi = self.line[1] == 'strict' + self.toks[1]) self.vcc.contents.append(self) class s_prefix(stanza): + + ''' $Prefix symbol ''' + def parse(self): - self.vcc.sympfx = self.line[1] + "_" + if len(self.toks) != 2: + self.syntax() + self.vcc.sympfx = self.toks[1] + "_" self.vcc.contents.append(self) @@ -832,6 +853,43 @@ DISPATCH = { "Synopsis": s_synopsis, } +def tokenize(str, seps=None, quotes=None): + if seps is None: + seps = "[](){},=" + if quotes is None: + quotes = '"' + "'" + quote = None + out = [] + i = 0 + inside = False + while i < len(str): + c = str[i] + # print("T", [c], quote, inside, i) + i += 1 + if quote is not None and c == quote: + inside = False + quote = None + out[-1] += c + elif quote is not None: + out[-1] += c + elif c.isspace(): + inside = False + elif seps.find(c) >= 0: + inside = False + out.append(c) + elif quotes.find(c) >= 0: + quote = c + out.append(c) + elif inside: + out[-1] += c + else: + out.append(c) + inside = True + #print("TOK", [str]) + #for i in out: + # print("\t", [i]) + return out + class vcc(object): def __init__(self, inputvcc, rstdir, outputprefix): @@ -864,12 +922,13 @@ class vcc(object): self.copyright = s.pop(0).strip() while s: ss = re.split('\n([^\t ])', s.pop(0), maxsplit=1) + toks = tokenize(ss[0]) c = ss[0].split() d = "".join(ss[1:]) - m = DISPATCH.get(c[0]) + m = DISPATCH.get(toks[0]) if m is None: err("Unknown stanze $%s" % ss[:i]) - m([c[0], " ".join(c[1:])], d.split('\n'), self) + m(toks, [c[0], " ".join(c[1:])], d.split('\n'), self) inputline = None def rst_copyright(self, fo): From dridi.boukelmoune at gmail.com Fri Feb 8 12:31:10 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 8 Feb 2019 12:31:10 +0000 (UTC) Subject: [6.0] af90bd621 More use of tokenlist Message-ID: <20190208123110.8B7E6618CD@lists.varnish-cache.org> commit af90bd6210f9ceab93943ce41954827090282846 Author: Poul-Henning Kamp Date: Tue Nov 27 14:05:09 2018 +0000 More use of tokenlist diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py index 4989e299b..e9fe75d73 100755 --- a/lib/libvcc/vmodtool.py +++ b/lib/libvcc/vmodtool.py @@ -589,10 +589,17 @@ class stanza(object): class s_module(stanza): + + ''' $Module modname man_section description ... ''' + def parse(self): + if len(self.toks) < 4: + self.syntax() a = self.line[1].split(None, 2) - self.vcc.modname = a[0] - self.vcc.mansection = a[1] + self.vcc.modname = self.toks[1] + self.vcc.mansection = self.toks[2] + # XXX: Find better solution for moddesc + self.vcc.moddesc = " ".join(self.toks[2:]) self.vcc.moddesc = a[2] self.rstlbl = "vmod_%s(%s)" % ( self.vcc.modname, @@ -676,17 +683,31 @@ class s_prefix(stanza): class s_synopsis(stanza): + + ''' $Synopsis [auto|manual] ''' + def parse(self): - if self.line[1] not in ('auto', 'manual'): + if len(self.toks) != 2: + self.syntax() + valid = { + 'auto': True, + 'manual': False, + } + self.vcc.auto_synopsis = vald.get(self.toks[1]) + if self.vcc.auto_synopsis is None: err("Valid Synopsis values are 'auto' or 'manual', got '%s'\n" % - self.line[1]) - self.vcc.auto_synopsis = self.line[1] == 'auto' + self.toks[1]) self.vcc.contents.append(self) class s_event(stanza): + + ''' $Event function_name ''' + def parse(self): - self.event_func = self.line[1] + if len(self.toks) != 2: + self.syntax() + self.event_func = self.toks[1] self.vcc.contents.append(self) def rstfile(self, fo, man): From dridi.boukelmoune at gmail.com Fri Feb 8 12:31:10 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 8 Feb 2019 12:31:10 +0000 (UTC) Subject: [6.0] 5a448f21c fix typo Message-ID: <20190208123110.ACBBC618D4@lists.varnish-cache.org> commit 5a448f21c22731407e2eecad9a537c6dda94916a Author: Nils Goroll Date: Tue Nov 27 17:34:50 2018 +0100 fix typo diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py index e9fe75d73..72b1c5a6b 100755 --- a/lib/libvcc/vmodtool.py +++ b/lib/libvcc/vmodtool.py @@ -693,7 +693,7 @@ class s_synopsis(stanza): 'auto': True, 'manual': False, } - self.vcc.auto_synopsis = vald.get(self.toks[1]) + self.vcc.auto_synopsis = valid.get(self.toks[1]) if self.vcc.auto_synopsis is None: err("Valid Synopsis values are 'auto' or 'manual', got '%s'\n" % self.toks[1]) From dridi.boukelmoune at gmail.com Fri Feb 8 12:31:10 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 8 Feb 2019 12:31:10 +0000 (UTC) Subject: [6.0] 752510121 Implement a better solution: Prefer a single quoted token for $Module description, and suggest people to do it that way. Message-ID: <20190208123110.CB01C618DE@lists.varnish-cache.org> commit 752510121b1dcecf7b6f62d901708c0ad38e3459 Author: Poul-Henning Kamp Date: Tue Nov 27 22:17:39 2018 +0000 Implement a better solution: Prefer a single quoted token for $Module description, and suggest people to do it that way. diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py index 72b1c5a6b..da1657a73 100755 --- a/lib/libvcc/vmodtool.py +++ b/lib/libvcc/vmodtool.py @@ -120,6 +120,15 @@ CTYPES.update(PRIVS) ####################################################################### +def is_quoted(str): + return len(str) > 2 and str[0] == str[-1] and str[0] in ('"', "'") + +def unquote(str): + assert is_quoted(str) + return str[1:-1] + +####################################################################### + def write_file_warning(fo, a, b, c): fo.write(a + "\n") @@ -598,9 +607,11 @@ class s_module(stanza): a = self.line[1].split(None, 2) self.vcc.modname = self.toks[1] self.vcc.mansection = self.toks[2] - # XXX: Find better solution for moddesc - self.vcc.moddesc = " ".join(self.toks[2:]) - self.vcc.moddesc = a[2] + if len(self.toks) == 4 and is_quoted(self.toks[3]): + self.vcc.moddesc = unquote(self.toks[3]) + else: + print("\nNOTICE: Please put $Module description in quotes.\n") + self.vcc.moddesc = " ".join(self.toks[3:]) self.rstlbl = "vmod_%s(%s)" % ( self.vcc.modname, self.vcc.mansection diff --git a/lib/libvmod_blob/vmod.vcc b/lib/libvmod_blob/vmod.vcc index 0a7e652d5..798989b52 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" $ABI strict diff --git a/lib/libvmod_debug/vmod.vcc b/lib/libvmod_debug/vmod.vcc index 6398d226d..f5ab7594a 100644 --- a/lib/libvmod_debug/vmod.vcc +++ b/lib/libvmod_debug/vmod.vcc @@ -26,7 +26,7 @@ # SUCH DAMAGE. # -$Module debug 3 Development, test and debug +$Module debug 3 "Development, test and debug" $ABI strict $Prefix xyzzy DESCRIPTION diff --git a/lib/libvmod_directors/vmod.vcc b/lib/libvmod_directors/vmod.vcc index 8fecc08e7..54b111fba 100644 --- a/lib/libvmod_directors/vmod.vcc +++ b/lib/libvmod_directors/vmod.vcc @@ -32,7 +32,7 @@ # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. -$Module directors 3 Varnish Directors Module +$Module directors 3 "Varnish Directors Module" $ABI strict DESCRIPTION diff --git a/lib/libvmod_proxy/vmod.vcc b/lib/libvmod_proxy/vmod.vcc index d986b5295..34b1199b2 100644 --- a/lib/libvmod_proxy/vmod.vcc +++ b/lib/libvmod_proxy/vmod.vcc @@ -25,7 +25,7 @@ # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. -$Module proxy 3 Varnish Module to extract TLV attributes from PROXYv2 +$Module proxy 3 "Varnish Module to extract TLV attributes from PROXYv2" $ABI strict DESCRIPTION diff --git a/lib/libvmod_purge/vmod.vcc b/lib/libvmod_purge/vmod.vcc index 25a9cb801..e158aac69 100644 --- a/lib/libvmod_purge/vmod.vcc +++ b/lib/libvmod_purge/vmod.vcc @@ -25,7 +25,7 @@ # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. -$Module purge 3 Varnish Purge Module +$Module purge 3 "Varnish Purge Module" $ABI strict DESCRIPTION diff --git a/lib/libvmod_std/vmod.vcc b/lib/libvmod_std/vmod.vcc index c30172ed1..fc5ef3736 100644 --- a/lib/libvmod_std/vmod.vcc +++ b/lib/libvmod_std/vmod.vcc @@ -25,7 +25,7 @@ # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. -$Module std 3 Varnish Standard Module +$Module std 3 "Varnish Standard Module" $ABI strict DESCRIPTION diff --git a/lib/libvmod_unix/vmod.vcc b/lib/libvmod_unix/vmod.vcc index e70a092d3..e227e9f99 100644 --- a/lib/libvmod_unix/vmod.vcc +++ b/lib/libvmod_unix/vmod.vcc @@ -5,7 +5,7 @@ # Authors: Geoffrey Simmons # -$Module unix 3 utilities for Unix domain sockets +$Module unix 3 "Utilities for Unix domain sockets" $ABI strict diff --git a/lib/libvmod_vtc/vmod.vcc b/lib/libvmod_vtc/vmod.vcc index c521f37da..94f8f75b6 100644 --- a/lib/libvmod_vtc/vmod.vcc +++ b/lib/libvmod_vtc/vmod.vcc @@ -25,7 +25,7 @@ # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. -$Module vtc 3 Utility module for varnishtest +$Module vtc 3 "Utility module for varnishtest" $ABI strict DESCRIPTION From dridi.boukelmoune at gmail.com Fri Feb 8 12:31:10 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 8 Feb 2019 12:31:10 +0000 (UTC) Subject: [6.0] 5e1afbfb5 Ditch the old prototype tokenizer for the new. Message-ID: <20190208123110.EE9C1618FC@lists.varnish-cache.org> commit 5e1afbfb554d81ca3172dcf3254d40ffafb02ea0 Author: Poul-Henning Kamp Date: Tue Nov 27 22:56:20 2018 +0000 Ditch the old prototype tokenizer for the new. Other polish. diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py index da1657a73..4886c4e26 100755 --- a/lib/libvcc/vmodtool.py +++ b/lib/libvcc/vmodtool.py @@ -235,10 +235,8 @@ class CType(object): self.spec = [] while True: x = wl.pop(0) - if x[0] == '"' and x[-1] == '"': - x = x[1:-1] - elif x[0] == "'" and x[-1] == "'": - x = x[1:-1] + if is_quoted(x): + x = unquote(x) assert x self.spec.append(x) enums[x] = True @@ -268,6 +266,9 @@ class CType(object): class arg(CType): + + ''' Parse front of word list into argument ''' + def __init__(self, wl, argnames, enums, end): super(arg, self).__init__(wl, enums) @@ -289,10 +290,8 @@ class arg(CType): x = wl.pop(0) if self.vt == "ENUM": - if x[0] == '"' and x[-1] == '"': - x = x[1:-1] - elif x[0] == "'" and x[-1] == "'": - x = x[1:-1] + if is_quoted(x): + x = unquote(x) self.defval = x def json(self, jl): @@ -305,60 +304,13 @@ class arg(CType): ####################################################################### -def lex(l): - wl = [] - s = 0 - assert l - for i in range(len(l)): - c = l[i] - - if s == 0 and re.match('[0-9a-zA-Z_.-]', c): - wl.append(c) - s = 3 - continue - - if s == 3: - if re.match('[0-9a-zA-Z_.-]', c): - wl[-1] += c - continue - s = 0 - - if s == 0 and c in (' ', '\t', '\n', '\r'): - continue - - if s == 0 and c in ('[', '(', '{', '}', ')', ']', ',', '='): - wl.append(c) - elif s == 0 and c in ('"', "'"): - sep = c - s = 1 - wl.append(c) - elif s == 1: - if c == '\\': - s = 2 - else: - wl[-1] += c - if c == sep: - s = 0 - elif s == 2: - wl[-1] += c - s = 1 - else: - err("Syntax error at char %d '%s'" % (i, c), warn=False) - - if s != 0: - err("Syntax error at char %d '%s'" % (i, c), warn=False) - return wl - -####################################################################### - - class ProtoType(object): def __init__(self, st, retval=True, prefix=""): self.st = st self.obj = None self.args = [] self.argstruct = False - wl = lex(st.line[1]) + wl = self.st.toks[1:] if retval: self.retval = CType(wl, st.vcc.enums) @@ -604,7 +556,6 @@ class s_module(stanza): def parse(self): if len(self.toks) < 4: self.syntax() - a = self.line[1].split(None, 2) self.vcc.modname = self.toks[1] self.vcc.mansection = self.toks[2] if len(self.toks) == 4 and is_quoted(self.toks[3]): @@ -885,43 +836,6 @@ DISPATCH = { "Synopsis": s_synopsis, } -def tokenize(str, seps=None, quotes=None): - if seps is None: - seps = "[](){},=" - if quotes is None: - quotes = '"' + "'" - quote = None - out = [] - i = 0 - inside = False - while i < len(str): - c = str[i] - # print("T", [c], quote, inside, i) - i += 1 - if quote is not None and c == quote: - inside = False - quote = None - out[-1] += c - elif quote is not None: - out[-1] += c - elif c.isspace(): - inside = False - elif seps.find(c) >= 0: - inside = False - out.append(c) - elif quotes.find(c) >= 0: - quote = c - out.append(c) - elif inside: - out[-1] += c - else: - out.append(c) - inside = True - #print("TOK", [str]) - #for i in out: - # print("\t", [i]) - return out - class vcc(object): def __init__(self, inputvcc, rstdir, outputprefix): @@ -954,7 +868,8 @@ class vcc(object): self.copyright = s.pop(0).strip() while s: ss = re.split('\n([^\t ])', s.pop(0), maxsplit=1) - toks = tokenize(ss[0]) + toks = self.tokenize(ss[0]) + inputline = '$' + ' '.join(toks) c = ss[0].split() d = "".join(ss[1:]) m = DISPATCH.get(toks[0]) @@ -963,6 +878,44 @@ class vcc(object): m(toks, [c[0], " ".join(c[1:])], d.split('\n'), self) inputline = None + def tokenize(self, str, seps=None, quotes=None): + if seps is None: + seps = "[](){},=" + if quotes is None: + quotes = '"' + "'" + quote = None + out = [] + i = 0 + inside = False + while i < len(str): + c = str[i] + # print("T", [c], quote, inside, i) + i += 1 + if quote is not None and c == quote: + inside = False + quote = None + out[-1] += c + elif quote is not None: + out[-1] += c + elif c.isspace(): + inside = False + elif seps.find(c) >= 0: + inside = False + out.append(c) + elif quotes.find(c) >= 0: + quote = c + out.append(c) + elif inside: + out[-1] += c + else: + out.append(c) + inside = True + #print("TOK", [str]) + #for i in out: + # print("\t", [i]) + return out + + def rst_copyright(self, fo): write_rst_hdr(fo, "COPYRIGHT", "=") fo.write("\n::\n\n") From dridi.boukelmoune at gmail.com Fri Feb 8 12:31:11 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 8 Feb 2019 12:31:11 +0000 (UTC) Subject: [6.0] 10c8db66f fix vmodtool error message Message-ID: <20190208123111.1961F61905@lists.varnish-cache.org> commit 10c8db66fd6a90ba3fc81139c94d5dfc7052ca27 Author: Nils Goroll Date: Wed Nov 28 13:51:10 2018 +0100 fix vmodtool error message diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py index 4886c4e26..2ef32e78c 100755 --- a/lib/libvcc/vmodtool.py +++ b/lib/libvcc/vmodtool.py @@ -874,7 +874,7 @@ class vcc(object): d = "".join(ss[1:]) m = DISPATCH.get(toks[0]) if m is None: - err("Unknown stanze $%s" % ss[:i]) + err("Unknown stanza $%s" % toks[0], warn=False) m(toks, [c[0], " ".join(c[1:])], d.split('\n'), self) inputline = None From dridi.boukelmoune at gmail.com Fri Feb 8 12:31:11 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 8 Feb 2019 12:31:11 +0000 (UTC) Subject: [6.0] b0249dc88 Test $Synopsis stanza Message-ID: <20190208123111.3B4EB61913@lists.varnish-cache.org> commit b0249dc8892a188e5214da47ab36980ce4b4aacd Author: Nils Goroll Date: Wed Nov 28 13:53:23 2018 +0100 Test $Synopsis stanza this would have caught 7395ecae8fdfaefca9ee5438d35ea6101c7a9f56 diff --git a/lib/libvmod_debug/vmod.vcc b/lib/libvmod_debug/vmod.vcc index f5ab7594a..0409c1f0a 100644 --- a/lib/libvmod_debug/vmod.vcc +++ b/lib/libvmod_debug/vmod.vcc @@ -29,6 +29,7 @@ $Module debug 3 "Development, test and debug" $ABI strict $Prefix xyzzy +$Synopsis auto DESCRIPTION =========== From dridi.boukelmoune at gmail.com Fri Feb 8 12:31:11 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 8 Feb 2019 12:31:11 +0000 (UTC) Subject: [6.0] db97d8eaf Add a debug flag to keep VCL C and so files around Message-ID: <20190208123111.5FDEB61924@lists.varnish-cache.org> commit db97d8eaf5b805cd101d5fb7e04a5b31289012b5 Author: Federico G. Schwindt Date: Fri Nov 2 12:02:38 2018 +0000 Add a debug flag to keep VCL C and so files around Enabled when using varnishtest -L. diff --git a/bin/varnishd/mgt/mgt_vcc.c b/bin/varnishd/mgt/mgt_vcc.c index 9777584f8..2b476307b 100644 --- a/bin/varnishd/mgt/mgt_vcc.c +++ b/bin/varnishd/mgt/mgt_vcc.c @@ -380,7 +380,8 @@ mgt_VccCompile(struct cli *cli, struct vclprog *vcl, const char *vclname, } AZ(fclose(fcs)); - (void)unlink(vp.csrcfile); + if (!MGT_DO_DEBUG(DBG_VCL_KEEP)) + (void)unlink(vp.csrcfile); free(vp.csrcfile); free(vp.dir); diff --git a/bin/varnishd/mgt/mgt_vcl.c b/bin/varnishd/mgt/mgt_vcl.c index 0cb29e44c..0ed9274f6 100644 --- a/bin/varnishd/mgt/mgt_vcl.c +++ b/bin/varnishd/mgt/mgt_vcl.c @@ -265,7 +265,8 @@ mgt_vcl_del(struct vclprog *vp) VTAILQ_REMOVE(&vclhead, vp, list); if (vp->fname != NULL) { - AZ(unlink(vp->fname)); + if (!MGT_DO_DEBUG(DBG_VCL_KEEP)) + AZ(unlink(vp->fname)); p = strrchr(vp->fname, '/'); AN(p); *p = '\0'; diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c index ac7e17adb..0c7b3f5a3 100644 --- a/bin/varnishtest/vtc_varnish.c +++ b/bin/varnishtest/vtc_varnish.c @@ -413,8 +413,9 @@ varnish_launch(struct varnish *v) if (vtc_witness) VSB_cat(vsb, " -p debug=+witness"); if (leave_temp) { - VSB_cat(vsb, " -p debug=+vsm_keep"); + VSB_cat(vsb, " -p debug=+vcl_keep"); VSB_cat(vsb, " -p debug=+vmod_so_keep"); + VSB_cat(vsb, " -p debug=+vsm_keep"); } VSB_printf(vsb, " -l 2m"); VSB_printf(vsb, " -p auto_restart=off"); diff --git a/include/tbl/debug_bits.h b/include/tbl/debug_bits.h index 4ac3ef60f..8bf099d5d 100644 --- a/include/tbl/debug_bits.h +++ b/include/tbl/debug_bits.h @@ -50,6 +50,7 @@ DEBUG_BIT(H2_NOCHECK, h2_nocheck, "Disable various H2 checks") DEBUG_BIT(VMOD_SO_KEEP, vmod_so_keep, "Keep copied VMOD libraries") DEBUG_BIT(PROCESSORS, processors, "Fetch/Deliver processors") DEBUG_BIT(PROTOCOL, protocol, "Protocol debugging") +DEBUG_BIT(VCL_KEEP, vcl_keep, "Keep VCL C and so files") #undef DEBUG_BIT /*lint -restore */ From dridi.boukelmoune at gmail.com Fri Feb 8 12:31:11 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 8 Feb 2019 12:31:11 +0000 (UTC) Subject: [6.0] eac2d9f24 Always keep .c and .so files if vcl_keep is set Message-ID: <20190208123111.8748361930@lists.varnish-cache.org> commit eac2d9f24ee11c17c1807ed9656fdda5a9a8030d Author: Federico G. Schwindt Date: Sun Dec 2 17:29:17 2018 +0000 Always keep .c and .so files if vcl_keep is set Add tests for vcl_keep and move vmod_so_keep together. Reported and diagnosed by jw @ irc. diff --git a/bin/varnishd/mgt/mgt_vcc.c b/bin/varnishd/mgt/mgt_vcc.c index 2b476307b..c42e889d7 100644 --- a/bin/varnishd/mgt/mgt_vcc.c +++ b/bin/varnishd/mgt/mgt_vcc.c @@ -346,11 +346,13 @@ mgt_VccCompile(struct cli *cli, struct vclprog *vcl, const char *vclname, VSB_destroy(&sb); if (status || C_flag) { - (void)unlink(vp.csrcfile); + if (!MGT_DO_DEBUG(DBG_VCL_KEEP)) { + (void)unlink(vp.csrcfile); + (void)unlink(vp.libfile); + (void)rmdir(vp.dir); + } free(vp.csrcfile); - (void)unlink(vp.libfile); free(vp.libfile); - (void)rmdir(vp.dir); free(vp.dir); if (status) { VCLI_Out(cli, "VCL compilation failed"); diff --git a/bin/varnishtest/tests/c00095.vtc b/bin/varnishtest/tests/c00095.vtc new file mode 100644 index 000000000..93ce3c8b6 --- /dev/null +++ b/bin/varnishtest/tests/c00095.vtc @@ -0,0 +1,84 @@ +varnishtest "vcl_keep and vmod_so_keep debug bits" + +feature topbuild + +server s1 { +} -start + +varnish v1 -vcl+backend { +} -start + +# Test valid and invalid VCL with vcl_keep unset + +varnish v1 -cliok "param.set debug -vcl_keep" + +varnish v1 -vcl+backend { +} + +shell -err "test -f ./v1/vcl_vcl2.*/vgc.c" + +varnish v1 -errvcl {No backends or directors found} { +} + +shell -err "test -f ./v1/vcl_vcl3.*/vgc.c" + +# Same but with vcl_keep set + +varnish v1 -cliok "param.set debug +vcl_keep" + +varnish v1 -vcl+backend { +} + +shell { + test -f ./v1/vcl_vcl4.*/vgc.c && + test -f ./v1/vcl_vcl4.*/vgc.so +} + +varnish v1 -errvcl {No backends or directors found} { +} + +shell { + test -f ./v1/vcl_vcl5.*/vgc.c && + test -f ./v1/vcl_vcl5.*/vgc.so +} + +# Test vmod with vmod_so_keep set + +varnish v1 -cliok "param.set debug +vmod_so_keep" + +varnish v1 -vcl+backend { + import std; +} + +shell "test -f ./v1/vmod_cache/_vmod_std.*" + +varnish v1 -stop +varnish v1 -cleanup + +# Ensure these are not deleted on exit + +shell { + test -f ./v1/vcl_vcl4.*/vgc.c && + test -f ./v1/vcl_vcl4.*/vgc.so && + test -f ./v1/vcl_vcl5.*/vgc.c && + test -f ./v1/vcl_vcl5.*/vgc.so && + test -f ./v1/vmod_cache/_vmod_std.* +} + +varnish v2 -vcl+backend { +} -start + +# And test vmod with vmod_so_keep unset + +varnish v2 -cliok "param.set debug -vmod_so_keep" + +varnish v2 -vcl+backend { + import std; +} + +shell "test -f ./v2/vmod_cache/_vmod_std.*" + +varnish v2 -stop +varnish v2 -cleanup + +shell -err "test -f ./v2/vmod_cache/_vmod_std.*" diff --git a/bin/varnishtest/tests/m00008.vtc b/bin/varnishtest/tests/m00008.vtc index 7026f578e..a0bc5b2a3 100644 --- a/bin/varnishtest/tests/m00008.vtc +++ b/bin/varnishtest/tests/m00008.vtc @@ -47,14 +47,3 @@ varnish v1 -errvcl {Malformed VMOD std} { backend default { .host = "${s1_sock}"; } import std from "${topbuild}/lib/libvmod_debug/.libs/libvmod_debug.so"; } - -# Check creation and cleanup of copied shared objects for VMODs -shell "test -e ./v1/vmod_cache/_vmod_std.*" - -# In case varnishtest was invoked with -L or -l, in which case the -# bit is switched on. -varnish v1 -cliok "param.set debug -vmod_so_keep" - -varnish v1 -stop -varnish v1 -cleanup -shell -err "test -e ./v1/vmod_cache/_vmod_std.*" diff --git a/bin/varnishtest/tests/m00030.vtc b/bin/varnishtest/tests/m00030.vtc deleted file mode 100644 index 4ea2e0ede..000000000 --- a/bin/varnishtest/tests/m00030.vtc +++ /dev/null @@ -1,17 +0,0 @@ -varnishtest "debug bit vmod_so_keep" - -feature topbuild - -varnish v1 -vcl { - import std; - backend b { .host = "${bad_backend}"; } -} -start - -shell "test -e ./v1/vmod_cache/_vmod_std.*" - -varnish v1 -cliok "param.set debug +vmod_so_keep" - -# cf m00008.vtc -varnish v1 -stop -varnish v1 -cleanup -shell "test -e ./v1/vmod_cache/_vmod_std.*" From dridi.boukelmoune at gmail.com Fri Feb 8 12:31:11 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 8 Feb 2019 12:31:11 +0000 (UTC) Subject: [6.0] ceafe79aa Update osx build and drop sudo: false Message-ID: <20190208123111.A9B1161935@lists.varnish-cache.org> commit ceafe79aa00637efa3fbcbc3cc2606221f2c736f Author: Federico G. Schwindt Date: Sun Dec 2 18:05:19 2018 +0000 Update osx build and drop sudo: false diff --git a/.travis.yml b/.travis.yml index da2bcbb8b..52424fefc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,5 @@ --- language: c -sudo: false matrix: fast_finish: true include: @@ -16,7 +15,7 @@ matrix: env: CLANG=7 SAN_FLAGS="--enable-asan --enable-ubsan" sudo: required - os: osx - osx_image: xcode10 + osx_image: xcode10.1 compiler: clang allow_failures: - os: osx From dridi.boukelmoune at gmail.com Fri Feb 8 12:31:11 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 8 Feb 2019 12:31:11 +0000 (UTC) Subject: [6.0] 4fc3914f4 Switch to xenial and tidy up Message-ID: <20190208123111.C60696193B@lists.varnish-cache.org> commit 4fc3914f4717e1c29901da3760320c40c3835ac4 Author: Federico G. Schwindt Date: Sun Dec 2 18:27:02 2018 +0000 Switch to xenial and tidy up diff --git a/.travis.yml b/.travis.yml index 52424fefc..8d31d9e04 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,27 +4,31 @@ matrix: fast_finish: true include: - os: linux - dist: trusty + dist: xenial compiler: gcc - os: linux - dist: trusty + dist: xenial compiler: clang - os: linux - dist: trusty + dist: xenial compiler: clang - env: CLANG=7 SAN_FLAGS="--enable-asan --enable-ubsan" - sudo: required + env: SAN_FLAGS="--enable-asan --enable-ubsan" - os: osx osx_image: xcode10.1 compiler: clang allow_failures: - os: osx - - env: CLANG=7 SAN_FLAGS="--enable-asan --enable-ubsan" + - env: SAN_FLAGS="--enable-asan --enable-ubsan" addons: apt: packages: - python-docutils - python-sphinx + homebrew: + packages: + - docutils + - nghttp2 + - sphinx-doc notifications: irc: channels: @@ -34,19 +38,8 @@ notifications: before_install: - | if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then - brew update - brew install docutils sphinx-doc nghttp2 export PATH="/usr/local/opt/sphinx-doc/bin:$PATH" - elif [[ -n "$CLANG" ]]; then - wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - - sudo apt-add-repository -y \ - "deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty-$CLANG main" - sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys BA9EF27F - sudo apt-add-repository -y \ - "deb http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu trusty main" - sudo apt-get update - sudo apt-get install -y clang-$CLANG llvm-$CLANG - export CC=clang-$CLANG + elif [[ -n "$SAN_FLAGS" ]]; then export CONFIGURE_ARGS="--enable-developer-warnings --enable-debugging-symbols --disable-stack-protector --with-persistent-storage ${SAN_FLAGS}" export ASAN_OPTIONS=abort_on_error=1,detect_odr_violation=1,detect_leaks=1,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 From dridi.boukelmoune at gmail.com Fri Feb 8 12:31:11 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 8 Feb 2019 12:31:11 +0000 (UTC) Subject: [6.0] e45fb125d Use upper case for abbreviations. Message-ID: <20190208123111.E0BC461940@lists.varnish-cache.org> commit e45fb125d8c907303d785458e47d9a613f3d668d Author: Lasse Karstensen Date: Sun Dec 2 20:24:17 2018 +0100 Use upper case for abbreviations. Pedantic back-port note: those are acronyms. diff --git a/lib/libvmod_proxy/vmod.vcc b/lib/libvmod_proxy/vmod.vcc index 34b1199b2..79aa4b678 100644 --- a/lib/libvmod_proxy/vmod.vcc +++ b/lib/libvmod_proxy/vmod.vcc @@ -38,14 +38,14 @@ as described in https://www.haproxy.org/download/1.8/doc/proxy-protocol.txt. $Function STRING alpn() Description - Extract alpn attribute. + Extract ALPN attribute. Example set req.http.alpn = proxy.alpn(); $Function STRING authority() Description - Extract authority attribute. This corresponds to sni from a tls + Extract authority attribute. This corresponds to SNI from a TLS connection. Example set req.http.authority = proxy.authority(); @@ -53,7 +53,7 @@ Example $Function BOOL is_ssl() Description - Report if proxy-protocol-v2 has ssl tlv. + Report if proxy-protocol-v2 has SSL TLV. Example | if (proxy.is_ssl()) { @@ -86,7 +86,7 @@ Example $Function STRING ssl_version() Description - Extract ssl version attribute. + Extract SSL version attribute. Example set req.http.ssl-version = proxy.ssl_version(); @@ -100,7 +100,7 @@ Example $Function STRING ssl_cipher() Description - Extract the ssl cipher attribute. + Extract the SSL cipher attribute. Example set req.http.ssl-cipher = proxy.ssl_cipher(); From dridi.boukelmoune at gmail.com Fri Feb 8 12:31:12 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 8 Feb 2019 12:31:12 +0000 (UTC) Subject: [6.0] 8d85c98a8 Improve docs Message-ID: <20190208123112.092AA61944@lists.varnish-cache.org> commit 8d85c98a8d6312b8e8ebdff8dc221104e57c5088 Author: Federico G. Schwindt Date: Sun Dec 2 20:19:22 2018 +0000 Improve docs Partially addresses #2846. I've avoided mentioning NULL on purpose as it's not really meaningful nor accessible from VCL. ymmv. diff --git a/doc/sphinx/reference/vcl.rst b/doc/sphinx/reference/vcl.rst index 7aa434da6..f402c2f06 100644 --- a/doc/sphinx/reference/vcl.rst +++ b/doc/sphinx/reference/vcl.rst @@ -93,7 +93,7 @@ Booleans can be either ``true`` or ``false``. In addition, in a boolean context some data types will evaluate to ``true`` or ``false`` depending on their value. -String types will evaluate to ``false`` if they are empty; backend types +String types will evaluate to ``false`` if they are not set; backend types will evaluate to ``false`` if they don't have a backend assigned; integer types will evaluate to ``false`` if their value is zero; duration types will evaluate to ``false`` if their value is equal or less than zero. @@ -135,18 +135,20 @@ include a fractional part, e.g. ``1.5s``. The supported units are: ``y`` years +In string context they return a string with their value rounded to +3 decimal places and excluding the unit, e.g. ``1.500``. + Integers ~~~~~~~~ Certain fields are integers, used as expected. In string context they -return a string. +return a string, e.g. ``1234``. Real numbers ~~~~~~~~~~~~ -VCL understands real numbers. As with integers, when used in a string -context they will return a string. - +VCL understands real numbers. In string context they return a string +with their value rounded to 3 decimal places, e.g. ``3.142``. Regular Expressions ------------------- From dridi.boukelmoune at gmail.com Fri Feb 8 12:31:12 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 8 Feb 2019 12:31:12 +0000 (UTC) Subject: [6.0] dadb6ebcf More coverage Message-ID: <20190208123112.2B48C6194B@lists.varnish-cache.org> commit dadb6ebcfca40f3ab6a4348236b665e746718483 Author: Federico G. Schwindt Date: Sun Dec 2 21:52:07 2018 +0000 More coverage diff --git a/bin/varnishtest/tests/u00006.vtc b/bin/varnishtest/tests/u00006.vtc index 8dcb2f920..2f1e41476 100644 --- a/bin/varnishtest/tests/u00006.vtc +++ b/bin/varnishtest/tests/u00006.vtc @@ -60,6 +60,25 @@ shell -err -expect "Cannot open output file (No such file or directory)" \ shell -err -expect "Only one of -n and -r options may be used" \ {varnishlog -n ${v1_name} -r ${v1_name}/_.vsm} +shell -err -expect "Expected integer got '}" \ + "varnishlog -q {}" +shell -err -expect "Expected positive integer" \ + "varnishlog -q {-1}" +shell -err -expect "Syntax error in level limit" \ + "varnishlog -q {1a}" +shell -err -expect "Expected VSL tag name got ''" \ + "varnishlog -q ''" +shell -err -expect "Tag name matches zero tags" \ + "varnishlog -q foo" +shell -err -expect "Tag name is ambiguous" \ + "varnishlog -q Resp" +shell -err -expect "Expected string got ''" \ + "varnishlog -q ReqHeader:" +shell -err -expect "Expected integer got ']'" \ + "varnishlog -q ReqHeader:foo[]" +shell -err -expect "Expected positive integer" \ + "varnishlog -q ReqHeader:foo[a]" + process p1 -wait shell {grep -q "0 CLI" ${tmpdir}/vlog} shell -match "0 CLI[ ]+- Wr 200 [0-9]+ PONG" \ From dridi.boukelmoune at gmail.com Fri Feb 8 12:31:12 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 8 Feb 2019 12:31:12 +0000 (UTC) Subject: [6.0] 964d8b784 Try to get this test running on SunOS Message-ID: <20190208123112.4783C61953@lists.varnish-cache.org> commit 964d8b784d48a54366cb8e1582b076bb196c94f4 Author: Federico G. Schwindt Date: Sun Dec 2 23:58:50 2018 +0000 Try to get this test running on SunOS diff --git a/bin/varnishtest/tests/u00006.vtc b/bin/varnishtest/tests/u00006.vtc index 2f1e41476..2f648ab8f 100644 --- a/bin/varnishtest/tests/u00006.vtc +++ b/bin/varnishtest/tests/u00006.vtc @@ -66,18 +66,18 @@ shell -err -expect "Expected positive integer" \ "varnishlog -q {-1}" shell -err -expect "Syntax error in level limit" \ "varnishlog -q {1a}" -shell -err -expect "Expected VSL tag name got ''" \ - "varnishlog -q ''" +shell -err -expect "Expected VSL tag name got '['" \ + {varnishlog -q "[]"} shell -err -expect "Tag name matches zero tags" \ "varnishlog -q foo" shell -err -expect "Tag name is ambiguous" \ "varnishlog -q Resp" -shell -err -expect "Expected string got ''" \ - "varnishlog -q ReqHeader:" +shell -err -expect "Expected string got '['" \ + {varnishlog -q "ReqHeader:[]"} shell -err -expect "Expected integer got ']'" \ - "varnishlog -q ReqHeader:foo[]" + {varnishlog -q "ReqHeader:foo[]"} shell -err -expect "Expected positive integer" \ - "varnishlog -q ReqHeader:foo[a]" + {varnishlog -q "ReqHeader:foo[a]"} process p1 -wait shell {grep -q "0 CLI" ${tmpdir}/vlog} From dridi.boukelmoune at gmail.com Fri Feb 8 12:31:12 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 8 Feb 2019 12:31:12 +0000 (UTC) Subject: [6.0] 5458c8b83 fix vmod object constructor documentation Message-ID: <20190208123112.6591B6195C@lists.varnish-cache.org> commit 5458c8b8318c49a272e38a13bcae4d312c817880 Author: Nils Goroll Date: Fri Oct 26 12:34:25 2018 +0200 fix vmod object constructor documentation The vmod name got lost in e7c0497404a5b4aadda71aead3b0e7fe946d6993 example before/after diff: - new xshard_param = shard_param() + new xshard_param = directors.shard_param() diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py index 2ef32e78c..23f372ce7 100755 --- a/lib/libvcc/vmodtool.py +++ b/lib/libvcc/vmodtool.py @@ -368,11 +368,13 @@ class ProtoType(object): pfx += pfx s = pfx if type(self.st) == s_object: - s += "new x" + self.bname + " = " + s += "new " + self.obj + " = " elif self.retval is not None: s += self.retval.vcl() + " " - if type(self.st) == s_method: + if type(self.st) == s_object: + s += self.st.vcc.modname + "." + self.name + "(" + elif type(self.st) == s_method: s += self.obj + self.bname + "(" else: s += self.name + "(" From dridi.boukelmoune at gmail.com Fri Feb 8 12:31:12 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 8 Feb 2019 12:31:12 +0000 (UTC) Subject: [6.0] 0fdc2c9f6 Some pylinting Message-ID: <20190208123112.8269A61962@lists.varnish-cache.org> commit 0fdc2c9f6e89a4bcd4019d3e2fc3cf05fb9c31d6 Author: Poul-Henning Kamp Date: Mon Dec 3 09:53:20 2018 +0000 Some pylinting diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py index 23f372ce7..92863055f 100755 --- a/lib/libvcc/vmodtool.py +++ b/lib/libvcc/vmodtool.py @@ -120,12 +120,12 @@ CTYPES.update(PRIVS) ####################################################################### -def is_quoted(str): - return len(str) > 2 and str[0] == str[-1] and str[0] in ('"', "'") +def is_quoted(txt): + return len(txt) > 2 and txt[0] == txt[-1] and txt[0] in ('"', "'") -def unquote(str): - assert is_quoted(str) - return str[1:-1] +def unquote(txt): + assert is_quoted(txt) + return txt[1:-1] ####################################################################### @@ -364,17 +364,17 @@ class ProtoType(object): self.args.append(t) def vcl_proto(self, short, pfx=""): - if type(self.st) == s_method: + if isinstance(self.st, MethodStanza): pfx += pfx s = pfx - if type(self.st) == s_object: + if isinstance(self.st, ObjectStanza): s += "new " + self.obj + " = " elif self.retval is not None: s += self.retval.vcl() + " " - if type(self.st) == s_object: + if isinstance(self.st, ObjectStanza): s += self.st.vcc.modname + "." + self.name + "(" - elif type(self.st) == s_method: + elif isinstance(self.st, MethodStanza): s += self.obj + self.bname + "(" else: s += self.name + "(" @@ -414,7 +414,7 @@ class ProtoType(object): write_rst_hdr(fo, s, '-') fo.write("\n::\n\n" + self.vcl_proto(False, pfx=" ") + "\n") - def synopsis(self, fo, man): + def synopsis(self, fo, unused_man): fo.write(self.vcl_proto(True, pfx=" ") + "\n") fo.write(" \n") @@ -489,7 +489,7 @@ class ProtoType(object): ####################################################################### -class stanza(object): +class Stanza(object): def __init__(self, toks, l0, doc, vcc): self.toks = toks self.line = l0 @@ -504,6 +504,9 @@ class stanza(object): self.proto = None self.parse() + def parse(self): + assert "subclass should have defined" == "parse method" + def dump(self): print(type(self), self.line) @@ -524,34 +527,33 @@ class stanza(object): self.rsttail(fo, man) fo.write("\n") - def rsthead(self, fo, man): - if self.proto is None: - return - self.proto.rsthead(fo) + def rsthead(self, fo, unused_man): + if self.proto is not None: + self.proto.rsthead(fo) - def rstmid(self, fo, man): + def rstmid(self, fo, unused_man): fo.write("\n".join(self.doc) + "\n") - def rsttail(self, fo, man): + def rsttail(self, unused_fo, unused_man): return def synopsis(self, fo, man): if self.proto is not None: self.proto.synopsis(fo, man) - def cstuff(self, fo, where): + def cstuff(self, unused_fo, unused_where): return - def cstruct(self, fo, define): + def cstruct(self, unused_fo, unused_define): return - def json(self, jl): + def json(self, unused_jl): return ####################################################################### -class s_module(stanza): +class ModuleStanza(Stanza): ''' $Module modname man_section description ... ''' @@ -617,7 +619,7 @@ class s_module(stanza): fo.write("\n") -class s_abi(stanza): +class ABIStanza(Stanza): ''' $ABI [strict|vrt] ''' @@ -635,7 +637,7 @@ class s_abi(stanza): self.vcc.contents.append(self) -class s_prefix(stanza): +class PrefixStanza(Stanza): ''' $Prefix symbol ''' @@ -646,7 +648,7 @@ class s_prefix(stanza): self.vcc.contents.append(self) -class s_synopsis(stanza): +class SynopsisStanza(Stanza): ''' $Synopsis [auto|manual] ''' @@ -664,7 +666,7 @@ class s_synopsis(stanza): self.vcc.contents.append(self) -class s_event(stanza): +class EventStanza(Stanza): ''' $Event function_name ''' @@ -696,7 +698,7 @@ class s_event(stanza): ]) -class s_function(stanza): +class FunctionStanza(Stanza): def parse(self): self.proto = ProtoType(self) self.rstlbl = "func_" + self.proto.name @@ -716,7 +718,7 @@ class s_function(stanza): self.proto.json(jl[-1], self.proto.cname()) -class s_object(stanza): +class ObjectStanza(Stanza): def parse(self): self.proto = ProtoType(self, retval=False) self.proto.obj = "x" + self.proto.name @@ -741,7 +743,7 @@ class s_object(stanza): for i in self.methods: i.rstfile(fo, man) - def rstmid(self, fo, man): + def rstmid(self, unused_fo, unused_man): return def synopsis(self, fo, man): @@ -794,17 +796,17 @@ class s_object(stanza): jl.append(ll) def dump(self): - super(s_object, self).dump() + super(ObjectStanza, self).dump() for i in self.methods: i.dump() ####################################################################### -class s_method(stanza): +class MethodStanza(Stanza): def parse(self): p = self.vcc.contents[-1] - assert type(p) == s_object + assert isinstance(p, ObjectStanza) self.pfx = p.proto.name self.proto = ProtoType(self, prefix=self.pfx) if not self.proto.bname.startswith("."): @@ -828,18 +830,21 @@ class s_method(stanza): ####################################################################### DISPATCH = { - "Module": s_module, - "Prefix": s_prefix, - "ABI": s_abi, - "Event": s_event, - "Function": s_function, - "Object": s_object, - "Method": s_method, - "Synopsis": s_synopsis, + "Module": ModuleStanza, + "Prefix": PrefixStanza, + "ABI": ABIStanza, + "Event": EventStanza, + "Function": FunctionStanza, + "Object": ObjectStanza, + "Method": MethodStanza, + "Synopsis": SynopsisStanza, } class vcc(object): + + ''' Processing context for a single .vcc file ''' + def __init__(self, inputvcc, rstdir, outputprefix): self.inputfile = inputvcc self.rstdir = rstdir @@ -880,7 +885,7 @@ class vcc(object): m(toks, [c[0], " ".join(c[1:])], d.split('\n'), self) inputline = None - def tokenize(self, str, seps=None, quotes=None): + def tokenize(self, txt, seps=None, quotes=None): if seps is None: seps = "[](){},=" if quotes is None: @@ -889,8 +894,8 @@ class vcc(object): out = [] i = 0 inside = False - while i < len(str): - c = str[i] + while i < len(txt): + c = txt[i] # print("T", [c], quote, inside, i) i += 1 if quote is not None and c == quote: @@ -1053,13 +1058,13 @@ class vcc(object): fo.write("\n") for i in self.contents: - if type(i) == s_object: + if isinstance(i, ObjectStanza): i.cstuff(fo, 'c') i.cstuff(fx, 'o') fx.write("/* Functions */\n") for i in self.contents: - if type(i) == s_function: + if isinstance(i, FunctionStanza): i.cstuff(fo, 'c') i.cstuff(fx, 'o') From dridi.boukelmoune at gmail.com Fri Feb 8 12:31:12 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 8 Feb 2019 12:31:12 +0000 (UTC) Subject: [6.0] b0a2afed3 Make it possible to change ncurses update rate. Message-ID: <20190208123112.A11F461967@lists.varnish-cache.org> commit b0a2afed38d217b4c4e8e4108f46ce9f54b1772b Author: Lasse Karstensen Date: Thu Aug 16 09:14:21 2018 +0200 Make it possible to change ncurses update rate. This is a squashed commit including lint removal and formatting suggested by @nigoroll. diff --git a/bin/varnishstat/varnishstat.c b/bin/varnishstat/varnishstat.c index be9e64c79..0ab37c1ac 100644 --- a/bin/varnishstat/varnishstat.c +++ b/bin/varnishstat/varnishstat.c @@ -324,7 +324,7 @@ main(int argc, char * const *argv) AN(VSC_Arg(vsc, 'f', "MAIN.cache_hit")); AN(VSC_Arg(vsc, 'f', "MAIN.cache_miss")); } - do_curses(vd, vsc, 1.0); + do_curses(vd, vsc); } else if (xml) do_xml(vd, vsc); diff --git a/bin/varnishstat/varnishstat.h b/bin/varnishstat/varnishstat.h index 6a73ef238..00099ea02 100644 --- a/bin/varnishstat/varnishstat.h +++ b/bin/varnishstat/varnishstat.h @@ -35,4 +35,4 @@ #include "vas.h" #include "vcs.h" -void do_curses(struct vsm *, struct vsc *, double); +void do_curses(struct vsm *, struct vsc *); diff --git a/bin/varnishstat/varnishstat_curses.c b/bin/varnishstat/varnishstat_curses.c index ad9c22135..b44ee70d8 100644 --- a/bin/varnishstat/varnishstat_curses.c +++ b/bin/varnishstat/varnishstat_curses.c @@ -435,6 +435,8 @@ draw_status(void) mvwprintw(w_status, 1, 0, "Uptime child: "); running(w_status, up_chld, VSM_WRK_RUNNING); + mvwprintw(w_status, 0, 55, "Refresh interval: %.3fs", interval); + if (COLS > 70) { mvwprintw(w_status, 0, getmaxx(w_status) - 37, "Hitrate n: %8u %8u %8u", hitrate.hr_10.n, hitrate.hr_100.n, @@ -899,6 +901,14 @@ handle_keypress(int ch) current = n_ptarray - 1; page_start = (current - l_points) + 1; break; + case '+': + interval += 0.1; + break; + case '-': + interval -= 0.1; + if (interval < 0.1) + interval = 0.1; + break; case 'v': verbosity = VSC_ChangeLevel(verbosity, 1); rebuild = 1; @@ -980,14 +990,12 @@ delpt(void *priv, const struct VSC_point *const vpt) } void -do_curses(struct vsm *vsm, struct vsc *vsc, double delay) +do_curses(struct vsm *vsm, struct vsc *vsc) { long t; int ch; double now; - interval = delay; - verbosity = VSC_ChangeLevel(NULL, 0); initscr(); diff --git a/doc/sphinx/reference/varnishstat.rst b/doc/sphinx/reference/varnishstat.rst index 89f1f2732..023a6d784 100644 --- a/doc/sphinx/reference/varnishstat.rst +++ b/doc/sphinx/reference/varnishstat.rst @@ -109,6 +109,13 @@ The following keys control the interactive display: Sample now. +<+> + Increase refresh interval. + +<-> + Decrease refresh interval. + + OUTPUTS ======= From dridi.boukelmoune at gmail.com Fri Feb 8 12:31:12 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 8 Feb 2019 12:31:12 +0000 (UTC) Subject: [6.0] ab965b7f4 Add a notification field for temporary messages. Message-ID: <20190208123112.BBA986196D@lists.varnish-cache.org> commit ab965b7f40b5a15d8aec36d09e706c696967fb5d Author: Lasse Karstensen Date: Sun Dec 2 22:09:32 2018 +0100 Add a notification field for temporary messages. diff --git a/bin/varnishstat/varnishstat_curses.c b/bin/varnishstat/varnishstat_curses.c index b44ee70d8..4ae43643d 100644 --- a/bin/varnishstat/varnishstat_curses.c +++ b/bin/varnishstat/varnishstat_curses.c @@ -120,6 +120,10 @@ static double t_sample = 0.; static double interval = 1.; static unsigned vsm_status = 0; +#define NOTIF_MAXLEN 256 +static char notification_message[NOTIF_MAXLEN] = ""; +static double notification_eol = 0.0; + static void init_hitrate(void) { @@ -435,7 +439,8 @@ draw_status(void) mvwprintw(w_status, 1, 0, "Uptime child: "); running(w_status, up_chld, VSM_WRK_RUNNING); - mvwprintw(w_status, 0, 55, "Refresh interval: %.3fs", interval); + if (VTIM_mono() < notification_eol) + mvwaddstr(w_status, 2, 0, notification_message); if (COLS > 70) { mvwprintw(w_status, 0, getmaxx(w_status) - 37, @@ -903,11 +908,19 @@ handle_keypress(int ch) break; case '+': interval += 0.1; + (void)snprintf(notification_message, NOTIF_MAXLEN, + "Refresh interval set to %.1f seconds.", interval); + + notification_eol = VTIM_mono() + 1.25; break; case '-': interval -= 0.1; if (interval < 0.1) interval = 0.1; + (void)snprintf(notification_message, NOTIF_MAXLEN, + "Refresh interval set to %.1f seconds.", interval); + + notification_eol = VTIM_mono() + 1.25; break; case 'v': verbosity = VSC_ChangeLevel(verbosity, 1); From dridi.boukelmoune at gmail.com Fri Feb 8 12:31:12 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 8 Feb 2019 12:31:12 +0000 (UTC) Subject: [6.0] bc039486e Add test coverage for ncurses update interval. Message-ID: <20190208123112.D85D961978@lists.varnish-cache.org> commit bc039486e4932eed9c31bfd3556f21c9706ae369 Author: Lasse Karstensen Date: Sun Dec 2 22:29:16 2018 +0100 Add test coverage for ncurses update interval. diff --git a/bin/varnishtest/tests/u00008.vtc b/bin/varnishtest/tests/u00008.vtc index 5e1beff3e..0c35fb3fc 100644 --- a/bin/varnishtest/tests/u00008.vtc +++ b/bin/varnishtest/tests/u00008.vtc @@ -1,4 +1,4 @@ -varnishtest "trivial run of varnistat in curses mode" +varnishtest "trivial run of varnishstat in curses mode" server s1 -repeat 4 { rxreq @@ -24,6 +24,14 @@ client c1 { process p1 -expect-text 0 0 "MAIN.s_sess" process p1 -screen_dump +process p1 -write {+} +process p1 -screen_dump +process p1 -expect-text 0 0 "Refresh interval set to 1.1 seconds." + +process p1 -write {-} +process p1 -screen_dump +process p1 -expect-text 0 0 "Refresh interval set to 1.0 seconds." + process p1 -write {vG} process p1 -expect-text 0 0 "VBE.vcl1.s1.req" process p1 -expect-text 0 0 "DIAG" From dridi.boukelmoune at gmail.com Fri Feb 8 12:31:13 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 8 Feb 2019 12:31:13 +0000 (UTC) Subject: [6.0] 14cfe437d vtim-ification Message-ID: <20190208123113.080DF6197E@lists.varnish-cache.org> commit 14cfe437dd177ef4170f2175ab92e1b6c0a57dd5 Author: Nils Goroll Date: Mon Dec 3 12:30:13 2018 +0100 vtim-ification Inclused re-declaration fixes for some places which I got wrong in the past. Conflicts: bin/varnishd/cache/cache_objhead.h diff --git a/bin/varnishd/cache/cache_obj.h b/bin/varnishd/cache/cache_obj.h index bdb6795bd..5229b7e00 100644 --- a/bin/varnishd/cache/cache_obj.h +++ b/bin/varnishd/cache/cache_obj.h @@ -46,7 +46,7 @@ typedef const void *objgetattr_f(struct worker *, struct objcore *, enum obj_attr attr, ssize_t *len); typedef void *objsetattr_f(struct worker *, struct objcore *, enum obj_attr attr, ssize_t len, const void *ptr); -typedef void objtouch_f(struct worker *, struct objcore *, double now); +typedef void objtouch_f(struct worker *, struct objcore *, vtim_real now); struct obj_methods { objfree_f *objfree; diff --git a/bin/varnishd/cache/cache_objhead.h b/bin/varnishd/cache/cache_objhead.h index 6bcb7b301..9e90d5b32 100644 --- a/bin/varnishd/cache/cache_objhead.h +++ b/bin/varnishd/cache/cache_objhead.h @@ -72,7 +72,7 @@ enum lookup_e HSH_Lookup(struct req *, struct objcore **, struct objcore **, int always_insert); void HSH_Ref(struct objcore *o); void HSH_AddString(struct req *, void *ctx, const char *str); -unsigned HSH_Purge(struct worker *, struct objhead *, double ttl_now, - double ttl, double grace, double keep); +unsigned HSH_Purge(struct worker *, struct objhead *, vtim_real ttl_now, + vtim_dur ttl, vtim_dur grace, vtim_dur keep); struct objcore *HSH_Private(const struct worker *wrk); void HSH_Abandon(struct objcore *oc); diff --git a/bin/varnishd/cache/cache_rfc2616.c b/bin/varnishd/cache/cache_rfc2616.c index ddecb9c4e..c9341fdd0 100644 --- a/bin/varnishd/cache/cache_rfc2616.c +++ b/bin/varnishd/cache/cache_rfc2616.c @@ -62,11 +62,11 @@ */ void -RFC2616_Ttl(struct busyobj *bo, double now, double *t_origin, +RFC2616_Ttl(struct busyobj *bo, vtim_real now, vtim_real *t_origin, float *ttl, float *grace, float *keep) { unsigned max_age, age; - double h_date, h_expires; + vtim_real h_date, h_expires; const char *p; const struct http *hp; @@ -258,7 +258,7 @@ int RFC2616_Do_Cond(const struct req *req) { const char *p, *e; - double ims, lm; + vtim_real ims, lm; /* * We MUST ignore If-Modified-Since if we have an If-None-Match diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c index b6faa8222..4141dfa21 100644 --- a/bin/varnishd/cache/cache_session.c +++ b/bin/varnishd/cache/cache_session.c @@ -253,7 +253,7 @@ HTC_RxPipeline(struct http_conn *htc, void *p) enum htc_status_e HTC_RxStuff(struct http_conn *htc, htc_complete_f *func, - double *t1, double *t2, double ti, double tn, int maxbytes) + vtim_real *t1, vtim_real *t2, vtim_real ti, vtim_real tn, int maxbytes) { vtim_dur tmo; vtim_real now; diff --git a/bin/varnishd/cache/cache_shmlog.c b/bin/varnishd/cache/cache_shmlog.c index e4db8158f..83e22f2f9 100644 --- a/bin/varnishd/cache/cache_shmlog.c +++ b/bin/varnishd/cache/cache_shmlog.c @@ -373,8 +373,8 @@ VSLb(struct vsl_log *vsl, enum VSL_tag_e tag, const char *fmt, ...) } void -VSLb_ts(struct vsl_log *vsl, const char *event, double first, double *pprev, - double now) +VSLb_ts(struct vsl_log *vsl, const char *event, vtim_real first, + vtim_real *pprev, vtim_real now) { /* XXX: Make an option to turn off some unnecessary timestamp diff --git a/bin/varnishd/cache/cache_tcp_pool.c b/bin/varnishd/cache/cache_tcp_pool.c index dbc12c685..9d623ef9c 100644 --- a/bin/varnishd/cache/cache_tcp_pool.c +++ b/bin/varnishd/cache/cache_tcp_pool.c @@ -66,7 +66,8 @@ struct pfd { /*-------------------------------------------------------------------- */ -typedef int cp_open_f(const struct conn_pool *, double tmo, const void **privp); +typedef int cp_open_f(const struct conn_pool *, vtim_dur tmo, + const void **privp); typedef void cp_close_f(struct pfd *); typedef int cp_cmp_f(const struct conn_pool *, const void *priv); typedef void cp_name_f(const struct pfd *, char *, unsigned, char *, unsigned); @@ -100,7 +101,7 @@ struct conn_pool { int n_used; - double holddown; + vtim_mono holddown; int holddown_errno; }; @@ -158,7 +159,7 @@ PFD_RemoteName(const struct pfd *p, char *abuf, unsigned alen, char *pbuf, */ static void v_matchproto_(waiter_handle_f) -vcp_handle(struct waited *w, enum wait_event ev, double now) +vcp_handle(struct waited *w, enum wait_event ev, vtim_real now) { struct pfd *pfd; struct conn_pool *cp; @@ -377,10 +378,10 @@ VCP_Recycle(const struct worker *wrk, struct pfd **pfdp) */ static int -VCP_Open(struct conn_pool *cp, double tmo, const void **privp, int *err) +VCP_Open(struct conn_pool *cp, vtim_dur tmo, const void **privp, int *err) { int r; - double h; + vtim_mono h; CHECK_OBJ_NOTNULL(cp, CONN_POOL_MAGIC); AN(err); @@ -487,7 +488,7 @@ VCP_Close(struct pfd **pfdp) */ static struct pfd * -VCP_Get(struct conn_pool *cp, double tmo, struct worker *wrk, +VCP_Get(struct conn_pool *cp, vtim_dur tmo, struct worker *wrk, unsigned force_fresh, int *err) { struct pfd *pfd; @@ -579,13 +580,13 @@ struct vtp_cs { }; static inline int -tmo2msec(double tmo) +tmo2msec(vtim_dur tmo) { return ( (int)floor(tmo * 1000.0) ); } static int v_matchproto_(cp_open_f) -vtp_open(const struct conn_pool *cp, double tmo, const void **privp) +vtp_open(const struct conn_pool *cp, vtim_dur tmo, const void **privp) { int s; int msec; @@ -673,7 +674,7 @@ static const struct cp_methods vtp_methods = { */ static int v_matchproto_(cp_open_f) -vus_open(const struct conn_pool *cp, double tmo, const void **privp) +vus_open(const struct conn_pool *cp, vtim_dur tmo, const void **privp) { int s; int msec; @@ -801,7 +802,7 @@ VTP_Rel(struct tcp_pool **tpp) */ int -VTP_Open(struct tcp_pool *tp, double tmo, const void **privp, int *err) +VTP_Open(struct tcp_pool *tp, vtim_dur tmo, const void **privp, int *err) { return (VCP_Open(tp->cp, tmo, privp, err)); } diff --git a/bin/varnishd/cache/cache_tcp_pool.h b/bin/varnishd/cache/cache_tcp_pool.h index 57564ba96..3c872336f 100644 --- a/bin/varnishd/cache/cache_tcp_pool.h +++ b/bin/varnishd/cache/cache_tcp_pool.h @@ -72,7 +72,7 @@ void VTP_Rel(struct tcp_pool **); * the pool is destroyed and all cached connections closed. */ -int VTP_Open(struct tcp_pool *, double tmo, const void **, int*); +int VTP_Open(struct tcp_pool *, vtim_dur tmo, const void **, int*); /* * Open a new connection and return the adress used. * errno will be returned in the last argument. diff --git a/bin/varnishd/cache/cache_transport.h b/bin/varnishd/cache/cache_transport.h index 5de0920a3..5da5e3501 100644 --- a/bin/varnishd/cache/cache_transport.h +++ b/bin/varnishd/cache/cache_transport.h @@ -79,7 +79,7 @@ void VPX_Send_Proxy(int fd, int version, const struct sess *); /* cache_session.c */ struct sess *SES_New(struct pool *); -void SES_Delete(struct sess *, enum sess_close reason, double now); +void SES_Delete(struct sess *, enum sess_close reason, vtim_real now); void SES_Close(struct sess *, enum sess_close reason); void SES_SetTransport(struct worker *, struct sess *, struct req *, const struct transport *); diff --git a/bin/varnishd/cache/cache_varnishd.h b/bin/varnishd/cache/cache_varnishd.h index 365b821fc..45aba733a 100644 --- a/bin/varnishd/cache/cache_varnishd.h +++ b/bin/varnishd/cache/cache_varnishd.h @@ -261,7 +261,7 @@ void ObjSetState(struct worker *, const struct objcore *, enum boc_state_e next); void ObjWaitState(const struct objcore *, enum boc_state_e want); void ObjTrimStore(struct worker *, struct objcore *); -void ObjTouch(struct worker *, struct objcore *, double now); +void ObjTouch(struct worker *, struct objcore *, vtim_real now); void ObjFreeObj(struct worker *, struct objcore *); void ObjSlim(struct worker *, struct objcore *); void *ObjSetAttr(struct worker *, struct objcore *, enum obj_attr, @@ -347,7 +347,7 @@ const char * HTC_Status(enum htc_status_e); void HTC_RxInit(struct http_conn *htc, struct ws *ws); void HTC_RxPipeline(struct http_conn *htc, void *); enum htc_status_e HTC_RxStuff(struct http_conn *, htc_complete_f *, - double *t1, double *t2, double ti, double tn, int maxbytes); + vtim_real *t1, vtim_real *t2, vtim_real ti, vtim_real tn, int maxbytes); #define SESS_ATTR(UP, low, typ, len) \ int SES_Set_##low(const struct sess *sp, const typ *src); \ diff --git a/bin/varnishd/fuzzers/esi_parse_fuzzer.c b/bin/varnishd/fuzzers/esi_parse_fuzzer.c index c09c888ba..972ffa0b1 100644 --- a/bin/varnishd/fuzzers/esi_parse_fuzzer.c +++ b/bin/varnishd/fuzzers/esi_parse_fuzzer.c @@ -56,8 +56,8 @@ VSLb(struct vsl_log *vsl, enum VSL_tag_e tag, const char *fmt, ...) } void -VSLb_ts(struct vsl_log *l, const char *event, double first, double *pprev, - double now) +VSLb_ts(struct vsl_log *l, const char *event, vtim_real first, vtim_real *pprev, + vtim_real now) { (void)l; (void)event; diff --git a/bin/varnishd/waiter/waiter.h b/bin/varnishd/waiter/waiter.h index 531f640d7..4a0d8a7d5 100644 --- a/bin/varnishd/waiter/waiter.h +++ b/bin/varnishd/waiter/waiter.h @@ -52,7 +52,7 @@ enum wait_event { WAITER_CLOSE }; -typedef void waiter_handle_f(struct waited *, enum wait_event, double now); +typedef void waiter_handle_f(struct waited *, enum wait_event, vtim_real now); struct waited { unsigned magic; @@ -62,8 +62,8 @@ struct waited { void *priv1; uintptr_t priv2; waiter_handle_f *func; - volatile double *tmo; - double idle; + volatile vtim_real *tmo; + vtim_real idle; }; /* cache_waiter.c */ diff --git a/bin/varnishstat/varnishstat_curses.c b/bin/varnishstat/varnishstat_curses.c index 4ae43643d..4b1703e6c 100644 --- a/bin/varnishstat/varnishstat_curses.c +++ b/bin/varnishstat/varnishstat_curses.c @@ -122,7 +122,7 @@ static unsigned vsm_status = 0; #define NOTIF_MAXLEN 256 static char notification_message[NOTIF_MAXLEN] = ""; -static double notification_eol = 0.0; +static vtim_mono notification_eol = 0.0; static void init_hitrate(void) diff --git a/include/vnum.h b/include/vnum.h index b24545015..266f156f5 100644 --- a/include/vnum.h +++ b/include/vnum.h @@ -31,5 +31,5 @@ /* from libvarnish/vnum.c */ double VNUM(const char *p); double VNUMpfx(const char *p, const char **e); -double VNUM_duration(const char *p); +vtim_dur VNUM_duration(const char *p); const char *VNUM_2bytes(const char *p, uintmax_t *r, uintmax_t rel); diff --git a/include/vtim.h b/include/vtim.h index 1968bc568..b1898a39d 100644 --- a/include/vtim.h +++ b/include/vtim.h @@ -31,10 +31,10 @@ /* from libvarnish/vtim.c */ extern unsigned VTIM_postel; #define VTIM_FORMAT_SIZE 30 -void VTIM_format(double t, char *p); -double VTIM_parse(const char *p); +void VTIM_format(vtim_real t, char *p); +vtim_real VTIM_parse(const char *p); vtim_mono VTIM_mono(void); vtim_real VTIM_real(void); void VTIM_sleep(vtim_dur t); -struct timespec VTIM_timespec(vtim_dur t); -struct timeval VTIM_timeval(vtim_dur t); +struct timespec VTIM_timespec(vtim_real t); +struct timeval VTIM_timeval(vtim_real t); diff --git a/lib/libvmod_directors/shard_dir.c b/lib/libvmod_directors/shard_dir.c index 01f044fff..a936e08d6 100644 --- a/lib/libvmod_directors/shard_dir.c +++ b/lib/libvmod_directors/shard_dir.c @@ -165,7 +165,7 @@ shard_next(struct shard_state *state, VCL_INT skip, VCL_BOOL healthy) int c, chosen = -1; uint32_t ringsz; VCL_BACKEND be; - double changed; + vtim_real changed; struct shard_be_info *sbe; AN(state); @@ -312,7 +312,7 @@ sharddir_any_healthy(struct sharddir *shardd, const struct busyobj *bo, unsigned retval = 0; VCL_BACKEND be; unsigned u; - double c; + vtim_real c; CHECK_OBJ_NOTNULL(shardd, SHARDDIR_MAGIC); CHECK_OBJ_ORNULL(bo, BUSYOBJ_MAGIC); diff --git a/lib/libvmod_directors/vdir.c b/lib/libvmod_directors/vdir.c index 84895c365..78f8d9c40 100644 --- a/lib/libvmod_directors/vdir.c +++ b/lib/libvmod_directors/vdir.c @@ -180,7 +180,7 @@ vdir_any_healthy(struct vdir *vd, const struct busyobj *bo, double *changed) unsigned retval = 0; VCL_BACKEND be; unsigned u; - double c; + vtim_real c; CHECK_OBJ_NOTNULL(vd, VDIR_MAGIC); CHECK_OBJ_ORNULL(bo, BUSYOBJ_MAGIC); From dridi.boukelmoune at gmail.com Fri Feb 8 12:31:13 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 8 Feb 2019 12:31:13 +0000 (UTC) Subject: [6.0] 9e77fc812 Add some testing bits for VSL -R Message-ID: <20190208123113.2A84461986@lists.varnish-cache.org> commit 9e77fc8121bf58c4d3cffae4b14c92352c2e495e Author: Dag Haavi Finstad Date: Mon Dec 3 11:39:42 2018 +0100 Add some testing bits for VSL -R diff --git a/bin/varnishtest/tests/u00003.vtc b/bin/varnishtest/tests/u00003.vtc index e18d9b912..cd4a4880a 100644 --- a/bin/varnishtest/tests/u00003.vtc +++ b/bin/varnishtest/tests/u00003.vtc @@ -26,7 +26,7 @@ varnish v1 -vcl+backend { shell { varnishncsa -n ${v1_name} -D -P ${tmpdir}/ncsa.pid \ - -w ${tmpdir}/ncsa.log + -w ${tmpdir}/ncsa.log -R 100/s } delay 1 diff --git a/bin/varnishtest/tests/u00006.vtc b/bin/varnishtest/tests/u00006.vtc index 2f648ab8f..9ffb331e7 100644 --- a/bin/varnishtest/tests/u00006.vtc +++ b/bin/varnishtest/tests/u00006.vtc @@ -12,7 +12,7 @@ process p1 { } -start shell { exec varnishlog -n ${v1_name} -D -P ${tmpdir}/vlog.pid \ - -w ${tmpdir}/vlog.bin + -w ${tmpdir}/vlog.bin -R 10/s } shell -match "Usage: .*varnishlog " \ @@ -79,6 +79,25 @@ shell -err -expect "Expected integer got ']'" \ shell -err -expect "Expected positive integer" \ {varnishlog -q "ReqHeader:foo[a]"} +shell -err -expect "-R: Syntax error" \ + "varnishlog -R 1foo" +shell -err -expect "-R: Range error" \ + "varnishlog -R 0" +shell -err -expect "-R: Range error" \ + "varnishlog -R -1" +shell -err -expect "-R: Range error" \ + "varnishlog -R 3000000000" +shell -err -expect "-R: Syntax error: Invalid duration" \ + "varnishlog -R 10/0s" +shell -err -expect "-R: Syntax error: Invalid duration" \ + "varnishlog -R 10/-10s" +shell -err -expect "-R: Syntax error: Invalid duration" \ + "varnishlog -R 10/1q" +shell -err -expect "-R: Syntax error: Invalid duration" \ + "varnishlog -R 10/11f09s" +shell -err -expect "-R: Syntax error" \ + "varnishlog -R 1000000000/1000000000000000000000000000000s" + process p1 -wait shell {grep -q "0 CLI" ${tmpdir}/vlog} shell -match "0 CLI[ ]+- Wr 200 [0-9]+ PONG" \ From dridi.boukelmoune at gmail.com Fri Feb 8 12:31:13 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 8 Feb 2019 12:31:13 +0000 (UTC) Subject: [6.0] ceed5fe67 Tolerate null IP addresses for ACL matches Message-ID: <20190208123113.4E5F261996@lists.varnish-cache.org> commit ceed5fe671111abeb05676ba770ba5be7e89fd4a Author: Dridi Boukelmoune Date: Wed Nov 28 11:30:18 2018 +0100 Tolerate null IP addresses for ACL matches A vmod may return a null IP. This relaxes the check in VRT_acl_match to fail the transaction instead of crashing. Refs #2842 diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c index 9f838132f..4ff427f35 100644 --- a/bin/varnishd/cache/cache_vrt.c +++ b/bin/varnishd/cache/cache_vrt.c @@ -83,6 +83,10 @@ VRT_acl_match(VRT_CTX, VCL_ACL acl, VCL_IP ip) CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(acl, VRT_ACL_MAGIC); + if (ip == NULL) { + VRT_fail(ctx, "Cannot match a null IP address"); + return (0); + } assert(VSA_Sane(ip)); return (acl->match(ctx, ip)); } diff --git a/bin/varnishtest/tests/r01504.vtc b/bin/varnishtest/tests/r01504.vtc index 02182a519..9767ff0b4 100644 --- a/bin/varnishtest/tests/r01504.vtc +++ b/bin/varnishtest/tests/r01504.vtc @@ -1,10 +1,26 @@ -varnishtest "unreferenced acls" +varnishtest "unreferenced or null acls" varnish v1 -arg "-p vcc_err_unref=off" -vcl { + import vtc; backend s1 { - .host = "127.0.0.1"; + .host = "${bad_backend}"; } acl foo { "127.0.0.1"; } -} + acl bar { + "127.0.0.1"; + } + sub vcl_recv { + if (vtc.no_ip() ~ bar) { + return (synth(200)); + } + } +} -start + +client c1 { + txreq + rxresp + expect resp.status == 503 + expect resp.body ~ "VCL failed" +} -run diff --git a/lib/libvmod_vtc/vmod.vcc b/lib/libvmod_vtc/vmod.vcc index 94f8f75b6..248f4b2d6 100644 --- a/lib/libvmod_vtc/vmod.vcc +++ b/lib/libvmod_vtc/vmod.vcc @@ -66,6 +66,10 @@ $Function STEVEDORE no_stevedore() Fails at storage selection. +$Function IP no_ip() + +Returns a null IP address, not even a bogo_ip. + $Function VOID panic(STRING_LIST) It can be useful to crash the child process in order to test the robustness diff --git a/lib/libvmod_vtc/vmod_vtc.c b/lib/libvmod_vtc/vmod_vtc.c index 6b6501adf..197fe81f0 100644 --- a/lib/libvmod_vtc/vmod_vtc.c +++ b/lib/libvmod_vtc/vmod_vtc.c @@ -89,6 +89,14 @@ vmod_no_stevedore(VRT_CTX) return (NULL); } +VCL_IP v_matchproto_(td_vtc_no_ip) +vmod_no_ip(VRT_CTX) +{ + + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + return (NULL); +} + /*--------------------------------------------------------------------*/ VCL_VOID v_matchproto_(td_vtc_panic) From dridi.boukelmoune at gmail.com Fri Feb 8 12:31:13 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 8 Feb 2019 12:31:13 +0000 (UTC) Subject: [6.0] 1845b8937 vsl -R: Add strtol underflow/overflow handling Message-ID: <20190208123113.71229619AD@lists.varnish-cache.org> commit 1845b8937c45df862bc36138a86b977f058392f8 Author: Dag Haavi Finstad Date: Mon Dec 3 14:31:35 2018 +0100 vsl -R: Add strtol underflow/overflow handling Conflicts: lib/libvarnishapi/vsl_arg.c For some reason it was missing errno.h... diff --git a/lib/libvarnishapi/vsl_arg.c b/lib/libvarnishapi/vsl_arg.c index 2929b4ccf..25402e583 100644 --- a/lib/libvarnishapi/vsl_arg.c +++ b/lib/libvarnishapi/vsl_arg.c @@ -31,6 +31,7 @@ #include "config.h" #include +#include #include #include #include @@ -310,7 +311,10 @@ vsl_R_arg(struct VSL_data *vsl, const char *arg) AN(arg); CHECK_OBJ_NOTNULL(vsl, VSL_MAGIC); + errno = 0; l = strtol(arg, &p, 0); + if ((l == LONG_MIN || l == LONG_MAX) && errno == ERANGE) + return (vsl_diag(vsl, "-R: Range error")); if (l <= 0 || l > INT_MAX) return (vsl_diag(vsl, "-R: Range error")); vsl->R_opt_l = l; From dridi.boukelmoune at gmail.com Fri Feb 8 13:13:09 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 8 Feb 2019 13:13:09 +0000 (UTC) Subject: [6.0] 58d10b093 rename OC_F_PASS -> OC_F_HFM - zero code change Message-ID: <20190208131309.574186473B@lists.varnish-cache.org> commit 58d10b0936fa659a6d7954707b9845d82f51f13a Author: Nils Goroll Date: Mon Dec 3 21:11:05 2018 +0100 rename OC_F_PASS -> OC_F_HFM - zero code change Now that we got hit-for-pass (hfp) and hit-for-miss (hfm), we should name the latter consistently to avoid unnecessary confusion diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index be6dc162c..4193c4e2c 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -127,7 +127,7 @@ vbf_beresp2obj(struct busyobj *bo) l += l2; if (bo->uncacheable) - bo->fetch_objcore->flags |= OC_F_PASS; + bo->fetch_objcore->flags |= OC_F_HFM; if (!vbf_allocobj(bo, l)) { if (vary != NULL) @@ -196,7 +196,7 @@ vbf_stp_mkbereq(struct worker *wrk, struct busyobj *bo) if (bo->stale_oc != NULL && ObjCheckFlag(bo->wrk, bo->stale_oc, OF_IMSCAND) && (bo->stale_oc->boc != NULL || ObjGetLen(wrk, bo->stale_oc) != 0)) { - AZ(bo->stale_oc->flags & (OC_F_PASS|OC_F_PRIVATE)); + AZ(bo->stale_oc->flags & (OC_F_HFM|OC_F_PRIVATE)); q = HTTP_GetHdrPack(bo->wrk, bo->stale_oc, H_Last_Modified); if (q != NULL) http_PrintfHeader(bo->bereq0, @@ -355,7 +355,7 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo) if (http_IsStatus(bo->beresp, 304)) { if (bo->stale_oc != NULL && ObjCheckFlag(bo->wrk, bo->stale_oc, OF_IMSCAND)) { - AZ(bo->stale_oc->flags & (OC_F_PASS|OC_F_PRIVATE)); + AZ(bo->stale_oc->flags & (OC_F_HFM|OC_F_PRIVATE)); if (ObjCheckFlag(bo->wrk, bo->stale_oc, OF_CHGGZIP)) { /* * If we changed the gzip status of the object @@ -418,7 +418,7 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo) wrk->handling = VCL_RET_DELIVER; } if (bo->do_pass || bo->uncacheable) - bo->fetch_objcore->flags |= OC_F_PASS; + bo->fetch_objcore->flags |= OC_F_HFM; assert(wrk->handling == VCL_RET_DELIVER); @@ -454,7 +454,7 @@ vbf_stp_fetchbody(struct worker *wrk, struct busyobj *bo) * We don't fail the fetch, in order for HitMiss * objects to be created. */ - AN(vfc->oc->flags & OC_F_PASS); + AN(vfc->oc->flags & OC_F_HFM); VSLb(wrk->vsl, SLT_Debug, "Fetch: Pass delivery abandoned"); bo->htc->doclose = SC_RX_BODY; @@ -608,7 +608,7 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) ObjSetFlag(bo->wrk, bo->fetch_objcore, OF_##U, 1); #include "tbl/obj_attr.h" - if (!(bo->fetch_objcore->flags & OC_F_PASS) && + if (!(bo->fetch_objcore->flags & OC_F_HFM) && http_IsStatus(bo->beresp, 200) && ( http_GetHdr(bo->beresp, H_Last_Modified, &p) || http_GetHdr(bo->beresp, H_ETag, &p))) diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index bb32d4fc2..f8029cb98 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -445,7 +445,7 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp, ObjGetXID(wrk, oc), EXP_Dttl(req, oc)); oc = NULL; retval = HSH_MISS; - } else if (oc->flags & OC_F_PASS) { + } else if (oc->flags & OC_F_HFM) { wrk->stats->cache_hitmiss++; VSLb(req->vsl, SLT_HitMiss, "%u %.6f", ObjGetXID(wrk, oc), EXP_Dttl(req, oc)); @@ -472,7 +472,7 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp, } } - if (exp_oc != NULL && exp_oc->flags & OC_F_PASS) { + if (exp_oc != NULL && exp_oc->flags & OC_F_HFM) { wrk->stats->cache_hitmiss++; VSLb(req->vsl, SLT_HitMiss, "%u %.6f", ObjGetXID(wrk, exp_oc), EXP_Dttl(req, exp_oc)); diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index cd01c2976..cafdd010f 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -401,7 +401,7 @@ cnt_transmit(struct worker *wrk, struct req *req) http_Unset(req->resp, H_Content_Length); } else if (clval >= 0 && clval == req->resp_len) { /* Reuse C-L header */ - } else if (head && req->objcore->flags & OC_F_PASS) { + } else if (head && req->objcore->flags & OC_F_HFM) { /* * Don't touch C-L header (debatable) * @@ -423,9 +423,9 @@ cnt_transmit(struct worker *wrk, struct req *req) VSLb_ts_req(req, "Resp", W_TIM_real(wrk)); - if (req->objcore->flags & (OC_F_PRIVATE | OC_F_PASS | OC_F_HFP)) { + if (req->objcore->flags & (OC_F_PRIVATE | OC_F_HFM | OC_F_HFP)) { if (req->objcore->flags & OC_F_HFP) - AN(req->objcore->flags & OC_F_PASS); + AN(req->objcore->flags & OC_F_HFM); if (boc != NULL) { HSH_Abandon(req->objcore); ObjWaitState(req->objcore, BOS_FINISHED); @@ -534,7 +534,7 @@ cnt_lookup(struct worker *wrk, struct req *req) CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); AZ(oc->flags & OC_F_BUSY); req->objcore = oc; - AZ(oc->flags & OC_F_PASS); + AZ(oc->flags & OC_F_HFM); VSLb(req->vsl, SLT_Hit, "%u %.6f %.6f %.6f", ObjGetXID(wrk, req->objcore), @@ -547,7 +547,7 @@ cnt_lookup(struct worker *wrk, struct req *req) switch (wrk->handling) { case VCL_RET_DELIVER: if (busy != NULL) { - AZ(oc->flags & OC_F_PASS); + AZ(oc->flags & OC_F_HFM); CHECK_OBJ_NOTNULL(busy->boc, BOC_MAGIC); // XXX: shouldn't we go to miss? VBF_Fetch(wrk, req, busy, oc, VBF_BACKGROUND); diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index 405bb4310..d3787b193 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -823,7 +823,7 @@ VRT_r_obj_uncacheable(VRT_CTX) CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); CHECK_OBJ_NOTNULL(ctx->req->objcore, OBJCORE_MAGIC); - return (ctx->req->objcore->flags & OC_F_PASS ? 1 : 0); + return (ctx->req->objcore->flags & OC_F_HFM ? 1 : 0); } /*--------------------------------------------------------------------*/ diff --git a/include/tbl/oc_flags.h b/include/tbl/oc_flags.h index fc8788b64..84fd86f80 100644 --- a/include/tbl/oc_flags.h +++ b/include/tbl/oc_flags.h @@ -30,7 +30,7 @@ OC_FLAG(PURGED, purged, (1<<0)) //lint !e835 OC_FLAG(BUSY, busy, (1<<1)) -OC_FLAG(PASS, pass, (1<<2)) +OC_FLAG(HFM, hfm, (1<<2)) OC_FLAG(HFP, hfp, (1<<3)) OC_FLAG(ABANDON, abandon, (1<<4)) OC_FLAG(PRIVATE, private, (1<<5)) From dridi.boukelmoune at gmail.com Fri Feb 8 13:13:09 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 8 Feb 2019 13:13:09 +0000 (UTC) Subject: [6.0] 3bb4686b0 merge HSH_EXP and HSH_EXPBUSY into HSH_GRACE Message-ID: <20190208131309.6DFB86473E@lists.varnish-cache.org> commit 3bb4686b07d5a52c24ca9c887caf6ed536c9f01d Author: Nils Goroll Date: Mon Dec 3 21:17:05 2018 +0100 merge HSH_EXP and HSH_EXPBUSY into HSH_GRACE they are the same case diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index f8029cb98..4ee3dbce6 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -496,7 +496,7 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp, } else { if (exp_oc->hits < LONG_MAX) exp_oc->hits++; - retval = HSH_EXPBUSY; + retval = HSH_GRACE; } } else { Lck_Unlock(&oh->mtx); @@ -518,7 +518,7 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp, assert(HSH_DerefObjHead(wrk, &oh)); if (exp_oc->hits < LONG_MAX) exp_oc->hits++; - return (HSH_EXP); + return (HSH_GRACE); } /* There are one or more busy objects, wait for them */ diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index cafdd010f..65c90e6b7 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -556,7 +556,7 @@ cnt_lookup(struct worker *wrk, struct req *req) } wrk->stats->cache_hit++; req->is_hit = 1; - if (lr == HSH_EXP || lr == HSH_EXPBUSY) + if (lr == HSH_GRACE) wrk->stats->cache_hit_grace++; req->req_step = R_STP_DELIVER; return (REQ_FSM_MORE); diff --git a/bin/varnishd/hash/hash_slinger.h b/bin/varnishd/hash/hash_slinger.h index d6cad78ae..aa4f284f4 100644 --- a/bin/varnishd/hash/hash_slinger.h +++ b/bin/varnishd/hash/hash_slinger.h @@ -53,8 +53,7 @@ enum lookup_e { HSH_MISS, HSH_BUSY, HSH_HIT, - HSH_EXP, - HSH_EXPBUSY + HSH_GRACE }; /* mgt_hash.c */ From dridi.boukelmoune at gmail.com Fri Feb 8 13:13:09 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 8 Feb 2019 13:13:09 +0000 (UTC) Subject: [6.0] 91c3dfc03 Introduce HSH_HITPASS and HSH_HITMISS and clarify grace/keep HSH_HITMISS Message-ID: <20190208131309.893B964741@lists.varnish-cache.org> commit 91c3dfc03b2369fe2d8efe27376a638f88375cbe Author: Nils Goroll Date: Mon Dec 3 21:34:12 2018 +0100 Introduce HSH_HITPASS and HSH_HITMISS and clarify grace/keep HSH_HITMISS diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index 4ee3dbce6..66fd223f5 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -444,14 +444,14 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp, VSLb(req->vsl, SLT_HitPass, "%u %.6f", ObjGetXID(wrk, oc), EXP_Dttl(req, oc)); oc = NULL; - retval = HSH_MISS; + retval = HSH_HITPASS; } else if (oc->flags & OC_F_HFM) { wrk->stats->cache_hitmiss++; VSLb(req->vsl, SLT_HitMiss, "%u %.6f", ObjGetXID(wrk, oc), EXP_Dttl(req, oc)); *bocp = hsh_insert_busyobj(wrk, oh); oc->refcnt++; - retval = HSH_MISS; + retval = HSH_HITMISS; } else { oc->refcnt++; if (oc->hits < LONG_MAX) @@ -473,11 +473,17 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp, } if (exp_oc != NULL && exp_oc->flags & OC_F_HFM) { + /* + * expired HFM ("grace/keep HFM") + * + * XXX should HFM objects actually have grace/keep ? + */ wrk->stats->cache_hitmiss++; VSLb(req->vsl, SLT_HitMiss, "%u %.6f", ObjGetXID(wrk, exp_oc), EXP_Dttl(req, exp_oc)); - exp_oc = NULL; - busy_found = 0; + *bocp = hsh_insert_busyobj(wrk, oh); + Lck_Unlock(&oh->mtx); + return (HSH_HITMISS); } if (!busy_found) { diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 65c90e6b7..85af28381 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -516,21 +516,23 @@ cnt_lookup(struct worker *wrk, struct req *req) } AZ(req->objcore); - if (lr == HSH_MISS) { - if (busy != NULL) { - /* hitmiss, out-of-grace or ordinary miss */ - AN(busy->flags & OC_F_BUSY); - req->objcore = busy; - req->stale_oc = oc; - req->req_step = R_STP_MISS; - } else { - /* hitpass */ - AZ(oc); - req->req_step = R_STP_PASS; - } + if (lr == HSH_MISS || lr == HSH_HITMISS) { + AN(busy); + AN(busy->flags & OC_F_BUSY); + req->objcore = busy; + req->stale_oc = oc; + req->req_step = R_STP_MISS; + return (REQ_FSM_MORE); + } + if (lr == HSH_HITPASS) { + AZ(busy); + AZ(oc); + req->req_step = R_STP_PASS; return (REQ_FSM_MORE); } + assert(lr == HSH_HIT || lr == HSH_GRACE); + CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); AZ(oc->flags & OC_F_BUSY); req->objcore = oc; diff --git a/bin/varnishd/hash/hash_slinger.h b/bin/varnishd/hash/hash_slinger.h index aa4f284f4..9434ce874 100644 --- a/bin/varnishd/hash/hash_slinger.h +++ b/bin/varnishd/hash/hash_slinger.h @@ -53,6 +53,8 @@ enum lookup_e { HSH_MISS, HSH_BUSY, HSH_HIT, + HSH_HITMISS, + HSH_HITPASS, HSH_GRACE }; From dridi.boukelmoune at gmail.com Fri Feb 8 13:13:09 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 8 Feb 2019 13:13:09 +0000 (UTC) Subject: [6.0] fab3b3e19 reduce amount of work done under the objhead mutex Message-ID: <20190208131309.A4D9C64746@lists.varnish-cache.org> commit fab3b3e197b73f91f966761ca751390b02034ce1 Author: Nils Goroll Date: Mon Dec 3 22:11:53 2018 +0100 reduce amount of work done under the objhead mutex in particular, move logging diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index 66fd223f5..64c12686d 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -348,6 +348,8 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp, int busy_found; enum lookup_e retval; const uint8_t *vary; + unsigned xid = 0; + float dttl = 0.0; AN(ocp); *ocp = NULL; @@ -440,15 +442,13 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp, assert(oh->refcnt > 1); assert(oc->objhead == oh); if (oc->flags & OC_F_HFP) { - wrk->stats->cache_hitpass++; - VSLb(req->vsl, SLT_HitPass, "%u %.6f", - ObjGetXID(wrk, oc), EXP_Dttl(req, oc)); + xid = ObjGetXID(wrk, oc); + dttl = EXP_Dttl(req, oc); oc = NULL; retval = HSH_HITPASS; } else if (oc->flags & OC_F_HFM) { - wrk->stats->cache_hitmiss++; - VSLb(req->vsl, SLT_HitMiss, "%u %.6f", - ObjGetXID(wrk, oc), EXP_Dttl(req, oc)); + xid = ObjGetXID(wrk, oc); + dttl = EXP_Dttl(req, oc); *bocp = hsh_insert_busyobj(wrk, oh); oc->refcnt++; retval = HSH_HITMISS; @@ -462,6 +462,24 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp, *ocp = oc; if (*bocp == NULL) assert(HSH_DerefObjHead(wrk, &oh)); + + switch (retval) { + case HSH_HITPASS: + wrk->stats->cache_hitpass++; + VSLb(req->vsl, SLT_HitPass, "%u %.6f", + xid, dttl); + break; + case HSH_HITMISS: + wrk->stats->cache_hitmiss++; + VSLb(req->vsl, SLT_HitMiss, "%u %.6f", + xid, dttl); + break; + case HSH_HIT: + break; + default: + INCOMPL(); + } + return (retval); } if (EXP_Ttl(NULL, oc) < req->t_req && /* ignore req.ttl */ @@ -478,11 +496,13 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp, * * XXX should HFM objects actually have grace/keep ? */ - wrk->stats->cache_hitmiss++; - VSLb(req->vsl, SLT_HitMiss, "%u %.6f", ObjGetXID(wrk, exp_oc), - EXP_Dttl(req, exp_oc)); + xid = ObjGetXID(wrk, exp_oc); + dttl = EXP_Dttl(req, exp_oc); *bocp = hsh_insert_busyobj(wrk, oh); Lck_Unlock(&oh->mtx); + + wrk->stats->cache_hitmiss++; + VSLb(req->vsl, SLT_HitMiss, "%u %.6f", xid, dttl); return (HSH_HITMISS); } @@ -528,13 +548,11 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp, } /* There are one or more busy objects, wait for them */ + VTAILQ_INSERT_TAIL(&oh->waitinglist, req, w_list); + Lck_Unlock(&oh->mtx); AZ(req->hash_ignore_busy); - VTAILQ_INSERT_TAIL(&oh->waitinglist, req, w_list); - if (DO_DEBUG(DBG_WAITINGLIST)) - VSLb(req->vsl, SLT_Debug, "on waiting list <%p>", oh); - wrk->stats->busy_sleep++; /* * The objhead reference transfers to the sess, we get it @@ -544,7 +562,10 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp, req->hash_objhead = oh; req->wrk = NULL; req->waitinglist = 1; - Lck_Unlock(&oh->mtx); + + if (DO_DEBUG(DBG_WAITINGLIST)) + VSLb(req->vsl, SLT_Debug, "on waiting list <%p>", oh); + return (HSH_BUSY); } From dridi.boukelmoune at gmail.com Fri Feb 8 13:13:09 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 8 Feb 2019 13:13:09 +0000 (UTC) Subject: [6.0] 7519d5330 Add req.is_hitmiss and req.is_hitpass Message-ID: <20190208131309.C45676474C@lists.varnish-cache.org> commit 7519d53304e2b2b491060bfa89aab48141689cc2 Author: Nils Goroll Date: Mon Dec 3 22:43:50 2018 +0100 Add req.is_hitmiss and req.is_hitpass Closes #2743 Conflicts: doc/changes.rst doc/changes.rst was considered binary in master, it won't be in 6.0 so there will be no need to pick a1d2db691eef3ee09ec30c591006c9aa2a5026f5 too. Refs a1d2db691eef3ee09ec30c591006c9aa2a5026f5 diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 85af28381..b4bcc71ce 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -522,12 +522,15 @@ cnt_lookup(struct worker *wrk, struct req *req) req->objcore = busy; req->stale_oc = oc; req->req_step = R_STP_MISS; + if (lr == HSH_HITMISS) + req->is_hitmiss = 1; return (REQ_FSM_MORE); } if (lr == HSH_HITPASS) { AZ(busy); AZ(oc); req->req_step = R_STP_PASS; + req->is_hitpass = 1; return (REQ_FSM_MORE); } @@ -828,6 +831,8 @@ cnt_recv_prep(struct req *req, const char *ci) req->vdc->retval = 0; req->is_hit = 0; + req->is_hitmiss = 0; + req->is_hitpass = 0; } /*-------------------------------------------------------------------- * We have a complete request, set everything up and start it. diff --git a/bin/varnishtest/tests/c00014.vtc b/bin/varnishtest/tests/c00014.vtc index a0dbf5493..6fc238813 100644 --- a/bin/varnishtest/tests/c00014.vtc +++ b/bin/varnishtest/tests/c00014.vtc @@ -16,6 +16,12 @@ server s1 { } -start varnish v1 -vcl+backend { + sub vcl_miss { + set req.http.hitmiss = req.is_hitmiss; + } + sub vcl_deliver { + set resp.http.hitmiss = req.http.hitmiss; + } sub vcl_backend_response { set beresp.do_stream = false; set beresp.uncacheable = true; @@ -28,6 +34,7 @@ client c1 { expect resp.status == 200 expect resp.bodylen == 12 expect resp.http.x-varnish == "1001" + expect resp.http.hitmiss == "false" } -start barrier b1 sync @@ -39,6 +46,7 @@ client c2 { expect resp.status == 200 expect resp.bodylen == 6 expect resp.http.x-varnish == "1004" + expect resp.http.hitmiss == "true" } -run client c1 -wait diff --git a/bin/varnishtest/tests/c00081.vtc b/bin/varnishtest/tests/c00081.vtc index b08fa3250..ffd344080 100644 --- a/bin/varnishtest/tests/c00081.vtc +++ b/bin/varnishtest/tests/c00081.vtc @@ -12,10 +12,10 @@ server s1 { varnish v1 -vcl+backend { sub vcl_miss { - set req.http.miss = "True"; + set req.http.miss = true; } sub vcl_pass { - set req.http.pass = "True"; + set req.http.hitpass = req.is_hitpass; } sub vcl_backend_response { @@ -24,7 +24,7 @@ varnish v1 -vcl+backend { sub vcl_deliver { set resp.http.miss = req.http.miss; - set resp.http.pass = req.http.pass; + set resp.http.hitpass = req.http.hitpass; } } -start @@ -36,17 +36,17 @@ logexpect l1 -v v1 -g vxid { client c1 { txreq rxresp - expect resp.http.miss == True + expect resp.http.miss == true txreq rxresp - expect resp.http.pass == True + expect resp.http.hitpass == true delay 3 txreq rxresp - expect resp.http.miss == True + expect resp.http.miss == true } -run logexpect l1 -wait diff --git a/doc/changes.rst b/doc/changes.rst index 5ac9da18f..94583e701 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -34,6 +34,10 @@ Varnish Cache 6.0.3 (unreleased) renamed the red/black tree macros from ``VRB_*`` to ``VRBT_*`` to disambiguate from the acronym for Varnish Request Body. +* added ``req.is_hitmiss`` and ``req.is_hitpass`` (2743_) + +.. _2743: https://github.com/varnishcache/varnish-cache/issues/2743 + ================================ Varnish Cache 6.0.2 (2018-11-07) ================================ diff --git a/doc/sphinx/reference/vcl_var.rst b/doc/sphinx/reference/vcl_var.rst index 4efbdff39..e8c04d928 100644 --- a/doc/sphinx/reference/vcl_var.rst +++ b/doc/sphinx/reference/vcl_var.rst @@ -391,6 +391,21 @@ req.hash_always_miss This is useful to force-update the cache without invalidating existing entries in case the fetch fails. +req.is_hitmiss + + Type: BOOL + + Readable from: client + + If this request resulted in a hitmiss + +req.is_hitpass + + Type: BOOL + + Readable from: client + + If this request resulted in a hitpass req_top.method diff --git a/include/tbl/req_flags.h b/include/tbl/req_flags.h index e23b9c1a2..2c0dbe803 100644 --- a/include/tbl/req_flags.h +++ b/include/tbl/req_flags.h @@ -34,6 +34,8 @@ REQ_FLAG(disable_esi, 0, 0, "") REQ_FLAG(hash_ignore_busy, 1, 1, "") REQ_FLAG(hash_always_miss, 1, 1, "") REQ_FLAG(is_hit, 0, 0, "") +REQ_FLAG(is_hitmiss, 1, 0, "") +REQ_FLAG(is_hitpass, 1, 0, "") REQ_FLAG(waitinglist, 0, 0, "") REQ_FLAG(want100cont, 0, 0, "") REQ_FLAG(late100cont, 0, 0, "") From dridi.boukelmoune at gmail.com Fri Feb 8 13:13:09 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 8 Feb 2019 13:13:09 +0000 (UTC) Subject: [6.0] 14be7fce0 add a lookup enum never to escape HSH_Lookup Message-ID: <20190208131309.DE53964758@lists.varnish-cache.org> commit 14be7fce0a4959a1b1ad24383cd944f7834ce348 Author: Nils Goroll Date: Mon Dec 3 22:49:51 2018 +0100 add a lookup enum never to escape HSH_Lookup This is caught by assert(lr == HSH_HIT || lr == HSH_GRACE); in cnt_lookup() diff --git a/bin/varnishd/hash/hash_slinger.h b/bin/varnishd/hash/hash_slinger.h index 9434ce874..6c17b8374 100644 --- a/bin/varnishd/hash/hash_slinger.h +++ b/bin/varnishd/hash/hash_slinger.h @@ -50,6 +50,7 @@ struct hash_slinger { }; enum lookup_e { + HSH_CONTINUE, HSH_MISS, HSH_BUSY, HSH_HIT, From dridi.boukelmoune at gmail.com Fri Feb 8 13:13:10 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 8 Feb 2019 13:13:10 +0000 (UTC) Subject: [6.0] e2d1a6504 Move HSH_DeleteObjHead into the hash deref methods Message-ID: <20190208131310.06EC86476C@lists.varnish-cache.org> commit e2d1a6504539fb111b69732ee1feb57719db65a3 Author: Martin Blix Grydeland Date: Tue Nov 20 12:48:49 2018 +0100 Move HSH_DeleteObjHead into the hash deref methods Move the clean up call to HSH_DeleteObjHead inside of the hash deref methods that require it, instead of having the outside (single) caller do it based off the return value. This just cleans up and makes the logic more transparent. diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index 64c12686d..fd0deeb19 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -983,7 +983,6 @@ HSH_DerefObjHead(struct worker *wrk, struct objhead **poh) { struct objhead *oh; struct rush rush; - int r; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); TAKE_OBJ_NOTNULL(oh, poh, OBJHEAD_MAGIC); @@ -1016,10 +1015,7 @@ HSH_DerefObjHead(struct worker *wrk, struct objhead **poh) Lck_Unlock(&oh->mtx); assert(oh->refcnt > 0); - r = hash->deref(oh); - if (!r) - HSH_DeleteObjHead(wrk, oh); - return (r); + return (hash->deref(wrk, oh)); } void diff --git a/bin/varnishd/hash/hash_classic.c b/bin/varnishd/hash/hash_classic.c index 3440b9bd2..d3303c875 100644 --- a/bin/varnishd/hash/hash_classic.c +++ b/bin/varnishd/hash/hash_classic.c @@ -172,7 +172,7 @@ hcl_lookup(struct worker *wrk, const void *digest, struct objhead **noh) */ static int v_matchproto_(hash_deref_f) -hcl_deref(struct objhead *oh) +hcl_deref(struct worker *wrk, struct objhead *oh) { struct hcl_hd *hp; int ret; @@ -187,6 +187,8 @@ hcl_deref(struct objhead *oh) } else ret = 1; Lck_Unlock(&hp->mtx); + if (!ret) + HSH_DeleteObjHead(wrk, oh); return (ret); } diff --git a/bin/varnishd/hash/hash_critbit.c b/bin/varnishd/hash/hash_critbit.c index c673595b2..1c453148f 100644 --- a/bin/varnishd/hash/hash_critbit.c +++ b/bin/varnishd/hash/hash_critbit.c @@ -347,13 +347,15 @@ hcb_start(void) } static int v_matchproto_(hash_deref_f) -hcb_deref(struct objhead *oh) +hcb_deref(struct worker *wrk, struct objhead *oh) { + int r; + (void)wrk; CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC); Lck_Lock(&oh->mtx); assert(oh->refcnt > 0); - oh->refcnt--; + r = --oh->refcnt; if (oh->refcnt == 0) { Lck_Lock(&hcb_mtx); hcb_delete(&hcb_root, oh); @@ -364,7 +366,7 @@ hcb_deref(struct objhead *oh) #ifdef PHK fprintf(stderr, "hcb_defef %d %d <%s>\n", __LINE__, r, oh->hash); #endif - return (1); + return (r); } static struct objhead * v_matchproto_(hash_lookup_f) diff --git a/bin/varnishd/hash/hash_simple_list.c b/bin/varnishd/hash/hash_simple_list.c index 4c1e9025a..643148ed0 100644 --- a/bin/varnishd/hash/hash_simple_list.c +++ b/bin/varnishd/hash/hash_simple_list.c @@ -108,7 +108,7 @@ hsl_lookup(struct worker *wrk, const void *digest, struct objhead **noh) */ static int v_matchproto_(hash_deref_f) -hsl_deref(struct objhead *oh) +hsl_deref(struct worker *wrk, struct objhead *oh) { int ret; @@ -119,6 +119,8 @@ hsl_deref(struct objhead *oh) } else ret = 1; Lck_Unlock(&hsl_mtx); + if (!ret) + HSH_DeleteObjHead(wrk, oh); return (ret); } diff --git a/bin/varnishd/hash/hash_slinger.h b/bin/varnishd/hash/hash_slinger.h index 6c17b8374..0ff95cca2 100644 --- a/bin/varnishd/hash/hash_slinger.h +++ b/bin/varnishd/hash/hash_slinger.h @@ -36,7 +36,7 @@ typedef void hash_start_f(void); typedef void hash_prep_f(struct worker *); typedef struct objhead *hash_lookup_f(struct worker *, const void *digest, struct objhead **); -typedef int hash_deref_f(struct objhead *); +typedef int hash_deref_f(struct worker *, struct objhead *); struct hash_slinger { unsigned magic; From dridi.boukelmoune at gmail.com Fri Feb 8 13:13:10 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 8 Feb 2019 13:13:10 +0000 (UTC) Subject: [6.0] abb63ed7f Change hash slingers deref func to take a locked objhead Message-ID: <20190208131310.213C864771@lists.varnish-cache.org> commit abb63ed7f32db2aaa7437e0bb59f65b648871a60 Author: Martin Blix Grydeland Date: Tue Nov 20 12:59:36 2018 +0100 Change hash slingers deref func to take a locked objhead This changes the hash slingers deref function to take a locked objhead on input, and unlocking it before returning. This saves a lock/unlock sequence for critbit (which is the critical one) on HSH_DerefObjHead. diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index fd0deeb19..9468504d5 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -1012,7 +1012,6 @@ HSH_DerefObjHead(struct worker *wrk, struct objhead **poh) hsh_rush2(wrk, &rush); Lck_Lock(&oh->mtx); } - Lck_Unlock(&oh->mtx); assert(oh->refcnt > 0); return (hash->deref(wrk, oh)); diff --git a/bin/varnishd/hash/hash_classic.c b/bin/varnishd/hash/hash_classic.c index d3303c875..cb3b0b3a2 100644 --- a/bin/varnishd/hash/hash_classic.c +++ b/bin/varnishd/hash/hash_classic.c @@ -178,6 +178,9 @@ hcl_deref(struct worker *wrk, struct objhead *oh) int ret; CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC); + Lck_AssertHeld(&oh->mtx); + Lck_Unlock(&oh->mtx); + CAST_OBJ_NOTNULL(hp, oh->hoh_head, HCL_HEAD_MAGIC); assert(oh->refcnt > 0); Lck_Lock(&hp->mtx); diff --git a/bin/varnishd/hash/hash_critbit.c b/bin/varnishd/hash/hash_critbit.c index 1c453148f..fcedbef5f 100644 --- a/bin/varnishd/hash/hash_critbit.c +++ b/bin/varnishd/hash/hash_critbit.c @@ -353,7 +353,7 @@ hcb_deref(struct worker *wrk, struct objhead *oh) (void)wrk; CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC); - Lck_Lock(&oh->mtx); + Lck_AssertHeld(&oh->mtx); assert(oh->refcnt > 0); r = --oh->refcnt; if (oh->refcnt == 0) { diff --git a/bin/varnishd/hash/hash_simple_list.c b/bin/varnishd/hash/hash_simple_list.c index 643148ed0..8c0858e18 100644 --- a/bin/varnishd/hash/hash_simple_list.c +++ b/bin/varnishd/hash/hash_simple_list.c @@ -112,6 +112,10 @@ hsl_deref(struct worker *wrk, struct objhead *oh) { int ret; + CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC); + Lck_AssertHeld(&oh->mtx); + Lck_Unlock(&oh->mtx); + Lck_Lock(&hsl_mtx); if (--oh->refcnt == 0) { VTAILQ_REMOVE(&hsl_head, oh, hoh_list); From dridi.boukelmoune at gmail.com Fri Feb 8 13:13:10 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 8 Feb 2019 13:13:10 +0000 (UTC) Subject: [6.0] fa716ba28 Rename HSH_DerefObjhead() to hsh_deref_objhead() Message-ID: <20190208131310.3CA526477D@lists.varnish-cache.org> commit fa716ba280f59d6b9b2d0543b59eefcbfab637d4 Author: Martin Blix Grydeland Date: Tue Dec 4 10:55:19 2018 +0100 Rename HSH_DerefObjhead() to hsh_deref_objhead() Make this function lower case for consistency. diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index 9468504d5..80a8a6f92 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -76,7 +76,7 @@ static struct objhead *private_oh; static void hsh_rush1(const struct worker *, struct objhead *, struct rush *, int); static void hsh_rush2(struct worker *, struct rush *); -static int HSH_DerefObjHead(struct worker *wrk, struct objhead **poh); +static int hsh_deref_objhead(struct worker *wrk, struct objhead **poh); /*---------------------------------------------------------------------*/ @@ -461,7 +461,7 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp, Lck_Unlock(&oh->mtx); *ocp = oc; if (*bocp == NULL) - assert(HSH_DerefObjHead(wrk, &oh)); + assert(hsh_deref_objhead(wrk, &oh)); switch (retval) { case HSH_HITPASS: @@ -541,7 +541,7 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp, Lck_Unlock(&oh->mtx); *ocp = exp_oc; - assert(HSH_DerefObjHead(wrk, &oh)); + assert(hsh_deref_objhead(wrk, &oh)); if (exp_oc->hits < LONG_MAX) exp_oc->hits++; return (HSH_GRACE); @@ -974,12 +974,12 @@ HSH_DerefObjCore(struct worker *wrk, struct objcore **ocp, int rushmax) /* Drop our ref on the objhead */ assert(oh->refcnt > 0); - (void)HSH_DerefObjHead(wrk, &oh); + (void)hsh_deref_objhead(wrk, &oh); return (0); } static int -HSH_DerefObjHead(struct worker *wrk, struct objhead **poh) +hsh_deref_objhead(struct worker *wrk, struct objhead **poh) { struct objhead *oh; struct rush rush; From dridi.boukelmoune at gmail.com Fri Feb 8 13:13:10 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 8 Feb 2019 13:13:10 +0000 (UTC) Subject: [6.0] e4c302679 Add hsh_deref_objhead_unlock(), taking a locked objhead Message-ID: <20190208131310.5E5DF647A2@lists.varnish-cache.org> commit e4c3026796dede208efd7dcb547ab9c2068cfc6d Author: Martin Blix Grydeland Date: Tue Dec 4 10:57:11 2018 +0100 Add hsh_deref_objhead_unlock(), taking a locked objhead Split hsh_deref_objhead() into two parts, with the new hsh_deref_objhead_unlock() function expecting a locked objhead reference on input. diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index 80a8a6f92..5a13bffd0 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -77,6 +77,7 @@ static void hsh_rush1(const struct worker *, struct objhead *, struct rush *, int); static void hsh_rush2(struct worker *, struct rush *); static int hsh_deref_objhead(struct worker *wrk, struct objhead **poh); +static int hsh_deref_objhead_unlock(struct worker *wrk, struct objhead **poh); /*---------------------------------------------------------------------*/ @@ -979,7 +980,7 @@ HSH_DerefObjCore(struct worker *wrk, struct objcore **ocp, int rushmax) } static int -hsh_deref_objhead(struct worker *wrk, struct objhead **poh) +hsh_deref_objhead_unlock(struct worker *wrk, struct objhead **poh) { struct objhead *oh; struct rush rush; @@ -988,9 +989,10 @@ hsh_deref_objhead(struct worker *wrk, struct objhead **poh) TAKE_OBJ_NOTNULL(oh, poh, OBJHEAD_MAGIC); INIT_OBJ(&rush, RUSH_MAGIC); + Lck_AssertHeld(&oh->mtx); + if (oh == private_oh) { assert(VTAILQ_EMPTY(&oh->waitinglist)); - Lck_Lock(&oh->mtx); assert(oh->refcnt > 1); oh->refcnt--; Lck_Unlock(&oh->mtx); @@ -1005,7 +1007,6 @@ hsh_deref_objhead(struct worker *wrk, struct objhead **poh) * just make the hold the same ref's as objcore, that would * confuse hashers. */ - Lck_Lock(&oh->mtx); while (oh->refcnt == 1 && !VTAILQ_EMPTY(&oh->waitinglist)) { hsh_rush1(wrk, oh, &rush, HSH_RUSH_ALL); Lck_Unlock(&oh->mtx); @@ -1017,6 +1018,18 @@ hsh_deref_objhead(struct worker *wrk, struct objhead **poh) return (hash->deref(wrk, oh)); } +static int +hsh_deref_objhead(struct worker *wrk, struct objhead **poh) +{ + struct objhead *oh; + + CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); + TAKE_OBJ_NOTNULL(oh, poh, OBJHEAD_MAGIC); + + Lck_Lock(&oh->mtx); + return (hsh_deref_objhead_unlock(wrk, &oh)); +} + void HSH_Init(const struct hash_slinger *slinger) { From dridi.boukelmoune at gmail.com Fri Feb 8 13:13:10 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 8 Feb 2019 13:13:10 +0000 (UTC) Subject: [6.0] 02dd83ba1 Reduce locking in HSH_Lookup() Message-ID: <20190208131310.75F95647AE@lists.varnish-cache.org> commit 02dd83ba173406d2f0c8e4808f2c2dbc6061dd65 Author: Martin Blix Grydeland Date: Tue Dec 4 10:57:11 2018 +0100 Reduce locking in HSH_Lookup() Make use of the new hsh_deref_objhead_unlock() in HSH_Lookup() to reduce the number of times the objhead mutex is taken during cache hits. diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index 5a13bffd0..cfda2bb9c 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -459,10 +459,11 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp, oc->hits++; retval = HSH_HIT; } - Lck_Unlock(&oh->mtx); *ocp = oc; if (*bocp == NULL) - assert(hsh_deref_objhead(wrk, &oh)); + AN(hsh_deref_objhead_unlock(wrk, &oh)); + else + Lck_Unlock(&oh->mtx); switch (retval) { case HSH_HITPASS: @@ -539,12 +540,10 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp, assert(oh->refcnt > 1); assert(exp_oc->objhead == oh); exp_oc->refcnt++; - Lck_Unlock(&oh->mtx); *ocp = exp_oc; - - assert(hsh_deref_objhead(wrk, &oh)); if (exp_oc->hits < LONG_MAX) exp_oc->hits++; + AN(hsh_deref_objhead_unlock(wrk, &oh)); return (HSH_GRACE); } From dridi.boukelmoune at gmail.com Fri Feb 8 13:13:10 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 8 Feb 2019 13:13:10 +0000 (UTC) Subject: [6.0] b2f9f2fba Display the VCL syntax during a panic Message-ID: <20190208131310.921A4647B8@lists.varnish-cache.org> commit b2f9f2fba172b280404790a114f253061e341691 Author: Dridi Boukelmoune Date: Tue Dec 4 16:01:13 2018 +0100 Display the VCL syntax during a panic diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c index d7a891802..410724e5d 100644 --- a/bin/varnishd/cache/cache_vcl.c +++ b/bin/varnishd/cache/cache_vcl.c @@ -212,6 +212,7 @@ VCL_Panic(struct vsb *vsb, const struct vcl *vcl) VSB_printf(vsb, "conf = NULL\n"); } else { PAN_CheckMagic(vsb, vcl->conf, VCL_CONF_MAGIC); + VSB_printf(vsb, "syntax = \"%d\",\n", vcl->conf->syntax); VSB_printf(vsb, "srcname = {\n"); VSB_indent(vsb, 2); for (i = 0; i < vcl->conf->nsrc; ++i) From dridi.boukelmoune at gmail.com Fri Feb 8 13:13:10 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 8 Feb 2019 13:13:10 +0000 (UTC) Subject: [6.0] daa0f945a Printf format fix Message-ID: <20190208131310.AEB63647CC@lists.varnish-cache.org> commit daa0f945a38d774d289f558cf006ae4d71dd03ef Author: Poul-Henning Kamp Date: Tue Dec 4 21:53:36 2018 +0000 Printf format fix diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c index 410724e5d..4cf196ea0 100644 --- a/bin/varnishd/cache/cache_vcl.c +++ b/bin/varnishd/cache/cache_vcl.c @@ -212,7 +212,7 @@ VCL_Panic(struct vsb *vsb, const struct vcl *vcl) VSB_printf(vsb, "conf = NULL\n"); } else { PAN_CheckMagic(vsb, vcl->conf, VCL_CONF_MAGIC); - VSB_printf(vsb, "syntax = \"%d\",\n", vcl->conf->syntax); + VSB_printf(vsb, "syntax = \"%u\",\n", vcl->conf->syntax); VSB_printf(vsb, "srcname = {\n"); VSB_indent(vsb, 2); for (i = 0; i < vcl->conf->nsrc; ++i) From dridi.boukelmoune at gmail.com Fri Feb 8 13:13:10 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 8 Feb 2019 13:13:10 +0000 (UTC) Subject: [6.0] a79e90ffe Simplify HSH_Lookup 1/N Message-ID: <20190208131310.CBF79647D8@lists.varnish-cache.org> commit a79e90ffe12e4656f125344d0dcfaf190a7ede26 Author: Poul-Henning Kamp Date: Tue Dec 4 21:54:16 2018 +0000 Simplify HSH_Lookup 1/N Move successful loop termination out of the loop. Inspired by: #2856 diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index cfda2bb9c..15c8fe8bb 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -439,51 +439,11 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp, } if (EXP_Ttl(req, oc) > req->t_req) { - /* If still valid, use it */ assert(oh->refcnt > 1); assert(oc->objhead == oh); - if (oc->flags & OC_F_HFP) { - xid = ObjGetXID(wrk, oc); - dttl = EXP_Dttl(req, oc); - oc = NULL; - retval = HSH_HITPASS; - } else if (oc->flags & OC_F_HFM) { - xid = ObjGetXID(wrk, oc); - dttl = EXP_Dttl(req, oc); - *bocp = hsh_insert_busyobj(wrk, oh); - oc->refcnt++; - retval = HSH_HITMISS; - } else { - oc->refcnt++; - if (oc->hits < LONG_MAX) - oc->hits++; - retval = HSH_HIT; - } - *ocp = oc; - if (*bocp == NULL) - AN(hsh_deref_objhead_unlock(wrk, &oh)); - else - Lck_Unlock(&oh->mtx); - - switch (retval) { - case HSH_HITPASS: - wrk->stats->cache_hitpass++; - VSLb(req->vsl, SLT_HitPass, "%u %.6f", - xid, dttl); - break; - case HSH_HITMISS: - wrk->stats->cache_hitmiss++; - VSLb(req->vsl, SLT_HitMiss, "%u %.6f", - xid, dttl); - break; - case HSH_HIT: - break; - default: - INCOMPL(); - } - - return (retval); + break; } + if (EXP_Ttl(NULL, oc) < req->t_req && /* ignore req.ttl */ oc->t_origin > exp_t_origin) { /* record the newest object */ @@ -492,6 +452,48 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp, } } + if (oc != NULL) { + if (oc->flags & OC_F_HFP) { + xid = ObjGetXID(wrk, oc); + dttl = EXP_Dttl(req, oc); + oc = NULL; + retval = HSH_HITPASS; + } else if (oc->flags & OC_F_HFM) { + xid = ObjGetXID(wrk, oc); + dttl = EXP_Dttl(req, oc); + *bocp = hsh_insert_busyobj(wrk, oh); + oc->refcnt++; + retval = HSH_HITMISS; + } else { + oc->refcnt++; + if (oc->hits < LONG_MAX) + oc->hits++; + retval = HSH_HIT; + } + *ocp = oc; + if (*bocp == NULL) + AN(hsh_deref_objhead_unlock(wrk, &oh)); + else + Lck_Unlock(&oh->mtx); + + switch (retval) { + case HSH_HITPASS: + wrk->stats->cache_hitpass++; + VSLb(req->vsl, SLT_HitPass, "%u %.6f", xid, dttl); + break; + case HSH_HITMISS: + wrk->stats->cache_hitmiss++; + VSLb(req->vsl, SLT_HitMiss, "%u %.6f", xid, dttl); + break; + case HSH_HIT: + break; + default: + INCOMPL(); + } + + return (retval); + } + if (exp_oc != NULL && exp_oc->flags & OC_F_HFM) { /* * expired HFM ("grace/keep HFM") From dridi.boukelmoune at gmail.com Fri Feb 8 13:13:10 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 8 Feb 2019 13:13:10 +0000 (UTC) Subject: [6.0] 5ee0e2573 Simplify HSH_Lookup 2/N Message-ID: <20190208131310.ED5C6647EA@lists.varnish-cache.org> commit 5ee0e2573a77c1508faf0dccf2d6432c7d3aa561 Author: Poul-Henning Kamp Date: Tue Dec 4 22:02:05 2018 +0000 Simplify HSH_Lookup 2/N Refactor the hit-cases Inspired by: #2856 diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index 15c8fe8bb..c5f5d3c7d 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -452,46 +452,31 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp, } } + if (oc != NULL && oc->flags & OC_F_HFP) { + xid = ObjGetXID(wrk, oc); + dttl = EXP_Dttl(req, oc); + AN(hsh_deref_objhead_unlock(wrk, &oh)); + wrk->stats->cache_hitpass++; + VSLb(req->vsl, SLT_HitPass, "%u %.6f", xid, dttl); + return (HSH_HITPASS); + } + if (oc != NULL) { - if (oc->flags & OC_F_HFP) { - xid = ObjGetXID(wrk, oc); - dttl = EXP_Dttl(req, oc); - oc = NULL; - retval = HSH_HITPASS; - } else if (oc->flags & OC_F_HFM) { + *ocp = oc; + oc->refcnt++; + if (oc->flags & OC_F_HFM) { xid = ObjGetXID(wrk, oc); dttl = EXP_Dttl(req, oc); *bocp = hsh_insert_busyobj(wrk, oh); - oc->refcnt++; - retval = HSH_HITMISS; - } else { - oc->refcnt++; - if (oc->hits < LONG_MAX) - oc->hits++; - retval = HSH_HIT; - } - *ocp = oc; - if (*bocp == NULL) - AN(hsh_deref_objhead_unlock(wrk, &oh)); - else Lck_Unlock(&oh->mtx); - - switch (retval) { - case HSH_HITPASS: - wrk->stats->cache_hitpass++; - VSLb(req->vsl, SLT_HitPass, "%u %.6f", xid, dttl); - break; - case HSH_HITMISS: wrk->stats->cache_hitmiss++; VSLb(req->vsl, SLT_HitMiss, "%u %.6f", xid, dttl); - break; - case HSH_HIT: - break; - default: - INCOMPL(); - } - - return (retval); + return (HSH_HITMISS); + } + if (oc->hits < LONG_MAX) + oc->hits++; + AN(hsh_deref_objhead_unlock(wrk, &oh)); + return (HSH_HIT); } if (exp_oc != NULL && exp_oc->flags & OC_F_HFM) { @@ -499,6 +484,7 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp, * expired HFM ("grace/keep HFM") * * XXX should HFM objects actually have grace/keep ? + * XXX also: why isn't *ocp = exp_oc ? */ xid = ObjGetXID(wrk, exp_oc); dttl = EXP_Dttl(req, exp_oc); From dridi.boukelmoune at gmail.com Fri Feb 8 13:13:11 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 8 Feb 2019 13:13:11 +0000 (UTC) Subject: [6.0] 718918663 Simplify HSH_Lookup 3/N Message-ID: <20190208131311.188BA647F6@lists.varnish-cache.org> commit 718918663cacd1159efa550da1fce8aed669feb3 Author: Poul-Henning Kamp Date: Tue Dec 4 23:08:02 2018 +0000 Simplify HSH_Lookup 3/N Use req->hash_always_miss directly Inspired by: #2856 diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index c5f5d3c7d..94b7d2dd9 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -338,8 +338,7 @@ hsh_insert_busyobj(struct worker *wrk, struct objhead *oh) */ enum lookup_e -HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp, - int always_insert) +HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp) { struct worker *wrk; struct objhead *oh; @@ -384,7 +383,7 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp, CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC); Lck_AssertHeld(&oh->mtx); - if (always_insert) { + if (req->hash_always_miss) { /* XXX: should we do predictive Vary in this case ? */ /* Insert new objcore in objecthead and release mutex */ *bocp = hsh_insert_busyobj(wrk, oh); @@ -472,7 +471,7 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp, wrk->stats->cache_hitmiss++; VSLb(req->vsl, SLT_HitMiss, "%u %.6f", xid, dttl); return (HSH_HITMISS); - } + } if (oc->hits < LONG_MAX) oc->hits++; AN(hsh_deref_objhead_unlock(wrk, &oh)); diff --git a/bin/varnishd/cache/cache_objhead.h b/bin/varnishd/cache/cache_objhead.h index 9e90d5b32..e12463981 100644 --- a/bin/varnishd/cache/cache_objhead.h +++ b/bin/varnishd/cache/cache_objhead.h @@ -68,8 +68,7 @@ int HSH_DerefObjCore(struct worker *, struct objcore **, int rushmax); #define HSH_RUSH_POLICY -1 #define HSH_RUSH_ALL INT_MAX -enum lookup_e HSH_Lookup(struct req *, struct objcore **, struct objcore **, - int always_insert); +enum lookup_e HSH_Lookup(struct req *, struct objcore **, struct objcore **); void HSH_Ref(struct objcore *o); void HSH_AddString(struct req *, void *ctx, const char *str); unsigned HSH_Purge(struct worker *, struct objhead *, vtim_real ttl_now, diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index b4bcc71ce..78395d7e5 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -495,7 +495,7 @@ cnt_lookup(struct worker *wrk, struct req *req) AZ(req->objcore); if (req->hash_objhead) had_objhead = 1; - lr = HSH_Lookup(req, &oc, &busy, req->hash_always_miss ? 1 : 0); + lr = HSH_Lookup(req, &oc, &busy); if (lr == HSH_BUSY) { /* * We lost the session to a busy object, disembark the @@ -986,7 +986,8 @@ cnt_purge(struct worker *wrk, struct req *req) VRY_Prep(req); AZ(req->objcore); - lr = HSH_Lookup(req, &oc, &boc, 1); + req->hash_always_miss = 1; + lr = HSH_Lookup(req, &oc, &boc); assert (lr == HSH_MISS); AZ(oc); CHECK_OBJ_NOTNULL(boc, OBJCORE_MAGIC); From dridi.boukelmoune at gmail.com Fri Feb 8 13:13:11 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 8 Feb 2019 13:13:11 +0000 (UTC) Subject: [6.0] 0f0464411 Simplify HSH_Lookup 4/4 Message-ID: <20190208131311.36B06647FF@lists.varnish-cache.org> commit 0f0464411a7db6395fefec185e2a24df42ddb2b3 Author: Poul-Henning Kamp Date: Tue Dec 4 23:45:27 2018 +0000 Simplify HSH_Lookup 4/4 Simplify the !busy cases Inspired by: #2856 diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index 94b7d2dd9..197ebc4c7 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -346,7 +346,6 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp) struct objcore *exp_oc; double exp_t_origin; int busy_found; - enum lookup_e retval; const uint8_t *vary; unsigned xid = 0; float dttl = 0.0; @@ -448,6 +447,8 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp) /* record the newest object */ exp_oc = oc; exp_t_origin = oc->t_origin; + assert(oh->refcnt > 1); + assert(exp_oc->objhead == oh); } } @@ -489,43 +490,31 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp) dttl = EXP_Dttl(req, exp_oc); *bocp = hsh_insert_busyobj(wrk, oh); Lck_Unlock(&oh->mtx); - wrk->stats->cache_hitmiss++; VSLb(req->vsl, SLT_HitMiss, "%u %.6f", xid, dttl); return (HSH_HITMISS); } if (!busy_found) { - /* Insert objcore in objecthead */ *bocp = hsh_insert_busyobj(wrk, oh); if (exp_oc != NULL) { - assert(oh->refcnt > 1); - assert(exp_oc->objhead == oh); exp_oc->refcnt++; - Lck_Unlock(&oh->mtx); *ocp = exp_oc; - - if (EXP_Ttl_grace(req, exp_oc) < req->t_req) { - retval = HSH_MISS; - } else { + if (EXP_Ttl_grace(req, exp_oc) > req->t_req) { if (exp_oc->hits < LONG_MAX) exp_oc->hits++; - retval = HSH_GRACE; + Lck_Unlock(&oh->mtx); + return (HSH_GRACE); } - } else { - Lck_Unlock(&oh->mtx); - retval = HSH_MISS; } - - return (retval); + Lck_Unlock(&oh->mtx); + return (HSH_MISS); } AN(busy_found); if (exp_oc != NULL && EXP_Ttl_grace(req, exp_oc) >= req->t_req) { /* we do not wait on the busy object if in grace */ - assert(oh->refcnt > 1); - assert(exp_oc->objhead == oh); exp_oc->refcnt++; *ocp = exp_oc; if (exp_oc->hits < LONG_MAX) From dridi.boukelmoune at gmail.com Fri Feb 8 13:13:11 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 8 Feb 2019 13:13:11 +0000 (UTC) Subject: [6.0] 150d4c4ee Clean up dead code in hsh_deref_objhead_unlock Message-ID: <20190208131311.4E66F64809@lists.varnish-cache.org> commit 150d4c4ee2841d46652d256c5a5a42efa944ce6e Author: Dag Haavi Finstad Date: Wed Dec 5 10:25:57 2018 +0100 Clean up dead code in hsh_deref_objhead_unlock req's on waiting list do indeed hold an objhead ref (req->hash_objhead), so the condition for the while loop in hsh_deref_objhead_unlock will always evaluate to false. This gets rid of the needless rushing code and replaces it with an assert. diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index 197ebc4c7..6d030c9ad 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -776,8 +776,10 @@ HSH_Unbusy(struct worker *wrk, struct objcore *oc) VTAILQ_REMOVE(&oh->objcs, oc, hsh_list); VTAILQ_INSERT_HEAD(&oh->objcs, oc, hsh_list); oc->flags &= ~OC_F_BUSY; - if (!VTAILQ_EMPTY(&oh->waitinglist)) + if (!VTAILQ_EMPTY(&oh->waitinglist)) { + assert(oh->refcnt > 1); hsh_rush1(wrk, oh, &rush, HSH_RUSH_POLICY); + } Lck_Unlock(&oh->mtx); if (!(oc->flags & OC_F_PRIVATE)) EXP_Insert(wrk, oc); @@ -932,8 +934,10 @@ HSH_DerefObjCore(struct worker *wrk, struct objcore **ocp, int rushmax) r = --oc->refcnt; if (!r) VTAILQ_REMOVE(&oh->objcs, oc, hsh_list); - if (!VTAILQ_EMPTY(&oh->waitinglist)) + if (!VTAILQ_EMPTY(&oh->waitinglist)) { + assert(oh->refcnt > 1); hsh_rush1(wrk, oh, &rush, rushmax); + } Lck_Unlock(&oh->mtx); hsh_rush2(wrk, &rush); if (r != 0) @@ -958,11 +962,9 @@ static int hsh_deref_objhead_unlock(struct worker *wrk, struct objhead **poh) { struct objhead *oh; - struct rush rush; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); TAKE_OBJ_NOTNULL(oh, poh, OBJHEAD_MAGIC); - INIT_OBJ(&rush, RUSH_MAGIC); Lck_AssertHeld(&oh->mtx); @@ -974,20 +976,8 @@ hsh_deref_objhead_unlock(struct worker *wrk, struct objhead **poh) return(1); } - /* - * Make absolutely certain that we do not let the final ref - * disappear until the waitinglist is empty. - * This is necessary because the req's on the waiting list do - * not hold any ref on the objhead of their own, and we cannot - * just make the hold the same ref's as objcore, that would - * confuse hashers. - */ - while (oh->refcnt == 1 && !VTAILQ_EMPTY(&oh->waitinglist)) { - hsh_rush1(wrk, oh, &rush, HSH_RUSH_ALL); - Lck_Unlock(&oh->mtx); - hsh_rush2(wrk, &rush); - Lck_Lock(&oh->mtx); - } + if (oh->refcnt == 1) + assert(VTAILQ_EMPTY(&oh->waitinglist)); assert(oh->refcnt > 0); return (hash->deref(wrk, oh)); From nils.goroll at uplex.de Mon Feb 11 10:18:03 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 11 Feb 2019 10:18:03 +0000 (UTC) Subject: [master] 0942fd55b add debug bit to count contended locks Message-ID: <20190211101803.AAB6B92E91@lists.varnish-cache.org> commit 0942fd55bd51faeab8dd9765aac14db129ddf502 Author: Nils Goroll Date: Mon Feb 11 11:16:40 2019 +0100 add debug bit to count contended locks Thank you to phk for the improvement over the initial suggestion diff --git a/bin/varnishd/VSC_lck.vsc b/bin/varnishd/VSC_lck.vsc index 1a6b6ee8b..0470964a5 100644 --- a/bin/varnishd/VSC_lck.vsc +++ b/bin/varnishd/VSC_lck.vsc @@ -30,5 +30,27 @@ :oneliner: Lock Operations +.. varnish_vsc:: dbg_busy + :type: counter + :level: debug + :oneliner: Contended lock operations + + If the ``lck`` debug bit is set: Lock operations which + returned EBUSY on the first locking attempt. + + If the ``lck`` debug bit is unset, this counter will never be + incremented even if lock operations are contended. + +.. varnish_vsc:: dbg_try_fail + :type: counter + :level: debug + :oneliner: Contended trylock operations + + If the ``lck`` debug bit is set: Trylock operations which + returned EBUSY. + + If the ``lck`` debug bit is unset, this counter will never be + incremented even if lock operations are contended. + .. varnish_vsc_end:: lck diff --git a/bin/varnishd/cache/cache_lck.c b/bin/varnishd/cache/cache_lck.c index 30cbbab4a..af21c7ba4 100644 --- a/bin/varnishd/cache/cache_lck.c +++ b/bin/varnishd/cache/cache_lck.c @@ -107,11 +107,20 @@ void v_matchproto_() Lck__Lock(struct lock *lck, const char *p, int l) { struct ilck *ilck; + int r = EINVAL; CAST_OBJ_NOTNULL(ilck, lck->priv, ILCK_MAGIC); if (DO_DEBUG(DBG_WITNESS)) Lck_Witness_Lock(ilck, p, l, ""); - AZ(pthread_mutex_lock(&ilck->mtx)); + else if (DO_DEBUG(DBG_LCK)) { + r = pthread_mutex_trylock(&ilck->mtx); + if (r == EBUSY) + ilck->stat->dbg_busy++; + else + AZ(r); + } + if (r) + AZ(pthread_mutex_lock(&ilck->mtx)); AZ(ilck->held); ilck->stat->locks++; ilck->owner = pthread_self(); @@ -162,7 +171,8 @@ Lck__Trylock(struct lock *lck, const char *p, int l) ilck->held = 1; ilck->stat->locks++; ilck->owner = pthread_self(); - } + } else if (DO_DEBUG(DBG_LCK)) + ilck->stat->dbg_try_fail++; return (r); } diff --git a/include/tbl/debug_bits.h b/include/tbl/debug_bits.h index 8bf099d5d..83206e80d 100644 --- a/include/tbl/debug_bits.h +++ b/include/tbl/debug_bits.h @@ -51,6 +51,7 @@ DEBUG_BIT(VMOD_SO_KEEP, vmod_so_keep, "Keep copied VMOD libraries") DEBUG_BIT(PROCESSORS, processors, "Fetch/Deliver processors") DEBUG_BIT(PROTOCOL, protocol, "Protocol debugging") DEBUG_BIT(VCL_KEEP, vcl_keep, "Keep VCL C and so files") +DEBUG_BIT(LCK, lck, "Additional lock statistics") #undef DEBUG_BIT /*lint -restore */ From nils.goroll at uplex.de Mon Feb 11 10:22:08 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 11 Feb 2019 10:22:08 +0000 (UTC) Subject: [master] f7d1c8bf3 fix oversight from previous commit Message-ID: <20190211102208.7250993148@lists.varnish-cache.org> commit f7d1c8bf39f348c6b214760b9bcf46877a3b5cb1 Author: Nils Goroll Date: Mon Feb 11 11:21:19 2019 +0100 fix oversight from previous commit diff --git a/bin/varnishd/cache/cache_lck.c b/bin/varnishd/cache/cache_lck.c index af21c7ba4..fba7e03a2 100644 --- a/bin/varnishd/cache/cache_lck.c +++ b/bin/varnishd/cache/cache_lck.c @@ -112,7 +112,7 @@ Lck__Lock(struct lock *lck, const char *p, int l) CAST_OBJ_NOTNULL(ilck, lck->priv, ILCK_MAGIC); if (DO_DEBUG(DBG_WITNESS)) Lck_Witness_Lock(ilck, p, l, ""); - else if (DO_DEBUG(DBG_LCK)) { + if (DO_DEBUG(DBG_LCK)) { r = pthread_mutex_trylock(&ilck->mtx); if (r == EBUSY) ilck->stat->dbg_busy++; From phk at FreeBSD.org Mon Feb 11 11:34:09 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 11 Feb 2019 11:34:09 +0000 (UTC) Subject: [master] 2cba061d8 Don't increment the contested counter until we have the lock. Message-ID: <20190211113409.3784E94A08@lists.varnish-cache.org> commit 2cba061d8d47934af1226b2c87701324d6b84cee Author: Poul-Henning Kamp Date: Mon Feb 11 11:32:51 2019 +0000 Don't increment the contested counter until we have the lock. diff --git a/bin/varnishd/cache/cache_lck.c b/bin/varnishd/cache/cache_lck.c index fba7e03a2..4021166e4 100644 --- a/bin/varnishd/cache/cache_lck.c +++ b/bin/varnishd/cache/cache_lck.c @@ -114,14 +114,13 @@ Lck__Lock(struct lock *lck, const char *p, int l) Lck_Witness_Lock(ilck, p, l, ""); if (DO_DEBUG(DBG_LCK)) { r = pthread_mutex_trylock(&ilck->mtx); - if (r == EBUSY) - ilck->stat->dbg_busy++; - else - AZ(r); + assert(r == 0 || r == EBUSY); } if (r) AZ(pthread_mutex_lock(&ilck->mtx)); AZ(ilck->held); + if (r == EBUSY) + ilck->stat->dbg_busy++; ilck->stat->locks++; ilck->owner = pthread_self(); ilck->held = 1; From dridi.boukelmoune at gmail.com Mon Feb 11 13:14:09 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 11 Feb 2019 13:14:09 +0000 (UTC) Subject: [master] 7b7b9c70c Typo Message-ID: <20190211131409.3592196CB8@lists.varnish-cache.org> commit 7b7b9c70cc4fac2e97e7ccee77a518ab2575660e Author: Dridi Boukelmoune Date: Mon Feb 11 14:13:14 2019 +0100 Typo diff --git a/doc/sphinx/phk/lucky.rst b/doc/sphinx/phk/lucky.rst index b7737f442..7a1df5ba5 100644 --- a/doc/sphinx/phk/lucky.rst +++ b/doc/sphinx/phk/lucky.rst @@ -4,7 +4,7 @@ Do you feel lucky ? =================== -Whenever a corporate cotton-mouth says anything, their laywers +Whenever a corporate cotton-mouth says anything, their lawers always make them add a footnote to the effect that *"Past performance is not predictive of future results."* so they do not get sued for being insufficiently clairvoyant. @@ -87,8 +87,8 @@ Around the time of the 2019-03-15 release we will gather for a VDD and then we will know and be ready to say something more detailed. I don't think it is realistic to roll out any kind of H3 support -in the september release, that release will probably only contain -a some of the necessary prepatory reorganization, so expect to +in the September release, that release will probably only contain +a some of the necessary preparatory reorganization, so expect to run production on 6.0 LTS for a while. --------------------- @@ -138,7 +138,7 @@ to receive the reply from their heartbroken spouse, that you are many months too late [#f2]_. Jacob was not a major persona on the Internet, but between doing a -lot of interesting stuff as a multi-disicpline phd. in physics, +lot of interesting stuff as a multi-discipline phd. in physics, being a really good Ada programmer, a huge Lego enthusiast, an incredibly helpful person *and* really *good* at helping, he had a lot of friends in many corners of the Internet. From dridi.boukelmoune at gmail.com Mon Feb 11 13:17:09 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 11 Feb 2019 13:17:09 +0000 (UTC) Subject: [master] fb22c6081 Typo in my typo fix Message-ID: <20190211131709.A107096FED@lists.varnish-cache.org> commit fb22c6081a992357727892a7f63802a0f7e05918 Author: Dridi Boukelmoune Date: Mon Feb 11 14:16:04 2019 +0100 Typo in my typo fix diff --git a/doc/sphinx/phk/lucky.rst b/doc/sphinx/phk/lucky.rst index 7a1df5ba5..bf84ce746 100644 --- a/doc/sphinx/phk/lucky.rst +++ b/doc/sphinx/phk/lucky.rst @@ -4,7 +4,7 @@ Do you feel lucky ? =================== -Whenever a corporate cotton-mouth says anything, their lawers +Whenever a corporate cotton-mouth says anything, their lawyers always make them add a footnote to the effect that *"Past performance is not predictive of future results."* so they do not get sued for being insufficiently clairvoyant. From nils.goroll at uplex.de Mon Feb 11 13:38:08 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 11 Feb 2019 13:38:08 +0000 (UTC) Subject: [master] 31bd91829 Improse FetchError on first byte timeout Message-ID: <20190211133808.67717978A1@lists.varnish-cache.org> commit 31bd91829dc07c25525abcf2e4a4b91f484d7a37 Author: Nils Goroll Date: Mon Feb 11 14:30:23 2019 +0100 Improse FetchError on first byte timeout Fixes #2185 Test case by @fgsch diff --git a/bin/varnishd/http1/cache_http1_fetch.c b/bin/varnishd/http1/cache_http1_fetch.c index f1b0ac3cb..fa456a408 100644 --- a/bin/varnishd/http1/cache_http1_fetch.c +++ b/bin/varnishd/http1/cache_http1_fetch.c @@ -199,6 +199,10 @@ V1F_FetchRespHdr(struct busyobj *bo) VSLb(bo->vsl, SLT_FetchError, "overflow"); htc->doclose = SC_RX_OVERFLOW; break; + case HTC_S_IDLE: + VSLb(bo->vsl, SLT_FetchError, "first byte timeout"); + htc->doclose = SC_RX_TIMEOUT; + break; default: VSLb(bo->vsl, SLT_FetchError, "HTC %s (%d)", HTC_Status(hs), hs); diff --git a/bin/varnishtest/tests/b00023.vtc b/bin/varnishtest/tests/b00023.vtc index 9ee5ed340..fd64cb2bd 100644 --- a/bin/varnishtest/tests/b00023.vtc +++ b/bin/varnishtest/tests/b00023.vtc @@ -19,12 +19,18 @@ varnish v1 -vcl+backend { } } -start +logexpect l1 -v v1 { + expect * 1002 FetchError "first byte timeout" +} -start + client c1 { txreq rxresp expect resp.status == 503 } -run +logexpect l1 -wait + server s1 { rxreq delay 0.2 From hermunn at varnish-software.com Mon Feb 11 14:11:09 2019 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Mon, 11 Feb 2019 14:11:09 +0000 (UTC) Subject: [4.1] 61367ed17 Prepare for 4.1.11 release Message-ID: <20190211141109.295189B56F@lists.varnish-cache.org> commit 61367ed17d08a9ef80a2d42dc84caef79cdeee7a Author: P?l Hermunn Johansen Date: Thu Jan 3 15:25:15 2019 +0100 Prepare for 4.1.11 release diff --git a/configure.ac b/configure.ac index e4c246277..905b5b75a 100644 --- a/configure.ac +++ b/configure.ac @@ -1,8 +1,8 @@ AC_PREREQ(2.59) AC_COPYRIGHT([Copyright (c) 2006 Verdens Gang AS -Copyright (c) 2006-2018 Varnish Software]) +Copyright (c) 2006-2019 Varnish Software]) AC_REVISION([$Id$]) -AC_INIT([Varnish], [4.1.10], [varnish-dev at varnish-cache.org]) +AC_INIT([Varnish], [4.1.11], [varnish-dev at varnish-cache.org]) AC_CONFIG_SRCDIR(include/miniobj.h) AC_CONFIG_HEADERS([config.h]) AC_CONFIG_MACRO_DIR([m4]) diff --git a/doc/changes.rst b/doc/changes.rst index 629f27725..82a615b2d 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -1,5 +1,5 @@ ================================= -Varnish Cache 4.1.11 (unreleased) +Varnish Cache 4.1.11 (2019-02-11) ================================= Changes since 4.1.10: diff --git a/lib/libvarnish/version.c b/lib/libvarnish/version.c index 61711654e..b2258ccde 100644 --- a/lib/libvarnish/version.c +++ b/lib/libvarnish/version.c @@ -44,5 +44,5 @@ VCS_Message(const char *progname) { fprintf(stderr, "%s (%s)\n", progname, VCS_version); fprintf(stderr, "Copyright (c) 2006 Verdens Gang AS\n"); - fprintf(stderr, "Copyright (c) 2006-2015 Varnish Software AS\n"); + fprintf(stderr, "Copyright (c) 2006-2019 Varnish Software AS\n"); } From phk at FreeBSD.org Tue Feb 12 10:02:10 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 12 Feb 2019 10:02:10 +0000 (UTC) Subject: [master] 5735a543c Insist that VCL_RET_FAIL goes through VRT_fail() and not VRT_handling() Message-ID: <20190212100210.DD5BE7A06@lists.varnish-cache.org> commit 5735a543c720655c484ef11c70b6cde7f201d5ca Author: Poul-Henning Kamp Date: Tue Feb 12 10:01:00 2019 +0000 Insist that VCL_RET_FAIL goes through VRT_fail() and not VRT_handling() diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c index 45b4e1399..8940a6797 100644 --- a/bin/varnishd/cache/cache_vrt.c +++ b/bin/varnishd/cache/cache_vrt.c @@ -491,11 +491,11 @@ VRT_handling(VRT_CTX, unsigned hand) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); - if (ctx->handling == NULL) - return; + assert(hand != VCL_RET_FAIL); + AN(ctx->handling); + AZ(*ctx->handling); assert(hand > 0); assert(hand < VCL_RET_MAX); - // XXX:NOTYET assert(*ctx->handling == 0); *ctx->handling = hand; } @@ -507,16 +507,21 @@ VRT_fail(VRT_CTX, const char *fmt, ...) va_list ap; assert(ctx->vsl != NULL || ctx->msg != NULL); + AN(ctx->handling); + if (*ctx->handling == VCL_RET_FAIL) + return; + AZ(*ctx->handling); + AN(fmt); AZ(strchr(fmt, '\n')); va_start(ap, fmt); - if (ctx->vsl != NULL) + if (ctx->vsl != NULL) { VSLbv(ctx->vsl, SLT_VCL_Error, fmt, ap); - else { + } else { VSB_vprintf(ctx->msg, fmt, ap); VSB_putc(ctx->msg, '\n'); } va_end(ap); - VRT_handling(ctx, VCL_RET_FAIL); + *ctx->handling = VCL_RET_FAIL; } /*-------------------------------------------------------------------- @@ -772,9 +777,8 @@ VRT_purge(VRT_CTX, VCL_DURATION ttl, VCL_DURATION grace, VCL_DURATION keep) CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); if ((ctx->method & (VCL_MET_HIT|VCL_MET_MISS)) == 0) { - VSLb(ctx->vsl, SLT_VCL_Error, + VRT_fail(ctx, "purge can only happen in vcl_hit{} or vcl_miss{}"); - VRT_handling(ctx, VCL_RET_FAIL); return (0); } diff --git a/lib/libvcc/vcc_action.c b/lib/libvcc/vcc_action.c index ded906870..02d323a14 100644 --- a/lib/libvcc/vcc_action.c +++ b/lib/libvcc/vcc_action.c @@ -350,7 +350,10 @@ vcc_act_return(struct vcc *tl, struct token *t, struct symbol *sym) } } ERRCHK(tl); - Fb(tl, 1, "VRT_handling(ctx, VCL_RET_%s);\n", h); + if (hand == VCL_RET_FAIL) + Fb(tl, 1, "VRT_fail(ctx, \"Failed from VCL\");\n"); + else + Fb(tl, 1, "VRT_handling(ctx, VCL_RET_%s);\n", h); SkipToken(tl, ')'); SkipToken(tl, ';'); } diff --git a/lib/libvcc/vcc_compile.c b/lib/libvcc/vcc_compile.c index 13994eb6b..203f34465 100644 --- a/lib/libvcc/vcc_compile.c +++ b/lib/libvcc/vcc_compile.c @@ -318,8 +318,15 @@ EmitInitFini(const struct vcc *tl) if (VSB_len(p->event)) has_event = 1; } + + /* Handle failures from vcl_init */ + Fc(tl, 0, "\n"); + Fc(tl, 0, "\tif (*ctx->handling != VCL_RET_OK)\n"); + Fc(tl, 0, "\t\treturn(1);\n"); + VTAILQ_FOREACH(sy, &tl->sym_objects, sideways) { Fc(tl, 0, "\tif (!%s) {\n", sy->rname); + Fc(tl, 0, "\t\t*ctx->handling = 0;\n"); Fc(tl, 0, "\t\tVRT_fail(ctx, " "\"Object %s not initialized\");\n" , sy->name); Fc(tl, 0, "\t\treturn(1);\n"); @@ -655,7 +662,12 @@ vcc_CompileSource(struct vcc *tl, struct source *sp) /* Tie vcl_init/fini in */ ifp = New_IniFin(tl); - VSB_printf(ifp->ini, "\tVGC_function_vcl_init(ctx);"); + VSB_printf(ifp->ini, "\tVGC_function_vcl_init(ctx);\n"); + /* + * We do not return(1) if this fails, because the failure + * could be half way into vcl_init{} so vcl_fini{} must + * always be called, also on failure. + */ VSB_printf(ifp->fin, "\t\tVGC_function_vcl_fini(ctx);"); /* Emit method functions */ From dridi.boukelmoune at gmail.com Tue Feb 12 10:03:09 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 12 Feb 2019 10:03:09 +0000 (UTC) Subject: [6.0] 2dc0afd17 make two identical comparisons the same Message-ID: <20190212100309.B8E0E7C6C@lists.varnish-cache.org> commit 2dc0afd17f1e123513c83abbe36d9c9f63df083a Author: Nils Goroll Date: Wed Dec 5 11:40:13 2018 +0100 make two identical comparisons the same see 11 lines down Conflicts: bin/varnishd/cache/cache_hash.c diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index 6d030c9ad..78b61ce11 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -501,9 +501,8 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp) if (exp_oc != NULL) { exp_oc->refcnt++; *ocp = exp_oc; - if (EXP_Ttl_grace(req, exp_oc) > req->t_req) { - if (exp_oc->hits < LONG_MAX) - exp_oc->hits++; + if (EXP_Ttl_grace(req, exp_oc) >= req->t_req) { + exp_oc->hits++; Lck_Unlock(&oh->mtx); return (HSH_GRACE); } From dridi.boukelmoune at gmail.com Tue Feb 12 10:03:09 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 12 Feb 2019 10:03:09 +0000 (UTC) Subject: [6.0] a95864291 fsm graphviz: polish the waitinglist arrow Message-ID: <20190212100309.D78AD7C6F@lists.varnish-cache.org> commit a9586429145fb3defc62b1d65f244d95b0fc4812 Author: Nils Goroll Date: Wed Dec 5 11:56:44 2018 +0100 fsm graphviz: polish the waitinglist arrow diff --git a/doc/graphviz/cache_req_fsm.dot b/doc/graphviz/cache_req_fsm.dot index 3501b7bb1..b9f6a80c2 100644 --- a/doc/graphviz/cache_req_fsm.dot +++ b/doc/graphviz/cache_req_fsm.dot @@ -124,7 +124,7 @@ digraph cache_req_fsm { label="{cnt_lookup:|{vcl_hit\{\}|{req.*|obj.*}}|{fail|deliver|miss|restart|synth|pass}}" ] } - lookup:busy:e -> lookup:top:e [label="(waitinglist)", + lookup:busy:s -> lookup:top:ne [label=" waitinglist", color=grey, fontcolor=grey] lookup:miss:s -> miss [style=bold,color=blue] From dridi.boukelmoune at gmail.com Tue Feb 12 10:03:09 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 12 Feb 2019 10:03:09 +0000 (UTC) Subject: [6.0] 461d1a042 fsm graphviz: add hfm Message-ID: <20190212100309.F20CF7C73@lists.varnish-cache.org> commit 461d1a0427920066293ab8d751cd068be74367ec Author: Nils Goroll Date: Wed Dec 5 11:57:18 2018 +0100 fsm graphviz: add hfm diff --git a/doc/graphviz/cache_req_fsm.dot b/doc/graphviz/cache_req_fsm.dot index b9f6a80c2..9dda7bf9e 100644 --- a/doc/graphviz/cache_req_fsm.dot +++ b/doc/graphviz/cache_req_fsm.dot @@ -117,7 +117,7 @@ digraph cache_req_fsm { shape=record color=grey fontcolor=grey - label="{cnt_lookup:|hash lookup|{hit?|miss?|hit-for-pass?|busy?}}" + label="{cnt_lookup:|hash lookup|{hit?|miss?|hit-for-miss?|hit-for-pass?|busy?}}" ] lookup2 [ shape=record @@ -128,6 +128,7 @@ digraph cache_req_fsm { color=grey, fontcolor=grey] lookup:miss:s -> miss [style=bold,color=blue] + lookup:hfm:s -> miss [style=bold,color=blue] lookup:hfp:s -> pass [style=bold,color=red] lookup:h:s -> lookup2 [style=bold,color=green] From dridi.boukelmoune at gmail.com Tue Feb 12 10:03:10 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 12 Feb 2019 10:03:10 +0000 (UTC) Subject: [6.0] 5db08bed7 fsm graphviz: label hfm/hfp Message-ID: <20190212100310.174DB7C77@lists.varnish-cache.org> commit 5db08bed7580a761f81328a5c94faaa607201dcd Author: Nils Goroll Date: Wed Dec 5 12:09:24 2018 +0100 fsm graphviz: label hfm/hfp Ref #2743 diff --git a/doc/graphviz/cache_req_fsm.dot b/doc/graphviz/cache_req_fsm.dot index 9dda7bf9e..a33de6d5b 100644 --- a/doc/graphviz/cache_req_fsm.dot +++ b/doc/graphviz/cache_req_fsm.dot @@ -128,8 +128,8 @@ digraph cache_req_fsm { color=grey, fontcolor=grey] lookup:miss:s -> miss [style=bold,color=blue] - lookup:hfm:s -> miss [style=bold,color=blue] - lookup:hfp:s -> pass [style=bold,color=red] + lookup:hfm:s -> miss [style=bold,color=blue,label=" req.\n is_hitmiss"] + lookup:hfp:s -> pass [style=bold,color=red,label=" req.\n is_hitpass"] lookup:h:s -> lookup2 [style=bold,color=green] lookup2:deliver:s -> deliver:n [style=bold,color=green] From dridi.boukelmoune at gmail.com Tue Feb 12 10:03:10 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 12 Feb 2019 10:03:10 +0000 (UTC) Subject: [6.0] 55d4f7eac sm graphviz: document that miss from hit is going to die Message-ID: <20190212100310.2F9287C7B@lists.varnish-cache.org> commit 55d4f7eac5ebf8c8356aa6bd9ad2cbaafe20d69e Author: Nils Goroll Date: Wed Dec 5 12:21:02 2018 +0100 sm graphviz: document that miss from hit is going to die and polish the output formatting by reordering Ref #1799 diff --git a/doc/graphviz/cache_req_fsm.dot b/doc/graphviz/cache_req_fsm.dot index a33de6d5b..629072dc5 100644 --- a/doc/graphviz/cache_req_fsm.dot +++ b/doc/graphviz/cache_req_fsm.dot @@ -121,7 +121,7 @@ digraph cache_req_fsm { ] lookup2 [ shape=record - label="{cnt_lookup:|{vcl_hit\{\}|{req.*|obj.*}}|{fail|deliver|miss|restart|synth|pass}}" + label="{cnt_lookup:|{vcl_hit\{\}|{req.*|obj.*}}|{fail|deliver|pass|restart|synth|miss}}" ] } lookup:busy:s -> lookup:top:ne [label=" waitinglist", @@ -133,9 +133,7 @@ digraph cache_req_fsm { lookup:h:s -> lookup2 [style=bold,color=green] lookup2:deliver:s -> deliver:n [style=bold,color=green] - lookup2:miss:s -> miss [style=bold,color=blue] - // XXX should not happen - // lookup2:miss:s -> pass [style=bold,color=red,label="(no busy obj)"] + lookup2:miss:s -> miss [color=blue,label=" #1799 \n EOL"] lookup2:pass:s -> pass [style=bold,color=red] /* cnt_miss */ From dridi.boukelmoune at gmail.com Tue Feb 12 10:03:10 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 12 Feb 2019 10:03:10 +0000 (UTC) Subject: [6.0] fb936e871 update the generated graphviz svg Message-ID: <20190212100310.4BA407C7F@lists.varnish-cache.org> commit fb936e871111195f7b84e325f42171de0d8ee8b9 Author: Nils Goroll Date: Wed Dec 5 12:25:26 2018 +0100 update the generated graphviz svg diff --git a/doc/graphviz/cache_req_fsm.svg b/doc/graphviz/cache_req_fsm.svg index 60c71acd1..eeb0a75c8 100644 --- a/doc/graphviz/cache_req_fsm.svg +++ b/doc/graphviz/cache_req_fsm.svg @@ -4,496 +4,509 @@ - - + + cache_req_fsm - + cluster_backend - + acceptor - -Request received + +Request received recv - -cnt_recv: - -vcl_recv{} - -req.* - -fail - -hash - -purge - -pass - -pipe - -restart - -synth - -vcl + +cnt_recv: + +vcl_recv{} + +req.* + +fail + +hash + +purge + +pass + +pipe + +restart + +synth + +vcl acceptor->recv - - + + label_select - -LABEL + +LABEL label_select->recv - - + + ESI_REQ - -ESI request + +ESI request ESI_REQ->recv - - + + RESTART -RESTART +RESTART restart - -cnt_restart: - -fail - -ok? - -max_restarts? + +cnt_restart: + +fail + +ok? + +max_restarts? -RESTART->restart - - +RESTART->restart + + hash - -cnt_recv: - -vcl_hash{} - -req.* - -lookup + +cnt_recv: + +vcl_hash{} + +req.* + +lookup -recv:hash->hash - - +recv:hash->hash + + -recv:pipe->hash - - +recv:pipe->hash + + -recv:pass->hash - - +recv:pass->hash + + -recv:purge:s->hash - - +recv:purge:s->hash + + vcl_label -switch to vcl -LABEL +switch to vcl +LABEL -recv:vcl:s->vcl_label - - +recv:vcl:s->vcl_label + + SYNTH -SYNTH +SYNTH synth - -cnt_synth: - -vcl_synth{} - -req.* - -resp.* - -fail - -deliver - -restart + +cnt_synth: + +vcl_synth{} + +req.* + +resp.* + +fail + +deliver + +restart SYNTH->synth - - + + FAIL -FAIL +FAIL FAIL->synth - - + + deliver - -cnt_deliver: - -Filter obj.->resp. - -vcl_deliver{} - -req.* - -resp.* - -fail - -restart - -deliver - -synth + +cnt_deliver: + +Filter obj.->resp. + +vcl_deliver{} + +req.* + +resp.* + +fail + +restart + +deliver + +synth V1D_Deliver - -V1D_Deliver + +V1D_Deliver deliver:deliver:s->V1D_Deliver - - + + deliver:deliver:s->V1D_Deliver - - + + deliver:deliver:s->V1D_Deliver - - + + DONE - -DONE + +DONE V1D_Deliver->DONE - - + + stream - -stream? -body + +stream? +body stream->V1D_Deliver - - + + synth:del:s->V1D_Deliver - - + + see backend graph -see backend graph +see backend graph BGFETCH - -BGFETCH + +BGFETCH FETCH - -FETCH + +FETCH FETCH_DONE - -FETCH_DONE + +FETCH_DONE FETCH->FETCH_DONE - - + + FETCH_FAIL - -FETCH_FAIL + +FETCH_FAIL FETCH->FETCH_FAIL - - + + FETCH_DONE->deliver - - + + FETCH_DONE->deliver - - + + FETCH_FAIL->synth - - + + lookup2 - -cnt_lookup: - -vcl_hit{} - -req.* - -obj.* - -fail - -deliver - -miss - -restart - -synth - -pass + +cnt_lookup: + +vcl_hit{} + +req.* + +obj.* + +fail + +deliver + +pass + +restart + +synth + +miss -lookup2:deliver:s->deliver:n - - +lookup2:deliver:s->deliver:n + + lookup2:deliver:s->BGFETCH - - -parallel -if obj expired + + +parallel +if obj expired miss - -cnt_miss: - -vcl_miss{} - -req.* - -fail - -fetch - -synth - -restart - -pass + +cnt_miss: + +vcl_miss{} + +req.* + +fail + +fetch + +synth + +restart + +pass -lookup2:miss:s->miss - - +lookup2:miss:s->miss + + + #1799 + EOL pass - -cnt_pass: - -vcl_pass{} - -req.* - -fail - -fetch - -synth - -restart + +cnt_pass: + +vcl_pass{} + +req.* + +fail + +fetch + +synth + +restart -lookup2:pass:s->pass - - +lookup2:pass:s->pass + + lookup - -cnt_lookup: - -hash lookup - -hit? - -miss? - -hit-for-pass? - -busy? + +cnt_lookup: + +hash lookup + +hit? + +miss? + +hit-for-miss? + +hit-for-pass? + +busy? -lookup:h:s->lookup2 - - +lookup:h:s->lookup2 + + -lookup:busy:e->lookup:top:e - - -(waitinglist) +lookup:busy:s->lookup:top:ne + + + waitinglist lookup:miss:s->miss - - + + + + +lookup:hfm:s->miss + + + req. + is_hitmiss -lookup:hfp:s->pass - - +lookup:hfp:s->pass + + + req. + is_hitpass -miss:fetch:s->FETCH - - +miss:fetch:s->FETCH + + -miss:pass:s->pass - - +miss:pass:s->pass + + -pass:fetch:s->FETCH - - +pass:fetch:s->FETCH + + pipe - -cnt_pipe: - -filter req.*->bereq.* - -vcl_pipe{} - -req.* - -bereq.* - -fail - -pipe - -synth + +cnt_pipe: + +filter req.*->bereq.* + +vcl_pipe{} + +req.* + +bereq.* + +fail + +pipe + +synth pipe_do - -send bereq, -copy bytes until close + +send bereq, +copy bytes until close -pipe:pipe->pipe_do - - +pipe:pipe->pipe_do + + -pipe_do->DONE - - +pipe_do->DONE + + -restart:ok:s->recv - - +restart:ok:s->recv + + err_restart -SYNTH +SYNTH -restart:max:s->err_restart - - +restart:max:s->err_restart + + -hash:lookup:w->lookup - - +hash:lookup:w->lookup + + -hash:lookup:s->pass - - +hash:lookup:s->pass + + -hash:lookup:e->pipe - - +hash:lookup:e->pipe + + purge - -cnt_purge: - -vcl_purge{} - -req.* - -fail - -synth - -restart + +cnt_purge: + +vcl_purge{} + +req.* + +fail + +synth + +restart -hash:lookup:s->purge:top:n - - +hash:lookup:s->purge:top:n + + From dridi.boukelmoune at gmail.com Tue Feb 12 10:03:10 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 12 Feb 2019 10:03:10 +0000 (UTC) Subject: [6.0] 0a1463a23 do not unlock oh before the waitinglist setup is complete Message-ID: <20190212100310.6774F7C83@lists.varnish-cache.org> commit 0a1463a2381b2456cc0053d15e5c27a018b58cc9 Author: Nils Goroll Date: Wed Dec 5 13:23:38 2018 +0100 do not unlock oh before the waitinglist setup is complete The moment we unlock the oh, another thread could rush req Partially undoes f35b86bc1d3a9d1b61979667fc07e4fffedc27ae Huge thank you to @mbgrydeland for spotting my mistake diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index 78b61ce11..f4d2fecce 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -524,11 +524,9 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp) /* There are one or more busy objects, wait for them */ VTAILQ_INSERT_TAIL(&oh->waitinglist, req, w_list); - Lck_Unlock(&oh->mtx); AZ(req->hash_ignore_busy); - wrk->stats->busy_sleep++; /* * The objhead reference transfers to the sess, we get it * back when the sess comes off the waiting list and @@ -541,6 +539,9 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp) if (DO_DEBUG(DBG_WAITINGLIST)) VSLb(req->vsl, SLT_Debug, "on waiting list <%p>", oh); + Lck_Unlock(&oh->mtx); + + wrk->stats->busy_sleep++; return (HSH_BUSY); } From dridi.boukelmoune at gmail.com Tue Feb 12 13:28:09 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 12 Feb 2019 13:28:09 +0000 (UTC) Subject: [6.0] 4cc66784f test durations with decimals as inputs to std.duration Message-ID: <20190212132810.057E564C59@lists.varnish-cache.org> commit 4cc66784f1259475cc1f75ee09cd9e9d0fb2b35e Author: Nils Goroll Date: Sun Dec 9 22:22:21 2018 +0100 test durations with decimals as inputs to std.duration diff --git a/bin/varnishtest/tests/m00005.vtc b/bin/varnishtest/tests/m00005.vtc index fecbe3fc6..13e8c2dc9 100644 --- a/bin/varnishtest/tests/m00005.vtc +++ b/bin/varnishtest/tests/m00005.vtc @@ -14,13 +14,17 @@ varnish v1 -vcl+backend { } -start client c1 { + txreq -hdr "ttl: 0.010s" + rxresp + expect resp.http.ttl == 1000000.010 + txreq -hdr "ttl: 10ms" rxresp expect resp.http.ttl == 1000000.010 - txreq -hdr "ttl: 10s" + txreq -hdr "ttl: 10.1s" rxresp - expect resp.http.ttl == 1000010.000 + expect resp.http.ttl == 1000010.100 txreq -hdr "ttl: 10m" rxresp From dridi.boukelmoune at gmail.com Tue Feb 12 13:28:10 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 12 Feb 2019 13:28:10 +0000 (UTC) Subject: [6.0] 9e6ec423f Release wrk->vcl before (potentially) long-running worker jobs which do not need it (acceptor, h2_sess) Message-ID: <20190212132810.1E0D464C5C@lists.varnish-cache.org> commit 9e6ec423f67ff3840ea76200abd9d7b87a558190 Author: Poul-Henning Kamp Date: Mon Dec 10 09:22:04 2018 +0000 Release wrk->vcl before (potentially) long-running worker jobs which do not need it (acceptor, h2_sess) diff --git a/bin/varnishd/cache/cache_acceptor.c b/bin/varnishd/cache/cache_acceptor.c index b05a53a59..fb37ad574 100644 --- a/bin/varnishd/cache/cache_acceptor.c +++ b/bin/varnishd/cache/cache_acceptor.c @@ -460,6 +460,10 @@ vca_accept_task(struct worker *wrk, void *arg) while (!pool_accepting) VTIM_sleep(.1); + /* Dont hold on to (possibly) discarded VCLs */ + if (wrk->vcl != NULL) + VCL_Rel(&wrk->vcl); + while (!ps->pool->die) { INIT_OBJ(&wa, WRK_ACCEPT_MAGIC); wa.acceptlsock = ls; @@ -535,12 +539,6 @@ vca_accept_task(struct worker *wrk, void *arg) if (!ps->pool->die && DO_DEBUG(DBG_SLOW_ACCEPTOR)) VTIM_sleep(2.0); - /* - * We were able to hand off, so release this threads VCL - * reference (if any) so we don't hold on to discarded VCLs. - */ - if (wrk->vcl != NULL) - VCL_Rel(&wrk->vcl); } } diff --git a/bin/varnishd/http2/cache_http2_session.c b/bin/varnishd/http2/cache_http2_session.c index ce114d390..246400de7 100644 --- a/bin/varnishd/http2/cache_http2_session.c +++ b/bin/varnishd/http2/cache_http2_session.c @@ -345,6 +345,9 @@ h2_new_session(struct worker *wrk, void *arg) sp = req->sp; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + if (wrk->vcl) + VCL_Rel(&wrk->vcl); + assert(req->transport == &H2_transport); assert (req->err_code == H2_PU_MARKER || req->err_code == H2_OU_MARKER); From phk at FreeBSD.org Tue Feb 12 20:05:10 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 12 Feb 2019 20:05:10 +0000 (UTC) Subject: [master] f6abce43a Refactor our "call into VCL" code a little Message-ID: <20190212200510.1963F9C130@lists.varnish-cache.org> commit f6abce43a7e5b4b9cffa85b77ccc723f3946af45 Author: Poul-Henning Kamp Date: Tue Feb 12 20:04:02 2019 +0000 Refactor our "call into VCL" code a little diff --git a/bin/varnishd/cache/cache_director.c b/bin/varnishd/cache/cache_director.c index bff135a1f..562059ae1 100644 --- a/bin/varnishd/cache/cache_director.c +++ b/bin/varnishd/cache/cache_director.c @@ -298,7 +298,7 @@ do_list(struct cli *cli, struct director *d, void *priv) if (d->vdir->admin_health == VDI_AH_DELETED) return (0); - ctx = VCL_Get_CliCtx(0,0); + ctx = VCL_Get_CliCtx(0); // XXX admin health "probe" for the no-probe case is confusing VCLI_Out(cli, "\n%-*s %-*s ", @@ -333,7 +333,7 @@ do_list_json(struct cli *cli, struct director *d, void *priv) if (d->vdir->admin_health == VDI_AH_DELETED) return (0); - ctx = VCL_Get_CliCtx(0,0); + ctx = VCL_Get_CliCtx(0); VCLI_Out(cli, "%s", la->jsep); la->jsep = ",\n"; diff --git a/bin/varnishd/cache/cache_varnishd.h b/bin/varnishd/cache/cache_varnishd.h index 07fd45969..2fdd427ba 100644 --- a/bin/varnishd/cache/cache_varnishd.h +++ b/bin/varnishd/cache/cache_varnishd.h @@ -389,7 +389,7 @@ const char *VCL_Return_Name(unsigned); const char *VCL_Method_Name(unsigned); void VCL_Bo2Ctx(struct vrt_ctx *, struct busyobj *); void VCL_Req2Ctx(struct vrt_ctx *, struct req *); -struct vrt_ctx *VCL_Get_CliCtx(unsigned, int); +struct vrt_ctx *VCL_Get_CliCtx(int); void VCL_Rel_CliCtx(struct vrt_ctx **); #define VCL_MET_MAC(l,u,t,b) \ diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c index a524a7981..cf9133ed6 100644 --- a/bin/varnishd/cache/cache_vcl.c +++ b/bin/varnishd/cache/cache_vcl.c @@ -109,7 +109,7 @@ VCL_Req2Ctx(struct vrt_ctx *ctx, struct req *req) /*--------------------------------------------------------------------*/ struct vrt_ctx * -VCL_Get_CliCtx(unsigned method, int msg) +VCL_Get_CliCtx(int msg) { ASSERT_CLI(); @@ -117,7 +117,6 @@ VCL_Get_CliCtx(unsigned method, int msg) INIT_OBJ(&ctx_cli, VRT_CTX_MAGIC); handling_cli = 0; ctx_cli.handling = &handling_cli; - ctx_cli.method = method; ctx_cli.now = VTIM_real(); if (msg) { ctx_cli.msg = VSB_new_auto(); @@ -158,6 +157,8 @@ vcl_send_event(VRT_CTX, enum vcl_event_e ev) ev == VCL_EVENT_WARM || ev == VCL_EVENT_COLD || ev == VCL_EVENT_DISCARD); + assert(ev != VCL_EVENT_LOAD || ctx->method == VCL_MET_INIT); + assert(ev != VCL_EVENT_DISCARD || ctx->method == VCL_MET_FINI); AN(ctx->handling); *ctx->handling = 0; AN(ctx->ws); @@ -533,7 +534,8 @@ vcl_set_state(VRT_CTX, const char *state) } static void -vcl_cancel_load(VRT_CTX, struct cli *cli, const char *name, const char *step) +vcl_cancel_load(struct vrt_ctx *ctx, struct cli *cli, + const char *name, const char *step) { struct vcl *vcl = ctx->vcl; @@ -545,8 +547,9 @@ vcl_cancel_load(VRT_CTX, struct cli *cli, const char *name, const char *step) VCLI_Out(cli, "VCL \"%s\" Failed %s", name, step); if (VSB_len(ctx->msg)) VCLI_Out(cli, "\nMessage:\n\t%s", VSB_data(ctx->msg)); - *ctx->handling = 0; + ctx->method = VCL_MET_FINI; AZ(vcl_send_event(ctx, VCL_EVENT_DISCARD)); + ctx->method = 0; vcl_KillBackends(vcl); free(vcl->loaded_name); VCL_Close(&vcl); @@ -584,7 +587,9 @@ vcl_load(struct cli *cli, struct vrt_ctx *ctx, ctx->vcl = vcl; VSB_clear(ctx->msg); + ctx->method = VCL_MET_INIT; i = vcl_send_event(ctx, VCL_EVENT_LOAD); + ctx->method = 0; if (i || *ctx->handling != VCL_RET_OK) { vcl_cancel_load(ctx, cli, name, "initialization"); return; @@ -616,7 +621,7 @@ VCL_Poll(void) struct vcl *vcl, *vcl2; ASSERT_CLI(); - ctx = VCL_Get_CliCtx(0, 0); + ctx = VCL_Get_CliCtx(0); VTAILQ_FOREACH_SAFE(vcl, &vcl_head, list, vcl2) { if (vcl->temp == VCL_TEMP_BUSY || vcl->temp == VCL_TEMP_COOLING) { @@ -630,10 +635,11 @@ VCL_Poll(void) assert(vcl != vcl_active); assert(VTAILQ_EMPTY(&vcl->ref_list)); VTAILQ_REMOVE(&vcl_head, vcl, list); - ctx->method = VCL_MET_FINI; ctx->vcl = vcl; ctx->syntax = ctx->vcl->conf->syntax; + ctx->method = VCL_MET_FINI; AZ(vcl_send_event(ctx, VCL_EVENT_DISCARD)); + ctx->method = 0; vcl_KillBackends(vcl); free(vcl->loaded_name); VCL_Close(&vcl); @@ -732,7 +738,7 @@ vcl_cli_load(struct cli *cli, const char * const *av, void *priv) AZ(priv); ASSERT_CLI(); - ctx = VCL_Get_CliCtx(VCL_MET_INIT, 1); + ctx = VCL_Get_CliCtx(1); vcl_load(cli, ctx, av[2], av[3], av[4]); VCL_Rel_CliCtx(&ctx); } @@ -746,7 +752,7 @@ vcl_cli_state(struct cli *cli, const char * const *av, void *priv) ASSERT_CLI(); AN(av[2]); AN(av[3]); - ctx = VCL_Get_CliCtx(0, 1); + ctx = VCL_Get_CliCtx(1); ctx->vcl = vcl_find(av[2]); AN(ctx->vcl); // MGT ensures this if (vcl_set_state(ctx, av[3])) { From nils.goroll at uplex.de Wed Feb 13 06:56:07 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 13 Feb 2019 06:56:07 +0000 (UTC) Subject: [master] 5ecae908c stop using "purge" in the context of bans Message-ID: <20190213065607.9AB12ADFC7@lists.varnish-cache.org> commit 5ecae908c8cfb9c6d2422d55d1081e5941b8a6e1 Author: Nils Goroll Date: Wed Feb 13 07:52:42 2019 +0100 stop using "purge" in the context of bans diff --git a/bin/varnishtest/tests/c00022.vtc b/bin/varnishtest/tests/c00022.vtc index 79a034fb2..42383a63a 100644 --- a/bin/varnishtest/tests/c00022.vtc +++ b/bin/varnishtest/tests/c00022.vtc @@ -20,11 +20,11 @@ server s1 { varnish v1 -vcl+backend { sub vcl_recv { - if (req.method == "PURGE") { + if (req.method == "BAN") { ban ("req.url == " + req.url); return (synth(410)); } - if (req.method == "PURGESTR") { + if (req.method == "BANSTR") { ban ("" + req.http.ban); return (synth(410)); } @@ -42,7 +42,7 @@ client c1 { # Ban: something else client c1 { - txreq -req PURGE -url /foox + txreq -req BAN -url /foox rxresp expect resp.status == 410 } -run @@ -59,7 +59,7 @@ client c1 { # Ban: it client c1 { - txreq -req PURGE -url /foo + txreq -req BAN -url /foo rxresp expect resp.status == 410 } -run @@ -76,7 +76,7 @@ client c1 { # Ban: everything else client c1 { - txreq -req PURGESTR -hdr "ban: req.url != /foo" + txreq -req BANSTR -hdr "ban: req.url != /foo" rxresp expect resp.status == 410 } -run @@ -93,7 +93,7 @@ client c1 { # Ban: it client c1 { - txreq -req PURGESTR -hdr "Ban: obj.http.foo == bar6" + txreq -req BANSTR -hdr "Ban: obj.http.foo == bar6" rxresp expect resp.status == 410 } -run @@ -110,7 +110,7 @@ client c1 { # Ban: something else client c1 { - txreq -req PURGESTR -hdr "Ban: obj.http.foo == bar6" + txreq -req BANSTR -hdr "Ban: obj.http.foo == bar6" rxresp expect resp.status == 410 } -run @@ -128,7 +128,7 @@ client c1 { # Header match client c1 { - txreq -req PURGESTR -hdr "Ban: req.http.foo == barcheck" + txreq -req BANSTR -hdr "Ban: req.http.foo == barcheck" rxresp expect resp.status == 410 } -run @@ -144,7 +144,7 @@ client c1 { # Header match client c1 { - txreq -req PURGESTR -hdr "Ban: obj.http.foo == barcheck" + txreq -req BANSTR -hdr "Ban: obj.http.foo == barcheck" rxresp expect resp.status == 410 } -run diff --git a/bin/varnishtest/tests/v00011.vtc b/bin/varnishtest/tests/v00011.vtc index ea79b6492..9d391d3c0 100644 --- a/bin/varnishtest/tests/v00011.vtc +++ b/bin/varnishtest/tests/v00011.vtc @@ -10,7 +10,7 @@ server s1 { varnish v1 -vcl+backend { sub vcl_recv { - if (req.method == "PURGE") { + if (req.method == "BAN") { ban(req.http.doesntexist); ban(""); ban("req.url"); @@ -43,7 +43,7 @@ logexpect l1 -v v1 -d 1 -g vxid { } -start client c1 { - txreq -req "PURGE" + txreq -req "BAN" rxresp expect resp.http.X-Varnish == "1004" expect resp.status == 209 From phk at FreeBSD.org Wed Feb 13 13:06:10 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 13 Feb 2019 13:06:10 +0000 (UTC) Subject: [master] 4709fae3a Don't panic if you try to relabel a VCL with the same label. Message-ID: <20190213130610.A5C19BFB99@lists.varnish-cache.org> commit 4709fae3a703b5904a799b8aa1df2872e803219f Author: Poul-Henning Kamp Date: Wed Feb 13 13:04:30 2019 +0000 Don't panic if you try to relabel a VCL with the same label. Fixes #2834 diff --git a/bin/varnishd/mgt/mgt_vcl.c b/bin/varnishd/mgt/mgt_vcl.c index 7d8acb572..1a51ba07c 100644 --- a/bin/varnishd/mgt/mgt_vcl.c +++ b/bin/varnishd/mgt/mgt_vcl.c @@ -918,6 +918,13 @@ mcf_vcl_label(struct cli *cli, const char * const *av, void *priv) VCLI_Out(cli, "%s is not a label", vpl->name); return; } + if (!VTAILQ_EMPTY(&vpl->dfrom) && + VTAILQ_FIRST(&vpl->dfrom)->to == vpt) { + VCLI_SetResult(cli, CLIS_PARAM); + VCLI_Out(cli, "VCL '%s' already has label '%s'", + vpt->name, vpl->name); + return; + } if (!VTAILQ_EMPTY(&vpt->dfrom) && !VTAILQ_EMPTY(&vpl->dto)) { VCLI_SetResult(cli, CLIS_PARAM); diff --git a/bin/varnishtest/tests/c00077.vtc b/bin/varnishtest/tests/c00077.vtc index 49ed76797..c32983893 100644 --- a/bin/varnishtest/tests/c00077.vtc +++ b/bin/varnishtest/tests/c00077.vtc @@ -13,6 +13,10 @@ varnish v1 -vcl+backend { varnish v1 -clierr 106 "vcl.label vcl.A vcl1" varnish v1 -cliok "vcl.label vclA vcl1" +varnish v1 -clierr 106 "vcl.label vclA vcl1" +varnish v1 -cliexpect {VCL 'vcl1' already has label 'vclA'} { + vcl.label vclA vcl1 +} varnish v1 -vcl+backend { sub vcl_recv { From nils.goroll at uplex.de Thu Feb 14 17:17:08 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Thu, 14 Feb 2019 17:17:08 +0000 (UTC) Subject: [master] 965857f2b improve beresp.filters doc Message-ID: <20190214171708.ADE5FB2627@lists.varnish-cache.org> commit 965857f2b0605bbc791c794879109c778c81b69a Author: Nils Goroll Date: Thu Feb 14 18:15:56 2019 +0100 improve beresp.filters doc diff --git a/doc/sphinx/reference/vcl_var.rst b/doc/sphinx/reference/vcl_var.rst index c962f3147..e50139020 100644 --- a/doc/sphinx/reference/vcl_var.rst +++ b/doc/sphinx/reference/vcl_var.rst @@ -938,7 +938,48 @@ beresp.filters Writable from: vcl_backend_response - List of VFP filters the beresp.body will be pulled through. + List of Varnish Fetch Processor (VFP) filters the beresp.body + will be pulled through. + + VFP Filters change the body before going into the cache and/or + being handed to the client side, where it may get processed + again by resp.filters. + + The following VFP filters exist in varnish-cache: + + * ``testgunzip``: Test if a body is valid gzip and refuse it + otherwise + + * ``gunzip``: Uncompress gzip content + + * ``esi``: ESI-process plain text content + + * ``esi_gzip``: Save gzipped snippets for efficient + ESI-processing + + This filter enables stitching together ESI from individually + gzipped fragments, saving processing power for + re-compression on the client side at the expense of some + compression efficiency. + + Additional VFP filters are available from VMODs. + + By default, beresp.filters is constructed as follows: + + * ``gunzip`` gets added for gzipped content if + ``beresp.do_gunzip`` or ``beresp.do_esi`` are true. + + * ``esi_gzip`` gets added if ``beresp.do_esi`` is true + together with ``beresp.do_gzip`` or content is already + compressed. + + * ``esi`` gets added if ``beresp.do_esi`` is true + + * ``gzip`` gets added for uncompressed content if + ``beresp.do_gzip`` is true + + * ``testgunzip`` gets added for compressed content if + ``beresp.do_gunzip`` is false. obj ~~~ From dridi at varni.sh Fri Feb 15 14:14:44 2019 From: dridi at varni.sh (Dridi Boukelmoune) Date: Fri, 15 Feb 2019 15:14:44 +0100 Subject: [master] 70693bee0 do we want to retire backend.list -v ? In-Reply-To: <20190205105209.13FE3A72E4@lists.varnish-cache.org> References: <20190205105209.13FE3A72E4@lists.varnish-cache.org> Message-ID: On Tue, Feb 5, 2019 at 11:52 AM Nils Goroll wrote: > > > commit 70693bee053043f696b221cb5daba8f040b9b06e > Author: Nils Goroll > Date: Tue Feb 5 11:51:34 2019 +0100 > > do we want to retire backend.list -v ? > > diff --git a/bin/varnishd/cache/cache_director.c b/bin/varnishd/cache/cache_director.c > index 3b21903f4..bff135a1f 100644 > --- a/bin/varnishd/cache/cache_director.c > +++ b/bin/varnishd/cache/cache_director.c > @@ -371,6 +371,10 @@ cli_backend_list(struct cli *cli, const char * const *av, void *priv) > struct list_args la[1]; > int i; > > + /* > + * XXX for all cases in varnish-cache, -v is synonymous to > + * -p and -v is not documented. Retire? I think we should kill it before the March release, good catch! > + */ > (void)priv; > ASSERT_CLI(); > INIT_OBJ(la, LIST_ARGS_MAGIC); > _______________________________________________ > varnish-commit mailing list > varnish-commit at varnish-cache.org > https://www.varnish-cache.org/lists/mailman/listinfo/varnish-commit From nils.goroll at uplex.de Fri Feb 15 15:16:09 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Fri, 15 Feb 2019 15:16:09 +0000 (UTC) Subject: [master] 4288f45bd I forgot the simplest of them all Message-ID: <20190215151609.24CA9A4186@lists.varnish-cache.org> commit 4288f45bd0b29313a5115764fca150060e27d0c9 Author: Nils Goroll Date: Fri Feb 15 16:15:12 2019 +0100 I forgot the simplest of them all diff --git a/doc/sphinx/reference/vcl_var.rst b/doc/sphinx/reference/vcl_var.rst index e50139020..2aedb54f7 100644 --- a/doc/sphinx/reference/vcl_var.rst +++ b/doc/sphinx/reference/vcl_var.rst @@ -947,6 +947,8 @@ beresp.filters The following VFP filters exist in varnish-cache: + * ``gzip``: compress a body using gzip + * ``testgunzip``: Test if a body is valid gzip and refuse it otherwise From phk at phk.freebsd.dk Fri Feb 15 17:12:12 2019 From: phk at phk.freebsd.dk (Poul-Henning Kamp) Date: Fri, 15 Feb 2019 17:12:12 +0000 Subject: [master] 70693bee0 do we want to retire backend.list -v ? In-Reply-To: References: <20190205105209.13FE3A72E4@lists.varnish-cache.org> Message-ID: <5194.1550250732@critter.freebsd.dk> -------- In message , Dridi Boukelmoune writes: >> + /* >> + * XXX for all cases in varnish-cache, -v is synonymous to >> + * -p and -v is not documented. Retire? > >I think we should kill it before the March release, good catch! No objection. -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk at FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence. From dridi.boukelmoune at gmail.com Sat Feb 16 09:12:08 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Sat, 16 Feb 2019 09:12:08 +0000 (UTC) Subject: [master] a2a5cf1ba VDP_Push itself is not fail-safe Message-ID: <20190216091208.1EC199095@lists.varnish-cache.org> commit a2a5cf1ba9c21d510699852d99a6864d8b68b9d6 Author: Dridi Boukelmoune Date: Sat Feb 16 10:10:07 2019 +0100 VDP_Push itself is not fail-safe Refs 832d6da2d732636b42a78920980a84b3e33bda9b diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index 9279baaa7..df30f0e8c 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -833,14 +833,14 @@ ved_deliver(struct req *req, struct boc *boc, int wantbody) INIT_OBJ(foo, VED_FOO_MAGIC); foo->ecx = ecx; - AZ(VDP_Push(req, &ved_gzgz, foo)); + XXXAZ(VDP_Push(req, &ved_gzgz, foo)); } else if (ecx->isgzip && !i) { /* Non-Gzip'ed include in gzip'ed parent */ - AZ(VDP_Push(req, &ved_pretend_gz, ecx)); + XXXAZ(VDP_Push(req, &ved_pretend_gz, ecx)); } else { /* Anything else goes straight through */ - AZ(VDP_Push(req, &ved_ved, ecx)); + XXXAZ(VDP_Push(req, &ved_ved, ecx)); } (void)VDP_DeliverObj(req); (void)VDP_bytes(req, VDP_FLUSH, NULL, 0); From nils.goroll at uplex.de Sun Feb 17 11:43:07 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Sun, 17 Feb 2019 11:43:07 +0000 (UTC) Subject: [master] 9bca6f7b5 retire undocumented backend.list -v option Message-ID: <20190217114307.B35FEB2B13@lists.varnish-cache.org> commit 9bca6f7b504221e7fdb2344daa9901fe980a68dc Author: Nils Goroll Date: Sun Feb 17 12:41:47 2019 +0100 retire undocumented backend.list -v option as agreed on -commit. Closes #2906 diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c index 36f036fdc..f5b867335 100644 --- a/bin/varnishd/cache/cache_backend.c +++ b/bin/varnishd/cache/cache_backend.c @@ -446,8 +446,8 @@ vbe_panic(const struct director *d, struct vsb *vsb) */ static void v_matchproto_(vdi_list_f) -vbe_list(VRT_CTX, const struct director *d, struct vsb *vsb, int vflag, - int pflag, int jflag) +vbe_list(VRT_CTX, const struct director *d, struct vsb *vsb, int pflag, + int jflag) { struct backend *bp; @@ -457,12 +457,12 @@ vbe_list(VRT_CTX, const struct director *d, struct vsb *vsb, int vflag, CAST_OBJ_NOTNULL(bp, d->priv, BACKEND_MAGIC); if (bp->probe != NULL) - VBP_Status(vsb, bp, vflag | pflag, jflag); - else if (jflag && (vflag | pflag)) + VBP_Status(vsb, bp, pflag, jflag); + else if (jflag && pflag) VSB_printf(vsb, "{},\n"); else if (jflag) VSB_printf(vsb, "\"%s\"", d->sick ? "sick" : "healthy"); - else if (vflag | pflag) + else if (pflag) return; else VSB_printf(vsb, "%-*s", VDI_LIST_W_PROBE, diff --git a/bin/varnishd/cache/cache_director.c b/bin/varnishd/cache/cache_director.c index 562059ae1..c8a4d863c 100644 --- a/bin/varnishd/cache/cache_director.c +++ b/bin/varnishd/cache/cache_director.c @@ -272,7 +272,6 @@ struct list_args { unsigned magic; #define LIST_ARGS_MAGIC 0x7e7cefeb int p; - int v; int j; const char *jsep; }; @@ -306,14 +305,14 @@ do_list(struct cli *cli, struct director *d, void *priv) VDI_LIST_W_ADMIN, VDI_Ahealth(d)); if (d->vdir->methods->list != NULL) - d->vdir->methods->list(ctx, d, cli->sb, 0, 0, 0); + d->vdir->methods->list(ctx, d, cli->sb, 0, 0); else VCLI_Out(cli, "%-*s", VDI_LIST_W_PROBE, cli_health(ctx, d)); VTIM_format(d->vdir->health_changed, time_str); VCLI_Out(cli, " %s", time_str); - if ((la->p || la->v) && d->vdir->methods->list != NULL) - d->vdir->methods->list(ctx, d, cli->sb, la->p, la->v, 0); + if (la->p && d->vdir->methods->list != NULL) + d->vdir->methods->list(ctx, d, cli->sb, la->p, 0); VCL_Rel_CliCtx(&ctx); AZ(ctx); @@ -345,14 +344,14 @@ do_list_json(struct cli *cli, struct director *d, void *priv) VCLI_Out(cli, "\"admin_health\": \"%s\",\n", VDI_Ahealth(d)); VCLI_Out(cli, "\"probe_message\": "); if (d->vdir->methods->list != NULL) - d->vdir->methods->list(ctx, d, cli->sb, 0, 0, 1); + d->vdir->methods->list(ctx, d, cli->sb, 0, 1); else VCLI_Out(cli, "\"%s\"", cli_health(ctx, d)); VCLI_Out(cli, ",\n"); - if ((la->p || la->v) && d->vdir->methods->list != NULL) { + if (la->p && d->vdir->methods->list != NULL) { VCLI_Out(cli, "\"probe_details\": "); - d->vdir->methods->list(ctx, d, cli->sb, la->p, la->v, 1); + d->vdir->methods->list(ctx, d, cli->sb, la->p, 1); } VCLI_Out(cli, "\"last_change\": %.3f\n", d->vdir->health_changed); VSB_indent(cli->sb, -2); @@ -371,10 +370,6 @@ cli_backend_list(struct cli *cli, const char * const *av, void *priv) struct list_args la[1]; int i; - /* - * XXX for all cases in varnish-cache, -v is synonymous to - * -p and -v is not documented. Retire? - */ (void)priv; ASSERT_CLI(); INIT_OBJ(la, LIST_ARGS_MAGIC); @@ -384,7 +379,6 @@ cli_backend_list(struct cli *cli, const char * const *av, void *priv) switch(*p) { case 'j': la->j = 1; break; case 'p': la->p = !la->p; break; - case 'v': la->p = !la->p; break; default: VCLI_Out(cli, "Invalid flag %c", *p); VCLI_SetResult(cli, CLIS_PARAM); diff --git a/doc/changes.rst b/doc/changes.rst index d8fb2404c..ad3a2659a 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -68,6 +68,9 @@ Varnish Cache trunk (ongoing) For best forward compatibility, we recommend that scripts parse JSON output as obtained using the ``-j`` option. +* The undocumented ``-v`` option to the ``backend.list`` cli command + has been removed + VCL --- diff --git a/include/vrt.h b/include/vrt.h index 091508dda..11c4eb2c2 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -478,7 +478,7 @@ typedef enum sess_close vdi_http1pipe_f(VRT_CTX, VCL_BACKEND); typedef void vdi_event_f(VCL_BACKEND, enum vcl_event_e); typedef void vdi_destroy_f(VCL_BACKEND); typedef void vdi_panic_f(VCL_BACKEND, struct vsb *); -typedef void vdi_list_f(VRT_CTX, VCL_BACKEND, struct vsb *, int, int, int); +typedef void vdi_list_f(VRT_CTX, VCL_BACKEND, struct vsb *, int, int); struct vdi_methods { unsigned magic; From nils.goroll at uplex.de Sun Feb 17 13:45:12 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Sun, 17 Feb 2019 13:45:12 +0000 (UTC) Subject: [master] 286604ce4 fix b00016.vtc Message-ID: <20190217134512.5D3DEBFE5E@lists.varnish-cache.org> commit 286604ce44e69e61405f83086f57b5e57d7d76dc Author: Nils Goroll Date: Sun Feb 17 14:42:50 2019 +0100 fix b00016.vtc The second vcl did not actually do anything useful because the second client would hit a cached response. diff --git a/bin/varnishtest/tests/b00016.vtc b/bin/varnishtest/tests/b00016.vtc index abf25b3b6..80d28d8cb 100644 --- a/bin/varnishtest/tests/b00016.vtc +++ b/bin/varnishtest/tests/b00016.vtc @@ -1,14 +1,17 @@ varnishtest "Check naming of backends" -server s1 { +server s1 -repeat 2 -keepalive { rxreq txresp } -start varnish v1 -vcl+backend { + sub vcl_recv { + return (pass); + } sub vcl_backend_response { - set beresp.http.X-Backend-Name = bereq.backend; + set beresp.http.X-Backend-Name = bereq.backend; } } -start @@ -28,15 +31,18 @@ varnish v1 -vcl+backend { sub vcl_recv { set req.backend_hint = bar.backend(); + return (pass); } sub vcl_backend_response { - set beresp.http.X-Backend-Name = bereq.backend; + set beresp.http.X-Director-Name = bereq.backend; + set beresp.http.X-Backend-Name = beresp.backend; } } client c1 { txreq -url "/" rxresp + expect resp.http.X-Director-Name == "bar" expect resp.http.X-Backend-Name == "s1" } -run From nils.goroll at uplex.de Mon Feb 18 09:49:03 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 18 Feb 2019 09:49:03 +0000 (UTC) Subject: [master] b06cdbbab Add bans on obj.ttl, obj.age, obj.grace and obj.keep Message-ID: <20190218094903.841ABA554D@lists.varnish-cache.org> commit b06cdbbab4099a351e188106add56b5e1eb0b927 Author: Nils Goroll Date: Fri Feb 15 14:49:22 2019 +0100 Add bans on obj.ttl, obj.age, obj.grace and obj.keep Also add a duration argument type and the operators >, >=, < and <= for use with it (besides the existing == and !=). obj.ttl and obj.age are compared relative to the time the ban was issued, as required by the fact that bans are evaluated some arbitrary time after they are created. For this reason, the ban_dups parameter has no effect on obj.ttl and obj.age bans, duplicates of bans using these fields are never removed. obj.grace and obj.keep are compared as absolute values. In an effort to support The Proprietary Stevedore (tm) [or any other storage engine supporting persistent bans - if any?], the existing ban serialisation format is preserved and upgrades _should_ work seamlessly. But downgrades won't. Using the BANS_HAS_* macros, we try to make the relationship between the ban serialisation in cache_ban_build.c and access in cache_ban.c more obvious. We now generate all fields and operators from table files as well as the definition of allowed operators for fields. The user help text about allowed operators is generated at init time. diff --git a/bin/varnishd/cache/cache_ban.c b/bin/varnishd/cache/cache_ban.c index a8c9a08c1..122fd9aab 100644 --- a/bin/varnishd/cache/cache_ban.c +++ b/bin/varnishd/cache/cache_ban.c @@ -31,6 +31,7 @@ #include "config.h" #include +#include #include "cache_varnishd.h" #include "cache_ban.h" @@ -40,6 +41,10 @@ #include "vend.h" #include "vmb.h" +/* cache_ban_build.c */ +void BAN_Build_Init(void); +void BAN_Build_Fini(void); + struct lock ban_mtx; int ban_shutdown; struct banhead_s ban_head = VTAILQ_HEAD_INITIALIZER(ban_head); @@ -55,9 +60,18 @@ struct ban_test { uint8_t arg1; const char *arg1_spec; const char *arg2; + double arg2_double; const void *arg2_spec; }; +static const char * const arg_name[BAN_ARGARRSZ + 1] = { +#define PVAR(a, b, c) [BAN_ARGIDX(c)] = (a), +#include "tbl/ban_vars.h" + [BAN_ARGARRSZ] = NULL +}; + +extern const char * const oper[BAN_OPERARRSZ + 1]; + /*-------------------------------------------------------------------- * Storage handling of bans */ @@ -148,6 +162,9 @@ ban_equal(const uint8_t *bs1, const uint8_t *bs2) u = vbe32dec(bs1 + BANS_LENGTH); if (u != vbe32dec(bs2 + BANS_LENGTH)) return (0); + if (bs1[BANS_FLAGS] & BANS_FLAG_NODEDUP) + return (0); + return (!memcmp(bs1 + BANS_LENGTH, bs2 + BANS_LENGTH, u - BANS_LENGTH)); } @@ -200,16 +217,25 @@ ban_get_lump(const uint8_t **bs) static void ban_iter(const uint8_t **bs, struct ban_test *bt) { + uint64_t dtmp; memset(bt, 0, sizeof *bt); + bt->arg2_double = nan(""); bt->arg1 = *(*bs)++; - if (bt->arg1 == BANS_ARG_REQHTTP || bt->arg1 == BANS_ARG_OBJHTTP) { + if (BANS_HAS_ARG1_SPEC(bt->arg1)) { bt->arg1_spec = (const char *)*bs; (*bs) += (*bs)[0] + 2; } + if (BANS_HAS_ARG2_DOUBLE(bt->arg1)) { + dtmp = vbe64dec(ban_get_lump(bs)); + bt->oper = *(*bs)++; + + memcpy(&bt->arg2_double, &dtmp, sizeof dtmp); + return; + } bt->arg2 = ban_get_lump(bs); bt->oper = *(*bs)++; - if (bt->oper == BANS_OPER_MATCH || bt->oper == BANS_OPER_NMATCH) + if (BANS_HAS_ARG2_SPEC(bt->oper)) bt->arg2_spec = ban_get_lump(bs); } @@ -456,20 +482,32 @@ BAN_Time(const struct ban *b) */ int -ban_evaluate(struct worker *wrk, const uint8_t *bs, struct objcore *oc, +ban_evaluate(struct worker *wrk, const uint8_t *bsarg, struct objcore *oc, const struct http *reqhttp, unsigned *tests) { struct ban_test bt; - const uint8_t *be; + const uint8_t *bs, *be; const char *p; const char *arg1; + double darg1, darg2; + + /* + * for ttl and age, fix the point in time such that banning refers to + * the same point in time when the ban is evaluated + * + * for grace/keep, we assume that the absolute values are pola and that + * users will most likely also specify a ttl criterion if they want to + * fix a point in time (such as "obj.ttl > 5h && obj.keep > 3h") + */ + bs = bsarg; be = bs + ban_len(bs); bs += BANS_HEAD_LEN; while (bs < be) { (*tests)++; ban_iter(&bs, &bt); arg1 = NULL; + darg1 = darg2 = nan(""); switch (bt.arg1) { case BANS_ARG_URL: AN(reqhttp); @@ -486,18 +524,42 @@ ban_evaluate(struct worker *wrk, const uint8_t *bs, struct objcore *oc, case BANS_ARG_OBJSTATUS: arg1 = HTTP_GetHdrPack(wrk, oc, H__Status); break; + case BANS_ARG_OBJTTL: + darg1 = oc->ttl + oc->t_origin; + darg2 = bt.arg2_double + ban_time(bsarg); + break; + case BANS_ARG_OBJAGE: + darg1 = 0.0 - oc->t_origin; + darg2 = 0.0 - (ban_time(bsarg) - bt.arg2_double); + break; + case BANS_ARG_OBJGRACE: + darg1 = oc->grace; + darg2 = bt.arg2_double; + break; + case BANS_ARG_OBJKEEP: + darg1 = oc->keep; + darg2 = bt.arg2_double; + break; default: WRONG("Wrong BAN_ARG code"); } switch (bt.oper) { case BANS_OPER_EQ: - if (arg1 == NULL || strcmp(arg1, bt.arg2)) + if (arg1 == NULL) { + if (isnan(darg1) || darg1 != darg2) + return (0); + } else if (strcmp(arg1, bt.arg2)) { return (0); + } break; case BANS_OPER_NEQ: - if (arg1 != NULL && !strcmp(arg1, bt.arg2)) + if (arg1 == NULL) { + if (! isnan(darg1) && darg1 == darg2) + return (0); + } else if (!strcmp(arg1, bt.arg2)) { return (0); + } break; case BANS_OPER_MATCH: if (arg1 == NULL || @@ -511,6 +573,30 @@ ban_evaluate(struct worker *wrk, const uint8_t *bs, struct objcore *oc, 0, 0, NULL, 0) >= 0) return (0); break; + case BANS_OPER_GT: + AZ(arg1); + assert(! isnan(darg1)); + if (!(darg1 > darg2)) + return (0); + break; + case BANS_OPER_GTE: + AZ(arg1); + assert(! isnan(darg1)); + if (!(darg1 >= darg2)) + return (0); + break; + case BANS_OPER_LT: + AZ(arg1); + assert(! isnan(darg1)); + if (!(darg1 < darg2)) + return (0); + break; + case BANS_OPER_LTE: + AZ(arg1); + assert(! isnan(darg1)); + if (!(darg1 <= darg2)) + return (0); + break; default: WRONG("Wrong BAN_OPER code"); } @@ -668,46 +754,67 @@ ccf_ban(struct cli *cli, const char * const *av, void *priv) } } +#define Ms 60 +#define Hs (Ms * 60) +#define Ds (Hs * 24) +#define Ws (Ds * 7) +#define Ys (Ds * 365) + +#define Xfmt(buf, var, s, unit) \ + ((var) >= s && (var) % s == 0) \ + bprintf((buf), "%ju" unit, (var) / s) + +// XXX move to VTIM? +#define vdur_render(buf, dur) do { \ + uint64_t dec = (uint64_t)floor(dur); \ + uint64_t frac = (uint64_t)floor((dur) * 1e3) % UINT64_C(1000); \ + if (dec == 0 && frac == 0) \ + (void) strncpy(buf, "0s", sizeof(buf)); \ + else if (dec == 0) \ + bprintf((buf), "%jums", frac); \ + else if (frac != 0) \ + bprintf((buf), "%ju.%03jus", dec, frac); \ + else if Xfmt(buf, dec, Ys, "y"); \ + else if Xfmt(buf, dec, Ws, "w"); \ + else if Xfmt(buf, dec, Ds, "d"); \ + else if Xfmt(buf, dec, Hs, "h"); \ + else if Xfmt(buf, dec, Ms, "m"); \ + else \ + bprintf((buf), "%jus", dec); \ + } while (0) + static void ban_render(struct cli *cli, const uint8_t *bs, int quote) { struct ban_test bt; const uint8_t *be; + char buf[64]; be = bs + ban_len(bs); bs += BANS_HEAD_LEN; while (bs < be) { ban_iter(&bs, &bt); - switch (bt.arg1) { - case BANS_ARG_URL: - VCLI_Out(cli, "req.url"); - break; - case BANS_ARG_REQHTTP: - VCLI_Out(cli, "req.http.%.*s", - bt.arg1_spec[0] - 1, bt.arg1_spec + 1); - break; - case BANS_ARG_OBJHTTP: - VCLI_Out(cli, "obj.http.%.*s", + ASSERT_BAN_ARG(bt.arg1); + ASSERT_BAN_OPER(bt.oper); + + if (BANS_HAS_ARG1_SPEC(bt.arg1)) + VCLI_Out(cli, "%s.%.*s", + arg_name[BAN_ARGIDX(bt.arg1)], bt.arg1_spec[0] - 1, bt.arg1_spec + 1); - break; - case BANS_ARG_OBJSTATUS: - VCLI_Out(cli, "obj.status"); - break; - default: - WRONG("Wrong BANS_ARG"); - } - switch (bt.oper) { - case BANS_OPER_EQ: VCLI_Out(cli, " == "); break; - case BANS_OPER_NEQ: VCLI_Out(cli, " != "); break; - case BANS_OPER_MATCH: VCLI_Out(cli, " ~ "); break; - case BANS_OPER_NMATCH: VCLI_Out(cli, " !~ "); break; - default: - WRONG("Wrong BANS_OPER"); - } - if (quote) - VCLI_Quote(cli, bt.arg2); else + VCLI_Out(cli, "%s", arg_name[BAN_ARGIDX(bt.arg1)]); + + VCLI_Out(cli, " %s ", oper[BAN_OPERIDX(bt.oper)]); + + if (BANS_HAS_ARG2_DOUBLE(bt.arg1)) { + vdur_render(buf, bt.arg2_double); + VCLI_Out(cli, "%s", buf); + } else if (quote) { + VCLI_Quote(cli, bt.arg2); + } else { VCLI_Out(cli, "%s", bt.arg2); + } + if (bs < be) VCLI_Out(cli, " && "); } @@ -867,6 +974,7 @@ BAN_Init(void) { struct ban_proto *bp; + BAN_Build_Init(); Lck_New(&ban_mtx, lck_ban); CLI_AddFuncs(ban_cmds); @@ -907,4 +1015,6 @@ BAN_Shutdown(void) /* Export the ban list to compact it */ ban_export(); Lck_Unlock(&ban_mtx); + + BAN_Build_Fini(); } diff --git a/bin/varnishd/cache/cache_ban.h b/bin/varnishd/cache/cache_ban.h index 1a9420825..c4d04fa23 100644 --- a/bin/varnishd/cache/cache_ban.h +++ b/bin/varnishd/cache/cache_ban.h @@ -73,16 +73,53 @@ #define BANS_FLAG_OBJ (1<<1) #define BANS_FLAG_COMPLETED (1<<2) #define BANS_FLAG_HTTP (1<<3) +#define BANS_FLAG_DURATION (1<<4) +#define BANS_FLAG_NODEDUP (1<<5) #define BANS_OPER_EQ 0x10 +#define _BANS_OPER_OFF BANS_OPER_EQ #define BANS_OPER_NEQ 0x11 #define BANS_OPER_MATCH 0x12 #define BANS_OPER_NMATCH 0x13 +#define BANS_OPER_GT 0x14 +#define BANS_OPER_GTE 0x15 +#define BANS_OPER_LT 0x16 +#define BANS_OPER_LTE 0x17 +#define _BANS_OPER_LIM (BANS_OPER_LTE + 1) + +#define BAN_OPERIDX(x) ((x) - _BANS_OPER_OFF) +#define BAN_OPERARRSZ (_BANS_OPER_LIM - _BANS_OPER_OFF) +#define ASSERT_BAN_OPER(x) assert((x) >= _BANS_OPER_OFF && (x) < _BANS_OPER_LIM) #define BANS_ARG_URL 0x18 +#define _BANS_ARG_OFF BANS_ARG_URL #define BANS_ARG_REQHTTP 0x19 #define BANS_ARG_OBJHTTP 0x1a #define BANS_ARG_OBJSTATUS 0x1b +#define BANS_ARG_OBJTTL 0x1c +#define BANS_ARG_OBJAGE 0x1d +#define BANS_ARG_OBJGRACE 0x1e +#define BANS_ARG_OBJKEEP 0x1f +#define _BANS_ARG_LIM (BANS_ARG_OBJKEEP + 1) + +#define BAN_ARGIDX(x) ((x) - _BANS_ARG_OFF) +#define BAN_ARGARRSZ (_BANS_ARG_LIM - _BANS_ARG_OFF) +#define ASSERT_BAN_ARG(x) assert((x) >= _BANS_ARG_OFF && (x) < _BANS_ARG_LIM) + +// has an arg1_spec (BANS_FLAG_HTTP at build time) +#define BANS_HAS_ARG1_SPEC(arg) \ + ((arg) == BANS_ARG_REQHTTP || \ + (arg) == BANS_ARG_OBJHTTP) + +// has an arg2_spec (regex) +#define BANS_HAS_ARG2_SPEC(oper) \ + ((oper) == BANS_OPER_MATCH || \ + (oper) == BANS_OPER_NMATCH) + +// has an arg2_double (BANS_FLAG_DURATION at build time) +#define BANS_HAS_ARG2_DOUBLE(arg) \ + ((arg) >= BANS_ARG_OBJTTL && \ + (arg) <= BANS_ARG_OBJKEEP) /*--------------------------------------------------------------------*/ diff --git a/bin/varnishd/cache/cache_ban_build.c b/bin/varnishd/cache/cache_ban_build.c index e3b9873a8..948df5d8a 100644 --- a/bin/varnishd/cache/cache_ban_build.c +++ b/bin/varnishd/cache/cache_ban_build.c @@ -37,6 +37,10 @@ #include "vend.h" #include "vtim.h" +#include "vnum.h" + +void BAN_Build_Init(void); +void BAN_Build_Fini(void); struct ban_proto { unsigned magic; @@ -61,6 +65,24 @@ static const struct pvar { { 0, 0, 0} }; +/* operators allowed per argument (pvar.tag) */ +static const unsigned arg_opervalid[BAN_ARGARRSZ + 1] = { +#define ARGOPER(arg, mask) [BAN_ARGIDX(arg)] = (mask), +#include "tbl/ban_arg_oper.h" + [BAN_ARGARRSZ] = 0 +}; + +// init'ed in _Init +static const char *arg_operhelp[BAN_ARGARRSZ + 1]; + +// operators +const char * const oper[BAN_OPERARRSZ + 1] = { +#define OPER(op, str) [BAN_OPERIDX(op)] = (str), +#include "tbl/ban_oper.h" + [BAN_OPERARRSZ] = NULL +}; + + /*-------------------------------------------------------------------- */ @@ -177,6 +199,18 @@ ban_parse_regexp(struct ban_proto *bp, const char *a3) return (0); } +static int +ban_parse_oper(const char *p) +{ + int i; + + for (i = 0; i < BAN_OPERARRSZ; i++) { + if (!strcmp(p, oper[i])) + return _BANS_OPER_OFF + i; + } + return -1; +} + /*-------------------------------------------------------------------- * Add a (and'ed) test-condition to a ban */ @@ -186,7 +220,10 @@ BAN_AddTest(struct ban_proto *bp, const char *a1, const char *a2, const char *a3) { const struct pvar *pv; - const char *err; + double darg; + uint64_t dtmp; + uint8_t denc[sizeof darg]; + int op; CHECK_OBJ_NOTNULL(bp, BAN_PROTO_MAGIC); AN(bp->vsb); @@ -208,28 +245,46 @@ BAN_AddTest(struct ban_proto *bp, bp->flags |= pv->flag; VSB_putc(bp->vsb, pv->tag); - if (pv->flag & BANS_FLAG_HTTP) + if (pv->flag & BANS_FLAG_HTTP) { + assert(BANS_HAS_ARG1_SPEC(pv->tag)); ban_parse_http(bp, a1 + strlen(pv->name)); + } + + op = ban_parse_oper(a2); + if (op < 0 || + ((1<tag)]) == 0) + return (ban_error(bp, + "expected conditional (%s) got \"%s\"", + arg_operhelp[BAN_ARGIDX(pv->tag)], + a2)); + + if ((pv->flag & BANS_FLAG_DURATION) == 0) { + assert(! BANS_HAS_ARG2_DOUBLE(pv->tag)); - ban_add_lump(bp, a3, strlen(a3) + 1); - if (!strcmp(a2, "~")) { - VSB_putc(bp->vsb, BANS_OPER_MATCH); - err = ban_parse_regexp(bp, a3); - if (err) - return (err); - } else if (!strcmp(a2, "!~")) { - VSB_putc(bp->vsb, BANS_OPER_NMATCH); - err = ban_parse_regexp(bp, a3); - if (err) - return (err); - } else if (!strcmp(a2, "==")) { - VSB_putc(bp->vsb, BANS_OPER_EQ); - } else if (!strcmp(a2, "!=")) { - VSB_putc(bp->vsb, BANS_OPER_NEQ); - } else { + ban_add_lump(bp, a3, strlen(a3) + 1); + VSB_putc(bp->vsb, op); + + if (! BANS_HAS_ARG2_SPEC(op)) + return (NULL); + + return (ban_parse_regexp(bp, a3)); + } + + assert(pv->flag & BANS_FLAG_DURATION); + assert(BANS_HAS_ARG2_DOUBLE(pv->tag)); + darg = VNUM_duration(a3); + if (isnan(darg)) { return (ban_error(bp, - "expected conditional (~, !~, == or !=) got \"%s\"", a2)); + "expected duration [ms|s|m|h|d|w|y] got \"%s\"", a3)); } + + assert(sizeof darg == sizeof dtmp); + assert(sizeof dtmp == sizeof denc); + memcpy(&dtmp, &darg, sizeof dtmp); + vbe64enc(denc, dtmp); + + ban_add_lump(bp, denc, sizeof denc); + VSB_putc(bp->vsb, op); return (NULL); } @@ -275,6 +330,7 @@ BAN_Commit(struct ban_proto *bp) b->flags = bp->flags; + // XXX why don't we vbe*enc timestamp and flags? memset(b->spec, 0, BANS_HEAD_LEN); t0 = VTIM_real(); memcpy(b->spec + BANS_TIMESTAMP, &t0, sizeof t0); @@ -329,3 +385,66 @@ BAN_Commit(struct ban_proto *bp) BAN_Abandon(bp); return (NULL); } + +static void +ban_build_arg_operhelp(struct vsb *vsb, int arg) +{ + unsigned mask; + const char *p = NULL, *n = NULL; + int i; + + ASSERT_BAN_ARG(arg); + mask = arg_opervalid[BAN_ARGIDX(arg)]; + + for (i = 0; i < BAN_OPERARRSZ; i++) { + if ((mask & (1< 1d" +varnish v1 -cliok "ban obj.keep == 0s && obj.ttl > 1d" + +# BANS_FLAG_NODEDUP +varnish v1 -cliexpect {(?s) obj\.ttl > 1d\b.*obj\.ttl > 1d\b} "ban.list" + +client c1 { + txreq + rxresp + expect resp.bodylen == 2 +} -run + +varnish v1 -cliok "ban obj.ttl <= 2m" + +client c1 { + txreq + rxresp + expect resp.bodylen == 3 +} -run + +varnish v1 -cliok "ban obj.age > 1d" +varnish v1 -cliok "ban obj.age > 1d" + +# BANS_FLAG_NODEDUP +varnish v1 -cliexpect {(?s) obj\.age > 1d\b.*obj\.age > 1d\b} "ban.list" + client c1 { txreq rxresp expect resp.bodylen == 3 } -run + +varnish v1 -cliok "ban obj.age < 1m" + +client c1 { + txreq + rxresp + expect resp.bodylen == 4 +} -run + +varnish v1 -cliok "ban obj.grace != 10s" +varnish v1 -cliok "ban obj.grace != 10s" + +# ! BANS_FLAG_NODEDUP +varnish v1 -cliexpect {(?s) obj\.grace != 10s\b.* \d C\b} "ban.list" + +client c1 { + txreq + rxresp + expect resp.bodylen == 4 +} -run + +varnish v1 -cliok "ban obj.grace == 10s" + +client c1 { + txreq + rxresp + expect resp.bodylen == 5 +} -run + +varnish v1 -cliok "ban obj.keep != 0s" +varnish v1 -cliok "ban obj.keep != 0s" + +# ! BANS_FLAG_NODEDUP +varnish v1 -cliexpect {(?s) obj\.keep != 0s\b.* \d C\b} "ban.list" + +client c1 { + txreq + rxresp + expect resp.bodylen == 5 +} -run + +varnish v1 -cliok "ban obj.keep == 0s" + +client c1 { + txreq + rxresp + expect resp.bodylen == 6 +} -run + +# duration formatting - 0s is being tested above +varnish v1 -cliok "ban obj.keep == 123ms" +varnish v1 -cliexpect {(?s) obj\.keep == 123ms\b} "ban.list" +varnish v1 -cliok "ban obj.keep == 0.456s" +varnish v1 -cliexpect {(?s) obj\.keep == 456ms\b} "ban.list" +varnish v1 -cliok "ban obj.keep == 6.789s" +varnish v1 -cliexpect {(?s) obj\.keep == 6.789s\b} "ban.list" +varnish v1 -cliok "ban obj.keep == 42y" +varnish v1 -cliexpect {(?s) obj\.keep == 42y\b} "ban.list" +varnish v1 -cliok "ban obj.keep == 365d" +varnish v1 -cliexpect {(?s) obj\.keep == 1y\b} "ban.list" +varnish v1 -cliok "ban obj.keep == 9w" +varnish v1 -cliexpect {(?s) obj\.keep == 9w\b} "ban.list" +varnish v1 -cliok "ban obj.keep == 7d" +varnish v1 -cliexpect {(?s) obj\.keep == 1w\b} "ban.list" +varnish v1 -cliok "ban obj.keep == 3d" +varnish v1 -cliexpect {(?s) obj\.keep == 3d\b} "ban.list" +varnish v1 -cliok "ban obj.keep == 24h" +varnish v1 -cliexpect {(?s) obj\.keep == 1d\b} "ban.list" +varnish v1 -cliok "ban obj.keep == 18h" +varnish v1 -cliexpect {(?s) obj\.keep == 18h\b} "ban.list" +varnish v1 -cliok "ban obj.keep == 1.5h" +varnish v1 -cliexpect {(?s) obj\.keep == 90m\b} "ban.list" +varnish v1 -cliok "ban obj.keep == 10m" +varnish v1 -cliexpect {(?s) obj\.keep == 10m\b} "ban.list" +varnish v1 -cliok "ban obj.keep == 0.5m" +varnish v1 -cliexpect {(?s) obj\.keep == 30s\b} "ban.list" diff --git a/bin/varnishtest/tests/v00011.vtc b/bin/varnishtest/tests/v00011.vtc index 9d391d3c0..8a613be33 100644 --- a/bin/varnishtest/tests/v00011.vtc +++ b/bin/varnishtest/tests/v00011.vtc @@ -1,4 +1,4 @@ -varnishtest "Test vcl purging" +varnishtest "Test vcl ban()" server s1 { rxreq @@ -18,6 +18,9 @@ varnish v1 -vcl+backend { ban("req.url // bar"); ban("req.url == bar //"); ban("foo == bar //"); + ban("obj.age == 4"); + ban("obj.age // 4d"); + ban("obj.http.foo > 4d"); ban("req.url ~ ^/$"); return (synth(209,"foo")); } @@ -36,9 +39,13 @@ logexpect l1 -v v1 -d 1 -g vxid { expect * 1004 VCL_Error {ban[(][)]: No ban conditions found[.]} expect * 1004 VCL_Error {ban[(][)]: Expected comparison operator[.]} expect * 1004 VCL_Error {ban[(][)]: Expected second operand[.]} - expect * 1004 VCL_Error {ban[(][)]: expected conditional [(]~, !~, == or !=[)] got "//"} - expect * 1004 VCL_Error {ban[(][)]: Expected && between conditions, found .//.} - expect * 1004 VCL_Error {ban[(][)]: Unknown or unsupported field .foo.} + expect * 1004 VCL_Error {ban[(][)]: expected conditional [(]==, !=, ~ or !~[)] got "//"} + expect * 1004 VCL_Error {ban[(][)]: Expected && between conditions, found "//"} + expect * 1004 VCL_Error {ban[(][)]: Unknown or unsupported field "foo"} + expect * 1004 VCL_Error {ban[(][)]: expected duration .ms|s|m|h|d|w|y. got "4"} + expect * 1004 VCL_Error {ban[(][)]: expected conditional [(]==, !=, >, >=, < or <=[)] got "//"} + expect * 1004 VCL_Error {ban[(][)]: expected conditional [(]==, !=, ~ or !~[)] got ">"} + } -start diff --git a/doc/sphinx/reference/vcl.rst b/doc/sphinx/reference/vcl.rst index c1de845e7..03382272a 100644 --- a/doc/sphinx/reference/vcl.rst +++ b/doc/sphinx/reference/vcl.rst @@ -457,23 +457,59 @@ ban(STRING) * **: - * ``req.url``: The request url - * ``req.http.*``: Any request header - * ``obj.status``: The cache object status - * ``obj.http.*``: Any cache object header + * string fields: + + * ``req.url``: The request url + * ``req.http.*``: Any request header + * ``obj.status``: The cache object status + * ``obj.http.*``: Any cache object header + + ``obj.status`` is treated as a string despite the fact that it + is actually an integer. + + * duration fields: + + * ``obj.ttl``: Remaining ttl at the time the ban is issued + * ``obj.age``: Object age at the time the ban is issued + * ``obj.grace``: The grace time of the object + * ``obj.keep``: The keep time of the object + * **: - * ``==``: ** and ** are equal strings (case sensitive) - * ``!=``: ** and ** are unequal strings (case sensitive) - * ``~``: ** matches the regular expression ** - * ``!~``:** does not match the regular expression ** + * for all fields: + + * ``==``: ** and ** are equal + * ``!=``: ** and ** are unequal + + strings are compared case sensitively + + * for string fields: + + * ``~``: ** matches the regular expression ** + * ``!~``:** does not match the regular expression ** + + * for duration fields: + + * ``>``: ** is greater than ** + * ``>=``: ** is greater than or equal to ** + * ``<``: ** is less than ** + * ``<=``: ** is less than or equal to ** + + + * **: + + * for string fields: + + Either a literal string or a regular expression. Note that + ** does not use any of the string delimiters like ``"`` or + ``{"``\ *...*\ ``"}`` used elsewhere in varnish. To match + against strings containing whitespace, regular expressions + containing ``\s`` can be used. + + * for duration fields: - * **: Either a literal string or a regular expression. Note - that ** does not use any of the string delimiters like ``"`` - or ``{"``\ *...*\ ``"}`` used elsewhere in varnish. To match - against strings containing whitespace, regular expressions - containing ``\s`` can be used. + A VCL duration like ``10s``, ``5m`` or ``1h``, see `Durations`_ Expressions can be chained using the *and* operator ``&&``. For *or* semantics, use several bans. diff --git a/doc/sphinx/users-guide/purging.rst b/doc/sphinx/users-guide/purging.rst index afe1fe266..58fa52e45 100644 --- a/doc/sphinx/users-guide/purging.rst +++ b/doc/sphinx/users-guide/purging.rst @@ -149,9 +149,12 @@ will produce a status of all current bans:: The ban list contains the ID of the ban, the timestamp when the ban entered the ban list. A count of the objects that has reached this point in the ban list, optionally postfixed with a 'G' for "Gone", if the ban -is no longer valid. Finally, the ban expression is listed. The ban can -be marked as "Gone" if it is a duplicate ban, but is still kept in the list -for optimization purposes. +is no longer valid. Finally, the ban expression is listed. Notice +that durations are not necessarily expressed in the originally given +unit, for instance ``7d`` will get turned into ``1w``. + +The ban can be marked as "Gone" if it is a duplicate ban, but is still +kept in the list for optimization purposes. Forcing a cache miss ~~~~~~~~~~~~~~~~~~~~ diff --git a/include/Makefile.am b/include/Makefile.am index 63757e48c..ddd5fefcf 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -5,6 +5,8 @@ nobase_pkginclude_HEADERS = \ tbl/acct_fields_bereq.h \ tbl/acct_fields_req.h \ tbl/backend_poll.h \ + tbl/ban_arg_oper.h \ + tbl/ban_oper.h \ tbl/ban_vars.h \ tbl/bo_flags.h \ tbl/boc_state.h \ diff --git a/include/tbl/ban_arg_oper.h b/include/tbl/ban_arg_oper.h new file mode 100644 index 000000000..df372c2aa --- /dev/null +++ b/include/tbl/ban_arg_oper.h @@ -0,0 +1,58 @@ +/*- + * Copyright 2017 UPLEX - Nils Goroll Systemoptimierung + * All rights reserved. + * + * Author: Nils Goroll + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Define which operators are valid for which ban arguments + */ + +/*lint -save -e525 -e539 */ + +#define BANS_OPER_STRING \ + (1< + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * 1. Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * Define ban operators + */ + +/*lint -save -e525 -e539 */ + +OPER(BANS_OPER_EQ, "==") +OPER(BANS_OPER_NEQ, "!=") +OPER(BANS_OPER_MATCH, "~") +OPER(BANS_OPER_NMATCH, "!~") +OPER(BANS_OPER_GT, ">") +OPER(BANS_OPER_GTE, ">=") +OPER(BANS_OPER_LT, "<") +OPER(BANS_OPER_LTE, "<=") + +#undef OPER + +/*lint -restore */ diff --git a/include/tbl/ban_vars.h b/include/tbl/ban_vars.h index 14e06b010..db7ff2ef7 100644 --- a/include/tbl/ban_vars.h +++ b/include/tbl/ban_vars.h @@ -31,10 +31,30 @@ /*lint -save -e525 -e539 */ -PVAR("req.url", BANS_FLAG_REQ, BANS_ARG_URL) -PVAR("req.http.", BANS_FLAG_REQ | BANS_FLAG_HTTP, BANS_ARG_REQHTTP) -PVAR("obj.status", BANS_FLAG_OBJ, BANS_ARG_OBJSTATUS) -PVAR("obj.http.", BANS_FLAG_OBJ | BANS_FLAG_HTTP, BANS_ARG_OBJHTTP) +PVAR("req.url", + BANS_FLAG_REQ, + BANS_ARG_URL) +PVAR("req.http.", + BANS_FLAG_REQ | BANS_FLAG_HTTP, + BANS_ARG_REQHTTP) +PVAR("obj.status", + BANS_FLAG_OBJ, + BANS_ARG_OBJSTATUS) +PVAR("obj.http.", + BANS_FLAG_OBJ | BANS_FLAG_HTTP, + BANS_ARG_OBJHTTP) +PVAR("obj.ttl", + BANS_FLAG_OBJ | BANS_FLAG_DURATION | BANS_FLAG_NODEDUP, + BANS_ARG_OBJTTL) +PVAR("obj.age", + BANS_FLAG_OBJ | BANS_FLAG_DURATION | BANS_FLAG_NODEDUP, + BANS_ARG_OBJAGE) +PVAR("obj.grace", + BANS_FLAG_OBJ | BANS_FLAG_DURATION, + BANS_ARG_OBJGRACE) +PVAR("obj.keep", + BANS_FLAG_OBJ | BANS_FLAG_DURATION, + BANS_ARG_OBJKEEP) #undef PVAR /*lint -restore */ diff --git a/include/tbl/cli_cmds.h b/include/tbl/cli_cmds.h index 5c28ed5c8..91f30b1b8 100644 --- a/include/tbl/cli_cmds.h +++ b/include/tbl/cli_cmds.h @@ -61,7 +61,9 @@ CLI_CMD(BAN_LIST, " * ``R`` for req.* tests\n\n" " * ``O`` for obj.* tests\n\n" " * Pointer to ban object\n\n" - " * Ban specification", + " * Ban specification\n\n" + " Durations of ban specifications get normalized, for example \"7d\"" + " gets changed into \"1w\".", 0, 0 ) From nils.goroll at uplex.de Mon Feb 18 09:50:12 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 18 Feb 2019 09:50:12 +0000 (UTC) Subject: [master] 60670c9ce changelog Message-ID: <20190218095012.3FD64A573B@lists.varnish-cache.org> commit 60670c9ce4a2782b900ca81438d0864a51b7b908 Author: Nils Goroll Date: Mon Feb 18 10:49:41 2019 +0100 changelog diff --git a/doc/changes.rst b/doc/changes.rst index ad3a2659a..04fd721e6 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -71,6 +71,9 @@ Varnish Cache trunk (ongoing) * The undocumented ``-v`` option to the ``backend.list`` cli command has been removed +* The ban facility has been extended by bans access to obj.ttl, + obj.age, obj.grace and obj.keep and additional inequality operators. + VCL --- From phk at FreeBSD.org Mon Feb 18 11:31:09 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 18 Feb 2019 11:31:09 +0000 (UTC) Subject: [master] 0250f7587 Flexelinting Message-ID: <20190218113109.1BC2BA86B3@lists.varnish-cache.org> commit 0250f758786fa8dde7bfff8a64d54a4a6fcc3054 Author: Poul-Henning Kamp Date: Mon Feb 18 11:30:20 2019 +0000 Flexelinting diff --git a/bin/varnishd/cache/cache_ban_build.c b/bin/varnishd/cache/cache_ban_build.c index 948df5d8a..2d2f2ba69 100644 --- a/bin/varnishd/cache/cache_ban_build.c +++ b/bin/varnishd/cache/cache_ban_build.c @@ -252,7 +252,7 @@ BAN_AddTest(struct ban_proto *bp, op = ban_parse_oper(a2); if (op < 0 || - ((1<tag)]) == 0) + ((1U << BAN_OPERIDX(op)) & arg_opervalid[BAN_ARGIDX(pv->tag)]) == 0) return (ban_error(bp, "expected conditional (%s) got \"%s\"", arg_operhelp[BAN_ARGIDX(pv->tag)], @@ -397,7 +397,7 @@ ban_build_arg_operhelp(struct vsb *vsb, int arg) mask = arg_opervalid[BAN_ARGIDX(arg)]; for (i = 0; i < BAN_OPERARRSZ; i++) { - if ((mask & (1< commit ee51ce05625de5ed2fd88bc7eee17c9f4abbc18d Author: Nils Goroll Date: Mon Feb 18 13:02:39 2019 +0100 integer types consistency Thank you, @fgsch diff --git a/bin/varnishd/cache/cache_ban.c b/bin/varnishd/cache/cache_ban.c index 122fd9aab..283cad024 100644 --- a/bin/varnishd/cache/cache_ban.c +++ b/bin/varnishd/cache/cache_ban.c @@ -766,8 +766,8 @@ ccf_ban(struct cli *cli, const char * const *av, void *priv) // XXX move to VTIM? #define vdur_render(buf, dur) do { \ - uint64_t dec = (uint64_t)floor(dur); \ - uint64_t frac = (uint64_t)floor((dur) * 1e3) % UINT64_C(1000); \ + uintmax_t dec = (uintmax_t)floor(dur); \ + uintmax_t frac = (uintmax_t)floor((dur) * 1e3) % UINTMAX_C(1000); \ if (dec == 0 && frac == 0) \ (void) strncpy(buf, "0s", sizeof(buf)); \ else if (dec == 0) \ From geoff at uplex.de Mon Feb 18 13:46:09 2019 From: geoff at uplex.de (Geoff Simmons) Date: Mon, 18 Feb 2019 13:46:09 +0000 (UTC) Subject: [master] 54af42d4c Rename the obj flag OF_CHGGZIP to OF_CHGCE, for "changed Content-Encoding". Message-ID: <20190218134609.5FF4DAD3D8@lists.varnish-cache.org> commit 54af42d4c328089625a59eb063e75d5c72125852 Author: Geoff Simmons Date: Mon Feb 18 14:41:42 2019 +0100 Rename the obj flag OF_CHGGZIP to OF_CHGCE, for "changed Content-Encoding". And update the comment explaining what happens. This is to make it apparent that a VFP has changed C-E in the stored object, so C-E should not be changed by an IMS fetch, and a new ETag from IMS has to be weakened. The flag is appropriate for use by any VFP that needs to manipulate C-E this way (not just gzip). Closes #2910 diff --git a/bin/varnishd/cache/cache_esi_fetch.c b/bin/varnishd/cache/cache_esi_fetch.c index 81ad5535f..e301ab705 100644 --- a/bin/varnishd/cache/cache_esi_fetch.c +++ b/bin/varnishd/cache/cache_esi_fetch.c @@ -162,7 +162,7 @@ vfp_esi_gzip_init(struct vfp_ctx *vc, struct vfp_entry *vfe) ALLOC_OBJ(vef, VEF_MAGIC); if (vef == NULL) return (VFP_ERROR); - vc->obj_flags |= OF_GZIPED | OF_CHGGZIP | OF_ESIPROC; + vc->obj_flags |= OF_GZIPED | OF_CHGCE | OF_ESIPROC; vef->vgz = VGZ_NewGzip(vc->wrk->vsl, "G F E"); vef->vep = VEP_Init(vc, vc->req, vfp_vep_callback, vef); vef->ibuf_sz = cache_param->gzip_buffer; diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 57aa5bd0f..33a751ea2 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -356,11 +356,12 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo) if (bo->stale_oc != NULL && ObjCheckFlag(bo->wrk, bo->stale_oc, OF_IMSCAND)) { AZ(bo->stale_oc->flags & (OC_F_HFM|OC_F_PRIVATE)); - if (ObjCheckFlag(bo->wrk, bo->stale_oc, OF_CHGGZIP)) { + if (ObjCheckFlag(bo->wrk, bo->stale_oc, OF_CHGCE)) { /* - * If we changed the gzip status of the object - * the stored Content_Encoding controls we - * must weaken any new ETag we get. + * If a VFP changed C-E in the stored + * object, then don't overwrite C-E from + * the IMS fetch, and we must weaken any + * new ETag we get. */ http_Unset(bo->beresp, H_Content_Encoding); RFC2616_Weaken_Etag(bo->beresp); diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c index a06bba614..c4b1f0998 100644 --- a/bin/varnishd/cache/cache_gzip.c +++ b/bin/varnishd/cache/cache_gzip.c @@ -465,14 +465,14 @@ vfp_gzip_init(struct vfp_ctx *vc, struct vfp_entry *vfe) if (http_GetHdr(vc->resp, H_Content_Encoding, NULL)) return (VFP_NULL); vg = VGZ_NewGzip(vc->wrk->vsl, vfe->vfp->priv1); - vc->obj_flags |= OF_GZIPED | OF_CHGGZIP; + vc->obj_flags |= OF_GZIPED | OF_CHGCE; } else { if (!http_HdrIs(vc->resp, H_Content_Encoding, "gzip")) return (VFP_NULL); if (vfe->vfp == &VFP_gunzip) { vg = VGZ_NewGunzip(vc->wrk->vsl, vfe->vfp->priv1); vc->obj_flags &= ~OF_GZIPED; - vc->obj_flags |= OF_CHGGZIP; + vc->obj_flags |= OF_CHGCE; } else { vg = VGZ_NewTestGunzip(vc->wrk->vsl, vfe->vfp->priv1); vc->obj_flags |= OF_GZIPED; diff --git a/include/tbl/obj_attr.h b/include/tbl/obj_attr.h index b0b6773e1..a695c1efa 100644 --- a/include/tbl/obj_attr.h +++ b/include/tbl/obj_attr.h @@ -55,7 +55,7 @@ #ifdef OBJ_FLAG /* upper, lower, val */ OBJ_FLAG(GZIPED, gziped, (1<<1)) - OBJ_FLAG(CHGGZIP, chggzip, (1<<2)) + OBJ_FLAG(CHGCE, chgce, (1<<2)) OBJ_FLAG(IMSCAND, imscand, (1<<3)) OBJ_FLAG(ESIPROC, esiproc, (1<<4)) #undef OBJ_FLAG From lasse.karstensen at gmail.com Mon Feb 18 15:19:11 2019 From: lasse.karstensen at gmail.com (Lasse Karstensen) Date: Mon, 18 Feb 2019 15:19:11 +0000 (UTC) Subject: [master] 230aa946f Improve help and clarity of --boilerplate. Message-ID: <20190218151911.16756AF1E5@lists.varnish-cache.org> commit 230aa946f25395f3be339d12295347858e544d80 Author: Lasse Karstensen Date: Mon Feb 18 16:16:50 2019 +0100 Improve help and clarity of --boilerplate. diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py index 2a88c2ab4..fe2a45161 100755 --- a/lib/libvcc/vmodtool.py +++ b/lib/libvcc/vmodtool.py @@ -47,7 +47,7 @@ import json import hashlib AMBOILERPLATE = ''' -# Boilerplate generated by vmodtool.py - changes will be overwritten +# Generated by vmodtool.py --boilerplate. AM_LDFLAGS = $(AM_LT_LDFLAGS) @@ -1133,7 +1133,7 @@ if __name__ == "__main__": oparser.add_option('-b', '--boilerplate', action='store_true', default=False, - help="Be strict when parsing the input file") + help="Create automake_boilerplate.am") oparser.add_option('-N', '--strict', action='store_true', default=False, help="Be strict when parsing the input file") oparser.add_option('-o', '--output', metavar="prefix", default='vcc_if', From phk at FreeBSD.org Mon Feb 18 16:03:09 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 18 Feb 2019 16:03:09 +0000 (UTC) Subject: [master] 52d7fc834 Ignore return-value from nice(), it's not important and has a useless spec. Message-ID: <20190218160309.B48D2B009E@lists.varnish-cache.org> commit 52d7fc8343a887f9ca1a9bdb58d1ffa8bb1f9e71 Author: Poul-Henning Kamp Date: Mon Feb 18 16:01:45 2019 +0000 Ignore return-value from nice(), it's not important and has a useless spec. diff --git a/bin/varnishtest/vtc_main.c b/bin/varnishtest/vtc_main.c index 1a7fa98a2..0f4b144d2 100644 --- a/bin/varnishtest/vtc_main.c +++ b/bin/varnishtest/vtc_main.c @@ -228,7 +228,7 @@ cleaner_setup(void) assert(cleaner_pid >= 0); if (cleaner_pid == 0) { closefd(&p[1]); - AZ(nice(1)); + (void)nice(1); /* Not important */ setbuf(stdin, NULL); AZ(dup2(p[0], STDIN_FILENO)); while (fgets(buf, sizeof buf, stdin)) { From dridi.boukelmoune at gmail.com Mon Feb 18 16:05:10 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 18 Feb 2019 16:05:10 +0000 (UTC) Subject: [master] 60a70c883 Code style Message-ID: <20190218160510.5D92BB0273@lists.varnish-cache.org> commit 60a70c883741008ac359d2a3c3f6941d5994c4da Author: Dridi Boukelmoune Date: Mon Feb 18 17:04:25 2019 +0100 Code style This line ain't too long to be broken. diff --git a/lib/libvcc/vcc_vmod.c b/lib/libvcc/vcc_vmod.c index 483411010..225560d25 100644 --- a/lib/libvcc/vcc_vmod.c +++ b/lib/libvcc/vcc_vmod.c @@ -225,8 +225,7 @@ vcc_ParseImport(struct vcc *tl) msym->def_e = tl->t; - if (VFIL_searchpath(tl->vmod_path, - vcc_path_dlopen, &hdl, fn, &fnpx)) { + if (VFIL_searchpath(tl->vmod_path, vcc_path_dlopen, &hdl, fn, &fnpx)) { VSB_printf(tl->sb, "Could not load VMOD %.*s\n", PF(mod)); VSB_printf(tl->sb, "\tFile name: %s\n", fnpx != NULL ? fnpx : fn); From nils.goroll at uplex.de Mon Feb 18 17:44:10 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 18 Feb 2019 17:44:10 +0000 (UTC) Subject: [master] 55448d30f check in new boilerplates Message-ID: <20190218174410.795BEB2126@lists.varnish-cache.org> commit 55448d30fa3c5c6411dddbf24f7b4e59a8e150e3 Author: Nils Goroll Date: Mon Feb 18 18:42:43 2019 +0100 check in new boilerplates diff --git a/lib/libvmod_blob/automake_boilerplate.am b/lib/libvmod_blob/automake_boilerplate.am index 5bad5e10a..a761d9336 100644 --- a/lib/libvmod_blob/automake_boilerplate.am +++ b/lib/libvmod_blob/automake_boilerplate.am @@ -1,5 +1,5 @@ -# Boilerplate generated by vmodtool.py - changes will be overwritten +# Generated by vmodtool.py --boilerplate. AM_LDFLAGS = $(AM_LT_LDFLAGS) diff --git a/lib/libvmod_debug/automake_boilerplate.am b/lib/libvmod_debug/automake_boilerplate.am index fd3aaea3a..db1c206a5 100644 --- a/lib/libvmod_debug/automake_boilerplate.am +++ b/lib/libvmod_debug/automake_boilerplate.am @@ -1,5 +1,5 @@ -# Boilerplate generated by vmodtool.py - changes will be overwritten +# Generated by vmodtool.py --boilerplate. AM_LDFLAGS = $(AM_LT_LDFLAGS) diff --git a/lib/libvmod_directors/automake_boilerplate.am b/lib/libvmod_directors/automake_boilerplate.am index 2c0b9b5b9..218c89e4d 100644 --- a/lib/libvmod_directors/automake_boilerplate.am +++ b/lib/libvmod_directors/automake_boilerplate.am @@ -1,5 +1,5 @@ -# Boilerplate generated by vmodtool.py - changes will be overwritten +# Generated by vmodtool.py --boilerplate. AM_LDFLAGS = $(AM_LT_LDFLAGS) diff --git a/lib/libvmod_proxy/automake_boilerplate.am b/lib/libvmod_proxy/automake_boilerplate.am index 4ee1e5abd..8f65c6158 100644 --- a/lib/libvmod_proxy/automake_boilerplate.am +++ b/lib/libvmod_proxy/automake_boilerplate.am @@ -1,5 +1,5 @@ -# Boilerplate generated by vmodtool.py - changes will be overwritten +# Generated by vmodtool.py --boilerplate. AM_LDFLAGS = $(AM_LT_LDFLAGS) diff --git a/lib/libvmod_purge/automake_boilerplate.am b/lib/libvmod_purge/automake_boilerplate.am index d107999e3..04278675c 100644 --- a/lib/libvmod_purge/automake_boilerplate.am +++ b/lib/libvmod_purge/automake_boilerplate.am @@ -1,5 +1,5 @@ -# Boilerplate generated by vmodtool.py - changes will be overwritten +# Generated by vmodtool.py --boilerplate. AM_LDFLAGS = $(AM_LT_LDFLAGS) diff --git a/lib/libvmod_std/automake_boilerplate.am b/lib/libvmod_std/automake_boilerplate.am index e744db0c6..2dda52b09 100644 --- a/lib/libvmod_std/automake_boilerplate.am +++ b/lib/libvmod_std/automake_boilerplate.am @@ -1,5 +1,5 @@ -# Boilerplate generated by vmodtool.py - changes will be overwritten +# Generated by vmodtool.py --boilerplate. AM_LDFLAGS = $(AM_LT_LDFLAGS) diff --git a/lib/libvmod_unix/automake_boilerplate.am b/lib/libvmod_unix/automake_boilerplate.am index 18d06b8cd..d6db5e354 100644 --- a/lib/libvmod_unix/automake_boilerplate.am +++ b/lib/libvmod_unix/automake_boilerplate.am @@ -1,5 +1,5 @@ -# Boilerplate generated by vmodtool.py - changes will be overwritten +# Generated by vmodtool.py --boilerplate. AM_LDFLAGS = $(AM_LT_LDFLAGS) diff --git a/lib/libvmod_vtc/automake_boilerplate.am b/lib/libvmod_vtc/automake_boilerplate.am index 063ab92ba..93b78e7dc 100644 --- a/lib/libvmod_vtc/automake_boilerplate.am +++ b/lib/libvmod_vtc/automake_boilerplate.am @@ -1,5 +1,5 @@ -# Boilerplate generated by vmodtool.py - changes will be overwritten +# Generated by vmodtool.py --boilerplate. AM_LDFLAGS = $(AM_LT_LDFLAGS) From dridi at varni.sh Mon Feb 18 20:42:13 2019 From: dridi at varni.sh (Dridi Boukelmoune) Date: Mon, 18 Feb 2019 21:42:13 +0100 Subject: [master] 5735a543c Insist that VCL_RET_FAIL goes through VRT_fail() and not VRT_handling() In-Reply-To: <20190212100210.DD5BE7A06@lists.varnish-cache.org> References: <20190212100210.DD5BE7A06@lists.varnish-cache.org> Message-ID: On Tue, Feb 12, 2019 at 11:02 AM Poul-Henning Kamp wrote: > > > commit 5735a543c720655c484ef11c70b6cde7f201d5ca > Author: Poul-Henning Kamp > Date: Tue Feb 12 10:01:00 2019 +0000 > > Insist that VCL_RET_FAIL goes through VRT_fail() and not VRT_handling() This is a hard VRT breakage, if it's not documented in vrt.h, someone please fix that. This will obviously not land in 6.0 when back-ports reach this point. Dridi > diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c > index 45b4e1399..8940a6797 100644 > --- a/bin/varnishd/cache/cache_vrt.c > +++ b/bin/varnishd/cache/cache_vrt.c > @@ -491,11 +491,11 @@ VRT_handling(VRT_CTX, unsigned hand) > { > > CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); > - if (ctx->handling == NULL) > - return; > + assert(hand != VCL_RET_FAIL); > + AN(ctx->handling); > + AZ(*ctx->handling); > assert(hand > 0); > assert(hand < VCL_RET_MAX); > - // XXX:NOTYET assert(*ctx->handling == 0); > *ctx->handling = hand; > } > > @@ -507,16 +507,21 @@ VRT_fail(VRT_CTX, const char *fmt, ...) > va_list ap; > > assert(ctx->vsl != NULL || ctx->msg != NULL); > + AN(ctx->handling); > + if (*ctx->handling == VCL_RET_FAIL) > + return; > + AZ(*ctx->handling); > + AN(fmt); > AZ(strchr(fmt, '\n')); > va_start(ap, fmt); > - if (ctx->vsl != NULL) > + if (ctx->vsl != NULL) { > VSLbv(ctx->vsl, SLT_VCL_Error, fmt, ap); > - else { > + } else { > VSB_vprintf(ctx->msg, fmt, ap); > VSB_putc(ctx->msg, '\n'); > } > va_end(ap); > - VRT_handling(ctx, VCL_RET_FAIL); > + *ctx->handling = VCL_RET_FAIL; > } > > /*-------------------------------------------------------------------- > @@ -772,9 +777,8 @@ VRT_purge(VRT_CTX, VCL_DURATION ttl, VCL_DURATION grace, VCL_DURATION keep) > CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); > > if ((ctx->method & (VCL_MET_HIT|VCL_MET_MISS)) == 0) { > - VSLb(ctx->vsl, SLT_VCL_Error, > + VRT_fail(ctx, > "purge can only happen in vcl_hit{} or vcl_miss{}"); > - VRT_handling(ctx, VCL_RET_FAIL); > return (0); > } > > diff --git a/lib/libvcc/vcc_action.c b/lib/libvcc/vcc_action.c > index ded906870..02d323a14 100644 > --- a/lib/libvcc/vcc_action.c > +++ b/lib/libvcc/vcc_action.c > @@ -350,7 +350,10 @@ vcc_act_return(struct vcc *tl, struct token *t, struct symbol *sym) > } > } > ERRCHK(tl); > - Fb(tl, 1, "VRT_handling(ctx, VCL_RET_%s);\n", h); > + if (hand == VCL_RET_FAIL) > + Fb(tl, 1, "VRT_fail(ctx, \"Failed from VCL\");\n"); > + else > + Fb(tl, 1, "VRT_handling(ctx, VCL_RET_%s);\n", h); > SkipToken(tl, ')'); > SkipToken(tl, ';'); > } > diff --git a/lib/libvcc/vcc_compile.c b/lib/libvcc/vcc_compile.c > index 13994eb6b..203f34465 100644 > --- a/lib/libvcc/vcc_compile.c > +++ b/lib/libvcc/vcc_compile.c > @@ -318,8 +318,15 @@ EmitInitFini(const struct vcc *tl) > if (VSB_len(p->event)) > has_event = 1; > } > + > + /* Handle failures from vcl_init */ > + Fc(tl, 0, "\n"); > + Fc(tl, 0, "\tif (*ctx->handling != VCL_RET_OK)\n"); > + Fc(tl, 0, "\t\treturn(1);\n"); > + > VTAILQ_FOREACH(sy, &tl->sym_objects, sideways) { > Fc(tl, 0, "\tif (!%s) {\n", sy->rname); > + Fc(tl, 0, "\t\t*ctx->handling = 0;\n"); > Fc(tl, 0, "\t\tVRT_fail(ctx, " > "\"Object %s not initialized\");\n" , sy->name); > Fc(tl, 0, "\t\treturn(1);\n"); > @@ -655,7 +662,12 @@ vcc_CompileSource(struct vcc *tl, struct source *sp) > > /* Tie vcl_init/fini in */ > ifp = New_IniFin(tl); > - VSB_printf(ifp->ini, "\tVGC_function_vcl_init(ctx);"); > + VSB_printf(ifp->ini, "\tVGC_function_vcl_init(ctx);\n"); > + /* > + * We do not return(1) if this fails, because the failure > + * could be half way into vcl_init{} so vcl_fini{} must > + * always be called, also on failure. > + */ > VSB_printf(ifp->fin, "\t\tVGC_function_vcl_fini(ctx);"); > > /* Emit method functions */ > _______________________________________________ > varnish-commit mailing list > varnish-commit at varnish-cache.org > https://www.varnish-cache.org/lists/mailman/listinfo/varnish-commit From phk at phk.freebsd.dk Mon Feb 18 20:45:05 2019 From: phk at phk.freebsd.dk (Poul-Henning Kamp) Date: Mon, 18 Feb 2019 20:45:05 +0000 Subject: [master] 5735a543c Insist that VCL_RET_FAIL goes through VRT_fail() and not VRT_handling() In-Reply-To: References: <20190212100210.DD5BE7A06@lists.varnish-cache.org> Message-ID: <62800.1550522705@critter.freebsd.dk> -------- In message , Dridi Boukelmoune writes: >On Tue, Feb 12, 2019 at 11:02 AM Poul-Henning Kamp wrote: >> >> >> commit 5735a543c720655c484ef11c70b6cde7f201d5ca >> Author: Poul-Henning Kamp >> Date: Tue Feb 12 10:01:00 2019 +0000 >> >> Insist that VCL_RET_FAIL goes through VRT_fail() and not VRT_handling() > >This is a hard VRT breakage, if it's not documented in vrt.h, someone >please fix that. > >This will obviously not land in 6.0 when back-ports reach this point. Which I don't think it should, because I dont see us backporting #2902 where this comes from. -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk at FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence. From dridi at varni.sh Mon Feb 18 21:13:39 2019 From: dridi at varni.sh (Dridi Boukelmoune) Date: Mon, 18 Feb 2019 22:13:39 +0100 Subject: [master] 5735a543c Insist that VCL_RET_FAIL goes through VRT_fail() and not VRT_handling() In-Reply-To: <62800.1550522705@critter.freebsd.dk> References: <20190212100210.DD5BE7A06@lists.varnish-cache.org> <62800.1550522705@critter.freebsd.dk> Message-ID: > Which I don't think it should, because I dont see us backporting #2902 > where this comes from. I take them in order, so I haven't revisited #2902 yet for the 6.0 branch. This triggered during my weekly CI against master, on code that actually predates the introduction of VRT_fail(): https://travis-ci.org/Dridi/libvmod-querystring/jobs/495041218#L2196 I believe we discussed it today during the bugwash, so it's unfortunate that my cron job triggers on Monday afternoon because simply VRT_fail()ing during vcl_init today will not feed the CLI error message on older branches :) To anyone interested in a workaround in case VRT_fail() doesn't feed the error message starting with 6.2, or the people of the trunk persuasion, I was able to handle both cases without trying too hard: https://github.com/Dridi/libvmod-querystring/commit/6b63758 If I had more than one occurrence it wouldn't be too hard to wrap in a function, and I believe the consensus during bugwash was to restore the old behavior so I should be able to get rid of this after the March release. Dridi From dridi.boukelmoune at gmail.com Tue Feb 19 11:15:13 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 19 Feb 2019 11:15:13 +0000 (UTC) Subject: [6.0] 110db401e Changelog update Message-ID: <20190219111513.0AD141034FC@lists.varnish-cache.org> commit 110db401eb1008210b3bfbf4eeb429d5bb6f8fdd Author: Dridi Boukelmoune Date: Tue Feb 19 12:14:11 2019 +0100 Changelog update diff --git a/doc/changes.rst b/doc/changes.rst index 94583e701..0b08f51fc 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -34,9 +34,36 @@ Varnish Cache 6.0.3 (unreleased) renamed the red/black tree macros from ``VRB_*`` to ``VRBT_*`` to disambiguate from the acronym for Varnish Request Body. -* added ``req.is_hitmiss`` and ``req.is_hitpass`` (2743_) +* Added ``req.is_hitmiss`` and ``req.is_hitpass`` (2743_) +* Fix assinging == (2809_) + +* Add error handling for STV_NewObject() (2831_) + +* Fix VRT_fail for 'if'/'elseif' conditional expressions (2840_) + +* Add VSL rate limiting (2837_) + + This adds rate limiting to varnishncsa and varnishlog. + +* For ``varnishtest -L``, also keep VCL C source files. + +* Make it possible to change ``varnishncsa`` update rate. (2741_) + +* Tolerate null IP addresses for ACL matches. + +* Many cache lookup optimizations. + +* Display the VCL syntax during a panic. + +* Update to the VCL diagrams to include hit-for-miss. + +.. _2741: https://github.com/varnishcache/varnish-cache/pull/2741 .. _2743: https://github.com/varnishcache/varnish-cache/issues/2743 +.. _2809: https://github.com/varnishcache/varnish-cache/issues/2809 +.. _2831: https://github.com/varnishcache/varnish-cache/issues/2831 +.. _2837: https://github.com/varnishcache/varnish-cache/pull/2837 +.. _2840: https://github.com/varnishcache/varnish-cache/issues/2840 ================================ Varnish Cache 6.0.2 (2018-11-07) From dridi.boukelmoune at gmail.com Tue Feb 19 11:23:08 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 19 Feb 2019 11:23:08 +0000 (UTC) Subject: [master] 80178f5ac Changelog update Message-ID: <20190219112308.81509103860@lists.varnish-cache.org> commit 80178f5ac2333f550cc6adc53c3b0d0901433bbf Author: Dridi Boukelmoune Date: Tue Feb 19 12:21:32 2019 +0100 Changelog update Refs 110db401eb1008210b3bfbf4eeb429d5bb6f8fdd from the 6.0 branch. diff --git a/doc/changes.rst b/doc/changes.rst index 04fd721e6..ce2bd46ae 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -40,11 +40,7 @@ Varnish Cache trunk (ongoing) * Adjust code generator python tools to python 3 and prefer python 3 over python 2 where available -* fix some stats metrics (vsc) which were wrongly marked as _gauge_ - -* fix ``varnishd -I`` (2782_) - -* added a thread pool watchdog which will restart the worker process +* Added a thread pool watchdog which will restart the worker process if scheduling tasks onto worker threads appears stuck. The new parameter ``thread_pool_watchdog`` configures it. (2418_) @@ -57,7 +53,7 @@ Varnish Cache trunk (ongoing) * VSB quoted output has been unified to three-digit octal, VSB_QUOTE_ESCHEX has been added to prefer hex over octal quoting -* retired long deprecated parameters (VIP16_). Replacement mapping is: +* Retired long deprecated parameters (VIP16_). Replacement mapping is: ``shm_reclen`` -> ``vsl_reclen`` ``vcl_dir`` -> ``vcl_path`` ``vmod_dir`` -> ``vmod_path`` @@ -74,10 +70,16 @@ Varnish Cache trunk (ongoing) * The ban facility has been extended by bans access to obj.ttl, obj.age, obj.grace and obj.keep and additional inequality operators. +* Many cache lookup optimizations. + +* Display the VCL syntax during a panic. + +* Update to the VCL diagrams to include hit-for-miss. + VCL --- -* added ``req.is_hitmiss`` and ``req.is_hitpass`` (2743_) +* Added ``req.is_hitmiss`` and ``req.is_hitpass`` (2743_) bundled tools @@ -89,6 +91,12 @@ bundled tools * Add ``param.reset`` command to ``varnishadm`` +* Add VSL rate limiting (2837_) + + This adds rate limiting to varnishncsa and varnishlog. + +* Make it possible to change ``varnishncsa`` update rate. (2741_) + C APIs (for vmod and utility authors) ------------------------------------- @@ -106,6 +114,8 @@ C APIs (for vmod and utility authors) function/method is assumed to be immutable. In other words, a vmod `must not` modify any data which was previously returned. +* Tolerate null IP addresses for ACL matches. + * Added ``vstrerror()`` as a safe wrapper for ``strerror()`` to avoid a NULL pointer dereference under rare conditions where the latter could return NULL. (2815_) @@ -121,7 +131,7 @@ C APIs (for vmod and utility authors) function will be called ``vmod_foo`` and with ``$Prefix bar`` it will be called ``bar_foo``. -* in the `vmodtool`\ -generated ReStructuredText documentation, +* In the `vmodtool`\ -generated ReStructuredText documentation, anchors have been renamed * from ``obj_``\ `class` to `vmodname`\ ``.``\ `class` for @@ -177,9 +187,9 @@ C APIs (for vmod and utility authors) Fixed bugs ---------- -* fixed ``varnishhist`` display error (2780_) +* Fixed ``varnishhist`` display error (2780_) -* fix ``varnishstat -f`` in curses mode (interactively, without +* Fix ``varnishstat -f`` in curses mode (interactively, without ``-1``, 2787_) * Handle an out-of-workspace condition in HTTP/2 delivery more @@ -198,23 +208,34 @@ Fixed bugs * Fix vmod object constructor documentation in the ``vmodtool.py`` - generated RST files +* Fix some stats metrics (vsc) which were wrongly marked as _gauge_ -.. _2809: https://github.com/varnishcache/varnish-cache/issues/2809 -.. _2820: https://github.com/varnishcache/varnish-cache/issues/2820 -.. _2815: https://github.com/varnishcache/varnish-cache/issues/2815 -.. _2823: https://github.com/varnishcache/varnish-cache/issues/2823 -.. _2813: https://github.com/varnishcache/varnish-cache/pull/2813 -.. _2792: https://github.com/varnishcache/varnish-cache/pull/2792 -.. _2783: https://github.com/varnishcache/varnish-cache/pull/2783 +* Fix ``varnishd -I`` (2782_) + +* Add error handling for STV_NewObject() (2831_) + +* Fix VRT_fail for 'if'/'elseif' conditional expressions (2840_) + +.. _2418: https://github.com/varnishcache/varnish-cache/issues/2418 +.. _2589: https://github.com/varnishcache/varnish-cache/issues/2589 +.. _2741: https://github.com/varnishcache/varnish-cache/pull/2741 +.. _2743: https://github.com/varnishcache/varnish-cache/issues/2743 .. _2780: https://github.com/varnishcache/varnish-cache/issues/2780 .. _2782: https://github.com/varnishcache/varnish-cache/issues/2782 +.. _2783: https://github.com/varnishcache/varnish-cache/pull/2783 .. _2787: https://github.com/varnishcache/varnish-cache/issues/2787 -.. _2589: https://github.com/varnishcache/varnish-cache/issues/2589 -.. _2418: https://github.com/varnishcache/varnish-cache/issues/2418 .. _2788: https://github.com/varnishcache/varnish-cache/issues/2788 .. _2790: https://github.com/varnishcache/varnish-cache/issues/2790 +.. _2792: https://github.com/varnishcache/varnish-cache/pull/2792 +.. _2809: https://github.com/varnishcache/varnish-cache/issues/2809 +.. _2813: https://github.com/varnishcache/varnish-cache/pull/2813 +.. _2815: https://github.com/varnishcache/varnish-cache/issues/2815 +.. _2820: https://github.com/varnishcache/varnish-cache/issues/2820 +.. _2823: https://github.com/varnishcache/varnish-cache/issues/2823 +.. _2831: https://github.com/varnishcache/varnish-cache/issues/2831 +.. _2837: https://github.com/varnishcache/varnish-cache/pull/2837 +.. _2840: https://github.com/varnishcache/varnish-cache/issues/2840 .. _VIP16: https://github.com/varnishcache/varnish-cache/wiki/VIP16%3A-Retire-parameters-aliases -.. _2743: https://github.com/varnishcache/varnish-cache/issues/2743 ================================ Varnish Cache 6.1.0 (2018-09-17) From dridi.boukelmoune at gmail.com Tue Feb 19 15:23:09 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 19 Feb 2019 15:23:09 +0000 (UTC) Subject: [6.0] 4f4be6fc2 Updating devicedetect.vcl to upstream Message-ID: <20190219152309.E1649107B0D@lists.varnish-cache.org> commit 4f4be6fc2b4534e755243cc4551343834b6a1ac2 Author: Dridi Boukelmoune Date: Tue Feb 19 15:47:08 2019 +0100 Updating devicedetect.vcl to upstream 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 dridi.boukelmoune at gmail.com Tue Feb 19 15:23:10 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 19 Feb 2019 15:23:10 +0000 (UTC) Subject: [6.0] 7d1ded3aa Prepare for 6.0.3 Message-ID: <20190219152310.062C8107B10@lists.varnish-cache.org> commit 7d1ded3aa033a018317dbafc61587026ea2ef8a3 Author: Dridi Boukelmoune Date: Tue Feb 19 16:21:57 2019 +0100 Prepare for 6.0.3 diff --git a/configure.ac b/configure.ac index 615dcd9d1..58153c804 100644 --- a/configure.ac +++ b/configure.ac @@ -1,8 +1,8 @@ AC_PREREQ(2.59) AC_COPYRIGHT([Copyright (c) 2006 Verdens Gang AS -Copyright (c) 2006-2018 Varnish Software]) +Copyright (c) 2006-2019 Varnish Software]) AC_REVISION([$Id$]) -AC_INIT([Varnish], [6.0.2], [varnish-dev at varnish-cache.org]) +AC_INIT([Varnish], [6.0.3], [varnish-dev at varnish-cache.org]) AC_CONFIG_SRCDIR(include/miniobj.h) AC_CONFIG_HEADERS([config.h]) AC_CONFIG_MACRO_DIR([m4]) diff --git a/doc/changes.rst b/doc/changes.rst index 0b08f51fc..08ff9b41e 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -27,7 +27,7 @@ individual releases. These documents are updated as part of the release process. ================================ -Varnish Cache 6.0.3 (unreleased) +Varnish Cache 6.0.3 (2019-02-19) ================================ * Included ``vtree.h`` in the distribution for vmods and diff --git a/doc/sphinx/index.rst b/doc/sphinx/index.rst index 9a708b593..e86d038fe 100644 --- a/doc/sphinx/index.rst +++ b/doc/sphinx/index.rst @@ -37,7 +37,7 @@ Longer listings like example command output and VCL look like this:: $ /opt/varnish/sbin/varnishd -V varnishd (varnish-trunk revision 199de9b) Copyright (c) 2006 Verdens Gang AS - Copyright (c) 2006-2018 Varnish Software AS + Copyright (c) 2006-2019 Varnish Software AS .. For maintainers: diff --git a/lib/libvarnish/version.c b/lib/libvarnish/version.c index 1b9a42196..b2258ccde 100644 --- a/lib/libvarnish/version.c +++ b/lib/libvarnish/version.c @@ -44,5 +44,5 @@ VCS_Message(const char *progname) { fprintf(stderr, "%s (%s)\n", progname, VCS_version); fprintf(stderr, "Copyright (c) 2006 Verdens Gang AS\n"); - fprintf(stderr, "Copyright (c) 2006-2018 Varnish Software AS\n"); + fprintf(stderr, "Copyright (c) 2006-2019 Varnish Software AS\n"); } From phk at FreeBSD.org Tue Feb 19 22:24:08 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 19 Feb 2019 22:24:08 +0000 (UTC) Subject: [master] 45239c241 Use a turboencabulator to autocolumnate non-json vcl.list output Message-ID: <20190219222408.9380810FEB5@lists.varnish-cache.org> commit 45239c2413098201a9c32e9fad597e352d694205 Author: Poul-Henning Kamp Date: Tue Feb 19 22:23:14 2019 +0000 Use a turboencabulator to autocolumnate non-json vcl.list output diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c index cf9133ed6..88844c295 100644 --- a/bin/varnishd/cache/cache_vcl.c +++ b/bin/varnishd/cache/cache_vcl.c @@ -657,12 +657,15 @@ vcl_cli_list(struct cli *cli, const char * const *av, void *priv) { struct vcl *vcl; const char *flg; + struct vsb *vsb; /* NB: Shall generate same output as mcf_vcl_list() */ (void)av; (void)priv; ASSERT_CLI(); + vsb = VSB_new_auto(); + AN(vsb); VTAILQ_FOREACH(vcl, &vcl_head, list) { if (vcl == vcl_active) { flg = "active"; @@ -670,19 +673,20 @@ vcl_cli_list(struct cli *cli, const char * const *av, void *priv) flg = "discarded"; } else flg = "available"; - VCLI_Out(cli, "%-10s %5s/%-8s %6u %s", + VSB_printf(vsb, "%s\t%s\t%s\t%6u\t%s", flg, vcl->state, vcl->temp, vcl->busy, vcl->loaded_name); if (vcl->label != NULL) { - VCLI_Out(cli, " -> %s", vcl->label->loaded_name); + VSB_printf(vsb, "\t->\t%s", vcl->label->loaded_name); if (vcl->nrefs) - VCLI_Out(cli, " (%d return(vcl)%s)", + VSB_printf(vsb, " (%d return(vcl)%s)", vcl->nrefs, vcl->nrefs > 1 ? "'s" : ""); } else if (vcl->nlabels > 0) { - VCLI_Out(cli, " (%d label%s)", + VSB_printf(vsb, "\t<-\t(%d label%s)", vcl->nlabels, vcl->nlabels > 1 ? "s" : ""); } - VCLI_Out(cli, "\n"); + VSB_printf(vsb, "\n"); } + VCLI_VTE(cli, &vsb, 80); } static void v_matchproto_(cli_func_t) diff --git a/bin/varnishd/mgt/mgt_vcl.c b/bin/varnishd/mgt/mgt_vcl.c index 1a51ba07c..d9773c78f 100644 --- a/bin/varnishd/mgt/mgt_vcl.c +++ b/bin/varnishd/mgt/mgt_vcl.c @@ -799,11 +799,13 @@ mcf_vcl_list(struct cli *cli, const char * const *av, void *priv) char *p; struct vclprog *vp; struct vcldep *vd; + struct vsb *vsb; /* NB: Shall generate same output as vcl_cli_list() */ (void)av; (void)priv; + if (MCH_Running()) { if (!mgt_cli_askchild(&status, &p, "vcl.list\n")) { VCLI_SetResult(cli, status); @@ -811,26 +813,29 @@ mcf_vcl_list(struct cli *cli, const char * const *av, void *priv) } free(p); } else { + vsb = VSB_new_auto(); + AN(vsb); + VTAILQ_FOREACH(vp, &vclhead, list) { - VCLI_Out(cli, "%-10s %5s", - vp == active_vcl ? "active" : "available", - vp->state); - VCLI_Out(cli, "/%-8s", vp->warm ? + VSB_printf(vsb, "%s", + vp == active_vcl ? "active" : "available"); + VSB_printf(vsb, "\t%s\t%s", vp->state, vp->warm ? VCL_STATE_WARM : VCL_STATE_COLD); - VCLI_Out(cli, " %6s %s", "-", vp->name); + VSB_printf(vsb, "\t%6s\t%s", "-", vp->name); if (mcf_is_label(vp)) { vd = VTAILQ_FIRST(&vp->dfrom); AN(vd); - VCLI_Out(cli, " -> %s", vd->to->name); + VSB_printf(vsb, "\t->\t%s", vd->to->name); if (vp->nto > 0) - VCLI_Out(cli, " (%d return(vcl)%s)", + VSB_printf(vsb, " (%d return(vcl)%s)", vp->nto, vp->nto > 1 ? "'s" : ""); } else if (vp->nto > 0) { - VCLI_Out(cli, " (%d label%s)", + VSB_printf(vsb, "\t<-\t(%d label%s)", vp->nto, vp->nto > 1 ? "s" : ""); } - VCLI_Out(cli, "\n"); + VSB_printf(vsb, "\n"); } + VCLI_VTE(cli, &vsb, 80); } } diff --git a/bin/varnishtest/tests/s00005.vtc b/bin/varnishtest/tests/s00005.vtc index 4dac2f167..01c2def7e 100644 --- a/bin/varnishtest/tests/s00005.vtc +++ b/bin/varnishtest/tests/s00005.vtc @@ -105,7 +105,7 @@ varnish v1 -clijson "vcl.list -j" varnish v1 -start varnish v1 -cliok "vcl.list" -varnish v1 -cliok "vcl.label snarf vcl1" +varnish v1 -cliok "vcl.label slartibartfast vcl1" server s1 -start client c1 -run diff --git a/bin/varnishtest/tests/u00000.vtc b/bin/varnishtest/tests/u00000.vtc index ae91b169f..5eba11b19 100644 --- a/bin/varnishtest/tests/u00000.vtc +++ b/bin/varnishtest/tests/u00000.vtc @@ -101,7 +101,7 @@ shell -expect {VCL compiled.} { varnishadm -n ${tmpdir}/v1 vcl.load vcl1 ${tmpdir}/vcl } -shell -expect {active auto/warm - vcl1} { +shell -expect {active auto warm - vcl1} { varnishadm -n ${tmpdir}/v1 vcl.list } @@ -145,8 +145,8 @@ shell { } varnish v2 -arg "-f ${tmpdir}/ok1" -arg "-f ${tmpdir}/ok2" -start -varnish v2 -cliexpect {available *auto/warm *0 boot0} "vcl.list" -varnish v2 -cliexpect {active *auto/warm *0 boot} "vcl.list" +varnish v2 -cliexpect {available auto warm 0 boot0} "vcl.list" +varnish v2 -cliexpect {active auto warm 0 boot} "vcl.list" varnish v2 -stop -wait # Test multiple -f options with a bad VCL diff --git a/bin/varnishtest/tests/u00011.vtc b/bin/varnishtest/tests/u00011.vtc index b53a9ba7b..25ddf8f1a 100644 --- a/bin/varnishtest/tests/u00011.vtc +++ b/bin/varnishtest/tests/u00011.vtc @@ -24,7 +24,7 @@ process p1 -expect-text 0 1 "PONG" process p1 -write "vcl.li\t\r" -process p1 -expect-text 0 1 "active auto/warm" +process p1 -expect-text 0 1 "active auto warm 1 vcl1" process p1 -write "vcl.s\t\th\t vcl1\r" diff --git a/bin/varnishtest/tests/u00012.vtc b/bin/varnishtest/tests/u00012.vtc index e9822213a..2744ae40a 100644 --- a/bin/varnishtest/tests/u00012.vtc +++ b/bin/varnishtest/tests/u00012.vtc @@ -22,7 +22,7 @@ process p1 -expect-text 0 1 "PONG" process p1 -write "vcl.list\r" -process p1 -expect-text 0 0 "auto/warm" +process p1 -expect-text 0 0 "auto warm" process p1 -write "vcl.show vcl1\r" diff --git a/bin/varnishtest/tests/v00003.vtc b/bin/varnishtest/tests/v00003.vtc index 6236f28f1..5ef44b95b 100644 --- a/bin/varnishtest/tests/v00003.vtc +++ b/bin/varnishtest/tests/v00003.vtc @@ -88,7 +88,7 @@ varnish v1 -expect !VBE.vcl1.default.happy varnish v1 -cliok "param.set max_esi_depth 42" varnish v1 -clierr 300 "vcl.state vcl1 warm" -varnish v1 -cliexpect "available *cold/cold *[0-9]+ *vcl1\\s+active *warm/warm *[0-9]+ *vcl2" "vcl.list" +varnish v1 -cliexpect "available *cold *cold *[0-9]+ *vcl1\\s+active *warm *warm *[0-9]+ *vcl2" "vcl.list" # A warm-up failure can also fail a child start varnish v1 -cliok stop diff --git a/bin/varnishtest/tests/v00045.vtc b/bin/varnishtest/tests/v00045.vtc index 0f9cdf5a6..2591f9d36 100644 --- a/bin/varnishtest/tests/v00045.vtc +++ b/bin/varnishtest/tests/v00045.vtc @@ -17,7 +17,7 @@ varnish v1 -cliok "vcl.state vcl1 cold" # We should now see it as cooling delay 1 -varnish v1 -cliexpect "cold/cooling.*vcl1" vcl.list +varnish v1 -cliexpect "available cold cooling 0 vcl1" vcl.list varnish v1 -clijson "vcl.list -j" # It can't be warmed up yet @@ -26,7 +26,7 @@ varnish v1 -cliexpect "vmod-debug ref on vcl1" "vcl.state vcl1 warm" # It will eventually cool down delay 2 -varnish v1 -cliexpect "cold/cold.*vcl1" vcl.list +varnish v1 -cliexpect "available cold cold 0 vcl1" vcl.list varnish v1 -clijson "vcl.list -j" # At this point it becomes possible to warm up again diff --git a/doc/sphinx/reference/vtla.rst b/doc/sphinx/reference/vtla.rst index 905d2d6c1..ba80b8958 100644 --- a/doc/sphinx/reference/vtla.rst +++ b/doc/sphinx/reference/vtla.rst @@ -90,6 +90,9 @@ VSS VTC Varnish Test Code -- a test-specification for the varnishtest program. +VTE + Varnish Turbo Encabulator + VTLA Varnish Three Letter Acronym -- No rule without an exception. diff --git a/include/vcli_serve.h b/include/vcli_serve.h index 00b364ff4..71beae3a1 100644 --- a/include/vcli_serve.h +++ b/include/vcli_serve.h @@ -106,3 +106,6 @@ cli_func_t VCLS_func_help; cli_func_t VCLS_func_help_json; cli_func_t VCLS_func_ping; cli_func_t VCLS_func_ping_json; + +/* From libvarnish/vte.c */ +void VCLI_VTE(struct cli *cli, struct vsb **src, int width); diff --git a/lib/libvarnish/Makefile.am b/lib/libvarnish/Makefile.am index a7a57dd49..bb27d4e1e 100644 --- a/lib/libvarnish/Makefile.am +++ b/lib/libvarnish/Makefile.am @@ -39,6 +39,7 @@ libvarnish_a_SOURCES = \ vss.c \ vsub.c \ vtcp.c \ + vte.c \ vtim.c \ vus.c diff --git a/lib/libvarnish/vte.c b/lib/libvarnish/vte.c new file mode 100644 index 000000000..3063d4b90 --- /dev/null +++ b/lib/libvarnish/vte.c @@ -0,0 +1,116 @@ +/*- + * Copyright (c) 2019 Varnish Software AS + * All rights reserved. + * + * Author: Poul-Henning Kamp + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ + +#include "config.h" + +#include +#include + +#include "vdef.h" +#include "vqueue.h" + +#include "vas.h" +#include "vcli_serve.h" +#include "vsb.h" + +#define MAXCOL 10 + +void +VCLI_VTE(struct cli *cli, struct vsb **src, int width) +{ + int w_col[MAXCOL]; + int n_col = 0; + int w_ln = 0; + int cc = 0; + int wc = 0; + int wl = 0; + int nsp; + const char *p; + char *s; + + AN(cli); + AN(src); + AN(*src); + AZ(VSB_finish(*src)); + if (VSB_len(*src) == 0) { + VSB_destroy(src); + return; + } + s = VSB_data(*src); + AN(s); + memset(w_col, 0, sizeof w_col); + for (p = s; *p ; p++) { + if (*p == '\t' || *p == '\n') { + if (wc > w_col[cc]) + w_col[cc] = wc; + cc++; + assert(cc < MAXCOL); + wc = 0; + } + if (*p == '\n') { + if (cc > n_col) + n_col = cc; + cc = 0; + wc = 0; + if (wl > w_ln) + w_ln = wl; + wl = 0; + } + wc++; + wl++; + } + + if (n_col == 0) + return; + AN(n_col); + + nsp = (width - (w_ln)) / n_col; + if (nsp > 3) + nsp = 3; + + cc = 0; + wc = 0; + for (p = s; *p ; p++) { + if (*p == '\t') { + while (wc++ < w_col[cc] + nsp) + VCLI_Out(cli, " "); + cc++; + wc = 0; + } else if (*p == '\n') { + VCLI_Out(cli, "%c", *p); + cc = 0; + wc = 0; + } else { + VCLI_Out(cli, "%c", *p); + wc++; + } + } + VSB_destroy(src); +} + From phk at FreeBSD.org Tue Feb 19 22:37:07 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 19 Feb 2019 22:37:07 +0000 (UTC) Subject: [master] c97b8e369 Try to stave off trouble as seen to day with generated vmod-boilerplate Message-ID: <20190219223707.EA34F11038C@lists.varnish-cache.org> commit c97b8e369594050e7c60494429626ea98c46ecb3 Author: Poul-Henning Kamp Date: Tue Feb 19 22:36:12 2019 +0000 Try to stave off trouble as seen to day with generated vmod-boilerplate diff --git a/tools/vtest.sh b/tools/vtest.sh index 1508c2fca..4d4b3d6dd 100755 --- a/tools/vtest.sh +++ b/tools/vtest.sh @@ -212,6 +212,7 @@ while [ $MAXRUNS -eq 0 ] || [ $i -lt $MAXRUNS ] do i=$((i + 1)) + (cd "${SRCDIR}" && git reset --hard > /dev/null 2>&1 || true) (cd "${SRCDIR}" && git pull > /dev/null 2>&1 || true) rev=`cd "${SRCDIR}" && git show -s --pretty=format:%H` if [ "${waitnext}" -gt 0 -a "x${rev}" = "x${orev}" ] ; then From nils.goroll at uplex.de Wed Feb 20 08:41:07 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 20 Feb 2019 08:41:07 +0000 (UTC) Subject: [master] 3690dfb7d minor help text edit Message-ID: <20190220084107.BC84F674A@lists.varnish-cache.org> commit 3690dfb7d224b80ae81488cef3123fd013578c47 Author: Nils Goroll Date: Wed Feb 20 08:56:18 2019 +0100 minor help text edit diff --git a/include/tbl/cli_cmds.h b/include/tbl/cli_cmds.h index 91f30b1b8..0492aa714 100644 --- a/include/tbl/cli_cmds.h +++ b/include/tbl/cli_cmds.h @@ -52,7 +52,7 @@ CLI_CMD(BAN_LIST, "ban.list [-j]", "List the active bans.", - " Unless ``-j`` is specified (for JSON output), " + " Unless ``-j`` is specified for JSON output, " " the output format is:\n\n" " * Time the ban was issued.\n\n" " * Objects referencing this ban.\n\n" From nils.goroll at uplex.de Wed Feb 20 08:41:07 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 20 Feb 2019 08:41:07 +0000 (UTC) Subject: [master] 25f38bd54 document vcl.list output change Message-ID: <20190220084107.D24C8674D@lists.varnish-cache.org> commit 25f38bd54f59868d41af53a5ae5388544c892aba Author: Nils Goroll Date: Wed Feb 20 09:29:19 2019 +0100 document vcl.list output change Ref 45239c2413098201a9c32e9fad597e352d694205 diff --git a/doc/changes.rst b/doc/changes.rst index ce2bd46ae..6a88d45d2 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -67,6 +67,18 @@ Varnish Cache trunk (ongoing) * The undocumented ``-v`` option to the ``backend.list`` cli command has been removed +* Changed the formatting of the ``vcl.list`` command from:: + + status state/temperature busy name [labelinfo] + + to:: + + status state temperature busy name [<-|->] [info] + + Column width is now dynamic. + + See varnish-cli(7) for details on the field values (which remain unchanged). + * The ban facility has been extended by bans access to obj.ttl, obj.age, obj.grace and obj.keep and additional inequality operators. diff --git a/include/tbl/cli_cmds.h b/include/tbl/cli_cmds.h index 0492aa714..5350a7194 100644 --- a/include/tbl/cli_cmds.h +++ b/include/tbl/cli_cmds.h @@ -107,7 +107,17 @@ CLI_CMD(VCL_LIST, "vcl.list", "vcl.list [-j]", "List all loaded configuration.", - " ``-j`` specifies JSON output.", + " Unless ``-j`` is specified for JSON output, " + " the output format is five or seven columns of dynamic width, " + " separated by white space with the fields:\n\n" + " * status: active, available or discarded\n\n" + " * state: label, cold, warm, or auto\n\n" + " * temperature: init, cold, warm, busy or cooling\n\n" + " * busy: number of references to this vcl (integer)\n\n" + " * name: the name given to this vcl or label\n\n" + " * [ ``<-`` | ``->`` ] and label info last two fields)\n\n" + " * ``->`` : label \"points to\" the named \n\n" + " * ``<-`` ( label[s]): the vcl has label(s)\n\n", 0, 0 ) From nils.goroll at uplex.de Wed Feb 20 08:41:07 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 20 Feb 2019 08:41:07 +0000 (UTC) Subject: [master] dc69d1c13 make vmodtool reject arguments of type VOID Message-ID: <20190220084107.ED0D56751@lists.varnish-cache.org> commit dc69d1c136f248b56686c7abd9b3d82ab367737d Author: Nils Goroll Date: Wed Feb 20 09:38:04 2019 +0100 make vmodtool reject arguments of type VOID VOID is only valid as a return type. If VOID was used as an argument, the C compiler would bail out, yet we should better check this early. Looking through CTYPES, VOID seems to be the only type not valid for arguments, thus the explicit check. diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py index fe2a45161..30e9a50f9 100755 --- a/lib/libvcc/vmodtool.py +++ b/lib/libvcc/vmodtool.py @@ -359,6 +359,8 @@ class ProtoType(object): self.argstruct = True else: t = arg(wl, names, st.vcc.enums, ',') + if t.vt == 'VOID': + err("arguments can not be of type '%s'" % t.vt, warn=False) if t.nm is None: t.nm2 = "arg%d" % n else: From nils.goroll at uplex.de Wed Feb 20 08:51:07 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 20 Feb 2019 08:51:07 +0000 (UTC) Subject: [master] 207280b9b have vmodtool check STRING_LIST position Message-ID: <20190220085107.26EFF6EF1@lists.varnish-cache.org> commit 207280b9b7c96bf10f9271aaeafd8cfac0532c69 Author: Nils Goroll Date: Wed Feb 20 09:48:15 2019 +0100 have vmodtool check STRING_LIST position not? en passant diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py index 30e9a50f9..bbde1ca98 100755 --- a/lib/libvcc/vmodtool.py +++ b/lib/libvcc/vmodtool.py @@ -361,6 +361,8 @@ class ProtoType(object): t = arg(wl, names, st.vcc.enums, ',') if t.vt == 'VOID': err("arguments can not be of type '%s'" % t.vt, warn=False) + if t.vt == 'STRING_LIST' and len(wl) > 1: + err("'%s' must be the last argument" % t.vt, warn=False) if t.nm is None: t.nm2 = "arg%d" % n else: From nils.goroll at uplex.de Wed Feb 20 08:54:08 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 20 Feb 2019 08:54:08 +0000 (UTC) Subject: [master] 5362c7e70 be more accurate Message-ID: <20190220085408.8390B7151@lists.varnish-cache.org> commit 5362c7e7034ddf976d6a4c66d48a5187c2e6647f Author: Nils Goroll Date: Wed Feb 20 09:53:53 2019 +0100 be more accurate diff --git a/doc/changes.rst b/doc/changes.rst index 6a88d45d2..48e3cdf4d 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -77,7 +77,8 @@ Varnish Cache trunk (ongoing) Column width is now dynamic. - See varnish-cli(7) for details on the field values (which remain unchanged). + Field values remain unchanged except for the label information, see + varnish-cli(7) for details. * The ban facility has been extended by bans access to obj.ttl, obj.age, obj.grace and obj.keep and additional inequality operators. From dridi.boukelmoune at gmail.com Wed Feb 20 11:23:07 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 20 Feb 2019 11:23:07 +0000 (UTC) Subject: [master] 9c1e251c9 Typo Message-ID: <20190220112307.B4904613E3@lists.varnish-cache.org> commit 9c1e251c9853d7ac5e2749b492a25a6c7b354dfd Author: Dridi Boukelmoune Date: Wed Feb 20 12:21:43 2019 +0100 Typo diff --git a/doc/changes.rst b/doc/changes.rst index 48e3cdf4d..541b39224 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -108,7 +108,7 @@ bundled tools This adds rate limiting to varnishncsa and varnishlog. -* Make it possible to change ``varnishncsa`` update rate. (2741_) +* Make it possible to change ``varnishstat`` update rate. (2741_) C APIs (for vmod and utility authors) ------------------------------------- From lasse.karstensen at gmail.com Wed Feb 20 21:32:08 2019 From: lasse.karstensen at gmail.com (Lasse Karstensen) Date: Wed, 20 Feb 2019 21:32:08 +0000 (UTC) Subject: [master] 9ca3df8fe s/varnish/Varnish/g in docs. Message-ID: <20190220213208.1A37910D46B@lists.varnish-cache.org> commit 9ca3df8fec3d7647e469ac5ae5a02c04621219db Author: Lasse Karstensen Date: Wed Feb 20 22:28:15 2019 +0100 s/varnish/Varnish/g in docs. Because it looks better. diff --git a/doc/sphinx/users-guide/esi.rst b/doc/sphinx/users-guide/esi.rst index a88e9cc91..b85d18f23 100644 --- a/doc/sphinx/users-guide/esi.rst +++ b/doc/sphinx/users-guide/esi.rst @@ -115,7 +115,7 @@ ESI includes with HTTPS protocol ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ If ESI:include tags specify HTTPS protocol, it will be ignored -by default, because varnish has no way to fetch it encryption +by default, because Varnish has no way to fetch it encryption enabled. If you want to treat HTTPS in ESI:include tags as if it were HTTP, set:: diff --git a/doc/sphinx/users-guide/purging.rst b/doc/sphinx/users-guide/purging.rst index 58fa52e45..d91ad57a1 100644 --- a/doc/sphinx/users-guide/purging.rst +++ b/doc/sphinx/users-guide/purging.rst @@ -45,7 +45,7 @@ following VCL in place:: As you can see we have used a new action - return(purge). This ends execution of vcl_recv and jumps to vcl_hash. This is just like we -handle a regular request. When vcl_hash calls return(lookup) varnish +handle a regular request. When vcl_hash calls return(lookup) Varnish will purge the object and then call vcl_purge. Here you have the option of adding any particular actions you want Varnish to take once it has purge the object. @@ -78,7 +78,7 @@ the following command from the shell:: See :ref:`vcl(7)_ban` for details on the syntax of ban expressions. In particular, note that in the example given above, the quotes are required for execution from the shell and escaping the backslash in -the regular expression is required by the varnish cli interface. +the regular expression is required by the Varnish cli interface. Bans are checked when we hit an object in the cache, but before we deliver it. *An object is only checked against newer bans*. diff --git a/doc/sphinx/users-guide/storage-backends.rst b/doc/sphinx/users-guide/storage-backends.rst index 3dd71408a..9ba6076a4 100644 --- a/doc/sphinx/users-guide/storage-backends.rst +++ b/doc/sphinx/users-guide/storage-backends.rst @@ -71,11 +71,11 @@ implementations. In particular, `libumem`_ is included in the family of OpenSolaris descendent operating systems where jemalloc(3) is not commonly available. -If `libumem`_ is not used otherwise, varnish will only use it for +If `libumem`_ is not used otherwise, Varnish will only use it for storage allocations and keep the default libc allocator for all other -varnish memory allocation purposes. +Varnish memory allocation purposes. -If `libumem`_ is already loaded when varnish initializes, this message +If `libumem`_ is already loaded when Varnish initializes, this message is output:: notice: libumem was already found to be loaded @@ -91,15 +91,15 @@ reasons for this to be the case are: ``LD_PRELOAD_32=/usr/lib/libumem.so.1`` or ``LD_PRELOAD=/usr/lib/libumem.so.1`` is set -varnish will also output this message to recommend settings for using +Varnish will also output this message to recommend settings for using `libumem`_ for all allocations:: it is recommended to set UMEM_OPTIONS=perthread_cache=0,backend=mmap before starting varnish This recommendation should be followed to achieve an optimal -`libumem`_ configuration for varnish. Setting this environment -variable before starting varnish is required becuase `libumem`_ cannot +`libumem`_ configuration for Varnish. Setting this environment +variable before starting Varnish is required becuase `libumem`_ cannot be reconfigured once loaded. .. _libumem: http://dtrace.org/blogs/ahl/2004/07/13/number-11-of-20-libumem/ diff --git a/doc/sphinx/users-guide/vcl-backends.rst b/doc/sphinx/users-guide/vcl-backends.rst index 58448916f..7867140eb 100644 --- a/doc/sphinx/users-guide/vcl-backends.rst +++ b/doc/sphinx/users-guide/vcl-backends.rst @@ -74,7 +74,7 @@ really arbitrary data. You want to send mobile devices to a different backend? No problem. ``if (req.http.User-agent ~ /mobile/) ..`` should do the trick. -Without an explicit backend selection, varnish will continue using +Without an explicit backend selection, Varnish will continue using the `default` backend. If there is no backend named `default`, the first backend found in the vcl will be used as the default backend. diff --git a/doc/sphinx/users-guide/vcl-built-in-subs.rst b/doc/sphinx/users-guide/vcl-built-in-subs.rst index 690f337ef..95c9885a9 100644 --- a/doc/sphinx/users-guide/vcl-built-in-subs.rst +++ b/doc/sphinx/users-guide/vcl-built-in-subs.rst @@ -345,7 +345,7 @@ The `vcl_backend_fetch` subroutine may terminate with calling background fetch, control is passed to :ref:`vcl_synth` on the client side with ``resp.status`` preset to 503. -Before calling `vcl_backend_fetch`, varnish core prepares the `bereq` +Before calling `vcl_backend_fetch`, Varnish core prepares the `bereq` backend request as follows: * Unless the request is a `pass`, @@ -411,7 +411,7 @@ The `vcl_backend_response` subroutine may terminate with calling 304 handling ~~~~~~~~~~~~ -For a 304 response, varnish core code amends ``beresp`` before calling +For a 304 response, Varnish core code amends ``beresp`` before calling `vcl_backend_response`: * If the gzip status changed, ``Content-Encoding`` is unset and any diff --git a/doc/sphinx/users-guide/vcl-grace.rst b/doc/sphinx/users-guide/vcl-grace.rst index dddfac5f7..fcaa301bb 100644 --- a/doc/sphinx/users-guide/vcl-grace.rst +++ b/doc/sphinx/users-guide/vcl-grace.rst @@ -61,7 +61,7 @@ The effect of grace and keep For most users setting the default grace and/or a suitable grace for each object is enough. The default VCL will do the right thing and behave as described above. However, if you want to customize how -varnish behaves, then you should know some of the details on how this +Varnish behaves, then you should know some of the details on how this works. When ``sub vcl_recv`` ends with ``return (lookup)`` (which is the diff --git a/doc/sphinx/users-guide/vcl-separate.rst b/doc/sphinx/users-guide/vcl-separate.rst index 031807cb3..a654fe9ed 100644 --- a/doc/sphinx/users-guide/vcl-separate.rst +++ b/doc/sphinx/users-guide/vcl-separate.rst @@ -17,7 +17,7 @@ First load the two VCL files:: vcl.load vc_1 /somewhere/vc.vcl These are 100% normal VCL files, as they would look if you ran -only that single domain on your varnish instance. +only that single domain on your Varnish instance. Next we need to point VCL labels to them:: From phk at FreeBSD.org Wed Feb 20 21:48:07 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 20 Feb 2019 21:48:07 +0000 (UTC) Subject: [master] a0436a439 Use the Turbo encabulator for backend.list Message-ID: <20190220214807.484FE10D9D5@lists.varnish-cache.org> commit a0436a439f078902812a5adb1f2d2f979ca315bc Author: Poul-Henning Kamp Date: Wed Feb 20 20:28:37 2019 +0000 Use the Turbo encabulator for backend.list Lines starting with a space are interpreted as a "block quote" and not ecabulated, this is used for probe details. diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c index f5b867335..3ff3c9ac7 100644 --- a/bin/varnishd/cache/cache_backend.c +++ b/bin/varnishd/cache/cache_backend.c @@ -465,7 +465,7 @@ vbe_list(VRT_CTX, const struct director *d, struct vsb *vsb, int pflag, else if (pflag) return; else - VSB_printf(vsb, "%-*s", VDI_LIST_W_PROBE, + VSB_printf(vsb, "%s", d->sick ? "sick" : "healthy"); } diff --git a/bin/varnishd/cache/cache_backend_probe.c b/bin/varnishd/cache/cache_backend_probe.c index 19719fca3..8e0d22036 100644 --- a/bin/varnishd/cache/cache_backend_probe.c +++ b/bin/varnishd/cache/cache_backend_probe.c @@ -515,19 +515,19 @@ void VBP_Status(struct vsb *vsb, const struct backend *be, int details, int json) { struct vbp_target *vt; - char buf[VDI_LIST_W_PROBE + 2]; CHECK_OBJ_NOTNULL(be, BACKEND_MAGIC); vt = be->probe; CHECK_OBJ_NOTNULL(vt, VBP_TARGET_MAGIC); if (!details) { - bprintf(buf, "%u/%u %s", vt->good, vt->window, - vt->backend->director->sick ? "bad" : "good"); if (json) - VSB_printf(vsb, "\"%s\"", buf); + VSB_printf(vsb, "[%u, %u, \"%s\"]", + vt->good, vt->window, + vt->backend->director->sick ? "bad" : "good"); else - VSB_printf(vsb, "%-*s", VDI_LIST_W_PROBE, buf); + VSB_printf(vsb, "%u/%u %s", vt->good, vt->window, + vt->backend->director->sick ? "bad" : "good"); return; } @@ -547,7 +547,7 @@ VBP_Status(struct vsb *vsb, const struct backend *be, int details, int json) } VSB_printf(vsb, - "\nCurrent states good: %2u threshold: %2u window: %2u\n", + "\n Current states good: %2u threshold: %2u window: %2u\n", vt->good, vt->threshold, vt->window); VSB_printf(vsb, " Average response time of good probes: %.6f\n", vt->avg); diff --git a/bin/varnishd/cache/cache_director.c b/bin/varnishd/cache/cache_director.c index c8a4d863c..5161be684 100644 --- a/bin/varnishd/cache/cache_director.c +++ b/bin/varnishd/cache/cache_director.c @@ -274,6 +274,7 @@ struct list_args { int p; int j; const char *jsep; + struct vsb *vsb; }; static const char * @@ -291,7 +292,9 @@ do_list(struct cli *cli, struct director *d, void *priv) struct list_args *la; struct vrt_ctx *ctx; + AN(cli); CAST_OBJ_NOTNULL(la, priv, LIST_ARGS_MAGIC); + AN(la->vsb); CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); if (d->vdir->admin_health == VDI_AH_DELETED) @@ -300,20 +303,19 @@ do_list(struct cli *cli, struct director *d, void *priv) ctx = VCL_Get_CliCtx(0); // XXX admin health "probe" for the no-probe case is confusing - VCLI_Out(cli, "\n%-*s %-*s ", - VDI_LIST_W_NAME, d->vdir->cli_name, - VDI_LIST_W_ADMIN, VDI_Ahealth(d)); + VSB_printf(la->vsb, "%s\t%s\t", d->vdir->cli_name, VDI_Ahealth(d)); if (d->vdir->methods->list != NULL) - d->vdir->methods->list(ctx, d, cli->sb, 0, 0); + d->vdir->methods->list(ctx, d, la->vsb, 0, 0); else - VCLI_Out(cli, "%-*s", VDI_LIST_W_PROBE, cli_health(ctx, d)); + VSB_printf(la->vsb, "%s", cli_health(ctx, d)); VTIM_format(d->vdir->health_changed, time_str); - VCLI_Out(cli, " %s", time_str); + VSB_printf(la->vsb, "\t%s", time_str); if (la->p && d->vdir->methods->list != NULL) - d->vdir->methods->list(ctx, d, cli->sb, la->p, 0); + d->vdir->methods->list(ctx, d, la->vsb, la->p, 0); + VSB_printf(la->vsb, "\n"); VCL_Rel_CliCtx(&ctx); AZ(ctx); @@ -392,7 +394,7 @@ cli_backend_list(struct cli *cli, const char * const *av, void *priv) return; } if (la->j) { - VCLI_JSON_begin(cli, 2, av); + VCLI_JSON_begin(cli, 3, av); VCLI_Out(cli, ",\n"); VCLI_Out(cli, "{\n"); VSB_indent(cli->sb, 2); @@ -402,12 +404,12 @@ cli_backend_list(struct cli *cli, const char * const *av, void *priv) VCLI_Out(cli, "}"); VCLI_JSON_end(cli); } else { - VCLI_Out(cli, "%-*s %-*s %-*s %s", - VDI_LIST_W_NAME, "Backend name", - VDI_LIST_W_ADMIN, "Admin", - VDI_LIST_W_PROBE, "Probe", - "Last change"); + la->vsb = VSB_new_auto(); + AN(la->vsb); + VSB_printf(la->vsb, "%s\t%s\t%s\t%s\n", + "Backend name", "Admin", "Probe", "Last change"); (void)VCL_IterDirector(cli, av[i], do_list, la); + VCLI_VTE(cli, &la->vsb, 80); } } diff --git a/include/vrt.h b/include/vrt.h index 11c4eb2c2..f6fc9ca26 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -496,11 +496,6 @@ struct vdi_methods { vdi_list_f *list; }; -/* width of fields in "backend.list" */ -#define VDI_LIST_W_NAME 30 -#define VDI_LIST_W_ADMIN 7 -#define VDI_LIST_W_PROBE 14 - struct vcldir; struct director { diff --git a/lib/libvarnish/vte.c b/lib/libvarnish/vte.c index 3063d4b90..c2f49ec51 100644 --- a/lib/libvarnish/vte.c +++ b/lib/libvarnish/vte.c @@ -66,6 +66,11 @@ VCLI_VTE(struct cli *cli, struct vsb **src, int width) AN(s); memset(w_col, 0, sizeof w_col); for (p = s; *p ; p++) { + if (wl == 0 && *p == ' ') { + while (p[1] != '\0' && *p != '\n') + p++; + continue; + } if (*p == '\t' || *p == '\n') { if (wc > w_col[cc]) w_col[cc] = wc; @@ -81,9 +86,10 @@ VCLI_VTE(struct cli *cli, struct vsb **src, int width) if (wl > w_ln) w_ln = wl; wl = 0; + } else { + wc++; + wl++; } - wc++; - wl++; } if (n_col == 0) @@ -97,6 +103,15 @@ VCLI_VTE(struct cli *cli, struct vsb **src, int width) cc = 0; wc = 0; for (p = s; *p ; p++) { + if (wc == 0 && cc == 0 && *p == ' ') { + while (p[1] != '\0') { + VCLI_Out(cli, "%c", *p); + if (*p == '\n') + break; + p++; + } + continue; + } if (*p == '\t') { while (wc++ < w_col[cc] + nsp) VCLI_Out(cli, " "); From nils.goroll at uplex.de Thu Feb 21 08:52:08 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Thu, 21 Feb 2019 08:52:08 +0000 (UTC) Subject: [master] 751665662 document backend.list Message-ID: <20190221085208.74A674BBF@lists.varnish-cache.org> commit 75166566231624195d0d5a5b28b887587ffb5b91 Author: Nils Goroll Date: Thu Feb 21 09:47:00 2019 +0100 document backend.list diff --git a/include/tbl/cli_cmds.h b/include/tbl/cli_cmds.h index 5350a7194..0bc1e0f0f 100644 --- a/include/tbl/cli_cmds.h +++ b/include/tbl/cli_cmds.h @@ -272,6 +272,22 @@ CLI_CMD(BACKEND_LIST, "List backends.\n", " ``-p`` also shows probe status.\n\n" " ``-j`` specifies JSON output.\n\n" + " Unless ``-j`` is specified for JSON output, " + " the output format is four columns of dynamic width, " + " separated by white space with the fields:\n\n" + " * Backend name\n\n" + " * Admin: How health state is determined:\n\n" + " * healthy: Set healthy through backend.set_health.\n\n" + " * sick: Set sick through backend.set_health.\n\n" + " * probe: Health state determined by a probe.\n\n" + " * deleted: Backend has been deleted, but not yet cleaned up.\n\n" + /* XXX #2896 TBD */ + " * Probe: Summary of probe checks:\n\n" + " * healthy\n\n" + " * sick\n\n" + " * x/y {good,bad}: The backend is good or bad by x/y measure (e.g." + " probes or number of backends in a director\n\n" + " * Last change: Timestamp when the health state last changed.\n\n" " The health state reported here is generic. A backend's health " "may also depend on the context it is being used in (e.g. " "the object's hash), so the actual health state as visible " From nils.goroll at uplex.de Thu Feb 21 08:52:08 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Thu, 21 Feb 2019 08:52:08 +0000 (UTC) Subject: [master] f403938c3 document backend.list changes Message-ID: <20190221085208.8AFE04BC2@lists.varnish-cache.org> commit f403938c39b981f6e1de49481e31ca16407c67da Author: Nils Goroll Date: Thu Feb 21 09:51:23 2019 +0100 document backend.list changes Ref: a0436a439f078902812a5adb1f2d2f979ca315bc diff --git a/doc/changes.rst b/doc/changes.rst index 541b39224..55177809a 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -58,12 +58,21 @@ Varnish Cache trunk (ongoing) ``vcl_dir`` -> ``vcl_path`` ``vmod_dir`` -> ``vmod_path`` -* Changed the width of the `Probe` column of the ``backend.list`` - cli command from 10 to 14 characters +* The width of the columns of the ``backend.list`` cli command output + is now dynamic. For best forward compatibility, we recommend that scripts parse JSON output as obtained using the ``-j`` option. +* The format of the ``backend.list -j`` (JSON) cli command output has + changed: + + * the ``probe_message`` field of a backend can now also have the + format ``[X, Y, state]``, X and Y being integers signifying X out + of Y probes/backends/... + +.. expecting more changes here #2896 + * The undocumented ``-v`` option to the ``backend.list`` cli command has been removed From dridi.boukelmoune at gmail.com Thu Feb 21 13:44:07 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 21 Feb 2019 13:44:07 +0000 (UTC) Subject: [master] 4d8e4b9cb Fix max_concurrent_streams check Message-ID: <20190221134407.AE30561CA5@lists.varnish-cache.org> commit 4d8e4b9cb960039d08814034d65d3ece1e78d042 Author: Shohei Tanaka(@xcir) Date: Thu Feb 21 21:01:17 2019 +0900 Fix max_concurrent_streams check diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index 5b6ce30c0..bb2de4cf4 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -634,7 +634,7 @@ h2_rx_headers(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) if (r2 == NULL) { if (h2->rxf_stream <= h2->highest_stream) return (H2CE_PROTOCOL_ERROR); // rfc7540,l,1153,1158 - if (h2->refcnt >= h2->local_settings.max_concurrent_streams) { + if (h2->refcnt > h2->local_settings.max_concurrent_streams) { VSLb(h2->vsl, SLT_Debug, "H2: stream %u: Hit maximum number of " "concurrent streams", h2->rxf_stream); diff --git a/bin/varnishtest/tests/t02012.vtc b/bin/varnishtest/tests/t02012.vtc index 5319453e7..3f7ec8092 100644 --- a/bin/varnishtest/tests/t02012.vtc +++ b/bin/varnishtest/tests/t02012.vtc @@ -12,7 +12,7 @@ server s1 { varnish v1 -cliok "param.set feature +http2" varnish v1 -cliok "param.set debug +syncvsl" -varnish v1 -cliok "param.set h2_max_concurrent_streams 3" +varnish v1 -cliok "param.set h2_max_concurrent_streams 2" varnish v1 -vcl+backend { import vtc; From nils.goroll at uplex.de Thu Feb 21 16:04:08 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Thu, 21 Feb 2019 16:04:08 +0000 (UTC) Subject: [master] cfbe88a10 fix vmodtool boilerplate for -o Message-ID: <20190221160408.ABAD764A8F@lists.varnish-cache.org> commit cfbe88a10c3f92bb26c2d688b10ae1a228e9db7a Author: Nils Goroll Date: Thu Feb 21 17:01:11 2019 +0100 fix vmodtool boilerplate for -o Fixes #2914 diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py index bbde1ca98..6cf6fdfaa 100755 --- a/lib/libvcc/vmodtool.py +++ b/lib/libvcc/vmodtool.py @@ -71,18 +71,18 @@ libvmod_XXX_la_LDFLAGS = \\ \t$(VMOD_LDFLAGS) \\ \t at SAN_LDFLAGS@ -nodist_libvmod_XXX_la_SOURCES = vcc_if.c vcc_if.h +nodist_libvmod_XXX_la_SOURCES = PFX.c PFX.h -$(libvmod_XXX_la_OBJECTS): vcc_if.h +$(libvmod_XXX_la_OBJECTS): PFX.h -vcc_if.h vmod_XXX.rst vmod_XXX.man.rst: vcc_if.c +PFX.h vmod_XXX.rst vmod_XXX.man.rst: PFX.c -vcc_if.c: $(vmodtool) $(srcdir)/vmod.vcc +PFX.c: $(vmodtool) $(srcdir)/vmod.vcc \t at PYTHON@ $(vmodtool) $(vmodtoolargs) $(srcdir)/vmod.vcc EXTRA_DIST = vmod.vcc automake_boilerplate.am -CLEANFILES = $(builddir)/vcc_if.c $(builddir)/vcc_if.h \\ +CLEANFILES = $(builddir)/PFX.c $(builddir)/PFX.h \\ \t$(builddir)/vmod_XXX.rst \\ \t$(builddir)/vmod_XXX.man.rst @@ -952,7 +952,8 @@ class vcc(object): def amboilerplate(self): ''' Produce boilplate for autocrap tools ''' fo = self.openfile("automake_boilerplate.am") - fo.write(AMBOILERPLATE.replace("XXX", self.modname)) + fo.write(AMBOILERPLATE.replace("XXX", self.modname) + .replace("PFX", self.pfx)) fo.close() def mkdefs(self, fo): From nils.goroll at uplex.de Thu Feb 21 17:09:06 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Thu, 21 Feb 2019 17:09:06 +0000 (UTC) Subject: [master] c72674662 fix between bytes timeout vs total timeout Message-ID: <20190221170906.E724E6E0B4@lists.varnish-cache.org> commit c726746621f7b87a069fdc0ca83bef82b4cefd5b Author: Nils Goroll Date: Thu Feb 21 17:59:51 2019 +0100 fix between bytes timeout vs total timeout On the client side, we impose a total timeout, yet on the client side we use between_bytes_timeout and do not care about the total (<- we might want to reconsider this). Yet HTC_RxStuff only implemented a total timeout, for which we effectively used first_byte_timeout + between_bytes_timeout. Yet if first_byte_timeout was not used up, the effective timeout between bytes could be substantially longer than between_bytes_timeout (initially analyzed by @daghf). We now add a duration argument td to HTC_RxStuff which will be used in addition to (or instead of) the existing total timeout tn. Either td or tn must be given. Testcase originally by @fgsch, slightly modified to avoid an assertion failure in vtc_server due to the connection being closed by varnish. Fixes #2395 diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c index bf3fd14ff..259110d7b 100644 --- a/bin/varnishd/cache/cache_session.c +++ b/bin/varnishd/cache/cache_session.c @@ -247,12 +247,14 @@ HTC_RxPipeline(struct http_conn *htc, void *p) * *t1 becomes time of first non-idle rx * *t2 becomes time of complete rx * ti is when we return IDLE if nothing has arrived - * tn is when we timeout on non-complete + * tn is when we timeout on non-complete (total timeout) + * td is max timeout between reads */ enum htc_status_e HTC_RxStuff(struct http_conn *htc, htc_complete_f *func, - vtim_real *t1, vtim_real *t2, vtim_real ti, vtim_real tn, int maxbytes) + vtim_real *t1, vtim_real *t2, vtim_real ti, vtim_real tn, vtim_dur td, + int maxbytes) { vtim_dur tmo; vtim_real now; @@ -267,7 +269,7 @@ HTC_RxStuff(struct http_conn *htc, htc_complete_f *func, assert(htc->rxbuf_b <= htc->rxbuf_e); assert(htc->rxbuf_e <= htc->ws->r); - AZ(isnan(tn)); + AZ(isnan(tn) && isnan(td)); if (t1 != NULL) assert(isnan(*t1)); @@ -309,9 +311,18 @@ HTC_RxStuff(struct http_conn *htc, htc_complete_f *func, else WRONG("htc_status_e"); - tmo = tn - now; - if (!isnan(ti) && ti < tn && hs == HTC_S_EMPTY) + if (hs == HTC_S_EMPTY && !isnan(ti) && (isnan(tn) || ti < tn)) tmo = ti - now; + else if (isnan(tn)) + tmo = td; + else if (isnan(td)) + tmo = tn - now; + else if (td < tn - now) + tmo = td; + else + tmo = tn - now; + + AZ(isnan(tmo)); z = maxbytes - (htc->rxbuf_e - htc->rxbuf_b); if (z <= 0) { /* maxbytes reached but not HTC_S_COMPLETE. Return @@ -328,14 +339,11 @@ HTC_RxStuff(struct http_conn *htc, htc_complete_f *func, } else if (z > 0) htc->rxbuf_e += z; else if (z == -2) { - if (hs == HTC_S_EMPTY && ti <= now) { - WS_ReleaseP(htc->ws, htc->rxbuf_b); + WS_ReleaseP(htc->ws, htc->rxbuf_b); + if (hs == HTC_S_EMPTY) return (HTC_S_IDLE); - } - if (tn <= now) { - WS_ReleaseP(htc->ws, htc->rxbuf_b); + else return (HTC_S_TIMEOUT); - } } } } diff --git a/bin/varnishd/cache/cache_varnishd.h b/bin/varnishd/cache/cache_varnishd.h index 2fdd427ba..2aab94ab7 100644 --- a/bin/varnishd/cache/cache_varnishd.h +++ b/bin/varnishd/cache/cache_varnishd.h @@ -342,7 +342,8 @@ const char * HTC_Status(enum htc_status_e); void HTC_RxInit(struct http_conn *htc, struct ws *ws); void HTC_RxPipeline(struct http_conn *htc, void *); enum htc_status_e HTC_RxStuff(struct http_conn *, htc_complete_f *, - vtim_real *t1, vtim_real *t2, vtim_real ti, vtim_real tn, int maxbytes); + vtim_real *t1, vtim_real *t2, vtim_real ti, vtim_real tn, vtim_dur td, + int maxbytes); #define SESS_ATTR(UP, low, typ, len) \ int SES_Set_##low(const struct sess *sp, const typ *src); \ diff --git a/bin/varnishd/http1/cache_http1_fetch.c b/bin/varnishd/http1/cache_http1_fetch.c index fa456a408..f4ee4ebf0 100644 --- a/bin/varnishd/http1/cache_http1_fetch.c +++ b/bin/varnishd/http1/cache_http1_fetch.c @@ -178,7 +178,7 @@ V1F_FetchRespHdr(struct busyobj *bo) t = VTIM_real() + htc->first_byte_timeout; hs = HTC_RxStuff(htc, HTTP1_Complete, NULL, NULL, - t, t + htc->between_bytes_timeout, cache_param->http_resp_size); + t, NAN, htc->between_bytes_timeout, cache_param->http_resp_size); if (hs != HTC_S_COMPLETE) { bo->acct.beresp_hdrbytes += htc->rxbuf_e - htc->rxbuf_b; diff --git a/bin/varnishd/http1/cache_http1_fsm.c b/bin/varnishd/http1/cache_http1_fsm.c index 14b36d4d2..c2386dcb1 100644 --- a/bin/varnishd/http1/cache_http1_fsm.c +++ b/bin/varnishd/http1/cache_http1_fsm.c @@ -332,6 +332,7 @@ HTTP1_Session(struct worker *wrk, struct req *req) &req->t_first, &req->t_req, sp->t_idle + cache_param->timeout_linger, sp->t_idle + cache_param->timeout_idle, + NAN, cache_param->http_req_size); AZ(req->htc->ws->r); if (hs < HTC_S_EMPTY) { diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index bb2de4cf4..e824eadb8 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -1080,7 +1080,7 @@ h2_rxframe(struct worker *wrk, struct h2_sess *h2) h2->sess->t_idle = VTIM_real(); hs = HTC_RxStuff(h2->htc, h2_frame_complete, NULL, NULL, NAN, - h2->sess->t_idle + cache_param->timeout_idle, + h2->sess->t_idle + cache_param->timeout_idle, NAN, h2->local_settings.max_frame_size + 9); switch (hs) { case HTC_S_COMPLETE: diff --git a/bin/varnishd/http2/cache_http2_session.c b/bin/varnishd/http2/cache_http2_session.c index eee053931..ed73f5f31 100644 --- a/bin/varnishd/http2/cache_http2_session.c +++ b/bin/varnishd/http2/cache_http2_session.c @@ -291,7 +291,7 @@ h2_ou_session(struct worker *wrk, struct h2_sess *h2, /* Wait for PRISM response */ hs = HTC_RxStuff(h2->htc, H2_prism_complete, - NULL, NULL, NAN, h2->sess->t_idle + cache_param->timeout_idle, + NULL, NULL, NAN, h2->sess->t_idle + cache_param->timeout_idle, NAN, sizeof H2_prism); if (hs != HTC_S_COMPLETE) { VSLb(h2->vsl, SLT_Debug, "H2: No/Bad OU PRISM (hs=%d)", hs); diff --git a/bin/varnishd/proxy/cache_proxy_proto.c b/bin/varnishd/proxy/cache_proxy_proto.c index fc4c451b3..86fc2f97d 100644 --- a/bin/varnishd/proxy/cache_proxy_proto.c +++ b/bin/varnishd/proxy/cache_proxy_proto.c @@ -554,7 +554,7 @@ vpx_new_session(struct worker *wrk, void *arg) HTC_RxInit(req->htc, req->ws); hs = HTC_RxStuff(req->htc, vpx_complete, - NULL, NULL, NAN, sp->t_idle + cache_param->timeout_idle, + NULL, NULL, NAN, sp->t_idle + cache_param->timeout_idle, NAN, 1024); // XXX ? if (hs != HTC_S_COMPLETE) { Req_Release(req); diff --git a/bin/varnishtest/tests/r02395.vtc b/bin/varnishtest/tests/r02395.vtc new file mode 100644 index 000000000..99461e16c --- /dev/null +++ b/bin/varnishtest/tests/r02395.vtc @@ -0,0 +1,22 @@ +varnishtest "Test between_bytes_timeout works fetching headers" + +server s1 { + rxreq + send "HTTP/1.0 " + delay 2 +} -start + +varnish v1 -vcl+backend { + sub vcl_recv { return (pass); } + sub vcl_backend_fetch { set bereq.between_bytes_timeout = 1s; } +} -start + +varnish v1 -cliok "param.set debug +syncvsl" + +client c1 { + txreq + rxresp + expect resp.status == 503 +} -run + +server s1 -wait From nils.goroll at uplex.de Thu Feb 21 17:10:34 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Thu, 21 Feb 2019 18:10:34 +0100 Subject: [master] c72674662 fix between bytes timeout vs total timeout In-Reply-To: <20190221170906.E724E6E0B4@lists.varnish-cache.org> References: <20190221170906.E724E6E0B4@lists.varnish-cache.org> Message-ID: <3212d8ce-9eff-416b-3001-f5c1e2260ec2@uplex.de> Apologies for the error in the commit message, the first sentence should have read: > On the client side, we impose a total timeout, yet on the *backend* side ... -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 488 bytes Desc: OpenPGP digital signature URL: From dridi at varni.sh Thu Feb 21 17:13:36 2019 From: dridi at varni.sh (Dridi Boukelmoune) Date: Thu, 21 Feb 2019 18:13:36 +0100 Subject: [master] c72674662 fix between bytes timeout vs total timeout In-Reply-To: <3212d8ce-9eff-416b-3001-f5c1e2260ec2@uplex.de> References: <20190221170906.E724E6E0B4@lists.varnish-cache.org> <3212d8ce-9eff-416b-3001-f5c1e2260ec2@uplex.de> Message-ID: On Thu, Feb 21, 2019 at 6:10 PM Nils Goroll wrote: > > Apologies for the error in the commit message, the first sentence should have read: > > > On the client side, we impose a total timeout, yet on the *backend* side ... Does this mean the client side total timeout applies to bgfetch too? Dridi From nils.goroll at uplex.de Thu Feb 21 17:34:30 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Thu, 21 Feb 2019 18:34:30 +0100 Subject: [master] c72674662 fix between bytes timeout vs total timeout In-Reply-To: References: <20190221170906.E724E6E0B4@lists.varnish-cache.org> <3212d8ce-9eff-416b-3001-f5c1e2260ec2@uplex.de> Message-ID: <3275562b-ef92-8b84-dd6c-c276117b2e6c@uplex.de> On 21/02/2019 18:13, Dridi Boukelmoune wrote: > Does this mean the client side total timeout applies to bgfetch too? No, that's the NAN argument here: diff --git a/bin/varnishd/http1/cache_http1_fetch.c b/bin/varnishd/http1/cache_http1_fetch.c index fa456a408..f4ee4ebf0 100644 --- a/bin/varnishd/http1/cache_http1_fetch.c +++ b/bin/varnishd/http1/cache_http1_fetch.c @@ -178,7 +178,7 @@ V1F_FetchRespHdr(struct busyobj *bo) t = VTIM_real() + htc->first_byte_timeout; hs = HTC_RxStuff(htc, HTTP1_Complete, NULL, NULL, - t, t + htc->between_bytes_timeout, cache_param->http_resp_size); + t, NAN, htc->between_bytes_timeout, cache_param->http_resp_size); if (hs != HTC_S_COMPLETE) { bo->acct.beresp_hdrbytes += htc->rxbuf_e - htc->rxbuf_b; -- ** * * UPLEX - Nils Goroll Systemoptimierung Scheffelstra?e 32 22301 Hamburg tel +49 40 28805731 mob +49 170 2723133 fax +49 40 42949753 xmpp://slink at jabber.int.uplex.de/ http://uplex.de/ -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 488 bytes Desc: OpenPGP digital signature URL: From dridi at varni.sh Thu Feb 21 17:35:20 2019 From: dridi at varni.sh (Dridi Boukelmoune) Date: Thu, 21 Feb 2019 18:35:20 +0100 Subject: [master] c72674662 fix between bytes timeout vs total timeout In-Reply-To: <3275562b-ef92-8b84-dd6c-c276117b2e6c@uplex.de> References: <20190221170906.E724E6E0B4@lists.varnish-cache.org> <3212d8ce-9eff-416b-3001-f5c1e2260ec2@uplex.de> <3275562b-ef92-8b84-dd6c-c276117b2e6c@uplex.de> Message-ID: On Thu, Feb 21, 2019 at 6:34 PM Nils Goroll wrote: > > On 21/02/2019 18:13, Dridi Boukelmoune wrote: > > Does this mean the client side total timeout applies to bgfetch too? > > No, that's the NAN argument here: Cool, I missed it, thanks! Dridi From phk at FreeBSD.org Fri Feb 22 07:54:07 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 22 Feb 2019 07:54:07 +0000 (UTC) Subject: [master] cda192100 We cannot trust the mailcall to be empty just because we got the mutex, for instance the VFP might have nipped out for more storage. Message-ID: <20190222075407.B580310F75C@lists.varnish-cache.org> commit cda1921004f10d3a56e6e044426473d99c88fa56 Author: Poul-Henning Kamp Date: Fri Feb 22 07:47:49 2019 +0000 We cannot trust the mailcall to be empty just because we got the mutex, for instance the VFP might have nipped out for more storage. Fixes: #2572 diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index e824eadb8..b7c319102 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -755,6 +755,8 @@ h2_rx_data(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) return (H2SE_STREAM_CLOSED); // rfc7540,l,1766,1769 } Lck_Lock(&h2->sess->mtx); + while (h2->mailcall != NULL && h2->error == 0 && r2->error == 0) + AZ(Lck_CondWait(h2->cond, &h2->sess->mtx, 0)); AZ(h2->mailcall); h2->mailcall = r2; h2->req0->r_window -= h2->rxf_len; From phk at FreeBSD.org Fri Feb 22 09:07:06 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 22 Feb 2019 09:07:06 +0000 (UTC) Subject: [master] f36328435 Make it explicit that vcl.discard are not allowed to fail in the child process. Message-ID: <20190222090706.EECFE110BFD@lists.varnish-cache.org> commit f3632843589a0d5095f60cec2ed1589268f59b86 Author: Poul-Henning Kamp Date: Fri Feb 22 09:05:40 2019 +0000 Make it explicit that vcl.discard are not allowed to fail in the child process. Inspired by: #2471 diff --git a/bin/varnishd/mgt/mgt_vcl.c b/bin/varnishd/mgt/mgt_vcl.c index d9773c78f..28fc35579 100644 --- a/bin/varnishd/mgt/mgt_vcl.c +++ b/bin/varnishd/mgt/mgt_vcl.c @@ -784,9 +784,9 @@ mcf_vcl_discard(struct cli *cli, const char * const *av, void *priv) else (void)mgt_vcl_setstate(cli, vp, VCL_STATE_COLD); if (MCH_Running()) { - /* XXX If this fails the child is crashing, figure that later */ assert(vp->state != VCL_STATE_WARM); - (void)mgt_cli_askchild(&status, &p, "vcl.discard %s\n", av[2]); + if (mgt_cli_askchild(&status, &p, "vcl.discard %s\n", av[2])) + assert(status == CLIS_OK || status == CLIS_COMMS); free(p); } mgt_vcl_del(vp); From phk at FreeBSD.org Fri Feb 22 10:06:06 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 22 Feb 2019 10:06:06 +0000 (UTC) Subject: [master] dd45b5496 The vsc and vsc_seg variables are global to the VMOD, rather than per-VCL, so cleanup should only happen on the last discard event. Message-ID: <20190222100606.D155D111D26@lists.varnish-cache.org> commit dd45b5496ccbb95136e47d327c29c2accae34563 Author: Poul-Henning Kamp Date: Fri Feb 22 10:02:58 2019 +0000 The vsc and vsc_seg variables are global to the VMOD, rather than per-VCL, so cleanup should only happen on the last discard event. This brought confusion to #2576, and while that ticket is probably easier to debug if the counters were per-vcl, I think it is important to keep the "per-vmod" behaviour around as an example. diff --git a/lib/libvmod_debug/vmod_debug.c b/lib/libvmod_debug/vmod_debug.c index c62b3e85e..fa05142b6 100644 --- a/lib/libvmod_debug/vmod_debug.c +++ b/lib/libvmod_debug/vmod_debug.c @@ -56,6 +56,7 @@ static VCL_DURATION vcl_release_delay = 0.0; static pthread_mutex_t vsc_mtx = PTHREAD_MUTEX_INITIALIZER; static struct vsc_seg *vsc_seg = NULL; static struct VSC_debug *vsc = NULL; +static int loads; /**********************************************************************/ @@ -284,6 +285,9 @@ event_load(VRT_CTX, struct vmod_priv *priv) struct priv_vcl *priv_vcl; AN(ctx->msg); + + loads++; + if (cache_param->nuke_limit == 42) { VSB_printf(ctx->msg, "nuke_limit is not the answer."); return (-1); @@ -370,19 +374,38 @@ event_cold(VRT_CTX, const struct vmod_priv *priv) return (0); } +static int +event_discard(VRT_CTX, void *priv) +{ + + (void)priv; + + VRT_RemoveVFP(ctx, &xyzzy_rot13); + + if (--loads) + return(0); + + /* + * The vsc and vsc_seg variables are not per-VCL, they are + * the same in all VCL's which import the same binary version + * of this VMOD, so we should only carry out cleanup on the + * last discard event. + */ + if (vsc) + VSC_debug_Destroy(&vsc_seg); + + return(0); +} + int v_matchproto_(vmod_event_f) xyzzy_event_function(VRT_CTX, struct vmod_priv *priv, enum vcl_event_e e) { switch (e) { - case VCL_EVENT_LOAD: return (event_load(ctx, priv)); - case VCL_EVENT_WARM: return (event_warm(ctx, priv)); - case VCL_EVENT_COLD: return (event_cold(ctx, priv)); - case VCL_EVENT_DISCARD: - VRT_RemoveVFP(ctx, &xyzzy_rot13); - if (vsc) - VSC_debug_Destroy(&vsc_seg); - return (0); + case VCL_EVENT_LOAD: return (event_load(ctx, priv)); + case VCL_EVENT_WARM: return (event_warm(ctx, priv)); + case VCL_EVENT_COLD: return (event_cold(ctx, priv)); + case VCL_EVENT_DISCARD: return (event_discard(ctx, priv)); default: return (0); } } From nils.goroll at uplex.de Fri Feb 22 10:38:07 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Fri, 22 Feb 2019 10:38:07 +0000 (UTC) Subject: [master] f52ce7344 polish Message-ID: <20190222103807.5409C1126F1@lists.varnish-cache.org> commit f52ce7344c5fd4547dd28d98820a4c6111494af6 Author: Nils Goroll Date: Fri Feb 22 11:24:31 2019 +0100 polish diff --git a/bin/varnishtest/vtc_http.c b/bin/varnishtest/vtc_http.c index 0c136cfd1..57da440de 100644 --- a/bin/varnishtest/vtc_http.c +++ b/bin/varnishtest/vtc_http.c @@ -594,17 +594,16 @@ static void http_swallow_body(struct http *hp, char * const *hh, int body) { char *p; - int i, l, ll; + int i, l; - ll = 0; p = http_find_header(hh, "transfer-encoding"); if (p != NULL && !strcasecmp(p, "chunked")) { while (http_rxchunk(hp) > 0) continue; - vtc_dump(hp->vl, 4, "body", hp->body, ll); - ll = hp->rxbuf + hp->prxbuf - hp->body; - hp->bodyl = ll; - bprintf(hp->bodylen, "%d", ll); + l = hp->rxbuf + hp->prxbuf - hp->body; + vtc_dump(hp->vl, 4, "body", hp->body, l); + hp->bodyl = l; + bprintf(hp->bodylen, "%d", l); return; } p = http_find_header(hh, "content-length"); @@ -617,17 +616,18 @@ http_swallow_body(struct http *hp, char * const *hh, int body) bprintf(hp->bodylen, "%d", l); return; } + l = 0; if (body) { do { i = http_rxchar(hp, 1, 1); if (i < 0) return; - ll += i; + l += i; } while (i > 0); - vtc_dump(hp->vl, 4, "rxeof", hp->body, ll); + vtc_dump(hp->vl, 4, "rxeof", hp->body, l); } - hp->bodyl = ll; - bprintf(hp->bodylen, "%d", ll); + hp->bodyl = l; + bprintf(hp->bodylen, "%d", l); } /********************************************************************** @@ -1764,7 +1764,7 @@ cmd_http_settings(CMD_ARGS) static void cmd_http_stream(CMD_ARGS) { - struct http *hp = (struct http *)priv; + struct http *hp; CAST_OBJ_NOTNULL(hp, priv, HTTP_MAGIC); if (!hp->h2) { vtc_log(hp->vl, 4, "Not in H/2 mode, do what's needed"); From hermunn at varnish-software.com Fri Feb 22 10:40:10 2019 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 22 Feb 2019 10:40:10 +0000 (UTC) Subject: [4.1] 7c7fbbd59 Remove incorrect changelog line: cache_hit_grace Message-ID: <20190222104010.2D4BA1128A9@lists.varnish-cache.org> commit 7c7fbbd590f6c51288bc2aefc7fade98de890d22 Author: P?l Hermunn Johansen Date: Fri Feb 22 11:39:20 2019 +0100 Remove incorrect changelog line: cache_hit_grace It was added in 4.1.10, not in 4.1.11 diff --git a/doc/changes.rst b/doc/changes.rst index 82a615b2d..01645691c 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -18,7 +18,6 @@ Bugs fixed * Panic on return (retry) of a conditional fetch (2700_) * Set the task arguments under the lock (2719_) * Stabilize the test case b000064.vtc for real (2751_) -* New counter added: cache_hit_grace (2831_) .. _2661: https://github.com/varnishcache/varnish-cache/issues/2661 .. _2681: https://github.com/varnishcache/varnish-cache/issues/2681 @@ -26,7 +25,6 @@ Bugs fixed .. _2700: https://github.com/varnishcache/varnish-cache/issues/2700 .. _2719: https://github.com/varnishcache/varnish-cache/issues/2719 .. _2751: https://github.com/varnishcache/varnish-cache/issues/2751 -.. _2831: https://github.com/varnishcache/varnish-cache/issues/2831 ================================= Varnish Cache 4.1.10 (2018-04-25) From hermunn at varnish-software.com Fri Feb 22 11:02:11 2019 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Fri, 22 Feb 2019 11:02:11 +0000 (UTC) Subject: [4.1] f55f449c8 Add issue 2831 back, now with correct text Message-ID: <20190222110211.99337112FB9@lists.varnish-cache.org> commit f55f449c8b37029040f254c4e914b7522448d791 Author: P?l Hermunn Johansen Date: Fri Feb 22 12:01:03 2019 +0100 Add issue 2831 back, now with correct text diff --git a/doc/changes.rst b/doc/changes.rst index 01645691c..3b17eecf3 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -18,6 +18,7 @@ Bugs fixed * Panic on return (retry) of a conditional fetch (2700_) * Set the task arguments under the lock (2719_) * Stabilize the test case b000064.vtc for real (2751_) +* cache_req_body panics when Transient is full (2831_) .. _2661: https://github.com/varnishcache/varnish-cache/issues/2661 .. _2681: https://github.com/varnishcache/varnish-cache/issues/2681 @@ -25,6 +26,7 @@ Bugs fixed .. _2700: https://github.com/varnishcache/varnish-cache/issues/2700 .. _2719: https://github.com/varnishcache/varnish-cache/issues/2719 .. _2751: https://github.com/varnishcache/varnish-cache/issues/2751 +.. _2831: https://github.com/varnishcache/varnish-cache/issues/2831 ================================= Varnish Cache 4.1.10 (2018-04-25) From nils.goroll at uplex.de Fri Feb 22 13:56:07 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Fri, 22 Feb 2019 13:56:07 +0000 (UTC) Subject: [master] a2c41bf13 teach vtc to read bodies partially Message-ID: <20190222135607.2637D116057@lists.varnish-cache.org> commit a2c41bf1367399c11f45579ade62d992d9fd9786 Author: Nils Goroll Date: Fri Feb 22 13:41:50 2019 +0100 teach vtc to read bodies partially also polished http_swallow_body() and made the body dump prefix name more consistent to indicate the receive method: (new) (old) chunked body c-l body eof rxeof diff --git a/bin/varnishtest/tests/a00019.vtc b/bin/varnishtest/tests/a00019.vtc new file mode 100644 index 000000000..28ab15466 --- /dev/null +++ b/bin/varnishtest/tests/a00019.vtc @@ -0,0 +1,64 @@ +varnishtest "Check rxrespbody -max" + +server s1 { + rxreq + txresp -bodylen 65536 + rxreq + txresp +} -start + +server s2 { + rxreq + txresp -nolen -hdr "Transfer-Encoding: chunked" + chunkedlen 8192 + chunkedlen 4096 + chunkedlen 4096 + chunkedlen 16384 + chunkedlen 16384 + chunkedlen 16384 + chunkedlen 0 + rxreq + txresp +} -start + +server s3 { + rxreq + txresp -nolen -bodylen 65536 +} -start + +client c1 -connect ${s1_sock} { + txreq + rxresphdrs + rxrespbody -max 8192 + expect resp.bodylen == 8192 + rxrespbody -max 8192 + expect resp.bodylen == 16384 + rxrespbody + expect resp.bodylen == 65536 + txreq + rxresp +} -run + +client c2 -connect ${s2_sock} { + txreq + rxresphdrs + rxrespbody -max 8192 + expect resp.bodylen == 8192 + rxrespbody -max 8192 + expect resp.bodylen == 16384 + rxrespbody + expect resp.bodylen == 65536 + txreq + rxresp +} -run + +client c3 -connect ${s3_sock} { + txreq + rxresphdrs + rxrespbody -max 8192 + expect resp.bodylen == 8192 + rxrespbody -max 8192 + expect resp.bodylen == 16384 + rxrespbody + expect resp.bodylen == 65536 +} -run diff --git a/bin/varnishtest/vtc_http.c b/bin/varnishtest/vtc_http.c index 57da440de..0861aa091 100644 --- a/bin/varnishtest/vtc_http.c +++ b/bin/varnishtest/vtc_http.c @@ -588,44 +588,54 @@ http_rxchunk(struct http *hp) /********************************************************************** * Swallow a HTTP message body + * + * max: 0 is all */ static void -http_swallow_body(struct http *hp, char * const *hh, int body) +http_swallow_body(struct http *hp, char * const *hh, int body, int max) { - char *p; - int i, l; + const char *p; + int i, l, ll; + + l = hp->rxbuf + hp->prxbuf - hp->body; p = http_find_header(hh, "transfer-encoding"); if (p != NULL && !strcasecmp(p, "chunked")) { - while (http_rxchunk(hp) > 0) - continue; - l = hp->rxbuf + hp->prxbuf - hp->body; - vtc_dump(hp->vl, 4, "body", hp->body, l); - hp->bodyl = l; - bprintf(hp->bodylen, "%d", l); - return; - } - p = http_find_header(hh, "content-length"); - if (p != NULL) { - l = strtoul(p, NULL, 10); - if (http_rxchar(hp, l, 0) < 0) + ll = 0; + while (http_rxchunk(hp) > 0) { + ll = hp->rxbuf + hp->prxbuf - hp->body - l; + if (max && ll >= max) + break; + } + p = "chunked"; + } else if ((p = http_find_header(hh, "content-length"))) { + ll = strtoul(p, NULL, 10); + if (max && ll > l + max) + ll = max; + else + ll -= l; + i = http_rxchar(hp, ll, 0); + if (i < 0) return; - vtc_dump(hp->vl, 4, "body", hp->body, l); - hp->bodyl = l; - bprintf(hp->bodylen, "%d", l); - return; - } - l = 0; - if (body) { + p = "c-l"; + } else if (body) { + ll = 0; do { i = http_rxchar(hp, 1, 1); if (i < 0) return; - l += i; + ll += i; + if (max && ll >= max) + break; } while (i > 0); - vtc_dump(hp->vl, 4, "rxeof", hp->body, l); + p = "eof"; + } else { + p = "none"; + ll = l = 0; } + vtc_dump(hp->vl, 4, p, hp->body + l, ll); + l += ll; hp->bodyl = l; bprintf(hp->bodylen, "%d", l); } @@ -699,9 +709,9 @@ cmd_http_rxresp(CMD_ARGS) if (!has_obj) return; else if (!strcmp(hp->resp[1], "200")) - http_swallow_body(hp, hp->resp, 1); + http_swallow_body(hp, hp->resp, 1, 0); else - http_swallow_body(hp, hp->resp, 0); + http_swallow_body(hp, hp->resp, 0, 0); vtc_log(hp->vl, 4, "bodylen = %s", hp->bodylen); } @@ -1128,7 +1138,7 @@ cmd_http_rxreq(CMD_ARGS) http_splitheader(hp, 1); if (http_count_header(hp->req, "Content-Length") > 1) vtc_fatal(vl, "Multiple Content-Length headers.\n"); - http_swallow_body(hp, hp->req, 0); + http_swallow_body(hp, hp->req, 0, 0); vtc_log(vl, 4, "bodylen = %s", hp->bodylen); } @@ -1177,20 +1187,23 @@ cmd_http_rxreqbody(CMD_ARGS) for (; *av != NULL; av++) vtc_fatal(hp->vl, "Unknown http rxreq spec: %s\n", *av); - http_swallow_body(hp, hp->req, 0); + http_swallow_body(hp, hp->req, 0, 0); vtc_log(hp->vl, 4, "bodylen = %s", hp->bodylen); } /* SECTION: client-server.spec.rxrespbody * * rxrespbody (client only) - * Receive a response's body. + * Receive (part of) a response's body. + * + * -max : max length of this receive, 0 for all */ static void cmd_http_rxrespbody(CMD_ARGS) { struct http *hp; + int max = 0; (void)cmd; (void)vl; @@ -1200,8 +1213,14 @@ cmd_http_rxrespbody(CMD_ARGS) av++; for (; *av != NULL; av++) - vtc_fatal(hp->vl, "Unknown http rxrespbody spec: %s\n", *av); - http_swallow_body(hp, hp->resp, 0); + if (!strcmp(*av, "-max")) { + max = atoi(av[1]); + av++; + } else + vtc_fatal(hp->vl, + "Unknown http rxrespbody spec: %s\n", *av); + + http_swallow_body(hp, hp->resp, 1, max); vtc_log(hp->vl, 4, "bodylen = %s", hp->bodylen); } From nils.goroll at uplex.de Fri Feb 22 13:56:07 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Fri, 22 Feb 2019 13:56:07 +0000 (UTC) Subject: [master] 08403b1dd Incremental freeing of storage for hfm/hpf and proper vtc Message-ID: <20190222135607.3AAA611605A@lists.varnish-cache.org> commit 08403b1dd03d392c22713b9b9c72e51235f95caf Author: Nils Goroll Date: Fri Feb 22 14:53:50 2019 +0100 Incremental freeing of storage for hfm/hpf and proper vtc Previously, we did not test for the storage being actually freed and freeing only happened for passes, either explicit or a hit on hfm or hfp, but not the for the object becoming the hfm/hfp. We now handle incremental freeing for hfm/hfp as for private objects and add a test which actually checks that storage is being freed on the go. Fixes #2653 diff --git a/bin/varnishd/cache/cache_deliver_proc.c b/bin/varnishd/cache/cache_deliver_proc.c index c956c93a0..1bd65a66c 100644 --- a/bin/varnishd/cache/cache_deliver_proc.c +++ b/bin/varnishd/cache/cache_deliver_proc.c @@ -150,11 +150,12 @@ vdp_objiterator(void *priv, unsigned flush, const void *ptr, ssize_t len) int VDP_DeliverObj(struct req *req) { - int r; + int r, final; CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - r = ObjIterate(req->wrk, req->objcore, req, vdp_objiterator, - req->objcore->flags & OC_F_PRIVATE ? 1 : 0); + final = req->objcore->flags & (OC_F_PRIVATE | OC_F_HFM | OC_F_HFP) + ? 1 : 0; + r = ObjIterate(req->wrk, req->objcore, req, vdp_objiterator, final); if (r < 0) return (r); return (0); diff --git a/bin/varnishtest/tests/c00075.vtc b/bin/varnishtest/tests/c00075.vtc index 6cafdde62..c671844eb 100644 --- a/bin/varnishtest/tests/c00075.vtc +++ b/bin/varnishtest/tests/c00075.vtc @@ -1,20 +1,148 @@ varnishtest "Test large pass deleted during streaming" +barrier ba1 cond 3 +barrier ba2 cond 2 + +barrier bb1 cond 3 +barrier bb2 cond 2 + +barrier bc1 cond 3 +barrier bc2 cond 2 + +barrier bd1 cond 3 +barrier bd2 cond 2 + server s1 { rxreq - txresp -nolen -hdr "Transfer-Encoding: chunked" - chunkedlen 65536 + expect req.url == "/hfm" + txresp -nolen -hdr "Transfer-Encoding: chunked" \ + -hdr "Cache-Control: no-cache" + chunkedlen 32768 + barrier ba1 sync + chunkedlen 32768 + chunkedlen 0 + + rxreq + expect req.url == "/hfm" + txresp -nolen -hdr "Transfer-Encoding: chunked" \ + -hdr "Cache-Control: no-cache" + chunkedlen 32768 + barrier bb1 sync + chunkedlen 32768 + chunkedlen 0 + + rxreq + expect req.url == "/hfp" + txresp -nolen -hdr "Transfer-Encoding: chunked" \ + -hdr "Cache-Control: no-cache" + chunkedlen 32768 + barrier bc1 sync + chunkedlen 32768 + chunkedlen 0 + + rxreq + expect req.url == "/hfp" + txresp -nolen -hdr "Transfer-Encoding: chunked" \ + -hdr "Cache-Control: no-cache" + chunkedlen 32768 + barrier bd1 sync + chunkedlen 32768 chunkedlen 0 } -start varnish v1 \ - -arg "-s default,1m" -vcl+backend { } -start + -arg "-s default,1m" -vcl+backend { + sub vcl_backend_response { + if (bereq.url == "/hfp") { + return (pass(10m)); + } + } + sub vcl_deliver { + set resp.http.is-hitmiss = req.is_hitmiss; + set resp.http.is-hitpass = req.is_hitpass; + } +} -start -varnish v1 -cliok "debug.fragfetch 1024" +varnish v1 -cliok "debug.fragfetch 8192" client c1 { - txreq -hdr "Cookie: bar" - rxresp + txreq -url "/hfm" + rxresphdrs + rxrespbody -max 8192 + barrier ba1 sync + barrier ba2 sync + rxrespbody expect resp.bodylen == 65536 + expect resp.http.is-hitmiss == false + expect resp.http.is-hitpass == false expect_pattern -} -run +} -start + +barrier ba1 sync +varnish v1 -expect SM?.Transient.g_bytes < 24576 +barrier ba2 sync + +# HFM object +varnish v1 -expect SM?.Transient.g_bytes < 500 + +# pass on the HFM +client c1 { + txreq -url "/hfm" + rxresphdrs + rxrespbody -max 8192 + barrier bb1 sync + barrier bb2 sync + rxrespbody + expect resp.bodylen == 65536 + expect resp.http.is-hitmiss == true + expect resp.http.is-hitpass == false + expect_pattern +} -start + +barrier bb1 sync +varnish v1 -expect SM?.Transient.g_bytes < 24576 +barrier bb2 sync + +client c1 -wait + +## hfp + +client c1 { + txreq -url "/hfp" + rxresphdrs + rxrespbody -max 8192 + barrier bc1 sync + barrier bc2 sync + rxrespbody + expect resp.bodylen == 65536 + expect resp.http.is-hitmiss == false + expect resp.http.is-hitpass == false + expect_pattern +} -start + +barrier bc1 sync +varnish v1 -expect SM?.Transient.g_bytes < 24576 +barrier bc2 sync + +# HFM object +varnish v1 -expect SM?.Transient.g_bytes < 500 + +# pass on the HFM +client c1 { + txreq -url "/hfp" + rxresphdrs + rxrespbody -max 8192 + barrier bd1 sync + barrier bd2 sync + rxrespbody + expect resp.bodylen == 65536 + expect resp.http.is-hitmiss == false + expect resp.http.is-hitpass == true + expect_pattern +} -start + +barrier bd1 sync +varnish v1 -expect SM?.Transient.g_bytes < 24576 +barrier bd2 sync + +client c1 -wait From nils.goroll at uplex.de Fri Feb 22 14:03:07 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Fri, 22 Feb 2019 14:03:07 +0000 (UTC) Subject: [master] 97ef14c8d polish vtc from previous commit Message-ID: <20190222140307.888A31164EF@lists.varnish-cache.org> commit 97ef14c8dc7c7866dd1d1c8e61d5d49d879024f4 Author: Nils Goroll Date: Fri Feb 22 15:01:38 2019 +0100 polish vtc from previous commit things I seem to only notice in my email reader... diff --git a/bin/varnishtest/tests/c00075.vtc b/bin/varnishtest/tests/c00075.vtc index c671844eb..6caacbfaa 100644 --- a/bin/varnishtest/tests/c00075.vtc +++ b/bin/varnishtest/tests/c00075.vtc @@ -82,6 +82,8 @@ barrier ba1 sync varnish v1 -expect SM?.Transient.g_bytes < 24576 barrier ba2 sync +client c1 -wait + # HFM object varnish v1 -expect SM?.Transient.g_bytes < 500 @@ -105,7 +107,10 @@ barrier bb2 sync client c1 -wait -## hfp +# HFM object +varnish v1 -expect SM?.Transient.g_bytes < 500 + +##### hfp client c1 { txreq -url "/hfp" @@ -124,10 +129,12 @@ barrier bc1 sync varnish v1 -expect SM?.Transient.g_bytes < 24576 barrier bc2 sync -# HFM object -varnish v1 -expect SM?.Transient.g_bytes < 500 +client c1 -wait -# pass on the HFM +# HFM + HFP object +varnish v1 -expect SM?.Transient.g_bytes < 1000 + +# pass on the HFP client c1 { txreq -url "/hfp" rxresphdrs @@ -146,3 +153,6 @@ varnish v1 -expect SM?.Transient.g_bytes < 24576 barrier bd2 sync client c1 -wait + +# HFM + HFP object +varnish v1 -expect SM?.Transient.g_bytes < 1000 From nils.goroll at uplex.de Sat Feb 23 11:50:08 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Sat, 23 Feb 2019 11:50:08 +0000 (UTC) Subject: [master] 8aa77803c Illustrate directors.shard_param() use Message-ID: <20190223115008.14D5E10AAE5@lists.varnish-cache.org> commit 8aa77803ce10bcfc440fcee426eb4cbba8778e80 Author: Nils Goroll Date: Sat Feb 23 12:49:22 2019 +0100 Illustrate directors.shard_param() use diff --git a/lib/libvmod_directors/vmod.vcc b/lib/libvmod_directors/vmod.vcc index 71ec5be1b..1727f1f67 100644 --- a/lib/libvmod_directors/vmod.vcc +++ b/lib/libvmod_directors/vmod.vcc @@ -349,10 +349,12 @@ Set the default rampup duration. See `rampup` parameter of $Method VOID .associate(BLOB param=0) -Associate a default `vmod_directors.shard_param`_ object or clear an association. +Associate a default `vmod_directors.shard_param`_ object or clear an +association. The value of the `param` argument must be a call to the -`vmod_directors.shard_param.use`_ method. No argument clears the association. +`vmod_directors.shard_param.use`_ method. No argument clears the +association. The association can be changed per backend request using the `param` argument of `vmod_directors.shard.backend`_. @@ -567,10 +569,10 @@ $Object shard_param() Create a shard parameter set. -A parameter set allows for re-use of `vmod_directors.shard.backend`_ arguments -across many shard director instances and simplifies advanced use cases -(e.g. shard director with custom parameters layered below other -directors). +A parameter set allows for re-use of `vmod_directors.shard.backend`_ +arguments across many shard director instances and simplifies advanced +use cases (e.g. shard director with custom parameters layered below +other directors). Parameter sets have two scopes: @@ -583,6 +585,38 @@ respective backend request. Parameter sets can not be used in client context. +The following example is a typical use case: A parameter set is +associated with several directors. Director choice happens on the +client side and parameters are changed on the backend side to +implement retries on alternative backends:: + + sub vcl_init { + new shard_param = directors.shard_param(); + + new dir_A = directors.shard(); + dir_A.add_backend(...); + dir_A.reconfigure(shard_param); + dir_A.associate(shard_param.use()); # <-- ! + + new dir_B = directors.shard(); + dir_B.add_backend(...); + dir_B.reconfigure(shard_param); + dir_B.associate(shard_param.use()); # <-- ! + } + + sub vcl_recv { + if (...) { + set req.backend_hint = dir_A.backend(resolve=LAZY); + } else { + set req.backend_hint = dir_B.backend(resolve=LAZY); + } + } + + sub vcl_backend_fetch { + # changes dir_A and dir_B behaviour + shard_param.set(alt=bereq.retries); + } + $Method VOID .clear() Reset the parameter set to default values as documented for From geoff at uplex.de Sat Feb 23 17:26:06 2019 From: geoff at uplex.de (Geoff Simmons) Date: Sat, 23 Feb 2019 17:26:06 +0000 (UTC) Subject: [master] 2fb770ed1 Improve test coverage for VSL query parsing. Message-ID: <20190223172606.28BC2111486@lists.varnish-cache.org> commit 2fb770ed1d4704aeac58e9e44e87c76216f661df Author: Geoff Simmons Date: Sat Feb 23 18:24:55 2019 +0100 Improve test coverage for VSL query parsing. diff --git a/bin/varnishtest/tests/u00006.vtc b/bin/varnishtest/tests/u00006.vtc index b263af36c..ad1b9d3f1 100644 --- a/bin/varnishtest/tests/u00006.vtc +++ b/bin/varnishtest/tests/u00006.vtc @@ -83,6 +83,22 @@ shell -err -expect "Expected integer got ']'" \ {varnishlog -q "ReqHeader:foo[]"} shell -err -expect "Expected positive integer" \ {varnishlog -q "ReqHeader:foo[a]"} +shell -err -expect "Syntax error in tag name" \ + {varnishlog -q '*x* eq "foo"'} +shell -err -expect "Expected number got '>'" \ + {varnishlog -q "RespStatus > >"} +shell -err -expect "Floating point parse error" \ + {varnishlog -q "Timestamp:Start[1] > 0.foo"} +shell -err -expect "Integer parse error" \ + {varnishlog -q "RespStatus > foo"} +shell -err -expect "Expected string got '>'" \ + {varnishlog -q "ReqMethod eq >"} +shell -err -expect "Expected regular expression got '>'" \ + {varnishlog -q "ReqMethod ~ >"} +shell -err -expect "Regular expression error: " \ + {varnishlog -q 'ReqMethod ~ "("'} +shell -err -expect "Expected operator got 'ReqMethod'" \ + {varnishlog -q "RespStatus ReqMethod 200"} shell -err -expect "-R: Syntax error" \ "varnishlog -R 1foo" From geoff at uplex.de Sat Feb 23 17:49:06 2019 From: geoff at uplex.de (Geoff Simmons) Date: Sat, 23 Feb 2019 17:49:06 +0000 (UTC) Subject: [master] fcc229e1e Improve test coverage for VSL binary file reads. Message-ID: <20190223174906.7C00C111B9E@lists.varnish-cache.org> commit fcc229e1ea4855c8129019e791d7b32425a5cf39 Author: Geoff Simmons Date: Sat Feb 23 18:48:20 2019 +0100 Improve test coverage for VSL binary file reads. diff --git a/bin/varnishtest/tests/u00006.vtc b/bin/varnishtest/tests/u00006.vtc index ad1b9d3f1..aef71d393 100644 --- a/bin/varnishtest/tests/u00006.vtc +++ b/bin/varnishtest/tests/u00006.vtc @@ -154,3 +154,13 @@ shell -match {^\*[ ]+<< BeReq\s+>>[ ]+1005[ ]+ -[ ]+BereqURL[ ]+/bar $} \ "varnishlog -r ${tmpdir}/vlog.bin -b -C -I BAR" + +shell -match {^\*[ ]+<< BeReq\s+>>[ ]+1005[ ]+} \ + "cat ${tmpdir}/vlog.bin | varnishlog -r - -b -C -I BAR" + +shell "rm -f ${tmpdir}/foo" +shell -err -expect "Cannot open ${tmpdir}/foo: " \ + "varnishlog -r ${tmpdir}/foo" +shell "echo foobar > ${tmpdir}/foo" +shell -err -expect "Not a VSL file: ${tmpdir}/foo" \ + "varnishlog -r ${tmpdir}/foo" From phk at FreeBSD.org Mon Feb 25 08:30:12 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 25 Feb 2019 08:30:12 +0000 (UTC) Subject: [master] 6473fa9ed Simplify the rxbuffer handling slightly. Message-ID: <20190225083012.AEFBB115B40@lists.varnish-cache.org> commit 6473fa9edbff219dbb8ceecc0a0cd1bc1d8ce3b5 Author: Poul-Henning Kamp Date: Mon Feb 25 08:23:38 2019 +0000 Simplify the rxbuffer handling slightly. diff --git a/bin/varnishtest/vtc_http.c b/bin/varnishtest/vtc_http.c index 0861aa091..fc0512b7c 100644 --- a/bin/varnishtest/vtc_http.c +++ b/bin/varnishtest/vtc_http.c @@ -419,7 +419,7 @@ http_splitheader(struct http *hp, int req) } n = 0; - p = hp->rxbuf; + p = hp->rx_b; if (*p == '\0') { vtc_log(hp->vl, 4, "No headers"); return; @@ -511,8 +511,8 @@ http_rxchar(struct http *hp, int n, int eof) continue; } assert(i > 0); - assert(hp->prxbuf + n < hp->nrxbuf); - i = read(hp->fd, hp->rxbuf + hp->prxbuf, n); + assert(hp->rx_p + n < hp->rx_e); + i = read(hp->fd, hp->rx_p, n); if (!(pfd[0].revents & POLLIN)) vtc_log(hp->vl, 4, "HTTP rx poll (fd:%d revents: %x n=%d, i=%d)", @@ -531,8 +531,8 @@ http_rxchar(struct http *hp, int n, int eof) hp->fd, strerror(errno)); return (-1); } - hp->prxbuf += i; - hp->rxbuf[hp->prxbuf] = '\0'; + hp->rx_p += i; + *hp->rx_p = '\0'; n -= i; } return (1); @@ -541,48 +541,38 @@ http_rxchar(struct http *hp, int n, int eof) static int http_rxchunk(struct http *hp) { - char *q; - int l, i; + char *q, *old; + int i; - l = hp->prxbuf; + old = hp->rx_p; do { if (http_rxchar(hp, 1, 0) < 0) return (-1); - } while (hp->rxbuf[hp->prxbuf - 1] != '\n'); - vtc_dump(hp->vl, 4, "len", hp->rxbuf + l, -1); - i = strtoul(hp->rxbuf + l, &q, 16); + } while (hp->rx_p[-1] != '\n'); + vtc_dump(hp->vl, 4, "len", old, -1); + i = strtoul(old, &q, 16); bprintf(hp->chunklen, "%d", i); - if ((q == hp->rxbuf + l) || - (*q != '\0' && !vct_islws(*q))) { - vtc_log(hp->vl, hp->fatal, "chunked fail %02x @ %td", - *q, q - (hp->rxbuf + l)); + if ((q == old) || (q == hp->rx_p) || (*q != '\0' && !vct_islws(*q))) { + vtc_log(hp->vl, hp->fatal, "Chunklen fail (%02x @ %td)", + (*q & 0xff), q - old); return (-1); } - assert(q != hp->rxbuf + l); assert(*q == '\0' || vct_islws(*q)); - hp->prxbuf = l; + hp->rx_p = old; if (i > 0) { if (http_rxchar(hp, i, 0) < 0) return (-1); - vtc_dump(hp->vl, 4, "chunk", hp->rxbuf + l, i); + vtc_dump(hp->vl, 4, "chunk", old, i); } - l = hp->prxbuf; + old = hp->rx_p; if (http_rxchar(hp, 2, 0) < 0) return (-1); - if (!vct_iscrlf(hp->rxbuf + l)) { - vtc_log(hp->vl, hp->fatal, - "Wrong chunk tail[0] = %02x", - hp->rxbuf[l] & 0xff); - return (-1); - } - if (!vct_iscrlf(hp->rxbuf + l + 1)) { - vtc_log(hp->vl, hp->fatal, - "Wrong chunk tail[1] = %02x", - hp->rxbuf[l + 1] & 0xff); + if (!vct_iscrlf(old)) { + vtc_log(hp->vl, hp->fatal, "Chunklen without CRLF"); return (-1); } - hp->prxbuf = l; - hp->rxbuf[l] = '\0'; + hp->rx_p = old; + *hp->rx_p = '\0'; return (i); } @@ -595,22 +585,27 @@ http_rxchunk(struct http *hp) static void http_swallow_body(struct http *hp, char * const *hh, int body, int max) { - const char *p; + const char *p, *q; int i, l, ll; - l = hp->rxbuf + hp->prxbuf - hp->body; + l = hp->rx_p - hp->body; p = http_find_header(hh, "transfer-encoding"); + q = http_find_header(hh, "content-length"); if (p != NULL && !strcasecmp(p, "chunked")) { + if (q != NULL) { + vtc_log(hp->vl, hp->fatal, "Both C-E: Chunked and C-L"); + return; + } ll = 0; while (http_rxchunk(hp) > 0) { - ll = hp->rxbuf + hp->prxbuf - hp->body - l; + ll = (hp->rx_p - hp->body) - l; if (max && ll >= max) break; } p = "chunked"; - } else if ((p = http_find_header(hh, "content-length"))) { - ll = strtoul(p, NULL, 10); + } else if (q != NULL) { + ll = strtoul(q, NULL, 10); if (max && ll > l + max) ll = max; else @@ -647,41 +642,44 @@ http_swallow_body(struct http *hp, char * const *hh, int body, int max) static void http_rxhdr(struct http *hp) { - int i, j; + int i, s = 0; char *p; + ssize_t l; CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC); - hp->prxbuf = 0; - hp->rxbuf[0] = '\0'; + hp->rx_p = hp->rx_b; + *hp->rx_p = '\0'; hp->body = NULL; bprintf(hp->bodylen, "%s", ""); while (1) { - j = http_rxchar(hp, 1, 1); - p = hp->rxbuf + hp->prxbuf - 1; - for (i = 0; p > hp->rxbuf; p--) { - if (*p != '\n') - break; - if (p - 1 > hp->rxbuf && p[-1] == '\r') - p--; - if (++i == 2) - break; - } - if (i == 2 || !j) + p = hp->rx_p; + i = http_rxchar(hp, 1, 1); + if (i < 1) + break; + if (s == 0 && *p == '\r') + s = 1; + else if ((s == 0 || s == 1) && *p == '\n') + s = 2; + else if (s == 2 && *p == '\r') + s = 3; + else if ((s == 2 || s == 3) && *p == '\n') break; + else + s = 0; } - vtc_dump(hp->vl, 4, "rxhdr", hp->rxbuf, hp->prxbuf); - vtc_log(hp->vl, 4, "rxhdrlen = %d", hp->prxbuf); - if (!j) - vtc_log(hp->vl, hp->fatal, "EOF timeout=%d", hp->timeout); - hp->body = hp->rxbuf + hp->prxbuf; + l = hp->rx_p - hp->rx_b; + vtc_dump(hp->vl, 4, "rxhdr", hp->rx_b, l); + vtc_log(hp->vl, 4, "rxhdrlen = %zd", l); + hp->body = hp->rx_p; } /* SECTION: client-server.spec.rxresp * * rxresp [-no_obj] (client only) - * Receive and parse a response's headers and body. If -no_obj is present, only get - * the headers. + * Receive and parse a response's headers and body. If -no_obj is + * present, only get the headers. */ + static void cmd_http_rxresp(CMD_ARGS) { @@ -720,6 +718,7 @@ cmd_http_rxresp(CMD_ARGS) * rxresphdrs (client only) * Receive and parse a response's headers. */ + static void cmd_http_rxresphdrs(CMD_ARGS) { @@ -741,7 +740,6 @@ cmd_http_rxresphdrs(CMD_ARGS) "Multiple Content-Length headers.\n"); } - /********************************************************************** * Ungzip rx'ed body */ @@ -1243,7 +1241,7 @@ cmd_http_rxchunk(CMD_ARGS) i = http_rxchunk(hp); if (i == 0) { - ll = hp->rxbuf + hp->prxbuf - hp->body; + ll = hp->rx_p - hp->body; hp->bodyl = ll; bprintf(hp->bodylen, "%d", ll); vtc_log(hp->vl, 4, "bodylen = %s", hp->bodylen); @@ -1738,10 +1736,10 @@ cmd_http_rxpri(CMD_ARGS) CAST_OBJ_NOTNULL(hp, priv, HTTP_MAGIC); ONLY_SERVER(hp, av); - hp->prxbuf = 0; + hp->rx_p = hp->rx_b; if (!http_rxchar(hp, sizeof(PREFACE), 0)) vtc_fatal(vl, "Couldn't retrieve connection preface"); - if (memcmp(hp->rxbuf, PREFACE, sizeof(PREFACE))) + if (memcmp(hp->rx_b, PREFACE, sizeof(PREFACE))) vtc_fatal(vl, "Received invalid preface\n"); start_h2(hp); AN(hp->h2); @@ -1892,7 +1890,7 @@ http_process_cleanup(void *arg) if (hp->h2) stop_h2(hp); VSB_destroy(&hp->vsb); - free(hp->rxbuf); + free(hp->rx_b); free(hp->rem_ip); free(hp->rem_port); free(hp->rem_path); @@ -1913,8 +1911,11 @@ http_process(struct vtclog *vl, const char *spec, int sock, int *sfd, hp->timeout = vtc_maxdur * 1000 / 2; hp->nrxbuf = 2048*1024; - hp->rxbuf = malloc(hp->nrxbuf); /* XXX */ - AN(hp->rxbuf); + hp->rx_b = malloc(hp->nrxbuf); + AN(hp->rx_b); + hp->rx_e = hp->rx_b + hp->nrxbuf; + hp->rx_p = hp->rx_b; + *hp->rx_p = '\0'; hp->vsb = VSB_new_auto(); AN(hp->vsb); diff --git a/bin/varnishtest/vtc_http.h b/bin/varnishtest/vtc_http.h index 5cd079890..6c857183f 100644 --- a/bin/varnishtest/vtc_http.h +++ b/bin/varnishtest/vtc_http.h @@ -39,11 +39,12 @@ struct http { struct vsb *vsb; int nrxbuf; - char *rxbuf; + char *rx_b; + char *rx_p; + char *rx_e; char *rem_ip; char *rem_port; char *rem_path; - int prxbuf; char *body; unsigned bodyl; char bodylen[20]; From phk at FreeBSD.org Mon Feb 25 08:30:12 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 25 Feb 2019 08:30:12 +0000 (UTC) Subject: [master] 1a7f60eec Whitespace OCD Message-ID: <20190225083012.C7038115B43@lists.varnish-cache.org> commit 1a7f60eec13755cae4aaf3d05bc2dc44f9a5b84e Author: Poul-Henning Kamp Date: Mon Feb 25 08:28:59 2019 +0000 Whitespace OCD diff --git a/bin/varnishtest/tests/a00019.vtc b/bin/varnishtest/tests/a00019.vtc index 28ab15466..975364445 100644 --- a/bin/varnishtest/tests/a00019.vtc +++ b/bin/varnishtest/tests/a00019.vtc @@ -8,15 +8,15 @@ server s1 { } -start server s2 { - rxreq - txresp -nolen -hdr "Transfer-Encoding: chunked" - chunkedlen 8192 - chunkedlen 4096 - chunkedlen 4096 - chunkedlen 16384 - chunkedlen 16384 - chunkedlen 16384 - chunkedlen 0 + rxreq + txresp -nolen -hdr "Transfer-Encoding: chunked" + chunkedlen 8192 + chunkedlen 4096 + chunkedlen 4096 + chunkedlen 16384 + chunkedlen 16384 + chunkedlen 16384 + chunkedlen 0 rxreq txresp } -start diff --git a/bin/varnishtest/tests/r02395.vtc b/bin/varnishtest/tests/r02395.vtc index 99461e16c..fd2440648 100644 --- a/bin/varnishtest/tests/r02395.vtc +++ b/bin/varnishtest/tests/r02395.vtc @@ -1,22 +1,22 @@ varnishtest "Test between_bytes_timeout works fetching headers" server s1 { - rxreq - send "HTTP/1.0 " - delay 2 + rxreq + send "HTTP/1.0 " + delay 2 } -start varnish v1 -vcl+backend { - sub vcl_recv { return (pass); } - sub vcl_backend_fetch { set bereq.between_bytes_timeout = 1s; } + sub vcl_recv { return (pass); } + sub vcl_backend_fetch { set bereq.between_bytes_timeout = 1s; } } -start varnish v1 -cliok "param.set debug +syncvsl" client c1 { - txreq - rxresp - expect resp.status == 503 + txreq + rxresp + expect resp.status == 503 } -run server s1 -wait diff --git a/bin/varnishtest/vtc_http.c b/bin/varnishtest/vtc_http.c index fc0512b7c..d0e6921da 100644 --- a/bin/varnishtest/vtc_http.c +++ b/bin/varnishtest/vtc_http.c @@ -654,7 +654,7 @@ http_rxhdr(struct http *hp) while (1) { p = hp->rx_p; i = http_rxchar(hp, 1, 1); - if (i < 1) + if (i < 1) break; if (s == 0 && *p == '\r') s = 1; From geoff at uplex.de Mon Feb 25 14:37:08 2019 From: geoff at uplex.de (Geoff Simmons) Date: Mon, 25 Feb 2019 14:37:08 +0000 (UTC) Subject: [master] 492c9bfb0 Add criteria for bundling new VMODs to the dev-guide. Message-ID: <20190225143708.992F29F20@lists.varnish-cache.org> commit 492c9bfb0f7e849652161dc88567b3a078aa5db8 Author: Geoff Simmons Date: Mon Feb 25 15:35:53 2019 +0100 Add criteria for bundling new VMODs to the dev-guide. References #2912 diff --git a/doc/sphinx/dev-guide/index.rst b/doc/sphinx/dev-guide/index.rst index f1c818245..633a0102c 100644 --- a/doc/sphinx/dev-guide/index.rst +++ b/doc/sphinx/dev-guide/index.rst @@ -81,3 +81,35 @@ These rules are imported from the X11 project: * Provide mechanism, rather than policy. +Bundling VMODs with the Varnish distribution +-------------------------------------------- + +Decisions about whether to add a new Varnish module (VMOD) to those +bundled with Varnish are guided by these criteria. + +* The VMOD is known to be in widespread use and in high demand for + common use cases. + +* Or, if the VMOD is relatively new, it provides compelling features + that the developer group agrees will be a valuable enhancement for + the project. + +* The VMOD does not create dependencies on additional external + libraries. VMODs that are "glue" for a library come from third + parties. + + * We don't want to add new burdens of dependency and compatibility + to the project. + + * We don't want to force Varnish deployments to install more than + admins explicitly choose to install. + +* The VMOD code follows project conventions (passes make distcheck, + follows source code style, and so forth). + + * A pull request can demonstrate that this is the case (after any + necessary fixups). + +* The developer group commits to maintaining the code for the long run + (so there will have to be a consensus that we're comfortable with + it). From dridi.boukelmoune at gmail.com Mon Feb 25 17:57:07 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 25 Feb 2019 17:57:07 +0000 (UTC) Subject: [master] fda04bf39 Kill goto statements in vmod-shard Message-ID: <20190225175707.CECA5641BE@lists.varnish-cache.org> commit fda04bf398313a30f6fb7ad8c88085454a35d01d Author: Dridi Boukelmoune Date: Mon Feb 25 18:49:06 2019 +0100 Kill goto statements in vmod-shard With that, (almost) only libvgz carries goto statements from zlib. This isn't changing any of the previous semantics, in particular the AN(be) assertion from the "ok:" jump is honored by all code paths formerly leading to it. Previously, the bitmap was allocated on the stack prior to the magic check of shardd, which is now fixed at the expense of a potential code style violation. But more importantly, we currently read the number of backends prior to acquiring the read lock, but there is no evidence that this was done on purpose and not overlooked, besides moving a possibly expensive state initialization outside of the critical section. If that was on purpose, please document it. diff --git a/lib/libvmod_directors/shard_dir.c b/lib/libvmod_directors/shard_dir.c index 624ac2f9d..7a96565e3 100644 --- a/lib/libvmod_directors/shard_dir.c +++ b/lib/libvmod_directors/shard_dir.c @@ -338,114 +338,135 @@ sharddir_any_healthy(VRT_CTX, struct sharddir *shardd, VCL_TIME *changed) sharddir_unlock(shardd); return (retval); } + /* * core function for the director backend/resolve method */ -VCL_BACKEND -sharddir_pick_be(VRT_CTX, struct sharddir *shardd, + +static VCL_BACKEND +sharddir_pick_be_locked(VRT_CTX, struct sharddir *shardd, uint32_t key, VCL_INT alt, VCL_REAL warmup, VCL_BOOL rampup, - enum healthy_e healthy) + enum healthy_e healthy, struct shard_state *state) { VCL_BACKEND be; - struct shard_state state; - unsigned picklist_sz = VBITMAP_SZ(shardd->n_backend); - char picklist_spc[picklist_sz]; VCL_DURATION chosen_r, alt_r; CHECK_OBJ_NOTNULL(shardd, SHARDDIR_MAGIC); CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); AN(ctx->vsl); - memset(&state, 0, sizeof(state)); - init_state(&state, ctx, shardd, vbit_init(picklist_spc, picklist_sz)); - - sharddir_rdlock(shardd); if (shardd->n_backend == 0) { shard_err0(ctx, shardd, "no backends"); - goto err; + return (NULL); } assert(shardd->hashcircle); validate_alt(ctx, shardd, &alt); - state.idx = shard_lookup(shardd, key); - assert(state.idx >= 0); + state->idx = shard_lookup(shardd, key); + assert(state->idx >= 0); SHDBG(SHDBG_LOOKUP, shardd, "lookup key %x idx %d host %u", - key, state.idx, shardd->hashcircle[state.idx].host); + key, state->idx, shardd->hashcircle[state->idx].host); if (alt > 0) { - if (shard_next(&state, alt - 1, healthy == ALL ? 1 : 0) == -1) { - if (state.previous.hostid != -1) { + if (shard_next(state, alt - 1, healthy == ALL ? 1 : 0) == -1) { + if (state->previous.hostid != -1) { be = sharddir_backend(shardd, - state.previous.hostid); - goto ok; + state->previous.hostid); + AN(be); + return (be); } - goto err; + return (NULL); } } - if (shard_next(&state, 0, healthy == IGNORE ? 0 : 1) == -1) { - if (state.previous.hostid != -1) { - be = sharddir_backend(shardd, state.previous.hostid); - goto ok; + if (shard_next(state, 0, healthy == IGNORE ? 0 : 1) == -1) { + if (state->previous.hostid != -1) { + be = sharddir_backend(shardd, state->previous.hostid); + AN(be); + return (be); } - goto err; + return (NULL); } - be = sharddir_backend(shardd, state.last.hostid); + be = sharddir_backend(shardd, state->last.hostid); + AN(be); if (warmup == -1) warmup = shardd->warmup; /* short path for cases we dont want ramup/warmup or can't */ if (alt > 0 || healthy == IGNORE || (!rampup && warmup == 0) || - shard_next(&state, 0, 1) == -1) - goto ok; + shard_next(state, 0, 1) == -1) + return (be); assert(alt == 0); - assert(state.previous.hostid >= 0); - assert(state.last.hostid >= 0); - assert(state.previous.hostid != state.last.hostid); - assert(be == sharddir_backend(shardd, state.previous.hostid)); + assert(state->previous.hostid >= 0); + assert(state->last.hostid >= 0); + assert(state->previous.hostid != state->last.hostid); + assert(be == sharddir_backend(shardd, state->previous.hostid)); - chosen_r = shardcfg_get_rampup(shardd, state.previous.hostid); - alt_r = shardcfg_get_rampup(shardd, state.last.hostid); + chosen_r = shardcfg_get_rampup(shardd, state->previous.hostid); + alt_r = shardcfg_get_rampup(shardd, state->last.hostid); SHDBG(SHDBG_RAMPWARM, shardd, "chosen host %d rampup %f changed %f", - state.previous.hostid, chosen_r, - ctx->now - state.previous.changed); + state->previous.hostid, chosen_r, + ctx->now - state->previous.changed); SHDBG(SHDBG_RAMPWARM, shardd, "alt host %d rampup %f changed %f", - state.last.hostid, alt_r, - ctx->now - state.last.changed); + state->last.hostid, alt_r, + ctx->now - state->last.changed); - if (ctx->now - state.previous.changed < chosen_r) { + if (ctx->now - state->previous.changed < chosen_r) { /* * chosen host is in rampup * - no change if alternative host is also in rampup or the dice * has rolled in favour of the chosen host */ if (!rampup || - ctx->now - state.last.changed < alt_r || + ctx->now - state->last.changed < alt_r || VRND_RandomTestableDouble() * chosen_r < - (ctx->now - state.previous.changed)) - goto ok; + (ctx->now - state->previous.changed)) + return (be); } else { /* chosen host not in rampup - warmup ? */ if (warmup == 0 || VRND_RandomTestableDouble() > warmup) - goto ok; + return (be); } - be = sharddir_backend(shardd, state.last.hostid); + be = sharddir_backend(shardd, state->last.hostid); + return (be); +} - ok: - AN(be); +VCL_BACKEND +sharddir_pick_be(VRT_CTX, struct sharddir *shardd, + uint32_t key, VCL_INT alt, VCL_REAL warmup, VCL_BOOL rampup, + enum healthy_e healthy) +{ + VCL_BACKEND be; + struct shard_state state[1]; + unsigned picklist_sz; + + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + CHECK_OBJ_NOTNULL(shardd, SHARDDIR_MAGIC); + + /* NB: Allocate bitmap on the stack + * + * XXX: Should we read n_backend under the lock and check whether + * n_backend is zero before allocating the state? + */ + picklist_sz = VBITMAP_SZ(shardd->n_backend); + char picklist_spc[picklist_sz]; + + memset(state, 0, sizeof(state)); + init_state(state, ctx, shardd, vbit_init(picklist_spc, picklist_sz)); + + sharddir_rdlock(shardd); + be = sharddir_pick_be_locked(ctx, shardd, key, alt, warmup, rampup, + healthy, state); sharddir_unlock(shardd); - vbit_destroy(state.picklist); + + vbit_destroy(state->picklist); return (be); - err: - sharddir_unlock(shardd); - vbit_destroy(state.picklist); - return NULL; } From nils.goroll at uplex.de Mon Feb 25 18:17:08 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 25 Feb 2019 18:17:08 +0000 (UTC) Subject: [master] 5666ed7a6 complement the cleanup started in the previous commit Message-ID: <20190225181708.10CC164978@lists.varnish-cache.org> commit 5666ed7a613f0d2fcf22d1f480eccd9bdddc685a Author: Nils Goroll Date: Mon Feb 25 19:12:07 2019 +0100 complement the cleanup started in the previous commit Thank you, @Dridi - yes, allocations outside the lock were motivated by minimizing the critical section, but n_backend could actually change, so this was wrong. As we use an RW lock, doing more work under it should only have marginal impact. - n_backend == 0 is probably best handled as a special case diff --git a/lib/libvmod_directors/shard_dir.c b/lib/libvmod_directors/shard_dir.c index 7a96565e3..e40bb67bb 100644 --- a/lib/libvmod_directors/shard_dir.c +++ b/lib/libvmod_directors/shard_dir.c @@ -354,11 +354,7 @@ sharddir_pick_be_locked(VRT_CTX, struct sharddir *shardd, CHECK_OBJ_NOTNULL(shardd, SHARDDIR_MAGIC); CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); AN(ctx->vsl); - - if (shardd->n_backend == 0) { - shard_err0(ctx, shardd, "no backends"); - return (NULL); - } + assert(shardd->n_backend > 0); assert(shardd->hashcircle); @@ -451,18 +447,20 @@ sharddir_pick_be(VRT_CTX, struct sharddir *shardd, CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(shardd, SHARDDIR_MAGIC); - /* NB: Allocate bitmap on the stack - * - * XXX: Should we read n_backend under the lock and check whether - * n_backend is zero before allocating the state? - */ + sharddir_rdlock(shardd); + + if (shardd->n_backend == 0) { + shard_err0(ctx, shardd, "no backends"); + sharddir_unlock(shardd); + return (NULL); + } + picklist_sz = VBITMAP_SZ(shardd->n_backend); char picklist_spc[picklist_sz]; memset(state, 0, sizeof(state)); init_state(state, ctx, shardd, vbit_init(picklist_spc, picklist_sz)); - sharddir_rdlock(shardd); be = sharddir_pick_be_locked(ctx, shardd, key, alt, warmup, rampup, healthy, state); sharddir_unlock(shardd); From phk at FreeBSD.org Mon Feb 25 22:08:07 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 25 Feb 2019 22:08:07 +0000 (UTC) Subject: [master] 05d59c656 Flexelint constification Message-ID: <20190225220807.28CDC101CAA@lists.varnish-cache.org> commit 05d59c656478c1a57e0ee8e2241f070b0b4b9f1b Author: Poul-Henning Kamp Date: Mon Feb 25 22:06:55 2019 +0000 Flexelint constification diff --git a/lib/libvmod_directors/shard_dir.c b/lib/libvmod_directors/shard_dir.c index e40bb67bb..50a280de6 100644 --- a/lib/libvmod_directors/shard_dir.c +++ b/lib/libvmod_directors/shard_dir.c @@ -344,7 +344,7 @@ sharddir_any_healthy(VRT_CTX, struct sharddir *shardd, VCL_TIME *changed) */ static VCL_BACKEND -sharddir_pick_be_locked(VRT_CTX, struct sharddir *shardd, +sharddir_pick_be_locked(VRT_CTX, const struct sharddir *shardd, uint32_t key, VCL_INT alt, VCL_REAL warmup, VCL_BOOL rampup, enum healthy_e healthy, struct shard_state *state) { From dridi.boukelmoune at gmail.com Tue Feb 26 09:07:07 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 26 Feb 2019 09:07:07 +0000 (UTC) Subject: [master] e35c2d6b7 Whitespace OCD Message-ID: <20190226090707.3954310DD07@lists.varnish-cache.org> commit e35c2d6b72a8d9d390ab6306a2a0c62df68c874a Author: Dridi Boukelmoune Date: Tue Feb 26 10:06:21 2019 +0100 Whitespace OCD diff --git a/lib/libvmod_directors/shard_dir.c b/lib/libvmod_directors/shard_dir.c index 50a280de6..54d5caabe 100644 --- a/lib/libvmod_directors/shard_dir.c +++ b/lib/libvmod_directors/shard_dir.c @@ -344,9 +344,9 @@ sharddir_any_healthy(VRT_CTX, struct sharddir *shardd, VCL_TIME *changed) */ static VCL_BACKEND -sharddir_pick_be_locked(VRT_CTX, const struct sharddir *shardd, - uint32_t key, VCL_INT alt, VCL_REAL warmup, VCL_BOOL rampup, - enum healthy_e healthy, struct shard_state *state) +sharddir_pick_be_locked(VRT_CTX, const struct sharddir *shardd, uint32_t key, + VCL_INT alt, VCL_REAL warmup, VCL_BOOL rampup, enum healthy_e healthy, + struct shard_state *state) { VCL_BACKEND be; VCL_DURATION chosen_r, alt_r; @@ -436,9 +436,8 @@ sharddir_pick_be_locked(VRT_CTX, const struct sharddir *shardd, } VCL_BACKEND -sharddir_pick_be(VRT_CTX, struct sharddir *shardd, - uint32_t key, VCL_INT alt, VCL_REAL warmup, VCL_BOOL rampup, - enum healthy_e healthy) +sharddir_pick_be(VRT_CTX, struct sharddir *shardd, uint32_t key, VCL_INT alt, + VCL_REAL warmup, VCL_BOOL rampup, enum healthy_e healthy) { VCL_BACKEND be; struct shard_state state[1]; From nils.goroll at uplex.de Tue Feb 26 14:42:03 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Tue, 26 Feb 2019 14:42:03 +0000 (UTC) Subject: [master] cddc0974b Add VRT_LookupDirector for vcl runtime lookup by name Message-ID: <20190226144203.1F91C113931@lists.varnish-cache.org> commit cddc0974b38c060d2df61ae98babee6e19f36d83 Author: Nils Goroll Date: Sun Feb 17 14:15:15 2019 +0100 Add VRT_LookupDirector for vcl runtime lookup by name I did consider generalizing VCL_IterDirector which handles backend iterations for the CLI, but found the complications not worth the savings for such a trivial function. diff --git a/bin/varnishd/cache/cache_vrt_vcl.c b/bin/varnishd/cache/cache_vrt_vcl.c index c17c80e5d..3374f80f4 100644 --- a/bin/varnishd/cache/cache_vrt_vcl.c +++ b/bin/varnishd/cache/cache_vrt_vcl.c @@ -261,6 +261,35 @@ VRT_DisableDirector(VCL_BACKEND d) vdir->health_changed = VTIM_real(); } +VCL_BACKEND +VRT_LookupDirector(VRT_CTX, VCL_STRING name) +{ + struct vcl *vcl; + struct vcldir *vdir; + VCL_BACKEND dd, d = NULL; + + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + AN(name); + + assert(ctx->method & VCL_MET_TASK_H); + ASSERT_CLI(); + + vcl = ctx->vcl; + CHECK_OBJ_NOTNULL(vcl, VCL_MAGIC); + + Lck_Lock(&vcl_mtx); + VTAILQ_FOREACH(vdir, &vcl->director_list, list) { + dd = vdir->dir; + if (strcmp(dd->vcl_name, name)) + continue; + d = dd; + break; + } + Lck_Unlock(&vcl_mtx); + + return (d); +} + /*--------------------------------------------------------------------*/ VCL_BACKEND diff --git a/include/vrt.h b/include/vrt.h index f6fc9ca26..72c9c4d78 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -62,6 +62,7 @@ * req->req_bodybytes removed * use: AZ(ObjGetU64(req->wrk, req->body_oc, OA_LEN, &u)); * struct vdi_methods .list callback signature changed + * VRT_LookupDirector() added * 8.0 (2018-09-15) * VRT_Strands() added * VRT_StrandsWS() added @@ -512,6 +513,7 @@ VCL_BACKEND VRT_AddDirector(VRT_CTX, const struct vdi_methods *, void *, const char *, ...) v_printflike_(4, 5); void VRT_SetHealth(VCL_BACKEND d, int health); void VRT_DisableDirector(VCL_BACKEND); +VCL_BACKEND VRT_LookupDirector(VRT_CTX, VCL_STRING); void VRT_DelDirector(VCL_BACKEND *); /* Suckaddr related */ From nils.goroll at uplex.de Tue Feb 26 14:42:03 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Tue, 26 Feb 2019 14:42:03 +0000 (UTC) Subject: [master] c7b96c31b add directors.lookup() Message-ID: <20190226144203.3FEC2113934@lists.varnish-cache.org> commit c7b96c31b1a0db1a54eaabc4b0ec0b6d27fb0da1 Author: Nils Goroll Date: Tue Feb 26 15:38:18 2019 +0100 add directors.lookup() diff --git a/bin/varnishtest/tests/b00016.vtc b/bin/varnishtest/tests/b00016.vtc index 80d28d8cb..af3627f52 100644 --- a/bin/varnishtest/tests/b00016.vtc +++ b/bin/varnishtest/tests/b00016.vtc @@ -6,7 +6,12 @@ server s1 -repeat 2 -keepalive { } -start varnish v1 -vcl+backend { + import directors; + sub vcl_recv { + if (req.url == "/lookup") { + set req.http.foo = directors.lookup("s1"); + } return (pass); } @@ -19,6 +24,10 @@ client c1 { txreq -url "/" rxresp expect resp.http.X-Backend-Name == "s1" + txreq -url "/lookup" + rxresp + expect resp.status == 503 + expect resp.reason == "VCL failed" } -run varnish v1 -vcl+backend { @@ -26,7 +35,7 @@ varnish v1 -vcl+backend { sub vcl_init { new bar = directors.random(); - bar.add_backend(s1, 1); + bar.add_backend(directors.lookup("s1"), 1); } sub vcl_recv { diff --git a/doc/changes.rst b/doc/changes.rst index 55177809a..7173b6316 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -104,6 +104,11 @@ VCL * Added ``req.is_hitmiss`` and ``req.is_hitpass`` (2743_) +bundled vmods +------------- + +* Added ``directors.lookup()`` + bundled tools ------------- diff --git a/lib/libvmod_directors/Makefile.am b/lib/libvmod_directors/Makefile.am index f4a59e2a5..706e24a30 100644 --- a/lib/libvmod_directors/Makefile.am +++ b/lib/libvmod_directors/Makefile.am @@ -5,6 +5,7 @@ libvmod_directors_la_SOURCES = \ vdir.h \ fall_back.c \ hash.c \ + misc.c \ random.c \ round_robin.c \ vmod_shard.c \ diff --git a/lib/libvmod_directors/misc.c b/lib/libvmod_directors/misc.c new file mode 100644 index 000000000..c72799558 --- /dev/null +++ b/lib/libvmod_directors/misc.c @@ -0,0 +1,47 @@ +/*- + * Copyright 2019 UPLEX - Nils Goroll Systemoptimierung + * All rights reserved. + * + * Author: Nils Goroll + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include "config.h" + +#include "vdef.h" +#include "vrt.h" +#include "vcl.h" + +#include "vcc_if.h" + +VCL_BACKEND +VPFX(lookup)(VRT_CTX, VCL_STRING name) +{ + if ((ctx->method & VCL_MET_TASK_H) == 0) { + VRT_fail(ctx, + "lookup() may only be called from vcl_init / vcl_fini"); + return (NULL); + } + + return (VRT_LookupDirector(ctx, name)); +} diff --git a/lib/libvmod_directors/vmod.vcc b/lib/libvmod_directors/vmod.vcc index 1727f1f67..f30f2b2a1 100644 --- a/lib/libvmod_directors/vmod.vcc +++ b/lib/libvmod_directors/vmod.vcc @@ -687,6 +687,12 @@ This method may only be used in backend context. For use with the `param` argument of `vmod_directors.shard.backend`_ to associate this shard parameter set with a shard director. +$Function BACKEND lookup(STRING) + +Lookup a backend by its name. + +This function can only be used from ``vcl_init{}`` and ``vcl_fini{}``. + ACKNOWLEDGEMENTS ================ From lasse.karstensen at gmail.com Tue Feb 26 15:03:07 2019 From: lasse.karstensen at gmail.com (Lasse Karstensen) Date: Tue, 26 Feb 2019 15:03:07 +0000 (UTC) Subject: [master] 4cf4bbefe Shorten compiler flags when developing. Message-ID: <20190226150307.623C4114151@lists.varnish-cache.org> commit 4cf4bbefe0ad1801852e116c46f7059c6c30dc48 Author: Lasse Karstensen Date: Tue Feb 26 10:34:03 2019 +0100 Shorten compiler flags when developing. This commit attempts to make it easier to read build output, and hopefully makes configure.ac easier as well. -Wall has already been added around line 645, no need to add it twice. On GCC -Wreturn-type is a part of -Wall, which we enable elsewhere. https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html On Clang -Wreturn-type is enabled by default: https://clang.llvm.org/docs/DiagnosticsReference.html#wreturn-type Same with -Wswitch as -Wreturn-type, so that can be removed as well. Finally, use spaces instead of tabs to make cc output shorter and more readable. diff --git a/configure.ac b/configure.ac index 804da7992..985dd64d1 100644 --- a/configure.ac +++ b/configure.ac @@ -671,24 +671,20 @@ AX_CHECK_COMPILE_FLAG([-Werror=unused-result], # This corresponds to FreeBSD's WARNS level 6 DEVELOPER_CFLAGS=" \ - -Werror \ - -Wall \ - -Wno-format-y2k \ - -W \ - -Wstrict-prototypes \ - -Wmissing-prototypes \ - -Wpointer-arith \ - -Wreturn-type \ - -Wcast-qual \ - -Wwrite-strings \ - -Wswitch \ - -Wshadow \ - -Wunused-parameter \ - -Wcast-align \ - -Wchar-subscripts \ - -Wnested-externs \ - -Wextra \ - -Wno-sign-compare \ + -Werror \ + -Wno-format-y2k \ + -Wstrict-prototypes \ + -Wmissing-prototypes \ + -Wpointer-arith \ + -Wcast-qual \ + -Wwrite-strings \ + -Wshadow \ + -Wunused-parameter \ + -Wcast-align \ + -Wchar-subscripts \ + -Wnested-externs \ + -Wextra \ + -Wno-sign-compare \ " # These are not compliable yet From nils.goroll at uplex.de Tue Feb 26 15:04:08 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Tue, 26 Feb 2019 15:04:08 +0000 (UTC) Subject: [master] 493b5e586 fix visibility attributes autocrap test for SUNCC Message-ID: <20190226150408.6BD461142C8@lists.varnish-cache.org> commit 493b5e586f804ab87a7991c41e6a5053a4167639 Author: Nils Goroll Date: Tue Feb 26 15:59:07 2019 +0100 fix visibility attributes autocrap test for SUNCC Spotted by @lkarsten diff --git a/configure.ac b/configure.ac index 985dd64d1..24956aaca 100644 --- a/configure.ac +++ b/configure.ac @@ -241,15 +241,21 @@ AC_CHECK_FUNCS([pthread_setname_np]) AC_CHECK_FUNCS([pthread_mutex_isowned_np]) LIBS="${save_LIBS}" +AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"]) + # Support for visibility attribute save_CFLAGS="${CFLAGS}" -CFLAGS="${CFLAGS} -Werror" +if test "$SUNCC" = "yes" ; then + CFLAGS="${CFLAGS} -errwarn=%all,no%E_EMPTY_TRANSLATION_UNIT" +else + CFLAGS="${CFLAGS} -Werror" +fi AC_CACHE_CHECK([whether we have support for visibility attributes], [ac_cv_have_viz], [AC_RUN_IFELSE( [AC_LANG_PROGRAM([[ - #if ((__GNUC__-0) * 10 + __GNUC_MINOR__-0 >= 33) + #if ((__GNUC__-0) * 10 + __GNUC_MINOR__-0 >= 33 || defined(__SUNPRO_C)) # define ZLIB_INTERNAL __attribute__((visibility ("hidden"))) #else # define ZLIB_INTERNAL @@ -646,8 +652,6 @@ AX_CHECK_COMPILE_FLAG([-Wall], [CFLAGS="${CFLAGS} -Wall" OCFLAGS="${OCFLAGS} -Wall"]) -AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"]) - if test "$SUNCC" = "yes" ; then SUNCC_CFLAGS=" \ -errwarn=%all,no%E_EMPTY_TRANSLATION_UNIT \ From nils.goroll at uplex.de Tue Feb 26 16:40:10 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Tue, 26 Feb 2019 16:40:10 +0000 (UTC) Subject: [master] c5a69fedb Improve rst formatting of vmod_std Message-ID: <20190226164010.BBDE0115E26@lists.varnish-cache.org> commit c5a69fedb161b8f3484d20ff8153a8d92a79c27c Author: Nils Goroll Date: Tue Feb 26 16:50:50 2019 +0100 Improve rst formatting of vmod_std in particular: - remove defintion lists (Description/Example) - examples as code blocks:: - argument names as *emphasis* - ``literals`` Ref: doc/README.WRITING_RST.rst diff --git a/doc/README.WRITING_RST.rst b/doc/README.WRITING_RST.rst index 7b8078e6d..77e005476 100644 --- a/doc/README.WRITING_RST.rst +++ b/doc/README.WRITING_RST.rst @@ -15,6 +15,14 @@ not follow the style: .. _Reference: http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#character-level-inline-markup + * exception: Links to manpages outside varnish as `man(section)` + +* use code blocks for:: + + Examples and + + other code + References are tricky --------------------- diff --git a/lib/libvmod_std/vmod.vcc b/lib/libvmod_std/vmod.vcc index cf919d250..39365af2a 100644 --- a/lib/libvmod_std/vmod.vcc +++ b/lib/libvmod_std/vmod.vcc @@ -31,407 +31,430 @@ $Module std 3 "Varnish Standard Module" DESCRIPTION =========== -`vmod_std` contains basic functions which are part and parcel of Varnish, -but which for reasons of architecture fit better in a VMOD. +.. note: not using :ref:`vmod_std(3)` because it expands to "VMOD + std - Varnish Standard Module" and here just the plan vmod name + makes more sense. -One particular class of functions in vmod_std is the conversions functions -which all have the form:: +*vmod_std* contains basic functions which are part and parcel of +Varnish, but which for reasons of architecture fit better in a VMOD. + +One particular class of functions in *vmod_std* is the conversions +functions which all have the form:: TYPE type(STRING, TYPE) -These functions attempt to convert STRING to the TYPE, and if that fails, -they return the second argument, which must have the given TYPE. +These functions attempt to convert *STRING* to the *TYPE*, and if that +fails, they return the second argument, which must have the given +*TYPE*. $Function STRING toupper(STRING_LIST s) -Description - Converts the string *s* to uppercase. -Example +Converts the string *s* to uppercase. + +Example:: + set beresp.http.scream = std.toupper("yes!"); $Function STRING tolower(STRING_LIST s) -Description - Converts the string *s* to lowercase. -Example +Converts the string *s* to lowercase. + +Example:: + set beresp.http.nice = std.tolower("VerY"); $Function VOID set_ip_tos(INT tos) -Description - Sets the IP type-of-service (TOS) field for the current session - to *tos*. Silently ignored if the listen address is a Unix - domain socket. - Please note that the TOS field is not removed by the end of the - request so probably want to set it on every request should you - utilize it. -Example - | if (req.url ~ "^/slow/") { - | std.set_ip_tos(0); - | } +Sets the IP type-of-service (TOS) field for the current session to +*tos*. Silently ignored if the listen address is a Unix domain socket. + +Please note that the TOS field is not removed by the end of the +request so probably want to set it on every request should you utilize +it. + +Example:: + + if (req.url ~ "^/slow/") { + std.set_ip_tos(0); + } $Function REAL random(REAL lo, REAL hi) -Description - Returns a random real number between *lo* and *hi*. - This function uses the "testable" random generator in varnishd - which enables determinstic tests to be run (See m00002.vtc). - This function should not be used for cryptographic applications. -Example +Returns a random real number between *lo* and *hi*. + +This function uses the "testable" random generator in varnishd which +enables determinstic tests to be run (See ``m00002.vtc``). This +function should not be used for cryptographic applications. + +Example:: + set beresp.http.random-number = std.random(1, 100); $Function VOID log(STRING_LIST s) -Description - Logs the string *s* to the shared memory log, using VSL tag - *SLT_VCL_Log*. -Example +Logs the string *s* to the shared memory log, using :ref:`vsl(7)` tag +``SLT_VCL_Log``. + +Example:: + std.log("Something fishy is going on with the vhost " + req.http.host); $Function VOID syslog(INT priority, STRING_LIST s) -Description - Logs the string *s* to syslog tagged with *priority*. *priority* - is formed by ORing the facility and level values. See your - system's syslog.h file for possible values. +Logs the string *s* to syslog tagged with *priority*. *priority* is +formed by ORing the facility and level values. See your system's +``syslog.h`` file for possible values. + +Notice: Unlike VCL and other functions in the std vmod, this function +will not fail VCL processing for workspace overflows: For an out of +workspace condition, the `vmod_std.syslog`_ function has no effect. + +Example:: - Notice: Unlike VCL and other functions in the std vmod, this - function will not fail VCL processing for workspace overflows: - For an out of workspace condition, the ``syslog()`` function - has no effect. -Example std.syslog(9, "Something is wrong"); - This will send a message to syslog using LOG_USER | LOG_ALERT. +This will send a message to syslog using ``LOG_USER | LOG_ALERT``. $Function STRING fileread(PRIV_CALL, STRING) -Description - Reads a file and returns a string with the content. The result - is cached indefinitely per filename. -Example +Reads a file and returns a string with the content. The result is +cached indefinitely per filename. + +Example:: + synthetic("Response was served by " + std.fileread("/etc/hostname")); Consider that the entire contents of the file appear in the string that is returned, including newlines that may result in invalid -headers if ``std.fileread()`` is used to form a header. In that case, -you may need to modify the string, for example with ``regsub()``:: +headers if `vmod_std.fileread`_ is used to form a header. In that +case, you may need to modify the string, for example with +``regsub()`` (see :ref:`vcl(7)`):: set beresp.http.served-by = regsub(std.fileread("/etc/hostname"), "\R$", ""); $Function BOOL file_exists(STRING path) -Description - Returns `true` if path or the file pointed to by path exists, - `false` otherwise. -Example - | if (std.file_exists("/etc/return_503")) { - | return (synth(503, "Varnish is in maintenance")); - | } +Returns ``true`` if path or the file pointed to by path exists, +``false`` otherwise. + +Example:: + + if (std.file_exists("/etc/return_503")) { + return (synth(503, "Varnish is in maintenance")); + }`` $Function VOID collect(HEADER hdr, STRING sep=", ") -Description - Collapses multiple *hdr* headers into one long header. The - default separator *sep* is the standard comma separator to - use when collapsing headers, with an additional whitespace - for pretty printing. +Collapses multiple *hdr* headers into one long header. The default +separator *sep* is the standard comma separator to use when collapsing +headers, with an additional whitespace for pretty printing. - Care should be taken when collapsing headers. In particular - collapsing Set-Cookie will lead to unexpected results on the - browser side. -Examples - | std.collect(req.http.accept); - | std.collect(req.http.cookie, "; "); +Care should be taken when collapsing headers. In particular collapsing +``Set-Cookie`` will lead to unexpected results on the browser side. + +Examples:: + + std.collect(req.http.accept); + std.collect(req.http.cookie, "; "); $Function DURATION duration(STRING s, DURATION fallback) -Description - Converts the string *s* to seconds. *s* must be quantified - with ms (milliseconds), s (seconds), m (minutes), h (hours), - d (days), w (weeks) or y (years) units. If conversion fails, - *fallback* will be returned. -Example +Converts the string *s* to seconds. *s* must be quantified with ``ms`` +(milliseconds), ``s`` (seconds), ``m`` (minutes), ``h`` (hours), ``d`` +(days), ``w`` (weeks) or ``y`` (years) units. If conversion fails, +*fallback* will be returned. + +Example:: + set beresp.ttl = std.duration("1w", 3600s); $Function BYTES bytes(STRING s, BYTES fallback) -Description - Converts the string *s* to bytes. *s* can be quantified - with a multiplier (k, m, g, t, p). If conversion fails, - *fallback* will be returned. -Example +Converts the string *s* to bytes. *s* can be quantified with a +multiplier (``k``, ``m``, ``g``, ``t``, ``p``). If conversion fails, +*fallback* will be returned. + +Example:: + std.cache_req_body(std.bytes(something.somewhere, 10K)); $Function INT integer(STRING s, INT fallback) -Description - Converts the string *s* to an integer. If conversion fails, - *fallback* will be returned. -Example - | if (std.integer(req.http.foo, 0) > 5) { - | ... - | } +Converts the string *s* to an integer. If conversion fails, *fallback* +will be returned. + +Example:: + + if (std.integer(req.http.foo, 0) > 5) { + ... + } $Function IP ip(STRING s, IP fallback, BOOL resolve = 1) -Description - Converts the string *s* to the first IP number returned by - the system library function getaddrinfo(3). If conversion - fails, *fallback* will be returned. +Converts the string *s* to the first IP number returned by +the system library function `getaddrinfo(3)`. If conversion +fails, *fallback* will be returned. + +If *resolve* is false, `getaddrinfo(3)` is called using +``AI_NUMERICHOST`` to avoid network lookups. This makes "pure" IP +strings cheaper to convert. - If *resolve* is false, getaddrinfo() is called using *AI_NUMERICHOST* - to avoid network lookups. This makes "pure" IP strings cheaper to - convert. +Example:: -Example - | if (std.ip(req.http.X-forwarded-for, "0.0.0.0") ~ my_acl) { - | ... - | } + if (std.ip(req.http.X-forwarded-for, "0.0.0.0") ~ my_acl) { + ... + } $Function REAL real(STRING s, REAL fallback) -Description - Converts the string *s* to a real. If conversion fails, - *fallback* will be returned. -Example - | if (std.real(req.http.foo, 0.0) > 5.5) { - | ... - | } +Converts the string *s* to a real. If conversion fails, *fallback* +will be returned. + +Example:: + + if (std.real(req.http.foo, 0.0) > 5.5) { + ... + } $Function INT real2integer(REAL r, INT fallback) -Description - Rounds the real *r* to the nearest integer, but round halfway - cases away from zero (see round(3)). If conversion fails, - *fallback* will be returned. -Example +Rounds the real *r* to the nearest integer, but round halfway cases +away from zero (see `round(3)`). If conversion fails, *fallback* will +be returned. + +Examples:: + set req.http.integer = std.real2integer(1140618699.00, 0); set req.http.posone = real2integer( 0.5, 0); # = 1.0 set req.http.negone = real2integer(-0.5, 0); # = -1.0 $Function TIME real2time(REAL r, TIME fallback) -Description - Rounds the real *r* to the nearest integer (see - `vmod_std.real2integer`_) and returns the corresponding time when - interpreted as a unix epoch. If conversion fails, *fallback* - will be returned. -Example +Rounds the real *r* to the nearest integer (see +`vmod_std.real2integer`_) and returns the corresponding time when +interpreted as a unix epoch. If conversion fails, *fallback* will be +returned. + +Example:: + set req.http.time = std.real2time(1140618699.00, now); $Function INT time2integer(TIME t, INT fallback) -Description - Converts the time *t* to a integer. If conversion fails, - *fallback* will be returned. -Example +Converts the time *t* to a integer. If conversion fails, +*fallback* will be returned. + +Example:: + set req.http.int = std.time2integer(now, 0); $Function REAL time2real(TIME t, REAL fallback) -Description - Converts the time *t* to a real. If conversion fails, - *fallback* will be returned. -Example +Converts the time *t* to a real. If conversion fails, *fallback* will +be returned. + +Example:: + set req.http.real = std.time2real(now, 1.0); $Function BOOL healthy(BACKEND be) -Description - Returns `true` if the backend *be* is healthy. +Returns ``true`` if the backend *be* is healthy. $Function INT port(IP ip) -Description - Returns the port number of the IP address *ip*. Always returns - 0 for a ``*.ip`` variable whose value is ``0.0.0.0`` because - the listen address is a Unix domain socket. +Returns the port number of the IP address *ip*. Always returns ``0`` +for a ``*.ip`` variable whose value is ``0.0.0.0`` because the listen +address is a Unix domain socket. $Function VOID rollback(HTTP h) -Description - Restores the *h* HTTP headers to their original state. -Example +Restores the *h* HTTP headers to their original state. + +Example:: + std.rollback(bereq); $Function VOID timestamp(STRING s) -Description - Introduces a timestamp in the log with the current time, using - the string *s* as the label. This is useful to time the execution - of lengthy VCL procedures, and makes the timestamps inserted - automatically by Varnish more accurate. -Example +Introduces a timestamp in the log with the current time, using the +string *s* as the label. This is useful to time the execution of +lengthy VCL procedures, and makes the timestamps inserted +automatically by Varnish more accurate. + +Example:: + std.timestamp("curl-request"); $Function STRING querysort(STRING) -Description - Sorts the query string for cache normalization purposes. -Example +Sorts the query string for cache normalization purposes. + +Example:: + set req.url = std.querysort(req.url); $Function BOOL cache_req_body(BYTES size) -Description - Caches the request body if it is smaller than *size*. Returns - `true` if the body was cached, `false` otherwise. +Caches the request body if it is smaller than *size*. Returns +``true`` if the body was cached, ``false`` otherwise. + +.. XXX fix wording: not the pass but rather the req body matters + +Normally the request body is not available after sending it to the +backend. By caching it is possible to retry pass operations, +e.g. ``POST`` and ``PUT``. + +Example:: - Normally the request body is not available after sending it to - the backend. By caching it is possible to retry pass operations, - e.g. POST and PUT. -Example - | if (std.cache_req_body(1KB)) { - | ... - | } + if (std.cache_req_body(1KB)) { + ... + } $Function STRING strstr(STRING s1, STRING s2) -Description - Returns a string beginning at the first occurrence of the string - *s2* in the string *s1*, or an empty string if *s2* is not found. +Returns a string beginning at the first occurrence of the string *s2* +in the string *s1*, or an empty string if *s2* is not found. - Note that the comparison is case sensitive. -Example - | if (std.strstr(req.url, req.http.restrict)) { - | ... - | } +Note that the comparison is case sensitive. - This will check if the content of req.http.restrict occurs - anywhere in req.url. +Example:: + + if (std.strstr(req.url, req.http.restrict)) { + ... + } + +This will check if the content of ``req.http.restrict`` occurs +anywhere in ``req.url``. $Function TIME time(STRING s, TIME fallback) -Description - Converts the string *s* to a time. If conversion fails, - *fallback* will be returned. +Converts the string *s* to a time. If conversion fails, *fallback* +will be returned. + +Supported formats:: - Supported formats: + "Sun, 06 Nov 1994 08:49:37 GMT" + "Sunday, 06-Nov-94 08:49:37 GMT" + "Sun Nov 6 08:49:37 1994" + "1994-11-06T08:49:37" + "784111777.00" + "784111777" - | "Sun, 06 Nov 1994 08:49:37 GMT" - | "Sunday, 06-Nov-94 08:49:37 GMT" - | "Sun Nov 6 08:49:37 1994" - | "1994-11-06T08:49:37" - | "784111777.00" - | "784111777" -Example - | if (std.time(resp.http.last-modified, now) < now - 1w) { - | ... - | } +Example:: + + if (std.time(resp.http.last-modified, now) < now - 1w) { + ... + } $Function STRING getenv(STRING name) -Description - Return environment variable *name* or the empty string. +Return environment variable *name* or the empty string. See `getenv(3)`. + +Example:: - See getenv(3) -Example - | set req.http.My-Env = std.getenv("MY_ENV"); + set req.http.My-Env = std.getenv("MY_ENV"); $Function VOID late_100_continue(BOOL late) -Description - Controls when varnish reacts to an `Expect: 100-continue` client - request header. - - Varnish always generates a `100 Continue` response if - requested by the client trough the `Expect: 100-continue` - header when waiting for request body data. - - But, by default, the `100 Continue` response is already - generated immediately after `vcl_recv` returns to reduce - latencies under the assumption that the request body will be - read eventually. - - Calling `std.late_100_continue(true)` in `vcl_recv` will cause - the `100 Continue` response to only be sent when needed. This - may cause additional latencies for processing request bodies, - but is the correct behavior by strict interpretation of - RFC7231. - - This function has no effect outside `vcl_recv` and after - calling `std.cache_req_body()` or any other function consuming - the request body. - -Example - | vcl_recv { - | std.late_100_continue(true); - | - | if (req.method == "POST") { - | std.late_100_continue(false); - | return (pass); - | } - | ... - | } +Controls when varnish reacts to an ``Expect: 100-continue`` client +request header. + +Varnish always generates a ``100 Continue`` response if requested by +the client trough the ``Expect: 100-continue`` header when waiting for +request body data. + +But, by default, the ``100 Continue`` response is already generated +immediately after ``vcl_recv`` returns to reduce latencies under the +assumption that the request body will be read eventually. + +Calling ``std.late_100_continue(true)`` in ``vcl_recv`` will cause the +``100 Continue`` response to only be sent when needed. This may cause +additional latencies for processing request bodies, but is the correct +behavior by strict interpretation of RFC7231. + +This function has no effect outside ``vcl_recv`` and after calling +``std.cache_req_body()`` or any other function consuming the request +body. + +Example:: + + vcl_recv { + std.late_100_continue(true); + + if (req.method == "POST") { + std.late_100_continue(false); + return (pass); + } + ... + } $Function BOOL syntax(REAL) -Description - Returns the true if VCL version is at least REAL. +Returns ``true`` if VCL version is at least *REAL*. $Function BOOL fnmatch(STRING pattern, STRING subject, BOOL pathname=1, BOOL noescape=0, BOOL period=0) -Description - Shell-style pattern matching; returns `true` if *subject* - matches *pattern*, where *pattern* may contain wildcard - characters such as \* or ?. - - The match is executed by the implementation of `fnmatch(3)` on - your system. The rules for pattern matching on most systems - include the following: - - * \* matches any sequence of characters - - * ? matches a single character - - * a bracket expression such as [abc] or [!0-9] is interpreted - as a character class according to the rules of basic regular - expressions (*not* PCRE regexen), except that ! is used for - character class negation instead of ^. - - If *pathname* is `true`, then the forward slash character / is - only matched literally, and never matches \*, ? or a bracket - expression. Otherwise, / may match one of those patterns. By - default, *pathname* is `true`. - - If *noescape* is `true`, then the backslash character \\ is - matched as an ordinary character. Otherwise, \\ is an escape - character, and matches the character that follows it in the - `pattern`. For example, \\\\ matches \\ when *noescape* is - `true`, and \\\\ when `false`. By default, *noescape* is - `false`. - - If *period* is `true`, then a leading period character . only - matches literally, and never matches \*, ? or a bracket - expression. A period is leading if it is the first character - in `subject`; if *pathname* is also `true`, then a period that - immediately follows a / is also leading (as in "/."). By - default, *period* is `false`. - - `fnmatch()` invokes VCL failure and returns `false` if either - of *pattern* or *subject* is NULL -- for example, if an unset - header is specified. - -Examples - | # Matches URLs such as /foo/bar and /foo/baz - | if (std.fnmatch("/foo/\*", req.url)) { ... } - | - | # Matches URLs such as /foo/bar/baz and /foo/baz/quux - | if (std.fnmatch("/foo/\*/\*", bereq.url)) { ... } - | - | # Matches /foo/bar/quux, but not /foo/bar/baz/quux - | if (std.fnmatch("/foo/\*/quux", req.url)) { ... } - | - | # Matches /foo/bar/quux and /foo/bar/baz/quux - | if (std.fnmatch("/foo/\*/quux", req.url, pathname=false)) { ... } - | - | # Matches /foo/bar, /foo/car and /foo/far - | if (std.fnmatch("/foo/?ar", req.url)) { ... } - | - | # Matches /foo/ followed by a non-digit - | if (std.fnmatch("/foo/[!0-9]", req.url)) { ... } +Shell-style pattern matching; returns ``true`` if *subject* matches +*pattern*, where *pattern* may contain wildcard characters such as ``*`` +or ``?``. + +The match is executed by the implementation of `fnmatch(3)` on your +system. The rules for pattern matching on most systems include the +following: + +* ``*`` matches any sequence of characters + +* ``?`` matches a single character + +* a bracket expression such as ``[abc]`` or ``[!0-9]`` is interpreted + as a character class according to the rules of basic regular + expressions (*not* `pcre(3)` regexen), except that ``!`` is used for + character class negation instead of ``^``. + +If *pathname* is ``true``, then the forward slash character ``/`` is +only matched literally, and never matches ``*``, ``?`` or a bracket +expression. Otherwise, ``/`` may match one of those patterns. By +default, *pathname* is ``true``. + +If *noescape* is ``true``, then the backslash character ``\`` is +matched as an ordinary character. Otherwise, ``\`` is an escape +character, and matches the character that follows it in the +*pattern*. For example, ``\\`` matches ``\`` when *noescape* is +``true``, and ``\\`` when ``false``. By default, *noescape* is +``false``. + +If *period* is ``true``, then a leading period character ``.`` only +matches literally, and never matches ``*``, ``?`` or a bracket +expression. A period is leading if it is the first character in +*subject*; if *pathname* is also ``true``, then a period that +immediately follows a ``/`` is also leading (as in ``/.``). By +default, *period* is ``false``. + +`vmod_std.fnmatch`_ invokes VCL failure and returns ``false`` if +either of *pattern* or *subject* is ``NULL`` -- for example, if an +unset header is specified. + +Examples:: + + # Matches URLs such as /foo/bar and /foo/baz + if (std.fnmatch("/foo/\*", req.url)) { ... } + + # Matches URLs such as /foo/bar/baz and /foo/baz/quux + if (std.fnmatch("/foo/\*/\*", bereq.url)) { ... } + + # Matches /foo/bar/quux, but not /foo/bar/baz/quux + if (std.fnmatch("/foo/\*/quux", req.url)) { ... } + + # Matches /foo/bar/quux and /foo/bar/baz/quux + if (std.fnmatch("/foo/\*/quux", req.url, pathname=false)) { ... } + + # Matches /foo/bar, /foo/car and /foo/far + if (std.fnmatch("/foo/?ar", req.url)) { ... } + + # Matches /foo/ followed by a non-digit + if (std.fnmatch("/foo/[!0-9]", req.url)) { ... } SEE ALSO From nils.goroll at uplex.de Tue Feb 26 17:42:08 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Tue, 26 Feb 2019 17:42:08 +0000 (UTC) Subject: [master] 7b9e39f1c more vmod rst formatting cleanup Message-ID: <20190226174208.1CCE51170B3@lists.varnish-cache.org> commit 7b9e39f1c7d0a874edd7016e57d63daf8a70a036 Author: Nils Goroll Date: Tue Feb 26 18:41:02 2019 +0100 more vmod rst formatting cleanup Ref: doc/README.WRITING_RST.rst diff --git a/lib/libvmod_blob/vmod.vcc b/lib/libvmod_blob/vmod.vcc index 302293f76..5e34381a4 100644 --- a/lib/libvmod_blob/vmod.vcc +++ b/lib/libvmod_blob/vmod.vcc @@ -13,7 +13,7 @@ DESCRIPTION =========== This VMOD provides utility functions and an object for the VCL data -type BLOB, which may contain arbitrary data of any length. +type ``BLOB``, which may contain arbitrary data of any length. Examples:: @@ -71,24 +71,24 @@ ENUM values for an encoding scheme can be one of: * ``HEX`` * ``URL`` -Empty strings are decoded into a "null blob" (of length 0), -and conversely a null blob is encoded as the empty string. +Empty strings are decoded into a "null blob" (of length 0), and +conversely a null blob is encoded as the empty string. -For encodings with ``HEX`` or ``URL``, you may also specify a ``case`` +For encodings with ``HEX`` or ``URL``, you may also specify a *case* ENUM with one of the values ``LOWER``, ``UPPER`` or ``DEFAULT`` to produce a string with lower- or uppercase hex digits (in ``[a-f]`` or -``[A-F]``). The default value for ``case`` is ``DEFAULT``, which for +``[A-F]``). The default value for *case* is ``DEFAULT``, which for ``HEX`` and ``URL`` means the same as ``LOWER``. -The ``case`` ENUM is not relevant for decodings; ``HEX`` or ``URL`` +The *case* ENUM is not relevant for decodings; ``HEX`` or ``URL`` strings to be decoded as BLOBs may have hex digits in either case, or in mixed case. -The ``case`` ENUM MUST be set to ``DEFAULT`` for the other encodings -(BASE64* and IDENTITY). You cannot, for example, produce an uppercase -string by using the IDENTITY scheme with ``case=UPPER``. To change the -case of a string, use the ``toupper`` or ``tolower`` functions from -:ref:`vmod_std(3)`. +The *case* ENUM MUST be set to ``DEFAULT`` for the other encodings +(``BASE64*`` and ``IDENTITY``). You cannot, for example, produce an +uppercase string by using the ``IDENTITY`` scheme with +``case=UPPER``. To change the case of a string, use the ``std.toupper()`` or +``std.tolower()`` functions from :ref:`vmod_std(3)`. IDENTITY ~~~~~~~~ @@ -97,7 +97,7 @@ The simplest encoding converts between the BLOB and STRING data types, leaving the contents byte-identical. Note that a BLOB may contain a null byte at any position before its -end; if such a BLOB is decoded with IDENTITY, the resulting STRING +end; if such a BLOB is decoded with ``IDENTITY``, the resulting STRING will have a null byte at that position. Since VCL strings, like C strings, are represented with a terminating null byte, the string will be truncated, appearing to contain less data than the original @@ -109,15 +109,15 @@ blob. For example:: = blob.encode(IDENTITY, blob=blob.decode(HEX, encoded="666f6f00626172")); -IDENTITY is the default encoding and decoding. So the above can also -be written as:: +``IDENTITY`` is the default encoding and decoding. So the above can +also be written as:: # Decode from the hex encoding for "foo\0bar". # The header will be seen as "foo". set resp.http.Trunced-Foo2 = blob.encode(blob=blob.decode(HEX, encoded="666f6f00626172")); -The ``case`` ENUM MUST be set to ``DEFAULT`` for ``IDENTITY`` encodings. +The *case* ENUM MUST be set to ``DEFAULT`` for ``IDENTITY`` encodings. BASE64* ~~~~~~~ @@ -139,14 +139,14 @@ The ``BASE64URLNOPAD`` encoding uses the same alphabet as ``BASE6URL``, but leaves out the padding. Thus the length of an encoding with this scheme is not necessarily a multiple of four. -The ``case`` ENUM MUST be set to ``DEFAULT`` for for all of the +The *case* ENUM MUST be set to ``DEFAULT`` for for all of the ``BASE64*`` encodings. HEX ~~~ The ``HEX`` encoding scheme converts hex strings into blobs and vice -versa. For encodings, you may use the ``case`` ENUM to specify upper- +versa. For encodings, you may use the *case* ENUM to specify upper- or lowercase hex digits ``A`` through ``f`` (default ``DEFAULT``, which means the same as ``LOWER``). A prefix such as ``0x`` is not used for an encoding and is illegal for a decoding. @@ -167,25 +167,25 @@ URL ~~~ The ``URL`` decoding replaces any ``%<2-hex-digits>`` substrings with -the binary value of the hexadecimal number after the % sign. +the binary value of the hexadecimal number after the ``%`` sign. The ``URL`` encoding implements "percent encoding" as per RFC3986. The -``case`` ENUM determines the case of the hex digits, but does not +*case* ENUM determines the case of the hex digits, but does not affect alphabetic characters that are not percent-encoded. $Function BLOB decode(ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, HEX, URL} decoding="IDENTITY", INT length=0, STRANDS encoded) -Returns the BLOB derived from the string ``encoded`` according to the -scheme specified by ``decoding``. +Returns the BLOB derived from the string *encoded* according to the +scheme specified by *decoding*. -If ``length`` > 0, only decode the first ``length`` characters of the -encoded string. If ``length`` <= 0 or greater than the length of the -string, then decode the entire string. The default value of ``length`` +If *length* > 0, only decode the first *length* characters of the +encoded string. If *length* <= 0 or greater than the length of the +string, then decode the entire string. The default value of *length* is 0. -``decoding`` defaults to IDENTITY. +*decoding* defaults to IDENTITY. Example:: @@ -202,13 +202,14 @@ $Function STRING encode(ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, HEX, URL} encoding="IDENTITY", ENUM {LOWER, UPPER, DEFAULT} case="DEFAULT", BLOB blob) -Returns a string representation of the BLOB ``blob`` as specified by -``encoding``. ``case`` determines the case of hex digits for the -``HEX`` and ``URL`` encodings, and is ignored for the other encodings. +Returns a string representation of the BLOB *blob* as specified by +*encoding*. *case* determines the case of hex digits for the ``HEX`` +and ``URL`` encodings, and is ignored for the other encodings. -``encoding`` defaults to IDENTITY, and ``case`` defaults to DEFAULT. -DEFAULT is interpreted as LOWER for the HEX and URL encodings, and is -the required value for the other encodings. +*encoding* defaults to ``IDENTITY``, and *case* defaults to +``DEFAULT``. ``DEFAULT`` is interpreted as ``LOWER`` for the ``HEX`` +and ``URL`` encodings, and is the required value for the other +encodings. Example:: @@ -234,18 +235,19 @@ $Function STRING transcode(ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, 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 +*encoded* according to the scheme *decoding*, and then returning the encoding of the resulting blob according to the scheme -``encoding``. ``case`` determines the case of hex digits for the +*encoding*. *case* determines the case of hex digits for the ``HEX`` and ``URL`` encodings, and is ignored for other encodings. -As with ``decode()``: If ``length`` > 0, only decode the first -``length`` characters of the encoded string, otherwise decode the -entire string. The default value of ``length`` is 0. +As with `vmod_blob.decode`_: If *length* > 0, only decode the first +*length* characters of the encoded string, otherwise decode the +entire string. The default value of *length* is 0. -``decoding`` and ``encoding`` default to IDENTITY, and ``case`` -defaults to DEFAULT. DEFAULT is interpreted as LOWER for the HEX and -URL encodings, and is the required value for the other encodings. +*decoding* and *encoding* default to IDENTITY, and *case* defaults to +``DEFAULT``. ``DEFAULT`` is interpreted as ``LOWER`` for the ``HEX`` +and ``URL`` encodings, and is the required value for the other +encodings. Example:: @@ -267,22 +269,23 @@ Example:: $Function BOOL same(BLOB, BLOB) -Returns true if and only if the two BLOB arguments are the same +Returns ``true`` if and only if the two BLOB arguments are the same object, i.e. they specify exactly the same region of memory, or both are empty. If the BLOBs are both empty (length is 0 and/or the internal pointer -is NULL), then ``same()`` returns ``true``. If any non-empty BLOB -is compared to an empty BLOB, then ``same()`` returns ``false``. +is ``NULL``), then `vmod_blob.same`_ returns ``true``. If any +non-empty BLOB is compared to an empty BLOB, then `vmod_blob.same`_ +returns ``false``. $Function BOOL equal(BLOB, BLOB) Returns true if and only if the two BLOB arguments have equal contents (possibly in different memory regions). -As with ``same()``: If the BLOBs are both empty, then ``equal()`` +As with `vmod_blob.same`_: If the BLOBs are both empty, then `vmod_blob.equal`_ returns ``true``. If any non-empty BLOB is compared to an empty BLOB, -then ``equal()`` returns ``false``. +then `vmod_blob.equal`_ returns ``false``. $Function INT length(BLOB) @@ -290,11 +293,11 @@ Returns the length of the BLOB. $Function BLOB sub(BLOB, BYTES length, BYTES offset = 0) -Returns a new BLOB formed from ``length`` bytes of the BLOB argument -starting at ``offset`` bytes from the start of its memory region. The -default value of ``offset`` is 0B. +Returns a new BLOB formed from *length* bytes of the BLOB argument +starting at *offset* bytes from the start of its memory region. The +default value of *offset* is ``0B``. -``sub()`` fails and returns NULL if the BLOB argument is empty, or if +`vmod_blob.sub`_ fails and returns NULL if the BLOB argument is empty, or if ``offset + length`` requires more bytes than are available in the BLOB. @@ -303,7 +306,7 @@ $Object blob(ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, HEX, STRANDS encoded) Creates an object that contains the BLOB derived from the string -``encoded`` according to the scheme ``decoding``. +*encoded* according to the scheme *decoding*. Example:: @@ -335,7 +338,7 @@ $Method STRING .encode(ENUM {IDENTITY, BASE64, BASE64URL, BASE64URLNOPAD, HEX, ENUM {LOWER, UPPER, DEFAULT} case="DEFAULT") Returns an encoding of BLOB created by the constructor, according to -the scheme ``encoding``. ``case`` determines the case of hex digits +the scheme *encoding*. *case* determines the case of hex digits for the ``HEX`` and ``URL`` encodings, and MUST be set to ``DEFAULT`` for the other encodings. @@ -347,71 +350,74 @@ Example:: # blob as base64 set resp.http.The-Blob-b64 = theblob1.encode(BASE64); -For any ``blob`` object, encoding ``ENC`` and case ``CASE``, encodings -via the ``.encode()`` method and the ``encode()`` function are equal:: +For any `vmod_blob.blob`_ object, `encoding` and `case`, encodings via +the `vmod_blob.blob.encode`_ method and the `vmod_blob.encode`_ +function are equal:: # Always true: blob.encode(ENC, CASE, blob.get()) == blob.encode(ENC, CASE) -But the object method is more efficient -- the encoding is computed -once and cached (with allocation in heap memory), and the cached -encoding is retrieved on every subsequent call. The ``encode()`` -function computes the encoding on every call, allocating space for the -string in Varnish workspaces. +But the `vmod_blob.blob.encode`_ object method is more efficient -- +the encoding is computed once and cached (with allocation in heap +memory), and the cached encoding is retrieved on every subsequent +call. The `vmod_blob.encode`_ function computes the encoding on every +call, allocating space for the string in Varnish workspaces. So if the data in a BLOB are fixed at VCL initialization time, so that its encodings will always be the same, it is better to create a -``blob`` object. The VMOD's functions should be used for data that are +`vmod_blob.blob`_ object. The VMOD's functions should be used for data that are not known until runtime. ERRORS ====== -The encoders, decoders and ``sub()`` may fail if there is insufficient -space to create the new blob or string. Decoders may also fail if the -encoded string is an illegal format for the decoding scheme. Encoders -will fail for the ``IDENTITY`` and ``BASE64*`` encoding schemes if the -``case`` ENUM is not set to ``DEFAULT``. +The encoders, decoders and `vmod_blob.sub`_ may fail if there is +insufficient space to create the new blob or string. Decoders may also +fail if the encoded string is an illegal format for the decoding +scheme. Encoders will fail for the ``IDENTITY`` and ``BASE64*`` +encoding schemes if the *case* ENUM is not set to ``DEFAULT``. If any of the VMOD's methods, functions or constructor fail, then VCL failure is invoked, just as if ``return(fail)`` had been called in the VCL source. This means that: -* If the ``blob`` object constructor fails, or if any methods or - functions fail during ``vcl_init``, then the VCL program will fail +* If the ``vmod_blob.blob`_ object constructor fails, or if any methods or + functions fail during ``vcl_init{}``, then the VCL program will fail to load, and the VCC compiler will emit an error message. * If a method or function fails in any other VCL subroutine besides - ``vcl_synth``, then control is directed to ``vcl_synth``. The + ``vcl_synth{}``, then control is directed to ``vcl_synth{}``. The response status is set to 503 with the reason string ``"VCL - failed"``, and an error message will be written to the Varnish log + failed"``, and an error message will be written to the :ref:`vsl(7)` using the tag ``VCL_Error``. -* If the failure occurs during ``vcl_synth``, then ``vcl_synth`` is - aborted. The response line ``"503 VCL failed"`` is returned, and +* If the failure occurs during ``vcl_synth{}``, then ``vcl_synth{}`` + is aborted. The response line ``"503 VCL failed"`` is returned, and the ``VCL_Error`` message is written to the log. LIMITATIONS =========== The VMOD allocates memory in various ways for new blobs and -strings. The ``blob`` object and its methods allocate memory from the -heap, and hence they are only limited by available virtual memory. +strings. The `vmod_blob.blob`_ object and its methods allocate memory +from the heap, and hence they are only limited by available virtual +memory. -The ``encode()``, ``decode()`` and ``transcode()`` functions allocate -Varnish workspace, as does ``sub()`` for the newly created BLOB. If -these functions are failing, as indicated by "out of space" messages -in the Varnish log (with the ``VCL_Error`` tag), then you will need to -increase the varnishd parameters ``workspace_client`` and/or -``workspace_backend``. +The `vmod_blob.encode`_, `vmod_blob.decode`_ and +`vmod_blob.transcode`_ functions allocate Varnish workspace, as does +`vmod_blob.sub`_ for the newly created BLOB. If these functions are +failing, as indicated by "out of space" messages in the Varnish log +(with the ``VCL_Error`` tag), then you will need to increase the +varnishd parameters ``workspace_client`` and/or ``workspace_backend``. -The ``transcode()`` function also allocates space on the stack for a -temporary BLOB. If this function causes stack overflow, you may need -to increase the varnishd parameter ``thread_pool_stack``. +The `vmod_blob.transcode`_ function also allocates space on the stack +for a temporary BLOB. If this function causes stack overflow, you may +need to increase the varnishd parameter ``thread_pool_stack``. SEE ALSO ======== * :ref:`varnishd(1)` * :ref:`vcl(7)` +* :ref:`vsl(7)` * :ref:`vmod_std(3)` diff --git a/lib/libvmod_debug/vmod.vcc b/lib/libvmod_debug/vmod.vcc index 016bca407..2ff1d0220 100644 --- a/lib/libvmod_debug/vmod.vcc +++ b/lib/libvmod_debug/vmod.vcc @@ -92,22 +92,22 @@ $Method VOID .test_priv_call(PRIV_CALL) Test method for call private pointers -Objects share the PRIV_* state with other objects and methods from the -same vmod - IOW the PRIV_* state is per vmod, not per object. +Objects share the ``PRIV_*`` state with other objects and methods from +the same vmod - IOW the ``PRIV_*`` state is per vmod, not per object. $Method VOID .test_priv_vcl(PRIV_VCL) Test method for VCL private pointers -Objects share the PRIV_* state with other objects and methods from the -same vmod - IOW the PRIV_* state is per vmod, not per object. +Objects share the ``PRIV_*`` state with other objects and methods from +the same vmod - IOW the ``PRIV_*`` state is per vmod, not per object. $Method STRING .test_priv_task(PRIV_TASK, STRING s="") Test method for TASK private pointers -Objects share the PRIV_* state with other objects and methods from the -same vmod - IOW the PRIV_* state is per vmod, not per object. +Objects share the ``PRIV_*`` state with other objects and methods from +the same vmod - IOW the ``PRIV_*`` state is per vmod, not per object. $Method STRING .test_priv_top(PRIV_TOP, STRING) @@ -196,12 +196,12 @@ 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().) +(Uses ``VRT_StrandsWS()``.) $Function STRING collect(STRANDS) Return the string formed by concatenating the given strings. -(Uses VRT_CollectStrands().) +(Uses ``VRT_CollectStrands()``.) $Function VOID sethdr(HEADER, STRANDS) @@ -209,14 +209,15 @@ Set the given header with the concatenation of the given strings. $Function DURATION priv_perf(INT size, INT rounds=10000) -Benchmark VRT_priv_task() with `size` elements, iterating `rounds` +Benchmark ``VRT_priv_task()`` with `size` elements, iterating `rounds` times. -Returns the average time taken for each call scaled up from nanoseconds -to seconds - iow the value given as seconds is actually the duration -in nanoseconds. +Returns the average time taken for each call scaled up from +nanoseconds to seconds - iow the value given as seconds is actually +the duration in nanoseconds. -For comparable results, a higher size run should called first and discarded. +For comparable results, a higher size run should called first and +discarded. $Object NULL_OK obj_opt(PRIV_CALL, PRIV_VCL, PRIV_TASK, [STRING s], [BOOL b]) diff --git a/lib/libvmod_directors/vmod.vcc b/lib/libvmod_directors/vmod.vcc index f30f2b2a1..7a81ee422 100644 --- a/lib/libvmod_directors/vmod.vcc +++ b/lib/libvmod_directors/vmod.vcc @@ -38,7 +38,7 @@ $Module directors 3 "Varnish Directors Module" DESCRIPTION =========== -`vmod_directors` enables backend load balancing in Varnish. +*vmod_directors* enables backend load balancing in Varnish. The module implements load balancing techniques, and also serves as an example on how one could extend the load balancing capabilities of @@ -49,7 +49,7 @@ To enable load balancing you must import this vmod (directors). Then you define your backends. Once you have the backends declared you can add them to a director. This happens in executed VCL code. If you want to emulate the previous behavior of Varnish 3.0 you can just -initialize the directors in vcl_init, like this:: +initialize the directors in ``vcl_init{}``, like this:: sub vcl_init { new vdir = directors.round_robin(); @@ -58,173 +58,183 @@ initialize the directors in vcl_init, like this:: } As you can see there is nothing keeping you from manipulating the -directors elsewhere in VCL. So, you could have VCL code that would -add more backends to a director when a certain URL is called. +directors elsewhere in VCL. So, you could have VCL code that would add +more backends to a director when a certain URL is called. Note that directors can use other directors as backends. $Object round_robin() -Description - Create a round robin director. +Create a round robin director. + +This director will pick backends in a round robin fashion. + +Example:: - This director will pick backends in a round robin fashion. -Example new vdir = directors.round_robin(); $Method VOID .add_backend(BACKEND) -Description - Add a backend to the round-robin director. -Example +Add a backend to the round-robin director. + +Example:: + vdir.add_backend(backend1); $Method VOID .remove_backend(BACKEND) -Description - Remove a backend from the round-robin director. -Example +Remove a backend from the round-robin director. + +Example:: + vdir.remove_backend(backend1); $Method BACKEND .backend() -Description - Pick a backend from the director. -Example +Pick a backend from the director. + +Example:: + set req.backend_hint = vdir.backend(); $Object fallback(BOOL sticky = 0) -Description - Create a fallback director. +Create a fallback director. - A fallback director will try each of the added backends in turn, - and return the first one that is healthy. +A fallback director will try each of the added backends in turn, and +return the first one that is healthy. - If ``sticky`` is set to true, the director will keep using the healthy - backend, even if a higher-priority backend becomes available. Once the - whole backend list is exhausted, it'll start over at the beginning. +If *sticky* is set to ``true``, the director will keep using the +healthy backend, even if a higher-priority backend becomes +available. Once the whole backend list is exhausted, it'll start over +at the beginning. + +Example:: -Example new vdir = directors.fallback(); $Method VOID .add_backend(BACKEND) -Description - Add a backend to the director. +Add a backend to the director. + +Note that the order in which this is done matters for the fallback +director. - Note that the order in which this is done matters for the fallback - director. +Example:: -Example vdir.add_backend(backend1); $Method VOID .remove_backend(BACKEND) -Description - Remove a backend from the director. -Example +Remove a backend from the director. + +Example:: + vdir.remove_backend(backend1); $Method BACKEND .backend() -Description - Pick a backend from the director. -Example - set req.backend_hint = vdir.backend(); +Pick a backend from the director. + +Example:: + set req.backend_hint = vdir.backend(); $Object random() -Description - Create a random backend director. +Create a random backend director. - The random director distributes load over the backends using - a weighted random probability distribution. - The "testable" random generator in varnishd is used, which - enables deterministic tests to be run (See: d00004.vtc). +The random director distributes load over the backends using a +weighted random probability distribution. + +The "testable" random generator in varnishd is used, which enables +deterministic tests to be run (See: ``d00004.vtc``). + +Example:: -Example new vdir = directors.random(); $Method VOID .add_backend(BACKEND, REAL) -Description - Add a backend to the director with a given weight. +Add a backend to the director with a given weight. - Each backend will receive approximately 100 * (weight / - (sum(all_added_weights))) per cent of the traffic sent to this - director. +Each backend will receive approximately 100 * (weight / +(sum(all_added_weights))) per cent of the traffic sent to this +director. -Example - | # 2/3 to backend1, 1/3 to backend2. - | vdir.add_backend(backend1, 10.0); - | vdir.add_backend(backend2, 5.0); +Example:: + + # 2/3 to backend1, 1/3 to backend2. + vdir.add_backend(backend1, 10.0); + vdir.add_backend(backend2, 5.0); $Method VOID .remove_backend(BACKEND) -Description - Remove a backend from the director. -Example +Remove a backend from the director. + +Example:: + vdir.remove_backend(backend1); $Method BACKEND .backend() -Description - Pick a backend from the director. -Example +Pick a backend from the director. + +Example:: + set req.backend_hint = vdir.backend(); $Object hash() -Description - Create a hashing backend director. +Create a hashing backend director. + +The director chooses the backend server by computing a hash/digest of +the string given to `vmod_directors.hash.backend`_. - The director chooses the backend server by computing a hash/digest - of the string given to .backend(). +Commonly used with ``client.ip`` or a session cookie to get sticky +sessions. - Commonly used with ``client.ip`` or a session cookie to get - sticky sessions. +Example:: -Example new vdir = directors.hash(); $Method VOID .add_backend(BACKEND, REAL) -Description - Add a backend to the director with a certain weight. +Add a backend to the director with a certain weight. - Weight is used as in the random director. Recommended value is - 1.0 unless you have special needs. +Weight is used as in the random director. Recommended value is 1.0 +unless you have special needs. + +Example:: -Example vdir.add_backend(backend1, 1.0); $Method VOID .remove_backend(BACKEND) -Description - Remove a backend from the director. -Example +Remove a backend from the director. + +Example:: vdir.remove_backend(backend1); $Method BACKEND .backend(STRING_LIST) -Description - Pick a backend from the backend director. +Pick a backend from the backend director. - Use the string or list of strings provided to pick the backend. -Example - | # pick a backend based on the cookie header from the client - | set req.backend_hint = vdir.backend(req.http.cookie); +Use the string or list of strings provided to pick the backend. + +Example:: + # pick a backend based on the cookie header from the client + set req.backend_hint = vdir.backend(req.http.cookie); $Object shard() Create a shard director. Note that the shard director needs to be configured using at least one -``shard.add_backend()`` call(s) **followed by a** -``shard.reconfigure()`` **call** before it can hand out backends. +`vmod_directors.shard.add_backend`_ call(s) **followed by a** +`vmod_directors.shard.reconfigure`_ **call** before it can hand out +backends. _Note_ that due to various restrictions (documented below), it is recommended to use the shard director on the backend side. @@ -259,7 +269,7 @@ Varnish servers: application servers, requesting similar objects from the same server may help to optimize efficiency of such caches. - For example, sharding by URL or some `id` component of the url has + For example, sharding by URL or some *id* component of the url has been shown to drastically improve the efficiency of many content management systems. @@ -302,24 +312,24 @@ The drawbacks are: Method `````` -When ``.reconfigure()`` is called, a consistent hashing circular data -structure gets built from the last 32 bits of SHA256 hash values of -``\ `` (default `ident` being the backend name) for each -backend and for a running number `n` from 1 to `replicas`. Hashing -creates the seemingly random order for placement of backends on the -consistent hashing ring. +When `vmod_directors.shard.reconfigure`_ is called, a consistent +hashing circular data structure gets built from the last 32 bits of +SHA256 hash values of **\ ** (default *ident* being the +backend name) for each backend and for a running number *n* from 1 to +*replicas*. Hashing creates the seemingly random order for placement +of backends on the consistent hashing ring. -When ``.backend()`` is called, a load balancing key gets generated -unless provided. The smallest hash value in the circle is looked up -that is larger than the key (searching clockwise and wrapping around -as necessary). The backend for this hash value is the preferred -backend for the given key. +When `vmod_directors.shard.backend`_ is called, a load balancing key +gets generated unless provided. The smallest hash value in the circle +is looked up that is larger than the key (searching clockwise and +wrapping around as necessary). The backend for this hash value is the +preferred backend for the given key. If a healthy backend is requested, the search is continued linearly on the ring as long as backends found are unhealthy or all backends have -been checked. The order of these "alternative backends" on the ring -is likely to differ for different keys. Alternative backends can also -be selected explicitly. +been checked. The order of these "alternative backends" on the ring is +likely to differ for different keys. Alternative backends can also be +selected explicitly. On consistent hashing see: @@ -338,61 +348,65 @@ when configuring the shard director, you are advised to check:: $Method VOID .set_warmup(REAL probability=0.0) -Set the default warmup probability. See the `warmup` parameter of -``shard.backend()``. If probability is 0.0 (default), warmup is -disabled. +Set the default warmup probability. See the *warmup* parameter of +`vmod_directors.shard.backend`_. If *probability* is 0.0 (default), +warmup is disabled. $Method VOID .set_rampup(DURATION duration=0) -Set the default rampup duration. See `rampup` parameter of -`shard.backend()`. If duration is 0 (default), rampup is disabled. +Set the default rampup duration. See *rampup* parameter of +`vmod_directors.shard.backend`_. If *duration* is 0 (default), rampup +is disabled. $Method VOID .associate(BLOB param=0) Associate a default `vmod_directors.shard_param`_ object or clear an association. -The value of the `param` argument must be a call to the +The value of the *param* argument must be a call to the `vmod_directors.shard_param.use`_ method. No argument clears the association. -The association can be changed per backend request using the `param` +The association can be changed per backend request using the *param* argument of `vmod_directors.shard.backend`_. $Method BOOL .add_backend(PRIV_TASK, BACKEND backend, [STRING ident], [DURATION rampup]) -Add a backend `backend` to the director. +Add a backend *backend* to the director. -`ident`: Optionally specify an identification string for this backend, -which will be hashed by `shard.reconfigure()` to construct the -consistent hashing ring. The identification string defaults to the -backend name. +*ident*: Optionally specify an identification string for this backend, +which will be hashed by `vmod_directors.shard.reconfigure`_ to +construct the consistent hashing ring. The identification string +defaults to the backend name. -`ident` allows to add multiple instances of the same backend. +*ident* allows to add multiple instances of the same backend. -`rampup`: Optionally specify a specific rampup time for this +*rampup*: Optionally specify a specific rampup time for this backend. Otherwise, the per-director rampup time is used (see -:ref:`vmod_directors.shard.set_rampup`). +`vmod_directors.shard.set_rampup`_). -NOTE: Backend changes need to be finalized with `shard.reconfigure()` -and are only supported on one shard director at a time. +NOTE: Backend changes need to be finalized with +`vmod_directors.shard.reconfigure`_ and are only supported on one +shard director at a time. $Method BOOL .remove_backend(PRIV_TASK, [BACKEND backend=0], [STRING ident=0]) -Remove backend(s) from the director. Either `backend` or `ident` must -be specified. `ident` removes a specific instance. If `backend` is -given without `ident`, all instances of this backend are removed. +Remove backend(s) from the director. Either *backend* or *ident* must +be specified. *ident* removes a specific instance. If *backend* is +given without *ident*, all instances of this backend are removed. -NOTE: Backend changes need to be finalized with `shard.reconfigure()` -and are only supported on one shard director at a time. +NOTE: Backend changes need to be finalized with +`vmod_directors.shard.reconfigure`_ and are only supported on one +shard director at a time. $Method BOOL .clear(PRIV_TASK) Remove all backends from the director. -NOTE: Backend changes need to be finalized with `shard.reconfigure()` -and are only supported on one shard director at a time. +NOTE: Backend changes need to be finalized with +`vmod_directors.shard.reconfigure`_ and are only supported on one +shard director at a time. $Method BOOL .reconfigure(PRIV_TASK, INT replicas=67) @@ -403,13 +417,13 @@ used. $Method INT .key(STRING_LIST) -Convenience method to generate a sharding key for use with the `key` -argument to the ``shard.backend()`` method by hashing the given string -with SHA256. +Convenience method to generate a sharding key for use with the *key* +argument to the `vmod_directors.shard.backend`_ method by hashing the +given string with SHA256. To generate sharding keys using other hashes, use a custom vmod like -`vmod blobdigest`_ with the `key_blob` argument of the -``shard.backend()`` method. +`vmod blobdigest`_ with the *key_blob* argument of the +`vmod_directors.shard.backend`_ method. .. _vmod blobdigest: https://code.uplex.de/uplex-varnish/libvmod-blobdigest/blob/master/README.rst @@ -433,91 +447,91 @@ differ for different keys, depending on the number of backends and the number of replicas. In particular, the backend order referred to here is _not_ the order given when backends are added. -* `by` how to determine the sharding key +* *by* how to determine the sharding key - * `HASH`: + * ``HASH``: * when called in backend context: Use the varnish hash value as - set by `vcl_hash` + set by ``vcl_hash{}`` - * when called in client context: hash `req.url` + * when called in client context: hash ``req.url`` - * `URL`: hash req.url / bereq.url + * ``URL``: hash req.url / bereq.url - * `KEY`: use the `key` argument + * ``KEY``: use the *key* argument - * `BLOB`: use the `key_blob` argument + * ``BLOB``: use the *key_blob* argument -* `key` lookup key with `by=KEY` +* *key* lookup key with ``by=KEY`` - the `shard.key()` function may come handy to generate a sharding - key from custom strings. + the `vmod_directors.shard.key`_ method may come handy to generate a + sharding key from custom strings. -* `key_blob` lookup key with `by=BLOB` +* *key_blob* lookup key with ``by=BLOB`` Currently, this uses the first 4 bytes from the given blob in network byte order (big endian), left-padded with zeros for blobs smaller than 4 bytes. -* `alt` alternative backend selection +* *alt* alternative backend selection - Select the `alt`-th alternative backend for the given `key`. + Select the *alt*-th alternative backend for the given *key*. This is particularly useful for retries / restarts due to backend - errors: By setting `alt=req.restarts` or `alt=bereq.retries` with + errors: By setting ``alt=req.restarts`` or ``alt=bereq.retries`` with healthy=ALL, another server gets selected. - The rampup and warmup features are only active for `alt==0` + The rampup and warmup features are only active for ``alt==0`` -* `rampup` slow start for servers which just went healthy +* *rampup* slow start for servers which just went healthy - If `alt==0` and the chosen backend is in its rampup period, with a + If ``alt==0`` and the chosen backend is in its rampup period, with a probability proportional to the fraction of time since the backup became healthy to the rampup period, return the next alternative backend, unless this is also in its rampup period. The default rampup interval can be set per shard director using the - `set_rampup()` method or specifically per backend with the - `set_backend()` method. + `vmod_directors.shard.set_rampup`_ method or specifically per + backend with the `vmod_directors.shard.add_backend`_ method. -* `warmup` probabilistic alternative server selection +* *warmup* probabilistic alternative server selection possible values: -1, 0..1 - `-1`: use the warmup probability from the director definition + ``-1``: use the warmup probability from the director definition - Only used for `alt==0`: Sets the ratio of requests (0.0 to 1.0) that - goes to the next alternate backend to warm it up when the preferred - backend is healthy. Not active if any of the preferred or + Only used for ``alt==0``: Sets the ratio of requests (0.0 to 1.0) + that goes to the next alternate backend to warm it up when the + preferred backend is healthy. Not active if any of the preferred or alternative backend are in rampup. - `warmup=0.5` is a convenient way to spread the load for each key + ``warmup=0.5`` is a convenient way to spread the load for each key over two backends under normal operating conditions. -* `healthy` +* *healthy* * CHOSEN: Return a healthy backend if possible. - For `alt==0`, return the first healthy backend or none. + For ``alt==0``, return the first healthy backend or none. - For `alt > 0`, ignore the health state of backends skipped for + For ``alt > 0``, ignore the health state of backends skipped for alternative backend selection, then return the next healthy backend. If this does not exist, return the last healthy backend of those skipped or none. * IGNORE: Completely ignore backend health state - Just return the first or `alt`-th alternative backend, ignoring - health state. Ignore `rampup` and `warmup`. + Just return the first or *alt*-th alternative backend, ignoring + health state, *rampup* and *warmup*. * ALL: Check health state also for alternative backend selection - For `alt > 0`, return the `alt`-th alternative backend of all + For ``alt > 0``, return the *alt*-th alternative backend of all those healthy, the last healthy backend found or none. -* `resolve` +* *resolve* - default: `LAZY` in ``vcl_init{}``, `NOW` otherwise + default: ``LAZY`` in ``vcl_init{}``, ``NOW`` otherwise * ``NOW``: look up a backend and return it. @@ -535,9 +549,9 @@ is _not_ the order given when backends are added. parameter set affect the shard director instance for the backend request irrespective of where it is referenced. -* `param` +* *param* - Use or associate a parameter set. The value of the `param` argument + Use or associate a parameter set. The value of the *param* argument must be a call to the `vmod_directors.shard_param.use`_ method. default: as set by `vmod_directors.shard.associate`_ or unset. @@ -545,25 +559,27 @@ is _not_ the order given when backends are added. * for ``resolve=NOW`` take parameter defaults from the `vmod_directors.shard_param`_ parameter set - * for ``resolve=LAZY`` associate the `vmod_directors.shard_param`_ parameter - set for this backend request + * for ``resolve=LAZY`` associate the `vmod_directors.shard_param`_ + parameter set for this backend request Implementation notes for use of parameter sets with ``resolve=LAZY``: - * A `param` argument remains associated and any changes to the + * A *param* argument remains associated and any changes to the associated parameter set affect the sharding decision once the director resolves to an actual backend. - * If other parameter arguments are also given, they have preference - and are kept even if the parameter set given by the `param` - argument is subsequently changed within the same backend request. + * If other parameter arguments are also given, they have + preference and are kept even if the parameter set given by the + *param* argument is subsequently changed within the same backend + request. - * Each call to `vmod_directors.shard.backend`_ overrides any previous call. + * Each call to `vmod_directors.shard.backend`_ overrides any + previous call. $Method VOID .debug(INT) -`intentionally undocumented` +*intentionally undocumented* $Object shard_param() @@ -592,18 +608,18 @@ implement retries on alternative backends:: sub vcl_init { new shard_param = directors.shard_param(); - + new dir_A = directors.shard(); dir_A.add_backend(...); dir_A.reconfigure(shard_param); dir_A.associate(shard_param.use()); # <-- ! - + new dir_B = directors.shard(); dir_B.add_backend(...); dir_B.reconfigure(shard_param); dir_B.associate(shard_param.use()); # <-- ! } - + sub vcl_recv { if (...) { set req.backend_hint = dir_A.backend(resolve=LAZY); @@ -611,7 +627,7 @@ implement retries on alternative backends:: set req.backend_hint = dir_B.backend(resolve=LAZY); } } - + sub vcl_backend_fetch { # changes dir_A and dir_B behaviour shard_param.set(alt=bereq.retries); @@ -650,7 +666,7 @@ This method may not be used in client context $Method STRING .get_by() -Get a string representation of the `by` enum argument which denotes +Get a string representation of the *by* enum argument which denotes how a shard director using this parameter object would derive the shard key. See `vmod_directors.shard.backend`_. @@ -661,22 +677,22 @@ use. See `vmod_directors.shard.backend`_. $Method INT .get_alt() -Get the `alt` parameter which a shard director using this parameter +Get the *alt* parameter which a shard director using this parameter object would use. See `vmod_directors.shard.backend`_. $Method REAL .get_warmup() -Get the `warmup` parameter which a shard director using this parameter +Get the *warmup* parameter which a shard director using this parameter object would use. See `vmod_directors.shard.backend`_. $Method BOOL .get_rampup() -Get the `rampup` parameter which a shard director using this parameter +Get the *rampup* parameter which a shard director using this parameter object would use. See `vmod_directors.shard.backend`_. $Method STRING .get_healthy() -Get a string representation of the `healthy` enum argument which a +Get a string representation of the *healthy* enum argument which a shard director using this parameter object would use. See `vmod_directors.shard.backend`_. @@ -684,8 +700,8 @@ $Method BLOB .use() This method may only be used in backend context. -For use with the `param` argument of `vmod_directors.shard.backend`_ to associate -this shard parameter set with a shard director. +For use with the *param* argument of `vmod_directors.shard.backend`_ +to associate this shard parameter set with a shard director. $Function BACKEND lookup(STRING) diff --git a/lib/libvmod_proxy/vmod.vcc b/lib/libvmod_proxy/vmod.vcc index 2d0663582..d07456cb5 100644 --- a/lib/libvmod_proxy/vmod.vcc +++ b/lib/libvmod_proxy/vmod.vcc @@ -31,91 +31,96 @@ $Module proxy 3 "Varnish Module to extract TLV attributes from PROXYv2" DESCRIPTION =========== -`vmod_proxy` contains functions to extract proxy-protocol-v2 TLV attributes -as described in https://www.haproxy.org/download/1.8/doc/proxy-protocol.txt. - +*vmod_proxy* contains functions to extract proxy-protocol-v2 TLV +attributes as described in +https://www.haproxy.org/download/1.8/doc/proxy-protocol.txt. $Function STRING alpn() -Description - Extract ALPN attribute. -Example +Extract ALPN attribute. + +Example:: + set req.http.alpn = proxy.alpn(); $Function STRING authority() -Description - Extract authority attribute. This corresponds to SNI from a TLS - connection. -Example +Extract authority attribute. This corresponds to SNI from a TLS +connection. + +Example:: + set req.http.authority = proxy.authority(); $Function BOOL is_ssl() -Description - Report if proxy-protocol-v2 has SSL TLV. +Report if proxy-protocol-v2 has SSL TLV. + +Example:: -Example - | if (proxy.is_ssl()) { - | set req.http.ssl-version = proxy.ssl_version(); - | } + if (proxy.is_ssl()) { + set req.http.ssl-version = proxy.ssl_version(); + } $Function BOOL client_has_cert_sess() -Description - Report if the client provided a certificate at least once over the TLS - session this connection belongs to. +Report if the client provided a certificate at least once over the TLS +session this connection belongs to. $Function BOOL client_has_cert_conn() -Description - Report if the client provided a certificate over the current connection. +Report if the client provided a certificate over the current +connection. $Function INT ssl_verify_result() -Description - Report the SSL_get_verify_result from a TLS session. It only matters - if client_has_cert_sess() is true. Per default, value is set to 0 - (X509_V_OK). +Report the SSL_get_verify_result from a TLS session. It only matters +if client_has_cert_sess() is true. Per default, value is set to 0 +(X509_V_OK). -Example - | if (proxy.client_has_cert_sess() && proxy.ssl_verify_result() == 0) { - | set req.http.ssl-verify = "ok"; - | } +Example:: + + if (proxy.client_has_cert_sess() && proxy.ssl_verify_result() == 0) { + set req.http.ssl-verify = "ok"; + } $Function STRING ssl_version() -Description - Extract SSL version attribute. -Example +Extract SSL version attribute. + +Example:: + set req.http.ssl-version = proxy.ssl_version(); $Function STRING client_cert_cn() -Description - Extract the common name attribute of the client certificate's. -Example +Extract the common name attribute of the client certificate's. + +Example:: set req.http.cert-cn = proxy.client_cert_cn(); $Function STRING ssl_cipher() -Description - Extract the SSL cipher attribute. -Example +Extract the SSL cipher attribute. + +Example:: + set req.http.ssl-cipher = proxy.ssl_cipher(); $Function STRING cert_sign() -Description - Extract the certificate signature algorithm attribute. -Example +Extract the certificate signature algorithm attribute. + +Example:: + set req.http.cert-sign = proxy.cert_sign(); $Function STRING cert_key() -Description - Extract the certificate key algorithm attribute. -Example +Extract the certificate key algorithm attribute. + +Example:: + set req.http.cert-key = proxy.cert_key(); SEE ALSO diff --git a/lib/libvmod_purge/vmod.vcc b/lib/libvmod_purge/vmod.vcc index c8d8185cc..a0fafde83 100644 --- a/lib/libvmod_purge/vmod.vcc +++ b/lib/libvmod_purge/vmod.vcc @@ -31,10 +31,11 @@ $Module purge 3 "Varnish Purge Module" DESCRIPTION =========== -`vmod_purge` contains functions that offer a finer-grained control than the -``purge`` transition in ``vcl_recv``. The functions can only be called from -``vcl_hit`` or ``vcl_miss`` and they should in general be used in both to -ensure that all variants of a same object are taken care of. +*vmod_purge* contains functions that offer a finer-grained control +than ``return(purge)`` from ``vcl_recv{}``. The functions can only be +called from ``vcl_hit{}`` or ``vcl_miss{}`` and they should in general +be used in both to ensure that all variants of a same object are taken +care of. EXAMPLE ======= @@ -83,20 +84,23 @@ EXAMPLE $Function INT hard() -Description - This is equivalent to ``return(purge)`` but explicitly called from - ``vcl_hit`` and ``vcl_miss``. It returns the number of purged objects. -Example +This is equivalent to ``return(purge)`` but explicitly called from +``vcl_hit{}`` and ``vcl_miss{}``. It returns the number of purged +objects. + +Example:: + set req.http.purged = purge.hard(); $Function INT soft(DURATION ttl = 0, DURATION grace = -1, DURATION keep = -1) -Description - Sets the TTL, grace and keep. By default, TTL is set to 0 with grace - and keep periods left untouched. Setting a negative value for grace or - keep periods leaves them untouched. Setting all three parameters to - 0 is equivalent to a hard purge. It can only be called from ``vcl_hit`` - or ``vcl_miss``. It returns the number of soft-purged objects. +Sets the *ttl*, *grace* and *keep*. + +By default, *ttl* is set to 0 with *grace* and *keep* periods left +untouched. Setting a negative value for *grace* or *keep* periods +leaves them untouched. Setting all three parameters to ``0`` is +equivalent to a hard purge. It can only be called from ``vcl_hit{}`` +or ``vcl_miss{}``. It returns the number of soft-purged objects. SEE ALSO ======== diff --git a/lib/libvmod_unix/vmod.vcc b/lib/libvmod_unix/vmod.vcc index 38e48a7d3..0c1140872 100644 --- a/lib/libvmod_unix/vmod.vcc +++ b/lib/libvmod_unix/vmod.vcc @@ -48,15 +48,15 @@ Examples:: Obtaining the peer credentials is possible on a platform that supports one of the following: -* ``getpeereid(3)`` (such as FreeBSD and other BSD-derived systems) +* `getpeereid(3)` (such as FreeBSD and other BSD-derived systems) -* the socket option ``SO_PEERCRED`` for ``getsockopt(2)`` (Linux) +* the socket option ``SO_PEERCRED`` for `getsockopt(2)` (Linux) -* ``getpeerucred(3C)`` (SunOS and descendants) +* `getpeerucred(3C)` (SunOS and descendants) On SunOS and friends, the ``PRIV_PROC_INFO`` privilege set is added to the Varnish child process while the VMOD is loaded, see -``setppriv(2)``. +`setppriv(2)`. On most platforms, the value returned is the effective user or group that was valid when the peer process initiated the connection. @@ -82,32 +82,32 @@ ERRORS All functions in this VMOD are subject to the following constraints: -* None of them may be called in ``vcl_init`` or ``vcl_fini``. If one - of them is called in ``vcl_init``, then the VCL program will fail to - load, with an error message from the VMOD. +* None of them may be called in ``vcl_init{}`` or ``vcl_fini{}``. If + one of them is called in ``vcl_init{}``, then the VCL program will + fail to load, with an error message from the VMOD. * If called on a platform that is not supported, then VCL failure is invoked. An error message is written to the log (with the ``VCL_Error`` tag), and for all VCL subroutines except for - ``vcl_synth``, control is directed immediately to ``vcl_synth``, + ``vcl_synth{}``, control is directed immediately to ``vcl_synth{}``, with the response status set to 503 and the reason string set to "VCL failed". - If the failure occurs during ``vcl_synth``, then ``vcl_synth`` is - aborted, and the the response line "503 VCL failed" is sent. + If the failure occurs during ``vcl_synth{}``, then ``vcl_synth{}`` + is aborted, and the the response line "503 VCL failed" is sent. * If the current listener is not a Unix domain socket, or if the attempt to read credentials fails, then a ``VCL_Error`` message is - written to the log. The STRING functions (``vmod_user`` and - ``vmod_group``) return NULL, while the INT functions (``vmod_uid`` - and ``vmod_gid``) return -1. + written to the log. The STRING functions (`vmod_unix.user`_ and + `vmod_unix.group`_) return ``NULL``, while the INT functions + (`vmod_unix.uid`_ and `vmod_unix.gid`_) return -1. SEE ALSO ======== * :ref:`varnishd(1)` * :ref:`vcl(7)` -* ``getpeereid(3)`` -* ``getsockopt(2)`` -* ``getpeerucred(3C)`` -* ``setppriv(2)`` +* `getpeereid(3)` +* `getsockopt(2)` +* `getpeerucred(3C)` +* `setppriv(2)` From nils.goroll at uplex.de Tue Feb 26 17:51:08 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Tue, 26 Feb 2019 17:51:08 +0000 (UTC) Subject: [master] a720dc820 improve cache_req_body doc wording Message-ID: <20190226175109.0BD2A1174AF@lists.varnish-cache.org> commit a720dc820d25458a3076b9e2869b1a7ee4020b52 Author: Nils Goroll Date: Tue Feb 26 18:48:36 2019 +0100 improve cache_req_body doc wording diff --git a/lib/libvmod_std/vmod.vcc b/lib/libvmod_std/vmod.vcc index 39365af2a..a8468cfcf 100644 --- a/lib/libvmod_std/vmod.vcc +++ b/lib/libvmod_std/vmod.vcc @@ -299,11 +299,9 @@ $Function BOOL cache_req_body(BYTES size) Caches the request body if it is smaller than *size*. Returns ``true`` if the body was cached, ``false`` otherwise. -.. XXX fix wording: not the pass but rather the req body matters - -Normally the request body is not available after sending it to the -backend. By caching it is possible to retry pass operations, -e.g. ``POST`` and ``PUT``. +Normally the request body can only be sent once. Caching it enables +retrying backend requests with a request body, as usually the case +with ``POST`` and ``PUT``. Example:: From nils.goroll at uplex.de Tue Feb 26 21:18:06 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Tue, 26 Feb 2019 21:18:06 +0000 (UTC) Subject: [master] 89e2dceb8 fix forgotten VCL_INT limits Message-ID: <20190226211806.F11717589@lists.varnish-cache.org> commit 89e2dceb8e92fbe9be9399261245737a4ea3522e Author: Nils Goroll Date: Tue Feb 26 22:15:53 2019 +0100 fix forgotten VCL_INT limits we missed to change these when we changed the VCL_INT typedef from long to int64_t Should we add VCL_INT_MAX / VCL_INT_MIN (and for the other integer types, respectively)? diff --git a/lib/libvmod_std/vmod_std_conversions.c b/lib/libvmod_std/vmod_std_conversions.c index 659c148c3..a072cf5ef 100644 --- a/lib/libvmod_std/vmod_std_conversions.c +++ b/lib/libvmod_std/vmod_std_conversions.c @@ -81,7 +81,7 @@ vmod_integer(VRT_CTX, VCL_STRING p, VCL_INT i) return (i); r = trunc(r); - if (r > LONG_MAX || r < LONG_MIN) + if (r > INT64_MAX || r < INT64_MIN) return (i); return ((VCL_INT)r); @@ -158,7 +158,7 @@ vmod_real2integer(VRT_CTX, VCL_REAL r, VCL_INT i) if (!isfinite(r)) return (i); r = round(r); - if (r > LONG_MAX || r < LONG_MIN) + if (r > INT64_MAX || r < INT64_MIN) return(i); return ((VCL_INT)r); } @@ -182,7 +182,7 @@ vmod_time2integer(VRT_CTX, VCL_TIME t, VCL_INT i) if (!isfinite(t)) return (i); t = round(t); - if (t > LONG_MAX || t < LONG_MIN) + if (t > INT64_MAX || t < INT64_MIN) return(i); return ((VCL_INT)t); } From phk at FreeBSD.org Wed Feb 27 09:07:07 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 27 Feb 2019 09:07:07 +0000 (UTC) Subject: [master] dee47cc47 VSL a SLT_RespProtocol HTTP/2.0 when we deliver by H2 Message-ID: <20190227090707.76AA910559D@lists.varnish-cache.org> commit dee47cc47b52dd8af11cb073661e9a757944aa7c Author: Poul-Henning Kamp Date: Wed Feb 27 09:05:08 2019 +0000 VSL a SLT_RespProtocol HTTP/2.0 when we deliver by H2 Closes #2905 diff --git a/bin/varnishd/http2/cache_http2_deliver.c b/bin/varnishd/http2/cache_http2_deliver.c index f19565011..20609e8e7 100644 --- a/bin/varnishd/http2/cache_http2_deliver.c +++ b/bin/varnishd/http2/cache_http2_deliver.c @@ -235,6 +235,7 @@ h2_deliver(struct req *req, struct boc *boc, int sendbody) sp = req->sp; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + VSLb(req->vsl, SLT_RespProtocol, "HTTP/2.0"); l = WS_Reserve(req->ws, 0); AN(VSB_new(&resp, req->ws->f, l, VSB_FIXEDLEN)); From nils.goroll at uplex.de Wed Feb 27 10:32:07 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 27 Feb 2019 10:32:07 +0000 (UTC) Subject: [master] 3207f0dad vtest: handle empty headers when reading the response Message-ID: <20190227103207.8EA22106CB0@lists.varnish-cache.org> commit 3207f0dad2212b02468e417ba3f39cc9e951df53 Author: Nils Goroll Date: Wed Feb 27 11:19:45 2019 +0100 vtest: handle empty headers when reading the response vtest would segfault due to a null pointer access on empty headers diff --git a/bin/varnishtest/vtc_http.c b/bin/varnishtest/vtc_http.c index d0e6921da..349eb596b 100644 --- a/bin/varnishtest/vtc_http.c +++ b/bin/varnishtest/vtc_http.c @@ -706,6 +706,8 @@ cmd_http_rxresp(CMD_ARGS) "Multiple Content-Length headers.\n"); if (!has_obj) return; + if (!hp->resp[0] || !hp->resp[1]) + return; else if (!strcmp(hp->resp[1], "200")) http_swallow_body(hp, hp->resp, 1, 0); else From nils.goroll at uplex.de Wed Feb 27 16:54:09 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 27 Feb 2019 16:54:09 +0000 (UTC) Subject: [master] 898b2fe59 max out precision of VNUMpfx and test for it Message-ID: <20190227165409.4D82910E53C@lists.varnish-cache.org> commit 898b2fe595571a8e9e8d106420be93d9ba81253c Author: Nils Goroll Date: Wed Feb 27 17:37:06 2019 +0100 max out precision of VNUMpfx and test for it the previous code would round 9007199254740991 to 9007199254740992 Tested on linux and the four vtest SunOS variants diff --git a/lib/libvarnish/vnum.c b/lib/libvarnish/vnum.c index 43baa7da5..9502e9dc4 100644 --- a/lib/libvarnish/vnum.c +++ b/lib/libvarnish/vnum.c @@ -69,7 +69,8 @@ VNUMpfx(const char *p, const char **t) for (; *p != '\0'; p++) { if (vct_isdigit(*p)) { - m = m * 10. + *p - '0'; + m *= 10.; + m += *p - '0'; e = ne; if (e) ne = e - 1.0; @@ -285,6 +286,12 @@ static struct test_case { { "1PB ", (uintmax_t)0, (uintmax_t)1125899906842624ULL}, { "1.3 PB", (uintmax_t)0, (uintmax_t)1463669878895411ULL}, + // highest integers not rounded for double conversion + { "9007199254740988", (uintmax_t)0, (uintmax_t)9007199254740988ULL}, + { "9007199254740989", (uintmax_t)0, (uintmax_t)9007199254740989ULL}, + { "9007199254740990", (uintmax_t)0, (uintmax_t)9007199254740990ULL}, + { "9007199254740991", (uintmax_t)0, (uintmax_t)9007199254740991ULL}, + { "1%", (uintmax_t)1024, (uintmax_t)10 }, { "2%", (uintmax_t)1024, (uintmax_t)20 }, { "3%", (uintmax_t)1024, (uintmax_t)31 }, From nils.goroll at uplex.de Wed Feb 27 16:54:09 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 27 Feb 2019 16:54:09 +0000 (UTC) Subject: [master] 0f7f757c4 sensible limits for VCL_INT and VCL_BYTES Message-ID: <20190227165409.6947C10E53F@lists.varnish-cache.org> commit 0f7f757c478351e7a30c9820f7542b868743b7b8 Author: Nils Goroll Date: Wed Feb 27 15:40:38 2019 +0100 sensible limits for VCL_INT and VCL_BYTES diff --git a/include/vrt.h b/include/vrt.h index 72c9c4d78..2b377947a 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -211,6 +211,21 @@ typedef vtim_real VCL_TIME; typedef struct vcl * VCL_VCL; typedef void VCL_VOID; +/* + * technically, as our VCL_INT is int64_t, its limits are INT64_MIN/INT64_MAX. + * + * Yet, for conversions, we use VNUMpfx with a double intermediate, so above + * 2^53 we see rounding errors. In order to catch a potential floor rounding + * error, we make our limit 2^53-1 + * + * Ref: https://stackoverflow.com/a/1848762 + */ +#define VCL_INT_MAX ((INT64_C(1)<<53)-1) +#define VCL_INT_MIN (-VCL_INT_MAX) + +#define VCL_BYTES_MAX VCL_INT_MAX +#define VCL_BYTES_MIN 0 + struct vrt_type { unsigned magic; #define VRT_TYPE_MAGIC 0xa943bc32 diff --git a/lib/libvmod_std/vmod_std_conversions.c b/lib/libvmod_std/vmod_std_conversions.c index a072cf5ef..ed85bed0f 100644 --- a/lib/libvmod_std/vmod_std_conversions.c +++ b/lib/libvmod_std/vmod_std_conversions.c @@ -81,7 +81,7 @@ vmod_integer(VRT_CTX, VCL_STRING p, VCL_INT i) return (i); r = trunc(r); - if (r > INT64_MAX || r < INT64_MIN) + if (r > VCL_INT_MAX || r < VCL_INT_MIN) return (i); return ((VCL_INT)r); @@ -158,7 +158,7 @@ vmod_real2integer(VRT_CTX, VCL_REAL r, VCL_INT i) if (!isfinite(r)) return (i); r = round(r); - if (r > INT64_MAX || r < INT64_MIN) + if (r > VCL_INT_MAX || r < VCL_INT_MIN) return(i); return ((VCL_INT)r); } @@ -182,7 +182,7 @@ vmod_time2integer(VRT_CTX, VCL_TIME t, VCL_INT i) if (!isfinite(t)) return (i); t = round(t); - if (t > INT64_MAX || t < INT64_MIN) + if (t > VCL_INT_MAX || t < VCL_INT_MIN) return(i); return ((VCL_INT)t); }