From fgsch at lodoss.net Fri Mar 1 11:35:09 2019 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Fri, 1 Mar 2019 11:35:09 +0000 (UTC) Subject: [master] f06c02c93 Trailing grave accents and whitespace Message-ID: <20190301113509.2C345116F46@lists.varnish-cache.org> commit f06c02c93b8deffed6b214d1893bcb84351a4374 Author: Federico G. Schwindt Date: Fri Mar 1 11:29:47 2019 +0000 Trailing grave accents and whitespace diff --git a/.gitignore b/.gitignore index 6a6eb8f57..d24c7b41c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -# Matches ALL Makefile and Makefile.in occurrences +# Matches ALL Makefile and Makefile.in occurrences Makefile Makefile.in diff --git a/doc/changes.rst b/doc/changes.rst index 7173b6316..8d7d253e6 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -260,7 +260,7 @@ Fixed bugs .. _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 +.. _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 diff --git a/doc/sphinx/reference/vtla.rst b/doc/sphinx/reference/vtla.rst index ba80b8958..1fdfb4abf 100644 --- a/doc/sphinx/reference/vtla.rst +++ b/doc/sphinx/reference/vtla.rst @@ -14,107 +14,107 @@ This page tells you what we use them for, if & when we remember to add them... VAV - Varnish Arg Vector -- Argv parsing. + Varnish Arg Vector -- Argv parsing. VBE Varnish Back End -- Code for contacting backends - (bin/varnishd/cache_backend.c) + (bin/varnishd/cache_backend.c) VBP Varnish Backend Polling -- Health checks of backends - (bin/varnishd/cache_backend_poll.c) + (bin/varnishd/cache_backend_poll.c) VCA Varnish Connection Acceptor -- The code that receives/accepts the - TCP connections (bin/varnishd/cache_acceptor.c) + TCP connections (bin/varnishd/cache_acceptor.c) VCC - VCL to C Compiler -- The code that compiles VCL to C code. (lib/libvcl) + VCL to C Compiler -- The code that compiles VCL to C code. (lib/libvcl) VCL Varnish Configuration Language -- The domain-specific programming - language used for configuring a varnishd. + language used for configuring a varnishd. VCT - Varnish CType(3) -- Character classification for RFC2616 and XML parsing. + Varnish CType(3) -- Character classification for RFC2616 and XML parsing. VDD Varnish (Core) Developer Day -- Quarterly invite-only meeting strictly - for Varnish core (C) developers, packagers and VMOD hackers. + for Varnish core (C) developers, packagers and VMOD hackers. VEV - Varnish EVent -- library functions to implement a simple event-dispatcher. + Varnish EVent -- library functions to implement a simple event-dispatcher. VGB Varnish Governing Board -- May or may not exist. - If you need to ask, you are not on it. + If you need to ask, you are not on it. VGC - Varnish Generated Code -- Code generated by VCC from VCL. + Varnish Generated Code -- Code generated by VCC from VCL. VIN - Varnish Instance Naming -- Resolution of -n arguments. + Varnish Instance Naming -- Resolution of -n arguments. VLU Varnish Line Up -- library functions to collect stream of bytes - into lines for processing. (lib/libvarnish/vlu.c) + into lines for processing. (lib/libvarnish/vlu.c) VRE Varnish Regular Expression -- library functions for regular expression - based matching and substring replacement. (lib/libvarnish/vre.c) + based matching and substring replacement. (lib/libvarnish/vre.c) VRT Varnish Run Time -- functions called from compiled code. - (bin/varnishd/cache_vrt.c) + (bin/varnishd/cache_vrt.c) VRY VaRY -- Related to processing of Vary: HTTP headers. - (bin/varnishd/cache_vary.c) + (bin/varnishd/cache_vary.c) VSL Varnish Shared memory Log -- The log written into the shared - memory segment for varnish{log,ncsa,top,hist} to see. + memory segment for varnish{log,ncsa,top,hist} to see. VSB Varnish string Buffer -- a copy of the FreeBSD "sbuf" library, - for safe string handling. + for safe string handling. VSC Varnish Statistics Counter -- counters for various stats, - exposed via varnishapi. + exposed via varnishapi. VSS Varnish Session Stuff -- library functions to wrap DNS/TCP. - (lib/libvarnish/vss.c) + (lib/libvarnish/vss.c) VTC - Varnish Test Code -- a test-specification for the varnishtest program. + Varnish Test Code -- a test-specification for the varnishtest program. VTE Varnish Turbo Encabulator VTLA - Varnish Three Letter Acronym -- No rule without an exception. + Varnish Three Letter Acronym -- No rule without an exception. VUG Varnish User Group meeting -- Half-yearly event where the users and developers of Varnish Cache gather to share experiences and plan - future development. + future development. VWx - Varnish Waiter 'x' -- A code module to monitor idle sessions. + Varnish Waiter 'x' -- A code module to monitor idle sessions. VWE - Varnish Waiter Epoll -- epoll(2) (linux) based waiter module. + Varnish Waiter Epoll -- epoll(2) (linux) based waiter module. VWK - Varnish Waiter Kqueue -- kqueue(2) (freebsd) based waiter module. + Varnish Waiter Kqueue -- kqueue(2) (freebsd) based waiter module. VWP - Varnish Waiter Poll -- poll(2) based waiter module. + Varnish Waiter Poll -- poll(2) based waiter module. VWS - Varnish Waiter Solaris -- Solaris ports(2) based waiter module. + Varnish Waiter Solaris -- Solaris ports(2) based waiter module. diff --git a/lib/libvarnishapi/Makefile.am b/lib/libvarnishapi/Makefile.am index a94efee04..59ac166b0 100644 --- a/lib/libvarnishapi/Makefile.am +++ b/lib/libvarnishapi/Makefile.am @@ -99,7 +99,7 @@ vxp_test_CFLAGS = \ vxp_test_LDADD = @PCRE_LIBS@ \ ${RT_LIBS} ${LIBM} ${PTHREAD_LIBS} -TESTS = vsl_glob_test +TESTS = vsl_glob_test noinst_PROGRAMS += vsl_glob_test diff --git a/lib/libvmod_std/vmod.vcc b/lib/libvmod_std/vmod.vcc index a8468cfcf..b3d994618 100644 --- a/lib/libvmod_std/vmod.vcc +++ b/lib/libvmod_std/vmod.vcc @@ -141,7 +141,7 @@ Example:: if (std.file_exists("/etc/return_503")) { return (synth(503, "Varnish is in maintenance")); - }`` + } $Function VOID collect(HEADER hdr, STRING sep=", ") From geoff at uplex.de Sun Mar 3 16:31:06 2019 From: geoff at uplex.de (Geoff Simmons) Date: Sun, 3 Mar 2019 16:31:06 +0000 (UTC) Subject: [master] 259d36f27 Start filling out the "Chnages" doc for the March 2019 release. Message-ID: <20190303163106.5187510955A@lists.varnish-cache.org> commit 259d36f27dffeea90ccb9daabcd8993bf13ccadf Author: Geoff Simmons Date: Sun Mar 3 17:30:14 2019 +0100 Start filling out the "Chnages" doc for the March 2019 release. diff --git a/doc/sphinx/whats-new/changes-trunk.rst b/doc/sphinx/whats-new/changes-trunk.rst index 7bac84756..d3bf72a6e 100644 --- a/doc/sphinx/whats-new/changes-trunk.rst +++ b/doc/sphinx/whats-new/changes-trunk.rst @@ -20,21 +20,46 @@ merged, may be found in the `change log`_. varnishd ======== +Cache lookups have undergone a number of optimizations, among them to +reduce lock contention, and to shorten and simplify the critical +section of lookup code. + +We have added a "watchdog" for thread pools that will panic the worker +process, causing it to restart, if scheduling tasks onto worker +threads appears to be deadlocking. The length of time until the panic +is set by the :ref:`ref_param_thread_pool_watchdog` parameter. If this +happens, it probably means that thread pools are too small, and you +should consider increasing the parameters +:ref:`ref_param_thread_pool_min`, :ref:`ref_param_thread_pool_max` +and/or :ref:`ref_param_thread_pools`. + Parameters ~~~~~~~~~~ -**XXX changes in -p parameters** +Some parameters that have been long deprecated are now retired. Now +you must use these parameters: + +* :ref:`ref_param_vsl_reclen` (in place of ``shm_reclen``) + +* :ref:`ref_param_vcl_path` (in place of ``vcl_dir``) + +* :ref:`ref_param_vmod_path` (in place of ``vmod_dir``) + +Added :ref:`ref_param_thread_pool_watchdog`, see above. Other changes in varnishd ~~~~~~~~~~~~~~~~~~~~~~~~~ +The VCL syntax version is now displayed in a panic message, as 41 for +VCL 4.1 and 40 for VCL 4.0. + Changes to VCL ============== VCL variables ~~~~~~~~~~~~~ -**XXX new, deprecated or removed variables, or changed semantics** +Added ``req.is_hitmiss`` and ``req.is_hitpass``, see :ref:`vcl(7)`. Other changes to VCL ~~~~~~~~~~~~~~~~~~~~ @@ -42,17 +67,18 @@ Other changes to VCL VMODs ===== -**XXX changes in the bundled VMODs** +Added the function :ref:`vmod_directors.lookup`, only for use in +``vcl_init`` or ``vcl_fini``. -varnishlog -========== +varnishlog(1) and vsl(7) +======================== -**XXX changes concerning varnishlog(1) and/or vsl(7)** +Timing information is now uniformly reported with microsecond +precision. This affects the tags ``ExpKill`` and ``ExpRearm`` +(previously with nanosecond precision). -varnishadm -========== - -**XXX changes concerning varnishadm(1) and/or varnish-cli(7)** +varnishadm(1) and varnish-cli(7) +================================ JSON responses, requested with the ``-j`` option, are now possible for the following commands (see :ref:`varnish-cli(7)`): @@ -64,6 +90,62 @@ the following commands (see :ref:`varnish-cli(7)`): * ``storage.list -j`` * ``panic.show -j`` +For automated parsing of CLI responses (``varnishadm`` output), we +recommend the use of JSON format. + +The "probe message" field in the output of ``backend.list`` (in the +``probe_message`` field of JSON format, or the ``Probe`` column of +non-JSON output) has been changed to display ``X/Y state``, where: + +* Integer ``X`` is the number of good probes in the most recent + window; or if the backend in question is a director, the number of + healthy backends accessed via the director. + +* Integer ``Y`` is the window in which the threshold for overall + health of the backend is defined (from the ``.window`` field of a + probe, see :ref:`vcl(7)`); or in the case of a director, the total + number of backends accessed via the director. + +* ``state`` is one of the strings ``"good"`` or ``"bad"``, for the + overall health of the backend or director. + +In the ``probe_message`` field of ``backend.list -j`` output, this +appears as the array ``[X, Y, state]``. + +The non-JSON output of ``vcl.list`` has been changed: + +* The ``state`` and ``temperature`` fields appear in separate columns + (previously combined in one column). + +* The optional column showing the relationships between labels and VCL + configurations (when labels are in use) has been separated into two + columns. + +See :ref:`varnish-cli(7)` for details. In the JSON output for +``vcl.list -j``, this information appears in separate fields. + +The width of columns in ``backend.list`` and ``vcl.list`` output +(non-JSON) is now dynamic, to fit the width of the terminal window. + +Bans may now be defined with respect to ``obj.ttl``, ``obj.age``, +``obj.grace`` and ``obj.keep``, referring to the expiration and age +properties of the cached object. A ban expression may also be defined +with one of the comparison operators ``<``, ``<=``, ``>`` and ``>=``; +these may only be used with one of the new duration variables for +bans. Duration constants (such as ``5m`` for five minutes of ``3h`` +for three hours) may be used in the ```` position against which +these objects are compared in a ban expression. + +``obj.ttl`` and ``obj.age`` are evaluated with respect to the time at +which the ban was defined, while ``obj.grace`` and ``obj.keep`` are +evaluated as the grace or keep time assigned to the object. So to issue +a ban for objects whose TTL expires more than 5 hours from now and +whose keep parameter is greater than 3 hours, use this expression:: + + obj.ttl > 5h && obj.keep > 3h + +See :ref:`vcl(7)` and :ref:`users-guide-purging` for details. + varnishstat =========== @@ -77,7 +159,7 @@ varnishtest Changes for developers and VMOD authors ======================================= -**XXX changes concerning VRT, the public APIs, source code organization, -builds etc.** +Python tools that generate code now prefer python 3 over python 2, +when availabale. *eof* From geoff at uplex.de Sun Mar 3 17:27:05 2019 From: geoff at uplex.de (Geoff Simmons) Date: Sun, 3 Mar 2019 17:27:05 +0000 (UTC) Subject: [master] 93e21e094 Document param.reset in "Changes", and add some subsection headers. Message-ID: <20190303172705.72F3710A514@lists.varnish-cache.org> commit 93e21e094e1a90b63ff41033afa4fadf48e8a0a1 Author: Geoff Simmons Date: Sun Mar 3 18:25:43 2019 +0100 Document param.reset in "Changes", and add some subsection headers. diff --git a/doc/sphinx/whats-new/changes-trunk.rst b/doc/sphinx/whats-new/changes-trunk.rst index d3bf72a6e..dc385ec67 100644 --- a/doc/sphinx/whats-new/changes-trunk.rst +++ b/doc/sphinx/whats-new/changes-trunk.rst @@ -80,6 +80,9 @@ precision. This affects the tags ``ExpKill`` and ``ExpRearm`` varnishadm(1) and varnish-cli(7) ================================ +JSON output +~~~~~~~~~~~ + JSON responses, requested with the ``-j`` option, are now possible for the following commands (see :ref:`varnish-cli(7)`): @@ -93,6 +96,15 @@ the following commands (see :ref:`varnish-cli(7)`): For automated parsing of CLI responses (``varnishadm`` output), we recommend the use of JSON format. +``param.reset `` +~~~~~~~~~~~~~~~~~~~~~~~ + +Added the command ``param.reset`` to reset a parameter's value to its +default, see :ref:`varnish-cli(7)`. + +Listing backends and VCLs +~~~~~~~~~~~~~~~~~~~~~~~~~ + The "probe message" field in the output of ``backend.list`` (in the ``probe_message`` field of JSON format, or the ``Probe`` column of non-JSON output) has been changed to display ``X/Y state``, where: @@ -127,6 +139,9 @@ See :ref:`varnish-cli(7)` for details. In the JSON output for The width of columns in ``backend.list`` and ``vcl.list`` output (non-JSON) is now dynamic, to fit the width of the terminal window. +Banning by expiration parameters +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + Bans may now be defined with respect to ``obj.ttl``, ``obj.age``, ``obj.grace`` and ``obj.keep``, referring to the expiration and age properties of the cached object. A ban expression may also be defined From geoff at uplex.de Sun Mar 3 17:48:06 2019 From: geoff at uplex.de (Geoff Simmons) Date: Sun, 3 Mar 2019 17:48:06 +0000 (UTC) Subject: [master] c556a9426 Update "Changes" concerning VSL/VUT. Message-ID: <20190303174806.7F97F10AE58@lists.varnish-cache.org> commit c556a9426deb7fe830ca53172ce8a639967828b7 Author: Geoff Simmons Date: Sun Mar 3 18:47:15 2019 +0100 Update "Changes" concerning VSL/VUT. diff --git a/doc/sphinx/whats-new/changes-trunk.rst b/doc/sphinx/whats-new/changes-trunk.rst index dc385ec67..834456722 100644 --- a/doc/sphinx/whats-new/changes-trunk.rst +++ b/doc/sphinx/whats-new/changes-trunk.rst @@ -70,12 +70,25 @@ VMODs Added the function :ref:`vmod_directors.lookup`, only for use in ``vcl_init`` or ``vcl_fini``. -varnishlog(1) and vsl(7) -======================== - -Timing information is now uniformly reported with microsecond -precision. This affects the tags ``ExpKill`` and ``ExpRearm`` -(previously with nanosecond precision). +varnishlog(1), varnishncsa(1) and vsl(7) +======================================== + +The performance of bundled log readers, including ``varnishlog`` and +``varnishncsa`` (and any tool using the internal VUT interface for +Varnish utilities) has been improved. They continue reading log +contents in bulk as long as more contents are known to be available, +not stopping as frequently (and unnecessarily) to check the status of +the shared memory mapping. + +``varnishlog`` and ``varnishncsa`` now have the ``-R`` command-line +option for rate-limiting, to limit the number of log transactions read +per unit time. This can make it less likely for log reads to fall +behind and fail with overrun errors under heavy loads. See +:ref:`varnishlog(1)` and :ref:`varnishncsa(1)` for details. + +Timing information is now uniformly reported in the log with +microsecond precision. This affects the tags ``ExpKill`` and +``ExpRearm`` (previously with nanosecond precision). varnishadm(1) and varnish-cli(7) ================================ From geoff at uplex.de Sun Mar 3 17:56:06 2019 From: geoff at uplex.de (Geoff Simmons) Date: Sun, 3 Mar 2019 17:56:06 +0000 (UTC) Subject: [master] 7b2fe3270 Mention relaxed restrictions on UDS backend paths in "Changes". Message-ID: <20190303175606.7474E10C271@lists.varnish-cache.org> commit 7b2fe3270413f7e12c51ae1986f7723ea3b2b612 Author: Geoff Simmons Date: Sun Mar 3 18:54:35 2019 +0100 Mention relaxed restrictions on UDS backend paths in "Changes". diff --git a/doc/sphinx/whats-new/changes-trunk.rst b/doc/sphinx/whats-new/changes-trunk.rst index 834456722..00678f117 100644 --- a/doc/sphinx/whats-new/changes-trunk.rst +++ b/doc/sphinx/whats-new/changes-trunk.rst @@ -64,6 +64,15 @@ Added ``req.is_hitmiss`` and ``req.is_hitpass``, see :ref:`vcl(7)`. Other changes to VCL ~~~~~~~~~~~~~~~~~~~~ +When the ``.path`` field of a backend declaration is used to define a +Unix domain socket as the backend address, and the socket file does +not exist or is not accessible at VCL load time, then a warning is +issued, but the VCL load is allowed to continue. Previously, the load +would fail in that case. This makes it easier to start the peer +component listening at the socket, or set the socket's permissions, +after starting Varnish or loading VCL. If the socket still cannot be +accessed when a fetch is attempted, then the fetch fails. + VMODs ===== From geoff at uplex.de Sun Mar 3 18:30:10 2019 From: geoff at uplex.de (Geoff Simmons) Date: Sun, 3 Mar 2019 18:30:10 +0000 (UTC) Subject: [master] ee0322f81 In "Changes", clarify that CLI JSON support has been extended. Message-ID: <20190303183010.5063710CC44@lists.varnish-cache.org> commit ee0322f81fad3f3e0c755c54420ffab2864ec712 Author: Geoff Simmons Date: Sun Mar 3 19:28:10 2019 +0100 In "Changes", clarify that CLI JSON support has been extended. It may have sounded like it's been added for the first time. diff --git a/doc/sphinx/whats-new/changes-trunk.rst b/doc/sphinx/whats-new/changes-trunk.rst index 00678f117..db6f963a1 100644 --- a/doc/sphinx/whats-new/changes-trunk.rst +++ b/doc/sphinx/whats-new/changes-trunk.rst @@ -115,6 +115,9 @@ the following commands (see :ref:`varnish-cli(7)`): * ``storage.list -j`` * ``panic.show -j`` +The ``-j`` option was already available for ``backend.list``, ``ping`` +and ``help`` in previous versions. + For automated parsing of CLI responses (``varnishadm`` output), we recommend the use of JSON format. From geoff at uplex.de Sun Mar 3 18:30:10 2019 From: geoff at uplex.de (Geoff Simmons) Date: Sun, 3 Mar 2019 18:30:10 +0000 (UTC) Subject: [master] b309be935 Mention new VSC counters in "Changes". Message-ID: <20190303183010.71A2210CC47@lists.varnish-cache.org> commit b309be93524744ad1b90aa854270bd2025275785 Author: Geoff Simmons Date: Sun Mar 3 19:29:19 2019 +0100 Mention new VSC counters in "Changes". diff --git a/doc/sphinx/whats-new/changes-trunk.rst b/doc/sphinx/whats-new/changes-trunk.rst index db6f963a1..d2d28d8c9 100644 --- a/doc/sphinx/whats-new/changes-trunk.rst +++ b/doc/sphinx/whats-new/changes-trunk.rst @@ -186,10 +186,11 @@ whose keep parameter is greater than 3 hours, use this expression:: See :ref:`vcl(7)` and :ref:`users-guide-purging` for details. -varnishstat -=========== +varnishstat(1) and varnish-counters(7) +====================================== -**XXX changes concerning varnishstat(1) and/or varnish-counters(7)** +Added the ``ws_*_overflow`` and ``client_resp_500`` counters to better +diagnose workspace overflow issues, see :ref:`varnish-counters(7)`. varnishtest =========== From geoff at uplex.de Sun Mar 3 19:25:07 2019 From: geoff at uplex.de (Geoff Simmons) Date: Sun, 3 Mar 2019 19:25:07 +0000 (UTC) Subject: [master] 7e913e545 Document debug:+vcl_keep and its use for varnishtest in "Changes". Message-ID: <20190303192507.19C3D10DD07@lists.varnish-cache.org> commit 7e913e545fe7b0a42ad57802a9ce77a04f646f2e Author: Geoff Simmons Date: Sun Mar 3 20:24:03 2019 +0100 Document debug:+vcl_keep and its use for varnishtest in "Changes". diff --git a/doc/sphinx/whats-new/changes-trunk.rst b/doc/sphinx/whats-new/changes-trunk.rst index d2d28d8c9..ec61ffc26 100644 --- a/doc/sphinx/whats-new/changes-trunk.rst +++ b/doc/sphinx/whats-new/changes-trunk.rst @@ -47,6 +47,11 @@ you must use these parameters: Added :ref:`ref_param_thread_pool_watchdog`, see above. +The :ref:`ref_param_debug` parameter now has a flag ``vcl_keep``. When +the flag is turned on, C sources and shared object libraries that were +generated from VCL sources are retained in the Varnish working +directory (see the notes about ``varnishtest`` below). + Other changes in varnishd ~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -195,7 +200,12 @@ diagnose workspace overflow issues, see :ref:`varnish-counters(7)`. varnishtest =========== -**XXX changes concerning varnishtest(1) and/or vtc(7)** +When :ref:`varnishtest(1)` is invoked with either of the ``-L`` or +``-l`` options to retain the temporary directory after tests, the +``vcl_keep`` flag for the :ref:`ref_param_debug` is switched on (see +`Parameters`_ above). This means that C sources and shared objects +generated from VCL can also be inspected after a test. By default, the +temporary directory is deleted after each test. Changes for developers and VMOD authors ======================================= From geoff at uplex.de Sun Mar 3 19:40:08 2019 From: geoff at uplex.de (Geoff Simmons) Date: Sun, 3 Mar 2019 19:40:08 +0000 (UTC) Subject: [master] 0cbf691f2 Mention the change of varnishstat curses refresh in "Changes". Message-ID: <20190303194008.0A87E10E217@lists.varnish-cache.org> commit 0cbf691f21af3984c68522e3f1278d7e1d7bd91a Author: Geoff Simmons Date: Sun Mar 3 20:37:47 2019 +0100 Mention the change of varnishstat curses refresh in "Changes". diff --git a/doc/sphinx/whats-new/changes-trunk.rst b/doc/sphinx/whats-new/changes-trunk.rst index ec61ffc26..a94324cc8 100644 --- a/doc/sphinx/whats-new/changes-trunk.rst +++ b/doc/sphinx/whats-new/changes-trunk.rst @@ -197,6 +197,10 @@ varnishstat(1) and varnish-counters(7) Added the ``ws_*_overflow`` and ``client_resp_500`` counters to better diagnose workspace overflow issues, see :ref:`varnish-counters(7)`. +In curses mode, :ref:`varnishstat(1)` now allows use of the ``+`` and +``-`` keys to increase or decrease the refresh rate of the curses +window. + varnishtest =========== From geoff at uplex.de Sun Mar 3 20:20:07 2019 From: geoff at uplex.de (Geoff Simmons) Date: Sun, 3 Mar 2019 20:20:07 +0000 (UTC) Subject: [master] ea9d3f6a9 Start filling in the "Upgrading" socument for the March 2019 release. Message-ID: <20190303202007.47BCA10EE04@lists.varnish-cache.org> commit ea9d3f6a95cae8646faac9fd7f8772d148af79b7 Author: Geoff Simmons Date: Sun Mar 3 21:19:16 2019 +0100 Start filling in the "Upgrading" socument for the March 2019 release. diff --git a/doc/sphinx/whats-new/changes-trunk.rst b/doc/sphinx/whats-new/changes-trunk.rst index a94324cc8..04dc342a8 100644 --- a/doc/sphinx/whats-new/changes-trunk.rst +++ b/doc/sphinx/whats-new/changes-trunk.rst @@ -107,6 +107,8 @@ microsecond precision. This affects the tags ``ExpKill`` and varnishadm(1) and varnish-cli(7) ================================ +.. _whatsnew_changes_cli_json: + JSON output ~~~~~~~~~~~ @@ -132,6 +134,8 @@ recommend the use of JSON format. Added the command ``param.reset`` to reset a parameter's value to its default, see :ref:`varnish-cli(7)`. +.. _whatsnew_changes_vcl_list_backend_list: + Listing backends and VCLs ~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/doc/sphinx/whats-new/upgrading-trunk.rst b/doc/sphinx/whats-new/upgrading-trunk.rst index 6143fde99..e46362048 100644 --- a/doc/sphinx/whats-new/upgrading-trunk.rst +++ b/doc/sphinx/whats-new/upgrading-trunk.rst @@ -30,4 +30,45 @@ to:** * Changes in public APIs that may require changes in VMODs or VAPI/VUT clients. +VCL +=== + +VCL programs for Varnish 6.1 can be expected to run without changes in +the new version. + +A VCL load will now issue a warning, but does not fail as previously, +if a backend declaration uses the ``.path`` field to specify a Unix +domain socket, but the socket file does not exist or is not accessible +at VCL load time. This makes it possible to start the peer component +listening at the socket, or set its permissions, after Varnish starts +or the VCL is loaded. Backend fetches fail if the socket is not +accessible by the time the fetch is attempted. + +Runtime parameters +================== + +Some varnishd ``-p`` parameters that have been deprecated for some +time have been removed. If you haven't changed them yet, you have to +now. These are: + +* ``shm_reclen`` -- use :ref:`ref_param_vsl_reclen` instead + +* ``vcl_dir`` -- use :ref:`ref_param_vcl_path` instead + +* ``vmod_dir`` -- use :ref:`ref_param_vmod_path` instead + +varnishadm and the CLI +====================== + +The output formats of the ``vcl.list`` and ``backend.list`` commands +have changed, see :ref:`whatsnew_changes_vcl_list_backend_list` and +:ref:`varnish-cli(7)` for details. In non-JSON mode, the width of +columns in ``backend.list`` and ``vcl.list`` output is now dynamic, to +fit the width of the terminal window. + +The ``-j`` option for JSON output has been added to a number of +commands, see :ref:`whatsnew_changes_cli_json` and +:ref:`varnish-cli(7)`. We recommend the use of JSON format for +automated parsing of CLI responses (:ref:`varnishadm(1)` output). + *eof* From phk at FreeBSD.org Mon Mar 4 09:40:08 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 4 Mar 2019 09:40:08 +0000 (UTC) Subject: [master] 141ea56a4 Add the VCF - aka "The CatFlap" Message-ID: <20190304094008.B40DC7F9B@lists.varnish-cache.org> commit 141ea56a43459d2c1b29d2a299ff9b67356228c6 Author: Poul-Henning Kamp Date: Mon Mar 4 09:37:24 2019 +0000 Add the VCF - aka "The CatFlap" I have reimplemented this based on Nils's #2858, because I found it too complex and intrusive. (In particular we try to avoid unions in Varnish). Testcase m00051 by: Nils Goroll Closes: #2858 diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 2018c9bce..163c52948 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -101,6 +101,7 @@ struct sess; struct transport; struct worker; struct listen_sock; +struct vcf; #define DIGEST_LEN 32 @@ -530,6 +531,8 @@ struct req { struct acct_req acct; struct vrt_privs privs[1]; + + struct vcf *vcf; }; #define IS_TOPREQ(req) ((req)->topreq == (req)) diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index e9b8466d9..a778bf535 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -81,6 +81,15 @@ static int hsh_deref_objhead_unlock(struct worker *wrk, struct objhead **poh); /*---------------------------------------------------------------------*/ +#define VCF_RETURN(x) const struct vcf_return VCF_##x[1] = { \ + { .name = #x, } \ +}; + +VCF_RETURNS() +#undef VCF_RETURN + +/*---------------------------------------------------------------------*/ + static struct objhead * hsh_newobjhead(void) { @@ -344,6 +353,7 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp) struct objhead *oh; struct objcore *oc; struct objcore *exp_oc; + const struct vcf_return *vr; vtim_real exp_t_origin; int busy_found; const uint8_t *vary; @@ -359,6 +369,7 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp) wrk = req->wrk; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(req->http, HTTP_MAGIC); + CHECK_OBJ_ORNULL(req->vcf, VCF_MAGIC); AN(hash); hsh_prealloc(wrk); @@ -436,6 +447,19 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp) continue; } + if (req->vcf != NULL) { + vr = req->vcf->func(req, &oc, &exp_oc, 0); + if (vr == VCF_CONTINUE) + continue; + if (vr == VCF_MISS) { + oc = NULL; + break; + } + if (vr == VCF_HIT) + break; + assert(vr == VCF_DEFAULT); + } + if (EXP_Ttl(req, oc) > req->t_req) { assert(oh->refcnt > 1); assert(oc->objhead == oh); @@ -452,6 +476,9 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp) } } + if (req->vcf != NULL) + (void)req->vcf->func(req, &oc, &exp_oc, 1); + if (oc != NULL && oc->flags & OC_F_HFP) { xid = ObjGetXID(wrk, oc); dttl = EXP_Dttl(req, oc); diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 1768efee1..1bd7911ee 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -490,6 +490,11 @@ cnt_lookup(struct worker *wrk, struct req *req) if (had_objhead) VSLb_ts_req(req, "Waitinglist", W_TIM_real(wrk)); + if (req->vcf != NULL) { + (void)req->vcf->func(req, NULL, NULL, 2); + req->vcf = NULL; + } + if (busy == NULL) { VRY_Finish(req, DISCARD); } else { diff --git a/bin/varnishd/cache/cache_varnishd.h b/bin/varnishd/cache/cache_varnishd.h index 2aab94ab7..a117d8b8d 100644 --- a/bin/varnishd/cache/cache_varnishd.h +++ b/bin/varnishd/cache/cache_varnishd.h @@ -85,6 +85,37 @@ typedef enum htc_status_e htc_complete_f(struct http_conn *); extern volatile struct params * cache_param; +/* ------------------------------------------------------------------- + * The VCF facility is deliberately undocumented, use at your peril. + */ + +struct vcf_return { + const char *name; +}; + +#define VCF_RETURNS() \ + VCF_RETURN(CONTINUE) \ + VCF_RETURN(DEFAULT) \ + VCF_RETURN(MISS) \ + VCF_RETURN(HIT) + +#define VCF_RETURN(x) extern const struct vcf_return VCF_##x[1]; +VCF_RETURNS() +#undef VCF_RETURN + +typedef const struct vcf_return *vcf_func_f( + struct req *req, + struct objcore **oc, + struct objcore **oc_exp, + int state); + +struct vcf { + unsigned magic; +#define VCF_MAGIC 0x183285d1 + vcf_func_f *func; + void *priv; +}; + /* Prototypes etc ----------------------------------------------------*/ /* cache_acceptor.c */ diff --git a/bin/varnishd/flint.lnt b/bin/varnishd/flint.lnt index 42a40290f..5a1942528 100644 --- a/bin/varnishd/flint.lnt +++ b/bin/varnishd/flint.lnt @@ -39,6 +39,7 @@ -esym(765, vrt_magic_string_end) -esym(759, vrt_magic_string_end) -esym(768, vrt_ref::*) +-esym(768, vcf_return::name) -esym(768, VCL_conf::*) // FLINT Bug20090910_838 diff --git a/bin/varnishtest/tests/m00051.vtc b/bin/varnishtest/tests/m00051.vtc new file mode 100644 index 000000000..a5231894a --- /dev/null +++ b/bin/varnishtest/tests/m00051.vtc @@ -0,0 +1,54 @@ +varnishtest "catflap" + +varnish v1 -vcl { + import debug; + + backend dummy { .host = "${bad_backend}"; } + + sub vcl_recv { + if (req.http.id) { + debug.catflap(miss); + } else if (req.http.get == "first") { + debug.catflap(first); + } else if (req.http.get == "last") { + debug.catflap(last); + } else { + return (fail); + } + return (hash); + } + + sub vcl_backend_error { + if (! bereq.http.id) { + return (deliver); + } + set beresp.status = 200; + set beresp.ttl = 1s; + set beresp.grace = 1m; + set beresp.http.id = bereq.http.id; + } +} -start + +client c1 { + txreq -hdr "id: 1" + rxresp + expect resp.status == 200 + txreq -hdr "id: 2" + rxresp + expect resp.status == 200 + txreq -hdr "id: 3" + rxresp + expect resp.status == 200 + + # the first object is the one which went into cache last + + txreq -hdr "get: first" + rxresp + expect resp.status == 200 + expect resp.http.id == "3" + + txreq -hdr "get: last" + rxresp + expect resp.status == 200 + expect resp.http.id == "1" +} -run diff --git a/doc/sphinx/reference/vtla.rst b/doc/sphinx/reference/vtla.rst index 1fdfb4abf..76dccd068 100644 --- a/doc/sphinx/reference/vtla.rst +++ b/doc/sphinx/reference/vtla.rst @@ -31,6 +31,9 @@ VCA VCC VCL to C Compiler -- The code that compiles VCL to C code. (lib/libvcl) +VCF + Varnish CatFlap + VCL Varnish Configuration Language -- The domain-specific programming language used for configuring a varnishd. diff --git a/lib/libvmod_debug/vmod.vcc b/lib/libvmod_debug/vmod.vcc index 2ff1d0220..4c5f652eb 100644 --- a/lib/libvmod_debug/vmod.vcc +++ b/lib/libvmod_debug/vmod.vcc @@ -230,3 +230,7 @@ $Method STRING .meth_opt(PRIV_CALL, PRIV_VCL, PRIV_TASK, Test object method with all the fancy stuff. $Function STRANDS return_strands(STRANDS strand) + +$Function VOID catflap(ENUM {miss, first, last} type) + +Test the HSH_Lookup catflap diff --git a/lib/libvmod_debug/vmod_debug.c b/lib/libvmod_debug/vmod_debug.c index fa05142b6..7161596ae 100644 --- a/lib/libvmod_debug/vmod_debug.c +++ b/lib/libvmod_debug/vmod_debug.c @@ -630,3 +630,72 @@ xyzzy_return_strands(VRT_CTX, VCL_STRANDS strand) CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); return (strand); } + +/*---------------------------------------------------------------------*/ + +static const struct vcf_return * v_matchproto_(vcf_func_f) +xyzzy_catflap_simple(struct req *req, struct objcore **oc, + struct objcore **oc_exp, int state) +{ + + CHECK_OBJ_NOTNULL(req, REQ_MAGIC); + CHECK_OBJ_NOTNULL(req->vcf, VCF_MAGIC); + assert(req->vcf->func == xyzzy_catflap_simple); + + (void)oc; + (void)oc_exp; + if (state == 0) { + if (req->vcf->priv == VENUM(first)) + return (VCF_HIT); + if (req->vcf->priv == VENUM(miss)) + return (VCF_MISS); + WRONG("Shouldn't get here"); + } + return (VCF_DEFAULT); +} + +static const struct vcf_return * v_matchproto_(vcf_func_f) +xyzzy_catflap_last(struct req *req, struct objcore **oc, + struct objcore **oc_exp, int state) +{ + + CHECK_OBJ_NOTNULL(req, REQ_MAGIC); + CHECK_OBJ_NOTNULL(req->vcf, VCF_MAGIC); + assert(req->vcf->func == xyzzy_catflap_last); + + (void)oc_exp; + if (state == 0) { + AN(oc); + CHECK_OBJ_NOTNULL(*oc, OBJCORE_MAGIC); + req->vcf->priv = *oc; + return (VCF_CONTINUE); + } + if (state == 1) { + AN(oc); + if (req->vcf->priv != NULL) + CAST_OBJ_NOTNULL(*oc, req->vcf->priv, OBJCORE_MAGIC); + return (VCF_CONTINUE); + } + return (VCF_DEFAULT); +} + +VCL_VOID +xyzzy_catflap(VRT_CTX, VCL_ENUM type) +{ + struct req *req; + + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + req = ctx->req; + CHECK_OBJ_NOTNULL(req, REQ_MAGIC); + XXXAZ(req->vcf); + req->vcf = WS_Alloc(req->ws, sizeof *req->vcf); + INIT_OBJ(req->vcf, VCF_MAGIC); + if (type == VENUM(first) || type == VENUM(miss)) { + req->vcf->func = xyzzy_catflap_simple; + req->vcf->priv = TRUST_ME(type); + } else if (type == VENUM(last)) { + req->vcf->func = xyzzy_catflap_last; + } else { + WRONG("Wrong VENUM"); + } +} From nils.goroll at uplex.de Mon Mar 4 13:01:08 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 4 Mar 2019 13:01:08 +0000 (UTC) Subject: [master] 5a1a9b089 make vmod_std conversions more flexible Message-ID: <20190304130108.367B1634F7@lists.varnish-cache.org> commit 5a1a9b0894667b9b1bcf8671b26690ee9a78001f Author: Nils Goroll Date: Wed Feb 27 18:42:28 2019 +0100 make vmod_std conversions more flexible In order to avoid the cross product problem with conversion functions (from x to y types would require x*y functions), we add flexibility regarding the input parameters to conversion functions: Each convertion function named after the destination type now takes all sensible arguments by name. int is named integer because of the reserved symbol name "int" in C. All functions should be fully backwards compatible (existing vtcs continue to work), but compile time checks are now effectively removed. The conversion functions now trigger vcl errors if used incorrectly or if conversion errors occur and no failback is provided. However, if a failback is provided, vcl errors are only raised for usage errors. For consistency, the conversion functions now only ever truncate if necessary. std.round() is added for explicit rounding where required. Existing functions which are now obsolete are marked deprecated. Ref #2899 Ref https://github.com/varnishcache/varnish-cache/wiki/VIP12:-vmod-polymorphism-(for-type-conversions) diff --git a/bin/varnishtest/tests/m00005.vtc b/bin/varnishtest/tests/m00005.vtc index 9ce01bf42..253f49584 100644 --- a/bin/varnishtest/tests/m00005.vtc +++ b/bin/varnishtest/tests/m00005.vtc @@ -9,8 +9,36 @@ varnish v1 -vcl+backend { import std; sub vcl_deliver { - set resp.http.duration = std.duration(req.http.duration, 1s) + 1000000s; - set resp.http.bytes = std.bytes(req.http.bytes, 10K) + 512B; + if (req.http.d-real) { + set resp.http.duration = + std.duration(real=std.real(req.http.d-real)) + + 1000000s; + } else if (req.http.d-int) { + set resp.http.duration = + std.duration(integer=std.integer(req.http.d-int)) + + 1000000s; + } else if (req.http.duration-nf) { + set resp.http.duration = + std.duration(req.http.duration) + 1000000s; + } else { + set resp.http.duration = + std.duration(req.http.duration, 1s) + 1000000s; + } + if (req.http.b-real) { + set resp.http.bytes = + std.bytes(real=std.real(req.http.b-real)) + + 512B; + } else if (req.http.b-int) { + set resp.http.bytes = + std.bytes(integer=std.integer(req.http.b-int)) + + 512B; + } else if (req.http.bytes-nf) { + set resp.http.bytes = std.bytes(req.http.bytes-nf) + + 512B; + } else { + set resp.http.bytes = std.bytes(req.http.bytes, 10K) + + 512B; + } } } -start @@ -82,4 +110,100 @@ client c1 { txreq -hdr "duration: 100" rxresp expect resp.http.duration == 1000001.000 + + # --- + + txreq -hdr "d-real: 0.010" -hdr "b-real: 2048.99999" + rxresp + expect resp.http.duration == 1000000.010 + expect resp.http.bytes == 2560.000 + + txreq -hdr "d-real: 10.1" -hdr "b-real: 3145728.9" + rxresp + expect resp.http.duration == 1000010.100 + expect resp.http.bytes == 3146240.000 + + txreq -hdr "d-real: 600" -hdr "b-real: 4831838208.123" + rxresp + expect resp.http.duration == 1000600.000 + expect resp.http.bytes == 4831838720.000 + + txreq -hdr "d-real: 36000" -hdr "b-real: 131941395333.12" + rxresp + expect resp.http.duration == 1036000.000 + expect resp.http.bytes == 131941395845.000 + + txreq -hdr "d-real: -100" + rxresp + expect resp.http.duration == 999900.000 + + txreq -hdr "d-real: -inf" + rxresp + expect resp.status == 503 +} -run + +client c1 { + txreq -hdr "d-int: 600" -hdr "b-int: 4831838208" + rxresp + expect resp.http.duration == 1000600.000 + expect resp.http.bytes == 4831838720.000 + + txreq -hdr "d-int: 36000" -hdr "b-int: 131941395333" + rxresp + expect resp.http.duration == 1036000.000 + expect resp.http.bytes == 131941395845.000 + + txreq -hdr "d-int: -100" + rxresp + expect resp.http.duration == 999900.000 + + txreq -hdr "d-int: x" + rxresp + expect resp.status == 503 +} -run + +client c1 { + txreq -hdr "duration-nf: s" + rxresp + expect resp.status == 503 +} -run +client c1 { + txreq -hdr "duration-nf: 3wx" + rxresp + expect resp.status == 503 +} -run +client c1 { + txreq -hdr "duration-nf: -inf" + rxresp + expect resp.status == 503 +} -run +client c1 { + txreq -hdr "duration-nf: 2x" + rxresp + expect resp.status == 503 +} -run +client c1 { + txreq -hdr "duration-nf: 2h x" + rxresp + expect resp.status == 503 +} -run +client c1 { + txreq -hdr "duration-nf: 100" + rxresp + expect resp.status == 503 +} -run +client c1 { + txreq -hdr "bytes-nf: x" + rxresp + expect resp.status == 503 +} -run +client c1 { + txreq -hdr "b-real: x" + rxresp + expect resp.status == 503 +} -run +client c1 { + txreq -hdr "b-int: x" + rxresp + expect resp.status == 503 } -run diff --git a/bin/varnishtest/tests/m00007.vtc b/bin/varnishtest/tests/m00007.vtc index b66fc0b98..51840f5dd 100644 --- a/bin/varnishtest/tests/m00007.vtc +++ b/bin/varnishtest/tests/m00007.vtc @@ -13,16 +13,57 @@ varnish v1 -vcl+backend { set resp.http.ltzero = (std.integer(req.http.foo, 0) < 0); set resp.http.iszero = (std.integer(req.http.foo, 0) == 0); set resp.http.converted = std.integer(req.http.foo, 0); + + if (req.http.nofb) { + set resp.http.nofb = std.integer(req.http.foo); + } + + if (req.http.bool) { + set resp.http.bool = + std.integer(bool=req.http.bool != ""); + } + if (req.http.bytes) { + set resp.http.bytes = + std.integer(bytes=std.bytes(req.http.bytes)); + } + if (req.http.duration) { + set resp.http.duration = + std.integer(duration=std.duration(req.http.duration)); + } + if (req.http.real) { + set resp.http.real = + std.integer(real=std.real(req.http.real)); + } + if (req.http.time) { + set resp.http.time = + std.integer(time=std.time(req.http.time)); + } + if (req.http.err1) { + set resp.http.time = std.integer(); + } + if (req.http.err2) { + set resp.http.time = std.integer(real=1.0, bool=true); + } } } -start client c1 { - txreq -hdr "foo: 1" + txreq -hdr "foo: 1" \ + -hdr "bool: whatever" \ + -hdr "bytes: 1b" \ + -hdr "duration: 1s" \ + -hdr "real: 1.9" \ + -hdr "time: Thu, 01 Jan 1970 00:00:01 GMT" rxresp expect resp.http.gtzero == true expect resp.http.ltzero == false expect resp.http.iszero == false expect resp.http.converted == 1 + expect resp.http.bool == 1 + expect resp.http.duration == 1 + expect resp.http.bytes == 1 + expect resp.http.real == 1 + expect resp.http.time == 1 txreq -hdr "foo: -1" rxresp @@ -38,10 +79,71 @@ client c1 { expect resp.http.iszero == true expect resp.http.converted == 0 + # VCL_INT_MAX + txreq -hdr "foo: 9007199254740991" \ + -hdr "bytes: 9007199254740991b" \ + -hdr "duration: 9007199254740991s" \ + -hdr "real: 9007199254740991" \ + -hdr "time: 9007199254740991" + rxresp + expect resp.http.gtzero == true + expect resp.http.ltzero == false + expect resp.http.iszero == false + expect resp.http.converted == 9007199254740991 + expect resp.http.bytes == 9007199254740991 + expect resp.http.duration == 9007199254740991 + expect resp.http.real == 9007199254740991 + expect resp.http.time == 9007199254740991 + + # VCL_INT_MIN + txreq -hdr "foo: -9007199254740991" \ + -hdr "duration: -9007199254740991s" \ + -hdr "real: -9007199254740991" + rxresp + expect resp.http.gtzero == false + expect resp.http.ltzero == true + expect resp.http.iszero == false + expect resp.http.converted == -9007199254740991 + expect resp.http.duration == -9007199254740991 + expect resp.http.real == -9007199254740991 + txreq -hdr "foo: bar" rxresp expect resp.http.gtzero == false expect resp.http.ltzero == false expect resp.http.iszero == true expect resp.http.converted == 0 + + txreq -hdr "foo: 9007199254740992" + rxresp + expect resp.http.converted == 0 + + txreq -hdr "foo: -9007199254740992" + rxresp + expect resp.http.converted == 0 +} -run +client c1 { + txreq -hdr "nofb: 9007199254740992" + rxresp + expect resp.status == 503 +} -run +client c1 { + txreq -hdr "nofb: -9007199254740992" + rxresp + expect resp.status == 503 +} -run +client c1 { + txreq -hdr "nofb: x" + rxresp + expect resp.status == 503 +} -run +client c1 { + txreq -hdr "err1: 1" + rxresp + expect resp.status == 503 +} -run +client c1 { + txreq -hdr "err2: 1" + rxresp + expect resp.status == 503 } -run diff --git a/bin/varnishtest/tests/m00015.vtc b/bin/varnishtest/tests/m00015.vtc index 1845fa7ce..3e7974958 100644 --- a/bin/varnishtest/tests/m00015.vtc +++ b/bin/varnishtest/tests/m00015.vtc @@ -1,4 +1,4 @@ -varnishtest "Test vmod_std.real conversion" +varnishtest "Test std.real() conversion and std.round" server s1 { rxreq @@ -17,6 +17,8 @@ varnish v1 -vcl+backend { set resp.http.t5 = std.real("1.0 ", 0.0); set resp.http.t6 = std.real(" 1.0", 0.0); set resp.http.t7 = std.real(" 1.0 ", 0.0); + set resp.http.t8 = std.round(42.42); + set resp.http.t9 = std.round(-42.42); } } -start @@ -32,4 +34,112 @@ client c1 { expect resp.http.t5 == 1.000 expect resp.http.t6 == 1.000 expect resp.http.t7 == 1.000 + expect resp.http.t8 == 42.000 + expect resp.http.t9 == -42.000 +} -run + +varnish v1 -vcl+backend { + import std; + + sub vcl_deliver { + set resp.http.converted = std.real(req.http.foo, 0); + + if (req.http.nofb) { + set resp.http.nofb = std.real(req.http.foo); + } + + if (req.http.bool) { + set resp.http.bool = + std.real(bool=req.http.bool != ""); + } + if (req.http.bytes) { + set resp.http.bytes = + std.real(bytes=std.bytes(req.http.bytes)); + } + if (req.http.duration) { + set resp.http.duration = + std.real(duration=std.duration(req.http.duration)); + } + if (req.http.integer) { + set resp.http.integer = + std.real(integer=std.integer(req.http.integer)); + } + if (req.http.time) { + set resp.http.time = + std.real(time=std.time(req.http.time)); + } + } +} + +client c1 { + txreq -hdr "foo: 1" \ + -hdr "bool: whatever" \ + -hdr "bytes: 1b" \ + -hdr "duration: 1s" \ + -hdr "integer: 1" \ + -hdr "time: Thu, 01 Jan 1970 00:00:01 GMT" + rxresp + expect resp.http.converted == 1.000 + expect resp.http.bool == 1.000 + expect resp.http.duration == 1.000 + expect resp.http.bytes == 1.000 + expect resp.http.integer == 1.000 + expect resp.http.time == 1.000 + + txreq -hdr "foo: -1" + rxresp + expect resp.http.converted == -1.000 + + txreq -hdr "foo: 0" + rxresp + expect resp.http.converted == 0.000 + + # VCL_INT_MAX + txreq -hdr "foo: 9007199254740991" \ + -hdr "bytes: 9007199254740991b" \ + -hdr "duration: 9007199254740991s" \ + -hdr "integer: 9007199254740991" \ + -hdr "time: 9007199254740991" + rxresp + expect resp.http.converted == 9007199254740991.000 + expect resp.http.bytes == 9007199254740991.000 + expect resp.http.duration == 9007199254740991.000 + expect resp.http.integer == 9007199254740991.000 + expect resp.http.time == 9007199254740991.000 + + # VCL_INT_MIN + txreq -hdr "foo: -9007199254740991" \ + -hdr "duration: -9007199254740991s" \ + -hdr "integer: -9007199254740991" + rxresp + expect resp.http.converted == -9007199254740991.000 + expect resp.http.duration == -9007199254740991.000 + expect resp.http.integer == -9007199254740991.000 + + txreq -hdr "foo: bar" + rxresp + expect resp.http.converted == 0.000 + + txreq -hdr "foo: 9007199254740992" + rxresp + expect resp.http.converted == 9007199254740992.000 + + txreq -hdr "foo: -9007199254740992" + rxresp + expect resp.http.converted == -9007199254740992.000 +} -run +client c1 { + txreq -hdr "nofb: NAN" + rxresp + expect resp.status == 503 +} -run +client c1 { + txreq -hdr "nofb: -INF" + rxresp + expect resp.status == 503 +} -run +client c1 { + txreq -hdr "nofb: x" + rxresp + expect resp.status == 503 } -run diff --git a/bin/varnishtest/tests/m00020.vtc b/bin/varnishtest/tests/m00020.vtc index eb2eb0f5b..fd61e11fb 100644 --- a/bin/varnishtest/tests/m00020.vtc +++ b/bin/varnishtest/tests/m00020.vtc @@ -17,47 +17,74 @@ varnish v1 -vcl+backend { if (std.time(req.http.x-date, now) > now + 1y) { set resp.http.x-future = 1; } + if (req.http.real) { + if (resp.http.x-date != "" + + std.time(real=std.real(req.http.real))) { + return(synth(503)); + } + } + if (req.http.integer) { + if (resp.http.x-date != "" + + std.time(integer=std.integer(req.http.integer))) { + return(synth(503)); + } + } } } -start client c1 { - txreq -hdr "X-Date: Mon, 20 Dec 2010 00:00:00 GMT" + txreq -hdr "X-Date: Mon, 20 Dec 2010 00:00:00 GMT" \ + -hdr "real: 1292803200.0" \ + -hdr "integer: 1292803200" rxresp + expect resp.status == 200 expect resp.http.x-past == 1 expect resp.http.x-date == "Mon, 20 Dec 2010 00:00:00 GMT" - txreq -hdr "X-Date: Monday, 20-Dec-30 00:00:00 GMT" + # invalid date + txreq -hdr "X-Date: Monday, 20-Dec-30 00:00:00 GMT" \ + -hdr "real: 1923955200.0" \ + -hdr "integer: 1923955200" rxresp + expect resp.status == 503 expect resp.http.x-past == expect resp.http.x-future == txreq -hdr "X-Date: Monday, 30-Feb-15 00:00:00 GMT" rxresp + expect resp.status == 200 expect resp.http.x-past == expect resp.http.x-future == - txreq -hdr "X-Date: Friday, 20-Dec-30 00:00:00 GMT" + txreq -hdr "X-Date: Friday, 20-Dec-30 00:00:00 GMT" \ + -hdr "real: 1923955200.0" \ + -hdr "integer: 1923955200" rxresp + expect resp.status == 200 expect resp.http.x-future == 1 expect resp.http.x-date == "Fri, 20 Dec 2030 00:00:00 GMT" txreq -hdr "X-Date: Mon Dec 20 00:00:00 2010" rxresp + expect resp.status == 200 expect resp.http.x-past == 1 expect resp.http.x-date == "Mon, 20 Dec 2010 00:00:00 GMT" txreq -hdr "X-Date: 2030-12-20T00:00:00" rxresp + expect resp.status == 200 expect resp.http.x-future == 1 expect resp.http.x-date == "Fri, 20 Dec 2030 00:00:00 GMT" txreq -hdr "X-Date: 1292803200.00" rxresp + expect resp.status == 200 expect resp.http.x-past == 1 expect resp.http.x-date == "Mon, 20 Dec 2010 00:00:00 GMT" txreq -hdr "X-Date: 1923955200" rxresp + expect resp.status == 200 expect resp.http.x-future == 1 expect resp.http.x-date == "Fri, 20 Dec 2030 00:00:00 GMT" @@ -68,66 +95,79 @@ client c1 { # leapsecond txreq -hdr "X-Date: Mon, 20 Dec 2010 00:00:60 GMT" rxresp + expect resp.status == 200 expect resp.http.x-date == "Mon, 20 Dec 2010 00:00:59 GMT" delay .1 # Range tests txreq -hdr "X-Date: Mon, 20 Dec 2010 00:00:61 GMT" rxresp + expect resp.status == 200 expect resp.http.x-date != "Mon, 20 Dec 2010 00:00:61 GMT" delay .1 txreq -hdr "X-Date: Mon, 20 Dec 2010 00:60:00 GMT" rxresp + expect resp.status == 200 expect resp.http.x-date != "Mon, 20 Dec 2010 00:60:00 GMT" delay .1 txreq -hdr "X-Date: Mon, 20 Dec 2010 24:00:00 GMT" rxresp + expect resp.status == 200 expect resp.http.x-date != "Mon, 20 Dec 2010 24:00:00 GMT" delay .1 txreq -hdr "X-Date: Tue, 20 Dec 2010 00:00:00 GMT" rxresp + expect resp.status == 200 expect resp.http.x-date != "Tue, 20 Dec 2010 00:00:00 GMT" delay .1 txreq -hdr "X-Date: Mon, 29 Feb 2010 00:00:00 GMT" rxresp + expect resp.status == 200 expect resp.http.x-date != "Mon, 29 Feb 2010 00:00:00 GMT" delay .1 txreq -hdr "X-Date: Wed, 29 Feb 2012 00:00:00 GMT" rxresp + expect resp.status == 200 expect resp.http.x-date == "Wed, 29 Feb 2012 00:00:00 GMT" delay .1 txreq -hdr "X-Date: 2010-13-20T00:00:00" rxresp + expect resp.status == 200 delay .1 txreq -hdr "X-Date: Sun 31 Dec 1899 23:59:59 GMT" rxresp + expect resp.status == 200 expect resp.http.x-date != "Sun 31 Dec 1899 23:59:59 GMT" delay .1 # White space etc. txreq -hdr "X-Date: z Wed, 29 Feb 2012 00:00:00 GMT" rxresp + expect resp.status == 200 expect resp.http.x-date == "Wed, 29 Feb 2012 00:00:00 GMT" delay .1 txreq -hdr "X-Date: Wedx 29 Feb 2012 00:00:00 GMT" rxresp + expect resp.status == 200 expect resp.http.x-date != "Wed, 29 Feb 2012 00:00:00 GMT" delay .1 txreq -hdr "X-Date: Wed, 29 Feb 2012 00:00:00 GMT x" rxresp + expect resp.status == 200 expect resp.http.x-date != "Wed, 29 Feb 2012 00:00:00 GMT" delay .1 txreq rxresp + expect resp.status == 200 expect resp.http.x-date != } -run diff --git a/lib/libvmod_std/vmod.vcc b/lib/libvmod_std/vmod.vcc index b3d994618..bf2396c21 100644 --- a/lib/libvmod_std/vmod.vcc +++ b/lib/libvmod_std/vmod.vcc @@ -157,38 +157,96 @@ Examples:: std.collect(req.http.accept); std.collect(req.http.cookie, "; "); -$Function DURATION duration(STRING s, DURATION fallback) +$Function DURATION duration([STRING s], [DURATION fallback], + [REAL real], [INT integer]) -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. +Returns a DURATION from a STRING, REAL or INT argument. -Example:: +For a STRING *s* argument, *s* must be quantified by ``ms`` +(milliseconds), ``s`` (seconds), ``m`` (minutes), ``h`` (hours),``d`` +(days), ``w`` (weeks) or ``y`` (years) units. + +*real* and *integer* arguments are taken as seconds. + +If the conversion of an *s* argument fails, *fallback* will be +returned if provided, or a VCL failure will be triggered. +Conversions from *real* and *integer* arguments never fail. + +Only one of the *s*, *real* or *integer* arguments may be given or a VCL +failure will be triggered. + +Examples:: set beresp.ttl = std.duration("1w", 3600s); + set beresp.ttl = std.duration(real=1.5); + set beresp.ttl = std.duration(integer=10); -$Function BYTES bytes(STRING s, BYTES fallback) +$Function BYTES bytes([STRING s], [BYTES fallback], [REAL real], [INT integer]) -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. +Returns BYTES from a STRING, REAL or INT argument. -Example:: +A STRING *s* argument can be quantified with a multiplier (``k`` +(kilo), ``m`` (mega), ``g`` (giga), ``t`` (tera) or ``p`` (peta)). - std.cache_req_body(std.bytes(something.somewhere, 10K)); +*real* and *integer* arguments are taken as bytes. + +If the conversion of an *s* argument fails, *fallback* will be +returned if provided, or a VCL failure will be triggered. -$Function INT integer(STRING s, INT fallback) +Other conversions may fail if the argument can not be represented, +because it is negative, too small or too large. Again, *fallback* will +be returned if provided, or a VCL failure will be triggered. -Converts the string *s* to an integer. If conversion fails, *fallback* -will be returned. +*real* arguments will be rounded down. + +Only one of the *s*, *real* or *integer* arguments may be given or a VCL +failure will be triggered. Example:: + std.cache_req_body(std.bytes(something.somewhere, 10K)); + std.cache_req_body(std.bytes(integer=10*1024)); + std.cache_req_body(std.bytes(real=10.0*1024)); + +$Function INT integer([STRING s], [INT fallback], + [BOOL bool], [BYTES bytes], [DURATION duration], [REAL real], + [TIME time]) + +Returns an INT from a STRING, BOOL or other quantity. + +If the conversion of an *s* argument fails, *fallback* will be +returned if provided, or a VCL failure will be triggered. + +A *bool* argument will be returned as 0 for ``false`` and 1 for +``true``. This conversion will never fail. + +For a *bytes* argument, the number of bytes will be returned. This +conversion will never fail. + +A *duration* argument will be rounded down to the number of seconds +and returned. + +A *real* argument will be rounded down and returned. + +For a *time* argument, the number of seconds since the UNIX epoch +(1970-01-01 00:00:00 UTC) will be returned. + +*duration*, *real* and *time* conversions may fail if the argument can +not be represented because it is too small or too large. If so, +*fallback* will be returned if provided, or a VCL failure will be +triggered. + +Only one of the *s*, *bool*, *bytes*, *duration*, *real* or *time* +arguments may be given or a VCL failure will be triggered. + +Examples:: if (std.integer(req.http.foo, 0) > 5) { ... } + set resp.http.answer = std.integer(real=126.42/3); + + $Function IP ip(STRING s, IP fallback, BOOL resolve = 1) Converts the string *s* to the first IP number returned by @@ -205,10 +263,31 @@ Example:: ... } -$Function REAL real(STRING s, REAL fallback) +$Function REAL real([STRING s], [REAL fallback], [INT integer], + [BOOL bool], [BYTES bytes], [DURATION duration], + [TIME time]) -Converts the string *s* to a real. If conversion fails, *fallback* -will be returned. +Returns a REAL from a STRING, BOOL or other quantity. + +If the conversion of an *s* argument fails, *fallback* will be +returned if provided, or a VCL failure will be triggered. + +A *bool* argument will be returned as 0.0 for ``false`` and 1.0 for +``true``. + +For a *bytes* argument, the number of bytes will be returned. + +For a *duration* argument, the number of seconds will be returned. + +An *integer* argument will be returned as a REAL. + +For a *time* argument, the number of seconds since the UNIX epoch +(1970-01-01 00:00:00 UTC) will be returned. + +None of these conversions other than *s* will fail. + +Only one of the *s*, *integer*, *bool*, *bytes*, *duration* or *time* +arguments may be given or a VCL failure will be triggered. Example:: @@ -216,8 +295,19 @@ Example:: ... } +$Function REAL round(REAL r) + +Rounds the real *r* to the nearest integer, but round halfway cases +away from zero (see `round(3)`). + $Function INT real2integer(REAL r, INT fallback) +**DEPRECATED**: This function will be removed in a future version of +varnish, use `vmod_std.integer`_ with a *real* argument and the +`vmod_std.round`_ function instead, for example:: + + std.integer(real=std.round(...), fallback=...) + 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. @@ -230,6 +320,12 @@ Examples:: $Function TIME real2time(REAL r, TIME fallback) +**DEPRECATED**: This function will be removed in a future version of +varnish, use `vmod_std.time`_ with a *real* argument and the +`vmod_std.round`_ function instead, for example:: + + std.time(real=std.round(...), fallback=...) + 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 @@ -241,6 +337,12 @@ Example:: $Function INT time2integer(TIME t, INT fallback) +**DEPRECATED**: This function will be removed in a future version of +varnish, use `vmod_std.integer`_ with a *time* argument instead, for +example:: + + std.integer(time=..., fallback=...) + Converts the time *t* to a integer. If conversion fails, *fallback* will be returned. @@ -250,6 +352,12 @@ Example:: $Function REAL time2real(TIME t, REAL fallback) +**DEPRECATED**: This function will be removed in a future version of +varnish, use `vmod_std.real`_ with a *time* argument instead, for +example:: + + std.real(time=..., fallback=...) + Converts the time *t* to a real. If conversion fails, *fallback* will be returned. @@ -325,12 +433,11 @@ Example:: This will check if the content of ``req.http.restrict`` occurs anywhere in ``req.url``. -$Function TIME time(STRING s, TIME fallback) +$Function TIME time([STRING s], [TIME fallback], [REAL real], [INT integer]) -Converts the string *s* to a time. If conversion fails, *fallback* -will be returned. +Returns a TIME from a STRING, REAL or INT argument. -Supported formats:: +For a STRING *s* argument, the following formats are supported:: "Sun, 06 Nov 1994 08:49:37 GMT" "Sunday, 06-Nov-94 08:49:37 GMT" @@ -339,12 +446,22 @@ Supported formats:: "784111777.00" "784111777" -Example:: +*real* and *integer* arguments are taken as seconds since the epoch. + +If the conversion of an *s* argument fails or a negative *real* or +*integer* argument is given, *fallback* will be returned if provided, +or a VCL failure will be triggered. + +Examples:: if (std.time(resp.http.last-modified, now) < now - 1w) { ... } + if (std.time(int=2147483647) < now - 1w) { + ... + } + $Function STRING getenv(STRING name) Return environment variable *name* or the empty string. See `getenv(3)`. diff --git a/lib/libvmod_std/vmod_std_conversions.c b/lib/libvmod_std/vmod_std_conversions.c index ed85bed0f..c20402b1c 100644 --- a/lib/libvmod_std/vmod_std_conversions.c +++ b/lib/libvmod_std/vmod_std_conversions.c @@ -44,47 +44,139 @@ #include "vtim.h" #include "vcc_if.h" +static inline int onearg(VRT_CTX, const char *f, int nargs) +{ + if (nargs == 1) + return (1); + VRT_fail(ctx, "std.%s: %s arguments", f, + nargs > 1 ? "too many" : "not enough"); + return (0); +} + +/* + * not handling real arg isfinite() / nan() : caller error + * always trunc, never round + */ + VCL_DURATION v_matchproto_(td_std_duration) -vmod_duration(VRT_CTX, VCL_STRING p, VCL_DURATION d) +vmod_duration(VRT_CTX, struct VARGS(duration) *a) { double r; + int nargs; CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); - r = VNUM_duration(p); - return (isnan(r) ? d : r); + + nargs = a->valid_s + a->valid_real + a->valid_integer; + + if (! onearg(ctx, "duration", nargs)) + return (0); + + if (a->valid_real) + return ((VCL_DURATION)a->real); + if (a->valid_integer) + return ((VCL_DURATION)a->integer); + + assert(a->valid_s); + + r = VNUM_duration(a->s); + + if (! isnan(r)) + return (r); + + if (a->valid_fallback) + return (a->fallback); + + VRT_fail(ctx, "std.duration: conversion failed"); + return (0); } VCL_BYTES v_matchproto_(td_std_bytes) -vmod_bytes(VRT_CTX, VCL_STRING p, VCL_BYTES d) +vmod_bytes(VRT_CTX, struct VARGS(bytes) *a) { uintmax_t r; + VCL_BYTES b; + VCL_REAL rr; + int nargs; CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); - if (VNUM_2bytes(p, &r, 0) != NULL) - return (d); - return (r); + + nargs = a->valid_s + a->valid_real + a->valid_integer; + + if (! onearg(ctx, "bytes", nargs)) + return (0); + + b = -1; + if (a->valid_s) { + if (VNUM_2bytes(a->s, &r, 0) == NULL && + r <= VCL_BYTES_MAX) + b = (VCL_BYTES)r; + } else if (a->valid_real) { + rr = trunc(a->real); + if (rr <= (VCL_REAL)VCL_BYTES_MAX) + b = (VCL_BYTES)rr; + } else if (a->valid_integer) { + b = (VCL_BYTES)a->integer; + } else { + INCOMPL(); + } + + if (b >= 0) + return (b); + + if (a->valid_fallback) + return (a->fallback); + + VRT_fail(ctx, "std.bytes: conversion failed"); + return (0); } VCL_INT v_matchproto_(td_std_integer) -vmod_integer(VRT_CTX, VCL_STRING p, VCL_INT i) +vmod_integer(VRT_CTX, struct VARGS(integer) *a) { const char *e; double r; + int nargs; CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); - if (p == NULL) - return (i); + nargs = a->valid_s + a->valid_bool + a->valid_bytes + + a->valid_duration + a->valid_real + a->valid_time; + + if (! onearg(ctx, "integer", nargs)) + return (0); + + r = NAN; + if (a->valid_bool) { + return (!! a->bool); + } else if (a->valid_bytes) { + return (a->bytes); + } else if (a->valid_s) { + if (a->s) { + r = VNUMpfx(a->s, &e); + if (e != NULL) + r = NAN; + } + } else if (a->valid_duration) { + r = a->duration; + } else if (a->valid_real) { + r = a->real; + } else if (a->valid_time) { + r = a->time; + } else { + INCOMPL(); + } - r = VNUMpfx(p, &e); - if (isnan(r) || e != NULL) - return (i); + if (! isnan(r)) { + r = trunc(r); + if (r >= VCL_INT_MIN && r <= VCL_INT_MAX) + return ((VCL_INT)r); + } - r = trunc(r); - if (r > VCL_INT_MAX || r < VCL_INT_MIN) - return (i); + if (a->valid_fallback) + return (a->fallback); - return ((VCL_INT)r); + VRT_fail(ctx, "std.integer: conversion failed"); + return (0); } VCL_IP @@ -133,23 +225,54 @@ vmod_ip(VRT_CTX, VCL_STRING s, VCL_IP d, VCL_BOOL n) } VCL_REAL v_matchproto_(td_std_real) -vmod_real(VRT_CTX, VCL_STRING p, VCL_REAL d) +vmod_real(VRT_CTX, struct VARGS(real) *a) { - double r; + VCL_REAL r; + int nargs; CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); - if (p == NULL) - return (d); + nargs = a->valid_s + a->valid_integer + a->valid_bool + a->valid_bytes + + a->valid_duration + a->valid_time; - r = VNUM(p); + if (! onearg(ctx, "real", nargs)) + return (0); - if (isnan(r)) - return (d); + if (a->valid_integer) + return ((VCL_REAL)a->integer); + else if (a->valid_bool) + return ((VCL_REAL)(!! a->bool)); + else if (a->valid_bytes) + return ((VCL_REAL)a->bytes); + else if (a->valid_duration) + return ((VCL_REAL)a->duration); + else if (a->valid_time) + return ((VCL_REAL)a->time); - return (r); + assert(a->valid_s); + + r = NAN; + if (a->s != NULL) + r = VNUM(a->s); + + if (!isnan(r)) + return (r); + + if (a->valid_fallback) + return (a->fallback); + + VRT_fail(ctx, "std.real: conversion failed"); + return (0); +} + +VCL_REAL v_matchproto_(td_std_round) +vmod_round(VRT_CTX, VCL_REAL r) +{ + (void) ctx; + return (round(r)); } + VCL_INT v_matchproto_(td_std_real2integer) vmod_real2integer(VRT_CTX, VCL_REAL r, VCL_INT i) { @@ -199,14 +322,39 @@ vmod_time2real(VRT_CTX, VCL_TIME t, VCL_REAL r) } VCL_TIME v_matchproto_(td_std_time) -vmod_time(VRT_CTX, VCL_STRING p, VCL_TIME d) +vmod_time(VRT_CTX, struct VARGS(time)* a) { double r; + int nargs; CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); - r = VTIM_parse(p); - if (r) - return (r); - return (vmod_real(ctx, p, d)); + nargs = a->valid_s + a->valid_real + a->valid_integer; + + if (! onearg(ctx, "time", nargs)) + return (0); + + if (a->valid_integer) + return ((VCL_REAL)a->integer); + else if (a->valid_real) + return ((VCL_REAL)a->real); + + assert(a->valid_s); + + if (a->s) { + r = VTIM_parse(a->s); + if (r) + return (r); + + r = VNUM(a->s); + + if (!isnan(r) && r > 0) + return (r); + } + + if (a->valid_fallback) + return (a->fallback); + + VRT_fail(ctx, "std.time: conversion failed"); + return (0); } From nils.goroll at uplex.de Mon Mar 4 13:02:06 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 4 Mar 2019 13:02:06 +0000 (UTC) Subject: [master] 3ad34e875 Retire return(miss) from vcl_hit {} Message-ID: <20190304130207.062CD6376D@lists.varnish-cache.org> commit 3ad34e8755c0c46a7b94fbc34ae4837e8c9a1ad5 Author: Nils Goroll Date: Wed Dec 5 16:16:54 2018 +0100 Retire return(miss) from vcl_hit {} Ref #1799 diff --git a/bin/varnishd/builtin.vcl b/bin/varnishd/builtin.vcl index 4835a231c..ce4a5c445 100644 --- a/bin/varnishd/builtin.vcl +++ b/bin/varnishd/builtin.vcl @@ -96,17 +96,7 @@ sub vcl_purge { } sub vcl_hit { - if (obj.ttl >= 0s) { - // A pure unadulterated hit, deliver it - return (deliver); - } - if (obj.ttl + obj.grace > 0s) { - // Object is in grace, deliver it - // Automatically triggers a background fetch - return (deliver); - } - // fetch & deliver once we get the result - return (miss); + return (deliver); } sub vcl_miss { diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 1bd7911ee..2cbedfdf6 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -552,24 +552,6 @@ cnt_lookup(struct worker *wrk, struct req *req) wrk->stats->cache_hit_grace++; req->req_step = R_STP_DELIVER; return (REQ_FSM_MORE); - case VCL_RET_MISS: - if (busy != NULL) { - req->objcore = busy; - req->stale_oc = oc; - req->req_step = R_STP_MISS; - } else { - (void)HSH_DerefObjCore(wrk, &req->objcore, - HSH_RUSH_POLICY); - /* - * We don't have a busy object, so treat this - * like a pass - */ - VSLb(req->vsl, SLT_VCL_Error, - "vcl_hit{} returns miss without busy object." - " Doing pass."); - req->req_step = R_STP_PASS; - } - return (REQ_FSM_MORE); case VCL_RET_RESTART: req->req_step = R_STP_RESTART; break; diff --git a/bin/varnishtest/tests/r01335.vtc b/bin/varnishtest/tests/r01335.vtc deleted file mode 100644 index 1488c9822..000000000 --- a/bin/varnishtest/tests/r01335.vtc +++ /dev/null @@ -1,25 +0,0 @@ -varnishtest "#1335 fetch without busy object" - -server s1 { - rxreq - txresp -bodylen 5 - rxreq - txresp -bodylen 6 -} -start - -varnish v1 -vcl+backend { - sub vcl_hit { - if (req.http.two == "2") { - return (miss); // also #1603 - } - } -} -start - -client c1 { - txreq - rxresp -} -run -client c1 { - txreq -hdr "two: 2" - rxresp -} -run diff --git a/doc/graphviz/cache_req_fsm.dot b/doc/graphviz/cache_req_fsm.dot index 629072dc5..bf777fdcd 100644 --- a/doc/graphviz/cache_req_fsm.dot +++ b/doc/graphviz/cache_req_fsm.dot @@ -133,7 +133,6 @@ 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 [color=blue,label=" #1799 \n EOL"] lookup2:pass:s -> pass [style=bold,color=red] /* cnt_miss */ diff --git a/lib/libvcc/generate.py b/lib/libvcc/generate.py index 5f7191f11..991c29ae6 100755 --- a/lib/libvcc/generate.py +++ b/lib/libvcc/generate.py @@ -115,7 +115,7 @@ returns = ( ), ('hit', "C", - ('fail', 'synth', 'restart', 'pass', 'miss', 'deliver',) + ('fail', 'synth', 'restart', 'pass', 'deliver',) ), ('deliver', "C", From nils.goroll at uplex.de Mon Mar 4 13:03:06 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 4 Mar 2019 13:03:06 +0000 (UTC) Subject: [master] b10f2a6f2 Update FSM svg Message-ID: <20190304130306.6033F63927@lists.varnish-cache.org> commit b10f2a6f26f171e039743e4e068068a1f0a48417 Author: Nils Goroll Date: Mon Mar 4 14:02:21 2019 +0100 Update FSM svg Ref #2859 diff --git a/doc/graphviz/cache_req_fsm.svg b/doc/graphviz/cache_req_fsm.svg index eeb0a75c8..97da4c954 100644 --- a/doc/graphviz/cache_req_fsm.svg +++ b/doc/graphviz/cache_req_fsm.svg @@ -4,509 +4,502 @@ - - + + 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 - -pass - -restart - -synth - -miss + +cnt_lookup: + +vcl_hit{} + +req.* + +obj.* + +fail + +deliver + +pass + +restart + +synth + +miss lookup2:deliver:s->deliver:n - - + + lookup2:deliver:s->BGFETCH - - -parallel -if obj expired - - -miss - -cnt_miss: - -vcl_miss{} - -req.* - -fail - -fetch - -synth - -restart - -pass - - -lookup2:miss:s->miss - - - #1799 - EOL + + +parallel +if obj expired 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-miss? - -hit-for-pass? - -busy? + +cnt_lookup: + +hash lookup + +hit? + +miss? + +hit-for-miss? + +hit-for-pass? + +busy? lookup:h:s->lookup2 - - + + lookup:busy:s->lookup:top:ne - - - waitinglist + + + waitinglist + + +miss + +cnt_miss: + +vcl_miss{} + +req.* + +fail + +fetch + +synth + +restart + +pass lookup:miss:s->miss - - + + lookup:hfm:s->miss - - - req. - is_hitmiss + + + req. + is_hitmiss lookup:hfp:s->pass - - - req. - is_hitpass + + + 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 nils.goroll at uplex.de Mon Mar 4 13:10:09 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 4 Mar 2019 13:10:09 +0000 (UTC) Subject: [master] b73c8827b document removed return(miss) from vcl_hit Message-ID: <20190304131009.BC02363DCE@lists.varnish-cache.org> commit b73c8827bc84439eba6994750c8889188d94ce2b Author: Nils Goroll Date: Mon Mar 4 14:09:01 2019 +0100 document removed return(miss) from vcl_hit Ref #2859 #1799 diff --git a/doc/sphinx/whats-new/changes-trunk.rst b/doc/sphinx/whats-new/changes-trunk.rst index 04dc342a8..521427c37 100644 --- a/doc/sphinx/whats-new/changes-trunk.rst +++ b/doc/sphinx/whats-new/changes-trunk.rst @@ -78,6 +78,10 @@ component listening at the socket, or set the socket's permissions, after starting Varnish or loading VCL. If the socket still cannot be accessed when a fetch is attempted, then the fetch fails. +``return(miss)`` from ``vcl_hit{}`` did never work as intended for the +common case (it actually turned into a pass), so we now removed it and +changed the ``builtin.vcl``. + VMODs ===== diff --git a/doc/sphinx/whats-new/upgrading-trunk.rst b/doc/sphinx/whats-new/upgrading-trunk.rst index e46362048..9eaa3b662 100644 --- a/doc/sphinx/whats-new/upgrading-trunk.rst +++ b/doc/sphinx/whats-new/upgrading-trunk.rst @@ -44,6 +44,15 @@ listening at the socket, or set its permissions, after Varnish starts or the VCL is loaded. Backend fetches fail if the socket is not accessible by the time the fetch is attempted. + +``return(miss)`` from ``vcl_hit{}`` is now removed. Options to +implement similar functionality are: + +* a vmod using the new *catflap* mechanism + +* ``return (restart)`` from ``vcl_hit{}`` and ``set + req.hash_always_miss = true;`` in ``vcl_recv{}`` for the restart. + Runtime parameters ================== From nils.goroll at uplex.de Mon Mar 4 13:30:09 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 4 Mar 2019 13:30:09 +0000 (UTC) Subject: [master] 3ad673f2b Document vmod_std changes Message-ID: <20190304133009.C919864561@lists.varnish-cache.org> commit 3ad673f2b67590014127e78f6d826363607532ec Author: Nils Goroll Date: Mon Mar 4 14:27:36 2019 +0100 Document vmod_std changes Ref #2899 diff --git a/doc/sphinx/whats-new/changes-trunk.rst b/doc/sphinx/whats-new/changes-trunk.rst index 521427c37..050483955 100644 --- a/doc/sphinx/whats-new/changes-trunk.rst +++ b/doc/sphinx/whats-new/changes-trunk.rst @@ -88,6 +88,32 @@ VMODs Added the function :ref:`vmod_directors.lookup`, only for use in ``vcl_init`` or ``vcl_fini``. +The type-conversion functions in :ref:`vmod_std(3)` have been reworked +to make them more flexible and easier to use: +:ref:`vmod_std.duration`, :ref:`vmod_std.bytes`, +:ref:`vmod_std.integer`, :ref:`vmod_std.real` and :ref:`vmod_std.time` +now also accept suitable numeral or quantitative arguments. + +These type-conversion functions should be fully backwards compatible, +but the following differences should be noted: + +* The *fallback* is not required and more. A conversion failure in the + absense of a *fallback* argument will now trigger a VCL failure. + +* A VCL failure will also be triggered if no or more than one argument + (plus optional *fallback*) is given. + +* Conversion functions now only ever truncate if necessary (instead of + rounding). + +* :ref:`vmod_std.round` has been added for explicit rounding. + +The functions :ref:`vmod_std.real2integer`, :ref:`vmod_std.real2time`, +:ref:`vmod_std.time2integer` and :ref:`vmod_std.time2real` are +superseded by these changed and should thus be replaced by the above +mentioned conversion functions. They will be removed in a future +version of Varnish. + varnishlog(1), varnishncsa(1) and vsl(7) ======================================== From nils.goroll at uplex.de Mon Mar 4 14:26:08 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 4 Mar 2019 14:26:08 +0000 (UTC) Subject: [master] b815ceb35 bring more nuance to backend.list output for directors Message-ID: <20190304142608.35A4865883@lists.varnish-cache.org> commit b815ceb3517aab699abed7d526bff1fd180446b9 Author: Nils Goroll Date: Tue Feb 5 10:40:32 2019 +0100 bring more nuance to backend.list output for directors by example of the round-robin director Also changes the backend probe state good->healthy bad->sick for consistency diff --git a/bin/varnishd/cache/cache_backend_probe.c b/bin/varnishd/cache/cache_backend_probe.c index 8e0d22036..c7dbb2247 100644 --- a/bin/varnishd/cache/cache_backend_probe.c +++ b/bin/varnishd/cache/cache_backend_probe.c @@ -524,10 +524,10 @@ VBP_Status(struct vsb *vsb, const struct backend *be, int details, int json) if (json) VSB_printf(vsb, "[%u, %u, \"%s\"]", vt->good, vt->window, - vt->backend->director->sick ? "bad" : "good"); + vt->backend->director->sick ? "sick" : "healthy"); else VSB_printf(vsb, "%u/%u %s", vt->good, vt->window, - vt->backend->director->sick ? "bad" : "good"); + vt->backend->director->sick ? "sick" : "healthy"); return; } diff --git a/bin/varnishd/cache/cache_director.c b/bin/varnishd/cache/cache_director.c index 5161be684..e4e86511c 100644 --- a/bin/varnishd/cache/cache_director.c +++ b/bin/varnishd/cache/cache_director.c @@ -229,6 +229,26 @@ VRT_Healthy(VRT_CTX, VCL_BACKEND d, VCL_TIME *changed) return (d->vdir->methods->healthy(ctx, d, changed)); } +/*-------------------------------------------------------------------- + * Update health_changed. This is for load balancing directors + * to update their health_changed time based on their backends. + */ +VCL_VOID +VRT_SetChanged(VRT_CTX, VCL_BACKEND d, VCL_TIME changed) +{ + (void)ctx; + + if (d == NULL) + return; + + CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); + + if (changed <= d->vdir->health_changed) + return; + + d->vdir->health_changed = changed; +} + /* Send Event ---------------------------------------------------------- */ diff --git a/include/vrt.h b/include/vrt.h index 2b377947a..ca821d591 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -63,6 +63,7 @@ * use: AZ(ObjGetU64(req->wrk, req->body_oc, OA_LEN, &u)); * struct vdi_methods .list callback signature changed * VRT_LookupDirector() added + * VRT_SetChanged() added * 8.0 (2018-09-15) * VRT_Strands() added * VRT_StrandsWS() added @@ -524,6 +525,7 @@ struct director { }; VCL_BOOL VRT_Healthy(VRT_CTX, VCL_BACKEND, VCL_TIME *); +VCL_VOID VRT_SetChanged(VRT_CTX, VCL_BACKEND, VCL_TIME); 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); diff --git a/lib/libvmod_directors/round_robin.c b/lib/libvmod_directors/round_robin.c index bd50bfedd..f7c3afb60 100644 --- a/lib/libvmod_directors/round_robin.c +++ b/lib/libvmod_directors/round_robin.c @@ -44,7 +44,7 @@ struct vmod_directors_round_robin { unsigned nxt; }; -static VCL_BOOL v_matchproto_(vdi_healthy) +static VCL_BOOL v_matchproto_(vdi_healthy_f) vmod_rr_healthy(VRT_CTX, VCL_BACKEND dir, VCL_TIME *changed) { struct vmod_directors_round_robin *rr; @@ -55,6 +55,17 @@ vmod_rr_healthy(VRT_CTX, VCL_BACKEND dir, VCL_TIME *changed) return (vdir_any_healthy(ctx, rr->vd, changed)); } +static void v_matchproto_(vdi_list_f) +vmod_rr_list(VRT_CTX, VCL_BACKEND dir, struct vsb *vsb, int pflag, int jflag) +{ + struct vmod_directors_round_robin *rr; + + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + CHECK_OBJ_NOTNULL(dir, DIRECTOR_MAGIC); + CAST_OBJ_NOTNULL(rr, dir->priv, VMOD_DIRECTORS_ROUND_ROBIN_MAGIC); + return (vdir_list(ctx, rr->vd, vsb, pflag, jflag)); +} + static VCL_BACKEND v_matchproto_(vdi_resolve_f) vmod_rr_resolve(VRT_CTX, VCL_BACKEND dir) { @@ -96,7 +107,8 @@ static const struct vdi_methods vmod_rr_methods[1] = {{ .type = "round-robin", .healthy = vmod_rr_healthy, .resolve = vmod_rr_resolve, - .destroy = vmod_rr_destroy + .destroy = vmod_rr_destroy, + .list = vmod_rr_list }}; VCL_VOID v_matchproto_() diff --git a/lib/libvmod_directors/vdir.c b/lib/libvmod_directors/vdir.c index 50deb0244..865ee1979 100644 --- a/lib/libvmod_directors/vdir.c +++ b/lib/libvmod_directors/vdir.c @@ -29,10 +29,12 @@ #include "config.h" #include +#include #include "cache/cache.h" #include "vbm.h" +#include "vsb.h" #include "vdir.h" @@ -192,6 +194,74 @@ vdir_any_healthy(VRT_CTX, struct vdir *vd, VCL_TIME *changed) return (retval); } +void +vdir_list(VRT_CTX, struct vdir *vd, struct vsb *vsb, int pflag, int jflag) +{ + VCL_TIME c, changed = 0; + VCL_BACKEND be; + VCL_BOOL h; + unsigned u, nh = 0; + + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + CHECK_OBJ_NOTNULL(vd, VDIR_MAGIC); + + if (pflag) { + if (jflag) { + VSB_printf(vsb, "{\n"); + VSB_indent(vsb, 2); + } else { + VSB_printf(vsb, "\n"); + } + } + + vdir_rdlock(vd); + for (u = 0; u < vd->n_backend; u++) { + be = vd->backend[u]; + CHECK_OBJ_NOTNULL(be, DIRECTOR_MAGIC); + c = 0; + h = VRT_Healthy(ctx, be, &c); + if (h) + nh++; + if (c > changed) + changed = c; + if ((pflag) == 0) + continue; + if (jflag) { + if (u) + VSB_printf(vsb, ",\n"); + VSB_printf(vsb, "\"%s\": \"%s\"", + be->vcl_name, h ? "healthy" : "sick"); + } else { + VSB_printf(vsb, "\t%s: %s\n", + be->vcl_name, h ? "healthy" : "sick"); + } + } + vdir_unlock(vd); + + VRT_SetChanged(ctx, vd->dir, changed); + + if (jflag && (pflag)) { + VSB_printf(vsb, "\n"); + VSB_indent(vsb, -2); + VSB_printf(vsb, "},\n"); + } + + if (pflag) + return; + + /* + * for health state, the api-correct thing would be to call our own + * healthy function, but that would just re-iterate the backends for no + * real benefit + */ + + if (jflag) + VSB_printf(vsb, "[%u, %u, \"%s\"]", nh, u, + nh ? "healthy" : "sick"); + else + VSB_printf(vsb, "%u/%u %s", nh, u, nh ? "healthy" : "sick"); +} + static unsigned vdir_pick_by_weight(const struct vdir *vd, double w, const struct vbitmap *blacklist) diff --git a/lib/libvmod_directors/vdir.h b/lib/libvmod_directors/vdir.h index 15d79992a..7afbcdead 100644 --- a/lib/libvmod_directors/vdir.h +++ b/lib/libvmod_directors/vdir.h @@ -50,4 +50,5 @@ void vdir_unlock(struct vdir *vd); void vdir_add_backend(VRT_CTX, struct vdir *, VCL_BACKEND, double weight); void vdir_remove_backend(VRT_CTX, struct vdir *, VCL_BACKEND, unsigned *cur); VCL_BOOL vdir_any_healthy(VRT_CTX, struct vdir *, VCL_TIME *); +void vdir_list(VRT_CTX, struct vdir *, struct vsb *, int, int); VCL_BACKEND vdir_pick_be(VRT_CTX, struct vdir *, double w); From nils.goroll at uplex.de Mon Mar 4 14:48:07 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 4 Mar 2019 14:48:07 +0000 (UTC) Subject: [master] 93a188354 fix glitches Message-ID: <20190304144807.BCEA66E235@lists.varnish-cache.org> commit 93a188354338133439c34a0d8f1d4bc4e747e9a2 Author: Nils Goroll Date: Mon Mar 4 15:41:14 2019 +0100 fix glitches Ref: #2896 diff --git a/bin/varnishtest/tests/o00004.vtc b/bin/varnishtest/tests/o00004.vtc index 6aa345c33..5effa2890 100644 --- a/bin/varnishtest/tests/o00004.vtc +++ b/bin/varnishtest/tests/o00004.vtc @@ -49,5 +49,5 @@ varnish v2 -vcl { server s1 -wait delay 1 -varnish v2 -cliexpect "vcl1.bp1[ ]+probe[ ]+1/1[ ]+good" backend.list -varnish v2 -cliexpect "vcl1.bp2[ ]+probe[ ]+1/1[ ]+good" backend.list +varnish v2 -cliexpect "vcl1.bp1[ ]+probe[ ]+1/1[ ]+healthy" backend.list +varnish v2 -cliexpect "vcl1.bp2[ ]+probe[ ]+1/1[ ]+healthy" backend.list diff --git a/bin/varnishtest/tests/r02702.vtc b/bin/varnishtest/tests/r02702.vtc index c9a938a90..a68c9acb3 100644 --- a/bin/varnishtest/tests/r02702.vtc +++ b/bin/varnishtest/tests/r02702.vtc @@ -29,7 +29,7 @@ varnish v1 -vcl { delay 1 -varnish v1 -cliexpect "vcl1.s1[ ]+probe[ ]+1/1[ ]+good" backend.list +varnish v1 -cliexpect "vcl1.s1[ ]+probe[ ]+1/1[ ]+healthy" backend.list # For PROXYv2, we apply a trick similar to o0000[24].vtc, since # Varnish accepts (and ignores) PROXY LOCAL. @@ -63,7 +63,7 @@ server s1 -wait delay 1 -varnish v3 -cliexpect "vcl1.bp[ ]+probe[ ]+1/1[ ]+good" backend.list +varnish v3 -cliexpect "vcl1.bp[ ]+probe[ ]+1/1[ ]+healthy" backend.list # Verify in the v2 log that PROXY LOCAL was sent. diff --git a/lib/libvmod_directors/round_robin.c b/lib/libvmod_directors/round_robin.c index f7c3afb60..ff8ff7799 100644 --- a/lib/libvmod_directors/round_robin.c +++ b/lib/libvmod_directors/round_robin.c @@ -63,7 +63,7 @@ vmod_rr_list(VRT_CTX, VCL_BACKEND dir, struct vsb *vsb, int pflag, int jflag) CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(dir, DIRECTOR_MAGIC); CAST_OBJ_NOTNULL(rr, dir->priv, VMOD_DIRECTORS_ROUND_ROBIN_MAGIC); - return (vdir_list(ctx, rr->vd, vsb, pflag, jflag)); + vdir_list(ctx, rr->vd, vsb, pflag, jflag); } static VCL_BACKEND v_matchproto_(vdi_resolve_f) From nils.goroll at uplex.de Mon Mar 4 16:22:07 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 4 Mar 2019 16:22:07 +0000 (UTC) Subject: [master] 70d2425c5 VDI_Resolve() should not return a director which is admin-unhealthy Message-ID: <20190304162207.82EF610101D@lists.varnish-cache.org> commit 70d2425c597641bc241554ed010177791eec9daf Author: Nils Goroll Date: Mon Mar 4 17:18:52 2019 +0100 VDI_Resolve() should not return a director which is admin-unhealthy Implicitly fixes the same issue for VDI_GetHdr diff --git a/bin/varnishd/cache/cache_director.c b/bin/varnishd/cache/cache_director.c index e4e86511c..b78e6c863 100644 --- a/bin/varnishd/cache/cache_director.c +++ b/bin/varnishd/cache/cache_director.c @@ -95,11 +95,17 @@ VDI_Resolve(VRT_CTX) VSLb(bo->vsl, SLT_FetchError, "Director %s returned no backend", d->vcl_name); } + CHECK_OBJ_ORNULL(d, DIRECTOR_MAGIC); - if (d == NULL) + if (d == NULL) { VSLb(bo->vsl, SLT_FetchError, "No backend"); - else + } else { AN(d->vdir); + + if (d->vdir->admin_health->health == 0) + d = NULL; + } + return (d); } From phk at FreeBSD.org Mon Mar 4 22:13:06 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 4 Mar 2019 22:13:06 +0000 (UTC) Subject: [master] e34de5c17 Fix a race condition where we do not allow reuse of a stream-allowance as soon as a RST_STREAM has been received. Message-ID: <20190304221306.1093E107257@lists.varnish-cache.org> commit e34de5c17515d9975588becde2577db60858fcc9 Author: Poul-Henning Kamp Date: Mon Mar 4 22:11:09 2019 +0000 Fix a race condition where we do not allow reuse of a stream-allowance as soon as a RST_STREAM has been received. Testcase by: xcir Fixes: #2923 diff --git a/bin/varnishd/http2/cache_http2.h b/bin/varnishd/http2/cache_http2.h index 70e31d14e..958942f35 100644 --- a/bin/varnishd/http2/cache_http2.h +++ b/bin/varnishd/http2/cache_http2.h @@ -148,6 +148,7 @@ struct h2_sess { struct sess *sess; int refcnt; + int pending_kills; uint32_t highest_stream; int bogosity; int do_sweep; @@ -228,8 +229,7 @@ void H2_Send(struct worker *, struct h2_req *, struct h2_req * h2_new_req(const struct worker *, struct h2_sess *, unsigned stream, struct req *); void h2_del_req(struct worker *, const struct h2_req *); -void h2_kill_req(struct worker *, const struct h2_sess *, - struct h2_req *, h2_error); +void h2_kill_req(struct worker *, struct h2_sess *, struct h2_req *, h2_error); int h2_rxframe(struct worker *, struct h2_sess *); h2_error h2_set_setting(struct h2_sess *, const uint8_t *); void h2_req_body(struct req*); diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index b7c319102..17081da5a 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -197,6 +197,8 @@ h2_del_req(struct worker *wrk, const struct h2_req *r2) Lck_Lock(&sp->mtx); assert(h2->refcnt > 0); --h2->refcnt; + if (h2->pending_kills > 0) + h2->pending_kills--; /* XXX: PRIORITY reshuffle */ VTAILQ_REMOVE(&h2->streams, r2, list); Lck_Unlock(&sp->mtx); @@ -206,14 +208,16 @@ h2_del_req(struct worker *wrk, const struct h2_req *r2) } void -h2_kill_req(struct worker *wrk, const struct h2_sess *h2, +h2_kill_req(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2, h2_error h2e) { ASSERT_RXTHR(h2); AN(h2e); Lck_Lock(&h2->sess->mtx); - VSLb(h2->vsl, SLT_Debug, "KILL st=%u state=%d", r2->stream, r2->state); + VSLb(h2->vsl, SLT_Debug, "KILL st=%u state=%d sched=%d", + r2->stream, r2->state, r2->scheduled); + h2->pending_kills++; if (r2->error == NULL) r2->error = h2e; if (r2->scheduled) { @@ -634,7 +638,8 @@ 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->pending_kills > + 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/r02923.vtc b/bin/varnishtest/tests/r02923.vtc new file mode 100644 index 000000000..ee332df3e --- /dev/null +++ b/bin/varnishtest/tests/r02923.vtc @@ -0,0 +1,82 @@ +varnishtest "race cond in max_concurrent_streams when request after receiving RST_STREAM" + +barrier b1 sock 6 +barrier b2 sock 6 +barrier b3 sock 6 +barrier b4 sock 6 + +server s1 { + rxreq + txresp +} -start + +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 -vcl+backend { + import vtc; + + sub vcl_recv { + } + + sub vcl_backend_fetch { + vtc.barrier_sync("${b1_sock}"); + vtc.barrier_sync("${b2_sock}"); + vtc.barrier_sync("${b3_sock}"); + vtc.barrier_sync("${b4_sock}"); + } +} -start + +client c1 { + txpri + stream 0 rxsettings -run + + stream 1 { + txreq + barrier b1 sync + barrier b2 sync + barrier b3 sync + barrier b4 sync + rxresp + expect resp.status == 200 + } -start + + stream 3 { + barrier b1 sync + txreq + txrst -err 0x8 + barrier b2 sync + barrier b3 sync + barrier b4 sync + } -start + + stream 5 { + barrier b1 sync + barrier b2 sync + txreq + txrst -err 0x8 + barrier b3 sync + barrier b4 sync + } -start + + stream 7 { + barrier b1 sync + barrier b2 sync + barrier b3 sync + txreq + barrier b4 sync + rxresp + expect resp.status == 200 + } -start + + stream 9 { + barrier b1 sync + barrier b2 sync + barrier b3 sync + barrier b4 sync + txreq + rxresp + expect resp.status == 200 + } -start +} -run From phk at FreeBSD.org Mon Mar 4 23:09:06 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 4 Mar 2019 23:09:06 +0000 (UTC) Subject: [master] 14721f537 On platforms without closefrom() try to find out the highest open fd by reading /proc/`getpid`/fd directory. Message-ID: <20190304230906.CF41A108378@lists.varnish-cache.org> commit 14721f5379ea644cec138dc73958ecbfcee09888 Author: Poul-Henning Kamp Date: Mon Mar 4 23:06:43 2019 +0000 On platforms without closefrom() try to find out the highest open fd by reading /proc/`getpid`/fd directory. If it fails we fall back to sysconf(_SC_OPEN_MAX) as usual. diff --git a/lib/libvarnish/vsub.c b/lib/libvarnish/vsub.c index 06457992c..fc2083cbb 100644 --- a/lib/libvarnish/vsub.c +++ b/lib/libvarnish/vsub.c @@ -33,10 +33,14 @@ #include +#include #include #include // Solaris closefrom(3c) #include #include +#ifndef HAVE_CLOSEFROM +# include +#endif #include "vdef.h" @@ -61,8 +65,32 @@ VSUB_closefrom(int fd) #ifdef HAVE_CLOSEFROM closefrom(fd); + return; #else - int i = sysconf(_SC_OPEN_MAX); + char buf[128]; + int i, maxfd = 0; + DIR *d; + struct dirent *de; + char *p; + + bprintf(buf, "/proc/%d/fd/", getpid()); + d = opendir(buf); + if (d != NULL) { + while (1) { + de = readdir(d); + if (de == NULL) + break; + i = strtoul(de->d_name, &p, 10); + if (*p != '\0') + continue; + if (i > maxfd) + maxfd = i; + } + AZ(closedir(d)); + } + + if (maxfd == 0) + maxfd = sysconf(_SC_OPEN_MAX); assert(i > 0); for (; i > fd; i--) (void)close(i); From phk at FreeBSD.org Mon Mar 4 23:13:07 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 4 Mar 2019 23:13:07 +0000 (UTC) Subject: [master] 6ab261261 Always look for .rej files... Message-ID: <20190304231307.28C9F1085BC@lists.varnish-cache.org> commit 6ab26126194fc81017c1847925b7ea4fc2b10969 Author: Poul-Henning Kamp Date: Mon Mar 4 23:12:27 2019 +0000 Always look for .rej files... diff --git a/lib/libvarnish/vsub.c b/lib/libvarnish/vsub.c index fc2083cbb..3a497c9c4 100644 --- a/lib/libvarnish/vsub.c +++ b/lib/libvarnish/vsub.c @@ -91,9 +91,9 @@ VSUB_closefrom(int fd) if (maxfd == 0) maxfd = sysconf(_SC_OPEN_MAX); - assert(i > 0); - for (; i > fd; i--) - (void)close(i); + assert(maxfd > 0); + for (; maxfd > fd; maxfd--) + (void)close(maxfd); #endif } From nils.goroll at uplex.de Tue Mar 5 11:09:03 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Tue, 5 Mar 2019 11:09:03 +0000 (UTC) Subject: [master] b16a9d9a8 Retire (struct director).sick and VRT_SetHealth() Message-ID: <20190305110903.6623D11679C@lists.varnish-cache.org> commit b16a9d9a8d000a0c9fcac2245ec0e6e0bd5cbecb Author: Nils Goroll Date: Mon Mar 4 17:14:57 2019 +0100 Retire (struct director).sick and VRT_SetHealth() The sick state of the director and the healthy callback are the same thing coming from different directions: Either we query the status dynamically or we already have it. For layering directors, the health state is determined by their backends, so having a director-layer sick state does not make much sense and duplicates logic. Also, the sick field duplicates admin_health to some extend (see cache_director.c do_set_health). This is also relevant in the context of streamlining the backend.list output: admin_health "probe" only makes sense if backends actually do have a probe (= some dynamically determined health state). It appears streaight forward that the presense of a vdi_healthy_f callback is the signal for dynamically determined health state. So we move the sick field into VBE and retire VRT_SetHealth(). We also remove the ctx argument from VRT_SetChanged() because I previously overlooked that it is required, for example, in probe code where we got no ctx. Ref #2896 diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c index 3ff3c9ac7..d553d0317 100644 --- a/bin/varnishd/cache/cache_backend.c +++ b/bin/varnishd/cache/cache_backend.c @@ -122,7 +122,7 @@ vbe_dir_getfd(struct worker *wrk, struct backend *bp, struct busyobj *bo, CHECK_OBJ_NOTNULL(bp, BACKEND_MAGIC); AN(bp->vsc); - if (bp->director->sick) { + if (bp->sick) { VSLb(bo->vsl, SLT_FetchError, "backend %s: unhealthy", VRT_BACKEND_string(bp->director)); bp->vsc->unhealthy++; @@ -461,14 +461,33 @@ vbe_list(VRT_CTX, const struct director *d, struct vsb *vsb, int pflag, else if (jflag && pflag) VSB_printf(vsb, "{},\n"); else if (jflag) - VSB_printf(vsb, "\"%s\"", d->sick ? "sick" : "healthy"); + VSB_printf(vsb, "\"%s\"", bp->sick ? "sick" : "healthy"); else if (pflag) return; else VSB_printf(vsb, "%s", - d->sick ? "sick" : "healthy"); + bp->sick ? "sick" : "healthy"); } +/*-------------------------------------------------------------------- + */ + +static VCL_BOOL v_matchproto_(vdi_healthy_f) +vbe_healthy(VRT_CTX, VCL_BACKEND d, VCL_TIME *t) +{ + struct backend *bp; + + (void)ctx; + CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); + CAST_OBJ_NOTNULL(bp, d->priv, BACKEND_MAGIC); + + if (t != NULL) + *t = bp->changed; + + return (! bp->sick); +} + + /*-------------------------------------------------------------------- */ @@ -483,6 +502,20 @@ static const struct vdi_methods vbe_methods[1] = {{ .destroy = vbe_destroy, .panic = vbe_panic, .list = vbe_list, + .healthy = vbe_healthy +}}; + +static const struct vdi_methods vbe_methods_noprobe[1] = {{ + .magic = VDI_METHODS_MAGIC, + .type = "backend", + .http1pipe = vbe_dir_http1pipe, + .gethdrs = vbe_dir_gethdrs, + .getip = vbe_dir_getip, + .finish = vbe_dir_finish, + .event = vbe_dir_event, + .destroy = vbe_destroy, + .panic = vbe_panic, + .list = vbe_list }}; /*-------------------------------------------------------------------- @@ -542,8 +575,11 @@ VRT_new_backend_clustered(VRT_CTX, struct vsmw_cluster *vc, if (vbp != NULL) VBP_Insert(be, vbp, be->tcp_pool); + else + be->sick = 0; - be->director = VRT_AddDirector(ctx, vbe_methods, be, + be->director = VRT_AddDirector(ctx, + vbp != NULL ? vbe_methods : vbe_methods_noprobe, be, "%s", vrt->vcl_name); if (be->director != NULL) { diff --git a/bin/varnishd/cache/cache_backend.h b/bin/varnishd/cache/cache_backend.h index 796be9b32..c46e10365 100644 --- a/bin/varnishd/cache/cache_backend.h +++ b/bin/varnishd/cache/cache_backend.h @@ -57,6 +57,9 @@ struct backend { VRT_BACKEND_FIELDS() + unsigned sick; + vtim_real changed; + struct vbp_target *probe; struct vsc_seg *vsc_seg; diff --git a/bin/varnishd/cache/cache_backend_probe.c b/bin/varnishd/cache/cache_backend_probe.c index c7dbb2247..ba8316162 100644 --- a/bin/varnishd/cache/cache_backend_probe.c +++ b/bin/varnishd/cache/cache_backend_probe.c @@ -152,9 +152,8 @@ vbp_has_poked(struct vbp_target *vt) void VBP_Update_Backend(struct vbp_target *vt) { - unsigned i = 0; + unsigned i = 0, chg; char bits[10]; - const char *logmsg; CHECK_OBJ_NOTNULL(vt, VBP_TARGET_MAGIC); @@ -175,27 +174,21 @@ VBP_Update_Backend(struct vbp_target *vt) return; } - if (vt->good >= vt->threshold) { - if (vt->backend->director->sick) { - logmsg = "Back healthy"; - VRT_SetHealth(vt->backend->director, 1); - } else { - logmsg = "Still healthy"; - } - } else { - if (vt->backend->director->sick) { - logmsg = "Still sick"; - } else { - logmsg = "Went sick"; - VRT_SetHealth(vt->backend->director, 0); - } - } - VSL(SLT_Backend_health, 0, "%s %s %s %u %u %u %.6f %.6f %s", - vt->backend->director->vcl_name, logmsg, bits, + i = (vt->good < vt->threshold); + chg = (i != vt->backend->sick); + vt->backend->sick = i; + + VSL(SLT_Backend_health, 0, "%s %s %s %s %u %u %u %.6f %.6f %s", + vt->backend->director->vcl_name, chg ? "Went" : "Still", + i ? "sick" : "healthy", bits, vt->good, vt->threshold, vt->window, vt->last, vt->avg, vt->resp_buf); VBE_SetHappy(vt->backend, vt->happy); + if (chg) { + vt->backend->changed = VTIM_real(); + VRT_SetChanged(vt->backend->director, vt->backend->changed); + } Lck_Unlock(&vbp_mtx); } @@ -524,10 +517,10 @@ VBP_Status(struct vsb *vsb, const struct backend *be, int details, int json) if (json) VSB_printf(vsb, "[%u, %u, \"%s\"]", vt->good, vt->window, - vt->backend->director->sick ? "sick" : "healthy"); + vt->backend->sick ? "sick" : "healthy"); else VSB_printf(vsb, "%u/%u %s", vt->good, vt->window, - vt->backend->director->sick ? "sick" : "healthy"); + vt->backend->sick ? "sick" : "healthy"); return; } @@ -690,7 +683,7 @@ VBP_Remove(struct backend *be) CHECK_OBJ_NOTNULL(vt, VBP_TARGET_MAGIC); Lck_Lock(&vbp_mtx); - VRT_SetHealth(be->director, 1); + be->sick = 1; be->probe = NULL; vt->backend = NULL; if (vt->running) { diff --git a/bin/varnishd/cache/cache_director.c b/bin/varnishd/cache/cache_director.c index b78e6c863..064ac546b 100644 --- a/bin/varnishd/cache/cache_director.c +++ b/bin/varnishd/cache/cache_director.c @@ -229,21 +229,18 @@ VRT_Healthy(VRT_CTX, VCL_BACKEND d, VCL_TIME *changed) if (d->vdir->methods->healthy == NULL) { if (changed != NULL) *changed = d->vdir->health_changed; - return (!d->sick); + return (1); } return (d->vdir->methods->healthy(ctx, d, changed)); } /*-------------------------------------------------------------------- - * Update health_changed. This is for load balancing directors - * to update their health_changed time based on their backends. + * Update health_changed. */ VCL_VOID -VRT_SetChanged(VRT_CTX, VCL_BACKEND d, VCL_TIME changed) +VRT_SetChanged(VCL_BACKEND d, VCL_TIME changed) { - (void)ctx; - if (d == NULL) return; @@ -278,7 +275,6 @@ VDI_Panic(const struct director *d, struct vsb *vsb, const char *nm) VSB_printf(vsb, "%s = %p {\n", nm, d); VSB_indent(vsb, 2); VSB_printf(vsb, "cli_name = %s,\n", d->vdir->cli_name); - VSB_printf(vsb, "health = %s,\n", d->sick ? "sick" : "healthy"); VSB_printf(vsb, "admin_health = %s, changed = %f,\n", VDI_Ahealth(d), d->vdir->health_changed); VSB_printf(vsb, "type = %s {\n", d->vdir->methods->type); @@ -460,8 +456,6 @@ do_set_health(struct cli *cli, struct director *d, void *priv) if (d->vdir->admin_health != sh->ah) { d->vdir->health_changed = VTIM_real(); d->vdir->admin_health = sh->ah; - d->sick &= ~0x02; - d->sick |= sh->ah->health ? 0 : 0x02; } return (0); } diff --git a/bin/varnishd/cache/cache_vrt_vcl.c b/bin/varnishd/cache/cache_vrt_vcl.c index 3374f80f4..b70430edd 100644 --- a/bin/varnishd/cache/cache_vrt_vcl.c +++ b/bin/varnishd/cache/cache_vrt_vcl.c @@ -186,7 +186,6 @@ VRT_AddDirector(VRT_CTX, const struct vdi_methods *m, void *priv, d->vcl_name = vdir->cli_name + i; vdir->vcl = vcl; - d->sick = 0; vdir->admin_health = VDI_AH_PROBE; vdir->health_changed = VTIM_real(); @@ -231,22 +230,6 @@ VRT_DelDirector(VCL_BACKEND *bp) FREE_OBJ(vdir); } -void -VRT_SetHealth(VCL_BACKEND d, int health) -{ - struct vcldir *vdir; - - CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); - vdir = d->vdir; - CHECK_OBJ_NOTNULL(vdir, VCLDIR_MAGIC); - - if (health) - vdir->dir->sick &= ~0x01; - else - vdir->dir->sick |= 0x01; - vdir->health_changed = VTIM_real(); -} - void VRT_DisableDirector(VCL_BACKEND d) { @@ -257,7 +240,6 @@ VRT_DisableDirector(VCL_BACKEND d) CHECK_OBJ_NOTNULL(vdir, VCLDIR_MAGIC); vdir->admin_health = VDI_AH_DELETED; - vdir->dir->sick |= 0x04; vdir->health_changed = VTIM_real(); } diff --git a/include/vrt.h b/include/vrt.h index ca821d591..0d4b339a3 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -64,6 +64,7 @@ * struct vdi_methods .list callback signature changed * VRT_LookupDirector() added * VRT_SetChanged() added + * VRT_SetHealth() removed * 8.0 (2018-09-15) * VRT_Strands() added * VRT_StrandsWS() added @@ -518,17 +519,15 @@ struct vcldir; struct director { unsigned magic; #define DIRECTOR_MAGIC 0x3336351d - unsigned sick; void *priv; char *vcl_name; struct vcldir *vdir; }; VCL_BOOL VRT_Healthy(VRT_CTX, VCL_BACKEND, VCL_TIME *); -VCL_VOID VRT_SetChanged(VRT_CTX, VCL_BACKEND, VCL_TIME); +VCL_VOID VRT_SetChanged(VCL_BACKEND, VCL_TIME); 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 *); diff --git a/lib/libvmod_directors/vdir.c b/lib/libvmod_directors/vdir.c index 865ee1979..58b8b8dcc 100644 --- a/lib/libvmod_directors/vdir.c +++ b/lib/libvmod_directors/vdir.c @@ -238,7 +238,7 @@ vdir_list(VRT_CTX, struct vdir *vd, struct vsb *vsb, int pflag, int jflag) } vdir_unlock(vd); - VRT_SetChanged(ctx, vd->dir, changed); + VRT_SetChanged(vd->dir, changed); if (jflag && (pflag)) { VSB_printf(vsb, "\n"); From nils.goroll at uplex.de Tue Mar 5 11:09:03 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Tue, 5 Mar 2019 11:09:03 +0000 (UTC) Subject: [master] 7b658a48c rename admin_health probe -> auto, fix admin health output Message-ID: <20190305110903.7ECF511679F@lists.varnish-cache.org> commit 7b658a48ce4bc214e97fc7f44d6a9bf054cb250d Author: Nils Goroll Date: Mon Mar 4 16:00:42 2019 +0100 rename admin_health probe -> auto, fix admin health output backend.list now shows "probe" only if a probe is present. Ref #2896 diff --git a/bin/varnishd/cache/cache_director.c b/bin/varnishd/cache/cache_director.c index 064ac546b..345402798 100644 --- a/bin/varnishd/cache/cache_director.c +++ b/bin/varnishd/cache/cache_director.c @@ -60,7 +60,6 @@ vdi_str2ahealth(const char *t) #define VBE_AHEALTH(l,u,h) if (!strcasecmp(t, #l)) return (VDI_AH_##u); VBE_AHEALTH_LIST #undef VBE_AHEALTH - if (!strcasecmp(t, "auto")) return (VDI_AH_PROBE); return (NULL); } @@ -70,7 +69,11 @@ VDI_Ahealth(const struct director *d) CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC); AN(d->vdir->admin_health); - return (d->vdir->admin_health->name); + if (d->vdir->admin_health != VDI_AH_AUTO) + return (d->vdir->admin_health->name); + if (d->vdir->methods->healthy != NULL) + return ("probe"); + return ("healthy"); } /* Resolve director --------------------------------------------------*/ diff --git a/bin/varnishd/cache/cache_director.h b/bin/varnishd/cache/cache_director.h index d4553e150..7c0442513 100644 --- a/bin/varnishd/cache/cache_director.h +++ b/bin/varnishd/cache/cache_director.h @@ -46,7 +46,7 @@ struct vcldir { #define VBE_AHEALTH_LIST \ VBE_AHEALTH(healthy, HEALTHY, 1) \ VBE_AHEALTH(sick, SICK, 0) \ - VBE_AHEALTH(probe, PROBE, -1) \ + VBE_AHEALTH(auto, AUTO, -1) \ VBE_AHEALTH(deleted, DELETED, 0) #define VBE_AHEALTH(l,u,h) extern const struct vdi_ahealth * const VDI_AH_##u; diff --git a/bin/varnishd/cache/cache_vrt_vcl.c b/bin/varnishd/cache/cache_vrt_vcl.c index b70430edd..92ac448d3 100644 --- a/bin/varnishd/cache/cache_vrt_vcl.c +++ b/bin/varnishd/cache/cache_vrt_vcl.c @@ -186,7 +186,7 @@ VRT_AddDirector(VRT_CTX, const struct vdi_methods *m, void *priv, d->vcl_name = vdir->cli_name + i; vdir->vcl = vcl; - vdir->admin_health = VDI_AH_PROBE; + vdir->admin_health = VDI_AH_AUTO; vdir->health_changed = VTIM_real(); Lck_Lock(&vcl_mtx); From nils.goroll at uplex.de Tue Mar 5 11:09:03 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Tue, 5 Mar 2019 11:09:03 +0000 (UTC) Subject: [master] 82d8153af use 0/0 healthy for "no probe" in the probe field Message-ID: <20190305110903.9C3131167A2@lists.varnish-cache.org> commit 82d8153afb50928ba54f4152fd095f6fa3051c64 Author: Nils Goroll Date: Mon Mar 4 18:18:23 2019 +0100 use 0/0 healthy for "no probe" in the probe field Add another column for the probe result Ref #2896 diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c index d553d0317..2ba8e0a89 100644 --- a/bin/varnishd/cache/cache_backend.c +++ b/bin/varnishd/cache/cache_backend.c @@ -461,12 +461,11 @@ vbe_list(VRT_CTX, const struct director *d, struct vsb *vsb, int pflag, else if (jflag && pflag) VSB_printf(vsb, "{},\n"); else if (jflag) - VSB_printf(vsb, "\"%s\"", bp->sick ? "sick" : "healthy"); + VSB_printf(vsb, "[0, 0, \"healthy\"]"); else if (pflag) return; else - VSB_printf(vsb, "%s", - bp->sick ? "sick" : "healthy"); + VSB_cat(vsb, "0/0\thealthy"); } /*-------------------------------------------------------------------- diff --git a/bin/varnishd/cache/cache_backend_probe.c b/bin/varnishd/cache/cache_backend_probe.c index ba8316162..94757a6b3 100644 --- a/bin/varnishd/cache/cache_backend_probe.c +++ b/bin/varnishd/cache/cache_backend_probe.c @@ -519,7 +519,7 @@ VBP_Status(struct vsb *vsb, const struct backend *be, int details, int json) vt->good, vt->window, vt->backend->sick ? "sick" : "healthy"); else - VSB_printf(vsb, "%u/%u %s", vt->good, vt->window, + VSB_printf(vsb, "%u/%u\t%s", vt->good, vt->window, vt->backend->sick ? "sick" : "healthy"); return; } diff --git a/bin/varnishd/cache/cache_director.c b/bin/varnishd/cache/cache_director.c index 345402798..423eb0550 100644 --- a/bin/varnishd/cache/cache_director.c +++ b/bin/varnishd/cache/cache_director.c @@ -327,13 +327,14 @@ 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 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, la->vsb, 0, 0); + else if (d->vdir->methods->healthy != NULL) + VSB_printf(la->vsb, "0/0\t%s", cli_health(ctx, d)); else - VSB_printf(la->vsb, "%s", cli_health(ctx, d)); + VSB_cat(la->vsb, "0/0\thealthy"); VTIM_format(d->vdir->health_changed, time_str); VSB_printf(la->vsb, "\t%s", time_str); @@ -372,8 +373,11 @@ do_list_json(struct cli *cli, struct director *d, void *priv) VCLI_Out(cli, "\"probe_message\": "); if (d->vdir->methods->list != NULL) d->vdir->methods->list(ctx, d, cli->sb, 0, 1); + else if (d->vdir->methods->healthy != NULL) + VCLI_Out(cli, "[0, 0, \"%s\"]", cli_health(ctx, d)); else - VCLI_Out(cli, "\"%s\"", cli_health(ctx, d)); + VCLI_Out(cli, "[0, 0, \"healthy\"]"); + VCLI_Out(cli, ",\n"); if (la->p && d->vdir->methods->list != NULL) { @@ -431,8 +435,8 @@ cli_backend_list(struct cli *cli, const char * const *av, void *priv) } else { 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"); + VSB_printf(la->vsb, "%s\t%s\t%s\t%s\t%s\n", + "Backend name", "Admin", "Probe", "Health", "Last change"); (void)VCL_IterDirector(cli, av[i], do_list, la); VCLI_VTE(cli, &la->vsb, 80); } diff --git a/lib/libvmod_directors/vdir.c b/lib/libvmod_directors/vdir.c index 58b8b8dcc..323b155f3 100644 --- a/lib/libvmod_directors/vdir.c +++ b/lib/libvmod_directors/vdir.c @@ -259,7 +259,7 @@ vdir_list(VRT_CTX, struct vdir *vd, struct vsb *vsb, int pflag, int jflag) VSB_printf(vsb, "[%u, %u, \"%s\"]", nh, u, nh ? "healthy" : "sick"); else - VSB_printf(vsb, "%u/%u %s", nh, u, nh ? "healthy" : "sick"); + VSB_printf(vsb, "%u/%u\t%s", nh, u, nh ? "healthy" : "sick"); } static unsigned From nils.goroll at uplex.de Tue Mar 5 11:09:03 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Tue, 5 Mar 2019 11:09:03 +0000 (UTC) Subject: [master] 61a5add4c VSB_printf -> VSB_cat Message-ID: <20190305110903.B70351167A7@lists.varnish-cache.org> commit 61a5add4c349b9aae7466378a14d79d4d1fab8b6 Author: Nils Goroll Date: Tue Mar 5 11:39:18 2019 +0100 VSB_printf -> VSB_cat diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c index 2ba8e0a89..d5f5bb2ee 100644 --- a/bin/varnishd/cache/cache_backend.c +++ b/bin/varnishd/cache/cache_backend.c @@ -459,9 +459,9 @@ vbe_list(VRT_CTX, const struct director *d, struct vsb *vsb, int pflag, if (bp->probe != NULL) VBP_Status(vsb, bp, pflag, jflag); else if (jflag && pflag) - VSB_printf(vsb, "{},\n"); + VSB_cat(vsb, "{},\n"); else if (jflag) - VSB_printf(vsb, "[0, 0, \"healthy\"]"); + VSB_cat(vsb, "[0, 0, \"healthy\"]"); else if (pflag) return; else diff --git a/lib/libvmod_directors/vdir.c b/lib/libvmod_directors/vdir.c index 323b155f3..95afd315d 100644 --- a/lib/libvmod_directors/vdir.c +++ b/lib/libvmod_directors/vdir.c @@ -207,10 +207,10 @@ vdir_list(VRT_CTX, struct vdir *vd, struct vsb *vsb, int pflag, int jflag) if (pflag) { if (jflag) { - VSB_printf(vsb, "{\n"); + VSB_cat(vsb, "{\n"); VSB_indent(vsb, 2); } else { - VSB_printf(vsb, "\n"); + VSB_cat(vsb, "\n"); } } @@ -228,7 +228,7 @@ vdir_list(VRT_CTX, struct vdir *vd, struct vsb *vsb, int pflag, int jflag) continue; if (jflag) { if (u) - VSB_printf(vsb, ",\n"); + VSB_cat(vsb, ",\n"); VSB_printf(vsb, "\"%s\": \"%s\"", be->vcl_name, h ? "healthy" : "sick"); } else { @@ -241,9 +241,9 @@ vdir_list(VRT_CTX, struct vdir *vd, struct vsb *vsb, int pflag, int jflag) VRT_SetChanged(vd->dir, changed); if (jflag && (pflag)) { - VSB_printf(vsb, "\n"); + VSB_cat(vsb, "\n"); VSB_indent(vsb, -2); - VSB_printf(vsb, "},\n"); + VSB_cat(vsb, "},\n"); } if (pflag) From nils.goroll at uplex.de Tue Mar 5 12:06:08 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Tue, 5 Mar 2019 12:06:08 +0000 (UTC) Subject: [master] c8384298a docfix: bereq.body is not tied to pass any more Message-ID: <20190305120608.256EB117C82@lists.varnish-cache.org> commit c8384298a5b012f9613e4564db8ee734bd75dbac Author: Nils Goroll Date: Tue Mar 5 12:22:46 2019 +0100 docfix: bereq.body is not tied to pass any more diff --git a/doc/sphinx/reference/vcl_var.rst b/doc/sphinx/reference/vcl_var.rst index 2aedb54f7..ab8459496 100644 --- a/doc/sphinx/reference/vcl_var.rst +++ b/doc/sphinx/reference/vcl_var.rst @@ -510,7 +510,7 @@ bereq.body Unsetable from: vcl_backend_fetch - The request body, only present on `pass` requests. + The request body. Unset will also remove `bereq.http.Content-Length`. From nils.goroll at uplex.de Tue Mar 5 12:06:08 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Tue, 5 Mar 2019 12:06:08 +0000 (UTC) Subject: [master] 3d90373df backend.list doc Message-ID: <20190305120608.3D147117C86@lists.varnish-cache.org> commit 3d90373df69e7f0ceac3f0f91b11b469ff377d40 Author: Nils Goroll Date: Tue Mar 5 12:21:11 2019 +0100 backend.list doc diff --git a/include/tbl/cli_cmds.h b/include/tbl/cli_cmds.h index 0bc1e0f0f..ee0da1bd5 100644 --- a/include/tbl/cli_cmds.h +++ b/include/tbl/cli_cmds.h @@ -273,25 +273,35 @@ CLI_CMD(BACKEND_LIST, " ``-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, " + " the output format is five 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" + " * ``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 or some other\n" + " dynamic mechanism.\n\n" + " * ``deleted``: Backend has been deleted, but not yet cleaned\n" + " up.\n\n" + " Admin has precedence over Health\n\n" + " * Probe *X*\\ /\\ *Y*: *X* out of *Y* checks have succeeded\n\n" + " *X* and *Y* are backend specific and may represent probe checks,\n" + " other backends or any other metric.\n\n" + " If there is no probe or the director does not provide details on\n" + " probe check results, ``0/0`` is output.\n\n" + " * Health: Probe health state\n\n" + " * ``healthy``\n\n" + " * ``sick``\n\n" + " If there is no probe, ``healthy`` is output.\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 VCL (e.g. using std.healthy()) may differ.", + "from VCL (e.g. using ``std.healthy()``) may differ.\n\n" + " For ``-j``, the object members should be self explanatory,\n" + " matching the fields described above. ``probe_message`` has the\n" + " format ``[X, Y, \"state\"]`` as described above for Probe. JSON\n" + " Probe details (``-j -p`` arguments) are director specific.", 0, 2 ) From nils.goroll at uplex.de Tue Mar 5 12:06:08 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Tue, 5 Mar 2019 12:06:08 +0000 (UTC) Subject: [master] 2107068a9 update directors developer docs Message-ID: <20190305120608.59F3F117C8C@lists.varnish-cache.org> commit 2107068a9bfd34519638eb2691811ce4c855c349 Author: Nils Goroll Date: Tue Mar 5 12:41:10 2019 +0100 update directors developer docs diff --git a/doc/sphinx/reference/directors.rst b/doc/sphinx/reference/directors.rst index 8758b4535..ace8b69d3 100644 --- a/doc/sphinx/reference/directors.rst +++ b/doc/sphinx/reference/directors.rst @@ -52,7 +52,6 @@ code instead:: struct director { unsigned magic; #define DIRECTOR_MAGIC 0x3336351d - unsigned sick; void *priv; char *vcl_name; struct vcldir *vdir; @@ -62,8 +61,9 @@ A director can be summed up as: - being of a specific ``type`` with a set of operations which is identical for all instances of that particular type -- some instance specific attributes such as a ``vcl_name``, health - state and ``type``\ -specific private data + +- some instance specific attributes such as a ``vcl_name`` + and ``type``\ -specific private data The difference between a *load balancing* director and a *backend* director is mainly the functions they will implement. @@ -71,14 +71,21 @@ director is mainly the functions they will implement. The fundamental steps towards a director implementation are: - implement the required functions + - fill a ``struct vdi_methods`` with the name of your director type and your function pointers + + Existence of a ``healthy`` callback signifies that the director has + some means of dynamically determining its health state. + - in your constructor or other initialization routine, allocate and initialize your director-specific configuration state (aka private data) and call ``VRT_AddDirector()`` with your ``struct vdi_methods``, the pointer to your state and a printf format for the name of your director instance + - implement methods or functions returning ``VCL_BACKEND`` + - in your destructor or other finalizer, call ``VRT_DelDirector()`` For forwards compatibility, it is strongly recommended for the last From nils.goroll at uplex.de Tue Mar 5 12:06:08 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Tue, 5 Mar 2019 12:06:08 +0000 (UTC) Subject: [master] 342b706e8 director changes -> release notes, changes Message-ID: <20190305120608.7B7B4117C91@lists.varnish-cache.org> commit 342b706e8691b4d8f3464099e0892753e8f9d4f8 Author: Nils Goroll Date: Tue Mar 5 13:04:15 2019 +0100 director changes -> release notes, changes diff --git a/doc/changes.rst b/doc/changes.rst index 8d7d253e6..5e601b797 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -64,14 +64,12 @@ Varnish Cache trunk (ongoing) 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: + See release notes for details. - * 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/... +* The format of the ``backend.list -j`` (JSON) cli command output has + changed. -.. expecting more changes here #2896 + See release notes for details. * The undocumented ``-v`` option to the ``backend.list`` cli command has been removed @@ -197,6 +195,12 @@ C APIs (for vmod and utility authors) AZ(ObjGetU64(req->wrk, req->body_oc, OA_LEN, &u)); + * ``VRT_SetHealth()`` has been removed and ``VRT_SetChanged()`` + added. ``VRT_LookupDirector()`` (only to be called from CLI + contexts) as been added. + + See release notes for details + * 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 diff --git a/doc/sphinx/whats-new/changes-trunk.rst b/doc/sphinx/whats-new/changes-trunk.rst index 050483955..3c43b22ad 100644 --- a/doc/sphinx/whats-new/changes-trunk.rst +++ b/doc/sphinx/whats-new/changes-trunk.rst @@ -166,27 +166,47 @@ default, see :ref:`varnish-cli(7)`. .. _whatsnew_changes_vcl_list_backend_list: -Listing backends and VCLs -~~~~~~~~~~~~~~~~~~~~~~~~~ +Listing backends +~~~~~~~~~~~~~~~~ + +``backend.list`` has grown an additional column, the output has +changed and fields are now of dynamic width: + +* The ``Admin`` column now accurately states ``probe`` only if a + backend has some means of dynamically determining health state. + +* The ``Probe`` column has been changed to display ``X/Y``, where: + + * Integer ``X`` is the number of good probes in the most recent + window; or if the backend in question is a director, the number of + healthy backends accessed via the director or any other + director-specific metric. + + * Integer ``Y`` is the window in which the threshold for overall + health of the backend is defined (from the ``.window`` field of a + probe, see :ref:`vcl(7)`); or in the case of a director, the total + number of backends accessed via the director or any other + director-specific metric. -The "probe message" field in the output of ``backend.list`` (in the -``probe_message`` field of JSON format, or the ``Probe`` column of -non-JSON output) has been changed to display ``X/Y state``, where: + If there is no probe or the director does not provide details, + ``0/0`` is output. -* Integer ``X`` is the number of good probes in the most recent - window; or if the backend in question is a director, the number of - healthy backends accessed via the director. +* The ``Health`` column has been added to contain the dynamic (probe) + health state and the format has been unified to just ``healthy`` or + ``sick``. -* Integer ``Y`` is the window in which the threshold for overall - health of the backend is defined (from the ``.window`` field of a - probe, see :ref:`vcl(7)`); or in the case of a director, the total - number of backends accessed via the director. + If there is no probe, ``Health`` is always given as + ``healthy``. Notice that the administrative health as shown in the + ``Admin`` column has precedence. -* ``state`` is one of the strings ``"good"`` or ``"bad"``, for the - overall health of the backend or director. +In the ``probe_message`` field of ``backend.list -j`` output, the +``Probe`` and ``Health`` columns appears as the array ``[X, Y, +health]``. -In the ``probe_message`` field of ``backend.list -j`` output, this -appears as the array ``[X, Y, state]``. +See :ref:`varnish-cli(7)` for details. + +Listing VCLs +~~~~~~~~~~~~ The non-JSON output of ``vcl.list`` has been changed: @@ -251,4 +271,21 @@ Changes for developers and VMOD authors Python tools that generate code now prefer python 3 over python 2, when availabale. +Directors +~~~~~~~~~ + +The director API has been changed slightly: The most relevant design +change is that the ``healthy`` callback now is the only means to +determine a director's health state dynamically, the ``sick`` member +of ``struct director`` has been removed. Consequently, +``VRT_SetHealth()`` has been removed and ``VRT_SetChanged()`` added to +update the last health state change time. + +Presence of the ``healthy`` callback now also signifies if the +director is considered to have a *probe* with respect to the CLI. + +The signature of the ``list`` callback has been changed to reflect the +retirement of the undocumented ``backend.list -v`` parameter and to +add a ``VRT_CTX``. + *eof* From phk at FreeBSD.org Tue Mar 5 22:52:07 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 5 Mar 2019 22:52:07 +0000 (UTC) Subject: [master] 361070ea0 Reformat to avoid backslashes which makes Flexelint break out in hives. Message-ID: <20190305225207.B66DA1011D4@lists.varnish-cache.org> commit 361070ea0a8c85b815e5678ad0ae3fb8d13caa23 Author: Poul-Henning Kamp Date: Tue Mar 5 22:50:18 2019 +0000 Reformat to avoid backslashes which makes Flexelint break out in hives. diff --git a/include/tbl/cli_cmds.h b/include/tbl/cli_cmds.h index ee0da1bd5..f886f94db 100644 --- a/include/tbl/cli_cmds.h +++ b/include/tbl/cli_cmds.h @@ -284,7 +284,7 @@ CLI_CMD(BACKEND_LIST, " * ``deleted``: Backend has been deleted, but not yet cleaned\n" " up.\n\n" " Admin has precedence over Health\n\n" - " * Probe *X*\\ /\\ *Y*: *X* out of *Y* checks have succeeded\n\n" + " * Probe ``X/Y``: *X* out of *Y* checks have succeeded\n\n" " *X* and *Y* are backend specific and may represent probe checks,\n" " other backends or any other metric.\n\n" " If there is no probe or the director does not provide details on\n" From phk at FreeBSD.org Wed Mar 6 09:27:09 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 6 Mar 2019 09:27:09 +0000 (UTC) Subject: [master] a0ad90253 Fix #2923 properly by tracking which requests have been counted towards our max-session limit, and by adjusting the counts at frame rx/tx time. Message-ID: <20190306092709.1046010CEC3@lists.varnish-cache.org> commit a0ad902537bd0d14e663a7208f398ad55aed29e1 Author: Poul-Henning Kamp Date: Wed Mar 6 09:25:19 2019 +0000 Fix #2923 properly by tracking which requests have been counted towards our max-session limit, and by adjusting the counts at frame rx/tx time. Fixes: #2923 Thanks to: xcir diff --git a/bin/varnishd/http2/cache_http2.h b/bin/varnishd/http2/cache_http2.h index 958942f35..5399f2f98 100644 --- a/bin/varnishd/http2/cache_http2.h +++ b/bin/varnishd/http2/cache_http2.h @@ -119,6 +119,7 @@ struct h2_req { uint32_t stream; int scheduled; enum h2_stream_e state; + int counted; struct h2_sess *h2sess; struct req *req; double t_send; @@ -148,7 +149,7 @@ struct h2_sess { struct sess *sess; int refcnt; - int pending_kills; + int open_streams; uint32_t highest_stream; int bogosity; int do_sweep; diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index 17081da5a..370748ccd 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -197,8 +197,6 @@ h2_del_req(struct worker *wrk, const struct h2_req *r2) Lck_Lock(&sp->mtx); assert(h2->refcnt > 0); --h2->refcnt; - if (h2->pending_kills > 0) - h2->pending_kills--; /* XXX: PRIORITY reshuffle */ VTAILQ_REMOVE(&h2->streams, r2, list); Lck_Unlock(&sp->mtx); @@ -217,7 +215,11 @@ h2_kill_req(struct worker *wrk, struct h2_sess *h2, Lck_Lock(&h2->sess->mtx); VSLb(h2->vsl, SLT_Debug, "KILL st=%u state=%d sched=%d", r2->stream, r2->state, r2->scheduled); - h2->pending_kills++; + if (r2->counted) { + assert(h2->open_streams > 0); + h2->open_streams--; + r2->counted = 0; + } if (r2->error == NULL) r2->error = h2e; if (r2->scheduled) { @@ -638,7 +640,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->pending_kills > + if (h2->open_streams >= h2->local_settings.max_concurrent_streams) { VSLb(h2->vsl, SLT_Debug, "H2: stream %u: Hit maximum number of " @@ -647,6 +649,8 @@ h2_rx_headers(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) } h2->highest_stream = h2->rxf_stream; r2 = h2_new_req(wrk, h2, h2->rxf_stream, NULL); + r2->counted = 1; + h2->open_streams++; } CHECK_OBJ_NOTNULL(r2, H2_REQ_MAGIC); diff --git a/bin/varnishd/http2/cache_http2_send.c b/bin/varnishd/http2/cache_http2_send.c index 638fea632..b3eb68801 100644 --- a/bin/varnishd/http2/cache_http2_send.c +++ b/bin/varnishd/http2/cache_http2_send.c @@ -285,6 +285,15 @@ H2_Send(struct worker *wrk, struct h2_req *r2, Lck_Lock(&h2->sess->mtx); mfs = h2->remote_settings.max_frame_size; + if (r2->counted && ( + (ftyp == H2_F_HEADERS && (flags & H2FF_HEADERS_END_STREAM)) || + (ftyp == H2_F_DATA && (flags & H2FF_DATA_END_STREAM)) || + ftyp == H2_F_RST_STREAM + )) { + assert(h2->open_streams > 0); + h2->open_streams--; + r2->counted = 0; + } Lck_Unlock(&h2->sess->mtx); if (ftyp->respect_window) { diff --git a/bin/varnishtest/tests/r02923.vtc b/bin/varnishtest/tests/r02923.vtc index ee332df3e..324f20cff 100644 --- a/bin/varnishtest/tests/r02923.vtc +++ b/bin/varnishtest/tests/r02923.vtc @@ -1,13 +1,18 @@ varnishtest "race cond in max_concurrent_streams when request after receiving RST_STREAM" -barrier b1 sock 6 -barrier b2 sock 6 -barrier b3 sock 6 -barrier b4 sock 6 +barrier b1 sock 2 +barrier b2 sock 2 +barrier b3 sock 2 +barrier b4 sock 2 +barrier b5 sock 3 server s1 { - rxreq - txresp + rxreq + expect req.url == /nosync + txresp + rxreq + expect req.url == /sync + txresp } -start varnish v1 -cliok "param.set feature +http2" @@ -15,68 +20,81 @@ varnish v1 -cliok "param.set debug +syncvsl" varnish v1 -cliok "param.set h2_max_concurrent_streams 3" varnish v1 -vcl+backend { - import vtc; + import vtc; - sub vcl_recv { - } + sub vcl_recv { + } - sub vcl_backend_fetch { - vtc.barrier_sync("${b1_sock}"); - vtc.barrier_sync("${b2_sock}"); - vtc.barrier_sync("${b3_sock}"); - vtc.barrier_sync("${b4_sock}"); - } + sub vcl_backend_fetch { + if(bereq.url ~ "/sync"){ + vtc.barrier_sync("${b1_sock}"); + vtc.barrier_sync("${b5_sock}"); + } + } } -start client c1 { - txpri - stream 0 rxsettings -run - - stream 1 { - txreq - barrier b1 sync - barrier b2 sync - barrier b3 sync - barrier b4 sync - rxresp - expect resp.status == 200 - } -start - - stream 3 { - barrier b1 sync - txreq - txrst -err 0x8 - barrier b2 sync - barrier b3 sync - barrier b4 sync - } -start - - stream 5 { - barrier b1 sync - barrier b2 sync - txreq - txrst -err 0x8 - barrier b3 sync - barrier b4 sync - } -start - - stream 7 { - barrier b1 sync - barrier b2 sync - barrier b3 sync - txreq - barrier b4 sync - rxresp - expect resp.status == 200 - } -start - - stream 9 { - barrier b1 sync - barrier b2 sync - barrier b3 sync - barrier b4 sync - txreq - rxresp - expect resp.status == 200 - } -start + txpri + stream 0 rxsettings -run + + stream 1 { + txreq -url /sync + rxresp + expect resp.status == 200 + } -start + + stream 3 { + barrier b1 sync + delay .5 + # Goes on waiting list + txreq -url /sync + delay .5 + txrst -err 0x8 + delay .5 + barrier b2 sync + } -start + + stream 5 { + barrier b2 sync + txreq -url /nosync + delay .5 + rxresp + delay .5 + expect resp.status == 200 + barrier b3 sync + } -start + + stream 7 { + barrier b3 sync + # Goes on waiting list + txreq -url /sync + delay .5 + txrst -err 0x8 + delay .5 + barrier b4 sync + } -start + + stream 9 { + barrier b4 sync + # Goes on waiting list + txreq -url /sync + delay .5 + barrier b5 sync + delay .5 + rxresp + delay .5 + expect resp.status == 200 + } -start + + stream 11 { + barrier b5 sync + txreq -url /sync + delay .5 + rxresp + delay .5 + expect resp.status == 200 + } -start + + } -run + From phk at FreeBSD.org Wed Mar 6 10:44:08 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 6 Mar 2019 10:44:08 +0000 (UTC) Subject: [master] 70b7a75f6 Sync with VTEST Message-ID: <20190306104408.33F4310E575@lists.varnish-cache.org> commit 70b7a75f676208c6a604463678a2755b64791fe9 Author: Poul-Henning Kamp Date: Wed Mar 6 10:11:08 2019 +0000 Sync with VTEST diff --git a/bin/varnishtest/vtc_haproxy.c b/bin/varnishtest/vtc_haproxy.c index 2fee33b30..89d0106e3 100644 --- a/bin/varnishtest/vtc_haproxy.c +++ b/bin/varnishtest/vtc_haproxy.c @@ -52,6 +52,11 @@ #define HAPROXY_EXPECT_EXIT (128 + HAPROXY_SIGNAL) #define HAPROXY_GOOD_CONF "Configuration file is valid" +struct envar { + VTAILQ_ENTRY(envar) list; + char *name; + char *value; +}; struct haproxy { unsigned magic; @@ -70,6 +75,7 @@ struct haproxy { pid_t ppid; int fds[4]; char *cfg_fn; + struct vsb *cfg_vsb; pthread_t tp; int expect_exit; @@ -83,6 +89,7 @@ struct haproxy { char *workdir; struct vsb *msgs; + VTAILQ_HEAD(,envar) envars; }; static VTAILQ_HEAD(, haproxy) haproxies = @@ -105,15 +112,56 @@ struct haproxy_cli { size_t rxbuf_sz; char *rxbuf; - vtim_dur timeout; + double timeout; }; +static void haproxy_write_conf(struct haproxy *h); + +static void +haproxy_add_envar(struct haproxy *h, + const char *name, const char *value) +{ + struct envar *e; + + e = malloc(sizeof *e); + AN(e); + e->name = strdup(name); + e->value = strdup(value); + AN(e->name); + AN(e->value); + VTAILQ_INSERT_TAIL(&h->envars, e, list); +} + +static void +haproxy_delete_envars(struct haproxy *h) +{ + struct envar *e, *e2; + VTAILQ_FOREACH_SAFE(e, &h->envars, list, e2) { + VTAILQ_REMOVE(&h->envars, e, list); + free(e->name); + free(e->value); + free(e); + } +} + +static void +haproxy_build_env(const struct haproxy *h) +{ + struct envar *e; + + VTAILQ_FOREACH(e, &h->envars, list) { + if (setenv(e->name, e->value, 0) == -1) + vtc_fatal(h->vl, "setenv() failed: %s (%d)", + strerror(errno), errno); + } +} + /********************************************************************** * Socket connect (same as client_tcp_connect()). */ static int -haproxy_cli_tcp_connect(struct vtclog *vl, const char *addr, vtim_dur tmo, +haproxy_cli_tcp_connect(struct vtclog *vl, const char *addr, double tmo, const char **errp) { int fd; @@ -481,6 +529,7 @@ haproxy_new(const char *name) bprintf(buf, "rm -rf \"%s\" ; mkdir -p \"%s\"", h->workdir, h->workdir); AZ(system(buf)); + VTAILQ_INIT(&h->envars); VTAILQ_INSERT_TAIL(&haproxies, h, list); return (h); @@ -582,12 +631,16 @@ haproxy_start(struct haproxy *h) h->expect_exit = HAPROXY_EXPECT_EXIT; } + haproxy_write_conf(h); + AZ(pipe(&h->fds[0])); vtc_log(h->vl, 4, "XXX %d @%d", h->fds[1], __LINE__); AZ(pipe(&h->fds[2])); h->pid = h->ppid = fork(); assert(h->pid >= 0); if (h->pid == 0) { + haproxy_build_env(h); + haproxy_delete_envars(h); AZ(chdir(h->name)); AZ(dup2(h->fds[0], 0)); assert(dup2(h->fds[3], 1) == 1); @@ -676,7 +729,7 @@ haproxy_wait(struct haproxy *h) #define HAPROXY_BE_FD_STRLEN strlen(HAPROXY_BE_FD_STR) static int -haproxy_build_backends(const struct haproxy *h, const char *vsb_data) +haproxy_build_backends(struct haproxy *h, const char *vsb_data) { char *s, *p, *q; @@ -715,9 +768,7 @@ haproxy_build_backends(const struct haproxy *h, const char *vsb_data) bprintf(buf, "%d", sock); vtc_log(h->vl, 4, "setenv(%s, %s)", p, buf); - if (setenv(p, buf, 0) == -1) - vtc_fatal(h->vl, "setenv() failed: %s (%d)", - strerror(errno), errno); + haproxy_add_envar(h, p, buf); p = q; } free(s); @@ -745,9 +796,9 @@ haproxy_check_conf(struct haproxy *h, const char *expect) */ static void -haproxy_write_conf(const struct haproxy *h, const char *cfg, int auto_be) +haproxy_store_conf(struct haproxy *h, const char *cfg, int auto_be) { - struct vsb *vsb, *vsb2, *vsb3; + struct vsb *vsb, *vsb2; vsb = VSB_new_auto(); AN(vsb); @@ -767,19 +818,28 @@ haproxy_write_conf(const struct haproxy *h, const char *cfg, int auto_be) AZ(haproxy_build_backends(h, VSB_data(vsb))); - vsb3 = macro_expand(h->vl, VSB_data(vsb)); - AN(vsb3); + h->cfg_vsb = macro_expand(h->vl, VSB_data(vsb)); + AN(h->cfg_vsb); + + VSB_destroy(&vsb2); + VSB_destroy(&vsb); +} +static void +haproxy_write_conf(struct haproxy *h) +{ + struct vsb *vsb; + + vsb = macro_expand(h->vl, VSB_data(h->cfg_vsb)); + AN(vsb); + + vtc_dump(h->vl, 4, "conf", VSB_data(vsb), VSB_len(vsb)); if (VFIL_writefile(h->workdir, h->cfg_fn, - VSB_data(vsb3), VSB_len(vsb3)) != 0) + VSB_data(vsb), VSB_len(vsb)) != 0) vtc_fatal(h->vl, "failed to write haproxy configuration file: %s (%d)", strerror(errno), errno); - vtc_dump(h->vl, 4, "conf", VSB_data(vsb3), VSB_len(vsb3)); - - VSB_destroy(&vsb3); - VSB_destroy(&vsb2); VSB_destroy(&vsb); } @@ -881,7 +941,7 @@ cmd_haproxy(CMD_ARGS) if (!strcmp(*av, "-conf-OK")) { AN(av[1]); - haproxy_write_conf(h, av[1], 0); + haproxy_store_conf(h, av[1], 0); av++; haproxy_check_conf(h, HAPROXY_GOOD_CONF); continue; @@ -889,7 +949,7 @@ cmd_haproxy(CMD_ARGS) if (!strcmp(*av, "-conf-BAD")) { AN(av[1]); AN(av[2]); - haproxy_write_conf(h, av[2], 0); + haproxy_store_conf(h, av[2], 0); h->expect_exit = 1; haproxy_check_conf(h, av[1]); av += 2; @@ -923,13 +983,13 @@ cmd_haproxy(CMD_ARGS) } if (!strcmp(*av, "-conf")) { AN(av[1]); - haproxy_write_conf(h, av[1], 0); + haproxy_store_conf(h, av[1], 0); av++; continue; } if (!strcmp(*av, "-conf+backend")) { AN(av[1]); - haproxy_write_conf(h, av[1], 1); + haproxy_store_conf(h, av[1], 1); av++; continue; } From phk at FreeBSD.org Wed Mar 6 10:44:08 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 6 Mar 2019 10:44:08 +0000 (UTC) Subject: [master] 8204c7fc8 Don't try to receive body if we sent HEAD Message-ID: <20190306104408.4B81F10E578@lists.varnish-cache.org> commit 8204c7fc844dcafe4d94a4d2c2254205a1e46d48 Author: Poul-Henning Kamp Date: Wed Mar 6 10:39:07 2019 +0000 Don't try to receive body if we sent HEAD Based on patch from @haproxyFred diff --git a/bin/varnishtest/vtc_http.c b/bin/varnishtest/vtc_http.c index 349eb596b..3e928cd49 100644 --- a/bin/varnishtest/vtc_http.c +++ b/bin/varnishtest/vtc_http.c @@ -708,7 +708,9 @@ cmd_http_rxresp(CMD_ARGS) return; if (!hp->resp[0] || !hp->resp[1]) return; - else if (!strcmp(hp->resp[1], "200")) + if (hp->head_method) + return; + if (!strcmp(hp->resp[1], "200")) http_swallow_body(hp, hp->resp, 1, 0); else http_swallow_body(hp, hp->resp, 0, 0); @@ -1282,6 +1284,7 @@ cmd_http_txreq(CMD_ARGS) av++; } else if (!strcmp(*av, "-req")) { req = av[1]; + hp->head_method = !strcasecmp(av[1], "HEAD") ; av++; } else if (!hp->sfd && !strcmp(*av, "-up")) { up = av[1]; diff --git a/bin/varnishtest/vtc_http.h b/bin/varnishtest/vtc_http.h index 6c857183f..4db97a82f 100644 --- a/bin/varnishtest/vtc_http.h +++ b/bin/varnishtest/vtc_http.h @@ -56,6 +56,8 @@ struct http { int gziplevel; int gzipresidual; + int head_method; + int fatal; /* H/2 */ From nils.goroll at uplex.de Wed Mar 6 10:47:07 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 6 Mar 2019 10:47:07 +0000 (UTC) Subject: [master] b7881806b travis: give us the test output Message-ID: <20190306104707.B453B10E88D@lists.varnish-cache.org> commit b7881806b595115ab5305c939e4ac95f7c4dd88e Author: Nils Goroll Date: Wed Mar 6 11:39:02 2019 +0100 travis: give us the test output Noticed for #2929: travis make check failed, but there is no information as to why, because that is hidden in the test-suite log diff --git a/.travis.yml b/.travis.yml index 8d31d9e04..1c4e8f8b3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -55,3 +55,12 @@ script: else make -j3 check VERBOSE=1 fi + if [[ !? -ne 0 ]] + for f in $(find . -name test-suite.log); do + if ! grep -E '(ERROR|FAIL):.*[1-9]' $f >/dev/null ; then continue ; fi + echo ---------------------------------------------------------------------------- + echo $f + echo ---------------------------------------------------------------------------- + cat $f + done + fi From nils.goroll at uplex.de Wed Mar 6 11:10:07 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 6 Mar 2019 11:10:07 +0000 (UTC) Subject: [master] 82464e363 fix my shell stupidity Message-ID: <20190306111008.02E5E10F04B@lists.varnish-cache.org> commit 82464e363a4807f2a7e92ce910653b76f80262ba Author: Nils Goroll Date: Wed Mar 6 12:09:23 2019 +0100 fix my shell stupidity include coffee.vcl diff --git a/.travis.yml b/.travis.yml index 1c4e8f8b3..81cec4d2b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -55,7 +55,8 @@ script: else make -j3 check VERBOSE=1 fi - if [[ !? -ne 0 ]] + err=$? + if [[ $err -ne 0 ]] ; then for f in $(find . -name test-suite.log); do if ! grep -E '(ERROR|FAIL):.*[1-9]' $f >/dev/null ; then continue ; fi echo ---------------------------------------------------------------------------- @@ -64,3 +65,4 @@ script: cat $f done fi + exit $err From nils.goroll at uplex.de Wed Mar 6 12:00:14 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 6 Mar 2019 12:00:14 +0000 (UTC) Subject: [master] 478ccc86a add probe details for directors.random Message-ID: <20190306120014.37E9310FFD7@lists.varnish-cache.org> commit 478ccc86a466740e2d53be66b80cb7aa5aeab875 Author: Nils Goroll Date: Wed Mar 6 12:58:08 2019 +0100 add probe details for directors.random Ref #2896 diff --git a/lib/libvmod_directors/random.c b/lib/libvmod_directors/random.c index 567315193..93e5a96f6 100644 --- a/lib/libvmod_directors/random.c +++ b/lib/libvmod_directors/random.c @@ -56,6 +56,18 @@ vmod_random_healthy(VRT_CTX, VCL_BACKEND dir, VCL_TIME *changed) return (vdir_any_healthy(ctx, rr->vd, changed)); } +static void v_matchproto_(vdi_list_f) +vmod_random_list(VRT_CTX, VCL_BACKEND dir, struct vsb *vsb, int pflag, + int jflag) +{ + struct vmod_directors_random *rr; + + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + CHECK_OBJ_NOTNULL(dir, DIRECTOR_MAGIC); + CAST_OBJ_NOTNULL(rr, dir->priv, VMOD_DIRECTORS_RANDOM_MAGIC); + vdir_list(ctx, rr->vd, vsb, pflag, jflag, 1); +} + static VCL_BACKEND v_matchproto_(vdi_resolve_f) vmod_random_resolve(VRT_CTX, VCL_BACKEND dir) { @@ -87,7 +99,8 @@ static const struct vdi_methods vmod_random_methods[1] = {{ .type = "random", .healthy = vmod_random_healthy, .resolve = vmod_random_resolve, - .destroy = vmod_random_destroy + .destroy = vmod_random_destroy, + .list = vmod_random_list }}; diff --git a/lib/libvmod_directors/round_robin.c b/lib/libvmod_directors/round_robin.c index ff8ff7799..fc32ab646 100644 --- a/lib/libvmod_directors/round_robin.c +++ b/lib/libvmod_directors/round_robin.c @@ -63,7 +63,7 @@ vmod_rr_list(VRT_CTX, VCL_BACKEND dir, struct vsb *vsb, int pflag, int jflag) CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(dir, DIRECTOR_MAGIC); CAST_OBJ_NOTNULL(rr, dir->priv, VMOD_DIRECTORS_ROUND_ROBIN_MAGIC); - vdir_list(ctx, rr->vd, vsb, pflag, jflag); + vdir_list(ctx, rr->vd, vsb, pflag, jflag, 0); } static VCL_BACKEND v_matchproto_(vdi_resolve_f) diff --git a/lib/libvmod_directors/vdir.c b/lib/libvmod_directors/vdir.c index 95afd315d..088d2e9a9 100644 --- a/lib/libvmod_directors/vdir.c +++ b/lib/libvmod_directors/vdir.c @@ -195,7 +195,8 @@ vdir_any_healthy(VRT_CTX, struct vdir *vd, VCL_TIME *changed) } void -vdir_list(VRT_CTX, struct vdir *vd, struct vsb *vsb, int pflag, int jflag) +vdir_list(VRT_CTX, struct vdir *vd, struct vsb *vsb, int pflag, int jflag, + int weight) { VCL_TIME c, changed = 0; VCL_BACKEND be; @@ -209,8 +210,13 @@ vdir_list(VRT_CTX, struct vdir *vd, struct vsb *vsb, int pflag, int jflag) if (jflag) { VSB_cat(vsb, "{\n"); VSB_indent(vsb, 2); + if (weight) + VSB_printf(vsb, "\"total_weight\": %f,\n", + vd->total_weight); + VSB_cat(vsb, "\"backends\": {\n"); + VSB_indent(vsb, 2); } else { - VSB_cat(vsb, "\n"); + VSB_cat(vsb, "\n\n\tBackend\tWeight\tHealth\n"); } } @@ -229,11 +235,23 @@ vdir_list(VRT_CTX, struct vdir *vd, struct vsb *vsb, int pflag, int jflag) if (jflag) { if (u) VSB_cat(vsb, ",\n"); - VSB_printf(vsb, "\"%s\": \"%s\"", - be->vcl_name, h ? "healthy" : "sick"); + if (weight) + VSB_printf(vsb, "\"%s\": [%f, \"%s\"]", + be->vcl_name, vd->weight[u], + h ? "healthy" : "sick"); + else + VSB_printf(vsb, "\"%s\": \"%s\"", + be->vcl_name, h ? "healthy" : "sick"); } else { - VSB_printf(vsb, "\t%s: %s\n", - be->vcl_name, h ? "healthy" : "sick"); + VSB_cat(vsb, "\t"); + VSB_cat(vsb, be->vcl_name); + if (weight) + VSB_printf(vsb, "\t%.2f%%\t", + 100 * vd->weight[u] / vd->total_weight); + else + VSB_cat(vsb, "\t-\t"); + VSB_cat(vsb, h ? "healthy" : "sick"); + VSB_cat(vsb, "\n"); } } vdir_unlock(vd); @@ -244,6 +262,8 @@ vdir_list(VRT_CTX, struct vdir *vd, struct vsb *vsb, int pflag, int jflag) VSB_cat(vsb, "\n"); VSB_indent(vsb, -2); VSB_cat(vsb, "},\n"); + VSB_indent(vsb, -2); + VSB_cat(vsb, "},\n"); } if (pflag) diff --git a/lib/libvmod_directors/vdir.h b/lib/libvmod_directors/vdir.h index 7afbcdead..abc454e71 100644 --- a/lib/libvmod_directors/vdir.h +++ b/lib/libvmod_directors/vdir.h @@ -50,5 +50,5 @@ void vdir_unlock(struct vdir *vd); void vdir_add_backend(VRT_CTX, struct vdir *, VCL_BACKEND, double weight); void vdir_remove_backend(VRT_CTX, struct vdir *, VCL_BACKEND, unsigned *cur); VCL_BOOL vdir_any_healthy(VRT_CTX, struct vdir *, VCL_TIME *); -void vdir_list(VRT_CTX, struct vdir *, struct vsb *, int, int); +void vdir_list(VRT_CTX, struct vdir *, struct vsb *, int, int, int); VCL_BACKEND vdir_pick_be(VRT_CTX, struct vdir *, double w); From nils.goroll at uplex.de Wed Mar 6 12:20:09 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 6 Mar 2019 12:20:09 +0000 (UTC) Subject: [master] 92d01627c add probe details for directors.fallback Message-ID: <20190306122009.49C801106FB@lists.varnish-cache.org> commit 92d01627ca7a8f07ffb513a3e20cf9e8260dc6d6 Author: Nils Goroll Date: Wed Mar 6 13:18:45 2019 +0100 add probe details for directors.fallback Ref #2896 diff --git a/lib/libvmod_directors/fall_back.c b/lib/libvmod_directors/fall_back.c index 02ac28186..f00a6f11e 100644 --- a/lib/libvmod_directors/fall_back.c +++ b/lib/libvmod_directors/fall_back.c @@ -36,6 +36,7 @@ #include "vcc_if.h" #include "vdir.h" +#include "vsb.h" struct vmod_directors_fallback { unsigned magic; @@ -56,6 +57,94 @@ vmod_fallback_healthy(VRT_CTX, VCL_BACKEND dir, VCL_TIME *changed) return (vdir_any_healthy(ctx, fb->vd, changed)); } +static void v_matchproto_(vdi_list_f) +vmod_fallback_list(VRT_CTX, VCL_BACKEND dir, struct vsb *vsb, int pflag, + int jflag) +{ + struct vmod_directors_fallback *fb; + struct vdir *vd; + VCL_TIME c, changed = 0; + VCL_BACKEND be; + VCL_BOOL h; + unsigned u, nh = 0; + + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + CHECK_OBJ_NOTNULL(dir, DIRECTOR_MAGIC); + CAST_OBJ_NOTNULL(fb, dir->priv, VMOD_DIRECTORS_FALLBACK_MAGIC); + CAST_OBJ_NOTNULL(vd, fb->vd, VDIR_MAGIC); + + if (pflag) { + if (jflag) { + VSB_cat(vsb, "{\n"); + VSB_indent(vsb, 2); + VSB_printf(vsb, "\"sticky\": %s,\n", + fb->st ? "true" : "false"); + VSB_cat(vsb, "\"backends\": {\n"); + VSB_indent(vsb, 2); + } else { + VSB_cat(vsb, "\n\n\tBackend\tCurrent\tHealth\n"); + } + } + + vdir_rdlock(vd); + for (u = 0; u < vd->n_backend; u++) { + be = vd->backend[u]; + CHECK_OBJ_NOTNULL(be, DIRECTOR_MAGIC); + c = 0; + h = VRT_Healthy(ctx, be, &c); + if (h) + nh++; + if (c > changed) + changed = c; + if ((pflag) == 0) + continue; + if (jflag) { + if (u) + VSB_cat(vsb, ",\n"); + VSB_printf(vsb, "\"%s\": [%s, \"%s\"]", + be->vcl_name, + fb->cur == u ? "true" : "false", + h ? "healthy" : "sick"); + } else { + VSB_cat(vsb, "\t"); + VSB_cat(vsb, be->vcl_name); + if (fb->cur == u) + VSB_cat(vsb, "\t*\t"); + else + VSB_cat(vsb, "\t\t"); + VSB_cat(vsb, h ? "healthy" : "sick"); + VSB_cat(vsb, "\n"); + } + } + vdir_unlock(vd); + + VRT_SetChanged(vd->dir, changed); + + if (jflag && (pflag)) { + VSB_cat(vsb, "\n"); + VSB_indent(vsb, -2); + VSB_cat(vsb, "},\n"); + VSB_indent(vsb, -2); + VSB_cat(vsb, "},\n"); + } + + if (pflag) + return; + + /* + * for health state, the api-correct thing would be to call our own + * healthy function, but that would just re-iterate the backends for no + * real benefit + */ + + if (jflag) + VSB_printf(vsb, "[%u, %u, \"%s\"]", nh, u, + nh ? "healthy" : "sick"); + else + VSB_printf(vsb, "%u/%u\t%s", nh, u, nh ? "healthy" : "sick"); + +} + static VCL_BACKEND v_matchproto_(vdi_resolve_f) vmod_fallback_resolve(VRT_CTX, VCL_BACKEND dir) { @@ -99,7 +188,8 @@ static const struct vdi_methods vmod_fallback_methods[1] = {{ .type = "fallback", .healthy = vmod_fallback_healthy, .resolve = vmod_fallback_resolve, - .destroy = vmod_fallback_destroy + .destroy = vmod_fallback_destroy, + .list = vmod_fallback_list }}; From phk at FreeBSD.org Wed Mar 6 14:58:07 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 6 Mar 2019 14:58:07 +0000 (UTC) Subject: [master] 54be487be Fail gracefull rather than xxxassert() on lack of worker threads. Message-ID: <20190306145807.E23C411335A@lists.varnish-cache.org> commit 54be487be4863decea34f4cf9600789b0c51f838 Author: Poul-Henning Kamp Date: Wed Mar 6 14:57:06 2019 +0000 Fail gracefull rather than xxxassert() on lack of worker threads. Fixes: #2930 diff --git a/bin/varnishd/http2/cache_http2_session.c b/bin/varnishd/http2/cache_http2_session.c index ed73f5f31..671d4a01d 100644 --- a/bin/varnishd/http2/cache_http2_session.c +++ b/bin/varnishd/http2/cache_http2_session.c @@ -299,7 +299,12 @@ h2_ou_session(struct worker *wrk, struct h2_sess *h2, h2_del_req(wrk, r2); return (0); } - XXXAZ(Pool_Task(wrk->pool, &req->task, TASK_QUEUE_REQ)); + if (Pool_Task(wrk->pool, &req->task, TASK_QUEUE_REQ)) { + r2->scheduled = 0; + h2_del_req(wrk, r2); + VSLb(h2->vsl, SLT_Debug, "H2: No Worker-threads"); + return (h2_ou_rel(wrk, req)); + } return (1); } From nils.goroll at uplex.de Wed Mar 6 15:26:07 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 6 Mar 2019 15:26:07 +0000 (UTC) Subject: [master] 8c9bc4f50 invert the logic of the vdir blacklist to heathy bitmap Message-ID: <20190306152607.36D12113CBF@lists.varnish-cache.org> commit 8c9bc4f50e51008da90af27c7dbd3c80337f867e Author: Nils Goroll Date: Wed Mar 6 14:48:18 2019 +0100 invert the logic of the vdir blacklist to heathy bitmap ... and name it appropriately diff --git a/lib/libvmod_directors/vdir.c b/lib/libvmod_directors/vdir.c index 088d2e9a9..a27f6474d 100644 --- a/lib/libvmod_directors/vdir.c +++ b/lib/libvmod_directors/vdir.c @@ -66,8 +66,8 @@ vdir_new(VRT_CTX, struct vdir **vdp, const char *vcl_name, *vdp = vd; AZ(pthread_rwlock_init(&vd->mtx, NULL)); vd->dir = VRT_AddDirector(ctx, m, priv, "%s", vcl_name); - vd->vbm = vbit_new(8); - AN(vd->vbm); + vd->healthy = vbit_new(8); + AN(vd->healthy); } void @@ -81,7 +81,7 @@ vdir_delete(struct vdir **vdp) free(vd->backend); free(vd->weight); AZ(pthread_rwlock_destroy(&vd->mtx)); - vbit_destroy(vd->vbm); + vbit_destroy(vd->healthy); FREE_OBJ(vd); } @@ -284,17 +284,17 @@ vdir_list(VRT_CTX, struct vdir *vd, struct vsb *vsb, int pflag, int jflag, static unsigned vdir_pick_by_weight(const struct vdir *vd, double w, - const struct vbitmap *blacklist) + const struct vbitmap *healthy) { double a = 0.0; VCL_BACKEND be = NULL; unsigned u; - AN(blacklist); + AN(healthy); for (u = 0; u < vd->n_backend; u++) { be = vd->backend[u]; CHECK_OBJ_NOTNULL(be, DIRECTOR_MAGIC); - if (vbit_test(blacklist, u)) + if (! vbit_test(healthy, u)) continue; a += vd->weight[u]; if (w < a) @@ -315,13 +315,14 @@ vdir_pick_be(VRT_CTX, struct vdir *vd, double w) vdir_wrlock(vd); for (u = 0; u < vd->n_backend; u++) { if (VRT_Healthy(ctx, vd->backend[u], NULL)) { - vbit_clr(vd->vbm, u); + vbit_set(vd->healthy, u); tw += vd->weight[u]; - } else - vbit_set(vd->vbm, u); + } else { + vbit_clr(vd->healthy, u); + } } if (tw > 0.0) { - u = vdir_pick_by_weight(vd, w * tw, vd->vbm); + u = vdir_pick_by_weight(vd, w * tw, vd->healthy); assert(u < vd->n_backend); be = vd->backend[u]; CHECK_OBJ_NOTNULL(be, DIRECTOR_MAGIC); diff --git a/lib/libvmod_directors/vdir.h b/lib/libvmod_directors/vdir.h index abc454e71..786f233e2 100644 --- a/lib/libvmod_directors/vdir.h +++ b/lib/libvmod_directors/vdir.h @@ -38,7 +38,7 @@ struct vdir { double *weight; double total_weight; VCL_BACKEND dir; - struct vbitmap *vbm; + struct vbitmap *healthy; }; void vdir_new(VRT_CTX, struct vdir **vdp, const char *vcl_name, From nils.goroll at uplex.de Wed Mar 6 15:26:07 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 6 Mar 2019 15:26:07 +0000 (UTC) Subject: [master] 429c0a8eb gc an over-zealous test Message-ID: <20190306152607.4BB5C113CC2@lists.varnish-cache.org> commit 429c0a8eb4a9fb02fa5202adbb108652c7aea4ee Author: Nils Goroll Date: Wed Mar 6 14:49:37 2019 +0100 gc an over-zealous test diff --git a/lib/libvmod_directors/vdir.c b/lib/libvmod_directors/vdir.c index a27f6474d..91890d2c9 100644 --- a/lib/libvmod_directors/vdir.c +++ b/lib/libvmod_directors/vdir.c @@ -287,13 +287,10 @@ vdir_pick_by_weight(const struct vdir *vd, double w, const struct vbitmap *healthy) { double a = 0.0; - VCL_BACKEND be = NULL; unsigned u; AN(healthy); for (u = 0; u < vd->n_backend; u++) { - be = vd->backend[u]; - CHECK_OBJ_NOTNULL(be, DIRECTOR_MAGIC); if (! vbit_test(healthy, u)) continue; a += vd->weight[u]; From nils.goroll at uplex.de Wed Mar 6 15:26:07 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 6 Mar 2019 15:26:07 +0000 (UTC) Subject: [master] 31cfcdc1a gc superflous argument Message-ID: <20190306152607.6409E113CC5@lists.varnish-cache.org> commit 31cfcdc1ac0ad69449a63d957412b957263da7aa Author: Nils Goroll Date: Wed Mar 6 14:53:30 2019 +0100 gc superflous argument diff --git a/lib/libvmod_directors/vdir.c b/lib/libvmod_directors/vdir.c index 91890d2c9..bb6bacec6 100644 --- a/lib/libvmod_directors/vdir.c +++ b/lib/libvmod_directors/vdir.c @@ -283,9 +283,9 @@ vdir_list(VRT_CTX, struct vdir *vd, struct vsb *vsb, int pflag, int jflag, } static unsigned -vdir_pick_by_weight(const struct vdir *vd, double w, - const struct vbitmap *healthy) +vdir_pick_by_weight(const struct vdir *vd, double w) { + const struct vbitmap *healthy = vd->healthy; double a = 0.0; unsigned u; @@ -319,7 +319,7 @@ vdir_pick_be(VRT_CTX, struct vdir *vd, double w) } } if (tw > 0.0) { - u = vdir_pick_by_weight(vd, w * tw, vd->healthy); + u = vdir_pick_by_weight(vd, w * tw); assert(u < vd->n_backend); be = vd->backend[u]; CHECK_OBJ_NOTNULL(be, DIRECTOR_MAGIC); From nils.goroll at uplex.de Wed Mar 6 15:26:07 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 6 Mar 2019 15:26:07 +0000 (UTC) Subject: [master] 8d47bfc8d vdir: centralize health info, fix total_weight Message-ID: <20190306152607.7C3AE113CCA@lists.varnish-cache.org> commit 8d47bfc8d16c8deb980ace67dc8bbace67405c99 Author: Nils Goroll Date: Wed Mar 6 15:40:23 2019 +0100 vdir: centralize health info, fix total_weight Whenever we gather health information about our backends, we should also update the other metrics: - director changed time - total weight - number of healthy backends (added) This also adds back sensible use of (struct vdir).total_weight, which was maintained by add_backend / remove_backend, but not used anywhere and useless anyway because, for the hash and random directors, the total weight of the _healthy_ directors is required. This also fixes the weight output for backend.list to be relative to the healthy backends. Ref #2896 diff --git a/lib/libvmod_directors/fall_back.c b/lib/libvmod_directors/fall_back.c index f00a6f11e..88efb699b 100644 --- a/lib/libvmod_directors/fall_back.c +++ b/lib/libvmod_directors/fall_back.c @@ -37,6 +37,7 @@ #include "vdir.h" #include "vsb.h" +#include "vbm.h" struct vmod_directors_fallback { unsigned magic; @@ -63,10 +64,9 @@ vmod_fallback_list(VRT_CTX, VCL_BACKEND dir, struct vsb *vsb, int pflag, { struct vmod_directors_fallback *fb; struct vdir *vd; - VCL_TIME c, changed = 0; VCL_BACKEND be; VCL_BOOL h; - unsigned u, nh = 0; + unsigned u, nh; CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(dir, DIRECTOR_MAGIC); @@ -87,17 +87,13 @@ vmod_fallback_list(VRT_CTX, VCL_BACKEND dir, struct vsb *vsb, int pflag, } vdir_rdlock(vd); - for (u = 0; u < vd->n_backend; u++) { + vdir_update_health(ctx, vd); + for (u = 0; pflag && u < vd->n_backend; u++) { be = vd->backend[u]; CHECK_OBJ_NOTNULL(be, DIRECTOR_MAGIC); - c = 0; - h = VRT_Healthy(ctx, be, &c); - if (h) - nh++; - if (c > changed) - changed = c; - if ((pflag) == 0) - continue; + + h = vbit_test(vd->healthy, u); + if (jflag) { if (u) VSB_cat(vsb, ",\n"); @@ -116,10 +112,9 @@ vmod_fallback_list(VRT_CTX, VCL_BACKEND dir, struct vsb *vsb, int pflag, VSB_cat(vsb, "\n"); } } + nh = vd->n_healthy; vdir_unlock(vd); - VRT_SetChanged(vd->dir, changed); - if (jflag && (pflag)) { VSB_cat(vsb, "\n"); VSB_indent(vsb, -2); @@ -131,18 +126,11 @@ vmod_fallback_list(VRT_CTX, VCL_BACKEND dir, struct vsb *vsb, int pflag, if (pflag) return; - /* - * for health state, the api-correct thing would be to call our own - * healthy function, but that would just re-iterate the backends for no - * real benefit - */ - if (jflag) VSB_printf(vsb, "[%u, %u, \"%s\"]", nh, u, nh ? "healthy" : "sick"); else VSB_printf(vsb, "%u/%u\t%s", nh, u, nh ? "healthy" : "sick"); - } static VCL_BACKEND v_matchproto_(vdi_resolve_f) diff --git a/lib/libvmod_directors/vdir.c b/lib/libvmod_directors/vdir.c index bb6bacec6..1caab2e3c 100644 --- a/lib/libvmod_directors/vdir.c +++ b/lib/libvmod_directors/vdir.c @@ -47,6 +47,9 @@ vdir_expand(struct vdir *vd, unsigned n) AN(vd->backend); vd->weight = realloc(vd->weight, n * sizeof *vd->weight); AN(vd->weight); + if (n > vd->healthy->nbits) + vbit_expand(vd->healthy, n); + AN(vd->healthy); vd->l_backend = n; } @@ -127,7 +130,6 @@ vdir_add_backend(VRT_CTX, struct vdir *vd, VCL_BACKEND be, double weight) u = vd->n_backend++; vd->backend[u] = be; vd->weight[u] = weight; - vd->total_weight += weight; vdir_unlock(vd); } @@ -152,7 +154,6 @@ vdir_remove_backend(VRT_CTX, struct vdir *vd, VCL_BACKEND be, unsigned *cur) vdir_unlock(vd); return; } - vd->total_weight -= vd->weight[u]; n = (vd->n_backend - u) - 1; memmove(&vd->backend[u], &vd->backend[u+1], n * sizeof(vd->backend[0])); memmove(&vd->weight[u], &vd->weight[u+1], n * sizeof(vd->weight[0])); @@ -198,10 +199,9 @@ void vdir_list(VRT_CTX, struct vdir *vd, struct vsb *vsb, int pflag, int jflag, int weight) { - VCL_TIME c, changed = 0; VCL_BACKEND be; VCL_BOOL h; - unsigned u, nh = 0; + unsigned u, nh; CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(vd, VDIR_MAGIC); @@ -221,23 +221,19 @@ vdir_list(VRT_CTX, struct vdir *vd, struct vsb *vsb, int pflag, int jflag, } vdir_rdlock(vd); - for (u = 0; u < vd->n_backend; u++) { + vdir_update_health(ctx, vd); + for (u = 0; pflag && u < vd->n_backend; u++) { be = vd->backend[u]; CHECK_OBJ_NOTNULL(be, DIRECTOR_MAGIC); - c = 0; - h = VRT_Healthy(ctx, be, &c); - if (h) - nh++; - if (c > changed) - changed = c; - if ((pflag) == 0) - continue; + + h = vbit_test(vd->healthy, u); + if (jflag) { if (u) VSB_cat(vsb, ",\n"); if (weight) VSB_printf(vsb, "\"%s\": [%f, \"%s\"]", - be->vcl_name, vd->weight[u], + be->vcl_name, h ? vd->weight[u] : 0.0, h ? "healthy" : "sick"); else VSB_printf(vsb, "\"%s\": \"%s\"", @@ -245,7 +241,7 @@ vdir_list(VRT_CTX, struct vdir *vd, struct vsb *vsb, int pflag, int jflag, } else { VSB_cat(vsb, "\t"); VSB_cat(vsb, be->vcl_name); - if (weight) + if (h && weight) VSB_printf(vsb, "\t%.2f%%\t", 100 * vd->weight[u] / vd->total_weight); else @@ -254,10 +250,9 @@ vdir_list(VRT_CTX, struct vdir *vd, struct vsb *vsb, int pflag, int jflag, VSB_cat(vsb, "\n"); } } + nh = vd->n_healthy; vdir_unlock(vd); - VRT_SetChanged(vd->dir, changed); - if (jflag && (pflag)) { VSB_cat(vsb, "\n"); VSB_indent(vsb, -2); @@ -269,12 +264,6 @@ vdir_list(VRT_CTX, struct vdir *vd, struct vsb *vsb, int pflag, int jflag, if (pflag) return; - /* - * for health state, the api-correct thing would be to call our own - * healthy function, but that would just re-iterate the backends for no - * real benefit - */ - if (jflag) VSB_printf(vsb, "[%u, %u, \"%s\"]", nh, u, nh ? "healthy" : "sick"); @@ -282,6 +271,55 @@ vdir_list(VRT_CTX, struct vdir *vd, struct vsb *vsb, int pflag, int jflag, VSB_printf(vsb, "%u/%u\t%s", nh, u, nh ? "healthy" : "sick"); } +/* + * iterate backends and update + * - healthy bitmap + * - number of healthy backends + * - total_weight + * - last change time of the VCL_BACKEND + * + * must be called under the vdir lock (read or write). + * + * A write lock is required if consistency between the individual attributes is + * a must, e.g. when total_weight is required to be the exact sum of the weights + * + * The read lock is safe because add_backend expands the healthy bitmap and all + * other members are atomic and may be used if consistency is not required. + */ +void +vdir_update_health(VRT_CTX, struct vdir *vd) +{ + VCL_TIME c, changed = 0; + VCL_BOOL h; + VCL_BACKEND be; + unsigned u, nh = 0; + double tw = 0.0; + struct vbitmap *healthy = vd->healthy; + + healthy = vd->healthy; + for (u = 0; u < vd->n_backend; u++) { + be = vd->backend[u]; + CHECK_OBJ_NOTNULL(be, DIRECTOR_MAGIC); + c = 0; + h = VRT_Healthy(ctx, vd->backend[u], &c); + if (h) { + nh++; + tw += vd->weight[u]; + } + if (c > changed) + changed = c; + if (h != vbit_test(healthy, u)) { + if (h) + vbit_set(healthy, u); + else + vbit_clr(healthy, u); + } + } + VRT_SetChanged(vd->dir, changed); + vd->total_weight = tw; + vd->n_healthy = nh; +} + static unsigned vdir_pick_by_weight(const struct vdir *vd, double w) { @@ -304,22 +342,14 @@ VCL_BACKEND vdir_pick_be(VRT_CTX, struct vdir *vd, double w) { unsigned u; - double tw = 0.0; VCL_BACKEND be = NULL; CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(vd, VDIR_MAGIC); vdir_wrlock(vd); - for (u = 0; u < vd->n_backend; u++) { - if (VRT_Healthy(ctx, vd->backend[u], NULL)) { - vbit_set(vd->healthy, u); - tw += vd->weight[u]; - } else { - vbit_clr(vd->healthy, u); - } - } - if (tw > 0.0) { - u = vdir_pick_by_weight(vd, w * tw); + vdir_update_health(ctx, vd); + if (vd->total_weight > 0.0) { + u = vdir_pick_by_weight(vd, w * vd->total_weight); assert(u < vd->n_backend); be = vd->backend[u]; CHECK_OBJ_NOTNULL(be, DIRECTOR_MAGIC); diff --git a/lib/libvmod_directors/vdir.h b/lib/libvmod_directors/vdir.h index 786f233e2..287d88fae 100644 --- a/lib/libvmod_directors/vdir.h +++ b/lib/libvmod_directors/vdir.h @@ -39,6 +39,7 @@ struct vdir { double total_weight; VCL_BACKEND dir; struct vbitmap *healthy; + unsigned n_healthy; }; void vdir_new(VRT_CTX, struct vdir **vdp, const char *vcl_name, @@ -51,4 +52,5 @@ void vdir_add_backend(VRT_CTX, struct vdir *, VCL_BACKEND, double weight); void vdir_remove_backend(VRT_CTX, struct vdir *, VCL_BACKEND, unsigned *cur); VCL_BOOL vdir_any_healthy(VRT_CTX, struct vdir *, VCL_TIME *); void vdir_list(VRT_CTX, struct vdir *, struct vsb *, int, int, int); +void vdir_update_health(VRT_CTX, struct vdir *); VCL_BACKEND vdir_pick_be(VRT_CTX, struct vdir *, double w); From nils.goroll at uplex.de Wed Mar 6 15:26:07 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 6 Mar 2019 15:26:07 +0000 (UTC) Subject: [master] 4caac9525 fix json format glitch Message-ID: <20190306152607.93C7E113CCE@lists.varnish-cache.org> commit 4caac9525ccd2c9903696f18493255e995c4c874 Author: Nils Goroll Date: Wed Mar 6 16:12:21 2019 +0100 fix json format glitch Ref #2896 diff --git a/lib/libvmod_directors/fall_back.c b/lib/libvmod_directors/fall_back.c index 88efb699b..50df8c799 100644 --- a/lib/libvmod_directors/fall_back.c +++ b/lib/libvmod_directors/fall_back.c @@ -118,7 +118,7 @@ vmod_fallback_list(VRT_CTX, VCL_BACKEND dir, struct vsb *vsb, int pflag, if (jflag && (pflag)) { VSB_cat(vsb, "\n"); VSB_indent(vsb, -2); - VSB_cat(vsb, "},\n"); + VSB_cat(vsb, "}\n"); VSB_indent(vsb, -2); VSB_cat(vsb, "},\n"); } diff --git a/lib/libvmod_directors/vdir.c b/lib/libvmod_directors/vdir.c index 1caab2e3c..e3495be76 100644 --- a/lib/libvmod_directors/vdir.c +++ b/lib/libvmod_directors/vdir.c @@ -256,7 +256,7 @@ vdir_list(VRT_CTX, struct vdir *vd, struct vsb *vsb, int pflag, int jflag, if (jflag && (pflag)) { VSB_cat(vsb, "\n"); VSB_indent(vsb, -2); - VSB_cat(vsb, "},\n"); + VSB_cat(vsb, "}\n"); VSB_indent(vsb, -2); VSB_cat(vsb, "},\n"); } From nils.goroll at uplex.de Wed Mar 6 15:29:06 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 6 Mar 2019 15:29:06 +0000 (UTC) Subject: [master] f1fed55fd space efficiency ocd Message-ID: <20190306152906.B12681143CC@lists.varnish-cache.org> commit f1fed55fd3174fbf851b6c5b01c767e48d32de3c Author: Nils Goroll Date: Wed Mar 6 16:28:37 2019 +0100 space efficiency ocd diff --git a/lib/libvmod_directors/vdir.h b/lib/libvmod_directors/vdir.h index 287d88fae..e448bee43 100644 --- a/lib/libvmod_directors/vdir.h +++ b/lib/libvmod_directors/vdir.h @@ -31,15 +31,15 @@ struct vbitmap; struct vdir { unsigned magic; #define VDIR_MAGIC 0x99f4b726 - pthread_rwlock_t mtx; unsigned n_backend; unsigned l_backend; + unsigned n_healthy; + pthread_rwlock_t mtx; VCL_BACKEND *backend; double *weight; double total_weight; VCL_BACKEND dir; struct vbitmap *healthy; - unsigned n_healthy; }; void vdir_new(VRT_CTX, struct vdir **vdp, const char *vcl_name, From nils.goroll at uplex.de Wed Mar 6 17:26:07 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 6 Mar 2019 17:26:07 +0000 (UTC) Subject: [master] 1c61a4bc2 polish weight column Message-ID: <20190306172607.988DA1165CA@lists.varnish-cache.org> commit 1c61a4bc2f0228221697909a348ccf2556ff9d92 Author: Nils Goroll Date: Wed Mar 6 17:53:52 2019 +0100 polish weight column Ref #2896 diff --git a/lib/libvmod_directors/vdir.c b/lib/libvmod_directors/vdir.c index e3495be76..d40611c97 100644 --- a/lib/libvmod_directors/vdir.c +++ b/lib/libvmod_directors/vdir.c @@ -202,6 +202,7 @@ vdir_list(VRT_CTX, struct vdir *vd, struct vsb *vsb, int pflag, int jflag, VCL_BACKEND be; VCL_BOOL h; unsigned u, nh; + double w; CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(vd, VDIR_MAGIC); @@ -228,12 +229,14 @@ vdir_list(VRT_CTX, struct vdir *vd, struct vsb *vsb, int pflag, int jflag, h = vbit_test(vd->healthy, u); + w = h ? vd->weight[u] : 0.0; + if (jflag) { if (u) VSB_cat(vsb, ",\n"); if (weight) VSB_printf(vsb, "\"%s\": [%f, \"%s\"]", - be->vcl_name, h ? vd->weight[u] : 0.0, + be->vcl_name, w, h ? "healthy" : "sick"); else VSB_printf(vsb, "\"%s\": \"%s\"", @@ -241,9 +244,9 @@ vdir_list(VRT_CTX, struct vdir *vd, struct vsb *vsb, int pflag, int jflag, } else { VSB_cat(vsb, "\t"); VSB_cat(vsb, be->vcl_name); - if (h && weight) - VSB_printf(vsb, "\t%.2f%%\t", - 100 * vd->weight[u] / vd->total_weight); + if (weight) + VSB_printf(vsb, "\t%6.2f%%\t", + 100 * w / vd->total_weight); else VSB_cat(vsb, "\t-\t"); VSB_cat(vsb, h ? "healthy" : "sick"); From nils.goroll at uplex.de Wed Mar 6 17:26:07 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 6 Mar 2019 17:26:07 +0000 (UTC) Subject: [master] b756bacf3 add backend.list -p for directors.shard Message-ID: <20190306172607.B45BF1165CD@lists.varnish-cache.org> commit b756bacf3789e2dfa99cb040b0fcc810b6815025 Author: Nils Goroll Date: Wed Mar 6 17:37:00 2019 +0100 add backend.list -p for directors.shard Ref #2896 diff --git a/lib/libvmod_directors/shard_dir.c b/lib/libvmod_directors/shard_dir.c index 54d5caabe..645d394a7 100644 --- a/lib/libvmod_directors/shard_dir.c +++ b/lib/libvmod_directors/shard_dir.c @@ -256,7 +256,7 @@ sharddir_delete(struct sharddir **sharddp) FREE_OBJ(shardd); } -static void +void sharddir_rdlock(struct sharddir *shardd) { CHECK_OBJ_NOTNULL(shardd, SHARDDIR_MAGIC); diff --git a/lib/libvmod_directors/shard_dir.h b/lib/libvmod_directors/shard_dir.h index a1e51e244..44a109b70 100644 --- a/lib/libvmod_directors/shard_dir.h +++ b/lib/libvmod_directors/shard_dir.h @@ -132,6 +132,7 @@ void sharddir_new(struct sharddir **sharddp, const char *vcl_name, void sharddir_set_param(struct sharddir *shardd, const struct vmod_directors_shard_param *param); void sharddir_delete(struct sharddir **sharddp); +void sharddir_rdlock(struct sharddir *shardd); void sharddir_wrlock(struct sharddir *shardd); void sharddir_unlock(struct sharddir *shardd); VCL_BOOL sharddir_any_healthy(VRT_CTX, struct sharddir *, VCL_TIME *); diff --git a/lib/libvmod_directors/vmod_shard.c b/lib/libvmod_directors/vmod_shard.c index 5360f3aac..91a2dc945 100644 --- a/lib/libvmod_directors/vmod_shard.c +++ b/lib/libvmod_directors/vmod_shard.c @@ -40,6 +40,7 @@ #include "vcc_if.h" #include "shard_dir.h" #include "shard_cfg.h" +#include "vsb.h" /* ------------------------------------------------------------------------- * shard director: LAZY mode (vdi resolve function), parameter objects @@ -171,6 +172,7 @@ vmod_shard_param_read(VRT_CTX, const void *id, */ static vdi_healthy_f vmod_shard_healthy; static vdi_resolve_f vmod_shard_resolve; +static vdi_list_f vmod_shard_list; struct vmod_directors_shard { unsigned magic; @@ -243,7 +245,8 @@ static const struct vdi_methods vmod_shard_methods[1] = {{ .type = "shard", .resolve = vmod_shard_resolve, .healthy = vmod_shard_healthy, - .destroy = vmod_shard_destroy + .destroy = vmod_shard_destroy, + .list = vmod_shard_list }}; @@ -754,6 +757,111 @@ vmod_shard_resolve(VRT_CTX, VCL_BACKEND dir) pp->rampup, pp->healthy)); } +void v_matchproto_(vdi_list_f) +vmod_shard_list(VRT_CTX, VCL_BACKEND dir, struct vsb *vsb, int pflag, int jflag) +{ + struct sharddir *shardd; + struct shard_backend *sbe; + VCL_TIME c, changed = 0; + VCL_DURATION rampup_d, d; + VCL_BACKEND be; + VCL_BOOL h; + unsigned u, nh = 0; + double rampup_p; + + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + CHECK_OBJ_NOTNULL(dir, DIRECTOR_MAGIC); + CAST_OBJ_NOTNULL(shardd, dir->priv, SHARDDIR_MAGIC); + + if (pflag) { + if (jflag) { + VSB_cat(vsb, "{\n"); + VSB_indent(vsb, 2); + VSB_printf(vsb, "\"warmup\": %f,\n", shardd->warmup); + VSB_printf(vsb, "\"rampup_duration\": %f,\n", + shardd->rampup_duration); + VSB_cat(vsb, "\"backends\": {\n"); + VSB_indent(vsb, 2); + } else { + VSB_cat(vsb, "\n\n\tBackend\tIdent\tHealth\t" + "Rampup Remaining\n"); + } + } + + sharddir_rdlock(shardd); + for (u = 0; u < shardd->n_backend; u++) { + sbe = &shardd->backend[u]; + AN(sbe); + be = sbe->backend; + CHECK_OBJ_NOTNULL(be, DIRECTOR_MAGIC); + + c = 0; + h = VRT_Healthy(ctx, be, &c); + if (h) + nh++; + if (c > changed) + changed = c; + if ((pflag) == 0) + continue; + + d = ctx->now - c; + rampup_d = shardcfg_get_rampup(shardd, u); + if (! h) { + rampup_p = 0.0; + rampup_d = 0.0; + } else if (d < rampup_d) { + rampup_p = d / rampup_d; + rampup_d -= d; + } else { + rampup_p = 1.0; + rampup_d = 0.0; + } + + if (jflag) { + if (u) + VSB_cat(vsb, ",\n"); + VSB_printf(vsb, "\"%s\": {\n", + be->vcl_name); + VSB_indent(vsb, 2); + VSB_printf(vsb, "\"ident\": \"%s\",\n", + sbe->ident ? sbe->ident : be->vcl_name); + VSB_printf(vsb, "\"health\": \"%s\",\n", + h ? "healthy" : "sick"); + VSB_printf(vsb, "\"canon_point\": %u,\n", + sbe->canon_point); + VSB_printf(vsb, "\"rampup\": %f,\n", rampup_p); + VSB_printf(vsb, "\"rampup_remaining\": %.3f\n", + rampup_d); + VSB_indent(vsb, -2); + VSB_cat(vsb, "}"); + } else { + VSB_printf(vsb, "\t%s\t\%s\t%s\t%6.2f%% %8.3fs\n", + be->vcl_name, + sbe->ident ? sbe->ident : be->vcl_name, + h ? "healthy" : "sick", + rampup_p * 100, rampup_d); + } + } + sharddir_unlock(shardd); + + if (jflag && (pflag)) { + VSB_cat(vsb, "\n"); + VSB_indent(vsb, -2); + VSB_cat(vsb, "}\n"); + VSB_indent(vsb, -2); + VSB_cat(vsb, "},\n"); + } + + if (pflag) + return; + + if (jflag) + VSB_printf(vsb, "[%u, %u, \"%s\"]", nh, u, + nh ? "healthy" : "sick"); + else + VSB_printf(vsb, "%u/%u\t%s", nh, u, nh ? "healthy" : "sick"); +} + VCL_VOID v_matchproto_(td_directors_shard_backend) vmod_shard_debug(VRT_CTX, struct vmod_directors_shard *vshard, VCL_INT i) From nils.goroll at uplex.de Wed Mar 6 17:26:07 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 6 Mar 2019 17:26:07 +0000 (UTC) Subject: [master] dd2c75542 polish backend.list -pj output Message-ID: <20190306172607.D7F5D1165D0@lists.varnish-cache.org> commit dd2c755424a15d05f6b4742070b7004bee14fbaa Author: Nils Goroll Date: Wed Mar 6 18:09:53 2019 +0100 polish backend.list -pj output interface-meister @slimhazard tells me the JSONista want objects Ref #2896 diff --git a/lib/libvmod_directors/fall_back.c b/lib/libvmod_directors/fall_back.c index 50df8c799..0ed228524 100644 --- a/lib/libvmod_directors/fall_back.c +++ b/lib/libvmod_directors/fall_back.c @@ -97,10 +97,21 @@ vmod_fallback_list(VRT_CTX, VCL_BACKEND dir, struct vsb *vsb, int pflag, if (jflag) { if (u) VSB_cat(vsb, ",\n"); - VSB_printf(vsb, "\"%s\": [%s, \"%s\"]", - be->vcl_name, - fb->cur == u ? "true" : "false", - h ? "healthy" : "sick"); + VSB_printf(vsb, "\"%s\": {\n", be->vcl_name); + VSB_indent(vsb, 2); + + if (fb->cur == u) + VSB_cat(vsb, "\"current\": true,\n"); + else + VSB_cat(vsb, "\"current\": false,\n"); + + if (h) + VSB_cat(vsb, "\"health\": \"healthy\"\n"); + else + VSB_cat(vsb, "\"health\": \"sick\"\n"); + + VSB_indent(vsb, -2); + VSB_cat(vsb, "}"); } else { VSB_cat(vsb, "\t"); VSB_cat(vsb, be->vcl_name); diff --git a/lib/libvmod_directors/vdir.c b/lib/libvmod_directors/vdir.c index d40611c97..027611296 100644 --- a/lib/libvmod_directors/vdir.c +++ b/lib/libvmod_directors/vdir.c @@ -234,13 +234,19 @@ vdir_list(VRT_CTX, struct vdir *vd, struct vsb *vsb, int pflag, int jflag, if (jflag) { if (u) VSB_cat(vsb, ",\n"); + VSB_printf(vsb, "\"%s\": {\n", be->vcl_name); + VSB_indent(vsb, 2); + if (weight) - VSB_printf(vsb, "\"%s\": [%f, \"%s\"]", - be->vcl_name, w, - h ? "healthy" : "sick"); + VSB_printf(vsb, "\"weight\": %f,\n", w); + + if (h) + VSB_cat(vsb, "\"health\": \"healthy\"\n"); else - VSB_printf(vsb, "\"%s\": \"%s\"", - be->vcl_name, h ? "healthy" : "sick"); + VSB_cat(vsb, "\"health\": \"sick\"\n"); + + VSB_indent(vsb, -2); + VSB_cat(vsb, "}"); } else { VSB_cat(vsb, "\t"); VSB_cat(vsb, be->vcl_name); From nils.goroll at uplex.de Wed Mar 6 17:26:07 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 6 Mar 2019 17:26:07 +0000 (UTC) Subject: [master] 0346b9c1d fix backend.list without -p Message-ID: <20190306172608.0AFCF1165D5@lists.varnish-cache.org> commit 0346b9c1d1e4b3beef7dc3cfefaa6bec8aa96018 Author: Nils Goroll Date: Wed Mar 6 18:21:43 2019 +0100 fix backend.list without -p I broke the Y from the X/Y column in 8d47bfc8d16c8deb980ace67dc8bbace67405c99 Ref #2896 diff --git a/lib/libvmod_directors/fall_back.c b/lib/libvmod_directors/fall_back.c index 0ed228524..0838e93fa 100644 --- a/lib/libvmod_directors/fall_back.c +++ b/lib/libvmod_directors/fall_back.c @@ -124,6 +124,7 @@ vmod_fallback_list(VRT_CTX, VCL_BACKEND dir, struct vsb *vsb, int pflag, } } nh = vd->n_healthy; + u = vd->n_backend; vdir_unlock(vd); if (jflag && (pflag)) { diff --git a/lib/libvmod_directors/vdir.c b/lib/libvmod_directors/vdir.c index 027611296..dfb8868d9 100644 --- a/lib/libvmod_directors/vdir.c +++ b/lib/libvmod_directors/vdir.c @@ -260,6 +260,7 @@ vdir_list(VRT_CTX, struct vdir *vd, struct vsb *vsb, int pflag, int jflag, } } nh = vd->n_healthy; + u = vd->n_backend; vdir_unlock(vd); if (jflag && (pflag)) { From nils.goroll at uplex.de Wed Mar 6 17:46:08 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 6 Mar 2019 17:46:08 +0000 (UTC) Subject: [master] 11a2c94aa fix printf format glitch Message-ID: <20190306174608.1123B1170A5@lists.varnish-cache.org> commit 11a2c94aa5e48a6c044e71d6a96101195b16033e Author: Nils Goroll Date: Wed Mar 6 18:45:08 2019 +0100 fix printf format glitch diff --git a/lib/libvmod_directors/vmod_shard.c b/lib/libvmod_directors/vmod_shard.c index 91a2dc945..7efd10cef 100644 --- a/lib/libvmod_directors/vmod_shard.c +++ b/lib/libvmod_directors/vmod_shard.c @@ -835,7 +835,7 @@ vmod_shard_list(VRT_CTX, VCL_BACKEND dir, struct vsb *vsb, int pflag, int jflag) VSB_indent(vsb, -2); VSB_cat(vsb, "}"); } else { - VSB_printf(vsb, "\t%s\t\%s\t%s\t%6.2f%% %8.3fs\n", + VSB_printf(vsb, "\t%s\t%s\t%s\t%6.2f%% %8.3fs\n", be->vcl_name, sbe->ident ? sbe->ident : be->vcl_name, h ? "healthy" : "sick", From nils.goroll at uplex.de Wed Mar 6 18:40:09 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 6 Mar 2019 18:40:09 +0000 (UTC) Subject: [master] ce562c0a8 Add a vtc to tell us where our default stacksize is too tight Message-ID: <20190306184009.B2A081180F2@lists.varnish-cache.org> commit ce562c0a8f1fe83a8be4fa243f61395471039d88 Author: Nils Goroll Date: Wed Mar 6 19:36:21 2019 +0100 Add a vtc to tell us where our default stacksize is too tight Ref #2817 diff --git a/bin/varnishtest/tests/r02817.vtc b/bin/varnishtest/tests/r02817.vtc new file mode 100644 index 000000000..ed5cd9e17 --- /dev/null +++ b/bin/varnishtest/tests/r02817.vtc @@ -0,0 +1,117 @@ +varnishtest "canary to tell us if our default stacksize is too tight" + +server s1 { + rxreq + expect req.http.esi0 == "foo" + txresp -gzipbody { + + Before include + + After include + + } + + rxreq + expect req.url == "/a1" + expect req.http.esi0 != "foo" + txresp -gzipbody { + + Before include + + After include + + } + + rxreq + expect req.url == "/b2" + expect req.http.esi0 != "foo" + txresp -gzipbody { + + Before include + + After include + + } + + rxreq + expect req.url == "/c3" + expect req.http.esi0 != "foo" + txresp -gzipbody { + + Before include + + After include + + } + + rxreq + expect req.url == "/d4" + expect req.http.esi0 != "foo" + txresp -gzipbody { + + Before include + + After include + + } + + rxreq + expect req.url == "/e5" + expect req.http.esi0 != "foo" + txresp -gzipbody { + + LAST + + } +} -start + +varnish v1 -vcl+backend { + import std; + import debug; + + sub recv0 { call recv1; std.log("STK recv0 " + debug.stk()); } + sub recv1 { call recv2; std.log("STK recv1 " + debug.stk()); } + sub recv2 { call recv3; std.log("STK recv2 " + debug.stk()); } + sub recv3 { call recv4; std.log("STK recv3 " + debug.stk()); } + sub recv4 { call recv5; std.log("STK recv4 " + debug.stk()); } + sub recv5 { call recv6; std.log("STK recv5 " + debug.stk()); } + sub recv6 { call recv7; std.log("STK recv6 " + debug.stk()); } + sub recv7 { call recv8; std.log("STK recv7 " + debug.stk()); } + sub recv8 { call recv9; std.log("STK recv8 " + debug.stk()); } + sub recv9 { + std.log("STK recv9 " + debug.stk()); + set req.http.regex = regsub(req.url, "(.*)", "\1\1\1\1\1\1\1\1"); + set req.http.regex = regsub(req.http.regex, "(.*)", + "\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1"); + # hey geoff, this is deliberate + set req.http.regex = regsub(req.http.regex, + "(.*)(.{5})(.{6})(.{7})(.{8})", "/\5\4\3\2\1"); + std.log("REGEX recv9 " + req.http.regex); + } + + sub vcl_recv { + if (req.esi_level > 0) { + set req.url = req.url + req.esi_level; + } else { + set req.http.esi0 = "foo"; + } + std.log("STK recv " + debug.stk()); + call recv0; + } + sub vcl_backend_response { + set beresp.do_esi = true; + } + sub vcl_deliver { + std.log("STK deliver " + debug.stk()); + } +} -start + +client c1 { + txreq -hdr "Host: foo" + rxresp + expect resp.status == 200 + +} + +client c1 -run +varnish v1 -expect esi_errors == 0 diff --git a/lib/libvmod_debug/vmod.vcc b/lib/libvmod_debug/vmod.vcc index 4c5f652eb..8c6ffad05 100644 --- a/lib/libvmod_debug/vmod.vcc +++ b/lib/libvmod_debug/vmod.vcc @@ -234,3 +234,12 @@ $Function STRANDS return_strands(STRANDS strand) $Function VOID catflap(ENUM {miss, first, last} type) Test the HSH_Lookup catflap + +$Function BYTES stk() + +Return an approximation of the amount of stack used. + +This function is by no means guaranteed to work cross platform and +should now only be used for diagnostic purposes. + +0B is returned if no sensible value can be determined. diff --git a/lib/libvmod_debug/vmod_debug.c b/lib/libvmod_debug/vmod_debug.c index 7161596ae..8bcd48c33 100644 --- a/lib/libvmod_debug/vmod_debug.c +++ b/lib/libvmod_debug/vmod_debug.c @@ -699,3 +699,22 @@ xyzzy_catflap(VRT_CTX, VCL_ENUM type) WRONG("Wrong VENUM"); } } + +VCL_BYTES +xyzzy_stk(VRT_CTX) +{ + const VCL_BYTES max = 100 * 1024 * 1024; + const char *a, *b; + VCL_BYTES r; + + a = TRUST_ME(&b); + b = TRUST_ME(ctx->req->wrk); + b += sizeof(*ctx->req->wrk); + + if (b > a && (r = b - a) < max) + return (r); + if (a > b && (r = a - b) < max) + return (r); + + return (0); +} From phk at FreeBSD.org Wed Mar 6 21:02:07 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 6 Mar 2019 21:02:07 +0000 (UTC) Subject: [master] 6c5148cb0 Minor flexlinting Message-ID: <20190306210207.CF3A15BC5@lists.varnish-cache.org> commit 6c5148cb01844403deefa1edaca466a63e030696 Author: Poul-Henning Kamp Date: Wed Mar 6 21:00:50 2019 +0000 Minor flexlinting diff --git a/lib/libvmod_directors/vdir.c b/lib/libvmod_directors/vdir.c index dfb8868d9..a862580b9 100644 --- a/lib/libvmod_directors/vdir.c +++ b/lib/libvmod_directors/vdir.c @@ -304,8 +304,9 @@ vdir_update_health(VRT_CTX, struct vdir *vd) VCL_BACKEND be; unsigned u, nh = 0; double tw = 0.0; - struct vbitmap *healthy = vd->healthy; + struct vbitmap *healthy; + CHECK_OBJ_NOTNULL(vd, VDIR_MAGIC); healthy = vd->healthy; for (u = 0; u < vd->n_backend; u++) { be = vd->backend[u]; diff --git a/lib/libvmod_directors/vmod_shard.c b/lib/libvmod_directors/vmod_shard.c index 7efd10cef..d7dd7d7d6 100644 --- a/lib/libvmod_directors/vmod_shard.c +++ b/lib/libvmod_directors/vmod_shard.c @@ -757,7 +757,7 @@ vmod_shard_resolve(VRT_CTX, VCL_BACKEND dir) pp->rampup, pp->healthy)); } -void v_matchproto_(vdi_list_f) +static void v_matchproto_(vdi_list_f) vmod_shard_list(VRT_CTX, VCL_BACKEND dir, struct vsb *vsb, int pflag, int jflag) { struct sharddir *shardd; From nils.goroll at uplex.de Wed Mar 6 23:05:08 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 6 Mar 2019 23:05:08 +0000 (UTC) Subject: [master] 0e88a1961 sync vsl to get logs closer to the panic Message-ID: <20190306230508.4F02F9637@lists.varnish-cache.org> commit 0e88a19619c1942c6224923c2d9389b4479d73da Author: Nils Goroll Date: Wed Mar 6 20:23:42 2019 +0100 sync vsl to get logs closer to the panic Ref #2817 diff --git a/bin/varnishtest/tests/r02817.vtc b/bin/varnishtest/tests/r02817.vtc index ed5cd9e17..5952dcb99 100644 --- a/bin/varnishtest/tests/r02817.vtc +++ b/bin/varnishtest/tests/r02817.vtc @@ -106,6 +106,8 @@ varnish v1 -vcl+backend { } } -start +varnish v1 -cliok "param.set debug +syncvsl" + client c1 { txreq -hdr "Host: foo" rxresp From nils.goroll at uplex.de Wed Mar 6 23:05:08 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 6 Mar 2019 23:05:08 +0000 (UTC) Subject: [master] b94a4429b improve r02817.vtc description Message-ID: <20190306230508.640D9963A@lists.varnish-cache.org> commit b94a4429b113b4da5884c0962d74e47a95f767ac Author: Nils Goroll Date: Wed Mar 6 22:21:05 2019 +0100 improve r02817.vtc description diff --git a/bin/varnishtest/tests/r02817.vtc b/bin/varnishtest/tests/r02817.vtc index 5952dcb99..4e9b1189f 100644 --- a/bin/varnishtest/tests/r02817.vtc +++ b/bin/varnishtest/tests/r02817.vtc @@ -1,4 +1,6 @@ -varnishtest "canary to tell us if our default stacksize is too tight" +varnishtest "canary to tell us if our default stacksize is too tight..." + +# ... for the default esi level 5 and a stack of 10 VCL subs server s1 { rxreq From nils.goroll at uplex.de Wed Mar 6 23:05:08 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 6 Mar 2019 23:05:08 +0000 (UTC) Subject: [master] a3129a534 thread info for panic where pthread_getattr_np() available Message-ID: <20190306230508.7E574963D@lists.varnish-cache.org> commit a3129a5340566d17192de8058a9c1dbb051a7039 Author: Nils Goroll Date: Wed Mar 6 23:24:46 2019 +0100 thread info for panic where pthread_getattr_np() available diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index 3a4fae5f4..fbae9dadf 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -650,6 +650,33 @@ pan_backtrace(struct vsb *vsb) VSB_indent(vsb, -2); } +#ifdef HAVE_PTHREAD_GETATTR_NP +static void +pan_threadattr(struct vsb *vsb) +{ + pthread_attr_t attr[1]; + size_t sz; + void *addr; + + if (pthread_getattr_np(pthread_self(), attr) != 0) + return; + + VSB_cat(vsb, "pthread.attr = {\n"); + VSB_indent(vsb, 2); + + if (pthread_attr_getguardsize(attr, &sz) == 0) + VSB_printf(vsb, "guard = %zu,\n", sz); + if (pthread_attr_getstack(attr, &addr, &sz) == 0) { + VSB_printf(vsb, "stack_bottom = %p,\n", addr); + VSB_printf(vsb, "stack_top = %p,\n", (char *)addr + sz); + VSB_printf(vsb, "stack_size = %zu,\n", sz); + } + VSB_indent(vsb, -2); + VSB_cat(vsb, "}\n"); + (void) pthread_attr_destroy(attr); +} +#endif + /*--------------------------------------------------------------------*/ static void __attribute__((__noreturn__)) @@ -722,6 +749,10 @@ pan_ic(const char *func, const char *file, int line, const char *cond, if (q != NULL) VSB_printf(pan_vsb, "thread = (%s)\n", q); +#ifdef HAVE_PTHREAD_GETATTR_NP + pan_threadattr(pan_vsb); +#endif + if (!FEATURE(FEATURE_SHORT_PANIC)) { req = THR_GetRequest(); VSB_cat(pan_vsb, "thr."); diff --git a/configure.ac b/configure.ac index 24956aaca..fbe5032ce 100644 --- a/configure.ac +++ b/configure.ac @@ -239,6 +239,7 @@ LIBS="${PTHREAD_LIBS}" AC_CHECK_FUNCS([pthread_set_name_np]) AC_CHECK_FUNCS([pthread_setname_np]) AC_CHECK_FUNCS([pthread_mutex_isowned_np]) +AC_CHECK_FUNCS([pthread_getattr_np]) LIBS="${save_LIBS}" AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"]) From nils.goroll at uplex.de Thu Mar 7 00:09:06 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Thu, 7 Mar 2019 00:09:06 +0000 (UTC) Subject: [master] e255baaa0 Check if adding another 4k to the stack is enough Message-ID: <20190307000906.D857860EA6@lists.varnish-cache.org> commit e255baaa0813a019f1da8ec7f614ad453eac6c8e Author: Nils Goroll Date: Thu Mar 7 01:07:51 2019 +0100 Check if adding another 4k to the stack is enough it is on my debian buster Ref #2817 diff --git a/bin/varnishtest/tests/r02817.vtc b/bin/varnishtest/tests/r02817.vtc index 4e9b1189f..51b4c0b41 100644 --- a/bin/varnishtest/tests/r02817.vtc +++ b/bin/varnishtest/tests/r02817.vtc @@ -67,7 +67,8 @@ server s1 { } } -start -varnish v1 -vcl+backend { +# XXX THIS TEST SHOULD USE THE DEFAULT STACK SIZE - WIP +varnish v1 -arg "-p thread_pool_stack=52k" -vcl+backend { import std; import debug; From nils.goroll at uplex.de Thu Mar 7 00:23:07 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Thu, 7 Mar 2019 00:23:07 +0000 (UTC) Subject: [master] a090d1519 execute backend.list -p[j] for all builtin directors Message-ID: <20190307002307.30CF4614FE@lists.varnish-cache.org> commit a090d15193ceb109a3563d4816389882b6d808f5 Author: Nils Goroll Date: Thu Mar 7 01:21:05 2019 +0100 execute backend.list -p[j] for all builtin directors Not yet much of a semantic test, but improving code coverage Ref #2896 diff --git a/bin/varnishtest/tests/d00039.vtc b/bin/varnishtest/tests/d00039.vtc new file mode 100644 index 000000000..868a2554e --- /dev/null +++ b/bin/varnishtest/tests/d00039.vtc @@ -0,0 +1,52 @@ +varnishtest "execute backend.list -p[j] on builtin directors" + +varnish v1 -vcl { + import directors; + import std; + + probe p {.url = "/foo"; } + backend a1 { .host = "${bad_ip}"; } + backend a2 { .host = "${bad_ip}"; } + backend a3 { .host = "${bad_ip}"; } + backend a4 { .host = "${bad_ip}"; .probe = p; } + + sub vcl_init { + new rr1 = directors.round_robin(); + rr1.add_backend(a1); + rr1.add_backend(a2); + rr1.add_backend(a3); + rr1.add_backend(a4); + new rr2 = directors.round_robin(); + rr2.add_backend(a1); + rr2.add_backend(a2); + new rr3 = directors.round_robin(); + rr3.add_backend(a4); + new shard = directors.shard(); + shard.set_rampup(1m); + shard.add_backend(a1); + shard.add_backend(a2, ident="A2", rampup=1h); + shard.add_backend(a3); + shard.add_backend(a4, rampup=10m); + shard.reconfigure(); + new rand = directors.random(); + rand.add_backend(a1, 1); + rand.add_backend(a2, 2); + rand.add_backend(a3, 3); + rand.add_backend(a4, 4); + new hash = directors.hash(); + hash.add_backend(a1, 1); + hash.add_backend(a2, 2); + hash.add_backend(a3, 3); + hash.add_backend(a4, 4); + new fallback = directors.fallback(); + fallback.add_backend(a1); + fallback.add_backend(a2); + fallback.add_backend(a3); + fallback.add_backend(a4); + } +} -start + +varnish v1 -cli "backend.list" +varnish v1 -cli "backend.list -p" +varnish v1 -clijson "backend.list -j" +varnish v1 -clijson "backend.list -pj" From fgsch at lodoss.net Thu Mar 7 01:16:07 2019 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Thu, 7 Mar 2019 01:16:07 +0000 (UTC) Subject: [master] bf55b2fcd Just use VERBOSE=1 Message-ID: <20190307011607.DDC79626CD@lists.varnish-cache.org> commit bf55b2fcdb544bb8c2c95a992e3111123c820723 Author: Federico G. Schwindt Date: Thu Mar 7 01:15:29 2019 +0000 Just use VERBOSE=1 diff --git a/.travis.yml b/.travis.yml index 81cec4d2b..93331c5de 100644 --- a/.travis.yml +++ b/.travis.yml @@ -51,18 +51,7 @@ before_install: script: - | if [[ "$TRAVIS_PULL_REQUEST" != "false" ]]; then - make -j3 distcheck + make -j3 distcheck VERBOSE=1 else make -j3 check VERBOSE=1 fi - err=$? - if [[ $err -ne 0 ]] ; then - for f in $(find . -name test-suite.log); do - if ! grep -E '(ERROR|FAIL):.*[1-9]' $f >/dev/null ; then continue ; fi - echo ---------------------------------------------------------------------------- - echo $f - echo ---------------------------------------------------------------------------- - cat $f - done - fi - exit $err From phk at FreeBSD.org Thu Mar 7 09:08:08 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 7 Mar 2019 09:08:08 +0000 (UTC) Subject: [master] 97d187d4d Renovate our pid-file handling. Message-ID: <20190307090808.8943F10553E@lists.varnish-cache.org> commit 97d187d4d659f549e5fcb73b62e4bee22cad10e2 Author: Poul-Henning Kamp Date: Thu Mar 7 09:06:13 2019 +0000 Renovate our pid-file handling. The FreeBSD origin has moved into territory where we will not go (CAPSICUM) so we can now varnish-ify this without cost. diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index ceebbf92c..8b1cadcb6 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -839,8 +839,9 @@ main(int argc, char * const *argv) S_arg = make_secret(dirname); AN(S_arg); - assert(!VPF_Write(pfh1)); - assert(pfh2 == NULL || !VPF_Write(pfh2)); + VPF_Write(pfh1); + if (pfh2 != NULL) + VPF_Write(pfh2); MGT_Complain(C_DEBUG, "Version: %s", VCS_version); MGT_Complain(C_DEBUG, "Platform: %s", VSB_data(vident) + 1); @@ -922,8 +923,8 @@ main(int argc, char * const *argv) MGT_Complain(C_INFO, "manager dies"); mgt_cli_close_all(); VEV_Destroy(&mgt_evb); - (void)VPF_Remove(pfh1); + VPF_Remove(pfh1); if (pfh2 != NULL) - (void)VPF_Remove(pfh2); + VPF_Remove(pfh2); exit(exit_status); } diff --git a/bin/varnishtest/tests/r02646.vtc b/bin/varnishtest/tests/r02646.vtc index a5c3c432c..8b8b97c08 100644 --- a/bin/varnishtest/tests/r02646.vtc +++ b/bin/varnishtest/tests/r02646.vtc @@ -14,8 +14,4 @@ delay 1 shell "rm -f ${tmpdir}/ncsa.pid" -process p1 -expect-exit 1 -stop -wait - -shell -expect "Cannot remove pid file ${tmpdir}/ncsa.pid" { - cat ${tmpdir}/p1/stderr -} +process p1 -stop -wait diff --git a/bin/varnishtest/vtc_haproxy.c b/bin/varnishtest/vtc_haproxy.c index 89d0106e3..82ce237bc 100644 --- a/bin/varnishtest/vtc_haproxy.c +++ b/bin/varnishtest/vtc_haproxy.c @@ -417,7 +417,7 @@ haproxy_wait_pidfile(struct haproxy *h) if (vtc_error) return; - if (VPF_read(h->pid_fn, &pid) != 0) { + if (VPF_Read(h->pid_fn, &pid) != 0) { bprintf(buf_err, "Could not read PID file '%s'", h->pid_fn); usleep(usleep_time); diff --git a/include/vpf.h b/include/vpf.h index d5266ac7c..51afaf36f 100644 --- a/include/vpf.h +++ b/include/vpf.h @@ -33,9 +33,8 @@ struct vpf_fh; struct vpf_fh *VPF_Open(const char *path, mode_t mode, pid_t *pidptr); -int VPF_Write(struct vpf_fh *pfh); -int VPF_Close(struct vpf_fh *pfh); -int VPF_Remove(struct vpf_fh *pfh); -int VPF_read(const char *path, pid_t *); +int VPF_Read(const char *path, pid_t *); +void VPF_Write(const struct vpf_fh *pfh); +void VPF_Remove(struct vpf_fh *pfh); #endif diff --git a/lib/libvarnish/vpf.c b/lib/libvarnish/vpf.c index 0c1bb1f2d..ce406a0dc 100644 --- a/lib/libvarnish/vpf.c +++ b/lib/libvarnish/vpf.c @@ -47,13 +47,11 @@ struct vpf_fh { int pf_fd; - char pf_path[MAXPATHLEN + 1]; + char *pf_path; dev_t pf_dev; ino_t pf_ino; }; -static int _VPF_Remove(struct vpf_fh *pfh, int freeit); - static int vpf_verify(const struct vpf_fh *pfh) { @@ -72,7 +70,7 @@ vpf_verify(const struct vpf_fh *pfh) } int -VPF_read(const char *path, pid_t *pidptr) +VPF_Read(const char *path, pid_t *pidptr) { char buf[16], *endptr; int error, fd, i; @@ -82,8 +80,8 @@ VPF_read(const char *path, pid_t *pidptr) return (errno); i = read(fd, buf, sizeof(buf) - 1); - error = errno; /* Remember errno in case close() wants to change it. */ - (void)close(fd); + error = errno; + closefd(&fd); if (i == -1) return (error); else if (i == 0) @@ -104,21 +102,7 @@ VPF_Open(const char *path, mode_t mode, pid_t *pidptr) { struct vpf_fh *pfh; struct stat sb; - int error, fd, len; - - pfh = malloc(sizeof(*pfh)); - if (pfh == NULL) - return (NULL); - - assert(path != NULL); - len = snprintf(pfh->pf_path, sizeof(pfh->pf_path), - "%s", path); - - if (len >= (int)sizeof(pfh->pf_path)) { - free(pfh); - errno = ENAMETOOLONG; - return (NULL); - } + int fd; /* * Open the PID file and obtain exclusive lock. @@ -126,15 +110,14 @@ VPF_Open(const char *path, mode_t mode, pid_t *pidptr) * PID file will be truncated again in VPF_Write(), so * VPF_Write() can be called multiple times. */ - fd = VFL_Open(pfh->pf_path, + fd = VFL_Open(path, O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC | O_NONBLOCK, mode); if (fd == -1) { if (errno == EWOULDBLOCK && pidptr != NULL) { - errno = VPF_read(pfh->pf_path, pidptr); + errno = VPF_Read(path, pidptr); if (errno == 0) errno = EEXIST; } - free(pfh); return (NULL); } @@ -142,14 +125,12 @@ VPF_Open(const char *path, mode_t mode, pid_t *pidptr) * Remember file information, so in VPF_Write() we are sure we write * to the proper descriptor. */ - if (fstat(fd, &sb) == -1) { - error = errno; - (void)unlink(pfh->pf_path); - (void)close(fd); - free(pfh); - errno = error; - return (NULL); - } + AZ(fstat(fd, &sb)); + + pfh = malloc(sizeof(*pfh)); + AN(pfh); + pfh->pf_path = strdup(path); + AN(pfh->pf_path); pfh->pf_fd = fd; pfh->pf_dev = sb.st_dev; @@ -158,99 +139,35 @@ VPF_Open(const char *path, mode_t mode, pid_t *pidptr) return (pfh); } -int -VPF_Write(struct vpf_fh *pfh) +void +VPF_Write(const struct vpf_fh *pfh) { char pidstr[16]; - int error, fd; /* * Check remembered descriptor, so we don't overwrite some other * file if pidfile was closed and descriptor reused. */ - errno = vpf_verify(pfh); - if (errno != 0) { - /* - * Don't close descriptor, because we are not sure if it's ours. - */ - return (-1); - } - fd = pfh->pf_fd; + if (vpf_verify(pfh) != 0) + return; /* * Truncate PID file, so multiple calls of VPF_Write() are allowed. */ - if (ftruncate(fd, 0) == -1) { - error = errno; - (void)_VPF_Remove(pfh, 0); - errno = error; - return (-1); - } + AZ(ftruncate(pfh->pf_fd, 0)); - error = snprintf(pidstr, sizeof(pidstr), "%jd", (intmax_t)getpid()); - assert(error < sizeof pidstr); - if (pwrite(fd, pidstr, strlen(pidstr), 0) != (ssize_t)strlen(pidstr)) { - error = errno; - (void)_VPF_Remove(pfh, 0); - errno = error; - return (-1); - } - - return (0); + bprintf(pidstr, "%jd", (intmax_t)getpid()); + assert(pwrite(pfh->pf_fd, pidstr, strlen(pidstr), 0) == + (ssize_t)strlen(pidstr)); } -int -VPF_Close(struct vpf_fh *pfh) +void +VPF_Remove(struct vpf_fh *pfh) { - int error; - - error = vpf_verify(pfh); - if (error != 0) { - errno = error; - return (-1); + if (vpf_verify(pfh) == 0) { + (void)unlink(pfh->pf_path); + closefd(&pfh->pf_fd); } - - if (close(pfh->pf_fd) == -1) - error = errno; + free(pfh->pf_path); free(pfh); - if (error != 0) { - errno = error; - return (-1); - } - return (0); -} - -static int -_VPF_Remove(struct vpf_fh *pfh, int freeit) -{ - int error; - - error = vpf_verify(pfh); - if (error != 0) { - errno = error; - return (-1); - } - - if (unlink(pfh->pf_path) == -1) - error = errno; - if (close(pfh->pf_fd) == -1) { - if (error == 0) - error = errno; - } - if (freeit) - free(pfh); - else - pfh->pf_fd = -1; - if (error != 0) { - errno = error; - return (-1); - } - return (0); -} - -int -VPF_Remove(struct vpf_fh *pfh) -{ - - return (_VPF_Remove(pfh, 1)); } diff --git a/lib/libvarnishapi/vut.c b/lib/libvarnishapi/vut.c index 61c200147..91be51925 100644 --- a/lib/libvarnishapi/vut.c +++ b/lib/libvarnishapi/vut.c @@ -81,10 +81,7 @@ vut_vpf_remove(void) AN(pfh); AN(pfh_vut.P_arg); - if (VPF_Remove(pfh) != 0) - VUT_Error(&pfh_vut, 1, "Cannot remove pid file %s: %s", - pfh_vut.P_arg, strerror(errno)); - + VPF_Remove(pfh); free(pfh_vut.P_arg); ZERO_OBJ(&pfh_vut, sizeof pfh_vut); pfh = NULL; @@ -312,7 +309,7 @@ VUT_Setup(struct VUT *vut) /* Write PID and setup exit handler */ if (vut->P_arg) { AN(pfh); - AZ(VPF_Write(pfh)); + VPF_Write(pfh); /* NB: move ownership to a global pseudo-VUT. */ INIT_OBJ(&pfh_vut, VUT_MAGIC); From nils.goroll at uplex.de Thu Mar 7 10:04:07 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Thu, 7 Mar 2019 10:04:07 +0000 (UTC) Subject: [master] 683b7cbe8 minor code reordering Message-ID: <20190307100407.D71F2106651@lists.varnish-cache.org> commit 683b7cbe8cde1dde8f9e516a354b82430f1d318e Author: Nils Goroll Date: Thu Mar 7 10:59:41 2019 +0100 minor code reordering diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c index 2bf69a0e5..fa2fa462f 100644 --- a/bin/varnishd/mgt/mgt_param.c +++ b/bin/varnishd/mgt/mgt_param.c @@ -642,10 +642,6 @@ MCF_InitParams(struct cli *cli) MCF_ParamConf(MCF_MAXIMUM, "vsl_space", "1G"); } -#if !defined(HAVE_ACCEPT_FILTERS) || defined(__linux) - MCF_ParamConf(MCF_DEFAULT, "accept_filter", "off"); -#endif - low = sysconf(_SC_THREAD_STACK_MIN); MCF_ParamConf(MCF_MINIMUM, "thread_pool_stack", "%jdb", (intmax_t)low); @@ -664,6 +660,10 @@ MCF_InitParams(struct cli *cli) MCF_ParamConf(MCF_MAXIMUM, "thread_pools", "%d", MAX_THREAD_POOLS); +#if !defined(HAVE_ACCEPT_FILTERS) || defined(__linux) + MCF_ParamConf(MCF_DEFAULT, "accept_filter", "off"); +#endif + VCLS_AddFunc(mgt_cls, MCF_AUTH, cli_params); vsb = VSB_new_auto(); From nils.goroll at uplex.de Thu Mar 7 10:04:07 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Thu, 7 Mar 2019 10:04:07 +0000 (UTC) Subject: [master] 1226e77f9 increase default stack size on 64bit from 48k to 56k Message-ID: <20190307100407.F23F6106654@lists.varnish-cache.org> commit 1226e77f9501c56976635c714c99d84f417aa5d2 Author: Nils Goroll Date: Thu Mar 7 11:00:23 2019 +0100 increase default stack size on 64bit from 48k to 56k Ref #2932 Fixes #2817 diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c index fa2fa462f..8e1653f85 100644 --- a/bin/varnishd/mgt/mgt_param.c +++ b/bin/varnishd/mgt/mgt_param.c @@ -629,6 +629,8 @@ MCF_InitParams(struct cli *cli) MCF_TcpParams(); + def = 56 * 1024; + if (sizeof(void *) < 8) { /*lint !e506 !e774 */ /* * Adjust default parameters for 32 bit systems to conserve @@ -640,6 +642,7 @@ MCF_InitParams(struct cli *cli) MCF_ParamConf(MCF_DEFAULT, "http_req_size", "12k"); MCF_ParamConf(MCF_DEFAULT, "gzip_buffer", "4k"); MCF_ParamConf(MCF_MAXIMUM, "vsl_space", "1G"); + def = 48 * 1024; } low = sysconf(_SC_THREAD_STACK_MIN); @@ -647,9 +650,8 @@ MCF_InitParams(struct cli *cli) #if defined(__SANITIZER) || __has_feature(address_sanitizer) def = 92 * 1024; -#else - def = 48 * 1024; #endif + if (def < low) def = low; MCF_ParamConf(MCF_DEFAULT, "thread_pool_stack", "%jdb", (intmax_t)def); diff --git a/bin/varnishtest/tests/r02817.vtc b/bin/varnishtest/tests/r02817.vtc index 51b4c0b41..4e9b1189f 100644 --- a/bin/varnishtest/tests/r02817.vtc +++ b/bin/varnishtest/tests/r02817.vtc @@ -67,8 +67,7 @@ server s1 { } } -start -# XXX THIS TEST SHOULD USE THE DEFAULT STACK SIZE - WIP -varnish v1 -arg "-p thread_pool_stack=52k" -vcl+backend { +varnish v1 -vcl+backend { import std; import debug; From nils.goroll at uplex.de Thu Mar 7 11:19:07 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Thu, 7 Mar 2019 11:19:07 +0000 (UTC) Subject: [master] 3902e920c directors.shard: fix hole handling during recondiguration Message-ID: <20190307111907.CBC6D107E21@lists.varnish-cache.org> commit 3902e920c8e922947078b1f3d1b0c21a0ae0560e Author: Nils Goroll Date: Thu Mar 7 11:51:57 2019 +0100 directors.shard: fix hole handling during recondiguration diff --git a/lib/libvmod_directors/shard_cfg.c b/lib/libvmod_directors/shard_cfg.c index 154595e8f..1483098ff 100644 --- a/lib/libvmod_directors/shard_cfg.c +++ b/lib/libvmod_directors/shard_cfg.c @@ -355,10 +355,15 @@ shardcfg_backend_lookup(const struct backend_reconfig *re, unsigned i, max = re->shardd->n_backend + re->hole_n; const struct shard_backend *bb = re->shardd->backend; - for (i = 0; i < max; i++) + if (max > 0) + AN(bb); + + for (i = 0; i < max; i++) { + if (bb[i].backend == NULL) + continue; // hole if (!shardcfg_backend_cmp(b, &bb[i])) return &bb[i]; - + } return NULL; } @@ -434,6 +439,8 @@ shardcfg_backend_del(struct backend_reconfig *re, struct shard_backend * const bb = re->shardd->backend; for (i = 0; i < max; i++) { + if (bb[i].backend == NULL) + continue; // hole if (shardcfg_backend_del_cmp(spec, &bb[i])) continue; From nils.goroll at uplex.de Thu Mar 7 11:19:07 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Thu, 7 Mar 2019 11:19:07 +0000 (UTC) Subject: [master] c316df77e vtc: shard reconfig coverage Message-ID: <20190307111908.08F85107E24@lists.varnish-cache.org> commit c316df77eb86d4702be7447554aa4595bb5f92f1 Author: Nils Goroll Date: Thu Mar 7 11:55:03 2019 +0100 vtc: shard reconfig coverage diff --git a/bin/varnishtest/tests/d00015.vtc b/bin/varnishtest/tests/d00015.vtc index 8e3aab64e..371f6bccd 100644 --- a/bin/varnishtest/tests/d00015.vtc +++ b/bin/varnishtest/tests/d00015.vtc @@ -126,6 +126,63 @@ varnish v1 -vcl+backend { } std.log("-- END"); + + ## gcov - semantic testing via the client request & .list + # expand + vd.add_backend(s1, "0x00"); + vd.add_backend(s1, "0x01"); + vd.add_backend(s1, "0x02"); + vd.add_backend(s1, "0x03"); + vd.add_backend(s1, "0x04"); + vd.add_backend(s1, "0x05"); + vd.add_backend(s1, "0x06"); + vd.add_backend(s1, "0x07"); + vd.add_backend(s1, "0x08"); + vd.add_backend(s1, "0x09"); + vd.add_backend(s1, "0x0a"); + vd.add_backend(s1, "0x0b"); + vd.add_backend(s1, "0x0c"); + vd.add_backend(s1, "0x0d"); + vd.add_backend(s1, "0x0e"); + vd.add_backend(s1, "0x0f"); + if (!vd.reconfigure(replicas=1)) { + std.log("reconfigure failed"); + } + vd.remove_backend(s1, "0x00"); + vd.remove_backend(s1, "0x01"); + vd.remove_backend(s1, "0x02"); + vd.remove_backend(s1, "0x03"); + vd.remove_backend(s1, "0x04"); + vd.remove_backend(s1, "0x05"); + vd.remove_backend(s1, "0x06"); + vd.remove_backend(s1, "0x07"); + vd.remove_backend(s1, "0x08"); + vd.remove_backend(s1, "0x09"); + vd.remove_backend(s1, "0x0a"); + vd.remove_backend(s1, "0x0b"); + vd.remove_backend(s1, "0x0c"); + vd.remove_backend(s1, "0x0d"); + vd.remove_backend(s1, "0x0e"); + vd.remove_backend(s1, "0x0f"); + if (!vd.reconfigure(replicas=1)) { + std.log("reconfigure failed"); + } + vd.set_warmup(0.5); + + + # hole handling + vd.remove_backend(s3, "4"); + vd.remove_backend(s3, "5"); + vd.add_backend(s1, "4"); + vd.add_backend(s2, "5"); + vd.remove_backend(s1, "5"); + vd.remove_backend(s1, "4"); + vd.add_backend(s3, "4"); + vd.add_backend(s3, "5"); + if (!vd.reconfigure(replicas=1)) { + std.log("reconfigure failed"); + } + vd.set_warmup(0); } sub vcl_recv { @@ -220,3 +277,5 @@ client c1 { } -run logexpect l1 -wait + +varnish v1 -cliexpect {(?s)Ident.*s3 +1 +h.*s3 +2 +h.*s3 +4 +h.*s3 +5 +h.*s3 +6 +h.*s3 +7 +h} "backend.list -p" From phk at FreeBSD.org Thu Mar 7 11:55:08 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 7 Mar 2019 11:55:08 +0000 (UTC) Subject: [master] 71f707953 Resync vfl.c with FreeBSD's flopen.c Message-ID: <20190307115508.D94AB108A71@lists.varnish-cache.org> commit 71f707953d7b76c8fb8df2aaed6ec1566ee7a178 Author: Poul-Henning Kamp Date: Thu Mar 7 11:54:15 2019 +0000 Resync vfl.c with FreeBSD's flopen.c diff --git a/include/vfl.h b/include/vfl.h index a07b21fd3..6cf926526 100644 --- a/include/vfl.h +++ b/include/vfl.h @@ -32,6 +32,5 @@ #define VFL_H_INCLUDED int VFL_Open(const char *, int, ...); -int VFL_Test(int fd, pid_t *pid); #endif diff --git a/lib/libvarnish/vfl.c b/lib/libvarnish/vfl.c index 9af496a91..1809dd79e 100644 --- a/lib/libvarnish/vfl.c +++ b/lib/libvarnish/vfl.c @@ -1,4 +1,6 @@ /*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * * Copyright (c) 2007-2009 Dag-Erling Co?dan Sm?rgrav * All rights reserved. * @@ -24,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * Derived from: - * $FreeBSD: head/lib/libutil/flopen.c 309344 2016-12-01 02:21:36Z cem $ + * $FreeBSD: head/lib/libutil/flopen.c 326219 2017-11-26 02:00:33Z pfg $ */ #include "config.h" @@ -48,8 +50,8 @@ * code's apparent simplicity; there would be no need for this function if it * was easy to get right. */ -int -VFL_Open(const char *path, int flags, ...) +static int +vflopenat(int dirfd, const char *path, int flags, va_list ap) { int fd, operation, serrno, trunc; struct stat sb, fsb; @@ -61,11 +63,7 @@ VFL_Open(const char *path, int flags, ...) mode = 0; if (flags & O_CREAT) { - va_list ap; - - va_start(ap, flags); mode = (mode_t)va_arg(ap, int); /* mode_t promoted to int */ - va_end(ap); } operation = LOCK_EX; @@ -76,7 +74,7 @@ VFL_Open(const char *path, int flags, ...) flags &= ~O_TRUNC; for (;;) { - if ((fd = open(path, flags, mode)) == -1) + if ((fd = openat(dirfd, path, flags, mode)) == -1) /* non-existent or no access */ return (-1); if (flock(fd, operation) == -1) { @@ -86,7 +84,7 @@ VFL_Open(const char *path, int flags, ...) errno = serrno; return (-1); } - if (stat(path, &sb) == -1) { + if (fstatat(dirfd, path, &sb, 0) == -1) { /* disappeared from under our feet */ (void)close(fd); continue; @@ -127,26 +125,14 @@ VFL_Open(const char *path, int flags, ...) } } -/* Tests if the given fd is locked through flopen - * If pid is non-NULL, stores the pid of the process holding the lock there - * Returns 1 if the file is locked - * Returns 0 if the file is unlocked - * Returns -1 on error (and errno) - */ int -VFL_Test(int fd, pid_t *pid) +VFL_Open(const char *path, int flags, ...) { - struct flock lock; - - memset(&lock, 0, sizeof lock); - lock.l_type = F_WRLCK; - lock.l_whence = SEEK_SET; + va_list ap; + int ret; - if (fcntl(fd, F_GETLK, &lock) == -1) - return (-1); - if (lock.l_type == F_UNLCK) - return (0); - if (pid != NULL) - *pid = lock.l_pid; - return (1); + va_start(ap, flags); + ret = vflopenat(AT_FDCWD, path, flags, ap); + va_end(ap); + return (ret); } From phk at FreeBSD.org Thu Mar 7 12:21:08 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 7 Mar 2019 12:21:08 +0000 (UTC) Subject: [master] 110a12824 Reflect that Lasse is no longer at V-S Message-ID: <20190307122108.0D78410931E@lists.varnish-cache.org> commit 110a1282449fdbe5b9109d3157d182d23f2492aa Author: Poul-Henning Kamp Date: Thu Mar 7 12:20:11 2019 +0000 Reflect that Lasse is no longer at V-S diff --git a/doc/sphinx/tutorial/introduction.rst b/doc/sphinx/tutorial/introduction.rst index cff726893..99862cc0e 100644 --- a/doc/sphinx/tutorial/introduction.rst +++ b/doc/sphinx/tutorial/introduction.rst @@ -59,8 +59,7 @@ About the Varnish development process Varnish is a community driven project. The development is overseen by the Varnish Governing Board which currently consists of Poul-Henning Kamp -(Architect), Rogier Mulhuijzen (Fastly) and Lasse Karstensen (Varnish -Software). +(Architect), Rogier Mulhuijzen (Fastly) and Lasse Karstensen (Independent). Please see https://www.varnish-cache.org/trac/wiki/Contributing as a starting point if you would like to contribute to Varnish. From martin at varnish-software.com Thu Mar 7 15:44:08 2019 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Thu, 7 Mar 2019 15:44:08 +0000 (UTC) Subject: [master] 81ef95b8d Unconfuse vxp_lexer Message-ID: <20190307154408.59AF510DF99@lists.varnish-cache.org> commit 81ef95b8df6b5ea159ea7f05da846385e3247301 Author: Martin Blix Grydeland Date: Thu Mar 7 16:33:58 2019 +0100 Unconfuse vxp_lexer This fixes up the vxp_lexer backslash handling. vxp_decstr() now only handles quoted strings, and will remove quotes and unescape the string. The bareword strings do not go through vxp_decstr(). One never reached error handler removed. Fixes: #2891 diff --git a/lib/libvarnishapi/vxp_lexer.c b/lib/libvarnishapi/vxp_lexer.c index 584cf4f97..58728fb16 100644 --- a/lib/libvarnishapi/vxp_lexer.c +++ b/lib/libvarnishapi/vxp_lexer.c @@ -61,25 +61,23 @@ vxp_add_token(struct vxp *vxp, unsigned tok, const char *b, const char *e) vxp->t = t; } -static int -vxp_decstr(struct vxp *vxp, int quoted) +/* Unquote and unescape string */ +static void +vxp_decstr(struct vxp *vxp) { const char *b, *e, *p; char *s; - unsigned l; int esc = 0; assert(vxp->t->tok == VAL); b = vxp->t->b; e = vxp->t->e; - if (quoted) { - assert(e - b >= 2); - b++; - e--; - } - l = e - b; - s = vxp->t->dec = vxp_Alloc(vxp, l + 1); + assert(e - b >= 2); + b++; + e--; + + s = vxp->t->dec = vxp_Alloc(vxp, e - b + 1); AN(vxp->t->dec); for (p = b; p < e; p++) { if (!esc && *p == '\\') { @@ -90,12 +88,6 @@ vxp_decstr(struct vxp *vxp, int quoted) *s++ = *p; } *s = '\0'; - if (esc || p != e) { - VSB_printf(vxp->sb, "Syntax error "); - vxp_ErrWhere(vxp, vxp->t, -1); - return (1); - } - return (0); } /* @@ -130,9 +122,11 @@ vxp_Lexer(struct vxp *vxp) if (*p == '"' || *p == '\'') { quote = *p; for (q = p + 1; q < vxp->e; q++) { - if (q[-1] == '\\') - continue; - if (*q == quote) { + if (*q == '\\') { + q++; + if (q == vxp->e) + break; + } else if (*q == quote) { q++; quote = '\0'; break; @@ -144,8 +138,7 @@ vxp_Lexer(struct vxp *vxp) vxp_ErrWhere(vxp, vxp->t, q - p); return; } - if (vxp_decstr(vxp, 1)) - return; + vxp_decstr(vxp); p = q; continue; } @@ -156,8 +149,10 @@ vxp_Lexer(struct vxp *vxp) if (!isword(*q)) break; vxp_add_token(vxp, VAL, p, q); - if (vxp_decstr(vxp, 0)) - return; + vxp->t->dec = vxp_Alloc(vxp, q - p + 1); + AN(vxp->t->dec); + memcpy(vxp->t->dec, p, q - p); + vxp->t->dec[q - p] = '\0'; p = q; continue; } From phk at FreeBSD.org Fri Mar 8 07:41:06 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 8 Mar 2019 07:41:06 +0000 (UTC) Subject: [master] 34d9130b3 Flexelinting Message-ID: <20190308074106.F0EA064040@lists.varnish-cache.org> commit 34d9130b34d21a53caa5ecf1fb584c8315b4eeba Author: Poul-Henning Kamp Date: Fri Mar 8 07:40:20 2019 +0000 Flexelinting diff --git a/lib/libvarnishapi/vxp_lexer.c b/lib/libvarnishapi/vxp_lexer.c index 58728fb16..b004c55f8 100644 --- a/lib/libvarnishapi/vxp_lexer.c +++ b/lib/libvarnishapi/vxp_lexer.c @@ -77,7 +77,7 @@ vxp_decstr(struct vxp *vxp) b++; e--; - s = vxp->t->dec = vxp_Alloc(vxp, e - b + 1); + s = vxp->t->dec = vxp_Alloc(vxp, (e - b) + 1); AN(vxp->t->dec); for (p = b; p < e; p++) { if (!esc && *p == '\\') { @@ -149,7 +149,7 @@ vxp_Lexer(struct vxp *vxp) if (!isword(*q)) break; vxp_add_token(vxp, VAL, p, q); - vxp->t->dec = vxp_Alloc(vxp, q - p + 1); + vxp->t->dec = vxp_Alloc(vxp, (q - p) + 1); AN(vxp->t->dec); memcpy(vxp->t->dec, p, q - p); vxp->t->dec[q - p] = '\0'; From phk at FreeBSD.org Fri Mar 8 10:41:07 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 8 Mar 2019 10:41:07 +0000 (UTC) Subject: [master] 1dc891a5a Protect open_streams under the session mutex. Message-ID: <20190308104107.7D97190DBA@lists.varnish-cache.org> commit 1dc891a5aad0e20f45726ea1c2d923d520917691 Author: Poul-Henning Kamp Date: Fri Mar 8 10:38:25 2019 +0000 Protect open_streams under the session mutex. Also count OU requests towards the limit. Fixes #2931 & #2933 diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index 370748ccd..99cd7d5d2 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -172,10 +172,14 @@ h2_new_req(const struct worker *wrk, struct h2_sess *h2, r2->h2sess = h2; r2->stream = stream; r2->req = req; + if (stream) + r2->counted = 1; r2->r_window = h2->local_settings.initial_window_size; r2->t_window = h2->remote_settings.initial_window_size; req->transport_priv = r2; Lck_Lock(&h2->sess->mtx); + if (stream) + h2->open_streams++; VTAILQ_INSERT_TAIL(&h2->streams, r2, list); Lck_Unlock(&h2->sess->mtx); h2->refcnt++; @@ -649,8 +653,6 @@ h2_rx_headers(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) } h2->highest_stream = h2->rxf_stream; r2 = h2_new_req(wrk, h2, h2->rxf_stream, NULL); - r2->counted = 1; - h2->open_streams++; } CHECK_OBJ_NOTNULL(r2, H2_REQ_MAGIC); From dridi.boukelmoune at gmail.com Fri Mar 8 10:59:06 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 8 Mar 2019 10:59:06 +0000 (UTC) Subject: [master] 0582753d3 Add a note regarding a race recently closed Message-ID: <20190308105906.9865391534@lists.varnish-cache.org> commit 0582753d3708bd8cd546b30e6d6096e91a721b39 Author: Dridi Boukelmoune Date: Fri Mar 8 11:57:19 2019 +0100 Add a note regarding a race recently closed Refs 1dc891a5aad0e20f45726ea1c2d923d520917691 Refs #2931 #2933 diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index 99cd7d5d2..acd38868b 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -644,6 +644,9 @@ 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 + /* XXX: is it safe to load h2->open_streams without the h2 + * session lock held? + */ if (h2->open_streams >= h2->local_settings.max_concurrent_streams) { VSLb(h2->vsl, SLT_Debug, From dridi.boukelmoune at gmail.com Fri Mar 8 11:02:08 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 8 Mar 2019 11:02:08 +0000 (UTC) Subject: [master] 78694521f Turn the question into an explanation Message-ID: <20190308110208.159E2917EE@lists.varnish-cache.org> commit 78694521f5b41677e0c7f45907eb20ff48e7bb46 Author: Dridi Boukelmoune Date: Fri Mar 8 12:00:22 2019 +0100 Turn the question into an explanation It was already answered outside of the commit log. diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index acd38868b..48ad050c7 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -644,8 +644,9 @@ 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 - /* XXX: is it safe to load h2->open_streams without the h2 - * session lock held? + /* NB: we don't need to guard the read of h2->open_streams + * because headers are handled sequentially so it cannot + * increase under our feet. */ if (h2->open_streams >= h2->local_settings.max_concurrent_streams) { From lasse.karstensen at gmail.com Fri Mar 8 11:47:06 2019 From: lasse.karstensen at gmail.com (Lasse Karstensen) Date: Fri, 8 Mar 2019 11:47:06 +0000 (UTC) Subject: [master] d32c475d4 Make it possible to override TMPDIR. Message-ID: <20190308114706.D11B9928D7@lists.varnish-cache.org> commit d32c475d424b7a63f41542d3f42b424311aaed8a Author: Lasse Karstensen Date: Fri Mar 8 12:45:54 2019 +0100 Make it possible to override TMPDIR. diff --git a/tools/vtest.sh b/tools/vtest.sh index 4d4b3d6dd..4464826e5 100755 --- a/tools/vtest.sh +++ b/tools/vtest.sh @@ -35,7 +35,7 @@ export MAKEFLAGS="${MAKEFLAGS:--j2}" # This tempdirectory must not be used by anything else. # Do *NOT* set this to /tmp -export TMPDIR=`pwd`/_vtest_tmp +export TMPDIR="${TMPDIR:-`pwd`/_vtest_tmp}" # Message to be shown in result pages # Max 10 char of [A-Za-z0-9/. _-] From phk at FreeBSD.org Fri Mar 8 12:21:06 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 8 Mar 2019 12:21:06 +0000 (UTC) Subject: [master] 3c04f5c71 Strip flags & final_flags when we switch to CONTINUATION headers. Message-ID: <20190308122107.07F0F9362C@lists.varnish-cache.org> commit 3c04f5c715a078cec448ffc14a48fec38596d4e7 Author: Poul-Henning Kamp Date: Fri Mar 8 12:19:30 2019 +0000 Strip flags & final_flags when we switch to CONTINUATION headers. Fixes #2934 diff --git a/bin/varnishd/http2/cache_http2_send.c b/bin/varnishd/http2/cache_http2_send.c index b3eb68801..dd20d1051 100644 --- a/bin/varnishd/http2/cache_http2_send.c +++ b/bin/varnishd/http2/cache_http2_send.c @@ -337,6 +337,8 @@ H2_Send(struct worker *wrk, struct h2_req *r2, p += tf; len -= tf; ftyp = ftyp->continuation; + flags &= ftyp->flags; + final_flags &= ftyp->flags; } while (!h2->error && len > 0); } } diff --git a/bin/varnishtest/tests/r02934.vtc b/bin/varnishtest/tests/r02934.vtc new file mode 100644 index 000000000..ac607b667 --- /dev/null +++ b/bin/varnishtest/tests/r02934.vtc @@ -0,0 +1,27 @@ +varnishtest "Bug in CONTINUATION flags when no sendbody" + +server s1 { + rxreq + expect req.proto == HTTP/1.1 + txresp -hdr "Content-Type: text/plain" -hdrlen Foo 100 + +} -start + +varnish v1 -cliok "param.set feature +http2" +varnish v1 -cliok "param.set debug +syncvsl" +varnish v1 -cliok "param.set debug +h2_nocheck" + +varnish v1 -vcl+backend { } -start + +client c1 { + stream 0 { + txsettings -framesize 64 + rxsettings + } -run + stream 1 { + txreq -req HEAD + rxresp + expect resp.status == 200 + expect resp.http.content-Type == "text/plain" + } -run +} -run From lasse.karstensen at gmail.com Fri Mar 8 19:23:06 2019 From: lasse.karstensen at gmail.com (Lasse Karstensen) Date: Fri, 8 Mar 2019 19:23:06 +0000 (UTC) Subject: [master] 2e757bb14 Use HTTPS. Message-ID: <20190308192306.D72799EFC4@lists.varnish-cache.org> commit 2e757bb14c8ef3d2be373a29795024a44e799dba Author: Lasse Karstensen Date: Fri Mar 8 20:21:49 2019 +0100 Use HTTPS. (test commit for vtest) diff --git a/README.Packaging b/README.Packaging index 71ac964f0..0b4275893 100644 --- a/README.Packaging +++ b/README.Packaging @@ -24,4 +24,4 @@ Third-party packages -------------------- Varnish Cache is built and packaged in many different operating systems and -distributions. Please see http://varnish-cache.org for more information. +distributions. Please see https://varnish-cache.org/ for more information. From geoff at uplex.de Mon Mar 11 10:22:07 2019 From: geoff at uplex.de (Geoff Simmons) Date: Mon, 11 Mar 2019 10:22:07 +0000 (UTC) Subject: [master] f3d4cad64 Polish the docs about VMOD std in the user release notes for March 2019. Message-ID: <20190311102207.B62E69B367@lists.varnish-cache.org> commit f3d4cad64b20ed3c0ce0839a0e39b201b0222055 Author: Geoff Simmons Date: Mon Mar 11 11:19:11 2019 +0100 Polish the docs about VMOD std in the user release notes for March 2019. Lists of formatted function names in HTML are easier to read in bullet lists. Moved the part about std conversion functions to "Upgrading", since the old versions are deprecated. "Changes" links to it. diff --git a/doc/sphinx/whats-new/changes-trunk.rst b/doc/sphinx/whats-new/changes-trunk.rst index 3c43b22ad..4dbfd5f49 100644 --- a/doc/sphinx/whats-new/changes-trunk.rst +++ b/doc/sphinx/whats-new/changes-trunk.rst @@ -85,34 +85,13 @@ changed the ``builtin.vcl``. VMODs ===== -Added the function :ref:`vmod_directors.lookup`, only for use in -``vcl_init`` or ``vcl_fini``. +New type-conversion functions have been added to :ref:`vmod_std(3)`, +and the previous conversion functions are now deprecated. See +:ref:`whatsnew_upgrading_std_conversion_2019_03`. -The type-conversion functions in :ref:`vmod_std(3)` have been reworked -to make them more flexible and easier to use: -:ref:`vmod_std.duration`, :ref:`vmod_std.bytes`, -:ref:`vmod_std.integer`, :ref:`vmod_std.real` and :ref:`vmod_std.time` -now also accept suitable numeral or quantitative arguments. - -These type-conversion functions should be fully backwards compatible, -but the following differences should be noted: - -* The *fallback* is not required and more. A conversion failure in the - absense of a *fallback* argument will now trigger a VCL failure. - -* A VCL failure will also be triggered if no or more than one argument - (plus optional *fallback*) is given. - -* Conversion functions now only ever truncate if necessary (instead of - rounding). - -* :ref:`vmod_std.round` has been added for explicit rounding. - -The functions :ref:`vmod_std.real2integer`, :ref:`vmod_std.real2time`, -:ref:`vmod_std.time2integer` and :ref:`vmod_std.time2real` are -superseded by these changed and should thus be replaced by the above -mentioned conversion functions. They will be removed in a future -version of Varnish. +The function :ref:`vmod_directors.lookup` has been added to +:ref:`vmod_directors(3)`, only for use in ``vcl_init`` or +``vcl_fini``. varnishlog(1), varnishncsa(1) and vsl(7) ======================================== diff --git a/doc/sphinx/whats-new/upgrading-trunk.rst b/doc/sphinx/whats-new/upgrading-trunk.rst index 9eaa3b662..335b7f210 100644 --- a/doc/sphinx/whats-new/upgrading-trunk.rst +++ b/doc/sphinx/whats-new/upgrading-trunk.rst @@ -66,6 +66,45 @@ now. These are: * ``vmod_dir`` -- use :ref:`ref_param_vmod_path` instead +.. _whatsnew_upgrading_std_conversion_2019_03: + +Type conversion functions in VMOD std +===================================== + +The type-conversion functions in :ref:`vmod_std(3)` have been reworked +to make them more flexible and easier to use. These new functions now +also accept suitable numeral or quantitative arguments. + +* :ref:`vmod_std.duration` +* :ref:`vmod_std.bytes` +* :ref:`vmod_std.integer` +* :ref:`vmod_std.real` +* :ref:`vmod_std.time` + +These type-conversion functions should be fully backwards compatible, +but the following differences should be noted: + +* The *fallback* is not required any more. A conversion failure in the + absence of a *fallback* argument will now trigger a VCL failure. + +* A VCL failure will also be triggered if no or more than one argument + (plus optional *fallback*) is given. + +* Conversion functions now only ever truncate if necessary (instead of + rounding). + +* :ref:`vmod_std.round` has been added for explicit rounding. + +These functions are deprecated and should be replaced by the new +conversion functions: + +* :ref:`vmod_std.real2integer` +* :ref:`vmod_std.real2time` +* :ref:`vmod_std.time2integer` +* :ref:`vmod_std.time2real` + +They will be removed in a future version of Varnish. + varnishadm and the CLI ====================== From geoff at uplex.de Mon Mar 11 10:56:07 2019 From: geoff at uplex.de (Geoff Simmons) Date: Mon, 11 Mar 2019 10:56:07 +0000 (UTC) Subject: [master] 3ff448bae Rearrange and reduce repetition a bit in "Changes" and "Upgrading". Message-ID: <20190311105607.68B549C0FB@lists.varnish-cache.org> commit 3ff448bae670b1c1a97a72cc713e8b8b3ac8492a Author: Geoff Simmons Date: Mon Mar 11 11:53:42 2019 +0100 Rearrange and reduce repetition a bit in "Changes" and "Upgrading". "Changes" details information that is visible and may be actionable for users. The docs reference one another (rather than repeat one another). diff --git a/doc/sphinx/whats-new/changes-trunk.rst b/doc/sphinx/whats-new/changes-trunk.rst index 4dbfd5f49..c39e8b662 100644 --- a/doc/sphinx/whats-new/changes-trunk.rst +++ b/doc/sphinx/whats-new/changes-trunk.rst @@ -2,14 +2,14 @@ updates for changes in the development branch. For changes in the released versions of Varnish, see:** :ref:`whats-new-index` -.. _whatsnew_changes_CURRENT: +.. _whatsnew_changes_2019_03: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Changes in Varnish **$NEXT_RELEASE** %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% For information about updating your current Varnish deployment to the -new version, see :ref:`whatsnew_upgrading_CURRENT`. +new version, see :ref:`whatsnew_upgrading_2019_03`. A more detailed and technical account of changes in Varnish, with links to issues that have been fixed and pull requests that have been @@ -36,14 +36,9 @@ and/or :ref:`ref_param_thread_pools`. Parameters ~~~~~~~~~~ -Some parameters that have been long deprecated are now retired. Now -you must use these parameters: - -* :ref:`ref_param_vsl_reclen` (in place of ``shm_reclen``) - -* :ref:`ref_param_vcl_path` (in place of ``vcl_dir``) - -* :ref:`ref_param_vmod_path` (in place of ``vmod_dir``) +Some parameters that have been long deprecated are now retired. See +:ref:`whatsnew_upgrading_params_2019_03` in +:ref:`whatsnew_upgrading_2019_03`. Added :ref:`ref_param_thread_pool_watchdog`, see above. @@ -69,18 +64,14 @@ Added ``req.is_hitmiss`` and ``req.is_hitpass``, see :ref:`vcl(7)`. Other changes to VCL ~~~~~~~~~~~~~~~~~~~~ -When the ``.path`` field of a backend declaration is used to define a -Unix domain socket as the backend address, and the socket file does -not exist or is not accessible at VCL load time, then a warning is -issued, but the VCL load is allowed to continue. Previously, the load -would fail in that case. This makes it easier to start the peer -component listening at the socket, or set the socket's permissions, -after starting Varnish or loading VCL. If the socket still cannot be -accessed when a fetch is attempted, then the fetch fails. +Runtime restrictions concerning the accessibility of Unix domain +sockets have been relaxed, see :ref:`whatsnew_upgrading_vcl_2019_03` +in :ref:`whatsnew_upgrading_2019_03`. ``return(miss)`` from ``vcl_hit{}`` did never work as intended for the common case (it actually turned into a pass), so we now removed it and -changed the ``builtin.vcl``. +changed the ``builtin.vcl``. See +:ref:`whatsnew_upgrading_vcl_2019_03`. VMODs ===== @@ -116,6 +107,12 @@ microsecond precision. This affects the tags ``ExpKill`` and varnishadm(1) and varnish-cli(7) ================================ +The output formats of the ``vcl.list`` and ``backend.list`` commands +have changed, see :ref:`whatsnew_upgrading_backend_list_2019_03` and +:ref:`whatsnew_upgrading_vcl_list_2019_03` in +:ref:`whatsnew_upgrading_2019_03`, as well as :ref:`varnish-cli(7)` +for details. + .. _whatsnew_changes_cli_json: JSON output @@ -134,8 +131,8 @@ the following commands (see :ref:`varnish-cli(7)`): The ``-j`` option was already available for ``backend.list``, ``ping`` and ``help`` in previous versions. -For automated parsing of CLI responses (``varnishadm`` output), we -recommend the use of JSON format. +For automated parsing of CLI responses (:ref:`varnishadm(1)` output), +we recommend the use of JSON format. ``param.reset `` ~~~~~~~~~~~~~~~~~~~~~~~ @@ -143,65 +140,6 @@ recommend the use of JSON format. Added the command ``param.reset`` to reset a parameter's value to its default, see :ref:`varnish-cli(7)`. -.. _whatsnew_changes_vcl_list_backend_list: - -Listing backends -~~~~~~~~~~~~~~~~ - -``backend.list`` has grown an additional column, the output has -changed and fields are now of dynamic width: - -* The ``Admin`` column now accurately states ``probe`` only if a - backend has some means of dynamically determining health state. - -* The ``Probe`` column has been changed to display ``X/Y``, where: - - * Integer ``X`` is the number of good probes in the most recent - window; or if the backend in question is a director, the number of - healthy backends accessed via the director or any other - director-specific metric. - - * Integer ``Y`` is the window in which the threshold for overall - health of the backend is defined (from the ``.window`` field of a - probe, see :ref:`vcl(7)`); or in the case of a director, the total - number of backends accessed via the director or any other - director-specific metric. - - If there is no probe or the director does not provide details, - ``0/0`` is output. - -* The ``Health`` column has been added to contain the dynamic (probe) - health state and the format has been unified to just ``healthy`` or - ``sick``. - - If there is no probe, ``Health`` is always given as - ``healthy``. Notice that the administrative health as shown in the - ``Admin`` column has precedence. - -In the ``probe_message`` field of ``backend.list -j`` output, the -``Probe`` and ``Health`` columns appears as the array ``[X, Y, -health]``. - -See :ref:`varnish-cli(7)` for details. - -Listing VCLs -~~~~~~~~~~~~ - -The non-JSON output of ``vcl.list`` has been changed: - -* The ``state`` and ``temperature`` fields appear in separate columns - (previously combined in one column). - -* The optional column showing the relationships between labels and VCL - configurations (when labels are in use) has been separated into two - columns. - -See :ref:`varnish-cli(7)` for details. In the JSON output for -``vcl.list -j``, this information appears in separate fields. - -The width of columns in ``backend.list`` and ``vcl.list`` output -(non-JSON) is now dynamic, to fit the width of the terminal window. - Banning by expiration parameters ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/doc/sphinx/whats-new/upgrading-trunk.rst b/doc/sphinx/whats-new/upgrading-trunk.rst index 335b7f210..4fa078b2e 100644 --- a/doc/sphinx/whats-new/upgrading-trunk.rst +++ b/doc/sphinx/whats-new/upgrading-trunk.rst @@ -2,7 +2,7 @@ updates for changes in the development branch. For changes in the released versions of Varnish, see:** :ref:`whats-new-index` -.. _whatsnew_upgrading_CURRENT: +.. _whatsnew_upgrading_2019_03: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Upgrading to Varnish **$NEXT_RELEASE** @@ -30,6 +30,8 @@ to:** * Changes in public APIs that may require changes in VMODs or VAPI/VUT clients. +.. _whatsnew_upgrading_vcl_2019_03: + VCL === @@ -44,7 +46,6 @@ listening at the socket, or set its permissions, after Varnish starts or the VCL is loaded. Backend fetches fail if the socket is not accessible by the time the fetch is attempted. - ``return(miss)`` from ``vcl_hit{}`` is now removed. Options to implement similar functionality are: @@ -53,6 +54,8 @@ implement similar functionality are: * ``return (restart)`` from ``vcl_hit{}`` and ``set req.hash_always_miss = true;`` in ``vcl_recv{}`` for the restart. +.. _whatsnew_upgrading_params_2019_03: + Runtime parameters ================== @@ -108,15 +111,71 @@ They will be removed in a future version of Varnish. varnishadm and the CLI ====================== -The output formats of the ``vcl.list`` and ``backend.list`` commands -have changed, see :ref:`whatsnew_changes_vcl_list_backend_list` and -:ref:`varnish-cli(7)` for details. In non-JSON mode, the width of -columns in ``backend.list`` and ``vcl.list`` output is now dynamic, to -fit the width of the terminal window. - The ``-j`` option for JSON output has been added to a number of -commands, see :ref:`whatsnew_changes_cli_json` and -:ref:`varnish-cli(7)`. We recommend the use of JSON format for -automated parsing of CLI responses (:ref:`varnishadm(1)` output). +commands, see :ref:`whatsnew_changes_cli_json` in +:ref:`whatsnew_changes_2019_03` and :ref:`varnish-cli(7)`. We +recommend the use of JSON format for automated parsing of CLI +responses (:ref:`varnishadm(1)` output). + +.. _whatsnew_upgrading_backend_list_2019_03: + +Listing backends +~~~~~~~~~~~~~~~~ + +``backend.list`` has grown an additional column, the output has +changed and fields are now of dynamic width: + +* The ``Admin`` column now accurately states ``probe`` only if a + backend has some means of dynamically determining health state. + +* The ``Probe`` column has been changed to display ``X/Y``, where: + + * Integer ``X`` is the number of good probes in the most recent + window; or if the backend in question is a director, the number of + healthy backends accessed via the director or any other + director-specific metric. + + * Integer ``Y`` is the window in which the threshold for overall + health of the backend is defined (from the ``.window`` field of a + probe, see :ref:`vcl(7)`); or in the case of a director, the total + number of backends accessed via the director or any other + director-specific metric. + + If there is no probe or the director does not provide details, + ``0/0`` is output. + +* The ``Health`` column has been added to contain the dynamic (probe) + health state and the format has been unified to just ``healthy`` or + ``sick``. + + If there is no probe, ``Health`` is always given as + ``healthy``. Notice that the administrative health as shown in the + ``Admin`` column has precedence. + +In the ``probe_message`` field of ``backend.list -j`` output, the +``Probe`` and ``Health`` columns appears as the array ``[X, Y, +health]``. + +See :ref:`varnish-cli(7)` for details. + +.. _whatsnew_upgrading_vcl_list_2019_03: + +Listing VCLs +~~~~~~~~~~~~ + +The non-JSON output of ``vcl.list`` has been changed: + +* The ``state`` and ``temperature`` fields appear in separate columns + (previously combined in one column). + +* The optional column showing the relationships between labels and VCL + configurations (when labels are in use) has been separated into two + columns. + +See :ref:`varnish-cli(7)` for details. In the JSON output for +``vcl.list -j``, this information appears in separate fields. + +The width of columns in ``backend.list`` and ``vcl.list`` output +(non-JSON) is now dynamic, to fit the width of the terminal window. *eof* From geoff at uplex.de Mon Mar 11 11:47:07 2019 From: geoff at uplex.de (Geoff Simmons) Date: Mon, 11 Mar 2019 11:47:07 +0000 (UTC) Subject: [master] fae8e5dd5 Add some notes and refs about VRT 9.0 in "Upgrading" for March 2019. Message-ID: <20190311114707.1FDF3A0312@lists.varnish-cache.org> commit fae8e5dd5f5b073507a294ecb77c327a44da7e7a Author: Geoff Simmons Date: Mon Mar 11 12:45:46 2019 +0100 Add some notes and refs about VRT 9.0 in "Upgrading" for March 2019. diff --git a/doc/sphinx/whats-new/changes-trunk.rst b/doc/sphinx/whats-new/changes-trunk.rst index c39e8b662..c1fdb270e 100644 --- a/doc/sphinx/whats-new/changes-trunk.rst +++ b/doc/sphinx/whats-new/changes-trunk.rst @@ -188,6 +188,8 @@ Changes for developers and VMOD authors Python tools that generate code now prefer python 3 over python 2, when availabale. +.. _whatsnew_changes_director_api_2019_03: + Directors ~~~~~~~~~ diff --git a/doc/sphinx/whats-new/upgrading-trunk.rst b/doc/sphinx/whats-new/upgrading-trunk.rst index 4fa078b2e..9ccd3fb02 100644 --- a/doc/sphinx/whats-new/upgrading-trunk.rst +++ b/doc/sphinx/whats-new/upgrading-trunk.rst @@ -178,4 +178,22 @@ See :ref:`varnish-cli(7)` for details. In the JSON output for The width of columns in ``backend.list`` and ``vcl.list`` output (non-JSON) is now dynamic, to fit the width of the terminal window. +For developers and authors of VMODs and API clients +=================================================== + +The VRT API has been bumped to version 9.0. Changes include: + +* Functions in the API have been added, and others removed. + +* The ``VCL_BLOB`` type is now implemented as ``struct vrt_blob``. + +* The ``req_bodybytes`` field of ``struct req`` has been removed, and + should now be accessed as an object core attribute. + +See ``vrt.h``, the `change log`_ and +:ref:`whatsnew_changes_director_api_2019_03` in +:ref:`whatsnew_changes_2019_03` for details. + +.. _change log: https://github.com/varnishcache/varnish-cache/blob/master/doc/changes.rst + *eof* From phk at FreeBSD.org Mon Mar 11 11:49:07 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 11 Mar 2019 11:49:07 +0000 (UTC) Subject: [master] 0ad326227 Add a 'debug.reqpool.fail F__F____F_FFF' command Message-ID: <20190311114907.2FA63A05C0@lists.varnish-cache.org> commit 0ad32622710c1787d85333faea844d4ab4dd760d Author: Poul-Henning Kamp Date: Mon Mar 11 11:44:41 2019 +0000 Add a 'debug.reqpool.fail F__F____F_FFF' command The argument is read LR and causes TASK_QUEUE_REQ allocs to fail. diff --git a/bin/varnishd/cache/cache_main.c b/bin/varnishd/cache/cache_main.c index 4683a3f3e..02ae0df84 100644 --- a/bin/varnishd/cache/cache_main.c +++ b/bin/varnishd/cache/cache_main.c @@ -392,10 +392,13 @@ child_main(int sigmagic, size_t altstksz) VMOD_Init(); + WRK_Init(); + BAN_Compile(); VRND_SeedAll(); + CLI_AddFuncs(debug_cmds); #if WITH_PERSISTENT_STORAGE diff --git a/bin/varnishd/cache/cache_varnishd.h b/bin/varnishd/cache/cache_varnishd.h index a117d8b8d..f5c4bf656 100644 --- a/bin/varnishd/cache/cache_varnishd.h +++ b/bin/varnishd/cache/cache_varnishd.h @@ -452,6 +452,9 @@ extern struct vrt_privs cli_task_privs[1]; void VMOD_Init(void); void VMOD_Panic(struct vsb *); +/* cache_wrk.c */ +void WRK_Init(void); + /* http1/cache_http1_pipe.c */ void V1P_Init(void); diff --git a/bin/varnishd/cache/cache_wrk.c b/bin/varnishd/cache/cache_wrk.c index 48672a9ea..ffa63deba 100644 --- a/bin/varnishd/cache/cache_wrk.c +++ b/bin/varnishd/cache/cache_wrk.c @@ -57,12 +57,15 @@ #include "cache_varnishd.h" #include "cache_pool.h" +#include "vcli_serve.h" #include "vtim.h" #include "hash/hash_slinger.h" static void Pool_Work_Thread(struct pool *pp, struct worker *wrk); +static uintmax_t reqpoolfail; + /*-------------------------------------------------------------------- * Create and start a back-ground thread which as its own worker and * session data structures; @@ -260,6 +263,17 @@ Pool_Task(struct pool *pp, struct pool_task *task, enum task_prio prio) AN(task->func); assert(prio < TASK_QUEUE_END); + if (prio == TASK_QUEUE_REQ && reqpoolfail) { + retval = reqpoolfail & 1; + reqpoolfail >>= 1; + if (retval) { + VSL(SLT_Debug, 0, + "Failing due to reqpoolfail (next= 0x%jx)", + reqpoolfail); + return(retval); + } + } + Lck_Lock(&pp->mtx); /* The common case first: Take an idle thread, do it. */ @@ -609,3 +623,40 @@ pool_herder(void *priv) } return (NULL); } + +/*-------------------------------------------------------------------- + * Debugging aids + */ + +static void v_matchproto_(cli_func_t) +debug_reqpoolfail(struct cli *cli, const char * const *av, void *priv) +{ + uintmax_t u = 1; + const char *p; + + (void)priv; + (void)cli; + reqpoolfail = 0; + for (p = av[2]; *p != '\0'; p++) { + if (*p == 'F' || *p == 'f') + reqpoolfail |= u; + u <<= 1; + } +} + +static struct cli_proto debug_cmds[] = { + { CLICMD_DEBUG_REQPOOLFAIL, "d", debug_reqpoolfail }, + { NULL } +}; + +/*-------------------------------------------------------------------- + * + */ + +void +WRK_Init(void) +{ + + CLI_AddFuncs(debug_cmds); +} + diff --git a/include/tbl/cli_cmds.h b/include/tbl/cli_cmds.h index f886f94db..99193c6c7 100644 --- a/include/tbl/cli_cmds.h +++ b/include/tbl/cli_cmds.h @@ -321,6 +321,15 @@ CLI_CMD(DEBUG_FRAGFETCH, 1, 1 ) +CLI_CMD(DEBUG_REQPOOLFAIL, + "debug.reqpool.fail", + "debug.reqpool.fail", + "Schedule req-pool failures.", + "The argument is read L-R and 'f' means fail:\n\n" + "\tparam.set debug.reqpoolfail F__F\n\n" + "Means that the frist and the third attempted allocation will fail", + 1, 1 +) CLI_CMD(DEBUG_XID, "debug.xid", "debug.xid", From phk at FreeBSD.org Mon Mar 11 11:49:07 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 11 Mar 2019 11:49:07 +0000 (UTC) Subject: [master] f2357c88f Don't panic on worker pool failuers during H2:OU handshake Message-ID: <20190311114907.481E9A05C5@lists.varnish-cache.org> commit f2357c88fa396b3fe911e9f194527e1fbe0dd978 Author: Poul-Henning Kamp Date: Mon Mar 11 11:47:18 2019 +0000 Don't panic on worker pool failuers during H2:OU handshake Fixes #2937 diff --git a/bin/varnishd/http2/cache_http2_session.c b/bin/varnishd/http2/cache_http2_session.c index 671d4a01d..cbdda42c0 100644 --- a/bin/varnishd/http2/cache_http2_session.c +++ b/bin/varnishd/http2/cache_http2_session.c @@ -303,7 +303,7 @@ h2_ou_session(struct worker *wrk, struct h2_sess *h2, r2->scheduled = 0; h2_del_req(wrk, r2); VSLb(h2->vsl, SLT_Debug, "H2: No Worker-threads"); - return (h2_ou_rel(wrk, req)); + return (0); } return (1); } diff --git a/bin/varnishtest/tests/r02937.vtc b/bin/varnishtest/tests/r02937.vtc new file mode 100644 index 000000000..8a2d00d58 --- /dev/null +++ b/bin/varnishtest/tests/r02937.vtc @@ -0,0 +1,25 @@ +varnishtest "#2937: Panic on OU pool failure" + +server s1 { + rxreq + txresp +} -start + +varnish v1 -vcl+backend {} -start + +varnish v1 -cliok "param.set feature +http2" +varnish v1 -cliok "debug.reqpool.fail F" + +client c1 { + send "GET / HTTP/1.1\r\n" + send "Host: foo\r\n" + send "Upgrade: h2c\r\n" + send "HTTP2-Settings: AAMAAABkAAQAAP__\r\n" + send "\r\n" + rxresp + expect resp.status == 101 + expect resp.http.upgrade == h2c + expect resp.http.connection == Upgrade + txpri + expect_close +} -run From phk at FreeBSD.org Mon Mar 11 11:49:07 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 11 Mar 2019 11:49:07 +0000 (UTC) Subject: [master] 6549d73d7 Whitespace OCD Message-ID: <20190311114907.6C3E6A05CA@lists.varnish-cache.org> commit 6549d73d7548314d5a60e354ea0e0619fc2a7076 Author: Poul-Henning Kamp Date: Mon Mar 11 11:47:43 2019 +0000 Whitespace OCD diff --git a/bin/varnishd/cache/cache_wrk.c b/bin/varnishd/cache/cache_wrk.c index ffa63deba..ce450584e 100644 --- a/bin/varnishd/cache/cache_wrk.c +++ b/bin/varnishd/cache/cache_wrk.c @@ -634,8 +634,8 @@ debug_reqpoolfail(struct cli *cli, const char * const *av, void *priv) uintmax_t u = 1; const char *p; - (void)priv; - (void)cli; + (void)priv; + (void)cli; reqpoolfail = 0; for (p = av[2]; *p != '\0'; p++) { if (*p == 'F' || *p == 'f') @@ -657,6 +657,6 @@ void WRK_Init(void) { - CLI_AddFuncs(debug_cmds); + CLI_AddFuncs(debug_cmds); } diff --git a/bin/varnishtest/tests/r02934.vtc b/bin/varnishtest/tests/r02934.vtc index ac607b667..923baf47c 100644 --- a/bin/varnishtest/tests/r02934.vtc +++ b/bin/varnishtest/tests/r02934.vtc @@ -3,7 +3,7 @@ varnishtest "Bug in CONTINUATION flags when no sendbody" server s1 { rxreq expect req.proto == HTTP/1.1 - txresp -hdr "Content-Type: text/plain" -hdrlen Foo 100 + txresp -hdr "Content-Type: text/plain" -hdrlen Foo 100 } -start @@ -19,7 +19,7 @@ client c1 { rxsettings } -run stream 1 { - txreq -req HEAD + txreq -req HEAD rxresp expect resp.status == 200 expect resp.http.content-Type == "text/plain" From geoff at uplex.de Mon Mar 11 12:00:14 2019 From: geoff at uplex.de (Geoff Simmons) Date: Mon, 11 Mar 2019 12:00:14 +0000 (UTC) Subject: [master] b7914209a Minor polish in the statement about cache optimization in "Changes". Message-ID: <20190311120014.A63DDA0E38@lists.varnish-cache.org> commit b7914209a4d7a004491455a7f4ea0107ebdaeaa7 Author: Geoff Simmons Date: Mon Mar 11 12:58:38 2019 +0100 Minor polish in the statement about cache optimization in "Changes". diff --git a/doc/sphinx/whats-new/changes-trunk.rst b/doc/sphinx/whats-new/changes-trunk.rst index c1fdb270e..bfbe962da 100644 --- a/doc/sphinx/whats-new/changes-trunk.rst +++ b/doc/sphinx/whats-new/changes-trunk.rst @@ -20,9 +20,10 @@ merged, may be found in the `change log`_. varnishd ======== -Cache lookups have undergone a number of optimizations, among them to -reduce lock contention, and to shorten and simplify the critical -section of lookup code. +Cache lookups have undergone a number of optimizations, among them +reduction in lock contention, and to shorten and simplify the critical +section of lookup code. We expect that this will improve performance +and scalability. We have added a "watchdog" for thread pools that will panic the worker process, causing it to restart, if scheduling tasks onto worker From nils.goroll at uplex.de Mon Mar 11 12:46:07 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 11 Mar 2019 12:46:07 +0000 (UTC) Subject: [master] ebb79ec63 clarify vmod std changes Message-ID: <20190311124607.91237A1EB7@lists.varnish-cache.org> commit ebb79ec634cf47ee7df524c1e7ecf10eff6dec29 Author: Nils Goroll Date: Mon Mar 11 13:45:21 2019 +0100 clarify vmod std changes diff --git a/doc/sphinx/whats-new/changes-trunk.rst b/doc/sphinx/whats-new/changes-trunk.rst index bfbe962da..367ce952e 100644 --- a/doc/sphinx/whats-new/changes-trunk.rst +++ b/doc/sphinx/whats-new/changes-trunk.rst @@ -77,8 +77,9 @@ changed the ``builtin.vcl``. See VMODs ===== -New type-conversion functions have been added to :ref:`vmod_std(3)`, -and the previous conversion functions are now deprecated. See +The type-conversion functions in :ref:`vmod_std(3)` have been reworked +to make them more flexible and easier to use. The ``std.``\ *x2y* +conversion functions are now deprecated. See :ref:`whatsnew_upgrading_std_conversion_2019_03`. The function :ref:`vmod_directors.lookup` has been added to From geoff at uplex.de Mon Mar 11 13:35:08 2019 From: geoff at uplex.de (Geoff Simmons) Date: Mon, 11 Mar 2019 13:35:08 +0000 (UTC) Subject: [master] e9511356f $NEXT_RELEASE for March 2019 is now 6.2 in the release docs. Message-ID: <20190311133508.6D18AA2FE3@lists.varnish-cache.org> commit e9511356fcadd979fa81090e35f0a70cd254dcc1 Author: Geoff Simmons Date: Mon Mar 11 14:34:07 2019 +0100 $NEXT_RELEASE for March 2019 is now 6.2 in the release docs. diff --git a/doc/sphinx/whats-new/changes-trunk.rst b/doc/sphinx/whats-new/changes-trunk.rst index 367ce952e..7992f6c51 100644 --- a/doc/sphinx/whats-new/changes-trunk.rst +++ b/doc/sphinx/whats-new/changes-trunk.rst @@ -4,9 +4,9 @@ released versions of Varnish, see:** :ref:`whats-new-index` .. _whatsnew_changes_2019_03: -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -Changes in Varnish **$NEXT_RELEASE** -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%% +Changes in Varnish 6.2 +%%%%%%%%%%%%%%%%%%%%%% For information about updating your current Varnish deployment to the new version, see :ref:`whatsnew_upgrading_2019_03`. diff --git a/doc/sphinx/whats-new/index.rst b/doc/sphinx/whats-new/index.rst index f98c16e40..315f71032 100644 --- a/doc/sphinx/whats-new/index.rst +++ b/doc/sphinx/whats-new/index.rst @@ -8,8 +8,8 @@ This section describes the changes and improvements between different versions of Varnish, and what upgrading between the different versions entail. -Varnish **$NEXT_RELEASE** -------------------------- +Varnish 6.2 +----------- **Note: These are working documents for a future release, with running updates for changes in the development branch. For changes in the diff --git a/doc/sphinx/whats-new/upgrading-trunk.rst b/doc/sphinx/whats-new/upgrading-trunk.rst index 9ccd3fb02..a7fa5efad 100644 --- a/doc/sphinx/whats-new/upgrading-trunk.rst +++ b/doc/sphinx/whats-new/upgrading-trunk.rst @@ -4,9 +4,9 @@ released versions of Varnish, see:** :ref:`whats-new-index` .. _whatsnew_upgrading_2019_03: -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -Upgrading to Varnish **$NEXT_RELEASE** -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%% +Upgrading to Varnish 6.2 +%%%%%%%%%%%%%%%%%%%%%%%% **XXX: how to upgrade from previous deployments to this version. Limited to work that has to be done for an upgrade, new From geoff at uplex.de Mon Mar 11 13:39:06 2019 From: geoff at uplex.de (Geoff Simmons) Date: Mon, 11 Mar 2019 13:39:06 +0000 (UTC) Subject: [master] 968dce902 Polish for clarity about std conversion functions in "Changes". Message-ID: <20190311133906.B55BFA3300@lists.varnish-cache.org> commit 968dce902f6e1e7196a342a32c0a0f71f7822d0c Author: Geoff Simmons Date: Mon Mar 11 14:38:12 2019 +0100 Polish for clarity about std conversion functions in "Changes". diff --git a/doc/sphinx/whats-new/upgrading-trunk.rst b/doc/sphinx/whats-new/upgrading-trunk.rst index a7fa5efad..b00cf8956 100644 --- a/doc/sphinx/whats-new/upgrading-trunk.rst +++ b/doc/sphinx/whats-new/upgrading-trunk.rst @@ -74,9 +74,9 @@ now. These are: Type conversion functions in VMOD std ===================================== -The type-conversion functions in :ref:`vmod_std(3)` have been reworked -to make them more flexible and easier to use. These new functions now -also accept suitable numeral or quantitative arguments. +There are new type-conversion functions in :ref:`vmod_std(3)`, +reworked to make them more flexible and easier to use. These new +functions now also accept suitable numeral or quantitative arguments. * :ref:`vmod_std.duration` * :ref:`vmod_std.bytes` @@ -98,8 +98,8 @@ but the following differences should be noted: * :ref:`vmod_std.round` has been added for explicit rounding. -These functions are deprecated and should be replaced by the new -conversion functions: +The following functions are deprecated and should be replaced by the +new conversion functions: * :ref:`vmod_std.real2integer` * :ref:`vmod_std.real2time` From nils.goroll at uplex.de Mon Mar 11 13:51:09 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 11 Mar 2019 13:51:09 +0000 (UTC) Subject: [master] 9e048812f rename the stack size canary Message-ID: <20190311135109.65B30A38B0@lists.varnish-cache.org> commit 9e048812f5b653acb15355a9eda1f662e03cd311 Author: Nils Goroll Date: Mon Mar 11 13:53:10 2019 +0100 rename the stack size canary Ref #2932 diff --git a/bin/varnishtest/tests/r02817.vtc b/bin/varnishtest/tests/v00004.vtc similarity index 100% rename from bin/varnishtest/tests/r02817.vtc rename to bin/varnishtest/tests/v00004.vtc From nils.goroll at uplex.de Mon Mar 11 13:51:09 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 11 Mar 2019 13:51:09 +0000 (UTC) Subject: [master] 84fce6656 stackspace canary: test with more realistic header sizes Message-ID: <20190311135109.7F7ADA38B3@lists.varnish-cache.org> commit 84fce6656d050838f23751b86a5e7f26a9b90b14 Author: Nils Goroll Date: Mon Mar 11 14:49:47 2019 +0100 stackspace canary: test with more realistic header sizes Closes #2932 diff --git a/bin/varnishtest/tests/v00004.vtc b/bin/varnishtest/tests/v00004.vtc index 4e9b1189f..ac42b64cc 100644 --- a/bin/varnishtest/tests/v00004.vtc +++ b/bin/varnishtest/tests/v00004.vtc @@ -5,7 +5,18 @@ varnishtest "canary to tell us if our default stacksize is too tight..." server s1 { rxreq expect req.http.esi0 == "foo" - txresp -gzipbody { + txresp \ + -hdr "Content-Type: text/html;charset=utf-8" \ + -hdr "Content-Language: en-US" \ + -hdr "X-UA-Compatible: IE=Edge" \ + -hdr "X-Content-Type-Options: nosniff" \ + -hdr "Content-Security-Policy-Report-Only: script-src 'unsafe-inline' 'unsafe-eval' 'self' blob: data: https:; style-src 'self' 'unsafe-inline' blob: data: https:; default-src 'self' https:; img-src https: blob: data: android-webview-video-poster:; frame-src blob: data: https:; worker-src blob: data: https:; child-src blob: data: https:; object-src 'self'; font-src 'self' https: blob: data: safari-extension://*; media-src 'self' blob: data: https:; connect-src wss: blob: data: https:; report-uri /csp_ep" \ + -hdr "Content-Security-Policy: upgrade-insecure-requests" \ + -hdr "Server: MySecretServerSauce" \ + -hdr "Cache-Control: public, max-age=90" \ + -hdr "Connection: keep-alive" \ + -hdr "Vary: Accept-Encoding, Origin" \ + -gzipbody { Before include @@ -16,7 +27,18 @@ server s1 { rxreq expect req.url == "/a1" expect req.http.esi0 != "foo" - txresp -gzipbody { + txresp \ + -hdr "Content-Type: text/html;charset=utf-8" \ + -hdr "Content-Language: en-US" \ + -hdr "X-UA-Compatible: IE=Edge" \ + -hdr "X-Content-Type-Options: nosniff" \ + -hdr "Content-Security-Policy-Report-Only: script-src 'unsafe-inline' 'unsafe-eval' 'self' blob: data: https:; style-src 'self' 'unsafe-inline' blob: data: https:; default-src 'self' https:; img-src https: blob: data: android-webview-video-poster:; frame-src blob: data: https:; worker-src blob: data: https:; child-src blob: data: https:; object-src 'self'; font-src 'self' https: blob: data: safari-extension://*; media-src 'self' blob: data: https:; connect-src wss: blob: data: https:; report-uri /csp_ep" \ + -hdr "Content-Security-Policy: upgrade-insecure-requests" \ + -hdr "Server: MySecretServerSauce" \ + -hdr "Cache-Control: public, max-age=90" \ + -hdr "Connection: keep-alive" \ + -hdr "Vary: Accept-Encoding, Origin" \ + -gzipbody { Before include @@ -27,7 +49,18 @@ server s1 { rxreq expect req.url == "/b2" expect req.http.esi0 != "foo" - txresp -gzipbody { + txresp \ + -hdr "Content-Type: text/html;charset=utf-8" \ + -hdr "Content-Language: en-US" \ + -hdr "X-UA-Compatible: IE=Edge" \ + -hdr "X-Content-Type-Options: nosniff" \ + -hdr "Content-Security-Policy-Report-Only: script-src 'unsafe-inline' 'unsafe-eval' 'self' blob: data: https:; style-src 'self' 'unsafe-inline' blob: data: https:; default-src 'self' https:; img-src https: blob: data: android-webview-video-poster:; frame-src blob: data: https:; worker-src blob: data: https:; child-src blob: data: https:; object-src 'self'; font-src 'self' https: blob: data: safari-extension://*; media-src 'self' blob: data: https:; connect-src wss: blob: data: https:; report-uri /csp_ep" \ + -hdr "Content-Security-Policy: upgrade-insecure-requests" \ + -hdr "Server: MySecretServerSauce" \ + -hdr "Cache-Control: public, max-age=90" \ + -hdr "Connection: keep-alive" \ + -hdr "Vary: Accept-Encoding, Origin" \ + -gzipbody { Before include @@ -38,7 +71,18 @@ server s1 { rxreq expect req.url == "/c3" expect req.http.esi0 != "foo" - txresp -gzipbody { + txresp \ + -hdr "Content-Type: text/html;charset=utf-8" \ + -hdr "Content-Language: en-US" \ + -hdr "X-UA-Compatible: IE=Edge" \ + -hdr "X-Content-Type-Options: nosniff" \ + -hdr "Content-Security-Policy-Report-Only: script-src 'unsafe-inline' 'unsafe-eval' 'self' blob: data: https:; style-src 'self' 'unsafe-inline' blob: data: https:; default-src 'self' https:; img-src https: blob: data: android-webview-video-poster:; frame-src blob: data: https:; worker-src blob: data: https:; child-src blob: data: https:; object-src 'self'; font-src 'self' https: blob: data: safari-extension://*; media-src 'self' blob: data: https:; connect-src wss: blob: data: https:; report-uri /csp_ep" \ + -hdr "Content-Security-Policy: upgrade-insecure-requests" \ + -hdr "Server: MySecretServerSauce" \ + -hdr "Cache-Control: public, max-age=90" \ + -hdr "Connection: keep-alive" \ + -hdr "Vary: Accept-Encoding, Origin" \ + -gzipbody { Before include @@ -49,7 +93,18 @@ server s1 { rxreq expect req.url == "/d4" expect req.http.esi0 != "foo" - txresp -gzipbody { + txresp \ + -hdr "Content-Type: text/html;charset=utf-8" \ + -hdr "Content-Language: en-US" \ + -hdr "X-UA-Compatible: IE=Edge" \ + -hdr "X-Content-Type-Options: nosniff" \ + -hdr "Content-Security-Policy-Report-Only: script-src 'unsafe-inline' 'unsafe-eval' 'self' blob: data: https:; style-src 'self' 'unsafe-inline' blob: data: https:; default-src 'self' https:; img-src https: blob: data: android-webview-video-poster:; frame-src blob: data: https:; worker-src blob: data: https:; child-src blob: data: https:; object-src 'self'; font-src 'self' https: blob: data: safari-extension://*; media-src 'self' blob: data: https:; connect-src wss: blob: data: https:; report-uri /csp_ep" \ + -hdr "Content-Security-Policy: upgrade-insecure-requests" \ + -hdr "Server: MySecretServerSauce" \ + -hdr "Cache-Control: public, max-age=90" \ + -hdr "Connection: keep-alive" \ + -hdr "Vary: Accept-Encoding, Origin" \ + -gzipbody { Before include @@ -60,7 +115,18 @@ server s1 { rxreq expect req.url == "/e5" expect req.http.esi0 != "foo" - txresp -gzipbody { + txresp \ + -hdr "Content-Type: text/html;charset=utf-8" \ + -hdr "Content-Language: en-US" \ + -hdr "X-UA-Compatible: IE=Edge" \ + -hdr "X-Content-Type-Options: nosniff" \ + -hdr "Content-Security-Policy-Report-Only: script-src 'unsafe-inline' 'unsafe-eval' 'self' blob: data: https:; style-src 'self' 'unsafe-inline' blob: data: https:; default-src 'self' https:; img-src https: blob: data: android-webview-video-poster:; frame-src blob: data: https:; worker-src blob: data: https:; child-src blob: data: https:; object-src 'self'; font-src 'self' https: blob: data: safari-extension://*; media-src 'self' blob: data: https:; connect-src wss: blob: data: https:; report-uri /csp_ep" \ + -hdr "Content-Security-Policy: upgrade-insecure-requests" \ + -hdr "Server: MySecretServerSauce" \ + -hdr "Cache-Control: public, max-age=90" \ + -hdr "Connection: keep-alive" \ + -hdr "Vary: Accept-Encoding, Origin" \ + -gzipbody { LAST @@ -82,7 +148,7 @@ varnish v1 -vcl+backend { sub recv8 { call recv9; std.log("STK recv8 " + debug.stk()); } sub recv9 { std.log("STK recv9 " + debug.stk()); - set req.http.regex = regsub(req.url, "(.*)", "\1\1\1\1\1\1\1\1"); + set req.http.regex = regsub(req.http.cookie, "(.*)", "\1\1\1\1\1\1\1\1"); set req.http.regex = regsub(req.http.regex, "(.*)", "\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1\1"); # hey geoff, this is deliberate @@ -111,7 +177,17 @@ varnish v1 -vcl+backend { varnish v1 -cliok "param.set debug +syncvsl" client c1 { - txreq -hdr "Host: foo" + txreq \ + -hdr "Host: foo" \ + -hdr "User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Firefox/60.0" \ + -hdr "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" \ + -hdr "Accept-Language: en-US,en;q=0.5" \ + -hdr "Accept-Encoding: gzip, deflate, br" \ + -hdr "Cookie: logged_in=yes; sess=vXgKJaOHR1I78w1WeTyH51EZSu1rhrC1aAINn+a4sVk/IMouksSSP0Mg4jzqhTMtdLilDo3t04fxRJP1ywB/loN9674CLOu2yzT996hUbzM8oza68yNzhSkkL4afQYOwLMJbtFvtY+lLHk3TJRHSS243HcYluLoo7qjmpiiUfx6JyIbRtl5xPPgVGkLgSA1Fu/yCXwfVCNhnLWHMSm1zd15CoroUCFDkuO0OponjseGPBzJ7NdFk2Fi5SJFZmhzHcBH/Ri/Uu5UeJwVAcJe9oPNuaWUR/Oy/D3nU81lOels8ypYJRmAAzO5r7RJ7KmIvjZhqxLG7cMViH/roegSgqxHsjXb/kSec2dmq1wQqSPYjxN/pIp8PefyM/IAho2h3WVKRDhYmAokhDIA8/UgMxaIyrWh1Ep6D16IU1uRMgx5Gjr6VJJ42GV23+OhfvlpdYoZxy7b9bwf7T3ABniF+VJOdMO5PTWfuG2Xt515FZ/byNpMYnMvWNGh4Ior8QyV2W0Nz4p0NJ5RWsnHYAoD3ySRC5E/cpu9RQsXdE1sVNDa7uMzgt0Bbnpk1ALeNN9JJ/l6zLATCKcvixty0Aonyi1nyG9LNL6+rtzsDOh7S5uDul67P2lXFUta1eY2Ma0e/JAHJcKgTqgFGCZJvsoFydnyu23AanhaPT4c3w3ZpGs0; evil_tracker=JcDDfXw14Efx4iLycPEDQaF8+Csci+cRHz0pwTm1JW9kvXyKlUcGVlpCw7qYZtORuNnVb3m6HOwJneFhAdDlw5FQbQh1YmX8ZBgKD51Fo8T0R/0a8W0suJ/mJrQ6H6MFjgZc8YE7vx8zt+nUPT0qfZ9TCSndA0EXLerIc6Cdu06wBPF0m2ydkMKIPn/R6pU+mVrn58RZrLdcbsrwm5mhSCM9RjDYqEMye9n7jhTbdyna+X+7S8XubJRXqWa9Zft2UuprU0wnUVUA6eFdqvaiAGoepQFjJjh13g0fp6+GJiNwfSJbjTi3GK2o9E9t8qfLr0Avzjj9rqPG2G5MBxZMjg" \ + -hdr "DNT: 1" \ + -hdr "Connection: keep-alive" \ + -hdr "Upgrade-Insecure-Requests: 1" \ + -hdr {If-None-Match: W/"9060a5e7924af13779c0437265ad2f1c} rxresp expect resp.status == 200 From nils.goroll at uplex.de Mon Mar 11 13:57:07 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 11 Mar 2019 13:57:07 +0000 (UTC) Subject: [master] 752277e62 fix semantics of the polishing Message-ID: <20190311135707.768FAA3D87@lists.varnish-cache.org> commit 752277e626fb37249229f4fe6af03a8c276939a5 Author: Nils Goroll Date: Mon Mar 11 14:55:56 2019 +0100 fix semantics of the polishing diff --git a/doc/sphinx/whats-new/upgrading-trunk.rst b/doc/sphinx/whats-new/upgrading-trunk.rst index b00cf8956..331e858b8 100644 --- a/doc/sphinx/whats-new/upgrading-trunk.rst +++ b/doc/sphinx/whats-new/upgrading-trunk.rst @@ -74,9 +74,9 @@ now. These are: Type conversion functions in VMOD std ===================================== -There are new type-conversion functions in :ref:`vmod_std(3)`, -reworked to make them more flexible and easier to use. These new -functions now also accept suitable numeral or quantitative arguments. +The existing type-conversion functions in :ref:`vmod_std(3)` have been +reworked to make them more flexible and easier to use. These functions +now also accept suitable numeral or quantitative arguments. * :ref:`vmod_std.duration` * :ref:`vmod_std.bytes` From nils.goroll at uplex.de Mon Mar 11 14:14:07 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 11 Mar 2019 14:14:07 +0000 (UTC) Subject: [master] 4a2c9e01c adjust description Message-ID: <20190311141407.139E3A44C0@lists.varnish-cache.org> commit 4a2c9e01c70cc138d767b5ecb3e7411e63a8f975 Author: Nils Goroll Date: Mon Mar 11 15:09:45 2019 +0100 adjust description Ref #2932 diff --git a/bin/varnishtest/tests/v00004.vtc b/bin/varnishtest/tests/v00004.vtc index ac42b64cc..5da5930f9 100644 --- a/bin/varnishtest/tests/v00004.vtc +++ b/bin/varnishtest/tests/v00004.vtc @@ -1,6 +1,10 @@ -varnishtest "canary to tell us if our default stacksize is too tight..." +varnishtest "test if our default paramers make sense ..." -# ... for the default esi level 5 and a stack of 10 VCL subs +# ... for our definition of a standard use case: +# - 2019 header madness +# - 5 ESI levels down +# - 10 VCL subs down +# - PCRE regsub server s1 { rxreq From nils.goroll at uplex.de Mon Mar 11 14:14:07 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 11 Mar 2019 14:14:07 +0000 (UTC) Subject: [master] 8be771d17 Increase 32bit workspace_backend by 4k for v00004.vtc to survive on 32bit Message-ID: <20190311141407.2DC25A44C3@lists.varnish-cache.org> commit 8be771d17aea9a82f453cabdfeac2ac0fc68a57c Author: Nils Goroll Date: Mon Mar 11 15:12:37 2019 +0100 Increase 32bit workspace_backend by 4k for v00004.vtc to survive on 32bit Ref #2932 diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c index 8e1653f85..1bc0cedb2 100644 --- a/bin/varnishd/mgt/mgt_param.c +++ b/bin/varnishd/mgt/mgt_param.c @@ -637,7 +637,7 @@ MCF_InitParams(struct cli *cli) * VM space. */ MCF_ParamConf(MCF_DEFAULT, "workspace_client", "24k"); - MCF_ParamConf(MCF_DEFAULT, "workspace_backend", "16k"); + MCF_ParamConf(MCF_DEFAULT, "workspace_backend", "20k"); MCF_ParamConf(MCF_DEFAULT, "http_resp_size", "8k"); MCF_ParamConf(MCF_DEFAULT, "http_req_size", "12k"); MCF_ParamConf(MCF_DEFAULT, "gzip_buffer", "4k"); From geoff at uplex.de Mon Mar 11 15:23:08 2019 From: geoff at uplex.de (Geoff Simmons) Date: Mon, 11 Mar 2019 15:23:08 +0000 (UTC) Subject: [master] 6502df904 Add discussion of thread_pool_stack and related issues to release docs. Message-ID: <20190311152308.8645AA5D44@lists.varnish-cache.org> commit 6502df9042978c8e8245051db59b639d80816e09 Author: Geoff Simmons Date: Mon Mar 11 16:21:47 2019 +0100 Add discussion of thread_pool_stack and related issues to release docs. diff --git a/doc/sphinx/whats-new/changes-trunk.rst b/doc/sphinx/whats-new/changes-trunk.rst index 7992f6c51..d21dec31a 100644 --- a/doc/sphinx/whats-new/changes-trunk.rst +++ b/doc/sphinx/whats-new/changes-trunk.rst @@ -34,9 +34,38 @@ should consider increasing the parameters :ref:`ref_param_thread_pool_min`, :ref:`ref_param_thread_pool_max` and/or :ref:`ref_param_thread_pools`. +.. _whatsnew_changes_params_2019_03: + Parameters ~~~~~~~~~~ +The default value for :ref:`ref_param_thread_pool_stack` on 64-bit +platforms has been increased to 56k (from 48k). Recently we had +occasional reports of stack overflow, apparently related to changes in +external libraries that are not under control of the Varnish project +(such as glibc). This may also have been related to stack overflow +issues on some platforms when recent versions of `jemalloc`_, the +recommended memory allocator for Varnish, have been used together with +`pcre`_ with JIT compilation enabled. + +Tests have shown that Varnish runs stably with the new default stack +size on a number of platforms, under conditions that previously may +have led to stack overflow -- such as ESI includes up to the default +limit of :ref:`ref_param_max_esi_depth`, relatively deep VCL +subroutine call depth, and recent jemalloc together with pcre-jit. + +Different sites have different requirements regarding the stack size. +For example, if your site uses a high depth of ESI includes, you are +probably already using an increased value of +:ref:`ref_param_thread_pool_stack`. If you don't have such +requirements, and you want to reduce memory footprint, you can +consider lowering :ref:`ref_param_thread_pool_stack`, but make sure to +test the result. + +.. _jemalloc: http://jemalloc.net/ + +.. _pcre: https://www.pcre.org/ + Some parameters that have been long deprecated are now retired. See :ref:`whatsnew_upgrading_params_2019_03` in :ref:`whatsnew_upgrading_2019_03`. diff --git a/doc/sphinx/whats-new/upgrading-trunk.rst b/doc/sphinx/whats-new/upgrading-trunk.rst index 331e858b8..59d49a34f 100644 --- a/doc/sphinx/whats-new/upgrading-trunk.rst +++ b/doc/sphinx/whats-new/upgrading-trunk.rst @@ -69,6 +69,11 @@ now. These are: * ``vmod_dir`` -- use :ref:`ref_param_vmod_path` instead +The default value of :ref:`ref_param_thread_pool_stack` on 64-bit +platforms has been increased to 56k (from 48k). See the discussion +under :ref:`whatsnew_changes_params_2019_03` in +:ref:`whatsnew_changes_2019_03` for details. + .. _whatsnew_upgrading_std_conversion_2019_03: Type conversion functions in VMOD std From nils.goroll at uplex.de Mon Mar 11 15:40:11 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 11 Mar 2019 15:40:11 +0000 (UTC) Subject: [master] c1c49ddb0 fix 32bit docs Message-ID: <20190311154011.55EF0A6425@lists.varnish-cache.org> commit c1c49ddb0652bcd14da09bb8441236635838b2a9 Author: Nils Goroll Date: Mon Mar 11 16:32:51 2019 +0100 fix 32bit docs Note: This does not consitute a change, we had just missed to document the values in use previously (except for workspace_backend which I will add to the release notes). diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c index 1bc0cedb2..c27df71f7 100644 --- a/bin/varnishd/mgt/mgt_param.c +++ b/bin/varnishd/mgt/mgt_param.c @@ -635,6 +635,8 @@ MCF_InitParams(struct cli *cli) /* * Adjust default parameters for 32 bit systems to conserve * VM space. + * + * Reflect changes in doc/sphinx/reference/varnishd.rst ! */ MCF_ParamConf(MCF_DEFAULT, "workspace_client", "24k"); MCF_ParamConf(MCF_DEFAULT, "workspace_backend", "20k"); diff --git a/doc/sphinx/reference/varnishd.rst b/doc/sphinx/reference/varnishd.rst index 9f6f8fb77..d13463f41 100644 --- a/doc/sphinx/reference/varnishd.rst +++ b/doc/sphinx/reference/varnishd.rst @@ -492,11 +492,13 @@ Default Value Exceptions on 32 bit Systems Be aware that on 32 bit systems, certain default values are reduced relative to the values listed below, in order to conserve VM space: -* workspace_client: 16k +* workspace_client: 24k +* workspace_backend: 20k * http_resp_size: 8k * http_req_size: 12k -* gzip_stack_buffer: 4k -* thread_pool_stack: 64k +* gzip_buffer: 4k +* vsl_space: 1G +* thread_pool_stack: 48k .. _List of Parameters: From nils.goroll at uplex.de Mon Mar 11 15:40:11 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 11 Mar 2019 15:40:11 +0000 (UTC) Subject: [master] d97817be3 doc 32bit workspace_backend bump Message-ID: <20190311154011.6A72EA6428@lists.varnish-cache.org> commit d97817be3992eadb4fc8ecd148c195502362782a Author: Nils Goroll Date: Mon Mar 11 16:36:55 2019 +0100 doc 32bit workspace_backend bump Ref 8be771d17aea9a82f453cabdfeac2ac0fc68a57c Ref #2932 diff --git a/doc/sphinx/whats-new/changes-trunk.rst b/doc/sphinx/whats-new/changes-trunk.rst index d21dec31a..e027faea1 100644 --- a/doc/sphinx/whats-new/changes-trunk.rst +++ b/doc/sphinx/whats-new/changes-trunk.rst @@ -77,6 +77,10 @@ the flag is turned on, C sources and shared object libraries that were generated from VCL sources are retained in the Varnish working directory (see the notes about ``varnishtest`` below). +For 32bit Platforms, we have increased the default +:ref:`ref_param_workspace_backend` from 16k to 20k accomodate larger +response headers have become common. + Other changes in varnishd ~~~~~~~~~~~~~~~~~~~~~~~~~ From nils.goroll at uplex.de Mon Mar 11 15:44:08 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 11 Mar 2019 15:44:08 +0000 (UTC) Subject: [master] 6f65045bd fix spelling/wording Message-ID: <20190311154408.6F967A67DD@lists.varnish-cache.org> commit 6f65045bd819e85c7244677b27e05d7e282fcb63 Author: Nils Goroll Date: Mon Mar 11 16:43:18 2019 +0100 fix spelling/wording diff --git a/doc/sphinx/whats-new/changes-trunk.rst b/doc/sphinx/whats-new/changes-trunk.rst index e027faea1..2501c937d 100644 --- a/doc/sphinx/whats-new/changes-trunk.rst +++ b/doc/sphinx/whats-new/changes-trunk.rst @@ -78,8 +78,8 @@ generated from VCL sources are retained in the Varnish working directory (see the notes about ``varnishtest`` below). For 32bit Platforms, we have increased the default -:ref:`ref_param_workspace_backend` from 16k to 20k accomodate larger -response headers have become common. +:ref:`ref_param_workspace_backend` from 16k to 20k accommodate larger +response headers which have become common. Other changes in varnishd ~~~~~~~~~~~~~~~~~~~~~~~~~ From dridi.boukelmoune at gmail.com Mon Mar 11 18:37:07 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 11 Mar 2019 18:37:07 +0000 (UTC) Subject: [master] 0945a8f41 Mention another source of stack increase Message-ID: <20190311183707.209E9A9D77@lists.varnish-cache.org> commit 0945a8f41bb567b01432f6a82e61f01a96ac39ba Author: Dridi Boukelmoune Date: Mon Mar 11 19:35:02 2019 +0100 Mention another source of stack increase diff --git a/doc/sphinx/whats-new/changes-trunk.rst b/doc/sphinx/whats-new/changes-trunk.rst index 2501c937d..56cf52bf3 100644 --- a/doc/sphinx/whats-new/changes-trunk.rst +++ b/doc/sphinx/whats-new/changes-trunk.rst @@ -46,7 +46,11 @@ external libraries that are not under control of the Varnish project (such as glibc). This may also have been related to stack overflow issues on some platforms when recent versions of `jemalloc`_, the recommended memory allocator for Varnish, have been used together with -`pcre`_ with JIT compilation enabled. +`pcre`_ with JIT compilation enabled. Compiler hardening flags may +also increase stack usage and on some systems such stack protector +flags may be enabled by default. With the addition of new mitigations +to new compiler releases, stack consumption may also increase on that +front. Tests have shown that Varnish runs stably with the new default stack size on a number of platforms, under conditions that previously may From geoff at uplex.de Mon Mar 11 20:48:07 2019 From: geoff at uplex.de (Geoff Simmons) Date: Mon, 11 Mar 2019 20:48:07 +0000 (UTC) Subject: [master] ab50d831b Rename the release doc source files for version 6.2. Message-ID: <20190311204807.2CE75AE5A3@lists.varnish-cache.org> commit ab50d831b2e3ded1947fe0d42905a55559d2d924 Author: Geoff Simmons Date: Mon Mar 11 21:47:13 2019 +0100 Rename the release doc source files for version 6.2. diff --git a/doc/sphinx/whats-new/changes-trunk.rst b/doc/sphinx/whats-new/changes-6.2.rst similarity index 100% rename from doc/sphinx/whats-new/changes-trunk.rst rename to doc/sphinx/whats-new/changes-6.2.rst diff --git a/doc/sphinx/whats-new/index.rst b/doc/sphinx/whats-new/index.rst index 315f71032..dbb145b44 100644 --- a/doc/sphinx/whats-new/index.rst +++ b/doc/sphinx/whats-new/index.rst @@ -18,8 +18,8 @@ released versions of Varnish, see the chapters listed below.** .. toctree:: :maxdepth: 2 - changes-trunk - upgrading-trunk + changes-6.2 + upgrading-6.2 Varnish 6.1 ----------- diff --git a/doc/sphinx/whats-new/upgrading-trunk.rst b/doc/sphinx/whats-new/upgrading-6.2.rst similarity index 100% rename from doc/sphinx/whats-new/upgrading-trunk.rst rename to doc/sphinx/whats-new/upgrading-6.2.rst From geoff at uplex.de Mon Mar 11 20:50:07 2019 From: geoff at uplex.de (Geoff Simmons) Date: Mon, 11 Mar 2019 20:50:07 +0000 (UTC) Subject: [master] 0318b1b0c Remove the XXX section from "Upgrading". Message-ID: <20190311205007.854D0AE78B@lists.varnish-cache.org> commit 0318b1b0c3152bf123c9fbf459c236f8faa45564 Author: Geoff Simmons Date: Mon Mar 11 21:48:47 2019 +0100 Remove the XXX section from "Upgrading". diff --git a/doc/sphinx/whats-new/upgrading-6.2.rst b/doc/sphinx/whats-new/upgrading-6.2.rst index 59d49a34f..758d18787 100644 --- a/doc/sphinx/whats-new/upgrading-6.2.rst +++ b/doc/sphinx/whats-new/upgrading-6.2.rst @@ -8,28 +8,6 @@ released versions of Varnish, see:** :ref:`whats-new-index` Upgrading to Varnish 6.2 %%%%%%%%%%%%%%%%%%%%%%%% -**XXX: how to upgrade from previous deployments to this -version. Limited to work that has to be done for an upgrade, new -features are listed in "Changes". Explicitly mention what does *not* -have to be changed, especially in VCL. May include, but is not limited -to:** - -* Elements of VCL that have been removed or are deprecated, or whose - semantics have changed. - -* -p parameters that have been removed or are deprecated, or whose - semantics have changed. - -* Changes in the CLI. - -* Changes in the output or interpretation of stats or the log, including - changes affecting varnishncsa/-hist/-top. - -* Changes that may be necessary in VTCs or in the use of varnishtest. - -* Changes in public APIs that may require changes in VMODs or VAPI/VUT - clients. - .. _whatsnew_upgrading_vcl_2019_03: VCL From phk at FreeBSD.org Tue Mar 12 08:01:07 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 12 Mar 2019 08:01:07 +0000 (UTC) Subject: [master] 740ee39c8 Detect the case where there is precisely zero bytes left in req->ws and return a 500 for that instead of panicing in VSB. Message-ID: <20190312080107.6E12863291@lists.varnish-cache.org> commit 740ee39c8d6ffd36631a136cb9be23cdb13893d0 Author: Poul-Henning Kamp Date: Tue Mar 12 08:00:05 2019 +0000 Detect the case where there is precisely zero bytes left in req->ws and return a 500 for that instead of panicing in VSB. Fixes #2938 diff --git a/bin/varnishd/http2/cache_http2_deliver.c b/bin/varnishd/http2/cache_http2_deliver.c index 20609e8e7..7ee71ac99 100644 --- a/bin/varnishd/http2/cache_http2_deliver.c +++ b/bin/varnishd/http2/cache_http2_deliver.c @@ -214,36 +214,28 @@ static const uint8_t h2_500_resp[] = { 0x1f, 0x27, 0x07, 'V', 'a', 'r', 'n', 'i', 's', 'h', }; -void v_matchproto_(vtr_deliver_f) -h2_deliver(struct req *req, struct boc *boc, int sendbody) +static int +h2_build_headers(struct vsb *resp, struct req *req) { - ssize_t sz, sz1; unsigned u, l; - uint8_t buf[6]; - const char *r; - struct http *hp; - struct sess *sp; - struct h2_req *r2; - struct vsb resp; int i; + struct http *hp; + const char *r; const struct hpack_static *hps; + uint8_t buf[6]; + ssize_t sz, sz1; - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - CHECK_OBJ_ORNULL(boc, BOC_MAGIC); - CHECK_OBJ_NOTNULL(req->objcore, OBJCORE_MAGIC); - CAST_OBJ_NOTNULL(r2, req->transport_priv, H2_REQ_MAGIC); - 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)); + if (l < 10) + return (-1); + + AN(VSB_new(resp, req->ws->f, l, VSB_FIXEDLEN)); l = h2_status(buf, req->resp->status); - VSB_bcat(&resp, buf, l); + VSB_bcat(resp, buf, l); hp = req->resp; - for (u = HTTP_HDR_FIRST; u < hp->nhd && !VSB_error(&resp); u++) { + for (u = HTTP_HDR_FIRST; u < hp->nhd && !VSB_error(resp); u++) { r = strchr(hp->hd[u].b, ':'); AN(r); @@ -264,25 +256,46 @@ h2_deliver(struct req *req, struct boc *boc, int sendbody) VSLb(req->vsl, SLT_Debug, "HP {%d, \"%s\", \"%s\"} <%s>", hps->idx, hps->name, hps->val, hp->hd[u].b); - h2_enc_len(&resp, 4, hps->idx, 0x10); + h2_enc_len(resp, 4, hps->idx, 0x10); } else { - VSB_putc(&resp, 0x10); + VSB_putc(resp, 0x10); sz--; - h2_enc_len(&resp, 7, sz, 0); + h2_enc_len(resp, 7, sz, 0); for (sz1 = 0; sz1 < sz; sz1++) - VSB_putc(&resp, tolower(hp->hd[u].b[sz1])); + VSB_putc(resp, tolower(hp->hd[u].b[sz1])); } while (vct_islws(*++r)) continue; sz = hp->hd[u].e - r; - h2_enc_len(&resp, 7, sz, 0); - VSB_bcat(&resp, r, sz); + h2_enc_len(resp, 7, sz, 0); + VSB_bcat(resp, r, sz); } - if (VSB_finish(&resp)) { - WS_MarkOverflow(req->ws); + return (VSB_finish(resp)); +} + +void v_matchproto_(vtr_deliver_f) +h2_deliver(struct req *req, struct boc *boc, int sendbody) +{ + ssize_t sz; + const char *r; + struct sess *sp; + struct h2_req *r2; + struct vsb resp; + + CHECK_OBJ_NOTNULL(req, REQ_MAGIC); + CHECK_OBJ_ORNULL(boc, BOC_MAGIC); + CHECK_OBJ_NOTNULL(req->objcore, OBJCORE_MAGIC); + CAST_OBJ_NOTNULL(r2, req->transport_priv, H2_REQ_MAGIC); + sp = req->sp; + CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + + VSLb(req->vsl, SLT_RespProtocol, "HTTP/2.0"); + + if (h2_build_headers(&resp, req)) { // We ran out of workspace, return minimal 500 + WS_MarkOverflow(req->ws); VSLb(req->vsl, SLT_Error, "workspace_client overflow"); VSLb(req->vsl, SLT_RespStatus, "500"); VSLb(req->vsl, SLT_RespReason, "Internal Server Error"); From phk at FreeBSD.org Tue Mar 12 09:48:07 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 12 Mar 2019 09:48:07 +0000 (UTC) Subject: [master] cb1b5899b Silence an annoying flexelint message Message-ID: <20190312094807.A34F7654BA@lists.varnish-cache.org> commit cb1b5899b13f0240631f54794dd7c26660245cb0 Author: Poul-Henning Kamp Date: Tue Mar 12 09:21:29 2019 +0000 Silence an annoying flexelint message diff --git a/bin/varnishd/http2/cache_http2_session.c b/bin/varnishd/http2/cache_http2_session.c index cbdda42c0..efd560db6 100644 --- a/bin/varnishd/http2/cache_http2_session.c +++ b/bin/varnishd/http2/cache_http2_session.c @@ -52,21 +52,21 @@ static const char H2_prism[24] = { }; static size_t -h2_enc_settings(const struct h2_settings *h2s, uint8_t *buf, size_t n) +h2_enc_settings(const struct h2_settings *h2s, uint8_t *buf, ssize_t n) { - size_t len = 0; + uint8_t *p = buf; #define H2_SETTING(U,l,v,d,...) \ if (h2s->l != d) { \ - len += 6; \ - assert(len <= n); \ - vbe16enc(buf, v); \ - buf += 2; \ - vbe32enc(buf, h2s->l); \ - buf += 4; \ + n -= 6; \ + assert(n >= 0); \ + vbe16enc(p, v); \ + p += 2; \ + vbe32enc(p, h2s->l); \ + p += 4; \ } #include "tbl/h2_settings.h" - return (len); + return (p - buf); } static const struct h2_settings H2_proto_settings = { From phk at FreeBSD.org Tue Mar 12 09:48:07 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 12 Mar 2019 09:48:07 +0000 (UTC) Subject: [master] 21ee39a55 Try to bring some kind of order to this Message-ID: <20190312094807.BCCA6654BD@lists.varnish-cache.org> commit 21ee39a55257beb0c10b3c393acbc1f8252072fa Author: Poul-Henning Kamp Date: Tue Mar 12 09:21:50 2019 +0000 Try to bring some kind of order to this diff --git a/lib/libvmod_std/vmod.vcc b/lib/libvmod_std/vmod.vcc index bf2396c21..f2597f5cc 100644 --- a/lib/libvmod_std/vmod.vcc +++ b/lib/libvmod_std/vmod.vcc @@ -38,14 +38,51 @@ DESCRIPTION *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:: +Numeric functions +================= - TYPE type(STRING, TYPE) +$Function REAL random(REAL lo, REAL hi) + +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 REAL round(REAL r) + +Rounds the real *r* to the nearest integer, but round halfway cases +away from zero (see `round(3)`). + + +String functions +================ + +$Function VOID collect(HEADER hdr, STRING sep=", ") + +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. -These functions attempt to convert *STRING* to the *TYPE*, and if that -fails, they return the second argument, which must have the given -*TYPE*. +Examples:: + + std.collect(req.http.accept); + std.collect(req.http.cookie, "; "); + +$Function STRING querysort(STRING) + +Sorts the query string for cache normalization purposes. + +Example:: + + set req.url = std.querysort(req.url); $Function STRING toupper(STRING_LIST s) @@ -63,57 +100,88 @@ Example:: set beresp.http.nice = std.tolower("VerY"); -$Function VOID set_ip_tos(INT tos) +$Function STRING strstr(STRING s1, STRING s2) -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. +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. -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. +Note that the comparison is case sensitive. Example:: - if (req.url ~ "^/slow/") { - std.set_ip_tos(0); + if (std.strstr(req.url, req.http.restrict)) { + ... } -$Function REAL random(REAL lo, REAL hi) +This will check if the content of ``req.http.restrict`` occurs +anywhere in ``req.url``. -Returns a random real number between *lo* and *hi*. +$Function BOOL fnmatch(STRING pattern, STRING subject, BOOL pathname=1, + BOOL noescape=0, BOOL period=0) -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. +Shell-style pattern matching; returns ``true`` if *subject* matches +*pattern*, where *pattern* may contain wildcard characters such as ``*`` +or ``?``. -Example:: +The match is executed by the implementation of `fnmatch(3)` on your +system. The rules for pattern matching on most systems include the +following: - set beresp.http.random-number = std.random(1, 100); +* ``*`` matches any sequence of characters -$Function VOID log(STRING_LIST s) +* ``?`` matches a single character -Logs the string *s* to the shared memory log, using :ref:`vsl(7)` tag -``SLT_VCL_Log``. +* 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 ``^``. -Example:: +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``. - std.log("Something fishy is going on with the vhost " + req.http.host); +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``. -$Function VOID syslog(INT priority, STRING_LIST s) +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``. -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. +`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. -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. +Examples:: -Example:: + # Matches URLs such as /foo/bar and /foo/baz + if (std.fnmatch("/foo/\*", req.url)) { ... } - std.syslog(9, "Something is wrong"); + # Matches URLs such as /foo/bar/baz and /foo/baz/quux + if (std.fnmatch("/foo/\*/\*", bereq.url)) { ... } -This will send a message to syslog using ``LOG_USER | LOG_ALERT``. + # 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)) { ... } + + +File(system) functions +====================== $Function STRING fileread(PRIV_CALL, STRING) @@ -143,19 +211,32 @@ Example:: return (synth(503, "Varnish is in maintenance")); } -$Function VOID collect(HEADER hdr, STRING sep=", ") -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. +Type Inspection functions +========================= -Care should be taken when collapsing headers. In particular collapsing -``Set-Cookie`` will lead to unexpected results on the browser side. +$Function BOOL healthy(BACKEND be) -Examples:: +Returns ``true`` if the backend *be* is healthy. - std.collect(req.http.accept); - std.collect(req.http.cookie, "; "); +$Function INT port(IP ip) + +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. + +Type Conversion functions +========================= + +These functions all have the same form:: + + TYPE type([arguments], [fallback TYPE]) + +Precisely one of the arguments must be provided, and it will be +converted to *TYPE*. + +If conversion fails, *fallback* will be returned and if no +fallback was specified, the VCL will be failed. $Function DURATION duration([STRING s], [DURATION fallback], [REAL real], [INT integer]) @@ -295,93 +376,62 @@ Example:: ... } -$Function REAL round(REAL r) +$Function TIME time([STRING s], [TIME fallback], [REAL real], [INT integer]) -Rounds the real *r* to the nearest integer, but round halfway cases -away from zero (see `round(3)`). +Returns a TIME from a STRING, REAL or INT argument. -$Function INT real2integer(REAL r, INT fallback) +For a STRING *s* argument, the following formats are supported:: -**DEPRECATED**: This function will be removed in a future version of -varnish, use `vmod_std.integer`_ with a *real* argument and the -`vmod_std.round`_ function instead, for example:: + "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" - std.integer(real=std.round(...), fallback=...) +*real* and *integer* arguments are taken as seconds since the epoch. -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. +If the conversion of an *s* argument fails or a negative *real* or +*integer* argument is given, *fallback* will be returned if provided, +or a VCL failure will be triggered. 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) - -**DEPRECATED**: This function will be removed in a future version of -varnish, use `vmod_std.time`_ with a *real* argument and the -`vmod_std.round`_ function instead, for example:: - - std.time(real=std.round(...), fallback=...) - -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); + if (std.time(resp.http.last-modified, now) < now - 1w) { + ... + } -$Function INT time2integer(TIME t, INT fallback) + if (std.time(int=2147483647) < now - 1w) { + ... + } -**DEPRECATED**: This function will be removed in a future version of -varnish, use `vmod_std.integer`_ with a *time* argument instead, for -example:: +LOGGING functions +================= - std.integer(time=..., fallback=...) +$Function VOID log(STRING_LIST s) -Converts the time *t* to a integer. If conversion fails, -*fallback* will be returned. +Logs the string *s* to the shared memory log, using :ref:`vsl(7)` tag +``SLT_VCL_Log``. Example:: - set req.http.int = std.time2integer(now, 0); - -$Function REAL time2real(TIME t, REAL fallback) + std.log("Something fishy is going on with the vhost " + req.http.host); -**DEPRECATED**: This function will be removed in a future version of -varnish, use `vmod_std.real`_ with a *time* argument instead, for -example:: +$Function VOID syslog(INT priority, STRING_LIST s) - std.real(time=..., fallback=...) +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. -Converts the time *t* to a real. If conversion fails, *fallback* will -be returned. +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:: - set req.http.real = std.time2real(now, 1.0); - -$Function BOOL healthy(BACKEND be) - -Returns ``true`` if the backend *be* is healthy. - -$Function INT port(IP ip) - -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) - -Restores the *h* HTTP headers to their original state. - -Example:: + std.syslog(9, "Something is wrong"); - std.rollback(bereq); +This will send a message to syslog using ``LOG_USER | LOG_ALERT``. $Function VOID timestamp(STRING s) @@ -394,13 +444,22 @@ Example:: std.timestamp("curl-request"); -$Function STRING querysort(STRING) -Sorts the query string for cache normalization purposes. +CONTROL and INFORMATION functions +================================= + +$Function BOOL syntax(REAL) + +Returns ``true`` if VCL version is at least *REAL*. + +$Function STRING getenv(STRING name) + +Return environment variable *name* or the empty string. See `getenv(3)`. Example:: - set req.url = std.querysort(req.url); + set req.http.My-Env = std.getenv("MY_ENV"); + $Function BOOL cache_req_body(BYTES size) @@ -417,59 +476,6 @@ Example:: ... } -$Function STRING strstr(STRING s1, STRING s2) - -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)) { - ... - } - -This will check if the content of ``req.http.restrict`` occurs -anywhere in ``req.url``. - -$Function TIME time([STRING s], [TIME fallback], [REAL real], [INT integer]) - -Returns a TIME from a STRING, REAL or INT argument. - -For a STRING *s* argument, the following formats are supported:: - - "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" - -*real* and *integer* arguments are taken as seconds since the epoch. - -If the conversion of an *s* argument fails or a negative *real* or -*integer* argument is given, *fallback* will be returned if provided, -or a VCL failure will be triggered. - -Examples:: - - if (std.time(resp.http.last-modified, now) < now - 1w) { - ... - } - - if (std.time(int=2147483647) < now - 1w) { - ... - } - -$Function STRING getenv(STRING name) - -Return environment variable *name* or the empty string. See `getenv(3)`. - -Example:: - - set req.http.My-Env = std.getenv("MY_ENV"); - $Function VOID late_100_continue(BOOL late) Controls when varnish reacts to an ``Expect: 100-continue`` client @@ -504,72 +510,98 @@ Example:: ... } -$Function BOOL syntax(REAL) +$Function VOID set_ip_tos(INT tos) -Returns ``true`` if VCL version is at least *REAL*. +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. -$Function BOOL fnmatch(STRING pattern, STRING subject, BOOL pathname=1, - BOOL noescape=0, BOOL period=0) +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. -Shell-style pattern matching; returns ``true`` if *subject* matches -*pattern*, where *pattern* may contain wildcard characters such as ``*`` -or ``?``. +Example:: -The match is executed by the implementation of `fnmatch(3)` on your -system. The rules for pattern matching on most systems include the -following: + if (req.url ~ "^/slow/") { + std.set_ip_tos(0); + } -* ``*`` matches any sequence of characters +$Function VOID rollback(HTTP h) -* ``?`` matches a single character +Restores the *h* HTTP headers to their original state. -* 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 ``^``. +Example:: -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``. + std.rollback(bereq); -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``. +DEPRECATED functions +==================== -`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. +$Function INT real2integer(REAL r, INT fallback) + +**DEPRECATED**: This function will be removed in a future version of +varnish, use `vmod_std.integer`_ with a *real* argument and the +`vmod_std.round`_ function instead, for example:: + + std.integer(real=std.round(...), fallback=...) + +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:: - # Matches URLs such as /foo/bar and /foo/baz - if (std.fnmatch("/foo/\*", req.url)) { ... } + 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 - # Matches URLs such as /foo/bar/baz and /foo/baz/quux - if (std.fnmatch("/foo/\*/\*", bereq.url)) { ... } +$Function TIME real2time(REAL r, TIME fallback) - # Matches /foo/bar/quux, but not /foo/bar/baz/quux - if (std.fnmatch("/foo/\*/quux", req.url)) { ... } +**DEPRECATED**: This function will be removed in a future version of +varnish, use `vmod_std.time`_ with a *real* argument and the +`vmod_std.round`_ function instead, for example:: - # Matches /foo/bar/quux and /foo/bar/baz/quux - if (std.fnmatch("/foo/\*/quux", req.url, pathname=false)) { ... } + std.time(real=std.round(...), fallback=...) - # Matches /foo/bar, /foo/car and /foo/far - if (std.fnmatch("/foo/?ar", req.url)) { ... } +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) + +**DEPRECATED**: This function will be removed in a future version of +varnish, use `vmod_std.integer`_ with a *time* argument instead, for +example:: + + std.integer(time=..., fallback=...) + +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) + +**DEPRECATED**: This function will be removed in a future version of +varnish, use `vmod_std.real`_ with a *time* argument instead, for +example:: + + std.real(time=..., fallback=...) + +Converts the time *t* to a real. If conversion fails, *fallback* will +be returned. + +Example:: + + set req.http.real = std.time2real(now, 1.0); - # Matches /foo/ followed by a non-digit - if (std.fnmatch("/foo/[!0-9]", req.url)) { ... } SEE ALSO From phk at FreeBSD.org Tue Mar 12 09:48:07 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 12 Mar 2019 09:48:07 +0000 (UTC) Subject: [master] 6e062834f Stylistic overhaul Message-ID: <20190312094807.D9A8A654C1@lists.varnish-cache.org> commit 6e062834fbf261759b5edcf7c1aa0c505beb87c1 Author: Poul-Henning Kamp Date: Tue Mar 12 09:23:03 2019 +0000 Stylistic overhaul diff --git a/include/vrt.h b/include/vrt.h index 0d4b339a3..cbbfd533a 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -53,6 +53,7 @@ * * * 9.0 (scheduled for 2019-03-15) + * Remove VCL_{INT|BYTES}_{MIN|MAX} macros * Make 'len' in vmod_priv 'long' * HTTP_Copy() removed * HTTP_Dup() added @@ -213,21 +214,6 @@ 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 c20402b1c..e7a2172f0 100644 --- a/lib/libvmod_std/vmod_std_conversions.c +++ b/lib/libvmod_std/vmod_std_conversions.c @@ -30,7 +30,6 @@ #include "config.h" #include -#include #include #include #include @@ -44,7 +43,22 @@ #include "vtim.h" #include "vcc_if.h" -static inline int onearg(VRT_CTX, const char *f, int nargs) +/* + * 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 + +static +int onearg(VRT_CTX, const char *f, int nargs) { if (nargs == 1) return (1); @@ -68,20 +82,20 @@ vmod_duration(VRT_CTX, struct VARGS(duration) *a) nargs = a->valid_s + a->valid_real + a->valid_integer; - if (! onearg(ctx, "duration", nargs)) + if (!onearg(ctx, "duration", nargs)) return (0); if (a->valid_real) return ((VCL_DURATION)a->real); + if (a->valid_integer) return ((VCL_DURATION)a->integer); - assert(a->valid_s); - - r = VNUM_duration(a->s); - - if (! isnan(r)) - return (r); + if (a->valid_s) { + r = VNUM_duration(a->s); + if (!isnan(r)) + return (r); + } if (a->valid_fallback) return (a->fallback); @@ -94,7 +108,6 @@ VCL_BYTES v_matchproto_(td_std_bytes) vmod_bytes(VRT_CTX, struct VARGS(bytes) *a) { uintmax_t r; - VCL_BYTES b; VCL_REAL rr; int nargs; @@ -102,26 +115,22 @@ vmod_bytes(VRT_CTX, struct VARGS(bytes) *a) nargs = a->valid_s + a->valid_real + a->valid_integer; - if (! onearg(ctx, "bytes", nargs)) + if (!onearg(ctx, "bytes", nargs)) return (0); - b = -1; - if (a->valid_s) { - if (VNUM_2bytes(a->s, &r, 0) == NULL && - r <= VCL_BYTES_MAX) - b = (VCL_BYTES)r; - } else if (a->valid_real) { + if (a->valid_s && + VNUM_2bytes(a->s, &r, 0) == NULL && + r <= VCL_BYTES_MAX) + return((VCL_BYTES)r); + + if (a->valid_real) { rr = trunc(a->real); if (rr <= (VCL_REAL)VCL_BYTES_MAX) - b = (VCL_BYTES)rr; - } else if (a->valid_integer) { - b = (VCL_BYTES)a->integer; - } else { - INCOMPL(); + return((VCL_BYTES)rr); } - if (b >= 0) - return (b); + if (a->valid_integer) + return((VCL_BYTES)a->integer); if (a->valid_fallback) return (a->fallback); @@ -142,31 +151,32 @@ vmod_integer(VRT_CTX, struct VARGS(integer) *a) nargs = a->valid_s + a->valid_bool + a->valid_bytes + a->valid_duration + a->valid_real + a->valid_time; - if (! onearg(ctx, "integer", nargs)) + if (!onearg(ctx, "integer", nargs)) return (0); r = NAN; - if (a->valid_bool) { - return (!! a->bool); - } else if (a->valid_bytes) { + if (a->valid_bool) + return (a->bool ? 1 : 0); + + if (a->valid_bytes) return (a->bytes); - } else if (a->valid_s) { - if (a->s) { - r = VNUMpfx(a->s, &e); - if (e != NULL) - r = NAN; - } - } else if (a->valid_duration) { + + if (a->valid_s && a->s != NULL) { + r = VNUMpfx(a->s, &e); + if (e != NULL) + r = NAN; + } + + if (a->valid_duration) r = a->duration; - } else if (a->valid_real) { + + if (a->valid_real) r = a->real; - } else if (a->valid_time) { + + if (a->valid_time) r = a->time; - } else { - INCOMPL(); - } - if (! isnan(r)) { + if (!isnan(r)) { r = trunc(r); if (r >= VCL_INT_MIN && r <= VCL_INT_MAX) return ((VCL_INT)r); @@ -180,7 +190,7 @@ vmod_integer(VRT_CTX, struct VARGS(integer) *a) } VCL_IP -vmod_ip(VRT_CTX, VCL_STRING s, VCL_IP d, VCL_BOOL n) +vmod_ip(VRT_CTX, VCL_STRING s, VCL_IP d, VCL_BOOL resolve) { struct addrinfo hints, *res0 = NULL; const struct addrinfo *res; @@ -204,7 +214,7 @@ vmod_ip(VRT_CTX, VCL_STRING s, VCL_IP d, VCL_BOOL n) memset(&hints, 0, sizeof(hints)); hints.ai_family = PF_UNSPEC; hints.ai_socktype = SOCK_STREAM; - if (!n) + if (!resolve) hints.ai_flags |= AI_NUMERICHOST; error = getaddrinfo(s, "80", &hints, &res0); if (!error) { @@ -235,28 +245,29 @@ vmod_real(VRT_CTX, struct VARGS(real) *a) nargs = a->valid_s + a->valid_integer + a->valid_bool + a->valid_bytes + a->valid_duration + a->valid_time; - if (! onearg(ctx, "real", nargs)) + if (!onearg(ctx, "real", nargs)) return (0); if (a->valid_integer) return ((VCL_REAL)a->integer); - else if (a->valid_bool) - return ((VCL_REAL)(!! a->bool)); - else if (a->valid_bytes) + + if (a->valid_bool) + return ((VCL_REAL)(a->bool ? 1 : 0)); + + if (a->valid_bytes) return ((VCL_REAL)a->bytes); - else if (a->valid_duration) + + if (a->valid_duration) return ((VCL_REAL)a->duration); - else if (a->valid_time) - return ((VCL_REAL)a->time); - assert(a->valid_s); + if (a->valid_time) + return ((VCL_REAL)a->time); - r = NAN; - if (a->s != NULL) + if (a->valid_s && a->s != NULL) { r = VNUM(a->s); - - if (!isnan(r)) - return (r); + if (!isnan(r)) + return (r); + } if (a->valid_fallback) return (a->fallback); @@ -272,6 +283,44 @@ vmod_round(VRT_CTX, VCL_REAL r) return (round(r)); } +VCL_TIME v_matchproto_(td_std_time) +vmod_time(VRT_CTX, struct VARGS(time)* a) +{ + double r; + int nargs; + + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + + nargs = a->valid_s + a->valid_real + a->valid_integer; + + if (!onearg(ctx, "time", nargs)) + return (0); + + if (a->valid_integer) + return ((VCL_REAL)a->integer); + + if (a->valid_real) + return ((VCL_REAL)a->real); + + if (a->valid_s && a->s != NULL) { + r = VTIM_parse(a->s); + if (r) + return (r); + + r = VNUM(a->s); + + if (!isnan(r) && r > 0) + return (r); + } + + if (a->valid_fallback) + return (a->fallback); + + VRT_fail(ctx, "std.time: conversion failed"); + return (0); +} + +/* These functions are deprecated as of 2019-03-15 release */ VCL_INT v_matchproto_(td_std_real2integer) vmod_real2integer(VRT_CTX, VCL_REAL r, VCL_INT i) @@ -321,40 +370,3 @@ vmod_time2real(VRT_CTX, VCL_TIME t, VCL_REAL r) return (t); } -VCL_TIME v_matchproto_(td_std_time) -vmod_time(VRT_CTX, struct VARGS(time)* a) -{ - double r; - int nargs; - - CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); - - nargs = a->valid_s + a->valid_real + a->valid_integer; - - if (! onearg(ctx, "time", nargs)) - return (0); - - if (a->valid_integer) - return ((VCL_REAL)a->integer); - else if (a->valid_real) - return ((VCL_REAL)a->real); - - assert(a->valid_s); - - if (a->s) { - r = VTIM_parse(a->s); - if (r) - return (r); - - r = VNUM(a->s); - - if (!isnan(r) && r > 0) - return (r); - } - - if (a->valid_fallback) - return (a->fallback); - - VRT_fail(ctx, "std.time: conversion failed"); - return (0); -} From phk at FreeBSD.org Tue Mar 12 09:51:07 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 12 Mar 2019 09:51:07 +0000 (UTC) Subject: [master] a3b26d0ba Make the fallback argument optional on std.ip Message-ID: <20190312095107.34C71659D3@lists.varnish-cache.org> commit a3b26d0ba7dd8763a4e34d9e18d92fc24f1c291c Author: Poul-Henning Kamp Date: Tue Mar 12 09:50:19 2019 +0000 Make the fallback argument optional on std.ip diff --git a/lib/libvmod_std/vmod.vcc b/lib/libvmod_std/vmod.vcc index f2597f5cc..3d45b8c59 100644 --- a/lib/libvmod_std/vmod.vcc +++ b/lib/libvmod_std/vmod.vcc @@ -328,15 +328,15 @@ Examples:: set resp.http.answer = std.integer(real=126.42/3); -$Function IP ip(STRING s, IP fallback, BOOL resolve = 1) +$Function IP ip(STRING s, [IP fallback], BOOL resolve = 1) Converts the string *s* to the first IP number returned by the system library function `getaddrinfo(3)`. If conversion -fails, *fallback* will be returned. +fails, *fallback* will be returned or VCL failure will happen. -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(3)` is called using ``AI_NUMERICHOST`` +to avoid network lookups. This makes "numerical" IP strings cheaper +to convert. Example:: diff --git a/lib/libvmod_std/vmod_std_conversions.c b/lib/libvmod_std/vmod_std_conversions.c index e7a2172f0..c89fa4e91 100644 --- a/lib/libvmod_std/vmod_std_conversions.c +++ b/lib/libvmod_std/vmod_std_conversions.c @@ -189,49 +189,62 @@ vmod_integer(VRT_CTX, struct VARGS(integer) *a) return (0); } -VCL_IP -vmod_ip(VRT_CTX, VCL_STRING s, VCL_IP d, VCL_BOOL resolve) +static VCL_IP +lookup(VCL_IP *p, const char *s, int resolve) { struct addrinfo hints, *res0 = NULL; const struct addrinfo *res; int error; + VCL_IP retval = NULL; + + if (s == NULL) + return (retval); + + memset(&hints, 0, sizeof(hints)); + hints.ai_family = PF_UNSPEC; + hints.ai_socktype = SOCK_STREAM; + if (!resolve) + hints.ai_flags |= AI_NUMERICHOST; + error = getaddrinfo(s, "80", &hints, &res0); + if (!error) { + for (res = res0; res != NULL; res = res->ai_next) { + retval = VSA_Build(p, res->ai_addr, res->ai_addrlen); + if (retval != NULL) + break; + } + freeaddrinfo(res0); + } + return (retval); +} + +VCL_IP +vmod_ip(VRT_CTX, struct VARGS(ip) *a) +{ void *p; - const struct suckaddr *r; + VCL_IP retval; CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); - AN(d); - assert(VSA_Sane(d)); + if (a->valid_fallback) + assert(VSA_Sane(a->fallback)); p = WS_Alloc(ctx->ws, vsa_suckaddr_len); if (p == NULL) { VSLb(ctx->vsl, SLT_VCL_Error, "vmod std.ip(): insufficient workspace"); - return (d); - } - r = NULL; - - if (s != NULL) { - memset(&hints, 0, sizeof(hints)); - hints.ai_family = PF_UNSPEC; - hints.ai_socktype = SOCK_STREAM; - if (!resolve) - hints.ai_flags |= AI_NUMERICHOST; - error = getaddrinfo(s, "80", &hints, &res0); - if (!error) { - for (res = res0; res != NULL; res = res->ai_next) { - r = VSA_Build(p, res->ai_addr, res->ai_addrlen); - if (r != NULL) - break; - } - } + return (NULL); } - if (r == NULL) { - WS_Reset(ctx->ws, (uintptr_t)p); - r = d; - } - if (res0 != NULL) - freeaddrinfo(res0); - return (r); + + retval = lookup(p, a->s, a->resolve); + if (retval != NULL) + return (retval); + + WS_Reset(ctx->ws, (uintptr_t)p); + + if (a->valid_fallback) + return (a->fallback); + + VRT_fail(ctx, "std.integer: conversion failed"); + return (NULL); } VCL_REAL v_matchproto_(td_std_real) From dridi.boukelmoune at gmail.com Tue Mar 12 10:00:14 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 12 Mar 2019 10:00:14 +0000 (UTC) Subject: [master] c22d8f777 Require Python >= 3.4 at build time Message-ID: <20190312100014.8233465F3E@lists.varnish-cache.org> commit c22d8f777c35a2c6f0a8939680e0db732a4ec3ad Author: Dridi Boukelmoune Date: Tue Mar 12 10:28:35 2019 +0100 Require Python >= 3.4 at build time Until the naked "python" executable refers to python3 (currently it is still python2) it now takes lower precedence. diff --git a/varnish-legacy.m4 b/varnish-legacy.m4 index e5e2821eb..9f67359ea 100644 --- a/varnish-legacy.m4 +++ b/varnish-legacy.m4 @@ -98,9 +98,10 @@ AC_SUBST([VMOD_DIR]) AC_DEFUN([VARNISH_VMODTOOL], [ -AC_CHECK_PROGS(PYTHON, [python3 python3.1 python3.2 python2.7 python2.6 python2.5 python2 python], "no") +AC_CHECK_PROGS(PYTHON, [python3.9 python3.8 python3.7 python3.6 python3.5 dnl + python3.4 python3 python, "no"]) if test "x$PYTHON" = "xno"; then - AC_MSG_ERROR([Python is needed to build, please install python.]) + AC_MSG_ERROR([Python >= 3.4 is needed to build, please install python.]) fi VARNISH_PKG_GET_VAR([VMODTOOL], [vmodtool]) AC_SUBST([VMODTOOL]) diff --git a/varnish.m4 b/varnish.m4 index 71df96d9c..392c36c60 100644 --- a/varnish.m4 +++ b/varnish.m4 @@ -130,10 +130,10 @@ AC_DEFUN([_VARNISH_CHECK_DEVEL], [ # --------------------- AC_DEFUN([_VARNISH_CHECK_PYTHON], [ m4_define_default([_AM_PYTHON_INTERPRETER_LIST], -[python3.9 python3.8 python3.7 python3.6 python3.5 python3.4 python2.7 dnl -python python2 python3]) - AM_PATH_PYTHON([2.7], [], [ - AC_MSG_ERROR([Python >= 2.7 is required.]) + [python3.9 python3.8 python3.7 python3.6 python3.5 dnl + python3.4 python3 python]) + AM_PATH_PYTHON([3.4], [], [ + AC_MSG_ERROR([Python >= 3.4 is required.]) ]) ]) From dridi.boukelmoune at gmail.com Tue Mar 12 10:00:14 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 12 Mar 2019 10:00:14 +0000 (UTC) Subject: [master] 4fb3afa17 Switch to python3 in all our scripts shebangs Message-ID: <20190312100014.B096D65F41@lists.varnish-cache.org> commit 4fb3afa17f705ce4bdf8cf3c3f5aea902e612459 Author: Dridi Boukelmoune Date: Tue Mar 12 10:30:35 2019 +0100 Switch to python3 in all our scripts shebangs diff --git a/bin/varnishtest/huffman_gen.py b/bin/varnishtest/huffman_gen.py index ab6b30e87..dd4f8e1e8 100755 --- a/bin/varnishtest/huffman_gen.py +++ b/bin/varnishtest/huffman_gen.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import re import sys diff --git a/bin/varnishtest/witness.py b/bin/varnishtest/witness.py index a4f0fffa6..af4a56e55 100644 --- a/bin/varnishtest/witness.py +++ b/bin/varnishtest/witness.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # This script is in the public domain # diff --git a/doc/sphinx/vtc-syntax.py b/doc/sphinx/vtc-syntax.py index d98fc96e5..161c50a02 100644 --- a/doc/sphinx/vtc-syntax.py +++ b/doc/sphinx/vtc-syntax.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # Copyright (c) 2006-2016 Varnish Software AS # All rights reserved. diff --git a/include/generate.py b/include/generate.py index e7d547593..c1ea3bcbb 100755 --- a/include/generate.py +++ b/include/generate.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # Copyright (c) 2006 Verdens Gang AS # Copyright (c) 2006-2015 Varnish Software AS diff --git a/include/tbl/style.py b/include/tbl/style.py index a88c475a3..0e7f657fb 100644 --- a/include/tbl/style.py +++ b/include/tbl/style.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # Very basic style-checker for include/tbl files. diff --git a/lib/libvarnishapi/generate.py b/lib/libvarnishapi/generate.py index d1357c985..ea4ebd02a 100755 --- a/lib/libvarnishapi/generate.py +++ b/lib/libvarnishapi/generate.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 #- # Copyright (c) 2006 Verdens Gang AS # Copyright (c) 2006-2015 Varnish Software AS diff --git a/lib/libvcc/generate.py b/lib/libvcc/generate.py index 991c29ae6..09af2d6d9 100755 --- a/lib/libvcc/generate.py +++ b/lib/libvcc/generate.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # Copyright (c) 2006 Verdens Gang AS # Copyright (c) 2006-2015 Varnish Software AS diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py index 6cf6fdfaa..22145e64a 100755 --- a/lib/libvcc/vmodtool.py +++ b/lib/libvcc/vmodtool.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # Copyright (c) 2010-2016 Varnish Software # All rights reserved. diff --git a/lib/libvcc/vsctool.py b/lib/libvcc/vsctool.py index d93871b73..2d7f69d55 100644 --- a/lib/libvcc/vsctool.py +++ b/lib/libvcc/vsctool.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- encoding: utf-8 -*- # # Copyright (c) 2017 Varnish Software AS diff --git a/tools/gcov_digest.py b/tools/gcov_digest.py index 188fb499d..3fbfdf946 100644 --- a/tools/gcov_digest.py +++ b/tools/gcov_digest.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # Copyright (c) 2017 Varnish Software AS # All rights reserved. diff --git a/tools/include_wash.py b/tools/include_wash.py index 973d5d6ad..94c11ba2c 100644 --- a/tools/include_wash.py +++ b/tools/include_wash.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 from __future__ import print_function From dridi.boukelmoune at gmail.com Tue Mar 12 10:00:14 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 12 Mar 2019 10:00:14 +0000 (UTC) Subject: [master] 089c2766c We live in the future now Message-ID: <20190312100014.D74CC65F45@lists.varnish-cache.org> commit 089c2766c04d26cd675eb9218f5bb0cd05b4e6f9 Author: Dridi Boukelmoune Date: Tue Mar 12 10:35:38 2019 +0100 We live in the future now For a given definition of "future" or "now". diff --git a/bin/varnishtest/witness.py b/bin/varnishtest/witness.py index af4a56e55..f5b516ee0 100644 --- a/bin/varnishtest/witness.py +++ b/bin/varnishtest/witness.py @@ -7,8 +7,6 @@ # python witness.py # dot -Tpng /tmp/_.dot > /tmp/_.png -from __future__ import print_function - d = dict() a = dict() diff --git a/doc/sphinx/vtc-syntax.py b/doc/sphinx/vtc-syntax.py index 161c50a02..42205797c 100644 --- a/doc/sphinx/vtc-syntax.py +++ b/doc/sphinx/vtc-syntax.py @@ -29,7 +29,6 @@ # Process various varnishtest C files and output reStructuredText to be # included in vtc(7). -from __future__ import print_function import sys import re diff --git a/include/generate.py b/include/generate.py index c1ea3bcbb..6d1377661 100755 --- a/include/generate.py +++ b/include/generate.py @@ -29,8 +29,6 @@ # # Generate vcs_version.h vmod_abi.h -from __future__ import print_function - import subprocess import os import sys diff --git a/include/tbl/style.py b/include/tbl/style.py index 0e7f657fb..31435887e 100644 --- a/include/tbl/style.py +++ b/include/tbl/style.py @@ -2,8 +2,6 @@ # # Very basic style-checker for include/tbl files. -from __future__ import print_function - import glob def check_file(fn): diff --git a/lib/libvcc/generate.py b/lib/libvcc/generate.py index 09af2d6d9..d36012eef 100755 --- a/lib/libvcc/generate.py +++ b/lib/libvcc/generate.py @@ -30,8 +30,6 @@ # Generate various .c and .h files for the VCL compiler and the interfaces # for it. -from __future__ import print_function - ####################################################################### # These are our tokens diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py index 22145e64a..708d750e8 100755 --- a/lib/libvcc/vmodtool.py +++ b/lib/libvcc/vmodtool.py @@ -34,9 +34,6 @@ Read the vmod.vcc file (inputvcc) and produce: vmod_${name}.man.rst -- Extracted documentation (rst2man input) """ -# This script should work with both Python 2 and Python 3. -from __future__ import print_function - import os import sys import re diff --git a/lib/libvcc/vsctool.py b/lib/libvcc/vsctool.py index 2d7f69d55..c175d181c 100644 --- a/lib/libvcc/vsctool.py +++ b/lib/libvcc/vsctool.py @@ -35,8 +35,6 @@ the same general syntax as a `.rst` file, but for now we process it with this program to get a *real* `.rst` file. ''' -from __future__ import print_function - import getopt import json import sys diff --git a/tools/gcov_digest.py b/tools/gcov_digest.py index 3fbfdf946..dc375d0f2 100644 --- a/tools/gcov_digest.py +++ b/tools/gcov_digest.py @@ -48,8 +48,6 @@ Options: """ -from __future__ import print_function - import os import sys import getopt diff --git a/tools/include_wash.py b/tools/include_wash.py index 94c11ba2c..61a0cae91 100644 --- a/tools/include_wash.py +++ b/tools/include_wash.py @@ -1,7 +1,5 @@ #!/usr/bin/env python3 -from __future__ import print_function - import os def check(fn): From dridi.boukelmoune at gmail.com Tue Mar 12 10:00:14 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 12 Mar 2019 10:00:14 +0000 (UTC) Subject: [master] bc37ac28b Mention the fate of Python 2 in upgrade notes Message-ID: <20190312100015.0C05265F50@lists.varnish-cache.org> commit bc37ac28b283a4a084a16d8a87abdbe6db62f547 Author: Dridi Boukelmoune Date: Tue Mar 12 10:56:12 2019 +0100 Mention the fate of Python 2 in upgrade notes At this point someone should take care of removing instructions for changes and upgrading documents authors to make sure they don't end up in the release. Instructions in doc/sphinx/installation/install.rst also need a serious refresh for all platforms and interested parties should take care of the platforms they are familiar with. diff --git a/doc/sphinx/whats-new/upgrading-6.2.rst b/doc/sphinx/whats-new/upgrading-6.2.rst index 758d18787..e4c4f7d21 100644 --- a/doc/sphinx/whats-new/upgrading-6.2.rst +++ b/doc/sphinx/whats-new/upgrading-6.2.rst @@ -164,6 +164,11 @@ The width of columns in ``backend.list`` and ``vcl.list`` output For developers and authors of VMODs and API clients =================================================== +Python 3.4 or later is now required to build Varnish, or use scripts +installed along with Varnish, such as ``vmodtool.py`` to build VMODs +or other Varnish artifacts. Python 2 is no longer supported, and this +support will likely be dropped from stable branches too. + The VRT API has been bumped to version 9.0. Changes include: * Functions in the API have been added, and others removed. From phk at FreeBSD.org Tue Mar 12 10:42:07 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 12 Mar 2019 10:42:07 +0000 (UTC) Subject: [master] 68446cc7f Make sure VCL_BYTES are non-negative Message-ID: <20190312104207.5EECC9295A@lists.varnish-cache.org> commit 68446cc7faeac77567e2f311512346900ba76c82 Author: Poul-Henning Kamp Date: Tue Mar 12 10:40:54 2019 +0000 Make sure VCL_BYTES are non-negative Pointed out by: slink diff --git a/lib/libvmod_std/vmod_std_conversions.c b/lib/libvmod_std/vmod_std_conversions.c index c89fa4e91..7bb4a67ff 100644 --- a/lib/libvmod_std/vmod_std_conversions.c +++ b/lib/libvmod_std/vmod_std_conversions.c @@ -123,13 +123,13 @@ vmod_bytes(VRT_CTX, struct VARGS(bytes) *a) r <= VCL_BYTES_MAX) return((VCL_BYTES)r); - if (a->valid_real) { + if (a->valid_real && !isnan(a->real) && a->real >= 0) { rr = trunc(a->real); if (rr <= (VCL_REAL)VCL_BYTES_MAX) return((VCL_BYTES)rr); } - if (a->valid_integer) + if (a->valid_integer && a->integer >= 0) return((VCL_BYTES)a->integer); if (a->valid_fallback) From nils.goroll at uplex.de Tue Mar 12 10:56:06 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Tue, 12 Mar 2019 10:56:06 +0000 (UTC) Subject: [master] 9a83659f9 minor disambiguation Message-ID: <20190312105606.8A46F9522D@lists.varnish-cache.org> commit 9a83659f9e9eca70ca66ca19c3eb9cd2afd0e286 Author: Nils Goroll Date: Tue Mar 12 11:17:31 2019 +0100 minor disambiguation diff --git a/lib/libvmod_std/vmod.vcc b/lib/libvmod_std/vmod.vcc index 3d45b8c59..789c8c125 100644 --- a/lib/libvmod_std/vmod.vcc +++ b/lib/libvmod_std/vmod.vcc @@ -232,8 +232,8 @@ These functions all have the same form:: TYPE type([arguments], [fallback TYPE]) -Precisely one of the arguments must be provided, and it will be -converted to *TYPE*. +Precisely one of the *arguments* must be provided (besides the +optional *fallback*), and it will be converted to *TYPE*. If conversion fails, *fallback* will be returned and if no fallback was specified, the VCL will be failed. From nils.goroll at uplex.de Tue Mar 12 10:56:06 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Tue, 12 Mar 2019 10:56:06 +0000 (UTC) Subject: [master] 59cb7bb8c No need to mention undoing a change which was introduced since last VRT Message-ID: <20190312105606.B5E7A95231@lists.varnish-cache.org> commit 59cb7bb8cac3891b9a84d8c56d25dd100b04b493 Author: Nils Goroll Date: Tue Mar 12 11:24:17 2019 +0100 No need to mention undoing a change which was introduced since last VRT diff --git a/include/vrt.h b/include/vrt.h index cbbfd533a..18f3769da 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -53,7 +53,6 @@ * * * 9.0 (scheduled for 2019-03-15) - * Remove VCL_{INT|BYTES}_{MIN|MAX} macros * Make 'len' in vmod_priv 'long' * HTTP_Copy() removed * HTTP_Dup() added From geoff at uplex.de Tue Mar 12 13:25:11 2019 From: geoff at uplex.de (Geoff Simmons) Date: Tue, 12 Mar 2019 13:25:11 +0000 (UTC) Subject: [master] 3f8bd8ba2 Mention changed vmodtool naming in "Upgrading". Message-ID: <20190312132511.68E98A0700@lists.varnish-cache.org> commit 3f8bd8ba290fa4332a4737b88a9a545f8873f109 Author: Geoff Simmons Date: Tue Mar 12 14:24:10 2019 +0100 Mention changed vmodtool naming in "Upgrading". diff --git a/doc/sphinx/whats-new/upgrading-6.2.rst b/doc/sphinx/whats-new/upgrading-6.2.rst index e4c4f7d21..5f6930967 100644 --- a/doc/sphinx/whats-new/upgrading-6.2.rst +++ b/doc/sphinx/whats-new/upgrading-6.2.rst @@ -184,4 +184,11 @@ See ``vrt.h``, the `change log`_ and .. _change log: https://github.com/varnishcache/varnish-cache/blob/master/doc/changes.rst +The vmodtool has been changed significantly to avoid name clashes in +the C identifiers declared in ``vcc_if.h``. This may necessitate +changing names in your VMOD code. To facilitate renaming, ``vcc_if.h`` +defines macros for prepending the vmod prefix, and for naming enums +and argument structs. For details, see the `change log`_, and examine +the contents of ``vcc_if.h`` after generation. + *eof* From geoff at uplex.de Tue Mar 12 13:36:07 2019 From: geoff at uplex.de (Geoff Simmons) Date: Tue, 12 Mar 2019 13:36:07 +0000 (UTC) Subject: [master] 6fc0b3c71 Don't mention the catflap in "Upgrading". Message-ID: <20190312133607.0EB9FA0C66@lists.varnish-cache.org> commit 6fc0b3c719fcacfe3bc6a62feaad95625edf7e13 Author: Geoff Simmons Date: Tue Mar 12 14:34:39 2019 +0100 Don't mention the catflap in "Upgrading". diff --git a/doc/sphinx/whats-new/upgrading-6.2.rst b/doc/sphinx/whats-new/upgrading-6.2.rst index 5f6930967..097dbfb44 100644 --- a/doc/sphinx/whats-new/upgrading-6.2.rst +++ b/doc/sphinx/whats-new/upgrading-6.2.rst @@ -24,13 +24,13 @@ listening at the socket, or set its permissions, after Varnish starts or the VCL is loaded. Backend fetches fail if the socket is not accessible by the time the fetch is attempted. -``return(miss)`` from ``vcl_hit{}`` is now removed. Options to -implement similar functionality are: +``return(miss)`` from ``vcl_hit{}`` is now removed. An option for +implementing similar functionality is: -* a vmod using the new *catflap* mechanism +* ``return (restart)`` from ``vcl_hit{}`` -* ``return (restart)`` from ``vcl_hit{}`` and ``set - req.hash_always_miss = true;`` in ``vcl_recv{}`` for the restart. +* in ``vcl_recv{}`` for the restart (when ``req.restarts`` has + increased), ``set req.hash_always_miss = true;``. .. _whatsnew_upgrading_params_2019_03: From fgsch at lodoss.net Tue Mar 12 14:40:11 2019 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Tue, 12 Mar 2019 14:40:11 +0000 (UTC) Subject: [master] fe9ec92ac More python3 changes Message-ID: <20190312144011.89227A3161@lists.varnish-cache.org> commit fe9ec92ac679d0f81ebff5529ed01e27e5848258 Author: Federico G. Schwindt Date: Tue Mar 12 14:20:42 2019 +0000 More python3 changes diff --git a/.travis.yml b/.travis.yml index 93331c5de..c5d4c8931 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,8 +22,8 @@ matrix: addons: apt: packages: - - python-docutils - - python-sphinx + - python3-docutils + - python3-sphinx homebrew: packages: - docutils diff --git a/doc/sphinx/installation/install.rst b/doc/sphinx/installation/install.rst index 33c1584da..9010e8153 100644 --- a/doc/sphinx/installation/install.rst +++ b/doc/sphinx/installation/install.rst @@ -89,8 +89,8 @@ them (replace ``sudo apt-get install`` if needed):: libpcre3-dev \ libtool \ pkg-config \ - python-docutils \ - python-sphinx + python3-docutils \ + python3-sphinx Optionally, to rebuild the svg files:: @@ -122,8 +122,8 @@ install required packages (replace ``sudo yum install`` if needed):: ncurses-devel \ pcre-devel \ pkgconfig \ - python-docutils \ - python-sphinx + python3-docutils \ + python3-sphinx Optionally, to rebuild the svg files:: From phk at FreeBSD.org Tue Mar 12 16:02:07 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 12 Mar 2019 16:02:07 +0000 (UTC) Subject: [master] aadeeabb4 Varnish source files are utf-8 Message-ID: <20190312160207.DDB3EA4E5A@lists.varnish-cache.org> commit aadeeabb439823184c5e75a5663ae4184d96608d Author: Poul-Henning Kamp Date: Tue Mar 12 16:00:40 2019 +0000 Varnish source files are utf-8 diff --git a/tools/gcov_digest.py b/tools/gcov_digest.py index dc375d0f2..2e2f6ebba 100644 --- a/tools/gcov_digest.py +++ b/tools/gcov_digest.py @@ -63,7 +63,7 @@ def process_gcov(fn, sn): dd = counts.get(sn) if dd is None: dd = {} - for ln in open(fn): + for ln in open(fn, encoding="UTF-8"): d = ln.split(":") cnt = d[0].strip() ll = d[1] From dridi.boukelmoune at gmail.com Tue Mar 12 18:44:07 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 12 Mar 2019 18:44:07 +0000 (UTC) Subject: [master] 248a9a50a Whitespace OCD Message-ID: <20190312184407.84646A7FA5@lists.varnish-cache.org> commit 248a9a50adaab4b9b134b0ae9c4bc37528f07883 Author: Dridi Boukelmoune Date: Tue Mar 12 19:42:33 2019 +0100 Whitespace OCD diff --git a/include/vdef.h b/include/vdef.h index df63b245f..acf94813f 100644 --- a/include/vdef.h +++ b/include/vdef.h @@ -126,9 +126,9 @@ #define v_statevariable_(varname) varname /*lint -esym(838,varname) */ #ifdef __SUNPRO_C -#define NEEDLESS(s) {} +# define NEEDLESS(s) {} #else -#define NEEDLESS(s) s +# define NEEDLESS(s) s #endif #if __GNUC_PREREQ__(2, 7) From dridi.boukelmoune at gmail.com Tue Mar 12 19:23:07 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 12 Mar 2019 19:23:07 +0000 (UTC) Subject: [master] dd28fc739 Style(9) and whitespace OCD Message-ID: <20190312192307.12728A8CE5@lists.varnish-cache.org> commit dd28fc739f47d08a95b3f29e39ec2db73d2fe79f Author: Dridi Boukelmoune Date: Tue Mar 12 20:10:06 2019 +0100 Style(9) and whitespace OCD Dealing with code style violations around the return keyword, I figured I could automate that fix, so I tried with my favourite refactoring tool and following those steps: $ cat >return.cocci <rereturn.cocci <tag)]) == 0) return (ban_error(bp, - "expected conditional (%s) got \"%s\"", - arg_operhelp[BAN_ARGIDX(pv->tag)], - a2)); + "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)); diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c index c4b1f0998..a48715055 100644 --- a/bin/varnishd/cache/cache_gzip.c +++ b/bin/varnishd/cache/cache_gzip.c @@ -69,7 +69,7 @@ static const char * vgz_msg(const struct vgz *vg) { CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC); - return vg->vz.msg ? vg->vz.msg : "(null)"; + return (vg->vz.msg ? vg->vz.msg : "(null)"); } /*-------------------------------------------------------------------- diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index a778bf535..f43e214ff 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -998,7 +998,7 @@ hsh_deref_objhead_unlock(struct worker *wrk, struct objhead **poh) assert(oh->refcnt > 1); oh->refcnt--; Lck_Unlock(&oh->mtx); - return(1); + return (1); } if (oh->refcnt == 1) diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c index 534cd5d2e..5e3c92cd0 100644 --- a/bin/varnishd/cache/cache_http.c +++ b/bin/varnishd/cache/cache_http.c @@ -143,7 +143,7 @@ HTTP_estimate(unsigned nhttp) { /* XXX: We trust the structs to size-aligned as necessary */ - return (PRNDUP(sizeof (struct http) + sizeof(txt) * nhttp + nhttp)); + return (PRNDUP(sizeof(struct http) + sizeof(txt) * nhttp + nhttp)); } struct http * @@ -989,7 +989,7 @@ HTTP_GetStatusPack(struct worker *wrk, struct objcore *oc) ptr = ObjGetAttr(wrk, oc, OA_HEADERS, NULL); AN(ptr); - return(vbe16dec(ptr + 2)); + return (vbe16dec(ptr + 2)); } /*--------------------------------------------------------------------*/ diff --git a/bin/varnishd/cache/cache_lck.c b/bin/varnishd/cache/cache_lck.c index 4021166e4..87dceb5ca 100644 --- a/bin/varnishd/cache/cache_lck.c +++ b/bin/varnishd/cache/cache_lck.c @@ -255,7 +255,7 @@ Lck_Delete(struct lock *lck) struct VSC_lck * Lck_CreateClass(struct vsc_seg **sg, const char *name) { - return(VSC_lck_New(NULL, sg, name)); + return (VSC_lck_New(NULL, sg, name)); } void diff --git a/bin/varnishd/cache/cache_mempool.c b/bin/varnishd/cache/cache_mempool.c index aa7adc0c4..9add62d3c 100644 --- a/bin/varnishd/cache/cache_mempool.c +++ b/bin/varnishd/cache/cache_mempool.c @@ -305,7 +305,7 @@ MPL_Get(struct mempool *mpl, unsigned *size) CHECK_OBJ_NOTNULL(mi, MEMITEM_MAGIC); /* Throw away sizeof info for FlexeLint: */ - return ((void*)(uintptr_t)(mi+1)); + return ((void *)(uintptr_t)(mi + 1)); } void diff --git a/bin/varnishd/cache/cache_obj.c b/bin/varnishd/cache/cache_obj.c index 77a3771a7..d46f4e4da 100644 --- a/bin/varnishd/cache/cache_obj.c +++ b/bin/varnishd/cache/cache_obj.c @@ -318,7 +318,7 @@ ObjGetLen(struct worker *wrk, struct objcore *oc) CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); AZ(ObjGetU64(wrk, oc, OA_LEN, &len)); - return(len); + return (len); } /*==================================================================== diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index fbae9dadf..9289a60ba 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -83,7 +83,7 @@ reqbody_status_2str(enum req_body_state_e e) #define REQ_BODY(U) case REQ_BODY_##U: return("R_BODY_" #U); #include "tbl/req_body.h" default: - return("?"); + return ("?"); } } @@ -106,12 +106,12 @@ const char * sess_close_2str(enum sess_close sc, int want_desc) { switch (sc) { - case SC_NULL: return(want_desc ? "(null)": "NULL"); + case SC_NULL: return (want_desc ? "(null)" : "NULL"); #define SESS_CLOSE(nm, s, err, desc) \ case SC_##nm: return(want_desc ? desc : #nm); #include "tbl/sess_close.h" - default: return(want_desc ? "(invalid)" : "INVALID"); + default: return (want_desc ? "(invalid)" : "INVALID"); } } diff --git a/bin/varnishd/cache/cache_req_body.c b/bin/varnishd/cache/cache_req_body.c index 903c973b5..13c4ed07f 100644 --- a/bin/varnishd/cache/cache_req_body.c +++ b/bin/varnishd/cache/cache_req_body.c @@ -254,7 +254,7 @@ VRB_Ignore(struct req *req) if (req->req_body_status == REQ_BODY_WITH_LEN || req->req_body_status == REQ_BODY_WITHOUT_LEN) (void)VRB_Iterate(req, httpq_req_body_discard, NULL); - return(0); + return (0); } /*---------------------------------------------------------------------- diff --git a/bin/varnishd/cache/cache_tcp_pool.c b/bin/varnishd/cache/cache_tcp_pool.c index 1eb4f5164..0e2fbd4f7 100644 --- a/bin/varnishd/cache/cache_tcp_pool.c +++ b/bin/varnishd/cache/cache_tcp_pool.c @@ -581,7 +581,7 @@ struct vtp_cs { static inline int tmo2msec(vtim_dur tmo) { - return ( (int)floor(tmo * 1000.0) ); + return ((int)floor(tmo * 1000.0)); } static int v_matchproto_(cp_open_f) @@ -763,7 +763,7 @@ VTP_Ref(const struct suckaddr *ip4, const struct suckaddr *ip6, const char *uds, if (ip6 != NULL) tp->ip6 = VSA_Clone(ip6); } - return(VCP_New(tp->cp, id, tp, methods)); + return (VCP_New(tp->cp, id, tp, methods)); } /*-------------------------------------------------------------------- @@ -837,7 +837,7 @@ VTP_Get(struct tcp_pool *tp, vtim_dur tmo, struct worker *wrk, unsigned force_fresh, int *err) { - return VCP_Get(tp->cp, tmo, wrk, force_fresh, err); + return (VCP_Get(tp->cp, tmo, wrk, force_fresh, err)); } /*-------------------------------------------------------------------- diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c index 8940a6797..2edfb85b6 100644 --- a/bin/varnishd/cache/cache_vrt.c +++ b/bin/varnishd/cache/cache_vrt.c @@ -154,7 +154,7 @@ VRT_GetHdr(VRT_CTX, const struct gethdr_s *hs) if (hs->where == HDR_OBJ) { CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); CHECK_OBJ_NOTNULL(ctx->req->objcore, OBJCORE_MAGIC); - return(HTTP_GetHdrPack(ctx->req->wrk, ctx->req->objcore, + return (HTTP_GetHdrPack(ctx->req->wrk, ctx->req->objcore, hs->what)); } hp = VRT_selecthttp(ctx, hs->where); @@ -362,7 +362,7 @@ VRT_Strands(char *d, size_t dl, VCL_STRANDS s) if (s->p[i] != NULL && *s->p[i] != '\0') { x = strlen(s->p[i]); if (b + x >= e) - return(NULL); + return (NULL); memcpy(b, s->p[i], x); b += x; } @@ -824,7 +824,7 @@ int VRT_strcmp(const char *s1, const char *s2) { if (s1 == NULL || s2 == NULL) - return(1); + return (1); return (strcmp(s1, s2)); } @@ -839,7 +839,7 @@ VCL_BOOL VRT_ipcmp(VCL_IP sua1, VCL_IP sua2) { if (sua1 == NULL || sua2 == NULL) - return(1); + return (1); return (VSA_Compare_IP(sua1, sua2)); } diff --git a/bin/varnishd/cache/cache_vrt_re.c b/bin/varnishd/cache/cache_vrt_re.c index 20a0cf6fc..9cd0de3e7 100644 --- a/bin/varnishd/cache/cache_vrt_re.c +++ b/bin/varnishd/cache/cache_vrt_re.c @@ -121,10 +121,10 @@ VRT_regsub(VRT_CTX, int all, const char *str, void *re, /* If it didn't match, we can return the original string */ if (i == VRE_ERROR_NOMATCH) - return(str); + return (str); if (i < VRE_ERROR_NOMATCH ) { VSLb(ctx->vsl, SLT_VCL_Error, "Regexp matching returned %d", i); - return(str); + return (str); } u = WS_Reserve(ctx->ws, 0); @@ -162,7 +162,7 @@ VRT_regsub(VRT_CTX, int all, const char *str, void *re, WS_Release(ctx->ws, 0); VSLb(ctx->vsl, SLT_VCL_Error, "Regexp matching returned %d", i); - return(str); + return (str); } } while (i != VRE_ERROR_NOMATCH); diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index afd0d475a..c734e0a5a 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -692,8 +692,7 @@ VRT_r_bereq_xid(VRT_CTX) CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC); AN(ctx->bo->vsl); - return (WS_Printf(ctx->ws, "%u", - VXID(ctx->bo->vsl->wid))); + return (WS_Printf(ctx->ws, "%u", VXID(ctx->bo->vsl->wid))); } VCL_STRING diff --git a/bin/varnishd/cache/cache_wrk.c b/bin/varnishd/cache/cache_wrk.c index ce450584e..a0fc4eacb 100644 --- a/bin/varnishd/cache/cache_wrk.c +++ b/bin/varnishd/cache/cache_wrk.c @@ -270,7 +270,7 @@ Pool_Task(struct pool *pp, struct pool_task *task, enum task_prio prio) VSL(SLT_Debug, 0, "Failing due to reqpoolfail (next= 0x%jx)", reqpoolfail); - return(retval); + return (retval); } } diff --git a/bin/varnishd/hash/hash_critbit.c b/bin/varnishd/hash/hash_critbit.c index fcedbef5f..515de002c 100644 --- a/bin/varnishd/hash/hash_critbit.c +++ b/bin/varnishd/hash/hash_critbit.c @@ -268,7 +268,7 @@ hcb_insert(struct worker *wrk, struct hcb_root *root, const uint8_t *digest, y2->leaf[s2] = *p; VWMB(); *p = hcb_r_y(y2); - return(oh2); + return (oh2); } /*--------------------------------------------------------------------*/ diff --git a/bin/varnishd/http1/cache_http1_fsm.c b/bin/varnishd/http1/cache_http1_fsm.c index c2386dcb1..4f6e8efd1 100644 --- a/bin/varnishd/http1/cache_http1_fsm.c +++ b/bin/varnishd/http1/cache_http1_fsm.c @@ -65,7 +65,7 @@ http1_getstate(const struct sess *sp) uintptr_t *p; AZ(SES_Get_proto_priv(sp, &p)); - return (const char *)*p; + return ((const char *)*p); } /*-------------------------------------------------------------------- diff --git a/bin/varnishd/http1/cache_http1_vfp.c b/bin/varnishd/http1/cache_http1_vfp.c index 736febf85..4171c6151 100644 --- a/bin/varnishd/http1/cache_http1_vfp.c +++ b/bin/varnishd/http1/cache_http1_vfp.c @@ -290,5 +290,5 @@ V1F_Setup_Fetch(struct vfp_ctx *vfc, struct http_conn *htc) break; } vfe->priv1 = htc; - return 0; + return (0); } diff --git a/bin/varnishd/mgt/mgt_acceptor.c b/bin/varnishd/mgt/mgt_acceptor.c index cd2794612..7f1207c63 100644 --- a/bin/varnishd/mgt/mgt_acceptor.c +++ b/bin/varnishd/mgt/mgt_acceptor.c @@ -103,9 +103,9 @@ mac_opensocket(struct listen_sock *ls) errno = 0; if (ls->perms->mode != 0 && chmod(ls->endpoint, ls->perms->mode) != 0) - return errno; + return (errno); if (chown(ls->endpoint, ls->perms->uid, ls->perms->gid) != 0) - return errno; + return (errno); } MCH_Fd_Inherit(ls->sock, "sock"); return (0); @@ -134,7 +134,7 @@ MAC_reopen_sockets(void) "Could not reopen listen socket %s: %s", ls->endpoint, vstrerror(err)); } - return fail; + return (fail); } /*--------------------------------------------------------------------*/ @@ -167,9 +167,9 @@ mk_listen_sock(const struct listen_arg *la, const struct suckaddr *sa) if (fail != EAFNOSUPPORT) ARGV_ERR("Could not get socket %s: %s\n", la->endpoint, vstrerror(fail)); - return(NULL); + return (NULL); } - return(ls); + return (ls); } static int v_matchproto_(vss_resolved_f) diff --git a/bin/varnishd/mgt/mgt_child.c b/bin/varnishd/mgt/mgt_child.c index 92a6313ca..b28a26953 100644 --- a/bin/varnishd/mgt/mgt_child.c +++ b/bin/varnishd/mgt/mgt_child.c @@ -648,7 +648,7 @@ MCH_Start_Child(void) mgt_launch_child(NULL); if (child_state != CH_RUNNING) return (2); - return(0); + return (0); } /*==================================================================== diff --git a/bin/varnishd/mgt/mgt_jail_solaris.c b/bin/varnishd/mgt/mgt_jail_solaris.c index f594eaede..dda89efae 100644 --- a/bin/varnishd/mgt/mgt_jail_solaris.c +++ b/bin/varnishd/mgt/mgt_jail_solaris.c @@ -242,13 +242,13 @@ static inline enum jail_gen_e jail_subproc_gen(enum jail_subproc_e e) { assert(e < (1 << JAILG_SHIFT)); - return (enum jail_gen_e)e; + return ((enum jail_gen_e)e); } static inline enum jail_gen_e jail_master_gen(enum jail_master_e e) { - return (enum jail_gen_e)(e << JAILG_SHIFT); + return ((enum jail_gen_e)(e << JAILG_SHIFT)); } static int v_matchproto_(jail_init_f) diff --git a/bin/varnishd/mgt/mgt_vcl.c b/bin/varnishd/mgt/mgt_vcl.c index 28fc35579..161063221 100644 --- a/bin/varnishd/mgt/mgt_vcl.c +++ b/bin/varnishd/mgt/mgt_vcl.c @@ -358,7 +358,7 @@ mgt_vcl_cache_vmod(const char *nm, const char *fm, const char *to) closefd(&fi); AZ(fchmod(fo, 0444)); closefd(&fo); - return(ret); + return (ret); } void diff --git a/bin/varnishd/storage/stevedore_utils.c b/bin/varnishd/storage/stevedore_utils.c index 926c6b5a9..99207e469 100644 --- a/bin/varnishd/storage/stevedore_utils.c +++ b/bin/varnishd/storage/stevedore_utils.c @@ -210,5 +210,5 @@ STV_FileSize(int fd, const char *size, unsigned *granularity, const char *ctx) /* Round down */ l -= (l % *granularity); - return(l); + return (l); } diff --git a/bin/varnishd/waiter/cache_waiter.c b/bin/varnishd/waiter/cache_waiter.c index fc316424b..d481358bb 100644 --- a/bin/varnishd/waiter/cache_waiter.c +++ b/bin/varnishd/waiter/cache_waiter.c @@ -120,7 +120,7 @@ Wait_HeapDue(const struct waiter *w, struct waited **wpp) } if (wpp != NULL) *wpp = wp; - return(Wait_When(wp)); + return (Wait_When(wp)); } /**********************************************************************/ diff --git a/bin/varnishd/waiter/cache_waiter_kqueue.c b/bin/varnishd/waiter/cache_waiter_kqueue.c index 8ab242e78..8a50c260c 100644 --- a/bin/varnishd/waiter/cache_waiter_kqueue.c +++ b/bin/varnishd/waiter/cache_waiter_kqueue.c @@ -131,7 +131,7 @@ vwk_thread(void *priv) closefd(&vwk->pipe[0]); closefd(&vwk->pipe[1]); closefd(&vwk->kq); - return(NULL); + return (NULL); } /*--------------------------------------------------------------------*/ diff --git a/bin/varnishd/waiter/cache_waiter_ports.c b/bin/varnishd/waiter/cache_waiter_ports.c index 5d34a5539..dc5e82805 100644 --- a/bin/varnishd/waiter/cache_waiter_ports.c +++ b/bin/varnishd/waiter/cache_waiter_ports.c @@ -211,7 +211,7 @@ vws_thread(void *priv) for (ei = 0; ei < nevents; ei++) vws_port_ev(vws, w, &ev[ei], now); } - return NULL; + return (NULL); } /*--------------------------------------------------------------------*/ diff --git a/lib/libvarnish/vcli_serve.c b/lib/libvarnish/vcli_serve.c index e5cf0c411..45363b302 100644 --- a/lib/libvarnish/vcli_serve.c +++ b/lib/libvarnish/vcli_serve.c @@ -410,7 +410,7 @@ cls_feed(struct VCLS_fd *cfd, const char *p, const char *e) VAV_Free(av); VSB_destroy(&cli->cmd); if (i) - return(i); + return (i); } } else { /* "<< nonce" mode */ diff --git a/lib/libvarnish/vjsn.c b/lib/libvarnish/vjsn.c index 61280496a..2ef5629ca 100644 --- a/lib/libvarnish/vjsn.c +++ b/lib/libvarnish/vjsn.c @@ -234,7 +234,7 @@ vjsn_string(struct vjsn *js) case 'u': vjsn_unicode(js, &p); if (js->err != NULL) - return(NULL); + return (NULL); break; default: js->err = "Bad string escape"; diff --git a/lib/libvarnish/vnum.c b/lib/libvarnish/vnum.c index 9502e9dc4..13bad74d1 100644 --- a/lib/libvarnish/vnum.c +++ b/lib/libvarnish/vnum.c @@ -80,7 +80,7 @@ VNUMpfx(const char *p, const char **t) break; } if (e > 0.0) - return(nan("")); // No digits + return (nan("")); // No digits if (*p == 'e' || *p == 'E') { p++; if (*p == '-' || *p == '+') diff --git a/lib/libvarnish/vtcp.c b/lib/libvarnish/vtcp.c index baf61f27e..d222d6bb4 100644 --- a/lib/libvarnish/vtcp.c +++ b/lib/libvarnish/vtcp.c @@ -518,7 +518,7 @@ VTCP_listen_on(const char *addr, const char *def_port, int depth, sock = VSS_resolver(addr, def_port, vtcp_lo_cb, &h, errp); if (*errp != NULL) return (-1); - return(sock); + return (sock); } /*-------------------------------------------------------------------- diff --git a/lib/libvarnish/vus.c b/lib/libvarnish/vus.c index 12ee9af31..200679fc0 100644 --- a/lib/libvarnish/vus.c +++ b/lib/libvarnish/vus.c @@ -53,13 +53,13 @@ VUS_resolver(const char *path, vus_resolved_f *func, void *priv, *err = NULL; if (strlen(path) + 1 > sizeof(uds.sun_path)) { *err = "Path too long for a Unix domain socket"; - return(-1); + return (-1); } bprintf(uds.sun_path, "%s", path); uds.sun_family = PF_UNIX; if (func != NULL) ret = func(priv, &uds); - return(ret); + return (ret); } int diff --git a/lib/libvarnishapi/vsm.c b/lib/libvarnishapi/vsm.c index f10c77e36..8c133a61e 100644 --- a/lib/libvarnishapi/vsm.c +++ b/lib/libvarnishapi/vsm.c @@ -857,7 +857,7 @@ VSM_Unmap(struct vsm *vd, struct vsm_fantom *vf) vf->b = NULL; vf->e = NULL; if (vg->refs > 0) - return(0); + return (0); if (vg->cluster) { assert(vg->s == NULL); diff --git a/lib/libvcc/vcc_symb.c b/lib/libvcc/vcc_symb.c index 4d088ecd1..8f19a0005 100644 --- a/lib/libvcc/vcc_symb.c +++ b/lib/libvcc/vcc_symb.c @@ -45,13 +45,13 @@ static vcc_kind_t VCC_HandleKind(vcc_type_t fmt) { - if (fmt == ACL) return(SYM_ACL); - if (fmt == BACKEND) return(SYM_BACKEND); - if (fmt == PROBE) return(SYM_PROBE); - if (fmt == STEVEDORE) return(SYM_STEVEDORE); - if (fmt == SUB) return(SYM_SUB); - if (fmt == INSTANCE) return(SYM_INSTANCE); - return(SYM_NONE); + if (fmt == ACL) return (SYM_ACL); + if (fmt == BACKEND) return (SYM_BACKEND); + if (fmt == PROBE) return (SYM_PROBE); + if (fmt == STEVEDORE) return (SYM_STEVEDORE); + if (fmt == SUB) return (SYM_SUB); + if (fmt == INSTANCE) return (SYM_INSTANCE); + return (SYM_NONE); } void diff --git a/lib/libvmod_blob/base64.c b/lib/libvmod_blob/base64.c index 594b84881..1ced6472f 100644 --- a/lib/libvmod_blob/base64.c +++ b/lib/libvmod_blob/base64.c @@ -39,19 +39,19 @@ size_t base64nopad_encode_l(size_t l) { - return base64_l(l) + 4; + return (base64_l(l) + 4); } size_t base64_encode_l(size_t l) { - return (((base64_l(l)) + 3) & ~3) + 1; + return ((((base64_l(l)) + 3) & ~3) + 1); } size_t base64_decode_l(size_t l) { - return ((l) * 3) >> 2; + return (((l) * 3) >> 2); } static inline int @@ -62,19 +62,19 @@ decode(char *restrict *restrict dest, const char *restrict const buf, if (n <= 1) { errno = EINVAL; - return -1; + return (-1); } d = *dest; for (int i = 0; i < n - 1; i++) { if (d == buf + buflen) { errno = ENOMEM; - return -1; + return (-1); } *d++ = (u >> 16) & 0xff; u <<= 8; } *dest += d - *dest; - return 1; + return (1); } ssize_t @@ -91,14 +91,14 @@ base64_encode(const enum encoding enc, const enum case_e kase, AN(buf); AN(alpha); if (in == NULL || inlength == 0) - return 0; + return (0); if ((enc == BASE64URLNOPAD && buflen < base64nopad_encode_l(inlength)) || (enc != BASE64URLNOPAD && buflen < base64_encode_l(inlength))) { errno = ENOMEM; - return -1; + return (-1); } while (end - in >= 3) { @@ -126,7 +126,7 @@ base64_encode(const enum encoding enc, const enum case_e kase, } } assert(p >= buf && p - buf <= buflen); - return p - buf; + return (p - buf); } ssize_t @@ -155,7 +155,7 @@ base64_decode(const enum encoding dec, char *restrict const buf, continue; if (*s && term) { errno = EINVAL; - return -1; + return (-1); } while (*s && len) { while (n < 4) { @@ -163,7 +163,7 @@ base64_decode(const enum encoding dec, char *restrict const buf, u <<= 6; if (b == ILL) { errno = EINVAL; - return -1; + return (-1); } n++; if (b == PAD) { @@ -178,7 +178,7 @@ base64_decode(const enum encoding dec, char *restrict const buf, } if (n == 4) { if (decode(&dest, buf, buflen, u, n-term) < 0) - return -1; + return (-1); n = 0; } } @@ -187,8 +187,8 @@ base64_decode(const enum encoding dec, char *restrict const buf, if (!alpha->padding) u <<= (6 * (4 - n)); if (decode(&dest, buf, buflen, u, n-term) < 0) - return -1; + return (-1); } - return dest - buf; + return (dest - buf); } diff --git a/lib/libvmod_blob/hex.c b/lib/libvmod_blob/hex.c index 2306a2fec..79a44feb9 100644 --- a/lib/libvmod_blob/hex.c +++ b/lib/libvmod_blob/hex.c @@ -59,19 +59,19 @@ const uint8_t nibble[] = { size_t hex_encode_l(size_t l) { - return ((l) << 1) + 1; + return (((l) << 1) + 1); } size_t hex_decode_l(size_t l) { - return ((l) + 1) >> 1; + return (((l) + 1) >> 1); } static inline char hex2byte(const unsigned char hi, const unsigned char lo) { - return (nibble[hi - '0'] << 4) | nibble[lo - '0']; + return ((nibble[hi - '0'] << 4) | nibble[lo - '0']); } ssize_t @@ -85,9 +85,9 @@ hex_encode(const enum encoding enc, const enum case_e kase, AN(buf); assert(enc == HEX); if (in == NULL || inlen == 0) - return 0; + return (0); if (buflen < hex_encode_l(inlen)) - return -1; + return (-1); if (kase == UPPER) alphabet = hex_alphabet[1]; @@ -97,7 +97,7 @@ hex_encode(const enum encoding enc, const enum case_e kase, *p++ = alphabet[in[i] & 0x0f]; } - return p - buf; + return (p - buf); } ssize_t @@ -130,13 +130,13 @@ hex_decode(const enum encoding dec, char *restrict const buf, } if (len == 0) - return 0; + return (0); if (n != -1 && len > n) len = n; if (((len+1) >> 1) > buflen) { errno = ENOMEM; - return -1; + return (-1); } if (len & 1) { extranib = '0'; @@ -160,5 +160,5 @@ hex_decode(const enum encoding dec, char *restrict const buf, extranib = *s; } assert(dest <= buf + buflen); - return dest - buf; + return (dest - buf); } diff --git a/lib/libvmod_blob/id.c b/lib/libvmod_blob/id.c index 3fc8d5280..e429db3ac 100644 --- a/lib/libvmod_blob/id.c +++ b/lib/libvmod_blob/id.c @@ -38,13 +38,13 @@ size_t id_encode_l(size_t l) { - return l + 1; + return (l + 1); } size_t id_decode_l(size_t l) { - return l; + return (l); } ssize_t @@ -57,12 +57,12 @@ id_encode(const enum encoding enc, const enum case_e kase, AN(buf); if (buflen < inlen + 1) - return -1; + return (-1); if (in == NULL || inlen == 0) - return 0; + return (0); memcpy(buf, in, inlen); - return inlen; + return (inlen); } ssize_t @@ -92,11 +92,11 @@ id_decode(const enum encoding enc, c -= len; if ((outlen += len) > buflen) { errno = ENOMEM; - return -1; + return (-1); } memcpy(dest, s, len); dest += len; } - return outlen; + return (outlen); } diff --git a/lib/libvmod_blob/url.c b/lib/libvmod_blob/url.c index 1713bb5ab..f035bb6ae 100644 --- a/lib/libvmod_blob/url.c +++ b/lib/libvmod_blob/url.c @@ -46,13 +46,13 @@ enum state_e { size_t url_encode_l(size_t l) { - return (l * 3) + 1; + return ((l * 3) + 1); } size_t url_decode_l(size_t l) { - return l; + return (l); } /* @@ -90,7 +90,7 @@ url_encode(const enum encoding enc, const enum case_e kase, AN(buf); assert(enc == URL); if (in == NULL || inlen == 0) - return 0; + return (0); if (kase == UPPER) alphabet = hex_alphabet[1]; @@ -98,19 +98,19 @@ url_encode(const enum encoding enc, const enum case_e kase, for (int i = 0; i < inlen; i++) { if (isunreserved(in[i])) { if (p == end) - return -1; + return (-1); *p++ = in[i]; } else { if (p + 3 > end) - return -1; + return (-1); *p++ = '%'; *p++ = alphabet[(in[i] & 0xf0) >> 4]; *p++ = alphabet[in[i] & 0x0f]; } } - return p - buf; + return (p - buf); } ssize_t @@ -146,7 +146,7 @@ url_decode(const enum encoding dec, char *restrict const buf, else { if (dest == end) { errno = ENOMEM; - return -1; + return (-1); } *dest++ = *s; } @@ -155,19 +155,19 @@ url_decode(const enum encoding dec, char *restrict const buf, if (isoutofrange(*s) || (nib = nibble[*s - '0']) == ILL) { errno = EINVAL; - return -1; + return (-1); } state = FIRSTNIB; break; case FIRSTNIB: if (dest == end) { errno = ENOMEM; - return -1; + return (-1); } if (isoutofrange(*s) || (nib2 = nibble[*s - '0']) == ILL) { errno = EINVAL; - return -1; + return (-1); } *dest++ = (nib << 4) | nib2; nib = 0; @@ -182,8 +182,8 @@ url_decode(const enum encoding dec, char *restrict const buf, } if (state != NORMAL) { errno = EINVAL; - return -1; + return (-1); } assert(dest <= end); - return dest - buf; + return (dest - buf); } diff --git a/lib/libvmod_blob/vmod_blob.c b/lib/libvmod_blob/vmod_blob.c index d032a439b..7820e810c 100644 --- a/lib/libvmod_blob/vmod_blob.c +++ b/lib/libvmod_blob/vmod_blob.c @@ -143,7 +143,7 @@ decode_l(enum encoding dec, VCL_STRANDS s) if (s->p[i] != NULL && *s->p[i] != '\0') len += strlen(s->p[i]); - return(func[dec].decode_l(len)); + return (func[dec].decode_l(len)); } static void @@ -175,9 +175,9 @@ check_enc_case(VRT_CTX, VCL_ENUM encs, VCL_ENUM case_s, enum encoding enc, { if (!encodes_hex(enc) && kase != DEFAULT) { VERR(ctx, "case %s is illegal with encoding %s", case_s, encs); - return 0; + return (0); } - return 1; + return (1); } /* Objects */ @@ -373,7 +373,7 @@ encode(VRT_CTX, enum encoding enc, enum case_e kase, VCL_BLOB b) AENC(enc); if (b == NULL) - return NULL; + return (NULL); CHECK_OBJ_NOTNULL(ctx->ws, WS_MAGIC); snap = WS_Snapshot(ctx->ws); @@ -386,16 +386,16 @@ encode(VRT_CTX, enum encoding enc, enum case_e kase, VCL_BLOB b) ERRNOMEM(ctx, "cannot encode"); WS_Release(ctx->ws, 0); WS_Reset(ctx->ws, snap); - return NULL; + return (NULL); } if (len == 0) { WS_Release(ctx->ws, 0); WS_Reset(ctx->ws, snap); - return ""; + return (""); } buf[len] = '\0'; WS_Release(ctx->ws, len + 1); - return buf; + return (buf); } VCL_STRING v_matchproto_(td_blob_encode) diff --git a/lib/libvmod_debug/vmod_debug.c b/lib/libvmod_debug/vmod_debug.c index 8bcd48c33..17454ba49 100644 --- a/lib/libvmod_debug/vmod_debug.c +++ b/lib/libvmod_debug/vmod_debug.c @@ -148,7 +148,7 @@ xyzzy_test_priv_task(VRT_CTX, struct vmod_priv *priv, VCL_STRING s) char *n = realloc(priv->priv, strlen(priv->priv) + strlen(s) + 2); if (n == NULL) - return NULL; + return (NULL); strcat(n, " "); strcat(n, s); priv->priv = n; @@ -383,7 +383,7 @@ event_discard(VRT_CTX, void *priv) VRT_RemoveVFP(ctx, &xyzzy_rot13); if (--loads) - return(0); + return (0); /* * The vsc and vsc_seg variables are not per-VCL, they are @@ -394,7 +394,7 @@ event_discard(VRT_CTX, void *priv) if (vsc) VSC_debug_Destroy(&vsc_seg); - return(0); + return (0); } int v_matchproto_(vmod_event_f) diff --git a/lib/libvmod_directors/shard_cfg.c b/lib/libvmod_directors/shard_cfg.c index 1483098ff..70d709c43 100644 --- a/lib/libvmod_directors/shard_cfg.c +++ b/lib/libvmod_directors/shard_cfg.c @@ -96,7 +96,7 @@ shard_change_get(VRT_CTX, struct vmod_priv *priv, shard_err0(ctx, shardd, "cannot change more than one shard director " "at a time"); - return NULL; + return (NULL); } return (change); } @@ -104,7 +104,7 @@ shard_change_get(VRT_CTX, struct vmod_priv *priv, change = WS_Alloc(ctx->ws, sizeof(*change)); if (change == NULL) { shard_err0(ctx, shardd, "could not get workspace"); - return NULL; + return (NULL); } INIT_OBJ(change, SHARD_CHANGE_MAGIC); @@ -159,13 +159,13 @@ shard_change_task_backend(VRT_CTX, change = shard_change_get(ctx, priv, shardd); if (change == NULL) - return 0; + return (0); b = WS_Alloc(ctx->ws, sizeof(*b)); if (b == NULL) { shard_err(ctx, shardd, ".%s_backend() WS_Alloc() failed", task_e == ADD_BE ? "add" : "remove"); - return 0; + return (0); } b->backend = be; @@ -174,7 +174,7 @@ shard_change_task_backend(VRT_CTX, shard_change_task_add(ctx, change, task_e, b); - return 1; + return (1); } /* @@ -187,16 +187,16 @@ shardcfg_add_backend(VRT_CTX, struct vmod_priv *priv, VCL_DURATION rampup) { AN(be); - return shard_change_task_backend(ctx, priv, shardd, ADD_BE, - be, ident, rampup); + return (shard_change_task_backend(ctx, priv, shardd, ADD_BE, + be, ident, rampup)); } VCL_BOOL shardcfg_remove_backend(VRT_CTX, struct vmod_priv *priv, const struct sharddir *shardd, VCL_BACKEND be, VCL_STRING ident) { - return shard_change_task_backend(ctx, priv, shardd, REMOVE_BE, - be, ident, 0); + return (shard_change_task_backend(ctx, priv, shardd, REMOVE_BE, + be, ident, 0)); } VCL_BOOL @@ -208,11 +208,11 @@ shardcfg_clear(VRT_CTX, struct vmod_priv *priv, const struct sharddir *shardd) change = shard_change_get(ctx, priv, shardd); if (change == NULL) - return 0; + return (0); shard_change_task_add(ctx, change, CLEAR, NULL); - return 1; + return (1); } /* @@ -226,7 +226,7 @@ static int circlepoint_compare(const struct shard_circlepoint *a, const struct shard_circlepoint *b) { - return (a->point == b->point) ? 0 : ((a->point > b->point) ? 1 : -1); + return ((a->point == b->point) ? 0 : ((a->point > b->point) ? 1 : -1)); } static void @@ -322,7 +322,7 @@ shardcfg_backend_cmp(const struct shard_backend *a, /* vcl_names are unique, so we can compare the backend pointers */ if (ai == NULL && bi == NULL) - return a->backend != b->backend; + return (a->backend != b->backend); if (ai == NULL) ai = VRT_BACKEND_string(a->backend); @@ -332,7 +332,7 @@ shardcfg_backend_cmp(const struct shard_backend *a, AN(ai); AN(bi); - return strcmp(ai, bi); + return (strcmp(ai, bi)); } /* for removal, we delete all instances if the backend matches */ @@ -343,9 +343,9 @@ shardcfg_backend_del_cmp(const struct shard_backend *task, assert(task->backend || task->ident); if (task->ident == NULL) - return task->backend != b->backend; + return (task->backend != b->backend); - return shardcfg_backend_cmp(task, b); + return (shardcfg_backend_cmp(task, b)); } static const struct shard_backend * @@ -362,9 +362,9 @@ shardcfg_backend_lookup(const struct backend_reconfig *re, if (bb[i].backend == NULL) continue; // hole if (!shardcfg_backend_cmp(b, &bb[i])) - return &bb[i]; + return (&bb[i]); } - return NULL; + return (NULL); } static void @@ -587,15 +587,15 @@ shardcfg_reconfigure(VRT_CTX, struct vmod_priv *priv, if (replicas <= 0) { shard_err(ctx, shardd, ".reconfigure() invalid replicas argument %ld", replicas); - return 0; + return (0); } change = shard_change_get(ctx, priv, shardd); if (change == NULL) - return 0; + return (0); if (VSTAILQ_FIRST(&change->tasks) == NULL) - return 1; + return (1); sharddir_wrlock(shardd); @@ -609,7 +609,7 @@ shardcfg_reconfigure(VRT_CTX, struct vmod_priv *priv, if (shardd->n_backend == 0) { shard_err0(ctx, shardd, ".reconfigure() no backends"); sharddir_unlock(shardd); - return 0; + return (0); } shardcfg_hashcircle(shardd, replicas); diff --git a/lib/libvmod_directors/shard_dir.c b/lib/libvmod_directors/shard_dir.c index 645d394a7..ac870cd6b 100644 --- a/lib/libvmod_directors/shard_dir.c +++ b/lib/libvmod_directors/shard_dir.c @@ -155,7 +155,7 @@ shard_lookup(const struct sharddir *shardd, const uint32_t key) low = i; } while (idx == -1); - return idx; + return (idx); } static int @@ -172,7 +172,7 @@ shard_next(struct shard_state *state, VCL_INT skip, VCL_BOOL healthy) CHECK_OBJ_NOTNULL(state->shardd, SHARDDIR_MAGIC); if (state->pickcount >= state->shardd->n_backend) - return -1; + return (-1); ringsz = state->shardd->n_backend * state->shardd->replicas; @@ -217,7 +217,7 @@ shard_next(struct shard_state *state, VCL_INT skip, VCL_BOOL healthy) if (++(state->idx) == ringsz) state->idx = 0; } - return chosen; + return (chosen); } void From dridi.boukelmoune at gmail.com Tue Mar 12 19:23:07 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 12 Mar 2019 19:23:07 +0000 (UTC) Subject: [master] 70d5051fe Style(9) and whitespace OCD, varnishtest edition Message-ID: <20190312192307.2FF3FA8CE8@lists.varnish-cache.org> commit 70d5051fe755ccd4a9b789d9ce83cf2eeb9b9622 Author: Dridi Boukelmoune Date: Tue Mar 12 20:10:06 2019 +0100 Style(9) and whitespace OCD, varnishtest edition See dd28fc739f47d08a95b3f29e39ec2db73d2fe79f for the whole story. diff --git a/bin/varnishtest/vtc.c b/bin/varnishtest/vtc.c index 8a9057333..f6c686d17 100644 --- a/bin/varnishtest/vtc.c +++ b/bin/varnishtest/vtc.c @@ -464,7 +464,7 @@ fail_out(void) if (once++) { vtc_log(vltop, 1, "failure during reset"); - return(vtc_error); + return (vtc_error); } old_err = vtc_error; if (!vtc_stop) @@ -543,5 +543,5 @@ exec_file(const char *fn, const char *script, const char *tmpdir, vtc_thread = pthread_self(); parse_string(script, cmds, NULL, vltop); - return(fail_out()); + return (fail_out()); } diff --git a/bin/varnishtest/vtc_client.c b/bin/varnishtest/vtc_client.c index 72b7cfb71..7d199d2ef 100644 --- a/bin/varnishtest/vtc_client.c +++ b/bin/varnishtest/vtc_client.c @@ -122,11 +122,11 @@ client_tcp_connect(struct vtclog *vl, const char *addr, double tmo, fd = VTCP_open(addr, NULL, tmo, errp); if (fd < 0) - return fd; + return (fd); VTCP_myname(fd, mabuf, sizeof mabuf, mpbuf, sizeof mpbuf); vtc_log(vl, 3, "connected fd %d from %s %s to %s", fd, mabuf, mpbuf, addr); - return fd; + return (fd); } /* cf. VTCP_Open() */ @@ -183,10 +183,10 @@ client_uds_connect(struct vtclog *vl, const char *path, double tmo, fd = VUS_resolver(path, uds_open, &tmo, errp); if (fd < 0) { *errp = strerror(errno); - return fd; + return (fd); } vtc_log(vl, 3, "connected fd %d to %s", fd, path); - return fd; + return (fd); } /********************************************************************** diff --git a/bin/varnishtest/vtc_h2_hpack.c b/bin/varnishtest/vtc_h2_hpack.c index e52f16855..f7343cab1 100644 --- a/bin/varnishtest/vtc_h2_hpack.c +++ b/bin/varnishtest/vtc_h2_hpack.c @@ -160,7 +160,7 @@ huff_simulate(const char *str, int ilen, int huff) olen += coding_table[(unsigned char)*str].size; str++; } - return ((olen+7)/8); + return ((olen + 7) / 8); } static enum hpk_result @@ -360,7 +360,7 @@ HPK_DecHdr(struct hpk_iter *iter, struct hpk_hdr *header) else if (*iter->buf >> 5 == 1) { if (hpk_done != num_decode(&num, iter, 5)) return (hpk_err); - return HPK_ResizeTbl(iter->ctx, num); + return (HPK_ResizeTbl(iter->ctx, num)); } else { return (hpk_err); } diff --git a/bin/varnishtest/vtc_haproxy.c b/bin/varnishtest/vtc_haproxy.c index 82ce237bc..7a54a7b0b 100644 --- a/bin/varnishtest/vtc_haproxy.c +++ b/bin/varnishtest/vtc_haproxy.c @@ -169,11 +169,11 @@ haproxy_cli_tcp_connect(struct vtclog *vl, const char *addr, double tmo, fd = VTCP_open(addr, NULL, tmo, errp); if (fd < 0) - return fd; + return (fd); VTCP_myname(fd, mabuf, sizeof mabuf, mpbuf, sizeof mpbuf); vtc_log(vl, 3, "CLI connected fd %d from %s %s to %s", fd, mabuf, mpbuf, addr); - return fd; + return (fd); } /* @@ -471,7 +471,7 @@ haproxy_cli_new(struct haproxy *h) hc->rxbuf = malloc(hc->rxbuf_sz); AN(hc->rxbuf); - return hc; + return (hc); } static void @@ -735,7 +735,7 @@ haproxy_build_backends(struct haproxy *h, const char *vsb_data) s = strdup(vsb_data); if (!s) - return -1; + return (-1); p = s; while (1) { diff --git a/bin/varnishtest/vtc_http.c b/bin/varnishtest/vtc_http.c index 3e928cd49..0c772f50d 100644 --- a/bin/varnishtest/vtc_http.c +++ b/bin/varnishtest/vtc_http.c @@ -305,33 +305,33 @@ cmd_var_resolve(struct http *hp, char *spec) { char **hh, *hdr; if (!strcmp(spec, "remote.ip")) - return(hp->rem_ip); + return (hp->rem_ip); if (!strcmp(spec, "remote.port")) - return(hp->rem_port); + return (hp->rem_port); if (!strcmp(spec, "remote.path")) - return(hp->rem_path); + return (hp->rem_path); if (!strcmp(spec, "req.method")) - return(hp->req[0]); + return (hp->req[0]); if (!strcmp(spec, "req.url")) - return(hp->req[1]); + return (hp->req[1]); if (!strcmp(spec, "req.proto")) - return(hp->req[2]); + return (hp->req[2]); if (!strcmp(spec, "resp.proto")) - return(hp->resp[0]); + return (hp->resp[0]); if (!strcmp(spec, "resp.status")) - return(hp->resp[1]); + return (hp->resp[1]); if (!strcmp(spec, "resp.reason")) - return(hp->resp[2]); + return (hp->resp[2]); if (!strcmp(spec, "resp.chunklen")) - return(hp->chunklen); + return (hp->chunklen); if (!strcmp(spec, "req.bodylen")) - return(hp->bodylen); + return (hp->bodylen); if (!strcmp(spec, "req.body")) - return(hp->body != NULL ? hp->body : spec); + return (hp->body != NULL ? hp->body : spec); if (!strcmp(spec, "resp.bodylen")) - return(hp->bodylen); + return (hp->bodylen); if (!strcmp(spec, "resp.body")) - return(hp->body != NULL ? hp->body : spec); + return (hp->body != NULL ? hp->body : spec); if (!strncmp(spec, "req.http.", 9)) { hh = hp->req; hdr = spec + 9; diff --git a/bin/varnishtest/vtc_http2.c b/bin/varnishtest/vtc_http2.c index e942bab17..cb15ebe82 100644 --- a/bin/varnishtest/vtc_http2.c +++ b/bin/varnishtest/vtc_http2.c @@ -881,7 +881,7 @@ find_header(const struct hpk_hdr *h, const char *k) int kl = strlen(k); while (h->t) { if (kl == h->key.len && !strncasecmp(h->key.ptr, k, kl)) - return h->value.ptr; + return (h->value.ptr); h++; } return (NULL); diff --git a/bin/varnishtest/vtc_main.c b/bin/varnishtest/vtc_main.c index 0f4b144d2..f90a92973 100644 --- a/bin/varnishtest/vtc_main.c +++ b/bin/varnishtest/vtc_main.c @@ -639,7 +639,7 @@ read_file(const char *fn, int ntest) " 'vtest' or 'varnishtest'\n", fn); free(p); vtc_skip++; - return(2); + return (2); } ALLOC_OBJ(tp, TST_MAGIC); AN(tp); @@ -647,7 +647,7 @@ read_file(const char *fn, int ntest) tp->script = p; tp->ntodo = ntest; VTAILQ_INSERT_TAIL(&tst_head, tp, list); - return(0); + return (0); } /********************************************************************** diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c index 02f6da13f..90e4d403d 100644 --- a/bin/varnishtest/vtc_varnish.c +++ b/bin/varnishtest/vtc_varnish.c @@ -869,10 +869,10 @@ do_expect_cb(void *priv, const struct VSC_point * const pt) struct stat_priv *sp = priv; if (pt == NULL) - return(0); + return (0); if (fnmatch(sp->target_pattern, pt->name, 0)) - return(0); + return (0); AZ(strcmp(pt->ctype, "uint64_t")); AN(pt->ptr); From dridi.boukelmoune at gmail.com Wed Mar 13 14:16:07 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 13 Mar 2019 14:16:07 +0000 (UTC) Subject: [master] 6d32bea6d Drop Python 2 for our docs dependencies too Message-ID: <20190313141607.19CD4931AA@lists.varnish-cache.org> commit 6d32bea6d95077a6dc2d9a360b244f8a8bd28d02 Author: Dridi Boukelmoune Date: Wed Mar 13 15:14:18 2019 +0100 Drop Python 2 for our docs dependencies too diff --git a/configure.ac b/configure.ac index fbe5032ce..36102cb30 100644 --- a/configure.ac +++ b/configure.ac @@ -41,7 +41,7 @@ AC_ARG_WITH([rst2man], AS_HELP_STRING([--with-rst2man=PATH], [Location of rst2man (auto)]), [RST2MAN="$withval"], AC_CHECK_PROGS(RST2MAN, - [rst2man rst2man.py rst2man-3.6 rst2man-2.7], + [rst2man rst2man.py rst2man-3.6 rst2man-3], [no])) if test "x$RST2MAN" = "xno"; then AC_MSG_ERROR( @@ -52,7 +52,7 @@ AC_ARG_WITH([sphinx-build], AS_HELP_STRING([--with-sphinx-build=PATH], [Location of sphinx-build (auto)]), [SPHINX="$withval"], AC_CHECK_PROGS(SPHINX, - [sphinx-build sphinx-build-3.6 sphinx-build-2.7], + [sphinx-build sphinx-build-3.6 sphinx-build-3], [no])) if test "x$SPHINX" = "xno"; then AC_MSG_ERROR( From dridi.boukelmoune at gmail.com Wed Mar 13 15:12:10 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 13 Mar 2019 15:12:10 +0000 (UTC) Subject: [master] e4941d2e0 Typo Message-ID: <20190313151210.43CA995AB2@lists.varnish-cache.org> commit e4941d2e0959e12d76377558f7f648be1a6042e7 Author: Dridi Boukelmoune Date: Wed Mar 13 16:10:08 2019 +0100 Typo diff --git a/lib/libvcc/vcc_vmod.c b/lib/libvcc/vcc_vmod.c index 225560d25..a455bbb8e 100644 --- a/lib/libvcc/vcc_vmod.c +++ b/lib/libvcc/vcc_vmod.c @@ -263,7 +263,7 @@ vcc_ParseImport(struct vcc *tl) VSB_printf(tl->sb, "\tFile name: %s\n", fnp); VSB_printf(tl->sb, "\tVMOD wants ABI version %u.%u\n", vmd->vrt_major, vmd->vrt_minor); - VSB_printf(tl->sb, "\tvarnishd provices ABI version %u.%u\n", + VSB_printf(tl->sb, "\tvarnishd provides ABI version %u.%u\n", VRT_MAJOR_VERSION, VRT_MINOR_VERSION); vcc_ErrWhere(tl, mod); return; From fgsch at lodoss.net Wed Mar 13 15:16:08 2019 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Wed, 13 Mar 2019 15:16:08 +0000 (UTC) Subject: [master] a7b80c7c2 Don't assume input buffer is valid after the call Message-ID: <20190313151608.6657295DAF@lists.varnish-cache.org> commit a7b80c7c277e1435bdab05fa2313b8fdafb2dc31 Author: Federico G. Schwindt Date: Wed Mar 13 14:46:59 2019 +0000 Don't assume input buffer is valid after the call Patch by @phk, test by yours truly. diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index df30f0e8c..8bea0e81d 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -537,7 +537,7 @@ ved_pretend_gzip_bytes(struct req *req, enum vdp_action act, void **priv, l -= lx; p += lx; } - /* buf2 is local, have to flush */ + /* buf1 & buf2 is local, have to flush */ return (ved_bytes(req, ecx, VDP_FLUSH, NULL, 0)); } @@ -609,8 +609,6 @@ ved_gzgz_bytes(struct req *req, enum vdp_action act, void **priv, ssize_t l; CAST_OBJ_NOTNULL(foo, *priv, VED_FOO_MAGIC); - (void)req; - (void)act; pp = ptr; if (len > 0) { /* Skip over the GZIP header */ @@ -630,7 +628,7 @@ ved_gzgz_bytes(struct req *req, enum vdp_action act, void **priv, if (dl > 0) { if (dl > len) dl = len; - if (ved_bytes(req, foo->ecx, VDP_NULL, pp, dl)) + if (ved_bytes(req, foo->ecx, act, pp, dl)) return(-1); foo->ll += dl; len -= dl; @@ -641,7 +639,7 @@ ved_gzgz_bytes(struct req *req, enum vdp_action act, void **priv, /* Remove the "LAST" bit */ foo->dbits[0] = *pp; foo->dbits[0] &= ~(1U << (foo->last & 7)); - if (ved_bytes(req, foo->ecx, VDP_NULL, foo->dbits, 1)) + if (ved_bytes(req, foo->ecx, act, foo->dbits, 1)) return (-1); foo->ll++; len--; @@ -653,7 +651,7 @@ ved_gzgz_bytes(struct req *req, enum vdp_action act, void **priv, if (dl > 0) { if (dl > len) dl = len; - if (ved_bytes(req, foo->ecx, VDP_NULL, pp, dl)) + if (ved_bytes(req, foo->ecx, act, pp, dl)) return (-1); foo->ll += dl; len -= dl; @@ -715,8 +713,7 @@ ved_gzgz_bytes(struct req *req, enum vdp_action act, void **priv, default: WRONG("compiler must be broken"); } - if (ved_bytes(req, foo->ecx, - VDP_NULL, foo->dbits + 1, foo->lpad)) + if (ved_bytes(req, foo->ecx, act, foo->dbits + 1, foo->lpad)) return (-1); } if (len > 0) { diff --git a/bin/varnishtest/tests/e00032.vtc b/bin/varnishtest/tests/e00032.vtc new file mode 100644 index 000000000..96c9e8deb --- /dev/null +++ b/bin/varnishtest/tests/e00032.vtc @@ -0,0 +1,25 @@ +varnishtest "Exercise ESI+gzip in pass mode" + +server s1 { + rxreq + txresp -gzipbody {} + rxreq + txresp -gzipbody "foo" +} -start + +varnish v1 -vcl+backend { + sub vcl_recv { + return (pass); + } + sub vcl_backend_response { + set beresp.do_esi = true; + } +} -start + +client c1 { + txreq -hdr "Accept-Encoding: gzip" + rxresp + expect resp.status == 200 + gunzip + expect resp.bodylen == 3 +} -run From nils.goroll at uplex.de Thu Mar 14 11:01:02 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Thu, 14 Mar 2019 11:01:02 +0000 (UTC) Subject: [master] d0b398738 ensure columns are separated by at least one space Message-ID: <20190314110102.36F3160593@lists.varnish-cache.org> commit d0b398738eb615969ae4f92095b130949b0006d7 Author: Nils Goroll Date: Thu Mar 14 11:57:00 2019 +0100 ensure columns are separated by at least one space Fixes #2943 diff --git a/lib/libvarnish/vte.c b/lib/libvarnish/vte.c index c2f49ec51..b0e2883d0 100644 --- a/lib/libvarnish/vte.c +++ b/lib/libvarnish/vte.c @@ -99,6 +99,8 @@ VCLI_VTE(struct cli *cli, struct vsb **src, int width) nsp = (width - (w_ln)) / n_col; if (nsp > 3) nsp = 3; + if (nsp < 1) + nsp = 1; cc = 0; wc = 0; From nils.goroll at uplex.de Thu Mar 14 13:57:08 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Thu, 14 Mar 2019 13:57:08 +0000 (UTC) Subject: [master] e39883d54 trivial polish Message-ID: <20190314135708.707CC63DEA@lists.varnish-cache.org> commit e39883d54685d4ef8a5f792d397560c5709a1763 Author: Nils Goroll Date: Thu Mar 14 14:55:40 2019 +0100 trivial polish diff --git a/lib/libvarnish/vte.c b/lib/libvarnish/vte.c index b0e2883d0..f71a147b8 100644 --- a/lib/libvarnish/vte.c +++ b/lib/libvarnish/vte.c @@ -99,7 +99,7 @@ VCLI_VTE(struct cli *cli, struct vsb **src, int width) nsp = (width - (w_ln)) / n_col; if (nsp > 3) nsp = 3; - if (nsp < 1) + else if (nsp < 1) nsp = 1; cc = 0; From geoff at uplex.de Thu Mar 14 16:34:07 2019 From: geoff at uplex.de (Geoff Simmons) Date: Thu, 14 Mar 2019 16:34:07 +0000 (UTC) Subject: [master] 156f91377 Mention VTest in "Changes" for 6.2. Message-ID: <20190314163407.E241B903D6@lists.varnish-cache.org> commit 156f91377b969f7aea03d64dbba5c75f7f4ea7ad Author: Geoff Simmons Date: Thu Mar 14 17:33:29 2019 +0100 Mention VTest in "Changes" for 6.2. diff --git a/doc/sphinx/whats-new/changes-6.2.rst b/doc/sphinx/whats-new/changes-6.2.rst index 56cf52bf3..f6db5c625 100644 --- a/doc/sphinx/whats-new/changes-6.2.rst +++ b/doc/sphinx/whats-new/changes-6.2.rst @@ -221,6 +221,14 @@ When :ref:`varnishtest(1)` is invoked with either of the ``-L`` or generated from VCL can also be inspected after a test. By default, the temporary directory is deleted after each test. +Since around the time of the last release, we have begun the project +`VTest`_, which is adapted from :ref:`varnishtest(1)`, but is made +available as a stand-alone program useful for testing various HTTP +clients, servers and proxies (not just Varnish). But for the time +being, we still use :ref:`varnishtest(1)` for our own testing. + +.. _VTest: https://github.com/vtest/VTest + Changes for developers and VMOD authors ======================================= From geoff at uplex.de Thu Mar 14 16:39:09 2019 From: geoff at uplex.de (Geoff Simmons) Date: Thu, 14 Mar 2019 16:39:09 +0000 (UTC) Subject: [master] c83e116b3 Remove the "future release" notice in user release docs for 6.2. Message-ID: <20190314163909.41279906B3@lists.varnish-cache.org> commit c83e116b3f0a598d059ae1a9b300761d3b41491e Author: Geoff Simmons Date: Thu Mar 14 17:36:46 2019 +0100 Remove the "future release" notice in user release docs for 6.2. Unless we think of something else to add, this version of the docs is suitable for the 6.2 release. diff --git a/doc/sphinx/whats-new/changes-6.2.rst b/doc/sphinx/whats-new/changes-6.2.rst index f6db5c625..491408cc5 100644 --- a/doc/sphinx/whats-new/changes-6.2.rst +++ b/doc/sphinx/whats-new/changes-6.2.rst @@ -1,7 +1,3 @@ -**Note: This is a working document for a future release, with running -updates for changes in the development branch. For changes in the -released versions of Varnish, see:** :ref:`whats-new-index` - .. _whatsnew_changes_2019_03: %%%%%%%%%%%%%%%%%%%%%% diff --git a/doc/sphinx/whats-new/index.rst b/doc/sphinx/whats-new/index.rst index dbb145b44..424c6685d 100644 --- a/doc/sphinx/whats-new/index.rst +++ b/doc/sphinx/whats-new/index.rst @@ -11,10 +11,6 @@ entail. Varnish 6.2 ----------- -**Note: These are working documents for a future release, with running -updates for changes in the development branch. For changes in the -released versions of Varnish, see the chapters listed below.** - .. toctree:: :maxdepth: 2 diff --git a/doc/sphinx/whats-new/upgrading-6.2.rst b/doc/sphinx/whats-new/upgrading-6.2.rst index 097dbfb44..089bc55b2 100644 --- a/doc/sphinx/whats-new/upgrading-6.2.rst +++ b/doc/sphinx/whats-new/upgrading-6.2.rst @@ -1,7 +1,3 @@ -**Note: This is a working document for a future release, with running -updates for changes in the development branch. For changes in the -released versions of Varnish, see:** :ref:`whats-new-index` - .. _whatsnew_upgrading_2019_03: %%%%%%%%%%%%%%%%%%%%%%%% From fgsch at lodoss.net Thu Mar 14 20:13:06 2019 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Thu, 14 Mar 2019 20:13:06 +0000 (UTC) Subject: [master] a71e2a0a0 Allow to override vmodtoolargs Message-ID: <20190314201307.1A89A9A131@lists.varnish-cache.org> commit a71e2a0a0ee53c938970f896b26f3728b398600c Author: Federico G. Schwindt Date: Thu Mar 14 20:07:58 2019 +0000 Allow to override vmodtoolargs diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py index 708d750e8..1b40b10b8 100755 --- a/lib/libvcc/vmodtool.py +++ b/lib/libvcc/vmodtool.py @@ -55,7 +55,7 @@ AM_CPPFLAGS = \\ vmoddir = $(pkglibdir)/vmods vmodtool = $(top_srcdir)/lib/libvcc/vmodtool.py -vmodtoolargs = --strict --boilerplate +vmodtoolargs ?= --strict --boilerplate vmod_LTLIBRARIES = libvmod_XXX.la diff --git a/lib/libvmod_blob/automake_boilerplate.am b/lib/libvmod_blob/automake_boilerplate.am index a761d9336..e3873eb7c 100644 --- a/lib/libvmod_blob/automake_boilerplate.am +++ b/lib/libvmod_blob/automake_boilerplate.am @@ -10,7 +10,7 @@ AM_CPPFLAGS = \ vmoddir = $(pkglibdir)/vmods vmodtool = $(top_srcdir)/lib/libvcc/vmodtool.py -vmodtoolargs = --strict --boilerplate +vmodtoolargs ?= --strict --boilerplate vmod_LTLIBRARIES = libvmod_blob.la diff --git a/lib/libvmod_debug/automake_boilerplate.am b/lib/libvmod_debug/automake_boilerplate.am index db1c206a5..44f1f6691 100644 --- a/lib/libvmod_debug/automake_boilerplate.am +++ b/lib/libvmod_debug/automake_boilerplate.am @@ -10,7 +10,7 @@ AM_CPPFLAGS = \ vmoddir = $(pkglibdir)/vmods vmodtool = $(top_srcdir)/lib/libvcc/vmodtool.py -vmodtoolargs = --strict --boilerplate +vmodtoolargs ?= --strict --boilerplate vmod_LTLIBRARIES = libvmod_debug.la diff --git a/lib/libvmod_directors/automake_boilerplate.am b/lib/libvmod_directors/automake_boilerplate.am index 218c89e4d..f1b6cac7e 100644 --- a/lib/libvmod_directors/automake_boilerplate.am +++ b/lib/libvmod_directors/automake_boilerplate.am @@ -10,7 +10,7 @@ AM_CPPFLAGS = \ vmoddir = $(pkglibdir)/vmods vmodtool = $(top_srcdir)/lib/libvcc/vmodtool.py -vmodtoolargs = --strict --boilerplate +vmodtoolargs ?= --strict --boilerplate vmod_LTLIBRARIES = libvmod_directors.la diff --git a/lib/libvmod_proxy/automake_boilerplate.am b/lib/libvmod_proxy/automake_boilerplate.am index 8f65c6158..683f8b80f 100644 --- a/lib/libvmod_proxy/automake_boilerplate.am +++ b/lib/libvmod_proxy/automake_boilerplate.am @@ -10,7 +10,7 @@ AM_CPPFLAGS = \ vmoddir = $(pkglibdir)/vmods vmodtool = $(top_srcdir)/lib/libvcc/vmodtool.py -vmodtoolargs = --strict --boilerplate +vmodtoolargs ?= --strict --boilerplate vmod_LTLIBRARIES = libvmod_proxy.la diff --git a/lib/libvmod_purge/automake_boilerplate.am b/lib/libvmod_purge/automake_boilerplate.am index 04278675c..ab6b314f3 100644 --- a/lib/libvmod_purge/automake_boilerplate.am +++ b/lib/libvmod_purge/automake_boilerplate.am @@ -10,7 +10,7 @@ AM_CPPFLAGS = \ vmoddir = $(pkglibdir)/vmods vmodtool = $(top_srcdir)/lib/libvcc/vmodtool.py -vmodtoolargs = --strict --boilerplate +vmodtoolargs ?= --strict --boilerplate vmod_LTLIBRARIES = libvmod_purge.la diff --git a/lib/libvmod_std/automake_boilerplate.am b/lib/libvmod_std/automake_boilerplate.am index 2dda52b09..3538cfdd5 100644 --- a/lib/libvmod_std/automake_boilerplate.am +++ b/lib/libvmod_std/automake_boilerplate.am @@ -10,7 +10,7 @@ AM_CPPFLAGS = \ vmoddir = $(pkglibdir)/vmods vmodtool = $(top_srcdir)/lib/libvcc/vmodtool.py -vmodtoolargs = --strict --boilerplate +vmodtoolargs ?= --strict --boilerplate vmod_LTLIBRARIES = libvmod_std.la diff --git a/lib/libvmod_unix/automake_boilerplate.am b/lib/libvmod_unix/automake_boilerplate.am index d6db5e354..967bffec8 100644 --- a/lib/libvmod_unix/automake_boilerplate.am +++ b/lib/libvmod_unix/automake_boilerplate.am @@ -10,7 +10,7 @@ AM_CPPFLAGS = \ vmoddir = $(pkglibdir)/vmods vmodtool = $(top_srcdir)/lib/libvcc/vmodtool.py -vmodtoolargs = --strict --boilerplate +vmodtoolargs ?= --strict --boilerplate vmod_LTLIBRARIES = libvmod_unix.la diff --git a/lib/libvmod_vtc/automake_boilerplate.am b/lib/libvmod_vtc/automake_boilerplate.am index 93b78e7dc..d82f03a78 100644 --- a/lib/libvmod_vtc/automake_boilerplate.am +++ b/lib/libvmod_vtc/automake_boilerplate.am @@ -10,7 +10,7 @@ AM_CPPFLAGS = \ vmoddir = $(pkglibdir)/vmods vmodtool = $(top_srcdir)/lib/libvcc/vmodtool.py -vmodtoolargs = --strict --boilerplate +vmodtoolargs ?= --strict --boilerplate vmod_LTLIBRARIES = libvmod_vtc.la From fgsch at lodoss.net Thu Mar 14 20:13:07 2019 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Thu, 14 Mar 2019 20:13:07 +0000 (UTC) Subject: [master] db006779d Pass the correct size Message-ID: <20190314201307.2EC5A9A134@lists.varnish-cache.org> commit db006779d1c3256858fa8ae6a0d43cf303e43803 Author: Federico G. Schwindt Date: Thu Mar 14 20:09:41 2019 +0000 Pass the correct size Reported by coverity. diff --git a/bin/varnishd/cache/cache_acceptor.c b/bin/varnishd/cache/cache_acceptor.c index f80d4b2f4..8300d1b5d 100644 --- a/bin/varnishd/cache/cache_acceptor.c +++ b/bin/varnishd/cache/cache_acceptor.c @@ -518,7 +518,7 @@ vca_accept_task(struct worker *wrk, void *arg) strcpy(lport, "0"); } else { VTCP_myname(ls->sock, laddr, VTCP_ADDRBUFSIZE, - lport, VTCP_ADDRBUFSIZE); + lport, VTCP_PORTBUFSIZE); } VSL(SLT_SessError, 0, "%s %s %s %d %d %s", From fgsch at lodoss.net Thu Mar 14 21:07:08 2019 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Thu, 14 Mar 2019 21:07:08 +0000 (UTC) Subject: [master] 05d0b9c14 Silent coverity Message-ID: <20190314210708.8B52E9C59F@lists.varnish-cache.org> commit 05d0b9c1420bd77944ee82aed2639f9bf810202e Author: Federico G. Schwindt Date: Thu Mar 14 21:03:31 2019 +0000 Silent coverity diff --git a/lib/libvmod_debug/vmod_debug.c b/lib/libvmod_debug/vmod_debug.c index 17454ba49..6bbdbda1b 100644 --- a/lib/libvmod_debug/vmod_debug.c +++ b/lib/libvmod_debug/vmod_debug.c @@ -689,6 +689,7 @@ xyzzy_catflap(VRT_CTX, VCL_ENUM type) CHECK_OBJ_NOTNULL(req, REQ_MAGIC); XXXAZ(req->vcf); req->vcf = WS_Alloc(req->ws, sizeof *req->vcf); + AN(req->vcf); INIT_OBJ(req->vcf, VCF_MAGIC); if (type == VENUM(first) || type == VENUM(miss)) { req->vcf->func = xyzzy_catflap_simple; From fgsch at lodoss.net Thu Mar 14 21:07:08 2019 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Thu, 14 Mar 2019 21:07:08 +0000 (UTC) Subject: [master] c8d216e02 More python3 tweaking Message-ID: <20190314210708.A6E6A9C5A4@lists.varnish-cache.org> commit c8d216e025617fee27cbaf3643a12dd55ed8e177 Author: Federico G. Schwindt Date: Thu Mar 14 21:04:05 2019 +0000 More python3 tweaking diff --git a/configure.ac b/configure.ac index 36102cb30..78e47a8e4 100644 --- a/configure.ac +++ b/configure.ac @@ -45,7 +45,7 @@ AC_ARG_WITH([rst2man], [no])) if test "x$RST2MAN" = "xno"; then AC_MSG_ERROR( - [rst2man is needed to build Varnish, please install python-docutils.]) + [rst2man is needed to build Varnish, please install python3-docutils.]) fi AC_ARG_WITH([sphinx-build], @@ -56,7 +56,7 @@ AC_ARG_WITH([sphinx-build], [no])) if test "x$SPHINX" = "xno"; then AC_MSG_ERROR( - [sphinx-build is needed to build Varnish, please install python-sphinx.]) + [sphinx-build is needed to build Varnish, please install python3-sphinx.]) fi AC_ARG_WITH([rst2html], From dridi.boukelmoune at gmail.com Thu Mar 14 21:12:07 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 14 Mar 2019 21:12:07 +0000 (UTC) Subject: [master] 872543998 We definitely no longer support Python 2 Message-ID: <20190314211207.8CC099CE78@lists.varnish-cache.org> commit 8725439982af486a025f42fb919b62beea4406af Author: Dridi Boukelmoune Date: Thu Mar 14 22:07:28 2019 +0100 We definitely no longer support Python 2 I'm keeping that information in both the changes and upgrading documents to increase the chances that people will notice it. The imprecise "changes" statement predated the decision to drop Python 2 entirely and was spotted by Geoff. diff --git a/doc/sphinx/whats-new/changes-6.2.rst b/doc/sphinx/whats-new/changes-6.2.rst index 491408cc5..98c91df0b 100644 --- a/doc/sphinx/whats-new/changes-6.2.rst +++ b/doc/sphinx/whats-new/changes-6.2.rst @@ -228,8 +228,7 @@ being, we still use :ref:`varnishtest(1)` for our own testing. Changes for developers and VMOD authors ======================================= -Python tools that generate code now prefer python 3 over python 2, -when availabale. +Python tools that generate code now require Python 3. .. _whatsnew_changes_director_api_2019_03: diff --git a/doc/sphinx/whats-new/upgrading-6.2.rst b/doc/sphinx/whats-new/upgrading-6.2.rst index 089bc55b2..9d816184c 100644 --- a/doc/sphinx/whats-new/upgrading-6.2.rst +++ b/doc/sphinx/whats-new/upgrading-6.2.rst @@ -163,7 +163,7 @@ For developers and authors of VMODs and API clients Python 3.4 or later is now required to build Varnish, or use scripts installed along with Varnish, such as ``vmodtool.py`` to build VMODs or other Varnish artifacts. Python 2 is no longer supported, and this -support will likely be dropped from stable branches too. +support will likely be dropped in a future 6.0 LTS release too. The VRT API has been bumped to version 9.0. Changes include: From geoff at uplex.de Thu Mar 14 21:49:09 2019 From: geoff at uplex.de (Geoff Simmons) Date: Thu, 14 Mar 2019 21:49:09 +0000 (UTC) Subject: [master] 2897c7e47 Mention VMOD immutability in "Upgrading for developers". Message-ID: <20190314214909.8DF419DAB6@lists.varnish-cache.org> commit 2897c7e477ee70184189bed56bf74f24ebc3bb2a Author: Geoff Simmons Date: Thu Mar 14 22:48:05 2019 +0100 Mention VMOD immutability in "Upgrading for developers". diff --git a/doc/sphinx/whats-new/upgrading-6.2.rst b/doc/sphinx/whats-new/upgrading-6.2.rst index 9d816184c..011bd875a 100644 --- a/doc/sphinx/whats-new/upgrading-6.2.rst +++ b/doc/sphinx/whats-new/upgrading-6.2.rst @@ -187,4 +187,10 @@ defines macros for prepending the vmod prefix, and for naming enums and argument structs. For details, see the `change log`_, and examine the contents of ``vcc_if.h`` after generation. +Going forward, we will adhere to the principle that data returned by +VMOD methods and functions are immutable. This is now enforced in some +places by use of the ``const`` modifier. A VMOD is free to do as it +sees fit within its own implementation, but if you attempt to change +something returned by another VMOD, the results are undefined. + *eof* From fgsch at lodoss.net Thu Mar 14 22:13:06 2019 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Thu, 14 Mar 2019 22:13:06 +0000 (UTC) Subject: [master] e7d624664 First stab at getting coverity running Message-ID: <20190314221306.8F7F79E79F@lists.varnish-cache.org> commit e7d6246645ba316ac05cc0e5abc9b2e68ba71587 Author: Federico G. Schwindt Date: Thu Mar 14 22:08:52 2019 +0000 First stab at getting coverity running diff --git a/.travis.yml b/.travis.yml index c5d4c8931..4476939c9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,6 @@ --- language: c + matrix: fast_finish: true include: @@ -19,6 +20,7 @@ matrix: allow_failures: - os: osx - env: SAN_FLAGS="--enable-asan --enable-ubsan" + addons: apt: packages: @@ -29,13 +31,15 @@ addons: - docutils - nghttp2 - sphinx-doc + notifications: irc: channels: - "irc.linpro.no#varnish-hacking" on_success: change use_notice: true -before_install: + +before_script: - | if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export PATH="/usr/local/opt/sphinx-doc/bin:$PATH" @@ -48,6 +52,7 @@ before_install: fi - ./autogen.sh - ./configure ${CONFIGURE_ARGS} + script: - | if [[ "$TRAVIS_PULL_REQUEST" != "false" ]]; then @@ -55,3 +60,25 @@ script: else make -j3 check VERBOSE=1 fi + +jobs: + include: + - stage: coverity + if: type = cron + env: + - secure: "TndnHrwJk9FRSuVQWUk+ZrRc0jcNc0PW3TnvbRicIIwvYSLkMV5Y1tCQ5Jq/P98DA48/N/gf9DCAiFkxrNSKVeOY70FKgHYWlS130GhTv7r0c8zd+CdEXNORclcbBNV5F3Pli/LxZ+RUImjOfwcIcWV4eYv54Xv7aNFDAaDt4G9QlkSwXykLlZkoWLJQXFbhDBFioT1F1mucD9q9izEEeE+kqO1QH/IfobAq9v7/WrcS38sYI+0WvB1S0ajWuZJgRYqy1bocDNcQd05Vbr9NfAdJ9y+4VTuluZtTUyLxu3/0Tw8mAjHkcpOeNU26r3LnpdRk+5JuOFej/MrCmYRRawVfyvNGtu9RwcMkv8jl48TTs5kTf6UwFqJhe85QSlSi7IszfrE8HfB7B6u8eRr67rqjTr9k/BwEQyoBdK4JElQDj4A1GYHClomxgzmMZnVLvStnAm+IjdNlee4SfY0jj2KfPBd/v6Ms+LGVqNV9NDDKRQdOQD+H52MkIWs5Xu9fU5VaWP+xjFomA9aXex3r5FCssgyQ2P+HtWPdjNEtrkNezzfZ5b+VBVP87RdxfSqkZaRxi6gof0AgeTHWoi7GN1scseiKLxxCI7C0dfQgKrXTN7mZdcED1MMYdiaSI9mlSYQDDUHMQGeY1n3a9D6bUcC/TcmYo524PoTFBZgbbYM=" + before_script: + - curl -s --data token=$COVTOKEN -O coverity_tool.tgz https://scan.coverity.com/download/linux64 + - tar -xf coverity_tool.tgz + - export PATH=$PATH:$(pwd)/cov-analysis-*/bin + script: + - ./autogen.sh + - ./configure + - cov-build --dir cov-int make + - tar -cfz varnish.tgz cov-int + - curl --form token=$COVTOKEN \ + --form email=varnish-dev at varnish-cache.org \ + --form file=@varnish.tgz \ + --form version="$TRAVIS_COMMIT" \ + --form description="$TRAVIS_BRANCH" \ + 'https://scan.coverity.com/builds?project=varnish' From fgsch at lodoss.net Thu Mar 14 22:33:07 2019 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Thu, 14 Mar 2019 22:33:07 +0000 (UTC) Subject: [master] 31ca5f6ee Take two Message-ID: <20190314223307.8DC96A00E8@lists.varnish-cache.org> commit 31ca5f6ee030eed854fce3dce987a9f9d1f19575 Author: Federico G. Schwindt Date: Thu Mar 14 22:31:44 2019 +0000 Take two diff --git a/.travis.yml b/.travis.yml index 4476939c9..d26586e8e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,57 +1,15 @@ --- language: c -matrix: - fast_finish: true - include: - - os: linux - dist: xenial - compiler: gcc - - os: linux - dist: xenial - compiler: clang - - os: linux - dist: xenial - compiler: clang - env: SAN_FLAGS="--enable-asan --enable-ubsan" - - os: osx - osx_image: xcode10.1 - compiler: clang - allow_failures: - - os: osx - - env: SAN_FLAGS="--enable-asan --enable-ubsan" - addons: apt: packages: - python3-docutils - python3-sphinx - homebrew: - packages: - - docutils - - nghttp2 - - sphinx-doc - -notifications: - irc: - channels: - - "irc.linpro.no#varnish-hacking" - on_success: change - use_notice: true before_script: - - | - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then - export PATH="/usr/local/opt/sphinx-doc/bin:$PATH" - 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 - export TSAN_OPTIONS=abort_on_error=1,halt_on_error=1,use_sigaltstack=0,suppressions=$(pwd)/tools/tsan.suppr - export UBSAN_OPTIONS=halt_on_error=1,print_stacktrace=1,use_sigaltstack=0,suppressions=$(pwd)/tools/ubsan.suppr - fi - ./autogen.sh - - ./configure ${CONFIGURE_ARGS} + - ./configure script: - | @@ -63,6 +21,41 @@ script: jobs: include: + - stage: test + os: linux + dist: xenial + compiler: gcc + - stage: test + os: linux + dist: xenial + compiler: clang + - stage: test + os: linux + dist: xenial + compiler: clang + env: SAN_BUILD=1 + before_script: + - | + 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 + export TSAN_OPTIONS=abort_on_error=1,halt_on_error=1,use_sigaltstack=0,suppressions=$(pwd)/tools/tsan.suppr + export UBSAN_OPTIONS=halt_on_error=1,print_stacktrace=1,use_sigaltstack=0,suppressions=$(pwd)/tools/ubsan.suppr + - ./autogen.sh + - ./configure --enable-developer-warnings --enable-debugging-symbols --disable-stack-protector --with-persistent-storage --enable-asan --enable-ubsan + - stage: test + os: osx + osx_image: xcode10.1 + compiler: clang + addons: + homebrew: + packages: + - docutils + - nghttp2 + - sphinx-doc + before_script: + - export PATH="/usr/local/opt/sphinx-doc/bin:$PATH" + - ./autogen.sh + - ./configure - stage: coverity if: type = cron env: @@ -82,3 +75,15 @@ jobs: --form version="$TRAVIS_COMMIT" \ --form description="$TRAVIS_BRANCH" \ 'https://scan.coverity.com/builds?project=varnish' + fast_finish: true + allow_failures: + - os: osx + - env: SAN_BUILD=1 + +notifications: + irc: + channels: + - "irc.linpro.no#varnish-hacking" + on_success: change + use_notice: true + From dridi at varni.sh Thu Mar 14 22:33:26 2019 From: dridi at varni.sh (Dridi Boukelmoune) Date: Thu, 14 Mar 2019 23:33:26 +0100 Subject: [master] e7d624664 First stab at getting coverity running In-Reply-To: <20190314221306.8F7F79E79F@lists.varnish-cache.org> References: <20190314221306.8F7F79E79F@lists.varnish-cache.org> Message-ID: On Thu, Mar 14, 2019 at 11:13 PM Federico G. Schwindt wrote: > > > commit e7d6246645ba316ac05cc0e5abc9b2e68ba71587 > Author: Federico G. Schwindt > Date: Thu Mar 14 22:08:52 2019 +0000 > > First stab at getting coverity running Back when I introduced Coverity Scan support in cashpack I managed to contain the complexity: https://github.com/Dridi/cashpack/blob/master/.travis.yml#L50-L57 The ugly part was that 1) I triggered those on demand by pushing master to a dedicated "coverity_scan" branch and 2) since I have a plethora of jobs in my matrix I wanted to make sure the coverity build happened only once: https://github.com/Dridi/cashpack/blob/master/.travis.yml#L58-L59 And I think it's an opportunity to have a travis/ subdirectory in our tools/ directory to offload some of the yaml file complexity to external scripts. It worked like a charm for me with vmod-querystring: https://github.com/Dridi/libvmod-querystring/blob/master/.travis.yml#L59-L61 https://github.com/Dridi/libvmod-querystring/tree/master/travis If I needed to redo it today, I would use a Travis cron build instead of a dedicated branch. The mechanic to detect whether it's a cron job or a dedicated branch is basically the same: inspect your environment. I do this to run weekly CI against master instead of my minimum required version: https://github.com/Dridi/libvmod-querystring/blob/master/travis/install_varnish.sh And that's how I'm informed when something lands in master and breaks downstream. (VRT, vmodtool, new varnish dependencies...) HTH Dridi From fgsch at lodoss.net Thu Mar 14 22:50:08 2019 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Thu, 14 Mar 2019 22:50:08 +0000 (UTC) Subject: [master] 2491883a3 More tweaking Message-ID: <20190314225008.E705FA097B@lists.varnish-cache.org> commit 2491883a360c4404c2ab5933a62e94a5b43accca Author: Federico G. Schwindt Date: Thu Mar 14 22:48:48 2019 +0000 More tweaking diff --git a/.travis.yml b/.travis.yml index d26586e8e..fbf0c9b85 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,14 +22,17 @@ script: jobs: include: - stage: test + if: type != cron os: linux dist: xenial compiler: gcc - stage: test + if: type != cron os: linux dist: xenial compiler: clang - stage: test + if: type != cron os: linux dist: xenial compiler: clang @@ -43,6 +46,7 @@ jobs: - ./autogen.sh - ./configure --enable-developer-warnings --enable-debugging-symbols --disable-stack-protector --with-persistent-storage --enable-asan --enable-ubsan - stage: test + if: type != cron os: osx osx_image: xcode10.1 compiler: clang @@ -77,8 +81,8 @@ jobs: 'https://scan.coverity.com/builds?project=varnish' fast_finish: true allow_failures: - - os: osx - - env: SAN_BUILD=1 + - os: osx + - env: SAN_BUILD=1 notifications: irc: From fgsch at lodoss.net Thu Mar 14 23:18:07 2019 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Thu, 14 Mar 2019 23:18:07 +0000 (UTC) Subject: [master] b5a29eb6a Appease coverity Message-ID: <20190314231807.51F3DA138C@lists.varnish-cache.org> commit b5a29eb6a8d3ff39d1db4ee18af8bd0373796195 Author: Federico G. Schwindt Date: Thu Mar 14 23:12:49 2019 +0000 Appease coverity diff --git a/bin/varnishtest/vtc_haproxy.c b/bin/varnishtest/vtc_haproxy.c index 7a54a7b0b..a3a5ed21e 100644 --- a/bin/varnishtest/vtc_haproxy.c +++ b/bin/varnishtest/vtc_haproxy.c @@ -832,6 +832,7 @@ haproxy_write_conf(struct haproxy *h) vsb = macro_expand(h->vl, VSB_data(h->cfg_vsb)); AN(vsb); + assert(VSB_len(vsb) >= 0); vtc_dump(h->vl, 4, "conf", VSB_data(vsb), VSB_len(vsb)); if (VFIL_writefile(h->workdir, h->cfg_fn, From fgsch at lodoss.net Thu Mar 14 23:23:00 2019 From: fgsch at lodoss.net (Federico Schwindt) Date: Thu, 14 Mar 2019 23:23:00 +0000 Subject: [master] e7d624664 First stab at getting coverity running In-Reply-To: References: <20190314221306.8F7F79E79F@lists.varnish-cache.org> Message-ID: I personally like to have everything in plain sight and I really like how it turned. Running coverity in a cron was the idea and it's how is implemented after the second commit. On Thu, Mar 14, 2019 at 10:34 PM Dridi Boukelmoune wrote: > On Thu, Mar 14, 2019 at 11:13 PM Federico G. Schwindt > wrote: > > > > > > commit e7d6246645ba316ac05cc0e5abc9b2e68ba71587 > > Author: Federico G. Schwindt > > Date: Thu Mar 14 22:08:52 2019 +0000 > > > > First stab at getting coverity running > > Back when I introduced Coverity Scan support in cashpack I managed to > contain the complexity: > > https://github.com/Dridi/cashpack/blob/master/.travis.yml#L50-L57 > > The ugly part was that 1) I triggered those on demand by pushing > master to a dedicated "coverity_scan" branch and 2) since I have a > plethora of jobs in my matrix I wanted to make sure the coverity build > happened only once: > > https://github.com/Dridi/cashpack/blob/master/.travis.yml#L58-L59 > > And I think it's an opportunity to have a travis/ subdirectory in our > tools/ directory to offload some of the yaml file complexity to > external scripts. It worked like a charm for me with vmod-querystring: > > > https://github.com/Dridi/libvmod-querystring/blob/master/.travis.yml#L59-L61 > https://github.com/Dridi/libvmod-querystring/tree/master/travis > > If I needed to redo it today, I would use a Travis cron build instead > of a dedicated branch. The mechanic to detect whether it's a cron > job or a dedicated branch is basically the same: inspect your > environment. > > I do this to run weekly CI against master instead of my minimum > required version: > > > https://github.com/Dridi/libvmod-querystring/blob/master/travis/install_varnish.sh > > And that's how I'm informed when something lands in master and > breaks downstream. (VRT, vmodtool, new varnish dependencies...) > > HTH > > > > Dridi > -------------- next part -------------- An HTML attachment was scrubbed... URL: From fgsch at lodoss.net Thu Mar 14 23:50:09 2019 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Thu, 14 Mar 2019 23:50:09 +0000 (UTC) Subject: [master] 5de9bc4f4 This test does not need dns Message-ID: <20190314235009.91A0EA20E9@lists.varnish-cache.org> commit 5de9bc4f498318307067735333cf15b70ba34b5a Author: Federico G. Schwindt Date: Thu Mar 14 23:35:50 2019 +0000 This test does not need dns diff --git a/bin/varnishtest/tests/v00016.vtc b/bin/varnishtest/tests/v00016.vtc index a53bcc579..e49e0470b 100644 --- a/bin/varnishtest/tests/v00016.vtc +++ b/bin/varnishtest/tests/v00016.vtc @@ -2,8 +2,6 @@ varnishtest "Various VCL compiler coverage tests" shell "true > ${tmpdir}/_varnishtest_empty_file" -feature dns - varnish v1 -vcl { backend b { .host = "127.0.0.1"; } include "${tmpdir}/_varnishtest_empty_file" ; From fgsch at lodoss.net Thu Mar 14 23:50:09 2019 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Thu, 14 Mar 2019 23:50:09 +0000 (UTC) Subject: [master] 0fc5c76b4 Move this around to avoid mistakes Message-ID: <20190314235009.A6592A20EC@lists.varnish-cache.org> commit 0fc5c76b487cd22e00d8e9ae953e4eb3eee2af47 Author: Federico G. Schwindt Date: Thu Mar 14 23:37:27 2019 +0000 Move this around to avoid mistakes diff --git a/bin/varnishtest/tests/p00000.vtc b/bin/varnishtest/tests/p00000.vtc index e3d23029e..05c308215 100644 --- a/bin/varnishtest/tests/p00000.vtc +++ b/bin/varnishtest/tests/p00000.vtc @@ -2,6 +2,10 @@ varnishtest "Test Basic persistence" feature persistent_storage +shell -err -expect {-spersistent has been deprecated} { + varnishd -spersistent -f '' +} + server s1 { rxreq txresp diff --git a/bin/varnishtest/tests/u00000.vtc b/bin/varnishtest/tests/u00000.vtc index 5eba11b19..46bc0c013 100644 --- a/bin/varnishtest/tests/u00000.vtc +++ b/bin/varnishtest/tests/u00000.vtc @@ -46,14 +46,6 @@ shell -err -expect {-d makes no sense with -C} "varnishd -C -b 127.0.0.1:80 -d " shell -err -expect {-F makes no sense with -C} "varnishd -C -b 127.0.0.1:80 -F " shell -err -expect {Neither -b nor -f given} { varnishd -n ${tmpdir}/v0 } -# This check is kept last because it may be skipped - -feature persistent_storage - -shell -err -expect {-spersistent has been deprecated} { - varnishd -spersistent -f '' -} - # Test -I and -l arguments (former a00016) shell -err -expect {Only one -I allowed} { @@ -160,3 +152,5 @@ shell -err -expect {Cannot read -f file} { exec varnishd -n ${tmpdir}/v0 -F -a :0 -l2m,3m -f ${tmpdir}/ok1 \ -f ${tmpdir}/bad -f ${tmpdir}/ok2 } + +# varnishd -spersistent is tested in p00000.vtc From fgsch at lodoss.net Fri Mar 15 01:20:09 2019 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Fri, 15 Mar 2019 01:20:09 +0000 (UTC) Subject: [master] 76da81191 More travis fiddling Message-ID: <20190315012009.24BEEA3F94@lists.varnish-cache.org> commit 76da8119139217f4593a48ceb021f13d07d6aae3 Author: Federico G. Schwindt Date: Fri Mar 15 01:18:13 2019 +0000 More travis fiddling diff --git a/.travis.yml b/.travis.yml index fbf0c9b85..54868f05b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,41 +1,37 @@ --- language: c -addons: - apt: - packages: - - python3-docutils - - python3-sphinx - -before_script: - - ./autogen.sh - - ./configure - -script: - - | - if [[ "$TRAVIS_PULL_REQUEST" != "false" ]]; then - make -j3 distcheck VERBOSE=1 - else - make -j3 check VERBOSE=1 - fi - jobs: + allow_failures: + - os: osx + - env: SAN_BUILD=1 + fast_finish: true include: - - stage: test - if: type != cron - os: linux - dist: xenial - compiler: gcc - - stage: test - if: type != cron - os: linux - dist: xenial - compiler: clang - - stage: test + - &test-linux + stage: test if: type != cron os: linux dist: xenial compiler: clang + addons: + apt: + packages: + - nghttp2 + - python3-docutils + - python3-sphinx + before_script: + - ./autogen.sh + - ./configure + script: &script-common + - | + if [[ "$TRAVIS_PULL_REQUEST" != "false" ]]; then + make -j3 distcheck VERBOSE=1 + else + make -j3 check VERBOSE=1 + fi + - <<: *test-linux + compiler: gcc + - <<: *test-linux env: SAN_BUILD=1 before_script: - | @@ -60,14 +56,16 @@ jobs: - export PATH="/usr/local/opt/sphinx-doc/bin:$PATH" - ./autogen.sh - ./configure - - stage: coverity + script: *script-common + - <<: *test-linux + stage: coverity if: type = cron env: - secure: "TndnHrwJk9FRSuVQWUk+ZrRc0jcNc0PW3TnvbRicIIwvYSLkMV5Y1tCQ5Jq/P98DA48/N/gf9DCAiFkxrNSKVeOY70FKgHYWlS130GhTv7r0c8zd+CdEXNORclcbBNV5F3Pli/LxZ+RUImjOfwcIcWV4eYv54Xv7aNFDAaDt4G9QlkSwXykLlZkoWLJQXFbhDBFioT1F1mucD9q9izEEeE+kqO1QH/IfobAq9v7/WrcS38sYI+0WvB1S0ajWuZJgRYqy1bocDNcQd05Vbr9NfAdJ9y+4VTuluZtTUyLxu3/0Tw8mAjHkcpOeNU26r3LnpdRk+5JuOFej/MrCmYRRawVfyvNGtu9RwcMkv8jl48TTs5kTf6UwFqJhe85QSlSi7IszfrE8HfB7B6u8eRr67rqjTr9k/BwEQyoBdK4JElQDj4A1GYHClomxgzmMZnVLvStnAm+IjdNlee4SfY0jj2KfPBd/v6Ms+LGVqNV9NDDKRQdOQD+H52MkIWs5Xu9fU5VaWP+xjFomA9aXex3r5FCssgyQ2P+HtWPdjNEtrkNezzfZ5b+VBVP87RdxfSqkZaRxi6gof0AgeTHWoi7GN1scseiKLxxCI7C0dfQgKrXTN7mZdcED1MMYdiaSI9mlSYQDDUHMQGeY1n3a9D6bUcC/TcmYo524PoTFBZgbbYM=" before_script: - - curl -s --data token=$COVTOKEN -O coverity_tool.tgz https://scan.coverity.com/download/linux64 + - curl --data "token=$COVTOKEN&project=varnish" -o coverity_tool.tgz https://scan.coverity.com/download/linux64 - tar -xf coverity_tool.tgz - - export PATH=$PATH:$(pwd)/cov-analysis-*/bin + - export PATH=$PATH:$(echo $(pwd)/cov-analysis-*/bin) script: - ./autogen.sh - ./configure @@ -79,10 +77,6 @@ jobs: --form version="$TRAVIS_COMMIT" \ --form description="$TRAVIS_BRANCH" \ 'https://scan.coverity.com/builds?project=varnish' - fast_finish: true - allow_failures: - - os: osx - - env: SAN_BUILD=1 notifications: irc: From geoff at uplex.de Fri Mar 15 06:28:07 2019 From: geoff at uplex.de (Geoff Simmons) Date: Fri, 15 Mar 2019 06:28:07 +0000 (UTC) Subject: [master] 4bdf4ef8e Doc polish and grammar OCD. Message-ID: <20190315062807.13597A9959@lists.varnish-cache.org> commit 4bdf4ef8efa00d15a3347ce9c2081d5d00be2900 Author: Geoff Simmons Date: Fri Mar 15 07:27:16 2019 +0100 Doc polish and grammar OCD. diff --git a/doc/sphinx/whats-new/changes-6.2.rst b/doc/sphinx/whats-new/changes-6.2.rst index 98c91df0b..8da9bfd04 100644 --- a/doc/sphinx/whats-new/changes-6.2.rst +++ b/doc/sphinx/whats-new/changes-6.2.rst @@ -77,7 +77,7 @@ the flag is turned on, C sources and shared object libraries that were generated from VCL sources are retained in the Varnish working directory (see the notes about ``varnishtest`` below). -For 32bit Platforms, we have increased the default +For 32-bit platforms, we have increased the default :ref:`ref_param_workspace_backend` from 16k to 20k accommodate larger response headers which have become common. @@ -212,10 +212,10 @@ varnishtest When :ref:`varnishtest(1)` is invoked with either of the ``-L`` or ``-l`` options to retain the temporary directory after tests, the -``vcl_keep`` flag for the :ref:`ref_param_debug` is switched on (see -`Parameters`_ above). This means that C sources and shared objects -generated from VCL can also be inspected after a test. By default, the -temporary directory is deleted after each test. +``vcl_keep`` flag for the :ref:`ref_param_debug` parameter is switched +on (see `Parameters`_ above). This means that C sources and shared +objects generated from VCL can also be inspected after a test. By +default, the temporary directory is deleted after each test. Since around the time of the last release, we have begun the project `VTest`_, which is adapted from :ref:`varnishtest(1)`, but is made diff --git a/doc/sphinx/whats-new/upgrading-6.2.rst b/doc/sphinx/whats-new/upgrading-6.2.rst index 011bd875a..5aaed3d42 100644 --- a/doc/sphinx/whats-new/upgrading-6.2.rst +++ b/doc/sphinx/whats-new/upgrading-6.2.rst @@ -132,7 +132,7 @@ changed and fields are now of dynamic width: ``Admin`` column has precedence. In the ``probe_message`` field of ``backend.list -j`` output, the -``Probe`` and ``Health`` columns appears as the array ``[X, Y, +``Probe`` and ``Health`` columns appear as the array ``[X, Y, health]``. See :ref:`varnish-cli(7)` for details. From phk at FreeBSD.org Fri Mar 15 08:33:07 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 15 Mar 2019 08:33:07 +0000 (UTC) Subject: [master] 6ac7a36e4 Check that objcore's do disappear Message-ID: <20190315083307.49222ADE35@lists.varnish-cache.org> commit 6ac7a36e46c8bf535751e0503b7583eab7030757 Author: Poul-Henning Kamp Date: Fri Mar 15 08:31:39 2019 +0000 Check that objcore's do disappear diff --git a/bin/varnishtest/tests/c00063.vtc b/bin/varnishtest/tests/c00063.vtc index 5b0a61e64..c784079da 100644 --- a/bin/varnishtest/tests/c00063.vtc +++ b/bin/varnishtest/tests/c00063.vtc @@ -32,3 +32,7 @@ client c1 { expect resp.http.foobar == "BLA1004" expect resp.body == "BLA1004" } -run + +delay 4 + +varnish v1 -expect n_objectcore == 0 From phk at FreeBSD.org Fri Mar 15 09:13:07 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 15 Mar 2019 09:13:07 +0000 (UTC) Subject: [master] 552f6f239 This test actually *do* need DNS Message-ID: <20190315091307.C35812EB2@lists.varnish-cache.org> commit 552f6f23930896c60dd4a063d2aee34e54e98e03 Author: Poul-Henning Kamp Date: Fri Mar 15 09:12:36 2019 +0000 This test actually *do* need DNS diff --git a/bin/varnishtest/tests/v00016.vtc b/bin/varnishtest/tests/v00016.vtc index e49e0470b..d41d750c3 100644 --- a/bin/varnishtest/tests/v00016.vtc +++ b/bin/varnishtest/tests/v00016.vtc @@ -1,5 +1,7 @@ varnishtest "Various VCL compiler coverage tests" +feature dns + shell "true > ${tmpdir}/_varnishtest_empty_file" varnish v1 -vcl { From nils.goroll at uplex.de Fri Mar 15 09:23:08 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Fri, 15 Mar 2019 09:23:08 +0000 (UTC) Subject: [master] de3e581eb kill stale oc for backend synth Message-ID: <20190315092308.95D954365@lists.varnish-cache.org> commit de3e581eb49ac3fbfc0f001f3fcd7db5e1ffea7f Author: Nils Goroll Date: Thu Mar 14 14:49:29 2019 +0100 kill stale oc for backend synth Fixes #2946 in the sense that we want to treat backend synth like any other object and kill the stale object it replaces. The two HSH_Kill calls could also be subsumed in vbf_fetch_thread(), but after an irc discussion, phk decided that he wanted to aim for even more consolidation later. The test checks that we remove the stale_oc, but not when abandoning the bereq. diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 33a751ea2..b320513fe 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -776,6 +776,8 @@ vbf_stp_error(struct worker *wrk, struct busyobj *bo) VSB_destroy(&synth_body); HSH_Unbusy(wrk, bo->fetch_objcore); ObjSetState(wrk, bo->fetch_objcore, BOS_FINISHED); + if (bo->stale_oc != NULL) + HSH_Kill(bo->stale_oc); return (F_STP_DONE); } diff --git a/bin/varnishtest/tests/r02946.vtc b/bin/varnishtest/tests/r02946.vtc new file mode 100644 index 000000000..06084791f --- /dev/null +++ b/bin/varnishtest/tests/r02946.vtc @@ -0,0 +1,33 @@ +varnishtest "#2946 - objcore leak for backend_synth" + +varnish v1 -vcl { + backend bad { .host = "${bad_backend}"; } + + sub vcl_backend_error { + if (bereq.http.abandon) { + return (abandon); + } + set beresp.status = 200; + set beresp.ttl = 0.0001s; + set beresp.grace = 1h; + } +} -start + +client c1 -repeat 20 -keepalive { + txreq + rxresp + expect resp.status == 200 + + delay 0.001 +} -run + +delay 2 + +client c1 { + txreq -hdr "abandon: true" + rxresp + expect resp.status == 200 + expect resp.http.age > 1 +} -run + +varnish v1 -expect n_objectcore == 1 From phk at FreeBSD.org Fri Mar 15 09:44:07 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 15 Mar 2019 09:44:07 +0000 (UTC) Subject: [master] 861606d3f Also reset global cmds like barrier Message-ID: <20190315094407.D5CE04AC4@lists.varnish-cache.org> commit 861606d3f3f7fb0ada893eac9392073d367f9acc Author: Poul-Henning Kamp Date: Fri Mar 15 09:42:17 2019 +0000 Also reset global cmds like barrier diff --git a/bin/varnishtest/vtc.c b/bin/varnishtest/vtc.c index f6c686d17..be6c85aa1 100644 --- a/bin/varnishtest/vtc.c +++ b/bin/varnishtest/vtc.c @@ -65,6 +65,8 @@ vtc_vrnd_unlock(void) AZ(pthread_mutex_unlock(&vtc_vrnd_mtx)); } +static const char *tfn; + /********************************************************************** * Macro facility */ @@ -79,6 +81,18 @@ struct macro { static VTAILQ_HEAD(,macro) macro_list = VTAILQ_HEAD_INITIALIZER(macro_list); +static const struct cmds global_cmds[] = { +#define CMD_GLOBAL(n) { #n, cmd_##n }, +#include "cmds.h" + { NULL, NULL } +}; + +static const struct cmds cmds[] = { +#define CMD_TOP(n) { #n, cmd_##n }, +#include "cmds.h" + { NULL, NULL } +}; + /**********************************************************************/ static struct macro * @@ -290,12 +304,6 @@ macro_expand(struct vtclog *vl, const char *text) * Static checkers like Coverity may bitch about this, but we don't care. */ -static const struct cmds global_cmds[] = { -#define CMD_GLOBAL(n) { #n, cmd_##n }, -#include "cmds.h" - { NULL, NULL } -}; - void parse_string(const char *spec, const struct cmds *cmd, void *priv, @@ -448,14 +456,6 @@ reset_cmds(const struct cmds *cmd) * Execute a file */ -static const struct cmds cmds[] = { -#define CMD_TOP(n) { #n, cmd_##n }, -#include "cmds.h" - { NULL, NULL } -}; - -static const char *tfn; - int fail_out(void) { @@ -470,6 +470,7 @@ fail_out(void) if (!vtc_stop) vtc_stop = 1; vtc_log(vltop, 1, "RESETTING after %s", tfn); + reset_cmds(global_cmds); reset_cmds(cmds); vtc_error |= old_err; From nils.goroll at uplex.de Fri Mar 15 10:05:10 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Fri, 15 Mar 2019 10:05:10 +0000 (UTC) Subject: [master] 38e70fad8 increase default stack size on 32bit to 52k Message-ID: <20190315100510.483485251@lists.varnish-cache.org> commit 38e70fad828fd43279e5e99c59972fbeebad82e4 Author: Nils Goroll Date: Fri Mar 15 10:58:52 2019 +0100 increase default stack size on 32bit to 52k Our stack space canary in v00004.vtc fell off the twig on fedora rawhide i686 Thank you to @ingvarha for testing, reporting and all your support overall! diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c index c27df71f7..5a1c0ca29 100644 --- a/bin/varnishd/mgt/mgt_param.c +++ b/bin/varnishd/mgt/mgt_param.c @@ -644,7 +644,7 @@ MCF_InitParams(struct cli *cli) MCF_ParamConf(MCF_DEFAULT, "http_req_size", "12k"); MCF_ParamConf(MCF_DEFAULT, "gzip_buffer", "4k"); MCF_ParamConf(MCF_MAXIMUM, "vsl_space", "1G"); - def = 48 * 1024; + def = 52 * 1024; } low = sysconf(_SC_THREAD_STACK_MIN); diff --git a/doc/sphinx/reference/varnishd.rst b/doc/sphinx/reference/varnishd.rst index d13463f41..53488b175 100644 --- a/doc/sphinx/reference/varnishd.rst +++ b/doc/sphinx/reference/varnishd.rst @@ -498,7 +498,7 @@ relative to the values listed below, in order to conserve VM space: * http_req_size: 12k * gzip_buffer: 4k * vsl_space: 1G -* thread_pool_stack: 48k +* thread_pool_stack: 52k .. _List of Parameters: diff --git a/doc/sphinx/whats-new/changes-6.2.rst b/doc/sphinx/whats-new/changes-6.2.rst index 8da9bfd04..2fea0f335 100644 --- a/doc/sphinx/whats-new/changes-6.2.rst +++ b/doc/sphinx/whats-new/changes-6.2.rst @@ -35,18 +35,20 @@ and/or :ref:`ref_param_thread_pools`. Parameters ~~~~~~~~~~ -The default value for :ref:`ref_param_thread_pool_stack` on 64-bit -platforms has been increased to 56k (from 48k). Recently we had -occasional reports of stack overflow, apparently related to changes in -external libraries that are not under control of the Varnish project -(such as glibc). This may also have been related to stack overflow -issues on some platforms when recent versions of `jemalloc`_, the -recommended memory allocator for Varnish, have been used together with -`pcre`_ with JIT compilation enabled. Compiler hardening flags may -also increase stack usage and on some systems such stack protector -flags may be enabled by default. With the addition of new mitigations -to new compiler releases, stack consumption may also increase on that -front. +The default value of :ref:`ref_param_thread_pool_stack` has been +increased from 48k to 56k on 64-bit platforms and to 52k on 32-bit +platforms. + +Recently we had occasional reports of stack overflow, apparently +related to changes in external libraries that are not under control of +the Varnish project (such as glibc). This may also have been related +to stack overflow issues on some platforms when recent versions of +`jemalloc`_, the recommended memory allocator for Varnish, have been +used together with `pcre`_ with JIT compilation enabled. Compiler +hardening flags may also increase stack usage and on some systems such +stack protector flags may be enabled by default. With the addition of +new mitigations to new compiler releases, stack consumption may also +increase on that front. Tests have shown that Varnish runs stably with the new default stack size on a number of platforms, under conditions that previously may diff --git a/doc/sphinx/whats-new/upgrading-6.2.rst b/doc/sphinx/whats-new/upgrading-6.2.rst index 5aaed3d42..3659a664a 100644 --- a/doc/sphinx/whats-new/upgrading-6.2.rst +++ b/doc/sphinx/whats-new/upgrading-6.2.rst @@ -43,9 +43,10 @@ now. These are: * ``vmod_dir`` -- use :ref:`ref_param_vmod_path` instead -The default value of :ref:`ref_param_thread_pool_stack` on 64-bit -platforms has been increased to 56k (from 48k). See the discussion -under :ref:`whatsnew_changes_params_2019_03` in +The default value of :ref:`ref_param_thread_pool_stack` has been +increased from 48k to 56k on 64-bit platforms and to 52k on 32-bit +platforms. See the discussion under +:ref:`whatsnew_changes_params_2019_03` in :ref:`whatsnew_changes_2019_03` for details. .. _whatsnew_upgrading_std_conversion_2019_03: diff --git a/include/tbl/params.h b/include/tbl/params.h index c60b48e2b..de34fb931 100644 --- a/include/tbl/params.h +++ b/include/tbl/params.h @@ -1313,7 +1313,7 @@ PARAM( /* typ */ bytes, /* min */ "2k", /* max */ NULL, - /* default */ "48k", + /* default */ "56k", /* units */ "bytes", /* flags */ EXPERIMENTAL, /* s-text */ From nils.goroll at uplex.de Fri Mar 15 12:06:07 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Fri, 15 Mar 2019 12:06:07 +0000 (UTC) Subject: [master] 5014b338a Revert "kill stale oc for backend synth" Message-ID: <20190315120607.617FD77E1@lists.varnish-cache.org> commit 5014b338a9bc6e2304c8b4e74b0ad32204a5ecc9 Author: Nils Goroll Date: Fri Mar 15 13:01:54 2019 +0100 Revert "kill stale oc for backend synth" This reverts commit de3e581eb49ac3fbfc0f001f3fcd7db5e1ffea7f. tests/saintmode/test04.vtc from varnish-modules revealed that there may be use cases where it is implied that vcl_backend_error will leave a ttl=0 object and the sale object will remain in place. This can be resolved by: - return(abandon) for these cases or - making the HSH_Kill conditional on bo->fetch_objcore->ttl > 0 but I already has concerns regarding the impact of this change and have them even more now. We need time to ponder about the consequences and a documented inefficiency is better than unexpected behaviour in a release. diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index b320513fe..33a751ea2 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -776,8 +776,6 @@ vbf_stp_error(struct worker *wrk, struct busyobj *bo) VSB_destroy(&synth_body); HSH_Unbusy(wrk, bo->fetch_objcore); ObjSetState(wrk, bo->fetch_objcore, BOS_FINISHED); - if (bo->stale_oc != NULL) - HSH_Kill(bo->stale_oc); return (F_STP_DONE); } diff --git a/bin/varnishtest/tests/r02946.vtc b/bin/varnishtest/tests/r02946.vtc deleted file mode 100644 index 06084791f..000000000 --- a/bin/varnishtest/tests/r02946.vtc +++ /dev/null @@ -1,33 +0,0 @@ -varnishtest "#2946 - objcore leak for backend_synth" - -varnish v1 -vcl { - backend bad { .host = "${bad_backend}"; } - - sub vcl_backend_error { - if (bereq.http.abandon) { - return (abandon); - } - set beresp.status = 200; - set beresp.ttl = 0.0001s; - set beresp.grace = 1h; - } -} -start - -client c1 -repeat 20 -keepalive { - txreq - rxresp - expect resp.status == 200 - - delay 0.001 -} -run - -delay 2 - -client c1 { - txreq -hdr "abandon: true" - rxresp - expect resp.status == 200 - expect resp.http.age > 1 -} -run - -varnish v1 -expect n_objectcore == 1 From hermunn at varnish-software.com Fri Mar 15 13:18:08 2019 From: hermunn at varnish-software.com (Pål Hermunn Johansen) Date: Fri, 15 Mar 2019 13:18:08 +0000 (UTC) Subject: [master] 85abf2044 Update Via header to 6.2 Message-ID: <20190315131808.73CE09F47@lists.varnish-cache.org> commit 85abf2044c3f501a674b594716a6af241797acf1 Author: P?l Hermunn Johansen Date: Fri Mar 15 14:16:35 2019 +0100 Update Via header to 6.2 diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 2cbedfdf6..a310cd32b 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -147,7 +147,7 @@ cnt_deliver(struct worker *wrk, struct req *req) http_PrintfHeader(req->resp, "Age: %.0f", floor(fmax(0., req->t_prev - req->objcore->t_origin))); - http_SetHeader(req->resp, "Via: 1.1 varnish (Varnish/6.1)"); + http_SetHeader(req->resp, "Via: 1.1 varnish (Varnish/6.2)"); if (cache_param->http_gzip_support && ObjCheckFlag(req->wrk, req->objcore, OF_GZIPED) && From hermunn at varnish-software.com Fri Mar 15 13:25:10 2019 From: hermunn at varnish-software.com (Pål Hermunn Johansen) Date: Fri, 15 Mar 2019 13:25:10 +0000 (UTC) Subject: [master] 8074ba4e7 Update changelog to 6.2 Message-ID: <20190315132510.6D9D260488@lists.varnish-cache.org> commit 8074ba4e795452b935531584dd0c9b3992ff624d Author: P?l Hermunn Johansen Date: Fri Mar 15 14:21:55 2019 +0100 Update changelog to 6.2 diff --git a/doc/changes.rst b/doc/changes.rst index 5e601b797..4e7494225 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -26,9 +26,9 @@ 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 trunk (ongoing) -============================= +================================ +Varnish Cache 6.2.0 (2019-03-15) +================================ * Extend JSON support in the CLI (2783_) From hermunn at varnish-software.com Fri Mar 15 13:39:09 2019 From: hermunn at varnish-software.com (Pål Hermunn Johansen) Date: Fri, 15 Mar 2019 13:39:09 +0000 (UTC) Subject: [master] 7a2e8ed00 Update version.c with new year Message-ID: <20190315133909.18D6E60A58@lists.varnish-cache.org> commit 7a2e8ed0067dbf4de0930327c7fe945d8e87b015 Author: P?l Hermunn Johansen Date: Fri Mar 15 14:37:22 2019 +0100 Update version.c with new year Happy new year! 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 hermunn at varnish-software.com Fri Mar 15 13:50:12 2019 From: hermunn at varnish-software.com (Pål Hermunn Johansen) Date: Fri, 15 Mar 2019 13:50:12 +0000 (UTC) Subject: [master] d7e64e2f7 VRT is now officially at 9.0 Message-ID: <20190315135012.4416560EB4@lists.varnish-cache.org> commit d7e64e2f76bcc7ef6932af89c1980f0c6e9290c5 Author: P?l Hermunn Johansen Date: Fri Mar 15 14:45:45 2019 +0100 VRT is now officially at 9.0 diff --git a/include/vrt.h b/include/vrt.h index 18f3769da..a0c4d4753 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -52,7 +52,7 @@ * binary/load-time compatible, increment MAJOR version * * - * 9.0 (scheduled for 2019-03-15) + * 9.0 (2019-03-15) * Make 'len' in vmod_priv 'long' * HTTP_Copy() removed * HTTP_Dup() added From fgsch at lodoss.net Sat Mar 16 19:11:06 2019 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sat, 16 Mar 2019 19:11:06 +0000 (UTC) Subject: [master] b114975e1 More travis shuffling Message-ID: <20190316191106.ED64B6E69@lists.varnish-cache.org> commit b114975e1fbbc632ca9f4aad8e18866df3c0125d Author: Federico G. Schwindt Date: Sat Mar 16 19:08:26 2019 +0000 More travis shuffling diff --git a/.travis.yml b/.travis.yml index 54868f05b..8126a2fb8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,6 @@ jobs: include: - &test-linux stage: test - if: type != cron os: linux dist: xenial compiler: clang @@ -32,6 +31,16 @@ jobs: - <<: *test-linux compiler: gcc - <<: *test-linux + stage: asan + addons: + apt: + sources: + - llvm-toolchain-xenial-8 + packages: + - clang-8 + - nghttp2 + - python3-docutils + - python3-sphinx env: SAN_BUILD=1 before_script: - | @@ -39,10 +48,10 @@ jobs: export LSAN_OPTIONS=abort_on_error=1,use_sigaltstack=0,suppressions=$(pwd)/tools/lsan.suppr export TSAN_OPTIONS=abort_on_error=1,halt_on_error=1,use_sigaltstack=0,suppressions=$(pwd)/tools/tsan.suppr export UBSAN_OPTIONS=halt_on_error=1,print_stacktrace=1,use_sigaltstack=0,suppressions=$(pwd)/tools/ubsan.suppr + export CC=clang-8 - ./autogen.sh - ./configure --enable-developer-warnings --enable-debugging-symbols --disable-stack-protector --with-persistent-storage --enable-asan --enable-ubsan - stage: test - if: type != cron os: osx osx_image: xcode10.1 compiler: clang @@ -59,25 +68,33 @@ jobs: script: *script-common - <<: *test-linux stage: coverity - if: type = cron env: - secure: "TndnHrwJk9FRSuVQWUk+ZrRc0jcNc0PW3TnvbRicIIwvYSLkMV5Y1tCQ5Jq/P98DA48/N/gf9DCAiFkxrNSKVeOY70FKgHYWlS130GhTv7r0c8zd+CdEXNORclcbBNV5F3Pli/LxZ+RUImjOfwcIcWV4eYv54Xv7aNFDAaDt4G9QlkSwXykLlZkoWLJQXFbhDBFioT1F1mucD9q9izEEeE+kqO1QH/IfobAq9v7/WrcS38sYI+0WvB1S0ajWuZJgRYqy1bocDNcQd05Vbr9NfAdJ9y+4VTuluZtTUyLxu3/0Tw8mAjHkcpOeNU26r3LnpdRk+5JuOFej/MrCmYRRawVfyvNGtu9RwcMkv8jl48TTs5kTf6UwFqJhe85QSlSi7IszfrE8HfB7B6u8eRr67rqjTr9k/BwEQyoBdK4JElQDj4A1GYHClomxgzmMZnVLvStnAm+IjdNlee4SfY0jj2KfPBd/v6Ms+LGVqNV9NDDKRQdOQD+H52MkIWs5Xu9fU5VaWP+xjFomA9aXex3r5FCssgyQ2P+HtWPdjNEtrkNezzfZ5b+VBVP87RdxfSqkZaRxi6gof0AgeTHWoi7GN1scseiKLxxCI7C0dfQgKrXTN7mZdcED1MMYdiaSI9mlSYQDDUHMQGeY1n3a9D6bUcC/TcmYo524PoTFBZgbbYM=" before_script: - curl --data "token=$COVTOKEN&project=varnish" -o coverity_tool.tgz https://scan.coverity.com/download/linux64 - - tar -xf coverity_tool.tgz + - tar xfz coverity_tool.tgz - export PATH=$PATH:$(echo $(pwd)/cov-analysis-*/bin) script: - ./autogen.sh - ./configure - cov-build --dir cov-int make - - tar -cfz varnish.tgz cov-int - - curl --form token=$COVTOKEN \ - --form email=varnish-dev at varnish-cache.org \ - --form file=@varnish.tgz \ - --form version="$TRAVIS_COMMIT" \ - --form description="$TRAVIS_BRANCH" \ + - tar cfz varnish.tgz cov-int + - curl --form token="$COVTOKEN" + --form email=varnish-dev at varnish-cache.org + --form file=@varnish.tgz + --form version="$TRAVIS_COMMIT" + --form description="$TRAVIS_BRANCH" 'https://scan.coverity.com/builds?project=varnish' +stages: + - name: test + if: type != cron + - name: asan + if: type != cron AND \ + type != pull_request + - name: coverity + if: type = cron + notifications: irc: channels: From fgsch at lodoss.net Sat Mar 16 19:16:06 2019 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sat, 16 Mar 2019 19:16:06 +0000 (UTC) Subject: [master] 3c1725bf2 Fix travis condition Message-ID: <20190316191606.C9AB77109@lists.varnish-cache.org> commit 3c1725bf2a05db27f64badbb07d1460252066edf Author: Federico G. Schwindt Date: Sat Mar 16 19:15:50 2019 +0000 Fix travis condition diff --git a/.travis.yml b/.travis.yml index 8126a2fb8..3486b8cfa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -90,7 +90,7 @@ stages: - name: test if: type != cron - name: asan - if: type != cron AND \ + if: type != cron AND type != pull_request - name: coverity if: type = cron From fgsch at lodoss.net Sun Mar 17 01:01:06 2019 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sun, 17 Mar 2019 01:01:06 +0000 (UTC) Subject: [master] 150fb581d Try to get (a)san build working Message-ID: <20190317010106.7141C64C72@lists.varnish-cache.org> commit 150fb581d74cd699e7881dd2d726c6448a85acd0 Author: Federico G. Schwindt Date: Sun Mar 17 00:59:17 2019 +0000 Try to get (a)san build working diff --git a/.travis.yml b/.travis.yml index 3486b8cfa..dee1fe866 100644 --- a/.travis.yml +++ b/.travis.yml @@ -31,13 +31,14 @@ jobs: - <<: *test-linux compiler: gcc - <<: *test-linux - stage: asan + stage: san addons: apt: sources: - llvm-toolchain-xenial-8 packages: - clang-8 + - llvm-8 - nghttp2 - python3-docutils - python3-sphinx @@ -89,7 +90,7 @@ jobs: stages: - name: test if: type != cron - - name: asan + - name: san if: type != cron AND type != pull_request - name: coverity From nils.goroll at uplex.de Sun Mar 17 09:32:06 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Sun, 17 Mar 2019 09:32:06 +0000 (UTC) Subject: [master] b12c73159 silence coverity Message-ID: <20190317093206.261EA9B0B8@lists.varnish-cache.org> commit b12c73159f8ed75f323f988e7fae9fb05e573361 Author: Nils Goroll Date: Sun Mar 17 10:25:10 2019 +0100 silence coverity diff --git a/bin/varnishd/cache/cache_ban_build.c b/bin/varnishd/cache/cache_ban_build.c index a3eae6eb2..660bdabc0 100644 --- a/bin/varnishd/cache/cache_ban_build.c +++ b/bin/varnishd/cache/cache_ban_build.c @@ -251,7 +251,7 @@ BAN_AddTest(struct ban_proto *bp, } op = ban_parse_oper(a2); - if (op < 0 || + if (op < _BANS_OPER_OFF || ((1U << BAN_OPERIDX(op)) & arg_opervalid[BAN_ARGIDX(pv->tag)]) == 0) return (ban_error(bp, "expected conditional (%s) got \"%s\"", From nils.goroll at uplex.de Sun Mar 17 09:32:06 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Sun, 17 Mar 2019 09:32:06 +0000 (UTC) Subject: [master] e1d47464d don't assert on failing WS_Alloc Message-ID: <20190317093206.35A2F9B0BA@lists.varnish-cache.org> commit e1d47464de79fac1823688b7437d5c8dccf27528 Author: Nils Goroll Date: Sun Mar 17 10:28:49 2019 +0100 don't assert on failing WS_Alloc not even in vmod_debug because it sets the only catflap example for the time being. diff --git a/lib/libvmod_debug/vmod_debug.c b/lib/libvmod_debug/vmod_debug.c index 6bbdbda1b..aa94579fe 100644 --- a/lib/libvmod_debug/vmod_debug.c +++ b/lib/libvmod_debug/vmod_debug.c @@ -689,7 +689,10 @@ xyzzy_catflap(VRT_CTX, VCL_ENUM type) CHECK_OBJ_NOTNULL(req, REQ_MAGIC); XXXAZ(req->vcf); req->vcf = WS_Alloc(req->ws, sizeof *req->vcf); - AN(req->vcf); + if (req->vcf == NULL) { + VRT_fail(ctx, "WS_Alloc failed in debug.catflap()"); + return; + } INIT_OBJ(req->vcf, VCF_MAGIC); if (type == VENUM(first) || type == VENUM(miss)) { req->vcf->func = xyzzy_catflap_simple; From nils.goroll at uplex.de Sun Mar 17 10:38:06 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Sun, 17 Mar 2019 10:38:06 +0000 (UTC) Subject: [master] 593cc0156 consolidate return keyword documentation Message-ID: <20190317103806.8CE599C884@lists.varnish-cache.org> commit 593cc01563a810c9cfb0900c7b026076b06e62c8 Author: Nils Goroll Date: Sun Mar 17 11:34:46 2019 +0100 consolidate return keyword documentation diff --git a/doc/sphinx/users-guide/vcl-built-in-subs.rst b/doc/sphinx/users-guide/vcl-built-in-subs.rst index 95c9885a9..3b749c835 100644 --- a/doc/sphinx/users-guide/vcl-built-in-subs.rst +++ b/doc/sphinx/users-guide/vcl-built-in-subs.rst @@ -17,8 +17,8 @@ The behaviour for ``return()`` keywords is identical or at least similar across subroutines, so differences are only documented where relevant. -common return keywords ----------------------- +common return keywords for the client and backend side +------------------------------------------------------ .. _fail: @@ -31,6 +31,11 @@ common return keywords Intended for fatal errors, for which only minimal error handling is possible. +client side +----------- + +common return keywords for the client side +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. _synth: ``synth(status code, reason)`` @@ -62,9 +67,6 @@ common return keywords preserved except for ``req.restarts`` and ``req.xid``, which need to change by design. -client side ------------ - .. _vcl_recv: vcl_recv @@ -323,6 +325,17 @@ following keywords: Backend Side ------------ + +common return keywords for the backend side +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. _abandon: + + ``abandon`` + Abandon the backend request. Unless the backend request was a + background fetch, control is passed to :ref:`vcl_synth` on the + client side with ``resp.status`` preset to 503. + .. _vcl_backend_fetch: vcl_backend_fetch @@ -337,14 +350,12 @@ The `vcl_backend_fetch` subroutine may terminate with calling ``fail`` see `fail`_ + ``abandon`` + see `abandon`_ + ``fetch`` Fetch the object from the backend. - ``abandon`` - Abandon the backend request. Unless the backend request was a - 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` backend request as follows: @@ -387,6 +398,9 @@ The `vcl_backend_response` subroutine may terminate with calling ``fail`` see `fail`_ + ``abandon`` + see `abandon`_ + ``deliver`` For a 304 response, create an updated cache object. Otherwise, fetch the object body from the backend and initiate @@ -398,11 +412,6 @@ The `vcl_backend_response` subroutine may terminate with calling If the number of retries is higher than *max_retries*, control will be passed to :ref:`vcl_backend_error`. - ``abandon`` - Abandon the backend request. Unless the backend request was a - background fetch, control is passed to :ref:`vcl_synth` on the - client side with ``resp.status`` preset to 503. - ``pass(duration)`` Mark the object as a hit-for-pass for the given duration. Subsequent lookups hitting this object will be turned into passed transactions, From nils.goroll at uplex.de Sun Mar 17 10:38:06 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Sun, 17 Mar 2019 10:38:06 +0000 (UTC) Subject: [master] afaf8246a document return (abandon) from vcl_backend_error {} Message-ID: <20190317103806.A0BC09C887@lists.varnish-cache.org> commit afaf8246a57bfc1549a6cf33a2d62e23171021a4 Author: Nils Goroll Date: Sun Mar 17 11:37:05 2019 +0100 document return (abandon) from vcl_backend_error {} diff --git a/doc/sphinx/users-guide/vcl-built-in-subs.rst b/doc/sphinx/users-guide/vcl-built-in-subs.rst index 3b749c835..a911ed005 100644 --- a/doc/sphinx/users-guide/vcl-built-in-subs.rst +++ b/doc/sphinx/users-guide/vcl-built-in-subs.rst @@ -504,6 +504,9 @@ with one of the following keywords: ``fail`` see `fail`_ + ``abandon`` + see `abandon`_ + ``deliver`` Deliver and possibly cache the object defined in `vcl_backend_error` **as if it was fetched from the backend**, also From dridi.boukelmoune at gmail.com Mon Mar 18 22:35:08 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 18 Mar 2019 22:35:08 +0000 (UTC) Subject: [master] 3cd00428b Generalize TAKE_OBJ_NOTNULL in object destructors Message-ID: <20190318223508.98DD3AC78C@lists.varnish-cache.org> commit 3cd00428b7a9886d3e23cc119d9cde14079d2149 Author: Dridi Boukelmoune Date: Mon Mar 18 23:27:32 2019 +0100 Generalize TAKE_OBJ_NOTNULL in object destructors It is now safe to assume that a constructor is always called with proper values or never called to begin with, and as such to panic if it's not the case. Bonus polish in the files I visited. Refs #2297 diff --git a/bin/varnishtest/tests/m00000.vtc b/bin/varnishtest/tests/m00000.vtc index 45262850b..5ddd706ce 100644 --- a/bin/varnishtest/tests/m00000.vtc +++ b/bin/varnishtest/tests/m00000.vtc @@ -123,9 +123,17 @@ varnish v1 -errvcl {Expression has type STRING, expected REAL} { varnish v1 -errvcl {Failed initialization} { import debug; + import directors; backend default { .host = "127.0.0.1"; } sub vcl_init { return (fail); + # uninitialized objects coverage new xyz = debug.obj(); + new fb = directors.fallback(); + new hsh = directors.hash(); + new rnd = directors.random(); + new rr = directors.round_robin(); + new shd = directors.shard(); + new shp = directors.shard_param(); } } diff --git a/lib/libvmod_blob/vmod_blob.c b/lib/libvmod_blob/vmod_blob.c index 7820e810c..2f8686edf 100644 --- a/lib/libvmod_blob/vmod_blob.c +++ b/lib/libvmod_blob/vmod_blob.c @@ -301,16 +301,13 @@ vmod_blob__fini(struct vmod_blob_blob **blobp) { struct vmod_blob_blob *b; - if (blobp == NULL || *blobp == NULL) - return; + TAKE_OBJ_NOTNULL(b, blobp, VMOD_BLOB_MAGIC); - b = *blobp; - *blobp = NULL; - CHECK_OBJ(b, VMOD_BLOB_MAGIC); if (b->freeptr != NULL) { free(b->freeptr); b->blob.blob = NULL; } + for (int i = 0; i < __MAX_ENCODING; i++) for (int j = 0; j < 2; j++) { char *s = b->encoding[i][j]; @@ -319,6 +316,7 @@ vmod_blob__fini(struct vmod_blob_blob **blobp) b->encoding[i][j] = NULL; } } + AZ(pthread_mutex_destroy(&b->lock)); FREE_OBJ(b); } diff --git a/lib/libvmod_debug/vmod_debug_dyn.c b/lib/libvmod_debug/vmod_debug_dyn.c index c7026b4ea..e8085394e 100644 --- a/lib/libvmod_debug/vmod_debug_dyn.c +++ b/lib/libvmod_debug/vmod_debug_dyn.c @@ -144,21 +144,16 @@ xyzzy_dyn__init(VRT_CTX, struct xyzzy_debug_dyn **dynp, *dynp = dyn; } -VCL_VOID +VCL_VOID v_matchproto_(td_xyzzy_debug_dyn__fini) xyzzy_dyn__fini(struct xyzzy_debug_dyn **dynp) { struct xyzzy_debug_dyn *dyn; - AN(dynp); - if (*dynp == NULL) - return; /* failed initialization */ - - CAST_OBJ_NOTNULL(dyn, *dynp, VMOD_DEBUG_DYN_MAGIC); + TAKE_OBJ_NOTNULL(dyn, dynp, VMOD_DEBUG_DYN_MAGIC); /* at this point all backends will be deleted by the vcl */ free(dyn->vcl_name); AZ(pthread_mutex_destroy(&dyn->mtx)); FREE_OBJ(dyn); - *dynp = NULL; } VCL_BACKEND v_matchproto_() @@ -194,6 +189,11 @@ dyn_uds_init(VRT_CTX, struct xyzzy_debug_dyn_uds *uds, VCL_STRING path) VRT_fail(ctx, "path must be an absolute path: %s", path); return (-1); } + + /* XXX: now that we accept that sockets may come after vcl.load + * and change during the life of a VCL, do we still need to check + * this? It looks like both if blocks can be retired. + */ errno = 0; if (stat(path, &st) != 0) { VRT_fail(ctx, "Cannot stat path %s: %s", path, strerror(errno)); @@ -224,9 +224,9 @@ dyn_uds_init(VRT_CTX, struct xyzzy_debug_dyn_uds *uds, VCL_STRING path) return (0); } -VCL_VOID v_matchproto_(td_debug_dyn_uds__init) +VCL_VOID v_matchproto_(td_xyzzy_debug_dyn_uds__init) xyzzy_dyn_uds__init(VRT_CTX, struct xyzzy_debug_dyn_uds **udsp, - const char *vcl_name, VCL_STRING path) + const char *vcl_name, VCL_STRING path) { struct xyzzy_debug_dyn_uds *uds; @@ -246,6 +246,7 @@ xyzzy_dyn_uds__init(VRT_CTX, struct xyzzy_debug_dyn_uds **udsp, FREE_OBJ(uds); return; } + *udsp = uds; } @@ -254,14 +255,10 @@ xyzzy_dyn_uds__fini(struct xyzzy_debug_dyn_uds **udsp) { struct xyzzy_debug_dyn_uds *uds; - if (udsp == NULL || *udsp == NULL) - return; - CHECK_OBJ(*udsp, VMOD_DEBUG_UDS_MAGIC); - uds = *udsp; + TAKE_OBJ_NOTNULL(uds, udsp, VMOD_DEBUG_UDS_MAGIC); free(uds->vcl_name); AZ(pthread_mutex_destroy(&uds->mtx)); FREE_OBJ(uds); - *udsp = NULL; } VCL_BACKEND v_matchproto_(td_debug_dyn_uds_backend) diff --git a/lib/libvmod_debug/vmod_debug_obj.c b/lib/libvmod_debug/vmod_debug_obj.c index 34eacca75..3928e5598 100644 --- a/lib/libvmod_debug/vmod_debug_obj.c +++ b/lib/libvmod_debug/vmod_debug_obj.c @@ -38,8 +38,9 @@ struct xyzzy_debug_obj { unsigned magic; #define VMOD_DEBUG_OBJ_MAGIC 0xccbd9b77 - int foobar; - const char *string, *number; + int foobar; + const char *string; + const char *number; }; VCL_VOID @@ -61,16 +62,16 @@ xyzzy_obj__init(VRT_CTX, struct xyzzy_debug_obj **op, AN(*op); } -VCL_VOID +VCL_VOID v_matchproto_(td_xyzzy_obj__fini) xyzzy_obj__fini(struct xyzzy_debug_obj **op) { + struct xyzzy_debug_obj *o; - AN(op); - AN(*op); - FREE_OBJ(*op); + TAKE_OBJ_NOTNULL(o, op, VMOD_DEBUG_OBJ_MAGIC); + FREE_OBJ(o); } -VCL_VOID v_matchproto_() +VCL_VOID v_matchproto_(td_xyzzy_obj_enum) xyzzy_obj_enum(VRT_CTX, struct xyzzy_debug_obj *o, VCL_ENUM e) { diff --git a/lib/libvmod_directors/fall_back.c b/lib/libvmod_directors/fall_back.c index 0838e93fa..c14e745af 100644 --- a/lib/libvmod_directors/fall_back.c +++ b/lib/libvmod_directors/fall_back.c @@ -214,10 +214,6 @@ vmod_fallback__fini(struct vmod_directors_fallback **fbp) { struct vmod_directors_fallback *fb; - // XXX 2297 - if (*fbp == NULL) - return; - TAKE_OBJ_NOTNULL(fb, fbp, VMOD_DIRECTORS_FALLBACK_MAGIC); VRT_DelDirector(&fb->vd->dir); } diff --git a/lib/libvmod_directors/hash.c b/lib/libvmod_directors/hash.c index 010aaeaa2..a82e19fe3 100644 --- a/lib/libvmod_directors/hash.c +++ b/lib/libvmod_directors/hash.c @@ -83,10 +83,6 @@ vmod_hash__fini(struct vmod_directors_hash **rrp) { struct vmod_directors_hash *rr; - // XXX 2297 - if (*rrp == NULL) - return; - TAKE_OBJ_NOTNULL(rr, rrp, VMOD_DIRECTORS_HASH_MAGIC); VRT_DelDirector(&rr->vd->dir); } diff --git a/lib/libvmod_directors/random.c b/lib/libvmod_directors/random.c index 93e5a96f6..3be74527f 100644 --- a/lib/libvmod_directors/random.c +++ b/lib/libvmod_directors/random.c @@ -124,10 +124,6 @@ vmod_random__fini(struct vmod_directors_random **rrp) { struct vmod_directors_random *rr; - // XXX 2297 - if (*rrp == NULL) - return; - TAKE_OBJ_NOTNULL(rr, rrp, VMOD_DIRECTORS_RANDOM_MAGIC); VRT_DelDirector(&rr->vd->dir); } diff --git a/lib/libvmod_directors/round_robin.c b/lib/libvmod_directors/round_robin.c index fc32ab646..d323f8a5e 100644 --- a/lib/libvmod_directors/round_robin.c +++ b/lib/libvmod_directors/round_robin.c @@ -131,10 +131,6 @@ vmod_round_robin__fini(struct vmod_directors_round_robin **rrp) { struct vmod_directors_round_robin *rr; - // XXX 2297 - if (*rrp == NULL) - return; - TAKE_OBJ_NOTNULL(rr, rrp, VMOD_DIRECTORS_ROUND_ROBIN_MAGIC); VRT_DelDirector(&rr->vd->dir); } diff --git a/lib/libvmod_directors/vmod_shard.c b/lib/libvmod_directors/vmod_shard.c index d7dd7d7d6..c25ebb9ec 100644 --- a/lib/libvmod_directors/vmod_shard.c +++ b/lib/libvmod_directors/vmod_shard.c @@ -275,10 +275,6 @@ vmod_shard__fini(struct vmod_directors_shard **vshardp) { struct vmod_directors_shard *vshard; - // XXX 2297 - if (*vshardp == NULL) - return; - TAKE_OBJ_NOTNULL(vshard, vshardp, VMOD_SHARD_SHARD_MAGIC); VRT_DelDirector(&vshard->dir); FREE_OBJ(vshard); @@ -899,10 +895,6 @@ vmod_shard_param__fini(struct vmod_directors_shard_param **pp) { struct vmod_directors_shard_param *p; - // XXX 2297 - if (*pp == NULL) - return; - TAKE_OBJ_NOTNULL(p, pp, VMOD_SHARD_SHARD_PARAM_MAGIC); FREE_OBJ(p); } From nils.goroll at uplex.de Wed Mar 20 10:27:07 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 20 Mar 2019 10:27:07 +0000 (UTC) Subject: [master] 88948d982 Change the stack overflow test to 128kb stacksize Message-ID: <20190320102707.4707A92CDD@lists.varnish-cache.org> commit 88948d982bcd165e05967d2a9c8684eb9f9cbd01 Author: Nils Goroll Date: Wed Mar 20 11:24:33 2019 +0100 Change the stack overflow test to 128kb stacksize on ppc64 fedora, the thread_pool_stack minimum is 128kb due to sysconf(_SC_THREAD_STACK_MIN) = 131072 It does not harm the test to use a larger stacksize, so we adjust it to this requirement for consistency and simplicity diff --git a/bin/varnishtest/tests/c00057.vtc b/bin/varnishtest/tests/c00057.vtc index 5118c79a0..be6569d24 100644 --- a/bin/varnishtest/tests/c00057.vtc +++ b/bin/varnishtest/tests/c00057.vtc @@ -12,7 +12,7 @@ server s1 { varnish v1 \ -arg "-p feature=+no_coredump" \ -arg "-p vcc_allow_inline_c=true" \ - -arg "-p thread_pool_stack=48k" \ + -arg "-p thread_pool_stack=128k" \ -vcl+backend { C{ #include @@ -27,11 +27,12 @@ void (*accessor)(volatile char *p) = _accessor; }C sub vcl_recv { C{ + const int stkkb = 128; int i; - volatile char overflow[48*1024]; + volatile char overflow[stkkb * 1024]; /* for downwards stack, take care to hit a single guard page */ - for (i = 47*1024; i >= 0; i -= 1024) + for (i = (stkkb - 1) * 1024; i >= 0; i -= 1024) accessor(overflow + i); /* NOTREACHED */ sleep(2); From nils.goroll at uplex.de Wed Mar 20 16:18:09 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 20 Mar 2019 16:18:09 +0000 (UTC) Subject: [master] b2d18f480 reserve vcl_* but not vcl* Message-ID: <20190320161809.9AB69A179B@lists.varnish-cache.org> commit b2d18f4804df1bc778540a72cd01efc2027df5db Author: Nils Goroll Date: Wed Mar 20 17:16:14 2019 +0100 reserve vcl_* but not vcl* Fixes #2953 diff --git a/bin/varnishtest/tests/v00020.vtc b/bin/varnishtest/tests/v00020.vtc index 3cbe2678e..1c61f02e5 100644 --- a/bin/varnishtest/tests/v00020.vtc +++ b/bin/varnishtest/tests/v00020.vtc @@ -208,7 +208,7 @@ varnish v1 -errvcl {Name of function, 'foo.bar', contains illegal character '.'} } } -varnish v1 -errvcl {The names 'vcl*' are reserved for subroutines.} { +varnish v1 -errvcl {The names 'vcl_*' are reserved for subroutines.} { sub vcl_bar { } sub vcl_recv { diff --git a/lib/libvcc/vcc_parse.c b/lib/libvcc/vcc_parse.c index af8e6a45e..faa929d5f 100644 --- a/lib/libvcc/vcc_parse.c +++ b/lib/libvcc/vcc_parse.c @@ -235,9 +235,10 @@ vcc_ParseFunction(struct vcc *tl) if (p == NULL) { if ((t->b[0] == 'v'|| t->b[0] == 'V') && (t->b[1] == 'c'|| t->b[1] == 'C') && - (t->b[2] == 'l'|| t->b[2] == 'L')) { - VSB_printf(tl->sb, - "The names 'vcl*' are reserved for subroutines.\n"); + (t->b[2] == 'l'|| t->b[2] == 'L') && + (t->b[3] == '_')) { + VSB_printf(tl->sb,"The names 'vcl_*'" + " are reserved for subroutines.\n"); vcc_ErrWhere(tl, t); VSB_printf(tl->sb, "Valid vcl_* subroutines are:\n"); VTAILQ_FOREACH(p, &tl->procs, list) { diff --git a/lib/libvcc/vcc_symb.c b/lib/libvcc/vcc_symb.c index 8f19a0005..67d4d8707 100644 --- a/lib/libvcc/vcc_symb.c +++ b/lib/libvcc/vcc_symb.c @@ -206,7 +206,8 @@ VCC_SymbolGet(struct vcc *tl, vcc_kind_t kind, const char *e, const char *x) if (tl->syntax >= VCL_41 && e == SYMTAB_CREATE && kind != SYM_SUB && (tl->t->b[0] == 'v'|| tl->t->b[0] == 'V') && (tl->t->b[1] == 'c'|| tl->t->b[1] == 'C') && - (tl->t->b[2] == 'l'|| tl->t->b[2] == 'L')) { + (tl->t->b[2] == 'l'|| tl->t->b[2] == 'L') && + (tl->t->b[3] == '_')) { VSB_printf(tl->sb, "Symbols named 'vcl_*' are reserved.\nAt:"); vcc_ErrWhere(tl, tl->t); From phk at FreeBSD.org Thu Mar 21 07:55:08 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 21 Mar 2019 07:55:08 +0000 (UTC) Subject: [master] 9fac6d080 Add include for NetBSD Message-ID: <20190321075508.6B0056024C@lists.varnish-cache.org> commit 9fac6d080bd4b501782d65c22856c0040a9af0a6 Author: Poul-Henning Kamp Date: Thu Mar 21 07:54:11 2019 +0000 Add include for NetBSD Submitted by: @tnn2 Fixes #2954 diff --git a/lib/libvarnish/vtcp.c b/lib/libvarnish/vtcp.c index d222d6bb4..521ab5343 100644 --- a/lib/libvarnish/vtcp.c +++ b/lib/libvarnish/vtcp.c @@ -31,6 +31,7 @@ #include #include +#include // for NetBSD #include #ifdef HAVE_SYS_FILIO_H # include From dridi.boukelmoune at gmail.com Thu Mar 21 11:39:08 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 21 Mar 2019 11:39:08 +0000 (UTC) Subject: [master] 1c0a20128 Fix sentence grammar Message-ID: <20190321113908.748B464843@lists.varnish-cache.org> commit 1c0a20128d3606955ebf39c1117a529afb55251c Author: Prince Rachit Sinha Date: Thu Mar 21 16:44:38 2019 +0530 Fix sentence grammar diff --git a/CONTRIBUTING b/CONTRIBUTING index fdc94d679..1e3a16921 100644 --- a/CONTRIBUTING +++ b/CONTRIBUTING @@ -17,8 +17,8 @@ Our main project communication is through or developer IRC channel:: Mondays at 13:00 EU time we hold our weekly "bugwash" where we go through new (and old) tickets. It speeds things up a lot if you -can be join the channel and answer questions directly when we go -over the ticket. +can join the channel and answer questions directly when we go over +the ticket. Github pull requests -------------------- From dridi.boukelmoune at gmail.com Fri Mar 22 07:35:08 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 22 Mar 2019 07:35:08 +0000 (UTC) Subject: [master] 4edaa2836 Use FREE_OBJ for VEV Message-ID: <20190322073508.8C417A9995@lists.varnish-cache.org> commit 4edaa2836c6aba837899b78866a2567c704e336b Author: Dridi Boukelmoune Date: Fri Mar 22 08:24:38 2019 +0100 Use FREE_OBJ for VEV This was actually done with a Coccinelle patch after finding plain free() calls out of tree: $ cat >free_obj.cocci <thread == pthread_self()); free(evb->pfd); free(evb->pev); - /* destroy evb->binheap */ - evb->magic = 0; - free(evb); + /* XXX: destroy evb->binheap */ + FREE_OBJ(evb); } /*--------------------------------------------------------------------*/ From fgsch at lodoss.net Sun Mar 24 11:59:05 2019 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sun, 24 Mar 2019 11:59:05 +0000 (UTC) Subject: [master] a50723242 Cosmetic Message-ID: <20190324115905.7058A987DA@lists.varnish-cache.org> commit a50723242ac43ee9bd021f23cf7a54e156f884b2 Author: Federico G. Schwindt Date: Sun Mar 24 11:56:29 2019 +0000 Cosmetic diff --git a/.travis.yml b/.travis.yml index dee1fe866..5f08d0109 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,7 @@ language: c jobs: allow_failures: - os: osx - - env: SAN_BUILD=1 + - env: ASAN=1 UBSAN=1 fast_finish: true include: - &test-linux @@ -31,7 +31,7 @@ jobs: - <<: *test-linux compiler: gcc - <<: *test-linux - stage: san + stage: sanitizers addons: apt: sources: @@ -42,7 +42,7 @@ jobs: - nghttp2 - python3-docutils - python3-sphinx - env: SAN_BUILD=1 + env: ASAN=1 UBSAN=1 before_script: - | 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 @@ -90,7 +90,7 @@ jobs: stages: - name: test if: type != cron - - name: san + - name: sanitizers if: type != cron AND type != pull_request - name: coverity