From fgsch at lodoss.net Sun Dec 2 17:40:15 2018 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sun, 2 Dec 2018 17:40:15 +0000 (UTC) Subject: [master] 747bf45fd Always keep .c and .so files if vcl_keep is set Message-ID: <20181202174015.7D2DE63CC1@lists.varnish-cache.org> commit 747bf45fd4e29bd3aadc3bd52f7299b1633af94f Author: Federico G. Schwindt Date: Sun Dec 2 17:29:17 2018 +0000 Always keep .c and .so files if vcl_keep is set Add tests for vcl_keep and move vmod_so_keep together. Reported and diagnosed by jw @ irc. diff --git a/bin/varnishd/mgt/mgt_vcc.c b/bin/varnishd/mgt/mgt_vcc.c index dabf750a3..cf7852e7c 100644 --- a/bin/varnishd/mgt/mgt_vcc.c +++ b/bin/varnishd/mgt/mgt_vcc.c @@ -345,11 +345,13 @@ mgt_VccCompile(struct cli *cli, struct vclprog *vcl, const char *vclname, VSB_destroy(&sb); if (status || C_flag) { - (void)unlink(vp.csrcfile); + if (!MGT_DO_DEBUG(DBG_VCL_KEEP)) { + (void)unlink(vp.csrcfile); + (void)unlink(vp.libfile); + (void)rmdir(vp.dir); + } free(vp.csrcfile); - (void)unlink(vp.libfile); free(vp.libfile); - (void)rmdir(vp.dir); free(vp.dir); if (status) { VCLI_Out(cli, "VCL compilation failed"); diff --git a/bin/varnishtest/tests/c00095.vtc b/bin/varnishtest/tests/c00095.vtc new file mode 100644 index 000000000..93ce3c8b6 --- /dev/null +++ b/bin/varnishtest/tests/c00095.vtc @@ -0,0 +1,84 @@ +varnishtest "vcl_keep and vmod_so_keep debug bits" + +feature topbuild + +server s1 { +} -start + +varnish v1 -vcl+backend { +} -start + +# Test valid and invalid VCL with vcl_keep unset + +varnish v1 -cliok "param.set debug -vcl_keep" + +varnish v1 -vcl+backend { +} + +shell -err "test -f ./v1/vcl_vcl2.*/vgc.c" + +varnish v1 -errvcl {No backends or directors found} { +} + +shell -err "test -f ./v1/vcl_vcl3.*/vgc.c" + +# Same but with vcl_keep set + +varnish v1 -cliok "param.set debug +vcl_keep" + +varnish v1 -vcl+backend { +} + +shell { + test -f ./v1/vcl_vcl4.*/vgc.c && + test -f ./v1/vcl_vcl4.*/vgc.so +} + +varnish v1 -errvcl {No backends or directors found} { +} + +shell { + test -f ./v1/vcl_vcl5.*/vgc.c && + test -f ./v1/vcl_vcl5.*/vgc.so +} + +# Test vmod with vmod_so_keep set + +varnish v1 -cliok "param.set debug +vmod_so_keep" + +varnish v1 -vcl+backend { + import std; +} + +shell "test -f ./v1/vmod_cache/_vmod_std.*" + +varnish v1 -stop +varnish v1 -cleanup + +# Ensure these are not deleted on exit + +shell { + test -f ./v1/vcl_vcl4.*/vgc.c && + test -f ./v1/vcl_vcl4.*/vgc.so && + test -f ./v1/vcl_vcl5.*/vgc.c && + test -f ./v1/vcl_vcl5.*/vgc.so && + test -f ./v1/vmod_cache/_vmod_std.* +} + +varnish v2 -vcl+backend { +} -start + +# And test vmod with vmod_so_keep unset + +varnish v2 -cliok "param.set debug -vmod_so_keep" + +varnish v2 -vcl+backend { + import std; +} + +shell "test -f ./v2/vmod_cache/_vmod_std.*" + +varnish v2 -stop +varnish v2 -cleanup + +shell -err "test -f ./v2/vmod_cache/_vmod_std.*" diff --git a/bin/varnishtest/tests/m00008.vtc b/bin/varnishtest/tests/m00008.vtc index 7026f578e..a0bc5b2a3 100644 --- a/bin/varnishtest/tests/m00008.vtc +++ b/bin/varnishtest/tests/m00008.vtc @@ -47,14 +47,3 @@ varnish v1 -errvcl {Malformed VMOD std} { backend default { .host = "${s1_sock}"; } import std from "${topbuild}/lib/libvmod_debug/.libs/libvmod_debug.so"; } - -# Check creation and cleanup of copied shared objects for VMODs -shell "test -e ./v1/vmod_cache/_vmod_std.*" - -# In case varnishtest was invoked with -L or -l, in which case the -# bit is switched on. -varnish v1 -cliok "param.set debug -vmod_so_keep" - -varnish v1 -stop -varnish v1 -cleanup -shell -err "test -e ./v1/vmod_cache/_vmod_std.*" diff --git a/bin/varnishtest/tests/m00030.vtc b/bin/varnishtest/tests/m00030.vtc deleted file mode 100644 index 4ea2e0ede..000000000 --- a/bin/varnishtest/tests/m00030.vtc +++ /dev/null @@ -1,17 +0,0 @@ -varnishtest "debug bit vmod_so_keep" - -feature topbuild - -varnish v1 -vcl { - import std; - backend b { .host = "${bad_backend}"; } -} -start - -shell "test -e ./v1/vmod_cache/_vmod_std.*" - -varnish v1 -cliok "param.set debug +vmod_so_keep" - -# cf m00008.vtc -varnish v1 -stop -varnish v1 -cleanup -shell "test -e ./v1/vmod_cache/_vmod_std.*" From fgsch at lodoss.net Sun Dec 2 18:09:06 2018 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sun, 2 Dec 2018 18:09:06 +0000 (UTC) Subject: [master] 7da9144d8 Update osx build and drop sudo: false Message-ID: <20181202180906.AF5596461D@lists.varnish-cache.org> commit 7da9144d84af239571e779867bc453042db0fb44 Author: Federico G. Schwindt Date: Sun Dec 2 18:05:19 2018 +0000 Update osx build and drop sudo: false diff --git a/.travis.yml b/.travis.yml index da2bcbb8b..52424fefc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,5 @@ --- language: c -sudo: false matrix: fast_finish: true include: @@ -16,7 +15,7 @@ matrix: env: CLANG=7 SAN_FLAGS="--enable-asan --enable-ubsan" sudo: required - os: osx - osx_image: xcode10 + osx_image: xcode10.1 compiler: clang allow_failures: - os: osx From fgsch at lodoss.net Sun Dec 2 19:19:04 2018 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sun, 2 Dec 2018 19:19:04 +0000 (UTC) Subject: [master] f5e3cf64e Switch to xenial and tidy up Message-ID: <20181202191904.D7AB865AC5@lists.varnish-cache.org> commit f5e3cf64ea5557c204fb36729a4eabc8eab5a933 Author: Federico G. Schwindt Date: Sun Dec 2 18:27:02 2018 +0000 Switch to xenial and tidy up diff --git a/.travis.yml b/.travis.yml index 52424fefc..8d31d9e04 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,27 +4,31 @@ matrix: fast_finish: true include: - os: linux - dist: trusty + dist: xenial compiler: gcc - os: linux - dist: trusty + dist: xenial compiler: clang - os: linux - dist: trusty + dist: xenial compiler: clang - env: CLANG=7 SAN_FLAGS="--enable-asan --enable-ubsan" - sudo: required + env: SAN_FLAGS="--enable-asan --enable-ubsan" - os: osx osx_image: xcode10.1 compiler: clang allow_failures: - os: osx - - env: CLANG=7 SAN_FLAGS="--enable-asan --enable-ubsan" + - env: SAN_FLAGS="--enable-asan --enable-ubsan" addons: apt: packages: - python-docutils - python-sphinx + homebrew: + packages: + - docutils + - nghttp2 + - sphinx-doc notifications: irc: channels: @@ -34,19 +38,8 @@ notifications: before_install: - | if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then - brew update - brew install docutils sphinx-doc nghttp2 export PATH="/usr/local/opt/sphinx-doc/bin:$PATH" - elif [[ -n "$CLANG" ]]; then - wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - - sudo apt-add-repository -y \ - "deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty-$CLANG main" - sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys BA9EF27F - sudo apt-add-repository -y \ - "deb http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu trusty main" - sudo apt-get update - sudo apt-get install -y clang-$CLANG llvm-$CLANG - export CC=clang-$CLANG + elif [[ -n "$SAN_FLAGS" ]]; then export CONFIGURE_ARGS="--enable-developer-warnings --enable-debugging-symbols --disable-stack-protector --with-persistent-storage ${SAN_FLAGS}" export ASAN_OPTIONS=abort_on_error=1,detect_odr_violation=1,detect_leaks=1,detect_stack_use_after_return=1,detect_invalid_pointer_pairs=1,handle_segv=0,handle_sigbus=0,use_sigaltstack=0,disable_coredump=0 export LSAN_OPTIONS=abort_on_error=1,use_sigaltstack=0,suppressions=$(pwd)/tools/lsan.suppr From lasse.karstensen at gmail.com Sun Dec 2 19:31:06 2018 From: lasse.karstensen at gmail.com (Lasse Karstensen) Date: Sun, 2 Dec 2018 19:31:06 +0000 (UTC) Subject: [master] 7bdf4d1f9 Use upper case for abbreviations. Message-ID: <20181202193106.3220D6E030@lists.varnish-cache.org> commit 7bdf4d1f98c3e5fcda9abcd4ab803468bb0f47ad Author: Lasse Karstensen Date: Sun Dec 2 20:24:17 2018 +0100 Use upper case for abbreviations. diff --git a/lib/libvmod_proxy/vmod.vcc b/lib/libvmod_proxy/vmod.vcc index 34b1199b2..79aa4b678 100644 --- a/lib/libvmod_proxy/vmod.vcc +++ b/lib/libvmod_proxy/vmod.vcc @@ -38,14 +38,14 @@ as described in https://www.haproxy.org/download/1.8/doc/proxy-protocol.txt. $Function STRING alpn() Description - Extract alpn attribute. + Extract ALPN attribute. Example set req.http.alpn = proxy.alpn(); $Function STRING authority() Description - Extract authority attribute. This corresponds to sni from a tls + Extract authority attribute. This corresponds to SNI from a TLS connection. Example set req.http.authority = proxy.authority(); @@ -53,7 +53,7 @@ Example $Function BOOL is_ssl() Description - Report if proxy-protocol-v2 has ssl tlv. + Report if proxy-protocol-v2 has SSL TLV. Example | if (proxy.is_ssl()) { @@ -86,7 +86,7 @@ Example $Function STRING ssl_version() Description - Extract ssl version attribute. + Extract SSL version attribute. Example set req.http.ssl-version = proxy.ssl_version(); @@ -100,7 +100,7 @@ Example $Function STRING ssl_cipher() Description - Extract the ssl cipher attribute. + Extract the SSL cipher attribute. Example set req.http.ssl-cipher = proxy.ssl_cipher(); From fgsch at lodoss.net Sun Dec 2 20:23:08 2018 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sun, 2 Dec 2018 20:23:08 +0000 (UTC) Subject: [master] d45e8a4ea Improve docs Message-ID: <20181202202308.6B15390447@lists.varnish-cache.org> commit d45e8a4ea980fb8c7acc004111a5d05620023074 Author: Federico G. Schwindt Date: Sun Dec 2 20:19:22 2018 +0000 Improve docs Partially addresses #2846. I've avoided mentioning NULL on purpose as it's not really meaningful nor accessible from VCL. ymmv. diff --git a/doc/sphinx/reference/vcl.rst b/doc/sphinx/reference/vcl.rst index 84aadafb4..fbd9cde3f 100644 --- a/doc/sphinx/reference/vcl.rst +++ b/doc/sphinx/reference/vcl.rst @@ -93,7 +93,7 @@ Booleans can be either ``true`` or ``false``. In addition, in a boolean context some data types will evaluate to ``true`` or ``false`` depending on their value. -String types will evaluate to ``false`` if they are empty; backend types +String types will evaluate to ``false`` if they are not set; backend types will evaluate to ``false`` if they don't have a backend assigned; integer types will evaluate to ``false`` if their value is zero; duration types will evaluate to ``false`` if their value is equal or less than zero. @@ -138,18 +138,20 @@ include a fractional part, e.g. ``1.5s``. The supported units are: ``y`` years +In string context they return a string with their value rounded to +3 decimal places and excluding the unit, e.g. ``1.500``. + Integers ~~~~~~~~ Certain fields are integers, used as expected. In string context they -return a string. +return a string, e.g. ``1234``. Real numbers ~~~~~~~~~~~~ -VCL understands real numbers. As with integers, when used in a string -context they will return a string. - +VCL understands real numbers. In string context they return a string +with their value rounded to 3 decimal places, e.g. ``3.142``. Regular Expressions ------------------- From fgsch at lodoss.net Sun Dec 2 23:03:06 2018 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sun, 2 Dec 2018 23:03:06 +0000 (UTC) Subject: [master] 4b66c900c More coverage Message-ID: <20181202230306.88A659355B@lists.varnish-cache.org> commit 4b66c900cdde4e82812583d2e7e7ef994c217a7b Author: Federico G. Schwindt Date: Sun Dec 2 21:52:07 2018 +0000 More coverage diff --git a/bin/varnishtest/tests/u00006.vtc b/bin/varnishtest/tests/u00006.vtc index 8dcb2f920..2f1e41476 100644 --- a/bin/varnishtest/tests/u00006.vtc +++ b/bin/varnishtest/tests/u00006.vtc @@ -60,6 +60,25 @@ shell -err -expect "Cannot open output file (No such file or directory)" \ shell -err -expect "Only one of -n and -r options may be used" \ {varnishlog -n ${v1_name} -r ${v1_name}/_.vsm} +shell -err -expect "Expected integer got '}" \ + "varnishlog -q {}" +shell -err -expect "Expected positive integer" \ + "varnishlog -q {-1}" +shell -err -expect "Syntax error in level limit" \ + "varnishlog -q {1a}" +shell -err -expect "Expected VSL tag name got ''" \ + "varnishlog -q ''" +shell -err -expect "Tag name matches zero tags" \ + "varnishlog -q foo" +shell -err -expect "Tag name is ambiguous" \ + "varnishlog -q Resp" +shell -err -expect "Expected string got ''" \ + "varnishlog -q ReqHeader:" +shell -err -expect "Expected integer got ']'" \ + "varnishlog -q ReqHeader:foo[]" +shell -err -expect "Expected positive integer" \ + "varnishlog -q ReqHeader:foo[a]" + process p1 -wait shell {grep -q "0 CLI" ${tmpdir}/vlog} shell -match "0 CLI[ ]+- Wr 200 [0-9]+ PONG" \ From fgsch at lodoss.net Mon Dec 3 00:00:12 2018 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Mon, 3 Dec 2018 00:00:12 +0000 (UTC) Subject: [master] 4185016f6 Try to get this test running on SunOS Message-ID: <20181203000012.43DFE94783@lists.varnish-cache.org> commit 4185016f67a38e815c37b63ec0b29c52cbf4b588 Author: Federico G. Schwindt Date: Sun Dec 2 23:58:50 2018 +0000 Try to get this test running on SunOS diff --git a/bin/varnishtest/tests/u00006.vtc b/bin/varnishtest/tests/u00006.vtc index 2f1e41476..2f648ab8f 100644 --- a/bin/varnishtest/tests/u00006.vtc +++ b/bin/varnishtest/tests/u00006.vtc @@ -66,18 +66,18 @@ shell -err -expect "Expected positive integer" \ "varnishlog -q {-1}" shell -err -expect "Syntax error in level limit" \ "varnishlog -q {1a}" -shell -err -expect "Expected VSL tag name got ''" \ - "varnishlog -q ''" +shell -err -expect "Expected VSL tag name got '['" \ + {varnishlog -q "[]"} shell -err -expect "Tag name matches zero tags" \ "varnishlog -q foo" shell -err -expect "Tag name is ambiguous" \ "varnishlog -q Resp" -shell -err -expect "Expected string got ''" \ - "varnishlog -q ReqHeader:" +shell -err -expect "Expected string got '['" \ + {varnishlog -q "ReqHeader:[]"} shell -err -expect "Expected integer got ']'" \ - "varnishlog -q ReqHeader:foo[]" + {varnishlog -q "ReqHeader:foo[]"} shell -err -expect "Expected positive integer" \ - "varnishlog -q ReqHeader:foo[a]" + {varnishlog -q "ReqHeader:foo[a]"} process p1 -wait shell {grep -q "0 CLI" ${tmpdir}/vlog} From phk at FreeBSD.org Mon Dec 3 10:02:08 2018 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 3 Dec 2018 10:02:08 +0000 (UTC) Subject: [master] 8f5d92128 Some pylinting Message-ID: <20181203100209.327C3A33CE@lists.varnish-cache.org> commit 8f5d92128a9376f781a0c28bf3bde9574cc8cdb3 Author: Poul-Henning Kamp Date: Mon Dec 3 09:53:20 2018 +0000 Some pylinting diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py index d0955f518..32d4e6f2e 100755 --- a/lib/libvcc/vmodtool.py +++ b/lib/libvcc/vmodtool.py @@ -120,12 +120,12 @@ CTYPES.update(PRIVS) ####################################################################### -def is_quoted(str): - return len(str) > 2 and str[0] == str[-1] and str[0] in ('"', "'") +def is_quoted(txt): + return len(txt) > 2 and txt[0] == txt[-1] and txt[0] in ('"', "'") -def unquote(str): - assert is_quoted(str) - return str[1:-1] +def unquote(txt): + assert is_quoted(txt) + return txt[1:-1] ####################################################################### @@ -364,17 +364,17 @@ class ProtoType(object): self.args.append(t) def vcl_proto(self, short, pfx=""): - if type(self.st) == s_method: + if isinstance(self.st, MethodStanza): pfx += pfx s = pfx - if type(self.st) == s_object: + if isinstance(self.st, ObjectStanza): s += "new " + self.obj + " = " elif self.retval is not None: s += self.retval.vcl() + " " - if type(self.st) == s_object: + if isinstance(self.st, ObjectStanza): s += self.st.vcc.modname + "." + self.name + "(" - elif type(self.st) == s_method: + elif isinstance(self.st, MethodStanza): s += self.obj + self.bname + "(" else: s += self.name + "(" @@ -414,7 +414,7 @@ class ProtoType(object): write_rst_hdr(fo, s, '-') fo.write("\n::\n\n" + self.vcl_proto(False, pfx=" ") + "\n") - def synopsis(self, fo, man): + def synopsis(self, fo, unused_man): fo.write(self.vcl_proto(True, pfx=" ") + "\n") fo.write(" \n") @@ -489,7 +489,7 @@ class ProtoType(object): ####################################################################### -class stanza(object): +class Stanza(object): def __init__(self, toks, l0, doc, vcc): self.toks = toks self.line = l0 @@ -504,6 +504,9 @@ class stanza(object): self.proto = None self.parse() + def parse(self): + assert "subclass should have defined" == "parse method" + def dump(self): print(type(self), self.line) @@ -524,34 +527,33 @@ class stanza(object): self.rsttail(fo, man) fo.write("\n") - def rsthead(self, fo, man): - if self.proto is None: - return - self.proto.rsthead(fo) + def rsthead(self, fo, unused_man): + if self.proto is not None: + self.proto.rsthead(fo) - def rstmid(self, fo, man): + def rstmid(self, fo, unused_man): fo.write("\n".join(self.doc) + "\n") - def rsttail(self, fo, man): + def rsttail(self, unused_fo, unused_man): return def synopsis(self, fo, man): if self.proto is not None: self.proto.synopsis(fo, man) - def cstuff(self, fo, where): + def cstuff(self, unused_fo, unused_where): return - def cstruct(self, fo, define): + def cstruct(self, unused_fo, unused_define): return - def json(self, jl): + def json(self, unused_jl): return ####################################################################### -class s_module(stanza): +class ModuleStanza(Stanza): ''' $Module modname man_section description ... ''' @@ -617,7 +619,7 @@ class s_module(stanza): fo.write("\n") -class s_abi(stanza): +class ABIStanza(Stanza): ''' $ABI [strict|vrt] ''' @@ -635,7 +637,7 @@ class s_abi(stanza): self.vcc.contents.append(self) -class s_prefix(stanza): +class PrefixStanza(Stanza): ''' $Prefix symbol ''' @@ -646,7 +648,7 @@ class s_prefix(stanza): self.vcc.contents.append(self) -class s_synopsis(stanza): +class SynopsisStanza(Stanza): ''' $Synopsis [auto|manual] ''' @@ -664,7 +666,7 @@ class s_synopsis(stanza): self.vcc.contents.append(self) -class s_event(stanza): +class EventStanza(Stanza): ''' $Event function_name ''' @@ -696,7 +698,7 @@ class s_event(stanza): ]) -class s_function(stanza): +class FunctionStanza(Stanza): def parse(self): self.proto = ProtoType(self) self.rstlbl = "func_" + self.proto.name @@ -716,7 +718,7 @@ class s_function(stanza): self.proto.json(jl[-1], self.proto.cname()) -class s_object(stanza): +class ObjectStanza(Stanza): def parse(self): self.proto = ProtoType(self, retval=False) self.proto.obj = "x" + self.proto.name @@ -741,7 +743,7 @@ class s_object(stanza): for i in self.methods: i.rstfile(fo, man) - def rstmid(self, fo, man): + def rstmid(self, unused_fo, unused_man): return def synopsis(self, fo, man): @@ -794,17 +796,17 @@ class s_object(stanza): jl.append(ll) def dump(self): - super(s_object, self).dump() + super(ObjectStanza, self).dump() for i in self.methods: i.dump() ####################################################################### -class s_method(stanza): +class MethodStanza(Stanza): def parse(self): p = self.vcc.contents[-1] - assert type(p) == s_object + assert isinstance(p, ObjectStanza) self.pfx = p.proto.name self.proto = ProtoType(self, prefix=self.pfx) if not self.proto.bname.startswith("."): @@ -828,18 +830,21 @@ class s_method(stanza): ####################################################################### DISPATCH = { - "Module": s_module, - "Prefix": s_prefix, - "ABI": s_abi, - "Event": s_event, - "Function": s_function, - "Object": s_object, - "Method": s_method, - "Synopsis": s_synopsis, + "Module": ModuleStanza, + "Prefix": PrefixStanza, + "ABI": ABIStanza, + "Event": EventStanza, + "Function": FunctionStanza, + "Object": ObjectStanza, + "Method": MethodStanza, + "Synopsis": SynopsisStanza, } class vcc(object): + + ''' Processing context for a single .vcc file ''' + def __init__(self, inputvcc, rstdir, outputprefix): self.inputfile = inputvcc self.rstdir = rstdir @@ -880,7 +885,7 @@ class vcc(object): m(toks, [c[0], " ".join(c[1:])], d.split('\n'), self) inputline = None - def tokenize(self, str, seps=None, quotes=None): + def tokenize(self, txt, seps=None, quotes=None): if seps is None: seps = "[](){},=" if quotes is None: @@ -889,8 +894,8 @@ class vcc(object): out = [] i = 0 inside = False - while i < len(str): - c = str[i] + while i < len(txt): + c = txt[i] # print("T", [c], quote, inside, i) i += 1 if quote is not None and c == quote: @@ -1053,13 +1058,13 @@ class vcc(object): fo.write("\n") for i in self.contents: - if type(i) == s_object: + if isinstance(i, ObjectStanza): i.cstuff(fo, 'c') i.cstuff(fx, 'o') fx.write("/* Functions */\n") for i in self.contents: - if type(i) == s_function: + if isinstance(i, FunctionStanza): i.cstuff(fo, 'c') i.cstuff(fx, 'o') From lasse.karstensen at gmail.com Mon Dec 3 10:27:13 2018 From: lasse.karstensen at gmail.com (Lasse Karstensen) Date: Mon, 3 Dec 2018 10:27:13 +0000 (UTC) Subject: [master] bdad159c9 Add a notification field for temporary messages. Message-ID: <20181203102713.32722A3E04@lists.varnish-cache.org> commit bdad159c9fda2e55c391b9ccefbbab301b1728fc Author: Lasse Karstensen Date: Sun Dec 2 22:09:32 2018 +0100 Add a notification field for temporary messages. diff --git a/bin/varnishstat/varnishstat_curses.c b/bin/varnishstat/varnishstat_curses.c index b44ee70d8..4ae43643d 100644 --- a/bin/varnishstat/varnishstat_curses.c +++ b/bin/varnishstat/varnishstat_curses.c @@ -120,6 +120,10 @@ static double t_sample = 0.; static double interval = 1.; static unsigned vsm_status = 0; +#define NOTIF_MAXLEN 256 +static char notification_message[NOTIF_MAXLEN] = ""; +static double notification_eol = 0.0; + static void init_hitrate(void) { @@ -435,7 +439,8 @@ draw_status(void) mvwprintw(w_status, 1, 0, "Uptime child: "); running(w_status, up_chld, VSM_WRK_RUNNING); - mvwprintw(w_status, 0, 55, "Refresh interval: %.3fs", interval); + if (VTIM_mono() < notification_eol) + mvwaddstr(w_status, 2, 0, notification_message); if (COLS > 70) { mvwprintw(w_status, 0, getmaxx(w_status) - 37, @@ -903,11 +908,19 @@ handle_keypress(int ch) break; case '+': interval += 0.1; + (void)snprintf(notification_message, NOTIF_MAXLEN, + "Refresh interval set to %.1f seconds.", interval); + + notification_eol = VTIM_mono() + 1.25; break; case '-': interval -= 0.1; if (interval < 0.1) interval = 0.1; + (void)snprintf(notification_message, NOTIF_MAXLEN, + "Refresh interval set to %.1f seconds.", interval); + + notification_eol = VTIM_mono() + 1.25; break; case 'v': verbosity = VSC_ChangeLevel(verbosity, 1); From lasse.karstensen at gmail.com Mon Dec 3 10:27:09 2018 From: lasse.karstensen at gmail.com (Lasse Karstensen) Date: Mon, 3 Dec 2018 10:27:09 +0000 (UTC) Subject: [master] 917124bf5 Make it possible to change ncurses update rate. Message-ID: <20181203102713.087EBA3E02@lists.varnish-cache.org> commit 917124bf56a4dc7b05e2f5646c5a99f31325de75 Author: Lasse Karstensen Date: Thu Aug 16 09:14:21 2018 +0200 Make it possible to change ncurses update rate. This is a squashed commit including lint removal and formatting suggested by @nigoroll. diff --git a/bin/varnishstat/varnishstat.c b/bin/varnishstat/varnishstat.c index be9e64c79..0ab37c1ac 100644 --- a/bin/varnishstat/varnishstat.c +++ b/bin/varnishstat/varnishstat.c @@ -324,7 +324,7 @@ main(int argc, char * const *argv) AN(VSC_Arg(vsc, 'f', "MAIN.cache_hit")); AN(VSC_Arg(vsc, 'f', "MAIN.cache_miss")); } - do_curses(vd, vsc, 1.0); + do_curses(vd, vsc); } else if (xml) do_xml(vd, vsc); diff --git a/bin/varnishstat/varnishstat.h b/bin/varnishstat/varnishstat.h index 6a73ef238..00099ea02 100644 --- a/bin/varnishstat/varnishstat.h +++ b/bin/varnishstat/varnishstat.h @@ -35,4 +35,4 @@ #include "vas.h" #include "vcs.h" -void do_curses(struct vsm *, struct vsc *, double); +void do_curses(struct vsm *, struct vsc *); diff --git a/bin/varnishstat/varnishstat_curses.c b/bin/varnishstat/varnishstat_curses.c index ad9c22135..b44ee70d8 100644 --- a/bin/varnishstat/varnishstat_curses.c +++ b/bin/varnishstat/varnishstat_curses.c @@ -435,6 +435,8 @@ draw_status(void) mvwprintw(w_status, 1, 0, "Uptime child: "); running(w_status, up_chld, VSM_WRK_RUNNING); + mvwprintw(w_status, 0, 55, "Refresh interval: %.3fs", interval); + if (COLS > 70) { mvwprintw(w_status, 0, getmaxx(w_status) - 37, "Hitrate n: %8u %8u %8u", hitrate.hr_10.n, hitrate.hr_100.n, @@ -899,6 +901,14 @@ handle_keypress(int ch) current = n_ptarray - 1; page_start = (current - l_points) + 1; break; + case '+': + interval += 0.1; + break; + case '-': + interval -= 0.1; + if (interval < 0.1) + interval = 0.1; + break; case 'v': verbosity = VSC_ChangeLevel(verbosity, 1); rebuild = 1; @@ -980,14 +990,12 @@ delpt(void *priv, const struct VSC_point *const vpt) } void -do_curses(struct vsm *vsm, struct vsc *vsc, double delay) +do_curses(struct vsm *vsm, struct vsc *vsc) { long t; int ch; double now; - interval = delay; - verbosity = VSC_ChangeLevel(NULL, 0); initscr(); diff --git a/doc/sphinx/reference/varnishstat.rst b/doc/sphinx/reference/varnishstat.rst index 89f1f2732..023a6d784 100644 --- a/doc/sphinx/reference/varnishstat.rst +++ b/doc/sphinx/reference/varnishstat.rst @@ -109,6 +109,13 @@ The following keys control the interactive display: Sample now. +<+> + Increase refresh interval. + +<-> + Decrease refresh interval. + + OUTPUTS ======= From lasse.karstensen at gmail.com Mon Dec 3 10:27:13 2018 From: lasse.karstensen at gmail.com (Lasse Karstensen) Date: Mon, 3 Dec 2018 10:27:13 +0000 (UTC) Subject: [master] c510b331a Add test coverage for ncurses update interval. Message-ID: <20181203102713.700CFA3E07@lists.varnish-cache.org> commit c510b331adc4595c5af4b922b2c1b7abb04c7daa Author: Lasse Karstensen Date: Sun Dec 2 22:29:16 2018 +0100 Add test coverage for ncurses update interval. diff --git a/bin/varnishtest/tests/u00008.vtc b/bin/varnishtest/tests/u00008.vtc index 5e1beff3e..0c35fb3fc 100644 --- a/bin/varnishtest/tests/u00008.vtc +++ b/bin/varnishtest/tests/u00008.vtc @@ -1,4 +1,4 @@ -varnishtest "trivial run of varnistat in curses mode" +varnishtest "trivial run of varnishstat in curses mode" server s1 -repeat 4 { rxreq @@ -24,6 +24,14 @@ client c1 { process p1 -expect-text 0 0 "MAIN.s_sess" process p1 -screen_dump +process p1 -write {+} +process p1 -screen_dump +process p1 -expect-text 0 0 "Refresh interval set to 1.1 seconds." + +process p1 -write {-} +process p1 -screen_dump +process p1 -expect-text 0 0 "Refresh interval set to 1.0 seconds." + process p1 -write {vG} process p1 -expect-text 0 0 "VBE.vcl1.s1.req" process p1 -expect-text 0 0 "DIAG" From noreply at github.com Mon Dec 3 10:27:13 2018 From: noreply at github.com (GitHub) Date: Mon, 3 Dec 2018 10:27:13 +0000 (UTC) Subject: [master] 0a64e73ad Merge pull request #2741 from lkarsten/varnishstat_refresh_interval Message-ID: <20181203102713.94539A3E0D@lists.varnish-cache.org> commit 0a64e73ad6e35f864382d5fcc632098f7c7c19bb Merge: 8f5d92128 c510b331a Author: Lasse Karstensen Date: Mon Dec 3 11:26:03 2018 +0100 Merge pull request #2741 from lkarsten/varnishstat_refresh_interval Make it possible to change ncurses update rate. From nils.goroll at uplex.de Mon Dec 3 11:33:08 2018 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 3 Dec 2018 11:33:08 +0000 (UTC) Subject: [master] 5fd5fdba9 vtim-ification Message-ID: <20181203113308.A3E12A57EA@lists.varnish-cache.org> commit 5fd5fdba9fcb3e7b388d86bb714bc2f3ab27e21f Author: Nils Goroll Date: Mon Dec 3 12:30:13 2018 +0100 vtim-ification Inclused re-declaration fixes for some places which I got wrong in the past. diff --git a/bin/varnishd/cache/cache_obj.h b/bin/varnishd/cache/cache_obj.h index bdb6795bd..5229b7e00 100644 --- a/bin/varnishd/cache/cache_obj.h +++ b/bin/varnishd/cache/cache_obj.h @@ -46,7 +46,7 @@ typedef const void *objgetattr_f(struct worker *, struct objcore *, enum obj_attr attr, ssize_t *len); typedef void *objsetattr_f(struct worker *, struct objcore *, enum obj_attr attr, ssize_t len, const void *ptr); -typedef void objtouch_f(struct worker *, struct objcore *, double now); +typedef void objtouch_f(struct worker *, struct objcore *, vtim_real now); struct obj_methods { objfree_f *objfree; diff --git a/bin/varnishd/cache/cache_objhead.h b/bin/varnishd/cache/cache_objhead.h index 81bba4da0..9e90d5b32 100644 --- a/bin/varnishd/cache/cache_objhead.h +++ b/bin/varnishd/cache/cache_objhead.h @@ -72,7 +72,7 @@ enum lookup_e HSH_Lookup(struct req *, struct objcore **, struct objcore **, int always_insert); void HSH_Ref(struct objcore *o); void HSH_AddString(struct req *, void *ctx, const char *str); -unsigned HSH_Purge(struct worker *, struct objhead *, vtim_dur ttl_now, +unsigned HSH_Purge(struct worker *, struct objhead *, vtim_real ttl_now, vtim_dur ttl, vtim_dur grace, vtim_dur keep); struct objcore *HSH_Private(const struct worker *wrk); void HSH_Abandon(struct objcore *oc); diff --git a/bin/varnishd/cache/cache_rfc2616.c b/bin/varnishd/cache/cache_rfc2616.c index ddecb9c4e..c9341fdd0 100644 --- a/bin/varnishd/cache/cache_rfc2616.c +++ b/bin/varnishd/cache/cache_rfc2616.c @@ -62,11 +62,11 @@ */ void -RFC2616_Ttl(struct busyobj *bo, double now, double *t_origin, +RFC2616_Ttl(struct busyobj *bo, vtim_real now, vtim_real *t_origin, float *ttl, float *grace, float *keep) { unsigned max_age, age; - double h_date, h_expires; + vtim_real h_date, h_expires; const char *p; const struct http *hp; @@ -258,7 +258,7 @@ int RFC2616_Do_Cond(const struct req *req) { const char *p, *e; - double ims, lm; + vtim_real ims, lm; /* * We MUST ignore If-Modified-Since if we have an If-None-Match diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c index c85331285..470b769b3 100644 --- a/bin/varnishd/cache/cache_session.c +++ b/bin/varnishd/cache/cache_session.c @@ -252,7 +252,7 @@ HTC_RxPipeline(struct http_conn *htc, void *p) enum htc_status_e HTC_RxStuff(struct http_conn *htc, htc_complete_f *func, - double *t1, double *t2, double ti, double tn, int maxbytes) + vtim_real *t1, vtim_real *t2, vtim_real ti, vtim_real tn, int maxbytes) { vtim_dur tmo; vtim_real now; diff --git a/bin/varnishd/cache/cache_shmlog.c b/bin/varnishd/cache/cache_shmlog.c index d57949a95..3465bd2de 100644 --- a/bin/varnishd/cache/cache_shmlog.c +++ b/bin/varnishd/cache/cache_shmlog.c @@ -372,8 +372,8 @@ VSLb(struct vsl_log *vsl, enum VSL_tag_e tag, const char *fmt, ...) } void -VSLb_ts(struct vsl_log *vsl, const char *event, double first, double *pprev, - double now) +VSLb_ts(struct vsl_log *vsl, const char *event, vtim_real first, + vtim_real *pprev, vtim_real now) { /* XXX: Make an option to turn off some unnecessary timestamp diff --git a/bin/varnishd/cache/cache_tcp_pool.c b/bin/varnishd/cache/cache_tcp_pool.c index 10c24e0da..1eb4f5164 100644 --- a/bin/varnishd/cache/cache_tcp_pool.c +++ b/bin/varnishd/cache/cache_tcp_pool.c @@ -65,7 +65,8 @@ struct pfd { /*-------------------------------------------------------------------- */ -typedef int cp_open_f(const struct conn_pool *, double tmo, const void **privp); +typedef int cp_open_f(const struct conn_pool *, vtim_dur tmo, + const void **privp); typedef void cp_close_f(struct pfd *); typedef int cp_cmp_f(const struct conn_pool *, const void *priv); typedef void cp_name_f(const struct pfd *, char *, unsigned, char *, unsigned); @@ -99,7 +100,7 @@ struct conn_pool { int n_used; - double holddown; + vtim_mono holddown; int holddown_errno; }; @@ -157,7 +158,7 @@ PFD_RemoteName(const struct pfd *p, char *abuf, unsigned alen, char *pbuf, */ static void v_matchproto_(waiter_handle_f) -vcp_handle(struct waited *w, enum wait_event ev, double now) +vcp_handle(struct waited *w, enum wait_event ev, vtim_real now) { struct pfd *pfd; struct conn_pool *cp; @@ -376,10 +377,10 @@ VCP_Recycle(const struct worker *wrk, struct pfd **pfdp) */ static int -VCP_Open(struct conn_pool *cp, double tmo, const void **privp, int *err) +VCP_Open(struct conn_pool *cp, vtim_dur tmo, const void **privp, int *err) { int r; - double h; + vtim_mono h; CHECK_OBJ_NOTNULL(cp, CONN_POOL_MAGIC); AN(err); @@ -486,7 +487,7 @@ VCP_Close(struct pfd **pfdp) */ static struct pfd * -VCP_Get(struct conn_pool *cp, double tmo, struct worker *wrk, +VCP_Get(struct conn_pool *cp, vtim_dur tmo, struct worker *wrk, unsigned force_fresh, int *err) { struct pfd *pfd; @@ -578,13 +579,13 @@ struct vtp_cs { }; static inline int -tmo2msec(double tmo) +tmo2msec(vtim_dur tmo) { return ( (int)floor(tmo * 1000.0) ); } static int v_matchproto_(cp_open_f) -vtp_open(const struct conn_pool *cp, double tmo, const void **privp) +vtp_open(const struct conn_pool *cp, vtim_dur tmo, const void **privp) { int s; int msec; @@ -672,7 +673,7 @@ static const struct cp_methods vtp_methods = { */ static int v_matchproto_(cp_open_f) -vus_open(const struct conn_pool *cp, double tmo, const void **privp) +vus_open(const struct conn_pool *cp, vtim_dur tmo, const void **privp) { int s; int msec; @@ -800,7 +801,7 @@ VTP_Rel(struct tcp_pool **tpp) */ int -VTP_Open(struct tcp_pool *tp, double tmo, const void **privp, int *err) +VTP_Open(struct tcp_pool *tp, vtim_dur tmo, const void **privp, int *err) { return (VCP_Open(tp->cp, tmo, privp, err)); } diff --git a/bin/varnishd/cache/cache_tcp_pool.h b/bin/varnishd/cache/cache_tcp_pool.h index 57564ba96..3c872336f 100644 --- a/bin/varnishd/cache/cache_tcp_pool.h +++ b/bin/varnishd/cache/cache_tcp_pool.h @@ -72,7 +72,7 @@ void VTP_Rel(struct tcp_pool **); * the pool is destroyed and all cached connections closed. */ -int VTP_Open(struct tcp_pool *, double tmo, const void **, int*); +int VTP_Open(struct tcp_pool *, vtim_dur tmo, const void **, int*); /* * Open a new connection and return the adress used. * errno will be returned in the last argument. diff --git a/bin/varnishd/cache/cache_transport.h b/bin/varnishd/cache/cache_transport.h index 5de0920a3..5da5e3501 100644 --- a/bin/varnishd/cache/cache_transport.h +++ b/bin/varnishd/cache/cache_transport.h @@ -79,7 +79,7 @@ void VPX_Send_Proxy(int fd, int version, const struct sess *); /* cache_session.c */ struct sess *SES_New(struct pool *); -void SES_Delete(struct sess *, enum sess_close reason, double now); +void SES_Delete(struct sess *, enum sess_close reason, vtim_real now); void SES_Close(struct sess *, enum sess_close reason); void SES_SetTransport(struct worker *, struct sess *, struct req *, const struct transport *); diff --git a/bin/varnishd/cache/cache_varnishd.h b/bin/varnishd/cache/cache_varnishd.h index a5a3d185b..8b5ad9ebd 100644 --- a/bin/varnishd/cache/cache_varnishd.h +++ b/bin/varnishd/cache/cache_varnishd.h @@ -261,7 +261,7 @@ void ObjSetState(struct worker *, const struct objcore *, enum boc_state_e next); void ObjWaitState(const struct objcore *, enum boc_state_e want); void ObjTrimStore(struct worker *, struct objcore *); -void ObjTouch(struct worker *, struct objcore *, double now); +void ObjTouch(struct worker *, struct objcore *, vtim_real now); void ObjFreeObj(struct worker *, struct objcore *); void ObjSlim(struct worker *, struct objcore *); void *ObjSetAttr(struct worker *, struct objcore *, enum obj_attr, @@ -342,7 +342,7 @@ const char * HTC_Status(enum htc_status_e); void HTC_RxInit(struct http_conn *htc, struct ws *ws); void HTC_RxPipeline(struct http_conn *htc, void *); enum htc_status_e HTC_RxStuff(struct http_conn *, htc_complete_f *, - double *t1, double *t2, double ti, double tn, int maxbytes); + vtim_real *t1, vtim_real *t2, vtim_real ti, vtim_real tn, int maxbytes); #define SESS_ATTR(UP, low, typ, len) \ int SES_Set_##low(const struct sess *sp, const typ *src); \ diff --git a/bin/varnishd/fuzzers/esi_parse_fuzzer.c b/bin/varnishd/fuzzers/esi_parse_fuzzer.c index c09c888ba..972ffa0b1 100644 --- a/bin/varnishd/fuzzers/esi_parse_fuzzer.c +++ b/bin/varnishd/fuzzers/esi_parse_fuzzer.c @@ -56,8 +56,8 @@ VSLb(struct vsl_log *vsl, enum VSL_tag_e tag, const char *fmt, ...) } void -VSLb_ts(struct vsl_log *l, const char *event, double first, double *pprev, - double now) +VSLb_ts(struct vsl_log *l, const char *event, vtim_real first, vtim_real *pprev, + vtim_real now) { (void)l; (void)event; diff --git a/bin/varnishd/waiter/waiter.h b/bin/varnishd/waiter/waiter.h index 531f640d7..4a0d8a7d5 100644 --- a/bin/varnishd/waiter/waiter.h +++ b/bin/varnishd/waiter/waiter.h @@ -52,7 +52,7 @@ enum wait_event { WAITER_CLOSE }; -typedef void waiter_handle_f(struct waited *, enum wait_event, double now); +typedef void waiter_handle_f(struct waited *, enum wait_event, vtim_real now); struct waited { unsigned magic; @@ -62,8 +62,8 @@ struct waited { void *priv1; uintptr_t priv2; waiter_handle_f *func; - volatile double *tmo; - double idle; + volatile vtim_real *tmo; + vtim_real idle; }; /* cache_waiter.c */ diff --git a/bin/varnishstat/varnishstat_curses.c b/bin/varnishstat/varnishstat_curses.c index 4ae43643d..4b1703e6c 100644 --- a/bin/varnishstat/varnishstat_curses.c +++ b/bin/varnishstat/varnishstat_curses.c @@ -122,7 +122,7 @@ static unsigned vsm_status = 0; #define NOTIF_MAXLEN 256 static char notification_message[NOTIF_MAXLEN] = ""; -static double notification_eol = 0.0; +static vtim_mono notification_eol = 0.0; static void init_hitrate(void) diff --git a/include/vnum.h b/include/vnum.h index b24545015..266f156f5 100644 --- a/include/vnum.h +++ b/include/vnum.h @@ -31,5 +31,5 @@ /* from libvarnish/vnum.c */ double VNUM(const char *p); double VNUMpfx(const char *p, const char **e); -double VNUM_duration(const char *p); +vtim_dur VNUM_duration(const char *p); const char *VNUM_2bytes(const char *p, uintmax_t *r, uintmax_t rel); diff --git a/include/vtim.h b/include/vtim.h index 1968bc568..b1898a39d 100644 --- a/include/vtim.h +++ b/include/vtim.h @@ -31,10 +31,10 @@ /* from libvarnish/vtim.c */ extern unsigned VTIM_postel; #define VTIM_FORMAT_SIZE 30 -void VTIM_format(double t, char *p); -double VTIM_parse(const char *p); +void VTIM_format(vtim_real t, char *p); +vtim_real VTIM_parse(const char *p); vtim_mono VTIM_mono(void); vtim_real VTIM_real(void); void VTIM_sleep(vtim_dur t); -struct timespec VTIM_timespec(vtim_dur t); -struct timeval VTIM_timeval(vtim_dur t); +struct timespec VTIM_timespec(vtim_real t); +struct timeval VTIM_timeval(vtim_real t); diff --git a/lib/libvmod_directors/shard_dir.c b/lib/libvmod_directors/shard_dir.c index acee05780..624ac2f9d 100644 --- a/lib/libvmod_directors/shard_dir.c +++ b/lib/libvmod_directors/shard_dir.c @@ -164,7 +164,7 @@ shard_next(struct shard_state *state, VCL_INT skip, VCL_BOOL healthy) int c, chosen = -1; uint32_t ringsz; VCL_BACKEND be; - double changed; + vtim_real changed; struct shard_be_info *sbe; AN(state); @@ -320,7 +320,7 @@ sharddir_any_healthy(VRT_CTX, struct sharddir *shardd, VCL_TIME *changed) unsigned retval = 0; VCL_BACKEND be; unsigned u; - double c; + vtim_real c; CHECK_OBJ_NOTNULL(shardd, SHARDDIR_MAGIC); sharddir_rdlock(shardd); diff --git a/lib/libvmod_directors/vdir.c b/lib/libvmod_directors/vdir.c index 61f78139e..50deb0244 100644 --- a/lib/libvmod_directors/vdir.c +++ b/lib/libvmod_directors/vdir.c @@ -172,7 +172,7 @@ vdir_any_healthy(VRT_CTX, struct vdir *vd, VCL_TIME *changed) unsigned retval = 0; VCL_BACKEND be; unsigned u; - double c; + vtim_real c; CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(vd, VDIR_MAGIC); From daghf at varnish-software.com Mon Dec 3 11:50:08 2018 From: daghf at varnish-software.com (Dag Haavi Finstad) Date: Mon, 3 Dec 2018 11:50:08 +0000 (UTC) Subject: [master] f42db30d4 Add some testing bits for VSL -R Message-ID: <20181203115008.46EA7A5F29@lists.varnish-cache.org> commit f42db30d48fdbcc15f8c2d241e700935ccce5077 Author: Dag Haavi Finstad Date: Mon Dec 3 11:39:42 2018 +0100 Add some testing bits for VSL -R diff --git a/bin/varnishtest/tests/u00003.vtc b/bin/varnishtest/tests/u00003.vtc index 30dc846e1..e6dac92f1 100644 --- a/bin/varnishtest/tests/u00003.vtc +++ b/bin/varnishtest/tests/u00003.vtc @@ -26,7 +26,7 @@ varnish v1 -vcl+backend { shell { varnishncsa -n ${v1_name} -D -P ${tmpdir}/ncsa.pid \ - -w ${tmpdir}/ncsa.log + -w ${tmpdir}/ncsa.log -R 100/s } process p1 -winsz 25 132 {varnishncsa -n ${v1_name}} -start diff --git a/bin/varnishtest/tests/u00006.vtc b/bin/varnishtest/tests/u00006.vtc index 2f648ab8f..9ffb331e7 100644 --- a/bin/varnishtest/tests/u00006.vtc +++ b/bin/varnishtest/tests/u00006.vtc @@ -12,7 +12,7 @@ process p1 { } -start shell { exec varnishlog -n ${v1_name} -D -P ${tmpdir}/vlog.pid \ - -w ${tmpdir}/vlog.bin + -w ${tmpdir}/vlog.bin -R 10/s } shell -match "Usage: .*varnishlog " \ @@ -79,6 +79,25 @@ shell -err -expect "Expected integer got ']'" \ shell -err -expect "Expected positive integer" \ {varnishlog -q "ReqHeader:foo[a]"} +shell -err -expect "-R: Syntax error" \ + "varnishlog -R 1foo" +shell -err -expect "-R: Range error" \ + "varnishlog -R 0" +shell -err -expect "-R: Range error" \ + "varnishlog -R -1" +shell -err -expect "-R: Range error" \ + "varnishlog -R 3000000000" +shell -err -expect "-R: Syntax error: Invalid duration" \ + "varnishlog -R 10/0s" +shell -err -expect "-R: Syntax error: Invalid duration" \ + "varnishlog -R 10/-10s" +shell -err -expect "-R: Syntax error: Invalid duration" \ + "varnishlog -R 10/1q" +shell -err -expect "-R: Syntax error: Invalid duration" \ + "varnishlog -R 10/11f09s" +shell -err -expect "-R: Syntax error" \ + "varnishlog -R 1000000000/1000000000000000000000000000000s" + process p1 -wait shell {grep -q "0 CLI" ${tmpdir}/vlog} shell -match "0 CLI[ ]+- Wr 200 [0-9]+ PONG" \ From dridi.boukelmoune at gmail.com Mon Dec 3 13:15:09 2018 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 3 Dec 2018 13:15:09 +0000 (UTC) Subject: [master] 7854af8fa Tolerate null IP addresses for ACL matches Message-ID: <20181203131509.EA2E5A7956@lists.varnish-cache.org> commit 7854af8fa91020fc4204b5995c23dae9ef71db9b Author: Dridi Boukelmoune Date: Wed Nov 28 11:30:18 2018 +0100 Tolerate null IP addresses for ACL matches A vmod may return a null IP. This relaxes the check in VRT_acl_match to fail the transaction instead of crashing. Refs #2842 diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c index 0c28ba29e..9ab637fed 100644 --- a/bin/varnishd/cache/cache_vrt.c +++ b/bin/varnishd/cache/cache_vrt.c @@ -82,6 +82,10 @@ VRT_acl_match(VRT_CTX, VCL_ACL acl, VCL_IP ip) CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(acl, VRT_ACL_MAGIC); + if (ip == NULL) { + VRT_fail(ctx, "Cannot match a null IP address"); + return (0); + } assert(VSA_Sane(ip)); return (acl->match(ctx, ip)); } diff --git a/bin/varnishtest/tests/r01504.vtc b/bin/varnishtest/tests/r01504.vtc index 02182a519..9767ff0b4 100644 --- a/bin/varnishtest/tests/r01504.vtc +++ b/bin/varnishtest/tests/r01504.vtc @@ -1,10 +1,26 @@ -varnishtest "unreferenced acls" +varnishtest "unreferenced or null acls" varnish v1 -arg "-p vcc_err_unref=off" -vcl { + import vtc; backend s1 { - .host = "127.0.0.1"; + .host = "${bad_backend}"; } acl foo { "127.0.0.1"; } -} + acl bar { + "127.0.0.1"; + } + sub vcl_recv { + if (vtc.no_ip() ~ bar) { + return (synth(200)); + } + } +} -start + +client c1 { + txreq + rxresp + expect resp.status == 503 + expect resp.body ~ "VCL failed" +} -run diff --git a/lib/libvmod_vtc/vmod.vcc b/lib/libvmod_vtc/vmod.vcc index 94f8f75b6..248f4b2d6 100644 --- a/lib/libvmod_vtc/vmod.vcc +++ b/lib/libvmod_vtc/vmod.vcc @@ -66,6 +66,10 @@ $Function STEVEDORE no_stevedore() Fails at storage selection. +$Function IP no_ip() + +Returns a null IP address, not even a bogo_ip. + $Function VOID panic(STRING_LIST) It can be useful to crash the child process in order to test the robustness diff --git a/lib/libvmod_vtc/vmod_vtc.c b/lib/libvmod_vtc/vmod_vtc.c index c2d4f383c..72320ba94 100644 --- a/lib/libvmod_vtc/vmod_vtc.c +++ b/lib/libvmod_vtc/vmod_vtc.c @@ -88,6 +88,14 @@ vmod_no_stevedore(VRT_CTX) return (NULL); } +VCL_IP v_matchproto_(td_vtc_no_ip) +vmod_no_ip(VRT_CTX) +{ + + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + return (NULL); +} + /*--------------------------------------------------------------------*/ VCL_VOID v_matchproto_(td_vtc_panic) From daghf at varnish-software.com Mon Dec 3 13:32:09 2018 From: daghf at varnish-software.com (Dag Haavi Finstad) Date: Mon, 3 Dec 2018 13:32:09 +0000 (UTC) Subject: [master] ec554a0f1 vsl -R: Add strtol underflow/overflow handling Message-ID: <20181203133209.6F6D1A802E@lists.varnish-cache.org> commit ec554a0f1483c793c2e978ce935c2c8e9dacb3f9 Author: Dag Haavi Finstad Date: Mon Dec 3 14:31:35 2018 +0100 vsl -R: Add strtol underflow/overflow handling diff --git a/lib/libvarnishapi/vsl_arg.c b/lib/libvarnishapi/vsl_arg.c index 2929b4ccf..c72d5a1a9 100644 --- a/lib/libvarnishapi/vsl_arg.c +++ b/lib/libvarnishapi/vsl_arg.c @@ -310,7 +310,10 @@ vsl_R_arg(struct VSL_data *vsl, const char *arg) AN(arg); CHECK_OBJ_NOTNULL(vsl, VSL_MAGIC); + errno = 0; l = strtol(arg, &p, 0); + if ((l == LONG_MIN || l == LONG_MAX) && errno == ERANGE) + return (vsl_diag(vsl, "-R: Range error")); if (l <= 0 || l > INT_MAX) return (vsl_diag(vsl, "-R: Range error")); vsl->R_opt_l = l; From nils.goroll at uplex.de Mon Dec 3 20:14:13 2018 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 3 Dec 2018 20:14:13 +0000 (UTC) Subject: [master] ad98214ea rename OC_F_PASS -> OC_F_HFM - zero code change Message-ID: <20181203201413.EA30F60DC5@lists.varnish-cache.org> commit ad98214eafa8975be8d34d6a24577b19293510b4 Author: Nils Goroll Date: Mon Dec 3 21:11:05 2018 +0100 rename OC_F_PASS -> OC_F_HFM - zero code change Now that we got hit-for-pass (hfp) and hit-for-miss (hfm), we should name the latter consistently to avoid unnecessary confusion diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 1056eca9f..9e0f5cb4d 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -126,7 +126,7 @@ vbf_beresp2obj(struct busyobj *bo) l += l2; if (bo->uncacheable) - bo->fetch_objcore->flags |= OC_F_PASS; + bo->fetch_objcore->flags |= OC_F_HFM; if (!vbf_allocobj(bo, l)) { if (vary != NULL) @@ -195,7 +195,7 @@ vbf_stp_mkbereq(struct worker *wrk, struct busyobj *bo) if (bo->stale_oc != NULL && ObjCheckFlag(bo->wrk, bo->stale_oc, OF_IMSCAND) && (bo->stale_oc->boc != NULL || ObjGetLen(wrk, bo->stale_oc) != 0)) { - AZ(bo->stale_oc->flags & (OC_F_PASS|OC_F_PRIVATE)); + AZ(bo->stale_oc->flags & (OC_F_HFM|OC_F_PRIVATE)); q = HTTP_GetHdrPack(bo->wrk, bo->stale_oc, H_Last_Modified); if (q != NULL) http_PrintfHeader(bo->bereq0, @@ -355,7 +355,7 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo) if (http_IsStatus(bo->beresp, 304)) { if (bo->stale_oc != NULL && ObjCheckFlag(bo->wrk, bo->stale_oc, OF_IMSCAND)) { - AZ(bo->stale_oc->flags & (OC_F_PASS|OC_F_PRIVATE)); + AZ(bo->stale_oc->flags & (OC_F_HFM|OC_F_PRIVATE)); if (ObjCheckFlag(bo->wrk, bo->stale_oc, OF_CHGGZIP)) { /* * If we changed the gzip status of the object @@ -418,7 +418,7 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo) wrk->handling = VCL_RET_DELIVER; } if (bo->do_pass || bo->uncacheable) - bo->fetch_objcore->flags |= OC_F_PASS; + bo->fetch_objcore->flags |= OC_F_HFM; assert(wrk->handling == VCL_RET_DELIVER); @@ -454,7 +454,7 @@ vbf_stp_fetchbody(struct worker *wrk, struct busyobj *bo) * We don't fail the fetch, in order for HitMiss * objects to be created. */ - AN(vfc->oc->flags & OC_F_PASS); + AN(vfc->oc->flags & OC_F_HFM); VSLb(wrk->vsl, SLT_Debug, "Fetch: Pass delivery abandoned"); bo->htc->doclose = SC_RX_BODY; @@ -551,7 +551,7 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) ObjSetFlag(bo->wrk, bo->fetch_objcore, OF_##U, 1); #include "tbl/obj_attr.h" - if (!(bo->fetch_objcore->flags & OC_F_PASS) && + if (!(bo->fetch_objcore->flags & OC_F_HFM) && http_IsStatus(bo->beresp, 200) && ( http_GetHdr(bo->beresp, H_Last_Modified, &p) || http_GetHdr(bo->beresp, H_ETag, &p))) diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index d8cd7e332..5e1cff9e3 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -445,7 +445,7 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp, ObjGetXID(wrk, oc), EXP_Dttl(req, oc)); oc = NULL; retval = HSH_MISS; - } else if (oc->flags & OC_F_PASS) { + } else if (oc->flags & OC_F_HFM) { wrk->stats->cache_hitmiss++; VSLb(req->vsl, SLT_HitMiss, "%u %.6f", ObjGetXID(wrk, oc), EXP_Dttl(req, oc)); @@ -472,7 +472,7 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp, } } - if (exp_oc != NULL && exp_oc->flags & OC_F_PASS) { + if (exp_oc != NULL && exp_oc->flags & OC_F_HFM) { wrk->stats->cache_hitmiss++; VSLb(req->vsl, SLT_HitMiss, "%u %.6f", ObjGetXID(wrk, exp_oc), EXP_Dttl(req, exp_oc)); diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index ae807f739..c1bae241a 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -387,7 +387,7 @@ cnt_transmit(struct worker *wrk, struct req *req) http_Unset(req->resp, H_Content_Length); } else if (clval >= 0 && clval == req->resp_len) { /* Reuse C-L header */ - } else if (head && req->objcore->flags & OC_F_PASS) { + } else if (head && req->objcore->flags & OC_F_HFM) { /* * Don't touch C-L header (debatable) * @@ -409,9 +409,9 @@ cnt_transmit(struct worker *wrk, struct req *req) VSLb_ts_req(req, "Resp", W_TIM_real(wrk)); - if (req->objcore->flags & (OC_F_PRIVATE | OC_F_PASS | OC_F_HFP)) { + if (req->objcore->flags & (OC_F_PRIVATE | OC_F_HFM | OC_F_HFP)) { if (req->objcore->flags & OC_F_HFP) - AN(req->objcore->flags & OC_F_PASS); + AN(req->objcore->flags & OC_F_HFM); if (boc != NULL) { HSH_Abandon(req->objcore); ObjWaitState(req->objcore, BOS_FINISHED); @@ -521,7 +521,7 @@ cnt_lookup(struct worker *wrk, struct req *req) CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); AZ(oc->flags & OC_F_BUSY); req->objcore = oc; - AZ(oc->flags & OC_F_PASS); + AZ(oc->flags & OC_F_HFM); VSLb(req->vsl, SLT_Hit, "%u %.6f %.6f %.6f", ObjGetXID(wrk, req->objcore), @@ -534,7 +534,7 @@ cnt_lookup(struct worker *wrk, struct req *req) switch (wrk->handling) { case VCL_RET_DELIVER: if (busy != NULL) { - AZ(oc->flags & OC_F_PASS); + AZ(oc->flags & OC_F_HFM); CHECK_OBJ_NOTNULL(busy->boc, BOC_MAGIC); // XXX: shouldn't we go to miss? VBF_Fetch(wrk, req, busy, oc, VBF_BACKGROUND); diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index e9e821f11..a12c5fea2 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -822,7 +822,7 @@ VRT_r_obj_uncacheable(VRT_CTX) CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); CHECK_OBJ_NOTNULL(ctx->req->objcore, OBJCORE_MAGIC); - return (ctx->req->objcore->flags & OC_F_PASS ? 1 : 0); + return (ctx->req->objcore->flags & OC_F_HFM ? 1 : 0); } /*--------------------------------------------------------------------*/ diff --git a/include/tbl/oc_flags.h b/include/tbl/oc_flags.h index fc8788b64..84fd86f80 100644 --- a/include/tbl/oc_flags.h +++ b/include/tbl/oc_flags.h @@ -30,7 +30,7 @@ OC_FLAG(PURGED, purged, (1<<0)) //lint !e835 OC_FLAG(BUSY, busy, (1<<1)) -OC_FLAG(PASS, pass, (1<<2)) +OC_FLAG(HFM, hfm, (1<<2)) OC_FLAG(HFP, hfp, (1<<3)) OC_FLAG(ABANDON, abandon, (1<<4)) OC_FLAG(PRIVATE, private, (1<<5)) From nils.goroll at uplex.de Mon Dec 3 20:18:07 2018 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 3 Dec 2018 20:18:07 +0000 (UTC) Subject: [master] 9cb08c1d8 merge HSH_EXP and HSH_EXPBUSY into HSH_GRACE Message-ID: <20181203201807.9C0A660FF2@lists.varnish-cache.org> commit 9cb08c1d8f51bad69f3fe78951d606f1db11137e Author: Nils Goroll Date: Mon Dec 3 21:17:05 2018 +0100 merge HSH_EXP and HSH_EXPBUSY into HSH_GRACE they are the same case diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index 5e1cff9e3..1d615d28b 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -496,7 +496,7 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp, } else { if (exp_oc->hits < LONG_MAX) exp_oc->hits++; - retval = HSH_EXPBUSY; + retval = HSH_GRACE; } } else { Lck_Unlock(&oh->mtx); @@ -518,7 +518,7 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp, assert(HSH_DerefObjHead(wrk, &oh)); if (exp_oc->hits < LONG_MAX) exp_oc->hits++; - return (HSH_EXP); + return (HSH_GRACE); } /* There are one or more busy objects, wait for them */ diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index c1bae241a..33010aba9 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -543,7 +543,7 @@ cnt_lookup(struct worker *wrk, struct req *req) } wrk->stats->cache_hit++; req->is_hit = 1; - if (lr == HSH_EXP || lr == HSH_EXPBUSY) + if (lr == HSH_GRACE) wrk->stats->cache_hit_grace++; req->req_step = R_STP_DELIVER; return (REQ_FSM_MORE); diff --git a/bin/varnishd/hash/hash_slinger.h b/bin/varnishd/hash/hash_slinger.h index d6cad78ae..aa4f284f4 100644 --- a/bin/varnishd/hash/hash_slinger.h +++ b/bin/varnishd/hash/hash_slinger.h @@ -53,8 +53,7 @@ enum lookup_e { HSH_MISS, HSH_BUSY, HSH_HIT, - HSH_EXP, - HSH_EXPBUSY + HSH_GRACE }; /* mgt_hash.c */ From nils.goroll at uplex.de Mon Dec 3 21:20:10 2018 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 3 Dec 2018 21:20:10 +0000 (UTC) Subject: [master] ed4ed27f1 Introduce HSH_HITPASS and HSH_HITMISS and clarify grace/keep HSH_HITMISS Message-ID: <20181203212010.C61DB62352@lists.varnish-cache.org> commit ed4ed27f1c24a9b336d6462d198d6518358bb202 Author: Nils Goroll Date: Mon Dec 3 21:34:12 2018 +0100 Introduce HSH_HITPASS and HSH_HITMISS and clarify grace/keep HSH_HITMISS diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index 1d615d28b..8e59f101d 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -444,14 +444,14 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp, VSLb(req->vsl, SLT_HitPass, "%u %.6f", ObjGetXID(wrk, oc), EXP_Dttl(req, oc)); oc = NULL; - retval = HSH_MISS; + retval = HSH_HITPASS; } else if (oc->flags & OC_F_HFM) { wrk->stats->cache_hitmiss++; VSLb(req->vsl, SLT_HitMiss, "%u %.6f", ObjGetXID(wrk, oc), EXP_Dttl(req, oc)); *bocp = hsh_insert_busyobj(wrk, oh); oc->refcnt++; - retval = HSH_MISS; + retval = HSH_HITMISS; } else { oc->refcnt++; if (oc->hits < LONG_MAX) @@ -473,11 +473,17 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp, } if (exp_oc != NULL && exp_oc->flags & OC_F_HFM) { + /* + * expired HFM ("grace/keep HFM") + * + * XXX should HFM objects actually have grace/keep ? + */ wrk->stats->cache_hitmiss++; VSLb(req->vsl, SLT_HitMiss, "%u %.6f", ObjGetXID(wrk, exp_oc), EXP_Dttl(req, exp_oc)); - exp_oc = NULL; - busy_found = 0; + *bocp = hsh_insert_busyobj(wrk, oh); + Lck_Unlock(&oh->mtx); + return (HSH_HITMISS); } if (!busy_found) { diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 33010aba9..477e4f468 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -503,21 +503,23 @@ cnt_lookup(struct worker *wrk, struct req *req) } AZ(req->objcore); - if (lr == HSH_MISS) { - if (busy != NULL) { - /* hitmiss, out-of-grace or ordinary miss */ - AN(busy->flags & OC_F_BUSY); - req->objcore = busy; - req->stale_oc = oc; - req->req_step = R_STP_MISS; - } else { - /* hitpass */ - AZ(oc); - req->req_step = R_STP_PASS; - } + if (lr == HSH_MISS || lr == HSH_HITMISS) { + AN(busy); + AN(busy->flags & OC_F_BUSY); + req->objcore = busy; + req->stale_oc = oc; + req->req_step = R_STP_MISS; + return (REQ_FSM_MORE); + } + if (lr == HSH_HITPASS) { + AZ(busy); + AZ(oc); + req->req_step = R_STP_PASS; return (REQ_FSM_MORE); } + assert(lr == HSH_HIT || lr == HSH_GRACE); + CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); AZ(oc->flags & OC_F_BUSY); req->objcore = oc; diff --git a/bin/varnishd/hash/hash_slinger.h b/bin/varnishd/hash/hash_slinger.h index aa4f284f4..9434ce874 100644 --- a/bin/varnishd/hash/hash_slinger.h +++ b/bin/varnishd/hash/hash_slinger.h @@ -53,6 +53,8 @@ enum lookup_e { HSH_MISS, HSH_BUSY, HSH_HIT, + HSH_HITMISS, + HSH_HITPASS, HSH_GRACE }; From nils.goroll at uplex.de Mon Dec 3 21:20:10 2018 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 3 Dec 2018 21:20:10 +0000 (UTC) Subject: [master] f35b86bc1 reduce amount of work done under the objhead mutex Message-ID: <20181203212010.DB8BA62354@lists.varnish-cache.org> commit f35b86bc1d3a9d1b61979667fc07e4fffedc27ae Author: Nils Goroll Date: Mon Dec 3 22:11:53 2018 +0100 reduce amount of work done under the objhead mutex in particular, move logging diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index 8e59f101d..d1491d592 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -348,6 +348,8 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp, int busy_found; enum lookup_e retval; const uint8_t *vary; + unsigned xid = 0; + float dttl = 0.0; AN(ocp); *ocp = NULL; @@ -440,15 +442,13 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp, assert(oh->refcnt > 1); assert(oc->objhead == oh); if (oc->flags & OC_F_HFP) { - wrk->stats->cache_hitpass++; - VSLb(req->vsl, SLT_HitPass, "%u %.6f", - ObjGetXID(wrk, oc), EXP_Dttl(req, oc)); + xid = ObjGetXID(wrk, oc); + dttl = EXP_Dttl(req, oc); oc = NULL; retval = HSH_HITPASS; } else if (oc->flags & OC_F_HFM) { - wrk->stats->cache_hitmiss++; - VSLb(req->vsl, SLT_HitMiss, "%u %.6f", - ObjGetXID(wrk, oc), EXP_Dttl(req, oc)); + xid = ObjGetXID(wrk, oc); + dttl = EXP_Dttl(req, oc); *bocp = hsh_insert_busyobj(wrk, oh); oc->refcnt++; retval = HSH_HITMISS; @@ -462,6 +462,24 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp, *ocp = oc; if (*bocp == NULL) assert(HSH_DerefObjHead(wrk, &oh)); + + switch (retval) { + case HSH_HITPASS: + wrk->stats->cache_hitpass++; + VSLb(req->vsl, SLT_HitPass, "%u %.6f", + xid, dttl); + break; + case HSH_HITMISS: + wrk->stats->cache_hitmiss++; + VSLb(req->vsl, SLT_HitMiss, "%u %.6f", + xid, dttl); + break; + case HSH_HIT: + break; + default: + INCOMPL(); + } + return (retval); } if (EXP_Ttl(NULL, oc) < req->t_req && /* ignore req.ttl */ @@ -478,11 +496,13 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp, * * XXX should HFM objects actually have grace/keep ? */ - wrk->stats->cache_hitmiss++; - VSLb(req->vsl, SLT_HitMiss, "%u %.6f", ObjGetXID(wrk, exp_oc), - EXP_Dttl(req, exp_oc)); + xid = ObjGetXID(wrk, exp_oc); + dttl = EXP_Dttl(req, exp_oc); *bocp = hsh_insert_busyobj(wrk, oh); Lck_Unlock(&oh->mtx); + + wrk->stats->cache_hitmiss++; + VSLb(req->vsl, SLT_HitMiss, "%u %.6f", xid, dttl); return (HSH_HITMISS); } @@ -528,13 +548,11 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp, } /* There are one or more busy objects, wait for them */ + VTAILQ_INSERT_TAIL(&oh->waitinglist, req, w_list); + Lck_Unlock(&oh->mtx); AZ(req->hash_ignore_busy); - VTAILQ_INSERT_TAIL(&oh->waitinglist, req, w_list); - if (DO_DEBUG(DBG_WAITINGLIST)) - VSLb(req->vsl, SLT_Debug, "on waiting list <%p>", oh); - wrk->stats->busy_sleep++; /* * The objhead reference transfers to the sess, we get it @@ -544,7 +562,10 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp, req->hash_objhead = oh; req->wrk = NULL; req->waitinglist = 1; - Lck_Unlock(&oh->mtx); + + if (DO_DEBUG(DBG_WAITINGLIST)) + VSLb(req->vsl, SLT_Debug, "on waiting list <%p>", oh); + return (HSH_BUSY); } From nils.goroll at uplex.de Mon Dec 3 21:47:08 2018 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 3 Dec 2018 21:47:08 +0000 (UTC) Subject: [master] 6f57a2190 Add req.is_hitmiss and req.is_hitpass Message-ID: <20181203214708.32DBD62EC5@lists.varnish-cache.org> commit 6f57a2190283aa812482157d713ac51d17a529e6 Author: Nils Goroll Date: Mon Dec 3 22:43:50 2018 +0100 Add req.is_hitmiss and req.is_hitpass Closes #2743 diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 477e4f468..dd77bf033 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -509,12 +509,15 @@ cnt_lookup(struct worker *wrk, struct req *req) req->objcore = busy; req->stale_oc = oc; req->req_step = R_STP_MISS; + if (lr == HSH_HITMISS) + req->is_hitmiss = 1; return (REQ_FSM_MORE); } if (lr == HSH_HITPASS) { AZ(busy); AZ(oc); req->req_step = R_STP_PASS; + req->is_hitpass = 1; return (REQ_FSM_MORE); } @@ -815,6 +818,8 @@ cnt_recv_prep(struct req *req, const char *ci) req->vdc->retval = 0; req->is_hit = 0; + req->is_hitmiss = 0; + req->is_hitpass = 0; } /*-------------------------------------------------------------------- * We have a complete request, set everything up and start it. diff --git a/bin/varnishtest/tests/c00014.vtc b/bin/varnishtest/tests/c00014.vtc index a0dbf5493..6fc238813 100644 --- a/bin/varnishtest/tests/c00014.vtc +++ b/bin/varnishtest/tests/c00014.vtc @@ -16,6 +16,12 @@ server s1 { } -start varnish v1 -vcl+backend { + sub vcl_miss { + set req.http.hitmiss = req.is_hitmiss; + } + sub vcl_deliver { + set resp.http.hitmiss = req.http.hitmiss; + } sub vcl_backend_response { set beresp.do_stream = false; set beresp.uncacheable = true; @@ -28,6 +34,7 @@ client c1 { expect resp.status == 200 expect resp.bodylen == 12 expect resp.http.x-varnish == "1001" + expect resp.http.hitmiss == "false" } -start barrier b1 sync @@ -39,6 +46,7 @@ client c2 { expect resp.status == 200 expect resp.bodylen == 6 expect resp.http.x-varnish == "1004" + expect resp.http.hitmiss == "true" } -run client c1 -wait diff --git a/bin/varnishtest/tests/c00081.vtc b/bin/varnishtest/tests/c00081.vtc index b08fa3250..ffd344080 100644 --- a/bin/varnishtest/tests/c00081.vtc +++ b/bin/varnishtest/tests/c00081.vtc @@ -12,10 +12,10 @@ server s1 { varnish v1 -vcl+backend { sub vcl_miss { - set req.http.miss = "True"; + set req.http.miss = true; } sub vcl_pass { - set req.http.pass = "True"; + set req.http.hitpass = req.is_hitpass; } sub vcl_backend_response { @@ -24,7 +24,7 @@ varnish v1 -vcl+backend { sub vcl_deliver { set resp.http.miss = req.http.miss; - set resp.http.pass = req.http.pass; + set resp.http.hitpass = req.http.hitpass; } } -start @@ -36,17 +36,17 @@ logexpect l1 -v v1 -g vxid { client c1 { txreq rxresp - expect resp.http.miss == True + expect resp.http.miss == true txreq rxresp - expect resp.http.pass == True + expect resp.http.hitpass == true delay 3 txreq rxresp - expect resp.http.miss == True + expect resp.http.miss == true } -run logexpect l1 -wait diff --git a/doc/changes.rst b/doc/changes.rst index a3d500a28..f80b52ef7 100644 Binary files a/doc/changes.rst and b/doc/changes.rst differ diff --git a/doc/sphinx/reference/vcl_var.rst b/doc/sphinx/reference/vcl_var.rst index c0007a761..c962f3147 100644 --- a/doc/sphinx/reference/vcl_var.rst +++ b/doc/sphinx/reference/vcl_var.rst @@ -391,6 +391,21 @@ req.hash_always_miss This is useful to force-update the cache without invalidating existing entries in case the fetch fails. +req.is_hitmiss + + Type: BOOL + + Readable from: client + + If this request resulted in a hitmiss + +req.is_hitpass + + Type: BOOL + + Readable from: client + + If this request resulted in a hitpass req_top.method diff --git a/include/tbl/req_flags.h b/include/tbl/req_flags.h index e23b9c1a2..2c0dbe803 100644 --- a/include/tbl/req_flags.h +++ b/include/tbl/req_flags.h @@ -34,6 +34,8 @@ REQ_FLAG(disable_esi, 0, 0, "") REQ_FLAG(hash_ignore_busy, 1, 1, "") REQ_FLAG(hash_always_miss, 1, 1, "") REQ_FLAG(is_hit, 0, 0, "") +REQ_FLAG(is_hitmiss, 1, 0, "") +REQ_FLAG(is_hitpass, 1, 0, "") REQ_FLAG(waitinglist, 0, 0, "") REQ_FLAG(want100cont, 0, 0, "") REQ_FLAG(late100cont, 0, 0, "") From nils.goroll at uplex.de Mon Dec 3 22:08:13 2018 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 3 Dec 2018 22:08:13 +0000 (UTC) Subject: [master] a1d2db691 I garbled changes.rst Message-ID: <20181203220813.0ACCE63641@lists.varnish-cache.org> commit a1d2db691eef3ee09ec30c591006c9aa2a5026f5 Author: Nils Goroll Date: Mon Dec 3 23:06:57 2018 +0100 I garbled changes.rst diff --git a/doc/changes.rst b/doc/changes.rst index f80b52ef7..79e353b15 100644 Binary files a/doc/changes.rst and b/doc/changes.rst differ From nils.goroll at uplex.de Mon Dec 3 22:08:12 2018 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 3 Dec 2018 22:08:12 +0000 (UTC) Subject: [master] cf955a495 add a lookup enum never to escape HSH_Lookup Message-ID: <20181203220812.EC22D6363F@lists.varnish-cache.org> commit cf955a495f870d77fdb2d945b5379eaf187af894 Author: Nils Goroll Date: Mon Dec 3 22:49:51 2018 +0100 add a lookup enum never to escape HSH_Lookup This is caught by assert(lr == HSH_HIT || lr == HSH_GRACE); in cnt_lookup() diff --git a/bin/varnishd/hash/hash_slinger.h b/bin/varnishd/hash/hash_slinger.h index 9434ce874..6c17b8374 100644 --- a/bin/varnishd/hash/hash_slinger.h +++ b/bin/varnishd/hash/hash_slinger.h @@ -50,6 +50,7 @@ struct hash_slinger { }; enum lookup_e { + HSH_CONTINUE, HSH_MISS, HSH_BUSY, HSH_HIT, From martin at varnish-software.com Tue Dec 4 13:46:08 2018 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Tue, 4 Dec 2018 13:46:08 +0000 (UTC) Subject: [master] 5e5c39cf8 Move HSH_DeleteObjHead into the hash deref methods Message-ID: <20181204134608.B08D4A1A4B@lists.varnish-cache.org> commit 5e5c39cf82843ce294690012b270a0ae47c5938e Author: Martin Blix Grydeland Date: Tue Nov 20 12:48:49 2018 +0100 Move HSH_DeleteObjHead into the hash deref methods Move the clean up call to HSH_DeleteObjHead inside of the hash deref methods that require it, instead of having the outside (single) caller do it based off the return value. This just cleans up and makes the logic more transparent. diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index d1491d592..18bbd7a07 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -983,7 +983,6 @@ HSH_DerefObjHead(struct worker *wrk, struct objhead **poh) { struct objhead *oh; struct rush rush; - int r; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); TAKE_OBJ_NOTNULL(oh, poh, OBJHEAD_MAGIC); @@ -1016,10 +1015,7 @@ HSH_DerefObjHead(struct worker *wrk, struct objhead **poh) Lck_Unlock(&oh->mtx); assert(oh->refcnt > 0); - r = hash->deref(oh); - if (!r) - HSH_DeleteObjHead(wrk, oh); - return (r); + return (hash->deref(wrk, oh)); } void diff --git a/bin/varnishd/hash/hash_classic.c b/bin/varnishd/hash/hash_classic.c index 3440b9bd2..d3303c875 100644 --- a/bin/varnishd/hash/hash_classic.c +++ b/bin/varnishd/hash/hash_classic.c @@ -172,7 +172,7 @@ hcl_lookup(struct worker *wrk, const void *digest, struct objhead **noh) */ static int v_matchproto_(hash_deref_f) -hcl_deref(struct objhead *oh) +hcl_deref(struct worker *wrk, struct objhead *oh) { struct hcl_hd *hp; int ret; @@ -187,6 +187,8 @@ hcl_deref(struct objhead *oh) } else ret = 1; Lck_Unlock(&hp->mtx); + if (!ret) + HSH_DeleteObjHead(wrk, oh); return (ret); } diff --git a/bin/varnishd/hash/hash_critbit.c b/bin/varnishd/hash/hash_critbit.c index c673595b2..1c453148f 100644 --- a/bin/varnishd/hash/hash_critbit.c +++ b/bin/varnishd/hash/hash_critbit.c @@ -347,13 +347,15 @@ hcb_start(void) } static int v_matchproto_(hash_deref_f) -hcb_deref(struct objhead *oh) +hcb_deref(struct worker *wrk, struct objhead *oh) { + int r; + (void)wrk; CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC); Lck_Lock(&oh->mtx); assert(oh->refcnt > 0); - oh->refcnt--; + r = --oh->refcnt; if (oh->refcnt == 0) { Lck_Lock(&hcb_mtx); hcb_delete(&hcb_root, oh); @@ -364,7 +366,7 @@ hcb_deref(struct objhead *oh) #ifdef PHK fprintf(stderr, "hcb_defef %d %d <%s>\n", __LINE__, r, oh->hash); #endif - return (1); + return (r); } static struct objhead * v_matchproto_(hash_lookup_f) diff --git a/bin/varnishd/hash/hash_simple_list.c b/bin/varnishd/hash/hash_simple_list.c index 4c1e9025a..643148ed0 100644 --- a/bin/varnishd/hash/hash_simple_list.c +++ b/bin/varnishd/hash/hash_simple_list.c @@ -108,7 +108,7 @@ hsl_lookup(struct worker *wrk, const void *digest, struct objhead **noh) */ static int v_matchproto_(hash_deref_f) -hsl_deref(struct objhead *oh) +hsl_deref(struct worker *wrk, struct objhead *oh) { int ret; @@ -119,6 +119,8 @@ hsl_deref(struct objhead *oh) } else ret = 1; Lck_Unlock(&hsl_mtx); + if (!ret) + HSH_DeleteObjHead(wrk, oh); return (ret); } diff --git a/bin/varnishd/hash/hash_slinger.h b/bin/varnishd/hash/hash_slinger.h index 6c17b8374..0ff95cca2 100644 --- a/bin/varnishd/hash/hash_slinger.h +++ b/bin/varnishd/hash/hash_slinger.h @@ -36,7 +36,7 @@ typedef void hash_start_f(void); typedef void hash_prep_f(struct worker *); typedef struct objhead *hash_lookup_f(struct worker *, const void *digest, struct objhead **); -typedef int hash_deref_f(struct objhead *); +typedef int hash_deref_f(struct worker *, struct objhead *); struct hash_slinger { unsigned magic; From martin at varnish-software.com Tue Dec 4 13:46:08 2018 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Tue, 4 Dec 2018 13:46:08 +0000 (UTC) Subject: [master] b420840d1 Change hash slingers deref func to take a locked objhead Message-ID: <20181204134608.C621AA1A4D@lists.varnish-cache.org> commit b420840d1bade47cef3ecbb724757cea158e8475 Author: Martin Blix Grydeland Date: Tue Nov 20 12:59:36 2018 +0100 Change hash slingers deref func to take a locked objhead This changes the hash slingers deref function to take a locked objhead on input, and unlocking it before returning. This saves a lock/unlock sequence for critbit (which is the critical one) on HSH_DerefObjHead. diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index 18bbd7a07..4a430f3e3 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -1012,7 +1012,6 @@ HSH_DerefObjHead(struct worker *wrk, struct objhead **poh) hsh_rush2(wrk, &rush); Lck_Lock(&oh->mtx); } - Lck_Unlock(&oh->mtx); assert(oh->refcnt > 0); return (hash->deref(wrk, oh)); diff --git a/bin/varnishd/hash/hash_classic.c b/bin/varnishd/hash/hash_classic.c index d3303c875..cb3b0b3a2 100644 --- a/bin/varnishd/hash/hash_classic.c +++ b/bin/varnishd/hash/hash_classic.c @@ -178,6 +178,9 @@ hcl_deref(struct worker *wrk, struct objhead *oh) int ret; CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC); + Lck_AssertHeld(&oh->mtx); + Lck_Unlock(&oh->mtx); + CAST_OBJ_NOTNULL(hp, oh->hoh_head, HCL_HEAD_MAGIC); assert(oh->refcnt > 0); Lck_Lock(&hp->mtx); diff --git a/bin/varnishd/hash/hash_critbit.c b/bin/varnishd/hash/hash_critbit.c index 1c453148f..fcedbef5f 100644 --- a/bin/varnishd/hash/hash_critbit.c +++ b/bin/varnishd/hash/hash_critbit.c @@ -353,7 +353,7 @@ hcb_deref(struct worker *wrk, struct objhead *oh) (void)wrk; CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC); - Lck_Lock(&oh->mtx); + Lck_AssertHeld(&oh->mtx); assert(oh->refcnt > 0); r = --oh->refcnt; if (oh->refcnt == 0) { diff --git a/bin/varnishd/hash/hash_simple_list.c b/bin/varnishd/hash/hash_simple_list.c index 643148ed0..8c0858e18 100644 --- a/bin/varnishd/hash/hash_simple_list.c +++ b/bin/varnishd/hash/hash_simple_list.c @@ -112,6 +112,10 @@ hsl_deref(struct worker *wrk, struct objhead *oh) { int ret; + CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC); + Lck_AssertHeld(&oh->mtx); + Lck_Unlock(&oh->mtx); + Lck_Lock(&hsl_mtx); if (--oh->refcnt == 0) { VTAILQ_REMOVE(&hsl_head, oh, hoh_list); From martin at varnish-software.com Tue Dec 4 13:46:08 2018 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Tue, 4 Dec 2018 13:46:08 +0000 (UTC) Subject: [master] c34a9d3d0 Rename HSH_DerefObjhead() to hsh_deref_objhead() Message-ID: <20181204134608.EBDD7A1A50@lists.varnish-cache.org> commit c34a9d3d06bbd2f73d1637213663ffd140d884fe Author: Martin Blix Grydeland Date: Tue Dec 4 10:55:19 2018 +0100 Rename HSH_DerefObjhead() to hsh_deref_objhead() Make this function lower case for consistency. diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index 4a430f3e3..099d99b40 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -76,7 +76,7 @@ static struct objhead *private_oh; static void hsh_rush1(const struct worker *, struct objhead *, struct rush *, int); static void hsh_rush2(struct worker *, struct rush *); -static int HSH_DerefObjHead(struct worker *wrk, struct objhead **poh); +static int hsh_deref_objhead(struct worker *wrk, struct objhead **poh); /*---------------------------------------------------------------------*/ @@ -461,7 +461,7 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp, Lck_Unlock(&oh->mtx); *ocp = oc; if (*bocp == NULL) - assert(HSH_DerefObjHead(wrk, &oh)); + assert(hsh_deref_objhead(wrk, &oh)); switch (retval) { case HSH_HITPASS: @@ -541,7 +541,7 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp, Lck_Unlock(&oh->mtx); *ocp = exp_oc; - assert(HSH_DerefObjHead(wrk, &oh)); + assert(hsh_deref_objhead(wrk, &oh)); if (exp_oc->hits < LONG_MAX) exp_oc->hits++; return (HSH_GRACE); @@ -974,12 +974,12 @@ HSH_DerefObjCore(struct worker *wrk, struct objcore **ocp, int rushmax) /* Drop our ref on the objhead */ assert(oh->refcnt > 0); - (void)HSH_DerefObjHead(wrk, &oh); + (void)hsh_deref_objhead(wrk, &oh); return (0); } static int -HSH_DerefObjHead(struct worker *wrk, struct objhead **poh) +hsh_deref_objhead(struct worker *wrk, struct objhead **poh) { struct objhead *oh; struct rush rush; From martin at varnish-software.com Tue Dec 4 13:46:09 2018 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Tue, 4 Dec 2018 13:46:09 +0000 (UTC) Subject: [master] 24cdd3af7 Add hsh_deref_objhead_unlock(), taking a locked objhead Message-ID: <20181204134609.18249A1A57@lists.varnish-cache.org> commit 24cdd3af7c154264442d15c96566b905475db6fd Author: Martin Blix Grydeland Date: Tue Dec 4 10:57:11 2018 +0100 Add hsh_deref_objhead_unlock(), taking a locked objhead Split hsh_deref_objhead() into two parts, with the new hsh_deref_objhead_unlock() function expecting a locked objhead reference on input. diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index 099d99b40..593ca01dc 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -77,6 +77,7 @@ static void hsh_rush1(const struct worker *, struct objhead *, struct rush *, int); static void hsh_rush2(struct worker *, struct rush *); static int hsh_deref_objhead(struct worker *wrk, struct objhead **poh); +static int hsh_deref_objhead_unlock(struct worker *wrk, struct objhead **poh); /*---------------------------------------------------------------------*/ @@ -979,7 +980,7 @@ HSH_DerefObjCore(struct worker *wrk, struct objcore **ocp, int rushmax) } static int -hsh_deref_objhead(struct worker *wrk, struct objhead **poh) +hsh_deref_objhead_unlock(struct worker *wrk, struct objhead **poh) { struct objhead *oh; struct rush rush; @@ -988,9 +989,10 @@ hsh_deref_objhead(struct worker *wrk, struct objhead **poh) TAKE_OBJ_NOTNULL(oh, poh, OBJHEAD_MAGIC); INIT_OBJ(&rush, RUSH_MAGIC); + Lck_AssertHeld(&oh->mtx); + if (oh == private_oh) { assert(VTAILQ_EMPTY(&oh->waitinglist)); - Lck_Lock(&oh->mtx); assert(oh->refcnt > 1); oh->refcnt--; Lck_Unlock(&oh->mtx); @@ -1005,7 +1007,6 @@ hsh_deref_objhead(struct worker *wrk, struct objhead **poh) * just make the hold the same ref's as objcore, that would * confuse hashers. */ - Lck_Lock(&oh->mtx); while (oh->refcnt == 1 && !VTAILQ_EMPTY(&oh->waitinglist)) { hsh_rush1(wrk, oh, &rush, HSH_RUSH_ALL); Lck_Unlock(&oh->mtx); @@ -1017,6 +1018,18 @@ hsh_deref_objhead(struct worker *wrk, struct objhead **poh) return (hash->deref(wrk, oh)); } +static int +hsh_deref_objhead(struct worker *wrk, struct objhead **poh) +{ + struct objhead *oh; + + CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); + TAKE_OBJ_NOTNULL(oh, poh, OBJHEAD_MAGIC); + + Lck_Lock(&oh->mtx); + return (hsh_deref_objhead_unlock(wrk, &oh)); +} + void HSH_Init(const struct hash_slinger *slinger) { From martin at varnish-software.com Tue Dec 4 13:46:09 2018 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Tue, 4 Dec 2018 13:46:09 +0000 (UTC) Subject: [master] 73289ed99 Reduce locking in HSH_Lookup() Message-ID: <20181204134609.409CCA1A5C@lists.varnish-cache.org> commit 73289ed99e0cb0e8fcbb666ffc55b30c9d51a680 Author: Martin Blix Grydeland Date: Tue Dec 4 10:57:11 2018 +0100 Reduce locking in HSH_Lookup() Make use of the new hsh_deref_objhead_unlock() in HSH_Lookup() to reduce the number of times the objhead mutex is taken during cache hits. diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index 593ca01dc..5d68a1392 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -459,10 +459,11 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp, oc->hits++; retval = HSH_HIT; } - Lck_Unlock(&oh->mtx); *ocp = oc; if (*bocp == NULL) - assert(hsh_deref_objhead(wrk, &oh)); + AN(hsh_deref_objhead_unlock(wrk, &oh)); + else + Lck_Unlock(&oh->mtx); switch (retval) { case HSH_HITPASS: @@ -539,12 +540,10 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp, assert(oh->refcnt > 1); assert(exp_oc->objhead == oh); exp_oc->refcnt++; - Lck_Unlock(&oh->mtx); *ocp = exp_oc; - - assert(hsh_deref_objhead(wrk, &oh)); if (exp_oc->hits < LONG_MAX) exp_oc->hits++; + AN(hsh_deref_objhead_unlock(wrk, &oh)); return (HSH_GRACE); } From dridi.boukelmoune at gmail.com Tue Dec 4 15:04:07 2018 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 4 Dec 2018 15:04:07 +0000 (UTC) Subject: [master] fb4b6d693 Display the VCL syntax during a panic Message-ID: <20181204150407.9B37BA3A7B@lists.varnish-cache.org> commit fb4b6d6938be6df2506cd6e5eeac1434b8f231a7 Author: Dridi Boukelmoune Date: Tue Dec 4 16:01:13 2018 +0100 Display the VCL syntax during a panic diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c index a5a33cf9b..30dee548b 100644 --- a/bin/varnishd/cache/cache_vcl.c +++ b/bin/varnishd/cache/cache_vcl.c @@ -211,6 +211,7 @@ VCL_Panic(struct vsb *vsb, const struct vcl *vcl) VSB_printf(vsb, "conf = NULL\n"); } else { PAN_CheckMagic(vsb, vcl->conf, VCL_CONF_MAGIC); + VSB_printf(vsb, "syntax = \"%d\",\n", vcl->conf->syntax); VSB_printf(vsb, "srcname = {\n"); VSB_indent(vsb, 2); for (i = 0; i < vcl->conf->nsrc; ++i) From phk at FreeBSD.org Tue Dec 4 23:47:08 2018 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 4 Dec 2018 23:47:08 +0000 (UTC) Subject: [master] c3a219446 Printf format fix Message-ID: <20181204234708.7FACD423F@lists.varnish-cache.org> commit c3a219446ccbd9b87435e0b0aee7b4f5413f73f2 Author: Poul-Henning Kamp Date: Tue Dec 4 21:53:36 2018 +0000 Printf format fix diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c index 30dee548b..418c6d7ee 100644 --- a/bin/varnishd/cache/cache_vcl.c +++ b/bin/varnishd/cache/cache_vcl.c @@ -211,7 +211,7 @@ VCL_Panic(struct vsb *vsb, const struct vcl *vcl) VSB_printf(vsb, "conf = NULL\n"); } else { PAN_CheckMagic(vsb, vcl->conf, VCL_CONF_MAGIC); - VSB_printf(vsb, "syntax = \"%d\",\n", vcl->conf->syntax); + VSB_printf(vsb, "syntax = \"%u\",\n", vcl->conf->syntax); VSB_printf(vsb, "srcname = {\n"); VSB_indent(vsb, 2); for (i = 0; i < vcl->conf->nsrc; ++i) From phk at FreeBSD.org Tue Dec 4 23:47:08 2018 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 4 Dec 2018 23:47:08 +0000 (UTC) Subject: [master] f29d2049b Simplify HSH_Lookup 1/N Message-ID: <20181204234708.989B14241@lists.varnish-cache.org> commit f29d2049b8fca02b714e27953069ccb074220cd1 Author: Poul-Henning Kamp Date: Tue Dec 4 21:54:16 2018 +0000 Simplify HSH_Lookup 1/N Move successful loop termination out of the loop. Inspired by: #2856 diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index 5d68a1392..55d1a8de9 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -439,51 +439,11 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp, } if (EXP_Ttl(req, oc) > req->t_req) { - /* If still valid, use it */ assert(oh->refcnt > 1); assert(oc->objhead == oh); - if (oc->flags & OC_F_HFP) { - xid = ObjGetXID(wrk, oc); - dttl = EXP_Dttl(req, oc); - oc = NULL; - retval = HSH_HITPASS; - } else if (oc->flags & OC_F_HFM) { - xid = ObjGetXID(wrk, oc); - dttl = EXP_Dttl(req, oc); - *bocp = hsh_insert_busyobj(wrk, oh); - oc->refcnt++; - retval = HSH_HITMISS; - } else { - oc->refcnt++; - if (oc->hits < LONG_MAX) - oc->hits++; - retval = HSH_HIT; - } - *ocp = oc; - if (*bocp == NULL) - AN(hsh_deref_objhead_unlock(wrk, &oh)); - else - Lck_Unlock(&oh->mtx); - - switch (retval) { - case HSH_HITPASS: - wrk->stats->cache_hitpass++; - VSLb(req->vsl, SLT_HitPass, "%u %.6f", - xid, dttl); - break; - case HSH_HITMISS: - wrk->stats->cache_hitmiss++; - VSLb(req->vsl, SLT_HitMiss, "%u %.6f", - xid, dttl); - break; - case HSH_HIT: - break; - default: - INCOMPL(); - } - - return (retval); + break; } + if (EXP_Ttl(NULL, oc) < req->t_req && /* ignore req.ttl */ oc->t_origin > exp_t_origin) { /* record the newest object */ @@ -492,6 +452,48 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp, } } + if (oc != NULL) { + if (oc->flags & OC_F_HFP) { + xid = ObjGetXID(wrk, oc); + dttl = EXP_Dttl(req, oc); + oc = NULL; + retval = HSH_HITPASS; + } else if (oc->flags & OC_F_HFM) { + xid = ObjGetXID(wrk, oc); + dttl = EXP_Dttl(req, oc); + *bocp = hsh_insert_busyobj(wrk, oh); + oc->refcnt++; + retval = HSH_HITMISS; + } else { + oc->refcnt++; + if (oc->hits < LONG_MAX) + oc->hits++; + retval = HSH_HIT; + } + *ocp = oc; + if (*bocp == NULL) + AN(hsh_deref_objhead_unlock(wrk, &oh)); + else + Lck_Unlock(&oh->mtx); + + switch (retval) { + case HSH_HITPASS: + wrk->stats->cache_hitpass++; + VSLb(req->vsl, SLT_HitPass, "%u %.6f", xid, dttl); + break; + case HSH_HITMISS: + wrk->stats->cache_hitmiss++; + VSLb(req->vsl, SLT_HitMiss, "%u %.6f", xid, dttl); + break; + case HSH_HIT: + break; + default: + INCOMPL(); + } + + return (retval); + } + if (exp_oc != NULL && exp_oc->flags & OC_F_HFM) { /* * expired HFM ("grace/keep HFM") From phk at FreeBSD.org Tue Dec 4 23:47:08 2018 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 4 Dec 2018 23:47:08 +0000 (UTC) Subject: [master] 6567393d1 Simplify HSH_Lookup 2/N Message-ID: <20181204234708.B71E74244@lists.varnish-cache.org> commit 6567393d1396738e32fc93a5fa2905d1ed2fef55 Author: Poul-Henning Kamp Date: Tue Dec 4 22:02:05 2018 +0000 Simplify HSH_Lookup 2/N Refactor the hit-cases Inspired by: #2856 diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index 55d1a8de9..7f9e6db78 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -452,46 +452,31 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp, } } + if (oc != NULL && oc->flags & OC_F_HFP) { + xid = ObjGetXID(wrk, oc); + dttl = EXP_Dttl(req, oc); + AN(hsh_deref_objhead_unlock(wrk, &oh)); + wrk->stats->cache_hitpass++; + VSLb(req->vsl, SLT_HitPass, "%u %.6f", xid, dttl); + return (HSH_HITPASS); + } + if (oc != NULL) { - if (oc->flags & OC_F_HFP) { - xid = ObjGetXID(wrk, oc); - dttl = EXP_Dttl(req, oc); - oc = NULL; - retval = HSH_HITPASS; - } else if (oc->flags & OC_F_HFM) { + *ocp = oc; + oc->refcnt++; + if (oc->flags & OC_F_HFM) { xid = ObjGetXID(wrk, oc); dttl = EXP_Dttl(req, oc); *bocp = hsh_insert_busyobj(wrk, oh); - oc->refcnt++; - retval = HSH_HITMISS; - } else { - oc->refcnt++; - if (oc->hits < LONG_MAX) - oc->hits++; - retval = HSH_HIT; - } - *ocp = oc; - if (*bocp == NULL) - AN(hsh_deref_objhead_unlock(wrk, &oh)); - else Lck_Unlock(&oh->mtx); - - switch (retval) { - case HSH_HITPASS: - wrk->stats->cache_hitpass++; - VSLb(req->vsl, SLT_HitPass, "%u %.6f", xid, dttl); - break; - case HSH_HITMISS: wrk->stats->cache_hitmiss++; VSLb(req->vsl, SLT_HitMiss, "%u %.6f", xid, dttl); - break; - case HSH_HIT: - break; - default: - INCOMPL(); - } - - return (retval); + return (HSH_HITMISS); + } + if (oc->hits < LONG_MAX) + oc->hits++; + AN(hsh_deref_objhead_unlock(wrk, &oh)); + return (HSH_HIT); } if (exp_oc != NULL && exp_oc->flags & OC_F_HFM) { @@ -499,6 +484,7 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp, * expired HFM ("grace/keep HFM") * * XXX should HFM objects actually have grace/keep ? + * XXX also: why isn't *ocp = exp_oc ? */ xid = ObjGetXID(wrk, exp_oc); dttl = EXP_Dttl(req, exp_oc); From phk at FreeBSD.org Tue Dec 4 23:47:08 2018 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 4 Dec 2018 23:47:08 +0000 (UTC) Subject: [master] 44b9308ff Simplify HSH_Lookup 3/N Message-ID: <20181204234708.D6BDA4248@lists.varnish-cache.org> commit 44b9308ff267d946c95068a150e68a2bd46abee6 Author: Poul-Henning Kamp Date: Tue Dec 4 23:08:02 2018 +0000 Simplify HSH_Lookup 3/N Use req->hash_always_miss directly Inspired by: #2856 diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index 7f9e6db78..c2fc818c9 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -338,8 +338,7 @@ hsh_insert_busyobj(struct worker *wrk, struct objhead *oh) */ enum lookup_e -HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp, - int always_insert) +HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp) { struct worker *wrk; struct objhead *oh; @@ -384,7 +383,7 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp, CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC); Lck_AssertHeld(&oh->mtx); - if (always_insert) { + if (req->hash_always_miss) { /* XXX: should we do predictive Vary in this case ? */ /* Insert new objcore in objecthead and release mutex */ *bocp = hsh_insert_busyobj(wrk, oh); @@ -472,7 +471,7 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp, wrk->stats->cache_hitmiss++; VSLb(req->vsl, SLT_HitMiss, "%u %.6f", xid, dttl); return (HSH_HITMISS); - } + } if (oc->hits < LONG_MAX) oc->hits++; AN(hsh_deref_objhead_unlock(wrk, &oh)); diff --git a/bin/varnishd/cache/cache_objhead.h b/bin/varnishd/cache/cache_objhead.h index 9e90d5b32..e12463981 100644 --- a/bin/varnishd/cache/cache_objhead.h +++ b/bin/varnishd/cache/cache_objhead.h @@ -68,8 +68,7 @@ int HSH_DerefObjCore(struct worker *, struct objcore **, int rushmax); #define HSH_RUSH_POLICY -1 #define HSH_RUSH_ALL INT_MAX -enum lookup_e HSH_Lookup(struct req *, struct objcore **, struct objcore **, - int always_insert); +enum lookup_e HSH_Lookup(struct req *, struct objcore **, struct objcore **); void HSH_Ref(struct objcore *o); void HSH_AddString(struct req *, void *ctx, const char *str); unsigned HSH_Purge(struct worker *, struct objhead *, vtim_real ttl_now, diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index dd77bf033..20a219f38 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -482,7 +482,7 @@ cnt_lookup(struct worker *wrk, struct req *req) AZ(req->objcore); if (req->hash_objhead) had_objhead = 1; - lr = HSH_Lookup(req, &oc, &busy, req->hash_always_miss ? 1 : 0); + lr = HSH_Lookup(req, &oc, &busy); if (lr == HSH_BUSY) { /* * We lost the session to a busy object, disembark the @@ -973,7 +973,8 @@ cnt_purge(struct worker *wrk, struct req *req) VRY_Prep(req); AZ(req->objcore); - lr = HSH_Lookup(req, &oc, &boc, 1); + req->hash_always_miss = 1; + lr = HSH_Lookup(req, &oc, &boc); assert (lr == HSH_MISS); AZ(oc); CHECK_OBJ_NOTNULL(boc, OBJCORE_MAGIC); From phk at FreeBSD.org Tue Dec 4 23:47:08 2018 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 4 Dec 2018 23:47:08 +0000 (UTC) Subject: [master] a9b537e7c Simplify HSH_Lookup 4/4 Message-ID: <20181204234708.F2A34424C@lists.varnish-cache.org> commit a9b537e7cef0f9367a6100fc44f7a1ca43109fa1 Author: Poul-Henning Kamp Date: Tue Dec 4 23:45:27 2018 +0000 Simplify HSH_Lookup 4/4 Simplify the !busy cases Inspired by: #2856 diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index c2fc818c9..ac2af79a0 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -346,7 +346,6 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp) struct objcore *exp_oc; vtim_real exp_t_origin; int busy_found; - enum lookup_e retval; const uint8_t *vary; unsigned xid = 0; float dttl = 0.0; @@ -448,6 +447,8 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp) /* record the newest object */ exp_oc = oc; exp_t_origin = oc->t_origin; + assert(oh->refcnt > 1); + assert(exp_oc->objhead == oh); } } @@ -489,43 +490,31 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp) dttl = EXP_Dttl(req, exp_oc); *bocp = hsh_insert_busyobj(wrk, oh); Lck_Unlock(&oh->mtx); - wrk->stats->cache_hitmiss++; VSLb(req->vsl, SLT_HitMiss, "%u %.6f", xid, dttl); return (HSH_HITMISS); } if (!busy_found) { - /* Insert objcore in objecthead */ *bocp = hsh_insert_busyobj(wrk, oh); if (exp_oc != NULL) { - assert(oh->refcnt > 1); - assert(exp_oc->objhead == oh); exp_oc->refcnt++; - Lck_Unlock(&oh->mtx); *ocp = exp_oc; - - if (EXP_Ttl_grace(req, exp_oc) < req->t_req) { - retval = HSH_MISS; - } else { + if (EXP_Ttl_grace(req, exp_oc) > req->t_req) { if (exp_oc->hits < LONG_MAX) exp_oc->hits++; - retval = HSH_GRACE; + Lck_Unlock(&oh->mtx); + return (HSH_GRACE); } - } else { - Lck_Unlock(&oh->mtx); - retval = HSH_MISS; } - - return (retval); + Lck_Unlock(&oh->mtx); + return (HSH_MISS); } AN(busy_found); if (exp_oc != NULL && EXP_Ttl_grace(req, exp_oc) >= req->t_req) { /* we do not wait on the busy object if in grace */ - assert(oh->refcnt > 1); - assert(exp_oc->objhead == oh); exp_oc->refcnt++; *ocp = exp_oc; if (exp_oc->hits < LONG_MAX) From phk at FreeBSD.org Wed Dec 5 08:23:10 2018 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 5 Dec 2018 08:23:10 +0000 (UTC) Subject: [master] b637c111d Make obj.hits a native VCL_INT which are always 64 bit, so we can avoid the LONG_MAX check. Message-ID: <20181205082310.E122B64A00@lists.varnish-cache.org> commit b637c111d6db652f7849c0d68fa19491f0f9c598 Author: Poul-Henning Kamp Date: Wed Dec 5 08:22:13 2018 +0000 Make obj.hits a native VCL_INT which are always 64 bit, so we can avoid the LONG_MAX check. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 2b13aa9ce..b7e6e1f7e 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -346,7 +346,8 @@ struct objcore { struct objhead *objhead; struct boc *boc; vtim_real timer_when; - long hits; + VCL_INT hits; + vtim_real t_origin; float ttl; diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index ac2af79a0..d6c2fded9 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -473,8 +473,7 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp) VSLb(req->vsl, SLT_HitMiss, "%u %.6f", xid, dttl); return (HSH_HITMISS); } - if (oc->hits < LONG_MAX) - oc->hits++; + oc->hits++; AN(hsh_deref_objhead_unlock(wrk, &oh)); return (HSH_HIT); } @@ -502,8 +501,7 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp) exp_oc->refcnt++; *ocp = exp_oc; if (EXP_Ttl_grace(req, exp_oc) > req->t_req) { - if (exp_oc->hits < LONG_MAX) - exp_oc->hits++; + exp_oc->hits++; Lck_Unlock(&oh->mtx); return (HSH_GRACE); } @@ -517,8 +515,7 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp) /* we do not wait on the busy object if in grace */ exp_oc->refcnt++; *ocp = exp_oc; - if (exp_oc->hits < LONG_MAX) - exp_oc->hits++; + exp_oc->hits++; AN(hsh_deref_objhead_unlock(wrk, &oh)); return (HSH_GRACE); } From daghf at varnish-software.com Wed Dec 5 09:43:03 2018 From: daghf at varnish-software.com (Dag Haavi Finstad) Date: Wed, 5 Dec 2018 09:43:03 +0000 (UTC) Subject: [master] b81bb71db Clean up dead code in hsh_deref_objhead_unlock Message-ID: <20181205094303.3F8216E185@lists.varnish-cache.org> commit b81bb71db0ce1655a0a23bdb47e5b8b3f8315749 Author: Dag Haavi Finstad Date: Wed Dec 5 10:25:57 2018 +0100 Clean up dead code in hsh_deref_objhead_unlock req's on waiting list do indeed hold an objhead ref (req->hash_objhead), so the condition for the while loop in hsh_deref_objhead_unlock will always evaluate to false. This gets rid of the needless rushing code and replaces it with an assert. diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index d6c2fded9..f7f662b27 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -773,8 +773,10 @@ HSH_Unbusy(struct worker *wrk, struct objcore *oc) VTAILQ_REMOVE(&oh->objcs, oc, hsh_list); VTAILQ_INSERT_HEAD(&oh->objcs, oc, hsh_list); oc->flags &= ~OC_F_BUSY; - if (!VTAILQ_EMPTY(&oh->waitinglist)) + if (!VTAILQ_EMPTY(&oh->waitinglist)) { + assert(oh->refcnt > 1); hsh_rush1(wrk, oh, &rush, HSH_RUSH_POLICY); + } Lck_Unlock(&oh->mtx); if (!(oc->flags & OC_F_PRIVATE)) EXP_Insert(wrk, oc); @@ -929,8 +931,10 @@ HSH_DerefObjCore(struct worker *wrk, struct objcore **ocp, int rushmax) r = --oc->refcnt; if (!r) VTAILQ_REMOVE(&oh->objcs, oc, hsh_list); - if (!VTAILQ_EMPTY(&oh->waitinglist)) + if (!VTAILQ_EMPTY(&oh->waitinglist)) { + assert(oh->refcnt > 1); hsh_rush1(wrk, oh, &rush, rushmax); + } Lck_Unlock(&oh->mtx); hsh_rush2(wrk, &rush); if (r != 0) @@ -955,11 +959,9 @@ static int hsh_deref_objhead_unlock(struct worker *wrk, struct objhead **poh) { struct objhead *oh; - struct rush rush; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); TAKE_OBJ_NOTNULL(oh, poh, OBJHEAD_MAGIC); - INIT_OBJ(&rush, RUSH_MAGIC); Lck_AssertHeld(&oh->mtx); @@ -971,20 +973,8 @@ hsh_deref_objhead_unlock(struct worker *wrk, struct objhead **poh) return(1); } - /* - * Make absolutely certain that we do not let the final ref - * disappear until the waitinglist is empty. - * This is necessary because the req's on the waiting list do - * not hold any ref on the objhead of their own, and we cannot - * just make the hold the same ref's as objcore, that would - * confuse hashers. - */ - while (oh->refcnt == 1 && !VTAILQ_EMPTY(&oh->waitinglist)) { - hsh_rush1(wrk, oh, &rush, HSH_RUSH_ALL); - Lck_Unlock(&oh->mtx); - hsh_rush2(wrk, &rush); - Lck_Lock(&oh->mtx); - } + if (oh->refcnt == 1) + assert(VTAILQ_EMPTY(&oh->waitinglist)); assert(oh->refcnt > 0); return (hash->deref(wrk, oh)); From nils.goroll at uplex.de Wed Dec 5 10:41:10 2018 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 5 Dec 2018 10:41:10 +0000 (UTC) Subject: [master] 04d9a40a5 make two identical comparisons the same Message-ID: <20181205104110.4034C9073D@lists.varnish-cache.org> commit 04d9a40a565c21380d3b8e64ee713d17e7636363 Author: Nils Goroll Date: Wed Dec 5 11:40:13 2018 +0100 make two identical comparisons the same see 11 lines down diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index f7f662b27..5c25abc4a 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -500,7 +500,7 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp) if (exp_oc != NULL) { exp_oc->refcnt++; *ocp = exp_oc; - if (EXP_Ttl_grace(req, exp_oc) > req->t_req) { + if (EXP_Ttl_grace(req, exp_oc) >= req->t_req) { exp_oc->hits++; Lck_Unlock(&oh->mtx); return (HSH_GRACE); From hermunn at varnish-software.com Wed Dec 5 10:59:07 2018 From: hermunn at varnish-software.com (PÃ¥l Hermunn Johansen) Date: Wed, 5 Dec 2018 10:59:07 +0000 (UTC) Subject: [4.1] 2c1b624ea Stabilize b000064.vtc for real Message-ID: <20181205105907.DAA3790DC3@lists.varnish-cache.org> commit 2c1b624ea3d6506a0de65ac5d861520a1cf9fa7f Author: P?l Hermunn Johansen Date: Fri Aug 31 15:29:12 2018 +0200 Stabilize b000064.vtc for real Fixes: #2753 Conflicts: bin/varnishtest/tests/b00064.vtc diff --git a/bin/varnishtest/tests/b00064.vtc b/bin/varnishtest/tests/b00064.vtc index 8fee088d2..a29ad916e 100644 --- a/bin/varnishtest/tests/b00064.vtc +++ b/bin/varnishtest/tests/b00064.vtc @@ -38,8 +38,11 @@ varnish v1 -vcl+backend { set req.http.X-grace = obj.grace; } sub vcl_backend_response { - set beresp.ttl = 0.1s; + set beresp.ttl = 1ms; set beresp.grace = 1m; + if (bereq.is_bgfetch) { + set beresp.http.X-was-bgfetch = "1"; + } } sub vcl_deliver { if (req.http.X-grace) { @@ -65,6 +68,7 @@ client c1 { expect resp.body == "1" expect resp.http.X-grace == expect resp.http.X-req-grace == + expect resp.http.X-was-bgfetch == } -run # let the latest object's ttl expire. @@ -81,11 +85,13 @@ client c2 { expect resp.body == "1" expect resp.http.X-grace == "60.000" expect resp.http.X-req-grace < 0. -} -start + expect resp.http.X-was-bgfetch == +} -run -delay .1 +# c3 asks for graced object, but now we disable grace. The c2 client +# started the background fetch, which will take a long time (until c4 +# has gotten its reply). -# c3 asks for graced object, but now we disable grace. client c3 { txreq -hdr "X-no-grace: true" rxresp @@ -95,6 +101,7 @@ client c3 { expect resp.body == "2" expect resp.http.X-grace == "60.000" expect resp.http.X-req-grace == "0.000" + expect resp.http.X-was-bgfetch == "1" } -start delay .1 @@ -112,9 +119,9 @@ client c4 { expect resp.body == "1" expect resp.http.X-grace == "60.000" expect resp.http.X-req-grace < 0. + expect resp.http.X-was-bgfetch == } -start -client c2 -wait client c3 -wait client c4 -wait From nils.goroll at uplex.de Wed Dec 5 11:26:07 2018 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 5 Dec 2018 11:26:07 +0000 (UTC) Subject: [master] 3c95f47d9 fsm graphviz: polish the waitinglist arrow Message-ID: <20181205112607.BF3E7917A7@lists.varnish-cache.org> commit 3c95f47d973e6abda5587c76bfe7a3905973544f Author: Nils Goroll Date: Wed Dec 5 11:56:44 2018 +0100 fsm graphviz: polish the waitinglist arrow diff --git a/doc/graphviz/cache_req_fsm.dot b/doc/graphviz/cache_req_fsm.dot index 3501b7bb1..b9f6a80c2 100644 --- a/doc/graphviz/cache_req_fsm.dot +++ b/doc/graphviz/cache_req_fsm.dot @@ -124,7 +124,7 @@ digraph cache_req_fsm { label="{cnt_lookup:|{vcl_hit\{\}|{req.*|obj.*}}|{fail|deliver|miss|restart|synth|pass}}" ] } - lookup:busy:e -> lookup:top:e [label="(waitinglist)", + lookup:busy:s -> lookup:top:ne [label=" waitinglist", color=grey, fontcolor=grey] lookup:miss:s -> miss [style=bold,color=blue] From nils.goroll at uplex.de Wed Dec 5 11:26:07 2018 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 5 Dec 2018 11:26:07 +0000 (UTC) Subject: [master] c82dda997 fsm graphviz: add hfm Message-ID: <20181205112607.CA54F917AA@lists.varnish-cache.org> commit c82dda9970f75249c4cd4ae7cf7cec5008b56613 Author: Nils Goroll Date: Wed Dec 5 11:57:18 2018 +0100 fsm graphviz: add hfm diff --git a/doc/graphviz/cache_req_fsm.dot b/doc/graphviz/cache_req_fsm.dot index b9f6a80c2..9dda7bf9e 100644 --- a/doc/graphviz/cache_req_fsm.dot +++ b/doc/graphviz/cache_req_fsm.dot @@ -117,7 +117,7 @@ digraph cache_req_fsm { shape=record color=grey fontcolor=grey - label="{cnt_lookup:|hash lookup|{hit?|miss?|hit-for-pass?|busy?}}" + label="{cnt_lookup:|hash lookup|{hit?|miss?|hit-for-miss?|hit-for-pass?|busy?}}" ] lookup2 [ shape=record @@ -128,6 +128,7 @@ digraph cache_req_fsm { color=grey, fontcolor=grey] lookup:miss:s -> miss [style=bold,color=blue] + lookup:hfm:s -> miss [style=bold,color=blue] lookup:hfp:s -> pass [style=bold,color=red] lookup:h:s -> lookup2 [style=bold,color=green] From nils.goroll at uplex.de Wed Dec 5 11:26:08 2018 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 5 Dec 2018 11:26:08 +0000 (UTC) Subject: [master] b509c36e4 sm graphviz: document that miss from hit is going to die Message-ID: <20181205112608.22D0E917B1@lists.varnish-cache.org> commit b509c36e439190d8c073719391f68ce846c4e6b3 Author: Nils Goroll Date: Wed Dec 5 12:21:02 2018 +0100 sm graphviz: document that miss from hit is going to die and polish the output formatting by reordering Ref #1799 diff --git a/doc/graphviz/cache_req_fsm.dot b/doc/graphviz/cache_req_fsm.dot index a33de6d5b..629072dc5 100644 --- a/doc/graphviz/cache_req_fsm.dot +++ b/doc/graphviz/cache_req_fsm.dot @@ -121,7 +121,7 @@ digraph cache_req_fsm { ] lookup2 [ shape=record - label="{cnt_lookup:|{vcl_hit\{\}|{req.*|obj.*}}|{fail|deliver|miss|restart|synth|pass}}" + label="{cnt_lookup:|{vcl_hit\{\}|{req.*|obj.*}}|{fail|deliver|pass|restart|synth|miss}}" ] } lookup:busy:s -> lookup:top:ne [label=" waitinglist", @@ -133,9 +133,7 @@ digraph cache_req_fsm { lookup:h:s -> lookup2 [style=bold,color=green] lookup2:deliver:s -> deliver:n [style=bold,color=green] - lookup2:miss:s -> miss [style=bold,color=blue] - // XXX should not happen - // lookup2:miss:s -> pass [style=bold,color=red,label="(no busy obj)"] + lookup2:miss:s -> miss [color=blue,label=" #1799 \n EOL"] lookup2:pass:s -> pass [style=bold,color=red] /* cnt_miss */ From nils.goroll at uplex.de Wed Dec 5 11:26:07 2018 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 5 Dec 2018 11:26:07 +0000 (UTC) Subject: [master] 6b3cdd5a7 fsm graphviz: label hfm/hfp Message-ID: <20181205112607.EE745917AE@lists.varnish-cache.org> commit 6b3cdd5a706e376945dc6f30b28bc0cdbc6e9d6b Author: Nils Goroll Date: Wed Dec 5 12:09:24 2018 +0100 fsm graphviz: label hfm/hfp Ref #2743 diff --git a/doc/graphviz/cache_req_fsm.dot b/doc/graphviz/cache_req_fsm.dot index 9dda7bf9e..a33de6d5b 100644 --- a/doc/graphviz/cache_req_fsm.dot +++ b/doc/graphviz/cache_req_fsm.dot @@ -128,8 +128,8 @@ digraph cache_req_fsm { color=grey, fontcolor=grey] lookup:miss:s -> miss [style=bold,color=blue] - lookup:hfm:s -> miss [style=bold,color=blue] - lookup:hfp:s -> pass [style=bold,color=red] + lookup:hfm:s -> miss [style=bold,color=blue,label=" req.\n is_hitmiss"] + lookup:hfp:s -> pass [style=bold,color=red,label=" req.\n is_hitpass"] lookup:h:s -> lookup2 [style=bold,color=green] lookup2:deliver:s -> deliver:n [style=bold,color=green] From nils.goroll at uplex.de Wed Dec 5 11:26:08 2018 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 5 Dec 2018 11:26:08 +0000 (UTC) Subject: [master] 70977c36c update the generated graphviz svg Message-ID: <20181205112608.4CD63917B8@lists.varnish-cache.org> commit 70977c36c3b85a71cd5cf98b43e94f458c0eaed7 Author: Nils Goroll Date: Wed Dec 5 12:25:26 2018 +0100 update the generated graphviz svg diff --git a/doc/graphviz/cache_req_fsm.svg b/doc/graphviz/cache_req_fsm.svg index 60c71acd1..eeb0a75c8 100644 --- a/doc/graphviz/cache_req_fsm.svg +++ b/doc/graphviz/cache_req_fsm.svg @@ -4,496 +4,509 @@ - - + + cache_req_fsm - + cluster_backend - + acceptor - -Request received + +Request received recv - -cnt_recv: - -vcl_recv{} - -req.* - -fail - -hash - -purge - -pass - -pipe - -restart - -synth - -vcl + +cnt_recv: + +vcl_recv{} + +req.* + +fail + +hash + +purge + +pass + +pipe + +restart + +synth + +vcl acceptor->recv - - + + label_select - -LABEL + +LABEL label_select->recv - - + + ESI_REQ - -ESI request + +ESI request ESI_REQ->recv - - + + RESTART -RESTART +RESTART restart - -cnt_restart: - -fail - -ok? - -max_restarts? + +cnt_restart: + +fail + +ok? + +max_restarts? -RESTART->restart - - +RESTART->restart + + hash - -cnt_recv: - -vcl_hash{} - -req.* - -lookup + +cnt_recv: + +vcl_hash{} + +req.* + +lookup -recv:hash->hash - - +recv:hash->hash + + -recv:pipe->hash - - +recv:pipe->hash + + -recv:pass->hash - - +recv:pass->hash + + -recv:purge:s->hash - - +recv:purge:s->hash + + vcl_label -switch to vcl -LABEL +switch to vcl +LABEL -recv:vcl:s->vcl_label - - +recv:vcl:s->vcl_label + + SYNTH -SYNTH +SYNTH synth - -cnt_synth: - -vcl_synth{} - -req.* - -resp.* - -fail - -deliver - -restart + +cnt_synth: + +vcl_synth{} + +req.* + +resp.* + +fail + +deliver + +restart SYNTH->synth - - + + FAIL -FAIL +FAIL FAIL->synth - - + + deliver - -cnt_deliver: - -Filter obj.->resp. - -vcl_deliver{} - -req.* - -resp.* - -fail - -restart - -deliver - -synth + +cnt_deliver: + +Filter obj.->resp. + +vcl_deliver{} + +req.* + +resp.* + +fail + +restart + +deliver + +synth V1D_Deliver - -V1D_Deliver + +V1D_Deliver deliver:deliver:s->V1D_Deliver - - + + deliver:deliver:s->V1D_Deliver - - + + deliver:deliver:s->V1D_Deliver - - + + DONE - -DONE + +DONE V1D_Deliver->DONE - - + + stream - -stream? -body + +stream? +body stream->V1D_Deliver - - + + synth:del:s->V1D_Deliver - - + + see backend graph -see backend graph +see backend graph BGFETCH - -BGFETCH + +BGFETCH FETCH - -FETCH + +FETCH FETCH_DONE - -FETCH_DONE + +FETCH_DONE FETCH->FETCH_DONE - - + + FETCH_FAIL - -FETCH_FAIL + +FETCH_FAIL FETCH->FETCH_FAIL - - + + FETCH_DONE->deliver - - + + FETCH_DONE->deliver - - + + FETCH_FAIL->synth - - + + lookup2 - -cnt_lookup: - -vcl_hit{} - -req.* - -obj.* - -fail - -deliver - -miss - -restart - -synth - -pass + +cnt_lookup: + +vcl_hit{} + +req.* + +obj.* + +fail + +deliver + +pass + +restart + +synth + +miss -lookup2:deliver:s->deliver:n - - +lookup2:deliver:s->deliver:n + + lookup2:deliver:s->BGFETCH - - -parallel -if obj expired + + +parallel +if obj expired miss - -cnt_miss: - -vcl_miss{} - -req.* - -fail - -fetch - -synth - -restart - -pass + +cnt_miss: + +vcl_miss{} + +req.* + +fail + +fetch + +synth + +restart + +pass -lookup2:miss:s->miss - - +lookup2:miss:s->miss + + + #1799 + EOL pass - -cnt_pass: - -vcl_pass{} - -req.* - -fail - -fetch - -synth - -restart + +cnt_pass: + +vcl_pass{} + +req.* + +fail + +fetch + +synth + +restart -lookup2:pass:s->pass - - +lookup2:pass:s->pass + + lookup - -cnt_lookup: - -hash lookup - -hit? - -miss? - -hit-for-pass? - -busy? + +cnt_lookup: + +hash lookup + +hit? + +miss? + +hit-for-miss? + +hit-for-pass? + +busy? -lookup:h:s->lookup2 - - +lookup:h:s->lookup2 + + -lookup:busy:e->lookup:top:e - - -(waitinglist) +lookup:busy:s->lookup:top:ne + + + waitinglist lookup:miss:s->miss - - + + + + +lookup:hfm:s->miss + + + req. + is_hitmiss -lookup:hfp:s->pass - - +lookup:hfp:s->pass + + + req. + is_hitpass -miss:fetch:s->FETCH - - +miss:fetch:s->FETCH + + -miss:pass:s->pass - - +miss:pass:s->pass + + -pass:fetch:s->FETCH - - +pass:fetch:s->FETCH + + pipe - -cnt_pipe: - -filter req.*->bereq.* - -vcl_pipe{} - -req.* - -bereq.* - -fail - -pipe - -synth + +cnt_pipe: + +filter req.*->bereq.* + +vcl_pipe{} + +req.* + +bereq.* + +fail + +pipe + +synth pipe_do - -send bereq, -copy bytes until close + +send bereq, +copy bytes until close -pipe:pipe->pipe_do - - +pipe:pipe->pipe_do + + -pipe_do->DONE - - +pipe_do->DONE + + -restart:ok:s->recv - - +restart:ok:s->recv + + err_restart -SYNTH +SYNTH -restart:max:s->err_restart - - +restart:max:s->err_restart + + -hash:lookup:w->lookup - - +hash:lookup:w->lookup + + -hash:lookup:s->pass - - +hash:lookup:s->pass + + -hash:lookup:e->pipe - - +hash:lookup:e->pipe + + purge - -cnt_purge: - -vcl_purge{} - -req.* - -fail - -synth - -restart + +cnt_purge: + +vcl_purge{} + +req.* + +fail + +synth + +restart -hash:lookup:s->purge:top:n - - +hash:lookup:s->purge:top:n + + From nils.goroll at uplex.de Wed Dec 5 12:27:13 2018 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 5 Dec 2018 12:27:13 +0000 (UTC) Subject: [master] d49ade4c3 do not unlock oh before the waitinglist setup is complete Message-ID: <20181205122713.8A10193359@lists.varnish-cache.org> commit d49ade4c3d229c9a4d3eb60791f95ffb837e7e18 Author: Nils Goroll Date: Wed Dec 5 13:23:38 2018 +0100 do not unlock oh before the waitinglist setup is complete The moment we unlock the oh, another thread could rush req Partially undoes f35b86bc1d3a9d1b61979667fc07e4fffedc27ae Huge thank you to @mbgrydeland for spotting my mistake diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index 5c25abc4a..e9b8466d9 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -522,11 +522,9 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp) /* There are one or more busy objects, wait for them */ VTAILQ_INSERT_TAIL(&oh->waitinglist, req, w_list); - Lck_Unlock(&oh->mtx); AZ(req->hash_ignore_busy); - wrk->stats->busy_sleep++; /* * The objhead reference transfers to the sess, we get it * back when the sess comes off the waiting list and @@ -539,6 +537,9 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp) if (DO_DEBUG(DBG_WAITINGLIST)) VSLb(req->vsl, SLT_Debug, "on waiting list <%p>", oh); + Lck_Unlock(&oh->mtx); + + wrk->stats->busy_sleep++; return (HSH_BUSY); } From daghf at varnish-software.com Thu Dec 6 09:37:12 2018 From: daghf at varnish-software.com (Dag Haavi Finstad) Date: Thu, 6 Dec 2018 09:37:12 +0000 (UTC) Subject: [master] 5b6a4e560 travis: Our svg bits require graphviz Message-ID: <20181206093712.352DC5101@lists.varnish-cache.org> commit 5b6a4e5600ebf37fb3a7f46020e38da4cc8994ae Author: Dag Haavi Finstad Date: Thu Dec 6 10:35:24 2018 +0100 travis: Our svg bits require graphviz diff --git a/.travis.yml b/.travis.yml index 8d31d9e04..311ebd559 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,6 +24,7 @@ addons: packages: - python-docutils - python-sphinx + - graphviz homebrew: packages: - docutils From dridi at varni.sh Thu Dec 6 09:43:39 2018 From: dridi at varni.sh (Dridi Boukelmoune) Date: Thu, 6 Dec 2018 10:43:39 +0100 Subject: [master] 5b6a4e560 travis: Our svg bits require graphviz In-Reply-To: <20181206093712.352DC5101@lists.varnish-cache.org> References: <20181206093712.352DC5101@lists.varnish-cache.org> Message-ID: On Thu, Dec 6, 2018 at 10:37 AM Dag Haavi Finstad wrote: > > > commit 5b6a4e5600ebf37fb3a7f46020e38da4cc8994ae > Author: Dag Haavi Finstad > Date: Thu Dec 6 10:35:24 2018 +0100 > > travis: Our svg bits require graphviz It was decided that we check in the generated SVGs to not require graphviz downstream, this probably needs to be reverted. > diff --git a/.travis.yml b/.travis.yml > index 8d31d9e04..311ebd559 100644 > --- a/.travis.yml > +++ b/.travis.yml > @@ -24,6 +24,7 @@ addons: > packages: > - python-docutils > - python-sphinx > + - graphviz > homebrew: > packages: > - docutils > _______________________________________________ > varnish-commit mailing list > varnish-commit at varnish-cache.org > https://www.varnish-cache.org/lists/mailman/listinfo/varnish-commit From daghf at varnish-software.com Thu Dec 6 09:48:35 2018 From: daghf at varnish-software.com (Dag Haavi Finstad) Date: Thu, 6 Dec 2018 10:48:35 +0100 Subject: [master] 5b6a4e560 travis: Our svg bits require graphviz In-Reply-To: References: <20181206093712.352DC5101@lists.varnish-cache.org> Message-ID: Something else is probably wrong, then? I did this because I noticed Nils' PR #2859 is currently failing in travis because of what looks to be a missing graphviz dependency. https://github.com/varnishcache/varnish-cache/pull/2859 https://travis-ci.org/varnishcache/varnish-cache/jobs/463897300 I'll revert. On Thu, Dec 6, 2018 at 10:44 AM Dridi Boukelmoune wrote: > On Thu, Dec 6, 2018 at 10:37 AM Dag Haavi Finstad > wrote: > > > > > > commit 5b6a4e5600ebf37fb3a7f46020e38da4cc8994ae > > Author: Dag Haavi Finstad > > Date: Thu Dec 6 10:35:24 2018 +0100 > > > > travis: Our svg bits require graphviz > > It was decided that we check in the generated SVGs to not require > graphviz downstream, this probably needs to be reverted. > > > diff --git a/.travis.yml b/.travis.yml > > index 8d31d9e04..311ebd559 100644 > > --- a/.travis.yml > > +++ b/.travis.yml > > @@ -24,6 +24,7 @@ addons: > > packages: > > - python-docutils > > - python-sphinx > > + - graphviz > > homebrew: > > packages: > > - docutils > > _______________________________________________ > > varnish-commit mailing list > > varnish-commit at varnish-cache.org > > https://www.varnish-cache.org/lists/mailman/listinfo/varnish-commit > -- Dag Haavi Finstad Software Developer | Varnish Software Mobile: +47 476 64 134 We Make Websites Fly! -------------- next part -------------- An HTML attachment was scrubbed... URL: From daghf at varnish-software.com Thu Dec 6 09:50:15 2018 From: daghf at varnish-software.com (Dag Haavi Finstad) Date: Thu, 6 Dec 2018 09:50:15 +0000 (UTC) Subject: [master] 6c625090a Revert "travis: Our svg bits require graphviz" Message-ID: <20181206095015.4C41F59C0@lists.varnish-cache.org> commit 6c625090a1ad51a6abd6ead5dad735fda75861ad Author: Dag Haavi Finstad Date: Thu Dec 6 10:48:50 2018 +0100 Revert "travis: Our svg bits require graphviz" This reverts commit 5b6a4e5600ebf37fb3a7f46020e38da4cc8994ae. diff --git a/.travis.yml b/.travis.yml index 311ebd559..8d31d9e04 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,7 +24,6 @@ addons: packages: - python-docutils - python-sphinx - - graphviz homebrew: packages: - docutils From dridi at varni.sh Thu Dec 6 09:54:42 2018 From: dridi at varni.sh (Dridi Boukelmoune) Date: Thu, 6 Dec 2018 10:54:42 +0100 Subject: [master] 5b6a4e560 travis: Our svg bits require graphviz In-Reply-To: References: <20181206093712.352DC5101@lists.varnish-cache.org> Message-ID: On Thu, Dec 6, 2018 at 10:48 AM Dag Haavi Finstad wrote: > > Something else is probably wrong, then? > > I did this because I noticed Nils' PR #2859 is currently failing in travis because of what looks to be a missing graphviz dependency. > https://github.com/varnishcache/varnish-cache/pull/2859 > https://travis-ci.org/varnishcache/varnish-cache/jobs/463897300 > > I'll revert. Nils is very much aware of this (he recently made modifications to the FSM diagrams outside of this PR) and most likely didn't update the SVGs on purpose. > I Intentionally did not include the generated SVGs in this PR to not add changes without any semantic value. I read he omitted them to avoid SVG noise in the diff for reviewers. Dridi From phk at FreeBSD.org Thu Dec 6 10:31:17 2018 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 6 Dec 2018 10:31:17 +0000 (UTC) Subject: [master] e8985f227 Convert req->top to a structure so we can store more stuff in it. Message-ID: <20181206103117.1C60A6800@lists.varnish-cache.org> commit e8985f22711fe9a342b27a10052ae3655f64435c Author: Poul-Henning Kamp Date: Thu Dec 6 10:29:46 2018 +0000 Convert req->top to a structure so we can store more stuff in it. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index b7e6e1f7e..c202381d6 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -444,6 +444,12 @@ struct busyobj { /*--------------------------------------------------------------------*/ +struct reqtop { + unsigned magic; +#define REQTOP_MAGIC 0x57fbda52 + struct req *topreq; +}; + struct req { unsigned magic; #define REQ_MAGIC 0x2751aaa1 @@ -453,7 +459,7 @@ struct req { enum sess_close doclose; int restarts; int esi_level; - struct req *top; /* esi_level == 0 request */ + struct reqtop *top; /* esi_level == 0 request */ #define REQ_FLAG(l, r, w, d) unsigned l:1; #include "tbl/req_flags.h" diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index 9d1fd4782..c4733af7d 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -103,6 +103,7 @@ ved_include(struct req *preq, const char *src, const char *host, enum req_fsm_nxt s; CHECK_OBJ_NOTNULL(preq, REQ_MAGIC); + CHECK_OBJ_NOTNULL(preq->top, REQTOP_MAGIC); sp = preq->sp; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(ecx, ECX_MAGIC); @@ -124,11 +125,6 @@ ved_include(struct req *preq, const char *src, const char *host, VSLb(preq->vsl, SLT_Link, "req %u esi", VXID(req->vsl->wid)); req->esi_level = preq->esi_level + 1; - if (preq->esi_level == 0) - assert(preq->top == preq); - else - CHECK_OBJ_NOTNULL(preq->top, REQ_MAGIC); - req->top = preq->top; HTTP_Copy(req->http0, preq->http0); @@ -263,6 +259,17 @@ ved_vdp_esi_init(struct req *req, void **priv) ecx->preq = req; *priv = ecx; RFC2616_Weaken_Etag(req->resp); + + if (req->esi_level == 0) { + Req_MakeTop(req); + if (req->top == NULL) { + VSLb(req->vsl, SLT_Error, + "(top)request workspace overflow"); + Req_Fail(req, SC_OVERLOAD); + return (-1); + } + } + req->res_mode |= RES_ESI; if (req->resp_len != 0) req->resp_len = -1; diff --git a/bin/varnishd/cache/cache_req.c b/bin/varnishd/cache/cache_req.c index 5ab13a2cf..e0ade75a6 100644 --- a/bin/varnishd/cache/cache_req.c +++ b/bin/varnishd/cache/cache_req.c @@ -93,7 +93,6 @@ Req_New(const struct worker *wrk, struct sess *sp) AN(req); req->magic = REQ_MAGIC; req->sp = sp; - req->top = req; // esi overrides e = (char*)req + sz; p = (char*)(req + 1); @@ -176,6 +175,7 @@ Req_Release(struct req *req) MPL_AssertSane(req); VSL_Flush(req->vsl, 0); req->sp = NULL; + req->top = NULL; MPL_Free(pp->mpl_req, req); } @@ -194,6 +194,7 @@ Req_Rollback(struct req *req) if (WS_Overflowed(req->ws)) req->wrk->stats->ws_client_overflow++; WS_Reset(req->ws, req->ws_req); + req->top = NULL; } /*---------------------------------------------------------------------- @@ -211,10 +212,10 @@ Req_Cleanup(struct sess *sp, struct worker *wrk, struct req *req) req->director_hint = NULL; req->restarts = 0; + req->top = 0; AZ(req->esi_level); AZ(req->privs->magic); - assert(req->top == req); if (req->vcl != NULL) { if (wrk->vcl != NULL) @@ -261,3 +262,20 @@ Req_Fail(struct req *req, enum sess_close reason) AN(req->transport->req_fail); req->transport->req_fail(req, reason); } + +/*---------------------------------------------------------------------- + */ + +void +Req_MakeTop(struct req *req) +{ + + CHECK_OBJ_ORNULL(req->top, REQTOP_MAGIC); + if (req->top != NULL) + return; + req->top = WS_Alloc(req->ws, sizeof *req->top); + if (req->top != NULL) { + INIT_OBJ(req->top, REQTOP_MAGIC); + req->top->topreq = req; + } +} diff --git a/bin/varnishd/cache/cache_varnishd.h b/bin/varnishd/cache/cache_varnishd.h index 8b5ad9ebd..ef3184bed 100644 --- a/bin/varnishd/cache/cache_varnishd.h +++ b/bin/varnishd/cache/cache_varnishd.h @@ -314,6 +314,7 @@ void Req_Rollback(struct req *req); void Req_Cleanup(struct sess *sp, struct worker *wrk, struct req *req); void Req_Fail(struct req *req, enum sess_close reason); void Req_AcctLogCharge(struct VSC_main_wrk *, struct req *); +void Req_MakeTop(struct req *req); /* cache_req_body.c */ int VRB_Ignore(struct req *); diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c index 418c6d7ee..de2c35502 100644 --- a/bin/varnishd/cache/cache_vcl.c +++ b/bin/varnishd/cache/cache_vcl.c @@ -94,7 +94,11 @@ VCL_Req2Ctx(struct vrt_ctx *ctx, struct req *req) ctx->vcl = req->vcl; ctx->vsl = req->vsl; ctx->http_req = req->http; - ctx->http_req_top = req->top->http; + CHECK_OBJ_ORNULL(req->top, REQTOP_MAGIC); + if (req->top != NULL) + ctx->http_req_top = req->top->topreq->http; + else + ctx->http_req_top = req->http; ctx->http_resp = req->resp; ctx->req = req; ctx->sp = req->sp; diff --git a/bin/varnishd/cache/cache_vrt_priv.c b/bin/varnishd/cache/cache_vrt_priv.c index 0719e203f..f1940ea4d 100644 --- a/bin/varnishd/cache/cache_vrt_priv.c +++ b/bin/varnishd/cache/cache_vrt_priv.c @@ -158,17 +158,23 @@ struct vmod_priv * VRT_priv_top(VRT_CTX, const void *vmod_id) { struct vrt_privs *vps; + struct req *req; CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); - if (ctx->req) { - CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); - CHECK_OBJ_NOTNULL(ctx->req->top, REQ_MAGIC); - CAST_OBJ_NOTNULL(vps, ctx->req->top->privs, VRT_PRIVS_MAGIC); - return (vrt_priv_dynamic(ctx->req->top->ws, vps, - (uintptr_t)vmod_id)); - } else + if (ctx->req == NULL) { WRONG("PRIV_TOP is only accessible in client VCL context"); - NEEDLESS(return NULL); + NEEDLESS(return NULL); + } + CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); + if (ctx->req->top != NULL) { + CHECK_OBJ_NOTNULL(ctx->req->top, REQTOP_MAGIC); + CHECK_OBJ_NOTNULL(ctx->req->top->topreq, REQ_MAGIC); + req = ctx->req->top->topreq; + } else { + req = ctx->req; + } + CAST_OBJ_NOTNULL(vps, req->privs, VRT_PRIVS_MAGIC); + return (vrt_priv_dynamic(req->ws, vps, (uintptr_t)vmod_id)); } /*-------------------------------------------------------------------- diff --git a/bin/varnishd/cache/cache_vrt_vcl.c b/bin/varnishd/cache/cache_vrt_vcl.c index 4147e211c..5b443017c 100644 --- a/bin/varnishd/cache/cache_vrt_vcl.c +++ b/bin/varnishd/cache/cache_vrt_vcl.c @@ -411,6 +411,7 @@ vcl_call_method(struct worker *wrk, struct req *req, struct busyobj *bo, CHECK_OBJ_NOTNULL(req, REQ_MAGIC); CHECK_OBJ_NOTNULL(req->sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(req->vcl, VCL_MAGIC); + CHECK_OBJ_ORNULL(req->top, REQTOP_MAGIC); VCL_Req2Ctx(&ctx, req); } if (bo != NULL) { From nils.goroll at uplex.de Sun Dec 9 21:23:07 2018 From: nils.goroll at uplex.de (Nils Goroll) Date: Sun, 9 Dec 2018 21:23:07 +0000 (UTC) Subject: [master] 14136d4a2 test durations with decimals as inputs to std.duration Message-ID: <20181209212307.F08759BA83@lists.varnish-cache.org> commit 14136d4a277c230ef03ff47a1e9ead773a42cb27 Author: Nils Goroll Date: Sun Dec 9 22:22:21 2018 +0100 test durations with decimals as inputs to std.duration diff --git a/bin/varnishtest/tests/m00005.vtc b/bin/varnishtest/tests/m00005.vtc index fecbe3fc6..13e8c2dc9 100644 --- a/bin/varnishtest/tests/m00005.vtc +++ b/bin/varnishtest/tests/m00005.vtc @@ -14,13 +14,17 @@ varnish v1 -vcl+backend { } -start client c1 { + txreq -hdr "ttl: 0.010s" + rxresp + expect resp.http.ttl == 1000000.010 + txreq -hdr "ttl: 10ms" rxresp expect resp.http.ttl == 1000000.010 - txreq -hdr "ttl: 10s" + txreq -hdr "ttl: 10.1s" rxresp - expect resp.http.ttl == 1000010.000 + expect resp.http.ttl == 1000010.100 txreq -hdr "ttl: 10m" rxresp From phk at FreeBSD.org Mon Dec 10 09:45:16 2018 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 10 Dec 2018 09:45:16 +0000 (UTC) Subject: [master] f0b50447e Release wrk->vcl before (potentially) long-running worker jobs which do not need it (acceptor, h2_sess) Message-ID: <20181210094516.ECC77ACB7F@lists.varnish-cache.org> commit f0b50447e14cc496acf9cbcf719c56baf087d4f6 Author: Poul-Henning Kamp Date: Mon Dec 10 09:22:04 2018 +0000 Release wrk->vcl before (potentially) long-running worker jobs which do not need it (acceptor, h2_sess) diff --git a/bin/varnishd/cache/cache_acceptor.c b/bin/varnishd/cache/cache_acceptor.c index 3874ac70d..ba4e84be9 100644 --- a/bin/varnishd/cache/cache_acceptor.c +++ b/bin/varnishd/cache/cache_acceptor.c @@ -460,6 +460,10 @@ vca_accept_task(struct worker *wrk, void *arg) while (!pool_accepting) VTIM_sleep(.1); + /* Dont hold on to (possibly) discarded VCLs */ + if (wrk->vcl != NULL) + VCL_Rel(&wrk->vcl); + while (!ps->pool->die) { INIT_OBJ(&wa, WRK_ACCEPT_MAGIC); wa.acceptlsock = ls; @@ -547,12 +551,6 @@ vca_accept_task(struct worker *wrk, void *arg) if (!ps->pool->die && DO_DEBUG(DBG_SLOW_ACCEPTOR)) VTIM_sleep(2.0); - /* - * We were able to hand off, so release this threads VCL - * reference (if any) so we don't hold on to discarded VCLs. - */ - if (wrk->vcl != NULL) - VCL_Rel(&wrk->vcl); } } diff --git a/bin/varnishd/http2/cache_http2_session.c b/bin/varnishd/http2/cache_http2_session.c index 932a5b93f..8828c146e 100644 --- a/bin/varnishd/http2/cache_http2_session.c +++ b/bin/varnishd/http2/cache_http2_session.c @@ -344,6 +344,9 @@ h2_new_session(struct worker *wrk, void *arg) sp = req->sp; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + if (wrk->vcl) + VCL_Rel(&wrk->vcl); + assert(req->transport == &H2_transport); assert (req->err_code == H2_PU_MARKER || req->err_code == H2_OU_MARKER); From phk at FreeBSD.org Mon Dec 10 11:40:10 2018 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 10 Dec 2018 11:40:10 +0000 (UTC) Subject: [master] 2fe1e1aa9 Centralize the req borrowing VCL from wrk Message-ID: <20181210114010.B0A792D72@lists.varnish-cache.org> commit 2fe1e1aa91af45277da5cdc41bc458b4a97a17d9 Author: Poul-Henning Kamp Date: Mon Dec 10 10:23:30 2018 +0000 Centralize the req borrowing VCL from wrk diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 20a219f38..69b5f8dd4 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -821,6 +821,7 @@ cnt_recv_prep(struct req *req, const char *ci) req->is_hitmiss = 0; req->is_hitpass = 0; } + /*-------------------------------------------------------------------- * We have a complete request, set everything up and start it. * We can come here both with a request from the client and with @@ -1026,7 +1027,6 @@ CNT_Request(struct worker *wrk, struct req *req) CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - AN(req->vcl); /* * Possible entrance states @@ -1041,6 +1041,13 @@ CNT_Request(struct worker *wrk, struct req *req) /* wrk can have changed for restarts */ req->vfc->wrk = req->wrk = wrk; wrk->vsl = req->vsl; + if (req->req_step == R_STP_TRANSPORT) { + AZ(req->vcl); + VCL_Refresh(&wrk->vcl); + req->vcl = wrk->vcl; + wrk->vcl = NULL; + } + AN(req->vcl); if (req->req_step != R_STP_LOOKUP) VCL_TaskEnter(req->vcl, req->privs); for (nxt = REQ_FSM_MORE; nxt == REQ_FSM_MORE; ) { diff --git a/bin/varnishd/http1/cache_http1_fsm.c b/bin/varnishd/http1/cache_http1_fsm.c index a6693f662..7210ab761 100644 --- a/bin/varnishd/http1/cache_http1_fsm.c +++ b/bin/varnishd/http1/cache_http1_fsm.c @@ -281,11 +281,6 @@ http1_dissect(struct worker *wrk, struct req *req) VSLb_ts_req(req, "Start", req->t_first); VSLb_ts_req(req, "Req", req->t_req); - /* Borrow VCL reference from worker thread */ - VCL_Refresh(&wrk->vcl); - req->vcl = wrk->vcl; - wrk->vcl = NULL; - HTTP_Setup(req->http, req->ws, req->vsl, SLT_ReqMethod); req->err_code = HTTP1_DissectRequest(req->htc, req->http); diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index 7d040b7d0..0ff9b03a6 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -661,9 +661,6 @@ h2_rx_headers(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) req->t_req = VTIM_real(); req->t_prev = req->t_first; VSLb_ts_req(req, "Start", req->t_first); - VCL_Refresh(&wrk->vcl); - req->vcl = wrk->vcl; - wrk->vcl = NULL; req->acct.req_hdrbytes += h2->rxf_len; HTTP_Setup(req->http, req->ws, req->vsl, SLT_ReqMethod); diff --git a/bin/varnishd/http2/cache_http2_session.c b/bin/varnishd/http2/cache_http2_session.c index 8828c146e..115ec6b8d 100644 --- a/bin/varnishd/http2/cache_http2_session.c +++ b/bin/varnishd/http2/cache_http2_session.c @@ -239,8 +239,7 @@ h2_ou_rel(struct worker *wrk, struct req *req) { CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - AN (req->vcl); - VCL_Rel(&req->vcl); + AZ(req->vcl); Req_AcctLogCharge(wrk->stats, req); Req_Release(req); return (0); From phk at FreeBSD.org Tue Dec 11 11:51:12 2018 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 11 Dec 2018 11:51:12 +0000 (UTC) Subject: [master] 3f0c7ade7 Give esi:includes a ->minimal_reponse and make it panic, because that should not happen. Message-ID: <20181211115112.455AAA5CFF@lists.varnish-cache.org> commit 3f0c7ade7e23bc4317e07eb9c665bf6bd6bf02c1 Author: Poul-Henning Kamp Date: Tue Dec 11 10:33:12 2018 +0000 Give esi:includes a ->minimal_reponse and make it panic, because that should not happen. diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index 656df25a8..97bc7e6f0 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -68,11 +68,20 @@ struct ecx { uint32_t crc; }; +static int v_matchproto_(vtr_minimal_response_f) +ved_minimal_response(struct req *req, uint16_t status) +{ + (void)req; + (void)status; + WRONG("esi:includes should not try minimal responses"); +} + static const struct transport VED_transport = { - .magic = TRANSPORT_MAGIC, - .name = "ESI_INCLUDE", - .deliver = ved_deliver, - .reembark = ved_reembark, + .magic = TRANSPORT_MAGIC, + .name = "ESI_INCLUDE", + .deliver = ved_deliver, + .reembark = ved_reembark, + .minimal_response = ved_minimal_response, }; /*--------------------------------------------------------------------*/ diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 69b5f8dd4..0a16ae808 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -64,7 +64,6 @@ cnt_transport(struct worker *wrk, struct req *req) CHECK_OBJ_NOTNULL(req->http, HTTP_MAGIC); CHECK_OBJ_NOTNULL(req->transport, TRANSPORT_MAGIC); assert(req->req_body_status != REQ_BODY_INIT); - AN(req->transport->minimal_response); if (http_GetHdr(req->http, H_Expect, &p)) { if (strcasecmp(p, "100-continue")) { @@ -1028,6 +1027,10 @@ CNT_Request(struct worker *wrk, struct req *req) CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(req, REQ_MAGIC); + CHECK_OBJ_NOTNULL(req->transport, TRANSPORT_MAGIC); + AN(req->transport->deliver); + AN(req->transport->minimal_response); + /* * Possible entrance states */ From phk at FreeBSD.org Tue Dec 11 11:51:11 2018 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 11 Dec 2018 11:51:11 +0000 (UTC) Subject: [master] d46391faf Don't recache req->vcl in wrk unless it will speed things up later. Message-ID: <20181211115112.2D784A5CFC@lists.varnish-cache.org> commit d46391fafb854fc9e6f0f217668de5e7f9311305 Author: Poul-Henning Kamp Date: Tue Dec 11 08:45:07 2018 +0000 Don't recache req->vcl in wrk unless it will speed things up later. diff --git a/bin/varnishd/cache/cache_req.c b/bin/varnishd/cache/cache_req.c index e0ade75a6..d16f550c4 100644 --- a/bin/varnishd/cache/cache_req.c +++ b/bin/varnishd/cache/cache_req.c @@ -217,12 +217,8 @@ Req_Cleanup(struct sess *sp, struct worker *wrk, struct req *req) AZ(req->esi_level); AZ(req->privs->magic); - if (req->vcl != NULL) { - if (wrk->vcl != NULL) - VCL_Rel(&wrk->vcl); - wrk->vcl = req->vcl; - req->vcl = NULL; - } + if (req->vcl != NULL) + VCL_Recache(wrk, &req->vcl); /* Charge and log byte counters */ if (req->vsl->wid) { diff --git a/bin/varnishd/cache/cache_varnishd.h b/bin/varnishd/cache/cache_varnishd.h index ef3184bed..0c29891e6 100644 --- a/bin/varnishd/cache/cache_varnishd.h +++ b/bin/varnishd/cache/cache_varnishd.h @@ -382,6 +382,7 @@ void VCL_Panic(struct vsb *, const struct vcl *); void VCL_Poll(void); void VCL_Ref(struct vcl *); void VCL_Refresh(struct vcl **); +void VCL_Recache(struct worker *, struct vcl **); void VCL_Rel(struct vcl **); void VCL_TaskEnter(const struct vcl *, struct vrt_privs *); void VCL_TaskLeave(const struct vcl *, struct vrt_privs *); diff --git a/bin/varnishd/cache/cache_vrt_vcl.c b/bin/varnishd/cache/cache_vrt_vcl.c index 5b443017c..051d16c9f 100644 --- a/bin/varnishd/cache/cache_vrt_vcl.c +++ b/bin/varnishd/cache/cache_vrt_vcl.c @@ -76,17 +76,36 @@ VCL_Method_Name(unsigned m) void VCL_Refresh(struct vcl **vcc) { + + while (vcl_active == NULL) + (void)usleep(100000); + if (*vcc == vcl_active) return; if (*vcc != NULL) VCL_Rel(vcc); /* XXX: optimize locking */ - while (vcl_active == NULL) - (void)usleep(100000); - vcl_get(vcc, NULL); } +void +VCL_Recache(struct worker *wrk, struct vcl **vclp) +{ + + AN(wrk); + AN(vclp); + CHECK_OBJ_NOTNULL(*vclp, VCL_MAGIC); + + if (*vclp != vcl_active || wrk->vcl == vcl_active) { + VCL_Rel(vclp); + return; + } + if (wrk->vcl != NULL) + VCL_Rel(&wrk->vcl); + wrk->vcl = *vclp; + *vclp = NULL; +} + void VCL_Ref(struct vcl *vcl) { From phk at FreeBSD.org Tue Dec 11 11:51:12 2018 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 11 Dec 2018 11:51:12 +0000 (UTC) Subject: [master] 5691cc0db Don't borrow the parent VCL in esi-includes, vcl switching would give subsequent esi-includes the wrong vcl. Message-ID: <20181211115112.4F959A5D00@lists.varnish-cache.org> commit 5691cc0dbf1f6e59a5f21d4b84047c6cb9371fd6 Author: Poul-Henning Kamp Date: Tue Dec 11 08:53:31 2018 +0000 Don't borrow the parent VCL in esi-includes, vcl switching would give subsequent esi-includes the wrong vcl. diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index c4733af7d..656df25a8 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -163,7 +163,7 @@ ved_include(struct req *preq, const char *src, const char *host, AZ(req->vcl); req->vcl = preq->vcl; - preq->vcl = NULL; + VCL_Ref(req->vcl); req->req_step = R_STP_RECV; req->t_req = preq->t_req; @@ -197,9 +197,7 @@ ved_include(struct req *preq, const char *src, const char *host, AZ(req->wrk); } - AZ(preq->vcl); - preq->vcl = req->vcl; - req->vcl = NULL; + VCL_Rel(&req->vcl); req->wrk = NULL; THR_SetRequest(preq); From phk at FreeBSD.org Tue Dec 11 11:51:12 2018 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 11 Dec 2018 11:51:12 +0000 (UTC) Subject: [master] 2e66e0b93 Make it the transports job to increment stats->client_req Message-ID: <20181211115112.5D11BA5D02@lists.varnish-cache.org> commit 2e66e0b93ba6e50fa5ef499cd6a4860d0fa56134 Author: Poul-Henning Kamp Date: Tue Dec 11 11:49:30 2018 +0000 Make it the transports job to increment stats->client_req diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 0a16ae808..5316c8a2e 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -78,8 +78,6 @@ cnt_transport(struct worker *wrk, struct req *req) http_Unset(req->http, H_Expect); } - wrk->stats->client_req++; - AZ(req->err_code); req->doclose = http_DoConnection(req->http); diff --git a/bin/varnishd/http1/cache_http1_fsm.c b/bin/varnishd/http1/cache_http1_fsm.c index 7210ab761..3ef60429d 100644 --- a/bin/varnishd/http1/cache_http1_fsm.c +++ b/bin/varnishd/http1/cache_http1_fsm.c @@ -441,6 +441,7 @@ HTTP1_Session(struct worker *wrk, struct req *req) } else if (st == H1PROC) { req->task.func = http1_req; req->task.priv = req; + wrk->stats->client_req++; if (CNT_Request(wrk, req) == REQ_FSM_DISEMBARK) return; req->task.func = NULL; diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index 0ff9b03a6..76046d92f 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -536,6 +536,7 @@ h2_do_req(struct worker *wrk, void *priv) THR_SetRequest(req); req->http->conds = 1; + wrk->stats->client_req++; if (CNT_Request(wrk, req) != REQ_FSM_DISEMBARK) { AZ(req->ws->r); h2 = r2->h2sess; From phk at FreeBSD.org Tue Dec 11 16:16:08 2018 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 11 Dec 2018 16:16:08 +0000 (UTC) Subject: [master] 2c59afe22 Simplify the interface between esi:include delivery and CNT Message-ID: <20181211161609.1D724AE3D0@lists.varnish-cache.org> commit 2c59afe22ba108c7f2ab5ff75b2e30baf4ef9ec7 Author: Poul-Henning Kamp Date: Tue Dec 11 16:09:35 2018 +0000 Simplify the interface between esi:include delivery and CNT diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index 97bc7e6f0..4bc9cd098 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -126,68 +126,59 @@ ved_include(struct req *preq, const char *src, const char *host, } req = Req_New(wrk, sp); - SES_Ref(sp); - req->req_body_status = REQ_BODY_NONE; + AN(req); + THR_SetRequest(req); AZ(req->vsl->wid); req->vsl->wid = VXID_Get(wrk, VSL_CLIENTMARKER); + VSLb(req->vsl, SLT_Begin, "req %u esi", VXID(preq->vsl->wid)); VSLb(preq->vsl, SLT_Link, "req %u esi", VXID(req->vsl->wid)); + + VSLb_ts_req(req, "Start", W_TIM_real(wrk)); + req->esi_level = preq->esi_level + 1; req->top = preq->top; - HTTP_Copy(req->http0, preq->http0); + HTTP_Setup(req->http, req->ws, req->vsl, SLT_ReqMethod); + HTTP_Copy(req->http, preq->http); + req->http->conds = 0; - req->http0->ws = req->ws; - req->http0->vsl = req->vsl; - req->http0->logtag = SLT_ReqMethod; - req->http0->conds = 0; - - http_SetH(req->http0, HTTP_HDR_URL, src); + http_SetH(req->http, HTTP_HDR_URL, src); if (host != NULL && *host != '\0') { - http_Unset(req->http0, H_Host); - http_SetHeader(req->http0, host); + http_Unset(req->http, H_Host); + http_SetHeader(req->http, host); } - http_ForceField(req->http0, HTTP_HDR_METHOD, "GET"); - http_ForceField(req->http0, HTTP_HDR_PROTO, "HTTP/1.1"); + http_ForceField(req->http, HTTP_HDR_METHOD, "GET"); + http_ForceField(req->http, HTTP_HDR_PROTO, "HTTP/1.1"); /* Don't allow conditionals, we can't use a 304 */ - http_Unset(req->http0, H_If_Modified_Since); - http_Unset(req->http0, H_If_None_Match); + http_Unset(req->http, H_If_Modified_Since); + http_Unset(req->http, H_If_None_Match); /* Don't allow Range */ - http_Unset(req->http0, H_Range); + http_Unset(req->http, H_Range); /* Set Accept-Encoding according to what we want */ - http_Unset(req->http0, H_Accept_Encoding); + http_Unset(req->http, H_Accept_Encoding); if (ecx->isgzip) - http_ForceHeader(req->http0, H_Accept_Encoding, "gzip"); + http_ForceHeader(req->http, H_Accept_Encoding, "gzip"); /* Client content already taken care of */ - http_Unset(req->http0, H_Content_Length); - - /* Reset request to status before we started messing with it */ - HTTP_Copy(req->http, req->http0); + http_Unset(req->http, H_Content_Length); + req->req_body_status = REQ_BODY_NONE; AZ(req->vcl); req->vcl = preq->vcl; VCL_Ref(req->vcl); - req->req_step = R_STP_RECV; + req->req_step = R_STP_TRANSPORT; req->t_req = preq->t_req; - assert(isnan(req->t_first)); - assert(isnan(req->t_prev)); req->transport = &VED_transport; req->transport_priv = ecx; - THR_SetRequest(req); - - VSLb_ts_req(req, "Start", W_TIM_real(wrk)); - - req->ws_req = WS_Snapshot(req->ws); - while (1) { req->wrk = wrk; ecx->woken = 0; @@ -202,7 +193,6 @@ ved_include(struct req *preq, const char *src, const char *host, (void)Lck_CondWait( &ecx->preq->wrk->cond, &sp->mtx, 0); Lck_Unlock(&sp->mtx); - ecx->woken = 0; AZ(req->wrk); } @@ -213,7 +203,6 @@ ved_include(struct req *preq, const char *src, const char *host, Req_AcctLogCharge(wrk->stats, req); Req_Release(req); - SES_Rel(sp); } /*--------------------------------------------------------------------*/ diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 5316c8a2e..7255cd63c 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -1034,15 +1034,14 @@ CNT_Request(struct worker *wrk, struct req *req) */ assert( req->req_step == R_STP_LOOKUP || - req->req_step == R_STP_TRANSPORT || - req->req_step == R_STP_RECV); + req->req_step == R_STP_TRANSPORT); AN(req->vsl->wid & VSL_CLIENTMARKER); /* wrk can have changed for restarts */ req->vfc->wrk = req->wrk = wrk; wrk->vsl = req->vsl; - if (req->req_step == R_STP_TRANSPORT) { + if (req->req_step == R_STP_TRANSPORT && req->vcl == NULL) { AZ(req->vcl); VCL_Refresh(&wrk->vcl); req->vcl = wrk->vcl; From dridi.boukelmoune at gmail.com Tue Dec 11 17:22:07 2018 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 11 Dec 2018 17:22:07 +0000 (UTC) Subject: [master] bdc0c48f3 Sync documentation with mgt_main.c Message-ID: <20181211172207.81FB329D4@lists.varnish-cache.org> commit bdc0c48f38c8789337896d913e7825d0f26bc821 Author: Dridi Boukelmoune Date: Tue Dec 11 18:20:14 2018 +0100 Sync documentation with mgt_main.c See `git grep PROXY -- bin/varnishd/mgt/mgt_main.c`. diff --git a/doc/sphinx/reference/varnishd.rst b/doc/sphinx/reference/varnishd.rst index de7ee866f..57c657711 100644 --- a/doc/sphinx/reference/varnishd.rst +++ b/doc/sphinx/reference/varnishd.rst @@ -57,7 +57,7 @@ Basic options Name is referenced in logs. If name is not specified, "a0", "a1", etc. is used. An additional protocol type can be set for the - listening socket with PROTO. Valid protocol types are: HTTP/1 + listening socket with PROTO. Valid protocol types are: HTTP (default), and PROXY. Multiple listening addresses can be specified by using different From dridi.boukelmoune at gmail.com Tue Dec 11 17:49:07 2018 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 11 Dec 2018 17:49:07 +0000 (UTC) Subject: [master] e135d0725 More details on 6.0 packaging changes Message-ID: <20181211174907.624364320@lists.varnish-cache.org> commit e135d07250a77368ededf5f9107a8cb445a35e83 Author: Dridi Boukelmoune Date: Tue Dec 11 18:46:55 2018 +0100 More details on 6.0 packaging changes It turns out people are really attached to their varnish.params file. diff --git a/doc/sphinx/whats-new/upgrading-6.0.rst b/doc/sphinx/whats-new/upgrading-6.0.rst index 7dcf0850c..510993143 100644 --- a/doc/sphinx/whats-new/upgrading-6.0.rst +++ b/doc/sphinx/whats-new/upgrading-6.0.rst @@ -592,6 +592,17 @@ since there's no more reasons to have them diverge: we initially inherited packaging support from downstream package maintainers, and they deserve many thanks for that. +The biggest change that resulted in unifying our systemd setup across +all official packages is that the ``varnish.params`` file available on +Red Hat derivatives is gone. We noticed that using an environment file +to hide the fact that ``varnishd`` is configured via command line +arguments misled some people into thinking that what was proposed in +the file was your only set of configuration options. For example, you +can specify multiple listen addresses using multiple ``-a`` options +but you only get variables for one address and a catch-all variable +``DAEMON_OPTS`` for anything not fitting in the template. In addition +using an environment file pollutes the process's environment. + Another big difference between Red Hat and Debian derivatives was the way we handled VCL reloads via the service manager. We introduced a new ``varnishreload`` script that operates on top of ``varnishadm`` From phk at FreeBSD.org Thu Dec 13 10:13:11 2018 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 13 Dec 2018 10:13:11 +0000 (UTC) Subject: [master] 07ad2fb86 Normalize esi:include -- CNT interaction even more Message-ID: <20181213101311.5D72F63A1E@lists.varnish-cache.org> commit 07ad2fb863b7db12e94449e11d47a1eefb2dd359 Author: Poul-Henning Kamp Date: Wed Dec 12 00:12:40 2018 +0000 Normalize esi:include -- CNT interaction even more diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index 4bc9cd098..fdc3e798d 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -201,7 +201,7 @@ ved_include(struct req *preq, const char *src, const char *host, req->wrk = NULL; THR_SetRequest(preq); - Req_AcctLogCharge(wrk->stats, req); + Req_Cleanup(sp, wrk, req); Req_Release(req); } diff --git a/bin/varnishd/cache/cache_req.c b/bin/varnishd/cache/cache_req.c index d16f550c4..bc1f6152d 100644 --- a/bin/varnishd/cache/cache_req.c +++ b/bin/varnishd/cache/cache_req.c @@ -63,7 +63,11 @@ Req_AcctLogCharge(struct VSC_main_wrk *ds, struct req *req) (uintmax_t)(a->resp_hdrbytes + a->resp_bodybytes)); } - /* Charge to main byte counters (except for ESI subrequests) */ + /* + * Charge to main byte counters, except for ESI subrequests + * which are charged as they pass through the topreq. + * XXX: make this test req->top instead + */ #define ACCT(foo) \ if (req->esi_level == 0) \ ds->s_##foo += a->foo; \ @@ -214,7 +218,6 @@ Req_Cleanup(struct sess *sp, struct worker *wrk, struct req *req) req->restarts = 0; req->top = 0; - AZ(req->esi_level); AZ(req->privs->magic); if (req->vcl != NULL) @@ -239,6 +242,7 @@ Req_Cleanup(struct sess *sp, struct worker *wrk, struct req *req) req->hash_always_miss = 0; req->hash_ignore_busy = 0; + req->esi_level = 0; req->is_hit = 0; if (WS_Overflowed(req->ws)) From phk at FreeBSD.org Thu Dec 13 10:13:11 2018 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 13 Dec 2018 10:13:11 +0000 (UTC) Subject: [master] e259c586e Dump req->topreq Message-ID: <20181213101311.7756A63A21@lists.varnish-cache.org> commit e259c586ef64f38562e49de506f666d68d3a84cc Author: Poul-Henning Kamp Date: Thu Dec 13 07:58:27 2018 +0000 Dump req->topreq diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index c1da769d8..c0ef87130 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -455,6 +455,20 @@ pan_busyobj(struct vsb *vsb, const struct busyobj *bo) /*--------------------------------------------------------------------*/ +static void +pan_top(struct vsb *vsb, const struct reqtop *top) +{ + VSB_printf(vsb, "top = %p {\n", top); + if (PAN_already(vsb, top)) + return; + VSB_indent(vsb, 2); + pan_req(vsb, top->topreq); + VSB_indent(vsb, -2); + VSB_printf(vsb, "},\n"); +} + +/*--------------------------------------------------------------------*/ + static void pan_req(struct vsb *vsb, const struct req *req) { @@ -528,6 +542,9 @@ pan_req(struct vsb *vsb, const struct req *req) pan_privs(vsb, req->privs); + if (req->top != NULL) + pan_top(vsb, req->top); + VSB_indent(vsb, -2); VSB_printf(vsb, "},\n"); } From phk at FreeBSD.org Thu Dec 13 10:13:11 2018 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 13 Dec 2018 10:13:11 +0000 (UTC) Subject: [master] 7ccd8e607 Generally test on req-toppines rather than esi_level Message-ID: <20181213101311.B18A163A26@lists.varnish-cache.org> commit 7ccd8e60721012822f8654a2bf1afc73dbf6c725 Author: Poul-Henning Kamp Date: Thu Dec 13 08:23:00 2018 +0000 Generally test on req-toppines rather than esi_level diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index c202381d6..f6925ea82 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -538,6 +538,8 @@ struct req { struct vrt_privs privs[1]; }; +#define IS_TOPREQ(req) ((req)->top == NULL || (req)->top->topreq == (req)) + /*-------------------------------------------------------------------- * Struct sess is a high memory-load structure because sessions typically * hang around the waiter for relatively long time. diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index fdc3e798d..3169274a3 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -256,7 +256,7 @@ ved_vdp_esi_init(struct req *req, void **priv) *priv = ecx; RFC2616_Weaken_Etag(req->resp); - if (req->esi_level == 0) { + if (IS_TOPREQ(req)) { Req_MakeTop(req); if (req->top == NULL) { VSLb(req->vsl, SLT_Error, diff --git a/bin/varnishd/cache/cache_req.c b/bin/varnishd/cache/cache_req.c index bc1f6152d..d2f3c2d31 100644 --- a/bin/varnishd/cache/cache_req.c +++ b/bin/varnishd/cache/cache_req.c @@ -63,16 +63,11 @@ Req_AcctLogCharge(struct VSC_main_wrk *ds, struct req *req) (uintmax_t)(a->resp_hdrbytes + a->resp_bodybytes)); } - /* - * Charge to main byte counters, except for ESI subrequests - * which are charged as they pass through the topreq. - * XXX: make this test req->top instead - */ -#define ACCT(foo) \ - if (req->esi_level == 0) \ - ds->s_##foo += a->foo; \ - a->foo = 0; + if (IS_TOPREQ(req)) { +#define ACCT(foo) ds->s_##foo += a->foo; #include "tbl/acct_fields_req.h" + } + memset(a, 0, sizeof *a); } /*-------------------------------------------------------------------- @@ -216,7 +211,6 @@ Req_Cleanup(struct sess *sp, struct worker *wrk, struct req *req) req->director_hint = NULL; req->restarts = 0; - req->top = 0; AZ(req->privs->magic); @@ -244,6 +238,7 @@ Req_Cleanup(struct sess *sp, struct worker *wrk, struct req *req) req->hash_ignore_busy = 0; req->esi_level = 0; req->is_hit = 0; + req->top = 0; if (WS_Overflowed(req->ws)) wrk->stats->ws_client_overflow++; diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 7255cd63c..66b1d4fa1 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -182,7 +182,7 @@ cnt_deliver(struct worker *wrk, struct req *req) assert(wrk->handling == VCL_RET_DELIVER); - if (req->esi_level == 0 && + if (IS_TOPREQ(req) && http_IsStatus(req->resp, 200) && req->http->conds && RFC2616_Do_Cond(req)) http_PutResponse(req->resp, "HTTP/1.1", 304, NULL); @@ -917,7 +917,7 @@ cnt_recv(struct worker *wrk, struct req *req) req->req_step = R_STP_LOOKUP; break; case VCL_RET_PIPE: - if (req->esi_level > 0) { + if (!IS_TOPREQ(req)) { VSLb(req->vsl, SLT_VCL_Error, "vcl_recv{} returns pipe for ESI included object." " Doing pass."); diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index a12c5fea2..a141df54d 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -520,7 +520,7 @@ VRT_l_req_esi(VRT_CTX, VCL_BOOL process_esi) * Only allow you to turn of esi in the main request * else everything gets confused */ - if (ctx->req->esi_level == 0) + if (IS_TOPREQ(ctx->req)) ctx->req->disable_esi = !process_esi; } From phk at FreeBSD.org Thu Dec 13 11:20:11 2018 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 13 Dec 2018 11:20:11 +0000 (UTC) Subject: [master] d0d200778 Remove the http->conds microoptimization, it does not save anything any more. Message-ID: <20181213112011.C84C1650FA@lists.varnish-cache.org> commit d0d200778cfffd08e7bc439be073426ab4062bfa Author: Poul-Henning Kamp Date: Thu Dec 13 11:18:53 2018 +0000 Remove the http->conds microoptimization, it does not save anything any more. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index f6925ea82..86db641dc 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -165,7 +165,6 @@ struct http { struct ws *ws; uint16_t status; uint8_t protover; - uint8_t conds; /* If-* headers present */ }; /*--------------------------------------------------------------------*/ diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index 3169274a3..a4aeb584b 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -142,7 +142,6 @@ ved_include(struct req *preq, const char *src, const char *host, HTTP_Setup(req->http, req->ws, req->vsl, SLT_ReqMethod); HTTP_Copy(req->http, preq->http); - req->http->conds = 0; http_SetH(req->http, HTTP_HDR_URL, src); if (host != NULL && *host != '\0') { diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 66b1d4fa1..05d5339f4 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -182,9 +182,7 @@ cnt_deliver(struct worker *wrk, struct req *req) assert(wrk->handling == VCL_RET_DELIVER); - if (IS_TOPREQ(req) && - http_IsStatus(req->resp, 200) && - req->http->conds && RFC2616_Do_Cond(req)) + if (IS_TOPREQ(req) && RFC2616_Do_Cond(req)) http_PutResponse(req->resp, "HTTP/1.1", 304, NULL); req->req_step = R_STP_TRANSMIT; diff --git a/bin/varnishd/cache/cache_rfc2616.c b/bin/varnishd/cache/cache_rfc2616.c index c9341fdd0..bd5ed88c6 100644 --- a/bin/varnishd/cache/cache_rfc2616.c +++ b/bin/varnishd/cache/cache_rfc2616.c @@ -260,6 +260,9 @@ RFC2616_Do_Cond(const struct req *req) const char *p, *e; vtim_real ims, lm; + if (!http_IsStatus(req->resp, 200)) + return (0); + /* * We MUST ignore If-Modified-Since if we have an If-None-Match * header [RFC7232 3.3 p16]. diff --git a/bin/varnishd/http1/cache_http1_proto.c b/bin/varnishd/http1/cache_http1_proto.c index dd81863d3..15090bdcf 100644 --- a/bin/varnishd/http1/cache_http1_proto.c +++ b/bin/varnishd/http1/cache_http1_proto.c @@ -115,7 +115,6 @@ http1_dissect_hdrs(struct http *hp, char *p, struct http_conn *htc, assert(p > htc->rxbuf_b); assert(p <= htc->rxbuf_e); hp->nhd = HTTP_HDR_FIRST; - hp->conds = 0; r = NULL; /* For FlexeLint */ for (; p < htc->rxbuf_e; p = r) { @@ -173,11 +172,6 @@ http1_dissect_hdrs(struct http *hp, char *p, struct http_conn *htc, return (400); } - if ((p[0] == 'i' || p[0] == 'I') && - (p[1] == 'f' || p[1] == 'F') && - p[2] == '-') - hp->conds = 1; - while (q > p && vct_issp(q[-1])) q--; *q = '\0'; diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index 76046d92f..8915e1498 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -535,7 +535,6 @@ h2_do_req(struct worker *wrk, void *priv) CAST_OBJ_NOTNULL(r2, req->transport_priv, H2_REQ_MAGIC); THR_SetRequest(req); - req->http->conds = 1; wrk->stats->client_req++; if (CNT_Request(wrk, req) != REQ_FSM_DISEMBARK) { AZ(req->ws->r); From phk at FreeBSD.org Wed Dec 19 11:24:10 2018 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 19 Dec 2018 11:24:10 +0000 (UTC) Subject: [master] 5949ab3fa NULL terminate list of commands. Message-ID: <20181219112410.B02C196A27@lists.varnish-cache.org> commit 5949ab3fa366d1ea45731f25dbb5d85f34e1d529 Author: Poul-Henning Kamp Date: Wed Dec 19 11:23:11 2018 +0000 NULL terminate list of commands. Submitted by: Frederic Lecaille diff --git a/bin/varnishtest/vtc_haproxy.c b/bin/varnishtest/vtc_haproxy.c index 846b5c8a8..ff9376018 100644 --- a/bin/varnishtest/vtc_haproxy.c +++ b/bin/varnishtest/vtc_haproxy.c @@ -275,6 +275,7 @@ static const struct cmds haproxy_cli_cmds[] = { CMD_HAPROXY_CLI(send) CMD_HAPROXY_CLI(expect) #undef CMD_HAPROXY_CLI + { NULL, NULL } }; /********************************************************************** diff --git a/bin/varnishtest/vtc_syslog.c b/bin/varnishtest/vtc_syslog.c index e415d8c92..419553930 100644 --- a/bin/varnishtest/vtc_syslog.c +++ b/bin/varnishtest/vtc_syslog.c @@ -429,6 +429,7 @@ static const struct cmds syslog_cmds[] = { CMD_SYSLOG(expect) CMD_SYSLOG(recv) #undef CMD_SYSLOG + { NULL, NULL } }; /********************************************************************** From lasse.karstensen at gmail.com Fri Dec 21 14:03:06 2018 From: lasse.karstensen at gmail.com (Lasse Karstensen) Date: Fri, 21 Dec 2018 14:03:06 +0000 (UTC) Subject: [master] f08815219 Ignore generated RST files. Message-ID: <20181221140306.1126B4356@lists.varnish-cache.org> commit f088152194f57a26e8e173e60e4f8cb6a460aae3 Author: Lasse Karstensen Date: Fri Dec 21 15:02:01 2018 +0100 Ignore generated RST files. diff --git a/.gitignore b/.gitignore index c96ca4b91..f6870aa1b 100644 --- a/.gitignore +++ b/.gitignore @@ -97,6 +97,8 @@ cscope.*out /doc/*.html /doc/sphinx/build/ /doc/sphinx/conf.py +/doc/sphinx/reference/vmod_*.generated.rst + # graphviz-generated /doc/graphviz/*.pdf From fgsch at lodoss.net Sun Dec 23 01:27:05 2018 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sun, 23 Dec 2018 01:27:05 +0000 (UTC) Subject: [master] c1f35e2b1 Tidy up Message-ID: <20181223012705.8406C7B5E@lists.varnish-cache.org> commit c1f35e2b1e6efcb6a4fc82e91ba23423e1c6bc66 Author: Federico G. Schwindt Date: Fri Dec 21 16:46:14 2018 +0000 Tidy up diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 9e0f5cb4d..7bec80cb9 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -498,11 +498,10 @@ vbf_stp_fetchbody(struct worker *wrk, struct busyobj *bo) ObjTrimStore(wrk, vfc->oc); return (F_STP_FETCHEND); } + static enum fetch_step vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) { - const char *p; - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(bo->fetch_objcore, OBJCORE_MAGIC); @@ -553,8 +552,8 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) if (!(bo->fetch_objcore->flags & OC_F_HFM) && http_IsStatus(bo->beresp, 200) && ( - http_GetHdr(bo->beresp, H_Last_Modified, &p) || - http_GetHdr(bo->beresp, H_ETag, &p))) + http_GetHdr(bo->beresp, H_Last_Modified, NULL) || + http_GetHdr(bo->beresp, H_ETag, NULL))) ObjSetFlag(bo->wrk, bo->fetch_objcore, OF_IMSCAND, 1); assert(bo->fetch_objcore->boc->refcount >= 1); From dridi.boukelmoune at gmail.com Mon Dec 24 16:26:07 2018 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 24 Dec 2018 16:26:07 +0000 (UTC) Subject: [master] 9f7686969 Polish Message-ID: <20181224162607.32F7E63679@lists.varnish-cache.org> commit 9f768696922519414ae89e4a6ce0bf2806f94f6d Author: Dridi Boukelmoune Date: Mon Dec 24 17:14:31 2018 +0100 Polish diff --git a/bin/varnishd/cache/cache_vrt_priv.c b/bin/varnishd/cache/cache_vrt_priv.c index f1940ea4d..9f7612bc4 100644 --- a/bin/varnishd/cache/cache_vrt_priv.c +++ b/bin/varnishd/cache/cache_vrt_priv.c @@ -209,5 +209,5 @@ VCL_TaskLeave(const struct vcl *vcl, struct vrt_privs *privs) VRBT_FOREACH_SAFE(vp, vrt_priv_tree, &privs->privs, vp1) { VRT_priv_fini(vp->priv); } - INIT_OBJ(privs, 0); + ZERO_OBJ(privs, sizeof *privs); } From dridi.boukelmoune at gmail.com Wed Dec 26 11:01:06 2018 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 26 Dec 2018 11:01:06 +0000 (UTC) Subject: [master] 6972c55b7 Clarify priv_task tear-down Message-ID: <20181226110106.73A06980D9@lists.varnish-cache.org> commit 6972c55b70da9711fcb46c489edcce5727b1c24e Author: Dridi Boukelmoune Date: Wed Dec 26 11:58:30 2018 +0100 Clarify priv_task tear-down Someone should triple-check that it is indeed safe. diff --git a/bin/varnishd/cache/cache_vrt_priv.c b/bin/varnishd/cache/cache_vrt_priv.c index 9f7612bc4..211990cc3 100644 --- a/bin/varnishd/cache/cache_vrt_priv.c +++ b/bin/varnishd/cache/cache_vrt_priv.c @@ -206,8 +206,11 @@ VCL_TaskLeave(const struct vcl *vcl, struct vrt_privs *privs) AN(vcl); CHECK_OBJ_NOTNULL(privs, VRT_PRIVS_MAGIC); - VRBT_FOREACH_SAFE(vp, vrt_priv_tree, &privs->privs, vp1) { + /* NB: We don't bother removing entries as we finish them because it's + * a costly operation. Instead we safely walk the whole tree and clear + * the head at the very end. + */ + VRBT_FOREACH_SAFE(vp, vrt_priv_tree, &privs->privs, vp1) VRT_priv_fini(vp->priv); - } ZERO_OBJ(privs, sizeof *privs); } From dridi.boukelmoune at gmail.com Thu Dec 27 07:33:05 2018 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 27 Dec 2018 07:33:05 +0000 (UTC) Subject: [master] fbc143344 Move the embark step outside of CNT_Request Message-ID: <20181227073306.10C9493D6@lists.varnish-cache.org> commit fbc143344f3de364231b298281c7c5fbb0a2f291 Author: Dridi Boukelmoune Date: Thu Dec 27 08:31:11 2018 +0100 Move the embark step outside of CNT_Request And make the caller responsible for formally entering the task. diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index a4aeb584b..5642f31e1 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -178,10 +178,12 @@ ved_include(struct req *preq, const char *src, const char *host, req->transport = &VED_transport; req->transport_priv = ecx; + CNT_Embark(wrk, req); + VCL_TaskEnter(req->vcl, req->privs); + while (1) { - req->wrk = wrk; ecx->woken = 0; - s = CNT_Request(wrk, req); + s = CNT_Request(req); if (s == REQ_FSM_DONE) break; DSL(DBG_WAITINGLIST, req->vsl->wid, @@ -193,6 +195,7 @@ ved_include(struct req *preq, const char *src, const char *host, &ecx->preq->wrk->cond, &sp->mtx, 0); Lck_Unlock(&sp->mtx); AZ(req->wrk); + CNT_Embark(wrk, req); } VCL_Rel(&req->vcl); diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 05d5339f4..f5e6b16f7 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -1015,13 +1015,34 @@ cnt_diag(struct req *req, const char *state) VSL_Flush(req->vsl, 0); } +void +CNT_Embark(struct worker *wrk, struct req *req) +{ + + CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); + CHECK_OBJ_NOTNULL(req, REQ_MAGIC); + + /* wrk can have changed for restarts */ + req->vfc->wrk = req->wrk = wrk; + wrk->vsl = req->vsl; + if (req->req_step == R_STP_TRANSPORT && req->vcl == NULL) { + VCL_Refresh(&wrk->vcl); + req->vcl = wrk->vcl; + wrk->vcl = NULL; + } + + AN(req->vcl); +} + enum req_fsm_nxt -CNT_Request(struct worker *wrk, struct req *req) +CNT_Request(struct req *req) { + struct worker *wrk; enum req_fsm_nxt nxt; - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(req, REQ_MAGIC); + wrk = req->wrk; + CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(req->transport, TRANSPORT_MAGIC); AN(req->transport->deliver); @@ -1035,19 +1056,9 @@ CNT_Request(struct worker *wrk, struct req *req) req->req_step == R_STP_TRANSPORT); AN(req->vsl->wid & VSL_CLIENTMARKER); - - /* wrk can have changed for restarts */ - req->vfc->wrk = req->wrk = wrk; - wrk->vsl = req->vsl; - if (req->req_step == R_STP_TRANSPORT && req->vcl == NULL) { - AZ(req->vcl); - VCL_Refresh(&wrk->vcl); - req->vcl = wrk->vcl; - wrk->vcl = NULL; - } AN(req->vcl); - if (req->req_step != R_STP_LOOKUP) - VCL_TaskEnter(req->vcl, req->privs); + CHECK_OBJ(req->privs, VRT_PRIVS_MAGIC); + for (nxt = REQ_FSM_MORE; nxt == REQ_FSM_MORE; ) { /* * This is a good place to be paranoid about the various diff --git a/bin/varnishd/cache/cache_varnishd.h b/bin/varnishd/cache/cache_varnishd.h index 0c29891e6..b8c53a6df 100644 --- a/bin/varnishd/cache/cache_varnishd.h +++ b/bin/varnishd/cache/cache_varnishd.h @@ -330,7 +330,8 @@ enum req_fsm_nxt { REQ_FSM_DISEMBARK, }; -enum req_fsm_nxt CNT_Request(struct worker *, struct req *); +void CNT_Embark(struct worker *, struct req *); +enum req_fsm_nxt CNT_Request(struct req *); /* cache_session.c */ void SES_NewPool(struct pool *, unsigned pool_no); diff --git a/bin/varnishd/http1/cache_http1_fsm.c b/bin/varnishd/http1/cache_http1_fsm.c index 3ef60429d..deee26649 100644 --- a/bin/varnishd/http1/cache_http1_fsm.c +++ b/bin/varnishd/http1/cache_http1_fsm.c @@ -442,7 +442,10 @@ HTTP1_Session(struct worker *wrk, struct req *req) req->task.func = http1_req; req->task.priv = req; wrk->stats->client_req++; - if (CNT_Request(wrk, req) == REQ_FSM_DISEMBARK) + CNT_Embark(wrk, req); + if (req->req_step == R_STP_TRANSPORT) + VCL_TaskEnter(req->vcl, req->privs); + if (CNT_Request(req) == REQ_FSM_DISEMBARK) return; req->task.func = NULL; req->task.priv = NULL; diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index 8915e1498..d71b6949a 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -534,9 +534,12 @@ h2_do_req(struct worker *wrk, void *priv) CAST_OBJ_NOTNULL(req, priv, REQ_MAGIC); CAST_OBJ_NOTNULL(r2, req->transport_priv, H2_REQ_MAGIC); THR_SetRequest(req); + CNT_Embark(wrk, req); + if (req->req_step == R_STP_TRANSPORT) + VCL_TaskEnter(req->vcl, req->privs); wrk->stats->client_req++; - if (CNT_Request(wrk, req) != REQ_FSM_DISEMBARK) { + if (CNT_Request(req) != REQ_FSM_DISEMBARK) { AZ(req->ws->r); h2 = r2->h2sess; CHECK_OBJ_NOTNULL(h2, H2_SESS_MAGIC); From fgsch at lodoss.net Thu Dec 27 17:13:04 2018 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Thu, 27 Dec 2018 17:13:04 +0000 (UTC) Subject: [master] f1d7ca28b Permit subsequent conditional requests on 304 Message-ID: <20181227171304.F03F794249@lists.varnish-cache.org> commit f1d7ca28be5ffba201cfe357b39261e7d25f5f18 Author: Federico G. Schwindt Date: Thu Dec 27 17:10:20 2018 +0000 Permit subsequent conditional requests on 304 Fixes #2871. diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 7bec80cb9..02ad2cc56 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -648,7 +648,8 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo) OA_ESIDATA)); AZ(ObjCopyAttr(bo->wrk, bo->fetch_objcore, bo->stale_oc, OA_FLAGS)); - ObjSetFlag(bo->wrk, bo->fetch_objcore, OF_IMSCAND, 0); + if (bo->fetch_objcore->flags & OC_F_HFM) + ObjSetFlag(bo->wrk, bo->fetch_objcore, OF_IMSCAND, 0); AZ(ObjCopyAttr(bo->wrk, bo->fetch_objcore, bo->stale_oc, OA_GZIPBITS)); if (bo->do_stream) { diff --git a/bin/varnishtest/tests/b00039.vtc b/bin/varnishtest/tests/b00039.vtc index b9d40bfeb..ba4285369 100644 --- a/bin/varnishtest/tests/b00039.vtc +++ b/bin/varnishtest/tests/b00039.vtc @@ -6,6 +6,9 @@ server s1 { rxreq expect req.http.if-modified-since == "Wed, 11 Sep 2013 13:36:55 GMT" txresp -status 304 + rxreq + expect req.http.if-modified-since == "Wed, 11 Sep 2013 13:36:55 GMT" + txresp -status 304 } -start varnish v1 -vcl+backend { @@ -44,3 +47,13 @@ client c1 { expect resp.body == "Geoff Rules" expect resp.http.was-304 == "true" } -run + +delay 1 + +client c1 { + txreq + rxresp + expect resp.status == 200 + expect resp.body == "Geoff Rules" + expect resp.http.was-304 == "true" +} -run From fgsch at lodoss.net Sun Dec 30 18:39:05 2018 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sun, 30 Dec 2018 18:39:05 +0000 (UTC) Subject: [master] 19e37f8e1 Rework backend probe code a bit Message-ID: <20181230183905.D2D4A9C7D1@lists.varnish-cache.org> commit 19e37f8e1d8a9220c1cc1e0dc19d6346a622a907 Author: Federico G. Schwindt Date: Sun Dec 30 18:34:40 2018 +0000 Rework backend probe code a bit If we timed out during polling display the correct error. In addition, treat all polling errors as receive errors. Fixes #2866. diff --git a/bin/varnishd/cache/cache_backend_probe.c b/bin/varnishd/cache/cache_backend_probe.c index 1537c9de7..3f478db38 100644 --- a/bin/varnishd/cache/cache_backend_probe.c +++ b/bin/varnishd/cache/cache_backend_probe.c @@ -341,6 +341,7 @@ vbp_poke(struct vbp_target *vt) /* Send the request */ if (vbp_write(vt, &s, vt->req, vt->req_len) != 0) return; + vt->good_xmit |= 1; pfd->fd = s; @@ -349,21 +350,21 @@ vbp_poke(struct vbp_target *vt) pfd->events = POLLIN; pfd->revents = 0; tmo = (int)round((t_end - t_now) * 1e3); - if (tmo > 0) - i = poll(pfd, 1, tmo); - if (i == 0) { - vt->err_recv |= 1; - bprintf(vt->resp_buf, "Poll error %d (%s)", - errno, vstrerror(errno)); - VTCP_close(&s); - return; - } if (tmo <= 0) { bprintf(vt->resp_buf, - "Poll (read) timeout %.3fs exceeded by %.3fs", - vt->timeout, t_now - t_end); - VTCP_close(&s); - return; + "Poll timeout %.3fs exceeded by %.3fs", + vt->timeout, t_now - t_end); + i = -1; + break; + } + i = poll(pfd, 1, tmo); + if (i <= 0) { + if (!i) + errno = ETIMEDOUT; + bprintf(vt->resp_buf, "Poll error %d (%s)", + errno, vstrerror(errno)); + i = -1; + break; } if (rlen < sizeof vt->resp_buf) i = read(s, vt->resp_buf + rlen,