From phk at FreeBSD.org Sun Apr 2 19:59:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Sun, 02 Apr 2017 21:59:05 +0200 Subject: [master] 7179b96 Tempt fate and try to make getopt() error strings part of our tests, in order to have less ambiguous error messages. Message-ID: commit 7179b965ff398f6726ff3bb97e878dd388356905 Author: Poul-Henning Kamp Date: Sun Apr 2 19:57:02 2017 +0000 Tempt fate and try to make getopt() error strings part of our tests, in order to have less ambiguous error messages. diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index 1c45b32..2d3a9dc 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -530,12 +530,9 @@ main(int argc, char * const *argv) do { switch (o) { case '?': - if (optopt == '?') { + if (optopt == '?') usage(); - exit(1); - } - ARGV_ERR("Option '%c' unknown.\n", - optopt); + exit(2); case 'V': case 'x': ARGV_ERR("-%c must be the first argument\n", o); diff --git a/bin/varnishtest/tests/a00009.vtc b/bin/varnishtest/tests/a00009.vtc index abe4c85..e4d0aa6 100644 --- a/bin/varnishtest/tests/a00009.vtc +++ b/bin/varnishtest/tests/a00009.vtc @@ -11,7 +11,10 @@ shell -err -expect {-V must be the first argument} "varnishd -d -V foo " shell -err -expect {Too many arguments for -x} "varnishd -x foo bar" shell -err -expect {Invalid -x argument} "varnishd -x foo " -shell -err -expect {Option 'A' unknown.} "varnishd -A " + +# This one is tricky, the getopt message on stderr is not standardized. +shell -err -expect {option --} "varnishd -A " + shell -err -expect {Usage: varnishd [options]} "varnishd -? " shell -err -expect {Too many arguments} "varnishd foo " From phk at FreeBSD.org Sun Apr 2 19:59:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Sun, 02 Apr 2017 21:59:05 +0200 Subject: [master] 06c83b9 Pass sensible maxlengths to HTC_RxStuff() and document how the workspace_client parameter influences H2 traffic. Message-ID: commit 06c83b96bbb9dc387b5eed9b9065e93ad33021a8 Author: Poul-Henning Kamp Date: Sun Apr 2 19:58:11 2017 +0000 Pass sensible maxlengths to HTC_RxStuff() and document how the workspace_client parameter influences H2 traffic. diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index 4441406..ab0f28d 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -827,7 +827,7 @@ h2_rxframe(struct worker *wrk, struct h2_sess *h2) hs = HTC_RxStuff(h2->htc, h2_frame_complete, NULL, NULL, NAN, h2->sess->t_idle + cache_param->timeout_idle + 100, - 1024); + 16384 + 9); // rfc7540,l,4228,4228 if (hs != HTC_S_COMPLETE) { Lck_Lock(&h2->sess->mtx); VSLb(h2->vsl, SLT_Debug, "H2: No frame (hs=%d)", hs); diff --git a/bin/varnishd/http2/cache_http2_session.c b/bin/varnishd/http2/cache_http2_session.c index c1dee52..0dbb541 100644 --- a/bin/varnishd/http2/cache_http2_session.c +++ b/bin/varnishd/http2/cache_http2_session.c @@ -238,7 +238,8 @@ h2_ou_session(struct worker *wrk, struct h2_sess *h2, /* Wait for PRISM response */ hs = HTC_RxStuff(h2->htc, H2_prism_complete, - NULL, NULL, NAN, h2->sess->t_idle + cache_param->timeout_idle, 256); + NULL, NULL, NAN, h2->sess->t_idle + cache_param->timeout_idle, + sizeof H2_prism); if (hs != HTC_S_COMPLETE) { VSLb(h2->vsl, SLT_Debug, "H2: No/Bad OU PRISM (hs=%d)", hs); h2_del_req(wrk, r2); diff --git a/include/tbl/params.h b/include/tbl/params.h index f66ffd1..a44b625 100644 --- a/include/tbl/params.h +++ b/include/tbl/params.h @@ -1611,7 +1611,11 @@ PARAM( /* flags */ DELAYED_EFFECT, /* s-text */ "Bytes of HTTP protocol workspace for clients HTTP req/resp. Use a " - "multiple of 4k for VM efficiency.", + "multiple of 4k for VM efficiency.\n" + "For HTTP/2 compliance this must be at least 20k, in order to " + "receive fullsize (=16k) frames from the client. That usually " + "happens only in POST/PUT bodies. For other traffic-patterns " + "smaller values work just fine.", /* l-text */ "", /* func */ NULL ) From phk at FreeBSD.org Mon Apr 3 06:43:06 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 03 Apr 2017 08:43:06 +0200 Subject: [master] 3f4a5a1 Don't panic if return(pass(DURATION)) is used on client side. Ignore the argument with a VSL message. Message-ID: commit 3f4a5a1bc3f7ce22136f161149854e483d3478b6 Author: Poul-Henning Kamp Date: Mon Apr 3 06:33:22 2017 +0000 Don't panic if return(pass(DURATION)) is used on client side. Ignore the argument with a VSL message. Fixes: #2299 diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c index efc877f..a8100b3 100644 --- a/bin/varnishd/cache/cache_vrt.c +++ b/bin/varnishd/cache/cache_vrt.c @@ -91,6 +91,11 @@ VRT_hit_for_pass(VRT_CTX, VCL_DURATION d) struct objcore *oc; CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + if (ctx->bo == NULL) { + VSLb(ctx->vsl, SLT_Error, + "Note: Ignoring DURATION argument to return(pass);"); + return; + } CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC); oc = ctx->bo->fetch_objcore; oc->ttl = d; diff --git a/bin/varnishtest/tests/c00010.vtc b/bin/varnishtest/tests/c00010.vtc index 5e8b087..a128b73 100644 --- a/bin/varnishtest/tests/c00010.vtc +++ b/bin/varnishtest/tests/c00010.vtc @@ -17,7 +17,7 @@ varnish v1 -vcl+backend { if (req.url == "/foo") { return(hash); } else { - return(pass); + return(pass(10m)); } } sub vcl_hit { From phk at FreeBSD.org Mon Apr 3 08:30:09 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 03 Apr 2017 10:30:09 +0200 Subject: [master] 20adece Move the responsibility for NUL terminating the RX buffer into the completion function. Message-ID: commit 20adece32a54597c21ac5874dcf9a7dd76f242bc Author: Poul-Henning Kamp Date: Mon Apr 3 08:28:56 2017 +0000 Move the responsibility for NUL terminating the RX buffer into the completion function. Fixes #2285 diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c index e36c9e3..02e1059 100644 --- a/bin/varnishd/cache/cache_session.c +++ b/bin/varnishd/cache/cache_session.c @@ -237,7 +237,7 @@ HTC_RxStuff(struct http_conn *htc, htc_complete_f *func, double tmo; double now; enum htc_status_e hs; - int i; + ssize_t z; CHECK_OBJ_NOTNULL(htc, HTTP_CONN_MAGIC); AN(htc->rfd); @@ -255,15 +255,16 @@ HTC_RxStuff(struct http_conn *htc, htc_complete_f *func, WS_ReleaseP(htc->ws, htc->rxbuf_b); return (HTC_S_OVERFLOW); } - if ((htc->ws->r - htc->rxbuf_b) - 1L < maxbytes) - maxbytes = (htc->ws->r - htc->rxbuf_b) - 1L; /* Space for NUL */ + z = (htc->ws->r - htc->rxbuf_b); + if (z < maxbytes) + maxbytes = z; while (1) { now = VTIM_real(); AZ(htc->pipeline_b); AZ(htc->pipeline_e); - assert(htc->rxbuf_e < htc->ws->r); - *htc->rxbuf_e = '\0'; + assert(htc->rxbuf_e <= htc->ws->r); + hs = func(htc); if (hs == HTC_S_OVERFLOW || hs == HTC_S_JUNK) { WS_ReleaseP(htc->ws, htc->rxbuf_b); @@ -290,21 +291,21 @@ HTC_RxStuff(struct http_conn *htc, htc_complete_f *func, tmo = tn - now; if (!isnan(ti) && ti < tn) tmo = ti - now; - i = maxbytes - (htc->rxbuf_e - htc->rxbuf_b); - assert(i >= 0); - if (i == 0) { + z = maxbytes - (htc->rxbuf_e - htc->rxbuf_b); + assert(z >= 0); + if (z == 0) { WS_ReleaseP(htc->ws, htc->rxbuf_b); return (HTC_S_OVERFLOW); } if (tmo <= 0.0) tmo = 1e-3; - i = VTCP_read(*htc->rfd, htc->rxbuf_e, i, tmo); - if (i == 0 || i == -1) { + z = VTCP_read(*htc->rfd, htc->rxbuf_e, z, tmo); + if (z == 0 || z == -1) { WS_ReleaseP(htc->ws, htc->rxbuf_b); return (HTC_S_EOF); - } else if (i > 0) - htc->rxbuf_e += i; - else if (i == -2) { + } else if (z > 0) + htc->rxbuf_e += z; + else if (z == -2) { 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_proto.c b/bin/varnishd/http1/cache_http1_proto.c index 05d23b3..2e691fd 100644 --- a/bin/varnishd/http1/cache_http1_proto.c +++ b/bin/varnishd/http1/cache_http1_proto.c @@ -73,7 +73,11 @@ HTTP1_Complete(struct http_conn *htc) CHECK_OBJ_NOTNULL(htc, HTTP_CONN_MAGIC); assert(htc->rxbuf_e >= htc->rxbuf_b); - assert(*htc->rxbuf_e == '\0'); + assert(htc->rxbuf_e <= htc->ws->r); + + if (htc->rxbuf_e == htc->ws->r) + return (HTC_S_OVERFLOW); // No space for NUL + *htc->rxbuf_e = '\0'; /* Skip any leading white space */ for (p = htc->rxbuf_b ; vct_islws(*p); p++) diff --git a/bin/varnishd/proxy/cache_proxy_proto.c b/bin/varnishd/proxy/cache_proxy_proto.c index 14e186a..d4231bc 100644 --- a/bin/varnishd/proxy/cache_proxy_proto.c +++ b/bin/varnishd/proxy/cache_proxy_proto.c @@ -297,6 +297,9 @@ vpx_complete(struct http_conn *htc) CHECK_OBJ_NOTNULL(htc, HTTP_CONN_MAGIC); + assert(htc->rxbuf_e >= htc->rxbuf_b); + assert(htc->rxbuf_e <= htc->ws->r); + l = htc->rxbuf_e - htc->rxbuf_b; p = htc->rxbuf_b; j = 0x3; @@ -308,6 +311,8 @@ vpx_complete(struct http_conn *htc) if (j == 0) return (HTC_S_JUNK); if (j == 1 && i == sizeof vpx1_sig) { + assert (htc->rxbuf_e < htc->ws->r); + *htc->rxbuf_e = '\0'; q = strchr(p + i, '\n'); if (q != NULL && (q - htc->rxbuf_b) > 107) return (HTC_S_OVERFLOW); From martin at varnish-software.com Mon Apr 3 11:46:06 2017 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Mon, 03 Apr 2017 13:46:06 +0200 Subject: [master] a3ab892 Add ASSERT_CLI() to a couple of backend handling functions Message-ID: commit a3ab8922eb8e665dc6f510883425897680576e4b Author: Martin Blix Grydeland Date: Fri Mar 31 11:00:03 2017 +0200 Add ASSERT_CLI() to a couple of backend handling functions VBE_Delete() and VBE_Poll() are only safe to call from the CLI handling thread. Add ASSERT_CLI() to make that explicit. diff --git a/bin/varnishd/cache/cache_backend_cfg.c b/bin/varnishd/cache/cache_backend_cfg.c index c5f3542..767a87c 100644 --- a/bin/varnishd/cache/cache_backend_cfg.c +++ b/bin/varnishd/cache/cache_backend_cfg.c @@ -194,6 +194,7 @@ VBE_Event(struct backend *be, enum vcl_event_e ev) void VBE_Delete(struct backend *be) { + ASSERT_CLI(); CHECK_OBJ_NOTNULL(be, BACKEND_MAGIC); if (be->probe != NULL) @@ -437,6 +438,7 @@ VBE_Poll(void) struct backend *be; double now = VTIM_real(); + ASSERT_CLI(); Lck_Lock(&backends_mtx); while (1) { be = VTAILQ_FIRST(&cool_backends); From martin at varnish-software.com Mon Apr 3 11:46:06 2017 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Mon, 03 Apr 2017 13:46:06 +0200 Subject: [master] 667256f Fix the spinlock loop in VBE_Poll Message-ID: commit 667256f191066672ec85c79e35bc9f995409c034 Author: Martin Blix Grydeland Date: Fri Mar 31 13:12:24 2017 +0200 Fix the spinlock loop in VBE_Poll VBE_Poll would not advance to test the next backend on the cooling list when the backend's n_conn is non-zero. This would create a spinlock effect, causing delays that could make the master kill the child because of CLI timeout. Fixes: #2295 diff --git a/bin/varnishd/cache/cache_backend_cfg.c b/bin/varnishd/cache/cache_backend_cfg.c index 767a87c..e4acf8a 100644 --- a/bin/varnishd/cache/cache_backend_cfg.c +++ b/bin/varnishd/cache/cache_backend_cfg.c @@ -435,15 +435,13 @@ static struct cli_proto backend_cmds[] = { void VBE_Poll(void) { - struct backend *be; + struct backend *be, *be2; double now = VTIM_real(); ASSERT_CLI(); Lck_Lock(&backends_mtx); - while (1) { - be = VTAILQ_FIRST(&cool_backends); - if (be == NULL) - break; + VTAILQ_FOREACH_SAFE(be, &cool_backends, list, be2) { + CHECK_OBJ_NOTNULL(be, BACKEND_MAGIC); if (be->cooled > now) break; if (be->n_conn > 0) diff --git a/bin/varnishtest/tests.disabled/r02295.vtc b/bin/varnishtest/tests.disabled/r02295.vtc new file mode 100644 index 0000000..f7a06e1 --- /dev/null +++ b/bin/varnishtest/tests.disabled/r02295.vtc @@ -0,0 +1,53 @@ +varnishtest "Test cooled dynamic backend clean up" + +# This test is disabled because it needs a timeout of 80 seconds (-t80 to +# varnishtest). This is because the cooled backend timeout in varnish core +# is hard coded to 60 seconds. + +server s1 { + rxreq + delay 70 + txresp +} -start + +varnish v1 -arg "-p cli_timeout=2 -p first_byte_timeout=80" -vcl { + import debug; + + backend dummy { .host = "${bad_backend}"; } + + sub vcl_init { + new s1 = debug.dyn("${s1_addr}", "${s1_port}"); + } + + sub vcl_recv { + if (req.url == "/refresh") { + s1.refresh("${s1_addr}", "${s1_port}"); + return (synth(200, "OK")); + } + } + + sub vcl_backend_fetch { + set bereq.backend = s1.backend(); + } +} -start + +client c1 { + timeout 120 + txreq + rxresp + expect resp.status == 200 +} -start + +delay 1 + +client c2 { + txreq -url /refresh + rxresp + expect resp.status == 200 +} -run + +delay 61 + +varnish v1 -cliok "ping" + +client c1 -wait From hermunn at varnish-software.com Mon Apr 3 12:18:05 2017 From: hermunn at varnish-software.com (Pål Hermunn Johansen) Date: Mon, 03 Apr 2017 14:18:05 +0200 Subject: [4.1] 8ed1c28 s/VXID/vxid/ Message-ID: commit 8ed1c28a9f4091d640c80c77c69801e3624dd0db Author: Dridi Boukelmoune Date: Thu Feb 23 14:06:41 2017 +0100 s/VXID/vxid/ diff --git a/doc/sphinx/reference/vsl-query.rst b/doc/sphinx/reference/vsl-query.rst index e757285..8f72a07 100644 --- a/doc/sphinx/reference/vsl-query.rst +++ b/doc/sphinx/reference/vsl-query.rst @@ -52,22 +52,22 @@ The grouping modes are: together. Client connections are open ended when using HTTP keep-alives, so it is undefined when the session will be reported. If the transaction timeout period is exceeded an - incomplete session will be reported. Non-transactional data (VXID + incomplete session will be reported. Non-transactional data (vxid == 0) is not reported. * Request Transactions are grouped by request, where the set will include the request itself as well as any backend requests or ESI-subrequests. - Session data and non-transactional data (VXID == 0) is not + Session data and non-transactional data (vxid == 0) is not reported. * VXID - Transactions are not grouped, so each VXID is reported in it's + Transactions are not grouped, so each vxid is reported in it's entirety. Sessions, requests, ESI-requests and backend requests are all reported individually. Non-transactional data is not reported - (VXID == 0). This is the default. + (vxid == 0). This is the default. * Raw From hermunn at varnish-software.com Mon Apr 3 12:18:06 2017 From: hermunn at varnish-software.com (Pål Hermunn Johansen) Date: Mon, 03 Apr 2017 14:18:06 +0200 Subject: [4.1] adb8de0 If the client workspace is almost, but not quite exhaused, we may not be able to get enough iovec's to do Chunked transmission. Message-ID: commit adb8de06f305aa21003a7e65aab0083e2216d89f Author: Poul-Henning Kamp Date: Thu Mar 23 08:08:29 2017 +0000 If the client workspace is almost, but not quite exhaused, we may not be able to get enough iovec's to do Chunked transmission. Fixes #2275 And #2207 was probably misdiagnosed, but the fix is correct anyhow. Conflicts: bin/varnishd/http1/cache_http1_line.c diff --git a/bin/varnishd/http1/cache_http1_line.c b/bin/varnishd/http1/cache_http1_line.c index 9f13543..a8e4f01 100644 --- a/bin/varnishd/http1/cache_http1_line.c +++ b/bin/varnishd/http1/cache_http1_line.c @@ -92,7 +92,8 @@ V1L_Reserve(struct worker *wrk, struct ws *ws, int *fd, struct vsl_log *vsl, u = WS_Reserve(ws, 0); u = PRNDDN(u); u /= sizeof(struct iovec); - if (u == 0) { + if (u < 3) { + /* Must have at least 3 in case of chunked encoding */ WS_Release(ws, 0); WS_MarkOverflow(ws); return; @@ -264,6 +265,7 @@ V1L_Chunked(const struct worker *wrk) CHECK_OBJ_NOTNULL(v1l, V1L_MAGIC); assert(v1l->ciov == v1l->siov); + assert(v1l->siov >= 3); /* * If there are not space for chunked header, a chunk of data and * a chunk tail, we might as well flush right away. diff --git a/bin/varnishtest/tests/c00071.vtc b/bin/varnishtest/tests/c00071.vtc index e281c90..b6c9947 100644 --- a/bin/varnishtest/tests/c00071.vtc +++ b/bin/varnishtest/tests/c00071.vtc @@ -14,7 +14,7 @@ server s1 { varnish v1 -vcl+backend { import ${vmod_debug}; sub vcl_deliver { - debug.workspace_allocate(client, debug.workspace_free(client) - 160); + debug.workspace_allocate(client, debug.workspace_free(client) - 208); if (req.url ~ "/bar") { set resp.http.x-foo = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; From hermunn at varnish-software.com Mon Apr 3 12:31:06 2017 From: hermunn at varnish-software.com (Pål Hermunn Johansen) Date: Mon, 03 Apr 2017 14:31:06 +0200 Subject: [4.1] 8a8604d Correct check when parsing the query string. Message-ID: commit 8a8604da337455bb07664ca7050b6d56c471ab88 Author: Federico G. Schwindt Date: Sun Feb 26 19:16:22 2017 +0000 Correct check when parsing the query string. Fixes #2233. diff --git a/bin/varnishtest/tests/r02233.vtc b/bin/varnishtest/tests/r02233.vtc new file mode 100644 index 0000000..87ab8ad --- /dev/null +++ b/bin/varnishtest/tests/r02233.vtc @@ -0,0 +1,24 @@ +varnishtest "Fail earlier if we cannot fit the query string" + +server s1 { + rxreq + txresp +} -start + +varnish v1 -arg "-p workspace_client=9k" -vcl+backend { + import ${vmod_std}; + + sub vcl_recv { + set req.url = std.querysort(req.url); + } +} -start + +client c1 { + send "GET /?a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1" + send "&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1" + send "&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1" + send " HTTP/1.1\r\n" + send "Host: foo\r\n\r\n" + rxresp + expect resp.status == 500 +} -run diff --git a/lib/libvmod_std/vmod_std_querysort.c b/lib/libvmod_std/vmod_std_querysort.c index 6f6a90b..c54cc5f 100644 --- a/lib/libvmod_std/vmod_std_querysort.c +++ b/lib/libvmod_std/vmod_std_querysort.c @@ -94,7 +94,7 @@ vmod_querysort(VRT_CTX, VCL_STRING url) pp[np++] = 1 + cu; for (cq = 1 + cu; *cq != '\0'; cq++) { if (*cq == '&') { - if (pp + 3 > pe) { + if (pp + np + 3 > pe) { WS_Release(ctx->ws, 0); WS_MarkOverflow(ctx->ws); return (url); From phk at FreeBSD.org Mon Apr 3 19:30:07 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 03 Apr 2017 21:30:07 +0200 Subject: [master] 6c9021d Add an assert to ensure that our estimate of struct http size matches the actual size later on. Message-ID: commit 6c9021d9f5ed89ebcd597d7ef144b1886e370111 Author: Poul-Henning Kamp Date: Mon Apr 3 19:18:33 2017 +0000 Add an assert to ensure that our estimate of struct http size matches the actual size later on. Inspired by: #2298 diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 5bc79d7..bc79aa3 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -749,7 +749,7 @@ void VGZ_UpdateObj(const struct vfp_ctx *, struct vgz*, enum vgz_ua_e); /* cache_http.c */ unsigned HTTP_estimate(unsigned nhttp); void HTTP_Copy(struct http *to, const struct http * const fm); -struct http *HTTP_create(void *p, uint16_t nhttp); +struct http *HTTP_create(void *p, uint16_t nhttp, unsigned); const char *http_Status2Reason(unsigned, const char **); unsigned http_EstimateWS(const struct http *fm, unsigned how); void http_PutResponse(struct http *to, const char *proto, uint16_t status, diff --git a/bin/varnishd/cache/cache_busyobj.c b/bin/varnishd/cache/cache_busyobj.c index 8fbcf43..0b9d62f 100644 --- a/bin/varnishd/cache/cache_busyobj.c +++ b/bin/varnishd/cache/cache_busyobj.c @@ -101,17 +101,17 @@ VBO_GetBusyObj(struct worker *wrk, const struct req *req) nhttp = (uint16_t)cache_param->http_max_hdr; sz = HTTP_estimate(nhttp); - bo->bereq0 = HTTP_create(p, nhttp); + bo->bereq0 = HTTP_create(p, nhttp, sz); p += sz; p = (void*)PRNDUP(p); assert(p < bo->end); - bo->bereq = HTTP_create(p, nhttp); + bo->bereq = HTTP_create(p, nhttp, sz); p += sz; p = (void*)PRNDUP(p); assert(p < bo->end); - bo->beresp = HTTP_create(p, nhttp); + bo->beresp = HTTP_create(p, nhttp, sz); p += sz; p = (void*)PRNDUP(p); assert(p < bo->end); diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c index 5d900bf..d18ca52 100644 --- a/bin/varnishd/cache/cache_http.c +++ b/bin/varnishd/cache/cache_http.c @@ -147,7 +147,7 @@ HTTP_estimate(unsigned nhttp) } struct http * -HTTP_create(void *p, uint16_t nhttp) +HTTP_create(void *p, uint16_t nhttp, unsigned len) { struct http *hp; @@ -156,6 +156,7 @@ HTTP_create(void *p, uint16_t nhttp) hp->hd = (void*)(hp + 1); hp->shd = nhttp; hp->hdf = (void*)(hp->hd + nhttp); + assert((unsigned char*)p + len == hp->hdf + nhttp); return (hp); } diff --git a/bin/varnishd/cache/cache_req.c b/bin/varnishd/cache/cache_req.c index 1899bb0..b95fc9e 100644 --- a/bin/varnishd/cache/cache_req.c +++ b/bin/varnishd/cache/cache_req.c @@ -77,17 +77,17 @@ Req_New(const struct worker *wrk, struct sess *sp) nhttp = (uint16_t)cache_param->http_max_hdr; hl = HTTP_estimate(nhttp); - req->http = HTTP_create(p, nhttp); + req->http = HTTP_create(p, nhttp, hl); p += hl; p = (void*)PRNDUP(p); assert(p < e); - req->http0 = HTTP_create(p, nhttp); + req->http0 = HTTP_create(p, nhttp, hl); p += hl; p = (void*)PRNDUP(p); assert(p < e); - req->resp = HTTP_create(p, nhttp); + req->resp = HTTP_create(p, nhttp, hl); p += hl; p = (void*)PRNDUP(p); assert(p < e); From phk at FreeBSD.org Mon Apr 3 20:28:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 03 Apr 2017 22:28:05 +0200 Subject: [master] 1389fc9 Move and rename CNT_AcctLogCharge() to Req_AcctLogCharge() Message-ID: commit 1389fc9667ccd85018db2aeecaf431256f8d4d04 Author: Poul-Henning Kamp Date: Mon Apr 3 20:05:57 2017 +0000 Move and rename CNT_AcctLogCharge() to Req_AcctLogCharge() diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index bc79aa3..ee33de0 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -933,6 +933,7 @@ struct req *Req_New(const struct worker *, struct sess *); void Req_Release(struct req *); void Req_Cleanup(struct sess *sp, struct worker *wrk, struct req *req); void Req_Fail(struct req *req, enum sess_close reason); +void Req_AcctLogCharge(struct dstat *, struct req *); /* cache_req_body.c */ int VRB_Ignore(struct req *); @@ -942,7 +943,6 @@ void VRB_Free(struct req *); /* cache_req_fsm.c [CNT] */ enum req_fsm_nxt CNT_Request(struct worker *, struct req *); -void CNT_AcctLogCharge(struct dstat *, struct req *); /* cache_session.c [SES] */ void SES_Wait(struct sess *, const struct transport *); diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index 17682da..6931e16 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -199,7 +199,7 @@ ved_include(struct req *preq, const char *src, const char *host, } VRTPRIV_dynamic_kill(req->sp->privs, (uintptr_t)req); - CNT_AcctLogCharge(wrk->stats, req); + Req_AcctLogCharge(wrk->stats, req); VSL_End(req->vsl); preq->vcl = req->vcl; diff --git a/bin/varnishd/cache/cache_req.c b/bin/varnishd/cache/cache_req.c index b95fc9e..a3499ca 100644 --- a/bin/varnishd/cache/cache_req.c +++ b/bin/varnishd/cache/cache_req.c @@ -43,6 +43,32 @@ #include "vtim.h" +void +Req_AcctLogCharge(struct dstat *ds, struct req *req) +{ + struct acct_req *a; + + AN(ds); + CHECK_OBJ_NOTNULL(req, REQ_MAGIC); + + a = &req->acct; + + if (req->vsl->wid && !(req->res_mode & RES_PIPE)) { + VSLb(req->vsl, SLT_ReqAcct, "%ju %ju %ju %ju %ju %ju", + (uintmax_t)a->req_hdrbytes, + (uintmax_t)a->req_bodybytes, + (uintmax_t)(a->req_hdrbytes + a->req_bodybytes), + (uintmax_t)a->resp_hdrbytes, + (uintmax_t)a->resp_bodybytes, + (uintmax_t)(a->resp_hdrbytes + a->resp_bodybytes)); + } + +#define ACCT(foo) \ + ds->s_##foo += a->foo; \ + a->foo = 0; +#include "tbl/acct_fields_req.h" +} + /*-------------------------------------------------------------------- * Alloc/Free a request */ @@ -170,7 +196,7 @@ Req_Cleanup(struct sess *sp, struct worker *wrk, struct req *req) /* Charge and log byte counters */ if (req->vsl->wid) { - CNT_AcctLogCharge(wrk->stats, req); + Req_AcctLogCharge(wrk->stats, req); VSL_End(req->vsl); } req->req_bodybytes = 0; diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index aa8e1d7..1723bed 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -1016,29 +1016,3 @@ CNT_Request(struct worker *wrk, struct req *req) assert(nxt == REQ_FSM_DISEMBARK || req->ws->r == NULL); return (nxt); } - -void -CNT_AcctLogCharge(struct dstat *ds, struct req *req) -{ - struct acct_req *a; - - AN(ds); - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - - a = &req->acct; - - if (req->vsl->wid && !(req->res_mode & RES_PIPE)) { - VSLb(req->vsl, SLT_ReqAcct, "%ju %ju %ju %ju %ju %ju", - (uintmax_t)a->req_hdrbytes, - (uintmax_t)a->req_bodybytes, - (uintmax_t)(a->req_hdrbytes + a->req_bodybytes), - (uintmax_t)a->resp_hdrbytes, - (uintmax_t)a->resp_bodybytes, - (uintmax_t)(a->resp_hdrbytes + a->resp_bodybytes)); - } - -#define ACCT(foo) \ - ds->s_##foo += a->foo; \ - a->foo = 0; -#include "tbl/acct_fields_req.h" -} diff --git a/bin/varnishd/http1/cache_http1_fsm.c b/bin/varnishd/http1/cache_http1_fsm.c index 5bd4429..bd68ae8 100644 --- a/bin/varnishd/http1/cache_http1_fsm.c +++ b/bin/varnishd/http1/cache_http1_fsm.c @@ -197,7 +197,7 @@ http1_reembark(struct worker *wrk, struct req *req) wrk->stats->busy_killed++; AN (req->vcl); VCL_Rel(&req->vcl); - CNT_AcctLogCharge(wrk->stats, req); + Req_AcctLogCharge(wrk->stats, req); Req_Release(req); SES_Delete(sp, SC_OVERLOAD, NAN); DSL(DBG_WAITINGLIST, req->vsl->wid, "kill from waiting list"); @@ -402,7 +402,7 @@ HTTP1_Session(struct worker *wrk, struct req *req) if (hs < HTC_S_EMPTY) { req->acct.req_hdrbytes += req->htc->rxbuf_e - req->htc->rxbuf_b; - CNT_AcctLogCharge(wrk->stats, req); + Req_AcctLogCharge(wrk->stats, req); Req_Release(req); switch (hs) { case HTC_S_CLOSE: diff --git a/bin/varnishd/http2/cache_http2_session.c b/bin/varnishd/http2/cache_http2_session.c index 0dbb541..c12e2f5 100644 --- a/bin/varnishd/http2/cache_http2_session.c +++ b/bin/varnishd/http2/cache_http2_session.c @@ -205,7 +205,7 @@ h2_ou_session(struct worker *wrk, struct h2_sess *h2, VSLb(h2->vsl, SLT_Debug, "H2: Bad HTTP-Settings"); AN (req->vcl); VCL_Rel(&req->vcl); - CNT_AcctLogCharge(wrk->stats, req); + Req_AcctLogCharge(wrk->stats, req); Req_Release(req); return (0); } @@ -366,7 +366,7 @@ h2_reembark(struct worker *wrk, struct req *req) wrk->stats->busy_killed++; AN (req->vcl); VCL_Rel(&req->vcl); - CNT_AcctLogCharge(wrk->stats, req); + Req_AcctLogCharge(wrk->stats, req); Req_Release(req); DSL(DBG_WAITINGLIST, req->vsl->wid, "kill from waiting list"); usleep(10000); From phk at FreeBSD.org Mon Apr 3 20:28:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 03 Apr 2017 22:28:05 +0200 Subject: [master] 6d1fb08 Bring ESI req cleanup more in line with the other req cleanups. Message-ID: commit 6d1fb0821b012762df057f63133437bb8871f631 Author: Poul-Henning Kamp Date: Mon Apr 3 20:26:10 2017 +0000 Bring ESI req cleanup more in line with the other req cleanups. diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index 6931e16..b2d013c 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -98,18 +98,21 @@ ved_include(struct req *preq, const char *src, const char *host, struct ecx *ecx) { struct worker *wrk; + struct sess *sp; struct req *req; enum req_fsm_nxt s; CHECK_OBJ_NOTNULL(preq, REQ_MAGIC); + sp = preq->sp; + CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(ecx, ECX_MAGIC); wrk = preq->wrk; if (preq->esi_level >= cache_param->max_esi_depth) return; - req = Req_New(wrk, preq->sp); - SES_Ref(preq->sp); + req = Req_New(wrk, sp); + SES_Ref(sp); req->req_body_status = REQ_BODY_NONE; AZ(req->vsl->wid); req->vsl->wid = VXID_Get(wrk, VSL_CLIENTMARKER); @@ -158,6 +161,7 @@ ved_include(struct req *preq, const char *src, const char *host, /* Reset request to status before we started messing with it */ HTTP_Copy(req->http, req->http0); + AZ(req->vcl); req->vcl = preq->vcl; preq->vcl = NULL; @@ -189,27 +193,27 @@ ved_include(struct req *preq, const char *src, const char *host, DSL(DBG_WAITINGLIST, req->vsl->wid, "loop waiting for ESI (%d)", (int)s); assert(s == REQ_FSM_DISEMBARK); - Lck_Lock(&req->sp->mtx); + Lck_Lock(&sp->mtx); if (!ecx->woken) (void)Lck_CondWait( - &ecx->preq->wrk->cond, &req->sp->mtx, 0); - Lck_Unlock(&req->sp->mtx); + &ecx->preq->wrk->cond, &sp->mtx, 0); + Lck_Unlock(&sp->mtx); ecx->woken = 0; AZ(req->wrk); } - VRTPRIV_dynamic_kill(req->sp->privs, (uintptr_t)req); - Req_AcctLogCharge(wrk->stats, req); - VSL_End(req->vsl); + VRTPRIV_dynamic_kill(sp->privs, (uintptr_t)req); + AZ(preq->vcl); preq->vcl = req->vcl; req->vcl = NULL; req->wrk = NULL; - THR_SetRequest(preq); - SES_Rel(req->sp); + + Req_AcctLogCharge(wrk->stats, req); Req_Release(req); + SES_Rel(sp); } /*--------------------------------------------------------------------*/ From nils.goroll at uplex.de Tue Apr 4 14:39:05 2017 From: nils.goroll at uplex.de (Nils Goroll) Date: Tue, 04 Apr 2017 16:39:05 +0200 Subject: [master] 5e4d6c8 backend probe: no need to parse a reason phrase we do not use Message-ID: commit 5e4d6c843376acc0bf14872d89a4e8bb2f77186b Author: Nils Goroll Date: Tue Apr 4 15:55:06 2017 +0200 backend probe: no need to parse a reason phrase we do not use Ref: bcdf4f12891eb7ecba395bdf268f8be4c9faa255 https://tools.ietf.org/html/rfc7230#section-3.1.2 diff --git a/bin/varnishd/cache/cache_backend_probe.c b/bin/varnishd/cache/cache_backend_probe.c index 3d5bc15..52de48f 100644 --- a/bin/varnishd/cache/cache_backend_probe.c +++ b/bin/varnishd/cache/cache_backend_probe.c @@ -369,9 +369,9 @@ vbp_poke(struct vbp_target *vt) if (p != NULL) *p = '\0'; - i = sscanf(vt->resp_buf, "HTTP/%*f %u %s", &resp, buf); + i = sscanf(vt->resp_buf, "HTTP/%*f %u ", &resp); - if ((i == 1 || i == 2) && resp == vt->exp_status) + if (i == 1 && resp == vt->exp_status) vt->happy |= 1; } From nils.goroll at uplex.de Tue Apr 4 14:39:05 2017 From: nils.goroll at uplex.de (Nils Goroll) Date: Tue, 04 Apr 2017 16:39:05 +0200 Subject: [master] 9f42262 backend polling: Test responses without reason, check the outcome Message-ID: commit 9f4226200ef7784b597056fbb788b57f64ca6ef3 Author: Nils Goroll Date: Tue Apr 4 16:09:59 2017 +0200 backend polling: Test responses without reason, check the outcome We expect: - two initial healthy probes (threshold - 1 = 2 by default) - eight healthy probes (explicitly checked) - five failing probes - two healthy probes To tolerate up to 500ms before cliexpect runs after the barrier was raised, we accept up to five additional failed probes. diff --git a/bin/varnishtest/tests/c00017.vtc b/bin/varnishtest/tests/c00017.vtc index b062980..42960d0 100644 --- a/bin/varnishtest/tests/c00017.vtc +++ b/bin/varnishtest/tests/c00017.vtc @@ -23,6 +23,12 @@ server s1 { txresp -proto "FROBOZ" -status 200 -hdr "Bar: foo" -body "foobar" accept } + loop 2 { + rxreq + expect req.url == "/" + send "HTTP/1.1 200 \r\n" + accept + } barrier b1 sync } -start @@ -42,4 +48,4 @@ varnish v1 -vcl { barrier b1 sync -varnish v1 -cli "backend.list -p" +varnish v1 -cliexpect "^CLI RX| -+H{10}-{5}H{2}-{0,5} Happy" "backend.list -p" From hermunn at varnish-software.com Tue Apr 4 15:10:07 2017 From: hermunn at varnish-software.com (Pål Hermunn Johansen) Date: Tue, 04 Apr 2017 17:10:07 +0200 Subject: [4.1] 3e19f33 Fix race in the VSL segment counter initialization Message-ID: commit 3e19f335e78e8100ae0eb3c9ddc0d4f14c389430 Author: Martin Blix Grydeland Date: Tue Mar 7 17:13:26 2017 +0100 Fix race in the VSL segment counter initialization Fix a stupid misstake where the segment counter in the VSL segment was set just before the entire struct was cleared during initialization. This didn't cause problems in the common case because it would be set correctly on the very first log line produced. But it did open a race where an unfortunate early log client would assume it was lagging indefinetely behind varnishd on the log reading and report overflow error. This was most commonly experienced with varnishtest. Fixes: #2241 diff --git a/bin/varnishd/cache/cache_shmlog.c b/bin/varnishd/cache/cache_shmlog.c index 789e902..b96bf73 100644 --- a/bin/varnishd/cache/cache_shmlog.c +++ b/bin/varnishd/cache/cache_shmlog.c @@ -470,13 +470,13 @@ VSM_Init(void) problems with regard to readers on that event visible */ vsl_segment_n = UINT_MAX - VSL_SEGMENTS + 1; AZ(vsl_segment_n % VSL_SEGMENTS); - vsl_head->segment_n = vsl_segment_n; vsl_ptr = vsl_head->log; *vsl_ptr = VSL_ENDMARKER; memset(vsl_head, 0, sizeof *vsl_head); vsl_head->segsize = vsl_segsize; vsl_head->offset[0] = 0; + vsl_head->segment_n = vsl_segment_n; for (i = 1; i < VSL_SEGMENTS; i++) vsl_head->offset[i] = -1; VWMB(); From varnish-commit at varnish-cache.org Tue Apr 4 21:27:53 2017 From: varnish-commit at varnish-cache.org (varnish-commit) Date: Wed, 5 Apr 2017 05:27:53 +0800 Subject: =?utf-8?B?UkXvvJrov53nuqrpl67popjlkZjlt6XlpITnkIY=?= Message-ID: <20170405052804426017@ygxdwife.com> 1.????????????????????????????????? 2.??????????????????2?????????????? 3.??????????????????? 4.??????????????????????????????? 5.???????????????????????????????? 6.??????????????????? 7.??????????????????? 8.????????????5%?????????????? -------------- next part -------------- A non-text attachment was scrubbed... Name: ????????.docx Type: application/octet-stream Size: 23015 bytes Desc: not available URL: From phk at FreeBSD.org Tue Apr 4 22:03:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 05 Apr 2017 00:03:05 +0200 Subject: [master] 425d37b Introduce a barrier to prevent the HEADERS from overtaking the WINDOWS_UPDATE Message-ID: commit 425d37b6420cb7c4cc0c50af4a55684685525f0f Author: Poul-Henning Kamp Date: Tue Apr 4 22:01:59 2017 +0000 Introduce a barrier to prevent the HEADERS from overtaking the WINDOWS_UPDATE diff --git a/bin/varnishtest/tests/t02005.vtc b/bin/varnishtest/tests/t02005.vtc index 2cf31ee..85235f7 100644 --- a/bin/varnishtest/tests/t02005.vtc +++ b/bin/varnishtest/tests/t02005.vtc @@ -1,7 +1,10 @@ varnishtest "H2 POST" +barrier b1 cond 2 + server s1 { rxreq + barrier b1 sync txresp -hdr "Content-Type: text/plain" -body response } -start @@ -13,6 +16,7 @@ client c1 { txreq -req POST -hdr content-type text/plain -hdr content-length 7 -body request rxwinup + barrier b1 sync # First, HTTP checks rxresp expect resp.http.content-Type == "text/plain" From phk at FreeBSD.org Tue Apr 4 23:08:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 05 Apr 2017 01:08:05 +0200 Subject: [master] b8d0687 Also stabilize t02006 with a barrier to keep HEADERS from overtaking WINDOWS UPDATE Message-ID: commit b8d06876da481ce6e69ee2165d86e2118eabf915 Author: Poul-Henning Kamp Date: Tue Apr 4 23:06:42 2017 +0000 Also stabilize t02006 with a barrier to keep HEADERS from overtaking WINDOWS UPDATE diff --git a/bin/varnishtest/tests/t02006.vtc b/bin/varnishtest/tests/t02006.vtc index 58b33e3..31a5fbf 100644 --- a/bin/varnishtest/tests/t02006.vtc +++ b/bin/varnishtest/tests/t02006.vtc @@ -1,8 +1,11 @@ varnishtest "H2 POST w/ 100 Continue" +barrier b1 cond 2 + server s1 { rxreq expect req.proto == HTTP/1.1 + barrier b1 sync txresp -hdr "Content-Type: text/plain" -body response } -start @@ -28,6 +31,7 @@ client c1 { -data request rxwinup + barrier b1 sync rxresp expect resp.status == 200 expect resp.http.content-Type == "text/plain" From phk at FreeBSD.org Wed Apr 5 06:47:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 05 Apr 2017 08:47:05 +0200 Subject: [master] 1d9d85e Collect H2 cookies in H2 code, long time before we get to create req->http0. Message-ID: commit 1d9d85eb0cd32c55712e8dabe00f1249ce502ca3 Author: Poul-Henning Kamp Date: Wed Apr 5 06:45:08 2017 +0000 Collect H2 cookies in H2 code, long time before we get to create req->http0. Fixes #2300 Testcase by Simon diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 1723bed..1320e81 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -799,9 +799,6 @@ cnt_recv(struct worker *wrk, struct req *req) http_CollectHdr(req->http, H_Cache_Control); - if (req->http->protover == 20) // rfc7540,l,3114,3120 - http_CollectHdrSep(req->http, H_Cookie, "; "); - if (req->req_body_status == REQ_BODY_FAIL) { req->doclose = SC_OVERLOAD; return (REQ_FSM_DONE); diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index ab0f28d..27c95bd 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -467,6 +467,12 @@ h2_do_req(struct worker *wrk, void *priv) CAST_OBJ_NOTNULL(req, priv, REQ_MAGIC); CAST_OBJ_NOTNULL(r2, req->transport_priv, H2_REQ_MAGIC); THR_SetRequest(req); + + // XXX: Smarter to do this already at HPACK time into tail end of + // XXX: WS, then copy back once all headers received. + // XXX: Have I mentioned H/2 Is hodge-podge ? + http_CollectHdrSep(req->http, H_Cookie, "; "); // rfc7540,l,3114,3120 + req->http->conds = 1; if (CNT_Request(wrk, req) != REQ_FSM_DISEMBARK) { AZ(req->ws->r); diff --git a/bin/varnishtest/tests/r02300.vtc b/bin/varnishtest/tests/r02300.vtc new file mode 100644 index 0000000..130a172 --- /dev/null +++ b/bin/varnishtest/tests/r02300.vtc @@ -0,0 +1,29 @@ +varnishtest "ESI Cookie" + +server s1 { + fatal + rxreq + expect req.http.cookie == "Foo=Bar; B=C" + txresp -body "" + + rxreq + expect req.http.cookie == "Foo=Bar; B=C" + txresp +} -start + +varnish v1 -cliok {param.set feature +http2} +varnish v1 -cliok {param.set debug +syncvsl} + + +varnish v1 -vcl+backend { + sub vcl_backend_response { + set beresp.do_esi = true; + } +} -start + +client c1 { + stream 1 { + txreq -url "/" -hdr cookie "Foo=Bar" -hdr cookie "B=C" + rxresp + } -start +} -run From hermunn at varnish-software.com Wed Apr 5 10:03:05 2017 From: hermunn at varnish-software.com (Pål Hermunn Johansen) Date: Wed, 05 Apr 2017 12:03:05 +0200 Subject: [4.1] 72a6d1e Set the go-cold timer on newly loaded warm auto VCLs Message-ID: commit 72a6d1ecd68a0e8cbf5f8d484624993a12c5cf36 Author: Martin Blix Grydeland Date: Wed Mar 22 10:59:54 2017 +0100 Set the go-cold timer on newly loaded warm auto VCLs Newly loaded VCLs didn't get their go cold timer set even when they were set to auto, causing them to never go cold automatically. Fixes: #2270 Conflicts: bin/varnishd/mgt/mgt_vcl.c diff --git a/bin/varnishd/mgt/mgt_vcl.c b/bin/varnishd/mgt/mgt_vcl.c index 3801863..4c47730 100644 --- a/bin/varnishd/mgt/mgt_vcl.c +++ b/bin/varnishd/mgt/mgt_vcl.c @@ -216,6 +216,8 @@ mgt_new_vcl(struct cli *cli, const char *vclname, const char *vclsrc, if (!mgt_cli_askchild(&status, &p, "vcl.load %s %s %d%s\n", vp->name, vp->fname, vp->warm, vp->state)) { + if (vp->warm && !strcmp(vp->state, "auto")) + vp->go_cold = VTIM_mono(); free(p); return; } diff --git a/bin/varnishtest/tests/r02270.vtc b/bin/varnishtest/tests/r02270.vtc new file mode 100644 index 0000000..8547ca5 --- /dev/null +++ b/bin/varnishtest/tests/r02270.vtc @@ -0,0 +1,19 @@ +varnishtest "Test that never used VCLs go cold automatically" + +server s1 { + rxreq + txresp +} -start + +varnish v1 -arg "-p vcl_cooldown=1" -vcl+backend { +} -start + +varnish v1 -expect VBE.vcl1.s1.happy >= 0 + +varnish v1 -cliok {vcl.inline vcl2 "vcl 4.0; backend s1 {.host = \"${s1_addr}\"; .port = \"${s1_port}\"; }"} + +varnish v1 -expect VBE.vcl2.s1.happy >= 0 + +delay 5 + +varnish v1 -expect !VBE.vcl2.s1.happy From hermunn at varnish-software.com Wed Apr 5 10:03:05 2017 From: hermunn at varnish-software.com (Pål Hermunn Johansen) Date: Wed, 05 Apr 2017 12:03:05 +0200 Subject: [4.1] bd7c708 Do not update mgt's mirrored VCL temp state on child temp state failures Message-ID: commit bd7c70805fada96b9c41ef99e604525e3734ca99 Author: Martin Blix Grydeland Date: Wed Mar 22 14:17:17 2017 +0100 Do not update mgt's mirrored VCL temp state on child temp state failures The child expects mgt to be consistent in its VCL state changes, e.g. not ask the child to 'use' a VCL that isn't warm. Not doing so will cause the child to assert (see asserts in cache_vcl.c:ccf_config_use). This could trigger because the mgt erranously would set its recorded temp regardless of the child's reply in mgt_vcl_setstate. This patch changes it to only record the new temp in mgt if the child replied success. If the child isn't running the new temp is always recorded. Slightly update v00044.vtc test case to reflect the need to update the state before restarting the child. Ref: https://github.com/varnishcache/varnish-cache/pull/2273 diff --git a/bin/varnishd/mgt/mgt_vcl.c b/bin/varnishd/mgt/mgt_vcl.c index 4c47730..9e9c53c 100644 --- a/bin/varnishd/mgt/mgt_vcl.c +++ b/bin/varnishd/mgt/mgt_vcl.c @@ -151,21 +151,26 @@ mgt_vcl_setstate(struct cli *cli, struct vclprog *vp, const char *vs) if (vp->warm == warm) return (0); - vp->warm = warm; - - if (vp->warm == 0) - vp->go_cold = 0; - - if (child_pid < 0) + if (child_pid < 0) { + vp->warm = warm; + if (vp->warm == 0) + vp->go_cold = 0; return (0); + } i = mgt_cli_askchild(&status, &p, "vcl.state %s %d%s\n", - vp->name, vp->warm, vp->state); + vp->name, warm, vp->state); if (i) { AN(cli); - AN(vp->warm); + AN(warm); VCLI_SetResult(cli, status); VCLI_Out(cli, "%s", p); + } else { + /* Success, update mgt's VCL state to reflect child's + state */ + vp->warm = warm; + if (vp->warm == 0) + vp->go_cold = 0; } free(p); diff --git a/bin/varnishtest/tests/v00044.vtc b/bin/varnishtest/tests/v00044.vtc index c056d6c..cc449aa 100644 --- a/bin/varnishtest/tests/v00044.vtc +++ b/bin/varnishtest/tests/v00044.vtc @@ -90,4 +90,5 @@ varnish v1 -clierr 300 "vcl.state vcl1 warm" # A warm-up failure can also fail a child start varnish v1 -cliok stop +varnish v1 -cliok "vcl.state vcl1 warm" varnish v1 -clierr 300 start From hermunn at varnish-software.com Wed Apr 5 12:24:05 2017 From: hermunn at varnish-software.com (Pål Hermunn Johansen) Date: Wed, 05 Apr 2017 14:24:05 +0200 Subject: [4.1] 04b4e38 Fix the spinlock loop in VBE_Poll Message-ID: commit 04b4e3805bf7357d6e73dc4bf97e2b8bc6d823f5 Author: Martin Blix Grydeland Date: Fri Mar 31 13:12:24 2017 +0200 Fix the spinlock loop in VBE_Poll VBE_Poll would not advance to test the next backend on the cooling list when the backend's n_conn is non-zero. This would create a spinlock effect, causing delays that could make the master kill the child because of CLI timeout. Fixes: #2295 diff --git a/bin/varnishd/cache/cache_backend_cfg.c b/bin/varnishd/cache/cache_backend_cfg.c index 50e9e4d..4562fb9 100644 --- a/bin/varnishd/cache/cache_backend_cfg.c +++ b/bin/varnishd/cache/cache_backend_cfg.c @@ -440,14 +440,12 @@ static struct cli_proto backend_cmds[] = { void VBE_Poll(void) { - struct backend *be; + struct backend *be, *be2; double now = VTIM_real(); Lck_Lock(&backends_mtx); - while (1) { - be = VTAILQ_FIRST(&cool_backends); - if (be == NULL) - break; + VTAILQ_FOREACH_SAFE(be, &cool_backends, list, be2) { + CHECK_OBJ_NOTNULL(be, BACKEND_MAGIC); if (be->cooled > now) break; if (be->n_conn > 0) diff --git a/bin/varnishtest/tests.disabled/r02295.vtc b/bin/varnishtest/tests.disabled/r02295.vtc new file mode 100644 index 0000000..f7a06e1 --- /dev/null +++ b/bin/varnishtest/tests.disabled/r02295.vtc @@ -0,0 +1,53 @@ +varnishtest "Test cooled dynamic backend clean up" + +# This test is disabled because it needs a timeout of 80 seconds (-t80 to +# varnishtest). This is because the cooled backend timeout in varnish core +# is hard coded to 60 seconds. + +server s1 { + rxreq + delay 70 + txresp +} -start + +varnish v1 -arg "-p cli_timeout=2 -p first_byte_timeout=80" -vcl { + import debug; + + backend dummy { .host = "${bad_backend}"; } + + sub vcl_init { + new s1 = debug.dyn("${s1_addr}", "${s1_port}"); + } + + sub vcl_recv { + if (req.url == "/refresh") { + s1.refresh("${s1_addr}", "${s1_port}"); + return (synth(200, "OK")); + } + } + + sub vcl_backend_fetch { + set bereq.backend = s1.backend(); + } +} -start + +client c1 { + timeout 120 + txreq + rxresp + expect resp.status == 200 +} -start + +delay 1 + +client c2 { + txreq -url /refresh + rxresp + expect resp.status == 200 +} -run + +delay 61 + +varnish v1 -cliok "ping" + +client c1 -wait From phk at FreeBSD.org Wed Apr 5 14:03:06 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 05 Apr 2017 16:03:06 +0200 Subject: [master] 6a40a47 Lock h2->vsl with mutex, even though most of the SLT_Debug stuff will eventually go away. Message-ID: commit 6a40a47531ada96dae7394171fa3722193b1600d Author: Poul-Henning Kamp Date: Wed Apr 5 14:02:08 2017 +0000 Lock h2->vsl with mutex, even though most of the SLT_Debug stuff will eventually go away. Fixes #2283 diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index 27c95bd..1711704 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -199,8 +199,8 @@ h2_kill_req(struct worker *wrk, const struct h2_sess *h2, ASSERT_RXTHR(h2); AN(h2e); - VSLb(h2->vsl, SLT_Debug, "KILL st=%u state=%d", r2->stream, r2->state); Lck_Lock(&h2->sess->mtx); + VSLb(h2->vsl, SLT_Debug, "KILL st=%u state=%d", r2->stream, r2->state); if (r2->error == NULL) r2->error = h2e; if (r2->scheduled) { @@ -230,10 +230,6 @@ h2_vsl_frame(const struct h2_sess *h2, const void *ptr, size_t len) assert(len >= 9); b = ptr; - VSLb_bin(h2->vsl, SLT_H2RxHdr, 9, b); - if (len > 9) - VSLb_bin(h2->vsl, SLT_H2RxBody, len - 9, b + 9); - vsb = VSB_new_auto(); AN(vsb); p = h2_framename((enum h2frame)b[3]); @@ -252,7 +248,13 @@ h2_vsl_frame(const struct h2_sess *h2, const void *ptr, size_t len) VSB_quote(vsb, b + 9, len - 9, VSB_QUOTE_HEX); } AZ(VSB_finish(vsb)); + Lck_Lock(&h2->sess->mtx); + VSLb_bin(h2->vsl, SLT_H2RxHdr, 9, b); + if (len > 9) + VSLb_bin(h2->vsl, SLT_H2RxBody, len - 9, b + 9); + VSLb(h2->vsl, SLT_Debug, "H2RXF %s", VSB_data(vsb)); + Lck_Unlock(&h2->sess->mtx); VSB_destroy(&vsb); } @@ -322,7 +324,9 @@ h2_rx_goaway(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) (void)r2; h2->goaway_last_stream = vbe32dec(h2->rxf_data); h2->error = h2_connectionerror(vbe32dec(h2->rxf_data + 4)); + Lck_Lock(&h2->sess->mtx); VSLb(h2->vsl, SLT_Debug, "GOAWAY %s", h2->error->name); + Lck_Unlock(&h2->sess->mtx); return (h2->error); } @@ -403,20 +407,26 @@ h2_set_setting(struct h2_sess *h2, const uint8_t *d) y = vbe32dec(d + 2); if (x >= H2_SETTING_TBL_LEN || h2_setting_tbl[x] == NULL) { // rfc7540,l,2181,2182 + Lck_Lock(&h2->sess->mtx); VSLb(h2->vsl, SLT_Debug, "H2SETTING unknown setting 0x%04x=%08x (ignored)", x, y); + Lck_Unlock(&h2->sess->mtx); return (0); } s = h2_setting_tbl[x]; AN(s); if (y < s->minval || y > s->maxval) { + Lck_Lock(&h2->sess->mtx); VSLb(h2->vsl, SLT_Debug, "H2SETTING invalid %s=0x%08x", s->name, y); + Lck_Unlock(&h2->sess->mtx); AN(s->range_error); if (!DO_DEBUG(DBG_H2_NOCHECK)) return (s->range_error); } + Lck_Lock(&h2->sess->mtx); VSLb(h2->vsl, SLT_Debug, "H2SETTING %s=0x%08x", s->name, y); + Lck_Unlock(&h2->sess->mtx); AN(s->setfunc); s->setfunc(&h2->remote_settings, y); return (0); @@ -496,7 +506,9 @@ h2_end_headers(struct worker *wrk, const struct h2_sess *h2, FREE_OBJ(r2->decode); r2->state = H2_S_CLOS_REM; if (h2e != NULL) { + Lck_Lock(&h2->sess->mtx); VSLb(h2->vsl, SLT_Debug, "HPACK/FINI %s", h2e->name); + Lck_Unlock(&h2->sess->mtx); AZ(r2->req->ws->r); h2_del_req(wrk, r2); return (h2e); @@ -568,7 +580,9 @@ h2_rx_headers(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) } h2e = h2h_decode_bytes(h2, r2->decode, p, l); if (h2e != NULL) { + Lck_Lock(&h2->sess->mtx); VSLb(h2->vsl, SLT_Debug, "HPACK(hdr) %s", h2e->name); + Lck_Unlock(&h2->sess->mtx); (void)h2h_decode_fini(h2, r2->decode); AZ(r2->req->ws->r); h2_del_req(wrk, r2); @@ -595,7 +609,9 @@ h2_rx_continuation(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) req = r2->req; h2e = h2h_decode_bytes(h2, r2->decode, h2->rxf_data, h2->rxf_len); if (h2e != NULL) { + Lck_Lock(&h2->sess->mtx); VSLb(h2->vsl, SLT_Debug, "HPACK(cont) %s", h2e->name); + Lck_Unlock(&h2->sess->mtx); (void)h2h_decode_fini(h2, r2->decode); AZ(r2->req->ws->r); h2_del_req(wrk, r2); @@ -767,8 +783,10 @@ h2_procframe(struct worker *wrk, struct h2_sess *h2, // rfc7540,l,1140,1145 // rfc7540,l,1153,1158 /* No even streams, we don't do PUSH_PROMISE */ + Lck_Lock(&h2->sess->mtx); VSLb(h2->vsl, SLT_Debug, "H2: illegal stream (=%u)", h2->rxf_stream); + Lck_Unlock(&h2->sess->mtx); return (H2CE_PROTOCOL_ERROR); } @@ -793,7 +811,9 @@ h2_procframe(struct worker *wrk, struct h2_sess *h2, if (h2->rxf_stream == 0 || h2e->connection) return (h2e); // Connection errors one level up + Lck_Lock(&h2->sess->mtx); VSLb(h2->vsl, SLT_Debug, "H2: stream %u: %s", h2->rxf_stream, h2e->txt); + Lck_Unlock(&h2->sess->mtx); vbe32enc(b, h2e->val); H2_Send_Get(wrk, h2, h2->req0); @@ -851,17 +871,17 @@ h2_rxframe(struct worker *wrk, struct h2_sess *h2) /* XXX: later full DATA will not be rx'ed yet. */ HTC_RxPipeline(h2->htc, h2->htc->rxbuf_b + h2->rxf_len + 9); - Lck_Lock(&h2->sess->mtx); h2_vsl_frame(h2, h2->htc->rxbuf_b, 9L + h2->rxf_len); - Lck_Unlock(&h2->sess->mtx); if (h2->rxf_type >= H2FMAX) { // rfc7540,l,679,681 // XXX: later, drain rest of frame h2->bogosity++; + Lck_Lock(&h2->sess->mtx); VSLb(h2->vsl, SLT_Debug, "H2: Unknown frame type 0x%02x (ignored)", (uint8_t)h2->rxf_type); + Lck_Unlock(&h2->sess->mtx); return (1); } h2f = h2flist[h2->rxf_type]; @@ -872,9 +892,11 @@ h2_rxframe(struct worker *wrk, struct h2_sess *h2) if (h2->rxf_flags & ~h2f->flags) { // rfc7540,l,687,688 h2->bogosity++; + Lck_Lock(&h2->sess->mtx); VSLb(h2->vsl, SLT_Debug, "H2: Unknown flags 0x%02x on %s (ignored)", (uint8_t)h2->rxf_flags & ~h2f->flags, h2f->name); + Lck_Unlock(&h2->sess->mtx); h2->rxf_flags &= h2f->flags; } diff --git a/bin/varnishd/http2/cache_http2_session.c b/bin/varnishd/http2/cache_http2_session.c index c12e2f5..dc3ac30 100644 --- a/bin/varnishd/http2/cache_http2_session.c +++ b/bin/varnishd/http2/cache_http2_session.c @@ -339,9 +339,10 @@ h2_new_session(struct worker *wrk, void *arg) } if (!again) break; - VTAILQ_FOREACH(r2, &h2->streams, list) - VSLb(h2->vsl, SLT_Debug, "ST %u %d", r2->stream, r2->state); Lck_Lock(&h2->sess->mtx); + VTAILQ_FOREACH(r2, &h2->streams, list) + VSLb(h2->vsl, SLT_Debug, "ST %u %d", + r2->stream, r2->state); (void)Lck_CondWait(h2->cond, &h2->sess->mtx, VTIM_real() + .1); Lck_Unlock(&h2->sess->mtx); } From phk at FreeBSD.org Thu Apr 6 09:28:06 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 06 Apr 2017 11:28:06 +0200 Subject: [master] e57e541 Whitespace ocd Message-ID: commit e57e5417e2ea7867fd7339154b8fa0abb4acb872 Author: Poul-Henning Kamp Date: Thu Apr 6 09:23:28 2017 +0000 Whitespace ocd diff --git a/include/vrt.h b/include/vrt.h index ef5204a..625bc36 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -40,7 +40,7 @@ * * * 6.1 (unreleased): - * http_CollectHdrSep added + * http_CollectHdrSep added * 6.0 (2017-03-15): * VRT_hit_for_pass added * VRT_ipcmp added From phk at FreeBSD.org Thu Apr 6 09:28:06 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 06 Apr 2017 11:28:06 +0200 Subject: [master] f299ae8 Mark frametypes which get charged to the session as overhead Message-ID: commit f299ae887704bad396fdeaa878b5b7ebad23b1b1 Author: Poul-Henning Kamp Date: Thu Apr 6 09:24:04 2017 +0000 Mark frametypes which get charged to the session as overhead diff --git a/bin/varnishd/http2/cache_http2.h b/bin/varnishd/http2/cache_http2.h index 0550e15..f04fb0b 100644 --- a/bin/varnishd/http2/cache_http2.h +++ b/bin/varnishd/http2/cache_http2.h @@ -74,6 +74,7 @@ struct h2_frame_s { int respect_window; h2_frame continuation; uint8_t final_flags; + int overhead; }; #define H2_FRAME(l,U,...) extern const struct h2_frame_s H2_F_##U[1]; diff --git a/include/tbl/h2_frames.h b/include/tbl/h2_frames.h index 4089d9e..8259082 100644 --- a/include/tbl/h2_frames.h +++ b/include/tbl/h2_frames.h @@ -38,6 +38,7 @@ * tx_flow-control // rfc7540,l,1265,1270 * tx_continuation * tx_final-flags + * overhead */ H2_FRAME(data, DATA, 0x0, 0x09, H2CE_PROTOCOL_ERROR, // rfc7540,l,1758,1761 @@ -45,7 +46,8 @@ H2CE_PROTOCOL_ERROR, 1, H2_F_DATA, - 0x01 // rfc7540,l,1750,1753 + 0x01, // rfc7540,l,1750,1753 + 0 ) H2_FRAME(headers, HEADERS, 0x1, 0x2d, H2CE_PROTOCOL_ERROR, // rfc7540,l,1876,1879 @@ -53,7 +55,8 @@ 0, // rfc7540,l,938,940 0, H2_F_CONTINUATION, - 0x04 // rfc7540,l,1855,1857 + 0x04, // rfc7540,l,1855,1857 + 0 ) H2_FRAME(priority, PRIORITY, 0x2, 0x00, H2CE_PROTOCOL_ERROR, // rfc7540,l,1933,1936 @@ -61,7 +64,8 @@ 0, // rfc7540,l,938,940 0, 0, - 0 + 0, + 1 ) H2_FRAME(rst_stream, RST_STREAM, 0x3, 0x00, H2CE_PROTOCOL_ERROR, // rfc7540,l,1993,1996 @@ -69,7 +73,8 @@ H2CE_PROTOCOL_ERROR, 0, 0, - 0 + 0, + 1 ) H2_FRAME(settings, SETTINGS, 0x4, 0x01, 0, @@ -77,7 +82,8 @@ H2CE_PROTOCOL_ERROR, 0, 0, - 0 + 0, + 1 ) H2_FRAME(push_promise, PUSH_PROMISE, 0x5, 0x0c, H2CE_PROTOCOL_ERROR, // rfc7540,l,2262,2263 @@ -85,7 +91,8 @@ H2CE_PROTOCOL_ERROR, 0, H2_F_CONTINUATION, - 0x04 // rfc7540,l,2249,2251 + 0x04, // rfc7540,l,2249,2251 + 2 ) H2_FRAME(ping, PING, 0x6, 0x01, 0, @@ -93,7 +100,8 @@ H2CE_PROTOCOL_ERROR, 0, 0, - 0 + 0, + 1 ) H2_FRAME(goaway, GOAWAY, 0x7, 0x00, 0, @@ -101,7 +109,8 @@ H2CE_PROTOCOL_ERROR, 0, 0, - 0 + 0, + 1 ) H2_FRAME(window_update, WINDOW_UPDATE, 0x8, 0x00, 0, @@ -109,7 +118,8 @@ H2CE_PROTOCOL_ERROR, 0, 0, - 0 + 0, + 1 ) H2_FRAME(continuation, CONTINUATION, 0x9, 0x04, H2CE_PROTOCOL_ERROR, // rfc7540,l,2764,2767 @@ -117,7 +127,8 @@ H2CE_PROTOCOL_ERROR, 0, H2_F_CONTINUATION, - 0x04 // rfc7540,l,2753,2754 + 0x04, // rfc7540,l,2753,2754 + 0 ) #undef H2_FRAME #endif From phk at FreeBSD.org Thu Apr 6 09:28:06 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 06 Apr 2017 11:28:06 +0200 Subject: [master] 8abfe28 Charge H2 traffic to ReqAcct VSL record. Message-ID: commit 8abfe28c8925cf2541f757edce43c3bdd3952477 Author: Poul-Henning Kamp Date: Thu Apr 6 09:25:51 2017 +0000 Charge H2 traffic to ReqAcct VSL record. All H2 frame headers gets charged to the sessions "session req" All H2 frame bodies, except HEADERS, CONTIUATION and DATA also gets charged to the "session req". H2 frame bodies of HEADERS, CONTIUATION and DATA gets charged to the request. diff --git a/bin/varnishd/http2/cache_http2_deliver.c b/bin/varnishd/http2/cache_http2_deliver.c index be422e6..f9463ef 100644 --- a/bin/varnishd/http2/cache_http2_deliver.c +++ b/bin/varnishd/http2/cache_http2_deliver.c @@ -91,6 +91,7 @@ h2_bytes(struct req *req, enum vdp_action act, void **priv, H2_F_DATA, act == VDP_FINI ? H2FF_DATA_END_STREAM : H2FF_NONE, len, ptr); + req->acct.resp_bodybytes += len; H2_Send_Rel(r2->h2sess, r2); return (0); } @@ -256,6 +257,7 @@ h2_deliver(struct req *req, struct boc *boc, int sendbody) H2_Send(req->wrk, r2, H2_F_HEADERS, (sendbody ? 0 : H2FF_HEADERS_END_STREAM) | H2FF_HEADERS_END_HEADERS, sz, req->ws->f); + req->acct.resp_hdrbytes += sz; H2_Send_Rel(r2->h2sess, r2); WS_Release(req->ws, 0); diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index 1711704..1083d0e 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -537,6 +537,7 @@ h2_rx_headers(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) size_t l; ASSERT_RXTHR(h2); + AN(r2); if (r2->state != H2_S_IDLE) return (H2CE_PROTOCOL_ERROR); // XXX spec ? r2->state = H2_S_OPEN; @@ -559,6 +560,7 @@ h2_rx_headers(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) VCL_Refresh(&wrk->vcl); req->vcl = wrk->vcl; wrk->vcl = NULL; + req->acct.req_hdrbytes += h2->rxf_len; HTTP_Setup(req->http, req->ws, req->vsl, SLT_ReqMethod); http_SetH(req->http, HTTP_HDR_PROTO, "HTTP/2.0"); @@ -604,10 +606,12 @@ h2_rx_continuation(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) h2_error h2e; ASSERT_RXTHR(h2); + AN(r2); if (r2->state != H2_S_OPEN) return (H2CE_PROTOCOL_ERROR); // XXX spec ? req = r2->req; h2e = h2h_decode_bytes(h2, r2->decode, h2->rxf_data, h2->rxf_len); + r2->req->acct.req_hdrbytes += h2->rxf_len; if (h2e != NULL) { Lck_Lock(&h2->sess->mtx); VSLb(h2->vsl, SLT_Debug, "HPACK(cont) %s", h2e->name); @@ -632,12 +636,14 @@ h2_rx_data(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) unsigned wi; (void)wrk; + AN(r2); ASSERT_RXTHR(h2); Lck_Lock(&h2->sess->mtx); AZ(h2->mailcall); h2->mailcall = r2; h2->r_window -= h2->rxf_len; r2->r_window -= h2->rxf_len; + // req_bodybytes accounted in CNT code. if (r2->cond) AZ(pthread_cond_signal(r2->cond)); while (h2->mailcall != NULL && h2->error == 0 && r2->error == 0) @@ -872,6 +878,7 @@ h2_rxframe(struct worker *wrk, struct h2_sess *h2) HTC_RxPipeline(h2->htc, h2->htc->rxbuf_b + h2->rxf_len + 9); h2_vsl_frame(h2, h2->htc->rxbuf_b, 9L + h2->rxf_len); + h2->srq->acct.req_hdrbytes += 9; if (h2->rxf_type >= H2FMAX) { // rfc7540,l,679,681 @@ -882,12 +889,15 @@ h2_rxframe(struct worker *wrk, struct h2_sess *h2) "H2: Unknown frame type 0x%02x (ignored)", (uint8_t)h2->rxf_type); Lck_Unlock(&h2->sess->mtx); + h2->srq->acct.req_bodybytes += h2->rxf_len; return (1); } h2f = h2flist[h2->rxf_type]; AN(h2f->name); AN(h2f->rxfunc); + if (h2f->overhead) + h2->srq->acct.req_bodybytes += h2->rxf_len; if (h2->rxf_flags & ~h2f->flags) { // rfc7540,l,687,688 diff --git a/bin/varnishd/http2/cache_http2_send.c b/bin/varnishd/http2/cache_http2_send.c index a220b1e..fa837c9 100644 --- a/bin/varnishd/http2/cache_http2_send.c +++ b/bin/varnishd/http2/cache_http2_send.c @@ -107,6 +107,9 @@ H2_Send_Frame(struct worker *wrk, const struct h2_sess *h2, h2_mk_hdr(hdr, ftyp, flags, len, stream); Lck_Lock(&h2->sess->mtx); VSLb_bin(h2->vsl, SLT_H2TxHdr, 9, hdr); + h2->srq->acct.resp_hdrbytes += 9; + if (ftyp->overhead) + h2->srq->acct.resp_bodybytes += len; Lck_Unlock(&h2->sess->mtx); s = write(h2->sess->fd, hdr, sizeof hdr); diff --git a/bin/varnishtest/tests/t02005.vtc b/bin/varnishtest/tests/t02005.vtc index 85235f7..31be89b 100644 --- a/bin/varnishtest/tests/t02005.vtc +++ b/bin/varnishtest/tests/t02005.vtc @@ -11,7 +11,19 @@ server s1 { varnish v1 -vcl+backend {} -cliok "param.set feature +http2" -start varnish v1 -cliok "param.set debug +syncvsl" +logexpect l1 -v v1 -g raw { + expect * 1001 ReqAcct "80 7 87 106 8 114" + expect * 1000 ReqAcct "45 8 53 72 28 100" +} -start + client c1 { + stream 0 { + txping + rxping + } -run + stream 0 { + rxwinup + } -start stream 1 { txreq -req POST -hdr content-type text/plain -hdr content-length 7 -body request @@ -24,5 +36,8 @@ client c1 { # Then, payload checks expect resp.body == response } -run + stream 0 -wait } -run + +logexpect l1 -wait From phk at FreeBSD.org Thu Apr 6 10:25:06 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 06 Apr 2017 12:25:06 +0200 Subject: [master] d2d121f Don't access struct http after teardown Message-ID: commit d2d121f053b1009385c27b972eb5192aeac3d6ac Author: Poul-Henning Kamp Date: Thu Apr 6 10:23:43 2017 +0000 Don't access struct http after teardown Fixes #2263 diff --git a/bin/varnishd/http2/cache_http2_hpack.c b/bin/varnishd/http2/cache_http2_hpack.c index 9bcc1dd..a7fe43d 100644 --- a/bin/varnishd/http2/cache_http2_hpack.c +++ b/bin/varnishd/http2/cache_http2_hpack.c @@ -305,10 +305,10 @@ h2h_decode_bytes(struct h2_sess *h2, struct h2h_decode *d, } if (d->error == H2SE_ENHANCE_YOUR_CALM) { - http_Teardown(hp); d->out = d->reset; d->out_l = hp->ws->r - d->out; d->out_u = 0; + http_Teardown(hp); assert(d->out_u < d->out_l); } else if (d->error) break; From hermunn at varnish-software.com Thu Apr 6 10:50:06 2017 From: hermunn at varnish-software.com (Pål Hermunn Johansen) Date: Thu, 06 Apr 2017 12:50:06 +0200 Subject: [4.1] 768a00c Introduce a ZERO_OBJ macro similar to bzero Message-ID: commit 768a00c185437b24021ccce8debf232c26b605c4 Author: Dridi Boukelmoune Date: Fri Feb 17 18:06:39 2017 +0100 Introduce a ZERO_OBJ macro similar to bzero It uses `explicit_bzero` when available and falls back to `memset` otherwise. Conflicts: configure.ac diff --git a/configure.ac b/configure.ac index a145726..5c61a61 100644 --- a/configure.ac +++ b/configure.ac @@ -251,6 +251,7 @@ AC_CHECK_FUNCS([strerror]) AC_FUNC_STRERROR_R AC_CHECK_FUNCS([dladdr]) AC_CHECK_FUNCS([socket]) +AC_CHECK_FUNCS([explicit_bzero]) AC_CHECK_FUNCS([nanosleep]) AC_CHECK_FUNCS([setppriv]) AC_CHECK_FUNCS([fallocate]) diff --git a/include/miniobj.h b/include/miniobj.h index 901143f..75093ce 100644 --- a/include/miniobj.h +++ b/include/miniobj.h @@ -5,6 +5,12 @@ * */ +#if HAVE_EXPLICIT_BZERO +# define ZERO_OBJ(to, sz) explicit_bzero(to, sz) +#else +# define ZERO_OBJ(to, sz) (void)memset(to, 0, sz) +#endif + #define INIT_OBJ(to, type_magic) \ do { \ (void)memset(to, 0, sizeof *to); \ @@ -20,7 +26,7 @@ #define FREE_OBJ(to) \ do { \ - (to)->magic = (0); \ + ZERO_OBJ(&(to)->magic, sizeof (to)->magic); \ free(to); \ to = NULL; \ } while (0) From hermunn at varnish-software.com Thu Apr 6 11:36:05 2017 From: hermunn at varnish-software.com (Pål Hermunn Johansen) Date: Thu, 06 Apr 2017 13:36:05 +0200 Subject: [4.1] 09ce321 Add a setenv command to varnishtest Message-ID: commit 09ce321d10e797bcb1908791f53b90dbfe46adce Author: Dag Haavi Finstad Date: Mon Feb 13 17:18:56 2017 +0100 Add a setenv command to varnishtest This lets you set environment variables in a test case. Usage is setenv "FOO" "bar" which will set FOO=bar if FOO does not already exist. There is also an optional '-force' argument, which will overwrite the current variable if already set: setenv -force "FOO" "baz" The force argument corresponds to passing a non-zero third argument to setenv(3). diff --git a/bin/varnishtest/tests/m10027.vtc b/bin/varnishtest/tests/m10027.vtc new file mode 100644 index 0000000..7c6adaa --- /dev/null +++ b/bin/varnishtest/tests/m10027.vtc @@ -0,0 +1,73 @@ +varnishtest "Test setenv" + +setenv FOO "BAR BAZ" + +varnish v1 -vcl { + import ${vmod_std}; + + backend dummy { .host = "${bad_ip}"; .port = "9080"; } + + sub vcl_recv { + return(synth(200)); + } + + sub vcl_synth { + set resp.http.X-FOO = std.getenv("FOO"); + } +} -start + +client c1 { + txreq + rxresp + expect resp.http.X-FOO == "BAR BAZ" +} -run + +varnish v1 -stop + +setenv FOO QUUX + +varnish v2 -vcl { + import ${vmod_std}; + + backend dummy { .host = "${bad_ip}"; .port = "9080"; } + + sub vcl_recv { + return(synth(200)); + } + + sub vcl_synth { + set resp.http.X-FOO = std.getenv("FOO"); + } +} -start + +client c2 -connect ${v2_sock} { + txreq + rxresp + expect resp.http.X-FOO == "BAR BAZ" +} -run + +varnish v2 -stop + +setenv -force FOO QUUX + +varnish v3 -vcl { + import ${vmod_std}; + + backend dummy { .host = "${bad_ip}"; .port = "9080"; } + + sub vcl_recv { + return(synth(200)); + } + + sub vcl_synth { + set resp.http.X-FOO = std.getenv("FOO"); + } +} -start + +client c3 -connect ${v3_sock} { + txreq + rxresp + expect resp.http.X-FOO == "QUUX" +} -run + +varnish v2 -stop diff --git a/bin/varnishtest/vtc.c b/bin/varnishtest/vtc.c index 5532e33..4d75686 100644 --- a/bin/varnishtest/vtc.c +++ b/bin/varnishtest/vtc.c @@ -497,6 +497,38 @@ cmd_err_shell(CMD_ARGS) } /********************************************************************** + * Set environment variables + */ + +static void +cmd_setenv(CMD_ARGS) +{ + int r; + int force; + + (void)priv; + (void)cmd; + + if (av == NULL) + return; + AN(av[1]); + AN(av[2]); + + force = 0; + if (strcmp("-force", av[1]) == 0) { + force = 1; + av++; + AN(av[2]); + } + if (av[3] != NULL) + vtc_log(vl, 0, "CMD setenv: Unexpected argument '%s'", av[3]); + r = setenv(av[1], av[2], force); + if (r != 0) + vtc_log(vl, 0, "CMD setenv %s=\"%s\" failed: %s", + av[1], av[2], strerror(errno)); +} + +/********************************************************************** * Dump command arguments */ @@ -659,6 +691,7 @@ static const struct cmds cmds[] = { { "feature", cmd_feature }, { "logexpect", cmd_logexp }, { "process", cmd_process }, + { "setenv", cmd_setenv }, { NULL, NULL } }; From hermunn at varnish-software.com Thu Apr 6 11:55:05 2017 From: hermunn at varnish-software.com (Pål Hermunn Johansen) Date: Thu, 06 Apr 2017 13:55:05 +0200 Subject: [4.1] 14ce480 Make sure Age is always less than max-age Message-ID: commit 14ce48044a680032adc51244f58dac03c391cea1 Author: Reza Naghibi Date: Wed Feb 15 16:16:07 2017 -0500 Make sure Age is always less than max-age By rounding Age down, we make sure Age < max-age while the object is fresh. Otherwise, we can prematurely get Age == max-age and Varnish will calculate that as a 0s TTL and create a pass scenario. Conflicts: bin/varnishd/cache/cache_req_fsm.c diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 5214c46..cedfe1e 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -154,7 +154,7 @@ cnt_deliver(struct worker *wrk, struct req *req) * age. Truncate to zero in that case). */ http_PrintfHeader(req->resp, "Age: %.0f", - fmax(0., req->t_prev - req->objcore->exp.t_origin)); + floor(fmax(0., req->t_prev - req->objcore->exp.t_origin)); http_SetHeader(req->resp, "Via: 1.1 varnish-v4"); diff --git a/bin/varnishtest/tests/s00006.vtc b/bin/varnishtest/tests/s00006.vtc new file mode 100644 index 0000000..c347e67 --- /dev/null +++ b/bin/varnishtest/tests/s00006.vtc @@ -0,0 +1,30 @@ +varnishtest "Check that Age is always less than max-age while not stale" + +server s1 { + rxreq + expect req.url == "/" + txresp -hdr "Cache-control: max-age=2" +} -start + +varnish v1 -vcl+backend { } -start + +client c1 { + txreq -url "/" + rxresp + expect resp.status == 200 + expect resp.http.Age == 0 + + delay 0.8 + + txreq -url "/" + rxresp + expect resp.status == 200 + expect resp.http.Age == 0 + + delay 1.0 + + txreq -url "/" + rxresp + expect resp.status == 200 + expect resp.http.Age == 1 +} -run From hermunn at varnish-software.com Thu Apr 6 12:05:06 2017 From: hermunn at varnish-software.com (Pål Hermunn Johansen) Date: Thu, 06 Apr 2017 14:05:06 +0200 Subject: [4.1] ca754f5 Forgot to amend previous commit Message-ID: commit ca754f5b6bbb24e7cc4526a2088ff180941503c6 Author: P?l Hermunn Johansen Date: Thu Apr 6 14:02:31 2017 +0200 Forgot to amend previous commit There was a missing bracket that I fixed but forgot to amend the commit. Fixing with this one. diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index cedfe1e..f114284 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -154,7 +154,7 @@ cnt_deliver(struct worker *wrk, struct req *req) * age. Truncate to zero in that case). */ http_PrintfHeader(req->resp, "Age: %.0f", - floor(fmax(0., req->t_prev - req->objcore->exp.t_origin)); + floor(fmax(0., req->t_prev - req->objcore->exp.t_origin))); http_SetHeader(req->resp, "Via: 1.1 varnish-v4"); From martin at varnish-software.com Thu Apr 6 12:56:05 2017 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Thu, 06 Apr 2017 14:56:05 +0200 Subject: [4.1] c8bfb6e Introduce a `vxid` LHS for VSL queries Message-ID: commit c8bfb6e92b3281e3005cf3283454ce52b41c6c3f Author: Dridi Boukelmoune Date: Thu Feb 2 11:04:37 2017 +0100 Introduce a `vxid` LHS for VSL queries It shares a lot of parsing infrastructure with log records, but doesn't support the taglist syntax. Only a verbatim `vxid` token can be used as the LHS, and only integer operators are supported. diff --git a/bin/varnishtest/tests/b00050.vtc b/bin/varnishtest/tests/b00050.vtc new file mode 100644 index 0000000..399df82 --- /dev/null +++ b/bin/varnishtest/tests/b00050.vtc @@ -0,0 +1,61 @@ +varnishtest "VXID log filtering" + +server s1 { + rxreq + txresp +} -start + +varnish v1 -arg "-p thread_pools=1" -vcl+backend { } -start + +logexpect l1 -v v1 -q "vxid == 1001" { + expect 0 1001 Begin "req 1000 rxreq" +} -start + +client c1 { + txreq + rxresp +} -run + +logexpect -wait + +# vxid only supports integer operations + +shell -err -expect "Expected vxid operator got '~'" { + varnishlog -n ${v1_name} -d -q 'vxid ~ 1001' +} + +shell -err -expect "Expected vxid operator got '!~'" { + varnishlog -n ${v1_name} -d -q 'vxid !~ 1001' +} + +shell -err -expect "Expected vxid operator got 'eq'" { + varnishlog -n ${v1_name} -d -q 'vxid eq 1001' +} + +shell -err -expect "Expected vxid operator got 'ne'" { + varnishlog -n ${v1_name} -d -q 'vxid ne 1001' +} + +# vxid only supports integer operands + +shell -err -expect "Expected integer got '1001.5'" { + varnishlog -n ${v1_name} -d -q 'vxid != 1001.5' +} + +# vxid doesn't support taglist selection + +shell -err -expect "Unexpected taglist selection for vxid" { + varnishlog -n ${v1_name} -d -q 'vxid[1] >= 1001' +} + +shell -err -expect "Unexpected taglist selection for vxid" { + varnishlog -n ${v1_name} -d -q '{1}vxid <= 1001' +} + +shell -err -expect "Unexpected taglist selection for vxid" { + varnishlog -n ${v1_name} -d -q 'vxid,Link > 1001' +} + +shell -err -expect "Unexpected taglist selection for vxid" { + varnishlog -n ${v1_name} -d -q 'vxid,vxid < 1001' +} diff --git a/lib/libvarnishapi/generate.py b/lib/libvarnishapi/generate.py index 00205cd..053a1e4 100755 --- a/lib/libvarnishapi/generate.py +++ b/lib/libvarnishapi/generate.py @@ -71,6 +71,7 @@ tokens = { # Special "T_TRUE": None, + "VXID": "vxid", } ####################################################################### diff --git a/lib/libvarnishapi/vsl_query.c b/lib/libvarnishapi/vsl_query.c index 0159429..5f6a84d 100644 --- a/lib/libvarnishapi/vsl_query.c +++ b/lib/libvarnishapi/vsl_query.c @@ -74,6 +74,48 @@ struct vslq_query { } static int +vslq_test_vxid(const struct vex *vex, const struct VSL_transaction *trans) +{ + const struct vex_rhs *rhs; + + AN(vex); + AN(trans); + + rhs = vex->rhs; + CHECK_OBJ_NOTNULL(rhs, VEX_RHS_MAGIC); + + /* Prepare */ + switch (vex->tok) { + case T_EQ: /* == */ + case T_NEQ: /* != */ + case '<': + case '>': + case T_LEQ: /* <= */ + case T_GEQ: /* >= */ + if (rhs->type != VEX_INT) + WRONG("Wrong RHS type for vxid"); + /* FALLTHROUGH */ + default: + break; + } + + /* Compare */ + switch (vex->tok) { + #define VXID_TEST_NUMOP(OP) return (trans->vxid OP rhs->val_int); + case T_EQ: VXID_TEST_NUMOP(==); + case T_NEQ: VXID_TEST_NUMOP(!=); + case '<': VXID_TEST_NUMOP(<); + case '>': VXID_TEST_NUMOP(>); + case T_LEQ: VXID_TEST_NUMOP(<=); + case T_GEQ: VXID_TEST_NUMOP(>=); + #undef VXID_TEST_NUMOP + default: WRONG("Bad vxid expression token"); + } + + NEEDLESS(return (0)); +} + +static int vslq_test_rec(const struct vex *vex, const struct VSLC_ptr *rec) { const struct vex_rhs *rhs; @@ -226,6 +268,17 @@ vslq_test(const struct vex *vex, struct VSL_transaction * const ptrans[]) CHECK_OBJ_NOTNULL(vex, VEX_MAGIC); CHECK_OBJ_NOTNULL(vex->lhs, VEX_LHS_MAGIC); AN(vex->lhs->tags); + assert(vex->lhs->vxid <= 1); + + if (vex->lhs->vxid) { + AZ(vex->lhs->taglist); + for (t = ptrans[0]; t != NULL; t = *++ptrans) + if (vslq_test_vxid(vex, t)) + return (1); + return (0); + } + + AN(vex->lhs->taglist); for (t = ptrans[0]; t != NULL; t = *++ptrans) { if (vex->lhs->level >= 0) { diff --git a/lib/libvarnishapi/vxp.h b/lib/libvarnishapi/vxp.h index afed0d0..c7a0981 100644 --- a/lib/libvarnishapi/vxp.h +++ b/lib/libvarnishapi/vxp.h @@ -86,6 +86,8 @@ struct vex_lhs { int field; int level; int level_pm; + unsigned taglist; + unsigned vxid; }; enum vex_rhs_e { diff --git a/lib/libvarnishapi/vxp_parse.c b/lib/libvarnishapi/vxp_parse.c index 7ec8865..0e32afc 100644 --- a/lib/libvarnishapi/vxp_parse.c +++ b/lib/libvarnishapi/vxp_parse.c @@ -112,14 +112,19 @@ vxp_expr_lhs(struct vxp *vxp, struct vex_lhs **plhs) while (1) { /* The tags this expression applies to */ - if (vxp->t->tok != VAL) { + if (vxp->t->tok == VXID) { + (*plhs)->vxid++; + i = 0; + } else if (vxp->t->tok != VAL) { VSB_printf(vxp->sb, "Expected VSL tag name got '%.*s' ", PF(vxp->t)); vxp_ErrWhere(vxp, vxp->t, -1); return; + } else { + (*plhs)->taglist++; + i = VSL_Glob2Tags(vxp->t->dec, -1, vsl_vbm_bitset, + (*plhs)->tags); } - i = VSL_Glob2Tags(vxp->t->dec, -1, vsl_vbm_bitset, - (*plhs)->tags); if (i == -1) { VSB_printf(vxp->sb, "Tag name matches zero tags "); vxp_ErrWhere(vxp, vxp->t, -1); @@ -135,7 +140,7 @@ vxp_expr_lhs(struct vxp *vxp, struct vex_lhs **plhs) vxp_ErrWhere(vxp, vxp->t, -1); return; } - assert(i > 0); + assert(i > 0 || vxp->t->tok == VXID); vxp_NextToken(vxp); if (vxp->t->tok != ',') break; @@ -177,10 +182,20 @@ vxp_expr_lhs(struct vxp *vxp, struct vex_lhs **plhs) ExpectErr(vxp, ']'); vxp_NextToken(vxp); } + + if ((*plhs)->vxid == 0) + return; + + if ((*plhs)->vxid > 1 || (*plhs)->level >= 0 || + (*plhs)->field > 0 || (*plhs)->prefixlen > 0 || + (*plhs)->taglist > 0) { + VSB_printf(vxp->sb, "Unexpected taglist selection for vxid "); + vxp_ErrWhere(vxp, vxp->t, -1); + } } static void -vxp_expr_num(struct vxp *vxp, struct vex_rhs **prhs) +vxp_expr_num(struct vxp *vxp, struct vex_rhs **prhs, int vxid) { char *endptr; @@ -213,6 +228,12 @@ vxp_expr_num(struct vxp *vxp, struct vex_rhs **prhs) return; } } + if (vxid && (*prhs)->type != VEX_INT) { + VSB_printf(vxp->sb, "Expected integer got '%.*s' ", + PF(vxp->t)); + vxp_ErrWhere(vxp, vxp->t, 0); + return; + } vxp_NextToken(vxp); } @@ -269,6 +290,28 @@ vxp_expr_regex(struct vxp *vxp, struct vex_rhs **prhs) vxp_NextToken(vxp); } +static void +vxp_vxid_cmp(struct vxp *vxp) +{ + + switch (vxp->t->tok) { + /* Valid operators */ + case T_EQ: /* == */ + case '<': /* < */ + case '>': /* > */ + case T_GEQ: /* >= */ + case T_LEQ: /* <= */ + case T_NEQ: /* != */ + break; + + /* Error */ + default: + VSB_printf(vxp->sb, "Expected vxid operator got '%.*s' ", + PF(vxp->t)); + vxp_ErrWhere(vxp, vxp->t, -1); + } +} + /* * SYNTAX: * expr_cmp: @@ -287,6 +330,11 @@ vxp_expr_cmp(struct vxp *vxp, struct vex **pvex) vxp_expr_lhs(vxp, &(*pvex)->lhs); ERRCHK(vxp); + if ((*pvex)->lhs->vxid) { + vxp_vxid_cmp(vxp); + ERRCHK(vxp); + } + /* Test operator */ switch (vxp->t->tok) { @@ -333,7 +381,7 @@ vxp_expr_cmp(struct vxp *vxp, struct vex **pvex) case T_GEQ: /* >= */ case T_LEQ: /* <= */ case T_NEQ: /* != */ - vxp_expr_num(vxp, &(*pvex)->rhs); + vxp_expr_num(vxp, &(*pvex)->rhs, (*pvex)->lhs->vxid); break; case T_SEQ: /* eq */ case T_SNEQ: /* ne */ From martin at varnish-software.com Thu Apr 6 12:56:05 2017 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Thu, 06 Apr 2017 14:56:05 +0200 Subject: [4.1] 36d4863 Use code litterals for the grouping modes Message-ID: commit 36d4863d430b951d9256645982c2b89cec1b5c0e Author: Dridi Boukelmoune Date: Thu Feb 23 14:08:49 2017 +0100 Use code litterals for the grouping modes diff --git a/doc/sphinx/reference/vsl-query.rst b/doc/sphinx/reference/vsl-query.rst index 8f72a07..8f47156 100644 --- a/doc/sphinx/reference/vsl-query.rst +++ b/doc/sphinx/reference/vsl-query.rst @@ -46,7 +46,7 @@ be 0. The grouping modes are: -* Session +* ``session`` All transactions initiated by a client connection are reported together. Client connections are open ended when using HTTP @@ -55,21 +55,21 @@ The grouping modes are: incomplete session will be reported. Non-transactional data (vxid == 0) is not reported. -* Request +* ``request`` Transactions are grouped by request, where the set will include the request itself as well as any backend requests or ESI-subrequests. Session data and non-transactional data (vxid == 0) is not reported. -* VXID +* ``vxid`` Transactions are not grouped, so each vxid is reported in it's entirety. Sessions, requests, ESI-requests and backend requests are all reported individually. Non-transactional data is not reported (vxid == 0). This is the default. -* Raw +* ``raw`` Every log record will make up a transaction of it's own. All data, including non-transactional data will be reported. From martin at varnish-software.com Thu Apr 6 12:56:05 2017 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Thu, 06 Apr 2017 14:56:05 +0200 Subject: [4.1] cfc29b3 Document vxid VSL queries Message-ID: commit cfc29b32a5c2839734e432a843d7390555c0add7 Author: Dridi Boukelmoune Date: Thu Feb 23 14:45:18 2017 +0100 Document vxid VSL queries diff --git a/doc/sphinx/reference/vsl-query.rst b/doc/sphinx/reference/vsl-query.rst index 8f47156..a91d404 100644 --- a/doc/sphinx/reference/vsl-query.rst +++ b/doc/sphinx/reference/vsl-query.rst @@ -30,6 +30,8 @@ A query is run on a group of transactions. A query expression is true if there is a log record within the group that satisfies the condition. It is false only if none of the log records satisfies the condition. Query expressions can be combined using boolean functions. +In addition to log records, it is possible to query transaction ids +(vxid) in query. GROUPING ======== @@ -119,6 +121,16 @@ records. :: +Additionally, a query expression can occur on the transaction +itself rather than log records belonging to the transaction. :: + + vxid + +A ``vxid`` query allows you to directly target a specific transacion, +whose id can be obtained from an ``X-Varnish`` HTTP header, the +default "guru meditation" error page, or ``Begin`` and ``Link`` log +records. + Record selection criteria ------------------------- @@ -273,6 +285,10 @@ QUERY EXPRESSION EXAMPLES BerespStatus >= 500 or {2+}Timestamp:Process[2] > 1. +* Log non-transactional errors. (Assumes raw grouping mode). :: + + vxid == 0 and Error + HISTORY ======= From martin at varnish-software.com Thu Apr 6 12:56:05 2017 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Thu, 06 Apr 2017 14:56:05 +0200 Subject: [4.1] d79d215 Move from NEEDLESS back to NEEDLESS_RETURN Message-ID: commit d79d215826b392d6209b7cba9a704e3288e369b7 Author: Dridi Boukelmoune Date: Wed Mar 8 13:39:58 2017 +0100 Move from NEEDLESS back to NEEDLESS_RETURN diff --git a/lib/libvarnishapi/vsl_query.c b/lib/libvarnishapi/vsl_query.c index 5f6a84d..bd7f9a4 100644 --- a/lib/libvarnishapi/vsl_query.c +++ b/lib/libvarnishapi/vsl_query.c @@ -112,7 +112,7 @@ vslq_test_vxid(const struct vex *vex, const struct VSL_transaction *trans) default: WRONG("Bad vxid expression token"); } - NEEDLESS(return (0)); + NEEDLESS_RETURN(0); } static int From martin at varnish-software.com Thu Apr 6 12:56:05 2017 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Thu, 06 Apr 2017 14:56:05 +0200 Subject: [4.1] 96edffd Missing logexpect name Message-ID: commit 96edffd49b9bd285643e3a144033e893e2a7d7bd Author: Dridi Boukelmoune Date: Wed Mar 8 13:59:30 2017 +0100 Missing logexpect name diff --git a/bin/varnishtest/tests/b00050.vtc b/bin/varnishtest/tests/b00050.vtc index 399df82..ef9918b 100644 --- a/bin/varnishtest/tests/b00050.vtc +++ b/bin/varnishtest/tests/b00050.vtc @@ -16,7 +16,7 @@ client c1 { rxresp } -run -logexpect -wait +logexpect l1 -wait # vxid only supports integer operations From martin at varnish-software.com Thu Apr 6 12:56:05 2017 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Thu, 06 Apr 2017 14:56:05 +0200 Subject: [4.1] 5e88d78 Back-port b00050.vtc to 4.1 Message-ID: commit 5e88d78ad28b5fd5d0a115dda2a335abe75d9e63 Author: Dridi Boukelmoune Date: Wed Mar 8 14:27:32 2017 +0100 Back-port b00050.vtc to 4.1 diff --git a/bin/varnishtest/tests/b00050.vtc b/bin/varnishtest/tests/b00050.vtc index ef9918b..9c4705c 100644 --- a/bin/varnishtest/tests/b00050.vtc +++ b/bin/varnishtest/tests/b00050.vtc @@ -20,42 +20,42 @@ logexpect l1 -wait # vxid only supports integer operations -shell -err -expect "Expected vxid operator got '~'" { - varnishlog -n ${v1_name} -d -q 'vxid ~ 1001' +err_shell "Expected vxid operator got '~'" { + varnishlog -n ${v1_name} -d -q 'vxid ~ 1001' 2>&1 } -shell -err -expect "Expected vxid operator got '!~'" { - varnishlog -n ${v1_name} -d -q 'vxid !~ 1001' +err_shell "Expected vxid operator got '!~'" { + varnishlog -n ${v1_name} -d -q 'vxid !~ 1001' 2>&1 } -shell -err -expect "Expected vxid operator got 'eq'" { - varnishlog -n ${v1_name} -d -q 'vxid eq 1001' +err_shell "Expected vxid operator got 'eq'" { + varnishlog -n ${v1_name} -d -q 'vxid eq 1001' 2>&1 } -shell -err -expect "Expected vxid operator got 'ne'" { - varnishlog -n ${v1_name} -d -q 'vxid ne 1001' +err_shell "Expected vxid operator got 'ne'" { + varnishlog -n ${v1_name} -d -q 'vxid ne 1001' 2>&1 } # vxid only supports integer operands -shell -err -expect "Expected integer got '1001.5'" { - varnishlog -n ${v1_name} -d -q 'vxid != 1001.5' +err_shell "Expected integer got '1001.5'" { + varnishlog -n ${v1_name} -d -q 'vxid != 1001.5' 2>&1 } # vxid doesn't support taglist selection -shell -err -expect "Unexpected taglist selection for vxid" { - varnishlog -n ${v1_name} -d -q 'vxid[1] >= 1001' +err_shell "Unexpected taglist selection for vxid" { + varnishlog -n ${v1_name} -d -q 'vxid[1] >= 1001' 2>&1 } -shell -err -expect "Unexpected taglist selection for vxid" { - varnishlog -n ${v1_name} -d -q '{1}vxid <= 1001' +err_shell "Unexpected taglist selection for vxid" { + varnishlog -n ${v1_name} -d -q '{1}vxid <= 1001' 2>&1 } -shell -err -expect "Unexpected taglist selection for vxid" { - varnishlog -n ${v1_name} -d -q 'vxid,Link > 1001' +err_shell "Unexpected taglist selection for vxid" { + varnishlog -n ${v1_name} -d -q 'vxid,Link > 1001' 2>&1 } -shell -err -expect "Unexpected taglist selection for vxid" { - varnishlog -n ${v1_name} -d -q 'vxid,vxid < 1001' +err_shell "Unexpected taglist selection for vxid" { + varnishlog -n ${v1_name} -d -q 'vxid,vxid < 1001' 2>&1 } From martin at varnish-software.com Thu Apr 6 12:56:05 2017 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Thu, 06 Apr 2017 14:56:05 +0200 Subject: [4.1] d648f9c Start the 4.1.6 changelog Message-ID: commit d648f9c03f2aab1c237d2e83431f9a540e32cc5f Author: Martin Blix Grydeland Date: Thu Apr 6 14:53:10 2017 +0200 Start the 4.1.6 changelog diff --git a/doc/changes.rst b/doc/changes.rst index f1166fd..9c91baf 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -1,3 +1,10 @@ +====================================== +Varnish Cache 4.1.6-beta1 (unreleased) +====================================== + +* Introduce a vxid left hand side for VSL queries. This allows + matching on records matching a known vxid. + ================================ Varnish Cache 4.1.5 (2017-02-09) ================================ From phk at FreeBSD.org Thu Apr 6 13:46:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 06 Apr 2017 15:46:05 +0200 Subject: [master] b2ff51b Remove this http_Teardown() entirely, it doesn't belong here. Message-ID: commit b2ff51b0680d59091632179e9091b8bf90026194 Author: Poul-Henning Kamp Date: Thu Apr 6 13:44:34 2017 +0000 Remove this http_Teardown() entirely, it doesn't belong here. diff --git a/bin/varnishd/http2/cache_http2_hpack.c b/bin/varnishd/http2/cache_http2_hpack.c index a7fe43d..460b43f 100644 --- a/bin/varnishd/http2/cache_http2_hpack.c +++ b/bin/varnishd/http2/cache_http2_hpack.c @@ -308,7 +308,6 @@ h2h_decode_bytes(struct h2_sess *h2, struct h2h_decode *d, d->out = d->reset; d->out_l = hp->ws->r - d->out; d->out_u = 0; - http_Teardown(hp); assert(d->out_u < d->out_l); } else if (d->error) break; From phk at FreeBSD.org Thu Apr 6 13:46:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 06 Apr 2017 15:46:05 +0200 Subject: [master] 308843a Don't attept return(pipe) on HTTP/2 requests, pass with a VSL message. Message-ID: commit 308843aaf8b67eee4a53889bca31aa319fd2f2f1 Author: Poul-Henning Kamp Date: Thu Apr 6 13:45:02 2017 +0000 Don't attept return(pipe) on HTTP/2 requests, pass with a VSL message. diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 1320e81..cdd443f 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -864,15 +864,20 @@ cnt_recv(struct worker *wrk, struct req *req) req->req_step = R_STP_LOOKUP; return (REQ_FSM_MORE); case VCL_RET_PIPE: - if (req->esi_level == 0) { + if (req->esi_level > 0) { + VSLb(req->vsl, SLT_VCL_Error, + "vcl_recv{} returns pipe for ESI included object." + " Doing pass."); + req->req_step = R_STP_PASS; + } else if (req->http0->protover > 11) { + VSLb(req->vsl, SLT_VCL_Error, + "vcl_recv{} returns pipe for HTTP/2 request." + " Doing pass."); + req->req_step = R_STP_PASS; + } else { req->req_step = R_STP_PIPE; - return (REQ_FSM_MORE); } - VSLb(req->vsl, SLT_VCL_Error, - "vcl_recv{} returns pipe for ESI included object." - " Doing pass."); - req->req_step = R_STP_PASS; - return (REQ_FSM_DONE); + return (REQ_FSM_MORE); case VCL_RET_PASS: req->req_step = R_STP_PASS; return (REQ_FSM_MORE); diff --git a/bin/varnishtest/tests/t02000.vtc b/bin/varnishtest/tests/t02000.vtc index 6eb9ff8..3be9e17 100644 --- a/bin/varnishtest/tests/t02000.vtc +++ b/bin/varnishtest/tests/t02000.vtc @@ -9,7 +9,11 @@ server s1 { -bodylen 10 } -start -varnish v1 -vcl+backend {} -start +varnish v1 -vcl+backend { + sub vcl_recv { + return (pipe); + } +} -start varnish v1 -cliok "param.set debug +syncvsl" From phk at FreeBSD.org Thu Apr 6 19:46:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 06 Apr 2017 21:46:05 +0200 Subject: [master] e1e7e76 Putter around with a featherduster: Message-ID: commit e1e7e764bd8c53900a204551c8123971b778e85f Author: Poul-Henning Kamp Date: Thu Apr 6 19:45:06 2017 +0000 Putter around with a featherduster: Remove forgotten debugging VSL. Renovate a VCL comment. diff --git a/bin/varnishd/builtin.vcl b/bin/varnishd/builtin.vcl index 14c7955..4e74948 100644 --- a/bin/varnishd/builtin.vcl +++ b/bin/varnishd/builtin.vcl @@ -36,7 +36,7 @@ vcl 4.0; sub vcl_recv { if (req.method == "PRI") { - /* We do not support SPDY or HTTP/2.0 */ + /* This will never happen in properly formed traffic (see: RFC7540) */ return (synth(405)); } if (req.method != "GET" && diff --git a/bin/varnishd/http1/cache_http1_deliver.c b/bin/varnishd/http1/cache_http1_deliver.c index 3f19bdf..e6a6845 100644 --- a/bin/varnishd/http1/cache_http1_deliver.c +++ b/bin/varnishd/http1/cache_http1_deliver.c @@ -99,8 +99,6 @@ V1D_Deliver(struct req *req, struct boc *boc, int sendbody) } } - VSLb(req->vsl, SLT_Debug, "RES_MODE %x", req->res_mode); - if (!req->doclose && http_HdrIs(req->resp, H_Connection, "close")) { req->doclose = SC_RESP_CLOSE; } else if (req->doclose) { diff --git a/bin/varnishd/http2/cache_http2_deliver.c b/bin/varnishd/http2/cache_http2_deliver.c index f9463ef..a9d4ad5 100644 --- a/bin/varnishd/http2/cache_http2_deliver.c +++ b/bin/varnishd/http2/cache_http2_deliver.c @@ -193,8 +193,6 @@ h2_deliver(struct req *req, struct boc *boc, int sendbody) sp = req->sp; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); - VSLb(req->vsl, SLT_Debug, "H2: Deliver"); - (void)WS_Reserve(req->ws, 0); p = (void*)req->ws->f; From phk at FreeBSD.org Fri Apr 7 07:14:06 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 07 Apr 2017 09:14:06 +0200 Subject: [master] cd54c18 Summarize changes for 5.1.2 Message-ID: commit cd54c184d40d221ec79c5aa7c4a089a9bdbc03b1 Author: Poul-Henning Kamp Date: Fri Apr 7 07:13:20 2017 +0000 Summarize changes for 5.1.2 diff --git a/doc/changes.rst b/doc/changes.rst index 2546c4d..41d83d0 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -1,4 +1,26 @@ ================================ +Varnish Cache 5.1.2 (2017-04-07) +================================ + +* Fix an endless loop in Backend Polling (#2295) + +* Fix a Chunked bug in tight workspaces (#2207, #2275) + +* Fix a bug relating to req.body when on waitinglist (#2266) + +* Handle EPIPE on broken TCP connections (#2267) + +* Work around the x86 arch's turbo-double FP format in parameter + setup code. (#1875) + +* Fix race related to backend probe with proxy header (#2278) + +* Keep VCL temperature consistent between mgt/worker also when + worker protests. + +* A lot of HTTP/2 fixes. + +================================ Varnish Cache 5.1.1 (2017-03-16) ================================ From phk at FreeBSD.org Fri Apr 7 07:25:06 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 07 Apr 2017 09:25:06 +0200 Subject: [master] a575331 Ignore DATA received after stream closed Message-ID: commit a575331d6043c7dbaf5ed9aa850e8619bf42aad4 Author: Poul-Henning Kamp Date: Fri Apr 7 07:20:20 2017 +0000 Ignore DATA received after stream closed Fixes #2304 diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index 1083d0e..a44d05b 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -636,8 +636,9 @@ h2_rx_data(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) unsigned wi; (void)wrk; - AN(r2); ASSERT_RXTHR(h2); + if (r2 == NULL) + return (0); Lck_Lock(&h2->sess->mtx); AZ(h2->mailcall); h2->mailcall = r2; diff --git a/bin/varnishtest/tests/t02003.vtc b/bin/varnishtest/tests/t02003.vtc index db5fb31..2f32a51 100644 --- a/bin/varnishtest/tests/t02003.vtc +++ b/bin/varnishtest/tests/t02003.vtc @@ -417,3 +417,35 @@ varnish v1 -expect MEMPOOL.req1.live == 0 varnish v1 -expect MEMPOOL.sess0.live == 0 varnish v1 -expect MEMPOOL.sess1.live == 0 +####################################################################### +# Test DATA error conditions + +client c1 { + stream 1 { + txdata -data "FOOBAR" + } -run + stream 0 { + rxgoaway + } -run + expect_close +} -run + +client c1 { + stream 1 { + txreq + rxresp + txdata -data "FOOBAR" + } -run + stream 3 { + txreq + rxresp + } -run +} -run + +varnish v1 -vsl_catchup + +varnish v1 -expect MEMPOOL.req0.live == 0 +varnish v1 -expect MEMPOOL.req1.live == 0 +varnish v1 -expect MEMPOOL.sess0.live == 0 +varnish v1 -expect MEMPOOL.sess1.live == 0 + From phk at FreeBSD.org Fri Apr 7 07:46:06 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 07 Apr 2017 09:46:06 +0200 Subject: [master] 6e58e28 Don't send both c-l and chunked to backend for h2. Message-ID: commit 6e58e283a4415f6bc005299c2d6230fa81295bf2 Author: Poul-Henning Kamp Date: Fri Apr 7 07:45:11 2017 +0000 Don't send both c-l and chunked to backend for h2. Fixes #2247 diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index a44d05b..87dca6e 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -473,6 +473,7 @@ h2_do_req(struct worker *wrk, void *priv) { struct req *req; struct h2_req *r2; + const char *b; CAST_OBJ_NOTNULL(req, priv, REQ_MAGIC); CAST_OBJ_NOTNULL(r2, req->transport_priv, H2_REQ_MAGIC); @@ -483,6 +484,15 @@ h2_do_req(struct worker *wrk, void *priv) // XXX: Have I mentioned H/2 Is hodge-podge ? http_CollectHdrSep(req->http, H_Cookie, "; "); // rfc7540,l,3114,3120 + if (req->req_body_status == REQ_BODY_INIT) { + if (!http_GetHdr(req->http, H_Content_Length, &b)) + req->req_body_status = REQ_BODY_WITHOUT_LEN; + else + req->req_body_status = REQ_BODY_WITH_LEN; + } else { + assert (req->req_body_status == REQ_BODY_NONE); + } + req->http->conds = 1; if (CNT_Request(wrk, req) != REQ_FSM_DISEMBARK) { AZ(req->ws->r); @@ -517,8 +527,6 @@ h2_end_headers(struct worker *wrk, const struct h2_sess *h2, if (h2->rxf_flags & H2FF_HEADERS_END_STREAM) req->req_body_status = REQ_BODY_NONE; - else - req->req_body_status = REQ_BODY_WITHOUT_LEN; req->req_step = R_STP_TRANSPORT; req->task.func = h2_do_req; diff --git a/bin/varnishtest/tests/t02005.vtc b/bin/varnishtest/tests/t02005.vtc index 31be89b..81ad091 100644 --- a/bin/varnishtest/tests/t02005.vtc +++ b/bin/varnishtest/tests/t02005.vtc @@ -4,6 +4,8 @@ barrier b1 cond 2 server s1 { rxreq + expect req.http.content-length == 7 + expect req.http.transfer-encoding == barrier b1 sync txresp -hdr "Content-Type: text/plain" -body response } -start diff --git a/bin/varnishtest/tests/t02006.vtc b/bin/varnishtest/tests/t02006.vtc index 31a5fbf..30e4ac8 100644 --- a/bin/varnishtest/tests/t02006.vtc +++ b/bin/varnishtest/tests/t02006.vtc @@ -4,6 +4,8 @@ barrier b1 cond 2 server s1 { rxreq + expect req.http.content-length == + expect req.http.transfer-encoding == chunked expect req.proto == HTTP/1.1 barrier b1 sync txresp -hdr "Content-Type: text/plain" -body response @@ -21,7 +23,6 @@ client c1 { -nohdrend txcont \ -hdr expect 100-continue \ - -hdr content-length 7 \ -nostrend rxhdrs From hermunn at varnish-software.com Fri Apr 7 11:27:05 2017 From: hermunn at varnish-software.com (Pål Hermunn Johansen) Date: Fri, 07 Apr 2017 13:27:05 +0200 Subject: [master] 6ece695 Prepare for 5.1.2 final Message-ID: commit 6ece695868b71d47c5a3619e18c3b18792bfe149 Author: P?l Hermunn Johansen Date: Fri Apr 7 13:18:26 2017 +0200 Prepare for 5.1.2 final diff --git a/configure.ac b/configure.ac index 7aaf658..4f9b4f2 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ AC_PREREQ(2.59) AC_COPYRIGHT([Copyright (c) 2006 Verdens Gang AS Copyright (c) 2006-2017 Varnish Software]) AC_REVISION([$Id$]) -AC_INIT([Varnish], [5.1.1], [varnish-dev at varnish-cache.org]) +AC_INIT([Varnish], [5.1.2], [varnish-dev at varnish-cache.org]) AC_CONFIG_SRCDIR(include/miniobj.h) AC_CONFIG_HEADERS([config.h]) AC_CONFIG_MACRO_DIR([m4]) From hermunn at varnish-software.com Fri Apr 7 11:58:06 2017 From: hermunn at varnish-software.com (Pål Hermunn Johansen) Date: Fri, 07 Apr 2017 13:58:06 +0200 Subject: [4.1] 29779c9 Update changelog Message-ID: commit 29779c9ce5569181ed1325a1e1f7b7a6402da212 Author: P?l Hermunn Johansen Date: Fri Apr 7 12:45:40 2017 +0200 Update changelog diff --git a/doc/changes.rst b/doc/changes.rst index 9c91baf..5422367 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -4,6 +4,29 @@ Varnish Cache 4.1.6-beta1 (unreleased) * Introduce a vxid left hand side for VSL queries. This allows matching on records matching a known vxid. +* Environment variables are now available in the stdandard VMOD; + std.getenv() +* Add setenv command to varnishtest + + +Bugs fixed +---------- +* 2200_ - Dramatically simplify VEV, fix assert in vev.c +* 2216_ - Make sure Age is always less than max-age +* 2233_ - Correct check when parsing the query string +* 2241_ - VSL fails to get hold of SHM +* 2270_ - Newly loaded auto VCLs don't get their go_cold timer set +* 2273_ - Master cooling problem +* 2295_ - Spinning loop in VBE_Poll causes master to kill child on + CLI timeout + +.. _2200: https://github.com/varnishcache/varnish-cache/issues/2200 +.. _2216: https://github.com/varnishcache/varnish-cache/pull/2216 +.. _2233: https://github.com/varnishcache/varnish-cache/issues/2233 +.. _2241: https://github.com/varnishcache/varnish-cache/issues/2241 +.. _2270: https://github.com/varnishcache/varnish-cache/issues/2270 +.. _2273: https://github.com/varnishcache/varnish-cache/pull/2273 +.. _2295: https://github.com/varnishcache/varnish-cache/issues/2295 ================================ Varnish Cache 4.1.5 (2017-02-09) From phk at FreeBSD.org Fri Apr 7 16:28:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 07 Apr 2017 18:28:05 +0200 Subject: [master] 62d9622 Don't attempt to check if varnishd is still running if we have already failed. Message-ID: commit 62d96228556f15cc63b560f9ef34f70a7ab0e4cc Author: Poul-Henning Kamp Date: Fri Apr 7 16:23:06 2017 +0000 Don't attempt to check if varnishd is still running if we have already failed. Fixes #2301 diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c index 31ab631..22b0307 100644 --- a/bin/varnishtest/vtc_varnish.c +++ b/bin/varnishtest/vtc_varnish.c @@ -663,8 +663,10 @@ varnish_wait(struct varnish *v) vtc_log(v->vl, 2, "Wait"); - /* Do a backend.list to log if child is still running */ - varnish_ask_cli(v, "backend.list", &resp); + if (!vtc_error) { + /* Do a backend.list to log if child is still running */ + varnish_ask_cli(v, "backend.list", &resp); + } /* Then stop it */ varnish_stop(v); From phk at FreeBSD.org Fri Apr 7 22:25:06 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Sat, 08 Apr 2017 00:25:06 +0200 Subject: [master] a90be95 We're back to being trunk now, but still in code slush for a couple of days ... just in case. Message-ID: commit a90be95f2ab79f8c4ca9309e7a39c2e52df67f95 Author: Poul-Henning Kamp Date: Fri Apr 7 21:40:32 2017 +0000 We're back to being trunk now, but still in code slush for a couple of days ... just in case. diff --git a/configure.ac b/configure.ac index 4f9b4f2..d556c23 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ AC_PREREQ(2.59) AC_COPYRIGHT([Copyright (c) 2006 Verdens Gang AS Copyright (c) 2006-2017 Varnish Software]) AC_REVISION([$Id$]) -AC_INIT([Varnish], [5.1.2], [varnish-dev at varnish-cache.org]) +AC_INIT([Varnish], [trunk], [varnish-dev at varnish-cache.org]) AC_CONFIG_SRCDIR(include/miniobj.h) AC_CONFIG_HEADERS([config.h]) AC_CONFIG_MACRO_DIR([m4]) From fgsch at lodoss.net Sun Apr 9 02:41:05 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sun, 09 Apr 2017 04:41:05 +0200 Subject: [master] ad19df6 Don't use ws when returning the fallback value Message-ID: commit ad19df6a0c8d65a1045563b90f76bd4fad0e7326 Author: Federico G. Schwindt Date: Sun Apr 9 11:36:39 2017 +0900 Don't use ws when returning the fallback value diff --git a/lib/libvmod_std/vmod_std_conversions.c b/lib/libvmod_std/vmod_std_conversions.c index 7fb736c..24dd571 100644 --- a/lib/libvmod_std/vmod_std_conversions.c +++ b/lib/libvmod_std/vmod_std_conversions.c @@ -125,7 +125,7 @@ vmod_ip(VRT_CTX, VCL_STRING s, VCL_IP d) const struct addrinfo *res; int error; void *p; - struct suckaddr *r; + const struct suckaddr *r; CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); AN(d); @@ -135,7 +135,7 @@ vmod_ip(VRT_CTX, VCL_STRING s, VCL_IP d) if (p == NULL) { VSLb(ctx->vsl, SLT_VCL_Error, "vmod std.ip(): insufficient workspace"); - return d; + return (d); } r = NULL; @@ -153,8 +153,8 @@ vmod_ip(VRT_CTX, VCL_STRING s, VCL_IP d) } } if (r == NULL) { - r = p; - memcpy(r, d, vsa_suckaddr_len); + WS_Reset(ctx->ws, (uintptr_t)p); + r = d; } if (res0 != NULL) freeaddrinfo(res0); From fgsch at lodoss.net Sun Apr 9 02:41:05 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sun, 09 Apr 2017 04:41:05 +0200 Subject: [master] 3c77f50 Log what we actually tried to use Message-ID: commit 3c77f500e06859063f0e28ab595d6452fc799b5f Author: Federico G. Schwindt Date: Sun Apr 9 11:38:56 2017 +0900 Log what we actually tried to use diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c index d18ca52..62d98bd 100644 --- a/bin/varnishd/cache/cache_http.c +++ b/bin/varnishd/cache/cache_http.c @@ -1210,8 +1210,9 @@ http_PrintfHeader(struct http *to, const char *fmt, ...) va_end(ap); if (n + 1 >= l || to->nhd >= to->shd) { http_fail(to); - VSLb(to->vsl, SLT_LostHeader, "%s", - n + 1 >= l ? fmt : to->ws->f); + va_start(ap, fmt); + VSLbv(to->vsl, SLT_LostHeader, fmt, ap); + va_end(ap); WS_Release(to->ws, 0); return; } From dridi.boukelmoune at gmail.com Mon Apr 10 11:39:05 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 10 Apr 2017 13:39:05 +0200 Subject: [master] 997e6c8 Bump VRT to 6.1 Message-ID: commit 997e6c8a164a1ec9afafef6c40ff463cebfadc85 Author: Dridi Boukelmoune Date: Mon Apr 10 13:35:47 2017 +0200 Bump VRT to 6.1 It should have been done for 5.1.2 but hasn't. This is a minor bump of a single addition so the impact is limited. I also left the release date to "unreleased" on purpose, since it technically hasn't been released as 6.1 yet. diff --git a/include/vrt.h b/include/vrt.h index 625bc36..b8377f3 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -67,7 +67,7 @@ #define VRT_MAJOR_VERSION 6U -#define VRT_MINOR_VERSION 0U +#define VRT_MINOR_VERSION 1U /***********************************************************************/ From phk at FreeBSD.org Mon Apr 10 11:59:04 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 10 Apr 2017 13:59:04 +0200 Subject: [5.1] d87dcf1 This assert will not hold in all error situations. Message-ID: commit d87dcf17d367c3db62c7ee56f61c57b45dce8fc8 Author: Poul-Henning Kamp Date: Mon Mar 20 08:41:03 2017 +0000 This assert will not hold in all error situations. diff --git a/bin/varnishtest/vtc_http2.c b/bin/varnishtest/vtc_http2.c index b472d81..bef8689 100644 --- a/bin/varnishtest/vtc_http2.c +++ b/bin/varnishtest/vtc_http2.c @@ -836,7 +836,7 @@ receive_frame(void *priv) continue; } AZ(pthread_mutex_unlock(&hp->mtx)); - AZ(vsb); + assert(vtc_error || vsb == NULL); return (NULL); } From phk at FreeBSD.org Mon Apr 10 11:59:04 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 10 Apr 2017 13:59:04 +0200 Subject: [5.1] 29db5c9 Add a H1 testcase which exercises the single like of code which triggers this bug for H2. (H2 will be added to the testcase as part of the fix.) Message-ID: commit 29db5c9a92493ae6553f5cce37c04a2a625e96cd Author: Poul-Henning Kamp Date: Tue Mar 21 12:24:48 2017 +0000 Add a H1 testcase which exercises the single like of code which triggers this bug for H2. (H2 will be added to the testcase as part of the fix.) diff --git a/bin/varnishtest/tests/r02258.vtc b/bin/varnishtest/tests/r02258.vtc new file mode 100644 index 0000000..ab2fac3 --- /dev/null +++ b/bin/varnishtest/tests/r02258.vtc @@ -0,0 +1,24 @@ +varnishtest "Streaming range premature finish" + +server s1 { + non_fatal + rxreq + txresp -nolen -hdr "Content-length: 9" + delay 1 + send "BLA" + delay .4 + send "BLA" + delay .3 + send "BL" +} -start + +varnish v1 -vcl+backend { } -start + +client c1 { + txreq -hdr "range: bytes=0-16" + rxresp -no_obj + expect resp.status == 206 + expect resp.http.content-length == 9 + recv 8 + expect_close +} -run From nils.goroll at uplex.de Mon Apr 10 11:59:04 2017 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 10 Apr 2017 13:59:04 +0200 Subject: [5.1] a8b453c Allow EPIPE in VTCP_Check() Message-ID: commit a8b453cb432e9717e1a8afab91433aa4294ba27e Author: Nils Goroll Date: Tue Mar 21 13:41:25 2017 +0100 Allow EPIPE in VTCP_Check() We may see it after a write on a socket which has been closed by the remote end. Fixes #2267 diff --git a/lib/libvarnish/vtcp.c b/lib/libvarnish/vtcp.c index 67be8a0..9122f3e 100644 --- a/lib/libvarnish/vtcp.c +++ b/lib/libvarnish/vtcp.c @@ -577,7 +577,7 @@ VTCP_Check(int a) * connection. * This is a bug in Solaris and documented behaviour on NetBSD. */ - if (errno == EINVAL || errno == ETIMEDOUT) + if (errno == EINVAL || errno == ETIMEDOUT || errno == EPIPE) return (1); #endif return (0); From phk at FreeBSD.org Mon Apr 10 11:59:04 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 10 Apr 2017 13:59:04 +0200 Subject: [5.1] 5fd8055 Add a xport->req_fail() for H2 Message-ID: commit 5fd805510aaf960b613ead15add444786b083647 Author: Poul-Henning Kamp Date: Tue Mar 21 13:37:46 2017 +0000 Add a xport->req_fail() for H2 Fixes: #2258 diff --git a/bin/varnishd/http1/cache_http1_fsm.c b/bin/varnishd/http1/cache_http1_fsm.c index 4b00488..5a7c958 100644 --- a/bin/varnishd/http1/cache_http1_fsm.c +++ b/bin/varnishd/http1/cache_http1_fsm.c @@ -243,14 +243,14 @@ struct transport HTTP1_transport = { .name = "HTTP/1", .magic = TRANSPORT_MAGIC, .deliver = V1D_Deliver, - .unwait = http1_unwait, + .minimal_response = http1_minimal_response, + .new_session = http1_new_session, + .reembark = http1_reembark, .req_body = http1_req_body, .req_fail = http1_req_fail, - .new_session = http1_new_session, - .sess_panic = http1_sess_panic, .req_panic = http1_req_panic, - .reembark = http1_reembark, - .minimal_response = http1_minimal_response, + .sess_panic = http1_sess_panic, + .unwait = http1_unwait, }; /*---------------------------------------------------------------------- diff --git a/bin/varnishd/http2/cache_http2.h b/bin/varnishd/http2/cache_http2.h index 89b85df..bd9e778 100644 --- a/bin/varnishd/http2/cache_http2.h +++ b/bin/varnishd/http2/cache_http2.h @@ -225,3 +225,6 @@ int h2_rxframe(struct worker *, struct h2_sess *); h2_error h2_set_setting(struct h2_sess *, const uint8_t *); void h2_req_body(struct req*); task_func_t h2_do_req; +#ifdef TRANSPORT_MAGIC +vtr_req_fail_f h2_req_fail; +#endif diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index 3ab643e..117690c 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -663,6 +663,15 @@ h2_req_body(struct req *req) /**********************************************************************/ +void __match_proto__(vtr_req_fail_f) +h2_req_fail(struct req *req, enum sess_close reason) +{ + assert(reason > 0); + assert(req->sp->fd != 0); +} + +/**********************************************************************/ + static enum htc_status_e __match_proto__(htc_complete_f) h2_frame_complete(struct http_conn *htc) { diff --git a/bin/varnishd/http2/cache_http2_session.c b/bin/varnishd/http2/cache_http2_session.c index 6922166..ce28251 100644 --- a/bin/varnishd/http2/cache_http2_session.c +++ b/bin/varnishd/http2/cache_http2_session.c @@ -364,10 +364,11 @@ h2_reembark(struct worker *wrk, struct req *req) struct transport H2_transport = { .name = "H2", .magic = TRANSPORT_MAGIC, - .new_session = h2_new_session, - .sess_panic = h2_sess_panic, .deliver = h2_deliver, - .req_body = h2_req_body, .minimal_response = h2_minimal_response, + .new_session = h2_new_session, .reembark = h2_reembark, + .req_body = h2_req_body, + .req_fail = h2_req_fail, + .sess_panic = h2_sess_panic, }; diff --git a/bin/varnishtest/tests/r02258.vtc b/bin/varnishtest/tests/r02258.vtc index ab2fac3..707d4b6 100644 --- a/bin/varnishtest/tests/r02258.vtc +++ b/bin/varnishtest/tests/r02258.vtc @@ -1,7 +1,6 @@ varnishtest "Streaming range premature finish" server s1 { - non_fatal rxreq txresp -nolen -hdr "Content-length: 9" delay 1 @@ -10,6 +9,7 @@ server s1 { send "BLA" delay .3 send "BL" + delay .3 } -start varnish v1 -vcl+backend { } -start @@ -22,3 +22,30 @@ client c1 { recv 8 expect_close } -run + +delay .3 + +server s1 { + rxreq + txresp -nolen -hdr "Content-length: 9" + delay 1 + send "BLA" + delay .4 + send "BLA" + delay .3 + send "BL" +} -start + +varnish v1 -cliok "param.set feature +http2" + +client c1 { + stream 1 { + txreq -hdr "range" "bytes=0-16" + rxhdrs + expect resp.status == 206 + expect resp.http.content-length == 9 + rxdata -all + } -run +} -run + + From nils.goroll at uplex.de Mon Apr 10 11:59:04 2017 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 10 Apr 2017 13:59:04 +0200 Subject: [5.1] 528fd74 sync VRB_Ignore() comment with reality Message-ID: commit 528fd74b0d886a90cc23babe6b977ada4f3d7329 Author: Nils Goroll Date: Tue Mar 21 19:20:07 2017 +0100 sync VRB_Ignore() comment with reality diff --git a/bin/varnishd/cache/cache_req_body.c b/bin/varnishd/cache/cache_req_body.c index 935a9fc..a27e4b4 100644 --- a/bin/varnishd/cache/cache_req_body.c +++ b/bin/varnishd/cache/cache_req_body.c @@ -218,7 +218,9 @@ VRB_Iterate(struct req *req, objiterate_f *func, void *priv) /*---------------------------------------------------------------------- * VRB_Ignore() is a dedicated function, because we might * be able to disuade or terminate its transmission in some protocols. - * For HTTP1 we have no such luck, and we just iterate it into oblivion. + * + * For HTTP1, we do nothing if we are going to close the connection anyway or + * just iterate it into oblivion. */ static int __match_proto__(objiterate_f) From phk at FreeBSD.org Mon Apr 10 11:59:04 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 10 Apr 2017 13:59:04 +0200 Subject: [5.1] 3da40ca Add panic function for {vrt|vmod}_privs Message-ID: commit 3da40ca9eb539046e0db1134062538208a772619 Author: Poul-Henning Kamp Date: Tue Mar 21 23:27:54 2017 +0000 Add panic function for {vrt|vmod}_privs diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index 84c78ea..d261c2d 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -122,8 +122,8 @@ sess_close_2str(enum sess_close sc, int want_desc) static const void *already_list[N_ALREADY]; static int already_idx; -static int -pan_already(struct vsb *vsb, const void *ptr) +int +PAN_already(struct vsb *vsb, const void *ptr) { int i; @@ -143,7 +143,6 @@ pan_already(struct vsb *vsb, const void *ptr) return (0); } - /*--------------------------------------------------------------------*/ static void @@ -151,7 +150,7 @@ pan_ws(struct vsb *vsb, const struct ws *ws) { VSB_printf(vsb, "ws = %p {\n", ws); - if (pan_already(vsb, ws)) + if (PAN_already(vsb, ws)) return; VSB_indent(vsb, 2); PAN_CheckMagic(vsb, ws, WS_MAGIC); @@ -183,7 +182,7 @@ pan_htc(struct vsb *vsb, const struct http_conn *htc) { VSB_printf(vsb, "http_conn = %p {\n", htc); - if (pan_already(vsb, htc)) + if (PAN_already(vsb, htc)) return; VSB_indent(vsb, 2); PAN_CheckMagic(vsb, htc, HTTP_CONN_MAGIC); @@ -215,7 +214,7 @@ pan_http(struct vsb *vsb, const char *id, const struct http *h) int i; VSB_printf(vsb, "http[%s] = %p {\n", id, h); - if (pan_already(vsb, h)) + if (PAN_already(vsb, h)) return; VSB_indent(vsb, 2); PAN_CheckMagic(vsb, h, HTTP_MAGIC); @@ -239,7 +238,7 @@ static void pan_boc(struct vsb *vsb, const struct boc *boc) { VSB_printf(vsb, "boc = %p {\n", boc); - if (pan_already(vsb, boc)) + if (PAN_already(vsb, boc)) return; VSB_indent(vsb, 2); PAN_CheckMagic(vsb, boc, BOC_MAGIC); @@ -259,7 +258,7 @@ pan_objcore(struct vsb *vsb, const char *typ, const struct objcore *oc) const char *p; VSB_printf(vsb, "objcore[%s] = %p {\n", typ, oc); - if (pan_already(vsb, oc)) + if (PAN_already(vsb, oc)) return; VSB_indent(vsb, 2); PAN_CheckMagic(vsb, oc, OBJCORE_MAGIC); @@ -314,7 +313,7 @@ pan_wrk(struct vsb *vsb, const struct worker *wrk) const char *p; VSB_printf(vsb, "worker = %p {\n", wrk); - if (pan_already(vsb, wrk)) + if (PAN_already(vsb, wrk)) return; VSB_indent(vsb, 2); PAN_CheckMagic(vsb, wrk, WORKER_MAGIC); @@ -364,7 +363,7 @@ pan_busyobj(struct vsb *vsb, const struct busyobj *bo) const char *p; VSB_printf(vsb, "busyobj = %p {\n", bo); - if (pan_already(vsb, bo)) + if (PAN_already(vsb, bo)) return; VSB_indent(vsb, 2); PAN_CheckMagic(vsb, bo, BUSYOBJ_MAGIC); @@ -419,7 +418,7 @@ pan_req(struct vsb *vsb, const struct req *req) const struct transport *xp; VSB_printf(vsb, "req = %p {\n", req); - if (pan_already(vsb, req)) + if (PAN_already(vsb, req)) return; VSB_indent(vsb, 2); PAN_CheckMagic(vsb, req, REQ_MAGIC); @@ -498,7 +497,7 @@ pan_sess(struct vsb *vsb, const struct sess *sp) const struct transport *xp; VSB_printf(vsb, "sp = %p {\n", sp); - if (pan_already(vsb, sp)) + if (PAN_already(vsb, sp)) return; VSB_indent(vsb, 2); PAN_CheckMagic(vsb, sp, SESS_MAGIC); @@ -521,6 +520,8 @@ pan_sess(struct vsb *vsb, const struct sess *sp) cp = SES_Get_String_Attr(sp, SA_CLIENT_PORT); VSB_printf(vsb, "client = %s %s,\n", ci, cp); + pan_privs(vsb, sp->privs); + VSB_indent(vsb, -2); VSB_printf(vsb, "},\n"); } diff --git a/bin/varnishd/cache/cache_priv.h b/bin/varnishd/cache/cache_priv.h index abf5e7f..0ff51eb 100644 --- a/bin/varnishd/cache/cache_priv.h +++ b/bin/varnishd/cache/cache_priv.h @@ -90,6 +90,7 @@ void ObjInit(void); /* cache_panic.c */ void PAN_Init(void); +int PAN_already(struct vsb *, const void *); /* cache_pool.c */ void Pool_Init(void); @@ -118,6 +119,7 @@ void VCL_Poll(void); /* cache_vrt.c */ void VRTPRIV_init(struct vrt_privs *privs); void VRTPRIV_dynamic_kill(struct vrt_privs *privs, uintptr_t id); +void pan_privs(struct vsb *, const struct vrt_privs *); /* cache_vrt_vmod.c */ void VMOD_Init(void); diff --git a/bin/varnishd/cache/cache_vrt_priv.c b/bin/varnishd/cache/cache_vrt_priv.c index bc97995..baafa66 100644 --- a/bin/varnishd/cache/cache_vrt_priv.c +++ b/bin/varnishd/cache/cache_vrt_priv.c @@ -54,6 +54,38 @@ static struct vmod_priv cli_task_priv; */ void +pan_privs(struct vsb *vsb, const struct vrt_privs *privs) +{ + struct vrt_priv *vp; + + VSB_printf(vsb, "privs = %p {\n", privs); + if (PAN_already(vsb, privs)) + return; + VSB_indent(vsb, 2); + PAN_CheckMagic(vsb, privs, VRT_PRIVS_MAGIC); + if (privs->magic == VRT_PRIVS_MAGIC) { + VTAILQ_FOREACH(vp, &privs->privs, list) { + PAN_CheckMagic(vsb, vp, VRT_PRIV_MAGIC); + VSB_printf(vsb, + "priv {p %p l %d f %p} vcl %p id %jx vmod %jx\n", + vp->priv->priv, + vp->priv->len, + vp->priv->free, + vp->vcl, + (uintmax_t)vp->id, + (uintmax_t)vp->vmod_id + ); + } + } + VSB_indent(vsb, -2); + VSB_printf(vsb, "},\n"); +} + + +/*-------------------------------------------------------------------- + */ + +void VRTPRIV_init(struct vrt_privs *privs) { From phk at FreeBSD.org Mon Apr 10 11:59:04 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 10 Apr 2017 13:59:04 +0200 Subject: [5.1] e94a5e4 Also release the req0. Message-ID: commit e94a5e4a88201cf73ff42a27bfcf497461d49c4e Author: Poul-Henning Kamp Date: Tue Mar 21 23:59:14 2017 +0000 Also release the req0. diff --git a/bin/varnishd/http2/cache_http2_session.c b/bin/varnishd/http2/cache_http2_session.c index ce28251..4c46a57 100644 --- a/bin/varnishd/http2/cache_http2_session.c +++ b/bin/varnishd/http2/cache_http2_session.c @@ -288,6 +288,7 @@ h2_new_session(struct worker *wrk, void *arg) CNT_AcctLogCharge(wrk->stats, req); VCL_Rel(&req->vcl); Req_Release(req); + h2_del_req(wrk, h2->req0); SES_Delete(h2->sess, SC_RX_JUNK, NAN); return; } From phk at FreeBSD.org Mon Apr 10 11:59:04 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 10 Apr 2017 13:59:04 +0200 Subject: [5.1] 4204414 Move a bunch of SES_ functions to cache_transport.h, they are not for casual calling. Message-ID: commit 4204414270572f997fb28625ae830b8363b63731 Author: Poul-Henning Kamp Date: Wed Mar 22 07:40:11 2017 +0000 Move a bunch of SES_ functions to cache_transport.h, they are not for casual calling. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index c45cc5e..cfed8b4 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -944,15 +944,10 @@ enum req_fsm_nxt CNT_Request(struct worker *, struct req *); void CNT_AcctLogCharge(struct dstat *, struct req *); /* cache_session.c [SES] */ -struct sess *SES_New(struct pool *); -void SES_Close(struct sess *, enum sess_close reason); void SES_Wait(struct sess *, const struct transport *); -void SES_Delete(struct sess *, enum sess_close reason, double now); void SES_Ref(struct sess *sp); void SES_Rel(struct sess *sp); int SES_Reschedule_Req(struct req *); -void SES_SetTransport(struct worker *, struct sess *, struct req *, - const struct transport *); enum htc_status_e { HTC_S_JUNK = -5, diff --git a/bin/varnishd/cache/cache_transport.h b/bin/varnishd/cache/cache_transport.h index 22c10b2..3433959 100644 --- a/bin/varnishd/cache/cache_transport.h +++ b/bin/varnishd/cache/cache_transport.h @@ -75,3 +75,10 @@ void H2_OU_Sess(struct worker *, struct sess *, struct req *); const struct transport *XPORT_ByNumber(uint16_t no); void VPX_Send_Proxy(int fd, int version, const struct sess *); + +/* cache_session.c */ +struct sess *SES_New(struct pool *); +void SES_Delete(struct sess *, enum sess_close reason, double now); +void SES_Close(struct sess *, enum sess_close reason); +void SES_SetTransport(struct worker *, struct sess *, struct req *, + const struct transport *); diff --git a/bin/varnishd/http1/cache_http1_deliver.c b/bin/varnishd/http1/cache_http1_deliver.c index 0833f49..3f19bdf 100644 --- a/bin/varnishd/http1/cache_http1_deliver.c +++ b/bin/varnishd/http1/cache_http1_deliver.c @@ -136,7 +136,7 @@ V1D_Deliver(struct req *req, struct boc *boc, int sendbody) } if ((V1L_FlushRelease(req->wrk) || err) && req->sp->fd >= 0) - SES_Close(req->sp, SC_REM_CLOSE); + Req_Fail(req, SC_REM_CLOSE); AZ(req->wrk->v1l); VDP_close(req); } From phk at FreeBSD.org Mon Apr 10 11:59:04 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 10 Apr 2017 13:59:04 +0200 Subject: [5.1] 5b70451 Fixes to and better test-coverage of exception paths in H2 upgrade. Message-ID: commit 5b70451f629cfe80584e8ea9e63221b60256edfa Author: Poul-Henning Kamp Date: Wed Mar 22 08:41:51 2017 +0000 Fixes to and better test-coverage of exception paths in H2 upgrade. diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index 117690c..60b671c 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -181,7 +181,6 @@ h2_del_req(struct worker *wrk, struct h2_req *r2) Req_Release(r2->req); if (r) return; - /* All streams gone, including stream #0, clean up */ req = h2->srq; Req_Cleanup(sp, wrk, req); diff --git a/bin/varnishd/http2/cache_http2_session.c b/bin/varnishd/http2/cache_http2_session.c index 4c46a57..18b2adf 100644 --- a/bin/varnishd/http2/cache_http2_session.c +++ b/bin/varnishd/http2/cache_http2_session.c @@ -192,11 +192,12 @@ h2_b64url_settings(struct h2_sess *h2, struct req *req) /**********************************************************************/ static int -h2_ou_session(const struct worker *wrk, struct h2_sess *h2, +h2_ou_session(struct worker *wrk, struct h2_sess *h2, struct req *req) { ssize_t sz; enum htc_status_e hs; + struct h2_req *r2; if (h2_b64url_settings(h2, req)) { VSLb(h2->vsl, SLT_Debug, "H2: Bad HTTP-Settings"); @@ -220,7 +221,7 @@ h2_ou_session(const struct worker *wrk, struct h2_sess *h2, HTC_RxInit(h2->htc, h2->ws); /* Start req thread */ - (void)h2_new_req(wrk, h2, 1, req); + r2 = h2_new_req(wrk, h2, 1, req); req->req_step = R_STP_RECV; req->transport = &H2_transport; req->req_step = R_STP_TRANSPORT; @@ -233,7 +234,8 @@ h2_ou_session(const struct worker *wrk, struct h2_sess *h2, hs = HTC_RxStuff(h2->htc, H2_prism_complete, NULL, NULL, NAN, h2->sess->t_idle + cache_param->timeout_idle, 256); if (hs != HTC_S_COMPLETE) { - VSLb(h2->vsl, SLT_Debug, "H2: No OU PRISM (hs=%d)", hs); + VSLb(h2->vsl, SLT_Debug, "H2: No/Bad OU PRISM (hs=%d)", hs); + h2_del_req(wrk, r2); return (0); } XXXAZ(Pool_Task(wrk->pool, &req->task, TASK_QUEUE_REQ)); @@ -285,11 +287,7 @@ h2_new_session(struct worker *wrk, void *arg) h2->req0 = h2_new_req(wrk, h2, 0, NULL); if (req->err_code == H2_OU_MARKER && !h2_ou_session(wrk, h2, req)) { - CNT_AcctLogCharge(wrk->stats, req); - VCL_Rel(&req->vcl); - Req_Release(req); h2_del_req(wrk, h2->req0); - SES_Delete(h2->sess, SC_RX_JUNK, NAN); return; } assert(HTC_S_COMPLETE == H2_prism_complete(h2->htc)); diff --git a/bin/varnishtest/tests/t02000.vtc b/bin/varnishtest/tests/t02000.vtc index 2bdfac9..29fe3ba 100644 --- a/bin/varnishtest/tests/t02000.vtc +++ b/bin/varnishtest/tests/t02000.vtc @@ -8,9 +8,17 @@ server s1 { varnish v1 -vcl+backend {} -start -varnish v1 -cliok "param.set feature +http2" varnish v1 -cliok "param.set debug +syncvsl" +varnish v1 -cliok "param.set feature -http2" + +client c1 { + txpri + expect_close +} -run + +varnish v1 -cliok "param.set feature +http2" + client c1 { stream 1 { txprio -weight 10 -stream 0 diff --git a/bin/varnishtest/tests/t02001.vtc b/bin/varnishtest/tests/t02001.vtc index d461f53..a55920a 100644 --- a/bin/varnishtest/tests/t02001.vtc +++ b/bin/varnishtest/tests/t02001.vtc @@ -27,16 +27,41 @@ client c1 { server s1 { rxreq - expect req.url == /upgrade + expect req.url == /upgrade1 + expect req.http.host == foo.bar + expect req.bodylen == 4 + txresp -status 401 -bodylen 8 + + rxreq + expect req.url == /upgrade2 expect req.http.host == foo.bar barrier b1 sync - txresp -status 401 -bodylen 11 + txresp -status 402 -bodylen 11 } -start +delay .5 + varnish v1 -cliok "param.set feature +http2" +# We don't support upgrades with body + +client c1 { + send "POST /upgrade1 HTTP/1.1\r\n" + send "Host: foo.bar\r\n" + send "Upgrade: h2c\r\n" + send "HTTP2-Settings: AAMAAABkAAQAAP__\r\n" + send "Content-Length: 4\r\n" + send "\r\n" + send "FOO\n" + rxresp + expect resp.status == 401 + expect resp.bodylen == 8 +} -run + +delay .5 + client c1 { - send "GET /upgrade HTTP/1.1\r\n" + send "GET /upgrade2 HTTP/1.1\r\n" send "Host: foo.bar\r\n" send "Upgrade: h2c\r\n" send "HTTP2-Settings: AAMAAABkAAQAAP__\r\n" @@ -56,7 +81,7 @@ client c1 { barrier b1 sync stream 1 { rxresp - expect resp.status == 401 + expect resp.status == 402 expect resp.bodylen == 11 } -run } -run From phk at FreeBSD.org Mon Apr 10 11:59:04 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 10 Apr 2017 13:59:04 +0200 Subject: [5.1] 4d3037a Generalize HPACK length encoding Message-ID: commit 4d3037a13ea2fd253f3c575f8cd6d7ed9f0fc17f Author: Poul-Henning Kamp Date: Wed Mar 22 09:27:19 2017 +0000 Generalize HPACK length encoding Fixes #2260 diff --git a/bin/varnishd/http2/cache_http2_deliver.c b/bin/varnishd/http2/cache_http2_deliver.c index 3ef75a3..2d65033 100644 --- a/bin/varnishd/http2/cache_http2_deliver.c +++ b/bin/varnishd/http2/cache_http2_deliver.c @@ -154,6 +154,24 @@ h2_minimal_response(struct req *req, uint16_t status) return (0); } +static uint8_t * +h2_enc_len(uint8_t *p, unsigned bits, unsigned val) +{ + assert(bits < 8); + unsigned mask = (1U << bits) - 1U; + + if (val >= mask) { + *p++ |= (uint8_t)mask; + val -= mask; + while (val >= 128) { + *p++ = 0x80 | ((uint8_t)val & 0x7f); + val >>= 7; + } + } + *p++ = (uint8_t)val; + return (p); +} + void __match_proto__(vtr_deliver_f) h2_deliver(struct req *req, struct boc *boc, int sendbody) { @@ -205,23 +223,13 @@ h2_deliver(struct req *req, struct boc *boc, int sendbody) VSLb(req->vsl, SLT_Debug, "HP {%d, \"%s\", \"%s\"} <%s>", hps->idx, hps->name, hps->val, hp->hd[u].b); - if (hps->idx < 15) { - *p++ = 0x10 | hps->idx; - } else { - *p++ = 0x1f; - *p++ = hps->idx - 0x0f; - } + *p = 0x10; + p = h2_enc_len(p, 4, hps->idx); } else { *p++ = 0x10; sz--; - if (sz < 127) { - *p++ = (uint8_t)sz; - } else { - *p++ = 0x7f; - *p++ = (uint8_t)sz - 0x7f; - } - + p = h2_enc_len(p, 7, sz); for (sz1 = 0; sz1 < sz; sz1++) *p++ = (uint8_t)tolower(hp->hd[u].b[sz1]); @@ -230,14 +238,7 @@ h2_deliver(struct req *req, struct boc *boc, int sendbody) while (vct_islws(*++r)) continue; sz = hp->hd[u].e - r; - assert(sz <= 254); - if (sz < 127) { - *p++ = (uint8_t)sz; - } else if (sz < 127 * 2) { - *p++ = 0x7f; - *p++ = (uint8_t)sz - 0x7f; - } - + p = h2_enc_len(p, 7, sz); memcpy(p, r, sz); p += sz; assert(WS_Inside(req->ws, p, NULL)); diff --git a/bin/varnishtest/tests/t02000.vtc b/bin/varnishtest/tests/t02000.vtc index 29fe3ba..cb14e51 100644 --- a/bin/varnishtest/tests/t02000.vtc +++ b/bin/varnishtest/tests/t02000.vtc @@ -3,7 +3,10 @@ varnishtest "Direct H2 start" server s1 { rxreq expect req.http.host == foo.bar - txresp -bodylen 10 + txresp \ + -hdr "H234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789I: foo" \ + -hdr "Foo: H234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789I" \ + -bodylen 10 } -start varnish v1 -vcl+backend {} -start From phk at FreeBSD.org Mon Apr 10 11:59:04 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 10 Apr 2017 13:59:04 +0200 Subject: [5.1] 569dc01 Add a couple of commits to try to catch #2257 Message-ID: commit 569dc01257c7c5744ffc4e10b09156f4c3ea3912 Author: Poul-Henning Kamp Date: Wed Mar 22 11:38:52 2017 +0000 Add a couple of commits to try to catch #2257 diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index ee135e7..524a21e 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -1011,6 +1011,7 @@ CNT_Request(struct worker *wrk, struct req *req) VRB_Free(req); req->wrk = NULL; } + assert(nxt == REQ_FSM_DISEMBARK || req->ws->r == NULL); return (nxt); } diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index 60b671c..33aea63 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -440,6 +440,7 @@ h2_do_req(struct worker *wrk, void *priv) req->http->conds = 1; if (CNT_Request(wrk, req) != REQ_FSM_DISEMBARK) { VSL(SLT_Debug, 0, "H2REQ CNT done"); + AZ(req->ws->r); r2->state = H2_S_CLOSED; h2_del_req(wrk, r2); } From nils.goroll at uplex.de Mon Apr 10 11:59:04 2017 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 10 Apr 2017 13:59:04 +0200 Subject: [5.1] 11fe8b0 I want to find this vtc when grepping for waitinglist Message-ID: commit 11fe8b0f70115414544e79fda2e85d57ac60101c Author: Nils Goroll Date: Wed Mar 22 14:06:11 2017 +0100 I want to find this vtc when grepping for waitinglist diff --git a/bin/varnishtest/tests/c00013.vtc b/bin/varnishtest/tests/c00013.vtc index b833296..e2bbedb 100644 --- a/bin/varnishtest/tests/c00013.vtc +++ b/bin/varnishtest/tests/c00013.vtc @@ -1,4 +1,4 @@ -varnishtest "Test parking second request on backend delay" +varnishtest "Test parking second request on backend delay (waitinglist)" barrier b1 cond 2 barrier b2 cond 2 From nils.goroll at uplex.de Mon Apr 10 11:59:04 2017 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 10 Apr 2017 13:59:04 +0200 Subject: [5.1] 3e015a1 Do all of the vfc setup and init in one place and only when needed Message-ID: commit 3e015a1a8e256c65d4536390b6db098740ca9a5e Author: Nils Goroll Date: Wed Mar 22 14:17:55 2017 +0100 Do all of the vfc setup and init in one place and only when needed Previously, we would be left with a set up but uninitialized req->vfc when reembarking a request on the waitinglist because the set up was done in CNT_Request, but transport->req_body was only called in cnt_recv. Fixes #2266 diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 524a21e..2086966 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -90,6 +90,14 @@ cnt_transport(struct worker *wrk, struct req *req) return (REQ_FSM_DONE); } + if (req->req_body_status < REQ_BODY_TAKEN) { + AN(req->transport->req_body != NULL); + VFP_Setup(req->vfc); + req->vfc->http = req->http; + req->vfc->wrk = wrk; + req->transport->req_body(req); + } + HTTP_Copy(req->http0, req->http); // For ESI & restart req->req_step = R_STP_RECV; return (REQ_FSM_MORE); @@ -791,13 +799,9 @@ cnt_recv(struct worker *wrk, struct req *req) http_CollectHdr(req->http, H_Cache_Control); - if (req->transport->req_body != NULL) { - req->transport->req_body(req); - - if (req->req_body_status == REQ_BODY_FAIL) { - req->doclose = SC_OVERLOAD; - return (REQ_FSM_DONE); - } + if (req->req_body_status == REQ_BODY_FAIL) { + req->doclose = SC_OVERLOAD; + return (REQ_FSM_DONE); } VCL_recv_method(req->vcl, wrk, req, NULL, NULL); @@ -967,13 +971,8 @@ CNT_Request(struct worker *wrk, struct req *req) AN(req->vsl->wid & VSL_CLIENTMARKER); - req->wrk = wrk; + req->vfc->wrk = req->wrk = wrk; wrk->vsl = req->vsl; - - VFP_Setup(req->vfc); - req->vfc->http = req->http; - req->vfc->wrk = wrk; - for (nxt = REQ_FSM_MORE; nxt == REQ_FSM_MORE; ) { /* * This is a good place to be paranoid about the various diff --git a/bin/varnishtest/tests/r02266.vtc b/bin/varnishtest/tests/r02266.vtc new file mode 100644 index 0000000..5fed4d6 --- /dev/null +++ b/bin/varnishtest/tests/r02266.vtc @@ -0,0 +1,50 @@ +varnishtest "request with body parked on waitinglist - almost identical to c00013.vtc" + +barrier b1 cond 2 +barrier b2 cond 2 + +server s1 { + rxreq + expect req.url == "/foo" + send "HTTP/1.0 200 OK\r\nConnection: close\r\n\r\n" + delay .2 + barrier b1 sync + delay .2 + send "line1\n" + delay .2 + barrier b2 sync + send "line2\n" +} -start + +varnish v1 -vcl+backend { + sub vcl_backend_response { + set beresp.do_stream = false; + } +} -start + +varnish v1 -cliok "param.set debug +syncvsl" + +client c1 { + txreq -url "/foo" -hdr "client: c1" + rxresp + expect resp.status == 200 + expect resp.bodylen == 12 + expect resp.http.x-varnish == "1001" +} -start + +barrier b1 sync + +client c2 { + txreq -url "/foo" -hdr "client: c2" -body 1 + delay .2 + barrier b2 sync + rxresp + expect resp.status == 200 + expect resp.bodylen == 12 + expect resp.http.x-varnish == "1004 1002" +} -run + +client c1 -wait + +varnish v1 -expect busy_sleep >= 1 +varnish v1 -expect busy_wakeup >= 1 diff --git a/include/tbl/req_body.h b/include/tbl/req_body.h index 9878e9c..5b4716a 100644 --- a/include/tbl/req_body.h +++ b/include/tbl/req_body.h @@ -32,6 +32,7 @@ REQ_BODY(INIT) REQ_BODY(WITHOUT_LEN) REQ_BODY(WITH_LEN) +/* states >= TAKEN imply that no body is to be read */ REQ_BODY(TAKEN) REQ_BODY(CACHED) REQ_BODY(FAIL) From phk at FreeBSD.org Mon Apr 10 11:59:04 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 10 Apr 2017 13:59:04 +0200 Subject: [5.1] 8e77985 If the client workspace is almost, but not quite exhaused, we may not be able to get enough iovec's to do Chunked transmission. Message-ID: commit 8e77985261fa4bef963a0e55b7d7392d75e93c2e Author: Poul-Henning Kamp Date: Thu Mar 23 08:08:29 2017 +0000 If the client workspace is almost, but not quite exhaused, we may not be able to get enough iovec's to do Chunked transmission. Fixes #2275 And #2207 was probably misdiagnosed, but the fix is correct anyhow. diff --git a/bin/varnishd/http1/cache_http1_line.c b/bin/varnishd/http1/cache_http1_line.c index 2565b05..5f102b0 100644 --- a/bin/varnishd/http1/cache_http1_line.c +++ b/bin/varnishd/http1/cache_http1_line.c @@ -89,7 +89,8 @@ V1L_Reserve(struct worker *wrk, struct ws *ws, int *fd, struct vsl_log *vsl, v1l->res = res; u = WS_ReserveLumps(ws, sizeof(struct iovec)); - if (u == 0) { + if (u < 3) { + /* Must have at least 3 in case of chunked encoding */ WS_Release(ws, 0); WS_MarkOverflow(ws); return; @@ -262,6 +263,7 @@ V1L_Chunked(const struct worker *wrk) CHECK_OBJ_NOTNULL(v1l, V1L_MAGIC); assert(v1l->ciov == v1l->siov); + assert(v1l->siov >= 3); /* * If there are not space for chunked header, a chunk of data and * a chunk tail, we might as well flush right away. diff --git a/bin/varnishtest/tests/c00071.vtc b/bin/varnishtest/tests/c00071.vtc index 50574df..a168eb8 100644 --- a/bin/varnishtest/tests/c00071.vtc +++ b/bin/varnishtest/tests/c00071.vtc @@ -14,7 +14,7 @@ server s1 { varnish v1 -vcl+backend { import debug; sub vcl_deliver { - debug.workspace_allocate(client, debug.workspace_free(client) - 160); + debug.workspace_allocate(client, debug.workspace_free(client) - 208); if (req.url ~ "/bar") { set resp.http.x-foo = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; From phk at FreeBSD.org Mon Apr 10 11:59:04 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 10 Apr 2017 13:59:04 +0200 Subject: [5.1] 3bb4641 FlexeLinting: Avoid cpp macro argument names inside strings Message-ID: commit 3bb4641bf1f6620d246c00cf88b2bf92b10ce3bd Author: Poul-Henning Kamp Date: Thu Mar 23 10:40:45 2017 +0000 FlexeLinting: Avoid cpp macro argument names inside strings diff --git a/bin/varnishtest/vtc.h b/bin/varnishtest/vtc.h index 0e09392..8ba61c2 100644 --- a/bin/varnishtest/vtc.h +++ b/bin/varnishtest/vtc.h @@ -41,13 +41,13 @@ #include "vqueue.h" #include "vsb.h" -#define VTC_CHECK_NAME(vl, name, type, chr) \ +#define VTC_CHECK_NAME(vl, nm, type, chr) \ do { \ - AN(name); \ - if (*(name) != chr) \ + AN(nm); \ + if (*(nm) != chr) \ vtc_fatal(vl, \ type " name must start with '%c' (got %s)", \ - chr, name); \ + chr, nm); \ } while (0) struct vtclog; diff --git a/bin/varnishtest/vtc_http2.c b/bin/varnishtest/vtc_http2.c index bef8689..1f6bfc3 100644 --- a/bin/varnishtest/vtc_http2.c +++ b/bin/varnishtest/vtc_http2.c @@ -840,12 +840,12 @@ receive_frame(void *priv) return (NULL); } -#define STRTOU32(n, s, p, v, c) \ +#define STRTOU32(n, ss, p, v, c) \ do { \ - n = strtoul(s, &p, 0); \ + n = strtoul(ss, &p, 0); \ if (*p != '\0') \ vtc_fatal(v, "%s takes an integer as argument" \ - "(found %s)", c, s); \ + "(found %s)", c, ss); \ } while (0) #define STRTOU32_CHECK(n, sp, p, v, c, l) \ @@ -2336,7 +2336,7 @@ cmd_rxpush(CMD_ARGS) if (s->frame->type != TYPE_ ## upctype) \ vtc_fatal(vl, "Received frame of type %d " \ "is invalid for %s", \ - s->frame->type, "rx ## lctype"); \ + s->frame->type, "rx" #lctype); \ } /* SECTION: stream.spec.prio_rxprio rxprio From phk at FreeBSD.org Mon Apr 10 11:59:04 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 10 Apr 2017 13:59:04 +0200 Subject: [5.1] d73a4e4 Flexelinting: initialize variable flexelint cannot see through. Message-ID: commit d73a4e4a42ad44ce6d79dab5f89d1bc9d5a41f0b Author: Poul-Henning Kamp Date: Thu Mar 23 11:21:40 2017 +0000 Flexelinting: initialize variable flexelint cannot see through. diff --git a/bin/varnishtest/vtc_process.c b/bin/varnishtest/vtc_process.c index 8960692..eaf8d02 100644 --- a/bin/varnishtest/vtc_process.c +++ b/bin/varnishtest/vtc_process.c @@ -220,7 +220,7 @@ process_start(struct process *p) struct vsb *cl; int out_fd, err_fd; int fds[2]; - int fdt[2]; + int fdt[2] = { -1, -1 }; CHECK_OBJ_NOTNULL(p, PROCESS_MAGIC); if (p->hasthread) From martin at varnish-software.com Mon Apr 10 11:59:05 2017 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Mon, 10 Apr 2017 13:59:05 +0200 Subject: [5.1] 6cb0c66 Add parenthesis to clearify code Message-ID: commit 6cb0c6664bb5ef53b6e2cd6fdc5e4b56567eca44 Author: Martin Blix Grydeland Date: Wed Mar 22 14:04:37 2017 +0100 Add parenthesis to clearify code diff --git a/bin/varnishd/mgt/mgt_vcl.c b/bin/varnishd/mgt/mgt_vcl.c index 9c1e412..9f6672c 100644 --- a/bin/varnishd/mgt/mgt_vcl.c +++ b/bin/varnishd/mgt/mgt_vcl.c @@ -387,14 +387,14 @@ mgt_vcl_setstate(struct cli *cli, struct vclprog *vp, const char *vs) } if (vs == VCL_STATE_AUTO) { now = VTIM_mono(); - vs = vp->warm ? VCL_STATE_WARM : VCL_STATE_COLD; + vs = (vp->warm ? VCL_STATE_WARM : VCL_STATE_COLD); if (vp->go_cold > 0 && vp->state == VCL_STATE_AUTO && vp->go_cold + mgt_param.vcl_cooldown < now) vs = VCL_STATE_COLD; } assert(vs != VCL_STATE_AUTO); - warm = vs == VCL_STATE_WARM ? 1 : 0; + warm = (vs == VCL_STATE_WARM ? 1 : 0); if (vp->warm == warm) return (0); From martin at varnish-software.com Mon Apr 10 11:59:05 2017 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Mon, 10 Apr 2017 13:59:05 +0200 Subject: [5.1] ad8e8f8 Do not update mgt's mirrored VCL temp state on child temp state failures Message-ID: commit ad8e8f8e5ea4f14097825d4a4a23411e2ac222ae Author: Martin Blix Grydeland Date: Wed Mar 22 14:17:17 2017 +0100 Do not update mgt's mirrored VCL temp state on child temp state failures The child expects mgt to be consistent in its VCL state changes, e.g. not ask the child to 'use' a VCL that isn't warm. Not doing so will cause the child to assert (see asserts in cache_vcl.c:ccf_config_use). This could trigger because the mgt erranously would set its recorded temp regardless of the child's reply in mgt_vcl_setstate. This patch changes it to only record the new temp in mgt if the child replied success. If the child isn't running the new temp is always recorded. Slightly update v00044.vtc test case to reflect the need to update the state before restarting the child. diff --git a/bin/varnishd/mgt/mgt_vcl.c b/bin/varnishd/mgt/mgt_vcl.c index 9f6672c..8849752 100644 --- a/bin/varnishd/mgt/mgt_vcl.c +++ b/bin/varnishd/mgt/mgt_vcl.c @@ -399,16 +399,15 @@ mgt_vcl_setstate(struct cli *cli, struct vclprog *vp, const char *vs) if (vp->warm == warm) return (0); - vp->warm = warm; - - if (vp->warm == 0) - vp->go_cold = 0; - - if (!MCH_Running()) + if (!MCH_Running()) { + vp->warm = warm; + if (vp->warm == 0) + vp->go_cold = 0; return (0); + } i = mgt_cli_askchild(&status, &p, "vcl.state %s %d%s\n", - vp->name, vp->warm, vp->state); + vp->name, warm, vp->state); if (i && cli != NULL) { VCLI_SetResult(cli, status); VCLI_Out(cli, "%s", p); @@ -416,8 +415,15 @@ mgt_vcl_setstate(struct cli *cli, struct vclprog *vp, const char *vs) MGT_Complain(C_ERR, "Please file ticket: VCL poker problem: " "'vcl.state %s %d%s' -> %03d '%s'", - vp->name, vp->warm, vp->state, i, p); + vp->name, warm, vp->state, i, p); + } else { + /* Success, update mgt's VCL state to reflect child's + state */ + vp->warm = warm; + if (vp->warm == 0) + vp->go_cold = 0; } + free(p); return (i); } diff --git a/bin/varnishtest/tests/v00044.vtc b/bin/varnishtest/tests/v00044.vtc index 26feae3..ff218f2 100644 --- a/bin/varnishtest/tests/v00044.vtc +++ b/bin/varnishtest/tests/v00044.vtc @@ -90,4 +90,5 @@ varnish v1 -clierr 300 "vcl.state vcl1 warm" # A warm-up failure can also fail a child start varnish v1 -cliok stop +varnish v1 -cliok "vcl.state vcl1 warm" varnish v1 -clierr 300 start From martin at varnish-software.com Mon Apr 10 11:59:05 2017 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Mon, 10 Apr 2017 13:59:05 +0200 Subject: [5.1] 744e55d Log VSM/VSL errors in varnishtest Message-ID: commit 744e55dc837c3be0a6761cfbc7406419a44d7cc0 Author: Martin Blix Grydeland Date: Wed Mar 22 17:58:28 2017 +0100 Log VSM/VSL errors in varnishtest This might be useful for debugging diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c index 5941848..154952e 100644 --- a/bin/varnishtest/vtc_varnish.c +++ b/bin/varnishtest/vtc_varnish.c @@ -209,11 +209,15 @@ varnishlog_thread(void *priv) if (c == NULL) { VTIM_sleep(0.1); if (VSM_Open(vsm)) { + vtc_log(v->vl, 3, "vsm|%s", + VSM_Error(vsm)); VSM_ResetError(vsm); continue; } c = VSL_CursorVSM(vsl, vsm, opt); if (c == NULL) { + vtc_log(v->vl, 3, "vsl|%s", + VSL_Error(vsl)); VSL_ResetError(vsl); continue; } From martin at varnish-software.com Mon Apr 10 11:59:05 2017 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Mon, 10 Apr 2017 13:59:05 +0200 Subject: [5.1] 110d073 Add a vsl_catchup varnishtest function Message-ID: commit 110d0732d4ba6a6bfb082994f632b837490a7e9b Author: Martin Blix Grydeland Date: Wed Mar 22 18:09:12 2017 +0100 Add a vsl_catchup varnishtest function This enables waiting for the logging thread to idle to make sure all generated log is caught. diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c index 154952e..eb42078 100644 --- a/bin/varnishtest/vtc_varnish.c +++ b/bin/varnishtest/vtc_varnish.c @@ -82,6 +82,7 @@ struct varnish { unsigned vsl_tag_count[256]; volatile int vsl_rec; + volatile int vsl_idle; }; #define NONSENSE "%XJEIFLH|)Xspa8P" @@ -182,6 +183,16 @@ wait_running(const struct varnish *v) * Varnishlog gatherer thread */ +static void +vsl_catchup(const struct varnish *v) +{ + int vsl_idle; + + vsl_idle = v->vsl_idle; + while (vsl_idle == v->vsl_idle) + VTIM_sleep(0.1); +} + static void * varnishlog_thread(void *priv) { @@ -249,6 +260,7 @@ varnishlog_thread(void *priv) } if (i == 0) { /* Nothing to do but wait */ + v->vsl_idle++; VTIM_sleep(0.1); } else if (i == -2) { /* Abandoned - try reconnect */ @@ -1054,6 +1066,10 @@ varnish_expect(const struct varnish *v, char * const *av) * style pattern (ie: fnmatch(3)) as used in shell filename expansion. * To see all counters use pattern "*", to see all counters about * requests use "*req*". + * + * \-vsl_catchup + * Wait until the logging thread has idled to make sure that all + * the generated log is flushed */ void @@ -1209,6 +1225,10 @@ cmd_varnish(CMD_ARGS) varnish_wait(v); continue; } + if (!strcmp(*av, "-vsl_catchup")) { + vsl_catchup(v); + continue; + } vtc_fatal(v->vl, "Unknown varnish argument: %s", *av); } } From phk at FreeBSD.org Mon Apr 10 11:59:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 10 Apr 2017 13:59:05 +0200 Subject: [5.1] 30786d6 Tune for 32 bit machines also Message-ID: commit 30786d676a67adbbfc4ec174ab193171232f6ad5 Author: Poul-Henning Kamp Date: Thu Mar 23 12:57:36 2017 +0000 Tune for 32 bit machines also diff --git a/bin/varnishtest/tests/c00071.vtc b/bin/varnishtest/tests/c00071.vtc index a168eb8..77e39d3 100644 --- a/bin/varnishtest/tests/c00071.vtc +++ b/bin/varnishtest/tests/c00071.vtc @@ -14,7 +14,7 @@ server s1 { varnish v1 -vcl+backend { import debug; sub vcl_deliver { - debug.workspace_allocate(client, debug.workspace_free(client) - 208); + debug.workspace_allocate(client, debug.workspace_free(client) - 192); if (req.url ~ "/bar") { set resp.http.x-foo = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; From phk at FreeBSD.org Mon Apr 10 11:59:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 10 Apr 2017 13:59:05 +0200 Subject: [5.1] 1ed2adc Merge branch 'master' of github.com:varnishcache/varnish-cache Message-ID: commit 1ed2adc1e1cd647b4cb21d397f3543cdff729813 Merge: 30786d6 110d073 Author: Poul-Henning Kamp Date: Thu Mar 23 12:57:49 2017 +0000 Merge branch 'master' of github.com:varnishcache/varnish-cache From phk at FreeBSD.org Mon Apr 10 11:59:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 10 Apr 2017 13:59:05 +0200 Subject: [5.1] ce9c09a Negative SIZE to debug.workspace_allocate() now means "leave this much free in workspace". Message-ID: commit ce9c09a297a7b15f9db28411a5cb712113f803d9 Author: Poul-Henning Kamp Date: Thu Mar 23 13:27:45 2017 +0000 Negative SIZE to debug.workspace_allocate() now means "leave this much free in workspace". Add debug.typesize() which can tell us the C-sizeof() various types. diff --git a/lib/libvmod_debug/vmod.vcc b/lib/libvmod_debug/vmod.vcc index 4fe903f..b33d3af 100644 --- a/lib/libvmod_debug/vmod.vcc +++ b/lib/libvmod_debug/vmod.vcc @@ -167,6 +167,8 @@ $Function VOID workspace_allocate(ENUM { client, backend, session, thread }, INT size) Allocate and zero out SIZE bytes from a workspace. +If SIZE is negative, all but that many bytes are allocated from the workspace. +(NB: Beware of the alignment imposed on workspace allocations.) $Function BOOL workspace_overflowed(ENUM { client, backend, session, thread }) @@ -203,3 +205,17 @@ Synchronize with a varnishtest shared barrier. $Function VOID test_probe(PROBE probe, PROBE same = 0) Only here to make sure probe definitions are passed properly. + +$Function INT typesize(STRING) + +Returns the size in bytes of a collection of C-datatypes. + +* 'p' = pointer +* 'i' = int +* 'd' = double +* 'f' = float +* 'l' = long +* 's' = short +* 'z' = size_t +* 'o' = off_t +* 'j' = intmax_t diff --git a/lib/libvmod_debug/vmod_debug.c b/lib/libvmod_debug/vmod_debug.c index fe07219..65bea1f 100644 --- a/lib/libvmod_debug/vmod_debug.c +++ b/lib/libvmod_debug/vmod_debug.c @@ -410,6 +410,10 @@ vmod_workspace_allocate(VRT_CTX, VCL_ENUM which, VCL_INT size) WS_Assert(ws); AZ(ws->r); + if (size < 0) { + size += WS_Reserve(ws, 0); + WS_Release(ws, 0); + } s = WS_Alloc(ws, size); if (!s) return; @@ -544,3 +548,27 @@ vmod_test_probe(VRT_CTX, VCL_PROBE probe, VCL_PROBE same) CHECK_OBJ_ORNULL(same, VRT_BACKEND_PROBE_MAGIC); AZ(same == NULL || probe == same); } + +VCL_INT +vmod_typesize(VRT_CTX, VCL_STRING s) +{ + int i = 0; + const char *p; + + (void)ctx; + for (p = s; *p; p++) { + switch (*p) { + case 'p': i += sizeof(void *); break; + case 'i': i += sizeof(int); break; + case 'd': i += sizeof(double); break; + case 'f': i += sizeof(float); break; + case 'l': i += sizeof(long); break; + case 's': i += sizeof(short); break; + case 'z': i += sizeof(size_t); break; + case 'o': i += sizeof(off_t); break; + case 'j': i += sizeof(intmax_t); break; + default: return(-1); + } + } + return (i); +} From phk at FreeBSD.org Mon Apr 10 11:59:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 10 Apr 2017 13:59:05 +0200 Subject: [5.1] 3ca71eb Add testcase for #2275 Message-ID: commit 3ca71ebe745f3806f3c0ec3cf5f749688de2c2ab Author: Poul-Henning Kamp Date: Thu Mar 23 13:29:28 2017 +0000 Add testcase for #2275 diff --git a/bin/varnishtest/tests/r02275.vtc b/bin/varnishtest/tests/r02275.vtc new file mode 100644 index 0000000..5458832 --- /dev/null +++ b/bin/varnishtest/tests/r02275.vtc @@ -0,0 +1,39 @@ +varnishtest "Chunked with no space for iov's on workspace" + +server s1 -repeat 2 { + rxreq + txresp -nolen -hdr "Transfer-encoding: chunked" + delay 1 + chunkedlen 10 + delay .1 + chunkedlen 10 + delay .1 + chunkedlen 0 +} -start + +varnish v1 -vcl+backend { + import debug; + + sub vcl_deliver { + if (req.url == "/1") { + debug.workspace_allocate(client, + -1 * (40 + debug.typesize("p") * 25)); + } else { + debug.workspace_allocate(client, + -1 * (48 + debug.typesize("p") * 25)); + } + set resp.http.foo = debug.workspace_free(client); + } +} -start + +client c1 { + txreq -url /1 + rxresp + expect resp.status == 500 +} -run +client c1 { + txreq -url /2 + rxresp + expect resp.status == 200 +} -run + From dridi.boukelmoune at gmail.com Mon Apr 10 11:59:05 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 10 Apr 2017 13:59:05 +0200 Subject: [5.1] 52099d4 Don't append newline for varnishtest -p Message-ID: commit 52099d46f7ac50b92be718d87bbfad32408d30c3 Author: Dridi Boukelmoune Date: Thu Mar 23 15:33:15 2017 +0100 Don't append newline for varnishtest -p Original patch from @joshuaspence. Closes #2262 diff --git a/bin/varnishtest/tests/r02262.vtc b/bin/varnishtest/tests/r02262.vtc new file mode 100644 index 0000000..15ffe26 --- /dev/null +++ b/bin/varnishtest/tests/r02262.vtc @@ -0,0 +1,10 @@ +varnishtest "varnishtest -p" + +shell { +cat >_.vtc < 0) From phk at FreeBSD.org Mon Apr 10 11:59:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 10 Apr 2017 13:59:05 +0200 Subject: [5.1] 01d7080 Use the new "allocate all but" debug.workspace_allocate() feature Message-ID: commit 01d7080bf421c1f3cd57e7df8aca0d8ccc1ec588 Author: Poul-Henning Kamp Date: Thu Mar 23 17:45:19 2017 +0000 Use the new "allocate all but" debug.workspace_allocate() feature diff --git a/bin/varnishtest/tests/c00071.vtc b/bin/varnishtest/tests/c00071.vtc index 77e39d3..befa08d 100644 --- a/bin/varnishtest/tests/c00071.vtc +++ b/bin/varnishtest/tests/c00071.vtc @@ -14,7 +14,7 @@ server s1 { varnish v1 -vcl+backend { import debug; sub vcl_deliver { - debug.workspace_allocate(client, debug.workspace_free(client) - 192); + debug.workspace_allocate(client, -192); if (req.url ~ "/bar") { set resp.http.x-foo = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; diff --git a/bin/varnishtest/tests/r01834.vtc b/bin/varnishtest/tests/r01834.vtc index 1937da1..e5e1dbc 100644 --- a/bin/varnishtest/tests/r01834.vtc +++ b/bin/varnishtest/tests/r01834.vtc @@ -18,7 +18,7 @@ varnish v1 -vcl+backend { } sub vcl_backend_fetch { - debug.workspace_allocate(backend, debug.workspace_free(backend) - std.integer(bereq.http.WS, 256)); + debug.workspace_allocate(backend, -1 * std.integer(bereq.http.WS, 256)); } } -start From phk at FreeBSD.org Mon Apr 10 11:59:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 10 Apr 2017 13:59:05 +0200 Subject: [5.1] 97d8ef9 Change/simplify the V1L logic for chunked encoding. Message-ID: commit 97d8ef918f98ebf08f12e5e7f7a5f54ca7fe6067 Author: Poul-Henning Kamp Date: Thu Mar 23 19:00:55 2017 +0000 Change/simplify the V1L logic for chunked encoding. This reverts the patch for #2207, which as martin points out, is not a good idea after all. diff --git a/bin/varnishd/http1/cache_http1_line.c b/bin/varnishd/http1/cache_http1_line.c index 5f102b0..8215fab 100644 --- a/bin/varnishd/http1/cache_http1_line.c +++ b/bin/varnishd/http1/cache_http1_line.c @@ -161,9 +161,7 @@ V1L_Flush(const struct worker *wrk) CHECK_OBJ_NOTNULL(v1l, V1L_MAGIC); AN(v1l->wfd); - /* For chunked, there must be one slot reserved for the chunked tail */ - if (v1l->ciov < v1l->siov) - assert(v1l->niov < v1l->siov); + assert(v1l->niov <= v1l->siov); if (*v1l->wfd >= 0 && v1l->liov > 0 && v1l->werr == 0) { if (v1l->ciov < v1l->siov && v1l->cliov > 0) { @@ -174,6 +172,7 @@ V1L_Flush(const struct worker *wrk) v1l->iov[v1l->ciov].iov_len = i; v1l->liov += i; + /* This is OK, because siov was --'ed */ v1l->iov[v1l->niov].iov_base = cbuf + i - 2; v1l->iov[v1l->niov++].iov_len = 2; v1l->liov += 2; @@ -240,16 +239,14 @@ V1L_Write(const struct worker *wrk, const void *ptr, ssize_t len) return (0); if (len == -1) len = strlen(ptr); - if (v1l->niov >= v1l->siov - (v1l->ciov < v1l->siov ? 2 : 0)) - (void)V1L_Flush(wrk); + assert(v1l->niov < v1l->siov); v1l->iov[v1l->niov].iov_base = TRUST_ME(ptr); v1l->iov[v1l->niov].iov_len = len; v1l->liov += len; v1l->niov++; - if (v1l->ciov < v1l->siov) { - assert(v1l->niov < v1l->siov); - v1l->cliov += len; - } + v1l->cliov += len; + if (v1l->niov >= v1l->siov) + (void)V1L_Flush(wrk); return (len); } @@ -270,6 +267,7 @@ V1L_Chunked(const struct worker *wrk) */ if (v1l->niov + 3 >= v1l->siov) (void)V1L_Flush(wrk); + v1l->siov--; v1l->ciov = v1l->niov++; v1l->cliov = 0; assert(v1l->ciov < v1l->siov); @@ -294,6 +292,7 @@ V1L_EndChunk(const struct worker *wrk) assert(v1l->ciov < v1l->siov); (void)V1L_Flush(wrk); + v1l->siov++; v1l->ciov = v1l->siov; v1l->niov = 0; v1l->cliov = 0; From phk at FreeBSD.org Mon Apr 10 11:59:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 10 Apr 2017 13:59:05 +0200 Subject: [5.1] b335c0e Put a priority block in a HEADERS frame Message-ID: commit b335c0eee4fa15218aee417308c6bcb50bcd6dc0 Author: Poul-Henning Kamp Date: Thu Mar 23 19:22:45 2017 +0000 Put a priority block in a HEADERS frame diff --git a/bin/varnishtest/tests/t02000.vtc b/bin/varnishtest/tests/t02000.vtc index cb14e51..16b79b8 100644 --- a/bin/varnishtest/tests/t02000.vtc +++ b/bin/varnishtest/tests/t02000.vtc @@ -33,7 +33,7 @@ client c1 { txprio -weight 10 -stream 2 } -run stream 7 { - txreq -hdr :authority foo.bar -pad cotton + txreq -dep 3 -hdr :authority foo.bar -pad cotton rxresp expect resp.status == 200 } -start From phk at FreeBSD.org Mon Apr 10 11:59:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 10 Apr 2017 13:59:05 +0200 Subject: [5.1] 2e5da22 Make -vsl_catchup bail on test-failure or child death Message-ID: commit 2e5da2264069121e6001b8da9d1f16ec7430b7cc Author: Poul-Henning Kamp Date: Thu Mar 23 20:08:51 2017 +0000 Make -vsl_catchup bail on test-failure or child death diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c index eb42078..2079943 100644 --- a/bin/varnishtest/vtc_varnish.c +++ b/bin/varnishtest/vtc_varnish.c @@ -189,7 +189,7 @@ vsl_catchup(const struct varnish *v) int vsl_idle; vsl_idle = v->vsl_idle; - while (vsl_idle == v->vsl_idle) + while (!vtc_error && v->pid && vsl_idle == v->vsl_idle) VTIM_sleep(0.1); } From phk at FreeBSD.org Mon Apr 10 11:59:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 10 Apr 2017 13:59:05 +0200 Subject: [5.1] 6358f4a Try to push H2 into even weirder corners. Message-ID: commit 6358f4a81edec4065b3bfeaeea54583d70336eb5 Author: Poul-Henning Kamp Date: Thu Mar 23 21:19:46 2017 +0000 Try to push H2 into even weirder corners. diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index 33aea63..6683752 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -177,12 +177,14 @@ h2_del_req(struct worker *wrk, struct h2_req *r2) /* XXX: PRIORITY reshuffle */ VTAILQ_REMOVE(&h2->streams, r2, list); Lck_Unlock(&sp->mtx); + AZ(r2->req->ws->r); Req_Cleanup(sp, wrk, r2->req); Req_Release(r2->req); if (r) return; /* All streams gone, including stream #0, clean up */ req = h2->srq; + AZ(req->ws->r); Req_Cleanup(sp, wrk, req); Req_Release(req); SES_Delete(sp, SC_RX_JUNK, NAN); @@ -271,15 +273,21 @@ h2_rx_rst_stream(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) { (void)wrk; + AN(r2); if (h2->rxf_len != 4) // rfc7540,l,2003,2004 return (H2CE_FRAME_SIZE_ERROR); - if (r2 == NULL) - return (0); Lck_Lock(&h2->sess->mtx); r2->error = h2_streamerror(vbe32dec(h2->rxf_data)); +VSLb(h2->vsl, SLT_Debug, "H2RST %u %d %s", r2->stream, r2->state, r2->error->name); if (r2->wrk != NULL) - AZ(pthread_cond_signal(&r2->wrk->cond)); + AZ(pthread_cond_signal(h2->cond)); + if (r2->state != H2_S_IDLE) { + r2->state = H2_S_CLOSED; + r2 = NULL; + } Lck_Unlock(&h2->sess->mtx); + if (r2 != NULL) + h2_del_req(wrk, r2); return (0); } @@ -620,7 +628,9 @@ h2_vfp_body(struct vfp_ctx *vc, struct vfp_entry *vfe, void *ptr, ssize_t *lp) Lck_Lock(&h2->sess->mtx); while (h2->mailcall != r2 && h2->error == 0 && r2->error == 0) AZ(Lck_CondWait(h2->cond, &h2->sess->mtx, 0)); - if (h2->mailcall == r2) { + if (h2->error || r2->error) { + retval = VFP_ERROR; + } else { assert(h2->mailcall == r2); if (l > h2->rxf_len) l = h2->rxf_len; @@ -636,8 +646,6 @@ h2_vfp_body(struct vfp_ctx *vc, struct vfp_entry *vfe, void *ptr, ssize_t *lp) } h2->mailcall = NULL; AZ(pthread_cond_broadcast(h2->cond)); - } else { - retval = VFP_ERROR; } Lck_Unlock(&h2->sess->mtx); return (retval); diff --git a/bin/varnishd/http2/cache_http2_session.c b/bin/varnishd/http2/cache_http2_session.c index 18b2adf..69fc12f 100644 --- a/bin/varnishd/http2/cache_http2_session.c +++ b/bin/varnishd/http2/cache_http2_session.c @@ -313,7 +313,7 @@ h2_new_session(struct worker *wrk, void *arg) AN(h2->error); /* Delete all idle streams */ Lck_Lock(&sp->mtx); - VSLb(h2->vsl, SLT_Debug, "H2 CLEANUP %p", h2->error); + VSLb(h2->vsl, SLT_Debug, "H2 CLEANUP %s", h2->error->name); VTAILQ_FOREACH(r2, &h2->streams, list) { if (r2->error == 0) r2->error = h2->error; diff --git a/bin/varnishtest/tests/t02007.vtc b/bin/varnishtest/tests/t02007.vtc index a3d44be..b168535 100644 --- a/bin/varnishtest/tests/t02007.vtc +++ b/bin/varnishtest/tests/t02007.vtc @@ -4,6 +4,19 @@ server s1 { rxreq expect req.proto == HTTP/1.1 txresp -hdr "Content-Type: text/plain" -hdrlen Foo 100 -bodylen 100 + + non_fatal + close + accept + rxreq + expect req.url == /3 + expect req.proto == HTTP/1.1 + txresp -hdr "Content-Type: text/plain" -hdrlen Foo 50 -bodylen 50 + + close + accept + rxreq + expect req.url == /5 } -start varnish v1 -vcl+backend {} -cliok "param.set feature +http2" -start @@ -40,3 +53,36 @@ client c1 { } -run } -run +varnish v1 -vsl_catchup + +client c1 { + stream 3 { + txreq \ + -req POST \ + -url /3 \ + -hdr content-type text/plain \ + -nostrend + delay .2 + txdata \ + -nostrend \ + -data request + delay .2 + txrst -err 0x333 + } -run + delay 2 + + stream 5 { + txreq \ + -req POST \ + -url /5 \ + -hdr content-type text/plain \ + -nostrend + delay .2 + txdata \ + -nostrend \ + -data request + delay .2 + } -run +} -run + +varnish v1 -vsl_catchup From phk at FreeBSD.org Mon Apr 10 11:59:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 10 Apr 2017 13:59:05 +0200 Subject: [5.1] cc5c71b Handle RST_STREAM on completed streams Message-ID: commit cc5c71b733c63de72e1ddc3114e0cf569753e19c Author: Poul-Henning Kamp Date: Thu Mar 23 22:07:10 2017 +0000 Handle RST_STREAM on completed streams diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index 6683752..b5f07a2 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -273,9 +273,10 @@ h2_rx_rst_stream(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) { (void)wrk; - AN(r2); if (h2->rxf_len != 4) // rfc7540,l,2003,2004 return (H2CE_FRAME_SIZE_ERROR); + if (r2 == NULL) + return (0); Lck_Lock(&h2->sess->mtx); r2->error = h2_streamerror(vbe32dec(h2->rxf_data)); VSLb(h2->vsl, SLT_Debug, "H2RST %u %d %s", r2->stream, r2->state, r2->error->name); diff --git a/bin/varnishtest/tests/t02000.vtc b/bin/varnishtest/tests/t02000.vtc index 16b79b8..6eb9ff8 100644 --- a/bin/varnishtest/tests/t02000.vtc +++ b/bin/varnishtest/tests/t02000.vtc @@ -36,6 +36,8 @@ client c1 { txreq -dep 3 -hdr :authority foo.bar -pad cotton rxresp expect resp.status == 200 + delay 1 + txrst -err 0x1111 } -start stream 0 { txping -data "_-__-_-_" From phk at FreeBSD.org Mon Apr 10 11:59:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 10 Apr 2017 13:59:05 +0200 Subject: [5.1] e8bb7ec Give this test 8 bytes more to succeed in. Message-ID: commit e8bb7ec58b893a138b1c1d782b2b2e40d69cc97c Author: Poul-Henning Kamp Date: Thu Mar 23 22:50:38 2017 +0000 Give this test 8 bytes more to succeed in. diff --git a/bin/varnishtest/tests/r02275.vtc b/bin/varnishtest/tests/r02275.vtc index 5458832..a5b2e27 100644 --- a/bin/varnishtest/tests/r02275.vtc +++ b/bin/varnishtest/tests/r02275.vtc @@ -20,7 +20,7 @@ varnish v1 -vcl+backend { -1 * (40 + debug.typesize("p") * 25)); } else { debug.workspace_allocate(client, - -1 * (48 + debug.typesize("p") * 25)); + -1 * (56 + debug.typesize("p") * 25)); } set resp.http.foo = debug.workspace_free(client); } From phk at FreeBSD.org Mon Apr 10 11:59:06 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 10 Apr 2017 13:59:06 +0200 Subject: [5.1] 35d1e51 Avoid sign-extension in hexdump Message-ID: commit 35d1e519ec717f10a1e274423eb1666d7ed965e2 Author: Poul-Henning Kamp Date: Fri Mar 24 06:58:19 2017 +0000 Avoid sign-extension in hexdump diff --git a/bin/varnishtest/vtc.h b/bin/varnishtest/vtc.h index 8ba61c2..ba0fb1c 100644 --- a/bin/varnishtest/vtc.h +++ b/bin/varnishtest/vtc.h @@ -107,8 +107,7 @@ void vtc_fatal(struct vtclog *vl, const char *, ...) __attribute__((__noreturn__)) __v_printflike(2,3); void vtc_dump(struct vtclog *vl, int lvl, const char *pfx, const char *str, int len); -void vtc_hexdump(struct vtclog *vl, int lvl, const char *pfx, - const char *str, int len); +void vtc_hexdump(struct vtclog *, int , const char *, const void *, int ); int vtc_send_proxy(int fd, int version, const struct suckaddr *sac, const struct suckaddr *sas); diff --git a/bin/varnishtest/vtc_log.c b/bin/varnishtest/vtc_log.c index 7f31744..df786e8 100644 --- a/bin/varnishtest/vtc_log.c +++ b/bin/varnishtest/vtc_log.c @@ -231,17 +231,18 @@ vtc_dump(struct vtclog *vl, int lvl, const char *pfx, const char *str, int len) void vtc_hexdump(struct vtclog *vl, int lvl, const char *pfx, - const char *str, int len) + const void *ptr, int len) { int nl = 1; unsigned l; + const uint8_t *ss = ptr; AN(pfx); GET_VL(vl); - if (str == NULL) + if (ss == NULL) vtc_leadin(vl, lvl, "%s(null)\n", pfx); else { - for (l = 0; l < len; l++, str++) { + for (l = 0; l < len; l++, ss++) { if (l > 512) { VSB_printf(vl->vsb, "..."); break; @@ -250,7 +251,7 @@ vtc_hexdump(struct vtclog *vl, int lvl, const char *pfx, vtc_leadin(vl, lvl, "%s| ", pfx); nl = 0; } - VSB_printf(vl->vsb, " %02x", *str); + VSB_printf(vl->vsb, " %02x", *ss); if ((l & 0xf) == 0xf) { VSB_printf(vl->vsb, "\n"); nl = 1; From phk at FreeBSD.org Mon Apr 10 11:59:06 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 10 Apr 2017 13:59:06 +0200 Subject: [5.1] 1ad7006 A LOT more H2 plumbing. Message-ID: commit 1ad7006dd182e33b06fa60816adf3b4f5a761452 Author: Poul-Henning Kamp Date: Fri Mar 24 11:00:33 2017 +0000 A LOT more H2 plumbing. diff --git a/bin/varnishd/http2/cache_http2.h b/bin/varnishd/http2/cache_http2.h index bd9e778..b95ac67 100644 --- a/bin/varnishd/http2/cache_http2.h +++ b/bin/varnishd/http2/cache_http2.h @@ -221,6 +221,8 @@ h2_error H2_Send(struct worker *, const struct h2_req *, struct h2_req * h2_new_req(const struct worker *, struct h2_sess *, unsigned stream, struct req *); void h2_del_req(struct worker *, struct h2_req *); +void h2_kill_req(struct worker *, const struct h2_sess *, + struct h2_req *, h2_error); int h2_rxframe(struct worker *, struct h2_sess *); h2_error h2_set_setting(struct h2_sess *, const uint8_t *); void h2_req_body(struct req*); diff --git a/bin/varnishd/http2/cache_http2_deliver.c b/bin/varnishd/http2/cache_http2_deliver.c index 2d65033..be422e6 100644 --- a/bin/varnishd/http2/cache_http2_deliver.c +++ b/bin/varnishd/http2/cache_http2_deliver.c @@ -260,7 +260,6 @@ h2_deliver(struct req *req, struct boc *boc, int sendbody) WS_Release(req->ws, 0); - if (sendbody) { VDP_push(req, h2_bytes, NULL, 1, "H2"); err = VDP_DeliverObj(req); diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index b5f07a2..146754f 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -190,6 +190,31 @@ h2_del_req(struct worker *wrk, struct h2_req *r2) SES_Delete(sp, SC_RX_JUNK, NAN); } +void +h2_kill_req(struct worker *wrk, const struct h2_sess *h2, + struct h2_req *r2, h2_error h2e) +{ + + VSLb(h2->vsl, SLT_Debug, "KILL st=%u state=%d", r2->stream, r2->state); + Lck_Lock(&h2->sess->mtx); + r2->error = h2e; + switch (r2->state) { + case H2_S_CLOS_REM: + if (r2->wrk != NULL) + AZ(pthread_cond_signal(h2->cond)); + r2 = NULL; + break; + case H2_S_OPEN: + (void)h2h_decode_fini(h2, r2->decode); + break; + default: + break; + } + Lck_Unlock(&h2->sess->mtx); + if (r2 != NULL) + h2_del_req(wrk, r2); +} + /**********************************************************************/ static void @@ -241,8 +266,7 @@ h2_rx_ping(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) (void)r2; if (h2->rxf_len != 8) // rfc7540,l,2364,2366 return (H2CE_FRAME_SIZE_ERROR); - if (h2->rxf_stream != 0) // rfc7540,l,2359,2362 - return (H2CE_PROTOCOL_ERROR); + AZ(h2->rxf_stream); // rfc7540,l,2359,2362 if (h2->rxf_flags != 0) // We never send pings return (H2SE_PROTOCOL_ERROR); H2_Send_Get(wrk, h2, r2); @@ -275,20 +299,9 @@ h2_rx_rst_stream(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) if (h2->rxf_len != 4) // rfc7540,l,2003,2004 return (H2CE_FRAME_SIZE_ERROR); - if (r2 == NULL) - return (0); - Lck_Lock(&h2->sess->mtx); - r2->error = h2_streamerror(vbe32dec(h2->rxf_data)); -VSLb(h2->vsl, SLT_Debug, "H2RST %u %d %s", r2->stream, r2->state, r2->error->name); - if (r2->wrk != NULL) - AZ(pthread_cond_signal(h2->cond)); - if (r2->state != H2_S_IDLE) { - r2->state = H2_S_CLOSED; - r2 = NULL; - } - Lck_Unlock(&h2->sess->mtx); if (r2 != NULL) - h2_del_req(wrk, r2); + h2_kill_req(wrk, h2, r2, + h2_streamerror(vbe32dec(h2->rxf_data))); return (0); } @@ -463,7 +476,6 @@ h2_end_headers(const struct worker *wrk, const struct h2_sess *h2, h2_error h2e; assert(r2->state == H2_S_OPEN); - r2->state = H2_S_CLOS_REM; h2e = h2h_decode_fini(h2, r2->decode); FREE_OBJ(r2->decode); if (h2e != NULL) { @@ -480,6 +492,7 @@ h2_end_headers(const struct worker *wrk, const struct h2_sess *h2, req->req_step = R_STP_TRANSPORT; req->task.func = h2_do_req; req->task.priv = req; + r2->state = H2_S_CLOS_REM; // XXX: not _quite_ true XXXAZ(Pool_Task(wrk->pool, &req->task, TASK_QUEUE_REQ)); return (0); } @@ -535,7 +548,10 @@ h2_rx_headers(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) } h2e = h2h_decode_bytes(h2, r2->decode, p, l); if (h2e != NULL) { - VSL(SLT_Debug, 0, "H2H_DECODE_BYTES %s", h2e->name); + VSL(SLT_Debug, 0, "H2H_DECODE_BYTES(hdr) %s", h2e->name); + (void)h2h_decode_fini(h2, r2->decode); + AZ(r2->req->ws->r); + h2_del_req(wrk, r2); return (h2e); } if (h2->rxf_flags & H2FF_HEADERS_END_HEADERS) @@ -558,7 +574,10 @@ h2_rx_continuation(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) req = r2->req; h2e = h2h_decode_bytes(h2, r2->decode, h2->rxf_data, h2->rxf_len); if (h2e != NULL) { - VSL(SLT_Debug, 0, "H2H_DECODE_BYTES %s", h2e->name); + VSL(SLT_Debug, 0, "H2H_DECODE_BYTES(cont) %s", h2e->name); + (void)h2h_decode_fini(h2, r2->decode); + AZ(r2->req->ws->r); + h2_del_req(wrk, r2); return (h2e); } if (h2->rxf_flags & H2FF_HEADERS_END_HEADERS) @@ -677,6 +696,7 @@ h2_req_fail(struct req *req, enum sess_close reason) { assert(reason > 0); assert(req->sp->fd != 0); + VSLb(req->vsl, SLT_Debug, "H2FAILREQ"); } /**********************************************************************/ @@ -836,7 +856,7 @@ h2_rxframe(struct worker *wrk, struct h2_sess *h2) h2->bogosity++; VSLb(h2->vsl, SLT_Debug, "H2: Unknown flags 0x%02x on %s (ignored)", - (uint8_t)h2->rxf_flags, h2f->name); + (uint8_t)h2->rxf_flags & ~h2f->flags, h2f->name); h2->rxf_flags &= h2f->flags; } diff --git a/bin/varnishd/http2/cache_http2_session.c b/bin/varnishd/http2/cache_http2_session.c index 69fc12f..63732d2 100644 --- a/bin/varnishd/http2/cache_http2_session.c +++ b/bin/varnishd/http2/cache_http2_session.c @@ -201,6 +201,10 @@ h2_ou_session(struct worker *wrk, struct h2_sess *h2, if (h2_b64url_settings(h2, req)) { VSLb(h2->vsl, SLT_Debug, "H2: Bad HTTP-Settings"); + AN (req->vcl); + VCL_Rel(&req->vcl); + CNT_AcctLogCharge(wrk->stats, req); + Req_Release(req); return (0); } @@ -317,20 +321,25 @@ h2_new_session(struct worker *wrk, void *arg) VTAILQ_FOREACH(r2, &h2->streams, list) { if (r2->error == 0) r2->error = h2->error; +#if 0 if (r2->wrk != NULL) - AZ(pthread_cond_signal(&r2->wrk->cond)); + AZ(pthread_cond_signal(&r2->wrk->cond)); // XXX Why? +#endif } + AZ(pthread_cond_signal(h2->cond)); while (1) { VTAILQ_FOREACH(r2, &h2->streams, list) - if (r2->state == H2_S_IDLE && r2 != h2->req0) + if (r2->state != H2_S_CLOS_REM && r2 != h2->req0) break; if (r2 == NULL) break; Lck_Unlock(&sp->mtx); - h2_del_req(wrk, r2); + h2_kill_req(wrk, h2, r2, h2->error); Lck_Lock(&sp->mtx); } VSLb(h2->vsl, SLT_Debug, "H2CLEAN done"); + VTAILQ_FOREACH(r2, &h2->streams, list) + VSLb(h2->vsl, SLT_Debug, "ST %u %d", r2->stream, r2->state); Lck_Unlock(&sp->mtx); h2->cond = NULL; h2_del_req(wrk, h2->req0); diff --git a/bin/varnishtest/tests/t02001.vtc b/bin/varnishtest/tests/t02001.vtc index a55920a..d744822 100644 --- a/bin/varnishtest/tests/t02001.vtc +++ b/bin/varnishtest/tests/t02001.vtc @@ -39,7 +39,12 @@ server s1 { txresp -status 402 -bodylen 11 } -start -delay .5 +varnish v1 -vsl_catchup + +varnish v1 -expect MEMPOOL.req0.live == 0 +varnish v1 -expect MEMPOOL.req1.live == 0 +varnish v1 -expect MEMPOOL.sess0.live == 0 +varnish v1 -expect MEMPOOL.sess1.live == 0 varnish v1 -cliok "param.set feature +http2" @@ -58,7 +63,12 @@ client c1 { expect resp.bodylen == 8 } -run -delay .5 +varnish v1 -vsl_catchup + +varnish v1 -expect MEMPOOL.req0.live == 0 +varnish v1 -expect MEMPOOL.req1.live == 0 +varnish v1 -expect MEMPOOL.sess0.live == 0 +varnish v1 -expect MEMPOOL.sess1.live == 0 client c1 { send "GET /upgrade2 HTTP/1.1\r\n" @@ -86,6 +96,13 @@ client c1 { } -run } -run +varnish v1 -vsl_catchup + +varnish v1 -expect MEMPOOL.req0.live == 0 +varnish v1 -expect MEMPOOL.req1.live == 0 +varnish v1 -expect MEMPOOL.sess0.live == 0 +varnish v1 -expect MEMPOOL.sess1.live == 0 + client c1 { # Illegal HTTP2-Settings send "GET /noupgrade HTTP/1.1\r\n" @@ -96,6 +113,13 @@ client c1 { expect_close } -run +varnish v1 -vsl_catchup + +varnish v1 -expect MEMPOOL.req0.live == 0 +varnish v1 -expect MEMPOOL.req1.live == 0 +varnish v1 -expect MEMPOOL.sess0.live == 0 +varnish v1 -expect MEMPOOL.sess1.live == 0 + client c1 { # PRISM with error in last bit send "GET /noupgrade HTTP/1.1\r\n" @@ -111,8 +135,7 @@ client c1 { expect_close } -run -# XXX: Tests temporarily neutered, they are too flakey -#varnish v1 -expect MEMPOOL.req0.live == 0 -#varnish v1 -expect MEMPOOL.req1.live == 0 -#varnish v1 -expect MEMPOOL.sess0.live == 0 -#varnish v1 -expect MEMPOOL.sess1.live == 0 +varnish v1 -expect MEMPOOL.req0.live == 0 +varnish v1 -expect MEMPOOL.req1.live == 0 +varnish v1 -expect MEMPOOL.sess0.live == 0 +varnish v1 -expect MEMPOOL.sess1.live == 0 diff --git a/bin/varnishtest/tests/t02003.vtc b/bin/varnishtest/tests/t02003.vtc index 62b0fe7..a3b99e3 100644 --- a/bin/varnishtest/tests/t02003.vtc +++ b/bin/varnishtest/tests/t02003.vtc @@ -1,4 +1,4 @@ -varnishtest "H2 Stream error conditions" +varnishtest "H2 Frame coverage/error conditions" server s1 { rxreq @@ -26,6 +26,13 @@ client c1 { stream 0 -wait } -run +varnish v1 -vsl_catchup + +varnish v1 -expect MEMPOOL.req0.live == 0 +varnish v1 -expect MEMPOOL.req1.live == 0 +varnish v1 -expect MEMPOOL.sess0.live == 0 +varnish v1 -expect MEMPOOL.sess1.live == 0 + ####################################################################### # Test reverse order stream numbers @@ -44,6 +51,13 @@ client c1 { stream 0 -wait } -run +varnish v1 -vsl_catchup + +varnish v1 -expect MEMPOOL.req0.live == 0 +varnish v1 -expect MEMPOOL.req1.live == 0 +varnish v1 -expect MEMPOOL.sess0.live == 0 +varnish v1 -expect MEMPOOL.sess1.live == 0 + ####################################################################### # Test WINDOW_UPDATE error conditions @@ -68,7 +82,13 @@ client c1 { } -start stream 5 { txprio - sendhex "000003 08 00 00000005 010203" + sendhex "000003 08 00 00000005" + delay .1 + sendhex 01 + delay .1 + sendhex 02 + delay .1 + sendhex 03 } -run stream 0 -wait } -run @@ -93,6 +113,13 @@ client c1 { } -run } -run +varnish v1 -vsl_catchup + +varnish v1 -expect MEMPOOL.req0.live == 0 +varnish v1 -expect MEMPOOL.req1.live == 0 +varnish v1 -expect MEMPOOL.sess0.live == 0 +varnish v1 -expect MEMPOOL.sess1.live == 0 + ####################################################################### # Test PING error conditions @@ -114,6 +141,22 @@ client c1 { } -run } -run +client c1 { + stream 0 { + sendhex "000007 06 80 00000000 01020304050607" + rxgoaway + expect goaway.laststream == 0 + expect goaway.err == FRAME_SIZE_ERROR + } -run +} -run + +varnish v1 -vsl_catchup + +varnish v1 -expect MEMPOOL.req0.live == 0 +varnish v1 -expect MEMPOOL.req1.live == 0 +varnish v1 -expect MEMPOOL.sess0.live == 0 +varnish v1 -expect MEMPOOL.sess1.live == 0 + ####################################################################### # Test PUSH_PROMISE error conditions @@ -130,6 +173,14 @@ client c1 { stream 0 -wait } -run +varnish v1 -vsl_catchup + +varnish v1 -expect MEMPOOL.req0.live == 0 +varnish v1 -expect MEMPOOL.req1.live == 0 +varnish v1 -expect MEMPOOL.sess0.live == 0 +varnish v1 -expect MEMPOOL.sess1.live == 0 + +####################################################################### # Test RST_STREAM error conditions client c1 { @@ -166,6 +217,20 @@ client c1 { } -run } -run +client c1 { + stream 1 { + txreq -nohdrend + txrst -err 0x666 + } -run +} -run + +varnish v1 -vsl_catchup + +varnish v1 -expect MEMPOOL.req0.live == 0 +varnish v1 -expect MEMPOOL.req1.live == 0 +varnish v1 -expect MEMPOOL.sess0.live == 0 +varnish v1 -expect MEMPOOL.sess1.live == 0 + ####################################################################### # Test SETTING error conditions @@ -186,8 +251,7 @@ client c1 { rxgoaway expect goaway.err == PROTOCOL_ERROR expect goaway.laststream == 0 - } -run -} -run + } -run } -run client c1 { stream 0 { @@ -207,3 +271,112 @@ client c1 { rxping } -run } -run + +varnish v1 -vsl_catchup + +varnish v1 -expect MEMPOOL.req0.live == 0 +varnish v1 -expect MEMPOOL.req1.live == 0 +varnish v1 -expect MEMPOOL.sess0.live == 0 +varnish v1 -expect MEMPOOL.sess1.live == 0 + +####################################################################### +# Test GOAWAY error conditions + +client c1 { + stream 0 { + txgoaway -err 2 + } -run + expect_close +} -run + +client c1 { + stream 0 { + txgoaway -err 2222 + } -run + expect_close +} -run + + +varnish v1 -vsl_catchup + +varnish v1 -expect MEMPOOL.req0.live == 0 +varnish v1 -expect MEMPOOL.req1.live == 0 +varnish v1 -expect MEMPOOL.sess0.live == 0 +varnish v1 -expect MEMPOOL.sess1.live == 0 + +####################################################################### +# Test HEADERS error conditions + +client c1 { + stream 1 { + txreq -nostrend + txreq -nostrend + } -run + stream 0 { + rxgoaway + } -run + expect_close +} -run + +client c1 { + stream 0 { + sendhex 00000c + sendhex 01 + sendhex 05 + sendhex 00000001 + sendhex ffffffff + sendhex ffffffff + sendhex ffffffff + rxgoaway + expect goaway.err == COMPRESSION_ERROR + } -run +} -run + +varnish v1 -vsl_catchup + +varnish v1 -expect MEMPOOL.req0.live == 0 +varnish v1 -expect MEMPOOL.req1.live == 0 +varnish v1 -expect MEMPOOL.sess0.live == 0 +varnish v1 -expect MEMPOOL.sess1.live == 0 + +####################################################################### +# Test CONTINUATION error conditions + +client c1 { + stream 1 { + txreq -nostrend + txcont -hdr "foo" "bar" + } -run + stream 0 { + rxgoaway + } -run + expect_close +} -run + +client c1 { + stream 0 { + sendhex 000014 + sendhex 01 + sendhex 01 + sendhex 00000001 + sendhex {8286 8441 0f77 7777 2e65 7861 6d70 6c65 2e63 6f6d} + + sendhex 00000c + sendhex 09 + sendhex 04 + sendhex 00000001 + sendhex ffffffff + sendhex ffffffff + sendhex ffffffff + rxgoaway + expect goaway.err == COMPRESSION_ERROR + } -run +} -run + +varnish v1 -vsl_catchup + +varnish v1 -expect MEMPOOL.req0.live == 0 +varnish v1 -expect MEMPOOL.req1.live == 0 +varnish v1 -expect MEMPOOL.sess0.live == 0 +varnish v1 -expect MEMPOOL.sess1.live == 0 + diff --git a/bin/varnishtest/tests/t02008.vtc b/bin/varnishtest/tests/t02008.vtc index a1bccba..75cee51 100644 --- a/bin/varnishtest/tests/t02008.vtc +++ b/bin/varnishtest/tests/t02008.vtc @@ -27,7 +27,7 @@ client c1 { txprio } -run stream 0 { - txgoaway -err 7 + txgoaway -err 2 } -run expect_close } -run From noreply at github.com Mon Apr 10 11:59:06 2017 From: noreply at github.com (GitHub) Date: Mon, 10 Apr 2017 13:59:06 +0200 Subject: [5.1] 3767269 How to report signal panics Message-ID: commit 37672695d84b1bed51d71be8c61c6719513502b2 Author: Dridi Boukelmoune Date: Fri Mar 24 19:22:47 2017 +0100 How to report signal panics diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index ca79ff0..3c29561 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -2,6 +2,11 @@ ## Expected Behavior + ## Expected Behavior @@ -42,3 +63,4 @@ * Version used: * Operating System and version: +* Source of binary packages used (if any) From nils.goroll at uplex.de Mon Apr 10 11:59:06 2017 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 10 Apr 2017 13:59:06 +0200 Subject: [5.1] acd4c29 no debuginfo packages on packagecloud.io Message-ID: commit acd4c296d59bbc768a7189aab963222ce48088df Author: Nils Goroll Date: Sun Mar 26 13:48:54 2017 +0200 no debuginfo packages on packagecloud.io diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index 6bc9424..2e578a7 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -12,7 +12,10 @@ - but at least the latest release of a supported version - you got - - debuginfo packages installed when running binaries from packages + - debuginfo packages installed when running binaries from + packages if these are available from the package source + you are using + - or have compiled with debug information whenever possible (configure --enable-debugging-symbols) From dridi.boukelmoune at gmail.com Mon Apr 10 11:59:06 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 10 Apr 2017 13:59:06 +0200 Subject: [5.1] bc2ea2c Support multi-lib systems for out-of-tree builds Message-ID: commit bc2ea2c35ebd1dcf613b5b9ab2b3957d0b4b4839 Author: Dridi Boukelmoune Date: Mon Mar 27 21:26:15 2017 +0200 Support multi-lib systems for out-of-tree builds On systems where both 32 and 64-bit libraries can co-exist, simply inheriting Varnish's prefix is not enough because VMODs might land in the wrong directory. For instance, on rhel you will find both /usr/lib and /usr/lib64. This is usually not a problem with package managers, because they usually take care of everything at configure time, for example RPMs may use a %configure macro that defines all well-known directories. It can however be overlooked when a VMOD is manually built from source. diff --git a/varnish.m4 b/varnish.m4 index 58248fb..400e087 100644 --- a/varnish.m4 +++ b/varnish.m4 @@ -1,4 +1,4 @@ -# Copyright (c) 2016 Varnish Software AS +# Copyright (c) 2016-2017 Varnish Software AS # All rights reserved. # # Author: Dridi Boukelmoune @@ -29,7 +29,7 @@ # OF THE POSSIBILITY OF SUCH DAMAGE. # varnish.m4 - Macros to define VMOD builds. -*- Autoconf -*- -# serial 6 (varnish-5.1.0) +# serial 7 (varnish-5.1.2) # # This collection of macros helps create VMODs or tools interacting with # Varnish Cache using the GNU build system (autotools). In order to work @@ -93,7 +93,12 @@ AC_DEFUN([_VARNISH_PKG_CONFIG], [ [$VARNISHAPI_SBINDIR:$VARNISHAPI_BINDIR:$PATH]) dnl Inherit Varnish's prefix if undefined - test "$prefix" = NONE && ac_default_prefix=$VARNISHAPI_PREFIX + dnl Also the libdir for multi-lib systems + if test "$prefix" = NONE + then + ac_default_prefix=$VARNISHAPI_PREFIX + libdir=$VARNISHAPI_LIBDIR + fi dnl Define the VCL directory for automake vcldir=$($PKG_CONFIG --define-variable=datadir=$datadir \ From phk at FreeBSD.org Mon Apr 10 11:59:06 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 10 Apr 2017 13:59:06 +0200 Subject: [5.1] 581948c Log the remote address to make it easier to cross-ref to VSL Message-ID: commit 581948c49181751b935fff809d6a54cfcb4594b2 Author: Poul-Henning Kamp Date: Tue Mar 28 07:28:02 2017 +0000 Log the remote address to make it easier to cross-ref to VSL diff --git a/bin/varnishtest/vtc_server.c b/bin/varnishtest/vtc_server.c index 773e7fb..13dd336 100644 --- a/bin/varnishtest/vtc_server.c +++ b/bin/varnishtest/vtc_server.c @@ -152,6 +152,8 @@ server_thread(void *priv) struct sockaddr_storage addr_s; struct sockaddr *addr; socklen_t l; + char abuf[VTCP_ADDRBUFSIZE]; + char pbuf[VTCP_PORTBUFSIZE]; CAST_OBJ_NOTNULL(s, priv, SERVER_MAGIC); assert(s->sock >= 0); @@ -167,7 +169,8 @@ server_thread(void *priv) fd = accept(s->sock, addr, &l); if (fd < 0) vtc_fatal(vl, "Accept failed: %s", strerror(errno)); - vtc_log(vl, 3, "accepted fd %d", fd); + VTCP_hisname(fd, abuf, sizeof abuf, pbuf, sizeof pbuf); + vtc_log(vl, 3, "accepted fd %d %s %s", fd, abuf, pbuf); fd = http_process(vl, s->spec, fd, &s->sock); vtc_log(vl, 3, "shutting fd %d", fd); j = shutdown(fd, SHUT_WR); From phk at FreeBSD.org Mon Apr 10 11:59:06 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 10 Apr 2017 13:59:06 +0200 Subject: [5.1] 15f5c12 When the client abandons a fetch we close the connection to the backend if still in mid-transfer. With sufficiently small -bodylen, as in this test, that might or might not happen. Message-ID: commit 15f5c12d9945263027fd7493205120054af3d22a Author: Poul-Henning Kamp Date: Tue Mar 28 07:36:22 2017 +0000 When the client abandons a fetch we close the connection to the backend if still in mid-transfer. With sufficiently small -bodylen, as in this test, that might or might not happen. Explicitly close from the server side, to stabilize this test. Fixes #2280 diff --git a/bin/varnishtest/tests/r02042.vtc b/bin/varnishtest/tests/r02042.vtc index fcb79a6..8e59926 100644 --- a/bin/varnishtest/tests/r02042.vtc +++ b/bin/varnishtest/tests/r02042.vtc @@ -20,6 +20,9 @@ server s1 { expect req.http.If-None-Match == txresp -hdr "ETag: foo" -bodylen 7 + close + accept + rxreq expect req.url == "/lm" txresp -hdr "Last-Modified: Thu, 26 Jun 2008 12:00:01 GMT" \ @@ -107,6 +110,8 @@ client c1 { expect resp.http.X-Cache == "MISS" } -run +varnish v1 -vsl_catchup + # The next two tests are adapted from the former r01206.vtc, reflecting # changes for the recv->pass and beresp.uncacheable (hit-for-miss) cases # after rolling back the fix for #1206, and verifying that they are @@ -125,6 +130,9 @@ server s1 { expect req.http.If-None-Match == "foo" txresp -hdr "ETag: foo" -bodylen 7 + close + accept + rxreq expect req.url == "/lm2" txresp -hdr "Last-Modified: Thu, 26 Jun 2008 12:00:01 GMT" \ @@ -201,6 +209,9 @@ server s1 { expect req.http.If-None-Match == txresp -hdr "ETag: foo" -bodylen 7 + close + accept + rxreq expect req.url == "/lm3" txresp -hdr "Last-Modified: Thu, 26 Jun 2008 12:00:01 GMT" \ From dridi.boukelmoune at gmail.com Mon Apr 10 11:59:06 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 10 Apr 2017 13:59:06 +0200 Subject: [5.1] 99b1a62 Check backend existence when reading proxy_header Message-ID: commit 99b1a625c400ce0751967f1a0b7552d60de9c144 Author: Dridi Boukelmoune Date: Tue Mar 28 10:43:56 2017 +0200 Check backend existence when reading proxy_header A probe may still be running when its backend is deleted. In that case it needs to read the proxy_header field under the lock and give up if the backend was already gone. Not sure how to write a test case for this one. Fixes #2278 diff --git a/bin/varnishd/cache/cache_backend_probe.c b/bin/varnishd/cache/cache_backend_probe.c index 4c18854..3d5bc15 100644 --- a/bin/varnishd/cache/cache_backend_probe.c +++ b/bin/varnishd/cache/cache_backend_probe.c @@ -267,7 +267,7 @@ vbp_write_proxy_v1(struct vbp_target *vt, int *sock) static void vbp_poke(struct vbp_target *vt) { - int s, tmo, i; + int s, tmo, i, proxy_header; double t_start, t_now, t_end; unsigned rlen, resp; char buf[8192], *p; @@ -299,12 +299,22 @@ vbp_poke(struct vbp_target *vt) return; } + Lck_Lock(&vbp_mtx); + if (vt->backend != NULL) + proxy_header = vt->backend->proxy_header; + else + proxy_header = -1; + Lck_Unlock(&vbp_mtx); + + if (proxy_header < 0) + return; + /* Send the PROXY header */ - assert(vt->backend->proxy_header <= 2); - if (vt->backend->proxy_header == 1) { + assert(proxy_header <= 2); + if (proxy_header == 1) { if (vbp_write_proxy_v1(vt, &s) != 0) return; - } else if (vt->backend->proxy_header == 2 && + } else if (proxy_header == 2 && vbp_write(vt, &s, vbp_proxy_local, sizeof vbp_proxy_local) != 0) return; From phk at FreeBSD.org Mon Apr 10 11:59:06 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 10 Apr 2017 13:59:06 +0200 Subject: [5.1] c022cc4 It is more robust to wait for the client connection to close than to delay a random-ish number of seconds Message-ID: commit c022cc4ce74118d78b62d78d3e84a071bc52cc8c Author: Poul-Henning Kamp Date: Tue Mar 28 14:47:09 2017 +0000 It is more robust to wait for the client connection to close than to delay a random-ish number of seconds diff --git a/bin/varnishtest/tests/c00057.vtc b/bin/varnishtest/tests/c00057.vtc index ba0ec1e..6ad74aa 100644 --- a/bin/varnishtest/tests/c00057.vtc +++ b/bin/varnishtest/tests/c00057.vtc @@ -16,8 +16,7 @@ varnish v1 -vcl+backend { client c1 { txreq + expect_close } -run -delay 7 - varnish v1 -cliok "panic.show" From phk at FreeBSD.org Mon Apr 10 11:59:06 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 10 Apr 2017 13:59:06 +0200 Subject: [5.1] 54b5a09 Try to confuse GCC to not doing FP brain-damage. Message-ID: commit 54b5a09f00c027da280361b30d32a4ff309ba3ab Author: Poul-Henning Kamp Date: Tue Mar 28 18:44:12 2017 +0000 Try to confuse GCC to not doing FP brain-damage. Fixes #1875 (maybe) diff --git a/bin/varnishd/mgt/mgt_param_tweak.c b/bin/varnishd/mgt/mgt_param_tweak.c index 12a7a52..b26581e 100644 --- a/bin/varnishd/mgt/mgt_param_tweak.c +++ b/bin/varnishd/mgt/mgt_param_tweak.c @@ -52,7 +52,7 @@ static int tweak_generic_double(struct vsb *vsb, volatile double *dest, const char *arg, const char *min, const char *max, const char *fmt) { - double u, minv = 0, maxv = 0; + volatile double u, minv = 0, maxv = 0; if (arg != NULL) { if (min != NULL) { From phk at FreeBSD.org Mon Apr 10 11:59:06 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 10 Apr 2017 13:59:06 +0200 Subject: [5.1] 89e4f96 Remove place_holder code. Message-ID: commit 89e4f9690e54564587f41767bf3b66f04a097f4e Author: Poul-Henning Kamp Date: Wed Mar 29 07:47:35 2017 +0000 Remove place_holder code. diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index fa59e28..d54453e 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -838,21 +838,10 @@ h2_rxframe(struct worker *wrk, struct h2_sess *h2) return (1); } h2f = h2flist[h2->rxf_type]; -#if 1 + AN(h2f->name); AN(h2f->rxfunc); -#else - /* If we ever get holes in the frame table... */ - if (h2f->name == NULL || h2f->func == NULL) { - // rfc7540,l,679,681 - // XXX: later, drain rest of frame - h2->bogosity++; - VSLb(h2->vsl, SLT_Debug, - "H2: Unimplemented frame type 0x%02x (ignored)", - h2->rxf_type); - return (0); - } -#endif + if (h2->rxf_flags & ~h2f->flags) { // rfc7540,l,687,688 h2->bogosity++; From phk at FreeBSD.org Mon Apr 10 11:59:07 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 10 Apr 2017 13:59:07 +0200 Subject: [5.1] 735b0ec Add a copy of the rxthread to h2_sess and create an assert so we can mark up functions where only it can go. Message-ID: commit 735b0ec916ea8a48258c2968c7d0f01d603f3b60 Author: Poul-Henning Kamp Date: Wed Mar 29 08:30:21 2017 +0000 Add a copy of the rxthread to h2_sess and create an assert so we can mark up functions where only it can go. Mark scheduled h2_req's. diff --git a/bin/varnishd/http2/cache_http2.h b/bin/varnishd/http2/cache_http2.h index b95ac67..3d761ed 100644 --- a/bin/varnishd/http2/cache_http2.h +++ b/bin/varnishd/http2/cache_http2.h @@ -116,6 +116,7 @@ struct h2_req { unsigned magic; #define H2_REQ_MAGIC 0x03411584 uint32_t stream; + int scheduled; enum h2_stream_e state; struct h2_sess *h2sess; struct req *req; @@ -137,6 +138,7 @@ struct h2_sess { unsigned magic; #define H2_SESS_MAGIC 0xa16f7e4b + pthread_t rxthr; struct h2_req *mailcall; pthread_cond_t *cond; @@ -175,6 +177,8 @@ struct h2_sess { h2_error error; }; +#define ASSERT_RXTHR(h2) do {assert(h2->rxthr == pthread_self());} while(0) + /* http2/cache_http2_panic.c */ #ifdef TRANSPORT_MAGIC vtr_sess_panic_f h2_sess_panic; diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index d54453e..b8b19aa 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -263,6 +263,7 @@ static h2_error __match_proto__(h2_frame_f) h2_rx_ping(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) { + ASSERT_RXTHR(h2); (void)r2; if (h2->rxf_len != 8) // rfc7540,l,2364,2366 return (H2CE_FRAME_SIZE_ERROR); @@ -282,9 +283,10 @@ h2_rx_ping(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) static h2_error __match_proto__(h2_frame_f) h2_rx_push_promise(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) { - // rfc7540,l,2262,2267 + (void)wrk; - (void)h2; + ASSERT_RXTHR(h2); + // rfc7540,l,2262,2267 (void)r2; return (H2CE_PROTOCOL_ERROR); } @@ -295,7 +297,9 @@ h2_rx_push_promise(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) static h2_error __match_proto__(h2_frame_f) h2_rx_rst_stream(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) { + (void)wrk; + ASSERT_RXTHR(h2); if (h2->rxf_len != 4) // rfc7540,l,2003,2004 return (H2CE_FRAME_SIZE_ERROR); @@ -313,6 +317,7 @@ h2_rx_goaway(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) { (void)wrk; + ASSERT_RXTHR(h2); (void)r2; h2->goaway_last_stream = vbe32dec(h2->rxf_data); h2->error = h2_connectionerror(vbe32dec(h2->rxf_data + 4)); @@ -329,6 +334,7 @@ h2_rx_window_update(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) uint32_t wu; (void)wrk; + ASSERT_RXTHR(h2); if (h2->rxf_len != 4) return (H2CE_FRAME_SIZE_ERROR); wu = vbe32dec(h2->rxf_data) & ~(1LU<<31); @@ -353,7 +359,7 @@ h2_rx_priority(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) { (void)wrk; - (void)h2; + ASSERT_RXTHR(h2); xxxassert(r2->stream & 1); return (0); } @@ -423,6 +429,7 @@ h2_rx_settings(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) h2_error retval = 0; AN(wrk); + ASSERT_RXTHR(h2); AN(r2); AZ(h2->rxf_stream); if (h2->rxf_flags == H2FF_SETTINGS_ACK) { @@ -463,6 +470,7 @@ h2_do_req(struct worker *wrk, void *priv) if (CNT_Request(wrk, req) != REQ_FSM_DISEMBARK) { VSL(SLT_Debug, 0, "H2REQ CNT done"); AZ(req->ws->r); + r2->scheduled = 0; r2->state = H2_S_CLOSED; h2_del_req(wrk, r2); } @@ -475,6 +483,7 @@ h2_end_headers(struct worker *wrk, const struct h2_sess *h2, { h2_error h2e; + ASSERT_RXTHR(h2); assert(r2->state == H2_S_OPEN); h2e = h2h_decode_fini(h2, r2->decode); FREE_OBJ(r2->decode); @@ -495,6 +504,7 @@ h2_end_headers(struct worker *wrk, const struct h2_sess *h2, req->req_step = R_STP_TRANSPORT; req->task.func = h2_do_req; req->task.priv = req; + r2->scheduled = 1; XXXAZ(Pool_Task(wrk->pool, &req->task, TASK_QUEUE_REQ)); return (0); } @@ -507,6 +517,7 @@ h2_rx_headers(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) const uint8_t *p; size_t l; + ASSERT_RXTHR(h2); if (r2->state != H2_S_IDLE) return (H2CE_PROTOCOL_ERROR); // XXX spec ? r2->state = H2_S_OPEN; @@ -571,6 +582,7 @@ h2_rx_continuation(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) struct req *req; h2_error h2e; + ASSERT_RXTHR(h2); if (r2->state != H2_S_OPEN) return (H2CE_PROTOCOL_ERROR); // XXX spec ? req = r2->req; @@ -597,6 +609,7 @@ h2_rx_data(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) unsigned wi; (void)wrk; + ASSERT_RXTHR(h2); AZ(h2->mailcall); h2->mailcall = r2; Lck_Lock(&h2->sess->mtx); @@ -730,6 +743,7 @@ h2_procframe(struct worker *wrk, struct h2_sess *h2, h2_error h2e; char b[4]; + ASSERT_RXTHR(h2); if (h2->rxf_stream == 0 && h2f->act_szero != 0) return (h2f->act_szero); @@ -801,6 +815,7 @@ h2_rxframe(struct worker *wrk, struct h2_sess *h2) h2_error h2e; char b[8]; + ASSERT_RXTHR(h2); (void)VTCP_blocking(*h2->htc->rfd); h2->sess->t_idle = VTIM_real(); hs = HTC_RxStuff(h2->htc, h2_frame_complete, diff --git a/bin/varnishd/http2/cache_http2_session.c b/bin/varnishd/http2/cache_http2_session.c index 63732d2..967dd1f 100644 --- a/bin/varnishd/http2/cache_http2_session.c +++ b/bin/varnishd/http2/cache_http2_session.c @@ -98,6 +98,7 @@ h2_new_sess(const struct worker *wrk, struct sess *sp, struct req *srq) h2->vsl->wid = sp->vxid; h2->htc->rfd = &sp->fd; h2->sess = sp; + h2->rxthr = pthread_self(); VTAILQ_INIT(&h2->streams); VTAILQ_INIT(&h2->txqueue); h2->local_settings = H2_proto_settings; From phk at FreeBSD.org Mon Apr 10 11:59:07 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 10 Apr 2017 13:59:07 +0200 Subject: [5.1] ec9c04d Stop nagging the VSM if we ran out of it after an error Message-ID: commit ec9c04d60ff0a6c7c87bc4d6d1c26c7ed40789b5 Author: Poul-Henning Kamp Date: Wed Mar 29 09:45:14 2017 +0000 Stop nagging the VSM if we ran out of it after an error diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c index 2079943..31ab631 100644 --- a/bin/varnishtest/vtc_varnish.c +++ b/bin/varnishtest/vtc_varnish.c @@ -218,6 +218,8 @@ varnishlog_thread(void *priv) opt = 0; while (v->pid || c != NULL) { if (c == NULL) { + if (vtc_error) + break; VTIM_sleep(0.1); if (VSM_Open(vsm)) { vtc_log(v->vl, 3, "vsm|%s", From phk at FreeBSD.org Mon Apr 10 11:59:07 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 10 Apr 2017 13:59:07 +0200 Subject: [5.1] bf6ce0f Improve the handling of h2 frame-reception when the connection closes. Insist we get the frames we expect. Message-ID: commit bf6ce0f733856843fd4598d8216df7e437d20187 Author: Poul-Henning Kamp Date: Wed Mar 29 11:08:47 2017 +0000 Improve the handling of h2 frame-reception when the connection closes. Insist we get the frames we expect. diff --git a/bin/varnishtest/tests/t02003.vtc b/bin/varnishtest/tests/t02003.vtc index 5c6b30c..b2e964f 100644 --- a/bin/varnishtest/tests/t02003.vtc +++ b/bin/varnishtest/tests/t02003.vtc @@ -269,8 +269,9 @@ client c1 { client c1 { stream 0 { - # SETTING unknown vlaue + # SETTING unknown value sendhex "000006 04 00 00000000 ffff00000000" + rxsettings txping rxping } -run diff --git a/bin/varnishtest/vtc_http2.c b/bin/varnishtest/vtc_http2.c index 1f6bfc3..ead77a4 100644 --- a/bin/varnishtest/vtc_http2.c +++ b/bin/varnishtest/vtc_http2.c @@ -177,27 +177,30 @@ get_bytes(const struct http *hp, char *buf, int n) if (i < 0 && errno == EINTR) continue; if (i == 0) - vtc_log(hp->vl, hp->fatal, + vtc_log(hp->vl, 3, "HTTP2 rx timeout (fd:%d %u ms)", hp->fd, hp->timeout); if (i < 0) - vtc_log(hp->vl, hp->fatal, + vtc_log(hp->vl, 3, "HTTP2 rx failed (fd:%d poll: %s)", hp->fd, strerror(errno)); - assert(i > 0); + if (i <= 0) + return (i); i = read(hp->fd, buf, n); if (!(pfd[0].revents & POLLIN)) vtc_log(hp->vl, 4, "HTTP2 rx poll (fd:%d revents: %x n=%d, i=%d)", hp->fd, pfd[0].revents, n, i); if (i == 0) - vtc_log(hp->vl, hp->fatal, + vtc_log(hp->vl, 3, "HTTP2 rx EOF (fd:%d read: %s)", hp->fd, strerror(errno)); if (i < 0) - vtc_log(hp->vl, hp->fatal, + vtc_log(hp->vl, 3, "HTTP2 rx failed (fd:%d read: %s)", hp->fd, strerror(errno)); + if (i <= 0) + return (i); n -= i; } return (1); @@ -729,7 +732,12 @@ receive_frame(void *priv) AZ(pthread_mutex_unlock(&hp->mtx)); if (!get_bytes(hp, hdr, 9)) { - vtc_log(hp->vl, 1, "could not get header"); + AZ(pthread_mutex_lock(&hp->mtx)); + VTAILQ_FOREACH(s, &hp->streams, list) + AZ(pthread_cond_signal(&s->cond)); + AZ(pthread_mutex_unlock(&hp->mtx)); + vtc_log(hp->vl, hp->fatal, + "could not get frame header"); return (NULL); } ALLOC_OBJ(f, FRAME_MAGIC); @@ -747,7 +755,15 @@ receive_frame(void *priv) f->data = malloc(f->size + 1L); AN(f->data); f->data[f->size] = '\0'; - AN(get_bytes(hp, f->data, f->size)); + if (get_bytes(hp, f->data, f->size) <= 0) { + AZ(pthread_mutex_lock(&hp->mtx)); + VTAILQ_FOREACH(s, &hp->streams, list) + AZ(pthread_cond_signal(&s->cond)); + AZ(pthread_mutex_unlock(&hp->mtx)); + vtc_log(hp->vl, hp->fatal, + "could not get frame body"); + return (NULL); + } } /* is the corresponding stream waiting? */ @@ -2331,12 +2347,13 @@ cmd_rxpush(CMD_ARGS) (void)cmd; \ (void)av; \ CAST_OBJ_NOTNULL(s, priv, STREAM_MAGIC); \ - if ((s->frame = rxstuff(s))) \ - return; \ - if (s->frame->type != TYPE_ ## upctype) \ - vtc_fatal(vl, "Received frame of type %d " \ - "is invalid for %s", \ - s->frame->type, "rx" #lctype); \ + s->frame = rxstuff(s); \ + if (s->frame != NULL && s->frame->type != TYPE_ ## upctype) \ + vtc_fatal(vl, \ + "Wrong frame type %s (%d) wanted %s", \ + s->frame->type < TYPE_MAX ? \ + h2_types[s->frame->type] : "?", \ + s->frame->type, #upctype); \ } /* SECTION: stream.spec.prio_rxprio rxprio From phk at FreeBSD.org Mon Apr 10 11:59:07 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 10 Apr 2017 13:59:07 +0200 Subject: [5.1] d56a248 Use each streams workers condvar instead of broadcasting. Message-ID: commit d56a2481d2ae5703c9401692670d265154d6861c Author: Poul-Henning Kamp Date: Wed Mar 29 11:16:29 2017 +0000 Use each streams workers condvar instead of broadcasting. diff --git a/bin/varnishd/http2/cache_http2.h b/bin/varnishd/http2/cache_http2.h index 3d761ed..0550e15 100644 --- a/bin/varnishd/http2/cache_http2.h +++ b/bin/varnishd/http2/cache_http2.h @@ -120,6 +120,7 @@ struct h2_req { enum h2_stream_e state; struct h2_sess *h2sess; struct req *req; + pthread_cond_t *cond; VTAILQ_ENTRY(h2_req) list; int64_t t_window; int64_t r_window; diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index b8b19aa..bba57de 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -138,6 +138,7 @@ h2_new_req(const struct worker *wrk, struct h2_sess *h2, { struct h2_req *r2; + ASSERT_RXTHR(h2); if (req == NULL) req = Req_New(wrk, h2->sess); CHECK_OBJ_NOTNULL(req, REQ_MAGIC); @@ -200,8 +201,8 @@ h2_kill_req(struct worker *wrk, const struct h2_sess *h2, r2->error = h2e; switch (r2->state) { case H2_S_CLOS_REM: - if (r2->wrk != NULL) - AZ(pthread_cond_signal(h2->cond)); + if (r2->cond != NULL) + AZ(pthread_cond_signal(r2->cond)); r2 = NULL; break; case H2_S_OPEN: @@ -487,7 +488,7 @@ h2_end_headers(struct worker *wrk, const struct h2_sess *h2, assert(r2->state == H2_S_OPEN); h2e = h2h_decode_fini(h2, r2->decode); FREE_OBJ(r2->decode); - r2->state = H2_S_CLOS_REM; // XXX: not _quite_ true + r2->state = H2_S_CLOS_REM; if (h2e != NULL) { VSL(SLT_Debug, 0, "H2H_DECODE_FINI %s", h2e->name); AZ(r2->req->ws->r); @@ -610,12 +611,13 @@ h2_rx_data(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) (void)wrk; ASSERT_RXTHR(h2); + Lck_Lock(&h2->sess->mtx); AZ(h2->mailcall); h2->mailcall = r2; - Lck_Lock(&h2->sess->mtx); h2->r_window -= h2->rxf_len; r2->r_window -= h2->rxf_len; - AZ(pthread_cond_broadcast(h2->cond)); + if (r2->cond) + AZ(pthread_cond_signal(r2->cond)); while (h2->mailcall != NULL && h2->error == 0 && r2->error == 0) AZ(Lck_CondWait(h2->cond, &h2->sess->mtx, 0)); wi = cache_param->h2_rx_window_increment; @@ -628,6 +630,7 @@ h2_rx_data(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) w2 = 1; } Lck_Unlock(&h2->sess->mtx); + if (w1 || w2) { vbe32enc(buf, wi); H2_Send_Get(wrk, h2, h2->req0); @@ -661,8 +664,10 @@ h2_vfp_body(struct vfp_ctx *vc, struct vfp_entry *vfe, void *ptr, ssize_t *lp) *lp = 0; Lck_Lock(&h2->sess->mtx); + r2->cond = &vc->wrk->cond; while (h2->mailcall != r2 && h2->error == 0 && r2->error == 0) - AZ(Lck_CondWait(h2->cond, &h2->sess->mtx, 0)); + AZ(Lck_CondWait(r2->cond, &h2->sess->mtx, 0)); + r2->cond = NULL; if (h2->error || r2->error) { retval = VFP_ERROR; } else { @@ -680,7 +685,7 @@ h2_vfp_body(struct vfp_ctx *vc, struct vfp_entry *vfe, void *ptr, ssize_t *lp) retval = VFP_END; } h2->mailcall = NULL; - AZ(pthread_cond_broadcast(h2->cond)); + AZ(pthread_cond_signal(h2->cond)); } Lck_Unlock(&h2->sess->mtx); return (retval); From phk at FreeBSD.org Mon Apr 10 11:59:07 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 10 Apr 2017 13:59:07 +0200 Subject: [5.1] 49c58d7 Don't let stream threads muck around in the stream list. Message-ID: commit 49c58d726d98ce82d1e9d84d436436e268c8d36d Author: Poul-Henning Kamp Date: Wed Mar 29 11:50:13 2017 +0000 Don't let stream threads muck around in the stream list. This should fix some H2 tickets. diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index bba57de..1a85b1e 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -171,6 +171,7 @@ h2_del_req(struct worker *wrk, struct h2_req *r2) CHECK_OBJ_NOTNULL(r2, H2_REQ_MAGIC); h2 = r2->h2sess; CHECK_OBJ_NOTNULL(h2, H2_SESS_MAGIC); + ASSERT_RXTHR(h2); sp = h2->sess; Lck_Lock(&sp->mtx); assert(h2->refcnt > 0); @@ -196,20 +197,19 @@ h2_kill_req(struct worker *wrk, const struct h2_sess *h2, struct h2_req *r2, h2_error h2e) { + ASSERT_RXTHR(h2); + AN(h2e); VSLb(h2->vsl, SLT_Debug, "KILL st=%u state=%d", r2->stream, r2->state); Lck_Lock(&h2->sess->mtx); - r2->error = h2e; - switch (r2->state) { - case H2_S_CLOS_REM: + if (r2->error == NULL) + r2->error = h2e; + if (r2->scheduled) { if (r2->cond != NULL) AZ(pthread_cond_signal(r2->cond)); r2 = NULL; - break; - case H2_S_OPEN: - (void)h2h_decode_fini(h2, r2->decode); - break; - default: - break; + } else { + if (r2->state == H2_S_OPEN) + (void)h2h_decode_fini(h2, r2->decode); } Lck_Unlock(&h2->sess->mtx); if (r2 != NULL) @@ -304,9 +304,9 @@ h2_rx_rst_stream(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) if (h2->rxf_len != 4) // rfc7540,l,2003,2004 return (H2CE_FRAME_SIZE_ERROR); - if (r2 != NULL) - h2_kill_req(wrk, h2, r2, - h2_streamerror(vbe32dec(h2->rxf_data))); + if (r2 == NULL) + return (0); + h2_kill_req(wrk, h2, r2, h2_streamerror(vbe32dec(h2->rxf_data))); return (0); } @@ -473,7 +473,8 @@ h2_do_req(struct worker *wrk, void *priv) AZ(req->ws->r); r2->scheduled = 0; r2->state = H2_S_CLOSED; - h2_del_req(wrk, r2); + if (r2->h2sess->error) + AZ(pthread_cond_signal(r2->h2sess->cond)); } THR_SetRequest(NULL); } @@ -744,7 +745,7 @@ static h2_error h2_procframe(struct worker *wrk, struct h2_sess *h2, h2_frame h2f) { - struct h2_req *r2 = NULL; + struct h2_req *r2 = NULL, *r22; h2_error h2e; char b[4]; @@ -767,9 +768,12 @@ h2_procframe(struct worker *wrk, struct h2_sess *h2, return (H2CE_PROTOCOL_ERROR); } - VTAILQ_FOREACH(r2, &h2->streams, list) + VTAILQ_FOREACH_SAFE(r2, &h2->streams, list, r22) { if (r2->stream == h2->rxf_stream) break; + if (r2->state == H2_S_CLOSED && !r2->scheduled) + h2_del_req(wrk, r2); + } if (r2 == NULL && h2f->act_sidle == 0) { if (h2->rxf_stream <= h2->highest_stream) diff --git a/bin/varnishd/http2/cache_http2_session.c b/bin/varnishd/http2/cache_http2_session.c index 967dd1f..3725586 100644 --- a/bin/varnishd/http2/cache_http2_session.c +++ b/bin/varnishd/http2/cache_http2_session.c @@ -275,8 +275,9 @@ h2_new_session(struct worker *wrk, void *arg) struct req *req; struct sess *sp; struct h2_sess *h2; - struct h2_req *r2; + struct h2_req *r2, *r22; uintptr_t wsp; + int again; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CAST_OBJ_NOTNULL(req, arg, REQ_MAGIC); @@ -316,32 +317,32 @@ h2_new_session(struct worker *wrk, void *arg) } AN(h2->error); + /* Delete all idle streams */ - Lck_Lock(&sp->mtx); VSLb(h2->vsl, SLT_Debug, "H2 CLEANUP %s", h2->error->name); VTAILQ_FOREACH(r2, &h2->streams, list) { if (r2->error == 0) r2->error = h2->error; -#if 0 - if (r2->wrk != NULL) - AZ(pthread_cond_signal(&r2->wrk->cond)); // XXX Why? -#endif + if (r2->cond != NULL) + AZ(pthread_cond_signal(r2->cond)); } AZ(pthread_cond_signal(h2->cond)); - while (1) { - VTAILQ_FOREACH(r2, &h2->streams, list) - if (r2->state != H2_S_CLOS_REM && r2 != h2->req0) - break; - if (r2 == NULL) + while(1) { + again = 0; + VTAILQ_FOREACH_SAFE(r2, &h2->streams, list, r22) { + if (r2 != h2->req0) { + h2_kill_req(wrk, h2, r2, h2->error); + again++; + } + } + if (!again) break; - Lck_Unlock(&sp->mtx); - h2_kill_req(wrk, h2, r2, h2->error); - Lck_Lock(&sp->mtx); + VTAILQ_FOREACH(r2, &h2->streams, list) + VSLb(h2->vsl, SLT_Debug, "ST %u %d", r2->stream, r2->state); + Lck_Lock(&h2->sess->mtx); + (void)Lck_CondWait(h2->cond, &h2->sess->mtx, .1); + Lck_Unlock(&h2->sess->mtx); } - VSLb(h2->vsl, SLT_Debug, "H2CLEAN done"); - VTAILQ_FOREACH(r2, &h2->streams, list) - VSLb(h2->vsl, SLT_Debug, "ST %u %d", r2->stream, r2->state); - Lck_Unlock(&sp->mtx); h2->cond = NULL; h2_del_req(wrk, h2->req0); } From phk at FreeBSD.org Mon Apr 10 11:59:07 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 10 Apr 2017 13:59:07 +0200 Subject: [5.1] ad75b0e Add an assert so silly buggers who are to busy to check the arguments Lck_CondWait() will stopped in the tracks. Message-ID: commit ad75b0e43077b4c0be78729abf126646a8b361a9 Author: Poul-Henning Kamp Date: Wed Mar 29 17:45:03 2017 +0000 Add an assert so silly buggers who are to busy to check the arguments Lck_CondWait() will stopped in the tracks. diff --git a/bin/varnishd/cache/cache_lck.c b/bin/varnishd/cache/cache_lck.c index 4081d60..609971a 100644 --- a/bin/varnishd/cache/cache_lck.c +++ b/bin/varnishd/cache/cache_lck.c @@ -199,6 +199,7 @@ Lck_CondWait(pthread_cond_t *cond, struct lock *lck, double when) if (when == 0) { AZ(pthread_cond_wait(cond, &ilck->mtx)); } else { + assert(when > 1e9); ts.tv_nsec = (long)(modf(when, &t) * 1e9); ts.tv_sec = (long)t; retval = pthread_cond_timedwait(cond, &ilck->mtx, &ts); From phk at FreeBSD.org Mon Apr 10 11:59:07 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 10 Apr 2017 13:59:07 +0200 Subject: [5.1] 9042625 This silly bugger has now checked the arguments to Lck_CondWait() Message-ID: commit 90426253ab8f9fe706bce4f3d3d7e3da52b40583 Author: Poul-Henning Kamp Date: Wed Mar 29 17:46:05 2017 +0000 This silly bugger has now checked the arguments to Lck_CondWait() diff --git a/bin/varnishd/http2/cache_http2_session.c b/bin/varnishd/http2/cache_http2_session.c index 3725586..c1dee52 100644 --- a/bin/varnishd/http2/cache_http2_session.c +++ b/bin/varnishd/http2/cache_http2_session.c @@ -38,6 +38,7 @@ #include "http2/cache_http2.h" #include "vend.h" +#include "vtim.h" static const char h2_resp_101[] = "HTTP/1.1 101 Switching Protocols\r\n" @@ -340,7 +341,7 @@ h2_new_session(struct worker *wrk, void *arg) VTAILQ_FOREACH(r2, &h2->streams, list) VSLb(h2->vsl, SLT_Debug, "ST %u %d", r2->stream, r2->state); Lck_Lock(&h2->sess->mtx); - (void)Lck_CondWait(h2->cond, &h2->sess->mtx, .1); + (void)Lck_CondWait(h2->cond, &h2->sess->mtx, VTIM_real() + .1); Lck_Unlock(&h2->sess->mtx); } h2->cond = NULL; From phk at FreeBSD.org Mon Apr 10 11:59:07 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 10 Apr 2017 13:59:07 +0200 Subject: [5.1] c737577 Straighten out the HPACK error path. Message-ID: commit c73757749d29af793f470c97d2846629256448a3 Author: Poul-Henning Kamp Date: Wed Mar 29 18:55:42 2017 +0000 Straighten out the HPACK error path. Fixes #2289 diff --git a/bin/varnishd/http2/cache_http2_hpack.c b/bin/varnishd/http2/cache_http2_hpack.c index 4b0a1ce..9bcc1dd 100644 --- a/bin/varnishd/http2/cache_http2_hpack.c +++ b/bin/varnishd/http2/cache_http2_hpack.c @@ -49,7 +49,7 @@ h2h_checkhdr(const struct http *hp, const char *b, size_t namelen, size_t len) if (namelen == 2) { VSLb(hp->vsl, SLT_BogoHeader, "Empty name"); - return (H2CE_PROTOCOL_ERROR); + return (H2SE_PROTOCOL_ERROR); } for (p = b; p < b + len; p++) { @@ -61,7 +61,7 @@ h2h_checkhdr(const struct http *hp, const char *b, size_t namelen, size_t len) VSLb(hp->vsl, SLT_BogoHeader, "Illegal header name (upper-case): %.*s", (int)(len > 20 ? 20 : len), b); - return (H2CE_PROTOCOL_ERROR); + return (H2SE_PROTOCOL_ERROR); } if (vct_istchar(*p)) { /* XXX: vct should have a proper class for @@ -71,7 +71,7 @@ h2h_checkhdr(const struct http *hp, const char *b, size_t namelen, size_t len) VSLb(hp->vsl, SLT_BogoHeader, "Illegal header name: %.*s", (int)(len > 20 ? 20 : len), b); - return (H2CE_PROTOCOL_ERROR); + return (H2SE_PROTOCOL_ERROR); } else if (p < b + namelen) { /* ': ' added by us */ assert(*p == ':' || *p == ' '); @@ -82,7 +82,7 @@ h2h_checkhdr(const struct http *hp, const char *b, size_t namelen, size_t len) VSLb(hp->vsl, SLT_BogoHeader, "Illegal header value: %.*s", (int)(len > 20 ? 20 : len), b); - return (H2CE_PROTOCOL_ERROR); + return (H2SE_PROTOCOL_ERROR); } } @@ -134,7 +134,7 @@ h2h_addhdr(struct http *hp, char *b, size_t namelen, size_t len) VSLb(hp->vsl, SLT_BogoHeader, "Unknown pseudo-header: %.*s", (int)(len > 20 ? 20 : len), b); - return (H2SE_PROTOCOL_ERROR); + return (H2SE_PROTOCOL_ERROR); // rfc7540,l,2990,2992 } } else n = hp->nhd; @@ -145,7 +145,7 @@ h2h_addhdr(struct http *hp, char *b, size_t namelen, size_t len) VSLb(hp->vsl, SLT_BogoHeader, "Duplicate pseudo-header: %.*s", (int)(len > 20 ? 20 : len), b); - return (H2SE_PROTOCOL_ERROR); + return (H2SE_PROTOCOL_ERROR); // rfc7540,l,3158,3162 } } else { /* Check for space in struct http */ diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index 1a85b1e..5e34543 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -469,7 +469,6 @@ h2_do_req(struct worker *wrk, void *priv) THR_SetRequest(req); req->http->conds = 1; if (CNT_Request(wrk, req) != REQ_FSM_DISEMBARK) { - VSL(SLT_Debug, 0, "H2REQ CNT done"); AZ(req->ws->r); r2->scheduled = 0; r2->state = H2_S_CLOSED; @@ -491,7 +490,7 @@ h2_end_headers(struct worker *wrk, const struct h2_sess *h2, FREE_OBJ(r2->decode); r2->state = H2_S_CLOS_REM; if (h2e != NULL) { - VSL(SLT_Debug, 0, "H2H_DECODE_FINI %s", h2e->name); + VSLb(h2->vsl, SLT_Debug, "HPACK/FINI %s", h2e->name); AZ(r2->req->ws->r); h2_del_req(wrk, r2); return (h2e); @@ -558,12 +557,12 @@ h2_rx_headers(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) p += 1; } if (h2->rxf_flags & H2FF_HEADERS_PRIORITY) { - p += 5; l -= 5; + p += 5; } h2e = h2h_decode_bytes(h2, r2->decode, p, l); if (h2e != NULL) { - VSL(SLT_Debug, 0, "H2H_DECODE_BYTES(hdr) %s", h2e->name); + VSLb(h2->vsl, SLT_Debug, "HPACK(hdr) %s", h2e->name); (void)h2h_decode_fini(h2, r2->decode); AZ(r2->req->ws->r); h2_del_req(wrk, r2); @@ -590,7 +589,7 @@ h2_rx_continuation(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) req = r2->req; h2e = h2h_decode_bytes(h2, r2->decode, h2->rxf_data, h2->rxf_len); if (h2e != NULL) { - VSL(SLT_Debug, 0, "H2H_DECODE_BYTES(cont) %s", h2e->name); + VSLb(h2->vsl, SLT_Debug, "HPACK(cont) %s", h2e->name); (void)h2h_decode_fini(h2, r2->decode); AZ(r2->req->ws->r); h2_del_req(wrk, r2); @@ -733,7 +732,6 @@ h2_frame_complete(struct http_conn *htc) if (l < 9) return (HTC_S_MORE); u = vbe32dec(htc->rxbuf_b) >> 8; - VSL(SLT_Debug, 0, "RX %p %d %u", htc->rxbuf_b, l, u); if (l < u + 9) // XXX: Only for !DATA frames return (HTC_S_MORE); return (HTC_S_COMPLETE); @@ -792,12 +790,11 @@ h2_procframe(struct worker *wrk, struct h2_sess *h2, VSLb(h2->vsl, SLT_Debug, "H2: stream %u: %s", h2->rxf_stream, h2e->txt); vbe32enc(b, h2e->val); - H2_Send_Get(wrk, h2, r2); + H2_Send_Get(wrk, h2, h2->req0); (void)H2_Send_Frame(wrk, h2, H2_F_RST_STREAM, 0, sizeof b, h2->rxf_stream, b); - H2_Send_Rel(h2, r2); + H2_Send_Rel(h2, h2->req0); - h2_del_req(wrk, r2); return (0); } diff --git a/bin/varnishtest/tests/t02003.vtc b/bin/varnishtest/tests/t02003.vtc index b2e964f..eef69e2 100644 --- a/bin/varnishtest/tests/t02003.vtc +++ b/bin/varnishtest/tests/t02003.vtc @@ -349,6 +349,14 @@ client c1 { } -run } -run +client c1 { + stream 1 { + txreq -hdr ":bla" "foo" + rxrst + expect rst.err == PROTOCOL_ERROR + } -run +} -run + varnish v1 -vsl_catchup varnish v1 -expect MEMPOOL.req0.live == 0 From phk at FreeBSD.org Mon Apr 10 11:59:07 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 10 Apr 2017 13:59:07 +0200 Subject: [5.1] 3db481a A *little* bit more coverage Message-ID: commit 3db481a96f55ecff21983c09c644f578ac507b1f Author: Poul-Henning Kamp Date: Thu Mar 30 07:23:20 2017 +0000 A *little* bit more coverage diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index 5e34543..4441406 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -767,10 +767,10 @@ h2_procframe(struct worker *wrk, struct h2_sess *h2, } VTAILQ_FOREACH_SAFE(r2, &h2->streams, list, r22) { - if (r2->stream == h2->rxf_stream) - break; if (r2->state == H2_S_CLOSED && !r2->scheduled) h2_del_req(wrk, r2); + else if (r2->stream == h2->rxf_stream) + break; } if (r2 == NULL && h2f->act_sidle == 0) { diff --git a/bin/varnishtest/tests/t02003.vtc b/bin/varnishtest/tests/t02003.vtc index eef69e2..db5fb31 100644 --- a/bin/varnishtest/tests/t02003.vtc +++ b/bin/varnishtest/tests/t02003.vtc @@ -228,6 +228,18 @@ client c1 { } -run } -run +client c1 { + stream 1 { + txreq + rxresp + } -run + stream 1 { + # RST_STREAM on closed stream + txrst + } -run +} -run + + varnish v1 -vsl_catchup varnish v1 -expect MEMPOOL.req0.live == 0 From martin at varnish-software.com Mon Apr 10 11:59:07 2017 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Mon, 10 Apr 2017 13:59:07 +0200 Subject: [5.1] 5dd70af Set the go-cold timer on newly loaded warm auto VCLs Message-ID: commit 5dd70aff3e968f173d3b747b1d1a2bb805be5f6f Author: Martin Blix Grydeland Date: Wed Mar 22 10:59:54 2017 +0100 Set the go-cold timer on newly loaded warm auto VCLs Newly loaded VCLs didn't get their go cold timer set even when they were set to auto, causing them to never go cold automatically. Fixes: #2270 diff --git a/bin/varnishd/mgt/mgt_vcl.c b/bin/varnishd/mgt/mgt_vcl.c index 8849752..9a1a42b 100644 --- a/bin/varnishd/mgt/mgt_vcl.c +++ b/bin/varnishd/mgt/mgt_vcl.c @@ -481,8 +481,13 @@ mgt_new_vcl(struct cli *cli, const char *vclname, const char *vclsrc, mgt_vcl_del(vp); VCLI_Out(cli, "%s", p); VCLI_SetResult(cli, status); + free(p); + return; } free(p); + + if (vp->warm && !strcmp(vp->state, "auto")) + vp->go_cold = VTIM_mono(); } /*--------------------------------------------------------------------*/ diff --git a/bin/varnishtest/tests/r02270.vtc b/bin/varnishtest/tests/r02270.vtc new file mode 100644 index 0000000..8547ca5 --- /dev/null +++ b/bin/varnishtest/tests/r02270.vtc @@ -0,0 +1,19 @@ +varnishtest "Test that never used VCLs go cold automatically" + +server s1 { + rxreq + txresp +} -start + +varnish v1 -arg "-p vcl_cooldown=1" -vcl+backend { +} -start + +varnish v1 -expect VBE.vcl1.s1.happy >= 0 + +varnish v1 -cliok {vcl.inline vcl2 "vcl 4.0; backend s1 {.host = \"${s1_addr}\"; .port = \"${s1_port}\"; }"} + +varnish v1 -expect VBE.vcl2.s1.happy >= 0 + +delay 5 + +varnish v1 -expect !VBE.vcl2.s1.happy From dridi.boukelmoune at gmail.com Mon Apr 10 11:59:07 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 10 Apr 2017 13:59:07 +0200 Subject: [5.1] 5087989 Teach http_CollectHdr to use arbitrary separators Message-ID: commit 5087989e7bd1afa01d02552fcfe7284609d7d5fd Author: Dridi Boukelmoune Date: Thu Mar 30 14:53:43 2017 +0200 Teach http_CollectHdr to use arbitrary separators This done via a new http_CollectHdrSep function, implying a VRT minor bump. Refs #2291 diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index cfed8b4..5bc79d7 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -783,6 +783,7 @@ void http_CopyHome(const struct http *hp); void http_Unset(struct http *hp, const char *hdr); unsigned http_CountHdr(const struct http *hp, const char *hdr); void http_CollectHdr(struct http *hp, const char *hdr); +void http_CollectHdrSep(struct http *hp, const char *hdr, const char *sep); void http_VSL_log(const struct http *hp); void HTTP_Merge(struct worker *, struct objcore *, struct http *to); uint16_t HTTP_GetStatusPack(struct worker *, struct objcore *oc); diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c index 0c1487d..8ad5ea8 100644 --- a/bin/varnishd/cache/cache_http.c +++ b/bin/varnishd/cache/cache_http.c @@ -1,6 +1,6 @@ /*- * Copyright (c) 2006 Verdens Gang AS - * Copyright (c) 2006-2015 Varnish Software AS + * Copyright (c) 2006-2017 Varnish Software AS * All rights reserved. * * Author: Poul-Henning Kamp @@ -328,12 +328,30 @@ http_CountHdr(const struct http *hp, const char *hdr) void http_CollectHdr(struct http *hp, const char *hdr) { - unsigned u, l, ml, f, x, d; + + http_CollectHdrSep(hp, hdr, NULL); +} + +/*-------------------------------------------------------------------- + * You may prefer to collapse header fields using a different separator. + * For Cookie headers, the separator is "; " for example. That's probably + * the only example too. + */ + +void +http_CollectHdrSep(struct http *hp, const char *hdr, const char *sep) +{ + unsigned u, l, lsep, ml, f, x, d; char *b = NULL, *e = NULL; CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC); if (WS_Overflowed(hp->ws)) return; + + if (sep == NULL || *sep == '\0') + sep = ","; + lsep = strlen(sep); + l = hdr[0]; assert(l == strlen(hdr + 1)); assert(hdr[l] == ':'); @@ -371,15 +389,15 @@ http_CollectHdr(struct http *hp, const char *hdr) AN(e); /* Append the Nth header we found */ - if (b < e) - *b++ = ','; x = Tlen(hp->hd[u]) - l; - if (b + x >= e) { + if (b + lsep + x >= e) { http_fail(hp); VSLb(hp->vsl, SLT_LostHeader, "%s", hdr + 1); WS_Release(hp->ws, 0); return; } + memcpy(b, sep, lsep); + b += lsep; memcpy(b, hp->hd[u].b + *hdr, x); b += x; } diff --git a/include/vrt.h b/include/vrt.h index d8e4b4e..ef5204a 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -39,6 +39,8 @@ * binary/load-time compatible, increment MAJOR version * * + * 6.1 (unreleased): + * http_CollectHdrSep added * 6.0 (2017-03-15): * VRT_hit_for_pass added * VRT_ipcmp added From dridi.boukelmoune at gmail.com Mon Apr 10 11:59:07 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 10 Apr 2017 13:59:07 +0200 Subject: [5.1] d26a828 Collapse Cookie headers in HTTP/2 Message-ID: commit d26a828751ac8a49b04774a2014228de4e76205d Author: Dridi Boukelmoune Date: Thu Mar 30 14:58:58 2017 +0200 Collapse Cookie headers in HTTP/2 Fixes #2291 diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 3963625..aa8e1d7 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -1,6 +1,6 @@ /*- * Copyright (c) 2006 Verdens Gang AS - * Copyright (c) 2006-2015 Varnish Software AS + * Copyright (c) 2006-2017 Varnish Software AS * All rights reserved. * * Author: Poul-Henning Kamp @@ -799,6 +799,9 @@ cnt_recv(struct worker *wrk, struct req *req) http_CollectHdr(req->http, H_Cache_Control); + if (req->http->protover == 20) // rfc7540,l,3114,3120 + http_CollectHdrSep(req->http, H_Cookie, "; "); + if (req->req_body_status == REQ_BODY_FAIL) { req->doclose = SC_OVERLOAD; return (REQ_FSM_DONE); diff --git a/bin/varnishtest/tests/r02291.vtc b/bin/varnishtest/tests/r02291.vtc new file mode 100644 index 0000000..25659dd --- /dev/null +++ b/bin/varnishtest/tests/r02291.vtc @@ -0,0 +1,33 @@ +varnishtest "Collect cookie headers in HTTP/2" + +server s1 -repeat 2 { + rxreq + txresp +} -start + +varnish v1 -vcl+backend { } -start +varnish v1 -cliok "param.set feature +http2" + +logexpect l1 -v v1 { + expect * * BereqProtocol HTTP/1.1 + expect * = BereqHeader "Cookie: user=alice" + expect * = BereqHeader "Cookie: peer=bob" + expect * * BereqProtocol HTTP/2.0 + expect * = BereqHeader "cookie: user=alice; peer=bob" +} -start + +client c1 { + txreq -hdr "Cookie: user=alice" -hdr "Cookie: peer=bob" + rxresp + expect resp.status == 200 +} -run + +client c2 { + stream 1 { + txreq -hdr cookie user=alice -hdr cookie peer=bob + rxresp + expect resp.status == 200 + } -run +} -run + +logexpect l1 -wait From dridi.boukelmoune at gmail.com Mon Apr 10 11:59:07 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 10 Apr 2017 13:59:07 +0200 Subject: [5.1] 58b2d30 Grow a separator argument in std.collect Message-ID: commit 58b2d3061bd2e2bc9a8f45729e4fb1c2e6dc6ccb Author: Dridi Boukelmoune Date: Thu Mar 30 15:56:36 2017 +0200 Grow a separator argument in std.collect Fixes #2292 diff --git a/lib/libvmod_std/vmod.vcc b/lib/libvmod_std/vmod.vcc index 61eed10..ab1741d 100644 --- a/lib/libvmod_std/vmod.vcc +++ b/lib/libvmod_std/vmod.vcc @@ -1,5 +1,5 @@ #- -# Copyright (c) 2010-2015 Varnish Software AS +# Copyright (c) 2010-2017 Varnish Software AS # All rights reserved. # # Author: Poul-Henning Kamp @@ -107,17 +107,19 @@ Description Example set beresp.http.served-by = std.fileread("/etc/hostname"); -$Function VOID collect(HEADER hdr) +$Function VOID collect(HEADER hdr, STRING sep=",") Description Collapses multiple *hdr* headers into one long header. - The header values are joined with a comma (","). + The header values are joined with a comma (",") unless a + different separator is specified. Care should be taken when collapsing headers. In particular collapsing Set-Cookie will lead to unexpected results on the browser side. -Example - std.collect(req.http.cookie); +Examples + std.collect(req.http.accept); + std.collect(req.http.cookie, "; "); $Function DURATION duration(STRING s, DURATION fallback) diff --git a/lib/libvmod_std/vmod_std.c b/lib/libvmod_std/vmod_std.c index 557e88d..601de8b 100644 --- a/lib/libvmod_std/vmod_std.c +++ b/lib/libvmod_std/vmod_std.c @@ -1,5 +1,5 @@ /*- - * Copyright (c) 2010-2015 Varnish Software AS + * Copyright (c) 2010-2017 Varnish Software AS * All rights reserved. * * Author: Poul-Henning Kamp @@ -174,13 +174,13 @@ vmod_syslog(VRT_CTX, VCL_INT fac, const char *fmt, ...) } VCL_VOID __match_proto__(td_std_collect) -vmod_collect(VRT_CTX, VCL_HEADER hdr) +vmod_collect(VRT_CTX, VCL_HEADER hdr, VCL_STRING sep) { struct http *hp; CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); hp = VRT_selecthttp(ctx, hdr->where); - http_CollectHdr(hp, hdr->what); + http_CollectHdrSep(hp, hdr->what, sep); } VCL_BOOL __match_proto__(td_std_healthy) From dridi.boukelmoune at gmail.com Mon Apr 10 11:59:07 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 10 Apr 2017 13:59:07 +0200 Subject: [5.1] eadcc45 Ignore leading spaces in http_CollectHdr Message-ID: commit eadcc45ee781f54bdd8e41e5cefea001132114da Author: Dridi Boukelmoune Date: Thu Mar 30 16:18:54 2017 +0200 Ignore leading spaces in http_CollectHdr The default separator is now ", " to maintain the "pretty collapsing" of the headers without risking an extra space with the "; " separator for cookies. Refs #2291 Refs #2292 diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c index 8ad5ea8..5d900bf 100644 --- a/bin/varnishd/cache/cache_http.c +++ b/bin/varnishd/cache/cache_http.c @@ -343,13 +343,14 @@ http_CollectHdrSep(struct http *hp, const char *hdr, const char *sep) { unsigned u, l, lsep, ml, f, x, d; char *b = NULL, *e = NULL; + const char *v; CHECK_OBJ_NOTNULL(hp, HTTP_MAGIC); if (WS_Overflowed(hp->ws)) return; if (sep == NULL || *sep == '\0') - sep = ","; + sep = ", "; lsep = strlen(sep); l = hdr[0]; @@ -390,6 +391,13 @@ http_CollectHdrSep(struct http *hp, const char *hdr, const char *sep) /* Append the Nth header we found */ x = Tlen(hp->hd[u]) - l; + + v = hp->hd[u].b + *hdr; + while (vct_issp(*v)) { + v++; + x--; + } + if (b + lsep + x >= e) { http_fail(hp); VSLb(hp->vsl, SLT_LostHeader, "%s", hdr + 1); @@ -398,7 +406,7 @@ http_CollectHdrSep(struct http *hp, const char *hdr, const char *sep) } memcpy(b, sep, lsep); b += lsep; - memcpy(b, hp->hd[u].b + *hdr, x); + memcpy(b, v, x); b += x; } if (b == NULL) diff --git a/bin/varnishtest/tests/r02291.vtc b/bin/varnishtest/tests/r02291.vtc index 25659dd..3a02360 100644 --- a/bin/varnishtest/tests/r02291.vtc +++ b/bin/varnishtest/tests/r02291.vtc @@ -13,7 +13,7 @@ logexpect l1 -v v1 { expect * = BereqHeader "Cookie: user=alice" expect * = BereqHeader "Cookie: peer=bob" expect * * BereqProtocol HTTP/2.0 - expect * = BereqHeader "cookie: user=alice; peer=bob" + expect * = BereqHeader "cookie: user=alice; peer=bob" } -start client c1 { diff --git a/lib/libvmod_std/vmod.vcc b/lib/libvmod_std/vmod.vcc index ab1741d..d4a4381 100644 --- a/lib/libvmod_std/vmod.vcc +++ b/lib/libvmod_std/vmod.vcc @@ -107,7 +107,7 @@ Description Example set beresp.http.served-by = std.fileread("/etc/hostname"); -$Function VOID collect(HEADER hdr, STRING sep=",") +$Function VOID collect(HEADER hdr, STRING sep=", ") Description Collapses multiple *hdr* headers into one long header. From dridi.boukelmoune at gmail.com Mon Apr 10 11:59:07 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 10 Apr 2017 13:59:07 +0200 Subject: [5.1] 99efebb Coverage for std.collect Message-ID: commit 99efebb3c986aebf313c1f2ad43dddbfa4c07159 Author: Dridi Boukelmoune Date: Thu Mar 30 16:32:26 2017 +0200 Coverage for std.collect Refs #2291 Refs #2292 diff --git a/bin/varnishtest/tests/m00006.vtc b/bin/varnishtest/tests/m00006.vtc index 2afad24..24ad5f9 100644 --- a/bin/varnishtest/tests/m00006.vtc +++ b/bin/varnishtest/tests/m00006.vtc @@ -20,7 +20,7 @@ varnish v1 -vcl+backend { std.collect(beresp.http.bar); } sub vcl_deliver { - std.collect(resp.http.qux); + std.collect(resp.http.qux, "; "); } } -start @@ -28,5 +28,5 @@ client c1 { txreq -hdr "Foo: 1" -hdr "Foo: 2" -hdr "Baz: 3" -hdr "Baz: 4" rxresp expect resp.http.bar == "a, b" - expect resp.http.qux == "c, d" + expect resp.http.qux == "c; d" } -run From dridi.boukelmoune at gmail.com Mon Apr 10 11:59:07 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 10 Apr 2017 13:59:07 +0200 Subject: [5.1] 84e98d8 Improve documentation for std.collect Message-ID: commit 84e98d8d0d5c922805bcd47e29a48580d026fc22 Author: Dridi Boukelmoune Date: Fri Mar 31 09:12:27 2017 +0200 Improve documentation for std.collect diff --git a/lib/libvmod_std/vmod.vcc b/lib/libvmod_std/vmod.vcc index d4a4381..2ebfb45 100644 --- a/lib/libvmod_std/vmod.vcc +++ b/lib/libvmod_std/vmod.vcc @@ -110,16 +110,17 @@ Example $Function VOID collect(HEADER hdr, STRING sep=", ") Description - Collapses multiple *hdr* headers into one long header. - The header values are joined with a comma (",") unless a - different separator is specified. + Collapses multiple *hdr* headers into one long header. The + default separator *sep* is the standard comma separator to + use when collapsing headers, with an additional whitespace + for pretty printing. Care should be taken when collapsing headers. In particular collapsing Set-Cookie will lead to unexpected results on the browser side. Examples - std.collect(req.http.accept); - std.collect(req.http.cookie, "; "); + | std.collect(req.http.accept); + | std.collect(req.http.cookie, "; "); $Function DURATION duration(STRING s, DURATION fallback) From nils.goroll at uplex.de Mon Apr 10 11:59:07 2017 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 10 Apr 2017 13:59:07 +0200 Subject: [5.1] b758894 try to stabilize this test for make -j80 check Message-ID: commit b758894297ec967f33fe9fd6af90fcd9ff342313 Author: Nils Goroll Date: Fri Mar 31 17:11:23 2017 +0200 try to stabilize this test for make -j80 check diff --git a/bin/varnishtest/tests/r01490.vtc b/bin/varnishtest/tests/r01490.vtc index 76b32be..88c2550 100644 --- a/bin/varnishtest/tests/r01490.vtc +++ b/bin/varnishtest/tests/r01490.vtc @@ -13,6 +13,8 @@ varnish v1 \ -vcl+backend {} varnish v1 -start +delay 2 + varnish v1 -expect threads == 2 logexpect l1 -v v1 -g raw { From phk at FreeBSD.org Mon Apr 10 11:59:08 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 10 Apr 2017 13:59:08 +0200 Subject: [5.1] 7179b96 Tempt fate and try to make getopt() error strings part of our tests, in order to have less ambiguous error messages. Message-ID: commit 7179b965ff398f6726ff3bb97e878dd388356905 Author: Poul-Henning Kamp Date: Sun Apr 2 19:57:02 2017 +0000 Tempt fate and try to make getopt() error strings part of our tests, in order to have less ambiguous error messages. diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c index 1c45b32..2d3a9dc 100644 --- a/bin/varnishd/mgt/mgt_main.c +++ b/bin/varnishd/mgt/mgt_main.c @@ -530,12 +530,9 @@ main(int argc, char * const *argv) do { switch (o) { case '?': - if (optopt == '?') { + if (optopt == '?') usage(); - exit(1); - } - ARGV_ERR("Option '%c' unknown.\n", - optopt); + exit(2); case 'V': case 'x': ARGV_ERR("-%c must be the first argument\n", o); diff --git a/bin/varnishtest/tests/a00009.vtc b/bin/varnishtest/tests/a00009.vtc index abe4c85..e4d0aa6 100644 --- a/bin/varnishtest/tests/a00009.vtc +++ b/bin/varnishtest/tests/a00009.vtc @@ -11,7 +11,10 @@ shell -err -expect {-V must be the first argument} "varnishd -d -V foo " shell -err -expect {Too many arguments for -x} "varnishd -x foo bar" shell -err -expect {Invalid -x argument} "varnishd -x foo " -shell -err -expect {Option 'A' unknown.} "varnishd -A " + +# This one is tricky, the getopt message on stderr is not standardized. +shell -err -expect {option --} "varnishd -A " + shell -err -expect {Usage: varnishd [options]} "varnishd -? " shell -err -expect {Too many arguments} "varnishd foo " From phk at FreeBSD.org Mon Apr 10 11:59:08 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 10 Apr 2017 13:59:08 +0200 Subject: [5.1] 06c83b9 Pass sensible maxlengths to HTC_RxStuff() and document how the workspace_client parameter influences H2 traffic. Message-ID: commit 06c83b96bbb9dc387b5eed9b9065e93ad33021a8 Author: Poul-Henning Kamp Date: Sun Apr 2 19:58:11 2017 +0000 Pass sensible maxlengths to HTC_RxStuff() and document how the workspace_client parameter influences H2 traffic. diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index 4441406..ab0f28d 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -827,7 +827,7 @@ h2_rxframe(struct worker *wrk, struct h2_sess *h2) hs = HTC_RxStuff(h2->htc, h2_frame_complete, NULL, NULL, NAN, h2->sess->t_idle + cache_param->timeout_idle + 100, - 1024); + 16384 + 9); // rfc7540,l,4228,4228 if (hs != HTC_S_COMPLETE) { Lck_Lock(&h2->sess->mtx); VSLb(h2->vsl, SLT_Debug, "H2: No frame (hs=%d)", hs); diff --git a/bin/varnishd/http2/cache_http2_session.c b/bin/varnishd/http2/cache_http2_session.c index c1dee52..0dbb541 100644 --- a/bin/varnishd/http2/cache_http2_session.c +++ b/bin/varnishd/http2/cache_http2_session.c @@ -238,7 +238,8 @@ h2_ou_session(struct worker *wrk, struct h2_sess *h2, /* Wait for PRISM response */ hs = HTC_RxStuff(h2->htc, H2_prism_complete, - NULL, NULL, NAN, h2->sess->t_idle + cache_param->timeout_idle, 256); + NULL, NULL, NAN, h2->sess->t_idle + cache_param->timeout_idle, + sizeof H2_prism); if (hs != HTC_S_COMPLETE) { VSLb(h2->vsl, SLT_Debug, "H2: No/Bad OU PRISM (hs=%d)", hs); h2_del_req(wrk, r2); diff --git a/include/tbl/params.h b/include/tbl/params.h index f66ffd1..a44b625 100644 --- a/include/tbl/params.h +++ b/include/tbl/params.h @@ -1611,7 +1611,11 @@ PARAM( /* flags */ DELAYED_EFFECT, /* s-text */ "Bytes of HTTP protocol workspace for clients HTTP req/resp. Use a " - "multiple of 4k for VM efficiency.", + "multiple of 4k for VM efficiency.\n" + "For HTTP/2 compliance this must be at least 20k, in order to " + "receive fullsize (=16k) frames from the client. That usually " + "happens only in POST/PUT bodies. For other traffic-patterns " + "smaller values work just fine.", /* l-text */ "", /* func */ NULL ) From phk at FreeBSD.org Mon Apr 10 11:59:08 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 10 Apr 2017 13:59:08 +0200 Subject: [5.1] 3f4a5a1 Don't panic if return(pass(DURATION)) is used on client side. Ignore the argument with a VSL message. Message-ID: commit 3f4a5a1bc3f7ce22136f161149854e483d3478b6 Author: Poul-Henning Kamp Date: Mon Apr 3 06:33:22 2017 +0000 Don't panic if return(pass(DURATION)) is used on client side. Ignore the argument with a VSL message. Fixes: #2299 diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c index efc877f..a8100b3 100644 --- a/bin/varnishd/cache/cache_vrt.c +++ b/bin/varnishd/cache/cache_vrt.c @@ -91,6 +91,11 @@ VRT_hit_for_pass(VRT_CTX, VCL_DURATION d) struct objcore *oc; CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + if (ctx->bo == NULL) { + VSLb(ctx->vsl, SLT_Error, + "Note: Ignoring DURATION argument to return(pass);"); + return; + } CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC); oc = ctx->bo->fetch_objcore; oc->ttl = d; diff --git a/bin/varnishtest/tests/c00010.vtc b/bin/varnishtest/tests/c00010.vtc index 5e8b087..a128b73 100644 --- a/bin/varnishtest/tests/c00010.vtc +++ b/bin/varnishtest/tests/c00010.vtc @@ -17,7 +17,7 @@ varnish v1 -vcl+backend { if (req.url == "/foo") { return(hash); } else { - return(pass); + return(pass(10m)); } } sub vcl_hit { From phk at FreeBSD.org Mon Apr 10 11:59:08 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 10 Apr 2017 13:59:08 +0200 Subject: [5.1] 20adece Move the responsibility for NUL terminating the RX buffer into the completion function. Message-ID: commit 20adece32a54597c21ac5874dcf9a7dd76f242bc Author: Poul-Henning Kamp Date: Mon Apr 3 08:28:56 2017 +0000 Move the responsibility for NUL terminating the RX buffer into the completion function. Fixes #2285 diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c index e36c9e3..02e1059 100644 --- a/bin/varnishd/cache/cache_session.c +++ b/bin/varnishd/cache/cache_session.c @@ -237,7 +237,7 @@ HTC_RxStuff(struct http_conn *htc, htc_complete_f *func, double tmo; double now; enum htc_status_e hs; - int i; + ssize_t z; CHECK_OBJ_NOTNULL(htc, HTTP_CONN_MAGIC); AN(htc->rfd); @@ -255,15 +255,16 @@ HTC_RxStuff(struct http_conn *htc, htc_complete_f *func, WS_ReleaseP(htc->ws, htc->rxbuf_b); return (HTC_S_OVERFLOW); } - if ((htc->ws->r - htc->rxbuf_b) - 1L < maxbytes) - maxbytes = (htc->ws->r - htc->rxbuf_b) - 1L; /* Space for NUL */ + z = (htc->ws->r - htc->rxbuf_b); + if (z < maxbytes) + maxbytes = z; while (1) { now = VTIM_real(); AZ(htc->pipeline_b); AZ(htc->pipeline_e); - assert(htc->rxbuf_e < htc->ws->r); - *htc->rxbuf_e = '\0'; + assert(htc->rxbuf_e <= htc->ws->r); + hs = func(htc); if (hs == HTC_S_OVERFLOW || hs == HTC_S_JUNK) { WS_ReleaseP(htc->ws, htc->rxbuf_b); @@ -290,21 +291,21 @@ HTC_RxStuff(struct http_conn *htc, htc_complete_f *func, tmo = tn - now; if (!isnan(ti) && ti < tn) tmo = ti - now; - i = maxbytes - (htc->rxbuf_e - htc->rxbuf_b); - assert(i >= 0); - if (i == 0) { + z = maxbytes - (htc->rxbuf_e - htc->rxbuf_b); + assert(z >= 0); + if (z == 0) { WS_ReleaseP(htc->ws, htc->rxbuf_b); return (HTC_S_OVERFLOW); } if (tmo <= 0.0) tmo = 1e-3; - i = VTCP_read(*htc->rfd, htc->rxbuf_e, i, tmo); - if (i == 0 || i == -1) { + z = VTCP_read(*htc->rfd, htc->rxbuf_e, z, tmo); + if (z == 0 || z == -1) { WS_ReleaseP(htc->ws, htc->rxbuf_b); return (HTC_S_EOF); - } else if (i > 0) - htc->rxbuf_e += i; - else if (i == -2) { + } else if (z > 0) + htc->rxbuf_e += z; + else if (z == -2) { 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_proto.c b/bin/varnishd/http1/cache_http1_proto.c index 05d23b3..2e691fd 100644 --- a/bin/varnishd/http1/cache_http1_proto.c +++ b/bin/varnishd/http1/cache_http1_proto.c @@ -73,7 +73,11 @@ HTTP1_Complete(struct http_conn *htc) CHECK_OBJ_NOTNULL(htc, HTTP_CONN_MAGIC); assert(htc->rxbuf_e >= htc->rxbuf_b); - assert(*htc->rxbuf_e == '\0'); + assert(htc->rxbuf_e <= htc->ws->r); + + if (htc->rxbuf_e == htc->ws->r) + return (HTC_S_OVERFLOW); // No space for NUL + *htc->rxbuf_e = '\0'; /* Skip any leading white space */ for (p = htc->rxbuf_b ; vct_islws(*p); p++) diff --git a/bin/varnishd/proxy/cache_proxy_proto.c b/bin/varnishd/proxy/cache_proxy_proto.c index 14e186a..d4231bc 100644 --- a/bin/varnishd/proxy/cache_proxy_proto.c +++ b/bin/varnishd/proxy/cache_proxy_proto.c @@ -297,6 +297,9 @@ vpx_complete(struct http_conn *htc) CHECK_OBJ_NOTNULL(htc, HTTP_CONN_MAGIC); + assert(htc->rxbuf_e >= htc->rxbuf_b); + assert(htc->rxbuf_e <= htc->ws->r); + l = htc->rxbuf_e - htc->rxbuf_b; p = htc->rxbuf_b; j = 0x3; @@ -308,6 +311,8 @@ vpx_complete(struct http_conn *htc) if (j == 0) return (HTC_S_JUNK); if (j == 1 && i == sizeof vpx1_sig) { + assert (htc->rxbuf_e < htc->ws->r); + *htc->rxbuf_e = '\0'; q = strchr(p + i, '\n'); if (q != NULL && (q - htc->rxbuf_b) > 107) return (HTC_S_OVERFLOW); From martin at varnish-software.com Mon Apr 10 11:59:08 2017 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Mon, 10 Apr 2017 13:59:08 +0200 Subject: [5.1] a3ab892 Add ASSERT_CLI() to a couple of backend handling functions Message-ID: commit a3ab8922eb8e665dc6f510883425897680576e4b Author: Martin Blix Grydeland Date: Fri Mar 31 11:00:03 2017 +0200 Add ASSERT_CLI() to a couple of backend handling functions VBE_Delete() and VBE_Poll() are only safe to call from the CLI handling thread. Add ASSERT_CLI() to make that explicit. diff --git a/bin/varnishd/cache/cache_backend_cfg.c b/bin/varnishd/cache/cache_backend_cfg.c index c5f3542..767a87c 100644 --- a/bin/varnishd/cache/cache_backend_cfg.c +++ b/bin/varnishd/cache/cache_backend_cfg.c @@ -194,6 +194,7 @@ VBE_Event(struct backend *be, enum vcl_event_e ev) void VBE_Delete(struct backend *be) { + ASSERT_CLI(); CHECK_OBJ_NOTNULL(be, BACKEND_MAGIC); if (be->probe != NULL) @@ -437,6 +438,7 @@ VBE_Poll(void) struct backend *be; double now = VTIM_real(); + ASSERT_CLI(); Lck_Lock(&backends_mtx); while (1) { be = VTAILQ_FIRST(&cool_backends); From martin at varnish-software.com Mon Apr 10 11:59:08 2017 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Mon, 10 Apr 2017 13:59:08 +0200 Subject: [5.1] 667256f Fix the spinlock loop in VBE_Poll Message-ID: commit 667256f191066672ec85c79e35bc9f995409c034 Author: Martin Blix Grydeland Date: Fri Mar 31 13:12:24 2017 +0200 Fix the spinlock loop in VBE_Poll VBE_Poll would not advance to test the next backend on the cooling list when the backend's n_conn is non-zero. This would create a spinlock effect, causing delays that could make the master kill the child because of CLI timeout. Fixes: #2295 diff --git a/bin/varnishd/cache/cache_backend_cfg.c b/bin/varnishd/cache/cache_backend_cfg.c index 767a87c..e4acf8a 100644 --- a/bin/varnishd/cache/cache_backend_cfg.c +++ b/bin/varnishd/cache/cache_backend_cfg.c @@ -435,15 +435,13 @@ static struct cli_proto backend_cmds[] = { void VBE_Poll(void) { - struct backend *be; + struct backend *be, *be2; double now = VTIM_real(); ASSERT_CLI(); Lck_Lock(&backends_mtx); - while (1) { - be = VTAILQ_FIRST(&cool_backends); - if (be == NULL) - break; + VTAILQ_FOREACH_SAFE(be, &cool_backends, list, be2) { + CHECK_OBJ_NOTNULL(be, BACKEND_MAGIC); if (be->cooled > now) break; if (be->n_conn > 0) diff --git a/bin/varnishtest/tests.disabled/r02295.vtc b/bin/varnishtest/tests.disabled/r02295.vtc new file mode 100644 index 0000000..f7a06e1 --- /dev/null +++ b/bin/varnishtest/tests.disabled/r02295.vtc @@ -0,0 +1,53 @@ +varnishtest "Test cooled dynamic backend clean up" + +# This test is disabled because it needs a timeout of 80 seconds (-t80 to +# varnishtest). This is because the cooled backend timeout in varnish core +# is hard coded to 60 seconds. + +server s1 { + rxreq + delay 70 + txresp +} -start + +varnish v1 -arg "-p cli_timeout=2 -p first_byte_timeout=80" -vcl { + import debug; + + backend dummy { .host = "${bad_backend}"; } + + sub vcl_init { + new s1 = debug.dyn("${s1_addr}", "${s1_port}"); + } + + sub vcl_recv { + if (req.url == "/refresh") { + s1.refresh("${s1_addr}", "${s1_port}"); + return (synth(200, "OK")); + } + } + + sub vcl_backend_fetch { + set bereq.backend = s1.backend(); + } +} -start + +client c1 { + timeout 120 + txreq + rxresp + expect resp.status == 200 +} -start + +delay 1 + +client c2 { + txreq -url /refresh + rxresp + expect resp.status == 200 +} -run + +delay 61 + +varnish v1 -cliok "ping" + +client c1 -wait From phk at FreeBSD.org Mon Apr 10 11:59:08 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 10 Apr 2017 13:59:08 +0200 Subject: [5.1] 6c9021d Add an assert to ensure that our estimate of struct http size matches the actual size later on. Message-ID: commit 6c9021d9f5ed89ebcd597d7ef144b1886e370111 Author: Poul-Henning Kamp Date: Mon Apr 3 19:18:33 2017 +0000 Add an assert to ensure that our estimate of struct http size matches the actual size later on. Inspired by: #2298 diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 5bc79d7..bc79aa3 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -749,7 +749,7 @@ void VGZ_UpdateObj(const struct vfp_ctx *, struct vgz*, enum vgz_ua_e); /* cache_http.c */ unsigned HTTP_estimate(unsigned nhttp); void HTTP_Copy(struct http *to, const struct http * const fm); -struct http *HTTP_create(void *p, uint16_t nhttp); +struct http *HTTP_create(void *p, uint16_t nhttp, unsigned); const char *http_Status2Reason(unsigned, const char **); unsigned http_EstimateWS(const struct http *fm, unsigned how); void http_PutResponse(struct http *to, const char *proto, uint16_t status, diff --git a/bin/varnishd/cache/cache_busyobj.c b/bin/varnishd/cache/cache_busyobj.c index 8fbcf43..0b9d62f 100644 --- a/bin/varnishd/cache/cache_busyobj.c +++ b/bin/varnishd/cache/cache_busyobj.c @@ -101,17 +101,17 @@ VBO_GetBusyObj(struct worker *wrk, const struct req *req) nhttp = (uint16_t)cache_param->http_max_hdr; sz = HTTP_estimate(nhttp); - bo->bereq0 = HTTP_create(p, nhttp); + bo->bereq0 = HTTP_create(p, nhttp, sz); p += sz; p = (void*)PRNDUP(p); assert(p < bo->end); - bo->bereq = HTTP_create(p, nhttp); + bo->bereq = HTTP_create(p, nhttp, sz); p += sz; p = (void*)PRNDUP(p); assert(p < bo->end); - bo->beresp = HTTP_create(p, nhttp); + bo->beresp = HTTP_create(p, nhttp, sz); p += sz; p = (void*)PRNDUP(p); assert(p < bo->end); diff --git a/bin/varnishd/cache/cache_http.c b/bin/varnishd/cache/cache_http.c index 5d900bf..d18ca52 100644 --- a/bin/varnishd/cache/cache_http.c +++ b/bin/varnishd/cache/cache_http.c @@ -147,7 +147,7 @@ HTTP_estimate(unsigned nhttp) } struct http * -HTTP_create(void *p, uint16_t nhttp) +HTTP_create(void *p, uint16_t nhttp, unsigned len) { struct http *hp; @@ -156,6 +156,7 @@ HTTP_create(void *p, uint16_t nhttp) hp->hd = (void*)(hp + 1); hp->shd = nhttp; hp->hdf = (void*)(hp->hd + nhttp); + assert((unsigned char*)p + len == hp->hdf + nhttp); return (hp); } diff --git a/bin/varnishd/cache/cache_req.c b/bin/varnishd/cache/cache_req.c index 1899bb0..b95fc9e 100644 --- a/bin/varnishd/cache/cache_req.c +++ b/bin/varnishd/cache/cache_req.c @@ -77,17 +77,17 @@ Req_New(const struct worker *wrk, struct sess *sp) nhttp = (uint16_t)cache_param->http_max_hdr; hl = HTTP_estimate(nhttp); - req->http = HTTP_create(p, nhttp); + req->http = HTTP_create(p, nhttp, hl); p += hl; p = (void*)PRNDUP(p); assert(p < e); - req->http0 = HTTP_create(p, nhttp); + req->http0 = HTTP_create(p, nhttp, hl); p += hl; p = (void*)PRNDUP(p); assert(p < e); - req->resp = HTTP_create(p, nhttp); + req->resp = HTTP_create(p, nhttp, hl); p += hl; p = (void*)PRNDUP(p); assert(p < e); From phk at FreeBSD.org Mon Apr 10 11:59:08 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 10 Apr 2017 13:59:08 +0200 Subject: [5.1] 1389fc9 Move and rename CNT_AcctLogCharge() to Req_AcctLogCharge() Message-ID: commit 1389fc9667ccd85018db2aeecaf431256f8d4d04 Author: Poul-Henning Kamp Date: Mon Apr 3 20:05:57 2017 +0000 Move and rename CNT_AcctLogCharge() to Req_AcctLogCharge() diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index bc79aa3..ee33de0 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -933,6 +933,7 @@ struct req *Req_New(const struct worker *, struct sess *); void Req_Release(struct req *); void Req_Cleanup(struct sess *sp, struct worker *wrk, struct req *req); void Req_Fail(struct req *req, enum sess_close reason); +void Req_AcctLogCharge(struct dstat *, struct req *); /* cache_req_body.c */ int VRB_Ignore(struct req *); @@ -942,7 +943,6 @@ void VRB_Free(struct req *); /* cache_req_fsm.c [CNT] */ enum req_fsm_nxt CNT_Request(struct worker *, struct req *); -void CNT_AcctLogCharge(struct dstat *, struct req *); /* cache_session.c [SES] */ void SES_Wait(struct sess *, const struct transport *); diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index 17682da..6931e16 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -199,7 +199,7 @@ ved_include(struct req *preq, const char *src, const char *host, } VRTPRIV_dynamic_kill(req->sp->privs, (uintptr_t)req); - CNT_AcctLogCharge(wrk->stats, req); + Req_AcctLogCharge(wrk->stats, req); VSL_End(req->vsl); preq->vcl = req->vcl; diff --git a/bin/varnishd/cache/cache_req.c b/bin/varnishd/cache/cache_req.c index b95fc9e..a3499ca 100644 --- a/bin/varnishd/cache/cache_req.c +++ b/bin/varnishd/cache/cache_req.c @@ -43,6 +43,32 @@ #include "vtim.h" +void +Req_AcctLogCharge(struct dstat *ds, struct req *req) +{ + struct acct_req *a; + + AN(ds); + CHECK_OBJ_NOTNULL(req, REQ_MAGIC); + + a = &req->acct; + + if (req->vsl->wid && !(req->res_mode & RES_PIPE)) { + VSLb(req->vsl, SLT_ReqAcct, "%ju %ju %ju %ju %ju %ju", + (uintmax_t)a->req_hdrbytes, + (uintmax_t)a->req_bodybytes, + (uintmax_t)(a->req_hdrbytes + a->req_bodybytes), + (uintmax_t)a->resp_hdrbytes, + (uintmax_t)a->resp_bodybytes, + (uintmax_t)(a->resp_hdrbytes + a->resp_bodybytes)); + } + +#define ACCT(foo) \ + ds->s_##foo += a->foo; \ + a->foo = 0; +#include "tbl/acct_fields_req.h" +} + /*-------------------------------------------------------------------- * Alloc/Free a request */ @@ -170,7 +196,7 @@ Req_Cleanup(struct sess *sp, struct worker *wrk, struct req *req) /* Charge and log byte counters */ if (req->vsl->wid) { - CNT_AcctLogCharge(wrk->stats, req); + Req_AcctLogCharge(wrk->stats, req); VSL_End(req->vsl); } req->req_bodybytes = 0; diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index aa8e1d7..1723bed 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -1016,29 +1016,3 @@ CNT_Request(struct worker *wrk, struct req *req) assert(nxt == REQ_FSM_DISEMBARK || req->ws->r == NULL); return (nxt); } - -void -CNT_AcctLogCharge(struct dstat *ds, struct req *req) -{ - struct acct_req *a; - - AN(ds); - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - - a = &req->acct; - - if (req->vsl->wid && !(req->res_mode & RES_PIPE)) { - VSLb(req->vsl, SLT_ReqAcct, "%ju %ju %ju %ju %ju %ju", - (uintmax_t)a->req_hdrbytes, - (uintmax_t)a->req_bodybytes, - (uintmax_t)(a->req_hdrbytes + a->req_bodybytes), - (uintmax_t)a->resp_hdrbytes, - (uintmax_t)a->resp_bodybytes, - (uintmax_t)(a->resp_hdrbytes + a->resp_bodybytes)); - } - -#define ACCT(foo) \ - ds->s_##foo += a->foo; \ - a->foo = 0; -#include "tbl/acct_fields_req.h" -} diff --git a/bin/varnishd/http1/cache_http1_fsm.c b/bin/varnishd/http1/cache_http1_fsm.c index 5bd4429..bd68ae8 100644 --- a/bin/varnishd/http1/cache_http1_fsm.c +++ b/bin/varnishd/http1/cache_http1_fsm.c @@ -197,7 +197,7 @@ http1_reembark(struct worker *wrk, struct req *req) wrk->stats->busy_killed++; AN (req->vcl); VCL_Rel(&req->vcl); - CNT_AcctLogCharge(wrk->stats, req); + Req_AcctLogCharge(wrk->stats, req); Req_Release(req); SES_Delete(sp, SC_OVERLOAD, NAN); DSL(DBG_WAITINGLIST, req->vsl->wid, "kill from waiting list"); @@ -402,7 +402,7 @@ HTTP1_Session(struct worker *wrk, struct req *req) if (hs < HTC_S_EMPTY) { req->acct.req_hdrbytes += req->htc->rxbuf_e - req->htc->rxbuf_b; - CNT_AcctLogCharge(wrk->stats, req); + Req_AcctLogCharge(wrk->stats, req); Req_Release(req); switch (hs) { case HTC_S_CLOSE: diff --git a/bin/varnishd/http2/cache_http2_session.c b/bin/varnishd/http2/cache_http2_session.c index 0dbb541..c12e2f5 100644 --- a/bin/varnishd/http2/cache_http2_session.c +++ b/bin/varnishd/http2/cache_http2_session.c @@ -205,7 +205,7 @@ h2_ou_session(struct worker *wrk, struct h2_sess *h2, VSLb(h2->vsl, SLT_Debug, "H2: Bad HTTP-Settings"); AN (req->vcl); VCL_Rel(&req->vcl); - CNT_AcctLogCharge(wrk->stats, req); + Req_AcctLogCharge(wrk->stats, req); Req_Release(req); return (0); } @@ -366,7 +366,7 @@ h2_reembark(struct worker *wrk, struct req *req) wrk->stats->busy_killed++; AN (req->vcl); VCL_Rel(&req->vcl); - CNT_AcctLogCharge(wrk->stats, req); + Req_AcctLogCharge(wrk->stats, req); Req_Release(req); DSL(DBG_WAITINGLIST, req->vsl->wid, "kill from waiting list"); usleep(10000); From phk at FreeBSD.org Mon Apr 10 11:59:08 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 10 Apr 2017 13:59:08 +0200 Subject: [5.1] 6d1fb08 Bring ESI req cleanup more in line with the other req cleanups. Message-ID: commit 6d1fb0821b012762df057f63133437bb8871f631 Author: Poul-Henning Kamp Date: Mon Apr 3 20:26:10 2017 +0000 Bring ESI req cleanup more in line with the other req cleanups. diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index 6931e16..b2d013c 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -98,18 +98,21 @@ ved_include(struct req *preq, const char *src, const char *host, struct ecx *ecx) { struct worker *wrk; + struct sess *sp; struct req *req; enum req_fsm_nxt s; CHECK_OBJ_NOTNULL(preq, REQ_MAGIC); + sp = preq->sp; + CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(ecx, ECX_MAGIC); wrk = preq->wrk; if (preq->esi_level >= cache_param->max_esi_depth) return; - req = Req_New(wrk, preq->sp); - SES_Ref(preq->sp); + req = Req_New(wrk, sp); + SES_Ref(sp); req->req_body_status = REQ_BODY_NONE; AZ(req->vsl->wid); req->vsl->wid = VXID_Get(wrk, VSL_CLIENTMARKER); @@ -158,6 +161,7 @@ ved_include(struct req *preq, const char *src, const char *host, /* Reset request to status before we started messing with it */ HTTP_Copy(req->http, req->http0); + AZ(req->vcl); req->vcl = preq->vcl; preq->vcl = NULL; @@ -189,27 +193,27 @@ ved_include(struct req *preq, const char *src, const char *host, DSL(DBG_WAITINGLIST, req->vsl->wid, "loop waiting for ESI (%d)", (int)s); assert(s == REQ_FSM_DISEMBARK); - Lck_Lock(&req->sp->mtx); + Lck_Lock(&sp->mtx); if (!ecx->woken) (void)Lck_CondWait( - &ecx->preq->wrk->cond, &req->sp->mtx, 0); - Lck_Unlock(&req->sp->mtx); + &ecx->preq->wrk->cond, &sp->mtx, 0); + Lck_Unlock(&sp->mtx); ecx->woken = 0; AZ(req->wrk); } - VRTPRIV_dynamic_kill(req->sp->privs, (uintptr_t)req); - Req_AcctLogCharge(wrk->stats, req); - VSL_End(req->vsl); + VRTPRIV_dynamic_kill(sp->privs, (uintptr_t)req); + AZ(preq->vcl); preq->vcl = req->vcl; req->vcl = NULL; req->wrk = NULL; - THR_SetRequest(preq); - SES_Rel(req->sp); + + Req_AcctLogCharge(wrk->stats, req); Req_Release(req); + SES_Rel(sp); } /*--------------------------------------------------------------------*/ From nils.goroll at uplex.de Mon Apr 10 11:59:08 2017 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 10 Apr 2017 13:59:08 +0200 Subject: [5.1] 5e4d6c8 backend probe: no need to parse a reason phrase we do not use Message-ID: commit 5e4d6c843376acc0bf14872d89a4e8bb2f77186b Author: Nils Goroll Date: Tue Apr 4 15:55:06 2017 +0200 backend probe: no need to parse a reason phrase we do not use Ref: bcdf4f12891eb7ecba395bdf268f8be4c9faa255 https://tools.ietf.org/html/rfc7230#section-3.1.2 diff --git a/bin/varnishd/cache/cache_backend_probe.c b/bin/varnishd/cache/cache_backend_probe.c index 3d5bc15..52de48f 100644 --- a/bin/varnishd/cache/cache_backend_probe.c +++ b/bin/varnishd/cache/cache_backend_probe.c @@ -369,9 +369,9 @@ vbp_poke(struct vbp_target *vt) if (p != NULL) *p = '\0'; - i = sscanf(vt->resp_buf, "HTTP/%*f %u %s", &resp, buf); + i = sscanf(vt->resp_buf, "HTTP/%*f %u ", &resp); - if ((i == 1 || i == 2) && resp == vt->exp_status) + if (i == 1 && resp == vt->exp_status) vt->happy |= 1; } From nils.goroll at uplex.de Mon Apr 10 11:59:08 2017 From: nils.goroll at uplex.de (Nils Goroll) Date: Mon, 10 Apr 2017 13:59:08 +0200 Subject: [5.1] 9f42262 backend polling: Test responses without reason, check the outcome Message-ID: commit 9f4226200ef7784b597056fbb788b57f64ca6ef3 Author: Nils Goroll Date: Tue Apr 4 16:09:59 2017 +0200 backend polling: Test responses without reason, check the outcome We expect: - two initial healthy probes (threshold - 1 = 2 by default) - eight healthy probes (explicitly checked) - five failing probes - two healthy probes To tolerate up to 500ms before cliexpect runs after the barrier was raised, we accept up to five additional failed probes. diff --git a/bin/varnishtest/tests/c00017.vtc b/bin/varnishtest/tests/c00017.vtc index b062980..42960d0 100644 --- a/bin/varnishtest/tests/c00017.vtc +++ b/bin/varnishtest/tests/c00017.vtc @@ -23,6 +23,12 @@ server s1 { txresp -proto "FROBOZ" -status 200 -hdr "Bar: foo" -body "foobar" accept } + loop 2 { + rxreq + expect req.url == "/" + send "HTTP/1.1 200 \r\n" + accept + } barrier b1 sync } -start @@ -42,4 +48,4 @@ varnish v1 -vcl { barrier b1 sync -varnish v1 -cli "backend.list -p" +varnish v1 -cliexpect "^CLI RX| -+H{10}-{5}H{2}-{0,5} Happy" "backend.list -p" From phk at FreeBSD.org Mon Apr 10 11:59:08 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 10 Apr 2017 13:59:08 +0200 Subject: [5.1] 425d37b Introduce a barrier to prevent the HEADERS from overtaking the WINDOWS_UPDATE Message-ID: commit 425d37b6420cb7c4cc0c50af4a55684685525f0f Author: Poul-Henning Kamp Date: Tue Apr 4 22:01:59 2017 +0000 Introduce a barrier to prevent the HEADERS from overtaking the WINDOWS_UPDATE diff --git a/bin/varnishtest/tests/t02005.vtc b/bin/varnishtest/tests/t02005.vtc index 2cf31ee..85235f7 100644 --- a/bin/varnishtest/tests/t02005.vtc +++ b/bin/varnishtest/tests/t02005.vtc @@ -1,7 +1,10 @@ varnishtest "H2 POST" +barrier b1 cond 2 + server s1 { rxreq + barrier b1 sync txresp -hdr "Content-Type: text/plain" -body response } -start @@ -13,6 +16,7 @@ client c1 { txreq -req POST -hdr content-type text/plain -hdr content-length 7 -body request rxwinup + barrier b1 sync # First, HTTP checks rxresp expect resp.http.content-Type == "text/plain" From phk at FreeBSD.org Mon Apr 10 11:59:08 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 10 Apr 2017 13:59:08 +0200 Subject: [5.1] b8d0687 Also stabilize t02006 with a barrier to keep HEADERS from overtaking WINDOWS UPDATE Message-ID: commit b8d06876da481ce6e69ee2165d86e2118eabf915 Author: Poul-Henning Kamp Date: Tue Apr 4 23:06:42 2017 +0000 Also stabilize t02006 with a barrier to keep HEADERS from overtaking WINDOWS UPDATE diff --git a/bin/varnishtest/tests/t02006.vtc b/bin/varnishtest/tests/t02006.vtc index 58b33e3..31a5fbf 100644 --- a/bin/varnishtest/tests/t02006.vtc +++ b/bin/varnishtest/tests/t02006.vtc @@ -1,8 +1,11 @@ varnishtest "H2 POST w/ 100 Continue" +barrier b1 cond 2 + server s1 { rxreq expect req.proto == HTTP/1.1 + barrier b1 sync txresp -hdr "Content-Type: text/plain" -body response } -start @@ -28,6 +31,7 @@ client c1 { -data request rxwinup + barrier b1 sync rxresp expect resp.status == 200 expect resp.http.content-Type == "text/plain" From phk at FreeBSD.org Mon Apr 10 11:59:08 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 10 Apr 2017 13:59:08 +0200 Subject: [5.1] 1d9d85e Collect H2 cookies in H2 code, long time before we get to create req->http0. Message-ID: commit 1d9d85eb0cd32c55712e8dabe00f1249ce502ca3 Author: Poul-Henning Kamp Date: Wed Apr 5 06:45:08 2017 +0000 Collect H2 cookies in H2 code, long time before we get to create req->http0. Fixes #2300 Testcase by Simon diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 1723bed..1320e81 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -799,9 +799,6 @@ cnt_recv(struct worker *wrk, struct req *req) http_CollectHdr(req->http, H_Cache_Control); - if (req->http->protover == 20) // rfc7540,l,3114,3120 - http_CollectHdrSep(req->http, H_Cookie, "; "); - if (req->req_body_status == REQ_BODY_FAIL) { req->doclose = SC_OVERLOAD; return (REQ_FSM_DONE); diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index ab0f28d..27c95bd 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -467,6 +467,12 @@ h2_do_req(struct worker *wrk, void *priv) CAST_OBJ_NOTNULL(req, priv, REQ_MAGIC); CAST_OBJ_NOTNULL(r2, req->transport_priv, H2_REQ_MAGIC); THR_SetRequest(req); + + // XXX: Smarter to do this already at HPACK time into tail end of + // XXX: WS, then copy back once all headers received. + // XXX: Have I mentioned H/2 Is hodge-podge ? + http_CollectHdrSep(req->http, H_Cookie, "; "); // rfc7540,l,3114,3120 + req->http->conds = 1; if (CNT_Request(wrk, req) != REQ_FSM_DISEMBARK) { AZ(req->ws->r); diff --git a/bin/varnishtest/tests/r02300.vtc b/bin/varnishtest/tests/r02300.vtc new file mode 100644 index 0000000..130a172 --- /dev/null +++ b/bin/varnishtest/tests/r02300.vtc @@ -0,0 +1,29 @@ +varnishtest "ESI Cookie" + +server s1 { + fatal + rxreq + expect req.http.cookie == "Foo=Bar; B=C" + txresp -body "" + + rxreq + expect req.http.cookie == "Foo=Bar; B=C" + txresp +} -start + +varnish v1 -cliok {param.set feature +http2} +varnish v1 -cliok {param.set debug +syncvsl} + + +varnish v1 -vcl+backend { + sub vcl_backend_response { + set beresp.do_esi = true; + } +} -start + +client c1 { + stream 1 { + txreq -url "/" -hdr cookie "Foo=Bar" -hdr cookie "B=C" + rxresp + } -start +} -run From phk at FreeBSD.org Mon Apr 10 11:59:08 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 10 Apr 2017 13:59:08 +0200 Subject: [5.1] 6a40a47 Lock h2->vsl with mutex, even though most of the SLT_Debug stuff will eventually go away. Message-ID: commit 6a40a47531ada96dae7394171fa3722193b1600d Author: Poul-Henning Kamp Date: Wed Apr 5 14:02:08 2017 +0000 Lock h2->vsl with mutex, even though most of the SLT_Debug stuff will eventually go away. Fixes #2283 diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index 27c95bd..1711704 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -199,8 +199,8 @@ h2_kill_req(struct worker *wrk, const struct h2_sess *h2, ASSERT_RXTHR(h2); AN(h2e); - VSLb(h2->vsl, SLT_Debug, "KILL st=%u state=%d", r2->stream, r2->state); Lck_Lock(&h2->sess->mtx); + VSLb(h2->vsl, SLT_Debug, "KILL st=%u state=%d", r2->stream, r2->state); if (r2->error == NULL) r2->error = h2e; if (r2->scheduled) { @@ -230,10 +230,6 @@ h2_vsl_frame(const struct h2_sess *h2, const void *ptr, size_t len) assert(len >= 9); b = ptr; - VSLb_bin(h2->vsl, SLT_H2RxHdr, 9, b); - if (len > 9) - VSLb_bin(h2->vsl, SLT_H2RxBody, len - 9, b + 9); - vsb = VSB_new_auto(); AN(vsb); p = h2_framename((enum h2frame)b[3]); @@ -252,7 +248,13 @@ h2_vsl_frame(const struct h2_sess *h2, const void *ptr, size_t len) VSB_quote(vsb, b + 9, len - 9, VSB_QUOTE_HEX); } AZ(VSB_finish(vsb)); + Lck_Lock(&h2->sess->mtx); + VSLb_bin(h2->vsl, SLT_H2RxHdr, 9, b); + if (len > 9) + VSLb_bin(h2->vsl, SLT_H2RxBody, len - 9, b + 9); + VSLb(h2->vsl, SLT_Debug, "H2RXF %s", VSB_data(vsb)); + Lck_Unlock(&h2->sess->mtx); VSB_destroy(&vsb); } @@ -322,7 +324,9 @@ h2_rx_goaway(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) (void)r2; h2->goaway_last_stream = vbe32dec(h2->rxf_data); h2->error = h2_connectionerror(vbe32dec(h2->rxf_data + 4)); + Lck_Lock(&h2->sess->mtx); VSLb(h2->vsl, SLT_Debug, "GOAWAY %s", h2->error->name); + Lck_Unlock(&h2->sess->mtx); return (h2->error); } @@ -403,20 +407,26 @@ h2_set_setting(struct h2_sess *h2, const uint8_t *d) y = vbe32dec(d + 2); if (x >= H2_SETTING_TBL_LEN || h2_setting_tbl[x] == NULL) { // rfc7540,l,2181,2182 + Lck_Lock(&h2->sess->mtx); VSLb(h2->vsl, SLT_Debug, "H2SETTING unknown setting 0x%04x=%08x (ignored)", x, y); + Lck_Unlock(&h2->sess->mtx); return (0); } s = h2_setting_tbl[x]; AN(s); if (y < s->minval || y > s->maxval) { + Lck_Lock(&h2->sess->mtx); VSLb(h2->vsl, SLT_Debug, "H2SETTING invalid %s=0x%08x", s->name, y); + Lck_Unlock(&h2->sess->mtx); AN(s->range_error); if (!DO_DEBUG(DBG_H2_NOCHECK)) return (s->range_error); } + Lck_Lock(&h2->sess->mtx); VSLb(h2->vsl, SLT_Debug, "H2SETTING %s=0x%08x", s->name, y); + Lck_Unlock(&h2->sess->mtx); AN(s->setfunc); s->setfunc(&h2->remote_settings, y); return (0); @@ -496,7 +506,9 @@ h2_end_headers(struct worker *wrk, const struct h2_sess *h2, FREE_OBJ(r2->decode); r2->state = H2_S_CLOS_REM; if (h2e != NULL) { + Lck_Lock(&h2->sess->mtx); VSLb(h2->vsl, SLT_Debug, "HPACK/FINI %s", h2e->name); + Lck_Unlock(&h2->sess->mtx); AZ(r2->req->ws->r); h2_del_req(wrk, r2); return (h2e); @@ -568,7 +580,9 @@ h2_rx_headers(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) } h2e = h2h_decode_bytes(h2, r2->decode, p, l); if (h2e != NULL) { + Lck_Lock(&h2->sess->mtx); VSLb(h2->vsl, SLT_Debug, "HPACK(hdr) %s", h2e->name); + Lck_Unlock(&h2->sess->mtx); (void)h2h_decode_fini(h2, r2->decode); AZ(r2->req->ws->r); h2_del_req(wrk, r2); @@ -595,7 +609,9 @@ h2_rx_continuation(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) req = r2->req; h2e = h2h_decode_bytes(h2, r2->decode, h2->rxf_data, h2->rxf_len); if (h2e != NULL) { + Lck_Lock(&h2->sess->mtx); VSLb(h2->vsl, SLT_Debug, "HPACK(cont) %s", h2e->name); + Lck_Unlock(&h2->sess->mtx); (void)h2h_decode_fini(h2, r2->decode); AZ(r2->req->ws->r); h2_del_req(wrk, r2); @@ -767,8 +783,10 @@ h2_procframe(struct worker *wrk, struct h2_sess *h2, // rfc7540,l,1140,1145 // rfc7540,l,1153,1158 /* No even streams, we don't do PUSH_PROMISE */ + Lck_Lock(&h2->sess->mtx); VSLb(h2->vsl, SLT_Debug, "H2: illegal stream (=%u)", h2->rxf_stream); + Lck_Unlock(&h2->sess->mtx); return (H2CE_PROTOCOL_ERROR); } @@ -793,7 +811,9 @@ h2_procframe(struct worker *wrk, struct h2_sess *h2, if (h2->rxf_stream == 0 || h2e->connection) return (h2e); // Connection errors one level up + Lck_Lock(&h2->sess->mtx); VSLb(h2->vsl, SLT_Debug, "H2: stream %u: %s", h2->rxf_stream, h2e->txt); + Lck_Unlock(&h2->sess->mtx); vbe32enc(b, h2e->val); H2_Send_Get(wrk, h2, h2->req0); @@ -851,17 +871,17 @@ h2_rxframe(struct worker *wrk, struct h2_sess *h2) /* XXX: later full DATA will not be rx'ed yet. */ HTC_RxPipeline(h2->htc, h2->htc->rxbuf_b + h2->rxf_len + 9); - Lck_Lock(&h2->sess->mtx); h2_vsl_frame(h2, h2->htc->rxbuf_b, 9L + h2->rxf_len); - Lck_Unlock(&h2->sess->mtx); if (h2->rxf_type >= H2FMAX) { // rfc7540,l,679,681 // XXX: later, drain rest of frame h2->bogosity++; + Lck_Lock(&h2->sess->mtx); VSLb(h2->vsl, SLT_Debug, "H2: Unknown frame type 0x%02x (ignored)", (uint8_t)h2->rxf_type); + Lck_Unlock(&h2->sess->mtx); return (1); } h2f = h2flist[h2->rxf_type]; @@ -872,9 +892,11 @@ h2_rxframe(struct worker *wrk, struct h2_sess *h2) if (h2->rxf_flags & ~h2f->flags) { // rfc7540,l,687,688 h2->bogosity++; + Lck_Lock(&h2->sess->mtx); VSLb(h2->vsl, SLT_Debug, "H2: Unknown flags 0x%02x on %s (ignored)", (uint8_t)h2->rxf_flags & ~h2f->flags, h2f->name); + Lck_Unlock(&h2->sess->mtx); h2->rxf_flags &= h2f->flags; } diff --git a/bin/varnishd/http2/cache_http2_session.c b/bin/varnishd/http2/cache_http2_session.c index c12e2f5..dc3ac30 100644 --- a/bin/varnishd/http2/cache_http2_session.c +++ b/bin/varnishd/http2/cache_http2_session.c @@ -339,9 +339,10 @@ h2_new_session(struct worker *wrk, void *arg) } if (!again) break; - VTAILQ_FOREACH(r2, &h2->streams, list) - VSLb(h2->vsl, SLT_Debug, "ST %u %d", r2->stream, r2->state); Lck_Lock(&h2->sess->mtx); + VTAILQ_FOREACH(r2, &h2->streams, list) + VSLb(h2->vsl, SLT_Debug, "ST %u %d", + r2->stream, r2->state); (void)Lck_CondWait(h2->cond, &h2->sess->mtx, VTIM_real() + .1); Lck_Unlock(&h2->sess->mtx); } From phk at FreeBSD.org Mon Apr 10 11:59:08 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 10 Apr 2017 13:59:08 +0200 Subject: [5.1] e57e541 Whitespace ocd Message-ID: commit e57e5417e2ea7867fd7339154b8fa0abb4acb872 Author: Poul-Henning Kamp Date: Thu Apr 6 09:23:28 2017 +0000 Whitespace ocd diff --git a/include/vrt.h b/include/vrt.h index ef5204a..625bc36 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -40,7 +40,7 @@ * * * 6.1 (unreleased): - * http_CollectHdrSep added + * http_CollectHdrSep added * 6.0 (2017-03-15): * VRT_hit_for_pass added * VRT_ipcmp added From phk at FreeBSD.org Mon Apr 10 11:59:09 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 10 Apr 2017 13:59:09 +0200 Subject: [5.1] f299ae8 Mark frametypes which get charged to the session as overhead Message-ID: commit f299ae887704bad396fdeaa878b5b7ebad23b1b1 Author: Poul-Henning Kamp Date: Thu Apr 6 09:24:04 2017 +0000 Mark frametypes which get charged to the session as overhead diff --git a/bin/varnishd/http2/cache_http2.h b/bin/varnishd/http2/cache_http2.h index 0550e15..f04fb0b 100644 --- a/bin/varnishd/http2/cache_http2.h +++ b/bin/varnishd/http2/cache_http2.h @@ -74,6 +74,7 @@ struct h2_frame_s { int respect_window; h2_frame continuation; uint8_t final_flags; + int overhead; }; #define H2_FRAME(l,U,...) extern const struct h2_frame_s H2_F_##U[1]; diff --git a/include/tbl/h2_frames.h b/include/tbl/h2_frames.h index 4089d9e..8259082 100644 --- a/include/tbl/h2_frames.h +++ b/include/tbl/h2_frames.h @@ -38,6 +38,7 @@ * tx_flow-control // rfc7540,l,1265,1270 * tx_continuation * tx_final-flags + * overhead */ H2_FRAME(data, DATA, 0x0, 0x09, H2CE_PROTOCOL_ERROR, // rfc7540,l,1758,1761 @@ -45,7 +46,8 @@ H2CE_PROTOCOL_ERROR, 1, H2_F_DATA, - 0x01 // rfc7540,l,1750,1753 + 0x01, // rfc7540,l,1750,1753 + 0 ) H2_FRAME(headers, HEADERS, 0x1, 0x2d, H2CE_PROTOCOL_ERROR, // rfc7540,l,1876,1879 @@ -53,7 +55,8 @@ 0, // rfc7540,l,938,940 0, H2_F_CONTINUATION, - 0x04 // rfc7540,l,1855,1857 + 0x04, // rfc7540,l,1855,1857 + 0 ) H2_FRAME(priority, PRIORITY, 0x2, 0x00, H2CE_PROTOCOL_ERROR, // rfc7540,l,1933,1936 @@ -61,7 +64,8 @@ 0, // rfc7540,l,938,940 0, 0, - 0 + 0, + 1 ) H2_FRAME(rst_stream, RST_STREAM, 0x3, 0x00, H2CE_PROTOCOL_ERROR, // rfc7540,l,1993,1996 @@ -69,7 +73,8 @@ H2CE_PROTOCOL_ERROR, 0, 0, - 0 + 0, + 1 ) H2_FRAME(settings, SETTINGS, 0x4, 0x01, 0, @@ -77,7 +82,8 @@ H2CE_PROTOCOL_ERROR, 0, 0, - 0 + 0, + 1 ) H2_FRAME(push_promise, PUSH_PROMISE, 0x5, 0x0c, H2CE_PROTOCOL_ERROR, // rfc7540,l,2262,2263 @@ -85,7 +91,8 @@ H2CE_PROTOCOL_ERROR, 0, H2_F_CONTINUATION, - 0x04 // rfc7540,l,2249,2251 + 0x04, // rfc7540,l,2249,2251 + 2 ) H2_FRAME(ping, PING, 0x6, 0x01, 0, @@ -93,7 +100,8 @@ H2CE_PROTOCOL_ERROR, 0, 0, - 0 + 0, + 1 ) H2_FRAME(goaway, GOAWAY, 0x7, 0x00, 0, @@ -101,7 +109,8 @@ H2CE_PROTOCOL_ERROR, 0, 0, - 0 + 0, + 1 ) H2_FRAME(window_update, WINDOW_UPDATE, 0x8, 0x00, 0, @@ -109,7 +118,8 @@ H2CE_PROTOCOL_ERROR, 0, 0, - 0 + 0, + 1 ) H2_FRAME(continuation, CONTINUATION, 0x9, 0x04, H2CE_PROTOCOL_ERROR, // rfc7540,l,2764,2767 @@ -117,7 +127,8 @@ H2CE_PROTOCOL_ERROR, 0, H2_F_CONTINUATION, - 0x04 // rfc7540,l,2753,2754 + 0x04, // rfc7540,l,2753,2754 + 0 ) #undef H2_FRAME #endif From phk at FreeBSD.org Mon Apr 10 11:59:09 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 10 Apr 2017 13:59:09 +0200 Subject: [5.1] 8abfe28 Charge H2 traffic to ReqAcct VSL record. Message-ID: commit 8abfe28c8925cf2541f757edce43c3bdd3952477 Author: Poul-Henning Kamp Date: Thu Apr 6 09:25:51 2017 +0000 Charge H2 traffic to ReqAcct VSL record. All H2 frame headers gets charged to the sessions "session req" All H2 frame bodies, except HEADERS, CONTIUATION and DATA also gets charged to the "session req". H2 frame bodies of HEADERS, CONTIUATION and DATA gets charged to the request. diff --git a/bin/varnishd/http2/cache_http2_deliver.c b/bin/varnishd/http2/cache_http2_deliver.c index be422e6..f9463ef 100644 --- a/bin/varnishd/http2/cache_http2_deliver.c +++ b/bin/varnishd/http2/cache_http2_deliver.c @@ -91,6 +91,7 @@ h2_bytes(struct req *req, enum vdp_action act, void **priv, H2_F_DATA, act == VDP_FINI ? H2FF_DATA_END_STREAM : H2FF_NONE, len, ptr); + req->acct.resp_bodybytes += len; H2_Send_Rel(r2->h2sess, r2); return (0); } @@ -256,6 +257,7 @@ h2_deliver(struct req *req, struct boc *boc, int sendbody) H2_Send(req->wrk, r2, H2_F_HEADERS, (sendbody ? 0 : H2FF_HEADERS_END_STREAM) | H2FF_HEADERS_END_HEADERS, sz, req->ws->f); + req->acct.resp_hdrbytes += sz; H2_Send_Rel(r2->h2sess, r2); WS_Release(req->ws, 0); diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index 1711704..1083d0e 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -537,6 +537,7 @@ h2_rx_headers(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) size_t l; ASSERT_RXTHR(h2); + AN(r2); if (r2->state != H2_S_IDLE) return (H2CE_PROTOCOL_ERROR); // XXX spec ? r2->state = H2_S_OPEN; @@ -559,6 +560,7 @@ h2_rx_headers(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) VCL_Refresh(&wrk->vcl); req->vcl = wrk->vcl; wrk->vcl = NULL; + req->acct.req_hdrbytes += h2->rxf_len; HTTP_Setup(req->http, req->ws, req->vsl, SLT_ReqMethod); http_SetH(req->http, HTTP_HDR_PROTO, "HTTP/2.0"); @@ -604,10 +606,12 @@ h2_rx_continuation(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) h2_error h2e; ASSERT_RXTHR(h2); + AN(r2); if (r2->state != H2_S_OPEN) return (H2CE_PROTOCOL_ERROR); // XXX spec ? req = r2->req; h2e = h2h_decode_bytes(h2, r2->decode, h2->rxf_data, h2->rxf_len); + r2->req->acct.req_hdrbytes += h2->rxf_len; if (h2e != NULL) { Lck_Lock(&h2->sess->mtx); VSLb(h2->vsl, SLT_Debug, "HPACK(cont) %s", h2e->name); @@ -632,12 +636,14 @@ h2_rx_data(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) unsigned wi; (void)wrk; + AN(r2); ASSERT_RXTHR(h2); Lck_Lock(&h2->sess->mtx); AZ(h2->mailcall); h2->mailcall = r2; h2->r_window -= h2->rxf_len; r2->r_window -= h2->rxf_len; + // req_bodybytes accounted in CNT code. if (r2->cond) AZ(pthread_cond_signal(r2->cond)); while (h2->mailcall != NULL && h2->error == 0 && r2->error == 0) @@ -872,6 +878,7 @@ h2_rxframe(struct worker *wrk, struct h2_sess *h2) HTC_RxPipeline(h2->htc, h2->htc->rxbuf_b + h2->rxf_len + 9); h2_vsl_frame(h2, h2->htc->rxbuf_b, 9L + h2->rxf_len); + h2->srq->acct.req_hdrbytes += 9; if (h2->rxf_type >= H2FMAX) { // rfc7540,l,679,681 @@ -882,12 +889,15 @@ h2_rxframe(struct worker *wrk, struct h2_sess *h2) "H2: Unknown frame type 0x%02x (ignored)", (uint8_t)h2->rxf_type); Lck_Unlock(&h2->sess->mtx); + h2->srq->acct.req_bodybytes += h2->rxf_len; return (1); } h2f = h2flist[h2->rxf_type]; AN(h2f->name); AN(h2f->rxfunc); + if (h2f->overhead) + h2->srq->acct.req_bodybytes += h2->rxf_len; if (h2->rxf_flags & ~h2f->flags) { // rfc7540,l,687,688 diff --git a/bin/varnishd/http2/cache_http2_send.c b/bin/varnishd/http2/cache_http2_send.c index a220b1e..fa837c9 100644 --- a/bin/varnishd/http2/cache_http2_send.c +++ b/bin/varnishd/http2/cache_http2_send.c @@ -107,6 +107,9 @@ H2_Send_Frame(struct worker *wrk, const struct h2_sess *h2, h2_mk_hdr(hdr, ftyp, flags, len, stream); Lck_Lock(&h2->sess->mtx); VSLb_bin(h2->vsl, SLT_H2TxHdr, 9, hdr); + h2->srq->acct.resp_hdrbytes += 9; + if (ftyp->overhead) + h2->srq->acct.resp_bodybytes += len; Lck_Unlock(&h2->sess->mtx); s = write(h2->sess->fd, hdr, sizeof hdr); diff --git a/bin/varnishtest/tests/t02005.vtc b/bin/varnishtest/tests/t02005.vtc index 85235f7..31be89b 100644 --- a/bin/varnishtest/tests/t02005.vtc +++ b/bin/varnishtest/tests/t02005.vtc @@ -11,7 +11,19 @@ server s1 { varnish v1 -vcl+backend {} -cliok "param.set feature +http2" -start varnish v1 -cliok "param.set debug +syncvsl" +logexpect l1 -v v1 -g raw { + expect * 1001 ReqAcct "80 7 87 106 8 114" + expect * 1000 ReqAcct "45 8 53 72 28 100" +} -start + client c1 { + stream 0 { + txping + rxping + } -run + stream 0 { + rxwinup + } -start stream 1 { txreq -req POST -hdr content-type text/plain -hdr content-length 7 -body request @@ -24,5 +36,8 @@ client c1 { # Then, payload checks expect resp.body == response } -run + stream 0 -wait } -run + +logexpect l1 -wait From phk at FreeBSD.org Mon Apr 10 11:59:09 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 10 Apr 2017 13:59:09 +0200 Subject: [5.1] d2d121f Don't access struct http after teardown Message-ID: commit d2d121f053b1009385c27b972eb5192aeac3d6ac Author: Poul-Henning Kamp Date: Thu Apr 6 10:23:43 2017 +0000 Don't access struct http after teardown Fixes #2263 diff --git a/bin/varnishd/http2/cache_http2_hpack.c b/bin/varnishd/http2/cache_http2_hpack.c index 9bcc1dd..a7fe43d 100644 --- a/bin/varnishd/http2/cache_http2_hpack.c +++ b/bin/varnishd/http2/cache_http2_hpack.c @@ -305,10 +305,10 @@ h2h_decode_bytes(struct h2_sess *h2, struct h2h_decode *d, } if (d->error == H2SE_ENHANCE_YOUR_CALM) { - http_Teardown(hp); d->out = d->reset; d->out_l = hp->ws->r - d->out; d->out_u = 0; + http_Teardown(hp); assert(d->out_u < d->out_l); } else if (d->error) break; From phk at FreeBSD.org Mon Apr 10 11:59:09 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 10 Apr 2017 13:59:09 +0200 Subject: [5.1] b2ff51b Remove this http_Teardown() entirely, it doesn't belong here. Message-ID: commit b2ff51b0680d59091632179e9091b8bf90026194 Author: Poul-Henning Kamp Date: Thu Apr 6 13:44:34 2017 +0000 Remove this http_Teardown() entirely, it doesn't belong here. diff --git a/bin/varnishd/http2/cache_http2_hpack.c b/bin/varnishd/http2/cache_http2_hpack.c index a7fe43d..460b43f 100644 --- a/bin/varnishd/http2/cache_http2_hpack.c +++ b/bin/varnishd/http2/cache_http2_hpack.c @@ -308,7 +308,6 @@ h2h_decode_bytes(struct h2_sess *h2, struct h2h_decode *d, d->out = d->reset; d->out_l = hp->ws->r - d->out; d->out_u = 0; - http_Teardown(hp); assert(d->out_u < d->out_l); } else if (d->error) break; From phk at FreeBSD.org Mon Apr 10 11:59:09 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 10 Apr 2017 13:59:09 +0200 Subject: [5.1] 308843a Don't attept return(pipe) on HTTP/2 requests, pass with a VSL message. Message-ID: commit 308843aaf8b67eee4a53889bca31aa319fd2f2f1 Author: Poul-Henning Kamp Date: Thu Apr 6 13:45:02 2017 +0000 Don't attept return(pipe) on HTTP/2 requests, pass with a VSL message. diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 1320e81..cdd443f 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -864,15 +864,20 @@ cnt_recv(struct worker *wrk, struct req *req) req->req_step = R_STP_LOOKUP; return (REQ_FSM_MORE); case VCL_RET_PIPE: - if (req->esi_level == 0) { + if (req->esi_level > 0) { + VSLb(req->vsl, SLT_VCL_Error, + "vcl_recv{} returns pipe for ESI included object." + " Doing pass."); + req->req_step = R_STP_PASS; + } else if (req->http0->protover > 11) { + VSLb(req->vsl, SLT_VCL_Error, + "vcl_recv{} returns pipe for HTTP/2 request." + " Doing pass."); + req->req_step = R_STP_PASS; + } else { req->req_step = R_STP_PIPE; - return (REQ_FSM_MORE); } - VSLb(req->vsl, SLT_VCL_Error, - "vcl_recv{} returns pipe for ESI included object." - " Doing pass."); - req->req_step = R_STP_PASS; - return (REQ_FSM_DONE); + return (REQ_FSM_MORE); case VCL_RET_PASS: req->req_step = R_STP_PASS; return (REQ_FSM_MORE); diff --git a/bin/varnishtest/tests/t02000.vtc b/bin/varnishtest/tests/t02000.vtc index 6eb9ff8..3be9e17 100644 --- a/bin/varnishtest/tests/t02000.vtc +++ b/bin/varnishtest/tests/t02000.vtc @@ -9,7 +9,11 @@ server s1 { -bodylen 10 } -start -varnish v1 -vcl+backend {} -start +varnish v1 -vcl+backend { + sub vcl_recv { + return (pipe); + } +} -start varnish v1 -cliok "param.set debug +syncvsl" From phk at FreeBSD.org Mon Apr 10 11:59:09 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 10 Apr 2017 13:59:09 +0200 Subject: [5.1] e1e7e76 Putter around with a featherduster: Message-ID: commit e1e7e764bd8c53900a204551c8123971b778e85f Author: Poul-Henning Kamp Date: Thu Apr 6 19:45:06 2017 +0000 Putter around with a featherduster: Remove forgotten debugging VSL. Renovate a VCL comment. diff --git a/bin/varnishd/builtin.vcl b/bin/varnishd/builtin.vcl index 14c7955..4e74948 100644 --- a/bin/varnishd/builtin.vcl +++ b/bin/varnishd/builtin.vcl @@ -36,7 +36,7 @@ vcl 4.0; sub vcl_recv { if (req.method == "PRI") { - /* We do not support SPDY or HTTP/2.0 */ + /* This will never happen in properly formed traffic (see: RFC7540) */ return (synth(405)); } if (req.method != "GET" && diff --git a/bin/varnishd/http1/cache_http1_deliver.c b/bin/varnishd/http1/cache_http1_deliver.c index 3f19bdf..e6a6845 100644 --- a/bin/varnishd/http1/cache_http1_deliver.c +++ b/bin/varnishd/http1/cache_http1_deliver.c @@ -99,8 +99,6 @@ V1D_Deliver(struct req *req, struct boc *boc, int sendbody) } } - VSLb(req->vsl, SLT_Debug, "RES_MODE %x", req->res_mode); - if (!req->doclose && http_HdrIs(req->resp, H_Connection, "close")) { req->doclose = SC_RESP_CLOSE; } else if (req->doclose) { diff --git a/bin/varnishd/http2/cache_http2_deliver.c b/bin/varnishd/http2/cache_http2_deliver.c index f9463ef..a9d4ad5 100644 --- a/bin/varnishd/http2/cache_http2_deliver.c +++ b/bin/varnishd/http2/cache_http2_deliver.c @@ -193,8 +193,6 @@ h2_deliver(struct req *req, struct boc *boc, int sendbody) sp = req->sp; CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); - VSLb(req->vsl, SLT_Debug, "H2: Deliver"); - (void)WS_Reserve(req->ws, 0); p = (void*)req->ws->f; From phk at FreeBSD.org Mon Apr 10 11:59:09 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 10 Apr 2017 13:59:09 +0200 Subject: [5.1] cd54c18 Summarize changes for 5.1.2 Message-ID: commit cd54c184d40d221ec79c5aa7c4a089a9bdbc03b1 Author: Poul-Henning Kamp Date: Fri Apr 7 07:13:20 2017 +0000 Summarize changes for 5.1.2 diff --git a/doc/changes.rst b/doc/changes.rst index 2546c4d..41d83d0 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -1,4 +1,26 @@ ================================ +Varnish Cache 5.1.2 (2017-04-07) +================================ + +* Fix an endless loop in Backend Polling (#2295) + +* Fix a Chunked bug in tight workspaces (#2207, #2275) + +* Fix a bug relating to req.body when on waitinglist (#2266) + +* Handle EPIPE on broken TCP connections (#2267) + +* Work around the x86 arch's turbo-double FP format in parameter + setup code. (#1875) + +* Fix race related to backend probe with proxy header (#2278) + +* Keep VCL temperature consistent between mgt/worker also when + worker protests. + +* A lot of HTTP/2 fixes. + +================================ Varnish Cache 5.1.1 (2017-03-16) ================================ From phk at FreeBSD.org Mon Apr 10 11:59:09 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 10 Apr 2017 13:59:09 +0200 Subject: [5.1] a575331 Ignore DATA received after stream closed Message-ID: commit a575331d6043c7dbaf5ed9aa850e8619bf42aad4 Author: Poul-Henning Kamp Date: Fri Apr 7 07:20:20 2017 +0000 Ignore DATA received after stream closed Fixes #2304 diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index 1083d0e..a44d05b 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -636,8 +636,9 @@ h2_rx_data(struct worker *wrk, struct h2_sess *h2, struct h2_req *r2) unsigned wi; (void)wrk; - AN(r2); ASSERT_RXTHR(h2); + if (r2 == NULL) + return (0); Lck_Lock(&h2->sess->mtx); AZ(h2->mailcall); h2->mailcall = r2; diff --git a/bin/varnishtest/tests/t02003.vtc b/bin/varnishtest/tests/t02003.vtc index db5fb31..2f32a51 100644 --- a/bin/varnishtest/tests/t02003.vtc +++ b/bin/varnishtest/tests/t02003.vtc @@ -417,3 +417,35 @@ varnish v1 -expect MEMPOOL.req1.live == 0 varnish v1 -expect MEMPOOL.sess0.live == 0 varnish v1 -expect MEMPOOL.sess1.live == 0 +####################################################################### +# Test DATA error conditions + +client c1 { + stream 1 { + txdata -data "FOOBAR" + } -run + stream 0 { + rxgoaway + } -run + expect_close +} -run + +client c1 { + stream 1 { + txreq + rxresp + txdata -data "FOOBAR" + } -run + stream 3 { + txreq + rxresp + } -run +} -run + +varnish v1 -vsl_catchup + +varnish v1 -expect MEMPOOL.req0.live == 0 +varnish v1 -expect MEMPOOL.req1.live == 0 +varnish v1 -expect MEMPOOL.sess0.live == 0 +varnish v1 -expect MEMPOOL.sess1.live == 0 + From phk at FreeBSD.org Mon Apr 10 11:59:09 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 10 Apr 2017 13:59:09 +0200 Subject: [5.1] 6e58e28 Don't send both c-l and chunked to backend for h2. Message-ID: commit 6e58e283a4415f6bc005299c2d6230fa81295bf2 Author: Poul-Henning Kamp Date: Fri Apr 7 07:45:11 2017 +0000 Don't send both c-l and chunked to backend for h2. Fixes #2247 diff --git a/bin/varnishd/http2/cache_http2_proto.c b/bin/varnishd/http2/cache_http2_proto.c index a44d05b..87dca6e 100644 --- a/bin/varnishd/http2/cache_http2_proto.c +++ b/bin/varnishd/http2/cache_http2_proto.c @@ -473,6 +473,7 @@ h2_do_req(struct worker *wrk, void *priv) { struct req *req; struct h2_req *r2; + const char *b; CAST_OBJ_NOTNULL(req, priv, REQ_MAGIC); CAST_OBJ_NOTNULL(r2, req->transport_priv, H2_REQ_MAGIC); @@ -483,6 +484,15 @@ h2_do_req(struct worker *wrk, void *priv) // XXX: Have I mentioned H/2 Is hodge-podge ? http_CollectHdrSep(req->http, H_Cookie, "; "); // rfc7540,l,3114,3120 + if (req->req_body_status == REQ_BODY_INIT) { + if (!http_GetHdr(req->http, H_Content_Length, &b)) + req->req_body_status = REQ_BODY_WITHOUT_LEN; + else + req->req_body_status = REQ_BODY_WITH_LEN; + } else { + assert (req->req_body_status == REQ_BODY_NONE); + } + req->http->conds = 1; if (CNT_Request(wrk, req) != REQ_FSM_DISEMBARK) { AZ(req->ws->r); @@ -517,8 +527,6 @@ h2_end_headers(struct worker *wrk, const struct h2_sess *h2, if (h2->rxf_flags & H2FF_HEADERS_END_STREAM) req->req_body_status = REQ_BODY_NONE; - else - req->req_body_status = REQ_BODY_WITHOUT_LEN; req->req_step = R_STP_TRANSPORT; req->task.func = h2_do_req; diff --git a/bin/varnishtest/tests/t02005.vtc b/bin/varnishtest/tests/t02005.vtc index 31be89b..81ad091 100644 --- a/bin/varnishtest/tests/t02005.vtc +++ b/bin/varnishtest/tests/t02005.vtc @@ -4,6 +4,8 @@ barrier b1 cond 2 server s1 { rxreq + expect req.http.content-length == 7 + expect req.http.transfer-encoding == barrier b1 sync txresp -hdr "Content-Type: text/plain" -body response } -start diff --git a/bin/varnishtest/tests/t02006.vtc b/bin/varnishtest/tests/t02006.vtc index 31a5fbf..30e4ac8 100644 --- a/bin/varnishtest/tests/t02006.vtc +++ b/bin/varnishtest/tests/t02006.vtc @@ -4,6 +4,8 @@ barrier b1 cond 2 server s1 { rxreq + expect req.http.content-length == + expect req.http.transfer-encoding == chunked expect req.proto == HTTP/1.1 barrier b1 sync txresp -hdr "Content-Type: text/plain" -body response @@ -21,7 +23,6 @@ client c1 { -nohdrend txcont \ -hdr expect 100-continue \ - -hdr content-length 7 \ -nostrend rxhdrs From hermunn at varnish-software.com Mon Apr 10 11:59:09 2017 From: hermunn at varnish-software.com (Pål Hermunn Johansen) Date: Mon, 10 Apr 2017 13:59:09 +0200 Subject: [5.1] 6ece695 Prepare for 5.1.2 final Message-ID: commit 6ece695868b71d47c5a3619e18c3b18792bfe149 Author: P?l Hermunn Johansen Date: Fri Apr 7 13:18:26 2017 +0200 Prepare for 5.1.2 final diff --git a/configure.ac b/configure.ac index 7aaf658..4f9b4f2 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ AC_PREREQ(2.59) AC_COPYRIGHT([Copyright (c) 2006 Verdens Gang AS Copyright (c) 2006-2017 Varnish Software]) AC_REVISION([$Id$]) -AC_INIT([Varnish], [5.1.1], [varnish-dev at varnish-cache.org]) +AC_INIT([Varnish], [5.1.2], [varnish-dev at varnish-cache.org]) AC_CONFIG_SRCDIR(include/miniobj.h) AC_CONFIG_HEADERS([config.h]) AC_CONFIG_MACRO_DIR([m4]) From dridi.boukelmoune at gmail.com Mon Apr 10 12:30:07 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 10 Apr 2017 14:30:07 +0200 Subject: [master] c271aef Hijack errno in Lck_CondWait Message-ID: commit c271aef9b5b07f7dfc6272f75b4acc56954ea533 Author: Dridi Boukelmoune Date: Mon Mar 13 13:04:54 2017 +0100 Hijack errno in Lck_CondWait This should help diagnose #2253. diff --git a/bin/varnishd/cache/cache_lck.c b/bin/varnishd/cache/cache_lck.c index 609971a..bf8151f 100644 --- a/bin/varnishd/cache/cache_lck.c +++ b/bin/varnishd/cache/cache_lck.c @@ -188,7 +188,6 @@ int __match_proto__() Lck_CondWait(pthread_cond_t *cond, struct lock *lck, double when) { struct ilck *ilck; - int retval = 0; struct timespec ts; double t; @@ -197,20 +196,21 @@ Lck_CondWait(pthread_cond_t *cond, struct lock *lck, double when) assert(pthread_equal(ilck->owner, pthread_self())); ilck->held = 0; if (when == 0) { - AZ(pthread_cond_wait(cond, &ilck->mtx)); + errno = pthread_cond_wait(cond, &ilck->mtx); + AZ(errno); } else { assert(when > 1e9); ts.tv_nsec = (long)(modf(when, &t) * 1e9); ts.tv_sec = (long)t; - retval = pthread_cond_timedwait(cond, &ilck->mtx, &ts); - assert(retval == 0 || - retval == ETIMEDOUT || - retval == EINTR); + errno = pthread_cond_timedwait(cond, &ilck->mtx, &ts); + assert(errno == 0 || + errno == ETIMEDOUT || + errno == EINTR); } AZ(ilck->held); ilck->held = 1; ilck->owner = pthread_self(); - return (retval); + return (errno); } void From dridi.boukelmoune at gmail.com Mon Apr 10 14:39:05 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 10 Apr 2017 16:39:05 +0200 Subject: [4.1] f137686 Make miniobj work downstream Message-ID: commit f13768615549759b4db6cd792e83a1fc30ea0ee2 Author: Dridi Boukelmoune Date: Sat Mar 11 13:50:34 2017 +0100 Make miniobj work downstream Conflicts: configure.ac varnish.m4 diff --git a/configure.ac b/configure.ac index 5c61a61..03412cd 100644 --- a/configure.ac +++ b/configure.ac @@ -244,6 +244,7 @@ AC_CHECK_MEMBERS([struct sockaddr.sa_len],,,[ ]) # Checks for library functions. +_VARNISH_CHECK_EXPLICIT_BZERO AC_TYPE_SIGNAL AC_TYPE_SIZE_T AC_FUNC_VPRINTF diff --git a/include/miniobj.h b/include/miniobj.h index 75093ce..3e4829e 100644 --- a/include/miniobj.h +++ b/include/miniobj.h @@ -5,7 +5,7 @@ * */ -#if HAVE_EXPLICIT_BZERO +#ifdef HAVE_EXPLICIT_BZERO # define ZERO_OBJ(to, sz) explicit_bzero(to, sz) #else # define ZERO_OBJ(to, sz) (void)memset(to, 0, sz) diff --git a/varnish.m4 b/varnish.m4 index 75ac9a3..acdd58f 100644 --- a/varnish.m4 +++ b/varnish.m4 @@ -31,6 +31,12 @@ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED # OF THE POSSIBILITY OF SUCH DAMAGE. +# _VARNISH_CHECK_EXPLICIT_BZERO() +# ------------------------------- +AC_DEFUN([_VARNISH_CHECK_EXPLICIT_BZERO], [ + AC_CHECK_FUNCS([explicit_bzero]) +]) + # _VARNISH_PKG_CONFIG # -------------------- AC_DEFUN([_VARNISH_PKG_CONFIG], [ @@ -53,6 +59,7 @@ AC_DEFUN([_VARNISH_PKG_CONFIG], [ AC_DEFUN([_VARNISH_CHECK_DEVEL], [ AC_REQUIRE([_VARNISH_PKG_CONFIG]) + AC_REQUIRE([_VARNISH_CHECK_EXPLICIT_BZERO]) [_orig_cppflags=$CPPFLAGS] [CPPFLAGS=$VARNISHAPI_CFLAGS] @@ -254,6 +261,7 @@ AC_DEFUN([VARNISH_VMODS], [ # AC_DEFUN([VARNISH_PREREQ], [ AC_REQUIRE([_VARNISH_PKG_CONFIG]) + AC_REQUIRE([_VARNISH_CHECK_EXPLICIT_BZERO]) AC_MSG_CHECKING([for Varnish]) AC_MSG_RESULT([$VARNISH_VERSION]) From dridi.boukelmoune at gmail.com Mon Apr 10 14:55:06 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 10 Apr 2017 16:55:06 +0200 Subject: [master] 6768c37 Ignore missing reason in probe responses Message-ID: commit 6768c376edf2c879654d701bff7ffc95aa0eebfe Author: Dridi Boukelmoune Date: Mon Sep 12 18:53:05 2016 +0200 Ignore missing reason in probe responses This is a cherry-pick of 3271c51e303b1f187d851cdaf056a940ccaa8365 that fixed the issue for Varnish 3.0 since it wasn't a problem in the 4.1 series then. This is only a back-port of the regression test since the referenced commits already fixed the regression. Refs 5e4d6c843376acc0bf14872d89a4e8bb2f77186b Refs 9f4226200ef7784b597056fbb788b57f64ca6ef3 Refs #2069 diff --git a/bin/varnishtest/tests/r02069.vtc b/bin/varnishtest/tests/r02069.vtc new file mode 100644 index 0000000..9e59644 --- /dev/null +++ b/bin/varnishtest/tests/r02069.vtc @@ -0,0 +1,38 @@ +varnishtest "Probe response without a reason" + +server s1 -repeat 20 { + rxreq + send "HTTP/1.1 200\r\n\r\n" +} -start + +varnish v1 -vcl { + import std; + + backend s1 { + .host = "${s1_addr}"; + .port = "${s1_port}"; + .probe = { + .initial = 0; + .window = 5; + .threshold = 5; + .interval = 100ms; + } + } + + sub vcl_recv { + if (std.healthy(req.backend_hint)) { + return (synth(200)); + } + else { + return (synth(500)); + } + } +} -start + +delay 1 + +client c1 { + txreq + rxresp + expect resp.status == 200 +} -run From phk at FreeBSD.org Tue Apr 11 09:40:06 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 11 Apr 2017 11:40:06 +0200 Subject: [master] ce9ebf1 Release 5.1 post mortem Message-ID: commit ce9ebf1259e2af5bd0dfa3e51c53758e2f31a4b9 Author: Poul-Henning Kamp Date: Tue Apr 11 09:38:46 2017 +0000 Release 5.1 post mortem diff --git a/doc/sphinx/phk/index.rst b/doc/sphinx/phk/index.rst index 2dfcdb7..8dd4f13 100644 --- a/doc/sphinx/phk/index.rst +++ b/doc/sphinx/phk/index.rst @@ -8,6 +8,7 @@ You may or may not want to know what Poul-Henning thinks. .. toctree:: :maxdepth: 1 + somethinghappened.rst trialerror.rst farfaraway.rst thatslow.rst diff --git a/doc/sphinx/phk/somethinghappened.rst b/doc/sphinx/phk/somethinghappened.rst new file mode 100644 index 0000000..3878b21 --- /dev/null +++ b/doc/sphinx/phk/somethinghappened.rst @@ -0,0 +1,95 @@ +.. _phk_somethinghappened: + +==================================================== +Something (funny) happened on the way to 5.1.0^H1^H2 +==================================================== + +Some time back we, or to be perfectly honest, I, decided that in +the future we would do two varnish releases per year, march 15th +and september 15th and damn the torpedoes. + +The 5.1.X release was the first real test of this and it went a +little less smooth than I would have preferred, and it is pretty +much all my own fault. + +As you may have heard, we're in the process of `building a new house +`_ and that obviously takes a +lot of time on my part, most recently we have put up our "old" house +for sale etc. etc. + +So I was distracted, and suddenly it was march 15th but come hell +or high water: We cut the release. + +... and almost immediately found that it had a total show-stopper +bug which would cause the worker process to restart too often. + +Ok, fix that and roll 5.1.1 + +... and find another two, not quite as severe but still unacceptable +problems. + +Deep breath, fix those, and a lot of HTTP/2 stuff reported by +simon & xcir, who kindly subject that part of the code to some +live traffic ... and roll 5.1.2. + +This one will stick I hope. Next release will be September 15th. + +... unless something truly horrible lurks in 5.1.2. + +Success, Failure or Meh? (strike out the not applicable) +-------------------------------------------------------- + +Seen from a release engineering point of view we live a very +sheltered life in the Varnish Project. + +Our code base is small, 120 thousand lines of code and we +wrote almost all of it ourselves, which means that we +control the quality standard throughout. + +Thanks to our focus on code-quality, we have never had to +rush out a bug/security-fix in the full glare of the combined +scorn of Nanog, Hackernews, Reddit and Metasploit [#f2]_. + +We also don't link against any huge "middleware" libraries, I think +the biggest ones are Ncurses and PCRE [#f1]_, both of which are +quite stable, and we don't depend on any obscure single-compiler +languages either. + +So while rushing out point releases with short notice is pretty +routine for many other projects, it was a new experience for us, +and it reminded us of a couple of things we had sort of forgotten [#f3]_. + +I am absolutely certain that if we had not had our "release +by calendar" policy in place, I would probably not have been +willing to sign of on a release until after all the +house-building-moving-finding-where-I-put-the-computer madness +is over late in summer, and then I would probably still insist +on delaying it for a month just to catch my bearings. + +That would have held some +`pretty significant new code `_ +from our users for another half year, for no particular reason. + +So yeah, it was pretty embarrasing to have to amend our 5.1 release +twice in two weeks, but it did prove that the "release by calendar" +strategy is right for our project: It forced us to get our s**t +toggether so users can benefit from the work we do in a timely +fashion. + +And thanks to the heroic testing efforts of Simon and Xcir, you may +even be able to use the HTTP/2 support in 5.1.2 as a result. + +Next time, by which I mean "September 15th 2017", we'll try to do better. + +Poul-Henning, 2017-04-11 + +.. rubric:: Footnotes + +.. [#f1] Ncurses is just shy of 120 thousand lines of code and + PCRE is 96 thousand lines but that is getting of lightly, + compared to linking against any kind of GUI. + +.. [#f2] The bugs which caused 5.1.1 and 5.1.2 "merely" resulted + in bad stability, they were not security issues. + +.. [#f3] Always release from a branch, in case you need to release again. From dridi.boukelmoune at gmail.com Tue Apr 11 13:32:06 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 11 Apr 2017 15:32:06 +0200 Subject: [master] f895383 Restore shm_reclen as an alias for vsl_reclen Message-ID: commit f895383ded3f24f2a42e7224567d31ec9a2af535 Author: Dridi Boukelmoune Date: Tue Apr 11 15:24:57 2017 +0200 Restore shm_reclen as an alias for vsl_reclen Fixes #2307 diff --git a/bin/varnishd/mgt/mgt_param_tbl.c b/bin/varnishd/mgt/mgt_param_tbl.c index e29788d..431e937 100644 --- a/bin/varnishd/mgt/mgt_param_tbl.c +++ b/bin/varnishd/mgt/mgt_param_tbl.c @@ -144,6 +144,12 @@ struct parspec mgt_parspec[] = { MEMPOOL_TEXT, 0, "10,100,10", ""}, + { "shm_reclen", tweak_vsl_reclen, &mgt_param.vsl_reclen, + "16b", NULL, + "Old name for vsl_reclen, use that instead.", + 0, + "255b", + "bytes" }, { NULL, NULL, NULL } }; diff --git a/bin/varnishtest/tests/r02307.vtc b/bin/varnishtest/tests/r02307.vtc new file mode 100644 index 0000000..a86fe6d --- /dev/null +++ b/bin/varnishtest/tests/r02307.vtc @@ -0,0 +1,4 @@ +varnishtest "shm_reclen alias for vsl_reclen" + +varnish v1 -cli "param.set shm_reclen 42" +varnish v1 -cliexpect 42b "param.show vsl_reclen" diff --git a/include/tbl/params.h b/include/tbl/params.h index a44b625..5658f4b 100644 --- a/include/tbl/params.h +++ b/include/tbl/params.h @@ -969,6 +969,8 @@ PARAM( /* func */ NULL ) +#if 0 +/* actual location mgt_param_tbl.c */ PARAM( /* name */ shm_reclen, /* typ */ vsl_reclen, @@ -982,6 +984,7 @@ PARAM( /* l-text */ "", /* func */ NULL ) +#endif PARAM( /* name */ shortlived, From martin at varnish-software.com Wed Apr 12 11:50:06 2017 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Wed, 12 Apr 2017 13:50:06 +0200 Subject: [master] 6a636e6 Fix an issue with hpack table shifting Message-ID: commit 6a636e645d1fcdb451c9c8fe3ad09fcbe42349f1 Author: Martin Blix Grydeland Date: Wed Apr 12 13:44:17 2017 +0200 Fix an issue with hpack table shifting When inserting a new hpack table entry using a referenced name, and the referenced name would be removed from the table as a result of the insertion, there was a bug in the memory move/copy operations that would memmove a too large area. This wouldn't cause problems because we never used the full 32 bytes that the standard sets as per element overhead. Fix it, and the same time simplify the logic to be easier to read. Add a test case for trimmed indexed name insertion where the table isn't empty after removing the indexed entry. diff --git a/bin/varnishd/hpack/vhp_table.c b/bin/varnishd/hpack/vhp_table.c index 4f59501..d37fa69 100644 --- a/bin/varnishd/hpack/vhp_table.c +++ b/bin/varnishd/hpack/vhp_table.c @@ -191,14 +191,14 @@ int VHT_NewEntry_Indexed(struct vht_table *tbl, unsigned idx) { struct vht_entry *e, *e2; - unsigned l, l2, lbuf, lentry, lname, u; - uint8_t buf[48]; + unsigned l, l2, lentry, lname, u; + uint8_t tmp[48]; /* Referenced name insertion. This has to be done carefully because the referenced name may be evicted as the result of the insertion (RFC 7541 section 4.4). */ - assert(sizeof buf >= VHT_ENTRY_SIZE); + assert(sizeof tmp >= VHT_ENTRY_SIZE); CHECK_OBJ_NOTNULL(tbl, VHT_TABLE_MAGIC); assert(tbl->maxsize <= tbl->protomax); @@ -248,8 +248,8 @@ VHT_NewEntry_Indexed(struct vht_table *tbl, unsigned idx) } /* The tricky case: The referenced name will be evicted as a - result of the insertion. Move the element data to the end of - the buffer through a local buffer. */ + result of the insertion. Move the referenced element data to + the end of the buffer through a local buffer. */ /* Remove the referenced element from the entry list */ assert(idx == tbl->n - 1); @@ -260,22 +260,16 @@ VHT_NewEntry_Indexed(struct vht_table *tbl, unsigned idx) memmove(TBLENTRY(tbl, 1), TBLENTRY(tbl, 0), (tbl->n - 1) * sizeof *e); tbl->n--; - /* Shift the referenced element last in the buffer. Use what space - is available in the table buffer and the local buffer to keep - memmove operations to a minimum. */ + /* Shift the referenced element last using a temporary buffer. */ l = 0; while (l < lentry) { l2 = lentry - l; - if (l2 > tbl->maxsize - TBLSIZE(tbl)) - l2 = tbl->maxsize - TBLSIZE(tbl); - lbuf = lentry - l - l2; - if (lbuf > sizeof buf) - lbuf = sizeof buf; - memcpy(tbl->buf + tbl->size, tbl->buf, l2); - memcpy(buf, tbl->buf + l2, lbuf); - memmove(tbl->buf, tbl->buf + l2 + lbuf, tbl->size + l2); - memcpy(tbl->buf + tbl->size - lbuf, buf, lbuf); - l += l2 + lbuf; + if (l2 > sizeof tmp) + l2 = sizeof tmp; + memcpy(tmp, tbl->buf, l2); + memmove(tbl->buf, tbl->buf + l2, tbl->size - l2); + memcpy(tbl->buf + tbl->size - l2, tmp, l2); + l += l2; } assert(l == lentry); tbl->size -= lentry; @@ -754,6 +748,55 @@ test_4(void) printf("\n"); } +static void +test_5(void) +{ + struct vht_table tbl[1]; + char buf_a[3]; + char buf_b[2]; + int i; + + if (verbose) + printf("Test 5:\n"); + + assert(sizeof buf_a > 0); + for (i = 0; i < sizeof buf_a - 1; i++) + buf_a[i] = 'a'; + buf_a[i++] = '\0'; + + assert(sizeof buf_b > 0); + for (i = 0; i < sizeof buf_b - 1; i++) + buf_b[i] = 'b'; + buf_b[i++] = '\0'; + + AZ(VHT_Init(tbl, + 3 * ((sizeof buf_a - 1)+(sizeof buf_b - 1)+VHT_ENTRY_SIZE))); + + VHT_NewEntry(tbl); + VHT_AppendName(tbl, buf_a, sizeof buf_a - 1); + VHT_AppendValue(tbl, buf_b, sizeof buf_b - 1); + AZ(vht_matchtable(tbl, buf_a, buf_b, NULL)); + + VHT_NewEntry(tbl); + VHT_AppendName(tbl, buf_a, sizeof buf_a - 1); + VHT_AppendValue(tbl, buf_b, sizeof buf_b - 1); + AZ(vht_matchtable(tbl, buf_a, buf_b, buf_a, buf_b, NULL)); + + VHT_NewEntry(tbl); + VHT_AppendName(tbl, buf_a, sizeof buf_a - 1); + VHT_AppendValue(tbl, buf_b, sizeof buf_b - 1); + AZ(vht_matchtable(tbl, buf_a, buf_b, buf_a, buf_b, buf_a, buf_b, NULL)); + + AZ(VHT_NewEntry_Indexed(tbl, VHT_DYNAMIC + 2)); + VHT_AppendValue(tbl, buf_b, sizeof buf_b - 1); + AZ(vht_matchtable(tbl, buf_a, buf_b, buf_a, buf_b, buf_a, buf_b, NULL)); + + VHT_Fini(tbl); + printf("Test 5 finished successfully\n"); + if (verbose) + printf("\n"); +} + int main(int argc, char **argv) { @@ -777,6 +820,7 @@ main(int argc, char **argv) test_2(); test_3(); test_4(); + test_5(); return (0); } From fgsch at lodoss.net Fri Apr 14 03:42:05 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Fri, 14 Apr 2017 05:42:05 +0200 Subject: [master] dff3c2b Add std.file_exists(path) to check if path exists Message-ID: commit dff3c2be8c11192075bbc32e47b08cac4fe7c471 Author: Jonathan Huot Date: Wed Mar 29 14:59:14 2017 +0200 Add std.file_exists(path) to check if path exists diff --git a/bin/varnishtest/tests/m00029.vtc b/bin/varnishtest/tests/m00029.vtc new file mode 100644 index 0000000..c92b839 --- /dev/null +++ b/bin/varnishtest/tests/m00029.vtc @@ -0,0 +1,22 @@ +varnishtest "Test std.file_exists" + +server s1 { + rxreq + txresp +} -start + +varnish v1 -vcl+backend { + import std; + + sub vcl_deliver { + set resp.http.existsA = std.file_exists("/non/existent"); + set resp.http.existsB = std.file_exists("${tmpdir}/v1/_.vsm"); + } +} -start + +client c1 { + txreq + rxresp + expect resp.http.existsA == "false" + expect resp.http.existsB == "true" +} -run diff --git a/lib/libvmod_std/vmod.vcc b/lib/libvmod_std/vmod.vcc index 2ebfb45..3bfa0e3 100644 --- a/lib/libvmod_std/vmod.vcc +++ b/lib/libvmod_std/vmod.vcc @@ -107,6 +107,16 @@ Description Example set beresp.http.served-by = std.fileread("/etc/hostname"); +$Function BOOL file_exists(STRING path) + +Description + Returns `true` if path or the file pointed to by path exists, + `false` otherwise. +Example + | if (std.file_exists("/etc/return_503")) { + | return (synth(503, "Varnish is in maintenance")); + | } + $Function VOID collect(HEADER hdr, STRING sep=", ") Description diff --git a/lib/libvmod_std/vmod_std.c b/lib/libvmod_std/vmod_std.c index 601de8b..717982e 100644 --- a/lib/libvmod_std/vmod_std.c +++ b/lib/libvmod_std/vmod_std.c @@ -28,11 +28,15 @@ #include "config.h" +#include +#include + #include #include #include #include +#include #include "cache/cache.h" @@ -173,6 +177,15 @@ vmod_syslog(VRT_CTX, VCL_INT fac, const char *fmt, ...) WS_Release(ctx->ws, 0); } +VCL_BOOL __match_proto__(td_std_file_exists) +vmod_file_exists(VRT_CTX, VCL_STRING file_name) +{ + struct stat st; + + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + return (stat(file_name, &st) == 0); +} + VCL_VOID __match_proto__(td_std_collect) vmod_collect(VRT_CTX, VCL_HEADER hdr, VCL_STRING sep) { From fgsch at lodoss.net Fri Apr 14 10:39:05 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Fri, 14 Apr 2017 12:39:05 +0200 Subject: [master] 9284b8b Rework test to work in both 32 and 64 bits Message-ID: commit 9284b8b68fe1eb14d130829c8bd64753e2d0b3cd Author: Federico G. Schwindt Date: Fri Apr 14 14:34:42 2017 +0900 Rework test to work in both 32 and 64 bits diff --git a/bin/varnishtest/tests/r02233.vtc b/bin/varnishtest/tests/r02233.vtc index fad35b2..f877f60 100644 --- a/bin/varnishtest/tests/r02233.vtc +++ b/bin/varnishtest/tests/r02233.vtc @@ -1,26 +1,30 @@ varnishtest "Fail earlier if we cannot fit the query string" -feature 64bit - server s1 { rxreq txresp } -start -varnish v1 -arg "-p workspace_client=9k" -vcl+backend { +varnish v1 -vcl+backend { + import debug; import std; sub vcl_recv { - set req.url = std.querysort(req.url); + debug.workspace_allocate(client, -92); + if (std.querysort(req.url) == req.url) { + std.log("querysort failed"); + } } } -start +logexpect l1 -v v1 { + expect * * VCL_Log "querysort failed" +} -start + client c1 { - send "GET /?a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1" - send "&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1" - send "&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1" - send " HTTP/1.1\r\n" - send "Host: foo\r\n\r\n" + txreq -url /?a=2&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1&a=1 rxresp expect resp.status == 500 } -run + +logexpect l1 -wait From fgsch at lodoss.net Fri Apr 14 10:39:05 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Fri, 14 Apr 2017 12:39:05 +0200 Subject: [master] 5ae3f01 Spelling Message-ID: commit 5ae3f0181cea26b204a51f02e538c1669fdab4de Author: Federico G. Schwindt Date: Fri Apr 14 19:33:58 2017 +0900 Spelling diff --git a/doc/sphinx/reference/vsl-query.rst b/doc/sphinx/reference/vsl-query.rst index a91d404..891d361 100644 --- a/doc/sphinx/reference/vsl-query.rst +++ b/doc/sphinx/reference/vsl-query.rst @@ -66,14 +66,14 @@ The grouping modes are: * ``vxid`` - Transactions are not grouped, so each vxid is reported in it's + Transactions are not grouped, so each vxid is reported in its entirety. Sessions, requests, ESI-requests and backend requests are all reported individually. Non-transactional data is not reported (vxid == 0). This is the default. * ``raw`` - Every log record will make up a transaction of it's own. All data, + Every log record will make up a transaction of its own. All data, including non-transactional data will be reported. Transaction Hierarchy @@ -154,7 +154,7 @@ the name or at the end, and will select all tags that match either the prefix or subscript. A single '*' will select all tags. The record prefix will further limit the matches to those records that -has this prefix as it's first part of the record content followed by a +has this prefix as their first part of the record content followed by a colon. The part of the log record matched against will then be limited to what follows the prefix and colon. This is useful when matching against specific HTTP headers. The record prefix matching is done case From fgsch at lodoss.net Fri Apr 14 15:26:06 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Fri, 14 Apr 2017 17:26:06 +0200 Subject: [master] d84c2dd Shuffle things around in prep for upcoming work Message-ID: commit d84c2dd718c5548673bddc6e36f510c5649458b8 Author: Federico G. Schwindt Date: Fri Apr 14 21:07:13 2017 +0900 Shuffle things around in prep for upcoming work diff --git a/bin/varnishncsa/varnishncsa.c b/bin/varnishncsa/varnishncsa.c index bec05e5..bfb38aa 100644 --- a/bin/varnishncsa/varnishncsa.c +++ b/bin/varnishncsa/varnishncsa.c @@ -804,11 +804,10 @@ parse_format(const char *format) } static int -isprefix(const char *prefix, const char *b, const char *e, const char **next) +isprefix(const char *prefix, size_t len, const char *b, + const char *e, const char **next) { - size_t len; - - len = strlen(prefix); + assert(len > 0); if (e - b < len || strncasecmp(b, prefix, len)) return (0); b += len; @@ -897,6 +896,24 @@ process_hdr(const struct watch_head *head, const char *b, const char *e) } } + +static void +process_vsl(const struct vsl_watch_head *head, enum VSL_tag_e tag, + const char *b, const char *e) +{ + struct vsl_watch *w; + + VTAILQ_FOREACH(w, head, list) { + CHECK_OBJ_NOTNULL(w, VSL_WATCH_MAGIC); + if (tag != w->tag) + continue; + if (w->idx == 0) + frag_line(0, b, e, &w->frag); + else + frag_fields(0, b, e, w->idx, &w->frag, 0, NULL); + } +} + static int __match_proto__(VSLQ_dispatch_f) dispatch_f(struct VSL_data *vsl, struct VSL_transaction * const pt[], void *priv) @@ -905,7 +922,6 @@ dispatch_f(struct VSL_data *vsl, struct VSL_transaction * const pt[], unsigned tag; const char *b, *e, *p; struct watch *w; - struct vsl_watch *vslw; int i, skip, be_mark; (void)vsl; (void)priv; @@ -991,32 +1007,34 @@ dispatch_f(struct VSL_data *vsl, struct VSL_transaction * const pt[], break; case (SLT_Timestamp + BACKEND_MARKER): case SLT_Timestamp: - if (isprefix("Start:", b, e, &p)) { +#define PREFIX(a, b, c, d) isprefix(a, strlen(a), b, c, d) + if (PREFIX("Start:", b, e, &p)) { frag_fields(0, p, e, 1, &CTX.frag[F_tstart], 0, NULL); - } else if (isprefix("Resp:", b, e, &p) || - isprefix("PipeSess:", b, e, &p) || - isprefix("BerespBody:", b, e, &p)) { + } else if (PREFIX("Resp:", b, e, &p) || + PREFIX("PipeSess:", b, e, &p) || + PREFIX("BerespBody:", b, e, &p)) { frag_fields(0, p, e, 1, &CTX.frag[F_tend], 0, NULL); - } else if (isprefix("Process:", b, e, &p) || - isprefix("Pipe:", b, e, &p) || - isprefix("Beresp:", b, e, &p)) { + } else if (PREFIX("Process:", b, e, &p) || + PREFIX("Pipe:", b, e, &p) || + PREFIX("Beresp:", b, e, &p)) { frag_fields(0, p, e, 2, &CTX.frag[F_ttfb], 0, NULL); } break; case (SLT_BereqHeader + BACKEND_MARKER): case SLT_ReqHeader: - if (isprefix("Authorization:", b, e, &p) && - isprefix("basic ", p, e, &p)) + if (PREFIX("Authorization:", b, e, &p) && + PREFIX("basic ", p, e, &p)) frag_line(0, p, e, &CTX.frag[F_auth]); - else if (isprefix("Host:", b, e, &p)) + else if (PREFIX("Host:", b, e, &p)) frag_line(0, p, e, &CTX.frag[F_host]); +#undef PREFIX break; case SLT_VCL_call: if (!strcasecmp(b, "recv")) { @@ -1073,18 +1091,7 @@ dispatch_f(struct VSL_data *vsl, struct VSL_transaction * const pt[], (tag == SLT_BerespHeader && CTX.b_opt)) process_hdr(&CTX.watch_resphdr, b, e); - VTAILQ_FOREACH(vslw, &CTX.watch_vsl, list) { - CHECK_OBJ_NOTNULL(vslw, VSL_WATCH_MAGIC); - if (tag == vslw->tag) { - if (vslw->idx == 0) - frag_line(0, b, e, - &vslw->frag); - else - frag_fields(0, b, e, - vslw->idx, &vslw->frag, - 0, NULL); - } - } + process_vsl(&CTX.watch_vsl, tag, b ,e); } if (skip) continue; From fgsch at lodoss.net Fri Apr 14 15:58:06 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Fri, 14 Apr 2017 17:58:06 +0200 Subject: [master] 396316b Add record-prefix support to varnishncsa Message-ID: commit 396316ba442e6f9aa000297cb24c6ce4057db6cf Author: Federico G. Schwindt Date: Fri Apr 14 17:54:27 2017 +0200 Add record-prefix support to varnishncsa The parsing still requires some TLC but this does not make it any worse so let's get this in first. Prompted by and ideas from github::xcir via #2077. diff --git a/bin/varnishncsa/varnishncsa.c b/bin/varnishncsa/varnishncsa.c index bfb38aa..f446fce 100644 --- a/bin/varnishncsa/varnishncsa.c +++ b/bin/varnishncsa/varnishncsa.c @@ -130,6 +130,8 @@ struct vsl_watch { VTAILQ_ENTRY(vsl_watch) list; enum VSL_tag_e tag; int idx; + char *prefix; + int prefixlen; struct fragment frag; }; VTAILQ_HEAD(vsl_watch_head, vsl_watch); @@ -567,7 +569,7 @@ addf_hdr(struct watch_head *head, const char *key, const char *str) } static void -addf_vsl(enum VSL_tag_e tag, long i) +addf_vsl(enum VSL_tag_e tag, long i, const char *prefix) { struct vsl_watch *w; @@ -576,6 +578,10 @@ addf_vsl(enum VSL_tag_e tag, long i) w->tag = tag; assert(i <= INT_MAX); w->idx = i; + if (prefix) { + assert(asprintf(&w->prefix, "%s:", prefix) > 0); + w->prefixlen = strlen(w->prefix); + } VTAILQ_INSERT_TAIL(&CTX.watch_vsl, w, list); addf_fragment(&w->frag, "-"); @@ -658,14 +664,23 @@ parse_x_format(char *buf) *r = '\0'; } else i = 0; - slt = VSL_Name2Tag(buf, -1); + r = buf; + while (r < e && *r != ':') + r++; + if (r != e) { + slt = VSL_Name2Tag(buf, r - buf); + r++; + } else { + slt = VSL_Name2Tag(buf, -1); + r = NULL; + } if (slt == -2) VUT_Error(1, "Tag not unique: %s", buf); if (slt == -1) VUT_Error(1, "Unknown log tag: %s", buf); assert(slt >= 0); - addf_vsl(slt, i); + addf_vsl(slt, i, r); return; } VUT_Error(1, "Unknown formatting extension: %s", buf); @@ -902,15 +917,20 @@ process_vsl(const struct vsl_watch_head *head, enum VSL_tag_e tag, const char *b, const char *e) { struct vsl_watch *w; + const char *p; VTAILQ_FOREACH(w, head, list) { CHECK_OBJ_NOTNULL(w, VSL_WATCH_MAGIC); if (tag != w->tag) continue; + p = b; + if (w->prefixlen > 0 && + !isprefix(w->prefix, w->prefixlen, b, e, &p)) + continue; if (w->idx == 0) - frag_line(0, b, e, &w->frag); + frag_line(0, p, e, &w->frag); else - frag_fields(0, b, e, w->idx, &w->frag, 0, NULL); + frag_fields(0, p, e, w->idx, &w->frag, 0, NULL); } } @@ -1091,7 +1111,7 @@ dispatch_f(struct VSL_data *vsl, struct VSL_transaction * const pt[], (tag == SLT_BerespHeader && CTX.b_opt)) process_hdr(&CTX.watch_resphdr, b, e); - process_vsl(&CTX.watch_vsl, tag, b ,e); + process_vsl(&CTX.watch_vsl, tag, b, e); } if (skip) continue; diff --git a/bin/varnishtest/tests/u00003.vtc b/bin/varnishtest/tests/u00003.vtc index d799a51..adac521 100644 --- a/bin/varnishtest/tests/u00003.vtc +++ b/bin/varnishtest/tests/u00003.vtc @@ -17,6 +17,30 @@ shell { -w ${tmpdir}/ncsa.log } +delay 1 + +client c1 { + txreq -url /foo + rxresp +} -run + +delay 1 + +shell "mv ${tmpdir}/ncsa.log ${tmpdir}/ncsa.old.log" +shell "kill -HUP `cat ${tmpdir}/ncsa.pid`" + +client c1 { + txreq -url /bar + rxresp +} -run + +delay 1 + +shell "kill `cat ${tmpdir}/ncsa.pid`" + +shell "grep -q /foo ${tmpdir}/ncsa.old.log" +shell "grep -q /bar ${tmpdir}/ncsa.log" + shell -expect "Usage: varnishncsa " \ "varnishncsa -h" shell -expect "Copyright (c) 2006 Verdens Gang AS" \ @@ -58,32 +82,10 @@ shell -err -expect "Empty format file" \ #shell -err -expect "Can't read format from file (Is a directory)" \ # {varnishncsa -f ${tmpdir}} -delay 1 - -client c1 { - txreq -url /foo - rxresp -} -run - -delay 1 - -shell "mv ${tmpdir}/ncsa.log ${tmpdir}/ncsa.old.log" -shell "kill -HUP `cat ${tmpdir}/ncsa.pid`" - -client c1 { - txreq -url /bar - rxresp -} -run - -delay 1 - -shell "kill `cat ${tmpdir}/ncsa.pid`" - -shell "grep -q /foo ${tmpdir}/ncsa.old.log" -shell "grep -q /bar ${tmpdir}/ncsa.log" - shell {echo "%{VSL:Begin}x %{Varnish:vxid}x %{VCL_Log:foo}x %D %T %{Varnish:handling}x %{%Z}t" >${tmpdir}/format} shell -match "^req 1000 rxreq 1001 [0-9]+ 0 miss [A-Z]{3,}" \ {varnishncsa -n ${v1_name} -d -f ${tmpdir}/format} shell -match "^bereq 1001 fetch 1002 qux [0-9]+ 0 - [A-Z]{3,}" \ {varnishncsa -n ${v1_name} -d -f ${tmpdir}/format -b} +shell -match "\d{10}\.\d{6} \d\.\d{6} \d\.\d{6} - \d{10}\.\d{6}" \ + {varnishncsa -n ${v1_name} -d -F "%{VSL:Timestamp:Resp}x %{VSL:Timestamp:foo}x %{VSL:Timestamp:Resp[2]}x"} diff --git a/doc/sphinx/reference/varnishncsa.rst b/doc/sphinx/reference/varnishncsa.rst index ce1b1d9..2f9492f 100644 --- a/doc/sphinx/reference/varnishncsa.rst +++ b/doc/sphinx/reference/varnishncsa.rst @@ -174,13 +174,22 @@ Supported formatters are: VCL_Log:key The value set by std.log("key:value") in VCL. - VSL:tag[field] - The value of the VSL entry for the given tag. The field will, - if present, treat the log record as a white space separated list - of fields, and only the nth part of the record will be matched - against. Fields start counting at 1. Defaults to '-' when the tag - is not seen, or when the field is out of bounds. If a tag appears - multiple times in a single transaction, the first occurrence is used. + VSL:tag:record-prefix[field] + The value of the VSL entry for the given tag-record prefix-field + combination. Tag is mandatory, the other components are optional. + + The record prefix will limit the matches to those records that + have this prefix as the first part of the record content followed + by a colon. + + The field will, if present, treat the log record as a white + space separated list of fields, and only the nth part of the + record will be matched against. Fields start counting at 1. + + Defaults to '-' when the tag is not seen, the record prefix + does not match or the field is out of bounds. If a tag appears + multiple times in a single transaction, the first occurrence + is used. SIGNALS ======= @@ -202,11 +211,15 @@ multiple times in a single transaction, the first occurrence is used. EXAMPLE ======= -Log the second field of the Begin tag, corresponding to the VXID of the -parent transaction:: +Log the second field of the Begin record, corresponding to the VXID +of the parent transaction:: varnishncsa -F "%{VSL:Begin[2]}x" +Log the entire Timestamp record associated with the processing length:: + + varnishncsa -F "%{VSL:Timestamp:Process}x" + SEE ALSO ======== From fgsch at lodoss.net Sun Apr 16 07:31:06 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sun, 16 Apr 2017 09:31:06 +0200 Subject: [master] 76b31eb Polish Message-ID: commit 76b31ebffc1c3800aec596a6c95067bcd4949f0f Author: Federico G. Schwindt Date: Sat Apr 15 04:50:24 2017 +0100 Polish diff --git a/bin/varnishncsa/varnishncsa.c b/bin/varnishncsa/varnishncsa.c index f446fce..cdfde2d 100644 --- a/bin/varnishncsa/varnishncsa.c +++ b/bin/varnishncsa/varnishncsa.c @@ -827,7 +827,7 @@ isprefix(const char *prefix, size_t len, const char *b, return (0); b += len; if (next) { - while (b < e && *b && *b == ' ') + while (b < e && *b == ' ') b++; *next = b; } @@ -891,7 +891,7 @@ frag_line(int force, const char *b, const char *e, struct fragment *f) ++b; /* Skip trailing space */ - while (e > b && isspace(*(e - 1))) + while (e > b && isspace(e[-1])) --e; f->gen = CTX.gen; @@ -911,7 +911,6 @@ process_hdr(const struct watch_head *head, const char *b, const char *e) } } - static void process_vsl(const struct vsl_watch_head *head, enum VSL_tag_e tag, const char *b, const char *e) @@ -1027,34 +1026,34 @@ dispatch_f(struct VSL_data *vsl, struct VSL_transaction * const pt[], break; case (SLT_Timestamp + BACKEND_MARKER): case SLT_Timestamp: -#define PREFIX(a, b, c, d) isprefix(a, strlen(a), b, c, d) - if (PREFIX("Start:", b, e, &p)) { +#define ISPREFIX(a, b, c, d) isprefix(a, strlen(a), b, c, d) + if (ISPREFIX("Start:", b, e, &p)) { frag_fields(0, p, e, 1, &CTX.frag[F_tstart], 0, NULL); - } else if (PREFIX("Resp:", b, e, &p) || - PREFIX("PipeSess:", b, e, &p) || - PREFIX("BerespBody:", b, e, &p)) { + } else if (ISPREFIX("Resp:", b, e, &p) || + ISPREFIX("PipeSess:", b, e, &p) || + ISPREFIX("BerespBody:", b, e, &p)) { frag_fields(0, p, e, 1, &CTX.frag[F_tend], 0, NULL); - } else if (PREFIX("Process:", b, e, &p) || - PREFIX("Pipe:", b, e, &p) || - PREFIX("Beresp:", b, e, &p)) { + } else if (ISPREFIX("Process:", b, e, &p) || + ISPREFIX("Pipe:", b, e, &p) || + ISPREFIX("Beresp:", b, e, &p)) { frag_fields(0, p, e, 2, &CTX.frag[F_ttfb], 0, NULL); } break; case (SLT_BereqHeader + BACKEND_MARKER): case SLT_ReqHeader: - if (PREFIX("Authorization:", b, e, &p) && - PREFIX("basic ", p, e, &p)) + if (ISPREFIX("Authorization:", b, e, &p) && + ISPREFIX("basic ", p, e, &p)) frag_line(0, p, e, &CTX.frag[F_auth]); - else if (PREFIX("Host:", b, e, &p)) + else if (ISPREFIX("Host:", b, e, &p)) frag_line(0, p, e, &CTX.frag[F_host]); -#undef PREFIX +#undef ISPREFIX break; case SLT_VCL_call: if (!strcasecmp(b, "recv")) { From fgsch at lodoss.net Sun Apr 16 07:50:05 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sun, 16 Apr 2017 09:50:05 +0200 Subject: [master] 8583f91 More coverage and fixes Message-ID: commit 8583f91d99bd28aa99e4d354f4119ccf510a3e89 Author: Federico G. Schwindt Date: Sun Apr 16 08:48:55 2017 +0100 More coverage and fixes diff --git a/bin/varnishtest/tests/u00003.vtc b/bin/varnishtest/tests/u00003.vtc index adac521..b3559bb 100644 --- a/bin/varnishtest/tests/u00003.vtc +++ b/bin/varnishtest/tests/u00003.vtc @@ -7,8 +7,15 @@ server s1 -repeat 2 { varnish v1 -vcl+backend { import std; - sub vcl_backend_fetch { - std.log("foo:qux"); + + sub vcl_recv { + if (req.url == "/2") { + return (pipe); + } + } + + sub vcl_miss { + std.log("quux:quuz"); } } -start @@ -20,7 +27,9 @@ shell { delay 1 client c1 { - txreq -url /foo + txreq -url /1?foo=bar -hdr "baz: qux" + rxresp + txreq -url /1?foo=bar rxresp } -run @@ -30,7 +39,7 @@ shell "mv ${tmpdir}/ncsa.log ${tmpdir}/ncsa.old.log" shell "kill -HUP `cat ${tmpdir}/ncsa.pid`" client c1 { - txreq -url /bar + txreq -url /2 rxresp } -run @@ -38,9 +47,13 @@ delay 1 shell "kill `cat ${tmpdir}/ncsa.pid`" -shell "grep -q /foo ${tmpdir}/ncsa.old.log" -shell "grep -q /bar ${tmpdir}/ncsa.log" +# default formatter and rotation +shell -match {127.0.0.1 - - \[../.../20[1-9][0-9]:..:..:.. \+....\] (?# +)"GET http://localhost/1\?foo=bar HTTP/1.1" 200 0 "-" "-"} \ + "cat ${tmpdir}/ncsa.old.log" +shell "grep -q /2 ${tmpdir}/ncsa.log" +# command line shell -expect "Usage: varnishncsa " \ "varnishncsa -h" shell -expect "Copyright (c) 2006 Verdens Gang AS" \ @@ -51,10 +64,10 @@ shell -err -expect "Unknown format specifier at: %{foo}A" \ {varnishncsa -F "%{foo}A"} shell -err -expect "Unknown format specifier at: %A" \ {varnishncsa -F "%A"} +shell -err -expect "Unmatched bracket at: %{foo" \ + "varnishncsa -F %{foo" shell -err -expect "Unknown formatting extension: foo" \ {varnishncsa -F "%{foo}x"} -shell -err -expect "Usage: varnishncsa " \ - {varnishncsa extra} shell -err -expect "Missing tag in VSL:" \ {varnishncsa -F "%{VSL:}x"} shell -err -expect "Unknown log tag: nonexistent" \ @@ -69,9 +82,11 @@ shell -err -expect "Unknown log tag: Begin[a" \ {varnishncsa -F "%{VSL:Begin[a}x"} shell -err -expect "Syntax error: VSL:Begin[a]" \ {varnishncsa -F "%{VSL:Begin[a]}x"} -shell -err -expect "Syntax error. Field specifier must be positive: Begin[0]" \ +shell -err -match {Syntax error. (?# +)Field specifier must be positive: Begin\[0\]} \ {varnishncsa -F "%{VSL:Begin[0]}x"} -shell -err -expect "Field specifier 999999999999 for the tag VSL:Begin[999999999999] is probably too high" \ +shell -err -match {Field specifier 999999999999 for the tag (?# +)VSL:Begin\[999999999999\] is probably too high} \ {varnishncsa -F "%{VSL:Begin[999999999999]}x"} shell -err -expect "Can't open format file (No such file or directory)" \ {varnishncsa -f /nonexistent/file} @@ -81,11 +96,36 @@ shell -err -expect "Empty format file" \ # directory but happily works in FreeBSD. #shell -err -expect "Can't read format from file (Is a directory)" \ # {varnishncsa -f ${tmpdir}} +shell -err -expect "Invalid grouping mode: session" \ + {varnishncsa -g session} +shell -err -expect "Can't open output file (No such file or directory)" \ + {varnishncsa -w /nonexistent/file} +shell -err -expect "Usage: varnishncsa " \ + {varnishncsa extra} -shell {echo "%{VSL:Begin}x %{Varnish:vxid}x %{VCL_Log:foo}x %D %T %{Varnish:handling}x %{%Z}t" >${tmpdir}/format} -shell -match "^req 1000 rxreq 1001 [0-9]+ 0 miss [A-Z]{3,}" \ +# -f and standard formatters +shell {echo "%b %D %H %h %I %{baz}i %l %m %{Age}o %O %q %s %t %{%Y}t \ +%T %U %u" > ${tmpdir}/format} +shell -match {^\d+ \d+ HTTP/1.1 127.0.0.1 \d+ qux - GET 0 \d+ (?# +)\?foo=bar 200 \[../.../(20[1-9][0-9]):..:..:.. \+....\] \1 \d+ /1 - +\d+ \d+ HTTP/1.1 127.0.0.1 \d+ - - GET 0 \d+ (?# +)\?foo=bar 200 \[../.../(20[1-9][0-9]):..:..:.. \+....\] \1 \d+ /1 - +- \d+ HTTP/1.1 127.0.0.1 \d+ - - GET - \d+ (?# +) - \[../.../(20[1-9][0-9]):..:..:.. \+....\] \1 \d+ /2 -$} \ {varnishncsa -n ${v1_name} -d -f ${tmpdir}/format} -shell -match "^bereq 1001 fetch 1002 qux [0-9]+ 0 - [A-Z]{3,}" \ - {varnishncsa -n ${v1_name} -d -f ${tmpdir}/format -b} -shell -match "\d{10}\.\d{6} \d\.\d{6} \d\.\d{6} - \d{10}\.\d{6}" \ - {varnishncsa -n ${v1_name} -d -F "%{VSL:Timestamp:Resp}x %{VSL:Timestamp:foo}x %{VSL:Timestamp:Resp[2]}x"} + +# extended variables +shell -match {^\d+.\d{6} miss miss c 1001 quuz +\d+.\d{6} hit hit c 1003\s +\d+.\d{6} miss pipe c 1005\s$} \ + {varnishncsa -n ${v1_name} -d -F "%{Varnish:time_firstbyte}x \ +%{Varnish:hitmiss}x %{Varnish:handling}x %{Varnish:side}x \ +%{Varnish:vxid}x %{VCL_Log:quux}x"} + +# %{VSL:..}x +shell -match {^req (\d+) rxreq \1 \d{10}\.\d{6} (\d+\.\d{6}) \d+\.\d{6} \2 - +req (\d+) rxreq \3 \d{10}\.\d{6} (\d+\.\d{6}) \d+\.\d{6} \4 - +req (\d+) rxreq \5 - - -$} \ + {varnishncsa -n ${v1_name} -d -F "%{VSL:Begin}x \ +%{VSL:Begin[2]}x %{VSL:Timestamp:Resp}x \ +%{VSL:Timestamp:Resp[2]}x %{VSL:Timestamp:foo}x"} From fgsch at lodoss.net Sun Apr 16 10:21:06 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sun, 16 Apr 2017 12:21:06 +0200 Subject: [master] 8ede23d Don't assume 127.0.0.1 Message-ID: commit 8ede23dece6a73b54ae8aba3f913c1bebf37b7f1 Author: Federico G. Schwindt Date: Sun Apr 16 11:17:16 2017 +0100 Don't assume 127.0.0.1 diff --git a/bin/varnishtest/tests/u00003.vtc b/bin/varnishtest/tests/u00003.vtc index b3559bb..4d4b4ea 100644 --- a/bin/varnishtest/tests/u00003.vtc +++ b/bin/varnishtest/tests/u00003.vtc @@ -48,7 +48,7 @@ delay 1 shell "kill `cat ${tmpdir}/ncsa.pid`" # default formatter and rotation -shell -match {127.0.0.1 - - \[../.../20[1-9][0-9]:..:..:.. \+....\] (?# +shell -match {\d+.\d+.\d+.\d+ - - \[../.../20[1-9][0-9]:..:..:.. \+....\] (?# )"GET http://localhost/1\?foo=bar HTTP/1.1" 200 0 "-" "-"} \ "cat ${tmpdir}/ncsa.old.log" shell "grep -q /2 ${tmpdir}/ncsa.log" @@ -106,11 +106,11 @@ shell -err -expect "Usage: varnishncsa " \ # -f and standard formatters shell {echo "%b %D %H %h %I %{baz}i %l %m %{Age}o %O %q %s %t %{%Y}t \ %T %U %u" > ${tmpdir}/format} -shell -match {^\d+ \d+ HTTP/1.1 127.0.0.1 \d+ qux - GET 0 \d+ (?# +shell -match {^\d+ \d+ HTTP/1.1 \d+.\d+.\d+.\d+ \d+ qux - GET 0 \d+ (?# )\?foo=bar 200 \[../.../(20[1-9][0-9]):..:..:.. \+....\] \1 \d+ /1 - -\d+ \d+ HTTP/1.1 127.0.0.1 \d+ - - GET 0 \d+ (?# +\d+ \d+ HTTP/1.1 \d+.\d+.\d+.\d+ \d+ - - GET 0 \d+ (?# )\?foo=bar 200 \[../.../(20[1-9][0-9]):..:..:.. \+....\] \1 \d+ /1 - -- \d+ HTTP/1.1 127.0.0.1 \d+ - - GET - \d+ (?# +- \d+ HTTP/1.1 \d+.\d+.\d+.\d+ \d+ - - GET - \d+ (?# ) - \[../.../(20[1-9][0-9]):..:..:.. \+....\] \1 \d+ /2 -$} \ {varnishncsa -n ${v1_name} -d -f ${tmpdir}/format} From fgsch at lodoss.net Sun Apr 16 16:23:05 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sun, 16 Apr 2017 18:23:05 +0200 Subject: [master] 8a8f07f Further coverage and corrections Message-ID: commit 8a8f07ffd2bf920340c71059b1b9a49a84910f55 Author: Federico G. Schwindt Date: Sun Apr 16 14:20:44 2017 +0100 Further coverage and corrections diff --git a/bin/varnishtest/tests/u00003.vtc b/bin/varnishtest/tests/u00003.vtc index 4d4b4ea..61cabf9 100644 --- a/bin/varnishtest/tests/u00003.vtc +++ b/bin/varnishtest/tests/u00003.vtc @@ -2,7 +2,7 @@ varnishtest "varnishncsa coverage" server s1 -repeat 2 { rxreq - txresp + txresp -bodylen 100 } -start varnish v1 -vcl+backend { @@ -12,11 +12,16 @@ varnish v1 -vcl+backend { if (req.url == "/2") { return (pipe); } + return (hash); } sub vcl_miss { std.log("quux:quuz"); } + + sub vcl_hit { + return (synth(404)); + } } -start shell { @@ -27,9 +32,9 @@ shell { delay 1 client c1 { - txreq -url /1?foo=bar -hdr "baz: qux" + txreq -url /1?foo=bar -hdr "authorization: basic dXNlcjpwYXNz" rxresp - txreq -url /1?foo=bar + txreq -url /1?foo=bar -hdr "baz: qux" rxresp } -run @@ -48,8 +53,10 @@ delay 1 shell "kill `cat ${tmpdir}/ncsa.pid`" # default formatter and rotation -shell -match {\d+.\d+.\d+.\d+ - - \[../.../20[1-9][0-9]:..:..:.. \+....\] (?# -)"GET http://localhost/1\?foo=bar HTTP/1.1" 200 0 "-" "-"} \ +shell -match {^\d+.\d+.\d+.\d+ - user \[../.../20[1-9][0-9]:..:..:.. (?# +)[+-]....\] "GET http://localhost/1\?foo=bar HTTP/1.1" 200 100 "-" "-" +\d+.\d+.\d+.\d+ - - \[../.../20[1-9][0-9]:..:..:.. [+-]....\] (?# +)"GET http://localhost/1\?foo=bar HTTP/1.1" 404 \d+ "-" "-"$} \ "cat ${tmpdir}/ncsa.old.log" shell "grep -q /2 ${tmpdir}/ncsa.log" @@ -103,20 +110,30 @@ shell -err -expect "Can't open output file (No such file or directory)" \ shell -err -expect "Usage: varnishncsa " \ {varnishncsa extra} +# -b +shell -match {^127.0.0.1 100 +- 0$} \ + {varnishncsa -n ${v1_name} -b -d -F "%{Host}i %b"} +# -c +shell -match {^- 100 +- \d+ +- -$} \ + {varnishncsa -n ${v1_name} -c -d -F "%{Host}i %b"} + # -f and standard formatters shell {echo "%b %D %H %h %I %{baz}i %l %m %{Age}o %O %q %s %t %{%Y}t \ %T %U %u" > ${tmpdir}/format} -shell -match {^\d+ \d+ HTTP/1.1 \d+.\d+.\d+.\d+ \d+ qux - GET 0 \d+ (?# -)\?foo=bar 200 \[../.../(20[1-9][0-9]):..:..:.. \+....\] \1 \d+ /1 - -\d+ \d+ HTTP/1.1 \d+.\d+.\d+.\d+ \d+ - - GET 0 \d+ (?# -)\?foo=bar 200 \[../.../(20[1-9][0-9]):..:..:.. \+....\] \1 \d+ /1 - +shell -match {^100 \d+ HTTP/1.1 \d+.\d+.\d+.\d+ \d+ - - GET 0 \d+ (?# +)\?foo=bar 200 \[../.../(20[1-9][0-9]):..:..:.. [+-]....\] \1 \d+ /1 user +\d+ \d+ HTTP/1.1 \d+.\d+.\d+.\d+ \d+ qux - GET - \d+ (?# +)\?foo=bar 404 \[../.../(20[1-9][0-9]):..:..:.. [+-]....\] \1 \d+ /1 - - \d+ HTTP/1.1 \d+.\d+.\d+.\d+ \d+ - - GET - \d+ (?# -) - \[../.../(20[1-9][0-9]):..:..:.. \+....\] \1 \d+ /2 -$} \ +) - \[../.../(20[1-9][0-9]):..:..:.. [+-]....\] \1 \d+ /2 -$} \ {varnishncsa -n ${v1_name} -d -f ${tmpdir}/format} # extended variables shell -match {^\d+.\d{6} miss miss c 1001 quuz -\d+.\d{6} hit hit c 1003\s +\d+.\d{6} miss synth c 1003\s \d+.\d{6} miss pipe c 1005\s$} \ {varnishncsa -n ${v1_name} -d -F "%{Varnish:time_firstbyte}x \ %{Varnish:hitmiss}x %{Varnish:handling}x %{Varnish:side}x \ diff --git a/bin/varnishtest/tests/u00006.vtc b/bin/varnishtest/tests/u00006.vtc index 1514a87..221138e 100644 --- a/bin/varnishtest/tests/u00006.vtc +++ b/bin/varnishtest/tests/u00006.vtc @@ -39,6 +39,8 @@ shell -err -expect {-x: Syntax error in "**"} \ {varnishlog -x "**"} shell -err -expect {-X: Syntax error in "**"} \ {varnishlog -X "**:bar"} +shell -err -expect "Cannot open output file (No such file or directory)" \ + {varnishlog -w /nonexistent/file} process p1 -wait shell {grep -q "0 CLI" ${tmpdir}/vlog} @@ -66,13 +68,12 @@ shell "kill `cat ${tmpdir}/vlog.pid`" shell -match {^\*[ ]+<< Request\s+>>[ ]+1001[ ]+ -[ ]+1001 ReqURL[ ]+c /foo -$} { - varnishlog -v -r ${tmpdir}/vlog.bin~ -i ReqURL -q "RespStatus == 200" -} +$} \ + {varnishlog -r ${tmpdir}/vlog.bin~ -i ReqURL -v \ + -q "RespStatus == 200"} shell -match "-[ ]+BereqURL[ ]+/bar" \ "varnishlog -r ${tmpdir}/vlog.bin -x ReqURL" shell -match {^\*[ ]+<< BeReq\s+>>[ ]+1005[ ]+ -[ ]+BereqURL[ ]+/bar -$} { - varnishlog -r ${tmpdir}/vlog.bin -b -C -I BAR -} +$} \ + "varnishlog -r ${tmpdir}/vlog.bin -b -C -I BAR" From fgsch at lodoss.net Sun Apr 16 16:23:05 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sun, 16 Apr 2017 18:23:05 +0200 Subject: [master] 4250773 More cleanup Message-ID: commit 4250773b0841621a3b3f102f358301b905876446 Author: Federico G. Schwindt Date: Sun Apr 16 14:38:06 2017 +0100 More cleanup diff --git a/bin/varnishncsa/varnishncsa.c b/bin/varnishncsa/varnishncsa.c index cdfde2d..fac7959 100644 --- a/bin/varnishncsa/varnishncsa.c +++ b/bin/varnishncsa/varnishncsa.c @@ -487,7 +487,7 @@ addf_int32(int32_t *i) } static void -addf_time(char type, const char *fmt, const char *str) +addf_time(char type, const char *fmt) { struct format *f; @@ -499,10 +499,6 @@ addf_time(char type, const char *fmt, const char *str) f->time_fmt = strdup(fmt); AN(f->time_fmt); } - if (str != NULL) { - f->string = strdup(str); - AN(f->string); - } VTAILQ_INSERT_TAIL(&CTX.format, f, list); } @@ -526,8 +522,7 @@ addf_vcl_log(const char *key, const char *str) AN(key); ALLOC_OBJ(w, WATCH_MAGIC); AN(w); - w->key = strdup(key); - AN(w->key); + assert(asprintf(&w->key, "%s:", key) > 0); w->keylen = strlen(w->key); VTAILQ_INSERT_TAIL(&CTX.watch_vcl_log, w, list); @@ -727,7 +722,7 @@ parse_format(const char *format) addf_fragment(&CTX.frag[F_b], "-"); break; case 'D': /* Float request time */ - addf_time(*p, NULL, NULL); + addf_time(*p, NULL); break; case 'h': /* Client host name / IP Address */ addf_fragment(&CTX.frag[F_h], "-"); @@ -757,10 +752,10 @@ parse_format(const char *format) addf_fragment(&CTX.frag[F_s], "-"); break; case 't': /* strftime */ - addf_time(*p, TIME_FMT, NULL); + addf_time(*p, TIME_FMT); break; case 'T': /* Int request time */ - addf_time(*p, NULL, NULL); + addf_time(*p, NULL); break; case 'u': /* Remote user from auth */ addf_auth("-"); @@ -790,7 +785,7 @@ parse_format(const char *format) addf_hdr(&CTX.watch_resphdr, buf, "-"); break; case 't': - addf_time(*q, buf, NULL); + addf_time(*q, buf); break; case 'x': parse_x_format(buf); @@ -903,11 +898,12 @@ static void process_hdr(const struct watch_head *head, const char *b, const char *e) { struct watch *w; + const char *p; VTAILQ_FOREACH(w, head, list) { - if (e - b < w->keylen || strncasecmp(b, w->key, w->keylen)) + if (!isprefix(w->key, w->keylen, b, e, &p)) continue; - frag_line(1, b + w->keylen, e, &w->frag); + frag_line(1, p, e, &w->frag); } } @@ -942,6 +938,7 @@ dispatch_f(struct VSL_data *vsl, struct VSL_transaction * const pt[], const char *b, *e, *p; struct watch *w; int i, skip, be_mark; + (void)vsl; (void)priv; @@ -1087,15 +1084,10 @@ dispatch_f(struct VSL_data *vsl, struct VSL_transaction * const pt[], case SLT_VCL_Log: VTAILQ_FOREACH(w, &CTX.watch_vcl_log, list) { CHECK_OBJ_NOTNULL(w, WATCH_MAGIC); - if (e - b <= w->keylen || + if (e - b < w->keylen || strncmp(b, w->key, w->keylen)) continue; p = b + w->keylen; - if (*p != ':') - continue; - p++; - if (p > e) - continue; frag_line(0, p, e, &w->frag); } break; From fgsch at lodoss.net Sun Apr 16 17:37:05 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sun, 16 Apr 2017 19:37:05 +0200 Subject: [master] c5f64a0 Another 127.0.0.1 that should not be Message-ID: commit c5f64a0990754e5703264f6e4e0bf7a7514d4943 Author: Federico G. Schwindt Date: Sun Apr 16 17:52:28 2017 +0100 Another 127.0.0.1 that should not be diff --git a/bin/varnishtest/tests/u00003.vtc b/bin/varnishtest/tests/u00003.vtc index 61cabf9..4b026c7 100644 --- a/bin/varnishtest/tests/u00003.vtc +++ b/bin/varnishtest/tests/u00003.vtc @@ -111,7 +111,7 @@ shell -err -expect "Usage: varnishncsa " \ {varnishncsa extra} # -b -shell -match {^127.0.0.1 100 +shell -match {^\d+.\d+.\d+.\d+ 100 - 0$} \ {varnishncsa -n ${v1_name} -b -d -F "%{Host}i %b"} # -c From dridi.boukelmoune at gmail.com Tue Apr 18 10:45:06 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 18 Apr 2017 12:45:06 +0200 Subject: [master] cf3d172 Polish Message-ID: commit cf3d1724641c8a33bbf397c7d8a5c7c5434cadc1 Author: Dridi Boukelmoune Date: Tue Apr 18 12:44:01 2017 +0200 Polish diff --git a/bin/varnishncsa/varnishncsa.c b/bin/varnishncsa/varnishncsa.c index fac7959..46f110c 100644 --- a/bin/varnishncsa/varnishncsa.c +++ b/bin/varnishncsa/varnishncsa.c @@ -118,7 +118,7 @@ struct watch { VTAILQ_ENTRY(watch) list; char *key; - unsigned keylen; + int keylen; struct fragment frag; }; VTAILQ_HEAD(watch_head, watch); @@ -522,8 +522,8 @@ addf_vcl_log(const char *key, const char *str) AN(key); ALLOC_OBJ(w, WATCH_MAGIC); AN(w); - assert(asprintf(&w->key, "%s:", key) > 0); - w->keylen = strlen(w->key); + w->keylen = asprintf(&w->key, "%s:", key); + assert(w->keylen > 0); VTAILQ_INSERT_TAIL(&CTX.watch_vcl_log, w, list); ALLOC_OBJ(f, FORMAT_MAGIC); @@ -574,8 +574,8 @@ addf_vsl(enum VSL_tag_e tag, long i, const char *prefix) assert(i <= INT_MAX); w->idx = i; if (prefix) { - assert(asprintf(&w->prefix, "%s:", prefix) > 0); - w->prefixlen = strlen(w->prefix); + w->prefixlen = asprintf(&w->prefix, "%s:", prefix); + assert(w->prefixlen > 0); } VTAILQ_INSERT_TAIL(&CTX.watch_vsl, w, list); From fgsch at lodoss.net Thu Apr 20 07:51:05 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Thu, 20 Apr 2017 09:51:05 +0200 Subject: [master] 81478a1 More cleanup Message-ID: commit 81478a1f1d7236701fd2b08eb2d4a6bf2cc3acd3 Author: Federico G. Schwindt Date: Wed Apr 19 14:13:24 2017 +0100 More cleanup diff --git a/bin/varnishncsa/varnishncsa.c b/bin/varnishncsa/varnishncsa.c index 46f110c..364f580 100644 --- a/bin/varnishncsa/varnishncsa.c +++ b/bin/varnishncsa/varnishncsa.c @@ -393,7 +393,7 @@ format_auth(const struct format *format) if (CTX.frag[F_auth].gen != CTX.gen || VB64_decode(buf, sizeof buf, CTX.frag[F_auth].b, - CTX.frag[F_auth].e)) { + CTX.frag[F_auth].e)) { if (format->string == NULL) return (-1); AZ(vsb_esc_cat(CTX.vsb, format->string, @@ -514,7 +514,7 @@ addf_requestline(void) } static void -addf_vcl_log(const char *key, const char *str) +addf_vcl_log(const char *key) { struct watch *w; struct format *f; @@ -530,15 +530,13 @@ addf_vcl_log(const char *key, const char *str) AN(f); f->func = &format_fragment; f->frag = &w->frag; - if (str != NULL) { - f->string = strdup(str); - AN(f->string); - } + f->string = strdup(""); + AN(f->string); VTAILQ_INSERT_TAIL(&CTX.format, f, list); } static void -addf_hdr(struct watch_head *head, const char *key, const char *str) +addf_hdr(struct watch_head *head, const char *key) { struct watch *w; struct format *f; @@ -547,19 +545,16 @@ addf_hdr(struct watch_head *head, const char *key, const char *str) AN(key); ALLOC_OBJ(w, WATCH_MAGIC); AN(w); - w->key = strdup(key); - AN(w->key); - w->keylen = strlen(w->key); + w->keylen = asprintf(&w->key, "%s:", key); + assert(w->keylen > 0); VTAILQ_INSERT_TAIL(head, w, list); ALLOC_OBJ(f, FORMAT_MAGIC); AN(f); f->func = &format_fragment; f->frag = &w->frag; - if (str != NULL) { - f->string = strdup(str); - AN(f->string); - } + f->string = strdup("-"); + AN(f->string); VTAILQ_INSERT_TAIL(&CTX.format, f, list); } @@ -573,27 +568,24 @@ addf_vsl(enum VSL_tag_e tag, long i, const char *prefix) w->tag = tag; assert(i <= INT_MAX); w->idx = i; - if (prefix) { + if (prefix != NULL) { w->prefixlen = asprintf(&w->prefix, "%s:", prefix); assert(w->prefixlen > 0); } VTAILQ_INSERT_TAIL(&CTX.watch_vsl, w, list); - addf_fragment(&w->frag, "-"); } static void -addf_auth(const char *str) +addf_auth(void) { struct format *f; ALLOC_OBJ(f, FORMAT_MAGIC); AN(f); f->func = &format_auth; - if (str != NULL) { - f->string = strdup(str); - AN(f->string); - } + f->string = strdup("-"); + AN(f->string); VTAILQ_INSERT_TAIL(&CTX.format, f, list); } @@ -625,7 +617,7 @@ parse_x_format(char *buf) return; } if (!strncmp(buf, "VCL_Log:", 8)) { - addf_vcl_log(buf + 8, ""); + addf_vcl_log(buf + 8); return; } if (!strncmp(buf, "VSL:", 4)) { @@ -758,7 +750,7 @@ parse_format(const char *format) addf_time(*p, NULL); break; case 'u': /* Remote user from auth */ - addf_auth("-"); + addf_auth(); break; case 'U': /* URL */ addf_fragment(&CTX.frag[F_U], "-"); @@ -777,12 +769,10 @@ parse_format(const char *format) q++; switch (*q) { case 'i': - strcat(buf, ":"); - addf_hdr(&CTX.watch_reqhdr, buf, "-"); + addf_hdr(&CTX.watch_reqhdr, buf); break; case 'o': - strcat(buf, ":"); - addf_hdr(&CTX.watch_resphdr, buf, "-"); + addf_hdr(&CTX.watch_resphdr, buf); break; case 't': addf_time(*q, buf); From martin at varnish-software.com Thu Apr 20 12:41:06 2017 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Thu, 20 Apr 2017 14:41:06 +0200 Subject: [master] f1741d9 cannot link to varnishapi, symbols missing Message-ID: commit f1741d992b6b366223e72a0e4cfe59bb4743a1af Author: Denes Matetelki Date: Tue Apr 18 09:43:34 2017 +0200 cannot link to varnishapi, symbols missing fixes https://github.com/varnishcache/varnish-cache/issues/2313 diff --git a/lib/libvarnishapi/libvarnishapi.map b/lib/libvarnishapi/libvarnishapi.map index 6f20f44..5c084d8 100644 --- a/lib/libvarnishapi/libvarnishapi.map +++ b/lib/libvarnishapi/libvarnishapi.map @@ -40,8 +40,8 @@ LIBVARNISHAPI_1.0 { VSM_Head; VSM_Find_Chunk; VSM_Close; - VSM_iter0; - VSM_intern; + VSM__iter0; + VSM__intern; VSC_Setup; VSC_Arg; From geoff at uplex.de Thu Apr 20 13:32:05 2017 From: geoff at uplex.de (Geoff Simmons) Date: Thu, 20 Apr 2017 15:32:05 +0200 Subject: [master] 6ab9e9c Add debug bit vmod_so_keep This makes it possible to load VMOD shared objects into a debugger after a varnishd crash. Message-ID: commit 6ab9e9cd6aad14b48224a349a0e801bae30b8f31 Author: Geoff Simmons Date: Thu Apr 20 15:14:40 2017 +0200 Add debug bit vmod_so_keep This makes it possible to load VMOD shared objects into a debugger after a varnishd crash. diff --git a/bin/varnishd/mgt/mgt_vcl.c b/bin/varnishd/mgt/mgt_vcl.c index 9a1a42b..618f976 100644 --- a/bin/varnishd/mgt/mgt_vcl.c +++ b/bin/varnishd/mgt/mgt_vcl.c @@ -272,7 +272,8 @@ mgt_vcl_del(struct vclprog *vp) FREE_OBJ(vd); if (VTAILQ_EMPTY(&vf->vcls)) { - AZ(unlink(vf->fname)); + if (! MGT_DO_DEBUG(DBG_VMOD_SO_KEEP)) + AZ(unlink(vf->fname)); VTAILQ_REMOVE(&vmodhead, vf, list); free(vf->fname); FREE_OBJ(vf); diff --git a/bin/varnishtest/tests/m00008.vtc b/bin/varnishtest/tests/m00008.vtc index 202ce56..abeffb9 100644 --- a/bin/varnishtest/tests/m00008.vtc +++ b/bin/varnishtest/tests/m00008.vtc @@ -44,3 +44,9 @@ varnish v1 -errvcl {Malformed VMOD std} { import std from "${topbuild}/lib/libvmod_debug/.libs/libvmod_debug.so"; } +# Check creation and cleanup of copied shared objects for VMODs +shell "test -e ./v1/vmod_cache/_vmod_std.*" + +varnish v1 -stop +varnish v1 -cleanup +shell -err "test -e ./v1/vmod_cache/_vmod_std.*" diff --git a/bin/varnishtest/tests/m00030.vtc b/bin/varnishtest/tests/m00030.vtc new file mode 100644 index 0000000..ff72884 --- /dev/null +++ b/bin/varnishtest/tests/m00030.vtc @@ -0,0 +1,17 @@ +varnishtest "debug bit vmod_so_keep" + +feature topbuild + +varnish v1 -vcl { + import std from "${topbuild}/lib/libvmod_std/.libs/"; + backend b { .host = "${bad_backend}"; } +} -start + +shell "test -e ./v1/vmod_cache/_vmod_std.*" + +varnish v1 -cliok "param.set debug +vmod_so_keep" + +# cf m00008.vtc +varnish v1 -stop +varnish v1 -cleanup +shell "test -e ./v1/vmod_cache/_vmod_std.*" diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c index 22b0307..1f6a38f 100644 --- a/bin/varnishtest/vtc_varnish.c +++ b/bin/varnishtest/vtc_varnish.c @@ -1045,7 +1045,7 @@ varnish_expect(const struct varnish *v, char * const *av) * * \-cleanup * Once Varnish is stopped, clean everything after it. This is only used - * in one test and you should never need it. + * in very few tests and you should never need it. * * Once Varnish is started, you can talk to it (as you would through * ``varnishadm``) with these additional switches:: diff --git a/include/tbl/debug_bits.h b/include/tbl/debug_bits.h index e089022..50e4839 100644 --- a/include/tbl/debug_bits.h +++ b/include/tbl/debug_bits.h @@ -47,6 +47,7 @@ DEBUG_BIT(VSM_KEEP, vsm_keep, "Keep the VSM file on restart") DEBUG_BIT(DROP_POOLS, drop_pools, "Drop thread pools (testing)") DEBUG_BIT(SLOW_ACCEPTOR, slow_acceptor, "Slow down Acceptor") DEBUG_BIT(H2_NOCHECK, h2_nocheck, "Disable various H2 checks") +DEBUG_BIT(VMOD_SO_KEEP, vmod_so_keep, "Keep copied VMOD libraries") #undef DEBUG_BIT /*lint -restore */ From geoff at uplex.de Thu Apr 20 13:32:06 2017 From: geoff at uplex.de (Geoff Simmons) Date: Thu, 20 Apr 2017 15:32:06 +0200 Subject: [master] d851560 When varnishtest is invoked with -l/-L, don't delete VMOD shared objects. Message-ID: commit d8515607dd98234ba42619e73e7a18e0e9648157 Author: Geoff Simmons Date: Thu Apr 20 15:29:53 2017 +0200 When varnishtest is invoked with -l/-L, don't delete VMOD shared objects. diff --git a/bin/varnishtest/tests/m00008.vtc b/bin/varnishtest/tests/m00008.vtc index abeffb9..849ba4e 100644 --- a/bin/varnishtest/tests/m00008.vtc +++ b/bin/varnishtest/tests/m00008.vtc @@ -47,6 +47,10 @@ varnish v1 -errvcl {Malformed VMOD std} { # Check creation and cleanup of copied shared objects for VMODs shell "test -e ./v1/vmod_cache/_vmod_std.*" +# In case varnishtest was invoked with -L or -l, in which case the +# bit is switched on. +varnish v1 -cliok "param.set debug -vmod_so_keep" + varnish v1 -stop varnish v1 -cleanup shell -err "test -e ./v1/vmod_cache/_vmod_std.*" diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c index 1f6a38f..55f601a 100644 --- a/bin/varnishtest/vtc_varnish.c +++ b/bin/varnishtest/vtc_varnish.c @@ -418,8 +418,10 @@ varnish_launch(struct varnish *v) VSB_cat(vsb, VSB_data(params_vsb)); if (vtc_witness) VSB_cat(vsb, " -p debug=+witness"); - if (leave_temp) + if (leave_temp) { VSB_cat(vsb, " -p debug=+vsm_keep"); + VSB_cat(vsb, " -p debug=+vmod_so_keep"); + } VSB_printf(vsb, " -l 2m,1m,-"); VSB_printf(vsb, " -p auto_restart=off"); VSB_printf(vsb, " -p syslog_cli_traffic=off"); From martin at varnish-software.com Fri Apr 21 08:56:05 2017 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Fri, 21 Apr 2017 10:56:05 +0200 Subject: [master] 1fb9571 Fix spelling misstake related to #2313 Message-ID: commit 1fb9571cf29e26c627a552f62027110c78d8dc8d Author: Martin Blix Grydeland Date: Fri Apr 21 10:55:40 2017 +0200 Fix spelling misstake related to #2313 diff --git a/lib/libvarnishapi/libvarnishapi.map b/lib/libvarnishapi/libvarnishapi.map index 5c084d8..a07bd30 100644 --- a/lib/libvarnishapi/libvarnishapi.map +++ b/lib/libvarnishapi/libvarnishapi.map @@ -41,7 +41,7 @@ LIBVARNISHAPI_1.0 { VSM_Find_Chunk; VSM_Close; VSM__iter0; - VSM__intern; + VSM__itern; VSC_Setup; VSC_Arg; From phk at FreeBSD.org Fri Apr 21 16:26:06 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 21 Apr 2017 18:26:06 +0200 Subject: [master] bf82595 Whitespace CDO Message-ID: commit bf82595d8ac35fb7c3b550d88dd4a5f4221048e2 Author: Poul-Henning Kamp Date: Fri Apr 21 07:06:12 2017 +0000 Whitespace CDO diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c index 55f601a..d20e82a 100644 --- a/bin/varnishtest/vtc_varnish.c +++ b/bin/varnishtest/vtc_varnish.c @@ -421,7 +421,7 @@ varnish_launch(struct varnish *v) if (leave_temp) { VSB_cat(vsb, " -p debug=+vsm_keep"); VSB_cat(vsb, " -p debug=+vmod_so_keep"); - } + } VSB_printf(vsb, " -l 2m,1m,-"); VSB_printf(vsb, " -p auto_restart=off"); VSB_printf(vsb, " -p syslog_cli_traffic=off"); @@ -999,7 +999,7 @@ varnish_expect(const struct varnish *v, char * const *av) * With: * * vNAME - * Identify the Varnish server with a string, it must starts with 'v'. + * Identify the Varnish server with a string, it must starts with 'v'. * * \-arg STRING * Pass an argument to varnishd, for example "-h simple_list". diff --git a/lib/libvmod_std/vmod.vcc b/lib/libvmod_std/vmod.vcc index 3bfa0e3..0923fb7 100644 --- a/lib/libvmod_std/vmod.vcc +++ b/lib/libvmod_std/vmod.vcc @@ -114,7 +114,7 @@ Description `false` otherwise. Example | if (std.file_exists("/etc/return_503")) { - | return (synth(503, "Varnish is in maintenance")); + | return (synth(503, "Varnish is in maintenance")); | } $Function VOID collect(HEADER hdr, STRING sep=", ") From fgsch at lodoss.net Sat Apr 22 16:42:05 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sat, 22 Apr 2017 18:42:05 +0200 Subject: [master] 6bae8a4 More whitespace OCD Message-ID: commit 6bae8a4f3a859475ab2e52069492058261016594 Author: Federico G. Schwindt Date: Sat Apr 22 17:38:04 2017 +0100 More whitespace OCD diff --git a/bin/varnishd/mgt/mgt_vcl.c b/bin/varnishd/mgt/mgt_vcl.c index 618f976..59f2026 100644 --- a/bin/varnishd/mgt/mgt_vcl.c +++ b/bin/varnishd/mgt/mgt_vcl.c @@ -272,7 +272,7 @@ mgt_vcl_del(struct vclprog *vp) FREE_OBJ(vd); if (VTAILQ_EMPTY(&vf->vcls)) { - if (! MGT_DO_DEBUG(DBG_VMOD_SO_KEEP)) + if (!MGT_DO_DEBUG(DBG_VMOD_SO_KEEP)) AZ(unlink(vf->fname)); VTAILQ_REMOVE(&vmodhead, vf, list); free(vf->fname); diff --git a/doc/sphinx/phk/somethinghappened.rst b/doc/sphinx/phk/somethinghappened.rst index 3878b21..30d45fa 100644 --- a/doc/sphinx/phk/somethinghappened.rst +++ b/doc/sphinx/phk/somethinghappened.rst @@ -66,7 +66,7 @@ house-building-moving-finding-where-I-put-the-computer madness is over late in summer, and then I would probably still insist on delaying it for a month just to catch my bearings. -That would have held some +That would have held some `pretty significant new code `_ from our users for another half year, for no particular reason. From phk at FreeBSD.org Mon Apr 24 14:31:06 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 24 Apr 2017 16:31:06 +0200 Subject: [master] e8812d1 FlexeLint infrastructure Message-ID: commit e8812d10a6d947db17648b2c3ce2611b8d758116 Author: Poul-Henning Kamp Date: Mon Apr 24 14:30:17 2017 +0000 FlexeLint infrastructure diff --git a/.gitignore b/.gitignore index 74fb278..41b82cf 100644 --- a/.gitignore +++ b/.gitignore @@ -123,3 +123,7 @@ vt_key.pub # Coverity output /cov-int /myproject.tgz + +# Flexelint droppings +_.fl +_.fl.old diff --git a/lib/flint.lnt b/lib/flint.lnt new file mode 100644 index 0000000..e69de29 diff --git a/lib/libvarnish/flint.sh b/lib/libvarnish/flint.sh index f79c531..7696210 100755 --- a/lib/libvarnish/flint.sh +++ b/lib/libvarnish/flint.sh @@ -1,30 +1,27 @@ #!/bin/sh -T=/tmp/_$$ +if [ "x$1" = "x-ok" -a -f _.fl ] ; then + echo "Saved as reference" + mv _.fl _.fl.old + exit 0 +fi + flexelint \ - -I/usr/include \ + ../../flint.lnt \ + flint.lnt \ -I. \ -I../../include \ -I../.. \ - flint.lnt \ - *.c > $T 2>&1 + -I/usr/local/include \ + *.c \ + 2>&1 | tee _.fl + +if [ -f _.fl.old ] ; then + diff -u _.fl.old _.fl +fi -for t in Error Warning Info -do - sed -n "/$t [0-9][0-9][0-9]:/s/.*\($t [0-9][0-9][0-9]\).*/\1/p" $T -done | awk ' -$2 == 830 { next } -$2 == 831 { next } - { - i=$2"_"$1 - h[i]++ - n++ - } -END { - printf "%5d %s\n", n, "Total" - for (i in h) - printf "%5d %s\n", h[i], i - } -' | sort -rn +if [ "x$1" = "x-ok" ] ; then + echo "Saved as reference" + mv _.fl _.fl.old +fi -cat $T diff --git a/lib/libvarnishapi/flint.lnt b/lib/libvarnishapi/flint.lnt new file mode 100644 index 0000000..e69de29 diff --git a/lib/libvarnishapi/flint.sh b/lib/libvarnishapi/flint.sh new file mode 100755 index 0000000..e324e1f --- /dev/null +++ b/lib/libvarnishapi/flint.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +if [ "x$1" = "x-ok" -a -f _.fl ] ; then + echo "Saved as reference" + mv _.fl _.fl.old + exit 0 +fi + +flexelint \ + ../../flint.lnt \ + ../flint.lnt \ + flint.lnt \ + -I. \ + -I../../include \ + -I../.. \ + -I/usr/local/include \ + *.c \ + 2>&1 | tee _.fl + +if [ -f _.fl.old ] ; then + diff -u _.fl.old _.fl +fi + +if [ "x$1" = "x-ok" ] ; then + echo "Saved as reference" + mv _.fl _.fl.old +fi + From hermunn at varnish-software.com Mon Apr 24 14:34:06 2017 From: hermunn at varnish-software.com (Pål Hermunn Johansen) Date: Mon, 24 Apr 2017 16:34:06 +0200 Subject: [4.1] 08fb539 Don't attempt to check if varnishd is still running if we have already failed. Message-ID: commit 08fb539150e9ca34b3c3388d6cae8d0b289519f1 Author: Poul-Henning Kamp Date: Fri Apr 7 16:23:06 2017 +0000 Don't attempt to check if varnishd is still running if we have already failed. Fixes #2301 diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c index 93b366c..bbfea18 100644 --- a/bin/varnishtest/vtc_varnish.c +++ b/bin/varnishtest/vtc_varnish.c @@ -667,8 +667,10 @@ varnish_wait(struct varnish *v) vtc_log(v->vl, 2, "Wait"); - /* Do a backend.list to log if child is still running */ - varnish_ask_cli(v, "backend.list", &resp); + if (!vtc_error) { + /* Do a backend.list to log if child is still running */ + varnish_ask_cli(v, "backend.list", &resp); + } /* Then stop it */ varnish_stop(v); From hermunn at varnish-software.com Mon Apr 24 15:16:06 2017 From: hermunn at varnish-software.com (Pål Hermunn Johansen) Date: Mon, 24 Apr 2017 17:16:06 +0200 Subject: [4.1] 7fc09f9 Hijack errno in Lck_CondWait Message-ID: commit 7fc09f9e906236b3b2e6264bd782cea56a5c009c Author: Dridi Boukelmoune Date: Mon Mar 13 13:04:54 2017 +0100 Hijack errno in Lck_CondWait This should help diagnose #2253. diff --git a/bin/varnishd/cache/cache_lck.c b/bin/varnishd/cache/cache_lck.c index 90190dc..8284340 100644 --- a/bin/varnishd/cache/cache_lck.c +++ b/bin/varnishd/cache/cache_lck.c @@ -184,7 +184,6 @@ int __match_proto__() Lck_CondWait(pthread_cond_t *cond, struct lock *lck, double when) { struct ilck *ilck; - int retval = 0; struct timespec ts; double t; @@ -193,19 +192,20 @@ Lck_CondWait(pthread_cond_t *cond, struct lock *lck, double when) assert(pthread_equal(ilck->owner, pthread_self())); ilck->held = 0; if (when == 0) { - AZ(pthread_cond_wait(cond, &ilck->mtx)); + errno = pthread_cond_wait(cond, &ilck->mtx); + AZ(errno); } else { ts.tv_nsec = (long)(modf(when, &t) * 1e9); ts.tv_sec = (long)t; - retval = pthread_cond_timedwait(cond, &ilck->mtx, &ts); - assert(retval == 0 || - retval == ETIMEDOUT || - retval == EINTR); + errno = pthread_cond_timedwait(cond, &ilck->mtx, &ts); + assert(errno == 0 || + errno == ETIMEDOUT || + errno == EINTR); } AZ(ilck->held); ilck->held = 1; ilck->owner = pthread_self(); - return (retval); + return (errno); } void From dridi.boukelmoune at gmail.com Mon Apr 24 15:32:06 2017 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 24 Apr 2017 17:32:06 +0200 Subject: [master] 9e754cc Polish verbose compliance in varnish.m4 Message-ID: commit 9e754cc5dcd6b6461ce97af5b2ee52fec5161621 Author: Dridi Boukelmoune Date: Mon Apr 24 16:38:52 2017 +0200 Polish verbose compliance in varnish.m4 This is a cosmetic tweak, it doesn't change any behavior. No need to bump the serial for that. The benefits are a better output of silent make executions, and the preservation of configured variables like $(PYTHON) all the way downstream. A word on this stunt: \$(A""M_V_GEN) The backslash is here to escape the dollar sign, nothing too surprising. However the expression between the brackets is rejected by autoconf because it looks like an undefined macro. To prevent that, the string is closed and reopen at once to break the token-inside-brackets construct. diff --git a/varnish.m4 b/varnish.m4 index 400e087..82514ea 100644 --- a/varnish.m4 +++ b/varnish.m4 @@ -205,10 +205,10 @@ vmod_$1.lo: vcc_$1_if.c vcc_$1_if.h vcc_$1_if.h vmod_$1.rst vmod_$1.man.rst: vcc_$1_if.c vcc_$1_if.c: vmod_$1.vcc - \$(AM_V_VMODTOOL) $PYTHON $VMODTOOL -o vcc_$1_if \$(srcdir)/vmod_$1.vcc + \$(AM_V_VMODTOOL) \$(PYTHON) \$(VMODTOOL) -o vcc_$1_if \$(srcdir)/vmod_$1.vcc vmod_$1.3: vmod_$1.man.rst - $RST2MAN vmod_$1.man.rst vmod_$1.3 + \$(A""M_V_GEN) \$(RST2MAN) vmod_$1.man.rst vmod_$1.3 clean: clean-vmod-$1 From phk at FreeBSD.org Mon Apr 24 17:01:06 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 24 Apr 2017 19:01:06 +0200 Subject: [master] b8f7f94 More FlexeLint running Message-ID: commit b8f7f9455d4bb93ed5a6a135d4b872fc44ea36f2 Author: Poul-Henning Kamp Date: Mon Apr 24 17:00:36 2017 +0000 More FlexeLint running diff --git a/bin/varnishncsa/flint.sh b/bin/varnishncsa/flint.sh index f7d7988..dda2d3a 100755 --- a/bin/varnishncsa/flint.sh +++ b/bin/varnishncsa/flint.sh @@ -1,31 +1,26 @@ #!/bin/sh -T=/tmp/_$$ +if [ "x$1" = "x-ok" -a -f _.fl ] ; then + echo "Saved as reference" + mv _.fl _.fl.old + exit 0 +fi + flexelint \ - -I/usr/include \ - -I. \ - -I../.. \ - -I../../include \ + ../../flint.lnt \ ../flint.lnt \ flint.lnt \ - *.c > $T 2>&1 + -I. \ + -I../../include \ + -I../.. \ + *.c \ + 2>&1 | tee _.fl -for t in Error Warning Info -do - sed -n "/$t [0-9][0-9][0-9]:/s/.*\($t [0-9][0-9][0-9]\).*/\1/p" $T -done | awk ' -$2 == 830 { next } -$2 == 831 { next } - { - i=$2"_"$1 - h[i]++ - n++ - } -END { - printf "%5d %s\n", n, "Total" - for (i in h) - printf "%5d %s\n", h[i], i - } -' | sort -rn +if [ -f _.fl.old ] ; then + diff -u _.fl.old _.fl +fi -cat $T +if [ "x$1" = "x-ok" ] ; then + echo "Saved as reference" + mv _.fl _.fl.old +fi diff --git a/lib/libvarnish/flint.lnt b/lib/libvarnish/flint.lnt index cc2ed87..f049cc6 100644 --- a/lib/libvarnish/flint.lnt +++ b/lib/libvarnish/flint.lnt @@ -1,5 +1,3 @@ --passes=8 - +libh mgt_event.h +libh ../../config.h From geoff at uplex.de Mon Apr 24 17:10:06 2017 From: geoff at uplex.de (Geoff Simmons) Date: Mon, 24 Apr 2017 19:10:06 +0200 Subject: [master] 98f14f5 Help emacs automatically follow project conventions. Message-ID: commit 98f14f500495ac8cf5b50a76618e9639ba7a3a34 Author: Geoff Simmons Date: Mon Apr 24 19:08:45 2017 +0200 Help emacs automatically follow project conventions. diff --git a/.dir-locals.el b/.dir-locals.el new file mode 100644 index 0000000..143ac8a --- /dev/null +++ b/.dir-locals.el @@ -0,0 +1,2 @@ +((nil . ((indent-tabs-mode . t))) + (c-mode . ((c-file-style . "BSD")))) From phk at FreeBSD.org Mon Apr 24 20:16:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 24 Apr 2017 22:16:05 +0200 Subject: [master] f6b82e3 Use a skeleton script for flint.sh throughout. Message-ID: commit f6b82e38d61cd2995bc63e9c6817a25c54e643a5 Author: Poul-Henning Kamp Date: Mon Apr 24 20:14:33 2017 +0000 Use a skeleton script for flint.sh throughout. diff --git a/bin/varnishadm/flint.lnt b/bin/varnishadm/flint.lnt new file mode 100644 index 0000000..e69de29 diff --git a/bin/varnishadm/flint.sh b/bin/varnishadm/flint.sh new file mode 100755 index 0000000..5994de7 --- /dev/null +++ b/bin/varnishadm/flint.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +FLOPS=' + *.c + ../../lib/libvarnishapi/*.c +' + +. ../../tools/flint_skel.sh diff --git a/bin/varnishd/flint.sh b/bin/varnishd/flint.sh index 50d1c4b..5606dfb 100755 --- a/bin/varnishd/flint.sh +++ b/bin/varnishd/flint.sh @@ -1,45 +1,25 @@ #!/bin/sh -if [ "x$1" = "x-ok" -a -f _.fl ] ; then - echo "Saved as reference" - mv _.fl _.fl.old - exit 0 -fi +FLOPS=' + -I../../lib/libvgz + -DVARNISHD_IS_NOT_A_VMOD + -DVARNISH_STATE_DIR=\"foo\" + -DVARNISH_VMOD_DIR=\"foo\" + -DVARNISH_VCL_DIR=\"foo\" + cache/*.c + common/*.c + hash/*.c + http1/*.c + http2/*.c + mgt/*.c + proxy/*.c + storage/*.c + waiter/*.c + ../../lib/libvarnish/*.c + ../../lib/libvcc/*.c + ../../lib/libvmod_std/*.c + ../../lib/libvmod_debug/*.c + ../../lib/libvmod_directors/*.c +' -flexelint \ - ../../flint.lnt \ - ../flint.lnt \ - flint.lnt \ - -I. \ - -I../../include \ - -I../../lib/libvgz \ - -I../.. \ - -I/usr/local/include \ - -DVARNISHD_IS_NOT_A_VMOD \ - -DVARNISH_STATE_DIR=\"foo\" \ - -DVARNISH_VMOD_DIR=\"foo\" \ - -DVARNISH_VCL_DIR=\"foo\" \ - cache/*.c \ - common/*.c \ - hash/*.c \ - http1/*.c \ - http2/*.c \ - mgt/*.c \ - proxy/*.c \ - storage/*.c \ - waiter/*.c \ - ../../lib/libvarnish/*.c \ - ../../lib/libvcc/*.c \ - ../../lib/libvmod_std/*.c \ - ../../lib/libvmod_debug/*.c \ - ../../lib/libvmod_directors/*.c \ - 2>&1 | tee _.fl - -if [ -f _.fl.old ] ; then - diff -u _.fl.old _.fl -fi - -if [ "x$1" = "x-ok" ] ; then - echo "Saved as reference" - mv _.fl _.fl.old -fi +. ../../tools/flint_skel.sh diff --git a/bin/varnishhist/flint.lnt b/bin/varnishhist/flint.lnt new file mode 100644 index 0000000..e69de29 diff --git a/bin/varnishhist/flint.sh b/bin/varnishhist/flint.sh new file mode 100755 index 0000000..5994de7 --- /dev/null +++ b/bin/varnishhist/flint.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +FLOPS=' + *.c + ../../lib/libvarnishapi/*.c +' + +. ../../tools/flint_skel.sh diff --git a/bin/varnishlog/flint.sh b/bin/varnishlog/flint.sh index 26e0fa3..6f94f89 100755 --- a/bin/varnishlog/flint.sh +++ b/bin/varnishlog/flint.sh @@ -1,29 +1,10 @@ #!/bin/sh -if [ "x$1" = "x-ok" -a -f _.fl ] ; then - echo "Saved as reference" - mv _.fl _.fl.old - exit 0 -fi +FLOPS=' + -DVARNISH_STATE_DIR=\"foo\" + *.c + ../../lib/libvarnishapi/*.c +' -flexelint \ - ../../flint.lnt \ - ../flint.lnt \ - flint.lnt \ - -I. \ - -I../../include \ - -I../.. \ - -I/usr/local/include \ - -DVARNISH_STATE_DIR=\"foo\" \ - *.c \ - ../../lib/libvarnishapi/*.c \ - 2>&1 | tee _.fl +. ../../tools/flint_skel.sh -if [ -f _.fl.old ] ; then - diff -u _.fl.old _.fl -fi - -if [ "x$1" = "x-ok" ] ; then - echo "Saved as reference" - mv _.fl _.fl.old -fi diff --git a/bin/varnishncsa/flint.sh b/bin/varnishncsa/flint.sh index dda2d3a..5994de7 100755 --- a/bin/varnishncsa/flint.sh +++ b/bin/varnishncsa/flint.sh @@ -1,26 +1,8 @@ #!/bin/sh -if [ "x$1" = "x-ok" -a -f _.fl ] ; then - echo "Saved as reference" - mv _.fl _.fl.old - exit 0 -fi +FLOPS=' + *.c + ../../lib/libvarnishapi/*.c +' -flexelint \ - ../../flint.lnt \ - ../flint.lnt \ - flint.lnt \ - -I. \ - -I../../include \ - -I../.. \ - *.c \ - 2>&1 | tee _.fl - -if [ -f _.fl.old ] ; then - diff -u _.fl.old _.fl -fi - -if [ "x$1" = "x-ok" ] ; then - echo "Saved as reference" - mv _.fl _.fl.old -fi +. ../../tools/flint_skel.sh diff --git a/bin/varnishstat/flint.sh b/bin/varnishstat/flint.sh index a94710d..5994de7 100755 --- a/bin/varnishstat/flint.sh +++ b/bin/varnishstat/flint.sh @@ -1,11 +1,8 @@ #!/bin/sh -flexelint \ - -I/usr/include \ - -I. \ - -I../../include \ - -I../.. \ - ../flint.lnt \ - flint.lnt \ - *.c \ +FLOPS=' + *.c ../../lib/libvarnishapi/*.c +' + +. ../../tools/flint_skel.sh diff --git a/bin/varnishtest/flint.sh b/bin/varnishtest/flint.sh index 7f9c759..49f5e2d 100755 --- a/bin/varnishtest/flint.sh +++ b/bin/varnishtest/flint.sh @@ -1,29 +1,10 @@ #!/bin/sh -if [ "x$1" = "x-ok" -a -f _.fl ] ; then - echo "Saved as reference" - mv _.fl _.fl.old - exit 0 -fi +FLOPS=' + -DTOP_BUILDDIR="foo" + -I../../lib/libvgz + *.c +' -flexelint \ - -DTOP_BUILDDIR='"foo"' \ - -I/usr/include \ - -I. \ - -I../../include \ - -I../../lib/libvgz \ - -I../.. \ - ../../flint.lnt \ - ../flint.lnt \ - flint.lnt \ - *.c \ - 2>&1 | tee _.fl +. ../../tools/flint_skel.sh -if [ -f _.fl.old ] ; then - diff -u _.fl.old _.fl -fi - -if [ "x$1" = "x-ok" ] ; then - echo "Saved as reference" - mv _.fl _.fl.old -fi diff --git a/bin/varnishtop/flint.sh b/bin/varnishtop/flint.sh index a94710d..5994de7 100755 --- a/bin/varnishtop/flint.sh +++ b/bin/varnishtop/flint.sh @@ -1,11 +1,8 @@ #!/bin/sh -flexelint \ - -I/usr/include \ - -I. \ - -I../../include \ - -I../.. \ - ../flint.lnt \ - flint.lnt \ - *.c \ +FLOPS=' + *.c ../../lib/libvarnishapi/*.c +' + +. ../../tools/flint_skel.sh diff --git a/lib/libvarnish/flint.sh b/lib/libvarnish/flint.sh index 7696210..0964d4c 100755 --- a/lib/libvarnish/flint.sh +++ b/lib/libvarnish/flint.sh @@ -1,27 +1,7 @@ #!/bin/sh -if [ "x$1" = "x-ok" -a -f _.fl ] ; then - echo "Saved as reference" - mv _.fl _.fl.old - exit 0 -fi - -flexelint \ - ../../flint.lnt \ - flint.lnt \ - -I. \ - -I../../include \ - -I../.. \ - -I/usr/local/include \ - *.c \ - 2>&1 | tee _.fl - -if [ -f _.fl.old ] ; then - diff -u _.fl.old _.fl -fi - -if [ "x$1" = "x-ok" ] ; then - echo "Saved as reference" - mv _.fl _.fl.old -fi +FLOPS=' + *.c +' +. ../../tools/flint_skel.sh diff --git a/lib/libvarnishapi/flint.sh b/lib/libvarnishapi/flint.sh index e324e1f..0964d4c 100755 --- a/lib/libvarnishapi/flint.sh +++ b/lib/libvarnishapi/flint.sh @@ -1,28 +1,7 @@ #!/bin/sh -if [ "x$1" = "x-ok" -a -f _.fl ] ; then - echo "Saved as reference" - mv _.fl _.fl.old - exit 0 -fi - -flexelint \ - ../../flint.lnt \ - ../flint.lnt \ - flint.lnt \ - -I. \ - -I../../include \ - -I../.. \ - -I/usr/local/include \ - *.c \ - 2>&1 | tee _.fl - -if [ -f _.fl.old ] ; then - diff -u _.fl.old _.fl -fi - -if [ "x$1" = "x-ok" ] ; then - echo "Saved as reference" - mv _.fl _.fl.old -fi +FLOPS=' + *.c +' +. ../../tools/flint_skel.sh diff --git a/lib/libvcc/flint.sh b/lib/libvcc/flint.sh index 3bb465a..0964d4c 100755 --- a/lib/libvcc/flint.sh +++ b/lib/libvcc/flint.sh @@ -1,10 +1,7 @@ #!/bin/sh -flexelint \ - -I/usr/include \ - -I. \ - -I../.. \ - -I../../include \ - -I../../contrib/libevent \ - flint.lnt \ +FLOPS=' *.c +' + +. ../../tools/flint_skel.sh diff --git a/lib/libvmod_debug/flint.lnt b/lib/libvmod_debug/flint.lnt new file mode 100644 index 0000000..e69de29 diff --git a/lib/libvmod_debug/flint.sh b/lib/libvmod_debug/flint.sh index b4bc3e7..522e30d 100755 --- a/lib/libvmod_debug/flint.sh +++ b/lib/libvmod_debug/flint.sh @@ -1,10 +1,8 @@ #!/bin/sh -flexelint \ - -u \ - ../../flint.lnt \ - -I. \ - -I../.. \ - -I../../include \ - -I../../bin/varnishd \ +FLOPS=' + -I../../bin/varnishd *.c +' + +. ../../tools/flint_skel.sh diff --git a/lib/libvmod_directors/flint.lnt b/lib/libvmod_directors/flint.lnt new file mode 100644 index 0000000..e69de29 diff --git a/lib/libvmod_directors/flint.sh b/lib/libvmod_directors/flint.sh new file mode 100755 index 0000000..522e30d --- /dev/null +++ b/lib/libvmod_directors/flint.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +FLOPS=' + -I../../bin/varnishd + *.c +' + +. ../../tools/flint_skel.sh diff --git a/lib/libvmod_std/flint.lnt b/lib/libvmod_std/flint.lnt new file mode 100644 index 0000000..e69de29 diff --git a/lib/libvmod_std/flint.sh b/lib/libvmod_std/flint.sh index b4bc3e7..522e30d 100755 --- a/lib/libvmod_std/flint.sh +++ b/lib/libvmod_std/flint.sh @@ -1,10 +1,8 @@ #!/bin/sh -flexelint \ - -u \ - ../../flint.lnt \ - -I. \ - -I../.. \ - -I../../include \ - -I../../bin/varnishd \ +FLOPS=' + -I../../bin/varnishd *.c +' + +. ../../tools/flint_skel.sh diff --git a/tools/flint_skel.sh b/tools/flint_skel.sh new file mode 100644 index 0000000..557c7aa --- /dev/null +++ b/tools/flint_skel.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +if [ "x$1" = "x-ok" -a -f _.fl ] ; then + echo "Saved as reference" + mv _.fl _.fl.old + exit 0 +fi + +flexelint \ + ../../flint.lnt \ + ../flint.lnt \ + flint.lnt \ + -zero \ + -I. \ + -I../../include \ + -I../.. \ + -I/usr/local/include \ + $FLOPS \ + 2>&1 | tee _.fl + +if [ -f _.fl.old ] ; then + diff -u _.fl.old _.fl +fi + +if [ "x$1" = "x-ok" ] ; then + echo "Saved as reference" + mv _.fl _.fl.old +fi From phk at FreeBSD.org Mon Apr 24 20:55:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 24 Apr 2017 22:55:05 +0200 Subject: [master] a740fdc Emit the actual vmod name in the Flexelint comment Message-ID: commit a740fdc0efb77135b77cc25ea75b97ddc2042912 Author: Poul-Henning Kamp Date: Mon Apr 24 20:39:58 2017 +0000 Emit the actual vmod name in the Flexelint comment diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py index cbe06b9..efa8c58 100755 --- a/lib/libvcc/vmodtool.py +++ b/lib/libvcc/vmodtool.py @@ -811,7 +811,7 @@ class vcc(object): self.cstruct(fx, "struct " + csn) - fo.write("\n/*lint -esym(754, Vmod_debug_Func::*) */\n") + fo.write("\n/*lint -esym(754, Vmod_" + self.modname + "_Func::*) */\n") self.cstruct_init(fo, "struct " + csn) fx.close() From phk at FreeBSD.org Mon Apr 24 20:55:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 24 Apr 2017 22:55:05 +0200 Subject: [master] 0d3bee4 Add another couple of FlexeLint mitigations Message-ID: commit 0d3bee46ff5c3fdc40b9ad05e6554b8735f9cf6b Author: Poul-Henning Kamp Date: Mon Apr 24 20:45:12 2017 +0000 Add another couple of FlexeLint mitigations diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py index efa8c58..c8214e4 100755 --- a/lib/libvcc/vmodtool.py +++ b/lib/libvcc/vmodtool.py @@ -756,7 +756,8 @@ class vcc(object): fo.write("/*lint -restore */\n") def api(self, fo): - fo.write("\n/*lint -esym(759, Vmod_%s_Data) */\n" % (self.modname)) + for i in (714, 759, 765): + fo.write("\n/*lint -esym(%d, Vmod_%s_Data) */\n" % (i, self.modname)) fo.write("const struct vmod_data Vmod_%s_Data = {\n" % self.modname) fo.write("\t.vrt_major =\tVRT_MAJOR_VERSION,\n") From phk at FreeBSD.org Mon Apr 24 20:55:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 24 Apr 2017 22:55:05 +0200 Subject: [master] 84af74d Handle a few high-volume FlexeLint complaints Message-ID: commit 84af74d1cae0202dc27a145bf25cc1c50b585417 Author: Poul-Henning Kamp Date: Mon Apr 24 20:53:47 2017 +0000 Handle a few high-volume FlexeLint complaints diff --git a/bin/flint.lnt b/bin/flint.lnt index 0c9412c..d5f3dc3 100644 --- a/bin/flint.lnt +++ b/bin/flint.lnt @@ -37,7 +37,6 @@ -emacro(702, WEXITSTATUS) // signed shift right --e786 // String concatenation within initializer -e726 // Extraneous comma ignored -e825 // control flows into case/default without -fallthrough comment diff --git a/bin/varnishd/vclflint.lnt b/bin/varnishd/vclflint.lnt index 747d87b..74ba97c 100644 --- a/bin/varnishd/vclflint.lnt +++ b/bin/varnishd/vclflint.lnt @@ -17,9 +17,6 @@ // Harmless --e786 // String concatenation within initializer - // Harmless - -e752 // local declarator [...] not referenced -e754 // local structure member [...] not referenced -e526 // Symbol [...] not defined diff --git a/bin/varnishncsa/flint.lnt b/bin/varnishncsa/flint.lnt index 5faddb8..462320f 100644 --- a/bin/varnishncsa/flint.lnt +++ b/bin/varnishncsa/flint.lnt @@ -6,7 +6,6 @@ -e728 // Symbol ... not explicitly initialized -e716 // while(1) ... -e785 // Too few initializers for aggregate --e786 // String concatenation within initializer // cache_vcl.c -e641 // Converting enum 'cli_status_e' to int diff --git a/bin/varnishtest/flint.lnt b/bin/varnishtest/flint.lnt index 1ef8431..9686e5f 100644 --- a/bin/varnishtest/flint.lnt +++ b/bin/varnishtest/flint.lnt @@ -31,7 +31,6 @@ -e713 // Loss of precision (assignment) (unsigned long long to long long) -e574 // Signed-unsigned mix with relational -e835 // A zero has been given as ___ argument to operator '___' (<<) --e786 // String concatenation within initializer -e788 // enum value not used in defaulted switch -efile(451, vmods.h) diff --git a/flint.lnt b/flint.lnt index 4a52501..0876042 100644 --- a/flint.lnt +++ b/flint.lnt @@ -18,6 +18,7 @@ -e726 // Extraneous comma ignored -e641 // Converting enum '...' to int -e763 // Redundant declaration for symbol '...' previously declared +-e786 // String concatenation within initializer // +e958 // padding @@ -99,6 +100,8 @@ /////////////////////////////////////////////////////////////////////// +// It is ok to default after handling a few select SLT_* tags +-esym(788, VSL_tag_e::SLT_*) // enum constant '...' not used within defaulted switch -esym(785,VSL_tags) // Sparse array diff --git a/include/tbl/vsl_tags_http.h b/include/tbl/vsl_tags_http.h index 393dbe5..e0d1802 100644 --- a/include/tbl/vsl_tags_http.h +++ b/include/tbl/vsl_tags_http.h @@ -43,7 +43,7 @@ * */ -/*lint -save -e525 -e539 */ +/*lint -save -e525 -e539 -e835 */ SLTH(Method, HTTP_HDR_METHOD, 1, 0, "method", "The HTTP request method used.\n\n" diff --git a/lib/libvarnish/flint.lnt b/lib/libvarnish/flint.lnt index f049cc6..f5e545e 100644 --- a/lib/libvarnish/flint.lnt +++ b/lib/libvarnish/flint.lnt @@ -26,7 +26,6 @@ -e728 // Symbol ... not explicitly initialized -e716 // while(1) ... -e785 // Too few initializers for aggregate --e786 // String concatenation within initializer -esym(534, sprintf) // Ignoring return value of function -esym(534, asprintf) // Ignoring return value of function diff --git a/lib/libvcc/flint.lnt b/lib/libvcc/flint.lnt index e264dab..f0b8f65 100644 --- a/lib/libvcc/flint.lnt +++ b/lib/libvcc/flint.lnt @@ -27,7 +27,6 @@ -esym(534, memset) // Ignoring return value of function -e788 // enum constant 'HND_Unclass' not used within defaulted switch -e716 // while(1) ... --e786 // String concatenation within initializer -e732 // Loss of sign (arg. no. 2) (int to unsigned int) From phk at FreeBSD.org Mon Apr 24 21:58:06 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 24 Apr 2017 23:58:06 +0200 Subject: [master] 44536a5 Tell FlexeLint that Colin knew what he was doing with those zeros. Message-ID: commit 44536a5ac96991b96c8841605124cc07474bd824 Author: Poul-Henning Kamp Date: Mon Apr 24 21:16:17 2017 +0000 Tell FlexeLint that Colin knew what he was doing with those zeros. diff --git a/lib/libvarnish/flint.lnt b/lib/libvarnish/flint.lnt index f5e545e..5755730 100644 --- a/lib/libvarnish/flint.lnt +++ b/lib/libvarnish/flint.lnt @@ -47,6 +47,9 @@ -emacro(506, assert) // constant value boolean -emacro(774, HTTPH) // always false +-efunc(835, SHA256_Transform) // A zero has been given as ___ argument to operator '___' +-efunc(778, SHA256_Transform) // Constant expression evaluates to 0 in operation '___' + // cache.h -emacro(506, INCOMPL) // Constant value Boolean From phk at FreeBSD.org Mon Apr 24 21:58:06 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 24 Apr 2017 23:58:06 +0200 Subject: [master] 0bfec78 Pull in the corresponding flint.lnt files when we absorb files from other directories. Message-ID: commit 0bfec78026dfc66fda99596bb141a07755623fbb Author: Poul-Henning Kamp Date: Mon Apr 24 21:42:21 2017 +0000 Pull in the corresponding flint.lnt files when we absorb files from other directories. diff --git a/bin/varnishd/flint.sh b/bin/varnishd/flint.sh index 5606dfb..569fbbe 100755 --- a/bin/varnishd/flint.sh +++ b/bin/varnishd/flint.sh @@ -15,10 +15,15 @@ FLOPS=' proxy/*.c storage/*.c waiter/*.c + ../../lib/libvarnish/flint.lnt ../../lib/libvarnish/*.c + ../../lib/libvcc/flint.lnt ../../lib/libvcc/*.c + ../../lib/libvmod_std/flint.lnt ../../lib/libvmod_std/*.c + ../../lib/libvmod_debug/flint.lnt ../../lib/libvmod_debug/*.c + ../../lib/libvmod_directors/flint.lnt ../../lib/libvmod_directors/*.c ' From phk at FreeBSD.org Mon Apr 24 21:58:06 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 24 Apr 2017 23:58:06 +0200 Subject: [master] 2ddc4eb Be much more focused about 835 (Passing zero to operators like |, << etc.) Message-ID: commit 2ddc4eb916d8b493073390b74c3716bc7916d8bd Author: Poul-Henning Kamp Date: Mon Apr 24 21:57:22 2017 +0000 Be much more focused about 835 (Passing zero to operators like |, << etc.) diff --git a/bin/flint.lnt b/bin/flint.lnt index d5f3dc3..55d2f4a 100644 --- a/bin/flint.lnt +++ b/bin/flint.lnt @@ -40,5 +40,3 @@ -e726 // Extraneous comma ignored -e825 // control flows into case/default without -fallthrough comment --e835 // A zero has been given as ___ argument to operator '___' (<<) - diff --git a/bin/varnishd/flint.lnt b/bin/varnishd/flint.lnt index e55dc34..eb21112 100644 --- a/bin/varnishd/flint.lnt +++ b/bin/varnishd/flint.lnt @@ -61,7 +61,17 @@ -esym(458, params) // unlocked access --emacro(835, HTTPH) // Info 835: A zero has been given as left argument to operator '&' +-emacro(835, HCB_BIT_NODE) // Info 835: A zero has been given as left argument to operator '<<' +-emacro(835, VBC_STATE_AVAIL) // Info 835: A zero has been given as left argument to operator '<<' +-emacro(835, BANS_FLAG_REQ) // Info 835: A zero has been given as left argument to operator '<<' +-emacro(835, HTTPH) // Info 835: A zero has been given as left argument to operator '<<' +-emacro(835, HTTPH_R_PASS) // Info 835: A zero has been given as left argument to operator '<<' +-emacro(835, SMP_SC_LOADED) // Info 835: A zero has been given as left argument to operator '<<' +-emacro(835, SMP_SEG_MUSTLOAD) // Info 835: A zero has been given as left argument to operator '<<' +-emacro(835, DELAYED_EFFECT) // Info 835: A zero has been given as left argument to operator '<<' +-emacro(835, HDF_FILTER) // Info 835: A zero has been given as left argument to operator '<<' +-emacro(835, O_LARGEFILE) // Info 835: A zero has been given as left argument to operator '<<' + -emacro(845, HTTPH) // Info 845: The left argument to operator '&&' is certain to be 0 -esym(773, PCRE_DATE) // Expression-like macro '___' not parenthesized ////////////// diff --git a/bin/varnishlog/flint.lnt b/bin/varnishlog/flint.lnt index f2b336d..c29d6d4 100644 --- a/bin/varnishlog/flint.lnt +++ b/bin/varnishlog/flint.lnt @@ -1,4 +1,3 @@ --e835 // A zero has been given as ___ argument to operator '___' (<<) -e712 // 14 Info 712 Loss of precision (___) (___ to ___) -e747 // 16 Info 747 Significant prototype coercion (___) ___ to ___ diff --git a/bin/varnishtest/flint.lnt b/bin/varnishtest/flint.lnt index 9686e5f..6e82dd6 100644 --- a/bin/varnishtest/flint.lnt +++ b/bin/varnishtest/flint.lnt @@ -30,7 +30,8 @@ -e737 // [45] Loss of sign in promotion from int to unsigned -e713 // Loss of precision (assignment) (unsigned long long to long long) -e574 // Signed-unsigned mix with relational --e835 // A zero has been given as ___ argument to operator '___' (<<) +-emacro(835, STRTOU32_CHECK) // A zero has been given as ___ argument to operator '___' + -e788 // enum value not used in defaulted switch -efile(451, vmods.h) diff --git a/flint.lnt b/flint.lnt index 0876042..0cdded0 100644 --- a/flint.lnt +++ b/flint.lnt @@ -56,6 +56,16 @@ -emacro(774, VALID_OBJ) // boolean always true /////////////////////////////////////////////////////////////////////// +// Places where we use x<<0 for reasons of symmetry + +-emacro(835, VCT_SP) // A zero has been given as ___ argument to operator '___' +-emacro(835, VSL_COPT_TAIL) // A zero has been given as ___ argument to operator '___' +-emacro(835, SLT_F_UNUSED) // A zero has been given as ___ argument to operator '___' +-emacro(835, ARGV_COMMENT) // A zero has been given as ___ argument to operator '___' +-emacro(835, F_SEEN_ixIX) // A zero has been given as ___ argument to operator '___' +-emacro(835, VEX_OPT_CASELESS) // A zero has been given as ___ argument to operator '___' + +/////////////////////////////////////////////////////////////////////// // -esym(759, VSB_*) // header decl could be moved diff --git a/lib/libvcc/flint.lnt b/lib/libvcc/flint.lnt index f0b8f65..50a8868 100644 --- a/lib/libvcc/flint.lnt +++ b/lib/libvcc/flint.lnt @@ -29,6 +29,7 @@ -e716 // while(1) ... -e732 // Loss of sign (arg. no. 2) (int to unsigned int) +-emacro(835, EXPR_VAR) // // Info 835: A zero has been given as right argument to operator '<<' -e763 // Redundant declaration for symbol '...' previously declared From phk at FreeBSD.org Mon Apr 24 22:14:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 25 Apr 2017 00:14:05 +0200 Subject: [master] 1841912 Pull in libvarnishapi's flint.lnt Message-ID: commit 18419126469976ef9778213c5c821e5eb38360f3 Author: Poul-Henning Kamp Date: Mon Apr 24 22:12:33 2017 +0000 Pull in libvarnishapi's flint.lnt diff --git a/bin/varnishadm/flint.sh b/bin/varnishadm/flint.sh index 5994de7..631bb13 100755 --- a/bin/varnishadm/flint.sh +++ b/bin/varnishadm/flint.sh @@ -2,6 +2,7 @@ FLOPS=' *.c + ../../lib/libvarnishapi/flint.lnt ../../lib/libvarnishapi/*.c ' diff --git a/bin/varnishhist/flint.sh b/bin/varnishhist/flint.sh index 5994de7..631bb13 100755 --- a/bin/varnishhist/flint.sh +++ b/bin/varnishhist/flint.sh @@ -2,6 +2,7 @@ FLOPS=' *.c + ../../lib/libvarnishapi/flint.lnt ../../lib/libvarnishapi/*.c ' diff --git a/bin/varnishlog/flint.sh b/bin/varnishlog/flint.sh index 6f94f89..74b7d70 100755 --- a/bin/varnishlog/flint.sh +++ b/bin/varnishlog/flint.sh @@ -3,6 +3,7 @@ FLOPS=' -DVARNISH_STATE_DIR=\"foo\" *.c + ../../lib/libvarnishapi/flint.lnt ../../lib/libvarnishapi/*.c ' diff --git a/bin/varnishncsa/flint.sh b/bin/varnishncsa/flint.sh index 5994de7..631bb13 100755 --- a/bin/varnishncsa/flint.sh +++ b/bin/varnishncsa/flint.sh @@ -2,6 +2,7 @@ FLOPS=' *.c + ../../lib/libvarnishapi/flint.lnt ../../lib/libvarnishapi/*.c ' diff --git a/bin/varnishstat/flint.sh b/bin/varnishstat/flint.sh index 5994de7..631bb13 100755 --- a/bin/varnishstat/flint.sh +++ b/bin/varnishstat/flint.sh @@ -2,6 +2,7 @@ FLOPS=' *.c + ../../lib/libvarnishapi/flint.lnt ../../lib/libvarnishapi/*.c ' diff --git a/bin/varnishtop/flint.sh b/bin/varnishtop/flint.sh index 5994de7..631bb13 100755 --- a/bin/varnishtop/flint.sh +++ b/bin/varnishtop/flint.sh @@ -2,6 +2,7 @@ FLOPS=' *.c + ../../lib/libvarnishapi/flint.lnt ../../lib/libvarnishapi/*.c ' From phk at FreeBSD.org Mon Apr 24 22:14:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 25 Apr 2017 00:14:05 +0200 Subject: [master] 921bc4f FlexeLint: Neuter __v_printflike() Message-ID: commit 921bc4f131a819fff2540627e4d20c7ebdb81011 Author: Poul-Henning Kamp Date: Mon Apr 24 22:13:02 2017 +0000 FlexeLint: Neuter __v_printflike() diff --git a/flint.lnt b/flint.lnt index 0cdded0..7e34839 100644 --- a/flint.lnt +++ b/flint.lnt @@ -22,6 +22,8 @@ // +e958 // padding ++d__v_printflike() + /////////////////////////////////////////////////////////////////////// // System/Posix/Iso-C library related From phk at FreeBSD.org Mon Apr 24 22:14:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 25 Apr 2017 00:14:05 +0200 Subject: [master] 5dfa83b Don't include test-programs in FlexeLint runs Message-ID: commit 5dfa83b0e3480e0c7524b99673bc8bdc80b1177e Author: Poul-Henning Kamp Date: Mon Apr 24 22:13:32 2017 +0000 Don't include test-programs in FlexeLint runs diff --git a/lib/libvarnishapi/vsl2rst.c b/lib/libvarnishapi/vsl2rst.c index e4767d5..ea9866e 100644 --- a/lib/libvarnishapi/vsl2rst.c +++ b/lib/libvarnishapi/vsl2rst.c @@ -27,6 +27,8 @@ * */ +#ifndef __FLEXELINT__ + #include "config.h" #include @@ -111,3 +113,5 @@ main(int argc, char *argv[]) return (0); } + +#endif // __FLEXELINT__ diff --git a/lib/libvarnishapi/vsl_glob_test.c b/lib/libvarnishapi/vsl_glob_test.c index bc5eee1..3ad2ec8 100644 --- a/lib/libvarnishapi/vsl_glob_test.c +++ b/lib/libvarnishapi/vsl_glob_test.c @@ -28,6 +28,8 @@ * Test what VSL_Name2Tag and VSL_Glob2Tags produces */ +#ifndef __FLEXELINT__ + #include #include #include @@ -69,3 +71,5 @@ main(int argc, char * const *argv) return (0); } + +#endif // __FLEXELINT__ diff --git a/lib/libvarnishapi/vxp_test.c b/lib/libvarnishapi/vxp_test.c index cbb598a..bcca61b 100644 --- a/lib/libvarnishapi/vxp_test.c +++ b/lib/libvarnishapi/vxp_test.c @@ -26,6 +26,8 @@ * SUCH DAMAGE. */ +#ifndef __FLEXELINT__ + #include #include #include @@ -84,3 +86,5 @@ main(int argc, char * const *argv) return (0); } + +#endif // __FLEXELINT__ From phk at FreeBSD.org Mon Apr 24 22:48:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 25 Apr 2017 00:48:05 +0200 Subject: [master] 3fa742c Don't include aux/util/test programs in FlexeLint runs Message-ID: commit 3fa742c7a93a56c0c276e2a7c26d2d5bb28e53ac Author: Poul-Henning Kamp Date: Mon Apr 24 22:26:37 2017 +0000 Don't include aux/util/test programs in FlexeLint runs diff --git a/bin/varnishstat/vsc2rst.c b/bin/varnishstat/vsc2rst.c index c53dc72..6446ccb 100644 --- a/bin/varnishstat/vsc2rst.c +++ b/bin/varnishstat/vsc2rst.c @@ -27,6 +27,8 @@ * */ +#ifndef __FLEXELINT__ + #include "config.h" #include @@ -67,3 +69,5 @@ int main(int argc, char **argv) #include "tbl/vsc_all.h" return (0); } + +#endif // __FLEXELINT__ From phk at FreeBSD.org Mon Apr 24 22:48:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 25 Apr 2017 00:48:05 +0200 Subject: [master] 80955bd Leave __v_printflike() to vdef.h where it belongs Message-ID: commit 80955bd7d44b9f5b6e66e4ef3dcde59604e89ac1 Author: Poul-Henning Kamp Date: Mon Apr 24 22:27:05 2017 +0000 Leave __v_printflike() to vdef.h where it belongs diff --git a/flint.lnt b/flint.lnt index 7e34839..0cdded0 100644 --- a/flint.lnt +++ b/flint.lnt @@ -22,8 +22,6 @@ // +e958 // padding -+d__v_printflike() - /////////////////////////////////////////////////////////////////////// // System/Posix/Iso-C library related From phk at FreeBSD.org Mon Apr 24 22:48:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 25 Apr 2017 00:48:05 +0200 Subject: [master] 12fa1f5 Minor Flexelinting Message-ID: commit 12fa1f551ff1847e6854e650698c17df5d61385d Author: Poul-Henning Kamp Date: Mon Apr 24 22:39:14 2017 +0000 Minor Flexelinting diff --git a/bin/varnishhist/varnishhist.c b/bin/varnishhist/varnishhist.c index 19cbc33..4a6b7d0 100644 --- a/bin/varnishhist/varnishhist.c +++ b/bin/varnishhist/varnishhist.c @@ -106,7 +106,7 @@ static int scales[] = { INT_MAX }; -static struct profile { +struct profile { const char *name; char VSL_arg; enum VSL_tag_e tag; @@ -114,13 +114,14 @@ static struct profile { int field; int hist_low; int hist_high; -} +}; + #define HIS_PROF(name,vsl_arg,tag,prefix,field,hist_low,high_high,doc) \ {name,vsl_arg,tag,prefix,field,hist_low,high_high}, #define HIS_NO_PREFIX NULL #define HIS_CLIENT 'c' #define HIS_BACKEND 'b' -profiles[] = { +static const struct profile profiles[] = { #include "varnishhist_profiles.h" { NULL } }; @@ -129,7 +130,7 @@ profiles[] = { #undef HIS_CLIENT #undef HIS_PROF -static struct profile *active_profile; +static const struct profile *active_profile; volatile sig_atomic_t quit = 0; @@ -224,7 +225,7 @@ accumulate(struct VSL_data *vsl, struct VSL_transaction * const pt[], { int i, tag, skip, match, hit; unsigned u; - double value; + double value = 0; struct VSL_transaction *tr; double t; const char *tsp; @@ -582,6 +583,7 @@ main(int argc, char **argv) break; } } + AN(active_profile); if (!active_profile->name) VUT_Error(1, "-P: No such profile '%s'", profile); @@ -599,7 +601,8 @@ main(int argc, char **argv) if (timebend > 0) t0 = VTIM_mono(); - format = malloc(4 * fnum); + format = malloc(4L * fnum); + AN(format); for (i = 0; i < fnum - 1; i++) strcpy(format + 4 * i, "%*s "); strcpy(format + 4 * (fnum - 1), "%lf"); From phk at FreeBSD.org Mon Apr 24 22:48:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 25 Apr 2017 00:48:05 +0200 Subject: [master] e6193ce Minor FlexeLintery Message-ID: commit e6193ce4869e42e88bd97322ed9359781f1c2703 Author: Poul-Henning Kamp Date: Mon Apr 24 22:47:40 2017 +0000 Minor FlexeLintery diff --git a/lib/libvarnishapi/flint.lnt b/lib/libvarnishapi/flint.lnt index e69de29..4a0c875 100644 --- a/lib/libvarnishapi/flint.lnt +++ b/lib/libvarnishapi/flint.lnt @@ -0,0 +1,2 @@ +-esym(788, vex_rhs_e::*) +-esym(788, VSL_transaction_e::*) diff --git a/lib/libvarnishapi/vsl_arg.c b/lib/libvarnishapi/vsl_arg.c index 23f1844..0ab5679 100644 --- a/lib/libvarnishapi/vsl_arg.c +++ b/lib/libvarnishapi/vsl_arg.c @@ -53,7 +53,6 @@ #include "vre.h" #include "vapi/vsl.h" -#include "vapi/vsm.h" #include "vsl_api.h" #include "vsm_api.h" diff --git a/lib/libvarnishapi/vxp.h b/lib/libvarnishapi/vxp.h index c7a0981..e1e9918 100644 --- a/lib/libvarnishapi/vxp.h +++ b/lib/libvarnishapi/vxp.h @@ -49,7 +49,6 @@ struct token { const char *b; const char *e; VTAILQ_ENTRY(token) list; - unsigned cnt; char *dec; }; @@ -57,7 +56,6 @@ struct vxp { unsigned magic; #define VXP_MAGIC 0x59C7F6AC - const char *src; const char *b; const char *e; @@ -124,7 +122,6 @@ struct vex { /* VXP internals */ #define ERRCHK(tl) do { if ((tl)->err) return; } while (0) -#define Expect(a, b) vxp__Expect(a, b) #define ExpectErr(a, b) \ do { vxp__Expect(a, b); ERRCHK(a); } while (0) #define SkipToken(a, b) \ From hermunn at varnish-software.com Tue Apr 25 15:39:05 2017 From: hermunn at varnish-software.com (Pål Hermunn Johansen) Date: Tue, 25 Apr 2017 17:39:05 +0200 Subject: [4.1] 59b47f8 Add std.file_exists(path) to check if path exists Message-ID: commit 59b47f863ecbfad591ad2b665fcd51a76bc2f8cc Author: Jonathan Huot Date: Wed Mar 29 14:59:14 2017 +0200 Add std.file_exists(path) to check if path exists Conflicts: lib/libvmod_std/vmod.vcc lib/libvmod_std/vmod_std.c diff --git a/bin/varnishtest/tests/m00029.vtc b/bin/varnishtest/tests/m00029.vtc new file mode 100644 index 0000000..fbae76e --- /dev/null +++ b/bin/varnishtest/tests/m00029.vtc @@ -0,0 +1,22 @@ +varnishtest "Test std.file_exists" + +server s1 { + rxreq + txresp +} -start + +varnish v1 -vcl+backend { + import ${vmod_std}; + + sub vcl_deliver { + set resp.http.existsA = std.file_exists("/non/existent"); + set resp.http.existsB = std.file_exists("${tmpdir}/v1/_.vsm"); + } +} -start + +client c1 { + txreq + rxresp + expect resp.http.existsA == "false" + expect resp.http.existsB == "true" +} -run diff --git a/lib/libvmod_std/vmod.vcc b/lib/libvmod_std/vmod.vcc index 97d3b5e..e7f1d6f 100644 --- a/lib/libvmod_std/vmod.vcc +++ b/lib/libvmod_std/vmod.vcc @@ -104,6 +104,16 @@ Description Example set beresp.http.served-by = std.fileread("/etc/hostname"); +$Function BOOL file_exists(STRING path) + +Description + Returns `true` if path or the file pointed to by path exists, + `false` otherwise. +Example + | if (std.file_exists("/etc/return_503")) { + | return (synth(503, "Varnish is in maintenance")); + | } + $Function VOID collect(HEADER hdr) Description diff --git a/lib/libvmod_std/vmod_std.c b/lib/libvmod_std/vmod_std.c index 685a348..2539fc0 100644 --- a/lib/libvmod_std/vmod_std.c +++ b/lib/libvmod_std/vmod_std.c @@ -28,14 +28,17 @@ #include "config.h" -#include #include +#include +#include + #include #include #include #include #include +#include #include "vrt.h" #include "vtcp.h" @@ -176,6 +179,15 @@ vmod_syslog(VRT_CTX, VCL_INT fac, const char *fmt, ...) va_end(ap); } +VCL_BOOL __match_proto__(td_std_file_exists) +vmod_file_exists(VRT_CTX, VCL_STRING file_name) +{ + struct stat st; + + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + return (stat(file_name, &st) == 0); +} + VCL_VOID __match_proto__(td_std_collect) vmod_collect(VRT_CTX, VCL_HEADER hdr) { From phk at FreeBSD.org Wed Apr 26 11:22:06 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 26 Apr 2017 13:22:06 +0200 Subject: [master] c6505ab Flexelintery Message-ID: commit c6505ab9f242e82f547479b9a1aaef5d5a3afcd3 Author: Poul-Henning Kamp Date: Tue Apr 25 06:56:26 2017 +0000 Flexelintery diff --git a/lib/libvarnish/flint.lnt b/lib/libvarnish/flint.lnt index 5755730..77a2a2d 100644 --- a/lib/libvarnish/flint.lnt +++ b/lib/libvarnish/flint.lnt @@ -1,6 +1,10 @@ +libh mgt_event.h +libh ../../config.h ++fan // Allow anon unions + +-dVARNISH_STATE_DIR="foo" + -emacro((???),va_arg) // the va_arg() macro can yield 415, 416, 661, 662 // 796 and 797 (out-of-bounds errors). -elib(123) // size is both a variable and a macro with args diff --git a/lib/libvarnish/vav.c b/lib/libvarnish/vav.c index d39932f..51a7ef6 100644 --- a/lib/libvarnish/vav.c +++ b/lib/libvarnish/vav.c @@ -112,7 +112,7 @@ VAV_BackSlashDecode(const char *s, const char *e) if (e == NULL) e = strchr(s, '\0'); assert(e != NULL); - p = calloc((e - s) + 1, 1); + p = calloc((e - s) + 1L, 1); if (p == NULL) return (p); for (r = p, q = s; q < e; ) { @@ -193,7 +193,7 @@ VAV_Parse(const char *s, int *argc, int flag) assert(argv != NULL); } if (flag & ARGV_NOESC) { - argv[nargv] = malloc(1 + (s - p)); + argv[nargv] = malloc(1L + (s - p)); assert(argv[nargv] != NULL); memcpy(argv[nargv], p, s - p); argv[nargv][s - p] = '\0'; diff --git a/lib/libvarnish/vpf.c b/lib/libvarnish/vpf.c index 7883adb..a5fd683 100644 --- a/lib/libvarnish/vpf.c +++ b/lib/libvarnish/vpf.c @@ -188,7 +188,7 @@ VPF_Write(struct vpf_fh *pfh) return (-1); } - error = snprintf(pidstr, sizeof(pidstr), "%ju", (uintmax_t)getpid()); + error = snprintf(pidstr, sizeof(pidstr), "%jd", (intmax_t)getpid()); assert(error < sizeof pidstr); if (pwrite(fd, pidstr, strlen(pidstr), 0) != (ssize_t)strlen(pidstr)) { error = errno; diff --git a/lib/libvarnish/vsa.c b/lib/libvarnish/vsa.c index c6fcac2..c2e157b 100644 --- a/lib/libvarnish/vsa.c +++ b/lib/libvarnish/vsa.c @@ -333,9 +333,9 @@ VSA_Compare_IP(const struct suckaddr *sua1, const struct suckaddr *sua2) case PF_INET6: return (memcmp(&sua1->sa6.sin6_addr, &sua2->sa6.sin6_addr, sizeof(struct in6_addr))); + default: + WRONG("Just plain insane"); } - - WRONG("Just plain insane"); NEEDLESS(return(-1)); } From phk at FreeBSD.org Wed Apr 26 11:22:06 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 26 Apr 2017 13:22:06 +0200 Subject: [master] 81def20 FlexeLint polishing. Message-ID: commit 81def204b50fb4680e84c98f7d815b356da04526 Author: Poul-Henning Kamp Date: Wed Apr 26 11:21:17 2017 +0000 FlexeLint polishing. diff --git a/bin/varnishadm/varnishadm.c b/bin/varnishadm/varnishadm.c index 2bd49ba..1c046b2 100644 --- a/bin/varnishadm/varnishadm.c +++ b/bin/varnishadm/varnishadm.c @@ -186,7 +186,8 @@ do_args(int sock, int argc, char * const *argv) * to have a global variable. */ static int _line_sock; -static void send_line(char *l) +static void __match_proto__() +send_line(char *l) { if (l) { cli_write(_line_sock, l); diff --git a/bin/varnishd/flint.lnt b/bin/varnishd/flint.lnt index eb21112..2ab787f 100644 --- a/bin/varnishd/flint.lnt +++ b/bin/varnishd/flint.lnt @@ -57,7 +57,6 @@ -sem (VBE_DropRefLocked, thread_unlock) -e454 // mutex not released (...ReleaseLocked) -e457 // unprotected access --e777 // float equality comparison -esym(458, params) // unlocked access diff --git a/bin/varnishhist/varnishhist.c b/bin/varnishhist/varnishhist.c index 4a6b7d0..7feec7d 100644 --- a/bin/varnishhist/varnishhist.c +++ b/bin/varnishhist/varnishhist.c @@ -82,7 +82,7 @@ static double vsl_t0 = 0, vsl_to, vsl_ts = 0; static pthread_cond_t timebend_cv; static double log_ten; -static int scales[] = { +static const int scales[] = { 1, 2, 3, diff --git a/bin/varnishstat/varnishstat_curses.c b/bin/varnishstat/varnishstat_curses.c index b96101d..0ba009f 100644 --- a/bin/varnishstat/varnishstat_curses.c +++ b/bin/varnishstat/varnishstat_curses.c @@ -119,7 +119,6 @@ static WINDOW *w_info = NULL; static int verbosity = VSC_level_info; static int keep_running = 1; -static int show_info = 1; static int hide_unseen = 1; static int page_start = 0; static int current = 0; @@ -476,7 +475,7 @@ make_windows(void) l_status = LINES_STATUS; l_bar_t = LINES_BAR_T; l_bar_b = LINES_BAR_B; - l_info = (show_info ? LINES_INFO : 0); + l_info = LINES_INFO; l_points = Y - (l_status + l_bar_t + l_bar_b + l_info); if (l_points < LINES_POINTS_MIN) { l_points += l_info; @@ -634,7 +633,7 @@ draw_bar_t(void) } static void -draw_line_default(WINDOW *w, int y, int x, int X, struct pt *pt) +draw_line_default(WINDOW *w, int y, int x, int X, const struct pt *pt) { enum { COL_CUR, @@ -722,7 +721,7 @@ print_trunc(WINDOW *w, uintmax_t val) } static void -draw_line_bytes(WINDOW *w, int y, int x, int X, struct pt *pt) +draw_line_bytes(WINDOW *w, int y, int x, int X, const struct pt *pt) { enum { COL_CUR, @@ -779,7 +778,7 @@ draw_line_bytes(WINDOW *w, int y, int x, int X, struct pt *pt) } static void -draw_line_bitmap(WINDOW *w, int y, int x, int X, struct pt *pt) +draw_line_bitmap(WINDOW *w, int y, int x, int X, const struct pt *pt) { int ch; enum { @@ -822,7 +821,7 @@ draw_line_bitmap(WINDOW *w, int y, int x, int X, struct pt *pt) } static void -draw_line_duration(WINDOW *w, int y, int x, int X, struct pt *pt) +draw_line_duration(WINDOW *w, int y, int x, int X, const struct pt *pt) { enum { COL_DUR, @@ -853,7 +852,7 @@ draw_line_duration(WINDOW *w, int y, int x, int X, struct pt *pt) } static void -draw_line(WINDOW *w, int y, struct pt *pt) +draw_line(WINDOW *w, int y, const struct pt *pt) { int x, X; diff --git a/flint.lnt b/flint.lnt index 0cdded0..c8bdee3 100644 --- a/flint.lnt +++ b/flint.lnt @@ -15,11 +15,22 @@ /////////////////////////////////////////////////////////////////////// // General stylistic issues --e726 // Extraneous comma ignored -e641 // Converting enum '...' to int +-e726 // Extraneous comma ignored -e763 // Redundant declaration for symbol '...' previously declared +-e777 // Testing floats for equality -e786 // String concatenation within initializer +-esym(818, argv) // Pointer parameter '...' could be declared as pointing to const + +/* + * va_list's are opaque for a reason, but we pretend to FlexeLint that it + * is just a void*, so it proposes constification, which is not generally OK, + * for instance on register-spilling architectures. + * XXX: Maybe 'ap' is a badly chosen conventional name here... + */ +-esym(818, ap) // Pointer parameter '...' could be declared as pointing to const + // +e958 // padding /////////////////////////////////////////////////////////////////////// From hermunn at varnish-software.com Wed Apr 26 11:25:05 2017 From: hermunn at varnish-software.com (Pål Hermunn Johansen) Date: Wed, 26 Apr 2017 13:25:05 +0200 Subject: [4.1] 0cb5b09 cannot link to varnishapi, symbols missing Message-ID: commit 0cb5b09b0c00e135e0cfa6632d5d89470b286c31 Author: Denes Matetelki Date: Tue Apr 18 09:43:34 2017 +0200 cannot link to varnishapi, symbols missing Fixes: #2313 This is a back port of f1741d99 from master. diff --git a/lib/libvarnishapi/libvarnishapi.map b/lib/libvarnishapi/libvarnishapi.map index e5aa91d..1e11835 100644 --- a/lib/libvarnishapi/libvarnishapi.map +++ b/lib/libvarnishapi/libvarnishapi.map @@ -40,9 +40,9 @@ LIBVARNISHAPI_1.0 { VSM_Head; VSM_Find_Chunk; VSM_Close; - VSM_iter0; - VSM_intern; - + VSM__iter0; + VSM__itern; + VSC_Setup; VSC_Arg; VSC_Open; From phk at FreeBSD.org Wed Apr 26 11:51:04 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 26 Apr 2017 13:51:04 +0200 Subject: [master] 70aec05 FlexeLinting mainly related to #includs Message-ID: commit 70aec0594f7e60ffc9c6db6f3af42997de279d92 Author: Poul-Henning Kamp Date: Wed Apr 26 11:50:29 2017 +0000 FlexeLinting mainly related to #includs diff --git a/bin/varnishd/flint.lnt b/bin/varnishd/flint.lnt index 2ab787f..f0667fd 100644 --- a/bin/varnishd/flint.lnt +++ b/bin/varnishd/flint.lnt @@ -115,7 +115,6 @@ -e455 // thread lock -e458 // unprotected read --e728 // Symbol ... not explicitly initialized -e716 // while(1) ... -e717 // do ... while(1) ... -e785 // Too few initializers for aggregate diff --git a/bin/varnishhist/flint.lnt b/bin/varnishhist/flint.lnt index e69de29..78ae771 100644 --- a/bin/varnishhist/flint.lnt +++ b/bin/varnishhist/flint.lnt @@ -0,0 +1,2 @@ +-efile(451, "varnishhist_profiles.h") +-efile(451, "varnishhist_options.h") diff --git a/bin/varnishhist/varnishhist.c b/bin/varnishhist/varnishhist.c index 7feec7d..9d0fc45 100644 --- a/bin/varnishhist/varnishhist.c +++ b/bin/varnishhist/varnishhist.c @@ -49,10 +49,8 @@ #include "vdef.h" #include "vcurses.h" #include "vapi/vsl.h" -#include "vapi/vsm.h" #include "vapi/voptget.h" #include "vas.h" -#include "vcs.h" #include "vut.h" #include "vtim.h" @@ -612,7 +610,7 @@ main(int argc, char **argv) VUT_Setup(); if (pthread_create(&thr, NULL, do_curses, NULL) != 0) VUT_Error(1, "pthread_create(): %s", strerror(errno)); - VUT.dispatch_f = &accumulate; + VUT.dispatch_f = accumulate; VUT.dispatch_priv = NULL; VUT.sighup_f = sighup; VUT_Main(); diff --git a/bin/varnishlog/flint.lnt b/bin/varnishlog/flint.lnt index c29d6d4..7d06a3e 100644 --- a/bin/varnishlog/flint.lnt +++ b/bin/varnishlog/flint.lnt @@ -4,6 +4,8 @@ -e763 // Redundant declaration for symbol '...' previously declared -e716 // while(1) ... +-efile(451, "varnishlog_options.h") + -e457 // unprotected write access -e459 // unprotected access -e458 // unprotected access diff --git a/bin/varnishlog/varnishlog.c b/bin/varnishlog/varnishlog.c index 6fd36b4..6f8fdb6 100644 --- a/bin/varnishlog/varnishlog.c +++ b/bin/varnishlog/varnishlog.c @@ -46,7 +46,6 @@ #include "vas.h" #include "vdef.h" #include "vpf.h" -#include "vsb.h" #include "vut.h" #include "miniobj.h" diff --git a/bin/varnishncsa/flint.lnt b/bin/varnishncsa/flint.lnt index 462320f..f9fb415 100644 --- a/bin/varnishncsa/flint.lnt +++ b/bin/varnishncsa/flint.lnt @@ -1,9 +1,10 @@ +d__attribute__()= +-efile(451, "varnishncsa_options.h") + -e763 // Redundant declaration for symbol '...' previously declared -e726 // Extraneous comma ignored --e728 // Symbol ... not explicitly initialized -e716 // while(1) ... -e785 // Too few initializers for aggregate diff --git a/bin/varnishncsa/varnishncsa.c b/bin/varnishncsa/varnishncsa.c index 364f580..8c4923c 100644 --- a/bin/varnishncsa/varnishncsa.c +++ b/bin/varnishncsa/varnishncsa.c @@ -59,7 +59,6 @@ #include "vapi/voptget.h" #include "vas.h" #include "vdef.h" -#include "vcs.h" #include "vsb.h" #include "vut.h" #include "vqueue.h" diff --git a/bin/varnishstat/flint.lnt b/bin/varnishstat/flint.lnt index 509e13a..eaa89be 100644 --- a/bin/varnishstat/flint.lnt +++ b/bin/varnishstat/flint.lnt @@ -1,6 +1,8 @@ +libh mgt_event.h +-efile(451, varnishstat_options.h) + -esym(850, av) -e712 // 14 Info 712 Loss of precision (___) (___ to ___) diff --git a/bin/varnishtest/vtc_http.c b/bin/varnishtest/vtc_http.c index 4df6dd2..557f90f 100644 --- a/bin/varnishtest/vtc_http.c +++ b/bin/varnishtest/vtc_http.c @@ -1675,7 +1675,11 @@ cmd_http_fatal(CMD_ARGS) * Same as for the top-level barrier */ -static const char PREFACE[24] = "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n"; +static const char PREFACE[24] = { + 0x50, 0x52, 0x49, 0x20, 0x2a, 0x20, 0x48, 0x54, + 0x54, 0x50, 0x2f, 0x32, 0x2e, 0x30, 0x0d, 0x0a, + 0x0d, 0x0a, 0x53, 0x4d, 0x0d, 0x0a, 0x0d, 0x0a +}; /* SECTION: client-server.spec.txpri * diff --git a/bin/varnishtest/vtc_http2.c b/bin/varnishtest/vtc_http2.c index ead77a4..18d9361 100644 --- a/bin/varnishtest/vtc_http2.c +++ b/bin/varnishtest/vtc_http2.c @@ -44,7 +44,6 @@ #include "vtc.h" #include "vtc_http.h" -#include "vct.h" #include "vfil.h" #include "vgz.h" #include "vnum.h" diff --git a/bin/varnishtop/varnishtop.c b/bin/varnishtop/varnishtop.c index 0c08e02..6af08a1 100644 --- a/bin/varnishtop/varnishtop.c +++ b/bin/varnishtop/varnishtop.c @@ -50,9 +50,7 @@ #include "vapi/voptget.h" #include "vas.h" #include "vdef.h" -#include "vcs.h" #include "vtree.h" -#include "vsb.h" #include "vut.h" #if 0 diff --git a/flint.lnt b/flint.lnt index c8bdee3..43917a9 100644 --- a/flint.lnt +++ b/flint.lnt @@ -8,6 +8,9 @@ -efile(451, "tbl/*.h") // No include guard -efile(537, "tbl/*.h") // Repeated include +-efile(451, "../../include/vut_options.h") // No include guard +-efile(451, "../../include/vapi/vapi_options.h") // No include guard + -efile(451, ../../config.h) // No include guard -efile(766, ../../config.h) // Header file '___' not used in module '___' @@ -17,6 +20,7 @@ // General stylistic issues -e641 // Converting enum '...' to int -e726 // Extraneous comma ignored +-e728 // Symbol ... not explicitly initialized -e763 // Redundant declaration for symbol '...' previously declared -e777 // Testing floats for equality -e786 // String concatenation within initializer @@ -31,6 +35,8 @@ */ -esym(818, ap) // Pointer parameter '...' could be declared as pointing to const +-efunc(789, main) // Assigning address of auto variable '...' to static + // +e958 // padding /////////////////////////////////////////////////////////////////////// diff --git a/lib/libvarnish/flint.lnt b/lib/libvarnish/flint.lnt index 77a2a2d..2ac9733 100644 --- a/lib/libvarnish/flint.lnt +++ b/lib/libvarnish/flint.lnt @@ -27,7 +27,6 @@ -e763 // Redundant declaration for symbol '...' previously declared -e726 // Extraneous comma ignored --e728 // Symbol ... not explicitly initialized -e716 // while(1) ... -e785 // Too few initializers for aggregate From fgsch at lodoss.net Wed Apr 26 12:47:05 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Wed, 26 Apr 2017 14:47:05 +0200 Subject: [master] 2107c3b Add checks Message-ID: commit 2107c3b1d9ea98c779d5a07eae942d716f2759a6 Author: Federico G. Schwindt Date: Sun Apr 23 22:00:25 2017 +0100 Add checks diff --git a/bin/varnishncsa/varnishncsa.c b/bin/varnishncsa/varnishncsa.c index 8c4923c..2a94519 100644 --- a/bin/varnishncsa/varnishncsa.c +++ b/bin/varnishncsa/varnishncsa.c @@ -414,6 +414,7 @@ print(void) VSB_clear(CTX.vsb); VTAILQ_FOREACH(f, &CTX.format, list) { + CHECK_OBJ_NOTNULL(f, FORMAT_MAGIC); i = (f->func)(f); if (r > i) r = i; @@ -890,6 +891,7 @@ process_hdr(const struct watch_head *head, const char *b, const char *e) const char *p; VTAILQ_FOREACH(w, head, list) { + CHECK_OBJ_NOTNULL(w, WATCH_MAGIC); if (!isprefix(w->key, w->keylen, b, e, &p)) continue; frag_line(1, p, e, &w->frag); From fgsch at lodoss.net Wed Apr 26 12:47:05 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Wed, 26 Apr 2017 14:47:05 +0200 Subject: [master] a6dcbf5 Fix compilation with sanitizer(s) enabled Message-ID: commit a6dcbf5ae4b39011a9a43471b7facdbb8d552cf2 Author: Federico G. Schwindt Date: Tue Apr 25 07:15:10 2017 -0700 Fix compilation with sanitizer(s) enabled diff --git a/bin/varnishd/Makefile.am b/bin/varnishd/Makefile.am index 1034c51..844b158 100644 --- a/bin/varnishd/Makefile.am +++ b/bin/varnishd/Makefile.am @@ -163,19 +163,22 @@ varnishd_LDADD = \ noinst_PROGRAMS = vhp_gen_hufdec vhp_gen_hufdec_SOURCES = hpack/vhp_gen_hufdec.c -vhp_gen_hufdec_CFLAGS = -include config.h +vhp_gen_hufdec_CFLAGS = @SAN_CFLAGS@ \ + -include config.h vhp_gen_hufdec_LDADD = \ $(top_builddir)/lib/libvarnish/libvarnish.a noinst_PROGRAMS += vhp_table_test vhp_table_test_SOURCES = hpack/vhp_table.c -vhp_table_test_CFLAGS = -DTABLE_TEST_DRIVER -include config.h +vhp_table_test_CFLAGS = @SAN_CFLAGS@ \ + -DTABLE_TEST_DRIVER -include config.h vhp_table_test_LDADD = \ $(top_builddir)/lib/libvarnish/libvarnish.a noinst_PROGRAMS += vhp_decode_test vhp_decode_test_SOURCES = hpack/vhp_decode.c hpack/vhp_table.c -vhp_decode_test_CFLAGS = -DDECODE_TEST_DRIVER -include config.h +vhp_decode_test_CFLAGS = @SAN_CFLAGS@ \ + -DDECODE_TEST_DRIVER -include config.h vhp_decode_test_LDADD = \ $(top_builddir)/lib/libvarnish/libvarnish.a From fgsch at lodoss.net Wed Apr 26 12:47:05 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Wed, 26 Apr 2017 14:47:05 +0200 Subject: [master] deb830f Plug a harmless heap use-after-free Message-ID: commit deb830fbe6faf314a02908694a1e3d16070dc0fa Author: Federico G. Schwindt Date: Tue Apr 25 07:20:39 2017 -0700 Plug a harmless heap use-after-free diff --git a/bin/varnishd/common/heritage.h b/bin/varnishd/common/heritage.h index b7bca53..5d6a8af 100644 --- a/bin/varnishd/common/heritage.h +++ b/bin/varnishd/common/heritage.h @@ -48,7 +48,6 @@ struct listen_sock { VTAILQ_ENTRY(listen_sock) list; VTAILQ_ENTRY(listen_sock) arglist; int sock; - const struct listen_arg *arg; char *name; struct suckaddr *addr; const struct transport *transport; diff --git a/bin/varnishd/mgt/mgt_acceptor.c b/bin/varnishd/mgt/mgt_acceptor.c index 3b0985f..f9926f4 100644 --- a/bin/varnishd/mgt/mgt_acceptor.c +++ b/bin/varnishd/mgt/mgt_acceptor.c @@ -114,11 +114,10 @@ mac_callback(void *priv, const struct suckaddr *sa) VTAILQ_FOREACH(ls, &heritage.socks, list) { if (!VSA_Compare(sa, ls->addr)) ARGV_ERR("-a arguments %s and %s have same address\n", - ls->arg->name, la->name); + ls->name, la->name); } ALLOC_OBJ(ls, LISTEN_SOCK_MAGIC); AN(ls); - ls->arg = la; ls->sock = -1; ls->addr = VSA_Clone(sa); AN(ls->addr); From fgsch at lodoss.net Wed Apr 26 12:47:05 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Wed, 26 Apr 2017 14:47:05 +0200 Subject: [master] cd4b0df Fix a heap overflow in varnishtest Message-ID: commit cd4b0df90747a83d6d8b42b7fb01a0835526e124 Author: Federico G. Schwindt Date: Wed Apr 26 05:28:43 2017 -0700 Fix a heap overflow in varnishtest diff --git a/bin/varnishtest/vtc_http2.c b/bin/varnishtest/vtc_http2.c index 18d9361..275fba2 100644 --- a/bin/varnishtest/vtc_http2.c +++ b/bin/varnishtest/vtc_http2.c @@ -2004,7 +2004,7 @@ cmd_txgoaway(CMD_ARGS) vtc_fatal(vl, "Unknown txgoaway spec: %s\n", *av); if (!f.data) - f.data = malloc(2); + f.data = malloc(8); vbe32enc(f.data, ls); vbe32enc(f.data + 4, err); write_frame(s->hp, &f, 1); From fgsch at lodoss.net Wed Apr 26 12:47:05 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Wed, 26 Apr 2017 14:47:05 +0200 Subject: [master] 2818d34 Tidy up Message-ID: commit 2818d34f3ffe75f3417aee208febf07fb8a2eed0 Author: Federico G. Schwindt Date: Wed Apr 26 05:31:12 2017 -0700 Tidy up diff --git a/bin/varnishtest/vtc_http2.c b/bin/varnishtest/vtc_http2.c index 275fba2..796344e 100644 --- a/bin/varnishtest/vtc_http2.c +++ b/bin/varnishtest/vtc_http2.c @@ -1228,7 +1228,7 @@ cmd_var_resolve(const struct stream *s, const char *spec, char *buf) #include "tbl/h2_error.h" else return (spec); - return(NULL); + return (NULL); } /* SECTION: stream.spec.frame_sendhex sendhex @@ -1726,7 +1726,7 @@ cmd_txrst(CMD_ARGS) while (*++av) { if (!strcmp(*av, "-err")) { ++av; - for (err=0; h2_errs[err]; err++) { + for (err = 0; h2_errs[err]; err++) { if (!strcmp(h2_errs[err], *av)) break; } @@ -1944,12 +1944,12 @@ cmd_txping(CMD_ARGS) } /* - * SECTION: stream.spec.goaway_txgoaway rxgoaway + * SECTION: stream.spec.goaway_txgoaway txgoaway * * Possible options include: * * \-err STRING|INT - * set the error code to eplain the termination. The second argument + * set the error code to explain the termination. The second argument * can be a integer or the string version of the error code as found * in rfc7540#7. * @@ -1969,18 +1969,16 @@ cmd_txgoaway(CMD_ARGS) uint32_t err = 0; uint32_t ls = 0; struct frame f; - char buf[8]; (void)cmd; CAST_OBJ_NOTNULL(s, priv, STREAM_MAGIC); - memset(buf, 0, 8); INIT_FRAME(f, GOAWAY, 8, s->id, 0); while (*++av) { if (!strcmp(*av, "-err")) { ++av; - for (err=0; h2_errs[err]; err++) + for (err = 0; h2_errs[err]; err++) if (!strcmp(h2_errs[err], *av)) break; @@ -1996,6 +1994,7 @@ cmd_txgoaway(CMD_ARGS) vtc_fatal(vl, "this frame already has debug data"); f.size = 8 + strlen(*av); f.data = malloc(f.size); + AN(f.data); memcpy(f.data + 8, *av, f.size - 8); } else break; @@ -2003,8 +2002,10 @@ cmd_txgoaway(CMD_ARGS) if (*av != NULL) vtc_fatal(vl, "Unknown txgoaway spec: %s\n", *av); - if (!f.data) + if (!f.data) { f.data = malloc(8); + AN(f.data); + } vbe32enc(f.data, ls); vbe32enc(f.data + 4, err); write_frame(s->hp, &f, 1); From phk at FreeBSD.org Wed Apr 26 12:58:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 26 Apr 2017 14:58:05 +0200 Subject: [master] 95b8ecc More Flexelintery Message-ID: commit 95b8eccd379bce2e7e8e5182ed0d25567e6d65fd Author: Poul-Henning Kamp Date: Wed Apr 26 12:57:33 2017 +0000 More Flexelintery diff --git a/bin/flint.lnt b/bin/flint.lnt index 55d2f4a..dadd62d 100644 --- a/bin/flint.lnt +++ b/bin/flint.lnt @@ -37,6 +37,4 @@ -emacro(702, WEXITSTATUS) // signed shift right --e726 // Extraneous comma ignored - -e825 // control flows into case/default without -fallthrough comment diff --git a/bin/varnishd/flint.lnt b/bin/varnishd/flint.lnt index f0667fd..5432486 100644 --- a/bin/varnishd/flint.lnt +++ b/bin/varnishd/flint.lnt @@ -115,9 +115,7 @@ -e455 // thread lock -e458 // unprotected read --e716 // while(1) ... -e717 // do ... while(1) ... --e785 // Too few initializers for aggregate -e850 // for loop index variable '___' whose type category is '___' // is modified in body of the for loop that began at '___' diff --git a/bin/varnishd/vclflint.lnt b/bin/varnishd/vclflint.lnt index 74ba97c..de6aaab 100644 --- a/bin/varnishd/vclflint.lnt +++ b/bin/varnishd/vclflint.lnt @@ -4,9 +4,6 @@ -esym(763, sess) // Redundant declaration for symbol 'sess' -esym(763, cli) // Redundant declaration for symbol 'cli' --e785 // Too few initializers for aggregate '___' of type '___' - - -esym(750, VCL_RET_*) // not ref -esym(750, VCL_MET_*) // not ref diff --git a/bin/varnishhist/varnishhist.c b/bin/varnishhist/varnishhist.c index 9d0fc45..51c5038 100644 --- a/bin/varnishhist/varnishhist.c +++ b/bin/varnishhist/varnishhist.c @@ -130,7 +130,7 @@ static const struct profile profiles[] = { static const struct profile *active_profile; -volatile sig_atomic_t quit = 0; +static volatile sig_atomic_t quit = 0; static void update(void) diff --git a/bin/varnishhist/varnishhist_options.h b/bin/varnishhist/varnishhist_options.h index 055681b..a9bedea 100644 --- a/bin/varnishhist/varnishhist_options.h +++ b/bin/varnishhist/varnishhist_options.h @@ -78,11 +78,11 @@ HIS_OPT_p #define HIS_CLIENT "client" #define HIS_BACKEND "backend" #define HIS_NO_PREFIX "" -#define HIS_PROF(name,cb,tag,prefix,field,hist_low,high_high,doc) \ +#define HIS_PROF(name,cb,tg,prefix,fld,hist_low,high_high,doc) \ VOPT("P:", "[-P " name "]", \ "Predefined " cb " profile", \ "Predefined " cb " profile: " doc \ - " (field " #field " of " #tag " " prefix " VSL tag)." \ + " (field " #fld " of " #tg " " prefix " VSL tag)." \ ) #include "varnishhist_profiles.h" #undef HIS_NO_PREFIX diff --git a/bin/varnishlog/flint.lnt b/bin/varnishlog/flint.lnt index 7d06a3e..5600f42 100644 --- a/bin/varnishlog/flint.lnt +++ b/bin/varnishlog/flint.lnt @@ -2,7 +2,6 @@ -e747 // 16 Info 747 Significant prototype coercion (___) ___ to ___ -e763 // Redundant declaration for symbol '...' previously declared --e716 // while(1) ... -efile(451, "varnishlog_options.h") diff --git a/bin/varnishncsa/flint.lnt b/bin/varnishncsa/flint.lnt index f9fb415..d2a0b91 100644 --- a/bin/varnishncsa/flint.lnt +++ b/bin/varnishncsa/flint.lnt @@ -4,9 +4,6 @@ -efile(451, "varnishncsa_options.h") -e763 // Redundant declaration for symbol '...' previously declared --e726 // Extraneous comma ignored --e716 // while(1) ... --e785 // Too few initializers for aggregate // cache_vcl.c -e641 // Converting enum 'cli_status_e' to int diff --git a/bin/varnishncsa/varnishncsa.c b/bin/varnishncsa/varnishncsa.c index 2a94519..65ed5c5 100644 --- a/bin/varnishncsa/varnishncsa.c +++ b/bin/varnishncsa/varnishncsa.c @@ -70,7 +70,6 @@ static const char progname[] = "varnishncsa"; struct format; -struct fragment; enum e_frag { F_H, /* %H Proto */ diff --git a/bin/varnishstat/flint.lnt b/bin/varnishstat/flint.lnt index eaa89be..45b5b0e 100644 --- a/bin/varnishstat/flint.lnt +++ b/bin/varnishstat/flint.lnt @@ -9,7 +9,6 @@ -e747 // 16 Info 747 Significant prototype coercion (___) ___ to ___ -e763 // Redundant declaration for symbol '...' previously declared --e716 // while(1) ... -e457 // unprotected write access -e459 // unprotected access diff --git a/bin/varnishtest/flint.lnt b/bin/varnishtest/flint.lnt index 6e82dd6..786b758 100644 --- a/bin/varnishtest/flint.lnt +++ b/bin/varnishtest/flint.lnt @@ -20,7 +20,6 @@ -e679 // Suspicious Truncation in arithmetic expression combining with pointer -e763 // Redundant declaration for symbol '...' previously declared --e716 // while(1) ... -e457 // unprotected write access -e459 // unprotected access diff --git a/bin/varnishtest/vtc_main.c b/bin/varnishtest/vtc_main.c index b84b40f..9b60ba4 100644 --- a/bin/varnishtest/vtc_main.c +++ b/bin/varnishtest/vtc_main.c @@ -51,7 +51,6 @@ #include "vnum.h" #include "vqueue.h" #include "vrnd.h" -#include "vsa.h" #include "vss.h" #include "vsub.h" #include "vtcp.h" diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c index d20e82a..f098ef8 100644 --- a/bin/varnishtest/vtc_varnish.c +++ b/bin/varnishtest/vtc_varnish.c @@ -50,7 +50,6 @@ #include "vapi/vsm.h" #include "vcli.h" #include "vre.h" -#include "vss.h" #include "vsub.h" #include "vtcp.h" #include "vtim.h" diff --git a/bin/varnishtop/flint.lnt b/bin/varnishtop/flint.lnt index 4920e47..a91f0a3 100644 --- a/bin/varnishtop/flint.lnt +++ b/bin/varnishtop/flint.lnt @@ -3,7 +3,6 @@ -e747 // 16 Info 747 Significant prototype coercion (___) ___ to ___ -e763 // Redundant declaration for symbol '...' previously declared --e716 // while(1) ... -e457 // unprotected write access -e459 // unprotected access diff --git a/bin/varnishtop/varnishtop.c b/bin/varnishtop/varnishtop.c index 6af08a1..af486a7 100644 --- a/bin/varnishtop/varnishtop.c +++ b/bin/varnishtop/varnishtop.c @@ -78,7 +78,7 @@ static pthread_mutex_t mtx = PTHREAD_MUTEX_INITIALIZER; static int f_flag = 0; static unsigned maxfieldlen = 0; -volatile sig_atomic_t quit = 0; +static volatile sig_atomic_t quit = 0; static VRB_HEAD(t_order, top) h_order = VRB_INITIALIZER(&h_order); static VRB_HEAD(t_key, top) h_key = VRB_INITIALIZER(&h_key); diff --git a/flint.lnt b/flint.lnt index 43917a9..35d7f0e 100644 --- a/flint.lnt +++ b/flint.lnt @@ -19,10 +19,12 @@ /////////////////////////////////////////////////////////////////////// // General stylistic issues -e641 // Converting enum '...' to int +-e716 // while(1) ... -e726 // Extraneous comma ignored -e728 // Symbol ... not explicitly initialized -e763 // Redundant declaration for symbol '...' previously declared -e777 // Testing floats for equality +-e785 // Too few initializers for aggregate -e786 // String concatenation within initializer -esym(818, argv) // Pointer parameter '...' could be declared as pointing to const @@ -121,11 +123,20 @@ -emacro(740, VTAILQ_LAST) // Unusual pointer cast (incompatible indirect types) -emacro(740, VTAILQ_PREV) // Unusual pointer cast (incompatible indirect types) +-esym(754, "*::vtqh_first") // local struct member '...' not referenced + /////////////////////////////////////////////////////////////////////// // -emacro(527, NEEDLESS) // unreachable code /////////////////////////////////////////////////////////////////////// +// + +-esym(765, vsl_vbm_bitclr) +-esym(765, vsl_vbm_bitset) +-esym(765, vsm_diag) + +/////////////////////////////////////////////////////////////////////// // It is ok to default after handling a few select SLT_* tags -esym(788, VSL_tag_e::SLT_*) // enum constant '...' not used within defaulted switch diff --git a/lib/libvarnish/flint.lnt b/lib/libvarnish/flint.lnt index 2ac9733..f246d5c 100644 --- a/lib/libvarnish/flint.lnt +++ b/lib/libvarnish/flint.lnt @@ -26,9 +26,6 @@ -ffc // No automatic custody -e763 // Redundant declaration for symbol '...' previously declared --e726 // Extraneous comma ignored --e716 // while(1) ... --e785 // Too few initializers for aggregate -esym(534, sprintf) // Ignoring return value of function -esym(534, asprintf) // Ignoring return value of function diff --git a/lib/libvarnishapi/daemon.c b/lib/libvarnishapi/daemon.c index 33b8552..feb7924 100644 --- a/lib/libvarnishapi/daemon.c +++ b/lib/libvarnishapi/daemon.c @@ -68,7 +68,7 @@ varnish_daemon(int nochdir, int noclose) int osa_ok; /* A SIGHUP may be thrown when the parent exits below. */ - sigemptyset(&sa.sa_mask); + AZ(sigemptyset(&sa.sa_mask)); sa.sa_handler = SIG_IGN; sa.sa_flags = 0; osa_ok = sigaction(SIGHUP, &sa, &osa); @@ -89,7 +89,7 @@ varnish_daemon(int nochdir, int noclose) newgrp = setsid(); oerrno = errno; if (osa_ok != -1) - sigaction(SIGHUP, &osa, NULL); + AZ(sigaction(SIGHUP, &osa, NULL)); if (newgrp == -1) { errno = oerrno; diff --git a/lib/libvarnishapi/vsc.c b/lib/libvarnishapi/vsc.c index 74c567e..5165620 100644 --- a/lib/libvarnishapi/vsc.c +++ b/lib/libvarnishapi/vsc.c @@ -378,7 +378,7 @@ vsc_filter_pt_list(struct VSM_data *vd) VSB_printf(vsb, "%s.", pt->point.section->ident); VSB_printf(vsb, "%s", pt->point.desc->name); - VSB_finish(vsb); + AZ(VSB_finish(vsb)); if (fnmatch(sf->pattern, VSB_data(vsb), 0)) continue; VTAILQ_REMOVE(&vsc->pt_list, pt, list); diff --git a/lib/libvarnishapi/vsl.c b/lib/libvarnishapi/vsl.c index a6e0f21..f1b1846 100644 --- a/lib/libvarnishapi/vsl.c +++ b/lib/libvarnishapi/vsl.c @@ -418,7 +418,7 @@ VSL_WriteOpen(struct VSL_data *vsl, const char *name, int append, int unbuf) if (0 == ftell(f)) { if (fwrite(head, 1, sizeof head, f) != sizeof head) { vsl_diag(vsl, "%s", strerror(errno)); - fclose(f); + (void)fclose(f); return (NULL); } } diff --git a/lib/libvarnishapi/vsl_api.h b/lib/libvarnishapi/vsl_api.h index c77ba28..8aef719 100644 --- a/lib/libvarnishapi/vsl_api.h +++ b/lib/libvarnishapi/vsl_api.h @@ -32,8 +32,7 @@ #define VSL_FILE_ID "VSL" /*lint -esym(534, vsl_diag) */ -int vsl_diag(struct VSL_data *vsl, const char *fmt, ...) - __v_printflike(2, 3); +int vsl_diag(struct VSL_data *vsl, const char *fmt, ...) __v_printflike(2, 3); void vsl_vbm_bitset(int bit, void *priv); void vsl_vbm_bitclr(int bit, void *priv); diff --git a/lib/libvcc/flint.lnt b/lib/libvcc/flint.lnt index 50a8868..7160b2e 100644 --- a/lib/libvcc/flint.lnt +++ b/lib/libvcc/flint.lnt @@ -26,7 +26,6 @@ -esym(534, vsb_vprintf) // Ignoring return value of function -esym(534, memset) // Ignoring return value of function -e788 // enum constant 'HND_Unclass' not used within defaulted switch --e716 // while(1) ... -e732 // Loss of sign (arg. no. 2) (int to unsigned int) -emacro(835, EXPR_VAR) // // Info 835: A zero has been given as right argument to operator '<<' diff --git a/lib/libvmod_directors/shard_dir.c b/lib/libvmod_directors/shard_dir.c index 90a35fa..aa56483 100644 --- a/lib/libvmod_directors/shard_dir.c +++ b/lib/libvmod_directors/shard_dir.c @@ -209,7 +209,7 @@ sharddir_delete(struct sharddir **sharddp) FREE_OBJ(shardd); } -void +static void sharddir_rdlock(struct sharddir *shardd) { CHECK_OBJ_NOTNULL(shardd, SHARDDIR_MAGIC); diff --git a/lib/libvmod_directors/shard_dir.h b/lib/libvmod_directors/shard_dir.h index de35c41..35a947c 100644 --- a/lib/libvmod_directors/shard_dir.h +++ b/lib/libvmod_directors/shard_dir.h @@ -105,7 +105,6 @@ void sharddir_debug(struct sharddir *shardd, const uint32_t flags); void sharddir_err(VRT_CTX, enum VSL_tag_e tag, const char *fmt, ...); void sharddir_new(struct sharddir **sharddp, const char *vcl_name); void sharddir_delete(struct sharddir **sharddp); -void sharddir_rdlock(struct sharddir *shardd); void sharddir_wrlock(struct sharddir *shardd); void sharddir_unlock(struct sharddir *shardd); VCL_BACKEND sharddir_pick_be(VRT_CTX, struct sharddir *, uint32_t, VCL_INT, From hermunn at varnish-software.com Wed Apr 26 13:19:05 2017 From: hermunn at varnish-software.com (Pål Hermunn Johansen) Date: Wed, 26 Apr 2017 15:19:05 +0200 Subject: [4.1] 38c3e74 Update changelog Message-ID: commit 38c3e74df4138d06644223982be4ce33c8a7b5c9 Author: Denes Matetelki Date: Wed Apr 26 14:20:25 2017 +0200 Update changelog diff --git a/doc/changes.rst b/doc/changes.rst index 5422367..eafaaf7 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -17,8 +17,13 @@ Bugs fixed * 2241_ - VSL fails to get hold of SHM * 2270_ - Newly loaded auto VCLs don't get their go_cold timer set * 2273_ - Master cooling problem +* 2275_ - If the client workspace is almost, but not quite exhaused, we may + not be able to get enough iovec's to do Chunked transmission. * 2295_ - Spinning loop in VBE_Poll causes master to kill child on CLI timeout +* 2301_ - Don't attempt to check if varnishd is still running if we have + already failed. +* 2313_ - Cannot link to varnishapi, symbols missing .. _2200: https://github.com/varnishcache/varnish-cache/issues/2200 .. _2216: https://github.com/varnishcache/varnish-cache/pull/2216 @@ -26,7 +31,10 @@ Bugs fixed .. _2241: https://github.com/varnishcache/varnish-cache/issues/2241 .. _2270: https://github.com/varnishcache/varnish-cache/issues/2270 .. _2273: https://github.com/varnishcache/varnish-cache/pull/2273 +.. _2275: https://github.com/varnishcache/varnish-cache/issues/2275 .. _2295: https://github.com/varnishcache/varnish-cache/issues/2295 +.. _2301: https://github.com/varnishcache/varnish-cache/issues/2301 +.. _2313: https://github.com/varnishcache/varnish-cache/issues/2313 ================================ Varnish Cache 4.1.5 (2017-02-09) From hermunn at varnish-software.com Wed Apr 26 13:19:06 2017 From: hermunn at varnish-software.com (Pål Hermunn Johansen) Date: Wed, 26 Apr 2017 15:19:06 +0200 Subject: [4.1] 5ba741b Prepare for 4.1.6 release Message-ID: commit 5ba741bab7af3d2d2bdc3e8ab0547d201541d256 Author: P?l Hermunn Johansen Date: Wed Apr 26 15:04:23 2017 +0200 Prepare for 4.1.6 release diff --git a/configure.ac b/configure.ac index 03412cd..ecf8530 100644 --- a/configure.ac +++ b/configure.ac @@ -2,7 +2,7 @@ AC_PREREQ(2.59) AC_COPYRIGHT([Copyright (c) 2006 Verdens Gang AS Copyright (c) 2006-2016 Varnish Software]) AC_REVISION([$Id$]) -AC_INIT([Varnish], [4.1.5], [varnish-dev at varnish-cache.org]) +AC_INIT([Varnish], [4.1.6], [varnish-dev at varnish-cache.org]) AC_CONFIG_SRCDIR(include/miniobj.h) AC_CONFIG_HEADERS([config.h]) AC_CONFIG_MACRO_DIR([m4]) diff --git a/doc/changes.rst b/doc/changes.rst index eafaaf7..83b93ab 100644 --- a/doc/changes.rst +++ b/doc/changes.rst @@ -1,6 +1,6 @@ -====================================== -Varnish Cache 4.1.6-beta1 (unreleased) -====================================== +================================ +Varnish Cache 4.1.6 (2017-04-26) +================================ * Introduce a vxid left hand side for VSL queries. This allows matching on records matching a known vxid. From phk at FreeBSD.org Wed Apr 26 13:21:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 26 Apr 2017 15:21:05 +0200 Subject: [master] f183416 Flexelint (neuter thread/lock diags centrally) Message-ID: commit f183416a4f9f9b4a6e94353afb4dd81bca58a3af Author: Poul-Henning Kamp Date: Wed Apr 26 13:20:16 2017 +0000 Flexelint (neuter thread/lock diags centrally) diff --git a/bin/varnishd/flint.lnt b/bin/varnishd/flint.lnt index 5432486..e6eac30 100644 --- a/bin/varnishd/flint.lnt +++ b/bin/varnishd/flint.lnt @@ -55,10 +55,6 @@ //-sem (pthread_mutex_lock, thread_lock) -sem (pthread_mutex_trylock, thread_lock) -sem (VBE_DropRefLocked, thread_unlock) --e454 // mutex not released (...ReleaseLocked) --e457 // unprotected access - --esym(458, params) // unlocked access -emacro(835, HCB_BIT_NODE) // Info 835: A zero has been given as left argument to operator '<<' -emacro(835, VBC_STATE_AVAIL) // Info 835: A zero has been given as left argument to operator '<<' @@ -80,8 +76,6 @@ -efile(451, "symbol_kind.h") // No include guard -efile(451, "config.h") // No include guard ////////////// -// -e458 // unprotected access -// -e456 // merged locking paths -sem(vca_thread_acct, thread_mono) -sem(vca_epoll_thread, thread_mono) -sem(vca_kqueue_thread, thread_mono) @@ -90,8 +84,6 @@ -sem(exp_timer, thread_mono) -sem(wrk_herdtimer_thread, thread_mono) -sem(wrk_herder_thread, thread_mono) --esym(458, heritage) --esym(458, name_key) ////////////// // 436 = Apparent preprocessor directive in invocation of macro '___' @@ -113,8 +105,6 @@ -sem(vdi_dns_cache_list_add, custodial(3)) --e455 // thread lock --e458 // unprotected read -e717 // do ... while(1) ... -e850 // for loop index variable '___' whose type category is '___' // is modified in body of the for loop that began at '___' diff --git a/bin/varnishlog/flint.lnt b/bin/varnishlog/flint.lnt index 5600f42..518e640 100644 --- a/bin/varnishlog/flint.lnt +++ b/bin/varnishlog/flint.lnt @@ -5,10 +5,6 @@ -efile(451, "varnishlog_options.h") --e457 // unprotected write access --e459 // unprotected access --e458 // unprotected access - -e732 // Loss of sign (arg. no. 2) (int to unsigned -e737 // [45] Loss of sign in promotion from int to unsigned -e713 // Loss of precision (assignment) (unsigned long long to long long) diff --git a/bin/varnishstat/flint.lnt b/bin/varnishstat/flint.lnt index 45b5b0e..c3971af 100644 --- a/bin/varnishstat/flint.lnt +++ b/bin/varnishstat/flint.lnt @@ -10,10 +10,6 @@ -e763 // Redundant declaration for symbol '...' previously declared --e457 // unprotected write access --e459 // unprotected access --e458 // unprotected access - -e732 // Loss of sign (arg. no. 2) (int to unsigned -e737 // [45] Loss of sign in promotion from int to unsigned -e713 // Loss of precision (assignment) (unsigned long long to long long) diff --git a/bin/varnishtest/flint.lnt b/bin/varnishtest/flint.lnt index 786b758..e3da9d5 100644 --- a/bin/varnishtest/flint.lnt +++ b/bin/varnishtest/flint.lnt @@ -21,9 +21,6 @@ -e763 // Redundant declaration for symbol '...' previously declared --e457 // unprotected write access --e459 // unprotected access --e458 // unprotected access // -e732 // Loss of sign (arg. no. 2) (int to unsigned -e737 // [45] Loss of sign in promotion from int to unsigned diff --git a/bin/varnishtop/flint.lnt b/bin/varnishtop/flint.lnt index a91f0a3..eef5d4d 100644 --- a/bin/varnishtop/flint.lnt +++ b/bin/varnishtop/flint.lnt @@ -4,10 +4,6 @@ -e763 // Redundant declaration for symbol '...' previously declared --e457 // unprotected write access --e459 // unprotected access --e458 // unprotected access - -e732 // Loss of sign (arg. no. 2) (int to unsigned -e737 // [45] Loss of sign in promotion from int to unsigned -e713 // Loss of precision (assignment) (unsigned long long to long long) diff --git a/flint.lnt b/flint.lnt index 35d7f0e..e2c3046 100644 --- a/flint.lnt +++ b/flint.lnt @@ -17,6 +17,15 @@ +libh(../../config.h) /////////////////////////////////////////////////////////////////////// +// Thread/locking, too many false positives still +-e454 // A thread mutex has been locked but not unlocked___ +-e455 // A thread mutex that had not been locked is being unlocked +-e456 // Two execution paths are being combined with different mutex lock states +-e457 // unprotected write access +-e458 // unprotected access +-e459 // unprotected access + +/////////////////////////////////////////////////////////////////////// // General stylistic issues -e641 // Converting enum '...' to int -e716 // while(1) ... From phk at FreeBSD.org Wed Apr 26 19:37:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 26 Apr 2017 21:37:05 +0200 Subject: [master] d5c05a8 Flexelintery Message-ID: commit d5c05a8bc6d7de083fa1df2e0da2304200ceada2 Author: Poul-Henning Kamp Date: Wed Apr 26 19:25:56 2017 +0000 Flexelintery diff --git a/flint.lnt b/flint.lnt index e2c3046..0cea578 100644 --- a/flint.lnt +++ b/flint.lnt @@ -142,8 +142,11 @@ // -esym(765, vsl_vbm_bitclr) +-esym(759, vsl_vbm_bitclr) -esym(765, vsl_vbm_bitset) +-esym(759, vsl_vbm_bitset) -esym(765, vsm_diag) +-esym(759, vsm_diag) /////////////////////////////////////////////////////////////////////// From phk at FreeBSD.org Wed Apr 26 19:37:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 26 Apr 2017 21:37:05 +0200 Subject: [master] 2e610e1 More Flexelintery Message-ID: commit 2e610e1cc5f906f81430350cea44117a9d27ddc9 Author: Poul-Henning Kamp Date: Wed Apr 26 19:36:27 2017 +0000 More Flexelintery diff --git a/bin/varnishd/flint.lnt b/bin/varnishd/flint.lnt index e6eac30..c276b5d 100644 --- a/bin/varnishd/flint.lnt +++ b/bin/varnishd/flint.lnt @@ -136,7 +136,6 @@ // Review all below this line /////////////////////////////////////////////// --e737 // 143 Loss of sign in promotion from ___ to ___ -e713 // 42 Loss of precision (___) (___ to ___) -e574 // 48 Signed-unsigned mix with relational -e840 // Use of nul character in a string literal (see: vcc_if.c) diff --git a/bin/varnishlog/flint.lnt b/bin/varnishlog/flint.lnt index 518e640..d0d1157 100644 --- a/bin/varnishlog/flint.lnt +++ b/bin/varnishlog/flint.lnt @@ -6,7 +6,6 @@ -efile(451, "varnishlog_options.h") -e732 // Loss of sign (arg. no. 2) (int to unsigned --e737 // [45] Loss of sign in promotion from int to unsigned -e713 // Loss of precision (assignment) (unsigned long long to long long) -e574 // Signed-unsigned mix with relational diff --git a/bin/varnishncsa/flint.lnt b/bin/varnishncsa/flint.lnt index d2a0b91..29fa2cd 100644 --- a/bin/varnishncsa/flint.lnt +++ b/bin/varnishncsa/flint.lnt @@ -22,6 +22,5 @@ -e534 // Ignoring return value of function -e557 // unrecog format -e732 // Loss of sign (arg. no. 2) (int to unsigned --e737 // [45] Loss of sign in promotion from int to unsigned -e788 // tag not used in defaulted switch diff --git a/bin/varnishstat/flint.lnt b/bin/varnishstat/flint.lnt index c3971af..7ae5887 100644 --- a/bin/varnishstat/flint.lnt +++ b/bin/varnishstat/flint.lnt @@ -11,7 +11,6 @@ -e763 // Redundant declaration for symbol '...' previously declared -e732 // Loss of sign (arg. no. 2) (int to unsigned --e737 // [45] Loss of sign in promotion from int to unsigned -e713 // Loss of precision (assignment) (unsigned long long to long long) -e574 // Signed-unsigned mix with relational diff --git a/bin/varnishtest/flint.lnt b/bin/varnishtest/flint.lnt index e3da9d5..0c2658c 100644 --- a/bin/varnishtest/flint.lnt +++ b/bin/varnishtest/flint.lnt @@ -23,7 +23,6 @@ // -e732 // Loss of sign (arg. no. 2) (int to unsigned --e737 // [45] Loss of sign in promotion from int to unsigned -e713 // Loss of precision (assignment) (unsigned long long to long long) -e574 // Signed-unsigned mix with relational -emacro(835, STRTOU32_CHECK) // A zero has been given as ___ argument to operator '___' diff --git a/bin/varnishtop/flint.lnt b/bin/varnishtop/flint.lnt index eef5d4d..b5dc5fa 100644 --- a/bin/varnishtop/flint.lnt +++ b/bin/varnishtop/flint.lnt @@ -5,7 +5,6 @@ -e763 // Redundant declaration for symbol '...' previously declared -e732 // Loss of sign (arg. no. 2) (int to unsigned --e737 // [45] Loss of sign in promotion from int to unsigned -e713 // Loss of precision (assignment) (unsigned long long to long long) -e574 // Signed-unsigned mix with relational diff --git a/flint.lnt b/flint.lnt index 0cea578..38a1678 100644 --- a/flint.lnt +++ b/flint.lnt @@ -31,6 +31,7 @@ -e716 // while(1) ... -e726 // Extraneous comma ignored -e728 // Symbol ... not explicitly initialized +-e737 // Loss of sign in promotion from int to unsigned int -e763 // Redundant declaration for symbol '...' previously declared -e777 // Testing floats for equality -e785 // Too few initializers for aggregate diff --git a/lib/libvarnish/flint.lnt b/lib/libvarnish/flint.lnt index f246d5c..b134f47 100644 --- a/lib/libvarnish/flint.lnt +++ b/lib/libvarnish/flint.lnt @@ -59,7 +59,6 @@ // Review all below this line /////////////////////////////////////////////// -e732 // Loss of sign (arg. no. 2) (int to unsigned --e737 // [45] Loss of sign in promotion from int to unsigned -e713 // Loss of precision (assignment) (unsigned long long to long long) -e574 // Signed-unsigned mix with relational -e712 // Loss of precision (assignment) (long long to diff --git a/lib/libvarnishapi/vsl.c b/lib/libvarnishapi/vsl.c index f1b1846..8e803ce 100644 --- a/lib/libvarnishapi/vsl.c +++ b/lib/libvarnishapi/vsl.c @@ -366,8 +366,9 @@ VSL_PrintTransactions(struct VSL_data *vsl, struct VSL_transaction * const pt[], if (t->level > 3) VSL_PRINT(fo, "*%1.1u* ", t->level); else - VSL_PRINT(fo, "%-3.*s ", t->level, "***"); - VSL_PRINT(fo, "%*.s%-14s %*.s%-10u\n", + VSL_PRINT(fo, "%-3.*s ", + (int)(t->level), "***"); + VSL_PRINT(fo, "%*.s%-14s %*.s%-10d\n", verbose ? 10 + 1 : 0, " ", VSL_transactions[t->type], verbose ? 1 + 1 : 0, " ", @@ -387,7 +388,8 @@ VSL_PrintTransactions(struct VSL_data *vsl, struct VSL_transaction * const pt[], if (t->level > 3) VSL_PRINT(fo, "-%1.1u- ", t->level); else if (t->level) - VSL_PRINT(fo, "%-3.*s ", t->level, "---"); + VSL_PRINT(fo, "%-3.*s ", + (int)(t->level), "---"); if (verbose) i = VSL_Print(vsl, t->c, fo); else diff --git a/lib/libvcc/flint.lnt b/lib/libvcc/flint.lnt index 7160b2e..6e346b1 100644 --- a/lib/libvcc/flint.lnt +++ b/lib/libvcc/flint.lnt @@ -33,7 +33,6 @@ -e763 // Redundant declaration for symbol '...' previously declared --e737 // Loss of sign in promotion from int to unsigned int -e534 // Ignoring return value of function -e506 // Constant value boolean -e774 // Boolean within 'if' always evaluates to False From phk at FreeBSD.org Wed Apr 26 20:39:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 26 Apr 2017 22:39:05 +0200 Subject: [master] af0c665 Un-copy&paste the code to compare two strings in expect. Message-ID: commit af0c665e38fb9e20039d43c7b7d1ceba78c2b867 Author: Poul-Henning Kamp Date: Wed Apr 26 20:37:26 2017 +0000 Un-copy&paste the code to compare two strings in expect. diff --git a/bin/varnishtest/flint.lnt b/bin/varnishtest/flint.lnt index 0c2658c..ad1e024 100644 --- a/bin/varnishtest/flint.lnt +++ b/bin/varnishtest/flint.lnt @@ -24,7 +24,6 @@ // -e732 // Loss of sign (arg. no. 2) (int to unsigned -e713 // Loss of precision (assignment) (unsigned long long to long long) --e574 // Signed-unsigned mix with relational -emacro(835, STRTOU32_CHECK) // A zero has been given as ___ argument to operator '___' -e788 // enum value not used in defaulted switch diff --git a/bin/varnishtest/vtc.h b/bin/varnishtest/vtc.h index ba0fb1c..996b199 100644 --- a/bin/varnishtest/vtc.h +++ b/bin/varnishtest/vtc.h @@ -132,3 +132,5 @@ void b64_settings(const struct http *hp, const char *s); /* vtc_subr.c */ struct vsb *vtc_hex_to_bin(struct vtclog *vl, const char *arg); +void vtc_expect(struct vtclog *, const char *, const char *, const char *, + const char *, const char *); diff --git a/bin/varnishtest/vtc_http.c b/bin/varnishtest/vtc_http.c index 557f90f..044581e 100644 --- a/bin/varnishtest/vtc_http.c +++ b/bin/varnishtest/vtc_http.c @@ -46,7 +46,6 @@ #include "vfil.h" #include "vgz.h" #include "vnum.h" -#include "vre.h" #include "vtcp.h" #include "hpack.h" @@ -345,13 +344,9 @@ static void cmd_http_expect(CMD_ARGS) { struct http *hp; - const char *lhs, *clhs; + const char *lhs; char *cmp; - const char *rhs, *crhs; - vre_t *vre; - const char *error; - int erroroffset; - int i, retval = -1; + const char *rhs; (void)cmd; (void)vl; @@ -367,41 +362,7 @@ cmd_http_expect(CMD_ARGS) cmp = av[1]; rhs = cmd_var_resolve(hp, av[2]); - clhs = lhs ? lhs : ""; - crhs = rhs ? rhs : ""; - - if (!strcmp(cmp, "~") || !strcmp(cmp, "!~")) { - vre = VRE_compile(crhs, 0, &error, &erroroffset); - if (vre == NULL) - vtc_fatal(hp->vl, "REGEXP error: %s (@%d) (%s)", - error, erroroffset, crhs); - i = VRE_exec(vre, clhs, strlen(clhs), 0, 0, NULL, 0, 0); - retval = (i >= 0 && *cmp == '~') || (i < 0 && *cmp == '!'); - VRE_free(&vre); - } else if (!strcmp(cmp, "==")) { - retval = strcmp(clhs, crhs) == 0; - } else if (!strcmp(cmp, "!=")) { - retval = strcmp(clhs, crhs) != 0; - } else if (lhs == NULL || rhs == NULL) { - // fail inequality comparisons if either side is undef'ed - retval = 0; - } else if (!strcmp(cmp, "<")) { - retval = isless(VNUM(lhs), VNUM(rhs)); - } else if (!strcmp(cmp, ">")) { - retval = isgreater(VNUM(lhs), VNUM(rhs)); - } else if (!strcmp(cmp, "<=")) { - retval = islessequal(VNUM(lhs), VNUM(rhs)); - } else if (!strcmp(cmp, ">=")) { - retval = isgreaterequal(VNUM(lhs), VNUM(rhs)); - } - - if (retval == -1) - vtc_fatal(hp->vl, - "EXPECT %s (%s) %s %s (%s) test not implemented", - av[0], clhs, av[1], av[2], crhs); - else - vtc_log(hp->vl, retval ? 4 : 0, "EXPECT %s (%s) %s \"%s\" %s", - av[0], clhs, cmp, crhs, retval ? "match" : "failed"); + vtc_expect(vl, av[0], lhs, cmp, av[2], rhs); } static void diff --git a/bin/varnishtest/vtc_http2.c b/bin/varnishtest/vtc_http2.c index 796344e..c0271cb 100644 --- a/bin/varnishtest/vtc_http2.c +++ b/bin/varnishtest/vtc_http2.c @@ -46,8 +46,6 @@ #include "vfil.h" #include "vgz.h" -#include "vnum.h" -#include "vre.h" #include "hpack.h" #include "vend.h" @@ -2412,13 +2410,9 @@ cmd_expect(CMD_ARGS) { struct http *hp; struct stream *s; - const char *lhs, *clhs; + const char *lhs; char *cmp; - const char *rhs, *crhs; - vre_t *vre; - const char *error; - int erroroffset; - int i, retval = -1; + const char *rhs; char buf[20]; (void)cmd; @@ -2437,42 +2431,7 @@ cmd_expect(CMD_ARGS) lhs = cmd_var_resolve(s, av[0], buf); cmp = av[1]; rhs = cmd_var_resolve(s, av[2], buf); - - clhs = lhs ? lhs : ""; - crhs = rhs ? rhs : ""; - - if (!strcmp(cmp, "~") || !strcmp(cmp, "!~")) { - vre = VRE_compile(crhs, 0, &error, &erroroffset); - if (vre == NULL) - vtc_fatal(vl, "REGEXP error: %s (@%d) (%s)", - error, erroroffset, crhs); - i = VRE_exec(vre, clhs, strlen(clhs), 0, 0, NULL, 0, 0); - retval = (i >= 0 && *cmp == '~') || (i < 0 && *cmp == '!'); - VRE_free(&vre); - } else if (!strcmp(cmp, "==")) { - retval = strcmp(clhs, crhs) == 0; - } else if (!strcmp(cmp, "!=")) { - retval = strcmp(clhs, crhs) != 0; - } else if (lhs == NULL || rhs == NULL) { - // fail inequality comparisons if either side is undef'ed - retval = 0; - } else if (!strcmp(cmp, "<")) { - retval = isless(VNUM(lhs), VNUM(rhs)); - } else if (!strcmp(cmp, ">")) { - retval = isgreater(VNUM(lhs), VNUM(rhs)); - } else if (!strcmp(cmp, "<=")) { - retval = islessequal(VNUM(lhs), VNUM(rhs)); - } else if (!strcmp(cmp, ">=")) { - retval = isgreaterequal(VNUM(lhs), VNUM(rhs)); - } - - if (retval == -1) - vtc_fatal(vl, - "EXPECT %s (%s) %s %s (%s) test not implemented", - av[0], clhs, av[1], av[2], crhs); - else - vtc_log(vl, retval ? 4 : 0, "(s%d) EXPECT %s (%s) %s \"%s\" %s", - s->id, av[0], clhs, cmp, crhs, retval ? "match" : "failed"); + vtc_expect(vl, av[0], lhs, cmp, av[2], rhs); AZ(pthread_mutex_unlock(&s->hp->mtx)); } diff --git a/bin/varnishtest/vtc_subr.c b/bin/varnishtest/vtc_subr.c index a898b12..c992cd9 100644 --- a/bin/varnishtest/vtc_subr.c +++ b/bin/varnishtest/vtc_subr.c @@ -28,11 +28,14 @@ #include "config.h" +#include +#include #include -#include "vtc.h" - #include "vct.h" +#include "vnum.h" +#include "vre.h" +#include "vtc.h" struct vsb * vtc_hex_to_bin(struct vtclog *vl, const char *arg) @@ -66,3 +69,61 @@ vtc_hex_to_bin(struct vtclog *vl, const char *arg) AZ(VSB_finish(vsb)); return (vsb); } + +void +vtc_expect(struct vtclog *vl, + const char *olhs, const char *lhs, + const char *cmp, + const char *orhs, const char *rhs) +{ + vre_t *vre; + const char *error; + int erroroffset; + int i, j, retval = -1; + double fl, fr; + + j = lhs == NULL || rhs == NULL; + if (lhs == NULL) + lhs = ""; + if (rhs == NULL) + rhs = ""; + + if (!strcmp(cmp, "~") || !strcmp(cmp, "!~")) { + vre = VRE_compile(rhs, 0, &error, &erroroffset); + if (vre == NULL) + vtc_fatal(vl, "REGEXP error: %s (@%d) (%s)", + error, erroroffset, rhs); + i = VRE_exec(vre, lhs, strlen(lhs), 0, 0, NULL, 0, 0); + retval = (i >= 0 && *cmp == '~') || (i < 0 && *cmp == '!'); + VRE_free(&vre); + } else if (!strcmp(cmp, "==")) { + retval = strcmp(lhs, rhs) == 0; + } else if (!strcmp(cmp, "!=")) { + retval = strcmp(lhs, rhs) != 0; + } else if (j) { + // fail inequality comparisons if either side is undef'ed + retval = 0; + } else { + fl = VNUM(lhs); + fr = VNUM(rhs); + if (!strcmp(cmp, "<")) + retval = isless(fl, fr); + else if (!strcmp(cmp, ">")) + retval = isgreater(fl, fr); + else if (!strcmp(cmp, "<=")) + retval = islessequal(fl, fr); + else if (!strcmp(cmp, ">=")) + retval = isgreaterequal(fl, fr); + } + + if (retval == -1) + vtc_fatal(vl, + "EXPECT %s (%s) %s %s (%s) test not implemented", + olhs, lhs, cmp, orhs, rhs); + else if (retval == 0) + vtc_fatal(vl, "EXPECT %s (%s) %s \"%s\" failed", + olhs, lhs, cmp, rhs); + else + vtc_log(vl, 4, "EXPECT %s (%s) %s \"%s\" match", + olhs, lhs, cmp, rhs); +} From phk at FreeBSD.org Wed Apr 26 20:39:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 26 Apr 2017 22:39:05 +0200 Subject: [master] fb2a191 More FlexeLinting Message-ID: commit fb2a19197b4aca2bfea0f8a7b921e03d5a977efe Author: Poul-Henning Kamp Date: Wed Apr 26 20:37:58 2017 +0000 More FlexeLinting diff --git a/bin/varnishd/flint.lnt b/bin/varnishd/flint.lnt index c276b5d..3643b1b 100644 --- a/bin/varnishd/flint.lnt +++ b/bin/varnishd/flint.lnt @@ -137,7 +137,6 @@ // Review all below this line /////////////////////////////////////////////// -e713 // 42 Loss of precision (___) (___ to ___) --e574 // 48 Signed-unsigned mix with relational -e840 // Use of nul character in a string literal (see: vcc_if.c) -e663 // Suspicious array to pointer conversion -e778 // Constant expression evaluates to 0 in operation '___' diff --git a/bin/varnishlog/flint.lnt b/bin/varnishlog/flint.lnt index d0d1157..509f2fe 100644 --- a/bin/varnishlog/flint.lnt +++ b/bin/varnishlog/flint.lnt @@ -7,7 +7,6 @@ -e732 // Loss of sign (arg. no. 2) (int to unsigned -e713 // Loss of precision (assignment) (unsigned long long to long long) --e574 // Signed-unsigned mix with relational -e788 // enum constant '___' not used within defaulted switch -e641 // Converting enum '___' to '___' diff --git a/bin/varnishncsa/flint.lnt b/bin/varnishncsa/flint.lnt index 29fa2cd..ac808d4 100644 --- a/bin/varnishncsa/flint.lnt +++ b/bin/varnishncsa/flint.lnt @@ -12,7 +12,6 @@ -e767 // Macro redef (system queue.h vs ours ) --e574 // Signed-unsigned mix with relational -e712 // Loss of precision (assignment) (long long to -e747 // Significant prototype coercion (arg. no. 2) long -e713 // Loss of precision (assignment) (unsigned long long to long long) diff --git a/bin/varnishstat/flint.lnt b/bin/varnishstat/flint.lnt index 7ae5887..b3d6bb7 100644 --- a/bin/varnishstat/flint.lnt +++ b/bin/varnishstat/flint.lnt @@ -12,7 +12,6 @@ -e732 // Loss of sign (arg. no. 2) (int to unsigned -e713 // Loss of precision (assignment) (unsigned long long to long long) --e574 // Signed-unsigned mix with relational /////////////////////////////////////////////////////////////////////// // Varnishstat specific diff --git a/bin/varnishtop/flint.lnt b/bin/varnishtop/flint.lnt index b5dc5fa..aa3e9eb 100644 --- a/bin/varnishtop/flint.lnt +++ b/bin/varnishtop/flint.lnt @@ -6,7 +6,6 @@ -e732 // Loss of sign (arg. no. 2) (int to unsigned -e713 // Loss of precision (assignment) (unsigned long long to long long) --e574 // Signed-unsigned mix with relational /////////////////////////////////////////////////////////////////////// // Varnishstat specific diff --git a/flint.lnt b/flint.lnt index 38a1678..364ede9 100644 --- a/flint.lnt +++ b/flint.lnt @@ -27,6 +27,7 @@ /////////////////////////////////////////////////////////////////////// // General stylistic issues +-e574 // Signed-unsigned mix with relational -e641 // Converting enum '...' to int -e716 // while(1) ... -e726 // Extraneous comma ignored diff --git a/include/miniobj.h b/include/miniobj.h index 8186b9b..13aa3a6 100644 --- a/include/miniobj.h +++ b/include/miniobj.h @@ -75,9 +75,10 @@ #define REPLACE(ptr, val) \ do { \ + const char *_vreplace = (val); \ free(ptr); \ - if ((val) != NULL) { \ - ptr = strdup(val); \ + if (_vreplace != NULL) { \ + ptr = strdup(_vreplace); \ AN((ptr)); \ } else { \ ptr = NULL; \ diff --git a/lib/libvarnish/flint.lnt b/lib/libvarnish/flint.lnt index b134f47..cc5a375 100644 --- a/lib/libvarnish/flint.lnt +++ b/lib/libvarnish/flint.lnt @@ -60,7 +60,6 @@ -e732 // Loss of sign (arg. no. 2) (int to unsigned -e713 // Loss of precision (assignment) (unsigned long long to long long) --e574 // Signed-unsigned mix with relational -e712 // Loss of precision (assignment) (long long to -e747 // Significant prototype coercion (arg. no. 2) long diff --git a/lib/libvarnishapi/vsl.c b/lib/libvarnishapi/vsl.c index 8e803ce..207a862 100644 --- a/lib/libvarnishapi/vsl.c +++ b/lib/libvarnishapi/vsl.c @@ -172,7 +172,7 @@ vsl_match_IX(struct VSL_data *vsl, const vslf_list *list, const struct vslf *vslf; (void)vsl; - tag = VSL_TAG(c->rec.ptr); + tag = (enum VSL_tag_e)VSL_TAG(c->rec.ptr); cdata = VSL_CDATA(c->rec.ptr); len = VSL_LEN(c->rec.ptr); @@ -194,7 +194,7 @@ VSL_Match(struct VSL_data *vsl, const struct VSL_cursor *c) CHECK_OBJ_NOTNULL(vsl, VSL_MAGIC); if (c == NULL || c->rec.ptr == NULL) return (0); - tag = VSL_TAG(c->rec.ptr); + tag = (enum VSL_tag_e)VSL_TAG(c->rec.ptr); if (tag <= SLT__Bogus || tag >= SLT__Reserved) return (0); if (vsl->c_opt && !VSL_CLIENT(c->rec.ptr)) @@ -245,7 +245,7 @@ VSL_Print(const struct VSL_data *vsl, const struct VSL_cursor *c, void *fo) return (0); if (fo == NULL) fo = stdout; - tag = VSL_TAG(c->rec.ptr); + tag = (enum VSL_tag_e)VSL_TAG(c->rec.ptr); vxid = VSL_ID(c->rec.ptr); len = VSL_LEN(c->rec.ptr); type = VSL_CLIENT(c->rec.ptr) ? 'c' : VSL_BACKEND(c->rec.ptr) ? @@ -283,7 +283,7 @@ VSL_PrintTerse(const struct VSL_data *vsl, const struct VSL_cursor *c, void *fo) return (0); if (fo == NULL) fo = stdout; - tag = VSL_TAG(c->rec.ptr); + tag = (enum VSL_tag_e)VSL_TAG(c->rec.ptr); len = VSL_LEN(c->rec.ptr); data = VSL_CDATA(c->rec.ptr); diff --git a/lib/libvarnishapi/vsl_dispatch.c b/lib/libvarnishapi/vsl_dispatch.c index 57a416a..a93df10 100644 --- a/lib/libvarnishapi/vsl_dispatch.c +++ b/lib/libvarnishapi/vsl_dispatch.c @@ -859,7 +859,7 @@ vtx_scan(struct VSLQ *vslq, struct vtx *vtx) continue; } - tag = VSL_TAG(ptr); + tag = (enum VSL_tag_e)VSL_TAG(ptr); assert(tag != SLT__Batch); switch (tag) { @@ -1247,14 +1247,14 @@ vslq_next(struct VSLQ *vslq) if (i != 1) return (i); - tag = VSL_TAG(c->rec.ptr); + tag = (enum VSL_tag_e)VSL_TAG(c->rec.ptr); if (tag == SLT__Batch) { vxid = VSL_BATCHID(c->rec.ptr); len = VSL_END(c->rec.ptr, VSL_BATCHLEN(c->rec.ptr)) - c->rec.ptr; if (len == 0) return (i); - tag = VSL_TAG(VSL_NEXT(c->rec.ptr)); + tag = (enum VSL_tag_e)VSL_TAG(VSL_NEXT(c->rec.ptr)); } else { vxid = VSL_ID(c->rec.ptr); len = VSL_NEXT(c->rec.ptr) - c->rec.ptr; diff --git a/lib/libvcc/flint.lnt b/lib/libvcc/flint.lnt index 6e346b1..6b931e0 100644 --- a/lib/libvcc/flint.lnt +++ b/lib/libvcc/flint.lnt @@ -37,7 +37,6 @@ -e506 // Constant value boolean -e774 // Boolean within 'if' always evaluates to False -e713 // Loss of precision (assignment) (unsigned long long to long long) --e574 // Signed-unsigned mix with relational -e539 // Did not expect positive indentation -e734 // Loss of precision (assignment) (31 bits to 8 bits) -e747 // Significant prototype coercion (arg. no. 2) long From fgsch at lodoss.net Wed Apr 26 23:40:05 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Thu, 27 Apr 2017 01:40:05 +0200 Subject: [master] f85fcc5 Add missing header Message-ID: commit f85fcc5132728888583e5ace139aeb695f381a96 Author: Federico G. Schwindt Date: Wed Apr 26 16:39:12 2017 -0700 Add missing header diff --git a/bin/varnishtest/vtc_subr.c b/bin/varnishtest/vtc_subr.c index c992cd9..eb6223f 100644 --- a/bin/varnishtest/vtc_subr.c +++ b/bin/varnishtest/vtc_subr.c @@ -28,9 +28,10 @@ #include "config.h" +#include #include #include -#include +#include #include "vct.h" #include "vnum.h" From phk at FreeBSD.org Thu Apr 27 06:40:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 27 Apr 2017 08:40:05 +0200 Subject: [master] a7baa5c Add missing includes of config.h Message-ID: commit a7baa5ce317c006682acddc369806cfa13073d34 Author: Poul-Henning Kamp Date: Thu Apr 27 06:15:40 2017 +0000 Add missing includes of config.h diff --git a/bin/varnishd/common/common_vsc.c b/bin/varnishd/common/common_vsc.c index 6981ef1..c064f73 100644 --- a/bin/varnishd/common/common_vsc.c +++ b/bin/varnishd/common/common_vsc.c @@ -28,6 +28,8 @@ * */ +#include "config.h" + #include "common.h" /* Build the static vsc type names */ diff --git a/bin/varnishd/hpack/vhp_decode.c b/bin/varnishd/hpack/vhp_decode.c index 3fa4b5e..328d197 100644 --- a/bin/varnishd/hpack/vhp_decode.c +++ b/bin/varnishd/hpack/vhp_decode.c @@ -28,6 +28,8 @@ * */ +#include "config.h" + #include #include #include diff --git a/bin/varnishd/hpack/vhp_table.c b/bin/varnishd/hpack/vhp_table.c index d37fa69..3357844 100644 --- a/bin/varnishd/hpack/vhp_table.c +++ b/bin/varnishd/hpack/vhp_table.c @@ -25,9 +25,6 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - */ - -/* * Layout: * * buf [ @@ -46,6 +43,8 @@ * */ +#include "config.h" + #include #include #include diff --git a/bin/varnishtest/vtc_proxy.c b/bin/varnishtest/vtc_proxy.c index e61658c..b1a6b05 100644 --- a/bin/varnishtest/vtc_proxy.c +++ b/bin/varnishtest/vtc_proxy.c @@ -26,6 +26,8 @@ * SUCH DAMAGE. */ +#include "config.h" + #include #include diff --git a/lib/libvarnishapi/vsl_cursor.c b/lib/libvarnishapi/vsl_cursor.c index 2348ad9..0285df3 100644 --- a/lib/libvarnishapi/vsl_cursor.c +++ b/lib/libvarnishapi/vsl_cursor.c @@ -29,6 +29,8 @@ * */ +#include "config.h" + #include #include #include diff --git a/lib/libvarnishapi/vsl_dispatch.c b/lib/libvarnishapi/vsl_dispatch.c index a93df10..e1d633c 100644 --- a/lib/libvarnishapi/vsl_dispatch.c +++ b/lib/libvarnishapi/vsl_dispatch.c @@ -28,6 +28,8 @@ * */ +#include "config.h" + #include #include #include diff --git a/lib/libvarnishapi/vsl_query.c b/lib/libvarnishapi/vsl_query.c index dd69eec..79a9f66 100644 --- a/lib/libvarnishapi/vsl_query.c +++ b/lib/libvarnishapi/vsl_query.c @@ -28,6 +28,8 @@ * */ +#include "config.h" + #include #include #include From phk at FreeBSD.org Thu Apr 27 06:40:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 27 Apr 2017 08:40:05 +0200 Subject: [master] 3d60db6 Sort out some signed/unsigned mismatches Message-ID: commit 3d60db6b8ec5de2337e52b73163305ae7c5c0094 Author: Poul-Henning Kamp Date: Thu Apr 27 06:39:42 2017 +0000 Sort out some signed/unsigned mismatches diff --git a/include/vapi/vsl.h b/include/vapi/vsl.h index c6afb2f..03d98d7 100644 --- a/include/vapi/vsl.h +++ b/include/vapi/vsl.h @@ -110,8 +110,8 @@ enum VSL_reason_e { struct VSL_transaction { unsigned level; - int32_t vxid; - int32_t vxid_parent; + uint32_t vxid; + uint32_t vxid_parent; enum VSL_transaction_e type; enum VSL_reason_e reason; struct VSL_cursor *c; diff --git a/include/vre.h b/include/vre.h index f19ff2c..8062a3a 100644 --- a/include/vre.h +++ b/include/vre.h @@ -52,7 +52,7 @@ extern const unsigned VRE_has_jit; extern const unsigned VRE_CASELESS; extern const unsigned VRE_NOTEMPTY; -vre_t *VRE_compile(const char *, int, const char **, int *); +vre_t *VRE_compile(const char *, unsigned, const char **, int *); int VRE_exec(const vre_t *code, const char *subject, int length, int startoffset, int options, int *ovector, int ovecsize, const volatile struct vre_limits *lim); diff --git a/lib/libvarnish/vre.c b/lib/libvarnish/vre.c index b625566..61469d1 100644 --- a/lib/libvarnish/vre.c +++ b/lib/libvarnish/vre.c @@ -65,7 +65,7 @@ const unsigned VRE_CASELESS = PCRE_CASELESS; const unsigned VRE_NOTEMPTY = PCRE_NOTEMPTY; vre_t * -VRE_compile(const char *pattern, int options, +VRE_compile(const char *pattern, unsigned options, const char **errptr, int *erroffset) { vre_t *v; diff --git a/lib/libvarnishapi/vsl.c b/lib/libvarnishapi/vsl.c index 207a862..b418c64 100644 --- a/lib/libvarnishapi/vsl.c +++ b/lib/libvarnishapi/vsl.c @@ -368,7 +368,7 @@ VSL_PrintTransactions(struct VSL_data *vsl, struct VSL_transaction * const pt[], else VSL_PRINT(fo, "%-3.*s ", (int)(t->level), "***"); - VSL_PRINT(fo, "%*.s%-14s %*.s%-10d\n", + VSL_PRINT(fo, "%*.s%-14s %*.s%-10u\n", verbose ? 10 + 1 : 0, " ", VSL_transactions[t->type], verbose ? 1 + 1 : 0, " ", diff --git a/lib/libvarnishapi/vsl_cursor.c b/lib/libvarnishapi/vsl_cursor.c index 0285df3..c90f93d 100644 --- a/lib/libvarnishapi/vsl_cursor.c +++ b/lib/libvarnishapi/vsl_cursor.c @@ -318,7 +318,7 @@ vslc_file_delete(const struct VSL_cursor *cursor) static ssize_t vslc_file_readn(int fd, void *buf, size_t n) { - size_t t = 0; + ssize_t t = 0; ssize_t l; while (t < n) { @@ -335,7 +335,7 @@ vslc_file_next(const struct VSL_cursor *cursor) { struct vslc_file *c; ssize_t i; - size_t l; + ssize_t l; CAST_OBJ_NOTNULL(c, cursor->priv_data, VSLC_FILE_MAGIC); assert(&c->cursor == cursor); diff --git a/lib/libvarnishapi/vut.c b/lib/libvarnishapi/vut.c index 0783f7d..7889010 100644 --- a/lib/libvarnishapi/vut.c +++ b/lib/libvarnishapi/vut.c @@ -237,10 +237,10 @@ VUT_Setup(void) AZ(VUT.vsm); AZ(VUT.vslq); - /* Check input arguments */ - if ((VUT.n_arg == NULL ? 0 : 1) + - (VUT.N_arg == NULL ? 0 : 1) + - (VUT.r_arg == NULL ? 0 : 1) > 1) + /* Check input arguments (2 used for bug in FlexeLint) */ + if ((VUT.n_arg == NULL ? 0 : 2) + + (VUT.N_arg == NULL ? 0 : 2) + + (VUT.r_arg == NULL ? 0 : 2) > 2) VUT_Error(1, "Only one of -n, -N and -r options may be used"); /* Create and validate the query expression */ diff --git a/lib/libvarnishapi/vxp.h b/lib/libvarnishapi/vxp.h index e1e9918..b282a17 100644 --- a/lib/libvarnishapi/vxp.h +++ b/lib/libvarnishapi/vxp.h @@ -64,7 +64,7 @@ struct vxp { struct token *t; unsigned vex_options; - int vre_options; + unsigned vre_options; struct vsb *sb; int err; diff --git a/lib/libvarnishapi/vxp_parse.c b/lib/libvarnishapi/vxp_parse.c index 0331bd3..201d03a 100644 --- a/lib/libvarnishapi/vxp_parse.c +++ b/lib/libvarnishapi/vxp_parse.c @@ -195,7 +195,7 @@ vxp_expr_lhs(struct vxp *vxp, struct vex_lhs **plhs) } static void -vxp_expr_num(struct vxp *vxp, struct vex_rhs **prhs, int vxid) +vxp_expr_num(struct vxp *vxp, struct vex_rhs **prhs, unsigned vxid) { char *endptr; From phk at FreeBSD.org Fri Apr 28 06:17:06 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 28 Apr 2017 08:17:06 +0200 Subject: [master] 35a4eb7 Minor FlexeLintery Message-ID: commit 35a4eb76c13ed891d6dec6a792d8fc4dfcdfc3de Author: Poul-Henning Kamp Date: Fri Apr 28 06:16:08 2017 +0000 Minor FlexeLintery diff --git a/bin/varnishncsa/varnishncsa.c b/bin/varnishncsa/varnishncsa.c index 65ed5c5..1629aa1 100644 --- a/bin/varnishncsa/varnishncsa.c +++ b/bin/varnishncsa/varnishncsa.c @@ -436,7 +436,7 @@ addf_string(const char *str) AN(str); ALLOC_OBJ(f, FORMAT_MAGIC); AN(f); - f->func = &format_string; + f->func = format_string; f->string = strdup(str); AN(f->string); VTAILQ_INSERT_TAIL(&CTX.format, f, list); @@ -450,7 +450,7 @@ addf_strptr(const char *const *strptr) AN(strptr); ALLOC_OBJ(f, FORMAT_MAGIC); AN(f); - f->func = &format_strptr; + f->func = format_strptr; f->strptr = strptr; VTAILQ_INSERT_TAIL(&CTX.format, f, list); } @@ -463,7 +463,7 @@ addf_fragment(struct fragment *frag, const char *str) AN(frag); ALLOC_OBJ(f, FORMAT_MAGIC); AN(f); - f->func = &format_fragment; + f->func = format_fragment; f->frag = frag; if (str != NULL) { f->string = strdup(str); @@ -480,7 +480,7 @@ addf_int32(int32_t *i) AN(i); ALLOC_OBJ(f, FORMAT_MAGIC); AN(f); - f->func = &format_int32; + f->func = format_int32; f->int32 = i; VTAILQ_INSERT_TAIL(&CTX.format, f, list); } @@ -492,7 +492,7 @@ addf_time(char type, const char *fmt) ALLOC_OBJ(f, FORMAT_MAGIC); AN(f); - f->func = &format_time; + f->func = format_time; f->time_type = type; if (fmt != NULL) { f->time_fmt = strdup(fmt); @@ -508,7 +508,7 @@ addf_requestline(void) ALLOC_OBJ(f, FORMAT_MAGIC); AN(f); - f->func = &format_requestline; + f->func = format_requestline; VTAILQ_INSERT_TAIL(&CTX.format, f, list); } @@ -527,7 +527,7 @@ addf_vcl_log(const char *key) ALLOC_OBJ(f, FORMAT_MAGIC); AN(f); - f->func = &format_fragment; + f->func = format_fragment; f->frag = &w->frag; f->string = strdup(""); AN(f->string); @@ -550,7 +550,7 @@ addf_hdr(struct watch_head *head, const char *key) ALLOC_OBJ(f, FORMAT_MAGIC); AN(f); - f->func = &format_fragment; + f->func = format_fragment; f->frag = &w->frag; f->string = strdup("-"); AN(f->string); @@ -582,7 +582,7 @@ addf_auth(void) ALLOC_OBJ(f, FORMAT_MAGIC); AN(f); - f->func = &format_auth; + f->func = format_auth; f->string = strdup("-"); AN(f->string); VTAILQ_INSERT_TAIL(&CTX.format, f, list); @@ -1122,6 +1122,7 @@ read_format(const char *formatfile) if (fmtfile == NULL) VUT_Error(1, "Can't open format file (%s)", strerror(errno)); + AN(fmtfile); fmtlen = getline(&fmt, &len, fmtfile); if (fmtlen == -1) { free(fmt); @@ -1185,6 +1186,7 @@ main(int argc, char * const *argv) case 'h': /* Usage help */ usage(0); + break; case 'w': /* Write to file */ REPLACE(CTX.w_arg, optarg); @@ -1218,7 +1220,7 @@ main(int argc, char * const *argv) format = NULL; /* Setup output */ - VUT.dispatch_f = &dispatch_f; + VUT.dispatch_f = dispatch_f; VUT.dispatch_priv = NULL; VUT.sighup_f = sighup; if (CTX.w_arg) { diff --git a/bin/varnishtop/flint.lnt b/bin/varnishtop/flint.lnt index aa3e9eb..4d95f0a 100644 --- a/bin/varnishtop/flint.lnt +++ b/bin/varnishtop/flint.lnt @@ -1,3 +1,4 @@ +-efile(451, "varnishtop_options.h") -e712 // 14 Info 712 Loss of precision (___) (___ to ___) -e747 // 16 Info 747 Significant prototype coercion (___) ___ to ___ diff --git a/lib/libvarnishapi/vut.c b/lib/libvarnishapi/vut.c index 7889010..a0df661 100644 --- a/lib/libvarnishapi/vut.c +++ b/lib/libvarnishapi/vut.c @@ -157,6 +157,7 @@ VUT_Arg(int opt, const char *arg) return (VUT_g_Arg(arg)); case 'k': /* Log transaction limit */ + AN(arg); VUT.k_arg = (int)strtol(arg, &p, 10); if (*p != '\0' || VUT.k_arg <= 0) VUT_Error(1, "-k: Invalid number '%s'", arg); @@ -183,6 +184,7 @@ VUT_Arg(int opt, const char *arg) return (1); case 't': /* VSM connect timeout */ + AN(arg); if (!strcasecmp("off", arg)) VUT.t_arg = -1.; else { From phk at FreeBSD.org Fri Apr 28 06:46:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 28 Apr 2017 08:46:05 +0200 Subject: [master] db448e5 Make VUT_Error() always exit and insist on non-zero exit status. Message-ID: commit db448e5677135bf18056852867d1fe42c5ddc969 Author: Poul-Henning Kamp Date: Fri Apr 28 06:43:53 2017 +0000 Make VUT_Error() always exit and insist on non-zero exit status. Use fprintf(stderr,...) for progress messages. I doubt we need a VUT_Msg() for that, given that only one use was from outside vut.c, and that is probably an API mistake. diff --git a/bin/varnishstat/varnishstat.c b/bin/varnishstat/varnishstat.c index 713b473..c1f152e 100644 --- a/bin/varnishstat/varnishstat.c +++ b/bin/varnishstat/varnishstat.c @@ -326,8 +326,8 @@ main(int argc, char * const *argv) if (!i) break; if (isnan(t_start) && t_arg > 0.) { - VUT_Error(0, "Can't open log -" - " retrying for %.0f seconds", t_arg); + fprintf(stderr, "Can't open log -" + " retrying for %.0f seconds\n", t_arg); t_start = VTIM_real(); } if (t_arg <= 0.) diff --git a/include/vut.h b/include/vut.h index d1e6ab3..5825994 100644 --- a/include/vut.h +++ b/include/vut.h @@ -67,8 +67,9 @@ struct VUT { extern struct VUT VUT; +//lint -sem(VUT_Error, r_no) void VUT_Error(int status, const char *fmt, ...) - __v_printflike(2, 3); + __v_printflike(2, 3) __attribute__((__noreturn__)); int VUT_g_Arg(const char *arg); diff --git a/lib/libvarnishapi/vut.c b/lib/libvarnishapi/vut.c index a0df661..3fd66ef 100644 --- a/lib/libvarnishapi/vut.c +++ b/lib/libvarnishapi/vut.c @@ -115,14 +115,14 @@ VUT_Error(int status, const char *fmt, ...) { va_list ap; + assert(status != 0); AN(fmt); va_start(ap, fmt); vfprintf(stderr, fmt, ap); va_end(ap); fprintf(stderr, "\n"); - if (status) - exit(status); + exit(status); } int @@ -278,8 +278,8 @@ VUT_Setup(void) break; if (isnan(t_start) && VUT.t_arg > 0.) { - VUT_Error(0, "Cannot open log -" - " retrying for %.0f seconds", VUT.t_arg); + fprintf(stderr, "Cannot open log -" + " retrying for %.0f seconds\n", VUT.t_arg); t_start = VTIM_real(); } VSM_Close(VUT.vsm); @@ -299,7 +299,7 @@ VUT_Setup(void) else VUT_Error(1, "%s", VSL_Error(VUT.vsl)); } else if (!isnan(t_start)) - VUT_Error(0, "Log opened"); + fprintf(stderr, "Log opened\n"); } if (c) @@ -394,7 +394,7 @@ VUT_Main(void) } VSLQ_SetCursor(VUT.vslq, &c); AZ(c); - VUT_Error(0, "Log reacquired"); + fprintf(stderr, "Log reacquired\n"); } i = VSLQ_Dispatch(VUT.vslq, vut_dispatch, NULL); @@ -424,10 +424,10 @@ VUT_Main(void) if (i == -2) /* Abandoned */ - VUT_Error(0, "Log abandoned"); + fprintf(stderr, "Log abandoned\n"); else if (i < -2) /* Overrun */ - VUT_Error(0, "Log overrun"); + fprintf(stderr, "Log overrun\n"); VSM_Close(VUT.vsm); } From phk at FreeBSD.org Fri Apr 28 07:42:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 28 Apr 2017 09:42:05 +0200 Subject: [master] f6b2f55 Make Flexelint ignore returnvalues from -lcurses Message-ID: commit f6b2f55de41471d953b49e87739c58954c082566 Author: Poul-Henning Kamp Date: Fri Apr 28 07:02:03 2017 +0000 Make Flexelint ignore returnvalues from -lcurses diff --git a/flint.lnt b/flint.lnt index 364ede9..f03773f 100644 --- a/flint.lnt +++ b/flint.lnt @@ -158,6 +158,33 @@ -esym(785,VSL_tags) // Sparse array /////////////////////////////////////////////////////////////////////// +// -lcurses +-esym(534, beep) +-esym(534, curs_set) +-esym(534, delwin) +-esym(534, doupdate) +-esym(534, endwin) +-esym(534, initscr) +-esym(534, intrflush) +-esym(534, keypad) +-esym(534, mvprintw) +-esym(534, mvwprintw) +-esym(534, nodelay) +-esym(534, noecho) +-esym(534, nonl) +-esym(534, raw) +-esym(534, waddch) +-esym(534, wattr_off) +-esym(534, wattr_on) +-esym(534, wbkgd) +-esym(534, werase) +-esym(534, wmove) +-esym(534, wnoutrefresh) +-esym(534, wprintw) +-esym(534, wredrawln) +-esym(534, wrefresh) + +/////////////////////////////////////////////////////////////////////// // Noise reduction, review periodically -e459 // unlocked access from func-ptr @@ -165,4 +192,3 @@ -e712 // Loss of precision (___) (___ to ___) -e732 // Loss of sign (___) (___ to ___) -e747 // Significant prototype coercion (___) ___ to ___ - From phk at FreeBSD.org Fri Apr 28 07:42:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 28 Apr 2017 09:42:05 +0200 Subject: [master] 1457d59 Reduce flexelint config to the minimum necessary Message-ID: commit 1457d594ab0da56e4defd2e59328e9bd7f1de27f Author: Poul-Henning Kamp Date: Fri Apr 28 07:39:55 2017 +0000 Reduce flexelint config to the minimum necessary diff --git a/lib/libvarnish/flint.lnt b/lib/libvarnish/flint.lnt index cc5a375..ce26899 100644 --- a/lib/libvarnish/flint.lnt +++ b/lib/libvarnish/flint.lnt @@ -1,76 +1,7 @@ -+libh mgt_event.h -+libh ../../config.h - -+fan // Allow anon unions - --dVARNISH_STATE_DIR="foo" - --emacro((???),va_arg) // the va_arg() macro can yield 415, 416, 661, 662 - // 796 and 797 (out-of-bounds errors). --elib(123) // size is both a variable and a macro with args --emacro(736, isnan) // isnanf - - --header(../../config.h) - --efile(451, "../../config.h") - -// Fix strchr() semtics, it can only return NULL if arg2 != 0 --sem(strchr, 1p, type(1), 2n == 0 ? (@p < 1p) : (@p < 1p || @p == 0 )) - --sem(lbv_assert, r_no) --sem(lbv_xxxassert, r_no) --sem(WS_Init, custodial(2)) --sem(http_Setup, custodial(2)) - --ffc // No automatic custody - --e763 // Redundant declaration for symbol '...' previously declared - --esym(534, sprintf) // Ignoring return value of function --esym(534, asprintf) // Ignoring return value of function --esym(534, printf) // Ignoring return value of function --esym(534, fprintf) // Ignoring return value of function --esym(534, memset) // Ignoring return value of function --esym(534, memcpy) // Ignoring return value of function --esym(534, memmove) // Ignoring return value of function --esym(534, strcpy) // Ignoring return value of function --esym(534, vsb_printf) // Ignoring return value of function --esym(534, vsb_cat) // Ignoring return value of function --esym(534, vsb_bcat) // Ignoring return value of function --esym(534, vsb_putc) // Ignoring return value of function --esym(534, strcat) // Ignoring return value of function --esym(534, strcpy) // Ignoring return value of function - --emacro(506, isnan) // constant value boolean --emacro(747, isnan) // significant coersion --emacro(506, assert) // constant value boolean --emacro(774, HTTPH) // always false - -efunc(835, SHA256_Transform) // A zero has been given as ___ argument to operator '___' -efunc(778, SHA256_Transform) // Constant expression evaluates to 0 in operation '___' ++fan // Allow anon unions -// cache.h --emacro(506, INCOMPL) // Constant value Boolean - -// cache_vcl.c --e641 // Converting enum 'cli_status_e' to int - -// Review all below this line /////////////////////////////////////////////// - --e732 // Loss of sign (arg. no. 2) (int to unsigned -e713 // Loss of precision (assignment) (unsigned long long to long long) --e712 // Loss of precision (assignment) (long long to --e747 // Significant prototype coercion (arg. no. 2) long - -/* - --e767 // Macro redef (system queue.h vs ours ) --e506 // Constant value boolean --e818 // Pointer parameter '...' could be declared as pointing to const --e774 // Boolean within 'if' always evaluates to False --e534 // Ignoring return value of function --e557 // unrecog format - -*/ +-dVARNISH_STATE_DIR="foo" From phk at FreeBSD.org Fri Apr 28 07:42:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 28 Apr 2017 09:42:05 +0200 Subject: [master] 12f71d4 Use bprintf() Message-ID: commit 12f71d4a2418deb5f414446b91a925d941351c93 Author: Poul-Henning Kamp Date: Fri Apr 28 07:40:39 2017 +0000 Use bprintf() diff --git a/bin/varnishstat/varnishstat_curses.c b/bin/varnishstat/varnishstat_curses.c index 0ba009f..af015d4 100644 --- a/bin/varnishstat/varnishstat_curses.c +++ b/bin/varnishstat/varnishstat_curses.c @@ -45,6 +45,7 @@ #include #include +#include "vdef.h" #include "vas.h" #include "miniobj.h" #include "vqueue.h" @@ -276,9 +277,8 @@ build_pt_list_cb(void *priv, const struct VSC_point *vpt) CAST_OBJ_NOTNULL(pt_priv, priv, PT_PRIV_MAGIC); AZ(strcmp(vpt->desc->ctype, "uint64_t")); - snprintf(buf, sizeof buf, "%s.%s.%s", vpt->section->type, + bprintf(buf, "%s.%s.%s", vpt->section->type, vpt->section->ident, vpt->desc->name); - buf[sizeof buf - 1] = '\0'; VTAILQ_FOREACH(pt, &ptlist, list) { CHECK_OBJ_NOTNULL(pt, PT_MAGIC); @@ -301,17 +301,13 @@ build_pt_list_cb(void *priv, const struct VSC_point *vpt) pt->key = strdup(buf); AN(pt->key); - *buf = '\0'; - if (strcmp(vpt->section->type, "")) { - strncat(buf, vpt->section->type, sizeof buf - strlen(buf) - 1); - strncat(buf, ".", sizeof buf - strlen(buf) - 1); - } - if (strcmp(vpt->section->ident, "")) { - strncat(buf, vpt->section->ident, sizeof buf - strlen(buf) - 1); - strncat(buf, ".", sizeof buf - strlen(buf) - 1); - } - strncat(buf, vpt->desc->name, sizeof buf - strlen(buf) - 1); - pt->name = strdup(buf); + if (*vpt->section->type != '\0') + bprintf(buf, "%s.%s", vpt->section->type, vpt->desc->name); + else if (*vpt->section->ident != '\0') + bprintf(buf, "%s.%s", vpt->section->ident, vpt->desc->name); + else + bprintf(buf, "%s", vpt->desc->name); + REPLACE(pt->name, buf); AN(pt->name); pt->vpt = vpt; @@ -937,7 +933,7 @@ draw_bar_b(void) if (current < n_ptarray - 1) mvwprintw(w_bar_b, 0, x, "%s", ptarray[current]->name); - snprintf(buf, sizeof(buf) - 1, "%d-%d/%d", page_start + 1, + bprintf(buf, "%d-%d/%d", page_start + 1, page_start + l_points < n_ptarray ? page_start + l_points : n_ptarray, n_ptarray); From phk at FreeBSD.org Fri Apr 28 07:42:05 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 28 Apr 2017 09:42:05 +0200 Subject: [master] d27e908 Check the VPF return values Message-ID: commit d27e9083036c84164034340c7f1ec3e0f25d3c51 Author: Poul-Henning Kamp Date: Fri Apr 28 07:40:53 2017 +0000 Check the VPF return values diff --git a/lib/libvarnishapi/vut.c b/lib/libvarnishapi/vut.c index 3fd66ef..f69528c 100644 --- a/lib/libvarnishapi/vut.c +++ b/lib/libvarnishapi/vut.c @@ -66,7 +66,7 @@ static void vut_vpf_remove(void) { if (VUT.pfh) { - VPF_Remove(VUT.pfh); + AZ(VPF_Remove(VUT.pfh)); VUT.pfh = NULL; } } @@ -326,7 +326,7 @@ VUT_Setup(void) /* Write PID and setup exit handler */ if (VUT.pfh != NULL) { - VPF_Write(VUT.pfh); + AZ(VPF_Write(VUT.pfh)); AZ(atexit(vut_vpf_remove)); } } From phk at FreeBSD.org Fri Apr 28 10:02:06 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 28 Apr 2017 12:02:06 +0200 Subject: [master] 5060e91 Don't point to the last character, when the complaint is that more characters are necessary. Message-ID: commit 5060e9103c56c3dee2db3e2def0340f65aab2f93 Author: Poul-Henning Kamp Date: Fri Apr 28 08:18:55 2017 +0000 Don't point to the last character, when the complaint is that more characters are necessary. diff --git a/lib/libvarnishapi/vxp_lexer.c b/lib/libvarnishapi/vxp_lexer.c index ee616a9..d858d40 100644 --- a/lib/libvarnishapi/vxp_lexer.c +++ b/lib/libvarnishapi/vxp_lexer.c @@ -141,7 +141,7 @@ vxp_Lexer(struct vxp *vxp) vxp_add_token(vxp, VAL, p, q); if (quote != '\0') { VSB_printf(vxp->sb, "Unterminated string "); - vxp_ErrWhere(vxp, vxp->t, q - p - 1); + vxp_ErrWhere(vxp, vxp->t, q - p); return; } if (vxp_decstr(vxp, 1)) From phk at FreeBSD.org Fri Apr 28 10:02:06 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 28 Apr 2017 12:02:06 +0200 Subject: [master] 4a9c1fd More Flexelintery Message-ID: commit 4a9c1fdca0cbd9696c9c7d99246783aa5bd7f4af Author: Poul-Henning Kamp Date: Fri Apr 28 10:01:28 2017 +0000 More Flexelintery diff --git a/bin/varnishstat/varnishstat_curses.c b/bin/varnishstat/varnishstat_curses.c index af015d4..586ee18 100644 --- a/bin/varnishstat/varnishstat_curses.c +++ b/bin/varnishstat/varnishstat_curses.c @@ -1023,7 +1023,7 @@ handle_keypress(int ch) break; case 'G': current = n_ptarray - 1; - page_start = current - l_points + 1; + page_start = (current - l_points) + 1; break; case 'v': verbosity++; diff --git a/bin/varnishtest/vtc_main.c b/bin/varnishtest/vtc_main.c index 9b60ba4..f9de433 100644 --- a/bin/varnishtest/vtc_main.c +++ b/bin/varnishtest/vtc_main.c @@ -491,7 +491,7 @@ ip_magic(void) * XXX: "localhost", but that doesn't work out of the box. * XXX: Things like "prefer_ipv6" parameter complicates things. */ - fd = VSS_resolver("127.0.0.1", NULL, &bind_cb, NULL, &p); + fd = VSS_resolver("127.0.0.1", NULL, bind_cb, NULL, &p); assert(fd >= 0); VTCP_myname(fd, abuf, sizeof abuf, pbuf, sizeof(pbuf)); extmacro_def("localhost", "%s", abuf); diff --git a/bin/varnishtop/varnishtop.c b/bin/varnishtop/varnishtop.c index af486a7..c7d48ff 100644 --- a/bin/varnishtop/varnishtop.c +++ b/bin/varnishtop/varnishtop.c @@ -203,10 +203,10 @@ update(int p) n++; AC(erase()); if (end_of_file) - AC(mvprintw(0, COLS - 1 - strlen(VUT.name) - 5, "%s (EOF)", + AC(mvprintw(0, (COLS - strlen(VUT.name)) - (1 + 6), "%s (EOF)", VUT.name)); else - AC(mvprintw(0, COLS - 1 - strlen(VUT.name), "%s", VUT.name)); + AC(mvprintw(0, (COLS - strlen(VUT.name)) - 1, "%s", VUT.name)); AC(mvprintw(0, 0, "list length %u", ntop)); for (tp = VRB_MIN(t_order, &h_order); tp != NULL; tp = tp2) { tp2 = VRB_NEXT(t_order, &h_order, tp); @@ -308,6 +308,7 @@ dump(void) } } +//lint -sem(usage, r_no) static void __attribute__((__noreturn__)) usage(int status) { @@ -366,7 +367,7 @@ main(int argc, char **argv) exit(1); } } - VUT.dispatch_f = &accumulate; + VUT.dispatch_f = accumulate; VUT.dispatch_priv = NULL; VUT.sighup_f = sighup; VUT_Main(); diff --git a/flint.lnt b/flint.lnt index f03773f..f77c78b 100644 --- a/flint.lnt +++ b/flint.lnt @@ -60,6 +60,7 @@ // ignore retval -esym(534, printf) -esym(534, fprintf) +-esym(534, vfprintf) -esym(534, sprintf) -esym(534, memset) @@ -151,6 +152,10 @@ -esym(759, vsm_diag) /////////////////////////////////////////////////////////////////////// +// "miniobj.h" + +-emacro(774, REPLACE) + // It is ok to default after handling a few select SLT_* tags -esym(788, VSL_tag_e::SLT_*) // enum constant '...' not used within defaulted switch diff --git a/lib/libvarnish/flint.lnt b/lib/libvarnish/flint.lnt index ce26899..0a014ba 100644 --- a/lib/libvarnish/flint.lnt +++ b/lib/libvarnish/flint.lnt @@ -5,3 +5,5 @@ -e713 // Loss of precision (assignment) (unsigned long long to long long) -dVARNISH_STATE_DIR="foo" + +--emacro((835),BINHEAP_NOIDX) diff --git a/lib/libvarnishapi/flint.lnt b/lib/libvarnishapi/flint.lnt index 4a0c875..59ad7b6 100644 --- a/lib/libvarnishapi/flint.lnt +++ b/lib/libvarnishapi/flint.lnt @@ -1,2 +1,6 @@ ++fan + -esym(788, vex_rhs_e::*) -esym(788, VSL_transaction_e::*) +-esym(769, vex_rhs_e::VEX__UNSET) +-esym(749, chunk_t::chunk_t__unassigned) diff --git a/lib/libvarnishapi/vsl_query.c b/lib/libvarnishapi/vsl_query.c index 79a9f66..b2d43a8 100644 --- a/lib/libvarnishapi/vsl_query.c +++ b/lib/libvarnishapi/vsl_query.c @@ -61,19 +61,21 @@ struct vslq_query { struct vex *vex; }; -#define VSLQ_TEST_NUMOP(TYPE, PRE_LHS, OP, PRE_RHS) \ - switch (TYPE) { \ - case VEX_INT: \ - if (PRE_LHS##_int OP PRE_RHS##_int) \ - return (1); \ - return (0); \ - case VEX_FLOAT: \ - if (PRE_LHS##_float OP PRE_RHS##_float) \ - return (1); \ - return (0); \ - default: \ - WRONG("Wrong RHS type"); \ - } +#define VSLQ_TEST_NUMOP(TYPE, PRE_LHS, OP, PRE_RHS) \ + do { \ + switch (TYPE) { \ + case VEX_INT: \ + if (PRE_LHS##_int OP PRE_RHS##_int) \ + return (1); \ + return (0); \ + case VEX_FLOAT: \ + if (PRE_LHS##_float OP PRE_RHS##_float) \ + return (1); \ + return (0); \ + default: \ + WRONG("Wrong RHS type"); \ + } \ + } while(0) \ static int vslq_test_vxid(const struct vex *vex, const struct VSL_transaction *trans) @@ -103,7 +105,7 @@ vslq_test_vxid(const struct vex *vex, const struct VSL_transaction *trans) /* Compare */ switch (vex->tok) { - #define VXID_TEST_NUMOP(OP) return (trans->vxid OP rhs->val_int); +#define VXID_TEST_NUMOP(OP) return (trans->vxid OP rhs->val_int) case T_EQ: VXID_TEST_NUMOP(==); case T_NEQ: VXID_TEST_NUMOP(!=); case '<': VXID_TEST_NUMOP(<); @@ -185,10 +187,9 @@ vslq_test_rec(const struct vex *vex, const struct VSLC_ptr *rec) switch (rhs->type) { case VEX_INT: lhs_int = strtoll(b, &p, 0); - if (*p == '\0' || isspace(*p)) - break; - /* Can't parse - no match */ - return (0); + if (*p != '\0' && !isspace(*p)) + return (0); /* Can't parse - no match */ + break; case VEX_FLOAT: lhs_float = VNUMpfx(b, &q); if (isnan(lhs_float)) @@ -257,8 +258,7 @@ vslq_test_rec(const struct vex *vex, const struct VSLC_ptr *rec) default: WRONG("Bad expression token"); } - - return (0); + NEEDLESS(return (0)); } static int diff --git a/lib/libvarnishapi/vut.c b/lib/libvarnishapi/vut.c index f69528c..5c5b90e 100644 --- a/lib/libvarnishapi/vut.c +++ b/lib/libvarnishapi/vut.c @@ -373,7 +373,7 @@ VUT_Main(void) if (VUT.sigusr1) { /* Flush and report any incomplete records */ VUT.sigusr1 = 0; - VSLQ_Flush(VUT.vslq, vut_dispatch, NULL); + (void)VSLQ_Flush(VUT.vslq, vut_dispatch, NULL); } if (VUT.vsm != NULL && !VSM_IsOpen(VUT.vsm)) { @@ -420,7 +420,7 @@ VUT_Main(void) /* XXX: Make continuation optional */ - VSLQ_Flush(VUT.vslq, vut_dispatch, NULL); + (void)VSLQ_Flush(VUT.vslq, vut_dispatch, NULL); if (i == -2) /* Abandoned */ diff --git a/lib/libvarnishapi/vxp.h b/lib/libvarnishapi/vxp.h index b282a17..0cb7a9e 100644 --- a/lib/libvarnishapi/vxp.h +++ b/lib/libvarnishapi/vxp.h @@ -70,8 +70,6 @@ struct vxp { int err; }; -struct vex; - struct vex_lhs { /* Left-hand-side of a vex expression. Stores the information about which records and what parts of those records the From phk at FreeBSD.org Fri Apr 28 15:04:06 2017 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 28 Apr 2017 17:04:06 +0200 Subject: [master] 95a34ee Minor flexelintery Message-ID: commit 95a34ee944b2fb6e51d2eecf4179a48539805102 Author: Poul-Henning Kamp Date: Fri Apr 28 15:03:45 2017 +0000 Minor flexelintery diff --git a/bin/varnishtest/flint.lnt b/bin/varnishtest/flint.lnt index ad1e024..65c57c0 100644 --- a/bin/varnishtest/flint.lnt +++ b/bin/varnishtest/flint.lnt @@ -16,6 +16,8 @@ -e850 // for loop index variable '___' whose type category is '___' is modified in body of the for loop that began at '___' -e443 // for clause irregularity: variable '___' initialized in 1st expression does not match '___' modified in 3rd +-emacro({506,774},FEATURE) +-emacro({506,774},STRTOU32_CHECK) -e679 // Suspicious Truncation in arithmetic expression combining with pointer diff --git a/bin/varnishtest/vtc_h2_hpack.c b/bin/varnishtest/vtc_h2_hpack.c index 447d59a..52f1f1c 100644 --- a/bin/varnishtest/vtc_h2_hpack.c +++ b/bin/varnishtest/vtc_h2_hpack.c @@ -40,7 +40,7 @@ struct symbol { uint8_t size; }; -static struct symbol coding_table[] = { +static const struct symbol coding_table[] = { #define HPACK(i, v, l) {v, l}, #include "vtc_h2_enctbl.h" #undef HPACK diff --git a/bin/varnishtest/vtc_http2.c b/bin/varnishtest/vtc_http2.c index c0271cb..31591ae 100644 --- a/bin/varnishtest/vtc_http2.c +++ b/bin/varnishtest/vtc_http2.c @@ -1269,7 +1269,7 @@ cmd_sendhex(CMD_ARGS) hdr.value.ptr = strdup(v); \ AN(hdr.value.ptr); \ hdr.value.len = strlen(v); \ - HPK_EncHdr(iter, &hdr); \ + (void)HPK_EncHdr(iter, &hdr); \ free(hdr.key.ptr); \ free(hdr.value.ptr); \ } diff --git a/bin/varnishtest/vtc_main.c b/bin/varnishtest/vtc_main.c index f9de433..e7e778f 100644 --- a/bin/varnishtest/vtc_main.c +++ b/bin/varnishtest/vtc_main.c @@ -532,6 +532,8 @@ read_file(const char *fn, int ntest) if (*q != '#') break; q = strchr(q, '\n'); + if (q == NULL) + break; } if (q == NULL || *q == '\0') { @@ -566,6 +568,7 @@ main(int argc, char * const *argv) int ch, i; int ntest = 1; /* Run tests this many times */ uintmax_t bufsiz; + const char *p; if (getenv("TMPDIR") != NULL) tmppath = strdup(getenv("TMPDIR")); @@ -579,8 +582,9 @@ main(int argc, char * const *argv) params_vsb = VSB_new_auto(); AN(params_vsb); - if (getenv("VARNISHTEST_DURATION")) - vtc_maxdur = atoi(getenv("VARNISHTEST_DURATION")); + p = getenv("VARNISHTEST_DURATION"); + if (p != NULL) + vtc_maxdur = atoi(p); setbuf(stdout, NULL); setbuf(stderr, NULL); From fgsch at lodoss.net Sat Apr 29 04:36:06 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sat, 29 Apr 2017 06:36:06 +0200 Subject: [master] 8572a43 Skip processing empty strings earlier Message-ID: commit 8572a43523c45f02a892c56907c2c78e8d2e72c3 Author: Federico G. Schwindt Date: Fri Apr 28 21:16:07 2017 -0700 Skip processing empty strings earlier diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c index a8100b3..c69914c 100644 --- a/bin/varnishd/cache/cache_vrt.c +++ b/bin/varnishd/cache/cache_vrt.c @@ -170,7 +170,7 @@ VRT_StringList(char *d, unsigned dl, const char *p, va_list ap) b = d; e = b + dl; while (p != vrt_magic_string_end && b < e) { - if (p != NULL) { + if (p != NULL && *p != '\0') { x = strlen(p); if (b + x < e) memcpy(b, p, x); From fgsch at lodoss.net Sat Apr 29 23:24:06 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sun, 30 Apr 2017 01:24:06 +0200 Subject: [master] 06047a0 Delay must be followed by a number Message-ID: commit 06047a0a84a63a40ba330883247fa87b69fe2cde Author: Federico G. Schwindt Date: Sun Apr 30 00:21:47 2017 +0100 Delay must be followed by a number diff --git a/bin/varnishtest/tests/b00026.vtc b/bin/varnishtest/tests/b00026.vtc index 2f5915f..48fce00 100644 --- a/bin/varnishtest/tests/b00026.vtc +++ b/bin/varnishtest/tests/b00026.vtc @@ -5,13 +5,13 @@ feature SO_RCVTIMEO_WORKS server s1 { rxreq expect req.url == "from_backend" - delay 1; + delay 1 txresp } -start server s2 { rxreq expect req.url == "from_vcl" - delay 1.5; + delay 1.5 txresp } -start diff --git a/bin/varnishtest/vtc.c b/bin/varnishtest/vtc.c index 76f5706..0934661 100644 --- a/bin/varnishtest/vtc.c +++ b/bin/varnishtest/vtc.c @@ -33,6 +33,9 @@ #include #include +#include +#include +#include #include #include #include @@ -40,8 +43,6 @@ #include #include #include -#include -#include #include "vtc.h" @@ -656,6 +657,8 @@ cmd_delay(CMD_ARGS) AN(av[1]); AZ(av[2]); f = VNUM(av[1]); + if (isnan(f)) + vtc_fatal(vl, "Syntax error in number (%s)", av[1]); vtc_log(vl, 3, "delaying %g second(s)", f); VTIM_sleep(f); } From fgsch at lodoss.net Sat Apr 29 23:24:06 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sun, 30 Apr 2017 01:24:06 +0200 Subject: [master] 6ad0fc2 Do not step into the unknown Message-ID: commit 6ad0fc2fa594c95e99c8ccdcd14d989bce71d24b Author: Federico G. Schwindt Date: Sun Apr 30 00:22:18 2017 +0100 Do not step into the unknown diff --git a/lib/libvarnish/vtim.c b/lib/libvarnish/vtim.c index 0c06f41..5e84e65 100644 --- a/lib/libvarnish/vtim.c +++ b/lib/libvarnish/vtim.c @@ -407,6 +407,7 @@ VTIM_timeval(double t) { struct timeval tv; + AZ(isnan(t)); tv.tv_sec = (time_t)trunc(t); tv.tv_usec = (int)(1e6 * (t - tv.tv_sec)); return (tv); @@ -417,6 +418,7 @@ VTIM_timespec(double t) { struct timespec tv; + AZ(isnan(t)); tv.tv_sec = (time_t)trunc(t); tv.tv_nsec = (int)(1e9 * (t - tv.tv_sec)); return (tv); From fgsch at lodoss.net Sat Apr 29 23:43:05 2017 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sun, 30 Apr 2017 01:43:05 +0200 Subject: [master] 9d1adbc Plug another left shift of a negative value Message-ID: commit 9d1adbc5e4be7ab0c9884437b2ce6281edf41d02 Author: Federico G. Schwindt Date: Sun Apr 30 00:32:13 2017 +0100 Plug another left shift of a negative value From upstream: Avoid left shift of a negative value in flush rank calculation. The C standard permits an undefined result for a left shift of a negative value. diff --git a/lib/libvgz/deflate.c b/lib/libvgz/deflate.c index 24cfb77..4a7c6b3 100644 --- a/lib/libvgz/deflate.c +++ b/lib/libvgz/deflate.c @@ -157,7 +157,7 @@ struct static_tree_desc_s {int dummy;}; /* for buggy compilers */ #endif /* rank Z_BLOCK between Z_NO_FLUSH and Z_PARTIAL_FLUSH */ -#define RANK(f) (((f) << 1) - ((f) > 4 ? 9 : 0)) +#define RANK(f) (((f) * 2) - ((f) > 4 ? 9 : 0)) /* =========================================================================== * Update a hash value with the given input byte