From varnish-commit at varnish-cache.org Sun Jan 1 23:33:58 2017 From: varnish-commit at varnish-cache.org (varnish-commit at varnish-cache.org) Date: 1 Jan 2017 19:33:58 -0400 Subject: hi! Message-ID: <004a01d26489$05767f28$4a00a4be$@varnish-cache.org> Dear varnish-commit, We are looking for employees working remotely. My name is Lyman, I am the personnel manager of a large International company. Most of the work you can do from home, that is, at a distance. Salary is $2600-$5200. If you are interested in this offer, please visit Our Site d_healthGood day! -------------- next part -------------- An HTML attachment was scrubbed... URL: From varnish-commit at varnish-cache.org Mon Jan 2 10:25:14 2017 From: varnish-commit at varnish-cache.org (varnish-commit at varnish-cache.org) Date: 2 Jan 2017 14:25:14 +0400 Subject: Vacancy #627 Message-ID: <586A30DE.0579.DEE48E@varnish-commit.varnish-cache.org> Dear varnish-commit, We are looking for employees working remotely. My name is Bruno, I am the personnel manager of a large International company. Most of the work you can do from home, that is, at a distance. Salary is $2300-$5300. If you are interested in this offer, please visit Our Site d_healthHave a nice day! -------------- next part -------------- An HTML attachment was scrubbed... URL: From phk at FreeBSD.org Mon Jan 2 10:45:04 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 02 Jan 2017 11:45:04 +0100 Subject: [master] c7e5e1d Simplify the song&dance around our listen sockets, and hopefully make it work more like people would expect. Message-ID: commit c7e5e1d849372393cefd15fb3c30bfbb97704f34 Author: Poul-Henning Kamp Date: Mon Jan 2 10:44:05 2017 +0000 Simplify the song&dance around our listen sockets, and hopefully make it work more like people would expect. Fixes #1991 diff --git a/bin/varnishd/common/heritage.h b/bin/varnishd/common/heritage.h index 6a3d5a0..b7bca53 100644 --- a/bin/varnishd/common/heritage.h +++ b/bin/varnishd/common/heritage.h @@ -31,12 +31,24 @@ struct vsm_sc; struct suckaddr; +struct transport; + +struct listen_arg { + unsigned magic; +#define LISTEN_ARG_MAGIC 0xbb2fc333 + VTAILQ_ENTRY(listen_arg) list; + const char *name; + VTAILQ_HEAD(,listen_sock) socks; + const struct transport *transport; +}; struct listen_sock { unsigned magic; #define LISTEN_SOCK_MAGIC 0x999e4b57 VTAILQ_ENTRY(listen_sock) list; + VTAILQ_ENTRY(listen_sock) arglist; int sock; + const struct listen_arg *arg; char *name; struct suckaddr *addr; const struct transport *transport; diff --git a/bin/varnishd/mgt/mgt.h b/bin/varnishd/mgt/mgt.h index 99b4fc0..30b120a 100644 --- a/bin/varnishd/mgt/mgt.h +++ b/bin/varnishd/mgt/mgt.h @@ -45,9 +45,7 @@ extern int exit_status; /* mgt_acceptor.c */ void MAC_Arg(const char *); -void MAC_Validate(void); void MAC_reopen_sockets(struct cli *); -int MAC_sockets_ready(struct cli *); /* mgt_child.c */ extern pid_t child_pid; diff --git a/bin/varnishd/mgt/mgt_acceptor.c b/bin/varnishd/mgt/mgt_acceptor.c index 70a333a..b0cc47f 100644 --- a/bin/varnishd/mgt/mgt_acceptor.c +++ b/bin/varnishd/mgt/mgt_acceptor.c @@ -49,8 +49,11 @@ #include "vss.h" #include "vtcp.h" +static VTAILQ_HEAD(,listen_arg) listen_args = + VTAILQ_HEAD_INITIALIZER(listen_args); + static int -mac_opensocket(struct listen_sock *ls, struct cli *cli) +mac_opensocket(struct listen_sock *ls) { int fail; @@ -62,9 +65,6 @@ mac_opensocket(struct listen_sock *ls, struct cli *cli) ls->sock = VTCP_bind(ls->addr, NULL); fail = errno; if (ls->sock < 0) { - if (cli != NULL) - VCLI_Out(cli, "Could not get socket %s: %s\n", - ls->name, strerror(errno)); AN(fail); return (fail); } @@ -80,106 +80,87 @@ void MAC_reopen_sockets(struct cli *cli) { struct listen_sock *ls; + int fail; - VJ_master(JAIL_MASTER_PRIVPORT); - VTAILQ_FOREACH(ls, &heritage.socks, list) - (void)mac_opensocket(ls, cli); - VJ_master(JAIL_MASTER_LOW); -} - -/*===================================================================== - * Make sure we have all our sockets (and try once more to get them) - */ - -int -MAC_sockets_ready(struct cli *cli) -{ - int retval = 1; - struct listen_sock *ls; - - VJ_master(JAIL_MASTER_PRIVPORT); VTAILQ_FOREACH(ls, &heritage.socks, list) { - if (ls->sock < 0) - (void)mac_opensocket(ls, cli); - if (ls->sock < 0) - retval = 0; + VJ_master(JAIL_MASTER_PRIVPORT); + fail = mac_opensocket(ls); + VJ_master(JAIL_MASTER_LOW); + if (fail == 0) + continue; + if (cli == NULL) + MGT_complain(C_ERR, + "Could not reopen listen socket %s: %s", + ls->name, strerror(fail)); + else + VCLI_Out(cli, + "Could not reopen listen socket %s: %s\n", + ls->name, strerror(fail)); } - VJ_master(JAIL_MASTER_LOW); - return (retval); } /*--------------------------------------------------------------------*/ -struct mac_help { - unsigned magic; -#define MAC_HELP_MAGIC 0x1e00a9d9 - int good; - const char *name; - const struct transport *transport; -}; - static int __match_proto__(vss_resolved_f) mac_callback(void *priv, const struct suckaddr *sa) { - struct mac_help *mh; + struct listen_arg *la; struct listen_sock *ls; + char abuf[VTCP_ADDRBUFSIZE], pbuf[VTCP_PORTBUFSIZE]; + char nbuf[VTCP_ADDRBUFSIZE+VTCP_PORTBUFSIZE+2]; + int fail; - CAST_OBJ_NOTNULL(mh, priv, MAC_HELP_MAGIC); + CAST_OBJ_NOTNULL(la, priv, LISTEN_ARG_MAGIC); VTAILQ_FOREACH(ls, &heritage.socks, list) { if (!VSA_Compare(sa, ls->addr)) ARGV_ERR("-a arguments %s and %s have same address\n", - ls->name, mh->name); + ls->arg->name, la->name); } ALLOC_OBJ(ls, LISTEN_SOCK_MAGIC); AN(ls); + ls->arg = la; ls->sock = -1; ls->addr = VSA_Clone(sa); AN(ls->addr); - ls->name = strdup(mh->name); + ls->name = strdup(la->name); AN(ls->name); - ls->transport = mh->transport; + ls->transport = la->transport; + VJ_master(JAIL_MASTER_PRIVPORT); + fail = mac_opensocket(ls); + VJ_master(JAIL_MASTER_LOW); + if (fail) { + free(ls->addr); + free(ls->name); + FREE_OBJ(ls); + if (fail != EAFNOSUPPORT) + ARGV_ERR("Could not get socket %s: %s", + la->name, strerror(fail)); + return(0); + } + if (VSA_Port(ls->addr) == 0) { + /* + * If the argv port number is zero, we adopt whatever + * port number this VTCP_bind() found us, as if + * it was specified by the argv. + */ + free(ls->addr); + ls->addr = VTCP_my_suckaddr(ls->sock); + VTCP_myname(ls->sock, abuf, sizeof abuf, + pbuf, sizeof pbuf); + bprintf(nbuf, "%s:%s", abuf, pbuf); + REPLACE(ls->name, nbuf); + } + VTAILQ_INSERT_TAIL(&la->socks, ls, arglist); VTAILQ_INSERT_TAIL(&heritage.socks, ls, list); - mh->good++; return (0); } void -MAC_Validate(void) -{ - struct listen_sock *ls; - int fail; - char abuf[VTCP_ADDRBUFSIZE], pbuf[VTCP_PORTBUFSIZE]; - char nbuf[VTCP_ADDRBUFSIZE+VTCP_PORTBUFSIZE+2]; - - VTAILQ_FOREACH(ls, &heritage.socks, list) { - VJ_master(JAIL_MASTER_PRIVPORT); - fail = mac_opensocket(ls, NULL); - VJ_master(JAIL_MASTER_LOW); - if (fail) - ARGV_ERR("Cannot open socket: %s: %s\n", - ls->name, strerror(fail)); - if (VSA_Port(ls->addr) == 0) { - /* - * If the port number is zero, we adopt whatever - * port number this VTCP_bind() found us, as if - * specified by argument. - */ - free(ls->addr); - ls->addr = VTCP_my_suckaddr(ls->sock); - VTCP_myname(ls->sock, abuf, sizeof abuf, - pbuf, sizeof pbuf); - bprintf(nbuf, "%s:%s", abuf, pbuf); - REPLACE(ls->name, nbuf); - } - } -} - -void MAC_Arg(const char *arg) { char **av; - struct mac_help *mh; + struct listen_arg *la; const char *err; int error; const struct transport *xp; @@ -190,9 +171,11 @@ MAC_Arg(const char *arg) if (av[0] != NULL) ARGV_ERR("%s\n", av[0]); - ALLOC_OBJ(mh, MAC_HELP_MAGIC); - AN(mh); - mh->name = av[1]; + ALLOC_OBJ(la, LISTEN_ARG_MAGIC); + AN(la); + VTAILQ_INIT(&la->socks); + VTAILQ_INSERT_TAIL(&listen_args, la, list); + la->name = av[1]; if (av[2] == NULL) { xp = XPORT_Find("http/1"); @@ -204,11 +187,10 @@ MAC_Arg(const char *arg) ARGV_ERR("Too many sub-arguments to -a(%s)\n", av[2]); } AN(xp); - mh->transport = xp; + la->transport = xp; - error = VSS_resolver(av[1], "80", mac_callback, mh, &err); - if (mh->good == 0 || error) - ARGV_ERR("socket %s didn't resolve\n", av[1]); + error = VSS_resolver(av[1], "80", mac_callback, la, &err); + if (VTAILQ_EMPTY(&la->socks) || error) + ARGV_ERR("Got no socket(s) for %s\n", av[1]); VAV_Free(av); - FREE_OBJ(mh); } diff --git a/bin/varnishd/mgt/mgt_child.c b/bin/varnishd/mgt/mgt_child.c index 5061af5..9a4d955 100644 --- a/bin/varnishd/mgt/mgt_child.c +++ b/bin/varnishd/mgt/mgt_child.c @@ -305,17 +305,6 @@ mgt_launch_child(struct cli *cli) if (child_state != CH_STOPPED && child_state != CH_DIED) return; - if (!MAC_sockets_ready(cli)) { - child_state = CH_STOPPED; - if (cli != NULL) { - VCLI_SetResult(cli, CLIS_CANT); - return; - } - MGT_complain(C_ERR, - "Child start failed: could not open sockets"); - return; - } - child_state = CH_STARTING; /* Open pipe for mgr->child CLI */ diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index 59982ec..9be977b 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -656,6 +656,7 @@ main(int argc, char * const *argv) */ VSUB_closefrom(STDERR_FILENO + 1); mgt_got_fd(STDERR_FILENO); + setbuf(stdout, NULL); setbuf(stderr, NULL); @@ -855,8 +856,6 @@ main(int argc, char * const *argv) if (VTAILQ_EMPTY(&heritage.socks)) MAC_Arg(":80"); - MAC_Validate(); - assert(! VTAILQ_EMPTY(&heritage.socks)); if (!d_flag) { From phk at FreeBSD.org Mon Jan 2 11:42:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 02 Jan 2017 12:42:05 +0100 Subject: [master] 34765a4 Forgot to commit the changes test-case for #1991 Message-ID: commit 34765a4c15356f8513c059313002c01c04b316fa Author: Poul-Henning Kamp Date: Mon Jan 2 11:40:17 2017 +0000 Forgot to commit the changes test-case for #1991 diff --git a/bin/varnishtest/tests/c00003.vtc b/bin/varnishtest/tests/c00003.vtc index 75db736..bc4596f 100644 --- a/bin/varnishtest/tests/c00003.vtc +++ b/bin/varnishtest/tests/c00003.vtc @@ -4,7 +4,7 @@ varnishtest "Check that we fail to start if any listen address does not work" # and are on Linux, ensure /proc/net/ipv4/ip_nonlocal_bind is set to 0. # All bad listen addresses -err_shell "could not be resolved to an IP address" { +err_shell "Error: Could not get socket" { varnishd -F -a "${bad_ip}:0" -b '***' -n ${tmpdir} 2>&1 } From phk at FreeBSD.org Mon Jan 2 12:18:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 02 Jan 2017 13:18:05 +0100 Subject: [master] 6bd790c Clamp vsl_space and vsm_space to 4GB Message-ID: commit 6bd790c58c46f56c499c937a77350403ac8f6d30 Author: Poul-Henning Kamp Date: Mon Jan 2 12:16:09 2017 +0000 Clamp vsl_space and vsm_space to 4GB Fixes: #1750 diff --git a/include/tbl/params.h b/include/tbl/params.h index 0dd1d62..36aa4b0 100644 --- a/include/tbl/params.h +++ b/include/tbl/params.h @@ -1513,7 +1513,7 @@ PARAM( /* name */ vsl_space, /* typ */ bytes, /* min */ "1M", - /* max */ NULL, + /* max */ "4G", /* default */ "80M", /* units */ "bytes", /* flags */ MUST_RESTART, @@ -1530,7 +1530,7 @@ PARAM( /* name */ vsm_space, /* typ */ bytes, /* min */ "1M", - /* max */ NULL, + /* max */ "4G", /* default */ "1M", /* units */ "bytes", /* flags */ MUST_RESTART, From phk at FreeBSD.org Mon Jan 2 13:18:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 02 Jan 2017 14:18:05 +0100 Subject: [master] 071a8d8 Limit vsl_space and vsm_space in a 32bit compatible fashion Message-ID: commit 071a8d840a2d9f13f73af8f9eba5f168519a96fb Author: Poul-Henning Kamp Date: Mon Jan 2 13:17:02 2017 +0000 Limit vsl_space and vsm_space in a 32bit compatible fashion diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index 9be977b..c0bdd6e 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -436,6 +436,9 @@ init_params(struct cli *cli) MCF_ParamConf(MCF_DEFAULT, "http_resp_size", "8k"); MCF_ParamConf(MCF_DEFAULT, "http_req_size", "12k"); MCF_ParamConf(MCF_DEFAULT, "gzip_buffer", "4k"); + } else { + MCF_ParamConf(MCF_MAXIMUM, "vsl_space", "4G"); + MCF_ParamConf(MCF_MAXIMUM, "vsm_space", "4G"); } #if !defined(HAVE_ACCEPT_FILTERS) || defined(__linux) diff --git a/include/tbl/params.h b/include/tbl/params.h index 36aa4b0..d54114d 100644 --- a/include/tbl/params.h +++ b/include/tbl/params.h @@ -1513,7 +1513,7 @@ PARAM( /* name */ vsl_space, /* typ */ bytes, /* min */ "1M", - /* max */ "4G", + /* max */ "2G", /* default */ "80M", /* units */ "bytes", /* flags */ MUST_RESTART, @@ -1530,7 +1530,7 @@ PARAM( /* name */ vsm_space, /* typ */ bytes, /* min */ "1M", - /* max */ "4G", + /* max */ "2G", /* default */ "1M", /* units */ "bytes", /* flags */ MUST_RESTART, From phk at FreeBSD.org Mon Jan 2 13:37:04 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 02 Jan 2017 14:37:04 +0100 Subject: [master] e3b43c6 Ok then: On 32bit 1G will be the max vsl/vsm size. Message-ID: commit e3b43c68fe9842b51104365e3232d46e42df3bfa Author: Poul-Henning Kamp Date: Mon Jan 2 13:36:09 2017 +0000 Ok then: On 32bit 1G will be the max vsl/vsm size. diff --git a/include/tbl/params.h b/include/tbl/params.h index d54114d..09aec90 100644 --- a/include/tbl/params.h +++ b/include/tbl/params.h @@ -1513,7 +1513,7 @@ PARAM( /* name */ vsl_space, /* typ */ bytes, /* min */ "1M", - /* max */ "2G", + /* max */ "1G", /* default */ "80M", /* units */ "bytes", /* flags */ MUST_RESTART, @@ -1530,7 +1530,7 @@ PARAM( /* name */ vsm_space, /* typ */ bytes, /* min */ "1M", - /* max */ "2G", + /* max */ "1G", /* default */ "1M", /* units */ "bytes", /* flags */ MUST_RESTART, From varnish-commit at varnish-cache.org Mon Jan 2 18:19:47 2017 From: varnish-commit at varnish-cache.org (varnish-commit at varnish-cache.org) Date: 2 Jan 2017 18:19:47 +0000 Subject: for CV Message-ID: <462529633562639158325482@varnish-cache.org> Dear varnish-commit, We are looking for employees working remotely. My name is Alonzo, I am the personnel manager of a large International company. Most of the work you can do from home, that is, at a distance. Salary is $2900-$5100. If you are interested in this offer, please visit Our Site d_healthHave a nice day! -------------- next part -------------- An HTML attachment was scrubbed... URL: From phk at FreeBSD.org Mon Jan 2 19:29:04 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 02 Jan 2017 20:29:04 +0100 Subject: [master] af56b5c Set req.backend_hint from the VCL we switch to. Message-ID: commit af56b5c6e1052121733d30f3235317e0c004b772 Author: Poul-Henning Kamp Date: Mon Jan 2 19:27:56 2017 +0000 Set req.backend_hint from the VCL we switch to. Spotted by: dridi Fixes: #2175 diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 16fee9f..f5ea3ae 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -691,8 +691,11 @@ cnt_recv(struct worker *wrk, struct req *req) } VCL_recv_method(req->vcl, wrk, req, NULL, NULL); - if (wrk->handling == VCL_RET_VCL) + if (wrk->handling == VCL_RET_VCL) { + req->director_hint = VCL_DefaultDirector(req->vcl); + AN(req->director_hint); VCL_recv_method(req->vcl, wrk, req, NULL, NULL); + } /* Attempts to cache req.body may fail */ if (req->req_body_status == REQ_BODY_FAIL) { diff --git a/bin/varnishtest/tests/r02175.vtc b/bin/varnishtest/tests/r02175.vtc new file mode 100644 index 0000000..1a33fe4 --- /dev/null +++ b/bin/varnishtest/tests/r02175.vtc @@ -0,0 +1,41 @@ +varnishtest "leak backend" + +server s1 { + rxreq + txresp -hdr "Leak: no" +} -start + +server s2 { + rxreq + txresp -hdr "Leak: yes" +} -start + +varnish v1 -vcl { + backend s1 { .host="${s1_addr}"; .port="${s1_port}"; } + + sub vcl_deliver { + set resp.http.Label = "yes"; + } +} + +varnish v1 -cli "vcl.label lbl vcl1" + +varnish v1 -vcl { + backend s2 { .host="${s2_addr}"; .port="${s2_port}"; } + + sub vcl_recv { + set req.backend_hint = s2; + return (vcl(lbl)); + } + + sub vcl_deliver { + set resp.http.Label = "no"; + } +} -start + +client c1 { + txreq + rxresp + expect resp.http.Label == yes + expect resp.http.Leak == no +} -run From phk at FreeBSD.org Mon Jan 2 21:46:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 02 Jan 2017 22:46:05 +0100 Subject: [master] 4f6df99 Missing newline Message-ID: commit 4f6df996725ba79da474cdd34decc244b52384c9 Author: Poul-Henning Kamp Date: Mon Jan 2 20:12:39 2017 +0000 Missing newline diff --git a/bin/varnishd/mgt/mgt_acceptor.c b/bin/varnishd/mgt/mgt_acceptor.c index b0cc47f..14ce0e6 100644 --- a/bin/varnishd/mgt/mgt_acceptor.c +++ b/bin/varnishd/mgt/mgt_acceptor.c @@ -134,7 +134,7 @@ mac_callback(void *priv, const struct suckaddr *sa) free(ls->name); FREE_OBJ(ls); if (fail != EAFNOSUPPORT) - ARGV_ERR("Could not get socket %s: %s", + ARGV_ERR("Could not get socket %s: %s\n", la->name, strerror(fail)); return(0); } From phk at FreeBSD.org Mon Jan 2 21:46:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 02 Jan 2017 22:46:05 +0100 Subject: [master] 7fcf52f Fix alignment of produced C-source Message-ID: commit 7fcf52f5d8038887779f2b31be38cbccb69facf6 Author: Poul-Henning Kamp Date: Mon Jan 2 20:53:03 2017 +0000 Fix alignment of produced C-source diff --git a/lib/libvcc/vcc_vmod.c b/lib/libvcc/vcc_vmod.c index efc3dcd..af0c7f2 100644 --- a/lib/libvcc/vcc_vmod.c +++ b/lib/libvcc/vcc_vmod.c @@ -210,8 +210,8 @@ vcc_ParseImport(struct vcc *tl) VSB_printf(ifp->ini, "\t\treturn(1);"); /* XXX: zero the function pointer structure ?*/ - VSB_printf(ifp->fin, "\t\tVRT_priv_fini(&vmod_priv_%.*s);", PF(mod)); - VSB_printf(ifp->fin, "\n\t\tVRT_Vmod_Fini(&VGC_vmod_%.*s);", PF(mod)); + VSB_printf(ifp->fin, "\t\tVRT_priv_fini(&vmod_priv_%.*s);\n", PF(mod)); + VSB_printf(ifp->fin, "\t\t\tVRT_Vmod_Fini(&VGC_vmod_%.*s);", PF(mod)); ifp = NULL; From phk at FreeBSD.org Mon Jan 2 21:46:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 02 Jan 2017 22:46:05 +0100 Subject: [master] 3cf5876 Make a backup-copy of vmod shlibs into the working directory (= -n) so that our compiled VCLs are certain to restart/reload even if the VMOD package has been updated in the meantime. Message-ID: commit 3cf587668219166188e0dce304edb0bf8ab346ab Author: Poul-Henning Kamp Date: Mon Jan 2 21:44:18 2017 +0000 Make a backup-copy of vmod shlibs into the working directory (= -n) so that our compiled VCLs are certain to restart/reload even if the VMOD package has been updated in the meantime. Fixes: #2041 diff --git a/bin/varnishd/cache/cache_vrt_vmod.c b/bin/varnishd/cache/cache_vrt_vmod.c index b7d7bab..a938568 100644 --- a/bin/varnishd/cache/cache_vrt_vmod.c +++ b/bin/varnishd/cache/cache_vrt_vmod.c @@ -34,8 +34,11 @@ #include "cache.h" #include +#include +#include #include #include +#include #include "vcli_serve.h" #include "vrt.h" @@ -54,6 +57,7 @@ struct vmod { char *nm; char *path; + char *backup; void *hdl; const void *funcs; int funclen; @@ -61,9 +65,50 @@ struct vmod { static VTAILQ_HEAD(,vmod) vmods = VTAILQ_HEAD_INITIALIZER(vmods); +static int +vrt_vmod_backup_copy(VRT_CTX, const char *nm, const char *fm, const char *to) +{ + int fi, fo; + int ret = 0; + ssize_t sz; + char buf[BUFSIZ]; + + fo = open(to, O_WRONLY | O_CREAT | O_EXCL, 0744); + if (fo < 0 && errno == EEXIST) + return (0); + if (fo < 0) { + VSB_printf(ctx->msg, "Creating copy of vmod %s: %s\n", + nm, strerror(errno)); + return (1); + } + fi = open(fm, O_RDONLY); + if (fi < 0) { + VSB_printf(ctx->msg, "Opening vmod %s from %s: %s\n", + nm, fm, strerror(errno)); + AZ(unlink(to)); + AZ(close(fo)); + return (1); + } + while (1) { + sz = read(fi, buf, sizeof buf); + if (sz == 0) + break; + if (sz < 0 || sz != write(fo, buf, sz)) { + VSB_printf(ctx->msg, "Copying vmod %s: %s\n", + nm, strerror(errno)); + AZ(unlink(to)); + ret = 1; + break; + } + } + AZ(close(fi)); + AZ(close(fo)); + return(ret); +} + int -VRT_Vmod_Init(struct vmod **hdl, void *ptr, int len, const char *nm, - const char *path, const char *file_id, VRT_CTX) +VRT_Vmod_Init(VRT_CTX, struct vmod **hdl, void *ptr, int len, const char *nm, + const char *path, const char *file_id, const char *backup) { struct vmod *v; const struct vmod_data *d; @@ -76,11 +121,18 @@ VRT_Vmod_Init(struct vmod **hdl, void *ptr, int len, const char *nm, AN(hdl); AZ(*hdl); - dlhdl = dlopen(path, RTLD_NOW | RTLD_LOCAL); + /* + * We make a backup copy of the VMOD shlib in our working directory + * and dlopen that, so that we can still restart the VCL's we have + * already compiled when people updated their VMOD package. + */ + if (vrt_vmod_backup_copy(ctx, nm, path, backup)) + return (1); + + dlhdl = dlopen(backup, RTLD_NOW | RTLD_LOCAL); if (dlhdl == NULL) { - VSB_printf(ctx->msg, "Loading VMOD %s from %s:\n", nm, path); + VSB_printf(ctx->msg, "Loading vmod %s from %s:\n", nm, backup); VSB_printf(ctx->msg, "dlopen() failed: %s\n", dlerror()); - VSB_printf(ctx->msg, "Check child process permissions.\n"); return (1); } @@ -90,6 +142,7 @@ VRT_Vmod_Init(struct vmod **hdl, void *ptr, int len, const char *nm, if (v == NULL) { ALLOC_OBJ(v, VMOD_MAGIC); AN(v); + REPLACE(v->backup, backup); v->hdl = dlhdl; @@ -99,7 +152,7 @@ VRT_Vmod_Init(struct vmod **hdl, void *ptr, int len, const char *nm, d->file_id == NULL || strcmp(d->file_id, file_id)) { VSB_printf(ctx->msg, - "Loading VMOD %s from %s:\n", nm, path); + "Loading vmod %s from %s:\n", nm, path); VSB_printf(ctx->msg, "This is no longer the same file seen by" " the VCL-compiler.\n"); @@ -163,6 +216,8 @@ VRT_Vmod_Fini(struct vmod **hdl) return; free(v->nm); free(v->path); + AZ(unlink(v->backup)); + free(v->backup); VTAILQ_REMOVE(&vmods, v, list); VSC_C_main->vmods--; FREE_OBJ(v); diff --git a/include/vrt.h b/include/vrt.h index 8668bca..567c49b 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -314,8 +314,8 @@ void VRT_delete_backend(VRT_CTX, struct director **); int VRT_VSA_GetPtr(const struct suckaddr *sua, const unsigned char ** dst); /* VMOD/Modules related */ -int VRT_Vmod_Init(struct vmod **hdl, void *ptr, int len, const char *nm, - const char *path, const char *file_id, VRT_CTX); +int VRT_Vmod_Init(VRT_CTX, struct vmod **hdl, void *ptr, int len, + const char *nm, const char *path, const char *file_id, const char *backup); void VRT_Vmod_Fini(struct vmod **hdl); /* VCL program related */ diff --git a/lib/libvcc/vcc_vmod.c b/lib/libvcc/vcc_vmod.c index af0c7f2..ef2a9e0 100644 --- a/lib/libvcc/vcc_vmod.c +++ b/lib/libvcc/vcc_vmod.c @@ -196,7 +196,8 @@ vcc_ParseImport(struct vcc *tl) ifp = New_IniFin(tl); - VSB_printf(ifp->ini, "\tif (VRT_Vmod_Init(&VGC_vmod_%.*s,\n", PF(mod)); + VSB_printf(ifp->ini, "\tif (VRT_Vmod_Init(ctx,\n"); + VSB_printf(ifp->ini, "\t &VGC_vmod_%.*s,\n", PF(mod)); VSB_printf(ifp->ini, "\t &Vmod_%.*s_Func,\n", PF(mod)); VSB_printf(ifp->ini, "\t sizeof(Vmod_%.*s_Func),\n", PF(mod)); VSB_printf(ifp->ini, "\t \"%.*s\",\n", PF(mod)); @@ -206,7 +207,9 @@ vcc_ParseImport(struct vcc *tl) AN(vmd); AN(vmd->file_id); VSB_printf(ifp->ini, "\t \"%s\",\n", vmd->file_id); - VSB_printf(ifp->ini, "\t ctx))\n"); + VSB_printf(ifp->ini, "\t \"./_vmod_%.*s.%s\"\n", + PF(mod), vmd->file_id); + VSB_printf(ifp->ini, "\t ))\n"); VSB_printf(ifp->ini, "\t\treturn(1);"); /* XXX: zero the function pointer structure ?*/ diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py index 377605b..dff4403 100755 --- a/lib/libvcc/vmodtool.py +++ b/lib/libvcc/vmodtool.py @@ -467,7 +467,7 @@ class s_event(stanza): def rstfile(self, fo, man): if len(self.doc) != 0: err("Not emitting .RST for $Event %s\n" % - self.event_func) + self.event_func) def hfile(self, fo): fo.write("#ifdef VCL_MET_MAX\n") From phk at FreeBSD.org Tue Jan 3 10:02:06 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 03 Jan 2017 11:02:06 +0100 Subject: [master] 2944ad5 Impose a consistent style on include/tbl headers. Message-ID: commit 2944ad5d0487ba21eeab60db0a223635170b5898 Author: Poul-Henning Kamp Date: Tue Jan 3 09:59:00 2017 +0000 Impose a consistent style on include/tbl headers. Flexelint comments are mandatory, and must bracket all content after the initial block comment. Macros can either be single line "FOO(....)\n" or multiple line "FOO(...\n)\n\n" Any macros defined or called must be #undef'ed by the include/tbl file include/tbl/style.py checks this. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 8a9ec6d..96bbaf9 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -69,7 +69,6 @@ enum req_fsm_nxt { enum body_status { #define BODYSTATUS(U,l) BS_##U, #include "tbl/body_status.h" -#undef BODYSTATUS }; /*--------------------------------------------------------------------*/ @@ -77,7 +76,6 @@ enum body_status { enum req_body_state_e { #define REQ_BODY(U) REQ_BODY_##U, #include -#undef REQ_BODY }; /*--------------------------------------------------------------------*/ @@ -86,7 +84,6 @@ enum sess_close { SC_NULL = 0, #define SESS_CLOSE(nm, stat, err, desc) SC_##nm, #include "tbl/sess_close.h" -#undef SESS_CLOSE }; /*-------------------------------------------------------------------- @@ -95,7 +92,6 @@ enum sess_close { enum { #define SLTH(tag, ind, req, resp, sdesc, ldesc) ind, #include "tbl/vsl_tags_http.h" -#undef SLTH }; /*--------------------------------------------------------------------*/ @@ -138,14 +134,12 @@ enum req_step { R_STP_NONE = 0, #define REQ_STEP(l, u, arg) R_STP_##u, #include "tbl/steps.h" -#undef REQ_STEP }; enum fetch_step { F_STP_NONE = 0, #define FETCH_STEP(l, U, arg) F_STP_##U, #include "tbl/steps.h" -#undef FETCH_STEP }; /*--------------------------------------------------------------------*/ @@ -246,7 +240,6 @@ struct http_conn { struct acct_req { #define ACCT(foo) uint64_t foo; #include "tbl/acct_fields_req.h" -#undef ACCT }; /*--------------------------------------------------------------------*/ @@ -254,7 +247,6 @@ struct acct_req { struct acct_bereq { #define ACCT(foo) uint64_t foo; #include "tbl/acct_fields_bereq.h" -#undef ACCT }; /*--------------------------------------------------------------------*/ @@ -370,7 +362,6 @@ struct storeobj { enum boc_state_e { #define BOC_STATE(U, l) BOS_##U, #include "tbl/boc_state.h" -#undef BOC_STATE }; struct boc { @@ -398,28 +389,22 @@ enum obj_attr { #define OBJ_VARATTR(U, l) OA_##U, #define OBJ_AUXATTR(U, l) OA_##U, #include "tbl/obj_attr.h" -#undef OBJ_AUXATTR -#undef OBJ_VARATTR -#undef OBJ_FIXATTR OA__MAX, }; enum obj_flags { #define OBJ_FLAG(U, l, v) OF_##U = v, #include "tbl/obj_attr.h" -#undef OBJ_FLAG }; enum oc_flags { #define OC_FLAG(U, l, v) OC_F_##U = v, #include "tbl/oc_flags.h" -#undef OC_FLAG }; enum oc_exp_flags { #define OC_EXP_FLAG(U, l, v) OC_EF_##U = v, #include "tbl/oc_exp_flags.h" -#undef OC_EXP_FLAG }; struct objcore { @@ -498,7 +483,6 @@ struct busyobj { #define BO_FLAG(l, r, w, d) unsigned l:1; #include "tbl/bo_flags.h" -#undef BO_FLAG /* Timeouts */ double connect_timeout; @@ -543,7 +527,6 @@ struct req { #define REQ_FLAG(l, r, w, d) unsigned l:1; #include "tbl/req_flags.h" -#undef REQ_FLAG uint16_t err_code; const char *err_reason; @@ -635,7 +618,6 @@ enum sess_attr { #define SESS_ATTR(UP, low, typ, len) SA_##UP, SA_TRANSPORT, #include "tbl/sess_attr.h" -#undef SESS_ATTR SA_LAST }; @@ -817,9 +799,14 @@ uint16_t HTTP1_DissectResponse(struct http_conn *, struct http *resp, const struct http *req); unsigned HTTP1_Write(const struct worker *w, const struct http *hp, const int*); +#define HTTPH_R_PASS (1 << 0) /* Request (c->b) in pass mode */ +#define HTTPH_R_FETCH (1 << 1) /* Request (c->b) for fetch */ +#define HTTPH_A_INS (1 << 2) /* Response (b->o) for insert */ +#define HTTPH_A_PASS (1 << 3) /* Response (b->o) for pass */ + #define HTTPH(a, b, c) extern char b[]; #include "tbl/http_headers.h" -#undef HTTPH + extern const char H__Status[]; extern const char H__Proto[]; extern const char H__Reason[]; @@ -861,7 +848,6 @@ struct VSC_C_lck *Lck_CreateClass(const char *name); #define LOCK(nam) extern struct VSC_C_lck *lck_##nam; #include "tbl/locks.h" -#undef LOCK /* cache_mempool.c */ void MPL_AssertSane(void *item); @@ -989,7 +975,6 @@ enum htc_status_e HTC_RxStuff(struct http_conn *, htc_complete_f *, int SES_Get_##low(const struct sess *sp, typ **dst); \ void SES_Reserve_##low(struct sess *sp, typ **dst); #include "tbl/sess_attr.h" -#undef SESS_ATTR void SES_Set_String_Attr(struct sess *sp, enum sess_attr a, const char *src); const char *SES_Get_String_Attr(const struct sess *sp, enum sess_attr a); @@ -1054,7 +1039,6 @@ const char *VCL_Return_Name(unsigned); void VCL_##l##_method(struct vcl *, struct worker *, struct req *, \ struct busyobj *bo, void *specific); #include "tbl/vcl_returns.h" -#undef VCL_MET_MAC /* cache_vrt.c */ diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c index 55b2a13..58a89bd 100644 --- a/bin/varnishd/cache/cache_backend.c +++ b/bin/varnishd/cache/cache_backend.c @@ -173,7 +173,6 @@ vbe_dir_finish(const struct director *d, struct worker *wrk, bp->vsc->conn--; #define ACCT(foo) bp->vsc->foo += bo->acct.foo; #include "tbl/acct_fields_bereq.h" -#undef ACCT Lck_Unlock(&bp->mtx); bo->htc = NULL; } diff --git a/bin/varnishd/cache/cache_backend_probe.c b/bin/varnishd/cache/cache_backend_probe.c index 6cd51e6..22a5d98 100644 --- a/bin/varnishd/cache/cache_backend_probe.c +++ b/bin/varnishd/cache/cache_backend_probe.c @@ -74,7 +74,6 @@ struct vbp_target { /* Collected statistics */ #define BITMAP(n, c, t, b) uint64_t n; #include "tbl/backend_poll.h" -#undef BITMAP double last; double avg; @@ -116,7 +115,6 @@ vbp_start_poke(struct vbp_target *vt) #define BITMAP(n, c, t, b) \ vt->n <<= 1; #include "tbl/backend_poll.h" -#undef BITMAP vt->last = 0; vt->resp_buf[0] = '\0'; @@ -161,7 +159,6 @@ vbp_update_backend(struct vbp_target *vt) #define BITMAP(n, c, t, b) \ bits[i++] = (vt->n & 1) ? c : '-'; #include "tbl/backend_poll.h" -#undef BITMAP bits[i] = '\0'; if (vt->good >= vt->threshold) { @@ -201,7 +198,6 @@ vbp_reset(struct vbp_target *vt) #define BITMAP(n, c, t, b) \ vt->n = 0; #include "tbl/backend_poll.h" -#undef BITMAP for (u = 0; u < vt->initial; u++) { vbp_start_poke(vt); @@ -429,7 +425,6 @@ vbp_health_one(struct cli *cli, const struct vbp_target *vt) if ((vt->n != 0) || (b)) \ vbp_bitmap(cli, (c), vt->n, (t)); #include "tbl/backend_poll.h" -#undef BITMAP } void diff --git a/bin/varnishd/cache/cache_ban_build.c b/bin/varnishd/cache/cache_ban_build.c index 2ec9544..0a3378a 100644 --- a/bin/varnishd/cache/cache_ban_build.c +++ b/bin/varnishd/cache/cache_ban_build.c @@ -58,7 +58,6 @@ static const struct pvar { } pvars[] = { #define PVAR(a, b, c) { (a), (b), (c) }, #include "tbl/ban_vars.h" -#undef PVAR { 0, 0, 0} }; diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 82e873c..9c4841d 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -967,7 +967,6 @@ vbf_fetch_thread(struct worker *wrk, void *priv) stp = vbf_stp_##l arg; \ break; #include "tbl/steps.h" -#undef FETCH_STEP default: WRONG("Illegal fetch_step"); } diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c index 6c39c3c..23bad44 100644 --- a/bin/varnishd/cache/cache_http.c +++ b/bin/varnishd/cache/cache_http.c @@ -41,7 +41,6 @@ #define HTTPH(a, b, c) char b[] = "*" a ":"; #include "tbl/http_headers.h" -#undef HTTPH const char H__Status[] = "\010:status:"; const char H__Proto[] = "\007:proto:"; @@ -671,7 +670,7 @@ http_DoConnection(struct http *hp) strlen(a) == u && !strncasecmp(a, b, u)) \ return (SC_RX_BAD); #include "tbl/http_headers.h" -#undef HTTPH + /*lint -restore */ v = http_findhdr(hp, u, b); @@ -813,7 +812,6 @@ http_EstimateWS(const struct http *fm, unsigned how) if (((c) & how) && http_IsHdr(&fm->hd[u], (b))) \ continue; #include "tbl/http_headers.h" -#undef HTTPH l += Tlen(fm->hd[u]) + 1L; } return (PRNDUP(l + 1L)); @@ -855,7 +853,6 @@ HTTP_Encode(const struct http *fm, uint8_t *p0, unsigned l, unsigned how) if (((c) & how) && http_IsHdr(&fm->hd[u], (b))) \ continue; #include "tbl/http_headers.h" -#undef HTTPH http_VSLH(fm, u); w = Tlen(fm->hd[u]) + 1L; assert(p + w + 1 <= e); @@ -1049,7 +1046,6 @@ http_filterfields(struct http *to, const struct http *fm, unsigned how) if (((c) & how) && http_IsHdr(&fm->hd[u], (b))) \ continue; #include "tbl/http_headers.h" -#undef HTTPH assert (to->nhd < to->shd); to->hd[to->nhd] = fm->hd[u]; to->hdf[to->nhd] = 0; @@ -1221,5 +1217,4 @@ HTTP_Init(void) #define HTTPH(a, b, c) b[0] = (char)strlen(b + 1); #include "tbl/http_headers.h" -#undef HTTPH } diff --git a/bin/varnishd/cache/cache_lck.c b/bin/varnishd/cache/cache_lck.c index 74cc5b9..4081d60 100644 --- a/bin/varnishd/cache/cache_lck.c +++ b/bin/varnishd/cache/cache_lck.c @@ -250,7 +250,6 @@ Lck_CreateClass(const char *name) #define LOCK(nam) struct VSC_C_lck *lck_##nam; #include "tbl/locks.h" -#undef LOCK void LCK_Init(void) @@ -262,5 +261,4 @@ LCK_Init(void) #endif #define LOCK(nam) lck_##nam = Lck_CreateClass(#nam); #include "tbl/locks.h" -#undef LOCK } diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index 68253ff..eb10008 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -74,7 +74,6 @@ body_status_2str(enum body_status e) switch(e) { #define BODYSTATUS(U,l) case BS_##U: return (#l); #include "tbl/body_status.h" -#undef BODYSTATUS default: return ("?"); } @@ -88,7 +87,6 @@ reqbody_status_2str(enum req_body_state_e e) switch (e) { #define REQ_BODY(U) case REQ_BODY_##U: return("R_BODY_" #U); #include "tbl/req_body.h" -#undef REQ_BODY default: return("?"); } @@ -102,7 +100,6 @@ boc_state_2str(enum boc_state_e e) switch (e) { #define BOC_STATE(U,l) case BOS_##U: return(#l); #include "tbl/boc_state.h" -#undef BOC_STATE default: return ("?"); } @@ -118,7 +115,6 @@ sess_close_2str(enum sess_close sc, int want_desc) #define SESS_CLOSE(nm, s, err, desc) \ case SC_##nm: return(want_desc ? desc : #nm); #include "tbl/sess_close.h" -#undef SESS_CLOSE default: return(want_desc ? "(invalid)" : "INVALID"); } @@ -272,14 +268,13 @@ pan_objcore(struct vsb *vsb, const char *typ, const struct objcore *oc) #define OC_FLAG(U, l, v) \ if (oc->flags & v) { VSB_printf(vsb, "%s" #l, p); p = ", "; } #include "tbl/oc_flags.h" -#undef OC_FLAG VSB_printf(vsb, "},\n"); VSB_printf(vsb, "exp_flags = {"); p = ""; #define OC_EXP_FLAG(U, l, v) \ if (oc->exp_flags & v) { VSB_printf(vsb, "%s" #l, p); p = ", "; } #include "tbl/oc_exp_flags.h" -#undef OC_EXP_FLAG + VSB_printf(vsb, "},\n"); if (oc->boc != NULL) pan_boc(vsb, oc->boc); @@ -378,7 +373,6 @@ pan_busyobj(struct vsb *vsb, const struct busyobj *bo) #define BO_FLAG(l, r, w, d) \ if(bo->l) { VSB_printf(vsb, "%s" #l, p); p = ", "; } #include "tbl/bo_flags.h" -#undef BO_FLAG /*lint -restore */ VSB_printf(vsb, "},\n"); @@ -439,7 +433,6 @@ pan_req(struct vsb *vsb, const struct req *req) switch (req->req_step) { #define REQ_STEP(l, u, arg) case R_STP_##u: stp = "R_STP_" #u; break; #include "tbl/steps.h" -#undef REQ_STEP default: stp = NULL; } if (stp != NULL) @@ -482,7 +475,6 @@ pan_req(struct vsb *vsb, const struct req *req) VSB_indent(vsb, 2); #define REQ_FLAG(l, r, w, d) if(req->l) VSB_printf(vsb, #l ",\n"); #include "tbl/req_flags.h" -#undef REQ_FLAG VSB_indent(vsb, -2); VSB_printf(vsb, "},\n"); diff --git a/bin/varnishd/cache/cache_req.c b/bin/varnishd/cache/cache_req.c index 71d7733..62f8369 100644 --- a/bin/varnishd/cache/cache_req.c +++ b/bin/varnishd/cache/cache_req.c @@ -126,7 +126,6 @@ Req_Release(struct req *req) #define ACCT(foo) \ AZ(req->acct.foo); #include "tbl/acct_fields_req.h" -#undef ACCT AZ(req->vcl); if (req->vsl->wid) diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index f5ea3ae..694260e 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -863,7 +863,6 @@ CNT_Request(struct worker *wrk, struct req *req) nxt = cnt_##l arg; \ break; #include "tbl/steps.h" -#undef REQ_STEP default: WRONG("State engine misfire"); } @@ -903,5 +902,4 @@ CNT_AcctLogCharge(struct dstat *ds, struct req *req) ds->s_##foo += a->foo; \ a->foo = 0; #include "tbl/acct_fields_req.h" -#undef ACCT } diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c index c65ad95..cc148b3 100644 --- a/bin/varnishd/cache/cache_session.c +++ b/bin/varnishd/cache/cache_session.c @@ -142,7 +142,6 @@ ses_reserve_attr(struct sess *sp, enum sess_attr a, void **dst, int sz) } #include "tbl/sess_attr.h" -#undef SESS_ATTR void SES_Set_String_Attr(struct sess *sp, enum sess_attr a, const char *src) @@ -155,7 +154,6 @@ SES_Set_String_Attr(struct sess *sp, enum sess_attr a, const char *src) switch (a) { #define SESS_ATTR(UP, low, typ, len) case SA_##UP: assert(len < 0); break; #include "tbl/sess_attr.h" -#undef SESS_ATTR default: WRONG("wrong sess_attr"); } @@ -173,7 +171,6 @@ SES_Get_String_Attr(const struct sess *sp, enum sess_attr a) switch (a) { #define SESS_ATTR(UP, low, typ, len) case SA_##UP: assert(len < 0); break; #include "tbl/sess_attr.h" -#undef SESS_ATTR default: WRONG("wrong sess_attr"); } @@ -483,7 +480,7 @@ ses_close_acct(enum sess_close reason) i = err; \ break; #include "tbl/sess_close.h" -#undef SESS_CLOSE + default: WRONG("Wrong event in ses_close_acct"); } diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c index 2379d8e..f284575 100644 --- a/bin/varnishd/cache/cache_vcl.c +++ b/bin/varnishd/cache/cache_vcl.c @@ -225,7 +225,6 @@ VCL_Return_Name(unsigned r) case VCL_RET_##U: \ return(#l); #include "tbl/vcl_returns.h" -#undef VCL_RET_MAC default: return (NULL); } @@ -240,7 +239,6 @@ VCL_Method_Name(unsigned m) case VCL_MET_##upper: \ return (#upper); #include "tbl/vcl_returns.h" -#undef VCL_MET_MAC default: return (NULL); } @@ -1056,7 +1054,6 @@ VCL_##func##_method(struct vcl *vcl, struct worker *wrk, \ } #include "tbl/vcl_returns.h" -#undef VCL_MET_MAC /*--------------------------------------------------------------------*/ diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index 4932b26..34be2a2 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -199,7 +199,6 @@ VRT_r_beresp_##field(VRT_CTX) \ VBERESPR##r(l) \ VBERESPW##w(l) #include "tbl/bo_flags.h" -#undef BO_FLAG /*--------------------------------------------------------------------*/ @@ -649,7 +648,6 @@ VRT_r_req_##field(VRT_CTX) \ VREQR##r(l) \ VREQW##w(l) #include "tbl/req_flags.h" -#undef REQ_FLAG /*--------------------------------------------------------------------*/ diff --git a/bin/varnishd/common/params.h b/bin/varnishd/common/params.h index aadb0ea..269f188 100644 --- a/bin/varnishd/common/params.h +++ b/bin/varnishd/common/params.h @@ -43,14 +43,12 @@ enum debug_bits { #define DEBUG_BIT(U, l, d) DBG_##U, #include "tbl/debug_bits.h" -#undef DEBUG_BIT DBG_Reserved }; enum feature_bits { #define FEATURE_BIT(U, l, d, ld) FEATURE_##U, #include "tbl/feature_bits.h" -#undef FEATURE_BIT FEATURE_Reserved }; @@ -73,7 +71,6 @@ struct params { #define ptyp_vsl_reclen unsigned #define PARAM(nm, ty, mi, ma, de, un, fl, st, lt, fn) ptyp_##ty nm; #include -#undef PARAM #undef ptyp_bool #undef ptyp_bytes #undef ptyp_bytes_u diff --git a/bin/varnishd/hpack/vhp.h b/bin/varnishd/hpack/vhp.h index 0f9852d..ae67136 100644 --- a/bin/varnishd/hpack/vhp.h +++ b/bin/varnishd/hpack/vhp.h @@ -69,7 +69,6 @@ enum vhd_ret_e { #define VHD_RET(NAME, VAL, DESC) \ VHD_##NAME = VAL, #include "tbl/vhd_return.h" -#undef VHD_RET }; struct vhd_int { diff --git a/bin/varnishd/hpack/vhp_decode.c b/bin/varnishd/hpack/vhp_decode.c index 0e2d34c..3fa4b5e 100644 --- a/bin/varnishd/hpack/vhp_decode.c +++ b/bin/varnishd/hpack/vhp_decode.c @@ -60,13 +60,11 @@ enum vhd_func_e { #define VHD_FSM_FUNC(NAME, func) \ VHD_F_##NAME, #include "tbl/vhd_fsm_funcs.h" -#undef VHD_FSM_FUNC VHD_F__MAX, }; #define VHD_FSM_FUNC(NAME, func) \ static vhd_state_f func; #include "tbl/vhd_fsm_funcs.h" -#undef VHD_FSM_FUNC /* States */ enum vhd_state_e { @@ -74,7 +72,6 @@ enum vhd_state_e { #define VHD_FSM(STATE, FUNC, arg1, arg2) \ VHD_S_##STATE, #include "tbl/vhd_fsm.h" -#undef VHD_FSM VHD_S__MAX, }; static const struct vhd_state { @@ -86,7 +83,6 @@ static const struct vhd_state { #define VHD_FSM(STATE, FUNC, arg1, arg2) \ [VHD_S_##STATE] = { #STATE, VHD_F_##FUNC, arg1, arg2 }, #include "tbl/vhd_fsm.h" -#undef VHD_FSM }; /* Utility functions */ @@ -508,7 +504,6 @@ VHD_Error(enum vhd_ret_e r) case VHD_##NAME: \ return ("VHD_" #NAME " (" DESC ")"); #include "tbl/vhd_return.h" -#undef VHD_RET default: return ("VHD_UNKNOWN"); } @@ -555,7 +550,6 @@ VHD_Decode(struct vhd_decode *d, struct vht_table *tbl, ret = func(ctx, first); \ break; #include "tbl/vhd_fsm_funcs.h" -#undef VHD_FSM_FUNC default: WRONG("Undefined vhd function"); break; diff --git a/bin/varnishd/hpack/vhp_gen_hufdec.c b/bin/varnishd/hpack/vhp_gen_hufdec.c index a15dbb7..5f86440 100644 --- a/bin/varnishd/hpack/vhp_gen_hufdec.c +++ b/bin/varnishd/hpack/vhp_gen_hufdec.c @@ -47,7 +47,6 @@ static const struct { } huf[] = { #define HPH(c, h, l) { h, l, (char)c }, #include "tbl/vhp_huffman.h" -#undef HPH }; #define HUF_LEN (sizeof huf / sizeof huf[0]) diff --git a/bin/varnishd/hpack/vhp_table.c b/bin/varnishd/hpack/vhp_table.c index 547a446..4f59501 100644 --- a/bin/varnishd/hpack/vhp_table.c +++ b/bin/varnishd/hpack/vhp_table.c @@ -72,7 +72,6 @@ static const struct vht_static static_table[] = { #define HPS(NUM, NAME, VAL) \ { NAME, sizeof NAME - 1, VAL, sizeof VAL - 1 }, #include "tbl/vhp_static.h" -#undef HPS }; #define TBLSIZE(tbl) ((tbl)->size + (tbl)->n * VHT_ENTRY_SIZE) diff --git a/bin/varnishd/http2/cache_http2_deliver.c b/bin/varnishd/http2/cache_http2_deliver.c index 7666a4d..fc0c56e 100644 --- a/bin/varnishd/http2/cache_http2_deliver.c +++ b/bin/varnishd/http2/cache_http2_deliver.c @@ -56,7 +56,6 @@ struct hpack_static { static const struct hpack_static hp_static[] = { #define HPS(I,N,V) [I] = { I, N ":", V }, #include "tbl/vhp_static.h" -#undef HPS { 0, "\377:", ""} // Terminator }; diff --git a/bin/varnishd/mgt/mgt_cli.c b/bin/varnishd/mgt/mgt_cli.c index 84a853a..79f4b90 100644 --- a/bin/varnishd/mgt/mgt_cli.c +++ b/bin/varnishd/mgt/mgt_cli.c @@ -55,12 +55,10 @@ #define CLI_CMD(U,l,s,h,d,m,M) \ const struct cli_cmd_desc CLICMD_##U[1] = {{ l, s, h, d, m, M }}; #include "tbl/cli_cmds.h" -#undef CLI_CMD static const struct cli_cmd_desc *cmds[] = { #define CLI_CMD(U,l,s,h,d,m,M) CLICMD_##U, #include "tbl/cli_cmds.h" -#undef CLI_CMD }; static const int ncmds = sizeof cmds / sizeof cmds[0]; diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index c0bdd6e..5242370 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -102,7 +102,6 @@ mgt_DumpRstVsl(void) #define SLTM(tag, flags, sdesc, ldesc) mgt_sltm(#tag, sdesc, ldesc); #include "tbl/vsl_tags.h" -#undef SLTM } /*--------------------------------------------------------------------*/ diff --git a/bin/varnishd/mgt/mgt_param_bits.c b/bin/varnishd/mgt/mgt_param_bits.c index 100d961..3706f27 100644 --- a/bin/varnishd/mgt/mgt_param_bits.c +++ b/bin/varnishd/mgt/mgt_param_bits.c @@ -111,7 +111,6 @@ bit_tweak(struct vsb *vsb, uint8_t *p, unsigned l, const char *arg, static const char * const VSL_tags[256] = { # define SLTM(foo,flags,sdesc,ldesc) [SLT_##foo] = #foo, # include "tbl/vsl_tags.h" -# undef SLTM NULL }; @@ -156,7 +155,6 @@ tweak_vsl_mask(struct vsb *vsb, const struct parspec *par, const char *arg) static const char * const debug_tags[] = { # define DEBUG_BIT(U, l, d) [DBG_##U] = #l, # include "tbl/debug_bits.h" -# undef DEBUG_BIT NULL }; @@ -196,7 +194,6 @@ tweak_debug(struct vsb *vsb, const struct parspec *par, const char *arg) static const char * const feature_tags[] = { # define FEATURE_BIT(U, l, d, ld) [FEATURE_##U] = #l, # include "tbl/feature_bits.h" -# undef FEATURE_BIT NULL }; diff --git a/bin/varnishd/mgt/mgt_param_tbl.c b/bin/varnishd/mgt/mgt_param_tbl.c index 5d4d451..b25539e 100644 --- a/bin/varnishd/mgt/mgt_param_tbl.c +++ b/bin/varnishd/mgt/mgt_param_tbl.c @@ -46,7 +46,6 @@ struct parspec mgt_parspec[] = { #define PARAM(nm, ty, mi, ma, de, un, fl, st, lt, fn) \ { #nm, tweak_##ty, &mgt_param.nm, mi, ma, st, fl, de, un }, #include "tbl/params.h" -#undef PARAM { "cc_command", tweak_string, &mgt_cc_cmd, NULL, NULL, diff --git a/bin/varnishd/storage/stevedore.c b/bin/varnishd/storage/stevedore.c index 0a3fd3f..ba9001e 100644 --- a/bin/varnishd/storage/stevedore.c +++ b/bin/varnishd/storage/stevedore.c @@ -229,4 +229,3 @@ VRT_Stv_##nm(const char *nm) \ } #include "tbl/vrt_stv_var.h" -#undef VRTSTVVAR diff --git a/bin/varnishd/storage/storage.h b/bin/varnishd/storage/storage.h index 849e442..8969f75 100644 --- a/bin/varnishd/storage/storage.h +++ b/bin/varnishd/storage/storage.h @@ -82,7 +82,6 @@ typedef void sml_free_f(struct storage *); #define VRTSTVVAR(nm,vt,ct,def) \ typedef ct stv_var_##nm(const struct stevedore *); #include "tbl/vrt_stv_var.h" -#undef VRTSTVVAR /*--------------------------------------------------------------------*/ @@ -115,7 +114,6 @@ struct stevedore { #define VRTSTVVAR(nm, vtype, ctype, dval) stv_var_##nm *var_##nm; #include "tbl/vrt_stv_var.h" -#undef VRTSTVVAR /* private fields for the stevedore */ void *priv; diff --git a/bin/varnishd/storage/storage_simple.c b/bin/varnishd/storage/storage_simple.c index 6eba0a8..584da81 100644 --- a/bin/varnishd/storage/storage_simple.c +++ b/bin/varnishd/storage/storage_simple.c @@ -204,7 +204,6 @@ sml_slim(struct worker *wrk, struct objcore *oc) o->aa_##l = NULL; \ } #include "tbl/obj_attr.h" -#undef OBJ_AUXATTR VTAILQ_FOREACH_SAFE(st, &o->list, list, stn) { CHECK_OBJ_NOTNULL(st, STORAGE_MAGIC); @@ -530,7 +529,6 @@ sml_getattr(struct worker *wrk, struct objcore *oc, enum obj_attr attr, *len = sizeof o->fa_##l; \ return (o->fa_##l); #include "tbl/obj_attr.h" -#undef OBJ_FIXATTR /* Variable size attributes */ #define OBJ_VARATTR(U, l) \ @@ -540,7 +538,6 @@ sml_getattr(struct worker *wrk, struct objcore *oc, enum obj_attr attr, *len = o->va_##l##_len; \ return (o->va_##l); #include "tbl/obj_attr.h" -#undef OBJ_VARATTR /* Auxiliary attributes */ #define OBJ_AUXATTR(U, l) \ @@ -551,7 +548,6 @@ sml_getattr(struct worker *wrk, struct objcore *oc, enum obj_attr attr, *len = o->aa_##l->len; \ return (o->aa_##l->ptr); #include "tbl/obj_attr.h" -#undef OBJ_AUXATTR default: break; @@ -581,7 +577,6 @@ sml_setattr(struct worker *wrk, struct objcore *oc, enum obj_attr attr, retval = o->fa_##l; \ break; #include "tbl/obj_attr.h" -#undef OBJ_FIXATTR /* Variable size attributes */ #define OBJ_VARATTR(U, l) \ @@ -599,7 +594,6 @@ sml_setattr(struct worker *wrk, struct objcore *oc, enum obj_attr attr, } \ break; #include "tbl/obj_attr.h" -#undef OBJ_VARATTR /* Auxiliary attributes */ #define OBJ_AUXATTR(U, l) \ @@ -622,7 +616,6 @@ sml_setattr(struct worker *wrk, struct objcore *oc, enum obj_attr attr, retval = o->aa_##l->ptr; \ break; #include "tbl/obj_attr.h" -#undef OBJ_AUXATTR default: WRONG("Unsupported OBJ_ATTR"); @@ -680,10 +673,6 @@ SML_panic(struct vsb *vsb, const struct objcore *oc) #include "tbl/obj_attr.h" -#undef OBJ_FIXATTR -#undef OBJ_VARATTR -#undef OBJ_AUXATTR - VTAILQ_FOREACH(st, &o->list, list) { sml_panic_st(vsb, "Body", st); } diff --git a/bin/varnishd/storage/storage_simple.h b/bin/varnishd/storage/storage_simple.h index bae82f4..6985cdd 100644 --- a/bin/varnishd/storage/storage_simple.h +++ b/bin/varnishd/storage/storage_simple.h @@ -44,23 +44,20 @@ struct object { #define OBJ_FIXATTR(U, l, s) \ uint8_t fa_##l[s]; #include "tbl/obj_attr.h" -#undef OBJ_FIXATTR /* Variable size attributes */ #define OBJ_VARATTR(U, l) \ uint8_t *va_##l; #include "tbl/obj_attr.h" -#undef OBJ_VARATTR + #define OBJ_VARATTR(U, l) \ unsigned va_##l##_len; #include "tbl/obj_attr.h" -#undef OBJ_VARATTR /* Auxiliary attributes */ #define OBJ_AUXATTR(U, l) \ struct storage *aa_##l; #include "tbl/obj_attr.h" -#undef OBJ_AUXATTR struct storagehead list; }; diff --git a/include/tbl/acct_fields_bereq.h b/include/tbl/acct_fields_bereq.h index 7b28879..b106325 100644 --- a/include/tbl/acct_fields_bereq.h +++ b/include/tbl/acct_fields_bereq.h @@ -30,8 +30,11 @@ */ /*lint -save -e525 -e539 */ + ACCT(bereq_hdrbytes) ACCT(bereq_bodybytes) ACCT(beresp_hdrbytes) ACCT(beresp_bodybytes) +#undef ACCT + /*lint -restore */ diff --git a/include/tbl/acct_fields_req.h b/include/tbl/acct_fields_req.h index 44ce5b8..3921ab2 100644 --- a/include/tbl/acct_fields_req.h +++ b/include/tbl/acct_fields_req.h @@ -31,8 +31,11 @@ */ /*lint -save -e525 -e539 */ + ACCT(req_hdrbytes) ACCT(req_bodybytes) ACCT(resp_hdrbytes) ACCT(resp_bodybytes) +#undef ACCT + /*lint -restore */ diff --git a/include/tbl/backend_poll.h b/include/tbl/backend_poll.h index 04174cb..a6fa339 100644 --- a/include/tbl/backend_poll.h +++ b/include/tbl/backend_poll.h @@ -28,6 +28,7 @@ */ /*lint -save -e525 -e539 */ + BITMAP(good_ipv4, '4', "Good IPv4", 0) BITMAP(good_ipv6, '6', "Good IPv6", 0) BITMAP( err_xmit, 'x', "Error Xmit", 0) @@ -35,4 +36,6 @@ BITMAP(good_xmit, 'X', "Good Xmit", 0) BITMAP( err_recv, 'r', "Error Recv", 0) BITMAP(good_recv, 'R', "Good Recv", 0) BITMAP(happy, 'H', "Happy", 1) -/* lint -restore */ +#undef BITMAP + +/*lint -restore */ diff --git a/include/tbl/ban_vars.h b/include/tbl/ban_vars.h index 7bc665d..14e06b0 100644 --- a/include/tbl/ban_vars.h +++ b/include/tbl/ban_vars.h @@ -30,8 +30,11 @@ */ /*lint -save -e525 -e539 */ + PVAR("req.url", BANS_FLAG_REQ, BANS_ARG_URL) PVAR("req.http.", BANS_FLAG_REQ | BANS_FLAG_HTTP, BANS_ARG_REQHTTP) PVAR("obj.status", BANS_FLAG_OBJ, BANS_ARG_OBJSTATUS) PVAR("obj.http.", BANS_FLAG_OBJ | BANS_FLAG_HTTP, BANS_ARG_OBJHTTP) +#undef PVAR + /*lint -restore */ diff --git a/include/tbl/bo_flags.h b/include/tbl/bo_flags.h index 06608e3..221f9a3 100644 --- a/include/tbl/bo_flags.h +++ b/include/tbl/bo_flags.h @@ -39,5 +39,6 @@ BO_FLAG(uncacheable, 0, 0, "") BO_FLAG(is_gzip, 0, 0, "") BO_FLAG(is_gunzip, 0, 0, "") BO_FLAG(was_304, 1, 0, "") +#undef BO_FLAG /*lint -restore */ diff --git a/include/tbl/boc_state.h b/include/tbl/boc_state.h index 5f71c7a..5297d8a 100644 --- a/include/tbl/boc_state.h +++ b/include/tbl/boc_state.h @@ -27,10 +27,13 @@ */ /*lint -save -e525 -e539 */ + BOC_STATE(INVALID, invalid) /* don't touch (yet) */ BOC_STATE(REQ_DONE, req_done) /* beresp.* can be examined */ BOC_STATE(PREP_STREAM, prep_stream) /* Prepare for streaming */ BOC_STATE(STREAM, stream) /* beresp.* can be examined */ BOC_STATE(FINISHED, finished) /* object is complete */ BOC_STATE(FAILED, failed) /* something went wrong */ +#undef BOC_STATE + /*lint -restore */ diff --git a/include/tbl/body_status.h b/include/tbl/body_status.h index 5f6031f..c171831 100644 --- a/include/tbl/body_status.h +++ b/include/tbl/body_status.h @@ -29,9 +29,12 @@ */ /*lint -save -e525 -e539 */ + BODYSTATUS(NONE, none) BODYSTATUS(ERROR, error) BODYSTATUS(CHUNKED, chunked) BODYSTATUS(LENGTH, length) BODYSTATUS(EOF, eof) +#undef BODYSTATUS + /*lint -restore */ diff --git a/include/tbl/cli_cmds.h b/include/tbl/cli_cmds.h index c0110c2..d162bad 100644 --- a/include/tbl/cli_cmds.h +++ b/include/tbl/cli_cmds.h @@ -26,9 +26,6 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - */ - -/* * These macros define the common data for requests in the CLI protocol. * The fields are: * const char * upper-case C-ident request_name @@ -40,6 +37,8 @@ * int maximum_arguments */ +/*lint -save -e525 -e539 */ + CLI_CMD(BAN, "ban", "ban [&& ...]", @@ -322,3 +321,6 @@ CLI_CMD(STORAGE_LIST, 0, 0 ) +#undef CLI_CMD + +/*lint -restore */ diff --git a/include/tbl/debug_bits.h b/include/tbl/debug_bits.h index fa0d32f..b354921 100644 --- a/include/tbl/debug_bits.h +++ b/include/tbl/debug_bits.h @@ -30,6 +30,7 @@ */ /*lint -save -e525 -e539 */ + DEBUG_BIT(REQ_STATE, req_state, "VSL Request state engine") DEBUG_BIT(WORKSPACE, workspace, "VSL Workspace operations") DEBUG_BIT(WAITER, waiter, "VSL Waiter internals") @@ -43,4 +44,6 @@ DEBUG_BIT(FLUSH_HEAD, flush_head, "Flush after http1 head") DEBUG_BIT(VTC_MODE, vtc_mode, "Varnishtest Mode") DEBUG_BIT(WITNESS, witness, "Emit WITNESS lock records") DEBUG_BIT(VSM_KEEP, vsm_keep, "Keep the VSM file on restart") +#undef DEBUG_BIT + /*lint -restore */ diff --git a/include/tbl/feature_bits.h b/include/tbl/feature_bits.h index a178b56..96500da 100644 --- a/include/tbl/feature_bits.h +++ b/include/tbl/feature_bits.h @@ -30,41 +30,53 @@ */ /*lint -save -e525 -e539 */ + FEATURE_BIT(SHORT_PANIC, short_panic, "Short panic message.", "Reduce level of detail for panic messages." ) + FEATURE_BIT(WAIT_SILO, wait_silo, "Wait for persistent silo.", "Wait for persistent silos to load completely before serving requests." ) + FEATURE_BIT(NO_COREDUMP, no_coredump, "No coredumps.", "Don't attempt to coredump child process on panics." ) + FEATURE_BIT(ESI_IGNORE_HTTPS, esi_ignore_https, "Treat HTTPS as HTTP in ESI:includes", "Convert b) in pass mode */ -#define HTTPH_R_FETCH (1 << 1) /* Request (c->b) for fetch */ -#define HTTPH_A_INS (1 << 2) /* Response (b->o) for insert */ -#define HTTPH_A_PASS (1 << 3) /* Response (b->o) for pass */ -#endif - /* Shorthand for this file only, to keep table narrow */ #if defined(P) || defined(F) || defined(I) || defined(H) || defined(S) @@ -116,5 +108,6 @@ H("X-Forwarded-For", H_X_Forwarded_For, 0 ) // No RFC #undef I #undef S #undef H +#undef HTTPH /*lint -restore */ diff --git a/include/tbl/http_response.h b/include/tbl/http_response.h index 6baacfb..eaa74c4 100644 --- a/include/tbl/http_response.h +++ b/include/tbl/http_response.h @@ -29,6 +29,7 @@ */ /*lint -save -e525 -e539 */ + HTTP_RESP(101, "Switching Protocols") HTTP_RESP(200, "OK") HTTP_RESP(201, "Created") @@ -69,4 +70,6 @@ HTTP_RESP(502, "Bad Gateway") HTTP_RESP(503, "Service Unavailable") HTTP_RESP(504, "Gateway Timeout") HTTP_RESP(505, "HTTP Version Not Supported") +#undef HTTP_RESP + /*lint -restore */ diff --git a/include/tbl/locks.h b/include/tbl/locks.h index 8d99eb7..a89b0b4 100644 --- a/include/tbl/locks.h +++ b/include/tbl/locks.h @@ -28,6 +28,7 @@ */ /*lint -save -e525 -e539 */ + LOCK(backend) LOCK(backend_tcp) LOCK(ban) @@ -47,4 +48,6 @@ LOCK(vxid) LOCK(waiter) LOCK(wq) LOCK(wstat) +#undef LOCK + /*lint -restore */ diff --git a/include/tbl/obj_attr.h b/include/tbl/obj_attr.h index d05b598..b0b6773 100644 --- a/include/tbl/obj_attr.h +++ b/include/tbl/obj_attr.h @@ -31,30 +31,34 @@ /* upper, lower, size */ #ifdef OBJ_FIXATTR -OBJ_FIXATTR(LEN, len, 8) -OBJ_FIXATTR(VXID, vxid, 4) -OBJ_FIXATTR(FLAGS, flags, 1) -OBJ_FIXATTR(GZIPBITS, gzipbits, 32) -OBJ_FIXATTR(LASTMODIFIED, lastmodified, 8) + OBJ_FIXATTR(LEN, len, 8) + OBJ_FIXATTR(VXID, vxid, 4) + OBJ_FIXATTR(FLAGS, flags, 1) + OBJ_FIXATTR(GZIPBITS, gzipbits, 32) + OBJ_FIXATTR(LASTMODIFIED, lastmodified, 8) + #undef OBJ_FIXATTR #endif /* upper, lower */ #ifdef OBJ_VARATTR -OBJ_VARATTR(VARY, vary) -OBJ_VARATTR(HEADERS, headers) + OBJ_VARATTR(VARY, vary) + OBJ_VARATTR(HEADERS, headers) + #undef OBJ_VARATTR #endif /* upper, lower */ #ifdef OBJ_AUXATTR -OBJ_AUXATTR(ESIDATA, esidata) + OBJ_AUXATTR(ESIDATA, esidata) + #undef OBJ_AUXATTR #endif #ifdef OBJ_FLAG /* upper, lower, val */ -OBJ_FLAG(GZIPED, gziped, (1<<1)) -OBJ_FLAG(CHGGZIP, chggzip, (1<<2)) -OBJ_FLAG(IMSCAND, imscand, (1<<3)) -OBJ_FLAG(ESIPROC, esiproc, (1<<4)) + OBJ_FLAG(GZIPED, gziped, (1<<1)) + OBJ_FLAG(CHGGZIP, chggzip, (1<<2)) + OBJ_FLAG(IMSCAND, imscand, (1<<3)) + OBJ_FLAG(ESIPROC, esiproc, (1<<4)) + #undef OBJ_FLAG #endif /*lint -restore */ diff --git a/include/tbl/oc_exp_flags.h b/include/tbl/oc_exp_flags.h index 2fc16e5..83160b0 100644 --- a/include/tbl/oc_exp_flags.h +++ b/include/tbl/oc_exp_flags.h @@ -27,9 +27,12 @@ */ /*lint -save -e525 -e539 */ + OC_EXP_FLAG(POSTED, posted, (1<<1)) OC_EXP_FLAG(REFD, refd, (1<<2)) OC_EXP_FLAG(MOVE, move, (1<<3)) OC_EXP_FLAG(INSERT, insert, (1<<4)) OC_EXP_FLAG(REMOVE, remove, (1<<5)) +#undef OC_EXP_FLAG + /*lint -restore */ diff --git a/include/tbl/oc_flags.h b/include/tbl/oc_flags.h index 825312b..2e231c7 100644 --- a/include/tbl/oc_flags.h +++ b/include/tbl/oc_flags.h @@ -27,10 +27,13 @@ */ /*lint -save -e525 -e539 */ + OC_FLAG(BUSY, busy, (1<<1)) OC_FLAG(PASS, pass, (1<<2)) OC_FLAG(ABANDON, abandon, (1<<4)) OC_FLAG(PRIVATE, private, (1<<5)) OC_FLAG(FAILED, failed, (1<<6)) OC_FLAG(DYING, dying, (1<<7)) +#undef OC_FLAG + /*lint -restore */ diff --git a/include/tbl/params.h b/include/tbl/params.h index 09aec90..5b79f8c 100644 --- a/include/tbl/params.h +++ b/include/tbl/params.h @@ -28,12 +28,12 @@ * PARAM(nm, ty, mi, ma, de, un, fl, st, lt, fn) */ +/*lint -save -e525 -e539 */ + #if defined(XYZZY) #error "Temporary macro XYZZY already defined" #endif -/*lint -save -e525 -e539 */ - #if defined(HAVE_ACCEPT_FILTERS) #define XYZZY MUST_RESTART #else @@ -1176,6 +1176,7 @@ PARAM( /* l-text */ "", /* func */ NULL ) + /* actual location mgt_pool.c */ PARAM( /* name */ thread_pool_reserve, @@ -1624,4 +1625,6 @@ PARAM( /* func */ NULL ) +#undef PARAM + /*lint -restore */ diff --git a/include/tbl/req_body.h b/include/tbl/req_body.h index e9e32b7..9878e9c 100644 --- a/include/tbl/req_body.h +++ b/include/tbl/req_body.h @@ -36,5 +36,6 @@ REQ_BODY(TAKEN) REQ_BODY(CACHED) REQ_BODY(FAIL) REQ_BODY(NONE) +#undef REQ_BODY /*lint -restore */ diff --git a/include/tbl/req_flags.h b/include/tbl/req_flags.h index 4b8ec5b..f743649 100644 --- a/include/tbl/req_flags.h +++ b/include/tbl/req_flags.h @@ -35,4 +35,6 @@ REQ_FLAG(hash_ignore_busy, 1, 1, "") REQ_FLAG(hash_always_miss, 1, 1, "") REQ_FLAG(is_hit, 0, 0, "") REQ_FLAG(waitinglist, 0, 0, "") +#undef REQ_FLAG + /*lint -restore */ diff --git a/include/tbl/sess_attr.h b/include/tbl/sess_attr.h index 4ab9631..6b4494f 100644 --- a/include/tbl/sess_attr.h +++ b/include/tbl/sess_attr.h @@ -40,5 +40,6 @@ SESS_ATTR(SERVER_ADDR, server_addr, struct suckaddr, vsa_suckaddr_len) SESS_ATTR(CLIENT_IP, client_ip, char, -1) SESS_ATTR(CLIENT_PORT, client_port, char, -1) SESS_ATTR(XPORT_PRIV, xport_priv, uintptr_t, sizeof(uintptr_t)) +#undef SESS_ATTR /*lint -restore */ diff --git a/include/tbl/sess_close.h b/include/tbl/sess_close.h index ef4c946..e1b4872 100644 --- a/include/tbl/sess_close.h +++ b/include/tbl/sess_close.h @@ -45,5 +45,6 @@ SESS_CLOSE(RESP_CLOSE, resp_close, 0, "Backend/VCL requested close") SESS_CLOSE(OVERLOAD, overload, 1, "Out of some resource") SESS_CLOSE(PIPE_OVERFLOW, pipe_overflow,1, "Session pipe overflow") SESS_CLOSE(RANGE_SHORT, range_short, 1, "Insufficient data for range") +#undef SESS_CLOSE /*lint -restore */ diff --git a/include/tbl/steps.h b/include/tbl/steps.h index b862a79..10d8f9f 100644 --- a/include/tbl/steps.h +++ b/include/tbl/steps.h @@ -31,30 +31,32 @@ /*lint -save -e525 -e539 */ #ifdef REQ_STEP -REQ_STEP(restart, RESTART, (wrk, req)) -REQ_STEP(recv, RECV, (wrk, req)) -REQ_STEP(pipe, PIPE, (wrk, req)) -REQ_STEP(pass, PASS, (wrk, req)) -REQ_STEP(lookup, LOOKUP, (wrk, req)) -REQ_STEP(purge, PURGE, (wrk, req)) -REQ_STEP(miss, MISS, (wrk, req)) -REQ_STEP(fetch, FETCH, (wrk, req)) -REQ_STEP(deliver, DELIVER, (wrk, req)) -REQ_STEP(synth, SYNTH, (wrk, req)) -REQ_STEP(transmit, TRANSMIT, (wrk, req)) + REQ_STEP(restart, RESTART, (wrk, req)) + REQ_STEP(recv, RECV, (wrk, req)) + REQ_STEP(pipe, PIPE, (wrk, req)) + REQ_STEP(pass, PASS, (wrk, req)) + REQ_STEP(lookup, LOOKUP, (wrk, req)) + REQ_STEP(purge, PURGE, (wrk, req)) + REQ_STEP(miss, MISS, (wrk, req)) + REQ_STEP(fetch, FETCH, (wrk, req)) + REQ_STEP(deliver, DELIVER, (wrk, req)) + REQ_STEP(synth, SYNTH, (wrk, req)) + REQ_STEP(transmit, TRANSMIT, (wrk, req)) + #undef REQ_STEP #endif #ifdef FETCH_STEP -FETCH_STEP(mkbereq, MKBEREQ, (wrk, bo)) -FETCH_STEP(retry, RETRY, (wrk, bo)) -FETCH_STEP(startfetch, STARTFETCH, (wrk, bo)) -FETCH_STEP(condfetch, CONDFETCH, (wrk, bo)) -FETCH_STEP(fetch, FETCH, (wrk, bo)) -FETCH_STEP(fetchbody, FETCHBODY, (wrk, bo)) -FETCH_STEP(fetchend, FETCHEND, (wrk, bo)) -FETCH_STEP(error, ERROR, (wrk, bo)) -FETCH_STEP(fail, FAIL, (wrk, bo)) -FETCH_STEP(done, DONE, ()) + FETCH_STEP(mkbereq, MKBEREQ, (wrk, bo)) + FETCH_STEP(retry, RETRY, (wrk, bo)) + FETCH_STEP(startfetch, STARTFETCH, (wrk, bo)) + FETCH_STEP(condfetch, CONDFETCH, (wrk, bo)) + FETCH_STEP(fetch, FETCH, (wrk, bo)) + FETCH_STEP(fetchbody, FETCHBODY, (wrk, bo)) + FETCH_STEP(fetchend, FETCHEND, (wrk, bo)) + FETCH_STEP(error, ERROR, (wrk, bo)) + FETCH_STEP(fail, FAIL, (wrk, bo)) + FETCH_STEP(done, DONE, ()) + #undef FETCH_STEP #endif /*lint -restore */ diff --git a/include/tbl/style.py b/include/tbl/style.py new file mode 100644 index 0000000..a29459c --- /dev/null +++ b/include/tbl/style.py @@ -0,0 +1,72 @@ +#!/usr/bin/env python +# +# Very basic style-checker for include/tbl files. + +from __future__ import print_function + +import glob + +def check_file(fn): + s = 0 + ll = [] + for l in open(fn): + ll.append(l) + + assert ll.pop(0)[:2] == "/*" + + while ll.pop(0) != " */\n": + continue + + assert len(ll) > 5 + + assert ll.pop(0) == "\n" + assert ll.pop(0) == "/*lint -save -e525 -e539 */\n" + assert ll.pop(0) == "\n" + + assert ll.pop(-1) == "/*lint -restore */\n" + assert ll.pop(-1) == "\n" + + for i in range(0, len(ll) -1): + assert ll[i] != "\n" or ll[i+1] != "\n" + assert ll[i] != ")\n" or ll[i+1] == "\n" or ll[i+1][0] == "#" + + m = {} + while len(ll) > 0: + i = ll.pop(0) + if i == "\n": + continue + l = i.lstrip() + if l[0] >= 'A' and l[0] <= 'Z': + j = l.split('(') + m[j[0]] = "Called" + l = l.split('//')[0] + l = l.split('/*')[0] + l = l.rstrip() + if l[-1] != ')': + while ll.pop(0) != ')\n': + continue + elif l[0] == "#": + j = l[1:].lstrip().split() + # print("#", j[0]) + if j[0] == "define": + m[j[1].split("(")[0].strip()] = "Defined" + if j[0] == "undef": + m[j[1]] = "Undef" + while l[-2:] == "\\\n": + l = ll.pop(0) + else: + pass + # print(l) + rv = 0 + for i in m: + if m[i] != "Undef": + print("ERROR", fn, i, m[i]) + rv += 1 + return rv + +rv = 0 +for fn in glob.glob("*.h"): + rv += check_file(fn) +if rv != 0: + print(rv, "Errors") +exit(rv) diff --git a/include/tbl/symbol_kind.h b/include/tbl/symbol_kind.h index 92d7900..f71228b 100644 --- a/include/tbl/symbol_kind.h +++ b/include/tbl/symbol_kind.h @@ -28,17 +28,20 @@ */ /*lint -save -e525 -e539 */ + VCC_SYMB(NONE, none) VCC_SYMB(ACL, acl) VCC_SYMB(BACKEND, backend) -VCC_SYMB(FUNC, func) /* VMOD function/procedure */ +VCC_SYMB(FUNC, func) VCC_SYMB(INSTANCE, instance) VCC_SYMB(METHOD, method) VCC_SYMB(OBJECT, object) VCC_SYMB(PROBE, probe) VCC_SYMB(STEVEDORE, stevedore) -VCC_SYMB(SUB, sub) /* VCL subroutine */ +VCC_SYMB(SUB, sub) VCC_SYMB(VAR, var) -VCC_SYMB(VCL, vcl) /* VCL program */ +VCC_SYMB(VCL, vcl) VCC_SYMB(VMOD, vmod) +#undef VCC_SYMB + /*lint -restore */ diff --git a/include/tbl/vhd_fsm.h b/include/tbl/vhd_fsm.h index 802b2e1..4d0e660 100644 --- a/include/tbl/vhd_fsm.h +++ b/include/tbl/vhd_fsm.h @@ -27,6 +27,8 @@ * */ +/*lint -save -e525 -e539 */ + /* Decode integer with prefix */ #define VHD_FSM_INTEGER(STATE, pfx) \ VHD_FSM(STATE, INTEGER, pfx, 0) @@ -265,3 +267,7 @@ VHD_FSM_GOTO(TEST_LITERAL_FINISH, IDLE) #undef VHD_FSM_BRANCH_ZIDX #undef VHD_FSM_BRANCH_BIT0 #undef VHD_FSM_LITERAL + +#undef VHD_FSM + +/*lint -restore */ diff --git a/include/tbl/vhd_fsm_funcs.h b/include/tbl/vhd_fsm_funcs.h index 92cd082..f8bb459 100644 --- a/include/tbl/vhd_fsm_funcs.h +++ b/include/tbl/vhd_fsm_funcs.h @@ -27,6 +27,8 @@ * */ +/*lint -save -e525 -e539 */ + VHD_FSM_FUNC(SKIP, vhd_skip) VHD_FSM_FUNC(GOTO, vhd_goto) VHD_FSM_FUNC(IDLE, vhd_idle) @@ -40,3 +42,6 @@ VHD_FSM_FUNC(BRANCH_ZIDX, vhd_branch_zidx) VHD_FSM_FUNC(BRANCH_BIT0, vhd_branch_bit0) VHD_FSM_FUNC(RAW, vhd_raw) VHD_FSM_FUNC(HUFFMAN, vhd_huffman) +#undef VHD_FSM_FUNC + +/*lint -restore */ diff --git a/include/tbl/vhd_return.h b/include/tbl/vhd_return.h index 31f6cca..66547d4 100644 --- a/include/tbl/vhd_return.h +++ b/include/tbl/vhd_return.h @@ -27,18 +27,22 @@ * */ -VHD_RET(ERR_ARG, -1, "Invalid HPACK instruction") -VHD_RET(ERR_INT, -2, "Integer overflow") -VHD_RET(ERR_IDX, -3, "Invalid table index") -VHD_RET(ERR_LEN, -4, "Invalid length") -VHD_RET(ERR_HUF, -5, "Invalid huffman code") -VHD_RET(ERR_UPD, -6, "Spurious update") +/*lint -save -e525 -e539 */ -VHD_RET(OK, 0, "OK") -VHD_RET(MORE, 1, "Feed me") -VHD_RET(NAME, 2, "Name") -VHD_RET(VALUE, 3, "Value") -VHD_RET(NAME_SEC, 4, "Name never index") -VHD_RET(VALUE_SEC, 5, "Value never index") -VHD_RET(BUF, 6, "Stuffed") -VHD_RET(AGAIN, 7, "Call again") +VHD_RET(ERR_ARG, -1, "Invalid HPACK instruction") +VHD_RET(ERR_INT, -2, "Integer overflow") +VHD_RET(ERR_IDX, -3, "Invalid table index") +VHD_RET(ERR_LEN, -4, "Invalid length") +VHD_RET(ERR_HUF, -5, "Invalid huffman code") +VHD_RET(ERR_UPD, -6, "Spurious update") +VHD_RET(OK, 0, "OK") +VHD_RET(MORE, 1, "Feed me") +VHD_RET(NAME, 2, "Name") +VHD_RET(VALUE, 3, "Value") +VHD_RET(NAME_SEC, 4, "Name never index") +VHD_RET(VALUE_SEC, 5, "Value never index") +VHD_RET(BUF, 6, "Stuffed") +VHD_RET(AGAIN, 7, "Call again") +#undef VHD_RET + +/*lint -restore */ diff --git a/include/tbl/vhp_huffman.h b/include/tbl/vhp_huffman.h index ad9ebe2..bbe825f 100644 --- a/include/tbl/vhp_huffman.h +++ b/include/tbl/vhp_huffman.h @@ -6,6 +6,8 @@ * HPACK Huffman table, but sorted by codes (RFC 7541 Appendix B) */ +/*lint -save -e525 -e539 */ + HPH(0x30, 0x00000000, 5) /* '0' */ HPH(0x31, 0x00000001, 5) /* '1' */ HPH(0x32, 0x00000002, 5) /* '2' */ @@ -262,3 +264,6 @@ HPH(0xf9, 0x0ffffffe, 28) HPH(0x0a, 0x3ffffffc, 30) HPH(0x0d, 0x3ffffffd, 30) HPH(0x16, 0x3ffffffe, 30) +#undef HPH + +/*lint -restore */ diff --git a/include/tbl/vhp_static.h b/include/tbl/vhp_static.h index 576c180..881543c 100644 --- a/include/tbl/vhp_static.h +++ b/include/tbl/vhp_static.h @@ -6,6 +6,8 @@ * HPACK: Static Table Definition (RFC 7540 Appendix A) */ +/*lint -save -e525 -e539 */ + HPS( 1, ":authority", "") HPS( 2, ":method", "GET") HPS( 3, ":method", "POST") @@ -67,3 +69,6 @@ HPS(58, "user-agent", "") HPS(59, "vary", "") HPS(60, "via", "") HPS(61, "www-authenticate", "") +#undef HPS + +/*lint -restore */ diff --git a/include/tbl/vsc_all.h b/include/tbl/vsc_all.h index 8b681de..1c761d4 100644 --- a/include/tbl/vsc_all.h +++ b/include/tbl/vsc_all.h @@ -27,45 +27,64 @@ * */ - /*lint -save -e525 -e539 */ + VSC_DO(MAIN, main, VSC_type_main) -#include "tbl/vsc_f_main.h" + #define VSC_FF VSC_F + #include "tbl/vsc_f_main.h" + #undef VSC_FF VSC_DONE(MAIN, main, VSC_type_main) VSC_DO(MGT, mgt, VSC_type_mgt) -#define VSC_DO_MGT -#include "tbl/vsc_fields.h" -#undef VSC_DO_MGT + #define VSC_DO_MGT + #define VSC_FF VSC_F + #include "tbl/vsc_fields.h" + #undef VSC_FF + #undef VSC_DO_MGT VSC_DONE(MGT, mgt, VSC_type_mgt) VSC_DO(MEMPOOL, mempool, VSC_type_mempool) -#define VSC_DO_MEMPOOL -#include "tbl/vsc_fields.h" -#undef VSC_DO_MEMPOOL + #define VSC_DO_MEMPOOL + #define VSC_FF VSC_F + #include "tbl/vsc_fields.h" + #undef VSC_FF + #undef VSC_DO_MEMPOOL VSC_DONE(MEMPOOL, mempool, VSC_type_mempool) VSC_DO(SMA, sma, VSC_type_sma) -#define VSC_DO_SMA -#include "tbl/vsc_fields.h" -#undef VSC_DO_SMA + #define VSC_DO_SMA + #define VSC_FF VSC_F + #include "tbl/vsc_fields.h" + #undef VSC_FF + #undef VSC_DO_SMA VSC_DONE(SMA, sma, VSC_type_sma) VSC_DO(SMF, smf, VSC_type_smf) -#define VSC_DO_SMF -#include "tbl/vsc_fields.h" -#undef VSC_DO_SMF + #define VSC_DO_SMF + #define VSC_FF VSC_F + #include "tbl/vsc_fields.h" + #undef VSC_FF + #undef VSC_DO_SMF VSC_DONE(SMF, smf, VSC_type_smf) VSC_DO(VBE, vbe, VSC_type_vbe) -#define VSC_DO_VBE -#include "tbl/vsc_fields.h" -#undef VSC_DO_VBE + #define VSC_DO_VBE + #define VSC_FF VSC_F + #include "tbl/vsc_fields.h" + #undef VSC_FF + #undef VSC_DO_VBE VSC_DONE(VBE, vbe, VSC_type_vbe) VSC_DO(LCK, lck, VSC_type_lck) -#define VSC_DO_LCK -#include "tbl/vsc_fields.h" -#undef VSC_DO_LCK + #define VSC_DO_LCK + #define VSC_FF VSC_F + #include "tbl/vsc_fields.h" + #undef VSC_FF + #undef VSC_DO_LCK VSC_DONE(LCK, lck, VSC_type_lck) + +#undef VSC_DO +#undef VSC_F +#undef VSC_DONE + /*lint -restore */ diff --git a/include/tbl/vsc_f_main.h b/include/tbl/vsc_f_main.h index 3952302..7dbc87d 100644 --- a/include/tbl/vsc_f_main.h +++ b/include/tbl/vsc_f_main.h @@ -31,31 +31,32 @@ * See include/tbl/vsc_fields.h for the table definition. */ +/*lint -save -e525 -e539 */ + /*-------------------------------------------------------------------- * Globals, not related to traffic */ -VSC_F(uptime, uint64_t, 0, 'c', 'd', info, +VSC_FF(uptime, uint64_t, 0, 'c', 'd', info, "Child process uptime", "How long the child process has been running." ) - /*--------------------------------------------------------------------- * Sessions */ -VSC_F(sess_conn, uint64_t, 1, 'c', 'i', info, +VSC_FF(sess_conn, uint64_t, 1, 'c', 'i', info, "Sessions accepted", "Count of sessions successfully accepted" ) -VSC_F(sess_drop, uint64_t, 1, 'c', 'i', info, +VSC_FF(sess_drop, uint64_t, 1, 'c', 'i', info, "Sessions dropped", "Count of sessions silently dropped due to lack of worker thread." ) -VSC_F(sess_fail, uint64_t, 1, 'c', 'i', info, +VSC_FF(sess_fail, uint64_t, 1, 'c', 'i', info, "Session accept failures", "Count of failures to accept TCP connection." " Either the client changed its mind, or the kernel ran out of" @@ -64,32 +65,32 @@ VSC_F(sess_fail, uint64_t, 1, 'c', 'i', info, /*---------------------------------------------------------------------*/ -VSC_F(client_req_400, uint64_t, 1, 'c', 'i', info, +VSC_FF(client_req_400, uint64_t, 1, 'c', 'i', info, "Client requests received, subject to 400 errors", "400 means we couldn't make sense of the request, it was" " malformed in some drastic way." ) -VSC_F(client_req_417, uint64_t, 1, 'c', 'i', info, +VSC_FF(client_req_417, uint64_t, 1, 'c', 'i', info, "Client requests received, subject to 417 errors", "417 means that something went wrong with an Expect: header." ) -VSC_F(client_req, uint64_t, 1, 'c', 'i', info, +VSC_FF(client_req, uint64_t, 1, 'c', 'i', info, "Good client requests received", "The count of parseable client requests seen." ) /*---------------------------------------------------------------------*/ -VSC_F(cache_hit, uint64_t, 1, 'c', 'i', info, +VSC_FF(cache_hit, uint64_t, 1, 'c', 'i', info, "Cache hits", "Count of cache hits. " " A cache hit indicates that an object has been delivered to a" " client without fetching it from a backend server." ) -VSC_F(cache_hitpass, uint64_t, 1, 'c', 'i', info, +VSC_FF(cache_hitpass, uint64_t, 1, 'c', 'i', info, "Cache hits for pass.", "Count of hits for pass." " A cache hit for pass indicates that Varnish is going to" @@ -98,7 +99,7 @@ VSC_F(cache_hitpass, uint64_t, 1, 'c', 'i', info, " decision is being used." ) -VSC_F(cache_miss, uint64_t, 1, 'c', 'i', info, +VSC_FF(cache_miss, uint64_t, 1, 'c', 'i', info, "Cache misses", "Count of misses." " A cache miss indicates the object was fetched from the" @@ -107,30 +108,34 @@ VSC_F(cache_miss, uint64_t, 1, 'c', 'i', info, /*---------------------------------------------------------------------*/ -VSC_F(backend_conn, uint64_t, 0, 'c', 'i', info, +VSC_FF(backend_conn, uint64_t, 0, 'c', 'i', info, "Backend conn. success", "How many backend connections have successfully been" " established." ) -VSC_F(backend_unhealthy, uint64_t, 0, 'c', 'i', info, +VSC_FF(backend_unhealthy, uint64_t, 0, 'c', 'i', info, "Backend conn. not attempted", "" ) -VSC_F(backend_busy, uint64_t, 0, 'c', 'i', info, + +VSC_FF(backend_busy, uint64_t, 0, 'c', 'i', info, "Backend conn. too many", "" ) -VSC_F(backend_fail, uint64_t, 0, 'c', 'i', info, + +VSC_FF(backend_fail, uint64_t, 0, 'c', 'i', info, "Backend conn. failures", "" ) -VSC_F(backend_reuse, uint64_t, 0, 'c', 'i', info, + +VSC_FF(backend_reuse, uint64_t, 0, 'c', 'i', info, "Backend conn. reuses", "Count of backend connection reuses." " This counter is increased whenever we reuse a recycled connection." ) -VSC_F(backend_recycle, uint64_t, 0, 'c', 'i', info, + +VSC_FF(backend_recycle, uint64_t, 0, 'c', 'i', info, "Backend conn. recycles", "Count of backend connection recycles." " This counter is increased whenever we have a keep-alive" @@ -138,7 +143,8 @@ VSC_F(backend_recycle, uint64_t, 0, 'c', 'i', info, " It has not yet been used, but it might be, unless the backend" " closes it." ) -VSC_F(backend_retry, uint64_t, 0, 'c', 'i', info, + +VSC_FF(backend_retry, uint64_t, 0, 'c', 'i', info, "Backend conn. retry", "" ) @@ -147,47 +153,57 @@ VSC_F(backend_retry, uint64_t, 0, 'c', 'i', info, * Backend fetch statistics */ -VSC_F(fetch_head, uint64_t, 1, 'c', 'i', info, +VSC_FF(fetch_head, uint64_t, 1, 'c', 'i', info, "Fetch no body (HEAD)", "beresp with no body because the request is HEAD." ) -VSC_F(fetch_length, uint64_t, 1, 'c', 'i', info, + +VSC_FF(fetch_length, uint64_t, 1, 'c', 'i', info, "Fetch with Length", "beresp.body with Content-Length." ) -VSC_F(fetch_chunked, uint64_t, 1, 'c', 'i', info, + +VSC_FF(fetch_chunked, uint64_t, 1, 'c', 'i', info, "Fetch chunked", "beresp.body with Chunked." ) -VSC_F(fetch_eof, uint64_t, 1, 'c', 'i', info, + +VSC_FF(fetch_eof, uint64_t, 1, 'c', 'i', info, "Fetch EOF", "beresp.body with EOF." ) -VSC_F(fetch_bad, uint64_t, 1, 'c', 'i', info, + +VSC_FF(fetch_bad, uint64_t, 1, 'c', 'i', info, "Fetch bad T-E", "beresp.body length/fetch could not be determined." ) -VSC_F(fetch_none, uint64_t, 1, 'c', 'i', info, + +VSC_FF(fetch_none, uint64_t, 1, 'c', 'i', info, "Fetch no body", "beresp.body empty" ) -VSC_F(fetch_1xx, uint64_t, 1, 'c', 'i', info, + +VSC_FF(fetch_1xx, uint64_t, 1, 'c', 'i', info, "Fetch no body (1xx)", "beresp with no body because of 1XX response." ) -VSC_F(fetch_204, uint64_t, 1, 'c', 'i', info, + +VSC_FF(fetch_204, uint64_t, 1, 'c', 'i', info, "Fetch no body (204)", "beresp with no body because of 204 response." ) -VSC_F(fetch_304, uint64_t, 1, 'c', 'i', info, + +VSC_FF(fetch_304, uint64_t, 1, 'c', 'i', info, "Fetch no body (304)", "beresp with no body because of 304 response." ) -VSC_F(fetch_failed, uint64_t, 1, 'c', 'i', info, + +VSC_FF(fetch_failed, uint64_t, 1, 'c', 'i', info, "Fetch failed (all causes)", "beresp fetch failed." ) -VSC_F(fetch_no_thread, uint64_t, 1, 'c', 'i', info, + +VSC_FF(fetch_no_thread, uint64_t, 1, 'c', 'i', info, "Fetch failed (no thread)", "beresp fetch failed, no thread available." ) @@ -198,74 +214,74 @@ VSC_F(fetch_no_thread, uint64_t, 1, 'c', 'i', info, * */ -VSC_F(pools, uint64_t, 0, 'g', 'i', info, +VSC_FF(pools, uint64_t, 0, 'g', 'i', info, "Number of thread pools", "Number of thread pools. See also parameter thread_pools." " NB: Presently pools cannot be removed once created." ) -VSC_F(threads, uint64_t, 0, 'g', 'i', info, +VSC_FF(threads, uint64_t, 0, 'g', 'i', info, "Total number of threads", "Number of threads in all pools." " See also parameters thread_pools, thread_pool_min and" " thread_pool_max." ) -VSC_F(threads_limited, uint64_t, 0, 'c', 'i', info, +VSC_FF(threads_limited, uint64_t, 0, 'c', 'i', info, "Threads hit max", "Number of times more threads were needed, but limit was reached" " in a thread pool. See also parameter thread_pool_max." ) -VSC_F(threads_created, uint64_t, 0, 'c', 'i', info, +VSC_FF(threads_created, uint64_t, 0, 'c', 'i', info, "Threads created", "Total number of threads created in all pools." ) -VSC_F(threads_destroyed, uint64_t, 0, 'c', 'i', info, +VSC_FF(threads_destroyed, uint64_t, 0, 'c', 'i', info, "Threads destroyed", "Total number of threads destroyed in all pools." ) -VSC_F(threads_failed, uint64_t, 0, 'c', 'i', info, +VSC_FF(threads_failed, uint64_t, 0, 'c', 'i', info, "Thread creation failed", "Number of times creating a thread failed." " See VSL::Debug for diagnostics." " See also parameter thread_fail_delay." ) -VSC_F(thread_queue_len, uint64_t, 0, 'g', 'i', info, +VSC_FF(thread_queue_len, uint64_t, 0, 'g', 'i', info, "Length of session queue", "Length of session queue waiting for threads." " NB: Only updates once per second." " See also parameter thread_queue_limit." ) -VSC_F(busy_sleep, uint64_t, 1, 'c', 'i', info, +VSC_FF(busy_sleep, uint64_t, 1, 'c', 'i', info, "Number of requests sent to sleep on busy objhdr", "Number of requests sent to sleep without a worker thread because" " they found a busy object." ) -VSC_F(busy_wakeup, uint64_t, 1, 'c', 'i', info, +VSC_FF(busy_wakeup, uint64_t, 1, 'c', 'i', info, "Number of requests woken after sleep on busy objhdr", "Number of requests taken off the busy object sleep list and" " rescheduled." ) -VSC_F(busy_killed, uint64_t, 1, 'c', 'i', info, +VSC_FF(busy_killed, uint64_t, 1, 'c', 'i', info, "Number of requests killed after sleep on busy objhdr", "Number of requests killed from the busy object sleep list" " due to lack of resources." ) -VSC_F(sess_queued, uint64_t, 0, 'c', 'i', info, +VSC_FF(sess_queued, uint64_t, 0, 'c', 'i', info, "Sessions queued for thread", "Number of times session was queued waiting for a thread." " See also parameter thread_queue_limit." ) -VSC_F(sess_dropped, uint64_t, 0, 'c', 'i', info, +VSC_FF(sess_dropped, uint64_t, 0, 'c', 'i', info, "Sessions dropped for thread", "Number of times session was dropped because the queue were too" " long already. See also parameter thread_queue_limit." @@ -273,120 +289,140 @@ VSC_F(sess_dropped, uint64_t, 0, 'c', 'i', info, /*---------------------------------------------------------------------*/ -VSC_F(n_object, uint64_t, 1, 'g', 'i', info, +VSC_FF(n_object, uint64_t, 1, 'g', 'i', info, "object structs made", "Approximate number of HTTP objects (headers + body, if present)" " in the cache." ) -VSC_F(n_vampireobject, uint64_t, 1, 'g', 'i', diag, + +VSC_FF(n_vampireobject, uint64_t, 1, 'g', 'i', diag, "unresurrected objects", "Number of unresurrected objects" ) -VSC_F(n_objectcore, uint64_t, 1, 'g', 'i', info, + +VSC_FF(n_objectcore, uint64_t, 1, 'g', 'i', info, "objectcore structs made", "Approximate number of object metadata elements in the cache." " Each object needs an objectcore, extra objectcores are for" " hit-for-pass and busy objects." ) -VSC_F(n_objecthead, uint64_t, 1, 'g', 'i', info, + +VSC_FF(n_objecthead, uint64_t, 1, 'g', 'i', info, "objecthead structs made", "Approximate number of different hash entries in the cache." ) -VSC_F(n_backend, uint64_t, 0, 'g', 'i', info, +VSC_FF(n_backend, uint64_t, 0, 'g', 'i', info, "Number of backends", "Number of backends known to us." ) -VSC_F(n_expired, uint64_t, 0, 'g', 'i', info, +VSC_FF(n_expired, uint64_t, 0, 'g', 'i', info, "Number of expired objects", "Number of objects that expired from cache" " because of old age." ) -VSC_F(n_lru_nuked, uint64_t, 0, 'g', 'i', info, + +VSC_FF(n_lru_nuked, uint64_t, 0, 'g', 'i', info, "Number of LRU nuked objects", "How many objects have been forcefully evicted" " from storage to make room for a new object." ) -VSC_F(n_lru_moved, uint64_t, 0, 'g', 'i', diag, + +VSC_FF(n_lru_moved, uint64_t, 0, 'g', 'i', diag, "Number of LRU moved objects", "Number of move operations done on the LRU list." ) -VSC_F(losthdr, uint64_t, 0, 'c', 'i', info, +VSC_FF(losthdr, uint64_t, 0, 'c', 'i', info, "HTTP header overflows", "" ) -VSC_F(s_sess, uint64_t, 1, 'c', 'i', info, +VSC_FF(s_sess, uint64_t, 1, 'c', 'i', info, "Total sessions seen", "" ) -VSC_F(s_req, uint64_t, 1, 'c', 'i', info, + +VSC_FF(s_req, uint64_t, 1, 'c', 'i', info, "Total requests seen", "" ) -VSC_F(s_pipe, uint64_t, 1, 'c', 'i', info, + +VSC_FF(s_pipe, uint64_t, 1, 'c', 'i', info, "Total pipe sessions seen", "" ) -VSC_F(s_pass, uint64_t, 1, 'c', 'i', info, + +VSC_FF(s_pass, uint64_t, 1, 'c', 'i', info, "Total pass-ed requests seen", "" ) -VSC_F(s_fetch, uint64_t, 1, 'c', 'i', info, + +VSC_FF(s_fetch, uint64_t, 1, 'c', 'i', info, "Total backend fetches initiated", "" ) -VSC_F(s_synth, uint64_t, 1, 'c', 'i', info, + +VSC_FF(s_synth, uint64_t, 1, 'c', 'i', info, "Total synthethic responses made", "" ) -VSC_F(s_req_hdrbytes, uint64_t, 1, 'c', 'B', info, + +VSC_FF(s_req_hdrbytes, uint64_t, 1, 'c', 'B', info, "Request header bytes", "Total request header bytes received" ) -VSC_F(s_req_bodybytes, uint64_t, 1, 'c', 'B', info, + +VSC_FF(s_req_bodybytes, uint64_t, 1, 'c', 'B', info, "Request body bytes", "Total request body bytes received" ) -VSC_F(s_resp_hdrbytes, uint64_t, 1, 'c', 'B', info, + +VSC_FF(s_resp_hdrbytes, uint64_t, 1, 'c', 'B', info, "Response header bytes", "Total response header bytes transmitted" ) -VSC_F(s_resp_bodybytes, uint64_t, 1, 'c', 'B', info, + +VSC_FF(s_resp_bodybytes, uint64_t, 1, 'c', 'B', info, "Response body bytes", "Total response body bytes transmitted" ) -VSC_F(s_pipe_hdrbytes, uint64_t, 0, 'c', 'B', info, + +VSC_FF(s_pipe_hdrbytes, uint64_t, 0, 'c', 'B', info, "Pipe request header bytes", "Total request bytes received for piped sessions" ) -VSC_F(s_pipe_in, uint64_t, 0, 'c', 'B', info, + +VSC_FF(s_pipe_in, uint64_t, 0, 'c', 'B', info, "Piped bytes from client", "Total number of bytes forwarded from clients in" " pipe sessions" ) -VSC_F(s_pipe_out, uint64_t, 0, 'c', 'B', info, + +VSC_FF(s_pipe_out, uint64_t, 0, 'c', 'B', info, "Piped bytes to client", "Total number of bytes forwarded to clients in" " pipe sessions" ) -VSC_F(sess_closed, uint64_t, 1, 'c', 'i', info, +VSC_FF(sess_closed, uint64_t, 1, 'c', 'i', info, "Session Closed", "" ) -VSC_F(sess_closed_err, uint64_t, 0, 'c', 'i', info, + +VSC_FF(sess_closed_err, uint64_t, 0, 'c', 'i', info, "Session Closed with error", "Total number of sessions closed with errors." " See sc_* diag counters for detailed breakdown" ) -VSC_F(sess_readahead, uint64_t, 1, 'c', 'i', info, + +VSC_FF(sess_readahead, uint64_t, 1, 'c', 'i', info, "Session Read Ahead", "" ) -VSC_F(sess_herd, uint64_t, 1, 'c', 'i', diag, + +VSC_FF(sess_herd, uint64_t, 1, 'c', 'i', diag, "Session herd", "Number of times the timeout_linger triggered" ) @@ -396,139 +432,159 @@ VSC_F(sess_herd, uint64_t, 1, 'c', 'i', diag, #define SESS_CLOSE_ERROR0 "" #define SESS_CLOSE_ERROR1 "Error " #define SESS_CLOSE(r, f, e, s) \ -VSC_F(sc_ ## f, uint64_t, 0, 'c', 'i', diag, \ +VSC_FF(sc_ ## f, uint64_t, 0, 'c', 'i', diag, \ "Session " SESS_CLOSE_ERR ## e #r, \ "Number of session closes with " \ SESS_CLOSE_ERROR ## e #r " (" s ")" \ ) #include "tbl/sess_close.h" -#undef SESS_CLOSE #undef SESS_CLOSE_ERROR1 #undef SESS_CLOSE_ERROR0 #undef SESS_CLOSE_ERR1 #undef SESS_CLOSE_ERR0 +#undef SESS_CLOSE /*--------------------------------------------------------------------*/ -VSC_F(shm_records, uint64_t, 0, 'c', 'i', diag, +VSC_FF(shm_records, uint64_t, 0, 'c', 'i', diag, "SHM records", "" ) -VSC_F(shm_writes, uint64_t, 0, 'c', 'i', diag, + +VSC_FF(shm_writes, uint64_t, 0, 'c', 'i', diag, "SHM writes", "" ) -VSC_F(shm_flushes, uint64_t, 0, 'c', 'i', diag, + +VSC_FF(shm_flushes, uint64_t, 0, 'c', 'i', diag, "SHM flushes due to overflow", "" ) -VSC_F(shm_cont, uint64_t, 0, 'c', 'i', diag, + +VSC_FF(shm_cont, uint64_t, 0, 'c', 'i', diag, "SHM MTX contention", "" ) -VSC_F(shm_cycles, uint64_t, 0, 'c', 'i', diag, + +VSC_FF(shm_cycles, uint64_t, 0, 'c', 'i', diag, "SHM cycles through buffer", "" ) /*--------------------------------------------------------------------*/ -VSC_F(backend_req, uint64_t, 0, 'c', 'i', info, +VSC_FF(backend_req, uint64_t, 0, 'c', 'i', info, "Backend requests made", "" ) /*--------------------------------------------------------------------*/ -VSC_F(n_vcl, uint64_t, 0, 'c', 'i', info, +VSC_FF(n_vcl, uint64_t, 0, 'c', 'i', info, "Number of loaded VCLs in total", "" ) -VSC_F(n_vcl_avail, uint64_t, 0, 'c', 'i', diag, + +VSC_FF(n_vcl_avail, uint64_t, 0, 'c', 'i', diag, "Number of VCLs available", "" ) -VSC_F(n_vcl_discard, uint64_t, 0, 'c', 'i', diag, + +VSC_FF(n_vcl_discard, uint64_t, 0, 'c', 'i', diag, "Number of discarded VCLs", "" ) /*--------------------------------------------------------------------*/ -VSC_F(bans, uint64_t, 0, 'g', 'i', info, +VSC_FF(bans, uint64_t, 0, 'g', 'i', info, "Count of bans", "Number of all bans in system, including bans superseded" " by newer bans and bans already checked by the ban-lurker." ) -VSC_F(bans_completed, uint64_t, 0, 'g', 'i', diag, + +VSC_FF(bans_completed, uint64_t, 0, 'g', 'i', diag, "Number of bans marked 'completed'", "Number of bans which are no longer active, either because they" " got checked by the ban-lurker or superseded by newer identical bans." ) -VSC_F(bans_obj, uint64_t, 0, 'g', 'i', diag, + +VSC_FF(bans_obj, uint64_t, 0, 'g', 'i', diag, "Number of bans using obj.*", "Number of bans which use obj.* variables. These bans can possibly" " be washed by the ban-lurker." ) -VSC_F(bans_req, uint64_t, 0, 'g', 'i', diag, + +VSC_FF(bans_req, uint64_t, 0, 'g', 'i', diag, "Number of bans using req.*", "Number of bans which use req.* variables. These bans can not" " be washed by the ban-lurker." ) -VSC_F(bans_added, uint64_t, 0, 'c', 'i', diag, + +VSC_FF(bans_added, uint64_t, 0, 'c', 'i', diag, "Bans added", "Counter of bans added to ban list." ) -VSC_F(bans_deleted, uint64_t, 0, 'c', 'i', diag, + +VSC_FF(bans_deleted, uint64_t, 0, 'c', 'i', diag, "Bans deleted", "Counter of bans deleted from ban list." ) -VSC_F(bans_tested, uint64_t, 0, 'c', 'i', diag, +VSC_FF(bans_tested, uint64_t, 0, 'c', 'i', diag, "Bans tested against objects (lookup)", "Count of how many bans and objects have been tested against" " each other during hash lookup." ) -VSC_F(bans_obj_killed, uint64_t, 0, 'c', 'i', diag, + +VSC_FF(bans_obj_killed, uint64_t, 0, 'c', 'i', diag, "Objects killed by bans (lookup)", "Number of objects killed by bans during object lookup." ) -VSC_F(bans_lurker_tested, uint64_t, 0, 'c', 'i', diag, + +VSC_FF(bans_lurker_tested, uint64_t, 0, 'c', 'i', diag, "Bans tested against objects (lurker)", "Count of how many bans and objects have been tested against" " each other by the ban-lurker." ) -VSC_F(bans_tests_tested, uint64_t, 0, 'c', 'i', diag, + +VSC_FF(bans_tests_tested, uint64_t, 0, 'c', 'i', diag, "Ban tests tested against objects (lookup)", "Count of how many tests and objects have been tested against" " each other during lookup." " 'ban req.url == foo && req.http.host == bar'" " counts as one in 'bans_tested' and as two in 'bans_tests_tested'" ) -VSC_F(bans_lurker_tests_tested, uint64_t, 0, 'c', 'i', diag, + +VSC_FF(bans_lurker_tests_tested, uint64_t, 0, 'c', 'i', diag, "Ban tests tested against objects (lurker)", "Count of how many tests and objects have been tested against" " each other by the ban-lurker." " 'ban req.url == foo && req.http.host == bar'" " counts as one in 'bans_tested' and as two in 'bans_tests_tested'" ) -VSC_F(bans_lurker_obj_killed, uint64_t, 0, 'c', 'i', diag, + +VSC_FF(bans_lurker_obj_killed, uint64_t, 0, 'c', 'i', diag, "Objects killed by bans (lurker)", "Number of objects killed by ban-lurker." ) -VSC_F(bans_dups, uint64_t, 0, 'c', 'i', diag, + +VSC_FF(bans_dups, uint64_t, 0, 'c', 'i', diag, "Bans superseded by other bans", "Count of bans replaced by later identical bans." ) -VSC_F(bans_lurker_contention, uint64_t, 0, 'c', 'i', diag, + +VSC_FF(bans_lurker_contention, uint64_t, 0, 'c', 'i', diag, "Lurker gave way for lookup", "Number of times the ban-lurker had to wait for lookups." ) -VSC_F(bans_persisted_bytes, uint64_t, 0, 'g', 'B', diag, + +VSC_FF(bans_persisted_bytes, uint64_t, 0, 'g', 'B', diag, "Bytes used by the persisted ban lists", "Number of bytes used by the persisted ban lists." ) -VSC_F(bans_persisted_fragmentation, uint64_t, 0, 'g', 'B', diag, + +VSC_FF(bans_persisted_fragmentation, uint64_t, 0, 'g', 'B', diag, "Extra bytes in persisted ban lists due to fragmentation", "Number of extra bytes accumulated through dropped and" " completed bans in the persistent ban lists." @@ -536,93 +592,98 @@ VSC_F(bans_persisted_fragmentation, uint64_t, 0, 'g', 'B', diag, /*--------------------------------------------------------------------*/ -VSC_F(n_purges, uint64_t, 0, 'g', 'i', info, +VSC_FF(n_purges, uint64_t, 0, 'g', 'i', info, "Number of purge operations executed", "" ) -VSC_F(n_obj_purged, uint64_t, 0, 'g', 'i', info, + +VSC_FF(n_obj_purged, uint64_t, 0, 'g', 'i', info, "Number of purged objects", "" ) /*--------------------------------------------------------------------*/ -VSC_F(exp_mailed, uint64_t, 0, 'c', 'i', diag, +VSC_FF(exp_mailed, uint64_t, 0, 'c', 'i', diag, "Number of objects mailed to expiry thread", "Number of objects mailed to expiry thread for handling." ) -VSC_F(exp_received, uint64_t, 0, 'c', 'i', diag, +VSC_FF(exp_received, uint64_t, 0, 'c', 'i', diag, "Number of objects received by expiry thread", "Number of objects received by expiry thread for handling." ) /*--------------------------------------------------------------------*/ -VSC_F(hcb_nolock, uint64_t, 1, 'c', 'i', debug, +VSC_FF(hcb_nolock, uint64_t, 1, 'c', 'i', debug, "HCB Lookups without lock", "" ) -VSC_F(hcb_lock, uint64_t, 0, 'c', 'i', debug, + +VSC_FF(hcb_lock, uint64_t, 0, 'c', 'i', debug, "HCB Lookups with lock", "" ) -VSC_F(hcb_insert, uint64_t, 0, 'c', 'i', debug, + +VSC_FF(hcb_insert, uint64_t, 0, 'c', 'i', debug, "HCB Inserts", "" ) /*--------------------------------------------------------------------*/ -VSC_F(esi_errors, uint64_t, 0, 'c', 'i', diag, +VSC_FF(esi_errors, uint64_t, 0, 'c', 'i', diag, "ESI parse errors (unlock)", "" ) -VSC_F(esi_warnings, uint64_t, 0, 'c', 'i', diag, + +VSC_FF(esi_warnings, uint64_t, 0, 'c', 'i', diag, "ESI parse warnings (unlock)", "" ) /*--------------------------------------------------------------------*/ -VSC_F(vmods, uint64_t, 0, 'g', 'i', info, +VSC_FF(vmods, uint64_t, 0, 'g', 'i', info, "Loaded VMODs", "" ) /*--------------------------------------------------------------------*/ -VSC_F(n_gzip, uint64_t, 0, 'c', 'i', info, +VSC_FF(n_gzip, uint64_t, 0, 'c', 'i', info, "Gzip operations", "" ) -VSC_F(n_gunzip, uint64_t, 0, 'c', 'i', info, + +VSC_FF(n_gunzip, uint64_t, 0, 'c', 'i', info, "Gunzip operations", "" ) /*--------------------------------------------------------------------*/ -VSC_F(vsm_free, uint64_t, 0, 'g', 'B', diag, +VSC_FF(vsm_free, uint64_t, 0, 'g', 'B', diag, "Free VSM space", "Number of bytes free in the shared memory used to communicate" " with tools like varnishstat, varnishlog etc." ) -VSC_F(vsm_used, uint64_t, 0, 'g', 'B', diag, +VSC_FF(vsm_used, uint64_t, 0, 'g', 'B', diag, "Used VSM space", "Number of bytes used in the shared memory used to communicate" " with tools like varnishstat, varnishlog etc." ) -VSC_F(vsm_cooling, uint64_t, 0, 'g', 'B', debug, +VSC_FF(vsm_cooling, uint64_t, 0, 'g', 'B', debug, "Cooling VSM space", "Number of bytes which will soon (max 1 minute) be freed" " in the shared memory used to communicate" " with tools like varnishstat, varnishlog etc." ) -VSC_F(vsm_overflow, uint64_t, 0, 'g', 'B', diag, +VSC_FF(vsm_overflow, uint64_t, 0, 'g', 'B', diag, "Overflow VSM space", "Number of bytes which does not fit" " in the shared memory used to communicate" @@ -631,7 +692,7 @@ VSC_F(vsm_overflow, uint64_t, 0, 'g', 'B', diag, " increasing the runtime variable vsm_space." ) -VSC_F(vsm_overflowed, uint64_t, 0, 'c', 'B', diag, +VSC_FF(vsm_overflowed, uint64_t, 0, 'c', 'B', diag, "Overflowed VSM space", "Total number of bytes which did not fit" " in the shared memory used to communicate" @@ -639,3 +700,7 @@ VSC_F(vsm_overflowed, uint64_t, 0, 'c', 'B', diag, " If this counter is not zero, consider" " increasing the runtime variable vsm_space." ) + +#undef VSC_FF + +/*lint -restore */ diff --git a/include/tbl/vsc_fields.h b/include/tbl/vsc_fields.h index fcf342f..30c16bd 100644 --- a/include/tbl/vsc_fields.h +++ b/include/tbl/vsc_fields.h @@ -61,36 +61,44 @@ * */ +/*lint -save -e525 -e539 */ + /**********************************************************************/ #ifdef VSC_DO_MGT -VSC_F(uptime, uint64_t, 0, 'c', 'd', info, +VSC_FF(uptime, uint64_t, 0, 'c', 'd', info, "Management process uptime", "Uptime in seconds of the management process" ) -VSC_F(child_start, uint64_t, 0, 'c', 'i', diag, + +VSC_FF(child_start, uint64_t, 0, 'c', 'i', diag, "Child process started", "Number of times the child process has been started" ) -VSC_F(child_exit, uint64_t, 0, 'c', 'i', diag, + +VSC_FF(child_exit, uint64_t, 0, 'c', 'i', diag, "Child process normal exit", "Number of times the child process has been cleanly stopped" ) -VSC_F(child_stop, uint64_t, 0, 'c', 'i', diag, + +VSC_FF(child_stop, uint64_t, 0, 'c', 'i', diag, "Child process unexpected exit", "Number of times the child process has exited with an unexpected" " return code" ) -VSC_F(child_died, uint64_t, 0, 'c', 'i', diag, + +VSC_FF(child_died, uint64_t, 0, 'c', 'i', diag, "Child process died (signal)", "Number of times the child process has died due to signals" ) -VSC_F(child_dump, uint64_t, 0, 'c', 'i', diag, + +VSC_FF(child_dump, uint64_t, 0, 'c', 'i', diag, "Child process core dumped", "Number of times the child process has produced core dumps" ) -VSC_F(child_panic, uint64_t, 0, 'c', 'i', diag, + +VSC_FF(child_panic, uint64_t, 0, 'c', 'i', diag, "Child process panic", "Number of times the management process has caught a child panic" ) @@ -101,15 +109,17 @@ VSC_F(child_panic, uint64_t, 0, 'c', 'i', diag, #ifdef VSC_DO_LCK -VSC_F(creat, uint64_t, 0, 'c', 'i', debug, +VSC_FF(creat, uint64_t, 0, 'c', 'i', debug, "Created locks", "" ) -VSC_F(destroy, uint64_t, 0, 'c', 'i', debug, + +VSC_FF(destroy, uint64_t, 0, 'c', 'i', debug, "Destroyed locks", "" ) -VSC_F(locks, uint64_t, 0, 'c', 'i', debug, + +VSC_FF(locks, uint64_t, 0, 'c', 'i', debug, "Lock Operations", "" ) @@ -121,37 +131,42 @@ VSC_F(locks, uint64_t, 0, 'c', 'i', debug, */ #if defined(VSC_DO_SMA) || defined (VSC_DO_SMF) -VSC_F(c_req, uint64_t, 0, 'c', 'i', info, +VSC_FF(c_req, uint64_t, 0, 'c', 'i', info, "Allocator requests", "Number of times the storage has been asked to provide a storage segment." ) -VSC_F(c_fail, uint64_t, 0, 'c', 'i', info, + +VSC_FF(c_fail, uint64_t, 0, 'c', 'i', info, "Allocator failures", "Number of times the storage has failed to provide a storage segment." ) -VSC_F(c_bytes, uint64_t, 0, 'c', 'B', info, + +VSC_FF(c_bytes, uint64_t, 0, 'c', 'B', info, "Bytes allocated", "Number of total bytes allocated by this storage." ) -VSC_F(c_freed, uint64_t, 0, 'c', 'B', info, + +VSC_FF(c_freed, uint64_t, 0, 'c', 'B', info, "Bytes freed", "Number of total bytes returned to this storage." ) -VSC_F(g_alloc, uint64_t, 0, 'g', 'i', info, + +VSC_FF(g_alloc, uint64_t, 0, 'g', 'i', info, "Allocations outstanding", "Number of storage allocations outstanding." ) -VSC_F(g_bytes, uint64_t, 0, 'g', 'B', info, + +VSC_FF(g_bytes, uint64_t, 0, 'g', 'B', info, "Bytes outstanding", "Number of bytes allocated from the storage." ) -VSC_F(g_space, uint64_t, 0, 'g', 'B', info, + +VSC_FF(g_space, uint64_t, 0, 'g', 'B', info, "Bytes available", "Number of bytes left in the storage." ) #endif - /**********************************************************************/ #ifdef VSC_DO_SMA @@ -161,63 +176,75 @@ VSC_F(g_space, uint64_t, 0, 'g', 'B', info, /**********************************************************************/ #ifdef VSC_DO_SMF -VSC_F(g_smf, uint64_t, 0, 'g', 'i', info, +VSC_FF(g_smf, uint64_t, 0, 'g', 'i', info, "N struct smf", "" ) -VSC_F(g_smf_frag, uint64_t, 0, 'g', 'i', info, + +VSC_FF(g_smf_frag, uint64_t, 0, 'g', 'i', info, "N small free smf", "" ) -VSC_F(g_smf_large, uint64_t, 0, 'g', 'i', info, + +VSC_FF(g_smf_large, uint64_t, 0, 'g', 'i', info, "N large free smf", "" ) + #endif /**********************************************************************/ #ifdef VSC_DO_VBE -VSC_F(happy, uint64_t, 0, 'b', 'b', info, +VSC_FF(happy, uint64_t, 0, 'b', 'b', info, "Happy health probes", "" ) -VSC_F(bereq_hdrbytes, uint64_t, 0, 'c', 'B', info, + +VSC_FF(bereq_hdrbytes, uint64_t, 0, 'c', 'B', info, "Request header bytes", "Total backend request header bytes sent" ) -VSC_F(bereq_bodybytes, uint64_t, 0, 'c', 'B', info, + +VSC_FF(bereq_bodybytes, uint64_t, 0, 'c', 'B', info, "Request body bytes", "Total backend request body bytes sent" ) -VSC_F(beresp_hdrbytes, uint64_t, 0, 'c', 'B', info, + +VSC_FF(beresp_hdrbytes, uint64_t, 0, 'c', 'B', info, "Response header bytes", "Total backend response header bytes received" ) -VSC_F(beresp_bodybytes, uint64_t, 0, 'c', 'B', info, + +VSC_FF(beresp_bodybytes, uint64_t, 0, 'c', 'B', info, "Response body bytes", "Total backend response body bytes received" ) -VSC_F(pipe_hdrbytes, uint64_t, 0, 'c', 'B', info, + +VSC_FF(pipe_hdrbytes, uint64_t, 0, 'c', 'B', info, "Pipe request header bytes", "Total request bytes sent for piped sessions" ) -VSC_F(pipe_out, uint64_t, 0, 'c', 'B', info, + +VSC_FF(pipe_out, uint64_t, 0, 'c', 'B', info, "Piped bytes to backend", "Total number of bytes forwarded to backend in" " pipe sessions" ) -VSC_F(pipe_in, uint64_t, 0, 'c', 'B', info, + +VSC_FF(pipe_in, uint64_t, 0, 'c', 'B', info, "Piped bytes from backend", "Total number of bytes forwarded from backend in" " pipe sessions" ) -VSC_F(conn, uint64_t, 0, 'g', 'i', info, + +VSC_FF(conn, uint64_t, 0, 'g', 'i', info, "Concurrent connections to backend", "" ) -VSC_F(req, uint64_t, 0, 'c', 'i', info, + +VSC_FF(req, uint64_t, 0, 'c', 'i', info, "Backend requests sent", "" ) @@ -227,49 +254,63 @@ VSC_F(req, uint64_t, 0, 'c', 'i', info, /**********************************************************************/ #ifdef VSC_DO_MEMPOOL -VSC_F(live, uint64_t, 0, 'g', 'i', debug, +VSC_FF(live, uint64_t, 0, 'g', 'i', debug, "In use", "" ) -VSC_F(pool, uint64_t, 0, 'g', 'i', debug, + +VSC_FF(pool, uint64_t, 0, 'g', 'i', debug, "In Pool", "" ) -VSC_F(sz_wanted, uint64_t, 0, 'g', 'B', debug, + +VSC_FF(sz_wanted, uint64_t, 0, 'g', 'B', debug, "Size requested", "" ) -VSC_F(sz_actual, uint64_t, 0, 'g', 'B', debug, + +VSC_FF(sz_actual, uint64_t, 0, 'g', 'B', debug, "Size allocated", "" ) -VSC_F(allocs, uint64_t, 0, 'c', 'i', debug, + +VSC_FF(allocs, uint64_t, 0, 'c', 'i', debug, "Allocations", "" ) -VSC_F(frees, uint64_t, 0, 'c', 'i', debug, + +VSC_FF(frees, uint64_t, 0, 'c', 'i', debug, "Frees", "" ) -VSC_F(recycle, uint64_t, 0, 'c', 'i', debug, + +VSC_FF(recycle, uint64_t, 0, 'c', 'i', debug, "Recycled from pool", "" ) -VSC_F(timeout, uint64_t, 0, 'c', 'i', debug, + +VSC_FF(timeout, uint64_t, 0, 'c', 'i', debug, "Timed out from pool", "" ) -VSC_F(toosmall, uint64_t, 0, 'c', 'i', debug, + +VSC_FF(toosmall, uint64_t, 0, 'c', 'i', debug, "Too small to recycle", "" ) -VSC_F(surplus, uint64_t, 0, 'c', 'i', debug, + +VSC_FF(surplus, uint64_t, 0, 'c', 'i', debug, "Too many for pool", "" ) -VSC_F(randry, uint64_t, 0, 'c', 'i', debug, + +VSC_FF(randry, uint64_t, 0, 'c', 'i', debug, "Pool ran dry", "" ) #endif + +#undef VSC_FF + +/*lint -restore */ diff --git a/include/tbl/vsc_levels.h b/include/tbl/vsc_levels.h index 4a41cfe..f85dd2a 100644 --- a/include/tbl/vsc_levels.h +++ b/include/tbl/vsc_levels.h @@ -25,9 +25,7 @@ * 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. - */ - -/* + * * Fields (v, l, e, d): * v - Verbosity lvl: Field name, in C-source * l - Label: Display name, in stats programs @@ -36,10 +34,19 @@ */ /*lint -save -e525 -e539 */ + VSC_LEVEL_F(info, "INFO", "Informational counters", - "Counters giving runtime information") + "Counters giving runtime information" +) + VSC_LEVEL_F(diag, "DIAG", "Diagnostic counters", - "Counters giving diagnostic information") + "Counters giving diagnostic information" +) + VSC_LEVEL_F(debug, "DEBUG", "Debug counters", - "Counters giving Varnish internals debug information") + "Counters giving Varnish internals debug information" +) + +#undef VSC_LEVEL_F + /*lint -restore */ diff --git a/include/tbl/vsc_types.h b/include/tbl/vsc_types.h index 22bc127..20adc1c 100644 --- a/include/tbl/vsc_types.h +++ b/include/tbl/vsc_types.h @@ -25,9 +25,7 @@ * 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. - */ - -/* + * * Fields (n, l, e, d): * n - Name: Field name, in C-source * t - Type: Type name, in shm chunk @@ -41,25 +39,35 @@ */ /*lint -save -e525 -e539 */ + VSC_TYPE_F(main, "MAIN", "", "Child", "Child process main counters" ) + VSC_TYPE_F(mgt, "MGT", "MGT", "Master", "Management process counters" ) + VSC_TYPE_F(mempool, "MEMPOOL", "MEMPOOL", "Memory pool", "Memory pool counters" ) + VSC_TYPE_F(sma, "SMA", "SMA", "Storage malloc", "Malloc storage counters" ) + VSC_TYPE_F(smf, "SMF", "SMF", "Storage file", "File storage counters" ) + VSC_TYPE_F(vbe, "VBE", "VBE", "Backend", "Backend counters" ) + VSC_TYPE_F(lck, "LCK", "LCK", "Lock", "Mutex lock counters" ) + +#undef VSC_TYPE_F + /*lint -restore */ diff --git a/include/tbl/vsl_tags.h b/include/tbl/vsl_tags.h index 339675e..93a2bfe 100644 --- a/include/tbl/vsl_tags.h +++ b/include/tbl/vsl_tags.h @@ -43,6 +43,7 @@ */ /*lint -save -e525 -e539 */ + #define NODEF_NOTICE \ "NB: This log record is masked by default.\n\n" @@ -77,16 +78,6 @@ SLTM(SessOpen, 0, "Client connection opened", "\n" ) -/* - * XXX: compilers are _so_ picky, and won't let us do an #include - * XXX: in the middle of a macro invocation :-( - * XXX: If we could, these three lines would have described the - * XXX: 'reason' field below. -#define SESS_CLOSE(nm, s, err, desc) " " #nm "\n\t" desc "\n\n" -#include "tbl/sess_close.h" -#undef SESS_CLOSE -*/ - SLTM(SessClose, 0, "Client connection closed", "SessClose is the last record for any client connection.\n\n" "The format is::\n\n" @@ -208,6 +199,7 @@ SLTM(BogoHeader, 0, "Bogus HTTP received", "Contains the first 20 characters of received HTTP headers we could" " not make sense of. Applies to both req.http and beresp.http.\n\n" ) + SLTM(LostHeader, 0, "Failed attempt to set HTTP header", "Logs the header name of a failed HTTP header operation due to" " resource exhaustion or configured limits.\n\n" @@ -550,4 +542,6 @@ SLTM(H2TxBody, 0, "Transmitted HTTP2 frame body", ) #undef NODEF_NOTICE +#undef SLTM + /*lint -restore */ diff --git a/include/tbl/vsl_tags_http.h b/include/tbl/vsl_tags_http.h index 82a2219..393dbe5 100644 --- a/include/tbl/vsl_tags_http.h +++ b/include/tbl/vsl_tags_http.h @@ -44,21 +44,27 @@ */ /*lint -save -e525 -e539 */ + SLTH(Method, HTTP_HDR_METHOD, 1, 0, "method", "The HTTP request method used.\n\n" ) + SLTH(URL, HTTP_HDR_URL, 1, 0, "URL", "The HTTP request URL.\n\n" ) + SLTH(Protocol, HTTP_HDR_PROTO, 1, 1, "protocol", "The HTTP protocol version information.\n\n" ) + SLTH(Status, HTTP_HDR_STATUS, 0, 1, "status", "The HTTP status code received.\n\n" ) + SLTH(Reason, HTTP_HDR_REASON, 0, 1, "response", "The HTTP response string received.\n\n" ) + SLTH(Header, HTTP_HDR_FIRST, 1, 1, "header", "HTTP header contents.\n\n" "The format is::\n\n" @@ -68,6 +74,7 @@ SLTH(Header, HTTP_HDR_FIRST, 1, 1, "header", "\t+----- Header name\n" "\n" ) + SLTH(Unset, HTTP_HDR_UNSET, 0, 0, "unset header", "HTTP header contents.\n\n" "The format is::\n\n" @@ -77,7 +84,11 @@ SLTH(Unset, HTTP_HDR_UNSET, 0, 0, "unset header", "\t+----- Header name\n" "\n" ) + SLTH(Lost, HTTP_HDR_LOST, 0, 0, "lost header", "" ) + +#undef SLTH + /*lint -restore */ diff --git a/include/vapi/vsc.h b/include/vapi/vsc.h index 83ed155..ded83df 100644 --- a/include/vapi/vsc.h +++ b/include/vapi/vsc.h @@ -189,8 +189,5 @@ const struct VSC_level_desc *VSC_LevelDesc(unsigned level); #define VSC_F(n,t,l,s,f,v,d,e) #define VSC_DONE(U,l,t) #include "tbl/vsc_all.h" -#undef VSC_DO -#undef VSC_F -#undef VSC_DONE #endif /* VAPI_VSC_H_INCLUDED */ diff --git a/include/vapi/vsc_int.h b/include/vapi/vsc_int.h index 44a2d83..2566724 100644 --- a/include/vapi/vsc_int.h +++ b/include/vapi/vsc_int.h @@ -49,6 +49,3 @@ enum VSC_level_e { #define VSC_F(n,t,l,s,f,v,d,e) t n; #define VSC_DONE(u,l,t) }; #include "tbl/vsc_all.h" -#undef VSC_DO -#undef VSC_F -#undef VSC_DONE diff --git a/include/vapi/vsl_int.h b/include/vapi/vsl_int.h index 206c045..c28604d 100644 --- a/include/vapi/vsl_int.h +++ b/include/vapi/vsl_int.h @@ -91,7 +91,6 @@ enum VSL_tag_e { SLT__Bogus = 0, #define SLTM(foo,flags,sdesc,ldesc) SLT_##foo, #include "tbl/vsl_tags.h" -#undef SLTM SLT__Reserved = 254, SLT__Batch = 255 }; diff --git a/include/vcli_serve.h b/include/vcli_serve.h index 332432c..1d7d5f9 100644 --- a/include/vcli_serve.h +++ b/include/vcli_serve.h @@ -51,7 +51,6 @@ struct cli_cmd_desc { #define CLI_CMD(U,l,s,h,d,m,M) extern const struct cli_cmd_desc CLICMD_##U[1]; #include "tbl/cli_cmds.h" -#undef CLI_CMD /* A CLI command */ struct cli_proto { diff --git a/lib/libvarnishapi/vsc.c b/lib/libvarnishapi/vsc.c index 67da9d6..6aff617 100644 --- a/lib/libvarnishapi/vsc.c +++ b/lib/libvarnishapi/vsc.c @@ -54,7 +54,6 @@ enum { #define VSC_TYPE_F(n,t,l,e,d) \ VSC_type_order_##n, #include "tbl/vsc_types.h" -#undef VSC_TYPE_F }; struct vsc_vf { @@ -304,9 +303,6 @@ vsc_add_pt(struct vsc *vsc, const volatile void *ptr, } #include "tbl/vsc_all.h" -#undef VSC_DO -#undef VSC_F -#undef VSC_DONE /*-------------------------------------------------------------------- */ @@ -329,7 +325,6 @@ vsc_build_vf_list(struct VSM_data *vd) vsc_add_vf(vsc, &vsc->iter_fantom, \ &VSC_type_desc_##n, VSC_type_order_##n); #include "tbl/vsc_types.h" -#undef VSC_TYPE_F } } @@ -459,12 +454,10 @@ VSC_LevelDesc(unsigned level) #define VSC_TYPE_F(n,t,l,e,d) const char *VSC_type_##n = t; #include "tbl/vsc_types.h" -#undef VSC_TYPE_F #define VSC_TYPE_F(n,t,l,e,d) \ const struct VSC_type_desc VSC_type_desc_##n = {l,e,d}; #include "tbl/vsc_types.h" -#undef VSC_TYPE_F #define VSC_DO(U,l,t) const struct VSC_desc VSC_desc_##l[] = { #define VSC_F(n,t,l,s,f,v,d,e) {#n,#t,s,f,&VSC_level_desc_##v,d,e}, diff --git a/lib/libvarnishapi/vsl.c b/lib/libvarnishapi/vsl.c index 1efc453..a6e0f21 100644 --- a/lib/libvarnishapi/vsl.c +++ b/lib/libvarnishapi/vsl.c @@ -62,7 +62,6 @@ const char * const VSL_tags[SLT__MAX] = { # define SLTM(foo,flags,sdesc,ldesc) [SLT_##foo] = #foo, # include "tbl/vsl_tags.h" -# undef SLTM }; const unsigned VSL_tagflags[SLT__MAX] = { diff --git a/lib/libvarnishapi/vsl2rst.c b/lib/libvarnishapi/vsl2rst.c index b9f7413..e4767d5 100644 --- a/lib/libvarnishapi/vsl2rst.c +++ b/lib/libvarnishapi/vsl2rst.c @@ -48,7 +48,6 @@ static struct SLT tags[SLT__MAX] = { #define SLTM(name, flags, sdesc, ldesc) \ [SLT_##name] = { SLT_##name, flags, #name, sdesc, ldesc }, #include "tbl/vsl_tags.h" -#undef SLTM }; static int diff --git a/lib/libvcc/generate.py b/lib/libvcc/generate.py index 9ee7469..55bb359 100755 --- a/lib/libvcc/generate.py +++ b/lib/libvcc/generate.py @@ -986,8 +986,15 @@ def file_header(fo): * * Edit and run generate.py instead. */ + """) +def lint_start(fo): + fo.write('/*lint -save -e525 -e539 */\n\n') + +def lint_end(fo): + fo.write('\n/*lint -restore */\n') + ####################################################################### polish_tokens(tokens) @@ -1028,9 +1035,9 @@ fo = open(join(buildroot, "include/tbl/vcl_returns.h"), "w") file_header(fo) -fo.write("\n/*lint -save -e525 -e539 */\n") +lint_start(fo) -fo.write("\n#ifdef VCL_RET_MAC\n") +fo.write("#ifdef VCL_RET_MAC\n") ll = sorted(returns) for i in sorted(rets.keys()): fo.write("VCL_RET_MAC(%s, %s" % (i.lower(), i.upper())) @@ -1039,7 +1046,8 @@ for i in sorted(rets.keys()): if i in j[2]: fo.write("%sVCL_MET_%s" % (s, j[0].upper())) s = " |\n\t" - fo.write("\n)\n") + fo.write("\n)\n\n") +fo.write("#undef VCL_RET_MAC\n") fo.write("#endif\n") fo.write("\n#ifdef VCL_MET_MAC\n") @@ -1050,9 +1058,10 @@ for i in ll: for j in sorted(i[2]): fo.write("%s(1U << VCL_RET_%s)" % (p, j.upper())) p = " |\n\t" - fo.write("\n))\n") + fo.write(")\n)\n\n") +fo.write("#undef VCL_MET_MAC\n") fo.write("#endif\n") -fo.write("\n/*lint -restore */\n") +lint_end(fo) fo.close() ####################################################################### @@ -1282,11 +1291,12 @@ fo.close() ft = open(join(buildroot, "include/tbl/vcc_types.h"), "w") file_header(ft) -ft.write("/*lint -save -e525 -e539 */\n") +lint_start(ft) for vcltype in sorted(vcltypes.keys()): ft.write("VCC_TYPE(" + vcltype + ")\n") -ft.write("/*lint -restore */\n") +ft.write("#undef VCC_TYPE\n") +lint_end(ft) ft.close() ####################################################################### @@ -1294,6 +1304,7 @@ ft.close() fo = open(join(buildroot, "include/tbl/vrt_stv_var.h"), "w") file_header(fo) +lint_start(fo) for i in stv_variables: ct = vcltypes[i[1]] @@ -1301,6 +1312,8 @@ for i in stv_variables: fo.write(ct + ",\t" + i[2] + ")") fo.write("\n") +fo.write("#undef VRTSTVVAR\n") +lint_end(fo) fo.close() ####################################################################### diff --git a/lib/libvcc/vcc_action.c b/lib/libvcc/vcc_action.c index 60525a7..92e7b9f 100644 --- a/lib/libvcc/vcc_action.c +++ b/lib/libvcc/vcc_action.c @@ -295,7 +295,6 @@ parse_return(struct vcc *tl) h = #U; \ } #include "tbl/vcl_returns.h" -#undef VCL_RET_MAC if (h == NULL) { VSB_printf(tl->sb, "Expected return action name.\n"); vcc_ErrWhere(tl, tl->t); diff --git a/lib/libvcc/vcc_compile.c b/lib/libvcc/vcc_compile.c index e350c95..a7dc484 100644 --- a/lib/libvcc/vcc_compile.c +++ b/lib/libvcc/vcc_compile.c @@ -68,7 +68,6 @@ struct method method_tab[] = { { "none", 0U, 0}, #define VCL_MET_MAC(l,U,t,b) { "vcl_"#l, b, VCL_MET_##U }, #include "tbl/vcl_returns.h" -#undef VCL_MET_MAC { NULL, 0U, 0} }; @@ -426,7 +425,6 @@ EmitStruct(const struct vcc *tl) #define VCL_MET_MAC(l,u,t,b) \ Fc(tl, 0, "\t." #l "_func = VGC_function_vcl_" #l ",\n"); #include "tbl/vcl_returns.h" -#undef VCL_MET_MAC Fc(tl, 0, "};\n"); } diff --git a/lib/libvcc/vcc_compile.h b/lib/libvcc/vcc_compile.h index 008c9bb..d4b3964 100644 --- a/lib/libvcc/vcc_compile.h +++ b/lib/libvcc/vcc_compile.h @@ -101,13 +101,11 @@ struct type { #define VCC_TYPE(foo) extern const struct type foo[1]; #include "tbl/vcc_types.h" -#undef VCC_TYPE enum symkind { #define VCC_SYMB(uu, ll) SYM_##uu, #include "tbl/symbol_kind.h" -#undef VCC_SYMB }; typedef void sym_expr_t(struct vcc *tl, struct expr **, diff --git a/lib/libvcc/vcc_symb.c b/lib/libvcc/vcc_symb.c index 21dd348..10362a3 100644 --- a/lib/libvcc/vcc_symb.c +++ b/lib/libvcc/vcc_symb.c @@ -55,7 +55,6 @@ VCC_SymKind(struct vcc *tl, const struct symbol *s) switch(s->kind) { #define VCC_SYMB(uu, ll) case SYM_##uu: return(#ll); #include "tbl/symbol_kind.h" -#undef VCC_SYMB default: ErrInternal(tl); VSB_printf(tl->sb, "Symbol Kind 0x%x\n", s->kind); @@ -204,7 +203,6 @@ vcc_global(struct vcc *tl, struct symbol *sym, #define VCL_MET_MAC(l,u,t,b) sym->r_methods |= VCL_MET_##u; #include "tbl/vcl_returns.h" -#undef VCL_MET_MAC } struct symbol * diff --git a/lib/libvcc/vcc_types.c b/lib/libvcc/vcc_types.c index b47e7f3..4f0a5c4 100644 --- a/lib/libvcc/vcc_types.c +++ b/lib/libvcc/vcc_types.c @@ -166,7 +166,6 @@ VCC_Type(const char *p) #define VCC_TYPE(foo) if (!strcmp(p, #foo)) return (foo); #include "tbl/vcc_types.h" -#undef VCC_TYPE return (NULL); } diff --git a/lib/libvcc/vcc_xref.c b/lib/libvcc/vcc_xref.c index d492cc6..166bfe4 100644 --- a/lib/libvcc/vcc_xref.c +++ b/lib/libvcc/vcc_xref.c @@ -231,7 +231,6 @@ vcc_CheckActionRecurse(struct vcc *tl, struct proc *p, unsigned bitmap) vcc_ErrWhere(tl, p->return_tok[VCL_RET_##U]); \ } #include "tbl/vcl_returns.h" -#undef VCL_RET_MAC VSB_printf(tl->sb, "\n...in subroutine \"%.*s\"\n", PF(p->name)); @@ -276,7 +275,6 @@ vcc_checkaction1(struct vcc *tl, const struct symbol *sym) VSB_printf(tl->sb, " \"%s\"", #l); #include "tbl/vcl_returns.h" -#undef VCL_RET_MAC VSB_printf(tl->sb, "\n"); tl->err = 1; } From phk at FreeBSD.org Tue Jan 3 10:08:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 03 Jan 2017 11:08:05 +0100 Subject: [master] 95584d2 And I overlooked that bit of course... Message-ID: commit 95584d2170c03d30bc50aa9c2a3169587c0e6f4b Author: Poul-Henning Kamp Date: Tue Jan 3 10:07:26 2017 +0000 And I overlooked that bit of course... diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 96bbaf9..ebf5eb2 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -253,12 +253,11 @@ struct acct_bereq { #define L0(t, n) #define L1(t, n) t n; -#define VSC_F(n,t,l,s,f,v,d,e) L##l(t, n) +#define VSC_FF(n,t,l,s,f,v,d,e) L##l(t, n) struct dstat { unsigned summs; #include "tbl/vsc_f_main.h" }; -#undef VSC_F #undef L0 #undef L1 diff --git a/bin/varnishd/cache/cache_pool.c b/bin/varnishd/cache/cache_pool.c index 47e8611..be26db4 100644 --- a/bin/varnishd/cache/cache_pool.c +++ b/bin/varnishd/cache/cache_pool.c @@ -58,9 +58,8 @@ pool_sumstat(const struct dstat *src) Lck_AssertHeld(&wstat_mtx); #define L0(n) #define L1(n) (VSC_C_main->n += src->n) -#define VSC_F(n,t,l,s,f,v,d,e) L##l(n); +#define VSC_FF(n,t,l,s,f,v,d,e) L##l(n); #include "tbl/vsc_f_main.h" -#undef VSC_F #undef L0 #undef L1 } diff --git a/bin/varnishd/cache/cache_wrk.c b/bin/varnishd/cache/cache_wrk.c index 1e63c3b..47b3fd7 100644 --- a/bin/varnishd/cache/cache_wrk.c +++ b/bin/varnishd/cache/cache_wrk.c @@ -140,9 +140,8 @@ pool_addstat(struct dstat *dst, struct dstat *src) dst->summs++; #define L0(n) #define L1(n) (dst->n += src->n) -#define VSC_F(n,t,l,s,f,v,d,e) L##l(n); +#define VSC_FF(n,t,l,s,f,v,d,e) L##l(n); #include "tbl/vsc_f_main.h" -#undef VSC_F #undef L0 #undef L1 memset(src, 0, sizeof *src); diff --git a/bin/varnishstat/vsc2rst.c b/bin/varnishstat/vsc2rst.c index f955b78..d1a97f4 100644 --- a/bin/varnishstat/vsc2rst.c +++ b/bin/varnishstat/vsc2rst.c @@ -38,10 +38,6 @@ #define P(x) \ printf(x "\n") -#define VSC_LEVEL_F(v,l,e,d) \ - printf("%s ? %s\n\t%s\n\n", l, e, d); -#define VSC_F(n, t, l, s, f, v, d, e) \ - printf("%s ? %s (%s)\n\t%s\n\n", #n, d, VSC_level_##v, e); int main(int argc, char **argv) { @@ -50,18 +46,24 @@ int main(int argc, char **argv) P("COUNTER LEVELS"); P("=============="); P(""); +#define VSC_LEVEL_F(v,l,e,d) \ + printf("%s ? %s\n\t%s\n\n", l, e, d); #include "tbl/vsc_levels.h" P(""); P("MAIN COUNTERS (MAIN.*)"); P("======================"); P(""); +#define VSC_FF(n, t, l, s, f, v, d, e) \ + printf("%s ? %s (%s)\n\t%s\n\n", #n, d, VSC_level_##v, e); #include "tbl/vsc_f_main.h" P("MANAGEMENT PROCESS COUNTERS (MGT.*)"); P("==================================="); P(""); #define VSC_DO_MGT +#define VSC_FF(n, t, l, s, f, v, d, e) \ + printf("%s ? %s (%s)\n\t%s\n\n", #n, d, VSC_level_##v, e); #include "tbl/vsc_fields.h" #undef VSC_DO_MGT @@ -70,6 +72,8 @@ int main(int argc, char **argv) P("===================================="); P(""); #define VSC_DO_MEMPOOL +#define VSC_FF(n, t, l, s, f, v, d, e) \ + printf("%s ? %s (%s)\n\t%s\n\n", #n, d, VSC_level_##v, e); #include "tbl/vsc_fields.h" #undef VSC_DO_MEMPOOL @@ -78,6 +82,8 @@ int main(int argc, char **argv) P("==================================="); P(""); #define VSC_DO_SMA +#define VSC_FF(n, t, l, s, f, v, d, e) \ + printf("%s ? %s (%s)\n\t%s\n\n", #n, d, VSC_level_##v, e); #include "tbl/vsc_fields.h" #undef VSC_DO_SMA @@ -86,6 +92,8 @@ int main(int argc, char **argv) P("================================="); P(""); #define VSC_DO_SMF +#define VSC_FF(n, t, l, s, f, v, d, e) \ + printf("%s ? %s (%s)\n\t%s\n\n", #n, d, VSC_level_##v, e); #include "tbl/vsc_fields.h" #undef VSC_DO_SMF @@ -94,6 +102,8 @@ int main(int argc, char **argv) P("============================"); P(""); #define VSC_DO_VBE +#define VSC_FF(n, t, l, s, f, v, d, e) \ + printf("%s ? %s (%s)\n\t%s\n\n", #n, d, VSC_level_##v, e); #include "tbl/vsc_fields.h" #undef VSC_DO_VBE @@ -102,6 +112,8 @@ int main(int argc, char **argv) P("====================="); P(""); #define VSC_DO_LCK +#define VSC_FF(n, t, l, s, f, v, d, e) \ + printf("%s ? %s (%s)\n\t%s\n\n", #n, d, VSC_level_##v, e); #include "tbl/vsc_fields.h" #undef VSC_DO_LCK From phk at FreeBSD.org Tue Jan 3 10:28:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 03 Jan 2017 11:28:05 +0100 Subject: [master] aa0abc0 Let the include/tbl files control the emission of VSC documentation Message-ID: commit aa0abc05f83d1e6459ef8e78d132d87416c36c39 Author: Poul-Henning Kamp Date: Tue Jan 3 10:21:37 2017 +0000 Let the include/tbl files control the emission of VSC documentation diff --git a/bin/varnishstat/vsc2rst.c b/bin/varnishstat/vsc2rst.c index d1a97f4..c53dc72 100644 --- a/bin/varnishstat/vsc2rst.c +++ b/bin/varnishstat/vsc2rst.c @@ -36,86 +36,34 @@ #include "tbl/vsc_levels.h" #undef VSC_LEVEL_F -#define P(x) \ - printf(x "\n") +static void +L(const char *s) +{ + printf("\n%s\n", s); + for (;*s != '\0'; s++) + putchar('='); + putchar('\n'); + putchar('\n'); +} int main(int argc, char **argv) { (void)argc; (void)argv; - P("COUNTER LEVELS"); - P("=============="); - P(""); + L("COUNTER LEVELS"); + #define VSC_LEVEL_F(v,l,e,d) \ printf("%s ? %s\n\t%s\n\n", l, e, d); -#include "tbl/vsc_levels.h" - - P(""); - P("MAIN COUNTERS (MAIN.*)"); - P("======================"); - P(""); -#define VSC_FF(n, t, l, s, f, v, d, e) \ - printf("%s ? %s (%s)\n\t%s\n\n", #n, d, VSC_level_##v, e); -#include "tbl/vsc_f_main.h" - - P("MANAGEMENT PROCESS COUNTERS (MGT.*)"); - P("==================================="); - P(""); -#define VSC_DO_MGT -#define VSC_FF(n, t, l, s, f, v, d, e) \ - printf("%s ? %s (%s)\n\t%s\n\n", #n, d, VSC_level_##v, e); -#include "tbl/vsc_fields.h" -#undef VSC_DO_MGT - - P(""); - P("PER MEMORY POOL COUNTERS (MEMPOOL.*)"); - P("===================================="); - P(""); -#define VSC_DO_MEMPOOL -#define VSC_FF(n, t, l, s, f, v, d, e) \ - printf("%s ? %s (%s)\n\t%s\n\n", #n, d, VSC_level_##v, e); -#include "tbl/vsc_fields.h" -#undef VSC_DO_MEMPOOL - P(""); - P("PER MALLOC STORAGE COUNTERS (SMA.*)"); - P("==================================="); - P(""); -#define VSC_DO_SMA -#define VSC_FF(n, t, l, s, f, v, d, e) \ - printf("%s ? %s (%s)\n\t%s\n\n", #n, d, VSC_level_##v, e); -#include "tbl/vsc_fields.h" -#undef VSC_DO_SMA +#include "tbl/vsc_levels.h" - P(""); - P("PER FILE STORAGE COUNTERS (SMF.*)"); - P("================================="); - P(""); -#define VSC_DO_SMF -#define VSC_FF(n, t, l, s, f, v, d, e) \ - printf("%s ? %s (%s)\n\t%s\n\n", #n, d, VSC_level_##v, e); -#include "tbl/vsc_fields.h" -#undef VSC_DO_SMF +#define VSC_DO(U,l,t,h) L(h); - P(""); - P("PER BACKEND COUNTERS (VBE.*)"); - P("============================"); - P(""); -#define VSC_DO_VBE -#define VSC_FF(n, t, l, s, f, v, d, e) \ +#define VSC_F(n, t, l, s, f, v, d, e) \ printf("%s ? %s (%s)\n\t%s\n\n", #n, d, VSC_level_##v, e); -#include "tbl/vsc_fields.h" -#undef VSC_DO_VBE - P(""); - P("LOCK COUNTERS (LCK.*)"); - P("====================="); - P(""); -#define VSC_DO_LCK -#define VSC_FF(n, t, l, s, f, v, d, e) \ - printf("%s ? %s (%s)\n\t%s\n\n", #n, d, VSC_level_##v, e); -#include "tbl/vsc_fields.h" -#undef VSC_DO_LCK +#define VSC_DONE(U,l,t) +#include "tbl/vsc_all.h" return (0); } diff --git a/include/tbl/vsc_all.h b/include/tbl/vsc_all.h index 1c761d4..c77c2b8 100644 --- a/include/tbl/vsc_all.h +++ b/include/tbl/vsc_all.h @@ -29,13 +29,13 @@ /*lint -save -e525 -e539 */ -VSC_DO(MAIN, main, VSC_type_main) +VSC_DO(MAIN, main, VSC_type_main, "MAIN COUNTERS (MAIN.*)") #define VSC_FF VSC_F #include "tbl/vsc_f_main.h" #undef VSC_FF VSC_DONE(MAIN, main, VSC_type_main) -VSC_DO(MGT, mgt, VSC_type_mgt) +VSC_DO(MGT, mgt, VSC_type_mgt, "MANAGEMENT PROCESS COUNTERS (MGT.*)") #define VSC_DO_MGT #define VSC_FF VSC_F #include "tbl/vsc_fields.h" @@ -43,7 +43,7 @@ VSC_DO(MGT, mgt, VSC_type_mgt) #undef VSC_DO_MGT VSC_DONE(MGT, mgt, VSC_type_mgt) -VSC_DO(MEMPOOL, mempool, VSC_type_mempool) +VSC_DO(MEMPOOL, mempool, VSC_type_mempool, "MEMORY POOL COUNTERS (MEMPOOL.*)") #define VSC_DO_MEMPOOL #define VSC_FF VSC_F #include "tbl/vsc_fields.h" @@ -51,7 +51,7 @@ VSC_DO(MEMPOOL, mempool, VSC_type_mempool) #undef VSC_DO_MEMPOOL VSC_DONE(MEMPOOL, mempool, VSC_type_mempool) -VSC_DO(SMA, sma, VSC_type_sma) +VSC_DO(SMA, sma, VSC_type_sma, "MALLOC STORAGE COUNTERS (SMA.*)") #define VSC_DO_SMA #define VSC_FF VSC_F #include "tbl/vsc_fields.h" @@ -59,7 +59,7 @@ VSC_DO(SMA, sma, VSC_type_sma) #undef VSC_DO_SMA VSC_DONE(SMA, sma, VSC_type_sma) -VSC_DO(SMF, smf, VSC_type_smf) +VSC_DO(SMF, smf, VSC_type_smf, "FILE STORAGE COUNTERS (SMF.*)") #define VSC_DO_SMF #define VSC_FF VSC_F #include "tbl/vsc_fields.h" @@ -67,7 +67,7 @@ VSC_DO(SMF, smf, VSC_type_smf) #undef VSC_DO_SMF VSC_DONE(SMF, smf, VSC_type_smf) -VSC_DO(VBE, vbe, VSC_type_vbe) +VSC_DO(VBE, vbe, VSC_type_vbe, "BACKEND COUNTERS (VBE.*)") #define VSC_DO_VBE #define VSC_FF VSC_F #include "tbl/vsc_fields.h" @@ -75,7 +75,7 @@ VSC_DO(VBE, vbe, VSC_type_vbe) #undef VSC_DO_VBE VSC_DONE(VBE, vbe, VSC_type_vbe) -VSC_DO(LCK, lck, VSC_type_lck) +VSC_DO(LCK, lck, VSC_type_lck, "LOCK COUNTERS (LCK.*)") #define VSC_DO_LCK #define VSC_FF VSC_F #include "tbl/vsc_fields.h" diff --git a/include/vapi/vsc.h b/include/vapi/vsc.h index ded83df..bf1b1f5 100644 --- a/include/vapi/vsc.h +++ b/include/vapi/vsc.h @@ -185,7 +185,7 @@ const struct VSC_level_desc *VSC_LevelDesc(unsigned level); #include "tbl/vsc_types.h" #undef VSC_TYPE_F -#define VSC_DO(U,l,t) extern const struct VSC_desc VSC_desc_##l[]; +#define VSC_DO(U,l,t,h) extern const struct VSC_desc VSC_desc_##l[]; #define VSC_F(n,t,l,s,f,v,d,e) #define VSC_DONE(U,l,t) #include "tbl/vsc_all.h" diff --git a/include/vapi/vsc_int.h b/include/vapi/vsc_int.h index 2566724..352c8ba 100644 --- a/include/vapi/vsc_int.h +++ b/include/vapi/vsc_int.h @@ -35,17 +35,15 @@ enum VSC_level_e { #define VSC_LEVEL_F(v,l,e,d) \ VSC_level_##v, #include "tbl/vsc_levels.h" -#undef VSC_LEVEL_F VSC_level_MAX, }; /* Forward declare the static vsc type names */ #define VSC_TYPE_F(n,t,l,e,d) extern const char *VSC_type_##n; #include "tbl/vsc_types.h" -#undef VSC_TYPE_F /* Define the vsc type structs */ -#define VSC_DO(u,l,t) struct VSC_C_##l { +#define VSC_DO(u,l,t,h) struct VSC_C_##l { #define VSC_F(n,t,l,s,f,v,d,e) t n; #define VSC_DONE(u,l,t) }; #include "tbl/vsc_all.h" diff --git a/lib/libvarnishapi/vsc.c b/lib/libvarnishapi/vsc.c index 6aff617..74c567e 100644 --- a/lib/libvarnishapi/vsc.c +++ b/lib/libvarnishapi/vsc.c @@ -286,7 +286,7 @@ vsc_add_pt(struct vsc *vsc, const volatile void *ptr, VTAILQ_INSERT_TAIL(&vsc->pt_list, pt, list); } -#define VSC_DO(U,l,t) \ +#define VSC_DO(U,l,t,h) \ static void \ iter_##l(struct vsc *vsc, const struct VSC_desc *descs, \ struct vsc_vf *vf) \ @@ -337,16 +337,13 @@ vsc_build_pt_list(struct VSM_data *vd) vsc_delete_pt_list(vsc); VTAILQ_FOREACH(vf, &vsc->vf_list, list) { -#define VSC_DO(U,l,t) \ +#define VSC_DO(U,l,t,h) \ CHECK_OBJ_NOTNULL(vf, VSC_VF_MAGIC); \ if (!strcmp(vf->fantom.type, t)) \ iter_##l(vsc, VSC_desc_##l, vf); #define VSC_F(n,t,l,s,f,v,d,e) #define VSC_DONE(a,b,c) #include "tbl/vsc_all.h" -#undef VSC_DO -#undef VSC_F -#undef VSC_DONE } } @@ -459,10 +456,7 @@ VSC_LevelDesc(unsigned level) const struct VSC_type_desc VSC_type_desc_##n = {l,e,d}; #include "tbl/vsc_types.h" -#define VSC_DO(U,l,t) const struct VSC_desc VSC_desc_##l[] = { +#define VSC_DO(U,l,t,h) const struct VSC_desc VSC_desc_##l[] = { #define VSC_F(n,t,l,s,f,v,d,e) {#n,#t,s,f,&VSC_level_desc_##v,d,e}, #define VSC_DONE(U,l,t) }; #include "tbl/vsc_all.h" -#undef VSC_DO -#undef VSC_F -#undef VSC_DONE From phk at FreeBSD.org Tue Jan 3 15:54:04 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 03 Jan 2017 16:54:04 +0100 Subject: [4.1] 4da4d6b Make 4.1 compile on !linux again. Message-ID: commit 4da4d6b3b7d5d2fbc66f4fbf7a10c6b062e0b8c6 Author: Poul-Henning Kamp Date: Tue Jan 3 15:53:17 2017 +0000 Make 4.1 compile on !linux again. Fixes: #2178 diff --git a/lib/libvarnish/vtcp.c b/lib/libvarnish/vtcp.c index 62a9fb6..d28b99c 100644 --- a/lib/libvarnish/vtcp.c +++ b/lib/libvarnish/vtcp.c @@ -38,9 +38,7 @@ #endif #include -#ifdef __linux -# include -#endif +#include #include #include From phk at FreeBSD.org Tue Jan 3 16:32:04 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 03 Jan 2017 17:32:04 +0100 Subject: [master] 3662d20 Use unsigned with bit-ops. Message-ID: commit 3662d20a088f25306b8bf70720bcf42ccd487249 Author: Poul-Henning Kamp Date: Tue Jan 3 16:30:50 2017 +0000 Use unsigned with bit-ops. diff --git a/bin/varnishd/storage/storage_file.c b/bin/varnishd/storage/storage_file.c index 139dc02..033d325 100644 --- a/bin/varnishd/storage/storage_file.c +++ b/bin/varnishd/storage/storage_file.c @@ -436,8 +436,8 @@ smf_alloc(const struct stevedore *st, size_t size) CAST_OBJ_NOTNULL(sc, st->priv, SMF_SC_MAGIC); assert(size > 0); - size += (sc->pagesize - 1L); - size &= ~(sc->pagesize - 1L); + size += (sc->pagesize - 1UL); + size &= ~(sc->pagesize - 1UL); Lck_Lock(&sc->mtx); sc->stats->c_req++; smf = alloc_smf(sc, size); From varnish-commit at varnish-cache.org Tue Jan 3 22:47:35 2017 From: varnish-commit at varnish-cache.org (varnish-commit at varnish-cache.org) Date: 3 Jan 2017 18:47:35 -0400 Subject: Salary [$1500 /week] Message-ID: <003e01d26617$040af35f$8ae71488$@varnish-cache.org> Dear varnish-commit, We are looking for employees working remotely. My name is Connie, I am the personnel manager of a large International company. Most of the work you can do from home, that is, at a distance. Salary is $2300-$5600. If you are interested in this offer, please visit Our Site d_healthBest regards! -------------- next part -------------- An HTML attachment was scrubbed... URL: From hermunn at varnish-software.com Thu Jan 5 10:19:05 2017 From: hermunn at varnish-software.com (Pål Hermunn Johansen) Date: Thu, 05 Jan 2017 11:19:05 +0100 Subject: [4.1] c261c23 Document default timeout for varnishtest Message-ID: commit c261c23605a61c1bd5350318b5407b59d1e90403 Author: Ricardo Nabinger Sanchez Date: Tue Dec 20 11:01:26 2016 -0200 Document default timeout for varnishtest diff --git a/doc/sphinx/reference/varnishtest.rst b/doc/sphinx/reference/varnishtest.rst index 5bfca7b..e0e1366 100644 --- a/doc/sphinx/reference/varnishtest.rst +++ b/doc/sphinx/reference/varnishtest.rst @@ -50,7 +50,7 @@ The following options are available: -q Quiet mode: report only failures --t duration Time tests out after this long +-t duration Time tests out after this long (default: 60s) -v Verbose mode: always report test log From phk at FreeBSD.org Thu Jan 5 11:28:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 05 Jan 2017 12:28:05 +0100 Subject: [master] 6147338 Avoid having two files called "params.h" Message-ID: commit 61473385913dae03d0e3655bfae0a8eac356a019 Author: Poul-Henning Kamp Date: Thu Jan 5 11:27:28 2017 +0000 Avoid having two files called "params.h" diff --git a/bin/varnishd/Makefile.am b/bin/varnishd/Makefile.am index 41fcf85..7ab414a 100644 --- a/bin/varnishd/Makefile.am +++ b/bin/varnishd/Makefile.am @@ -136,7 +136,7 @@ nobase_pkginclude_HEADERS = \ cache/cache_backend.h \ cache/cache_director.h \ common/common.h \ - common/params.h \ + common/com_params.h \ waiter/waiter.h varnishd_CFLAGS = \ diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index ebf5eb2..a1564e5 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -54,7 +54,7 @@ #include #include -#include "common/params.h" +#include "common/com_params.h" /*--------------------------------------------------------------------*/ diff --git a/bin/varnishd/common/com_params.h b/bin/varnishd/common/com_params.h new file mode 100644 index 0000000..269f188 --- /dev/null +++ b/bin/varnishd/common/com_params.h @@ -0,0 +1,110 @@ +/*- + * Copyright (c) 2006 Verdens Gang AS + * Copyright (c) 2006-2011 Varnish Software AS + * All rights reserved. + * + * Author: Poul-Henning Kamp + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This file contains the heritage passed when mgt forks cache + */ + +#ifdef COMMON_PARAMS_H +#error "Multiple includes of common/params.h" +#endif +#define COMMON_PARAMS_H + +#include + +#include "vre.h" + +#define VSM_CLASS_PARAM "Params" + +enum debug_bits { +#define DEBUG_BIT(U, l, d) DBG_##U, +#include "tbl/debug_bits.h" + DBG_Reserved +}; + +enum feature_bits { +#define FEATURE_BIT(U, l, d, ld) FEATURE_##U, +#include "tbl/feature_bits.h" + FEATURE_Reserved +}; + +struct poolparam { + unsigned min_pool; + unsigned max_pool; + double max_age; +}; + +struct params { + +#define ptyp_bool unsigned +#define ptyp_bytes ssize_t +#define ptyp_bytes_u unsigned +#define ptyp_double double +#define ptyp_poolparam struct poolparam +#define ptyp_timeout double +#define ptyp_uint unsigned +#define ptyp_vsl_buffer unsigned +#define ptyp_vsl_reclen unsigned +#define PARAM(nm, ty, mi, ma, de, un, fl, st, lt, fn) ptyp_##ty nm; +#include +#undef ptyp_bool +#undef ptyp_bytes +#undef ptyp_bytes_u +#undef ptyp_double +#undef ptyp_poolparam +#undef ptyp_timeout +#undef ptyp_uint +#undef ptyp_vsl_buffer +#undef ptyp_vsl_reclen + + /* Unprivileged user / group */ + uid_t uid; + gid_t gid; + + /* Worker threads and pool */ + unsigned wthread_min; + unsigned wthread_max; + unsigned wthread_reserve; + double wthread_timeout; + unsigned wthread_pools; + double wthread_add_delay; + double wthread_fail_delay; + double wthread_destroy_delay; + unsigned wthread_stats_rate; + ssize_t wthread_stacksize; + unsigned wthread_queue_limit; + + struct vre_limits vre_limits; + + struct poolparam req_pool; + struct poolparam sess_pool; + struct poolparam vbo_pool; + + uint8_t vsl_mask[256>>3]; + uint8_t debug_bits[(DBG_Reserved+7)>>3]; + uint8_t feature_bits[(FEATURE_Reserved+7)>>3]; +}; diff --git a/bin/varnishd/common/common_vsm.c b/bin/varnishd/common/common_vsm.c index 860b32c..9a09e07 100644 --- a/bin/varnishd/common/common_vsm.c +++ b/bin/varnishd/common/common_vsm.c @@ -41,7 +41,7 @@ #include #include "common.h" -#include "common/params.h" +#include "common/com_params.h" #include "vsm_priv.h" #include "vmb.h" diff --git a/bin/varnishd/common/params.h b/bin/varnishd/common/params.h deleted file mode 100644 index 269f188..0000000 --- a/bin/varnishd/common/params.h +++ /dev/null @@ -1,110 +0,0 @@ -/*- - * Copyright (c) 2006 Verdens Gang AS - * Copyright (c) 2006-2011 Varnish Software AS - * All rights reserved. - * - * Author: Poul-Henning Kamp - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * This file contains the heritage passed when mgt forks cache - */ - -#ifdef COMMON_PARAMS_H -#error "Multiple includes of common/params.h" -#endif -#define COMMON_PARAMS_H - -#include - -#include "vre.h" - -#define VSM_CLASS_PARAM "Params" - -enum debug_bits { -#define DEBUG_BIT(U, l, d) DBG_##U, -#include "tbl/debug_bits.h" - DBG_Reserved -}; - -enum feature_bits { -#define FEATURE_BIT(U, l, d, ld) FEATURE_##U, -#include "tbl/feature_bits.h" - FEATURE_Reserved -}; - -struct poolparam { - unsigned min_pool; - unsigned max_pool; - double max_age; -}; - -struct params { - -#define ptyp_bool unsigned -#define ptyp_bytes ssize_t -#define ptyp_bytes_u unsigned -#define ptyp_double double -#define ptyp_poolparam struct poolparam -#define ptyp_timeout double -#define ptyp_uint unsigned -#define ptyp_vsl_buffer unsigned -#define ptyp_vsl_reclen unsigned -#define PARAM(nm, ty, mi, ma, de, un, fl, st, lt, fn) ptyp_##ty nm; -#include -#undef ptyp_bool -#undef ptyp_bytes -#undef ptyp_bytes_u -#undef ptyp_double -#undef ptyp_poolparam -#undef ptyp_timeout -#undef ptyp_uint -#undef ptyp_vsl_buffer -#undef ptyp_vsl_reclen - - /* Unprivileged user / group */ - uid_t uid; - gid_t gid; - - /* Worker threads and pool */ - unsigned wthread_min; - unsigned wthread_max; - unsigned wthread_reserve; - double wthread_timeout; - unsigned wthread_pools; - double wthread_add_delay; - double wthread_fail_delay; - double wthread_destroy_delay; - unsigned wthread_stats_rate; - ssize_t wthread_stacksize; - unsigned wthread_queue_limit; - - struct vre_limits vre_limits; - - struct poolparam req_pool; - struct poolparam sess_pool; - struct poolparam vbo_pool; - - uint8_t vsl_mask[256>>3]; - uint8_t debug_bits[(DBG_Reserved+7)>>3]; - uint8_t feature_bits[(FEATURE_Reserved+7)>>3]; -}; diff --git a/bin/varnishd/mgt/mgt.h b/bin/varnishd/mgt/mgt.h index 30b120a..7f7f17f 100644 --- a/bin/varnishd/mgt/mgt.h +++ b/bin/varnishd/mgt/mgt.h @@ -31,7 +31,7 @@ #include #include "common/common.h" -#include "common/params.h" +#include "common/com_params.h" struct cli; struct parspec; From phk at FreeBSD.org Thu Jan 5 15:11:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 05 Jan 2017 16:11:05 +0100 Subject: [master] b7fe401 Try to get at least a little coverage on varnishtop Message-ID: commit b7fe4019f19c6a30db74a6b43c51b09f06d74361 Author: Poul-Henning Kamp Date: Thu Jan 5 15:10:02 2017 +0000 Try to get at least a little coverage on varnishtop diff --git a/bin/varnishtest/programs.h b/bin/varnishtest/programs.h index f7ffbf9..1bc85c8 100644 --- a/bin/varnishtest/programs.h +++ b/bin/varnishtest/programs.h @@ -27,9 +27,11 @@ * */ -VTC_PROG(varnishd) VTC_PROG(varnishadm) -VTC_PROG(varnishstat) +VTC_PROG(varnishd) VTC_PROG(varnishhist) VTC_PROG(varnishlog) VTC_PROG(varnishncsa) +VTC_PROG(varnishstat) +VTC_PROG(varnishtop) +#undef VTC_PROG diff --git a/bin/varnishtest/tests/u00004.vtc b/bin/varnishtest/tests/u00004.vtc new file mode 100644 index 0000000..561672f --- /dev/null +++ b/bin/varnishtest/tests/u00004.vtc @@ -0,0 +1,19 @@ +varnishtest "varnishtop coverage" + +server s1 { + rxreq + txresp +} -start + +varnish v1 -vcl+backend "" -start + +process p1 {varnishtop -1 -n ${v1_name} > /dev/null} -start + +client c1 { + txreq + rxresp +} -run + +process p1 -wait + +process p2 {varnishtop -1 -n ${v1_name} > /dev/null} -start -wait diff --git a/bin/varnishtest/vtc_main.c b/bin/varnishtest/vtc_main.c index 2f44f4a..8f9284a 100644 --- a/bin/varnishtest/vtc_main.c +++ b/bin/varnishtest/vtc_main.c @@ -384,7 +384,7 @@ i_mode(void) sep = ":"; \ } while (0); #include "programs.h" -#undef VTC_PROG + VSB_printf(vsb, ":%s", getenv("PATH")); AZ(VSB_finish(vsb)); From varnish-commit at varnish-cache.org Fri Jan 6 06:51:12 2017 From: varnish-commit at varnish-cache.org (varnish-commit at varnish-cache.org) Date: Fri, 06 Jan 2017 10:51:12 +0400 Subject: Speech of welcome Message-ID: <586F3E60.1070702@varnish-cache.org> Dear varnish-commit, We are looking for employees working remotely. My name is Callie, I am the personnel manager of a large International company. Most of the work you can do from home, that is, at a distance. Salary is $2000-$5200. If you are interested in this offer, please visit Our Site d_healthBest regards! -------------- next part -------------- An HTML attachment was scrubbed... URL: From varnish-commit at varnish-cache.org Fri Jan 6 13:24:18 2017 From: varnish-commit at varnish-cache.org (varnish-commit at varnish-cache.org) Date: 6 Jan 2017 19:24:18 +0600 Subject: Vacancy #627 Message-ID: <004001d26824$07e6e9b1$22ba2ca3$@varnish-cache.org> Dear varnish-commit, We are looking for employees working remotely. My name is Jarrett, I am the personnel manager of a large International company. Most of the work you can do from home, that is, at a distance. Salary is $2700-$5800. If you are interested in this offer, please visit Our Site d_healthHave a nice day! -------------- next part -------------- An HTML attachment was scrubbed... URL: From hermunn at varnish-software.com Fri Jan 6 13:13:04 2017 From: hermunn at varnish-software.com (Pål Hermunn Johansen) Date: Fri, 06 Jan 2017 14:13:04 +0100 Subject: [4.1] 18c9983 Handle comparison between backend and different things Message-ID: commit 18c9983ebd74f8873b9fd8c2a979a9c518ccc741 Author: P?l Hermunn Johansen Date: Fri Jan 6 14:07:42 2017 +0100 Handle comparison between backend and different things Comparing a backend with various stuff was not handled well. The test case shows what will give a compilation error, and the results of ways of comparing backends. When using a director, the demonstrated results are not obvious. Fixes: #2168 diff --git a/bin/varnishtest/tests/r02168.vtc b/bin/varnishtest/tests/r02168.vtc new file mode 100644 index 0000000..c5670a8 --- /dev/null +++ b/bin/varnishtest/tests/r02168.vtc @@ -0,0 +1,145 @@ +varnishtest "Comparing backends with and without a director" + +# How you cannot compare backends - test error handling +varnish v1 -errvcl {Not a backend} { + sub vcl_backend_response { + if (bereq.backend == bereq.http.a) { + } + } +} + +varnish v1 -errvcl {Backend not found} { + sub vcl_backend_response { + if (bereq.backend == foo) { + } + } +} + +varnish v1 -errvcl {Expected ID got} { + sub vcl_backend_response { + if (bereq.backend == "foo") { + } + } +} + +# Compare backends with regular backend: +server s1 { + rxreq + txresp -status 200 +} -start + +varnish v1 -vcl { + backend b1 { + .host = "${s1_addr}"; + .port = "${s1_port}"; + } + + sub vcl_recv { + set req.backend_hint = b1; + } + + sub vcl_backend_response { + set bereq.http.d1-backend = b1; + set bereq.http.req-backend = bereq.backend; + if (bereq.http.d1-backend == bereq.http.req-backend) { + set beresp.http.be-str-str-compare = "same"; + } else { + set beresp.http.be-str-str-compare = "different"; + } + if (bereq.backend == b1) { + set beresp.http.be-back-back-compare = "same"; + } else { + set beresp.http.be-back-back-compare = "different"; + } + } + + sub vcl_deliver { + set req.http.d1-backend = b1; + set req.http.hint = req.backend_hint; + if (req.http.d1-backend == req.http.hint) { + set resp.http.deliver-str-str-compare = "same"; + } else { + set resp.http.deliver-str-str-compare = "different"; + } + if (req.backend_hint == b1) { + set resp.http.deliver-back-back-compare = "same"; + } else { + set resp.http.deliver-back-back-compare = "different"; + } + } + +} -start + +client c1 { + txreq + rxresp + expect resp.status == 200 + expect resp.http.be-str-str-compare == "same" + expect resp.http.be-back-back-compare == "same" + expect resp.http.deliver-str-str-compare == "same" + expect resp.http.deliver-back-back-compare == "same" +} -run + +# In the second part, using a director will yield different results (see bottom): +server s2 { + rxreq + txresp -status 200 +} -start + +varnish v2 -vcl { + import ${vmod_directors}; + backend b1 { + .host = "${s2_addr}"; + .port = "${s2_port}"; + } + + sub vcl_init { + new d1 = directors.round_robin(); + d1.add_backend(b1); + } + + sub vcl_recv { + set req.backend_hint = d1.backend(); + } + + sub vcl_backend_response { + set bereq.http.d1-backend = d1.backend(); + set bereq.http.req-backend = bereq.backend; + if (bereq.http.d1-backend == bereq.http.req-backend) { + set beresp.http.be-str-str-compare = "same"; + } else { + set beresp.http.be-str-str-compare = "different"; + } + if (bereq.backend == b1) { + set beresp.http.be-back-back-compare = "same"; + } else { + set beresp.http.be-back-back-compare = "different"; + } + } + + sub vcl_deliver { + set req.http.d1-backend = d1.backend(); + set req.http.hint = req.backend_hint; + if (req.http.d1-backend == req.http.hint) { + set resp.http.deliver-str-str-compare = "same"; + } else { + set resp.http.deliver-str-str-compare = "different"; + } + if (req.backend_hint == b1) { + set resp.http.deliver-back-back-compare = "same"; + } else { + set resp.http.deliver-back-back-compare = "different"; + } + } + +} -start + +client c2 -connect ${v2_sock} { + txreq + rxresp + expect resp.status == 200 + expect resp.http.be-str-str-compare == "same" + expect resp.http.be-back-back-compare == "different" + expect resp.http.deliver-str-str-compare == "same" + expect resp.http.deliver-back-back-compare == "different" +} -run diff --git a/lib/libvcc/vcc_expr.c b/lib/libvcc/vcc_expr.c index 3066db3..65bd7a4 100644 --- a/lib/libvcc/vcc_expr.c +++ b/lib/libvcc/vcc_expr.c @@ -1237,7 +1237,16 @@ vcc_expr_cmp(struct vcc *tl, struct expr **e, enum var_type fmt) if (sym == NULL) { VSB_printf(tl->sb, "Backend not found: "); vcc_ErrToken(tl, tl->t); - VSB_printf(tl->sb, "\n"); + VSB_printf(tl->sb, + " (expected a backend identifier)\n"); + vcc_ErrWhere(tl, tl->t); + return; + } else if (sym->kind != SYM_BACKEND) { + VSB_printf(tl->sb, "Not a backend: "); + vcc_ErrToken(tl, tl->t); + VSB_printf(tl->sb, + " (right hand side must be a backend - saw a %s)\n", + VCC_SymKind(tl, sym)); vcc_ErrWhere(tl, tl->t); return; } From dridi.boukelmoune at gmail.com Fri Jan 6 17:45:05 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 06 Jan 2017 18:45:05 +0100 Subject: [master] 6b4c495 Make sure VTCs run against all binaries Message-ID: commit 6b4c4955d06308f898987777c7d656fa3d894b8e Author: Dridi Boukelmoune Date: Fri Jan 6 16:07:55 2017 +0100 Make sure VTCs run against all binaries Lexicographic order is fine, but can lead to interesting things like: ================================================================ Testsuite summary for Varnish trunk ================================================================ # TOTAL: 571 # PASS: 565 # SKIP: 6 # XFAIL: 0 # FAIL: 0 # XPASS: 0 # ERROR: 0 ================================================================ Making check in varnishtop CC varnishtop-varnishtop.o CC varnishtop-varnishtop_options.o CCLD varnishtop Making check in etc Making check in doc Making check in graphviz Making check in sphinx Making check in man In other words, picking `varnishtop` from somewhere else in the PATH. Since SUBDIRS are processed sequentially, this is change is enough to cover parallel builds too. While at it, polish u4.vtc a bit: get rid of the shell process. diff --git a/bin/Makefile.am b/bin/Makefile.am index b35764d..f103fe9 100644 --- a/bin/Makefile.am +++ b/bin/Makefile.am @@ -1,5 +1,7 @@ # +# XXX: varnishtest MUST always be built last + SUBDIRS = \ varnishadm \ varnishd \ @@ -7,5 +9,5 @@ SUBDIRS = \ varnishlog \ varnishncsa \ varnishstat \ - varnishtest \ - varnishtop + varnishtop \ + varnishtest diff --git a/bin/varnishtest/tests/u00004.vtc b/bin/varnishtest/tests/u00004.vtc index 561672f..e7743b4 100644 --- a/bin/varnishtest/tests/u00004.vtc +++ b/bin/varnishtest/tests/u00004.vtc @@ -7,7 +7,7 @@ server s1 { varnish v1 -vcl+backend "" -start -process p1 {varnishtop -1 -n ${v1_name} > /dev/null} -start +process p1 {exec varnishtop -1 -n ${v1_name} >/dev/null} -start client c1 { txreq @@ -16,4 +16,4 @@ client c1 { process p1 -wait -process p2 {varnishtop -1 -n ${v1_name} > /dev/null} -start -wait +process p2 {exec varnishtop -1 -n ${v1_name} >/dev/null} -start -wait From phk at FreeBSD.org Sat Jan 7 10:39:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Sat, 07 Jan 2017 11:39:05 +0100 Subject: [master] 48f1cba Add a program to compactly summarize gcov(1) results. Message-ID: commit 48f1cbac839f2a398d5a67512c7924b043e8d493 Author: Poul-Henning Kamp Date: Sat Jan 7 08:35:17 2017 +0000 Add a program to compactly summarize gcov(1) results. diff --git a/tools/gcov_digest.py b/tools/gcov_digest.py new file mode 100644 index 0000000..5fce2f5 --- /dev/null +++ b/tools/gcov_digest.py @@ -0,0 +1,194 @@ +#!/usr/bin/env python +# +# Copyright (c) 2017 Varnish Software AS +# All rights reserved. +# +# Author: Poul-Henning Kamp +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. + +""" +This program produces a compact summ of gcov run on all .o files +found in a subdirectory tree. + +Options: + + -g gcov-program + default:gcov49 + + -o output-filename + default: stdout + + -x exclude-subdir + default ".git" and ".deps" + + Arguments: + + directories to process + +""" + +from __future__ import print_function + +import os +import sys +import getopt +import subprocess + +counts = {} +lengths = {} + +exclude = [".git", ".deps",] + +def process_gcov(fn, sn): + """ Sum .gcov file into counts, then delete it """ + dd = counts.get(sn) + if dd is None: + dd = {} + for ln in open(fn): + d = ln.split(":") + cnt = d[0].strip() + ll = d[1] + if cnt == "-": + continue + if cnt == "#####": + cnt = 0 + else: + cnt = int(cnt) + lno = int(d[1]) + if lno not in dd: + dd[lno] = 0 + dd[lno] += cnt + counts[sn] = dd + pl = lengths.get(sn) + ll = ll.strip() + if d[2] == "/*EOF*/\n": + ll = pl + elif pl != ll and not pl is None: + print("CONFLICT", fn, ll, pl) + ll = "-1" + lengths[sn] = ll + os.remove(fn) + +def run_gcov(prog, subdir): + """ Walk tree, run gcov, process output """ + for root, dirs, files in os.walk(subdir): + for i in exclude: + if i in dirs: + dirs.remove(i) + for fn in files: + if fn[-2:] != ".o": + continue + + # if we find the .o file in a .../.libs the sources + # must be found relative to the parent directory + + if root[-6:] == "/.libs": + x = subprocess.check_output( + ["cd " + root + "/.. && " + + "exec " + prog + " -r .libs/" + fn], + stderr=subprocess.STDOUT, shell=True) + pf = ".." + else: + x = subprocess.check_output( + ["cd " + root + " && " + + "exec " + prog + " -r " + fn], + stderr=subprocess.STDOUT, shell=True) + pf = "" + + for ln in x.split("\n"): + ln = ln.split() + if len(ln) == 0: + continue + if ln[0] == "Creating": + gn = ln[1].strip("'") + assert gn[-5:] == ".gcov" + sn = gn[:-5] + process_gcov( + os.path.join(root, pf, gn), sn) + +def produce_output(fdo): + """ + Produce compact output file + + Format: + linefm [lineto] count + + "+" in linefm means "previous line + 1" + "." in count means "same as previous count" + """ + + for sn, cnt in counts.iteritems(): + fdo.write("/" + sn + " " + str(lengths[sn]) + "\n") + lnos = list(cnt.iteritems()) + lnos.sort() + pln = -1 + pcn = -1 + while len(lnos) > 0: + ln, cn = lnos.pop(0) + lnl = ln + while len(lnos) > 0: + lnn, cnn = lnos[0] + if lnl + 1 != lnn or cnn != cn: + break + lnos.pop(0) + lnl = lnn + if ln == pln + 1: + s = "+ " + else: + s = "%d " % ln + + if ln != lnl: + s += "%d " % lnl + pln = lnl + else: + pln = ln + + if cn == pcn: + s += "." + else: + s += "%d" % cn + pcn = cn + fdo.write(s + "\n") + +if __name__ == "__main__": + + optlist, args = getopt.getopt(sys.argv[1:], "g:o:x:") + + fo = sys.stdout + gcovprog = "gcov49" + + for f, v in optlist: + if f == '-o' and v == '-': + fo = sys.stdout + elif f == '-o': + fo = open(v, "w") + elif f == '-g': + gcovprog = v + elif f == '-x': + exclude.append(v) + else: + assert False + for dn in args: + run_gcov(gcovprog, dn) + + produce_output(fo) From phk at FreeBSD.org Sat Jan 7 10:39:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Sat, 07 Jan 2017 11:39:05 +0100 Subject: [master] cf17fc1 Close std{in|out|err} before invoking Eric. Message-ID: commit cf17fc1671f44b58cb81f9eb14b21f13139593f1 Author: Poul-Henning Kamp Date: Sat Jan 7 10:37:20 2017 +0000 Close std{in|out|err} before invoking Eric. diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index 5242370..11d1625 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -575,6 +575,36 @@ mgt_eric(void) exit(-1); } +static void +mgt_eric_im_done(int eric_fd, unsigned u) +{ + int fd; + + if (eric_fd < 0) + return; + + if (u == 0) + u = ERIC_MAGIC; + + fd = open("/dev/null", O_RDONLY); + assert(fd >= 0); + assert(dup2(fd, STDIN_FILENO) == STDIN_FILENO); + AZ(close(fd)); + + fd = open("/dev/null", O_WRONLY); + assert(fd >= 0); + assert(dup2(fd, STDOUT_FILENO) == STDOUT_FILENO); + AZ(close(fd)); + + fd = open("/dev/null", O_WRONLY); + assert(fd >= 0); + assert(dup2(fd, STDERR_FILENO) == STDERR_FILENO); + AZ(close(fd)); + + assert(write(eric_fd, &u, sizeof u) == sizeof u); + AZ(close(eric_fd)); +} + /*--------------------------------------------------------------------*/ int @@ -906,12 +936,7 @@ main(int argc, char * const *argv) u = MGT_Run(); - if (eric_fd > 0) { - if (u == 0) - u = ERIC_MAGIC; - assert(write(eric_fd, &u, sizeof u) == sizeof u); - AZ(close(eric_fd)); - } + mgt_eric_im_done(eric_fd, u); o = vev_schedule(mgt_evb); if (o != 0) From phk at FreeBSD.org Sat Jan 7 12:24:04 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Sat, 07 Jan 2017 13:24:04 +0100 Subject: [master] 1041a3d Attempt to make the tmp dir owned by 'varnish' for priv-sep Message-ID: commit 1041a3db81bd48f7c3185055c8815b09e24c488e Author: Poul-Henning Kamp Date: Sat Jan 7 12:05:22 2017 +0000 Attempt to make the tmp dir owned by 'varnish' for priv-sep diff --git a/tools/vtest.sh b/tools/vtest.sh index 6e1d8ca..fb55132 100755 --- a/tools/vtest.sh +++ b/tools/vtest.sh @@ -36,6 +36,9 @@ export MAKEFLAGS="${MAKEFLAGS:--j2}" export TMPDIR=`pwd`/tmp mkdir -p tmp +# Try to make varnish own it, in case we run as root +chown varnish tmp > /dev/null 2>&1 || true + # Message to be shown in result pages # Max 10 char of [A-Za-z0-9/. _-] MESSAGE="${MESSAGE:-}" From phk at FreeBSD.org Sat Jan 7 12:24:04 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Sat, 07 Jan 2017 13:24:04 +0100 Subject: [master] dd5d189 Add a ${workdir}/vmod_cache subdirectory for caching compiled VMODs. Otherwise jail_unix doesn't allow you to use VMODs. Message-ID: commit dd5d18952fb9badd4eb388c98a6da7c3882b0969 Author: Poul-Henning Kamp Date: Sat Jan 7 12:22:22 2017 +0000 Add a ${workdir}/vmod_cache subdirectory for caching compiled VMODs. Otherwise jail_unix doesn't allow you to use VMODs. diff --git a/bin/varnishd/mgt/mgt_child.c b/bin/varnishd/mgt/mgt_child.c index 9a4d955..5f23a24 100644 --- a/bin/varnishd/mgt/mgt_child.c +++ b/bin/varnishd/mgt/mgt_child.c @@ -307,6 +307,12 @@ mgt_launch_child(struct cli *cli) child_state = CH_STARTING; + if (VJ_make_vcldir("vmod_cache")) { + VCLI_Out(cli, "Could not create vmod cache dir"); + VCLI_SetResult(cli, CLIS_UNKNOWN); + return; + } + /* Open pipe for mgr->child CLI */ AZ(pipe(cp)); heritage.cli_in = cp[0]; diff --git a/lib/libvcc/vcc_vmod.c b/lib/libvcc/vcc_vmod.c index ef2a9e0..c2c4742 100644 --- a/lib/libvcc/vcc_vmod.c +++ b/lib/libvcc/vcc_vmod.c @@ -207,7 +207,7 @@ vcc_ParseImport(struct vcc *tl) AN(vmd); AN(vmd->file_id); VSB_printf(ifp->ini, "\t \"%s\",\n", vmd->file_id); - VSB_printf(ifp->ini, "\t \"./_vmod_%.*s.%s\"\n", + VSB_printf(ifp->ini, "\t \"./vmod_cache/_vmod_%.*s.%s\"\n", PF(mod), vmd->file_id); VSB_printf(ifp->ini, "\t ))\n"); VSB_printf(ifp->ini, "\t\treturn(1);"); From fgsch at lodoss.net Sat Jan 7 15:58:05 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sat, 07 Jan 2017 16:58:05 +0100 Subject: [master] 60366f3 Simplify Message-ID: commit 60366f388345c832416364c094fa6f83455e05fc Author: Federico G. Schwindt Date: Tue Jan 3 03:54:54 2017 +0000 Simplify diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index 11d1625..889bbdb 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -435,9 +435,8 @@ init_params(struct cli *cli) MCF_ParamConf(MCF_DEFAULT, "http_resp_size", "8k"); MCF_ParamConf(MCF_DEFAULT, "http_req_size", "12k"); MCF_ParamConf(MCF_DEFAULT, "gzip_buffer", "4k"); - } else { - MCF_ParamConf(MCF_MAXIMUM, "vsl_space", "4G"); - MCF_ParamConf(MCF_MAXIMUM, "vsm_space", "4G"); + MCF_ParamConf(MCF_MAXIMUM, "vsl_space", "1G"); + MCF_ParamConf(MCF_MAXIMUM, "vsm_space", "1G"); } #if !defined(HAVE_ACCEPT_FILTERS) || defined(__linux) diff --git a/include/tbl/params.h b/include/tbl/params.h index 5b79f8c..a1d52db 100644 --- a/include/tbl/params.h +++ b/include/tbl/params.h @@ -1514,7 +1514,7 @@ PARAM( /* name */ vsl_space, /* typ */ bytes, /* min */ "1M", - /* max */ "1G", + /* max */ "4G", /* default */ "80M", /* units */ "bytes", /* flags */ MUST_RESTART, @@ -1531,7 +1531,7 @@ PARAM( /* name */ vsm_space, /* typ */ bytes, /* min */ "1M", - /* max */ "1G", + /* max */ "4G", /* default */ "1M", /* units */ "bytes", /* flags */ MUST_RESTART, From fgsch at lodoss.net Sat Jan 7 17:41:04 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sat, 07 Jan 2017 18:41:04 +0100 Subject: [master] 2e1a483 Correct output Message-ID: commit 2e1a48353768a08c080f91a544d62324f3bd9f5a Author: Federico G. Schwindt Date: Sat Jan 7 16:37:30 2017 +0000 Correct output diff --git a/doc/sphinx/reference/vtc.rst b/doc/sphinx/reference/vtc.rst index a96702a..d08ec22 100644 --- a/doc/sphinx/reference/vtc.rst +++ b/doc/sphinx/reference/vtc.rst @@ -50,7 +50,7 @@ Lines and commands Test files take at most one command per line, with the first word of the line being the command and the following ones being its arguments. To continue over to a new line without breaking the argument string, you can escape the newline -character (\n) with a backslash (\). +character (\\n) with a backslash (\\). SYNTAX ====== From fgsch at lodoss.net Sat Jan 7 17:41:05 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sat, 07 Jan 2017 18:41:05 +0100 Subject: [master] f4566d4 Polish Message-ID: commit f4566d41417d0e6e3a2f46671850371c11ea2b13 Author: Federico G. Schwindt Date: Sat Jan 7 16:38:05 2017 +0000 Polish diff --git a/bin/varnishtest/vtc_process.c b/bin/varnishtest/vtc_process.c index effb25c..86ecf6a 100644 --- a/bin/varnishtest/vtc_process.c +++ b/bin/varnishtest/vtc_process.c @@ -273,13 +273,6 @@ process_kill(const struct process *p, const char *sig) } static inline void -process_stop(const struct process *p) -{ - - process_kill(p, "TERM"); -} - -static inline void process_terminate(const struct process *p) { @@ -376,7 +369,7 @@ cmd_process(CMD_ARGS) continue; } if (!strcmp(*av, "-stop")) { - process_stop(p); + process_kill(p, "TERM"); continue; } if (!strcmp(*av, "-write")) { From fgsch at lodoss.net Sat Jan 7 17:41:05 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sat, 07 Jan 2017 18:41:05 +0100 Subject: [master] 0863fc7 Use -run instead Message-ID: commit 0863fc70fcfeff333359dd892314e7e42bde0c6f Author: Federico G. Schwindt Date: Sat Jan 7 16:38:53 2017 +0000 Use -run instead diff --git a/bin/varnishtest/tests/u00004.vtc b/bin/varnishtest/tests/u00004.vtc index e7743b4..046b1f0 100644 --- a/bin/varnishtest/tests/u00004.vtc +++ b/bin/varnishtest/tests/u00004.vtc @@ -16,4 +16,4 @@ client c1 { process p1 -wait -process p2 {exec varnishtop -1 -n ${v1_name} >/dev/null} -start -wait +process p2 {exec varnishtop -1 -n ${v1_name} >/dev/null} -run From fgsch at lodoss.net Sat Jan 7 17:41:05 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sat, 07 Jan 2017 18:41:05 +0100 Subject: [master] f7a3acb Start documenting vtc's process Message-ID: commit f7a3acb83bfba001c5b95fd5d40eef1819496db6 Author: Federico G. Schwindt Date: Sat Jan 7 16:39:13 2017 +0000 Start documenting vtc's process diff --git a/bin/varnishtest/vtc_process.c b/bin/varnishtest/vtc_process.c index 86ecf6a..e53cd82 100644 --- a/bin/varnishtest/vtc_process.c +++ b/bin/varnishtest/vtc_process.c @@ -313,8 +313,47 @@ process_close(struct process *p) p->fds[1] = -1; } -/********************************************************************** - * Process command dispatch +/* SECTION: process process + * + * Run a process in the background with stdout and stderr redirected to + * ${tmpdir}/pNAME/stdout and ${tmpdir}/pNAME/stderr, respectively:: + * + * process pNAME SPEC [-wait] [-start] [-run] [-kill STRING] [-stop] \ + * [-write STRING] [-writeln STRING] [-close] + * + * pNAME + * Name of the process. It must start with 'p'. + * + * SPEC + * The command(s) to run in this process. + * + * \-start + * Start the process. + * + * \-wait + * Wait for the process to finish. + * + * \-run + * Shorthand for -start -wait. + * + * \-kill STRING + * Send a signal to the process. The argument can be either + * the string "TERM", "INT", or "KILL" for SIGTERM, SIGINT or SIGKILL + * signals, respectively, or a hyphen (-) followed by the signal + * number. + * + * \-stop + * Shorthand for -kill TERM. + * + * \-write STRING + * Write a string to the process' stdin. + * + * \-writeln STRING + * Same as -write followed by a newline (\\n). + * + * \-close + * Close the process' stdin. + * */ void diff --git a/doc/sphinx/Makefile.am b/doc/sphinx/Makefile.am index d00c566..5923186 100644 --- a/doc/sphinx/Makefile.am +++ b/doc/sphinx/Makefile.am @@ -183,6 +183,7 @@ VTCSYN_SRC = $(top_srcdir)/bin/varnishtest/vtc.c \ $(top_srcdir)/bin/varnishtest/vtc_http.c \ $(top_srcdir)/bin/varnishtest/vtc_http2.c \ $(top_srcdir)/bin/varnishtest/vtc_logexp.c \ + $(top_srcdir)/bin/varnishtest/vtc_process.c \ $(top_srcdir)/bin/varnishtest/vtc_varnish.c include/vtc-syntax.rst: vtc-syntax.py $(VTCSYN_SRC) $(PYTHON) $(top_srcdir)/doc/sphinx/vtc-syntax.py $(VTCSYN_SRC) > $@ From fgsch at lodoss.net Sat Jan 7 17:41:05 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sat, 07 Jan 2017 18:41:05 +0100 Subject: [master] 1f755da Clarify that both integer and float are accepted Message-ID: commit 1f755da8c6bdd7a1030a710b305107ab83d66e66 Author: Federico G. Schwindt Date: Sat Jan 7 17:06:38 2017 +0000 Clarify that both integer and float are accepted diff --git a/bin/varnishtest/vtc.c b/bin/varnishtest/vtc.c index 6062b24..987cbc8 100644 --- a/bin/varnishtest/vtc.c +++ b/bin/varnishtest/vtc.c @@ -518,7 +518,8 @@ cmd_err_shell(CMD_ARGS) /* SECTION: delay delay * - * Take a float as argument and sleep for that number of seconds. + * Sleep for the number of seconds specified in the argument. The number + * can include a fractional part, e.g. 1.5. */ /* SECTION: stream.spec.delay delay * From fgsch at lodoss.net Sat Jan 7 17:54:04 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sat, 07 Jan 2017 18:54:04 +0100 Subject: [master] 58c29dd Reunite all friends in a single place Message-ID: commit 58c29dd0519476081fa702c5c96ae031a97a152d Author: Federico G. Schwindt Date: Sat Jan 7 17:52:26 2017 +0000 Reunite all friends in a single place diff --git a/devscripts/coverity-run b/devscripts/coverity-run deleted file mode 100755 index a1d6263..0000000 --- a/devscripts/coverity-run +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/sh -# -# Build Varnish under Coverity, and upload the output to Coverity Scan. -# -# Requires the Coverity scanner in $PATH and the upload token set in $COVTOKEN. -# -# See https://github.com/varnishcache/varnish-cache/wiki/Coverity-scans for overview. -# - - -if [ -z "$COVTOKEN" ]; then - echo "ERROR: No COVTOKEN in environment" - exit 1 -fi - -if [ -z "`which cov-build`" ]; then - echo "ERROR: No Coverity (cov-build) in \$PATH. Download: https://scan.coverity.com/download?tab=cxx" - exit 1 -fi - -if [ -z "$EMAIL" ]; then - EMAIL="varnish-dev at varnish-cache.org" -fi - - -GITREF=`git rev-parse --short HEAD` -GITBRANCH=`git rev-parse --abbrev-ref HEAD` - -# Do a dirty check. -DIRT=`git status --porcelain 2>/dev/null | egrep '^(\ M|M)' | grep -v coverity-run` -if [ -n "$DIRT" ]; then - printf "ERROR: Refusing to analyse a dirty tree.\n$DIRT\n" - exit 2 -fi - -test "`basename $PWD`" = "devscripts" && cd .. - -make distclean || true -test -f configure || ./autogen.sh -./configure - -cov-build --dir cov-int make - -# the web ui seems to require the file to be called myproject.tgz. Very cute. -tar cvfz myproject.tgz cov-int - -curl --form token=$COVTOKEN \ - --form "email=$EMAIL" \ - --form "file=@myproject.tgz" \ - --form version="$GITREF" \ - --form description="description=${GITBRANCH}_branch" \ - 'https://scan.coverity.com/builds?project=varnish' - -rm myproject.tgz diff --git a/tools/coverity-run b/tools/coverity-run new file mode 100755 index 0000000..a1d6263 --- /dev/null +++ b/tools/coverity-run @@ -0,0 +1,54 @@ +#!/bin/sh +# +# Build Varnish under Coverity, and upload the output to Coverity Scan. +# +# Requires the Coverity scanner in $PATH and the upload token set in $COVTOKEN. +# +# See https://github.com/varnishcache/varnish-cache/wiki/Coverity-scans for overview. +# + + +if [ -z "$COVTOKEN" ]; then + echo "ERROR: No COVTOKEN in environment" + exit 1 +fi + +if [ -z "`which cov-build`" ]; then + echo "ERROR: No Coverity (cov-build) in \$PATH. Download: https://scan.coverity.com/download?tab=cxx" + exit 1 +fi + +if [ -z "$EMAIL" ]; then + EMAIL="varnish-dev at varnish-cache.org" +fi + + +GITREF=`git rev-parse --short HEAD` +GITBRANCH=`git rev-parse --abbrev-ref HEAD` + +# Do a dirty check. +DIRT=`git status --porcelain 2>/dev/null | egrep '^(\ M|M)' | grep -v coverity-run` +if [ -n "$DIRT" ]; then + printf "ERROR: Refusing to analyse a dirty tree.\n$DIRT\n" + exit 2 +fi + +test "`basename $PWD`" = "devscripts" && cd .. + +make distclean || true +test -f configure || ./autogen.sh +./configure + +cov-build --dir cov-int make + +# the web ui seems to require the file to be called myproject.tgz. Very cute. +tar cvfz myproject.tgz cov-int + +curl --form token=$COVTOKEN \ + --form "email=$EMAIL" \ + --form "file=@myproject.tgz" \ + --form version="$GITREF" \ + --form description="description=${GITBRANCH}_branch" \ + 'https://scan.coverity.com/builds?project=varnish' + +rm myproject.tgz From fgsch at lodoss.net Sat Jan 7 19:57:04 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sat, 07 Jan 2017 20:57:04 +0100 Subject: [master] bb44c36 Fix build with newer sphinx versions Message-ID: commit bb44c36c21fdebe0e84134b2945274708d996ea8 Author: Federico G. Schwindt Date: Sat Jan 7 19:44:22 2017 +0000 Fix build with newer sphinx versions diff --git a/doc/sphinx/Makefile.am b/doc/sphinx/Makefile.am index 5923186..6968535 100644 --- a/doc/sphinx/Makefile.am +++ b/doc/sphinx/Makefile.am @@ -7,7 +7,7 @@ SPHINXBUILD = sphinx-build -W -q -N PAPER = a4 BUILDDIR = build -ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees -D latex_paper_size=$(PAPER) $(SPHINXOPTS) $(builddir) +ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees -D latex_elements.papersize=$(PAPER) $(SPHINXOPTS) $(builddir) .PHONY: help clean html dirhtml pickle json htmlhelp qthelp latex changes linkcheck doctest diff --git a/doc/sphinx/Makefile.phk b/doc/sphinx/Makefile.phk index 57689bd..f04a711 100644 --- a/doc/sphinx/Makefile.phk +++ b/doc/sphinx/Makefile.phk @@ -8,8 +8,8 @@ PAPER = BUILDDIR = build # Internal variables. -PAPEROPT_a4 = -D latex_paper_size=a4 -PAPEROPT_letter = -D latex_paper_size=letter +PAPEROPT_a4 = -D latex_elements.papersize=a4 +PAPEROPT_letter = -D latex_elements.papersize=letter ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) $(CURDIR) .PHONY: help clean html dirhtml pickle json htmlhelp qthelp latex changes linkcheck doctest From fgsch at lodoss.net Sat Jan 7 21:42:04 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sat, 07 Jan 2017 22:42:04 +0100 Subject: [master] f597b86 Drop libvarnishcompat Message-ID: commit f597b86d73ca67f80b5ca9e86dac399111858963 Author: Federico G. Schwindt Date: Sat Jan 7 21:29:16 2017 +0000 Drop libvarnishcompat Move its remainings to libvarnishapi and include them conditionally. diff --git a/bin/varnishadm/Makefile.am b/bin/varnishadm/Makefile.am index 0ecc3e6..d0ca154 100644 --- a/bin/varnishadm/Makefile.am +++ b/bin/varnishadm/Makefile.am @@ -14,6 +14,5 @@ varnishadm_CFLAGS = @LIBEDIT_CFLAGS@ \ varnishadm_LDADD = \ $(top_builddir)/lib/libvarnish/libvarnish.a \ $(top_builddir)/lib/libvarnishapi/libvarnishapi.la \ - $(top_builddir)/lib/libvarnishcompat/libvarnishcompat.la \ ${PTHREAD_LIBS} ${RT_LIBS} ${NET_LIBS} @LIBEDIT_LIBS@ ${LIBM} \ @SAN_LDFLAGS@ diff --git a/bin/varnishd/Makefile.am b/bin/varnishd/Makefile.am index 7ab414a..9203a50 100644 --- a/bin/varnishd/Makefile.am +++ b/bin/varnishd/Makefile.am @@ -151,7 +151,6 @@ varnishd_LDFLAGS = -export-dynamic varnishd_LDADD = \ $(top_builddir)/lib/libvarnish/libvarnish.a \ - $(top_builddir)/lib/libvarnishcompat/libvarnishcompat.la \ $(top_builddir)/lib/libvcc/libvcc.a \ $(top_builddir)/lib/libvgz/libvgz.a \ @SAN_LDFLAGS@ \ diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index eb10008..8b6ad6d 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -29,12 +29,7 @@ #include "config.h" -#ifndef HAVE_EXECINFO_H -#include "compat/execinfo.h" -#else #include -#endif - #include #include #include diff --git a/bin/varnishd/flint.sh b/bin/varnishd/flint.sh index ba15504..50d1c4b 100755 --- a/bin/varnishd/flint.sh +++ b/bin/varnishd/flint.sh @@ -29,7 +29,6 @@ flexelint \ storage/*.c \ waiter/*.c \ ../../lib/libvarnish/*.c \ - ../../lib/libvarnishcompat/execinfo.c \ ../../lib/libvcc/*.c \ ../../lib/libvmod_std/*.c \ ../../lib/libvmod_debug/*.c \ diff --git a/bin/varnishhist/Makefile.am b/bin/varnishhist/Makefile.am index e01374b..281c05a 100644 --- a/bin/varnishhist/Makefile.am +++ b/bin/varnishhist/Makefile.am @@ -15,7 +15,6 @@ varnishhist_CFLAGS = \ @SAN_CFLAGS@ varnishhist_LDADD = \ - $(top_builddir)/lib/libvarnishcompat/libvarnishcompat.la \ $(top_builddir)/lib/libvarnishapi/libvarnishapi.la \ -lm \ @SAN_LDFLAGS@ \ diff --git a/bin/varnishlog/Makefile.am b/bin/varnishlog/Makefile.am index 9e309e7..28d5e67 100644 --- a/bin/varnishlog/Makefile.am +++ b/bin/varnishlog/Makefile.am @@ -15,7 +15,6 @@ varnishlog_CFLAGS = \ @SAN_CFLAGS@ varnishlog_LDADD = \ - $(top_builddir)/lib/libvarnishcompat/libvarnishcompat.la \ $(top_builddir)/lib/libvarnishapi/libvarnishapi.la \ @SAN_LDFLAGS@ \ ${RT_LIBS} ${LIBM} ${PTHREAD_LIBS} diff --git a/bin/varnishncsa/Makefile.am b/bin/varnishncsa/Makefile.am index a6cbeb7..b970910 100644 --- a/bin/varnishncsa/Makefile.am +++ b/bin/varnishncsa/Makefile.am @@ -17,7 +17,6 @@ varnishncsa_CFLAGS = \ @SAN_CFLAGS@ varnishncsa_LDADD = \ - $(top_builddir)/lib/libvarnishcompat/libvarnishcompat.la \ $(top_builddir)/lib/libvarnishapi/libvarnishapi.la \ @SAN_LDFLAGS@ \ ${RT_LIBS} ${LIBM} diff --git a/bin/varnishstat/Makefile.am b/bin/varnishstat/Makefile.am index 82303fa..34c7d41 100644 --- a/bin/varnishstat/Makefile.am +++ b/bin/varnishstat/Makefile.am @@ -17,7 +17,6 @@ varnishstat_CFLAGS = \ @SAN_CFLAGS@ varnishstat_LDADD = \ - $(top_builddir)/lib/libvarnishcompat/libvarnishcompat.la \ $(top_builddir)/lib/libvarnishapi/libvarnishapi.la \ @SAN_LDFLAGS@ \ @CURSES_LIB@ ${RT_LIBS} ${LIBM} ${PTHREAD_LIBS} diff --git a/bin/varnishtest/Makefile.am b/bin/varnishtest/Makefile.am index 2149ed4..636edd4 100644 --- a/bin/varnishtest/Makefile.am +++ b/bin/varnishtest/Makefile.am @@ -51,7 +51,6 @@ varnishtest_SOURCES = \ varnishtest_LDADD = \ $(top_builddir)/lib/libvarnish/libvarnish.a \ - $(top_builddir)/lib/libvarnishcompat/libvarnishcompat.la \ $(top_builddir)/lib/libvarnishapi/libvarnishapi.la \ $(top_builddir)/lib/libvgz/libvgz.a \ @SAN_LDFLAGS@ \ diff --git a/bin/varnishtop/Makefile.am b/bin/varnishtop/Makefile.am index fdd993a..68adae8 100644 --- a/bin/varnishtop/Makefile.am +++ b/bin/varnishtop/Makefile.am @@ -15,7 +15,6 @@ varnishtop_CFLAGS = \ @SAN_CFLAGS@ varnishtop_LDADD = \ - $(top_builddir)/lib/libvarnishcompat/libvarnishcompat.la \ $(top_builddir)/lib/libvarnishapi/libvarnishapi.la \ @SAN_LDFLAGS@ \ @CURSES_LIB@ ${RT_LIBS} ${LIBM} ${PTHREAD_LIBS} diff --git a/configure.ac b/configure.ac index 27cf34e..af57936 100644 --- a/configure.ac +++ b/configure.ac @@ -190,7 +190,6 @@ AC_CHECK_HEADERS([sys/personality.h]) AC_CHECK_HEADERS([sys/statvfs.h]) AC_CHECK_HEADERS([sys/vfs.h]) AC_CHECK_HEADERS([endian.h]) -AC_CHECK_HEADERS([execinfo.h]) AC_CHECK_HEADERS([pthread_np.h], [], [], [#include ]) AC_CHECK_HEADERS([priv.h]) @@ -284,10 +283,10 @@ case $target in esac AC_SUBST(JEMALLOC_LDADD) -# These functions are provided by libcompat on platforms where they -# are not available AC_CHECK_FUNCS([setproctitle]) -AC_SEARCH_LIBS(backtrace, [execinfo],[AC_DEFINE([HAVE_BACKTRACE],[1],[Define to 1 if the backtrace function exists])]) +AC_SEARCH_LIBS(backtrace, [execinfo], [], [ + AC_MSG_ERROR([Could not find backtrace() support]) +]) # white lie - we don't actually test it AC_MSG_CHECKING([whether daemon() works]) case $target in @@ -300,6 +299,7 @@ case $target in AC_CHECK_FUNCS([daemon]) ;; esac +AM_CONDITIONAL(HAVE_DAEMON, [test "x$HAVE_DAEMON" != "xno"]) AC_SYS_LARGEFILE @@ -699,7 +699,6 @@ AC_CONFIG_FILES([ lib/Makefile lib/libvarnish/Makefile lib/libvarnishapi/Makefile - lib/libvarnishcompat/Makefile lib/libvcc/Makefile lib/libvgz/Makefile lib/libvmod_debug/Makefile diff --git a/include/Makefile.am b/include/Makefile.am index 0bf9cec..34ca265 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -79,7 +79,6 @@ nobase_pkginclude_HEADERS += \ nobase_noinst_HEADERS = \ binary_heap.h \ compat/daemon.h \ - compat/execinfo.h \ vfl.h \ libvcc.h \ vcli_serve.h \ diff --git a/include/compat/execinfo.h b/include/compat/execinfo.h deleted file mode 100644 index 7b3b2e3..0000000 --- a/include/compat/execinfo.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2003 Maxim Sobolev - * All rights reserved. - * - * 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 THE 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 COMPAT_EXECINFO_H_INCLUDED -#define COMPAT_EXECINFO_H_INCLUDED - -#ifdef __cplusplus -extern "C" { -#endif - -int backtrace(void **, int); -char ** backtrace_symbols(void *const *, int); - -#ifdef __cplusplus -} -#endif - -#endif /* COMPAT_EXECINFO_H_INCLUDED */ diff --git a/lib/Makefile.am b/lib/Makefile.am index 579cebd..871cbaf 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -1,7 +1,6 @@ # SUBDIRS = \ - libvarnishcompat \ libvarnish \ libvarnishapi \ libvcc \ diff --git a/lib/libvarnishapi/Makefile.am b/lib/libvarnishapi/Makefile.am index f33fbe2..769e658 100644 --- a/lib/libvarnishapi/Makefile.am +++ b/lib/libvarnishapi/Makefile.am @@ -44,6 +44,10 @@ libvarnishapi_la_SOURCES = \ vxp_fixed_token.c \ libvarnishapi.map +if ! HAVE_DAEMON +libvarnishapi_la_SOURCES += daemon.c +endif + libvarnishapi_la_CFLAGS = \ -DVARNISH_STATE_DIR='"${VARNISH_STATE_DIR}"' \ @SAN_CFLAGS@ diff --git a/lib/libvarnishapi/daemon.c b/lib/libvarnishapi/daemon.c new file mode 100644 index 0000000..e68b3a1 --- /dev/null +++ b/lib/libvarnishapi/daemon.c @@ -0,0 +1,92 @@ +/*- + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * 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. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 THE REGENTS 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. + * Derived from: + * $FreeBSD: src/lib/libc/gen/daemon.c,v 1.8 2007/01/09 00:27:53 imp Exp $ + */ + +//lint -e{766} +#include "config.h" + +#include +#include +#include +#include +#include + +#include "compat/daemon.h" + +int +varnish_daemon(int nochdir, int noclose) +{ + struct sigaction osa, sa; + int fd; + pid_t newgrp; + int oerrno; + int osa_ok; + + /* A SIGHUP may be thrown when the parent exits below. */ + sigemptyset(&sa.sa_mask); + sa.sa_handler = SIG_IGN; + sa.sa_flags = 0; + osa_ok = sigaction(SIGHUP, &sa, &osa); + + switch (fork()) { + case -1: + return (-1); + case 0: + break; + default: + /* + * A fine point: _exit(0), not exit(0), to avoid triggering + * atexit(3) processing + */ + _exit(0); + } + + newgrp = setsid(); + oerrno = errno; + if (osa_ok != -1) + sigaction(SIGHUP, &osa, NULL); + + if (newgrp == -1) { + errno = oerrno; + return (-1); + } + + if (!nochdir) + (void)chdir("/"); + + if (!noclose && (fd = open("/dev/null", O_RDWR, 0)) != -1) { + (void)dup2(fd, STDIN_FILENO); + (void)dup2(fd, STDOUT_FILENO); + (void)dup2(fd, STDERR_FILENO); + if (fd > 2) + (void)close(fd); + } + return (0); +} diff --git a/lib/libvarnishcompat/Makefile.am b/lib/libvarnishcompat/Makefile.am deleted file mode 100644 index f2c878b..0000000 --- a/lib/libvarnishcompat/Makefile.am +++ /dev/null @@ -1,19 +0,0 @@ -# - -AM_CPPFLAGS = \ - -I$(top_srcdir)/include \ - -I$(top_builddir)/include - -AM_LDFLAGS = $(AM_LT_LDFLAGS) - -pkglib_LTLIBRARIES = libvarnishcompat.la - -libvarnishcompat_la_CFLAGS = \ - @SAN_CFLAGS@ - -libvarnishcompat_la_LDFLAGS = $(AM_LDFLAGS) -avoid-version \ - @SAN_LDFLAGS@ - -libvarnishcompat_la_SOURCES = \ - daemon.c \ - execinfo.c diff --git a/lib/libvarnishcompat/daemon.c b/lib/libvarnishcompat/daemon.c deleted file mode 100644 index 3ab6b7d..0000000 --- a/lib/libvarnishcompat/daemon.c +++ /dev/null @@ -1,96 +0,0 @@ -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * 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. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 THE REGENTS 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. - * Derived from: - * $FreeBSD: src/lib/libc/gen/daemon.c,v 1.8 2007/01/09 00:27:53 imp Exp $ - */ - -//lint -e{766} -#include "config.h" - -#ifndef HAVE_DAEMON - -#include -#include -#include -#include -#include - -#include "compat/daemon.h" - -int -varnish_daemon(int nochdir, int noclose) -{ - struct sigaction osa, sa; - int fd; - pid_t newgrp; - int oerrno; - int osa_ok; - - /* A SIGHUP may be thrown when the parent exits below. */ - sigemptyset(&sa.sa_mask); - sa.sa_handler = SIG_IGN; - sa.sa_flags = 0; - osa_ok = sigaction(SIGHUP, &sa, &osa); - - switch (fork()) { - case -1: - return (-1); - case 0: - break; - default: - /* - * A fine point: _exit(0), not exit(0), to avoid triggering - * atexit(3) processing - */ - _exit(0); - } - - newgrp = setsid(); - oerrno = errno; - if (osa_ok != -1) - sigaction(SIGHUP, &osa, NULL); - - if (newgrp == -1) { - errno = oerrno; - return (-1); - } - - if (!nochdir) - (void)chdir("/"); - - if (!noclose && (fd = open("/dev/null", O_RDWR, 0)) != -1) { - (void)dup2(fd, STDIN_FILENO); - (void)dup2(fd, STDOUT_FILENO); - (void)dup2(fd, STDERR_FILENO); - if (fd > 2) - (void)close(fd); - } - return (0); -} - -#endif diff --git a/lib/libvarnishcompat/execinfo.c b/lib/libvarnishcompat/execinfo.c deleted file mode 100644 index 17321b7..0000000 --- a/lib/libvarnishcompat/execinfo.c +++ /dev/null @@ -1,182 +0,0 @@ -/* - * Copyright (c) 2003 Maxim Sobolev - * All rights reserved. - * - * 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 THE 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. - */ - -//lint -e{766} -#include "config.h" - -#ifndef HAVE_BACKTRACE - -#include "compat/execinfo.h" - -#if defined (__GNUC__) && __GNUC__ >= 4 /* XXX Correct version to check for ? */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -static void *getreturnaddr(int); -static void *getframeaddr(int); - -int -backtrace(void **buffer, int size) -{ - int i; - - for (i = 1; getframeaddr(i + 1) != NULL && i != size + 1; i++) { - buffer[i - 1] = getreturnaddr(i); - if (buffer[i - 1] == NULL) - break; - } - return (i - 1); -} - -/* - * XXX: This implementation should be changed to a much more conservative - * XXX: memory strategy: Allocate 4k up front, realloc 4K more as needed. - */ - -char ** -backtrace_symbols(void *const *buffer, int size) -{ - size_t clen, alen; - int i; - char **rval; - - clen = size * sizeof(char *); - rval = malloc(clen); - if (rval == NULL) - return (NULL); - for (i = 0; i < size; i++) { - -#ifdef HAVE_DLADDR - { - Dl_info info; - int offset; - - if (dladdr(buffer[i], &info) != 0) { - if (info.dli_sname == NULL) - info.dli_sname = "?"; - if (info.dli_saddr == NULL) - info.dli_saddr = buffer[i]; - offset = (const char*)buffer[i] - - (const char*)info.dli_saddr; - /* "0x01234567 at filename" */ - alen = 2 + /* "0x" */ - (sizeof(void *) * 2) + /* "01234567" */ - 2 + /* " <" */ - strlen(info.dli_sname) + /* "function" */ - 1 + /* "+" */ - 10 + /* "offset */ - 5 + /* "> at " */ - strlen(info.dli_fname) + /* "filename" */ - 1; /* "\0" */ - rval = realloc(rval, clen + alen); - if (rval == NULL) - return NULL; - (void)snprintf((char *) rval + clen, alen, - "%p <%s+%d> at %s", buffer[i], info.dli_sname, - offset, info.dli_fname); - rval[i] = (char *) clen; - clen += alen; - continue; - } - } -#endif - alen = 2 + /* "0x" */ - (sizeof(void *) * 2) + /* "01234567" */ - 1; /* "\0" */ - rval = realloc(rval, clen + alen); - if (rval == NULL) - return NULL; - (void)snprintf((char *) rval + clen, alen, "%p", buffer[i]); - rval[i] = (char *) clen; - clen += alen; - } - - for (i = 0; i < size; i++) - rval[i] += (long) rval; - return (rval); -} - -/* Binary expansion */ -#define DO_P2_TIMES_1(x) DO_P2_TIMES_0(x); DO_P2_TIMES_0((x) + (1<<0)) -#define DO_P2_TIMES_2(x) DO_P2_TIMES_1(x); DO_P2_TIMES_1((x) + (1<<1)) -#define DO_P2_TIMES_3(x) DO_P2_TIMES_2(x); DO_P2_TIMES_2((x) + (1<<2)) -#define DO_P2_TIMES_4(x) DO_P2_TIMES_3(x); DO_P2_TIMES_3((x) + (1<<3)) -#define DO_P2_TIMES_5(x) DO_P2_TIMES_4(x); DO_P2_TIMES_4((x) + (1<<4)) -#define DO_P2_TIMES_6(x) DO_P2_TIMES_5(x); DO_P2_TIMES_5((x) + (1<<5)) -#define DO_P2_TIMES_7(x) DO_P2_TIMES_6(x); DO_P2_TIMES_6((x) + (1<<6)) - -static void * -getreturnaddr(int level) -{ - - switch(level) { -#define DO_P2_TIMES_0(x) case (x): return __builtin_return_address((x) + 1) - DO_P2_TIMES_7(0); -#undef DO_P2_TIMES_0 - default: return NULL; - } -} - -static void * -getframeaddr(int level) -{ - - switch(level) { -#define DO_P2_TIMES_0(x) case (x): return __builtin_frame_address((x) + 1) - DO_P2_TIMES_7(0); -#undef DO_P2_TIMES_0 - default: return NULL; - } -} - -#else - -int -backtrace(void **buffer, int size) -{ - (void)buffer; - (void)size; - return (0); -} - -char ** -backtrace_symbols(void *const *buffer, int size) -{ - (void)buffer; - (void)size; - return (0); -} - -#endif /* (__GNUC__) && __GNUC__ >= 4 */ -#endif /* HAVE_BACKTRACE */ From phk at FreeBSD.org Sat Jan 7 22:49:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Sat, 07 Jan 2017 23:49:05 +0100 Subject: [master] b2bee0e More coverage of mgt_main.c Message-ID: commit b2bee0e30bbe2ca62f5ad98050d310fae5467c4e Author: Poul-Henning Kamp Date: Sat Jan 7 22:47:46 2017 +0000 More coverage of mgt_main.c diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index 889bbdb..a926401 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -746,7 +746,7 @@ main(int argc, char * const *argv) av = VAV_Parse(optarg, NULL, ARGV_COMMA); AN(av); if (av[0] != NULL) - ARGV_ERR("\t-l ...: %s", av[0]); + ARGV_ERR("\t-l ...: %s\n", av[0]); if (av[1] != NULL) { MCF_ParamSet(cli, "vsl_space", av[1]); cli_check(cli); diff --git a/bin/varnishtest/tests/a00009.vtc b/bin/varnishtest/tests/a00009.vtc index 40b0be6..46fa487 100644 --- a/bin/varnishtest/tests/a00009.vtc +++ b/bin/varnishtest/tests/a00009.vtc @@ -1,6 +1,6 @@ varnishtest "Code coverage of VCL compiler and RSTdump etc" -shell "varnishd -b 127.0.0.1:80 -C -n ${tmpdir} 2> /${tmpdir}/_.c" +shell "varnishd -b 127.0.0.1:80 -C 2> /${tmpdir}/_.c" shell "varnishd -x dumprstparam > /${tmpdir}/_.param" shell "varnishd -x dumprstvsl > /${tmpdir}/_.vsl" shell "varnishd -x dumprstcli > /${tmpdir}/_.cli" @@ -16,3 +16,9 @@ err_shell {Only one of -b or -f can be specified} "varnishd -b a -f b 2>&1" err_shell {-C needs either -b or -f } "varnishd -C 2>&1" err_shell {-d makes no sense with -C} "varnishd -C -b 127.0.0.1:80 -d 2>&1" err_shell {-F makes no sense with -C} "varnishd -C -b 127.0.0.1:80 -F 2>&1" +err_shell {usage: varnishd [options]} "varnishd -h 2>&1" +err_shell {usage: varnishd [options]} "varnishd -? 2>&1" +err_shell {Invalid backslash sequence} {varnishd -l 'xyz\kk,xyz\foo' 2>&1} +err_shell {Invalid backslash sequence} {varnishd -l 'ab\8cd' 2>&1} +err_shell {Copyright (c) 2006} {varnishd -V 2>&1} +err_shell {Cannot open -S file (/nonexistent)} {varnishd -S /nonexistent 2>&1} From phk at FreeBSD.org Sat Jan 7 22:55:04 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Sat, 07 Jan 2017 23:55:04 +0100 Subject: [master] 80410e8 Report uid/gid so we can tell if jails technology was enabled. Message-ID: commit 80410e8ff23c321a117820a2384f0ebecb425886 Author: Poul-Henning Kamp Date: Sat Jan 7 22:53:34 2017 +0000 Report uid/gid so we can tell if jails technology was enabled. diff --git a/tools/vtest.sh b/tools/vtest.sh index fb55132..cdd2d85 100755 --- a/tools/vtest.sh +++ b/tools/vtest.sh @@ -157,11 +157,12 @@ do mkdir _report export LOG=_report/_log - echo "VTEST 1.02" > ${LOG} + echo "VTEST 1.03" > ${LOG} echo "DATE `date +%s`" >> ${LOG} echo "BRANCH trunk" >> ${LOG} echo "HOST `hostname`" >> ${LOG} echo "UNAME `uname -a`" >> ${LOG} + echo "UGID `id`" >> ${LOG} if [ -x /usr/bin/lsb_release ] ; then echo "LSB `lsb_release -d`" >> ${LOG} else From fgsch at lodoss.net Sun Jan 8 03:41:05 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sun, 08 Jan 2017 04:41:05 +0100 Subject: [master] 2881d76 Ignore rmdir() errors Message-ID: commit 2881d76fed1e67550cab2b346bdd61544b6dde8f Author: Federico G. Schwindt Date: Sun Jan 8 00:04:13 2017 +0000 Ignore rmdir() errors In OSX with the Xcode toolchain DWARF debug symbol files (.dSYM) will be created when cc_command is executed (when -g is present) and the directory will not be empty. Prompted after b2bee0e3. diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index a926401..b4766b2 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -874,7 +874,7 @@ main(int argc, char * const *argv) mgt_vcl_startup(cli, b_arg, f_arg, vcl, C_flag); if (C_flag) { if (Cn_arg == n_arg) - AZ(rmdir(Cn_arg)); + (void)rmdir(Cn_arg); AZ(VSB_finish(cli->sb)); fprintf(stderr, "%s\n", VSB_data(cli->sb)); exit(cli->result == CLIS_OK ? 0 : 2); From fgsch at lodoss.net Sun Jan 8 03:41:05 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sun, 08 Jan 2017 04:41:05 +0100 Subject: [master] 62ac930 Fix daemon.c inclusion when daemon() isn't present Message-ID: commit 62ac93056a9d279e29eab6f7be76920944370128 Author: Federico G. Schwindt Date: Sun Jan 8 03:32:27 2017 +0000 Fix daemon.c inclusion when daemon() isn't present diff --git a/configure.ac b/configure.ac index af57936..02a9f7f 100644 --- a/configure.ac +++ b/configure.ac @@ -299,7 +299,7 @@ case $target in AC_CHECK_FUNCS([daemon]) ;; esac -AM_CONDITIONAL(HAVE_DAEMON, [test "x$HAVE_DAEMON" != "xno"]) +AM_CONDITIONAL(HAVE_DAEMON, [test "x$ac_cv_func_daemon" != "xno"]) AC_SYS_LARGEFILE From fgsch at lodoss.net Sun Jan 8 11:06:05 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sun, 08 Jan 2017 12:06:05 +0100 Subject: [master] cd8437c Polish Message-ID: commit cd8437c633f0ccbfd411c459164906a4513aa265 Author: Federico G. Schwindt Date: Sun Jan 8 10:50:20 2017 +0000 Polish diff --git a/bin/varnishtest/tests/a00009.vtc b/bin/varnishtest/tests/a00009.vtc index 46fa487..f78916d 100644 --- a/bin/varnishtest/tests/a00009.vtc +++ b/bin/varnishtest/tests/a00009.vtc @@ -1,11 +1,17 @@ varnishtest "Code coverage of VCL compiler and RSTdump etc" -shell "varnishd -b 127.0.0.1:80 -C 2> /${tmpdir}/_.c" -shell "varnishd -x dumprstparam > /${tmpdir}/_.param" -shell "varnishd -x dumprstvsl > /${tmpdir}/_.vsl" -shell "varnishd -x dumprstcli > /${tmpdir}/_.cli" -err_shell {VCL version declaration missing} "echo 'bad vcl' >${tmpdir}/t.vcl ; varnishd -f ${tmpdir}/t.vcl -n ${tmpdir} 2>&1" -err_shell {VCL version declaration missing} "echo 'bad vcl' >${tmpdir}/t.vcl ; varnishd -C -f ${tmpdir}/t.vcl -n ${tmpdir} 2>&1" +shell "varnishd -b 127.0.0.1:80 -C 2> ${tmpdir}/_.c" +shell "varnishd -x dumprstparam > ${tmpdir}/_.param" +shell "varnishd -x dumprstvsl > ${tmpdir}/_.vsl" +shell "varnishd -x dumprstcli > ${tmpdir}/_.cli" +err_shell {VCL version declaration missing} { + echo 'bad vcl' > ${tmpdir}/t.vcl + varnishd -f ${tmpdir}/t.vcl -n ${tmpdir} 2>&1 +} +err_shell {VCL version declaration missing} { + echo 'bad vcl' > ${tmpdir}/t.vcl + varnishd -C -f ${tmpdir}/t.vcl -n ${tmpdir} 2>&1 +} err_shell {-spersistent has been deprecated} "varnishd -spersistent 2>&1" err_shell {Unknown jail method "xyz"} "varnishd -jxyz 2>&1" err_shell {-x is incompatible with everything else} "varnishd -d -x foo 2>&1" @@ -13,12 +19,13 @@ err_shell {Invalid -x argument} "varnishd -x foo 2>&1" err_shell {Too many arguments} "varnishd foo 2>&1" err_shell {Only one of -d or -F can be specified} "varnishd -d -F 2>&1" err_shell {Only one of -b or -f can be specified} "varnishd -b a -f b 2>&1" -err_shell {-C needs either -b or -f } "varnishd -C 2>&1" +err_shell {-C needs either -b or -f } \ + "varnishd -C 2>&1" err_shell {-d makes no sense with -C} "varnishd -C -b 127.0.0.1:80 -d 2>&1" err_shell {-F makes no sense with -C} "varnishd -C -b 127.0.0.1:80 -F 2>&1" err_shell {usage: varnishd [options]} "varnishd -h 2>&1" err_shell {usage: varnishd [options]} "varnishd -? 2>&1" err_shell {Invalid backslash sequence} {varnishd -l 'xyz\kk,xyz\foo' 2>&1} err_shell {Invalid backslash sequence} {varnishd -l 'ab\8cd' 2>&1} -err_shell {Copyright (c) 2006} {varnishd -V 2>&1} -err_shell {Cannot open -S file (/nonexistent)} {varnishd -S /nonexistent 2>&1} +err_shell {Copyright (c) 2006} "varnishd -V 2>&1" +err_shell {Cannot open -S file (/nonexistent)} "varnishd -S /nonexistent 2>&1" From phk at FreeBSD.org Sun Jan 8 12:00:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Sun, 08 Jan 2017 13:00:05 +0100 Subject: [master] a10d3bd Fix -S test to stay in tmpdir Message-ID: commit a10d3bd7fd40a754c326eeb70b9cee75c0c10fed Author: Poul-Henning Kamp Date: Sun Jan 8 11:59:39 2017 +0000 Fix -S test to stay in tmpdir diff --git a/bin/varnishtest/tests/a00009.vtc b/bin/varnishtest/tests/a00009.vtc index f78916d..868d6d2 100644 --- a/bin/varnishtest/tests/a00009.vtc +++ b/bin/varnishtest/tests/a00009.vtc @@ -28,4 +28,6 @@ err_shell {usage: varnishd [options]} "varnishd -? 2>&1" err_shell {Invalid backslash sequence} {varnishd -l 'xyz\kk,xyz\foo' 2>&1} err_shell {Invalid backslash sequence} {varnishd -l 'ab\8cd' 2>&1} err_shell {Copyright (c) 2006} "varnishd -V 2>&1" -err_shell {Cannot open -S file (/nonexistent)} "varnishd -S /nonexistent 2>&1" +err_shell {Cannot open -S file} { + varnishd -S ${tmpdir}/nonexistent -n ${tmpdir}/v0 2>&1 + From phk at FreeBSD.org Sun Jan 8 12:38:04 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Sun, 08 Jan 2017 13:38:04 +0100 Subject: [master] fd3ed58 Add missing close-} Message-ID: commit fd3ed58538b8eacb750ec13a0406b7c9c8a87f37 Author: Poul-Henning Kamp Date: Sun Jan 8 12:37:16 2017 +0000 Add missing close-} diff --git a/bin/varnishtest/tests/a00009.vtc b/bin/varnishtest/tests/a00009.vtc index 868d6d2..db33d36 100644 --- a/bin/varnishtest/tests/a00009.vtc +++ b/bin/varnishtest/tests/a00009.vtc @@ -30,4 +30,5 @@ err_shell {Invalid backslash sequence} {varnishd -l 'ab\8cd' 2>&1} err_shell {Copyright (c) 2006} "varnishd -V 2>&1" err_shell {Cannot open -S file} { varnishd -S ${tmpdir}/nonexistent -n ${tmpdir}/v0 2>&1 +} From phk at FreeBSD.org Sun Jan 8 22:04:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Sun, 08 Jan 2017 23:04:05 +0100 Subject: [master] c6bcb02 Messin' around with gcov Message-ID: commit c6bcb0276342a4fe4c3480569a1d9c587793b79f Author: Poul-Henning Kamp Date: Sun Jan 8 22:03:22 2017 +0000 Messin' around with gcov diff --git a/Makefile.am b/Makefile.am index 4c97327..0488281 100644 --- a/Makefile.am +++ b/Makefile.am @@ -42,4 +42,7 @@ cscope: find . -name '*.[hcS]' > cscope.files cscope -b +gcov_digest: + ${PYTHON} tools/gcov_digest.py -o _gcov + .PHONY: cscope diff --git a/tools/gcov_digest.py b/tools/gcov_digest.py index 5fce2f5..4b24187 100644 --- a/tools/gcov_digest.py +++ b/tools/gcov_digest.py @@ -43,7 +43,8 @@ Options: Arguments: - directories to process + directories to process. + default: . """ @@ -95,6 +96,8 @@ def run_gcov(prog, subdir): for i in exclude: if i in dirs: dirs.remove(i) + if " ".join(files).find(".gcda") == -1: + continue for fn in files: if fn[-2:] != ".o": continue @@ -106,13 +109,15 @@ def run_gcov(prog, subdir): x = subprocess.check_output( ["cd " + root + "/.. && " + "exec " + prog + " -r .libs/" + fn], - stderr=subprocess.STDOUT, shell=True) + stderr=subprocess.STDOUT, shell=True, + universal_newlines=True) pf = ".." else: x = subprocess.check_output( ["cd " + root + " && " + "exec " + prog + " -r " + fn], - stderr=subprocess.STDOUT, shell=True) + stderr=subprocess.STDOUT, shell=True, + universal_newlines=True) pf = "" for ln in x.split("\n"): @@ -137,9 +142,9 @@ def produce_output(fdo): "." in count means "same as previous count" """ - for sn, cnt in counts.iteritems(): + for sn, cnt in counts.items(): fdo.write("/" + sn + " " + str(lengths[sn]) + "\n") - lnos = list(cnt.iteritems()) + lnos = list(cnt.items()) lnos.sort() pln = -1 pcn = -1 @@ -188,6 +193,8 @@ if __name__ == "__main__": exclude.append(v) else: assert False + if len(args) == 0: + args = ["."] for dn in args: run_gcov(gcovprog, dn) From fgsch at lodoss.net Mon Jan 9 13:05:05 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Mon, 09 Jan 2017 14:05:05 +0100 Subject: [master] eeaa3c0 Some coverage on varnishstat Message-ID: commit eeaa3c025e4369960af37b736193dd0c67aeae98 Author: Federico G. Schwindt Date: Mon Jan 9 12:55:58 2017 +0000 Some coverage on varnishstat diff --git a/bin/varnishtest/tests/u00005.vtc b/bin/varnishtest/tests/u00005.vtc new file mode 100644 index 0000000..895333d --- /dev/null +++ b/bin/varnishtest/tests/u00005.vtc @@ -0,0 +1,18 @@ +varnishtest "varnishstat coverage" + +server s1 { + rxreq + txresp +} -start + +varnish v1 -vcl+backend {} -start + +delay 1 + +process p1 "exec varnishstat -h -n ${v1_name}" -run +process p2 "exec varnishstat -l -n ${v1_name}" -run +process p3 "exec varnishstat -V -n ${v1_name}" -run +process p4 "exec varnishstat -1 -n ${v1_name}" -run +process p5 "exec varnishstat -1 -n ${v1_name} -x" -run +process p6 "exec varnishstat -1 -n ${v1_name} -j" -run +process p7 "exec varnishstat -n ${v1_name} extra" -run From fgsch at lodoss.net Tue Jan 10 09:28:05 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Tue, 10 Jan 2017 10:28:05 +0100 Subject: [master] 1690d36 Better Message-ID: commit 1690d363b92dd2da60c406faff43f0d07fe7b591 Author: Federico G. Schwindt Date: Tue Jan 10 08:53:02 2017 +0000 Better diff --git a/bin/varnishtest/tests/u00002.vtc b/bin/varnishtest/tests/u00002.vtc index 173c9cd..a8485d9 100644 --- a/bin/varnishtest/tests/u00002.vtc +++ b/bin/varnishtest/tests/u00002.vtc @@ -7,8 +7,6 @@ server s1 { varnish v1 -vcl+backend {} -start -delay 1 - process p1 {varnishstat -1 -n ${v1_name} -f ^LCK.vbe.destroy \ -f LCK.vbe.* -f LCK.mempool.* | tr '[1-9]' '0'} -run diff --git a/bin/varnishtest/tests/u00003.vtc b/bin/varnishtest/tests/u00003.vtc index e76ed03..14a54c4 100644 --- a/bin/varnishtest/tests/u00003.vtc +++ b/bin/varnishtest/tests/u00003.vtc @@ -7,8 +7,6 @@ server s1 { varnish v1 -vcl+backend {} -start -delay 2 - err_shell "Missing tag in VSL:" \ {varnishncsa -n ${v1_name} -F "%{VSL:}x" 2>&1} diff --git a/bin/varnishtest/tests/u00005.vtc b/bin/varnishtest/tests/u00005.vtc index 895333d..b33fbe0 100644 --- a/bin/varnishtest/tests/u00005.vtc +++ b/bin/varnishtest/tests/u00005.vtc @@ -7,12 +7,10 @@ server s1 { varnish v1 -vcl+backend {} -start -delay 1 - -process p1 "exec varnishstat -h -n ${v1_name}" -run -process p2 "exec varnishstat -l -n ${v1_name}" -run -process p3 "exec varnishstat -V -n ${v1_name}" -run -process p4 "exec varnishstat -1 -n ${v1_name}" -run -process p5 "exec varnishstat -1 -n ${v1_name} -x" -run -process p6 "exec varnishstat -1 -n ${v1_name} -j" -run +process p1 "exec varnishstat -n ${v1_name} -h" -run +process p2 "exec varnishstat -n ${v1_name} -l" -run +process p3 "exec varnishstat -n ${v1_name} -V" -run +process p4 "exec varnishstat -n ${v1_name} -1" -run +process p5 "exec varnishstat -n ${v1_name} -x" -run +process p6 "exec varnishstat -n ${v1_name} -j" -run process p7 "exec varnishstat -n ${v1_name} extra" -run From fgsch at lodoss.net Tue Jan 10 09:28:05 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Tue, 10 Jan 2017 10:28:05 +0100 Subject: [master] 275b007 Start with varnishlog coverage Message-ID: commit 275b0076ca0a7b2c703a7f3b27ccd14a41dfb19b Author: Federico G. Schwindt Date: Tue Jan 10 08:54:39 2017 +0000 Start with varnishlog coverage diff --git a/bin/varnishtest/tests/u00006.vtc b/bin/varnishtest/tests/u00006.vtc new file mode 100644 index 0000000..d657b69 --- /dev/null +++ b/bin/varnishtest/tests/u00006.vtc @@ -0,0 +1,14 @@ +varnishtest "varnishlog coverage" + +server s1 { + rxreq + txresp +} -start + +varnish v1 -vcl+backend {} -start + +process p1 "exec varnishlog -n ${v1_name} -g raw -k 1" -start +process p2 "exec varnishlog -n ${v1_name} -h" -run +process p3 "exec varnishlog -n ${v1_name} -V" -run +process p4 "exec varnishlog -n ${v1_name} extra" -run +process p1 -wait From phk at FreeBSD.org Tue Jan 10 11:47:04 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 10 Jan 2017 12:47:04 +0100 Subject: [master] e8c074b Restrict return(vcl) to before any restart, and reset the req.http to avoid any memory leaks. Message-ID: commit e8c074b9abd382f0734c69596cdd532f0cadfe9e Author: Poul-Henning Kamp Date: Tue Jan 10 11:45:28 2017 +0000 Restrict return(vcl) to before any restart, and reset the req.http to avoid any memory leaks. Closes #2177 diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 694260e..e6a18b6 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -691,8 +691,10 @@ cnt_recv(struct worker *wrk, struct req *req) } VCL_recv_method(req->vcl, wrk, req, NULL, NULL); - if (wrk->handling == VCL_RET_VCL) { + if (wrk->handling == VCL_RET_VCL && req->restarts == 0) { req->director_hint = VCL_DefaultDirector(req->vcl); + HTTP_Copy(req->http, req->http0); + WS_Reset(req->ws, req->ws_req); AN(req->director_hint); VCL_recv_method(req->vcl, wrk, req, NULL, NULL); } @@ -724,7 +726,9 @@ cnt_recv(struct worker *wrk, struct req *req) switch(recv_handling) { case VCL_RET_VCL: VSLb(req->vsl, SLT_VCL_Error, - "return(vcl) only allowed from active (top) VCL."); + "Illegal return(vcl): %s", + req->restarts ? "Not after restarts" : + "Only from active VCL"); req->err_code = 503; req->req_step = R_STP_SYNTH; return (REQ_FSM_MORE); diff --git a/bin/varnishtest/tests/r02177.vtc b/bin/varnishtest/tests/r02177.vtc new file mode 100644 index 0000000..9d4e437 --- /dev/null +++ b/bin/varnishtest/tests/r02177.vtc @@ -0,0 +1,64 @@ +varnishtest "restart then switch to label" + +server s1 { + rxreq + txresp +} -start + +server s2 { + rxreq + txresp -status 404 +} -start + +varnish v1 -vcl { + backend s1 { .host="${s1_addr}"; .port="${s1_port}"; } +} -start + +varnish v1 -cli "vcl.label lbl1 vcl1" + +varnish v1 -vcl { + backend s1 { .host="${s1_addr}"; .port="${s1_port}"; } + + sub vcl_recv { + return (vcl(lbl1)); + } +} + +varnish v1 -cli "vcl.label lbl2 vcl2" + +varnish v1 -vcl { + backend s2 { .host="${s2_addr}"; .port="${s2_port}"; } + + sub vcl_recv { + if (req.restarts > 0) { + return (vcl(lbl1)); + } + if (req.http.restart) { + return (vcl(lbl2)); + } + } + + sub vcl_miss { + return (restart); + } +} + +varnish v1 -cliok "vcl.list" + +logexpect l1 -v v1 -g raw { + expect * * VCL_Error "Illegal return.vcl.: Not after restarts" + expect * * VCL_Error "Illegal return.vcl.: Only from active VCL" + +} -start + +client c1 { + txreq + rxresp + expect resp.status == 503 + + txreq -hdr "restart: yes" + rxresp + expect resp.status == 503 +} -run + +logexpect l1 -wait From dridi.boukelmoune at gmail.com Tue Jan 10 12:56:05 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 10 Jan 2017 13:56:05 +0100 Subject: [master] d977207 Collect vtest failed tests logs more reliably Message-ID: commit d977207d1259e985daf0050ad3a5e5bcc870c0d5 Author: Dridi Boukelmoune Date: Mon Nov 21 15:24:32 2016 +0100 Collect vtest failed tests logs more reliably Instead of randomly looking for the log files, look for them where we expect them to land. For instance, after a git pull, a distclean operation may not remove the dist directory if Varnish's version changed because it would reconfigure itself on the fly. Instead of reading the output of `make distcheck`, look for failing tests in the dist directory. diff --git a/tools/vtest.sh b/tools/vtest.sh index cdd2d85..4f732cb 100755 --- a/tools/vtest.sh +++ b/tools/vtest.sh @@ -80,21 +80,26 @@ makedistcheck () ( ) failedtests () ( - for t in `grep '^FAIL: tests/' ${1} | sort -u | sed 's/.* //'` + set -e + + REPORTDIR=`pwd`/_report + + cd varnish-cache + + VERSION=`./configure --version | awk 'NR == 1 {print $NF}'` + LOGDIR=varnish-$VERSION/_build/sub/bin/varnishtest/tests + VTCDIR=bin/varnishtest/tests + + grep -l ':test-result: FAIL' $LOGDIR/*.trs | + while read trs do - printf 'VTCGITREV %s ' "${t}" - ( - cd varnish-cache/bin/varnishtest/ - git log -n 1 ${t} | head -1 - ) - b=`basename ${t} .vtc` - for i in `find "${BUILDDIR}" -name ${b}.log -print` - do - if [ -f ${i} ] ; then - mv ${i} "_report/_${b}.log" - echo "MANIFEST _${b}.log" >> ${LOG} - fi - done + name=`basename $trs .trs` + vtc=${name}.vtc + log=${name}.log + rev=`git log -n 1 --pretty=format:%H ${VTCDIR}/${vtc}` + cp ${LOGDIR}/${log} ${REPORTDIR}/_${log} + echo "VTCGITREV ${name} ${rev}" + echo "MANIFEST _${log}" done ) @@ -179,7 +184,7 @@ do echo "MAKEDISTCHECK BAD" >> ${LOG} echo "MANIFEST _autogen" >> ${LOG} echo "MANIFEST _makedistcheck" >> ${LOG} - failedtests _report/_makedistcheck >> ${LOG} + failedtests >> ${LOG} else echo "MAKEDISTCHECK GOOD" >> ${LOG} waitnext=${WAITGOOD} From dridi.boukelmoune at gmail.com Tue Jan 10 12:56:05 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 10 Jan 2017 13:56:05 +0100 Subject: [master] 6cd97d1 Introduce a `vtest-clean` make target Message-ID: commit 6cd97d1167353a5129ee39f9524fa39eb195a9f4 Author: Dridi Boukelmoune Date: Fri Dec 23 11:07:28 2016 +0100 Introduce a `vtest-clean` make target When a `distcheck` fails, the $(distdir) is not removed and this is how we can collect test results. This directory is also left untouched by the `distclean` target run from `autogen.des`. So if the next commit checked by vtest fails before running inside the $(distdir), it will report failures from the previous run. To avoid that we can use $(am__remove_distdir) that deals with permissions but may not be stable API. diff --git a/Makefile.am b/Makefile.am index 0488281..f018bc8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -32,6 +32,9 @@ distcleancheck_listfiles = \ find . -type f -exec sh -c 'test -f $(srcdir)/$$1 || echo $$1' \ sh '{}' ';' +vtest-clean: + $(am__remove_distdir) + # XXX: This is a hack to ensure we have a built source tree when # running make dist If we had used non-recursive make we could have # solved it better, but we don't, so use this at least for now. diff --git a/tools/vtest.sh b/tools/vtest.sh index 4f732cb..a4e9fa6 100755 --- a/tools/vtest.sh +++ b/tools/vtest.sh @@ -76,6 +76,7 @@ autogen () ( makedistcheck () ( set -e cd "${BUILDDIR}" + nice make vtest-clean nice make distcheck ) From phk at FreeBSD.org Tue Jan 10 13:28:04 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 10 Jan 2017 14:28:04 +0100 Subject: [master] 19ff7a5 Keep track of and report how many return(vcl)'s hold a label Message-ID: commit 19ff7a5986568164a9d17c67f0723bfa233ffbce Author: Poul-Henning Kamp Date: Tue Jan 10 13:02:54 2017 +0000 Keep track of and report how many return(vcl)'s hold a label diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c index f284575..ba7f296 100644 --- a/bin/varnishd/cache/cache_vcl.c +++ b/bin/varnishd/cache/cache_vcl.c @@ -72,6 +72,7 @@ struct vcl { pthread_rwlock_t temp_rwl; VTAILQ_HEAD(,backend) backend_list; VTAILQ_HEAD(,vclref) ref_list; + int nrefs; struct vcl *label; int nlabels; }; @@ -521,16 +522,30 @@ VRT_count(VRT_CTX, unsigned u) } VCL_VCL -VRT_vcl_lookup(const char *name) +VRT_vcl_get(VRT_CTX, const char *name) { VCL_VCL vcl; + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); vcl = vcl_find(name); AN(vcl); + Lck_Lock(&vcl_mtx); + vcl->nrefs++; + Lck_Unlock(&vcl_mtx); return (vcl); } void +VRT_vcl_rel(VRT_CTX, VCL_VCL vcl) +{ + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + AN(vcl); + Lck_Lock(&vcl_mtx); + vcl->nrefs--; + Lck_Unlock(&vcl_mtx); +} + +void VRT_vcl_select(VRT_CTX, VCL_VCL vcl) { struct req *req = ctx->req; @@ -564,6 +579,7 @@ VRT_ref_vcl(VRT_CTX, const char *desc) Lck_Lock(&vcl_mtx); VTAILQ_INSERT_TAIL(&vcl->ref_list, ref, list); + vcl->nrefs++; Lck_Unlock(&vcl_mtx); return (ref); @@ -595,6 +611,7 @@ VRT_rel_vcl(VRT_CTX, struct vclref **refp) Lck_Lock(&vcl_mtx); assert(!VTAILQ_EMPTY(&vcl->ref_list)); VTAILQ_REMOVE(&vcl->ref_list, ref, list); + vcl->nrefs--; /* No garbage collection here, for the same reasons as in VCL_Rel. */ Lck_Unlock(&vcl_mtx); @@ -812,12 +829,15 @@ vcl_cli_list(struct cli *cli, const char * const *av, void *priv) flg = "available"; VCLI_Out(cli, "%-10s %5s/%-8s %6u %s", flg, vcl->state, vcl->temp, vcl->busy, vcl->loaded_name); - if (vcl->label != NULL) + if (vcl->label != NULL) { VCLI_Out(cli, " -> %s", vcl->label->loaded_name); - else if (vcl->nlabels > 1) - VCLI_Out(cli, " (%d labels)", vcl->nlabels); - else if (vcl->nlabels > 0) - VCLI_Out(cli, " (%d label)", vcl->nlabels); + if (vcl->nrefs) + VCLI_Out(cli, " (%d return(vcl)%s)", + vcl->nrefs, vcl->nrefs > 1 ? "'s" : ""); + } else if (vcl->nlabels > 0) { + VCLI_Out(cli, " (%d label%s)", + vcl->nlabels, vcl->nlabels > 1 ? "s" : ""); + } VCLI_Out(cli, "\n"); } } diff --git a/bin/varnishd/mgt/mgt_vcl.c b/bin/varnishd/mgt/mgt_vcl.c index e34b0cb..adfb7c6 100644 --- a/bin/varnishd/mgt/mgt_vcl.c +++ b/bin/varnishd/mgt/mgt_vcl.c @@ -643,15 +643,17 @@ mcf_vcl_list(struct cli *cli, const char * const *av, void *priv) vp->state); VCLI_Out(cli, "/%-8s", vp->warm ? VCL_STATE_WARM : VCL_STATE_COLD); - VCLI_Out(cli, " %6s %s", "", vp->name); + VCLI_Out(cli, " %6s %s", "-", vp->name); if (mcf_is_label(vp)) { vd = VTAILQ_FIRST(&vp->dfrom); AN(vd); VCLI_Out(cli, " -> %s", vd->to->name); - } else if (vp->nto > 1) { - VCLI_Out(cli, " (%d labels)", vp->nto); + if (vp->nto > 0) + VCLI_Out(cli, " (%d return(vcl)%s)", + vp->nto, vp->nto > 1 ? "'s" : ""); } else if (vp->nto > 0) { - VCLI_Out(cli, " (%d label)", vp->nto); + VCLI_Out(cli, " (%d label%s)", + vp->nto, vp->nto > 1 ? "s" : ""); } VCLI_Out(cli, "\n"); } diff --git a/include/vrt.h b/include/vrt.h index 567c49b..b6915d7 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -319,7 +319,8 @@ int VRT_Vmod_Init(VRT_CTX, struct vmod **hdl, void *ptr, int len, void VRT_Vmod_Fini(struct vmod **hdl); /* VCL program related */ -VCL_VCL VRT_vcl_lookup(const char *); +VCL_VCL VRT_vcl_get(VRT_CTX, const char *); +void VRT_vcl_rel(VRT_CTX, VCL_VCL); void VRT_vcl_select(VRT_CTX, VCL_VCL); struct vmod_priv; diff --git a/lib/libvcc/vcc_action.c b/lib/libvcc/vcc_action.c index 92e7b9f..9e45f58 100644 --- a/lib/libvcc/vcc_action.c +++ b/lib/libvcc/vcc_action.c @@ -264,8 +264,10 @@ parse_return_vcl(struct vcc *tl) p = New_IniFin(tl); AN(p); - VSB_printf(p->ini, "\t%s = VRT_vcl_lookup(\"%.*s\");", + VSB_printf(p->ini, "\t%s = VRT_vcl_get(ctx, \"%.*s\");", buf, PF(tl->t)); + VSB_printf(p->fin, "\tVRT_vcl_rel(ctx, %s);", + buf); } Fb(tl, 1, "VRT_vcl_select(ctx, %s);\t/* %.*s */\n", (const char*)sym->eval_priv, PF(tl->t)); From phk at FreeBSD.org Tue Jan 10 13:28:04 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 10 Jan 2017 14:28:04 +0100 Subject: [master] 2b01302 Load the vcls and labels into the child process in dependency order. Message-ID: commit 2b013025ddd134e283603c4d78687ac0209159a4 Author: Poul-Henning Kamp Date: Tue Jan 10 13:26:47 2017 +0000 Load the vcls and labels into the child process in dependency order. diff --git a/bin/varnishd/mgt/mgt_vcl.c b/bin/varnishd/mgt/mgt_vcl.c index adfb7c6..8061634 100644 --- a/bin/varnishd/mgt/mgt_vcl.c +++ b/bin/varnishd/mgt/mgt_vcl.c @@ -74,6 +74,7 @@ struct vclprog { VTAILQ_HEAD(, vcldep) dfrom; VTAILQ_HEAD(, vcldep) dto; int nto; + int loaded; }; static VTAILQ_HEAD(, vclprog) vclhead = VTAILQ_HEAD_INITIALIZER(vclhead); @@ -409,45 +410,46 @@ mgt_push_vcls_and_start(struct cli *cli, unsigned *status, char **p) { struct vclprog *vp; struct vcldep *vd; + int done; AN(active_vcl); /* The VCL has not been loaded yet, it cannot fail */ AZ(mgt_vcl_setstate(cli, active_vcl, VCL_STATE_WARM)); - VTAILQ_FOREACH(vp, &vclhead, list) { - if (!VTAILQ_EMPTY(&vp->dfrom)) - continue; - if (mcf_is_label(vp)) - continue; - if (mgt_cli_askchild(status, p, "vcl.load \"%s\" %s %d%s\n", - vp->name, vp->fname, vp->warm, vp->state)) - return (1); - free(*p); - *p = NULL; - } - VTAILQ_FOREACH(vp, &vclhead, list) { - if (!mcf_is_label(vp)) - continue; - vd = VTAILQ_FIRST(&vp->dfrom); - AN(vd); - if (mgt_cli_askchild(status, p, "vcl.label %s %s\n", - vp->name, vd->to->name)) - return (1); - free(*p); - *p = NULL; - } - VTAILQ_FOREACH(vp, &vclhead, list) { - if (VTAILQ_EMPTY(&vp->dfrom)) - continue; - if (mcf_is_label(vp)) - continue; - if (mgt_cli_askchild(status, p, "vcl.load \"%s\" %s %d%s\n", - vp->name, vp->fname, vp->warm, vp->state)) - return (1); - free(*p); - *p = NULL; - } + VTAILQ_FOREACH(vp, &vclhead, list) + vp->loaded = 0; + + do { + done = 1; + VTAILQ_FOREACH(vp, &vclhead, list) { + if (vp->loaded) + continue; + VTAILQ_FOREACH(vd, &vp->dfrom, lfrom) + if (!vd->to->loaded) + break; + if (vd != NULL) { + done = 0; + continue; + } + if (mcf_is_label(vp)) { + vd = VTAILQ_FIRST(&vp->dfrom); + AN(vd); + if (mgt_cli_askchild(status, p, + "vcl.label %s %s\n", + vp->name, vd->to->name)) + return (1); + } else { + if (mgt_cli_askchild(status, p, + "vcl.load \"%s\" %s %d%s\n", + vp->name, vp->fname, vp->warm, vp->state)) + return (1); + } + vp->loaded = 1; + free(*p); + *p = NULL; + } + } while(!done); if (mgt_cli_askchild(status, p, "vcl.use \"%s\"\n", active_vcl->name)) return (1); diff --git a/bin/varnishtest/tests/r02177.vtc b/bin/varnishtest/tests/r02177.vtc index 9d4e437..8c10934 100644 --- a/bin/varnishtest/tests/r02177.vtc +++ b/bin/varnishtest/tests/r02177.vtc @@ -12,7 +12,7 @@ server s2 { varnish v1 -vcl { backend s1 { .host="${s1_addr}"; .port="${s1_port}"; } -} -start +} varnish v1 -cli "vcl.label lbl1 vcl1" @@ -44,6 +44,8 @@ varnish v1 -vcl { } varnish v1 -cliok "vcl.list" +varnish v1 -start +varnish v1 -cliok "vcl.list" logexpect l1 -v v1 -g raw { expect * * VCL_Error "Illegal return.vcl.: Not after restarts" From phk at FreeBSD.org Tue Jan 10 14:53:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 10 Jan 2017 15:53:05 +0100 Subject: [master] 79a6261 Stabilize this test Message-ID: commit 79a6261ef17cc97ef318b79996fa3a09750c3fdd Author: Poul-Henning Kamp Date: Tue Jan 10 14:51:52 2017 +0000 Stabilize this test diff --git a/bin/varnishtest/tests/u00002.vtc b/bin/varnishtest/tests/u00002.vtc index a8485d9..4735cf5 100644 --- a/bin/varnishtest/tests/u00002.vtc +++ b/bin/varnishtest/tests/u00002.vtc @@ -7,6 +7,11 @@ server s1 { varnish v1 -vcl+backend {} -start +# On fast systems the next varnishstat will return "inf" counters +# if we don't give varnishd a chance to get going. + +delay 1 + process p1 {varnishstat -1 -n ${v1_name} -f ^LCK.vbe.destroy \ -f LCK.vbe.* -f LCK.mempool.* | tr '[1-9]' '0'} -run From dridi.boukelmoune at gmail.com Tue Jan 10 15:05:05 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 10 Jan 2017 16:05:05 +0100 Subject: [master] 82744f1 Coverage Message-ID: commit 82744f145e5a3f109d9471051e17c901eb4354a0 Author: Dridi Boukelmoune Date: Tue Jan 10 15:04:31 2017 +0100 Coverage Inherited from out-of-tree coverage scripts. diff --git a/bin/varnishtest/tests/a00009.vtc b/bin/varnishtest/tests/a00009.vtc index db33d36..a6071da 100644 --- a/bin/varnishtest/tests/a00009.vtc +++ b/bin/varnishtest/tests/a00009.vtc @@ -28,6 +28,7 @@ err_shell {usage: varnishd [options]} "varnishd -? 2>&1" err_shell {Invalid backslash sequence} {varnishd -l 'xyz\kk,xyz\foo' 2>&1} err_shell {Invalid backslash sequence} {varnishd -l 'ab\8cd' 2>&1} err_shell {Copyright (c) 2006} "varnishd -V 2>&1" +err_shell {usage: varnishd [options]} "varnishd --help 2>&1" err_shell {Cannot open -S file} { varnishd -S ${tmpdir}/nonexistent -n ${tmpdir}/v0 2>&1 } From fgsch at lodoss.net Tue Jan 10 23:12:04 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Wed, 11 Jan 2017 00:12:04 +0100 Subject: [master] 9d29b38 Polish, mostly for coverage purposes Message-ID: commit 9d29b38612a74c443e40434a9093a297845c194c Author: Federico G. Schwindt Date: Tue Jan 10 21:02:52 2017 +0000 Polish, mostly for coverage purposes diff --git a/bin/varnishadm/varnishadm.c b/bin/varnishadm/varnishadm.c index e90df71..b3823d8 100644 --- a/bin/varnishadm/varnishadm.c +++ b/bin/varnishadm/varnishadm.c @@ -484,9 +484,8 @@ main(int argc, char * const *argv) argv += optind; if (n_arg != NULL) { - if (T_arg != NULL || S_arg != NULL) { + if (T_arg != NULL || S_arg != NULL) usage(1); - } sock = n_arg_sock(n_arg); } else if (T_arg == NULL) { sock = n_arg_sock(""); diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index b4766b2..5d3126b 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -644,15 +644,31 @@ main(int argc, char * const *argv) */ while ((o = getopt(argc, argv, opt_spec)) != -1) { switch (o) { - case '?': usage(); break; - case 'b': b_arg = optarg; break; - case 'C': C_flag = 1; break; - case 'd': d_flag++; break; - case 'f': f_arg = optarg; break; - case 'F': F_flag = 1; break; - case 'j': j_arg = optarg; break; - case 'x': x_arg = optarg; break; - default: break; + case '?': + usage(); + case 'b': + b_arg = optarg; + break; + case 'C': + C_flag = 1; + break; + case 'd': + d_flag++; + break; + case 'f': + f_arg = optarg; + break; + case 'F': + F_flag = 1; + break; + case 'j': + j_arg = optarg; + break; + case 'x': + x_arg = optarg; + break; + default: + break; } } diff --git a/bin/varnishlog/varnishlog.c b/bin/varnishlog/varnishlog.c index c5d9d92..b61512d 100644 --- a/bin/varnishlog/varnishlog.c +++ b/bin/varnishlog/varnishlog.c @@ -137,7 +137,6 @@ main(int argc, char * const *argv) case 'h': /* Usage help */ usage(0); - break; case 'w': /* Write to file */ REPLACE(LOG.w_arg, optarg); From fgsch at lodoss.net Tue Jan 10 23:12:04 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Wed, 11 Jan 2017 00:12:04 +0100 Subject: [master] b5e64a9 Improve previous tests and add a few more Message-ID: commit b5e64a92d1f0d2d3e5017f1adf1baf4bfba6e89f Author: Federico G. Schwindt Date: Tue Jan 10 23:00:31 2017 +0000 Improve previous tests and add a few more diff --git a/bin/varnishtest/tests/u00005.vtc b/bin/varnishtest/tests/u00005.vtc index b33fbe0..4905e09 100644 --- a/bin/varnishtest/tests/u00005.vtc +++ b/bin/varnishtest/tests/u00005.vtc @@ -8,9 +8,18 @@ server s1 { varnish v1 -vcl+backend {} -start process p1 "exec varnishstat -n ${v1_name} -h" -run +shell {grep -q "Usage: varnishstat " ${tmpdir}/p1/stderr} process p2 "exec varnishstat -n ${v1_name} -l" -run +shell {grep -q "Varnishstat -f option fields:" ${tmpdir}/p2/stdout} process p3 "exec varnishstat -n ${v1_name} -V" -run +shell {grep -q "Copyright (c) 2006 Verdens Gang AS" ${tmpdir}/p3/stderr} process p4 "exec varnishstat -n ${v1_name} -1" -run +shell {grep -q "MAIN.uptime" ${tmpdir}/p4/stdout} process p5 "exec varnishstat -n ${v1_name} -x" -run +shell {grep -q "MAIN" ${tmpdir}/p5/stdout} process p6 "exec varnishstat -n ${v1_name} -j" -run +shell {grep -q "MAIN.uptime\":" ${tmpdir}/p6/stdout} process p7 "exec varnishstat -n ${v1_name} extra" -run +shell {grep -q "Usage: varnishstat " ${tmpdir}/p7/stderr} +process p8 "exec varnishstat -n /nonexistent" -run +shell {grep -q "Cannot open /nonexistent/_.vsm" ${tmpdir}/p8/stderr} diff --git a/bin/varnishtest/tests/u00006.vtc b/bin/varnishtest/tests/u00006.vtc index d657b69..b30bbfd 100644 --- a/bin/varnishtest/tests/u00006.vtc +++ b/bin/varnishtest/tests/u00006.vtc @@ -8,7 +8,20 @@ server s1 { varnish v1 -vcl+backend {} -start process p1 "exec varnishlog -n ${v1_name} -g raw -k 1" -start -process p2 "exec varnishlog -n ${v1_name} -h" -run -process p3 "exec varnishlog -n ${v1_name} -V" -run -process p4 "exec varnishlog -n ${v1_name} extra" -run +process p2 { + exec varnishlog -n ${v1_name} -g raw -k 1 -w ${tmpdir}/p2/output -A +} -start +process p3 "exec varnishlog -n ${v1_name} -h" -run +shell {grep -q "Usage: varnishlog " ${tmpdir}/p3/stderr} +process p4 "exec varnishlog -n ${v1_name} -V" -run +shell {grep -q "Copyright (c) 2006 Verdens Gang AS" ${tmpdir}/p4/stderr} +process p5 "exec varnishlog -n ${v1_name} extra" -run +shell {grep -q "Usage: varnishlog " ${tmpdir}/p5/stderr} +process p6 "exec varnishlog -n ${v1_name} -D" -run +shell {grep -q "Missing -w option" ${tmpdir}/p6/stderr} +process p7 "exec varnishlog -n ${v1_name} -L 0" -run +shell {grep -q -- "-L: Range error" ${tmpdir}/p7/stderr} process p1 -wait +shell {grep -q "0 CLI" ${tmpdir}/p1/stdout} +process p2 -wait +shell {grep -q "0 CLI" ${tmpdir}/p2/output} From phk at FreeBSD.org Wed Jan 11 10:30:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 11 Jan 2017 11:30:05 +0100 Subject: [master] cddfbca Arguments must be set on first invocation of a varnish instance Message-ID: commit cddfbcacbe686160cd4b0b9412c5adaaf73de185 Author: Poul-Henning Kamp Date: Wed Jan 11 10:25:28 2017 +0000 Arguments must be set on first invocation of a varnish instance diff --git a/bin/varnishtest/tests/c00005.vtc b/bin/varnishtest/tests/c00005.vtc index 9343306..b9072f8 100644 --- a/bin/varnishtest/tests/c00005.vtc +++ b/bin/varnishtest/tests/c00005.vtc @@ -9,6 +9,8 @@ server s1 { txresp -body "2222\n" } -start +varnish v1 -arg "-p vsl_mask=+VCL_trace" + varnish v1 -errvcl {Name acl1 must have type 'acl'.} { sub vcl_recv { if (client.ip ~ acl1) { @@ -21,7 +23,7 @@ varnish v1 -errvcl {Name acl1 must have type 'acl'.} { } } -varnish v1 -arg "-p vsl_mask=+VCL_trace" -vcl+backend { +varnish v1 -vcl+backend { sub vcl_recv { if (client.ip ~ acl1) { set req.url = "/"; From phk at FreeBSD.org Wed Jan 11 10:30:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 11 Jan 2017 11:30:05 +0100 Subject: [master] 85b8250 Fail tests if the process got a signal. Message-ID: commit 85b8250edecf74f35d9bcc34dfa19dd98c141595 Author: Poul-Henning Kamp Date: Wed Jan 11 10:27:46 2017 +0000 Fail tests if the process got a signal. diff --git a/bin/varnishtest/vtc_main.c b/bin/varnishtest/vtc_main.c index 8f9284a..1ca41f4 100644 --- a/bin/varnishtest/vtc_main.c +++ b/bin/varnishtest/vtc_main.c @@ -57,9 +57,6 @@ #include "vtim.h" #include "vct.h" -#define MAX_FILESIZE (1024 * 1024) - - struct vtc_tst { unsigned magic; #define TST_MAGIC 0x618d8b88 @@ -167,7 +164,7 @@ tst_cb(const struct vev *ve, int what) CAST_OBJ_NOTNULL(jp, ve->priv, JOB_MAGIC); - // printf("%p %s %d\n", ve, jp->tst->filename, what); + // printf("CB %p %s %d\n", ve, jp->tst->filename, what); if (what == 0) AZ(kill(jp->child, SIGKILL)); /* XXX: Timeout */ else @@ -186,10 +183,9 @@ tst_cb(const struct vev *ve, int what) t = VTIM_mono() - jp->t0; AZ(close(ve->fd)); - if (stx) + ecode = WTERMSIG(stx); + if (ecode == 0) ecode = WEXITSTATUS(stx); - else - ecode = 0; if (ecode > 1 && vtc_verbosity) printf("%s\n", jp->buf); From phk at FreeBSD.org Wed Jan 11 10:30:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 11 Jan 2017 11:30:05 +0100 Subject: [master] 1e6affc Refuse vcl.label if it would cause a return(vcl)'ed VCL to return(vcl) Message-ID: commit 1e6affcea87a2a4444ee54552599577a1509a4b6 Author: Poul-Henning Kamp Date: Wed Jan 11 10:28:18 2017 +0000 Refuse vcl.label if it would cause a return(vcl)'ed VCL to return(vcl) diff --git a/bin/varnishd/mgt/mgt_vcl.c b/bin/varnishd/mgt/mgt_vcl.c index 8061634..6791245 100644 --- a/bin/varnishd/mgt/mgt_vcl.c +++ b/bin/varnishd/mgt/mgt_vcl.c @@ -691,6 +691,18 @@ mcf_vcl_label(struct cli *cli, const char * const *av, void *priv) VCLI_Out(cli, "%s is not a label", vpl->name); return; } + if (!VTAILQ_EMPTY(&vpt->dfrom) && + !VTAILQ_EMPTY(&vpl->dto)) { + VCLI_SetResult(cli, CLIS_PARAM); + VCLI_Out(cli, "return(vcl) can only be used from" + " the active VCL.\n\n"); + VCLI_Out(cli, + "Label %s is used in return(vcl) from VCL %s\n", + vpl->name, VTAILQ_FIRST(&vpl->dto)->from->name); + VCLI_Out(cli, "and VCL %s also has return(vcl)", + vpt->name); + return; + } mgt_vcl_dep_del(VTAILQ_FIRST(&vpl->dfrom)); AN(VTAILQ_EMPTY(&vpl->dfrom)); } else { From phk at FreeBSD.org Wed Jan 11 10:30:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 11 Jan 2017 11:30:05 +0100 Subject: [master] 328c18e Test VCL-label loop detection Message-ID: commit 328c18e836b0b17ce02ddaa79548c0daf848023e Author: Poul-Henning Kamp Date: Wed Jan 11 10:28:47 2017 +0000 Test VCL-label loop detection diff --git a/bin/varnishtest/tests/v00048.vtc b/bin/varnishtest/tests/v00048.vtc index 68dedcf..67cd3a9 100644 --- a/bin/varnishtest/tests/v00048.vtc +++ b/bin/varnishtest/tests/v00048.vtc @@ -107,3 +107,23 @@ varnish v1 -cliok "vcl.label snarf vcl1" server s1 -start client c1 -run +# Test loop detection +####################################################################### + +varnish v1 -cliok vcl.list + +varnish v1 -vcl+backend { } + +varnish v1 -cliok "vcl.label lblA vcl3" + +varnish v1 -vcl+backend { sub vcl_recv { return (vcl(lblA)); } } + +varnish v1 -cliok "vcl.label lblB vcl4" + +varnish v1 -vcl+backend { sub vcl_recv { return (vcl(lblB)); } } + +varnish v1 -clierr 106 "vcl.label lblA vcl5" +varnish v1 -cliexpect \ + {can only be used from the active VCL} \ + {vcl.label lblA vcl5} + From phk at FreeBSD.org Wed Jan 11 12:28:04 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 11 Jan 2017 13:28:04 +0100 Subject: [master] 61de2e3 Add a generic VFIL_null_fd() function for pointing a fd at /dev/null Message-ID: commit 61de2e37b0ab6834746552cd3188bb20b1db8c52 Author: Poul-Henning Kamp Date: Wed Jan 11 12:27:28 2017 +0000 Add a generic VFIL_null_fd() function for pointing a fd at /dev/null diff --git a/bin/varnishd/mgt/mgt_child.c b/bin/varnishd/mgt/mgt_child.c index 5f23a24..988643a 100644 --- a/bin/varnishd/mgt/mgt_child.c +++ b/bin/varnishd/mgt/mgt_child.c @@ -50,6 +50,7 @@ #include "vbm.h" #include "vcli_serve.h" #include "vev.h" +#include "vfil.h" #include "vlu.h" #include "vtim.h" @@ -299,7 +300,7 @@ mgt_launch_child(struct cli *cli) unsigned u; char *p; struct vev *e; - int i, j, k, cp[2]; + int i, cp[2]; struct sigaction sa; if (child_state != CH_STOPPED && child_state != CH_DIED) @@ -345,8 +346,7 @@ mgt_launch_child(struct cli *cli) if (pid == 0) { /* Redirect stdin/out/err */ - AZ(close(STDIN_FILENO)); - assert(open("/dev/null", O_RDONLY) == STDIN_FILENO); + VFIL_null_fd(STDIN_FILENO); assert(dup2(heritage.std_fd, STDOUT_FILENO) == STDOUT_FILENO); assert(dup2(heritage.std_fd, STDERR_FILENO) == STDERR_FILENO); @@ -366,13 +366,8 @@ mgt_launch_child(struct cli *cli) for (i = STDERR_FILENO + 1; i < CLOSE_FD_UP_TO; i++) { if (vbit_test(fd_map, i)) continue; - if (close(i) == 0) { - k = open("/dev/null", O_RDONLY); - assert(k >= 0); - j = dup2(k, i); - assert(j == i); - AZ(close(k)); - } + if (close(i) == 0) + VFIL_null_fd(i); } #ifdef HAVE_SETPROCTITLE setproctitle("Varnish-Chld %s", heritage.name); diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index 5d3126b..dce1dba 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -363,12 +363,9 @@ cli_stdin_close(void *priv) (void)VPF_Remove(pfh); exit(0); } else { - (void)close(0); - (void)close(1); - (void)close(2); - AZ(open("/dev/null", O_RDONLY)); - assert(open("/dev/null", O_WRONLY) == 1); - assert(open("/dev/null", O_WRONLY) == 2); + VFIL_null_fd(STDIN_FILENO); + VFIL_null_fd(STDOUT_FILENO); + VFIL_null_fd(STDERR_FILENO); } } @@ -532,7 +529,6 @@ mgt_x_arg(const char *x_arg) ARGV_ERR("Invalid -x argument\n"); } - /*--------------------------------------------------------------------*/ #define ERIC_MAGIC 0x2246988a /* Eric is not random */ @@ -541,7 +537,6 @@ static int mgt_eric(void) { int eric_pipes[2]; - int fd; unsigned u; ssize_t sz; @@ -555,11 +550,7 @@ mgt_eric(void) AZ(close(eric_pipes[0])); assert(setsid() > 1); - fd = open("/dev/null", O_RDWR, 0); - assert(fd > 0); - assert(dup2(fd, STDIN_FILENO) == STDIN_FILENO); - if (fd > STDIN_FILENO) - AZ(close(fd)); + VFIL_null_fd(STDIN_FILENO); return (eric_pipes[1]); default: break; @@ -577,28 +568,13 @@ mgt_eric(void) static void mgt_eric_im_done(int eric_fd, unsigned u) { - int fd; - - if (eric_fd < 0) - return; if (u == 0) u = ERIC_MAGIC; - fd = open("/dev/null", O_RDONLY); - assert(fd >= 0); - assert(dup2(fd, STDIN_FILENO) == STDIN_FILENO); - AZ(close(fd)); - - fd = open("/dev/null", O_WRONLY); - assert(fd >= 0); - assert(dup2(fd, STDOUT_FILENO) == STDOUT_FILENO); - AZ(close(fd)); - - fd = open("/dev/null", O_WRONLY); - assert(fd >= 0); - assert(dup2(fd, STDERR_FILENO) == STDERR_FILENO); - AZ(close(fd)); + VFIL_null_fd(STDIN_FILENO); + VFIL_null_fd(STDOUT_FILENO); + VFIL_null_fd(STDERR_FILENO); assert(write(eric_fd, &u, sizeof u) == sizeof u); AZ(close(eric_fd)); @@ -951,7 +927,11 @@ main(int argc, char * const *argv) u = MGT_Run(); - mgt_eric_im_done(eric_fd, u); + if (eric_fd >= 0) + mgt_eric_im_done(eric_fd, u); + + if (F_flag) + VFIL_null_fd(STDIN_FILENO); o = vev_schedule(mgt_evb); if (o != 0) diff --git a/bin/varnishtest/vtc_main.c b/bin/varnishtest/vtc_main.c index 1ca41f4..0a2c9ae 100644 --- a/bin/varnishtest/vtc_main.c +++ b/bin/varnishtest/vtc_main.c @@ -282,8 +282,7 @@ start_test(void) jp->child = fork(); assert(jp->child >= 0); if (jp->child == 0) { - AZ(close(STDIN_FILENO)); - assert(open("/dev/null", O_RDONLY) == STDIN_FILENO); + VFIL_null_fd(STDIN_FILENO); assert(dup2(p[1], STDOUT_FILENO) == STDOUT_FILENO); assert(dup2(p[1], STDERR_FILENO) == STDERR_FILENO); VSUB_closefrom(STDERR_FILENO + 1); diff --git a/include/vfil.h b/include/vfil.h index 5d64dcb..48d6f62 100644 --- a/include/vfil.h +++ b/include/vfil.h @@ -31,6 +31,9 @@ struct vfil_path; /* from libvarnish/vfil.c */ + +void VFIL_null_fd(int); + int seed_random(void); char *VFIL_readfile(const char *pfx, const char *fn, ssize_t *sz); int VFIL_writefile(const char *pfx, const char *fn, const char *buf, size_t sz); diff --git a/lib/libvarnish/vfil.c b/lib/libvarnish/vfil.c index 489068e..ac39aff 100644 --- a/lib/libvarnish/vfil.c +++ b/lib/libvarnish/vfil.c @@ -62,6 +62,18 @@ #include "vfil.h" #include "vqueue.h" +void +VFIL_null_fd(int target) +{ + int fd; + + assert(target >= 0); + fd = open("/dev/null", O_RDWR); + assert(fd >= 0); + assert(dup2(fd, target) == target); + AZ(close(fd)); +} + static char * vfil_readfd(int fd, ssize_t *sz) { diff --git a/lib/libvarnish/vsub.c b/lib/libvarnish/vsub.c index 90b1c7c..87384c5 100644 --- a/lib/libvarnish/vsub.c +++ b/lib/libvarnish/vsub.c @@ -42,6 +42,7 @@ #include "vas.h" #include "vdef.h" +#include "vfil.h" #include "vlu.h" #include "vsb.h" #include "vsub.h" @@ -112,8 +113,7 @@ VSUB_run(struct vsb *sb, vsub_func_f *func, void *priv, const char *name, return (1); } if (pid == 0) { - AZ(close(STDIN_FILENO)); - assert(open("/dev/null", O_RDONLY) == STDIN_FILENO); + VFIL_null_fd(STDIN_FILENO); assert(dup2(p[1], STDOUT_FILENO) == STDOUT_FILENO); assert(dup2(p[1], STDERR_FILENO) == STDERR_FILENO); /* Close all other fds */ diff --git a/lib/libvarnishapi/daemon.c b/lib/libvarnishapi/daemon.c index e68b3a1..aba6433 100644 --- a/lib/libvarnishapi/daemon.c +++ b/lib/libvarnishapi/daemon.c @@ -39,6 +39,7 @@ #include #include "compat/daemon.h" +#include "vfil.h" int varnish_daemon(int nochdir, int noclose) @@ -81,12 +82,10 @@ varnish_daemon(int nochdir, int noclose) if (!nochdir) (void)chdir("/"); - if (!noclose && (fd = open("/dev/null", O_RDWR, 0)) != -1) { - (void)dup2(fd, STDIN_FILENO); - (void)dup2(fd, STDOUT_FILENO); - (void)dup2(fd, STDERR_FILENO); - if (fd > 2) - (void)close(fd); + if (!noclose) { + VFIL_null_fd(STDIN_FILENO); + VFIL_null_fd(STDOUT_FILENO); + VFIL_null_fd(STDERR_FILENO); } return (0); } From phk at FreeBSD.org Wed Jan 11 13:23:04 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 11 Jan 2017 14:23:04 +0100 Subject: [master] 1d04346 Make sure we have uintmax_t for vfil.h Message-ID: commit 1d04346a3645a7f7cb0a0fbafa21eb46510ff490 Author: Poul-Henning Kamp Date: Wed Jan 11 13:22:42 2017 +0000 Make sure we have uintmax_t for vfil.h diff --git a/lib/libvarnish/vsub.c b/lib/libvarnish/vsub.c index 87384c5..57b40b8 100644 --- a/lib/libvarnish/vsub.c +++ b/lib/libvarnish/vsub.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include From fgsch at lodoss.net Wed Jan 11 20:04:04 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Wed, 11 Jan 2017 21:04:04 +0100 Subject: [master] c6854d8 No need to test getopt or multiple invalid opts Message-ID: commit c6854d8823be9c7cd50c946b8c0cb92c245257cc Author: Federico G. Schwindt Date: Tue Jan 10 23:19:27 2017 +0000 No need to test getopt or multiple invalid opts diff --git a/bin/varnishtest/tests/a00009.vtc b/bin/varnishtest/tests/a00009.vtc index a6071da..27db34b 100644 --- a/bin/varnishtest/tests/a00009.vtc +++ b/bin/varnishtest/tests/a00009.vtc @@ -23,13 +23,11 @@ err_shell {-C needs either -b or -f } \ "varnishd -C 2>&1" err_shell {-d makes no sense with -C} "varnishd -C -b 127.0.0.1:80 -d 2>&1" err_shell {-F makes no sense with -C} "varnishd -C -b 127.0.0.1:80 -F 2>&1" -err_shell {usage: varnishd [options]} "varnishd -h 2>&1" err_shell {usage: varnishd [options]} "varnishd -? 2>&1" err_shell {Invalid backslash sequence} {varnishd -l 'xyz\kk,xyz\foo' 2>&1} err_shell {Invalid backslash sequence} {varnishd -l 'ab\8cd' 2>&1} err_shell {Copyright (c) 2006} "varnishd -V 2>&1" -err_shell {usage: varnishd [options]} "varnishd --help 2>&1" +err_shell {usage: varnishd [options]} "varnishd -A 2>&1" err_shell {Cannot open -S file} { varnishd -S ${tmpdir}/nonexistent -n ${tmpdir}/v0 2>&1 } - From fgsch at lodoss.net Wed Jan 11 20:04:04 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Wed, 11 Jan 2017 21:04:04 +0100 Subject: [master] f6a1111 More improvements and additions Message-ID: commit f6a1111e03d1ea67fb5fd254d48826e72f06545c Author: Federico G. Schwindt Date: Wed Jan 11 19:56:55 2017 +0000 More improvements and additions diff --git a/bin/varnishtest/tests/u00003.vtc b/bin/varnishtest/tests/u00003.vtc index 14a54c4..1c84887 100644 --- a/bin/varnishtest/tests/u00003.vtc +++ b/bin/varnishtest/tests/u00003.vtc @@ -1,4 +1,4 @@ -varnishtest "varnishncsa -F error handling" +varnishtest "varnishncsa error handling" server s1 { rxreq @@ -7,6 +7,18 @@ server s1 { varnish v1 -vcl+backend {} -start +err_shell "Missing -w option" \ + {varnishncsa -n ${v1_name} -D 2>&1} + +err_shell "Unknown format specifier at: %{foo}A" \ + {varnishncsa -n ${v1_name} -F "%{foo}A" 2>&1} + +err_shell "Unknown format specifier at: %A" \ + {varnishncsa -n ${v1_name} -F "%A" 2>&1} + +err_shell "Usage: varnishncsa " \ + {varnishncsa -n ${v1_name} extra 2>&1} + err_shell "Missing tag in VSL:" \ {varnishncsa -n ${v1_name} -F "%{VSL:}x" 2>&1} diff --git a/bin/varnishtest/tests/u00005.vtc b/bin/varnishtest/tests/u00005.vtc index 4905e09..d6b0dd4 100644 --- a/bin/varnishtest/tests/u00005.vtc +++ b/bin/varnishtest/tests/u00005.vtc @@ -19,7 +19,5 @@ process p5 "exec varnishstat -n ${v1_name} -x" -run shell {grep -q "MAIN" ${tmpdir}/p5/stdout} process p6 "exec varnishstat -n ${v1_name} -j" -run shell {grep -q "MAIN.uptime\":" ${tmpdir}/p6/stdout} -process p7 "exec varnishstat -n ${v1_name} extra" -run -shell {grep -q "Usage: varnishstat " ${tmpdir}/p7/stderr} -process p8 "exec varnishstat -n /nonexistent" -run -shell {grep -q "Cannot open /nonexistent/_.vsm" ${tmpdir}/p8/stderr} +err_shell "Usage: varnishstat " "varnishstat -n ${v1_name} extra 2>&1" +err_shell "Cannot open /nonexistent/_.vsm" "varnishstat -n /nonexistent 2>&1" diff --git a/bin/varnishtest/tests/u00006.vtc b/bin/varnishtest/tests/u00006.vtc index b30bbfd..8f49e75 100644 --- a/bin/varnishtest/tests/u00006.vtc +++ b/bin/varnishtest/tests/u00006.vtc @@ -11,17 +11,19 @@ process p1 "exec varnishlog -n ${v1_name} -g raw -k 1" -start process p2 { exec varnishlog -n ${v1_name} -g raw -k 1 -w ${tmpdir}/p2/output -A } -start -process p3 "exec varnishlog -n ${v1_name} -h" -run -shell {grep -q "Usage: varnishlog " ${tmpdir}/p3/stderr} -process p4 "exec varnishlog -n ${v1_name} -V" -run -shell {grep -q "Copyright (c) 2006 Verdens Gang AS" ${tmpdir}/p4/stderr} -process p5 "exec varnishlog -n ${v1_name} extra" -run -shell {grep -q "Usage: varnishlog " ${tmpdir}/p5/stderr} -process p6 "exec varnishlog -n ${v1_name} -D" -run -shell {grep -q "Missing -w option" ${tmpdir}/p6/stderr} -process p7 "exec varnishlog -n ${v1_name} -L 0" -run -shell {grep -q -- "-L: Range error" ${tmpdir}/p7/stderr} +process p3 { + exec varnishlog -n ${v1_name} -g raw -k 1 -w ${tmpdir}/p3/output.bin +} -start +process p4 "exec varnishlog -n ${v1_name} -h" -run +shell {grep -q "Usage: varnishlog " ${tmpdir}/p4/stderr} +process p5 "exec varnishlog -n ${v1_name} -V" -run +shell {grep -q "Copyright (c) 2006 Verdens Gang AS" ${tmpdir}/p5/stderr} +err_shell "Usage: varnishlog " "varnishlog -n ${v1_name} extra 2>&1" +err_shell "Missing -w option" "varnishlog -n ${v1_name} -D 2>&1" +err_shell "-L: Range error" "varnishlog -n ${v1_name} -L 0 2>&1" process p1 -wait shell {grep -q "0 CLI" ${tmpdir}/p1/stdout} process p2 -wait shell {grep -q "0 CLI" ${tmpdir}/p2/output} +process p3 -wait +shell {varnishlog -g raw -r ${tmpdir}/p3/output.bin | grep -q "0 CLI"} From phk at FreeBSD.org Wed Jan 11 23:24:04 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 12 Jan 2017 00:24:04 +0100 Subject: [master] 12bad7a Add experimental support for gcov (talk to me first!) and some general cleanup and polishing. Message-ID: commit 12bad7a1f6748bb9abb01731c2f5ce7e31bbb8c0 Author: Poul-Henning Kamp Date: Wed Jan 11 23:22:21 2017 +0000 Add experimental support for gcov (talk to me first!) and some general cleanup and polishing. diff --git a/tools/vtest.sh b/tools/vtest.sh index a4e9fa6..b39e819 100755 --- a/tools/vtest.sh +++ b/tools/vtest.sh @@ -33,11 +33,9 @@ set -e export MAKEFLAGS="${MAKEFLAGS:--j2}" -export TMPDIR=`pwd`/tmp -mkdir -p tmp - -# Try to make varnish own it, in case we run as root -chown varnish tmp > /dev/null 2>&1 || true +# This tempdirectory must not be used by anything else. +# Do *NOT* set this to /tmp +export TMPDIR=`pwd`/_vtest_tmp # Message to be shown in result pages # Max 10 char of [A-Za-z0-9/. _-] @@ -49,12 +47,28 @@ WAITGOOD=60 # unit: WAITPERIOD WAITBAD=1 # unit: WAITPERIOD MAXRUNS="${MAXRUNS:-0}" +####################################################################### +# NB: No User Serviceable Parts Beyond This Point +####################################################################### + +enable_gcov=false + SSH_DST="-p 203 vtest at varnish-cache.org" -export SRCDIR=`pwd`/varnish-cache -export BUILDDIR=${BUILDDIR:-${SRCDIR}} +export REPORTDIR=`pwd`/_report +export VTEST_REPORT="${REPORTDIR}/_log" ####################################################################### +# Establish TMPDIR + +mkdir -p ${TMPDIR} +rm -rf ${TMPDIR}/* + +# Try to make varnish own TMPDIR, in case we run as root +chown varnish ${TMPDIR} > /dev/null 2>&1 || true + +####################################################################### +# Establish the SRCDIR we build/run/test if ! (cd varnish-cache 2>/dev/null) ; then git clone \ @@ -62,30 +76,108 @@ if ! (cd varnish-cache 2>/dev/null) ; then varnish-cache fi +export SRCDIR=`pwd`/varnish-cache + +####################################################################### +# Submission of results + if [ ! -f vt_key.pub ] ; then ssh-keygen -t ed25519 -N "" -f vt_key fi +pack () ( + cd ${REPORTDIR} + tar czf - _log \ + `grep '^MANIFEST ' _log | sort -u | sed 's/^MANIFEST *//'` \ +) + +submit () ( + ssh \ + -T \ + -o StrictHostKeyChecking=no \ + -o PasswordAuthentication=no \ + -o NumberOfPasswordPrompts=0 \ + -o RequestTTY=no \ + -i vt_key \ + ${SSH_DST} \ + true \ + < ${1} +) + +rm -f ${TMPDIR}/_report.tgz +touch ${TMPDIR}/_report.tgz + +if ! submit ${TMPDIR}/_report.tgz; then + echo "Test submit failed" + echo + echo "You probably need to email this VTEST specific ssh-key" + echo "to phk at varnish-cache.org" + echo + sed 's/^/ /' vt_key.pub + echo + exit 2 +fi + +####################################################################### + autogen () ( set -e - cd "${BUILDDIR}" + cd "${SRCDIR}" nice make distclean > /dev/null 2>&1 || true nice sh "${SRCDIR}"/autogen.des ) makedistcheck () ( set -e - cd "${BUILDDIR}" + cd "${SRCDIR}" nice make vtest-clean nice make distcheck ) +gcovtest () ( + set -x + if [ `id -u` -eq 0 ] && su -m varnish -c 'true' ; then + su -m varnish -c "make check" || exit 1 + cd bin/varnishtest + ./varnishtest -i tests/[ab]0000?.vtc tests/j*.vtc || exit 1 + else + make check || exit 1 + fi +) + +makegcov () ( + set -x + cd "${SRCDIR}" + + export CFLAGS="-fprofile-arcs -ftest-coverage -fstack-protector -DDONT_DLCLOSE_VMODS" CC=gcc49 + export MAKEFLAGS=-j1 + + find . -name '*.gc??' -print | xargs rm -f + + sh autogen.des || exit 1 + + make || exit 1 + + if [ `id -u` -eq 0 ] ; then + chown -R varnish . | true + fi + + if gcovtest && make gcov_digest ; then + retval=0 + else + retval=1 + fi + + if [ `id -u` -eq 0 ] ; then + chown -R root . || true + fi + exit ${retval} +) + failedtests () ( set -e - REPORTDIR=`pwd`/_report - - cd varnish-cache + cd "${SRCDIR}" VERSION=`./configure --version | awk 'NR == 1 {print $NF}'` LOGDIR=varnish-$VERSION/_build/sub/bin/varnishtest/tests @@ -104,48 +196,20 @@ failedtests () ( done ) -pack () ( - cd _report - tar czf - _log \ - `grep '^MANIFEST ' _log | sort -u | sed 's/^MANIFEST *//'` \ -) - -submit () ( - ssh \ - -T \ - -o StrictHostKeyChecking=no \ - -o PasswordAuthentication=no \ - -o NumberOfPasswordPrompts=0 \ - -o RequestTTY=no \ - -i vt_key \ - ${SSH_DST} \ - true \ - < ${1} -) -rm -f _report.tgz -touch _report.tgz -if ! submit _report.tgz; then - echo "Test submit failed" - echo - echo "You probably need to email this VTEST specific ssh-key" - echo "to phk at varnish-cache.org" - echo - sed 's/^/ /' vt_key.pub - echo - exit 2 -fi orev=000 waitnext=${WAITBAD} i=0 +last_day=`date +%d` + while [ $MAXRUNS -eq 0 ] || [ $i -lt $MAXRUNS ] do i=$((i + 1)) - (cd varnish-cache && git pull > /dev/null 2>&1 || true) - rev=`cd varnish-cache && git show -s --pretty=format:%H` + (cd "${SRCDIR}" && git pull > /dev/null 2>&1 || true) + rev=`cd "${SRCDIR}" && git show -s --pretty=format:%H` if [ "${waitnext}" -gt 0 -a "x${rev}" = "x${orev}" ] ; then sleep ${WAITPERIOD} waitnext=`expr ${waitnext} - 1 || true` @@ -154,44 +218,66 @@ do waitnext=${WAITBAD} orev=${rev} - if ! [ -d "${BUILDDIR}" ] && ! mkdir -p "${BUILDDIR}" ; then - echo >&2 "could not create BUILDDIR ${BUILDDIR}" + if ! [ -d "${SRCDIR}" ] && ! mkdir -p "${SRCDIR}" ; then + echo >&2 "could not create SRCDIR ${SRCDIR}" exit 2 fi - rm -rf _report - mkdir _report - export LOG=_report/_log + rm -rf "${REPORTDIR}" + mkdir "${REPORTDIR}" + + if ! $enable_gcov ; then + do_gcov=false + elif [ -f _force_gcov ] ; then + do_gcov=true + rm -f _force_gcov + elif [ `date +%d` == $last_day ] ; then + do_gcov=false + elif [ `date +%H` -lt 3 ] ; then + do_gcov=false + else + do_gcov=true + fi - echo "VTEST 1.03" > ${LOG} - echo "DATE `date +%s`" >> ${LOG} - echo "BRANCH trunk" >> ${LOG} - echo "HOST `hostname`" >> ${LOG} - echo "UNAME `uname -a`" >> ${LOG} - echo "UGID `id`" >> ${LOG} + echo "VTEST 1.04" > ${VTEST_REPORT} + echo "DATE `date +%s`" >> ${VTEST_REPORT} + echo "BRANCH trunk" >> ${VTEST_REPORT} + echo "HOST `hostname`" >> ${VTEST_REPORT} + echo "UNAME `uname -a`" >> ${VTEST_REPORT} + echo "UGID `id`" >> ${VTEST_REPORT} if [ -x /usr/bin/lsb_release ] ; then - echo "LSB `lsb_release -d`" >> ${LOG} + echo "LSB `lsb_release -d`" >> ${VTEST_REPORT} else - echo "LSB none" >> ${LOG} + echo "LSB none" >> ${VTEST_REPORT} fi - echo "MESSAGE ${MESSAGE}" >> ${LOG} - echo "GITREV $rev" >> ${LOG} - if ! autogen >> _report/_autogen 2>&1 ; then - echo "AUTOGEN BAD" >> ${LOG} - echo "MANIFEST _autogen" >> ${LOG} + echo "MESSAGE ${MESSAGE}" >> ${VTEST_REPORT} + echo "GITREV $rev" >> ${VTEST_REPORT} + if ! autogen >> ${REPORTDIR}/_autogen 2>&1 ; then + echo "AUTOGEN BAD" >> ${VTEST_REPORT} + echo "MANIFEST _autogen" >> ${VTEST_REPORT} else - echo "AUTOGEN GOOD" >> ${LOG} - if ! makedistcheck >> _report/_makedistcheck 2>&1 ; then - echo "MAKEDISTCHECK BAD" >> ${LOG} - echo "MANIFEST _autogen" >> ${LOG} - echo "MANIFEST _makedistcheck" >> ${LOG} - failedtests >> ${LOG} + echo "AUTOGEN GOOD" >> ${VTEST_REPORT} + if $do_gcov ; then + last_day=`date +%d` + if makegcov >> ${REPORTDIR}/_makegcov 2>&1 ; then + mv ${SRCDIR}/_gcov ${REPORTDIR}/ + echo "MAKEGCOV GOOD" >> ${VTEST_REPORT} + echo "MANIFEST _gcov" >> ${VTEST_REPORT} + else + echo "MAKEGCOV BAD" >> ${VTEST_REPORT} + echo "MANIFEST _makegcov" >> ${VTEST_REPORT} + fi + elif ! makedistcheck >> ${REPORTDIR}/_makedistcheck 2>&1 ; then + echo "MAKEDISTCHECK BAD" >> ${VTEST_REPORT} + echo "MANIFEST _autogen" >> ${VTEST_REPORT} + echo "MANIFEST _makedistcheck" >> ${VTEST_REPORT} + failedtests >> ${VTEST_REPORT} else - echo "MAKEDISTCHECK GOOD" >> ${LOG} + echo "MAKEDISTCHECK GOOD" >> ${VTEST_REPORT} waitnext=${WAITGOOD} fi fi - echo "VTEST END" >> ${LOG} - pack > _report.tgz - submit _report.tgz + echo "VTEST END" >> ${VTEST_REPORT} + pack > ${TMPDIR}/_report.tgz + submit ${TMPDIR}/_report.tgz done From fgsch at lodoss.net Thu Jan 12 01:40:05 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Thu, 12 Jan 2017 02:40:05 +0100 Subject: [master] 1836d1f varnishhist coverage Message-ID: commit 1836d1ffb46b0ba16c89cb7221e63eb969d09b88 Author: Federico G. Schwindt Date: Thu Jan 12 01:36:18 2017 +0000 varnishhist coverage diff --git a/bin/varnishtest/tests/u00007.vtc b/bin/varnishtest/tests/u00007.vtc new file mode 100644 index 0000000..150b9a4 --- /dev/null +++ b/bin/varnishtest/tests/u00007.vtc @@ -0,0 +1,25 @@ +varnishtest "varnishhist coverage" + +server s1 { + rxreq + txresp +} -start + +varnish v1 -vcl+backend {} -start + +process p1 "exec varnishhist -n ${v1_name} -h" -run +shell {grep -q "Usage: varnishhist " ${tmpdir}/p1/stderr} +err_shell "Usage: varnishhist " \ + "varnishhist -n ${v1_name} extra 2>&1" +err_shell "-p: invalid '0'" "varnishhist -n ${v1_name} -p 0 2>&1" +err_shell "-B: being able to bend time does not mean we can stop it" \ + "varnishhist -n ${v1_name} -B 0 2>&1" +err_shell "-B: being able to bend time does not mean we can make it go backwards" "varnishhist -n ${v1_name} -B -1 2>&1" +err_shell "Invalid grouping mode: raw" \ + "varnishhist -n ${v1_name} -g raw 2>&1" +err_shell "-P: No such profile 'foo'" \ + "varnishhist -n ${v1_name} -P foo 2>&1" +err_shell "-P: 'foo:bar' is not a valid profile name or definition" \ + "varnishhist -n ${v1_name} -P foo:bar 2>&1" +err_shell "-P: 'foo:0:0:0' is not a valid tag name" \ + "varnishhist -n ${v1_name} -P foo:0:0:0 2>&1" From phk at FreeBSD.org Fri Jan 13 09:15:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 13 Jan 2017 10:15:05 +0100 Subject: [master] 43b8983 Don't print termsig as exitcode Message-ID: commit 43b898354dec4c76398f9a3b6466f68a4000af21 Author: Poul-Henning Kamp Date: Fri Jan 13 09:10:29 2017 +0000 Don't print termsig as exitcode diff --git a/bin/varnishtest/vtc_main.c b/bin/varnishtest/vtc_main.c index 0a2c9ae..b6175e8 100644 --- a/bin/varnishtest/vtc_main.c +++ b/bin/varnishtest/vtc_main.c @@ -216,7 +216,8 @@ tst_cb(const struct vev *ve, int what) jp->tst->filename, t); if (WIFSIGNALED(stx)) printf(" signal=%d", WTERMSIG(stx)); - printf(" exit=%d\n", ecode); + else if (WIFEXITED(stx)) + printf(" exit=%d\n", WEXITSTATUS(stx)); if (!vtc_continue) { /* XXX kill -9 other jobs ? */ exit(2); From phk at FreeBSD.org Fri Jan 13 09:39:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 13 Jan 2017 10:39:05 +0100 Subject: [master] 5d088eb Make it possible to compare STRING_LIST in vcl. Message-ID: commit 5d088ebfad3086403b85daf18d4bf048ad180c9b Author: Poul-Henning Kamp Date: Fri Jan 13 09:37:38 2017 +0000 Make it possible to compare STRING_LIST in vcl. Fixes #2078 diff --git a/bin/varnishtest/tests/v00020.vtc b/bin/varnishtest/tests/v00020.vtc index cb8ea6e..42f0f8e 100644 --- a/bin/varnishtest/tests/v00020.vtc +++ b/bin/varnishtest/tests/v00020.vtc @@ -319,3 +319,22 @@ varnish v1 -errvcl {Comparison of different types: BACKEND '==' STRING} { } } } + +server s1 { + rxreq + txresp -hdr "bar: X" +} -start + +varnish v1 -vcl+backend { + + sub vcl_deliver { + set resp.http.foo = + (resp.http.foo + resp.http.bar) == ("X" + resp.http.foo); + } +} -start + +client c1 { + txreq + rxresp + expect resp.http.foo == "true" +} -run diff --git a/lib/libvcc/vcc_expr.c b/lib/libvcc/vcc_expr.c index 9581cbf..7e92471 100644 --- a/lib/libvcc/vcc_expr.c +++ b/lib/libvcc/vcc_expr.c @@ -1102,6 +1102,8 @@ static const struct cmps { {STRING, T_EQ, "!VRT_strcmp(\v1, \v2)" }, {STRING, T_NEQ, "VRT_strcmp(\v1, \v2)" }, + {STRING_LIST, T_EQ, "!VRT_strcmp(\v1, \v2)" }, + {STRING_LIST, T_NEQ, "VRT_strcmp(\v1, \v2)" }, {VOID, 0, NULL} }; @@ -1133,6 +1135,11 @@ vcc_expr_cmp(struct vcc *tl, struct expr **e, vcc_type_t fmt) break; if (cp->fmt != VOID) { vcc_NextToken(tl); + if ((*e)->fmt == STRING_LIST) { + // XXX: This is not optimal, but we can't pass two + // STRING_LIST's to a function anyway... + vcc_expr_tostring(tl, e, STRING); + } vcc_expr_strfold(tl, &e2, (*e)->fmt); ERRCHK(tl); if (e2->fmt != (*e)->fmt) { /* XXX */ From phk at FreeBSD.org Fri Jan 13 09:46:04 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 13 Jan 2017 10:46:04 +0100 Subject: [master] a538048 Try to close a raise in this test where c1's request didn't get processed until after we switched VCL. Message-ID: commit a5380481e586252eed693be28c01bb502b534352 Author: Poul-Henning Kamp Date: Fri Jan 13 09:44:19 2017 +0000 Try to close a raise in this test where c1's request didn't get processed until after we switched VCL. Fixes #2052 diff --git a/bin/varnishtest/tests/d00012.vtc b/bin/varnishtest/tests/d00012.vtc index 96d4f65..bca1c5b 100644 --- a/bin/varnishtest/tests/d00012.vtc +++ b/bin/varnishtest/tests/d00012.vtc @@ -3,11 +3,13 @@ varnishtest "Test a dynamic backend discard during a request" # vcl.discard testing inspired by v00006.vtc from commit e1f7207 barrier b1 cond 2 +barrier b2 cond 2 server s1 { rxreq expect req.url == "/foo" barrier b1 sync + barrier b2 sync txresp } -start @@ -40,6 +42,8 @@ server s2 { txresp } -start +barrier b1 sync + varnish v1 -vcl { import debug; @@ -55,7 +59,7 @@ varnish v1 -vcl { } varnish v1 -cli "vcl.discard vcl1" -barrier b1 sync +barrier b2 sync client c1 -wait delay 2 From phk at FreeBSD.org Fri Jan 13 09:55:04 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 13 Jan 2017 10:55:04 +0100 Subject: [master] 5b7ec8b Clarify description of fetch_failed counter. Message-ID: commit 5b7ec8b1535fdb78a5af60666af84666498ed0d9 Author: Poul-Henning Kamp Date: Fri Jan 13 09:54:27 2017 +0000 Clarify description of fetch_failed counter. Fixes #1704 diff --git a/include/tbl/vsc_f_main.h b/include/tbl/vsc_f_main.h index 7dbc87d..6d9b369 100644 --- a/include/tbl/vsc_f_main.h +++ b/include/tbl/vsc_f_main.h @@ -199,7 +199,7 @@ VSC_FF(fetch_304, uint64_t, 1, 'c', 'i', info, ) VSC_FF(fetch_failed, uint64_t, 1, 'c', 'i', info, - "Fetch failed (all causes)", + "Fetch failed (all causes), where we do get hold of the backend.", "beresp fetch failed." ) From phk at FreeBSD.org Fri Jan 13 11:36:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 13 Jan 2017 12:36:05 +0100 Subject: [master] ca438c8 Allow INT and REAL to be negative. Message-ID: commit ca438c8ab5ffc4839f59ce586030de8b644aee27 Author: Poul-Henning Kamp Date: Fri Jan 13 11:34:58 2017 +0000 Allow INT and REAL to be negative. Fixes: #2167 diff --git a/bin/varnishtest/tests/m00019.vtc b/bin/varnishtest/tests/m00019.vtc index 825799c..c8251c9 100644 --- a/bin/varnishtest/tests/m00019.vtc +++ b/bin/varnishtest/tests/m00019.vtc @@ -19,9 +19,9 @@ varnish v1 -vcl+backend { sub vcl_deliver { set resp.http.foo1 = debug.argtest("1", 2.1, "3a"); - set resp.http.foo2 = debug.argtest("1", two=2.2, three="3b"); + set resp.http.foo2 = debug.argtest("1", two=-2.2, three="3b"); set resp.http.foo3 = debug.argtest("1", three="3c", two=2.3); - set resp.http.foo4 = debug.argtest("1", 2.4, three="3d"); + set resp.http.foo4 = debug.argtest("1", 2.4, three="3d", four=-1); set resp.http.foo5 = debug.argtest("1", 2.5); set resp.http.foo6 = debug.argtest("1", four=6); @@ -39,9 +39,9 @@ client c1 { rxresp expect resp.bodylen == "6" expect resp.http.foo1 == "1 2.1 3a , 4" - expect resp.http.foo2 == "1 2.2 3b , 4" + expect resp.http.foo2 == "1 -2.2 3b , 4" expect resp.http.foo3 == "1 2.3 3c , 4" - expect resp.http.foo4 == "1 2.4 3d , 4" + expect resp.http.foo4 == "1 2.4 3d , -1" expect resp.http.foo5 == "1 2.5 3 , 4" expect resp.http.foo6 == "1 2 3 , 6" diff --git a/lib/libvcc/vcc_expr.c b/lib/libvcc/vcc_expr.c index 7e92471..ce7ab89 100644 --- a/lib/libvcc/vcc_expr.c +++ b/lib/libvcc/vcc_expr.c @@ -840,7 +840,7 @@ vcc_expr4(struct vcc *tl, struct expr **e, vcc_type_t fmt) e1->constant = EXPR_CONST; vcc_NextToken(tl); *e = e1; - break; + return; case CNUM: /* * XXX: %g may not have enough decimals by default @@ -871,14 +871,31 @@ vcc_expr4(struct vcc *tl, struct expr **e, vcc_type_t fmt) } e1->constant = EXPR_CONST; *e = e1; + return; + case '-': + if (fmt == INT || fmt == REAL) { + vcc_NextToken(tl); + ExpectErr(tl, CNUM); + if (fmt == INT) { + e1 = vcc_mk_expr(INT, "-%.*s", PF(tl->t)); + vcc_NextToken(tl); + } else { + e1 = vcc_mk_expr(REAL, "-%f", + vcc_DoubleVal(tl)); + } + ERRCHK(tl); + e1->constant = EXPR_CONST; + *e = e1; + return; + } break; default: - VSB_printf(tl->sb, "Unknown token "); - vcc_ErrToken(tl, tl->t); - VSB_printf(tl->sb, " when looking for %s\n\n", fmt->name); - vcc_ErrWhere(tl, tl->t); break; } + VSB_printf(tl->sb, "Unknown token "); + vcc_ErrToken(tl, tl->t); + VSB_printf(tl->sb, " when looking for %s\n\n", fmt->name); + vcc_ErrWhere(tl, tl->t); } /*-------------------------------------------------------------------- From phk at FreeBSD.org Fri Jan 13 12:29:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 13 Jan 2017 13:29:05 +0100 Subject: [master] a82df92 Move some auxillary stuff out of mgt_main and clean up namespace a bit. Message-ID: commit a82df925b61a5c6c5e7e41f75d4229647fa0577b Author: Poul-Henning Kamp Date: Fri Jan 13 12:27:33 2017 +0000 Move some auxillary stuff out of mgt_main and clean up namespace a bit. diff --git a/bin/varnishd/Makefile.am b/bin/varnishd/Makefile.am index 9203a50..b812cc7 100644 --- a/bin/varnishd/Makefile.am +++ b/bin/varnishd/Makefile.am @@ -86,6 +86,7 @@ varnishd_SOURCES = \ mgt/mgt_param_tweak.c \ mgt/mgt_pool.c \ mgt/mgt_shmem.c \ + mgt/mgt_util.c \ mgt/mgt_vcc.c \ mgt/mgt_vcl.c \ proxy/cache_proxy_proto.c \ diff --git a/bin/varnishd/hash/mgt_hash.c b/bin/varnishd/hash/mgt_hash.c index a8cc352..6e772b2 100644 --- a/bin/varnishd/hash/mgt_hash.c +++ b/bin/varnishd/hash/mgt_hash.c @@ -71,7 +71,7 @@ HSH_config(const char *h_arg) for (ac = 0; av[ac + 2] != NULL; ac++) continue; - hp = pick(hsh_choice, av[1], "hash"); + hp = MGT_Pick(hsh_choice, av[1], "hash"); CHECK_OBJ_NOTNULL(hp, SLINGER_MAGIC); VSB_printf(vident, ",-h%s", av[1]); heritage.hash = hp; diff --git a/bin/varnishd/mgt/mgt.h b/bin/varnishd/mgt/mgt.h index 7f7f17f..dc69bc0 100644 --- a/bin/varnishd/mgt/mgt.h +++ b/bin/varnishd/mgt/mgt.h @@ -126,14 +126,12 @@ struct choice { const char *name; const void *ptr; }; -const void *pick(const struct choice *cp, const char *which, const char *kind); extern const char C_ERR[]; // Things are not as they should be extern const char C_INFO[]; // Normal stuff, keep a record for later extern const char C_DEBUG[]; // More detail than you'd normally want extern const char C_SECURITY[]; // Security issues extern const char C_CLI[]; // CLI traffic between master and child -void MGT_complain(const char *loud, const char *, ...) __v_printflike(2, 3); /* mgt_param.c */ void MCF_InitParams(struct cli *); @@ -152,9 +150,6 @@ void MCF_DumpRstParam(void); void MCF_AddParams(struct parspec *ps); extern struct params mgt_param; -/* mgt_param_tcp.c */ -void MCF_TcpParams(void); - /* mgt_shmem.c */ void mgt_SHM_Init(void); void mgt_SHM_static_alloc(const void *, ssize_t size, @@ -164,6 +159,15 @@ int mgt_SHM_Commit(void); void mgt_SHM_Destroy(int keep); void mgt_SHM_Size_Adjust(void); +/* mgt_param_tcp.c */ +void MCF_TcpParams(void); + +/* mgt_util.c */ +void mgt_DumpRstVsl(void); +struct vsb *mgt_BuildVident(void); +void MGT_Complain(const char *, const char *, ...) __v_printflike(2, 3); +const void *MGT_Pick(const struct choice *, const char *, const char *); +void mgt_SymbolHack(const char *); /* stevedore_mgt.c */ void STV_Config(const char *spec); diff --git a/bin/varnishd/mgt/mgt_acceptor.c b/bin/varnishd/mgt/mgt_acceptor.c index 14ce0e6..ae82607 100644 --- a/bin/varnishd/mgt/mgt_acceptor.c +++ b/bin/varnishd/mgt/mgt_acceptor.c @@ -89,7 +89,7 @@ MAC_reopen_sockets(struct cli *cli) if (fail == 0) continue; if (cli == NULL) - MGT_complain(C_ERR, + MGT_Complain(C_ERR, "Could not reopen listen socket %s: %s", ls->name, strerror(fail)); else diff --git a/bin/varnishd/mgt/mgt_child.c b/bin/varnishd/mgt/mgt_child.c index 988643a..d1c4f2f 100644 --- a/bin/varnishd/mgt/mgt_child.c +++ b/bin/varnishd/mgt/mgt_child.c @@ -119,7 +119,7 @@ mgt_panic_record(pid_t r) strnlen(heritage.panic_str, heritage.panic_str_len), VSB_QUOTE_NONL); AZ(VSB_finish(child_panic)); - MGT_complain(C_ERR, "Child (%jd) %s", + MGT_Complain(C_ERR, "Child (%jd) %s", (intmax_t)r, VSB_data(child_panic)); } @@ -222,7 +222,7 @@ child_line(void *priv, const char *p) { (void)priv; - MGT_complain(C_INFO, "Child (%jd) said %s", (intmax_t)child_pid, p); + MGT_Complain(C_INFO, "Child (%jd) said %s", (intmax_t)child_pid, p); return (0); } @@ -260,7 +260,7 @@ child_poker(const struct vev *e, int what) if (child_pid < 0) return (0); if (mgt_cli_askchild(&status, &r, "ping\n") || strncmp("PONG ", r, 5)) { - MGT_complain(C_ERR, "Unexpected reply from ping: %u %s", + MGT_Complain(C_ERR, "Unexpected reply from ping: %u %s", status, r); if (status != CLIS_COMMS) MGT_Child_Cli_Fail(); @@ -391,7 +391,7 @@ mgt_launch_child(struct cli *cli) exit(0); } assert(pid > 1); - MGT_complain(C_DEBUG, "Child (%jd) Started", (intmax_t)pid); + MGT_Complain(C_DEBUG, "Child (%jd) Started", (intmax_t)pid); VSC_C_mgt->child_start = ++static_VSC_C_mgt.child_start; /* Close stuff the child got */ @@ -430,7 +430,7 @@ mgt_launch_child(struct cli *cli) child_pid = pid; if (mgt_push_vcls_and_start(cli, &u, &p)) { VCLI_SetResult(cli, u); - MGT_complain(C_ERR, "Child (%jd) Pushing vcls failed:\n%s", + MGT_Complain(C_ERR, "Child (%jd) Pushing vcls failed:\n%s", (intmax_t)child_pid, p); free(p); child_state = CH_RUNNING; @@ -540,7 +540,7 @@ mgt_reap_child(void) } #endif AZ(VSB_finish(vsb)); - MGT_complain(status ? C_ERR : C_INFO, "%s", VSB_data(vsb)); + MGT_Complain(status ? C_ERR : C_INFO, "%s", VSB_data(vsb)); VSB_destroy(&vsb); /* Dispose of shared memory but evacuate panic messages first */ @@ -564,7 +564,7 @@ mgt_reap_child(void) child_pid = -1; - MGT_complain(C_DEBUG, "Child cleanup complete"); + MGT_Complain(C_DEBUG, "Child cleanup complete"); if (child_state == CH_DIED && mgt_param.auto_restart) mgt_launch_child(NULL); @@ -593,10 +593,10 @@ MGT_Child_Cli_Fail(void) if (child_pid < 0) return; if (kill_child() == 0) - MGT_complain(C_ERR, "Child (%jd) not responding to CLI," + MGT_Complain(C_ERR, "Child (%jd) not responding to CLI," " killed it.", (intmax_t)child_pid); else - MGT_complain(C_ERR, "Failed to kill child with PID %jd: %s", + MGT_Complain(C_ERR, "Failed to kill child with PID %jd: %s", (intmax_t)child_pid, strerror(errno)); } @@ -615,7 +615,7 @@ mgt_stop_child(void) child_state = CH_STOPPING; - MGT_complain(C_DEBUG, "Stopping Child"); + MGT_Complain(C_DEBUG, "Stopping Child"); mgt_reap_child(); } @@ -675,7 +675,7 @@ mgt_sigint(const struct vev *e, int what) (void)e; (void)what; - MGT_complain(C_ERR, "Manager got SIGINT"); + MGT_Complain(C_ERR, "Manager got SIGINT"); (void)fflush(stdout); if (child_pid >= 0) mgt_stop_child(); @@ -758,7 +758,7 @@ MGT_Run(void) AZ(sigaction(SIGHUP, &sac, NULL)); if (!d_flag && !mgt_has_vcl()) - MGT_complain(C_ERR, "No VCL loaded yet"); + MGT_Complain(C_ERR, "No VCL loaded yet"); else if (!d_flag) { mgt_launch_child(NULL); if (child_state != CH_RUNNING) @@ -767,7 +767,7 @@ MGT_Run(void) i = mgt_SHM_Commit(); if (i != 0) { - MGT_complain(C_ERR, "Could not commit SHM file"); + MGT_Complain(C_ERR, "Could not commit SHM file"); return (2); } diff --git a/bin/varnishd/mgt/mgt_cli.c b/bin/varnishd/mgt/mgt_cli.c index 79f4b90..6e6cc9a 100644 --- a/bin/varnishd/mgt/mgt_cli.c +++ b/bin/varnishd/mgt/mgt_cli.c @@ -285,7 +285,7 @@ mcf_auth(struct cli *cli, const char *const *av, void *priv) VCLI_AuthResponse(fd, cli->challenge, buf); AZ(close(fd)); if (strcasecmp(buf, av[2])) { - MGT_complain(C_SECURITY, + MGT_Complain(C_SECURITY, "CLI Authentication failure from %s", cli->ident); VCLI_SetResult(cli, CLIS_CLOSE); return; @@ -330,14 +330,14 @@ static void mgt_cli_cb_before(const struct cli *cli) { - MGT_complain(C_CLI, "CLI %s Rd %s", cli->ident, cli->cmd); + MGT_Complain(C_CLI, "CLI %s Rd %s", cli->ident, cli->cmd); } static void mgt_cli_cb_after(const struct cli *cli) { - MGT_complain(C_CLI, "CLI %s Wr %03u %s", + MGT_Complain(C_CLI, "CLI %s Wr %03u %s", cli->ident, cli->result, VSB_data(cli->sb)); } @@ -610,7 +610,7 @@ Marg_connect(const struct vev *e, int what) M_fd = VTCP_connected(M_fd); if (M_fd < 0) { - MGT_complain(C_INFO, "Could not connect to CLI-master: %m"); + MGT_Complain(C_INFO, "Could not connect to CLI-master: %m"); ma = VTAILQ_FIRST(&m_addr_list); AN(ma); VTAILQ_REMOVE(&m_addr_list, ma, list); diff --git a/bin/varnishd/mgt/mgt_jail.c b/bin/varnishd/mgt/mgt_jail.c index b0cd91d..a88a499 100644 --- a/bin/varnishd/mgt/mgt_jail.c +++ b/bin/varnishd/mgt/mgt_jail.c @@ -100,7 +100,7 @@ VJ_Init(const char *j_arg) ARGV_ERR("-j argument: %s\n", av[0]); if (av[1] == NULL) ARGV_ERR("-j argument is emtpy\n"); - vjt = pick(vj_choice, av[1], "jail"); + vjt = MGT_Pick(vj_choice, av[1], "jail"); CHECK_OBJ_NOTNULL(vjt, JAIL_TECH_MAGIC); (void)vjt->init(av + 2); VAV_Free(av); @@ -173,7 +173,7 @@ VJ_make_vcldir(const char *dname) return (vjt->make_vcldir(dname)); if (mkdir(dname, 0755) < 0 && errno != EEXIST) { - MGT_complain(C_ERR, "Cannot create VCL directory '%s': %s", + MGT_Complain(C_ERR, "Cannot create VCL directory '%s': %s", dname, strerror(errno)); return (1); } diff --git a/bin/varnishd/mgt/mgt_jail_solaris.c b/bin/varnishd/mgt/mgt_jail_solaris.c index a9a624e..1ab519e 100644 --- a/bin/varnishd/mgt/mgt_jail_solaris.c +++ b/bin/varnishd/mgt/mgt_jail_solaris.c @@ -392,7 +392,7 @@ vjs_setup(enum jail_gen_e jge) priv_set_t *priv_all; if (! (priv_all = priv_allocset())) { - MGT_complain(C_SECURITY, + MGT_Complain(C_SECURITY, "Solaris Jail warning: " " vjs_setup - priv_allocset failed: errno=%d (%s)", errno, strerror(errno)); @@ -425,7 +425,7 @@ vjs_privsep(enum jail_gen_e jge) if (getuid() != mgt_param.uid) XXXAZ(setuid(mgt_param.uid)); } else { - MGT_complain(C_SECURITY, + MGT_Complain(C_SECURITY, "Privilege %s missing, will not change uid/gid", PRIV_PROC_SETID); } @@ -456,7 +456,7 @@ vjs_waive(enum jail_gen_e jge) !(inheritable = priv_allocset()) || !(permitted = priv_allocset()) || !(limited = priv_allocset())) { - MGT_complain(C_SECURITY, + MGT_Complain(C_SECURITY, "Solaris Jail warning: " " vjs_waive - priv_allocset failed: errno=%d (%s)", errno, strerror(errno)); diff --git a/bin/varnishd/mgt/mgt_jail_unix.c b/bin/varnishd/mgt/mgt_jail_unix.c index a28cdc8..838b977 100644 --- a/bin/varnishd/mgt/mgt_jail_unix.c +++ b/bin/varnishd/mgt/mgt_jail_unix.c @@ -230,7 +230,7 @@ vju_subproc(enum jail_subproc_e jse) * reenable them again. */ if (prctl(PR_SET_DUMPABLE, 1) != 0) { - MGT_complain(C_INFO, + MGT_Complain(C_INFO, "Could not set dumpable bit. Core dumps turned off"); } #endif @@ -242,7 +242,7 @@ vju_make_vcldir(const char *dname) AZ(seteuid(0)); if (mkdir(dname, 0755) < 0 && errno != EEXIST) { - MGT_complain(C_ERR, "Cannot create VCL directory '%s': %s", + MGT_Complain(C_ERR, "Cannot create VCL directory '%s': %s", dname, strerror(errno)); return (1); } diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index dce1dba..ea884d8 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -76,117 +76,6 @@ int optreset; // Some has it, some doesn't. Cheaper than auto* /*--------------------------------------------------------------------*/ static void -mgt_sltm(const char *tag, const char *sdesc, const char *ldesc) -{ - int i; - - assert(sdesc != NULL && ldesc != NULL); - assert(*sdesc != '\0' || *ldesc != '\0'); - printf("\n%s\n", tag); - i = strlen(tag); - printf("%*.*s\n\n", i, i, "------------------------------------"); - if (*ldesc != '\0') - printf("%s\n", ldesc); - else if (*sdesc != '\0') - printf("%s\n", sdesc); -} - -/*lint -e{506} constant value boolean */ -static void -mgt_DumpRstVsl(void) -{ - - printf( - "\n.. The following is autogenerated output from " - "varnishd -x dumprstvsl\n\n"); - -#define SLTM(tag, flags, sdesc, ldesc) mgt_sltm(#tag, sdesc, ldesc); -#include "tbl/vsl_tags.h" -} - -/*--------------------------------------------------------------------*/ - -static void -build_vident(void) -{ - struct utsname uts; - - vident = VSB_new_auto(); - AN(vident); - if (!uname(&uts)) { - VSB_printf(vident, ",%s", uts.sysname); - VSB_printf(vident, ",%s", uts.release); - VSB_printf(vident, ",%s", uts.machine); - } -} - -/*-------------------------------------------------------------------- - * 'Ello, I wish to register a complaint... - */ - -#ifndef LOG_AUTHPRIV -# define LOG_AUTHPRIV 0 -#endif - -const char C_ERR[] = "Error:"; -const char C_INFO[] = "Info:"; -const char C_DEBUG[] = "Debug:"; -const char C_SECURITY[] = "Security:"; -const char C_CLI[] = "Cli:"; - -void -MGT_complain(const char *loud, const char *fmt, ...) -{ - va_list ap; - struct vsb *vsb; - int sf; - - if (loud == C_CLI && !mgt_param.syslog_cli_traffic) - return; - vsb = VSB_new_auto(); - AN(vsb); - va_start(ap, fmt); - VSB_vprintf(vsb, fmt, ap); - va_end(ap); - AZ(VSB_finish(vsb)); - - if (loud == C_ERR) - sf = LOG_ERR; - else if (loud == C_INFO) - sf = LOG_INFO; - else if (loud == C_DEBUG) - sf = LOG_DEBUG; - else if (loud == C_SECURITY) - sf = LOG_WARNING | LOG_AUTHPRIV; - else if (loud == C_CLI) - sf = LOG_INFO; - else - WRONG("Wrong complaint loudness"); - - if (loud != C_CLI) - fprintf(stderr, "%s %s\n", loud, VSB_data(vsb)); - - if (!MGT_DO_DEBUG(DBG_VTC_MODE)) - syslog(sf, "%s", VSB_data(vsb)); - VSB_destroy(&vsb); -} - -/*--------------------------------------------------------------------*/ - -const void * -pick(const struct choice *cp, const char *which, const char *kind) -{ - - for(; cp->name != NULL; cp++) { - if (!strcmp(cp->name, which)) - return (cp->ptr); - } - ARGV_ERR("Unknown %s method \"%s\"\n", kind, which); -} - -/*--------------------------------------------------------------------*/ - -static void usage(void) { #define FMT " %-28s # %s\n" @@ -275,83 +164,11 @@ cli_check(const struct cli *cli) } /*-------------------------------------------------------------------- - * All praise POSIX! Thanks to our glorious standards there are no - * standard way to get a back-trace of the stack, and even if we hack - * that together from spit and pieces of string, there is no way no - * standard way to translate a pointer to a symbol, which returns anything - * usable. (See for instance FreeBSD PR-134391). - * - * Attempt to run nm(1) on our binary during startup, hoping it will - * give us a usable list of symbols. - */ - -struct symbols { - uintptr_t a; - uintptr_t l; - char *n; - VTAILQ_ENTRY(symbols) list; -}; - -static VTAILQ_HEAD(,symbols) symbols = VTAILQ_HEAD_INITIALIZER(symbols); - -int -Symbol_Lookup(struct vsb *vsb, void *ptr) -{ - struct symbols *s, *s0; - uintptr_t pp; - - pp = (uintptr_t)ptr; - s0 = NULL; - VTAILQ_FOREACH(s, &symbols, list) { - if (s->a > pp || s->a + s->l <= pp) - continue; - if (s0 == NULL || s->l < s0->l) - s0 = s; - } - if (s0 == NULL) - return (-1); - VSB_printf(vsb, "%p: %s", ptr, s0->n); - if ((uintmax_t)pp != s0->a) - VSB_printf(vsb, "+0x%jx", (uintmax_t)pp - s0->a); - return (0); -} - -static void -Symbol_hack(const char *a0) -{ - char buf[BUFSIZ]; - FILE *fi; - struct symbols *s; - uintmax_t aa, ll; - char type[10]; - char name[100]; - int i; - - bprintf(buf, "nm -t x -n -P %s 2>/dev/null", a0); - fi = popen(buf, "r"); - if (fi == NULL) - return; - while (fgets(buf, sizeof buf, fi)) { - i = sscanf(buf, "%99s\t%9s\t%jx\t%jx\n", name, type, &aa, &ll); - if (i != 4) - continue; - s = malloc(sizeof *s + strlen(name) + 1); - AN(s); - s->a = aa; - s->l = ll; - s->n = (void*)(s + 1); - strcpy(s->n, name); - VTAILQ_INSERT_TAIL(&symbols, s, list); - } - (void)pclose(fi); -} - -/*-------------------------------------------------------------------- * This function is called when the CLI on stdin is closed. */ static void -cli_stdin_close(void *priv) +mgt_stdin_close(void *priv) { (void)priv; @@ -698,9 +515,9 @@ main(int argc, char * const *argv) VRND_SeedAll(); - build_vident(); + vident = mgt_BuildVident(); - Symbol_hack(argv[0]); + mgt_SymbolHack(argv[0]); /* Various initializations */ VTAILQ_INIT(&heritage.socks); @@ -909,10 +726,10 @@ main(int argc, char * const *argv) assert(pfh == NULL || !VPF_Write(pfh)); - MGT_complain(C_DEBUG, "Platform: %s", VSB_data(vident) + 1); + MGT_Complain(C_DEBUG, "Platform: %s", VSB_data(vident) + 1); if (d_flag) - mgt_cli_setup(0, 1, 1, "debug", cli_stdin_close, NULL); + mgt_cli_setup(0, 1, 1, "debug", mgt_stdin_close, NULL); if (strcmp(S_arg, "none")) mgt_cli_secret(S_arg); @@ -935,9 +752,9 @@ main(int argc, char * const *argv) o = vev_schedule(mgt_evb); if (o != 0) - MGT_complain(C_ERR, "vev_schedule() = %d", o); + MGT_Complain(C_ERR, "vev_schedule() = %d", o); - MGT_complain(C_INFO, "manager dies"); + MGT_Complain(C_INFO, "manager dies"); if (pfh != NULL) (void)VPF_Remove(pfh); exit(exit_status); diff --git a/bin/varnishd/mgt/mgt_shmem.c b/bin/varnishd/mgt/mgt_shmem.c index a131533..49a8753 100644 --- a/bin/varnishd/mgt/mgt_shmem.c +++ b/bin/varnishd/mgt/mgt_shmem.c @@ -151,7 +151,7 @@ vsm_zerofile(const char *fn, ssize_t size) fd = VFL_Open(fn, O_RDWR | O_CREAT | O_EXCL | O_NONBLOCK, 0640); if (fd < 0) { - MGT_complain(C_ERR, "Could not create %s: %s", + MGT_Complain(C_ERR, "Could not create %s: %s", fn, strerror(errno)); return (-1); } @@ -161,7 +161,7 @@ vsm_zerofile(const char *fn, ssize_t size) flags &= ~O_NONBLOCK; AZ(fcntl(fd, F_SETFL, flags)); if (VFIL_allocate(fd, (off_t)size, 1)) { - MGT_complain(C_ERR, "File allocation error %s: %s", + MGT_Complain(C_ERR, "File allocation error %s: %s", fn, strerror(errno)); return (-1); } @@ -223,7 +223,7 @@ mgt_SHM_Create(void) AZ(close(vsm_fd)); if (p == MAP_FAILED) { - MGT_complain(C_ERR, "Mmap error %s: %s", + MGT_Complain(C_ERR, "Mmap error %s: %s", fnbuf, strerror(errno)); mgt_shm_cleanup(); exit(1); @@ -274,7 +274,7 @@ mgt_SHM_Commit(void) bprintf(fnbuf, "%s.%jd", VSM_FILENAME, (intmax_t)getpid()); VJ_master(JAIL_MASTER_FILE); if (rename(fnbuf, VSM_FILENAME)) { - MGT_complain(C_ERR, "Rename failed %s -> %s: %s", + MGT_Complain(C_ERR, "Rename failed %s -> %s: %s", fnbuf, VSM_FILENAME, strerror(errno)); (void)unlink(fnbuf); retval = -1; diff --git a/bin/varnishd/mgt/mgt_util.c b/bin/varnishd/mgt/mgt_util.c new file mode 100644 index 0000000..8d2b0ee --- /dev/null +++ b/bin/varnishd/mgt/mgt_util.c @@ -0,0 +1,233 @@ +/*- + * Copyright (c) 2006 Verdens Gang AS + * Copyright (c) 2006-2011 Varnish Software AS + * All rights reserved. + * + * Author: Poul-Henning Kamp + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * The management process and CLI handling + */ + +#include "config.h" + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "mgt/mgt.h" + + +/*--------------------------------------------------------------------*/ + +static void +mgt_sltm(const char *tag, const char *sdesc, const char *ldesc) +{ + int i; + + assert(sdesc != NULL && ldesc != NULL); + assert(*sdesc != '\0' || *ldesc != '\0'); + printf("\n%s\n", tag); + i = strlen(tag); + printf("%*.*s\n\n", i, i, "------------------------------------"); + if (*ldesc != '\0') + printf("%s\n", ldesc); + else if (*sdesc != '\0') + printf("%s\n", sdesc); +} + +/*lint -e{506} constant value boolean */ +void +mgt_DumpRstVsl(void) +{ + + printf( + "\n.. The following is autogenerated output from " + "varnishd -x dumprstvsl\n\n"); + +#define SLTM(tag, flags, sdesc, ldesc) mgt_sltm(#tag, sdesc, ldesc); +#include "tbl/vsl_tags.h" +} + +/*--------------------------------------------------------------------*/ + +struct vsb * +mgt_BuildVident(void) +{ + struct utsname uts; + struct vsb *vsb; + + vsb = VSB_new_auto(); + AN(vsb); + if (!uname(&uts)) { + VSB_printf(vsb, ",%s", uts.sysname); + VSB_printf(vsb, ",%s", uts.release); + VSB_printf(vsb, ",%s", uts.machine); + } + return (vsb); +} + +/*-------------------------------------------------------------------- + * 'Ello, I wish to register a complaint... + */ + +#ifndef LOG_AUTHPRIV +# define LOG_AUTHPRIV 0 +#endif + +const char C_ERR[] = "Error:"; +const char C_INFO[] = "Info:"; +const char C_DEBUG[] = "Debug:"; +const char C_SECURITY[] = "Security:"; +const char C_CLI[] = "Cli:"; + +void +MGT_Complain(const char *loud, const char *fmt, ...) +{ + va_list ap; + struct vsb *vsb; + int sf; + + if (loud == C_CLI && !mgt_param.syslog_cli_traffic) + return; + vsb = VSB_new_auto(); + AN(vsb); + va_start(ap, fmt); + VSB_vprintf(vsb, fmt, ap); + va_end(ap); + AZ(VSB_finish(vsb)); + + if (loud == C_ERR) + sf = LOG_ERR; + else if (loud == C_INFO) + sf = LOG_INFO; + else if (loud == C_DEBUG) + sf = LOG_DEBUG; + else if (loud == C_SECURITY) + sf = LOG_WARNING | LOG_AUTHPRIV; + else if (loud == C_CLI) + sf = LOG_INFO; + else + WRONG("Wrong complaint loudness"); + + if (loud != C_CLI) + fprintf(stderr, "%s %s\n", loud, VSB_data(vsb)); + + if (!MGT_DO_DEBUG(DBG_VTC_MODE)) + syslog(sf, "%s", VSB_data(vsb)); + VSB_destroy(&vsb); +} + +/*--------------------------------------------------------------------*/ + +const void * +MGT_Pick(const struct choice *cp, const char *which, const char *kind) +{ + + for(; cp->name != NULL; cp++) { + if (!strcmp(cp->name, which)) + return (cp->ptr); + } + ARGV_ERR("Unknown %s method \"%s\"\n", kind, which); +} + +/*-------------------------------------------------------------------- + * All praise POSIX! Thanks to our glorious standards there are no + * standard way to get a back-trace of the stack, and even if we hack + * that together from spit and pieces of string, there is no way no + * standard way to translate a pointer to a symbol, which returns anything + * usable. (See for instance FreeBSD PR-134391). + * + * Attempt to run nm(1) on our binary during startup, hoping it will + * give us a usable list of symbols. + */ + +struct symbols { + uintptr_t a; + uintptr_t l; + char *n; + VTAILQ_ENTRY(symbols) list; +}; + +static VTAILQ_HEAD(,symbols) symbols = VTAILQ_HEAD_INITIALIZER(symbols); + +int +Symbol_Lookup(struct vsb *vsb, void *ptr) +{ + struct symbols *s, *s0; + uintptr_t pp; + + pp = (uintptr_t)ptr; + s0 = NULL; + VTAILQ_FOREACH(s, &symbols, list) { + if (s->a > pp || s->a + s->l <= pp) + continue; + if (s0 == NULL || s->l < s0->l) + s0 = s; + } + if (s0 == NULL) + return (-1); + VSB_printf(vsb, "%p: %s", ptr, s0->n); + if ((uintmax_t)pp != s0->a) + VSB_printf(vsb, "+0x%jx", (uintmax_t)pp - s0->a); + return (0); +} + +void +mgt_SymbolHack(const char *a0) +{ + char buf[BUFSIZ]; + FILE *fi; + struct symbols *s; + uintmax_t aa, ll; + char type[10]; + char name[100]; + int i; + + bprintf(buf, "nm -t x -n -P %s 2>/dev/null", a0); + fi = popen(buf, "r"); + if (fi == NULL) + return; + while (fgets(buf, sizeof buf, fi)) { + i = sscanf(buf, "%99s\t%9s\t%jx\t%jx\n", name, type, &aa, &ll); + if (i != 4) + continue; + s = malloc(sizeof *s + strlen(name) + 1); + AN(s); + s->a = aa; + s->l = ll; + s->n = (void*)(s + 1); + strcpy(s->n, name); + VTAILQ_INSERT_TAIL(&symbols, s, list); + } + (void)pclose(fi); +} diff --git a/bin/varnishd/storage/mgt_stevedore.c b/bin/varnishd/storage/mgt_stevedore.c index e41933e..c0cb743 100644 --- a/bin/varnishd/storage/mgt_stevedore.c +++ b/bin/varnishd/storage/mgt_stevedore.c @@ -162,7 +162,7 @@ STV_Config(const char *spec) for (ac = 0; av[ac + 2] != NULL; ac++) continue; - stv2 = pick(STV_choice, av[1], "storage"); + stv2 = MGT_Pick(STV_choice, av[1], "storage"); AN(stv2); /* Append strategy to ident string */ diff --git a/bin/varnishd/waiter/mgt_waiter.c b/bin/varnishd/waiter/mgt_waiter.c index 58d4307..7b8530f 100644 --- a/bin/varnishd/waiter/mgt_waiter.c +++ b/bin/varnishd/waiter/mgt_waiter.c @@ -59,7 +59,7 @@ Wait_config(const char *arg) ASSERT_MGT(); if (arg != NULL) - waiter = pick(waiter_choice, arg, "waiter"); + waiter = MGT_Pick(waiter_choice, arg, "waiter"); else waiter = waiter_choice[0].ptr; } From dridi.boukelmoune at gmail.com Sat Jan 14 15:02:05 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Sat, 14 Jan 2017 16:02:05 +0100 Subject: [master] 2e15bf8 Polish Message-ID: commit 2e15bf81cc42b0ca73cec3eb94cc1f2f22668050 Author: Dridi Boukelmoune Date: Sat Jan 14 16:00:53 2017 +0100 Polish diff --git a/bin/varnishtest/vtc_main.c b/bin/varnishtest/vtc_main.c index b6175e8..e3ecd0a 100644 --- a/bin/varnishtest/vtc_main.c +++ b/bin/varnishtest/vtc_main.c @@ -215,7 +215,7 @@ tst_cb(const struct vev *ve, int what) printf("# top TEST %s FAILED (%.3f)", jp->tst->filename, t); if (WIFSIGNALED(stx)) - printf(" signal=%d", WTERMSIG(stx)); + printf(" signal=%d\n", WTERMSIG(stx)); else if (WIFEXITED(stx)) printf(" exit=%d\n", WEXITSTATUS(stx)); if (!vtc_continue) { From phk at FreeBSD.org Sat Jan 14 17:54:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Sat, 14 Jan 2017 18:54:05 +0100 Subject: [master] 4f94d57 Periodic #include untangling/cleanup Message-ID: commit 4f94d576b546a4783480b152c909aacbb5532ffd Author: Poul-Henning Kamp Date: Sat Jan 14 17:53:03 2017 +0000 Periodic #include untangling/cleanup diff --git a/bin/varnishd/common/com_params.h b/bin/varnishd/common/com_params.h index 269f188..a1ddd69 100644 --- a/bin/varnishd/common/com_params.h +++ b/bin/varnishd/common/com_params.h @@ -34,8 +34,6 @@ #endif #define COMMON_PARAMS_H -#include - #include "vre.h" #define VSM_CLASS_PARAM "Params" diff --git a/bin/varnishd/common/common.h b/bin/varnishd/common/common.h index afdeafd..82305e4 100644 --- a/bin/varnishd/common/common.h +++ b/bin/varnishd/common/common.h @@ -28,6 +28,11 @@ * */ +#ifdef COMMON_COMMON_H +#error "Multiple includes of common/common.h" +#endif +#define COMMON_COMMON_H + #include #include diff --git a/bin/varnishd/common/common_vsm.c b/bin/varnishd/common/common_vsm.c index 9a09e07..e91ef24 100644 --- a/bin/varnishd/common/common_vsm.c +++ b/bin/varnishd/common/common_vsm.c @@ -34,7 +34,6 @@ #include "config.h" -#include #include #include #include diff --git a/bin/varnishd/http2/cache_http2_deliver.c b/bin/varnishd/http2/cache_http2_deliver.c index fc0c56e..db94d1d 100644 --- a/bin/varnishd/http2/cache_http2_deliver.c +++ b/bin/varnishd/http2/cache_http2_deliver.c @@ -34,9 +34,7 @@ #include #include -#include #include -#include #include "cache/cache_filter.h" #include "cache/cache_transport.h" diff --git a/bin/varnishd/http2/cache_http2_panic.c b/bin/varnishd/http2/cache_http2_panic.c index 6fe519b..6506436 100644 --- a/bin/varnishd/http2/cache_http2_panic.c +++ b/bin/varnishd/http2/cache_http2_panic.c @@ -31,14 +31,6 @@ #include "cache/cache.h" -#include - -#include -#include -#include -#include - -#include "cache/cache_filter.h" #include "cache/cache_transport.h" #include "http2/cache_http2.h" diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index 0f03e15..7e9ab9e 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -31,14 +31,8 @@ #include "cache/cache.h" -#include - -#include -#include #include -#include -#include "cache/cache_filter.h" #include "cache/cache_transport.h" #include "http2/cache_http2.h" diff --git a/bin/varnishd/http2/cache_http2_send.c b/bin/varnishd/http2/cache_http2_send.c index 257d518..f6f9587 100644 --- a/bin/varnishd/http2/cache_http2_send.c +++ b/bin/varnishd/http2/cache_http2_send.c @@ -31,14 +31,6 @@ #include "cache/cache.h" -#include - -#include -#include -#include -#include - -#include "cache/cache_filter.h" #include "cache/cache_transport.h" #include "http2/cache_http2.h" diff --git a/bin/varnishd/mgt/mgt.h b/bin/varnishd/mgt/mgt.h index dc69bc0..f06d912 100644 --- a/bin/varnishd/mgt/mgt.h +++ b/bin/varnishd/mgt/mgt.h @@ -28,7 +28,12 @@ * */ -#include +#ifdef MGT_MGT_H +#error "Multiple includes of mgt/mgt.h" +#endif +#define MGT_MGT_H + +#include #include "common/common.h" #include "common/com_params.h" diff --git a/bin/varnishd/mgt/mgt_acceptor.c b/bin/varnishd/mgt/mgt_acceptor.c index ae82607..c887464 100644 --- a/bin/varnishd/mgt/mgt_acceptor.c +++ b/bin/varnishd/mgt/mgt_acceptor.c @@ -35,7 +35,6 @@ #include #include #include -#include #include #include #include diff --git a/bin/varnishd/mgt/mgt_child.c b/bin/varnishd/mgt/mgt_child.c index d1c4f2f..e992eb2 100644 --- a/bin/varnishd/mgt/mgt_child.c +++ b/bin/varnishd/mgt/mgt_child.c @@ -38,8 +38,6 @@ #include #include #include -#include -#include #include #include #include diff --git a/bin/varnishd/mgt/mgt_cli.c b/bin/varnishd/mgt/mgt_cli.c index 6e6cc9a..c53205c 100644 --- a/bin/varnishd/mgt/mgt_cli.c +++ b/bin/varnishd/mgt/mgt_cli.c @@ -38,7 +38,6 @@ #include #include #include -#include #include #include #include diff --git a/bin/varnishd/mgt/mgt_jail.c b/bin/varnishd/mgt/mgt_jail.c index a88a499..515d56d 100644 --- a/bin/varnishd/mgt/mgt_jail.c +++ b/bin/varnishd/mgt/mgt_jail.c @@ -33,7 +33,6 @@ #include #include -#include #include #include #include diff --git a/bin/varnishd/mgt/mgt_jail_solaris.c b/bin/varnishd/mgt/mgt_jail_solaris.c index 1ab519e..96d1cba 100644 --- a/bin/varnishd/mgt/mgt_jail_solaris.c +++ b/bin/varnishd/mgt/mgt_jail_solaris.c @@ -208,7 +208,6 @@ #ifdef HAVE_SETPPRIV #include -#include #include #include #include diff --git a/bin/varnishd/mgt/mgt_jail_unix.c b/bin/varnishd/mgt/mgt_jail_unix.c index 838b977..12e25cb 100644 --- a/bin/varnishd/mgt/mgt_jail_unix.c +++ b/bin/varnishd/mgt/mgt_jail_unix.c @@ -30,13 +30,12 @@ #include "config.h" -#include #include #include #include #include -#include #include +#include #include #include diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index ea884d8..7b730dd 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -1,6 +1,6 @@ /*- * Copyright (c) 2006 Verdens Gang AS - * Copyright (c) 2006-2011 Varnish Software AS + * Copyright (c) 2006-2017 Varnish Software AS * All rights reserved. * * Author: Poul-Henning Kamp @@ -34,11 +34,9 @@ #include #include -#include #include #include #include -#include #include #include #include diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c index a6411ab..380882a 100644 --- a/bin/varnishd/mgt/mgt_param.c +++ b/bin/varnishd/mgt/mgt_param.c @@ -31,7 +31,6 @@ #include #include -#include #include #include diff --git a/bin/varnishd/mgt/mgt_param_bits.c b/bin/varnishd/mgt/mgt_param_bits.c index 3706f27..89b6005 100644 --- a/bin/varnishd/mgt/mgt_param_bits.c +++ b/bin/varnishd/mgt/mgt_param_bits.c @@ -31,7 +31,6 @@ #include #include -#include #include "mgt/mgt.h" #include "mgt/mgt_param.h" diff --git a/bin/varnishd/mgt/mgt_param_tbl.c b/bin/varnishd/mgt/mgt_param_tbl.c index b25539e..e29788d 100644 --- a/bin/varnishd/mgt/mgt_param_tbl.c +++ b/bin/varnishd/mgt/mgt_param_tbl.c @@ -29,8 +29,6 @@ #include "config.h" -#include - #include "mgt/mgt.h" #include "mgt/mgt_param.h" diff --git a/bin/varnishd/mgt/mgt_param_tcp.c b/bin/varnishd/mgt/mgt_param_tcp.c index 8def2a4..7744e1a 100644 --- a/bin/varnishd/mgt/mgt_param_tcp.c +++ b/bin/varnishd/mgt/mgt_param_tcp.c @@ -36,7 +36,6 @@ #include #include -#include #include #include #include diff --git a/bin/varnishd/mgt/mgt_param_tweak.c b/bin/varnishd/mgt/mgt_param_tweak.c index 70e1c9a..643563a 100644 --- a/bin/varnishd/mgt/mgt_param_tweak.c +++ b/bin/varnishd/mgt/mgt_param_tweak.c @@ -34,7 +34,6 @@ #include #include -#include #include #include #include diff --git a/bin/varnishd/mgt/mgt_pool.c b/bin/varnishd/mgt/mgt_pool.c index 7cb807d..95e667c 100644 --- a/bin/varnishd/mgt/mgt_pool.c +++ b/bin/varnishd/mgt/mgt_pool.c @@ -42,8 +42,6 @@ #include "config.h" -#include - #include "mgt/mgt.h" #include "mgt/mgt_param.h" diff --git a/bin/varnishd/mgt/mgt_shmem.c b/bin/varnishd/mgt/mgt_shmem.c index 49a8753..f0849e9 100644 --- a/bin/varnishd/mgt/mgt_shmem.c +++ b/bin/varnishd/mgt/mgt_shmem.c @@ -35,8 +35,6 @@ #include #include -#include -#include #include #include #include diff --git a/bin/varnishd/mgt/mgt_util.c b/bin/varnishd/mgt/mgt_util.c index 8d2b0ee..83b3bc5 100644 --- a/bin/varnishd/mgt/mgt_util.c +++ b/bin/varnishd/mgt/mgt_util.c @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * The management process and CLI handling + * The management process, various utility functions */ #include "config.h" @@ -34,15 +34,9 @@ #include #include -#include -#include -#include -#include -#include #include #include #include -#include #include "mgt/mgt.h" diff --git a/bin/varnishd/mgt/mgt_vcc.c b/bin/varnishd/mgt/mgt_vcc.c index 2cbaaeb..39e2803 100644 --- a/bin/varnishd/mgt/mgt_vcc.c +++ b/bin/varnishd/mgt/mgt_vcc.c @@ -34,7 +34,6 @@ #include #include #include -#include #include #include #include diff --git a/bin/varnishd/mgt/mgt_vcl.c b/bin/varnishd/mgt/mgt_vcl.c index 6791245..bb9d4e0 100644 --- a/bin/varnishd/mgt/mgt_vcl.c +++ b/bin/varnishd/mgt/mgt_vcl.c @@ -32,7 +32,6 @@ #include "config.h" #include -#include #include #include #include From phk at FreeBSD.org Sat Jan 14 18:30:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Sat, 14 Jan 2017 19:30:05 +0100 Subject: [master] 71d30ee Repatriate some non-child related stuff from mgt_child.c to mgt_main.c Message-ID: commit 71d30eeaede2b51618aff211b45e2bf47db705f8 Author: Poul-Henning Kamp Date: Sat Jan 14 18:28:55 2017 +0000 Repatriate some non-child related stuff from mgt_child.c to mgt_main.c diff --git a/bin/varnishd/mgt/mgt_child.c b/bin/varnishd/mgt/mgt_child.c index e992eb2..d480456 100644 --- a/bin/varnishd/mgt/mgt_child.c +++ b/bin/varnishd/mgt/mgt_child.c @@ -81,7 +81,6 @@ static struct vev *ev_listen; static struct vlu *child_std_vlu; static struct vsb *child_panic = NULL; -static double mgt_uptime_t0 = 0.; static void mgt_reap_child(void); @@ -667,37 +666,6 @@ mcf_server_status(struct cli *cli, const char * const *av, void *priv) /*--------------------------------------------------------------------*/ -static int __match_proto__(vev_cb_f) -mgt_sigint(const struct vev *e, int what) -{ - - (void)e; - (void)what; - MGT_Complain(C_ERR, "Manager got SIGINT"); - (void)fflush(stdout); - if (child_pid >= 0) - mgt_stop_child(); - exit(0); -} - -/*--------------------------------------------------------------------*/ - -static int __match_proto__(vev_cb_f) -mgt_uptime(const struct vev *e, int what) -{ - - (void)e; - (void)what; - AN(VSC_C_mgt); - VSC_C_mgt->uptime = static_VSC_C_mgt.uptime = - (uint64_t)(VTIM_real() - mgt_uptime_t0); - if (heritage.vsm != NULL) - VSM_common_ageupdate(heritage.vsm); - return (0); -} - -/*--------------------------------------------------------------------*/ - static struct cli_proto cli_child[] = { { CLICMD_SERVER_STATUS, "", mcf_server_status }, { CLICMD_SERVER_START, "", mcf_server_start }, @@ -716,45 +684,9 @@ static struct cli_proto cli_child[] = { int MGT_Run(void) { - struct sigaction sac; - struct vev *e; - int i; VCLS_AddFunc(mgt_cls, MCF_AUTH, cli_child); - mgt_uptime_t0 = VTIM_real(); - e = vev_new(); - XXXAN(e); - e->callback = mgt_uptime; - e->timeout = 1.0; - e->name = "mgt_uptime"; - AZ(vev_add(mgt_evb, e)); - - e = vev_new(); - XXXAN(e); - e->sig = SIGTERM; - e->callback = mgt_sigint; - e->name = "mgt_sigterm"; - AZ(vev_add(mgt_evb, e)); - - e = vev_new(); - XXXAN(e); - e->sig = SIGINT; - e->callback = mgt_sigint; - e->name = "mgt_sigint"; - AZ(vev_add(mgt_evb, e)); - -#ifdef HAVE_SETPROCTITLE - setproctitle("Varnish-Mgr %s", heritage.name); -#endif - - memset(&sac, 0, sizeof sac); - sac.sa_handler = SIG_IGN; - sac.sa_flags = SA_RESTART; - - AZ(sigaction(SIGPIPE, &sac, NULL)); - AZ(sigaction(SIGHUP, &sac, NULL)); - if (!d_flag && !mgt_has_vcl()) MGT_Complain(C_ERR, "No VCL loaded yet"); else if (!d_flag) { @@ -763,11 +695,5 @@ MGT_Run(void) return (2); } - i = mgt_SHM_Commit(); - if (i != 0) { - MGT_Complain(C_ERR, "Could not commit SHM file"); - return (2); - } - return(0); } diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index 7b730dd..cc36f27 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -31,12 +31,11 @@ #include "config.h" -#include - #include #include #include #include +#include #include #include #include @@ -397,6 +396,40 @@ mgt_eric_im_done(int eric_fd, unsigned u) /*--------------------------------------------------------------------*/ +static int __match_proto__(vev_cb_f) +mgt_sigint(const struct vev *e, int what) +{ + + (void)e; + (void)what; + MGT_Complain(C_ERR, "Manager got SIGINT"); + (void)fflush(stdout); + if (child_pid >= 0) + mgt_stop_child(); + exit(0); +} + +/*--------------------------------------------------------------------*/ + +static int __match_proto__(vev_cb_f) +mgt_uptime(const struct vev *e, int what) +{ + static double mgt_uptime_t0 = 0; + + (void)e; + (void)what; + AN(VSC_C_mgt); + if (mgt_uptime_t0 == 0) + mgt_uptime_t0 = VTIM_real(); + VSC_C_mgt->uptime = static_VSC_C_mgt.uptime = + (uint64_t)(VTIM_real() - mgt_uptime_t0); + if (heritage.vsm != NULL) + VSM_common_ageupdate(heritage.vsm); + return (0); +} + +/*--------------------------------------------------------------------*/ + int main(int argc, char * const *argv) { @@ -424,6 +457,8 @@ main(int argc, char * const *argv) char Cn_arg[] = "/tmp/varnishd_C_XXXXXXX"; const char * opt_spec = "a:b:Cdf:Fh:i:j:l:M:n:P:p:r:S:s:T:t:VW:x:"; unsigned u; + struct sigaction sac; + struct vev *e; mgt_tests(); @@ -507,6 +542,10 @@ main(int argc, char * const *argv) mgt_pid = getpid(); } +#ifdef HAVE_SETPROCTITLE + setproctitle("Varnish-Mgr %s", heritage.name); +#endif + /* Set up the mgt counters */ memset(&static_VSC_C_mgt, 0, sizeof static_VSC_C_mgt); VSC_C_mgt = &static_VSC_C_mgt; @@ -718,10 +757,6 @@ main(int argc, char * const *argv) S_arg = make_secret(dirname); AN(S_arg); - /************************************************************** - * After this point diagnostics will only be seen with -d - */ - assert(pfh == NULL || !VPF_Write(pfh)); MGT_Complain(C_DEBUG, "Platform: %s", VSB_data(vident) + 1); @@ -739,15 +774,52 @@ main(int argc, char * const *argv) /* Instantiate VSM */ mgt_SHM_Create(); - - u = MGT_Run(); + if (mgt_SHM_Commit()) { + MGT_Complain(C_ERR, "Could not commit SHM file"); + u = 2; + } else { + u = MGT_Run(); + } if (eric_fd >= 0) mgt_eric_im_done(eric_fd, u); + if (u) + exit(u); + + /* Failure is no longer an option */ + if (F_flag) VFIL_null_fd(STDIN_FILENO); + e = vev_new(); + AN(e); + e->callback = mgt_uptime; + e->timeout = 1.0; + e->name = "mgt_uptime"; + AZ(vev_add(mgt_evb, e)); + + e = vev_new(); + AN(e); + e->sig = SIGTERM; + e->callback = mgt_sigint; + e->name = "mgt_sigterm"; + AZ(vev_add(mgt_evb, e)); + + e = vev_new(); + AN(e); + e->sig = SIGINT; + e->callback = mgt_sigint; + e->name = "mgt_sigint"; + AZ(vev_add(mgt_evb, e)); + + memset(&sac, 0, sizeof sac); + sac.sa_handler = SIG_IGN; + sac.sa_flags = SA_RESTART; + + AZ(sigaction(SIGPIPE, &sac, NULL)); + AZ(sigaction(SIGHUP, &sac, NULL)); + o = vev_schedule(mgt_evb); if (o != 0) MGT_Complain(C_ERR, "vev_schedule() = %d", o); From phk at FreeBSD.org Sat Jan 14 18:43:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Sat, 14 Jan 2017 19:43:05 +0100 Subject: [master] 8984f5b Integrage the two-stage SHM creation procedure. Message-ID: commit 8984f5b0d45794ef5dd6df2d0900db2626fad7a5 Author: Poul-Henning Kamp Date: Sat Jan 14 18:42:02 2017 +0000 Integrage the two-stage SHM creation procedure. diff --git a/bin/varnishd/mgt/mgt.h b/bin/varnishd/mgt/mgt.h index f06d912..f96e997 100644 --- a/bin/varnishd/mgt/mgt.h +++ b/bin/varnishd/mgt/mgt.h @@ -160,7 +160,6 @@ void mgt_SHM_Init(void); void mgt_SHM_static_alloc(const void *, ssize_t size, const char *class, const char *type, const char *ident); void mgt_SHM_Create(void); -int mgt_SHM_Commit(void); void mgt_SHM_Destroy(int keep); void mgt_SHM_Size_Adjust(void); diff --git a/bin/varnishd/mgt/mgt_child.c b/bin/varnishd/mgt/mgt_child.c index d480456..77b8cb4 100644 --- a/bin/varnishd/mgt/mgt_child.c +++ b/bin/varnishd/mgt/mgt_child.c @@ -549,7 +549,6 @@ mgt_reap_child(void) mgt_SHM_Destroy(MGT_DO_DEBUG(DBG_VSM_KEEP)); } mgt_SHM_Create(); - mgt_SHM_Commit(); if (child_state == CH_RUNNING) child_state = CH_DIED; diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index cc36f27..5ec9a3a 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -772,14 +772,8 @@ main(int argc, char * const *argv) if (T_arg != NULL) mgt_cli_telnet(T_arg); - /* Instantiate VSM */ mgt_SHM_Create(); - if (mgt_SHM_Commit()) { - MGT_Complain(C_ERR, "Could not commit SHM file"); - u = 2; - } else { - u = MGT_Run(); - } + u = MGT_Run(); if (eric_fd >= 0) mgt_eric_im_done(eric_fd, u); diff --git a/bin/varnishd/mgt/mgt_shmem.c b/bin/varnishd/mgt/mgt_shmem.c index f0849e9..7ddcefc 100644 --- a/bin/varnishd/mgt/mgt_shmem.c +++ b/bin/varnishd/mgt/mgt_shmem.c @@ -257,28 +257,14 @@ mgt_SHM_Create(void) /* Commit changes, for OS's without coherent VM/buf */ AZ(msync(p, getpagesize(), MS_SYNC)); #endif -} - -/*-------------------------------------------------------------------- - * Commit the VSM - */ - -int -mgt_SHM_Commit(void) -{ - char fnbuf[64]; - int retval = 0; - - bprintf(fnbuf, "%s.%jd", VSM_FILENAME, (intmax_t)getpid()); VJ_master(JAIL_MASTER_FILE); if (rename(fnbuf, VSM_FILENAME)) { MGT_Complain(C_ERR, "Rename failed %s -> %s: %s", fnbuf, VSM_FILENAME, strerror(errno)); (void)unlink(fnbuf); - retval = -1; + exit(1); } VJ_master(JAIL_MASTER_LOW); - return (retval); } /*-------------------------------------------------------------------- From phk at FreeBSD.org Sat Jan 14 19:18:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Sat, 14 Jan 2017 20:18:05 +0100 Subject: [master] 8aedf4b Add a closefd(int*) macro to properly dispose of file descriptors Message-ID: commit 8aedf4bd4b2b0a4484138c01c9a0293b53fb9ec8 Author: Poul-Henning Kamp Date: Sat Jan 14 19:13:02 2017 +0000 Add a closefd(int*) macro to properly dispose of file descriptors diff --git a/include/vdef.h b/include/vdef.h index 892eda6..f0afe09 100644 --- a/include/vdef.h +++ b/include/vdef.h @@ -49,6 +49,13 @@ < sizeof buf); \ } while (0) +/* Close and discard filedescriptor */ +#define closefd(fdp) \ + do { \ + assert(*(fdp) >= 0); \ + AZ(close(*(fdp))); \ + *(fdp) = -1; \ + } while (0) #ifndef __GNUC_PREREQ # if defined __GNUC__ && defined __GNUC_MINOR__ From phk at FreeBSD.org Sat Jan 14 19:18:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Sat, 14 Jan 2017 20:18:05 +0100 Subject: [master] 0a105cd Put mgt_child.c in its own "MCH" namespace. Message-ID: commit 0a105cdd75c74a709c9ca85731727901f64e3dc8 Author: Poul-Henning Kamp Date: Sat Jan 14 19:17:09 2017 +0000 Put mgt_child.c in its own "MCH" namespace. diff --git a/bin/varnishd/common/common.h b/bin/varnishd/common/common.h index 82305e4..b476cb9 100644 --- a/bin/varnishd/common/common.h +++ b/bin/varnishd/common/common.h @@ -63,7 +63,7 @@ int Symbol_Lookup(struct vsb *vsb, void *ptr); /* Really belongs in mgt.h, but storage_file chokes on both */ -void mgt_child_inherit(int fd, const char *what); +void MCH_Fd_Inherit(int fd, const char *what); #define ARGV_ERR(...) \ do { \ diff --git a/bin/varnishd/mgt/mgt.h b/bin/varnishd/mgt/mgt.h index f96e997..d5a1381 100644 --- a/bin/varnishd/mgt/mgt.h +++ b/bin/varnishd/mgt/mgt.h @@ -53,11 +53,11 @@ void MAC_Arg(const char *); void MAC_reopen_sockets(struct cli *); /* mgt_child.c */ -extern pid_t child_pid; -int MGT_Run(void); -void mgt_stop_child(void); -void mgt_got_fd(int fd); -void MGT_Child_Cli_Fail(void); +int MCH_Init(int launch); +int MCH_Running(void); +void MCH_Stop_Child(void); +void MCH_TrackHighFd(int fd); +void MCH_Cli_Fail(void); /* mgt_cli.c */ diff --git a/bin/varnishd/mgt/mgt_acceptor.c b/bin/varnishd/mgt/mgt_acceptor.c index c887464..eabad1a 100644 --- a/bin/varnishd/mgt/mgt_acceptor.c +++ b/bin/varnishd/mgt/mgt_acceptor.c @@ -58,7 +58,7 @@ mac_opensocket(struct listen_sock *ls) CHECK_OBJ_NOTNULL(ls, LISTEN_SOCK_MAGIC); if (ls->sock > 0) { - mgt_child_inherit(ls->sock, NULL); + MCH_Fd_Inherit(ls->sock, NULL); AZ(close(ls->sock)); } ls->sock = VTCP_bind(ls->addr, NULL); @@ -67,7 +67,7 @@ mac_opensocket(struct listen_sock *ls) AN(fail); return (fail); } - mgt_child_inherit(ls->sock, "sock"); + MCH_Fd_Inherit(ls->sock, "sock"); return (0); } diff --git a/bin/varnishd/mgt/mgt_child.c b/bin/varnishd/mgt/mgt_child.c index 77b8cb4..d46f42d 100644 --- a/bin/varnishd/mgt/mgt_child.c +++ b/bin/varnishd/mgt/mgt_child.c @@ -52,7 +52,7 @@ #include "vlu.h" #include "vtim.h" -pid_t child_pid = -1; +static pid_t child_pid = -1; static struct vbitmap *fd_map; @@ -84,19 +84,6 @@ static struct vsb *child_panic = NULL; static void mgt_reap_child(void); -/*--------------------------------------------------------------------- - * A handy little function - */ - -static inline void -closex(int *fd) -{ - - assert(*fd >= 0); - AZ(close(*fd)); - *fd = -1; -} - /*===================================================================== * Panic string evacuation and handling */ @@ -127,7 +114,7 @@ mgt_panic_clear(void) } static void __match_proto__(cli_func_t) -mcf_panic_show(struct cli *cli, const char * const *av, void *priv) +mch_cli_panic_show(struct cli *cli, const char * const *av, void *priv) { (void)av; (void)priv; @@ -143,7 +130,7 @@ mcf_panic_show(struct cli *cli, const char * const *av, void *priv) } static void __match_proto__(cli_func_t) -mcf_panic_clear(struct cli *cli, const char * const *av, void *priv) +mch_cli_panic_clear(struct cli *cli, const char * const *av, void *priv) { (void)priv; @@ -180,7 +167,7 @@ static int mgt_max_fd; #define CLOSE_FD_UP_TO (mgt_max_fd + 100) void -mgt_got_fd(int fd) +MCH_TrackHighFd(int fd) { /* * Assert > 0, to catch bogus opens, we know where stdin goes @@ -197,7 +184,7 @@ mgt_got_fd(int fd) */ void -mgt_child_inherit(int fd, const char *what) +MCH_Fd_Inherit(int fd, const char *what) { assert(fd >= 0); @@ -260,7 +247,7 @@ child_poker(const struct vev *e, int what) MGT_Complain(C_ERR, "Unexpected reply from ping: %u %s", status, r); if (status != CLIS_COMMS) - MGT_Child_Cli_Fail(); + MCH_Cli_Fail(); } free(r); return 0; @@ -314,13 +301,13 @@ mgt_launch_child(struct cli *cli) /* Open pipe for mgr->child CLI */ AZ(pipe(cp)); heritage.cli_in = cp[0]; - mgt_child_inherit(heritage.cli_in, "cli_in"); + MCH_Fd_Inherit(heritage.cli_in, "cli_in"); child_cli_out = cp[1]; /* Open pipe for child->mgr CLI */ AZ(pipe(cp)); heritage.cli_out = cp[1]; - mgt_child_inherit(heritage.cli_out, "cli_out"); + MCH_Fd_Inherit(heritage.cli_out, "cli_out"); child_cli_in = cp[0]; /* @@ -392,13 +379,13 @@ mgt_launch_child(struct cli *cli) VSC_C_mgt->child_start = ++static_VSC_C_mgt.child_start; /* Close stuff the child got */ - closex(&heritage.std_fd); + closefd(&heritage.std_fd); - mgt_child_inherit(heritage.cli_in, NULL); - closex(&heritage.cli_in); + MCH_Fd_Inherit(heritage.cli_in, NULL); + closefd(&heritage.cli_in); - mgt_child_inherit(heritage.cli_out, NULL); - closex(&heritage.cli_out); + MCH_Fd_Inherit(heritage.cli_out, NULL); + closefd(&heritage.cli_out); child_std_vlu = VLU_New(NULL, child_line, 0); AN(child_std_vlu); @@ -431,7 +418,7 @@ mgt_launch_child(struct cli *cli) (intmax_t)child_pid, p); free(p); child_state = CH_RUNNING; - mgt_stop_child(); + MCH_Stop_Child(); } else child_state = CH_RUNNING; } @@ -472,9 +459,9 @@ mgt_reap_child(void) */ mgt_cli_stop_child(); if (child_cli_out >= 0) - closex(&child_cli_out); + closefd(&child_cli_out); if (child_cli_in >= 0) - closex(&child_cli_in); + closefd(&child_cli_in); /* Stop the poker */ if (ev_poker != NULL) { @@ -555,7 +542,7 @@ mgt_reap_child(void) /* Pick up any stuff lingering on stdout/stderr */ (void)child_listener(NULL, EV_RD); - closex(&child_output); + closefd(&child_output); VLU_Destroy(child_std_vlu); child_pid = -1; @@ -581,7 +568,7 @@ mgt_reap_child(void) */ void -MGT_Child_Cli_Fail(void) +MCH_Cli_Fail(void) { if (child_state != CH_RUNNING) @@ -603,7 +590,7 @@ MGT_Child_Cli_Fail(void) */ void -mgt_stop_child(void) +MCH_Stop_Child(void) { if (child_state != CH_RUNNING) @@ -616,12 +603,23 @@ mgt_stop_child(void) mgt_reap_child(); } +/*==================================================================== + * Query if the child is running + */ + +int +MCH_Running(void) +{ + + return (child_pid > 0); +} + /*===================================================================== - * CLI commands to start/stop child + * CLI commands */ static void __match_proto__(cli_func_t) -mcf_server_start(struct cli *cli, const char * const *av, void *priv) +mch_cli_server_start(struct cli *cli, const char * const *av, void *priv) { (void)av; @@ -640,37 +638,33 @@ mcf_server_start(struct cli *cli, const char * const *av, void *priv) } static void __match_proto__(cli_func_t) -mcf_server_stop(struct cli *cli, const char * const *av, void *priv) +mch_cli_server_stop(struct cli *cli, const char * const *av, void *priv) { (void)av; (void)priv; if (child_state == CH_RUNNING) { - mgt_stop_child(); + MCH_Stop_Child(); } else { VCLI_SetResult(cli, CLIS_CANT); VCLI_Out(cli, "Child in state %s", ch_state[child_state]); } } -/*--------------------------------------------------------------------*/ - static void -mcf_server_status(struct cli *cli, const char * const *av, void *priv) +mch_cli_server_status(struct cli *cli, const char * const *av, void *priv) { (void)av; (void)priv; VCLI_Out(cli, "Child in state %s", ch_state[child_state]); } -/*--------------------------------------------------------------------*/ - -static struct cli_proto cli_child[] = { - { CLICMD_SERVER_STATUS, "", mcf_server_status }, - { CLICMD_SERVER_START, "", mcf_server_start }, - { CLICMD_SERVER_STOP, "", mcf_server_stop }, - { CLICMD_PANIC_SHOW, "", mcf_panic_show }, - { CLICMD_PANIC_CLEAR, "", mcf_panic_clear }, +static struct cli_proto cli_mch[] = { + { CLICMD_SERVER_STATUS, "", mch_cli_server_status }, + { CLICMD_SERVER_START, "", mch_cli_server_start }, + { CLICMD_SERVER_STOP, "", mch_cli_server_stop }, + { CLICMD_PANIC_SHOW, "", mch_cli_panic_show }, + { CLICMD_PANIC_CLEAR, "", mch_cli_panic_clear }, { NULL } }; @@ -681,14 +675,12 @@ static struct cli_proto cli_child[] = { */ int -MGT_Run(void) +MCH_Init(int launch) { - VCLS_AddFunc(mgt_cls, MCF_AUTH, cli_child); + VCLS_AddFunc(mgt_cls, MCF_AUTH, cli_mch); - if (!d_flag && !mgt_has_vcl()) - MGT_Complain(C_ERR, "No VCL loaded yet"); - else if (!d_flag) { + if (launch) { mgt_launch_child(NULL); if (child_state != CH_RUNNING) return (2); diff --git a/bin/varnishd/mgt/mgt_cli.c b/bin/varnishd/mgt/mgt_cli.c index c53205c..2f9ca91 100644 --- a/bin/varnishd/mgt/mgt_cli.c +++ b/bin/varnishd/mgt/mgt_cli.c @@ -82,7 +82,7 @@ mcf_banner(struct cli *cli, const char *const *av, void *priv) VCLI_Out(cli, "\n"); VCLI_Out(cli, "Type 'help' for command list.\n"); VCLI_Out(cli, "Type 'quit' to close CLI session.\n"); - if (child_pid < 0) + if (!MCH_Running()) VCLI_Out(cli, "Type 'start' to launch worker process.\n"); VCLI_SetResult(cli, CLIS_OK); } @@ -146,12 +146,12 @@ mcf_askchild(struct cli *cli, const char * const *av, void *priv) VSB_destroy(&vsb); VCLI_SetResult(cli, CLIS_COMMS); VCLI_Out(cli, "CLI communication error"); - MGT_Child_Cli_Fail(); + MCH_Cli_Fail(); return; } VSB_destroy(&vsb); if (VCLI_ReadResult(cli_i, &u, &q, mgt_param.cli_timeout)) - MGT_Child_Cli_Fail(); + MCH_Cli_Fail(); VCLI_SetResult(cli, u); VCLI_Out(cli, "%s", q); free(q); @@ -199,12 +199,12 @@ mgt_cli_askchild(unsigned *status, char **resp, const char *fmt, ...) *status = CLIS_COMMS; if (resp != NULL) *resp = strdup("CLI communication error"); - MGT_Child_Cli_Fail(); + MCH_Cli_Fail(); return (CLIS_COMMS); } if (VCLI_ReadResult(cli_i, &u, resp, mgt_param.cli_timeout)) - MGT_Child_Cli_Fail(); + MCH_Cli_Fail(); if (status != NULL) *status = u; return (u == CLIS_OK ? 0 : u); @@ -280,7 +280,7 @@ mcf_auth(struct cli *cli, const char *const *av, void *priv) return; } VJ_master(JAIL_MASTER_LOW); - mgt_got_fd(fd); + MCH_TrackHighFd(fd); VCLI_AuthResponse(fd, cli->challenge, buf); AZ(close(fd)); if (strcasecmp(buf, av[2])) { @@ -484,7 +484,7 @@ telnet_accept(const struct vev *ev, int what) if (i < 0) return (0); - mgt_got_fd(i); + MCH_TrackHighFd(i); tn = telnet_new(i); vsb = sock_id("telnet", i); mgt_cli_setup(i, i, 0, VSB_data(vsb), telnet_close, tn); @@ -508,7 +508,7 @@ mgt_cli_secret(const char *S_arg) exit(2); } VJ_master(JAIL_MASTER_LOW); - mgt_got_fd(fd); + MCH_TrackHighFd(fd); i = read(fd, buf, sizeof buf); if (i == 0) { fprintf(stderr, "Empty secret-file \"%s\"\n", S_arg); @@ -646,7 +646,7 @@ Marg_poker(const struct vev *e, int what) if (s < 0) return (0); - mgt_got_fd(s); + MCH_TrackHighFd(s); M_conn = vev_new(); AN(M_conn); diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index 5ec9a3a..fd636c0 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -171,7 +171,7 @@ mgt_stdin_close(void *priv) (void)priv; if (d_flag) { - mgt_stop_child(); + MCH_Stop_Child(); mgt_cli_close_all(); if (pfh != NULL) (void)VPF_Remove(pfh); @@ -404,8 +404,8 @@ mgt_sigint(const struct vev *e, int what) (void)what; MGT_Complain(C_ERR, "Manager got SIGINT"); (void)fflush(stdout); - if (child_pid >= 0) - mgt_stop_child(); + if (MCH_Running()) + MCH_Stop_Child(); exit(0); } @@ -528,7 +528,7 @@ main(int argc, char * const *argv) * have inherited from sloppy process control daemons. */ VSUB_closefrom(STDERR_FILENO + 1); - mgt_got_fd(STDERR_FILENO); + MCH_TrackHighFd(STDERR_FILENO); setbuf(stdout, NULL); setbuf(stderr, NULL); @@ -538,7 +538,7 @@ main(int argc, char * const *argv) */ if (!C_flag && !d_flag && !F_flag) { eric_fd = mgt_eric(); - mgt_got_fd(eric_fd); + MCH_TrackHighFd(eric_fd); mgt_pid = getpid(); } @@ -773,7 +773,11 @@ main(int argc, char * const *argv) mgt_cli_telnet(T_arg); mgt_SHM_Create(); - u = MGT_Run(); + + if (!d_flag && !mgt_has_vcl()) + MGT_Complain(C_ERR, "No VCL loaded yet"); + + u = MCH_Init(d_flag ? 0 : 1); if (eric_fd >= 0) mgt_eric_im_done(eric_fd, u); diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c index 380882a..f10d312 100644 --- a/bin/varnishd/mgt/mgt_param.c +++ b/bin/varnishd/mgt/mgt_param.c @@ -383,7 +383,7 @@ MCF_ParamSet(struct cli *cli, const char *param, const char *val) if (cli->result != CLIS_OK) { VCLI_Out(cli, "\n(attempting to set param '%s' to '%s')", pp->name, val); - } else if (child_pid >= 0 && pp->flags & MUST_RESTART) { + } else if (MCH_Running() && pp->flags & MUST_RESTART) { VCLI_Out(cli, "\nChange will take effect when child is restarted"); } else if (pp->flags & MUST_RELOAD) { diff --git a/bin/varnishd/mgt/mgt_vcl.c b/bin/varnishd/mgt/mgt_vcl.c index bb9d4e0..c70c05d 100644 --- a/bin/varnishd/mgt/mgt_vcl.c +++ b/bin/varnishd/mgt/mgt_vcl.c @@ -293,7 +293,7 @@ mgt_vcl_setstate(struct cli *cli, struct vclprog *vp, const char *vs) if (vp->warm == 0) vp->go_cold = 0; - if (child_pid < 0) + if (!MCH_Running()) return (0); i = mgt_cli_askchild(&status, &p, "vcl.state %s %d%s\n", @@ -354,7 +354,7 @@ mgt_new_vcl(struct cli *cli, const char *vclname, const char *vclsrc, if (active_vcl == NULL) active_vcl = vp; - if (child_pid < 0) + if (!MCH_Running()) return; if (mgt_cli_askchild(&status, &p, "vcl.load %s %s %d%s\n", @@ -552,7 +552,7 @@ mcf_vcl_use(struct cli *cli, const char * const *av, void *priv) return; if (mgt_vcl_setstate(cli, vp, VCL_STATE_WARM)) return; - if (child_pid >= 0 && + if (MCH_Running() && mgt_cli_askchild(&status, &p, "vcl.use %s\n", av[2])) { VCLI_SetResult(cli, status); VCLI_Out(cli, "%s", p); @@ -611,7 +611,7 @@ mcf_vcl_discard(struct cli *cli, const char * const *av, void *priv) AN(vp->warm); else (void)mgt_vcl_setstate(cli, vp, VCL_STATE_COLD); - if (child_pid >= 0) { + if (MCH_Running()) { /* XXX If this fails the child is crashing, figure that later */ (void)mgt_cli_askchild(&status, &p, "vcl.discard %s\n", av[2]); free(p); @@ -631,7 +631,7 @@ mcf_vcl_list(struct cli *cli, const char * const *av, void *priv) (void)av; (void)priv; - if (child_pid >= 0) { + if (MCH_Running()) { if (!mgt_cli_askchild(&status, &p, "vcl.list\n")) { VCLI_SetResult(cli, status); VCLI_Out(cli, "%s", p); @@ -713,7 +713,7 @@ mcf_vcl_label(struct cli *cli, const char * const *av, void *priv) if (vpt->state == VCL_STATE_COLD) vpt->state = VCL_STATE_AUTO; (void)mgt_vcl_setstate(cli, vpt, VCL_STATE_WARM); - if (child_pid < 0) + if (!MCH_Running()) return; i = mgt_cli_askchild(&status, &p, "vcl.label %s %s\n", av[2], av[3]); diff --git a/bin/varnishd/storage/mgt_storage_persistent.c b/bin/varnishd/storage/mgt_storage_persistent.c index 0c87733..747032b 100644 --- a/bin/varnishd/storage/mgt_storage_persistent.c +++ b/bin/varnishd/storage/mgt_storage_persistent.c @@ -225,5 +225,5 @@ smp_mgt_init(struct stevedore *parent, int ac, char * const *av) parent->priv = sc; /* XXX: only for sendfile I guess... */ - mgt_child_inherit(sc->fd, "storage_persistent"); + MCH_Fd_Inherit(sc->fd, "storage_persistent"); } diff --git a/bin/varnishd/storage/storage_file.c b/bin/varnishd/storage/storage_file.c index 033d325..1b8e364 100644 --- a/bin/varnishd/storage/storage_file.c +++ b/bin/varnishd/storage/storage_file.c @@ -156,7 +156,7 @@ smf_init(struct stevedore *parent, int ac, char * const *av) parent->priv = sc; (void)STV_GetFile(fn, &sc->fd, &sc->filename, "-sfile"); - mgt_child_inherit(sc->fd, "storage_file"); + MCH_Fd_Inherit(sc->fd, "storage_file"); sc->filesize = STV_FileSize(sc->fd, size, &sc->pagesize, "-sfile"); if (VFIL_allocate(sc->fd, (off_t)sc->filesize, 0)) ARGV_ERR("(-sfile) allocation error: %s\n", strerror(errno)); From phk at FreeBSD.org Sat Jan 14 19:49:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Sat, 14 Jan 2017 20:49:05 +0100 Subject: [master] 64370e2 Use closefd() throughout Message-ID: commit 64370e2f088731b1a536354875cc770abf9e8140 Author: Poul-Henning Kamp Date: Sat Jan 14 19:28:16 2017 +0000 Use closefd() throughout diff --git a/bin/varnishd/cache/cache_acceptor.c b/bin/varnishd/cache/cache_acceptor.c index 754d1b0..cb907a9 100644 --- a/bin/varnishd/cache/cache_acceptor.c +++ b/bin/varnishd/cache/cache_acceptor.c @@ -305,7 +305,7 @@ vca_make_session(struct worker *wrk, void *arg) CAST_OBJ_NOTNULL(wa, arg, WRK_ACCEPT_MAGIC); if (VTCP_blocking(wa->acceptsock)) { - AZ(close(wa->acceptsock)); + closefd(&wa->acceptsock); wrk->stats->sess_drop++; // XXX Better counter ? WS_Release(wrk->aws, 0); return; @@ -322,7 +322,7 @@ vca_make_session(struct worker *wrk, void *arg) */ vca_pace_bad(); (void)VTCP_nonblocking(wa->acceptsock); - AZ(close(wa->acceptsock)); + closefd(&wa->acceptsock); wrk->stats->sess_drop++; WS_Release(wrk->aws, 0); return; diff --git a/bin/varnishd/cache/cache_vrt_vmod.c b/bin/varnishd/cache/cache_vrt_vmod.c index a938568..f64cb33 100644 --- a/bin/varnishd/cache/cache_vrt_vmod.c +++ b/bin/varnishd/cache/cache_vrt_vmod.c @@ -86,7 +86,7 @@ vrt_vmod_backup_copy(VRT_CTX, const char *nm, const char *fm, const char *to) VSB_printf(ctx->msg, "Opening vmod %s from %s: %s\n", nm, fm, strerror(errno)); AZ(unlink(to)); - AZ(close(fo)); + closefd(&fo); return (1); } while (1) { @@ -101,8 +101,8 @@ vrt_vmod_backup_copy(VRT_CTX, const char *nm, const char *fm, const char *to) break; } } - AZ(close(fi)); - AZ(close(fo)); + closefd(&fi); + closefd(&fo); return(ret); } diff --git a/bin/varnishd/mgt/mgt_acceptor.c b/bin/varnishd/mgt/mgt_acceptor.c index eabad1a..3b0985f 100644 --- a/bin/varnishd/mgt/mgt_acceptor.c +++ b/bin/varnishd/mgt/mgt_acceptor.c @@ -59,7 +59,7 @@ mac_opensocket(struct listen_sock *ls) CHECK_OBJ_NOTNULL(ls, LISTEN_SOCK_MAGIC); if (ls->sock > 0) { MCH_Fd_Inherit(ls->sock, NULL); - AZ(close(ls->sock)); + closefd(&ls->sock); } ls->sock = VTCP_bind(ls->addr, NULL); fail = errno; diff --git a/bin/varnishd/mgt/mgt_cli.c b/bin/varnishd/mgt/mgt_cli.c index 2f9ca91..eeeef21 100644 --- a/bin/varnishd/mgt/mgt_cli.c +++ b/bin/varnishd/mgt/mgt_cli.c @@ -282,7 +282,7 @@ mcf_auth(struct cli *cli, const char *const *av, void *priv) VJ_master(JAIL_MASTER_LOW); MCH_TrackHighFd(fd); VCLI_AuthResponse(fd, cli->challenge, buf); - AZ(close(fd)); + closefd(&fd); if (strcasecmp(buf, av[2])) { MGT_Complain(C_SECURITY, "CLI Authentication failure from %s", cli->ident); @@ -518,7 +518,7 @@ mgt_cli_secret(const char *S_arg) fprintf(stderr, "Can not read secret-file \"%s\"\n", S_arg); exit(2); } - AZ(close(fd)); + closefd(&fd); secret_file = S_arg; } diff --git a/bin/varnishd/mgt/mgt_jail.c b/bin/varnishd/mgt/mgt_jail.c index 515d56d..85cd840 100644 --- a/bin/varnishd/mgt/mgt_jail.c +++ b/bin/varnishd/mgt/mgt_jail.c @@ -156,7 +156,7 @@ VJ_make_workdir(const char *dname) ARGV_ERR("Cannot create test-file in %s (%s)\n" "Check permissions (or delete old directory)\n", dname, strerror(errno)); - AZ(close(fd)); + closefd(&fd); AZ(unlink("_.testfile")); VJ_master(JAIL_MASTER_LOW); return (0); diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index fd636c0..eb5cbb8 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -219,7 +219,7 @@ make_secret(const char *dirname) AZ(VRND_RandomCrypto(&b, 1)); assert(1 == write(fdo, &b, 1)); } - AZ(close(fdo)); + closefd(&fdo); VJ_master(JAIL_MASTER_LOW); AZ(atexit(mgt_secret_atexit)); return (fn); @@ -361,7 +361,7 @@ mgt_eric(void) fprintf(stderr, "Fork() failed: %s\n", strerror(errno)); exit(-1); case 0: - AZ(close(eric_pipes[0])); + closefd(&eric_pipes[0]); assert(setsid() > 1); VFIL_null_fd(STDIN_FILENO); @@ -369,7 +369,7 @@ mgt_eric(void) default: break; } - AZ(close(eric_pipes[1])); + closefd(&eric_pipes[1]); sz = read(eric_pipes[0], &u, sizeof u); if (sz == sizeof u && u == ERIC_MAGIC) exit(0); @@ -391,7 +391,7 @@ mgt_eric_im_done(int eric_fd, unsigned u) VFIL_null_fd(STDERR_FILENO); assert(write(eric_fd, &u, sizeof u) == sizeof u); - AZ(close(eric_fd)); + closefd(&eric_fd); } /*--------------------------------------------------------------------*/ @@ -681,7 +681,7 @@ main(int argc, char * const *argv) if (o < 0) ARGV_ERR("Cannot open -S file (%s): %s\n", S_arg, strerror(errno)); - AZ(close(o)); + closefd(&o); VJ_master(JAIL_MASTER_LOW); } diff --git a/bin/varnishd/mgt/mgt_param_tcp.c b/bin/varnishd/mgt/mgt_param_tcp.c index 7744e1a..9567d6f 100644 --- a/bin/varnishd/mgt/mgt_param_tcp.c +++ b/bin/varnishd/mgt/mgt_param_tcp.c @@ -75,7 +75,7 @@ tcp_keep_probes(void) tcp_probe(s, TCP_KEEPIDLE, "tcp_keepalive_time", 600); tcp_probe(s, TCP_KEEPCNT, "tcp_keepalive_probes", 5); tcp_probe(s, TCP_KEEPINTVL, "tcp_keepalive_intvl", 5); - AZ(close(s)); + closefd(&s); } #endif diff --git a/bin/varnishd/mgt/mgt_shmem.c b/bin/varnishd/mgt/mgt_shmem.c index 7ddcefc..e41018d 100644 --- a/bin/varnishd/mgt/mgt_shmem.c +++ b/bin/varnishd/mgt/mgt_shmem.c @@ -218,7 +218,7 @@ mgt_SHM_Create(void) MAP_HASSEMAPHORE | MAP_NOSYNC | MAP_SHARED, vsm_fd, 0); - AZ(close(vsm_fd)); + closefd(&vsm_fd); if (p == MAP_FAILED) { MGT_Complain(C_ERR, "Mmap error %s: %s", diff --git a/bin/varnishd/mgt/mgt_vcc.c b/bin/varnishd/mgt/mgt_vcc.c index 39e2803..863a49c 100644 --- a/bin/varnishd/mgt/mgt_vcc.c +++ b/bin/varnishd/mgt/mgt_vcc.c @@ -125,7 +125,7 @@ run_vcc(void *priv) fprintf(stderr, "VCC cannot write %s", vp->csrcfile); exit(2); } - AZ(close(fd)); + closefd(&fd); VSB_destroy(&csrc); exit(0); } @@ -216,7 +216,7 @@ mgt_vcc_touchfile(const char *fn, struct vsb *sb) if (geteuid() == 0) VSB_printf(sb, "Failed to change owner on %s: %s\n", fn, strerror(errno)); - AZ(close(i)); + closefd(&i); return (0); } diff --git a/bin/varnishd/waiter/cache_waiter_epoll.c b/bin/varnishd/waiter/cache_waiter_epoll.c index f19b20b..0a59592 100644 --- a/bin/varnishd/waiter/cache_waiter_epoll.c +++ b/bin/varnishd/waiter/cache_waiter_epoll.c @@ -146,9 +146,9 @@ vwe_thread(void *priv) if (vwe->nwaited == 0 && vwe->die) break; } - AZ(close(vwe->pipe[0])); - AZ(close(vwe->pipe[1])); - AZ(close(vwe->epfd)); + closefd(&vwe->pipe[0]); + closefd(&vwe->pipe[1]); + closefd(&vwe->epfd); return (NULL); } diff --git a/bin/varnishd/waiter/cache_waiter_kqueue.c b/bin/varnishd/waiter/cache_waiter_kqueue.c index 4832f49..e757e40 100644 --- a/bin/varnishd/waiter/cache_waiter_kqueue.c +++ b/bin/varnishd/waiter/cache_waiter_kqueue.c @@ -128,9 +128,9 @@ vwk_thread(void *priv) if (vwk->nwaited == 0 && vwk->die) break; } - AZ(close(vwk->pipe[0])); - AZ(close(vwk->pipe[1])); - AZ(close(vwk->kq)); + closefd(&vwk->pipe[0]); + closefd(&vwk->pipe[1]); + closefd(&vwk->kq); return(NULL); } diff --git a/bin/varnishd/waiter/cache_waiter_poll.c b/bin/varnishd/waiter/cache_waiter_poll.c index 282d7a8..19fde5d 100644 --- a/bin/varnishd/waiter/cache_waiter_poll.c +++ b/bin/varnishd/waiter/cache_waiter_poll.c @@ -262,8 +262,8 @@ vwp_fini(struct waiter *w) // XXX: set write pipe blocking assert(write(vwp->pipes[1], &vp, sizeof vp) == sizeof vp); AZ(pthread_join(vwp->thread, &vp)); - AZ(close(vwp->pipes[0])); - AZ(close(vwp->pipes[1])); + closefd(&vwp->pipes[0]); + closefd(&vwp->pipes[1]); free(vwp->pollfd); free(vwp->idx); } diff --git a/bin/varnishd/waiter/cache_waiter_ports.c b/bin/varnishd/waiter/cache_waiter_ports.c index 5b11be3..a7b2e47 100644 --- a/bin/varnishd/waiter/cache_waiter_ports.c +++ b/bin/varnishd/waiter/cache_waiter_ports.c @@ -256,7 +256,7 @@ vws_fini(struct waiter *w) CAST_OBJ_NOTNULL(vws, w->priv, VWS_MAGIC); vws->die = 1; - AZ(close(vws->dport)); + closefd(&vws->dport); AZ(pthread_join(vws->thread, &vp)); } From phk at FreeBSD.org Sat Jan 14 19:49:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Sat, 14 Jan 2017 20:49:05 +0100 Subject: [master] 0226b32 Don't use sprintf(3) Message-ID: commit 0226b328c2dcbae93b263fa4da033a9417f7e814 Author: Poul-Henning Kamp Date: Sat Jan 14 19:47:58 2017 +0000 Don't use sprintf(3) diff --git a/bin/varnishadm/varnishadm.c b/bin/varnishadm/varnishadm.c index b3823d8..421e3c5 100644 --- a/bin/varnishadm/varnishadm.c +++ b/bin/varnishadm/varnishadm.c @@ -62,6 +62,7 @@ #include "vapi/vsm.h" #include "vas.h" #include "vcli.h" +#include "vdef.h" #include "vnum.h" #include "vtcp.h" @@ -302,7 +303,7 @@ interactive(int sock) RL_EXIT(1); } - sprintf(buf, "%u\n", status); + bprintf(buf, "%u\n", status); u = write(1, buf, strlen(buf)); if (answer) { u = write(1, answer, strlen(answer)); @@ -352,7 +353,7 @@ pass(int sock) RL_EXIT(1); } - sprintf(buf, "%u\n", status); + bprintf(buf, "%u\n", status); u = write(1, buf, strlen(buf)); if (answer) { u = write(1, answer, strlen(answer)); diff --git a/bin/varnishd/cache/cache_shmlog.c b/bin/varnishd/cache/cache_shmlog.c index a294d65..cc3345d 100644 --- a/bin/varnishd/cache/cache_shmlog.c +++ b/bin/varnishd/cache/cache_shmlog.c @@ -401,7 +401,7 @@ VSLb_bin(struct vsl_log *vsl, enum VSL_tag_e tag, ssize_t len, const void *ptr) assert(VSL_END(vsl->wlp, len * 2 + 1) < vsl->wle); p = VSL_DATA(vsl->wlp); for (ll = 0; ll < len; ll++) { - (void)sprintf(p, "%02x", *pp++); + assert(snprintf(p, 3, "%02x", *pp++) == 2); p += 2; } if (suff) diff --git a/bin/varnishd/http2/cache_http2_deliver.c b/bin/varnishd/http2/cache_http2_deliver.c index db94d1d..b69b45d 100644 --- a/bin/varnishd/http2/cache_http2_deliver.c +++ b/bin/varnishd/http2/cache_http2_deliver.c @@ -130,7 +130,7 @@ h2_deliver(struct req *req, struct boc *boc, int sendbody) *p++ = 0x18; *p++ = 0x03; - (void)sprintf((char*)p, "%03d", req->resp->status); + assert(snprintf((char*)p, 4, "%03d", req->resp->status) == 3); p += 3; break; } diff --git a/bin/varnishd/mgt/mgt_child.c b/bin/varnishd/mgt/mgt_child.c index d46f42d..f6fc0c3 100644 --- a/bin/varnishd/mgt/mgt_child.c +++ b/bin/varnishd/mgt/mgt_child.c @@ -265,7 +265,7 @@ child_sigsegv_handler(int s, siginfo_t *si, void *c) (void)s; (void)c; - sprintf(buf, "Segmentation fault by instruction at %p", si->si_addr); + bprintf(buf, "Segmentation fault by instruction at %p", si->si_addr); VAS_Fail(__func__, __FILE__, __LINE__, diff --git a/bin/varnishtest/vtc_http.c b/bin/varnishtest/vtc_http.c index 70e226c..419491a 100644 --- a/bin/varnishtest/vtc_http.c +++ b/bin/varnishtest/vtc_http.c @@ -501,7 +501,7 @@ http_splitheader(struct http *hp, int req) assert(*p == '\0'); for (n = 0; n < 3 || hh[n] != NULL; n++) { - sprintf(buf, "http[%2d] ", n); + bprintf(buf, "http[%2d] ", n); vtc_dump(hp->vl, 4, buf, hh[n], -1); } } @@ -615,7 +615,7 @@ http_swallow_body(struct http *hp, char * const *hh, int body) vtc_dump(hp->vl, 4, "body", hp->body, ll); ll = hp->rxbuf + hp->prxbuf - hp->body; hp->bodyl = ll; - sprintf(hp->bodylen, "%d", ll); + bprintf(hp->bodylen, "%d", ll); return; } p = http_find_header(hh, "content-length"); @@ -635,7 +635,7 @@ http_swallow_body(struct http *hp, char * const *hh, int body) vtc_dump(hp->vl, 4, "rxeof", hp->body, ll); } hp->bodyl = ll; - sprintf(hp->bodylen, "%d", ll); + bprintf(hp->bodylen, "%d", ll); } /********************************************************************** @@ -1197,7 +1197,7 @@ cmd_http_rxchunk(CMD_ARGS) if (i == 0) { ll = hp->rxbuf + hp->prxbuf - hp->body; hp->bodyl = ll; - sprintf(hp->bodylen, "%d", ll); + bprintf(hp->bodylen, "%d", ll); vtc_log(hp->vl, 4, "bodylen = %s", hp->bodylen); } } @@ -1952,7 +1952,7 @@ xxx(void) for(n = 0; n < 999999999; n++) { *ibuf = 0; for (j = 0; j < 7; j++) { - sprintf(strchr(ibuf, 0), "%x", + snprintf(strchr(ibuf, 0), 5, "%x", (unsigned)random() & 0xffff); vz.next_in = TRUST_ME(ibuf); vz.avail_in = strlen(ibuf); diff --git a/lib/libvarnish/vcli_proto.c b/lib/libvarnish/vcli_proto.c index e9ea299..ee36362 100644 --- a/lib/libvarnish/vcli_proto.c +++ b/lib/libvarnish/vcli_proto.c @@ -65,7 +65,7 @@ VCLI_AuthResponse(int S_fd, const char *challenge, SHA256_Update(&ctx, "\n", 1); SHA256_Final(buf, &ctx); for(i = 0; i < SHA256_LEN; i++) - sprintf(response + 2 * i, "%02x", buf[i]); + assert(snprintf(response + 2 * i, 3, "%02x", buf[i]) == 2); } int diff --git a/lib/libvcc/vcc_acl.c b/lib/libvcc/vcc_acl.c index 8a8a87a..532d1bf 100644 --- a/lib/libvcc/vcc_acl.c +++ b/lib/libvcc/vcc_acl.c @@ -458,7 +458,7 @@ vcc_acl_emit(struct vcc *tl, const char *acln, int anon) } void -vcc_Acl_Hack(struct vcc *tl, char *b) +vcc_Acl_Hack(struct vcc *tl, char *b, size_t bl) { char acln[32]; unsigned tcond; @@ -469,8 +469,8 @@ vcc_Acl_Hack(struct vcc *tl, char *b) bprintf(acln, "%u", tl->unique++); vcc_acl_entry(tl); vcc_acl_emit(tl, acln, 1); - sprintf(b, "%smatch_acl_anon_%s(ctx, \v1)", - (tcond == T_NEQ ? "!" : ""), acln); + assert(snprintf(b, bl - 1, "%smatch_acl_anon_%s(ctx, \v1)", + (tcond == T_NEQ ? "!" : ""), acln) < bl - 1); } void diff --git a/lib/libvcc/vcc_backend.c b/lib/libvcc/vcc_backend.c index a5b5b5e..7909044 100644 --- a/lib/libvcc/vcc_backend.c +++ b/lib/libvcc/vcc_backend.c @@ -478,7 +478,7 @@ vcc_ParseBackend(struct vcc *tl) t_be = tl->t; vcc_NextToken(tl); - sprintf(vgcname, "vgc_backend_%.*s", PF(t_be)); + bprintf(vgcname, "vgc_backend_%.*s", PF(t_be)); Fh(tl, 0, "\nstatic struct director *%s;\n", vgcname); sym = VCC_HandleSymbol(tl, t_be, BACKEND, "%s", vgcname); diff --git a/lib/libvcc/vcc_compile.h b/lib/libvcc/vcc_compile.h index d4b3964..fd7daf1 100644 --- a/lib/libvcc/vcc_compile.h +++ b/lib/libvcc/vcc_compile.h @@ -233,7 +233,7 @@ struct method { /* vcc_acl.c */ void vcc_ParseAcl(struct vcc *tl); -void vcc_Acl_Hack(struct vcc *tl, char *b); +void vcc_Acl_Hack(struct vcc *tl, char *b, size_t bl); /* vcc_action.c */ int vcc_ParseAction(struct vcc *tl); diff --git a/lib/libvcc/vcc_expr.c b/lib/libvcc/vcc_expr.c index ce7ab89..d97c5f7 100644 --- a/lib/libvcc/vcc_expr.c +++ b/lib/libvcc/vcc_expr.c @@ -1197,7 +1197,7 @@ vcc_expr_cmp(struct vcc *tl, struct expr **e, vcc_type_t fmt) return; } if ((*e)->fmt == IP && (tl->t->tok == T_EQ || tl->t->tok == T_NEQ)) { - vcc_Acl_Hack(tl, buf); + vcc_Acl_Hack(tl, buf, sizeof buf); *e = vcc_expr_edit(BOOL, buf, *e, NULL); return; } diff --git a/lib/libvcc/vcc_utils.c b/lib/libvcc/vcc_utils.c index a95c20c..89ccccc 100644 --- a/lib/libvcc/vcc_utils.c +++ b/lib/libvcc/vcc_utils.c @@ -66,7 +66,7 @@ vcc_regexp(struct vcc *tl) return (NULL); } VRE_free(&t); - sprintf(buf, "VGC_re_%u", tl->unique++); + bprintf(buf, "VGC_re_%u", tl->unique++); p = TlAlloc(tl, strlen(buf) + 1); strcpy(p, buf); @@ -124,7 +124,7 @@ vcc_suckaddr(struct vcc *tl, const char *host, const struct suckaddr *vsa, q = TlAlloc(tl, 40); AN(q); - sprintf(q, "(const void*)suckaddr_%u", tl->unique); + assert(snprintf(q, 40, "(const void*)suckaddr_%u", tl->unique) < 40); *ip = q; tl->unique++; } diff --git a/lib/libvmod_debug/vmod_debug.c b/lib/libvmod_debug/vmod_debug.c index 9b4e5e7..023cdc3 100644 --- a/lib/libvmod_debug/vmod_debug.c +++ b/lib/libvmod_debug/vmod_debug.c @@ -168,7 +168,7 @@ vmod_blob2hex(VRT_CTX, VCL_BLOB b) p = s; q = b->priv; for (i = 0; i < b->len; i++) { - sprintf(p, "%02x", *q); + assert(snprintf(p, 3, "%02x", *q) == 2); p += 2; q += 1; } diff --git a/lib/libvmod_directors/shard_cfg.c b/lib/libvmod_directors/shard_cfg.c index 3f91aab..20e9b32 100644 --- a/lib/libvmod_directors/shard_cfg.c +++ b/lib/libvmod_directors/shard_cfg.c @@ -264,7 +264,7 @@ shardcfg_hashcircle(struct sharddir *shardd, VCL_INT replicas, enum alg_e alg) char s[len]; for (j = 0; j < replicas; j++) { - sprintf(s, "%s%d", ident, j); + assert(snprintf(s, len, "%s%d", ident, j) < len); shardd->hashcircle[i * replicas + j].point = shard_hash_f[alg](s); shardd->hashcircle[i * replicas + j].host = i; From phk at FreeBSD.org Sat Jan 14 20:27:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Sat, 14 Jan 2017 21:27:05 +0100 Subject: [master] f584f90 Disallow starting without either -b or -f in all other modes than -d. Message-ID: commit f584f901bd2330d36a9c6e22efea8142d85e01a3 Author: Poul-Henning Kamp Date: Sat Jan 14 20:25:32 2017 +0000 Disallow starting without either -b or -f in all other modes than -d. Allow -f '' as an override for people who really want this. diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index eb5cbb8..e0997ce 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -436,6 +436,7 @@ main(int argc, char * const *argv) int o, eric_fd = -1; unsigned C_flag = 0; unsigned F_flag = 0; + unsigned V_flag = 0; const char *b_arg = NULL; const char *f_arg = NULL; const char *i_arg = NULL; @@ -460,6 +461,9 @@ main(int argc, char * const *argv) struct sigaction sac; struct vev *e; + setbuf(stdout, NULL); + setbuf(stderr, NULL); + mgt_tests(); mgt_initialize(cli); @@ -490,6 +494,9 @@ main(int argc, char * const *argv) case 'j': j_arg = optarg; break; + case 'V': + V_flag = 1; + break; case 'x': x_arg = optarg; break; @@ -501,6 +508,12 @@ main(int argc, char * const *argv) if (argc != optind) ARGV_ERR("Too many arguments (%s...)\n", argv[optind]); + if (V_flag) { + if (argc != 2) + ARGV_ERR("-V is incompatible with everything else\n"); + VCS_Message("varnishd"); + exit(0); + } if (x_arg != NULL) { if (argc != 3) ARGV_ERR("-x is incompatible with everything else\n"); @@ -514,7 +527,7 @@ main(int argc, char * const *argv) if (d_flag && F_flag) ARGV_ERR("Only one of -d or -F can be specified\n"); - if (C_flag && b_arg == NULL && f_arg == NULL) + if (C_flag && b_arg == NULL && (f_arg == NULL || *f_arg == '\0')) ARGV_ERR("-C needs either -b or -f \n"); if (d_flag && C_flag) @@ -523,6 +536,12 @@ main(int argc, char * const *argv) if (F_flag && C_flag) ARGV_ERR("-F makes no sense with -C\n"); + if (!d_flag && b_arg == NULL && f_arg == NULL) + ARGV_ERR("Neither -b nor -f given. (use -f '' to override)\n"); + + if (f_arg != NULL && *f_arg == '\0') + f_arg = NULL; + /* * Start out by closing all unwanted file descriptors we might * have inherited from sloppy process control daemons. @@ -530,9 +549,6 @@ main(int argc, char * const *argv) VSUB_closefrom(STDERR_FILENO + 1); MCH_TrackHighFd(STDERR_FILENO); - setbuf(stdout, NULL); - setbuf(stderr, NULL); - /* * Have Eric Daemonize us if need be */ @@ -542,10 +558,6 @@ main(int argc, char * const *argv) mgt_pid = getpid(); } -#ifdef HAVE_SETPROCTITLE - setproctitle("Varnish-Mgr %s", heritage.name); -#endif - /* Set up the mgt counters */ memset(&static_VSC_C_mgt, 0, sizeof static_VSC_C_mgt); VSC_C_mgt = &static_VSC_C_mgt; @@ -576,6 +588,7 @@ main(int argc, char * const *argv) case 'f': case 'F': case 'j': + case 'V': case 'x': /* Handled in first pass */ break; @@ -642,10 +655,6 @@ main(int argc, char * const *argv) case 't': MCF_ParamSet(cli, "default_ttl", optarg); break; - case 'V': - /* XXX: we should print the ident here */ - VCS_Message("varnishd"); - exit(0); case 'W': W_arg = optarg; break; @@ -695,6 +704,10 @@ main(int argc, char * const *argv) if (VIN_N_Arg(n_arg, &heritage.name, &dirname, NULL) != 0) ARGV_ERR("Invalid instance (-n) name: %s\n", strerror(errno)); +#ifdef HAVE_SETPROCTITLE + setproctitle("Varnish-Mgr %s", heritage.name); +#endif + identify(i_arg); if (VJ_make_workdir(dirname)) @@ -735,16 +748,6 @@ main(int argc, char * const *argv) assert(! VTAILQ_EMPTY(&heritage.socks)); - if (!d_flag) { - if (b_arg == NULL && f_arg == NULL) { - fprintf(stderr, - "Warning: Neither -b nor -f given," - " won't start a worker child.\n" - " Master process started," - " use varnishadm to control it.\n"); - } - } - HSH_config(h_arg); Wait_config(W_arg); diff --git a/bin/varnishtest/tests/a00009.vtc b/bin/varnishtest/tests/a00009.vtc index 27db34b..023f4ea 100644 --- a/bin/varnishtest/tests/a00009.vtc +++ b/bin/varnishtest/tests/a00009.vtc @@ -12,8 +12,8 @@ err_shell {VCL version declaration missing} { echo 'bad vcl' > ${tmpdir}/t.vcl varnishd -C -f ${tmpdir}/t.vcl -n ${tmpdir} 2>&1 } -err_shell {-spersistent has been deprecated} "varnishd -spersistent 2>&1" -err_shell {Unknown jail method "xyz"} "varnishd -jxyz 2>&1" +err_shell {-spersistent has been deprecated} "varnishd -spersistent -f '' 2>&1" +err_shell {Unknown jail method "xyz"} "varnishd -jxyz -f '' 2>&1" err_shell {-x is incompatible with everything else} "varnishd -d -x foo 2>&1" err_shell {Invalid -x argument} "varnishd -x foo 2>&1" err_shell {Too many arguments} "varnishd foo 2>&1" @@ -24,10 +24,10 @@ err_shell {-C needs either -b or -f } \ err_shell {-d makes no sense with -C} "varnishd -C -b 127.0.0.1:80 -d 2>&1" err_shell {-F makes no sense with -C} "varnishd -C -b 127.0.0.1:80 -F 2>&1" err_shell {usage: varnishd [options]} "varnishd -? 2>&1" -err_shell {Invalid backslash sequence} {varnishd -l 'xyz\kk,xyz\foo' 2>&1} -err_shell {Invalid backslash sequence} {varnishd -l 'ab\8cd' 2>&1} -err_shell {Copyright (c) 2006} "varnishd -V 2>&1" +err_shell {Invalid backslash sequence} {varnishd -l 'xyz\kk,xyz\foo' -f '' 2>&1} +err_shell {Invalid backslash sequence} {varnishd -l 'ab\8cd' -f '' 2>&1} +err_shell {Copyright (c) 2006} "varnishd -V 2>&1 ; exit 1" err_shell {usage: varnishd [options]} "varnishd -A 2>&1" err_shell {Cannot open -S file} { - varnishd -S ${tmpdir}/nonexistent -n ${tmpdir}/v0 2>&1 + varnishd -S ${tmpdir}/nonexistent -n ${tmpdir}/v0 -f '' 2>&1 } From phk at FreeBSD.org Sat Jan 14 21:24:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Sat, 14 Jan 2017 22:24:05 +0100 Subject: [master] 9691055 Catch up with -f requirement Message-ID: commit 969105548569e02344df359b01f46851c0a296f8 Author: Poul-Henning Kamp Date: Sat Jan 14 21:19:57 2017 +0000 Catch up with -f requirement diff --git a/bin/varnishtest/tests/j00002.vtc b/bin/varnishtest/tests/j00002.vtc index f037dee..f4b6aed 100644 --- a/bin/varnishtest/tests/j00002.vtc +++ b/bin/varnishtest/tests/j00002.vtc @@ -2,7 +2,7 @@ varnishtest "-junix bad subarg handling" feature root -err_shell "unknown sub-argument" "varnishd -junix,bla=foo 2>&1" -err_shell "user not found" "varnishd -junix,user=/// 2>&1" -err_shell "user not found" "varnishd -junix,workuser=/// 2>&1" -err_shell "group not found" "varnishd -junix,ccgroup=/// 2>&1" +err_shell "unknown sub-argument" "varnishd -junix,bla=foo -f '' 2>&1" +err_shell "user not found" "varnishd -junix,user=/// -f '' 2>&1" +err_shell "user not found" "varnishd -junix,workuser=/// -f '' 2>&1" +err_shell "group not found" "varnishd -junix,ccgroup=/// -f '' 2>&1" diff --git a/bin/varnishtest/tests/j00003.vtc b/bin/varnishtest/tests/j00003.vtc index 50553b4..921d212 100644 --- a/bin/varnishtest/tests/j00003.vtc +++ b/bin/varnishtest/tests/j00003.vtc @@ -3,4 +3,4 @@ varnishtest "-junix bad subarg handling" feature root feature user_varnish -err_shell "have different login groups" "varnishd -junix,workuser=root 2>&1" +err_shell "have different login groups" "varnishd -junix,workuser=root -f '' 2>&1" From phk at FreeBSD.org Sat Jan 14 21:24:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Sat, 14 Jan 2017 22:24:05 +0100 Subject: [master] d306f91 Rework the -f/-b logic so we can take multiple -f arguments. Message-ID: commit d306f91ca2128361f64b14c7c4a7de6f08a1f9b9 Author: Poul-Henning Kamp Date: Sat Jan 14 21:20:13 2017 +0000 Rework the -f/-b logic so we can take multiple -f arguments. If you give multiple -f arguments, the resulting VCL's will be "boot0", "boot1", ... "boot668", "boot" And the last one will be the active one. The plan is to also allow both specification of an (optional) label and which VCL is to be the active one, but I want to think about if we should shoehorn that into -f or use a different option letter. diff --git a/bin/varnishd/mgt/mgt.h b/bin/varnishd/mgt/mgt.h index d5a1381..2c88cb4 100644 --- a/bin/varnishd/mgt/mgt.h +++ b/bin/varnishd/mgt/mgt.h @@ -182,8 +182,8 @@ char *mgt_VccCompile(struct cli *, struct vclprog *, const char *vclname, const char *vclsrc, const char *vclsrcfile, int C_flag); void mgt_vcl_init(void); -void mgt_vcl_startup(struct cli *, const char *b_arg, const char *f_arg, - const char *vclsrc, int Cflag); +void mgt_vcl_startup(struct cli *, const char *vclsrc, const char *origin, + const char *vclname, int Cflag); int mgt_push_vcls_and_start(struct cli *, unsigned *status, char **p); void mgt_vcl_export_labels(struct vcc *); int mgt_has_vcl(void); diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index e0997ce..2d1f6c9 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -52,6 +52,7 @@ #include "vin.h" #include "vpf.h" #include "vrnd.h" +#include "vsb.h" #include "vsha256.h" #include "vsub.h" #include "vtim.h" @@ -430,15 +431,23 @@ mgt_uptime(const struct vev *e, int what) /*--------------------------------------------------------------------*/ +struct f_arg { + unsigned magic; +#define F_ARG_MAGIC 0x840649a8 + char *farg; + char *src; + VTAILQ_ENTRY(f_arg) list; +}; + int main(int argc, char * const *argv) { int o, eric_fd = -1; unsigned C_flag = 0; + unsigned f_flag = 0; unsigned F_flag = 0; unsigned V_flag = 0; const char *b_arg = NULL; - const char *f_arg = NULL; const char *i_arg = NULL; const char *j_arg = NULL; const char *h_arg = "critbit"; @@ -451,7 +460,7 @@ main(int argc, char * const *argv) const char *x_arg = NULL; int s_arg_given = 0; const char *T_arg = "localhost:0"; - char *p, *vcl = NULL; + char *p; struct cli cli[1]; char *dirname; char **av; @@ -460,6 +469,9 @@ main(int argc, char * const *argv) unsigned u; struct sigaction sac; struct vev *e; + struct f_arg *fa; + struct vsb *vsb; + VTAILQ_HEAD(,f_arg) f_args = VTAILQ_HEAD_INITIALIZER(f_args); setbuf(stdout, NULL); setbuf(stderr, NULL); @@ -486,7 +498,7 @@ main(int argc, char * const *argv) d_flag++; break; case 'f': - f_arg = optarg; + f_flag = 1; break; case 'F': F_flag = 1; @@ -521,13 +533,13 @@ main(int argc, char * const *argv) exit(0); } - if (b_arg != NULL && f_arg != NULL) + if (b_arg != NULL && f_flag) ARGV_ERR("Only one of -b or -f can be specified\n"); if (d_flag && F_flag) ARGV_ERR("Only one of -d or -F can be specified\n"); - if (C_flag && b_arg == NULL && (f_arg == NULL || *f_arg == '\0')) + if (C_flag && b_arg == NULL && !f_flag) ARGV_ERR("-C needs either -b or -f \n"); if (d_flag && C_flag) @@ -536,12 +548,9 @@ main(int argc, char * const *argv) if (F_flag && C_flag) ARGV_ERR("-F makes no sense with -C\n"); - if (!d_flag && b_arg == NULL && f_arg == NULL) + if (!d_flag && b_arg == NULL && !f_flag) ARGV_ERR("Neither -b nor -f given. (use -f '' to override)\n"); - if (f_arg != NULL && *f_arg == '\0') - f_arg = NULL; - /* * Start out by closing all unwanted file descriptors we might * have inherited from sloppy process control daemons. @@ -582,10 +591,8 @@ main(int argc, char * const *argv) optreset = 1; while ((o = getopt(argc, argv, opt_spec)) != -1) { switch (o) { - case 'b': case 'C': case 'd': - case 'f': case 'F': case 'j': case 'V': @@ -595,6 +602,34 @@ main(int argc, char * const *argv) case 'a': MAC_Arg(optarg); break; + case 'b': + ALLOC_OBJ(fa, F_ARG_MAGIC); + AN(fa); + REPLACE(fa->farg, "<-b argument>"); + vsb = VSB_new_auto(); + AN(vsb); + VSB_printf(vsb, "vcl 4.0;\n"); + VSB_printf(vsb, "backend default {\n"); + VSB_printf(vsb, " .host = \"%s\";\n", optarg); + VSB_printf(vsb, "}\n"); + AZ(VSB_finish(vsb)); + fa->src = strdup(VSB_data(vsb)); + AN(fa->src); + VSB_destroy(&vsb); + VTAILQ_INSERT_TAIL(&f_args, fa, list); + break; + case 'f': + if (*optarg == '\0') + break; + ALLOC_OBJ(fa, F_ARG_MAGIC); + AN(fa); + REPLACE(fa->farg, optarg); + fa->src = VFIL_readfile(NULL, fa->farg, NULL); + if (fa->src == NULL) + ARGV_ERR("Cannot read -f file (%s): %s\n", + fa->farg, strerror(errno)); + VTAILQ_INSERT_TAIL(&f_args, fa, list); + break; case 'h': h_arg = optarg; break; @@ -679,7 +714,6 @@ main(int argc, char * const *argv) } assert(d_flag == 0 || F_flag == 0); - assert(b_arg == NULL || f_arg == NULL); if (S_arg != NULL && !strcmp(S_arg, "none")) { fprintf(stderr, @@ -694,13 +728,6 @@ main(int argc, char * const *argv) VJ_master(JAIL_MASTER_LOW); } - if (f_arg != NULL) { - vcl = VFIL_readfile(NULL, f_arg, NULL); - if (vcl == NULL) - ARGV_ERR("Cannot read -f file (%s): %s\n", - f_arg, strerror(errno)); - } - if (VIN_N_Arg(n_arg, &heritage.name, &dirname, NULL) != 0) ARGV_ERR("Invalid instance (-n) name: %s\n", strerror(errno)); @@ -729,19 +756,29 @@ main(int argc, char * const *argv) mgt_vcl_init(); - if (b_arg != NULL || f_arg != NULL) { - mgt_vcl_startup(cli, b_arg, f_arg, vcl, C_flag); - if (C_flag) { - if (Cn_arg == n_arg) - (void)rmdir(Cn_arg); + if (C_flag) { + VTAILQ_FOREACH(fa, &f_args, list) { + mgt_vcl_startup(cli, fa->src, + VTAILQ_NEXT(fa, list) == NULL ? "boot" : NULL, + fa->farg, 1); AZ(VSB_finish(cli->sb)); fprintf(stderr, "%s\n", VSB_data(cli->sb)); - exit(cli->result == CLIS_OK ? 0 : 2); + VSB_clear(cli->sb); + } + (void)rmdir(Cn_arg); + exit(cli->result == CLIS_OK ? 0 : 2); + } else { + while(!VTAILQ_EMPTY(&f_args)) { + fa = VTAILQ_FIRST(&f_args); + VTAILQ_REMOVE(&f_args, fa, list); + mgt_vcl_startup(cli, fa->src, + VTAILQ_EMPTY(&f_args) ? "boot" : NULL, + fa->farg, 0); + cli_check(cli); + free(fa->src); + FREE_OBJ(fa); } - cli_check(cli); - free(vcl); } - AZ(C_flag); if (VTAILQ_EMPTY(&heritage.socks)) MAC_Arg(":80"); diff --git a/bin/varnishd/mgt/mgt_vcl.c b/bin/varnishd/mgt/mgt_vcl.c index c70c05d..9d22352 100644 --- a/bin/varnishd/mgt/mgt_vcl.c +++ b/bin/varnishd/mgt/mgt_vcl.c @@ -369,25 +369,20 @@ mgt_new_vcl(struct cli *cli, const char *vclname, const char *vclsrc, /*--------------------------------------------------------------------*/ void -mgt_vcl_startup(struct cli *cli, const char *b_arg, const char *f_arg, - const char *vclsrc, int C_flag) +mgt_vcl_startup(struct cli *cli, const char *vclsrc, const char *vclname, + const char *origin, int C_flag) { - char buf[BUFSIZ]; + char buf[20]; + static int n = 0; - if (b_arg == NULL) { - AN(vclsrc); - AN(f_arg); - mgt_new_vcl(cli, "boot", vclsrc, f_arg, NULL, C_flag); - return; + AN(vclsrc); + AN(origin); + if (vclname == NULL) { + bprintf(buf, "boot%d", n++); + vclname = buf; } - - AZ(vclsrc); - bprintf(buf, - "vcl 4.0;\n" - "backend default {\n" - " .host = \"%s\";\n" - "}\n", b_arg); - mgt_new_vcl(cli, "boot", buf, "<-b argument>", NULL, C_flag); + mgt_new_vcl(cli, vclname, vclsrc, origin, NULL, C_flag); + active_vcl = mcf_vcl_byname(vclname); } /*--------------------------------------------------------------------*/ From fgsch at lodoss.net Sat Jan 14 23:45:04 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sun, 15 Jan 2017 00:45:04 +0100 Subject: [master] 7f9a97a Speed things up Message-ID: commit 7f9a97ad341a6b0cb121f8573e7bd8f57637905c Author: Federico G. Schwindt Date: Sat Jan 14 21:04:42 2017 +0000 Speed things up Add bad_backend macro and use it instead of ${bad_ip}/port, should shave a few seconds here and there. While here also replace some unneeded ${bad_ip} entries. diff --git a/bin/varnishtest/tests/b00015.vtc b/bin/varnishtest/tests/b00015.vtc index ec1990f..cc6df6d 100644 --- a/bin/varnishtest/tests/b00015.vtc +++ b/bin/varnishtest/tests/b00015.vtc @@ -4,8 +4,7 @@ varnishtest "Check synthetic error page caching" varnish v1 -vcl { backend foo { - .host = "${bad_ip}"; - .port = "9080"; + .host = "${bad_backend}"; } } -start diff --git a/bin/varnishtest/tests/b00017.vtc b/bin/varnishtest/tests/b00017.vtc index d0088aa..42c96fe 100644 --- a/bin/varnishtest/tests/b00017.vtc +++ b/bin/varnishtest/tests/b00017.vtc @@ -2,8 +2,7 @@ varnishtest "Check that we do not close one error" varnish v1 -vcl { backend foo { - .host = "${bad_ip}"; - .port = "9080"; + .host = "${bad_backend}"; } sub vcl_recv { return (synth(888)); diff --git a/bin/varnishtest/tests/c00028.vtc b/bin/varnishtest/tests/c00028.vtc index 7ecfb7c..0399e9f 100644 --- a/bin/varnishtest/tests/c00028.vtc +++ b/bin/varnishtest/tests/c00028.vtc @@ -2,8 +2,7 @@ varnishtest "Test that we can't recurse restarts forever" varnish v1 -vcl { backend bad { - .host = "${bad_ip}"; - .port = "9090"; + .host = "${bad_backend}"; } sub vcl_backend_fetch { diff --git a/bin/varnishtest/tests/c00061.vtc b/bin/varnishtest/tests/c00061.vtc index b22f259..d41ca79 100644 --- a/bin/varnishtest/tests/c00061.vtc +++ b/bin/varnishtest/tests/c00061.vtc @@ -2,7 +2,7 @@ varnishtest "retry in vcl_backend_error" varnish v1 -vcl { - backend b1 { .host = "${bad_ip}"; .port = "9080"; } + backend b1 { .host = "${bad_backend}"; } sub vcl_backend_error { return (retry); diff --git a/bin/varnishtest/tests/c00063.vtc b/bin/varnishtest/tests/c00063.vtc index 9da60a0..b5c2cfe 100644 --- a/bin/varnishtest/tests/c00063.vtc +++ b/bin/varnishtest/tests/c00063.vtc @@ -2,7 +2,7 @@ varnishtest "cache backend synth object" varnish v1 -vcl { - backend b { .host = "${bad_ip}"; .port = "9080"; } + backend b { .host = "${bad_backend}"; } sub vcl_backend_error { set beresp.ttl = 1s; diff --git a/bin/varnishtest/tests/c00066.vtc b/bin/varnishtest/tests/c00066.vtc index 7d8f972..0472415 100644 --- a/bin/varnishtest/tests/c00066.vtc +++ b/bin/varnishtest/tests/c00066.vtc @@ -6,7 +6,7 @@ server s1 { } -start varnish v1 -vcl+backend { - backend bad { .host = "${bad_ip}"; .port = "9080"; } + backend bad { .host = "${bad_backend}"; } sub vcl_recv { if (req.url == "/synth") { return (synth(200, "Synth test")); diff --git a/bin/varnishtest/tests/d00007.vtc b/bin/varnishtest/tests/d00007.vtc index cdc889c..eac4a4d 100644 --- a/bin/varnishtest/tests/d00007.vtc +++ b/bin/varnishtest/tests/d00007.vtc @@ -8,7 +8,7 @@ server s1 { varnish v1 -vcl { import debug; - backend dummy { .host = "${bad_ip}"; .port = "9080"; } + backend dummy { .host = "${bad_backend}"; } sub vcl_init { new s1 = debug.dyn("${s1_addr}", "${s1_port}"); diff --git a/bin/varnishtest/tests/d00008.vtc b/bin/varnishtest/tests/d00008.vtc index 465fcda..8fd71b9 100644 --- a/bin/varnishtest/tests/d00008.vtc +++ b/bin/varnishtest/tests/d00008.vtc @@ -15,7 +15,7 @@ server s2 { varnish v1 -vcl { import debug; - backend dummy { .host = "${bad_ip}"; .port = "9080"; } + backend dummy { .host = "${bad_backend}"; } sub vcl_init { new s1 = debug.dyn("${s1_addr}", "${s1_port}"); diff --git a/bin/varnishtest/tests/d00009.vtc b/bin/varnishtest/tests/d00009.vtc index fd30602..1318e7a 100644 --- a/bin/varnishtest/tests/d00009.vtc +++ b/bin/varnishtest/tests/d00009.vtc @@ -21,7 +21,7 @@ server s2 { varnish v1 -vcl { import debug; - backend dummy { .host = "${bad_ip}"; .port = "9080"; } + backend dummy { .host = "${bad_backend}"; } sub vcl_init { new s1 = debug.dyn("${s1_addr}", "${s1_port}"); diff --git a/bin/varnishtest/tests/d00010.vtc b/bin/varnishtest/tests/d00010.vtc index 4646ec2..6963e59 100644 --- a/bin/varnishtest/tests/d00010.vtc +++ b/bin/varnishtest/tests/d00010.vtc @@ -21,7 +21,7 @@ server s2 { varnish v1 -vcl { import debug; - backend dummy { .host = "${bad_ip}"; .port = "9080"; } + backend dummy { .host = "${bad_backend}"; } sub vcl_init { new s1 = debug.dyn("${s1_addr}", "${s1_port}"); diff --git a/bin/varnishtest/tests/d00011.vtc b/bin/varnishtest/tests/d00011.vtc index f2fb3a4..21fd684 100644 --- a/bin/varnishtest/tests/d00011.vtc +++ b/bin/varnishtest/tests/d00011.vtc @@ -14,7 +14,7 @@ varnish v1 -vcl { import std; import debug; - backend dummy { .host = "${bad_ip}"; .port = "9080"; } + backend dummy { .host = "${bad_backend}"; } sub vcl_init { new s1 = debug.dyn("${s1_addr}", "${s1_port}"); diff --git a/bin/varnishtest/tests/d00012.vtc b/bin/varnishtest/tests/d00012.vtc index bca1c5b..8e5f25f 100644 --- a/bin/varnishtest/tests/d00012.vtc +++ b/bin/varnishtest/tests/d00012.vtc @@ -16,7 +16,7 @@ server s1 { varnish v1 -arg "-p thread_pools=1" -vcl { import debug; - backend dummy { .host = "${bad_ip}"; .port = "9080"; } + backend dummy { .host = "${bad_backend}"; } sub vcl_init { new s1 = debug.dyn("${s1_addr}", "${s1_port}"); @@ -47,7 +47,7 @@ barrier b1 sync varnish v1 -vcl { import debug; - backend dummy { .host = "${bad_ip}"; .port = "9080"; } + backend dummy { .host = "${bad_backend}"; } sub vcl_init { new s2 = debug.dyn("${s2_addr}", "${s2_port}"); diff --git a/bin/varnishtest/tests/d00013.vtc b/bin/varnishtest/tests/d00013.vtc index 12457bf..a9b1826 100644 --- a/bin/varnishtest/tests/d00013.vtc +++ b/bin/varnishtest/tests/d00013.vtc @@ -14,7 +14,7 @@ varnish v1 -vcl { import std; import debug; - backend dummy { .host = "${bad_ip}"; .port = "9080"; } + backend dummy { .host = "${bad_backend}"; } sub vcl_init { new s1 = debug.dyn("${s1_addr}", "${s1_port}"); diff --git a/bin/varnishtest/tests/m00025.vtc b/bin/varnishtest/tests/m00025.vtc index cdd6a8e..432043f 100644 --- a/bin/varnishtest/tests/m00025.vtc +++ b/bin/varnishtest/tests/m00025.vtc @@ -3,7 +3,7 @@ varnishtest "Pass probe definitions to VMODs" varnish v1 -vcl { import debug; - backend be { .host = "${bad_ip}"; } + backend be { .host = "127.0.0.1"; } probe pb { } sub vcl_init { diff --git a/bin/varnishtest/tests/m00026.vtc b/bin/varnishtest/tests/m00026.vtc index 17ca1ed..8c5f717 100644 --- a/bin/varnishtest/tests/m00026.vtc +++ b/bin/varnishtest/tests/m00026.vtc @@ -3,7 +3,7 @@ varnishtest "Test std.getenv" varnish v1 -vcl { import std; - backend dummy { .host = "${bad_ip}"; .port = "9080"; } + backend dummy { .host = "${bad_backend}"; } sub vcl_recv { return(synth(200)); diff --git a/bin/varnishtest/tests/r00948.vtc b/bin/varnishtest/tests/r00948.vtc index 559cbbc..d029990 100644 --- a/bin/varnishtest/tests/r00948.vtc +++ b/bin/varnishtest/tests/r00948.vtc @@ -11,10 +11,10 @@ server s1 { varnish v1 -vcl+backend { sub vcl_recv { - if (client.ip == "${s1_addr}" || client.ip == "${bad_ip}") { + if (client.ip == "${s1_addr}" || client.ip == "127.0.0.1") { set req.http.foo1 = "Match"; } - if (client.ip == "${bad_ip}" || client.ip == "${s1_addr}") { + if (client.ip == "127.0.0.1" || client.ip == "${s1_addr}") { set req.http.foo2 = "Match"; } } diff --git a/bin/varnishtest/tests/r01002.vtc b/bin/varnishtest/tests/r01002.vtc index d9bfb52..fbede7c 100644 --- a/bin/varnishtest/tests/r01002.vtc +++ b/bin/varnishtest/tests/r01002.vtc @@ -3,7 +3,7 @@ varnishtest "Real relational comparisons" varnish v1 -vcl { import std; - backend foo { .host = "${bad_ip}"; .port = "9080"; } + backend foo { .host = "127.0.0.1"; } sub vcl_recv { if (std.random(0,5) < 1.0) { return (pipe); diff --git a/bin/varnishtest/tests/r01395.vtc b/bin/varnishtest/tests/r01395.vtc index 06962db..b7e3881 100644 --- a/bin/varnishtest/tests/r01395.vtc +++ b/bin/varnishtest/tests/r01395.vtc @@ -1,10 +1,7 @@ varnishtest "Test vcl_synth is called even if vcl_backend_fetch failed" varnish v1 -vcl { - backend default { - .host = "${bad_ip}"; - .port = "9090"; - } + backend default { .host = "${bad_backend}"; } sub vcl_backend_error { set beresp.status = 299; diff --git a/bin/varnishtest/tests/r01398.vtc b/bin/varnishtest/tests/r01398.vtc index ec0003e..3f929c3 100644 --- a/bin/varnishtest/tests/r01398.vtc +++ b/bin/varnishtest/tests/r01398.vtc @@ -2,8 +2,7 @@ varnishtest "ticket 1398" varnish v1 -vcl { backend foo { - .host = "${bad_ip}"; - .port = "9080"; + .host = "${bad_backend}"; } sub vcl_backend_response { set beresp.http.X-BE-Name = beresp.backend.name; diff --git a/bin/varnishtest/tests/r01504.vtc b/bin/varnishtest/tests/r01504.vtc index 8a466f7..02182a5 100644 --- a/bin/varnishtest/tests/r01504.vtc +++ b/bin/varnishtest/tests/r01504.vtc @@ -2,8 +2,7 @@ varnishtest "unreferenced acls" varnish v1 -arg "-p vcc_err_unref=off" -vcl { backend s1 { - .host = "${bad_ip}"; - .port = "9090"; + .host = "127.0.0.1"; } acl foo { "127.0.0.1"; diff --git a/bin/varnishtest/tests/r01510.vtc b/bin/varnishtest/tests/r01510.vtc index 7e1555b..1092ff7 100644 --- a/bin/varnishtest/tests/r01510.vtc +++ b/bin/varnishtest/tests/r01510.vtc @@ -11,7 +11,7 @@ varnish v1 -errvcl {Instance 'first' redefined.} { varnish v1 -errvcl {Name 'first' already defined.} { import debug; - backend first { .host = "${bad_ip}"; .port = "9080"; } + backend first { .host = "127.0.0.1"; } sub vcl_init { new first = debug.obj("FOO"); diff --git a/bin/varnishtest/tests/r01512.vtc b/bin/varnishtest/tests/r01512.vtc index 87556f1..09e07e0 100644 --- a/bin/varnishtest/tests/r01512.vtc +++ b/bin/varnishtest/tests/r01512.vtc @@ -33,7 +33,7 @@ client c1 { # Then across v_b_e and v_b_f varnish v1 -vcl { - backend bad { .host = "${bad_ip}"; .port = "9080"; } + backend bad { .host = "${bad_backend}"; } sub vcl_backend_fetch { set bereq.backend = bad; if (bereq.http.x-abandon == "2") { diff --git a/bin/varnishtest/tests/r01730.vtc b/bin/varnishtest/tests/r01730.vtc index baef368..c7a8ec1 100644 --- a/bin/varnishtest/tests/r01730.vtc +++ b/bin/varnishtest/tests/r01730.vtc @@ -1,7 +1,7 @@ varnishtest "Test connection error on pipe" varnish v1 -vcl { - backend default { .host = "${bad_ip}"; .port = "9080"; } + backend default { .host = "${bad_backend}"; } sub vcl_recv { return (pipe); } diff --git a/bin/varnishtest/tests/r01990.vtc b/bin/varnishtest/tests/r01990.vtc index e9f5a19..7c72f0f 100644 --- a/bin/varnishtest/tests/r01990.vtc +++ b/bin/varnishtest/tests/r01990.vtc @@ -4,13 +4,12 @@ varnish v1 -vcl { import debug; backend default { - .host = "${bad_ip}"; - .port = "9090"; + .host = "${bad_backend}"; } sub vcl_backend_fetch { # avoid LostHeader b Host: %s - set bereq.http.Host = "${bad_ip}"; + set bereq.http.Host = "127.0.0.1"; debug.workspace_allocate(backend, debug.workspace_free(backend)); } diff --git a/bin/varnishtest/tests/v00021.vtc b/bin/varnishtest/tests/v00021.vtc index 44c4327..5288ff5 100644 --- a/bin/varnishtest/tests/v00021.vtc +++ b/bin/varnishtest/tests/v00021.vtc @@ -43,7 +43,7 @@ varnish v1 -errvcl "Function recurses on" { varnish v1 -errvcl {Unused acl foo, defined:} { backend b { .host = "127.0.0.1"; } - acl foo { "localhost"; } + acl foo { "127.0.0.1"; } } @@ -75,7 +75,7 @@ varnish v1 -errvcl {Invalid return "deliver"} { varnish v1 -errvcl {HTTP header (buckinghambuckingham..) is too long.} { - backend foo { .host = "${bad_ip}"; .port = "9080"; } + backend foo { .host = "127.0.0.1"; } sub vcl_deliver { set resp.http.buckinghambuckinghambuckinghambuckinghambuckinghambuckinghambuckinghambuckinghambuckinghambuckinghambuckinghambuckinghambucking = "foobar"; @@ -84,7 +84,7 @@ varnish v1 -errvcl {HTTP header (buckinghambuckingham..) is too long.} { varnish v1 -vcl { - backend foo { .host = "${bad_ip}"; .port = "9080"; } + backend foo { .host = "127.0.0.1"; } sub vcl_deliver { set resp.http.buckinghambuckinghambuckinghambuckinghambuckinghambuckinghambuckinghambuckinghambuckinghambuckinghambuckinghambuckinghambuckin = "foobar"; diff --git a/bin/varnishtest/tests/v00050.vtc b/bin/varnishtest/tests/v00050.vtc index 9f05674..c880c7b 100644 --- a/bin/varnishtest/tests/v00050.vtc +++ b/bin/varnishtest/tests/v00050.vtc @@ -22,8 +22,7 @@ varnish v1 -vcl+backend { .initial = 0; } backend sick { - .host = "${bad_ip}"; - .port = "9080"; + .host = "${bad_backend}"; .probe = sick_probe; } diff --git a/bin/varnishtest/vtc_main.c b/bin/varnishtest/vtc_main.c index e3ecd0a..0a2c6e3 100644 --- a/bin/varnishtest/vtc_main.c +++ b/bin/varnishtest/vtc_main.c @@ -448,12 +448,20 @@ dns_works(void) * Figure out what IP related magic */ +static int __match_proto__(vss_resolved_f) +bind_cb(void *priv, const struct suckaddr *sa) +{ + (void)priv; + return (VTCP_bind(sa, NULL)); +} + static void ip_magic(void) { const char *p; int fd; char abuf[VTCP_ADDRBUFSIZE]; + char pbuf[VTCP_PORTBUFSIZE]; /* * In FreeBSD jails localhost/127.0.0.1 becomes the jails IP# @@ -462,12 +470,14 @@ ip_magic(void) * XXX: "localhost", but that doesn't work out of the box. * XXX: Things like "prefer_ipv6" parameter complicates things. */ - fd = VTCP_listen_on("127.0.0.1", NULL, 10, &p); + fd = VSS_resolver("127.0.0.1", NULL, &bind_cb, NULL, &p); assert(fd >= 0); - VTCP_myname(fd, abuf, sizeof abuf, NULL, 0); - AZ(close(fd)); + VTCP_myname(fd, abuf, sizeof abuf, pbuf, sizeof(pbuf)); extmacro_def("localhost", "%s", abuf); + /* Expose a backend that is forever down. */ + extmacro_def("bad_backend", "%s %s", abuf, pbuf); + /* * We need an IP number which will not repond, ever, and that is a * lot harder than it sounds. This IP# is from RFC5737 and a From phk at FreeBSD.org Sun Jan 15 12:40:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Sun, 15 Jan 2017 13:40:05 +0100 Subject: [master] 75c2065 Don't kill any pids <= 0 Message-ID: commit 75c2065dfc679c796f7e616fb9b475cbf932d762 Author: Poul-Henning Kamp Date: Sun Jan 15 10:47:43 2017 +0000 Don't kill any pids <= 0 diff --git a/bin/varnishtest/vtc_process.c b/bin/varnishtest/vtc_process.c index e53cd82..f8925e0 100644 --- a/bin/varnishtest/vtc_process.c +++ b/bin/varnishtest/vtc_process.c @@ -156,7 +156,7 @@ process_thread(void *priv) CAST_OBJ_NOTNULL(p, priv, PROCESS_MAGIC); r = wait4(p->pid, &p->status, 0, &ru); macro_undef(p->vl, p->name, "pid"); - p->pid = 0; + p->pid = -1; p->running = 0; vtc_log(p->vl, 2, "R %d Status: %04x (u %.6f s %.6f)", r, p->status, ru.ru_utime.tv_sec + 1e-6 * ru.ru_utime.tv_usec, @@ -228,7 +228,7 @@ process_wait(const struct process *p) { void *v; - if (p->running && p->pid) + if (p->running && p->pid > 0) AZ(pthread_join(p->tp, &v)); } @@ -252,7 +252,7 @@ process_kill(const struct process *p, const char *sig) CHECK_OBJ_NOTNULL(p, PROCESS_MAGIC); AN(sig); - if (!p->running || !p->pid) + if (!p->running || p->pid <= 0) vtc_log(p->vl, 0, "Cannot signal a non-running process"); if (!strcmp(sig, "TERM")) @@ -278,7 +278,7 @@ process_terminate(const struct process *p) process_kill(p, "TERM"); sleep(1); - if (p->running && p->pid) + if (p->running && p->pid > 0) process_kill(p, "KILL"); } @@ -291,7 +291,7 @@ process_write(const struct process *p, const char *text) { int r, len; - if (!p->running || !p->pid) + if (!p->running || p->pid <= 0) vtc_log(p->vl, 0, "Cannot write to a non-running process"); len = strlen(text); @@ -306,7 +306,7 @@ static void process_close(struct process *p) { - if (!p->running || !p->pid) + if (!p->running || p->pid <= 0) vtc_log(p->vl, 0, "Cannot close on a non-running process"); (void)close(p->fds[1]); @@ -368,7 +368,7 @@ cmd_process(CMD_ARGS) if (av == NULL) { /* Reset and free */ VTAILQ_FOREACH_SAFE(p, &processes, list, p2) { - if (p->running && p->pid) + if (p->running && p->pid > 0) process_terminate(p); VTAILQ_REMOVE(&processes, p, list); process_delete(p); From phk at FreeBSD.org Sun Jan 15 12:40:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Sun, 15 Jan 2017 13:40:05 +0100 Subject: [master] 1b833e5 Add a -log which vtc_dump's stdout+stderr from the subprocess. Message-ID: commit 1b833e5f07c3dfaa0770d6a0f8b615794c9bcffa Author: Poul-Henning Kamp Date: Sun Jan 15 11:11:08 2017 +0000 Add a -log which vtc_dump's stdout+stderr from the subprocess. diff --git a/bin/varnishtest/vtc_process.c b/bin/varnishtest/vtc_process.c index f8925e0..ee4dc05 100644 --- a/bin/varnishtest/vtc_process.c +++ b/bin/varnishtest/vtc_process.c @@ -42,6 +42,7 @@ #include #include "vtc.h" +#include "vlu.h" #include "vsub.h" struct process { @@ -56,7 +57,9 @@ struct process { char *outdir; char *out; char *err; - int fds[2]; + int fd_to; + int log; + int fd_from; pid_t pid; pthread_t tp; @@ -105,8 +108,8 @@ process_new(const char *name) p->outdir, p->outdir, p->out, p->err); AZ(system(buf)); - p->fds[0] = -1; - p->fds[1] = -1; + p->fd_to = -1; + p->fd_from = -1; if (*p->name != 'p') vtc_log(p->vl, 0, "Process name must start with 'p'"); @@ -146,14 +149,30 @@ process_delete(struct process *p) * Start the process thread */ +static int +process_vlu_func(void *priv, const char *l) +{ + struct process *p; + + CAST_OBJ_NOTNULL(p, priv, PROCESS_MAGIC); + vtc_dump(p->vl, 4, "output", l, -1); + return (0); +} + static void * process_thread(void *priv) { struct process *p; struct rusage ru; int r; + struct vlu *vlu; CAST_OBJ_NOTNULL(p, priv, PROCESS_MAGIC); + if (p->fd_from > 0) { + vlu = VLU_New(p, process_vlu_func, 1024); + while (!VLU_Fd(p->fd_from, vlu)) + continue; + } r = wait4(p->pid, &p->status, 0, &ru); macro_undef(p->vl, p->name, "pid"); p->pid = -1; @@ -174,8 +193,7 @@ process_thread(void *priv) p->status, WTERMSIG(p->status), WEXITSTATUS(p->status)); #endif - (void)close(p->fds[1]); - p->fds[1] = -1; + closefd(&p->fd_to); return (NULL); } @@ -185,6 +203,8 @@ process_start(struct process *p) { struct vsb *cl; int out_fd, err_fd; + int fds[2]; + int fdt[2]; CHECK_OBJ_NOTNULL(p, PROCESS_MAGIC); @@ -192,16 +212,24 @@ process_start(struct process *p) cl = macro_expand(p->vl, p->spec); AN(cl); - AZ(pipe(p->fds)); - out_fd = open(p->out, O_WRONLY|O_APPEND); - assert(out_fd >= 0); - err_fd = open(p->err, O_WRONLY|O_APPEND); - assert(err_fd >= 0); + AZ(pipe(fds)); + if (p->log) { + AZ(pipe(fdt)); + out_fd = fdt[1]; + err_fd = fdt[1]; + } else { + fdt[0] = -1; + fdt[1] = -1; + out_fd = open(p->out, O_WRONLY|O_APPEND); + assert(out_fd >= 0); + err_fd = open(p->err, O_WRONLY|O_APPEND); + assert(err_fd >= 0); + } p->pid = fork(); assert(p->pid >= 0); p->running = 1; if (p->pid == 0) { - assert(dup2(p->fds[0], 0) == 0); + assert(dup2(fds[0], 0) == 0); assert(dup2(out_fd, 1) == 1); assert(dup2(err_fd, 2) == 2); VSUB_closefrom(STDERR_FILENO + 1); @@ -211,10 +239,15 @@ process_start(struct process *p) } vtc_log(p->vl, 3, "PID: %ld", (long)p->pid); macro_def(p->vl, p->name, "pid", "%ld", (long)p->pid); - AZ(close(p->fds[0])); - AZ(close(out_fd)); - AZ(close(err_fd)); - p->fds[0] = -1; + closefd(&fds[0]); + p->fd_to = fds[1]; + if (p->log) { + closefd(&fdt[1]); + p->fd_from = fdt[0]; + } else { + closefd(&out_fd); + closefd(&err_fd); + } VSB_destroy(&cl); AZ(pthread_create(&p->tp, NULL, process_thread, p)); } @@ -296,7 +329,7 @@ process_write(const struct process *p, const char *text) len = strlen(text); vtc_log(p->vl, 4, "Writing %d bytes", len); - r = write(p->fds[1], text, len); + r = write(p->fd_to, text, len); if (r < 0) vtc_log(p->vl, 0, "Failed to write: %s (%d)", strerror(errno), errno); @@ -309,8 +342,7 @@ process_close(struct process *p) if (!p->running || p->pid <= 0) vtc_log(p->vl, 0, "Cannot close on a non-running process"); - (void)close(p->fds[1]); - p->fds[1] = -1; + closefd(&p->fd_to); } /* SECTION: process process @@ -330,6 +362,9 @@ process_close(struct process *p) * \-start * Start the process. * + * \-log + * Log stdout/stderr with vtc_dump() (must be before -start/-run) + * * \-wait * Wait for the process to finish. * @@ -394,6 +429,10 @@ cmd_process(CMD_ARGS) process_start(p); continue; } + if (!strcmp(*av, "-log")) { + p->log = 1; + continue; + } if (!strcmp(*av, "-wait")) { process_wait(p); continue; From phk at FreeBSD.org Sun Jan 15 12:40:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Sun, 15 Jan 2017 13:40:05 +0100 Subject: [master] 9235422 Keep track of being started in "no VCL" mode, and don't attempt to start the child process. Message-ID: commit 923542269238590ab0845b89245e00368b5054c1 Author: Poul-Henning Kamp Date: Sun Jan 15 11:21:28 2017 +0000 Keep track of being started in "no VCL" mode, and don't attempt to start the child process. diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index 2d1f6c9..77aa1d5 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -459,6 +459,7 @@ main(int argc, char * const *argv) const char *W_arg = NULL; const char *x_arg = NULL; int s_arg_given = 0; + int novcl = 0; const char *T_arg = "localhost:0"; char *p; struct cli cli[1]; @@ -619,8 +620,10 @@ main(int argc, char * const *argv) VTAILQ_INSERT_TAIL(&f_args, fa, list); break; case 'f': - if (*optarg == '\0') + if (*optarg == '\0') { + novcl = 1; break; + } ALLOC_OBJ(fa, F_ARG_MAGIC); AN(fa); REPLACE(fa->farg, optarg); @@ -814,10 +817,10 @@ main(int argc, char * const *argv) mgt_SHM_Create(); - if (!d_flag && !mgt_has_vcl()) + if (!d_flag && !mgt_has_vcl() && !novcl) MGT_Complain(C_ERR, "No VCL loaded yet"); - u = MCH_Init(d_flag ? 0 : 1); + u = MCH_Init(d_flag || novcl ? 0 : 1); if (eric_fd >= 0) mgt_eric_im_done(eric_fd, u); From phk at FreeBSD.org Sun Jan 15 12:40:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Sun, 15 Jan 2017 13:40:05 +0100 Subject: [master] 3fb17e9 Rework the shell command, so that expected exit code and pattern to be found are options to "shell". Deprecate err_shell. Message-ID: commit 3fb17e94de3e0a830bd5d987330fe7e09e6d7a75 Author: Poul-Henning Kamp Date: Sun Jan 15 12:35:52 2017 +0000 Rework the shell command, so that expected exit code and pattern to be found are options to "shell". Deprecate err_shell. Structure output to always be prefixed by "shell" since we're running at the top level. Also prefix commands with "exec 2>&1 ;" to join stdout+stderr by default. This still doesn't cover the shells stderr in case of bad shell syntax, which is annoying, but not worth fighting for right now. diff --git a/bin/varnishtest/vtc.c b/bin/varnishtest/vtc.c index 7693f0b..e2cb6b0 100644 --- a/bin/varnishtest/vtc.c +++ b/bin/varnishtest/vtc.c @@ -439,6 +439,19 @@ cmd_varnishtest(CMD_ARGS) * echo end * } * + * By default a zero exit code is expected. + * + * Notice that the commandstring is prefixed with "exec 2>&1;" to join + * stderr and stdout back to the varnishtest process. + * + * Optional arguments: + * + * -err - expect non-zero exit code + * + * -exit N - expect exit code N + * + * -expect string - expect str to be found in stdout+err + * * The vtc will fail if the return code of the shell is not 0. */ /* SECTION: client-server.spec.shell shell @@ -446,23 +459,80 @@ cmd_varnishtest(CMD_ARGS) * Same as for the top-level shell. */ +static void +cmd_shell_engine(struct vtclog *vl, int ok, + const char *cmd, const char *expect) +{ + struct vsb *vsb; + FILE *fp; + int r, c; + + AN(vl); + AN(cmd); + vsb = VSB_new_auto(); + AN(vsb); + VSB_printf(vsb, "exec 2>&1 ; %s", cmd); + AZ(VSB_finish(vsb)); + vtc_dump(vl, 4, "shell_cmd", VSB_data(vsb), -1); + fp = popen(VSB_data(vsb), "r"); + if (fp == NULL) + vtc_log(vl, 0, "popen fails: %s", strerror(errno)); + VSB_clear(vsb); + do { + c = getc(fp); + if (c != EOF) + VSB_putc(vsb, c); + } while (c != EOF); + r = pclose(fp); + vtc_log(vl, 4, "shell_status = 0x%04x", WEXITSTATUS(r)); + if (WIFSIGNALED(r)) + vtc_log(vl, 4, "shell_signal = %d", WTERMSIG(r)); + if (ok < 0 && !WEXITSTATUS(r)) + vtc_log(vl, 0, "shell did not fail as expected"); + else if (ok >= 0 && WEXITSTATUS(r) != ok) { + vtc_log(vl, 0, + "shell_exit not as expected: got 0x%04x wanted 0x%04x", + WEXITSTATUS(r), ok); + } + AZ(VSB_finish(vsb)); + vtc_dump(vl, 4, "shell_out", VSB_data(vsb), VSB_len(vsb)); + if (expect != NULL) { + if (strstr(VSB_data(vsb), expect) == NULL) + vtc_log(vl, 0, + "shell_expect not found: (\"%s\")", expect); + else + vtc_log(vl, 4, "shell_expect found"); + } + VSB_destroy(&vsb); +} + + void cmd_shell(CMD_ARGS) { (void)priv; (void)cmd; - int r, s; + int n; + int ok = 0; + const char *expect = NULL; if (av == NULL) return; - AN(av[1]); - AZ(av[2]); - vtc_dump(vl, 4, "shell", av[1], -1); - r = system(av[1]); - s = WEXITSTATUS(r); - if (s != 0) - vtc_log(vl, 0, "CMD '%s' failed with status %d (%s)", - av[1], s, strerror(errno)); + for (n = 1; av[n] != NULL; n++) { + if (!strcmp(av[n], "-err")) { + ok = -1; + } else if (!strcmp(av[n], "-exit")) { + n += 1; + ok = atoi(av[n]); + } else if (!strcmp(av[n], "-expect")) { + n += 1; + expect = av[n]; + } else { + break; + } + } + AN(av[n]); + cmd_shell_engine(vl, ok, av[n], expect); } /* SECTION: err_shell err_shell @@ -485,43 +555,15 @@ cmd_err_shell(CMD_ARGS) { (void)priv; (void)cmd; - struct vsb *vsb; - FILE *fp; - int r, c; if (av == NULL) return; AN(av[1]); AN(av[2]); AZ(av[3]); - vsb = VSB_new_auto(); - AN(vsb); - vtc_dump(vl, 4, "cmd", av[2], -1); - fp = popen(av[2], "r"); - if (fp == NULL) - vtc_log(vl, 0, "popen fails: %s", strerror(errno)); - do { - c = getc(fp); - if (c != EOF) - VSB_putc(vsb, c); - } while (c != EOF); - r = pclose(fp); - vtc_log(vl, 4, "Status = %d", WEXITSTATUS(r)); - if (WIFSIGNALED(r)) - vtc_log(vl, 4, "Signal = %d", WTERMSIG(r)); - if (WEXITSTATUS(r) == 0) { - vtc_log(vl, 0, - "expected error from shell"); - } - AZ(VSB_finish(vsb)); - vtc_dump(vl, 4, "stdout", VSB_data(vsb), VSB_len(vsb)); - if (strstr(VSB_data(vsb), av[1]) == NULL) - vtc_log(vl, 0, - "Did not find expected string: (\"%s\")", av[1]); - else - vtc_log(vl, 4, - "Found expected string: (\"%s\")", av[1]); - VSB_destroy(&vsb); + vtc_log(vl, 1, + "NOTICE: err_shell is deprecated, use 'shell -err -expect'"); + cmd_shell_engine(vl, -1, av[2], av[1]); } /* SECTION: delay delay From phk at FreeBSD.org Sun Jan 15 12:40:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Sun, 15 Jan 2017 13:40:05 +0100 Subject: [master] 0507566 Use new 'shell' command syntax. Message-ID: commit 0507566733bce811ee7fd118ca4a76ab91d6aa6a Author: Poul-Henning Kamp Date: Sun Jan 15 12:37:58 2017 +0000 Use new 'shell' command syntax. Test varnishd in -F mode with out VCL diff --git a/bin/varnishtest/tests/a00009.vtc b/bin/varnishtest/tests/a00009.vtc index 023f4ea..01ababb 100644 --- a/bin/varnishtest/tests/a00009.vtc +++ b/bin/varnishtest/tests/a00009.vtc @@ -1,33 +1,63 @@ -varnishtest "Code coverage of VCL compiler and RSTdump etc" +varnishtest "Code coverage of mgt_main, (VCL compiler and RSTdump etc)" shell "varnishd -b 127.0.0.1:80 -C 2> ${tmpdir}/_.c" shell "varnishd -x dumprstparam > ${tmpdir}/_.param" shell "varnishd -x dumprstvsl > ${tmpdir}/_.vsl" shell "varnishd -x dumprstcli > ${tmpdir}/_.cli" -err_shell {VCL version declaration missing} { +shell -err -expect {VCL version declaration missing} { echo 'bad vcl' > ${tmpdir}/t.vcl - varnishd -f ${tmpdir}/t.vcl -n ${tmpdir} 2>&1 + varnishd -f ${tmpdir}/t.vcl -n ${tmpdir} } -err_shell {VCL version declaration missing} { +shell -err -expect {VCL version declaration missing} { echo 'bad vcl' > ${tmpdir}/t.vcl - varnishd -C -f ${tmpdir}/t.vcl -n ${tmpdir} 2>&1 + varnishd -C -f ${tmpdir}/t.vcl -n ${tmpdir} } -err_shell {-spersistent has been deprecated} "varnishd -spersistent -f '' 2>&1" -err_shell {Unknown jail method "xyz"} "varnishd -jxyz -f '' 2>&1" -err_shell {-x is incompatible with everything else} "varnishd -d -x foo 2>&1" -err_shell {Invalid -x argument} "varnishd -x foo 2>&1" -err_shell {Too many arguments} "varnishd foo 2>&1" -err_shell {Only one of -d or -F can be specified} "varnishd -d -F 2>&1" -err_shell {Only one of -b or -f can be specified} "varnishd -b a -f b 2>&1" -err_shell {-C needs either -b or -f } \ - "varnishd -C 2>&1" -err_shell {-d makes no sense with -C} "varnishd -C -b 127.0.0.1:80 -d 2>&1" -err_shell {-F makes no sense with -C} "varnishd -C -b 127.0.0.1:80 -F 2>&1" -err_shell {usage: varnishd [options]} "varnishd -? 2>&1" -err_shell {Invalid backslash sequence} {varnishd -l 'xyz\kk,xyz\foo' -f '' 2>&1} -err_shell {Invalid backslash sequence} {varnishd -l 'ab\8cd' -f '' 2>&1} -err_shell {Copyright (c) 2006} "varnishd -V 2>&1 ; exit 1" -err_shell {usage: varnishd [options]} "varnishd -A 2>&1" -err_shell {Cannot open -S file} { - varnishd -S ${tmpdir}/nonexistent -n ${tmpdir}/v0 -f '' 2>&1 +shell -err -expect {-spersistent has been deprecated} "varnishd -spersistent -f '' " +shell -err -expect {Unknown jail method "xyz"} "varnishd -jxyz -f '' " +shell -err -expect {-x is incompatible with everything else} "varnishd -d -x foo " +shell -err -expect {Invalid -x argument} "varnishd -x foo " +shell -err -expect {Too many arguments} "varnishd foo " +shell -err -expect {Only one of -d or -F can be specified} "varnishd -d -F " +shell -err -expect {Only one of -b or -f can be specified} "varnishd -b a -f b " +shell -err -expect {-C needs either -b or -f } \ + "varnishd -C " +shell -err -expect {-d makes no sense with -C} "varnishd -C -b 127.0.0.1:80 -d " +shell -err -expect {-F makes no sense with -C} "varnishd -C -b 127.0.0.1:80 -F " +shell -err -expect {usage: varnishd [options]} "varnishd -? " +shell -err -expect {Invalid backslash sequence} {varnishd -l 'xyz\kk,xyz\foo' -f '' } +shell -err -expect {Invalid backslash sequence} {varnishd -l 'ab\8cd' -f '' } +shell -err -expect {Copyright (c) 2006} "varnishd -V ; exit 1" +shell -err -expect {usage: varnishd [options]} "varnishd -A " +shell -err -expect {Cannot open -S file} { + varnishd -S ${tmpdir}/nonexistent -n ${tmpdir}/v0 -f '' } +shell -err -expect {Neither -b nor -f given} { varnishd -n ${tmpdir}/v0 } + +# Test -F mode with no VCL loaded + +process p1 "exec varnishd -n ${tmpdir}/v0 -F -f '' -a :0" -log -start + +delay 1 + +shell { + ( + echo 'vcl 4.0;' + echo 'backend default {' + echo ' .host="${bad_backend}";' + echo '}' + ) > ${tmpdir}/vcl +} + +shell -expect {VCL compiled.} { + varnishadm -n ${tmpdir}/v0 vcl.load vcl1 ${tmpdir}/vcl +} + +shell -expect {active auto/warm - vcl1} { + varnishadm -n ${tmpdir}/v0 vcl.list +} + +shell {varnishadm -n ${tmpdir}/v0 start}} + +shell {varnishadm -n ${tmpdir}/v0 debug.listen_address} + +#process p1 -stop From phk at FreeBSD.org Sun Jan 15 12:40:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Sun, 15 Jan 2017 13:40:05 +0100 Subject: [master] eb7db22 Replace err_shell with shell -err -expect. Message-ID: commit eb7db2290d65b117996d1144a020e4be6132a28f Author: Poul-Henning Kamp Date: Sun Jan 15 12:38:19 2017 +0000 Replace err_shell with shell -err -expect. Many of these could benefit from a rethink now that we can expect a pattern also on shell commands which succeed. diff --git a/bin/varnishtest/tests/b00045.vtc b/bin/varnishtest/tests/b00045.vtc index 8b67483..74d18f3 100644 --- a/bin/varnishtest/tests/b00045.vtc +++ b/bin/varnishtest/tests/b00045.vtc @@ -14,5 +14,5 @@ client c1 { delay .2 -err_shell {Could not open pid/lock} \ +shell -err -expect {Could not open pid/lock} \ "varnishd -P ${tmpdir}/v1/varnishd.pid -b 127.0.0.1:80 -a :0 -n ${tmpdir} 2>&1" diff --git a/bin/varnishtest/tests/c00003.vtc b/bin/varnishtest/tests/c00003.vtc index bc4596f..aa86907 100644 --- a/bin/varnishtest/tests/c00003.vtc +++ b/bin/varnishtest/tests/c00003.vtc @@ -4,11 +4,11 @@ varnishtest "Check that we fail to start if any listen address does not work" # and are on Linux, ensure /proc/net/ipv4/ip_nonlocal_bind is set to 0. # All bad listen addresses -err_shell "Error: Could not get socket" { +shell -err -expect "Error: Could not get socket" { varnishd -F -a "${bad_ip}:0" -b '***' -n ${tmpdir} 2>&1 } # old style address list -err_shell "Unknown protocol" { +shell -err -expect "Unknown protocol" { varnishd -F -a "127.0.0.1:0,${bad_ip}:0" -b '***' -n ${tmpdir} 2>&1 } diff --git a/bin/varnishtest/tests/j00002.vtc b/bin/varnishtest/tests/j00002.vtc index f4b6aed..274844c 100644 --- a/bin/varnishtest/tests/j00002.vtc +++ b/bin/varnishtest/tests/j00002.vtc @@ -2,7 +2,7 @@ varnishtest "-junix bad subarg handling" feature root -err_shell "unknown sub-argument" "varnishd -junix,bla=foo -f '' 2>&1" -err_shell "user not found" "varnishd -junix,user=/// -f '' 2>&1" -err_shell "user not found" "varnishd -junix,workuser=/// -f '' 2>&1" -err_shell "group not found" "varnishd -junix,ccgroup=/// -f '' 2>&1" +shell -err -expect "unknown sub-argument" "varnishd -junix,bla=foo -f '' 2>&1" +shell -err -expect "user not found" "varnishd -junix,user=/// -f '' 2>&1" +shell -err -expect "user not found" "varnishd -junix,workuser=/// -f '' 2>&1" +shell -err -expect "group not found" "varnishd -junix,ccgroup=/// -f '' 2>&1" diff --git a/bin/varnishtest/tests/j00003.vtc b/bin/varnishtest/tests/j00003.vtc index 921d212..56e43ee 100644 --- a/bin/varnishtest/tests/j00003.vtc +++ b/bin/varnishtest/tests/j00003.vtc @@ -3,4 +3,4 @@ varnishtest "-junix bad subarg handling" feature root feature user_varnish -err_shell "have different login groups" "varnishd -junix,workuser=root -f '' 2>&1" +shell -err -expect "have different login groups" "varnishd -junix,workuser=root -f '' 2>&1" diff --git a/bin/varnishtest/tests/r01770.vtc b/bin/varnishtest/tests/r01770.vtc index 5243b4a..de66aab 100644 --- a/bin/varnishtest/tests/r01770.vtc +++ b/bin/varnishtest/tests/r01770.vtc @@ -1,4 +1,4 @@ varnishtest "bad protocol specs for -a" -err_shell "Too many sub-arguments" "varnishd -a 127.0.0.1:80000,PROXY,FOO -d 2>&1" -err_shell "Too many sub-arguments" "varnishd -a 127.0.0.1:80000,HTTP/1,FOO -d 2>&1" +shell -err -expect "Too many sub-arguments" "varnishd -a 127.0.0.1:80000,PROXY,FOO -d 2>&1" +shell -err -expect "Too many sub-arguments" "varnishd -a 127.0.0.1:80000,HTTP/1,FOO -d 2>&1" diff --git a/bin/varnishtest/tests/r01813.vtc b/bin/varnishtest/tests/r01813.vtc index 88bb5ae..e679f75 100644 --- a/bin/varnishtest/tests/r01813.vtc +++ b/bin/varnishtest/tests/r01813.vtc @@ -1,3 +1,3 @@ varnishtest "Duplicate -a arguments" -err_shell {have same address} "varnishd -d -a 127.0.0.1:38484 -a 127.0.0.1:38484 -b localhost:80 2>&1" +shell -err -expect {have same address} "varnishd -d -a 127.0.0.1:38484 -a 127.0.0.1:38484 -b localhost:80 2>&1" diff --git a/bin/varnishtest/tests/u00002.vtc b/bin/varnishtest/tests/u00002.vtc index 4735cf5..c42de64 100644 --- a/bin/varnishtest/tests/u00002.vtc +++ b/bin/varnishtest/tests/u00002.vtc @@ -17,14 +17,14 @@ process p1 {varnishstat -1 -n ${v1_name} -f ^LCK.vbe.destroy \ shell "grep -q vbe ${tmpdir}/p1/stdout" shell "grep -q mempool ${tmpdir}/p1/stdout" -err_shell "" "grep -q LCK.vbe.destroy ${tmpdir}/p1/stdout" +shell -err "grep -q LCK.vbe.destroy ${tmpdir}/p1/stdout" process p2 {varnishstat -1 -n ${v1_name} -f ^*vbe.destroy \ -f *vbe* -f *mempool* | tr '[1-9]' '0'} -run shell "grep -q vbe ${tmpdir}/p2/stdout" shell "grep -q mempool ${tmpdir}/p2/stdout" -err_shell "" "grep -q LCK.vbe.destroy ${tmpdir}/p2/stdout" +shell -err "grep -q LCK.vbe.destroy ${tmpdir}/p2/stdout" shell "cmp -s ${tmpdir}/p1/stdout ${tmpdir}/p2/stdout" diff --git a/bin/varnishtest/tests/u00003.vtc b/bin/varnishtest/tests/u00003.vtc index 1c84887..53366a3 100644 --- a/bin/varnishtest/tests/u00003.vtc +++ b/bin/varnishtest/tests/u00003.vtc @@ -7,41 +7,41 @@ server s1 { varnish v1 -vcl+backend {} -start -err_shell "Missing -w option" \ +shell -err -expect "Missing -w option" \ {varnishncsa -n ${v1_name} -D 2>&1} -err_shell "Unknown format specifier at: %{foo}A" \ +shell -err -expect "Unknown format specifier at: %{foo}A" \ {varnishncsa -n ${v1_name} -F "%{foo}A" 2>&1} -err_shell "Unknown format specifier at: %A" \ +shell -err -expect "Unknown format specifier at: %A" \ {varnishncsa -n ${v1_name} -F "%A" 2>&1} -err_shell "Usage: varnishncsa " \ +shell -err -expect "Usage: varnishncsa " \ {varnishncsa -n ${v1_name} extra 2>&1} -err_shell "Missing tag in VSL:" \ +shell -err -expect "Missing tag in VSL:" \ {varnishncsa -n ${v1_name} -F "%{VSL:}x" 2>&1} -err_shell "Unknown log tag: nonexistent" \ +shell -err -expect "Unknown log tag: nonexistent" \ {varnishncsa -n ${v1_name} -F "%{VSL:nonexistent}x" 2>&1} -err_shell "Tag not unique: Req" \ +shell -err -expect "Tag not unique: Req" \ {varnishncsa -n ${v1_name} -F "%{VSL:Req}x" 2>&1} -err_shell "Unknown log tag: Begin[" \ +shell -err -expect "Unknown log tag: Begin[" \ {varnishncsa -n ${v1_name} -F "%{VSL:Begin[}x" 2>&1} -err_shell "Syntax error: VSL:Begin]" \ +shell -err -expect "Syntax error: VSL:Begin]" \ {varnishncsa -n ${v1_name} -F "%{VSL:Begin]}x" 2>&1} -err_shell "Unknown log tag: Begin[a" \ +shell -err -expect "Unknown log tag: Begin[a" \ {varnishncsa -n ${v1_name} -F "%{VSL:Begin[a}x" 2>&1} -err_shell "Syntax error: VSL:Begin[a]" \ +shell -err -expect "Syntax error: VSL:Begin[a]" \ {varnishncsa -n ${v1_name} -F "%{VSL:Begin[a]}x" 2>&1} -err_shell "Syntax error. Field specifier must be positive: Begin[0]" \ +shell -err -expect "Syntax error. Field specifier must be positive: Begin[0]" \ {varnishncsa -n ${v1_name} -F "%{VSL:Begin[0]}x" 2>&1} -err_shell "Field specifier 999999999999 for the tag VSL:Begin[999999999999] is probably too high" \ +shell -err -expect "Field specifier 999999999999 for the tag VSL:Begin[999999999999] is probably too high" \ {varnishncsa -n ${v1_name} -F "%{VSL:Begin[999999999999]}x" 2>&1} diff --git a/bin/varnishtest/tests/u00005.vtc b/bin/varnishtest/tests/u00005.vtc index d6b0dd4..86b328c 100644 --- a/bin/varnishtest/tests/u00005.vtc +++ b/bin/varnishtest/tests/u00005.vtc @@ -19,5 +19,5 @@ process p5 "exec varnishstat -n ${v1_name} -x" -run shell {grep -q "MAIN" ${tmpdir}/p5/stdout} process p6 "exec varnishstat -n ${v1_name} -j" -run shell {grep -q "MAIN.uptime\":" ${tmpdir}/p6/stdout} -err_shell "Usage: varnishstat " "varnishstat -n ${v1_name} extra 2>&1" -err_shell "Cannot open /nonexistent/_.vsm" "varnishstat -n /nonexistent 2>&1" +shell -err -expect "Usage: varnishstat " "varnishstat -n ${v1_name} extra 2>&1" +shell -err -expect "Cannot open /nonexistent/_.vsm" "varnishstat -n /nonexistent 2>&1" diff --git a/bin/varnishtest/tests/u00006.vtc b/bin/varnishtest/tests/u00006.vtc index 8f49e75..64491b0 100644 --- a/bin/varnishtest/tests/u00006.vtc +++ b/bin/varnishtest/tests/u00006.vtc @@ -18,9 +18,9 @@ process p4 "exec varnishlog -n ${v1_name} -h" -run shell {grep -q "Usage: varnishlog " ${tmpdir}/p4/stderr} process p5 "exec varnishlog -n ${v1_name} -V" -run shell {grep -q "Copyright (c) 2006 Verdens Gang AS" ${tmpdir}/p5/stderr} -err_shell "Usage: varnishlog " "varnishlog -n ${v1_name} extra 2>&1" -err_shell "Missing -w option" "varnishlog -n ${v1_name} -D 2>&1" -err_shell "-L: Range error" "varnishlog -n ${v1_name} -L 0 2>&1" +shell -err -expect "Usage: varnishlog " "varnishlog -n ${v1_name} extra 2>&1" +shell -err -expect "Missing -w option" "varnishlog -n ${v1_name} -D 2>&1" +shell -err -expect "-L: Range error" "varnishlog -n ${v1_name} -L 0 2>&1" process p1 -wait shell {grep -q "0 CLI" ${tmpdir}/p1/stdout} process p2 -wait diff --git a/bin/varnishtest/tests/u00007.vtc b/bin/varnishtest/tests/u00007.vtc index 150b9a4..6f0c6b7 100644 --- a/bin/varnishtest/tests/u00007.vtc +++ b/bin/varnishtest/tests/u00007.vtc @@ -9,17 +9,17 @@ varnish v1 -vcl+backend {} -start process p1 "exec varnishhist -n ${v1_name} -h" -run shell {grep -q "Usage: varnishhist " ${tmpdir}/p1/stderr} -err_shell "Usage: varnishhist " \ +shell -err -expect "Usage: varnishhist " \ "varnishhist -n ${v1_name} extra 2>&1" -err_shell "-p: invalid '0'" "varnishhist -n ${v1_name} -p 0 2>&1" -err_shell "-B: being able to bend time does not mean we can stop it" \ +shell -err -expect "-p: invalid '0'" "varnishhist -n ${v1_name} -p 0 2>&1" +shell -err -expect "-B: being able to bend time does not mean we can stop it" \ "varnishhist -n ${v1_name} -B 0 2>&1" -err_shell "-B: being able to bend time does not mean we can make it go backwards" "varnishhist -n ${v1_name} -B -1 2>&1" -err_shell "Invalid grouping mode: raw" \ +shell -err -expect "-B: being able to bend time does not mean we can make it go backwards" "varnishhist -n ${v1_name} -B -1 2>&1" +shell -err -expect "Invalid grouping mode: raw" \ "varnishhist -n ${v1_name} -g raw 2>&1" -err_shell "-P: No such profile 'foo'" \ +shell -err -expect "-P: No such profile 'foo'" \ "varnishhist -n ${v1_name} -P foo 2>&1" -err_shell "-P: 'foo:bar' is not a valid profile name or definition" \ +shell -err -expect "-P: 'foo:bar' is not a valid profile name or definition" \ "varnishhist -n ${v1_name} -P foo:bar 2>&1" -err_shell "-P: 'foo:0:0:0' is not a valid tag name" \ +shell -err -expect "-P: 'foo:0:0:0' is not a valid tag name" \ "varnishhist -n ${v1_name} -P foo:0:0:0 2>&1" From fgsch at lodoss.net Sun Jan 15 13:11:05 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sun, 15 Jan 2017 14:11:05 +0100 Subject: [master] c261c33 Make this work with ipv6 as well Message-ID: commit c261c331483003100e7437d7213e141423fab612 Author: Federico G. Schwindt Date: Sun Jan 15 12:51:34 2017 +0000 Make this work with ipv6 as well diff --git a/lib/libvmod_debug/vmod_debug_dyn.c b/lib/libvmod_debug/vmod_debug_dyn.c index 826595d..8f71121 100644 --- a/lib/libvmod_debug/vmod_debug_dyn.c +++ b/lib/libvmod_debug/vmod_debug_dyn.c @@ -58,19 +58,21 @@ dyn_dir_init(VRT_CTX, struct vmod_debug_dyn *dyn, struct director *dir, *dir2; struct vrt_backend vrt; + vrt.port = port; + vrt.hosthdr = addr; CHECK_OBJ_NOTNULL(dyn, VMOD_DEBUG_DYN_MAGIC); XXXAN(addr); XXXAN(port); INIT_OBJ(&vrt, VRT_BACKEND_MAGIC); - vrt.port = port; vrt.vcl_name = dyn->vcl_name; - vrt.hosthdr = vrt.ipv4_addr; + vrt.port = port; + vrt.hosthdr = addr; memset(&hints, 0, sizeof(hints)); - hints.ai_family = AF_INET; + hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_STREAM; - AZ(getaddrinfo(vrt.ipv4_addr, vrt.port, &hints, &res)); + AZ(getaddrinfo(addr, port, &hints, &res)); XXXAZ(res->ai_next); sa = VSA_Malloc(res->ai_addr, res->ai_addrlen); From fgsch at lodoss.net Sun Jan 15 13:11:05 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sun, 15 Jan 2017 14:11:05 +0100 Subject: [master] a96bfb0 Also try with ipv6 if ipv4 is not available Message-ID: commit a96bfb0ac9a94e4bca659fd0e8cf44a588f77cc6 Author: Federico G. Schwindt Date: Sun Jan 15 13:05:41 2017 +0000 Also try with ipv6 if ipv4 is not available diff --git a/configure.ac b/configure.ac index 02a9f7f..10baf91 100644 --- a/configure.ac +++ b/configure.ac @@ -384,14 +384,17 @@ AC_CACHE_CHECK([whether SO_RCVTIMEO works], #include #include #include +#include ]],[[ -int sd = socket(AF_INET, SOCK_STREAM, 0); +int s = socket(AF_INET, SOCK_STREAM, 0); struct timeval tv = { 1, 0 }; -if (setsockopt(sd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof tv) == 0) { - socklen_t l = sizeof tv; - if (getsockopt(sd, SOL_SOCKET, SO_RCVTIMEO, &tv, &l) == 0) { - return (l != sizeof tv); - } +if (s < 0 && errno == EPROTONOSUPPORT) + s = socket(AF_INET6, SOCK_STREAM, 0); +if (setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof tv) == 0) { + socklen_t l = sizeof tv; + if (getsockopt(s, SOL_SOCKET, SO_RCVTIMEO, &tv, &l) == 0) { + return (l != sizeof tv); + } } return 1; ]])], @@ -412,14 +415,17 @@ AC_CACHE_CHECK([whether SO_SNDTIMEO works], #include #include #include +#include ]],[[ -int sd = socket(AF_INET, SOCK_STREAM, 0); +int s = socket(AF_INET, SOCK_STREAM, 0); struct timeval tv = { 1, 0 }; -if (setsockopt(sd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof tv) == 0) { - socklen_t l = sizeof tv; - if (getsockopt(sd, SOL_SOCKET, SO_SNDTIMEO, &tv, &l) == 0) { - return (l != sizeof tv); - } +if (s < 0 && errno == EPROTONOSUPPORT) + s = socket(AF_INET6, SOCK_STREAM, 0); +if (setsockopt(s, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof tv) == 0) { + socklen_t l = sizeof tv; + if (getsockopt(s, SOL_SOCKET, SO_SNDTIMEO, &tv, &l) == 0) { + return (l != sizeof tv); + } } return 1; ]])], @@ -443,15 +449,16 @@ AC_CACHE_CHECK([for TCP_KEEP(CNT|IDLE|INTVL) socket options], [ac_cv_have_tcp_keep], [AC_RUN_IFELSE( [AC_LANG_PROGRAM([[ -#include #include #include #include #include +#include ]],[[ int s = socket(AF_INET, SOCK_STREAM, 0); -int i; -i = 5; +int i = 5; +if (s < 0 && errno == EPROTONOSUPPORT) + s = socket(AF_INET6, SOCK_STREAM, 0); if (setsockopt(s, IPPROTO_TCP, TCP_KEEPCNT, &i, sizeof i)) return (1); if (setsockopt(s, IPPROTO_TCP, TCP_KEEPIDLE, &i, sizeof i)) @@ -475,15 +482,16 @@ AC_CACHE_CHECK([for TCP_FASTOPEN socket option], [ac_cv_have_tcp_fastopen], [AC_RUN_IFELSE( [AC_LANG_PROGRAM([[ -#include #include #include #include #include +#include ]],[[ int s = socket(AF_INET, SOCK_STREAM, 0); -int i; -i = 5; +int i = 5; +if (s < 0 && errno == EPROTONOSUPPORT) + s = socket(AF_INET6, SOCK_STREAM, 0); if (setsockopt(s, SOL_TCP, TCP_FASTOPEN, &i, sizeof i)) return (1); return (0); From fgsch at lodoss.net Sun Jan 15 15:38:04 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sun, 15 Jan 2017 16:38:04 +0100 Subject: [master] eb34cf5 Replace with shell command and simplify some cases Message-ID: commit eb34cf5217d977026cbceadb5204c099bad244f6 Author: Federico G. Schwindt Date: Sun Jan 15 14:42:47 2017 +0000 Replace with shell command and simplify some cases diff --git a/bin/varnishtest/tests/r02148.vtc b/bin/varnishtest/tests/r02148.vtc index 3caa00e..2995d93 100644 --- a/bin/varnishtest/tests/r02148.vtc +++ b/bin/varnishtest/tests/r02148.vtc @@ -14,7 +14,7 @@ client c1 { delay 1 -process p1 {varnishncsa -d -n ${v1_name} -F "%u %{Host}i"} -run -shell {grep -q "foo qux" ${tmpdir}/p1/stdout} -process p2 {varnishncsa -d -n ${v1_name} -F "%r"} -run -shell {grep -q "GET http://qux/ HTTP/1.1" ${tmpdir}/p2/stdout} +shell -expect "foo qux" \ + {varnishncsa -d -n ${v1_name} -F "%u %{Host}i"} +shell -expect "GET http://qux/ HTTP/1.1" \ + {varnishncsa -d -n ${v1_name} -F "%r"} diff --git a/bin/varnishtest/tests/u00000.vtc b/bin/varnishtest/tests/u00000.vtc index cba95c0..8684c25 100644 --- a/bin/varnishtest/tests/u00000.vtc +++ b/bin/varnishtest/tests/u00000.vtc @@ -24,9 +24,9 @@ process p2 -wait process p3 -wait # check stdout -shell "grep foo ${tmpdir}/p1/stdout >/dev/null 2>&1" -shell "grep bar ${tmpdir}/p2/stdout >/dev/null 2>&1" -shell "grep baz ${tmpdir}/p3/stdout >/dev/null 2>&1" +shell "grep -q foo ${tmpdir}/p1/stdout" +shell "grep -q bar ${tmpdir}/p2/stdout" +shell "grep -q baz ${tmpdir}/p3/stdout" # check stderr shell "test -f ${tmpdir}/p1/stderr -a ! -s ${tmpdir}/p1/stderr" diff --git a/bin/varnishtest/tests/u00002.vtc b/bin/varnishtest/tests/u00002.vtc index c42de64..67b7c81 100644 --- a/bin/varnishtest/tests/u00002.vtc +++ b/bin/varnishtest/tests/u00002.vtc @@ -28,6 +28,4 @@ shell -err "grep -q LCK.vbe.destroy ${tmpdir}/p2/stdout" shell "cmp -s ${tmpdir}/p1/stdout ${tmpdir}/p2/stdout" -process p3 {varnishstat -1 -n ${v1_name} -f MAIN.cache_hit} -run - -shell "grep -q cache_hit ${tmpdir}/p3/stdout" +shell -expect "cache_hit" "varnishstat -1 -n ${v1_name} -f MAIN.cache_hit" diff --git a/bin/varnishtest/tests/u00003.vtc b/bin/varnishtest/tests/u00003.vtc index 53366a3..6737762 100644 --- a/bin/varnishtest/tests/u00003.vtc +++ b/bin/varnishtest/tests/u00003.vtc @@ -8,40 +8,28 @@ server s1 { varnish v1 -vcl+backend {} -start shell -err -expect "Missing -w option" \ - {varnishncsa -n ${v1_name} -D 2>&1} - + {varnishncsa -n ${v1_name} -D} shell -err -expect "Unknown format specifier at: %{foo}A" \ - {varnishncsa -n ${v1_name} -F "%{foo}A" 2>&1} - + {varnishncsa -n ${v1_name} -F "%{foo}A"} shell -err -expect "Unknown format specifier at: %A" \ - {varnishncsa -n ${v1_name} -F "%A" 2>&1} - + {varnishncsa -n ${v1_name} -F "%A"} shell -err -expect "Usage: varnishncsa " \ - {varnishncsa -n ${v1_name} extra 2>&1} - + {varnishncsa -n ${v1_name} extra} shell -err -expect "Missing tag in VSL:" \ - {varnishncsa -n ${v1_name} -F "%{VSL:}x" 2>&1} - + {varnishncsa -n ${v1_name} -F "%{VSL:}x"} shell -err -expect "Unknown log tag: nonexistent" \ - {varnishncsa -n ${v1_name} -F "%{VSL:nonexistent}x" 2>&1} - + {varnishncsa -n ${v1_name} -F "%{VSL:nonexistent}x"} shell -err -expect "Tag not unique: Req" \ - {varnishncsa -n ${v1_name} -F "%{VSL:Req}x" 2>&1} - + {varnishncsa -n ${v1_name} -F "%{VSL:Req}x"} shell -err -expect "Unknown log tag: Begin[" \ - {varnishncsa -n ${v1_name} -F "%{VSL:Begin[}x" 2>&1} - + {varnishncsa -n ${v1_name} -F "%{VSL:Begin[}x"} shell -err -expect "Syntax error: VSL:Begin]" \ - {varnishncsa -n ${v1_name} -F "%{VSL:Begin]}x" 2>&1} - + {varnishncsa -n ${v1_name} -F "%{VSL:Begin]}x"} shell -err -expect "Unknown log tag: Begin[a" \ - {varnishncsa -n ${v1_name} -F "%{VSL:Begin[a}x" 2>&1} - + {varnishncsa -n ${v1_name} -F "%{VSL:Begin[a}x"} shell -err -expect "Syntax error: VSL:Begin[a]" \ - {varnishncsa -n ${v1_name} -F "%{VSL:Begin[a]}x" 2>&1} - + {varnishncsa -n ${v1_name} -F "%{VSL:Begin[a]}x"} shell -err -expect "Syntax error. Field specifier must be positive: Begin[0]" \ - {varnishncsa -n ${v1_name} -F "%{VSL:Begin[0]}x" 2>&1} - + {varnishncsa -n ${v1_name} -F "%{VSL:Begin[0]}x"} shell -err -expect "Field specifier 999999999999 for the tag VSL:Begin[999999999999] is probably too high" \ - {varnishncsa -n ${v1_name} -F "%{VSL:Begin[999999999999]}x" 2>&1} + {varnishncsa -n ${v1_name} -F "%{VSL:Begin[999999999999]}x"} diff --git a/bin/varnishtest/tests/u00005.vtc b/bin/varnishtest/tests/u00005.vtc index 86b328c..b331d26 100644 --- a/bin/varnishtest/tests/u00005.vtc +++ b/bin/varnishtest/tests/u00005.vtc @@ -7,17 +7,19 @@ server s1 { varnish v1 -vcl+backend {} -start -process p1 "exec varnishstat -n ${v1_name} -h" -run -shell {grep -q "Usage: varnishstat " ${tmpdir}/p1/stderr} -process p2 "exec varnishstat -n ${v1_name} -l" -run -shell {grep -q "Varnishstat -f option fields:" ${tmpdir}/p2/stdout} -process p3 "exec varnishstat -n ${v1_name} -V" -run -shell {grep -q "Copyright (c) 2006 Verdens Gang AS" ${tmpdir}/p3/stderr} -process p4 "exec varnishstat -n ${v1_name} -1" -run -shell {grep -q "MAIN.uptime" ${tmpdir}/p4/stdout} -process p5 "exec varnishstat -n ${v1_name} -x" -run -shell {grep -q "MAIN" ${tmpdir}/p5/stdout} -process p6 "exec varnishstat -n ${v1_name} -j" -run -shell {grep -q "MAIN.uptime\":" ${tmpdir}/p6/stdout} -shell -err -expect "Usage: varnishstat " "varnishstat -n ${v1_name} extra 2>&1" -shell -err -expect "Cannot open /nonexistent/_.vsm" "varnishstat -n /nonexistent 2>&1" +shell -expect "Usage: varnishstat " \ + "varnishstat -n ${v1_name} -h" +shell -expect "Varnishstat -f option fields:" \ + "varnishstat -n ${v1_name} -l" +shell -expect "Copyright (c) 2006 Verdens Gang AS" \ + "varnishstat -n ${v1_name} -V" +shell -expect "MAIN.uptime" \ + "varnishstat -n ${v1_name} -1" +shell -expect "MAIN" \ + "varnishstat -n ${v1_name} -x" +shell -expect "MAIN.uptime\":" \ + "varnishstat -n ${v1_name} -j" +shell -err -expect "Usage: varnishstat " \ + "varnishstat -n ${v1_name} extra" +shell -err -expect "Cannot open /nonexistent/_.vsm" \ + "varnishstat -n /nonexistent" diff --git a/bin/varnishtest/tests/u00006.vtc b/bin/varnishtest/tests/u00006.vtc index 64491b0..8ab806c 100644 --- a/bin/varnishtest/tests/u00006.vtc +++ b/bin/varnishtest/tests/u00006.vtc @@ -14,16 +14,19 @@ process p2 { process p3 { exec varnishlog -n ${v1_name} -g raw -k 1 -w ${tmpdir}/p3/output.bin } -start -process p4 "exec varnishlog -n ${v1_name} -h" -run -shell {grep -q "Usage: varnishlog " ${tmpdir}/p4/stderr} -process p5 "exec varnishlog -n ${v1_name} -V" -run -shell {grep -q "Copyright (c) 2006 Verdens Gang AS" ${tmpdir}/p5/stderr} -shell -err -expect "Usage: varnishlog " "varnishlog -n ${v1_name} extra 2>&1" -shell -err -expect "Missing -w option" "varnishlog -n ${v1_name} -D 2>&1" -shell -err -expect "-L: Range error" "varnishlog -n ${v1_name} -L 0 2>&1" +shell -expect "Usage: varnishlog " \ + "varnishlog -n ${v1_name} -h" +shell -expect "Copyright (c) 2006 Verdens Gang AS" \ + "varnishlog -n ${v1_name} -V" +shell -err -expect "Usage: varnishlog " \ + "varnishlog -n ${v1_name} extra" +shell -err -expect "Missing -w option" \ + "varnishlog -n ${v1_name} -D" +shell -err -expect "-L: Range error" \ + "varnishlog -n ${v1_name} -L 0" process p1 -wait shell {grep -q "0 CLI" ${tmpdir}/p1/stdout} process p2 -wait shell {grep -q "0 CLI" ${tmpdir}/p2/output} process p3 -wait -shell {varnishlog -g raw -r ${tmpdir}/p3/output.bin | grep -q "0 CLI"} +shell -expect "0 CLI" {varnishlog -g raw -r ${tmpdir}/p3/output.bin} diff --git a/bin/varnishtest/tests/u00007.vtc b/bin/varnishtest/tests/u00007.vtc index 6f0c6b7..444c07c 100644 --- a/bin/varnishtest/tests/u00007.vtc +++ b/bin/varnishtest/tests/u00007.vtc @@ -7,19 +7,21 @@ server s1 { varnish v1 -vcl+backend {} -start -process p1 "exec varnishhist -n ${v1_name} -h" -run -shell {grep -q "Usage: varnishhist " ${tmpdir}/p1/stderr} +shell -expect "Usage: varnishhist " \ + "varnishhist -n ${v1_name} -h" shell -err -expect "Usage: varnishhist " \ - "varnishhist -n ${v1_name} extra 2>&1" -shell -err -expect "-p: invalid '0'" "varnishhist -n ${v1_name} -p 0 2>&1" + "varnishhist -n ${v1_name} extra" +shell -err -expect "-p: invalid '0'" \ + "varnishhist -n ${v1_name} -p 0" shell -err -expect "-B: being able to bend time does not mean we can stop it" \ - "varnishhist -n ${v1_name} -B 0 2>&1" -shell -err -expect "-B: being able to bend time does not mean we can make it go backwards" "varnishhist -n ${v1_name} -B -1 2>&1" + "varnishhist -n ${v1_name} -B 0" +shell -err -expect "-B: being able to bend time does not mean we can make it go backwards" \ + "varnishhist -n ${v1_name} -B -1" shell -err -expect "Invalid grouping mode: raw" \ - "varnishhist -n ${v1_name} -g raw 2>&1" + "varnishhist -n ${v1_name} -g raw" shell -err -expect "-P: No such profile 'foo'" \ - "varnishhist -n ${v1_name} -P foo 2>&1" + "varnishhist -n ${v1_name} -P foo" shell -err -expect "-P: 'foo:bar' is not a valid profile name or definition" \ - "varnishhist -n ${v1_name} -P foo:bar 2>&1" + "varnishhist -n ${v1_name} -P foo:bar" shell -err -expect "-P: 'foo:0:0:0' is not a valid tag name" \ - "varnishhist -n ${v1_name} -P foo:0:0:0 2>&1" + "varnishhist -n ${v1_name} -P foo:0:0:0" From phk at FreeBSD.org Sun Jan 15 18:28:04 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Sun, 15 Jan 2017 19:28:04 +0100 Subject: [master] b0a7454 Close a couple of races. Message-ID: commit b0a7454f1771f4cefddb6b1340667bedf8df015c Author: Poul-Henning Kamp Date: Sun Jan 15 18:26:16 2017 +0000 Close a couple of races. diff --git a/bin/varnishtest/vtc_process.c b/bin/varnishtest/vtc_process.c index ee4dc05..ac6d4a3 100644 --- a/bin/varnishtest/vtc_process.c +++ b/bin/varnishtest/vtc_process.c @@ -62,8 +62,9 @@ struct process { int fd_from; pid_t pid; + pthread_mutex_t mtx; pthread_t tp; - unsigned running; + unsigned hasthread; int status; }; @@ -95,6 +96,7 @@ process_new(const char *name) ALLOC_OBJ(p, PROCESS_MAGIC); AN(p); REPLACE(p->name, name); + AZ(pthread_mutex_init(&p->mtx, NULL)); p->vl = vtc_logopen(name); AN(p->vl); @@ -129,6 +131,7 @@ process_delete(struct process *p) { CHECK_OBJ_NOTNULL(p, PROCESS_MAGIC); + AZ(pthread_mutex_destroy(&p->mtx)); vtc_logclose(p->vl); free(p->name); free(p->workdir); @@ -174,14 +177,22 @@ process_thread(void *priv) continue; } r = wait4(p->pid, &p->status, 0, &ru); + + closefd(&p->fd_to); + + AZ(pthread_mutex_lock(&p->mtx)); + macro_undef(p->vl, p->name, "pid"); p->pid = -1; - p->running = 0; - vtc_log(p->vl, 2, "R %d Status: %04x (u %.6f s %.6f)", r, p->status, + + vtc_log(p->vl, 2, "R 0x%04x Status: %04x (u %.6f s %.6f)", + r, p->status, ru.ru_utime.tv_sec + 1e-6 * ru.ru_utime.tv_usec, ru.ru_stime.tv_sec + 1e-6 * ru.ru_stime.tv_usec ); + AZ(pthread_mutex_unlock(&p->mtx)); + if (WIFEXITED(p->status) && WEXITSTATUS(p->status) == 0) return (NULL); #ifdef WCOREDUMP @@ -193,8 +204,6 @@ process_thread(void *priv) p->status, WTERMSIG(p->status), WEXITSTATUS(p->status)); #endif - closefd(&p->fd_to); - return (NULL); } @@ -207,6 +216,8 @@ process_start(struct process *p) int fdt[2]; CHECK_OBJ_NOTNULL(p, PROCESS_MAGIC); + if (p->hasthread) + vtc_log(p->vl, 0, "Already running, (-wait first)"); vtc_log(p->vl, 4, "CMD: %s", p->spec); @@ -227,7 +238,6 @@ process_start(struct process *p) } p->pid = fork(); assert(p->pid >= 0); - p->running = 1; if (p->pid == 0) { assert(dup2(fds[0], 0) == 0); assert(dup2(out_fd, 1) == 1); @@ -249,6 +259,7 @@ process_start(struct process *p) closefd(&err_fd); } VSB_destroy(&cl); + p->hasthread = 1; AZ(pthread_create(&p->tp, NULL, process_thread, p)); } @@ -257,12 +268,14 @@ process_start(struct process *p) */ static void -process_wait(const struct process *p) +process_wait(struct process *p) { void *v; - if (p->running && p->pid > 0) + if (p->hasthread) { AZ(pthread_join(p->tp, &v)); + p->hasthread = 0; + } } static void @@ -278,14 +291,19 @@ process_run(struct process *p) */ static void -process_kill(const struct process *p, const char *sig) +process_kill(struct process *p, const char *sig) { int j = 0; + pid_t pid; CHECK_OBJ_NOTNULL(p, PROCESS_MAGIC); AN(sig); + + AZ(pthread_mutex_lock(&p->mtx)); + pid = p->pid; + AZ(pthread_mutex_unlock(&p->mtx)); - if (!p->running || p->pid <= 0) + if (pid <= 0) vtc_log(p->vl, 0, "Cannot signal a non-running process"); if (!strcmp(sig, "TERM")) @@ -299,19 +317,20 @@ process_kill(const struct process *p, const char *sig) else vtc_log(p->vl, 0, "Could not grok signal (%s)", sig); - if (kill(-p->pid, j) < 0) - vtc_log(p->vl, 0, "Failed to send signal %d (%s)", j, strerror(errno)); + if (kill(-pid, j) < 0) + vtc_log(p->vl, 0, "Failed to send signal %d (%s)", + j, strerror(errno)); else vtc_log(p->vl, 4, "Sent signal %d", j); } static inline void -process_terminate(const struct process *p) +process_terminate(struct process *p) { process_kill(p, "TERM"); sleep(1); - if (p->running && p->pid > 0) + if (p->pid > 0) process_kill(p, "KILL"); } @@ -324,7 +343,7 @@ process_write(const struct process *p, const char *text) { int r, len; - if (!p->running || p->pid <= 0) + if (!p->hasthread) vtc_log(p->vl, 0, "Cannot write to a non-running process"); len = strlen(text); @@ -339,7 +358,7 @@ static void process_close(struct process *p) { - if (!p->running || p->pid <= 0) + if (!p->hasthread) vtc_log(p->vl, 0, "Cannot close on a non-running process"); closefd(&p->fd_to); @@ -403,8 +422,10 @@ cmd_process(CMD_ARGS) if (av == NULL) { /* Reset and free */ VTAILQ_FOREACH_SAFE(p, &processes, list, p2) { - if (p->running && p->pid > 0) + if (p->pid > 0) process_terminate(p); + if (p->hasthread) + process_wait(p); VTAILQ_REMOVE(&processes, p, list); process_delete(p); } From phk at FreeBSD.org Sun Jan 15 18:28:04 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Sun, 15 Jan 2017 19:28:04 +0100 Subject: [master] ead65de Don't allocate a lot of VSM for the -F test, we don't need it and it slows things down. Message-ID: commit ead65de2767cd76a6b3a3ae3561d815b97fcf68c Author: Poul-Henning Kamp Date: Sun Jan 15 18:26:30 2017 +0000 Don't allocate a lot of VSM for the -F test, we don't need it and it slows things down. diff --git a/bin/varnishtest/tests/a00009.vtc b/bin/varnishtest/tests/a00009.vtc index 01ababb..202ec4d 100644 --- a/bin/varnishtest/tests/a00009.vtc +++ b/bin/varnishtest/tests/a00009.vtc @@ -35,7 +35,7 @@ shell -err -expect {Neither -b nor -f given} { varnishd -n ${tmpdir}/v0 } # Test -F mode with no VCL loaded -process p1 "exec varnishd -n ${tmpdir}/v0 -F -f '' -a :0" -log -start +process p1 "exec varnishd -n ${tmpdir}/v0 -F -f '' -a :0 -l2m,3m" -log -start delay 1 @@ -49,7 +49,7 @@ shell { } shell -expect {VCL compiled.} { - varnishadm -n ${tmpdir}/v0 vcl.load vcl1 ${tmpdir}/vcl + varnishadm -n ${tmpdir}/v0 vcl.load vcl1 ${tmpdir}/vcl } shell -expect {active auto/warm - vcl1} { @@ -60,4 +60,4 @@ shell {varnishadm -n ${tmpdir}/v0 start}} shell {varnishadm -n ${tmpdir}/v0 debug.listen_address} -#process p1 -stop +process p1 -stop -wait From phk at FreeBSD.org Sun Jan 15 18:47:04 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Sun, 15 Jan 2017 19:47:04 +0100 Subject: [master] 9d790ec Also lock the to-fd Message-ID: commit 9d790ec30df404a8589cbfc189e51bdc6f9403ce Author: Poul-Henning Kamp Date: Sun Jan 15 18:42:19 2017 +0000 Also lock the to-fd diff --git a/bin/varnishtest/vtc_process.c b/bin/varnishtest/vtc_process.c index ac6d4a3..5e77936 100644 --- a/bin/varnishtest/vtc_process.c +++ b/bin/varnishtest/vtc_process.c @@ -178,10 +178,12 @@ process_thread(void *priv) } r = wait4(p->pid, &p->status, 0, &ru); - closefd(&p->fd_to); AZ(pthread_mutex_lock(&p->mtx)); + if (p->fd_to >= 0) + closefd(&p->fd_to); + macro_undef(p->vl, p->name, "pid"); p->pid = -1; @@ -361,7 +363,10 @@ process_close(struct process *p) if (!p->hasthread) vtc_log(p->vl, 0, "Cannot close on a non-running process"); - closefd(&p->fd_to); + AZ(pthread_mutex_lock(&p->mtx)); + if (p->fd_to >= 0) + closefd(&p->fd_to); + AZ(pthread_mutex_unlock(&p->mtx)); } /* SECTION: process process From fgsch at lodoss.net Sun Jan 15 20:07:04 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sun, 15 Jan 2017 21:07:04 +0100 Subject: [master] 4838b82 Revert pasto in earlier commit Message-ID: commit 4838b82e55560dcc466a36b40ea3f7c802fcc203 Author: Federico G. Schwindt Date: Sun Jan 15 19:16:38 2017 +0000 Revert pasto in earlier commit diff --git a/lib/libvmod_debug/vmod_debug_dyn.c b/lib/libvmod_debug/vmod_debug_dyn.c index 8f71121..03610ee 100644 --- a/lib/libvmod_debug/vmod_debug_dyn.c +++ b/lib/libvmod_debug/vmod_debug_dyn.c @@ -58,15 +58,13 @@ dyn_dir_init(VRT_CTX, struct vmod_debug_dyn *dyn, struct director *dir, *dir2; struct vrt_backend vrt; - vrt.port = port; - vrt.hosthdr = addr; CHECK_OBJ_NOTNULL(dyn, VMOD_DEBUG_DYN_MAGIC); XXXAN(addr); XXXAN(port); INIT_OBJ(&vrt, VRT_BACKEND_MAGIC); - vrt.vcl_name = dyn->vcl_name; vrt.port = port; + vrt.vcl_name = dyn->vcl_name; vrt.hosthdr = addr; memset(&hints, 0, sizeof(hints)); From fgsch at lodoss.net Sun Jan 15 23:09:05 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Mon, 16 Jan 2017 00:09:05 +0100 Subject: [master] e968899 Increment fetch_failed for all causes Message-ID: commit e96889983d14abca14894b66729e8b6077206f89 Author: Federico G. Schwindt Date: Sun Jan 15 20:11:48 2017 +0000 Increment fetch_failed for all causes IOW if we ended up in vcl_backend_error{} or failed after returning delivery in vcl_backend_response{} (e.g. we did not receive enough bytes) we will bump this counter. diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 9c4841d..05ad0bf 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -544,6 +544,7 @@ vbf_stp_fetchbody(struct worker *wrk, struct busyobj *bo) // XXX: doclose = ? return (F_STP_ERROR); } else { + wrk->stats->fetch_failed++; return (F_STP_FAIL); } } @@ -794,6 +795,7 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo) (void)VFP_Error(bo->vfc, "Template object failed"); if (bo->vfc->failed) { VDI_Finish(bo->wrk, bo); + wrk->stats->fetch_failed++; return (F_STP_FAIL); } return (F_STP_FETCHEND); @@ -817,6 +819,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++; + now = W_TIM_real(wrk); VSLb_ts_busyobj(bo, "Error", now); @@ -915,7 +919,6 @@ vbf_stp_fail(struct worker *wrk, const struct busyobj *bo) if (!(bo->fetch_objcore->flags & OC_F_BUSY)) HSH_Kill(bo->fetch_objcore); ObjSetState(wrk, bo->fetch_objcore, BOS_FAILED); - wrk->stats->fetch_failed++; return (F_STP_DONE); } diff --git a/bin/varnishtest/tests/b00020.vtc b/bin/varnishtest/tests/b00020.vtc index c51586b..1f0427c 100644 --- a/bin/varnishtest/tests/b00020.vtc +++ b/bin/varnishtest/tests/b00020.vtc @@ -46,4 +46,4 @@ client c1 { varnish v1 -expect n_object == 1 varnish v1 -expect n_objectcore == 1 - +varnish v1 -expect fetch_failed == 1 diff --git a/bin/varnishtest/tests/b00023.vtc b/bin/varnishtest/tests/b00023.vtc index 7685f66..d418904 100644 --- a/bin/varnishtest/tests/b00023.vtc +++ b/bin/varnishtest/tests/b00023.vtc @@ -17,7 +17,6 @@ client c1 { expect resp.status == 503 } -run - server s1 { rxreq delay 0.5 @@ -29,3 +28,5 @@ client c1 { rxresp expect resp.status == 200 } -run + +varnish v1 -expect fetch_failed == 1 diff --git a/bin/varnishtest/tests/b00038.vtc b/bin/varnishtest/tests/b00038.vtc index b963b4f..871ce93 100644 --- a/bin/varnishtest/tests/b00038.vtc +++ b/bin/varnishtest/tests/b00038.vtc @@ -35,3 +35,5 @@ client c1 { rxresp expect resp.status == 503 } -run + +varnish v1 -expect fetch_failed == 1 diff --git a/bin/varnishtest/tests/c00061.vtc b/bin/varnishtest/tests/c00061.vtc index d41ca79..1dba103 100644 --- a/bin/varnishtest/tests/c00061.vtc +++ b/bin/varnishtest/tests/c00061.vtc @@ -22,3 +22,6 @@ client c1 { rxresp expect resp.status == 504 } -run + +varnish v1 -expect backend_fail == 3 +varnish v1 -expect fetch_failed == 3 diff --git a/bin/varnishtest/tests/r01624.vtc b/bin/varnishtest/tests/r01624.vtc index 3232f42..c18ba11 100644 --- a/bin/varnishtest/tests/r01624.vtc +++ b/bin/varnishtest/tests/r01624.vtc @@ -25,9 +25,10 @@ varnish v1 -vcl+backend {} -start client c1 { txreq + rxresphdrs + expect resp.status == 200 non_fatal - timeout 3 - rxresp + rxrespbody } -run delay .2 @@ -38,3 +39,5 @@ client c1 { rxresp expect resp.bodylen == 7 } -run + +varnish v1 -expect fetch_failed == 1 diff --git a/bin/varnishtest/tests/r01648.vtc b/bin/varnishtest/tests/r01648.vtc index 1a8cef9..2780db8 100644 --- a/bin/varnishtest/tests/r01648.vtc +++ b/bin/varnishtest/tests/r01648.vtc @@ -75,3 +75,5 @@ client c3 { expect resp.status == 200 expect resp.body == "abcdef" } -run + +varnish v1 -expect fetch_failed == 2 diff --git a/include/tbl/vsc_f_main.h b/include/tbl/vsc_f_main.h index 6d9b369..7dbc87d 100644 --- a/include/tbl/vsc_f_main.h +++ b/include/tbl/vsc_f_main.h @@ -199,7 +199,7 @@ VSC_FF(fetch_304, uint64_t, 1, 'c', 'i', info, ) VSC_FF(fetch_failed, uint64_t, 1, 'c', 'i', info, - "Fetch failed (all causes), where we do get hold of the backend.", + "Fetch failed (all causes)", "beresp fetch failed." ) From fgsch at lodoss.net Mon Jan 16 00:04:05 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Mon, 16 Jan 2017 01:04:05 +0100 Subject: [master] 135adfa Merge tests Message-ID: commit 135adfa84a96d46f444a8db1bb2f358b46822820 Author: Federico G. Schwindt Date: Sun Jan 15 23:11:37 2017 +0000 Merge tests diff --git a/bin/varnishtest/tests/b00023.vtc b/bin/varnishtest/tests/b00023.vtc index d418904..9ee5ed3 100644 --- a/bin/varnishtest/tests/b00023.vtc +++ b/bin/varnishtest/tests/b00023.vtc @@ -1,15 +1,23 @@ -varnishtest "Check that the first_byte_timeout works from parameters" +varnishtest "Check that the first_byte_timeout works" feature SO_RCVTIMEO_WORKS +# From VCL + server s1 { rxreq - delay 1.5 - txresp -body "foo" + delay 1 + txresp } -start -varnish v1 -vcl+backend {} -start -varnish v1 -cliok "param.set first_byte_timeout 1" +varnish v1 -vcl+backend { + sub vcl_recv { + return (pass); + } + sub vcl_backend_fetch { + set bereq.first_byte_timeout = 0.5s; + } +} -start client c1 { txreq @@ -19,14 +27,65 @@ client c1 { server s1 { rxreq - delay 0.5 - txresp -body "foo" + delay 0.2 + txresp } -start -client c1 { +client c2 { txreq rxresp expect resp.status == 200 } -run -varnish v1 -expect fetch_failed == 1 +# From CLI + +varnish v1 -vcl+backend { + sub vcl_recv { + return (pass); + } +} +varnish v1 -cliok "param.set first_byte_timeout 0.5" + +server s1 { + rxreq + delay 1 + txresp +} -start + +client c1 -run + +server s1 { + rxreq + delay 0.2 + txresp +} -start + +client c2 -run + +# From backend definition + +server s1 { + rxreq + delay 1 + txresp +} -start + +varnish v1 -vcl { + backend b1 { + .host = "${s1_addr}"; + .port = "${s1_port}"; + .first_byte_timeout = 0.5s; + } +} + +client c1 -run + +server s1 { + rxreq + delay 0.2 + txresp +} -start + +client c2 -run + +varnish v1 -expect fetch_failed == 3 diff --git a/bin/varnishtest/tests/b00024.vtc b/bin/varnishtest/tests/b00024.vtc deleted file mode 100644 index 1a55153..0000000 --- a/bin/varnishtest/tests/b00024.vtc +++ /dev/null @@ -1,34 +0,0 @@ -varnishtest "Check that the first_byte_timeout works from vcl" - -feature SO_RCVTIMEO_WORKS - -server s1 { - rxreq - delay 1.5 - txresp -} -start - -varnish v1 -vcl+backend { - sub vcl_backend_fetch { - set bereq.first_byte_timeout = 1s; - } -} -start - -client c1 { - txreq - rxresp - expect resp.status == 503 -} -run - - -server s1 { - rxreq - delay 0.5 - txresp -} -start - -client c1 { - txreq - rxresp - expect resp.status == 200 -} -run diff --git a/bin/varnishtest/tests/b00025.vtc b/bin/varnishtest/tests/b00025.vtc deleted file mode 100644 index 05536ab..0000000 --- a/bin/varnishtest/tests/b00025.vtc +++ /dev/null @@ -1,39 +0,0 @@ -varnishtest "Check that the first_byte_timeout works from backend definition" - -feature SO_RCVTIMEO_WORKS - -server s1 { - rxreq - delay 1.5 - txresp -} -start - -varnish v1 -vcl { - backend b1 { - .host = "${s1_addr}"; - .port = "${s1_port}"; - .first_byte_timeout = 1s; - } -} -start - -# Fragmenting storage tests for #1397 -varnish v1 -cliok "debug.fragfetch 4" - -client c1 { - txreq - rxresp - expect resp.status == 503 -} -run - - -server s1 { - rxreq - delay 0.5 - txresp -} -start - -client c1 { - txreq - rxresp - expect resp.status == 200 -} -run From dridi.boukelmoune at gmail.com Mon Jan 16 06:09:05 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 16 Jan 2017 07:09:05 +0100 Subject: [master] 6e21a2e Fix shell expansion when mixed with regular strings Message-ID: commit 6e21a2ee385aaf1e8210e4904cf99ff8bb7a0f43 Author: Dridi Boukelmoune Date: Mon Jan 16 06:46:51 2017 +0100 Fix shell expansion when mixed with regular strings I noticed that some shells like ye olde bash available on SmartOS don't treat the following construct as single a token: ${dir}/${file} The following expands a single token on the RHS even if the variable contains spaces: var=${dir} But a token involving a regular string too needs to be protected by double quotes: var="${dir}/${file}" Even when none of the variables contain blanks. Refs #2139 diff --git a/tools/vtest.sh b/tools/vtest.sh index b39e819..fdef9eb 100755 --- a/tools/vtest.sh +++ b/tools/vtest.sh @@ -180,17 +180,17 @@ failedtests () ( cd "${SRCDIR}" VERSION=`./configure --version | awk 'NR == 1 {print $NF}'` - LOGDIR=varnish-$VERSION/_build/sub/bin/varnishtest/tests + LOGDIR="varnish-$VERSION/_build/sub/bin/varnishtest/tests" VTCDIR=bin/varnishtest/tests - grep -l ':test-result: FAIL' $LOGDIR/*.trs | + grep -l ':test-result: FAIL' "$LOGDIR/*.trs" | while read trs do name=`basename $trs .trs` - vtc=${name}.vtc - log=${name}.log - rev=`git log -n 1 --pretty=format:%H ${VTCDIR}/${vtc}` - cp ${LOGDIR}/${log} ${REPORTDIR}/_${log} + vtc="${name}.vtc" + log="${name}.log" + rev=`git log -n 1 --pretty=format:%H "${VTCDIR}/${vtc}"` + cp "${LOGDIR}/${log}" "${REPORTDIR}/_${log}" echo "VTCGITREV ${name} ${rev}" echo "MANIFEST _${log}" done From phk at FreeBSD.org Mon Jan 16 08:36:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 16 Jan 2017 09:36:05 +0100 Subject: [master] 86ae6dc Always insert space around '+' and '-' in generated C-code to not accidentally produce '--' and '++' operators. Message-ID: commit 86ae6dcfa265f380178396de06573a1ecebd8e13 Author: Poul-Henning Kamp Date: Mon Jan 16 08:33:56 2017 +0000 Always insert space around '+' and '-' in generated C-code to not accidentally produce '--' and '++' operators. Fixes #2184 diff --git a/lib/libvcc/vcc_expr.c b/lib/libvcc/vcc_expr.c index d97c5f7..415d54b 100644 --- a/lib/libvcc/vcc_expr.c +++ b/lib/libvcc/vcc_expr.c @@ -1023,7 +1023,7 @@ vcc_expr_add(struct vcc *tl, struct expr **e, vcc_type_t fmt) #define ADD_OK(op, a, b, c) \ if (tk->tok == op[0] && (*e)->fmt == a && e2->fmt == b) { \ - *e = vcc_expr_edit(c, "(\v1" op "\v2)", *e, e2); \ + *e = vcc_expr_edit(c, "(\v1 " op " \v2)", *e, e2);\ continue; \ } \ From phk at FreeBSD.org Mon Jan 16 08:36:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 16 Jan 2017 09:36:05 +0100 Subject: [master] 7c9916a Add test which provoked #2184 Message-ID: commit 7c9916a6eb046b2cd81b6c7c23e42bc3ddb424a0 Author: Poul-Henning Kamp Date: Mon Jan 16 08:35:14 2017 +0000 Add test which provoked #2184 diff --git a/bin/varnishtest/tests/v00020.vtc b/bin/varnishtest/tests/v00020.vtc index 42f0f8e..5f36a6c 100644 --- a/bin/varnishtest/tests/v00020.vtc +++ b/bin/varnishtest/tests/v00020.vtc @@ -78,6 +78,8 @@ varnish v1 -vcl { set req.http.foo = now - now; + set req.http.foo = 1- -1; + set req.http.foo = 1 + 1; set req.http.foo = 1 - 1; set req.http.foo = 3 * 2; From dridi.boukelmoune at gmail.com Mon Jan 16 09:04:05 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 16 Jan 2017 10:04:05 +0100 Subject: [master] d38082e Don't swallow the glob Message-ID: commit d38082e01b8d611a69667d3becde5ac2ebac7a0c Author: Dridi Boukelmoune Date: Mon Jan 16 10:02:33 2017 +0100 Don't swallow the glob Refs #2139 diff --git a/tools/vtest.sh b/tools/vtest.sh index fdef9eb..0489ac3 100755 --- a/tools/vtest.sh +++ b/tools/vtest.sh @@ -183,7 +183,7 @@ failedtests () ( LOGDIR="varnish-$VERSION/_build/sub/bin/varnishtest/tests" VTCDIR=bin/varnishtest/tests - grep -l ':test-result: FAIL' "$LOGDIR/*.trs" | + grep -l ':test-result: FAIL' "$LOGDIR"/*.trs | while read trs do name=`basename $trs .trs` From phk at FreeBSD.org Mon Jan 16 11:22:04 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 16 Jan 2017 12:22:04 +0100 Subject: [master] a29fca7 Move the production of vcs_version.h and vmod_abi.h to libvcc/generate.py Message-ID: commit a29fca70f7ccc75964bcfffb8c8ab1617fcf2bba Author: Poul-Henning Kamp Date: Mon Jan 16 10:45:57 2017 +0000 Move the production of vcs_version.h and vmod_abi.h to libvcc/generate.py diff --git a/include/Makefile.am b/include/Makefile.am index 34ca265..3c01782 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -102,59 +102,21 @@ nobase_noinst_HEADERS = \ vut.h \ vut_options.h -tbl/vrt_stv_var.h tbl/vcl_returns.h tbl/vcc_types.h vrt_obj.h: vcl.h -vcl.h: $(top_srcdir)/lib/libvcc/generate.py $(top_srcdir)/include/vrt.h +GENERATED_H = \ + tbl/vrt_stv_var.h \ + tbl/vcl_returns.h \ + tbl/vcc_types.h \ + vrt_obj.h \ + vcl.h \ + vcs_version.h \ + vmod_abi.h + +$(GENERATED_H): $(top_srcdir)/lib/libvcc/generate.py $(top_srcdir)/include/vrt.h mkdir -p tbl @PYTHON@ $(top_srcdir)/lib/libvcc/generate.py $(top_srcdir) $(top_builddir) BUILT_SOURCES = vcs_version.h vmod_abi.h MAINTAINERCLEANFILES = vcs_version.h -vcs_version.h: FORCE - @if [ -d "$(top_srcdir)/.git" ]; then \ - V="$$(git --git-dir=$(top_srcdir)/.git show -s --pretty=format:%h)" \ - B="$$(git --git-dir=$(top_srcdir)/.git rev-parse --abbrev-ref HEAD)" \ - H="$$(head -n 1 vcs_version.h 2>/dev/null || true)"; \ - if [ "/* $$V */" != "$$H" ]; then \ - ( \ - echo "/* $$V */" ;\ - echo '/*' ;\ - echo ' * NB: This file is machine generated, DO NOT EDIT!' ;\ - echo ' *' ;\ - echo ' * Run make to regenerate' ;\ - echo ' *' ;\ - echo ' */' ;\ - echo "/* $$V */" ;\ - echo '' ;\ - echo "#define VCS_Version \"$$V\"" ; \ - echo "#define VCS_Branch \"$$B\"" \ - ) > vcs_version.h ; \ - fi \ - else \ - if [ ! -f vcs_version.h ]; then \ - ( \ - echo "/* NOGIT */" ; \ - echo '/* No git commit ID available, see include/Makefile.am for explanation */' ; \ - echo '#define VCS_Version "NOGIT"' ; \ - echo '#define VCS_Branch "NOGIT"' \ - ) > vcs_version.h ; \ - fi \ - fi -FORCE: - -# If vcs_version contains NOGIT, Varnish has not been built from a -# tarball made with make dist, nor from a git checkout, so there's no -# way for us to give strong guarantees about what version you're -# actually running. -# -# The way to fix this is to either build Varnish from a tarball made -# with `make dist` or a git checkout. - -vmod_abi.h: vcs_version.h - @GITID=$$(sed 's/[^0-9a-f]//g;q' vcs_version.h) ; \ - if [ -z "$$GITID" ]; then \ - echo "warning: weak VMOD ABI checking, see include/Makefile.am" ; \ - fi ; \ - echo "#define VMOD_ABI_Version \"@PACKAGE_STRING@ $$GITID\"" > vmod_abi.h CLEANFILES = \ tbl/vcl_returns.h \ diff --git a/lib/libvcc/generate.py b/lib/libvcc/generate.py index 55bb359..9797273 100755 --- a/lib/libvcc/generate.py +++ b/lib/libvcc/generate.py @@ -30,6 +30,11 @@ # Generate various .c and .h files for the VCL compiler and the interfaces # for it. +from __future__ import print_function + +import subprocess +import os + ####################################################################### # These are our tokens @@ -984,7 +989,7 @@ def file_header(fo): fo.write("""/* * NB: This file is machine generated, DO NOT EDIT! * - * Edit and run generate.py instead. + * Edit and run lib/libvcc/generate.py instead. */ """) @@ -1371,3 +1376,43 @@ for i in stv_variables: fp_vclvar.write("\t%s\n" % j.strip()) fp_vclvar.close() + +####################################################################### + +if os.path.isdir(os.path.join(srcroot, ".git")): + v = subprocess.check_output([ + "git --git-dir=" + os.path.join(srcroot, ".git") + + " show -s --pretty=format:%h" + ], shell=True, universal_newlines=True) + b = subprocess.check_output([ + "git --git-dir=" + os.path.join(srcroot, ".git") + + " rev-parse --abbrev-ref HEAD" + ], shell=True, universal_newlines=True) + b = b.strip() +else: + b = "NOGIT" + v = "NOGIT" + +vcsfn = os.path.join(srcroot, "include", "vcs_version.h") + +try: + i = open(vcsfn).readline() +except IOError: + i = "" + +if i != "/* " + v + " */": + fo = open(vcsfn, "w") + file_header(fo) + fo.write('#define VCS_Version "%s"\n' % v) + fo.write('#define VCS_Branch "%s"\n' % b) + fo.close() + + for i in open(os.path.join(srcroot, "Makefile")): + if i[:14] == "PACKAGE_STRING": + break + i = i.split("=")[1].strip() + + fo = open(os.path.join(srcroot, "include", "vmod_abi.h"), "w") + file_header(fo) + fo.write('#define VMOD_ABI_Version "%s %s"\n' % (i, v)) + fo.close() From phk at FreeBSD.org Mon Jan 16 11:22:04 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 16 Jan 2017 12:22:04 +0100 Subject: [master] cf96240 Make sure people know which generate.py we're talking about Message-ID: commit cf962407ec6ec3fc891dd0e398dada6629687657 Author: Poul-Henning Kamp Date: Mon Jan 16 11:14:23 2017 +0000 Make sure people know which generate.py we're talking about diff --git a/lib/libvarnishapi/generate.py b/lib/libvarnishapi/generate.py index 00205cd..b796fde 100755 --- a/lib/libvarnishapi/generate.py +++ b/lib/libvarnishapi/generate.py @@ -154,7 +154,7 @@ def file_header(fo): fo.write("""/* * NB: This file is machine generated, DO NOT EDIT! * - * Edit and run generate.py instead + * Edit and run lib/libvarnishapi/generate.py instead */ """) From phk at FreeBSD.org Mon Jan 16 11:22:04 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 16 Jan 2017 12:22:04 +0100 Subject: [master] 26c3d5b Whitespace cleanup Message-ID: commit 26c3d5bd14d4f359f3c9a2f55b2312ed43632c64 Author: Poul-Henning Kamp Date: Mon Jan 16 11:21:00 2017 +0000 Whitespace cleanup diff --git a/bin/varnishtest/tests/a00009.vtc b/bin/varnishtest/tests/a00009.vtc index 202ec4d..c783c44 100644 --- a/bin/varnishtest/tests/a00009.vtc +++ b/bin/varnishtest/tests/a00009.vtc @@ -49,7 +49,7 @@ shell { } shell -expect {VCL compiled.} { - varnishadm -n ${tmpdir}/v0 vcl.load vcl1 ${tmpdir}/vcl + varnishadm -n ${tmpdir}/v0 vcl.load vcl1 ${tmpdir}/vcl } shell -expect {active auto/warm - vcl1} { diff --git a/include/Makefile.am b/include/Makefile.am index 3c01782..31cf0c4 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -115,7 +115,7 @@ $(GENERATED_H): $(top_srcdir)/lib/libvcc/generate.py $(top_srcdir)/include/vrt.h mkdir -p tbl @PYTHON@ $(top_srcdir)/lib/libvcc/generate.py $(top_srcdir) $(top_builddir) -BUILT_SOURCES = vcs_version.h vmod_abi.h +BUILT_SOURCES = $(GENERATED_H) MAINTAINERCLEANFILES = vcs_version.h CLEANFILES = \ diff --git a/lib/libvcc/generate.py b/lib/libvcc/generate.py index 9797273..2f27243 100755 --- a/lib/libvcc/generate.py +++ b/lib/libvcc/generate.py @@ -1381,18 +1381,18 @@ fp_vclvar.close() if os.path.isdir(os.path.join(srcroot, ".git")): v = subprocess.check_output([ - "git --git-dir=" + os.path.join(srcroot, ".git") + + "git --git-dir=" + os.path.join(srcroot, ".git") + " show -s --pretty=format:%h" ], shell=True, universal_newlines=True) b = subprocess.check_output([ - "git --git-dir=" + os.path.join(srcroot, ".git") + - " rev-parse --abbrev-ref HEAD" + "git --git-dir=" + os.path.join(srcroot, ".git") + + " rev-parse --abbrev-ref HEAD" ], shell=True, universal_newlines=True) b = b.strip() else: b = "NOGIT" v = "NOGIT" - + vcsfn = os.path.join(srcroot, "include", "vcs_version.h") try: From phk at FreeBSD.org Mon Jan 16 11:36:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 16 Jan 2017 12:36:05 +0100 Subject: [master] c1f8780 Add "-x dumpbuiltin" to varnishd Message-ID: commit c1f87801d25c845a8162e8d115cc607a1c1b6f0d Author: Poul-Henning Kamp Date: Mon Jan 16 11:34:34 2017 +0000 Add "-x dumpbuiltin" to varnishd diff --git a/bin/varnishd/builtin.vcl b/bin/varnishd/builtin.vcl index 9f7a346..2ccbf4c 100644 --- a/bin/varnishd/builtin.vcl +++ b/bin/varnishd/builtin.vcl @@ -26,17 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - - * - * The built-in (previously called default) VCL code. - * - * NB! You do NOT need to copy & paste all of these functions into your - * own vcl code, if you do not provide a definition of one of these - * functions, the compiler will automatically fall back to the default - * code from this file. - * - * This code will be prefixed with a backend declaration built from the - * -b argument. + * This is the builtin VCL code */ vcl 4.0; diff --git a/bin/varnishd/mgt/mgt.h b/bin/varnishd/mgt/mgt.h index 2c88cb4..60e7def 100644 --- a/bin/varnishd/mgt/mgt.h +++ b/bin/varnishd/mgt/mgt.h @@ -178,6 +178,7 @@ void STV_Config(const char *spec); void STV_Config_Transient(void); /* mgt_vcc.c */ +void mgt_DumpBuiltin(void); char *mgt_VccCompile(struct cli *, struct vclprog *, const char *vclname, const char *vclsrc, const char *vclsrcfile, int C_flag); diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index 77aa1d5..af8a521 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -340,6 +340,8 @@ mgt_x_arg(const char *x_arg) mgt_DumpRstVsl(); else if (!strcmp(x_arg, "dumprstcli")) mgt_DumpRstCli(); + else if (!strcmp(x_arg, "dumpbuiltin")) + mgt_DumpBuiltin(); else ARGV_ERR("Invalid -x argument\n"); } diff --git a/bin/varnishd/mgt/mgt_vcc.c b/bin/varnishd/mgt/mgt_vcc.c index 863a49c..6a810b6 100644 --- a/bin/varnishd/mgt/mgt_vcc.c +++ b/bin/varnishd/mgt/mgt_vcc.c @@ -76,6 +76,12 @@ static const char * const builtin_vcl = #include "builtin_vcl.h" "" ; +void +mgt_DumpBuiltin(void) +{ + puts(builtin_vcl); +} + /*-------------------------------------------------------------------- * Invoke system VCC compiler in a sub-process */ diff --git a/bin/varnishtest/tests/a00009.vtc b/bin/varnishtest/tests/a00009.vtc index c783c44..12cb05c 100644 --- a/bin/varnishtest/tests/a00009.vtc +++ b/bin/varnishtest/tests/a00009.vtc @@ -4,6 +4,7 @@ shell "varnishd -b 127.0.0.1:80 -C 2> ${tmpdir}/_.c" shell "varnishd -x dumprstparam > ${tmpdir}/_.param" shell "varnishd -x dumprstvsl > ${tmpdir}/_.vsl" shell "varnishd -x dumprstcli > ${tmpdir}/_.cli" +shell "varnishd -x dumpbuiltin > ${tmpdir}/_.builtin" shell -err -expect {VCL version declaration missing} { echo 'bad vcl' > ${tmpdir}/t.vcl varnishd -f ${tmpdir}/t.vcl -n ${tmpdir} From dridi.boukelmoune at gmail.com Mon Jan 16 12:01:05 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 16 Jan 2017 13:01:05 +0100 Subject: [master] ca79c40 Fix clang-specific warnings Message-ID: commit ca79c402ecc0fe2d68fb8640b6be13c004c967eb Author: Dridi Boukelmoune Date: Fri Dec 30 14:06:20 2016 +0100 Fix clang-specific warnings This round of fixes was originally from work-in-progress in #2174 but the way forward is to remove the autotools. Since #2174 became obsolete they should be checked in independently. Those are warnings we should be able to comply to, but are commented out since they are clang-specific, but I'm not sure how `optreset` should be handled so I left that one alone. Closes #2174 diff --git a/bin/varnishd/cache/cache_vrt_priv.c b/bin/varnishd/cache/cache_vrt_priv.c index 54b6694..bc97995 100644 --- a/bin/varnishd/cache/cache_vrt_priv.c +++ b/bin/varnishd/cache/cache_vrt_priv.c @@ -48,7 +48,7 @@ struct vrt_priv { uintptr_t vmod_id; }; -struct vmod_priv cli_task_priv; +static struct vmod_priv cli_task_priv; /*-------------------------------------------------------------------- */ diff --git a/bin/varnishhist/varnishhist.c b/bin/varnishhist/varnishhist.c index a5f6ee3..f587db4 100644 --- a/bin/varnishhist/varnishhist.c +++ b/bin/varnishhist/varnishhist.c @@ -77,9 +77,9 @@ static unsigned *bucket_miss; static unsigned *bucket_hit; static char *format; static int match_tag; -double timebend = 0, t0; -double vsl_t0 = 0, vsl_to, vsl_ts = 0; -pthread_cond_t timebend_cv; +static double timebend = 0, t0; +static double vsl_t0 = 0, vsl_to, vsl_ts = 0; +static pthread_cond_t timebend_cv; static double log_ten; static int scales[] = { @@ -106,7 +106,7 @@ static int scales[] = { INT_MAX }; -struct profile { +static struct profile { const char *name; char VSL_arg; enum VSL_tag_e tag; diff --git a/bin/varnishlog/varnishlog.c b/bin/varnishlog/varnishlog.c index b61512d..f4415a1 100644 --- a/bin/varnishlog/varnishlog.c +++ b/bin/varnishlog/varnishlog.c @@ -52,7 +52,7 @@ static const char progname[] = "varnishlog"; -struct log { +static struct log { /* Options */ int a_opt; int A_opt; diff --git a/bin/varnishncsa/varnishncsa.c b/bin/varnishncsa/varnishncsa.c index 18c8132..b6e68cb 100644 --- a/bin/varnishncsa/varnishncsa.c +++ b/bin/varnishncsa/varnishncsa.c @@ -134,7 +134,7 @@ struct vsl_watch { }; VTAILQ_HEAD(vsl_watch_head, vsl_watch); -struct ctx { +static struct ctx { /* Options */ int a_opt; int b_opt; diff --git a/bin/varnishtest/vtc.h b/bin/varnishtest/vtc.h index f6756a0..e196bf6 100644 --- a/bin/varnishtest/vtc.h +++ b/bin/varnishtest/vtc.h @@ -75,6 +75,9 @@ extern int vtc_stop; /* Abandon current test, no error */ extern pthread_t vtc_thread; extern int iflg; extern unsigned vtc_maxdur; +extern char *vmod_path; +extern struct vsb *params_vsb; +extern int leave_temp; extern int vtc_witness; extern int feature_dns; diff --git a/bin/varnishtest/vtc_h2_hpack.c b/bin/varnishtest/vtc_h2_hpack.c index f6378f7..695d2d7 100644 --- a/bin/varnishtest/vtc_h2_hpack.c +++ b/bin/varnishtest/vtc_h2_hpack.c @@ -49,8 +49,6 @@ static struct symbol coding_table[] = { #include "vtc_h2_dectbl.h" -struct symbol *EOS = &coding_table[256]; - #define MASK(pack, n) (pack >> (64 - n)) static int huff_decode(char *str, int nm, struct hpk_iter *iter, int ilen) diff --git a/bin/varnishtest/vtc_h2_tbl.c b/bin/varnishtest/vtc_h2_tbl.c index 21bcbd9..ae2ceca 100644 --- a/bin/varnishtest/vtc_h2_tbl.c +++ b/bin/varnishtest/vtc_h2_tbl.c @@ -44,7 +44,7 @@ #undef STAT_HDRS /*lint -save -e778 */ -const struct hpk_hdr sttbl[] = { +static const struct hpk_hdr sttbl[] = { {{NULL, 0, 0}, {NULL, 0, 0}, hpk_idx, 0}, #define STAT_HDRS(j, k, v) \ { \ diff --git a/bin/varnishtest/vtc_http.c b/bin/varnishtest/vtc_http.c index 419491a..d04b666 100644 --- a/bin/varnishtest/vtc_http.c +++ b/bin/varnishtest/vtc_http.c @@ -1666,7 +1666,7 @@ cmd_http_fatal(CMD_ARGS) * Same as for the top-level barrier */ -const char PREFACE[24] = "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n"; +static const char PREFACE[24] = "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n"; /* SECTION: client-server.spec.txpri * diff --git a/bin/varnishtest/vtc_main.c b/bin/varnishtest/vtc_main.c index 0a2c6e3..158de74 100644 --- a/bin/varnishtest/vtc_main.c +++ b/bin/varnishtest/vtc_main.c @@ -81,7 +81,7 @@ struct vtc_job { int iflg = 0; unsigned vtc_maxdur = 60; -unsigned vtc_bufsiz = 512 * 1024; +static unsigned vtc_bufsiz = 512 * 1024; static VTAILQ_HEAD(, vtc_tst) tst_head = VTAILQ_HEAD_INITIALIZER(tst_head); static struct vev_base *vb; diff --git a/lib/libvarnish/vnum.c b/lib/libvarnish/vnum.c index 750ff77..d7e1343 100644 --- a/lib/libvarnish/vnum.c +++ b/lib/libvarnish/vnum.c @@ -230,7 +230,7 @@ static struct test_case { { 0, 0, 0 }, }; -const char *vec[] = { +static const char *vec[] = { " 1", " 12", " 12.", diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py index dff4403..a6db988 100755 --- a/lib/libvcc/vmodtool.py +++ b/lib/libvcc/vmodtool.py @@ -724,7 +724,8 @@ class vcc(object): write_c_file_warning(fo) fo.write("struct vmod_priv;\n") fo.write("\n") - fo.write("extern const struct vmod_data Vmod_debug_Data;\n") + fo.write("extern const struct vmod_data Vmod_%s_Data;\n" % + (self.modname)) fo.write("\n") for j in self.contents: @@ -755,7 +756,7 @@ class vcc(object): fo.write("/*lint -restore */\n") def api(self, fo): - fo.write("\n/*lint -esym(759, Vmod_debug_Data) */\n") + fo.write("\n/*lint -esym(759, Vmod_%s_Data) */\n" % (self.modname)) fo.write("const struct vmod_data Vmod_%s_Data = {\n" % self.modname) fo.write("\t.vrt_major =\tVRT_MAJOR_VERSION,\n") From nils.goroll at uplex.de Mon Jan 16 13:00:06 2017 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 16 Jan 2017 14:00:06 +0100 Subject: [master] 4f85132 sync test name with reality Message-ID: commit 4f8513242675a28ba8641df6c6f5a508146840dc Author: Nils Goroll Date: Mon Jan 16 13:46:20 2017 +0100 sync test name with reality diff --git a/bin/varnishtest/tests/v00000.vtc b/bin/varnishtest/tests/v00000.vtc index fc22294..10f3892 100644 --- a/bin/varnishtest/tests/v00000.vtc +++ b/bin/varnishtest/tests/v00000.vtc @@ -1,4 +1,4 @@ -varnishtest "VCL/VRT: req.grace, obj.ttl and obj.grace" +varnishtest "VCL/VRT: req.ttl / beresp.ttl / beresp.grace" server s1 { From nils.goroll at uplex.de Mon Jan 16 13:00:06 2017 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 16 Jan 2017 14:00:06 +0100 Subject: [master] 282f3f4 Document req.ttl and when it is going to be removed Message-ID: commit 282f3f41aa51d52d350b5e9cb821f9ff9f128117 Author: Nils Goroll Date: Mon Jan 16 13:58:43 2017 +0100 Document req.ttl and when it is going to be removed closes #2014 diff --git a/lib/libvcc/generate.py b/lib/libvcc/generate.py index 2f27243..c3b971b 100755 --- a/lib/libvcc/generate.py +++ b/lib/libvcc/generate.py @@ -280,6 +280,14 @@ sp_variables = [ 'DURATION', ('client',), ('client',), """ + Upper limit on the object age for cache lookups to return hit. + + Usage of req.ttl should be replaced with a check on + obj.ttl in vcl_hit, returning miss when needed, but + this currently hits bug #1799, so an additional + workaround is required. + + Deprecated and scheduled for removal with varnish release 7. """ ), ('req.xid', From fgsch at lodoss.net Mon Jan 16 13:18:05 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Mon, 16 Jan 2017 14:18:05 +0100 Subject: [master] 766dee0 Drop long broken umem code Message-ID: commit 766dee06e1eba0309453a1c6e1115975b46eed8b Author: Federico G. Schwindt Date: Mon Jan 16 13:01:42 2017 +0000 Drop long broken umem code This can be reintroduced at a later time when someone feels like fixing / rewritting it. Related to #2147. diff --git a/bin/varnishd/Makefile.am b/bin/varnishd/Makefile.am index b812cc7..edc23f4 100644 --- a/bin/varnishd/Makefile.am +++ b/bin/varnishd/Makefile.am @@ -101,7 +101,6 @@ varnishd_SOURCES = \ storage/storage_persistent_silo.c \ storage/storage_persistent_subr.c \ storage/storage_simple.c \ - storage/storage_umem.c \ waiter/mgt_waiter.c \ waiter/cache_waiter.c \ waiter/cache_waiter_epoll.c \ @@ -157,7 +156,7 @@ varnishd_LDADD = \ @SAN_LDFLAGS@ \ @JEMALLOC_LDADD@ \ @PCRE_LIBS@ \ - ${DL_LIBS} ${PTHREAD_LIBS} ${NET_LIBS} ${RT_LIBS} ${LIBM} ${UMEM_LIBS} + ${DL_LIBS} ${PTHREAD_LIBS} ${NET_LIBS} ${RT_LIBS} ${LIBM} noinst_PROGRAMS = vhp_gen_hufdec vhp_gen_hufdec_SOURCES = hpack/vhp_gen_hufdec.c diff --git a/bin/varnishd/Makefile.phk b/bin/varnishd/Makefile.phk index 54f058a..28d8e85 100644 --- a/bin/varnishd/Makefile.phk +++ b/bin/varnishd/Makefile.phk @@ -89,7 +89,6 @@ PROG_SRC += storage/storage_persistent.c PROG_SRC += storage/storage_persistent_silo.c PROG_SRC += storage/storage_persistent_subr.c PROG_SRC += storage/storage_simple.c -PROG_SRC += storage/storage_umem.c PROG_SRC += waiter/cache_waiter.c PROG_SRC += waiter/cache_waiter_epoll.c diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index af8a521..0090655 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -117,9 +117,6 @@ usage(void) fprintf(stderr, FMT, "-s [name=]kind[,options]", "Backend storage specification"); fprintf(stderr, FMT, "", " -s malloc[,]"); -#ifdef HAVE_LIBUMEM - fprintf(stderr, FMT, "", " -s umem"); -#endif fprintf(stderr, FMT, "", " -s file,"); fprintf(stderr, FMT, "", " -s file,,"); fprintf(stderr, FMT, "", diff --git a/bin/varnishd/storage/mgt_stevedore.c b/bin/varnishd/storage/mgt_stevedore.c index c0cb743..304b3bd 100644 --- a/bin/varnishd/storage/mgt_stevedore.c +++ b/bin/varnishd/storage/mgt_stevedore.c @@ -125,9 +125,6 @@ static const struct choice STV_choice[] = { { "malloc", &sma_stevedore }, { "deprecated_persistent", &smp_stevedore }, { "persistent", &smp_fake_stevedore }, -#if defined(HAVE_LIBUMEM) && 0 - { "umem", &smu_stevedore }, -#endif { NULL, NULL } }; diff --git a/bin/varnishd/storage/storage_umem.c b/bin/varnishd/storage/storage_umem.c deleted file mode 100644 index edc798f..0000000 --- a/bin/varnishd/storage/storage_umem.c +++ /dev/null @@ -1,170 +0,0 @@ -/*- - * Copyright (c) 2006 Verdens Gang AS - * Copyright (c) 2006-2011 Varnish Software AS - * All rights reserved. - * - * Author: Poul-Henning Kamp - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * Storage method based on umem_alloc(3MALLOC) - */ - -//lint -e{766} -#include "config.h" - -#if defined(HAVE_LIBUMEM) && 0 - -#include -#include -#include - -#include "cache/cache.h" -#include "cache/cache_obj.h" -#include "storage/storage.h" -#include "storage/storage_simple.h" - -static size_t smu_max = SIZE_MAX; -static MTX smu_mtx; - -struct smu { - struct storage s; - size_t sz; -}; - -static struct storage * -smu_alloc(const struct stevedore *st, size_t size) -{ - struct smu *smu; - - Lck_Lock(&smu_mtx); - VSC_C_main->sma_nreq++; - if (VSC_C_main->sma_nbytes + size > smu_max) - size = 0; - else { - VSC_C_main->sma_nobj++; - VSC_C_main->sma_nbytes += size; - VSC_C_main->sma_balloc += size; - } - Lck_Unlock(&smu_mtx); - - if (size == 0) - return (NULL); - - smu = umem_zalloc(sizeof *smu, UMEM_DEFAULT); - if (smu == NULL) - return (NULL); - smu->sz = size; - smu->s.priv = smu; - smu->s.ptr = umem_alloc(size, UMEM_DEFAULT); - XXXAN(smu->s.ptr); - smu->s.len = 0; - smu->s.space = size; - smu->s.fd = -1; - smu->s.stevedore = st; - smu->s.magic = STORAGE_MAGIC; - return (&smu->s); -} - -static void -smu_free(struct storage *s) -{ - struct smu *smu; - - CHECK_OBJ_NOTNULL(s, STORAGE_MAGIC); - smu = s->priv; - assert(smu->sz == smu->s.space); - Lck_Lock(&smu_mtx); - VSC_C_main->sma_nobj--; - VSC_C_main->sma_nbytes -= smu->sz; - VSC_C_main->sma_bfree += smu->sz; - Lck_Unlock(&smu_mtx); - umem_free(smu->s.ptr, smu->s.space); - umem_free(smu, sizeof *smu); -} - -static void -smu_trim(const struct storage *s, size_t size) -{ - struct smu *smu; - void *p; - - CHECK_OBJ_NOTNULL(s, STORAGE_MAGIC); - smu = s->priv; - assert(smu->sz == smu->s.space); - if ((p = umem_alloc(size, UMEM_DEFAULT)) != NULL) { - memcpy(p, smu->s.ptr, size); - umem_free(smu->s.ptr, smu->s.space); - Lck_Lock(&smu_mtx); - VSC_C_main->sma_nbytes -= (smu->sz - size); - VSC_C_main->sma_bfree += smu->sz - size; - smu->sz = size; - Lck_Unlock(&smu_mtx); - smu->s.ptr = p; - smu->s.space = size; - } -} - -static void -smu_init(struct stevedore *parent, int ac, char * const *av) -{ - const char *e; - uintmax_t u; - - (void)parent; - - AZ(av[ac]); - if (ac > 1) - ARGV_ERR("(-sumem) too many arguments\n"); - - if (ac == 0 || *av[0] == '\0') - return; - - e = VNUM_2bytes(av[0], &u, 0); - if (e != NULL) - ARGV_ERR("(-sumem) size \"%s\": %s\n", av[0], e); - if ((u != (uintmax_t)(size_t)u)) - ARGV_ERR("(-sumem) size \"%s\": too big\n", av[0]); - smu_max = u; -} - -static void -smu_open(const struct stevedore *st) -{ - (void)st; - AZ(pthread_mutex_init(&smu_mtx, NULL)); -} - -const struct stevedore smu_stevedore = { - .magic = STEVEDORE_MAGIC, - .name = "umem", - .init = smu_init, - .open = smu_open, - .alloc = smu_alloc, - .free = smu_free, - .trim = smu_trim, - .allocobj = SML_allocobj, - .panic = SML_panic, - .methods = &SML_methods, -}; - -#endif /* HAVE_UMEM_H */ diff --git a/config.phk b/config.phk index 7058ced..ae7bc93 100644 --- a/config.phk +++ b/config.phk @@ -71,8 +71,7 @@ if true ; then sys/filio.h \ sys/mount.h \ sys/statvfs.h \ - sys/vfs.h \ - umem.h + sys/vfs.h do if [ -f /usr/include/$i ] ; then n=`echo $i | tr '[a-z/.]' '[A-Z__]'` @@ -299,7 +298,6 @@ exit 0 # SO_SNDTIMEO_WORKS + # VCC_CC + # HAVE_EPOLL_CTL - -# HAVE_LIBUMEM - # USE_PCRE_JIT - # _FILE_OFFSET_BITS - # diff --git a/configure.ac b/configure.ac index 10baf91..f4d8ec3 100644 --- a/configure.ac +++ b/configure.ac @@ -81,9 +81,6 @@ if test "x$ax_cv_curses" != xyes; then AC_MSG_ERROR([requires an X/Open-compatible Curses library]) fi -# Userland slab allocator from Solaris, ported to other systems -AC_CHECK_HEADERS([umem.h], [_VARNISH_CHECK_LIB(umem, umem_alloc)]) - # XXX: This _may_ be for OS/X AC_CHECK_LIBM AC_SUBST(LIBM) From fgsch at lodoss.net Mon Jan 16 13:18:05 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Mon, 16 Jan 2017 14:18:05 +0100 Subject: [master] eac07a5 Improvements as I go through the tests Message-ID: commit eac07a58e82c0d3b6353273793fdf6efca56671a Author: Federico G. Schwindt Date: Mon Jan 16 13:05:39 2017 +0000 Improvements as I go through the tests diff --git a/bin/varnishtest/tests/b00030.vtc b/bin/varnishtest/tests/b00030.vtc index a3fb9cc..5962b40 100644 --- a/bin/varnishtest/tests/b00030.vtc +++ b/bin/varnishtest/tests/b00030.vtc @@ -10,7 +10,7 @@ server s1 { varnish v1 -vcl+backend { sub vcl_recv { - return (synth(200,req.ttl)); + return (synth(200)); } sub vcl_synth { set resp.http.x-timestamp = now; @@ -20,5 +20,5 @@ varnish v1 -vcl+backend { client c1 { txreq rxresp - expect resp.reason == "-1.000" + expect resp.http.x-timestamp ~ "..., .. ... .... ..:..:.. GMT" } -run diff --git a/bin/varnishtest/tests/b00036.vtc b/bin/varnishtest/tests/b00036.vtc index c07fe86..97902ec 100644 --- a/bin/varnishtest/tests/b00036.vtc +++ b/bin/varnishtest/tests/b00036.vtc @@ -27,9 +27,7 @@ client c1 { txreq -req PURGE rxresp expect resp.reason == "Purged" -} -run -client c1 { txreq rxresp expect resp.http.foo == 2 diff --git a/bin/varnishtest/tests/b00040.vtc b/bin/varnishtest/tests/b00040.vtc index 123c3a1..228aaa9 100644 --- a/bin/varnishtest/tests/b00040.vtc +++ b/bin/varnishtest/tests/b00040.vtc @@ -1,4 +1,4 @@ -varnishtest "test certain mailformed reqests" +varnishtest "test certain mailformed requests" server s1 { rxreq diff --git a/bin/varnishtest/tests/v00020.vtc b/bin/varnishtest/tests/v00020.vtc index 5f36a6c..e76e2cb 100644 --- a/bin/varnishtest/tests/v00020.vtc +++ b/bin/varnishtest/tests/v00020.vtc @@ -78,22 +78,32 @@ varnish v1 -vcl { set req.http.foo = now - now; - set req.http.foo = 1- -1; - set req.http.foo = 1 + 1; set req.http.foo = 1 - 1; + set req.http.foo = 1 + -1; + set req.http.foo = 1 - -1; set req.http.foo = 3 * 2; set req.http.foo = 3 / 2; + set req.http.foo = 3 * -2; + set req.http.foo = 3 / -2; set req.http.foo = 3.6 + 1.4; set req.http.foo = 3.6 - 1.4; + set req.http.foo = 3.6 + -1.4; + set req.http.foo = 3.6 - -1.4; set req.http.foo = 3.6 * 1.4; set req.http.foo = 3.6 / 1.4; + set req.http.foo = 3.6 * -1.4; + set req.http.foo = 3.6 / -1.4; set req.http.foo = 1.0 + 1; set req.http.foo = 1.0 - 1; + set req.http.foo = 1.0 + -1; + set req.http.foo = 1.0 - -1; set req.http.foo = 3.0 * 2; set req.http.foo = 3.0 / 2; + set req.http.foo = 3.0 * -2; + set req.http.foo = 3.0 / -2; set req.http.foo = req.http.foo + "bar" ~ "bar"; set req.http.foo = req.http.foo + "bar" !~ "bar"; From fgsch at lodoss.net Mon Jan 16 13:18:05 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Mon, 16 Jan 2017 14:18:05 +0100 Subject: [master] 44b5055 Whitespace OCD Message-ID: commit 44b5055695a887121c359850f52656b5f441c75f Author: Federico G. Schwindt Date: Mon Jan 16 13:06:51 2017 +0000 Whitespace OCD diff --git a/bin/varnishtest/vtc_process.c b/bin/varnishtest/vtc_process.c index 5e77936..ee22d4a 100644 --- a/bin/varnishtest/vtc_process.c +++ b/bin/varnishtest/vtc_process.c @@ -300,7 +300,7 @@ process_kill(struct process *p, const char *sig) CHECK_OBJ_NOTNULL(p, PROCESS_MAGIC); AN(sig); - + AZ(pthread_mutex_lock(&p->mtx)); pid = p->pid; AZ(pthread_mutex_unlock(&p->mtx)); diff --git a/include/Makefile.am b/include/Makefile.am index 31cf0c4..4534cbf 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -109,7 +109,7 @@ GENERATED_H = \ vrt_obj.h \ vcl.h \ vcs_version.h \ - vmod_abi.h + vmod_abi.h $(GENERATED_H): $(top_srcdir)/lib/libvcc/generate.py $(top_srcdir)/include/vrt.h mkdir -p tbl diff --git a/tools/vtest.sh b/tools/vtest.sh index 0489ac3..33d94f1 100755 --- a/tools/vtest.sh +++ b/tools/vtest.sh @@ -158,7 +158,7 @@ makegcov () ( make || exit 1 - if [ `id -u` -eq 0 ] ; then + if [ `id -u` -eq 0 ] ; then chown -R varnish . | true fi @@ -168,7 +168,7 @@ makegcov () ( retval=1 fi - if [ `id -u` -eq 0 ] ; then + if [ `id -u` -eq 0 ] ; then chown -R root . || true fi exit ${retval} From martin at varnish-software.com Mon Jan 16 15:00:06 2017 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Mon, 16 Jan 2017 16:00:06 +0100 Subject: [master] 39e5492 The storage element may be empty on fetch fail Message-ID: commit 39e5492b191e6b8c4f84d9d18e118c22a236cad3 Author: Martin Blix Grydeland Date: Mon Jan 16 14:55:36 2017 +0100 The storage element may be empty on fetch fail A failed fetch won't have the storage trimmed, which may result in an empty storage element in the body list. Do not assert on non-empty size in the simple iterator. Fixes: #2186 diff --git a/bin/varnishd/storage/storage_simple.c b/bin/varnishd/storage/storage_simple.c index 584da81..011b9ec 100644 --- a/bin/varnishd/storage/storage_simple.c +++ b/bin/varnishd/storage/storage_simple.c @@ -260,8 +260,7 @@ sml_iterator(struct worker *wrk, struct objcore *oc, if (boc == NULL) { VTAILQ_FOREACH_SAFE(st, &obj->list, list, checkpoint) { - AN(st->len); - if (ret == 0) + if (ret == 0 && st->len > 0) ret = func(priv, 1, st->ptr, st->len); if (final) { VTAILQ_REMOVE(&obj->list, st, list); From dridi.boukelmoune at gmail.com Mon Jan 16 17:51:05 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 16 Jan 2017 18:51:05 +0100 Subject: [master] 48a93f6 Fix vtest on SmartOS Message-ID: commit 48a93f69e7387a7fa0b85e0d736c179843864722 Author: Dridi Boukelmoune Date: Mon Jan 16 18:48:19 2017 +0100 Fix vtest on SmartOS It looks like it was simply a difference between automake versions, let's see if it pans out. Refs #2139 diff --git a/tools/vtest.sh b/tools/vtest.sh index 33d94f1..4bb8ffe 100755 --- a/tools/vtest.sh +++ b/tools/vtest.sh @@ -183,6 +183,10 @@ failedtests () ( LOGDIR="varnish-$VERSION/_build/sub/bin/varnishtest/tests" VTCDIR=bin/varnishtest/tests + # cope with older automake, remove the sub directory + test ! -d $LOGDIR && + LOGDIR="varnish-$VERSION/_build/bin/varnishtest/tests" + grep -l ':test-result: FAIL' "$LOGDIR"/*.trs | while read trs do From dridi.boukelmoune at gmail.com Tue Jan 17 09:17:05 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 17 Jan 2017 10:17:05 +0100 Subject: [master] cb504e5 Remove umem remnant Message-ID: commit cb504e5aaa723e777b29ad8d4fb2885b7b7609ef Author: Dridi Boukelmoune Date: Tue Jan 17 10:15:47 2017 +0100 Remove umem remnant diff --git a/bin/varnishd/storage/storage.h b/bin/varnishd/storage/storage.h index 8969f75..2c842d0 100644 --- a/bin/varnishd/storage/storage.h +++ b/bin/varnishd/storage/storage.h @@ -148,6 +148,3 @@ void LRU_Touch(struct worker *, struct objcore *, double now); extern const struct stevedore sma_stevedore; extern const struct stevedore smf_stevedore; extern const struct stevedore smp_stevedore; -#ifdef HAVE_LIBUMEM -extern const struct stevedore smu_stevedore; -#endif From fgsch at lodoss.net Tue Jan 17 11:09:04 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Tue, 17 Jan 2017 12:09:04 +0100 Subject: [master] a95ff27 Add -log here as well and rearrange options Message-ID: commit a95ff27619593d9d0a5f8389536f94758ba3e0dd Author: Federico G. Schwindt Date: Tue Jan 17 10:59:01 2017 +0000 Add -log here as well and rearrange options diff --git a/bin/varnishtest/vtc_process.c b/bin/varnishtest/vtc_process.c index ee22d4a..af07779 100644 --- a/bin/varnishtest/vtc_process.c +++ b/bin/varnishtest/vtc_process.c @@ -374,8 +374,8 @@ process_close(struct process *p) * Run a process in the background with stdout and stderr redirected to * ${tmpdir}/pNAME/stdout and ${tmpdir}/pNAME/stderr, respectively:: * - * process pNAME SPEC [-wait] [-start] [-run] [-kill STRING] [-stop] \ - * [-write STRING] [-writeln STRING] [-close] + * process pNAME SPEC [-start] [-log] [-wait] [-run] [-kill STRING] \ + * [-stop] [-write STRING] [-writeln STRING] [-close] * * pNAME * Name of the process. It must start with 'p'. From fgsch at lodoss.net Tue Jan 17 22:05:05 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Tue, 17 Jan 2017 23:05:05 +0100 Subject: [master] 142ff1e Strip whitespaces from the version as well Message-ID: commit 142ff1ecf2da41c04226ce3e5c79230f842b4899 Author: Federico G. Schwindt Date: Tue Jan 17 20:58:12 2017 +0000 Strip whitespaces from the version as well diff --git a/lib/libvcc/generate.py b/lib/libvcc/generate.py index c3b971b..8e046e5 100755 --- a/lib/libvcc/generate.py +++ b/lib/libvcc/generate.py @@ -1392,6 +1392,7 @@ if os.path.isdir(os.path.join(srcroot, ".git")): "git --git-dir=" + os.path.join(srcroot, ".git") + " show -s --pretty=format:%h" ], shell=True, universal_newlines=True) + v = v.strip() b = subprocess.check_output([ "git --git-dir=" + os.path.join(srcroot, ".git") + " rev-parse --abbrev-ref HEAD" From fgsch at lodoss.net Tue Jan 17 22:05:05 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Tue, 17 Jan 2017 23:05:05 +0100 Subject: [master] 960fcc1 Fix tyops Message-ID: commit 960fcc1794818b8a37dc196b0ccb6fff67b7eedc Author: Daniel Gustafsson Date: Tue Jan 17 13:01:41 2017 +0100 Fix tyops diff --git a/doc/sphinx/phk/trialerror.rst b/doc/sphinx/phk/trialerror.rst index 86009b3..d36688e 100644 --- a/doc/sphinx/phk/trialerror.rst +++ b/doc/sphinx/phk/trialerror.rst @@ -21,7 +21,7 @@ and Management of Systems Prototyping"* etc. etc. The grey-beard at my workplace laconically said *"We already do that, only we call it Trial&Error."* -Programming as always been Trial&Error, and probably always will. +Programming has always been Trial&Error, and probably always will. All the early pioneers, like Wheeler, complained about how batch-scheduling of machine resources removed the "intimate" contact @@ -103,8 +103,8 @@ So it is only fair to dedicate VTEST to the friend I chatted with: `Bjarne `_ tried to model how to best distribute operating system kernels across a network, wrote a -adequate programming language tool for the job, which wass also -an adeqaute tool for a lot of other programming jobs. +adequate programming language tool for the job, which was also +an adequate tool for a lot of other programming jobs. Thanks Bjarne! From fgsch at lodoss.net Tue Jan 17 22:30:06 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Tue, 17 Jan 2017 23:30:06 +0100 Subject: [master] b8dec33 fix vsm_free (never incremented) Message-ID: commit b8dec3334e739a07a22dcbeb39aafcd45ed15fb8 Author: Emmanuel Hocdet Date: Mon Jan 16 18:15:50 2017 +0100 fix vsm_free (never incremented) diff --git a/bin/varnishd/common/common_vsm.c b/bin/varnishd/common/common_vsm.c index e91ef24..7b38c4a 100644 --- a/bin/varnishd/common/common_vsm.c +++ b/bin/varnishd/common/common_vsm.c @@ -179,6 +179,7 @@ VSM_common_cleaner(struct vsm_sc *sc, struct VSC_C_main *stats) break; VTAILQ_REMOVE(&sc->r_cooling, vr, list); sc->g_cooling -= vr->len; + sc->g_free += vr->len; vsm_common_insert_free(sc, vr); } stats->vsm_free = sc->g_free; From dridi.boukelmoune at gmail.com Wed Jan 18 09:39:05 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Wed, 18 Jan 2017 10:39:05 +0100 Subject: [master] fbc7240 There won't be a 5.0.1 Message-ID: commit fbc7240a332a666150d66dcfb13a7696def04bd8 Author: Dridi Boukelmoune Date: Wed Jan 18 10:37:22 2017 +0100 There won't be a 5.0.1 diff --git a/varnish.m4 b/varnish.m4 index bb26331..8b7d70e 100644 --- a/varnish.m4 +++ b/varnish.m4 @@ -29,7 +29,7 @@ # OF THE POSSIBILITY OF SUCH DAMAGE. # varnish.m4 - Macros to define VMOD builds. -*- Autoconf -*- -# serial 6 (varnish-5.0.1) +# serial 6 (varnish-5.1.0) # # This collection of macros helps create VMODs or tools interacting with # Varnish Cache using the GNU build system (autotools). In order to work @@ -318,7 +318,7 @@ AC_DEFUN([VARNISH_VMODS], [ # -------------------------------------------------- # Since: Varnish 4.1.4 # -# Since Varnish 5.0.1: +# Since Varnish 5.1.0: # - VARNISH_TEST_PATH added # - VARNISH_LIBRARY_PATH added # - VARNISHAPI_LIBDIR added From phk at FreeBSD.org Wed Jan 18 10:26:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 18 Jan 2017 11:26:05 +0100 Subject: [master] e8eac09 Clean up the vtc_logging a little bit, and make a explicit vtc_fatal() function to use instead of vtc_log(..., 0, ) in trivial cases. Message-ID: commit e8eac09fe5f709c041074d56ea95759def5cd97d Author: Poul-Henning Kamp Date: Wed Jan 18 10:24:11 2017 +0000 Clean up the vtc_logging a little bit, and make a explicit vtc_fatal() function to use instead of vtc_log(..., 0,) in trivial cases. diff --git a/bin/varnishtest/flint.lnt b/bin/varnishtest/flint.lnt index 3c31604..1ef8431 100644 --- a/bin/varnishtest/flint.lnt +++ b/bin/varnishtest/flint.lnt @@ -1,6 +1,9 @@ -// vtc_log's arg2 acts like an assert +// Tell FlexeLint when these don't return +-function(exit, vtc_fatal) -function(__assert(1), vtc_log(2)) +-function(__assert(1), vtc_dump(2)) +-function(__assert(1), vtc_hexdump(2)) -esym(850, av) diff --git a/bin/varnishtest/vtc.c b/bin/varnishtest/vtc.c index e2cb6b0..fe503b2 100644 --- a/bin/varnishtest/vtc.c +++ b/bin/varnishtest/vtc.c @@ -239,7 +239,7 @@ macro_expand(struct vtclog *vl, const char *text) m = macro_get(p, q); if (m == NULL) { VSB_destroy(&vsb); - vtc_log(vl, 0, "Macro ${%.*s} not found", (int)(q - p), + vtc_fatal(vl, "Macro ${%.*s} not found", (int)(q - p), p); NEEDLESS(return (NULL)); } @@ -330,7 +330,7 @@ parse_string(const char *spec, const struct cmds *cmd, void *priv, q++; } else { if (*p == '\n') - vtc_log(vl, 0, + vtc_fatal(vl, "Unterminated quoted string in line: %*.*s", (int)(p - f), (int)(p - f), f); assert(*p != '\n'); @@ -380,7 +380,7 @@ parse_string(const char *spec, const struct cmds *cmd, void *priv, if (!strcmp(token_s[0], cp->name)) break; if (cp->name == NULL) { - vtc_log(vl, 0, "Unknown command: \"%s\"", token_s[0]); + vtc_fatal(vl, "Unknown command: \"%s\"", token_s[0]); NEEDLESS(return); } @@ -476,7 +476,7 @@ cmd_shell_engine(struct vtclog *vl, int ok, vtc_dump(vl, 4, "shell_cmd", VSB_data(vsb), -1); fp = popen(VSB_data(vsb), "r"); if (fp == NULL) - vtc_log(vl, 0, "popen fails: %s", strerror(errno)); + vtc_fatal(vl, "popen fails: %s", strerror(errno)); VSB_clear(vsb); do { c = getc(fp); @@ -488,9 +488,9 @@ cmd_shell_engine(struct vtclog *vl, int ok, if (WIFSIGNALED(r)) vtc_log(vl, 4, "shell_signal = %d", WTERMSIG(r)); if (ok < 0 && !WEXITSTATUS(r)) - vtc_log(vl, 0, "shell did not fail as expected"); + vtc_fatal(vl, "shell did not fail as expected"); else if (ok >= 0 && WEXITSTATUS(r) != ok) { - vtc_log(vl, 0, + vtc_fatal(vl, "shell_exit not as expected: got 0x%04x wanted 0x%04x", WEXITSTATUS(r), ok); } @@ -498,7 +498,7 @@ cmd_shell_engine(struct vtclog *vl, int ok, vtc_dump(vl, 4, "shell_out", VSB_data(vsb), VSB_len(vsb)); if (expect != NULL) { if (strstr(VSB_data(vsb), expect) == NULL) - vtc_log(vl, 0, + vtc_fatal(vl, "shell_expect not found: (\"%s\")", expect); else vtc_log(vl, 4, "shell_expect found"); @@ -680,7 +680,7 @@ cmd_feature(CMD_ARGS) } else if (!strcmp(*av, "cmd")) { av++; if (*av == NULL) { - vtc_log(vl, 0, "Missing the command-line"); + vtc_fatal(vl, "Missing the command-line"); return; } r = system(*av); @@ -693,7 +693,7 @@ cmd_feature(CMD_ARGS) continue; if (!vtc_stop) { - vtc_log(vl, 0, + vtc_fatal(vl, "FAIL test, unknown feature: %s", *av); } else { vtc_log(vl, 1, diff --git a/bin/varnishtest/vtc.h b/bin/varnishtest/vtc.h index e196bf6..8f999ad 100644 --- a/bin/varnishtest/vtc.h +++ b/bin/varnishtest/vtc.h @@ -97,6 +97,8 @@ struct vtclog *vtc_logopen(const char *id); void vtc_logclose(struct vtclog *vl); void vtc_log(struct vtclog *vl, int lvl, const char *fmt, ...) __v_printflike(3, 4); +void vtc_fatal(struct vtclog *vl, const char *, ...) + __attribute__((__noreturn__)) __v_printflike(2,3); void vtc_dump(struct vtclog *vl, int lvl, const char *pfx, const char *str, int len); void vtc_hexdump(struct vtclog *vl, int lvl, const char *pfx, diff --git a/bin/varnishtest/vtc_barrier.c b/bin/varnishtest/vtc_barrier.c index 4052770..04f1d71 100644 --- a/bin/varnishtest/vtc_barrier.c +++ b/bin/varnishtest/vtc_barrier.c @@ -78,9 +78,9 @@ barrier_new(char *name, struct vtclog *vl) AN(b); AN(name); if (*name != 'b') - vtc_log(vl, 0, "Barrier name must start with 'b' (%s)", name); + vtc_fatal(vl, "Barrier name must start with 'b' (%s)", name); if (pthread_self() != vtc_thread) - vtc_log(vl, 0, + vtc_fatal(vl, "Barrier %s can only be created on the top thread", name); REPLACE(b->name, name); @@ -102,14 +102,14 @@ barrier_expect(struct barrier *b, const char *av, struct vtclog *vl) unsigned expected; if (b->type != BARRIER_NONE) - vtc_log(vl, 0, + vtc_fatal(vl, "Barrier(%s) use error: already initialized", b->name); AZ(b->expected); AZ(b->waiters); expected = strtoul(av, NULL, 0); if (expected < 2) - vtc_log(vl, 0, + vtc_fatal(vl, "Barrier(%s) use error: wrong expectation (%u)", b->name, expected); @@ -148,7 +148,7 @@ barrier_sock_thread(void *priv) if (sock < 0) { AZ(pthread_cond_signal(&b->cond)); AZ(pthread_mutex_unlock(&b->mtx)); - vtc_log(vl, 0, "Barrier(%s) %s fails: %s (errno=%d)", + vtc_fatal(vl, "Barrier(%s) %s fails: %s (errno=%d)", b->name, err, strerror(errno), errno); } assert(sock > 0); @@ -178,14 +178,14 @@ barrier_sock_thread(void *priv) if (errno == EINTR) continue; AZ(close(sock)); - vtc_log(vl, 0, + vtc_fatal(vl, "Barrier(%s) select fails: %s (errno=%d)", b->name, strerror(errno), errno); } assert(i == 1); assert(b->waiters <= b->expected); if (b->waiters == b->expected) - vtc_log(vl, 0, + vtc_fatal(vl, "Barrier(%s) use error: " "more waiters than the %u expected", b->name, b->expected); @@ -193,7 +193,7 @@ barrier_sock_thread(void *priv) i = accept(sock, NULL, NULL); if (i < 0) { AZ(close(sock)); - vtc_log(vl, 0, + vtc_fatal(vl, "Barrier(%s) accept fails: %s (errno=%d)", b->name, strerror(errno), errno); } @@ -251,11 +251,11 @@ barrier_cyclic(struct barrier *b, struct vtclog *vl) CHECK_OBJ_NOTNULL(b, BARRIER_MAGIC); if (b->type == BARRIER_NONE) - vtc_log(vl, 0, + vtc_fatal(vl, "Barrier(%s) use error: not initialized", b->name); if (b->waiters != 0) - vtc_log(vl, 0, + vtc_fatal(vl, "Barrier(%s) use error: already in use", b->name); b->cyclic = 1; @@ -274,7 +274,7 @@ barrier_cond_sync(struct barrier *b, struct vtclog *vl) assert(b->waiters <= b->expected); if (b->waiters == b->expected) - vtc_log(vl, 0, + vtc_fatal(vl, "Barrier(%s) use error: more waiters than the %u expected", b->name, b->expected); @@ -311,7 +311,7 @@ barrier_sock_sync(struct barrier *b, struct vtclog *vl) sock = VTCP_open(VSB_data(vsb), NULL, 0., &err); if (sock < 0) - vtc_log(vl, 0, "Barrier(%s) connection failed: %s", + vtc_fatal(vl, "Barrier(%s) connection failed: %s", b->name, err); VSB_delete(vsb); @@ -325,10 +325,10 @@ barrier_sock_sync(struct barrier *b, struct vtclog *vl) AZ(close(sock)); if (sz < 0) - vtc_log(vl, 0, "Barrier(%s) read failed: %s (errno=%d)", + vtc_fatal(vl, "Barrier(%s) read failed: %s (errno=%d)", b->name, strerror(i), i); if (sz > 0) - vtc_log(vl, 0, "Barrier(%s) unexpected data (%zdB)", + vtc_fatal(vl, "Barrier(%s) unexpected data (%zdB)", b->name, sz); } @@ -340,7 +340,7 @@ barrier_sync(struct barrier *b, struct vtclog *vl) switch (b->type) { case BARRIER_NONE: - vtc_log(vl, 0, + vtc_fatal(vl, "Barrier(%s) use error: not initialized", b->name); break; case BARRIER_COND: @@ -465,7 +465,7 @@ cmd_barrier(CMD_ARGS) barrier_cyclic(b, vl); continue; } - vtc_log(vl, 0, "Unknown barrier argument: %s", *av); + vtc_fatal(vl, "Unknown barrier argument: %s", *av); } AZ(pthread_mutex_unlock(&b->mtx)); } diff --git a/bin/varnishtest/vtc_client.c b/bin/varnishtest/vtc_client.c index 9e10019..3b7e6c8 100644 --- a/bin/varnishtest/vtc_client.c +++ b/bin/varnishtest/vtc_client.c @@ -93,14 +93,14 @@ client_proxy(struct vtclog *vl, int fd, int version, const char *spec) error = VSS_resolver(p, NULL, proxy_cb, &sac, &err); if (err != NULL) - vtc_log(vl, 0, "Could not resolve client address: %s", err); + vtc_fatal(vl, "Could not resolve client address: %s", err); assert(error == 1); error = VSS_resolver(p2, NULL, proxy_cb, &sas, &err); if (err != NULL) - vtc_log(vl, 0, "Could not resolve server address: %s", err); + vtc_fatal(vl, "Could not resolve server address: %s", err); assert(error == 1); if (vtc_send_proxy(fd, version, sac, sas)) - vtc_log(vl, 0, "Write failed: %s", strerror(errno)); + vtc_fatal(vl, "Write failed: %s", strerror(errno)); free(p); free(sac); free(sas); @@ -140,7 +140,7 @@ client_thread(void *priv) vtc_log(vl, 3, "Connect to %s", VSB_data(vsb)); fd = VTCP_open(VSB_data(vsb), NULL, 10., &err); if (fd < 0) - vtc_log(c->vl, 0, "Failed to open %s: %s", + vtc_fatal(c->vl, "Failed to open %s: %s", VSB_data(vsb), err); assert(fd >= 0); /* VTCP_blocking does its own checks, trust it */ @@ -176,7 +176,7 @@ client_new(const char *name) c->vl = vtc_logopen(name); AN(c->vl); if (*c->name != 'c') - vtc_log(c->vl, 0, "Client name must start with 'c'"); + vtc_fatal(c->vl, "Client name must start with 'c'"); bprintf(c->connect, "%s", "${v1_sock}"); VTAILQ_INSERT_TAIL(&clients, c, list); @@ -227,7 +227,7 @@ client_wait(struct client *c) vtc_log(c->vl, 2, "Waiting for client"); AZ(pthread_join(c->tp, &res)); if (res != NULL) - vtc_log(c->vl, 0, "Client returned \"%s\"", (char *)res); + vtc_fatal(c->vl, "Client returned \"%s\"", (char *)res); c->tp = 0; c->running = 0; } @@ -323,7 +323,7 @@ cmd_client(CMD_ARGS) continue; } if (**av == '-') - vtc_log(c->vl, 0, "Unknown client argument: %s", *av); + vtc_fatal(c->vl, "Unknown client argument: %s", *av); REPLACE(c->spec, *av); } } diff --git a/bin/varnishtest/vtc_http.c b/bin/varnishtest/vtc_http.c index d04b666..46f6d68 100644 --- a/bin/varnishtest/vtc_http.c +++ b/bin/varnishtest/vtc_http.c @@ -140,22 +140,22 @@ static const struct cmds http_cmds[]; #define ONLY_CLIENT(hp, av) \ do { \ if (hp->h2) \ - vtc_log(hp->vl, 0, \ + vtc_fatal(hp->vl, \ "\"%s\" only possible before H/2 upgrade", \ av[0]); \ if (hp->sfd != NULL) \ - vtc_log(hp->vl, 0, \ + vtc_fatal(hp->vl, \ "\"%s\" only possible in client", av[0]); \ } while (0) #define ONLY_SERVER(hp, av) \ do { \ if (hp->h2) \ - vtc_log(hp->vl, 0, \ + vtc_fatal(hp->vl, \ "\"%s\" only possible before H/2 upgrade", \ av[0]); \ if (hp->sfd == NULL) \ - vtc_log(hp->vl, 0, \ + vtc_fatal(hp->vl, \ "\"%s\" only possible in server", av[0]); \ } while (0) @@ -373,7 +373,7 @@ cmd_http_expect(CMD_ARGS) if (!strcmp(cmp, "~") || !strcmp(cmp, "!~")) { vre = VRE_compile(crhs, 0, &error, &erroroffset); if (vre == NULL) - vtc_log(hp->vl, 0, "REGEXP error: %s (@%d) (%s)", + vtc_fatal(hp->vl, "REGEXP error: %s (@%d) (%s)", error, erroroffset, crhs); i = VRE_exec(vre, clhs, strlen(clhs), 0, 0, NULL, 0, 0); retval = (i >= 0 && *cmp == '~') || (i < 0 && *cmp == '!'); @@ -396,7 +396,7 @@ cmd_http_expect(CMD_ARGS) } if (retval == -1) - vtc_log(hp->vl, 0, + vtc_fatal(hp->vl, "EXPECT %s (%s) %s %s (%s) test not implemented", av[0], clhs, av[1], av[2], crhs); else @@ -419,7 +419,7 @@ cmd_http_expect_pattern(CMD_ARGS) AZ(av[0]); for (p = hp->body; *p != '\0'; p++) { if (*p != t) - vtc_log(hp->vl, 0, + vtc_fatal(hp->vl, "EXPECT PATTERN FAIL @%zd should 0x%02x is 0x%02x", p - hp->body, t, *p); t += 1; @@ -694,12 +694,12 @@ cmd_http_rxresp(CMD_ARGS) if (!strcmp(*av, "-no_obj")) has_obj = 0; else - vtc_log(hp->vl, 0, + vtc_fatal(hp->vl, "Unknown http rxresp spec: %s\n", *av); http_rxhdr(hp); http_splitheader(hp, 0); if (http_count_header(hp->resp, "Content-Length") > 1) - vtc_log(hp->vl, 0, + vtc_fatal(hp->vl, "Multiple Content-Length headers.\n"); if (!has_obj) return; @@ -728,11 +728,11 @@ cmd_http_rxresphdrs(CMD_ARGS) av++; for(; *av != NULL; av++) - vtc_log(hp->vl, 0, "Unknown http rxresp spec: %s\n", *av); + vtc_fatal(hp->vl, "Unknown http rxresp spec: %s\n", *av); http_rxhdr(hp); http_splitheader(hp, 0); if (http_count_header(hp->resp, "Content-Length") > 1) - vtc_log(hp->vl, 0, + vtc_fatal(hp->vl, "Multiple Content-Length headers.\n"); } @@ -1026,7 +1026,7 @@ cmd_http_txresp(CMD_ARGS) av = http_tx_parse_args(av, vl, hp, body); if (*av != NULL) - vtc_log(hp->vl, 0, "Unknown http txresp spec: %s\n", *av); + vtc_fatal(hp->vl, "Unknown http txresp spec: %s\n", *av); http_write(hp, 4, "txresp"); } @@ -1043,16 +1043,16 @@ cmd_http_upgrade(CMD_ARGS) h = http_find_header(hp->req, "Upgrade"); if (!h || strcmp(h, "h2c")) - vtc_log(vl, 0, "Req misses \"Upgrade: h2c\" header"); + vtc_fatal(vl, "Req misses \"Upgrade: h2c\" header"); h = http_find_header(hp->req, "Connection"); if (!h || strcmp(h, "Upgrade, HTTP2-Settings")) - vtc_log(vl, 0, "Req misses \"Connection: " + vtc_fatal(vl, "Req misses \"Connection: " "Upgrade, HTTP2-Settings\" header"); h = http_find_header(hp->req, "HTTP2-Settings"); if (!h) - vtc_log(vl, 0, "Req misses \"HTTP2-Settings\" header"); + vtc_fatal(vl, "Req misses \"HTTP2-Settings\" header"); parse_string("txresp -status 101 " @@ -1092,11 +1092,11 @@ cmd_http_rxreq(CMD_ARGS) av++; for(; *av != NULL; av++) - vtc_log(vl, 0, "Unknown http rxreq spec: %s\n", *av); + vtc_fatal(vl, "Unknown http rxreq spec: %s\n", *av); http_rxhdr(hp); http_splitheader(hp, 1); if (http_count_header(hp->req, "Content-Length") > 1) - vtc_log(vl, 0, + vtc_fatal(vl, "Multiple Content-Length headers.\n"); http_swallow_body(hp, hp->req, 0); vtc_log(vl, 4, "bodylen = %s", hp->bodylen); @@ -1120,11 +1120,11 @@ cmd_http_rxreqhdrs(CMD_ARGS) av++; for(; *av != NULL; av++) - vtc_log(hp->vl, 0, "Unknown http rxreq spec: %s\n", *av); + vtc_fatal(hp->vl, "Unknown http rxreq spec: %s\n", *av); http_rxhdr(hp); http_splitheader(hp, 1); if (http_count_header(hp->req, "Content-Length") > 1) - vtc_log(hp->vl, 0, + vtc_fatal(hp->vl, "Multiple Content-Length headers.\n"); } @@ -1147,7 +1147,7 @@ cmd_http_rxreqbody(CMD_ARGS) av++; for(; *av != NULL; av++) - vtc_log(hp->vl, 0, "Unknown http rxreq spec: %s\n", *av); + vtc_fatal(hp->vl, "Unknown http rxreq spec: %s\n", *av); http_swallow_body(hp, hp->req, 0); vtc_log(hp->vl, 4, "bodylen = %s", hp->bodylen); } @@ -1171,7 +1171,7 @@ cmd_http_rxrespbody(CMD_ARGS) av++; for(; *av != NULL; av++) - vtc_log(hp->vl, 0, "Unknown http rxrespbody spec: %s\n", *av); + vtc_fatal(hp->vl, "Unknown http rxrespbody spec: %s\n", *av); http_swallow_body(hp, hp->resp, 0); vtc_log(hp->vl, 4, "bodylen = %s", hp->bodylen); } @@ -1249,7 +1249,7 @@ cmd_http_txreq(CMD_ARGS) av = http_tx_parse_args(av, vl, hp, NULL); if (*av != NULL) - vtc_log(hp->vl, 0, "Unknown http txreq spec: %s\n", *av); + vtc_fatal(hp->vl, "Unknown http txreq spec: %s\n", *av); http_write(hp, 4, "txreq"); if (up) { @@ -1411,7 +1411,7 @@ cmd_http_sendhex(CMD_ARGS) q += 2; buf[2] = '\0'; if (!vct_ishex(buf[0]) || !vct_ishex(buf[1])) - vtc_log(hp->vl, 0, "Illegal Hex char \"%c%c\"", + vtc_fatal(hp->vl, "Illegal Hex char \"%c%c\"", buf[0], buf[1]); p[i] = (uint8_t)strtoul(buf, NULL, 16); } @@ -1506,7 +1506,7 @@ cmd_http_timeout(CMD_ARGS) AZ(av[2]); d = VNUM(av[1]); if (isnan(d)) - vtc_log(vl, 0, "timeout is not a number (%s)", av[1]); + vtc_fatal(vl, "timeout is not a number (%s)", av[1]); hp->timeout = (int)(d * 1000.0); } @@ -1649,7 +1649,7 @@ cmd_http_fatal(CMD_ARGS) else if (!strcmp(av[0], "non_fatal")) hp->fatal = -1; else { - vtc_log(vl, 0, "XXX: fatal %s", cmd->name); + vtc_fatal(vl, "XXX: fatal %s", cmd->name); } } @@ -1715,9 +1715,9 @@ cmd_http_rxpri(CMD_ARGS) hp->prxbuf = 0; if (!http_rxchar(hp, sizeof(PREFACE), 0)) - vtc_log(vl, 0, "Couldn't retrieve connection preface"); + vtc_fatal(vl, "Couldn't retrieve connection preface"); if (memcmp(hp->rxbuf, PREFACE, sizeof(PREFACE))) - vtc_log(vl, 0, "Received invalid preface\n"); + vtc_fatal(vl, "Received invalid preface\n"); start_h2(hp); AN(hp->h2); } @@ -1738,7 +1738,7 @@ cmd_http_settings(CMD_ARGS) (void)cmd; if (!hp->h2) - vtc_log(hp->vl, 0, "Only possible in H/2 mode"); + vtc_fatal(hp->vl, "Only possible in H/2 mode"); CAST_OBJ_NOTNULL(hp, priv, HTTP_MAGIC); @@ -1746,12 +1746,12 @@ cmd_http_settings(CMD_ARGS) if (!strcmp(*av, "-dectbl")) { n = strtoul(av[1], &p, 0); if (*p != '\0') - vtc_log(hp->vl, 0, "-dectbl takes an integer as" + vtc_fatal(hp->vl, "-dectbl takes an integer as" " argument (found %s)", av[1]); HPK_ResizeTbl(hp->decctx, n); av++; } else - vtc_log(vl, 0, "Unknown settings spec: %s\n", *av); + vtc_fatal(vl, "Unknown settings spec: %s\n", *av); } } @@ -1798,7 +1798,7 @@ cmd_http_write_body(CMD_ARGS) AZ(av[2]); AZ(strcmp(av[0], "write_body")); if (VFIL_writefile(NULL, av[1], hp->body, hp->bodyl) != 0) - vtc_log(hp->vl, 0, "failed to write body: %s (%d)", + vtc_fatal(hp->vl, "failed to write body: %s (%d)", strerror(errno), errno); } diff --git a/bin/varnishtest/vtc_http2.c b/bin/varnishtest/vtc_http2.c index 6b58b73..449208e 100644 --- a/bin/varnishtest/vtc_http2.c +++ b/bin/varnishtest/vtc_http2.c @@ -131,14 +131,14 @@ clean_headers(struct hpk_hdr *h) #define ONLY_CLIENT(hp, av) \ do { \ if (hp->sfd != NULL) \ - vtc_log(hp->vl, 0, \ + vtc_fatal(hp->vl, \ "\"%s\" only possible in client", av[0]); \ } while (0) #define ONLY_SERVER(hp, av) \ do { \ if (hp->sfd == NULL) \ - vtc_log(hp->vl, 0, \ + vtc_fatal(hp->vl, \ "\"%s\" only possible in server", av[0]); \ } while (0) @@ -537,7 +537,7 @@ parse_prio(struct stream *s, struct frame *f) CAST_OBJ_NOTNULL(hp, s->hp, HTTP_MAGIC);; if (f->size != 5) - vtc_log(hp->vl, 0, "Size should be 5, but isn't (%d)", f->size); + vtc_fatal(hp->vl, "Size should be 5, but isn't (%d)", f->size); buf = f->data; AN(buf); @@ -570,7 +570,7 @@ parse_rst(const struct stream *s, struct frame *f) CAST_OBJ_NOTNULL(hp, s->hp, HTTP_MAGIC);; if (f->size != 4) - vtc_log(hp->vl, 0, "Size should be 4, but isn't (%d)", f->size); + vtc_fatal(hp->vl, "Size should be 4, but isn't (%d)", f->size); err = vbe32dec(f->data); f->md.rst_err = err; @@ -596,7 +596,7 @@ parse_settings(const struct stream *s, struct frame *f) CAST_OBJ_NOTNULL(hp, s->hp, HTTP_MAGIC);; if (f->size % 6) - vtc_log(hp->vl, 0, "Size should be a multiple of 6, but isn't (%d)", f->size); + vtc_fatal(hp->vl, "Size should be a multiple of 6, but isn't (%d)", f->size); for (i = 0; i <= SETTINGS_MAX; i++) f->md.settings[i] = NAN; @@ -630,7 +630,7 @@ parse_ping(const struct stream *s, struct frame *f) CHECK_OBJ_NOTNULL(s, STREAM_MAGIC); CAST_OBJ_NOTNULL(hp, s->hp, HTTP_MAGIC);; if (f->size != 8) - vtc_log(hp->vl, 0, "Size should be 8, but isn't (%d)", f->size); + vtc_fatal(hp->vl, "Size should be 8, but isn't (%d)", f->size); f->md.ping.ack = f->flags & ACK; memcpy(f->md.ping.data, f->data, 8); f->md.ping.data[8] = '\0'; @@ -650,9 +650,9 @@ parse_goaway(const struct stream *s, struct frame *f) CAST_OBJ_NOTNULL(hp, s->hp, HTTP_MAGIC);; if (f->size < 8) - vtc_log(hp->vl, 0, "Size should be at least 8, but isn't (%d)", f->size); + vtc_fatal(hp->vl, "Size should be at least 8, but isn't (%d)", f->size); if (f->data[0] & (1<<7)) - vtc_log(hp->vl, 0, "First bit of data is reserved and should be 0"); + vtc_fatal(hp->vl, "First bit of data is reserved and should be 0"); stid = vbe32dec(f->data); err = vbe32dec(f->data + 4); @@ -688,7 +688,7 @@ parse_winup(const struct stream *s, struct frame *f) CAST_OBJ_NOTNULL(hp, s->hp, HTTP_MAGIC);; if (f->size != 4) - vtc_log(hp->vl, 0, "Size should be 4, but isn't (%d)", f->size); + vtc_fatal(hp->vl, "Size should be 4, but isn't (%d)", f->size); if (f->data[0] & (1<<7)) vtc_log(hp->vl, s->hp->fatal, "First bit of data is reserved and should be 0"); @@ -764,7 +764,7 @@ receive_frame(void *priv) if (expect_cont && (f->type != TYPE_CONTINUATION || expect_cont != s->id)) - vtc_log(hp->vl, 0, "Expected CONTINUATION frame for" + vtc_fatal(hp->vl, "Expected CONTINUATION frame for" " stream %u", expect_cont); /* parse the frame according to it type, and fill the metada */ @@ -834,7 +834,7 @@ receive_frame(void *priv) do { \ n = strtoul(s, &p, 0); \ if (*p != '\0') { \ - vtc_log(v, 0, "%s takes an integer as argument" \ + vtc_fatal(v, "%s takes an integer as argument" \ "(found %s)", c, s); \ WRONG("Couldn't convert to integer");\ } \ @@ -846,13 +846,13 @@ do { \ AN(*sp); \ STRTOU32(n, *sp, p, v, c); \ if (l && n >= (1U << l)) \ - vtc_log(v, 0, \ + vtc_fatal(v, \ c " must be a %d-bits integer (found %s)", l, *sp); \ } while (0) #define CHECK_LAST_FRAME(TYPE) \ if (!f || f->type != TYPE_ ## TYPE) { \ - vtc_log(s->hp->vl, 0, "Last frame was not of type " #TYPE); \ + vtc_fatal(s->hp->vl, "Last frame was not of type " #TYPE); \ } #define RETURN_SETTINGS(idx) \ @@ -1060,7 +1060,7 @@ cmd_var_resolve(const struct stream *s, const char *spec, char *buf) else if (!strncmp(spec, "frame.", 6)) { spec += 6; if (!f) - vtc_log(s->hp->vl, 0, "No frame received yet."); + vtc_fatal(s->hp->vl, "No frame received yet."); if (!strcmp(spec, "data")) { return (f->data); } else if (!strcmp(spec, "type")) { RETURN_BUFFED(f->type); } else if (!strcmp(spec, "size")) { RETURN_BUFFED(f->size); } @@ -1069,7 +1069,7 @@ cmd_var_resolve(const struct stream *s, const char *spec, char *buf) if (f->type != TYPE_DATA && f->type != TYPE_HEADERS && f->type != TYPE_PUSH_PROMISE) - vtc_log(s->hp->vl, 0, + vtc_fatal(s->hp->vl, "Last frame was not of type " "DATA, HEADERS or PUSH"); RETURN_BUFFED(f->md.padded); @@ -1252,7 +1252,7 @@ cmd_sendhex(CMD_ARGS) q += 2; tmp[2] = '\0'; if (!vct_ishex(tmp[0]) || !vct_ishex(tmp[1])) - vtc_log(vl, 0, "Illegal Hex char \"%c%c\"", + vtc_fatal(vl, "Illegal Hex char \"%c%c\"", tmp[0], tmp[1]); buf[i] = (uint8_t)strtoul(tmp, NULL, 16); } @@ -1285,7 +1285,7 @@ cmd_sendhex(CMD_ARGS) if (AV_IS("plain")) { hdr.field.huff = 0; } \ else if (AV_IS("huf")) { hdr.field.huff = 1; } \ else \ - vtc_log(vl, 0, str " arg can be huf or plain (got: %s)", *av); \ + vtc_fatal(vl, str " arg can be huf or plain (got: %s)", *av); \ av++; \ AN(*av); \ hdr.field.ptr = *av; \ @@ -1484,7 +1484,7 @@ cmd_tx11obj(CMD_ARGS) else if (AV_IS("not")) { hdr.t = hpk_not; } else if (AV_IS("never")) { hdr.t = hpk_never; } else - vtc_log(vl, 0, "first -litidxHdr arg can be " + vtc_fatal(vl, "first -litidxHdr arg can be " "inc, not, never (got: %s)", *av); @@ -1502,7 +1502,7 @@ cmd_tx11obj(CMD_ARGS) else if (AV_IS("not")) { hdr.t = hpk_not; } else if (AV_IS("never")) { hdr.t = hpk_never; } else - vtc_log(vl, 0, "first -litHdr arg can be inc, " + vtc_fatal(vl, "first -litHdr arg can be inc, " "not, never (got: %s)", *av); STR_ENC(av, key, "second -litHdr"); @@ -1561,7 +1561,7 @@ cmd_tx11obj(CMD_ARGS) #undef CMD_IS #undef AV_IS if (*av != NULL) - vtc_log(vl, 0, "Unknown %s spec: %s\n", cmd_str, *av); + vtc_fatal(vl, "Unknown %s spec: %s\n", cmd_str, *av); memset(&hdr, 0, sizeof(hdr)); hdr.t = hpk_not; @@ -1589,7 +1589,7 @@ cmd_tx11obj(CMD_ARGS) } if (pad) { if (strlen(pad) >= 128) - vtc_log(vl, 0, "Padding is limited to 128 bytes"); + vtc_fatal(vl, "Padding is limited to 128 bytes"); f.flags |= PADDED; assert(f.size + strlen(pad) < BUF_SIZE); memmove(buf + 1, buf, f.size); @@ -1675,7 +1675,7 @@ cmd_txdata(CMD_ARGS) break; } if (*av != NULL) - vtc_log(vl, 0, "Unknown txdata spec: %s\n", *av); + vtc_fatal(vl, "Unknown txdata spec: %s\n", *av); if (!body) body = strdup(""); @@ -1683,7 +1683,7 @@ cmd_txdata(CMD_ARGS) if (pad) { f.flags |= PADDED; if (strlen(pad) >= 128) - vtc_log(vl, 0, "Padding is limited to 128 bytes"); + vtc_fatal(vl, "Padding is limited to 128 bytes"); data = malloc( 1 + strlen(body) + strlen(pad)); AN(data); *((uint8_t *)data) = strlen(pad); @@ -1741,7 +1741,7 @@ cmd_txrst(CMD_ARGS) break; } if (*av != NULL) - vtc_log(vl, 0, "Unknown txrst spec: %s\n", *av); + vtc_fatal(vl, "Unknown txrst spec: %s\n", *av); err = htonl(err); f.data = (void *)&err; @@ -1791,7 +1791,7 @@ cmd_txprio(CMD_ARGS) break; } if (*av != NULL) - vtc_log(vl, 0, "Unknown txprio spec: %s\n", *av); + vtc_fatal(vl, "Unknown txprio spec: %s\n", *av); s->weight = weight & 0xff; s->dependency = stid; @@ -1870,7 +1870,7 @@ cmd_txsettings(CMD_ARGS) else if (!strcmp(*av, "true")) vbe32enc(cursor, 1); else - vtc_log(vl, 0, "Push parameter is either " + vtc_fatal(vl, "Push parameter is either " "\"true\" or \"false\", not %s", *av); cursor += sizeof(uint32_t); @@ -1901,7 +1901,7 @@ cmd_txsettings(CMD_ARGS) break; } if (*av != NULL) - vtc_log(vl, 0, "Unknown txsettings spec: %s\n", *av); + vtc_fatal(vl, "Unknown txsettings spec: %s\n", *av); write_frame(hp, &f, 0); AZ(pthread_mutex_unlock(&hp->mtx)); @@ -1933,9 +1933,9 @@ cmd_txping(CMD_ARGS) if (!strcmp(*av, "-data")) { av++; if (f.data) - vtc_log(vl, 0, "this frame already has data"); + vtc_fatal(vl, "this frame already has data"); if (strlen(*av) != 8) - vtc_log(vl, 0, "data must be a 8-char string, found (%s)", *av); + vtc_fatal(vl, "data must be a 8-char string, found (%s)", *av); f.data = *av; } else if (!strcmp(*av, "-ack")) { f.flags |= 1; @@ -1943,7 +1943,7 @@ cmd_txping(CMD_ARGS) break; } if (*av != NULL) - vtc_log(vl, 0, "Unknown txping spec: %s\n", *av); + vtc_fatal(vl, "Unknown txping spec: %s\n", *av); if (!f.data) f.data = buf; write_frame(s->hp, &f, 1); @@ -2000,7 +2000,7 @@ cmd_txgoaway(CMD_ARGS) } else if (!strcmp(*av, "-debug")) { ++av; if (f.data) - vtc_log(vl, 0, "this frame already has debug data"); + vtc_fatal(vl, "this frame already has debug data"); f.size = 8 + strlen(*av); f.data = malloc(f.size); memcpy(f.data + 8, *av, f.size - 8); @@ -2008,7 +2008,7 @@ cmd_txgoaway(CMD_ARGS) break; } if (*av != NULL) - vtc_log(vl, 0, "Unknown txgoaway spec: %s\n", *av); + vtc_fatal(vl, "Unknown txgoaway spec: %s\n", *av); if (!f.data) f.data = malloc(2); @@ -2054,7 +2054,7 @@ cmd_txwinup(CMD_ARGS) break; } if (*av != NULL) - vtc_log(vl, 0, "Unknown txwinup spec: %s\n", *av); + vtc_fatal(vl, "Unknown txwinup spec: %s\n", *av); AZ(pthread_mutex_lock(&hp->mtx)); if (s->id == 0) @@ -2096,7 +2096,7 @@ rxstuff(struct stream *s) #define CHKFRAME(rt, wt, rcv, func) \ do { \ if (rt != wt) \ - vtc_log(vl, 0, "Frame #%d for %s was of type %s (%d) " \ + vtc_fatal(vl, "Frame #%d for %s was of type %s (%d) " \ "instead of %s (%d)", \ rcv, func, \ rt < TYPE_MAX ? h2_types[rt] : "?", rt, \ @@ -2139,7 +2139,7 @@ cmd_rxhdrs(CMD_ARGS) break; } if (*av != NULL) - vtc_log(vl, 0, "Unknown rxhdrs spec: %s\n", *av); + vtc_fatal(vl, "Unknown rxhdrs spec: %s\n", *av); while (rcv++ < times || (loop && !(f->flags & END_HEADERS))) { f = rxstuff(s); @@ -2174,7 +2174,7 @@ cmd_rxcont(CMD_ARGS) break; } if (*av != NULL) - vtc_log(vl, 0, "Unknown rxcont spec: %s\n", *av); + vtc_fatal(vl, "Unknown rxcont spec: %s\n", *av); while (rcv++ < times || (loop && !(f->flags & END_HEADERS))) { f = rxstuff(s); @@ -2222,7 +2222,7 @@ cmd_rxdata(CMD_ARGS) break; } if (*av != NULL) - vtc_log(vl, 0, "Unknown rxdata spec: %s\n", *av); + vtc_fatal(vl, "Unknown rxdata spec: %s\n", *av); while (rcv++ < times || (loop && !(f->flags & END_STREAM))) { f = rxstuff(s); @@ -2321,7 +2321,7 @@ cmd_rxpush(CMD_ARGS) break; } if (*av != NULL) - vtc_log(vl, 0, "Unknown rxpush spec: %s\n", *av); + vtc_fatal(vl, "Unknown rxpush spec: %s\n", *av); while (rcv++ < times || (loop && !(f->flags & END_HEADERS))) { f = rxstuff(s); @@ -2343,7 +2343,7 @@ cmd_rxpush(CMD_ARGS) if ((s->frame = rxstuff(s))) \ return; \ if (s->frame->type != TYPE_ ## upctype) \ - vtc_log(vl, 0, "Received frame of type %d " \ + vtc_fatal(vl, "Received frame of type %d " \ "is invalid for %s", \ s->frame->type, "rx ## lctype"); \ } @@ -2436,7 +2436,7 @@ cmd_expect(CMD_ARGS) if (!strcmp(cmp, "~") || !strcmp(cmp, "!~")) { vre = VRE_compile(crhs, 0, &error, &erroroffset); if (vre == NULL) - vtc_log(vl, 0, "REGEXP error: %s (@%d) (%s)", + vtc_fatal(vl, "REGEXP error: %s (@%d) (%s)", error, erroroffset, crhs); i = VRE_exec(vre, clhs, strlen(clhs), 0, 0, NULL, 0, 0); retval = (i >= 0 && *cmp == '~') || (i < 0 && *cmp == '!'); @@ -2459,7 +2459,7 @@ cmd_expect(CMD_ARGS) } if (retval == -1) - vtc_log(vl, 0, + vtc_fatal(vl, "EXPECT %s (%s) %s %s (%s) test not implemented", av[0], clhs, av[1], av[2], crhs); else @@ -2486,7 +2486,7 @@ cmd_write_body(CMD_ARGS) AZ(av[2]); AZ(strcmp(av[0], "write_body")); if (VFIL_writefile(NULL, av[1], s->body, s->bodylen) != 0) - vtc_log(s->hp->vl, 0, "failed to write body: %s (%d)", + vtc_fatal(s->hp->vl, "failed to write body: %s (%d)", strerror(errno), errno); } @@ -2574,7 +2574,7 @@ stream_new(const char *name, struct http *h) STRTOU32(s->id, name, p, h->vl, "stream"); if (s->id & (1U << 31)) - vtc_log(h->vl, 0, "Stream id must be a 31-bits integer " + vtc_fatal(h->vl, "Stream id must be a 31-bits integer " "(found %s)", name); CHECK_OBJ_NOTNULL(h, HTTP_MAGIC); @@ -2626,7 +2626,7 @@ stream_wait(struct stream *s) vtc_log(s->hp->vl, 2, "Waiting for stream %u", s->id); AZ(pthread_join(s->tp, &res)); if (res != NULL) - vtc_log(s->hp->vl, 0, "Stream %u returned \"%s\"", s->id, + vtc_fatal(s->hp->vl, "Stream %u returned \"%s\"", s->id, (char *)res); VTAILQ_FOREACH_SAFE(f, &s->fq, list, f2) @@ -2740,7 +2740,7 @@ cmd_stream(CMD_ARGS) continue; } if (**av == '-') - vtc_log(vl, 0, "Unknown client argument: %s", *av); + vtc_fatal(vl, "Unknown client argument: %s", *av); REPLACE(s->spec, *av); } } @@ -2766,7 +2766,7 @@ b64_settings(const struct http *hp, const char *s) else if (*s == '_') { v |= (uint64_t)63 << shift; } else - vtc_log(hp->vl, 0, "Bad \"HTTP2-Settings\" " + vtc_fatal(hp->vl, "Bad \"HTTP2-Settings\" " "header"); s++; } diff --git a/bin/varnishtest/vtc_log.c b/bin/varnishtest/vtc_log.c index b111d28..b415302 100644 --- a/bin/varnishtest/vtc_log.c +++ b/bin/varnishtest/vtc_log.c @@ -48,6 +48,7 @@ struct vtclog { struct vsb *vsb; pthread_mutex_t mtx; int act; + double tx; }; static pthread_key_t log_key; @@ -55,6 +56,24 @@ static double t0; /**********************************************************************/ +#define GET_VL(vl) \ + do { \ + CHECK_OBJ_NOTNULL(vl, VTCLOG_MAGIC); \ + vl->tx = VTIM_mono() - t0; \ + AZ(pthread_mutex_lock(&vl->mtx)); \ + vl->act = 1; \ + VSB_clear(vl->vsb); \ + } while(0) + +#define REL_VL(vl) \ + do { \ + AZ(VSB_finish(vl->vsb)); \ + vtc_log_emit(vl); \ + VSB_clear(vl->vsb); \ + vl->act = 0; \ + AZ(pthread_mutex_unlock(&vl->mtx)); \ + } while(0) + struct vtclog * vtc_logopen(const char *id) @@ -93,13 +112,36 @@ static const char * const lead[] = { #define NLEAD (sizeof(lead)/sizeof(lead[0])) static void -vtc_log_emit(const struct vtclog *vl, int lvl) +vtc_leadinv(const struct vtclog *vl, int lvl, const char *fmt, va_list ap) +{ + + assert(lvl < (int)NLEAD); + assert(lvl >= 0); + VSB_clear(vl->vsb); + VSB_printf(vl->vsb, "%s %-4s %4.1f ", + lead[lvl < 0 ? 1: lvl], vl->id, vl->tx); + if (fmt != NULL) + (void)VSB_vprintf(vl->vsb, fmt, ap); +} + +static void +vtc_leadin(const struct vtclog *vl, int lvl, const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + vtc_leadinv(vl, lvl, fmt, ap); + va_end(ap); +} + +static void +vtc_log_emit(const struct vtclog *vl) { int l; - if (lvl < 0) - lvl = 0; l = VSB_len(vl->vsb); + if (l == 0) + return; AZ(pthread_mutex_lock(&vtclog_mtx)); assert(vtclog_left > l); memcpy(vtclog_buf,VSB_data(vl->vsb), l); @@ -109,32 +151,37 @@ vtc_log_emit(const struct vtclog *vl, int lvl) AZ(pthread_mutex_unlock(&vtclog_mtx)); } -//lint -e{818} void -vtc_log(struct vtclog *vl, int lvl, const char *fmt, ...) +vtc_fatal(struct vtclog *vl, const char *fmt, ...) { - double tx; - CHECK_OBJ_NOTNULL(vl, VTCLOG_MAGIC); - tx = VTIM_mono() - t0; - AZ(pthread_mutex_lock(&vl->mtx)); - vl->act = 1; - assert(lvl < (int)NLEAD); - VSB_clear(vl->vsb); - VSB_printf(vl->vsb, "%s %-4s %4.1f ", - lead[lvl < 0 ? 1: lvl], vl->id, tx); + GET_VL(vl); va_list ap; va_start(ap, fmt); - (void)VSB_vprintf(vl->vsb, fmt, ap); - va_end(ap); + vtc_leadinv(vl, 0, fmt, ap); VSB_putc(vl->vsb, '\n'); - AZ(VSB_finish(vl->vsb)); + va_end(ap); + REL_VL(vl); - vtc_log_emit(vl, lvl); + vtc_error = 2; + if (pthread_self() != vtc_thread) + pthread_exit(NULL); + while(1) continue; +} +void +vtc_log(struct vtclog *vl, int lvl, const char *fmt, ...) +{ + + GET_VL(vl); + va_list ap; + va_start(ap, fmt); + if (lvl >= 0) { + vtc_leadinv(vl, lvl, fmt, ap); + VSB_putc(vl->vsb, '\n'); + } + va_end(ap); + REL_VL(vl); - VSB_clear(vl->vsb); - vl->act = 0; - AZ(pthread_mutex_unlock(&vl->mtx)); if (lvl > 0) return; if (lvl == 0) @@ -147,26 +194,16 @@ vtc_log(struct vtclog *vl, int lvl, const char *fmt, ...) * Dump a string */ -//lint -e{818} void vtc_dump(struct vtclog *vl, int lvl, const char *pfx, const char *str, int len) { int nl = 1, olen; unsigned l; - double tx; - CHECK_OBJ_NOTNULL(vl, VTCLOG_MAGIC); - tx = VTIM_mono() - t0; - assert(lvl >= 0); - assert(lvl < NLEAD); - AZ(pthread_mutex_lock(&vl->mtx)); - vl->act = 1; - VSB_clear(vl->vsb); - if (pfx == NULL) - pfx = ""; + AN(pfx); + GET_VL(vl); if (str == NULL) - VSB_printf(vl->vsb, "%s %-4s %4.1f %s(null)\n", - lead[lvl], vl->id, tx, pfx); + vtc_leadin(vl, lvl, "%s(null)\n", pfx); else { olen = len; if (len < 0) @@ -177,8 +214,7 @@ vtc_dump(struct vtclog *vl, int lvl, const char *pfx, const char *str, int len) break; } if (nl) { - VSB_printf(vl->vsb, "%s %-4s %4.1f %s| ", - lead[lvl], vl->id, tx, pfx); + vtc_leadin(vl, lvl, "%s| ", pfx); nl = 0; } if (*str == '\r') @@ -196,13 +232,7 @@ vtc_dump(struct vtclog *vl, int lvl, const char *pfx, const char *str, int len) } if (!nl) VSB_printf(vl->vsb, "\n"); - AZ(VSB_finish(vl->vsb)); - - vtc_log_emit(vl, lvl); - - VSB_clear(vl->vsb); - vl->act = 0; - AZ(pthread_mutex_unlock(&vl->mtx)); + REL_VL(vl); if (lvl == 0) { vtc_error = 2; if (pthread_self() != vtc_thread) @@ -214,28 +244,17 @@ vtc_dump(struct vtclog *vl, int lvl, const char *pfx, const char *str, int len) * Hexdump */ -//lint -e{818} void vtc_hexdump(struct vtclog *vl, int lvl, const char *pfx, const unsigned char *str, int len) { int nl = 1; unsigned l; - double tx; - CHECK_OBJ_NOTNULL(vl, VTCLOG_MAGIC); - tx = VTIM_mono() - t0; - assert(len >= 0); - assert(lvl >= 0); - assert(lvl < NLEAD); - AZ(pthread_mutex_lock(&vl->mtx)); - vl->act = 1; - VSB_clear(vl->vsb); - if (pfx == NULL) - pfx = ""; + AN(pfx); + GET_VL(vl); if (str == NULL) - VSB_printf(vl->vsb, "%s %-4s %4.1f %s| (null)", - lead[lvl], vl->id, tx, pfx); + vtc_leadin(vl, lvl, "%s(null)\n", pfx); else { for (l = 0; l < len; l++, str++) { if (l > 512) { @@ -243,8 +262,7 @@ vtc_hexdump(struct vtclog *vl, int lvl, const char *pfx, break; } if (nl) { - VSB_printf(vl->vsb, "%s %-4s %4.1f %s| ", - lead[lvl], vl->id, tx, pfx); + vtc_leadin(vl, lvl, "%s| ", pfx); nl = 0; } VSB_printf(vl->vsb, " %02x", *str); @@ -256,13 +274,7 @@ vtc_hexdump(struct vtclog *vl, int lvl, const char *pfx, } if (!nl) VSB_printf(vl->vsb, "\n"); - AZ(VSB_finish(vl->vsb)); - - vtc_log_emit(vl, lvl); - - VSB_clear(vl->vsb); - vl->act = 0; - AZ(pthread_mutex_unlock(&vl->mtx)); + REL_VL(vl); if (lvl == 0) { vtc_error = 2; if (pthread_self() != vtc_thread) @@ -286,7 +298,7 @@ vtc_log_VAS_Fail(const char *func, const char *file, int line, " Condition(%s) not true.\n", func, file, line, cond); } else { - vtc_log(vl, 0, "Assert error in %s(), %s line %d:" + vtc_fatal(vl, "Assert error in %s(), %s line %d:" " Condition(%s) not true.\n", func, file, line, cond); } abort(); diff --git a/bin/varnishtest/vtc_logexp.c b/bin/varnishtest/vtc_logexp.c index eb2843a..af7e6a1 100644 --- a/bin/varnishtest/vtc_logexp.c +++ b/bin/varnishtest/vtc_logexp.c @@ -343,9 +343,9 @@ logexp_thread(void *priv) while (le->test) { i = VSLQ_Dispatch(le->vslq, logexp_dispatch, le); if (i == 2) - vtc_log(le->vl, 0, "bad| expectation failed"); + vtc_fatal(le->vl, "bad| expectation failed"); else if (i < 0) - vtc_log(le->vl, 0, "bad| dispatch failed (%d)", i); + vtc_fatal(le->vl, "bad| dispatch failed (%d)", i); else if (i == 0 && le->test) VTIM_sleep(0.01); } @@ -376,30 +376,30 @@ logexp_start(struct logexp *le) AZ(le->vslq); if (le->n_arg == NULL) { - vtc_log(le->vl, 0, "-v argument not given"); + vtc_fatal(le->vl, "-v argument not given"); return; } if (VSM_n_Arg(le->vsm, VSB_data(le->n_arg)) <= 0) { - vtc_log(le->vl, 0, "-v argument error: %s", + vtc_fatal(le->vl, "-v argument error: %s", VSM_Error(le->vsm)); return; } if (VSM_Open(le->vsm)) { - vtc_log(le->vl, 0, "VSM_Open: %s", VSM_Error(le->vsm)); + vtc_fatal(le->vl, "VSM_Open: %s", VSM_Error(le->vsm)); return; } AN(le->vsl); c = VSL_CursorVSM(le->vsl, le->vsm, (le->d_arg ? 0 : VSL_COPT_TAIL) | VSL_COPT_BATCH); if (c == NULL) { - vtc_log(le->vl, 0, "VSL_CursorVSM: %s", VSL_Error(le->vsl)); + vtc_fatal(le->vl, "VSL_CursorVSM: %s", VSL_Error(le->vsl)); logexp_close(le); return; } le->vslq = VSLQ_New(le->vsl, &c, le->g_arg, le->query); if (le->vslq == NULL) { VSL_DeleteCursor(c); - vtc_log(le->vl, 0, "VSLQ_New: %s", VSL_Error(le->vsl)); + vtc_fatal(le->vl, "VSLQ_New: %s", VSL_Error(le->vsl)); AZ(le->vslq); logexp_close(le); return; @@ -423,7 +423,7 @@ logexp_wait(struct logexp *le) AZ(pthread_join(le->tp, &res)); logexp_close(le); if (res != NULL && !vtc_stop) - vtc_log(le->vl, 0, "logexp returned \"%p\"", (char *)res); + vtc_fatal(le->vl, "logexp returned \"%p\"", (char *)res); le->run = 0; } @@ -443,7 +443,7 @@ cmd_logexp_expect(CMD_ARGS) (void)cmd; CAST_OBJ_NOTNULL(le, priv, LOGEXP_MAGIC); if (av[1] == NULL || av[2] == NULL || av[3] == NULL) { - vtc_log(vl, 0, "Syntax error"); + vtc_fatal(vl, "Syntax error"); return; } @@ -452,7 +452,7 @@ cmd_logexp_expect(CMD_ARGS) else { skip_max = (int)strtol(av[1], &end, 10); if (*end != '\0' || skip_max < 0) { - vtc_log(vl, 0, "Not a positive integer: '%s'", av[1]); + vtc_fatal(vl, "Not a positive integer: '%s'", av[1]); return; } } @@ -463,7 +463,7 @@ cmd_logexp_expect(CMD_ARGS) else { vxid = (int)strtol(av[2], &end, 10); if (*end != '\0' || vxid < 0) { - vtc_log(vl, 0, "Not a positive integer: '%s'", av[2]); + vtc_fatal(vl, "Not a positive integer: '%s'", av[2]); return; } } @@ -474,7 +474,7 @@ cmd_logexp_expect(CMD_ARGS) else { tag = VSL_Name2Tag(av[3], strlen(av[3])); if (tag < 0) { - vtc_log(vl, 0, "Unknown tag name: '%s'", av[3]); + vtc_fatal(vl, "Unknown tag name: '%s'", av[3]); return; } } @@ -482,7 +482,7 @@ cmd_logexp_expect(CMD_ARGS) if (av[4]) { vre = VRE_compile(av[4], 0, &err, &pos); if (vre == NULL) { - vtc_log(vl, 0, "Regex error (%s): '%s' pos %d", + vtc_fatal(vl, "Regex error (%s): '%s' pos %d", err, av[4], pos); return; } @@ -559,7 +559,7 @@ cmd_logexpect(CMD_ARGS) break; if (!strcmp(*av, "-wait")) { if (!le->run) { - vtc_log(le->vl, 0, "logexp not -started '%s'", + vtc_fatal(le->vl, "logexp not -started '%s'", *av); return; } @@ -577,7 +577,7 @@ cmd_logexpect(CMD_ARGS) if (!strcmp(*av, "-v")) { if (av[1] == NULL) { - vtc_log(le->vl, 0, "Missing -v argument"); + vtc_fatal(le->vl, "Missing -v argument"); return; } if (le->n_arg != NULL) @@ -595,7 +595,7 @@ cmd_logexpect(CMD_ARGS) } if (!strcmp(*av, "-d")) { if (av[1] == NULL) { - vtc_log(le->vl, 0, "Missing -d argument"); + vtc_fatal(le->vl, "Missing -d argument"); return; } le->d_arg = atoi(av[1]); @@ -604,12 +604,12 @@ cmd_logexpect(CMD_ARGS) } if (!strcmp(*av, "-g")) { if (av[1] == NULL) { - vtc_log(le->vl, 0, "Missing -g argument"); + vtc_fatal(le->vl, "Missing -g argument"); return; } le->g_arg = VSLQ_Name2Grouping(av[1], strlen(av[1])); if (le->g_arg < 0) { - vtc_log(le->vl, 0, "Unknown grouping '%s'", + vtc_fatal(le->vl, "Unknown grouping '%s'", av[1]); return; } @@ -618,7 +618,7 @@ cmd_logexpect(CMD_ARGS) } if (!strcmp(*av, "-q")) { if (av[1] == NULL) { - vtc_log(le->vl, 0, "Missing -q argument"); + vtc_fatal(le->vl, "Missing -q argument"); return; } REPLACE(le->query, av[1]); @@ -640,10 +640,10 @@ cmd_logexpect(CMD_ARGS) av++; continue; } - vtc_log(le->vl, 0, "%s", VSL_Error(le->vsl)); + vtc_fatal(le->vl, "%s", VSL_Error(le->vsl)); return; } - vtc_log(le->vl, 0, "Unknown logexp argument: %s", *av); + vtc_fatal(le->vl, "Unknown logexp argument: %s", *av); return; } logexp_spec(le, *av); diff --git a/bin/varnishtest/vtc_process.c b/bin/varnishtest/vtc_process.c index af07779..f8209ff 100644 --- a/bin/varnishtest/vtc_process.c +++ b/bin/varnishtest/vtc_process.c @@ -114,7 +114,7 @@ process_new(const char *name) p->fd_from = -1; if (*p->name != 'p') - vtc_log(p->vl, 0, "Process name must start with 'p'"); + vtc_fatal(p->vl, "Process name must start with 'p'"); VTAILQ_INSERT_TAIL(&processes, p, list); return (p); @@ -219,7 +219,7 @@ process_start(struct process *p) CHECK_OBJ_NOTNULL(p, PROCESS_MAGIC); if (p->hasthread) - vtc_log(p->vl, 0, "Already running, (-wait first)"); + vtc_fatal(p->vl, "Already running, (-wait first)"); vtc_log(p->vl, 4, "CMD: %s", p->spec); @@ -306,7 +306,7 @@ process_kill(struct process *p, const char *sig) AZ(pthread_mutex_unlock(&p->mtx)); if (pid <= 0) - vtc_log(p->vl, 0, "Cannot signal a non-running process"); + vtc_fatal(p->vl, "Cannot signal a non-running process"); if (!strcmp(sig, "TERM")) j = SIGTERM; @@ -317,10 +317,10 @@ process_kill(struct process *p, const char *sig) else if (*sig == '-') j = strtoul(sig + 1, NULL, 10); else - vtc_log(p->vl, 0, "Could not grok signal (%s)", sig); + vtc_fatal(p->vl, "Could not grok signal (%s)", sig); if (kill(-pid, j) < 0) - vtc_log(p->vl, 0, "Failed to send signal %d (%s)", + vtc_fatal(p->vl, "Failed to send signal %d (%s)", j, strerror(errno)); else vtc_log(p->vl, 4, "Sent signal %d", j); @@ -346,13 +346,13 @@ process_write(const struct process *p, const char *text) int r, len; if (!p->hasthread) - vtc_log(p->vl, 0, "Cannot write to a non-running process"); + vtc_fatal(p->vl, "Cannot write to a non-running process"); len = strlen(text); vtc_log(p->vl, 4, "Writing %d bytes", len); r = write(p->fd_to, text, len); if (r < 0) - vtc_log(p->vl, 0, "Failed to write: %s (%d)", + vtc_fatal(p->vl, "Failed to write: %s (%d)", strerror(errno), errno); } @@ -361,7 +361,7 @@ process_close(struct process *p) { if (!p->hasthread) - vtc_log(p->vl, 0, "Cannot close on a non-running process"); + vtc_fatal(p->vl, "Cannot close on a non-running process"); AZ(pthread_mutex_lock(&p->mtx)); if (p->fd_to >= 0) @@ -492,7 +492,7 @@ cmd_process(CMD_ARGS) continue; } if (**av == '-') - vtc_log(p->vl, 0, "Unknown process argument: %s", *av); + vtc_fatal(p->vl, "Unknown process argument: %s", *av); REPLACE(p->spec, *av); } } diff --git a/bin/varnishtest/vtc_server.c b/bin/varnishtest/vtc_server.c index 377fd1a..c1ad16b 100644 --- a/bin/varnishtest/vtc_server.c +++ b/bin/varnishtest/vtc_server.c @@ -126,7 +126,7 @@ server_listen(struct server *s) VTCP_close(&s->sock); s->sock = VTCP_listen_on(s->listen, "0", s->depth, &err); if (err != NULL) - vtc_log(s->vl, 0, + vtc_fatal(s->vl, "Server listen address (%s) cannot be resolved: %s", s->listen, err); assert(s->sock > 0); @@ -166,13 +166,13 @@ server_thread(void *priv) l = sizeof addr_s; fd = accept(s->sock, addr, &l); if (fd < 0) - vtc_log(vl, 0, "Accept failed: %s", strerror(errno)); + vtc_fatal(vl, "Accept failed: %s", strerror(errno)); vtc_log(vl, 3, "accepted fd %d", fd); fd = http_process(vl, s->spec, fd, &s->sock); vtc_log(vl, 3, "shutting fd %d", fd); j = shutdown(fd, SHUT_WR); if (!VTCP_Check(j)) - vtc_log(vl, 0, "Shutdown failed: %s", strerror(errno)); + vtc_fatal(vl, "Shutdown failed: %s", strerror(errno)); VTCP_close(&fd); } vtc_log(vl, 2, "Ending"); @@ -217,7 +217,7 @@ server_dispatch_wrk(void *priv) vtc_log(vl, 3, "shutting fd %d", fd); j = shutdown(fd, SHUT_WR); if (!VTCP_Check(j)) - vtc_log(vl, 0, "Shutdown failed: %s", strerror(errno)); + vtc_fatal(vl, "Shutdown failed: %s", strerror(errno)); VTCP_close(&s->fd); vtc_log(vl, 2, "Ending"); return (NULL); @@ -245,7 +245,7 @@ server_dispatch_thread(void *priv) l = sizeof addr_s; fd = accept(s->sock, addr, &l); if (fd < 0) - vtc_log(vl, 0, "Accepted failed: %s", strerror(errno)); + vtc_fatal(vl, "Accepted failed: %s", strerror(errno)); bprintf(snbuf, "s%d", sn++); vtc_log(vl, 3, "dispatch fd %d -> %s", fd, snbuf); s2 = server_new(snbuf); @@ -298,7 +298,7 @@ server_wait(struct server *s) vtc_log(s->vl, 2, "Waiting for server (%d/%d)", s->sock, s->fd); AZ(pthread_join(s->tp, &res)); if (res != NULL && !vtc_stop) - vtc_log(s->vl, 0, "Server returned \"%p\"", + vtc_fatal(s->vl, "Server returned \"%p\"", (char *)res); s->tp = 0; s->run = 0; @@ -382,7 +382,7 @@ cmd_server(CMD_ARGS) break; if (!strcmp(*av, "-wait")) { if (!s->run) - vtc_log(s->vl, 0, "Server not -started"); + vtc_fatal(s->vl, "Server not -started"); server_wait(s); continue; } @@ -426,7 +426,7 @@ cmd_server(CMD_ARGS) continue; } if (**av == '-') - vtc_log(s->vl, 0, "Unknown server argument: %s", *av); + vtc_fatal(s->vl, "Unknown server argument: %s", *av); s->spec = *av; } } diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c index 9ca75ed..1bc8789 100644 --- a/bin/varnishtest/vtc_varnish.c +++ b/bin/varnishtest/vtc_varnish.c @@ -108,16 +108,16 @@ varnish_ask_cli(const struct varnish *v, const char *cmd, char **repl) vtc_dump(v->vl, 4, "CLI TX", cmd, -1); i = write(v->cli_fd, cmd, strlen(cmd)); if (i != strlen(cmd)) - vtc_log(v->vl, 0, "CLI write failed (%s) = %u %s", + vtc_fatal(v->vl, "CLI write failed (%s) = %u %s", cmd, errno, strerror(errno)); i = write(v->cli_fd, "\n", 1); if (i != 1) - vtc_log(v->vl, 0, "CLI write failed (%s) = %u %s", + vtc_fatal(v->vl, "CLI write failed (%s) = %u %s", cmd, errno, strerror(errno)); } i = VCLI_ReadResult(v->cli_fd, &retval, &r, vtc_maxdur); if (i != 0) { - vtc_log(v->vl, 0, "CLI failed (%s) = %d %u %s", + vtc_fatal(v->vl, "CLI failed (%s) = %d %u %s", cmd, i, retval, r); return ((enum VCLI_status_e)retval); } @@ -145,7 +145,7 @@ wait_stopped(const struct varnish *v) vtc_log(v->vl, 3, "wait-stopped"); st = varnish_ask_cli(v, "status", &r); if (st != CLIS_OK) - vtc_log(v->vl, 0, + vtc_fatal(v->vl, "CLI status command failed: %u %s", st, r); if (!strcmp(r, "Child in state stopped")) { free(r); @@ -170,10 +170,10 @@ wait_running(const struct varnish *v) vtc_log(v->vl, 3, "wait-running"); st = varnish_ask_cli(v, "status", &r); if (st != CLIS_OK) - vtc_log(v->vl, 0, + vtc_fatal(v->vl, "CLI status command failed: %u %s", st, r); if (!strcmp(r, "Child in state stopped")) { - vtc_log(v->vl, 0, + vtc_fatal(v->vl, "Child stopped before running: %u %s", st, r); free(r); break; @@ -313,7 +313,7 @@ varnish_new(const char *name) AZ(system(buf)); if (*v->name != 'v') - vtc_log(v->vl, 0, "Varnish name must start with 'v'"); + vtc_fatal(v->vl, "Varnish name must start with 'v'"); v->args = VSB_new_auto(); @@ -406,7 +406,7 @@ varnish_launch(struct varnish *v) /* Create listener socket */ v->cli_fd = VTCP_listen_on("127.0.0.1:0", NULL, 1, &err); if (err != NULL) - vtc_log(v->vl, 0, "Create CLI listen socket failed: %s", err); + vtc_fatal(v->vl, "Create CLI listen socket failed: %s", err); assert(v->cli_fd > 0); VTCP_myname(v->cli_fd, abuf, sizeof abuf, pbuf, sizeof pbuf); @@ -481,19 +481,19 @@ varnish_launch(struct varnish *v) vtc_log(v->vl, 4, "CLIPOLL %d 0x%x 0x%x", i, fd[0].revents, fd[1].revents); if (i == 0) { - vtc_log(v->vl, 0, "FAIL timeout waiting for CLI connection"); + vtc_fatal(v->vl, "FAIL timeout waiting for CLI connection"); AZ(close(v->cli_fd)); v->cli_fd = -1; return; } if (fd[1].revents & POLLHUP) { - vtc_log(v->vl, 0, "FAIL debug pipe closed"); + vtc_fatal(v->vl, "FAIL debug pipe closed"); AZ(close(v->cli_fd)); v->cli_fd = -1; return; } if (!(fd[0].revents & POLLIN)) { - vtc_log(v->vl, 0, "FAIL CLI connection wait failure"); + vtc_fatal(v->vl, "FAIL CLI connection wait failure"); AZ(close(v->cli_fd)); v->cli_fd = -1; return; @@ -502,7 +502,7 @@ varnish_launch(struct varnish *v) if (nfd < 0) { AZ(close(v->cli_fd)); v->cli_fd = -1; - vtc_log(v->vl, 0, "FAIL no CLI connection accepted"); + vtc_fatal(v->vl, "FAIL no CLI connection accepted"); return; } @@ -517,7 +517,7 @@ varnish_launch(struct varnish *v) if (vtc_error) return; if (u != CLIS_AUTH) - vtc_log(v->vl, 0, "CLI auth demand expected: %u %s", u, r); + vtc_fatal(v->vl, "CLI auth demand expected: %u %s", u, r); bprintf(abuf, "%s/_.secret", v->workdir); nfd = open(abuf, O_RDONLY); @@ -535,7 +535,7 @@ varnish_launch(struct varnish *v) if (vtc_error) return; if (u != CLIS_OK) - vtc_log(v->vl, 0, "CLI auth command failed: %u %s", u, r); + vtc_fatal(v->vl, "CLI auth command failed: %u %s", u, r); free(r); (void)VSM_n_Arg(v->vd, v->workdir); @@ -561,7 +561,7 @@ varnish_start(struct varnish *v) if (vtc_error) return; if (u != CLIS_OK) - vtc_log(v->vl, 0, "CLI start command failed: %u %s", u, resp); + vtc_fatal(v->vl, "CLI start command failed: %u %s", u, resp); wait_running(v); free(resp); resp = NULL; @@ -569,7 +569,7 @@ varnish_start(struct varnish *v) if (vtc_error) return; if (u != CLIS_OK) - vtc_log(v->vl, 0, "CLI debug.xid command failed: %u %s", + vtc_fatal(v->vl, "CLI debug.xid command failed: %u %s", u, resp); free(resp); resp = NULL; @@ -577,7 +577,7 @@ varnish_start(struct varnish *v) if (vtc_error) return; if (u != CLIS_OK) - vtc_log(v->vl, 0, + vtc_fatal(v->vl, "CLI debug.listen_address command failed: %u %s", u, resp); h = resp; p = strchr(h, '\n'); @@ -661,11 +661,11 @@ varnish_cleanup(struct varnish *v) if (WIFEXITED(status) && (WEXITSTATUS(status) == 0)) return; #ifdef WCOREDUMP - vtc_log(v->vl, 0, "Bad exit code: %04x sig %x exit %x core %x", + vtc_fatal(v->vl, "Bad exit code: %04x sig %x exit %x core %x", status, WTERMSIG(status), WEXITSTATUS(status), WCOREDUMP(status)); #else - vtc_log(v->vl, 0, "Bad exit code: %04x sig %x exit %x", + vtc_fatal(v->vl, "Bad exit code: %04x sig %x exit %x", status, WTERMSIG(status), WEXITSTATUS(status)); #endif } @@ -710,7 +710,7 @@ varnish_cli(struct varnish *v, const char *cli, unsigned exp, const char *re) if (re != NULL) { vre = VRE_compile(re, 0, &errptr, &err); if (vre == NULL) - vtc_log(v->vl, 0, "Illegal regexp"); + vtc_fatal(v->vl, "Illegal regexp"); } if (v->cli_fd < 0) varnish_launch(v); @@ -719,11 +719,11 @@ varnish_cli(struct varnish *v, const char *cli, unsigned exp, const char *re) u = varnish_ask_cli(v, cli, &resp); vtc_log(v->vl, 2, "CLI %03u <%s>", u, cli); if (exp != 0 && exp != (unsigned)u) - vtc_log(v->vl, 0, "FAIL CLI response %u expected %u", u, exp); + vtc_fatal(v->vl, "FAIL CLI response %u expected %u", u, exp); if (vre != NULL) { err = VRE_exec(vre, resp, strlen(resp), 0, 0, NULL, 0, NULL); if (err < 1) - vtc_log(v->vl, 0, "Expect failed (%d)", err); + vtc_fatal(v->vl, "Expect failed (%d)", err); VRE_free(&vre); } } @@ -752,7 +752,7 @@ varnish_vcl(struct varnish *v, const char *vcl, int fail, char **resp) u = varnish_ask_cli(v, VSB_data(vsb), resp); if (u == CLIS_OK && fail) { VSB_destroy(&vsb); - vtc_log(v->vl, 0, + vtc_fatal(v->vl, "VCL compilation succeeded expected failure"); return; } else if (u == CLIS_OK) { @@ -763,7 +763,7 @@ varnish_vcl(struct varnish *v, const char *vcl, int fail, char **resp) assert(u == CLIS_OK); } else if (!fail) { VSB_destroy(&vsb); - vtc_log(v->vl, 0, + vtc_fatal(v->vl, "VCL compilation failed expected success"); return; } else { @@ -806,7 +806,7 @@ varnish_vclbackend(struct varnish *v, const char *vcl) if (u != CLIS_OK) { VSB_destroy(&vsb); VSB_destroy(&vsb2); - vtc_log(v->vl, 0, "FAIL VCL does not compile"); + vtc_fatal(v->vl, "FAIL VCL does not compile"); return; } VSB_clear(vsb); @@ -968,14 +968,14 @@ varnish_expect(const struct varnish *v, char * const *av) } if (not) { - vtc_log(v->vl, 0, "Found (not expected): %s", av[0]+1); + vtc_fatal(v->vl, "Found (not expected): %s", av[0]+1); return; } good = 0; ref = strtoumax(av[2], &p, 0); if (ref == UINTMAX_MAX || *p) - vtc_log(v->vl, 0, "Syntax error in number (%s)", av[2]); + vtc_fatal(v->vl, "Syntax error in number (%s)", av[2]); if (!strcmp(av[1], "==")) { if (sp.val == ref) good = 1; } else if (!strcmp(av[1], "!=")) { if (sp.val != ref) good = 1; } else if (!strcmp(av[1], ">")) { if (sp.val > ref) good = 1; } @@ -983,13 +983,13 @@ varnish_expect(const struct varnish *v, char * const *av) else if (!strcmp(av[1], ">=")) { if (sp.val >= ref) good = 1; } else if (!strcmp(av[1], "<=")) { if (sp.val <= ref) good = 1; } else { - vtc_log(v->vl, 0, "comparison %s unknown", av[1]); + vtc_fatal(v->vl, "comparison %s unknown", av[1]); } if (good) break; } if (good == -1) { - vtc_log(v->vl, 0, "VSM error: %s", VSM_Error(v->vd)); + vtc_fatal(v->vl, "VSM error: %s", VSM_Error(v->vd)); } if (good == -2) { if (not) { @@ -997,14 +997,14 @@ varnish_expect(const struct varnish *v, char * const *av) av[0] + 1); return; } - vtc_log(v->vl, 0, "stats field %s unknown", av[0]); + vtc_fatal(v->vl, "stats field %s unknown", av[0]); } if (good == 1) { vtc_log(v->vl, 2, "as expected: %s (%ju) %s %s", av[0], sp.val, av[1], av[2]); } else { - vtc_log(v->vl, 0, "Not true: %s (%ju) %s %s (%ju)", + vtc_fatal(v->vl, "Not true: %s (%ju) %s %s (%ju)", av[0], (uintmax_t)sp.val, av[1], av[2], (uintmax_t)ref); } } @@ -1177,7 +1177,7 @@ cmd_varnish(CMD_ARGS) AN(av[2]); varnish_vcl(v, av[2], 1, &r); if (strstr(r, av[1]) == NULL) - vtc_log(v->vl, 0, + vtc_fatal(v->vl, "Did not find expected string: (\"%s\")", av[1]); else @@ -1252,6 +1252,6 @@ cmd_varnish(CMD_ARGS) varnish_wait(v); continue; } - vtc_log(v->vl, 0, "Unknown varnish argument: %s", *av); + vtc_fatal(v->vl, "Unknown varnish argument: %s", *av); } } From phk at FreeBSD.org Wed Jan 18 12:42:04 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 18 Jan 2017 13:42:04 +0100 Subject: [master] c14ceeb Remove a now visibly unreached return statement Message-ID: commit c14ceeb2c2347d05ebf3dadeaccaf9ec7a6c497a Author: Poul-Henning Kamp Date: Wed Jan 18 12:41:15 2017 +0000 Remove a now visibly unreached return statement diff --git a/bin/varnishtest/vtc.c b/bin/varnishtest/vtc.c index fe503b2..dbe4508 100644 --- a/bin/varnishtest/vtc.c +++ b/bin/varnishtest/vtc.c @@ -681,7 +681,6 @@ cmd_feature(CMD_ARGS) av++; if (*av == NULL) { vtc_fatal(vl, "Missing the command-line"); - return; } r = system(*av); if (WEXITSTATUS(r) == 0) From phk at FreeBSD.org Wed Jan 18 13:00:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 18 Jan 2017 14:00:05 +0100 Subject: [master] 761905d Remove another 25 unreachable statements Message-ID: commit 761905d49611e67049ecf5035958dff0ff3b33ee Author: Poul-Henning Kamp Date: Wed Jan 18 12:59:19 2017 +0000 Remove another 25 unreachable statements diff --git a/bin/varnishtest/vtc_logexp.c b/bin/varnishtest/vtc_logexp.c index af7e6a1..81396b5 100644 --- a/bin/varnishtest/vtc_logexp.c +++ b/bin/varnishtest/vtc_logexp.c @@ -375,34 +375,22 @@ logexp_start(struct logexp *le) AN(le->vsl); AZ(le->vslq); - if (le->n_arg == NULL) { + if (le->n_arg == NULL) vtc_fatal(le->vl, "-v argument not given"); - return; - } - if (VSM_n_Arg(le->vsm, VSB_data(le->n_arg)) <= 0) { + if (VSM_n_Arg(le->vsm, VSB_data(le->n_arg)) <= 0) vtc_fatal(le->vl, "-v argument error: %s", VSM_Error(le->vsm)); - return; - } - if (VSM_Open(le->vsm)) { + if (VSM_Open(le->vsm)) vtc_fatal(le->vl, "VSM_Open: %s", VSM_Error(le->vsm)); - return; - } AN(le->vsl); c = VSL_CursorVSM(le->vsl, le->vsm, (le->d_arg ? 0 : VSL_COPT_TAIL) | VSL_COPT_BATCH); - if (c == NULL) { + if (c == NULL) vtc_fatal(le->vl, "VSL_CursorVSM: %s", VSL_Error(le->vsl)); - logexp_close(le); - return; - } le->vslq = VSLQ_New(le->vsl, &c, le->g_arg, le->query); if (le->vslq == NULL) { VSL_DeleteCursor(c); vtc_fatal(le->vl, "VSLQ_New: %s", VSL_Error(le->vsl)); - AZ(le->vslq); - logexp_close(le); - return; } AZ(c); @@ -442,19 +430,15 @@ cmd_logexp_expect(CMD_ARGS) (void)cmd; CAST_OBJ_NOTNULL(le, priv, LOGEXP_MAGIC); - if (av[1] == NULL || av[2] == NULL || av[3] == NULL) { + if (av[1] == NULL || av[2] == NULL || av[3] == NULL) vtc_fatal(vl, "Syntax error"); - return; - } if (!strcmp(av[1], "*")) skip_max = LE_ANY; else { skip_max = (int)strtol(av[1], &end, 10); - if (*end != '\0' || skip_max < 0) { + if (*end != '\0' || skip_max < 0) vtc_fatal(vl, "Not a positive integer: '%s'", av[1]); - return; - } } if (!strcmp(av[2], "*")) vxid = LE_ANY; @@ -462,10 +446,8 @@ cmd_logexp_expect(CMD_ARGS) vxid = LE_LAST; else { vxid = (int)strtol(av[2], &end, 10); - if (*end != '\0' || vxid < 0) { + if (*end != '\0' || vxid < 0) vtc_fatal(vl, "Not a positive integer: '%s'", av[2]); - return; - } } if (!strcmp(av[3], "*")) tag = LE_ANY; @@ -473,19 +455,15 @@ cmd_logexp_expect(CMD_ARGS) tag = LE_LAST; else { tag = VSL_Name2Tag(av[3], strlen(av[3])); - if (tag < 0) { + if (tag < 0) vtc_fatal(vl, "Unknown tag name: '%s'", av[3]); - return; - } } vre = NULL; if (av[4]) { vre = VRE_compile(av[4], 0, &err, &pos); - if (vre == NULL) { + if (vre == NULL) vtc_fatal(vl, "Regex error (%s): '%s' pos %d", err, av[4], pos); - return; - } } ALLOC_OBJ(test, LOGEXP_TEST_MAGIC); @@ -558,11 +536,9 @@ cmd_logexpect(CMD_ARGS) if (vtc_error) break; if (!strcmp(*av, "-wait")) { - if (!le->run) { + if (!le->run) vtc_fatal(le->vl, "logexp not -started '%s'", *av); - return; - } logexp_wait(le); continue; } @@ -576,10 +552,8 @@ cmd_logexpect(CMD_ARGS) AZ(le->run); if (!strcmp(*av, "-v")) { - if (av[1] == NULL) { + if (av[1] == NULL) vtc_fatal(le->vl, "Missing -v argument"); - return; - } if (le->n_arg != NULL) VSB_destroy(&le->n_arg); vsb = VSB_new_auto(); @@ -594,33 +568,25 @@ cmd_logexpect(CMD_ARGS) continue; } if (!strcmp(*av, "-d")) { - if (av[1] == NULL) { + if (av[1] == NULL) vtc_fatal(le->vl, "Missing -d argument"); - return; - } le->d_arg = atoi(av[1]); av++; continue; } if (!strcmp(*av, "-g")) { - if (av[1] == NULL) { + if (av[1] == NULL) vtc_fatal(le->vl, "Missing -g argument"); - return; - } le->g_arg = VSLQ_Name2Grouping(av[1], strlen(av[1])); - if (le->g_arg < 0) { + if (le->g_arg < 0) vtc_fatal(le->vl, "Unknown grouping '%s'", av[1]); - return; - } av++; continue; } if (!strcmp(*av, "-q")) { - if (av[1] == NULL) { + if (av[1] == NULL) vtc_fatal(le->vl, "Missing -q argument"); - return; - } REPLACE(le->query, av[1]); av++; continue; @@ -641,10 +607,8 @@ cmd_logexpect(CMD_ARGS) continue; } vtc_fatal(le->vl, "%s", VSL_Error(le->vsl)); - return; } vtc_fatal(le->vl, "Unknown logexp argument: %s", *av); - return; } logexp_spec(le, *av); } diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c index 1bc8789..48ef3f8 100644 --- a/bin/varnishtest/vtc_varnish.c +++ b/bin/varnishtest/vtc_varnish.c @@ -116,11 +116,9 @@ varnish_ask_cli(const struct varnish *v, const char *cmd, char **repl) cmd, errno, strerror(errno)); } i = VCLI_ReadResult(v->cli_fd, &retval, &r, vtc_maxdur); - if (i != 0) { + if (i != 0) vtc_fatal(v->vl, "CLI failed (%s) = %d %u %s", cmd, i, retval, r); - return ((enum VCLI_status_e)retval); - } AZ(i); vtc_log(v->vl, 3, "CLI RX %u", retval); vtc_dump(v->vl, 4, "CLI RX", r, -1); @@ -172,12 +170,9 @@ wait_running(const struct varnish *v) if (st != CLIS_OK) vtc_fatal(v->vl, "CLI status command failed: %u %s", st, r); - if (!strcmp(r, "Child in state stopped")) { + if (!strcmp(r, "Child in state stopped")) vtc_fatal(v->vl, "Child stopped before running: %u %s", st, r); - free(r); - break; - } if (!strcmp(r, "Child in state running")) { free(r); break; @@ -503,7 +498,6 @@ varnish_launch(struct varnish *v) AZ(close(v->cli_fd)); v->cli_fd = -1; vtc_fatal(v->vl, "FAIL no CLI connection accepted"); - return; } AZ(close(v->cli_fd)); @@ -754,7 +748,6 @@ varnish_vcl(struct varnish *v, const char *vcl, int fail, char **resp) VSB_destroy(&vsb); vtc_fatal(v->vl, "VCL compilation succeeded expected failure"); - return; } else if (u == CLIS_OK) { VSB_clear(vsb); VSB_printf(vsb, "vcl.use vcl%d", v->vcl_nbr); @@ -765,7 +758,6 @@ varnish_vcl(struct varnish *v, const char *vcl, int fail, char **resp) VSB_destroy(&vsb); vtc_fatal(v->vl, "VCL compilation failed expected success"); - return; } else { vtc_log(v->vl, 2, "VCL compilation failed (as expected)"); } @@ -807,7 +799,6 @@ varnish_vclbackend(struct varnish *v, const char *vcl) VSB_destroy(&vsb); VSB_destroy(&vsb2); vtc_fatal(v->vl, "FAIL VCL does not compile"); - return; } VSB_clear(vsb); VSB_printf(vsb, "vcl.use vcl%d", v->vcl_nbr); @@ -967,10 +958,8 @@ varnish_expect(const struct varnish *v, char * const *av) continue; } - if (not) { + if (not) vtc_fatal(v->vl, "Found (not expected): %s", av[0]+1); - return; - } good = 0; ref = strtoumax(av[2], &p, 0); From phk at FreeBSD.org Wed Jan 18 13:14:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 18 Jan 2017 14:14:05 +0100 Subject: [master] 466985b More unreachable code Message-ID: commit 466985b56de15055846d39c864d5dc7f4e368fa7 Author: Poul-Henning Kamp Date: Wed Jan 18 13:13:35 2017 +0000 More unreachable code diff --git a/bin/varnishtest/vtc_http2.c b/bin/varnishtest/vtc_http2.c index 449208e..da9e540 100644 --- a/bin/varnishtest/vtc_http2.c +++ b/bin/varnishtest/vtc_http2.c @@ -830,14 +830,12 @@ receive_frame(void *priv) return (NULL); } -#define STRTOU32(n, s, p, v, c) \ - do { \ - n = strtoul(s, &p, 0); \ - if (*p != '\0') { \ - vtc_fatal(v, "%s takes an integer as argument" \ - "(found %s)", c, s); \ - WRONG("Couldn't convert to integer");\ - } \ +#define STRTOU32(n, s, p, v, c) \ + do { \ + n = strtoul(s, &p, 0); \ + if (*p != '\0') \ + vtc_fatal(v, "%s takes an integer as argument" \ + "(found %s)", c, s); \ } while (0) #define STRTOU32_CHECK(n, sp, p, v, c, l) \ @@ -851,7 +849,7 @@ do { \ } while (0) #define CHECK_LAST_FRAME(TYPE) \ - if (!f || f->type != TYPE_ ## TYPE) { \ + if (!f || f->type != TYPE_ ## TYPE) { \ vtc_fatal(s->hp->vl, "Last frame was not of type " #TYPE); \ } diff --git a/bin/varnishtest/vtc_logexp.c b/bin/varnishtest/vtc_logexp.c index 81396b5..e042e89 100644 --- a/bin/varnishtest/vtc_logexp.c +++ b/bin/varnishtest/vtc_logexp.c @@ -578,7 +578,7 @@ cmd_logexpect(CMD_ARGS) if (av[1] == NULL) vtc_fatal(le->vl, "Missing -g argument"); le->g_arg = VSLQ_Name2Grouping(av[1], strlen(av[1])); - if (le->g_arg < 0) + if (le->g_arg < 0) vtc_fatal(le->vl, "Unknown grouping '%s'", av[1]); av++; From phk at FreeBSD.org Wed Jan 18 13:23:04 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 18 Jan 2017 14:23:04 +0100 Subject: [master] 5bbf8b8 Another three, but these detected as "loop not reachable" because of the while { } do(0) in AZ... Message-ID: commit 5bbf8b8dc09c3441d649d37754bd1118d1aba981 Author: Poul-Henning Kamp Date: Wed Jan 18 13:21:54 2017 +0000 Another three, but these detected as "loop not reachable" because of the while { } do(0) in AZ... diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c index 48ef3f8..2e93365 100644 --- a/bin/varnishtest/vtc_varnish.c +++ b/bin/varnishtest/vtc_varnish.c @@ -475,24 +475,12 @@ varnish_launch(struct varnish *v) i = poll(fd, 2, 10000); vtc_log(v->vl, 4, "CLIPOLL %d 0x%x 0x%x", i, fd[0].revents, fd[1].revents); - if (i == 0) { + if (i == 0) vtc_fatal(v->vl, "FAIL timeout waiting for CLI connection"); - AZ(close(v->cli_fd)); - v->cli_fd = -1; - return; - } - if (fd[1].revents & POLLHUP) { + if (fd[1].revents & POLLHUP) vtc_fatal(v->vl, "FAIL debug pipe closed"); - AZ(close(v->cli_fd)); - v->cli_fd = -1; - return; - } - if (!(fd[0].revents & POLLIN)) { + if (!(fd[0].revents & POLLIN)) vtc_fatal(v->vl, "FAIL CLI connection wait failure"); - AZ(close(v->cli_fd)); - v->cli_fd = -1; - return; - } nfd = accept(v->cli_fd, NULL, NULL); if (nfd < 0) { AZ(close(v->cli_fd)); From phk at FreeBSD.org Wed Jan 18 13:57:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 18 Jan 2017 14:57:05 +0100 Subject: [master] 7dac2dd Minor nitpickery from coverity Message-ID: commit 7dac2dd95fa1134f49fc45ae89a77775e3989d62 Author: Poul-Henning Kamp Date: Wed Jan 18 13:44:42 2017 +0000 Minor nitpickery from coverity diff --git a/bin/varnishstat/varnishstat.c b/bin/varnishstat/varnishstat.c index 45aa6e8..713b473 100644 --- a/bin/varnishstat/varnishstat.c +++ b/bin/varnishstat/varnishstat.c @@ -250,7 +250,7 @@ list_fields(struct VSM_data *vd) /*--------------------------------------------------------------------*/ -static void +static void __attribute__((__noreturn__)) usage(int status) { const char **opt; From phk at FreeBSD.org Wed Jan 18 13:57:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 18 Jan 2017 14:57:05 +0100 Subject: [master] 60cd957 More coverity nitpickery Message-ID: commit 60cd957279ca9aed9b1e2b59492e533e9fbff9da Author: Poul-Henning Kamp Date: Wed Jan 18 13:45:01 2017 +0000 More coverity nitpickery diff --git a/bin/varnishhist/varnishhist.c b/bin/varnishhist/varnishhist.c index f587db4..4c22994 100644 --- a/bin/varnishhist/varnishhist.c +++ b/bin/varnishhist/varnishhist.c @@ -358,7 +358,8 @@ accumulate(struct VSL_data *vsl, struct VSL_transaction * const pt[], // Lck_CondWait ts.tv_nsec = (long)(modf(when, &t) * 1e9); ts.tv_sec = (long)t; - (void)pthread_cond_timedwait(&timebend_cv, &mtx, &ts); + i = pthread_cond_timedwait(&timebend_cv, &mtx, &ts); + assert(i == 0 || i == ETIMEDOUT); } AZ(pthread_mutex_unlock(&mtx)); @@ -444,7 +445,7 @@ do_curses(void *arg) } if (ch == '<' || ch == '>') { - pthread_mutex_lock(&mtx); + AZ(pthread_mutex_lock(&mtx)); vsl_to = vsl_t0 = vsl_ts; t0 = VTIM_mono(); if (timebend == 0) @@ -453,8 +454,8 @@ do_curses(void *arg) timebend /= 2; else timebend *= 2; - pthread_cond_broadcast(&timebend_cv); - pthread_mutex_unlock(&mtx); + AZ(pthread_cond_broadcast(&timebend_cv)); + AZ(pthread_mutex_unlock(&mtx)); } } NEEDLESS(pthread_exit(NULL)); @@ -462,7 +463,7 @@ do_curses(void *arg) /*--------------------------------------------------------------------*/ -static void +static void __attribute__((__noreturn__)) usage(int status) { const char **opt; diff --git a/bin/varnishncsa/varnishncsa.c b/bin/varnishncsa/varnishncsa.c index b6e68cb..2e0f14e 100644 --- a/bin/varnishncsa/varnishncsa.c +++ b/bin/varnishncsa/varnishncsa.c @@ -158,7 +158,7 @@ static struct ctx { int32_t vxid; } CTX; -static void +static void __attribute__((__noreturn__)) usage(int status) { const char **opt; diff --git a/bin/varnishtop/varnishtop.c b/bin/varnishtop/varnishtop.c index f6a005c..7addb28 100644 --- a/bin/varnishtop/varnishtop.c +++ b/bin/varnishtop/varnishtop.c @@ -310,7 +310,7 @@ dump(void) } } -static void +static void __attribute__((__noreturn__)) usage(int status) { const char **opt; From phk at FreeBSD.org Thu Jan 19 12:56:04 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 19 Jan 2017 13:56:04 +0100 Subject: [master] 78b51e3 Fix a mistake I made yesterday which truncated multiline vtc_dump() Message-ID: commit 78b51e3fa5595a423f0ab272dd66661a18ee3a2c Author: Poul-Henning Kamp Date: Thu Jan 19 09:39:32 2017 +0000 Fix a mistake I made yesterday which truncated multiline vtc_dump() diff --git a/bin/varnishtest/vtc_log.c b/bin/varnishtest/vtc_log.c index b415302..5ef0813 100644 --- a/bin/varnishtest/vtc_log.c +++ b/bin/varnishtest/vtc_log.c @@ -117,7 +117,6 @@ vtc_leadinv(const struct vtclog *vl, int lvl, const char *fmt, va_list ap) assert(lvl < (int)NLEAD); assert(lvl >= 0); - VSB_clear(vl->vsb); VSB_printf(vl->vsb, "%s %-4s %4.1f ", lead[lvl < 0 ? 1: lvl], vl->id, vl->tx); if (fmt != NULL) From phk at FreeBSD.org Thu Jan 19 12:56:04 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 19 Jan 2017 13:56:04 +0100 Subject: [master] 497b076 Use printf(3) for consistency Message-ID: commit 497b076d7d065eeb3ea283c09d2f6c33583bc45b Author: Poul-Henning Kamp Date: Thu Jan 19 11:30:38 2017 +0000 Use printf(3) for consistency diff --git a/bin/varnishd/mgt/mgt_vcc.c b/bin/varnishd/mgt/mgt_vcc.c index 6a810b6..fbb5027 100644 --- a/bin/varnishd/mgt/mgt_vcc.c +++ b/bin/varnishd/mgt/mgt_vcc.c @@ -79,7 +79,7 @@ static const char * const builtin_vcl = void mgt_DumpBuiltin(void) { - puts(builtin_vcl); + printf("%s", builtin_vcl); } /*-------------------------------------------------------------------- From phk at FreeBSD.org Thu Jan 19 12:56:04 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 19 Jan 2017 13:56:04 +0100 Subject: [master] e6746bd Introduce VSB_quote_pfx() which prefixes each line with a string. Message-ID: commit e6746bd90cb6a50843356c808caa1eae46627082 Author: Poul-Henning Kamp Date: Thu Jan 19 12:22:39 2017 +0000 Introduce VSB_quote_pfx() which prefixes each line with a string. This *mainly* affects VSB_QUOTE_NONL. Make sure VSB_QUOTE_NONL always ends with a NL diff --git a/include/vsb.h b/include/vsb.h index 35e752b..0f5bfdc 100644 --- a/include/vsb.h +++ b/include/vsb.h @@ -80,6 +80,8 @@ void VSB_destroy(struct vsb **); #define VSB_QUOTE_JSON 2 #define VSB_QUOTE_HEX 4 #define VSB_QUOTE_CSTR 8 +void VSB_quote_pfx(struct vsb *, const char*, const void *, + int len, int how); void VSB_quote(struct vsb *, const void *, int len, int how); void VSB_indent(struct vsb *, int); #ifdef __cplusplus diff --git a/lib/libvarnish/vsb.c b/lib/libvarnish/vsb.c index b713642..99e6f50 100644 --- a/lib/libvarnish/vsb.c +++ b/lib/libvarnish/vsb.c @@ -500,17 +500,26 @@ VSB_destroy(struct vsb **s) * Quote a string */ void -VSB_quote(struct vsb *s, const void *v, int len, int how) +VSB_quote_pfx(struct vsb *s, const char *pfx, const void *v, int len, int how) { const char *p; const char *q; int quote = 0; + int nl = 0; const unsigned char *u, *w; assert(v != NULL); if (len == -1) len = strlen(v); + if (len == 0 && (how & VSB_QUOTE_CSTR)) { + VSB_printf(s, "%s\"\"", pfx); + return; + } else if (len == 0) + return; + + VSB_cat(s, pfx); + if (how & VSB_QUOTE_HEX) { u = v; for (w = u; w < u + len; w++) @@ -537,8 +546,14 @@ VSB_quote(struct vsb *s, const void *v, int len, int how) (void)VSB_bcat(s, p, len); return; } - (void)VSB_putc(s, '"'); + + if (how & VSB_QUOTE_CSTR) + (void)VSB_putc(s, '"'); + for (q = p; q < p + len; q++) { + if (nl) + VSB_cat(s, pfx); + nl = 0; switch (*q) { case '?': if (how & VSB_QUOTE_CSTR) @@ -554,12 +569,14 @@ VSB_quote(struct vsb *s, const void *v, int len, int how) (void)VSB_putc(s, *q); break; case '\n': - if (how & VSB_QUOTE_CSTR) - (void)VSB_cat(s, "\\n\"\n\t\""); - else if (how & VSB_QUOTE_NONL) - (void)VSB_cat(s, "\n"); - else - (void)VSB_cat(s, "\\n"); + if (how & VSB_QUOTE_CSTR) { + (void)VSB_printf(s, "\\n\"\n%s\t\"", pfx); + } else if (how & VSB_QUOTE_NONL) { + (void)VSB_printf(s, "\n"); + nl = 1; + } else { + (void)VSB_printf(s, "\\n"); + } break; case '\r': (void)VSB_cat(s, "\\r"); @@ -576,7 +593,16 @@ VSB_quote(struct vsb *s, const void *v, int len, int how) break; } } - (void)VSB_putc(s, '"'); + if (how & VSB_QUOTE_CSTR) + (void)VSB_putc(s, '"'); + if ((how & VSB_QUOTE_NONL && !nl)) + (void)VSB_putc(s, '\n'); +} + +void +VSB_quote(struct vsb *s, const void *v, int len, int how) +{ + VSB_quote_pfx(s, "", v, len, how); } /* From phk at FreeBSD.org Thu Jan 19 12:56:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 19 Jan 2017 13:56:05 +0100 Subject: [master] 092287f Keep track of needing to join the thread Message-ID: commit 092287f6919a338bdc0ebaf2e12e7107c8bb449f Author: Poul-Henning Kamp Date: Thu Jan 19 12:29:10 2017 +0000 Keep track of needing to join the thread diff --git a/bin/varnishtest/vtc_barrier.c b/bin/varnishtest/vtc_barrier.c index 04f1d71..8eb0348 100644 --- a/bin/varnishtest/vtc_barrier.c +++ b/bin/varnishtest/vtc_barrier.c @@ -64,6 +64,7 @@ struct barrier { /* fields below are only for BARRIER_SOCK */ pthread_t thread; volatile unsigned active; + volatile unsigned need_join; }; static pthread_mutex_t barrier_mtx; @@ -236,6 +237,7 @@ barrier_sock(struct barrier *b, const char *av, struct vtclog *vl) barrier_expect(b, av, vl); b->type = BARRIER_SOCK; b->active = 1; + b->need_join = 1; /* NB. We can use the BARRIER_COND's pthread_cond_t to wait until the * socket is ready for convenience. @@ -419,8 +421,11 @@ cmd_barrier(CMD_ARGS) case BARRIER_COND: break; case BARRIER_SOCK: - b->active = 0; - AZ(pthread_join(b->thread, NULL)); + if (b->need_join) { + b->active = 0; + AZ(pthread_join(b->thread, NULL)); + b->need_join = 0; + } break; default: WRONG("Wrong barrier type"); From phk at FreeBSD.org Thu Jan 19 12:56:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 19 Jan 2017 13:56:05 +0100 Subject: [master] b6f0915 Use the new VSB_quote_pfx instead of hand-rolling Message-ID: commit b6f0915b9c7079ef37247dd9aee6a9c97712634c Author: Poul-Henning Kamp Date: Thu Jan 19 12:37:50 2017 +0000 Use the new VSB_quote_pfx instead of hand-rolling diff --git a/bin/varnishtest/vtc_log.c b/bin/varnishtest/vtc_log.c index 5ef0813..309a10b 100644 --- a/bin/varnishtest/vtc_log.c +++ b/bin/varnishtest/vtc_log.c @@ -196,41 +196,22 @@ vtc_log(struct vtclog *vl, int lvl, const char *fmt, ...) void vtc_dump(struct vtclog *vl, int lvl, const char *pfx, const char *str, int len) { - int nl = 1, olen; - unsigned l; + char buf[64]; AN(pfx); GET_VL(vl); if (str == NULL) vtc_leadin(vl, lvl, "%s(null)\n", pfx); else { - olen = len; + bprintf(buf, "%s %-4s %4.1f %s|", + lead[lvl < 0 ? 1: lvl], vl->id, vl->tx, pfx); if (len < 0) len = strlen(str); - for (l = 0; l < len; l++, str++) { - if (l > 1024 && olen != -2) { - VSB_printf(vl->vsb, "..."); - break; - } - if (nl) { - vtc_leadin(vl, lvl, "%s| ", pfx); - nl = 0; - } - if (*str == '\r') - VSB_printf(vl->vsb, "\\r"); - else if (*str == '\t') - VSB_printf(vl->vsb, "\\t"); - else if (*str == '\n') { - VSB_printf(vl->vsb, "\\n\n"); - nl = 1; - } else if (*str < 0x20 || *str > 0x7e) - VSB_printf(vl->vsb, "\\x%02x", (*str) & 0xff); - else - VSB_printf(vl->vsb, "%c", *str); - } + VSB_quote_pfx(vl->vsb, buf, str,len > 1024 ? 1024 : len, + VSB_QUOTE_NONL); + if (len > 1024) + VSB_printf(vl->vsb, "%s [...] (%d)", buf, len - 1024); } - if (!nl) - VSB_printf(vl->vsb, "\n"); REL_VL(vl); if (lvl == 0) { vtc_error = 2; diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c index 2e93365..7a2e710 100644 --- a/bin/varnishtest/vtc_varnish.c +++ b/bin/varnishtest/vtc_varnish.c @@ -477,7 +477,7 @@ varnish_launch(struct varnish *v) i, fd[0].revents, fd[1].revents); if (i == 0) vtc_fatal(v->vl, "FAIL timeout waiting for CLI connection"); - if (fd[1].revents & POLLHUP) + if (fd[1].revents & POLLHUP) vtc_fatal(v->vl, "FAIL debug pipe closed"); if (!(fd[0].revents & POLLIN)) vtc_fatal(v->vl, "FAIL CLI connection wait failure"); From phk at FreeBSD.org Thu Jan 19 12:56:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 19 Jan 2017 13:56:05 +0100 Subject: [master] 12664cd Collect stdout/err from the test-running process in a VSB and emit it at the end of the run where it is far more likely to be noticed. Message-ID: commit 12664cd84d4740f25cc6647b9c69171956c3a8bf Author: Poul-Henning Kamp Date: Thu Jan 19 12:49:02 2017 +0000 Collect stdout/err from the test-running process in a VSB and emit it at the end of the run where it is far more likely to be noticed. diff --git a/bin/varnishtest/vtc_main.c b/bin/varnishtest/vtc_main.c index 158de74..ebc8b4d 100644 --- a/bin/varnishtest/vtc_main.c +++ b/bin/varnishtest/vtc_main.c @@ -77,6 +77,8 @@ struct vtc_job { char *tmpdir; unsigned bufsiz; double t0; + struct vsb *diag; + int killed; }; int iflg = 0; @@ -161,21 +163,23 @@ tst_cb(const struct vev *ve, int what) pid_t px; double t; FILE *f; + char *p; + struct vsb *v; CAST_OBJ_NOTNULL(jp, ve->priv, JOB_MAGIC); // printf("CB %p %s %d\n", ve, jp->tst->filename, what); - if (what == 0) + if (what == 0) { + jp->killed = 1; AZ(kill(jp->child, SIGKILL)); /* XXX: Timeout */ - else + } else { assert(what & (EV_RD | EV_HUP)); + } *buf = '\0'; - i = read(ve->fd, buf, sizeof buf - 1); - if (i > 0) { - buf[i] = '\0'; - printf("######## %s ########\n%s", jp->tst->filename, buf); - } + i = read(ve->fd, buf, sizeof buf); + if (i > 0) + VSB_bcat(jp->diag, buf, i); if (i == 0) { njob--; px = wait4(jp->child, &stx, 0, NULL); @@ -187,10 +191,21 @@ tst_cb(const struct vev *ve, int what) if (ecode == 0) ecode = WEXITSTATUS(stx); - if (ecode > 1 && vtc_verbosity) - printf("%s\n", jp->buf); - else if (vtc_verbosity > 1) - printf("%s\n", jp->buf); + AZ(VSB_finish(jp->diag)); + v = VSB_new_auto(); + AN(v); + VSB_cat(v, jp->buf); + p = strchr(jp->buf, '\0'); + if (p > jp->buf && p[-1] != '\n') + VSB_putc(v, '\n'); + VSB_quote_pfx(v, "* diag 0.0 ", + VSB_data(jp->diag), -1, VSB_QUOTE_NONL); + AZ(VSB_finish(v)); + VSB_destroy(&jp->diag); + AZ(munmap(jp->buf, jp->bufsiz)); + + if ((ecode > 1 && vtc_verbosity) || vtc_verbosity > 1) + printf("%s", VSB_data(v)); if (!ecode) vtc_good++; @@ -206,13 +221,14 @@ tst_cb(const struct vev *ve, int what) bprintf(buf, "%s/LOG", jp->tmpdir); f = fopen(buf, "w"); AN(f); - (void)fprintf(f, "%s\n", jp->buf); + (void)fprintf(f, "%s\n", VSB_data(v)); AZ(fclose(f)); } free(jp->tmpdir); + VSB_destroy(&v); if (ecode > 1) { - printf("# top TEST %s FAILED (%.3f)", + printf("# top TEST %s FAILED (%.3f)", jp->tst->filename, t); if (WIFSIGNALED(stx)) printf(" signal=%d\n", WTERMSIG(stx)); @@ -223,11 +239,10 @@ tst_cb(const struct vev *ve, int what) exit(2); } } else if (vtc_verbosity) { - printf("# top TEST %s %s (%.3f)\n", + printf("# top TEST %s %s (%.3f)\n", jp->tst->filename, ecode ? "skipped" : "passed", t); } - AZ(munmap(jp->buf, jp->bufsiz)); if (jp->evt != NULL) vev_del(vb, jp->evt); @@ -252,6 +267,9 @@ start_test(void) ALLOC_OBJ(jp, JOB_MAGIC); AN(jp); + jp->diag = VSB_new_auto(); + AN(jp->diag); + jp->bufsiz = vtc_bufsiz; jp->buf = mmap(NULL, jp->bufsiz, PROT_READ|PROT_WRITE, From phk at FreeBSD.org Thu Jan 19 17:30:06 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 19 Jan 2017 18:30:06 +0100 Subject: [master] 79889bc Also \n terminate in the NONL case where no quoting is necessary. Message-ID: commit 79889bc2ff512ea2850cb5bd88b35677e3b660c1 Author: Poul-Henning Kamp Date: Thu Jan 19 17:16:19 2017 +0000 Also \n terminate in the NONL case where no quoting is necessary. diff --git a/bin/varnishtest/vtc.c b/bin/varnishtest/vtc.c index dbe4508..e0d2744 100644 --- a/bin/varnishtest/vtc.c +++ b/bin/varnishtest/vtc.c @@ -723,15 +723,39 @@ static const struct cmds cmds[] = { { NULL, NULL } }; +static const char *tfn; + +int +fail_out(void) +{ + unsigned old_err; + + old_err = vtc_error; + if (!vtc_stop) + vtc_stop = 1; + vtc_log(vltop, 1, "RESETTING after %s", tfn); + reset_cmds(cmds); + vtc_error |= old_err; + + if (vtc_error) + vtc_log(vltop, 1, "TEST %s FAILED", tfn); + else + vtc_log(vltop, 1, "TEST %s completed", tfn); + + if (vtc_stop > 1) + return (1); + return (vtc_error); +} + int exec_file(const char *fn, const char *script, const char *tmpdir, char *logbuf, unsigned loglen) { - unsigned old_err; FILE *f; (void)signal(SIGPIPE, SIG_IGN); + tfn = fn; vtc_loginit(logbuf, loglen); vltop = vtc_logopen("top"); AN(vltop); @@ -755,19 +779,5 @@ exec_file(const char *fn, const char *script, const char *tmpdir, vtc_thread = pthread_self(); parse_string(script, cmds, NULL, vltop); - old_err = vtc_error; - if (!vtc_stop) - vtc_stop = 1; - vtc_log(vltop, 1, "RESETTING after %s", fn); - reset_cmds(cmds); - vtc_error |= old_err; - - if (vtc_error) - vtc_log(vltop, 1, "TEST %s FAILED", fn); - else - vtc_log(vltop, 1, "TEST %s completed", fn); - - if (vtc_stop > 1) - return (1); - return (vtc_error); + return(fail_out()); } diff --git a/bin/varnishtest/vtc.h b/bin/varnishtest/vtc.h index 8f999ad..14f3340 100644 --- a/bin/varnishtest/vtc.h +++ b/bin/varnishtest/vtc.h @@ -57,6 +57,7 @@ struct cmds { void parse_string(const char *spec, const struct cmds *cmd, void *priv, struct vtclog *vl); +int fail_out(void); #define CMD(n) cmd_f cmd_##n CMD(delay); diff --git a/bin/varnishtest/vtc_http.c b/bin/varnishtest/vtc_http.c index 46f6d68..a25b235 100644 --- a/bin/varnishtest/vtc_http.c +++ b/bin/varnishtest/vtc_http.c @@ -524,14 +524,18 @@ http_rxchar(struct http *hp, int n, int eof) i = poll(pfd, 1, hp->timeout); if (i < 0 && errno == EINTR) continue; - if (i == 0) + if (i == 0) { vtc_log(hp->vl, hp->fatal, "HTTP rx timeout (fd:%d %u ms)", hp->fd, hp->timeout); - if (i < 0) + continue; + } + if (i < 0) { vtc_log(hp->vl, hp->fatal, "HTTP rx failed (fd:%d poll: %s)", hp->fd, strerror(errno)); + continue; + } assert(i > 0); assert(hp->prxbuf + n < hp->nrxbuf); i = read(hp->fd, hp->rxbuf + hp->prxbuf, n); @@ -541,14 +545,18 @@ http_rxchar(struct http *hp, int n, int eof) hp->fd, pfd[0].revents, n, i); if (i == 0 && eof) return (i); - if (i == 0) + if (i == 0) { vtc_log(hp->vl, hp->fatal, "HTTP rx EOF (fd:%d read: %s) %d", hp->fd, strerror(errno), n); - if (i < 0) + return (-1); + } + if (i < 0) { vtc_log(hp->vl, hp->fatal, "HTTP rx failed (fd:%d read: %s)", hp->fd, strerror(errno)); + return (-1); + } hp->prxbuf += i; hp->rxbuf[hp->prxbuf] = '\0'; n -= i; @@ -563,9 +571,10 @@ http_rxchunk(struct http *hp) int l, i; l = hp->prxbuf; - do - (void)http_rxchar(hp, 1, 0); - while (hp->rxbuf[hp->prxbuf - 1] != '\n'); + do { + if (http_rxchar(hp, 1, 0) < 0) + return (-1); + } while (hp->rxbuf[hp->prxbuf - 1] != '\n'); vtc_dump(hp->vl, 4, "len", hp->rxbuf + l, -1); i = strtoul(hp->rxbuf + l, &q, 16); bprintf(hp->chunklen, "%d", i); @@ -573,25 +582,31 @@ http_rxchunk(struct http *hp) (*q != '\0' && !vct_islws(*q))) { vtc_log(hp->vl, hp->fatal, "chunked fail %02x @ %td", *q, q - (hp->rxbuf + l)); + return (-1); } assert(q != hp->rxbuf + l); assert(*q == '\0' || vct_islws(*q)); hp->prxbuf = l; if (i > 0) { - (void)http_rxchar(hp, i, 0); - vtc_dump(hp->vl, 4, "chunk", - hp->rxbuf + l, i); + if (http_rxchar(hp, i, 0) < 0) + return (-1); + vtc_dump(hp->vl, 4, "chunk", hp->rxbuf + l, i); } l = hp->prxbuf; - (void)http_rxchar(hp, 2, 0); - if(!vct_iscrlf(hp->rxbuf + l)) + if (http_rxchar(hp, 2, 0) < 0) + return (-1); + if(!vct_iscrlf(hp->rxbuf + l)) { vtc_log(hp->vl, hp->fatal, "Wrong chunk tail[0] = %02x", hp->rxbuf[l] & 0xff); - if(!vct_iscrlf(hp->rxbuf + l + 1)) + return (-1); + } + if(!vct_iscrlf(hp->rxbuf + l + 1)) { vtc_log(hp->vl, hp->fatal, "Wrong chunk tail[1] = %02x", hp->rxbuf[l + 1] & 0xff); + return (-1); + } hp->prxbuf = l; hp->rxbuf[l] = '\0'; return (i); diff --git a/bin/varnishtest/vtc_log.c b/bin/varnishtest/vtc_log.c index 309a10b..8914e43 100644 --- a/bin/varnishtest/vtc_log.c +++ b/bin/varnishtest/vtc_log.c @@ -101,6 +101,18 @@ vtc_logclose(struct vtclog *vl) FREE_OBJ(vl); } +static void __attribute__((__noreturn__)) +vtc_logfail(void) +{ + + vtc_error = 2; + if (pthread_self() != vtc_thread) { + fprintf(stderr, "FAIL thread %p\n", pthread_self()); + pthread_exit(NULL); + } else + exit(fail_out()); +} + static const char * const lead[] = { "----", "* ", @@ -162,11 +174,9 @@ vtc_fatal(struct vtclog *vl, const char *fmt, ...) va_end(ap); REL_VL(vl); - vtc_error = 2; - if (pthread_self() != vtc_thread) - pthread_exit(NULL); - while(1) continue; + vtc_logfail(); } + void vtc_log(struct vtclog *vl, int lvl, const char *fmt, ...) { @@ -184,9 +194,7 @@ vtc_log(struct vtclog *vl, int lvl, const char *fmt, ...) if (lvl > 0) return; if (lvl == 0) - vtc_error = 2; - if (pthread_self() != vtc_thread) - pthread_exit(NULL); + vtc_logfail(); } /********************************************************************** @@ -213,11 +221,8 @@ vtc_dump(struct vtclog *vl, int lvl, const char *pfx, const char *str, int len) VSB_printf(vl->vsb, "%s [...] (%d)", buf, len - 1024); } REL_VL(vl); - if (lvl == 0) { - vtc_error = 2; - if (pthread_self() != vtc_thread) - pthread_exit(NULL); - } + if (lvl == 0) + vtc_logfail(); } /********************************************************************** @@ -255,11 +260,8 @@ vtc_hexdump(struct vtclog *vl, int lvl, const char *pfx, if (!nl) VSB_printf(vl->vsb, "\n"); REL_VL(vl); - if (lvl == 0) { - vtc_error = 2; - if (pthread_self() != vtc_thread) - pthread_exit(NULL); - } + if (lvl == 0) + vtc_logfail(); } /**********************************************************************/ diff --git a/bin/varnishtest/vtc_main.c b/bin/varnishtest/vtc_main.c index ebc8b4d..7cdf3fc 100644 --- a/bin/varnishtest/vtc_main.c +++ b/bin/varnishtest/vtc_main.c @@ -227,6 +227,9 @@ tst_cb(const struct vev *ve, int what) free(jp->tmpdir); VSB_destroy(&v); + if (jp->killed) + printf("# top TEST %s TIMED OUT (kill -9)\n", + jp->tst->filename); if (ecode > 1) { printf("# top TEST %s FAILED (%.3f)", jp->tst->filename, t); diff --git a/lib/libvarnish/vsb.c b/lib/libvarnish/vsb.c index 99e6f50..bc72919 100644 --- a/lib/libvarnish/vsb.c +++ b/lib/libvarnish/vsb.c @@ -544,6 +544,8 @@ VSB_quote_pfx(struct vsb *s, const char *pfx, const void *v, int len, int how) } if (!quote && !(how & (VSB_QUOTE_JSON|VSB_QUOTE_CSTR))) { (void)VSB_bcat(s, p, len); + if ((how & VSB_QUOTE_NONL) && p[len-1] != '\n') + (void)VSB_putc(s, '\n'); return; } @@ -595,7 +597,7 @@ VSB_quote_pfx(struct vsb *s, const char *pfx, const void *v, int len, int how) } if (how & VSB_QUOTE_CSTR) (void)VSB_putc(s, '"'); - if ((how & VSB_QUOTE_NONL && !nl)) + if ((how & VSB_QUOTE_NONL) && !nl) (void)VSB_putc(s, '\n'); } From phk at FreeBSD.org Thu Jan 19 17:30:06 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 19 Jan 2017 18:30:06 +0100 Subject: [master] 556951d Tell it if we timed out the testcase and killed the child. Message-ID: commit 556951d2f811b3398e1f85fd44432f654292f390 Author: Poul-Henning Kamp Date: Thu Jan 19 17:22:00 2017 +0000 Tell it if we timed out the testcase and killed the child. Fail out of http reception if the socket fails diff --git a/bin/varnishtest/vtc_http.c b/bin/varnishtest/vtc_http.c index a25b235..7c0d36b 100644 --- a/bin/varnishtest/vtc_http.c +++ b/bin/varnishtest/vtc_http.c @@ -625,7 +625,7 @@ http_swallow_body(struct http *hp, char * const *hh, int body) ll = 0; p = http_find_header(hh, "transfer-encoding"); if (p != NULL && !strcasecmp(p, "chunked")) { - while (http_rxchunk(hp) != 0) + while (http_rxchunk(hp) > 0) continue; vtc_dump(hp->vl, 4, "body", hp->body, ll); ll = hp->rxbuf + hp->prxbuf - hp->body; @@ -636,7 +636,8 @@ http_swallow_body(struct http *hp, char * const *hh, int body) p = http_find_header(hh, "content-length"); if (p != NULL) { l = strtoul(p, NULL, 10); - (void)http_rxchar(hp, l, 0); + if (http_rxchar(hp, l, 0) < 0) + return; vtc_dump(hp->vl, 4, "body", hp->body, l); hp->bodyl = l; bprintf(hp->bodylen, "%d", l); @@ -645,6 +646,8 @@ http_swallow_body(struct http *hp, char * const *hh, int body) if (body) { do { i = http_rxchar(hp, 1, 1); + if (i < 0) + return; ll += i; } while (i > 0); vtc_dump(hp->vl, 4, "rxeof", hp->body, ll); From phk at FreeBSD.org Thu Jan 19 17:30:06 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 19 Jan 2017 18:30:06 +0100 Subject: [master] 530cb4c Report testfiles without "varnishtest" as skipped. Message-ID: commit 530cb4c00c1e0282d6867dacdc0faa977b239ebe Author: Poul-Henning Kamp Date: Thu Jan 19 17:29:19 2017 +0000 Report testfiles without "varnishtest" as skipped. Have varnishtest test varnishtest (don't look!) diff --git a/bin/varnishtest/programs.h b/bin/varnishtest/programs.h index 1bc85c8..4849005 100644 --- a/bin/varnishtest/programs.h +++ b/bin/varnishtest/programs.h @@ -33,5 +33,6 @@ VTC_PROG(varnishhist) VTC_PROG(varnishlog) VTC_PROG(varnishncsa) VTC_PROG(varnishstat) +VTC_PROG(varnishtest) VTC_PROG(varnishtop) #undef VTC_PROG diff --git a/bin/varnishtest/tests/a00000.vtc b/bin/varnishtest/tests/a00000.vtc index eb42f48..8c3c17c 100644 --- a/bin/varnishtest/tests/a00000.vtc +++ b/bin/varnishtest/tests/a00000.vtc @@ -1,21 +1,27 @@ -# the first token in a varnishtest file must be "varnishtest", - # but whitespace (SP) - # and (TAB) and comments are fine +varnishtest "Test varnishtest itself" -varnishtest "basic default HTTP transactions" +shell -exit 1 -expect {usage: varnishtest} {varnishtest -h} -server s1 { - rxreq - txresp +shell { + pwd + echo 'notvarnishtest foo bar' > _.vtc + echo 'shell "exit 9"' >> _.vtc } -server s1 -start +shell -exit 2 -expect {doesn't start with 'varnishtest'} { + varnishtest -v _.vtc +} -client c1 -connect ${s1_sock} { - txreq - rxresp +shell -exit 77 -expect {0 tests failed, 1 tests skipped, 0 tests passed} { + unset TMPDIR + varnishtest -k _.vtc } -client c1 -run +# Test external macro-def with a a two-turtle test +shell -expect {__=barf} { + echo varnishtest foo > _.vtc + printf 'shell {echo %c{foobar} > ${tmpdir}/__}' '$' >> _.vtc + varnishtest -q -Dfoobar=barf _.vtc + echo __=`cat __` +} -server s1 -wait diff --git a/bin/varnishtest/tests/a00001.vtc b/bin/varnishtest/tests/a00001.vtc index fd2ea9c..e15969e 100644 --- a/bin/varnishtest/tests/a00001.vtc +++ b/bin/varnishtest/tests/a00001.vtc @@ -1,3 +1,6 @@ +# the first token in a varnishtest file must be "varnishtest", + # but whitespace (SP) + # and (TAB) and comments are fine varnishtest "basic default HTTP transactions with expect" server s1 { diff --git a/bin/varnishtest/vtc_main.c b/bin/varnishtest/vtc_main.c index 7cdf3fc..c18f355 100644 --- a/bin/varnishtest/vtc_main.c +++ b/bin/varnishtest/vtc_main.c @@ -544,6 +544,7 @@ read_file(const char *fn, int ntest) fprintf(stderr, "File \"%s\" doesn't start with 'varnishtest'\n", fn); free(p); + vtc_skip++; return(2); } ALLOC_OBJ(tp, TST_MAGIC); From phk at FreeBSD.org Thu Jan 19 17:36:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 19 Jan 2017 18:36:05 +0100 Subject: [master] a3d915f Remove debugging. Message-ID: commit a3d915f601a368547185bb87c74e06fed0c15826 Author: Poul-Henning Kamp Date: Thu Jan 19 17:35:28 2017 +0000 Remove debugging. diff --git a/bin/varnishtest/vtc_log.c b/bin/varnishtest/vtc_log.c index 8914e43..c2ebbf6 100644 --- a/bin/varnishtest/vtc_log.c +++ b/bin/varnishtest/vtc_log.c @@ -106,10 +106,9 @@ vtc_logfail(void) { vtc_error = 2; - if (pthread_self() != vtc_thread) { - fprintf(stderr, "FAIL thread %p\n", pthread_self()); + if (pthread_self() != vtc_thread) pthread_exit(NULL); - } else + else exit(fail_out()); } From fgsch at lodoss.net Thu Jan 19 22:13:04 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Thu, 19 Jan 2017 23:13:04 +0100 Subject: [master] 13db0ab Clarify %r formatter wrt multiple Host headers Message-ID: commit 13db0ab6bf857ede7bfc562e542b489f0ef0bfd9 Author: Federico G. Schwindt Date: Thu Jan 19 22:03:27 2017 +0000 Clarify %r formatter wrt multiple Host headers Also clarify %{X}i and %{X}o wrt multiple X headers. Fixes #2190. diff --git a/doc/sphinx/reference/varnishncsa.rst b/doc/sphinx/reference/varnishncsa.rst index f6f5560..ce1b1d9 100644 --- a/doc/sphinx/reference/varnishncsa.rst +++ b/doc/sphinx/reference/varnishncsa.rst @@ -98,7 +98,8 @@ Supported formatters are: total bytes sent to the backend. %{X}i - The contents of request header X. + The contents of request header X. If the header appears multiple times + in a single transaction, the last occurrence is used. %l Remote logname. Always '-'. @@ -107,7 +108,8 @@ Supported formatters are: Request method. Defaults to '-' if not known. %{X}o - The contents of response header X. + The contents of response header X. If the header appears multiple + times in a single transaction, the last occurrence is used. %O In client mode, total bytes sent to client. In backend mode, total @@ -178,8 +180,7 @@ Supported formatters are: of fields, and only the nth part of the record will be matched against. Fields start counting at 1. Defaults to '-' when the tag is not seen, or when the field is out of bounds. If a tag appears - several times in a single transaction, only the first occurrence - is used. + multiple times in a single transaction, the first occurrence is used. SIGNALS ======= @@ -195,6 +196,8 @@ NOTES The %r formatter is equivalent to "%m http://%{Host}i%U%q %H". This differs from apache's %r behavior, equivalent to "%m %U%q %H". +Furthermore, when using the %r formatter, if the Host header appears +multiple times in a single transaction, the first occurrence is used. EXAMPLE ======= From fgsch at lodoss.net Fri Jan 20 09:50:05 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Fri, 20 Jan 2017 10:50:05 +0100 Subject: [master] da0d1c8 Decouple testing from the gunzip counter Message-ID: commit da0d1c86c7b5348dfb3ed48160ca6dd57c876172 Author: Federico G. Schwindt Date: Wed Jan 18 08:33:52 2017 +0000 Decouple testing from the gunzip counter Add a new counter, n_test_gunzip to track the former. diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c index 1860799..deb3b21 100644 --- a/bin/varnishd/cache/cache_gzip.c +++ b/bin/varnishd/cache/cache_gzip.c @@ -76,7 +76,7 @@ vgz_msg(const struct vgz *vg) */ static struct vgz * -vgz_alloc_vgz(struct vsl_log *vsl, const char *id) +vgz_gunzip(struct vsl_log *vsl, const char *id) { struct vgz *vg; @@ -84,17 +84,7 @@ vgz_alloc_vgz(struct vsl_log *vsl, const char *id) AN(vg); vg->vsl = vsl; vg->id = id; - return (vg); -} - -static struct vgz * -VGZ_NewUngzip(struct vsl_log *vsl, const char *id) -{ - struct vgz *vg; - - vg = vgz_alloc_vgz(vsl, id); vg->dir = VGZ_UN; - VSC_C_main->n_gunzip++; /* * Max memory usage according to zonf.h: @@ -106,15 +96,32 @@ VGZ_NewUngzip(struct vsl_log *vsl, const char *id) return (vg); } +static struct vgz * +VGZ_NewGunzip(struct vsl_log *vsl, const char *id) +{ + VSC_C_main->n_gunzip++; + return (vgz_gunzip(vsl, id)); +} + +static struct vgz * +VGZ_NewTestGunzip(struct vsl_log *vsl, const char *id) +{ + VSC_C_main->n_test_gunzip++; + return (vgz_gunzip(vsl, id)); +} + struct vgz * VGZ_NewGzip(struct vsl_log *vsl, const char *id) { struct vgz *vg; int i; - vg = vgz_alloc_vgz(vsl, id); - vg->dir = VGZ_GZ; VSC_C_main->n_gzip++; + ALLOC_OBJ(vg, VGZ_MAGIC); + AN(vg); + vg->vsl = vsl; + vg->id = id; + vg->dir = VGZ_GZ; /* * From zconf.h: @@ -293,7 +300,7 @@ VDP_gunzip(struct req *req, enum vdp_action act, void **priv, CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); if (act == VDP_INIT) { - vg = VGZ_NewUngzip(req->vsl, "U D -"); + vg = VGZ_NewGunzip(req->vsl, "U D -"); AN(vg); if (vgz_getmbuf(vg)) { (void)VGZ_Destroy(&vg); @@ -451,7 +458,10 @@ vfp_gzip_init(struct vfp_ctx *vc, struct vfp_entry *vfe) } else { if (!http_HdrIs(vc->http, H_Content_Encoding, "gzip")) return (VFP_NULL); - vg = VGZ_NewUngzip(vc->wrk->vsl, vfe->vfp->priv1); + if (vfe->vfp->priv2 == VFP_GUNZIP) + vg = VGZ_NewGunzip(vc->wrk->vsl, vfe->vfp->priv1); + else + vg = VGZ_NewTestGunzip(vc->wrk->vsl, vfe->vfp->priv1); } if (vg == NULL) return (VFP_ERROR); diff --git a/bin/varnishtest/tests/g00001.vtc b/bin/varnishtest/tests/g00001.vtc index a1343fe..0f84f54 100644 --- a/bin/varnishtest/tests/g00001.vtc +++ b/bin/varnishtest/tests/g00001.vtc @@ -43,3 +43,7 @@ client c1 { expect resp.http.content-length == "26" expect resp.http.content-encoding == "gzip" } -run + +varnish v1 -expect n_gzip == 0 +varnish v1 -expect n_gunzip == 3 +varnish v1 -expect n_test_gunzip == 1 diff --git a/bin/varnishtest/tests/g00002.vtc b/bin/varnishtest/tests/g00002.vtc index 1abdd8e..b722617 100644 --- a/bin/varnishtest/tests/g00002.vtc +++ b/bin/varnishtest/tests/g00002.vtc @@ -50,3 +50,7 @@ client c1 { expect resp.http.content-encoding == expect resp.bodylen == 4109 } -run + +varnish v1 -expect n_gzip == 1 +varnish v1 -expect n_gunzip == 3 +varnish v1 -expect n_test_gunzip == 0 diff --git a/bin/varnishtest/tests/g00003.vtc b/bin/varnishtest/tests/g00003.vtc index 6fdae5c..ee032e3 100644 --- a/bin/varnishtest/tests/g00003.vtc +++ b/bin/varnishtest/tests/g00003.vtc @@ -49,3 +49,7 @@ client c1 { expect resp.http.content-encoding == expect resp.bodylen == 43 } -run + +varnish v1 -expect n_gzip == 1 +varnish v1 -expect n_gunzip == 2 +varnish v1 -expect n_test_gunzip == 0 diff --git a/include/tbl/vsc_f_main.h b/include/tbl/vsc_f_main.h index 7dbc87d..97e25ef 100644 --- a/include/tbl/vsc_f_main.h +++ b/include/tbl/vsc_f_main.h @@ -662,6 +662,11 @@ VSC_FF(n_gunzip, uint64_t, 0, 'c', 'i', info, "" ) +VSC_FF(n_test_gunzip, uint64_t, 0, 'c', 'i', info, + "Test gunzip operations", + "" +) + /*--------------------------------------------------------------------*/ VSC_FF(vsm_free, uint64_t, 0, 'g', 'B', diag, From fgsch at lodoss.net Fri Jan 20 12:01:05 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Fri, 20 Jan 2017 13:01:05 +0100 Subject: [master] fd23878 Remove new line and indentation OCD Message-ID: commit fd2387888f9ef9439916b90dcaff7331af9b1825 Author: Federico G. Schwindt Date: Fri Jan 20 11:58:18 2017 +0000 Remove new line and indentation OCD diff --git a/lib/libvarnishapi/vsl_arg.c b/lib/libvarnishapi/vsl_arg.c index 89ab29d..23f1844 100644 --- a/lib/libvarnishapi/vsl_arg.c +++ b/lib/libvarnishapi/vsl_arg.c @@ -244,13 +244,13 @@ vsl_ix_arg(struct VSL_data *vsl, int opt, const char *arg) vsl->vbm_supress); if (i == -1) return (vsl_diag(vsl, "-%c: \"%s\" matches zero tags", - (char)opt, arg)); + (char)opt, arg)); else if (i == -2) return (vsl_diag(vsl, "-%c: \"%s\" is ambiguous", - (char)opt, arg)); + (char)opt, arg)); else if (i == -3) return (vsl_diag(vsl, "-%c: Syntax error in \"%s\"", - (char)opt, arg)); + (char)opt, arg)); return (1); } @@ -278,16 +278,16 @@ vsl_IX_arg(struct VSL_data *vsl, int opt, const char *arg) vbit_destroy(tags); if (i == -1) return (vsl_diag(vsl, - "-%c: \"%*.*s\" matches zero tags", - (char)opt, l, l, b)); + "-%c: \"%*.*s\" matches zero tags", + (char)opt, l, l, b)); else if (i == -2) return (vsl_diag(vsl, - "-%c: \"%*.*s\" is ambiguous", - (char)opt, l, l, b)); + "-%c: \"%*.*s\" is ambiguous", + (char)opt, l, l, b)); else if (i <= -3) return (vsl_diag(vsl, - "-%c: Syntax error in \"%*.*s\"", - (char)opt, l, l, b)); + "-%c: Syntax error in \"%*.*s\"", + (char)opt, l, l, b)); b = e + 1; } @@ -295,8 +295,8 @@ vsl_IX_arg(struct VSL_data *vsl, int opt, const char *arg) if (vre == NULL) { if (tags) vbit_destroy(tags); - return (vsl_diag(vsl, "-%c: Regex error at position %d (%s)\n", - (char)opt, off, err)); + return (vsl_diag(vsl, "-%c: Regex error at position %d (%s)", + (char)opt, off, err)); } ALLOC_OBJ(vslf, VSLF_MAGIC); From fgsch at lodoss.net Fri Jan 20 12:01:05 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Fri, 20 Jan 2017 13:01:05 +0100 Subject: [master] 87a1a0d Merge tests and add more coverage Message-ID: commit 87a1a0d7e6cd9dd8a8985c7c16298e2096c4046c Author: Federico G. Schwindt Date: Fri Jan 20 11:59:20 2017 +0000 Merge tests and add more coverage My aim is to have one u* vtc per tool. diff --git a/bin/varnishtest/tests/u00002.vtc b/bin/varnishtest/tests/u00002.vtc deleted file mode 100644 index 67b7c81..0000000 --- a/bin/varnishtest/tests/u00002.vtc +++ /dev/null @@ -1,31 +0,0 @@ -varnishtest "Test varnishstat -f option" - -server s1 { - rxreq - txresp -} -start - -varnish v1 -vcl+backend {} -start - -# On fast systems the next varnishstat will return "inf" counters -# if we don't give varnishd a chance to get going. - -delay 1 - -process p1 {varnishstat -1 -n ${v1_name} -f ^LCK.vbe.destroy \ - -f LCK.vbe.* -f LCK.mempool.* | tr '[1-9]' '0'} -run - -shell "grep -q vbe ${tmpdir}/p1/stdout" -shell "grep -q mempool ${tmpdir}/p1/stdout" -shell -err "grep -q LCK.vbe.destroy ${tmpdir}/p1/stdout" - -process p2 {varnishstat -1 -n ${v1_name} -f ^*vbe.destroy \ - -f *vbe* -f *mempool* | tr '[1-9]' '0'} -run - -shell "grep -q vbe ${tmpdir}/p2/stdout" -shell "grep -q mempool ${tmpdir}/p2/stdout" -shell -err "grep -q LCK.vbe.destroy ${tmpdir}/p2/stdout" - -shell "cmp -s ${tmpdir}/p1/stdout ${tmpdir}/p2/stdout" - -shell -expect "cache_hit" "varnishstat -1 -n ${v1_name} -f MAIN.cache_hit" diff --git a/bin/varnishtest/tests/u00005.vtc b/bin/varnishtest/tests/u00005.vtc index b331d26..031b79c 100644 --- a/bin/varnishtest/tests/u00005.vtc +++ b/bin/varnishtest/tests/u00005.vtc @@ -7,19 +7,43 @@ server s1 { varnish v1 -vcl+backend {} -start +# On fast systems the next varnishstat will return "inf" counters +# if we don't give varnishd a chance to get going. + +delay 1 + +process p1 {varnishstat -1 -n ${v1_name} -f ^LCK.vbe.destroy \ + -f LCK.vbe.* -f LCK.mempool.* | tr '[1-9]' '0'} -run + +shell "grep -q vbe ${tmpdir}/p1/stdout" +shell "grep -q mempool ${tmpdir}/p1/stdout" +shell -err "grep -q LCK.vbe.destroy ${tmpdir}/p1/stdout" + +process p2 {varnishstat -1 -n ${v1_name} -f ^*vbe.destroy \ + -f *vbe* -f *mempool* | tr '[1-9]' '0'} -run + +shell "grep -q vbe ${tmpdir}/p2/stdout" +shell "grep -q mempool ${tmpdir}/p2/stdout" +shell -err "grep -q LCK.vbe.destroy ${tmpdir}/p2/stdout" + +shell "cmp -s ${tmpdir}/p1/stdout ${tmpdir}/p2/stdout" + +shell -expect "cache_hit" \ + "varnishstat -1 -n ${v1_name} -f MAIN.cache_hit" + shell -expect "Usage: varnishstat " \ - "varnishstat -n ${v1_name} -h" + "varnishstat -h" shell -expect "Varnishstat -f option fields:" \ "varnishstat -n ${v1_name} -l" shell -expect "Copyright (c) 2006 Verdens Gang AS" \ - "varnishstat -n ${v1_name} -V" + "varnishstat -V" +shell -err -expect "Usage: varnishstat " \ + "varnishstat extra" +shell -err -expect "Cannot open /nonexistent/_.vsm" \ + "varnishstat -n /nonexistent" shell -expect "MAIN.uptime" \ "varnishstat -n ${v1_name} -1" shell -expect "MAIN" \ "varnishstat -n ${v1_name} -x" shell -expect "MAIN.uptime\":" \ "varnishstat -n ${v1_name} -j" -shell -err -expect "Usage: varnishstat " \ - "varnishstat -n ${v1_name} extra" -shell -err -expect "Cannot open /nonexistent/_.vsm" \ - "varnishstat -n /nonexistent" diff --git a/bin/varnishtest/tests/u00006.vtc b/bin/varnishtest/tests/u00006.vtc index 8ab806c..60092e9 100644 --- a/bin/varnishtest/tests/u00006.vtc +++ b/bin/varnishtest/tests/u00006.vtc @@ -15,15 +15,29 @@ process p3 { exec varnishlog -n ${v1_name} -g raw -k 1 -w ${tmpdir}/p3/output.bin } -start shell -expect "Usage: varnishlog " \ - "varnishlog -n ${v1_name} -h" + "varnishlog -h" shell -expect "Copyright (c) 2006 Verdens Gang AS" \ - "varnishlog -n ${v1_name} -V" + "varnishlog -V" shell -err -expect "Usage: varnishlog " \ - "varnishlog -n ${v1_name} extra" + "varnishlog extra" shell -err -expect "Missing -w option" \ - "varnishlog -n ${v1_name} -D" + "varnishlog -D" shell -err -expect "-L: Range error" \ - "varnishlog -n ${v1_name} -L 0" + "varnishlog -L 0" +shell -err -expect {-i: "foo" matches zero tags} \ + "varnishlog -i foo" +shell -err -expect {-i: "Resp" is ambiguous} \ + "varnishlog -i Resp" +shell -err -expect {-I: "foo" matches zero tags} \ + "varnishlog -I foo:bar" +shell -err -expect {-I: "Resp" is ambiguous} \ + "varnishlog -I Resp:bar" +shell -err -expect {-I: Regex error at position 4 (missing ))} \ + {varnishlog -I "(foo"} +shell -err -expect {-x: Syntax error in "**"} \ + {varnishlog -x "**"} +shell -err -expect {-X: Syntax error in "**"} \ + {varnishlog -X "**:bar"} process p1 -wait shell {grep -q "0 CLI" ${tmpdir}/p1/stdout} process p2 -wait From dridi.boukelmoune at gmail.com Fri Jan 20 12:28:05 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 20 Jan 2017 13:28:05 +0100 Subject: [master] c132ce2 Introduce more process macros for convenience Message-ID: commit c132ce2477436a5b694b2435994646da49738d3f Author: Dridi Boukelmoune Date: Fri Jan 20 12:49:12 2017 +0100 Introduce more process macros for convenience While at it, kill the `workdir` field that is neither used nor exposed, and wrongfully based on the misleading ${pwd}. The overall documentation also got a refresh, not just the new macros. diff --git a/bin/varnishtest/tests/u00000.vtc b/bin/varnishtest/tests/u00000.vtc index 8684c25..3ed2eaf 100644 --- a/bin/varnishtest/tests/u00000.vtc +++ b/bin/varnishtest/tests/u00000.vtc @@ -24,11 +24,11 @@ process p2 -wait process p3 -wait # check stdout -shell "grep -q foo ${tmpdir}/p1/stdout" -shell "grep -q bar ${tmpdir}/p2/stdout" -shell "grep -q baz ${tmpdir}/p3/stdout" +shell "grep -q foo ${p1_out}" +shell "grep -q bar ${p2_out}" +shell "grep -q baz ${p3_out}" # check stderr -shell "test -f ${tmpdir}/p1/stderr -a ! -s ${tmpdir}/p1/stderr" -shell "test -f ${tmpdir}/p2/stderr -a ! -s ${tmpdir}/p2/stderr" -shell "test -f ${tmpdir}/p3/stderr -a ! -s ${tmpdir}/p3/stderr" +shell "test -f ${p1_err} -a ! -s ${p1_err}" +shell "test -f ${p2_err} -a ! -s ${p2_err}" +shell "test -f ${p3_err} -a ! -s ${p3_err}" diff --git a/bin/varnishtest/tests/u00005.vtc b/bin/varnishtest/tests/u00005.vtc index 031b79c..d80f197 100644 --- a/bin/varnishtest/tests/u00005.vtc +++ b/bin/varnishtest/tests/u00005.vtc @@ -15,18 +15,18 @@ delay 1 process p1 {varnishstat -1 -n ${v1_name} -f ^LCK.vbe.destroy \ -f LCK.vbe.* -f LCK.mempool.* | tr '[1-9]' '0'} -run -shell "grep -q vbe ${tmpdir}/p1/stdout" -shell "grep -q mempool ${tmpdir}/p1/stdout" -shell -err "grep -q LCK.vbe.destroy ${tmpdir}/p1/stdout" +shell "grep -q vbe ${p1_out}" +shell "grep -q mempool ${p1_out}" +shell -err "grep -q LCK.vbe.destroy ${p1_out}" process p2 {varnishstat -1 -n ${v1_name} -f ^*vbe.destroy \ -f *vbe* -f *mempool* | tr '[1-9]' '0'} -run -shell "grep -q vbe ${tmpdir}/p2/stdout" -shell "grep -q mempool ${tmpdir}/p2/stdout" -shell -err "grep -q LCK.vbe.destroy ${tmpdir}/p2/stdout" +shell "grep -q vbe ${p2_out}" +shell "grep -q mempool ${p2_out}" +shell -err "grep -q LCK.vbe.destroy ${p2_out}" -shell "cmp -s ${tmpdir}/p1/stdout ${tmpdir}/p2/stdout" +shell "cmp -s ${p1_out} ${p2_out}" shell -expect "cache_hit" \ "varnishstat -1 -n ${v1_name} -f MAIN.cache_hit" diff --git a/bin/varnishtest/tests/u00006.vtc b/bin/varnishtest/tests/u00006.vtc index 60092e9..5721a2b 100644 --- a/bin/varnishtest/tests/u00006.vtc +++ b/bin/varnishtest/tests/u00006.vtc @@ -39,8 +39,8 @@ shell -err -expect {-x: Syntax error in "**"} \ shell -err -expect {-X: Syntax error in "**"} \ {varnishlog -X "**:bar"} process p1 -wait -shell {grep -q "0 CLI" ${tmpdir}/p1/stdout} +shell {grep -q "0 CLI" ${p1_out}} process p2 -wait -shell {grep -q "0 CLI" ${tmpdir}/p2/output} +shell {grep -q "0 CLI" ${p2_dir}/output} process p3 -wait -shell -expect "0 CLI" {varnishlog -g raw -r ${tmpdir}/p3/output.bin} +shell -expect "0 CLI" {varnishlog -g raw -r ${p3_dir}/output.bin} diff --git a/bin/varnishtest/vtc.c b/bin/varnishtest/vtc.c index e0d2744..831ad0b 100644 --- a/bin/varnishtest/vtc.c +++ b/bin/varnishtest/vtc.c @@ -439,20 +439,21 @@ cmd_varnishtest(CMD_ARGS) * echo end * } * - * By default a zero exit code is expected. + * By default a zero exit code is expected, otherwise the vtc will fail. * * Notice that the commandstring is prefixed with "exec 2>&1;" to join * stderr and stdout back to the varnishtest process. * * Optional arguments: * - * -err - expect non-zero exit code + * \-err + * Expect non-zero exit code. * - * -exit N - expect exit code N + * \-exit N + * Expect exit code N instead of zero. * - * -expect string - expect str to be found in stdout+err - * - * The vtc will fail if the return code of the shell is not 0. + * \-expect string + * Expect str to be found in stdout+err. */ /* SECTION: client-server.spec.shell shell * diff --git a/bin/varnishtest/vtc_process.c b/bin/varnishtest/vtc_process.c index f8209ff..6cac10f 100644 --- a/bin/varnishtest/vtc_process.c +++ b/bin/varnishtest/vtc_process.c @@ -53,8 +53,7 @@ struct process { VTAILQ_ENTRY(process) list; char *spec; - char *workdir; - char *outdir; + char *dir; char *out; char *err; int fd_to; @@ -101,13 +100,12 @@ process_new(const char *name) p->vl = vtc_logopen(name); AN(p->vl); - PROCESS_EXPAND(workdir, "%s", "${pwd}"); - PROCESS_EXPAND(outdir, "${tmpdir}/%s", name); + PROCESS_EXPAND(dir, "${tmpdir}/%s", name); PROCESS_EXPAND(out, "${tmpdir}/%s/stdout", name); PROCESS_EXPAND(err, "${tmpdir}/%s/stderr", name); bprintf(buf, "rm -rf %s ; mkdir -p %s ; touch %s %s", - p->outdir, p->outdir, p->out, p->err); + p->dir, p->dir, p->out, p->err); AZ(system(buf)); p->fd_to = -1; @@ -134,20 +132,30 @@ process_delete(struct process *p) AZ(pthread_mutex_destroy(&p->mtx)); vtc_logclose(p->vl); free(p->name); - free(p->workdir); - free(p->outdir); + free(p->dir); free(p->out); free(p->err); /* - * We do not delete the outdir, it may contain useful stdout - * and stderr files. + * We do not delete the directory, it may contain useful stdout + * and stderr files. They will be deleted on account of belonging + * to the test's tmpdir. */ /* XXX: MEMLEAK (?) */ FREE_OBJ(p); } +static void +process_undef(struct process *p) +{ + CHECK_OBJ_NOTNULL(p, PROCESS_MAGIC); + + macro_undef(p->vl, p->name, "dir"); + macro_undef(p->vl, p->name, "out"); + macro_undef(p->vl, p->name, "err"); +} + /********************************************************************** * Start the process thread */ @@ -184,6 +192,7 @@ process_thread(void *priv) if (p->fd_to >= 0) closefd(&p->fd_to); + /* NB: We keep the other macros around */ macro_undef(p->vl, p->name, "pid"); p->pid = -1; @@ -251,6 +260,9 @@ process_start(struct process *p) } vtc_log(p->vl, 3, "PID: %ld", (long)p->pid); macro_def(p->vl, p->name, "pid", "%ld", (long)p->pid); + macro_def(p->vl, p->name, "dir", "%s", p->dir); + macro_def(p->vl, p->name, "out", "%s", p->out); + macro_def(p->vl, p->name, "err", "%s", p->err); closefd(&fds[0]); p->fd_to = fds[1]; if (p->log) { @@ -372,9 +384,9 @@ process_close(struct process *p) /* SECTION: process process * * Run a process in the background with stdout and stderr redirected to - * ${tmpdir}/pNAME/stdout and ${tmpdir}/pNAME/stderr, respectively:: + * ${pNAME_out} and ${pNAME_err}, both located in ${pNAME_dir}:: * - * process pNAME SPEC [-start] [-log] [-wait] [-run] [-kill STRING] \ + * process pNAME SPEC [-log] [-start] [-wait] [-run] [-kill STRING] \ * [-stop] [-write STRING] [-writeln STRING] [-close] * * pNAME @@ -383,24 +395,45 @@ process_close(struct process *p) * SPEC * The command(s) to run in this process. * - * \-start - * Start the process. - * * \-log * Log stdout/stderr with vtc_dump() (must be before -start/-run) * + * \-start + * Start the process. + * * \-wait * Wait for the process to finish. * * \-run * Shorthand for -start -wait. * + * In most cases, if you just want to start a process and wait for it + * to finish, you can use the varnishtest ``shell`` command instead. + * The following commands are equivalent:: + * + * shell "do --something" + * + * process p1 "do --something" -run + * + * However, you may use the the ``process`` variant to conveniently + * collect the standard input and output without dealing with shell + * redirections yourself. The ``shell`` command can also expect an + * expression from either output, consider using it if you only need + * to match one. + * * \-kill STRING * Send a signal to the process. The argument can be either * the string "TERM", "INT", or "KILL" for SIGTERM, SIGINT or SIGKILL * signals, respectively, or a hyphen (-) followed by the signal * number. * + * If you need to use other signals, you can use the ``kill``\(1) command + * directly:: + * + * shell "kill -USR1 ${pNAME_pid}" + * + * Note that SIGHUP usage is discouraged in test cases. + * * \-stop * Shorthand for -kill TERM. * @@ -432,6 +465,7 @@ cmd_process(CMD_ARGS) if (p->hasthread) process_wait(p); VTAILQ_REMOVE(&processes, p, list); + process_undef(p); process_delete(p); } return; From dridi.boukelmoune at gmail.com Fri Jan 20 15:21:04 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 20 Jan 2017 16:21:04 +0100 Subject: [master] 4908ac9 Retire err_shell where it was recently introduced Message-ID: commit 4908ac9f6f462ed98b73d0236eb2ce28f1ef16e8 Author: Dridi Boukelmoune Date: Fri Jan 20 16:17:13 2017 +0100 Retire err_shell where it was recently introduced Not part of a release, so not using a deprecation message. diff --git a/bin/varnishtest/vtc.c b/bin/varnishtest/vtc.c index 831ad0b..8f29889 100644 --- a/bin/varnishtest/vtc.c +++ b/bin/varnishtest/vtc.c @@ -546,10 +546,6 @@ cmd_shell(CMD_ARGS) * err_shell expect the shell command to fail AND stdout to match the string, * failing the test case otherwise. */ -/* SECTION: client-server.spec.shell err_shell - * - * Same as for the top-level err_shell. - */ void cmd_err_shell(CMD_ARGS) diff --git a/bin/varnishtest/vtc_http.c b/bin/varnishtest/vtc_http.c index 7c0d36b..f7f61a5 100644 --- a/bin/varnishtest/vtc_http.c +++ b/bin/varnishtest/vtc_http.c @@ -1799,9 +1799,9 @@ cmd_http_stream(CMD_ARGS) * * write_body STRING * Write the body of a request or a response to a file. By using the - * shell or err_shell commands, higher-level checks on the body can - * be performed (eg. XML, JSON, ...) provided that such checks can be - * delegated to an external program. + * shell command, higher-level checks on the body can be performed + * (eg. XML, JSON, ...) provided that such checks can be delegated + * to an external program. */ static void cmd_http_write_body(CMD_ARGS) @@ -1878,7 +1878,6 @@ static const struct cmds http_cmds[] = { /* general purpose */ CMD(barrier) CMD(delay) - CMD(err_shell) CMD(shell) #undef CMD_HTTP #undef CMD diff --git a/bin/varnishtest/vtc_http2.c b/bin/varnishtest/vtc_http2.c index da9e540..12a84f3 100644 --- a/bin/varnishtest/vtc_http2.c +++ b/bin/varnishtest/vtc_http2.c @@ -2528,9 +2528,8 @@ static const struct cmds stream_cmds[] = { /* general purpose */ CMD(barrier) CMD(delay) - CMD(err_shell) CMD(shell) - { NULL, NULL } + { NULL, NULL } #undef CMD_STREAM #undef CMD }; From phk at FreeBSD.org Fri Jan 20 19:59:04 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 20 Jan 2017 20:59:04 +0100 Subject: [master] ab72ccd It's more useful to emit the shell's stdout/stderr before failing the exit code test, than not doing so afterwards. Message-ID: commit ab72ccd7eade8f9c178fe397cee63d8b24679a04 Author: Poul-Henning Kamp Date: Fri Jan 20 19:57:19 2017 +0000 It's more useful to emit the shell's stdout/stderr before failing the exit code test, than not doing so afterwards. diff --git a/bin/varnishtest/vtc.c b/bin/varnishtest/vtc.c index 8f29889..a5d51ac 100644 --- a/bin/varnishtest/vtc.c +++ b/bin/varnishtest/vtc.c @@ -485,6 +485,8 @@ cmd_shell_engine(struct vtclog *vl, int ok, VSB_putc(vsb, c); } while (c != EOF); r = pclose(fp); + AZ(VSB_finish(vsb)); + vtc_dump(vl, 4, "shell_out", VSB_data(vsb), VSB_len(vsb)); vtc_log(vl, 4, "shell_status = 0x%04x", WEXITSTATUS(r)); if (WIFSIGNALED(r)) vtc_log(vl, 4, "shell_signal = %d", WTERMSIG(r)); @@ -495,8 +497,6 @@ cmd_shell_engine(struct vtclog *vl, int ok, "shell_exit not as expected: got 0x%04x wanted 0x%04x", WEXITSTATUS(r), ok); } - AZ(VSB_finish(vsb)); - vtc_dump(vl, 4, "shell_out", VSB_data(vsb), VSB_len(vsb)); if (expect != NULL) { if (strstr(VSB_data(vsb), expect) == NULL) vtc_fatal(vl, From phk at FreeBSD.org Fri Jan 20 19:59:04 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 20 Jan 2017 20:59:04 +0100 Subject: [master] ff65c2f Test the fail/skip exit codes of varnishtest Message-ID: commit ff65c2f4e5585e6ac3506ccc97165552c32e28e4 Author: Poul-Henning Kamp Date: Fri Jan 20 19:57:59 2017 +0000 Test the fail/skip exit codes of varnishtest diff --git a/bin/varnishtest/tests/a00000.vtc b/bin/varnishtest/tests/a00000.vtc index 8c3c17c..2fc2b9f 100644 --- a/bin/varnishtest/tests/a00000.vtc +++ b/bin/varnishtest/tests/a00000.vtc @@ -25,3 +25,17 @@ shell -expect {__=barf} { echo __=`cat __` } +# Test a test failure +shell -exit 2 -expect {TEST _.vtc FAILED} { + echo varnishtest foo > _.vtc + echo 'shell {false}' >> _.vtc + exec varnishtest -v _.vtc || true +} + +# Test a test skip +shell -exit 77 -expect {TEST _.vtc skipped} { + echo varnishtest foo > _.vtc + echo 'feature cmd false' >> _.vtc + exec varnishtest -v _.vtc || true +} + From fgsch at lodoss.net Fri Jan 20 21:41:05 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Fri, 20 Jan 2017 22:41:05 +0100 Subject: [master] 44ab999 Merge, simplify and add more coverage Message-ID: commit 44ab9990d0ce1bc01cb38ea9d8f171ef972fec75 Author: Federico G. Schwindt Date: Fri Jan 20 20:31:30 2017 +0000 Merge, simplify and add more coverage diff --git a/bin/varnishtest/tests/u00001.vtc b/bin/varnishtest/tests/u00001.vtc deleted file mode 100644 index b06a315..0000000 --- a/bin/varnishtest/tests/u00001.vtc +++ /dev/null @@ -1,43 +0,0 @@ -varnishtest "varnishncsa log file rotation" - -server s1 { - rxreq - expect req.url == "/foo" - txresp -status 200 - - rxreq - expect req.url == "/bar" - txresp -status 404 -} -start - -varnish v1 -vcl+backend "" -start - -shell "varnishncsa -D -P ${tmpdir}/ncsa.pid -n ${v1_name} -w ${tmpdir}/ncsa.log -F %s" - -# give varnishncsa enough time to open the VSM -delay 2 - -client c1 { - txreq -url "/foo" - rxresp -} -run - -# give varnishncsa enough time to write -delay 2 - -# rotate logs -shell "mv ${tmpdir}/ncsa.log ${tmpdir}/ncsa.old.log >/dev/null 2>&1" -shell "kill -HUP `cat ${tmpdir}/ncsa.pid`" - -client c1 { - txreq -url "/bar" - rxresp -} -run - -# give varnishncsa enough time to write -delay 2 - -shell "kill `cat ${tmpdir}/ncsa.pid`" - -shell "grep 200 ${tmpdir}/ncsa.old.log >/dev/null" -shell "grep 404 ${tmpdir}/ncsa.log >/dev/null" diff --git a/bin/varnishtest/tests/u00003.vtc b/bin/varnishtest/tests/u00003.vtc index 6737762..4b7eba2 100644 --- a/bin/varnishtest/tests/u00003.vtc +++ b/bin/varnishtest/tests/u00003.vtc @@ -1,35 +1,71 @@ -varnishtest "varnishncsa error handling" +varnishtest "varnishncsa coverage" -server s1 { +server s1 -repeat 2 { rxreq txresp } -start varnish v1 -vcl+backend {} -start +shell "varnishncsa -n ${v1_name} -D -P ${tmpdir}/ncsa.pid -w ${tmpdir}/ncsa.log" + shell -err -expect "Missing -w option" \ - {varnishncsa -n ${v1_name} -D} + {varnishncsa -D} shell -err -expect "Unknown format specifier at: %{foo}A" \ - {varnishncsa -n ${v1_name} -F "%{foo}A"} + {varnishncsa -F "%{foo}A"} shell -err -expect "Unknown format specifier at: %A" \ - {varnishncsa -n ${v1_name} -F "%A"} + {varnishncsa -F "%A"} +shell -err -expect "Unknown formatting extension: foo" \ + {varnishncsa -F "%{foo}x"} shell -err -expect "Usage: varnishncsa " \ - {varnishncsa -n ${v1_name} extra} + {varnishncsa extra} shell -err -expect "Missing tag in VSL:" \ - {varnishncsa -n ${v1_name} -F "%{VSL:}x"} + {varnishncsa -F "%{VSL:}x"} shell -err -expect "Unknown log tag: nonexistent" \ - {varnishncsa -n ${v1_name} -F "%{VSL:nonexistent}x"} + {varnishncsa -F "%{VSL:nonexistent}x"} shell -err -expect "Tag not unique: Req" \ - {varnishncsa -n ${v1_name} -F "%{VSL:Req}x"} + {varnishncsa -F "%{VSL:Req}x"} shell -err -expect "Unknown log tag: Begin[" \ - {varnishncsa -n ${v1_name} -F "%{VSL:Begin[}x"} + {varnishncsa -F "%{VSL:Begin[}x"} shell -err -expect "Syntax error: VSL:Begin]" \ - {varnishncsa -n ${v1_name} -F "%{VSL:Begin]}x"} + {varnishncsa -F "%{VSL:Begin]}x"} shell -err -expect "Unknown log tag: Begin[a" \ - {varnishncsa -n ${v1_name} -F "%{VSL:Begin[a}x"} + {varnishncsa -F "%{VSL:Begin[a}x"} shell -err -expect "Syntax error: VSL:Begin[a]" \ - {varnishncsa -n ${v1_name} -F "%{VSL:Begin[a]}x"} + {varnishncsa -F "%{VSL:Begin[a]}x"} shell -err -expect "Syntax error. Field specifier must be positive: Begin[0]" \ - {varnishncsa -n ${v1_name} -F "%{VSL:Begin[0]}x"} + {varnishncsa -F "%{VSL:Begin[0]}x"} shell -err -expect "Field specifier 999999999999 for the tag VSL:Begin[999999999999] is probably too high" \ - {varnishncsa -n ${v1_name} -F "%{VSL:Begin[999999999999]}x"} + {varnishncsa -F "%{VSL:Begin[999999999999]}x"} +shell -err -expect "Can't open format file (No such file or directory)" \ + {varnishncsa -n ${v1_name} -f /nonexistent} +shell -err -expect "Empty format file" \ + {varnishncsa -n ${v1_name} -f /dev/null} + +delay 1 + +client c1 { + txreq -url /foo + rxresp +} -run + +delay 1 + +shell "mv ${tmpdir}/ncsa.log ${tmpdir}/ncsa.old.log >/dev/null 2>&1" +shell "kill -HUP `cat ${tmpdir}/ncsa.pid`" + +client c1 { + txreq -url /bar + rxresp +} -run + +delay 1 + +shell "kill `cat ${tmpdir}/ncsa.pid`" + +shell "grep -q /foo ${tmpdir}/ncsa.old.log" +shell "grep -q /bar ${tmpdir}/ncsa.log" + +shell {echo "%{VSL:Begin}x %{Varnish:vxid}x %D %T %{Varnish:handling}x %{%Z}t" >${tmpdir}/format} +shell -expect "0 miss GMT" \ + {varnishncsa -n ${v1_name} -d -f ${tmpdir}/format} diff --git a/bin/varnishtest/tests/u00006.vtc b/bin/varnishtest/tests/u00006.vtc index 5721a2b..8b2861a 100644 --- a/bin/varnishtest/tests/u00006.vtc +++ b/bin/varnishtest/tests/u00006.vtc @@ -1,19 +1,20 @@ varnishtest "varnishlog coverage" -server s1 { +server s1 -repeat 2 { rxreq txresp } -start varnish v1 -vcl+backend {} -start -process p1 "exec varnishlog -n ${v1_name} -g raw -k 1" -start -process p2 { - exec varnishlog -n ${v1_name} -g raw -k 1 -w ${tmpdir}/p2/output -A -} -start -process p3 { - exec varnishlog -n ${v1_name} -g raw -k 1 -w ${tmpdir}/p3/output.bin +process p1 { + exec varnishlog -n ${v1_name} -g raw -k 3 -w ${tmpdir}/vlog -A } -start +shell { + exec varnishlog -n ${v1_name} -D -P ${tmpdir}/vlog.pid \ + -w ${tmpdir}/vlog.bin +} + shell -expect "Usage: varnishlog " \ "varnishlog -h" shell -expect "Copyright (c) 2006 Verdens Gang AS" \ @@ -38,9 +39,31 @@ shell -err -expect {-x: Syntax error in "**"} \ {varnishlog -x "**"} shell -err -expect {-X: Syntax error in "**"} \ {varnishlog -X "**:bar"} + process p1 -wait -shell {grep -q "0 CLI" ${p1_out}} -process p2 -wait -shell {grep -q "0 CLI" ${p2_dir}/output} -process p3 -wait -shell -expect "0 CLI" {varnishlog -g raw -r ${p3_dir}/output.bin} +shell {grep -q "0 CLI" ${tmpdir}/vlog} +shell -expect "0 CLI" "varnishlog -n ${v1_name} -d -g raw" + +client c1 { + txreq -url /foo + rxresp +} -run + +delay 1 + +shell "mv ${tmpdir}/vlog.bin ${tmpdir}/vlog.bin~ >/dev/null 2>&1" +shell "kill -HUP `cat ${tmpdir}/vlog.pid`" + +client c1 { + txreq -url /bar + rxresp +} -run + +delay 1 + +shell "kill `cat ${tmpdir}/vlog.pid`" + +shell -expect "/foo" { + varnishlog -r ${tmpdir}/vlog.bin~ -i ReqURL -q "RespStatus == 200" +} +shell -expect "/bar" "varnishlog -r ${tmpdir}/vlog.bin -x ReqURL" diff --git a/bin/varnishtest/tests/u00007.vtc b/bin/varnishtest/tests/u00007.vtc index 444c07c..b1bd0a2 100644 --- a/bin/varnishtest/tests/u00007.vtc +++ b/bin/varnishtest/tests/u00007.vtc @@ -8,20 +8,20 @@ server s1 { varnish v1 -vcl+backend {} -start shell -expect "Usage: varnishhist " \ - "varnishhist -n ${v1_name} -h" + "varnishhist -h" shell -err -expect "Usage: varnishhist " \ - "varnishhist -n ${v1_name} extra" + "varnishhist extra" shell -err -expect "-p: invalid '0'" \ - "varnishhist -n ${v1_name} -p 0" + "varnishhist -p 0" shell -err -expect "-B: being able to bend time does not mean we can stop it" \ - "varnishhist -n ${v1_name} -B 0" + "varnishhist -B 0" shell -err -expect "-B: being able to bend time does not mean we can make it go backwards" \ - "varnishhist -n ${v1_name} -B -1" + "varnishhist -B -1" shell -err -expect "Invalid grouping mode: raw" \ - "varnishhist -n ${v1_name} -g raw" + "varnishhist -g raw" shell -err -expect "-P: No such profile 'foo'" \ - "varnishhist -n ${v1_name} -P foo" + "varnishhist -P foo" shell -err -expect "-P: 'foo:bar' is not a valid profile name or definition" \ - "varnishhist -n ${v1_name} -P foo:bar" + "varnishhist -P foo:bar" shell -err -expect "-P: 'foo:0:0:0' is not a valid tag name" \ - "varnishhist -n ${v1_name} -P foo:0:0:0" + "varnishhist -P foo:0:0:0" From fgsch at lodoss.net Fri Jan 20 22:15:04 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Fri, 20 Jan 2017 23:15:04 +0100 Subject: [master] 318ad63 Fix previous and add another case Message-ID: commit 318ad63b4f4a49d4e96179ef1bd966391e3638e2 Author: Federico G. Schwindt Date: Fri Jan 20 22:10:04 2017 +0000 Fix previous and add another case diff --git a/bin/varnishtest/tests/u00003.vtc b/bin/varnishtest/tests/u00003.vtc index 4b7eba2..77b09dd 100644 --- a/bin/varnishtest/tests/u00003.vtc +++ b/bin/varnishtest/tests/u00003.vtc @@ -38,9 +38,11 @@ shell -err -expect "Syntax error. Field specifier must be positive: Begin[0]" \ shell -err -expect "Field specifier 999999999999 for the tag VSL:Begin[999999999999] is probably too high" \ {varnishncsa -F "%{VSL:Begin[999999999999]}x"} shell -err -expect "Can't open format file (No such file or directory)" \ - {varnishncsa -n ${v1_name} -f /nonexistent} + {varnishncsa -f /nonexistent/file} shell -err -expect "Empty format file" \ - {varnishncsa -n ${v1_name} -f /dev/null} + {varnishncsa -f /dev/null} +shell -err -expect "Can't read format from file (Is a directory)" \ + {varnishncsa -f ${tmpdir}} delay 1 @@ -67,5 +69,5 @@ shell "grep -q /foo ${tmpdir}/ncsa.old.log" shell "grep -q /bar ${tmpdir}/ncsa.log" shell {echo "%{VSL:Begin}x %{Varnish:vxid}x %D %T %{Varnish:handling}x %{%Z}t" >${tmpdir}/format} -shell -expect "0 miss GMT" \ +shell -expect "0 miss" \ {varnishncsa -n ${v1_name} -d -f ${tmpdir}/format} From fgsch at lodoss.net Fri Jan 20 23:41:05 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sat, 21 Jan 2017 00:41:05 +0100 Subject: [master] 0c8f02f This does not fail in FreeBSD Message-ID: commit 0c8f02f7a20bcc0172fd1161c3ea712dc1e5872a Author: Federico G. Schwindt Date: Fri Jan 20 23:33:42 2017 +0000 This does not fail in FreeBSD Comment it out for now and add a note for future reference. diff --git a/bin/varnishtest/tests/u00003.vtc b/bin/varnishtest/tests/u00003.vtc index 77b09dd..bb47954 100644 --- a/bin/varnishtest/tests/u00003.vtc +++ b/bin/varnishtest/tests/u00003.vtc @@ -41,8 +41,10 @@ shell -err -expect "Can't open format file (No such file or directory)" \ {varnishncsa -f /nonexistent/file} shell -err -expect "Empty format file" \ {varnishncsa -f /dev/null} -shell -err -expect "Can't read format from file (Is a directory)" \ - {varnishncsa -f ${tmpdir}} +# In Linux and SunOS, getline(3) fails when the stream refers to a +# directory but happily works in FreeBSD. +#shell -err -expect "Can't read format from file (Is a directory)" \ +# {varnishncsa -f ${tmpdir}} delay 1 From fgsch at lodoss.net Sat Jan 21 13:48:05 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sat, 21 Jan 2017 14:48:05 +0100 Subject: [master] ef0fa4e Polish Message-ID: commit ef0fa4e853f945c55ffaee9b35dd274aea0bb983 Author: Federico G. Schwindt Date: Sat Jan 21 01:24:24 2017 +0000 Polish diff --git a/bin/varnishtest/vtc_process.c b/bin/varnishtest/vtc_process.c index 6cac10f..dc968a1 100644 --- a/bin/varnishtest/vtc_process.c +++ b/bin/varnishtest/vtc_process.c @@ -228,7 +228,7 @@ process_start(struct process *p) CHECK_OBJ_NOTNULL(p, PROCESS_MAGIC); if (p->hasthread) - vtc_fatal(p->vl, "Already running, (-wait first)"); + vtc_fatal(p->vl, "Already running, -wait first"); vtc_log(p->vl, 4, "CMD: %s", p->spec); @@ -255,7 +255,8 @@ process_start(struct process *p) assert(dup2(err_fd, 2) == 2); VSUB_closefrom(STDERR_FILENO + 1); AZ(setpgid(0, 0)); - AZ(execl("/bin/sh", "/bin/sh", "-c", VSB_data(cl), (char*)0)); + AZ(execl("/bin/sh", "/bin/sh", "-c", VSB_data(cl), + (char *)NULL)); exit(1); } vtc_log(p->vl, 3, "PID: %ld", (long)p->pid); @@ -338,16 +339,6 @@ process_kill(struct process *p, const char *sig) vtc_log(p->vl, 4, "Sent signal %d", j); } -static inline void -process_terminate(struct process *p) -{ - - process_kill(p, "TERM"); - sleep(1); - if (p->pid > 0) - process_kill(p, "KILL"); -} - /********************************************************************** * Write to a process' stdin */ @@ -373,7 +364,7 @@ process_close(struct process *p) { if (!p->hasthread) - vtc_fatal(p->vl, "Cannot close on a non-running process"); + vtc_fatal(p->vl, "Cannot close a non-running process"); AZ(pthread_mutex_lock(&p->mtx)); if (p->fd_to >= 0) @@ -396,7 +387,7 @@ process_close(struct process *p) * The command(s) to run in this process. * * \-log - * Log stdout/stderr with vtc_dump() (must be before -start/-run) + * Log stdout/stderr with vtc_dump(). Must be before -start/-run. * * \-start * Start the process. @@ -427,8 +418,8 @@ process_close(struct process *p) * signals, respectively, or a hyphen (-) followed by the signal * number. * - * If you need to use other signals, you can use the ``kill``\(1) command - * directly:: + * If you need to use other signal names, you can use the ``kill``\(1) + * command directly:: * * shell "kill -USR1 ${pNAME_pid}" * @@ -460,8 +451,12 @@ cmd_process(CMD_ARGS) if (av == NULL) { /* Reset and free */ VTAILQ_FOREACH_SAFE(p, &processes, list, p2) { - if (p->pid > 0) - process_terminate(p); + if (p->pid > 0) { + process_kill(p, "TERM"); + sleep(1); + if (p->pid > 0) + process_kill(p, "KILL"); + } if (p->hasthread) process_wait(p); VTAILQ_REMOVE(&processes, p, list); @@ -490,6 +485,9 @@ cmd_process(CMD_ARGS) continue; } if (!strcmp(*av, "-log")) { + if (p->hasthread) + vtc_fatal(p->vl, + "Cannot log a running process"); p->log = 1; continue; } @@ -526,7 +524,8 @@ cmd_process(CMD_ARGS) continue; } if (**av == '-') - vtc_fatal(p->vl, "Unknown process argument: %s", *av); + vtc_fatal(p->vl, "Unknown process argument: %s", + *av); REPLACE(p->spec, *av); } } From fgsch at lodoss.net Sat Jan 21 13:48:05 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sat, 21 Jan 2017 14:48:05 +0100 Subject: [master] 60f868e GC unused variable Message-ID: commit 60f868e7cf4e61642bede22c6c65a571bd19cd60 Author: Federico G. Schwindt Date: Sat Jan 21 13:47:01 2017 +0000 GC unused variable diff --git a/lib/libvarnishapi/daemon.c b/lib/libvarnishapi/daemon.c index aba6433..55fc613 100644 --- a/lib/libvarnishapi/daemon.c +++ b/lib/libvarnishapi/daemon.c @@ -45,7 +45,6 @@ int varnish_daemon(int nochdir, int noclose) { struct sigaction osa, sa; - int fd; pid_t newgrp; int oerrno; int osa_ok; From fgsch at lodoss.net Sat Jan 21 20:58:04 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sat, 21 Jan 2017 21:58:04 +0100 Subject: [master] d9c3cdd Fix build when daemon() is not available Message-ID: commit d9c3cddae1b4b5ec15935500f824f9d90d411c5f Author: Federico G. Schwindt Date: Sat Jan 21 19:08:02 2017 +0000 Fix build when daemon() is not available diff --git a/lib/libvarnishapi/daemon.c b/lib/libvarnishapi/daemon.c index 55fc613..93e3bef 100644 --- a/lib/libvarnishapi/daemon.c +++ b/lib/libvarnishapi/daemon.c @@ -39,7 +39,24 @@ #include #include "compat/daemon.h" -#include "vfil.h" +#include "vas.h" + +/* + * Copied from libvarnish/vfil.c to avoid pulling libvarnish or vfil.c + * directly when daemon() is not working/available (i.e. OSX). + * + */ +static void +vfil_null_fd(int target) +{ + int fd; + + assert(target >= 0); + fd = open("/dev/null", O_RDWR); + assert(fd >= 0); + assert(dup2(fd, target) == target); + AZ(close(fd)); +} int varnish_daemon(int nochdir, int noclose) @@ -82,9 +99,9 @@ varnish_daemon(int nochdir, int noclose) (void)chdir("/"); if (!noclose) { - VFIL_null_fd(STDIN_FILENO); - VFIL_null_fd(STDOUT_FILENO); - VFIL_null_fd(STDERR_FILENO); + vfil_null_fd(STDIN_FILENO); + vfil_null_fd(STDOUT_FILENO); + vfil_null_fd(STDERR_FILENO); } return (0); } From fgsch at lodoss.net Sat Jan 21 21:36:05 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sat, 21 Jan 2017 22:36:05 +0100 Subject: [master] 2f5ac24 Add regexp matching support to the shell command Message-ID: commit 2f5ac240ab3cf82d292f17d4b4b009f713c32929 Author: Federico G. Schwindt Date: Sat Jan 21 21:22:02 2017 +0000 Add regexp matching support to the shell command Change some tests to use the new parameter and more coverage. diff --git a/bin/varnishtest/tests/u00003.vtc b/bin/varnishtest/tests/u00003.vtc index bb47954..6369e45 100644 --- a/bin/varnishtest/tests/u00003.vtc +++ b/bin/varnishtest/tests/u00003.vtc @@ -9,6 +9,10 @@ varnish v1 -vcl+backend {} -start shell "varnishncsa -n ${v1_name} -D -P ${tmpdir}/ncsa.pid -w ${tmpdir}/ncsa.log" +shell -expect "Usage: varnishncsa " \ + "varnishncsa -h" +shell -expect "Copyright (c) 2006 Verdens Gang AS" \ + "varnishncsa -V" shell -err -expect "Missing -w option" \ {varnishncsa -D} shell -err -expect "Unknown format specifier at: %{foo}A" \ @@ -71,5 +75,5 @@ shell "grep -q /foo ${tmpdir}/ncsa.old.log" shell "grep -q /bar ${tmpdir}/ncsa.log" shell {echo "%{VSL:Begin}x %{Varnish:vxid}x %D %T %{Varnish:handling}x %{%Z}t" >${tmpdir}/format} -shell -expect "0 miss" \ +shell -match "req 1000 rxreq 1001 [0-9]{5} 0 miss [A-Z]{3,}" \ {varnishncsa -n ${v1_name} -d -f ${tmpdir}/format} diff --git a/bin/varnishtest/tests/u00006.vtc b/bin/varnishtest/tests/u00006.vtc index 8b2861a..cda5d73 100644 --- a/bin/varnishtest/tests/u00006.vtc +++ b/bin/varnishtest/tests/u00006.vtc @@ -42,7 +42,8 @@ shell -err -expect {-X: Syntax error in "**"} \ process p1 -wait shell {grep -q "0 CLI" ${tmpdir}/vlog} -shell -expect "0 CLI" "varnishlog -n ${v1_name} -d -g raw" +shell -match "0 CLI[ ]+- Wr 200 [0-9]+ PONG" \ + {varnishlog -n ${v1_name} -d -g raw -X "Wr 200 [0-9]+ [^P]"} client c1 { txreq -url /foo @@ -63,7 +64,10 @@ delay 1 shell "kill `cat ${tmpdir}/vlog.pid`" -shell -expect "/foo" { - varnishlog -r ${tmpdir}/vlog.bin~ -i ReqURL -q "RespStatus == 200" +shell -match {^\*[ ]+<< Request\s+>>[ ]+1001[ ]+ +-[ ]+1001 ReqURL[ ]+c /foo +$} { + varnishlog -v -r ${tmpdir}/vlog.bin~ -i ReqURL -q "RespStatus == 200" } -shell -expect "/bar" "varnishlog -r ${tmpdir}/vlog.bin -x ReqURL" +shell -match "-[ ]+BereqURL[ ]+/bar" \ + "varnishlog -r ${tmpdir}/vlog.bin -x ReqURL" diff --git a/bin/varnishtest/vtc.c b/bin/varnishtest/vtc.c index a5d51ac..597e0c3 100644 --- a/bin/varnishtest/vtc.c +++ b/bin/varnishtest/vtc.c @@ -430,8 +430,9 @@ cmd_varnishtest(CMD_ARGS) /* SECTION: shell shell * - * Pass the string given as argument to a shell. If you have multiple commands - * to run, you can use curly barces to describe a multi-lines script, eg:: + * Pass the string given as argument to a shell. If you have multiple + * commands to run, you can use curly barces to describe a multi-lines + * script, eg:: * * shell { * echo begin @@ -452,8 +453,11 @@ cmd_varnishtest(CMD_ARGS) * \-exit N * Expect exit code N instead of zero. * - * \-expect string - * Expect str to be found in stdout+err. + * \-expect STRING + * Expect string to be found in stdout+err. + * + * \-match REGEXP + * Expect regexp to match the stdout+err output. */ /* SECTION: client-server.spec.shell shell * @@ -461,17 +465,26 @@ cmd_varnishtest(CMD_ARGS) */ static void -cmd_shell_engine(struct vtclog *vl, int ok, - const char *cmd, const char *expect) +cmd_shell_engine(struct vtclog *vl, int ok, const char *cmd, + const char *expect, const char *re) { struct vsb *vsb; FILE *fp; + vre_t *vre = NULL; + const char *errptr; int r, c; + int err; AN(vl); AN(cmd); vsb = VSB_new_auto(); AN(vsb); + if (re != NULL) { + vre = VRE_compile(re, 0, &errptr, &err); + if (vre == NULL) + vtc_fatal(vl, "shell_match invalid regexp (\"%s\")", + re); + } VSB_printf(vsb, "exec 2>&1 ; %s", cmd); AZ(VSB_finish(vsb)); vtc_dump(vl, 4, "shell_cmd", VSB_data(vsb), -1); @@ -503,6 +516,14 @@ cmd_shell_engine(struct vtclog *vl, int ok, "shell_expect not found: (\"%s\")", expect); else vtc_log(vl, 4, "shell_expect found"); + } else if (vre != NULL) { + if (VRE_exec(vre, VSB_data(vsb), VSB_len(vsb), 0, 0, + NULL, 0, NULL) < 1) + vtc_fatal(vl, + "shell_match failed: (\"%s\")", re); + else + vtc_log(vl, 4, "shell_match succeeded"); + VRE_free(&vre); } VSB_destroy(&vsb); } @@ -511,11 +532,13 @@ cmd_shell_engine(struct vtclog *vl, int ok, void cmd_shell(CMD_ARGS) { - (void)priv; - (void)cmd; + const char *expect = NULL; + const char *re = NULL; int n; int ok = 0; - const char *expect = NULL; + + (void)priv; + (void)cmd; if (av == NULL) return; @@ -526,14 +549,23 @@ cmd_shell(CMD_ARGS) n += 1; ok = atoi(av[n]); } else if (!strcmp(av[n], "-expect")) { + if (re != NULL) + vtc_fatal(vl, + "Cannot use -expect with -match"); n += 1; expect = av[n]; + } else if (!strcmp(av[n], "-match")) { + if (expect != NULL) + vtc_fatal(vl, + "Cannot use -match with -expect"); + n += 1; + re = av[n]; } else { break; } } AN(av[n]); - cmd_shell_engine(vl, ok, av[n], expect); + cmd_shell_engine(vl, ok, av[n], expect, re); } /* SECTION: err_shell err_shell @@ -560,7 +592,7 @@ cmd_err_shell(CMD_ARGS) AZ(av[3]); vtc_log(vl, 1, "NOTICE: err_shell is deprecated, use 'shell -err -expect'"); - cmd_shell_engine(vl, -1, av[2], av[1]); + cmd_shell_engine(vl, -1, av[2], av[1], NULL); } /* SECTION: delay delay From fgsch at lodoss.net Sun Jan 22 01:37:04 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sun, 22 Jan 2017 02:37:04 +0100 Subject: [master] 59e07f2 Forgot to add a test for -match Message-ID: commit 59e07f2af4c86370b26d61f6b81628bf60493cab Author: Federico G. Schwindt Date: Sun Jan 22 01:27:54 2017 +0000 Forgot to add a test for -match diff --git a/bin/varnishtest/tests/a00000.vtc b/bin/varnishtest/tests/a00000.vtc index 2fc2b9f..d85d51e 100644 --- a/bin/varnishtest/tests/a00000.vtc +++ b/bin/varnishtest/tests/a00000.vtc @@ -2,6 +2,8 @@ varnishtest "Test varnishtest itself" shell -exit 1 -expect {usage: varnishtest} {varnishtest -h} +shell -exit 1 -match {-D.*Define macro} {varnishtest -h} + shell { pwd echo 'notvarnishtest foo bar' > _.vtc From fgsch at lodoss.net Mon Jan 23 01:49:05 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Mon, 23 Jan 2017 02:49:05 +0100 Subject: [master] fbe0489 More coverage Message-ID: commit fbe04890b22843bb9c98fc1007e9d7ae3aa19904 Author: Federico G. Schwindt Date: Mon Jan 23 01:48:13 2017 +0000 More coverage diff --git a/bin/varnishtest/tests/u00003.vtc b/bin/varnishtest/tests/u00003.vtc index 6369e45..2f4e188 100644 --- a/bin/varnishtest/tests/u00003.vtc +++ b/bin/varnishtest/tests/u00003.vtc @@ -5,9 +5,17 @@ server s1 -repeat 2 { txresp } -start -varnish v1 -vcl+backend {} -start +varnish v1 -vcl+backend { + import std; + sub vcl_backend_fetch { + std.log("foo:qux"); + } +} -start -shell "varnishncsa -n ${v1_name} -D -P ${tmpdir}/ncsa.pid -w ${tmpdir}/ncsa.log" +shell { + varnishncsa -n ${v1_name} -D -P ${tmpdir}/ncsa.pid \ + -w ${tmpdir}/ncsa.log +} shell -expect "Usage: varnishncsa " \ "varnishncsa -h" @@ -74,6 +82,8 @@ shell "kill `cat ${tmpdir}/ncsa.pid`" shell "grep -q /foo ${tmpdir}/ncsa.old.log" shell "grep -q /bar ${tmpdir}/ncsa.log" -shell {echo "%{VSL:Begin}x %{Varnish:vxid}x %D %T %{Varnish:handling}x %{%Z}t" >${tmpdir}/format} -shell -match "req 1000 rxreq 1001 [0-9]{5} 0 miss [A-Z]{3,}" \ +shell {echo "%{VSL:Begin}x %{Varnish:vxid}x %{VCL_Log:foo}x %D %T %{Varnish:handling}x %{%Z}t" >${tmpdir}/format} +shell -match "^req 1000 rxreq 1001 [0-9]{5} 0 miss [A-Z]{3,}" \ {varnishncsa -n ${v1_name} -d -f ${tmpdir}/format} +shell -match "^bereq 1001 fetch 1002 qux [0-9]{5} 0 - [A-Z]{3,}" \ + {varnishncsa -n ${v1_name} -d -f ${tmpdir}/format -b} diff --git a/bin/varnishtest/tests/u00004.vtc b/bin/varnishtest/tests/u00004.vtc index 046b1f0..811b370 100644 --- a/bin/varnishtest/tests/u00004.vtc +++ b/bin/varnishtest/tests/u00004.vtc @@ -5,15 +5,18 @@ server s1 { txresp } -start -varnish v1 -vcl+backend "" -start - -process p1 {exec varnishtop -1 -n ${v1_name} >/dev/null} -start +varnish v1 -vcl+backend { } -start client c1 { txreq rxresp } -run -process p1 -wait +shell -expect "fetch" "varnishtop -n ${v1_name} -1 -d" -process p2 {exec varnishtop -1 -n ${v1_name} >/dev/null} -run +shell -expect "Usage: varnishtop " \ + "varnishtop -h" +shell -expect "Copyright (c) 2006 Verdens Gang AS" \ + "varnishtop -V" +shell -err -expect "Usage: varnishtop " \ + "varnishtop extra" diff --git a/bin/varnishtest/tests/u00006.vtc b/bin/varnishtest/tests/u00006.vtc index cda5d73..9b6f83f 100644 --- a/bin/varnishtest/tests/u00006.vtc +++ b/bin/varnishtest/tests/u00006.vtc @@ -71,3 +71,8 @@ $} { } shell -match "-[ ]+BereqURL[ ]+/bar" \ "varnishlog -r ${tmpdir}/vlog.bin -x ReqURL" +shell -match {^\*[ ]+<< BeReq\s+>>[ ]+1005[ ]+ +-[ ]+BereqURL[ ]+/bar +$} { + varnishlog -r ${tmpdir}/vlog.bin -b -C -I BAR +} diff --git a/bin/varnishtest/tests/u00007.vtc b/bin/varnishtest/tests/u00007.vtc index b1bd0a2..80d956c 100644 --- a/bin/varnishtest/tests/u00007.vtc +++ b/bin/varnishtest/tests/u00007.vtc @@ -9,6 +9,8 @@ varnish v1 -vcl+backend {} -start shell -expect "Usage: varnishhist " \ "varnishhist -h" +shell -expect "Copyright (c) 2006 Verdens Gang AS" \ + "varnishhist -V" shell -err -expect "Usage: varnishhist " \ "varnishhist extra" shell -err -expect "-p: invalid '0'" \ From phk at FreeBSD.org Wed Jan 25 09:46:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 25 Jan 2017 10:46:05 +0100 Subject: [master] d578e81 Be a little bit more communicative Message-ID: commit d578e813583f3291614302f4056326e32ec1bc0f Author: Poul-Henning Kamp Date: Wed Jan 25 09:36:50 2017 +0000 Be a little bit more communicative diff --git a/bin/varnishtest/vtc_logexp.c b/bin/varnishtest/vtc_logexp.c index e042e89..b564151 100644 --- a/bin/varnishtest/vtc_logexp.c +++ b/bin/varnishtest/vtc_logexp.c @@ -232,7 +232,7 @@ logexp_next(struct logexp *le) CHECK_OBJ_ORNULL(le->test, LOGEXP_TEST_MAGIC); if (le->test) - vtc_log(le->vl, 3, "waitfor| %s", VSB_data(le->test->str)); + vtc_log(le->vl, 3, "expecting| %s", VSB_data(le->test->str)); } static int __match_proto__(VSLQ_dispatch_f) @@ -336,7 +336,7 @@ logexp_thread(void *priv) AN(le->vslq); AZ(le->test); - vtc_log(le->vl, 4, "beg|"); + vtc_log(le->vl, 4, "begin|"); if (le->query != NULL) vtc_log(le->vl, 4, "qry| %s", le->query); logexp_next(le); From phk at FreeBSD.org Wed Jan 25 09:46:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 25 Jan 2017 10:46:05 +0100 Subject: [master] 73f0fd9 white-space ocd Message-ID: commit 73f0fd9bd66dadb519ef9d18cd1d44860a5c5681 Author: Poul-Henning Kamp Date: Wed Jan 25 09:42:16 2017 +0000 white-space ocd diff --git a/bin/varnishtest/vtc.c b/bin/varnishtest/vtc.c index 597e0c3..936fb7a 100644 --- a/bin/varnishtest/vtc.c +++ b/bin/varnishtest/vtc.c @@ -448,16 +448,16 @@ cmd_varnishtest(CMD_ARGS) * Optional arguments: * * \-err - * Expect non-zero exit code. + * Expect non-zero exit code. * * \-exit N - * Expect exit code N instead of zero. + * Expect exit code N instead of zero. * * \-expect STRING - * Expect string to be found in stdout+err. + * Expect string to be found in stdout+err. * * \-match REGEXP - * Expect regexp to match the stdout+err output. + * Expect regexp to match the stdout+err output. */ /* SECTION: client-server.spec.shell shell * From phk at FreeBSD.org Wed Jan 25 09:46:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 25 Jan 2017 10:46:05 +0100 Subject: [master] 6786c86 Nitpicking Message-ID: commit 6786c86ba5f650c9790f3e185e0cd508bc5bddbd Author: Poul-Henning Kamp Date: Wed Jan 25 09:44:04 2017 +0000 Nitpicking diff --git a/bin/varnishtest/vtc.c b/bin/varnishtest/vtc.c index 936fb7a..64ed594 100644 --- a/bin/varnishtest/vtc.c +++ b/bin/varnishtest/vtc.c @@ -579,7 +579,7 @@ cmd_shell(CMD_ARGS) * failing the test case otherwise. */ -void +static void cmd_err_shell(CMD_ARGS) { (void)priv; diff --git a/bin/varnishtest/vtc.h b/bin/varnishtest/vtc.h index 14f3340..a25d4ff 100644 --- a/bin/varnishtest/vtc.h +++ b/bin/varnishtest/vtc.h @@ -67,7 +67,6 @@ CMD(varnish); CMD(barrier); CMD(logexpect); CMD(process); -CMD(err_shell); CMD(shell); #undef CMD diff --git a/bin/varnishtest/vtc_process.c b/bin/varnishtest/vtc_process.c index dc968a1..a258f54 100644 --- a/bin/varnishtest/vtc_process.c +++ b/bin/varnishtest/vtc_process.c @@ -147,7 +147,7 @@ process_delete(struct process *p) } static void -process_undef(struct process *p) +process_undef(const struct process *p) { CHECK_OBJ_NOTNULL(p, PROCESS_MAGIC); From phk at FreeBSD.org Wed Jan 25 09:46:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 25 Jan 2017 10:46:05 +0100 Subject: [master] 7de2ff8 Change assert to proper error message and test it. Message-ID: commit 7de2ff8e4225bb4776e7ffd8cd4f36d0e85b4d8c Author: Poul-Henning Kamp Date: Wed Jan 25 09:44:17 2017 +0000 Change assert to proper error message and test it. Fixes #2197 diff --git a/bin/varnishd/cache/cache_esi_parse.c b/bin/varnishd/cache/cache_esi_parse.c index 7f17cc3..38ec348 100644 --- a/bin/varnishd/cache/cache_esi_parse.c +++ b/bin/varnishd/cache/cache_esi_parse.c @@ -479,7 +479,14 @@ vep_do_include(struct vep_state *vep, enum dowhat what) if (l > 7 && !memcmp(p, "http://", 7)) { h = p + 7; p = strchr(h, '/'); - AN(p); + if (p == NULL) { + vep_error(vep, + "ESI 1.0 invalid src= URL"); + vep->state = VEP_TAGERROR; + AZ(vep->attr_vsb); + VSB_destroy(&vep->include_src); + return; + } Debug("HOST <%.*s> PATH <%s>\n", (int)(p-h),h, p); VSB_printf(vep->vsb, "%c", VEC_INCL); VSB_printf(vep->vsb, "Host: %.*s%c", (int)(p-h), h, 0); @@ -496,7 +503,14 @@ vep_do_include(struct vep_state *vep, enum dowhat what) "ESI 1.0 https:// treated as http://"); h = p + 8; p = strchr(h, '/'); - AN(p); + if (p == NULL) { + vep_error(vep, + "ESI 1.0 invalid src= URL"); + vep->state = VEP_TAGERROR; + AZ(vep->attr_vsb); + VSB_destroy(&vep->include_src); + return; + } VSB_printf(vep->vsb, "%c", VEC_INCL); VSB_printf(vep->vsb, "Host: %.*s%c", (int)(p-h), h, 0); } else if (*p == '/') { diff --git a/bin/varnishtest/tests/e00006.vtc b/bin/varnishtest/tests/e00006.vtc index 759a0f4..6c9b5fd 100644 --- a/bin/varnishtest/tests/e00006.vtc +++ b/bin/varnishtest/tests/e00006.vtc @@ -43,3 +43,49 @@ client c1 { client c1 -run varnish v1 -expect esi_errors == 0 + +# Now try with invalid URLs + +server s1 { + rxreq + expect req.url == /http + txresp -body {1234} + rxreq + expect req.url == /https + txresp -body {123456} +} -start + +varnish v1 -vcl+backend { + sub vcl_recv { + set req.backend_hint = s2; + set req.backend_hint = s1; + } + sub vcl_backend_response { + set beresp.do_esi = true; + } +} + +varnish v1 -cliok "param.set feature +esi_ignore_https" + +logexpect l1 -v v1 -g raw { + expect * * ESI_xmlerror "ERR at 35 ESI 1.0 invalid src= URL" + expect * * ESI_xmlerror "WARN at 36 ESI 1.0 https:// treated as http://" + expect * * ESI_xmlerror "ERR at 36 ESI 1.0 invalid src= URL" +} -start + +client c1 { + txreq -url /http + rxresp + expect resp.status == 200 + expect resp.bodylen == 4 + txreq -url /https + rxresp + expect resp.status == 200 + expect resp.bodylen == 6 +} + +client c1 -run + +logexpect l1 -wait + +varnish v1 -expect esi_errors == 2 From hermunn at varnish-software.com Wed Jan 25 16:41:04 2017 From: hermunn at varnish-software.com (Pål Hermunn Johansen) Date: Wed, 25 Jan 2017 17:41:04 +0100 Subject: [4.1] 1978ebf fix vsm_free (never incremented) Message-ID: commit 1978ebff50643944b4e740ee6f5eb85ded5d0252 Author: Emmanuel Hocdet Date: Mon Jan 16 18:15:50 2017 +0100 fix vsm_free (never incremented) diff --git a/bin/varnishd/common/common_vsm.c b/bin/varnishd/common/common_vsm.c index f24841c..2dcab6f 100644 --- a/bin/varnishd/common/common_vsm.c +++ b/bin/varnishd/common/common_vsm.c @@ -180,6 +180,7 @@ VSM_common_cleaner(struct vsm_sc *sc, struct VSC_C_main *stats) break; VTAILQ_REMOVE(&sc->r_cooling, vr, list); sc->g_cooling -= vr->len; + sc->g_free += vr->len; vsm_common_insert_free(sc, vr); } stats->vsm_free = sc->g_free; From hermunn at varnish-software.com Thu Jan 26 15:38:04 2017 From: hermunn at varnish-software.com (Pål Hermunn Johansen) Date: Thu, 26 Jan 2017 16:38:04 +0100 Subject: [4.1] 5995222 Clarify %r formatter wrt multiple Host headers Message-ID: commit 5995222461de8a92f1bff61dc519c7f7f860d337 Author: Federico G. Schwindt Date: Thu Jan 19 22:03:27 2017 +0000 Clarify %r formatter wrt multiple Host headers Also clarify %{X}i and %{X}o wrt multiple X headers. Fixes #2190. Conflicts: doc/sphinx/reference/varnishncsa.rst diff --git a/doc/sphinx/reference/varnishncsa.rst b/doc/sphinx/reference/varnishncsa.rst index 55c38a8..3022c92 100644 --- a/doc/sphinx/reference/varnishncsa.rst +++ b/doc/sphinx/reference/varnishncsa.rst @@ -98,7 +98,8 @@ Supported formatters are: total bytes sent to the backend. %{X}i - The contents of request header X. + The contents of request header X. If the header appears multiple times + in a single transaction, the last occurrence is used. %l Remote logname. Always '-'. @@ -107,7 +108,8 @@ Supported formatters are: Request method. Defaults to '-' if not known. %{X}o - The contents of response header X. + The contents of response header X. If the header appears multiple + times in a single transaction, the last occurrence is used. %O In client mode, total bytes sent to client. In backend mode, total @@ -172,11 +174,13 @@ Supported formatters are: VCL_Log:key Output value set by std.log("key:value") in VCL. - VSL:tag or VSL:tag[field] - The value of the VSL entry for the given tag. If field is specified, - only the selected part is shown. Defaults to '-' when the tag is not - seen, or when the field is out of bounds. If a tag appears several - times in a single transaction, only the first occurrence is used. + VSL:tag[field] + The value of the VSL entry for the given tag. The field will, + if present, treat the log record as a white space separated list + of fields, and only the nth part of the record will be matched + against. Fields start counting at 1. Defaults to '-' when the tag + is not seen, or when the field is out of bounds. If a tag appears + multiple times in a single transaction, the first occurrence is used. SIGNALS ======= @@ -191,7 +195,9 @@ NOTES ===== The %r formatter is equivalent to "%m http://%{Host}i%U%q %H". This -differs from apache's %r behavior. For the latter use "%m %U%q %H". +differs from apache's %r behavior, equivalent to "%m %U%q %H". +Furthermore, when using the %r formatter, if the Host header appears +multiple times in a single transaction, the first occurrence is used. EXAMPLE ======= From hermunn at varnish-software.com Thu Jan 26 15:54:05 2017 From: hermunn at varnish-software.com (Pål Hermunn Johansen) Date: Thu, 26 Jan 2017 16:54:05 +0100 Subject: [4.1] 880b4ba Change assert to proper error message and test it. Message-ID: commit 880b4ba30da6a4d8307b1e0d70bcfd3ccc049717 Author: Poul-Henning Kamp Date: Wed Jan 25 09:44:17 2017 +0000 Change assert to proper error message and test it. Fixes #2197 diff --git a/bin/varnishd/cache/cache_esi_parse.c b/bin/varnishd/cache/cache_esi_parse.c index 8e8dd8f..e773435 100644 --- a/bin/varnishd/cache/cache_esi_parse.c +++ b/bin/varnishd/cache/cache_esi_parse.c @@ -489,7 +489,14 @@ vep_do_include(struct vep_state *vep, enum dowhat what) if (l > 7 && !memcmp(p, "http://", 7)) { h = p + 7; p = strchr(h, '/'); - AN(p); + if (p == NULL) { + vep_error(vep, + "ESI 1.0 invalid src= URL"); + vep->state = VEP_TAGERROR; + AZ(vep->attr_vsb); + VSB_destroy(&vep->include_src); + return; + } Debug("HOST <%.*s> PATH <%s>\n", (int)(p-h),h, p); VSB_printf(vep->vsb, "%c", VEC_INCL); VSB_printf(vep->vsb, "Host: %.*s%c", (int)(p-h), h, 0); @@ -506,7 +513,14 @@ vep_do_include(struct vep_state *vep, enum dowhat what) "ESI 1.0 https:// treated as http://"); h = p + 8; p = strchr(h, '/'); - AN(p); + if (p == NULL) { + vep_error(vep, + "ESI 1.0 invalid src= URL"); + vep->state = VEP_TAGERROR; + AZ(vep->attr_vsb); + VSB_destroy(&vep->include_src); + return; + } VSB_printf(vep->vsb, "%c", VEC_INCL); VSB_printf(vep->vsb, "Host: %.*s%c", (int)(p-h), h, 0); } else if (*p == '/') { diff --git a/bin/varnishtest/tests/e00006.vtc b/bin/varnishtest/tests/e00006.vtc index 759a0f4..6c9b5fd 100644 --- a/bin/varnishtest/tests/e00006.vtc +++ b/bin/varnishtest/tests/e00006.vtc @@ -43,3 +43,49 @@ client c1 { client c1 -run varnish v1 -expect esi_errors == 0 + +# Now try with invalid URLs + +server s1 { + rxreq + expect req.url == /http + txresp -body {1234} + rxreq + expect req.url == /https + txresp -body {123456} +} -start + +varnish v1 -vcl+backend { + sub vcl_recv { + set req.backend_hint = s2; + set req.backend_hint = s1; + } + sub vcl_backend_response { + set beresp.do_esi = true; + } +} + +varnish v1 -cliok "param.set feature +esi_ignore_https" + +logexpect l1 -v v1 -g raw { + expect * * ESI_xmlerror "ERR at 35 ESI 1.0 invalid src= URL" + expect * * ESI_xmlerror "WARN at 36 ESI 1.0 https:// treated as http://" + expect * * ESI_xmlerror "ERR at 36 ESI 1.0 invalid src= URL" +} -start + +client c1 { + txreq -url /http + rxresp + expect resp.status == 200 + expect resp.bodylen == 4 + txreq -url /https + rxresp + expect resp.status == 200 + expect resp.bodylen == 6 +} + +client c1 -run + +logexpect l1 -wait + +varnish v1 -expect esi_errors == 2 From phk at FreeBSD.org Fri Jan 27 09:01:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 27 Jan 2017 10:01:05 +0100 Subject: [master] 74eb0df0 Make waiters a "tbl/waiters.h" table Message-ID: commit 74eb0df0da7d6f415281887e74420717ec879598 Author: Poul-Henning Kamp Date: Fri Jan 27 09:00:07 2017 +0000 Make waiters a "tbl/waiters.h" table diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index 0090655..652a273 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -129,18 +129,8 @@ usage(void) fprintf(stderr, FMT, "-t TTL", "Default TTL"); fprintf(stderr, FMT, "-V", "version"); fprintf(stderr, FMT, "-W waiter", "Waiter implementation"); -#if defined(HAVE_KQUEUE) - fprintf(stderr, FMT, "", " -W kqueue"); -#endif -#if defined(HAVE_PORT_CREATE) - fprintf(stderr, FMT, "", " -W ports"); -#endif -#if defined(HAVE_EPOLL_CTL) - fprintf(stderr, FMT, "", " -W epoll"); -#endif - fprintf(stderr, FMT, "", " -W poll"); - -#undef FMT +#define WAITER(nm) fprintf(stderr, FMT, "", " -W " #nm); +#include "tbl/waiters.h" exit(1); } diff --git a/bin/varnishd/waiter/mgt_waiter.c b/bin/varnishd/waiter/mgt_waiter.c index 7b8530f..3010d86 100644 --- a/bin/varnishd/waiter/mgt_waiter.c +++ b/bin/varnishd/waiter/mgt_waiter.c @@ -37,16 +37,8 @@ #include "waiter/mgt_waiter.h" static const struct choice waiter_choice[] = { - #if defined(HAVE_KQUEUE) - { "kqueue", &waiter_kqueue }, - #endif - #if defined(HAVE_PORT_CREATE) - { "ports", &waiter_ports }, - #endif - #if defined(HAVE_EPOLL_CTL) - { "epoll", &waiter_epoll }, - #endif - { "poll", &waiter_poll }, +#define WAITER(nm) { #nm, &waiter_##nm }, +#include "tbl/waiters.h" { NULL, NULL} }; diff --git a/bin/varnishd/waiter/mgt_waiter.h b/bin/varnishd/waiter/mgt_waiter.h index 0106427..d8f6222 100644 --- a/bin/varnishd/waiter/mgt_waiter.h +++ b/bin/varnishd/waiter/mgt_waiter.h @@ -34,18 +34,7 @@ struct waiter_impl; /* mgt_waiter.c */ extern struct waiter_impl const * waiter; -#if defined(HAVE_EPOLL_CTL) -extern const struct waiter_impl waiter_epoll; -#endif - -#if defined(HAVE_KQUEUE) -extern const struct waiter_impl waiter_kqueue; -#endif - -#if defined(HAVE_PORT_CREATE) -extern const struct waiter_impl waiter_ports; -#endif - -extern const struct waiter_impl waiter_poll; +#define WAITER(nm) extern const struct waiter_impl waiter_##nm; +#include "tbl/waiters.h" void Wait_config(const char *arg); diff --git a/include/Makefile.am b/include/Makefile.am index 4534cbf..2df7780 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -44,6 +44,7 @@ nobase_pkginclude_HEADERS = \ tbl/vsc_types.h \ tbl/vsl_tags.h \ tbl/vsl_tags_http.h \ + tbl/waiters.h \ vapi/vsm.h \ vapi/vsm_int.h \ vapi/vsc.h \ diff --git a/include/tbl/waiters.h b/include/tbl/waiters.h new file mode 100644 index 0000000..f1f1d49 --- /dev/null +++ b/include/tbl/waiters.h @@ -0,0 +1,46 @@ +/*- + * Copyright (c) 2017 Varnish Software AS + * All rights reserved. + * + * Author: Poul-Henning Kamp + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * WAITER(nm) + */ + +/*lint -save -e525 -e539 */ + +#if defined(HAVE_KQUEUE) + WAITER(kqueue) +#endif + +#if defined(HAVE_PORT_CREATE) + WAITER(ports) +#endif + +#if defined(HAVE_EPOLL_CTL) + WAITER(epoll) +#endif + +WAITER(poll) +#undef WAITER From phk at FreeBSD.org Fri Jan 27 10:18:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 27 Jan 2017 11:18:05 +0100 Subject: [master] de4d412 Eliminate the waitfor structure. Message-ID: commit de4d41219297c1ad289718fc0e30c025aeb96cf2 Author: Poul-Henning Kamp Date: Fri Jan 27 10:17:33 2017 +0000 Eliminate the waitfor structure. diff --git a/bin/varnishd/cache/cache_backend_tcp.c b/bin/varnishd/cache/cache_backend_tcp.c index fdabe6f..425a7de 100644 --- a/bin/varnishd/cache/cache_backend_tcp.c +++ b/bin/varnishd/cache/cache_backend_tcp.c @@ -59,8 +59,6 @@ struct tcp_pool { int refcnt; struct lock mtx; - struct waitfor waitfor; - VTAILQ_HEAD(, vbc) connlist; int n_conn; @@ -162,9 +160,6 @@ VBT_Ref(const struct suckaddr *ip4, const struct suckaddr *ip6) VTAILQ_INIT(&tp->connlist); VTAILQ_INIT(&tp->killlist); VTAILQ_INSERT_HEAD(&pools, tp, list); - INIT_OBJ(&tp->waitfor, WAITFOR_MAGIC); - tp->waitfor.func = tcp_handle; - tp->waitfor.tmo = &cache_param->backend_idle_timeout; return (tp); } @@ -265,7 +260,8 @@ VBT_Recycle(const struct worker *wrk, struct tcp_pool *tp, struct vbc **vbcp) vbc->waited->fd = vbc->fd; vbc->waited->idle = VTIM_real(); vbc->state = VBC_STATE_AVAIL; - vbc->waited->waitfor = &tp->waitfor; + vbc->waited->func = tcp_handle; + vbc->waited->tmo = &cache_param->backend_idle_timeout; if (Wait_Enter(wrk->pool->waiter, vbc->waited)) { VTCP_close(&vbc->fd); memset(vbc, 0x33, sizeof *vbc); diff --git a/bin/varnishd/cache/cache_pool.h b/bin/varnishd/cache/cache_pool.h index fa3663a..83359ce 100644 --- a/bin/varnishd/cache/cache_pool.h +++ b/bin/varnishd/cache/cache_pool.h @@ -51,7 +51,6 @@ struct pool { struct dstat *a_stat; struct dstat *b_stat; - struct waitfor wf; struct mempool *mpl_req; struct mempool *mpl_sess; struct waiter *waiter; diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c index cc148b3..20a2844 100644 --- a/bin/varnishd/cache/cache_session.c +++ b/bin/varnishd/cache/cache_session.c @@ -455,7 +455,8 @@ SES_Wait(struct sess *sp, const struct transport *xp) wp->priv1 = sp; wp->priv2 = (uintptr_t)xp; wp->idle = sp->t_idle; - wp->waitfor = &pp->wf; + wp->func = ses_handle; + wp->tmo = &cache_param->timeout_idle; if (Wait_Enter(pp->waiter, wp)) SES_Delete(sp, SC_PIPE_OVERFLOW, NAN); } @@ -594,8 +595,5 @@ SES_NewPool(struct pool *pp, unsigned pool_no) pp->mpl_sess = MPL_New(nb, &cache_param->sess_pool, &cache_param->workspace_session); - INIT_OBJ(&pp->wf, WAITFOR_MAGIC); - pp->wf.func = ses_handle; - pp->wf.tmo = &cache_param->timeout_idle; pp->waiter = Waiter_New(); } diff --git a/bin/varnishd/waiter/cache_waiter.c b/bin/varnishd/waiter/cache_waiter.c index 2d31d36..28f50b1 100644 --- a/bin/varnishd/waiter/cache_waiter.c +++ b/bin/varnishd/waiter/cache_waiter.c @@ -71,10 +71,9 @@ Wait_Call(const struct waiter *w, struct waited *wp, { CHECK_OBJ_NOTNULL(w, WAITER_MAGIC); CHECK_OBJ_NOTNULL(wp, WAITED_MAGIC); - CHECK_OBJ_NOTNULL(wp->waitfor, WAITFOR_MAGIC); - AN(wp->waitfor->func); + AN(wp->func); assert(wp->idx == BINHEAP_NOIDX); - wp->waitfor->func(wp, ev, now); + wp->func(wp, ev, now); } /**********************************************************************/ @@ -133,7 +132,8 @@ Wait_Enter(const struct waiter *w, struct waited *wp) CHECK_OBJ_NOTNULL(w, WAITER_MAGIC); CHECK_OBJ_NOTNULL(wp, WAITED_MAGIC); assert(wp->fd > 0); // stdin never comes here - CHECK_OBJ_NOTNULL(wp->waitfor, WAITFOR_MAGIC); + AN(wp->func); + AN(wp->tmo); wp->idx = BINHEAP_NOIDX; return (w->impl->enter(w->priv, wp)); } diff --git a/bin/varnishd/waiter/waiter.h b/bin/varnishd/waiter/waiter.h index 4cbabb6..531f640 100644 --- a/bin/varnishd/waiter/waiter.h +++ b/bin/varnishd/waiter/waiter.h @@ -54,13 +54,6 @@ enum wait_event { typedef void waiter_handle_f(struct waited *, enum wait_event, double now); -struct waitfor { - unsigned magic; -#define WAITFOR_MAGIC 0x16b79246 - waiter_handle_f *func; - volatile double *tmo; -}; - struct waited { unsigned magic; #define WAITED_MAGIC 0x1743992d @@ -68,7 +61,8 @@ struct waited { unsigned idx; void *priv1; uintptr_t priv2; - const struct waitfor *waitfor; + waiter_handle_f *func; + volatile double *tmo; double idle; }; diff --git a/bin/varnishd/waiter/waiter_priv.h b/bin/varnishd/waiter/waiter_priv.h index 6db06ca..502d349 100644 --- a/bin/varnishd/waiter/waiter_priv.h +++ b/bin/varnishd/waiter/waiter_priv.h @@ -62,17 +62,16 @@ static inline double Wait_Tmo(const struct waited *wp) { CHECK_OBJ_ORNULL(wp, WAITED_MAGIC); - CHECK_OBJ_NOTNULL(wp->waitfor, WAITFOR_MAGIC); - AN(wp->waitfor->tmo); - return (*wp->waitfor->tmo); + AN(wp->tmo); + return (*wp->tmo); } static inline double Wait_When(const struct waited *wp) { CHECK_OBJ_ORNULL(wp, WAITED_MAGIC); - CHECK_OBJ_NOTNULL(wp->waitfor, WAITFOR_MAGIC); - return (wp->idle + *wp->waitfor->tmo); + AN(wp->tmo); + return (wp->idle + *wp->tmo); } void Wait_Call(const struct waiter *, struct waited *, From phk at FreeBSD.org Fri Jan 27 12:45:06 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 27 Jan 2017 13:45:06 +0100 Subject: [master] 95437e6 Get rid of the old "symbol" hack, it worked fine when everybody used GCC. Message-ID: commit 95437e6c882f2c2b332be94060a7ac96907db322 Author: Poul-Henning Kamp Date: Fri Jan 27 11:40:06 2017 +0000 Get rid of the old "symbol" hack, it worked fine when everybody used GCC. diff --git a/bin/varnishd/cache/cache_deliver_proc.c b/bin/varnishd/cache/cache_deliver_proc.c index 578f54c..5d3b23c 100644 --- a/bin/varnishd/cache/cache_deliver_proc.c +++ b/bin/varnishd/cache/cache_deliver_proc.c @@ -80,16 +80,6 @@ VDP_push(struct req *req, vdp_bytes *func, void *priv, int bottom, CHECK_OBJ_NOTNULL(req, REQ_MAGIC); AN(func); -#if 0 - // Gross hack for debugging - struct vsb *vsb; - vsb = VSB_new_auto(); - AN(vsb); - Symbol_Lookup(vsb, func); - AZ(VSB_finish(vsb)); - VSLb(req->vsl, SLT_Debug, "VDP %s %p %d", VSB_data(vsb), priv, bottom); - VSB_destroy(&vsb); -#endif vdp = WS_Alloc(req->ws, sizeof *vdp); if (vdp == NULL) return; diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index 8b6ad6d..16ecf47 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -31,6 +31,7 @@ #include #include +#include #include #include @@ -526,6 +527,7 @@ pan_backtrace(struct vsb *vsb) size_t i; char **strings; char *p; + char buf[32]; size = backtrace (array, BACKTRACE_LEVELS); if (size > BACKTRACE_LEVELS) { @@ -535,18 +537,21 @@ pan_backtrace(struct vsb *vsb) VSB_printf(vsb, "Backtrace:\n"); VSB_indent(vsb, 2); for (i = 0; i < size; i++) { - if (Symbol_Lookup(vsb, array[i]) < 0) { - strings = backtrace_symbols(&array[i], 1); - if (strings == NULL || strings[0] == NULL) { - VSB_printf(vsb, "%p: (?)", array[i]); - } else { - p = strrchr(strings[0], '/'); - if (p == NULL) - p = strings[0]; - else + bprintf(buf, "%p", array[i]); + VSB_printf(vsb, "%s: ", buf); + strings = backtrace_symbols(&array[i], 1); + if (strings == NULL || strings[0] == NULL) { + VSB_printf(vsb, "(?)"); + } else { + p = strings[0]; + if (!memcmp(buf, p, strlen(buf))) { + p += strlen(buf); + if (*p == ':') + p++; + while(*p == ' ') p++; - VSB_printf(vsb, "%p: %s", array[i], p); } + VSB_printf(vsb, "%s", p); } VSB_printf (vsb, "\n"); } diff --git a/bin/varnishd/common/common.h b/bin/varnishd/common/common.h index b476cb9..27da283 100644 --- a/bin/varnishd/common/common.h +++ b/bin/varnishd/common/common.h @@ -59,8 +59,6 @@ extern pid_t mgt_pid; /* varnishd.c */ extern struct vsb *vident; // XXX: -> heritage ? -int Symbol_Lookup(struct vsb *vsb, void *ptr); - /* Really belongs in mgt.h, but storage_file chokes on both */ void MCH_Fd_Inherit(int fd, const char *what); diff --git a/bin/varnishd/mgt/mgt.h b/bin/varnishd/mgt/mgt.h index 60e7def..d2dc522 100644 --- a/bin/varnishd/mgt/mgt.h +++ b/bin/varnishd/mgt/mgt.h @@ -171,7 +171,6 @@ void mgt_DumpRstVsl(void); struct vsb *mgt_BuildVident(void); void MGT_Complain(const char *, const char *, ...) __v_printflike(2, 3); const void *MGT_Pick(const struct choice *, const char *, const char *); -void mgt_SymbolHack(const char *); /* stevedore_mgt.c */ void STV_Config(const char *spec); diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index 652a273..286c025 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -565,8 +565,6 @@ main(int argc, char * const *argv) vident = mgt_BuildVident(); - mgt_SymbolHack(argv[0]); - /* Various initializations */ VTAILQ_INIT(&heritage.socks); mgt_evb = vev_new_base(); diff --git a/bin/varnishd/mgt/mgt_util.c b/bin/varnishd/mgt/mgt_util.c index 83b3bc5..0870089 100644 --- a/bin/varnishd/mgt/mgt_util.c +++ b/bin/varnishd/mgt/mgt_util.c @@ -153,75 +153,3 @@ MGT_Pick(const struct choice *cp, const char *which, const char *kind) } ARGV_ERR("Unknown %s method \"%s\"\n", kind, which); } - -/*-------------------------------------------------------------------- - * All praise POSIX! Thanks to our glorious standards there are no - * standard way to get a back-trace of the stack, and even if we hack - * that together from spit and pieces of string, there is no way no - * standard way to translate a pointer to a symbol, which returns anything - * usable. (See for instance FreeBSD PR-134391). - * - * Attempt to run nm(1) on our binary during startup, hoping it will - * give us a usable list of symbols. - */ - -struct symbols { - uintptr_t a; - uintptr_t l; - char *n; - VTAILQ_ENTRY(symbols) list; -}; - -static VTAILQ_HEAD(,symbols) symbols = VTAILQ_HEAD_INITIALIZER(symbols); - -int -Symbol_Lookup(struct vsb *vsb, void *ptr) -{ - struct symbols *s, *s0; - uintptr_t pp; - - pp = (uintptr_t)ptr; - s0 = NULL; - VTAILQ_FOREACH(s, &symbols, list) { - if (s->a > pp || s->a + s->l <= pp) - continue; - if (s0 == NULL || s->l < s0->l) - s0 = s; - } - if (s0 == NULL) - return (-1); - VSB_printf(vsb, "%p: %s", ptr, s0->n); - if ((uintmax_t)pp != s0->a) - VSB_printf(vsb, "+0x%jx", (uintmax_t)pp - s0->a); - return (0); -} - -void -mgt_SymbolHack(const char *a0) -{ - char buf[BUFSIZ]; - FILE *fi; - struct symbols *s; - uintmax_t aa, ll; - char type[10]; - char name[100]; - int i; - - bprintf(buf, "nm -t x -n -P %s 2>/dev/null", a0); - fi = popen(buf, "r"); - if (fi == NULL) - return; - while (fgets(buf, sizeof buf, fi)) { - i = sscanf(buf, "%99s\t%9s\t%jx\t%jx\n", name, type, &aa, &ll); - if (i != 4) - continue; - s = malloc(sizeof *s + strlen(name) + 1); - AN(s); - s->a = aa; - s->l = ll; - s->n = (void*)(s + 1); - strcpy(s->n, name); - VTAILQ_INSERT_TAIL(&symbols, s, list); - } - (void)pclose(fi); -} From phk at FreeBSD.org Fri Jan 27 12:45:06 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 27 Jan 2017 13:45:06 +0100 Subject: [master] 42fb7e9 Move req's vfp_ctx into struct req Message-ID: commit 42fb7e9646f486b74b1f2ca1c9195bfb712b6535 Author: Poul-Henning Kamp Date: Fri Jan 27 12:26:00 2017 +0000 Move req's vfp_ctx into struct req diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index a1564e5..add792c 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -227,7 +227,6 @@ struct http_conn { char *pipeline_b; char *pipeline_e; ssize_t content_length; - struct vfp_ctx vfc[1]; void *priv; /* Timeouts */ @@ -567,6 +566,7 @@ struct req { double t_req; /* Headers complete */ struct http_conn htc[1]; + struct vfp_ctx vfc[1]; const char *client_identity; /* HTTP request */ diff --git a/bin/varnishd/cache/cache_req_body.c b/bin/varnishd/cache/cache_req_body.c index 865b667..275260f 100644 --- a/bin/varnishd/cache/cache_req_body.c +++ b/bin/varnishd/cache/cache_req_body.c @@ -57,8 +57,8 @@ vrb_pull(struct req *req, ssize_t maxsize, objiterate_f *func, void *priv) CHECK_OBJ_NOTNULL(req, REQ_MAGIC); CHECK_OBJ_NOTNULL(req->htc, HTTP_CONN_MAGIC); - CHECK_OBJ_NOTNULL(req->htc->vfc, VFP_CTX_MAGIC); - vfc = req->htc->vfc; + CHECK_OBJ_NOTNULL(req->vfc, VFP_CTX_MAGIC); + vfc = req->vfc; req->body_oc = HSH_Private(req->wrk); AN(req->body_oc); @@ -291,8 +291,7 @@ VRB_Cache(struct req *req, ssize_t maxsize) if (req->htc->content_length > maxsize) { req->req_body_status = REQ_BODY_FAIL; - (void)VFP_Error(req->htc->vfc, - "Request body too big to cache"); + (void)VFP_Error(req->vfc, "Request body too big to cache"); return (-1); } diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index e6a18b6..e70fec3 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -678,9 +678,9 @@ cnt_recv(struct worker *wrk, struct req *req) http_CollectHdr(req->http, H_Cache_Control); - VFP_Setup(req->htc->vfc); - req->htc->vfc->http = req->http; - req->htc->vfc->wrk = wrk; + VFP_Setup(req->vfc); + req->vfc->http = req->http; + req->vfc->wrk = wrk; if (req->transport->req_body != NULL) { req->transport->req_body(req); diff --git a/bin/varnishd/http1/cache_http1_fsm.c b/bin/varnishd/http1/cache_http1_fsm.c index dc325e0..ed1d3fd 100644 --- a/bin/varnishd/http1/cache_http1_fsm.c +++ b/bin/varnishd/http1/cache_http1_fsm.c @@ -146,7 +146,7 @@ http1_req_body(struct req *req) case BS_EOF: case BS_LENGTH: case BS_CHUNKED: - if (V1F_Setup_Fetch(req->htc->vfc, req->htc) != 0) + if (V1F_Setup_Fetch(req->vfc, req->htc) != 0) req->req_body_status = REQ_BODY_FAIL; break; default: From phk at FreeBSD.org Fri Jan 27 12:45:06 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 27 Jan 2017 13:45:06 +0100 Subject: [master] a3c3e4e Have http_conn point to the fd rather than carry a copy Message-ID: commit a3c3e4ef2fb762bc6cfce1d0586bb69a58b815c7 Author: Poul-Henning Kamp Date: Fri Jan 27 12:43:43 2017 +0000 Have http_conn point to the fd rather than carry a copy diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index add792c..ddecdf6 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -218,7 +218,7 @@ struct http_conn { unsigned magic; #define HTTP_CONN_MAGIC 0x3e19edd1 - int fd; + int *rfd; enum sess_close doclose; enum body_status body_status; struct ws *ws; diff --git a/bin/varnishd/cache/cache_acceptor.c b/bin/varnishd/cache/cache_acceptor.c index cb907a9..d764d1b 100644 --- a/bin/varnishd/cache/cache_acceptor.c +++ b/bin/varnishd/cache/cache_acceptor.c @@ -373,7 +373,7 @@ vca_make_session(struct worker *wrk, void *arg) req = Req_New(wrk, sp); CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - req->htc->fd = sp->fd; + req->htc->rfd = &sp->fd; SES_SetTransport(wrk, sp, req, wa->acceptlsock->transport); } diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c index 58a89bd..3e7ecdb 100644 --- a/bin/varnishd/cache/cache_backend.c +++ b/bin/varnishd/cache/cache_backend.c @@ -119,7 +119,7 @@ vbe_dir_getfd(struct worker *wrk, struct backend *bp, struct busyobj *bo) INIT_OBJ(bo->htc, HTTP_CONN_MAGIC); bo->htc->priv = vc; - bo->htc->fd = vc->fd; + bo->htc->rfd = &vc->fd; FIND_TMO(first_byte_timeout, bo->htc->first_byte_timeout, bo, bp); FIND_TMO(between_bytes_timeout, diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index 16ecf47..8338490 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -183,7 +183,8 @@ pan_htc(struct vsb *vsb, const struct http_conn *htc) return; VSB_indent(vsb, 2); PAN_CheckMagic(vsb, htc, HTTP_CONN_MAGIC); - VSB_printf(vsb, "fd = %d,\n", htc->fd); + if (htc->rfd != NULL) + VSB_printf(vsb, "fd = %d (@%p),\n", *htc->rfd, htc->rfd); VSB_printf(vsb, "doclose = %s,\n", sess_close_2str(htc->doclose, 0)); pan_ws(vsb, htc->ws); VSB_printf(vsb, "{rxbuf_b, rxbuf_e} = {%p, %p},\n", diff --git a/bin/varnishd/cache/cache_req.c b/bin/varnishd/cache/cache_req.c index 62f8369..fe1598b 100644 --- a/bin/varnishd/cache/cache_req.c +++ b/bin/varnishd/cache/cache_req.c @@ -68,7 +68,6 @@ Req_New(const struct worker *wrk, struct sess *sp) req->top = req; // esi overrides INIT_OBJ(req->htc, HTTP_CONN_MAGIC); - req->htc->fd = -1; e = (char*)req + sz; p = (char*)(req + 1); diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c index 20a2844..10bb4bb 100644 --- a/bin/varnishd/cache/cache_session.c +++ b/bin/varnishd/cache/cache_session.c @@ -238,6 +238,8 @@ HTC_RxStuff(struct http_conn *htc, htc_complete_f *func, int i; CHECK_OBJ_NOTNULL(htc, HTTP_CONN_MAGIC); + AN(htc->rfd); + assert(*htc->rfd > 0); AN(htc->ws->r); AN(htc->rxbuf_b); assert(htc->rxbuf_b <= htc->rxbuf_e); @@ -294,7 +296,7 @@ HTC_RxStuff(struct http_conn *htc, htc_complete_f *func, } if (tmo <= 0.0) tmo = 1e-3; - i = VTCP_read(htc->fd, htc->rxbuf_e, i, tmo); + i = VTCP_read(*htc->rfd, htc->rxbuf_e, i, tmo); if (i == 0 || i == -1) { WS_ReleaseP(htc->ws, htc->rxbuf_b); return (HTC_S_EOF); diff --git a/bin/varnishd/http1/cache_http1_fetch.c b/bin/varnishd/http1/cache_http1_fetch.c index f29da00..15cf047 100644 --- a/bin/varnishd/http1/cache_http1_fetch.c +++ b/bin/varnishd/http1/cache_http1_fetch.c @@ -88,6 +88,7 @@ V1F_SendReq(struct worker *wrk, struct busyobj *bo, uint64_t *ctr, CHECK_OBJ_ORNULL(bo->req, REQ_MAGIC); htc = bo->htc; + assert(*htc->rfd > 0); hp = bo->bereq; if (bo->req != NULL && @@ -96,11 +97,11 @@ V1F_SendReq(struct worker *wrk, struct busyobj *bo, uint64_t *ctr, do_chunked = 1; } - VTCP_hisname(htc->fd, abuf, sizeof abuf, pbuf, sizeof pbuf); + VTCP_hisname(*htc->rfd, abuf, sizeof abuf, pbuf, sizeof pbuf); VSLb(bo->vsl, SLT_BackendStart, "%s %s", abuf, pbuf); - (void)VTCP_blocking(htc->fd); /* XXX: we should timeout instead */ - V1L_Reserve(wrk, wrk->aws, &htc->fd, bo->vsl, bo->t_prev); + (void)VTCP_blocking(*htc->rfd); /* XXX: we should timeout instead */ + V1L_Reserve(wrk, wrk->aws, htc->rfd, bo->vsl, bo->t_prev); *ctr += HTTP1_Write(wrk, hp, HTTP1_Req); /* Deal with any message-body the request might (still) have */ @@ -150,6 +151,7 @@ V1F_FetchRespHdr(struct busyobj *bo) CHECK_OBJ_ORNULL(bo->req, REQ_MAGIC); htc = bo->htc; + assert(*htc->rfd > 0); VSC_C_main->backend_req++; @@ -189,7 +191,7 @@ V1F_FetchRespHdr(struct busyobj *bo) } return (htc->rxbuf_e == htc->rxbuf_b ? 1 : -1); } - VTCP_set_read_timeout(htc->fd, htc->between_bytes_timeout); + VTCP_set_read_timeout(*htc->rfd, htc->between_bytes_timeout); hp = bo->beresp; diff --git a/bin/varnishd/http1/cache_http1_fsm.c b/bin/varnishd/http1/cache_http1_fsm.c index ed1d3fd..b6fd99a 100644 --- a/bin/varnishd/http1/cache_http1_fsm.c +++ b/bin/varnishd/http1/cache_http1_fsm.c @@ -130,7 +130,7 @@ http1_unwait(struct worker *wrk, void *arg) WS_Release(sp->ws, 0); req = Req_New(wrk, sp); CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - req->htc->fd = sp->fd; + req->htc->rfd = &sp->fd; HTC_RxInit(req->htc, req->ws); http1_setstate(sp, H1NEWREQ); wrk->task.func = http1_req; diff --git a/bin/varnishd/http1/cache_http1_vfp.c b/bin/varnishd/http1/cache_http1_vfp.c index b836cd3..d287fa5 100644 --- a/bin/varnishd/http1/cache_http1_vfp.c +++ b/bin/varnishd/http1/cache_http1_vfp.c @@ -73,7 +73,7 @@ v1f_read(const struct vfp_ctx *vc, struct http_conn *htc, void *d, ssize_t len) htc->pipeline_b = htc->pipeline_e = NULL; } if (len > 0) { - i = read(htc->fd, p, len); + i = read(*htc->rfd, p, len); if (i < 0) { // XXX: VTCP_Assert(i); // but also: EAGAIN VSLb(vc->wrk->vsl, SLT_FetchError, diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index 7e9ab9e..27872e7 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -136,7 +136,7 @@ h2_new_sess(const struct worker *wrk, struct sess *sp, struct req *srq) h2->ws = srq->ws; h2->vsl = srq->vsl; h2->vsl->wid = sp->vxid; - h2->htc->fd = sp->fd; + h2->htc->rfd = &sp->fd; h2->sess = sp; VTAILQ_INIT(&h2->streams); #define H2_SETTINGS(n,v,d) \ @@ -496,7 +496,7 @@ h2_rxframe(struct worker *wrk, struct h2_sess *h2) enum h2frame ft; struct h2_req *r2 = NULL; - (void)VTCP_blocking(h2->htc->fd); + (void)VTCP_blocking(*h2->htc->rfd); h2->sess->t_idle = VTIM_real(); hs = HTC_RxStuff(h2->htc, h2_frame_complete, NULL, NULL, NAN, From hermunn at varnish-software.com Fri Jan 27 13:20:05 2017 From: hermunn at varnish-software.com (Pål Hermunn Johansen) Date: Fri, 27 Jan 2017 14:20:05 +0100 Subject: [4.1] e8fcf40 Clarify description of fetch_failed counter. Message-ID: commit e8fcf408e40b745944a4b83df1b4c6af71eb3d59 Author: Poul-Henning Kamp Date: Fri Jan 13 09:54:27 2017 +0000 Clarify description of fetch_failed counter. Fixes #1704 Conflicts: include/tbl/vsc_f_main.h diff --git a/include/tbl/vsc_f_main.h b/include/tbl/vsc_f_main.h index ab926d9..9d05eff 100644 --- a/include/tbl/vsc_f_main.h +++ b/include/tbl/vsc_f_main.h @@ -184,7 +184,7 @@ VSC_F(fetch_304, uint64_t, 1, 'c', 'i', info, "beresp with no body because of 304 response." ) VSC_F(fetch_failed, uint64_t, 1, 'c', 'i', info, - "Fetch failed (all causes)", + "Fetch failed (all causes), where we do get hold of the backend.", "beresp fetch failed." ) VSC_F(fetch_no_thread, uint64_t, 1, 'c', 'i', info, From dridi.boukelmoune at gmail.com Fri Jan 27 14:00:06 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 27 Jan 2017 15:00:06 +0100 Subject: [master] 632fa99 Fix vmoddir when using --prefix at configure time Message-ID: commit 632fa996dc0492b66adf98f6e207088fd2d3ef27 Author: Dridi Boukelmoune Date: Fri Jan 27 14:54:10 2017 +0100 Fix vmoddir when using --prefix at configure time Spotted by Martin, when a VMOD relying on varnish.m4 is built with --prefix in the configure command-line, a pseudo hard-coded vmoddir is assumed: $libdir/varnish/vmods Instead, it now asks pkg-config for the vmoddir relative to the libdir. It worked in all cases with upstream Varnish Cache, but downstream modifications of the vmoddir would then be ignored. diff --git a/varnish.m4 b/varnish.m4 index 8b7d70e..3b603f0 100644 --- a/varnish.m4 +++ b/varnish.m4 @@ -133,7 +133,8 @@ AC_DEFUN([_VARNISH_VMOD_CONFIG], [ [NONE], [ vmoddir=$VARNISHAPI_VMODDIR ac_default_prefix=$VARNISHAPI_PREFIX], - [vmoddir=$libdir/varnish/vmods] + [vmoddir=$($PKG_CONFIG --define-variable=libdir=$libdir \ + --variable=vmoddir varnishapi)] ) AC_SUBST([vmoddir]) From martin at varnish-software.com Fri Jan 27 14:57:05 2017 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Fri, 27 Jan 2017 15:57:05 +0100 Subject: [4.1] 5e39315 Fix vmoddir when using --prefix at configure time Message-ID: commit 5e39315e40edd3812b7b1b0099a7f80e2b0a723d Author: Dridi Boukelmoune Date: Fri Jan 27 14:54:10 2017 +0100 Fix vmoddir when using --prefix at configure time Spotted by Martin, when a VMOD relying on varnish.m4 is built with --prefix in the configure command-line, a pseudo hard-coded vmoddir is assumed: $libdir/varnish/vmods Instead, it now asks pkg-config for the vmoddir relative to the libdir. It worked in all cases with upstream Varnish Cache, but downstream modifications of the vmoddir would then be ignored. diff --git a/varnish.m4 b/varnish.m4 index d0849ef..75ac9a3 100644 --- a/varnish.m4 +++ b/varnish.m4 @@ -95,7 +95,8 @@ AC_DEFUN([_VARNISH_VMOD_CONFIG], [ [NONE], [ vmoddir=$VARNISHAPI_VMODDIR ac_default_prefix=$VARNISHAPI_PREFIX], - [vmoddir=$libdir/varnish/vmods] + [vmoddir=$($PKG_CONFIG --define-variable=libdir=$libdir \ + --variable=vmoddir varnishapi)] ) AC_SUBST([vmoddir]) From dridi.boukelmoune at gmail.com Fri Jan 27 15:25:05 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 27 Jan 2017 16:25:05 +0100 Subject: [master] b5fd51b Fix vmod silent rules with bmake(1) Message-ID: commit b5fd51b54299d18e6ff31999c7f539f84cbe0533 Author: Dridi Boukelmoune Date: Fri Jan 27 16:23:36 2017 +0100 Fix vmod silent rules with bmake(1) diff --git a/varnish.m4 b/varnish.m4 index 3b603f0..f3894ce 100644 --- a/varnish.m4 +++ b/varnish.m4 @@ -139,7 +139,7 @@ AC_DEFUN([_VARNISH_VMOD_CONFIG], [ AC_SUBST([vmoddir]) dnl Define an automake silent execution for vmodtool - [am__v_VMODTOOL_0='@echo " VMODTOOL" $<;'] + [am__v_VMODTOOL_0='@echo " VMODTOOL" $''@;'] [am__v_VMODTOOL_1=''] [am__v_VMODTOOL_='$(am__v_VMODTOOL_$(AM_DEFAULT_VERBOSITY))'] [AM_V_VMODTOOL='$(am__v_VMODTOOL_$(V))'] From dridi.boukelmoune at gmail.com Fri Jan 27 16:47:05 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 27 Jan 2017 17:47:05 +0100 Subject: [master] 1c381f3 Stabilize flaky test r1813 Message-ID: commit 1c381f3c2d4b8f5687f7cb80c320aa9601d775ab Author: Dridi Boukelmoune Date: Fri Jan 27 17:44:36 2017 +0100 Stabilize flaky test r1813 Because it uses hard-coded ports, it often appears as failing in vtest so now it should succeed if the address wasn't available. diff --git a/bin/varnishtest/tests/r01813.vtc b/bin/varnishtest/tests/r01813.vtc index e679f75..7ed9ef8 100644 --- a/bin/varnishtest/tests/r01813.vtc +++ b/bin/varnishtest/tests/r01813.vtc @@ -1,3 +1,5 @@ varnishtest "Duplicate -a arguments" -shell -err -expect {have same address} "varnishd -d -a 127.0.0.1:38484 -a 127.0.0.1:38484 -b localhost:80 2>&1" +shell -err -match "(have same address)|(already in use)" { + varnishd -d -a 127.0.0.1:38484 -a 127.0.0.1:38484 -b localhost:80 +} From fgsch at lodoss.net Fri Jan 27 18:37:04 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Fri, 27 Jan 2017 19:37:04 +0100 Subject: [master] 46536b1 Polish Message-ID: commit 46536b1b4d04dd9d6011f1fe43a735ff1a364d41 Author: Federico G. Schwindt Date: Fri Jan 27 11:30:14 2017 +0000 Polish diff --git a/bin/varnishtest/vtc_process.c b/bin/varnishtest/vtc_process.c index a258f54..3c0b73c 100644 --- a/bin/varnishtest/vtc_process.c +++ b/bin/varnishtest/vtc_process.c @@ -240,8 +240,6 @@ process_start(struct process *p) out_fd = fdt[1]; err_fd = fdt[1]; } else { - fdt[0] = -1; - fdt[1] = -1; out_fd = open(p->out, O_WRONLY|O_APPEND); assert(out_fd >= 0); err_fd = open(p->err, O_WRONLY|O_APPEND); @@ -293,14 +291,6 @@ process_wait(struct process *p) } } -static void -process_run(struct process *p) -{ - - process_start(p); - process_wait(p); -} - /********************************************************************** * Send a signal to a process */ @@ -496,7 +486,8 @@ cmd_process(CMD_ARGS) continue; } if (!strcmp(*av, "-run")) { - process_run(p); + process_start(p); + process_wait(p); continue; } if (!strcmp(*av, "-kill")) { From fgsch at lodoss.net Fri Jan 27 18:37:04 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Fri, 27 Jan 2017 19:37:04 +0100 Subject: [master] b6d0ff8 Merge tests and reshuffle things Message-ID: commit b6d0ff84fabfce8bffad426c02421eb891ef6a7b Author: Federico G. Schwindt Date: Fri Jan 27 18:35:22 2017 +0000 Merge tests and reshuffle things diff --git a/bin/varnishtest/tests/c00003.vtc b/bin/varnishtest/tests/c00003.vtc index aa86907..270be73 100644 --- a/bin/varnishtest/tests/c00003.vtc +++ b/bin/varnishtest/tests/c00003.vtc @@ -1,4 +1,20 @@ -varnishtest "Check that we fail to start if any listen address does not work" +varnishtest "Check that we fail to start with erroneous -a/-b arguments" + +server s1 {} +varnish v1 -vcl+backend {} -start +varnish v1 -stop + +# Duplicate -a arguments +shell -err -expect "have same address" { + varnishd -d -a 127.0.0.1:${v1_port} -a 127.0.0.1:${v1_port} \ + -b localhost:80 +} + +# -a bad protocol specs +shell -err -expect "Too many sub-arguments" \ + "varnishd -a 127.0.0.1:80000,PROXY,FOO -d 2>&1" +shell -err -expect "Too many sub-arguments" \ + "varnishd -a 127.0.0.1:80000,HTTP/1,FOO -d 2>&1" # This requires non-local binds to be disabled. If you see this fail # and are on Linux, ensure /proc/net/ipv4/ip_nonlocal_bind is set to 0. diff --git a/bin/varnishtest/tests/j00002.vtc b/bin/varnishtest/tests/j00002.vtc deleted file mode 100644 index 274844c..0000000 --- a/bin/varnishtest/tests/j00002.vtc +++ /dev/null @@ -1,8 +0,0 @@ -varnishtest "-junix bad subarg handling" - -feature root - -shell -err -expect "unknown sub-argument" "varnishd -junix,bla=foo -f '' 2>&1" -shell -err -expect "user not found" "varnishd -junix,user=/// -f '' 2>&1" -shell -err -expect "user not found" "varnishd -junix,workuser=/// -f '' 2>&1" -shell -err -expect "group not found" "varnishd -junix,ccgroup=/// -f '' 2>&1" diff --git a/bin/varnishtest/tests/j00003.vtc b/bin/varnishtest/tests/j00003.vtc index 56e43ee..e67589e 100644 --- a/bin/varnishtest/tests/j00003.vtc +++ b/bin/varnishtest/tests/j00003.vtc @@ -1,6 +1,12 @@ varnishtest "-junix bad subarg handling" feature root + +shell -err -expect "unknown sub-argument" "varnishd -junix,bla=foo -f '' 2>&1" +shell -err -expect "user not found" "varnishd -junix,user=/// -f '' 2>&1" +shell -err -expect "user not found" "varnishd -junix,workuser=/// -f '' 2>&1" +shell -err -expect "group not found" "varnishd -junix,ccgroup=/// -f '' 2>&1" + feature user_varnish shell -err -expect "have different login groups" "varnishd -junix,workuser=root -f '' 2>&1" diff --git a/bin/varnishtest/tests/r01770.vtc b/bin/varnishtest/tests/r01770.vtc deleted file mode 100644 index de66aab..0000000 --- a/bin/varnishtest/tests/r01770.vtc +++ /dev/null @@ -1,4 +0,0 @@ -varnishtest "bad protocol specs for -a" - -shell -err -expect "Too many sub-arguments" "varnishd -a 127.0.0.1:80000,PROXY,FOO -d 2>&1" -shell -err -expect "Too many sub-arguments" "varnishd -a 127.0.0.1:80000,HTTP/1,FOO -d 2>&1" diff --git a/bin/varnishtest/tests/r01813.vtc b/bin/varnishtest/tests/r01813.vtc deleted file mode 100644 index 7ed9ef8..0000000 --- a/bin/varnishtest/tests/r01813.vtc +++ /dev/null @@ -1,5 +0,0 @@ -varnishtest "Duplicate -a arguments" - -shell -err -match "(have same address)|(already in use)" { - varnishd -d -a 127.0.0.1:38484 -a 127.0.0.1:38484 -b localhost:80 -} From fgsch at lodoss.net Fri Jan 27 18:58:04 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Fri, 27 Jan 2017 19:58:04 +0100 Subject: [master] 9a652c7 Schedule this (slow) test to run a bit earlier Message-ID: commit 9a652c7c3a879695d9495e10928366b1c910c3e3 Author: Federico G. Schwindt Date: Fri Jan 27 18:54:11 2017 +0000 Schedule this (slow) test to run a bit earlier diff --git a/bin/varnishtest/tests/s00005.vtc b/bin/varnishtest/tests/s00005.vtc new file mode 100644 index 0000000..67cd3a9 --- /dev/null +++ b/bin/varnishtest/tests/s00005.vtc @@ -0,0 +1,129 @@ +varnishtest "Test VCL labels" + +server s1 { + rxreq + txresp +} -start + +varnish v1 -vcl+backend {} + +# VCL name must be C-names +varnish v1 -clierr 106 {vcl.inline 0000 "vcl 4.0; backend b { .host = \"localhost\";} "} +varnish v1 -clierr 106 {vcl.inline a00/ "vcl 4.0; backend b { .host = \"localhost\";} "} +varnish v1 -clierr 106 {vcl.inline a00? "vcl 4.0; backend b { .host = \"localhost\";} "} + +varnish v1 -vcl+backend { + sub vcl_recv { + return (synth(400)); + } +} + +varnish v1 -start + +client c1 { + txreq + rxresp + expect resp.status == 400 +} -run + +varnish v1 -cliok "vcl.use vcl1" + +client c1 { + txreq + rxresp + expect resp.status == 200 +} -run + +varnish v1 -cliok "vcl.list" +varnish v1 -clierr 106 "vcl.label foo vcl0" +varnish v1 -cliok "vcl.label foo vcl2" +varnish v1 -cliok "vcl.label bar vcl2" +varnish v1 -cliok "vcl.list" +varnish v1 -clierr 300 "vcl.discard vcl2" +varnish v1 -cliok "vcl.discard bar" +varnish v1 -cliok "vcl.label foo vcl1" +varnish v1 -clierr 106 "vcl.label vcl1 vcl2" +varnish v1 -clierr 106 "vcl.state foo cold" +varnish v1 -clierr 300 "vcl.label bar foo" +varnish v1 -clierr 300 "vcl.discard vcl1" +varnish v1 -cliok "vcl.list" +varnish v1 -cliok "vcl.use foo" +varnish v1 -clierr 300 "vcl.discard foo" +varnish v1 -cliok "vcl.list" + +client c1 -run + +varnish v1 -cliok "vcl.label foo vcl2" + +client c1 { + txreq + rxresp + expect resp.status == 400 +} -run + +varnish v1 -cliok "vcl.use vcl1" +varnish v1 -cliok "vcl.list" + +client c1 { + txreq + rxresp + expect resp.status == 200 +} -run + +varnish v1 -cliok "vcl.discard foo" +varnish v1 -clierr 106 "vcl.discard foo" + +varnish v1 -stop +varnish v1 -cliok "vcl.list" +varnish v1 -clierr 106 "vcl.label fo- vcl0" +varnish v1 -cliok "vcl.label fo- vcl1" +varnish v1 -clierr 300 "vcl.label bar fo-" +varnish v1 -clierr 200 "vcl.state vcl1 warm" +varnish v1 -clierr 200 "vcl.state vcl1 auto" +varnish v1 -clierr 300 "vcl.state vcl1 cold" +varnish v1 -clierr 300 "vcl.discard vcl1" +varnish v1 -cliok "vcl.list" +varnish v1 -cliok "vcl.use fo-" +varnish v1 -clierr 300 "vcl.discard fo-" +varnish v1 -cliok "vcl.list" + +server s1 -start + +varnish v1 -start +client c1 -run +varnish v1 -stop +varnish v1 -cliok "vcl.use vcl1" +varnish v1 -cliok "vcl.discard fo-" +varnish v1 -clierr 106 "vcl.discard fo-" + +varnish v1 -cliok "vcl.label label1 vcl1" +varnish v1 -cliok "vcl.label label2 vcl1" +varnish v1 -cliok "vcl.label label3 vcl1" +varnish v1 -cliok "vcl.list" + +varnish v1 -start +varnish v1 -cliok "vcl.list" +varnish v1 -cliok "vcl.label snarf vcl1" +server s1 -start +client c1 -run + +# Test loop detection +####################################################################### + +varnish v1 -cliok vcl.list + +varnish v1 -vcl+backend { } + +varnish v1 -cliok "vcl.label lblA vcl3" + +varnish v1 -vcl+backend { sub vcl_recv { return (vcl(lblA)); } } + +varnish v1 -cliok "vcl.label lblB vcl4" + +varnish v1 -vcl+backend { sub vcl_recv { return (vcl(lblB)); } } + +varnish v1 -clierr 106 "vcl.label lblA vcl5" +varnish v1 -cliexpect \ + {can only be used from the active VCL} \ + {vcl.label lblA vcl5} + diff --git a/bin/varnishtest/tests/v00048.vtc b/bin/varnishtest/tests/v00048.vtc deleted file mode 100644 index 67cd3a9..0000000 --- a/bin/varnishtest/tests/v00048.vtc +++ /dev/null @@ -1,129 +0,0 @@ -varnishtest "Test VCL labels" - -server s1 { - rxreq - txresp -} -start - -varnish v1 -vcl+backend {} - -# VCL name must be C-names -varnish v1 -clierr 106 {vcl.inline 0000 "vcl 4.0; backend b { .host = \"localhost\";} "} -varnish v1 -clierr 106 {vcl.inline a00/ "vcl 4.0; backend b { .host = \"localhost\";} "} -varnish v1 -clierr 106 {vcl.inline a00? "vcl 4.0; backend b { .host = \"localhost\";} "} - -varnish v1 -vcl+backend { - sub vcl_recv { - return (synth(400)); - } -} - -varnish v1 -start - -client c1 { - txreq - rxresp - expect resp.status == 400 -} -run - -varnish v1 -cliok "vcl.use vcl1" - -client c1 { - txreq - rxresp - expect resp.status == 200 -} -run - -varnish v1 -cliok "vcl.list" -varnish v1 -clierr 106 "vcl.label foo vcl0" -varnish v1 -cliok "vcl.label foo vcl2" -varnish v1 -cliok "vcl.label bar vcl2" -varnish v1 -cliok "vcl.list" -varnish v1 -clierr 300 "vcl.discard vcl2" -varnish v1 -cliok "vcl.discard bar" -varnish v1 -cliok "vcl.label foo vcl1" -varnish v1 -clierr 106 "vcl.label vcl1 vcl2" -varnish v1 -clierr 106 "vcl.state foo cold" -varnish v1 -clierr 300 "vcl.label bar foo" -varnish v1 -clierr 300 "vcl.discard vcl1" -varnish v1 -cliok "vcl.list" -varnish v1 -cliok "vcl.use foo" -varnish v1 -clierr 300 "vcl.discard foo" -varnish v1 -cliok "vcl.list" - -client c1 -run - -varnish v1 -cliok "vcl.label foo vcl2" - -client c1 { - txreq - rxresp - expect resp.status == 400 -} -run - -varnish v1 -cliok "vcl.use vcl1" -varnish v1 -cliok "vcl.list" - -client c1 { - txreq - rxresp - expect resp.status == 200 -} -run - -varnish v1 -cliok "vcl.discard foo" -varnish v1 -clierr 106 "vcl.discard foo" - -varnish v1 -stop -varnish v1 -cliok "vcl.list" -varnish v1 -clierr 106 "vcl.label fo- vcl0" -varnish v1 -cliok "vcl.label fo- vcl1" -varnish v1 -clierr 300 "vcl.label bar fo-" -varnish v1 -clierr 200 "vcl.state vcl1 warm" -varnish v1 -clierr 200 "vcl.state vcl1 auto" -varnish v1 -clierr 300 "vcl.state vcl1 cold" -varnish v1 -clierr 300 "vcl.discard vcl1" -varnish v1 -cliok "vcl.list" -varnish v1 -cliok "vcl.use fo-" -varnish v1 -clierr 300 "vcl.discard fo-" -varnish v1 -cliok "vcl.list" - -server s1 -start - -varnish v1 -start -client c1 -run -varnish v1 -stop -varnish v1 -cliok "vcl.use vcl1" -varnish v1 -cliok "vcl.discard fo-" -varnish v1 -clierr 106 "vcl.discard fo-" - -varnish v1 -cliok "vcl.label label1 vcl1" -varnish v1 -cliok "vcl.label label2 vcl1" -varnish v1 -cliok "vcl.label label3 vcl1" -varnish v1 -cliok "vcl.list" - -varnish v1 -start -varnish v1 -cliok "vcl.list" -varnish v1 -cliok "vcl.label snarf vcl1" -server s1 -start -client c1 -run - -# Test loop detection -####################################################################### - -varnish v1 -cliok vcl.list - -varnish v1 -vcl+backend { } - -varnish v1 -cliok "vcl.label lblA vcl3" - -varnish v1 -vcl+backend { sub vcl_recv { return (vcl(lblA)); } } - -varnish v1 -cliok "vcl.label lblB vcl4" - -varnish v1 -vcl+backend { sub vcl_recv { return (vcl(lblB)); } } - -varnish v1 -clierr 106 "vcl.label lblA vcl5" -varnish v1 -cliexpect \ - {can only be used from the active VCL} \ - {vcl.label lblA vcl5} - From fgsch at lodoss.net Fri Jan 27 20:12:04 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Fri, 27 Jan 2017 21:12:04 +0100 Subject: [master] 311c2e1 Correct previous Message-ID: commit 311c2e1695174efb9e4beb4850e4ab32a93b6bce Author: Federico G. Schwindt Date: Fri Jan 27 20:00:58 2017 +0000 Correct previous diff --git a/bin/varnishtest/tests/c00003.vtc b/bin/varnishtest/tests/c00003.vtc index 270be73..1103129 100644 --- a/bin/varnishtest/tests/c00003.vtc +++ b/bin/varnishtest/tests/c00003.vtc @@ -1,11 +1,11 @@ varnishtest "Check that we fail to start with erroneous -a/-b arguments" -server s1 {} -varnish v1 -vcl+backend {} -start -varnish v1 -stop +varnish v1 -vcl { + backend dummy { .host = "${bad_backend}"; } +} -start -stop # Duplicate -a arguments -shell -err -expect "have same address" { +shell -err -match "have same address|already in use" { varnishd -d -a 127.0.0.1:${v1_port} -a 127.0.0.1:${v1_port} \ -b localhost:80 } From phk at FreeBSD.org Fri Jan 27 20:45:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 27 Jan 2017 21:45:05 +0100 Subject: [master] bfd84dd Dramatically simplify VEV Message-ID: commit bfd84dd94779b9c0cbcd19b01fdcfd35cddb0298 Author: Poul-Henning Kamp Date: Fri Jan 27 20:42:24 2017 +0000 Dramatically simplify VEV Fixes: #2200 diff --git a/bin/varnishtest/tests/c00057.vtc b/bin/varnishtest/tests/c00057.vtc index df4767b..ba0ec1e 100644 --- a/bin/varnishtest/tests/c00057.vtc +++ b/bin/varnishtest/tests/c00057.vtc @@ -18,6 +18,6 @@ client c1 { txreq } -run -delay 5 +delay 7 varnish v1 -cliok "panic.show" diff --git a/include/vev.h b/include/vev.h index 37db60f..47fd050 100644 --- a/include/vev.h +++ b/include/vev.h @@ -41,6 +41,7 @@ struct vev { const char *name; int fd; unsigned fd_flags; + unsigned fd_events; #define EV_RD POLLIN #define EV_WR POLLOUT #define EV_ERR POLLERR @@ -54,11 +55,9 @@ struct vev { /* priv */ double __when; - VTAILQ_ENTRY(vev) __list; unsigned __binheap_idx; unsigned __privflags; struct vev_base *__vevb; - int __poll_idx; }; struct vev_base *vev_new_base(void); diff --git a/lib/libvarnish/vev.c b/lib/libvarnish/vev.c index e3f10cf..e124ba3 100644 --- a/lib/libvarnish/vev.c +++ b/lib/libvarnish/vev.c @@ -43,7 +43,6 @@ #include "vas.h" #include "binary_heap.h" -#include "vqueue.h" #include "vev.h" #include "vtim.h" @@ -67,13 +66,11 @@ static int vev_nsig; struct vev_base { unsigned magic; #define VEV_BASE_MAGIC 0x477bcf3d - VTAILQ_HEAD(,vev) events; struct pollfd *pfd; + struct vev **pev; unsigned npfd; unsigned lpfd; struct binheap *binheap; - unsigned char compact_pfd; - unsigned char disturbed; unsigned psig; pthread_t thread; #ifdef DEBUG_EVENTS @@ -90,6 +87,7 @@ struct vev_base { } while (0); #else #define DBG(evb, ...) /* ... */ +//#define DBG(evb, ...) fprintf(stderr, __VA_ARGS__); #endif /*--------------------------------------------------------------------*/ @@ -102,7 +100,14 @@ vev_bh_update(void *priv, void *a, unsigned u) CAST_OBJ_NOTNULL(evb, priv, VEV_BASE_MAGIC); CAST_OBJ_NOTNULL(e, a, VEV_MAGIC); + assert(u < evb->lpfd); e->__binheap_idx = u; + if (u != BINHEAP_NOIDX) { + evb->pev[u] = e; + evb->pfd[u].fd = e->fd; + evb->pfd[u].events = + e->fd_flags & (EV_RD|EV_WR|EV_ERR|EV_HUP); + } } static int __match_proto__(binheap_cmp_t) @@ -123,7 +128,6 @@ static int vev_get_pfd(struct vev_base *evb) { unsigned u; - void *p; if (evb->lpfd + 1 < evb->npfd) return (0); @@ -134,11 +138,11 @@ vev_get_pfd(struct vev_base *evb) u = evb->npfd + 256; else u = evb->npfd * 2; - p = realloc(evb->pfd, sizeof *evb->pfd * u); - if (p == NULL) - return (1); evb->npfd = u; - evb->pfd = p; + evb->pfd = realloc(evb->pfd, sizeof(*evb->pfd) * u); + AN(evb->pfd); + evb->pev = realloc(evb->pev, sizeof(*evb->pev) * u); + AN(evb->pev); return (0); } @@ -190,12 +194,12 @@ vev_new_base(void) evb = calloc(sizeof *evb, 1); if (evb == NULL) return (evb); + evb->lpfd = BINHEAP_NOIDX + 1; if (vev_get_pfd(evb)) { free(evb); return (NULL); } evb->magic = VEV_BASE_MAGIC; - VTAILQ_INIT(&evb->events); evb->binheap = binheap_new(evb, vev_bh_cmp, vev_bh_update); evb->thread = pthread_self(); #ifdef DEBUG_EVENTS @@ -248,13 +252,14 @@ vev_add(struct vev_base *evb, struct vev *e) assert(evb->thread == pthread_self()); DBG(evb, "ev_add(%p) fd = %d\n", e, e->fd); - if (e->sig > 0 && vev_get_sig(e->sig)) - return (ENOMEM); - - if (e->fd >= 0 && vev_get_pfd(evb)) + if (vev_get_pfd(evb)) return (ENOMEM); if (e->sig > 0) { + if (vev_get_sig(e->sig)) + return (ENOMEM); + + assert(e->fd < 0); es = &vev_sigs[e->sig]; if (es->vev != NULL) return (EBUSY); @@ -267,36 +272,19 @@ vev_add(struct vev_base *evb, struct vev *e) es = NULL; } - if (e->fd >= 0) { - assert(evb->lpfd < evb->npfd); - evb->pfd[evb->lpfd].fd = e->fd; - evb->pfd[evb->lpfd].events = - e->fd_flags & (EV_RD|EV_WR|EV_ERR|EV_HUP); - e->__poll_idx = evb->lpfd; - evb->lpfd++; - DBG(evb, "... pidx = %d lpfd = %d\n", - e->__poll_idx, evb->lpfd); - } else - e->__poll_idx = -1; - e->magic = VEV_MAGIC; /* before binheap_insert() */ - if (e->timeout != 0.0) { + if (e->timeout != 0.0) e->__when += VTIM_mono() + e->timeout; - binheap_insert(evb->binheap, e); - assert(e->__binheap_idx > 0); - DBG(evb, "... bidx = %d\n", e->__binheap_idx); - } else { - e->__when = 0.0; - e->__binheap_idx = 0; - } + else + e->__when = 9e99; + + evb->lpfd++; + binheap_insert(evb->binheap, e); + assert(e->__binheap_idx != BINHEAP_NOIDX); e->__vevb = evb; e->__privflags = 0; - if (e->fd < 0) - VTAILQ_INSERT_TAIL(&evb->events, e, __list); - else - VTAILQ_INSERT_HEAD(&evb->events, e, __list); if (e->sig > 0) { assert(es != NULL); @@ -315,24 +303,16 @@ vev_del(struct vev_base *evb, struct vev *e) CHECK_OBJ_NOTNULL(evb, VEV_BASE_MAGIC); CHECK_OBJ_NOTNULL(e, VEV_MAGIC); - DBG(evb, "ev_del(%p) fd = %d\n", e, e->fd); + DBG(evb, "ev_del(%p) fd = %d i=%u L=%d\n", e, e->fd, e->__binheap_idx, evb->lpfd); assert(evb == e->__vevb); assert(evb->thread == pthread_self()); + assert(evb->pev[e->__binheap_idx] == e); - if (e->__binheap_idx != 0) - binheap_delete(evb->binheap, e->__binheap_idx); - AZ(e->__binheap_idx); - - if (e->fd >= 0) { - DBG(evb, "... pidx = %d\n", e->__poll_idx); - evb->pfd[e->__poll_idx].fd = -1; - if (e->__poll_idx == evb->lpfd - 1) - evb->lpfd--; - else - evb->compact_pfd++; - e->fd = -1; - DBG(evb, "... lpfd = %d\n", evb->lpfd); - } + assert(e->__binheap_idx != BINHEAP_NOIDX); + e->fd = -1; + binheap_delete(evb->binheap, e->__binheap_idx); + assert(e->__binheap_idx == BINHEAP_NOIDX); + evb->lpfd--; if (e->sig > 0) { assert(e->sig < vev_nsig); @@ -346,12 +326,8 @@ vev_del(struct vev_base *evb, struct vev *e) es->happened = 0; } - VTAILQ_REMOVE(&evb->events, e, __list); - e->magic = 0; e->__vevb = NULL; - - evb->disturbed = 1; } /*--------------------------------------------------------------------*/ @@ -371,38 +347,6 @@ vev_schedule(struct vev_base *evb) /*--------------------------------------------------------------------*/ -static void -vev_compact_pfd(struct vev_base *evb) -{ - unsigned u; - struct pollfd *p; - struct vev *ep; - int lfd; - - DBG(evb, "compact_pfd() lpfd = %d\n", evb->lpfd); - p = evb->pfd; - for (u = 0; u < evb->lpfd; u++, p++) { - DBG(evb, "...[%d] fd = %d\n", u, p->fd); - if (p->fd >= 0) - continue; - if (u == evb->lpfd - 1) - break; - lfd = evb->pfd[evb->lpfd - 1].fd; - VTAILQ_FOREACH(ep, &evb->events, __list) - if (ep->fd == lfd) - break; - AN(ep); - DBG(evb, "...[%d] move %p pidx %d\n", u, ep, ep->__poll_idx); - *p = evb->pfd[--evb->lpfd]; - ep->__poll_idx = u; - } - evb->lpfd = u; - evb->compact_pfd = 0; - DBG(evb, "... lpfd = %d\n", evb->lpfd); -} - -/*--------------------------------------------------------------------*/ - static int vev_sched_timeout(struct vev_base *evb, struct vev *e, double t) { @@ -449,16 +393,20 @@ int vev_schedule_one(struct vev_base *evb) { double t; - struct vev *e, *e2, *e3; - int i, j, tmo; - struct pollfd *pfd; + struct vev *e; + int i, j, k, tmo; CHECK_OBJ_NOTNULL(evb, VEV_BASE_MAGIC); assert(evb->thread == pthread_self()); + assert(evb->lpfd < evb->npfd); + + if (evb->psig) + return (vev_sched_signal(evb)); + e = binheap_root(evb->binheap); if (e != NULL) { CHECK_OBJ_NOTNULL(e, VEV_MAGIC); - assert(e->__binheap_idx == 1); + assert(e->__binheap_idx == BINHEAP_NOIDX + 1); t = VTIM_mono(); if (e->__when <= t) return (vev_sched_timeout(evb, e, t)); @@ -468,54 +416,43 @@ vev_schedule_one(struct vev_base *evb) } else tmo = INFTIM; - if (evb->compact_pfd) - vev_compact_pfd(evb); - - if (tmo == INFTIM && evb->lpfd == 0) + if (tmo == INFTIM && evb->lpfd == BINHEAP_NOIDX + 1) return (0); - if (evb->psig) - return (vev_sched_signal(evb)); - assert(evb->lpfd < evb->npfd); - i = poll(evb->pfd, evb->lpfd, tmo); + i = poll(evb->pfd + 1, evb->lpfd - 1, tmo); if (i == -1 && errno == EINTR) return (vev_sched_signal(evb)); + if (i == 0) { assert(e != NULL); t = VTIM_mono(); if (e->__when <= t) return (vev_sched_timeout(evb, e, t)); } - evb->disturbed = 0; - VTAILQ_FOREACH_SAFE(e, &evb->events, __list, e2) { - if (i == 0) - break; - if (e->fd < 0) - continue; - assert(e->__poll_idx < evb->lpfd); - pfd = &evb->pfd[e->__poll_idx]; - assert(pfd->fd == e->fd); - if (!pfd->revents) - continue; - DBG(evb, "callback(%p) fd = %d what = 0x%x pidx = %d\n", - e, e->fd, pfd->revents, e->__poll_idx); - j = e->callback(e, pfd->revents); - i--; - if (evb->disturbed) { - VTAILQ_FOREACH(e3, &evb->events, __list) { - if (e3 == e) { - e3 = VTAILQ_NEXT(e, __list); - break; - } else if (e3 == e2) - break; + + k = 0; + for(j = 1; j < evb->lpfd; j++) { + evb->pev[j]->fd_events = evb->pfd[j].revents; + if (evb->pev[j]->fd_events) + k++; + } + assert(k == i); + + DBG(evb, "EVENTS %d\n", i); + while (i > 0) { + for(j = BINHEAP_NOIDX + 1; j < evb->lpfd; j++) { + e = evb->pev[j]; + if (e->fd_events == 0) + continue; + DBG(evb, "EVENT %p j=%d fd=%d ev=0x%x %d\n", + e, j, e->fd, e->fd_events, i); + k = e->callback(e, e->fd_events); + e->fd_events = 0; + i--; + if (k) { + vev_del(evb, e); + free(e); } - e2 = e3; - evb->disturbed = 0; - } - if (j) { - vev_del(evb, e); - evb->disturbed = 0; - free(e); } } AZ(i); From varnish-commit at varnish-cache.org Fri Jan 27 14:15:21 2017 From: varnish-commit at varnish-cache.org (varnish-commit at varnish-cache.org) Date: 27 Jan 2017 05:15:21 -0900 Subject: For CV #612 Message-ID: <5F1FDB5BDF9B9F5F1FDB5BDF9B9F5F1F@HI7JI3HHI> Dear varnish-commit, We are looking for employees working remotely. My name is Ethan, I am the personnel manager of a large International company. Most of the work you can do from home, that is, at a distance. Salary is $2400-$5600. If you are interested in this offer, please visit Our Site Have a nice day! -------------- next part -------------- An HTML attachment was scrubbed... URL: From dridi.boukelmoune at gmail.com Sat Jan 28 00:19:04 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Sat, 28 Jan 2017 01:19:04 +0100 Subject: [master] 98f3f95 Retire a misleading construct Message-ID: commit 98f3f95341507bbd19494cf60433fe04de053449 Author: Dridi Boukelmoune Date: Sat Jan 28 01:12:44 2017 +0100 Retire a misleading construct The port may not be hardcoded, it is still available for other processes to steal during the race between `varnish v1 -stop` and the next `varnishd` execution. diff --git a/bin/varnishtest/tests/c00003.vtc b/bin/varnishtest/tests/c00003.vtc index 1103129..52c1269 100644 --- a/bin/varnishtest/tests/c00003.vtc +++ b/bin/varnishtest/tests/c00003.vtc @@ -1,13 +1,9 @@ varnishtest "Check that we fail to start with erroneous -a/-b arguments" -varnish v1 -vcl { - backend dummy { .host = "${bad_backend}"; } -} -start -stop - # Duplicate -a arguments +# XXX: this cannot be tested reliably, we tolerate port collision shell -err -match "have same address|already in use" { - varnishd -d -a 127.0.0.1:${v1_port} -a 127.0.0.1:${v1_port} \ - -b localhost:80 + varnishd -d -a 127.0.0.1:38484 -a 127.0.0.1:38484 -b localhost:80 } # -a bad protocol specs From dridi.boukelmoune at gmail.com Sat Jan 28 00:19:04 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Sat, 28 Jan 2017 01:19:04 +0100 Subject: [master] b5d65c1 Polish Message-ID: commit b5d65c1ab3ce373505c683a1f61270785f3e4272 Author: Dridi Boukelmoune Date: Sat Jan 28 01:16:32 2017 +0100 Polish diff --git a/bin/varnishtest/tests/c00003.vtc b/bin/varnishtest/tests/c00003.vtc index 52c1269..01adffd 100644 --- a/bin/varnishtest/tests/c00003.vtc +++ b/bin/varnishtest/tests/c00003.vtc @@ -7,20 +7,22 @@ shell -err -match "have same address|already in use" { } # -a bad protocol specs -shell -err -expect "Too many sub-arguments" \ - "varnishd -a 127.0.0.1:80000,PROXY,FOO -d 2>&1" -shell -err -expect "Too many sub-arguments" \ - "varnishd -a 127.0.0.1:80000,HTTP/1,FOO -d 2>&1" +shell -err -expect "Too many sub-arguments" { + varnishd -a 127.0.0.1:80000,PROXY,FOO -d +} +shell -err -expect "Too many sub-arguments" { + varnishd -a 127.0.0.1:80000,HTTP/1,FOO -d +} # This requires non-local binds to be disabled. If you see this fail # and are on Linux, ensure /proc/net/ipv4/ip_nonlocal_bind is set to 0. # All bad listen addresses shell -err -expect "Error: Could not get socket" { - varnishd -F -a "${bad_ip}:0" -b '***' -n ${tmpdir} 2>&1 + varnishd -F -a "${bad_ip}:0" -b '***' -n ${tmpdir} } # old style address list shell -err -expect "Unknown protocol" { - varnishd -F -a "127.0.0.1:0,${bad_ip}:0" -b '***' -n ${tmpdir} 2>&1 + varnishd -F -a "127.0.0.1:0,${bad_ip}:0" -b '***' -n ${tmpdir} } From varnish-commit at varnish-cache.org Sat Jan 28 15:23:12 2017 From: varnish-commit at varnish-cache.org (varnish-commit at varnish-cache.org) Date: 28 Jan 2017 22:23:12 +0700 Subject: Compliments Message-ID: <002d01d2797f$02479d69$10d09bbf$@varnish-cache.org> Dear varnish-commit, We are looking for employees working remotely. My name is Hector, I am the personnel manager of a large International company. Most of the work you can do from home, that is, at a distance. Salary is $2900-$5500. If you are interested in this offer, please visit Our Site Have a nice day! -------------- next part -------------- An HTML attachment was scrubbed... URL: From fgsch at lodoss.net Sat Jan 28 18:03:04 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sat, 28 Jan 2017 19:03:04 +0100 Subject: [master] a4e07fc Correct this test for good Message-ID: commit a4e07fc5a611062afddd2fb114d43d793054c15f Author: Federico G. Schwindt Date: Sat Jan 28 14:38:50 2017 +0000 Correct this test for good (Ab)use the bound address used for the bad_backend macro to expose a random port and avoid the dreaded collisions. diff --git a/bin/varnishtest/tests/c00003.vtc b/bin/varnishtest/tests/c00003.vtc index 01adffd..7f271cd 100644 --- a/bin/varnishtest/tests/c00003.vtc +++ b/bin/varnishtest/tests/c00003.vtc @@ -1,9 +1,9 @@ varnishtest "Check that we fail to start with erroneous -a/-b arguments" # Duplicate -a arguments -# XXX: this cannot be tested reliably, we tolerate port collision -shell -err -match "have same address|already in use" { - varnishd -d -a 127.0.0.1:38484 -a 127.0.0.1:38484 -b localhost:80 +shell -err -expect "have same address" { + varnishd -d -a 127.0.0.1:${random_port} \ + -a 127.0.0.1:${random_port} -b localhost:80 } # -a bad protocol specs diff --git a/bin/varnishtest/vtc_main.c b/bin/varnishtest/vtc_main.c index c18f355..29eec9c 100644 --- a/bin/varnishtest/vtc_main.c +++ b/bin/varnishtest/vtc_main.c @@ -499,6 +499,9 @@ ip_magic(void) /* Expose a backend that is forever down. */ extmacro_def("bad_backend", "%s %s", abuf, pbuf); + /* Expose a port that ought to be free */ + extmacro_def("random_port", "%s", pbuf); + /* * We need an IP number which will not repond, ever, and that is a * lot harder than it sounds. This IP# is from RFC5737 and a From fgsch at lodoss.net Sat Jan 28 18:03:04 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sat, 28 Jan 2017 19:03:04 +0100 Subject: [master] cfcfc6a Fix sporadic timeouts if we got cancelled Message-ID: commit cfcfc6a21575cc9dcd0c16a3785e60df5802c231 Author: Federico G. Schwindt Date: Sat Jan 28 17:32:57 2017 +0000 Fix sporadic timeouts if we got cancelled If we receive a cancellation during pthread_cond_(timed)wait() we will own the mutex on the way out. Avoid locking it twice, otherwise we will deadlock. diff --git a/bin/varnishtest/vtc_barrier.c b/bin/varnishtest/vtc_barrier.c index 8eb0348..ddbf828 100644 --- a/bin/varnishtest/vtc_barrier.c +++ b/bin/varnishtest/vtc_barrier.c @@ -408,6 +408,7 @@ void cmd_barrier(CMD_ARGS) { struct barrier *b, *b2; + int r; (void)priv; (void)cmd; @@ -416,7 +417,8 @@ cmd_barrier(CMD_ARGS) AZ(pthread_mutex_lock(&barrier_mtx)); /* Reset and free */ VTAILQ_FOREACH_SAFE(b, &barriers, list, b2) { - AZ(pthread_mutex_lock(&b->mtx)); + r = pthread_mutex_trylock(&b->mtx); + assert(r == 0 || r == EBUSY); switch (b->type) { case BARRIER_COND: break; From dridi.boukelmoune at gmail.com Sat Jan 28 19:27:04 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Sat, 28 Jan 2017 20:27:04 +0100 Subject: [master] a5a3aff Revert "Correct this test for good" Message-ID: commit a5a3affe70639273f4ec4e85aaaef3c510d4a557 Author: Dridi Boukelmoune Date: Sat Jan 28 20:25:28 2017 +0100 Revert "Correct this test for good" This reverts commit a4e07fc5a611062afddd2fb114d43d793054c15f. It still fails on FreeBSD and SunOS. diff --git a/bin/varnishtest/tests/c00003.vtc b/bin/varnishtest/tests/c00003.vtc index 7f271cd..01adffd 100644 --- a/bin/varnishtest/tests/c00003.vtc +++ b/bin/varnishtest/tests/c00003.vtc @@ -1,9 +1,9 @@ varnishtest "Check that we fail to start with erroneous -a/-b arguments" # Duplicate -a arguments -shell -err -expect "have same address" { - varnishd -d -a 127.0.0.1:${random_port} \ - -a 127.0.0.1:${random_port} -b localhost:80 +# XXX: this cannot be tested reliably, we tolerate port collision +shell -err -match "have same address|already in use" { + varnishd -d -a 127.0.0.1:38484 -a 127.0.0.1:38484 -b localhost:80 } # -a bad protocol specs diff --git a/bin/varnishtest/vtc_main.c b/bin/varnishtest/vtc_main.c index 29eec9c..c18f355 100644 --- a/bin/varnishtest/vtc_main.c +++ b/bin/varnishtest/vtc_main.c @@ -499,9 +499,6 @@ ip_magic(void) /* Expose a backend that is forever down. */ extmacro_def("bad_backend", "%s %s", abuf, pbuf); - /* Expose a port that ought to be free */ - extmacro_def("random_port", "%s", pbuf); - /* * We need an IP number which will not repond, ever, and that is a * lot harder than it sounds. This IP# is from RFC5737 and a From phk at FreeBSD.org Mon Jan 30 08:32:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 30 Jan 2017 09:32:05 +0100 Subject: [master] 34e327d Disallow SES_Close(SC_NULL) Message-ID: commit 34e327d22b5e9b2ee694a18344b54332d8a731db Author: Poul-Henning Kamp Date: Mon Jan 30 08:31:41 2017 +0000 Disallow SES_Close(SC_NULL) diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c index 10bb4bb..82933ab 100644 --- a/bin/varnishd/cache/cache_session.c +++ b/bin/varnishd/cache/cache_session.c @@ -502,12 +502,12 @@ SES_Close(struct sess *sp, enum sess_close reason) { int i; + assert(reason > 0); assert(sp->fd >= 0); i = close(sp->fd); assert(i == 0 || errno != EBADF); /* XXX EINVAL seen */ sp->fd = -(int)reason; - if (reason != SC_NULL) - ses_close_acct(reason); + ses_close_acct(reason); } /*-------------------------------------------------------------------- diff --git a/bin/varnishd/http1/cache_http1_fsm.c b/bin/varnishd/http1/cache_http1_fsm.c index b6fd99a..094294c 100644 --- a/bin/varnishd/http1/cache_http1_fsm.c +++ b/bin/varnishd/http1/cache_http1_fsm.c @@ -171,7 +171,9 @@ http1_req_panic(struct vsb *vsb, const struct req *req) static void __match_proto__(vtr_req_fail_f) http1_req_fail(struct req *req, enum sess_close reason) { - if (req->sp->fd >= 0) + assert(reason > 0); + assert(req->sp->fd != 0); + if (req->sp->fd > 0) SES_Close(req->sp, reason); } @@ -401,6 +403,7 @@ HTTP1_Session(struct worker *wrk, struct req *req) if (!FEATURE(FEATURE_HTTP2)) { VSLb(req->vsl, SLT_Debug, "H2 attempt"); + assert(req->doclose > 0); SES_Close(req->sp, req->doclose); http1_setstate(sp, H1CLEANUP); continue; @@ -418,6 +421,7 @@ HTTP1_Session(struct worker *wrk, struct req *req) req->acct.req_hdrbytes += req->htc->rxbuf_e - req->htc->rxbuf_b; if (i) { + assert(req->doclose > 0); SES_Close(req->sp, req->doclose); http1_setstate(sp, H1CLEANUP); continue; From phk at FreeBSD.org Mon Jan 30 11:30:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 30 Jan 2017 12:30:05 +0100 Subject: [master] 796adf9 More asserting on sp->fd Message-ID: commit 796adf96e217f2cb5b64aa1bb5bef8ded8194b88 Author: Poul-Henning Kamp Date: Mon Jan 30 11:29:13 2017 +0000 More asserting on sp->fd diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c index 82933ab..dc671ea 100644 --- a/bin/varnishd/cache/cache_session.c +++ b/bin/varnishd/cache/cache_session.c @@ -434,6 +434,7 @@ SES_Wait(struct sess *sp, const struct transport *xp) CHECK_OBJ_NOTNULL(xp, TRANSPORT_MAGIC); pp = sp->pool; CHECK_OBJ_NOTNULL(pp, POOL_MAGIC); + assert(sp->fd > 0); /* * XXX: waiter_epoll prevents us from zeroing the struct because * XXX: it keeps state across calls. @@ -503,7 +504,7 @@ SES_Close(struct sess *sp, enum sess_close reason) int i; assert(reason > 0); - assert(sp->fd >= 0); + assert(sp->fd > 0); i = close(sp->fd); assert(i == 0 || errno != EBADF); /* XXX EINVAL seen */ sp->fd = -(int)reason; From fgsch at lodoss.net Mon Jan 30 14:17:05 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Mon, 30 Jan 2017 15:17:05 +0100 Subject: [master] 6f9595e More VCC changes Message-ID: commit 6f9595e6563cf53118048bcb5d1591a6b631b84c Author: Federico G. Schwindt Date: Mon Jan 30 14:08:09 2017 +0000 More VCC changes - Try to distinguish between DURATION, REAL and INT automatically. - Explicitly mention which operands are possible when adding. Related to #2101. diff --git a/bin/varnishtest/tests/v00020.vtc b/bin/varnishtest/tests/v00020.vtc index e76e2cb..e7c0bb5 100644 --- a/bin/varnishtest/tests/v00020.vtc +++ b/bin/varnishtest/tests/v00020.vtc @@ -165,8 +165,7 @@ varnish v1 -errvcl {TIME + TIME not possible.} { } } -# XXX: error message should say something about DURATION -varnish v1 -errvcl {Expected ID got ';'} { +varnish v1 -errvcl {TIME + INT not possible.} { backend b { .host = "127.0.0.1"; } sub vcl_recv { set req.http.foo = now + 1; @@ -187,56 +186,42 @@ varnish v1 -errvcl {INT + TIME not possible.} { } } -# XXX: error message should spot DURATION -varnish v1 -errvcl {Expected ';' got 's'} { +varnish v1 -errvcl {INT + DURATION not possible.} { backend b { .host = "127.0.0.1"; } sub vcl_recv { set req.http.foo = 1 + 1s; } } -# XXX: should spot DURATION -varnish v1 -errvcl {Expected ';' got 's'} { - backend b { .host = "127.0.0.1"; } - sub vcl_recv { - set req.http.foo = 1s; - } -} - -# XXX: should spot DURATION -varnish v1 -errvcl {Expected ';' got 's'} { +varnish v1 -errvcl {DURATION + INT not possible.} { backend b { .host = "127.0.0.1"; } sub vcl_recv { set req.http.foo = 1s + 1; } } -# XXX: should spot DURATION -varnish v1 -errvcl {Expected ';' got 's'} { +varnish v1 -errvcl {DURATION + TIME not possible.} { backend b { .host = "127.0.0.1"; } sub vcl_recv { set req.http.foo = 1s + now; } } -# XXX: should spot DURATION -varnish v1 -errvcl {Expected ';' got 's'} { +varnish v1 -errvcl {DURATION + STRING not possible.} { backend b { .host = "127.0.0.1"; } sub vcl_recv { set req.http.foo = 1s + "foo"; } } -# XXX: should spot DURATION -varnish v1 -errvcl {Expected ';' got 's'} { +varnish v1 -errvcl {STRING + DURATION not possible.} { backend b { .host = "127.0.0.1"; } sub vcl_recv { set req.http.foo = "foo" + 1s; } } -# XXX: should spot DURATION -varnish v1 -errvcl {Expected ID got ';'} { +varnish v1 -errvcl {DURATION + INT not possible.} { backend b { .host = "127.0.0.1"; } sub vcl_recv { set req.ttl = 1s + 1; diff --git a/lib/libvcc/vcc_expr.c b/lib/libvcc/vcc_expr.c index 415d54b..52c0041 100644 --- a/lib/libvcc/vcc_expr.c +++ b/lib/libvcc/vcc_expr.c @@ -847,24 +847,18 @@ vcc_expr4(struct vcc *tl, struct expr **e, vcc_type_t fmt) * XXX: but %a is ugly, isn't it ? */ assert(fmt != VOID); - if (fmt == DURATION) { - vcc_Duration(tl, &d); - ERRCHK(tl); - e1 = vcc_mk_expr(DURATION, "%g", d); - } else if (fmt == BYTES) { + if (fmt == BYTES) { vcc_ByteVal(tl, &d); ERRCHK(tl); e1 = vcc_mk_expr(BYTES, "%.1f", d); - ERRCHK(tl); - } else if (fmt == REAL) { - e1 = vcc_mk_expr(REAL, "%f", vcc_DoubleVal(tl)); - ERRCHK(tl); - } else if (fmt == INT) { - e1 = vcc_mk_expr(INT, "%.*s", PF(tl->t)); - vcc_NextToken(tl); } else { vcc_NumVal(tl, &d, &i); - if (i) + ERRCHK(tl); + if (tl->t->tok == ID) { + e1 = vcc_mk_expr(DURATION, "%g", + d * vcc_TimeUnit(tl)); + ERRCHK(tl); + } else if (i || fmt == REAL) e1 = vcc_mk_expr(REAL, "%f", d); else e1 = vcc_mk_expr(INT, "%ld", (long)d); @@ -1000,12 +994,51 @@ vcc_expr_string_add(struct vcc *tl, struct expr **e, struct expr *e2) } } +static const struct adds { + unsigned op; + vcc_type_t a; + vcc_type_t b; + vcc_type_t fmt; +} vcc_adds[] = { + /* OK */ + { '-', TIME, TIME, DURATION }, + { '+', TIME, DURATION, TIME }, + { '-', TIME, DURATION, TIME }, + { '+', DURATION, DURATION, DURATION }, + { '-', DURATION, DURATION, DURATION }, + { '+', BYTES, BYTES, BYTES }, + { '-', BYTES, BYTES, BYTES }, + { '+', INT, INT, INT }, + { '-', INT, INT, INT }, + { '+', REAL, REAL, REAL }, + { '-', REAL, REAL, REAL }, + { '+', REAL, INT, REAL }, + { '-', REAL, INT, REAL }, + { '+', INT, REAL, REAL }, + { '-', INT, REAL, REAL }, + + /* Error */ + { '+', TIME, INT, VOID }, + { '+', TIME, REAL, VOID }, + { '+', INT, DURATION, VOID }, + { '+', REAL, DURATION, VOID }, + { '+', DURATION, INT, VOID }, + { '+', DURATION, REAL, VOID }, + { '+', DURATION, TIME, VOID }, + { '+', DURATION, STRING, VOID }, + { '+', STRING, DURATION, VOID }, + + { EOI, VOID, VOID, VOID } +}; + static void vcc_expr_add(struct vcc *tl, struct expr **e, vcc_type_t fmt) { + const struct adds *ap; struct expr *e2; vcc_type_t f2; struct token *tk; + char buf[128]; *e = NULL; vcc_expr_mul(tl, e, fmt); @@ -1021,31 +1054,19 @@ vcc_expr_add(struct vcc *tl, struct expr **e, vcc_type_t fmt) vcc_expr_mul(tl, &e2, f2); ERRCHK(tl); -#define ADD_OK(op, a, b, c) \ - if (tk->tok == op[0] && (*e)->fmt == a && e2->fmt == b) { \ - *e = vcc_expr_edit(c, "(\v1 " op " \v2)", *e, e2);\ - continue; \ - } \ - - ADD_OK("-", TIME, TIME, DURATION); - ADD_OK("+", TIME, DURATION, TIME); - ADD_OK("-", TIME, DURATION, TIME); - ADD_OK("+", DURATION, DURATION, DURATION); - ADD_OK("-", DURATION, DURATION, DURATION); - ADD_OK("+", BYTES, BYTES, BYTES); - ADD_OK("-", BYTES, BYTES, BYTES); - ADD_OK("+", INT, INT, INT); - ADD_OK("-", INT, INT, INT); - ADD_OK("+", REAL, REAL, REAL); - ADD_OK("-", REAL, REAL, REAL); - ADD_OK("+", REAL, INT, REAL); - ADD_OK("-", REAL, INT, REAL); - ADD_OK("+", INT, REAL, REAL); - ADD_OK("-", INT, REAL, REAL); - -#undef ADD_OK - - if (tk->tok == '+') { + for (ap = vcc_adds; ap->op != EOI; ap++) { + if (tk->tok == ap->op && (*e)->fmt == ap->a && + e2->fmt == ap->b) + break; + } + + if (ap->fmt != VOID) { + bprintf(buf, "(\v1 %c \v2)", ap->op); + *e = vcc_expr_edit(ap->fmt, buf, *e, e2); + continue; + } + + if (tk->tok == '+' && ap->op == EOI) { if ((*e)->fmt == STRING && e2->fmt == STRING) { vcc_expr_string_add(tl, e, e2); return; From fgsch at lodoss.net Mon Jan 30 17:39:05 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Mon, 30 Jan 2017 18:39:05 +0100 Subject: [master] cb4d034 Fix previous in 32 bits archs Message-ID: commit cb4d034662a6ec3fddaf4019a0fb36b5e9a17c99 Author: Federico G. Schwindt Date: Mon Jan 30 17:29:27 2017 +0000 Fix previous in 32 bits archs diff --git a/lib/libvcc/vcc_expr.c b/lib/libvcc/vcc_expr.c index 52c0041..974a80f 100644 --- a/lib/libvcc/vcc_expr.c +++ b/lib/libvcc/vcc_expr.c @@ -861,7 +861,8 @@ vcc_expr4(struct vcc *tl, struct expr **e, vcc_type_t fmt) } else if (i || fmt == REAL) e1 = vcc_mk_expr(REAL, "%f", d); else - e1 = vcc_mk_expr(INT, "%ld", (long)d); + e1 = vcc_mk_expr(INT, "%ld", + (unsigned long)d); } e1->constant = EXPR_CONST; *e = e1; From dridi.boukelmoune at gmail.com Tue Jan 31 09:57:05 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 31 Jan 2017 10:57:05 +0100 Subject: [master] 3ccc7fb Break Message-ID: commit 3ccc7fbf40fd12e4557acfc4bc49d3ceb1046929 Author: Dridi Boukelmoune Date: Tue Jan 31 10:54:52 2017 +0100 Break diff --git a/bin/varnishd/mgt/mgt_cli.c b/bin/varnishd/mgt/mgt_cli.c index eeeef21..e6a187f 100644 --- a/bin/varnishd/mgt/mgt_cli.c +++ b/bin/varnishd/mgt/mgt_cli.c @@ -567,7 +567,7 @@ mgt_cli_telnet(const char *T_arg) AZ(error); AZ(VSB_finish(vsb)); if (VSB_len(vsb) == 0) - ARGV_ERR("-T %s could not be listened on.", T_arg); + ARGV_ERR("-T %s could not be listened on.\n", T_arg); /* Save in shmem */ mgt_SHM_static_alloc(VSB_data(vsb), VSB_len(vsb) + 1, "Arg", "-T", ""); VSB_destroy(&vsb); From hermunn at varnish-software.com Tue Jan 31 10:40:05 2017 From: hermunn at varnish-software.com (Pål Hermunn Johansen) Date: Tue, 31 Jan 2017 11:40:05 +0100 Subject: [4.1] aee2522 Update changelog Message-ID: commit aee252217aa5c07aad8d5dda8272b21fbcaa291c Author: P?l Hermunn Johansen Date: Tue Jan 31 11:38:30 2017 +0100 Update changelog diff --git a/doc/changes.rst b/doc/changes.rst index 6ac9643..b15ba9a 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -7,17 +7,30 @@ Changes since 4.1.4: Bugs fixed ---------- +* 1704_ - (docfix) Clarify description of fetch_failed counter * 1834_ - Panic in workspace exhaustion conditions * 2106_ - 4.1.3: Varnish crashes with "Assert error in CNT_Request(), cache/cache_req_fsm.c line 820" * 2134_ - Disable Nagle's * 2148_ - varnishncsa cannot decode Authorization header if the format is incorrect. - +* 2168_ - Compare 'bereq.backend' / 'req.backend_hint' + myDirector.backend() does not work +* 2178_ - 4.1 branch does not compile on FreeBSD +* 2188_ - Fix vsm_free (never incremented) +* 2190_ - (docfix)varnishncsa: The %r formatter is NOT equivalent to... +* 2197_ - ESI parser panic on malformed src URL + +.. _1704: https://github.com/varnishcache/varnish-cache/issues/1704 .. _1834: https://github.com/varnishcache/varnish-cache/issues/1834 .. _2106: https://github.com/varnishcache/varnish-cache/issues/2106 .. _2134: https://github.com/varnishcache/varnish-cache/issues/2134 .. _2148: https://github.com/varnishcache/varnish-cache/issues/2148 +.. _2168: https://github.com/varnishcache/varnish-cache/issues/2168 +.. _2178: https://github.com/varnishcache/varnish-cache/issues/2178 +.. _2188: https://github.com/varnishcache/varnish-cache/pull/2188 +.. _2190: https://github.com/varnishcache/varnish-cache/issues/2190 +.. _2197: https://github.com/varnishcache/varnish-cache/issues/2197 ================================ Varnish Cache 4.1.4 (2016-12-01)