From fgsch at lodoss.net Sat Aug 1 10:42:46 2015 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sat, 01 Aug 2015 12:42:46 +0200 Subject: [master] 09b9125 Install vtcp.h as well Message-ID: commit 09b9125567a24b1ac0b2648ffbb193473d24e769 Author: Federico G. Schwindt Date: Sat Aug 1 09:23:40 2015 +0100 Install vtcp.h as well Discussed with Martin. diff --git a/include/Makefile.am b/include/Makefile.am index 8d21912..7088579 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -58,6 +58,7 @@ nobase_pkginclude_HEADERS += \ vsa.h \ vsb.h \ vsha256.h \ + vtcp.h \ vtim.h # Private headers From phk at FreeBSD.org Mon Aug 3 07:00:27 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 03 Aug 2015 09:00:27 +0200 Subject: [master] 2bb8dde Properly encode HTTP headers with weird characters to C identifiers. Message-ID: commit 2bb8ddef13e988216d58b2ed16f40e34db36a0cb Author: Poul-Henning Kamp Date: Mon Aug 3 06:59:20 2015 +0000 Properly encode HTTP headers with weird characters to C identifiers. Please note that using underscore in HTTP headers is considered a really bad idea because many application frameworks map minus to underscore in environment variables. Fixes: #1768 diff --git a/bin/varnishtest/tests/r01768.vtc b/bin/varnishtest/tests/r01768.vtc new file mode 100644 index 0000000..716701a --- /dev/null +++ b/bin/varnishtest/tests/r01768.vtc @@ -0,0 +1,19 @@ +varnishtest "http header collision -/_" + +server s1 { + rxreq + txresp +} -start + +varnish v1 -vcl+backend { + sub vcl_recv { + if (req.http.foo_bar == req.http.foo-bar) { + set req.http.foo_bar = "xxx"; + } + } +} -start + +client c1 { + txreq + rxresp +} -run diff --git a/lib/libvcc/vcc_var.c b/lib/libvcc/vcc_var.c index 0fd45ec..a018f36 100644 --- a/lib/libvcc/vcc_var.c +++ b/lib/libvcc/vcc_var.c @@ -43,43 +43,43 @@ vcc_Var_Wildcard(struct vcc *tl, const struct token *t, const struct symbol *wc) struct symbol *sym; struct var *v; const struct var *vh; - int l, i; - char c; - char buf[258]; - char cnam[256]; + unsigned u; + const char *p, *leaf; + struct vsb *vsb; vh = wc->var; + assert(vh->fmt == HEADER); v = TlAlloc(tl, sizeof *v); AN(v); - - assert(vh->fmt == HEADER); v->name = TlDupTok(tl, t); v->r_methods = vh->r_methods; v->w_methods = vh->w_methods; v->fmt = vh->fmt; + leaf = v->name + vh->len; /* Create a C-name version of the header name */ - l = strlen(v->name + vh->len) + 1; - for (i = 0; i < l - 1; i++) { - c = *(v->name + vh->len + i); - if (vct_isalpha(c) || vct_isdigit(c)) - cnam[i] = c; + vsb = VSB_new_auto(); + AN(vsb); + VSB_printf(vsb, "&VGC_%s_", vh->rname); + for (p = leaf, u = 1; *p != '\0'; p++, u++) + if (vct_isalpha(*p) || vct_isdigit(*p)) + VSB_putc(vsb, *p); else - cnam[i] = '_'; - } - cnam[i] = '\0'; + VSB_printf(vsb, "_%02x_", *p); + AZ(VSB_finish(vsb)); /* Create the static identifier */ - Fh(tl, 0, "static const struct gethdr_s VGC_%s_%s =\n", - vh->rname, cnam); - Fh(tl, 0, " { %s, \"\\%03o%s:\"};\n", - vh->rname, (unsigned)l, v->name + vh->len); - - bprintf(buf, "&VGC_%s_%s", vh->rname, cnam); - v->rname = TlDup(tl, buf); - bprintf(buf, "VRT_SetHdr(ctx, %s,", v->rname); - v->lname = TlDup(tl, buf); + Fh(tl, 0, "static const struct gethdr_s %s =\n", VSB_data(vsb) + 1); + Fh(tl, 0, " { %s, \"\\%03o%s:\"};\n", vh->rname, u, leaf); + + /* Create the symbol r/l values */ + v->rname = TlDup(tl, VSB_data(vsb)); + VSB_clear(vsb); + VSB_printf(vsb, "VRT_SetHdr(ctx, %s,", v->rname); + AZ(VSB_finish(vsb)); + v->lname = TlDup(tl, VSB_data(vsb)); + VSB_delete(vsb); sym = VCC_AddSymbolTok(tl, t, SYM_VAR); AN(sym); From phk at FreeBSD.org Mon Aug 3 07:06:29 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 03 Aug 2015 09:06:29 +0200 Subject: [master] fc5b473 Nitpicking Message-ID: commit fc5b4732bf86d7cccb52c4f5269f2d89a0fd39ff Author: Poul-Henning Kamp Date: Mon Aug 3 07:06:17 2015 +0000 Nitpicking diff --git a/flint.lnt b/flint.lnt index 434c54a..c6b741e 100644 --- a/flint.lnt +++ b/flint.lnt @@ -51,6 +51,7 @@ -emacro(731, assert) // booelan arg to eq/non-eq -emacro(731, xxxassert) // arg to eq/non-eq -emacro(527, WRONG) // unreachable code +-emacro(774, VALID_OBJ) // boolean always true /////////////////////////////////////////////////////////////////////// // diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py index 4db94a3..01de3a7 100755 --- a/lib/libvcc/vmodtool.py +++ b/lib/libvcc/vmodtool.py @@ -743,8 +743,8 @@ class FileSection(object): if re.match("['\"]", l): m = re.match("(['\"]).*?(\\1)", l) if not m: - raise FormatError("Unbalanced quote", - "Unbalanced quote on line %d" % ln) + raise FormatError("Unbalanced quote", + "Unbalanced quote on line %d" % ln) self.tl.append(Token(ln, 0, l[:m.end()])) self.l.insert(0, (ln, l[m.end():])) return From phk at FreeBSD.org Mon Aug 3 07:09:19 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 03 Aug 2015 09:09:19 +0200 Subject: [master] 73817d4 Add forgotten test-case Message-ID: commit 73817d4c288fdd9473bb80f0f358e1461062a47d Author: Poul-Henning Kamp Date: Mon Aug 3 07:09:09 2015 +0000 Add forgotten test-case diff --git a/bin/varnishtest/tests/r01761.vtc b/bin/varnishtest/tests/r01761.vtc new file mode 100644 index 0000000..a146d2b --- /dev/null +++ b/bin/varnishtest/tests/r01761.vtc @@ -0,0 +1,33 @@ +varnishtest "204 response with body" + +server s1 { + rxreq + txresp -status 204 -body "HiHo" +} -start + +varnish v1 -vcl+backend { + sub vcl_backend_response { + if (beresp.http.foo == "bar") { + set beresp.status = 204; + } + } +} -start + +client c1 { + txreq + rxresp + expect resp.status == 503 +} -run + +server s1 { + rxreq + txresp -hdr "Foo: bar" -body "HiHo" +} -start + +client c1 { + txreq -url /2 + rxresp + expect resp.status == 204 + expect resp.http.content-length == "" + expect resp.http.transfer-encoding == "" +} -run From dridi.boukelmoune at gmail.com Mon Aug 3 07:51:49 2015 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 03 Aug 2015 09:51:49 +0200 Subject: [master] f685156 Typos Message-ID: commit f6851567f12cf366665b6bb668f26968e47186d6 Author: Dridi Boukelmoune Date: Mon Aug 3 09:48:30 2015 +0200 Typos diff --git a/flint.lnt b/flint.lnt index c6b741e..c6824f5 100644 --- a/flint.lnt +++ b/flint.lnt @@ -22,7 +22,7 @@ /////////////////////////////////////////////////////////////////////// // System/Posix/Iso-C library related --emacro(747, isnan) // significant coersion +-emacro(747, isnan) // significant coercion // ignore retval -esym(534, printf) @@ -47,8 +47,8 @@ -sem(VAS_Fail, r_no) // does not return -emacro(506, assert) // constant value boolean -emacro(827, assert) // loop not reachable --emacro(774, assert) // booelan always true --emacro(731, assert) // booelan arg to eq/non-eq +-emacro(774, assert) // boolean always true +-emacro(731, assert) // boolean arg to eq/non-eq -emacro(731, xxxassert) // arg to eq/non-eq -emacro(527, WRONG) // unreachable code -emacro(774, VALID_OBJ) // boolean always true @@ -57,7 +57,7 @@ // -esym(759, VSB_*) // header decl could be moved --esym(765, VSB_*) // exten could be made static +-esym(765, VSB_*) // extern could be made static -esym(714, VSB_*) // symb not ref -sem(VSB_new, @p == (1p ? 1p : malloc(1))) -sem(VSB_delete, custodial(1)) From fgsch at lodoss.net Mon Aug 3 09:15:52 2015 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Mon, 03 Aug 2015 11:15:52 +0200 Subject: [master] ac13bad Correct prototypes Message-ID: commit ac13bad3970e0ec0a39ffe8ae14a481ee9e544f0 Author: Federico G. Schwindt Date: Mon Aug 3 09:53:35 2015 +0100 Correct prototypes diff --git a/bin/varnishd/mgt/mgt_acceptor.c b/bin/varnishd/mgt/mgt_acceptor.c index a956b27..f0e9a21 100644 --- a/bin/varnishd/mgt/mgt_acceptor.c +++ b/bin/varnishd/mgt/mgt_acceptor.c @@ -118,7 +118,7 @@ struct mac_help { enum sess_step first_step; }; -static int __match_proto__(vss_resolver_f) +static int __match_proto__(vss_resolved_f) mac_callback(void *priv, const struct suckaddr *sa) { struct mac_help *mh; diff --git a/bin/varnishd/mgt/mgt_cli.c b/bin/varnishd/mgt/mgt_cli.c index f618d5c..da3cf69 100644 --- a/bin/varnishd/mgt/mgt_cli.c +++ b/bin/varnishd/mgt/mgt_cli.c @@ -524,7 +524,7 @@ mgt_cli_secret(const char *S_arg) secret_file = S_arg; } -static int __match_proto__(vss_resolver_f) +static int __match_proto__(vss_resolved_f) mct_callback(void *priv, const struct suckaddr *sa) { int sock; From fgsch at lodoss.net Mon Aug 3 09:15:52 2015 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Mon, 03 Aug 2015 11:15:52 +0200 Subject: [master] 99b85e7 Better Message-ID: commit 99b85e7e4ee6139ddfc601246a57ac5f76c25462 Author: Federico G. Schwindt Date: Mon Aug 3 09:53:55 2015 +0100 Better diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 46f777e..2763f7b 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -137,13 +137,14 @@ cnt_deliver(struct worker *wrk, struct req *req) http_PrintfHeader(req->resp, "X-Varnish: %u", VXID(req->vsl->wid)); - /* We base Age calculation upon the last timestamp taken during - client request processing. This gives some inaccuracy, but - since Age is only full second resolution that shouldn't - matter. (Last request timestamp could be a Start timestamp - taken before the object entered into cache leading to negative - age. Truncate to zero in that case). - */ + /* + * We base Age calculation upon the last timestamp taken during + * client request processing. This gives some inaccuracy, but + * since Age is only full second resolution that shouldn't + * matter. (Last request timestamp could be a Start timestamp + * taken before the object entered into cache leading to negative + * age. Truncate to zero in that case). + */ http_PrintfHeader(req->resp, "Age: %.0f", fmax(0., req->t_prev - req->objcore->exp.t_origin)); From fgsch at lodoss.net Mon Aug 3 09:15:52 2015 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Mon, 03 Aug 2015 11:15:52 +0200 Subject: [master] 561b56c Remove -w option from varnishstat Message-ID: commit 561b56cececb80337df10b9d1ec2daebd7d28333 Author: Federico G. Schwindt Date: Mon Aug 3 10:04:58 2015 +0100 Remove -w option from varnishstat For continuous updates we can always use a shell loop. Fixes #1760. diff --git a/bin/varnishstat/varnishstat.c b/bin/varnishstat/varnishstat.c index 871aca7..2eda2bb 100644 --- a/bin/varnishstat/varnishstat.c +++ b/bin/varnishstat/varnishstat.c @@ -252,8 +252,7 @@ usage(void) #define FMT " %-28s # %s\n" fprintf(stderr, "usage: varnishstat " "[-1lV] [-f field] " - VSC_n_USAGE " " - "[-w delay]\n"); + VSC_n_USAGE "\n"); fprintf(stderr, FMT, "-1", "Print the statistics to stdout."); fprintf(stderr, FMT, "-f field", "Field inclusion glob"); fprintf(stderr, FMT, "", @@ -263,10 +262,6 @@ usage(void) fprintf(stderr, FMT, "-n varnish_name", "The varnishd instance to get logs from"); fprintf(stderr, FMT, "-V", "Display the version number and exit"); - fprintf(stderr, FMT, "-w delay", - "Wait delay seconds between updates." - " Default is 1 second." - " Can also be be used with -1, -x or -j for repeated output."); fprintf(stderr, FMT, "-x", "Print statistics to stdout as XML."); fprintf(stderr, FMT, "-j", @@ -280,14 +275,14 @@ main(int argc, char * const *argv) { int c; struct VSM_data *vd; - double delay = 1.0, t_arg = 5.0, t_start = NAN; - int once = 0, xml = 0, json = 0, do_repeat = 0, f_list = 0, curses = 0; + double t_arg = 5.0, t_start = NAN; + int once = 0, xml = 0, json = 0, f_list = 0, curses = 0; int i; vd = VSM_New(); AN(vd); - while ((c = getopt(argc, argv, VSC_ARGS "1f:lVw:xjt:")) != -1) { + while ((c = getopt(argc, argv, VSC_ARGS "1f:lVxjt:")) != -1) { switch (c) { case '1': once = 1; @@ -313,14 +308,6 @@ main(int argc, char * const *argv) case 'V': VCS_Message("varnishstat"); exit(0); - case 'w': - do_repeat = 1; - delay = VNUM(optarg); - if (isnan(delay)) { - fprintf(stderr, "-w: Syntax error"); - exit(1); - } - break; case 'x': xml = 1; break; @@ -360,7 +347,7 @@ main(int argc, char * const *argv) fprintf(stderr, "%s\n", VSM_Error(vd)); exit(1); } - do_curses(vd, delay); + do_curses(vd, 1.0); exit(0); } @@ -369,24 +356,19 @@ main(int argc, char * const *argv) exit(1); } - while (1) { - if (xml) - do_xml(vd); - else if (json) - do_json(vd); - else if (once) - do_once(vd, VSC_Main(vd, NULL)); - else if (f_list) - list_fields(vd); - else - assert(0); - if (!do_repeat) - break; + if (xml) + do_xml(vd); + else if (json) + do_json(vd); + else if (once) + do_once(vd, VSC_Main(vd, NULL)); + else if (f_list) + list_fields(vd); + else + assert(0); - /* end of output block marker. */ - printf("\n"); + /* end of output block marker. */ + printf("\n"); - (void)usleep(delay * 1e6); - } exit(0); } diff --git a/doc/sphinx/reference/varnishstat.rst b/doc/sphinx/reference/varnishstat.rst index e833706..afa4a0b 100644 --- a/doc/sphinx/reference/varnishstat.rst +++ b/doc/sphinx/reference/varnishstat.rst @@ -15,7 +15,7 @@ Varnish Cache statistics SYNOPSIS ======== -varnishstat [-1] [-x] [-j] [-f field] [-l] [-n varnish_name] [-N filename] [-V] [-w delay] +varnishstat [-1] [-x] [-j] [-f field] [-l] [-n varnish_name] [-N filename] [-V] .. TODO: autogenerate this synopsis like the others. @@ -64,10 +64,6 @@ The following options are available: -V Display the version number and exit. --w delay - Wait delay seconds between updates. The default is 1. Can - also be used with -1, -x or -j for repeated output. - -x Displays the result as XML. From phk at FreeBSD.org Mon Aug 3 10:42:52 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 03 Aug 2015 12:42:52 +0200 Subject: [master] c654ff9 Complain if there are sub-arguments to the -a protocol specs which don't understand them. Message-ID: commit c654ff91a1287d36ac5c61599cb4ae3d6be22236 Author: Poul-Henning Kamp Date: Mon Aug 3 10:28:48 2015 +0000 Complain if there are sub-arguments to the -a protocol specs which don't understand them. Fixes: #1770 diff --git a/bin/varnishd/mgt/mgt_acceptor.c b/bin/varnishd/mgt/mgt_acceptor.c index f0e9a21..0c28a13 100644 --- a/bin/varnishd/mgt/mgt_acceptor.c +++ b/bin/varnishd/mgt/mgt_acceptor.c @@ -192,9 +192,13 @@ MAC_Arg(const char *arg) if (av[2] == NULL || !strcmp(av[2], "HTTP/1")) { mh->first_step = S_STP_H1NEWSESS; mh->proto_name = "HTTP/1"; + if (av[2] != NULL && av[3] != NULL) + ARGV_ERR("Too many sub-arguments to -a(HTTP/1))\n"); } else if (!strcmp(av[2], "PROXY")) { mh->first_step = S_STP_PROXYNEWSESS; mh->proto_name = "PROXY"; + if (av[3] != NULL) + ARGV_ERR("Too many sub-arguments to -a(PROXY))\n"); } else { ARGV_ERR("Unknown protocol '%s'\n", av[2]); } diff --git a/bin/varnishtest/tests/r01770.vtc b/bin/varnishtest/tests/r01770.vtc new file mode 100644 index 0000000..774b050 --- /dev/null +++ b/bin/varnishtest/tests/r01770.vtc @@ -0,0 +1,5 @@ +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" +err_shell "Too many sub-arguments" "${varnishd} -a 127.0.0.1:80000,HTTP/1 -d 2>&1" From phk at FreeBSD.org Mon Aug 3 10:42:52 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 03 Aug 2015 12:42:52 +0200 Subject: [master] b4628df remove debug test Message-ID: commit b4628dfd22d74375132802aeeedf54a736453138 Author: Poul-Henning Kamp Date: Mon Aug 3 10:35:17 2015 +0000 remove debug test diff --git a/bin/varnishtest/tests/r01770.vtc b/bin/varnishtest/tests/r01770.vtc index 774b050..838e44b 100644 --- a/bin/varnishtest/tests/r01770.vtc +++ b/bin/varnishtest/tests/r01770.vtc @@ -2,4 +2,3 @@ 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" -err_shell "Too many sub-arguments" "${varnishd} -a 127.0.0.1:80000,HTTP/1 -d 2>&1" From phk at FreeBSD.org Mon Aug 3 12:56:08 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 03 Aug 2015 14:56:08 +0200 Subject: [master] b26f9ff Don't insist headers have a space after the colon. Message-ID: commit b26f9fff4877fbe1001c7f995df98f9241914e12 Author: Poul-Henning Kamp Date: Mon Aug 3 12:55:44 2015 +0000 Don't insist headers have a space after the colon. Fixes #1765 diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c index 05edd1b..e832992 100644 --- a/bin/varnishd/cache/cache_http.c +++ b/bin/varnishd/cache/cache_http.c @@ -927,9 +927,8 @@ HTTP_GetHdrPack(struct worker *wrk, struct objcore *oc, const char *hdr) while (*ptr != '\0') { if (!strncasecmp(ptr, hdr, l)) { ptr += l; - assert (vct_issp(*ptr)); - ptr++; - assert (!vct_issp(*ptr)); + while (vct_islws(*ptr)) + ptr++; return (ptr); } ptr = strchr(ptr, '\0') + 1; diff --git a/bin/varnishtest/tests/r01765.vtc b/bin/varnishtest/tests/r01765.vtc new file mode 100644 index 0000000..e3d8323 --- /dev/null +++ b/bin/varnishtest/tests/r01765.vtc @@ -0,0 +1,27 @@ +varnishtest "subset headers in packed format" + +server s1 { + rxreq + txresp -hdr "Foo:bar" + rxreq + txresp -hdr "Foo:bax" +} -start + +varnish v1 -vcl+backend { + sub vcl_hit { + if (obj.http.foo == "bar") { + return (pass); + } + } +} -start + +client c1 { + txreq + rxresp + expect resp.http.foo == bar + txreq + rxresp + expect resp.http.foo == bax +} -run + +delay 1 From fgsch at lodoss.net Mon Aug 3 16:36:10 2015 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Mon, 03 Aug 2015 18:36:10 +0200 Subject: [master] 28198ab Drop ExecStartPre Message-ID: commit 28198ab847c60382576c91a916ee4657484dd44f Author: Federico G. Schwindt Date: Mon Aug 3 13:58:54 2015 +0100 Drop ExecStartPre Fixes startup if vcl_dir was specified in DAEMON_OPTS. Reported by Gauthier Delacroix. Discussed with ssm on irc. diff --git a/redhat/varnish.service b/redhat/varnish.service index a4f3355..659dba2 100644 --- a/redhat/varnish.service +++ b/redhat/varnish.service @@ -27,7 +27,6 @@ EnvironmentFile=/etc/varnish/varnish.params Type=forking PIDFile=/var/run/varnish.pid PrivateTmp=true -ExecStartPre=/usr/sbin/varnishd -C -f $VARNISH_VCL_CONF ExecStart=/usr/sbin/varnishd \ -P /var/run/varnish.pid \ -f $VARNISH_VCL_CONF \ From fgsch at lodoss.net Mon Aug 3 16:36:10 2015 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Mon, 03 Aug 2015 18:36:10 +0200 Subject: [master] b8ff3f5 Source the default params only if needed Message-ID: commit b8ff3f5f2c8c7b00cbc172d623871dcef9e535a1 Author: Federico G. Schwindt Date: Mon Aug 3 14:05:32 2015 +0100 Source the default params only if needed Makes this work with multiple instances under systemd. Discussed with ingvar on irc. diff --git a/redhat/varnish_reload_vcl b/redhat/varnish_reload_vcl index be3c21a..2f47f3e 100755 --- a/redhat/varnish_reload_vcl +++ b/redhat/varnish_reload_vcl @@ -33,8 +33,10 @@ VARNISH_SECRET_FILE=\"$VARNISH_SECRET_FILE\" " } -# Read configuration -. /etc/sysconfig/varnish +# Fallback to the default configuration +if [ -z "$VARNISH_VCL_CONF" ]; then + . /etc/sysconfig/varnish +fi $debug && print_debug From fgsch at lodoss.net Mon Aug 3 16:36:10 2015 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Mon, 03 Aug 2015 18:36:10 +0200 Subject: [master] 20d0f0b Fix configtest when vcl_dir is specified Message-ID: commit 20d0f0bb357e88fb95066f15e50e86fa3ea27862 Author: Federico G. Schwindt Date: Mon Aug 3 14:07:33 2015 +0100 Fix configtest when vcl_dir is specified Reported and diff submitted by Gauthier Delacroix on varnish-dev. diff --git a/redhat/varnish.initrc b/redhat/varnish.initrc index 117e334..67b530a 100755 --- a/redhat/varnish.initrc +++ b/redhat/varnish.initrc @@ -126,7 +126,7 @@ rh_status_q() { configtest() { if [ -f "$VARNISH_VCL_CONF" ]; then - $exec -f "$VARNISH_VCL_CONF" -C -n /tmp > /dev/null && echo "Syntax ok" + $exec -f "$VARNISH_VCL_CONF" -C "$DAEMON_OPTS" -n /tmp > /dev/null && echo "Syntax ok" else echo "VARNISH_VCL_CONF is unset or does not point to a file" fi From fgsch at lodoss.net Mon Aug 3 16:36:10 2015 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Mon, 03 Aug 2015 18:36:10 +0200 Subject: [master] 3dde588 Better names and description Message-ID: commit 3dde58867c808d488ddf7b735562a107208443f6 Author: Federico G. Schwindt Date: Mon Aug 3 14:32:15 2015 +0100 Better names and description diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index 37b1985..eab4f90 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -162,9 +162,9 @@ usage(void) #endif fprintf(stderr, FMT, "", " -j unix[,user=][,ccgroup=]"); fprintf(stderr, FMT, "", " -j none"); - fprintf(stderr, FMT, "-l shl,free", "Size of shared memory file"); - fprintf(stderr, FMT, "", " shl: space for SHL records [80m]"); - fprintf(stderr, FMT, "", " free: space for other allocations [1m]"); + fprintf(stderr, FMT, "-l vsl,vsm", "Size of shared memory file"); + fprintf(stderr, FMT, "", " vsl: space for VSL records [80m]"); + fprintf(stderr, FMT, "", " vsm: space for stats counters [1m]"); fprintf(stderr, FMT, "-M address:port", "Reverse CLI destination"); fprintf(stderr, FMT, "-n dir", "varnishd working directory"); fprintf(stderr, FMT, "-P file", "PID file"); diff --git a/doc/sphinx/reference/varnishd.rst b/doc/sphinx/reference/varnishd.rst index 378daff..9506915 100644 --- a/doc/sphinx/reference/varnishd.rst +++ b/doc/sphinx/reference/varnishd.rst @@ -84,11 +84,11 @@ OPTIONS Specify the jailing technology to use. --l +-l - Specifies size of shmlog file. shl is the store for the shared - memory log records [80M] and free is the store for other allocations - [1M]. Scaling suffixes like 'k', 'M' can be used up to (E)xabytes. + Specifies size of shmlog file. vsl is the space for the VSL records + [80M] and vsm is the space for stats counters [1M]. Scaling suffixes + like 'K' and 'M' can be used up to (G)igabytes. Default is 81 Megabytes. -M From fgsch at lodoss.net Mon Aug 3 16:41:29 2015 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Mon, 03 Aug 2015 18:41:29 +0200 Subject: [master] cbf70b7 Update suggested read-only parameters Message-ID: commit cbf70b7beab81e0c4da8957f2cf778ad56d3e9a4 Author: Federico G. Schwindt Date: Mon Aug 3 17:40:51 2015 +0100 Update suggested read-only parameters diff --git a/doc/sphinx/reference/varnishd.rst b/doc/sphinx/reference/varnishd.rst index 9506915..7292a12 100644 --- a/doc/sphinx/reference/varnishd.rst +++ b/doc/sphinx/reference/varnishd.rst @@ -119,9 +119,9 @@ OPTIONS Make the listed parameters read only. This gives the system administrator a way to limit what the Varnish CLI can do. Consider - making parameters such as *user*, *group*, *cc_command*, - *vcc_allow_inline_c* read only as these can potentially be used to - escalate privileges from the CLI. + making parameters such as *cc_command*, *vcc_allow_inline_c* and + *vmod_dir* read only as these can potentially be used to escalate + privileges from the CLI. -S file From fgsch at lodoss.net Mon Aug 3 16:58:33 2015 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Mon, 03 Aug 2015 18:58:33 +0200 Subject: [master] 1bc257d Switch to container-based infrastructure Message-ID: commit 1bc257dbc0592023be04cb4473d9af11f329d1b4 Author: Federico G. Schwindt Date: Mon Aug 3 17:53:25 2015 +0100 Switch to container-based infrastructure diff --git a/.travis.yml b/.travis.yml index 8caad42..164ba4b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,8 +3,12 @@ language: c compiler: - clang - gcc +addons: + apt: + packages: + - python-docutils before_install: - - sudo apt-get install python-docutils - ./autogen.sh - ./configure +sudo: false script: 'make -j3 check VERBOSE=1' From martin at varnish-software.com Tue Aug 4 09:43:14 2015 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Tue, 04 Aug 2015 11:43:14 +0200 Subject: [master] e3e340d Trigger the panic dump handler also on sigabrt Message-ID: commit e3e340d58faaa8bfb2eeed02861cb4b8be328715 Author: Martin Blix Grydeland Date: Tue Aug 4 10:54:54 2015 +0200 Trigger the panic dump handler also on sigabrt This allows for a panic dump and backtrace to be produced on sigabrt. This is useful e.g. when using jemalloc's debug flags, which can through a special environment variable enable memory allocation consistency checks and trigger sigabrt on errors. diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index 5a8a59a..e20f668 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -465,6 +465,9 @@ pan_ic(const char *func, const char *file, int line, const char *cond, memset(&sa, 0, sizeof sa); sa.sa_handler = SIG_DFL; (void)sigaction(SIGSEGV, &sa, NULL); + /* Set SIGABRT back to default so the final abort() has the + desired effect */ + (void)sigaction(SIGABRT, &sa, NULL); switch(kind) { case VAS_WRONG: diff --git a/bin/varnishd/mgt/mgt_child.c b/bin/varnishd/mgt/mgt_child.c index 3a6890a..69c90d8 100644 --- a/bin/varnishd/mgt/mgt_child.c +++ b/bin/varnishd/mgt/mgt_child.c @@ -384,6 +384,7 @@ mgt_launch_child(struct cli *cli) sa.sa_flags = SA_SIGINFO; (void)sigaction(SIGSEGV, &sa, NULL); (void)sigaction(SIGBUS, &sa, NULL); + (void)sigaction(SIGABRT, &sa, NULL); } (void)signal(SIGINT, SIG_DFL); (void)signal(SIGTERM, SIG_DFL); From martin at varnish-software.com Tue Aug 4 09:43:14 2015 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Tue, 04 Aug 2015 11:43:14 +0200 Subject: [master] 5f7d81e Enable our sig{segv, bus, abrt} panic handlers by default. Message-ID: commit 5f7d81eac58ffb42a31788c5d9b39b28f2aea733 Author: Martin Blix Grydeland Date: Tue Aug 4 10:57:09 2015 +0200 Enable our sig{segv,bus,abrt} panic handlers by default. diff --git a/bin/varnishd/mgt/mgt_param_tbl.c b/bin/varnishd/mgt/mgt_param_tbl.c index 9c07c55..fa34aa1 100644 --- a/bin/varnishd/mgt/mgt_param_tbl.c +++ b/bin/varnishd/mgt/mgt_param_tbl.c @@ -419,7 +419,7 @@ struct parspec mgt_parspec[] = { "Install a signal handler which tries to dump debug " "information on segmentation and buserror faults.", MUST_RESTART, - "off", "bool" }, + "on", "bool" }, { "vcl_dir", tweak_string, &mgt_vcl_dir, NULL, NULL, "Directory from which relative VCL filenames (vcl.load and " diff --git a/bin/varnishtest/tests/c00057.vtc b/bin/varnishtest/tests/c00057.vtc index fe8e78e..df4767b 100644 --- a/bin/varnishtest/tests/c00057.vtc +++ b/bin/varnishtest/tests/c00057.vtc @@ -6,7 +6,6 @@ server s1 { } -start varnish v1 -cliok "param.set vcc_allow_inline_c true" -varnish v1 -cliok "param.set sigsegv_handler on" varnish v1 -vcl+backend { C{ #include From martin at varnish-software.com Tue Aug 4 10:03:50 2015 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Tue, 04 Aug 2015 12:03:50 +0200 Subject: [master] 7b573d5 Update parameter description to reflect that it also covers sigabrt Message-ID: commit 7b573d5d16f78ec1c71f3fce264406757aee0ec3 Author: Martin Blix Grydeland Date: Tue Aug 4 12:01:35 2015 +0200 Update parameter description to reflect that it also covers sigabrt We should perhaps rename this parameter away from sigsegv_handler? Maybe error_sighandler? Maybe move it into a feature bit for the disabling instead of a separate parameter too. diff --git a/bin/varnishd/mgt/mgt_param_tbl.c b/bin/varnishd/mgt/mgt_param_tbl.c index fa34aa1..fba9994 100644 --- a/bin/varnishd/mgt/mgt_param_tbl.c +++ b/bin/varnishd/mgt/mgt_param_tbl.c @@ -416,8 +416,9 @@ struct parspec mgt_parspec[] = { "180", "seconds" }, { "sigsegv_handler", tweak_bool, &mgt_param.sigsegv_handler, NULL, NULL, - "Install a signal handler which tries to dump debug " - "information on segmentation and buserror faults.", + "Install a signal handler which tries to dump debug" + " information on segmentation faults, bus errors and abort" + " signals.", MUST_RESTART, "on", "bool" }, { "vcl_dir", tweak_string, &mgt_vcl_dir, From martin at varnish-software.com Tue Aug 4 10:03:50 2015 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Tue, 04 Aug 2015 12:03:50 +0200 Subject: [master] 1955e46 Update params.h to reflect changes in mgt_param_tbl.c Message-ID: commit 1955e4601d9e53758884c598b70eeffca59de173 Author: Martin Blix Grydeland Date: Tue Aug 4 12:03:37 2015 +0200 Update params.h to reflect changes in mgt_param_tbl.c diff --git a/include/tbl/params.h b/include/tbl/params.h index 22addb0..71e9da4 100644 --- a/include/tbl/params.h +++ b/include/tbl/params.h @@ -962,12 +962,12 @@ PARAM( /* var */ sigsegv_handler, /* min */ none, /* max */ none, - /* default */ off, + /* default */ on, /* units */ bool, /* flags */ 0| MUST_RESTART, /* s-text */ "Install a signal handler which tries to dump debug information on " - "segmentation and buserror faults.\n", + "segmentation faults, bus errors and abort signals.\n", /* l-text */ "", /* func */ NULL ) From dridi.boukelmoune at gmail.com Tue Aug 4 13:42:37 2015 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 04 Aug 2015 15:42:37 +0200 Subject: [master] 2bb6565 Parameters cleanup Message-ID: commit 2bb6565fe48725297a702b931ec709dae1d1c619 Author: Dridi Boukelmoune Date: Mon Aug 3 13:00:10 2015 +0200 Parameters cleanup Mark optional parts as such and briefly document components. Sync with the man page. The address part for options -a and -b is technically optional too. diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index eab4f90..899b9ba 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -141,11 +141,14 @@ usage(void) #define FMT " %-28s # %s\n" fprintf(stderr, "usage: varnishd [options]\n"); - fprintf(stderr, FMT, "-a address:port,proto", + fprintf(stderr, FMT, "-a address[:port][,proto]", "HTTP listen address and port (default: *:80)"); - fprintf(stderr, FMT, "-b address:port", "backend address and port"); - fprintf(stderr, FMT, "", " -b "); - fprintf(stderr, FMT, "", " -b ':'"); + fprintf(stderr, FMT, "", " address: defaults to loopback"); + fprintf(stderr, FMT, "", " port: port or service (default: 80)"); + fprintf(stderr, FMT, "", " proto: HTTP/1 (default), PROXY"); + fprintf(stderr, FMT, "-b address[:port]", "backend address and port"); + fprintf(stderr, FMT, "", " address: hostname or IP"); + fprintf(stderr, FMT, "", " port: port or service (default: 80)"); fprintf(stderr, FMT, "-C", "print VCL code compiled to C language"); fprintf(stderr, FMT, "-d", "debug"); fprintf(stderr, FMT, "-F", "Run in foreground"); @@ -162,7 +165,7 @@ usage(void) #endif fprintf(stderr, FMT, "", " -j unix[,user=][,ccgroup=]"); fprintf(stderr, FMT, "", " -j none"); - fprintf(stderr, FMT, "-l vsl,vsm", "Size of shared memory file"); + fprintf(stderr, FMT, "-l vsl[,vsm]", "Size of shared memory file"); fprintf(stderr, FMT, "", " vsl: space for VSL records [80m]"); fprintf(stderr, FMT, "", " vsm: space for stats counters [1m]"); fprintf(stderr, FMT, "-M address:port", "Reverse CLI destination"); diff --git a/doc/sphinx/reference/varnishd.rst b/doc/sphinx/reference/varnishd.rst index 7292a12..f76f031 100644 --- a/doc/sphinx/reference/varnishd.rst +++ b/doc/sphinx/reference/varnishd.rst @@ -15,7 +15,7 @@ HTTP accelerator daemon SYNOPSIS ======== -varnishd [-a address[:port][,PROTO]] [-b host[:port]] [-C] [-d] [-F] [-f config] [-h type[,options]] [-i identity] [-j jail[,jailoptions]] [-l shl[,free]] [-M address:port] [-n name] [-P file] [-p param=value] [-r param[,param...]] [-S secret-file] [-s [name=]kind[,options]] [-T address[:port]] [-t TTL] [-V] [-W waiter] +varnishd [-a address[:port][,PROTO]] [-b host[:port]] [-C] [-d] [-F] [-f config] [-h type[,options]] [-i identity] [-j jail[,jailoptions]] [-l vsl[,vsm]] [-M address:port] [-n name] [-P file] [-p param=value] [-r param[,param...]] [-S secret-file] [-s [name=]kind[,options]] [-T address[:port]] [-t TTL] [-V] [-W waiter] DESCRIPTION =========== From fgsch at lodoss.net Thu Aug 6 08:28:17 2015 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Thu, 06 Aug 2015 10:28:17 +0200 Subject: [master] fbd7295 Typo Message-ID: commit fbd729506628b62b7867353701325eb709f5ded0 Author: Federico G. Schwindt Date: Thu Aug 6 09:16:50 2015 +0100 Typo diff --git a/bin/varnishd/cache/cache_shmlog.c b/bin/varnishd/cache/cache_shmlog.c index 9bb7d1e..07167d4 100644 --- a/bin/varnishd/cache/cache_shmlog.c +++ b/bin/varnishd/cache/cache_shmlog.c @@ -362,7 +362,7 @@ VSLb_ts(struct vsl_log *vsl, const char *event, double first, double *pprev, /* XXX: Make an option to turn off some unnecessary timestamp logging. This must be done carefully because some functions - (e.g. V1L_Reserve) takes the last timestamp as it's inital + (e.g. V1L_Reserve) takes the last timestamp as it's initial value for timeout calculation. */ vsl_sanity(vsl); assert(!isnan(now) && now != 0.); From fgsch at lodoss.net Thu Aug 6 08:28:17 2015 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Thu, 06 Aug 2015 10:28:17 +0200 Subject: [master] 093b112 Fix synth handling and update docs Message-ID: commit 093b11238e6f4e9624b8386893930eacf4060536 Author: Federico G. Schwindt Date: Thu Aug 6 09:17:01 2015 +0100 Fix synth handling and update docs error has been long retired. diff --git a/bin/varnishncsa/varnishncsa.c b/bin/varnishncsa/varnishncsa.c index 257a39d..9283beb 100644 --- a/bin/varnishncsa/varnishncsa.c +++ b/bin/varnishncsa/varnishncsa.c @@ -879,12 +879,12 @@ dispatch_f(struct VSL_data *vsl, struct VSL_transaction * const pt[], } else if (!strcasecmp(b, "pass")) { CTX.hitmiss = "miss"; CTX.handling = "pass"; - } else if (!strcasecmp(b, "error")) { - /* Arguably, error isn't a hit or + } else if (!strcasecmp(b, "synth")) { + /* Arguably, synth isn't a hit or a miss, but miss is less wrong */ CTX.hitmiss = "miss"; - CTX.handling = "error"; + CTX.handling = "synth"; } break; case SLT_VCL_return: diff --git a/doc/sphinx/reference/varnishncsa.rst b/doc/sphinx/reference/varnishncsa.rst index 3ab7759..d98f6e2 100644 --- a/doc/sphinx/reference/varnishncsa.rst +++ b/doc/sphinx/reference/varnishncsa.rst @@ -119,7 +119,7 @@ Supported formatters are: Varnish:handling How the request was handled, whether it was a cache hit, miss, - pass, pipe or error. + pass, pipe or synth. VCL_Log:key Output value set by std.log("key:value") in VCL. From fgsch at lodoss.net Thu Aug 6 09:49:03 2015 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Thu, 06 Aug 2015 11:49:03 +0200 Subject: [master] fd97e54 Spelling and typos Message-ID: commit fd97e5437715be80534013f7d8e06e89a1731b0a Author: Federico G. Schwindt Date: Thu Aug 6 10:45:26 2015 +0100 Spelling and typos diff --git a/bin/varnishd/mgt/mgt_param_tbl.c b/bin/varnishd/mgt/mgt_param_tbl.c index fba9994..565328e 100644 --- a/bin/varnishd/mgt/mgt_param_tbl.c +++ b/bin/varnishd/mgt/mgt_param_tbl.c @@ -178,7 +178,7 @@ struct parspec mgt_parspec[] = { { "timeout_idle", tweak_timeout, &mgt_param.timeout_idle, "0", NULL, "Idle timeout for client connections.\n" - "A connection is considered idle, until we have" + "A connection is considered idle, until we have " "received the full request headers.", 0, "5", "seconds" }, diff --git a/bin/varnishtop/varnishtop_options.h b/bin/varnishtop/varnishtop_options.h index 42c1755..f3529a0 100644 --- a/bin/varnishtop/varnishtop_options.h +++ b/bin/varnishtop/varnishtop_options.h @@ -33,7 +33,7 @@ #define TOP_OPT_1 \ VOPT("1", "[-1]", "Run once", \ - "Instead of a continously updated display, print the" \ + "Instead of a continuously updated display, print the" \ " statistics once and exit. Implies ``-d``." \ ) diff --git a/doc/sphinx/reference/states.rst b/doc/sphinx/reference/states.rst index 098e5a2..2f80f29 100644 --- a/doc/sphinx/reference/states.rst +++ b/doc/sphinx/reference/states.rst @@ -21,7 +21,7 @@ into the respective VCL subroutine. These can then be modified from VCL where necessary. The following graphs attempt to provide an overview over the -processing states, their transisions and the most relevant functions +processing states, their transitions and the most relevant functions in core code. They represent a compromise between usefulness for core/VMOD developers and administrators and are intended to serve as the reference basis for deriavtive work, such as more VCL-centric diff --git a/include/tbl/params.h b/include/tbl/params.h index 71e9da4..36c1b0d 100644 --- a/include/tbl/params.h +++ b/include/tbl/params.h @@ -1232,7 +1232,7 @@ PARAM( /* flags */ 00, /* s-text */ "Idle timeout for client connections.\n" - "A connection is considered idle, until we havereceived the full " + "A connection is considered idle, until we have received the full " "request headers.\n", /* l-text */ "", /* func */ NULL From dridi.boukelmoune at gmail.com Thu Aug 6 12:49:39 2015 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 06 Aug 2015 14:49:39 +0200 Subject: [master] 71a8353 Typo Message-ID: commit 71a83537340a6e881e483b5b0dd3206ffee9d177 Author: Dridi Boukelmoune Date: Thu Aug 6 14:47:56 2015 +0200 Typo diff --git a/bin/varnishd/cache/cache_shmlog.c b/bin/varnishd/cache/cache_shmlog.c index 07167d4..ae49087 100644 --- a/bin/varnishd/cache/cache_shmlog.c +++ b/bin/varnishd/cache/cache_shmlog.c @@ -362,7 +362,7 @@ VSLb_ts(struct vsl_log *vsl, const char *event, double first, double *pprev, /* XXX: Make an option to turn off some unnecessary timestamp logging. This must be done carefully because some functions - (e.g. V1L_Reserve) takes the last timestamp as it's initial + (e.g. V1L_Reserve) takes the last timestamp as its initial value for timeout calculation. */ vsl_sanity(vsl); assert(!isnan(now) && now != 0.); From phk at FreeBSD.org Mon Aug 10 06:55:29 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 10 Aug 2015 08:55:29 +0200 Subject: [master] 560de22 Be a bit more clear on this, hoping Coverity will catch the drift. Message-ID: commit 560de22727110d18fc8006f288fbde9223d5902b Author: Poul-Henning Kamp Date: Mon Aug 10 06:55:04 2015 +0000 Be a bit more clear on this, hoping Coverity will catch the drift. diff --git a/bin/varnishd/mgt/mgt_acceptor.c b/bin/varnishd/mgt/mgt_acceptor.c index 0c28a13..8c80f58 100644 --- a/bin/varnishd/mgt/mgt_acceptor.c +++ b/bin/varnishd/mgt/mgt_acceptor.c @@ -62,13 +62,15 @@ mac_opensocket(struct listen_sock *ls, struct cli *cli) } ls->sock = VTCP_bind(ls->addr, NULL); fail = errno; - if (ls->sock >= 0) - mgt_child_inherit(ls->sock, "sock"); - if (cli != NULL && ls->sock < 0) { - VCLI_Out(cli, "Could not get socket %s: %s\n", - ls->name, strerror(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); } - return (fail); + mgt_child_inherit(ls->sock, "sock"); + return (0); } /*===================================================================== @@ -152,7 +154,7 @@ MAC_Validate(void) VJ_master(JAIL_MASTER_PRIVPORT); fail = mac_opensocket(ls, NULL); VJ_master(JAIL_MASTER_LOW); - if (ls->sock < 0) + if (fail) ARGV_ERR("Cannot open socket: %s: %s\n", ls->name, strerror(fail)); if (VSA_Port(ls->addr) == 0) { From phk at FreeBSD.org Mon Aug 10 08:21:31 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 10 Aug 2015 10:21:31 +0200 Subject: [master] 6097d7b WS may give us more space than we ask for Message-ID: commit 6097d7baa5d88ed045df872ee4ba348580a88af3 Author: Poul-Henning Kamp Date: Mon Aug 10 07:52:41 2015 +0000 WS may give us more space than we ask for diff --git a/bin/varnishd/cache/cache_acceptor.c b/bin/varnishd/cache/cache_acceptor.c index 90965c3..9736ca9 100644 --- a/bin/varnishd/cache/cache_acceptor.c +++ b/bin/varnishd/cache/cache_acceptor.c @@ -364,7 +364,7 @@ vca_make_session(struct worker *wrk, void *arg) vca_tcp_opt_set(sp->fd, 0); /* SES_Proto_Sess() must be sceduled with reserved WS */ - assert(8 == WS_Reserve(sp->ws, 8)); + assert(8 <= WS_Reserve(sp->ws, 8)); wrk->task.func = SES_Proto_Sess; wrk->task.priv = sp; } diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c index 07123fb..9b8d2a5 100644 --- a/bin/varnishd/cache/cache_session.c +++ b/bin/varnishd/cache/cache_session.c @@ -448,7 +448,7 @@ ses_handle(struct waited *wp, enum wait_event ev, double now) case WAITER_ACTION: pp = sp->pool; CHECK_OBJ_NOTNULL(pp, POOL_MAGIC); - assert(sizeof *tp == WS_Reserve(sp->ws, sizeof *tp)); + assert(sizeof *tp <= WS_Reserve(sp->ws, sizeof *tp)); tp = (void*)sp->ws->f; tp->func = SES_Proto_Sess; tp->priv = sp; From phk at FreeBSD.org Mon Aug 10 09:24:04 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 10 Aug 2015 11:24:04 +0200 Subject: [master] a40ceb0 Introduce VTCP_read() which is a timeout-read on tcp sockets. Message-ID: commit a40ceb077e58c1d35f5e27568e745959be8e5007 Author: Poul-Henning Kamp Date: Mon Aug 10 09:23:47 2015 +0000 Introduce VTCP_read() which is a timeout-read on tcp sockets. diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c index 9b8d2a5..56340e0 100644 --- a/bin/varnishd/cache/cache_session.c +++ b/bin/varnishd/cache/cache_session.c @@ -41,7 +41,6 @@ #include "config.h" #include -#include #include #include @@ -197,8 +196,7 @@ SES_RxReInit(struct http_conn *htc) enum htc_status_e SES_Rx(struct http_conn *htc, double tmo) { - int i, j; - struct pollfd pfd[1]; + int i; CHECK_OBJ_NOTNULL(htc, HTTP_CONN_MAGIC); AN(htc->ws->r); @@ -207,18 +205,9 @@ SES_Rx(struct http_conn *htc, double tmo) i = (htc->ws->r - htc->rxbuf_e) - 1; /* space for NUL */ if (i <= 0) return (HTC_S_OVERFLOW); - if (tmo > 0.0) { - pfd[0].fd = htc->fd; - pfd[0].events = POLLIN; - pfd[0].revents = 0; - j = (int)floor(tmo * 1e3); - if (j == 0) - j++; - j = poll(pfd, 1, j); - if (j == 0) - return (HTC_S_TIMEOUT); - } - i = read(htc->fd, htc->rxbuf_e, i); + i = VTCP_read(htc->fd, htc->rxbuf_e, i, tmo); + if (i == -2) + return (HTC_S_TIMEOUT); if (i <= 0) return (HTC_S_EOF); htc->rxbuf_e += i; diff --git a/include/vtcp.h b/include/vtcp.h index f00b44a..a42e768 100644 --- a/include/vtcp.h +++ b/include/vtcp.h @@ -62,4 +62,5 @@ int VTCP_listen(const struct suckaddr *addr, int depth, const char **errp); int VTCP_listen_on(const char *addr, const char *def_port, int depth, const char **errp); void VTCP_set_read_timeout(int s, double seconds); +int VTCP_read(int fd, void *ptr, size_t len, double tmo); // #endif diff --git a/lib/libvarnish/vtcp.c b/lib/libvarnish/vtcp.c index a168c5f..3992555 100644 --- a/lib/libvarnish/vtcp.c +++ b/lib/libvarnish/vtcp.c @@ -554,3 +554,28 @@ VTCP_Check(int a) #endif return (0); } + +/*-------------------------------------------------------------------- + * + */ + +int +VTCP_read(int fd, void *ptr, size_t len, double tmo) +{ + struct pollfd pfd[1]; + int i, j; + + if (tmo > 0.0) { + pfd[0].fd = fd; + pfd[0].events = POLLIN; + pfd[0].revents = 0; + j = (int)floor(tmo * 1e3); + if (j == 0) + j++; + j = poll(pfd, 1, j); + if (j == 0) + return (-2); + } + i = read(fd, ptr, len); + return (i < 0 ? -1 : i); +} From phk at FreeBSD.org Mon Aug 10 09:56:59 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 10 Aug 2015 11:56:59 +0200 Subject: [master] 891889f Retool SES_RxReq() from a REQ specific thing to a general "receive som stuff on this TCP connection with timeouts" function. Message-ID: commit 891889f0d3613fb3e59167f87cc0752876f2bb1d Author: Poul-Henning Kamp Date: Mon Aug 10 09:55:58 2015 +0000 Retool SES_RxReq() from a REQ specific thing to a general "receive som stuff on this TCP connection with timeouts" function. Inpired by colliding patches from Martin & Lasse. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 6719345..4c57c4e 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -980,8 +980,8 @@ void SES_RxInit(struct http_conn *htc, struct ws *ws, unsigned maxbytes, unsigned maxhdr); void SES_RxReInit(struct http_conn *htc); enum htc_status_e SES_Rx(struct http_conn *htc, double tmo); -enum htc_status_e SES_RxReq(const struct worker *, struct req *, - htc_complete_f *func); +enum htc_status_e SES_RxStuff(struct http_conn *, htc_complete_f *, double t0, + double *t1, double *t2, double ti, double tn); #define SESS_ATTR(UP, low, typ, len) \ int SES_Get_##low(const struct sess *sp, typ *dst); \ diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c index 56340e0..7476419 100644 --- a/bin/varnishd/cache/cache_session.c +++ b/bin/varnishd/cache/cache_session.c @@ -217,66 +217,73 @@ SES_Rx(struct http_conn *htc, double tmo) /*---------------------------------------------------------------------- * Receive a request/packet/whatever, with timeouts + * + * t0 is when we start + * *t1 becomes time of first non-idle rx + * *t2 becomes time of complete rx + * ti is when we return IDLE if nothing has arrived + * tn is when we timeout on non-complete */ enum htc_status_e -SES_RxReq(const struct worker *wrk, struct req *req, htc_complete_f *func) +SES_RxStuff(struct http_conn *htc, htc_complete_f *func, double t0, + double *t1, double *t2, double ti, double tn) { double tmo; - double now, when; - struct sess *sp; + double now; enum htc_status_e hs; - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - sp = req->sp; - CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); + CHECK_OBJ_NOTNULL(htc, HTTP_CONN_MAGIC); - AZ(isnan(sp->t_idle)); - assert(isnan(req->t_first)); + AZ(isnan(t0)); + AZ(isnan(tn)); + if (t1 != NULL) + assert(isnan(*t1)); - when = sp->t_idle + cache_param->timeout_idle; - tmo = cache_param->timeout_linger; + now = t0; while (1) { - hs = SES_Rx(req->htc, tmo); - now = VTIM_real(); + if (!isnan(ti)) + tmo = ti - t0; + else + tmo = tn - t0; + hs = SES_Rx(htc, tmo); if (hs == HTC_S_EOF) { - WS_ReleaseP(req->htc->ws, req->htc->rxbuf_b); + WS_ReleaseP(htc->ws, htc->rxbuf_b); return (HTC_S_CLOSE); } if (hs == HTC_S_OVERFLOW) { - WS_ReleaseP(req->htc->ws, req->htc->rxbuf_b); + WS_ReleaseP(htc->ws, htc->rxbuf_b); return (HTC_S_OVERFLOW); } - hs = func(req->htc); + now = VTIM_real(); + hs = func(htc); if (hs == HTC_S_OVERFLOW) { - WS_ReleaseP(req->htc->ws, req->htc->rxbuf_b); + WS_ReleaseP(htc->ws, htc->rxbuf_b); return (HTC_S_OVERFLOW); } if (hs == HTC_S_JUNK) { - WS_ReleaseP(req->htc->ws, req->htc->rxbuf_b); + WS_ReleaseP(htc->ws, htc->rxbuf_b); return (HTC_S_JUNK); } if (hs == HTC_S_COMPLETE) { /* Got it, run with it */ - if (isnan(req->t_first)) - req->t_first = now; - req->t_req = now; + if (t1 != NULL && isnan(*t1)) + *t1 = now; + if (t2 != NULL) + *t2 = now; return (HTC_S_COMPLETE); } - if (when < now) + if (tn < now) return (HTC_S_TIMEOUT); if (hs == HTC_S_MORE) { /* Working on it */ - if (isnan(req->t_first)) - req->t_first = now; - tmo = when - now; + if (t1 != NULL && isnan(*t1)) + *t1 = now; + tmo = tn - now; continue; } assert(hs == HTC_S_EMPTY); - /* Nothing but whitespace */ - tmo = sp->t_idle + cache_param->timeout_linger - now; - if (tmo < 0) + if (ti < now) return (HTC_S_IDLE); } } diff --git a/bin/varnishd/http1/cache_http1_fsm.c b/bin/varnishd/http1/cache_http1_fsm.c index 103ba3b..e66fa96 100644 --- a/bin/varnishd/http1/cache_http1_fsm.c +++ b/bin/varnishd/http1/cache_http1_fsm.c @@ -199,7 +199,10 @@ HTTP1_Session(struct worker *wrk, struct req *req) AZ(req->vcl); AZ(req->esi_level); - hs = SES_RxReq(wrk, req, HTTP1_Complete); + hs = SES_RxStuff(req->htc, HTTP1_Complete, sp->t_idle, + &req->t_first, &req->t_req, + sp->t_idle + cache_param->timeout_linger, + sp->t_idle + cache_param->timeout_idle); if (hs < HTC_S_EMPTY) { req->acct.req_hdrbytes += req->htc->rxbuf_e - req->htc->rxbuf_b; diff --git a/bin/varnishd/proxy/cache_proxy_proto.c b/bin/varnishd/proxy/cache_proxy_proto.c index e359cb0..f3c9caa 100644 --- a/bin/varnishd/proxy/cache_proxy_proto.c +++ b/bin/varnishd/proxy/cache_proxy_proto.c @@ -351,7 +351,8 @@ VPX_Proto_Sess(struct worker *wrk, void *priv) assert(sizeof vpx1_sig == 5); assert(sizeof vpx2_sig == 12); - hs = SES_RxReq(wrk, req, vpx_complete); + hs = SES_RxStuff(req->htc, vpx_complete, sp->t_idle, + NULL, NULL, NAN, sp->t_idle + cache_param->timeout_idle); if (hs != HTC_S_COMPLETE) { Req_Release(req); SES_Delete(sp, SC_RX_JUNK, NAN); @@ -377,8 +378,6 @@ VPX_Proto_Sess(struct worker *wrk, void *priv) req->htc->pipeline_e = req->htc->rxbuf_e; WS_Release(req->htc->ws, 0); SES_RxReInit(req->htc); - req->t_req = NAN; - req->t_first = NAN; req->sp->sess_step = S_STP_H1NEWREQ; wrk->task.func = SES_Proto_Req; wrk->task.priv = req; From phk at FreeBSD.org Mon Aug 10 11:18:38 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 10 Aug 2015 13:18:38 +0200 Subject: [master] 9cd4a90 The ESI_VDP would double-close sessions when a flush error happened before an ESI include at one level, and then again at a higher level. Message-ID: commit 9cd4a9004dbc150bce5b98e31339075e5ab79caf Author: Poul-Henning Kamp Date: Mon Aug 10 11:18:16 2015 +0000 The ESI_VDP would double-close sessions when a flush error happened before an ESI include at one level, and then again at a higher level. Fixed by not closing the session in this case, as that will be taken care of at the end of delivery anyways when V1L_FlushRelease is called. Fixes: #1737 Submitted by: Martin diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index aa011b6..72a7763 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -317,7 +317,6 @@ VDP_ESI(struct req *req, enum vdp_action act, void **priv, r = (void*)strchr((const char*)q, '\0'); AN(r); if (VDP_bytes(req, VDP_FLUSH, NULL, 0)) { - SES_Close(req->sp, SC_REM_CLOSE); ecx->p = ecx->e; break; } diff --git a/bin/varnishtest/tests/r01737.vtc b/bin/varnishtest/tests/r01737.vtc new file mode 100644 index 0000000..66c5aee --- /dev/null +++ b/bin/varnishtest/tests/r01737.vtc @@ -0,0 +1,43 @@ +varnishtest "#1737 - ESI sublevel session close" + +# Build a esi request tree that fails on flush before include at two different +# levels. Synchronize a client close after the response headers have been +# received by the client. This produces write erros for the body parts in all +# fragments. +server s1 { + rxreq + txresp -body {} + sema r1 sync 2 + + rxreq + delay 1 + txresp -body {22} + + rxreq + txresp -body {1} + + rxreq + expect req.url == "/check" + rxresp +} -start + +varnish v1 -vcl+backend { + sub vcl_backend_response { + set beresp.do_esi = true; + } +} -start + +# Send request, read response headers then close connection +client c1 { + txreq + rxresp -no_obj + sema r1 sync 2 +} -run + +delay 3 + +# Check that Varnish is alive +client c1 { + txreq + rxresp +} -run From dridi.boukelmoune at gmail.com Tue Aug 11 07:52:01 2015 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 11 Aug 2015 09:52:01 +0200 Subject: [master] 9e6f88d Add the name of the built-in directors during init Message-ID: commit 9e6f88dede2eec3d366f52ea36076557581b9854 Author: Dridi Boukelmoune Date: Tue Aug 11 09:46:41 2015 +0200 Add the name of the built-in directors during init diff --git a/lib/libvmod_directors/fall_back.c b/lib/libvmod_directors/fall_back.c index 77ec45c..e73b1cf 100644 --- a/lib/libvmod_directors/fall_back.c +++ b/lib/libvmod_directors/fall_back.c @@ -91,7 +91,7 @@ vmod_fallback__init(VRT_CTX, ALLOC_OBJ(rr, VMOD_DIRECTORS_FALLBACK_MAGIC); AN(rr); *rrp = rr; - vdir_new(&rr->vd, vcl_name, vmod_fallback_healthy, + vdir_new(&rr->vd, "fallback", vcl_name, vmod_fallback_healthy, vmod_fallback_resolve, rr); } diff --git a/lib/libvmod_directors/hash.c b/lib/libvmod_directors/hash.c index c3def17..3029c7b 100644 --- a/lib/libvmod_directors/hash.c +++ b/lib/libvmod_directors/hash.c @@ -64,7 +64,7 @@ vmod_hash__init(VRT_CTX, struct vmod_directors_hash **rrp, rr->vbm = vbit_init(8); AN(rr->vbm); *rrp = rr; - vdir_new(&rr->vd, vcl_name, NULL, NULL, rr); + vdir_new(&rr->vd, "hash", vcl_name, NULL, NULL, rr); } VCL_VOID __match_proto__() diff --git a/lib/libvmod_directors/random.c b/lib/libvmod_directors/random.c index a0612f3..2f29887 100644 --- a/lib/libvmod_directors/random.c +++ b/lib/libvmod_directors/random.c @@ -87,8 +87,8 @@ vmod_random__init(VRT_CTX, struct vmod_directors_random **rrp, ALLOC_OBJ(rr, VMOD_DIRECTORS_RANDOM_MAGIC); AN(rr); *rrp = rr; - vdir_new(&rr->vd, vcl_name, vmod_random_healthy, vmod_random_resolve, - rr); + vdir_new(&rr->vd, "random", vcl_name, vmod_random_healthy, + vmod_random_resolve, rr); } VCL_VOID __match_proto__() diff --git a/lib/libvmod_directors/round_robin.c b/lib/libvmod_directors/round_robin.c index be92545..b2acf49 100644 --- a/lib/libvmod_directors/round_robin.c +++ b/lib/libvmod_directors/round_robin.c @@ -94,7 +94,8 @@ vmod_round_robin__init(VRT_CTX, ALLOC_OBJ(rr, VMOD_DIRECTORS_ROUND_ROBIN_MAGIC); AN(rr); *rrp = rr; - vdir_new(&rr->vd, vcl_name, vmod_rr_healthy, vmod_rr_resolve, rr); + vdir_new(&rr->vd, "round-robin", vcl_name, vmod_rr_healthy, + vmod_rr_resolve, rr); } VCL_VOID __match_proto__() diff --git a/lib/libvmod_directors/vdir.c b/lib/libvmod_directors/vdir.c index 938d6de..411df34 100644 --- a/lib/libvmod_directors/vdir.c +++ b/lib/libvmod_directors/vdir.c @@ -51,11 +51,12 @@ vdir_expand(struct vdir *vd, unsigned n) } void -vdir_new(struct vdir **vdp, const char *vcl_name, vdi_healthy_f *healthy, - vdi_resolve_f *resolve, void *priv) +vdir_new(struct vdir **vdp, const char *name, const char *vcl_name, + vdi_healthy_f *healthy, vdi_resolve_f *resolve, void *priv) { struct vdir *vd; + AN(name); AN(vcl_name); AN(vdp); AZ(*vdp); @@ -66,6 +67,7 @@ vdir_new(struct vdir **vdp, const char *vcl_name, vdi_healthy_f *healthy, ALLOC_OBJ(vd->dir, DIRECTOR_MAGIC); AN(vd->dir); + vd->dir->name = name; REPLACE(vd->dir->vcl_name, vcl_name); vd->dir->priv = priv; vd->dir->healthy = healthy; diff --git a/lib/libvmod_directors/vdir.h b/lib/libvmod_directors/vdir.h index 9214911..2e1cfe1 100644 --- a/lib/libvmod_directors/vdir.h +++ b/lib/libvmod_directors/vdir.h @@ -41,8 +41,8 @@ struct vdir { struct vbitmap *vbm; }; -void vdir_new(struct vdir **vdp, const char *vcl_name, vdi_healthy_f *healthy, - vdi_resolve_f *resolve, void *priv); +void vdir_new(struct vdir **vdp, const char *name, const char *vcl_name, + vdi_healthy_f *healthy, vdi_resolve_f *resolve, void *priv); void vdir_delete(struct vdir **vdp); void vdir_lock(struct vdir *vd); void vdir_unlock(struct vdir *vd); From fgsch at lodoss.net Tue Aug 11 11:08:47 2015 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Tue, 11 Aug 2015 13:08:47 +0200 Subject: [master] 44659cf GC removed functions Message-ID: commit 44659cf4bb33e77f5c650ddcaa536d04ecc4adb0 Author: Federico G. Schwindt Date: Tue Aug 11 11:28:49 2015 +0100 GC removed functions diff --git a/lib/libvarnish/vsb.3 b/lib/libvarnish/vsb.3 index e0968c7..0918289 100644 --- a/lib/libvarnish/vsb.3 +++ b/lib/libvarnish/vsb.3 @@ -34,20 +34,14 @@ .Sh NAME .Nm vsb_new , .Nm vsb_clear , -.Nm vsb_setpos , .Nm vsb_bcat , -.Nm vsb_bcpy , .Nm vsb_cat , -.Nm vsb_cpy , .Nm vsb_printf , .Nm vsb_vprintf , .Nm vsb_putc , -.Nm vsb_trim , -.Nm vsb_overflowed , .Nm vsb_finish , .Nm vsb_data , .Nm vsb_len , -.Nm vsb_done , .Nm vsb_delete .Nd safe string formatting .Sh LIBRARY @@ -59,33 +53,21 @@ .Ft void .Fn vsb_clear "struct vsb *s" .Ft int -.Fn vsb_setpos "struct vsb *s" "int pos" -.Ft int .Fn vsb_bcat "struct vsb *s" "const void *buf" "size_t len" .Ft int -.Fn vsb_bcpy "struct vsb *s" "const void *buf" "size_t len" -.Ft int .Fn vsb_cat "struct vsb *s" "const char *str" .Ft int -.Fn vsb_cpy "struct vsb *s" "const char *str" -.Ft int .Fn vsb_printf "struct vsb *s" "const char *fmt" "..." .Ft int .Fn vsb_vprintf "struct vsb *s" "const char *fmt" "va_list ap" .Ft int .Fn vsb_putc "struct vsb *s" "int c" -.Ft int -.Fn vsb_trim "struct vsb *s" -.Ft int -.Fn vsb_overflowed "struct vsb *s" .Ft void .Fn vsb_finish "struct vsb *s" .Ft char * .Fn vsb_data "struct vsb *s" .Ft int .Fn vsb_len "struct vsb *s" -.Ft int -.Fn vsb_done "struct vsb *s" .Ft void .Fn vsb_delete "struct vsb *s" .Sh DESCRIPTION @@ -162,16 +144,6 @@ function invalidates the contents of the and resets its position to zero. .Pp The -.Fn vsb_setpos -function sets the -.Fa vsb Ns 's -end position to -.Fa pos , -which is a value between zero and one less than the size of the -storage buffer. -This effectively truncates the vsb at the new position. -.Pp -The .Fn vsb_bcat function appends the first .Fa len @@ -181,15 +153,6 @@ to the .Fa vsb . .Pp The -.Fn vsb_bcpy -function replaces the contents of the -.Fa vsb -with the first -.Fa len -bytes from the buffer -.Fa buf . -.Pp -The .Fn vsb_cat function appends the NUL-terminated string .Fa str @@ -198,21 +161,6 @@ to the at the current position. .Pp The -.Fn vsb_cpy -function replaces the contents of the -.Fa vsb -with those of the NUL-terminated string -.Fa str . -This is equivalent to calling -.Fn vsb_cat -with a fresh -.Fa vsb -or one which position has been reset to zero with -.Fn vsb_clear -or -.Fn vsb_setpos . -.Pp -The .Fn vsb_printf function formats its arguments according to the format string pointed to by @@ -237,25 +185,12 @@ to the at the current position. .Pp The -.Fn vsb_trim -function removes trailing whitespace from the -.Fa vsb . -.Pp -The -.Fn vsb_overflowed -function returns a non-zero value if the -.Fa vsb -overflowed. -.Pp -The .Fn vsb_finish function null-terminates the .Fa vsb and marks it as finished, which means that it may no longer be modified using -.Fn vsb_setpos , .Fn vsb_cat , -.Fn vsb_cpy , .Fn vsb_printf or .Fn vsb_putc . @@ -268,8 +203,6 @@ functions return the actual string and its length, respectively; .Fn vsb_data only works on a finished .Fa vsb . -.Fn vsb_done -returns non-zero if the vsb is finished. .Sh NOTES If an operation caused an .Fa vsb @@ -278,12 +211,7 @@ to overflow, most subsequent operations on it will fail until the is finished using .Fn vsb_finish or reset using -.Fn vsb_clear , -or its position is reset to a value between 0 and one less than the -size of its storage buffer using -.Fn vsb_setpos , -or it is reinitialized to a sufficiently short string using -.Fn vsb_cpy . +.Fn vsb_clear . .Sh RETURN VALUES .Fn vsb_new returns @@ -292,22 +220,12 @@ if it failed to allocate a storage buffer, and a pointer to the new .Fa vsb otherwise. .Pp -.Fn vsb_setpos -returns \-1 if -.Fa pos -was invalid, and zero otherwise. -.Pp .Fn vsb_cat , -.Fn vsb_cpy , .Fn vsb_printf , -.Fn vsb_putc , and -.Fn vsb_trim +.Fn vsb_putc all return \-1 if the buffer overflowed, and zero otherwise. .Pp -.Fn vsb_overflowed -returns a non-zero value if the buffer overflowed, and zero otherwise. -.Pp .Fn vsb_data and .Fn vsb_len From dridi.boukelmoune at gmail.com Tue Aug 11 16:01:02 2015 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 11 Aug 2015 18:01:02 +0200 Subject: [master] c94a54b Consistent indentation Message-ID: commit c94a54b16cca4be4ffbd9cfc82ce1b9525595ade Author: Dridi Boukelmoune Date: Mon Aug 10 10:22:26 2015 +0200 Consistent indentation diff --git a/doc/sphinx/reference/index.rst b/doc/sphinx/reference/index.rst index 8eb11ed..bb73dd0 100644 --- a/doc/sphinx/reference/index.rst +++ b/doc/sphinx/reference/index.rst @@ -26,35 +26,35 @@ The Varnish Reference Manual vsl-query.rst .. todo:: - The programs: - . varnishd manual page - . varnishstat - . - counters explained - . common filtering options for shmlog tools - . varnishlog .. - . varnishtop .. - . varnishncsa .. - . varnishhist .. - The CLI: - . connections: -T -S -M - . varnishadm - . CLI commands and what they do - . - vcl.load - . - stop - . - start - . - ... - VCL language - . The functions: - . - vcl_recv - . - vcl_miss - . --- - . The things you can do - . - set - . - unset - . - esi - . - rollback - Varnishtest - . syntax etc. + The programs: + . varnishd manual page + . varnishstat + . - counters explained + . common filtering options for shmlog tools + . varnishlog .. + . varnishtop .. + . varnishncsa .. + . varnishhist .. + The CLI: + . connections: -T -S -M + . varnishadm + . CLI commands and what they do + . - vcl.load + . - stop + . - start + . - ... + VCL language + . The functions: + . - vcl_recv + . - vcl_miss + . --- + . The things you can do + . - set + . - unset + . - esi + . - rollback + Varnishtest + . syntax etc. Shared Memory . internals . Log records From dridi.boukelmoune at gmail.com Tue Aug 11 16:01:02 2015 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 11 Aug 2015 18:01:02 +0200 Subject: [master] cff301d Make sure `man -k varnish` finds all manuals pages Message-ID: commit cff301d2284ce3129c8a0898852e8e58ad05c6cf Author: Dridi Boukelmoune Date: Mon Aug 10 11:00:29 2015 +0200 Make sure `man -k varnish` finds all manuals pages diff --git a/doc/sphinx/reference/varnishstat.rst b/doc/sphinx/reference/varnishstat.rst index afa4a0b..b85e8a8 100644 --- a/doc/sphinx/reference/varnishstat.rst +++ b/doc/sphinx/reference/varnishstat.rst @@ -6,9 +6,9 @@ varnishstat =========== ---------------------------- +------------------------ Varnish Cache statistics ---------------------------- +------------------------ :Manual section: 1 diff --git a/doc/sphinx/reference/vsl.rst b/doc/sphinx/reference/vsl.rst index f90571e..0e753b0 100644 --- a/doc/sphinx/reference/vsl.rst +++ b/doc/sphinx/reference/vsl.rst @@ -6,9 +6,9 @@ VSL === ---------------------- -Shared Memory Logging ---------------------- +----------------------------- +Varnish Shared Memory Logging +----------------------------- :Manual section: 7 From dridi.boukelmoune at gmail.com Tue Aug 11 16:01:02 2015 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 11 Aug 2015 18:01:02 +0200 Subject: [master] fc7b312 Introduce new documentation placeholders Message-ID: commit fc7b31289440d8bc70c5e523617d2d1edf0c396d Author: Dridi Boukelmoune Date: Tue Aug 11 17:48:19 2015 +0200 Introduce new documentation placeholders diff --git a/doc/sphinx/reference/vmod.rst b/doc/sphinx/reference/vmod.rst index c339f0e..57fea73 100644 --- a/doc/sphinx/reference/vmod.rst +++ b/doc/sphinx/reference/vmod.rst @@ -1,3 +1,5 @@ +.. _ref-vmod: + %%%%%%%%%%%%%%%%%%%%%% VMOD - Varnish Modules %%%%%%%%%%%%%%%%%%%%%% @@ -99,6 +101,9 @@ For the std VMOD, the compiled vcc_if.h file looks like this:: Those are your C prototypes. Notice the ``vmod_`` prefix on the function names and the C-types as arguments. + +.. _ref-vmod-vcl-c-types: + VCL and C data types ==================== @@ -335,6 +340,20 @@ in the C-code etc, it is the VMODs own responsibility to track how many VCLs have called init (& fini) and free this global state when the count reaches zero. +.. _ref-vmod-event-functions: + +Event functions +=============== + +TODO + +.. _ref-vmod-objects: + +VMOD Objects +============ + +TODO + When to lock, and when not to lock ================================== From dridi.boukelmoune at gmail.com Tue Aug 11 16:01:02 2015 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 11 Aug 2015 18:01:02 +0200 Subject: [master] 00d5576 Start documenting how to write a director Message-ID: commit 00d5576f68383f900b772b1657d3d7010a2f9a44 Author: Dridi Boukelmoune Date: Tue Aug 11 17:50:43 2015 +0200 Start documenting how to write a director diff --git a/doc/sphinx/reference/directors.rst b/doc/sphinx/reference/directors.rst new file mode 100644 index 0000000..3adc333 --- /dev/null +++ b/doc/sphinx/reference/directors.rst @@ -0,0 +1,136 @@ +.. _ref-writing-a-director: + +%%%%%%%%%%%%%%%%%% +Writing a Director +%%%%%%%%%%%%%%%%%% + +Varnish already provides a set of general-purpose directors, and since Varnish +4, it is bundled in the built-in :ref:`vmod_directors(3)`. Writing a director +boils down to writing a VMOD, using the proper data structures and APIs. Not +only can you write your own director if none of the built-ins fit your needs, +but since Varnish 4.1 you can even write your own backends. + +Backends can be categorized as such: + +- static: native backends declared in VCL +- dynamic: native backends created by VMODs +- custom: backends created and fully managed by VMODs + + +Backends vs Directors +===================== + +The intuitive classification for backend and director is an endpoint for the +former and a cluster for the latter, but the actual implementation is a bit +more subtle. VMODs can accept backend arguments return backends in VCL (see +:ref:`ref-vmod-vcl-c-types`), but he underlying C type is ``struct director``. +Under the hood director is a generic concept, and a backend is a kind of +director. + +The line between the two is somewhat blurry at this point, let's look at some +code instead:: + + struct director { + unsigned magic; + #define DIRECTOR_MAGIC 0x3336351d + const char *name; + char *vcl_name; + vdi_http1pipe_f *http1pipe; + vdi_healthy_f *healthy; + vdi_resolve_f *resolve; + vdi_gethdrs_f *gethdrs; + vdi_getbody_f *getbody; + vdi_getip_f *getip; + vdi_finish_f *finish; + vdi_panic_f *panic; + void *priv; + const void *priv2; + }; + +A director can be summed up as: + +- a name (used for panics) +- a VCL name +- a set of operations +- the associated state + +What's the difference between a *cluster* director and a *backend* director? +The functions they will implement. + + +Creating a Director +=================== + +Custom Backends +--------------- + +If you want to implement a custom backend, have a look at how Varnish +implements native backends. It is the canonical implementation, and though it +provides other services like connection pooling or statistics, it is +essentially a director which state is a ``struct backend``. Varnish native +backends currently speak HTTP/1 over TCP, and as such, you need to make your +own custom backend if you want Varnish to do otherwise such as connecting over +UDP or UNIX-domain sockets or speaking a different protocol. + +You may also consider making your custom backend compliant with regards to the +VCL state (see :ref:`ref-vmod-event-functions`). + +A "backend" director must not implement the ``resolve`` function. More on that +below (:ref:`ref-writing-a-director-cluster`). + + +Dynamic Backends +---------------- + +If you want to speak HTTP/1 over TCP, but for some reason VCL does not fit the +bill, you can instead reuse the whole backend facility. It allows you for +instance to add and remove backends on-demand without the need to reload your +VCL. You can then leverage your provisioning system. + +You don't really deal with ``struct backend``, all you need is available +through the runtime API. Consider the following snippet:: + + backend default { + .host = "localhost"; + } + +The VCL compiler will turn this declaration into a ``struct vrt_backend``. When +the VCL is loaded, Varnish will call ``VRT_new_backend`` in order to create the +director. Dynamic backends are built just like static backends, one *struct* at +a time. You can get rid of the ``struct vrt_backend`` as soon as you have the +``struct director``. + +Unlike a custom backend, a dynamic backend can't exceed its VCL's lifespan, +because native backends are *owned* by VCLs. Though a dynamic backend can't +outlive its VCL, it can be deleted any time with ``VRT_delete_backend``. The +VCL will delete the remaining backends once discarded, you don't need to take +care of it. + +Consider using an object (see :ref:`ref-vmod-objects`) to manipulate dynamic +backends. They are tied to the VCL life cycle and make a handy data structure +to keep track of backends. It is also true for *cluster* directors that may +reference native backends. + +Finally, Varnish will take care of event propagation for *all* native backends. + + +.. _ref-writing-a-director-cluster: + +Cluster Directors +----------------- + +As in :ref:`vmod_directors(3)`, you can write directors that will group +backends sharing the same role, and pick them according to a strategy. If you +need more than the built-in strategies (round-robin, hash, ...), even though +they can be stacked, it is always possible to write your own. + +In this case you simply need to implement the ``resolve`` function for the +director. Directors are walked until a leaf director is found. A leaf director +doesn't have a ``resolve`` function and is used to actually make the backend +request. + + +Health Probes +============= + +TODO diff --git a/doc/sphinx/reference/index.rst b/doc/sphinx/reference/index.rst index bb73dd0..e787b4e 100644 --- a/doc/sphinx/reference/index.rst +++ b/doc/sphinx/reference/index.rst @@ -22,6 +22,7 @@ The Varnish Reference Manual vmod.rst vmod_std.generated.rst vmod_directors.generated.rst + directors.rst vsl.rst vsl-query.rst diff --git a/doc/sphinx/reference/vmod.rst b/doc/sphinx/reference/vmod.rst index 387843a..015e36c 100644 --- a/doc/sphinx/reference/vmod.rst +++ b/doc/sphinx/reference/vmod.rst @@ -239,6 +239,12 @@ BLOB An opaque type to pass random bits of memory between VMOD functions. +BACKEND + C-type: ``const struct director *`` + + A type for backend and director implementations. See + :ref:`ref-writing-a-director` + .. _ref-vmod-private-pointers: diff --git a/doc/sphinx/users-guide/vcl-backends.rst b/doc/sphinx/users-guide/vcl-backends.rst index 9ec1c82..b44ba9c 100644 --- a/doc/sphinx/users-guide/vcl-backends.rst +++ b/doc/sphinx/users-guide/vcl-backends.rst @@ -143,8 +143,9 @@ call certain actions in `vcl_init`.:: This director is a round-robin director. This means the director will distribute the incoming requests on a round-robin basis. There is -also a *random* director which distributes requests in a, you guessed -it, random fashion. +also a *random* director which distributes requests in a, you guessed it, +random fashion. If that is not enough, you can also write your own director +(see :ref:`ref-writing-a-director`). But what if one of your servers goes down? Can Varnish direct all the requests to the healthy server? Sure it can. This is where the Health From dridi.boukelmoune at gmail.com Tue Aug 11 16:01:02 2015 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 11 Aug 2015 18:01:02 +0200 Subject: [master] 7e88396 Make documentation reference more explicit Message-ID: commit 7e883962c0bf065d54ab22dbfa88d9da19546a37 Author: Dridi Boukelmoune Date: Tue Aug 11 17:49:53 2015 +0200 Make documentation reference more explicit diff --git a/doc/sphinx/reference/vmod.rst b/doc/sphinx/reference/vmod.rst index 57fea73..387843a 100644 --- a/doc/sphinx/reference/vmod.rst +++ b/doc/sphinx/reference/vmod.rst @@ -193,16 +193,16 @@ STRING_LIST are big enough. PRIV_VCL - See below + See :ref:`ref-vmod-private-pointers` below PRIV_CALL - See below + See :ref:`ref-vmod-private-pointers` below PRIV_TASK - See below + See :ref:`ref-vmod-private-pointers` below PRIV_TOP - See below + See :ref:`ref-vmod-private-pointers` below VOID C-type: ``void`` @@ -240,6 +240,8 @@ BLOB functions. +.. _ref-vmod-private-pointers: + Private Pointers ================ From phk at FreeBSD.org Wed Aug 12 12:38:42 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 12 Aug 2015 14:38:42 +0200 Subject: [master] ef786af Make the logging of logexpect clearer Message-ID: commit ef786affbd76cb13930d2088230bedc8df400008 Author: Poul-Henning Kamp Date: Wed Aug 12 12:00:08 2015 +0000 Make the logging of logexpect clearer diff --git a/bin/varnishtest/vtc_logexp.c b/bin/varnishtest/vtc_logexp.c index bd567ee..b74c688 100644 --- a/bin/varnishtest/vtc_logexp.c +++ b/bin/varnishtest/vtc_logexp.c @@ -182,7 +182,7 @@ logexp_next(struct logexp *le) CHECK_OBJ_ORNULL(le->test, LOGEXP_TEST_MAGIC); if (le->test) - vtc_log(le->vl, 3, "tst| %s", VSB_data(le->test->str)); + vtc_log(le->vl, 3, "waitfor| %s", VSB_data(le->test->str)); } static int __match_proto__(VSLQ_dispatch_f) @@ -239,7 +239,7 @@ logexp_dispatch(struct VSL_data *vsl, struct VSL_transaction * const pt[], skip = 1; if (ok) - legend = "ok"; + legend = "match"; else if (skip) legend = NULL; else @@ -450,7 +450,6 @@ cmd_logexp_expect(CMD_ARGS) test->tag = tag; test->vre = vre; VTAILQ_INSERT_TAIL(&le->tests, test, list); - vtc_log(vl, 4, "%s", VSB_data(test->str)); } static const struct cmds logexp_cmds[] = { From phk at FreeBSD.org Wed Aug 12 12:38:42 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 12 Aug 2015 14:38:42 +0200 Subject: [master] 61efcba Inspired by Martin I have stared hard at http_conn for a few days. Message-ID: commit 61efcba8d11bfe6a9f105c98830dd771a968883d Author: Poul-Henning Kamp Date: Wed Aug 12 12:35:35 2015 +0000 Inspired by Martin I have stared hard at http_conn for a few days. This commit cleans up a number of weeds and loose ends: The complete_function should not muck about with the pipelining or WS reservation. Only when we have dissected the headers for good do we know how long the headers were. Make the HTTP1_Dissect* functions have consistent parameters. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 4c57c4e..d73001b 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -838,8 +838,8 @@ enum sess_close http_DoConnection(struct http *hp); /* cache_http1_proto.c */ htc_complete_f HTTP1_Complete; -uint16_t HTTP1_DissectRequest(struct http_conn *htc, struct http *hp); -uint16_t HTTP1_DissectResponse(struct http *sp, struct http_conn *htc); +uint16_t HTTP1_DissectRequest(struct http_conn *, struct http *); +uint16_t HTTP1_DissectResponse(struct http_conn *, struct http *); unsigned HTTP1_Write(const struct worker *w, const struct http *hp, const int*); #define HTTPH(a, b, c) extern char b[]; diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c index 7476419..21f405f 100644 --- a/bin/varnishd/cache/cache_session.c +++ b/bin/varnishd/cache/cache_session.c @@ -219,7 +219,7 @@ SES_Rx(struct http_conn *htc, double tmo) * Receive a request/packet/whatever, with timeouts * * t0 is when we start - * *t1 becomes time of first non-idle rx + * *t1 becomes time of first non-idle rx * *t2 becomes time of complete rx * ti is when we return IDLE if nothing has arrived * tn is when we timeout on non-complete @@ -266,6 +266,7 @@ SES_RxStuff(struct http_conn *htc, htc_complete_f *func, double t0, return (HTC_S_JUNK); } if (hs == HTC_S_COMPLETE) { + WS_ReleaseP(htc->ws, htc->rxbuf_e); /* Got it, run with it */ if (t1 != NULL && isnan(*t1)) *t1 = now; diff --git a/bin/varnishd/http1/cache_http1_fetch.c b/bin/varnishd/http1/cache_http1_fetch.c index 2a2099b..ca1df5a 100644 --- a/bin/varnishd/http1/cache_http1_fetch.c +++ b/bin/varnishd/http1/cache_http1_fetch.c @@ -138,7 +138,7 @@ V1F_FetchRespHdr(struct busyobj *bo) struct http *hp; enum htc_status_e hs; - int first; + int first, i; struct http_conn *htc; CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); @@ -188,11 +188,13 @@ V1F_FetchRespHdr(struct busyobj *bo) htc->between_bytes_timeout); } } while (hs != HTC_S_COMPLETE); - bo->acct.beresp_hdrbytes += htc->rxbuf_e - htc->rxbuf_b; + WS_ReleaseP(htc->ws, htc->rxbuf_e); hp = bo->beresp; - if (HTTP1_DissectResponse(hp, htc)) { + i = HTTP1_DissectResponse(htc, hp); + bo->acct.beresp_hdrbytes += htc->rxbuf_e - htc->rxbuf_b; + if (i) { VSLb(bo->vsl, SLT_FetchError, "http format error"); htc->doclose = SC_RX_JUNK; return (-1); diff --git a/bin/varnishd/http1/cache_http1_fsm.c b/bin/varnishd/http1/cache_http1_fsm.c index e66fa96..6acf78c 100644 --- a/bin/varnishd/http1/cache_http1_fsm.c +++ b/bin/varnishd/http1/cache_http1_fsm.c @@ -159,6 +159,7 @@ HTTP1_Session(struct worker *wrk, struct req *req) { enum htc_status_e hs; struct sess *sp; + int i; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(req, REQ_MAGIC); @@ -234,9 +235,6 @@ HTTP1_Session(struct worker *wrk, struct req *req) if (hs != HTC_S_COMPLETE) WRONG("htc_status (nonbad)"); - req->acct.req_hdrbytes += - req->htc->rxbuf_e - req->htc->rxbuf_b; - sp->sess_step = S_STP_H1WORKING; break; case S_STP_H1BUSY: @@ -255,7 +253,10 @@ HTTP1_Session(struct worker *wrk, struct req *req) sp->sess_step = S_STP_H1PROC; break; case S_STP_H1WORKING: - if (http1_dissect(wrk, req)) { + i = http1_dissect(wrk, req); + req->acct.req_hdrbytes += + req->htc->rxbuf_e - req->htc->rxbuf_b; + if (i) { SES_Close(req->sp, req->doclose); sp->sess_step = S_STP_H1CLEANUP; break; @@ -277,16 +278,16 @@ HTTP1_Session(struct worker *wrk, struct req *req) return; SES_RxReInit(req->htc); if (HTTP1_Complete(req->htc) == HTC_S_COMPLETE) { + WS_ReleaseP(req->htc->ws, req->htc->rxbuf_e); AZ(req->vsl->wid); req->t_first = req->t_req = sp->t_idle; wrk->stats->sess_pipeline++; - req->acct.req_hdrbytes += - req->htc->rxbuf_e - req->htc->rxbuf_b; sp->sess_step = S_STP_H1WORKING; } else { if (req->htc->rxbuf_e != req->htc->rxbuf_b) wrk->stats->sess_readahead++; sp->sess_step = S_STP_H1NEWREQ; + } break; default: diff --git a/bin/varnishd/http1/cache_http1_proto.c b/bin/varnishd/http1/cache_http1_proto.c index 933c232..77b8f5b 100644 --- a/bin/varnishd/http1/cache_http1_proto.c +++ b/bin/varnishd/http1/cache_http1_proto.c @@ -83,6 +83,10 @@ HTTP1_Complete(struct http_conn *htc) *htc->rxbuf_e = '\0'; return (HTC_S_EMPTY); } + /* + * Here we just look for NL[CR]NL to see that reception + * is completed. More stringent validation happens later. + */ while (1) { p = strchr(p, '\n'); if (p == NULL) @@ -93,13 +97,6 @@ HTTP1_Complete(struct http_conn *htc) if (*p == '\n') break; } - p++; - WS_ReleaseP(htc->ws, htc->rxbuf_e); - if (p < htc->rxbuf_e) { - htc->pipeline_b = p; - htc->pipeline_e = htc->rxbuf_e; - htc->rxbuf_e = p; - } return (HTC_S_COMPLETE); } @@ -109,7 +106,7 @@ HTTP1_Complete(struct http_conn *htc) */ static uint16_t -http1_dissect_hdrs(struct http *hp, char *p, const struct http_conn *htc) +http1_dissect_hdrs(struct http *hp, char *p, struct http_conn *htc) { char *q, *r; @@ -122,6 +119,8 @@ http1_dissect_hdrs(struct http *hp, char *p, const struct http_conn *htc) /* Find end of next header */ q = r = p; + if (vct_iscrlf(p)) + break; while (r < htc->rxbuf_e) { if (!vct_iscrlf(r)) { r++; @@ -132,6 +131,8 @@ http1_dissect_hdrs(struct http *hp, char *p, const struct http_conn *htc) r += vct_skipcrlf(r); if (r >= htc->rxbuf_e) break; + if (vct_iscrlf(r)) + break; /* If line does not continue: got it. */ if (!vct_issp(*r)) break; @@ -184,6 +185,13 @@ http1_dissect_hdrs(struct http *hp, char *p, const struct http_conn *htc) return (400); } } + if (p < htc->rxbuf_e) + p += vct_skipcrlf(p); + if (p < htc->rxbuf_e) { + htc->pipeline_b = p; + htc->pipeline_e = htc->rxbuf_e; + htc->rxbuf_e = p; + } return (0); } @@ -192,7 +200,7 @@ http1_dissect_hdrs(struct http *hp, char *p, const struct http_conn *htc) */ static uint16_t -http1_splitline(struct http *hp, const struct http_conn *htc, const int *hf) +http1_splitline(struct http *hp, struct http_conn *htc, const int *hf) { char *p; int i; @@ -390,7 +398,7 @@ HTTP1_DissectRequest(struct http_conn *htc, struct http *hp) /*--------------------------------------------------------------------*/ uint16_t -HTTP1_DissectResponse(struct http *hp, struct http_conn *htc) +HTTP1_DissectResponse(struct http_conn *htc, struct http *hp) { uint16_t retval = 0; const char *p; diff --git a/bin/varnishd/proxy/cache_proxy_proto.c b/bin/varnishd/proxy/cache_proxy_proto.c index f3c9caa..113cea1 100644 --- a/bin/varnishd/proxy/cache_proxy_proto.c +++ b/bin/varnishd/proxy/cache_proxy_proto.c @@ -376,7 +376,6 @@ VPX_Proto_Sess(struct worker *wrk, void *priv) req->htc->pipeline_b = NULL; else req->htc->pipeline_e = req->htc->rxbuf_e; - WS_Release(req->htc->ws, 0); SES_RxReInit(req->htc); req->sp->sess_step = S_STP_H1NEWREQ; wrk->task.func = SES_Proto_Req; From phk at FreeBSD.org Wed Aug 12 13:56:00 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 12 Aug 2015 15:56:00 +0200 Subject: [master] 852fb46 fix printf format Message-ID: commit 852fb4624f28eccd8ff802dabc2fdcce7d2b5103 Author: Poul-Henning Kamp Date: Wed Aug 12 13:55:47 2015 +0000 fix printf format diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index e20f668..617b65d 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -151,7 +151,8 @@ pan_htc(struct vsb *vsb, const struct http_conn *htc) htc->rxbuf_b, htc->rxbuf_e); VSB_printf(vsb, "{pipeline_b, pipeline_e} = {%p, %p},\n", htc->pipeline_b, htc->pipeline_e); - VSB_printf(vsb, "content_length = %jd,\n", htc->content_length); + VSB_printf(vsb, "content_length = %jd,\n", + (intmax_t)htc->content_length); VSB_printf(vsb, "body_status = %s,\n", body_status_2str(htc->body_status)); VSB_printf(vsb, "first_byte_timeout = %f,\n", From fgsch at lodoss.net Thu Aug 13 22:13:07 2015 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Fri, 14 Aug 2015 00:13:07 +0200 Subject: [master] f8a913d Grammar and minor corrections Message-ID: commit f8a913d576b86195be86ee2174f47d0537e7af25 Author: Federico G. Schwindt Date: Wed Aug 12 23:10:18 2015 +0100 Grammar and minor corrections diff --git a/doc/changes.rst b/doc/changes.rst index 3caf9f0..a2e4598 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -614,7 +614,7 @@ Other Changes from 3.0.2 to 3.0.3 (2012-08-20) ======================================== -Varnishd +varnishd -------- - Fix a race on the n_sess counter. This race made varnish do excessive @@ -731,7 +731,7 @@ Other Changes from 3.0.2 rc 1 to 3.0.2 (2011-10-26) ============================================= -Varnishd +varnishd -------- - Make the size of the synthetic object workspace equal to @@ -762,7 +762,7 @@ Other Changes from 3.0.1 to 3.0.2 rc 1 (2011-10-06) ============================================= -Varnishd +varnishd -------- - Only log the first 20 bytes of extra headers to prevent overflows. @@ -824,7 +824,7 @@ Other Changes from 3.0.1 rc 1 to 3.0.1 (2011-08-30) ============================================= -Varnishd +varnishd -------- - Fix crash in streaming code. @@ -856,7 +856,7 @@ Other Changes from 3.0.0 to 3.0.1 rc 1 (2011-08-24) ============================================= -Varnishd +varnishd -------- - Avoid sending an empty end-chunk when sending bodyless responsed. @@ -933,7 +933,7 @@ Other Changes from 3.0 beta 2 to 3.0.0 (2011-06-16) ============================================= -Varnishd +varnishd -------- - Avoid sending an empty end-chunk when sending bodyless responsed. @@ -961,7 +961,7 @@ varnishadm Changes from 3.0 beta 1 to 3.0 beta 2 ===================================== -Varnishd +varnishd -------- - thread_pool_min and thread_pool_max now each refer to the number of @@ -1023,7 +1023,7 @@ Upcoming changes to do ``ban("req.url == " + req.url)`` instead. This syntax already works and is recommended. -Varnishd +varnishd -------- - Add streaming on ``pass`` and ``miss``. This is controlled by the @@ -1296,7 +1296,7 @@ varnishd - Do not filter out Content-Range headers in pass. -- Require -d, -b, -f, -S or -T when starting Varnishd. In human terms, +- Require -d, -b, -f, -S or -T when starting varnishd. In human terms, this means that it is legal to start varnishd without a Vcl or backend, but only if you have a CLI channel of some kind. diff --git a/doc/sphinx/glossary/index.rst b/doc/sphinx/glossary/index.rst index 2f9250e..a3d9761 100644 --- a/doc/sphinx/glossary/index.rst +++ b/doc/sphinx/glossary/index.rst @@ -21,7 +21,7 @@ Varnish Glossary master (process) One of the two processes in the varnishd program. - The master proces is a manager/nanny process which handles + The master process is a manager/nanny process which handles configuration, parameters, compilation of :term:VCL etc. but it does never get near the actual HTTP traffic. @@ -55,7 +55,7 @@ Varnish Glossary Program which presents varnish transaction log in "NCSA" format. varnishhist - Eye-candy program showing responsetime histogram in 1980ies + Eye-candy program showing response time histogram in 1980s ASCII-art style. varnishtest @@ -86,8 +86,8 @@ Varnish Glossary to varnishd they are just bytes. object - The (possibly) cached version of a backend response. Varnishd - receives a reponse from the backend and creates an object, + The (possibly) cached version of a backend response. varnishd + receives a response from the backend and creates an object, from which it may deliver cached responses to clients. If the object is created as a result of a request which is passed, it will not be stored for caching. diff --git a/doc/sphinx/reference/vsm.rst b/doc/sphinx/reference/vsm.rst index 13afbdd..fbea284 100644 --- a/doc/sphinx/reference/vsm.rst +++ b/doc/sphinx/reference/vsm.rst @@ -67,7 +67,7 @@ off" period. The Varnish way: ---------------- -If Varnishd starts, and finds a locked shared memory file, it will +If varnishd starts, and finds a locked shared memory file, it will exit with a message about using different -n arguments if you want multiple instances of varnishd. diff --git a/doc/sphinx/users-guide/run_security.rst b/doc/sphinx/users-guide/run_security.rst index d83ea18..41c68a8 100644 --- a/doc/sphinx/users-guide/run_security.rst +++ b/doc/sphinx/users-guide/run_security.rst @@ -47,7 +47,7 @@ CLI interface access The command line interface can be accessed in three ways. -`Varnishd` can be told to listen and offer CLI connections +`varnishd` can be told to listen and offer CLI connections on a TCP socket. You can bind the socket to pretty much anything the kernel will accept:: diff --git a/include/vsm_priv.h b/include/vsm_priv.h index 0cc1a9f..e6893cc 100644 --- a/include/vsm_priv.h +++ b/include/vsm_priv.h @@ -56,7 +56,7 @@ * Subscribers will have to monitor three things to make sure they look at * the right thing: The alloc_seq field, the age counter and the dev+inode * of the path-name. The former check is by far the cheaper, the second - * can be used to check that Varnishd is still alive and the last check + * can be used to check that varnishd is still alive and the last check * should only be employed when lack of activity in the VSM segment raises * suspicion that something has happened. * From fgsch at lodoss.net Thu Aug 13 22:13:07 2015 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Fri, 14 Aug 2015 00:13:07 +0200 Subject: [master] 1daa0c2 Specify the full path of the logs Message-ID: commit 1daa0c20bac4cf2ca9d0de0ba39d6646b3e46e37 Author: Federico G. Schwindt Date: Fri Aug 7 16:53:56 2015 +0100 Specify the full path of the logs This makes it easier to run multiple instances, each one writing to different files. diff --git a/redhat/varnish.logrotate b/redhat/varnish.logrotate index 535614d..f214d1b 100644 --- a/redhat/varnish.logrotate +++ b/redhat/varnish.logrotate @@ -1,4 +1,4 @@ -/var/log/varnish/*.log { +/var/log/varnish/varnish.log /var/log/varnish/varnishncsa.log { missingok notifempty sharedscripts From phk at FreeBSD.org Fri Aug 14 07:20:58 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 14 Aug 2015 09:20:58 +0200 Subject: [master] b6645ff Call the "complete" function first, the read more in SES_RxStuff() Message-ID: commit b6645ff23f84633f4061aa6274318870239bc227 Author: Poul-Henning Kamp Date: Fri Aug 14 07:18:34 2015 +0000 Call the "complete" function first, the read more in SES_RxStuff() This saves an entire state in the H1 FSM. (At the cost of not differentiating between read-ahead and full pipelining in VSC.) Inspired by patches from?Lasse & Martin diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c index 21f405f..69bf46d 100644 --- a/bin/varnishd/cache/cache_session.c +++ b/bin/varnishd/cache/cache_session.c @@ -232,6 +232,7 @@ SES_RxStuff(struct http_conn *htc, htc_complete_f *func, double t0, double tmo; double now; enum htc_status_e hs; + int i; CHECK_OBJ_NOTNULL(htc, HTTP_CONN_MAGIC); @@ -240,30 +241,12 @@ SES_RxStuff(struct http_conn *htc, htc_complete_f *func, double t0, if (t1 != NULL) assert(isnan(*t1)); - now = t0; while (1) { - if (!isnan(ti)) - tmo = ti - t0; - else - tmo = tn - t0; - hs = SES_Rx(htc, tmo); - if (hs == HTC_S_EOF) { - WS_ReleaseP(htc->ws, htc->rxbuf_b); - return (HTC_S_CLOSE); - } - if (hs == HTC_S_OVERFLOW) { - WS_ReleaseP(htc->ws, htc->rxbuf_b); - return (HTC_S_OVERFLOW); - } now = VTIM_real(); hs = func(htc); - if (hs == HTC_S_OVERFLOW) { + if (hs == HTC_S_OVERFLOW || hs == HTC_S_JUNK) { WS_ReleaseP(htc->ws, htc->rxbuf_b); - return (HTC_S_OVERFLOW); - } - if (hs == HTC_S_JUNK) { - WS_ReleaseP(htc->ws, htc->rxbuf_b); - return (HTC_S_JUNK); + return (hs); } if (hs == HTC_S_COMPLETE) { WS_ReleaseP(htc->ws, htc->rxbuf_e); @@ -274,18 +257,37 @@ SES_RxStuff(struct http_conn *htc, htc_complete_f *func, double t0, *t2 = now; return (HTC_S_COMPLETE); } - if (tn < now) + if (tn < now) { + /* XXX: WS_ReleaseP(htc->ws, htc->rxbuf_b); ? */ return (HTC_S_TIMEOUT); + } if (hs == HTC_S_MORE) { /* Working on it */ if (t1 != NULL && isnan(*t1)) *t1 = now; tmo = tn - now; - continue; + } else if (hs != HTC_S_EMPTY) + WRONG("htc_status_e"); + + tmo = tn - t0; + if (!isnan(ti) && ti < tn) + tmo = ti - t0; + i = (htc->ws->r - htc->rxbuf_e) - 1; /* space for NUL */ + if (i <= 0) { + WS_ReleaseP(htc->ws, htc->rxbuf_b); + return (HTC_S_OVERFLOW); + } + i = VTCP_read(htc->fd, htc->rxbuf_e, i, tmo); + if (i == 0 || i == -1) { + WS_ReleaseP(htc->ws, htc->rxbuf_b); + return (HTC_S_EOF); + } else if (i > 0) { + htc->rxbuf_e += i; + *htc->rxbuf_e = '\0'; + } else if (i == -2) { + if (hs == HTC_S_EMPTY && ti < now) + return (HTC_S_IDLE); } - assert(hs == HTC_S_EMPTY); - if (ti < now) - return (HTC_S_IDLE); } } diff --git a/bin/varnishd/http1/cache_http1_fsm.c b/bin/varnishd/http1/cache_http1_fsm.c index 6acf78c..7d7eef3 100644 --- a/bin/varnishd/http1/cache_http1_fsm.c +++ b/bin/varnishd/http1/cache_http1_fsm.c @@ -235,7 +235,16 @@ HTTP1_Session(struct worker *wrk, struct req *req) if (hs != HTC_S_COMPLETE) WRONG("htc_status (nonbad)"); - sp->sess_step = S_STP_H1WORKING; + i = http1_dissect(wrk, req); + req->acct.req_hdrbytes += + req->htc->rxbuf_e - req->htc->rxbuf_b; + if (i) { + SES_Close(req->sp, req->doclose); + sp->sess_step = S_STP_H1CLEANUP; + break; + } + req->req_step = R_STP_RECV; + sp->sess_step = S_STP_H1PROC; break; case S_STP_H1BUSY: /* @@ -252,18 +261,6 @@ HTTP1_Session(struct worker *wrk, struct req *req) } sp->sess_step = S_STP_H1PROC; break; - case S_STP_H1WORKING: - i = http1_dissect(wrk, req); - req->acct.req_hdrbytes += - req->htc->rxbuf_e - req->htc->rxbuf_b; - if (i) { - SES_Close(req->sp, req->doclose); - sp->sess_step = S_STP_H1CLEANUP; - break; - } - req->req_step = R_STP_RECV; - sp->sess_step = S_STP_H1PROC; - break; case S_STP_H1PROC: req->transport = &http1_transport; if (CNT_Request(wrk, req) == REQ_FSM_DISEMBARK) { @@ -277,18 +274,9 @@ HTTP1_Session(struct worker *wrk, struct req *req) if (Req_Cleanup(sp, wrk, req)) return; SES_RxReInit(req->htc); - if (HTTP1_Complete(req->htc) == HTC_S_COMPLETE) { - WS_ReleaseP(req->htc->ws, req->htc->rxbuf_e); - AZ(req->vsl->wid); - req->t_first = req->t_req = sp->t_idle; - wrk->stats->sess_pipeline++; - sp->sess_step = S_STP_H1WORKING; - } else { - if (req->htc->rxbuf_e != req->htc->rxbuf_b) - wrk->stats->sess_readahead++; - sp->sess_step = S_STP_H1NEWREQ; - - } + if (req->htc->rxbuf_e != req->htc->rxbuf_b) + wrk->stats->sess_readahead++; + sp->sess_step = S_STP_H1NEWREQ; break; default: WRONG("Wrong H1 session state"); diff --git a/bin/varnishtest/tests/b00012.vtc b/bin/varnishtest/tests/b00012.vtc index 81113b5..224bd1a 100644 --- a/bin/varnishtest/tests/b00012.vtc +++ b/bin/varnishtest/tests/b00012.vtc @@ -27,4 +27,4 @@ client c1 { expect resp.http.x-varnish == "1005 1004" } -run -varnish v1 -expect sess_pipeline == 2 +varnish v1 -expect sess_readahead == 2 diff --git a/include/tbl/steps.h b/include/tbl/steps.h index a5e618a..2c805d4 100644 --- a/include/tbl/steps.h +++ b/include/tbl/steps.h @@ -36,7 +36,6 @@ SESS_STEP(h1newreq, H1NEWREQ) SESS_STEP(h1proc, H1PROC) SESS_STEP(h1busy, H1BUSY) SESS_STEP(h1cleanup, H1CLEANUP) -SESS_STEP(h1working, H1WORKING) SESS_STEP(h1_last, H1_LAST) SESS_STEP(proxynewsess, PROXYNEWSESS) diff --git a/include/tbl/vsc_f_main.h b/include/tbl/vsc_f_main.h index 3c6c8d0..94341b5 100644 --- a/include/tbl/vsc_f_main.h +++ b/include/tbl/vsc_f_main.h @@ -384,10 +384,6 @@ VSC_F(sess_closed_err, uint64_t, 0, 'c', 'i', info, "Total number of sessions closed with errors." " See sc_* diag counters for detailed breakdown" ) -VSC_F(sess_pipeline, uint64_t, 1, 'c', 'i', info, - "Session Pipeline", - "" -) VSC_F(sess_readahead, uint64_t, 1, 'c', 'i', info, "Session Read Ahead", "" From phk at FreeBSD.org Fri Aug 14 08:03:53 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 14 Aug 2015 10:03:53 +0200 Subject: [master] c954e37 Eliminate the 'T0' argument from SES_RxStuff() it only saves a timestamp syscall in very rare circumstances. Message-ID: commit c954e37bf986e09313b0d7b6561a3e958f0e50ef Author: Poul-Henning Kamp Date: Fri Aug 14 08:03:20 2015 +0000 Eliminate the 'T0' argument from SES_RxStuff() it only saves a timestamp syscall in very rare circumstances. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index d73001b..6a2b047 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -980,7 +980,7 @@ void SES_RxInit(struct http_conn *htc, struct ws *ws, unsigned maxbytes, unsigned maxhdr); void SES_RxReInit(struct http_conn *htc); enum htc_status_e SES_Rx(struct http_conn *htc, double tmo); -enum htc_status_e SES_RxStuff(struct http_conn *, htc_complete_f *, double t0, +enum htc_status_e SES_RxStuff(struct http_conn *, htc_complete_f *, double *t1, double *t2, double ti, double tn); #define SESS_ATTR(UP, low, typ, len) \ diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c index 69bf46d..92f279a 100644 --- a/bin/varnishd/cache/cache_session.c +++ b/bin/varnishd/cache/cache_session.c @@ -226,7 +226,7 @@ SES_Rx(struct http_conn *htc, double tmo) */ enum htc_status_e -SES_RxStuff(struct http_conn *htc, htc_complete_f *func, double t0, +SES_RxStuff(struct http_conn *htc, htc_complete_f *func, double *t1, double *t2, double ti, double tn) { double tmo; @@ -236,7 +236,6 @@ SES_RxStuff(struct http_conn *htc, htc_complete_f *func, double t0, CHECK_OBJ_NOTNULL(htc, HTTP_CONN_MAGIC); - AZ(isnan(t0)); AZ(isnan(tn)); if (t1 != NULL) assert(isnan(*t1)); @@ -258,7 +257,7 @@ SES_RxStuff(struct http_conn *htc, htc_complete_f *func, double t0, return (HTC_S_COMPLETE); } if (tn < now) { - /* XXX: WS_ReleaseP(htc->ws, htc->rxbuf_b); ? */ + WS_ReleaseP(htc->ws, htc->rxbuf_b); return (HTC_S_TIMEOUT); } if (hs == HTC_S_MORE) { @@ -269,9 +268,9 @@ SES_RxStuff(struct http_conn *htc, htc_complete_f *func, double t0, } else if (hs != HTC_S_EMPTY) WRONG("htc_status_e"); - tmo = tn - t0; + tmo = tn - now; if (!isnan(ti) && ti < tn) - tmo = ti - t0; + tmo = ti - now; i = (htc->ws->r - htc->rxbuf_e) - 1; /* space for NUL */ if (i <= 0) { WS_ReleaseP(htc->ws, htc->rxbuf_b); diff --git a/bin/varnishd/http1/cache_http1_fsm.c b/bin/varnishd/http1/cache_http1_fsm.c index 7d7eef3..8e5762a 100644 --- a/bin/varnishd/http1/cache_http1_fsm.c +++ b/bin/varnishd/http1/cache_http1_fsm.c @@ -200,7 +200,7 @@ HTTP1_Session(struct worker *wrk, struct req *req) AZ(req->vcl); AZ(req->esi_level); - hs = SES_RxStuff(req->htc, HTTP1_Complete, sp->t_idle, + hs = SES_RxStuff(req->htc, HTTP1_Complete, &req->t_first, &req->t_req, sp->t_idle + cache_param->timeout_linger, sp->t_idle + cache_param->timeout_idle); diff --git a/bin/varnishd/proxy/cache_proxy_proto.c b/bin/varnishd/proxy/cache_proxy_proto.c index 113cea1..b817bc5 100644 --- a/bin/varnishd/proxy/cache_proxy_proto.c +++ b/bin/varnishd/proxy/cache_proxy_proto.c @@ -351,7 +351,7 @@ VPX_Proto_Sess(struct worker *wrk, void *priv) assert(sizeof vpx1_sig == 5); assert(sizeof vpx2_sig == 12); - hs = SES_RxStuff(req->htc, vpx_complete, sp->t_idle, + hs = SES_RxStuff(req->htc, vpx_complete, NULL, NULL, NAN, sp->t_idle + cache_param->timeout_idle); if (hs != HTC_S_COMPLETE) { Req_Release(req); From phk at FreeBSD.org Fri Aug 14 10:39:30 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 14 Aug 2015 12:39:30 +0200 Subject: [master] 4da5dff Always release the WS when SES_RxStuff() returns. Message-ID: commit 4da5dffafbe047015bcf03c1dd237c5b091c0fac Author: Poul-Henning Kamp Date: Fri Aug 14 10:39:12 2015 +0000 Always release the WS when SES_RxStuff() returns. diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c index 92f279a..8333123 100644 --- a/bin/varnishd/cache/cache_session.c +++ b/bin/varnishd/cache/cache_session.c @@ -284,8 +284,10 @@ SES_RxStuff(struct http_conn *htc, htc_complete_f *func, htc->rxbuf_e += i; *htc->rxbuf_e = '\0'; } else if (i == -2) { - if (hs == HTC_S_EMPTY && ti < now) + if (hs == HTC_S_EMPTY && ti < now) { + WS_ReleaseP(htc->ws, htc->rxbuf_b); return (HTC_S_IDLE); + } } } } diff --git a/bin/varnishd/http1/cache_http1_fsm.c b/bin/varnishd/http1/cache_http1_fsm.c index 8e5762a..210be90 100644 --- a/bin/varnishd/http1/cache_http1_fsm.c +++ b/bin/varnishd/http1/cache_http1_fsm.c @@ -204,6 +204,7 @@ HTTP1_Session(struct worker *wrk, struct req *req) &req->t_first, &req->t_req, sp->t_idle + cache_param->timeout_linger, sp->t_idle + cache_param->timeout_idle); + XXXAZ(req->htc->ws->r); if (hs < HTC_S_EMPTY) { req->acct.req_hdrbytes += req->htc->rxbuf_e - req->htc->rxbuf_b; diff --git a/bin/varnishd/proxy/cache_proxy_proto.c b/bin/varnishd/proxy/cache_proxy_proto.c index b817bc5..d029861 100644 --- a/bin/varnishd/proxy/cache_proxy_proto.c +++ b/bin/varnishd/proxy/cache_proxy_proto.c @@ -353,6 +353,7 @@ VPX_Proto_Sess(struct worker *wrk, void *priv) hs = SES_RxStuff(req->htc, vpx_complete, NULL, NULL, NAN, sp->t_idle + cache_param->timeout_idle); + XXXAZ(req->htc->ws->r); if (hs != HTC_S_COMPLETE) { Req_Release(req); SES_Delete(sp, SC_RX_JUNK, NAN); From fgsch at lodoss.net Fri Aug 14 12:23:11 2015 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Fri, 14 Aug 2015 14:23:11 +0200 Subject: [master] b79da41 First stab at getting event documented Message-ID: commit b79da4195f0755d9323e52f06c7651441f9ba09f Author: Federico G. Schwindt Date: Fri Aug 14 13:22:54 2015 +0100 First stab at getting event documented diff --git a/doc/sphinx/reference/vmod.rst b/doc/sphinx/reference/vmod.rst index 015e36c..6053685 100644 --- a/doc/sphinx/reference/vmod.rst +++ b/doc/sphinx/reference/vmod.rst @@ -51,17 +51,17 @@ data structures that does all the hard work. The std VMODs vmod.vcc file looks somewhat like this:: $Module std 3 - $Init init_function + $Event event_function $Function STRING toupper(STRING_LIST) $Function STRING tolower(STRING_LIST) $Function VOID set_ip_tos(INT) The first line gives the name of the module, nothing special there. -The second line specifies an optional "Init" function, which will -be called whenever a VCL program which imports this VMOD is loaded. -This gives a chance to initialize the module before any of the -functions it implements are called. More on this below. +The second line specifies an optional "Event" function, which will be +called whenever a VCL program which imports this VMOD is initially loaded +or transitions to any of the warm, active, cold and discarded states. +More on this below. The next three lines specify two functions in the VMOD, along with the types of the arguments, and that is probably where the hardest bit @@ -96,7 +96,7 @@ For the std VMOD, the compiled vcc_if.h file looks like this:: VCL_STRING vmod_tolower(VRT_CTX, const char *, ...); VCL_VOID vmod_set_ip_tos(VRT_CTX, VCL_INT); - int init_function(VRT_CTX, struct vmod_priv *); + vmod_event_f event_function; Those are your C prototypes. Notice the ``vmod_`` prefix on the function names and the C-types as arguments. @@ -242,8 +242,8 @@ BLOB BACKEND C-type: ``const struct director *`` - A type for backend and director implementations. See - :ref:`ref-writing-a-director` + A type for backend and director implementations. See + :ref:`ref-writing-a-director`. .. _ref-vmod-private-pointers: @@ -326,34 +326,30 @@ malloc would look like this:: The per-call vmod_privs are freed before the per-vcl vmod_priv. -Init functions -============== - -VMODs can have an "init" method which is called when a VCL -which imports the VMOD is loaded. - -The first argument to the init function is the vmod_priv specific -to this particular VCL, and if necessary, a VCL specific VMOD "fini" -function can be attached to its "free" hook. +.. _ref-vmod-event-functions: -The second argument is a pointer to the VCL's config structure, -which allows you to tell different VCLs which import this module -apart. +Event functions +=============== -Please notice that there is no "global" fini method. +VMODs can have an "event" function which is called when a VCL which +imports the VMOD is loaded, made active, or discarded. This corresponds +to the VCL_EVENT_LOAD, VCL_EVENT_USE, and VCL_EVENT_DISCARD events, +respectively. In addition, this function will be called when the VCL +state is changed to cold or warm, corresponding to the VCL_EVENT_COLD +and VCL_EVENT_WARM events. -If the VMOD has private global state, which includes any sockets -or files opened, any memory allocated to global or private variables -in the C-code etc, it is the VMODs own responsibility to track how -many VCLs have called init (& fini) and free this global state -when the count reaches zero. +The first argument to the event function is the VRT context. -.. _ref-vmod-event-functions: +The second argument is the vmod_priv specific to this particular VCL, +and if necessary, a VCL specific VMOD "fini" function can be attached +to its "free" hook. -Event functions -=============== +The third argument is the event. -TODO +If the VMOD has private global state, which includes any sockets or files +opened, any memory allocated to global or private variables in the C-code +etc, it is the VMODs own responsibility to track how many VCLs have called +init (& fini) and free this global state when the count reaches zero .. _ref-vmod-objects: @@ -368,7 +364,7 @@ When to lock, and when not to lock Varnish is heavily multithreaded, so by default VMODs must implement their own locking to protect shared resources. -When a VCL is loaded or unloaded, the init and priv->free are +When a VCL is loaded or unloaded, the event and priv->free are run sequentially all in a single thread, and there is guaranteed to be no other activity related to this particular VCL, nor are there init/fini activity in any other VCL or VMOD at this time. @@ -396,7 +392,7 @@ times it will give you the same single copy of the shared library file, without checking if it was updated in the meantime. This is obviously an oversight in the design of the dlopen(3) library -function, but back in the late 1980ies nobody could imagine why a +function, but back in the late 1980s nobody could imagine why a program would ever want to have multiple different versions of the same shared library mapped at the same time. From fgsch at lodoss.net Fri Aug 14 14:32:27 2015 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Fri, 14 Aug 2015 16:32:27 +0200 Subject: [master] 929be35 Rearrange and minor updates Message-ID: commit 929be359b4757ff2f11f6f28fd539338c917c4b7 Author: Federico G. Schwindt Date: Fri Aug 14 15:24:08 2015 +0100 Rearrange and minor updates diff --git a/doc/sphinx/reference/vmod.rst b/doc/sphinx/reference/vmod.rst index 6053685..893a1c7 100644 --- a/doc/sphinx/reference/vmod.rst +++ b/doc/sphinx/reference/vmod.rst @@ -56,22 +56,23 @@ The std VMODs vmod.vcc file looks somewhat like this:: $Function STRING tolower(STRING_LIST) $Function VOID set_ip_tos(INT) -The first line gives the name of the module, nothing special there. +The first line gives the name of the module and the manual section where +the documentation will reside. The second line specifies an optional "Event" function, which will be -called whenever a VCL program which imports this VMOD is initially loaded -or transitions to any of the warm, active, cold and discarded states. +called whenever a VCL program which imports this VMOD is loaded or +transitions to any of the warm, active, cold or discarded states. More on this below. -The next three lines specify two functions in the VMOD, along with the -types of the arguments, and that is probably where the hardest bit -of writing a VMOD is to be found, so we will talk about that at length -in a moment. +The next three lines define three functions in the VMOD, along with the +types of the arguments, and that is probably where the hardest bit of +writing a VMOD is to be found, so we will talk about that at length in +a moment. Notice that the third function returns VOID, that makes it a "procedure" -in VCL lingo, meaning that it cannot be used in expressions, right -side of assignments and such places. Instead it can be used as a -primary action, something functions which return a value can not:: +in VCL lingo, meaning that it cannot be used in expressions, right side +of assignments and such. Instead it can be used as a primary action, +something functions which return a value can not:: sub vcl_recv { std.set_ip_tos(32); @@ -98,8 +99,8 @@ For the std VMOD, the compiled vcc_if.h file looks like this:: vmod_event_f event_function; -Those are your C prototypes. Notice the ``vmod_`` prefix on the function -names and the C-types as arguments. +Those are your C prototypes. Notice the ``vmod_`` prefix on the +function names. .. _ref-vmod-vcl-c-types: @@ -111,40 +112,91 @@ VCL data types are targeted at the job, so for instance, we have data types like "DURATION" and "HEADER", but they all have some kind of C language representation. Here is a description of them. -All but the STRING_LIST type have typedefs: VCL_INT, VCL_REAL etc. +All but the PRIV and STRING_LIST types have typedefs: VCL_INT, VCL_REAL, +etc. -INT - C-type: ``long`` +BACKEND + C-type: ``const struct director *`` - An integer as we know and love them. + A type for backend and director implementations. See + :ref:`ref-writing-a-director`. -REAL +BLOB + C-type: ``const struct vmod_priv *`` + + An opaque type to pass random bits of memory between VMOD + functions. + +BOOL + C-type: ``unsigned`` + + Zero means false, anything else means true. + +BYTES C-type: ``double`` - A floating point value. + Unit: bytes. + + A storage space, as in 1024 bytes. DURATION C-type: ``double`` - Unit: seconds + Unit: seconds. A time interval, as in 25 seconds. +ENUM + C-type: ``const char *`` + + TODO + +HEADER + C-type: ``const struct gethdr_s *`` + + These are VCL compiler generated constants referencing a + particular header in a particular HTTP entity, for instance + ``req.http.cookie`` or ``beresp.http.last-modified``. By passing + a reference to the header, the VMOD code can both read and write + the header in question. + + If the header was passed as STRING, the VMOD code only sees + the value, but not where it came from. + +HTTP + C-type: ``struct http *`` + + TODO + +INT + C-type: ``long`` + + A (long) integer as we know and love them. + +IP + C-type: ``const struct suckaddr *`` + + This is an opaque type, see the ``include/vsa.h`` file for + which primitives we support on this type. + +REAL + C-type: ``double`` + + A floating point value. + TIME C-type: ``double`` - Unit: seconds since UNIX epoch + Unit: seconds since UNIX epoch. - An absolute time, as in 1284401161. When used in a string - context is formatted as "Mon, 13 Sep 2010 19:06:01 GMT". + An absolute time, as in 1284401161. STRING C-type: ``const char *`` A NUL-terminated text-string. - Can be NULL to indicate that the nonexistent string, for - instance:: + Can be NULL to indicate a nonexistent string, for instance in:: mymod.foo(req.http.foobar); @@ -192,58 +244,23 @@ STRING_LIST and make sure your workspace_client and workspace_backend params are big enough. -PRIV_VCL - See :ref:`ref-vmod-private-pointers` below - -PRIV_CALL - See :ref:`ref-vmod-private-pointers` below - -PRIV_TASK - See :ref:`ref-vmod-private-pointers` below - -PRIV_TOP - See :ref:`ref-vmod-private-pointers` below - VOID C-type: ``void`` Can only be used for return-value, which makes the function a VCL procedure. -HEADER - C-type: ``const struct gethdr_s *`` - - These are VCL compiler generated constants referencing - a particular header in a particular HTTP entity, for instance - ``req.http.cookie`` or ``beresp.http.last-modified``. - By passing a reference to the header, the VMOD code can - both read and write the header in question. - - If the header was passed as STRING, the VMOD code only sees - the value, but not where it came from. - -IP - C-type: ``const struct suckaddr *`` - - This is an opaque type, see the ``include/vsa.h`` file for - which primitives we support on this type. - -BOOL - C-type: ``unsigned`` - - Zero means false, anything else means true. - -BLOB - C-type: ``const struct vmod_priv *`` +PRIV_VCL + See :ref:`ref-vmod-private-pointers` below. - An opaque type to pass random bits of memory between VMOD - functions. +PRIV_CALL + See :ref:`ref-vmod-private-pointers` below. -BACKEND - C-type: ``const struct director *`` +PRIV_TASK + See :ref:`ref-vmod-private-pointers` below. - A type for backend and director implementations. See - :ref:`ref-writing-a-director`. +PRIV_TOP + See :ref:`ref-vmod-private-pointers` below. .. _ref-vmod-private-pointers: From fgsch at lodoss.net Sat Aug 15 08:35:33 2015 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sat, 15 Aug 2015 10:35:33 +0200 Subject: [master] 21d7396 To keep the OCD at bay sort this the right way Message-ID: commit 21d73961b69280895edb00dbd15116d0db7a1fe7 Author: Federico G. Schwindt Date: Sat Aug 15 00:12:38 2015 +0100 To keep the OCD at bay sort this the right way diff --git a/doc/sphinx/reference/vmod.rst b/doc/sphinx/reference/vmod.rst index 893a1c7..f6516a1 100644 --- a/doc/sphinx/reference/vmod.rst +++ b/doc/sphinx/reference/vmod.rst @@ -179,17 +179,22 @@ IP This is an opaque type, see the ``include/vsa.h`` file for which primitives we support on this type. -REAL - C-type: ``double`` +PRIV_CALL + See :ref:`ref-vmod-private-pointers` below. - A floating point value. +PRIV_TASK + See :ref:`ref-vmod-private-pointers` below. -TIME - C-type: ``double`` +PRIV_TOP + See :ref:`ref-vmod-private-pointers` below. - Unit: seconds since UNIX epoch. +PRIV_VCL + See :ref:`ref-vmod-private-pointers` below. - An absolute time, as in 1284401161. +REAL + C-type: ``double`` + + A floating point value. STRING C-type: ``const char *`` @@ -244,24 +249,19 @@ STRING_LIST and make sure your workspace_client and workspace_backend params are big enough. +TIME + C-type: ``double`` + + Unit: seconds since UNIX epoch. + + An absolute time, as in 1284401161. + VOID C-type: ``void`` Can only be used for return-value, which makes the function a VCL procedure. -PRIV_VCL - See :ref:`ref-vmod-private-pointers` below. - -PRIV_CALL - See :ref:`ref-vmod-private-pointers` below. - -PRIV_TASK - See :ref:`ref-vmod-private-pointers` below. - -PRIV_TOP - See :ref:`ref-vmod-private-pointers` below. - .. _ref-vmod-private-pointers: @@ -279,11 +279,6 @@ The VCL compiler supports the following private pointers: compiled regular expression specific to a regsub() statement or a simply caching the last output of some expensive lookup. -* ``PRIV_VCL`` "per vcl" private pointers are useful for such global - state that applies to all calls in this VCL, for instance flags that - determine if regular expressions are case-sensitive in this vmod or - similar. - * ``PRIV_TASK`` "per task" private pointers are useful for state that applies to calls for either a specific request or a backend request. For instance this can be the result of a parsed cookie @@ -297,6 +292,11 @@ The VCL compiler supports the following private pointers: defined for the client side. When used from backend VCL subs, a NULL pointer will be passed. +* ``PRIV_VCL`` "per vcl" private pointers are useful for such global + state that applies to all calls in this VCL, for instance flags that + determine if regular expressions are case-sensitive in this vmod or + similar. + The way it works in the vmod code, is that a ``struct vmod_priv *`` is passed to the functions where one of the ``PRIV_*`` argument types is specified. From phk at FreeBSD.org Mon Aug 17 05:34:29 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 17 Aug 2015 07:34:29 +0200 Subject: [master] f4053ac Move first_byte_timeout param to new order Message-ID: commit f4053ac00a0fd0b50b8095e586c23ebfd53b016c Author: Poul-Henning Kamp Date: Mon Aug 17 05:34:09 2015 +0000 Move first_byte_timeout param to new order diff --git a/bin/varnishd/common/params.h b/bin/varnishd/common/params.h index c8cd3a6..3dbfe6a 100644 --- a/bin/varnishd/common/params.h +++ b/bin/varnishd/common/params.h @@ -163,9 +163,6 @@ struct params { /* Default connection_timeout */ double connect_timeout; - /* Read timeouts for backend */ - double first_byte_timeout; - /* CLI buffer size */ unsigned cli_buffer; diff --git a/bin/varnishd/mgt/mgt_param_tbl.c b/bin/varnishd/mgt/mgt_param_tbl.c index 565328e..e6318c1 100644 --- a/bin/varnishd/mgt/mgt_param_tbl.c +++ b/bin/varnishd/mgt/mgt_param_tbl.c @@ -308,17 +308,6 @@ struct parspec mgt_parspec[] = { "backend request.", 0, "3.5", "seconds" }, - { "first_byte_timeout", tweak_timeout, - &mgt_param.first_byte_timeout, - "0", NULL, - "Default timeout for receiving first byte from backend. " - "We only wait for this many seconds for the first " - "byte before giving up. A value of 0 means it will never time " - "out. " - "VCL can override this default value for each backend and " - "backend request. This parameter does not apply to pipe.", - 0, - "60", "seconds" }, { "clock_skew", tweak_uint, &mgt_param.clock_skew, "0", NULL, "How much clockskew we are willing to accept between the " diff --git a/include/tbl/params.h b/include/tbl/params.h index 36c1b0d..d3a2982 100644 --- a/include/tbl/params.h +++ b/include/tbl/params.h @@ -178,6 +178,24 @@ PARAM( ) PARAM( + /* name */ first_byte_timeout, + /* tweak */ timeout, + /* min */ "0", + /* max */ NULL, + /* default */ "60", + /* units */ "seconds", + /* flags */ 0, + /* s-text */ + "Default timeout for receiving first byte from backend. We only " + "wait for this many seconds for the first byte before giving up. A " + "value of 0 means it will never time out. VCL can override this " + "default value for each backend and backend request. This " + "parameter does not apply to pipe.", + /* l-text */ "", + /* func */ NULL +) + +PARAM( /* name */ between_bytes_timeout, /* tweak */ timeout, /* min */ "0", @@ -444,24 +462,6 @@ PARAM( /* func */ NULL ) PARAM( - /* name */ first_byte_timeout, - /* tweak */ tweak_timeout, - /* var */ first_byte_timeout, - /* min */ 0.000, - /* max */ none, - /* default */ 60.000, - /* units */ seconds, - /* flags */ 00, - /* s-text */ - "Default timeout for receiving first byte from backend. We only " - "wait for this many seconds for the first byte before giving up. A " - "value of 0 means it will never time out. VCL can override this " - "default value for each backend and backend request. This " - "parameter does not apply to pipe.\n", - /* l-text */ "", - /* func */ NULL -) -PARAM( /* name */ gzip_buffer, /* tweak */ tweak_bytes_u, /* var */ gzip_buffer, From phk at FreeBSD.org Mon Aug 17 06:58:21 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 17 Aug 2015 08:58:21 +0200 Subject: [master] 8dc7483 Rewrite the H1 header fetch without SES_Rx(), this makes it simpler. Message-ID: commit 8dc74833d2bad4ce004f8dd7e78e9b8d6ddc5094 Author: Poul-Henning Kamp Date: Mon Aug 17 06:57:58 2015 +0000 Rewrite the H1 header fetch without SES_Rx(), this makes it simpler. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 6a2b047..648dad4 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -979,7 +979,6 @@ enum htc_status_e { void SES_RxInit(struct http_conn *htc, struct ws *ws, unsigned maxbytes, unsigned maxhdr); void SES_RxReInit(struct http_conn *htc); -enum htc_status_e SES_Rx(struct http_conn *htc, double tmo); enum htc_status_e SES_RxStuff(struct http_conn *, htc_complete_f *, double *t1, double *t2, double ti, double tn); diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c index 8333123..3d23c7c 100644 --- a/bin/varnishd/cache/cache_session.c +++ b/bin/varnishd/cache/cache_session.c @@ -189,32 +189,6 @@ SES_RxReInit(struct http_conn *htc) *htc->rxbuf_e = '\0'; } -/*-------------------------------------------------------------------- - * Receive more HTTP protocol bytes - */ - -enum htc_status_e -SES_Rx(struct http_conn *htc, double tmo) -{ - int i; - - CHECK_OBJ_NOTNULL(htc, HTTP_CONN_MAGIC); - AN(htc->ws->r); - AZ(htc->pipeline_b); - AZ(htc->pipeline_e); - i = (htc->ws->r - htc->rxbuf_e) - 1; /* space for NUL */ - if (i <= 0) - return (HTC_S_OVERFLOW); - i = VTCP_read(htc->fd, htc->rxbuf_e, i, tmo); - if (i == -2) - return (HTC_S_TIMEOUT); - if (i <= 0) - return (HTC_S_EOF); - htc->rxbuf_e += i; - *htc->rxbuf_e = '\0'; - return (HTC_S_MORE); -} - /*---------------------------------------------------------------------- * Receive a request/packet/whatever, with timeouts * diff --git a/bin/varnishd/http1/cache_http1_fetch.c b/bin/varnishd/http1/cache_http1_fetch.c index ca1df5a..1b6ceb4 100644 --- a/bin/varnishd/http1/cache_http1_fetch.c +++ b/bin/varnishd/http1/cache_http1_fetch.c @@ -137,7 +137,6 @@ V1F_FetchRespHdr(struct busyobj *bo) { struct http *hp; - enum htc_status_e hs; int first, i; struct http_conn *htc; @@ -160,23 +159,22 @@ V1F_FetchRespHdr(struct busyobj *bo) first = 1; do { - hs = SES_Rx(htc, 0); - if (hs == HTC_S_MORE) - hs = HTTP1_Complete(htc); - if (hs == HTC_S_OVERFLOW) { - WS_ReleaseP(htc->ws, htc->rxbuf_b); + i = (htc->ws->r - htc->rxbuf_e) - 1; /* space for NUL */ + if (i <= 0) { bo->acct.beresp_hdrbytes += htc->rxbuf_e - htc->rxbuf_b; + WS_ReleaseP(htc->ws, htc->rxbuf_b); VSLb(bo->vsl, SLT_FetchError, "http %sread error: overflow", first ? "first " : ""); htc->doclose = SC_RX_OVERFLOW; return (-1); } - if (hs == HTC_S_EOF) { - WS_ReleaseP(htc->ws, htc->rxbuf_b); + i = read(htc->fd, htc->rxbuf_e, i); + if (i <= 0) { bo->acct.beresp_hdrbytes += htc->rxbuf_e - htc->rxbuf_b; + WS_ReleaseP(htc->ws, htc->rxbuf_b); VSLb(bo->vsl, SLT_FetchError, "http %sread error: EOF", first ? "first " : ""); htc->doclose = SC_RX_TIMEOUT; @@ -187,7 +185,10 @@ V1F_FetchRespHdr(struct busyobj *bo) VTCP_set_read_timeout(htc->fd, htc->between_bytes_timeout); } - } while (hs != HTC_S_COMPLETE); + htc->rxbuf_e += i; + *htc->rxbuf_e = '\0'; + } while (HTTP1_Complete(htc) != HTC_S_COMPLETE); + WS_ReleaseP(htc->ws, htc->rxbuf_e); hp = bo->beresp; From dridi.boukelmoune at gmail.com Mon Aug 17 07:51:04 2015 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 17 Aug 2015 09:51:04 +0200 Subject: [master] d4c1acd Mention health probes for director writers Message-ID: commit d4c1acdf36f3563349cc81aec22aa4d2ad1403de Author: Dridi Boukelmoune Date: Mon Aug 17 09:39:47 2015 +0200 Mention health probes for director writers Add placeholders for pending patches that would need to be documented if merged. diff --git a/doc/sphinx/reference/directors.rst b/doc/sphinx/reference/directors.rst index 3adc333..cbd8a42 100644 --- a/doc/sphinx/reference/directors.rst +++ b/doc/sphinx/reference/directors.rst @@ -82,6 +82,8 @@ below (:ref:`ref-writing-a-director-cluster`). Dynamic Backends ---------------- +.. TODO document the VRT_BACKEND_FIELDS dance + If you want to speak HTTP/1 over TCP, but for some reason VCL does not fit the bill, you can instead reuse the whole backend facility. It allows you for instance to add and remove backends on-demand without the need to reload your @@ -108,8 +110,9 @@ care of it. Consider using an object (see :ref:`ref-vmod-objects`) to manipulate dynamic backends. They are tied to the VCL life cycle and make a handy data structure -to keep track of backends. It is also true for *cluster* directors that may -reference native backends. +to keep track of backends and objects have a VCL name you can reuse for the +director. It is also true for *cluster* directors that may reference native +backends. Finally, Varnish will take care of event propagation for *all* native backends. @@ -133,4 +136,18 @@ request. Health Probes ============= -TODO +It is possible in a VCL program to query the health of a director (see +:ref:`func_healthy`). A director can report its health if it implements the +``healthy`` function, it is otherwise always considered healthy. + +Unless you are making a dynamic backend, you need to take care of the health +probes yourselves. For *cluster* directors, being healthy typically means +having at least one healthy underlying backend or director. + +For dynamic backends, it is just a matter of assigning the ``probe`` field in +the ``struct vrt_backend``. Once the director is created, the probe definition +too is no longer needed. It is then Varnish that will take care of health +probing and disabling the feature on cold VCL (see +:ref:`ref-vmod-event-functions`). + +.. TODO document VCL_PROBE if patchwork #310 is merged diff --git a/doc/sphinx/reference/vmod.rst b/doc/sphinx/reference/vmod.rst index f6516a1..57db2a8 100644 --- a/doc/sphinx/reference/vmod.rst +++ b/doc/sphinx/reference/vmod.rst @@ -115,6 +115,8 @@ language representation. Here is a description of them. All but the PRIV and STRING_LIST types have typedefs: VCL_INT, VCL_REAL, etc. +.. TODO document ACL if patchwork #314 is merged + BACKEND C-type: ``const struct director *`` @@ -191,6 +193,8 @@ PRIV_TOP PRIV_VCL See :ref:`ref-vmod-private-pointers` below. +.. TODO document PROBE if patchwork #310 is merged + REAL C-type: ``double`` From phk at FreeBSD.org Mon Aug 17 08:36:09 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 17 Aug 2015 10:36:09 +0200 Subject: [master] 1cd42e8 Cherry-pick some WS overflow improvements from Lasse's patches. Message-ID: commit 1cd42e831ad75a8e9a03299baac446d066a39258 Author: Poul-Henning Kamp Date: Mon Aug 17 08:35:43 2015 +0000 Cherry-pick some WS overflow improvements from Lasse's patches. diff --git a/bin/varnishd/cache/cache_deliver_proc.c b/bin/varnishd/cache/cache_deliver_proc.c index 4fd666b..c887868 100644 --- a/bin/varnishd/cache/cache_deliver_proc.c +++ b/bin/varnishd/cache/cache_deliver_proc.c @@ -74,7 +74,8 @@ VDP_push(struct req *req, vdp_bytes *func, void *priv, int bottom) VSB_delete(vsb); #endif vdp = WS_Alloc(req->ws, sizeof *vdp); - AN(vdp); + if (vdp == NULL) + return; INIT_OBJ(vdp, VDP_ENTRY_MAGIC); vdp->func = func; vdp->priv = priv; diff --git a/bin/varnishd/cache/cache_range.c b/bin/varnishd/cache/cache_range.c index 6122984..1b4cbb0 100644 --- a/bin/varnishd/cache/cache_range.c +++ b/bin/varnishd/cache/cache_range.c @@ -159,15 +159,18 @@ vrg_dorange(struct req *req, const char *r) http_PrintfHeader(req->resp, "Content-Range: bytes %jd-%jd/*", (intmax_t)low, (intmax_t)high); req->resp_len = (intmax_t)(1 + high - low); - http_PutResponse(req->resp, "HTTP/1.1", 206, NULL); vrg_priv = WS_Alloc(req->ws, sizeof *vrg_priv); + if (vrg_priv == NULL) + return (-1); + XXXAN(vrg_priv); INIT_OBJ(vrg_priv, VRG_PRIV_MAGIC); vrg_priv->range_off = 0; vrg_priv->range_low = low; vrg_priv->range_high = high + 1; VDP_push(req, vrg_range_bytes, vrg_priv, 1); + http_PutResponse(req->resp, "HTTP/1.1", 206, NULL); return (0); } @@ -183,7 +186,7 @@ VRG_dorange(struct req *req, const char *r) /* We must snapshot the length if we're streaming from the backend */ i = vrg_dorange(req, r); - if (i) { + if (i > 0) { VSLb(req->vsl, SLT_Debug, "RANGE_FAIL line %d", i); http_Unset(req->resp, H_Content_Length); if (req->resp_len >= 0) diff --git a/bin/varnishd/cache/cache_vrt_re.c b/bin/varnishd/cache/cache_vrt_re.c index d96c4f4..c1ea167 100644 --- a/bin/varnishd/cache/cache_vrt_re.c +++ b/bin/varnishd/cache/cache_vrt_re.c @@ -171,6 +171,7 @@ VRT_regsub(VRT_CTX, int all, const char *str, void *re, /* Copy suffix to match */ Tadd(&res_b, res_e, str + offset, 1 + len - offset); if (res_b >= res_e) { + WS_MarkOverflow(ctx->ws); WS_Release(ctx->ws, 0); return (str); } From phk at FreeBSD.org Mon Aug 17 09:21:51 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 17 Aug 2015 11:21:51 +0200 Subject: [master] bf3d3dc Dump the VCL temperature in panics Message-ID: commit bf3d3dc2c78f740f6ff5b7bfea11eee1c51787d8 Author: Poul-Henning Kamp Date: Mon Aug 17 09:14:28 2015 +0000 Dump the VCL temperature in panics diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c index dd49cda..0d3ed42 100644 --- a/bin/varnishd/cache/cache_vcl.c +++ b/bin/varnishd/cache/cache_vcl.c @@ -88,6 +88,7 @@ VCL_Panic(struct vsb *vsb, const struct vcl *vcl) return; VSB_printf(vsb, "vcl = {\n"); VSB_indent(vsb, 2); + VSB_printf(vsb, "temp = %s\n", vcl->temp); VSB_printf(vsb, "srcname = {\n"); VSB_indent(vsb, 2); for (i = 0; i < vcl->conf->nsrc; ++i) From phk at FreeBSD.org Mon Aug 17 09:21:51 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 17 Aug 2015 11:21:51 +0200 Subject: [master] 0a800c5 It is OK to VCL_Ref a cooling VCL. Message-ID: commit 0a800c5167b6e8ccd0df483bb69136c30199aac2 Author: Poul-Henning Kamp Date: Mon Aug 17 09:21:13 2015 +0000 It is OK to VCL_Ref a cooling VCL. Fixes: #1776 diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c index 0d3ed42..e11cf01 100644 --- a/bin/varnishd/cache/cache_vcl.c +++ b/bin/varnishd/cache/cache_vcl.c @@ -163,7 +163,7 @@ VCL_Ref(struct vcl *vcl) { CHECK_OBJ_NOTNULL(vcl, VCL_MAGIC); - assert(vcl->temp == vcl_temp_warm); + assert(vcl->temp == vcl_temp_warm || vcl->temp == vcl_temp_cooling); Lck_Lock(&vcl_mtx); assert(vcl->busy > 0); vcl->busy++; From phk at FreeBSD.org Mon Aug 17 09:25:45 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 17 Aug 2015 11:25:45 +0200 Subject: [master] 0dffa87 Fix loading of cold VCLs Message-ID: commit 0dffa87db4bf9d449781d244a00745a23a02803d Author: Poul-Henning Kamp Date: Mon Aug 17 09:25:19 2015 +0000 Fix loading of cold VCLs Fixes: #1775 diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c index e11cf01..9c7ee4a 100644 --- a/bin/varnishd/cache/cache_vcl.c +++ b/bin/varnishd/cache/cache_vcl.c @@ -398,6 +398,10 @@ vcl_set_state(struct vcl *vcl, const char *state) case '0': if (vcl->temp == vcl_temp_cold) break; + if (vcl->temp == vcl_temp_init) { + vcl->temp = vcl_temp_cold; + break; + } if (vcl->busy == 0) { vcl->temp = vcl_temp_cold; (void)vcl->conf->event_vcl(&ctx, VCL_EVENT_COLD); diff --git a/bin/varnishtest/tests/r01775.vtc b/bin/varnishtest/tests/r01775.vtc new file mode 100644 index 0000000..5241b78 --- /dev/null +++ b/bin/varnishtest/tests/r01775.vtc @@ -0,0 +1,12 @@ +varnishtest "Test loading a VCL in cold state" + +server s1 { + rxreq + txresp +} -start + +varnish v1 -vcl+backend { + +} -start + +varnish v1 -cliok {vcl.inline vcl2 "vcl 4.0; backend b { .host = \":80\";}" cold} From dridi.boukelmoune at gmail.com Mon Aug 17 10:17:08 2015 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 17 Aug 2015 12:17:08 +0200 Subject: [master] b68360d Polish, remove a break Message-ID: commit b68360d4ff36a146e1a3103aa162509081f42d77 Author: Dridi Boukelmoune Date: Mon Aug 17 12:11:34 2015 +0200 Polish, remove a break diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c index 9c7ee4a..2b3c5d2 100644 --- a/bin/varnishd/cache/cache_vcl.c +++ b/bin/varnishd/cache/cache_vcl.c @@ -396,12 +396,10 @@ vcl_set_state(struct vcl *vcl, const char *state) switch(state[0]) { case '0': - if (vcl->temp == vcl_temp_cold) - break; - if (vcl->temp == vcl_temp_init) { + if (vcl->temp == vcl_temp_init) vcl->temp = vcl_temp_cold; + if (vcl->temp == vcl_temp_cold) break; - } if (vcl->busy == 0) { vcl->temp = vcl_temp_cold; (void)vcl->conf->event_vcl(&ctx, VCL_EVENT_COLD); From dridi.boukelmoune at gmail.com Tue Aug 18 09:32:05 2015 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 18 Aug 2015 11:32:05 +0200 Subject: [master] a2ed61d Enable probes for dynamic backends Message-ID: commit a2ed61d0be103d817abcc66b93e49a5720cfb3bd Author: Dridi Boukelmoune Date: Tue Aug 18 11:26:28 2015 +0200 Enable probes for dynamic backends Make sure probes can be managed outside of the cli thread, now that backends can be created any time. diff --git a/bin/varnishd/cache/cache_backend_probe.c b/bin/varnishd/cache/cache_backend_probe.c index 8060bb7..e0590d8 100644 --- a/bin/varnishd/cache/cache_backend_probe.c +++ b/bin/varnishd/cache/cache_backend_probe.c @@ -514,7 +514,6 @@ VBP_Control(const struct backend *be, int enable) { struct vbp_target *vt; - ASSERT_CLI(); CHECK_OBJ_NOTNULL(be, BACKEND_MAGIC); vt = be->probe; CHECK_OBJ_NOTNULL(vt, VBP_TARGET_MAGIC); @@ -545,7 +544,6 @@ VBP_Insert(struct backend *b, const struct vrt_backend_probe *vp, { struct vbp_target *vt; - ASSERT_CLI(); CHECK_OBJ_NOTNULL(b, BACKEND_MAGIC); CHECK_OBJ_NOTNULL(vp, VRT_BACKEND_PROBE_MAGIC); @@ -570,7 +568,6 @@ VBP_Remove(struct backend *be) { struct vbp_target *vt; - ASSERT_CLI(); CHECK_OBJ_NOTNULL(be, BACKEND_MAGIC); vt = be->probe; CHECK_OBJ_NOTNULL(vt, VBP_TARGET_MAGIC); From daghf at varnish-software.com Tue Aug 18 09:46:08 2015 From: daghf at varnish-software.com (Dag Haavi Finstad) Date: Tue, 18 Aug 2015 11:46:08 +0200 Subject: [master] c9b0aa0 Make varnishtop's vtree bits static. Message-ID: commit c9b0aa06e2a7f4bffb5b71cc183ba6bd1bd3ac3c Author: Dag Haavi Finstad Date: Tue Aug 18 11:45:49 2015 +0200 Make varnishtop's vtree bits static. diff --git a/bin/varnishtop/varnishtop.c b/bin/varnishtop/varnishtop.c index f9aaf47..3c4c733 100644 --- a/bin/varnishtop/varnishtop.c +++ b/bin/varnishtop/varnishtop.c @@ -109,10 +109,10 @@ static int f_flag = 0; static unsigned maxfieldlen = 0; -VRB_PROTOTYPE(t_order, top, e_order, cmp_order); -VRB_GENERATE(t_order, top, e_order, cmp_order); -VRB_PROTOTYPE(t_key, top, e_key, cmp_key); -VRB_GENERATE(t_key, top, e_key, cmp_key); +VRB_PROTOTYPE_STATIC(t_order, top, e_order, cmp_order); +VRB_GENERATE_STATIC(t_order, top, e_order, cmp_order); +VRB_PROTOTYPE_STATIC(t_key, top, e_key, cmp_key); +VRB_GENERATE_STATIC(t_key, top, e_key, cmp_key); static int __match_proto__(VSLQ_dispatch_f) accumulate(struct VSL_data *vsl, struct VSL_transaction * const pt[], From dridi.boukelmoune at gmail.com Tue Aug 18 09:51:09 2015 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 18 Aug 2015 11:51:09 +0200 Subject: [master] 6b4cbe2 Expose VCL probes to VMODs Message-ID: commit 6b4cbe2645331fb5466b6a5a8695a0913d2b1b1a Author: Dridi Boukelmoune Date: Tue Aug 18 11:40:08 2015 +0200 Expose VCL probes to VMODs diff --git a/doc/sphinx/reference/directors.rst b/doc/sphinx/reference/directors.rst index cbd8a42..8a16c87 100644 --- a/doc/sphinx/reference/directors.rst +++ b/doc/sphinx/reference/directors.rst @@ -150,4 +150,5 @@ too is no longer needed. It is then Varnish that will take care of health probing and disabling the feature on cold VCL (see :ref:`ref-vmod-event-functions`). -.. TODO document VCL_PROBE if patchwork #310 is merged +Instead of initializing your own probe definition, you can get a ``VCL_PROBE`` +directly built from VCL (see :ref:`ref-vmod-vcl-c-types`). diff --git a/doc/sphinx/reference/vmod.rst b/doc/sphinx/reference/vmod.rst index 57db2a8..0446e83 100644 --- a/doc/sphinx/reference/vmod.rst +++ b/doc/sphinx/reference/vmod.rst @@ -193,7 +193,10 @@ PRIV_TOP PRIV_VCL See :ref:`ref-vmod-private-pointers` below. -.. TODO document PROBE if patchwork #310 is merged +PROBE + C-type: ``const struct vrt_backend_probe *`` + + A named standalone backend probe definition. REAL C-type: ``double`` diff --git a/include/vrt.h b/include/vrt.h index 98168a3..4b429dd 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -67,20 +67,21 @@ struct ws; * (alphabetic order) */ -typedef const struct director * VCL_BACKEND; -typedef const struct vmod_priv * VCL_BLOB; -typedef unsigned VCL_BOOL; -typedef double VCL_BYTES; -typedef double VCL_DURATION; -typedef const char * VCL_ENUM; -typedef const struct gethdr_s * VCL_HEADER; -typedef struct http * VCL_HTTP; -typedef long VCL_INT; -typedef const struct suckaddr * VCL_IP; -typedef double VCL_REAL; -typedef const char * VCL_STRING; -typedef double VCL_TIME; -typedef void VCL_VOID; +typedef const struct director * VCL_BACKEND; +typedef const struct vmod_priv * VCL_BLOB; +typedef unsigned VCL_BOOL; +typedef double VCL_BYTES; +typedef double VCL_DURATION; +typedef const char * VCL_ENUM; +typedef const struct gethdr_s * VCL_HEADER; +typedef struct http * VCL_HTTP; +typedef long VCL_INT; +typedef const struct suckaddr * VCL_IP; +typedef const struct vrt_backend_probe * VCL_PROBE; +typedef double VCL_REAL; +typedef const char * VCL_STRING; +typedef double VCL_TIME; +typedef void VCL_VOID; /*********************************************************************** * This is the composite argument we pass to compiled VCL and VRT diff --git a/lib/libvcc/vcc_backend.c b/lib/libvcc/vcc_backend.c index c0501a3..14aedf3 100644 --- a/lib/libvcc/vcc_backend.c +++ b/lib/libvcc/vcc_backend.c @@ -249,7 +249,7 @@ void vcc_ParseProbe(struct vcc *tl) { struct token *t_probe; - int i; + struct symbol *sym; char *p; vcc_NextToken(tl); /* ID: probe */ @@ -258,11 +258,18 @@ vcc_ParseProbe(struct vcc *tl) ERRCHK(tl); t_probe = tl->t; vcc_NextToken(tl); - i = vcc_AddDef(tl, t_probe, SYM_PROBE); - if (i > 1) { + + sym = VCC_GetSymbolTok(tl, t_probe, SYM_PROBE); + AN(sym); + if (sym->ndef > 0) { VSB_printf(tl->sb, "Probe %.*s redefined\n", PF(t_probe)); vcc_ErrWhere(tl, t_probe); + return; } + sym->fmt = PROBE; + sym->eval = vcc_Eval_Probe; + sym->ndef++; + ERRCHK(tl); vcc_ParseProbeSpec(tl, t_probe, &p); if (vcc_IdIs(t_probe, "default")) { diff --git a/lib/libvcc/vcc_compile.h b/lib/libvcc/vcc_compile.h index 86f731d..893369e 100644 --- a/lib/libvcc/vcc_compile.h +++ b/lib/libvcc/vcc_compile.h @@ -280,6 +280,7 @@ sym_expr_t vcc_Eval_SymFunc; void vcc_Eval_Func(struct vcc *tl, const char *cfunc, const char *extra, const char *name, const char *args); sym_expr_t vcc_Eval_Backend; +sym_expr_t vcc_Eval_Probe; /* vcc_obj.c */ extern const struct var vcc_vars[]; diff --git a/lib/libvcc/vcc_expr.c b/lib/libvcc/vcc_expr.c index b9c6531..294d12a 100644 --- a/lib/libvcc/vcc_expr.c +++ b/lib/libvcc/vcc_expr.c @@ -516,6 +516,23 @@ vcc_Eval_Backend(struct vcc *tl, struct expr **e, const struct symbol *sym) /*-------------------------------------------------------------------- */ + +void +vcc_Eval_Probe(struct vcc *tl, struct expr **e, const struct symbol *sym) +{ + + assert(sym->kind == SYM_PROBE); + + vcc_ExpectCid(tl); + vcc_AddRef(tl, tl->t, SYM_PROBE); + *e = vcc_mk_expr(PROBE, "&vgc_probe_%.*s", PF(tl->t)); + (*e)->constant = EXPR_VAR; /* XXX ? */ + vcc_NextToken(tl); +} + +/*-------------------------------------------------------------------- + */ + void vcc_Eval_Var(struct vcc *tl, struct expr **e, const struct symbol *sym) { @@ -812,6 +829,8 @@ vcc_expr4(struct vcc *tl, struct expr **e, enum var_type fmt) sym = NULL; if (fmt == BACKEND) sym = VCC_FindSymbol(tl, tl->t, SYM_BACKEND); + if (fmt == PROBE) + sym = VCC_FindSymbol(tl, tl->t, SYM_PROBE); if (sym == NULL) sym = VCC_FindSymbol(tl, tl->t, SYM_VAR); if (sym == NULL) @@ -831,6 +850,7 @@ vcc_expr4(struct vcc *tl, struct expr **e, enum var_type fmt) case SYM_VAR: case SYM_FUNC: case SYM_BACKEND: + case SYM_PROBE: AN(sym->eval); AZ(*e); sym->eval(tl, e, sym); diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py index 01de3a7..5a6c0fc 100755 --- a/lib/libvcc/vmodtool.py +++ b/lib/libvcc/vmodtool.py @@ -60,6 +60,7 @@ ctypes = { 'PRIV_VCL': "struct vmod_priv *", 'PRIV_TASK': "struct vmod_priv *", 'PRIV_TOP': "struct vmod_priv *", + 'PROBE': "VCL_PROBE", 'REAL': "VCL_REAL", 'STRING': "VCL_STRING", 'STRING_LIST': "const char *, ...", From dridi.boukelmoune at gmail.com Tue Aug 18 13:12:51 2015 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 18 Aug 2015 15:12:51 +0200 Subject: [master] 2c4cb15 More details on event considerations for directors Message-ID: commit 2c4cb155e59e398d989a38473b37d6f9b6c403f5 Author: Dridi Boukelmoune Date: Tue Aug 18 15:06:34 2015 +0200 More details on event considerations for directors diff --git a/doc/sphinx/reference/directors.rst b/doc/sphinx/reference/directors.rst index 8a16c87..c4e6ecb 100644 --- a/doc/sphinx/reference/directors.rst +++ b/doc/sphinx/reference/directors.rst @@ -114,7 +114,11 @@ to keep track of backends and objects have a VCL name you can reuse for the director. It is also true for *cluster* directors that may reference native backends. -Finally, Varnish will take care of event propagation for *all* native backends. +Finally, Varnish will take care of event propagation for *all* native backends, +but dynamic backends can only be created when the VCL is warm. If your backends +are created by an independant thread (basically outside of VCL scope) you must +subscribe to VCL events and watch for VCL state (see +:ref:`ref-vmod-event-functions`). .. _ref-writing-a-director-cluster: From nils.goroll at uplex.de Tue Aug 18 16:02:04 2015 From: nils.goroll at uplex.de (Nils Goroll) Date: Tue, 18 Aug 2015 18:02:04 +0200 Subject: [master] 304342f vmodtool should actually raise an error for unknown keywords Message-ID: commit 304342fdb096d96c0d391f45e43ebca1314b339e Author: Nils Goroll Date: Tue Aug 18 17:58:29 2015 +0200 vmodtool should actually raise an error for unknown keywords ... like 'Unknown keyword: $Init' for 4.0 vcc files. diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py index 5a6c0fc..85a9ac2 100755 --- a/lib/libvcc/vmodtool.py +++ b/lib/libvcc/vmodtool.py @@ -870,14 +870,6 @@ def runmain(inputvcc, outputname="vcc_if"): ####################################################################### # Break into sections - keywords = { - "$Module": True, - "$Function": True, - "$Object": True, - "$Method": True, - "$Event": True, - } - sl = [] sc = FileSection() sl.append(sc) @@ -885,7 +877,7 @@ def runmain(inputvcc, outputname="vcc_if"): ln += 1 l = lines.pop(0) j = l.split() - if len(j) > 0 and j[0] in keywords: + if len(j) > 0 and re.match("^\$", j[0]): sc = FileSection() sl.append(sc) sc.add_line(ln, l) From dridi.boukelmoune at gmail.com Fri Aug 21 11:45:38 2015 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 21 Aug 2015 13:45:38 +0200 Subject: [master] a2d7099 Always send the VCL when delivering a VCL event Message-ID: commit a2d7099ebc25709d8905e34e341bc3abb59eb1e2 Author: Dridi Boukelmoune Date: Fri Aug 21 13:42:15 2015 +0200 Always send the VCL when delivering a VCL event diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c index 2b3c5d2..b4fda32 100644 --- a/bin/varnishd/cache/cache_vcl.c +++ b/bin/varnishd/cache/cache_vcl.c @@ -393,6 +393,7 @@ vcl_set_state(struct vcl *vcl, const char *state) INIT_OBJ(&ctx, VRT_CTX_MAGIC); ctx.handling = &hand; + ctx.vcl = vcl; switch(state[0]) { case '0': From dridi.boukelmoune at gmail.com Fri Aug 21 12:22:33 2015 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 21 Aug 2015 14:22:33 +0200 Subject: [master] 2998862 Always carry the VCL along with a VCL event Message-ID: commit 2998862d53516313ace942ed61edbb35f44f0d47 Author: Dridi Boukelmoune Date: Fri Aug 21 14:20:04 2015 +0200 Always carry the VCL along with a VCL event diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c index b4fda32..7e6247b 100644 --- a/bin/varnishd/cache/cache_vcl.c +++ b/bin/varnishd/cache/cache_vcl.c @@ -625,6 +625,7 @@ ccf_config_use(struct cli *cli, const char * const *av, void *priv) vsb = VSB_new_auto(); AN(vsb); ctx.msg = vsb; + ctx.vcl = vcl; i = vcl->conf->event_vcl(&ctx, VCL_EVENT_USE); AZ(VSB_finish(vsb)); if (i) { From dridi.boukelmoune at gmail.com Fri Aug 21 15:31:15 2015 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 21 Aug 2015 17:31:15 +0200 Subject: [master] d3a0764 Remove the length limit for backends display name Message-ID: commit d3a0764a7f1cc951055b7908f06ae7b61d960161 Author: Dridi Boukelmoune Date: Fri Aug 21 17:22:36 2015 +0200 Remove the length limit for backends display name diff --git a/bin/varnishd/cache/cache_backend_cfg.c b/bin/varnishd/cache/cache_backend_cfg.c index 3db5dbd..0a58de1 100644 --- a/bin/varnishd/cache/cache_backend_cfg.c +++ b/bin/varnishd/cache/cache_backend_cfg.c @@ -65,7 +65,7 @@ struct director * VRT_new_backend(VRT_CTX, const struct vrt_backend *vrt) { struct backend *b; - char buf[128]; + struct vsb *vsb; struct vcl *vcl; struct tcp_pool *tp = NULL; const struct vrt_backend_probe *vbp; @@ -89,8 +89,14 @@ VRT_new_backend(VRT_CTX, const struct vrt_backend *vrt) #undef DA #undef DN - bprintf(buf, "%s.%s", VCL_Name(vcl), vrt->vcl_name); - REPLACE(b->display_name, buf); + vsb = VSB_new_auto(); + AN(vsb); + VSB_printf(vsb, "%s.%s", VCL_Name(vcl), vrt->vcl_name); + AZ(VSB_finish(vsb)); + + b->display_name = strdup(VSB_data(vsb)); + AN(b->display_name); + VSB_delete(vsb); b->vcl = vcl; From dridi.boukelmoune at gmail.com Sun Aug 23 10:35:52 2015 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Sun, 23 Aug 2015 12:35:52 +0200 Subject: [master] 987ea3c Only the cli thread can send events to backends Message-ID: commit 987ea3c1040132d89da9ce2b7801679af061f537 Author: Dridi Boukelmoune Date: Sun Aug 23 12:25:27 2015 +0200 Only the cli thread can send events to backends diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c index 7e6247b..139e18b 100644 --- a/bin/varnishd/cache/cache_vcl.c +++ b/bin/varnishd/cache/cache_vcl.c @@ -229,6 +229,7 @@ vcl_BackendEvent(const struct vcl *vcl, enum vcl_event_e e) { struct backend *be; + ASSERT_CLI(); CHECK_OBJ_NOTNULL(vcl, VCL_MAGIC); AZ(vcl->busy); From dridi.boukelmoune at gmail.com Sun Aug 23 10:35:52 2015 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Sun, 23 Aug 2015 12:35:52 +0200 Subject: [master] d771942 Hide backends and directors implementation details Message-ID: commit d771942c0c6f151e267b63bbc548a4d4371b25be Author: Dridi Boukelmoune Date: Sun Aug 23 12:29:29 2015 +0200 Hide backends and directors implementation details Don't install cache_backend.h and cache_director.h, they expose more than what a VMOD needs to see. The VRT API jumps directly from struct vrt_backend to struct director, which makes struct backend more than simply opaque, it is completely invisible. However struct director needs to be visible and has been moved to cache.h along with its functions definitions. diff --git a/bin/varnishd/Makefile.am b/bin/varnishd/Makefile.am index dd2bae2..eb01348 100644 --- a/bin/varnishd/Makefile.am +++ b/bin/varnishd/Makefile.am @@ -99,6 +99,8 @@ varnishd_SOURCES = \ noinst_HEADERS = \ builtin_vcl.h \ + cache/cache_backend.h \ + cache/cache_director.h \ cache/cache_esi.h \ cache/cache_pool.h \ common/heritage.h \ @@ -116,8 +118,6 @@ noinst_HEADERS = \ nobase_pkginclude_HEADERS = \ cache/cache.h \ cache/cache_filter.h \ - cache/cache_backend.h \ - cache/cache_director.h \ common/common.h \ common/params.h \ waiter/waiter.h diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 648dad4..ed72296 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -190,6 +190,47 @@ struct http { }; /*-------------------------------------------------------------------- + * Director public APIs + */ + +typedef unsigned vdi_healthy_f(const struct director *, const struct busyobj *, + double *changed); + +typedef const struct director *vdi_resolve_f(const struct director *, + struct worker *, struct busyobj *); + +typedef int vdi_gethdrs_f(const struct director *, struct worker *, + struct busyobj *); +typedef int vdi_getbody_f(const struct director *, struct worker *, + struct busyobj *); +typedef const struct suckaddr *vdi_getip_f(const struct director *, + struct worker *, struct busyobj *); +typedef void vdi_finish_f(const struct director *, struct worker *, + struct busyobj *); + +typedef void vdi_http1pipe_f(const struct director *, struct req *, + struct busyobj *); + +typedef void vdi_panic_f(const struct director *, struct vsb *); + +struct director { + unsigned magic; +#define DIRECTOR_MAGIC 0x3336351d + const char *name; + char *vcl_name; + vdi_http1pipe_f *http1pipe; + vdi_healthy_f *healthy; + vdi_resolve_f *resolve; + vdi_gethdrs_f *gethdrs; + vdi_getbody_f *getbody; + vdi_getip_f *getip; + vdi_finish_f *finish; + vdi_panic_f *panic; + void *priv; + const void *priv2; +}; + +/*-------------------------------------------------------------------- * VFP filter state */ diff --git a/bin/varnishd/cache/cache_director.h b/bin/varnishd/cache/cache_director.h index cf20dc1..3bccf80 100644 --- a/bin/varnishd/cache/cache_director.h +++ b/bin/varnishd/cache/cache_director.h @@ -37,49 +37,6 @@ * */ -/*-------------------------------------------------------------------- - * A director is a piece of code which selects one of possibly multiple - * backends to use. - */ - - -typedef unsigned vdi_healthy_f(const struct director *, const struct busyobj *, - double *changed); - -typedef const struct director *vdi_resolve_f(const struct director *, - struct worker *, struct busyobj *); - -typedef int vdi_gethdrs_f(const struct director *, struct worker *, - struct busyobj *); -typedef int vdi_getbody_f(const struct director *, struct worker *, - struct busyobj *); -typedef const struct suckaddr *vdi_getip_f(const struct director *, - struct worker *, struct busyobj *); -typedef void vdi_finish_f(const struct director *, struct worker *, - struct busyobj *); - -typedef void vdi_http1pipe_f(const struct director *, struct req *, - struct busyobj *); - -typedef void vdi_panic_f(const struct director *, struct vsb *); - -struct director { - unsigned magic; -#define DIRECTOR_MAGIC 0x3336351d - const char *name; - char *vcl_name; - vdi_http1pipe_f *http1pipe; - vdi_healthy_f *healthy; - vdi_resolve_f *resolve; - vdi_gethdrs_f *gethdrs; - vdi_getbody_f *getbody; - vdi_getip_f *getip; - vdi_finish_f *finish; - vdi_panic_f *panic; - void *priv; - const void *priv2; -}; - /* cache_director.c */ int VDI_GetHdr(struct worker *, struct busyobj *); diff --git a/lib/libvmod_directors/vdir.c b/lib/libvmod_directors/vdir.c index 411df34..1738bcf 100644 --- a/lib/libvmod_directors/vdir.c +++ b/lib/libvmod_directors/vdir.c @@ -31,7 +31,6 @@ #include #include "cache/cache.h" -#include "cache/cache_director.h" #include "vrt.h" #include "vbm.h" From phk at FreeBSD.org Tue Aug 25 09:33:32 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 25 Aug 2015 11:33:32 +0200 Subject: [master] 8796fa6 Silence FlexeLint Message-ID: commit 8796fa66a10d790fec8b5a8e7ebdcc97d1c72712 Author: Poul-Henning Kamp Date: Tue Aug 25 09:12:14 2015 +0000 Silence FlexeLint diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index 617b65d..614317a 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -275,10 +275,12 @@ pan_busyobj(struct vsb *vsb, const struct busyobj *bo) VSB_printf(vsb, "state = %d,\n", (int)bo->state); VSB_printf(vsb, "flags = {"); p = ""; + /*lint -save -esym(438,p) */ #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"); if (VALID_OBJ(bo->htc, HTTP_CONN_MAGIC)) From phk at FreeBSD.org Tue Aug 25 09:33:32 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 25 Aug 2015 11:33:32 +0200 Subject: [master] 5fa4368 Make range processing log real messages rather than line numbers Message-ID: commit 5fa4368e946a3ef469cddb2b879765b03791cf2c Author: Poul-Henning Kamp Date: Tue Aug 25 09:33:14 2015 +0000 Make range processing log real messages rather than line numbers diff --git a/bin/varnishd/cache/cache_range.c b/bin/varnishd/cache/cache_range.c index 1b4cbb0..729533e 100644 --- a/bin/varnishd/cache/cache_range.c +++ b/bin/varnishd/cache/cache_range.c @@ -85,14 +85,14 @@ vrg_range_bytes(struct req *req, enum vdp_action act, void **priv, /*--------------------------------------------------------------------*/ -static int +static const char * vrg_dorange(struct req *req, const char *r) { ssize_t low, high, has_low, has_high, t; struct vrg_priv *vrg_priv; if (strncasecmp(r, "bytes=", 6)) - return (__LINE__); + return ("Not Bytes"); r += 6; /* The low end of range */ @@ -103,11 +103,11 @@ vrg_dorange(struct req *req, const char *r) low *= 10; low += *r++ - '0'; if (low < t) - return (__LINE__); + return ("Low number too big"); } if (*r++ != '-') - return (__LINE__); + return ("Missing hyphen"); /* The high end of range */ has_high = high = 0; @@ -117,20 +117,20 @@ vrg_dorange(struct req *req, const char *r) high *= 10; high += *r++ - '0'; if (high < t) - return (__LINE__); + return ("High number too big"); } if (*r != '\0') - return (__LINE__); + return ("Trailing stuff"); if (has_high + has_low == 0) - return (__LINE__); + return ("Neither high nor low"); if (!has_low) { if (req->resp_len < 0) - return (0); // Allow 200 response + return (NULL); // Allow 200 response if (high == 0) - return (__LINE__); + return ("No low, high is zero"); low = req->resp_len - high; if (low < 0) low = 0; @@ -138,7 +138,7 @@ vrg_dorange(struct req *req, const char *r) } else if (req->resp_len >= 0 && (high >= req->resp_len || !has_high)) high = req->resp_len - 1; else if (!has_high) - return (0); // Allow 200 response + return (NULL); // Allow 200 response /* * else (bo != NULL) { * We assume that the client knows what it's doing and trust @@ -147,10 +147,10 @@ vrg_dorange(struct req *req, const char *r) */ if (high < low) - return (__LINE__); + return ("high smaller than low"); if (req->resp_len >= 0 && low >= req->resp_len) - return (__LINE__); + return ("low range beyond object"); if (req->resp_len >= 0) http_PrintfHeader(req->resp, "Content-Range: bytes %jd-%jd/%jd", @@ -162,7 +162,7 @@ vrg_dorange(struct req *req, const char *r) vrg_priv = WS_Alloc(req->ws, sizeof *vrg_priv); if (vrg_priv == NULL) - return (-1); + return ("WS too small"); XXXAN(vrg_priv); INIT_OBJ(vrg_priv, VRG_PRIV_MAGIC); @@ -171,13 +171,13 @@ vrg_dorange(struct req *req, const char *r) vrg_priv->range_high = high + 1; VDP_push(req, vrg_range_bytes, vrg_priv, 1); http_PutResponse(req->resp, "HTTP/1.1", 206, NULL); - return (0); + return (NULL); } void VRG_dorange(struct req *req, const char *r) { - int i; + const char *err; CHECK_OBJ_NOTNULL(req, REQ_MAGIC); CHECK_OBJ_NOTNULL(req->objcore, OBJCORE_MAGIC); @@ -185,9 +185,9 @@ VRG_dorange(struct req *req, const char *r) /* We must snapshot the length if we're streaming from the backend */ - i = vrg_dorange(req, r); - if (i > 0) { - VSLb(req->vsl, SLT_Debug, "RANGE_FAIL line %d", i); + err = vrg_dorange(req, r); + if (err != NULL) { + VSLb(req->vsl, SLT_Debug, "RANGE_FAIL %s", err); http_Unset(req->resp, H_Content_Length); if (req->resp_len >= 0) http_PrintfHeader(req->resp, From daghf at varnish-software.com Tue Aug 25 13:24:54 2015 From: daghf at varnish-software.com (Dag Haavi Finstad) Date: Tue, 25 Aug 2015 15:24:54 +0200 Subject: [master] 69123e7 Minor language cleanup. Message-ID: commit 69123e7e17fba178af5ea8c1ae83cc4f6e7cc3a2 Author: Dag Haavi Finstad Date: Tue Aug 25 15:24:47 2015 +0200 Minor language cleanup. diff --git a/doc/sphinx/reference/directors.rst b/doc/sphinx/reference/directors.rst index c4e6ecb..de321b2 100644 --- a/doc/sphinx/reference/directors.rst +++ b/doc/sphinx/reference/directors.rst @@ -22,8 +22,8 @@ Backends vs Directors The intuitive classification for backend and director is an endpoint for the former and a cluster for the latter, but the actual implementation is a bit -more subtle. VMODs can accept backend arguments return backends in VCL (see -:ref:`ref-vmod-vcl-c-types`), but he underlying C type is ``struct director``. +more subtle. VMODs can accept backend arguments and return backends in VCL (see +:ref:`ref-vmod-vcl-c-types`), but the underlying C type is ``struct director``. Under the hood director is a generic concept, and a backend is a kind of director. @@ -69,8 +69,8 @@ implements native backends. It is the canonical implementation, and though it provides other services like connection pooling or statistics, it is essentially a director which state is a ``struct backend``. Varnish native backends currently speak HTTP/1 over TCP, and as such, you need to make your -own custom backend if you want Varnish to do otherwise such as connecting over -UDP or UNIX-domain sockets or speaking a different protocol. +own custom backend if you want Varnish to do otherwise such as connect over +UDP or UNIX-domain sockets or speak a different protocol. You may also consider making your custom backend compliant with regards to the VCL state (see :ref:`ref-vmod-event-functions`). @@ -150,8 +150,8 @@ having at least one healthy underlying backend or director. For dynamic backends, it is just a matter of assigning the ``probe`` field in the ``struct vrt_backend``. Once the director is created, the probe definition -too is no longer needed. It is then Varnish that will take care of health -probing and disabling the feature on cold VCL (see +too is no longer needed. It is then Varnish that will take care of the health +probe and disable the feature on a cold VCL (see :ref:`ref-vmod-event-functions`). Instead of initializing your own probe definition, you can get a ``VCL_PROBE`` From phk at FreeBSD.org Tue Aug 25 15:44:39 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 25 Aug 2015 17:44:39 +0200 Subject: [master] 1215933 Disable speculative Range handling on streaming transactions where we don't yet know the length. Message-ID: commit 121593312daabbef4e290a590b364a099980a8b7 Author: Poul-Henning Kamp Date: Tue Aug 25 15:42:26 2015 +0000 Disable speculative Range handling on streaming transactions where we don't yet know the length. I attempted to add a way to determine if the object was big enough *yet* to satisfy the Range, but that was non-viable. Fixes: #1777 diff --git a/bin/varnishd/cache/cache_range.c b/bin/varnishd/cache/cache_range.c index 729533e..9b2580e 100644 --- a/bin/varnishd/cache/cache_range.c +++ b/bin/varnishd/cache/cache_range.c @@ -137,7 +137,7 @@ vrg_dorange(struct req *req, const char *r) high = req->resp_len - 1; } else if (req->resp_len >= 0 && (high >= req->resp_len || !has_high)) high = req->resp_len - 1; - else if (!has_high) + else if (!has_high || req->resp_len < 0) return (NULL); // Allow 200 response /* * else (bo != NULL) { diff --git a/bin/varnishtest/tests.disabled/e00029.vtc b/bin/varnishtest/tests.disabled/e00029.vtc new file mode 100644 index 0000000..ea3dd70 --- /dev/null +++ b/bin/varnishtest/tests.disabled/e00029.vtc @@ -0,0 +1,42 @@ +varnishtest "fun esi includes and ranges" + +server s1 { + rxreq + expect req.url == "/1" + txresp -body {} + + rxreq + expect req.url == /bar + txresp -body {} + + rxreq + expect req.url == /foo + txresp -body "ABCD" + + rxreq + expect req.url == "/2" + txresp -gzipbody {} + +} -start + +varnish v1 -vcl+backend { + sub vcl_recv { + if (req.url == "/bar") { + set req.http.Range = "bytes=7-8"; + } + } + sub vcl_backend_response { + set beresp.do_esi = true; + } +} -start + +client c1 { + txreq -url /1 -hdr "Accept-encoding: gzip" + rxresp + expect resp.body == "BC" + delay .1 + txreq -url /2 -hdr "Accept-encoding: gzip" + rxresp + gunzip + expect resp.body == "BC" +} -run diff --git a/bin/varnishtest/tests.disabled/r01506.vtc b/bin/varnishtest/tests.disabled/r01506.vtc new file mode 100644 index 0000000..f2bb5b2 --- /dev/null +++ b/bin/varnishtest/tests.disabled/r01506.vtc @@ -0,0 +1,72 @@ +varnishtest "range requests on streamed response" + +server s1 -repeat 4 { + rxreq + txresp -nolen \ + -hdr "Transfer-Encoding: chunked" \ + -hdr "Connection: close" + send "11\r\n0_23456789abcdef\n" + send "11\r\n1_23456789abcdef\n" + send "11\r\n2_23456789abcdef\n" + send "11\r\n3_23456789abcdef\n" + sema r1 sync 2 + send "11\r\n4_23456789abcdef\n" + send "11\r\n5_23456789abcdef\n" + send "11\r\n6_23456789abcdef\n" + send "11\r\n7_23456789abcdef\n" + chunkedlen 0 + +} -start + +varnish v1 -vcl+backend {} -start + +varnish v1 -cliok "param.set debug +syncvsl" + +logexpect l1 -v v1 -g session { + expect 0 1000 Begin sess + expect * = SessClose RANGE_SHORT +} -start + +client c1 { + txreq -url /1 -hdr "Range: bytes=17-101" + rxresphdrs + expect resp.status == 206 + expect resp.http.content-length == 85 + sema r1 sync 2 + rxrespbody + expect resp.bodylen == 85 + delay .1 + + # We cannot do tail-ranges when streaming + txreq -url /2 -hdr "Range: bytes=-10" + rxresphdrs + expect resp.status == 200 + expect resp.http.Transfer-Encoding == chunked + sema r1 sync 2 + rxrespbody + expect resp.bodylen == 136 + delay .1 + + # We cannot do open-ranges when streaming + txreq -url /3 -hdr "Range: bytes=17-" + rxresphdrs + expect resp.status == 200 + expect resp.http.Transfer-Encoding == chunked + sema r1 sync 2 + rxrespbody + expect resp.bodylen == 136 + delay .1 + + # Invalid range + txreq -url /4 -hdr "Range: bytes=102-200" + rxresphdrs + expect resp.status == 206 + expect resp.http.content-length == 99 + sema r1 sync 2 + recv 34 + delay .3 + expect_close +} -run + +varnish v1 -expect sc_range_short == 1 +logexpect l1 -wait diff --git a/bin/varnishtest/tests.disabled/r01732.vtc b/bin/varnishtest/tests.disabled/r01732.vtc new file mode 100644 index 0000000..f738dec --- /dev/null +++ b/bin/varnishtest/tests.disabled/r01732.vtc @@ -0,0 +1,38 @@ +varnishtest "range related panic" + +server s1 { + rxreq + txresp -nolen -hdr "Transfer-Encoding: chunked" + chunkedlen 10 + chunkedlen 10 + sema r1 sync 2 + chunkedlen 10 + chunkedlen 10 + chunkedlen 10 + chunkedlen 0 + delay .1 + sema r2 sync 2 +} -start + +varnish v1 -vcl+backend { +} -start + +client c1 { + txreq -hdr "Range: bytes=0-100" + rxresphdrs + expect resp.status == 206 + expect resp.http.Content-Range == "bytes 0-100/*" +} -run + +delay .1 +sema r1 sync 2 +sema r2 sync 2 +delay .4 + +client c1 { + txreq -hdr "Range: bytes=0-100" + rxresp + expect resp.status == 206 + expect resp.http.Content-Range == "bytes 0-49/50" +} -run + diff --git a/bin/varnishtest/tests/c00034.vtc b/bin/varnishtest/tests/c00034.vtc index b1698cd..2b440c9 100644 --- a/bin/varnishtest/tests/c00034.vtc +++ b/bin/varnishtest/tests/c00034.vtc @@ -176,7 +176,7 @@ client c1 { -hdr "Range: bytes=2-5" \ -hdr "Accept-encoding: gzip" rxresp - expect resp.status == 206 - expect resp.http.Content-Range == "bytes 2-5/*" - expect resp.http.Content-Length == 4 + expect resp.status == 200 + gunzip + expect resp.bodylen == 100 } -run diff --git a/bin/varnishtest/tests/e00029.vtc b/bin/varnishtest/tests/e00029.vtc deleted file mode 100644 index ea3dd70..0000000 --- a/bin/varnishtest/tests/e00029.vtc +++ /dev/null @@ -1,42 +0,0 @@ -varnishtest "fun esi includes and ranges" - -server s1 { - rxreq - expect req.url == "/1" - txresp -body {} - - rxreq - expect req.url == /bar - txresp -body {} - - rxreq - expect req.url == /foo - txresp -body "ABCD" - - rxreq - expect req.url == "/2" - txresp -gzipbody {} - -} -start - -varnish v1 -vcl+backend { - sub vcl_recv { - if (req.url == "/bar") { - set req.http.Range = "bytes=7-8"; - } - } - sub vcl_backend_response { - set beresp.do_esi = true; - } -} -start - -client c1 { - txreq -url /1 -hdr "Accept-encoding: gzip" - rxresp - expect resp.body == "BC" - delay .1 - txreq -url /2 -hdr "Accept-encoding: gzip" - rxresp - gunzip - expect resp.body == "BC" -} -run diff --git a/bin/varnishtest/tests/r01506.vtc b/bin/varnishtest/tests/r01506.vtc deleted file mode 100644 index f2bb5b2..0000000 --- a/bin/varnishtest/tests/r01506.vtc +++ /dev/null @@ -1,72 +0,0 @@ -varnishtest "range requests on streamed response" - -server s1 -repeat 4 { - rxreq - txresp -nolen \ - -hdr "Transfer-Encoding: chunked" \ - -hdr "Connection: close" - send "11\r\n0_23456789abcdef\n" - send "11\r\n1_23456789abcdef\n" - send "11\r\n2_23456789abcdef\n" - send "11\r\n3_23456789abcdef\n" - sema r1 sync 2 - send "11\r\n4_23456789abcdef\n" - send "11\r\n5_23456789abcdef\n" - send "11\r\n6_23456789abcdef\n" - send "11\r\n7_23456789abcdef\n" - chunkedlen 0 - -} -start - -varnish v1 -vcl+backend {} -start - -varnish v1 -cliok "param.set debug +syncvsl" - -logexpect l1 -v v1 -g session { - expect 0 1000 Begin sess - expect * = SessClose RANGE_SHORT -} -start - -client c1 { - txreq -url /1 -hdr "Range: bytes=17-101" - rxresphdrs - expect resp.status == 206 - expect resp.http.content-length == 85 - sema r1 sync 2 - rxrespbody - expect resp.bodylen == 85 - delay .1 - - # We cannot do tail-ranges when streaming - txreq -url /2 -hdr "Range: bytes=-10" - rxresphdrs - expect resp.status == 200 - expect resp.http.Transfer-Encoding == chunked - sema r1 sync 2 - rxrespbody - expect resp.bodylen == 136 - delay .1 - - # We cannot do open-ranges when streaming - txreq -url /3 -hdr "Range: bytes=17-" - rxresphdrs - expect resp.status == 200 - expect resp.http.Transfer-Encoding == chunked - sema r1 sync 2 - rxrespbody - expect resp.bodylen == 136 - delay .1 - - # Invalid range - txreq -url /4 -hdr "Range: bytes=102-200" - rxresphdrs - expect resp.status == 206 - expect resp.http.content-length == 99 - sema r1 sync 2 - recv 34 - delay .3 - expect_close -} -run - -varnish v1 -expect sc_range_short == 1 -logexpect l1 -wait diff --git a/bin/varnishtest/tests/r01732.vtc b/bin/varnishtest/tests/r01732.vtc deleted file mode 100644 index f738dec..0000000 --- a/bin/varnishtest/tests/r01732.vtc +++ /dev/null @@ -1,38 +0,0 @@ -varnishtest "range related panic" - -server s1 { - rxreq - txresp -nolen -hdr "Transfer-Encoding: chunked" - chunkedlen 10 - chunkedlen 10 - sema r1 sync 2 - chunkedlen 10 - chunkedlen 10 - chunkedlen 10 - chunkedlen 0 - delay .1 - sema r2 sync 2 -} -start - -varnish v1 -vcl+backend { -} -start - -client c1 { - txreq -hdr "Range: bytes=0-100" - rxresphdrs - expect resp.status == 206 - expect resp.http.Content-Range == "bytes 0-100/*" -} -run - -delay .1 -sema r1 sync 2 -sema r2 sync 2 -delay .4 - -client c1 { - txreq -hdr "Range: bytes=0-100" - rxresp - expect resp.status == 206 - expect resp.http.Content-Range == "bytes 0-49/50" -} -run - diff --git a/bin/varnishtest/tests/r01777.vtc b/bin/varnishtest/tests/r01777.vtc new file mode 100644 index 0000000..6808023 --- /dev/null +++ b/bin/varnishtest/tests/r01777.vtc @@ -0,0 +1,18 @@ +varnishtest "range asked longer than object" + +server s1 { + rxreq + txresp -nolen -hdr "Transfer-Encoding: chunked" + delay .5 + chunkedlen 64 + chunkedlen 64 + chunkedlen 0 +} -start + +varnish v1 -vcl+backend { } -start + +client c1 { + txreq -hdr "Range: bytes=0-129" + rxresp + expect resp.status == 200 +} -run From phk at FreeBSD.org Tue Aug 25 17:10:41 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 25 Aug 2015 19:10:41 +0200 Subject: [master] 78ab22c Add a feature check for not-totally-demented-DNS service Message-ID: commit 78ab22c13c06a98088600d526d5c26b3376b2b3b Author: Poul-Henning Kamp Date: Tue Aug 25 17:10:19 2015 +0000 Add a feature check for not-totally-demented-DNS service diff --git a/bin/varnishtest/tests/m00011.vtc b/bin/varnishtest/tests/m00011.vtc index bd17059..7540c9b 100644 --- a/bin/varnishtest/tests/m00011.vtc +++ b/bin/varnishtest/tests/m00011.vtc @@ -1,6 +1,5 @@ varnishtest "Test std.ip" - server s1 { rxreq txresp -body "1" diff --git a/bin/varnishtest/vtc.c b/bin/varnishtest/vtc.c index 1309df0..f77f617 100644 --- a/bin/varnishtest/vtc.c +++ b/bin/varnishtest/vtc.c @@ -583,6 +583,9 @@ cmd_feature(CMD_ARGS) continue; #endif } + if (!strcmp(av[i], "dns") && feature_dns) + continue; + if (!strcmp(av[i], "topbuild") && iflg) continue; diff --git a/bin/varnishtest/vtc.h b/bin/varnishtest/vtc.h index f2817d8..518494c 100644 --- a/bin/varnishtest/vtc.h +++ b/bin/varnishtest/vtc.h @@ -71,6 +71,7 @@ extern pthread_t vtc_thread; extern int iflg; extern unsigned vtc_maxdur; extern int vtc_witness; +extern int feature_dns; void init_sema(void); void init_server(void); diff --git a/bin/varnishtest/vtc_main.c b/bin/varnishtest/vtc_main.c index df8787c..e1f15d1 100644 --- a/bin/varnishtest/vtc_main.c +++ b/bin/varnishtest/vtc_main.c @@ -30,6 +30,7 @@ #include #include +#include #include #include @@ -47,6 +48,9 @@ #include "vfil.h" #include "vqueue.h" #include "vrnd.h" +#include "vsa.h" +#include "vss.h" +#include "vtcp.h" #include "vtim.h" #define MAX_FILESIZE (1024 * 1024) @@ -89,6 +93,7 @@ static char *tmppath; static char *cwd = NULL; int leave_temp; int vtc_witness = 0; +int feature_dns; /********************************************************************** * Parse a -D option argument into a name/val pair, and insert @@ -384,6 +389,41 @@ i_mode(void) } /********************************************************************** + * Most test-cases use only numeric IP#'s but a few requires non-demented + * DNS services. This is a basic sanity check for those. + */ + +static int __match_proto__(vss_resolved_f) +dns_cb(void *priv, const struct suckaddr *sa) +{ + char abuf[VTCP_ADDRBUFSIZE]; + char pbuf[VTCP_PORTBUFSIZE]; + int *ret = priv; + + VTCP_name(sa, abuf, sizeof abuf, pbuf, sizeof pbuf); + if (strcmp(abuf, "130.225.244.222")) { + fprintf(stderr, "DNS-test: Wrong response: %s\n", abuf); + *ret = -1; + } else if (*ret == 0) + *ret = 1; + return (0); +} + +static int +dns_works(void) +{ + int ret = 0, error; + const char *msg; + + error = VSS_resolver("phk.freebsd.dk", NULL, dns_cb, &ret, &msg); + if (error || msg != NULL || ret != 1) { + fprintf(stderr, "DNS-test fails\n"); + return (0); + } + return (1); +} + +/********************************************************************** * Main */ @@ -480,6 +520,8 @@ main(int argc, char * const *argv) VTAILQ_INSERT_TAIL(&tst_head, tp, list); } + feature_dns = dns_works(); + if (iflg) i_mode(); From phk at FreeBSD.org Tue Aug 25 17:35:50 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 25 Aug 2015 19:35:50 +0200 Subject: [master] 1596823 polish Message-ID: commit 159682339108033f15ebf659cdaecc03971f66c7 Author: Poul-Henning Kamp Date: Tue Aug 25 17:18:25 2015 +0000 polish diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index 72a7763..1c43fb3 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -207,7 +207,7 @@ ved_decode_len(uint8_t **pp) p += 9; break; default: - printf("Illegal Length %d %d\n", *p, (*p & 15)); + Debug("Illegal Length %d %d\n", *p, (*p & 15)); INCOMPL(); } *pp = p; @@ -327,7 +327,7 @@ VDP_ESI(struct req *req, enum vdp_action act, void **priv, ecx->p = r + 1; break; default: - printf("XXXX 0x%02x [%s]\n", *ecx->p, ecx->p); + Debug("XXXX 0x%02x [%s]\n", *ecx->p, ecx->p); INCOMPL(); } break; From phk at FreeBSD.org Tue Aug 25 17:35:50 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 25 Aug 2015 19:35:50 +0200 Subject: [master] 22ff964 Get better diagnostics on ESI-code string errors. Message-ID: commit 22ff96495f8dfd774198431a3189831b1594cac9 Author: Poul-Henning Kamp Date: Tue Aug 25 17:35:23 2015 +0000 Get better diagnostics on ESI-code string errors. Related to: #1773 diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index 1c43fb3..ff30ae3 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -187,7 +187,7 @@ ved_include(struct req *preq, const char *src, const char *host, #define Debug(fmt, ...) /**/ static ssize_t -ved_decode_len(uint8_t **pp) +ved_decode_len(struct req *req, uint8_t **pp) { uint8_t *p; ssize_t l; @@ -207,8 +207,9 @@ ved_decode_len(uint8_t **pp) p += 9; break; default: - Debug("Illegal Length %d %d\n", *p, (*p & 15)); - INCOMPL(); + VSLb(req->vsl, SLT_Error, + "ESI-corruption: Illegal Length %d %d\n", *p, (*p & 15)); + WRONG("ESI-codes: illegal length"); } *pp = p; assert(l > 0); @@ -286,12 +287,16 @@ VDP_ESI(struct req *req, enum vdp_action act, void **priv, case VEC_V1: case VEC_V2: case VEC_V8: - ecx->l = ved_decode_len(&ecx->p); + ecx->l = ved_decode_len(req, &ecx->p); + if (ecx->l < 0) + return (-1); if (ecx->isgzip) { assert(*ecx->p == VEC_C1 || *ecx->p == VEC_C2 || *ecx->p == VEC_C8); - l = ved_decode_len(&ecx->p); + l = ved_decode_len(req, &ecx->p); + if (l < 0) + return (-1); icrc = vbe32dec(ecx->p); ecx->p += 4; if (ecx->isgzip) { @@ -305,7 +310,9 @@ VDP_ESI(struct req *req, enum vdp_action act, void **priv, case VEC_S1: case VEC_S2: case VEC_S8: - ecx->l = ved_decode_len(&ecx->p); + ecx->l = ved_decode_len(req, &ecx->p); + if (ecx->l < 0) + return (-1); Debug("SKIP1(%d)\n", (int)ecx->l); ecx->state = 4; break; @@ -327,8 +334,10 @@ VDP_ESI(struct req *req, enum vdp_action act, void **priv, ecx->p = r + 1; break; default: - Debug("XXXX 0x%02x [%s]\n", *ecx->p, ecx->p); - INCOMPL(); + VSLb(req->vsl, SLT_Error, + "ESI corruption line %d 0x%02x [%s]\n", + __LINE__, *ecx->p, ecx->p); + WRONG("ESI-codes: Illegal code"); } break; case 2: From phk at FreeBSD.org Tue Aug 25 17:54:13 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 25 Aug 2015 19:54:13 +0200 Subject: [master] b31c8b5 Temporarily set this testcase to use poll-waiter, to tease out OSX/64 issue... Message-ID: commit b31c8b505b4b09a47217a1faf361419d32f5da3b Author: Poul-Henning Kamp Date: Tue Aug 25 17:53:33 2015 +0000 Temporarily set this testcase to use poll-waiter, to tease out OSX/64 issue... diff --git a/bin/varnishtest/tests/m00011.vtc b/bin/varnishtest/tests/m00011.vtc index 7540c9b..29c4261 100644 --- a/bin/varnishtest/tests/m00011.vtc +++ b/bin/varnishtest/tests/m00011.vtc @@ -8,7 +8,7 @@ server s1 { } -start -varnish v1 -vcl+backend { +varnish v1 -arg "-Wpoll" -vcl+backend { import ${vmod_std}; sub vcl_deliver { From phk at FreeBSD.org Tue Aug 25 19:44:06 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 25 Aug 2015 21:44:06 +0200 Subject: [master] 34360fd Add some debugging (OSX64/m00011) Message-ID: commit 34360fd1bbecfc5b0a6b8a27c2fa97a19f0bcd6a Author: Poul-Henning Kamp Date: Tue Aug 25 19:43:51 2015 +0000 Add some debugging (OSX64/m00011) diff --git a/bin/varnishd/waiter/cache_waiter_poll.c b/bin/varnishd/waiter/cache_waiter_poll.c index 72c97fb..5e2edb8 100644 --- a/bin/varnishd/waiter/cache_waiter_poll.c +++ b/bin/varnishd/waiter/cache_waiter_poll.c @@ -171,12 +171,15 @@ vwp_main(void *priv) i = -1; else i = (int)floor(1e3 * (then - VTIM_real())); + assert(vwp->hpoll > 0); + AN(vwp->pollfd); v = poll(vwp->pollfd, vwp->hpoll, i); assert(v >= 0); now = VTIM_real(); if (vwp->pollfd[0].revents) v--; for (i = 1; i < vwp->hpoll;) { +VSL(SLT_Debug, vwp->pollfd[i].fd, "POLL loop i=%d revents=0x%x", i, vwp->pollfd[i].revents); assert(vwp->pollfd[i].fd != vwp->pipes[0]); wp = vwp->idx[i]; CHECK_OBJ_NOTNULL(wp, WAITED_MAGIC); From dridi.boukelmoune at gmail.com Thu Aug 27 10:47:26 2015 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 27 Aug 2015 12:47:26 +0200 Subject: [master] dc0b0ca Revert "Hide backends and directors implementation details" Message-ID: commit dc0b0ca1e818096505ea856b905c974fa847aa41 Author: Dridi Boukelmoune Date: Thu Aug 27 09:53:26 2015 +0200 Revert "Hide backends and directors implementation details" This reverts commit d771942c0c6f151e267b63bbc548a4d4371b25be, it needs to be discussed first. diff --git a/bin/varnishd/Makefile.am b/bin/varnishd/Makefile.am index eb01348..dd2bae2 100644 --- a/bin/varnishd/Makefile.am +++ b/bin/varnishd/Makefile.am @@ -99,8 +99,6 @@ varnishd_SOURCES = \ noinst_HEADERS = \ builtin_vcl.h \ - cache/cache_backend.h \ - cache/cache_director.h \ cache/cache_esi.h \ cache/cache_pool.h \ common/heritage.h \ @@ -118,6 +116,8 @@ noinst_HEADERS = \ nobase_pkginclude_HEADERS = \ cache/cache.h \ cache/cache_filter.h \ + cache/cache_backend.h \ + cache/cache_director.h \ common/common.h \ common/params.h \ waiter/waiter.h diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index ed72296..648dad4 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -190,47 +190,6 @@ struct http { }; /*-------------------------------------------------------------------- - * Director public APIs - */ - -typedef unsigned vdi_healthy_f(const struct director *, const struct busyobj *, - double *changed); - -typedef const struct director *vdi_resolve_f(const struct director *, - struct worker *, struct busyobj *); - -typedef int vdi_gethdrs_f(const struct director *, struct worker *, - struct busyobj *); -typedef int vdi_getbody_f(const struct director *, struct worker *, - struct busyobj *); -typedef const struct suckaddr *vdi_getip_f(const struct director *, - struct worker *, struct busyobj *); -typedef void vdi_finish_f(const struct director *, struct worker *, - struct busyobj *); - -typedef void vdi_http1pipe_f(const struct director *, struct req *, - struct busyobj *); - -typedef void vdi_panic_f(const struct director *, struct vsb *); - -struct director { - unsigned magic; -#define DIRECTOR_MAGIC 0x3336351d - const char *name; - char *vcl_name; - vdi_http1pipe_f *http1pipe; - vdi_healthy_f *healthy; - vdi_resolve_f *resolve; - vdi_gethdrs_f *gethdrs; - vdi_getbody_f *getbody; - vdi_getip_f *getip; - vdi_finish_f *finish; - vdi_panic_f *panic; - void *priv; - const void *priv2; -}; - -/*-------------------------------------------------------------------- * VFP filter state */ diff --git a/bin/varnishd/cache/cache_director.h b/bin/varnishd/cache/cache_director.h index 3bccf80..cf20dc1 100644 --- a/bin/varnishd/cache/cache_director.h +++ b/bin/varnishd/cache/cache_director.h @@ -37,6 +37,49 @@ * */ +/*-------------------------------------------------------------------- + * A director is a piece of code which selects one of possibly multiple + * backends to use. + */ + + +typedef unsigned vdi_healthy_f(const struct director *, const struct busyobj *, + double *changed); + +typedef const struct director *vdi_resolve_f(const struct director *, + struct worker *, struct busyobj *); + +typedef int vdi_gethdrs_f(const struct director *, struct worker *, + struct busyobj *); +typedef int vdi_getbody_f(const struct director *, struct worker *, + struct busyobj *); +typedef const struct suckaddr *vdi_getip_f(const struct director *, + struct worker *, struct busyobj *); +typedef void vdi_finish_f(const struct director *, struct worker *, + struct busyobj *); + +typedef void vdi_http1pipe_f(const struct director *, struct req *, + struct busyobj *); + +typedef void vdi_panic_f(const struct director *, struct vsb *); + +struct director { + unsigned magic; +#define DIRECTOR_MAGIC 0x3336351d + const char *name; + char *vcl_name; + vdi_http1pipe_f *http1pipe; + vdi_healthy_f *healthy; + vdi_resolve_f *resolve; + vdi_gethdrs_f *gethdrs; + vdi_getbody_f *getbody; + vdi_getip_f *getip; + vdi_finish_f *finish; + vdi_panic_f *panic; + void *priv; + const void *priv2; +}; + /* cache_director.c */ int VDI_GetHdr(struct worker *, struct busyobj *); diff --git a/lib/libvmod_directors/vdir.c b/lib/libvmod_directors/vdir.c index 1738bcf..411df34 100644 --- a/lib/libvmod_directors/vdir.c +++ b/lib/libvmod_directors/vdir.c @@ -31,6 +31,7 @@ #include #include "cache/cache.h" +#include "cache/cache_director.h" #include "vrt.h" #include "vbm.h" From dridi.boukelmoune at gmail.com Thu Aug 27 10:47:26 2015 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 27 Aug 2015 12:47:26 +0200 Subject: [master] e52a2cb Docs update on VCL temperature with fact checking Message-ID: commit e52a2cbc4b83df42b7fc2ec686be5328aa61883c Author: Dridi Boukelmoune Date: Wed Aug 26 23:45:41 2015 +0200 Docs update on VCL temperature with fact checking The Varnish CLI documentation was advertising an optional temperature parameter for `vcl.use`, and overall the test coverage wasn't deep enough. There is still room for improvement. The debug VMOD now logs some of the VCL events to help cover more behavior in `v00044.vtc`. diff --git a/bin/varnishtest/tests/v00044.vtc b/bin/varnishtest/tests/v00044.vtc index 6f44d82..c3fd107 100644 --- a/bin/varnishtest/tests/v00044.vtc +++ b/bin/varnishtest/tests/v00044.vtc @@ -7,7 +7,9 @@ server s1 -repeat 20 { close } -start +# The debug vmod logs some vcl events varnish v1 -arg "-p vcl_cooldown=1" -vcl { + import ${vmod_debug}; backend default { .host = "${s1_addr}"; .probe = { .interval = 1s; .initial = 1;} @@ -51,8 +53,34 @@ varnish v1 -expect VBE.vcl2.default.happy >= 0 delay 4 varnish v1 -expect !VBE.vcl2.default.happy -# Mark the used warm and use it the other +# Mark the used warm and use the other varnish v1 -cliok "vcl.state vcl1 warm" varnish v1 -cliok "vcl.use vcl2" + +# It will stay warm even after the cooldown period delay 4 +varnish v1 -expect VBE.vcl1.default.happy >= 0 varnish v1 -expect VBE.vcl2.default.happy >= 0 + +# You can't freeze the active VCL +varnish v1 -clierr 106 "vcl.state vcl2 cold" + +# However a warm event is guaranteed... +logexpect l1 -v v1 -g raw { + expect * 0 Debug "vcl1: VCL_EVENT_COLD" + expect * 0 Debug "vcl1: VCL_EVENT_WARM" + expect * 0 Debug "vcl1: VCL_EVENT_USE" +} -start + +# ...when you use a cold VCL +varnish v1 -cliok "vcl.state vcl1 cold" +varnish v1 -cliok "vcl.use vcl1" + +logexpect l1 -wait + +# It will apply the cooldown period once inactive +varnish v1 -cliok "vcl.use vcl2" +delay .4 +varnish v1 -expect VBE.vcl1.default.happy >= 0 +delay 4 +varnish v1 -expect !VBE.vcl1.default.happy diff --git a/doc/sphinx/reference/directors.rst b/doc/sphinx/reference/directors.rst index de321b2..9f1381c 100644 --- a/doc/sphinx/reference/directors.rst +++ b/doc/sphinx/reference/directors.rst @@ -116,9 +116,10 @@ backends. Finally, Varnish will take care of event propagation for *all* native backends, but dynamic backends can only be created when the VCL is warm. If your backends -are created by an independant thread (basically outside of VCL scope) you must +are created by an independent thread (basically outside of VCL scope) you must subscribe to VCL events and watch for VCL state (see -:ref:`ref-vmod-event-functions`). +:ref:`ref-vmod-event-functions`). You are also encouraged to comply with the +:ref:`ref_vcl_temperature` in general. .. _ref-writing-a-director-cluster: diff --git a/doc/sphinx/reference/varnish-cli.rst b/doc/sphinx/reference/varnish-cli.rst index e400408..4098afd 100644 --- a/doc/sphinx/reference/varnish-cli.rst +++ b/doc/sphinx/reference/varnish-cli.rst @@ -107,7 +107,7 @@ vcl.load [auto|cold|warm] vcl.inline [auto|cold|warm] Compile and load the VCL data under the name provided. -vcl.use [auto|cold|warm] +vcl.use Switch to the named configuration immediately. vcl.discard @@ -174,6 +174,28 @@ Integers can have "KB", "MB", "GB" or "TB" appended for size related fields. +.. _ref_vcl_temperature: + +VCL Temperature +--------------- + +A VCL program goes through several states related to the different commands: it +can be loaded, used, and later discarded. You can load several VCL programs and +switch at any time from one to another. There is only one active VCL, but the +previous active VCL will be maintained active until all its transactions are +over. + +Over time, if you often refresh your VCL and keep the previous versions around, +resource consumption will increase, you can't escape that. However, most of the +time you want only one to pay the price only for the active VCL and keep older +VCLs in case you'd need to rollback to a previous version. + +The VCL temperature allows you to minimize the footprint of inactive VCLs. Once +a VCL becomes cold, Varnish will release all the resources that can be be later +reacquired. You can manually set the temperature of a VCL or let varnish +automatically handle it. + + Scripting --------- diff --git a/doc/sphinx/reference/vmod.rst b/doc/sphinx/reference/vmod.rst index 0446e83..b3ccefa 100644 --- a/doc/sphinx/reference/vmod.rst +++ b/doc/sphinx/reference/vmod.rst @@ -355,14 +355,14 @@ The per-call vmod_privs are freed before the per-vcl vmod_priv. Event functions =============== -VMODs can have an "event" function which is called when a VCL which -imports the VMOD is loaded, made active, or discarded. This corresponds -to the VCL_EVENT_LOAD, VCL_EVENT_USE, and VCL_EVENT_DISCARD events, -respectively. In addition, this function will be called when the VCL -state is changed to cold or warm, corresponding to the VCL_EVENT_COLD -and VCL_EVENT_WARM events. +VMODs can have an "event" function which is called when a VCL which imports +the VMOD is loaded, made active, or discarded. This corresponds to the +``VCL_EVENT_LOAD``, ``VCL_EVENT_USE``, and ``VCL_EVENT_DISCARD`` events, +respectively. In addition, this function will be called when the VCL state is +changed to cold or warm, corresponding to the ``VCL_EVENT_COLD`` and +``VCL_EVENT_WARM`` events. -The first argument to the event function is the VRT context. +The first argument to the event function is a VRT context. The second argument is the vmod_priv specific to this particular VCL, and if necessary, a VCL specific VMOD "fini" function can be attached @@ -371,9 +371,16 @@ to its "free" hook. The third argument is the event. If the VMOD has private global state, which includes any sockets or files -opened, any memory allocated to global or private variables in the C-code -etc, it is the VMODs own responsibility to track how many VCLs have called -init (& fini) and free this global state when the count reaches zero +opened, any memory allocated to global or private variables in the C-code etc, +it is the VMODs own responsibility to track how many VCLs were loaded or +discarded and free this global state when the count reaches zero. + +VMOD writers are *strongly* encouraged to release all per-VCL resources for a +given VCL when it emits a ``VCL_EVENT_COLD`` event. You will get a chance to +reacquire the resources before the VCL becomes active again and be notified +first with a ``VCL_EVENT_WARM`` event, and then a ``VCL_EVENT_USE`` event. +Unless a user decides that a given VCL should always be warm, an inactive VMOD +will eventually become cold and should manage resources accordingly. .. _ref-vmod-objects: diff --git a/doc/sphinx/whats-new/changes.rst b/doc/sphinx/whats-new/changes.rst index b7fd4da..4a948ca 100644 --- a/doc/sphinx/whats-new/changes.rst +++ b/doc/sphinx/whats-new/changes.rst @@ -61,7 +61,7 @@ Example:: VMOD writers should read up on the new vcl_event system to release unnecessary -state when a VCL is transitioned to cold. +state when a VCL is transitioned to cold (see ref:`ref-vmod-event-functions`). PROXY protocol support diff --git a/lib/libvmod_debug/vmod_debug.c b/lib/libvmod_debug/vmod_debug.c index 3dddbac..c9b1028 100644 --- a/lib/libvmod_debug/vmod_debug.c +++ b/lib/libvmod_debug/vmod_debug.c @@ -253,6 +253,17 @@ int __match_proto__(vmod_event_f) event_function(VRT_CTX, struct vmod_priv *priv, enum vcl_event_e e) { struct priv_vcl *priv_vcl; + const char *ev; + + switch (e) { + case VCL_EVENT_COLD: ev = "VCL_EVENT_COLD"; break; + case VCL_EVENT_WARM: ev = "VCL_EVENT_WARM"; break; + case VCL_EVENT_USE: ev = "VCL_EVENT_USE"; break; + default: ev = NULL; + } + + if (ev != NULL) + VSL(SLT_Debug, 0, "%s: %s", VCL_Name(ctx->vcl), ev); if (e != VCL_EVENT_LOAD) return (0); From dridi.boukelmoune at gmail.com Thu Aug 27 10:47:26 2015 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Thu, 27 Aug 2015 12:47:26 +0200 Subject: [master] b6b3883 Short introduction to VMOD backends in 4.1 changes Message-ID: commit b6b3883049f32f55cbe8c3151540bfddb8006a03 Author: Dridi Boukelmoune Date: Thu Aug 27 12:41:19 2015 +0200 Short introduction to VMOD backends in 4.1 changes diff --git a/doc/sphinx/whats-new/changes.rst b/doc/sphinx/whats-new/changes.rst index 4a948ca..7b6eeba 100644 --- a/doc/sphinx/whats-new/changes.rst +++ b/doc/sphinx/whats-new/changes.rst @@ -94,7 +94,11 @@ in ``vcl_recv`` to see if traffic came in over the HTTP listening socket VMOD backends ============= -Not yet documented. +Before Varnish 4.1, backends could only be declared in native VCL. Varnish 4.0 +moved directors from VCL to VMODs, and VMODs can now also create backends. It +is possible to both create the same backends than VCL but dynamically, or +create backends that don't necesserally speak HTTP/1 over TCP to fetch +resources. More details in the :ref:`ref-writing-a-director` documentation. Surrogate keys From lkarsten at varnish-software.com Thu Aug 27 14:20:28 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 27 Aug 2015 16:20:28 +0200 Subject: [master] 660d9b1 Add long descriptions for stevedore counters. Message-ID: commit 660d9b1da311cd2d3de72be9e8c74702c24e7ec9 Author: Lasse Karstensen Date: Thu Aug 27 16:19:11 2015 +0200 Add long descriptions for stevedore counters. I often have to look up which one is which, try to avoid that in the future. diff --git a/include/tbl/vsc_fields.h b/include/tbl/vsc_fields.h index 7d45f5c..fcf342f 100644 --- a/include/tbl/vsc_fields.h +++ b/include/tbl/vsc_fields.h @@ -123,31 +123,31 @@ 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, "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, "Allocator failures", - "" + "Number of times the storage has failed to provide a storage segment." ) VSC_F(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, "Bytes freed", - "" + "Number of total bytes returned to this storage." ) VSC_F(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, "Bytes outstanding", - "" + "Number of bytes allocated from the storage." ) VSC_F(g_space, uint64_t, 0, 'g', 'B', info, "Bytes available", - "" + "Number of bytes left in the storage." ) #endif