From phk at FreeBSD.org Mon Oct 4 08:11:07 2021 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 4 Oct 2021 08:11:07 +0000 (UTC) Subject: [master] 3aae23376 Whitespace OCD Message-ID: <20211004081107.43A8A4F24@lists.varnish-cache.org> commit 3aae23376d283c4a387c8ee32578da539c9ad462 Author: Poul-Henning Kamp Date: Mon Oct 4 07:56:27 2021 +0000 Whitespace OCD diff --git a/bin/varnishd/fuzzers/esi_parse_fuzzer.c b/bin/varnishd/fuzzers/esi_parse_fuzzer.c index fb1e5ecb5..5cdb2f449 100644 --- a/bin/varnishd/fuzzers/esi_parse_fuzzer.c +++ b/bin/varnishd/fuzzers/esi_parse_fuzzer.c @@ -50,7 +50,7 @@ volatile struct params *cache_param; int PAN__DumpStruct(struct vsb *vsb, int block, int track, const void *ptr, - const char *smagic, unsigned magic, const char *fmt, ...) + const char *smagic, unsigned magic, const char *fmt, ...) { (void)vsb; (void)block; From phk at FreeBSD.org Mon Oct 4 08:11:07 2021 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 4 Oct 2021 08:11:07 +0000 (UTC) Subject: [master] 99f8560e4 Minor polish Message-ID: <20211004081107.57B1B4F28@lists.varnish-cache.org> commit 99f8560e458f0dc793490018c02c5010de60920c Author: Poul-Henning Kamp Date: Mon Oct 4 08:10:38 2021 +0000 Minor polish diff --git a/bin/varnishd/cache/cache_acceptor.c b/bin/varnishd/cache/cache_acceptor.c index d868e0cac..20cf8a248 100644 --- a/bin/varnishd/cache/cache_acceptor.c +++ b/bin/varnishd/cache/cache_acceptor.c @@ -709,21 +709,28 @@ VCA_Shutdown(void) static VTAILQ_HEAD(,transport) transports = VTAILQ_HEAD_INITIALIZER(transports); +static uint16_t next_xport; + +static void +XPORT_Register(struct transport *xp) +{ + + CHECK_OBJ_NOTNULL(xp, TRANSPORT_MAGIC); + AZ(xp->number); + + xp->number = ++next_xport; + VTAILQ_INSERT_TAIL(&transports, xp, list); +} + void XPORT_Init(void) { - uint16_t n; - struct transport *xp; ASSERT_MGT(); - VTAILQ_INSERT_TAIL(&transports, &PROXY_transport, list); - VTAILQ_INSERT_TAIL(&transports, &HTTP1_transport, list); - VTAILQ_INSERT_TAIL(&transports, &H2_transport, list); - - n = 0; - VTAILQ_FOREACH(xp, &transports, list) - xp->number = ++n; + XPORT_Register(&PROXY_transport); + XPORT_Register(&HTTP1_transport); + XPORT_Register(&H2_transport); } const struct transport * From martin at varnish-software.com Mon Oct 4 13:18:07 2021 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Mon, 4 Oct 2021 13:18:07 +0000 (UTC) Subject: [master] b2d840cf1 Build VSC generated sources in lib/libvsc Message-ID: <20211004131807.76C036E8D0@lists.varnish-cache.org> commit b2d840cf1b2b93b13d49172d95b5058dad981747 Author: Martin Blix Grydeland Date: Thu Sep 16 15:09:24 2021 +0200 Build VSC generated sources in lib/libvsc This is to resolve the chicken and egg problem of the VSC headers being generated only once bin/varnishd is built, while they are used in several VMODs and libraries. This moves the generation of the VSC .c and .h header files to a directory in lib that can be built earlier than its dependencies. Also Don't AC_SUBST the vsc files. The complete list of vsc files is known and listed in the .am file when automake is run, so there is no need to have configure.ac help with making lists. diff --git a/bin/varnishd/Makefile.am b/bin/varnishd/Makefile.am index af04e2995..0e564a9bc 100644 --- a/bin/varnishd/Makefile.am +++ b/bin/varnishd/Makefile.am @@ -4,7 +4,8 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/include \ -I$(top_srcdir)/lib/libvgz \ -I$(top_builddir)/bin/varnishd \ - -I$(top_builddir)/include + -I$(top_builddir)/include \ + -I$(top_builddir)/lib/libvsc sbin_PROGRAMS = varnishd @@ -178,6 +179,7 @@ varnishd_LDFLAGS = -export-dynamic varnishd_LDADD = \ $(top_builddir)/lib/libvcc/libvcc.la \ $(top_builddir)/lib/libvarnish/libvarnish.la \ + $(top_builddir)/lib/libvsc/libvsc.la \ $(top_builddir)/lib/libvgz/libvgz.la \ @JEMALLOC_LDADD@ \ ${DL_LIBS} ${PTHREAD_LIBS} ${NET_LIBS} ${RT_LIBS} ${LIBM} @@ -250,28 +252,3 @@ DISTCLEANFILES = builtin_vcl.c BUILT_SOURCES = vhp_hufdec.h DISTCLEANFILES += vhp_hufdec.h - -####################################################################### - -.vsc.c: - $(PYTHON) $(top_srcdir)/lib/libvcc/vsctool.py -ch $< - -VSC_SRC = \ - VSC_lck.vsc \ - VSC_main.vsc \ - VSC_mempool.vsc \ - VSC_mgt.vsc \ - VSC_sma.vsc \ - VSC_smf.vsc \ - VSC_smu.vsc \ - VSC_vbe.vsc - -VSC_GEN_C = @VSC_GEN_C@ -VSC_GEN_H = @VSC_GEN_H@ - -$(VSC_GEN_C): $(top_srcdir)/lib/libvcc/vsctool.py - -BUILT_SOURCES += $(VSC_GEN_C) -CLEANFILES = $(VSC_GEN_C) $(VSC_GEN_H) - -varnishd_SOURCES += $(VSC_SRC) diff --git a/configure.ac b/configure.ac index ca1a49c29..e5df08ab3 100644 --- a/configure.ac +++ b/configure.ac @@ -824,14 +824,6 @@ VMOD_TESTS="$(cd $srcdir/vmod && echo tests/*.vtc)" AC_SUBST(VMOD_TESTS) AM_SUBST_NOTMAKE(VMOD_TESTS) -VSC_SRC="$(cd $srcdir/bin/varnishd && echo *.vsc)" -VSC_GEN_C="$(echo $VSC_SRC | sed 's:\.vsc:.c:g')" -VSC_GEN_H="$(echo $VSC_SRC | sed 's:\.vsc:.h:g')" -# automake does not allow to AC_SUBST _SOURCES files (for a good -# reason), so we automate the cleanup at least -AC_SUBST(VSC_GEN_C) -AC_SUBST(VSC_GEN_H) - # Make sure this include dir exists AC_CONFIG_COMMANDS([mkdir], [$MKDIR_P doc/sphinx/include]) @@ -854,6 +846,7 @@ AC_CONFIG_FILES([ etc/Makefile include/Makefile lib/Makefile + lib/libvsc/Makefile lib/libvarnish/Makefile lib/libvarnishapi/Makefile lib/libvcc/Makefile diff --git a/doc/sphinx/Makefile.am b/doc/sphinx/Makefile.am index cb4e42881..45ec33345 100644 --- a/doc/sphinx/Makefile.am +++ b/doc/sphinx/Makefile.am @@ -86,22 +86,21 @@ include/params.rst: $(top_builddir)/bin/varnishd/varnishd BUILT_SOURCES += include/params.rst COUNTERS = \ - $(top_srcdir)/bin/varnishd/VSC_main.vsc \ - $(top_srcdir)/bin/varnishd/VSC_mgt.vsc \ - $(top_srcdir)/bin/varnishd/VSC_mempool.vsc \ - $(top_srcdir)/bin/varnishd/VSC_sma.vsc \ - $(top_srcdir)/bin/varnishd/VSC_smu.vsc \ - $(top_srcdir)/bin/varnishd/VSC_smf.vsc \ - $(top_srcdir)/bin/varnishd/VSC_vbe.vsc \ - $(top_srcdir)/bin/varnishd/VSC_lck.vsc - -include/counters.rst: $(top_srcdir)/lib/libvcc/vsctool.py $(COUNTERS) + $(top_srcdir)/lib/libvsc/VSC_main.vsc \ + $(top_srcdir)/lib/libvsc/VSC_mgt.vsc \ + $(top_srcdir)/lib/libvsc/VSC_mempool.vsc \ + $(top_srcdir)/lib/libvsc/VSC_sma.vsc \ + $(top_srcdir)/lib/libvsc/VSC_smu.vsc \ + $(top_srcdir)/lib/libvsc/VSC_smf.vsc \ + $(top_srcdir)/lib/libvsc/VSC_vbe.vsc \ + $(top_srcdir)/lib/libvsc/VSC_lck.vsc + +include/counters.rst: $(top_srcdir)/lib/libvsc/vsctool.py $(COUNTERS) echo -n '' > ${@}_ for i in $(COUNTERS); do \ - $(PYTHON) $(top_srcdir)/lib/libvcc/vsctool.py -r $$i >> ${@}_ ; \ + $(PYTHON) $(top_srcdir)/lib/libvsc/vsctool.py -r $$i >> ${@}_ ; \ done mv -f ${@}_ ${@} - BUILT_SOURCES += include/counters.rst include/varnishncsa_options.rst: $(top_builddir)/bin/varnishncsa/varnishncsa diff --git a/lib/Makefile.am b/lib/Makefile.am index 0f6873c50..951bdf36b 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -1,6 +1,7 @@ # SUBDIRS = \ + libvsc \ libvarnish \ libvarnishapi \ libvcc \ diff --git a/lib/libvcc/Makefile.am b/lib/libvcc/Makefile.am index dc6037f2b..8731890da 100644 --- a/lib/libvcc/Makefile.am +++ b/lib/libvcc/Makefile.am @@ -36,8 +36,7 @@ dist_noinst_SCRIPTS = \ generate.py dist_pkgdata_SCRIPTS = \ - vmodtool.py \ - vsctool.py + vmodtool.py ## keep in sync with include/Makefile.am vcc_obj.c: \ diff --git a/lib/libvsc/Makefile.am b/lib/libvsc/Makefile.am new file mode 100644 index 000000000..842515148 --- /dev/null +++ b/lib/libvsc/Makefile.am @@ -0,0 +1,32 @@ +# + +AM_CPPFLAGS = \ + -I$(top_srcdir)/include \ + -I$(top_builddir)/include + +VSC_SRC = \ + VSC_lck.vsc \ + VSC_main.vsc \ + VSC_mempool.vsc \ + VSC_mgt.vsc \ + VSC_sma.vsc \ + VSC_smf.vsc \ + VSC_smu.vsc \ + VSC_vbe.vsc + +VSC_GEN_C = $(VSC_SRC:.vsc=.c) +VSC_GEN_H = $(VSC_SRC:.vsc=.h) + +$(VSC_GEN_C): vsctool.py + +.vsc.c: + $(PYTHON) $(srcdir)/vsctool.py -ch $< + +noinst_LTLIBRARIES = libvsc.la +libvsc_la_SOURCES = $(VSC_SRC) + +dist_pkgdata_SCRIPTS = \ + vsctool.py + +BUILT_SOURCES = $(VSC_GEN_C) +CLEANFILES = $(VSC_GEN_C) $(VSC_GEN_H) diff --git a/bin/varnishd/VSC_lck.vsc b/lib/libvsc/VSC_lck.vsc similarity index 100% rename from bin/varnishd/VSC_lck.vsc rename to lib/libvsc/VSC_lck.vsc diff --git a/bin/varnishd/VSC_main.vsc b/lib/libvsc/VSC_main.vsc similarity index 100% rename from bin/varnishd/VSC_main.vsc rename to lib/libvsc/VSC_main.vsc diff --git a/bin/varnishd/VSC_mempool.vsc b/lib/libvsc/VSC_mempool.vsc similarity index 100% rename from bin/varnishd/VSC_mempool.vsc rename to lib/libvsc/VSC_mempool.vsc diff --git a/bin/varnishd/VSC_mgt.vsc b/lib/libvsc/VSC_mgt.vsc similarity index 100% rename from bin/varnishd/VSC_mgt.vsc rename to lib/libvsc/VSC_mgt.vsc diff --git a/bin/varnishd/VSC_sma.vsc b/lib/libvsc/VSC_sma.vsc similarity index 100% rename from bin/varnishd/VSC_sma.vsc rename to lib/libvsc/VSC_sma.vsc diff --git a/bin/varnishd/VSC_smf.vsc b/lib/libvsc/VSC_smf.vsc similarity index 100% rename from bin/varnishd/VSC_smf.vsc rename to lib/libvsc/VSC_smf.vsc diff --git a/bin/varnishd/VSC_smu.vsc b/lib/libvsc/VSC_smu.vsc similarity index 100% rename from bin/varnishd/VSC_smu.vsc rename to lib/libvsc/VSC_smu.vsc diff --git a/bin/varnishd/VSC_vbe.vsc b/lib/libvsc/VSC_vbe.vsc similarity index 100% rename from bin/varnishd/VSC_vbe.vsc rename to lib/libvsc/VSC_vbe.vsc diff --git a/lib/libvcc/vsctool.py b/lib/libvsc/vsctool.py similarity index 99% rename from lib/libvcc/vsctool.py rename to lib/libvsc/vsctool.py index 9df1dc40d..c9254b090 100755 --- a/lib/libvcc/vsctool.py +++ b/lib/libvsc/vsctool.py @@ -66,7 +66,7 @@ def genhdr(fo, name): fo.write(' * NB: This file is machine generated, DO NOT EDIT!\n') fo.write(' *\n') fo.write(' * Edit ' + name + - '.vsc and run lib/libvcc/vsctool.py instead.\n') + '.vsc and run lib/libvsc/vsctool.py instead.\n') fo.write(' */\n') fo.write('\n') diff --git a/vmod/Makefile.am b/vmod/Makefile.am index 957e069c4..29ffcf6bd 100644 --- a/vmod/Makefile.am +++ b/vmod/Makefile.am @@ -34,10 +34,10 @@ include $(srcdir)/automake_boilerplate_vtc.am # .vsc.c: - $(PYTHON) $(top_srcdir)/lib/libvcc/vsctool.py -c $< + $(PYTHON) $(top_srcdir)/lib/libvsc/vsctool.py -c $< .vsc.h: - $(PYTHON) $(top_srcdir)/lib/libvcc/vsctool.py -h $< + $(PYTHON) $(top_srcdir)/lib/libvsc/vsctool.py -h $< EXTRA_DIST += VSC_debug.vsc nodist_libvmod_debug_la_SOURCES += \ From martin at varnish-software.com Mon Oct 4 13:18:07 2021 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Mon, 4 Oct 2021 13:18:07 +0000 (UTC) Subject: [master] 43c8e8dd4 Declare anonymous structs in VSC header files Message-ID: <20211004131807.8A9E06E8D3@lists.varnish-cache.org> commit 43c8e8dd443ebd3cf9c556c873a91f57fe864736 Author: Martin Blix Grydeland Date: Fri Sep 17 17:05:43 2021 +0200 Declare anonymous structs in VSC header files Declare anonymous vsmw_cluster and vsc_seg structs in VSC header files. This is to silence errors when the header file is used in other contexts that don't know about these structs. diff --git a/lib/libvsc/vsctool.py b/lib/libvsc/vsctool.py index c9254b090..db2a396dc 100755 --- a/lib/libvsc/vsctool.py +++ b/lib/libvsc/vsctool.py @@ -195,6 +195,10 @@ class CounterSet(object): fo.write("#define VSC_" + self.name + "_size PRNDUP(sizeof(" + self.struct + "))\n\n") + fo.write("struct vsmw_cluster;\n"); + fo.write("struct vsc_seg;\n"); + fo.write("\n"); + fo.write(self.struct + " *VSC_" + self.name + "_New") fo.write("(struct vsmw_cluster *,\n") fo.write(" struct vsc_seg **, const char *fmt, ...);\n") From martin at varnish-software.com Mon Oct 4 13:18:07 2021 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Mon, 4 Oct 2021 13:18:07 +0000 (UTC) Subject: [master] 7dca91d50 Update .gitignore with new path to VSC_*.[ch] generated files Message-ID: <20211004131807.A5B886E8D9@lists.varnish-cache.org> commit 7dca91d504a24619126dd0a71abb42bcdba51e5f Author: Martin Blix Grydeland Date: Mon Sep 27 11:37:02 2021 +0200 Update .gitignore with new path to VSC_*.[ch] generated files diff --git a/.gitignore b/.gitignore index 7c5b4eb39..7432b1b94 100644 --- a/.gitignore +++ b/.gitignore @@ -68,8 +68,8 @@ cscope.*out /lib/libvarnishapi/vxp_tokens.h # Stats -/bin/varnishd/VSC_*.c -/bin/varnishd/VSC_*.h +/lib/libvsc/VSC_*.c +/lib/libvsc/VSC_*.h # Misc. generated files for included vmods. /vmod/VSC_*.c From nils.goroll at uplex.de Mon Oct 4 16:12:06 2021 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 4 Oct 2021 16:12:06 +0000 (UTC) Subject: [master] 64aa92750 sync flexelent with b2d840cf1b2b93b13d49172d95b5058dad981747 Message-ID: <20211004161206.6EF589793C@lists.varnish-cache.org> commit 64aa927504c34d9f1da8cc1593eedf934f823df8 Author: Nils Goroll Date: Mon Oct 4 18:10:50 2021 +0200 sync flexelent with b2d840cf1b2b93b13d49172d95b5058dad981747 diff --git a/bin/varnishd/flint.sh b/bin/varnishd/flint.sh index 24e329752..dde8ac8de 100644 --- a/bin/varnishd/flint.sh +++ b/bin/varnishd/flint.sh @@ -6,6 +6,7 @@ FLOPS=' -I../../lib/libvgz + -I../../lib/libvsc -DNOT_IN_A_VMOD -DVARNISH_STATE_DIR="foo" -DVARNISH_VMOD_DIR="foo" From nils.goroll at uplex.de Mon Oct 4 16:31:06 2021 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 4 Oct 2021 16:31:06 +0000 (UTC) Subject: [master] 4fba40baf flexelinting Message-ID: <20211004163106.985129B420@lists.varnish-cache.org> commit 4fba40baff97cdce324fc8be9ab53bdfec568172 Author: Nils Goroll Date: Mon Oct 4 18:24:25 2021 +0200 flexelinting Info 776 (Possible truncation of addition): I found no better way than using an additional size_t argument. This triggered a subsequent warning about an out-of-bounds access, which could be silenced with additional assertions on nac to be large anough such that av[ac] was not out of bounds. Warning 429: Custodial pointer 'av' (line 60) has not been freed or returned: In other cases, the argument vector comes from VAV_Parse() which flexelint apparently can't follow along, yet memory for a VAV is also allocated and never freed (see also bottom of STV_Config()). In this case I found no better way than to silence flexelint. diff --git a/bin/varnishd/storage/storage_debug.c b/bin/varnishd/storage/storage_debug.c index ad069ef5f..9086ebd0f 100644 --- a/bin/varnishd/storage/storage_debug.c +++ b/bin/varnishd/storage/storage_debug.c @@ -57,7 +57,8 @@ smd_init(struct stevedore *parent, int aac, char * const *aav) struct obj_methods *methods; const char *ident; int i, ac = 0; - char **av; + size_t nac; + char **av; //lint -e429 ident = parent->ident; memcpy(parent, &sma_stevedore, sizeof *parent); @@ -69,7 +70,10 @@ smd_init(struct stevedore *parent, int aac, char * const *aav) memcpy(methods, &SML_methods, sizeof *methods); parent->methods = methods; - av = calloc(aac + 1, sizeof *av); + assert(aac >= 0); + nac = aac; + nac++; + av = calloc(nac, sizeof *av); AN(av); for (i = 0; i < aac; i++) { if (aav[i] != NULL && ! strcmp(aav[i], "lessspace")) { @@ -79,6 +83,8 @@ smd_init(struct stevedore *parent, int aac, char * const *aav) REPLACE(av[ac], aav[i]); ac++; } + assert(ac >= 0); + assert(ac < (int)nac); AZ(av[ac]); sma_stevedore.init(parent, ac, av); From phk at FreeBSD.org Tue Oct 5 08:06:07 2021 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 5 Oct 2021 08:06:07 +0000 (UTC) Subject: [master] d6f11a543 Req_New() needs no wrk argument. Message-ID: <20211005080607.C3AFB91C96@lists.varnish-cache.org> commit d6f11a543df1ccd09cfb0b3e3ccfcf8ef75d73fd Author: Poul-Henning Kamp Date: Tue Oct 5 08:04:38 2021 +0000 Req_New() needs no wrk argument. diff --git a/bin/varnishd/cache/cache_acceptor.c b/bin/varnishd/cache/cache_acceptor.c index 20cf8a248..e9c174c0a 100644 --- a/bin/varnishd/cache/cache_acceptor.c +++ b/bin/varnishd/cache/cache_acceptor.c @@ -399,7 +399,7 @@ vca_make_session(struct worker *wrk, void *arg) } vca_tcp_opt_set(sp->fd, wa->acceptlsock->uds, 0); - req = Req_New(wrk, sp); + req = Req_New(sp); CHECK_OBJ_NOTNULL(req, REQ_MAGIC); req->htc->rfd = &sp->fd; diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index 7518b215b..483e3c0b6 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -129,7 +129,7 @@ ved_include(struct req *preq, const char *src, const char *host, return; } - req = Req_New(wrk, sp); + req = Req_New(sp); AN(req); THR_SetRequest(req); AZ(req->vsl->wid); diff --git a/bin/varnishd/cache/cache_req.c b/bin/varnishd/cache/cache_req.c index 5b3fe1964..a3e0b150a 100644 --- a/bin/varnishd/cache/cache_req.c +++ b/bin/varnishd/cache/cache_req.c @@ -104,7 +104,7 @@ Req_LogHit(struct worker *wrk, struct req *req, struct objcore *oc, */ struct req * -Req_New(const struct worker *wrk, struct sess *sp) +Req_New(struct sess *sp) { struct pool *pp; struct req *req; @@ -112,7 +112,6 @@ Req_New(const struct worker *wrk, struct sess *sp) unsigned sz, hl; char *p, *e; - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); pp = sp->pool; CHECK_OBJ_NOTNULL(pp, POOL_MAGIC); diff --git a/bin/varnishd/cache/cache_varnishd.h b/bin/varnishd/cache/cache_varnishd.h index fda1e4dba..57294faa9 100644 --- a/bin/varnishd/cache/cache_varnishd.h +++ b/bin/varnishd/cache/cache_varnishd.h @@ -400,7 +400,7 @@ void pan_pool(struct vsb *); int VRG_CheckBo(struct busyobj *); /* cache_req.c */ -struct req *Req_New(const struct worker *, struct sess *); +struct req *Req_New(struct sess *); void Req_Release(struct req *); void Req_Rollback(VRT_CTX); void Req_Cleanup(struct sess *sp, struct worker *wrk, struct req *req); diff --git a/bin/varnishd/http1/cache_http1_fsm.c b/bin/varnishd/http1/cache_http1_fsm.c index da8c5fea6..ccd9ee340 100644 --- a/bin/varnishd/http1/cache_http1_fsm.c +++ b/bin/varnishd/http1/cache_http1_fsm.c @@ -141,7 +141,7 @@ http1_unwait(struct worker *wrk, void *arg) CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CAST_OBJ_NOTNULL(sp, arg, SESS_MAGIC); WS_Release(sp->ws, 0); - req = Req_New(wrk, sp); + req = Req_New(sp); CHECK_OBJ_NOTNULL(req, REQ_MAGIC); req->htc->rfd = &sp->fd; HTC_RxInit(req->htc, req->ws); diff --git a/bin/varnishd/http2/cache_http2.h b/bin/varnishd/http2/cache_http2.h index a075f6305..09c88187a 100644 --- a/bin/varnishd/http2/cache_http2.h +++ b/bin/varnishd/http2/cache_http2.h @@ -243,8 +243,7 @@ void H2_Send(struct worker *, struct h2_req *, h2_frame type, uint8_t flags, uint32_t len, const void *, uint64_t *acct); /* cache_http2_proto.c */ -struct h2_req * h2_new_req(const struct worker *, struct h2_sess *, - unsigned stream, struct req *); +struct h2_req * h2_new_req(struct h2_sess *, unsigned stream, struct req *); int h2_stream_tmo(struct h2_sess *, const struct h2_req *, vtim_real); void h2_del_req(struct worker *, struct h2_req *); void h2_kill_req(struct worker *, struct h2_sess *, struct h2_req *, h2_error); diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index 41f18d828..a9ce140bc 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -138,14 +138,13 @@ h2_connectionerror(uint32_t u) /**********************************************************************/ struct h2_req * -h2_new_req(const struct worker *wrk, struct h2_sess *h2, - unsigned stream, struct req *req) +h2_new_req(struct h2_sess *h2, unsigned stream, struct req *req) { struct h2_req *r2; ASSERT_RXTHR(h2); if (req == NULL) - req = Req_New(wrk, h2->sess); + req = Req_New(h2->sess); CHECK_OBJ_NOTNULL(req, REQ_MAGIC); r2 = WS_Alloc(req->ws, sizeof *r2); @@ -661,7 +660,7 @@ h2_rx_headers(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) return (H2SE_REFUSED_STREAM); // rfc7540,l,1200,1205 } h2->highest_stream = h2->rxf_stream; - r2 = h2_new_req(wrk, h2, h2->rxf_stream, NULL); + r2 = h2_new_req(h2, h2->rxf_stream, NULL); } CHECK_OBJ_NOTNULL(r2, H2_REQ_MAGIC); diff --git a/bin/varnishd/http2/cache_http2_session.c b/bin/varnishd/http2/cache_http2_session.c index f8f7ae755..5d4e3ecd6 100644 --- a/bin/varnishd/http2/cache_http2_session.c +++ b/bin/varnishd/http2/cache_http2_session.c @@ -96,7 +96,7 @@ h2_local_settings(struct h2_settings *h2s) */ static struct h2_sess * -h2_init_sess(const struct worker *wrk, struct sess *sp, +h2_init_sess(struct sess *sp, struct h2_sess *h2s, struct req *srq, struct h2h_decode *decode) { uintptr_t *up; @@ -108,7 +108,7 @@ h2_init_sess(const struct worker *wrk, struct sess *sp, assert(*up == 0); if (srq == NULL) - srq = Req_New(wrk, sp); + srq = Req_New(sp); AN(srq); h2 = h2s; AN(h2); @@ -278,7 +278,7 @@ h2_ou_session(struct worker *wrk, struct h2_sess *h2, HTC_RxInit(h2->htc, h2->ws); /* Start req thread */ - r2 = h2_new_req(wrk, h2, 1, req); + r2 = h2_new_req(h2, 1, req); req->transport = &H2_transport; assert(req->req_step == R_STP_TRANSPORT); req->task->func = h2_do_req; @@ -354,9 +354,9 @@ h2_new_session(struct worker *wrk, void *arg) assert (req->err_code == H2_PU_MARKER || req->err_code == H2_OU_MARKER); - h2 = h2_init_sess(wrk, sp, &h2s, + h2 = h2_init_sess(sp, &h2s, req->err_code == H2_PU_MARKER ? req : NULL, &decode); - h2->req0 = h2_new_req(wrk, h2, 0, NULL); + h2->req0 = h2_new_req(h2, 0, NULL); AZ(h2->htc->priv); h2->htc->priv = h2; From dridi.boukelmoune at gmail.com Mon Oct 11 07:02:08 2021 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 11 Oct 2021 07:02:08 +0000 (UTC) Subject: [master] 32c2e0125 vtc_http2: Whitespace OCD Message-ID: <20211011070208.41EF2A769E@lists.varnish-cache.org> commit 32c2e01252b326b3368494c32f146c1dba0c6133 Author: Dridi Boukelmoune Date: Mon Oct 11 09:00:57 2021 +0200 vtc_http2: Whitespace OCD diff --git a/bin/varnishtest/vtc_http2.c b/bin/varnishtest/vtc_http2.c index 406193dbb..1ee37b95a 100644 --- a/bin/varnishtest/vtc_http2.c +++ b/bin/varnishtest/vtc_http2.c @@ -330,11 +330,11 @@ write_frame(const struct stream *sp, const struct frame *f, const unsigned lock) writeFrameHeader(hdr, f); - vtc_log(sp->vl, 3, "tx: stream: %d, type: %s (%d), " - "flags: 0x%02x, size: %d", - f->stid, - f->type < TYPE_MAX ? h2_types[f->type] : "?", - f->type, f->flags, f->size); + vtc_log(sp->vl, 3, + "tx: stream: %d, type: %s (%d), flags: 0x%02x, size: %d", + f->stid, + f->type < TYPE_MAX ? h2_types[f->type] : "?", + f->type, f->flags, f->size); if (lock) AZ(pthread_mutex_lock(&hp->mtx)); From phk at FreeBSD.org Mon Oct 11 21:41:11 2021 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 11 Oct 2021 21:41:11 +0000 (UTC) Subject: [master] e1da1915e Attempt to use `pthread_condattr_setclock(&ca, CLOCK_MONOTONIC)` Message-ID: <20211011214111.87F1F92BDE@lists.varnish-cache.org> commit e1da1915e8966ad38dd327b8728fd3f00557b83a Author: Poul-Henning Kamp Date: Mon Oct 11 21:40:22 2021 +0000 Attempt to use `pthread_condattr_setclock(&ca, CLOCK_MONOTONIC)` diff --git a/bin/varnishhist/varnishhist.c b/bin/varnishhist/varnishhist.c index 539245305..365ac2a84 100644 --- a/bin/varnishhist/varnishhist.c +++ b/bin/varnishhist/varnishhist.c @@ -366,9 +366,8 @@ accumulate(struct VSL_data *vsl, struct VSL_transaction * const pt[], vsl_to = vsl_t0 + (t - t0) * timebend; if (vsl_ts > vsl_to) { - double when = VTIM_real() + vsl_ts - vsl_to; struct timespec ts; - ts.tv_nsec = (long)(modf(when, &t) * 1e9); + ts.tv_nsec = (long)(modf(vsl_ts - vsl_to, &t) * 1e9); ts.tv_sec = (long)t; i = pthread_cond_timedwait(&timebend_cv, &mtx, &ts); assert(i == 0 || i == ETIMEDOUT); @@ -487,9 +486,12 @@ main(int argc, char **argv) pthread_t thr; int fnum; struct profile cli_p = {0}; + pthread_condattr_t ca; vut = VUT_InitProg(argc, argv, &vopt_spec); AN(vut); + AZ(pthread_condattr_init(&ca)); + AZ(pthread_condattr_setclock(&ca, CLOCK_MONOTONIC)); AZ(pthread_cond_init(&timebend_cv, NULL)); while ((i = getopt(argc, argv, vopt_spec.vopt_optstring)) != -1) { From dridi at varni.sh Mon Oct 11 21:50:52 2021 From: dridi at varni.sh (Dridi Boukelmoune) Date: Mon, 11 Oct 2021 21:50:52 +0000 Subject: [master] e1da1915e Attempt to use `pthread_condattr_setclock(&ca, CLOCK_MONOTONIC)` In-Reply-To: <20211011214111.87F1F92BDE@lists.varnish-cache.org> References: <20211011214111.87F1F92BDE@lists.varnish-cache.org> Message-ID: On Mon, Oct 11, 2021 at 9:41 PM Poul-Henning Kamp wrote: > > > commit e1da1915e8966ad38dd327b8728fd3f00557b83a > Author: Poul-Henning Kamp > Date: Mon Oct 11 21:40:22 2021 +0000 > > Attempt to use `pthread_condattr_setclock(&ca, CLOCK_MONOTONIC)` > > diff --git a/bin/varnishhist/varnishhist.c b/bin/varnishhist/varnishhist.c > index 539245305..365ac2a84 100644 > --- a/bin/varnishhist/varnishhist.c > +++ b/bin/varnishhist/varnishhist.c > @@ -366,9 +366,8 @@ accumulate(struct VSL_data *vsl, struct VSL_transaction * const pt[], > vsl_to = vsl_t0 + (t - t0) * timebend; > > if (vsl_ts > vsl_to) { > - double when = VTIM_real() + vsl_ts - vsl_to; > struct timespec ts; > - ts.tv_nsec = (long)(modf(when, &t) * 1e9); > + ts.tv_nsec = (long)(modf(vsl_ts - vsl_to, &t) * 1e9); > ts.tv_sec = (long)t; > i = pthread_cond_timedwait(&timebend_cv, &mtx, &ts); > assert(i == 0 || i == ETIMEDOUT); > @@ -487,9 +486,12 @@ main(int argc, char **argv) > pthread_t thr; > int fnum; > struct profile cli_p = {0}; > + pthread_condattr_t ca; > > vut = VUT_InitProg(argc, argv, &vopt_spec); > AN(vut); > + AZ(pthread_condattr_init(&ca)); > + AZ(pthread_condattr_setclock(&ca, CLOCK_MONOTONIC)); > AZ(pthread_cond_init(&timebend_cv, NULL)); Did you forget to pass ca to pthread_cond_init() ? From phk at phk.freebsd.dk Mon Oct 11 21:54:20 2021 From: phk at phk.freebsd.dk (Poul-Henning Kamp) Date: Mon, 11 Oct 2021 21:54:20 +0000 Subject: [master] e1da1915e Attempt to use `pthread_condattr_setclock(&ca, CLOCK_MONOTONIC)` In-Reply-To: References: <20211011214111.87F1F92BDE@lists.varnish-cache.org> Message-ID: <202110112154.19BLsKOU059783@critter.freebsd.dk> -------- Dridi Boukelmoune writes: > > + AZ(pthread_condattr_init(&ca)); > > + AZ(pthread_condattr_setclock(&ca, CLOCK_MONOTONIC)); > > AZ(pthread_cond_init(&timebend_cv, NULL)); > > Did you forget to pass ca to pthread_cond_init() ? I guess I did... -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk at FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence. From phk at FreeBSD.org Mon Oct 11 21:55:10 2021 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 11 Oct 2021 21:55:10 +0000 (UTC) Subject: [master] 58f90420a Duh! Also pass the condattr to the init call. Message-ID: <20211011215510.32B599374F@lists.varnish-cache.org> commit 58f90420a41b275eb5f1c86d8912e299398b9b7f Author: Poul-Henning Kamp Date: Mon Oct 11 21:54:42 2021 +0000 Duh! Also pass the condattr to the init call. Spotted by: Dridi diff --git a/bin/varnishhist/varnishhist.c b/bin/varnishhist/varnishhist.c index 365ac2a84..71f7a4d98 100644 --- a/bin/varnishhist/varnishhist.c +++ b/bin/varnishhist/varnishhist.c @@ -492,7 +492,7 @@ main(int argc, char **argv) AN(vut); AZ(pthread_condattr_init(&ca)); AZ(pthread_condattr_setclock(&ca, CLOCK_MONOTONIC)); - AZ(pthread_cond_init(&timebend_cv, NULL)); + AZ(pthread_cond_init(&timebend_cv, &ca)); while ((i = getopt(argc, argv, vopt_spec.vopt_optstring)) != -1) { switch (i) { From phk at FreeBSD.org Tue Oct 12 12:15:07 2021 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 12 Oct 2021 12:15:07 +0000 (UTC) Subject: [master] 266ce5fb5 Always AN function pointers before use. Message-ID: <20211012121507.BC8C4B25BA@lists.varnish-cache.org> commit 266ce5fb50811718dbf6b629602afb347196cafc Author: Poul-Henning Kamp Date: Tue Oct 12 11:04:43 2021 +0000 Always AN function pointers before use. diff --git a/bin/varnishd/cache/cache_wrk.c b/bin/varnishd/cache/cache_wrk.c index db4139a98..b8bc3efbd 100644 --- a/bin/varnishd/cache/cache_wrk.c +++ b/bin/varnishd/cache/cache_wrk.c @@ -483,6 +483,7 @@ Pool_Work_Thread(struct pool *pp, struct worker *wrk) do { memset(wrk->task, 0, sizeof wrk->task); assert(wrk->pool == pp); + AN(tp->func); tp->func(wrk, tp->priv); if (DO_DEBUG(DBG_VCLREL) && wrk->wpriv->vcl != NULL) VCL_Rel(&wrk->wpriv->vcl); From phk at FreeBSD.org Tue Oct 12 12:15:07 2021 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 12 Oct 2021 12:15:07 +0000 (UTC) Subject: [master] 55753f98b Centralize check for multiple Host: and Content-Length headers. Increment client_req_400 in more cases. Message-ID: <20211012121507.D8C7CB25BE@lists.varnish-cache.org> commit 55753f98b1b392766bd4baed7eb684c006225f57 Author: Poul-Henning Kamp Date: Tue Oct 12 11:26:58 2021 +0000 Centralize check for multiple Host: and Content-Length headers. Increment client_req_400 in more cases. diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 5116c8c4c..e754014e7 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -110,6 +110,7 @@ cnt_transport(struct worker *wrk, struct req *req) req->doclose = http_DoConnection(req->http, SC_REQ_CLOSE); if (req->doclose == SC_RX_BAD) { + wrk->stats->client_req_400++; (void)req->transport->minimal_response(req, 400); return (REQ_FSM_DONE); } @@ -927,6 +928,20 @@ cnt_recv(struct worker *wrk, struct req *req) http_VSL_log(req->http); + if (http_CountHdr(req->http0, H_Host) > 1) { + VSLb(req->vsl, SLT_BogoHeader, "Multiple Host: headers"); + wrk->stats->client_req_400++; + (void)req->transport->minimal_response(req, 400); + return (REQ_FSM_DONE); + } + + if (http_CountHdr(req->http0, H_Content_Length) > 1) { + VSLb(req->vsl, SLT_BogoHeader, "Multiple Content-Length: headers"); + wrk->stats->client_req_400++; + (void)req->transport->minimal_response(req, 400); + return (REQ_FSM_DONE); + } + cnt_recv_prep(req, ci); if (req->req_body_status == BS_ERROR) { diff --git a/bin/varnishd/http1/cache_http1_proto.c b/bin/varnishd/http1/cache_http1_proto.c index eb19825cc..f56a29b52 100644 --- a/bin/varnishd/http1/cache_http1_proto.c +++ b/bin/varnishd/http1/cache_http1_proto.c @@ -368,12 +368,6 @@ HTTP1_DissectRequest(struct http_conn *htc, struct http *hp) if (hp->protover < 10 || hp->protover > 11) return (400); - if (http_CountHdr(hp, H_Host) > 1) - return (400); - - if (http_CountHdr(hp, H_Content_Length) > 1) - return (400); - /* RFC2616, section 5.2, point 1 */ if (http_scheme_at(hp->hd[HTTP_HDR_URL].b, http)) b = hp->hd[HTTP_HDR_URL].b + 7; diff --git a/bin/varnishtest/tests/b00037.vtc b/bin/varnishtest/tests/b00037.vtc index 1b7c31235..74fad6118 100644 --- a/bin/varnishtest/tests/b00037.vtc +++ b/bin/varnishtest/tests/b00037.vtc @@ -8,6 +8,7 @@ client c1 { expect resp.status == 400 } -run +varnish v1 -vsl_catchup varnish v1 -expect client_req_400 == 1 client c1 { @@ -16,4 +17,28 @@ client c1 { expect resp.status == 400 } -run +varnish v1 -vsl_catchup varnish v1 -expect client_req_400 == 2 + +varnish v1 -cliok "param.set feature +http2" + +client c2 { + stream 7 { + txreq -hdr host foo -hdr host bar + rxresp + expect resp.status == 400 + } -run +} -run + +varnish v1 -vsl_catchup +varnish v1 -expect client_req_400 == 3 + +client c3 { + stream 3 { + txreq -req POST -hdr content-length 12 -hdr content-length 13 -body request + rxrst + } -run +} -run + +varnish v1 -vsl_catchup +varnish v1 -expect client_req_400 == 4 From phk at FreeBSD.org Tue Oct 12 15:33:07 2021 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 12 Oct 2021 15:33:07 +0000 (UTC) Subject: [master] c4ceb2d01 Make all mutexen PTHREAD_MUTEX_ERRORCHECK because PTHREAD_MUTEX_NORMAL is still deranged. (See: CERT secure coding POS04-C) Message-ID: <20211012153307.810E6939F@lists.varnish-cache.org> commit c4ceb2d017f1230b21ecc649a1fc692b97e939bb Author: Poul-Henning Kamp Date: Tue Oct 12 13:04:28 2021 +0000 Make all mutexen PTHREAD_MUTEX_ERRORCHECK because PTHREAD_MUTEX_NORMAL is still deranged. (See: CERT secure coding POS04-C) Also prepare a global condattr_monotime, which will soon be used. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 90b9d781e..14b5c0c09 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -685,6 +685,8 @@ int Lck__Trylock(struct lock *lck, const char *p, int l); void Lck__New(struct lock *lck, struct VSC_lck *, const char *); int Lck__Held(const struct lock *lck); int Lck__Owned(const struct lock *lck); +extern pthread_condattr_t condattr_monotime; +extern pthread_mutexattr_t mtxattr_errorcheck; /* public interface: */ void Lck_Delete(struct lock *lck); diff --git a/bin/varnishd/cache/cache_lck.c b/bin/varnishd/cache/cache_lck.c index 32b326ee1..af3f306ed 100644 --- a/bin/varnishd/cache/cache_lck.c +++ b/bin/varnishd/cache/cache_lck.c @@ -58,8 +58,6 @@ struct ilck { struct VSC_lck *stat; }; -static pthread_mutexattr_t attr; - /*--------------------------------------------------------------------*/ static void @@ -267,7 +265,7 @@ Lck__New(struct lock *lck, struct VSC_lck *st, const char *w) ilck->w = w; ilck->stat = st; ilck->stat->creat++; - AZ(pthread_mutex_init(&ilck->mtx, &attr)); + AZ(pthread_mutex_init(&ilck->mtx, &mtxattr_errorcheck)); lck->priv = ilck; } @@ -302,8 +300,6 @@ void LCK_Init(void) { - AZ(pthread_mutexattr_init(&attr)); - AZ(pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK)); #define LOCK(nam) lck_##nam = Lck_CreateClass(NULL, #nam); #include "tbl/locks.h" } diff --git a/bin/varnishd/cache/cache_main.c b/bin/varnishd/cache/cache_main.c index 4b98a8a0f..0e81c3928 100644 --- a/bin/varnishd/cache/cache_main.c +++ b/bin/varnishd/cache/cache_main.c @@ -57,6 +57,9 @@ int cache_shutdown = 0; volatile struct params *cache_param; static pthread_mutex_t cache_vrnd_mtx; +pthread_mutexattr_t mtxattr_errorcheck; +pthread_condattr_t condattr_monotime; + static void cache_vrnd_lock(void) { @@ -362,6 +365,12 @@ child_main(int sigmagic, size_t altstksz) malloc_message = child_malloc_fail; #endif + /* Before anything uses pthreads in anger */ + AZ(pthread_mutexattr_init(&mtxattr_errorcheck)); + AZ(pthread_mutexattr_settype(&mtxattr_errorcheck, PTHREAD_MUTEX_ERRORCHECK)); + AZ(pthread_condattr_init(&condattr_monotime)); + AZ(pthread_condattr_setclock(&condattr_monotime, CLOCK_MONOTONIC)); + cache_param = heritage.param; AZ(pthread_key_create(&req_key, NULL)); @@ -372,7 +381,7 @@ child_main(int sigmagic, size_t altstksz) THR_SetName("cache-main"); - AZ(pthread_mutex_init(&cache_vrnd_mtx, NULL)); + AZ(pthread_mutex_init(&cache_vrnd_mtx, &mtxattr_errorcheck)); VRND_Lock = cache_vrnd_lock; VRND_Unlock = cache_vrnd_unlock; diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index 3d01e6090..9123f1ce8 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -842,7 +842,7 @@ void PAN_Init(void) { - AZ(pthread_mutex_init(&panicstr_mtx, NULL)); + AZ(pthread_mutex_init(&panicstr_mtx, &mtxattr_errorcheck)); VAS_Fail_Func = pan_ic; pan_vsb = &pan_vsb_storage; AN(heritage.panic_str); diff --git a/bin/varnishd/cache/cache_shmlog.c b/bin/varnishd/cache/cache_shmlog.c index 4fc746eee..fbda72f0b 100644 --- a/bin/varnishd/cache/cache_shmlog.c +++ b/bin/varnishd/cache/cache_shmlog.c @@ -614,9 +614,9 @@ VSM_Init(void) assert(UINT_MAX % VSL_SEGMENTS == VSL_SEGMENTS - 1); - AZ(pthread_mutex_init(&vsl_mtx, NULL)); - AZ(pthread_mutex_init(&vsc_mtx, NULL)); - AZ(pthread_mutex_init(&vsm_mtx, NULL)); + AZ(pthread_mutex_init(&vsl_mtx, &mtxattr_errorcheck)); + AZ(pthread_mutex_init(&vsc_mtx, &mtxattr_errorcheck)); + AZ(pthread_mutex_init(&vsm_mtx, &mtxattr_errorcheck)); vsc_lock = vsm_vsc_lock; vsc_unlock = vsm_vsc_unlock; diff --git a/bin/varnishd/storage/stevedore.c b/bin/varnishd/storage/stevedore.c index a35e9eb7a..ccacac33c 100644 --- a/bin/varnishd/storage/stevedore.c +++ b/bin/varnishd/storage/stevedore.c @@ -175,7 +175,7 @@ STV_open(void) char buf[1024]; ASSERT_CLI(); - AZ(pthread_mutex_init(&stv_mtx, NULL)); + AZ(pthread_mutex_init(&stv_mtx, &mtxattr_errorcheck)); /* This string was prepared for us before the fork, and should * point to a configured stevedore. */ From phk at FreeBSD.org Tue Oct 12 15:33:07 2021 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 12 Oct 2021 15:33:07 +0000 (UTC) Subject: [master] 3e2a73bc0 Brute force rename Lck_CondWait() to Lck_CondWaitUntil() Message-ID: <20211012153307.9986C93A2@lists.varnish-cache.org> commit 3e2a73bc01f4366830fcf6a7689487444e2833a5 Author: Poul-Henning Kamp Date: Tue Oct 12 14:52:39 2021 +0000 Brute force rename Lck_CondWait() to Lck_CondWaitUntil() diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 14b5c0c09..f8e3514f2 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -690,7 +690,7 @@ extern pthread_mutexattr_t mtxattr_errorcheck; /* public interface: */ void Lck_Delete(struct lock *lck); -int Lck_CondWait(pthread_cond_t *cond, struct lock *lck, vtim_real); +int Lck_CondWaitUntil(pthread_cond_t *cond, struct lock *lck, vtim_real); #define Lck_New(a, b) Lck__New(a, b, #b) #define Lck_Lock(a) Lck__Lock(a, __func__, __LINE__) diff --git a/bin/varnishd/cache/cache_backend_probe.c b/bin/varnishd/cache/cache_backend_probe.c index 5fa8b1b7e..8d50d64b2 100644 --- a/bin/varnishd/cache/cache_backend_probe.c +++ b/bin/varnishd/cache/cache_backend_probe.c @@ -475,11 +475,11 @@ vbp_thread(struct worker *wrk, void *priv) vt = VBH_root(vbp_heap); if (vt == NULL) { nxt = 8.192 + now; - (void)Lck_CondWait(&vbp_cond, &vbp_mtx, nxt); + (void)Lck_CondWaitUntil(&vbp_cond, &vbp_mtx, nxt); } else if (vt->due > now) { nxt = vt->due; vt = NULL; - (void)Lck_CondWait(&vbp_cond, &vbp_mtx, nxt); + (void)Lck_CondWaitUntil(&vbp_cond, &vbp_mtx, nxt); } else { VBH_delete(vbp_heap, vt->heap_idx); vt->due = now + vt->interval; diff --git a/bin/varnishd/cache/cache_ban_lurker.c b/bin/varnishd/cache/cache_ban_lurker.c index d0990f410..c7c41e077 100644 --- a/bin/varnishd/cache/cache_ban_lurker.c +++ b/bin/varnishd/cache/cache_ban_lurker.c @@ -430,7 +430,7 @@ ban_lurker(struct worker *wrk, void *priv) Lck_Lock(&ban_mtx); if (gen == ban_generation) { Pool_Sumstat(wrk); - (void)Lck_CondWait(&ban_lurker_cond, &ban_mtx, d); + (void)Lck_CondWaitUntil(&ban_lurker_cond, &ban_mtx, d); ban_batch = 0; } gen = ban_generation; diff --git a/bin/varnishd/cache/cache_conn_pool.c b/bin/varnishd/cache/cache_conn_pool.c index 4f4b1b210..a1ec971ea 100644 --- a/bin/varnishd/cache/cache_conn_pool.c +++ b/bin/varnishd/cache/cache_conn_pool.c @@ -500,7 +500,7 @@ VCP_Wait(struct worker *wrk, struct pfd *pfd, vtim_real tmo) assert(pfd->cond == &wrk->cond); Lck_Lock(&cp->mtx); while (pfd->state == PFD_STATE_STOLEN) { - r = Lck_CondWait(&wrk->cond, &cp->mtx, tmo); + r = Lck_CondWaitUntil(&wrk->cond, &cp->mtx, tmo); if (r != 0) { if (r == EINTR) continue; diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index 483e3c0b6..f712b693e 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -202,7 +202,7 @@ ved_include(struct req *preq, const char *src, const char *host, assert(s == REQ_FSM_DISEMBARK); Lck_Lock(&sp->mtx); if (!ecx->woken) - (void)Lck_CondWait( + (void)Lck_CondWaitUntil( &ecx->preq->wrk->cond, &sp->mtx, 0); Lck_Unlock(&sp->mtx); AZ(req->wrk); diff --git a/bin/varnishd/cache/cache_expire.c b/bin/varnishd/cache/cache_expire.c index a415fce59..c75c5d894 100644 --- a/bin/varnishd/cache/cache_expire.c +++ b/bin/varnishd/cache/cache_expire.c @@ -419,7 +419,7 @@ exp_thread(struct worker *wrk, void *priv) } else if (tnext > t) { VSL_Flush(&ep->vsl, 0); Pool_Sumstat(wrk); - (void)Lck_CondWait(&ep->condvar, &ep->mtx, tnext); + (void)Lck_CondWaitUntil(&ep->condvar, &ep->mtx, tnext); } Lck_Unlock(&ep->mtx); diff --git a/bin/varnishd/cache/cache_lck.c b/bin/varnishd/cache/cache_lck.c index af3f306ed..a0aaaa907 100644 --- a/bin/varnishd/cache/cache_lck.c +++ b/bin/varnishd/cache/cache_lck.c @@ -208,7 +208,7 @@ Lck__Owned(const struct lock *lck) } int v_matchproto_() -Lck_CondWait(pthread_cond_t *cond, struct lock *lck, vtim_real when) +Lck_CondWaitUntil(pthread_cond_t *cond, struct lock *lck, vtim_real when) { struct ilck *ilck; struct timespec ts; diff --git a/bin/varnishd/cache/cache_obj.c b/bin/varnishd/cache/cache_obj.c index 76a90f9cf..e5cd2af28 100644 --- a/bin/varnishd/cache/cache_obj.c +++ b/bin/varnishd/cache/cache_obj.c @@ -257,7 +257,7 @@ ObjWaitExtend(const struct worker *wrk, const struct objcore *oc, uint64_t l) assert(l <= rv || oc->boc->state == BOS_FAILED); if (rv > l || oc->boc->state >= BOS_FINISHED) break; - (void)Lck_CondWait(&oc->boc->cond, &oc->boc->mtx, 0); + (void)Lck_CondWaitUntil(&oc->boc->cond, &oc->boc->mtx, 0); } rv = oc->boc->len_so_far; Lck_Unlock(&oc->boc->mtx); @@ -307,7 +307,7 @@ ObjWaitState(const struct objcore *oc, enum boc_state_e want) while (1) { if (oc->boc->state >= want) break; - (void)Lck_CondWait(&oc->boc->cond, &oc->boc->mtx, 0); + (void)Lck_CondWaitUntil(&oc->boc->cond, &oc->boc->mtx, 0); } Lck_Unlock(&oc->boc->mtx); } diff --git a/bin/varnishd/cache/cache_wrk.c b/bin/varnishd/cache/cache_wrk.c index b8bc3efbd..02be15c81 100644 --- a/bin/varnishd/cache/cache_wrk.c +++ b/bin/varnishd/cache/cache_wrk.c @@ -42,7 +42,7 @@ * * In our case, any worker thread which we wake up comes from the idle queue, * where it put itself under the mutex, releasing that mutex implicitly via - * Lck_CondWait() (which calls some variant of pthread_cond_wait). So we avoid + * Lck_CondWaitUntil() (which calls some variant of pthread_cond_wait). So we avoid * additional mutex contention knowing that any worker thread on the idle queue * is blocking on the cv. * @@ -440,7 +440,7 @@ Pool_Work_Thread(struct pool *pp, struct worker *wrk) tmo = now + 1.; else tmo = now + 60.; - (void)Lck_CondWait(&wrk->cond, &pp->mtx, tmo); + (void)Lck_CondWaitUntil(&wrk->cond, &pp->mtx, tmo); if (wrk->task->func != NULL) { /* We have been handed a new task */ tpx = *wrk->task; @@ -697,13 +697,13 @@ pool_herder(void *priv) if (pp->lqueue == 0) { if (DO_DEBUG(DBG_VTC_MODE)) delay = 0.5; - r = Lck_CondWait(&pp->herder_cond, &pp->mtx, + r = Lck_CondWaitUntil(&pp->herder_cond, &pp->mtx, VTIM_real() + delay); } else if (pp->nthr >= cache_param->wthread_max) { /* XXX: unsafe counters */ if (r != ETIMEDOUT) VSC_C_main->threads_limited++; - r = Lck_CondWait(&pp->herder_cond, &pp->mtx, + r = Lck_CondWaitUntil(&pp->herder_cond, &pp->mtx, VTIM_real() + 1.0); } Lck_Unlock(&pp->mtx); diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index a9ce140bc..4d9dc37b1 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -1038,7 +1038,7 @@ h2_vfp_body(struct vfp_ctx *vc, struct vfp_entry *vfe, void *ptr, ssize_t *lp) if (retval != VFP_OK || l > 0) break; - i = Lck_CondWait(r2->cond, &h2->sess->mtx, + i = Lck_CondWaitUntil(r2->cond, &h2->sess->mtx, VTIM_real() + SESS_TMO(h2->sess, timeout_idle)); if (i == ETIMEDOUT) { retval = VFP_ERROR; diff --git a/bin/varnishd/http2/cache_http2_send.c b/bin/varnishd/http2/cache_http2_send.c index a684b9488..a1439c0a5 100644 --- a/bin/varnishd/http2/cache_http2_send.c +++ b/bin/varnishd/http2/cache_http2_send.c @@ -59,7 +59,7 @@ h2_cond_wait(pthread_cond_t *cond, struct h2_sess *h2, struct h2_req *r2) if (cache_param->idle_send_timeout > 0.) when = now + cache_param->idle_send_timeout; - r = Lck_CondWait(cond, &h2->sess->mtx, when); + r = Lck_CondWaitUntil(cond, &h2->sess->mtx, when); assert(r == 0 || r == ETIMEDOUT); now = VTIM_real(); @@ -100,7 +100,7 @@ h2_send_get_locked(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) r2->wrk = wrk; VTAILQ_INSERT_TAIL(&h2->txqueue, r2, tx_list); while (!H2_SEND_HELD(h2, r2)) - AZ(Lck_CondWait(&wrk->cond, &h2->sess->mtx, 0)); + AZ(Lck_CondWaitUntil(&wrk->cond, &h2->sess->mtx, 0)); r2->wrk = NULL; } diff --git a/bin/varnishd/http2/cache_http2_session.c b/bin/varnishd/http2/cache_http2_session.c index 5d4e3ecd6..899f2ec56 100644 --- a/bin/varnishd/http2/cache_http2_session.c +++ b/bin/varnishd/http2/cache_http2_session.c @@ -429,7 +429,7 @@ h2_new_session(struct worker *wrk, void *arg) VTAILQ_FOREACH(r2, &h2->streams, list) VSLb(h2->vsl, SLT_Debug, "ST %u %d", r2->stream, r2->state); - (void)Lck_CondWait(h2->cond, &h2->sess->mtx, VTIM_real() + .1); + (void)Lck_CondWaitUntil(h2->cond, &h2->sess->mtx, VTIM_real() + .1); Lck_Unlock(&h2->sess->mtx); } h2->cond = NULL; From phk at FreeBSD.org Tue Oct 12 15:33:07 2021 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 12 Oct 2021 15:33:07 +0000 (UTC) Subject: [master] a2a00988d (Re)introduce Lck_CondWait() which waits forever and …Timeout which does not. Message-ID: <20211012153307.B4B4593A7@lists.varnish-cache.org> commit a2a00988d4286421213824d772125303171d9dca Author: Poul-Henning Kamp Date: Tue Oct 12 14:59:59 2021 +0000 (Re)introduce Lck_CondWait() which waits forever and ?Timeout which does not. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index f8e3514f2..e9803d8d1 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -690,7 +690,9 @@ extern pthread_mutexattr_t mtxattr_errorcheck; /* public interface: */ void Lck_Delete(struct lock *lck); -int Lck_CondWaitUntil(pthread_cond_t *cond, struct lock *lck, vtim_real); +int Lck_CondWaitUntil(pthread_cond_t *, struct lock *, vtim_real when); +int Lck_CondWait(pthread_cond_t *, struct lock *); +int Lck_CondWaitTimeout(pthread_cond_t *, struct lock *, vtim_dur timeout); #define Lck_New(a, b) Lck__New(a, b, #b) #define Lck_Lock(a) Lck__Lock(a, __func__, __LINE__) diff --git a/bin/varnishd/cache/cache_lck.c b/bin/varnishd/cache/cache_lck.c index a0aaaa907..a41b9a93e 100644 --- a/bin/varnishd/cache/cache_lck.c +++ b/bin/varnishd/cache/cache_lck.c @@ -42,9 +42,7 @@ #include #include -#if defined (__APPLE__) -# include "vtim.h" -#endif +#include "vtim.h" #include "VSC_lck.h" @@ -207,6 +205,24 @@ Lck__Owned(const struct lock *lck) return (pthread_equal(ilck->owner, pthread_self())); } +int v_matchproto_() +Lck_CondWait(pthread_cond_t *cond, struct lock *lck) +{ + return (Lck_CondWaitUntil(cond, lck, 0)); +} + +int v_matchproto_() +Lck_CondWaitTimeout(pthread_cond_t *cond, struct lock *lck, vtim_dur timeout) +{ + assert(timeout >= 0); + assert(timeout < 3600); + + if (timeout == 0) + return (Lck_CondWaitUntil(cond, lck, 0)); + else + return (Lck_CondWaitUntil(cond, lck, VTIM_real() + timeout)); +} + int v_matchproto_() Lck_CondWaitUntil(pthread_cond_t *cond, struct lock *lck, vtim_real when) { From phk at FreeBSD.org Tue Oct 12 15:33:07 2021 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 12 Oct 2021 15:33:07 +0000 (UTC) Subject: [master] e622ed38c Use Lck_CondWait() and Lck_CondWaitTimeout() instead of Lck_CondWaitUntil() Message-ID: <20211012153307.D019F93AB@lists.varnish-cache.org> commit e622ed38ca0fa8fd2b6223a52de17f580bb8dc3f Author: Poul-Henning Kamp Date: Tue Oct 12 15:31:32 2021 +0000 Use Lck_CondWait() and Lck_CondWaitTimeout() instead of Lck_CondWaitUntil() diff --git a/bin/varnishd/cache/cache_ban_lurker.c b/bin/varnishd/cache/cache_ban_lurker.c index c7c41e077..ab5280e88 100644 --- a/bin/varnishd/cache/cache_ban_lurker.c +++ b/bin/varnishd/cache/cache_ban_lurker.c @@ -413,7 +413,6 @@ void * v_matchproto_(bgthread_t) ban_lurker(struct worker *wrk, void *priv) { struct vsl_log vsl; - vtim_real d; vtim_dur dt; unsigned gen = ban_generation + 1; @@ -426,11 +425,11 @@ ban_lurker(struct worker *wrk, void *priv) dt = ban_lurker_work(wrk, &vsl); if (DO_DEBUG(DBG_LURKER)) VSLb(&vsl, SLT_Debug, "lurker: sleep = %lf", dt); - d = VTIM_real() + dt; Lck_Lock(&ban_mtx); if (gen == ban_generation) { Pool_Sumstat(wrk); - (void)Lck_CondWaitUntil(&ban_lurker_cond, &ban_mtx, d); + (void)Lck_CondWaitTimeout( + &ban_lurker_cond, &ban_mtx, dt); ban_batch = 0; } gen = ban_generation; diff --git a/bin/varnishd/cache/cache_conn_pool.c b/bin/varnishd/cache/cache_conn_pool.c index a1ec971ea..2a2a76ca8 100644 --- a/bin/varnishd/cache/cache_conn_pool.c +++ b/bin/varnishd/cache/cache_conn_pool.c @@ -488,7 +488,7 @@ VCP_Get(struct conn_pool *cp, vtim_dur tmo, struct worker *wrk, */ int -VCP_Wait(struct worker *wrk, struct pfd *pfd, vtim_real tmo) +VCP_Wait(struct worker *wrk, struct pfd *pfd, vtim_real when) { struct conn_pool *cp; int r; @@ -500,7 +500,7 @@ VCP_Wait(struct worker *wrk, struct pfd *pfd, vtim_real tmo) assert(pfd->cond == &wrk->cond); Lck_Lock(&cp->mtx); while (pfd->state == PFD_STATE_STOLEN) { - r = Lck_CondWaitUntil(&wrk->cond, &cp->mtx, tmo); + r = Lck_CondWaitUntil(&wrk->cond, &cp->mtx, when); if (r != 0) { if (r == EINTR) continue; diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index f712b693e..c6fc3b0b6 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -202,8 +202,7 @@ ved_include(struct req *preq, const char *src, const char *host, assert(s == REQ_FSM_DISEMBARK); Lck_Lock(&sp->mtx); if (!ecx->woken) - (void)Lck_CondWaitUntil( - &ecx->preq->wrk->cond, &sp->mtx, 0); + (void)Lck_CondWait(&ecx->preq->wrk->cond, &sp->mtx); Lck_Unlock(&sp->mtx); AZ(req->wrk); } diff --git a/bin/varnishd/cache/cache_obj.c b/bin/varnishd/cache/cache_obj.c index e5cd2af28..24785b567 100644 --- a/bin/varnishd/cache/cache_obj.c +++ b/bin/varnishd/cache/cache_obj.c @@ -257,7 +257,7 @@ ObjWaitExtend(const struct worker *wrk, const struct objcore *oc, uint64_t l) assert(l <= rv || oc->boc->state == BOS_FAILED); if (rv > l || oc->boc->state >= BOS_FINISHED) break; - (void)Lck_CondWaitUntil(&oc->boc->cond, &oc->boc->mtx, 0); + (void)Lck_CondWait(&oc->boc->cond, &oc->boc->mtx); } rv = oc->boc->len_so_far; Lck_Unlock(&oc->boc->mtx); @@ -307,7 +307,7 @@ ObjWaitState(const struct objcore *oc, enum boc_state_e want) while (1) { if (oc->boc->state >= want) break; - (void)Lck_CondWaitUntil(&oc->boc->cond, &oc->boc->mtx, 0); + (void)Lck_CondWait(&oc->boc->cond, &oc->boc->mtx); } Lck_Unlock(&oc->boc->mtx); } diff --git a/bin/varnishd/cache/cache_wrk.c b/bin/varnishd/cache/cache_wrk.c index 02be15c81..3ef669de8 100644 --- a/bin/varnishd/cache/cache_wrk.c +++ b/bin/varnishd/cache/cache_wrk.c @@ -440,7 +440,8 @@ Pool_Work_Thread(struct pool *pp, struct worker *wrk) tmo = now + 1.; else tmo = now + 60.; - (void)Lck_CondWaitUntil(&wrk->cond, &pp->mtx, tmo); + (void)Lck_CondWaitUntil( + &wrk->cond, &pp->mtx, tmo); if (wrk->task->func != NULL) { /* We have been handed a new task */ tpx = *wrk->task; @@ -697,14 +698,14 @@ pool_herder(void *priv) if (pp->lqueue == 0) { if (DO_DEBUG(DBG_VTC_MODE)) delay = 0.5; - r = Lck_CondWaitUntil(&pp->herder_cond, &pp->mtx, - VTIM_real() + delay); + r = Lck_CondWaitTimeout( + &pp->herder_cond, &pp->mtx, delay); } else if (pp->nthr >= cache_param->wthread_max) { /* XXX: unsafe counters */ if (r != ETIMEDOUT) VSC_C_main->threads_limited++; - r = Lck_CondWaitUntil(&pp->herder_cond, &pp->mtx, - VTIM_real() + 1.0); + r = Lck_CondWaitTimeout( + &pp->herder_cond, &pp->mtx, 1.0); } Lck_Unlock(&pp->mtx); } diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index 4d9dc37b1..572275392 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -1038,8 +1038,8 @@ h2_vfp_body(struct vfp_ctx *vc, struct vfp_entry *vfe, void *ptr, ssize_t *lp) if (retval != VFP_OK || l > 0) break; - i = Lck_CondWaitUntil(r2->cond, &h2->sess->mtx, - VTIM_real() + SESS_TMO(h2->sess, timeout_idle)); + i = Lck_CondWaitTimeout(r2->cond, &h2->sess->mtx, + SESS_TMO(h2->sess, timeout_idle)); if (i == ETIMEDOUT) { retval = VFP_ERROR; break; diff --git a/bin/varnishd/http2/cache_http2_send.c b/bin/varnishd/http2/cache_http2_send.c index a1439c0a5..84c6e2c93 100644 --- a/bin/varnishd/http2/cache_http2_send.c +++ b/bin/varnishd/http2/cache_http2_send.c @@ -46,7 +46,8 @@ static int h2_cond_wait(pthread_cond_t *cond, struct h2_sess *h2, struct h2_req *r2) { - vtim_real now, when = 0.; + vtim_dur tmo = 0.; + vtim_real now; int r; AN(cond); @@ -55,11 +56,10 @@ h2_cond_wait(pthread_cond_t *cond, struct h2_sess *h2, struct h2_req *r2) Lck_AssertHeld(&h2->sess->mtx); - now = VTIM_real(); if (cache_param->idle_send_timeout > 0.) - when = now + cache_param->idle_send_timeout; + tmo = cache_param->idle_send_timeout; - r = Lck_CondWaitUntil(cond, &h2->sess->mtx, when); + r = Lck_CondWaitTimeout(cond, &h2->sess->mtx, tmo); assert(r == 0 || r == ETIMEDOUT); now = VTIM_real(); @@ -100,7 +100,7 @@ h2_send_get_locked(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) r2->wrk = wrk; VTAILQ_INSERT_TAIL(&h2->txqueue, r2, tx_list); while (!H2_SEND_HELD(h2, r2)) - AZ(Lck_CondWaitUntil(&wrk->cond, &h2->sess->mtx, 0)); + AZ(Lck_CondWait(&wrk->cond, &h2->sess->mtx)); r2->wrk = NULL; } diff --git a/bin/varnishd/http2/cache_http2_session.c b/bin/varnishd/http2/cache_http2_session.c index 899f2ec56..889441a4c 100644 --- a/bin/varnishd/http2/cache_http2_session.c +++ b/bin/varnishd/http2/cache_http2_session.c @@ -429,7 +429,7 @@ h2_new_session(struct worker *wrk, void *arg) VTAILQ_FOREACH(r2, &h2->streams, list) VSLb(h2->vsl, SLT_Debug, "ST %u %d", r2->stream, r2->state); - (void)Lck_CondWaitUntil(h2->cond, &h2->sess->mtx, VTIM_real() + .1); + (void)Lck_CondWaitTimeout(h2->cond, &h2->sess->mtx, .1); Lck_Unlock(&h2->sess->mtx); } h2->cond = NULL; From phk at FreeBSD.org Tue Oct 12 15:55:07 2021 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 12 Oct 2021 15:55:07 +0000 (UTC) Subject: [master] a3ff92588 Eliminate racy and surplus to requirements subtest. Message-ID: <20211012155507.391E86141D@lists.varnish-cache.org> commit a3ff9258861e3d523bf5105a66f33e5b869a4a06 Author: Poul-Henning Kamp Date: Tue Oct 12 15:53:48 2021 +0000 Eliminate racy and surplus to requirements subtest. diff --git a/bin/varnishtest/tests/b00037.vtc b/bin/varnishtest/tests/b00037.vtc index 74fad6118..63d8014dc 100644 --- a/bin/varnishtest/tests/b00037.vtc +++ b/bin/varnishtest/tests/b00037.vtc @@ -1,6 +1,7 @@ varnishtest "Error on multiple Host headers" varnish v1 -vcl {backend be none;} -start +varnish v1 -cliok "param.set debug +syncvsl" client c1 { txreq -hdr "Host: foo" -hdr "Host: bar" @@ -33,12 +34,6 @@ client c2 { varnish v1 -vsl_catchup varnish v1 -expect client_req_400 == 3 -client c3 { - stream 3 { - txreq -req POST -hdr content-length 12 -hdr content-length 13 -body request - rxrst - } -run -} -run - -varnish v1 -vsl_catchup -varnish v1 -expect client_req_400 == 4 +# H2 with multiple content-length runs into thread-scheduling differences, +# and is unnecessary, as we know the check works from H1 and that it +# will be hit, because H2 with multiple Host: triggered. From phk at FreeBSD.org Wed Oct 13 07:32:07 2021 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 13 Oct 2021 07:32:07 +0000 (UTC) Subject: [master] cf00dd2ed VTIM usage polish Message-ID: <20211013073208.025FBACE96@lists.varnish-cache.org> commit cf00dd2ed96c9b7a2ccd02846d9bc55719b9b919 Author: Poul-Henning Kamp Date: Wed Oct 13 07:31:09 2021 +0000 VTIM usage polish diff --git a/bin/varnishd/cache/cache_lck.c b/bin/varnishd/cache/cache_lck.c index a41b9a93e..aeb228e46 100644 --- a/bin/varnishd/cache/cache_lck.c +++ b/bin/varnishd/cache/cache_lck.c @@ -228,7 +228,6 @@ Lck_CondWaitUntil(pthread_cond_t *cond, struct lock *lck, vtim_real when) { struct ilck *ilck; struct timespec ts; - vtim_real t; AN(lck); CAST_OBJ_NOTNULL(ilck, lck->priv, ILCK_MAGIC); @@ -240,8 +239,7 @@ Lck_CondWaitUntil(pthread_cond_t *cond, struct lock *lck, vtim_real when) AZ(errno); } else { assert(when > 1e9); - ts.tv_nsec = (long)(modf(when, &t) * 1e9); - ts.tv_sec = (long)t; + ts = VTIM_timespec(when); assert(ts.tv_nsec >= 0 && ts.tv_nsec <= 999999999); errno = pthread_cond_timedwait(cond, &ilck->mtx, &ts); #if defined (__APPLE__) diff --git a/bin/varnishd/http2/cache_http2_session.c b/bin/varnishd/http2/cache_http2_session.c index 889441a4c..b260ffc59 100644 --- a/bin/varnishd/http2/cache_http2_session.c +++ b/bin/varnishd/http2/cache_http2_session.c @@ -39,7 +39,6 @@ #include "http2/cache_http2.h" #include "vend.h" -#include "vtim.h" #include "vtcp.h" static const char h2_resp_101[] = From phk at FreeBSD.org Wed Oct 13 08:35:07 2021 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 13 Oct 2021 08:35:07 +0000 (UTC) Subject: [master] 79bfe18c7 Add a bit of coverage for varnishdm Message-ID: <20211013083507.BA1EBAED3E@lists.varnish-cache.org> commit 79bfe18c712ca9f6d31f663ee0814d93a4120e97 Author: Poul-Henning Kamp Date: Wed Oct 13 08:28:02 2021 +0000 Add a bit of coverage for varnishdm diff --git a/bin/varnishtest/tests/u00012.vtc b/bin/varnishtest/tests/u00012.vtc index 6c5af113f..3f4a19ec6 100644 --- a/bin/varnishtest/tests/u00012.vtc +++ b/bin/varnishtest/tests/u00012.vtc @@ -14,7 +14,7 @@ client c1 { varnish v1 -vsl_catchup -process p1 -log {varnishadm -p -n ${v1_name}} -start +process p1 -log {varnishadm -t 12 -p -n ${v1_name}} -start # expect a full status line in pass mode (no banner) process p1 -write "ping\r" @@ -28,3 +28,12 @@ process p1 -write "vcl.show vcl1\r" process p1 -expect-text 0 0 "backend s1" process p1 -screen_dump -write "\x04" -wait + +process p1 -log {varnishadm -t foobar 2>&1} -expect-exit 2 -run +process p1 -expect-text 0 0 "-t: Invalid argument:" + +process p1 -log {varnishadm -Q 2>&1} -expect-exit 1 -run +process p1 -expect-text 0 0 "Usage: varnishadm" + +process p2 -log {varnishadm -h 2>&1} -expect-exit 0 -run +process p2 -expect-text 0 0 "Usage: varnishadm" From phk at FreeBSD.org Wed Oct 13 08:35:07 2021 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 13 Oct 2021 08:35:07 +0000 (UTC) Subject: [master] 4ae73a5b1 Use VTIM_timespec() Message-ID: <20211013083507.CE18EAED43@lists.varnish-cache.org> commit 4ae73a5b19ec1fc87cc018c01757535667e33341 Author: Poul-Henning Kamp Date: Wed Oct 13 08:30:19 2021 +0000 Use VTIM_timespec() diff --git a/bin/varnishhist/varnishhist.c b/bin/varnishhist/varnishhist.c index 71f7a4d98..27d4f9289 100644 --- a/bin/varnishhist/varnishhist.c +++ b/bin/varnishhist/varnishhist.c @@ -367,8 +367,7 @@ accumulate(struct VSL_data *vsl, struct VSL_transaction * const pt[], if (vsl_ts > vsl_to) { struct timespec ts; - ts.tv_nsec = (long)(modf(vsl_ts - vsl_to, &t) * 1e9); - ts.tv_sec = (long)t; + ts = VTIM_timespec(vsl_ts - vsl_to); i = pthread_cond_timedwait(&timebend_cv, &mtx, &ts); assert(i == 0 || i == ETIMEDOUT); } From dridi.boukelmoune at gmail.com Mon Oct 25 05:32:06 2021 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 25 Oct 2021 05:32:06 +0000 (UTC) Subject: [master] e059f3f66 ws: Polish Message-ID: <20211025053206.B65EF90A81@lists.varnish-cache.org> commit e059f3f6647a9a7847b82d1ef20691235dbab195 Author: Dridi Boukelmoune Date: Mon Oct 25 07:31:15 2021 +0200 ws: Polish diff --git a/bin/varnishd/cache/cache_ws.c b/bin/varnishd/cache/cache_ws.c index 02a3a867c..c709817e1 100644 --- a/bin/varnishd/cache/cache_ws.c +++ b/bin/varnishd/cache/cache_ws.c @@ -146,14 +146,14 @@ WS_ReqPipeline(struct ws *ws, const void *b, const void *e) else AZ(b); + r = WS_ReserveAll(ws); + if (b == NULL) { AZ(e); - (void)WS_ReserveAll(ws); return (0); } AN(e); - r = WS_ReserveAll(ws); l = pdiff(b, e); assert(l <= r); memmove(ws->f, b, l); From dridi.boukelmoune at gmail.com Mon Oct 25 06:50:08 2021 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 25 Oct 2021 06:50:08 +0000 (UTC) Subject: [6.0] 4a48254d6 vtc: Fix h5 on my machine Message-ID: <20211025065008.780B89315E@lists.varnish-cache.org> commit 4a48254d6fb98739068c0691b5b8d8e94a406402 Author: Dridi Boukelmoune Date: Wed May 26 11:41:53 2021 +0200 vtc: Fix h5 on my machine Ever since my system upgraded haproxy to 2.3.10 this test has consistently timed out. While that would be a breaking change involving the independent vtest project too, I think the VTC syslog spec would work better with something like: expect skip facility.level regex Where skip could be uint, * or ? similar to how logexpect works, and both facility and level could also be * to be non-specific. For now, let's hope this does not break the test suite for anyone else. Conflicts: bin/varnishtest/tests/h00005.vtc diff --git a/bin/varnishtest/tests/h00005.vtc b/bin/varnishtest/tests/h00005.vtc index 098bf19ab..9ca3080ab 100644 --- a/bin/varnishtest/tests/h00005.vtc +++ b/bin/varnishtest/tests/h00005.vtc @@ -9,8 +9,6 @@ server s1 { } -start syslog S1 -level notice -bind "127.0.0.1:0" { - recv - recv recv info expect ~ \"dip\":\"${h1_fe_1_addr}\" } -start From dridi.boukelmoune at gmail.com Mon Oct 25 07:01:08 2021 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 25 Oct 2021 07:01:08 +0000 (UTC) Subject: [6.0] e993bda6a Import from VTest: Don't use explicit buffer size with no buffer Message-ID: <20211025070108.6DB10938AF@lists.varnish-cache.org> commit e993bda6a3a5051d43c176e6efb39ece1e95c782 Author: Poul-Henning Kamp Date: Thu Oct 15 07:35:04 2020 +0000 Import from VTest: Don't use explicit buffer size with no buffer diff --git a/bin/varnishtest/vtc_main.c b/bin/varnishtest/vtc_main.c index ee9b74c10..4b4f8fa11 100644 --- a/bin/varnishtest/vtc_main.c +++ b/bin/varnishtest/vtc_main.c @@ -552,7 +552,7 @@ main(int argc, char * const *argv) else tmppath = strdup("/tmp"); - cwd = getcwd(NULL, PATH_MAX); + cwd = getcwd(NULL, 0); extmacro_def("pwd", "%s", cwd); vmod_path = NULL; From dridi.boukelmoune at gmail.com Mon Oct 25 07:01:08 2021 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 25 Oct 2021 07:01:08 +0000 (UTC) Subject: [6.0] 3de983328 vtest: put cwd on the stack Message-ID: <20211025070108.77EB2938B1@lists.varnish-cache.org> commit 3de9833284f49b23b8b19f3f7c74bebaf07f474d Author: Nils Goroll Date: Thu Oct 15 12:01:35 2020 +0200 vtest: put cwd on the stack 0051cbe3b9cc24586e0ad99cff72041c6df944b8 did not work on solaris-descendents, the man page clearly states that the size argument also determines the buffer to be malloc()ed for a NULL buffer argument. diff --git a/bin/varnishtest/vtc_main.c b/bin/varnishtest/vtc_main.c index 4b4f8fa11..516ff99c4 100644 --- a/bin/varnishtest/vtc_main.c +++ b/bin/varnishtest/vtc_main.c @@ -540,6 +540,7 @@ main(int argc, char * const *argv) int ntest = 1; /* Run tests this many times */ uintmax_t bufsiz; const char *p; + char buf[PATH_MAX]; argv0 = strrchr(argv[0], '/'); if (argv0 == NULL) @@ -552,7 +553,7 @@ main(int argc, char * const *argv) else tmppath = strdup("/tmp"); - cwd = getcwd(NULL, 0); + cwd = getcwd(buf, sizeof buf); extmacro_def("pwd", "%s", cwd); vmod_path = NULL; From dridi.boukelmoune at gmail.com Mon Oct 25 14:40:19 2021 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 25 Oct 2021 14:40:19 +0000 (UTC) Subject: [master] 150f9fd56 cocci: Add a patch for VTIM_timespec() refactoring Message-ID: <20211025144019.6E41FA52F6@lists.varnish-cache.org> commit 150f9fd56390a722395d3d31fe1f68c1d577f33e Author: Dridi Boukelmoune Date: Mon Oct 25 16:31:37 2021 +0200 cocci: Add a patch for VTIM_timespec() refactoring Already archived since there are no more occurrences in trunk, but it could be useful on other branches or third-party libvarnish consumers. The coccinelle patch also takes care of the recent manual refactoring. Refs 4ae73a5b19ec1fc87cc018c01757535667e33341 Refs cf00dd2ed96c9b7a2ccd02846d9bc55719b9b919 diff --git a/bin/varnishd/waiter/cache_waiter_kqueue.c b/bin/varnishd/waiter/cache_waiter_kqueue.c index 8e70af060..b0f097c1b 100644 --- a/bin/varnishd/waiter/cache_waiter_kqueue.c +++ b/bin/varnishd/waiter/cache_waiter_kqueue.c @@ -104,8 +104,7 @@ vwk_thread(void *priv) Wait_Call(w, wp, WAITER_TIMEOUT, now); } then = vwk->next - now; - ts.tv_sec = (time_t)floor(then); - ts.tv_nsec = (long)(1e9 * (then - ts.tv_sec)); + ts = VTIM_timespec(then); Lck_Unlock(&vwk->mtx); n = kevent(vwk->kq, NULL, 0, ke, NKEV, &ts); assert(n >= 0); diff --git a/bin/varnishd/waiter/cache_waiter_ports.c b/bin/varnishd/waiter/cache_waiter_ports.c index 6ae65290c..362a4d940 100644 --- a/bin/varnishd/waiter/cache_waiter_ports.c +++ b/bin/varnishd/waiter/cache_waiter_ports.c @@ -174,8 +174,7 @@ vws_thread(void *priv) Wait_Call(w, wp, WAITER_TIMEOUT, now); } then = vws->next - now; - ts.tv_sec = (time_t)floor(then); - ts.tv_nsec = (long)(1e9 * (then - ts.tv_sec)); + ts = VTIM_timespec(then); /* * min number of events we accept. could consider to scale up diff --git a/tools/coccinelle/archive/vtim_timespec.cocci b/tools/coccinelle/archive/vtim_timespec.cocci new file mode 100644 index 000000000..0e5d561f6 --- /dev/null +++ b/tools/coccinelle/archive/vtim_timespec.cocci @@ -0,0 +1,23 @@ +/* + * This patch refactors to VTIM_timespec(). + */ + +@@ +expression fval, fmod; +struct timespec ts; +type t1, t2; +@@ + +- ts.tv_nsec = (t1)(modf(fval, &fmod) * 1e9); +- ts.tv_sec = (t2)fmod; ++ ts = VTIM_timespec(fval); + +@@ +expression fval; +struct timespec ts; +type t1, t2; +@@ + +- ts.tv_sec = (t1)floor(fval); +- ts.tv_nsec = (t2)(1e9 * (fval - ts.tv_sec)); ++ ts = VTIM_timespec(fval); From nils.goroll at uplex.de Tue Oct 26 09:46:08 2021 From: nils.goroll at uplex.de (Nils Goroll) Date: Tue, 26 Oct 2021 09:46:08 +0000 (UTC) Subject: [master] 006618c0c vcc: do not overwrite SUB symbol properties when call'ing Message-ID: <20211026094608.6C902A1AEF@lists.varnish-cache.org> commit 006618c0c512bf6403ae832094764240440a391b Author: Nils Goroll Date: Mon Oct 25 18:46:14 2021 +0200 vcc: do not overwrite SUB symbol properties when call'ing vcc_act_call() implements use-before-define semantics. To do so, it needs to instantiate SUB symbols if they do not exist. However, it wrongly called VCC_GlobalSymbol() also for existing symbols, overwriting symbol properties. In the case of the built-in subs, the symbol's lname (historically) still is the unescaped literal name, while user defined subs have their name escaped via VCC_GlobalSymbol() -> VCC_PrintCName(). This made the wrong call to VCC_GlobalSymbol() apparent when a built-in sub was called with an explicit "call" action. Besides fixing the VCC_GlobalSymbol() call, we also need to set the lname and rname attributes for built-in SUB symbols initialized in VCC_New(). Alternatively, we could also have used VCC_GlobalSymbol() there, but that would have affected other places where we (still) rely on the known name scheme of built-in subs, e.h. EmitStruct(). While the name unifaction was nice in general, I found the necessary changes (look up SUB symbols) not worth the benefit. Fixes #3719 diff --git a/bin/varnishtest/tests/m00053.vtc b/bin/varnishtest/tests/m00053.vtc index d5c501ea4..97ed034ce 100644 --- a/bin/varnishtest/tests/m00053.vtc +++ b/bin/varnishtest/tests/m00053.vtc @@ -92,9 +92,12 @@ varnish v1 -vcl { sub vcl_backend_fetch { debug.call(priv_top); } + sub vcl_backend_response { + set beresp.status = 200; + } sub vcl_backend_error { # falling through to None backend would be success - set beresp.status = 200; + call vcl_backend_response; return (deliver); } } -start diff --git a/lib/libvcc/vcc_action.c b/lib/libvcc/vcc_action.c index 7c7a57714..0ed675da6 100644 --- a/lib/libvcc/vcc_action.c +++ b/lib/libvcc/vcc_action.c @@ -52,16 +52,16 @@ vcc_act_call(struct vcc *tl, struct token *t, struct symbol *sym) t0 = tl->t; sym = VCC_SymbolGet(tl, SYM_MAIN, SYM_NONE, SYMTAB_PARTIAL_NOERR, XREF_REF); - if (sym == NULL) + if (sym == NULL) { sym = VCC_SymbolGet(tl, SYM_MAIN, SYM_SUB, SYMTAB_CREATE, XREF_REF); - - if (sym == NULL) - return; + if (sym == NULL) + return; + VCC_GlobalSymbol(sym, SUB); + } if (sym->kind == SYM_SUB) { vcc_AddCall(tl, t0, sym); - VCC_GlobalSymbol(sym, SUB); Fb(tl, 1, "%s(ctx, VSUB_STATIC, NULL);\n", sym->lname); SkipToken(tl, ';'); diff --git a/lib/libvcc/vcc_compile.c b/lib/libvcc/vcc_compile.c index 60427d526..d954ea8b9 100644 --- a/lib/libvcc/vcc_compile.c +++ b/lib/libvcc/vcc_compile.c @@ -820,6 +820,7 @@ VCC_New(void) struct vcc *tl; struct symbol *sym; struct proc *p; + struct vsb *vsb; int i; ALLOC_OBJ(tl, VCC_MAGIC); @@ -849,7 +850,25 @@ VCC_New(void) SYM_MAIN, SYM_SUB, VCL_LOW, VCL_HIGH); p = vcc_NewProc(tl, sym); p->method = &method_tab[i]; - VSB_printf(p->cname, "VGC_function_%s", p->method->name); + + // see also VCC_GlobalSymbol() + vsb = VSB_new_auto(); + AN(vsb); + VSB_printf(vsb, "%s_%s", SUB->global_pfx, p->method->name); + AZ(VSB_finish(vsb)); + + AZ(VSB_bcat(p->cname, VSB_data(vsb), VSB_len(vsb))); + + sym->lname = strdup(VSB_data(vsb)); + AN(sym->lname); + + VSB_clear(vsb); + VSB_printf(vsb, "sub_%s", sym->lname); + AZ(VSB_finish(vsb)); + + sym->rname = strdup(VSB_data(vsb)); + AN(sym->rname); + VSB_destroy(&vsb); } tl->sb = VSB_new_auto(); AN(tl->sb); From nils.goroll at uplex.de Tue Oct 26 12:39:06 2021 From: nils.goroll at uplex.de (Nils Goroll) Date: Tue, 26 Oct 2021 12:39:06 +0000 (UTC) Subject: [master] f653000eb vcc: Fix dynamic calls to built-in SUBs and properly check evaluation context Message-ID: <20211026123906.AEF95A70A3@lists.varnish-cache.org> commit f653000eb7a0973bbd9a9cf1acd3060f6db7cff9 Author: Nils Goroll Date: Tue Oct 26 13:33:23 2021 +0200 vcc: Fix dynamic calls to built-in SUBs and properly check evaluation context As a follow-up issue from #3719, it was noticed that dynamic calls to built-in SUBs did not work. This issue was caused by more (struct symbol) members missing initialization in VCC_New(). In turn, it became apparent that the evaluation context check in vcc_expr5() as tested in v00020.vtc only worked by accident, and only for built-in subs because (struct symbol).eval was NULL for built-in subs. We fix SUB type expression evaluation with a type specific evaluation function which allows expression evaluation from explicit SUB contexts only. Fixes #3720 diff --git a/bin/varnishtest/tests/m00053.vtc b/bin/varnishtest/tests/m00053.vtc index 97ed034ce..72e54ab89 100644 --- a/bin/varnishtest/tests/m00053.vtc +++ b/bin/varnishtest/tests/m00053.vtc @@ -98,6 +98,7 @@ varnish v1 -vcl { sub vcl_backend_error { # falling through to None backend would be success call vcl_backend_response; + debug.call(vcl_backend_response); return (deliver); } } -start @@ -205,6 +206,7 @@ varnish v1 -vcl { } sub vcl_init { + new vbr = debug.caller(vcl_backend_response); new c = debug.caller(foo); } diff --git a/bin/varnishtest/tests/v00020.vtc b/bin/varnishtest/tests/v00020.vtc index 603f3a251..a5b37eed3 100644 --- a/bin/varnishtest/tests/v00020.vtc +++ b/bin/varnishtest/tests/v00020.vtc @@ -31,12 +31,31 @@ varnish v1 -errvcl {Comparison of different types: INT '!=' STRING} { } } -varnish v1 -errvcl {Symbol 'vcl_recv' type (sub) can not be used in expression.} { +varnish v1 -errvcl {Symbol 'vcl_recv' can only be used as a SUB expression} { + backend proforma none; sub vcl_recv { set req.http.foo = vcl_recv; } } +varnish v1 -errvcl {Symbol 'vcl_recv' can only be used as a SUB expression} { + backend proforma none; + sub vcl_recv { + return (synth(200)); + } + sub vcl_synth { + set req.http.foo = vcl_recv; + } +} + +varnish v1 -errvcl {Symbol 'asub' can only be used as a SUB expression} { + backend proforma none; + sub asub {} + sub vcl_recv { + set req.http.foo = asub; + } +} + varnish v1 -errvcl {Symbol 'acl' type (reserved) can not be used in expression.} { import std; sub vcl_recv { call acl; } diff --git a/lib/libvcc/vcc_compile.c b/lib/libvcc/vcc_compile.c index d954ea8b9..d3acb0383 100644 --- a/lib/libvcc/vcc_compile.c +++ b/lib/libvcc/vcc_compile.c @@ -64,6 +64,7 @@ #include "libvcc.h" #include "vfil.h" +#include "vct.h" static const struct method method_tab[] = { { "none", 0U, 0}, @@ -869,6 +870,11 @@ VCC_New(void) sym->rname = strdup(VSB_data(vsb)); AN(sym->rname); VSB_destroy(&vsb); + + sym->type = SUB; + sym->kind = VCC_HandleKind(SUB); + AZ(VCT_invalid_name(sym->rname, NULL)); + sym->eval = vcc_Eval_Sub; } tl->sb = VSB_new_auto(); AN(tl->sb); diff --git a/lib/libvcc/vcc_compile.h b/lib/libvcc/vcc_compile.h index 3f3ccc3c0..6ce150c4c 100644 --- a/lib/libvcc/vcc_compile.h +++ b/lib/libvcc/vcc_compile.h @@ -351,6 +351,7 @@ sym_act_f vcc_Act_Obj; void vcc_Expr_Init(struct vcc *tl); sym_expr_t vcc_Eval_Var; sym_expr_t vcc_Eval_Handle; +sym_expr_t vcc_Eval_Sub; sym_expr_t vcc_Eval_SymFunc; sym_expr_t vcc_Eval_TypeMethod; void vcc_Eval_Func(struct vcc *, const struct vjsn_val *, @@ -377,6 +378,7 @@ void vcc_lex_source(struct vcc *tl, struct source *sp, int eoi); void vcc_stevedore(struct vcc *vcc, const char *stv_name); /* vcc_symb.c */ +vcc_kind_t VCC_HandleKind(vcc_type_t fmt); void VCC_PrintCName(struct vsb *vsb, const char *b, const char *e); struct symbol *VCC_MkSym(struct vcc *tl, const char *b, vcc_ns_t, vcc_kind_t, int, int); diff --git a/lib/libvcc/vcc_expr.c b/lib/libvcc/vcc_expr.c index c2e25c871..598a283b4 100644 --- a/lib/libvcc/vcc_expr.c +++ b/lib/libvcc/vcc_expr.c @@ -329,6 +329,29 @@ vcc_Eval_Handle(struct vcc *tl, struct expr **e, struct token *t, } } +void v_matchproto_(sym_expr_t) +vcc_Eval_Sub(struct vcc *tl, struct expr **e, struct token *t, + struct symbol *sym, vcc_type_t type) +{ + + (void)t; + (void)tl; + AN(sym->rname); + AZ(type->stringform); + + assert (sym->type == SUB); + + if (type == SUB) { + *e = vcc_mk_expr(sym->type, "%s", sym->rname); + (*e)->constant = EXPR_CONST; + return; + } + + VSB_printf(tl->sb, "Symbol '%s' can only be used as a %s expression\n", + sym->name, sym->type->name); + vcc_ErrWhere(tl, tl->t); +} + /*-------------------------------------------------------------------- */ diff --git a/lib/libvcc/vcc_symb.c b/lib/libvcc/vcc_symb.c index 5125cda3e..25d824b91 100644 --- a/lib/libvcc/vcc_symb.c +++ b/lib/libvcc/vcc_symb.c @@ -76,7 +76,7 @@ struct symtab { VTAILQ_HEAD(,symbol) symbols; }; -static vcc_kind_t +vcc_kind_t VCC_HandleKind(vcc_type_t fmt) { if (fmt == ACL) return (SYM_ACL); @@ -510,7 +510,10 @@ VCC_GlobalSymbol(struct symbol *sym, vcc_type_t type) sym->kind = VCC_HandleKind(sym->type); if (sym->kind != SYM_NONE) { AZ(VCT_invalid_name(sym->rname, NULL)); - sym->eval = vcc_Eval_Handle; + if (type == SUB) + sym->eval = vcc_Eval_Sub; + else + sym->eval = vcc_Eval_Handle; } else { WRONG("Wrong kind of global symbol"); } From nils.goroll at uplex.de Tue Oct 26 12:39:06 2021 From: nils.goroll at uplex.de (Nils Goroll) Date: Tue, 26 Oct 2021 12:39:06 +0000 (UTC) Subject: [master] 12be3d384 vcc: minor VSB polish Message-ID: <20211026123906.B39C0A70A8@lists.varnish-cache.org> commit 12be3d3849d25e01f4d8fa867e86d1025979c83e Author: Nils Goroll Date: Tue Oct 26 14:35:22 2021 +0200 vcc: minor VSB polish diff --git a/lib/libvcc/vcc_symb.c b/lib/libvcc/vcc_symb.c index 25d824b91..34736072b 100644 --- a/lib/libvcc/vcc_symb.c +++ b/lib/libvcc/vcc_symb.c @@ -496,9 +496,7 @@ VCC_GlobalSymbol(struct symbol *sym, vcc_type_t type) sym->lname = strdup(VSB_data(vsb)); AN(sym->lname); if (type == SUB) { - VSB_destroy(&vsb); - vsb = VSB_new_auto(); - AN(vsb); + VSB_clear(vsb); VSB_printf(vsb, "sub_%s", sym->lname); AZ(VSB_finish(vsb)); } From nils.goroll at uplex.de Tue Oct 26 13:38:06 2021 From: nils.goroll at uplex.de (Nils Goroll) Date: Tue, 26 Oct 2021 13:38:06 +0000 (UTC) Subject: [master] f970f1756 Add std.strftime() Message-ID: <20211026133806.EE6C8A8F0B@lists.varnish-cache.org> commit f970f175654b4471285b8dcb02e326835a3c7730 Author: Nils Goroll Date: Fri May 21 18:44:01 2021 +0200 Add std.strftime() add a vmod function for strftime() formatting in UTC. diff --git a/vmod/tests/std_b00011.vtc b/vmod/tests/std_b00011.vtc index fd61e11fb..bd0735237 100644 --- a/vmod/tests/std_b00011.vtc +++ b/vmod/tests/std_b00011.vtc @@ -1,4 +1,4 @@ -varnishtest "Test std.time" +varnishtest "Test std.time() and std.strftime()" server s1 { rxreq @@ -7,10 +7,17 @@ server s1 { varnish v1 -vcl+backend { import std; + import vtc; sub vcl_deliver { set resp.http.x-date = std.time( regsub(req.http.x-date, "z", " "), now); + if (req.http.over) { + vtc.workspace_alloc(client, -1); + } + set resp.http.utc = std.strftime( + std.time(req.http.x-date, now), + "%Y%m%dT%H%M%SZ"); if (std.time(req.http.x-date, now) < now - 1y) { set resp.http.x-past = 1; } @@ -40,6 +47,7 @@ client c1 { expect resp.status == 200 expect resp.http.x-past == 1 expect resp.http.x-date == "Mon, 20 Dec 2010 00:00:00 GMT" + expect resp.http.utc == "20101220T000000Z" # invalid date txreq -hdr "X-Date: Monday, 20-Dec-30 00:00:00 GMT" \ @@ -63,12 +71,14 @@ client c1 { expect resp.status == 200 expect resp.http.x-future == 1 expect resp.http.x-date == "Fri, 20 Dec 2030 00:00:00 GMT" + expect resp.http.utc == "20301220T000000Z" txreq -hdr "X-Date: Mon Dec 20 00:00:00 2010" rxresp expect resp.status == 200 expect resp.http.x-past == 1 expect resp.http.x-date == "Mon, 20 Dec 2010 00:00:00 GMT" + expect resp.http.utc == "20101220T000000Z" txreq -hdr "X-Date: 2030-12-20T00:00:00" rxresp @@ -76,11 +86,12 @@ client c1 { expect resp.http.x-future == 1 expect resp.http.x-date == "Fri, 20 Dec 2030 00:00:00 GMT" - txreq -hdr "X-Date: 1292803200.00" + txreq -hdr "X-Date: 1055455200.00" rxresp expect resp.status == 200 expect resp.http.x-past == 1 - expect resp.http.x-date == "Mon, 20 Dec 2010 00:00:00 GMT" + expect resp.http.x-date == "Thu, 12 Jun 2003 22:00:00 GMT" + expect resp.http.utc == "20030612T220000Z" txreq -hdr "X-Date: 1923955200" rxresp @@ -88,6 +99,13 @@ client c1 { expect resp.http.x-future == 1 expect resp.http.x-date == "Fri, 20 Dec 2030 00:00:00 GMT" + # overflow + txreq -hdr "X-Date: 1923955200" -hdr "Over: 1" + rxresp + expect resp.status == 500 +} -run + +client c1 { delay .2 # Coverage tests of vtim.c diff --git a/vmod/vmod_std.vcc b/vmod/vmod_std.vcc index 733d41306..c01b29cc2 100644 --- a/vmod/vmod_std.vcc +++ b/vmod/vmod_std.vcc @@ -435,6 +435,20 @@ Examples:: ... } +$Function STRING strftime(TIME time, STRING format) + +Format the *time* argument with the *format* argument using +`strftime(3)` and return the result for the UTC (historically GMT) +timezone. + +The empty string is returned if formatting fails, but may also be +returned as a valid result. + +Example:: + + set req.http.iso = std.strftime(now, "%Y%m%dT%H%M%SZ"); + # e.g. 20210521T175241Z + LOGGING functions ================= @@ -719,3 +733,4 @@ SEE ALSO * :ref:`varnishd(1)` * :ref:`vsl(7)` * `fnmatch(3)` +* `strftime(3)` diff --git a/vmod/vmod_std_conversions.c b/vmod/vmod_std_conversions.c index 662aec4b5..275e65622 100644 --- a/vmod/vmod_std_conversions.c +++ b/vmod/vmod_std_conversions.c @@ -326,6 +326,33 @@ vmod_time(VRT_CTX, struct VARGS(time)* a) return (0); } +VCL_STRING v_matchproto_(td_std_strftime) +vmod_strftime(VRT_CTX, VCL_TIME t, VCL_STRING fmt) +{ + struct tm tm; + time_t tt; + size_t r; + unsigned spc; + char *s; + + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + + tt = (time_t)(intmax_t)t; + if (gmtime_r(&tt, &tm) == NULL) + return (""); + + spc = WS_ReserveAll(ctx->ws); + s = WS_Reservation(ctx->ws); + r = strftime(s, spc, fmt, &tm); + if (r == 0) { + WS_Release(ctx->ws, 0); + return (""); + } + r++; + WS_Release(ctx->ws, r); + return (s); +} + /* These functions are deprecated as of 2019-03-15 release */ VCL_INT v_matchproto_(td_std_real2integer) From nils.goroll at uplex.de Tue Oct 26 13:40:08 2021 From: nils.goroll at uplex.de (Nils Goroll) Date: Tue, 26 Oct 2021 13:40:08 +0000 (UTC) Subject: [master] 0577bac0a Assert that if a connection is closed before being used, it is so for a reason Message-ID: <20211026134008.24011A9175@lists.varnish-cache.org> commit 0577bac0a1ef9247bffcd9c923b35367a5bb5b17 Author: Nils Goroll Date: Mon Aug 16 16:08:14 2021 +0200 Assert that if a connection is closed before being used, it is so for a reason ... but we can not make any assumption as to why Fixes #3664 diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c index 829b56595..063048931 100644 --- a/bin/varnishd/cache/cache_backend.c +++ b/bin/varnishd/cache/cache_backend.c @@ -233,15 +233,8 @@ vbe_dir_finish(VRT_CTX, VCL_BACKEND d) CHECK_OBJ_NOTNULL(bo->htc, HTTP_CONN_MAGIC); pfd = bo->htc->priv; bo->htc->priv = NULL; - if (PFD_State(pfd) != PFD_STATE_USED) { + if (PFD_State(pfd) != PFD_STATE_USED) AN(bo->htc->doclose); - if (bo->htc->doclose != SC_TX_PIPE) { -#define SESS_CLOSE(U, l, err, desc) \ - if (bo->htc->doclose == SC_ ## U) \ - AN(err); -#include "tbl/sess_close.h" - } - } if (bo->htc->doclose != SC_NULL || bp->proxy_header != 0) { VSLb(bo->vsl, SLT_BackendClose, "%d %s close", *PFD_Fd(pfd), VRT_BACKEND_string(d)); From nils.goroll at uplex.de Tue Oct 26 15:14:07 2021 From: nils.goroll at uplex.de (Nils Goroll) Date: Tue, 26 Oct 2021 15:14:07 +0000 (UTC) Subject: [master] 85c04cb96 gc stray declaration Message-ID: <20211026151408.048BBABD01@lists.varnish-cache.org> commit 85c04cb9670940823a1231b449d6764fb9ade9c1 Author: Nils Goroll Date: Tue Oct 26 17:12:16 2021 +0200 gc stray declaration Ref 611baec6f29681bc1cc3836e635dfa14cca3d018 diff --git a/include/vrt.h b/include/vrt.h index 1406e7b59..005e485bb 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -486,7 +486,6 @@ VCL_VOID VRT_call(VRT_CTX, VCL_SUB); VCL_STRING VRT_BACKEND_string(VCL_BACKEND); VCL_STRING VRT_BOOL_string(VCL_BOOL); VCL_STRING VRT_BLOB_string(VRT_CTX, VCL_BLOB); -VCL_STRING VRT_CollectString(VRT_CTX, const char *p, ...); VCL_STRING VRT_INT_string(VRT_CTX, VCL_INT); VCL_STRING VRT_IP_string(VRT_CTX, VCL_IP); VCL_STRING VRT_REAL_string(VRT_CTX, VCL_REAL); From phk at FreeBSD.org Tue Oct 26 18:03:06 2021 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 26 Oct 2021 18:03:06 +0000 (UTC) Subject: [master] c1ad57b12 Change the VJSN API to work on OSX Message-ID: <20211026180306.D9B7AB0B05@lists.varnish-cache.org> commit c1ad57b12f6e1c585af4560eec3a6d1ba0de1cc2 Author: Poul-Henning Kamp Date: Tue Oct 26 17:58:41 2021 +0000 Change the VJSN API to work on OSX When VJSN is both in libvarnish and libvarnishapi, as in varnishtest, you would think one of them took precedence, but not so on OSX. In the shlib (libvarnishapi) text (code) symbols come from the version in the main binary (varnishtest) which got it from libvarnish, whereas the data symbols come from the version in libvarnishapi, so we now hide the data symbols behind code. diff --git a/bin/varnishadm/varnishadm.c b/bin/varnishadm/varnishadm.c index 1a7f7c00c..306564416 100644 --- a/bin/varnishadm/varnishadm.c +++ b/bin/varnishadm/varnishadm.c @@ -258,21 +258,21 @@ command_generator (const char *text, int state) free(answer); AN(jsn_cmds); AN(jsn_cmds->value); - assert (jsn_cmds->value->type == VJSN_ARRAY); + assert (vjsn_is_array(jsn_cmds->value)); jv = VTAILQ_FIRST(&jsn_cmds->value->children); - assert (jv->type == VJSN_NUMBER); + assert (vjsn_is_number(jv)); jv = VTAILQ_NEXT(jv, list); - assert (jv->type == VJSN_ARRAY); + assert (vjsn_is_array(jv)); jv = VTAILQ_NEXT(jv, list); - assert (jv->type == VJSN_NUMBER); + assert (vjsn_is_number(jv)); jv = VTAILQ_NEXT(jv, list); } while (jv != NULL) { - assert (jv->type == VJSN_OBJECT); + assert (vjsn_is_object(jv)); jv2 = VTAILQ_FIRST(&jv->children); AN(jv2); jv = VTAILQ_NEXT(jv, list); - assert (jv2->type == VJSN_STRING); + assert (vjsn_is_string(jv2)); assert (!strcmp(jv2->name, "request")); if (!strncmp(text, jv2->value, strlen(text))) return (strdup(jv2->value)); diff --git a/bin/varnishd/mgt/mgt_symtab.c b/bin/varnishd/mgt/mgt_symtab.c index 88b9aa844..754a6d528 100644 --- a/bin/varnishd/mgt/mgt_symtab.c +++ b/bin/varnishd/mgt/mgt_symtab.c @@ -54,7 +54,7 @@ mgt_vcl_symtab_val(const struct vjsn_val *vv, const char *val) jv = vjsn_child(vv, val); AN(jv); - assert(jv->type == VJSN_STRING); + assert(vjsn_is_string(jv)); AN(jv->value); return (jv->value); } @@ -165,13 +165,13 @@ mgt_vcl_symtab(struct vclprog *vp, const char *input) AZ(err); AN(vj); vp->symtab = vj; - assert(vj->value->type == VJSN_ARRAY); + assert(vjsn_is_array(vj->value)); VTAILQ_FOREACH(v1, &vj->value->children, list) { - assert(v1->type == VJSN_OBJECT); + assert(vjsn_is_object(v1)); v2 = vjsn_child(v1, "dir"); if (v2 == NULL) continue; - assert(v2->type == VJSN_STRING); + assert(vjsn_is_string(v2)); if (strcmp(v2->value, "import")) continue; typ = mgt_vcl_symtab_val(v1, "type"); diff --git a/include/vjsn.h b/include/vjsn.h index 15a9eaa46..e4b8eb827 100644 --- a/include/vjsn.h +++ b/include/vjsn.h @@ -28,13 +28,14 @@ * SUCH DAMAGE. */ -extern const char VJSN_OBJECT[]; -extern const char VJSN_ARRAY[]; -extern const char VJSN_NUMBER[]; -extern const char VJSN_STRING[]; -extern const char VJSN_TRUE[]; -extern const char VJSN_FALSE[]; -extern const char VJSN_NULL[]; +#define VJSN_TYPES \ + VJSN_TYPE_MACRO(OBJECT, object) \ + VJSN_TYPE_MACRO(ARRAY, array) \ + VJSN_TYPE_MACRO(NUMBER, number) \ + VJSN_TYPE_MACRO(STRING, string) \ + VJSN_TYPE_MACRO(TRUE, true) \ + VJSN_TYPE_MACRO(FALSE, false) \ + VJSN_TYPE_MACRO(NULL, null) struct vjsn_val { unsigned magic; @@ -64,3 +65,8 @@ void vjsn_delete(struct vjsn **); void vjsn_dump(const struct vjsn *js, FILE *fo); void vjsn_dump_val(const struct vjsn_val *jsv, FILE *fo); struct vjsn_val *vjsn_child(const struct vjsn_val *, const char *); + +#define VJSN_TYPE_MACRO(UPPER, lower) \ + int vjsn_is_##lower(const struct vjsn_val *jsv); +VJSN_TYPES +#undef VJSN_TYPE_MACRO diff --git a/lib/libvarnish/vjsn.c b/lib/libvarnish/vjsn.c index 8b5444703..62163415a 100644 --- a/lib/libvarnish/vjsn.c +++ b/lib/libvarnish/vjsn.c @@ -43,13 +43,10 @@ #include "vqueue.h" #include "vjsn.h" -const char VJSN_OBJECT[] = "object"; -const char VJSN_ARRAY[] = "array"; -const char VJSN_NUMBER[] = "number"; -const char VJSN_STRING[] = "string"; -const char VJSN_TRUE[] = "true"; -const char VJSN_FALSE[] = "false"; -const char VJSN_NULL[] = "null"; +#define VJSN_TYPE_MACRO(UPPER, lower) \ + static const char VJSN_##UPPER[] = #lower; +VJSN_TYPES +#undef VJSN_TYPE_MACRO #define VJSN_EXPECT(js, xxx, ret) \ do { \ @@ -504,6 +501,17 @@ vjsn_dump(const struct vjsn *js, FILE *fo) vjsn_dump_i(js->value, fo, 0); } +#define VJSN_TYPE_MACRO(UPPER, lower) \ + int \ + vjsn_is_##lower(const struct vjsn_val *jsv) \ + { \ + CHECK_OBJ_NOTNULL(jsv, VJSN_VAL_MAGIC); \ + return (jsv->type == VJSN_##UPPER); \ + } +VJSN_TYPES +#undef VJSN_TYPE_MACRO + + #ifdef VJSN_TEST /* diff --git a/lib/libvarnishapi/vsc.c b/lib/libvarnishapi/vsc.c index 2fdcfe740..4d2f65c03 100644 --- a/lib/libvarnishapi/vsc.c +++ b/lib/libvarnishapi/vsc.c @@ -237,7 +237,7 @@ vsc_fill_point(const struct vsc *vsc, const struct vsc_seg *seg, vt = vjsn_child(vv, "name"); AN(vt); - assert(vt->type == VJSN_STRING); + assert(vjsn_is_string(vt)); VSB_clear(vsb); VSB_printf(vsb, "%s.%s", seg->fantom->ident, vt->value); @@ -253,7 +253,7 @@ vsc_fill_point(const struct vsc *vsc, const struct vsc_seg *seg, #define DOF(n, k) \ vt = vjsn_child(vv, k); \ AN(vt); \ - assert(vt->type == VJSN_STRING); \ + assert(vjsn_is_string(vt)); \ point->point.n = vt->value; DOF(ctype, "ctype"); @@ -262,7 +262,7 @@ vsc_fill_point(const struct vsc *vsc, const struct vsc_seg *seg, #undef DOF vt = vjsn_child(vv, "type"); AN(vt); - assert(vt->type == VJSN_STRING); + assert(vjsn_is_string(vt)); if (!strcmp(vt->value, "counter")) { point->point.semantics = 'c'; @@ -276,7 +276,7 @@ vsc_fill_point(const struct vsc *vsc, const struct vsc_seg *seg, vt = vjsn_child(vv, "format"); AN(vt); - assert(vt->type == VJSN_STRING); + assert(vjsn_is_string(vt)); if (!strcmp(vt->value, "integer")) { point->point.format = 'i'; @@ -292,7 +292,7 @@ vsc_fill_point(const struct vsc *vsc, const struct vsc_seg *seg, vt = vjsn_child(vv, "level"); AN(vt); - assert(vt->type == VJSN_STRING); + assert(vjsn_is_string(vt)); if (!strcmp(vt->value, "info")) { point->point.level = &levels[info]; diff --git a/lib/libvcc/vcc_expr.c b/lib/libvcc/vcc_expr.c index 598a283b4..1c601931c 100644 --- a/lib/libvcc/vcc_expr.c +++ b/lib/libvcc/vcc_expr.c @@ -496,7 +496,7 @@ vcc_func(struct vcc *tl, struct expr **e, const void *priv, int n; CAST_OBJ_NOTNULL(vv, priv, VJSN_VAL_MAGIC); - assert(vv->type == VJSN_ARRAY); + assert(vjsn_is_array(vv)); vv = VTAILQ_FIRST(&vv->children); rfmt = VCC_Type(VTAILQ_FIRST(&vv->children)->value); AN(rfmt); @@ -530,7 +530,7 @@ vcc_func(struct vcc *tl, struct expr **e, const void *priv, } VTAILQ_INIT(&head); for (;vv != NULL; vv = VTAILQ_NEXT(vv, list)) { - assert(vv->type == VJSN_ARRAY); + assert(vjsn_is_array(vv)); fa = calloc(1, sizeof *fa); AN(fa); fa->cname = cfunc; @@ -559,7 +559,7 @@ vcc_func(struct vcc *tl, struct expr **e, const void *priv, } } } - if (sa != NULL && vvp != NULL && vvp->type == VJSN_TRUE) { + if (sa != NULL && vvp != NULL && vjsn_is_true(vvp)) { fa->optional = 1; vvp = VTAILQ_NEXT(vvp, list); } diff --git a/lib/libvcc/vcc_vmod.c b/lib/libvcc/vcc_vmod.c index 496164f23..2b5ec5959 100644 --- a/lib/libvcc/vcc_vmod.c +++ b/lib/libvcc/vcc_vmod.c @@ -108,15 +108,15 @@ func_sym(struct vcc *tl, vcc_kind_t kind, const struct symbol *psym, v = VTAILQ_NEXT(v, list); - assert(v->type == VJSN_ARRAY); + assert(vjsn_is_array(v)); sym->action = vcc_Act_Call; sym->vmod_name = psym->vmod_name; sym->eval = vcc_Eval_SymFunc; sym->eval_priv = v; v = VTAILQ_FIRST(&v->children); - assert(v->type == VJSN_ARRAY); + assert(vjsn_is_array(v)); v = VTAILQ_FIRST(&v->children); - assert(v->type == VJSN_STRING); + assert(vjsn_is_string(v)); sym->type = VCC_Type(v->value); AN(sym->type); sym->r_methods = VCL_MET_TASK_ALL; @@ -134,9 +134,9 @@ vcc_json_always(struct vcc *tl, const struct vjsn *vj, const char *vmod_name) ifp = NULL; VTAILQ_FOREACH(vv, &vj->value->children, list) { - assert(vv->type == VJSN_ARRAY); + assert(vjsn_is_array(vv)); vv2 = VTAILQ_FIRST(&vv->children); - assert(vv2->type == VJSN_STRING); + assert(vjsn_is_string(vv2)); if (!strcmp(vv2->value, "$VMOD")) { vmod_syntax = strtod(VTAILQ_NEXT(vv2, list)->value, NULL); @@ -281,12 +281,12 @@ vcc_VmodSymbols(struct vcc *tl, const struct symbol *sym) } for (; vv != NULL; vv = VTAILQ_NEXT(vv, list)) { - if (vv->type != VJSN_ARRAY) + if (!vjsn_is_array(vv)) continue; vv1 = VTAILQ_FIRST(&vv->children); - assert(vv1->type == VJSN_STRING); + assert(vjsn_is_string(vv1)); vv2 = VTAILQ_NEXT(vv1, list); - if (vv2->type != VJSN_STRING) + if (!vjsn_is_string(vv2)) continue; kind = vcc_vmod_kind(vv1->value); @@ -499,9 +499,9 @@ vcc_Act_New(struct vcc *tl, struct token *t, struct symbol *sym) vv = VTAILQ_NEXT(vv, list); // vv = flags - assert(vv->type == VJSN_OBJECT); + assert(vjsn_is_object(vv)); VTAILQ_FOREACH(vf, &vv->children, list) - if (!strcmp(vf->name, "NULL_OK") && vf->type == VJSN_TRUE) + if (!strcmp(vf->name, "NULL_OK") && vjsn_is_true(vf)) null_ok = 1; if (!null_ok) VTAILQ_INSERT_TAIL(&tl->sym_objects, isym, sideways); @@ -514,7 +514,7 @@ vcc_Act_New(struct vcc *tl, struct token *t, struct symbol *sym) vf = VTAILQ_FIRST(&vv->children); vv = VTAILQ_NEXT(vv, list); - assert(vf->type == VJSN_STRING); + assert(vjsn_is_string(vf)); assert(!strcmp(vf->value, "$INIT")); vf = VTAILQ_NEXT(vf, list); @@ -530,7 +530,7 @@ vcc_Act_New(struct vcc *tl, struct token *t, struct symbol *sym) isym->def_e = tl->t; vf = VTAILQ_FIRST(&vv->children); - assert(vf->type == VJSN_STRING); + assert(vjsn_is_string(vf)); assert(!strcmp(vf->value, "$FINI")); vf = VTAILQ_NEXT(vf, list); From phk at FreeBSD.org Tue Oct 26 20:14:10 2021 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 26 Oct 2021 20:14:10 +0000 (UTC) Subject: [master] 7d5da1680 Dont use pthread_condattr_setclock(2) anyway, OSX does not have it. Message-ID: <20211026201411.59C9F603BD@lists.varnish-cache.org> commit 7d5da1680b7d2cbcf5da4331f65eb42377e48bec Author: Poul-Henning Kamp Date: Tue Oct 26 18:07:50 2021 +0000 Dont use pthread_condattr_setclock(2) anyway, OSX does not have it. diff --git a/bin/varnishhist/varnishhist.c b/bin/varnishhist/varnishhist.c index 27d4f9289..9a4d58917 100644 --- a/bin/varnishhist/varnishhist.c +++ b/bin/varnishhist/varnishhist.c @@ -366,8 +366,8 @@ accumulate(struct VSL_data *vsl, struct VSL_transaction * const pt[], vsl_to = vsl_t0 + (t - t0) * timebend; if (vsl_ts > vsl_to) { - struct timespec ts; - ts = VTIM_timespec(vsl_ts - vsl_to); + double when = VTIM_real() + vsl_ts - vsl_to; + struct timespec ts = VTIM_timespec(when); i = pthread_cond_timedwait(&timebend_cv, &mtx, &ts); assert(i == 0 || i == ETIMEDOUT); } @@ -485,13 +485,10 @@ main(int argc, char **argv) pthread_t thr; int fnum; struct profile cli_p = {0}; - pthread_condattr_t ca; vut = VUT_InitProg(argc, argv, &vopt_spec); AN(vut); - AZ(pthread_condattr_init(&ca)); - AZ(pthread_condattr_setclock(&ca, CLOCK_MONOTONIC)); - AZ(pthread_cond_init(&timebend_cv, &ca)); + AZ(pthread_cond_init(&timebend_cv, NULL)); while ((i = getopt(argc, argv, vopt_spec.vopt_optstring)) != -1) { switch (i) { From phk at FreeBSD.org Tue Oct 26 20:14:10 2021 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 26 Oct 2021 20:14:10 +0000 (UTC) Subject: [master] 37d1f705d Also give up on pthread_condattr_setclock(2) here: OSX does not support it Message-ID: <20211026201411.9683E603BE@lists.varnish-cache.org> commit 37d1f705de2d7d28e548e4e435bb6824a397585a Author: Poul-Henning Kamp Date: Tue Oct 26 20:13:35 2021 +0000 Also give up on pthread_condattr_setclock(2) here: OSX does not support it diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index e9803d8d1..f35b0ab69 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -685,7 +685,6 @@ int Lck__Trylock(struct lock *lck, const char *p, int l); void Lck__New(struct lock *lck, struct VSC_lck *, const char *); int Lck__Held(const struct lock *lck); int Lck__Owned(const struct lock *lck); -extern pthread_condattr_t condattr_monotime; extern pthread_mutexattr_t mtxattr_errorcheck; /* public interface: */ diff --git a/bin/varnishd/cache/cache_main.c b/bin/varnishd/cache/cache_main.c index 0e81c3928..645bfbd04 100644 --- a/bin/varnishd/cache/cache_main.c +++ b/bin/varnishd/cache/cache_main.c @@ -58,7 +58,6 @@ volatile struct params *cache_param; static pthread_mutex_t cache_vrnd_mtx; pthread_mutexattr_t mtxattr_errorcheck; -pthread_condattr_t condattr_monotime; static void cache_vrnd_lock(void) @@ -368,8 +367,6 @@ child_main(int sigmagic, size_t altstksz) /* Before anything uses pthreads in anger */ AZ(pthread_mutexattr_init(&mtxattr_errorcheck)); AZ(pthread_mutexattr_settype(&mtxattr_errorcheck, PTHREAD_MUTEX_ERRORCHECK)); - AZ(pthread_condattr_init(&condattr_monotime)); - AZ(pthread_condattr_setclock(&condattr_monotime, CLOCK_MONOTONIC)); cache_param = heritage.param; From phk at FreeBSD.org Wed Oct 27 08:37:05 2021 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 27 Oct 2021 08:37:05 +0000 (UTC) Subject: [master] d26b13053 Stabilize m00000 Message-ID: <20211027083705.7AA2CA59BE@lists.varnish-cache.org> commit d26b130534629254a76f1603064ca8e7abaa2faf Author: Poul-Henning Kamp Date: Wed Oct 27 08:36:24 2021 +0000 Stabilize m00000 diff --git a/bin/varnishtest/tests/m00000.vtc b/bin/varnishtest/tests/m00000.vtc index fb3a90e3d..694d1559d 100644 --- a/bin/varnishtest/tests/m00000.vtc +++ b/bin/varnishtest/tests/m00000.vtc @@ -78,12 +78,16 @@ client c1 { expect resp.status == 503 } -run +varnish v1 -vsl_catchup + client c1 { txreq -url "/priv-task-no-mem" rxresp expect resp.status == 503 } -run +varnish v1 -vsl_catchup + varnish v1 -expect DEBUG.count == 1 logexpect l1 -v v1 -g raw -d 1 { @@ -268,6 +272,8 @@ client c1 { expect resp.http.uzp-match == true } -run +varnish v1 -vsl_catchup + varnish v1 -vcl+backend { } varnish v1 -cliok "debug.vmod" @@ -279,6 +285,8 @@ varnish v1 -cliok "vcl.discard vcl[1-8]" varnish v1 -cliok "vcl.list" varnish v1 -cliok "debug.vmod" +delay .5 + varnish v1 -expect vmods == 0 varnish v1 -errvcl {Symbol 'std' type (vmod) can not be used in expression.} { From phk at FreeBSD.org Wed Oct 27 09:26:06 2021 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 27 Oct 2021 09:26:06 +0000 (UTC) Subject: [master] da6de540b In pass mode, postpone close if response is outstanding Message-ID: <20211027092606.90A5EA7149@lists.varnish-cache.org> commit da6de540b592411aa3f0e19a3d9b12ce30af879d Author: Poul-Henning Kamp Date: Wed Oct 27 09:24:43 2021 +0000 In pass mode, postpone close if response is outstanding diff --git a/bin/varnishadm/varnishadm.c b/bin/varnishadm/varnishadm.c index 306564416..83b86f7f1 100644 --- a/bin/varnishadm/varnishadm.c +++ b/bin/varnishadm/varnishadm.c @@ -341,6 +341,7 @@ pass(int sock) char buf[1024]; int i; ssize_t n; + int busy = 0; fds[0].fd = sock; fds[0].events = POLLIN; @@ -352,16 +353,22 @@ pass(int sock) continue; } assert(i > 0); - if (fds[0].revents & POLLIN) + if (fds[0].revents & POLLIN) { (void)pass_answer(fds[0].fd, pass_script); + busy = 0; + if (fds[1].fd < 0) + RL_EXIT(0); + } if (fds[1].revents & POLLIN || fds[1].revents & POLLHUP) { n = read(fds[1].fd, buf, sizeof buf - 1); if (n == 0) { - AZ(shutdown(sock, SHUT_WR)); + if (!busy) + RL_EXIT(0); fds[1].fd = -1; } else if (n < 0) { RL_EXIT(0); } else { + busy = 1; buf[n] = '\0'; cli_write(sock, buf); } From phk at FreeBSD.org Wed Oct 27 10:42:05 2021 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 27 Oct 2021 10:42:05 +0000 (UTC) Subject: [master] b16cea796 Dont rely on realpath(1), OSX does not have it. Message-ID: <20211027104205.D0951A95F2@lists.varnish-cache.org> commit b16cea796f519bda1ba0b45f24e9f3933c5c3e3c Author: Poul-Henning Kamp Date: Wed Oct 27 10:41:03 2021 +0000 Dont rely on realpath(1), OSX does not have it. diff --git a/doc/sphinx/Makefile.am b/doc/sphinx/Makefile.am index 45ec33345..56a3a9096 100644 --- a/doc/sphinx/Makefile.am +++ b/doc/sphinx/Makefile.am @@ -22,7 +22,7 @@ clean: .PHONY: link_srcdir link_srcdir: graphviz conf.py $(BUILT_SOURCES) if test "x$(srcdir)" != "x$(builddir)" && test ! -f index.rst; then \ - s=`realpath $(srcdir)`; \ + s=`cd $(srcdir) && pwd`; \ for f in `cd $$s && find . -type f`; do \ d=`dirname $$f`; \ test -d $$d || mkdir -p $$d; \ From nils.goroll at uplex.de Wed Oct 27 13:14:08 2021 From: nils.goroll at uplex.de (Nils Goroll) Date: Wed, 27 Oct 2021 13:14:08 +0000 (UTC) Subject: [master] cc1255d64 Replace VCL_INT_MAX/VCL_INT_MIN with VRT_INTEGER_MIN/VRT_INTEGER_MAX Message-ID: <20211027131408.71B92AD9C7@lists.varnish-cache.org> commit cc1255d641f9ece13f94bbadb80bb1245cf1d928 Author: Nils Goroll Date: Wed Oct 27 15:09:42 2021 +0200 Replace VCL_INT_MAX/VCL_INT_MIN with VRT_INTEGER_MIN/VRT_INTEGER_MAX diff --git a/vmod/tests/std_b00004.vtc b/vmod/tests/std_b00004.vtc index 784c887df..3d28fcffa 100644 --- a/vmod/tests/std_b00004.vtc +++ b/vmod/tests/std_b00004.vtc @@ -79,7 +79,7 @@ client c1 { expect resp.http.iszero == true expect resp.http.converted == 0 - # VCL_INT_MAX + # VRT_INTEGER_MAX txreq -hdr "foo: 999999999999999" \ -hdr "bytes: 999999999999999b" \ -hdr "duration: 999999999999.999s" \ @@ -95,7 +95,7 @@ client c1 { expect resp.http.real == 999999999999 expect resp.http.time == 999999999999 - # VCL_INT_MIN + # VRT_INTEGER_MIN txreq -hdr "foo: -999999999999999" \ -hdr "duration: -999999999999s" \ -hdr "real: -999999999999" diff --git a/vmod/vmod_std_conversions.c b/vmod/vmod_std_conversions.c index 275e65622..4ce88474b 100644 --- a/vmod/vmod_std_conversions.c +++ b/vmod/vmod_std_conversions.c @@ -47,18 +47,14 @@ #include "vcc_std_if.h" /* - * technically, as our VCL_INT is int64_t, its limits are INT64_MIN/INT64_MAX. + * technically, as our VCL_INT is int64_t, its limits are INT64_MIN + * .. INT64_MAX. * - * Yet, for conversions, we use VNUMpfx with a double intermediate, so above - * 2^53 we see rounding errors. In order to catch a potential floor rounding - * error, we make our limit 2^53-1 - * - * Ref: https://stackoverflow.com/a/1848762 + * We redistrict to VRT_INTEGER_MIN .. VRT_INTEGER_MAX */ -#define VCL_INT_MAX ((INT64_C(1)<<53)-1) -#define VCL_INT_MIN (-VCL_INT_MAX) -#define VCL_BYTES_MAX VCL_INT_MAX +/* limited by using double for conversions */ +#define VCL_BYTES_MAX ((INT64_C(1)<<53)-1) static int onearg(VRT_CTX, const char *f, int nargs) @@ -185,7 +181,7 @@ vmod_integer(VRT_CTX, struct VARGS(integer) *a) if (!isnan(r)) { r = trunc(r); - if (r >= VCL_INT_MIN && r <= VCL_INT_MAX) + if (r >= VRT_INTEGER_MIN && r <= VRT_INTEGER_MAX) return ((VCL_INT)r); } @@ -389,7 +385,7 @@ vmod_time2integer(VRT_CTX, VCL_TIME t, VCL_INT i) if (!isfinite(t)) return (i); t = round(t); - if (t > VCL_INT_MAX || t < VCL_INT_MIN) + if (t > VRT_INTEGER_MAX || t < VRT_INTEGER_MIN) return (i); return ((VCL_INT)t); } From phk at FreeBSD.org Wed Oct 27 16:33:07 2021 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 27 Oct 2021 16:33:07 +0000 (UTC) Subject: [master] 36e0454e4 Work around OSX returning EINVAL to pthread_cond_timedwait() Message-ID: <20211027163308.0E8697885@lists.varnish-cache.org> commit 36e0454e460ca921ef6db3b25947868f7f99bb90 Author: Poul-Henning Kamp Date: Wed Oct 27 16:32:05 2021 +0000 Work around OSX returning EINVAL to pthread_cond_timedwait() diff --git a/bin/varnishd/cache/cache_lck.c b/bin/varnishd/cache/cache_lck.c index aeb228e46..827a12343 100644 --- a/bin/varnishd/cache/cache_lck.c +++ b/bin/varnishd/cache/cache_lck.c @@ -229,6 +229,34 @@ Lck_CondWaitUntil(pthread_cond_t *cond, struct lock *lck, vtim_real when) struct ilck *ilck; struct timespec ts; +#if defined (__APPLE__) + /* + * I hate woo-doo programming in all it's forms and all it's + * manifestations, but for reasons I utterly fail to isolate + * yielding here is stops OSX from throwing a EINVAL to the + * pthread_cond_wait(3) call. + * + * I have tried very hard to determine if any of the three + * arguments are in fact invalid, and found nothing which + * even hints that it might be the case, and with high probability + * repeating the failed call with the exact same arguments + * will succeed. + * + * If you want to dive into this you can trigger the situation + * approx 30% of the time with: + * + * cd .../vmods && make -j check + * + * Env: + * Darwin Kernel Version 20.5.0: + * Sat May 8 05:10:31 PDT 2021; + * root:xnu-7195.121.3~9/RELEASE_ARM64_T8101 arm64 + * + * 20211027 /phk + */ + pthread_yield_np(); +#endif + AN(lck); CAST_OBJ_NOTNULL(ilck, lck->priv, ILCK_MAGIC); AN(ilck->held); @@ -242,19 +270,6 @@ Lck_CondWaitUntil(pthread_cond_t *cond, struct lock *lck, vtim_real when) ts = VTIM_timespec(when); assert(ts.tv_nsec >= 0 && ts.tv_nsec <= 999999999); errno = pthread_cond_timedwait(cond, &ilck->mtx, &ts); -#if defined (__APPLE__) - if (errno == EINVAL && when <= VTIM_real()) { - /* - * Most kernels treat this as honest error, - * recognizing that a thread has no way to - * prevent being descheduled between a user- - * land check of the timestamp, and getting - * the timestamp into the kernel before it - * expires. OS/X on the other hand... - */ - errno = ETIMEDOUT; - } -#endif assert(errno == 0 || errno == ETIMEDOUT || errno == EINTR); From nils.goroll at uplex.de Fri Oct 29 15:01:22 2021 From: nils.goroll at uplex.de (Nils Goroll) Date: Fri, 29 Oct 2021 15:01:22 +0000 (UTC) Subject: [master] 6a18074cf Duplicate v00016.vtc to v00022.vtc Message-ID: <20211029150122.A5A8F613D1@lists.varnish-cache.org> commit 6a18074cfce2954a13d3303eaa255daed470e6f5 Author: Nils Goroll Date: Fri Oct 29 16:55:02 2021 +0200 Duplicate v00016.vtc to v00022.vtc diff --git a/bin/varnishtest/tests/v00022.vtc b/bin/varnishtest/tests/v00022.vtc new file mode 100644 index 000000000..f4421a166 --- /dev/null +++ b/bin/varnishtest/tests/v00022.vtc @@ -0,0 +1,150 @@ +varnishtest "Various VCL compiler coverage tests" + +feature dns + +shell "true > ${tmpdir}/_varnishtest_empty_file" + +varnish v1 -vcl { + backend b { .host = "${localhost}"; } + include "${tmpdir}/_varnishtest_empty_file" ; +} + +varnish v1 -errvcl {include not followed by semicolon.} { + backend b { .host = "${localhost}"; } + include "${tmpdir}/_varnishtest_empty_file" | +} + +shell "rm -f ${tmpdir}/_varnishtest_empty_file" + +varnish v1 -errvcl {include not followed by string constant.} { + backend b { .host = "${localhost}"; } + include << +} + +varnish v1 -errvcl {include not followed by string constant.} { + /* token test */ + error lookup hash pipe pass fetch deliver discard keep restart + include + if else elseif elsif + ++ -- && || <= == != >= >> << += -= *= /= + { } ( ) * + - / % > < = ; ! & . | ~ , +} + +varnish v1 -errvcl {Unknown duration unit 'k'} { + backend b { .host = "${localhost}"; } + sub vcl_backend_response { set beresp.ttl = 1. k; } +} + +varnish v1 -errvcl {Operator > not possible on BACKEND} { + backend a { .host = "${localhost}"; } + backend b { .host = "${localhost}"; } + sub vcl_recv { if (a > b) { } } +} + +varnish v1 -errvcl {Unknown property 'foo' for type HTTP} { + backend b { .host = "${localhost}"; } + sub vcl_hash { if (req.foo != "bar") { } } +} + +varnish v1 -errvcl {Symbol not found: 'foo.bar'} { + sub vcl_init { + new bar = foo.bar(); + } +} + +varnish v1 -errvcl {Cannot be set in subroutine 'vcl_pipe'} { + backend b { .host = "${localhost}"; } + sub vcl_pipe { + set bereq.first_byte_timeout = 10s; + } +} + +varnish v1 -errvcl {Cannot be set in subroutine 'vcl_pipe'.} { + backend b { .host = "${localhost}"; } + sub vcl_pipe { + set bereq.between_bytes_timeout = 10s; + } +} + +varnish v1 -errvcl {Undefined backend c, first reference:} { + backend b { .host = "${localhost}"; } + sub vcl_backend_response { + if (beresp.backend == c) { + set beresp.ttl = 1h; + } + } +} + +varnish v1 -errvcl {Regexp compilation error:} { + backend b { .host = "${localhost}"; } + sub vcl_recv { + if (req.url ~ "[a") {} + } +} + +varnish v1 -errvcl {resolves to too many addresses} { + backend b { .host = "${localhost}"; } + sub vcl_recv { + if (remote.ip == "dns-canary-multi.varnish-cache.org") {} + } +} + +varnish v1 -errvcl {Expression has type directors.shard, expected ACL} { + import directors; + backend b { .host = "${localhost}"; } + + sub vcl_init { + new foo = directors.shard(); + } + sub vcl_recv { + if (client.ip ~ foo) { + return (synth(200)); + } + } +} + +varnish v1 -syntax 4.0 -errvcl {Expression has type directors.shard, expected ACL} { + import directors; + backend b { .host = "${localhost}"; } + + sub vcl_init { + new foo = directors.shard(); + } + sub vcl_recv { + if (client.ip ~ foo) { + return (synth(200)); + } + } +} + +varnish v1 -errvcl {Undefined sub foo} { + backend dummy None; + sub vcl_recv { + call foo; + } +} + +# NB: The line break in -errvcl is here on purpose, it prevents +# a spurious "Only available when" addition to be missed when the +# foo constructor could be confused with the foo instance name. +varnish v1 -syntax 4.0 -errvcl {Symbol not found: 'directors.foo' +At:} { + import directors; + backend b { .host = "${localhost}"; } + + sub vcl_init { + new foo = directors.foo(); + } +} + +# 'foo' overloaded +varnish v1 -syntax 4.0 -errvcl {Symbol not found: 'foo'} { + backend b { .host = "${localhost}"; } + + acl foo -pedantic { + "${localhost}"/32; + } + sub vcl_init { + new bar = foo; + } +} From nils.goroll at uplex.de Fri Oct 29 15:01:22 2021 From: nils.goroll at uplex.de (Nils Goroll) Date: Fri, 29 Oct 2021 15:01:22 +0000 (UTC) Subject: [master] 8d4640afe Split out dns-dependent test Message-ID: <20211029150122.AF602613D2@lists.varnish-cache.org> commit 8d4640afe72e72c16f1f5fa66bfd6b4e6a3a5c4e Author: Nils Goroll Date: Fri Oct 29 16:58:57 2021 +0200 Split out dns-dependent test diff --git a/bin/varnishtest/tests/v00016.vtc b/bin/varnishtest/tests/v00016.vtc index f4421a166..8a8dc1cf3 100644 --- a/bin/varnishtest/tests/v00016.vtc +++ b/bin/varnishtest/tests/v00016.vtc @@ -1,7 +1,5 @@ varnishtest "Various VCL compiler coverage tests" -feature dns - shell "true > ${tmpdir}/_varnishtest_empty_file" varnish v1 -vcl { @@ -82,13 +80,6 @@ varnish v1 -errvcl {Regexp compilation error:} { } } -varnish v1 -errvcl {resolves to too many addresses} { - backend b { .host = "${localhost}"; } - sub vcl_recv { - if (remote.ip == "dns-canary-multi.varnish-cache.org") {} - } -} - varnish v1 -errvcl {Expression has type directors.shard, expected ACL} { import directors; backend b { .host = "${localhost}"; } diff --git a/bin/varnishtest/tests/v00022.vtc b/bin/varnishtest/tests/v00022.vtc index f4421a166..fcb8014da 100644 --- a/bin/varnishtest/tests/v00022.vtc +++ b/bin/varnishtest/tests/v00022.vtc @@ -1,150 +1,10 @@ -varnishtest "Various VCL compiler coverage tests" +varnishtest "Various VCL compiler coverage tests - DNS dependent" feature dns -shell "true > ${tmpdir}/_varnishtest_empty_file" - -varnish v1 -vcl { - backend b { .host = "${localhost}"; } - include "${tmpdir}/_varnishtest_empty_file" ; -} - -varnish v1 -errvcl {include not followed by semicolon.} { - backend b { .host = "${localhost}"; } - include "${tmpdir}/_varnishtest_empty_file" | -} - -shell "rm -f ${tmpdir}/_varnishtest_empty_file" - -varnish v1 -errvcl {include not followed by string constant.} { - backend b { .host = "${localhost}"; } - include << -} - -varnish v1 -errvcl {include not followed by string constant.} { - /* token test */ - error lookup hash pipe pass fetch deliver discard keep restart - include - if else elseif elsif - ++ -- && || <= == != >= >> << += -= *= /= - { } ( ) * + - / % > < = ; ! & . | ~ , -} - -varnish v1 -errvcl {Unknown duration unit 'k'} { - backend b { .host = "${localhost}"; } - sub vcl_backend_response { set beresp.ttl = 1. k; } -} - -varnish v1 -errvcl {Operator > not possible on BACKEND} { - backend a { .host = "${localhost}"; } - backend b { .host = "${localhost}"; } - sub vcl_recv { if (a > b) { } } -} - -varnish v1 -errvcl {Unknown property 'foo' for type HTTP} { - backend b { .host = "${localhost}"; } - sub vcl_hash { if (req.foo != "bar") { } } -} - -varnish v1 -errvcl {Symbol not found: 'foo.bar'} { - sub vcl_init { - new bar = foo.bar(); - } -} - -varnish v1 -errvcl {Cannot be set in subroutine 'vcl_pipe'} { - backend b { .host = "${localhost}"; } - sub vcl_pipe { - set bereq.first_byte_timeout = 10s; - } -} - -varnish v1 -errvcl {Cannot be set in subroutine 'vcl_pipe'.} { - backend b { .host = "${localhost}"; } - sub vcl_pipe { - set bereq.between_bytes_timeout = 10s; - } -} - -varnish v1 -errvcl {Undefined backend c, first reference:} { - backend b { .host = "${localhost}"; } - sub vcl_backend_response { - if (beresp.backend == c) { - set beresp.ttl = 1h; - } - } -} - -varnish v1 -errvcl {Regexp compilation error:} { - backend b { .host = "${localhost}"; } - sub vcl_recv { - if (req.url ~ "[a") {} - } -} - varnish v1 -errvcl {resolves to too many addresses} { backend b { .host = "${localhost}"; } sub vcl_recv { if (remote.ip == "dns-canary-multi.varnish-cache.org") {} } } - -varnish v1 -errvcl {Expression has type directors.shard, expected ACL} { - import directors; - backend b { .host = "${localhost}"; } - - sub vcl_init { - new foo = directors.shard(); - } - sub vcl_recv { - if (client.ip ~ foo) { - return (synth(200)); - } - } -} - -varnish v1 -syntax 4.0 -errvcl {Expression has type directors.shard, expected ACL} { - import directors; - backend b { .host = "${localhost}"; } - - sub vcl_init { - new foo = directors.shard(); - } - sub vcl_recv { - if (client.ip ~ foo) { - return (synth(200)); - } - } -} - -varnish v1 -errvcl {Undefined sub foo} { - backend dummy None; - sub vcl_recv { - call foo; - } -} - -# NB: The line break in -errvcl is here on purpose, it prevents -# a spurious "Only available when" addition to be missed when the -# foo constructor could be confused with the foo instance name. -varnish v1 -syntax 4.0 -errvcl {Symbol not found: 'directors.foo' -At:} { - import directors; - backend b { .host = "${localhost}"; } - - sub vcl_init { - new foo = directors.foo(); - } -} - -# 'foo' overloaded -varnish v1 -syntax 4.0 -errvcl {Symbol not found: 'foo'} { - backend b { .host = "${localhost}"; } - - acl foo -pedantic { - "${localhost}"/32; - } - sub vcl_init { - new bar = foo; - } -} From nils.goroll at uplex.de Fri Oct 29 15:01:22 2021 From: nils.goroll at uplex.de (Nils Goroll) Date: Fri, 29 Oct 2021 15:01:22 +0000 (UTC) Subject: [master] b419d3d7e Use backend none more Message-ID: <20211029150122.C9BEC613D5@lists.varnish-cache.org> commit b419d3d7e02f3665f703165b7e37e092486e7ca9 Author: Nils Goroll Date: Fri Oct 29 17:00:05 2021 +0200 Use backend none more diff --git a/bin/varnishtest/tests/v00016.vtc b/bin/varnishtest/tests/v00016.vtc index 8a8dc1cf3..f1971efad 100644 --- a/bin/varnishtest/tests/v00016.vtc +++ b/bin/varnishtest/tests/v00016.vtc @@ -8,14 +8,14 @@ varnish v1 -vcl { } varnish v1 -errvcl {include not followed by semicolon.} { - backend b { .host = "${localhost}"; } + backend b none; include "${tmpdir}/_varnishtest_empty_file" | } shell "rm -f ${tmpdir}/_varnishtest_empty_file" varnish v1 -errvcl {include not followed by string constant.} { - backend b { .host = "${localhost}"; } + backend b none; include << } @@ -29,18 +29,18 @@ varnish v1 -errvcl {include not followed by string constant.} { } varnish v1 -errvcl {Unknown duration unit 'k'} { - backend b { .host = "${localhost}"; } + backend b none; sub vcl_backend_response { set beresp.ttl = 1. k; } } varnish v1 -errvcl {Operator > not possible on BACKEND} { - backend a { .host = "${localhost}"; } - backend b { .host = "${localhost}"; } + backend a none; + backend b none; sub vcl_recv { if (a > b) { } } } varnish v1 -errvcl {Unknown property 'foo' for type HTTP} { - backend b { .host = "${localhost}"; } + backend b none; sub vcl_hash { if (req.foo != "bar") { } } } @@ -51,21 +51,21 @@ varnish v1 -errvcl {Symbol not found: 'foo.bar'} { } varnish v1 -errvcl {Cannot be set in subroutine 'vcl_pipe'} { - backend b { .host = "${localhost}"; } + backend b none; sub vcl_pipe { set bereq.first_byte_timeout = 10s; } } varnish v1 -errvcl {Cannot be set in subroutine 'vcl_pipe'.} { - backend b { .host = "${localhost}"; } + backend b none; sub vcl_pipe { set bereq.between_bytes_timeout = 10s; } } varnish v1 -errvcl {Undefined backend c, first reference:} { - backend b { .host = "${localhost}"; } + backend b none; sub vcl_backend_response { if (beresp.backend == c) { set beresp.ttl = 1h; @@ -74,7 +74,7 @@ varnish v1 -errvcl {Undefined backend c, first reference:} { } varnish v1 -errvcl {Regexp compilation error:} { - backend b { .host = "${localhost}"; } + backend b none; sub vcl_recv { if (req.url ~ "[a") {} } @@ -82,7 +82,7 @@ varnish v1 -errvcl {Regexp compilation error:} { varnish v1 -errvcl {Expression has type directors.shard, expected ACL} { import directors; - backend b { .host = "${localhost}"; } + backend b none; sub vcl_init { new foo = directors.shard(); @@ -96,7 +96,7 @@ varnish v1 -errvcl {Expression has type directors.shard, expected ACL} { varnish v1 -syntax 4.0 -errvcl {Expression has type directors.shard, expected ACL} { import directors; - backend b { .host = "${localhost}"; } + backend b none; sub vcl_init { new foo = directors.shard(); @@ -121,7 +121,7 @@ varnish v1 -errvcl {Undefined sub foo} { varnish v1 -syntax 4.0 -errvcl {Symbol not found: 'directors.foo' At:} { import directors; - backend b { .host = "${localhost}"; } + backend b none; sub vcl_init { new foo = directors.foo(); @@ -130,7 +130,7 @@ At:} { # 'foo' overloaded varnish v1 -syntax 4.0 -errvcl {Symbol not found: 'foo'} { - backend b { .host = "${localhost}"; } + backend b none; acl foo -pedantic { "${localhost}"/32; diff --git a/bin/varnishtest/tests/v00022.vtc b/bin/varnishtest/tests/v00022.vtc index fcb8014da..953882fd8 100644 --- a/bin/varnishtest/tests/v00022.vtc +++ b/bin/varnishtest/tests/v00022.vtc @@ -3,7 +3,7 @@ varnishtest "Various VCL compiler coverage tests - DNS dependent" feature dns varnish v1 -errvcl {resolves to too many addresses} { - backend b { .host = "${localhost}"; } + backend b none; sub vcl_recv { if (remote.ip == "dns-canary-multi.varnish-cache.org") {} }