From phk at FreeBSD.org Mon Dec 2 08:53:07 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 2 Dec 2019 08:53:07 +0000 (UTC) Subject: [master] 1ba1773f6 Monday Morning FlexeLinting Message-ID: <20191202085307.1CE6810E48A@lists.varnish-cache.org> commit 1ba1773f6507c2cdd34d8e0e095298562c41c878 Author: Poul-Henning Kamp Date: Mon Dec 2 08:52:21 2019 +0000 Monday Morning FlexeLinting diff --git a/bin/varnishd/cache/cache_shmlog.c b/bin/varnishd/cache/cache_shmlog.c index f3765ff70..4eb9ed30b 100644 --- a/bin/varnishd/cache/cache_shmlog.c +++ b/bin/varnishd/cache/cache_shmlog.c @@ -509,7 +509,7 @@ vsm_vsmw_unlock(void) void VSM_Init(void) { - int i; + unsigned u; assert(UINT_MAX % VSL_SEGMENTS == VSL_SEGMENTS - 1); @@ -543,8 +543,8 @@ VSM_Init(void) vsl_head->segsize = vsl_segsize; vsl_head->offset[0] = 0; vsl_head->segment_n = vsl_segment_n; - for (i = 1; i < VSL_SEGMENTS; i++) - vsl_head->offset[i] = -1; + for (u = 1; u < VSL_SEGMENTS; u++) + vsl_head->offset[u] = -1; VWMB(); memcpy(vsl_head->marker, VSL_HEAD_MARKER, sizeof vsl_head->marker); } diff --git a/bin/varnishd/cache/cache_wrk.c b/bin/varnishd/cache/cache_wrk.c index dd032850f..3fd20eee2 100644 --- a/bin/varnishd/cache/cache_wrk.c +++ b/bin/varnishd/cache/cache_wrk.c @@ -165,7 +165,7 @@ pool_addstat(struct VSC_main_wrk *dst, struct VSC_main_wrk *src) memset(src, 0, sizeof *src); } -static inline int +static unsigned pool_reserve(void) { unsigned lim; @@ -508,7 +508,7 @@ pool_herder(void *priv) double t_idle; struct worker *wrk; double delay; - int wthread_min; + unsigned wthread_min; uintmax_t dq = (1ULL << 31); vtim_mono dqt = 0; diff --git a/bin/varnishd/http2/cache_http2_session.c b/bin/varnishd/http2/cache_http2_session.c index 0fce32bd8..8480692f0 100644 --- a/bin/varnishd/http2/cache_http2_session.c +++ b/bin/varnishd/http2/cache_http2_session.c @@ -163,16 +163,15 @@ h2_del_sess(struct worker *wrk, struct h2_sess *h2, enum sess_close reason) enum htc_status_e v_matchproto_(htc_complete_f) H2_prism_complete(struct http_conn *htc) { - ptrdiff_t l; + size_t sz; CHECK_OBJ_NOTNULL(htc, HTTP_CONN_MAGIC); - l = htc->rxbuf_e - htc->rxbuf_b; - if (l >= sizeof(H2_prism) && - !memcmp(htc->rxbuf_b, H2_prism, sizeof(H2_prism))) - return (HTC_S_COMPLETE); - if (l < sizeof(H2_prism) && !memcmp(htc->rxbuf_b, H2_prism, l)) - return (HTC_S_MORE); - return (HTC_S_JUNK); + sz = sizeof(H2_prism); + if (htc->rxbuf_b + sz > htc->rxbuf_e) + sz = htc->rxbuf_e - htc->rxbuf_b; + if (memcmp(htc->rxbuf_b, H2_prism, sz)) + return (HTC_S_JUNK); + return (sz == sizeof(H2_prism) ? HTC_S_COMPLETE : HTC_S_MORE); } diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c index 93afb9d35..03d707ee6 100644 --- a/bin/varnishd/mgt/mgt_param.c +++ b/bin/varnishd/mgt/mgt_param.c @@ -565,8 +565,8 @@ MCF_AddParams(struct parspec *ps) exit(4); } mcf_addpar(pp); - if (strlen(pp->name) + 1L > margin2) - margin2 = strlen(pp->name) + 1; + if ((int)strlen(pp->name) + 1 > margin2) + margin2 = (int)strlen(pp->name) + 1; } } diff --git a/bin/varnishd/mgt/mgt_vcl.c b/bin/varnishd/mgt/mgt_vcl.c index 8478887ae..81751b8ca 100644 --- a/bin/varnishd/mgt/mgt_vcl.c +++ b/bin/varnishd/mgt/mgt_vcl.c @@ -55,7 +55,7 @@ struct vclstate { static const struct vclstate VCL_STATE_LABEL[1] = {{ "label" }}; -static int vcl_count; +static unsigned vcl_count; struct vclproghead vclhead = VTAILQ_HEAD_INITIALIZER(vclhead); struct vmodfilehead vmodhead = VTAILQ_HEAD_INITIALIZER(vmodhead); diff --git a/bin/varnishd/storage/storage_persistent.h b/bin/varnishd/storage/storage_persistent.h index 7fe612fba..48fe8c0c5 100644 --- a/bin/varnishd/storage/storage_persistent.h +++ b/bin/varnishd/storage/storage_persistent.h @@ -230,7 +230,7 @@ struct smp_sc { const struct stevedore *stevedore; int fd; const char *filename; - off_t mediasize; + uint64_t mediasize; uintptr_t align; uint32_t granularity; uint32_t unique; diff --git a/bin/varnishd/storage/storage_simple.c b/bin/varnishd/storage/storage_simple.c index 83e8d713c..962756cdd 100644 --- a/bin/varnishd/storage/storage_simple.c +++ b/bin/varnishd/storage/storage_simple.c @@ -45,7 +45,7 @@ /*-------------------------------------------------------------------*/ static struct storage * -sml_stv_alloc(const struct stevedore *stv, size_t size, int flags) +sml_stv_alloc(const struct stevedore *stv, ssize_t size, int flags) { struct storage *st; @@ -74,7 +74,7 @@ sml_stv_alloc(const struct stevedore *stv, size_t size, int flags) if (size <= cache_param->fetch_chunksize) break; - size >>= 1; + size /= 2; } CHECK_OBJ_ORNULL(st, STORAGE_MAGIC); return (st); @@ -343,7 +343,7 @@ sml_iterator(struct worker *wrk, struct objcore *oc, */ static struct storage * -objallocwithnuke(struct worker *wrk, const struct stevedore *stv, size_t size, +objallocwithnuke(struct worker *wrk, const struct stevedore *stv, ssize_t size, int flags) { struct storage *st = NULL; From phk at FreeBSD.org Mon Dec 2 12:00:08 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 2 Dec 2019 12:00:08 +0000 (UTC) Subject: [master] 799aaa963 Merge from VTEST: Message-ID: <20191202120008.5399E111F57@lists.varnish-cache.org> commit 799aaa963a856a18ca9cac0906483d8d61eb2d56 Author: Poul-Henning Kamp Date: Mon Dec 2 11:42:36 2019 +0000 Merge from VTEST: vtc_haproxy: enable mcli with a separate flag from worker mode Support for the master cli in worker mode was added with commit 86e65f1 using the same flag as worker mode (-W). This is a problem with haproxy 1.8 because it has worker mode but no mcli. This patch adds -S to enable mcli for haproxy in a vtc. and: The two patches in attachment fix a bug in the haproxy CLI handling and add the support for the haproxy master CLI in VTest. Could you merge them? Thanks You can also find in attachment a vtc file which use this new feature. Submitted by: William Lallemand diff --git a/bin/varnishtest/vtc_haproxy.c b/bin/varnishtest/vtc_haproxy.c index b24af08ca..72e9d3438 100644 --- a/bin/varnishtest/vtc_haproxy.c +++ b/bin/varnishtest/vtc_haproxy.c @@ -47,6 +47,7 @@ #define HAPROXY_PROGRAM_ENV_VAR "HAPROXY_PROGRAM" #define HAPROXY_OPT_WORKER "-W" +#define HAPROXY_OPT_MCLI "-S" #define HAPROXY_OPT_DAEMON "-D" #define HAPROXY_SIGNAL SIGINT #define HAPROXY_EXPECT_EXIT (128 + HAPROXY_SIGNAL) @@ -68,6 +69,7 @@ struct haproxy { const char *filename; struct vsb *args; int opt_worker; + int opt_mcli; int opt_daemon; int opt_check_mode; char *pid_fn; @@ -87,6 +89,9 @@ struct haproxy { /* TCP socket CLI. */ struct haproxy_cli *cli; + /* master CLI */ + struct haproxy_cli *mcli; + char *workdir; struct vsb *msgs; char closed_sock[256]; /* Closed TCP socket */ @@ -191,6 +196,7 @@ cmd_haproxy_cli_send(CMD_ARGS) { struct vsb *vsb; struct haproxy_cli *hc; + int j; (void)cmd; (void)vl; @@ -225,6 +231,13 @@ cmd_haproxy_cli_send(CMD_ARGS) vtc_fatal(hc->vl, "CLI fd %d send error %s", hc->sock, strerror(errno)); + /* a CLI command must be followed by a SHUT_WR if we want HAProxy to + * close after the response */ + j = shutdown(hc->sock, SHUT_WR); + vtc_log(hc->vl, 3, "CLI shutting fd %d", hc->sock); + if (!VTCP_Check(j)) + vtc_fatal(hc->vl, "Shutdown failed: %s", strerror(errno)); + VSB_destroy(&vsb); } @@ -475,6 +488,51 @@ haproxy_cli_new(struct haproxy *h) return (hc); } +/* creates a master CLI client (-mcli) */ +static struct haproxy_cli * +haproxy_mcli_new(struct haproxy *h) +{ + struct haproxy_cli *hc; + + ALLOC_OBJ(hc, HAPROXY_CLI_MAGIC); + AN(hc); + + hc->vl = h->vl; + hc->sock = -1; + bprintf(hc->connect, "${%s_mcli_sock}", h->name); + + hc->txbuf_sz = hc->rxbuf_sz = 2048 * 1024; + hc->txbuf = malloc(hc->txbuf_sz); + AN(hc->txbuf); + hc->rxbuf = malloc(hc->rxbuf_sz); + AN(hc->rxbuf); + + return (hc); +} + +/* Bind an address/port for the master CLI (-mcli) */ +static int +haproxy_create_mcli(struct haproxy *h) +{ + int sock; + const char *err; + char buf[128], addr[128], port[128]; + + sock = VTCP_listen_on("localhost:0", NULL, 100, &err); + if (err != NULL) + vtc_fatal(h->vl, + "Create listen socket failed: %s", err); + assert(sock > 0); + + VTCP_myname(sock, addr, sizeof addr, port, sizeof port); + bprintf(buf, "%s_mcli", h->name); + macro_def(h->vl, buf, "sock", "%s %s", addr, port); + macro_def(h->vl, buf, "addr", "%s", addr); + macro_def(h->vl, buf, "port", "%s", port); + + return sock; +} + static void haproxy_cli_delete(struct haproxy_cli *hc) { @@ -545,6 +603,9 @@ haproxy_new(const char *name) h->cli = haproxy_cli_new(h); AN(h->cli); + h->mcli = haproxy_mcli_new(h); + AN(h->mcli); + bprintf(buf, "rm -rf \"%s\" ; mkdir -p \"%s\"", h->workdir, h->workdir); AZ(system(buf)); @@ -578,6 +639,7 @@ haproxy_delete(struct haproxy *h) free(h->pid_fn); VSB_destroy(&h->args); haproxy_cli_delete(h->cli); + haproxy_cli_delete(h->mcli); /* XXX: MEMLEAK (?) */ FREE_OBJ(h); @@ -598,6 +660,7 @@ haproxy_thread(void *priv) return (NULL); } + /********************************************************************** * Start a HAProxy instance. */ @@ -611,22 +674,28 @@ haproxy_start(struct haproxy *h) vtc_log(h->vl, 2, "%s", __func__); AZ(VSB_finish(h->args)); - vtc_log(h->vl, 4, "opt_worker %d opt_daemon %d opt_check_mode %d", - h->opt_worker, h->opt_daemon, h->opt_check_mode); + vtc_log(h->vl, 4, "opt_worker %d opt_daemon %d opt_check_mode %d opt_mcli %d", + h->opt_worker, h->opt_daemon, h->opt_check_mode, h->opt_mcli); vsb = VSB_new_auto(); AN(vsb); VSB_printf(vsb, "exec \"%s\"", h->filename); if (h->opt_check_mode) - VSB_printf(vsb, " -c"); + VSB_cat(vsb, " -c"); else if (h->opt_daemon) - VSB_printf(vsb, " -D"); + VSB_cat(vsb, " -D"); else - VSB_printf(vsb, " -d"); - - if (h->opt_worker) - VSB_printf(vsb, " -W"); + VSB_cat(vsb, " -d"); + + if (h->opt_worker) { + VSB_cat(vsb, " -W"); + if (h->opt_mcli) { + int sock; + sock = haproxy_create_mcli(h); + VSB_printf(vsb, " -S \"fd@%d\"", sock); + } + } VSB_printf(vsb, " %s", VSB_data(h->args)); @@ -707,6 +776,9 @@ haproxy_wait(struct haproxy *h) if (h->cli->spec) haproxy_cli_run(h->cli); + if (h->mcli->spec) + haproxy_cli_run(h->mcli); + closefd(&h->fds[1]); sig = SIGINT; @@ -827,7 +899,7 @@ haproxy_store_conf(struct haproxy *h, const char *cfg, int auto_be) VSB_printf(vsb, " global\n\tstats socket \"%s\" " "level admin mode 600\n", h->cli_fn); - VSB_printf(vsb, " stats socket \"fd@${cli}\" level admin\n"); + VSB_cat(vsb, " stats socket \"fd@${cli}\" level admin\n"); AZ(VSB_cat(vsb, cfg)); if (auto_be) @@ -898,12 +970,19 @@ haproxy_write_conf(struct haproxy *h) * \-W * Enable HAproxy in Worker mode. * + * \-S + * Enable HAproxy Master CLI in Worker mode + * * \-arg STRING * Pass an argument to haproxy, for example "-h simple_list". * * \-cli STRING * Specify the spec to be run by the command line interface (CLI). * + * \-mcli STRING + * Specify the spec to be run by the command line interface (CLI) + * of the Master process. + * * \-conf STRING * Specify the configuration to be loaded by this HAProxy instance. * @@ -984,7 +1063,10 @@ cmd_haproxy(CMD_ARGS) h->opt_worker = 1; continue; } - + if (!strcmp(*av, HAPROXY_OPT_MCLI)) { + h->opt_mcli = 1; + continue; + } if (!strcmp(*av, "-arg")) { AN(av[1]); AZ(h->pid); @@ -1001,6 +1083,15 @@ cmd_haproxy(CMD_ARGS) av++; continue; } + + if (!strcmp(*av, "-mcli")) { + REPLACE(h->mcli->spec, av[1]); + if (h->tp) + haproxy_cli_run(h->mcli); + av++; + continue; + } + if (!strcmp(*av, "-conf")) { AN(av[1]); haproxy_store_conf(h, av[1], 0); From phk at FreeBSD.org Mon Dec 2 12:00:08 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 2 Dec 2019 12:00:08 +0000 (UTC) Subject: [master] 24455b707 Merge from VTEST: Message-ID: <20191202120008.690DE111F5A@lists.varnish-cache.org> commit 24455b70728605a380c46454ef5dfdc598fc599e Author: Poul-Henning Kamp Date: Mon Dec 2 11:53:35 2019 +0000 Merge from VTEST: Avoid VSB_printf for static strings Done with the following semantic patch for Coccinelle: @@ expression vsb, fmt; @@ - VSB_printf(vsb, fmt); + VSB_cat(vsb, fmt); This patch is available in the Varnish source tree. diff --git a/bin/varnishtest/vtc_log.c b/bin/varnishtest/vtc_log.c index 1bdd5699c..be67a5d9c 100644 --- a/bin/varnishtest/vtc_log.c +++ b/bin/varnishtest/vtc_log.c @@ -257,7 +257,7 @@ vtc_hexdump(struct vtclog *vl, int lvl, const char *pfx, else { for (l = 0; l < len; l++, ss++) { if (l > 512) { - VSB_printf(vl->vsb, "..."); + VSB_cat(vl->vsb, "..."); break; } if (nl) { @@ -266,13 +266,13 @@ vtc_hexdump(struct vtclog *vl, int lvl, const char *pfx, } VSB_printf(vl->vsb, " %02x", *ss); if ((l & 0xf) == 0xf) { - VSB_printf(vl->vsb, "\n"); + VSB_cat(vl->vsb, "\n"); nl = 1; } } } if (!nl) - VSB_printf(vl->vsb, "\n"); + VSB_cat(vl->vsb, "\n"); REL_VL(vl); if (lvl == 0) vtc_logfail(); diff --git a/bin/varnishtest/vtc_main.c b/bin/varnishtest/vtc_main.c index a2c346067..c61ab7c7d 100644 --- a/bin/varnishtest/vtc_main.c +++ b/bin/varnishtest/vtc_main.c @@ -507,7 +507,7 @@ i_mode(void) /* * Build $PATH which can find all programs in the build tree */ - VSB_printf(vsb, "PATH="); + VSB_cat(vsb, "PATH="); sep = ""; #define VTC_PROG(l) \ do { \ @@ -688,7 +688,7 @@ main(int argc, char * const *argv) AN(cbvsb); setbuf(stdout, NULL); setbuf(stderr, NULL); - while ((ch = getopt(argc, argv, "b:CD:hij:kLln:p:qt:vW")) != -1) { + while ((ch = getopt(argc, argv, "b:CD:hij:kLln:p:qt:v")) != -1) { switch (ch) { case 'b': if (VNUM_2bytes(optarg, &bufsiz, 0)) { @@ -732,7 +732,7 @@ main(int argc, char * const *argv) ntest = strtoul(optarg, NULL, 0); break; case 'p': - VSB_printf(params_vsb, " -p "); + VSB_cat(params_vsb, " -p "); VSB_quote(params_vsb, optarg, -1, 0); break; case 'q': diff --git a/bin/varnishtest/vtc_proxy.c b/bin/varnishtest/vtc_proxy.c index 4477ab056..ffa322e85 100644 --- a/bin/varnishtest/vtc_proxy.c +++ b/bin/varnishtest/vtc_proxy.c @@ -100,9 +100,9 @@ vtc_send_proxy(int fd, int version, const struct suckaddr *sac, if (version == 1) { VSB_bcat(vsb, vpx1_sig, sizeof(vpx1_sig)); if (proto == PF_INET6) - VSB_printf(vsb, " TCP6 "); + VSB_cat(vsb, " TCP6 "); else if (proto == PF_INET) - VSB_printf(vsb, " TCP4 "); + VSB_cat(vsb, " TCP4 "); VTCP_name(sac, hc, sizeof(hc), pc, sizeof(pc)); VTCP_name(sas, hs, sizeof(hs), ps, sizeof(ps)); VSB_printf(vsb, "%s %s %s %s\r\n", hc, hs, pc, ps); diff --git a/bin/varnishtest/vtc_server.c b/bin/varnishtest/vtc_server.c index 9a1a0d68e..3ff49705e 100644 --- a/bin/varnishtest/vtc_server.c +++ b/bin/varnishtest/vtc_server.c @@ -67,7 +67,8 @@ struct server { static pthread_mutex_t server_mtx; -static VTAILQ_HEAD(, server) servers = VTAILQ_HEAD_INITIALIZER(servers); +static VTAILQ_HEAD(, server) servers = + VTAILQ_HEAD_INITIALIZER(servers); /********************************************************************** * Allocate and initialize a server diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c index 24ffab467..483690cbb 100644 --- a/bin/varnishtest/vtc_varnish.c +++ b/bin/varnishtest/vtc_varnish.c @@ -407,7 +407,7 @@ varnish_launch(struct varnish *v) vtc_log(v->vl, 2, "Launch"); vsb = VSB_new_auto(); AN(vsb); - VSB_printf(vsb, "cd ${pwd} &&"); + VSB_cat(vsb, "cd ${pwd} &&"); VSB_printf(vsb, " exec varnishd %s -d -n %s", v->jail, v->workdir); VSB_cat(vsb, VSB_data(params_vsb)); @@ -416,13 +416,13 @@ varnish_launch(struct varnish *v) VSB_cat(vsb, " -p debug=+vmod_so_keep"); VSB_cat(vsb, " -p debug=+vsm_keep"); } - VSB_printf(vsb, " -l 2m"); - VSB_printf(vsb, " -p auto_restart=off"); - VSB_printf(vsb, " -p syslog_cli_traffic=off"); - VSB_printf(vsb, " -p sigsegv_handler=on"); - VSB_printf(vsb, " -p thread_pool_min=10"); - VSB_printf(vsb, " -p debug=+vtc_mode"); - VSB_printf(vsb, " -p vsl_mask=+Debug"); + VSB_cat(vsb, " -l 2m"); + VSB_cat(vsb, " -p auto_restart=off"); + VSB_cat(vsb, " -p syslog_cli_traffic=off"); + VSB_cat(vsb, " -p sigsegv_handler=on"); + VSB_cat(vsb, " -p thread_pool_min=10"); + VSB_cat(vsb, " -p debug=+vtc_mode"); + VSB_cat(vsb, " -p vsl_mask=+Debug"); if (!v->has_a_arg) { VSB_printf(vsb, " -a '%s'", "127.0.0.1:0"); if (v->proto != NULL) From dridi.boukelmoune at gmail.com Mon Dec 2 12:14:06 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 2 Dec 2019 12:14:06 +0000 (UTC) Subject: [master] b39e9196a Delay the code generation of the set action Message-ID: <20191202121406.DB0A51126D6@lists.varnish-cache.org> commit b39e9196a41e98d4802c2bfe6582098599428ffa Author: Dridi Boukelmoune Date: Tue Nov 5 17:09:27 2019 +0100 Delay the code generation of the set action First, gather everything needed, then generate the C code. This avoids a bit of code duplication and makes the error handling more natural, right after the attempt at generating a matching expression. Refs #3100 diff --git a/lib/libvcc/vcc_action.c b/lib/libvcc/vcc_action.c index a8f3ca20a..7ce421599 100644 --- a/lib/libvcc/vcc_action.c +++ b/lib/libvcc/vcc_action.c @@ -106,8 +106,7 @@ vcc_act_set(struct vcc *tl, struct token *t, struct symbol *sym) return; } vcc_AddUses(tl, t, tl->t, sym->w_methods, "Cannot be set"); - Fb(tl, 1, "%s\n", sym->lname); - tl->indent += INDENT; + t = NULL; type = sym->type; for (ap = arith; ap->type != VOID; ap++) { if (ap->type != type) @@ -115,22 +114,24 @@ vcc_act_set(struct vcc *tl, struct token *t, struct symbol *sym) if (ap->oper != tl->t->tok) continue; if (ap->oper != '=') - Fb(tl, 1, "%s %c ", sym->rname, *tl->t->b); + t = tl->t; vcc_NextToken(tl); type = ap->want; break; } + if (ap->type == VOID) SkipToken(tl, ap->oper); - if (type == HEADER) { - vcc_Expr(tl, STRING_LIST); - } else if (type == STRING) { - vcc_Expr(tl, STRING_LIST); - } else if (type == BODY) { - vcc_Expr(tl, STRING_LIST); - } else { - vcc_Expr(tl, type); + + if (type == HEADER || type == STRING || type == BODY) { + type = STRING_LIST; } + + Fb(tl, 1, "%s\n", sym->lname); + tl->indent += INDENT; + if (t != NULL) + Fb(tl, 1, "%s %c ", sym->rname, *t->b); + vcc_Expr(tl, type); ERRCHK(tl); tl->indent -= INDENT; Fb(tl, 1, ");\n"); From dridi.boukelmoune at gmail.com Mon Dec 2 12:14:06 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 2 Dec 2019 12:14:06 +0000 (UTC) Subject: [master] 74298f6a1 Teach expressions to the set action's arithmetic table Message-ID: <20191202121407.00CF81126D9@lists.varnish-cache.org> commit 74298f6a19721489baa451dfd276c75106c677e2 Author: Dridi Boukelmoune Date: Tue Nov 5 18:18:36 2019 +0100 Teach expressions to the set action's arithmetic table It uses a similar trick as VCC expressions to find where the symbol name belongs. Refs #3100 diff --git a/lib/libvcc/vcc_action.c b/lib/libvcc/vcc_action.c index 7ce421599..e4ccd2e10 100644 --- a/lib/libvcc/vcc_action.c +++ b/lib/libvcc/vcc_action.c @@ -60,28 +60,46 @@ static const struct arith { vcc_type_t type; unsigned oper; vcc_type_t want; + const char *expr; } arith[] = { - { INT, T_INCR, INT }, - { INT, T_DECR, INT }, - { INT, T_MUL, INT }, - { INT, T_DIV, INT }, + { INT, T_INCR, INT, "\v + " }, + { INT, T_DECR, INT, "\v - " }, + { INT, T_MUL, INT, "\v * " }, + { INT, T_DIV, INT, "\v / " }, { INT, '=', INT }, { INT, 0, INT }, - { TIME, T_INCR, DURATION }, - { TIME, T_DECR, DURATION }, - { TIME, T_MUL, REAL }, - { TIME, T_DIV, REAL }, + { TIME, T_INCR, DURATION, "\v + " }, + { TIME, T_DECR, DURATION, "\v - " }, + { TIME, T_MUL, REAL, "\v * " }, + { TIME, T_DIV, REAL, "\v / " }, { TIME, '=', TIME }, { TIME, 0, TIME }, - { DURATION, T_INCR, DURATION }, - { DURATION, T_DECR, DURATION }, - { DURATION, T_MUL, REAL }, - { DURATION, T_DIV, REAL }, + { DURATION, T_INCR, DURATION, "\v + " }, + { DURATION, T_DECR, DURATION, "\v - " }, + { DURATION, T_MUL, REAL, "\v * " }, + { DURATION, T_DIV, REAL, "\v / " }, { DURATION, '=', DURATION }, { DURATION, 0, DURATION }, { VOID, '=', VOID } }; +static void +vcc_arith_expr(struct vcc *tl, struct symbol *sym, const struct arith *ap) +{ + const char *e; + + e = ap->expr; + if (e == NULL) + return; + + while (*e != '\0') { + if (*e == '\v') + Fb(tl, 1, "%s", sym->rname); + else + Fb(tl, 1, "%c", *e); + e++; + } +} /*--------------------------------------------------------------------*/ @@ -106,15 +124,12 @@ vcc_act_set(struct vcc *tl, struct token *t, struct symbol *sym) return; } vcc_AddUses(tl, t, tl->t, sym->w_methods, "Cannot be set"); - t = NULL; type = sym->type; for (ap = arith; ap->type != VOID; ap++) { if (ap->type != type) continue; if (ap->oper != tl->t->tok) continue; - if (ap->oper != '=') - t = tl->t; vcc_NextToken(tl); type = ap->want; break; @@ -129,8 +144,7 @@ vcc_act_set(struct vcc *tl, struct token *t, struct symbol *sym) Fb(tl, 1, "%s\n", sym->lname); tl->indent += INDENT; - if (t != NULL) - Fb(tl, 1, "%s %c ", sym->rname, *t->b); + vcc_arith_expr(tl, sym, ap); vcc_Expr(tl, type); ERRCHK(tl); tl->indent -= INDENT; From dridi.boukelmoune at gmail.com Mon Dec 2 12:14:07 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 2 Dec 2019 12:14:07 +0000 (UTC) Subject: [master] ee29af937 Teach libvcc how to set STRING += STRING; Message-ID: <20191202121407.24D151126DD@lists.varnish-cache.org> commit ee29af937a898d549287125b96c66688c68a829e Author: Dridi Boukelmoune Date: Tue Nov 5 18:24:00 2019 +0100 Teach libvcc how to set STRING += STRING; Refs #3100 diff --git a/bin/varnishtest/tests/v00018.vtc b/bin/varnishtest/tests/v00018.vtc index 3ce6bd051..cd5fc41db 100644 --- a/bin/varnishtest/tests/v00018.vtc +++ b/bin/varnishtest/tests/v00018.vtc @@ -27,11 +27,6 @@ varnish v1 -errvcl {Expected '=' got '+='} { sub vcl_backend_fetch { set bereq.backend += b; } } -varnish v1 -errvcl {Expected '=' got '+='} { - backend b { .host = "127.0.0.1"; } - sub vcl_recv { set req.url += now; } -} - varnish v1 -errvcl {Expected ';' got 'if'} { backend b { .host = "127.0.0.1"; } /* XXX: This should not really be an synth */ diff --git a/lib/libvcc/vcc_action.c b/lib/libvcc/vcc_action.c index e4ccd2e10..9d7f621cc 100644 --- a/lib/libvcc/vcc_action.c +++ b/lib/libvcc/vcc_action.c @@ -80,6 +80,7 @@ static const struct arith { { DURATION, T_DIV, REAL, "\v / " }, { DURATION, '=', DURATION }, { DURATION, 0, DURATION }, + { STRING, T_INCR, STRING, "\v,\n" }, { VOID, '=', VOID } }; From dridi.boukelmoune at gmail.com Mon Dec 2 12:14:07 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 2 Dec 2019 12:14:07 +0000 (UTC) Subject: [master] ade0ddc99 Generalize more special cases in the set action Message-ID: <20191202121407.470D41126E7@lists.varnish-cache.org> commit ade0ddc99b54446f672ea80a06751b1acb73e1f6 Author: Dridi Boukelmoune Date: Tue Nov 5 18:52:10 2019 +0100 Generalize more special cases in the set action At this point we should probably consider renaming the arithmetic table to something also more general. diff --git a/lib/libvcc/vcc_action.c b/lib/libvcc/vcc_action.c index 9d7f621cc..c099eaa33 100644 --- a/lib/libvcc/vcc_action.c +++ b/lib/libvcc/vcc_action.c @@ -80,7 +80,10 @@ static const struct arith { { DURATION, T_DIV, REAL, "\v / " }, { DURATION, '=', DURATION }, { DURATION, 0, DURATION }, - { STRING, T_INCR, STRING, "\v,\n" }, + { STRING, T_INCR, STRING_LIST, "\v,\n" }, + { STRING, '=', STRING_LIST }, + { HEADER, '=', STRING_LIST }, + { BODY, '=', STRING_LIST }, { VOID, '=', VOID } }; @@ -139,10 +142,6 @@ vcc_act_set(struct vcc *tl, struct token *t, struct symbol *sym) if (ap->type == VOID) SkipToken(tl, ap->oper); - if (type == HEADER || type == STRING || type == BODY) { - type = STRING_LIST; - } - Fb(tl, 1, "%s\n", sym->lname); tl->indent += INDENT; vcc_arith_expr(tl, sym, ap); From dridi.boukelmoune at gmail.com Mon Dec 2 12:14:07 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 2 Dec 2019 12:14:07 +0000 (UTC) Subject: [master] 94e6e03ed Repurpose the arithmetic table to an assignment table Message-ID: <20191202121407.67D4D1126ED@lists.varnish-cache.org> commit 94e6e03ed653f5147502d38376b60a24dfc342a5 Author: Dridi Boukelmoune Date: Tue Nov 5 18:55:18 2019 +0100 Repurpose the arithmetic table to an assignment table diff --git a/lib/libvcc/vcc_action.c b/lib/libvcc/vcc_action.c index c099eaa33..30b6eef31 100644 --- a/lib/libvcc/vcc_action.c +++ b/lib/libvcc/vcc_action.c @@ -56,12 +56,12 @@ vcc_act_call(struct vcc *tl, struct token *t, struct symbol *sym) /*--------------------------------------------------------------------*/ -static const struct arith { +static const struct assign { vcc_type_t type; unsigned oper; vcc_type_t want; const char *expr; -} arith[] = { +} assign[] = { { INT, T_INCR, INT, "\v + " }, { INT, T_DECR, INT, "\v - " }, { INT, T_MUL, INT, "\v * " }, @@ -88,7 +88,7 @@ static const struct arith { }; static void -vcc_arith_expr(struct vcc *tl, struct symbol *sym, const struct arith *ap) +vcc_assign_expr(struct vcc *tl, struct symbol *sym, const struct assign *ap) { const char *e; @@ -110,7 +110,7 @@ vcc_arith_expr(struct vcc *tl, struct symbol *sym, const struct arith *ap) static void v_matchproto_(sym_act_f) vcc_act_set(struct vcc *tl, struct token *t, struct symbol *sym) { - const struct arith *ap; + const struct assign *ap; vcc_type_t type; (void)t; @@ -129,7 +129,7 @@ vcc_act_set(struct vcc *tl, struct token *t, struct symbol *sym) } vcc_AddUses(tl, t, tl->t, sym->w_methods, "Cannot be set"); type = sym->type; - for (ap = arith; ap->type != VOID; ap++) { + for (ap = assign; ap->type != VOID; ap++) { if (ap->type != type) continue; if (ap->oper != tl->t->tok) @@ -144,7 +144,7 @@ vcc_act_set(struct vcc *tl, struct token *t, struct symbol *sym) Fb(tl, 1, "%s\n", sym->lname); tl->indent += INDENT; - vcc_arith_expr(tl, sym, ap); + vcc_assign_expr(tl, sym, ap); vcc_Expr(tl, type); ERRCHK(tl); tl->indent -= INDENT; From dridi.boukelmoune at gmail.com Mon Dec 2 12:14:07 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 2 Dec 2019 12:14:07 +0000 (UTC) Subject: [master] d6127c3e4 Teach libvcc how to set HEADER += STRING_LIST; Message-ID: <20191202121407.871101126F1@lists.varnish-cache.org> commit d6127c3e4332bfd9ccb6b5edf777f040d1db776b Author: Dridi Boukelmoune Date: Tue Nov 5 19:24:12 2019 +0100 Teach libvcc how to set HEADER += STRING_LIST; And avoid the indentation of characters in vcc_assign_expr(). Fixes #3079 Closes #3100 diff --git a/bin/varnishtest/tests/r03079.vtc b/bin/varnishtest/tests/r03079.vtc new file mode 100644 index 000000000..5da83f91f --- /dev/null +++ b/bin/varnishtest/tests/r03079.vtc @@ -0,0 +1,25 @@ +varnishtest "set VCL_??? += VCL_STRING;" + +server s1 { + rxreq + expect req.url == "/hello/world" + expect req.http.host == helloworld + txresp -hdr "x-powered-by: varnishtest" +} -start + +varnish v1 -vcl+backend { + sub vcl_backend_fetch { + set bereq.url += "/world"; + set bereq.http.host += "world"; + } + sub vcl_backend_response { + set beresp.http.x-powered-by += bereq.http.x-varnish; + } +} -start + +client c1 { + txreq -url "/hello" -hdr "host: hello" + rxresp + expect resp.status == 200 + expect resp.http.x-powered-by == varnishtest1002 +} -run diff --git a/lib/libvcc/vcc_action.c b/lib/libvcc/vcc_action.c index 30b6eef31..515a47a18 100644 --- a/lib/libvcc/vcc_action.c +++ b/lib/libvcc/vcc_action.c @@ -82,6 +82,7 @@ static const struct assign { { DURATION, 0, DURATION }, { STRING, T_INCR, STRING_LIST, "\v,\n" }, { STRING, '=', STRING_LIST }, + { HEADER, T_INCR, STRING_LIST, "VRT_GetHdr(ctx, \v),\n" }, { HEADER, '=', STRING_LIST }, { BODY, '=', STRING_LIST }, { VOID, '=', VOID } @@ -98,9 +99,9 @@ vcc_assign_expr(struct vcc *tl, struct symbol *sym, const struct assign *ap) while (*e != '\0') { if (*e == '\v') - Fb(tl, 1, "%s", sym->rname); + Fb(tl, 0, "%s", sym->rname); else - Fb(tl, 1, "%c", *e); + Fb(tl, 0, "%c", *e); e++; } } From dridi.boukelmoune at gmail.com Mon Dec 2 12:14:07 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 2 Dec 2019 12:14:07 +0000 (UTC) Subject: [master] 2a5db07e0 Polish the generated C code for the set action Message-ID: <20191202121407.AA2C21126F6@lists.varnish-cache.org> commit 2a5db07e0cc67094b4db6d10c4b9e90d46ea0d4b Author: Dridi Boukelmoune Date: Wed Nov 6 15:00:27 2019 +0100 Polish the generated C code for the set action diff --git a/lib/libvcc/vcc_action.c b/lib/libvcc/vcc_action.c index 515a47a18..5899b2b30 100644 --- a/lib/libvcc/vcc_action.c +++ b/lib/libvcc/vcc_action.c @@ -92,6 +92,7 @@ static void vcc_assign_expr(struct vcc *tl, struct symbol *sym, const struct assign *ap) { const char *e; + unsigned indent = 1; e = ap->expr; if (e == NULL) @@ -99,9 +100,10 @@ vcc_assign_expr(struct vcc *tl, struct symbol *sym, const struct assign *ap) while (*e != '\0') { if (*e == '\v') - Fb(tl, 0, "%s", sym->rname); + Fb(tl, indent, "%s", sym->rname); else - Fb(tl, 0, "%c", *e); + Fb(tl, indent, "%c", *e); + indent = 0; e++; } } From dridi.boukelmoune at gmail.com Mon Dec 2 12:14:07 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 2 Dec 2019 12:14:07 +0000 (UTC) Subject: [master] 2eb352d2b Fix the behavior of `set BODY = STRING;` Message-ID: <20191202121407.CA7FD1126FA@lists.varnish-cache.org> commit 2eb352d2bc4f07518a17bce8108c7ab89e24e4da Author: Dridi Boukelmoune Date: Thu Nov 7 10:12:03 2019 +0100 Fix the behavior of `set BODY = STRING;` Multiple calls to the synthetic() function result in the accumulation of all body parts. The ability to set a [be]resp body accidentally resulted in the same behavior. In other words writing `set resp.body = "string";` in VCL behaves as if `set resp.body += "string";` was written instead. This patch introduces an enum to distinguish between the two desired actions and enables both syntaxes without touching the behavior of the synthetic() function. diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index 7ed80cfd6..3a06d16a4 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -880,13 +880,17 @@ VRT_r_resp_do_esi(VRT_CTX) #define VRT_BODY_L(which) \ VCL_VOID \ -VRT_l_##which##_body(VRT_CTX, const char *str, ...) \ +VRT_l_##which##_body(VRT_CTX, enum lbody_e type, \ + const char *str, ...) \ { \ va_list ap; \ const char *p; \ struct vsb *vsb; \ \ CAST_OBJ_NOTNULL(vsb, ctx->specific, VSB_MAGIC); \ + assert(type == LBODY_SET || type == LBODY_ADD); \ + if (type == LBODY_SET) \ + VSB_clear(vsb); \ va_start(ap, str); \ p = str; \ while (p != vrt_magic_string_end) { \ diff --git a/bin/varnishtest/tests/r03079.vtc b/bin/varnishtest/tests/r03079.vtc index 5da83f91f..3b2f57204 100644 --- a/bin/varnishtest/tests/r03079.vtc +++ b/bin/varnishtest/tests/r03079.vtc @@ -1,4 +1,6 @@ -varnishtest "set VCL_??? += VCL_STRING;" +varnishtest "set VCL_??? [+]= VCL_???;" + +# set STRING|HEADER += STRINGS; server s1 { rxreq @@ -23,3 +25,53 @@ client c1 { expect resp.status == 200 expect resp.http.x-powered-by == varnishtest1002 } -run + +# set BODY [+]= STRINGS; + +varnish v1 -vcl { + import blob; + backend be none; + sub vcl_recv { + return (synth(200)); + } + sub vcl_synth { + if (req.url ~ "synth") { + synthetic("hello"); + if (req.url ~ "add") { + synthetic("world"); + } + } + if (req.url ~ "string") { + set resp.body = "hello"; + if (req.url ~ "reset") { + set resp.body = "world"; + } + if (req.url ~ "add") { + set resp.body += "world"; + } + } + return (deliver); + } +} + +client c1 { + txreq -url "/synth" + rxresp + expect resp.body == hello + + txreq -url "/synth/add" + rxresp + expect resp.body == helloworld + + txreq -url "/string" + rxresp + expect resp.body == hello + + txreq -url "/string/reset" + rxresp + expect resp.body == world + + txreq -url "/string/add" + rxresp + expect resp.body == helloworld +} -run diff --git a/include/vrt.h b/include/vrt.h index 863e60f65..5e2543e1c 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -55,6 +55,8 @@ * Changed type of vsa_suckaddr_len from int to size_t * New prefix_{ptr|len} fields in vrt_backend * VRT_HashStrands32() added + * VRT_l_resp_body() changed + * VRT_l_beresp_body() changed * 10.0 (2019-09-15) * VRT_UpperLowerStrands added. * VRT_synth_page now takes STRANDS argument @@ -264,6 +266,11 @@ struct vrt_type { size_t szof; }; +enum lbody_e { + LBODY_SET, + LBODY_ADD, +}; + /*********************************************************************** * This is the composite argument we pass to compiled VCL and VRT * functions. diff --git a/lib/libvcc/generate.py b/lib/libvcc/generate.py index d662375fd..83af5c925 100755 --- a/lib/libvcc/generate.py +++ b/lib/libvcc/generate.py @@ -216,10 +216,12 @@ class vardef(object): elif self.wr: fo.write('\tsym->lname = "VRT_l_%s(ctx, ";\n' % cnam) s = "void VRT_l_%s(VRT_CTX, " % cnam - if self.typ != "STRING" and self.typ != "BODY": - s += "VCL_" + self.typ + ")" - else: + if self.typ == "STRING": s += ctyp.c + ", ...)" + elif self.typ == "BODY": + s += "enum lbody_e, " + ctyp.c + ", ...)" + else: + s += "VCL_" + self.typ + ")" varproto(s) fo.write("\tsym->w_methods =\n") restrict(fo, self.wr) diff --git a/lib/libvcc/vcc_action.c b/lib/libvcc/vcc_action.c index 5899b2b30..7a539fa58 100644 --- a/lib/libvcc/vcc_action.c +++ b/lib/libvcc/vcc_action.c @@ -84,7 +84,8 @@ static const struct assign { { STRING, '=', STRING_LIST }, { HEADER, T_INCR, STRING_LIST, "VRT_GetHdr(ctx, \v),\n" }, { HEADER, '=', STRING_LIST }, - { BODY, '=', STRING_LIST }, + { BODY, '=', STRING_LIST, "LBODY_SET,\n" }, + { BODY, T_INCR, STRING_LIST, "LBODY_ADD,\n" }, { VOID, '=', VOID } }; From nils.goroll at uplex.de Mon Dec 2 13:18:06 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 2 Dec 2019 13:18:06 +0000 (UTC) Subject: [master] 2d4c2a50e turn return(vcl(...)) ito a noop for req.restarts > 0 Message-ID: <20191202131806.5AF42114602@lists.varnish-cache.org> commit 2d4c2a50e835a3d2d1b1e2cfb1a89bc1b0602c62 Author: Nils Goroll Date: Wed Nov 13 09:57:32 2019 +0100 turn return(vcl(...)) ito a noop for req.restarts > 0 As the FSM will fail for this case, we should not run the code in the first place. diff --git a/bin/varnishd/cache/cache_vpi.c b/bin/varnishd/cache/cache_vpi.c index 1ffc62a3e..2e37e3875 100644 --- a/bin/varnishd/cache/cache_vpi.c +++ b/bin/varnishd/cache/cache_vpi.c @@ -93,7 +93,7 @@ VPI_vcl_select(VRT_CTX, VCL_VCL vcl) CHECK_OBJ_NOTNULL(req, REQ_MAGIC); CHECK_OBJ_NOTNULL(req->top, REQTOP_MAGIC); - if (IS_TOPREQ(req) && req->top->vcl0 != NULL) + if ((IS_TOPREQ(req) && req->top->vcl0 != NULL) || req->restarts > 0) return; // Illegal, req-FSM will fail this later. /* XXX VCL_Task* are somewhat duplicated to those in Req_Rollback called From nils.goroll at uplex.de Mon Dec 2 13:18:06 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 2 Dec 2019 13:18:06 +0000 (UTC) Subject: [master] 78c65ef9c gc vcl argument of VCL_Task* Message-ID: <20191202131806.764FD114605@lists.varnish-cache.org> commit 78c65ef9cc50f5b449bed1ac040322556c0183c7 Author: Nils Goroll Date: Wed Nov 13 10:09:58 2019 +0100 gc vcl argument of VCL_Task* It is unclear to me what the original intention was, but at any rate, the privs are not vcl-specific and the vcl argument was not used. The motivation for this change is the follow up commit "cleanup implicit rollback for return(vcl(...))": For this commit, it would be unclear which vcl to roll back with, but as it actually does not matter, I think this change is warranted. diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index 99547f73c..6e6ca7a8f 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -186,7 +186,7 @@ ved_include(struct req *preq, const char *src, const char *host, req->transport_priv = ecx; CNT_Embark(wrk, req); - VCL_TaskEnter(req->vcl, req->privs); + VCL_TaskEnter(req->privs); while (1) { ecx->woken = 0; diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 8e59d5321..c80f1addf 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -105,8 +105,8 @@ void Bereq_Rollback(struct busyobj *bo) CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); vbf_cleanup(bo); - VCL_TaskLeave(bo->vcl, bo->privs); - VCL_TaskEnter(bo->vcl, bo->privs); + VCL_TaskLeave(bo->privs); + VCL_TaskEnter(bo->privs); HTTP_Clone(bo->bereq, bo->bereq0); WS_Reset(bo->bereq->ws, bo->ws_bo); WS_Reset(bo->ws, bo->ws_bo); @@ -907,7 +907,7 @@ vbf_fetch_thread(struct worker *wrk, void *priv) } #endif - VCL_TaskEnter(bo->vcl, bo->privs); + VCL_TaskEnter(bo->privs); while (stp != F_STP_DONE) { CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); assert(bo->fetch_objcore->boc->refcount >= 1); @@ -928,7 +928,7 @@ vbf_fetch_thread(struct worker *wrk, void *priv) assert(bo->director_state == DIR_S_NULL); - VCL_TaskLeave(bo->vcl, bo->privs); + VCL_TaskLeave(bo->privs); http_Teardown(bo->bereq); http_Teardown(bo->beresp); diff --git a/bin/varnishd/cache/cache_req.c b/bin/varnishd/cache/cache_req.c index 3516d2a10..0363bf72e 100644 --- a/bin/varnishd/cache/cache_req.c +++ b/bin/varnishd/cache/cache_req.c @@ -190,11 +190,11 @@ void Req_Rollback(struct req *req) { if (IS_TOPREQ(req)) - VCL_TaskLeave(req->vcl, req->top->privs); - VCL_TaskLeave(req->vcl, req->privs); - VCL_TaskEnter(req->vcl, req->privs); + VCL_TaskLeave(req->top->privs); + VCL_TaskLeave(req->privs); + VCL_TaskEnter(req->privs); if (IS_TOPREQ(req)) - VCL_TaskEnter(req->vcl, req->top->privs); + VCL_TaskEnter(req->top->privs); HTTP_Clone(req->http, req->http0); if (WS_Overflowed(req->ws)) req->wrk->stats->ws_client_overflow++; diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 60090c8c0..154679a19 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -1105,11 +1105,11 @@ CNT_Request(struct req *req) wrk->vsl = NULL; if (nxt == REQ_FSM_DONE) { if (IS_TOPREQ(req)) { - VCL_TaskLeave(req->vcl, req->top->privs); + VCL_TaskLeave(req->top->privs); if (req->top->vcl0 != NULL) VCL_Rel(&req->top->vcl0); } - VCL_TaskLeave(req->vcl, req->privs); + VCL_TaskLeave(req->privs); AN(req->vsl->wid); VRB_Free(req); req->wrk = NULL; diff --git a/bin/varnishd/cache/cache_varnishd.h b/bin/varnishd/cache/cache_varnishd.h index b9e7e32ca..7fa11d949 100644 --- a/bin/varnishd/cache/cache_varnishd.h +++ b/bin/varnishd/cache/cache_varnishd.h @@ -420,8 +420,8 @@ void VCL_Ref(struct vcl *); void VCL_Refresh(struct vcl **); void VCL_Recache(struct worker *, struct vcl **); void VCL_Rel(struct vcl **); -void VCL_TaskEnter(const struct vcl *, struct vrt_privs *); -void VCL_TaskLeave(const struct vcl *, struct vrt_privs *); +void VCL_TaskEnter(struct vrt_privs *); +void VCL_TaskLeave(struct vrt_privs *); const char *VCL_Return_Name(unsigned); const char *VCL_Method_Name(unsigned); void VCL_Bo2Ctx(struct vrt_ctx *, struct busyobj *); diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c index 4b8a0bb0d..d74f964b4 100644 --- a/bin/varnishd/cache/cache_vcl.c +++ b/bin/varnishd/cache/cache_vcl.c @@ -176,9 +176,9 @@ vcl_send_event(VRT_CTX, enum vcl_event_e ev) if (ev == VCL_EVENT_LOAD || ev == VCL_EVENT_WARM) AN(ctx->msg); - VCL_TaskEnter(ctx->vcl, cli_task_privs); + VCL_TaskEnter(cli_task_privs); r = ctx->vcl->conf->event_vcl(ctx, ev); - VCL_TaskLeave(ctx->vcl, cli_task_privs); + VCL_TaskLeave(cli_task_privs); if (r && (ev == VCL_EVENT_COLD || ev == VCL_EVENT_DISCARD)) WRONG("A VMOD cannot fail COLD or DISCARD events"); diff --git a/bin/varnishd/cache/cache_vpi.c b/bin/varnishd/cache/cache_vpi.c index 2e37e3875..565536f74 100644 --- a/bin/varnishd/cache/cache_vpi.c +++ b/bin/varnishd/cache/cache_vpi.c @@ -100,8 +100,8 @@ VPI_vcl_select(VRT_CTX, VCL_VCL vcl) * from FSM for VCL_RET_VCL. Keeping them here to ensure there are no * tasks during calls to VCL_Rel / vcl_get */ - VCL_TaskLeave(req->vcl, req->top->privs); - VCL_TaskLeave(req->vcl, req->privs); + VCL_TaskLeave(req->top->privs); + VCL_TaskLeave(req->privs); if (IS_TOPREQ(req)) { AN(req->top); AZ(req->top->vcl0); @@ -113,6 +113,6 @@ VPI_vcl_select(VRT_CTX, VCL_VCL vcl) vcl_get(&req->vcl, vcl); VSLb(ctx->req->vsl, SLT_VCL_use, "%s via %s", req->vcl->loaded_name, vcl->loaded_name); - VCL_TaskEnter(req->vcl, req->privs); - VCL_TaskEnter(req->vcl, req->top->privs); + VCL_TaskEnter(req->privs); + VCL_TaskEnter(req->top->privs); } diff --git a/bin/varnishd/cache/cache_vrt_priv.c b/bin/varnishd/cache/cache_vrt_priv.c index bcfd7d8d4..b20660436 100644 --- a/bin/varnishd/cache/cache_vrt_priv.c +++ b/bin/varnishd/cache/cache_vrt_priv.c @@ -194,19 +194,17 @@ VRT_priv_fini(const struct vmod_priv *p) /*--------------------------------------------------------------------*/ void -VCL_TaskEnter(const struct vcl *vcl, struct vrt_privs *privs) +VCL_TaskEnter(struct vrt_privs *privs) { - AN(vcl); VRTPRIV_init(privs); } void -VCL_TaskLeave(const struct vcl *vcl, struct vrt_privs *privs) +VCL_TaskLeave(struct vrt_privs *privs) { struct vrt_priv *vp, *vp1; - AN(vcl); /* * NB: We don't bother removing entries as we finish them because it's * a costly operation. Instead we safely walk the whole tree and clear diff --git a/bin/varnishd/cache/cache_vrt_vmod.c b/bin/varnishd/cache/cache_vrt_vmod.c index c760606bc..183e33aeb 100644 --- a/bin/varnishd/cache/cache_vrt_vmod.c +++ b/bin/varnishd/cache/cache_vrt_vmod.c @@ -167,12 +167,14 @@ VPI_Vmod_Unload(VRT_CTX, struct vmod **hdl) { struct vmod *v; + (void) ctx; + ASSERT_CLI(); TAKE_OBJ_NOTNULL(v, hdl, VMOD_MAGIC); - VCL_TaskLeave(ctx->vcl, cli_task_privs); - VCL_TaskEnter(ctx->vcl, cli_task_privs); + VCL_TaskLeave(cli_task_privs); + VCL_TaskEnter(cli_task_privs); #ifndef DONT_DLCLOSE_VMODS /* diff --git a/bin/varnishd/http1/cache_http1_fsm.c b/bin/varnishd/http1/cache_http1_fsm.c index b5536d545..ebe9133db 100644 --- a/bin/varnishd/http1/cache_http1_fsm.c +++ b/bin/varnishd/http1/cache_http1_fsm.c @@ -411,8 +411,8 @@ HTTP1_Session(struct worker *wrk, struct req *req) wrk->stats->client_req++; CNT_Embark(wrk, req); if (req->req_step == R_STP_TRANSPORT) { - VCL_TaskEnter(req->vcl, req->privs); - VCL_TaskEnter(req->vcl, req->top->privs); + VCL_TaskEnter(req->privs); + VCL_TaskEnter(req->top->privs); } if (CNT_Request(req) == REQ_FSM_DISEMBARK) return; diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index 4d33525c0..4930a5e0a 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -524,8 +524,8 @@ h2_do_req(struct worker *wrk, void *priv) THR_SetRequest(req); CNT_Embark(wrk, req); if (req->req_step == R_STP_TRANSPORT) { - VCL_TaskEnter(req->vcl, req->privs); - VCL_TaskEnter(req->vcl, req->top->privs); + VCL_TaskEnter(req->privs); + VCL_TaskEnter(req->top->privs); } wrk->stats->client_req++; From nils.goroll at uplex.de Mon Dec 2 13:18:06 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 2 Dec 2019 13:18:06 +0000 (UTC) Subject: [master] fd7c8bfca assert that esi requests do start on vcl0 Message-ID: <20191202131806.9613B114609@lists.varnish-cache.org> commit fd7c8bfca2c0ca7a00477618d80c2aab34b84903 Author: Nils Goroll Date: Wed Nov 13 12:00:37 2019 +0100 assert that esi requests do start on vcl0 ... which is the vcl the topreq started on diff --git a/bin/varnishd/cache/cache_vpi.c b/bin/varnishd/cache/cache_vpi.c index 565536f74..8a345ba41 100644 --- a/bin/varnishd/cache/cache_vpi.c +++ b/bin/varnishd/cache/cache_vpi.c @@ -96,6 +96,9 @@ VPI_vcl_select(VRT_CTX, VCL_VCL vcl) if ((IS_TOPREQ(req) && req->top->vcl0 != NULL) || req->restarts > 0) return; // Illegal, req-FSM will fail this later. + if (! IS_TOPREQ(req)) + assert(req->vcl == req->top->vcl0); + /* XXX VCL_Task* are somewhat duplicated to those in Req_Rollback called * from FSM for VCL_RET_VCL. Keeping them here to ensure there are no * tasks during calls to VCL_Rel / vcl_get From nils.goroll at uplex.de Mon Dec 2 13:18:06 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 2 Dec 2019 13:18:06 +0000 (UTC) Subject: [master] 525ff0e7b cleanup implicit rollback for return(vcl(...)) Message-ID: <20191202131806.B766211460D@lists.varnish-cache.org> commit 525ff0e7b00939538f1b3a4ce1f4e61f3dee44f2 Author: Nils Goroll Date: Wed Nov 13 12:06:55 2019 +0100 cleanup implicit rollback for return(vcl(...)) VCC generates a call to VPI_vcl_select() before returning to the fsm. We basically conducted half a rollback in VPI_vcl_slect and a rull rollback in the fsm. De-duplicate this dance and assert in the fsm that our request looks rolled back. diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 154679a19..f4067c1d8 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -879,7 +879,8 @@ cnt_recv(struct worker *wrk, struct req *req) VCL_recv_method(req->vcl, wrk, req, NULL, NULL); if (wrk->handling == VCL_RET_VCL && req->restarts == 0) { - Req_Rollback(req); + // Req_Rollback has happened in VPI_vcl_select + assert(WS_Snapshot(req->ws) == req->ws_req); cnt_recv_prep(req, ci); VCL_recv_method(req->vcl, wrk, req, NULL, NULL); } diff --git a/bin/varnishd/cache/cache_vpi.c b/bin/varnishd/cache/cache_vpi.c index 8a345ba41..b80f4be04 100644 --- a/bin/varnishd/cache/cache_vpi.c +++ b/bin/varnishd/cache/cache_vpi.c @@ -99,12 +99,8 @@ VPI_vcl_select(VRT_CTX, VCL_VCL vcl) if (! IS_TOPREQ(req)) assert(req->vcl == req->top->vcl0); - /* XXX VCL_Task* are somewhat duplicated to those in Req_Rollback called - * from FSM for VCL_RET_VCL. Keeping them here to ensure there are no - * tasks during calls to VCL_Rel / vcl_get - */ - VCL_TaskLeave(req->top->privs); - VCL_TaskLeave(req->privs); + Req_Rollback(req); + if (IS_TOPREQ(req)) { AN(req->top); AZ(req->top->vcl0); @@ -116,6 +112,4 @@ VPI_vcl_select(VRT_CTX, VCL_VCL vcl) vcl_get(&req->vcl, vcl); VSLb(ctx->req->vsl, SLT_VCL_use, "%s via %s", req->vcl->loaded_name, vcl->loaded_name); - VCL_TaskEnter(req->privs); - VCL_TaskEnter(req->top->privs); } From nils.goroll at uplex.de Mon Dec 2 13:18:06 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 2 Dec 2019 13:18:06 +0000 (UTC) Subject: [master] 2c8aefc3f improve the vcl(label) documentation Message-ID: <20191202131806.D6644114611@lists.varnish-cache.org> commit 2c8aefc3fe9d6982a1a1d3939a7121abc95c13ea Author: Nils Goroll Date: Wed Nov 13 12:12:37 2019 +0100 improve the vcl(label) documentation diff --git a/doc/sphinx/users-guide/vcl-built-in-subs.rst b/doc/sphinx/users-guide/vcl-built-in-subs.rst index 810ffedad..421186e4e 100644 --- a/doc/sphinx/users-guide/vcl-built-in-subs.rst +++ b/doc/sphinx/users-guide/vcl-built-in-subs.rst @@ -107,8 +107,14 @@ of the following keywords: :ref:`vcl_hash` to :ref:`vcl_purge`. ``vcl(label)`` - Switch to vcl labelled *label*. This will continue vcl processing - in this vcl's :ref:`vcl_recv` as if it was the active vcl. + Switch to vcl labelled *label*. + + This will roll back the request as if ``std.rollback(req)`` was + called and continue vcl processing in :ref:`vcl_recv` of the vcl + labelled *label* as if it was the active vcl. + + The ``vcl(label)`` return is only valid while the ``req.restarts`` + count is zero and if used from the active vcl. See the :ref:`ref_cli_vcl_label` command. From nils.goroll at uplex.de Mon Dec 2 13:18:06 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 2 Dec 2019 13:18:06 +0000 (UTC) Subject: [master] 381af034a gc unused argument Message-ID: <20191202131807.023A2114615@lists.varnish-cache.org> commit 381af034a232716737052ac1bbb405306815a6fb Author: Nils Goroll Date: Wed Nov 13 13:13:48 2019 +0100 gc unused argument I actually did consider this before, but thought we should keep it because we are currently dicussing to add a CTX to vmod object destructors. But this piece of code is unrelated and at any rate the argument can be added back when we need it. in short: @Dridi is right diff --git a/bin/varnishd/cache/cache_vrt_vmod.c b/bin/varnishd/cache/cache_vrt_vmod.c index 183e33aeb..5a5fd1d24 100644 --- a/bin/varnishd/cache/cache_vrt_vmod.c +++ b/bin/varnishd/cache/cache_vrt_vmod.c @@ -163,12 +163,10 @@ VPI_Vmod_Init(VRT_CTX, struct vmod **hdl, unsigned nbr, void *ptr, int len, } void -VPI_Vmod_Unload(VRT_CTX, struct vmod **hdl) +VPI_Vmod_Unload(struct vmod **hdl) { struct vmod *v; - (void) ctx; - ASSERT_CLI(); TAKE_OBJ_NOTNULL(v, hdl, VMOD_MAGIC); diff --git a/include/vcc_interface.h b/include/vcc_interface.h index 78dcccdcf..0d46f7c0f 100644 --- a/include/vcc_interface.h +++ b/include/vcc_interface.h @@ -53,7 +53,7 @@ void VPI_count(VRT_CTX, unsigned); int VPI_Vmod_Init(VRT_CTX, struct vmod **hdl, unsigned nbr, void *ptr, int len, const char *nm, const char *path, const char *file_id, const char *backup); -void VPI_Vmod_Unload(VRT_CTX, struct vmod **hdl); +void VPI_Vmod_Unload(struct vmod **hdl); typedef int acl_match_f(VRT_CTX, const VCL_IP); diff --git a/lib/libvcc/vcc_vmod.c b/lib/libvcc/vcc_vmod.c index dca8eabd8..a4d229a05 100644 --- a/lib/libvcc/vcc_vmod.c +++ b/lib/libvcc/vcc_vmod.c @@ -358,7 +358,7 @@ vcc_ParseImport(struct vcc *tl) /* XXX: zero the function pointer structure ?*/ VSB_printf(ifp->fin, "\t\tVRT_priv_fini(&vmod_priv_%.*s);", PF(mod)); VSB_printf(ifp->final, - "\t\tVPI_Vmod_Unload(ctx, &VGC_vmod_%.*s);", PF(mod)); + "\t\tVPI_Vmod_Unload(&VGC_vmod_%.*s);", PF(mod)); vj = vjsn_parse(vmd->json, &p); XXXAZ(p); From dridi.boukelmoune at gmail.com Mon Dec 2 17:56:06 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 2 Dec 2019 17:56:06 +0000 (UTC) Subject: [master] 32c7d7188 GC stale comment Message-ID: <20191202175606.96E2158F9@lists.varnish-cache.org> commit 32c7d718814e6ffce1038196d24cf3dd5986d394 Author: Dridi Boukelmoune Date: Mon Dec 2 18:54:47 2019 +0100 GC stale comment Refs 45af9764189ec55f0626a44ff64df7bef5d87d41 diff --git a/lib/libvcc/generate.py b/lib/libvcc/generate.py index 83af5c925..b526bfcdf 100755 --- a/lib/libvcc/generate.py +++ b/lib/libvcc/generate.py @@ -33,11 +33,6 @@ ####################################################################### # These are our tokens -# We could drop all words such as "include", "if" etc, and use the -# ID type instead, but declaring them tokens makes them reserved words -# which hopefully makes for better error messages. -# XXX: does it actually do that ? - import copy import sys from os.path import join From phk at FreeBSD.org Mon Dec 2 22:10:07 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 2 Dec 2019 22:10:07 +0000 (UTC) Subject: [master] 5d8a6c001 For CLI commands forwarded indirectly to the worker (via mgt_cli_askchild() as opposed to directly through mcf_askchild()), a truncated CLI response is not a failure. Message-ID: <20191202221007.32523620EE@lists.varnish-cache.org> commit 5d8a6c0012c05c2f095c3a59e9f1dbc89b9f2c55 Author: Poul-Henning Kamp Date: Mon Dec 2 22:05:30 2019 +0000 For CLI commands forwarded indirectly to the worker (via mgt_cli_askchild() as opposed to directly through mcf_askchild()), a truncated CLI response is not a failure. Fixes #3038 diff --git a/bin/varnishd/mgt/mgt_cli.c b/bin/varnishd/mgt/mgt_cli.c index 4abcfe8a6..f40f35b3f 100644 --- a/bin/varnishd/mgt/mgt_cli.c +++ b/bin/varnishd/mgt/mgt_cli.c @@ -122,7 +122,6 @@ mcf_askchild(struct cli *cli, const char * const *av, void *priv) int i; char *q; unsigned u; - struct vsb *vsb; (void)priv; /* @@ -137,21 +136,19 @@ mcf_askchild(struct cli *cli, const char * const *av, void *priv) "Type 'help' for more info."); return; } - vsb = VSB_new_auto(); + VSB_clear(cli_buf); for (i = 1; av[i] != NULL; i++) { - VSB_quote(vsb, av[i], strlen(av[i]), 0); - VSB_putc(vsb, ' '); + VSB_quote(cli_buf, av[i], strlen(av[i]), 0); + VSB_putc(cli_buf, ' '); } - VSB_putc(vsb, '\n'); - AZ(VSB_finish(vsb)); - if (VSB_tofile(cli_o, vsb)) { - VSB_destroy(&vsb); + VSB_putc(cli_buf, '\n'); + AZ(VSB_finish(cli_buf)); + if (VSB_tofile(cli_o, cli_buf)) { VCLI_SetResult(cli, CLIS_COMMS); VCLI_Out(cli, "CLI communication error"); MCH_Cli_Fail(); return; } - VSB_destroy(&vsb); if (VCLI_ReadResult(cli_i, &u, &q, mgt_param.cli_timeout)) MCH_Cli_Fail(); VCLI_SetResult(cli, u); @@ -179,20 +176,14 @@ mgt_cli_askchild(unsigned *status, char **resp, const char *fmt, ...) va_list ap; unsigned u; - if (cli_buf == NULL) { - cli_buf = VSB_new_auto(); - AN(cli_buf); - } else { - VSB_clear(cli_buf); - } + AN(status); + VSB_clear(cli_buf); if (resp != NULL) *resp = NULL; - if (status != NULL) - *status = 0; + *status = 0; if (cli_i < 0 || cli_o < 0) { - if (status != NULL) - *status = CLIS_CANT; + *status = CLIS_CANT; return (CLIS_CANT); } va_start(ap, fmt); @@ -202,8 +193,7 @@ mgt_cli_askchild(unsigned *status, char **resp, const char *fmt, ...) i = VSB_len(cli_buf); assert(i > 0 && VSB_data(cli_buf)[i - 1] == '\n'); if (VSB_tofile(cli_o, cli_buf)) { - if (status != NULL) - *status = CLIS_COMMS; + *status = CLIS_COMMS; if (resp != NULL) *resp = strdup("CLI communication error"); MCH_Cli_Fail(); @@ -212,9 +202,8 @@ mgt_cli_askchild(unsigned *status, char **resp, const char *fmt, ...) if (VCLI_ReadResult(cli_i, &u, resp, mgt_param.cli_timeout)) MCH_Cli_Fail(); - if (status != NULL) - *status = u; - return (u == CLIS_OK ? 0 : u); + *status = u; + return (u == CLIS_OK || u == CLIS_TRUNCATED ? 0 : u); } /*--------------------------------------------------------------------*/ @@ -369,6 +358,8 @@ mgt_cli_init_cls(void) VCLS_AddFunc(mgt_cls, MCF_AUTH, cli_proto); VCLS_AddFunc(mgt_cls, MCF_AUTH, cli_debug); VCLS_AddFunc(mgt_cls, MCF_AUTH, cli_askchild); + cli_buf = VSB_new_auto(); + AN(cli_buf); } /*-------------------------------------------------------------------- diff --git a/bin/varnishtest/tests/r03038.vtc b/bin/varnishtest/tests/r03038.vtc new file mode 100644 index 000000000..fd27faab8 --- /dev/null +++ b/bin/varnishtest/tests/r03038.vtc @@ -0,0 +1,25 @@ +varnishtest "vcl.list and cli_limit" + +server s1 { +} -start + +varnish v1 -vcl+backend { } -start +varnish v1 -vcl+backend { } +varnish v1 -vcl+backend { } +varnish v1 -vcl+backend { } +varnish v1 -vcl+backend { } +varnish v1 -vcl+backend { } +varnish v1 -vcl+backend { } +varnish v1 -vcl+backend { } +varnish v1 -vcl+backend { } +varnish v1 -vcl+backend { } + +varnish v1 -expect n_vcl_avail == 10 + +varnish v1 -cliok "param.set cli_limit 128b" + +varnish v1 -clierr 201 "vcl.list" + +varnish v1 -stop + +varnish v1 -clierr 201 "vcl.list" From dridi.boukelmoune at gmail.com Tue Dec 3 10:00:09 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 3 Dec 2019 10:00:09 +0000 (UTC) Subject: [master] 806b697a4 Whitespace OCD Message-ID: <20191203100009.E7C4B9C61C@lists.varnish-cache.org> commit 806b697a4c72db45a9e186b9c4b3ce64bfbdde11 Author: Dridi Boukelmoune Date: Tue Dec 3 10:58:46 2019 +0100 Whitespace OCD diff --git a/bin/varnishtest/tests/r03038.vtc b/bin/varnishtest/tests/r03038.vtc index fd27faab8..ea942e6fe 100644 --- a/bin/varnishtest/tests/r03038.vtc +++ b/bin/varnishtest/tests/r03038.vtc @@ -1,10 +1,10 @@ varnishtest "vcl.list and cli_limit" -server s1 { +server s1 { } -start varnish v1 -vcl+backend { } -start -varnish v1 -vcl+backend { } +varnish v1 -vcl+backend { } varnish v1 -vcl+backend { } varnish v1 -vcl+backend { } varnish v1 -vcl+backend { } From dridi at varni.sh Tue Dec 3 10:06:36 2019 From: dridi at varni.sh (Dridi Boukelmoune) Date: Tue, 3 Dec 2019 10:06:36 +0000 Subject: [master] 5d8a6c001 For CLI commands forwarded indirectly to the worker (via mgt_cli_askchild() as opposed to directly through mcf_askchild()), a truncated CLI response is not a failure. In-Reply-To: <20191202221007.32523620EE@lists.varnish-cache.org> References: <20191202221007.32523620EE@lists.varnish-cache.org> Message-ID: On Mon, Dec 2, 2019 at 10:10 PM Poul-Henning Kamp wrote: > > > commit 5d8a6c0012c05c2f095c3a59e9f1dbc89b9f2c55 > Author: Poul-Henning Kamp > Date: Mon Dec 2 22:05:30 2019 +0000 > > For CLI commands forwarded indirectly to the worker (via > mgt_cli_askchild() as opposed to directly through mcf_askchild()), > a truncated CLI response is not a failure. > > Fixes #3038 As explained in [3092] there is more to 3038, and in particular commands going through VTE don't truncate as documented [*] in the varnishd manual: > If the response exceeds this limit, the response code will be 201 instead > of 200 and the last line will indicate the truncation. The test case fails with either of the following changes: > diff --git i/bin/varnishtest/tests/r03038.vtc w/bin/varnishtest/tests/r03038.vtc > index ea942e6fe..fd35790dd 100644 > --- i/bin/varnishtest/tests/r03038.vtc > +++ w/bin/varnishtest/tests/r03038.vtc > @@ -19,7 +19,9 @@ varnish v1 -expect n_vcl_avail == 10 > varnish v1 -cliok "param.set cli_limit 128b" > > varnish v1 -clierr 201 "vcl.list" > +varnish v1 -cliexpect "[response was truncated]" > > varnish v1 -stop > > varnish v1 -clierr 201 "vcl.list" > +varnish v1 -cliexpect "[response was truncated]" So in my opinion there is still work to be done in this area and keeping track of the known CLI quirks should be done in a github issue. Dridi [3092] https://github.com/varnishcache/varnish-cache/pull/3092#issuecomment-560658131 [*] https://varnish-cache.org/docs/6.3/reference/varnishd.html#cli-limit From phk at phk.freebsd.dk Tue Dec 3 10:34:09 2019 From: phk at phk.freebsd.dk (Poul-Henning Kamp) Date: Tue, 03 Dec 2019 10:34:09 +0000 Subject: [master] 5d8a6c001 For CLI commands forwarded indirectly to the worker (via mgt_cli_askchild() as opposed to directly through mcf_askchild()), a truncated CLI response is not a failure. In-Reply-To: References: <20191202221007.32523620EE@lists.varnish-cache.org> Message-ID: <13154.1575369249@critter.freebsd.dk> -------- In message , Dridi Boukelmoune writes: >As explained in [3092] there is more to 3038, and in particular commands >going through VTE don't truncate as documented [*] in the varnishd manual: One of the reasons our issues fail to resolve is that the start wandering all over the place and I've had it with that. Reading through ever longer sagas to try to divine if a given issue can be closed or not is not productive use of anybodys time. It is painfully obvious in bug-washes, that the longer the issue comments, the less people are willing to engage and try to close, and no wonder! 3038 was a bug in vcl.list, that problem is solved and the ticket is closed. If there are seperate issues in VTE, then by all means open a ticket on that *AND ONLY THAT* so that we can close it when that issue is solved. -- Poul-Henning Kamp | UNIX since Zilog Zeus 3.20 phk at FreeBSD.ORG | TCP/IP since RFC 956 FreeBSD committer | BSD since 4.3-tahoe Never attribute to malice what can adequately be explained by incompetence. From dridi at varni.sh Tue Dec 3 10:46:34 2019 From: dridi at varni.sh (Dridi Boukelmoune) Date: Tue, 3 Dec 2019 10:46:34 +0000 Subject: [master] 5d8a6c001 For CLI commands forwarded indirectly to the worker (via mgt_cli_askchild() as opposed to directly through mcf_askchild()), a truncated CLI response is not a failure. In-Reply-To: <13154.1575369249@critter.freebsd.dk> References: <20191202221007.32523620EE@lists.varnish-cache.org> <13154.1575369249@critter.freebsd.dk> Message-ID: On Tue, Dec 3, 2019 at 10:34 AM Poul-Henning Kamp wrote: > > -------- > In message > , Dridi Boukelmoune writes: > > >As explained in [3092] there is more to 3038, and in particular commands > >going through VTE don't truncate as documented [*] in the varnishd manual: > > One of the reasons our issues fail to resolve is that the start > wandering all over the place and I've had it with that. > > Reading through ever longer sagas to try to divine if a given issue > can be closed or not is not productive use of anybodys time. > > It is painfully obvious in bug-washes, that the longer the issue > comments, the less people are willing to engage and try to close, > and no wonder! > > 3038 was a bug in vcl.list, that problem is solved and the ticket is closed. > > If there are seperate issues in VTE, then by all means open a ticket > on that *AND ONLY THAT* so that we can close it when that issue is solved. Like I said, we need to spend more brain cycles in this area. https://github.com/varnishcache/varnish-cache/issues/3148 Dridi From nils.goroll at uplex.de Tue Dec 3 11:09:43 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Tue, 3 Dec 2019 12:09:43 +0100 Subject: [master] 5d8a6c001 For CLI commands forwarded indirectly to the worker (via mgt_cli_askchild() as opposed to directly through mcf_askchild()), a truncated CLI response is not a failure. In-Reply-To: <13154.1575369249@critter.freebsd.dk> References: <20191202221007.32523620EE@lists.varnish-cache.org> <13154.1575369249@critter.freebsd.dk> Message-ID: <04a647a8-c31d-a3ef-0b9b-fcdeb4eee289@uplex.de> On 03/12/2019 11:34, Poul-Henning Kamp wrote: > Reading through ever longer sagas to try to divine if a given issue > can be closed or not is not productive use of anybodys time. I was wondering about the same. In particular for PRs, would it maybe make sense to re-start with a fresh one for those which had a certain number of iterations? -- ** * * UPLEX - Nils Goroll Systemoptimierung Scheffelstra?e 32 22301 Hamburg tel +49 40 28805731 mob +49 170 2723133 fax +49 40 42949753 xmpp://slink at jabber.int.uplex.de/ http://uplex.de/ -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 488 bytes Desc: OpenPGP digital signature URL: From phk at phk.freebsd.dk Tue Dec 3 11:29:52 2019 From: phk at phk.freebsd.dk (Poul-Henning Kamp) Date: Tue, 03 Dec 2019 11:29:52 +0000 Subject: [master] 5d8a6c001 For CLI commands forwarded indirectly to the worker (via mgt_cli_askchild() as opposed to directly through mcf_askchild()), a truncated CLI response is not a failure. In-Reply-To: <04a647a8-c31d-a3ef-0b9b-fcdeb4eee289@uplex.de> References: <20191202221007.32523620EE@lists.varnish-cache.org> <13154.1575369249@critter.freebsd.dk> <04a647a8-c31d-a3ef-0b9b-fcdeb4eee289@uplex.de> Message-ID: <13507.1575372592@critter.freebsd.dk> -------- In message <04a647a8-c31d-a3ef-0b9b-fcdeb4eee289 at uplex.de>, Nils Goroll writes: >On 03/12/2019 11:34, Poul-Henning Kamp wrote: >> Reading through ever longer sagas to try to divine if a given issue >> can be closed or not is not productive use of anybodys time. > >I was wondering about the same. In particular for PRs, would it maybe make sense >to re-start with a fresh one for those which had a certain number of iterations? I would be satisfied if for now we open new tickets for new issues discovered along the way. -- 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 nils.goroll at uplex.de Tue Dec 3 14:42:06 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Tue, 3 Dec 2019 14:42:06 +0000 (UTC) Subject: [master] 7a883dc57 shard director: improve alt parameter test coverage Message-ID: <20191203144206.E48A9A4989@lists.varnish-cache.org> commit 7a883dc5744f5dd225c9501c010c71d8c1b5e9a6 Author: Nils Goroll Date: Tue Dec 3 15:35:35 2019 +0100 shard director: improve alt parameter test coverage diff --git a/bin/varnishtest/tests/d00022.vtc b/bin/varnishtest/tests/d00022.vtc index 9344234b7..e8cf95a5c 100644 --- a/bin/varnishtest/tests/d00022.vtc +++ b/bin/varnishtest/tests/d00022.vtc @@ -67,6 +67,13 @@ varnish v1 -vcl+backend { if (req.http.vrstart) { return(restart); } + + set resp.http.all-alt-0 = vd.backend(by=KEY, key=1756955383, alt=0, healthy=ALL); + set resp.http.all-alt-1 = vd.backend(by=KEY, key=1756955383, alt=1, healthy=ALL); + set resp.http.all-alt-2 = vd.backend(by=KEY, key=1756955383, alt=2, healthy=ALL); + set resp.http.chosen-alt-0 = vd.backend(by=KEY, key=1756955383, alt=0, healthy=CHOSEN); + set resp.http.chosen-alt-1 = vd.backend(by=KEY, key=1756955383, alt=1, healthy=CHOSEN); + set resp.http.chosen-alt-2 = vd.backend(by=KEY, key=1756955383, alt=2, healthy=CHOSEN); } } -start @@ -76,12 +83,30 @@ client c1 { txreq -url /1 rxresp expect resp.body == "ech3Ooj" + expect resp.http.all-alt-0 == "s1" + expect resp.http.all-alt-1 == "s2" + expect resp.http.all-alt-2 == "s3" + expect resp.http.chosen-alt-0 == "s1" + expect resp.http.chosen-alt-1 == "s2" + expect resp.http.chosen-alt-2 == "s3" txreq -url /2 -hdr "vrstart: 1" rxresp expect resp.body == "ieQu2qua" + expect resp.http.all-alt-0 == "s1" + expect resp.http.all-alt-1 == "s2" + expect resp.http.all-alt-2 == "s3" + expect resp.http.chosen-alt-0 == "s1" + expect resp.http.chosen-alt-1 == "s2" + expect resp.http.chosen-alt-2 == "s3" txreq -url /3 -hdr "vrstart: 1" rxresp expect resp.body == "xiuFi3Pe" + expect resp.http.all-alt-0 == "s1" + expect resp.http.all-alt-1 == "s2" + expect resp.http.all-alt-2 == "s3" + expect resp.http.chosen-alt-0 == "s1" + expect resp.http.chosen-alt-1 == "s2" + expect resp.http.chosen-alt-2 == "s3" } -run From nils.goroll at uplex.de Fri Dec 6 08:33:08 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Fri, 6 Dec 2019 08:33:08 +0000 (UTC) Subject: [master] 7ae1bf244 test std.fileread on non-existing file Message-ID: <20191206083308.2BF4FB0B51@lists.varnish-cache.org> commit 7ae1bf244187520bc1514dd82d0bd7b1bbb9a5c1 Author: Nils Goroll Date: Fri Dec 6 09:30:48 2019 +0100 test std.fileread on non-existing file diff --git a/bin/varnishtest/tests/m00004.vtc b/bin/varnishtest/tests/m00004.vtc index c418b8fb4..0dfad4f0e 100644 --- a/bin/varnishtest/tests/m00004.vtc +++ b/bin/varnishtest/tests/m00004.vtc @@ -32,6 +32,7 @@ varnish v1 -vcl+backend { } sub vcl_deliver { + std.log(std.fileread("/this/file/should/not/exists")); if (req.url == "/one") { set resp.http.one = std.fileread("${tmpdir}/m00004_file_one"); } else if (req.url == "/two") { From dridi.boukelmoune at gmail.com Fri Dec 6 13:36:07 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 6 Dec 2019 13:36:07 +0000 (UTC) Subject: [master] db83e59a6 That was just a warning Message-ID: <20191206133607.C3C9B60851@lists.varnish-cache.org> commit db83e59a6c75919e39d0dbce2e4ee0dfcb577a81 Author: Dridi Boukelmoune Date: Fri Nov 8 13:52:44 2019 +0100 That was just a warning diff --git a/lib/libvcc/vcc_compile.h b/lib/libvcc/vcc_compile.h index 74871e421..9e1875c8b 100644 --- a/lib/libvcc/vcc_compile.h +++ b/lib/libvcc/vcc_compile.h @@ -374,6 +374,7 @@ void vcc_Coord(const struct vcc *tl, struct vsb *vsb, void vcc_ErrToken(const struct vcc *tl, const struct token *t); void vcc_ErrWhere(struct vcc *, const struct token *); void vcc_ErrWhere2(struct vcc *, const struct token *, const struct token *); +void vcc_Warn(struct vcc *); void vcc__Expect(struct vcc *tl, unsigned tok, unsigned line); int vcc_IdIs(const struct token *t, const char *p); diff --git a/lib/libvcc/vcc_token.c b/lib/libvcc/vcc_token.c index 04e10f96b..20caadabe 100644 --- a/lib/libvcc/vcc_token.c +++ b/lib/libvcc/vcc_token.c @@ -183,6 +183,16 @@ vcc_markline(const struct vcc *tl, const char *l, const char *le, VSB_putc(tl->sb, '\n'); } +void +vcc_Warn(struct vcc *tl) +{ + + AN(tl); + AN(tl->err); + VSB_cat(tl->sb, "(That was just a warning)\n"); + tl->err = 0; +} + /*--------------------------------------------------------------------*/ /* XXX: should take first+last token */ diff --git a/lib/libvcc/vcc_utils.c b/lib/libvcc/vcc_utils.c index c0e598532..3270e203a 100644 --- a/lib/libvcc/vcc_utils.c +++ b/lib/libvcc/vcc_utils.c @@ -281,10 +281,9 @@ Emit_UDS_Path(struct vcc *tl, const struct token *t_path, const char *errid) VSB_printf(tl->sb, "%s: Cannot stat: %s\n", errid, strerror(errno)); vcc_ErrWhere(tl, t_path); - if (err == ENOENT || err == EACCES) { - VSB_cat(tl->sb, "(That was just a warning)\n"); - tl->err = 0; - } else + if (err == ENOENT || err == EACCES) + vcc_Warn(tl); + else return; } else if (!S_ISSOCK(st.st_mode)) { VSB_printf(tl->sb, "%s: Not a socket:\n", errid); diff --git a/lib/libvcc/vcc_xref.c b/lib/libvcc/vcc_xref.c index e5f5f2858..fbabf77ce 100644 --- a/lib/libvcc/vcc_xref.c +++ b/lib/libvcc/vcc_xref.c @@ -83,10 +83,8 @@ vcc_checkref(struct vcc *tl, const struct symbol *sym) VSB_printf(tl->sb, "Unused %s %.*s, defined:\n", sym->kind->name, PF(sym->def_b)); vcc_ErrWhere(tl, sym->def_b); - if (!tl->err_unref) { - VSB_cat(tl->sb, "(That was just a warning)\n"); - tl->err = 0; - } + if (!tl->err_unref) + vcc_Warn(tl); } } @@ -233,10 +231,8 @@ vcc_checkaction2(struct vcc *tl, const struct symbol *sym) return; VSB_cat(tl->sb, "Function unused\n"); vcc_ErrWhere(tl, p->name); - if (!tl->err_unref) { - VSB_cat(tl->sb, "(That was just a warning)\n"); - tl->err = 0; - } + if (!tl->err_unref) + vcc_Warn(tl); } int From dridi.boukelmoune at gmail.com Fri Dec 6 15:48:06 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 6 Dec 2019 15:48:06 +0000 (UTC) Subject: [master] b41d04a99 GC unused option Message-ID: <20191206154806.4E11F63746@lists.varnish-cache.org> commit b41d04a9983b95111e468a481c62380662499156 Author: Dridi Boukelmoune Date: Fri Dec 6 16:43:13 2019 +0100 GC unused option diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py index a556d9035..6ed98632e 100755 --- a/lib/libvcc/vmodtool.py +++ b/lib/libvcc/vmodtool.py @@ -38,7 +38,6 @@ import os import sys import re import optparse -import unittest import copy import json import hashlib @@ -1166,16 +1165,8 @@ if __name__ == "__main__": oparser.add_option('-w', '--rstdir', metavar="directory", default='.', help='Where to save the generated RST files ' + '(default: ".")') - oparser.add_option('', '--runtests', action='store_true', default=False, - dest="runtests", help=optparse.SUPPRESS_HELP) (opts, args) = oparser.parse_args() - if opts.runtests: - # Pop off --runtests, pass remaining to unittest. - del sys.argv[1] - unittest.main() - exit() - i_vcc = None if len(args) == 1 and os.path.exists(args[0]): i_vcc = args[0] From dridi.boukelmoune at gmail.com Fri Dec 6 17:54:06 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 6 Dec 2019 17:54:06 +0000 (UTC) Subject: [master] 5ba8352f7 GC stale comment Message-ID: <20191206175406.9EC396E3BE@lists.varnish-cache.org> commit 5ba8352f7a83465a35b3a39fca2388f98367ee79 Author: Dridi Boukelmoune Date: Fri Dec 6 18:52:54 2019 +0100 GC stale comment diff --git a/doc/sphinx/Makefile.am b/doc/sphinx/Makefile.am index a9ce1bb75..27997013d 100644 --- a/doc/sphinx/Makefile.am +++ b/doc/sphinx/Makefile.am @@ -145,8 +145,6 @@ include/counters.rst: $(top_srcdir)/lib/libvcc/vsctool.py $(COUNTERS) BUILT_SOURCES += include/counters.rst -# XXX add varnishstat here when it's been _opt2rst'ed - include/varnishncsa_options.rst: $(top_builddir)/bin/varnishncsa/varnishncsa $(top_builddir)/bin/varnishncsa/varnishncsa --options > ${@}_ mv ${@}_ ${@} From dridi.boukelmoune at gmail.com Mon Dec 9 08:42:08 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 9 Dec 2019 08:42:08 +0000 (UTC) Subject: [master] e96c01d99 Document varnishstat ncurses up/down bindings Message-ID: <20191209084208.0BB4F917EE@lists.varnish-cache.org> commit e96c01d99d451855beba78855de735b30fadbd8c Author: Dridi Boukelmoune Date: Mon Dec 9 08:44:32 2019 +0100 Document varnishstat ncurses up/down bindings And avoid magic ASCII numbers when we could use character literals instead. diff --git a/bin/varnishstat/varnishstat_curses.c b/bin/varnishstat/varnishstat_curses.c index 0b5338225..7da4e6ef0 100644 --- a/bin/varnishstat/varnishstat_curses.c +++ b/bin/varnishstat/varnishstat_curses.c @@ -871,13 +871,13 @@ handle_keypress(int ch) { switch (ch) { case KEY_UP: - case 107: /* k */ + case 'k': if (current == 0) return; current--; break; case KEY_DOWN: - case 106: /* j */ + case 'j': if (current == n_ptarray - 1) return; current++; diff --git a/doc/sphinx/reference/varnishstat.rst b/doc/sphinx/reference/varnishstat.rst index 38684472a..043372a4f 100644 --- a/doc/sphinx/reference/varnishstat.rst +++ b/doc/sphinx/reference/varnishstat.rst @@ -73,10 +73,10 @@ Key bindings The following keys control the interactive display: - + or Navigate the counter list one line up. - + or Navigate the counter list one line down. or or From dridi.boukelmoune at gmail.com Mon Dec 9 08:42:08 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 9 Dec 2019 08:42:08 +0000 (UTC) Subject: [master] 60da5d783 Fold varnishstat ncurses top/bottom bindings Message-ID: <20191209084208.22DEA917F1@lists.varnish-cache.org> commit 60da5d7836077ae9a029e8bcbec0fac4a4dcd1cb Author: Dridi Boukelmoune Date: Mon Dec 9 08:47:27 2019 +0100 Fold varnishstat ncurses top/bottom bindings They have the same effect in practice despite looking different, so the simpler option is kept. Also considering vi key bindings and documented in the previous commit, and would definitely have the same meaning as and in this context. diff --git a/bin/varnishstat/varnishstat_curses.c b/bin/varnishstat/varnishstat_curses.c index 7da4e6ef0..a2987188e 100644 --- a/bin/varnishstat/varnishstat_curses.c +++ b/bin/varnishstat/varnishstat_curses.c @@ -896,9 +896,11 @@ handle_keypress(int ch) page_start += l_points; break; case KEY_HOME: + case 'g': current = 0; break; case KEY_END: + case 'G': current = n_ptarray - 1; break; case 'd': @@ -909,14 +911,6 @@ handle_keypress(int ch) scale = 1 - scale; rebuild = 1; break; - case 'g': - current = 0; - page_start = 0; - break; - case 'G': - current = n_ptarray - 1; - page_start = (current - l_points) + 1; - break; case '+': interval += 0.1; (void)snprintf(notification_message, NOTIF_MAXLEN, diff --git a/doc/sphinx/reference/varnishstat.rst b/doc/sphinx/reference/varnishstat.rst index 043372a4f..d8a7e106b 100644 --- a/doc/sphinx/reference/varnishstat.rst +++ b/doc/sphinx/reference/varnishstat.rst @@ -85,10 +85,10 @@ The following keys control the interactive display: or or Navigate the counter list one page down. - + or Navigate the counter list to the top. - + or Navigate the counter list to the bottom. @@ -99,12 +99,6 @@ The following keys control the interactive display: Toggle scaling of values. - - Go to the top of the counter list. - - - Go to the bottom of the counter list. - Increase verbosity. Defaults to only showing informational counters. From dridi.boukelmoune at gmail.com Mon Dec 9 08:42:08 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 9 Dec 2019 08:42:08 +0000 (UTC) Subject: [master] 8099ffa79 Declare varnishstat key bindings in an include table Message-ID: <20191209084208.3E3AA917F5@lists.varnish-cache.org> commit 8099ffa79ddc9a1964ed7985a9d3fc19fdf05d10 Author: Dridi Boukelmoune Date: Mon Dec 9 09:23:00 2019 +0100 Declare varnishstat key bindings in an include table For starters the include table will be used for two things: handle key presses in interactive mode and generate the "Key bindings" manual section. The table is so far built to satisfy those two requirements. It should then be repurposed for a help screen in interactive mode and possibly refined to accommodate this third use case. Refs #2990 diff --git a/bin/varnishstat/varnishstat_bindings.h b/bin/varnishstat/varnishstat_bindings.h new file mode 100644 index 000000000..678958e93 --- /dev/null +++ b/bin/varnishstat/varnishstat_bindings.h @@ -0,0 +1,106 @@ +/*- + * Copyright (c) 2019 Varnish Software AS + * All rights reserved. + * + * Author: Dridi Boukelmoune + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef BINDING_KEY +# define BINDING_KEY(key, name, next) +#endif + +#define BINDING_CTRL(c) ((c) & 0x1f) + +BINDING_KEY(KEY_UP, "UP", " or ") +BINDING_KEY('k', "k",) +BINDING(UP, "\tNavigate the counter list one line up.") + +BINDING_KEY(KEY_DOWN, "DOWN", " or ") +BINDING_KEY('j', "j",) +BINDING(DOWN, "\tNavigate the counter list one line down.") + +BINDING_KEY(KEY_PPAGE, "PAGEUP", " or ") +BINDING_KEY('b', "b", " or ") +BINDING_KEY(BINDING_CTRL('b'), "CTRL-B",) +BINDING(PAGEUP, "\tNavigate the counter list one page up.") + +BINDING_KEY(KEY_NPAGE, "PAGEDOWN", " or ") +BINDING_KEY(' ', "SPACE", " or ") +BINDING_KEY(BINDING_CTRL('F'), "CTRL-F",) +BINDING(PAGEDOWN, "\tNavigate the counter list one page down.") + +BINDING_KEY(KEY_HOME, "HOME", " or ") +BINDING_KEY('g', "g",) +BINDING(TOP, "\tNavigate the counter list to the top.") + +BINDING_KEY(KEY_END, "END", " or ") +BINDING_KEY('G', "G",) +BINDING(BOTTOM, "\tNavigate the counter list to the bottom.") + +BINDING_KEY('d', "d",) +BINDING(UNSEEN, + "\tToggle between showing and hiding unseen counters. Unseen\n" + "\tcounters are those that has been zero for the entire runtime\n" + "\tof varnishstat. Defaults to hide unseen counters." +) + +BINDING_KEY('e', "e",) +BINDING(SCALE, "\tToggle scaling of values.") + +BINDING_KEY('v', "v",) +BINDING(VERBOSE, + "\tIncrease verbosity. Defaults to only showing informational\n" + "\tcounters." +) + +BINDING_KEY('V', "V",) +BINDING(QUIET, + "\tDecrease verbosity. Defaults to only showing informational\n" + "\tcounters." +) + +BINDING_KEY('q', "q",) +BINDING(QUIT, "\tQuit.") + +BINDING_KEY(BINDING_CTRL('t'), "CTRL+T",) +BINDING(SAMPLE, "\tSample now.") + +BINDING_KEY('+', "+",) +BINDING(ACCEL, "\tIncrease refresh interval.") + +BINDING_KEY('-', "-",) +BINDING(DECEL, "\tDecrease refresh interval.") + +#ifdef BINDING_SIG +BINDING_KEY(BINDING_CTRL('c'), "CTRL+C",) +BINDING(SIG_INT, "") + +BINDING_KEY(BINDING_CTRL('z'), "CTRL+Z",) +BINDING(SIG_TSTP, "") +# undef BINDING_SIG +#endif + +#undef BINDING_KEY +#undef BINDING_CTRL +#undef BINDING From dridi.boukelmoune at gmail.com Mon Dec 9 08:42:08 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 9 Dec 2019 08:42:08 +0000 (UTC) Subject: [master] 8106bbe13 Use the varnishstat bindings table for key presses Message-ID: <20191209084208.58BB0917F9@lists.varnish-cache.org> commit 8106bbe13906df1c16ffd95be5c3f58b86926015 Author: Dridi Boukelmoune Date: Mon Dec 9 09:31:05 2019 +0100 Use the varnishstat bindings table for key presses This has the unfortunate effect of splitting a single switch statement into two, however the second one being based on an enum should yield a warning if in the future a new binding is added but not handled. For example a binding involving the key? diff --git a/bin/varnishstat/Makefile.am b/bin/varnishstat/Makefile.am index 129e75fc9..2e29e7932 100644 --- a/bin/varnishstat/Makefile.am +++ b/bin/varnishstat/Makefile.am @@ -9,6 +9,7 @@ bin_PROGRAMS = varnishstat varnishstat_SOURCES = \ varnishstat.h \ varnishstat.c \ + varnishstat_bindings.h \ varnishstat_curses.c \ varnishstat_options.h diff --git a/bin/varnishstat/varnishstat_curses.c b/bin/varnishstat/varnishstat_curses.c index a2987188e..b49a20a35 100644 --- a/bin/varnishstat/varnishstat_curses.c +++ b/bin/varnishstat/varnishstat_curses.c @@ -62,7 +62,11 @@ #define VALUE_MAX 999999999999 -#define CTRL(c) ((c) & 037) +enum kb_e { +#define BINDING(name, desc) KB_ ## name, +#define BINDING_SIG +#include "varnishstat_bindings.h" +}; struct ma { unsigned n, nmax; @@ -869,56 +873,62 @@ draw_screen(void) static void handle_keypress(int ch) { + enum kb_e kb; + switch (ch) { - case KEY_UP: - case 'k': +#define BINDING_KEY(chr, name, or) \ + case chr: +#define BINDING(name, desc) \ + kb = KB_ ## name; \ + break; +#define BINDING_SIG +#include "varnishstat_bindings.h" + default: + return; + } + + switch (kb) { + case KB_UP: if (current == 0) return; current--; break; - case KEY_DOWN: - case 'j': + case KB_DOWN: if (current == n_ptarray - 1) return; current++; break; - case KEY_PPAGE: - case CTRL('b'): - case 'b': + case KB_PAGEUP: current -= l_points; page_start -= l_points; break; - case KEY_NPAGE: - case CTRL('f'): - case ' ': + case KB_PAGEDOWN: current += l_points; if (page_start + l_points < n_ptarray - 1) page_start += l_points; break; - case KEY_HOME: - case 'g': + case KB_TOP: current = 0; break; - case KEY_END: - case 'G': + case KB_BOTTOM: current = n_ptarray - 1; break; - case 'd': + case KB_UNSEEN: hide_unseen = 1 - hide_unseen; rebuild = 1; break; - case 'e': + case KB_SCALE: scale = 1 - scale; rebuild = 1; break; - case '+': + case KB_ACCEL: interval += 0.1; (void)snprintf(notification_message, NOTIF_MAXLEN, "Refresh interval set to %.1f seconds.", interval); notification_eol = VTIM_mono() + 1.25; break; - case '-': + case KB_DECEL: interval -= 0.1; if (interval < 0.1) interval = 0.1; @@ -927,28 +937,28 @@ handle_keypress(int ch) notification_eol = VTIM_mono() + 1.25; break; - case 'v': + case KB_VERBOSE: verbosity = VSC_ChangeLevel(verbosity, 1); rebuild = 1; break; - case 'V': + case KB_QUIET: verbosity = VSC_ChangeLevel(verbosity, -1); rebuild = 1; break; - case 'q': + case KB_QUIT: keep_running = 0; return; - case CTRL('c'): + case KB_SIG_INT: AZ(raise(SIGINT)); return; - case CTRL('t'): + case KB_SAMPLE: sample = 1; return; - case CTRL('z'): + case KB_SIG_TSTP: AZ(raise(SIGTSTP)); return; default: - return; + WRONG("unhandled key binding"); } update_position(); From dridi.boukelmoune at gmail.com Mon Dec 9 08:42:08 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 9 Dec 2019 08:42:08 +0000 (UTC) Subject: [master] 64cb7b678 Generate the varnishstat(1) key bindings section Message-ID: <20191209084208.73584917FD@lists.varnish-cache.org> commit 64cb7b678f20626cd991a720df2878fbc5e7e7d6 Author: Dridi Boukelmoune Date: Mon Dec 9 09:34:46 2019 +0100 Generate the varnishstat(1) key bindings section It should currently result in 1:1 RST code, and might be output slightly differently to accomodate a help screen, without changing the semantic of the RST code. diff --git a/bin/varnishstat/varnishstat.c b/bin/varnishstat/varnishstat.c index 0ab37c1ac..6906499e5 100644 --- a/bin/varnishstat/varnishstat.c +++ b/bin/varnishstat/varnishstat.c @@ -257,6 +257,18 @@ usage(int status) exit(status); } +static int +key_bindings(void) +{ + +#define BINDING_KEY(chr, name, next) \ + printf("<%s>" next, name); +#define BINDING(name, desc) \ + printf("\n%s\n\n", desc); +#include "varnishstat_bindings.h" + return (0); +} + int main(int argc, char * const *argv) { @@ -267,6 +279,9 @@ main(int argc, char * const *argv) int has_f = 0; struct vsc *vsc; + if (argc == 2 && !strcmp(argv[1], "--bindings")) + exit(key_bindings()); + vut = VUT_InitProg(argc, argv, &vopt_spec); AN(vut); vd = VSM_New(); diff --git a/doc/sphinx/Makefile.am b/doc/sphinx/Makefile.am index 27997013d..41305b4a2 100644 --- a/doc/sphinx/Makefile.am +++ b/doc/sphinx/Makefile.am @@ -187,8 +187,12 @@ include/varnishstat_options.rst: $(top_builddir)/bin/varnishstat/varnishstat include/varnishstat_synopsis.rst: $(top_builddir)/bin/varnishstat/varnishstat $(top_builddir)/bin/varnishstat/varnishstat --synopsis > ${@}_ mv ${@}_ ${@} +include/varnishstat_bindings.rst: $(top_builddir)/bin/varnishstat/varnishstat + $(top_builddir)/bin/varnishstat/varnishstat --bindings > ${@}_ + mv ${@}_ ${@} BUILT_SOURCES += include/varnishstat_options.rst \ - include/varnishstat_synopsis.rst + include/varnishstat_synopsis.rst \ + include/varnishstat_bindings.rst include/vsl-tags.rst: $(top_builddir)/lib/libvarnishapi/vsl2rst $(top_builddir)/lib/libvarnishapi/vsl2rst > ${@}_ diff --git a/doc/sphinx/reference/varnishstat.rst b/doc/sphinx/reference/varnishstat.rst index d8a7e106b..26d1b9836 100644 --- a/doc/sphinx/reference/varnishstat.rst +++ b/doc/sphinx/reference/varnishstat.rst @@ -71,54 +71,7 @@ Avg_1000 Key bindings ------------ -The following keys control the interactive display: - - or - Navigate the counter list one line up. - - or - Navigate the counter list one line down. - - or or - Navigate the counter list one page up. - - or or - Navigate the counter list one page down. - - or - Navigate the counter list to the top. - - or - Navigate the counter list to the bottom. - - - Toggle between showing and hiding unseen counters. Unseen - counters are those that has been zero for the entire runtime - of varnishstat. Defaults to hide unseen counters. - - - Toggle scaling of values. - - - Increase verbosity. Defaults to only showing informational - counters. - - - Decrease verbosity. Defaults to only showing informational - counters. - - - Quit. - - - Sample now. - -<+> - Increase refresh interval. - -<-> - Decrease refresh interval. - +.. include:: ../include/varnishstat_bindings.rst OUTPUTS ======= From phk at FreeBSD.org Mon Dec 9 17:28:07 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 9 Dec 2019 17:28:07 +0000 (UTC) Subject: [master] c8393e7b6 Move responsibility for appending [response was truncated] to 201 responses to varnishadm. Message-ID: <20191209172807.CEA59623AB@lists.varnish-cache.org> commit c8393e7b6ef98fe2a84568c16067424874a93093 Author: Poul-Henning Kamp Date: Mon Dec 9 17:26:02 2019 +0000 Move responsibility for appending [response was truncated] to 201 responses to varnishadm. Part of fix for: #3148 diff --git a/bin/varnishadm/varnishadm.c b/bin/varnishadm/varnishadm.c index 3a94413d8..6d42895f2 100644 --- a/bin/varnishadm/varnishadm.c +++ b/bin/varnishadm/varnishadm.c @@ -161,7 +161,7 @@ do_args(int sock, int argc, char * const *argv) unsigned status; char *answer = NULL; - for (i=0; i 0) cli_write(sock, " "); @@ -175,8 +175,12 @@ do_args(int sock, int argc, char * const *argv) (void)close(sock); printf("%s\n", answer); - if (status == CLIS_OK || status == CLIS_TRUNCATED) + if (status == CLIS_OK) exit(0); + if (status == CLIS_TRUNCATED) { + printf("[response was truncated]\n"); + exit(0); + } fprintf(stderr, "Command failed with error code %u\n", status); exit(1); } @@ -254,6 +258,8 @@ pass_answer(int fd) printf("%s\n", answer); free(answer); } + if (status == CLIS_TRUNCATED) + printf("[response was truncated]\n"); (void)fflush(stdout); } diff --git a/bin/varnishtest/tests/r01169.vtc b/bin/varnishtest/tests/r01169.vtc index 73e741d78..16b85f6f8 100644 --- a/bin/varnishtest/tests/r01169.vtc +++ b/bin/varnishtest/tests/r01169.vtc @@ -1,4 +1,4 @@ -varnishtest "cli_limit truncating full parameter listing - #1169" +varnishtest "cli_limit *not* truncating full parameter listing by default - #1169" server s1 { rxreq From phk at FreeBSD.org Mon Dec 9 19:20:09 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 9 Dec 2019 19:20:09 +0000 (UTC) Subject: [master] 684316bac Forgot this file in c8393e7b6ef98fe2 Message-ID: <20191209192009.250426E06A@lists.varnish-cache.org> commit 684316bac1d6e46c5753c659057d6e4df7e8c906 Author: Poul-Henning Kamp Date: Mon Dec 9 19:18:49 2019 +0000 Forgot this file in c8393e7b6ef98fe2 diff --git a/lib/libvarnish/vcli_serve.c b/lib/libvarnish/vcli_serve.c index 5c95f4f74..b97611978 100644 --- a/lib/libvarnish/vcli_serve.c +++ b/lib/libvarnish/vcli_serve.c @@ -263,7 +263,6 @@ cls_exec(struct VCLS_fd *cfd, char * const *av) char *s; unsigned lim; int retval = 0; - const char *trunc = "!\n[response was truncated]\n"; CHECK_OBJ_NOTNULL(cfd, VCLS_FD_MAGIC); cs = cfd->cls; @@ -334,7 +333,7 @@ cls_exec(struct VCLS_fd *cfd, char * const *av) if (len > lim) { if (cli->result == CLIS_OK) cli->result = CLIS_TRUNCATED; - strcpy(s + (lim - strlen(trunc)), trunc); + s[lim - 1] = '\0'; assert(strlen(s) <= lim); } if (VCLI_WriteResult(cfd->fdo, cli->result, s) || From phk at FreeBSD.org Mon Dec 9 19:20:09 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 9 Dec 2019 19:20:09 +0000 (UTC) Subject: [master] 2c56c7e10 Flexelinting Message-ID: <20191209192009.2CA166E06C@lists.varnish-cache.org> commit 2c56c7e10101aa2ff62a5f8ec950ac4ce89e4606 Author: Poul-Henning Kamp Date: Mon Dec 9 19:19:28 2019 +0000 Flexelinting diff --git a/bin/varnishstat/flint.lnt b/bin/varnishstat/flint.lnt index b3160aab6..e47f76850 100644 --- a/bin/varnishstat/flint.lnt +++ b/bin/varnishstat/flint.lnt @@ -1,4 +1,5 @@ -+libh mgt_event.h +// +libh mgt_event.h --efile(451, varnishstat_options.h) +-efile(451, varnishstat_options.h) // No include guard +-efile(451, varnishstat_bindings.h) // No include guard diff --git a/bin/varnishstat/varnishstat_bindings.h b/bin/varnishstat/varnishstat_bindings.h index 678958e93..f90ade1fa 100644 --- a/bin/varnishstat/varnishstat_bindings.h +++ b/bin/varnishstat/varnishstat_bindings.h @@ -26,6 +26,8 @@ * SUCH DAMAGE. */ +/*lint -save -e525 -e539 */ + #ifndef BINDING_KEY # define BINDING_KEY(key, name, next) #endif @@ -104,3 +106,6 @@ BINDING(SIG_TSTP, "") #undef BINDING_KEY #undef BINDING_CTRL #undef BINDING + +/*lint -restore */ + diff --git a/bin/varnishstat/varnishstat_curses.c b/bin/varnishstat/varnishstat_curses.c index b49a20a35..5ca5e279e 100644 --- a/bin/varnishstat/varnishstat_curses.c +++ b/bin/varnishstat/varnishstat_curses.c @@ -107,7 +107,7 @@ static const volatile uint64_t *main_cache_hit; static const volatile uint64_t *main_cache_miss; static int l_status, l_bar_t, l_points, l_bar_b, l_info; -static int colw_name = COLW_NAME_MIN; +static unsigned colw_name = COLW_NAME_MIN; static WINDOW *w_status = NULL; static WINDOW *w_bar_t = NULL; static WINDOW *w_points = NULL; From phk at FreeBSD.org Mon Dec 9 19:20:09 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 9 Dec 2019 19:20:09 +0000 (UTC) Subject: [master] 9b5332e2a Add an assert Message-ID: <20191209192009.44F2E6E06F@lists.varnish-cache.org> commit 9b5332e2a2e0c5d3a0485704164ea9d3cebe4b68 Author: Poul-Henning Kamp Date: Mon Dec 9 19:19:35 2019 +0000 Add an assert diff --git a/lib/libvarnish/vsb.c b/lib/libvarnish/vsb.c index 2adf50d02..66fc7b1ed 100644 --- a/lib/libvarnish/vsb.c +++ b/lib/libvarnish/vsb.c @@ -309,6 +309,8 @@ VSB_cat(struct vsb *s, const char *str) assert_VSB_integrity(s); assert_VSB_state(s, 0); + KASSERT(str != NULL, + ("%s called with a NULL str pointer", __func__)); if (s->s_error != 0) return (-1); From dridi.boukelmoune at gmail.com Wed Dec 11 11:37:06 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 11 Dec 2019 11:37:06 +0000 (UTC) Subject: [6.0] 4ca376fab Switch to python3 in all our scripts shebangs Message-ID: <20191211113706.7ACB6A3FBF@lists.varnish-cache.org> commit 4ca376fab22e126b4e0a89d1773c379d1af23d0e Author: Dridi Boukelmoune Date: Tue Mar 12 10:30:35 2019 +0100 Switch to python3 in all our scripts shebangs diff --git a/bin/varnishtest/huffman_gen.py b/bin/varnishtest/huffman_gen.py index ab6b30e87..dd4f8e1e8 100755 --- a/bin/varnishtest/huffman_gen.py +++ b/bin/varnishtest/huffman_gen.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import re import sys diff --git a/bin/varnishtest/witness.py b/bin/varnishtest/witness.py index a4f0fffa6..af4a56e55 100644 --- a/bin/varnishtest/witness.py +++ b/bin/varnishtest/witness.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # This script is in the public domain # diff --git a/doc/sphinx/vtc-syntax.py b/doc/sphinx/vtc-syntax.py index ba7bd6bd7..6d4946d32 100644 --- a/doc/sphinx/vtc-syntax.py +++ b/doc/sphinx/vtc-syntax.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # Copyright (c) 2006-2016 Varnish Software AS # All rights reserved. diff --git a/include/generate.py b/include/generate.py index e7d547593..c1ea3bcbb 100755 --- a/include/generate.py +++ b/include/generate.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # Copyright (c) 2006 Verdens Gang AS # Copyright (c) 2006-2015 Varnish Software AS diff --git a/include/tbl/style.py b/include/tbl/style.py index a88c475a3..0e7f657fb 100644 --- a/include/tbl/style.py +++ b/include/tbl/style.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # Very basic style-checker for include/tbl files. diff --git a/lib/libvarnishapi/generate.py b/lib/libvarnishapi/generate.py index d1357c985..ea4ebd02a 100755 --- a/lib/libvarnishapi/generate.py +++ b/lib/libvarnishapi/generate.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 #- # Copyright (c) 2006 Verdens Gang AS # Copyright (c) 2006-2015 Varnish Software AS diff --git a/lib/libvcc/generate.py b/lib/libvcc/generate.py index 31edaa4a7..919e1569a 100755 --- a/lib/libvcc/generate.py +++ b/lib/libvcc/generate.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # Copyright (c) 2006 Verdens Gang AS # Copyright (c) 2006-2015 Varnish Software AS diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py index e92cf521e..14f93b11d 100755 --- a/lib/libvcc/vmodtool.py +++ b/lib/libvcc/vmodtool.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # Copyright (c) 2010-2016 Varnish Software # All rights reserved. diff --git a/lib/libvcc/vsctool.py b/lib/libvcc/vsctool.py index f1e0d02ab..e65b0072f 100644 --- a/lib/libvcc/vsctool.py +++ b/lib/libvcc/vsctool.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # -*- encoding: utf-8 -*- # # Copyright (c) 2017 Varnish Software AS diff --git a/tools/gcov_digest.py b/tools/gcov_digest.py index 188fb499d..3fbfdf946 100644 --- a/tools/gcov_digest.py +++ b/tools/gcov_digest.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # # Copyright (c) 2017 Varnish Software AS # All rights reserved. diff --git a/tools/include_wash.py b/tools/include_wash.py index 973d5d6ad..94c11ba2c 100644 --- a/tools/include_wash.py +++ b/tools/include_wash.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 from __future__ import print_function From dridi at varni.sh Wed Dec 11 11:49:02 2019 From: dridi at varni.sh (Dridi Boukelmoune) Date: Wed, 11 Dec 2019 11:49:02 +0000 Subject: [6.0] 4ca376fab Switch to python3 in all our scripts shebangs In-Reply-To: <20191211113706.7ACB6A3FBF@lists.varnish-cache.org> References: <20191211113706.7ACB6A3FBF@lists.varnish-cache.org> Message-ID: On Wed, Dec 11, 2019 at 11:37 AM Dridi Boukelmoune wrote: > > > commit 4ca376fab22e126b4e0a89d1773c379d1af23d0e > Author: Dridi Boukelmoune > Date: Tue Mar 12 10:30:35 2019 +0100 > > Switch to python3 in all our scripts shebangs This is a back-port of a commit from when trunk switched to python3 only. Since python2 is going EOL soon, and 6.0 LTS will outlive it, I skipped the pull request step since: - patch applied without a conflict - it fixes all shebangs in 6.0 - our scripts are already py3-ready I sent another email to this list to inform you that RHEL 8 bans the unversioned /usr/bin/python version so in addition to saying goodbye to py2 on all active branches this is also a necessary step to enable el8 support in the future. For this reason I'm cross-posting on both dev and commit mailing lists. I'll leave it to Reza (CC'd) to include this in the changelog. Our 6.x packaging already requires python3 anyway, it's just that if python2 is present in the build root it will no longer be used implicitly (or at all). Dridi > diff --git a/bin/varnishtest/huffman_gen.py b/bin/varnishtest/huffman_gen.py > index ab6b30e87..dd4f8e1e8 100755 > --- a/bin/varnishtest/huffman_gen.py > +++ b/bin/varnishtest/huffman_gen.py > @@ -1,4 +1,4 @@ > -#!/usr/bin/env python > +#!/usr/bin/env python3 > > import re > import sys > diff --git a/bin/varnishtest/witness.py b/bin/varnishtest/witness.py > index a4f0fffa6..af4a56e55 100644 > --- a/bin/varnishtest/witness.py > +++ b/bin/varnishtest/witness.py > @@ -1,4 +1,4 @@ > -#!/usr/bin/env python > +#!/usr/bin/env python3 > # > # This script is in the public domain > # > diff --git a/doc/sphinx/vtc-syntax.py b/doc/sphinx/vtc-syntax.py > index ba7bd6bd7..6d4946d32 100644 > --- a/doc/sphinx/vtc-syntax.py > +++ b/doc/sphinx/vtc-syntax.py > @@ -1,4 +1,4 @@ > -#!/usr/bin/env python > +#!/usr/bin/env python3 > # > # Copyright (c) 2006-2016 Varnish Software AS > # All rights reserved. > diff --git a/include/generate.py b/include/generate.py > index e7d547593..c1ea3bcbb 100755 > --- a/include/generate.py > +++ b/include/generate.py > @@ -1,4 +1,4 @@ > -#!/usr/bin/env python > +#!/usr/bin/env python3 > # > # Copyright (c) 2006 Verdens Gang AS > # Copyright (c) 2006-2015 Varnish Software AS > diff --git a/include/tbl/style.py b/include/tbl/style.py > index a88c475a3..0e7f657fb 100644 > --- a/include/tbl/style.py > +++ b/include/tbl/style.py > @@ -1,4 +1,4 @@ > -#!/usr/bin/env python > +#!/usr/bin/env python3 > # > # Very basic style-checker for include/tbl files. > > diff --git a/lib/libvarnishapi/generate.py b/lib/libvarnishapi/generate.py > index d1357c985..ea4ebd02a 100755 > --- a/lib/libvarnishapi/generate.py > +++ b/lib/libvarnishapi/generate.py > @@ -1,4 +1,4 @@ > -#!/usr/bin/env python > +#!/usr/bin/env python3 > #- > # Copyright (c) 2006 Verdens Gang AS > # Copyright (c) 2006-2015 Varnish Software AS > diff --git a/lib/libvcc/generate.py b/lib/libvcc/generate.py > index 31edaa4a7..919e1569a 100755 > --- a/lib/libvcc/generate.py > +++ b/lib/libvcc/generate.py > @@ -1,4 +1,4 @@ > -#!/usr/bin/env python > +#!/usr/bin/env python3 > # > # Copyright (c) 2006 Verdens Gang AS > # Copyright (c) 2006-2015 Varnish Software AS > diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py > index e92cf521e..14f93b11d 100755 > --- a/lib/libvcc/vmodtool.py > +++ b/lib/libvcc/vmodtool.py > @@ -1,4 +1,4 @@ > -#!/usr/bin/env python > +#!/usr/bin/env python3 > # > # Copyright (c) 2010-2016 Varnish Software > # All rights reserved. > diff --git a/lib/libvcc/vsctool.py b/lib/libvcc/vsctool.py > index f1e0d02ab..e65b0072f 100644 > --- a/lib/libvcc/vsctool.py > +++ b/lib/libvcc/vsctool.py > @@ -1,4 +1,4 @@ > -#!/usr/bin/env python > +#!/usr/bin/env python3 > # -*- encoding: utf-8 -*- > # > # Copyright (c) 2017 Varnish Software AS > diff --git a/tools/gcov_digest.py b/tools/gcov_digest.py > index 188fb499d..3fbfdf946 100644 > --- a/tools/gcov_digest.py > +++ b/tools/gcov_digest.py > @@ -1,4 +1,4 @@ > -#!/usr/bin/env python > +#!/usr/bin/env python3 > # > # Copyright (c) 2017 Varnish Software AS > # All rights reserved. > diff --git a/tools/include_wash.py b/tools/include_wash.py > index 973d5d6ad..94c11ba2c 100644 > --- a/tools/include_wash.py > +++ b/tools/include_wash.py > @@ -1,4 +1,4 @@ > -#!/usr/bin/env python > +#!/usr/bin/env python3 > > from __future__ import print_function > > _______________________________________________ > varnish-commit mailing list > varnish-commit at varnish-cache.org > https://www.varnish-cache.org/lists/mailman/listinfo/varnish-commit From dridi.boukelmoune at gmail.com Wed Dec 11 12:15:08 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 11 Dec 2019 12:15:08 +0000 (UTC) Subject: [master] 77d5d0f08 Align symbol table columns in the generated C code Message-ID: <20191211121508.26F1FA5BD8@lists.varnish-cache.org> commit 77d5d0f08af9a53f8171d915115f70dd96ba4543 Author: Dridi Boukelmoune Date: Mon Dec 2 11:46:14 2019 +0100 Align symbol table columns in the generated C code At the end of the VGC we output the contents of the symbol table inside a C comment. It might look like this: /* * Symbol Table * * reserved VOID 41 41 acl * reserved VOID 41 41 backend * action VOID 40 41 ban * var HTTP 0 99 bereq * var BACKEND 0 99 bereq.backend * [...] */ All columns are currently aligned because we know all the native VCL types and only the last column with the symbol names has unpredictable and arbitrary entries lengths. However, considering the following snippet: new fb = directors.fallback(); The involved symbols will look like: object VOID 41 41 directors.fallback instance INSTANCE 41 41 fb func VOID 40 41 fb.add_backend func BACKEND 40 41 fb.backend func VOID 40 41 fb.remove_backend In the future VMOD objects will likely grow their own types and for the same snippet we may have this instead: object directors.fallback 41 41 directors.fallback method VOID 40 41 directors.fallback.add_backend method BACKEND 40 41 directors.fallback.backend method VOID 40 41 directors.fallback.remove_backend instance directors.fallback 41 41 fb This change was initially submitted as part of #3147, but was considered trivial and fast-track-able by PHK. diff --git a/lib/libvcc/vcc_xref.c b/lib/libvcc/vcc_xref.c index fbabf77ce..271f787fd 100644 --- a/lib/libvcc/vcc_xref.c +++ b/lib/libvcc/vcc_xref.c @@ -322,6 +322,21 @@ vcc_CheckUses(struct vcc *tl) /*---------------------------------------------------------------------*/ +static int sym_type_len = 0; + +static void v_matchproto_(symwalk_f) +vcc_xreftable_len(struct vcc *tl, const struct symbol *sym) +{ + int len; + + (void)tl; + CHECK_OBJ_NOTNULL(sym, SYMBOL_MAGIC); + CHECK_OBJ_NOTNULL(sym->type, TYPE_MAGIC); + len = strlen(sym->type->name); + if (sym_type_len < len) + sym_type_len = len; +} + static void v_matchproto_(symwalk_f) vcc_xreftable(struct vcc *tl, const struct symbol *sym) { @@ -330,7 +345,7 @@ vcc_xreftable(struct vcc *tl, const struct symbol *sym) CHECK_OBJ_NOTNULL(sym->kind, KIND_MAGIC); CHECK_OBJ_NOTNULL(sym->type, TYPE_MAGIC); Fc(tl, 0, " * %-8s ", sym->kind->name); - Fc(tl, 0, " %-9s ", sym->type->name); + Fc(tl, 0, " %-*s ", sym_type_len, sym->type->name); Fc(tl, 0, " %2u %2u ", sym->lorev, sym->hirev); VCC_SymName(tl->fc, sym); if (sym->wildcard != NULL) @@ -343,6 +358,7 @@ VCC_XrefTable(struct vcc *tl) { Fc(tl, 0, "\n/*\n * Symbol Table\n *\n"); + VCC_WalkSymbols(tl, vcc_xreftable_len, SYM_NONE); VCC_WalkSymbols(tl, vcc_xreftable, SYM_NONE); Fc(tl, 0, "*/\n\n"); } From dridi.boukelmoune at gmail.com Wed Dec 11 15:28:06 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 11 Dec 2019 15:28:06 +0000 (UTC) Subject: [master] 12a16117d Omit the separator in VCC functions extra arguments Message-ID: <20191211152806.1CD3CAD187@lists.varnish-cache.org> commit 12a16117da90cf08bbf9d6dd05512477f0b81a7c Author: Dridi Boukelmoune Date: Wed Dec 11 16:15:45 2019 +0100 Omit the separator in VCC functions extra arguments Instead, the comma is emitted when there is indeed an extra argument. This change was initially submitted in #3147 and is needed when the extra argument may vary for a given symbol. More specifically, when a method symbol may be shared by several instance symbols, it becomes really difficult to find a spot where that extra comma might be added. Removing it from the extra argument itself makes this easier once we reach the point where method symbols are unique (per object) instead of repeated (per instance). diff --git a/lib/libvcc/vcc_expr.c b/lib/libvcc/vcc_expr.c index bab9251b5..cacbbdfac 100644 --- a/lib/libvcc/vcc_expr.c +++ b/lib/libvcc/vcc_expr.c @@ -465,7 +465,7 @@ vcc_func(struct vcc *tl, struct expr **e, const void *priv, VTAILQ_HEAD(,func_arg) head; struct token *t1; const struct vjsn_val *vv, *vvp; - const char *sa; + const char *sa, *extra_sep; char ssa[64]; int n; @@ -483,8 +483,13 @@ vcc_func(struct vcc *tl, struct expr **e, const void *priv, } vv = VTAILQ_NEXT(vv, list); SkipToken(tl, '('); - if (extra == NULL) + if (extra == NULL) { extra = ""; + extra_sep = ""; + } else { + AN(*extra); + extra_sep = ", "; + } VTAILQ_INIT(&head); for (;vv != NULL; vv = VTAILQ_NEXT(vv, list)) { assert(vv->type == VJSN_ARRAY); @@ -570,10 +575,11 @@ vcc_func(struct vcc *tl, struct expr **e, const void *priv, } if (sa != NULL) - e1 = vcc_mk_expr(rfmt, "%s(ctx%s,\v+\n&(%s)\v+ {\n", - cfunc, extra, sa); + e1 = vcc_mk_expr(rfmt, "%s(ctx%s%s,\v+\n&(%s)\v+ {\n", + cfunc, extra_sep, extra, sa); else - e1 = vcc_mk_expr(rfmt, "%s(ctx%s\v+", cfunc, extra); + e1 = vcc_mk_expr(rfmt, "%s(ctx%s%s\v+", + cfunc, extra_sep, extra); n = 0; VTAILQ_FOREACH_SAFE(fa, &head, list, fa2) { n++; diff --git a/lib/libvcc/vcc_vmod.c b/lib/libvcc/vcc_vmod.c index a4d229a05..610547b4a 100644 --- a/lib/libvcc/vcc_vmod.c +++ b/lib/libvcc/vcc_vmod.c @@ -385,7 +385,6 @@ vcc_Act_New(struct vcc *tl, struct token *t, struct symbol *sym) struct inifin *ifp; struct vsb *buf; const struct vjsn_val *vv, *vf; - const char *p; int null_ok = 0; (void)sym; @@ -433,7 +432,7 @@ vcc_Act_New(struct vcc *tl, struct token *t, struct symbol *sym) buf = VSB_new_auto(); AN(buf); - VSB_printf(buf, ", &%s, \"%s\"", sy1->rname, sy1->name); + VSB_printf(buf, "&%s, \"%s\"", sy1->rname, sy1->name); AZ(VSB_finish(buf)); vcc_Eval_Func(tl, vf, VSB_data(buf), sy2); VSB_destroy(&buf); @@ -456,9 +455,7 @@ vcc_Act_New(struct vcc *tl, struct token *t, struct symbol *sym) /* Instantiate symbols for the methods */ buf = VSB_new_auto(); AN(buf); - VSB_printf(buf, ", %s", sy1->rname); - AZ(VSB_finish(buf)); - p = TlDup(tl, VSB_data(buf)); + while (vv != NULL) { vf = VTAILQ_FIRST(&vv->children); assert(vf->type == VJSN_STRING); @@ -472,7 +469,7 @@ vcc_Act_New(struct vcc *tl, struct token *t, struct symbol *sym) sy3 = VCC_MkSym(tl, VSB_data(buf), SYM_FUNC, VCL_LOW, VCL_HIGH); AN(sy3); func_sym(sy3, sy2->vmod_name, VTAILQ_NEXT(vf, list)); - sy3->extra = p; + sy3->extra = sy1->rname; vv = VTAILQ_NEXT(vv, list); } VSB_destroy(&buf); From dridi.boukelmoune at gmail.com Wed Dec 11 15:28:06 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 11 Dec 2019 15:28:06 +0000 (UTC) Subject: [master] 1a6a6e8e6 Whitespace OCD Message-ID: <20191211152806.32ED6AD18A@lists.varnish-cache.org> commit 1a6a6e8e6eda2f5747269b8630c3eb2f6c646e4d Author: Dridi Boukelmoune Date: Wed Dec 11 16:23:17 2019 +0100 Whitespace OCD They fit within 80 columns. diff --git a/lib/libvcc/vcc_vmod.c b/lib/libvcc/vcc_vmod.c index 610547b4a..e18f7e048 100644 --- a/lib/libvcc/vcc_vmod.c +++ b/lib/libvcc/vcc_vmod.c @@ -350,15 +350,13 @@ vcc_ParseImport(struct vcc *tl) VSB_cat(tl->symtab, "\t\"type\": \"$VMOD\",\n"); VSB_printf(tl->symtab, "\t\"name\": \"%.*s\",\n", PF(mod)); VSB_printf(tl->symtab, "\t\"file\": \"%s\",\n", fnpx); - VSB_printf(tl->symtab, - "\t\"dst\": \"./vmod_cache/_vmod_%.*s.%s\"\n", + VSB_printf(tl->symtab, "\t\"dst\": \"./vmod_cache/_vmod_%.*s.%s\"\n", PF(mod), vmd->file_id); VSB_cat(tl->symtab, " }"); /* XXX: zero the function pointer structure ?*/ VSB_printf(ifp->fin, "\t\tVRT_priv_fini(&vmod_priv_%.*s);", PF(mod)); - VSB_printf(ifp->final, - "\t\tVPI_Vmod_Unload(&VGC_vmod_%.*s);", PF(mod)); + VSB_printf(ifp->final, "\t\tVPI_Vmod_Unload(&VGC_vmod_%.*s);", PF(mod)); vj = vjsn_parse(vmd->json, &p); XXXAZ(p); From dridi.boukelmoune at gmail.com Wed Dec 11 19:11:09 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 11 Dec 2019 19:11:09 +0000 (UTC) Subject: [master] 6d1a30287 Rename obscure symbol variables Message-ID: <20191211191109.AA8842596@lists.varnish-cache.org> commit 6d1a30287ee22dff9ce09571dca9864fd353927a Author: Dridi Boukelmoune Date: Wed Dec 11 20:08:41 2019 +0100 Rename obscure symbol variables Every time I read this code I fail to remember which symbol is which, so from now on the instance symbol will be called isym, the object symbol osym and the method symbols msym. diff --git a/lib/libvcc/vcc_vmod.c b/lib/libvcc/vcc_vmod.c index e18f7e048..af386ffb2 100644 --- a/lib/libvcc/vcc_vmod.c +++ b/lib/libvcc/vcc_vmod.c @@ -379,7 +379,7 @@ vcc_ParseImport(struct vcc *tl) void v_matchproto_(sym_act_f) vcc_Act_New(struct vcc *tl, struct token *t, struct symbol *sym) { - struct symbol *sy1, *sy2, *sy3; + struct symbol *isym, *osym, *msym; struct inifin *ifp; struct vsb *buf; const struct vjsn_val *vv, *vf; @@ -391,19 +391,19 @@ vcc_Act_New(struct vcc *tl, struct token *t, struct symbol *sym) ExpectErr(tl, ID); vcc_ExpectVid(tl, "VCL object"); ERRCHK(tl); - sy1 = VCC_HandleSymbol(tl, INSTANCE, "vo"); + isym = VCC_HandleSymbol(tl, INSTANCE, "vo"); ERRCHK(tl); - AN(sy1); - sy1->noref = 1; + AN(isym); + isym->noref = 1; ExpectErr(tl, '='); vcc_NextToken(tl); ExpectErr(tl, ID); - sy2 = VCC_SymbolGet(tl, SYM_OBJECT, SYMTAB_EXISTING, XREF_NONE); + osym = VCC_SymbolGet(tl, SYM_OBJECT, SYMTAB_EXISTING, XREF_NONE); ERRCHK(tl); - AN(sy2); - CAST_OBJ_NOTNULL(vv, sy2->eval_priv, VJSN_VAL_MAGIC); + AN(osym); + CAST_OBJ_NOTNULL(vv, osym->eval_priv, VJSN_VAL_MAGIC); // vv = object name vv = VTAILQ_NEXT(vv, list); @@ -413,12 +413,12 @@ vcc_Act_New(struct vcc *tl, struct token *t, struct symbol *sym) if (!strcmp(vf->name, "NULL_OK") && vf->type == VJSN_TRUE) null_ok = 1; if (!null_ok) - VTAILQ_INSERT_TAIL(&tl->sym_objects, sy1, sideways); + VTAILQ_INSERT_TAIL(&tl->sym_objects, isym, sideways); vv = VTAILQ_NEXT(vv, list); // vv = struct name - Fh(tl, 0, "static %s *%s;\n\n", vv->value, sy1->rname); + Fh(tl, 0, "static %s *%s;\n\n", vv->value, isym->rname); vv = VTAILQ_NEXT(vv, list); vf = VTAILQ_FIRST(&vv->children); @@ -430,13 +430,13 @@ vcc_Act_New(struct vcc *tl, struct token *t, struct symbol *sym) buf = VSB_new_auto(); AN(buf); - VSB_printf(buf, "&%s, \"%s\"", sy1->rname, sy1->name); + VSB_printf(buf, "&%s, \"%s\"", isym->rname, isym->name); AZ(VSB_finish(buf)); - vcc_Eval_Func(tl, vf, VSB_data(buf), sy2); + vcc_Eval_Func(tl, vf, VSB_data(buf), osym); VSB_destroy(&buf); ERRCHK(tl); SkipToken(tl, ';'); - sy1->def_e = tl->t; + isym->def_e = tl->t; vf = VTAILQ_FIRST(&vv->children); vv = VTAILQ_NEXT(vv, list); @@ -447,8 +447,8 @@ vcc_Act_New(struct vcc *tl, struct token *t, struct symbol *sym) vf = VTAILQ_FIRST(&vf->children); vf = VTAILQ_NEXT(vf, list); ifp = New_IniFin(tl); - VSB_printf(ifp->fin, "\t\tif (%s)\n", sy1->rname); - VSB_printf(ifp->fin, "\t\t\t\t%s(&%s);", vf->value, sy1->rname); + VSB_printf(ifp->fin, "\t\tif (%s)\n", isym->rname); + VSB_printf(ifp->fin, "\t\t\t\t%s(&%s);", vf->value, isym->rname); /* Instantiate symbols for the methods */ buf = VSB_new_auto(); @@ -462,12 +462,12 @@ vcc_Act_New(struct vcc *tl, struct token *t, struct symbol *sym) assert(vf->type == VJSN_STRING); VSB_clear(buf); - VSB_printf(buf, "%s.%s", sy1->name, vf->value); + VSB_printf(buf, "%s.%s", isym->name, vf->value); AZ(VSB_finish(buf)); - sy3 = VCC_MkSym(tl, VSB_data(buf), SYM_FUNC, VCL_LOW, VCL_HIGH); - AN(sy3); - func_sym(sy3, sy2->vmod_name, VTAILQ_NEXT(vf, list)); - sy3->extra = sy1->rname; + msym = VCC_MkSym(tl, VSB_data(buf), SYM_FUNC, VCL_LOW, VCL_HIGH); + AN(msym); + func_sym(msym, osym->vmod_name, VTAILQ_NEXT(vf, list)); + msym->extra = isym->rname; vv = VTAILQ_NEXT(vv, list); } VSB_destroy(&buf); From dridi.boukelmoune at gmail.com Wed Dec 11 20:03:07 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 11 Dec 2019 20:03:07 +0000 (UTC) Subject: [6.0] f76f21163 Stabilize c35 Message-ID: <20191211200307.2376647C0@lists.varnish-cache.org> commit f76f211636fec60fd4081d0029e84788dc47c662 Author: Dridi Boukelmoune Date: Thu Nov 7 22:44:42 2019 +0100 Stabilize c35 Spotted via vtest. diff --git a/bin/varnishtest/tests/c00035.vtc b/bin/varnishtest/tests/c00035.vtc index 4bffe363f..f063096e7 100644 --- a/bin/varnishtest/tests/c00035.vtc +++ b/bin/varnishtest/tests/c00035.vtc @@ -1,6 +1,7 @@ varnishtest "Dropping polling of a backend" server s1 -repeat 40 { + non_fatal rxreq txresp } -start From dridi.boukelmoune at gmail.com Wed Dec 11 20:03:07 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 11 Dec 2019 20:03:07 +0000 (UTC) Subject: [6.0] cceb96b62 get an idea about the margin before r02219.vtc fails Message-ID: <20191211200307.4F2C647C2@lists.varnish-cache.org> commit cceb96b6224b6bfe9b091ed1d93ae8c48374e64c Author: Nils Goroll Date: Tue Nov 5 18:50:36 2019 +0100 get an idea about the margin before r02219.vtc fails When making other changes which require additional workspace, this test may fail for too big a request in the first place. This additional logging facilitates before/after analysis diff --git a/bin/varnishtest/tests/r02219.vtc b/bin/varnishtest/tests/r02219.vtc index ff1a924f7..8b4d1c188 100644 --- a/bin/varnishtest/tests/r02219.vtc +++ b/bin/varnishtest/tests/r02219.vtc @@ -10,7 +10,10 @@ server s1 { } -start varnish v1 -arg "-p workspace_client=9k" -proto PROXY -vcl+backend { + import std; + import vtc; sub vcl_recv { + std.log(vtc.workspace_free(client)); return (pass); } } -start From nils.goroll at uplex.de Thu Dec 12 11:45:06 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Thu, 12 Dec 2019 11:45:06 +0000 (UTC) Subject: [master] 5e124e994 improve acl test coverage Message-ID: <20191212114506.A305DA1B69@lists.varnish-cache.org> commit 5e124e99498a2be723eaea54efead55c497ad225 Author: Nils Goroll Date: Thu Dec 12 12:44:13 2019 +0100 improve acl test coverage diff --git a/bin/varnishtest/tests/c00005.vtc b/bin/varnishtest/tests/c00005.vtc index b9072f8fd..5f6852d0c 100644 --- a/bin/varnishtest/tests/c00005.vtc +++ b/bin/varnishtest/tests/c00005.vtc @@ -1,4 +1,4 @@ -varnishtest "Test simple ACL" +varnishtest "Test ACLs" server s1 { rxreq @@ -64,3 +64,87 @@ varnish v1 -vcl+backend { } client c1 -run + +varnish v1 -cliok "param.set vsl_mask -VCL_trace" + +varnish v1 -vcl { + import std; + + backend dummy None; + + acl acl1 { + # bad notation (confusing) + "1.2.3.4"/24; + "1.2.3.66"/26; + + # more specific wins + "1.4.4.0"/22; + "1.3.4.0"/23; + "1.3.5.0"/26; + "1.3.6.0"/25; + "1.3.6.128"/25; + "1.3.0.0"/21; + "1.4.7.0"/24; + "1.4.6.0"/24; + } + + sub vcl_recv { + return (synth(200)); + } + sub t { + if (std.ip(req.http.ip) ~ acl1) { } + } + sub vcl_synth { + # variables would be nice, but not in core (yet?) + set req.http.ip = "1.2.3.0"; call t; + set req.http.ip = "1.2.3.63"; call t; + set req.http.ip = "1.2.3.64"; call t; + + set req.http.ip = "1.3.4.255"; call t; + set req.http.ip = "1.3.5.0"; call t; + set req.http.ip = "1.3.5.255"; call t; + set req.http.ip = "1.3.6.0"; call t; + set req.http.ip = "1.3.6.140"; call t; + set req.http.ip = "1.3.7.255"; call t; + + set req.http.ip = "1.4.5.255"; call t; + set req.http.ip = "1.4.6.64"; call t; + set req.http.ip = "1.4.7.64"; call t; + } +} + +logexpect l1 -v v1 -g raw { + expect * 1007 ReqHeader {^\Qip: 1.2.3.0\E$} + expect 0 = VCL_acl {^\QMATCH acl1 "1.2.3.4"/24\E} + expect 1 = ReqHeader {^\Qip: 1.2.3.63\E$} + expect 0 = VCL_acl {^\QMATCH acl1 "1.2.3.4"/24\E} + expect 1 = ReqHeader {^\Qip: 1.2.3.64\E$} + expect 0 = VCL_acl {^\QMATCH acl1 "1.2.3.66"/26\E} + + expect 1 = ReqHeader {^\Qip: 1.3.4.255\E$} + expect 0 = VCL_acl {^\QMATCH acl1 "1.3.4.0"/23\E} + expect 1 = ReqHeader {^\Qip: 1.3.5.0\E$} + expect 0 = VCL_acl {^\QMATCH acl1 "1.3.5.0"/26\E} + expect 1 = ReqHeader {^\Qip: 1.3.5.255\E$} + expect 0 = VCL_acl {^\QMATCH acl1 "1.3.4.0"/23\E} + expect 1 = ReqHeader {^\Qip: 1.3.6.0\E$} + expect 0 = VCL_acl {^\QMATCH acl1 "1.3.6.0"/25\E} + expect 1 = ReqHeader {^\Qip: 1.3.6.140\E$} + expect 0 = VCL_acl {^\QMATCH acl1 "1.3.6.128"/25\E} + expect 1 = ReqHeader {^\Qip: 1.3.7.255\E$} + expect 0 = VCL_acl {^\QMATCH acl1 "1.3.0.0"/21\E} + + expect 1 = ReqHeader {^\Qip: 1.4.5.255\E$} + expect 0 = VCL_acl {^\QMATCH acl1 "1.4.4.0"/22\E} + expect 1 = ReqHeader {^\Qip: 1.4.6.64\E$} + expect 0 = VCL_acl {^\QMATCH acl1 "1.4.6.0"/24\E} + expect 1 = ReqHeader {^\Qip: 1.4.7.64\E$} + expect 0 = VCL_acl {^\QMATCH acl1 "1.4.7.0"/24\E} +} -start + +client c1 { + txreq + rxresp +} -run + +logexpect l1 -wait From nils.goroll at uplex.de Thu Dec 12 11:50:05 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Thu, 12 Dec 2019 11:50:05 +0000 (UTC) Subject: [master] fc4dc01e1 improve acl test coverage Message-ID: <20191212115005.CCEB9A1EA2@lists.varnish-cache.org> commit fc4dc01e1bd27e86277e9f43d06fd1c128b45aee Author: Nils Goroll Date: Thu Dec 12 12:46:38 2019 +0100 improve acl test coverage I should have included the netnotation right away diff --git a/bin/varnishtest/tests/c00005.vtc b/bin/varnishtest/tests/c00005.vtc index 5f6852d0c..78845f332 100644 --- a/bin/varnishtest/tests/c00005.vtc +++ b/bin/varnishtest/tests/c00005.vtc @@ -84,7 +84,7 @@ varnish v1 -vcl { "1.3.6.0"/25; "1.3.6.128"/25; "1.3.0.0"/21; - "1.4.7.0"/24; + "1.4.7"; "1.4.6.0"/24; } @@ -139,7 +139,7 @@ logexpect l1 -v v1 -g raw { expect 1 = ReqHeader {^\Qip: 1.4.6.64\E$} expect 0 = VCL_acl {^\QMATCH acl1 "1.4.6.0"/24\E} expect 1 = ReqHeader {^\Qip: 1.4.7.64\E$} - expect 0 = VCL_acl {^\QMATCH acl1 "1.4.7.0"/24\E} + expect 0 = VCL_acl {^\QMATCH acl1 "1.4.7"\E} } -start client c1 { From nils.goroll at uplex.de Thu Dec 12 14:11:06 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Thu, 12 Dec 2019 14:11:06 +0000 (UTC) Subject: [master] e2006b180 acl netmask is unsigned Message-ID: <20191212141106.75E85A5259@lists.varnish-cache.org> commit e2006b1800c74de0ffdee31568bd2ba11708d0c6 Author: Nils Goroll Date: Thu Dec 12 12:59:07 2019 +0100 acl netmask is unsigned diff --git a/lib/libvcc/vcc_acl.c b/lib/libvcc/vcc_acl.c index da3f282d1..26231c4b6 100644 --- a/lib/libvcc/vcc_acl.c +++ b/lib/libvcc/vcc_acl.c @@ -44,7 +44,7 @@ struct acl_e { VTAILQ_ENTRY(acl_e) list; unsigned char data[ACL_MAXADDR]; - int mask; + unsigned mask; unsigned not; unsigned para; char *addr; From nils.goroll at uplex.de Thu Dec 12 14:11:06 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Thu, 12 Dec 2019 14:11:06 +0000 (UTC) Subject: [master] 827f37596 localhost is not localhost on FreeBSD/12.1 vtest boxes Message-ID: <20191212141106.8D56FA525E@lists.varnish-cache.org> commit 827f375965ba50b9ee1d87b09c2f445a6e806d2e Author: Nils Goroll Date: Thu Dec 12 15:08:33 2019 +0100 localhost is not localhost on FreeBSD/12.1 vtest boxes This test was failing before silently: It seems these vtest machines do not resolve localhost to the address passed as the localhost define to vtest, so use the latter in order to stabilize. diff --git a/bin/varnishtest/tests/c00005.vtc b/bin/varnishtest/tests/c00005.vtc index 78845f332..c52b06a3c 100644 --- a/bin/varnishtest/tests/c00005.vtc +++ b/bin/varnishtest/tests/c00005.vtc @@ -48,7 +48,7 @@ client c1 { varnish v1 -vcl+backend { acl acl1 { - ! "localhost"; + ! "${localhost}"; "0.0.0.0" / 0; "::" / 0; } From dridi at varni.sh Thu Dec 12 15:04:03 2019 From: dridi at varni.sh (Dridi Boukelmoune) Date: Thu, 12 Dec 2019 15:04:03 +0000 Subject: [master] 827f37596 localhost is not localhost on FreeBSD/12.1 vtest boxes In-Reply-To: <20191212141106.8D56FA525E@lists.varnish-cache.org> References: <20191212141106.8D56FA525E@lists.varnish-cache.org> Message-ID: On Thu, Dec 12, 2019 at 2:11 PM Nils Goroll wrote: > > > commit 827f375965ba50b9ee1d87b09c2f445a6e806d2e > Author: Nils Goroll > Date: Thu Dec 12 15:08:33 2019 +0100 > > localhost is not localhost on FreeBSD/12.1 vtest boxes > > This test was failing before silently: It seems these vtest machines do > not resolve localhost to the address passed as the localhost define to > vtest, so use the latter in order to stabilize. FreeBSD jails FYI From dridi.boukelmoune at gmail.com Thu Dec 12 16:46:06 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 12 Dec 2019 16:46:06 +0000 (UTC) Subject: [6.0] bd8e7301d Make this test un-racy. Message-ID: <20191212164606.3DAE1A89F2@lists.varnish-cache.org> commit bd8e7301d48d31d10f57ac145b0a97e98b4dd429 Author: Poul-Henning Kamp Date: Tue Nov 6 09:23:07 2018 +0000 Make this test un-racy. diff --git a/bin/varnishtest/tests/r01821.vtc b/bin/varnishtest/tests/r01821.vtc index b07799325..a7943e1b0 100644 --- a/bin/varnishtest/tests/r01821.vtc +++ b/bin/varnishtest/tests/r01821.vtc @@ -2,9 +2,13 @@ varnishtest "Slim down hit-for-miss / hit-for-miss objects" # see also #2768 -server s1 -repeat 2 { +server s1 { rxreq - txresp -bodylen 65535 + expect req.url == "/hfm" + txresp -hdr "HFM: True" -bodylen 65530 + rxreq + expect req.url == "/hfp" + txresp -hdr "HFP: True" -bodylen 65550 } -start varnish v1 -arg "-s Transient=default" -vcl+backend { @@ -25,16 +29,15 @@ logexpect l1 -v v1 -g raw { client c1 { txreq -url "/hfm" rxresp -} -start - -client c2 { + expect resp.status == 200 + expect resp.http.hfm == True txreq -url "/hfp" rxresp + expect resp.status == 200 + expect resp.http.hfp == True } -run -client c1 -wait - logexpect l1 -wait varnish v1 -expect SM?.Transient.c_bytes > 131072 -varnish v1 -expect SM?.Transient.g_bytes < 65536 +varnish v1 -expect SM?.Transient.g_bytes < 2000 From dridi.boukelmoune at gmail.com Fri Dec 13 10:55:06 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 13 Dec 2019 10:55:06 +0000 (UTC) Subject: [master] bdf9a4488 Stabilize r2946 Message-ID: <20191213105506.79471937EE@lists.varnish-cache.org> commit bdf9a4488100a514c9666044c9e2ac9beb5dd0d4 Author: Dridi Boukelmoune Date: Thu Dec 12 22:36:31 2019 +0100 Stabilize r2946 Under stress we might otherwise check n_objectcore before it gets a chance to decrease completely. Spotted via vtest. diff --git a/bin/varnishtest/tests/r02946.vtc b/bin/varnishtest/tests/r02946.vtc index b0eb3e6bf..4801178ad 100644 --- a/bin/varnishtest/tests/r02946.vtc +++ b/bin/varnishtest/tests/r02946.vtc @@ -42,4 +42,6 @@ client c1 { expect resp.http.age > 1 } -run +delay 1 + varnish v1 -expect n_objectcore == 1 From nils.goroll at uplex.de Fri Dec 13 13:47:07 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Fri, 13 Dec 2019 13:47:07 +0000 (UTC) Subject: [master] f29a25b5b improve documentation about the deprecated persistent storage engine Message-ID: <20191213134707.1309B97621@lists.varnish-cache.org> commit f29a25b5b1a56053052071d77780f29009a9beb0 Author: Nils Goroll Date: Fri Dec 13 14:45:45 2019 +0100 improve documentation about the deprecated persistent storage engine Ref #2575 diff --git a/doc/sphinx/phk/persistent.rst b/doc/sphinx/phk/persistent.rst index 2e0c40f32..cdcb2d9c0 100644 --- a/doc/sphinx/phk/persistent.rst +++ b/doc/sphinx/phk/persistent.rst @@ -1,4 +1,4 @@ -.. _phk_pesistent: +.. _phk_persistent: ==================== A persistent message @@ -15,9 +15,16 @@ Under narrow and ill defined circumstances, -spersistent works well, but in general it is more trouble than it is worth for you to run it, and we don't presently have the development resources to fix that. -If you think you have these circumstances, you need to specify +If you think you have these circumstances, you need to - -sdeprecated_persistent +* call ``configure`` with ``--with-persistent-storage`` before + compilation + +* use the storage engine name ``deprecated_persistent``, use a:: + + -sdeprecated_persistent, + + argument when starting varnish in order to use it. diff --git a/doc/sphinx/users-guide/storage-backends.rst b/doc/sphinx/users-guide/storage-backends.rst index b99972120..1b4dbddbe 100644 --- a/doc/sphinx/users-guide/storage-backends.rst +++ b/doc/sphinx/users-guide/storage-backends.rst @@ -162,10 +162,12 @@ and MADV_SEQUENTIAL madvise() advice argument, respectively. Defaults to On Linux, large objects and rotational disk should benefit from "sequential". -persistent (experimental) -~~~~~~~~~~~~~~~~~~~~~~~~~ +deprecated_persistent +~~~~~~~~~~~~~~~~~~~~~ -syntax: persistent,path,size {experimental} +syntax: deprecated_persistent,path,size {experimental} + +*Before using, read `phk_persistent`_!* Persistent storage. Varnish will store objects in a file in a manner that will secure the survival of *most* of the objects in the event of @@ -193,9 +195,10 @@ starts after a shutdown it will discard the content of any silo that isn't sealed. Note that taking persistent silos offline and at the same time using -bans can cause problems. This is due to the fact that bans added while the silo was -offline will not be applied to the silo when it reenters the cache. Consequently enabling -previously banned objects to reappear. +bans can cause problems. This is due to the fact that bans added while +the silo was offline will not be applied to the silo when it reenters +the cache. Consequently enabling previously banned objects to +reappear. Transient Storage ----------------- From nils.goroll at uplex.de Fri Dec 13 13:51:06 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Fri, 13 Dec 2019 13:51:06 +0000 (UTC) Subject: [master] 0fb7d872e fix formatting glitch from previous Message-ID: <20191213135106.93E129792B@lists.varnish-cache.org> commit 0fb7d872e2cf97d34c8e0bebe56732558948bc4c Author: Nils Goroll Date: Fri Dec 13 14:50:39 2019 +0100 fix formatting glitch from previous diff --git a/doc/sphinx/users-guide/storage-backends.rst b/doc/sphinx/users-guide/storage-backends.rst index 1b4dbddbe..3e9734a30 100644 --- a/doc/sphinx/users-guide/storage-backends.rst +++ b/doc/sphinx/users-guide/storage-backends.rst @@ -167,7 +167,7 @@ deprecated_persistent syntax: deprecated_persistent,path,size {experimental} -*Before using, read `phk_persistent`_!* +*Before using, read* :ref:`phk_persistent`\ *!* Persistent storage. Varnish will store objects in a file in a manner that will secure the survival of *most* of the objects in the event of From nils.goroll at uplex.de Fri Dec 13 14:46:07 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Fri, 13 Dec 2019 14:46:07 +0000 (UTC) Subject: [master] 74bfdf842 document VCL_acl SLT format Message-ID: <20191213144607.1437C9BE04@lists.varnish-cache.org> commit 74bfdf84243471dd0ab40fb25da313d882cb2b9b Author: Nils Goroll Date: Fri Dec 13 15:42:22 2019 +0100 document VCL_acl SLT format diff --git a/include/tbl/vsl_tags.h b/include/tbl/vsl_tags.h index 0252d0743..ff1d979dc 100644 --- a/include/tbl/vsl_tags.h +++ b/include/tbl/vsl_tags.h @@ -282,6 +282,17 @@ SLTM(Fetch_Body, 0, "Body fetched from backend", SLTM(VCL_acl, 0, "VCL ACL check results", "Logs VCL ACL evaluation results.\n\n" + "The format is::\n\n" + "\t%s [%s [%s]]\n" + "\t| | |\n" + "\t| | +- Matching entry (only for MATCH)\n" + "\t| +----- Name of the ACL for MATCH or NO_MATCH\n" + "\t+--------- MATCH, NO_MATCH or NO_FAM\n" + "\n" + "MATCH denotes an ACL match\n" + "NO_MATCH denotes that a checked ACL has not matched\n" + "NO_FAM denotes a missing address family and should not occur.\n" + "\n" ) SLTM(VCL_call, 0, "VCL method called", From nils.goroll at uplex.de Sun Dec 15 08:05:09 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Sun, 15 Dec 2019 08:05:09 +0000 (UTC) Subject: [master] 93498b56a acl vtc: match full lines only Message-ID: <20191215080509.43B57B25A0@lists.varnish-cache.org> commit 93498b56a0bedebe955d4f994a12bdde8a5c0ec5 Author: Nils Goroll Date: Sun Dec 15 09:04:18 2019 +0100 acl vtc: match full lines only diff --git a/bin/varnishtest/tests/c00005.vtc b/bin/varnishtest/tests/c00005.vtc index c52b06a3c..92ef9f9f2 100644 --- a/bin/varnishtest/tests/c00005.vtc +++ b/bin/varnishtest/tests/c00005.vtc @@ -115,31 +115,31 @@ varnish v1 -vcl { logexpect l1 -v v1 -g raw { expect * 1007 ReqHeader {^\Qip: 1.2.3.0\E$} - expect 0 = VCL_acl {^\QMATCH acl1 "1.2.3.4"/24\E} + expect 0 = VCL_acl {^\QMATCH acl1 "1.2.3.4"/24\E$} expect 1 = ReqHeader {^\Qip: 1.2.3.63\E$} - expect 0 = VCL_acl {^\QMATCH acl1 "1.2.3.4"/24\E} + expect 0 = VCL_acl {^\QMATCH acl1 "1.2.3.4"/24\E$} expect 1 = ReqHeader {^\Qip: 1.2.3.64\E$} - expect 0 = VCL_acl {^\QMATCH acl1 "1.2.3.66"/26\E} + expect 0 = VCL_acl {^\QMATCH acl1 "1.2.3.66"/26\E$} expect 1 = ReqHeader {^\Qip: 1.3.4.255\E$} - expect 0 = VCL_acl {^\QMATCH acl1 "1.3.4.0"/23\E} + expect 0 = VCL_acl {^\QMATCH acl1 "1.3.4.0"/23\E$} expect 1 = ReqHeader {^\Qip: 1.3.5.0\E$} - expect 0 = VCL_acl {^\QMATCH acl1 "1.3.5.0"/26\E} + expect 0 = VCL_acl {^\QMATCH acl1 "1.3.5.0"/26\E$} expect 1 = ReqHeader {^\Qip: 1.3.5.255\E$} - expect 0 = VCL_acl {^\QMATCH acl1 "1.3.4.0"/23\E} + expect 0 = VCL_acl {^\QMATCH acl1 "1.3.4.0"/23\E$} expect 1 = ReqHeader {^\Qip: 1.3.6.0\E$} - expect 0 = VCL_acl {^\QMATCH acl1 "1.3.6.0"/25\E} + expect 0 = VCL_acl {^\QMATCH acl1 "1.3.6.0"/25\E$} expect 1 = ReqHeader {^\Qip: 1.3.6.140\E$} - expect 0 = VCL_acl {^\QMATCH acl1 "1.3.6.128"/25\E} + expect 0 = VCL_acl {^\QMATCH acl1 "1.3.6.128"/25\E$} expect 1 = ReqHeader {^\Qip: 1.3.7.255\E$} - expect 0 = VCL_acl {^\QMATCH acl1 "1.3.0.0"/21\E} + expect 0 = VCL_acl {^\QMATCH acl1 "1.3.0.0"/21\E$} expect 1 = ReqHeader {^\Qip: 1.4.5.255\E$} - expect 0 = VCL_acl {^\QMATCH acl1 "1.4.4.0"/22\E} + expect 0 = VCL_acl {^\QMATCH acl1 "1.4.4.0"/22\E$} expect 1 = ReqHeader {^\Qip: 1.4.6.64\E$} - expect 0 = VCL_acl {^\QMATCH acl1 "1.4.6.0"/24\E} + expect 0 = VCL_acl {^\QMATCH acl1 "1.4.6.0"/24\E$} expect 1 = ReqHeader {^\Qip: 1.4.7.64\E$} - expect 0 = VCL_acl {^\QMATCH acl1 "1.4.7"\E} + expect 0 = VCL_acl {^\QMATCH acl1 "1.4.7"\E$} } -start client c1 { From dridi.boukelmoune at gmail.com Mon Dec 16 07:58:07 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 16 Dec 2019 07:58:07 +0000 (UTC) Subject: [master] 2b04d2930 Assert Message-ID: <20191216075807.DB4B9B246A@lists.varnish-cache.org> commit 2b04d29304f1dd54e599a253b608120fd33f2cfa Author: Dridi Boukelmoune Date: Fri Dec 13 19:00:35 2019 +0100 Assert diff --git a/lib/libvcc/vcc_symb.c b/lib/libvcc/vcc_symb.c index 4bb0a72a7..97d418921 100644 --- a/lib/libvcc/vcc_symb.c +++ b/lib/libvcc/vcc_symb.c @@ -358,6 +358,7 @@ VCC_MkSym(struct vcc *tl, const char *b, vcc_kind_t kind, int vlo, int vhi) sym = vcc_sym_in_tab(tl, st, kind, vlo, vhi); AZ(sym); sym = vcc_new_symbol(tl, st, kind, vlo, vhi); + AN(sym); sym->noref = 1; return (sym); } From dridi.boukelmoune at gmail.com Mon Dec 16 07:58:07 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 16 Dec 2019 07:58:07 +0000 (UTC) Subject: [master] 67da10c7b Coccinelle patch for SkipToken in libvcc Message-ID: <20191216075807.F068DB246D@lists.varnish-cache.org> commit 67da10c7b5e66c07dec07e30e678e6da1b1ac6d2 Author: Dridi Boukelmoune Date: Fri Dec 13 19:07:17 2019 +0100 Coccinelle patch for SkipToken in libvcc diff --git a/lib/libvcc/vcc_action.c b/lib/libvcc/vcc_action.c index 7a539fa58..95d3a9216 100644 --- a/lib/libvcc/vcc_action.c +++ b/lib/libvcc/vcc_action.c @@ -225,8 +225,7 @@ static void vcc_act_return_pass(struct vcc *tl) { - ExpectErr(tl, '('); - vcc_NextToken(tl); + SkipToken(tl, '('); Fb(tl, 1, "VRT_hit_for_pass(ctx,\n"); tl->indent += INDENT; vcc_Expr(tl, DURATION); @@ -240,8 +239,7 @@ vcc_act_return_pass(struct vcc *tl) static void vcc_act_return_fail(struct vcc *tl) { - ExpectErr(tl, '('); - vcc_NextToken(tl); + SkipToken(tl, '('); Fb(tl, 1, "VRT_fail(ctx,\n"); tl->indent += INDENT; vcc_Expr(tl, STRING); @@ -257,8 +255,7 @@ static void vcc_act_return_synth(struct vcc *tl) { - ExpectErr(tl, '('); - vcc_NextToken(tl); + SkipToken(tl, '('); Fb(tl, 1, "VRT_synth(ctx,\n"); tl->indent += INDENT; vcc_Expr(tl, INT); @@ -285,8 +282,7 @@ vcc_act_return_vcl(struct vcc *tl) struct inifin *p; char buf[1024]; - ExpectErr(tl, '('); - vcc_NextToken(tl); + SkipToken(tl, '('); ExpectErr(tl, ID); sym = VCC_SymbolGet(tl, SYM_VCL, SYMTAB_EXISTING, XREF_NONE); ERRCHK(tl); diff --git a/lib/libvcc/vcc_vmod.c b/lib/libvcc/vcc_vmod.c index af386ffb2..96b119913 100644 --- a/lib/libvcc/vcc_vmod.c +++ b/lib/libvcc/vcc_vmod.c @@ -396,9 +396,7 @@ vcc_Act_New(struct vcc *tl, struct token *t, struct symbol *sym) AN(isym); isym->noref = 1; - ExpectErr(tl, '='); - vcc_NextToken(tl); - + SkipToken(tl, '='); ExpectErr(tl, ID); osym = VCC_SymbolGet(tl, SYM_OBJECT, SYMTAB_EXISTING, XREF_NONE); ERRCHK(tl); diff --git a/tools/coccinelle/vcc_skip_token.cocci b/tools/coccinelle/vcc_skip_token.cocci new file mode 100644 index 000000000..a921accf6 --- /dev/null +++ b/tools/coccinelle/vcc_skip_token.cocci @@ -0,0 +1,11 @@ +/* + * This patch simplifies token parsing. + */ + +@@ +expression tl, tok; +@@ + +- ExpectErr(tl, tok); +- vcc_NextToken(tl); ++ SkipToken(tl, tok); From dridi.boukelmoune at gmail.com Mon Dec 16 11:17:06 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 16 Dec 2019 11:17:06 +0000 (UTC) Subject: [master] 7da6220df Assert Message-ID: <20191216111706.3FD9B56C8@lists.varnish-cache.org> commit 7da6220dfd86416200c43d84d40fce0cae1b5bae Author: Dridi Boukelmoune Date: Mon Dec 16 12:16:17 2019 +0100 Assert diff --git a/bin/varnishd/cache/cache_ws.c b/bin/varnishd/cache/cache_ws.c index a40bdbc1b..a8208d3a0 100644 --- a/bin/varnishd/cache/cache_ws.c +++ b/bin/varnishd/cache/cache_ws.c @@ -234,6 +234,7 @@ WS_ReserveAll(struct ws *ws) { unsigned b; + WS_Assert(ws); assert(ws->r == NULL); ws->r = ws->e; From nils.goroll at uplex.de Mon Dec 16 11:18:24 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 16 Dec 2019 12:18:24 +0100 Subject: [master] 7da6220df Assert In-Reply-To: <20191216111706.3FD9B56C8@lists.varnish-cache.org> References: <20191216111706.3FD9B56C8@lists.varnish-cache.org> Message-ID: <8267ce22-9e28-dc6b-078e-8bb0dc94baae@uplex.de> there already was one 4 lines below, that does checking twice gain? On 16/12/2019 12:17, Dridi Boukelmoune wrote: > > commit 7da6220dfd86416200c43d84d40fce0cae1b5bae > Author: Dridi Boukelmoune > Date: Mon Dec 16 12:16:17 2019 +0100 > > Assert > > diff --git a/bin/varnishd/cache/cache_ws.c b/bin/varnishd/cache/cache_ws.c > index a40bdbc1b..a8208d3a0 100644 > --- a/bin/varnishd/cache/cache_ws.c > +++ b/bin/varnishd/cache/cache_ws.c > @@ -234,6 +234,7 @@ WS_ReserveAll(struct ws *ws) > { > unsigned b; > > + WS_Assert(ws); > assert(ws->r == NULL); > > ws->r = ws->e; > _______________________________________________ > varnish-commit mailing list > varnish-commit at varnish-cache.org > https://www.varnish-cache.org/lists/mailman/listinfo/varnish-commit > -- ** * * UPLEX - Nils Goroll Systemoptimierung Scheffelstra?e 32 22301 Hamburg tel +49 40 28805731 mob +49 170 2723133 fax +49 40 42949753 xmpp://slink at jabber.int.uplex.de/ http://uplex.de/ -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 488 bytes Desc: OpenPGP digital signature URL: From nils.goroll at uplex.de Mon Dec 16 11:19:06 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 16 Dec 2019 11:19:06 +0000 (UTC) Subject: [master] 808be2b0c bring back "feature dns" after the canary has fallen over Message-ID: <20191216111906.1C8A95B45@lists.varnish-cache.org> commit 808be2b0c1c30f347605cdfd81f25b160b38043f Author: Nils Goroll Date: Mon Dec 16 12:13:57 2019 +0100 bring back "feature dns" after the canary has fallen over $ nslookup dns-canary.freebsd.dk Non-authoritative answer: *** Can't find dns-canary.freebsd.dk: No answer if anyone has a more reliable server to test, please just change it again. diff --git a/bin/varnishtest/vtc_misc.c b/bin/varnishtest/vtc_misc.c index d49388352..1bd6b88a8 100644 --- a/bin/varnishtest/vtc_misc.c +++ b/bin/varnishtest/vtc_misc.c @@ -352,13 +352,13 @@ dns_works(void) char abuf[VTCP_ADDRBUFSIZE]; char pbuf[VTCP_PORTBUFSIZE]; - sa = VSS_ResolveOne(NULL, "dns-canary.freebsd.dk", NULL, - AF_UNSPEC, SOCK_STREAM, 0); + sa = VSS_ResolveOne(NULL, "varnish.org", NULL, + AF_INET, SOCK_STREAM, 0); if (sa == NULL) return (0); VTCP_name(sa, abuf, sizeof abuf, pbuf, sizeof pbuf); free(sa); - if (strcmp(abuf, "192.0.2.255")) + if (strcmp(abuf, "176.58.90.154")) return (0); sa = VSS_ResolveOne(NULL, "varnish.org", NULL, From nils.goroll at uplex.de Mon Dec 16 11:19:06 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 16 Dec 2019 11:19:06 +0000 (UTC) Subject: [master] 71e39a968 more vcc coverage Message-ID: <20191216111906.360295B48@lists.varnish-cache.org> commit 71e39a968008bc185dffc14606cd032fa2e2547a Author: Nils Goroll Date: Mon Dec 16 12:15:39 2019 +0100 more vcc coverage diff --git a/bin/varnishtest/tests/v00016.vtc b/bin/varnishtest/tests/v00016.vtc index f1cab3db6..15e6fb511 100644 --- a/bin/varnishtest/tests/v00016.vtc +++ b/bin/varnishtest/tests/v00016.vtc @@ -117,6 +117,13 @@ varnish v1 -syntax 4.0 -errvcl {Undefined acl foo} { } } +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. From dridi at varni.sh Mon Dec 16 11:23:24 2019 From: dridi at varni.sh (Dridi Boukelmoune) Date: Mon, 16 Dec 2019 11:23:24 +0000 Subject: [master] 7da6220df Assert In-Reply-To: <8267ce22-9e28-dc6b-078e-8bb0dc94baae@uplex.de> References: <20191216111706.3FD9B56C8@lists.varnish-cache.org> <8267ce22-9e28-dc6b-078e-8bb0dc94baae@uplex.de> Message-ID: On Mon, Dec 16, 2019 at 11:18 AM Nils Goroll wrote: > > there already was one 4 lines below, that does checking twice gain? We dereference ws before we even check we have a correct one, so either we opt for at least a null check or a miniobj check, or we go for the complete workspace check. I chose the latter because the deprecated WS_Reserve does that and its replacement doesn't. Dridi From nils.goroll at uplex.de Mon Dec 16 11:38:06 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 16 Dec 2019 11:38:06 +0000 (UTC) Subject: [master] de316c119 gc duplicate check Message-ID: <20191216113806.72B6965D8@lists.varnish-cache.org> commit de316c1192458984c1f9119835e3e1e548971866 Author: Nils Goroll Date: Mon Dec 16 12:30:34 2019 +0100 gc duplicate check we already check for unused subs in vcc_checkref() Fixes #3159 diff --git a/lib/libvcc/vcc_xref.c b/lib/libvcc/vcc_xref.c index 271f787fd..415e9ce95 100644 --- a/lib/libvcc/vcc_xref.c +++ b/lib/libvcc/vcc_xref.c @@ -195,7 +195,7 @@ vcc_CheckActionRecurse(struct vcc *tl, struct proc *p, unsigned bitmap) /*--------------------------------------------------------------------*/ static void -vcc_checkaction1(struct vcc *tl, const struct symbol *sym) +vcc_checkaction(struct vcc *tl, const struct symbol *sym) { struct proc *p; @@ -219,30 +219,11 @@ vcc_checkaction1(struct vcc *tl, const struct symbol *sym) } -static void -vcc_checkaction2(struct vcc *tl, const struct symbol *sym) -{ - struct proc *p; - - p = sym->proc; - AN(p); - - if (p->called) - return; - VSB_cat(tl->sb, "Function unused\n"); - vcc_ErrWhere(tl, p->name); - if (!tl->err_unref) - vcc_Warn(tl); -} - int vcc_CheckAction(struct vcc *tl) { - VCC_WalkSymbols(tl, vcc_checkaction1, SYM_SUB); - if (tl->err) - return (tl->err); - VCC_WalkSymbols(tl, vcc_checkaction2, SYM_SUB); + VCC_WalkSymbols(tl, vcc_checkaction, SYM_SUB); return (tl->err); } From nils.goroll at uplex.de Mon Dec 16 11:38:06 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 16 Dec 2019 11:38:06 +0000 (UTC) Subject: [master] 9fc54436a mark a seemingly redundant test Message-ID: <20191216113806.89A9A65DB@lists.varnish-cache.org> commit 9fc54436a3f27c913233c1841f0b20958be22ef4 Author: Nils Goroll Date: Mon Dec 16 12:36:37 2019 +0100 mark a seemingly redundant test diff --git a/bin/varnishtest/tests/v00021.vtc b/bin/varnishtest/tests/v00021.vtc index 80ef0a93e..fe34b6f14 100644 --- a/bin/varnishtest/tests/v00021.vtc +++ b/bin/varnishtest/tests/v00021.vtc @@ -54,6 +54,7 @@ varnish v1 -errvcl {Unused sub foo, defined:} { } } +# deliberately testing for name "none" varnish v1 -errvcl {Unused sub none, defined:} { backend b { .host = "127.0.0.1"; } From dridi.boukelmoune at gmail.com Mon Dec 16 11:46:06 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 16 Dec 2019 11:46:06 +0000 (UTC) Subject: [master] 11bd2a9ee Add test case for #3159 Message-ID: <20191216114606.C9FAF6B6B@lists.varnish-cache.org> commit 11bd2a9ee6a5461d80f492b46b2a3e5637ed6041 Author: Dridi Boukelmoune Date: Mon Dec 16 12:44:51 2019 +0100 Add test case for #3159 diff --git a/bin/varnishtest/tests/r03159.vtc b/bin/varnishtest/tests/r03159.vtc new file mode 100644 index 000000000..e601e4a04 --- /dev/null +++ b/bin/varnishtest/tests/r03159.vtc @@ -0,0 +1,16 @@ +varnishtest "double sub unref warning" + +shell { + cat >unref.vcl <<-EOF + vcl 4.1; + backend be none; + sub foo { } + EOF +} + +varnish v1 -cliok "param.set vcc_err_unref off" + +shell -match "^1$" { + varnishadm -n "${v1_name}" vcl.load unref "${tmpdir}/unref.vcl" 2>&1 | + grep -c "That was just a warning" +} From nils.goroll at uplex.de Mon Dec 16 11:56:07 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 16 Dec 2019 11:56:07 +0000 (UTC) Subject: [master] ae742a4e1 turn long OBE special case into assertion Message-ID: <20191216115607.3F572707E@lists.varnish-cache.org> commit ae742a4e16cc45585f13410389c5ce4ac4eec9ec Author: Nils Goroll Date: Mon Dec 16 12:48:40 2019 +0100 turn long OBE special case into assertion diff --git a/lib/libvcc/vcc_xref.c b/lib/libvcc/vcc_xref.c index 415e9ce95..342fdb967 100644 --- a/lib/libvcc/vcc_xref.c +++ b/lib/libvcc/vcc_xref.c @@ -106,8 +106,7 @@ vcc_AddUses(struct vcc *tl, const struct token *t1, const struct token *t2, { struct procuse *pu; - if (tl->curproc == NULL) /* backend */ - return; + AN(tl->curproc); pu = TlAlloc(tl, sizeof *pu); assert(pu != NULL); pu->t1 = t1; From nils.goroll at uplex.de Mon Dec 16 11:56:07 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 16 Dec 2019 11:56:07 +0000 (UTC) Subject: [master] 04bce23c5 vcc_CheckUseRecurse() coverage Message-ID: <20191216115607.5A65F7083@lists.varnish-cache.org> commit 04bce23c529238a314db5be97290ea02db72e77f Author: Nils Goroll Date: Mon Dec 16 12:54:31 2019 +0100 vcc_CheckUseRecurse() coverage diff --git a/bin/varnishtest/tests/v00020.vtc b/bin/varnishtest/tests/v00020.vtc index 238927c34..06efb9021 100644 --- a/bin/varnishtest/tests/v00020.vtc +++ b/bin/varnishtest/tests/v00020.vtc @@ -246,6 +246,16 @@ varnish v1 -errvcl {Not available in method 'vcl_recv'.} { } } +varnish v1 -errvcl {Not available from method 'vcl_recv'.} { + backend b { .host = "127.0.0.1"; } + sub foo { + set req.http.foo = 100 + beresp.status; + } + sub vcl_recv { + call foo; + } +} + varnish v1 -errvcl {Name of ACL, 'foo.bar', contains illegal character '.'} { acl foo.bar { } From dridi.boukelmoune at gmail.com Mon Dec 16 12:09:06 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 16 Dec 2019 12:09:06 +0000 (UTC) Subject: [master] 658060e43 Attempt at stabilizing r2339 Message-ID: <20191216120906.BBA19783F@lists.varnish-cache.org> commit 658060e431ec4ef92c3de48c168bb613a794d814 Author: Dridi Boukelmoune Date: Mon Dec 16 13:06:07 2019 +0100 Attempt at stabilizing r2339 Spotted via vtest: l1 timed out despite varnishd logging what was expected next. This is tightening l1's expectation in the hope that r2339 will no longer flake. I wasn't able to reproduce this even on my vtest box where it failed. diff --git a/bin/varnishtest/tests/r02339.vtc b/bin/varnishtest/tests/r02339.vtc index a3cc99f92..178e24a39 100644 --- a/bin/varnishtest/tests/r02339.vtc +++ b/bin/varnishtest/tests/r02339.vtc @@ -63,39 +63,39 @@ logexpect l2 -v v1 -g raw { logexpect l1 -v v1 { expect * 1003 VCL_call HIT - expect * = VCL_call DELIVER + expect 0 = VCL_return deliver expect * 1004 VCL_call MISS - expect * = VCL_call DELIVER + expect 0 = VCL_return fetch expect * 1007 VCL_call RECV - expect * = VCL_Error purge - expect * = VCL_return fail + expect 0 = VCL_Error purge + expect 0 = VCL_return fail expect * 1009 VCL_call HASH - expect * = VCL_Error purge - expect * = VCL_return fail + expect 0 = VCL_Error purge + expect 0 = VCL_return fail expect * 1011 VCL_call PURGE - expect * = VCL_Error purge + expect 0 = VCL_Error purge expect * 1013 VCL_call PASS - expect * = VCL_Error purge + expect 0 = VCL_Error purge expect * 1015 VCL_call DELIVER - expect * = VCL_Error purge + expect 0 = VCL_Error purge expect * 1018 VCL_call SYNTH - expect * = VCL_Error purge + expect 0 = VCL_Error purge expect * 1021 VCL_call BACKEND_FETCH - expect * = VCL_Error purge + expect 0 = VCL_Error purge expect * 1024 VCL_call BACKEND_ERROR - expect * = VCL_Error purge + expect 0 = VCL_Error purge expect * 1027 VCL_call BACKEND_RESPONSE - expect * = VCL_Error purge + expect 0 = VCL_Error purge } -start client c1 { From nils.goroll at uplex.de Mon Dec 16 13:05:56 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 16 Dec 2019 14:05:56 +0100 Subject: [master] 7da6220df Assert In-Reply-To: References: <20191216111706.3FD9B56C8@lists.varnish-cache.org> <8267ce22-9e28-dc6b-078e-8bb0dc94baae@uplex.de> Message-ID: <9949e4de-0a1e-9529-08af-2e5e4f9fb3a9@uplex.de> my thinking was that two WS_Asserts were overkill and I think a CHECK_OBJ_NOTNULL would actually make more sense. On 16/12/2019 12:23, Dridi Boukelmoune wrote: > On Mon, Dec 16, 2019 at 11:18 AM Nils Goroll wrote: >> >> there already was one 4 lines below, that does checking twice gain? > > We dereference ws before we even check we have a correct one, so > either we opt for at least a null check or a miniobj check, or we go > for the complete workspace check. > > I chose the latter because the deprecated WS_Reserve does that and its > replacement doesn't. > > Dridi > -- ** * * UPLEX - Nils Goroll Systemoptimierung Scheffelstra?e 32 22301 Hamburg tel +49 40 28805731 mob +49 170 2723133 fax +49 40 42949753 xmpp://slink at jabber.int.uplex.de/ http://uplex.de/ -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 488 bytes Desc: OpenPGP digital signature URL: From nils.goroll at uplex.de Mon Dec 16 13:11:07 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 16 Dec 2019 13:11:07 +0000 (UTC) Subject: [master] 035a5becc output warnings also for varnishd -f argument Message-ID: <20191216131107.5E7D9603C0@lists.varnish-cache.org> commit 035a5beccb19fd280b6868c44382cb243a4b317b Author: Nils Goroll Date: Mon Dec 16 14:06:15 2019 +0100 output warnings also for varnishd -f argument Fixes #3160 diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index b4407db14..d05a02722 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -175,6 +175,9 @@ static void cli_check(const struct cli *cli) { if (cli->result == CLIS_OK) { + AZ(VSB_finish(cli->sb)); + if (VSB_len(cli->sb) > 0) + fprintf(stderr, "Warnings:\n%s\n", VSB_data(cli->sb)); VSB_clear(cli->sb); return; } diff --git a/bin/varnishtest/tests/r03159.vtc b/bin/varnishtest/tests/r03159.vtc index e601e4a04..2a78b99c8 100644 --- a/bin/varnishtest/tests/r03159.vtc +++ b/bin/varnishtest/tests/r03159.vtc @@ -1,4 +1,6 @@ -varnishtest "double sub unref warning" +varnishtest "double sub unref warning / warnings output for -f" + +# Also tests #3160 shell { cat >unref.vcl <<-EOF @@ -8,6 +10,16 @@ shell { EOF } +shell -match "^1$" { + { + varnishd -F -n "${tmpdir}/t" -a "${tmpdir}/sock" \ + -p vcc_err_unref=off -f "${tmpdir}/unref.vcl" & + pid=$! + varnishadm -n "${tmpdir}/t" stop + kill $pid + } 2>&1 | grep -c "That was just a warning" +} + varnish v1 -cliok "param.set vcc_err_unref off" shell -match "^1$" { From dridi at varni.sh Mon Dec 16 13:26:35 2019 From: dridi at varni.sh (Dridi Boukelmoune) Date: Mon, 16 Dec 2019 13:26:35 +0000 Subject: [master] 7da6220df Assert In-Reply-To: <9949e4de-0a1e-9529-08af-2e5e4f9fb3a9@uplex.de> References: <20191216111706.3FD9B56C8@lists.varnish-cache.org> <8267ce22-9e28-dc6b-078e-8bb0dc94baae@uplex.de> <9949e4de-0a1e-9529-08af-2e5e4f9fb3a9@uplex.de> Message-ID: On Mon, Dec 16, 2019 at 1:05 PM Nils Goroll wrote: > > my thinking was that two WS_Asserts were overkill and I think a > CHECK_OBJ_NOTNULL would actually make more sense. I think checking we should check have a valid workspace before we start fiddling with it, and then check that we left a valid workspace once we're done. This is what most functions do, and I happen to see that WS_ReserveAll missed that step, I don't see a point arguing further :-/ It's not like the sanity check has a huge cost. Dridi From slink at schokola.de Mon Dec 16 13:59:09 2019 From: slink at schokola.de (Nils Goroll) Date: Mon, 16 Dec 2019 14:59:09 +0100 Subject: [master] 7da6220df Assert In-Reply-To: References: <20191216111706.3FD9B56C8@lists.varnish-cache.org> <8267ce22-9e28-dc6b-078e-8bb0dc94baae@uplex.de> <9949e4de-0a1e-9529-08af-2e5e4f9fb3a9@uplex.de> Message-ID: On 16/12/2019 14:26, Dridi Boukelmoune wrote: > I don't see a point arguing further :-/ I won't From nils.goroll at uplex.de Mon Dec 16 14:09:07 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 16 Dec 2019 14:09:07 +0000 (UTC) Subject: [master] 0bff7aab7 set the cli_limit when the parameter is actually available Message-ID: <20191216140907.2685361D69@lists.varnish-cache.org> commit 0bff7aab71d0e2710cecacde1f0f10a99bfe7e80 Author: Nils Goroll Date: Mon Dec 16 14:49:54 2019 +0100 set the cli_limit when the parameter is actually available it is not before we have parsed parameters diff --git a/bin/varnishd/mgt/mgt_cli.c b/bin/varnishd/mgt/mgt_cli.c index f40f35b3f..04a27af95 100644 --- a/bin/varnishd/mgt/mgt_cli.c +++ b/bin/varnishd/mgt/mgt_cli.c @@ -352,7 +352,6 @@ mgt_cli_init_cls(void) mgt_cls = VCLS_New(NULL); AN(mgt_cls); - VCLS_SetLimit(mgt_cls, &mgt_param.cli_limit); VCLS_SetHooks(mgt_cls, mgt_cli_cb_before, mgt_cli_cb_after); VCLS_AddFunc(mgt_cls, MCF_NOAUTH, cli_auth); VCLS_AddFunc(mgt_cls, MCF_AUTH, cli_proto); diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index d05a02722..1f920a100 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -704,6 +704,8 @@ main(int argc, char * const *argv) VSB_data(cli[0].sb)); } + VCLS_SetLimit(mgt_cls, &mgt_param.cli_limit); + assert(d_flag == 0 || F_flag == 0); if (C_flag) { From nils.goroll at uplex.de Mon Dec 16 14:09:07 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 16 Dec 2019 14:09:07 +0000 (UTC) Subject: [master] 3c87f32a3 for compiling VCLs, truncation is not an error Message-ID: <20191216140907.3D9CB61D6D@lists.varnish-cache.org> commit 3c87f32a341ce14a28f34067c29ef428466f2a48 Author: Nils Goroll Date: Mon Dec 16 14:57:09 2019 +0100 for compiling VCLs, truncation is not an error diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index 1f920a100..77e2039a5 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -174,7 +174,7 @@ usage(void) static void cli_check(const struct cli *cli) { - if (cli->result == CLIS_OK) { + if (cli->result == CLIS_OK || cli->result == CLIS_TRUNCATED) { AZ(VSB_finish(cli->sb)); if (VSB_len(cli->sb) > 0) fprintf(stderr, "Warnings:\n%s\n", VSB_data(cli->sb)); @@ -804,7 +804,9 @@ main(int argc, char * const *argv) fprintf(stderr, "%s\n", VSB_data(cli->sb)); VSB_clear(cli->sb); } - exit(cli->result == CLIS_OK ? 0 : 2); + if (cli->result == CLIS_OK || cli->result == CLIS_TRUNCATED) + exit(0); + exit(2); } else { while (!VTAILQ_EMPTY(&f_args)) { fa = VTAILQ_FIRST(&f_args); diff --git a/bin/varnishd/mgt/mgt_vcl.c b/bin/varnishd/mgt/mgt_vcl.c index 81751b8ca..cc372d2b8 100644 --- a/bin/varnishd/mgt/mgt_vcl.c +++ b/bin/varnishd/mgt/mgt_vcl.c @@ -458,7 +458,7 @@ mgt_new_vcl(struct cli *cli, const char *vclname, const char *vclsrc, if (active_vcl == NULL) active_vcl = vp; - if (cli->result == CLIS_OK && + if ((cli->result == CLIS_OK || cli->result == CLIS_TRUNCATED) && vcl_count > mgt_param.max_vcl && mgt_param.max_vcl_handling == 1) { VCLI_Out(cli, "%d VCLs loaded\n", vcl_count); From phk at phk.freebsd.dk Mon Dec 16 21:59:40 2019 From: phk at phk.freebsd.dk (Poul-Henning Kamp) Date: Mon, 16 Dec 2019 21:59:40 +0000 Subject: [master] 808be2b0c bring back "feature dns" after the canary has fallen over In-Reply-To: <20191216111906.1C8A95B45@lists.varnish-cache.org> References: <20191216111906.1C8A95B45@lists.varnish-cache.org> Message-ID: <68958.1576533580@critter.freebsd.dk> -------- In message <20191216111906.1C8A95B45 at lists.varnish-cache.org>, Nils Goroll writ es: > bring back "feature dns" after the canary has fallen over > > $ nslookup dns-canary.freebsd.dk We need to bring this canary into the varnish.org domain. It is important that it return a recognizable IP# so that you don't get false positives from lying resolvers in hotels and shitty ISPs. -- 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 nils.goroll at uplex.de Tue Dec 17 06:46:17 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Tue, 17 Dec 2019 07:46:17 +0100 Subject: [master] 808be2b0c bring back "feature dns" after the canary has fallen over In-Reply-To: <68958.1576533580@critter.freebsd.dk> References: <20191216111906.1C8A95B45@lists.varnish-cache.org> <68958.1576533580@critter.freebsd.dk> Message-ID: <3c64f379-4213-8c84-397b-da9068df3be6@uplex.de> On 16/12/2019 22:59, Poul-Henning Kamp wrote: > It is important that it return a recognizable IP# so that > you don't get false positives from lying resolvers in hotels > and shitty ISPs. I used varnish.org for now, checking for 176.58.90.154. In which regard would other entries be better? Nils -- ** * * UPLEX - Nils Goroll Systemoptimierung Scheffelstra?e 32 22301 Hamburg tel +49 40 28805731 mob +49 170 2723133 fax +49 40 42949753 xmpp://slink at jabber.int.uplex.de/ http://uplex.de/ -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 488 bytes Desc: OpenPGP digital signature URL: From phk at phk.freebsd.dk Tue Dec 17 07:10:13 2019 From: phk at phk.freebsd.dk (Poul-Henning Kamp) Date: Tue, 17 Dec 2019 07:10:13 +0000 Subject: [master] 808be2b0c bring back "feature dns" after the canary has fallen over In-Reply-To: <3c64f379-4213-8c84-397b-da9068df3be6@uplex.de> References: <20191216111906.1C8A95B45@lists.varnish-cache.org> <68958.1576533580@critter.freebsd.dk> <3c64f379-4213-8c84-397b-da9068df3be6@uplex.de> Message-ID: <76839.1576566613@critter.freebsd.dk> -------- In message <3c64f379-4213-8c84-397b-da9068df3be6 at uplex.de>, Nils Goroll writes: >On 16/12/2019 22:59, Poul-Henning Kamp wrote: >> It is important that it return a recognizable IP# so that >> you don't get false positives from lying resolvers in hotels >> and shitty ISPs. > >I used varnish.org for now, checking for 176.58.90.154. In which regard would >other entries be better? It should be a dedicated DNS entry that only serves this purpose, so that we don't break VTEST by moving our webserver. -- 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 nils.goroll at uplex.de Tue Dec 17 07:15:56 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Tue, 17 Dec 2019 08:15:56 +0100 Subject: [master] 808be2b0c bring back "feature dns" after the canary has fallen over In-Reply-To: <76839.1576566613@critter.freebsd.dk> References: <20191216111906.1C8A95B45@lists.varnish-cache.org> <68958.1576533580@critter.freebsd.dk> <3c64f379-4213-8c84-397b-da9068df3be6@uplex.de> <76839.1576566613@critter.freebsd.dk> Message-ID: On 17/12/2019 08:10, Poul-Henning Kamp wrote: > It should be a dedicated DNS entry that only serves this purpose, > so that we don't break VTEST by moving our webserver. All right, I thought you were referring to some other DNS property that I was not aware of. Yes, if someone with access to the DNS could add one please? Nils -- ** * * UPLEX - Nils Goroll Systemoptimierung Scheffelstra?e 32 22301 Hamburg tel +49 40 28805731 mob +49 170 2723133 fax +49 40 42949753 xmpp://slink at jabber.int.uplex.de/ http://uplex.de/ -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 488 bytes Desc: OpenPGP digital signature URL: From nils.goroll at uplex.de Tue Dec 17 12:47:06 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Tue, 17 Dec 2019 12:47:06 +0000 (UTC) Subject: [master] 239a8a0d8 learn something new every day Message-ID: <20191217124706.DD577BE04C@lists.varnish-cache.org> commit 239a8a0d88e3369518bb740a04a82b4ea8122e60 Author: Nils Goroll Date: Tue Dec 17 13:01:58 2019 +0100 learn something new every day ...even after ~11 years of experience with varnish. today: return without an action from a custom subroutine. diff --git a/doc/sphinx/users-guide/vcl-syntax.rst b/doc/sphinx/users-guide/vcl-syntax.rst index 4ab5d7f74..ea97402cc 100644 --- a/doc/sphinx/users-guide/vcl-syntax.rst +++ b/doc/sphinx/users-guide/vcl-syntax.rst @@ -79,10 +79,23 @@ down for, uhm, examples. Logical *or* -Subroutines -~~~~~~~~~~~ +Built in subroutines +~~~~~~~~~~~~~~~~~~~~ -A subroutine is used to group code for legibility or reusability:: +Varnish has quite a few built in subroutines that are called for each +transaction as it flows through Varnish. These builtin subroutines are all +named ``vcl_*`` and are explained in :ref:`vcl-built-in-subs`. + +Processing in built in subroutines ends with ``return ()`` +(see :ref:`user-guide-vcl_actions`). + + +Custom subroutines +~~~~~~~~~~~~~~~~~~ + +You can write your own subroutines, whose names cannot start with ``vcl_``. + +A subroutine is typically used to group code for legibility or reusability:: sub pipe_if_local { if (client.ip ~ local) { @@ -90,15 +103,18 @@ A subroutine is used to group code for legibility or reusability:: } } - -Subroutines in VCL do not take arguments, nor do they return values. - -To call a subroutine, use the call keyword followed by the subroutine's name:: +To call a subroutine, use the ``call`` keyword followed by the +subroutine's name:: call pipe_if_local; -Varnish has quite a few built in subroutines that are called for each -transaction as it flows through Varnish. These builtin subroutines are all -named `vcl_*`. Your own subroutines cannot start their name with `vcl\_`. +Custom subroutines in VCL do not take arguments, nor do they return +values. + +``return ()`` (see :ref:`user-guide-vcl_actions`) as shown in +the example above returns all the way from the top level built in +subroutine (see :ref:`vcl-built-in-subs`) which, possibly through +multiple steps, lead to the call of the custom subroutine. -.. XXX:looks as bit funky as red text? benc +``return`` without an action resumes execution after the ``call`` +statement of the calling subroutine. From nils.goroll at uplex.de Tue Dec 17 12:47:06 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Tue, 17 Dec 2019 12:47:06 +0000 (UTC) Subject: [master] e0fe0e50a Improve return() documentation Message-ID: <20191217124706.F1914BE04F@lists.varnish-cache.org> commit e0fe0e50a43221b5ba6ce1c56c57f1e9d66b5357 Author: Nils Goroll Date: Tue Dec 17 13:42:28 2019 +0100 Improve return() documentation We had two places where we documented common actions, and one of them was outdated. diff --git a/doc/sphinx/users-guide/vcl-actions.rst b/doc/sphinx/users-guide/vcl-actions.rst index d26f5c6df..918c2b513 100644 --- a/doc/sphinx/users-guide/vcl-actions.rst +++ b/doc/sphinx/users-guide/vcl-actions.rst @@ -1,40 +1,84 @@ .. _user-guide-vcl_actions: -actions -~~~~~~~ +Actions +======= -The most common actions to return are these: +Actions are used with the ``return()`` keyword, which returns +control from subroutines back to varnish. The action determines how +processing in varnish continues as shown in :ref:`reference-states`. -.. XXX:Maybe a bit more explanation here what is an action and how it is returned? benc +Common actions are documented here, while additional actions specific +to only one or some subroutines are documented in +:ref:`vcl-built-in-subs` as well as which action can be used from +which built in subroutine. -*pass* - When you return pass the request and subsequent response will be passed to - and from the backend server. It won't be cached. `pass` can be returned from - `vcl_recv`. +common actions for the client and backend side +---------------------------------------------- -*hash* - When you return hash from `vcl_recv` you tell Varnish to deliver content - from cache even if the request otherwise indicates that the request - should be passed. +.. _fail: -*pipe* +``fail`` +~~~~~~~~ -.. XXX:What is pipe? benc + Transition to :ref:`vcl_synth` on the client side as for + ``return(synth(503, "VCL Failed"))``, but with any request state + changes undone as if ``std.rollback()`` was called and forcing a + connection close. - Pipe can be returned from `vcl_recv` as well. Pipe short circuits the - client and the backend connections and Varnish will just sit there - and shuffle bytes back and forth. Varnish will not look at the data being - send back and forth - so your logs will be incomplete. + Intended for fatal errors, for which only minimal error handling is + possible. -*deliver* - Deliver the object to the client. Usually returned from `vcl_backend_response`. +common actions for the client side +---------------------------------- -*restart* - Restart processing of the request. You can restart the processing of - the whole transaction. Changes to the `req` object are retained, except - for `req.backend_hint`, which gets reset to the default backend. +.. _synth: -*retry* - Retry the request against the backend. This can be returned from - `vcl_backend_response` or `vcl_backend_error` if you don't like the response - that the backend delivered. +``synth(status code, reason)`` +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + Transition to :ref:`vcl_synth` with ``resp.status`` and + ``resp.reason`` being preset to the arguments of ``synth()``. + +.. _pass: + +``pass`` +~~~~~~~~ + + Switch to pass mode, making the current request not use the cache + and not putting its response into it. Control will eventually pass to + :ref:`vcl_pass`. + +.. _pipe: + +``pipe`` +~~~~~~~~ + + Switch to pipe mode. Control will eventually pass to + :ref:`vcl_pipe`. + +.. _restart: + +``restart`` +~~~~~~~~~~~ + + Restart the transaction. Increases the ``req.restarts`` counter. + + If the number of restarts is higher than the *max_restarts* + parameter, control is passed to :ref:`vcl_synth` as for + ``return(synth(503, "Too many restarts"))`` + + For a restart, all modifications to ``req`` attributes are + preserved except for ``req.restarts`` and ``req.xid``, which need + to change by design. + +common actions for the backend side +----------------------------------- + +.. _abandon: + +``abandon`` +~~~~~~~~~~~ + + Abandon the backend request. Unless the backend request was a + background fetch, control is passed to :ref:`vcl_synth` on the + client side with ``resp.status`` preset to 503. diff --git a/doc/sphinx/users-guide/vcl-built-in-subs.rst b/doc/sphinx/users-guide/vcl-built-in-subs.rst index 421186e4e..7ecab44d1 100644 --- a/doc/sphinx/users-guide/vcl-built-in-subs.rst +++ b/doc/sphinx/users-guide/vcl-built-in-subs.rst @@ -9,64 +9,21 @@ and backend requests as well as upon ``vcl.load`` and ``vcl.discard``. See :ref:`reference-states` for a detailed graphical overview of the states and how they relate to core code functions and VCL subroutines. -Subroutines always terminate with a ``return()`` on a keyword, which -determines how processing continues in the request processing state -machine. +Built-in subroutines always terminate with a ``return()``, +where ```` determines how processing continues in the request +processing state machine. -The behaviour for ``return()`` keywords is identical or at least -similar across subroutines, so differences are only documented where -relevant. +The behaviour of actions is identical or at least similar across +subroutines, so differences are only documented where relevant. -common return keywords for the client and backend side ------------------------------------------------------- +Common actions are documented in +:ref:`user-guide-vcl_actions`. Actions specific to only one or some +subroutines are documented herein. -.. _fail: - - ``fail`` - Transition to :ref:`vcl_synth` on the client side as for - ``return(synth(503, "VCL Failed"))``, but with any request state - changes undone as if ``std.rollback()`` was called and forcing a - connection close. - - Intended for fatal errors, for which only minimal error handling is - possible. client side ----------- -common return keywords for the client side -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -.. _synth: - - ``synth(status code, reason)`` - Transition to :ref:`vcl_synth` with ``resp.status`` and - ``resp.reason`` being preset to the arguments of ``synth()``. - -.. _pass: - - ``pass`` - Switch to pass mode. Control will eventually pass to - :ref:`vcl_pass`. - -.. _pipe: - - ``pipe`` - Switch to pipe mode. Control will eventually pass to - :ref:`vcl_pipe`. - -.. _restart: - - ``restart`` - Restart the transaction. Increases the ``req.restarts`` counter. - - If the number of restarts is higher than the *max_restarts* - parameter, control is passed to :ref:`vcl_synth` as for - ``return(synth(503, "Too many restarts"))`` - - For a restart, all modifications to ``req`` attributes are - preserved except for ``req.restarts`` and ``req.xid``, which need - to change by design. - .. _vcl_recv: vcl_recv @@ -84,19 +41,19 @@ The `vcl_recv` subroutine may terminate with calling ``return()`` on one of the following keywords: ``fail`` - see `fail`_ + see :ref:`fail` ``synth(status code, reason)`` - see `synth`_ + see :ref:`synth` ``restart`` - see `restart`_ + see :ref:`restart` ``pass`` - see `pass`_ + see :ref:`pass` ``pipe`` - see `pipe`_ + see :ref:`pipe` ``hash`` Continue processing the object as a potential candidate for @@ -134,10 +91,10 @@ The `vcl_pipe` subroutine may terminate with calling ``return()`` with one of the following keywords: ``fail`` - see `fail`_ + see :ref:`fail` ``synth(status code, reason)`` - see `synth`_ + see :ref:`synth` ``pipe`` Proceed with pipe mode. @@ -156,13 +113,13 @@ The `vcl_pass` subroutine may terminate with calling ``return()`` with one of the following keywords: ``fail`` - see `fail`_ + see :ref:`fail` ``synth(status code, reason)`` - see `synth`_ + see :ref:`synth` ``restart`` - see `restart`_ + see :ref:`restart` ``fetch`` Proceed with pass mode - initiate a backend request. @@ -179,7 +136,7 @@ The `vcl_hash` subroutine may terminate with calling ``return()`` with one of the following keywords: ``fail`` - see `fail`_ + see :ref:`fail` ``lookup`` Look up the object in cache. @@ -210,13 +167,13 @@ The `vcl_purge` subroutine may terminate with calling ``return()`` with one of the following keywords: ``fail`` - see `fail`_ + see :ref:`fail` ``synth(status code, reason)`` - see `synth`_ + see :ref:`synth` ``restart`` - see `restart`_ + see :ref:`restart` .. _vcl_miss: @@ -234,16 +191,16 @@ The `vcl_miss` subroutine may terminate with calling ``return()`` with one of the following keywords: ``fail`` - see `fail`_ + see :ref:`fail` ``synth(status code, reason)`` - see `synth`_ + see :ref:`synth` ``restart`` - see `restart`_ + see :ref:`restart` ``pass`` - see `pass`_ + see :ref:`pass` ``fetch`` Retrieve the requested object from the backend. Control will @@ -262,16 +219,16 @@ The `vcl_hit` subroutine may terminate with calling ``return()`` with one of the following keywords: ``fail`` - see `fail`_ + see :ref:`fail` ``synth(status code, reason)`` - see `synth`_ + see :ref:`synth` ``restart`` - see `restart`_ + see :ref:`restart` ``pass`` - see `pass`_ + see :ref:`pass` ``deliver`` Deliver the object. If it is stale, a background fetch to refresh @@ -288,13 +245,13 @@ The `vcl_deliver` subroutine may terminate with calling ``return()`` with one of the following keywords: ``fail`` - see `fail`_ + see :ref:`fail` ``synth(status code, reason)`` - see `synth`_ + see :ref:`synth` ``restart`` - see `restart`_ + see :ref:`restart` ``deliver`` Deliver the object to the client. @@ -315,10 +272,10 @@ The subroutine may terminate with calling ``return()`` with one of the following keywords: ``fail`` - see `fail`_ + see :ref:`fail` ``restart`` - see `restart`_ + see :ref:`restart` ``deliver`` Directly deliver the object defined by `vcl_synth` to the client @@ -327,17 +284,6 @@ following keywords: Backend Side ------------ - -common return keywords for the backend side -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -.. _abandon: - - ``abandon`` - Abandon the backend request. Unless the backend request was a - background fetch, control is passed to :ref:`vcl_synth` on the - client side with ``resp.status`` preset to 503. - .. _vcl_backend_fetch: vcl_backend_fetch @@ -350,10 +296,10 @@ The `vcl_backend_fetch` subroutine may terminate with calling ``return()`` with one of the following keywords: ``fail`` - see `fail`_ + see :ref:`fail` ``abandon`` - see `abandon`_ + see :ref:`abandon` ``fetch`` Fetch the object from the backend. @@ -403,10 +349,10 @@ The `vcl_backend_response` subroutine may terminate with calling ``return()`` with one of the following keywords: ``fail`` - see `fail`_ + see :ref:`fail` ``abandon`` - see `abandon`_ + see :ref:`abandon` ``deliver`` For a 304 response, create an updated cache object. @@ -507,7 +453,7 @@ vcl_backend_error This subroutine is called if we fail the backend fetch or if *max_retries* has been exceeded. -Returning with `abandon`_ does not leave a cache object. +Returning with :ref:`abandon` does not leave a cache object. If returning with ``deliver`` and a ``beresp.ttl > 0s``, a synthetic cache object is generated in VCL, whose body may be constructed using @@ -527,10 +473,10 @@ The `vcl_backend_error` subroutine may terminate with calling ``return()`` with one of the following keywords: ``fail`` - see `fail`_ + see :ref:`fail` ``abandon`` - see `abandon`_ + see :ref:`abandon` ``deliver`` Deliver and possibly cache the object defined in From dridi.boukelmoune at gmail.com Tue Dec 17 13:08:06 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 17 Dec 2019 13:08:06 +0000 (UTC) Subject: [master] 6a394677d Slightly improve return; coverage Message-ID: <20191217130806.1BF6EBEA6B@lists.varnish-cache.org> commit 6a394677d8d509d778a4632dd156317c0523f874 Author: Dridi Boukelmoune Date: Tue Dec 17 14:06:37 2019 +0100 Slightly improve return; coverage diff --git a/bin/varnishtest/tests/v00034.vtc b/bin/varnishtest/tests/v00034.vtc index 4367444a3..44846a3ec 100644 --- a/bin/varnishtest/tests/v00034.vtc +++ b/bin/varnishtest/tests/v00034.vtc @@ -46,4 +46,5 @@ client c1 { txreq rxresp expect resp.http.foo == "foo" + expect resp.http.bar == } -run From dridi.boukelmoune at gmail.com Wed Dec 18 08:35:07 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 18 Dec 2019 08:35:07 +0000 (UTC) Subject: [master] db0baa744 Improve the VCL recursive sub calls error message Message-ID: <20191218083507.A2942A5689@lists.varnish-cache.org> commit db0baa744db9b71f5f14fba4b2e3b0c2e9d5a807 Author: Dridi Boukelmoune Date: Wed Dec 18 08:49:45 2019 +0100 Improve the VCL recursive sub calls error message Before: ...called from "foo" ('' Line 5 Pos 27) sub bar { call foo; } --------------------------#-- After: ...called from "bar" ('' Line 5 Pos 24) sub bar { call foo; } -----------------------###--- This fixes the "called from" part of the message to refer to the caller instead of the callee, and underlines the symbol token instead of the semi-colon. diff --git a/bin/varnishtest/tests/v00020.vtc b/bin/varnishtest/tests/v00020.vtc index 06efb9021..b59fb5350 100644 --- a/bin/varnishtest/tests/v00020.vtc +++ b/bin/varnishtest/tests/v00020.vtc @@ -246,14 +246,57 @@ varnish v1 -errvcl {Not available in method 'vcl_recv'.} { } } -varnish v1 -errvcl {Not available from method 'vcl_recv'.} { +varnish v1 -errvcl { +('' Line 4 Pos 44) -- (Pos 49) + sub foo { set req.http.foo = 100 + beresp.status; } +-------------------------------------------######---------- + +Not available from method 'vcl_recv'. + +...in subroutine "foo" +('' Line 4 Pos 13) + sub foo { set req.http.foo = 100 + beresp.status; } +------------###-------------------------------------------- + + +...called from "vcl_recv" +('' Line 5 Pos 29) + sub vcl_recv { call foo; } +----------------------------###--- +} { backend b { .host = "127.0.0.1"; } - sub foo { - set req.http.foo = 100 + beresp.status; - } - sub vcl_recv { - call foo; - } + sub foo { set req.http.foo = 100 + beresp.status; } + sub vcl_recv { call foo; } +} + +varnish v1 -errvcl { +('' Line 4 Pos 44) -- (Pos 49) + sub foo { set req.http.foo = 100 + beresp.status; } +-------------------------------------------######---------- + +Not available from method 'vcl_recv'. + +...in subroutine "foo" +('' Line 4 Pos 13) + sub foo { set req.http.foo = 100 + beresp.status; } +------------###-------------------------------------------- + + +...called from "bar" +('' Line 5 Pos 24) + sub bar { call foo; } +-----------------------###--- + + +...called from "vcl_recv" +('' Line 6 Pos 29) + sub vcl_recv { call bar; } +----------------------------###--- +} { + backend b { .host = "127.0.0.1"; } + sub foo { set req.http.foo = 100 + beresp.status; } + sub bar { call foo; } + sub vcl_recv { call bar; } } varnish v1 -errvcl {Name of ACL, 'foo.bar', contains illegal character '.'} { diff --git a/bin/varnishtest/tests/v00021.vtc b/bin/varnishtest/tests/v00021.vtc index fe34b6f14..0ae6dc5a3 100644 --- a/bin/varnishtest/tests/v00021.vtc +++ b/bin/varnishtest/tests/v00021.vtc @@ -25,14 +25,54 @@ varnish v1 -errvcl "Symbol not found" { sub vcl_recv { call foo; } } -varnish v1 -errvcl "Function recurses on" { +varnish v1 -errvcl { +Function recurses on +('' Line 5 Pos 13) + sub foo { call foo; } +------------###-------------- + + +...called from "foo" +('' Line 5 Pos 24) + sub foo { call foo; } +-----------------------###--- + + +...called from "vcl_recv" +('' Line 6 Pos 29) + sub vcl_recv { call foo; } +----------------------------###--- +} { backend b { .host = "127.0.0.1"; } sub foo { call foo; } sub vcl_recv { call foo; } } -varnish v1 -errvcl "Function recurses on" { +varnish v1 -errvcl { +Function recurses on +('' Line 6 Pos 13) + sub foo { call bar; } +------------###-------------- + + +...called from "bar" +('' Line 5 Pos 24) + sub bar { call foo; } +-----------------------###--- + + +...called from "foo" +('' Line 6 Pos 24) + sub foo { call bar; } +-----------------------###--- + + +...called from "vcl_recv" +('' Line 7 Pos 29) + sub vcl_recv { call foo; } +----------------------------###--- +} { backend b { .host = "127.0.0.1"; } sub bar { call foo; } diff --git a/lib/libvcc/vcc_action.c b/lib/libvcc/vcc_action.c index 95d3a9216..a1b57b407 100644 --- a/lib/libvcc/vcc_action.c +++ b/lib/libvcc/vcc_action.c @@ -42,12 +42,14 @@ static void v_matchproto_(sym_act_f) vcc_act_call(struct vcc *tl, struct token *t, struct symbol *sym) { + struct token *t0; (void)t; ExpectErr(tl, ID); + t0 = tl->t; sym = VCC_SymbolGet(tl, SYM_SUB, SYMTAB_CREATE, XREF_REF); if (sym != NULL) { - vcc_AddCall(tl, sym); + vcc_AddCall(tl, t0, sym); VCC_GlobalSymbol(sym, SUB, "VGC_function"); Fb(tl, 1, "%s(ctx);\n", sym->rname); SkipToken(tl, ';'); diff --git a/lib/libvcc/vcc_compile.h b/lib/libvcc/vcc_compile.h index 9e1875c8b..c356e0788 100644 --- a/lib/libvcc/vcc_compile.h +++ b/lib/libvcc/vcc_compile.h @@ -400,7 +400,7 @@ sym_act_f vcc_Act_New; int vcc_CheckReferences(struct vcc *tl); void VCC_XrefTable(struct vcc *); -void vcc_AddCall(struct vcc *, struct symbol *); +void vcc_AddCall(struct vcc *, struct token *, struct symbol *); void vcc_ProcAction(struct proc *p, unsigned action, struct token *t); int vcc_CheckAction(struct vcc *tl); void vcc_AddUses(struct vcc *, const struct token *, const struct token *, diff --git a/lib/libvcc/vcc_xref.c b/lib/libvcc/vcc_xref.c index 342fdb967..e680c1ba1 100644 --- a/lib/libvcc/vcc_xref.c +++ b/lib/libvcc/vcc_xref.c @@ -108,7 +108,7 @@ vcc_AddUses(struct vcc *tl, const struct token *t1, const struct token *t2, AN(tl->curproc); pu = TlAlloc(tl, sizeof *pu); - assert(pu != NULL); + AN(pu); pu->t1 = t1; pu->t2 = t2; if (pu->t2 == NULL) @@ -120,15 +120,15 @@ vcc_AddUses(struct vcc *tl, const struct token *t1, const struct token *t2, } void -vcc_AddCall(struct vcc *tl, struct symbol *sym) +vcc_AddCall(struct vcc *tl, struct token *t, struct symbol *sym) { struct proccall *pc; AN(sym); pc = TlAlloc(tl, sizeof *pc); - assert(pc != NULL); + AN(pc); pc->sym = sym; - pc->t = tl->t; + pc->t = t; pc->fm = tl->curproc; VTAILQ_INSERT_TAIL(&tl->curproc->calls, pc, list); } @@ -180,8 +180,8 @@ vcc_CheckActionRecurse(struct vcc *tl, struct proc *p, unsigned bitmap) return (1); } if (vcc_CheckActionRecurse(tl, pc->sym->proc, bitmap)) { - VSB_printf(tl->sb, "\n...called from \"%s\"\n", - pc->sym->name); + VSB_printf(tl->sb, "\n...called from \"%.*s\"\n", + PF(p->name)); vcc_ErrWhere(tl, pc->t); return (1); } @@ -259,7 +259,7 @@ vcc_CheckUseRecurse(struct vcc *tl, const struct proc *p, VTAILQ_FOREACH(pc, &p->calls, list) { if (vcc_CheckUseRecurse(tl, pc->sym->proc, m)) { VSB_printf(tl->sb, "\n...called from \"%.*s\"\n", - PF(pc->fm->name)); + PF(p->name)); vcc_ErrWhere(tl, pc->t); return (1); } From dridi.boukelmoune at gmail.com Wed Dec 18 20:51:07 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 18 Dec 2019 20:51:07 +0000 (UTC) Subject: [6.0] 0b6294808 Added the syntax 'backend name none;' Message-ID: <20191218205107.1248E7E99@lists.varnish-cache.org> commit 0b62948083015c2213b4344ff7c253b138019865 Author: Andrew Wiik Date: Tue Sep 24 19:30:09 2019 -0400 Added the syntax 'backend name none;' diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 0f32f38c3..03076960b 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -820,7 +820,6 @@ cnt_recv_prep(struct req *req, const char *ci) /* By default we use the first backend */ req->director_hint = VCL_DefaultDirector(req->vcl); - AN(req->director_hint); req->d_ttl = -1; req->d_grace = -1; diff --git a/bin/varnishtest/tests/v00060.vtc b/bin/varnishtest/tests/v00060.vtc new file mode 100644 index 000000000..3ce39e569 --- /dev/null +++ b/bin/varnishtest/tests/v00060.vtc @@ -0,0 +1,45 @@ +varnishtest "NULL backend allowed" + +server s1 { + rxreq + txresp + +} -start + +varnish v1 -vcl { + backend default none; +} -start + +client c1 { + txreq + rxresp + expect resp.status == 503 +} -run + +# Test NULL none default backend + +varnish v1 -vcl+backend { + backend null_backend none; + backend null_backend_uppercase None; + sub vcl_recv { + if (req.url ~ "/no_backend_lowercase") { + set req.backend_hint = null_backend; + } else if (req.url ~ "no_backend_uppercase") { + set req.backend_hint = null_backend_uppercase; + } + } +} + +client c1 { + txreq + rxresp + expect resp.status == 200 + + txreq -url "/no_backend_lowercase" + rxresp + expect resp.status == 503 + + txreq -url "/no_backend_uppercase" + rxresp + expect resp.status == 503 +} -run diff --git a/lib/libvcc/vcc_backend.c b/lib/libvcc/vcc_backend.c index 3f21cdbf6..4c8c0718c 100644 --- a/lib/libvcc/vcc_backend.c +++ b/lib/libvcc/vcc_backend.c @@ -321,6 +321,16 @@ vcc_ParseHostDef(struct vcc *tl, const struct token *t_be, const char *vgcname) "?proxy_header", NULL); + if (tl->t->tok == ID && (vcc_IdIs(tl->t, "none") || vcc_IdIs(tl->t, "None"))) { + vsb = VSB_new_auto(); + AN(vsb); + tl->fb = vsb; + Fb(tl, 0, "\n\t%s = (NULL);\n", vgcname); + vcc_NextToken(tl); + SkipToken(tl, ';'); + return; + } + SkipToken(tl, '{'); vsb = VSB_new_auto(); From dridi.boukelmoune at gmail.com Wed Dec 18 20:51:07 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 18 Dec 2019 20:51:07 +0000 (UTC) Subject: [6.0] c0be6d84d whitespace ocd Message-ID: <20191218205107.2C5937E9D@lists.varnish-cache.org> commit c0be6d84d3c133e84e6bedf650c4bbd35b533e88 Author: Nils Goroll Date: Mon Sep 30 15:21:48 2019 +0200 whitespace ocd Ref #3067 diff --git a/bin/varnishtest/tests/v00060.vtc b/bin/varnishtest/tests/v00060.vtc index 3ce39e569..b1540dd5a 100644 --- a/bin/varnishtest/tests/v00060.vtc +++ b/bin/varnishtest/tests/v00060.vtc @@ -20,18 +20,18 @@ client c1 { varnish v1 -vcl+backend { backend null_backend none; - backend null_backend_uppercase None; - sub vcl_recv { - if (req.url ~ "/no_backend_lowercase") { - set req.backend_hint = null_backend; - } else if (req.url ~ "no_backend_uppercase") { - set req.backend_hint = null_backend_uppercase; - } - } + backend null_backend_uppercase None; + sub vcl_recv { + if (req.url ~ "/no_backend_lowercase") { + set req.backend_hint = null_backend; + } else if (req.url ~ "no_backend_uppercase") { + set req.backend_hint = null_backend_uppercase; + } + } } client c1 { - txreq + txreq rxresp expect resp.status == 200 @@ -39,7 +39,7 @@ client c1 { rxresp expect resp.status == 503 - txreq -url "/no_backend_uppercase" + txreq -url "/no_backend_uppercase" rxresp expect resp.status == 503 } -run From dridi.boukelmoune at gmail.com Wed Dec 18 20:51:07 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 18 Dec 2019 20:51:07 +0000 (UTC) Subject: [6.0] a63415b47 avoid 3 duplicated lines (very minor) Message-ID: <20191218205107.4CC0B7EA1@lists.varnish-cache.org> commit a63415b47b48d0257f606ef28d259372276c0d03 Author: Nils Goroll Date: Mon Sep 30 15:22:17 2019 +0200 avoid 3 duplicated lines (very minor) Ref #3067 diff --git a/lib/libvcc/vcc_backend.c b/lib/libvcc/vcc_backend.c index 4c8c0718c..6bdaeb65e 100644 --- a/lib/libvcc/vcc_backend.c +++ b/lib/libvcc/vcc_backend.c @@ -321,10 +321,12 @@ vcc_ParseHostDef(struct vcc *tl, const struct token *t_be, const char *vgcname) "?proxy_header", NULL); - if (tl->t->tok == ID && (vcc_IdIs(tl->t, "none") || vcc_IdIs(tl->t, "None"))) { - vsb = VSB_new_auto(); - AN(vsb); - tl->fb = vsb; + vsb = VSB_new_auto(); + AN(vsb); + tl->fb = vsb; + + if (tl->t->tok == ID && + (vcc_IdIs(tl->t, "none") || vcc_IdIs(tl->t, "None"))) { Fb(tl, 0, "\n\t%s = (NULL);\n", vgcname); vcc_NextToken(tl); SkipToken(tl, ';'); @@ -333,10 +335,6 @@ vcc_ParseHostDef(struct vcc *tl, const struct token *t_be, const char *vgcname) SkipToken(tl, '{'); - vsb = VSB_new_auto(); - AN(vsb); - tl->fb = vsb; - Fb(tl, 0, "\nstatic const struct vrt_backend vgc_dir_priv_%s = {\n", vgcname); From dridi.boukelmoune at gmail.com Wed Dec 18 20:51:07 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 18 Dec 2019 20:51:07 +0000 (UTC) Subject: [6.0] 296b3ebc4 Add Backend None Documentation Message-ID: <20191218205107.732DC7EA6@lists.varnish-cache.org> commit 296b3ebc41ffa094e1a4d9e5fc9d64a422d4ec11 Author: Andrew Wiik Date: Mon Oct 7 20:28:19 2019 -0400 Add Backend None Documentation diff --git a/doc/sphinx/reference/vcl.rst b/doc/sphinx/reference/vcl.rst index 4057ee50a..7b3768853 100644 --- a/doc/sphinx/reference/vcl.rst +++ b/doc/sphinx/reference/vcl.rst @@ -286,6 +286,12 @@ parameters. The following attributes are available: Varnish reaches the maximum Varnish it will start failing connections. +Empty backends can also be defined using the following syntax.:: + + backend name none; + +An empty backend will always return status code 503 as if it is sick. + Backends can be used with *directors*. Please see the :ref:`vmod_directors(3)` man page for more information. diff --git a/doc/sphinx/users-guide/vcl-backends.rst b/doc/sphinx/users-guide/vcl-backends.rst index 58448916f..f4c8d37eb 100644 --- a/doc/sphinx/users-guide/vcl-backends.rst +++ b/doc/sphinx/users-guide/vcl-backends.rst @@ -31,6 +31,9 @@ Varnish can have several backends defined you can even join several backends together into clusters of backends for load balancing purposes. +backends can also be empty or 'none' with the following syntax.:: + + backend default none; Multiple backends ----------------- From nils.goroll at uplex.de Thu Dec 19 08:25:07 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Thu, 19 Dec 2019 08:25:07 +0000 (UTC) Subject: [master] ca45d7f21 only re-run generate.py for "developer mode" if it is present Message-ID: <20191219082507.B14F9A29C6@lists.varnish-cache.org> commit ca45d7f2117ba76912fd4fc394c001ba94b86bd2 Author: Nils Goroll Date: Thu Dec 19 09:19:39 2019 +0100 only re-run generate.py for "developer mode" if it is present Notice: The boolean expression does not lack parantheses, the test for generate.py is only to be and'ed with the test for .git Fixes #3165 diff --git a/include/Makefile.am b/include/Makefile.am index 7899eda6e..d31231ddd 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -132,9 +132,10 @@ GENERATED_H = vcl.h $(GEN_H) ## except when building from a distribution vcs_version.h: - @if test -e $(top_srcdir)/.git || \ - ! test -f $(srcdir)/vmod_abi.h || \ - ! test -f $(srcdir)/vcs_version.h ; then \ + @if test -e $(srcdir)/generate.py && \ + test -e $(top_srcdir)/.git || \ + ! test -f $(srcdir)/vmod_abi.h || \ + ! test -f $(srcdir)/vcs_version.h ; then \ ${PYTHON} $(srcdir)/generate.py \ $(top_srcdir) $(top_builddir) ; \ fi From nils.goroll at uplex.de Thu Dec 19 11:47:07 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Thu, 19 Dec 2019 11:47:07 +0000 (UTC) Subject: [master] e73cf61bd formatting Message-ID: <20191219114707.46DE6BEB2F@lists.varnish-cache.org> commit e73cf61bd683f0f36134521e3c5dc8cfac30a8e2 Author: Nils Goroll Date: Thu Dec 19 12:12:02 2019 +0100 formatting diff --git a/doc/sphinx/users-guide/troubleshooting.rst b/doc/sphinx/users-guide/troubleshooting.rst index 1b8d7a1c4..64c3aa894 100644 --- a/doc/sphinx/users-guide/troubleshooting.rst +++ b/doc/sphinx/users-guide/troubleshooting.rst @@ -59,9 +59,10 @@ Varnish is crashing - panics ---------------------------- When Varnish goes bust the child processes crashes. Most of the -crashes are caught by one of the many consistency checks we have included in the Varnish source code. When Varnish hits one of these the caching -process will crash itself in a controlled manner, leaving a nice -stack trace with the mother process. +crashes are caught by one of the many consistency checks we have +included in the Varnish source code. When Varnish hits one of these +the caching process will crash itself in a controlled manner, leaving +a nice stack trace with the mother process. You can inspect any panic messages by typing ``panic.show`` in the CLI.:: @@ -80,7 +81,8 @@ You can inspect any panic messages by typing ``panic.show`` in the CLI.:: (..) The crash might be due to misconfiguration or a bug. If you suspect it -is a bug you can use the output in a bug report, see the "Trouble Tickets" section in the Introduction chapter above. +is a bug you can use the output in a bug report, see the "Trouble +Tickets" section in the Introduction chapter above. Varnish is crashing - segfaults ------------------------------- @@ -94,7 +96,9 @@ debug a segfault the developers need you to provide a fair bit of data. * Make sure you have Varnish installed with debugging symbols. - * Make sure core dumps are allowed in the parent shell. (``ulimit -c unlimited``) + * Make sure core dumps are allowed in the parent shell:: + + ulimit -c unlimited Once you have the core you open it with `gdb` and issue the command ``bt`` to get a stack trace of the thread that caused the segfault. From nils.goroll at uplex.de Thu Dec 19 11:47:07 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Thu, 19 Dec 2019 11:47:07 +0000 (UTC) Subject: [master] dfcdd87c1 minor doc polish Message-ID: <20191219114707.59207BEB32@lists.varnish-cache.org> commit dfcdd87c1451c0bdca56dc3f978faaf6fc6b7c78 Author: Nils Goroll Date: Thu Dec 19 12:14:09 2019 +0100 minor doc polish diff --git a/doc/sphinx/users-guide/troubleshooting.rst b/doc/sphinx/users-guide/troubleshooting.rst index 64c3aa894..92ed87ced 100644 --- a/doc/sphinx/users-guide/troubleshooting.rst +++ b/doc/sphinx/users-guide/troubleshooting.rst @@ -6,10 +6,10 @@ Troubleshooting Varnish Sometimes Varnish misbehaves or rather behaves the way you told it to behave but not necessarily the way you want it to behave. In order for you to understand whats going on there are a couple of places you can -check. :ref:`varnishlog(1)`, `/var/log/syslog`, `/var/log/messages` -are all good places where Varnish might leave clues of whats going -on. This section will guide you through basic troubleshooting in -Varnish. +check. :ref:`varnishlog(1)`, ``/var/log/syslog``, +``/var/log/messages`` are all good places where Varnish might leave +clues of whats going on. This section will guide you through basic +troubleshooting in Varnish. When Varnish won't start @@ -17,17 +17,14 @@ When Varnish won't start Sometimes Varnish wont start. There is a plethora of possible reasons why Varnish wont start on your machine. We've seen everything from wrong -permissions on `/dev/null` to other processes blocking the ports. +permissions on ``/dev/null`` to other processes blocking the ports. Starting Varnish in debug mode to see what is going on. -Try to start Varnish by:: - - # varnishd -f /usr/local/etc/varnish/default.vcl -s malloc,1G -T 127.0.0.1: 2000 -a 0.0.0.0:8080 -d - -Notice the '-d' parameter. It will give you some more information on what -is going on. Let us see how Varnish will react when something else is -listening on its port.:: +Try to start Varnish with the same arguments as otherwise, but ``-d`` +added. This will give you some more information on what is going +on. Let us see how Varnish will react when something else is listening +on its port.:: # varnishd -n foo -f /usr/local/etc/varnish/default.vcl -s malloc,1G -T 127.0.0.1:2000 -a 0.0.0.0:8080 -d storage_malloc: max size 1024 MB. From nils.goroll at uplex.de Thu Dec 19 11:47:07 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Thu, 19 Dec 2019 11:47:07 +0000 (UTC) Subject: [master] 8dbb9ab23 some advise on working with core files and stack overflows Message-ID: <20191219114707.7284FBEB36@lists.varnish-cache.org> commit 8dbb9ab2352dd47e634d88b505254602ee874616 Author: Nils Goroll Date: Thu Dec 19 12:44:36 2019 +0100 some advise on working with core files and stack overflows as promised in #3161 diff --git a/doc/sphinx/users-guide/troubleshooting.rst b/doc/sphinx/users-guide/troubleshooting.rst index 92ed87ced..46e5459fd 100644 --- a/doc/sphinx/users-guide/troubleshooting.rst +++ b/doc/sphinx/users-guide/troubleshooting.rst @@ -81,6 +81,24 @@ The crash might be due to misconfiguration or a bug. If you suspect it is a bug you can use the output in a bug report, see the "Trouble Tickets" section in the Introduction chapter above. +Varnish is crashing - stack overflows +------------------------------------- + +Bugs put aside, the most likely cause of crashes are stack overflows, +which is why we have added a heuristic to add a note when a crash +looks like it was caused by one. In this case, the panic message +contains something like this:: + + Signal 11 (Segmentation fault) received at 0x7f631f1b2f98 si_code 1 + THIS PROBABLY IS A STACK OVERFLOW - check thread_pool_stack parameter + +as a first measure, please follow this advise and check if crashes +still occur when you add 128k to whatever the value of the +``thread_pool_stack`` parameter and restart varnish. + +If varnish stops crashing with a larger ``thread_pool_stack`` +parameter, it's not a bug (at least most likely). + Varnish is crashing - segfaults ------------------------------- @@ -93,12 +111,66 @@ debug a segfault the developers need you to provide a fair bit of data. * Make sure you have Varnish installed with debugging symbols. - * Make sure core dumps are allowed in the parent shell:: - - ulimit -c unlimited + * Check where your operating system writes core files and ensure that + you actually get them. For example on linux, learn about + ``/proc/sys/kernel/core_pattern`` from the `core(5)` manpage. + * Make sure core dumps are allowed in the parent shell from which + varnishd is being started. In shell, this would be:: + + ulimit -c unlimited + + but if varnish is started from an init-script, that would need to + be adjusted or in the case of systemd, ``LimitCORE=infinity`` set + in the service's ``[Service]]`` section of the unit file. + +Once you have the core, ``cd`` into varnish's working directory (as +given by the ``-n`` parameter, whose default is +``$PREFIX/var/varnish/$HOSTNAME`` with ``$PREFIX`` being the +installation prefix, usually ``/usr/local``, open the core with +``gdb`` and issue the command ``bt`` to get a stack trace of the +thread that caused the segfault. + +A basic debug session for varnish installed under ``/usr/local`` could look +like this:: + + $ cd /usr/local/var/varnish/`uname -n`/ + $ gdb /usr/local/sbin/varnishd core + GNU gdb (Debian 7.12-6) 7.12.0.20161007-git + Copyright (C) 2016 Free Software Foundation, Inc. + [...] + Core was generated by `/usr/local/sbin/varnishd -a 127.0.0.1:8080 -b 127.0.0.1:8080'. + Program terminated with signal SIGABRT, Aborted. + #0 __GI_raise (sig=sig at entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51 + 51 ../sysdeps/unix/sysv/linux/raise.c: No such file or directory. + [Current thread is 1 (Thread 0x7f7749ea3700 (LWP 31258))] + + (gdb) bt + #0 __GI_raise (sig=sig at entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51 + #1 0x00007f775132342a in __GI_abort () at abort.c:89 + #2 0x000000000045939f in pan_ic (func=0x7f77439fb811 "VCL", file=0x7f77439fb74c "", line=0, + cond=0x7f7740098130 "PANIC: deliberately!", kind=VAS_VCL) at cache/cache_panic.c:839 + #3 0x0000000000518cb1 in VAS_Fail (func=0x7f77439fb811 "VCL", file=0x7f77439fb74c "", line=0, + cond=0x7f7740098130 "PANIC: deliberately!", kind=VAS_VCL) at vas.c:51 + #4 0x00007f77439fa6e9 in vmod_panic (ctx=0x7f7749ea2068, str=0x7f7749ea2018) at vmod_vtc.c:109 + #5 0x00007f77449fa5b8 in VGC_function_vcl_recv (ctx=0x7f7749ea2068) at vgc.c:1957 + #6 0x0000000000491261 in vcl_call_method (wrk=0x7f7749ea2dd0, req=0x7f7740096020, bo=0x0, + specific=0x0, method=2, func=0x7f77449fa550 ) at cache/cache_vrt_vcl.c:462 + #7 0x0000000000493025 in VCL_recv_method (vcl=0x7f775083f340, wrk=0x7f7749ea2dd0, req=0x7f7740096020, + bo=0x0, specific=0x0) at ../../include/tbl/vcl_returns.h:192 + #8 0x0000000000462979 in cnt_recv (wrk=0x7f7749ea2dd0, req=0x7f7740096020) at cache/cache_req_fsm.c:880 + #9 0x0000000000461553 in CNT_Request (req=0x7f7740096020) at ../../include/tbl/steps.h:36 + #10 0x00000000004a7fc6 in HTTP1_Session (wrk=0x7f7749ea2dd0, req=0x7f7740096020) + at http1/cache_http1_fsm.c:417 + #11 0x00000000004a72c3 in http1_req (wrk=0x7f7749ea2dd0, arg=0x7f7740096020) + at http1/cache_http1_fsm.c:86 + #12 0x0000000000496bb6 in Pool_Work_Thread (pp=0x7f774980e140, wrk=0x7f7749ea2dd0) + at cache/cache_wrk.c:406 + #13 0x00000000004963e3 in WRK_Thread (qp=0x7f774980e140, stacksize=57344, thread_workspace=2048) + at cache/cache_wrk.c:144 + #14 0x000000000049610b in pool_thread (priv=0x7f774880ec80) at cache/cache_wrk.c:439 + #15 0x00007f77516954a4 in start_thread (arg=0x7f7749ea3700) at pthread_create.c:456 + #16 0x00007f77513d7d0f in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:97 -Once you have the core you open it with `gdb` and issue the command ``bt`` -to get a stack trace of the thread that caused the segfault. Varnish gives me Guru meditation From dridi.boukelmoune at gmail.com Thu Dec 19 18:25:07 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 19 Dec 2019 18:25:07 +0000 (UTC) Subject: [6.0] 161a783b4 Make it explicit that vcl.discard are not allowed to fail in the child process. Message-ID: <20191219182507.0F869A272B@lists.varnish-cache.org> commit 161a783b4e72f95acc4c45d8521bcc5b610a17b0 Author: Poul-Henning Kamp Date: Fri Feb 22 09:05:40 2019 +0000 Make it explicit that vcl.discard are not allowed to fail in the child process. Inspired by: #2471 diff --git a/bin/varnishd/mgt/mgt_vcl.c b/bin/varnishd/mgt/mgt_vcl.c index 0ed9274f6..85bd56f5f 100644 --- a/bin/varnishd/mgt/mgt_vcl.c +++ b/bin/varnishd/mgt/mgt_vcl.c @@ -765,9 +765,9 @@ mcf_vcl_discard(struct cli *cli, const char * const *av, void *priv) else (void)mgt_vcl_setstate(cli, vp, VCL_STATE_COLD); if (MCH_Running()) { - /* XXX If this fails the child is crashing, figure that later */ assert(vp->state != VCL_STATE_WARM); - (void)mgt_cli_askchild(&status, &p, "vcl.discard %s\n", av[2]); + if (mgt_cli_askchild(&status, &p, "vcl.discard %s\n", av[2])) + assert(status == CLIS_OK || status == CLIS_COMMS); free(p); } mgt_vcl_del(vp); From dridi.boukelmoune at gmail.com Thu Dec 19 18:25:07 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 19 Dec 2019 18:25:07 +0000 (UTC) Subject: [6.0] ae00a9c1f change semantics of the vcl 'auto' state and centralize vcl mgt Message-ID: <20191219182507.302FAA272E@lists.varnish-cache.org> commit ae00a9c1f1d4045bf2dc7eb0053d3ecc01e552c8 Author: Nils Goroll Date: Sat Nov 17 19:19:48 2018 +0100 change semantics of the vcl 'auto' state and centralize vcl mgt Conceptually, the auto state was a variant of the warm state which would automatically cool the vcl. Yet, cooling did not only transition the temperature, but also the state, so 'auto' only worked one way - except that vcl.use or moving a label (by labeling another vcl) would also set 'auto', so a manual warm/cold setting would get lost. Now the auto-state will remain no matter the actual temperature or labeling, so when a vcl needs to implicitly change temperature (due to being used or being labeled), an auto vcl will remain auto, and a cold/warm vcl will change state, but never become 'auto' implicitly. The vcl state/temperature test v00003.vtc, besides testing the new auto semantics, now also checks for the right vcl.list output and has been reduced by a duplicate check (warm event check has been integrated into an existing warm event). On other code changes: * mgt_vcl_setstate is now only concerned with the state, the temperature will be changed implicitly if so required. The state will either end up changed or restored, depending on success. owner of changes to the (struct vclprog).state member * mgt_vcl_settemp responsible for the right action to change the temperature. For auto, it will only change the temperature, for non-auto, also the state. owner of changes to the (struct vclprog).warm member * mgt_vcl_tellchild Inform the child about a change and/or temperature change * mgt_vcl_set_cooldown Update the cooldown (go_cold) appropriately, should be called after a change/temperature change. Fixes #2834 Closes #2801 Conflicts: bin/varnishtest/tests/v00003.vtc diff --git a/bin/varnishd/mgt/mgt_vcl.c b/bin/varnishd/mgt/mgt_vcl.c index 85bd56f5f..de8513c55 100644 --- a/bin/varnishd/mgt/mgt_vcl.c +++ b/bin/varnishd/mgt/mgt_vcl.c @@ -104,6 +104,9 @@ static struct vclprog *active_vcl; static struct vev *e_poker; static int mgt_vcl_setstate(struct cli *, struct vclprog *, const char *); +static int mgt_vcl_settemp(struct cli *, struct vclprog *, unsigned); +static int mgt_vcl_tellchild(struct cli *, struct vclprog *, unsigned); +static void mgt_vcl_set_cooldown(struct vclprog *, vtim_mono); /*--------------------------------------------------------------------*/ @@ -197,13 +200,19 @@ mgt_vcl_dep_add(struct vclprog *vp_from, struct vclprog *vp_to) CHECK_OBJ_NOTNULL(vp_from, VCLPROG_MAGIC); CHECK_OBJ_NOTNULL(vp_to, VCLPROG_MAGIC); ALLOC_OBJ(vd, VCLDEP_MAGIC); + + mgt_vcl_set_cooldown(vp_from, -1); + mgt_vcl_set_cooldown(vp_to, -1); + XXXAN(vd); vd->from = vp_from; VTAILQ_INSERT_TAIL(&vp_from->dfrom, vd, lfrom); vd->to = vp_to; VTAILQ_INSERT_TAIL(&vp_to->dto, vd, lto); vp_to->nto++; + assert(vp_to->state == VCL_STATE_WARM || /* vcl.label ... */ + vp_to->state == VCL_STATE_AUTO || /* vcl.label ... */ vp_to->state == VCL_STATE_LABEL); /* return(vcl(...)) */ } @@ -215,12 +224,8 @@ mgt_vcl_dep_del(struct vcldep *vd) VTAILQ_REMOVE(&vd->from->dfrom, vd, lfrom); VTAILQ_REMOVE(&vd->to->dto, vd, lto); vd->to->nto--; - if (vd->to->nto == 0 && vd->to->state == VCL_STATE_WARM) { - vd->to->state = VCL_STATE_AUTO; - AZ(vd->to->go_cold); - (void)mgt_vcl_setstate(NULL, vd->to, VCL_STATE_AUTO); - AN(vd->to->go_cold); - } + if (vd->to->nto == 0) + mgt_vcl_set_cooldown(vd->to, VTIM_mono()); FREE_OBJ(vd); } @@ -393,50 +398,79 @@ mgt_has_vcl(void) return (!VTAILQ_EMPTY(&vclhead)); } +/* + * go_cold + * + * -1: leave alone + * 0: timer not started - not currently used + * >0: when timer started + */ +static void +mgt_vcl_set_cooldown(struct vclprog *vp, vtim_mono now) +{ + CHECK_OBJ_NOTNULL(vp, VCLPROG_MAGIC); + + if (vp == active_vcl || + vp->state != VCL_STATE_AUTO || + vp->warm == 0 || + !VTAILQ_EMPTY(&vp->dto) || + !VTAILQ_EMPTY(&vp->dfrom)) + vp->go_cold = -1; + else + vp->go_cold = now; +} + static unsigned -mgt_vcl_cooldown(struct vclprog *vp) +mgt_vcl_cooldown(struct vclprog *vp, vtim_mono now) { - double now; + CHECK_OBJ_NOTNULL(vp, VCLPROG_MAGIC); - if (vp->state != VCL_STATE_AUTO) + if (vp->go_cold < 0) return (0); - now = VTIM_mono(); - if (vp->go_cold > 0 && vp->go_cold + mgt_param.vcl_cooldown < now) - return (1); + if (vp->go_cold == 0) { + mgt_vcl_set_cooldown(vp, now); + return (0); + } - if (vp->go_cold == 0 && vp != active_vcl) - vp->go_cold = now; + assert(vp->go_cold > 0); + + if (vp->go_cold + mgt_param.vcl_cooldown < now) + return (1); return (0); } static int -mgt_vcl_setstate(struct cli *cli, struct vclprog *vp, const char *vs) +mgt_vcl_settemp(struct cli *cli, struct vclprog *vp, unsigned warm) { - unsigned status, warm; - char *p; int i; - assert(vs != VCL_STATE_LABEL); + CHECK_OBJ_NOTNULL(vp, VCLPROG_MAGIC); - if (vp == active_vcl || mcf_is_label(vp)) { - AN(vp->warm); - /* Only the poker sends COLD indiscriminately, ignore it */ - if (vs == VCL_STATE_COLD) - AZ(cli); + if (warm == vp->warm) return (0); + + if (vp->state == VCL_STATE_AUTO || vp->state == VCL_STATE_LABEL) { + mgt_vcl_set_cooldown(vp, -1); + i = mgt_vcl_tellchild(cli, vp, warm); + mgt_vcl_set_cooldown(vp, VTIM_mono()); + } else { + i = mgt_vcl_setstate(cli, vp, + warm ? VCL_STATE_WARM : VCL_STATE_COLD); } - if (vs == VCL_STATE_AUTO) - vs = (mgt_vcl_cooldown(vp) ? VCL_STATE_COLD : VCL_STATE_WARM); - else - vp->go_cold = 0; + return (i); +} - warm = (vs == VCL_STATE_WARM ? 1 : 0); +static int +mgt_vcl_tellchild(struct cli *cli, struct vclprog *vp, unsigned warm) +{ + unsigned status; + char *p; + int i; - if (vp->warm == warm) - return (0); + CHECK_OBJ_NOTNULL(vp, VCLPROG_MAGIC); if (!MCH_Running()) { vp->warm = warm; @@ -444,7 +478,7 @@ mgt_vcl_setstate(struct cli *cli, struct vclprog *vp, const char *vs) } i = mgt_cli_askchild(&status, &p, "vcl.state %s %d%s\n", - vp->name, warm, vs); + vp->name, warm, vp->state); if (i && cli != NULL) { VCLI_SetResult(cli, status); VCLI_Out(cli, "%s", p); @@ -463,6 +497,47 @@ mgt_vcl_setstate(struct cli *cli, struct vclprog *vp, const char *vs) return (i); } +static int +mgt_vcl_setstate(struct cli *cli, struct vclprog *vp, const char *vs) +{ + unsigned warm; + int i; + const char *os; + + CHECK_OBJ_NOTNULL(vp, VCLPROG_MAGIC); + + assert(vs != VCL_STATE_LABEL); + + if (mcf_is_label(vp)) { + AN(vp->warm); + /* do not touch labels */ + return (0); + } + + if (vp->state == vs) + return (0); + + os = vp->state; + vp->state = vs; + + if (vp == active_vcl) { + assert (vs == VCL_STATE_WARM || vs == VCL_STATE_AUTO); + AN(vp->warm); + warm = 1; + } else if (vs == VCL_STATE_AUTO) { + warm = vp->warm; + } else { + warm = (vs == VCL_STATE_WARM ? 1 : 0); + } + + i = mgt_vcl_tellchild(cli, vp, warm); + if (i == 0) + mgt_vcl_set_cooldown(vp, VTIM_mono()); + else + vp->state = os; + return (i); +} + /*--------------------------------------------------------------------*/ static void @@ -518,8 +593,7 @@ mgt_new_vcl(struct cli *cli, const char *vclname, const char *vclsrc, } free(p); - if (vp->warm && vp->state == VCL_STATE_AUTO) - vp->go_cold = VTIM_mono(); + mgt_vcl_set_cooldown(vp, VTIM_mono()); } /*--------------------------------------------------------------------*/ @@ -537,8 +611,8 @@ mgt_vcl_startup(struct cli *cli, const char *vclsrc, const char *vclname, bprintf(buf, "boot%d", n++); vclname = buf; } + active_vcl = NULL; mgt_new_vcl(cli, vclname, vclsrc, origin, NULL, C_flag); - active_vcl = mcf_vcl_byname(vclname); } /*--------------------------------------------------------------------*/ @@ -565,7 +639,7 @@ mgt_push_vcls(struct cli *cli, unsigned *status, char **p) AN(active_vcl); /* The VCL has not been loaded yet, it cannot fail */ - AZ(mgt_vcl_setstate(cli, active_vcl, VCL_STATE_WARM)); + (void)cli; VTAILQ_FOREACH(vp, &vclhead, list) vp->loaded = 0; @@ -658,36 +732,21 @@ mcf_vcl_state(struct cli *cli, const char * const *av, void *priv) return; } - if (!VTAILQ_EMPTY(&vp->dto)) { - assert(vp->state != VCL_STATE_COLD); - if (state == VCL_STATE_COLD) { + if (state == VCL_STATE_COLD) { + if (!VTAILQ_EMPTY(&vp->dto)) { + assert(vp->state != VCL_STATE_COLD); VCLI_Out(cli, "A labeled VCL cannot be set cold"); VCLI_SetResult(cli, CLIS_CANT); return; } - } - - if (vp->state == state) - return; - - if (state == VCL_STATE_AUTO) { - vp->state = VCL_STATE_AUTO; - (void)mgt_vcl_setstate(cli, vp, VCL_STATE_AUTO); - } else if (state == VCL_STATE_COLD) { if (vp == active_vcl) { VCLI_Out(cli, "Cannot set the active VCL cold."); VCLI_SetResult(cli, CLIS_CANT); return; } - vp->state = VCL_STATE_AUTO; - (void)mgt_vcl_setstate(cli, vp, VCL_STATE_COLD); - } else if (state == VCL_STATE_WARM) { - if (mgt_vcl_setstate(cli, vp, VCL_STATE_WARM) == 0) - vp->state = VCL_STATE_WARM; - } else { - VCLI_Out(cli, "State must be one of auto, cold or warm."); - VCLI_SetResult(cli, CLIS_PARAM); } + + (void)mgt_vcl_setstate(cli, vp, state); } static void v_matchproto_(cli_func_t) @@ -696,6 +755,7 @@ mcf_vcl_use(struct cli *cli, const char * const *av, void *priv) unsigned status; char *p = NULL; struct vclprog *vp, *vp2; + vtim_mono now; (void)priv; vp = mcf_find_vcl(cli, av[2]); @@ -703,22 +763,22 @@ mcf_vcl_use(struct cli *cli, const char * const *av, void *priv) return; if (vp == active_vcl) return; - if (mgt_vcl_setstate(cli, vp, VCL_STATE_WARM)) + + if (mgt_vcl_settemp(cli, vp, 1)) return; + if (MCH_Running() && mgt_cli_askchild(&status, &p, "vcl.use %s\n", av[2])) { VCLI_SetResult(cli, status); VCLI_Out(cli, "%s", p); - AZ(vp->go_cold); - (void)mgt_vcl_setstate(cli, vp, VCL_STATE_AUTO); } else { VCLI_Out(cli, "VCL '%s' now active", av[2]); vp2 = active_vcl; active_vcl = vp; - if (vp2 != NULL) { - AZ(vp2->go_cold); - (void)mgt_vcl_setstate(cli, vp2, VCL_STATE_AUTO); - } + now = VTIM_mono(); + mgt_vcl_set_cooldown(vp, now); + if (vp2 != NULL) + mgt_vcl_set_cooldown(vp2, now); } free(p); } @@ -760,12 +820,14 @@ mcf_vcl_discard(struct cli *cli, const char * const *av, void *priv) } return; } - if (mcf_is_label(vp)) + if (mcf_is_label(vp)) { AN(vp->warm); - else + vp->warm = 0; + } else { (void)mgt_vcl_setstate(cli, vp, VCL_STATE_COLD); + } if (MCH_Running()) { - assert(vp->state != VCL_STATE_WARM); + AZ(vp->warm); if (mgt_cli_askchild(&status, &p, "vcl.discard %s\n", av[2])) assert(status == CLIS_OK || status == CLIS_COMMS); free(p); @@ -913,9 +975,8 @@ mcf_vcl_label(struct cli *cli, const char * const *av, void *priv) } } - if (mgt_vcl_setstate(cli, vpt, VCL_STATE_WARM)) + if (mgt_vcl_settemp(cli, vpt, 1)) return; - vpt->state = VCL_STATE_WARM; /* XXX: race with the poker? */ if (vpl != NULL) { mgt_vcl_dep_del(VTAILQ_FIRST(&vpl->dfrom)); @@ -925,7 +986,8 @@ mcf_vcl_label(struct cli *cli, const char * const *av, void *priv) } AN(vpl); - vpl->warm = 1; + if (mgt_vcl_settemp(cli, vpl, 1)) + return; mgt_vcl_dep_add(vpl, vpt); if (!MCH_Running()) @@ -945,13 +1007,16 @@ static int v_matchproto_(vev_cb_f) mgt_vcl_poker(const struct vev *e, int what) { struct vclprog *vp; + vtim_mono now; (void)e; (void)what; e_poker->timeout = mgt_param.vcl_cooldown * .45; - VTAILQ_FOREACH(vp, &vclhead, list) - if (mgt_vcl_cooldown(vp)) - (void)mgt_vcl_setstate(NULL, vp, VCL_STATE_COLD); + now = VTIM_mono(); + VTAILQ_FOREACH(vp, &vclhead, list) { + if (mgt_vcl_cooldown(vp, now)) + (void)mgt_vcl_settemp(NULL, vp, 0); + } return (0); } diff --git a/bin/varnishtest/tests/c00077.vtc b/bin/varnishtest/tests/c00077.vtc index 49ed76797..8b2c35df1 100644 --- a/bin/varnishtest/tests/c00077.vtc +++ b/bin/varnishtest/tests/c00077.vtc @@ -13,6 +13,8 @@ varnish v1 -vcl+backend { varnish v1 -clierr 106 "vcl.label vcl.A vcl1" varnish v1 -cliok "vcl.label vclA vcl1" +# labeling twice #2834 +varnish v1 -cliok "vcl.label vclA vcl1" varnish v1 -vcl+backend { sub vcl_recv { diff --git a/bin/varnishtest/tests/r02432.vtc b/bin/varnishtest/tests/r02432.vtc index 97b5d30d9..2365f1725 100644 --- a/bin/varnishtest/tests/r02432.vtc +++ b/bin/varnishtest/tests/r02432.vtc @@ -11,6 +11,7 @@ varnish v1 -vcl+backend { } -start varnish v1 -cliok "vcl.label label1 vcl1" +varnish v1 -cliok "vcl.list" varnish v1 -vcl+backend { sub vcl_recv { diff --git a/bin/varnishtest/tests/v00003.vtc b/bin/varnishtest/tests/v00003.vtc index 6236f28f1..2dcd423e6 100644 --- a/bin/varnishtest/tests/v00003.vtc +++ b/bin/varnishtest/tests/v00003.vtc @@ -4,7 +4,6 @@ server s1 -repeat 20 { rxreq txresp delay .2 - close } -start # The debug vmod logs temperature vcl events @@ -12,7 +11,8 @@ varnish v1 -arg "-p vcl_cooldown=1" -vcl { import debug; backend default { .host = "${s1_addr}"; - .probe = { .interval = 1s; .initial = 1;} + .port = "${s1_port}"; + .probe = { .interval = 1s; } } } -start @@ -24,7 +24,8 @@ varnish v1 -cliok "backend.list -p *.*" varnish v1 -vcl { backend default { .host = "${s1_addr}"; - .probe = { .interval = 1s; .initial = 1;} + .port = "${s1_port}"; + .probe = { .interval = 1s; } } } @@ -33,64 +34,64 @@ delay .4 varnish v1 -expect VBE.vcl1.default.happy >= 0 varnish v1 -expect VBE.vcl2.default.happy >= 0 -# Freeze the first VCL -varnish v1 -cliok "vcl.state vcl1 cold" -delay .4 -varnish v1 -expect !VBE.vcl1.default.happy +# We are about to freeze vcl, then implicitly thaw it via use. +# check that we see the events -# Set it auto should be a no-op -varnish v1 -cliok "vcl.state vcl1 auto" +logexpect l1 -v v1 -g raw { + expect * 0 Debug "vcl1: VCL_EVENT_COLD" + expect * 0 Debug "vcl1: VCL_EVENT_WARM" +} -start + +# Freeze vcl1 +varnish v1 -cliok "vcl.state vcl1 cold" +varnish v1 -cliexpect "available *cold/cold *[0-9]+ *vcl1\\s+active *auto/warm *[0-9]+ *vcl2" "vcl.list" delay .4 varnish v1 -expect !VBE.vcl1.default.happy -# Use it, and it should come alive +# Use it, and it should come warm (but not auto) varnish v1 -cliok "vcl.use vcl1" +varnish v1 -cliexpect "active *warm/warm *[0-9]+ *vcl1\\s+available *auto/warm *[0-9]+ *vcl2" "vcl.list" delay .4 varnish v1 -expect VBE.vcl1.default.happy >= 0 varnish v1 -expect VBE.vcl2.default.happy >= 0 +logexpect l1 -wait + # and the unused one should go cold delay 4 +varnish v1 -cliexpect "active *warm/warm *[0-9]+ *vcl1\\s+available *auto/cold *[0-9]+ *vcl2" "vcl.list" varnish v1 -expect !VBE.vcl2.default.happy -# Mark the used warm and use the other -varnish v1 -cliok "vcl.state vcl1 warm" +# use the other varnish v1 -cliok "vcl.use vcl2" +varnish v1 -cliexpect "available *warm/warm *[0-9]+ *vcl1\\s+active *auto/warm *[0-9]+ *vcl2" "vcl.list" -# It will stay warm even after the cooldown period +# the non-auto vcl will stay warm even after the cooldown period delay 4 +varnish v1 -cliexpect "available *warm/warm *[0-9]+ *vcl1\\s+active *auto/warm *[0-9]+ *vcl2" "vcl.list" varnish v1 -expect VBE.vcl1.default.happy >= 0 varnish v1 -expect VBE.vcl2.default.happy >= 0 # You can't freeze the active VCL varnish v1 -clierr 300 "vcl.state vcl2 cold" -# However a warm event is guaranteed... -logexpect l1 -v v1 -g raw { - expect * 0 Debug "vcl1: VCL_EVENT_COLD" - expect * 0 Debug "vcl1: VCL_EVENT_WARM" -} -start - -# ...when you use a cold VCL -varnish v1 -cliok "vcl.state vcl1 cold" -varnish v1 -cliok "vcl.use vcl1" - -logexpect l1 -wait - -# It will apply the cooldown period once inactive -varnish v1 -cliok "vcl.use vcl2" +# the non-auto vcl will apply the cooldown again once changed back to auto +varnish v1 -cliok "vcl.state vcl1 auto" +varnish v1 -cliexpect "available *auto/warm *[0-9]+ *vcl1\\s+active *auto/warm *[0-9]+ *vcl2" "vcl.list" delay .4 varnish v1 -expect VBE.vcl1.default.happy >= 0 delay 4 +varnish v1 -cliexpect "available *auto/cold *[0-9]+ *vcl1\\s+active *auto/warm *[0-9]+ *vcl2" "vcl.list" varnish v1 -expect !VBE.vcl1.default.happy # A VMOD's warm-up can fail varnish v1 -cliok "param.set max_esi_depth 42" varnish v1 -clierr 300 "vcl.state vcl1 warm" -varnish v1 -cliexpect "available *cold/cold *[0-9]+ *vcl1\\s+active *warm/warm *[0-9]+ *vcl2" "vcl.list" +varnish v1 -cliexpect "available *auto/cold *[0-9]+ *vcl1\\s+active *auto/warm *[0-9]+ *vcl2" "vcl.list" # A warm-up failure can also fail a child start varnish v1 -cliok stop varnish v1 -cliok "vcl.state vcl1 warm" +varnish v1 -cliok "vcl.list" varnish v1 -clierr 300 start From dridi.boukelmoune at gmail.com Thu Dec 19 18:25:07 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 19 Dec 2019 18:25:07 +0000 (UTC) Subject: [6.0] e8e4d4890 no implicit warmup for manual temperature control Message-ID: <20191219182507.57B68A2732@lists.varnish-cache.org> commit e8e4d48906aac5ec8c8394d07f3e0ad2b2952aa6 Author: Nils Goroll Date: Mon Nov 19 14:45:26 2018 +0100 no implicit warmup for manual temperature control As discussed during bugwash, we should be consistent about the manual temperature controls and not transition cold->warm, but rather fail. diff --git a/bin/varnishd/mgt/mgt_vcl.c b/bin/varnishd/mgt/mgt_vcl.c index de8513c55..049cee5af 100644 --- a/bin/varnishd/mgt/mgt_vcl.c +++ b/bin/varnishd/mgt/mgt_vcl.c @@ -463,6 +463,18 @@ mgt_vcl_settemp(struct cli *cli, struct vclprog *vp, unsigned warm) return (i); } +static int +mgt_vcl_requirewarm(struct cli *cli, struct vclprog *vp) +{ + if (vp->state == VCL_STATE_COLD) { + VCLI_SetResult(cli, CLIS_CANT); + VCLI_Out(cli, "VCL '%s' is cold - set to auto or warm first", + vp->name); + return (1); + } + return (mgt_vcl_settemp(cli, vp, 1)); +} + static int mgt_vcl_tellchild(struct cli *cli, struct vclprog *vp, unsigned warm) { @@ -764,7 +776,7 @@ mcf_vcl_use(struct cli *cli, const char * const *av, void *priv) if (vp == active_vcl) return; - if (mgt_vcl_settemp(cli, vp, 1)) + if (mgt_vcl_requirewarm(cli, vp)) return; if (MCH_Running() && @@ -975,10 +987,13 @@ mcf_vcl_label(struct cli *cli, const char * const *av, void *priv) } } - if (mgt_vcl_settemp(cli, vpt, 1)) + if (mgt_vcl_requirewarm(cli, vpt)) return; if (vpl != NULL) { + /* potentially fail before we delete the dependency */ + if (mgt_vcl_requirewarm(cli, vpl)) + return; mgt_vcl_dep_del(VTAILQ_FIRST(&vpl->dfrom)); AN(VTAILQ_EMPTY(&vpl->dfrom)); } else { @@ -986,7 +1001,7 @@ mcf_vcl_label(struct cli *cli, const char * const *av, void *priv) } AN(vpl); - if (mgt_vcl_settemp(cli, vpl, 1)) + if (mgt_vcl_requirewarm(cli, vpl)) return; mgt_vcl_dep_add(vpl, vpt); diff --git a/bin/varnishtest/tests/v00003.vtc b/bin/varnishtest/tests/v00003.vtc index 2dcd423e6..a1ac35fc9 100644 --- a/bin/varnishtest/tests/v00003.vtc +++ b/bin/varnishtest/tests/v00003.vtc @@ -48,7 +48,10 @@ varnish v1 -cliexpect "available *cold/cold *[0-9]+ *vcl1\\s+active *auto/warm * delay .4 varnish v1 -expect !VBE.vcl1.default.happy -# Use it, and it should come warm (but not auto) +# Manual temperature control needs to be explicit before use +varnish v1 -clierr 300 "vcl.use vcl1" + +varnish v1 -cliok "vcl.state vcl1 warm" varnish v1 -cliok "vcl.use vcl1" varnish v1 -cliexpect "active *warm/warm *[0-9]+ *vcl1\\s+available *auto/warm *[0-9]+ *vcl2" "vcl.list" delay .4 From dridi.boukelmoune at gmail.com Thu Dec 19 19:15:07 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 19 Dec 2019 19:15:07 +0000 (UTC) Subject: [6.0] ef20272c9 Make sure to use none backends in generated C code Message-ID: <20191219191507.BBD84A3DCB@lists.varnish-cache.org> commit ef20272c9fb77b6cb0c7b91c0267f48af5e1f7d9 Author: Dridi Boukelmoune Date: Fri Nov 15 17:04:40 2019 +0100 Make sure to use none backends in generated C code Otherwise you might run into this: Message from VCC-compiler: Unused backend nil, defined: ('' Line 4 Pos 17) backend nil none; ----------------###------ (That was just a warning) Message from C-compiler: vgc.c:1476:20: error: unused variable 'vgc_backend_nil' [-Werror,-Wunused-variable] static VCL_BACKEND vgc_backend_nil; ^ 1 error generated. Running C-compiler failed, exited with 1 VCL compilation failed This is done in both init and discard code to maintain the balance. diff --git a/bin/varnishtest/tests/v00060.vtc b/bin/varnishtest/tests/v00060.vtc index b1540dd5a..28bbcb89f 100644 --- a/bin/varnishtest/tests/v00060.vtc +++ b/bin/varnishtest/tests/v00060.vtc @@ -43,3 +43,9 @@ client c1 { rxresp expect resp.status == 503 } -run + +varnish v1 -cliok "param.set vcc_err_unref off" +varnish v1 -vcl { + backend bad { .host = "${bad_backend}"; } + backend nil none; +} diff --git a/lib/libvcc/vcc_backend.c b/lib/libvcc/vcc_backend.c index 6bdaeb65e..72a7a1e84 100644 --- a/lib/libvcc/vcc_backend.c +++ b/lib/libvcc/vcc_backend.c @@ -330,6 +330,9 @@ vcc_ParseHostDef(struct vcc *tl, const struct token *t_be, const char *vgcname) Fb(tl, 0, "\n\t%s = (NULL);\n", vgcname); vcc_NextToken(tl); SkipToken(tl, ';'); + ifp = New_IniFin(tl); + VSB_printf(ifp->ini, "\t(void)%s;\n", vgcname); + VSB_printf(ifp->fin, "\t\t(void)%s;\n", vgcname); return; } From reza at naghibi.com Thu Dec 19 21:04:07 2019 From: reza at naghibi.com (Reza Naghibi) Date: Thu, 19 Dec 2019 21:04:07 +0000 (UTC) Subject: [6.0] 8bf63a886 Correct the probe heap comparison function Message-ID: <20191219210407.96152A639B@lists.varnish-cache.org> commit 8bf63a886f6b2c74dcb6a246fc8fdd425c5a3408 Author: Martin Blix Grydeland Date: Tue Nov 5 16:25:28 2019 +0100 Correct the probe heap comparison function Fix the probe scheduler heap comparison function to be consistent with regard to different running state of the two arguments. With this fix, probes that are not running will always bubble to the top before those that are already running. diff --git a/bin/varnishd/cache/cache_backend_probe.c b/bin/varnishd/cache/cache_backend_probe.c index 9ed6e515c..b488c1525 100644 --- a/bin/varnishd/cache/cache_backend_probe.c +++ b/bin/varnishd/cache/cache_backend_probe.c @@ -696,8 +696,8 @@ vbp_cmp(void *priv, const void *a, const void *b) CAST_OBJ_NOTNULL(aa, a, VBP_TARGET_MAGIC); CAST_OBJ_NOTNULL(bb, b, VBP_TARGET_MAGIC); - if (aa->running && !bb->running) - return (0); + if ((aa->running == 0) != (bb->running == 0)) + return (aa->running == 0); return (aa->due < bb->due); } From reza at naghibi.com Thu Dec 19 21:11:07 2019 From: reza at naghibi.com (Reza Naghibi) Date: Thu, 19 Dec 2019 21:11:07 +0000 (UTC) Subject: [6.0] a8606b8e8 Add "error" state to backend fetch and response Message-ID: <20191219211107.30E33A67E7@lists.varnish-cache.org> commit a8606b8e8d143544f1704da8df1a1e1e25154767 Author: Andrew Wiik Date: Tue Jun 4 11:01:04 2019 -0400 Add "error" state to backend fetch and response diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 2d6f1ccbc..42b2272fc 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -407,6 +407,9 @@ struct busyobj { struct http_conn *htc; + uint16_t err_code; + const char *err_reason; + struct pool_task fetch_task; #define BO_FLAG(l, r, w, d) unsigned l:1; diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index d224e6c6b..3ce30ca8a 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -277,7 +277,7 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo) if (wrk->handling == VCL_RET_ABANDON || wrk->handling == VCL_RET_FAIL) return (F_STP_FAIL); - assert (wrk->handling == VCL_RET_FETCH); + assert (wrk->handling == VCL_RET_FETCH || wrk->handling == VCL_RET_ERROR); HTTP_Setup(bo->beresp, bo->ws, bo->vsl, SLT_BerespMethod); @@ -290,6 +290,9 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo) bo->vfc->resp = bo->beresp; bo->vfc->req = bo->bereq; + if (wrk->handling == VCL_RET_ERROR) + return (F_STP_ERROR); + i = VDI_GetHdr(wrk, bo); now = W_TIM_real(wrk); @@ -383,10 +386,15 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo) VCL_backend_response_method(bo->vcl, wrk, NULL, bo, NULL); - if (wrk->handling == VCL_RET_ABANDON || wrk->handling == VCL_RET_FAIL) { + if (wrk->handling == VCL_RET_ABANDON || wrk->handling == VCL_RET_FAIL || + wrk->handling == VCL_RET_ERROR) { bo->htc->doclose = SC_RESP_CLOSE; + VDI_Finish(bo->wrk, bo); - return (F_STP_FAIL); + if (wrk->handling == VCL_RET_ERROR) + return (F_STP_ERROR); + else + return (F_STP_FAIL); } if (wrk->handling == VCL_RET_RETRY) { @@ -756,7 +764,8 @@ vbf_stp_error(struct worker *wrk, struct busyobj *bo) AN(bo->fetch_objcore->flags & OC_F_BUSY); assert(bo->director_state == DIR_S_NULL); - wrk->stats->fetch_failed++; + if (wrk->handling != VCL_RET_ERROR) + wrk->stats->fetch_failed++; now = W_TIM_real(wrk); VSLb_ts_busyobj(bo, "Error", now); @@ -770,7 +779,11 @@ vbf_stp_error(struct worker *wrk, struct busyobj *bo) // XXX: reset all beresp flags ? HTTP_Setup(bo->beresp, bo->ws, bo->vsl, SLT_BerespMethod); - http_PutResponse(bo->beresp, "HTTP/1.1", 503, "Backend fetch failed"); + if (bo->err_code > 0) + http_PutResponse(bo->beresp, "HTTP/1.1", bo->err_code, bo->err_reason); + else + http_PutResponse(bo->beresp, "HTTP/1.1", 503, "Backend fetch failed"); + http_TimeHeader(bo->beresp, "Date: ", now); http_SetHeader(bo->beresp, "Server: Varnish"); diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c index 28ca3d8fd..4b49e1d3a 100644 --- a/bin/varnishd/cache/cache_vrt.c +++ b/bin/varnishd/cache/cache_vrt.c @@ -55,9 +55,18 @@ VRT_synth(VRT_CTX, VCL_INT code, VCL_STRING reason) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); - CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); + assert(ctx->req != NULL || ctx->bo != NULL); if (code < 100 || code > 65535) code = 503; + + if (ctx->req == NULL) { + CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC); + ctx->bo->err_code = (uint16_t)code; + ctx->bo->err_reason = reason ? reason + : http_Status2Reason(ctx->bo->err_code % 1000, NULL); + return; + } + ctx->req->err_code = (uint16_t)code; ctx->req->err_reason = reason ? reason : http_Status2Reason(ctx->req->err_code % 1000, NULL); diff --git a/bin/varnishtest/tests/v00062.vtc b/bin/varnishtest/tests/v00062.vtc new file mode 100644 index 000000000..365b949d6 --- /dev/null +++ b/bin/varnishtest/tests/v00062.vtc @@ -0,0 +1,78 @@ +varnishtest "backend_(fetch|response) error state with custom status/reason" + +server s1 -repeat 3 { + rxreq + txresp +} -start + +varnish v1 -vcl+backend { + sub vcl_backend_fetch { + if (bereq.url == "/errorsynth") { + return (error(403)); + } + + if (bereq.url == "/errorsynthbody") { + return (error(403, "Steven has no cookies")); + } + + if (bereq.url == "/error") { + return (error); + } + } + + sub vcl_backend_response { + if (bereq.url == "/resperrorsynth") { + return (error(403)); + } + + if (bereq.url == "/resperrorsynthbody") { + return (error(403, "Steven has no cookies")); + } + + if (bereq.url == "/resperror") { + return (error); + } + } + + sub vcl_backend_error { + set beresp.http.error = "visited"; + } +} -start + +client c1 { + txreq -url /error + rxresp + expect resp.status == 503 + expect resp.http.error == visited + + txreq -url /errorsynth + rxresp + expect resp.status == 403 + expect resp.http.error == visited + + txreq -url /errorsynthbody + rxresp + expect resp.status == 403 + expect resp.reason == "Steven has no cookies" + expect resp.http.error == visited + + txreq -url /resperror + rxresp + expect resp.status == 503 + expect resp.http.error == visited + + txreq -url /resperrorsynth + rxresp + expect resp.status == 403 + expect resp.http.error == visited + + txreq -url /resperrorsynthbody + rxresp + expect resp.status == 403 + expect resp.reason == "Steven has no cookies" + expect resp.http.error == visited +} -run + +# Make sure we don't increment the failed fetch counter + +varnish v1 -expect fetch_failed == 0 diff --git a/doc/graphviz/cache_fetch.dot b/doc/graphviz/cache_fetch.dot index eb68f72a3..96c0967a0 100644 --- a/doc/graphviz/cache_fetch.dot +++ b/doc/graphviz/cache_fetch.dot @@ -39,16 +39,18 @@ digraph cache_fetch { /* vbf_stp_startfetch() */ v_b_f [ shape=record - label="{vbf_stp_startfetch:|{vcl_backend_fetch\{\}|bereq.*}|{fail|abandon|fetch}}" + label="{vbf_stp_startfetch:|{vcl_backend_fetch\{\}|bereq.*}|{error|fail|abandon|fetch}}" ] + v_b_f:error:s -> v_b_e v_b_f:fetch:s -> v_b_hdrs [style=bold] v_b_hdrs [ label="send bereq,\nread beresp (headers)"] v_b_hdrs -> v_b_r [style=bold] v_b_hdrs -> v_b_e v_b_r [ shape=record - label="{vbf_stp_startfetch:|{vcl_backend_response\{\}|{bereq.*|beresp.*}}|{fail|{retry|{max?|ok?}}|abandon|{deliver or pass|{304?|other?}}}}" + label="{vbf_stp_startfetch:|{vcl_backend_response\{\}|{bereq.*|beresp.*}}|{error|fail|{retry|{max?|ok?}}|abandon|{deliver or pass|{304?|other?}}}}" ] + v_b_r:error:s -> v_b_e v_b_r:retry -> v_b_r_retry [color=purple] v_b_r:max -> v_b_e v_b_r:fetch_304:s -> vbf_stp_condfetch @@ -90,8 +92,8 @@ digraph cache_fetch { ] vbf_stp_condfetch:ok:s -> vbf_stp_fetchend - error [shape=plaintext] - error -> FETCH_FAIL + fail [shape=plaintext] + fail -> FETCH_FAIL /* vbf_stp_error */ v_b_e [ diff --git a/doc/graphviz/cache_fetch.svg b/doc/graphviz/cache_fetch.svg index aeb38a95b..fa09e056e 100644 --- a/doc/graphviz/cache_fetch.svg +++ b/doc/graphviz/cache_fetch.svg @@ -1,283 +1,338 @@ - - - + + cache_fetch - -cluster_backend - + + +cluster_backend + -RETRY -RETRY + +RETRY +RETRY -v_b_f - -vbf_stp_startfetch: - -vcl_backend_fetch{} - -bereq.* - -fail - -abandon - -fetch + +v_b_f + +vbf_stp_startfetch: + +vcl_backend_fetch{} + +bereq.* + +error + +fail + +abandon + +fetch -RETRY->v_b_f - - + +RETRY->v_b_f + + -v_b_f_BGFETCH - -BGFETCH + +v_b_f_BGFETCH + +BGFETCH -v_b_f_BGFETCH->v_b_f - - + +v_b_f_BGFETCH->v_b_f + + -v_b_f_FETCH - -FETCH + +v_b_f_FETCH + +FETCH -v_b_f_FETCH->v_b_f - - + +v_b_f_FETCH->v_b_f + + -v_b_f_FETCH->v_b_f - - + +v_b_f_FETCH->v_b_f + + + + + +v_b_e + +vbf_stp_error: + +vcl_backend_error{} + +bereq.* + +beresp.* + +retry + +fail + +max? + +ok? + +abandon + +deliver + + + +v_b_f:s->v_b_e + + -v_b_hdrs - -send bereq, -read beresp (headers) + +v_b_hdrs + +send bereq, +read beresp (headers) -v_b_f:fetch:s->v_b_hdrs - - + +v_b_f:s->v_b_hdrs + + - -v_b_r - -vbf_stp_startfetch: - -vcl_backend_response{} - -bereq.* - -beresp.* - -fail - -retry - -max? - -ok? - -abandon - -deliver or pass - -304? - -other? + + +FETCH_DONE + +FETCH_DONE - -v_b_hdrs->v_b_r - - + + +v_b_e:deliver->FETCH_DONE + + +"backend synth" - -v_b_e - -vbf_stp_error: - -vcl_backend_error{} - -bereq.* - -beresp.* - -retry - -fail - -max? - -ok? - -abandon - -deliver + + +FETCH_FAIL + +FETCH_FAIL + + + +v_b_e:s->FETCH_FAIL + + + + + +v_b_e_retry +RETRY + + + +v_b_e:retry->v_b_e_retry + + -v_b_hdrs->v_b_e - - + +v_b_hdrs->v_b_e + + + + + +v_b_r + +vbf_stp_startfetch: + +vcl_backend_response{} + +bereq.* + +beresp.* + +error + +fail + +retry + +max? + +ok? + +abandon + +deliver or pass + +304? + +other? + + + +v_b_hdrs->v_b_r + + + + + +v_b_r:s->v_b_e + + -v_b_r:max->v_b_e - - + +v_b_r:max->v_b_e + + -v_b_r_retry -RETRY + +v_b_r_retry +RETRY -v_b_r:retry->v_b_r_retry - - + +v_b_r:retry->v_b_r_retry + + -vbf_stp_condfetch - -vbf_stp_condfetch: - -copy obj attr - -steal body - -fetch_fail? - -ok? + +vbf_stp_condfetch + +vbf_stp_condfetch: + +copy obj attr + +steal body + +fetch_fail? + +ok? -v_b_r:fetch_304:s->vbf_stp_condfetch - - + +v_b_r:s->vbf_stp_condfetch + + -vbf_stp_fetch - -vbf_stp_fetch: - -setup VFPs - -get object - -error? - -body? + +vbf_stp_fetch + +vbf_stp_fetch: + +setup VFPs + +get object + +error? + +body? -v_b_r:non_304:s->vbf_stp_fetch - - - - -FETCH_DONE - -FETCH_DONE - - -v_b_e:deliver->FETCH_DONE - - -"backend synth" - - -FETCH_FAIL - -FETCH_FAIL - - -v_b_e:max:s->FETCH_FAIL - - - - -v_b_e_retry -RETRY - - -v_b_e:retry->v_b_e_retry - - + +v_b_r:s->vbf_stp_fetch + + -vbf_stp_fetchend - -vbf_stp_fetchend: - -finalize object and director - -done + +vbf_stp_fetchend + +vbf_stp_fetchend: + +finalize object and director + +done -vbf_stp_condfetch:ok:s->vbf_stp_fetchend - - + +vbf_stp_condfetch:s->vbf_stp_fetchend + + -vbf_stp_fetchbody - -vbf_stp_fetchbody: - -get storage - -read body, run VFPs - -fetch_fail? - -error? - -ok? + +vbf_stp_fetchbody + +vbf_stp_fetchbody: + +get storage + +read body, run VFPs + +fetch_fail? + +error? + +ok? -vbf_stp_fetch:body:s->vbf_stp_fetchbody - - + +vbf_stp_fetch:s->vbf_stp_fetchbody + + -vbf_stp_fetch:body:s->vbf_stp_fetchend - - + +vbf_stp_fetch:s->vbf_stp_fetchend + + -vbf_stp_fetchbody:ok:s->vbf_stp_fetchend - - + +vbf_stp_fetchbody:s->vbf_stp_fetchend + + -vbf_stp_fetchend:done:s->FETCH_DONE - - - - -error -error - - -error->FETCH_FAIL - - + +vbf_stp_fetchend:s->FETCH_DONE + + + + + +fail +fail + + + +fail->FETCH_FAIL + + -abandon -abandon + +abandon +abandon -abandon->FETCH_FAIL - - + +abandon->FETCH_FAIL + + diff --git a/doc/sphinx/users-guide/vcl-built-in-subs.rst b/doc/sphinx/users-guide/vcl-built-in-subs.rst index 690f337ef..76868dce4 100644 --- a/doc/sphinx/users-guide/vcl-built-in-subs.rst +++ b/doc/sphinx/users-guide/vcl-built-in-subs.rst @@ -345,7 +345,12 @@ The `vcl_backend_fetch` subroutine may terminate with calling background fetch, control is passed to :ref:`vcl_synth` on the client side with ``resp.status`` preset to 503. -Before calling `vcl_backend_fetch`, varnish core prepares the `bereq` + ``error(status code, reason)`` + Transition to :ref:`vcl_backend_error` with ``beresp.status`` and + ``beresp.reason`` being preset to the arguments of ``error()`` if + arguments are provided. + +Before calling `vcl_backend_fetch`, Varnish core prepares the `bereq` backend request as follows: * Unless the request is a `pass`, @@ -408,6 +413,11 @@ The `vcl_backend_response` subroutine may terminate with calling lookups hitting this object will be turned into passed transactions, as if ``vcl_recv`` had returned ``pass``. + ``error(status code, reason)`` + Transition to :ref:`vcl_backend_error` with ``beresp.status`` and + ``beresp.reason`` being preset to the arguments of ``error()`` if + arguments are provided. + 304 handling ~~~~~~~~~~~~ diff --git a/lib/libvcc/generate.py b/lib/libvcc/generate.py index 919e1569a..0118d7956 100755 --- a/lib/libvcc/generate.py +++ b/lib/libvcc/generate.py @@ -131,11 +131,11 @@ returns = ( ('backend_fetch', "B", - ('fail', 'fetch', 'abandon') + ('fail', 'fetch', 'abandon', 'error') ), ('backend_response', "B", - ('fail', 'deliver', 'retry', 'abandon', 'pass') + ('fail', 'deliver', 'retry', 'abandon', 'pass', 'error') ), ('backend_error', "B", diff --git a/lib/libvcc/vcc_action.c b/lib/libvcc/vcc_action.c index ded906870..210101feb 100644 --- a/lib/libvcc/vcc_action.c +++ b/lib/libvcc/vcc_action.c @@ -331,7 +331,7 @@ vcc_act_return(struct vcc *tl, struct token *t, struct symbol *sym) vcc_ProcAction(tl->curproc, hand, tl->t); vcc_NextToken(tl); if (tl->t->tok == '(') { - if (hand == VCL_RET_SYNTH) + if (hand == VCL_RET_SYNTH || hand == VCL_RET_ERROR) vcc_act_return_synth(tl); else if (hand == VCL_RET_VCL) vcc_act_return_vcl(tl); From reza at naghibi.com Thu Dec 19 21:11:07 2019 From: reza at naghibi.com (Reza Naghibi) Date: Thu, 19 Dec 2019 21:11:07 +0000 (UTC) Subject: [6.0] 27886a38a move backend error state reason and code struct field to end of struct Message-ID: <20191219211107.4DACCA67EA@lists.varnish-cache.org> commit 27886a38a483fea584b5f6e4793ce6e3082d200b Author: Andrew Wiik Date: Mon Aug 12 13:05:07 2019 -0400 move backend error state reason and code struct field to end of struct diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 42b2272fc..6dbefa84e 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -407,9 +407,6 @@ struct busyobj { struct http_conn *htc; - uint16_t err_code; - const char *err_reason; - struct pool_task fetch_task; #define BO_FLAG(l, r, w, d) unsigned l:1; @@ -437,6 +434,9 @@ struct busyobj { uint8_t digest[DIGEST_LEN]; struct vrt_privs privs[1]; + + uint16_t err_code; + const char *err_reason; }; From gquintard at users.noreply.github.com Fri Dec 20 11:10:08 2019 From: gquintard at users.noreply.github.com (guillaume quintard) Date: Fri, 20 Dec 2019 11:10:08 +0000 (UTC) Subject: [6.0] 183e032ea add if-range logic Message-ID: <20191220111008.76EDE4E11@lists.varnish-cache.org> commit 183e032ea6f4179ac88e3f4a1a28a8e2a60d37ae Author: Guillaume Quintard Date: Sat Nov 2 18:06:16 2019 -0700 add if-range logic diff --git a/bin/varnishd/cache/cache_range.c b/bin/varnishd/cache/cache_range.c index 37e4d84e7..63ce87af3 100644 --- a/bin/varnishd/cache/cache_range.c +++ b/bin/varnishd/cache/cache_range.c @@ -33,6 +33,7 @@ #include "cache_filter.h" #include "vct.h" +#include /*--------------------------------------------------------------------*/ @@ -180,6 +181,58 @@ vrg_dorange(struct req *req, const char *r, void **priv) return (NULL); } +/* + * return 1 if range should be observed, based on if-range value + * if-range can either be a date or an ETag [RFC7233 3.2 p8] + */ +static int +vrg_ifrange(struct req *req) +{ + const char *p, *e; + vtim_real ims, lm, d; + + if (!http_GetHdr(req->http, H_If_Range, &p)) // rfc7233,l,455,456 + return (1); + + /* strong validation needed */ + if (p[0] == 'W' && p[1] == '/') // rfc7233,l,500,501 + return (0); + + /* ETag */ + if (p[0] == '"') { // rfc7233,l,512,514 + if (!http_GetHdr(req->resp, H_ETag, &e)) + return (0); + if ((e[0] == 'W' && e[1] == '/')) // rfc7232,l,547,548 + return (0); + return (strcmp(p, e) == 0); // rfc7232,l,548,548 + } + + /* assume date, strong check [RFC7232 2.2.2 p7] */ + if (!(ims = VTIM_parse(p))) // rfc7233,l,502,512 + return (0); + + /* the response needs a Date */ + // rfc7232 fc7232,l,439,440 + if (!http_GetHdr(req->resp, H_Date, &p) || !(d = VTIM_parse(p))) + return (0); + + /* grab the Last Modified value */ + if (!http_GetHdr(req->resp, H_Last_Modified, &p)) + return (0); + + lm = VTIM_parse(p); + if (!lm) + return (0); + + /* Last Modified must be 60 seconds older than Date */ + if (lm > d + 60) // rfc7232,l,442,443 + return (0); + + if (lm != ims) // rfc7233,l,455,456 + return (0); + return (1); +} + static int v_matchproto_(vdp_init_f) vrg_range_init(struct req *req, void **priv) { @@ -187,6 +240,8 @@ vrg_range_init(struct req *req, void **priv) const char *err; assert(http_GetHdr(req->http, H_Range, &r)); + if (!vrg_ifrange(req)) // rfc7233,l,455,456 + return (1); err = vrg_dorange(req, r, priv); if (err == NULL) return (*priv == NULL ? 1 : 0); diff --git a/bin/varnishtest/tests/c00100.vtc b/bin/varnishtest/tests/c00100.vtc new file mode 100644 index 000000000..ebf690430 --- /dev/null +++ b/bin/varnishtest/tests/c00100.vtc @@ -0,0 +1,88 @@ +varnishtest "if-range header" + +server s1 { + rxreq + txresp -hdr {etag: "foo"} -hdr "last-modified: Wed, 21 Oct 2015 07:28:00 GMT" -bodylen 16 + + rxreq + txresp -bodylen 16 +} -start + +varnish v1 -vcl+backend {} -start + +client c1 { + txreq + rxresp + expect resp.status == 200 + expect resp.bodylen == 16 + + # if-range, but no range + txreq -hdr {if-range: "foo"} + rxresp + expect resp.status == 200 + expect resp.bodylen == 16 + + # non-matching etag if-range + txreq -hdr {if-range: "fooled"} -hdr "range: bytes=5-9" + rxresp + expect resp.status == 200 + expect resp.bodylen == 16 + + # matching etag if-range + txreq -hdr {if-range: "foo"} -hdr "range: bytes=5-9" + rxresp + expect resp.status == 206 + expect resp.bodylen == 5 + + # non-matching date if-range (past) + txreq -hdr "if-range: Wed, 21 Oct 2015 07:18:00 GMT" -hdr "range: bytes=5-9" + rxresp + expect resp.status == 200 + expect resp.bodylen == 16 + + # non-matching date if-range (future) + txreq -hdr "if-range: Wed, 21 Oct 2015 07:38:00 GMT" -hdr "range: bytes=5-9" + rxresp + expect resp.status == 200 + expect resp.bodylen == 16 + + # matching etag if-range + txreq -hdr "if-range: Wed, 21 Oct 2015 07:28:00 GMT" -hdr "range: bytes=5-9" + rxresp + expect resp.status == 206 + expect resp.bodylen == 5 +}-run + +varnish v1 -cliok "ban obj.status != x" + +# no etag/LM header +client c1 { + txreq + rxresp + expect resp.status == 200 + expect resp.bodylen == 16 + + # non-matching etag if-range + txreq -hdr {if-range: "fooled"} -hdr "range: bytes=5-9" + rxresp + expect resp.status == 200 + expect resp.bodylen == 16 + + # matching etag if-range + txreq -hdr {if-range: "foo"} -hdr "range: bytes=5-9" + rxresp + expect resp.status == 200 + expect resp.bodylen == 16 + + # non-matching date if-range (past) + txreq -hdr "if-range: Wed, 21 Oct 2015 07:18:00 GMT" -hdr "range: bytes=5-9" + rxresp + expect resp.status == 200 + expect resp.bodylen == 16 + + # non-matching date if-range (future) + txreq -hdr "if-range: Wed, 21 Oct 2015 07:38:00 GMT" -hdr "range: bytes=5-9" + rxresp + expect resp.status == 200 + expect resp.bodylen == 16 +} -run From dridi.boukelmoune at gmail.com Fri Dec 20 11:21:07 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 20 Dec 2019 11:21:07 +0000 (UTC) Subject: [master] 98dc20f46 Conditional fetch wait for streaming stale object Message-ID: <20191220112107.0F083537D@lists.varnish-cache.org> commit 98dc20f465cb38103a2c78c70a32c5eb162de220 Author: Martin Blix Grydeland Date: Wed Oct 9 14:01:15 2019 +0200 Conditional fetch wait for streaming stale object Wait for the stale object to become fully fetched, so that we can catch fetch errors, before we unbusy the new object. This serves two purposes. First it helps with request coalescing, and stops long chains of IMS-updated short-TTL objects all streaming from a single slow body fetch. Second it makes sure that all the object attributes are complete when we copy them (this would be an issue for ie OA_GZIPBITS). This patch OBE's r01646.vtc, and slightly patches r01648.vtc to expect a 503 instead of a 200 and a broken connection on the failing client. Fixes: #3089 diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index c80f1addf..3a1b91563 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -683,9 +683,37 @@ vbf_objiterator(void *priv, unsigned flush, const void *ptr, ssize_t len) static enum fetch_step vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo) { + struct boc *stale_boc; + enum boc_state_e stale_state; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + CHECK_OBJ_NOTNULL(bo->fetch_objcore, OBJCORE_MAGIC); + CHECK_OBJ_NOTNULL(bo->stale_oc, OBJCORE_MAGIC); + + stale_boc = HSH_RefBoc(bo->stale_oc); + CHECK_OBJ_ORNULL(stale_boc, BOC_MAGIC); + if (stale_boc) { + /* Wait for the stale object to become fully fetched, so + * that we can catch fetch errors, before we unbusy the + * new object. This serves two purposes. First it helps + * with request coalesching, and stops long chains of + * IMS-updated short-TTL objects all streaming from a + * single slow body fetch. Second it makes sure that all + * the object attributes are complete when we copy them + * (this would be an issue for ie OA_GZIPBITS). */ + ObjWaitState(bo->stale_oc, BOS_FINISHED); + stale_state = stale_boc->state; + HSH_DerefBoc(bo->wrk, bo->stale_oc); + stale_boc = NULL; + if (stale_state != BOS_FINISHED) { + (void)VFP_Error(bo->vfc, "Template object failed"); + vbf_cleanup(bo); + wrk->stats->fetch_failed++; + return (F_STP_FAIL); + } + } + AZ(bo->stale_oc->flags & OC_F_FAILED); AZ(vbf_beresp2obj(bo)); @@ -707,8 +735,6 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo) if (ObjIterate(wrk, bo->stale_oc, bo, vbf_objiterator, 0)) (void)VFP_Error(bo->vfc, "Template object failed"); - if (bo->stale_oc->flags & OC_F_FAILED) - (void)VFP_Error(bo->vfc, "Template object failed"); if (bo->vfc->failed) { vbf_cleanup(bo); wrk->stats->fetch_failed++; diff --git a/bin/varnishtest/tests/r01646.vtc b/bin/varnishtest/tests/r01646.vtc deleted file mode 100644 index 10b640ea5..000000000 --- a/bin/varnishtest/tests/r01646.vtc +++ /dev/null @@ -1,57 +0,0 @@ -varnishtest "cond/stream race ?" - -barrier b1 cond 3 -barrier b2 cond 2 - -server s1 { - rxreq - txresp -nolen -hdr "Transfer-Encoding: chunked" -hdr "Etag: foo" - chunkedlen 32 - barrier b1 sync - chunkedlen 32 - barrier b2 sync - chunkedlen 32 - chunkedlen 0 -} -start - -server s2 { - rxreq - expect req.http.if-none-match == "foo" - txresp -status 304 -} -start - -varnish v1 -vcl+backend { - sub vcl_backend_fetch { - if (bereq.http.foo == "s2") { - set bereq.backend = s2; - } - } - sub vcl_backend_response { - set beresp.ttl = 1s; - set beresp.grace = 0s; - set beresp.keep = 30s; - } -} -start - -varnish v1 -cliok "param.set debug +syncvsl" - -client c1 { - txreq - rxresphdrs - barrier b1 sync - rxrespbody - expect resp.bodylen == 96 -} -start - -client c2 { - barrier b1 sync - delay 2 - txreq -hdr "foo: s2" - rxresphdrs - barrier b2 sync - rxrespbody - expect resp.bodylen == 96 -} -start - -client c1 -wait -client c2 -wait diff --git a/bin/varnishtest/tests/r01648.vtc b/bin/varnishtest/tests/r01648.vtc index 2780db864..7e565af00 100644 --- a/bin/varnishtest/tests/r01648.vtc +++ b/bin/varnishtest/tests/r01648.vtc @@ -62,8 +62,7 @@ client c2 { txreq -hdr "Client: c2" barrier b1 sync rxresphdrs - expect resp.status == 200 - expect resp.http.transfer-encoding == "chunked" + expect resp.status == 503 } -run delay 1 @@ -76,4 +75,5 @@ client c3 { expect resp.body == "abcdef" } -run +client c1 -wait varnish v1 -expect fetch_failed == 2 diff --git a/bin/varnishtest/tests/r03089.vtc b/bin/varnishtest/tests/r03089.vtc new file mode 100644 index 000000000..15d912e0b --- /dev/null +++ b/bin/varnishtest/tests/r03089.vtc @@ -0,0 +1,69 @@ +varnishtest "r03089 - Assert error corrupt OA_GZIPBITS" + +barrier b1 cond 2 + +server s1 { + rxreq + expect req.url == /included + expect req.http.accept-encoding == "gzip" + txresp -nolen -hdr "Content-Length: 49" -hdr "Content-Encoding: gzip" -hdr {Etag: "asdf"} + barrier b1 sync + delay 1 + sendhex "1f 8b 08 08 ef 00 22 59 02 03 5f 00 0b 2e cd 53" + sendhex "f0 4d ac 54 30 32 04 22 2b 03 13 2b 13 73 85 d0" + sendhex "10 67 05 23 03 43 73 2e 00 cf 9b db c0 1d 00 00" + sendhex "00" +} -start + +server s2 { + rxreq + expect req.url == /included + expect req.http.If-None-Match == {"asdf"} + barrier b1 sync + txresp -status 304 -nolen -hdr "Etag: asdf" +} -start + +server s3 { + rxreq + expect req.url == / + txresp -gzipbody {} +} -start + +varnish v1 -arg "-p debug=+syncvsl" -vcl+backend { + sub vcl_deliver { + } + sub vcl_backend_fetch { + if (bereq.url == "/") { + set bereq.backend = s3; + } else if (bereq.http.backend == "s1") { + set bereq.backend = s1; + } else { + set bereq.backend = s2; + } + } + sub vcl_backend_response { + if (bereq.url == "/") { + set beresp.do_esi = true; + } else { + set beresp.ttl = 0.1s; + set beresp.grace = 0s; + set beresp.keep = 1m; + } + } +} -start + +client c1 { + txreq -url / -hdr "backend: s1" -hdr "Accept-encoding: gzip" + rxresp +} -start + +delay 1 + +client c2 { + txreq -url / -hdr "backend: s2" -hdr "Accept-encoding: gzip" + rxresp +} -start + +client c1 -wait +client c2 -wait + From dridi.boukelmoune at gmail.com Fri Dec 20 11:21:07 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 20 Dec 2019 11:21:07 +0000 (UTC) Subject: [master] 4c5aba28f Add a SLT_Notice VSL tag Message-ID: <20191220112107.29DCA5380@lists.varnish-cache.org> commit 4c5aba28fa9d8960384f32c5ebc273fc5693a67b Author: Martin Blix Grydeland Date: Mon Nov 25 11:41:26 2019 +0100 Add a SLT_Notice VSL tag This VSL tag will be used for informational messages related to exceptional handling of requests. diff --git a/doc/sphinx/reference/vsl.rst b/doc/sphinx/reference/vsl.rst index b314fd4d0..7ea7860e3 100644 --- a/doc/sphinx/reference/vsl.rst +++ b/doc/sphinx/reference/vsl.rst @@ -102,6 +102,17 @@ Error Backend request failed to vcl_backend_error. +NOTICE MESSAGES +=============== + +Notice messages contain informational messages about the handling of a +request. These can be exceptional circumstances encountered that causes +deviation from the normal handling. The messages are prefixed with [core] +for core Varnish generated messages, or with [] for VMOD +generated messages. The [core] messages are described in detail below, see +the individual VMOD documentation for messages from VMODs. + + HISTORY ======= diff --git a/include/tbl/vsl_tags.h b/include/tbl/vsl_tags.h index ff1d979dc..7ff491b07 100644 --- a/include/tbl/vsl_tags.h +++ b/include/tbl/vsl_tags.h @@ -676,6 +676,13 @@ SLTM(VCL_use, 0, "VCL in use", "\n" ) +SLTM(Notice, 0, "Informational messages about request handling", + "Informational log messages on events occured during request" + " handling. Lines are prefixed with either [core] or []." + " See the NOTICE MESSAGES section below or the individual VMOD manual" + " pages for detailed information of notice messages.\n" +) + #undef NOSUP_NOTICE #undef NODEF_NOTICE #undef SLTM From dridi.boukelmoune at gmail.com Fri Dec 20 11:21:07 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 20 Dec 2019 11:21:07 +0000 (UTC) Subject: [master] 9bf8e871f Log using SLT_Notice on condfetch streaming delay Message-ID: <20191220112107.484975384@lists.varnish-cache.org> commit 9bf8e871ff4232e6fce6578d53e3aac0f8ffd3c4 Author: Martin Blix Grydeland Date: Mon Nov 25 12:01:42 2019 +0100 Log using SLT_Notice on condfetch streaming delay Log a notice message when delaying a conditional fetch and the stale template object is still streaming. diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 3a1b91563..4eaa36a10 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -702,6 +702,8 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo) * single slow body fetch. Second it makes sure that all * the object attributes are complete when we copy them * (this would be an issue for ie OA_GZIPBITS). */ + VSLb(bo->vsl, SLT_Notice, + "[core] Conditional fetch wait for streaming object"); ObjWaitState(bo->stale_oc, BOS_FINISHED); stale_state = stale_boc->state; HSH_DerefBoc(bo->wrk, bo->stale_oc); diff --git a/doc/sphinx/reference/vsl.rst b/doc/sphinx/reference/vsl.rst index 7ea7860e3..71a3110b4 100644 --- a/doc/sphinx/reference/vsl.rst +++ b/doc/sphinx/reference/vsl.rst @@ -112,6 +112,15 @@ for core Varnish generated messages, or with [] for VMOD generated messages. The [core] messages are described in detail below, see the individual VMOD documentation for messages from VMODs. +[core] Conditional fetch wait for streaming object + The backend answered 304 Not Modified on a conditional fetch using + an object that has not yet been fully fetched as the stale + template object. This can only happen when the TTL of the object + is less than the time it takes to fetch it. The fetch is halted + until the stale object is fully fetched, upon which the new object + is created as normal. While waiting, any grace time on the stale + object will be in effect. + HISTORY ======= From guillaume at varnish-software.com Fri Dec 20 14:51:06 2019 From: guillaume at varnish-software.com (Guillaume Quintard) Date: Fri, 20 Dec 2019 14:51:06 +0000 (UTC) Subject: [master] cf7259b50 [cci] switch to py3-sphinx for alpine Message-ID: <20191220145106.18AB66230F@lists.varnish-cache.org> commit cf7259b5019ef62f74937c7decce408762c783eb Author: Guillaume Quintard Date: Fri Dec 20 14:26:31 2019 +0000 [cci] switch to py3-sphinx for alpine diff --git a/.circleci/config.yml b/.circleci/config.yml index d9ebaed2f..c6974912e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -71,7 +71,7 @@ commands: linux-headers \ pcre-dev \ py-docutils \ - py-sphinx \ + py3-sphinx \ tar \ sudo jobs: From guillaume at varnish-software.com Fri Dec 20 14:51:06 2019 From: guillaume at varnish-software.com (Guillaume Quintard) Date: Fri, 20 Dec 2019 14:51:06 +0000 (UTC) Subject: [master] 513ae61b0 [cci] don't worry about the alpine version Message-ID: <20191220145106.3A7D062312@lists.varnish-cache.org> commit 513ae61b06a21266707947eec0fd075a2b04396a Author: Guillaume Quintard Date: Fri Dec 20 14:49:29 2019 +0000 [cci] don't worry about the alpine version diff --git a/.circleci/config.yml b/.circleci/config.yml index c6974912e..9efb08e34 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -446,7 +446,7 @@ workflows: requires: - dist - distcheck: - name: distcheck_alpine_3.10 + name: distcheck_alpine dist: alpine release: "latest" #extra_conf: --without-jemalloc From dridi.boukelmoune at gmail.com Fri Dec 20 18:10:06 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 20 Dec 2019 18:10:06 +0000 (UTC) Subject: [master] 6a483b19f Tweak SLT_Notice to better fit the VSL Message-ID: <20191220181006.BCECC6ED67@lists.varnish-cache.org> commit 6a483b19f143ad472a4e82d2a76919f167f92b20 Author: Dridi Boukelmoune Date: Fri Dec 20 18:50:35 2019 +0100 Tweak SLT_Notice to better fit the VSL Martin entrusted me with those changes after I pointed out that [core] was not a great prefix considering that VSL records already have the notion of a prefix. I opted for: - an actionable "vsl:" prefix for core notice messages - a prefix naming scheme mapping to manual pages As a result I changed the documentation a bit. Better diff with --word-diff --ignore-all-space options. diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 4eaa36a10..64e5ebf77 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -703,7 +703,7 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo) * the object attributes are complete when we copy them * (this would be an issue for ie OA_GZIPBITS). */ VSLb(bo->vsl, SLT_Notice, - "[core] Conditional fetch wait for streaming object"); + "vsl: Conditional fetch wait for streaming object"); ObjWaitState(bo->stale_oc, BOS_FINISHED); stale_state = stale_boc->state; HSH_DerefBoc(bo->wrk, bo->stale_oc); diff --git a/doc/sphinx/reference/vsl.rst b/doc/sphinx/reference/vsl.rst index 71a3110b4..583bd07b9 100644 --- a/doc/sphinx/reference/vsl.rst +++ b/doc/sphinx/reference/vsl.rst @@ -107,19 +107,23 @@ NOTICE MESSAGES Notice messages contain informational messages about the handling of a request. These can be exceptional circumstances encountered that causes -deviation from the normal handling. The messages are prefixed with [core] -for core Varnish generated messages, or with [] for VMOD -generated messages. The [core] messages are described in detail below, see -the individual VMOD documentation for messages from VMODs. - -[core] Conditional fetch wait for streaming object - The backend answered 304 Not Modified on a conditional fetch using - an object that has not yet been fully fetched as the stale - template object. This can only happen when the TTL of the object - is less than the time it takes to fetch it. The fetch is halted - until the stale object is fully fetched, upon which the new object - is created as normal. While waiting, any grace time on the stale - object will be in effect. +deviation from the normal handling. The messages are prefixed with ``vsl`` +for core Varnish generated messages, and VMOD authors are encouraged to +use ``vmod_`` for their own notice messages. This matches the name +of the manual page where detailed descriptions of notice messages are +expected. + +The core messages are described below. + +Conditional fetch wait for streaming object +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The backend answered 304 Not Modified on a conditional fetch using an object +that has not yet been fully fetched as the stale template object. This can +only happen when the TTL of the object is less than the time it takes to fetch +it. The fetch is halted until the stale object is fully fetched, upon which +the new object is created as normal. While waiting, any grace time on the +stale object will be in effect. HISTORY diff --git a/include/tbl/vsl_tags.h b/include/tbl/vsl_tags.h index 7ff491b07..281416d63 100644 --- a/include/tbl/vsl_tags.h +++ b/include/tbl/vsl_tags.h @@ -678,9 +678,17 @@ SLTM(VCL_use, 0, "VCL in use", SLTM(Notice, 0, "Informational messages about request handling", "Informational log messages on events occured during request" - " handling. Lines are prefixed with either [core] or []." - " See the NOTICE MESSAGES section below or the individual VMOD manual" + " handling.\n\n" + "The format is::\n\n" + "\t%s: %s\n" + "\t| |\n" + "\t| +- Short description of the notice message\n" + "\t+----- Manual page containing the detailed description\n" + "\n" + "See the NOTICE MESSAGES section below or the individual VMOD manual" " pages for detailed information of notice messages.\n" + "\n" + ) #undef NOSUP_NOTICE From nils.goroll at uplex.de Sat Dec 21 10:05:13 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Sat, 21 Dec 2019 11:05:13 +0100 Subject: [master] 6a483b19f Tweak SLT_Notice to better fit the VSL In-Reply-To: <20191220181006.BCECC6ED67@lists.varnish-cache.org> References: <20191220181006.BCECC6ED67@lists.varnish-cache.org> Message-ID: <5c44b68e-ed7b-9422-6bb1-12e6ceecbb27@uplex.de> On 20/12/2019 19:10, Dridi Boukelmoune wrote: > - an actionable "vsl:" prefix for core notice messages ftr, I would have thought that "vsl" was not the best choice, but using the name of the man page where the notice is documented is cool. So +1 -- ** * * UPLEX - Nils Goroll Systemoptimierung Scheffelstra?e 32 22301 Hamburg tel +49 40 28805731 mob +49 170 2723133 fax +49 40 42949753 xmpp://slink at jabber.int.uplex.de/ http://uplex.de/ -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 488 bytes Desc: OpenPGP digital signature URL: From nils.goroll at uplex.de Sat Dec 21 10:41:08 2019 From: nils.goroll at uplex.de (Nils Goroll) Date: Sat, 21 Dec 2019 10:41:08 +0000 (UTC) Subject: [master] 7c4cdd485 demo and test use of the stringified session attributes Message-ID: <20191221104108.2C591B130D@lists.varnish-cache.org> commit 7c4cdd48563095fb70ff5db642288ae13a06f2ce Author: Nils Goroll Date: Sat Dec 21 11:30:38 2019 +0100 demo and test use of the stringified session attributes While, in most of the code, we now use SA_*_ADDR and format the address/port when needed, for the client ip and port, there still exist formatted strings as session attributes. I recently came across this in a different context and wondered if we should remove these string session attributes, but as we use them multiple times for each request, that would only imply additional overhead for repeated string formatting. So I think we should keep them for now, but we might want to consider to add to struct suckaddr optional formatted strings to avoid the duplicated formatting which already happens. This commit adds a regression test. Motivated by #3173 diff --git a/bin/varnishtest/tests/b00070.vtc b/bin/varnishtest/tests/b00070.vtc new file mode 100644 index 000000000..df7d3d5f7 --- /dev/null +++ b/bin/varnishtest/tests/b00070.vtc @@ -0,0 +1,23 @@ +varnishtest "client.ip vs. string session attrs" + +varnish v1 -vcl { + import debug; + import std; + backend dummy None; + sub vcl_recv { + return (synth(200)); + } + sub vcl_synth { + set resp.http.ci = client.ip; + set resp.http.s-ci = debug.client_ip(); + set resp.http.pi = std.port(client.ip); + set resp.http.s-pi = debug.client_port(); + } +} -start + +client c1 { + txreq + rxresp + expect resp.http.ci == resp.http.s-ci + expect resp.http.pi == resp.http.s-pi +} -run diff --git a/lib/libvmod_debug/vmod.vcc b/lib/libvmod_debug/vmod.vcc index 72b24b3ca..c58397fcb 100644 --- a/lib/libvmod_debug/vmod.vcc +++ b/lib/libvmod_debug/vmod.vcc @@ -274,3 +274,11 @@ $Object director() $Method BACKEND .fail() Return a backend which fails in director context + +$Function STRING client_ip() + +Get the stringified client ip from the session attr + +$Function STRING client_port() + +Get the stringified client port from the session attr diff --git a/lib/libvmod_debug/vmod_debug.c b/lib/libvmod_debug/vmod_debug.c index 1a547e172..5b85a6fc8 100644 --- a/lib/libvmod_debug/vmod_debug.c +++ b/lib/libvmod_debug/vmod_debug.c @@ -1011,3 +1011,19 @@ vmod_debug_director_resolve(VRT_CTX, VCL_BACKEND dir) VRT_fail(ctx, "fail"); return (NULL); } + +VCL_STRING v_matchproto_(td_xyzzy_debug_client_ip) +xyzzy_client_ip(VRT_CTX) +{ + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + + return (SES_Get_String_Attr(ctx->sp, SA_CLIENT_IP)); +} + +VCL_STRING v_matchproto_(td_xyzzy_debug_client_port) +xyzzy_client_port(VRT_CTX) +{ + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + + return (SES_Get_String_Attr(ctx->sp, SA_CLIENT_PORT)); +} From dridi.boukelmoune at gmail.com Mon Dec 23 09:14:06 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 23 Dec 2019 09:14:06 +0000 (UTC) Subject: [master] 60a9c5e68 Whitespace OCD Message-ID: <20191223091406.2A9AE106D79@lists.varnish-cache.org> commit 60a9c5e68efad9c07790d43093620681c5834fb0 Author: Dridi Boukelmoune Date: Mon Dec 23 10:13:34 2019 +0100 Whitespace OCD diff --git a/include/tbl/vsl_tags.h b/include/tbl/vsl_tags.h index 281416d63..cf3a20e2c 100644 --- a/include/tbl/vsl_tags.h +++ b/include/tbl/vsl_tags.h @@ -688,7 +688,6 @@ SLTM(Notice, 0, "Informational messages about request handling", "See the NOTICE MESSAGES section below or the individual VMOD manual" " pages for detailed information of notice messages.\n" "\n" - ) #undef NOSUP_NOTICE From dridi.boukelmoune at gmail.com Mon Dec 23 09:49:06 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 23 Dec 2019 09:49:06 +0000 (UTC) Subject: [master] cca228f5a Refer to VCL subs as subroutines in error messages Message-ID: <20191223094906.BBA671079D0@lists.varnish-cache.org> commit cca228f5a84791340e61eccdd0319f58908a65aa Author: Dridi Boukelmoune Date: Mon Dec 23 10:42:35 2019 +0100 Refer to VCL subs as subroutines in error messages Refs 17457b480a25 diff --git a/bin/varnishtest/tests/v00016.vtc b/bin/varnishtest/tests/v00016.vtc index 15e6fb511..10c80fbf3 100644 --- a/bin/varnishtest/tests/v00016.vtc +++ b/bin/varnishtest/tests/v00016.vtc @@ -52,14 +52,14 @@ varnish v1 -errvcl {Symbol not found: 'foo.bar'} { } } -varnish v1 -errvcl {Cannot be set in method 'vcl_pipe'} { +varnish v1 -errvcl {Cannot be set in subroutine 'vcl_pipe'} { backend b { .host = "127.0.0.1"; } sub vcl_pipe { set bereq.first_byte_timeout = 10s; } } -varnish v1 -errvcl {Cannot be set in method 'vcl_pipe'.} { +varnish v1 -errvcl {Cannot be set in subroutine 'vcl_pipe'.} { backend b { .host = "127.0.0.1"; } sub vcl_pipe { set bereq.between_bytes_timeout = 10s; diff --git a/bin/varnishtest/tests/v00018.vtc b/bin/varnishtest/tests/v00018.vtc index cd5fc41db..572fde61e 100644 --- a/bin/varnishtest/tests/v00018.vtc +++ b/bin/varnishtest/tests/v00018.vtc @@ -114,7 +114,7 @@ varnish v1 -errvcl {Expected return action name.} { } # issue #936 -varnish v1 -errvcl {Not a valid action in method 'vcl_recv'} { +varnish v1 -errvcl {Not a valid action in subroutine 'vcl_recv'} { backend foo { .host = "127.0.0.1"; } sub vcl_recv { synthetic("XXX"); diff --git a/bin/varnishtest/tests/v00020.vtc b/bin/varnishtest/tests/v00020.vtc index b59fb5350..4c2a526ae 100644 --- a/bin/varnishtest/tests/v00020.vtc +++ b/bin/varnishtest/tests/v00020.vtc @@ -200,7 +200,7 @@ varnish v1 -errvcl {IP + IP not possible.} { } } -varnish v1 -errvcl {Name of function, 'foo.bar', contains illegal character '.'} { +varnish v1 -errvcl {Name of subroutine, 'foo.bar', contains illegal character '.'} { sub foo.bar { } sub vcl_recv { @@ -223,7 +223,7 @@ varnish v1 -errvcl {Function returns VOID} { } } -varnish v1 -errvcl {Not available in method 'vcl_recv'.} { +varnish v1 -errvcl {Not available in subroutine 'vcl_recv'.} { import blob; backend b { .host = "127.0.0.1"; } sub vcl_recv { @@ -231,7 +231,7 @@ varnish v1 -errvcl {Not available in method 'vcl_recv'.} { } } -varnish v1 -errvcl {Not available in method 'vcl_hash'.} { +varnish v1 -errvcl {Not available in subroutine 'vcl_hash'.} { import blob; backend b { .host = "127.0.0.1"; } sub vcl_hash { @@ -239,7 +239,7 @@ varnish v1 -errvcl {Not available in method 'vcl_hash'.} { } } -varnish v1 -errvcl {Not available in method 'vcl_recv'.} { +varnish v1 -errvcl {Not available in subroutine 'vcl_recv'.} { backend b { .host = "127.0.0.1"; } sub vcl_recv { set req.http.foo = 100 + beresp.status; @@ -251,7 +251,7 @@ varnish v1 -errvcl { sub foo { set req.http.foo = 100 + beresp.status; } -------------------------------------------######---------- -Not available from method 'vcl_recv'. +Not available from subroutine 'vcl_recv'. ...in subroutine "foo" ('' Line 4 Pos 13) @@ -274,7 +274,7 @@ varnish v1 -errvcl { sub foo { set req.http.foo = 100 + beresp.status; } -------------------------------------------######---------- -Not available from method 'vcl_recv'. +Not available from subroutine 'vcl_recv'. ...in subroutine "foo" ('' Line 4 Pos 13) diff --git a/bin/varnishtest/tests/v00021.vtc b/bin/varnishtest/tests/v00021.vtc index 0ae6dc5a3..dd3392ee8 100644 --- a/bin/varnishtest/tests/v00021.vtc +++ b/bin/varnishtest/tests/v00021.vtc @@ -26,7 +26,7 @@ varnish v1 -errvcl "Symbol not found" { } varnish v1 -errvcl { -Function recurses on +Subroutine recurses on ('' Line 5 Pos 13) sub foo { call foo; } ------------###-------------- @@ -50,7 +50,7 @@ Function recurses on } varnish v1 -errvcl { -Function recurses on +Subroutine recurses on ('' Line 6 Pos 13) sub foo { call bar; } ------------###-------------- diff --git a/bin/varnishtest/tests/v00034.vtc b/bin/varnishtest/tests/v00034.vtc index 44846a3ec..768ef69ce 100644 --- a/bin/varnishtest/tests/v00034.vtc +++ b/bin/varnishtest/tests/v00034.vtc @@ -7,7 +7,7 @@ server s1 { varnish v1 -vcl+backend { } -start -varnish v1 -errvcl {Function 'c1' redefined} { +varnish v1 -errvcl {Subroutine 'c1' redefined} { backend foo { .host = "127.0.0.1"; } sub c1 { } sub c1 { } diff --git a/lib/libvcc/vcc_parse.c b/lib/libvcc/vcc_parse.c index d501ba8e0..978c10057 100644 --- a/lib/libvcc/vcc_parse.c +++ b/lib/libvcc/vcc_parse.c @@ -224,7 +224,7 @@ vcc_ParseFunction(struct vcc *tl) struct proc *p; vcc_NextToken(tl); - vcc_ExpectVid(tl, "function"); + vcc_ExpectVid(tl, "subroutine"); ERRCHK(tl); t = tl->t; @@ -253,7 +253,7 @@ vcc_ParseFunction(struct vcc *tl) p->name = t; VSB_printf(p->cname, "%s", sym->rname); } else if (p->method == NULL) { - VSB_printf(tl->sb, "Function '%s' redefined\n", sym->name); + VSB_printf(tl->sb, "Subroutine '%s' redefined\n", sym->name); vcc_ErrWhere(tl, t); VSB_printf(tl->sb, "Previously defined here:\n"); vcc_ErrWhere(tl, p->name); diff --git a/lib/libvcc/vcc_xref.c b/lib/libvcc/vcc_xref.c index e680c1ba1..f814e12d8 100644 --- a/lib/libvcc/vcc_xref.c +++ b/lib/libvcc/vcc_xref.c @@ -152,7 +152,7 @@ vcc_CheckActionRecurse(struct vcc *tl, struct proc *p, unsigned bitmap) AN(p); if (p->active) { - VSB_cat(tl->sb, "Function recurses on\n"); + VSB_cat(tl->sb, "Subroutine recurses on\n"); vcc_ErrWhere(tl, p->name); return (1); } @@ -174,7 +174,7 @@ vcc_CheckActionRecurse(struct vcc *tl, struct proc *p, unsigned bitmap) p->active = 1; VTAILQ_FOREACH(pc, &p->calls, list) { if (pc->sym->proc == NULL) { - VSB_printf(tl->sb, "Function %s does not exist\n", + VSB_printf(tl->sb, "Subroutine %s does not exist\n", pc->sym->name); vcc_ErrWhere(tl, pc->t); return (1); @@ -205,7 +205,7 @@ vcc_checkaction(struct vcc *tl, const struct symbol *sym) return; if (vcc_CheckActionRecurse(tl, p, p->method->ret_bitmap)) { VSB_printf(tl->sb, - "\n...which is the \"%s\" method\n", p->method->name); + "\n...which is the \"%s\" subroutine\n", p->method->name); VSB_cat(tl->sb, "Legal returns are:"); #define VCL_RET_MAC(l, U, B) \ if (p->method->ret_bitmap & ((1 << VCL_RET_##U))) \ @@ -249,7 +249,7 @@ vcc_CheckUseRecurse(struct vcc *tl, const struct proc *p, pu = vcc_FindIllegalUse(p, m); if (pu != NULL) { vcc_ErrWhere2(tl, pu->t1, pu->t2); - VSB_printf(tl->sb, "%s from method '%s'.\n", + VSB_printf(tl->sb, "%s from subroutine '%s'.\n", pu->use, m->name); VSB_printf(tl->sb, "\n...in subroutine \"%.*s\"\n", PF(pu->fm->name)); @@ -280,14 +280,14 @@ vcc_checkuses(struct vcc *tl, const struct symbol *sym) pu = vcc_FindIllegalUse(p, p->method); if (pu != NULL) { vcc_ErrWhere2(tl, pu->t1, pu->t2); - VSB_printf(tl->sb, "%s in method '%.*s'.", + VSB_printf(tl->sb, "%s in subroutine '%.*s'.", pu->use, PF(p->name)); VSB_cat(tl->sb, "\nAt: "); return; } if (vcc_CheckUseRecurse(tl, p, p->method)) { VSB_printf(tl->sb, - "\n...which is the \"%s\" method\n", p->method->name); + "\n...which is the \"%s\" subroutine\n", p->method->name); return; } } From dridi.boukelmoune at gmail.com Mon Dec 23 09:49:06 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 23 Dec 2019 09:49:06 +0000 (UTC) Subject: [master] 764f1fcad Refer to VCL subs as subroutines in the test suite Message-ID: <20191223094906.D22341079D3@lists.varnish-cache.org> commit 764f1fcade4a2b876d2aea9b5b590d5a094681b1 Author: Dridi Boukelmoune Date: Mon Dec 23 10:42:35 2019 +0100 Refer to VCL subs as subroutines in the test suite Except in r02275.vtc until the code it refers to stops referring to subroutines as methods. While I was searching for relevant tests cases I also broke some long lines. Refs 17457b480a25 diff --git a/bin/varnishtest/tests/r02351.vtc b/bin/varnishtest/tests/r02351.vtc index d2ee19af8..09d12e541 100644 --- a/bin/varnishtest/tests/r02351.vtc +++ b/bin/varnishtest/tests/r02351.vtc @@ -19,21 +19,25 @@ client c1 { # missing :path stream 3 { - txreq -noadd -hdr ":authority" "example.com" -hdr ":method" "GET" -hdr ":scheme" "http" + txreq -noadd -hdr ":authority" "example.com" \ + -hdr ":method" "GET" -hdr ":scheme" "http" rxrst expect rst.err == PROTOCOL_ERROR } -run # missing :method stream 5 { - txreq -noadd -hdr ":authority" "example.com" -hdr ":path" "/foo" -hdr ":scheme" "http" + txreq -noadd -hdr ":authority" "example.com" \ + -hdr ":path" "/foo" -hdr ":scheme" "http" rxrst expect rst.err == PROTOCOL_ERROR } -run # Duplicate :path stream 7 { - txreq -noadd -hdr ":path" "/" -hdr ":path" "/foo" -hdr ":method" "GET" -hdr ":authority" "example.com" -hdr ":scheme" "http" + txreq -noadd -hdr ":path" "/" -hdr ":path" "/foo" \ + -hdr ":method" "GET" -hdr ":authority" "example.com" \ + -hdr ":scheme" "http" rxrst expect rst.err == PROTOCOL_ERROR } -run diff --git a/bin/varnishtest/tests/v00015.vtc b/bin/varnishtest/tests/v00015.vtc index 1838a0838..3cb925de6 100644 --- a/bin/varnishtest/tests/v00015.vtc +++ b/bin/varnishtest/tests/v00015.vtc @@ -1,4 +1,4 @@ -varnishtest "Check function calls with no action return" +varnishtest "Check subroutine calls with no action return" server s1 { rxreq From dridi.boukelmoune at gmail.com Mon Dec 23 09:49:06 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 23 Dec 2019 09:49:06 +0000 (UTC) Subject: [master] d9d22f35d Simplify r02372.vtc Message-ID: <20191223094906.F1DED1079D6@lists.varnish-cache.org> commit d9d22f35d586d451ad92883ec83b4ef4338c8f7a Author: Dridi Boukelmoune Date: Mon Dec 23 10:47:03 2019 +0100 Simplify r02372.vtc We don't need randomness where we could have determinism. diff --git a/bin/varnishtest/tests/r02372.vtc b/bin/varnishtest/tests/r02372.vtc index a01401f16..0df38cb79 100644 --- a/bin/varnishtest/tests/r02372.vtc +++ b/bin/varnishtest/tests/r02372.vtc @@ -2,17 +2,14 @@ varnishtest "Count purges when there are many variants" server s1 -repeat 72 -keepalive { rxreq - txresp -hdr "Vary: foo" + txresp -hdr "Vary: x-varnish" } -start varnish v1 -arg "-p workspace_thread=512" -vcl+backend { - import std; - sub vcl_recv { if (req.method == "PURGE") { return (purge); } - set req.http.foo = "x" + std.random(1,10) * 1000000000; } } -start From dridi.boukelmoune at gmail.com Tue Dec 24 14:57:06 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 24 Dec 2019 14:57:06 +0000 (UTC) Subject: [master] bea2939cd Set be->cooled while holding backends_mtx Message-ID: <20191224145706.A46EDA2453@lists.varnish-cache.org> commit bea2939cd84f4ea165810e68e4537f65a73bd8b0 Author: Martin Blix Grydeland Date: Tue Dec 3 14:53:51 2019 +0100 Set be->cooled while holding backends_mtx Several functions (VBE_Poll and vbe_destroy) tests be->cooled == 0 to determine which of the two lists backends and cool_backends a specific instance currently lives on. If the flag is in the process of being changed, then the wrong list head may be used and will result in strange bugs. diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c index a2c437416..197065932 100644 --- a/bin/varnishd/cache/cache_backend.c +++ b/bin/varnishd/cache/cache_backend.c @@ -653,9 +653,9 @@ VRT_delete_backend(VRT_CTX, VCL_BACKEND *dp) CAST_OBJ_NOTNULL(be, d->priv, BACKEND_MAGIC); Lck_Lock(&be->mtx); VRT_DisableDirector(be->director); - be->cooled = VTIM_real() + 60.; Lck_Unlock(&be->mtx); Lck_Lock(&backends_mtx); + be->cooled = VTIM_real() + 60.; VTAILQ_REMOVE(&backends, be, list); VTAILQ_INSERT_TAIL(&cool_backends, be, list); Lck_Unlock(&backends_mtx); From dridi.boukelmoune at gmail.com Tue Dec 24 14:57:06 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 24 Dec 2019 14:57:06 +0000 (UTC) Subject: [master] 08593cb92 Add an assert that VRT_delete_backend is only called once Message-ID: <20191224145706.BF9B3A2456@lists.varnish-cache.org> commit 08593cb921d11f82dd8cf0b25c2fb5cab82d0d4b Author: Martin Blix Grydeland Date: Wed Dec 4 13:10:07 2019 +0100 Add an assert that VRT_delete_backend is only called once VRT_delete_backend() sets be->cooled to non-zero as the only place where that is done. Assert that it is zero on entry as a check that VRT_delete_backend isn't called multiple times. diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c index 197065932..4bc367c22 100644 --- a/bin/varnishd/cache/cache_backend.c +++ b/bin/varnishd/cache/cache_backend.c @@ -655,6 +655,7 @@ VRT_delete_backend(VRT_CTX, VCL_BACKEND *dp) VRT_DisableDirector(be->director); Lck_Unlock(&be->mtx); Lck_Lock(&backends_mtx); + AZ(be->cooled); be->cooled = VTIM_real() + 60.; VTAILQ_REMOVE(&backends, be, list); VTAILQ_INSERT_TAIL(&cool_backends, be, list); From dridi.boukelmoune at gmail.com Tue Dec 24 17:30:06 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 24 Dec 2019 17:30:06 +0000 (UTC) Subject: [master] a45399497 [cci] better weekly handling Message-ID: <20191224173006.42FDDA5DB3@lists.varnish-cache.org> commit a453994978df8c11a7dbf7e188a8d0079bd5f71a Author: Guillaume Quintard Date: Mon Dec 23 11:51:26 2019 +0000 [cci] better weekly handling if version is trunk, change it to the current date and add a flag file so that packages can be suffixed with -weekly/.weekly depending on the platform diff --git a/.circleci/config.yml b/.circleci/config.yml index 9efb08e34..225022123 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -105,24 +105,13 @@ jobs: - run: name: Update changelog version command: | - VERSION=$(./configure --version | awk 'NR == 1 {print $NF}') - - # VERSION looks like 5.2.1 or 5.2.0-rc1 - MAJOR=${VERSION%.*} # 5.2 - MINOR=${VERSION##*.} # 1 or 0-rc1 - MINOR=${MINOR%%-*} # 1 or 0 - RELEASE=${VERSION#*-} # 5.2.1 or rc1 - RELEASE=${RELEASE#$VERSION} # '' or rc1 - - # Take version override set on Jenkins builds into account. - if [ "$VERSION" = "trunk" ]; then - DEBVERSION=`date "+%Y%m%d"`-weekly~<< parameters.release >> + if [ -e .is_weekly ]; then + WEEKLY='-weekly' else - DEBVERSION="$MAJOR.$MINOR"-1~<< parameters.release >> + WEEKLY= fi - - sed -i -e "s|@SECTION@|varnish-$MAJOR|" "debian/control" - sed -i -e "s|@VERSION@|$DEBVERSION|" "debian/changelog" + VERSION=$(./configure --version | awk 'NR == 1 {print $NF}')$WEEKLY~<< parameters.release >> + sed -i -e "s|@VERSION@|$VERSION|" "debian/changelog" - run: name: Install Build-Depends packages command: | @@ -143,7 +132,7 @@ jobs: paths: - debs/varnish*.deb - debs/varnish*.dsc - build_alpine: + build_apks: description: Build alpine apks docker: - image: alpine @@ -178,16 +167,8 @@ jobs: command: | tar xavf varnish-*.tar.gz VERSION=$(varnish-*/configure --version | awk 'NR == 1 {print $NF}') - if [ "$VERSION" = trunk ]; then - WEEKLYVERSION=`date "+%Y%m%d"` - sed -i \ - -e "s@^pkgver=.*@pkgver=$WEEKLYVERSION@" \ - -e "s@^builddir=.*@builddir=\"\$srcdir/varnish-$VERSION\"@" \ - -e "s@^source=.*@source=varnish-trunk.tar.gz@" APKBUILD - else - sed -i "s@^pkgver=.*@pkgver=$VERSION@" APKBUILD - fi - rm -rf varnish-$VERSION + sed -i "s/@VERSION@/$VERSION/" APKBUILD + rm -rf varnish-*/ - run: name: Fix checksums, build command: | @@ -212,11 +193,17 @@ jobs: - run: name: Create the dist tarball command: | + # if version is "trunk", it's a weekly tarball, override the version + if grep 'AC_INIT.*trunk.*' ./configure.ac; then + sed -i -e "s/^AC_INIT.*trunk.*/AC_INIT([Varnish], [$(date +%Y%m%d)], [varnish-dev at varnish-cache.org])/" ./configure.ac + touch .is_weekly + fi ./autogen.des --quiet make dist -j 16 - persist_to_workspace: root: . paths: + - .is_weekly - varnish*.tar.gz - tools/*.suppr tar_pkg_tools: @@ -340,33 +327,22 @@ jobs: # use python3 sed -i '1 i\%global __python %{__python3}' "$DIST_DIR"/redhat/varnish.spec - [ -n "$DIST" ] - VERSION=$("$DIST_DIR"/configure --version | awk 'NR == 1 {print $NF}') - - # VERSION looks like 5.2.1 or 5.2.0-rc1 - MAJOR=${VERSION%.*} # 5.2 - MINOR=${VERSION##*.} # 1 or 0-rc1 - MINOR=${MINOR%%-*} # 1 or 0 - RELEASE=${VERSION#*-} # 5.2.1 or rc1 - RELEASE=${RELEASE#$VERSION} # '' or rc1 + if [ -e .is_weekly ]; then + WEEKLY='.weekly' + else + WEEKLY= + fi + VERSION=$("$DIST_DIR"/configure --version | awk 'NR == 1 {print $NF}')$WEEKLY cp -r -L "$DIST_DIR"/redhat/* "$DIST_DIR"/ tar zcf "$DIST_DIR.tgz" --exclude "$DIST_DIR/redhat" "$DIST_DIR"/ - if [ "$VERSION" = "trunk" ]; then - RPMVERSION=`date "+%Y%m%d"` - else - RPMVERSION="$MAJOR.$MINOR" - fi + RPMVERSION="$VERSION" RESULT_DIR="rpms" CUR_DIR="$(pwd)" rpmbuild() { - if [ -n "$RELEASE" ] - then - set -- --define "v_rc $RELEASE" "$@" - fi command rpmbuild \ --define "_smp_mflags -j10" \ --define "dist $DIST" \ @@ -422,7 +398,8 @@ workflows: <<: *pkg_req - build_centos_7: <<: *pkg_req - - build_alpine: + - build_apks: + name: build_alpine <<: *pkg_req - push_packages: requires: From dridi.boukelmoune at gmail.com Thu Dec 26 11:40:06 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 26 Dec 2019 11:40:06 +0000 (UTC) Subject: [master] f9b7f1818 Add coverage for backend creation in a cold VCL Message-ID: <20191226114006.395F65C5E@lists.varnish-cache.org> commit f9b7f1818c83b1bfa20a09120f6d41e43023df81 Author: Dridi Boukelmoune Date: Thu Dec 26 12:31:00 2019 +0100 Add coverage for backend creation in a cold VCL Refs #3176 diff --git a/bin/varnishtest/tests/v00063.vtc b/bin/varnishtest/tests/v00063.vtc new file mode 100644 index 000000000..6e8508530 --- /dev/null +++ b/bin/varnishtest/tests/v00063.vtc @@ -0,0 +1,20 @@ +varnishtest "Create a backend after a COLD event" + +server s1 -start + +varnish v1 -cliok "param.set feature +no_coredump" +varnish v1 -expectexit 0x20 +varnish v1 -vcl+backend { + import debug; + sub vcl_init { + debug.cold_backend(); + } +} -start + +# load and use a new VCL +varnish v1 -vcl+backend {} + +# expect a panic during the COLD event +varnish v1 -clierr 400 "vcl.state vcl1 cold" +varnish v1 -cliexpect "Dynamic Backends can only be added to warm VCLs" panic.show +varnish v1 -cliok panic.clear diff --git a/lib/libvmod_debug/vmod.vcc b/lib/libvmod_debug/vmod.vcc index c58397fcb..b8fe56f73 100644 --- a/lib/libvmod_debug/vmod.vcc +++ b/lib/libvmod_debug/vmod.vcc @@ -247,11 +247,15 @@ should now only be used for diagnostic purposes. $Function VOID vcl_prevent_cold(PRIV_VCL) -Prevent VCL from going cold +Prevent VCL from going cold. $Function VOID vcl_allow_cold(PRIV_VCL) -Allow VCL to go cold +Allow VCL to go cold. + +$Function VOID cold_backend(PRIV_VCL) + +Schedule a backend creation attempt when the VCL cools down, panic guaranteed. $Function VOID sndbuf(BYTES sndbuf) diff --git a/lib/libvmod_debug/vmod_debug.c b/lib/libvmod_debug/vmod_debug.c index 5b85a6fc8..e379f5c08 100644 --- a/lib/libvmod_debug/vmod_debug.c +++ b/lib/libvmod_debug/vmod_debug.c @@ -51,6 +51,7 @@ struct priv_vcl { struct vclref *vclref_cold; VCL_DURATION vcl_discard_delay; VCL_BACKEND be; + unsigned cold_be; }; @@ -385,6 +386,8 @@ xyzzy_vcl_prevent_cold(VRT_CTX, struct vmod_priv *priv) struct priv_vcl *priv_vcl; char buf[32]; + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + AN(priv); CAST_OBJ_NOTNULL(priv_vcl, priv->priv, PRIV_VCL_MAGIC); AZ(priv_vcl->vclref_cold); @@ -397,13 +400,24 @@ xyzzy_vcl_allow_cold(VRT_CTX, struct vmod_priv *priv) { struct priv_vcl *priv_vcl; - (void)ctx; - + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + AN(priv); CAST_OBJ_NOTNULL(priv_vcl, priv->priv, PRIV_VCL_MAGIC); AN(priv_vcl->vclref_cold); VRT_VCL_Allow_Cold(&priv_vcl->vclref_cold); } +VCL_VOID +xyzzy_cold_backend(VRT_CTX, struct vmod_priv *priv) +{ + struct priv_vcl *priv_vcl; + + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + AN(priv); + CAST_OBJ_NOTNULL(priv_vcl, priv->priv, PRIV_VCL_MAGIC); + priv_vcl->cold_be = 1; +} + static const struct vdi_methods empty_methods[1] = {{ .magic = VDI_METHODS_MAGIC, .type = "debug.dummy" @@ -426,8 +440,11 @@ event_warm(VRT_CTX, const struct vmod_priv *priv) CAST_OBJ_NOTNULL(priv_vcl, priv->priv, PRIV_VCL_MAGIC); AZ(priv_vcl->vclref_discard); - bprintf(buf, "vmod-debug ref on %s", VCL_Name(ctx->vcl)); - priv_vcl->vclref_discard = VRT_VCL_Prevent_Discard(ctx, buf); + if (!priv_vcl->cold_be) { + /* NB: set up a COOLING step unless we want a COLD backend. */ + bprintf(buf, "vmod-debug ref on %s", VCL_Name(ctx->vcl)); + priv_vcl->vclref_discard = VRT_VCL_Prevent_Discard(ctx, buf); + } AZ(priv_vcl->be); priv_vcl->be = VRT_AddDirector(ctx, empty_methods, @@ -454,15 +471,25 @@ event_cold(VRT_CTX, const struct vmod_priv *priv) { pthread_t thread; struct priv_vcl *priv_vcl; + struct vrt_backend be[1]; CAST_OBJ_NOTNULL(priv_vcl, priv->priv, PRIV_VCL_MAGIC); - AN(priv_vcl->vclref_discard); VSL(SLT_Debug, 0, "%s: VCL_EVENT_COLD", VCL_Name(ctx->vcl)); VRT_DelDirector(&priv_vcl->be); + if (priv_vcl->cold_be) { + AZ(priv_vcl->vclref_discard); + INIT_OBJ(be, VRT_BACKEND_MAGIC); + be->path = "/"; + be->vcl_name = "doomed"; + priv_vcl->be = VRT_new_backend(ctx, be); + WRONG("unreachable"); + } + if (priv_vcl->vcl_discard_delay == 0.0) { + AN(priv_vcl->vclref_discard); VRT_VCL_Allow_Discard(&priv_vcl->vclref_discard); return (0); } From dridi.boukelmoune at gmail.com Thu Dec 26 17:19:06 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 26 Dec 2019 17:19:06 +0000 (UTC) Subject: [master] 07a09db90 Only let VRT_AddDirector undo a COOLING attempt Message-ID: <20191226171906.5DBAA1026E1@lists.varnish-cache.org> commit 07a09db90be92ebd018d1799c865534c9e78242f Author: Dridi Boukelmoune Date: Thu Dec 26 17:29:21 2019 +0100 Only let VRT_AddDirector undo a COOLING attempt When a VCL is in the COOLING state it is supposed to delete the director that was being added, but at the same time when a VBE backend fails to be added as a director it would also undo itself. This is in general a code path very hard to reach because either this happens in a worker and the opportunistic check always kicks in to hide the problem or this is done asynchronously (e.g. non-blocking lookups to create dynamic backends) and the race window is very small. In order to solve this the opportunistic check is skipped in VTC mode. The test coverage with vmod_debug is done synchronously to make things easier, but for this reason vbe_destroy can no longer expect to only run in the CLI thread. This is inspired by a similar patch by Martin for a different branch, since VRT_AddDirector deletes the backend upon failure, everything needs to be set up beforehand. We have to tolerate backend creation attempts in a COOLING VCL because in the asynchronous case the VCL temperature will change before COLD events are dispatched so there's no way to prevent a race. Closes #3176 diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c index 4bc367c22..84f42b21a 100644 --- a/bin/varnishd/cache/cache_backend.c +++ b/bin/varnishd/cache/cache_backend.c @@ -396,7 +396,6 @@ vbe_destroy(const struct director *d) { struct backend *be; - ASSERT_CLI(); CAST_OBJ_NOTNULL(be, d->priv, BACKEND_MAGIC); if (be->probe != NULL) @@ -520,7 +519,7 @@ static const struct vdi_methods vbe_methods_noprobe[1] = {{ * Create a new static or dynamic director::backend instance. */ -size_t v_matchproto_() +size_t VRT_backend_vsm_need(VRT_CTX) { (void)ctx; @@ -547,13 +546,15 @@ vrt_hash_be(const struct vrt_backend *vrt) return (vbe64dec(ident)); } -VCL_BACKEND v_matchproto_() +VCL_BACKEND VRT_new_backend_clustered(VRT_CTX, struct vsmw_cluster *vc, const struct vrt_backend *vrt) { + VCL_BACKEND d; struct backend *be; struct vcl *vcl; const struct vrt_backend_probe *vbp; + const struct vdi_methods *m; CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(vrt, VRT_BACKEND_MAGIC); @@ -593,45 +594,34 @@ VRT_new_backend_clustered(VRT_CTX, struct vsmw_cluster *vc, if (vbp == NULL) vbp = VCL_DefaultProbe(vcl); - if (vbp != NULL) + if (vbp != NULL) { VBP_Insert(be, vbp, be->tcp_pool); - else + m = vbe_methods; + } else { be->sick = 0; + m = vbe_methods_noprobe; + } + + Lck_Lock(&backends_mtx); + VTAILQ_INSERT_TAIL(&backends, be, list); + VSC_C_main->n_backend++; + Lck_Unlock(&backends_mtx); + + d = VRT_AddDirector(ctx, m, be, "%s", vrt->vcl_name); - be->director = VRT_AddDirector(ctx, - vbp != NULL ? vbe_methods : vbe_methods_noprobe, be, - "%s", vrt->vcl_name); + /* NB: if VRT_AddDirector failed, be was already freed. */ + if (d != NULL) { + be->director = d; - if (be->director != NULL) { /* for cold VCL, update initial director state */ if (be->probe != NULL && ! vcl->temp->is_warm) VBP_Update_Backend(be->probe); - - Lck_Lock(&backends_mtx); - VTAILQ_INSERT_TAIL(&backends, be, list); - VSC_C_main->n_backend++; - Lck_Unlock(&backends_mtx); - return (be->director); } - /* undo */ - if (vbp != NULL) - VBP_Remove(be); - - VTP_Rel(&be->tcp_pool); - - VSC_vbe_Destroy(&be->vsc_seg); -#define DA(x) do { if (be->x != NULL) free(be->x); } while (0) -#define DN(x) /**/ - VRT_BACKEND_HANDLE(); -#undef DA -#undef DN - Lck_Delete(&be->mtx); - FREE_OBJ(be); - return (NULL); + return (d); } -VCL_BACKEND v_matchproto_() +VCL_BACKEND VRT_new_backend(VRT_CTX, const struct vrt_backend *vrt) { return (VRT_new_backend_clustered(ctx, NULL, vrt)); diff --git a/bin/varnishd/cache/cache_vrt_vcl.c b/bin/varnishd/cache/cache_vrt_vcl.c index 42bbf3b9b..cc332e96c 100644 --- a/bin/varnishd/cache/cache_vrt_vcl.c +++ b/bin/varnishd/cache/cache_vrt_vcl.c @@ -149,7 +149,6 @@ VRT_AddDirector(VRT_CTX, const struct vdi_methods *m, void *priv, struct vsb *vsb; struct vcl *vcl; struct vcldir *vdir; - struct director *d; const struct vcltemp *temp; va_list ap; int i; @@ -161,18 +160,17 @@ VRT_AddDirector(VRT_CTX, const struct vdi_methods *m, void *priv, CHECK_OBJ_NOTNULL(vcl, VCL_MAGIC); // opportunistic, re-checked again under lock - if (vcl->temp == VCL_TEMP_COOLING) + if (vcl->temp == VCL_TEMP_COOLING && !DO_DEBUG(DBG_VTC_MODE)) return (NULL); - ALLOC_OBJ(d, DIRECTOR_MAGIC); - AN(d); ALLOC_OBJ(vdir, VCLDIR_MAGIC); AN(vdir); - vdir->dir = d; - d->vdir = vdir; + ALLOC_OBJ(vdir->dir, DIRECTOR_MAGIC); + AN(vdir->dir); + vdir->dir->vdir = vdir; vdir->methods = m; - d->priv = priv; + vdir->dir->priv = priv; vsb = VSB_new_auto(); AN(vsb); VSB_printf(vsb, "%s.", VCL_Name(vcl)); @@ -183,18 +181,24 @@ VRT_AddDirector(VRT_CTX, const struct vdi_methods *m, void *priv, AZ(VSB_finish(vsb)); REPLACE(vdir->cli_name, VSB_data(vsb)); VSB_destroy(&vsb); - d->vcl_name = vdir->cli_name + i; + vdir->dir->vcl_name = vdir->cli_name + i; vdir->vcl = vcl; vdir->admin_health = VDI_AH_AUTO; vdir->health_changed = VTIM_real(); + /* NB: at this point we look at the VCL temperature after getting + * through the trouble of creating the director even though it might + * not be legal to do so. Because we change the VCL temperature before + * sending COLD events we have to tolerate and undo attempts for the + * COOLING case. + */ Lck_Lock(&vcl_mtx); temp = vcl->temp; if (temp != VCL_TEMP_COOLING) VTAILQ_INSERT_TAIL(&vcl->director_list, vdir, list); if (temp->is_warm) - VDI_Event(d, VCL_EVENT_WARM); + VDI_Event(vdir->dir, VCL_EVENT_WARM); Lck_Unlock(&vcl_mtx); if (temp == VCL_TEMP_COOLING) { @@ -204,7 +208,7 @@ VRT_AddDirector(VRT_CTX, const struct vdi_methods *m, void *priv, if (!temp->is_warm && temp != VCL_TEMP_INIT) WRONG("Dynamic Backends can only be added to warm VCLs"); - return (d); + return (vdir->dir); } static void diff --git a/bin/varnishtest/tests/v00063.vtc b/bin/varnishtest/tests/v00063.vtc index 6e8508530..974794eac 100644 --- a/bin/varnishtest/tests/v00063.vtc +++ b/bin/varnishtest/tests/v00063.vtc @@ -14,7 +14,19 @@ varnish v1 -vcl+backend { # load and use a new VCL varnish v1 -vcl+backend {} -# expect a panic during the COLD event +# expect a panic during the COLD event, COLD state varnish v1 -clierr 400 "vcl.state vcl1 cold" varnish v1 -cliexpect "Dynamic Backends can only be added to warm VCLs" panic.show varnish v1 -cliok panic.clear + +varnish v1 -vcl+backend { + import debug; + sub vcl_init { + debug.cooling_backend(); + } +} + +varnish v1 -cliok "vcl.use vcl2" + +# expect no panic during the COLD event, COOLING state +varnish v1 -cliok "vcl.state vcl3 cold" diff --git a/lib/libvmod_debug/vmod.vcc b/lib/libvmod_debug/vmod.vcc index b8fe56f73..e28bbd204 100644 --- a/lib/libvmod_debug/vmod.vcc +++ b/lib/libvmod_debug/vmod.vcc @@ -255,7 +255,11 @@ Allow VCL to go cold. $Function VOID cold_backend(PRIV_VCL) -Schedule a backend creation attempt when the VCL cools down, panic guaranteed. +Schedule a backend creation attempt when the VCL is COLD, panic guaranteed. + +$Function VOID cooling_backend(PRIV_VCL) + +Schedule a backend creation attempt when the VCL is COOLING, failure guaranteed. $Function VOID sndbuf(BYTES sndbuf) diff --git a/lib/libvmod_debug/vmod_debug.c b/lib/libvmod_debug/vmod_debug.c index e379f5c08..2c601fe1c 100644 --- a/lib/libvmod_debug/vmod_debug.c +++ b/lib/libvmod_debug/vmod_debug.c @@ -52,6 +52,7 @@ struct priv_vcl { VCL_DURATION vcl_discard_delay; VCL_BACKEND be; unsigned cold_be; + unsigned cooling_be; }; @@ -418,6 +419,17 @@ xyzzy_cold_backend(VRT_CTX, struct vmod_priv *priv) priv_vcl->cold_be = 1; } +VCL_VOID +xyzzy_cooling_backend(VRT_CTX, struct vmod_priv *priv) +{ + struct priv_vcl *priv_vcl; + + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + AN(priv); + CAST_OBJ_NOTNULL(priv_vcl, priv->priv, PRIV_VCL_MAGIC); + priv_vcl->cooling_be = 1; +} + static const struct vdi_methods empty_methods[1] = {{ .magic = VDI_METHODS_MAGIC, .type = "debug.dummy" @@ -466,12 +478,22 @@ cooldown_thread(void *priv) return (NULL); } +static VCL_BACKEND +create_cold_backend(VRT_CTX) +{ + struct vrt_backend be[1]; + + INIT_OBJ(be, VRT_BACKEND_MAGIC); + be->path = "/"; + be->vcl_name = "doomed"; + return (VRT_new_backend(ctx, be)); +} + static int event_cold(VRT_CTX, const struct vmod_priv *priv) { pthread_t thread; struct priv_vcl *priv_vcl; - struct vrt_backend be[1]; CAST_OBJ_NOTNULL(priv_vcl, priv->priv, PRIV_VCL_MAGIC); @@ -481,13 +503,16 @@ event_cold(VRT_CTX, const struct vmod_priv *priv) if (priv_vcl->cold_be) { AZ(priv_vcl->vclref_discard); - INIT_OBJ(be, VRT_BACKEND_MAGIC); - be->path = "/"; - be->vcl_name = "doomed"; - priv_vcl->be = VRT_new_backend(ctx, be); + priv_vcl->be = create_cold_backend(ctx); WRONG("unreachable"); } + if (priv_vcl->cooling_be) { + AN(priv_vcl->vclref_discard); + priv_vcl->be = create_cold_backend(ctx); + AZ(priv_vcl->be); + } + if (priv_vcl->vcl_discard_delay == 0.0) { AN(priv_vcl->vclref_discard); VRT_VCL_Allow_Discard(&priv_vcl->vclref_discard); From dridi.boukelmoune at gmail.com Thu Dec 26 18:17:05 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 26 Dec 2019 18:17:05 +0000 (UTC) Subject: [master] aeead7e77 Plug minor leak Message-ID: <20191226181705.E8BDF103A3B@lists.varnish-cache.org> commit aeead7e77f542762fe171e7f7dd142dddc056e62 Author: Dridi Boukelmoune Date: Thu Dec 26 19:00:03 2019 +0100 Plug minor leak diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c index 03d707ee6..4eaecfae5 100644 --- a/bin/varnishd/mgt/mgt_param.c +++ b/bin/varnishd/mgt/mgt_param.c @@ -575,16 +575,47 @@ MCF_AddParams(struct parspec *ps) */ static void -mcf_wash_param(struct cli *cli, const struct parspec *pp, const char **val, +mcf_dyn_vsb(enum mcf_which_e which, struct parspec *pp, struct vsb *vsb) +{ + + switch (which) { + case MCF_DEFAULT: + REPLACE(pp->dyn_def, VSB_data(vsb)); + pp->def = pp->dyn_def; + break; + case MCF_MINIMUM: + REPLACE(pp->dyn_min, VSB_data(vsb)); + pp->min = pp->dyn_min; + break; + case MCF_MAXIMUM: + REPLACE(pp->dyn_max, VSB_data(vsb)); + pp->max = pp->dyn_max; + break; + default: + WRONG("bad 'which'"); + } +} + +static void +mcf_wash_param(struct cli *cli, struct parspec *pp, enum mcf_which_e which, const char *name, struct vsb *vsb) { + const char *val; int err; - AN(*val); + switch (which) { + case MCF_DEFAULT: val = pp->def; break; + case MCF_MINIMUM: val = pp->min; break; + case MCF_MAXIMUM: val = pp->max; break; + default: + WRONG("bad 'which'"); + } + AN(val); + VSB_clear(vsb); VSB_printf(vsb, "FAILED to set %s for param %s: %s\n", - name, pp->name, *val); - err = pp->func(vsb, pp, *val); + name, pp->name, val); + err = pp->func(vsb, pp, val); AZ(VSB_finish(vsb)); if (err) { VCLI_Out(cli, "%s\n", VSB_data(vsb)); @@ -595,10 +626,8 @@ mcf_wash_param(struct cli *cli, const struct parspec *pp, const char **val, err = pp->func(vsb, pp, NULL); AZ(err); AZ(VSB_finish(vsb)); - if (strcmp(*val, VSB_data(vsb))) { - *val = strdup(VSB_data(vsb)); - AN(*val); - } + if (strcmp(val, VSB_data(vsb))) + mcf_dyn_vsb(which, pp, vsb); } /*--------------------------------------------------------------------*/ @@ -679,11 +708,11 @@ MCF_InitParams(struct cli *cli) if (pp->flags & NOT_IMPLEMENTED) continue; if (pp->min != NULL) - mcf_wash_param(cli, pp, &pp->min, "minimum", vsb); + mcf_wash_param(cli, pp, MCF_MINIMUM, "minimum", vsb); if (pp->max != NULL) - mcf_wash_param(cli, pp, &pp->max, "maximum", vsb); + mcf_wash_param(cli, pp, MCF_MAXIMUM, "maximum", vsb); AN(pp->def); - mcf_wash_param(cli, pp, &pp->def, "default", vsb); + mcf_wash_param(cli, pp, MCF_DEFAULT, "default", vsb); } VSB_destroy(&vsb); } @@ -706,22 +735,7 @@ MCF_ParamConf(enum mcf_which_e which, const char * const param, VSB_vprintf(vsb, fmt, ap); va_end(ap); AZ(VSB_finish(vsb)); - switch (which) { - case MCF_DEFAULT: - REPLACE(pp->dyn_def, VSB_data(vsb)); - pp->def = pp->dyn_def; - break; - case MCF_MINIMUM: - REPLACE(pp->dyn_min, VSB_data(vsb)); - pp->min = pp->dyn_min; - break; - case MCF_MAXIMUM: - REPLACE(pp->dyn_max, VSB_data(vsb)); - pp->max = pp->dyn_max; - break; - default: - WRONG("bad 'which'"); - } + mcf_dyn_vsb(which, pp, vsb); VSB_delete(vsb); } diff --git a/tools/lsan.suppr b/tools/lsan.suppr index 03abb5f9c..485d27703 100644 --- a/tools/lsan.suppr +++ b/tools/lsan.suppr @@ -1,9 +1,5 @@ # varnishtest leak:varnishtest -# pp->{def,min,max} -leak:MCF_ParamConf -# pp->{def,min,max} -leak:mcf_wash_param # av leak:STV_Config # av From fgsch at lodoss.net Fri Dec 27 02:05:10 2019 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Fri, 27 Dec 2019 02:05:10 +0000 (UTC) Subject: [master] 8c90b585c No longer needed Message-ID: <20191227020510.C7AD510F2A8@lists.varnish-cache.org> commit 8c90b585c4234eddaac822a07b9c55f3d1bad4f3 Author: Federico G. Schwindt Date: Thu Dec 26 23:02:39 2019 -0300 No longer needed Fixed in 7ff636dca1dc3e94ce19edba4ff38d4d9267726b. diff --git a/tools/lsan.suppr b/tools/lsan.suppr index 485d27703..854eaca9f 100644 --- a/tools/lsan.suppr +++ b/tools/lsan.suppr @@ -13,6 +13,4 @@ leak:binheap_new # ev leak:mct_callback # -leak:backtrace_symbols -# leak:vsmw_newcluster From dridi.boukelmoune at gmail.com Fri Dec 27 07:59:06 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 27 Dec 2019 07:59:06 +0000 (UTC) Subject: [master] cb6ef1196 Remove the opportunistic COOLING check Message-ID: <20191227075906.EBBFD1182A2@lists.varnish-cache.org> commit cb6ef119673fda4891f570a14f27fa638b89c9f6 Author: Dridi Boukelmoune Date: Fri Dec 27 08:52:36 2019 +0100 Remove the opportunistic COOLING check Otherwise at this point nothing is undone. And backend creation while a VCL is stuck in the COOLING state should be unlikely enough that we can assume the happy path by default. Refs #3176 diff --git a/bin/varnishd/cache/cache_vrt_vcl.c b/bin/varnishd/cache/cache_vrt_vcl.c index cc332e96c..2c63b4b1a 100644 --- a/bin/varnishd/cache/cache_vrt_vcl.c +++ b/bin/varnishd/cache/cache_vrt_vcl.c @@ -159,10 +159,6 @@ VRT_AddDirector(VRT_CTX, const struct vdi_methods *m, void *priv, vcl = ctx->vcl; CHECK_OBJ_NOTNULL(vcl, VCL_MAGIC); - // opportunistic, re-checked again under lock - if (vcl->temp == VCL_TEMP_COOLING && !DO_DEBUG(DBG_VTC_MODE)) - return (NULL); - ALLOC_OBJ(vdir, VCLDIR_MAGIC); AN(vdir); ALLOC_OBJ(vdir->dir, DIRECTOR_MAGIC); From dridi.boukelmoune at gmail.com Fri Dec 27 09:25:05 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 27 Dec 2019 09:25:05 +0000 (UTC) Subject: [master] 00fa3c754 Restore previous VRT_AddDirector semantics Message-ID: <20191227092505.ECBB55822@lists.varnish-cache.org> commit 00fa3c754a2abe04c55fa9825acfb1a2d3c800e0 Author: Dridi Boukelmoune Date: Fri Dec 27 10:12:56 2019 +0100 Restore previous VRT_AddDirector semantics Upon failure, don't destroy the underlying director implementation. When the deletion code was split in c671bb6691f27172ae9103226cb09a99c9812483 in order to be reused in 615298547adfb06aa785b42552062bc391f56ecd, it mistakenly included the director implementation. Instead, it's really the caller's job to tear down the backend if it couldn't be added. Since vbe_destroy operates on a director, it is split in two to avoid reintroducing the previous "undo" code duplication. Refs #3176 diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c index 84f42b21a..d1c4b90b7 100644 --- a/bin/varnishd/cache/cache_backend.c +++ b/bin/varnishd/cache/cache_backend.c @@ -391,12 +391,11 @@ vbe_dir_event(const struct director *d, enum vcl_event_e ev) /*---------------------------------------------------------------------*/ -static void v_matchproto_(vdi_destroy_f) -vbe_destroy(const struct director *d) +static void +vbe_free(struct backend *be) { - struct backend *be; - CAST_OBJ_NOTNULL(be, d->priv, BACKEND_MAGIC); + CHECK_OBJ_NOTNULL(be, BACKEND_MAGIC); if (be->probe != NULL) VBP_Remove(be); @@ -421,6 +420,15 @@ vbe_destroy(const struct director *d) FREE_OBJ(be); } +static void v_matchproto_(vdi_destroy_f) +vbe_destroy(const struct director *d) +{ + struct backend *be; + + CAST_OBJ_NOTNULL(be, d->priv, BACKEND_MAGIC); + vbe_free(be); +} + /*--------------------------------------------------------------------*/ static void @@ -550,7 +558,6 @@ VCL_BACKEND VRT_new_backend_clustered(VRT_CTX, struct vsmw_cluster *vc, const struct vrt_backend *vrt) { - VCL_BACKEND d; struct backend *be; struct vcl *vcl; const struct vrt_backend_probe *vbp; @@ -607,18 +614,17 @@ VRT_new_backend_clustered(VRT_CTX, struct vsmw_cluster *vc, VSC_C_main->n_backend++; Lck_Unlock(&backends_mtx); - d = VRT_AddDirector(ctx, m, be, "%s", vrt->vcl_name); - - /* NB: if VRT_AddDirector failed, be was already freed. */ - if (d != NULL) { - be->director = d; + be->director = VRT_AddDirector(ctx, m, be, "%s", vrt->vcl_name); + if (be->director != NULL) { /* for cold VCL, update initial director state */ if (be->probe != NULL && ! vcl->temp->is_warm) VBP_Update_Backend(be->probe); + return (be->director); } - return (d); + vbe_free(be); + return (NULL); } VCL_BACKEND diff --git a/bin/varnishd/cache/cache_vrt_vcl.c b/bin/varnishd/cache/cache_vrt_vcl.c index 2c63b4b1a..228517d5c 100644 --- a/bin/varnishd/cache/cache_vrt_vcl.c +++ b/bin/varnishd/cache/cache_vrt_vcl.c @@ -41,8 +41,6 @@ #include "cache_director.h" #include "cache_vcl.h" -static void deldirector(struct vcldir *); - /*--------------------------------------------------------------------*/ const char * @@ -142,6 +140,15 @@ VCL_Rel(struct vcl **vcc) /*--------------------------------------------------------------------*/ +static void +vcldir_free(struct vcldir *vdir) +{ + + free(vdir->cli_name); + FREE_OBJ(vdir->dir); + FREE_OBJ(vdir); +} + VCL_BACKEND VRT_AddDirector(VRT_CTX, const struct vdi_methods *m, void *priv, const char *fmt, ...) @@ -159,6 +166,10 @@ VRT_AddDirector(VRT_CTX, const struct vdi_methods *m, void *priv, vcl = ctx->vcl; CHECK_OBJ_NOTNULL(vcl, VCL_MAGIC); + // opportunistic, re-checked again under lock + if (vcl->temp == VCL_TEMP_COOLING && !DO_DEBUG(DBG_VTC_MODE)) + return (NULL); + ALLOC_OBJ(vdir, VCLDIR_MAGIC); AN(vdir); ALLOC_OBJ(vdir->dir, DIRECTOR_MAGIC); @@ -198,7 +209,7 @@ VRT_AddDirector(VRT_CTX, const struct vdi_methods *m, void *priv, Lck_Unlock(&vcl_mtx); if (temp == VCL_TEMP_COOLING) { - deldirector(vdir); + vcldir_free(vdir); return (NULL); } if (!temp->is_warm && temp != VCL_TEMP_INIT) @@ -207,16 +218,6 @@ VRT_AddDirector(VRT_CTX, const struct vdi_methods *m, void *priv, return (vdir->dir); } -static void -deldirector(struct vcldir *vdir) -{ - if(vdir->methods->destroy != NULL) - vdir->methods->destroy(vdir->dir); - free(vdir->cli_name); - FREE_OBJ(vdir->dir); - FREE_OBJ(vdir); -} - void VRT_DelDirector(VCL_BACKEND *bp) { @@ -238,8 +239,10 @@ VRT_DelDirector(VCL_BACKEND *bp) if (temp->is_warm) VDI_Event(d, VCL_EVENT_COLD); + if(vdir->methods->destroy != NULL) + vdir->methods->destroy(d); assert (d == vdir->dir); - deldirector(vdir); + vcldir_free(vdir); } void From dridi.boukelmoune at gmail.com Fri Dec 27 13:41:06 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 27 Dec 2019 13:41:06 +0000 (UTC) Subject: [master] 5a55b53a0 Plug memory leaks witnessed in varnishtest Message-ID: <20191227134106.18CDD634A2@lists.varnish-cache.org> commit 5a55b53a0d83c892e90b8c064944a4054c076d77 Author: Dridi Boukelmoune Date: Fri Dec 27 13:34:39 2019 +0100 Plug memory leaks witnessed in varnishtest For those that aren't leaked on purpose, that is... diff --git a/bin/varnishtest/vtc_h2_hpack.c b/bin/varnishtest/vtc_h2_hpack.c index a00208ad9..e16361c9f 100644 --- a/bin/varnishtest/vtc_h2_hpack.c +++ b/bin/varnishtest/vtc_h2_hpack.c @@ -379,12 +379,16 @@ HPK_DecHdr(struct hpk_iter *iter, struct hpk_hdr *header) return (hpk_err); txtcpy(&header->key, t); } else { - if (hpk_more != str_decode(iter, &header->key)) + if (hpk_more != str_decode(iter, &header->key)) { + free(header->key.ptr); return (hpk_err); + } } - if (hpk_err == str_decode(iter, &header->value)) + if (hpk_err == str_decode(iter, &header->value)) { + free(header->key.ptr); return (hpk_err); + } if (must_index) push_header(iter->ctx, header); diff --git a/bin/varnishtest/vtc_http2.c b/bin/varnishtest/vtc_http2.c index 049d7dd1b..9d9a4e5f6 100644 --- a/bin/varnishtest/vtc_http2.c +++ b/bin/varnishtest/vtc_http2.c @@ -116,13 +116,16 @@ struct stream { static void clean_headers(struct hpk_hdr *h) { - while (h->t) { + unsigned n = MAX_HDR; + + while (h->t && n > 0) { if (h->key.len) free(h->key.ptr); if (h->value.len) free(h->value.ptr); memset(h, 0, sizeof(*h)); h++; + n--; } } @@ -284,18 +287,30 @@ do { \ } while(0) static void -clean_frame(struct frame **f) +replace_frame(struct frame **fp, struct frame *new) { - AN(f); - if (!*f) + struct frame *old; + + AN(fp); + CHECK_OBJ_ORNULL(new, FRAME_MAGIC); + + old = *fp; + *fp = new; + if (old == NULL) return; - CHECK_OBJ_NOTNULL(*f, FRAME_MAGIC); + CHECK_OBJ(old, FRAME_MAGIC); + if (old->type == TYPE_GOAWAY) + free(old->md.goaway.debug); + free(old->data); + FREE_OBJ(old); +} - if ((*f)->type == TYPE_GOAWAY) - free((*f)->md.goaway.debug); - free((*f)->data); - FREE_OBJ(*f); +static void +clean_frame(struct frame **fp) +{ + + replace_frame(fp, NULL); } static void @@ -783,6 +798,7 @@ receive_frame(void *priv) else hdrs = s->resp; } + clean_headers(hdrs); hdrs[0].t = hpk_unset; AZ(vsb); vsb = VSB_new_auto(); @@ -2107,10 +2123,9 @@ rxstuff(struct stream *s) } clean_frame(&s->frame); f = VTAILQ_LAST(&s->fq, fq_head); + CHECK_OBJ_NOTNULL(f, FRAME_MAGIC); VTAILQ_REMOVE(&s->fq, f, list); AZ(pthread_mutex_unlock(&s->hp->mtx)); - - CHECK_OBJ_NOTNULL(f, FRAME_MAGIC); return (f); } @@ -2165,14 +2180,14 @@ cmd_rxhdrs(CMD_ARGS) vtc_fatal(vl, "Unknown rxhdrs spec: %s\n", *av); do { - f = rxstuff(s); - if (!f) - return; + replace_frame(&f, rxstuff(s)); + if (f == NULL) + break; rcv++; CHKFRAME(f->type, expect, rcv, "rxhdrs"); expect = TYPE_CONTINUATION; } while (rcv < times || (loop && !(f->flags & END_HEADERS))); - s->frame = f; + replace_frame(&s->frame, f); } static void @@ -2203,13 +2218,13 @@ cmd_rxcont(CMD_ARGS) vtc_fatal(vl, "Unknown rxcont spec: %s\n", *av); do { - f = rxstuff(s); - if (!f) - return; + replace_frame(&f, rxstuff(s)); + if (f == NULL) + break; rcv++; CHKFRAME(f->type, TYPE_CONTINUATION, rcv, "rxcont"); } while (rcv < times || (loop && !(f->flags & END_HEADERS))); - s->frame = f; + replace_frame(&s->frame, f); } @@ -2254,13 +2269,13 @@ cmd_rxdata(CMD_ARGS) vtc_fatal(vl, "Unknown rxdata spec: %s\n", *av); do { - f = rxstuff(s); - if (!f) - return; + replace_frame(&f, rxstuff(s)); + if (f == NULL) + break; rcv++; CHKFRAME(f->type, TYPE_DATA, rcv, "rxhdata"); } while (rcv < times || (loop && !(f->flags & END_STREAM))); - s->frame = f; + replace_frame(&s->frame, f); } /* SECTION: stream.spec.data_10 rxreq, rxresp @@ -2300,19 +2315,22 @@ cmd_rxmsg(CMD_ARGS) end_stream = f->flags & END_STREAM; while (!(f->flags & END_HEADERS)) { - f = rxstuff(s); - if (!f) + replace_frame(&f, rxstuff(s)); + if (f == NULL) return; rcv++; CHKFRAME(f->type, TYPE_CONTINUATION, rcv, *av); } - while (!end_stream && (f = rxstuff(s)) != NULL) { + while (!end_stream) { + replace_frame(&f, rxstuff(s)); + if (f == NULL) + break; rcv++; CHKFRAME(f->type, TYPE_DATA, rcv, *av); end_stream = f->flags & END_STREAM; } - s->frame = f; + replace_frame(&s->frame, f); } /* SECTION: stream.spec.data_12 rxpush @@ -2553,11 +2571,7 @@ stream_thread(void *priv) struct stream *s; CAST_OBJ_NOTNULL(s, priv, STREAM_MAGIC); - parse_string(s->spec, stream_cmds, s, s->hp->vl); - - clean_headers(s->req); - clean_headers(s->resp); vtc_log(s->hp->vl, 2, "Ending stream %u", s->id); return (NULL); } @@ -2604,7 +2618,17 @@ stream_new(const char *name, struct http *h) static void stream_delete(struct stream *s) { + struct frame *f, *f2; + CHECK_OBJ_NOTNULL(s, STREAM_MAGIC); + + VTAILQ_FOREACH_SAFE(f, &s->fq, list, f2) { + VTAILQ_REMOVE(&s->fq, f, list); + clean_frame(&f); + } + clean_headers(s->req); + clean_headers(s->resp); + AZ(s->frame); free(s->body); free(s->spec); free(s->name); @@ -2640,8 +2664,10 @@ stream_wait(struct stream *s) vtc_fatal(s->hp->vl, "Stream %u returned \"%s\"", s->id, (char *)res); - VTAILQ_FOREACH_SAFE(f, &s->fq, list, f2) + VTAILQ_FOREACH_SAFE(f, &s->fq, list, f2) { + VTAILQ_REMOVE(&s->fq, f, list); clean_frame(&f); + } clean_frame(&s->frame); s->tp = 0; s->running = 0; diff --git a/bin/varnishtest/vtc_main.c b/bin/varnishtest/vtc_main.c index c61ab7c7d..f0b147265 100644 --- a/bin/varnishtest/vtc_main.c +++ b/bin/varnishtest/vtc_main.c @@ -370,6 +370,10 @@ tst_cb(const struct vev *ve, int what) VEV_Stop(vb, jp->evt); free(jp->evt); } + if (jp->tst->ntodo == 0) { + free(jp->tst->script); + FREE_OBJ(jp->tst); + } FREE_OBJ(jp); return (1); } @@ -406,8 +410,7 @@ start_test(void) VTAILQ_INSERT_TAIL(&tst_head, tp, list); jp->tst = tp; - jp->tmpdir = strdup(tmpdir); - AN(jp->tmpdir); + REPLACE(jp->tmpdir, tmpdir); AZ(pipe(p)); assert(p[0] > STDERR_FILENO); diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c index 483690cbb..bbc80899c 100644 --- a/bin/varnishtest/vtc_varnish.c +++ b/bin/varnishtest/vtc_varnish.c @@ -174,11 +174,12 @@ wait_running(const struct varnish *v) vtc_fatal(v->vl, "Child stopped before running: %u %s", st, r); if (!strcmp(r, "Child in state running")) { + free(r); + r = NULL; st = varnish_ask_cli(v, "debug.listen_address", &r); if (st != CLIS_OK) vtc_fatal(v->vl, - "CLI status command failed: %u %s", - st, r); + "CLI status command failed: %u %s", st, r); free(r); break; } @@ -349,7 +350,9 @@ varnish_delete(struct varnish *v) CHECK_OBJ_NOTNULL(v, VARNISH_MAGIC); vtc_logclose(v->vl); free(v->name); + free(v->jail); free(v->workdir); + VSB_destroy(&v->args); if (v->vsc != NULL) VSC_Destroy(&v->vsc, v->vsm_vsc); if (v->vsm_vsc != NULL) diff --git a/tools/lsan.suppr b/tools/lsan.suppr index 854eaca9f..bcdbfbfbc 100644 --- a/tools/lsan.suppr +++ b/tools/lsan.suppr @@ -1,5 +1,5 @@ # varnishtest -leak:varnishtest +leak:parse_string # av leak:STV_Config # av From dridi.boukelmoune at gmail.com Sat Dec 28 09:20:09 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Sat, 28 Dec 2019 09:20:09 +0000 (UTC) Subject: [master] 93686c6a2 Plug leaks caught by c80 with ASAN Message-ID: <20191228092009.A5A54114758@lists.varnish-cache.org> commit 93686c6a2993870984ee34d18705f38203560eeb Author: Dridi Boukelmoune Date: Fri Dec 27 19:07:51 2019 +0100 Plug leaks caught by c80 with ASAN This is only a matter of leaving the acceptor loop to always free the poolsock before returning from the function. This was initially done in only one place out of three, with no room to exit the accept inner loop in the absence of an incoming connection. With this we may have everything in place to drop the drop_pools debug flag. Refs 656982a5cf70 Closes #3177 diff --git a/bin/varnishd/cache/cache_acceptor.c b/bin/varnishd/cache/cache_acceptor.c index 0e7ee9877..169ec3d1e 100644 --- a/bin/varnishd/cache/cache_acceptor.c +++ b/bin/varnishd/cache/cache_acceptor.c @@ -456,13 +456,10 @@ vca_accept_task(struct worker *wrk, void *arg) do { i = accept(ls->sock, (void*)&wa.acceptaddr, &wa.acceptaddrlen); - } while (i < 0 && errno == EAGAIN); + } while (i < 0 && errno == EAGAIN && !ps->pool->die); - if (i < 0 && ps->pool->die) { - VSL(SLT_Debug, 0, "XXX Accept thread dies %p", ps); - FREE_OBJ(ps); - return; - } + if (i < 0 && ps->pool->die) + break; if (i < 0 && ls->sock == -2) { /* Shut down in progress */ @@ -525,15 +522,19 @@ vca_accept_task(struct worker *wrk, void *arg) * must reschedule the listening task so it will be * taken up by another thread again. */ - if (!ps->pool->die) + if (!ps->pool->die) { AZ(Pool_Task(wrk->pool, &ps->task, TASK_QUEUE_VCA)); - return; + return; + } } if (!ps->pool->die && DO_DEBUG(DBG_SLOW_ACCEPTOR)) VTIM_sleep(2.0); } + + VSL(SLT_Debug, 0, "XXX Accept thread dies %p", ps); + FREE_OBJ(ps); } /*-------------------------------------------------------------------- diff --git a/bin/varnishd/cache/cache_pool.c b/bin/varnishd/cache/cache_pool.c index 75ed4bd94..22b2a7036 100644 --- a/bin/varnishd/cache/cache_pool.c +++ b/bin/varnishd/cache/cache_pool.c @@ -227,6 +227,7 @@ pool_poolherder(void *priv) free(ppx->a_stat); free(ppx->b_stat); SES_DestroyPool(ppx); + Lck_Delete(&ppx->mtx); FREE_OBJ(ppx); VSC_C_main->pools--; } From guillaume at varnish-software.com Sun Dec 29 14:07:08 2019 From: guillaume at varnish-software.com (Guillaume Quintard) Date: Sun, 29 Dec 2019 14:07:08 +0000 (UTC) Subject: [master] df1c887fb [cci] remove useless defines Message-ID: <20191229140708.1FCFD113078@lists.varnish-cache.org> commit df1c887fb2fc58e4996e82c4ceac6e68a1b95e20 Author: Guillaume Quintard Date: Thu Dec 26 17:31:36 2019 +0000 [cci] remove useless defines diff --git a/.circleci/config.yml b/.circleci/config.yml index 225022123..0d1c135c9 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -345,8 +345,6 @@ jobs: rpmbuild() { command rpmbuild \ --define "_smp_mflags -j10" \ - --define "dist $DIST" \ - --define "_topdir $HOME/rpmbuild" \ --define "_sourcedir $CUR_DIR" \ --define "_srcrpmdir $CUR_DIR/${RESULT_DIR}" \ --define "_rpmdir $CUR_DIR/${RESULT_DIR}" \ From guillaume at varnish-software.com Sun Dec 29 14:07:08 2019 From: guillaume at varnish-software.com (Guillaume Quintard) Date: Sun, 29 Dec 2019 14:07:08 +0000 (UTC) Subject: [master] a65d7e71e [cci] don't checkout the alpine branch Message-ID: <20191229140708.3523611307B@lists.varnish-cache.org> commit a65d7e71ea8d3e2b130fde6973d12f3bf20ae130 Author: Guillaume Quintard Date: Thu Dec 26 17:35:15 2019 +0000 [cci] don't checkout the alpine branch diff --git a/.circleci/config.yml b/.circleci/config.yml index 0d1c135c9..421357a2c 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -221,7 +221,6 @@ jobs: ssh-keyscan -H github.com >> ~/.ssh/known_hosts echo ${CIRCLE_REPOSITORY_URL} git clone --branch=weekly https://github.com/varnishcache/pkg-varnish-cache.git . - git checkout alpine tar cvzf debian.tar.gz debian --dereference tar cvzf redhat.tar.gz redhat --dereference tar cvzf alpine.tar.gz alpine --dereference From guillaume at varnish-software.com Sun Dec 29 14:07:08 2019 From: guillaume at varnish-software.com (Guillaume Quintard) Date: Sun, 29 Dec 2019 14:07:08 +0000 (UTC) Subject: [master] 281138580 [cci] try to order jobs sensibly Message-ID: <20191229140708.541FD11307F@lists.varnish-cache.org> commit 2811385803c9bd0445c754f96f120dd43287f03e Author: Guillaume Quintard Date: Thu Dec 26 17:42:45 2019 +0000 [cci] try to order jobs sensibly diff --git a/.circleci/config.yml b/.circleci/config.yml index 421357a2c..e363654fe 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -75,115 +75,6 @@ commands: tar \ sudo jobs: - build_debs: - parameters: - release: - description: the release name (stretch|buster|xenial|bionic) - default: "" - type: string - dist: - description: the Linux distribution (debian|ubuntu) - default: "" - type: string - description: Build << parameters.release >> debs - docker: - - image: << parameters.dist >>:<< parameters.release >> - steps: - - run: - name: Install packaging tools - command: | - apt-get update - apt-get install -y dpkg-dev ca-certificates debhelper devscripts equivs - - attach_workspace: - at: ~/project - - run: - name: Untar debian - command: tar xavf debian.tar.gz - - run: - name: Untar orig - command: tar xavf varnish*.tar.gz --strip 1 - - run: - name: Update changelog version - command: | - if [ -e .is_weekly ]; then - WEEKLY='-weekly' - else - WEEKLY= - fi - VERSION=$(./configure --version | awk 'NR == 1 {print $NF}')$WEEKLY~<< parameters.release >> - sed -i -e "s|@VERSION@|$VERSION|" "debian/changelog" - - run: - name: Install Build-Depends packages - command: | - export DEBIAN_FRONTEND=noninteractive - export DEBCONF_NONINTERACTIVE_SEEN=true - yes | mk-build-deps --install debian/control || true - - run: - name: Build the packages - command: | - dpkg-buildpackage -us -uc -j16 - - run: - name: Import the packages into the workspace - command: | - mkdir debs - mv ../*.deb ../*.dsc debs/ - - persist_to_workspace: - root: . - paths: - - debs/varnish*.deb - - debs/varnish*.dsc - build_apks: - description: Build alpine apks - docker: - - image: alpine - working_directory: /workspace - steps: - - run: - name: Install certificates to mount the workspace, and tar - command: | - apk update - apk add -q ca-certificates tar - - attach_workspace: - at: /workspace - - run: - name: Untar alpine - command: | - tar xavf alpine.tar.gz --strip 1 - - run: - name: Install sdk, add user - command: | - apk add alpine-sdk - adduser -D builder - echo "builder ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers - addgroup builder abuild - mkdir -p /var/cache/distfiles - chmod a+w /var/cache/distfiles - - run: - name: Generate key - command: | - su builder -c "abuild-keygen -nai" - - run: - name: Fix APKBUILD's variables - command: | - tar xavf varnish-*.tar.gz - VERSION=$(varnish-*/configure --version | awk 'NR == 1 {print $NF}') - sed -i "s/@VERSION@/$VERSION/" APKBUILD - rm -rf varnish-*/ - - run: - name: Fix checksums, build - command: | - chown builder -R /workspace - su builder -c "abuild checksum" - su builder -c "abuild -r" - - run: - name: Fix the APKBUILD's version - command: | - mkdir apks - cp /home/builder/packages/x86_64/*.apk apks - - persist_to_workspace: - root: . - paths: - - apks/*.apk dist: docker: - image: centos:7 @@ -278,19 +169,115 @@ jobs: sudo -u varnish \ --preserve-env=ASAN_OPTIONS,LSAN_OPTIONS,TSAN_OPTIONS,UBSAN_OPTIONS \ make distcheck VERBOSE=1 -j 12 -k - push_packages: + build_apks: + description: Build alpine apks docker: - - image: centos:7 + - image: alpine + working_directory: /workspace steps: + - run: + name: Install certificates to mount the workspace, and tar + command: | + apk update + apk add -q ca-certificates tar + - attach_workspace: + at: /workspace + - run: + name: Untar alpine + command: | + tar xavf alpine.tar.gz --strip 1 + - run: + name: Install sdk, add user + command: | + apk add alpine-sdk + adduser -D builder + echo "builder ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers + addgroup builder abuild + mkdir -p /var/cache/distfiles + chmod a+w /var/cache/distfiles + - run: + name: Generate key + command: | + su builder -c "abuild-keygen -nai" + - run: + name: Fix APKBUILD's variables + command: | + tar xavf varnish-*.tar.gz + VERSION=$(varnish-*/configure --version | awk 'NR == 1 {print $NF}') + sed -i "s/@VERSION@/$VERSION/" APKBUILD + rm -rf varnish-*/ + - run: + name: Fix checksums, build + command: | + chown builder -R /workspace + su builder -c "abuild checksum" + su builder -c "abuild -r" + - run: + name: Fix the APKBUILD's version + command: | + mkdir apks + cp /home/builder/packages/x86_64/*.apk apks + - persist_to_workspace: + root: . + paths: + - apks/*.apk + build_debs: + parameters: + release: + description: the release name (stretch|buster|xenial|bionic) + default: "" + type: string + dist: + description: the Linux distribution (debian|ubuntu) + default: "" + type: string + description: Build << parameters.release >> debs + docker: + - image: << parameters.dist >>:<< parameters.release >> + steps: + - run: + name: Install packaging tools + command: | + apt-get update + apt-get install -y dpkg-dev ca-certificates debhelper devscripts equivs - attach_workspace: at: ~/project - run: - name: Tar the packages + name: Untar debian + command: tar xavf debian.tar.gz + - run: + name: Untar orig + command: tar xavf varnish*.tar.gz --strip 1 + - run: + name: Update changelog version command: | - tar cvzf packages.tar.gz rpms/*.rpm debs/*.deb debs/*.dsc apks/*.apk - - store_artifacts: - destination: packages.tar.gz - path: packages.tar.gz + if [ -e .is_weekly ]; then + WEEKLY='-weekly' + else + WEEKLY= + fi + VERSION=$(./configure --version | awk 'NR == 1 {print $NF}')$WEEKLY~<< parameters.release >> + sed -i -e "s|@VERSION@|$VERSION|" "debian/changelog" + - run: + name: Install Build-Depends packages + command: | + export DEBIAN_FRONTEND=noninteractive + export DEBCONF_NONINTERACTIVE_SEEN=true + yes | mk-build-deps --install debian/control || true + - run: + name: Build the packages + command: | + dpkg-buildpackage -us -uc -j16 + - run: + name: Import the packages into the workspace + command: | + mkdir debs + mv ../*.deb ../*.dsc debs/ + - persist_to_workspace: + root: . + paths: + - debs/varnish*.deb + - debs/varnish*.dsc build_centos_7: docker: - image: centos:7 @@ -361,7 +348,19 @@ jobs: paths: - rpms/*.rpm - rpms/*/*.rpm - + push_packages: + docker: + - image: centos:7 + steps: + - attach_workspace: + at: ~/project + - run: + name: Tar the packages + command: | + tar cvzf packages.tar.gz rpms/*.rpm debs/*.deb debs/*.dsc apks/*.apk + - store_artifacts: + destination: packages.tar.gz + path: packages.tar.gz pkg_req: &pkg_req requires: - dist From guillaume at varnish-software.com Sun Dec 29 14:07:08 2019 From: guillaume at varnish-software.com (Guillaume Quintard) Date: Sun, 29 Dec 2019 14:07:08 +0000 (UTC) Subject: [master] 8d15affe3 [cci] no need for rst2pdf Message-ID: <20191229140708.70850113083@lists.varnish-cache.org> commit 8d15affe306826271e49b3ab913aca9bba00974b Author: Guillaume Quintard Date: Thu Dec 26 17:49:39 2019 +0000 [cci] no need for rst2pdf diff --git a/.circleci/config.yml b/.circleci/config.yml index e363654fe..61c73fab6 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -26,7 +26,6 @@ commands: make \ pkg-config \ python3-sphinx \ - rst2pdf \ sudo centos_install_build_deps: description: Install build dependencies @@ -49,7 +48,6 @@ commands: pcre-devel \ python3 \ python-sphinx \ - rst2pdf \ sudo alpine_install_build_deps: description: Install build dependencies From guillaume at varnish-software.com Sun Dec 29 14:07:08 2019 From: guillaume at varnish-software.com (Guillaume Quintard) Date: Sun, 29 Dec 2019 14:07:08 +0000 (UTC) Subject: [master] 1b45abda4 [cci] make is part of build essential Message-ID: <20191229140708.8A5B5113087@lists.varnish-cache.org> commit 1b45abda468b0af7c4867cf56ba45535483c34ef Author: Guillaume Quintard Date: Thu Dec 26 17:52:46 2019 +0000 [cci] make is part of build essential diff --git a/.circleci/config.yml b/.circleci/config.yml index 61c73fab6..479c3e40d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -23,7 +23,6 @@ commands: libpcre3-dev \ libtool \ libunwind-dev \ - make \ pkg-config \ python3-sphinx \ sudo From guillaume at varnish-software.com Sun Dec 29 14:07:08 2019 From: guillaume at varnish-software.com (Guillaume Quintard) Date: Sun, 29 Dec 2019 14:07:08 +0000 (UTC) Subject: [master] 6fa7db979 [cci] adjust the release tag to the dist macro Message-ID: <20191229140708.A710911308B@lists.varnish-cache.org> commit 6fa7db979bc1efc676232498703437769743f19c Author: Guillaume Quintard Date: Thu Dec 26 17:57:03 2019 +0000 [cci] adjust the release tag to the dist macro diff --git a/.circleci/config.yml b/.circleci/config.yml index 479c3e40d..4cf35ed90 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -332,7 +332,7 @@ jobs: --define "_srcrpmdir $CUR_DIR/${RESULT_DIR}" \ --define "_rpmdir $CUR_DIR/${RESULT_DIR}" \ --define "versiontag ${RPMVERSION}" \ - --define "releasetag 0.0." \ + --define "releasetag 0.0" \ --define "srcname $DIST_DIR" \ --define "nocheck 1" \ "$@" From guillaume at varnish-software.com Sun Dec 29 14:07:08 2019 From: guillaume at varnish-software.com (Guillaume Quintard) Date: Sun, 29 Dec 2019 14:07:08 +0000 (UTC) Subject: [master] f799737d5 [cci] parameterize which commits to use Message-ID: <20191229140708.C2EA1113090@lists.varnish-cache.org> commit f799737d5e7f46519d2350006f192a23b76f5319 Author: Guillaume Quintard Date: Sun Dec 29 13:47:35 2019 +0000 [cci] parameterize which commits to use diff --git a/.circleci/config.yml b/.circleci/config.yml index 4cf35ed90..81253d7cd 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,4 +1,12 @@ version: 2.1 + +parameters: + vc-commit: + type: string + default: "HEAD" + pkg-commit: + type: string + default: "weekly" commands: debian_install_build_deps: description: Install build dependencies @@ -81,6 +89,7 @@ jobs: - run: name: Create the dist tarball command: | + git checkout << pipeline.parameters.vc-commit >> # if version is "trunk", it's a weekly tarball, override the version if grep 'AC_INIT.*trunk.*' ./configure.ac; then sed -i -e "s/^AC_INIT.*trunk.*/AC_INIT([Varnish], [$(date +%Y%m%d)], [varnish-dev at varnish-cache.org])/" ./configure.ac @@ -108,7 +117,8 @@ jobs: mkdir -p ~/.ssh ssh-keyscan -H github.com >> ~/.ssh/known_hosts echo ${CIRCLE_REPOSITORY_URL} - git clone --branch=weekly https://github.com/varnishcache/pkg-varnish-cache.git . + git clone https://github.com/varnishcache/pkg-varnish-cache.git . + git checkout << pipeline.parameters.pkg-commit >> tar cvzf debian.tar.gz debian --dereference tar cvzf redhat.tar.gz redhat --dereference tar cvzf alpine.tar.gz alpine --dereference From dridi.boukelmoune at gmail.com Mon Dec 30 10:44:06 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 30 Dec 2019 10:44:06 +0000 (UTC) Subject: [master] f7b2fb2fd Whitespace OCD Message-ID: <20191230104406.BB6B01090C7@lists.varnish-cache.org> commit f7b2fb2fda26693594441b5948824d3db619efda Author: Dridi Boukelmoune Date: Mon Dec 30 11:42:18 2019 +0100 Whitespace OCD diff --git a/bin/varnishd/cache/cache_acceptor.c b/bin/varnishd/cache/cache_acceptor.c index 169ec3d1e..d230b43f3 100644 --- a/bin/varnishd/cache/cache_acceptor.c +++ b/bin/varnishd/cache/cache_acceptor.c @@ -455,7 +455,7 @@ vca_accept_task(struct worker *wrk, void *arg) wa.acceptaddrlen = sizeof wa.acceptaddr; do { i = accept(ls->sock, (void*)&wa.acceptaddr, - &wa.acceptaddrlen); + &wa.acceptaddrlen); } while (i < 0 && errno == EAGAIN && !ps->pool->die); if (i < 0 && ps->pool->die) From dridi.boukelmoune at gmail.com Mon Dec 30 11:01:07 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 30 Dec 2019 11:01:07 +0000 (UTC) Subject: [master] 02a9d3d45 Fix double-free introduced by leak plug Message-ID: <20191230110107.2C9A810973F@lists.varnish-cache.org> commit 02a9d3d45006912e06c95398436c9b2d66677ad5 Author: Dridi Boukelmoune Date: Mon Dec 30 11:59:03 2019 +0100 Fix double-free introduced by leak plug Once all instances of a given test are started all of the remaining tests would free the test data structure, we needed another counter to keep track of ongoing tests so that only the last one to finish would do the single free. diff --git a/bin/varnishtest/vtc_main.c b/bin/varnishtest/vtc_main.c index f0b147265..a080de934 100644 --- a/bin/varnishtest/vtc_main.c +++ b/bin/varnishtest/vtc_main.c @@ -72,6 +72,7 @@ struct vtc_tst { const char *filename; char *script; unsigned ntodo; + unsigned nwait; }; struct vtc_job { @@ -370,7 +371,8 @@ tst_cb(const struct vev *ve, int what) VEV_Stop(vb, jp->evt); free(jp->evt); } - if (jp->tst->ntodo == 0) { + jp->tst->nwait--; + if (jp->tst->nwait == 0) { free(jp->tst->script); FREE_OBJ(jp->tst); } @@ -644,6 +646,7 @@ read_file(const char *fn, int ntest) tp->filename = fn; tp->script = p; tp->ntodo = ntest; + tp->nwait = ntest; VTAILQ_INSERT_TAIL(&tst_head, tp, list); return (0); } From dridi.boukelmoune at gmail.com Mon Dec 30 11:49:06 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 30 Dec 2019 11:49:06 +0000 (UTC) Subject: [master] af9b7f66a Polish VTCP usage in the acceptor setup Message-ID: <20191230114906.9D80510A959@lists.varnish-cache.org> commit af9b7f66a8902e99ca9b5fbdac70cf06495b81f8 Author: Dridi Boukelmoune Date: Mon Dec 30 12:37:12 2019 +0100 Polish VTCP usage in the acceptor setup This adds the errno value to error logs for TCP fast open and accept filters. For FreeBSD errno is cleared prior to calling setsockopt with the hope that it will help understand if it's actually failing with an undocumented ENOENT. Speaking of documentation, the return value is either 0 or -1 for so there's no point in logging that. diff --git a/bin/varnishd/cache/cache_acceptor.c b/bin/varnishd/cache/cache_acceptor.c index d230b43f3..36eddcca7 100644 --- a/bin/varnishd/cache/cache_acceptor.c +++ b/bin/varnishd/cache/cache_acceptor.c @@ -623,14 +623,11 @@ ccf_start(struct cli *cli, const char * const *av, void *priv) VTAILQ_FOREACH(ls, &heritage.socks, list) { CHECK_OBJ_NOTNULL(ls->transport, TRANSPORT_MAGIC); assert (ls->sock > 0); // We know where stdin is - if (cache_param->tcp_fastopen) { - int i; - i = VTCP_fastopen(ls->sock, cache_param->listen_depth); - if (i) - VSL(SLT_Error, 0, - "Kernel TCP Fast Open: sock=%d, ret=%d %s", - ls->sock, i, vstrerror(errno)); - } + if (cache_param->tcp_fastopen && + VTCP_fastopen(ls->sock, cache_param->listen_depth)) + VSL(SLT_Error, 0, + "Kernel TCP Fast Open: sock=%d, errno=%d %s", + ls->sock, errno, vstrerror(errno)); if (listen(ls->sock, cache_param->listen_depth)) { VCLI_SetResult(cli, CLIS_CANT); VCLI_Out(cli, "Listen failed on socket '%s': %s", @@ -638,14 +635,10 @@ ccf_start(struct cli *cli, const char * const *av, void *priv) return; } vca_tcp_opt_set(ls->sock, ls->uds, 1); - if (cache_param->accept_filter) { - int i; - i = VTCP_filter_http(ls->sock); - if (i) - VSL(SLT_Error, 0, - "Kernel filtering: sock=%d, ret=%d %s", - ls->sock, i, vstrerror(errno)); - } + if (cache_param->accept_filter && VTCP_filter_http(ls->sock)) + VSL(SLT_Error, 0, + "Kernel filtering: sock=%d, errno=%d %s", + ls->sock, errno, vstrerror(errno)); } need_test = 1; diff --git a/lib/libvarnish/vtcp.c b/lib/libvarnish/vtcp.c index 625438ab1..1d7ca9a18 100644 --- a/lib/libvarnish/vtcp.c +++ b/lib/libvarnish/vtcp.c @@ -151,10 +151,11 @@ VTCP_filter_http(int sock) int retval; struct accept_filter_arg afa; - memset(&afa, 0, sizeof(afa)); - strcpy(afa.af_name, "httpready"); + memset(&afa, 0, sizeof afa); + bprintf(afa.af_name, "httpready"); + errno = 0; retval = setsockopt(sock, SOL_SOCKET, SO_ACCEPTFILTER, - &afa, sizeof afa ); + &afa, sizeof afa); return (retval); } @@ -166,7 +167,7 @@ VTCP_filter_http(int sock) int retval; int defer = 1; - retval = setsockopt(sock, SOL_TCP,TCP_DEFER_ACCEPT, + retval = setsockopt(sock, SOL_TCP, TCP_DEFER_ACCEPT, &defer, sizeof defer); return (retval); } From dridi.boukelmoune at gmail.com Mon Dec 30 12:20:06 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 30 Dec 2019 12:20:06 +0000 (UTC) Subject: [master] 3e17b28a7 Stabilize r1804 Message-ID: <20191230122006.E71C910C4A1@lists.varnish-cache.org> commit 3e17b28a794367e1352bfddf2d15460091b76590 Author: Dridi Boukelmoune Date: Mon Dec 30 13:16:07 2019 +0100 Stabilize r1804 It was a bit racy in the sense that the logs for c2 could be committed before the c1 logs. I hardened the expectations a bit in the process. diff --git a/bin/varnishtest/tests/r01804.vtc b/bin/varnishtest/tests/r01804.vtc index 983091d88..7fcbaa1e6 100644 --- a/bin/varnishtest/tests/r01804.vtc +++ b/bin/varnishtest/tests/r01804.vtc @@ -6,18 +6,15 @@ server s1 { } -start -varnish v1 -arg "-afoo=127.0.0.1:0,PROXY" -vcl+backend { -} -start +varnish v1 -arg "-a foo=127.0.0.1:0,PROXY" +varnish v1 -arg "-p thread_pools=1" +varnish v1 -vcl+backend "" -start -logexpect l1 -v v1 -d 0 -g session { - expect * * Begin {^sess .* PROXY$} - expect * = SessOpen {^.* foo .*} - expect * = Proxy {^1 } - expect * * Begin {^req} - expect * * Begin {^sess .* PROXY$} - expect * = SessOpen {^.* foo .*} - expect * = Proxy {^2 } - expect * * Begin {^req} +logexpect l1 -v v1 -g session { + expect * 1000 Begin {^sess .* PROXY$} + expect 0 = SessOpen {^.* foo .*} + expect 0 = Proxy {^1 } + expect * 1001 Begin {^req} } -start client c1 { @@ -26,6 +23,15 @@ client c1 { rxresp } -run +logexpect l1 -wait + +logexpect l2 -v v1 -g session { + expect * 1003 Begin {^sess .* PROXY$} + expect 0 = SessOpen {^.* foo .*} + expect 0 = Proxy {^2 } + expect * 1004 Begin {^req} +} -start + client c2 { # good IPv4 sendhex "0d 0a 0d 0a 00 0d 0a 51 55 49 54 0a" @@ -38,4 +44,4 @@ client c2 { rxresp } -run -logexpect l1 -wait +logexpect l2 -wait From phk at FreeBSD.org Mon Dec 30 12:52:06 2019 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 30 Dec 2019 12:52:06 +0000 (UTC) Subject: [master] e95fda1db Fix compilation on certain llvm versions Message-ID: <20191230125206.D185E10CF87@lists.varnish-cache.org> commit e95fda1dbabdcb46547c733e5c744b4e7422a56e Author: Poul-Henning Kamp Date: Mon Dec 30 12:51:42 2019 +0000 Fix compilation on certain llvm versions diff --git a/lib/libvarnish/vtcp.c b/lib/libvarnish/vtcp.c index 1d7ca9a18..a7ed8f4f9 100644 --- a/lib/libvarnish/vtcp.c +++ b/lib/libvarnish/vtcp.c @@ -152,7 +152,7 @@ VTCP_filter_http(int sock) struct accept_filter_arg afa; memset(&afa, 0, sizeof afa); - bprintf(afa.af_name, "httpready"); + bprintf(afa.af_name, "%s", "httpready"); errno = 0; retval = setsockopt(sock, SOL_SOCKET, SO_ACCEPTFILTER, &afa, sizeof afa); From dridi.boukelmoune at gmail.com Mon Dec 30 15:44:07 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 30 Dec 2019 15:44:07 +0000 (UTC) Subject: [master] 34d38f0b0 Expose the master and worker PIDs via the CLI Message-ID: <20191230154407.4AFF71105E1@lists.varnish-cache.org> commit 34d38f0b006482b58fc6b7bf3dc30ced6b7e2a66 Author: Dridi Boukelmoune Date: Mon Dec 30 16:38:05 2019 +0100 Expose the master and worker PIDs via the CLI The change in u00011.vtc is the result of having two commands starting with "pi", breaking auto-completion. Fortunately "pin\t" still does the trick. diff --git a/bin/varnishd/mgt/mgt_child.c b/bin/varnishd/mgt/mgt_child.c index ca6037706..da85d048b 100644 --- a/bin/varnishd/mgt/mgt_child.c +++ b/bin/varnishd/mgt/mgt_child.c @@ -666,6 +666,31 @@ MCH_Running(void) * CLI commands */ +static void v_matchproto_(cli_func_t) +mch_pid(struct cli *cli, const char * const *av, void *priv) +{ + + (void)av; + (void)priv; + VCLI_Out(cli, "Master: %10jd\n", (intmax_t)getpid()); + if (!MCH_Running()) + return; + VCLI_Out(cli, "Worker: %10jd\n", (intmax_t)child_pid); +} + +static void v_matchproto_(cli_func_t) +mch_pid_json(struct cli *cli, const char * const *av, void *priv) +{ + + (void)priv; + VCLI_JSON_begin(cli, 2, av); + VCLI_Out(cli, ",\n {\"master\": %jd", (intmax_t)getpid()); + if (MCH_Running()) + VCLI_Out(cli, ", \"worker\": %jd", (intmax_t)child_pid); + VCLI_Out(cli, "}"); + VCLI_JSON_end(cli); +} + static void v_matchproto_(cli_func_t) mch_cli_server_start(struct cli *cli, const char * const *av, void *priv) { @@ -725,6 +750,7 @@ static struct cli_proto cli_mch[] = { { CLICMD_PANIC_SHOW, "", mch_cli_panic_show, mch_cli_panic_show_json }, { CLICMD_PANIC_CLEAR, "", mch_cli_panic_clear }, + { CLICMD_PID, "", mch_pid, mch_pid_json }, { NULL } }; diff --git a/bin/varnishtest/tests/b00071.vtc b/bin/varnishtest/tests/b00071.vtc new file mode 100644 index 000000000..e69a92510 --- /dev/null +++ b/bin/varnishtest/tests/b00071.vtc @@ -0,0 +1,9 @@ +varnishtest "varnish-cli pid command" + +varnish v1 -cliexpect "^Master: +[0-9]+\n$" pid +varnish v1 -cliok "pid -j" + +varnish v1 -vcl {backend be none;} -start + +varnish v1 -cliexpect "^Master: +[0-9]+\nWorker: +[0-9]+\n$" pid +varnish v1 -cliok "pid -j" diff --git a/bin/varnishtest/tests/u00011.vtc b/bin/varnishtest/tests/u00011.vtc index 25ddf8f1a..52d222bd4 100644 --- a/bin/varnishtest/tests/u00011.vtc +++ b/bin/varnishtest/tests/u00011.vtc @@ -18,7 +18,7 @@ process p1 -log {varnishadm -n ${v1_name}} -start process p1 -expect-text 0 1 "Type 'quit' to close CLI session." -process p1 -write "pi\t\r" +process p1 -write "pin\t\r" process p1 -expect-text 0 1 "PONG" diff --git a/include/tbl/cli_cmds.h b/include/tbl/cli_cmds.h index 3493736c0..7ad0817d8 100644 --- a/include/tbl/cli_cmds.h +++ b/include/tbl/cli_cmds.h @@ -400,6 +400,14 @@ CLI_CMD(STORAGE_LIST, 0, 0 ) +CLI_CMD(PID, + "pid", + "pid [-j]", + "Show the pid of the master process, and the worker if it's running.", + " ``-j`` specifies JSON output.", + 0, 0 +) + #undef CLI_CMD /*lint -restore */ From dridi.boukelmoune at gmail.com Mon Dec 30 17:08:05 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 30 Dec 2019 17:08:05 +0000 (UTC) Subject: [master] 28956a650 Make it possible to see how t02015 fails Message-ID: <20191230170805.B21BB1120BD@lists.varnish-cache.org> commit 28956a65095ff0e0a2e12983fddbf77689d6c7f1 Author: Dridi Boukelmoune Date: Mon Dec 30 18:05:13 2019 +0100 Make it possible to see how t02015 fails I couldn't reproduce the failure reported by VTEST but hopefully this will shed some light next time it happens. Better diff with the --word-diff option. diff --git a/bin/varnishtest/tests/t02015.vtc b/bin/varnishtest/tests/t02015.vtc index 3da5c24d4..2d43de79c 100644 --- a/bin/varnishtest/tests/t02015.vtc +++ b/bin/varnishtest/tests/t02015.vtc @@ -36,14 +36,12 @@ client c1 { } -run } -run -shell { +shell -match "^12345$" { varnishncsa -n ${v1_name} -F '%{VSL:ReqAcct[5]}x' -d \ - -q 'ReqHeader:stream == 1' | - grep 12345 + -q 'ReqHeader:stream == 1' } -shell { +shell -match "^1000$" { varnishncsa -n ${v1_name} -F '%{VSL:ReqAcct[5]}x' -d \ - -q 'ReqHeader:stream == 3' | - grep 1000 + -q 'ReqHeader:stream == 3' } From dridi.boukelmoune at gmail.com Tue Dec 31 10:05:10 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 31 Dec 2019 10:05:10 +0000 (UTC) Subject: [master] 5604bdaa6 Add a hint in the accept_filter documentation Message-ID: <20191231100510.33205102247@lists.varnish-cache.org> commit 5604bdaa6730d4372a7308746ef4b5cf9ca4d073 Author: Dridi Boukelmoune Date: Tue Dec 31 09:14:26 2019 +0100 Add a hint in the accept_filter documentation Trying to understand why I was seeing setsockopt fail on FreeBSD VTEST boxes and why it failed with an undocumented ENOENT I finally realized that I needed to kldload accf_http beforehand. The ENOENT errno was probably a result of accept_filter code not finding a kernel module for "httpready". diff --git a/include/tbl/params.h b/include/tbl/params.h index 272829a10..61fa9a03a 100644 --- a/include/tbl/params.h +++ b/include/tbl/params.h @@ -48,7 +48,8 @@ PARAM( /* units */ "bool", /* flags */ XYZZY, /* s-text */ - "Enable kernel accept-filters.", + "Enable kernel accept-filters. This may require a kernel module to " + "be loaded to have an effect when enabled.", /* l-text */ NULL, /* func */ NULL ) diff --git a/lib/libvarnish/vtcp.c b/lib/libvarnish/vtcp.c index a7ed8f4f9..763db1ee6 100644 --- a/lib/libvarnish/vtcp.c +++ b/lib/libvarnish/vtcp.c @@ -153,7 +153,6 @@ VTCP_filter_http(int sock) memset(&afa, 0, sizeof afa); bprintf(afa.af_name, "%s", "httpready"); - errno = 0; retval = setsockopt(sock, SOL_SOCKET, SO_ACCEPTFILTER, &afa, sizeof afa); return (retval); From dridi.boukelmoune at gmail.com Tue Dec 31 10:05:10 2019 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 31 Dec 2019 10:05:10 +0000 (UTC) Subject: [master] ef420233e Tweak test cases to work with or disable accept_filter Message-ID: <20191231100510.479A410224A@lists.varnish-cache.org> commit ef420233e61c38e8f446a48a6da8d6aa7d8b5eef Author: Dridi Boukelmoune Date: Tue Dec 31 10:45:50 2019 +0100 Tweak test cases to work with or disable accept_filter The test cases disabling the accept_filter parameter are those involving GET requests with a body that are meant to be cached, and one test case covering OOB data. The rest uses the POST method since the httpready filter will only let syntactically correct GET or HEAD methods pass to the application. Apparently FreeBSD's httpready filter considers that a GET request with a body is syntactically incorrect although this is not specifically said in the manual. The HTTP specification doesn't forbid such requests and they are hard to justify considering the semantics of GET and HEAD, but there are products in the wild relying on that. On the other hand GET\r\n\r\n isn't considered malformed, see r01881.vtc. We don't need the dataready filter on FreeBSD for listen addresses that expect a PROXY protocol header, the httpready filter will effectively work like that if the request doesn't look like a GET or a HEAD. diff --git a/bin/varnishtest/tests/b00037.vtc b/bin/varnishtest/tests/b00037.vtc index 7112cff95..1b7c31235 100644 --- a/bin/varnishtest/tests/b00037.vtc +++ b/bin/varnishtest/tests/b00037.vtc @@ -1,12 +1,6 @@ varnishtest "Error on multiple Host headers" -server s1 { - rxreq - txresp -} -start - -varnish v1 -vcl+backend { -} -start +varnish v1 -vcl {backend be none;} -start client c1 { txreq -hdr "Host: foo" -hdr "Host: bar" @@ -17,7 +11,7 @@ client c1 { varnish v1 -expect client_req_400 == 1 client c1 { - txreq -hdr "Content-Length: 12" -bodylen 12 + txreq -method POST -hdr "Content-Length: 12" -bodylen 12 rxresp expect resp.status == 400 } -run diff --git a/bin/varnishtest/tests/b00046.vtc b/bin/varnishtest/tests/b00046.vtc index 2c60f6630..abf5663d5 100644 --- a/bin/varnishtest/tests/b00046.vtc +++ b/bin/varnishtest/tests/b00046.vtc @@ -12,6 +12,7 @@ server s1 { send_urgent " " } -start +varnish v1 -cliok "param.set accept_filter off" varnish v1 -vcl+backend {} -start client c1 { diff --git a/bin/varnishtest/tests/b00069.vtc b/bin/varnishtest/tests/b00069.vtc index 2167c9483..9d4145dc9 100644 --- a/bin/varnishtest/tests/b00069.vtc +++ b/bin/varnishtest/tests/b00069.vtc @@ -2,20 +2,20 @@ varnishtest "HTTP/1 parsing checks" # Some tricky requests that have been known to cause parsing errors in the past. -server s1 { +server s1 -repeat 3 { rxreq txresp } -start -varnish v1 -vcl+backend { -} -start +varnish v1 -vcl+backend "" -start # This test checks a bug that was dependent on the contents of the buffer left behind # by the previous request client c1 { - send "GET / HTTP/1.1\r\nHost: asdf.com\r\nFoo: baar\r\n\r\n\r\n\r\n\r\n" + send "POST / HTTP/1.1\r\nHost: asdf.com\r\nFoo: baar\r\n\r\n\r\n\r\n\r\n" rxresp - send "GET / HTTP/1.1\r\nHost: asdf.com\r\nAsdf: b\n \r\n\r\nSj\r" + expect resp.status == 200 + send "POST / HTTP/1.1\r\nHost: asdf.com\r\nAsdf: b\n \r\n\r\nSj\r" rxresp expect resp.status == 200 } -run @@ -23,7 +23,7 @@ client c1 { # This tests that the line continuation handling doesn't clear out the end of headers # [CR]LF client c1 { - send "GET / HTTP/1.1\r\nHost: asdf.com\r\nAsdf: b\n \r\n\r\nSj" + send "POST / HTTP/1.1\r\nHost: asdf.com\r\nAsdf: b\n \r\n\r\nSj" rxresp expect resp.status == 200 } -run diff --git a/bin/varnishtest/tests/l00002.vtc b/bin/varnishtest/tests/l00002.vtc index 82296bc66..7d6a03cf7 100644 --- a/bin/varnishtest/tests/l00002.vtc +++ b/bin/varnishtest/tests/l00002.vtc @@ -23,11 +23,11 @@ varnish v1 -vcl+backend { } -start # Request (1001): -# GET /1 HTTP/1.1\r\n 17 bytes +# POST /1 HTTP/1.1\r\n 18 bytes # Host: foo\r\n 11 bytes # Content-Length: 4\r\n 19 bytes # \r\n 2 bytes -# Total: 49 bytes +# Total: 50 bytes # Response: # HTTP/1.1 200 OK\r\n 17 bytes # Content-Length: 1000\r\n 22 bytes @@ -72,7 +72,7 @@ varnish v1 -vcl+backend { # Total: 28 bytes logexpect l1 -v v1 -g session { expect * 1001 Begin "^req .* rxreq" - expect * = ReqAcct "^49 4 53 87 1000 1087$" + expect * = ReqAcct "^50 4 54 87 1000 1087$" expect 0 = End expect * 1003 Begin "^req .* rxreq" expect * = ReqAcct "^30 0 30 87 2000 2087$" @@ -87,7 +87,7 @@ logexpect l1 -v v1 -g session { # Request 1001 client c1 { - txreq -url "/1" -hdr "Host: foo" -body "asdf" + txreq -method POST -url "/1" -hdr "Host: foo" -body "asdf" rxresp expect resp.status == 200 @@ -104,7 +104,7 @@ client c1 { logexpect l1 -wait -varnish v1 -expect s_req_hdrbytes == 116 +varnish v1 -expect s_req_hdrbytes == 117 varnish v1 -expect s_req_bodybytes == 4 varnish v1 -expect s_resp_hdrbytes == 289 varnish v1 -expect s_resp_bodybytes == 5000 diff --git a/bin/varnishtest/tests/r01881.vtc b/bin/varnishtest/tests/r01881.vtc index 5c3ab4dde..7a4977bbb 100644 --- a/bin/varnishtest/tests/r01881.vtc +++ b/bin/varnishtest/tests/r01881.vtc @@ -17,7 +17,7 @@ varnish v1 -vcl+backend { } -start client c1 { - txreq -body "foobar" + txreq -method POST -body "foobar" rxresp expect resp.status == 200 } -run diff --git a/bin/varnishtest/tests/r01914.vtc b/bin/varnishtest/tests/r01914.vtc index 2414daddb..753051893 100644 --- a/bin/varnishtest/tests/r01914.vtc +++ b/bin/varnishtest/tests/r01914.vtc @@ -13,6 +13,7 @@ varnish v1 \ -arg "-s default,1MB" \ -arg "-s default,1MB" \ -arg "-s Transient=default" \ + -arg "-p accept_filter=off" \ -syntax 4.0 \ -vcl+backend { import std; diff --git a/bin/varnishtest/tests/r02105.vtc b/bin/varnishtest/tests/r02105.vtc index 5834c1197..4dd2c9a28 100644 --- a/bin/varnishtest/tests/r02105.vtc +++ b/bin/varnishtest/tests/r02105.vtc @@ -9,6 +9,7 @@ server s1 { txresp } -start +varnish v1 -cliok "param.set accept_filter off" varnish v1 -vcl+backend { sub vcl_backend_response { set beresp.ttl = 0.5s; diff --git a/bin/varnishtest/tests/r02266.vtc b/bin/varnishtest/tests/r02266.vtc index 5fed4d676..c0f4c9d18 100644 --- a/bin/varnishtest/tests/r02266.vtc +++ b/bin/varnishtest/tests/r02266.vtc @@ -16,6 +16,7 @@ server s1 { send "line2\n" } -start +varnish v1 -cliok "param.set accept_filter off" varnish v1 -vcl+backend { sub vcl_backend_response { set beresp.do_stream = false; diff --git a/include/tbl/params.h b/include/tbl/params.h index 61fa9a03a..c2742057d 100644 --- a/include/tbl/params.h +++ b/include/tbl/params.h @@ -49,7 +49,11 @@ PARAM( /* flags */ XYZZY, /* s-text */ "Enable kernel accept-filters. This may require a kernel module to " - "be loaded to have an effect when enabled.", + "be loaded to have an effect when enabled.\n\n" + "Enabling accept_filter may prevent some requests to reach Varnish " + "in the first place. Malformed requests may go unnoticed and not " + "increase the client_req_400 counter. GET or HEAD requests with a " + "body may be blocked altogether.", /* l-text */ NULL, /* func */ NULL )