From martin at varnish-software.com Tue Feb 4 10:27:11 2014 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Tue, 04 Feb 2014 11:27:11 +0100 Subject: [master] 2e63682 Strengten link checks against loops in the linked records. Message-ID: commit 2e63682065c9d676f691e4900e57c3677ec4ebcc Author: Martin Blix Grydeland Date: Tue Feb 4 11:24:09 2014 +0100 Strengten link checks against loops in the linked records. diff --git a/lib/libvarnishapi/vsl_dispatch.c b/lib/libvarnishapi/vsl_dispatch.c index 5ff57e3..c0ed3c9 100644 --- a/lib/libvarnishapi/vsl_dispatch.c +++ b/lib/libvarnishapi/vsl_dispatch.c @@ -656,6 +656,7 @@ vtx_set_parent(struct vtx *parent, struct vtx *child) CHECK_OBJ_NOTNULL(parent, VTX_MAGIC); CHECK_OBJ_NOTNULL(child, VTX_MAGIC); + assert(parent != child); AZ(parent->flags & VTX_F_COMPLETE); AZ(child->flags & VTX_F_COMPLETE); AZ(child->parent); @@ -736,8 +737,10 @@ vtx_scan_begin(struct VSLQ *vslq, struct vtx *vtx, const uint32_t *ptr) vtx->reason = reason; if (p_vxid == 0) - /* No parent */ + /* Zero means no parent */ return (0); + if (p_vxid == vtx->key.vxid) + return (vtx_diag_tag(vtx, ptr, "link to self")); if (vslq->grouping == VSL_g_vxid) return (0); /* No links */ @@ -796,6 +799,11 @@ vtx_scan_link(struct VSLQ *vslq, struct vtx *vtx, const uint32_t *ptr) if (vslq->grouping == VSL_g_request && vtx->type == VSL_t_sess) return (0); /* No links */ + if (c_vxid == 0) + return (vtx_diag_tag(vtx, ptr, "illegal link vxid")); + if (c_vxid == vtx->key.vxid) + return (vtx_diag_tag(vtx, ptr, "link to self")); + /* Lookup and check child vtx */ c_vtx = vtx_lookup(vslq, c_vxid); if (c_vtx == NULL) { From martin at varnish-software.com Tue Feb 4 10:27:11 2014 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Tue, 04 Feb 2014 11:27:11 +0100 Subject: [master] 5659c4d Don't loop to your self in synthesized Begin records. Message-ID: commit 5659c4d0900a522e729a6c9e573ed032e6b587fd Author: Martin Blix Grydeland Date: Tue Feb 4 11:25:04 2014 +0100 Don't loop to your self in synthesized Begin records. This would cause the API to link this log record to itself, creating endless loops. Correct it by setting it to zero (meaning no parent). diff --git a/lib/libvarnishapi/vsl_dispatch.c b/lib/libvarnishapi/vsl_dispatch.c index c0ed3c9..0aee758 100644 --- a/lib/libvarnishapi/vsl_dispatch.c +++ b/lib/libvarnishapi/vsl_dispatch.c @@ -881,7 +881,7 @@ vtx_force(struct VSLQ *vslq, struct vtx *vtx, const char *reason) vtx_scan(vslq, vtx); if (!(vtx->flags & VTX_F_BEGIN)) vtx_synth_rec(vtx, SLT_Begin, "%s %u synth", - vsl_t_names[vtx->type], vtx->key.vxid); + vsl_t_names[vtx->type], 0); vtx_diag(vtx, reason); if (!(vtx->flags & VTX_F_END)) vtx_synth_rec(vtx, SLT_End, "synth"); From daghf at varnish-software.com Tue Feb 4 11:59:51 2014 From: daghf at varnish-software.com (Dag Haavi Finstad) Date: Tue, 04 Feb 2014 12:59:51 +0100 Subject: [master] 336bd58 Fix WS_Printf off by one error/truncation handling. Message-ID: commit 336bd5861a0340d0729c4b053dfc01e127f2f1da Author: Dag Haavi Finstad Date: Tue Feb 4 12:59:47 2014 +0100 Fix WS_Printf off by one error/truncation handling. diff --git a/bin/varnishd/cache/cache_ws.c b/bin/varnishd/cache/cache_ws.c index 5ed9040..8ef7aca 100644 --- a/bin/varnishd/cache/cache_ws.c +++ b/bin/varnishd/cache/cache_ws.c @@ -175,11 +175,12 @@ WS_Printf(struct ws *ws, const char *fmt, ...) p = ws->f; va_start(ap, fmt); v = vsnprintf(p, u, fmt, ap); - if (v > u) { + va_end(ap); + if (v >= u) { WS_Release(ws, 0); p = NULL; } else { - WS_Release(ws, v); + WS_Release(ws, v + 1); } return (p); } From phk at FreeBSD.org Wed Feb 5 09:42:23 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 05 Feb 2014 10:42:23 +0100 Subject: [master] 2eddf20 Rewrite test-cases to not use req.backend Message-ID: commit 2eddf20ca7dffe58e94144982c5be403b7224de4 Author: Poul-Henning Kamp Date: Wed Feb 5 09:32:26 2014 +0000 Rewrite test-cases to not use req.backend diff --git a/bin/varnishtest/tests/b00026.vtc b/bin/varnishtest/tests/b00026.vtc index b094b0a..2f5915f 100644 --- a/bin/varnishtest/tests/b00026.vtc +++ b/bin/varnishtest/tests/b00026.vtc @@ -29,13 +29,16 @@ varnish v1 -vcl { sub vcl_recv { if (req.url == "from_backend") { - set req.backend = b1; return(pass); } - set req.backend = b2; } sub vcl_backend_fetch { set bereq.first_byte_timeout = 2s; + if (bereq.url == "from_backend") { + set bereq.backend = b1; + } else { + set bereq.backend = b2; + } } } -start varnish v1 -cliok "param.set first_byte_timeout 0.5" diff --git a/bin/varnishtest/tests/c00009.vtc b/bin/varnishtest/tests/c00009.vtc index 3d43334..7931e81 100644 --- a/bin/varnishtest/tests/c00009.vtc +++ b/bin/varnishtest/tests/c00009.vtc @@ -14,10 +14,13 @@ server s2 { varnish v1 -vcl+backend { sub vcl_recv { - if (req.restarts == 0) { - set req.backend = s1; + set req.http.restarts = req.restarts; + } + sub vcl_backend_fetch { + if (bereq.http.restarts == "0") { + set bereq.backend = s1; } else { - set req.backend = s2; + set bereq.backend = s2; } } diff --git a/bin/varnishtest/tests/c00028.vtc b/bin/varnishtest/tests/c00028.vtc index 4f8a0ff..91abe45 100644 --- a/bin/varnishtest/tests/c00028.vtc +++ b/bin/varnishtest/tests/c00028.vtc @@ -5,8 +5,8 @@ varnish v1 -vcl { .host = "${bad_ip}"; .port = "9090"; } - sub vcl_recv { - set req.backend = bad; + sub vcl_backend_fetch { + set bereq.backend = bad; } sub vcl_error { return (restart); diff --git a/bin/varnishtest/tests/c00038.vtc b/bin/varnishtest/tests/c00038.vtc index 0764e85..e9402b6 100644 --- a/bin/varnishtest/tests/c00038.vtc +++ b/bin/varnishtest/tests/c00038.vtc @@ -17,11 +17,13 @@ varnish v1 -vcl+backend { if (req.http.x-ignorebusy == "1") { set req.hash_ignore_busy = true; } - if (req.http.x-client == "1") { - set req.backend = s1; + } + sub vcl_backend_fetch { + if (bereq.http.x-client == "1") { + set bereq.backend = s1; } - if (req.http.x-client == "2") { - set req.backend = s2; + if (bereq.http.x-client == "2") { + set bereq.backend = s2; } } } -start diff --git a/bin/varnishtest/tests/c00043.vtc b/bin/varnishtest/tests/c00043.vtc index 46cc4e1..0960621 100644 --- a/bin/varnishtest/tests/c00043.vtc +++ b/bin/varnishtest/tests/c00043.vtc @@ -16,9 +16,9 @@ server s2 { } -start varnish v1 -vcl+backend { - sub vcl_recv { - if (req.http.bar) { - set req.backend = s2; + sub vcl_backend_fetch { + if (bereq.http.bar) { + set bereq.backend = s2; } } } -start diff --git a/bin/varnishtest/tests/e00006.vtc b/bin/varnishtest/tests/e00006.vtc index 79382fc..759a0f4 100644 --- a/bin/varnishtest/tests/e00006.vtc +++ b/bin/varnishtest/tests/e00006.vtc @@ -22,11 +22,11 @@ server s2 { } -start varnish v1 -vcl+backend { - sub vcl_recv { - if (req.http.host == "bozz") { - set req.backend = s2; + sub vcl_backend_fetch { + if (bereq.http.host == "bozz") { + set bereq.backend = s2; } else { - set req.backend = s1; + set bereq.backend = s1; } } sub vcl_backend_response { diff --git a/bin/varnishtest/tests/m00009.vtc b/bin/varnishtest/tests/m00009.vtc index 4e97863..7fbeec1 100644 --- a/bin/varnishtest/tests/m00009.vtc +++ b/bin/varnishtest/tests/m00009.vtc @@ -34,8 +34,8 @@ varnish v1 -vcl+backend { rr.add_backend(s4); } - sub vcl_recv { - set req.backend = rr.backend(); + sub vcl_backend_fetch { + set bereq.backend = rr.backend(); } } -start diff --git a/bin/varnishtest/tests/m00010.vtc b/bin/varnishtest/tests/m00010.vtc index db2a07f..9d8ba1d 100644 --- a/bin/varnishtest/tests/m00010.vtc +++ b/bin/varnishtest/tests/m00010.vtc @@ -47,8 +47,8 @@ varnish v1 -vcl+backend { rr3.add_backend(rr2.backend()); } - sub vcl_recv { - set req.backend = rr3.backend(); + sub vcl_backend_fetch { + set bereq.backend = rr3.backend(); } } -start diff --git a/bin/varnishtest/tests/r00255.vtc b/bin/varnishtest/tests/r00255.vtc index 1aedcc1..27b2bc8 100644 --- a/bin/varnishtest/tests/r00255.vtc +++ b/bin/varnishtest/tests/r00255.vtc @@ -10,7 +10,11 @@ server s1 { -body "012345\n" } -start -varnish v1 -vcl+backend { sub vcl_recv {set req.backend = s1;} } -start +varnish v1 -vcl+backend { + sub vcl_backend_fetch { + set bereq.backend = s1; + } +} -start client c1 { txreq -url "/" diff --git a/bin/varnishtest/tests/r00263.vtc b/bin/varnishtest/tests/r00263.vtc index 39f1ef5..c9036d5 100644 --- a/bin/varnishtest/tests/r00263.vtc +++ b/bin/varnishtest/tests/r00263.vtc @@ -16,8 +16,8 @@ varnish v1 -vcl { cluster.add_backend(node3, 1); } - sub vcl_recv { - set req.backend = cluster.backend(); + sub vcl_backend_fetch { + set bereq.backend = cluster.backend(); } } -start diff --git a/bin/varnishtest/tests/r00306.vtc b/bin/varnishtest/tests/r00306.vtc index 9e85b25..0d4c465 100644 --- a/bin/varnishtest/tests/r00306.vtc +++ b/bin/varnishtest/tests/r00306.vtc @@ -33,8 +33,8 @@ varnish v1 -vcl { foo.add_backend(s2, 1); } - sub vcl_recv { - set req.backend = foo.backend(); + sub vcl_backend_fetch { + set bereq.backend = foo.backend(); } } -start diff --git a/bin/varnishtest/tests/r00433.vtc b/bin/varnishtest/tests/r00433.vtc index 01462d4..494d8a8 100644 --- a/bin/varnishtest/tests/r00433.vtc +++ b/bin/varnishtest/tests/r00433.vtc @@ -23,11 +23,11 @@ server s2 { } -start varnish v1 -vcl+backend { - sub vcl_recv { - if (req.url == "/foo") { - set req.backend = s1; + sub vcl_backend_fetch { + if (bereq.url == "/foo") { + set bereq.backend = s1; } else { - set req.backend = s2; + set bereq.backend = s2; } } diff --git a/bin/varnishtest/tests/r00722.vtc b/bin/varnishtest/tests/r00722.vtc index ef7268c..739b8f0 100644 --- a/bin/varnishtest/tests/r00722.vtc +++ b/bin/varnishtest/tests/r00722.vtc @@ -22,8 +22,8 @@ varnish v1 -vcl+backend { foo.add_backend(b2, 1); foo.add_backend(b3, 1); } - sub vcl_recv { - set req.backend = foo.backend(); + sub vcl_backend_fetch { + set bereq.backend = foo.backend(); } } -start diff --git a/bin/varnishtest/tests/r00916.vtc b/bin/varnishtest/tests/r00916.vtc index 2b3a9e0..04aa7c6 100644 --- a/bin/varnishtest/tests/r00916.vtc +++ b/bin/varnishtest/tests/r00916.vtc @@ -10,8 +10,8 @@ varnish v1 -errvcl {Symbol not found: 's-1' (expected type BACKEND)} { sub s1 { } sub vcl_backend_response { - if (req.backend == s-1){ - set req.backend = s-1; + if (bereq.backend == s-1){ + set bereq.backend = s-1; } } } diff --git a/bin/varnishtest/tests/r01073.vtc b/bin/varnishtest/tests/r01073.vtc index 58d8ae6..3e0c44e 100644 --- a/bin/varnishtest/tests/r01073.vtc +++ b/bin/varnishtest/tests/r01073.vtc @@ -19,11 +19,13 @@ varnish v1 -vcl+backend { if (req.http.x-hash-always-miss == "1") { set req.hash_always_miss = true; } - if (req.http.x-client == "1") { - set req.backend = s1; + } + sub vcl_backend_fetch { + if (bereq.http.x-client == "1") { + set bereq.backend = s1; } - if (req.http.x-client == "2") { - set req.backend = s2; + if (bereq.http.x-client == "2") { + set bereq.backend = s2; } } } -start diff --git a/bin/varnishtest/tests/r01144.vtc b/bin/varnishtest/tests/r01144.vtc index dcd1505..284c848 100644 --- a/bin/varnishtest/tests/r01144.vtc +++ b/bin/varnishtest/tests/r01144.vtc @@ -11,9 +11,9 @@ varnish v1 -vcl+backend { .host = "127.0.0.1"; .port = "54321"; } - sub vcl_recv { - if (req.url == "never") { - set req.backend = fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210; + sub vcl_backend_fetch { + if (bereq.url == "never") { + set bereq.backend = fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210; } } } -start @@ -30,9 +30,9 @@ varnish v1 -errvcl {Expected ID got '0'} { .host = "127.0.0.1"; .port = "54321"; } - sub vcl_recv { - if (req.url == "never") { - set req.backend = fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210; + sub vcl_backend_fetch { + if (bereq.url == "never") { + set bereq.backend = fedcba9876543210fedcba9876543210fedcba9876543210fedcba9876543210; } } } diff --git a/bin/varnishtest/tests/r01164.vtc b/bin/varnishtest/tests/r01164.vtc index b9072e1..2951482 100644 --- a/bin/varnishtest/tests/r01164.vtc +++ b/bin/varnishtest/tests/r01164.vtc @@ -5,8 +5,8 @@ varnish v1 -vcl { .host = "127.0.0.1"; } - sub vcl_recv { - set req.backend = storage_foo; + sub vcl_backend_fetch { + set bereq.backend = storage_foo; } } @@ -15,8 +15,8 @@ varnish v1 -vcl { .host = "127.0.0.1"; } - sub vcl_recv { - set req.backend = storagefoo; + sub vcl_backend_fetch { + set bereq.backend = storagefoo; } } diff --git a/bin/varnishtest/tests/v00007.vtc b/bin/varnishtest/tests/v00007.vtc index 313d970..196f92e 100644 --- a/bin/varnishtest/tests/v00007.vtc +++ b/bin/varnishtest/tests/v00007.vtc @@ -16,8 +16,8 @@ varnish v1 -vcl+backend { foo.add_backend(s1, 1); } - sub vcl_recv { - set req.backend = foo.backend(); + sub vcl_backend_fetch { + set bereq.backend = foo.backend(); } } -start diff --git a/bin/varnishtest/tests/v00009.vtc b/bin/varnishtest/tests/v00009.vtc index a356a51..af925fb 100644 --- a/bin/varnishtest/tests/v00009.vtc +++ b/bin/varnishtest/tests/v00009.vtc @@ -33,8 +33,8 @@ varnish v1 -vcl+backend { batman.add_backend(s4); } - sub vcl_recv { - set req.backend = batman.backend(); + sub vcl_backend_fetch { + set bereq.backend = batman.backend(); } } -start diff --git a/bin/varnishtest/tests/v00014.vtc b/bin/varnishtest/tests/v00014.vtc index 67d3431..3a48188 100644 --- a/bin/varnishtest/tests/v00014.vtc +++ b/bin/varnishtest/tests/v00014.vtc @@ -27,7 +27,7 @@ varnish v1 -vcl { } sub vcl_recv { - if (std.healthy(req.backend)) { + if (std.healthy(default)) { return(error(200,"Backend healthy")); } else { return(error(500,"Backend sick")); diff --git a/bin/varnishtest/tests/v00016.vtc b/bin/varnishtest/tests/v00016.vtc index a155dd0..7a00d95 100644 --- a/bin/varnishtest/tests/v00016.vtc +++ b/bin/varnishtest/tests/v00016.vtc @@ -84,8 +84,9 @@ varnish v1 -errvcl {Expression has type DURATION, expected BOOL} { } varnish v1 -errvcl {Operator > not possible on BACKEND} { + backend a { .host = "127.0.0.1"; } backend b { .host = "127.0.0.1"; } - sub vcl_recv { if (req.backend > b) { } } + sub vcl_recv { if (a > b) { } } } varnish v1 -errvcl {Symbol not found: 'req.hash' (expected type BOOL):} { diff --git a/bin/varnishtest/tests/v00018.vtc b/bin/varnishtest/tests/v00018.vtc index c264cca..720c816 100644 --- a/bin/varnishtest/tests/v00018.vtc +++ b/bin/varnishtest/tests/v00018.vtc @@ -29,7 +29,7 @@ varnish v1 -errvcl {Expected '=' got '>>'} { varnish v1 -errvcl {Expected '=' got '+='} { backend b { .host = "127.0.0.1"; } - sub vcl_recv { set req.backend += b; } + sub vcl_backend_fetch { set bereq.backend += b; } } varnish v1 -errvcl {Expected '=' got '+='} { diff --git a/bin/varnishtest/tests/v00022.vtc b/bin/varnishtest/tests/v00022.vtc index 10f4c9f..5e5a17b 100644 --- a/bin/varnishtest/tests/v00022.vtc +++ b/bin/varnishtest/tests/v00022.vtc @@ -43,9 +43,11 @@ varnish v1 -vcl+backend { } sub vcl_recv { - set req.backend = foo.backend(); return(pass); } + sub vcl_backend_fetch { + set bereq.backend = foo.backend(); + } } -start # NB: Do not change the number 1 diff --git a/bin/varnishtest/tests/v00026.vtc b/bin/varnishtest/tests/v00026.vtc index 40d3b33..e1b77b9 100644 --- a/bin/varnishtest/tests/v00026.vtc +++ b/bin/varnishtest/tests/v00026.vtc @@ -25,9 +25,11 @@ varnish v1 -vcl+backend { } sub vcl_recv { - set req.backend = h1.backend(req.url); return(pass); } + sub vcl_backend_fetch { + set bereq.backend = h1.backend(bereq.url); + } } -start diff --git a/bin/varnishtest/tests/v00027.vtc b/bin/varnishtest/tests/v00027.vtc index 72a7030..f014322 100644 --- a/bin/varnishtest/tests/v00027.vtc +++ b/bin/varnishtest/tests/v00027.vtc @@ -20,9 +20,9 @@ varnish v1 -vcl { .port = "${s2_port}"; } - sub vcl_recv { - if (req.url != req.url) { - set req.backend = s1; + sub vcl_backend_fetch { + if (bereq.url != bereq.url) { + set bereq.backend = s1; } } } -start diff --git a/bin/varnishtest/tests/v00036.vtc b/bin/varnishtest/tests/v00036.vtc index 42e9123..7bb1be8 100644 --- a/bin/varnishtest/tests/v00036.vtc +++ b/bin/varnishtest/tests/v00036.vtc @@ -26,9 +26,11 @@ varnish v1 -vcl+backend { } sub vcl_recv { - set req.backend = fb1.backend(); return (pass); } + sub vcl_backend_fetch { + set bereq.backend = fb1.backend(); + } } -start From phk at FreeBSD.org Wed Feb 5 10:46:41 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 05 Feb 2014 11:46:41 +0100 Subject: [master] 7f97686 Rename req.backend to req.backend_hint and restrict it to vcl_recv{} Message-ID: commit 7f9768602064589d122f72aea95e05c894c7e975 Author: Poul-Henning Kamp Date: Wed Feb 5 10:44:34 2014 +0000 Rename req.backend to req.backend_hint and restrict it to vcl_recv{} Rename beresp.storage to beresp.storage_hint for consistency. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 6e522bb..93ec51f 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -664,7 +664,7 @@ struct req { uint16_t err_code; const char *err_reason; - struct director *director; + struct director *director_hint; struct VCL_conf *vcl; char *ws_req; /* WS above request data */ diff --git a/bin/varnishd/cache/cache_busyobj.c b/bin/varnishd/cache/cache_busyobj.c index 2466404..65a24bf 100644 --- a/bin/varnishd/cache/cache_busyobj.c +++ b/bin/varnishd/cache/cache_busyobj.c @@ -144,7 +144,7 @@ VBO_GetBusyObj(struct worker *wrk, const struct req *req) bo->do_stream = 1; - bo->director = req->director; + bo->director = req->director_hint; bo->vcl = req->vcl; VCL_Ref(bo->vcl); diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index eb69164..b7eba44 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -357,7 +357,6 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp, wrk = req->wrk; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(req->http, HTTP_MAGIC); - AN(req->director); AN(hash); hsh_prealloc(wrk); diff --git a/bin/varnishd/cache/cache_http1_fsm.c b/bin/varnishd/cache/cache_http1_fsm.c index 3389f6d..5d0f286 100644 --- a/bin/varnishd/cache/cache_http1_fsm.c +++ b/bin/varnishd/cache/cache_http1_fsm.c @@ -183,7 +183,7 @@ http1_cleanup(struct sess *sp, struct worker *wrk, struct req *req) CHECK_OBJ_ORNULL(req->vcl, VCL_CONF_MAGIC); AZ(req->obj); - req->director = NULL; + req->director_hint = NULL; req->restarts = 0; AZ(req->esi_level); diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index ec7713a..b2f3ef0 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -208,7 +208,7 @@ cnt_error(struct worker *wrk, struct req *req) bo->stats = NULL; if (req->obj == NULL) { req->doclose = SC_OVERLOAD; - req->director = NULL; + req->director_hint = NULL; AZ(HSH_DerefObjCore(&wrk->stats, &bo->fetch_objcore)); bo->fetch_objcore = NULL; http_Teardown(bo->beresp); @@ -634,7 +634,7 @@ cnt_restart(struct worker *wrk, struct req *req) CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - req->director = NULL; + req->director_hint = NULL; if (++req->restarts >= cache_param->max_restarts) { VSLb(req->vsl, SLT_VCL_Error, "Too many restarts"); req->err_code = 503; @@ -698,9 +698,9 @@ cnt_recv(struct worker *wrk, struct req *req) } /* By default we use the first backend */ - AZ(req->director); - req->director = req->vcl->director[0]; - AN(req->director); + AZ(req->director_hint); + req->director_hint = req->vcl->director[0]; + AN(req->director_hint); req->d_ttl = -1; req->disable_esi = 0; diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index dad35f3..5d875ed 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -279,7 +279,7 @@ VRT_r_beresp_backend_ip(const struct vrt_ctx *ctx) } const char * -VRT_r_beresp_storage(const struct vrt_ctx *ctx) +VRT_r_beresp_storage_hint(const struct vrt_ctx *ctx) { CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC); @@ -290,7 +290,7 @@ VRT_r_beresp_storage(const struct vrt_ctx *ctx) } void -VRT_l_beresp_storage(const struct vrt_ctx *ctx, const char *str, ...) +VRT_l_beresp_storage_hint(const struct vrt_ctx *ctx, const char *str, ...) { va_list ap; const char *b; @@ -326,8 +326,8 @@ VRT_r_req_##nm(const struct vrt_ctx *ctx) \ return(ctx->req->elem); \ } -REQ_VAR_L(backend, director, struct director *,) -REQ_VAR_R(backend, director, struct director *) +REQ_VAR_L(backend_hint, director_hint, struct director *,) +REQ_VAR_R(backend_hint, director_hint, struct director *) REQ_VAR_L(ttl, d_ttl, double, if (!(arg>0.0)) arg = 0;) REQ_VAR_R(ttl, d_ttl, double) diff --git a/bin/varnishtest/tests/b00016.vtc b/bin/varnishtest/tests/b00016.vtc index fc2478e..f4763ee 100644 --- a/bin/varnishtest/tests/b00016.vtc +++ b/bin/varnishtest/tests/b00016.vtc @@ -1,74 +1,42 @@ varnishtest "Check naming of backends" -varnish v1 -vcl { - backend foo { - .host = "${bad_ip}"; .port = "9080"; - } +server s1 { + rxreq + txresp +} -start - sub vcl_recv { - return(error(200,"ok")); - } +varnish v1 -vcl+backend { - sub vcl_error { - set obj.http.X-Backend-Name = req.backend; + sub vcl_backend_response { + set beresp.http.X-Backend-Name = bereq.backend; } } -start client c1 { txreq -url "/" rxresp - expect resp.http.X-Backend-Name == "foo" + expect resp.http.X-Backend-Name == "s1" } -run -varnish v1 -vcl { +varnish v1 -vcl+backend { import ${vmod_directors}; - backend b1 { - .host = "${bad_ip}"; .port = "9080"; - } sub vcl_init { new bar = directors.random(); - bar.add_backend(b1, 1); - } - - sub vcl_recv { - set req.backend = bar.backend(); - return(error(200,"ok")); - } - - sub vcl_error { - set obj.http.X-Backend-Name = req.backend; - } -} - -client c1 { - txreq -url "/" - rxresp - expect resp.http.X-Backend-Name == "bar" -} -run - -varnish v1 -vcl { - import ${vmod_directors}; - backend b1 { - .host = "${bad_ip}"; .port = "9080"; - } - sub vcl_init { - new baz = directors.round_robin(); - baz.add_backend(b1); + bar.add_backend(s1, 1); } sub vcl_recv { - set req.backend = baz.backend(); - return (error(200,"ok")); + set req.backend_hint = bar.backend(); } - sub vcl_error { - set obj.http.X-Backend-Name = req.backend; + sub vcl_backend_response { + set beresp.http.X-Backend-Name = bereq.backend; } } client c1 { txreq -url "/" rxresp - expect resp.http.X-Backend-Name == "baz" + expect resp.http.X-Backend-Name == "s1" } -run diff --git a/bin/varnishtest/tests/c00044.vtc b/bin/varnishtest/tests/c00044.vtc index fb415eb..9bd7950 100644 --- a/bin/varnishtest/tests/c00044.vtc +++ b/bin/varnishtest/tests/c00044.vtc @@ -24,7 +24,7 @@ varnish v1 \ -vcl+backend { sub vcl_backend_response { set beresp.do_stream = false; - set beresp.storage = "invalid"; + set beresp.storage_hint = "invalid"; } } -start diff --git a/bin/varnishtest/tests/c00045.vtc b/bin/varnishtest/tests/c00045.vtc index 23967fa..c653cf0 100644 --- a/bin/varnishtest/tests/c00045.vtc +++ b/bin/varnishtest/tests/c00045.vtc @@ -16,7 +16,7 @@ varnish v1 \ -vcl+backend { sub vcl_backend_response { set beresp.do_stream = false; - set beresp.storage = "s0"; + set beresp.storage_hint = "s0"; } } -start diff --git a/bin/varnishtest/tests/c00046.vtc b/bin/varnishtest/tests/c00046.vtc index a2e1d2b..3abea2f 100644 --- a/bin/varnishtest/tests/c00046.vtc +++ b/bin/varnishtest/tests/c00046.vtc @@ -15,7 +15,7 @@ varnish v1 \ -arg "-smalloc,1m" \ -vcl+backend { sub vcl_backend_response { - set beresp.storage = "s0"; + set beresp.storage_hint = "s0"; } } -start diff --git a/bin/varnishtest/tests/p00008.vtc b/bin/varnishtest/tests/p00008.vtc index 411c4b4..b839a0c 100644 --- a/bin/varnishtest/tests/p00008.vtc +++ b/bin/varnishtest/tests/p00008.vtc @@ -20,9 +20,9 @@ varnish v1 \ -arg "-sper2=persistent,${tmpdir}/_.per2,10m" \ -vcl+backend { sub vcl_backend_response { - set beresp.storage = "per1"; + set beresp.storage_hint = "per1"; if (bereq.url ~ "silo2") { - set beresp.storage = "per2"; + set beresp.storage_hint = "per2"; } } } -start diff --git a/bin/varnishtest/tests/r01175.vtc b/bin/varnishtest/tests/r01175.vtc index 5539b20..5624c20 100644 --- a/bin/varnishtest/tests/r01175.vtc +++ b/bin/varnishtest/tests/r01175.vtc @@ -7,7 +7,7 @@ server s1 { varnish v1 -arg "-s test=malloc,1M" -vcl+backend { sub vcl_backend_response { - set beresp.storage = "test"; + set beresp.storage_hint = "test"; set beresp.do_stream = false; } } -start diff --git a/bin/varnishtest/tests/r01283.vtc b/bin/varnishtest/tests/r01283.vtc index 015b2fa..9b843ce 100644 --- a/bin/varnishtest/tests/r01283.vtc +++ b/bin/varnishtest/tests/r01283.vtc @@ -16,7 +16,7 @@ varnish v1 \ } sub vcl_backend_response { set beresp.do_stream = false; - set beresp.storage = "Transient"; + set beresp.storage_hint = "Transient"; } } -start diff --git a/bin/varnishtest/tests/r01284.vtc b/bin/varnishtest/tests/r01284.vtc index 68dc456..697f104 100644 --- a/bin/varnishtest/tests/r01284.vtc +++ b/bin/varnishtest/tests/r01284.vtc @@ -15,7 +15,7 @@ varnish v1 \ -vcl+backend { sub vcl_backend_response { set beresp.do_stream = false; - set beresp.storage = "Transient"; + set beresp.storage_hint = "Transient"; } } -start diff --git a/bin/varnishtest/tests/v00033.vtc b/bin/varnishtest/tests/v00033.vtc index d3eecc3..a10fac1 100644 --- a/bin/varnishtest/tests/v00033.vtc +++ b/bin/varnishtest/tests/v00033.vtc @@ -15,7 +15,7 @@ varnish v1 -vcl+backend { storage.nowhere.free_space + 1 B + 1 KB + 1 MB + 1GB + 1TB; if (bereq.url == "/foo") { - set beresp.storage = "Transient"; + set beresp.storage_hint = "Transient"; } } sub vcl_deliver { diff --git a/lib/libvcc/generate.py b/lib/libvcc/generate.py index a36c2d4..8d8f14f 100755 --- a/lib/libvcc/generate.py +++ b/lib/libvcc/generate.py @@ -253,11 +253,13 @@ The client's IP address. Does the client accept the gzip transfer encoding. """ ), - ('req.backend', + ('req.backend_hint', 'BACKEND', - ( 'client',), - ( 'client',), """ - The backend to use to service the request. + ( 'recv',), + ( 'recv',), """ + Set bereq.backend to this if we attemt to fetch. + This variable is a convenience so the overall + policy can be set up once and for all in vcl_recv{}. """ ), ('req.hash_ignore_busy', @@ -455,11 +457,11 @@ The client's IP address. IP of the backend this response was fetched from. """ ), - ('beresp.storage', + ('beresp.storage_hint', 'STRING', ( 'backend_response',), ( 'backend_response',), """ - Set to force Varnish to save this object to a + Hint to Varnish that you want to save this object to a particular storage backend. """ ), From tfheen at err.no Wed Feb 5 11:30:12 2014 From: tfheen at err.no (Tollef Fog Heen) Date: Wed, 05 Feb 2014 12:30:12 +0100 Subject: [master] b52a310 Generate reference/params.rst as part of build process Message-ID: commit b52a3108c28a357c82be4318e84a7a2b3c24516b Author: Tollef Fog Heen Date: Wed Feb 5 12:28:58 2014 +0100 Generate reference/params.rst as part of build process diff --git a/doc/sphinx/Makefile.am b/doc/sphinx/Makefile.am index 54c01f6..692cf6f 100644 --- a/doc/sphinx/Makefile.am +++ b/doc/sphinx/Makefile.am @@ -30,7 +30,7 @@ help: clean: -rm -rf $(BUILDDIR)/* -html: +html: reference/params.rst $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." @@ -176,6 +176,5 @@ dist-hook: distclean-local: rm -rf $(BUILDDIR) -# XXX: doesn't work... -#reference/params.rst: $(top_builddir)/bin/varnishd/varnishd -# $(top_builddir)/bin/varnishd/varnishd -x dumprstparam > reference/params.rst +reference/params.rst: + $(top_builddir)/bin/varnishd/varnishd -x dumprstparam > reference/params.rst diff --git a/doc/sphinx/reference/params.rst b/doc/sphinx/reference/params.rst deleted file mode 100644 index e475158..0000000 --- a/doc/sphinx/reference/params.rst +++ /dev/null @@ -1,1090 +0,0 @@ - -.. The following is the autogenerated output from varnishd -x dumprstparam - -.. _ref_param_accept_filter: - -accept_filter -~~~~~~~~~~~~~ - * Units: bool - * Default: on - * Flags: must_restart - -Enable kernel accept-filters, if supported by the kernel. - -.. _ref_param_acceptor_sleep_decay: - -acceptor_sleep_decay -~~~~~~~~~~~~~~~~~~~~ - * Default: 0.9 - * Minimum: 0 - * Maximum: 1 - * Flags: experimental - -If we run out of resources, such as file descriptors or worker threads, the acceptor will sleep between accepts. -This parameter (multiplicatively) reduces the sleep duration for each succesfull accept. (ie: 0.9 = reduce by 10%) - -.. _ref_param_acceptor_sleep_incr: - -acceptor_sleep_incr -~~~~~~~~~~~~~~~~~~~ - * Units: s - * Default: 0.001000 - * Minimum: 0.000000 - * Maximum: 1.000000 - * Flags: experimental - -If we run out of resources, such as file descriptors or worker threads, the acceptor will sleep between accepts. -This parameter control how much longer we sleep, each time we fail to accept a new connection in succession. - -.. _ref_param_acceptor_sleep_max: - -acceptor_sleep_max -~~~~~~~~~~~~~~~~~~ - * Units: s - * Default: 0.050000 - * Minimum: 0.000000 - * Maximum: 10.000000 - * Flags: experimental - -If we run out of resources, such as file descriptors or worker threads, the acceptor will sleep between accepts. -This parameter limits how long it can sleep between attempts to accept new connections. - -.. _ref_param_auto_restart: - -auto_restart -~~~~~~~~~~~~ - * Units: bool - * Default: on - -Restart child process automatically if it dies. This is not related to restarts in VCL. - -.. _ref_param_ban_dups: - -ban_dups -~~~~~~~~ - * Units: bool - * Default: on - -Detect and eliminate duplicate bans. - -.. _ref_param_ban_lurker_sleep: - -ban_lurker_sleep -~~~~~~~~~~~~~~~~ - * Units: s - * Default: 0.010000 - * Minimum: 0.000000 - -How long time does the ban lurker thread sleep between successful attempts to push the last item up the ban list. It always sleeps a second when nothing can be done. -A value of zero disables the ban lurker. - -.. _ref_param_between_bytes_timeout: - -between_bytes_timeout -~~~~~~~~~~~~~~~~~~~~~ - * Units: s - * Default: 60.000000 - * Minimum: 0.000000 - -Default timeout between bytes when receiving data from backend. We only wait for this many seconds between bytes before giving up. A value of 0 means it will never time out. VCL can override this default value for each backend request and backend request. This parameter does not apply to pipe mode. - -.. _ref_param_busyobj_worker_cache: - -busyobj_worker_cache -~~~~~~~~~~~~~~~~~~~~ - * Units: bool - * Default: off - -Cache free busyobj per worker thread. Disable this if you have very high hitrates and want to save the memory of one busyobj per worker thread. - -.. _ref_param_cc_command: - -cc_command -~~~~~~~~~~ - * Default: "exec clang -std=gnu99 -Qunused-arguments -D_THREAD_SAFE -pthread -fpic -shared -Wl,-x -o %o %s" - * Flags: must_reload - -Command used for compiling the C source code to a dlopen(3) loadable object. Any occurrence of %s in the string will be replaced with the source file name, and %o will be replaced with the output file name. - -.. _ref_param_cli_buffer: - -cli_buffer -~~~~~~~~~~ - * Units: bytes - * Default: 8k - * Minimum: 4k - -Size of buffer for CLI command input. -You may need to increase this if you have big VCL files and use the vcl.inline CLI command. -NB: Must be specified with -p to have an effect. - -.. _ref_param_cli_limit: - -cli_limit -~~~~~~~~~ - * Units: bytes - * Default: 48k - * Minimum: 128b - * Maximum: 99999999b - -Maximum size of CLI response. If the response exceeds this limit, the reponse code will be 201 instead of 200 and the last line will indicate the truncation. - -.. _ref_param_cli_timeout: - -cli_timeout -~~~~~~~~~~~ - * Units: seconds - * Default: 10 - * Minimum: 0 - -Timeout for CLI requests from the parent to the child process. If this timeout expires before the child responds, the master process will terminate the child process. The setting of auto_restart determines if it will get restarted automatically. - -.. _ref_param_clock_skew: - -clock_skew -~~~~~~~~~~ - * Units: s - * Default: 10 - * Minimum: 0 - -How much clockskew we are willing to accept between the backend and our own clock. - -.. _ref_param_connect_timeout: - -connect_timeout -~~~~~~~~~~~~~~~ - * Units: s - * Default: 3.500000 - * Minimum: 0.000000 - -Default connection timeout for backend connections. We only try to connect to the backend for this many seconds before giving up. VCL can override this default value for each backend and backend request. - -.. _ref_param_critbit_cooloff: - -critbit_cooloff -~~~~~~~~~~~~~~~ - * Units: s - * Default: 180.000000 - * Minimum: 60.000000 - * Maximum: 254.000000 - * Flags: wizard - -How long time the critbit hasher keeps deleted objheads on the cooloff list. - -.. _ref_param_debug: - -debug -~~~~~ - * Default: none - -Enable/Disable various kinds of debugging. - - *none* - Disable all debugging - -Use +/- prefix to set/reset individual bits: - - *req_state* - VSL Request state engine - - *workspace* - VSL Workspace operations - - *waiter* - VSL Waiter internals - - *waitinglist* - VSL Waitinglist events - - *syncvsl* - Make VSL synchronous - - *hashedge* - Edge cases in Hash - - *vclrel* - Rapid VCL release - - *lurker* - VSL Ban lurker - - *esi_chop* - Chop ESI fetch to bits - -.. _ref_param_default_grace: - -default_grace -~~~~~~~~~~~~~ - * Units: seconds - * Default: 10.000000 - * Minimum: 0.000000 - * Flags: - -Default grace period. We will deliver an object this long after it has expired, provided another thread is attempting to get a new copy. - -.. _ref_param_default_keep: - -default_keep -~~~~~~~~~~~~ - * Units: seconds - * Default: 0.000000 - * Minimum: 0.000000 - * Flags: - -Default keep period. We will keep a useless object around this long, making it available for conditional backend fetches. That means that the object will be removed from the cache at the end of ttl+grace+keep. - -.. _ref_param_default_ttl: - -default_ttl -~~~~~~~~~~~ - * Units: seconds - * Default: 20.000000 - * Minimum: 0.000000 - * Flags: - -The TTL assigned to objects if neither the backend nor the VCL code assigns one. - -.. _ref_param_feature: - -feature -~~~~~~~ - * Default: none - -Enable/Disable various minor features. - - *none* - Disable all features. - -Use +/- prefix to enable/disable individual feature: - - *short_panic* - Short panic message. - - *wait_silo* - Wait for persistent silo. - - *no_coredump* - No coredumps. - - *esi_ignore_https* - Treat HTTPS as HTTP in ESI:includes - - *esi_disable_xml_check* - Don't check of body looks like XML - - *esi_ignore_other_elements* - Ignore non-esi XML-elements - - *esi_remove_bom* - Remove UTF-8 BOM - -.. _ref_param_fetch_chunksize: - -fetch_chunksize -~~~~~~~~~~~~~~~ - * Units: bytes - * Default: 128k - * Minimum: 4k - * Flags: experimental - -The default chunksize used by fetcher. This should be bigger than the majority of objects with short TTLs. -Internal limits in the storage_file module makes increases above 128kb a dubious idea. - -.. _ref_param_fetch_maxchunksize: - -fetch_maxchunksize -~~~~~~~~~~~~~~~~~~ - * Units: bytes - * Default: 0.25G - * Minimum: 64k - * Flags: experimental - -The maximum chunksize we attempt to allocate from storage. Making this too large may cause delays and storage fragmentation. - -.. _ref_param_first_byte_timeout: - -first_byte_timeout -~~~~~~~~~~~~~~~~~~ - * Units: s - * Default: 60.000000 - * Minimum: 0.000000 - -Default timeout for receiving first byte from backend. We only wait for this many seconds for the first byte before giving up. A value of 0 means it will never time out. VCL can override this default value for each backend and backend request. This parameter does not apply to pipe. - -.. _ref_param_group: - -group -~~~~~ - * Default: nogroup (65533) - * Flags: must_restart - -The unprivileged group to run as. - -.. _ref_param_gzip_buffer: - -gzip_buffer -~~~~~~~~~~~ - * Units: bytes - * Default: 32k - * Minimum: 2k - * Flags: experimental - -Size of malloc buffer used for gzip processing. -These buffers are used for in-transit data, for instance gunzip'ed data being sent to a client.Making this space to small results in more overhead, writes to sockets etc, making it too big is probably just a waste of memory. - -.. _ref_param_gzip_level: - -gzip_level -~~~~~~~~~~ - * Default: 6 - * Minimum: 0 - * Maximum: 9 - -Gzip compression level: 0=debug, 1=fast, 9=best - -.. _ref_param_gzip_memlevel: - -gzip_memlevel -~~~~~~~~~~~~~ - * Default: 8 - * Minimum: 1 - * Maximum: 9 - -Gzip memory level 1=slow/least, 9=fast/most compression. -Memory impact is 1=1k, 2=2k, ... 9=256k. - -.. _ref_param_http_gzip_support: - -http_gzip_support -~~~~~~~~~~~~~~~~~ - * Units: bool - * Default: on - -Enable gzip support. When enabled Varnish request compressed objects from the backend and store them compressed. If a client does not support gzip encoding Varnish will uncompress compressed objects on demand. Varnish will also rewrite the Accept-Encoding header of clients indicating support for gzip to: - Accept-Encoding: gzip - -Clients that do not support gzip will have their Accept-Encoding header removed. For more information on how gzip is implemented please see the chapter on gzip in the Varnish reference. - -.. _ref_param_http_max_hdr: - -http_max_hdr -~~~~~~~~~~~~ - * Units: header lines - * Default: 64 - * Minimum: 32 - * Maximum: 65535 - -Maximum number of HTTP header lines we allow in {req|resp|bereq|beresp}.http (obj.http is autosized to the exact number of headers). -Cheap, ~20 bytes, in terms of workspace memory. -Note that the first line occupies five header lines. - -.. _ref_param_http_range_support: - -http_range_support -~~~~~~~~~~~~~~~~~~ - * Units: bool - * Default: on - -Enable support for HTTP Range headers. - -.. _ref_param_http_req_hdr_len: - -http_req_hdr_len -~~~~~~~~~~~~~~~~ - * Units: bytes - * Default: 8k - * Minimum: 40b - -Maximum length of any HTTP client request header we will allow. The limit is inclusive its continuation lines. - -.. _ref_param_http_req_size: - -http_req_size -~~~~~~~~~~~~~ - * Units: bytes - * Default: 32k - * Minimum: 0.25k - -Maximum number of bytes of HTTP client request we will deal with. This is a limit on all bytes up to the double blank line which ends the HTTP request. -The memory for the request is allocated from the client workspace (param: workspace_client) and this parameter limits how much of that the request is allowed to take up. - -.. _ref_param_http_resp_hdr_len: - -http_resp_hdr_len -~~~~~~~~~~~~~~~~~ - * Units: bytes - * Default: 8k - * Minimum: 40b - -Maximum length of any HTTP backend response header we will allow. The limit is inclusive its continuation lines. - -.. _ref_param_http_resp_size: - -http_resp_size -~~~~~~~~~~~~~~ - * Units: bytes - * Default: 32k - * Minimum: 0.25k - -Maximum number of bytes of HTTP backend resonse we will deal with. This is a limit on all bytes up to the double blank line which ends the HTTP request. -The memory for the request is allocated from the worker workspace (param: thread_pool_workspace) and this parameter limits how much of that the request is allowed to take up. - -.. _ref_param_idle_send_timeout: - -idle_send_timeout -~~~~~~~~~~~~~~~~~ - * Units: seconds - * Default: 60 - * Minimum: 0 - * Flags: delayed - -Time to wait with no data sent. If no data has been transmitted in this many -seconds the session is closed. -See setsockopt(2) under SO_SNDTIMEO for more information. - -.. _ref_param_listen_address: - -listen_address -~~~~~~~~~~~~~~ - * Default: :80 - * Flags: must_restart - -Whitespace separated list of network endpoints where Varnish will accept requests. -Possible formats: host, host:port, :port - -.. _ref_param_listen_depth: - -listen_depth -~~~~~~~~~~~~ - * Units: connections - * Default: 1024 - * Minimum: 0 - * Flags: must_restart - -Listen queue depth. - -.. _ref_param_log_local_address: - -log_local_address -~~~~~~~~~~~~~~~~~ - * Units: bool - * Default: on - -Log the local address on the TCP connection in the SessionOpen VSL record. -Disabling this saves a getsockname(2) system call per TCP connection. - -.. _ref_param_lru_interval: - -lru_interval -~~~~~~~~~~~~ - * Units: seconds - * Default: 2 - * Minimum: 0 - * Flags: experimental - -Grace period before object moves on LRU list. -Objects are only moved to the front of the LRU list if they have not been moved there already inside this timeout period. This reduces the amount of lock operations necessary for LRU list access. - -.. _ref_param_max_esi_depth: - -max_esi_depth -~~~~~~~~~~~~~ - * Units: levels - * Default: 5 - * Minimum: 0 - -Maximum depth of esi:include processing. - -.. _ref_param_max_restarts: - -max_restarts -~~~~~~~~~~~~ - * Units: restarts - * Default: 4 - * Minimum: 0 - -Upper limit on how many times a request can restart. -Be aware that restarts are likely to cause a hit against the backend, so don't increase thoughtlessly. - -.. _ref_param_max_retries: - -max_retries -~~~~~~~~~~~ - * Units: retries - * Default: 4 - * Minimum: 0 - -Upper limit on how many times a backend fetch can retry. - -.. _ref_param_nuke_limit: - -nuke_limit -~~~~~~~~~~ - * Units: allocations - * Default: 50 - * Minimum: 0 - * Flags: experimental - -Maximum number of objects we attempt to nuke in orderto make space for a object body. - -.. _ref_param_pcre_match_limit: - -pcre_match_limit -~~~~~~~~~~~~~~~~ - * Default: 10000 - * Minimum: 1 - -The limit for the number of internal matching function calls in a pcre_exec() execution. - -.. _ref_param_pcre_match_limit_recursion: - -pcre_match_limit_recursion -~~~~~~~~~~~~~~~~~~~~~~~~~~ - * Default: 10000 - * Minimum: 1 - -The limit for the number of internal matching function recursions in a pcre_exec() execution. - -.. _ref_param_ping_interval: - -ping_interval -~~~~~~~~~~~~~ - * Units: seconds - * Default: 3 - * Minimum: 0 - * Flags: must_restart - -Interval between pings from parent to child. -Zero will disable pinging entirely, which makes it possible to attach a debugger to the child. - -.. _ref_param_pipe_timeout: - -pipe_timeout -~~~~~~~~~~~~ - * Units: seconds - * Default: 60 - * Minimum: 0 - -Idle timeout for PIPE sessions. If nothing have been received in either direction for this many seconds, the session is closed. - -.. _ref_param_pool_req: - -pool_req -~~~~~~~~ - * Default: 10,100,10 - -Parameters for per worker pool request memory pool. -The three numbers are: - - *min_pool* - minimum size of free pool. - - *max_pool* - maximum size of free pool. - - *max_age* - max age of free element. - -.. _ref_param_pool_sess: - -pool_sess -~~~~~~~~~ - * Default: 10,100,10 - -Parameters for per worker pool session memory pool. -The three numbers are: - - *min_pool* - minimum size of free pool. - - *max_pool* - maximum size of free pool. - - *max_age* - max age of free element. - -.. _ref_param_pool_vbc: - -pool_vbc -~~~~~~~~ - * Default: 10,100,10 - -Parameters for backend connection memory pool. -The three numbers are: - - *min_pool* - minimum size of free pool. - - *max_pool* - maximum size of free pool. - - *max_age* - max age of free element. - -.. _ref_param_pool_vbo: - -pool_vbo -~~~~~~~~ - * Default: 10,100,10 - -Parameters for backend object fetch memory pool. -The three numbers are: - - *min_pool* - minimum size of free pool. - - *max_pool* - maximum size of free pool. - - *max_age* - max age of free element. - -.. _ref_param_prefer_ipv6: - -prefer_ipv6 -~~~~~~~~~~~ - * Units: bool - * Default: off - -Prefer IPv6 address when connecting to backends which have both IPv4 and IPv6 addresses. - -.. _ref_param_rush_exponent: - -rush_exponent -~~~~~~~~~~~~~ - * Units: requests per request - * Default: 3 - * Minimum: 2 - * Flags: experimental - -How many parked request we start for each completed request on the object. -NB: Even with the implict delay of delivery, this parameter controls an exponential increase in number of worker threads. - -.. _ref_param_send_timeout: - -send_timeout -~~~~~~~~~~~~ - * Units: seconds - * Default: 600 - * Minimum: 0 - * Flags: delayed - -Send timeout for client connections. If the HTTP response hasn't been transmitted in this many -seconds the session is closed. -See setsockopt(2) under SO_SNDTIMEO for more information. - -.. _ref_param_session_max: - -session_max -~~~~~~~~~~~ - * Units: sessions - * Default: 100000 - * Minimum: 1000 - -Maximum number of sessions we will allocate from one pool before just dropping connections. -This is mostly an anti-DoS measure, and setting it plenty high should not hurt, as long as you have the memory for it. - -.. _ref_param_shm_reclen: - -shm_reclen -~~~~~~~~~~ - * Units: bytes - * Default: 255b - * Minimum: 16b - * Maximum: 65535b - -Maximum number of bytes in SHM log record. -Maximum is 65535 bytes. - -.. _ref_param_shortlived: - -shortlived -~~~~~~~~~~ - * Units: s - * Default: 10.000000 - * Minimum: 0.000000 - -Objects created with TTL shorter than this are always put in transient storage. - -.. _ref_param_sigsegv_handler: - -sigsegv_handler -~~~~~~~~~~~~~~~ - * Units: bool - * Default: off - * Flags: must_restart - -Install a signal handler which tries to dump debug information on segmentation faults. - -.. _ref_param_syslog_cli_traffic: - -syslog_cli_traffic -~~~~~~~~~~~~~~~~~~ - * Units: bool - * Default: on - -Log all CLI traffic to syslog(LOG_INFO). - -.. _ref_param_tcp_keepalive_intvl: - -tcp_keepalive_intvl -~~~~~~~~~~~~~~~~~~~ - * Units: seconds - * Default: 5 - * Minimum: 1 - * Maximum: 100 - * Flags: experimental - -The number of seconds between TCP keep-alive probes. Note that this setting will only take effect when it is less thanthe system default. - -.. _ref_param_tcp_keepalive_probes: - -tcp_keepalive_probes -~~~~~~~~~~~~~~~~~~~~ - * Units: probes - * Default: 5 - * Minimum: 1 - * Maximum: 100 - * Flags: experimental - -The maximum number of TCP keep-alive probes to send before giving up and killing the connection if no response is obtained from the other end. Note that this setting will only take effect when it is less than the system default. - -.. _ref_param_tcp_keepalive_time: - -tcp_keepalive_time -~~~~~~~~~~~~~~~~~~ - * Units: seconds - * Default: 600 - * Minimum: 1 - * Maximum: 7200 - * Flags: experimental - -The number of seconds a connection needs to be idle before TCP begins sending out keep-alive probes. Note that this setting will only take effect when it is less than the system default. - -.. _ref_param_thread_pool_add_delay: - -thread_pool_add_delay -~~~~~~~~~~~~~~~~~~~~~ - * Units: seconds - * Default: 0.000000 - * Minimum: 0.000000 - * Flags: experimental - -Wait at least this long after creating a thread. - -Some (buggy) systems may need a short (sub-second) delay between creating threads. -Set this to a few milliseconds if you see the 'threads_failed' counter grow too much. - -Setting this too high results in insuffient worker threads. - -.. _ref_param_thread_pool_destroy_delay: - -thread_pool_destroy_delay -~~~~~~~~~~~~~~~~~~~~~~~~~ - * Units: seconds - * Default: 1.000000 - * Minimum: 0.010000 - * Flags: delayed, experimental - -Wait this long after destroying a thread. - -This controls the decay of thread pools when idle(-ish). - -Minimum is 0.01 second. - -.. _ref_param_thread_pool_fail_delay: - -thread_pool_fail_delay -~~~~~~~~~~~~~~~~~~~~~~ - * Units: seconds - * Default: 0.200000 - * Minimum: 0.010000 - * Flags: experimental - -Wait at least this long after a failed thread creation before trying to create another thread. - -Failure to create a worker thread is often a sign that the end is near, because the process is running out of some resource. This delay tries to not rush the end on needlessly. - -If thread creation failures are a problem, check that thread_pool_max is not too high. - -It may also help to increase thread_pool_timeout and thread_pool_min, to reduce the rate at which treads are destroyed and later recreated. - -.. _ref_param_thread_pool_max: - -thread_pool_max -~~~~~~~~~~~~~~~ - * Units: threads - * Default: 5000 - * Minimum: 10 - * Flags: delayed - -The maximum number of worker threads in each pool. - -Do not set this higher than you have to, since excess worker threads soak up RAM and CPU and generally just get in the way of getting work done. - -Minimum is 10 threads. - -.. _ref_param_thread_pool_min: - -thread_pool_min -~~~~~~~~~~~~~~~ - * Units: threads - * Default: 100 - * Minimum: 10 - * Flags: delayed - -The minimum number of worker threads in each pool. - -Increasing this may help ramp up faster from low load situations or when threads have expired. - -Minimum is 10 threads. - -.. _ref_param_thread_pool_stack: - -thread_pool_stack -~~~~~~~~~~~~~~~~~ - * Units: bytes - * Default: 48k - * Minimum: 2k - * Flags: experimental - -Worker thread stack size. -This is likely rounded up to a multiple of 4k by the kernel. -The kernel/OS has a lower limit which will be enforced. - -.. _ref_param_thread_pool_timeout: - -thread_pool_timeout -~~~~~~~~~~~~~~~~~~~ - * Units: seconds - * Default: 300.000000 - * Minimum: 10.000000 - * Flags: delayed, experimental - -Thread idle threshold. - -Threads in excess of thread_pool_min, which have been idle for at least this long, will be destroyed. - -Minimum is 10 seconds. - -.. _ref_param_thread_pools: - -thread_pools -~~~~~~~~~~~~ - * Units: pools - * Default: 2 - * Minimum: 1 - * Flags: delayed, experimental - -Number of worker thread pools. - -Increasing number of worker pools decreases lock contention. - -Too many pools waste CPU and RAM resources, and more than one pool for each CPU is probably detrimal to performance. - -Can be increased on the fly, but decreases require a restart to take effect. - -.. _ref_param_thread_queue_limit: - -thread_queue_limit -~~~~~~~~~~~~~~~~~~ - * Default: 20 - * Minimum: 0 - * Flags: experimental - -Permitted queue length per thread-pool. - -This sets the number of requests we will queue, waiting for an available thread. Above this limit sessions will be dropped instead of queued. - -.. _ref_param_thread_stats_rate: - -thread_stats_rate -~~~~~~~~~~~~~~~~~ - * Units: requests - * Default: 10 - * Minimum: 0 - * Flags: experimental - -Worker threads accumulate statistics, and dump these into the global stats counters if the lock is free when they finish a request. -This parameters defines the maximum number of requests a worker thread may handle, before it is forced to dump its accumulated stats into the global counters. - -.. _ref_param_timeout_idle: - -timeout_idle -~~~~~~~~~~~~ - * Units: seconds - * Default: 5.000000 - * Minimum: 0.000000 - -Idle timeout for client connections. -A connection is considered idle, until we receive a non-white-space character on it. - -.. _ref_param_timeout_linger: - -timeout_linger -~~~~~~~~~~~~~~ - * Units: seconds - * Default: 0.050000 - * Minimum: 0.000000 - * Flags: experimental - -How long time the workerthread lingers on an idle session before handing it over to the waiter. -When sessions are reused, as much as half of all reuses happen within the first 100 msec of the previous request completing. -Setting this too high results in worker threads not doing anything for their keep, setting it too low just means that more sessions take a detour around the waiter. - -.. _ref_param_timeout_req: - -timeout_req -~~~~~~~~~~~ - * Units: seconds - * Default: 2.000000 - * Minimum: 0.000000 - -Max time to receive clients request header, measured from first non-white-space character to double CRNL. - -.. _ref_param_user: - -user -~~~~ - * Default: nobody (65534) - * Flags: must_restart - -The unprivileged user to run as. - -.. _ref_param_vcc_allow_inline_c: - -vcc_allow_inline_c -~~~~~~~~~~~~~~~~~~ - * Units: bool - * Default: off - -Allow inline C code in VCL. - -.. _ref_param_vcc_err_unref: - -vcc_err_unref -~~~~~~~~~~~~~ - * Units: bool - * Default: on - -Unreferenced VCL objects result in error. - -.. _ref_param_vcc_unsafe_path: - -vcc_unsafe_path -~~~~~~~~~~~~~~~ - * Units: bool - * Default: on - -Allow '/' in vmod & include paths. -Allow 'import ... from ...'. - -.. _ref_param_vcl_dir: - -vcl_dir -~~~~~~~ - * Default: /opt/varnish/etc/varnish - -Directory from which relative VCL filenames (vcl.load and include) are opened. - -.. _ref_param_vmod_dir: - -vmod_dir -~~~~~~~~ - * Default: /opt/varnish/lib/varnish/vmods - -Directory where VCL modules are to be found. - -.. _ref_param_vsl_buffer: - -vsl_buffer -~~~~~~~~~~ - * Units: bytes - * Default: 4k - * Minimum: 1k - -Bytes of (req-/backend-)workspace dedicated to buffering VSL records. -At a bare minimum, this must be longer than the longest HTTP header to be logged. -Setting this too high costs memory, setting it too low will cause more VSL flushes and likely increase lock-contention on the VSL mutex. -Minimum is 1k bytes. - -.. _ref_param_vsl_mask: - -vsl_mask -~~~~~~~~ - * Default: -VCL_trace,-WorkThread,-Hash - -Mask individual VSL messages from being logged. - - *default* - Set default value - -Use +/- prefixe in front of VSL tag name, to mask/unmask individual VSL messages. - -.. _ref_param_vsl_space: - -vsl_space -~~~~~~~~~ - * Units: bytes - * Default: 80M - * Minimum: 1M - * Flags: must_restart - -The amount of space to allocate for the VSL fifo buffer in the VSM memory segment. If you make this too small, varnish{ncsa|log} etc will not be able to keep up. Making it too large just costs memory resources. - -.. _ref_param_vsm_space: - -vsm_space -~~~~~~~~~ - * Units: bytes - * Default: 1M - * Minimum: 1M - * Flags: must_restart - -The amount of space to allocate for stats counters in the VSM memory segment. If you make this too small, some counters will be invisible. Making it too large just costs memory resources. - -.. _ref_param_waiter: - -waiter -~~~~~~ - * Default: kqueue (possible values: kqueue, poll) - * Flags: must_restart, wizard - -Select the waiter kernel interface. - -.. _ref_param_workspace_backend: - -workspace_backend -~~~~~~~~~~~~~~~~~ - * Units: bytes - * Default: 64k - * Minimum: 1k - * Flags: delayed - -Bytes of HTTP protocol workspace for backend HTTP req/resp. If larger than 4k, use a multiple of 4k for VM efficiency. - -.. _ref_param_workspace_client: - -workspace_client -~~~~~~~~~~~~~~~~ - * Units: bytes - * Default: 64k - * Minimum: 3k - * Flags: delayed - -Bytes of HTTP protocol workspace for clients HTTP req/resp. If larger than 4k, use a multiple of 4k for VM efficiency. - -.. _ref_param_workspace_thread: - -workspace_thread -~~~~~~~~~~~~~~~~ - * Units: bytes - * Default: 2k - * Minimum: 0.25k - * Maximum: 8k - * Flags: delayed - -Bytes of auxillary workspace per thread. -This workspace is used for certain temporary data structures during the operation of a worker thread. -One use is for the io-vectors for writing requests and responses to sockets, having too little space will result in more writev(2) system calls, having too much just wastes the space. - From tfheen at err.no Wed Feb 5 12:14:19 2014 From: tfheen at err.no (Tollef Fog Heen) Date: Wed, 05 Feb 2014 13:14:19 +0100 Subject: [master] 2abb545 Build man from man/ and add params.rst to BUILT_OBJECTS Message-ID: commit 2abb545829d9a494360b020cd5efcf5cb2a0a07c Author: Tollef Fog Heen Date: Wed Feb 5 13:14:16 2014 +0100 Build man from man/ and add params.rst to BUILT_OBJECTS diff --git a/Makefile.am b/Makefile.am index 66c9e03..2eb3af4 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,6 +1,6 @@ ACLOCAL_AMFLAGS = -I m4 -SUBDIRS = include lib bin man etc doc +SUBDIRS = include lib bin etc doc man SUBDIRS += redhat diff --git a/bin/varnishd/Makefile.am b/bin/varnishd/Makefile.am index e0a8461..8cd8cf5 100644 --- a/bin/varnishd/Makefile.am +++ b/bin/varnishd/Makefile.am @@ -8,8 +8,6 @@ AM_CPPFLAGS = \ sbin_PROGRAMS = varnishd -dist_man_MANS = varnishd.1 - varnishd_SOURCES = \ cache/cache_acceptor.c \ cache/cache_backend.c \ @@ -146,13 +144,3 @@ builtin_vcl.h: builtin.vcl # Explicitly record dependency mgt/mgt_vcc.c: builtin_vcl.h - -varnishd.1: $(top_srcdir)/doc/sphinx/reference/varnishd.rst -if HAVE_RST2MAN - ${RST2MAN} $? $@ -else - @echo "========================================" - @echo "You need rst2man installed to make dist" - @echo "========================================" - @false -endif diff --git a/doc/sphinx/Makefile.am b/doc/sphinx/Makefile.am index 692cf6f..df3d3c4 100644 --- a/doc/sphinx/Makefile.am +++ b/doc/sphinx/Makefile.am @@ -176,5 +176,8 @@ dist-hook: distclean-local: rm -rf $(BUILDDIR) -reference/params.rst: +reference/params.rst: $(top_builddir)/bin/varnishd/varnishd + mkdir -p reference $(top_builddir)/bin/varnishd/varnishd -x dumprstparam > reference/params.rst + +BUILT_SOURCES = reference/params.rst diff --git a/man/Makefile.am b/man/Makefile.am index 1ed3a5d..7d0b1f6 100644 --- a/man/Makefile.am +++ b/man/Makefile.am @@ -8,7 +8,7 @@ vsc2rst_SOURCES = vsc2rst.c \ AM_CPPFLAGS = -I$(top_srcdir)/include -dist_man_MANS = vcl.7 varnish-cli.7 varnish-counters.7 vsl.7 vsl-query.7 +dist_man_MANS = vcl.7 varnish-cli.7 varnish-counters.7 vsl.7 vsl-query.7 varnishd.1 MAINTAINERCLEANFILES = $(dist_man_MANS) vcl.7: $(top_srcdir)/doc/sphinx/reference/vcl.rst \ @@ -63,3 +63,13 @@ else @echo "========================================" @false endif + +varnishd.1: $(top_srcdir)/doc/sphinx/reference/varnishd.rst +if HAVE_RST2MAN + ${RST2MAN} $^ $@ +else + @echo "========================================" + @echo "You need rst2man installed to make dist" + @echo "========================================" + @false +endif From tfheen at err.no Wed Feb 5 12:50:29 2014 From: tfheen at err.no (Tollef Fog Heen) Date: Wed, 05 Feb 2014 13:50:29 +0100 Subject: [master] c191685 Ensure source tree is built before running make dist Message-ID: commit c191685566820de1ce5da2bcf49a5bc3d7537e5c Author: Tollef Fog Heen Date: Wed Feb 5 13:50:27 2014 +0100 Ensure source tree is built before running make dist diff --git a/Makefile.am b/Makefile.am index 2eb3af4..2aa609f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -36,6 +36,11 @@ distcleancheck_listfiles = \ find . -type f -exec sh -c 'test -f $(srcdir)/$$1 || echo $$1' \ sh '{}' ';' +# XXX: This is a hack to ensure we have a built source tree when +# running make dist If we had used non-recursive make we could have +# solved it better, but we don't, so use this at least for now. +LICENSE: all + cscope: -rm -f cscope* find . -name '*.[hcS]' > cscope.files From phk at FreeBSD.org Wed Feb 5 14:28:32 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 05 Feb 2014 15:28:32 +0100 Subject: [master] 090e84c Fix an oversight which disabled TTL calculation on IMS fetches. Message-ID: commit 090e84c5a28397ad7e4b2ac6fbfdbb58bc712882 Author: Poul-Henning Kamp Date: Wed Feb 5 14:27:37 2014 +0000 Fix an oversight which disabled TTL calculation on IMS fetches. Also make sure that objects marked uncacheable on an IMS is treated as such. diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 9bbc6c1..fa58309 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -271,7 +271,7 @@ vbf_stp_fetchhdr(struct worker *wrk, struct busyobj *bo) if (bo->do_esi) bo->do_stream = 0; - if (bo->do_pass) + if (bo->do_pass || bo->uncacheable) bo->fetch_objcore->flags |= OC_F_PASS; assert(wrk->handling == VCL_RET_DELIVER); diff --git a/bin/varnishd/cache/cache_rfc2616.c b/bin/varnishd/cache/cache_rfc2616.c index dcf4c55..5334291 100644 --- a/bin/varnishd/cache/cache_rfc2616.c +++ b/bin/varnishd/cache/cache_rfc2616.c @@ -117,6 +117,7 @@ RFC2616_Ttl(struct busyobj *bo) case 300: /* Multiple Choices */ case 301: /* Moved Permanently */ case 302: /* Moved Temporarily */ + case 304: /* Not Modified */ case 307: /* Temporary Redirect */ case 410: /* Gone */ case 404: /* Not Found */ diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index 5d875ed..2b1629a 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -181,6 +181,7 @@ VRT_l_beresp_uncacheable(const struct vrt_ctx *ctx, unsigned a) VSLb(ctx->vsl, SLT_VCL_Error, "Ignoring attempt to reset beresp.uncacheable"); } else if (a) { + VSLb(ctx->vsl, SLT_Debug, "XXXX: UNCACHEABLE %u" , a); ctx->bo->uncacheable = a; } } From tfheen at err.no Wed Feb 5 14:34:34 2014 From: tfheen at err.no (Tollef Fog Heen) Date: Wed, 05 Feb 2014 15:34:34 +0100 Subject: [master] b5929ad Move doc generation into doc/sphinx and man Message-ID: commit b5929ad76db05b36876c91f990e2d043106c72b4 Author: Tollef Fog Heen Date: Wed Feb 5 15:34:25 2014 +0100 Move doc generation into doc/sphinx and man diff --git a/.gitignore b/.gitignore index 78cdba5..35dfbe7 100644 --- a/.gitignore +++ b/.gitignore @@ -76,32 +76,19 @@ cscope.*out # Man-files and binaries /man/vsc2rst -/man/vcl.7 -/man/vsl.7 -/man/vsl-query.7 -/man/varnish-cli.7 -/man/varnish-counters.7 +/man/*.7 +/man/*.1 +/doc/sphinx/include /bin/varnish*/varnish*_opt2rst /bin/varnishadm/varnishadm -/bin/varnishadm/varnishadm.1 /bin/varnishd/varnishd -/bin/varnishd/varnishd.1 /bin/varnishhist/varnishhist -/bin/varnishhist/varnishhist.1 /bin/varnishlog/varnishlog -/bin/varnishlog/varnishlog.1 -/bin/varnishlog/varnishlog_*.rst /bin/varnishncsa/varnishncsa -/bin/varnishncsa/varnishncsa.1 -/bin/varnishncsa/varnishncsa_*.rst /bin/varnishreplay/varnishreplay -/bin/varnishreplay/varnishreplay.1 /bin/varnishstat/varnishstat -/bin/varnishstat/varnishstat.1 /bin/varnishtest/varnishtest -/bin/varnishtest/varnishtest.1 /bin/varnishtop/varnishtop -/bin/varnishtop/varnishtop.1 # Doc-stuff generated from xml /doc/*.html diff --git a/Makefile.am b/Makefile.am index 2aa609f..389be99 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,8 +1,6 @@ ACLOCAL_AMFLAGS = -I m4 -SUBDIRS = include lib bin etc doc man - -SUBDIRS += redhat +SUBDIRS = include lib bin etc doc redhat pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = varnishapi.pc @@ -22,6 +20,16 @@ DISTCHECK_CONFIGURE_FLAGS = \ install-data-local: $(install_sh) -d -m 0755 $(DESTDIR)$(localstatedir)/varnish +if HAVE_RST2MAN +SUBDIRS += man +else +dist-hook: + @echo "========================================" + @echo "You need rst2man installed to make dist" + @echo "========================================" + @false +endif + distcheck-hook: V="@PACKAGE_VERSION@" ; \ V="$${V%%-*}" ; \ diff --git a/bin/varnishadm/Makefile.am b/bin/varnishadm/Makefile.am index 8fb28d7..f3050eb 100644 --- a/bin/varnishadm/Makefile.am +++ b/bin/varnishadm/Makefile.am @@ -4,8 +4,6 @@ AM_CPPFLAGS = -I$(top_srcdir)/include bin_PROGRAMS = varnishadm -dist_man_MANS = varnishadm.1 - varnishadm_SOURCES = \ varnishadm.c \ $(top_builddir)/lib/libvarnish/vas.c \ @@ -19,13 +17,3 @@ varnishadm_LDADD = \ $(top_builddir)/lib/libvarnishapi/libvarnishapi.la \ $(top_builddir)/lib/libvarnishcompat/libvarnishcompat.la \ ${PTHREAD_LIBS} ${RT_LIBS} ${NET_LIBS} @LIBEDIT_LIBS@ ${LIBM} - -varnishadm.1: $(top_srcdir)/doc/sphinx/reference/varnishadm.rst -if HAVE_RST2MAN - ${RST2MAN} $? $@ -else - @echo "========================================" - @echo "You need rst2man installed to make dist" - @echo "========================================" - @false -endif diff --git a/bin/varnishhist/Makefile.am b/bin/varnishhist/Makefile.am index 5423155..9511a6e 100644 --- a/bin/varnishhist/Makefile.am +++ b/bin/varnishhist/Makefile.am @@ -4,8 +4,6 @@ AM_CPPFLAGS = -I$(top_srcdir)/include bin_PROGRAMS = varnishhist -dist_man_MANS = varnishhist.1 - varnishhist_SOURCES = varnishhist.c \ $(top_builddir)/lib/libvarnish/vas.c \ $(top_builddir)/lib/libvarnish/version.c @@ -15,13 +13,3 @@ varnishhist_LDADD = \ $(top_builddir)/lib/libvarnishapi/libvarnishapi.la \ -lm \ @CURSES_LIB@ ${RT_LIBS} ${PTHREAD_LIBS} - -varnishhist.1: $(top_srcdir)/doc/sphinx/reference/varnishhist.rst -if HAVE_RST2MAN - ${RST2MAN} $? $@ -else - @echo "========================================" - @echo "You need rst2man installed to make dist" - @echo "========================================" - @false -endif diff --git a/bin/varnishlog/Makefile.am b/bin/varnishlog/Makefile.am index a757b61..1e6fa79 100644 --- a/bin/varnishlog/Makefile.am +++ b/bin/varnishlog/Makefile.am @@ -4,8 +4,6 @@ AM_CPPFLAGS = -I$(top_srcdir)/include bin_PROGRAMS = varnishlog -dist_man_MANS = varnishlog.1 - varnishlog_SOURCES = \ varnishlog.c \ varnishlog_options.h \ @@ -28,29 +26,3 @@ varnishlog_opt2rst_SOURCES = \ varnishlog_options.h \ varnishlog_options.c \ $(top_srcdir)/lib/libvarnishtools/opt2rst.c - -BUILT_SOURCES = varnishlog_options.rst varnishlog_synopsis.rst -EXTRA_DIST = $(BUILT_SOURCES) -MAINTAINERCLEANFILES = $(EXTRA_DIST) - -varnishlog_options.rst: - ./varnishlog_opt2rst options > $@ -varnishlog_synopsis.rst: - ./varnishlog_opt2rst synopsis > $@ - -if HAVE_RST2MAN -varnishlog_options.rst varnishlog_synopsis.rst: varnishlog_opt2rst -endif - -varnishlog.1: \ - $(top_srcdir)/doc/sphinx/reference/varnishlog.rst \ - varnishlog_options.rst \ - varnishlog_synopsis.rst -if HAVE_RST2MAN - ${RST2MAN} $(top_srcdir)/doc/sphinx/reference/varnishlog.rst $@ -else - @echo "========================================" - @echo "You need rst2man installed to make dist" - @echo "========================================" - @false -endif diff --git a/bin/varnishncsa/Makefile.am b/bin/varnishncsa/Makefile.am index 6f3a7f9..12a3f4d 100644 --- a/bin/varnishncsa/Makefile.am +++ b/bin/varnishncsa/Makefile.am @@ -4,8 +4,6 @@ AM_CPPFLAGS = -I$(top_srcdir)/include bin_PROGRAMS = varnishncsa -dist_man_MANS = varnishncsa.1 - varnishncsa_SOURCES = \ varnishncsa.c \ varnishncsa_options.h \ @@ -30,29 +28,3 @@ varnishncsa_opt2rst_SOURCES = \ varnishncsa_options.h \ varnishncsa_options.c \ $(top_srcdir)/lib/libvarnishtools/opt2rst.c - -BUILT_SOURCES = varnishncsa_options.rst varnishncsa_synopsis.rst -EXTRA_DIST = $(BUILT_SOURCES) -MAINTAINERCLEANFILES = $(EXTRA_DIST) - -varnishncsa_options.rst: - ./varnishncsa_opt2rst options > $@ -varnishncsa_synopsis.rst: - ./varnishncsa_opt2rst synopsis > $@ - -if HAVE_RST2MAN -varnishncsa_options.rst varnishncsa_synopsis.rst: varnishncsa_opt2rst -endif - -varnishncsa.1: \ - $(top_srcdir)/doc/sphinx/reference/varnishncsa.rst \ - varnishncsa_options.rst \ - varnishncsa_synopsis.rst -if HAVE_RST2MAN - ${RST2MAN} $(top_srcdir)/doc/sphinx/reference/varnishncsa.rst $@ -else - @echo "========================================" - @echo "You need rst2man installed to make dist" - @echo "========================================" - @false -endif diff --git a/bin/varnishreplay/Makefile.am b/bin/varnishreplay/Makefile.am index 59c6a0d..72a293d 100644 --- a/bin/varnishreplay/Makefile.am +++ b/bin/varnishreplay/Makefile.am @@ -4,8 +4,6 @@ AM_CPPFLAGS = -I$(top_srcdir)/include bin_PROGRAMS = varnishreplay -dist_man_MANS = varnishreplay.1 - varnishreplay_SOURCES = \ varnishreplay.c \ $(top_builddir)/lib/libvarnish/vas.c \ @@ -16,13 +14,3 @@ varnishreplay_LDADD = \ $(top_builddir)/lib/libvarnishcompat/libvarnishcompat.la \ $(top_builddir)/lib/libvarnishapi/libvarnishapi.la \ ${RT_LIBS} ${PTHREAD_LIBS} ${NET_LIBS} ${LIBM} - -varnishreplay.1: $(top_srcdir)/doc/sphinx/reference/varnishreplay.rst -if HAVE_RST2MAN - ${RST2MAN} $? $@ -else - @echo "========================================" - @echo "You need rst2man installed to make dist" - @echo "========================================" - @false -endif diff --git a/bin/varnishstat/Makefile.am b/bin/varnishstat/Makefile.am index d22edac..fe17250 100644 --- a/bin/varnishstat/Makefile.am +++ b/bin/varnishstat/Makefile.am @@ -4,8 +4,6 @@ AM_CPPFLAGS = -I$(top_srcdir)/include bin_PROGRAMS = varnishstat -dist_man_MANS = varnishstat.1 - varnishstat_SOURCES = \ varnishstat.h \ \ @@ -19,13 +17,3 @@ varnishstat_LDADD = \ $(top_builddir)/lib/libvarnishcompat/libvarnishcompat.la \ $(top_builddir)/lib/libvarnishapi/libvarnishapi.la \ @CURSES_LIB@ ${RT_LIBS} ${LIBM} ${PTHREAD_LIBS} - -varnishstat.1: $(top_srcdir)/doc/sphinx/reference/varnishstat.rst -if HAVE_RST2MAN - ${RST2MAN} $? $@ -else - @echo "========================================" - @echo "You need rst2man installed to make dist" - @echo "========================================" - @false -endif diff --git a/bin/varnishtest/Makefile.am b/bin/varnishtest/Makefile.am index b51d822..5af8068 100644 --- a/bin/varnishtest/Makefile.am +++ b/bin/varnishtest/Makefile.am @@ -19,8 +19,6 @@ AM_CPPFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/lib/libvgz bin_PROGRAMS = varnishtest -dist_man_MANS = varnishtest.1 - varnishtest_SOURCES = \ vtc.c \ vtc.h \ @@ -47,13 +45,3 @@ varnishtest_CFLAGS = \ EXTRA_DIST = $(top_srcdir)/bin/varnishtest/tests/*.vtc \ $(top_srcdir)/bin/varnishtest/tests/README - -varnishtest.1: $(top_srcdir)/doc/sphinx/reference/varnishtest.rst -if HAVE_RST2MAN - ${RST2MAN} $? $@ -else - @echo "========================================" - @echo "You need rst2man installed to make dist" - @echo "========================================" - @false -endif diff --git a/bin/varnishtop/Makefile.am b/bin/varnishtop/Makefile.am index a38e293..b919dba 100644 --- a/bin/varnishtop/Makefile.am +++ b/bin/varnishtop/Makefile.am @@ -4,8 +4,6 @@ AM_CPPFLAGS = -I$(top_srcdir)/include bin_PROGRAMS = varnishtop -dist_man_MANS = varnishtop.1 - varnishtop_SOURCES = varnishtop.c \ varnishtop_options.h \ varnishtop_options.c \ @@ -28,29 +26,3 @@ varnishtop_opt2rst_SOURCES = \ varnishtop_options.h \ varnishtop_options.c \ $(top_srcdir)/lib/libvarnishtools/opt2rst.c - -BUILT_SOURCES = varnishtop_options.rst varnishtop_synopsis.rst -EXTRA_DIST = $(BUILT_SOURCES) -MAINTAINERCLEANFILES = $(EXTRA_DIST) - -varnishtop_options.rst: - ./varnishtop_opt2rst options > $@ -varnishtop_synopsis.rst: - ./varnishtop_opt2rst synopsis > $@ - -if HAVE_RST2MAN -varnishtop_options.rst varnishtop_synopsis.rst: varnishtop_opt2rst -endif - -varnishtop.1: \ - $(top_srcdir)/doc/sphinx/reference/varnishtop.rst \ - varnishtop_options.rst \ - varnishtop_synopsis.rst -if HAVE_RST2MAN - ${RST2MAN} $(top_srcdir)/doc/sphinx/reference/varnishtop.rst $@ -else - @echo "========================================" - @echo "You need rst2man installed to make dist" - @echo "========================================" - @false -endif diff --git a/configure.ac b/configure.ac index 38634b9..f25b2cf 100644 --- a/configure.ac +++ b/configure.ac @@ -554,6 +554,9 @@ fi VTC_TESTS="$(cd $srcdir/bin/varnishtest && echo tests/*.vtc)" AC_SUBST(VTC_TESTS) +# Make sure this include dir exists +AC_CONFIG_COMMANDS([mkdir], [$MKDIR_P doc/sphinx/include]) + # Generate output AC_CONFIG_FILES([ Makefile diff --git a/doc/sphinx/Makefile.am b/doc/sphinx/Makefile.am index df3d3c4..7940d07 100644 --- a/doc/sphinx/Makefile.am +++ b/doc/sphinx/Makefile.am @@ -30,7 +30,7 @@ help: clean: -rm -rf $(BUILDDIR)/* -html: reference/params.rst +html: $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." @@ -112,7 +112,6 @@ EXTRA_DIST = \ phk/vcl_expr.rst \ phk/wanton_destruction.rst \ reference/index.rst \ - reference/params.rst \ reference/varnishadm.rst \ reference/varnish-cli.rst \ reference/varnishd.rst \ @@ -168,7 +167,6 @@ EXTRA_DIST = \ users-guide/vcl-variables.rst \ users-guide/websockets.rst - dist-hook: $(MAKE) html cp -r $(BUILDDIR) $(distdir) @@ -176,8 +174,30 @@ dist-hook: distclean-local: rm -rf $(BUILDDIR) -reference/params.rst: $(top_builddir)/bin/varnishd/varnishd - mkdir -p reference - $(top_builddir)/bin/varnishd/varnishd -x dumprstparam > reference/params.rst - -BUILT_SOURCES = reference/params.rst +include/params.rst: $(top_builddir)/bin/varnishd/varnishd + $(top_builddir)/bin/varnishd/varnishd -x dumprstparam > include/params.rst +BUILT_SOURCES = include/params.rst + +include/varnishncsa_options.rst: $(top_builddir)/bin/varnishncsa/varnishncsa_opt2rst + $(top_builddir)/bin/varnishncsa/varnishncsa_opt2rst options > $@ +include/varnishncsa_synopsis.rst: $(top_builddir)/bin/varnishncsa/varnishncsa_opt2rst + $(top_builddir)/bin/varnishncsa/varnishncsa_opt2rst synopsis > $@ +BUILT_SOURCES += include/varnishncsa_options.rst \ + include/varnishncsa_synopsis.rst + +include/varnishlog_options.rst: $(top_builddir)/bin/varnishlog/varnishlog_opt2rst + $(top_builddir)/bin/varnishlog/varnishlog_opt2rst options > $@ +include/varnishlog_synopsis.rst: $(top_builddir)/bin/varnishlog/varnishlog_opt2rst + $(top_builddir)/bin/varnishlog/varnishlog_opt2rst synopsis > $@ +BUILT_SOURCES += include/varnishlog_options.rst \ + include/varnishlog_synopsis.rst + +include/varnishtop_options.rst: $(top_builddir)/bin/varnishtop/varnishtop_opt2rst + $(top_builddir)/bin/varnishtop/varnishtop_opt2rst options > $@ +include/varnishtop_synopsis.rst: $(top_builddir)/bin/varnishtop/varnishtop_opt2rst + $(top_builddir)/bin/varnishtop/varnishtop_opt2rst synopsis > $@ +BUILT_SOURCES += include/varnishtop_options.rst \ + include/varnishtop_synopsis.rst + +EXTRA_DIST += $(BUILT_SOURCES) +MAINTAINERCLEANFILES = $(EXTRA_DIST) diff --git a/doc/sphinx/reference/varnishd.rst b/doc/sphinx/reference/varnishd.rst index 48fd44c..f5599c5 100644 --- a/doc/sphinx/reference/varnishd.rst +++ b/doc/sphinx/reference/varnishd.rst @@ -230,7 +230,7 @@ workspace_client (=16k), thread_pool_workspace (=16k), http_resp_size thread_pool_stack (=64k) are reduced relative to the values listed here, in order to conserve VM space. -.. include:: params.rst +.. include:: ../include/params.rst SEE ALSO ======== diff --git a/doc/sphinx/reference/varnishlog.rst b/doc/sphinx/reference/varnishlog.rst index 9d93fe1..60ebc57 100644 --- a/doc/sphinx/reference/varnishlog.rst +++ b/doc/sphinx/reference/varnishlog.rst @@ -19,7 +19,7 @@ Display Varnish logs SYNOPSIS ======== -.. include:: ../../../bin/varnishlog/varnishlog_synopsis.rst +.. include:: ../include/varnishlog_synopsis.rst varnishlog |synopsis| OPTIONS @@ -27,7 +27,7 @@ OPTIONS The following options are available: -.. include:: ../../../bin/varnishlog/varnishlog_options.rst +.. include:: ../include/varnishlog_options.rst -k num diff --git a/doc/sphinx/reference/varnishncsa.rst b/doc/sphinx/reference/varnishncsa.rst index 50dcfe6..8189696 100644 --- a/doc/sphinx/reference/varnishncsa.rst +++ b/doc/sphinx/reference/varnishncsa.rst @@ -16,7 +16,7 @@ Display Varnish logs in Apache / NCSA combined log format SYNOPSIS ======== -.. include:: ../../../bin/varnishncsa/varnishncsa_synopsis.rst +.. include:: ../include/varnishncsa_synopsis.rst varnishncsa |synopsis| DESCRIPTION @@ -33,7 +33,7 @@ applicable transactions. Non-request transactions are ignored. The following options are available: -.. include:: ../../../bin/varnishncsa/varnishncsa_options.rst +.. include:: ../include/varnishncsa_options.rst FORMAT ====== diff --git a/doc/sphinx/reference/varnishtop.rst b/doc/sphinx/reference/varnishtop.rst index 23298d5..7ebc384 100644 --- a/doc/sphinx/reference/varnishtop.rst +++ b/doc/sphinx/reference/varnishtop.rst @@ -17,7 +17,7 @@ Varnish log entry ranking SYNOPSIS ======== -.. include:: ../../../bin/varnishtop/varnishtop_synopsis.rst +.. include:: ../include/varnishtop_synopsis.rst varnishtop |synopsis| DESCRIPTION @@ -32,7 +32,7 @@ recorded in the log. The following options are available: -.. include:: ../../../bin/varnishtop/varnishtop_options.rst +.. include:: ../include/varnishtop_options.rst EXAMPLES ======== diff --git a/man/Makefile.am b/man/Makefile.am index 7d0b1f6..2b26b0b 100644 --- a/man/Makefile.am +++ b/man/Makefile.am @@ -8,68 +8,59 @@ vsc2rst_SOURCES = vsc2rst.c \ AM_CPPFLAGS = -I$(top_srcdir)/include -dist_man_MANS = vcl.7 varnish-cli.7 varnish-counters.7 vsl.7 vsl-query.7 varnishd.1 +dist_man_MANS = vcl.7 \ + varnish-cli.7 \ + varnish-counters.7 \ + vsl.7 \ + vsl-query.7 \ + varnishadm.1 \ + varnishd.1 \ + varnishlog.1 \ + varnishncsa.1 \ + varnishreplay.1 \ + varnishstat.1 \ + varnishtest.1 \ + varnishtop.1 + MAINTAINERCLEANFILES = $(dist_man_MANS) vcl.7: $(top_srcdir)/doc/sphinx/reference/vcl.rst \ $(top_srcdir)/bin/varnishd/builtin.vcl -if HAVE_RST2MAN ${RST2MAN} $(top_srcdir)/doc/sphinx/reference/vcl.rst $@ -else - @echo "========================================" - @echo "You need rst2man installed to make dist" - @echo "========================================" - @false -endif varnish-cli.7: $(top_srcdir)/doc/sphinx/reference/varnish-cli.rst -if HAVE_RST2MAN ${RST2MAN} $(top_srcdir)/doc/sphinx/reference/varnish-cli.rst $@ -else - @echo "========================================" - @echo "You need rst2man installed to make dist" - @echo "========================================" - @false -endif -if HAVE_RST2MAN varnish-counters.7: vsc2rst ./vsc2rst | ${RST2MAN} - $@ -else -varnish-counters.7: $(top_srcdir)/include/tbl/vsc_fields.h - @echo "========================================" - @echo "You need rst2man installed to make dist" - @echo "========================================" - @false -endif vsl.7: $(top_srcdir)/doc/sphinx/reference/vsl.rst \ $(top_srcdir)/lib/libvarnishapi/vsl-tags.rst -if HAVE_RST2MAN ${RST2MAN} $(top_srcdir)/doc/sphinx/reference/vsl.rst $@ -else - @echo "========================================" - @echo "You need rst2man installed to make dist" - @echo "========================================" - @false -endif vsl-query.7: $(top_srcdir)/doc/sphinx/reference/vsl-query.rst -if HAVE_RST2MAN ${RST2MAN} $(top_srcdir)/doc/sphinx/reference/vsl-query.rst $@ -else - @echo "========================================" - @echo "You need rst2man installed to make dist" - @echo "========================================" - @false -endif -varnishd.1: $(top_srcdir)/doc/sphinx/reference/varnishd.rst -if HAVE_RST2MAN - ${RST2MAN} $^ $@ -else - @echo "========================================" - @echo "You need rst2man installed to make dist" - @echo "========================================" - @false -endif +%.7: $(top_srcdir)/doc/sphinx/reference/%.rst + ${RST2MAN} $(top_srcdir)/doc/sphinx/reference/vsl-query.rst $@ + +%.1: $(top_srcdir)/doc/sphinx/reference/%.rst + ${RST2MAN} $< $@ + +varnishncsa.1: \ + $(top_srcdir)/doc/sphinx/reference/varnishncsa.rst \ + $(top_srcdir)/doc/sphinx/include/varnishncsa_options.rst \ + $(top_srcdir)/doc/sphinx/include/varnishncsa_synopsis.rst + ${RST2MAN} $(top_srcdir)/doc/sphinx/reference/varnishncsa.rst $@ + +varnishlog.1: \ + $(top_srcdir)/doc/sphinx/reference/varnishlog.rst \ + $(top_srcdir)/doc/sphinx/include/varnishlog_options.rst \ + $(top_srcdir)/doc/sphinx/include/varnishlog_synopsis.rst + ${RST2MAN} $(top_srcdir)/doc/sphinx/reference/varnishlog.rst $@ + +varnishtop.1: \ + $(top_srcdir)/doc/sphinx/reference/varnishtop.rst \ + $(top_srcdir)/doc/sphinx/include/varnishtop_options.rst \ + $(top_srcdir)/doc/sphinx/include/varnishtop_synopsis.rst + ${RST2MAN} $(top_srcdir)/doc/sphinx/reference/varnishtop.rst $@ From martin at varnish-software.com Wed Feb 5 14:42:34 2014 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Wed, 05 Feb 2014 15:42:34 +0100 Subject: [master] 862c6a1 Don't output trailing '\0' of SLT_Debug records Message-ID: commit 862c6a174ac335a5aba048d9e4af733ab9c64f2f Author: Martin Blix Grydeland Date: Wed Feb 5 15:40:22 2014 +0100 Don't output trailing '\0' of SLT_Debug records SLT_Debug is special as it is both used as a binary log record and as a text record. Add a special case for it and don't escape-output the trailing zero. diff --git a/lib/libvarnishapi/vsl.c b/lib/libvarnishapi/vsl.c index 363085a..6e0f20a 100644 --- a/lib/libvarnishapi/vsl.c +++ b/lib/libvarnishapi/vsl.c @@ -255,6 +255,8 @@ VSL_Print(const struct VSL_data *vsl, const struct VSL_cursor *c, void *fo) if (VSL_tagflags[tag] & SLT_F_BINARY) { VSL_PRINT(fo, "%10u %-14s %c \"", vxid, VSL_tags[tag], type); while (len-- > 0) { + if (len == 0 && tag == SLT_Debug && *data == '\0') + break; if (*data >= ' ' && *data <= '~') VSL_PRINT(fo, "%c", *data); else @@ -288,6 +290,8 @@ VSL_PrintTerse(const struct VSL_data *vsl, const struct VSL_cursor *c, void *fo) if (VSL_tagflags[tag] & SLT_F_BINARY) { VSL_PRINT(fo, "%-14s \"", VSL_tags[tag]); while (len-- > 0) { + if (len == 0 && tag == SLT_Debug && *data == '\0') + break; if (*data >= ' ' && *data <= '~') VSL_PRINT(fo, "%c", *data); else From phk at FreeBSD.org Wed Feb 5 19:14:24 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 05 Feb 2014 20:14:24 +0100 Subject: [master] be429e5 Make the CHANGE column show negative numbers when gauges drop Message-ID: commit be429e5e3b421d9a07be4bfa8025951841dea9c8 Author: Poul-Henning Kamp Date: Wed Feb 5 19:13:59 2014 +0000 Make the CHANGE column show negative numbers when gauges drop diff --git a/bin/varnishstat/varnishstat_curses.c b/bin/varnishstat/varnishstat_curses.c index 2b0137d..e722408 100644 --- a/bin/varnishstat/varnishstat_curses.c +++ b/bin/varnishstat/varnishstat_curses.c @@ -380,7 +380,7 @@ sample_points(void) pt->t_cur = VTIM_mono(); if (pt->t_last) - pt->chg = (pt->cur - (intmax_t)pt->last) / + pt->chg = ((intmax_t)pt->cur - (intmax_t)pt->last) / (pt->t_cur - pt->t_last); if (pt->flag == 'g') { From phk at FreeBSD.org Wed Feb 5 21:14:48 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 05 Feb 2014 22:14:48 +0100 Subject: [master] 760db1b Dump the objects on busyobj on panic in fetch code Message-ID: commit 760db1bd31e95f4573fc54583c51f84ec6add533 Author: Poul-Henning Kamp Date: Wed Feb 5 21:05:04 2014 +0000 Dump the objects on busyobj on panic in fetch code diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index 81b794d..8df8bfa 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -210,11 +210,11 @@ pan_http(const char *id, const struct http *h, int indent) /*--------------------------------------------------------------------*/ static void -pan_object(const struct object *o) +pan_object(const char *typ, const struct object *o) { const struct storage *st; - VSB_printf(pan_vsp, " obj = %p {\n", o); + VSB_printf(pan_vsp, " obj (%s) = %p {\n", typ, o); VSB_printf(pan_vsp, " vxid = %u,\n", o->vxid); pan_http("obj", o->http, 4); VSB_printf(pan_vsp, " len = %jd,\n", (intmax_t)o->len); @@ -284,6 +284,10 @@ pan_busyobj(const struct busyobj *bo) if (bo->beresp->ws != NULL) pan_http("beresp", bo->beresp, 4); pan_ws(bo->ws_o, 4); + if (bo->fetch_obj) + pan_object("FETCH", bo->fetch_obj); + if (bo->ims_obj) + pan_object("IMS", bo->ims_obj); VSB_printf(pan_vsp, " }\n"); } @@ -337,7 +341,7 @@ pan_req(const struct req *req) if (VALID_OBJ(req->obj, OBJECT_MAGIC)) { if (req->obj->objcore->busyobj != NULL) pan_busyobj(req->obj->objcore->busyobj); - pan_object(req->obj); + pan_object("REQ", req->obj); } VSB_printf(pan_vsp, "},\n"); From phk at FreeBSD.org Wed Feb 5 21:14:48 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 05 Feb 2014 22:14:48 +0100 Subject: [master] aeebcb5 Only grab the extra reference if we have a request thread that wants it. Message-ID: commit aeebcb565a4dfe4e2c3f720e5428b7b78bd0686a Author: Poul-Henning Kamp Date: Wed Feb 5 21:13:54 2014 +0000 Only grab the extra reference if we have a request thread that wants it. Zeroed in on by: scoof diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index fa58309..c6514fd 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -780,9 +780,11 @@ VBF_Fetch(struct worker *wrk, struct req *req, struct objcore *oc, bo->vary = req->vary_b; req->vary_b = NULL; - HSH_Ref(oc); + if (mode != VBF_BACKGROUND) + HSH_Ref(oc); bo->fetch_objcore = oc; + AZ(bo->ims_obj); if (oldobj != NULL) { if (http_GetHdr(oldobj->http, H_Last_Modified, NULL) || http_GetHdr(oldobj->http, H_ETag, NULL)) { From fgsch at lodoss.net Wed Feb 5 23:50:34 2014 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Thu, 06 Feb 2014 00:50:34 +0100 Subject: [master] 9878c6c Spelling Message-ID: commit 9878c6c2c4a45984e307748aa5b15872c514c19e Author: Federico G. Schwindt Date: Wed Feb 5 23:50:22 2014 +0000 Spelling diff --git a/lib/libvcc/generate.py b/lib/libvcc/generate.py index 8d8f14f..01a6243 100755 --- a/lib/libvcc/generate.py +++ b/lib/libvcc/generate.py @@ -257,7 +257,7 @@ The client's IP address. 'BACKEND', ( 'recv',), ( 'recv',), """ - Set bereq.backend to this if we attemt to fetch. + Set bereq.backend to this if we attempt to fetch. This variable is a convenience so the overall policy can be set up once and for all in vcl_recv{}. """ @@ -1160,7 +1160,7 @@ for i in l: fo.write("\n" + i[0] + "\n\n") fo.write("\tType: " + i[1] + "\n\n") rst_where(fo, "Readable from: ", i[2]) - rst_where(fo, "Writeable frome: ", i[3]) + rst_where(fo, "Writable from: ", i[3]) for j in i[4].split("\n"): fo.write("\t" + j.strip() + "\n") From perbu at varnish-software.com Thu Feb 6 13:33:11 2014 From: perbu at varnish-software.com (Per Buer) Date: Thu, 06 Feb 2014 14:33:11 +0100 Subject: [master] 130ada9 Update tutorial for 4.0 Message-ID: commit 130ada9d511ee84046661166f904dd27cc0a2d57 Author: Per Buer Date: Thu Feb 6 13:51:26 2014 +0100 Update tutorial for 4.0 diff --git a/doc/sphinx/tutorial/backend_servers.rst b/doc/sphinx/tutorial/backend_servers.rst index 69d1c28..476d325 100644 --- a/doc/sphinx/tutorial/backend_servers.rst +++ b/doc/sphinx/tutorial/backend_servers.rst @@ -15,6 +15,8 @@ is probably /etc/varnish/default.vcl. If you've been following the tutorial there is probably a section of the configuration that looks like this::: + vcl 4.0; + backend default { .host = "www.varnish-cache.org"; .port = "80"; @@ -31,10 +33,12 @@ server so now we need to tie it to the origin. For this example, let's pretend the origin server is running on localhost, port 8080.:: - backend default { - .host = "127.0.0.1"; - .port = "8080"; - } + vcl 4.0; + + backend default { + .host = "127.0.0.1"; + .port = "8080"; + } Varnish can have several backends defined and can you can even join diff --git a/doc/sphinx/tutorial/starting_varnish.rst b/doc/sphinx/tutorial/starting_varnish.rst index ed2ca12..58bf574 100644 --- a/doc/sphinx/tutorial/starting_varnish.rst +++ b/doc/sphinx/tutorial/starting_varnish.rst @@ -37,6 +37,8 @@ Fire up your favorite editor and edit /etc/varnish/default.vcl. Most of it is commented out but there is some text that is not. It will probably look like this:: + vcl 4.0; + backend default { .host = "127.0.0.1"; .port = "8080"; @@ -45,6 +47,8 @@ probably look like this:: We'll change it and make it point to something that works. Hopefully www.varnish-cache.org is up. Let's use that. Replace the text with:: + vcl 4.0; + backend default { .host = "www.varnish-cache.org"; .port = "80"; From perbu at varnish-software.com Thu Feb 6 13:33:11 2014 From: perbu at varnish-software.com (Per Buer) Date: Thu, 06 Feb 2014 14:33:11 +0100 Subject: [master] 63dce4f Reformat and rewrite for readability Message-ID: commit 63dce4fed739d953729aeb7f170568bb8f9f7c17 Author: Per Buer Date: Thu Feb 6 14:18:35 2014 +0100 Reformat and rewrite for readability diff --git a/doc/sphinx/users-guide/intro.rst b/doc/sphinx/users-guide/intro.rst index e497e00..bd1ec46 100644 --- a/doc/sphinx/users-guide/intro.rst +++ b/doc/sphinx/users-guide/intro.rst @@ -4,24 +4,21 @@ The Big Varnish Picture ======================= What is in this package called "Varnish", what are all the different -bits and pieces named and will you need a hex-wrench for assembly ? +bits and pieces named and will you need a hex-wrench for assembly? The two main parts of Varnish are the two processes in the varnishd -program. - -The first process is called "the manager", and its job is to talk -to you, the administrator, and make the things you ask for happen. +program. The first process is called "the manager", and its job is to +talk to you, the administrator, and make the things you ask for +happen. The second process is called "the worker" or just "the child" and this is the process which does all the actual work with your HTTP traffic. -When you start varnishd, you start the manager process, and once -it is done handling all the command line flags, it will start the -child process for you. - -Should the child process die, the manager will start it again for -you, automatically and right away. +When you start varnishd, you start the manager process, and once it is +done handling all the command line flags, it will start the child +process for you. Should the child process die, the manager will start +it again for you, automatically and right away. The main reason for this division of labor is security: The manager process will typically run with "root" permissions, in order to @@ -29,12 +26,11 @@ open TCP socket port 80, but it starts the child process with minimal permissions, as a defensive measure. The manager process is interactive, it offers a CLI -- Command Line -Interface, which can be used manually, from scripts or programs. - -The CLI offers almost full control of what Varnish actually does -to your HTTP traffic, and we have gone to great lengths to ensure -that you should not need to restart the Varnish processes, unless -you need to change something very fundamental. +Interface, which can be used manually, from scripts or programs. The +CLI offers almost full control of what Varnish actually does to your +HTTP traffic, and we have gone to great lengths to ensure that you +should not need to restart the Varnish processes, unless you need to +change something very fundamental. The CLI can be safely accessed remotely, using a simple and flexible PSK -- Pre Shared Key, access control scheme, so it is easy to @@ -46,7 +42,6 @@ All this is covered in :ref:`users_running`. How the child process should deal with the HTTP requests, what to cache, which headers to remove etc, is al specified in a small programming language called VCL -- Varnish Configuration Language. - The manager process will compile the VCL program and check it for errors, but it is the child process which runs the VCL program, for each and every HTTP request which comes in. @@ -75,13 +70,10 @@ can do for your HTTP traffic, there really is no limit. :ref:`users_vcl` describes VCL and what it can do in great detail. Varnish uses a piece of shared memory to report its activity and -status. - -For each HTTP request, a number of very detailed records will be -appended to the log segment in this shared memory. - -Other processes can subscribe to log-records, filter them, and -format them, for instance as NCSA style log records. +status. For each HTTP request, a number of very detailed records will +be appended to the log segment in this shared memory. Other processes +can subscribe to log-records, filter them, and format them, for +instance as NCSA style log records. Another segment in shared memory is used for statistics counters, this allows real-time, down to microsecond resolution monitoring @@ -95,24 +87,21 @@ writing :ref:`users_report` explains how all that work. -Presumably the reason why you are interested in Varnish, is that -you want your website to work better. - -There are many aspects of performance tuning a website, from -relatively simple policy decisions about what to cache, to designing -a geographically diverse multilevel CDNs using ESI and automatic -failover. +Presumably the reason why you are interested in Varnish, is that you +want your website to work better. There are many aspects of +performance tuning a website, from relatively simple policy decisions +about what to cache, to designing a geographically diverse multilevel +CDNs using ESI and automatic failover. :ref:`users_performance` will take you through the possibilities and facilities Varnish offers. -Finally, Murphys Law must be contended with: Things will go wrong, -and more likely than not, they will do so at zero-zero-dark O'clock. - -...during a hurricane, when your phones battery is flat and your +Finally, Murphys Law must be contended with: Things will go wrong, and +more likely than not, they will do so at zero-zero-dark O'clock. Most +likely during a hurricane, when your phones battery is flat and your wife had prepared a intimate evening to celebrate your aniversary. -Yes, we've all been there, havn't we ? +Yes, we've all been there, havn't we? When things go wrong :ref:`users_trouble` will hopefully be of some help. From perbu at varnish-software.com Thu Feb 6 13:33:11 2014 From: perbu at varnish-software.com (Per Buer) Date: Thu, 06 Feb 2014 14:33:11 +0100 Subject: [master] 6aff95f clarity Message-ID: commit 6aff95f5382cd5aa6f4a98ceed7a13b9ac6491eb Author: Per Buer Date: Thu Feb 6 14:19:12 2014 +0100 clarity diff --git a/doc/sphinx/users-guide/run_cli.rst b/doc/sphinx/users-guide/run_cli.rst index 2b5509a..a5e97e1 100644 --- a/doc/sphinx/users-guide/run_cli.rst +++ b/doc/sphinx/users-guide/run_cli.rst @@ -45,7 +45,7 @@ What can you do with the CLI The CLI gives you almost total control over varnishd: * load/use/discard VCL programs -* ban cache content +* ban (invalidate) cache content * change parameters * start/stop worker process @@ -115,7 +115,7 @@ but they are banned from delivery. Instead of checking each and every cached object right away, we test each object against the regular expression only if and when -some requests decides to deliver it. +a HTTP request asks for it. Banning stuff is much cheaper than restarting Varnish to get rid of wronly cached content. From perbu at varnish-software.com Thu Feb 6 13:33:11 2014 From: perbu at varnish-software.com (Per Buer) Date: Thu, 06 Feb 2014 14:33:11 +0100 Subject: [master] 1be3f1a add two params for -r consideration - and a bit for reformatting Message-ID: commit 1be3f1a185dfce49457f4a5ae62d163cd9458c00 Author: Per Buer Date: Thu Feb 6 14:19:53 2014 +0100 add two params for -r consideration - and a bit for reformatting diff --git a/doc/sphinx/users-guide/run_security.rst b/doc/sphinx/users-guide/run_security.rst index a2557a2..fb4b4d4 100644 --- a/doc/sphinx/users-guide/run_security.rst +++ b/doc/sphinx/users-guide/run_security.rst @@ -31,13 +31,13 @@ line, in order to make them invulnerable to subsequent manipulation. The important decisions to make are: -#. Who should have access to the Command Line Interface ? +#. Who should have access to the Command Line Interface? -#. Which parameters can they change ? +#. Which parameters can they change? -#. Will inline-C code be allowed ? +#. Will inline-C code be allowed? -#. If/how VMODs will be restricted ? +#. If/how VMODs will be restricted? CLI interface access ^^^^^^^^^^^^^^^^^^^^ @@ -89,7 +89,7 @@ command on stdin/stdout, but since you started the process, it would be hard to prevent you getting CLI access, wouldn't it ? CLI interface authentication -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ By default the CLI interface is protected with a simple, yet strong "Pre Shared Key" authentication method, which do not provide @@ -150,6 +150,9 @@ HTTP service, but a few can do more damage than that: :ref:`ref_param_cc_command` Execute arbitrary programs +:ref:`ref_param_vcc_allow_inline_c` + Allow inline C in VCL, which would any C code from VCL to be executed by Varnish. + Furthermore you may want to look at and lock down: :ref:`ref_param_syslog_cli_traffic` @@ -158,6 +161,11 @@ Furthermore you may want to look at and lock down: :ref:`ref_param_vcc_unsafe_path` Retrict VCL/VMODS to :ref:`ref_param_vcl_dir` and :ref:`ref_param_vmod_dir` +:ref:`ref_param_vmod_dir` + The directory where Varnish will will look + for modules. This could potentially be used to load rouge + modules into Varnish. + The CLI interface ----------------- From perbu at varnish-software.com Thu Feb 6 13:33:11 2014 From: perbu at varnish-software.com (Per Buer) Date: Thu, 06 Feb 2014 14:33:11 +0100 Subject: [master] 9b59003 remove cruft Message-ID: commit 9b59003fc7bc20d57a14cf07eff4bfc0939a2ebf Author: Per Buer Date: Thu Feb 6 14:20:55 2014 +0100 remove cruft diff --git a/doc/sphinx/users-guide/operation-cli.rst b/doc/sphinx/users-guide/operation-cli.rst deleted file mode 100644 index 5cb40a5..0000000 --- a/doc/sphinx/users-guide/operation-cli.rst +++ /dev/null @@ -1,6 +0,0 @@ - - -Varnishadm ----------- - -You connect to it and everything becomes awesome. From perbu at varnish-software.com Thu Feb 6 13:33:11 2014 From: perbu at varnish-software.com (Per Buer) Date: Thu, 06 Feb 2014 14:33:11 +0100 Subject: [master] e4c66f7 Move purging into the performance section and explain its role Message-ID: commit e4c66f75b38930fd0e87ee2eecf23da1339f26fe Author: Per Buer Date: Thu Feb 6 14:26:38 2014 +0100 Move purging into the performance section and explain its role diff --git a/doc/sphinx/users-guide/operation.rst b/doc/sphinx/users-guide/operation.rst index dc45e7e..ed6f5e0 100644 --- a/doc/sphinx/users-guide/operation.rst +++ b/doc/sphinx/users-guide/operation.rst @@ -6,7 +6,6 @@ XXX: These are chapters which need to find a new home in the other sections. .. toctree:: :maxdepth: 2 - operation-cli purging compression esi diff --git a/doc/sphinx/users-guide/performance.rst b/doc/sphinx/users-guide/performance.rst index c28dea0..1dbb991 100644 --- a/doc/sphinx/users-guide/performance.rst +++ b/doc/sphinx/users-guide/performance.rst @@ -6,7 +6,16 @@ Varnish and Website Performance This section is about tuning the performance of your Varnish server, and about tuning the performance of your website using Varnish. +The section is split into two. One deals with the various tools and +functions of Varnish that you should be aware of and the other focuses +on the how to purge content out of your cache. Purging of content is +essential in a performance context because it allows you to extend the +*time-to-live* (TTL) of your cached objects. Having a long TTL allows +Varnish to keep the content in cache longer, meaning Varnish will make +send fewer requests to your relativly slow backend. + .. toctree:: :maxdepth: 2 increasing-your-hitrate + purging From perbu at varnish-software.com Thu Feb 6 13:33:12 2014 From: perbu at varnish-software.com (Per Buer) Date: Thu, 06 Feb 2014 14:33:12 +0100 Subject: [master] 1199126 Add compression to performance Message-ID: commit 1199126de3127df1fd46b6c2615f02f89feca3d8 Author: Per Buer Date: Thu Feb 6 14:29:24 2014 +0100 Add compression to performance diff --git a/doc/sphinx/users-guide/operation.rst b/doc/sphinx/users-guide/operation.rst index ed6f5e0..76fbf5d 100644 --- a/doc/sphinx/users-guide/operation.rst +++ b/doc/sphinx/users-guide/operation.rst @@ -6,8 +6,6 @@ XXX: These are chapters which need to find a new home in the other sections. .. toctree:: :maxdepth: 2 - purging - compression esi vary cookies diff --git a/doc/sphinx/users-guide/performance.rst b/doc/sphinx/users-guide/performance.rst index 1dbb991..baf9c75 100644 --- a/doc/sphinx/users-guide/performance.rst +++ b/doc/sphinx/users-guide/performance.rst @@ -6,7 +6,7 @@ Varnish and Website Performance This section is about tuning the performance of your Varnish server, and about tuning the performance of your website using Varnish. -The section is split into two. One deals with the various tools and +The section is split in three sections. One deals with the various tools and functions of Varnish that you should be aware of and the other focuses on the how to purge content out of your cache. Purging of content is essential in a performance context because it allows you to extend the @@ -14,8 +14,14 @@ essential in a performance context because it allows you to extend the Varnish to keep the content in cache longer, meaning Varnish will make send fewer requests to your relativly slow backend. +The final section deals with compression of web content. Varnish can +gzip content when fetching it from the backend and then deliver +compressed. This will reduce the time it takes to download the content +thereby increasing the performance of your website. + .. toctree:: :maxdepth: 2 increasing-your-hitrate purging + compression From perbu at varnish-software.com Thu Feb 6 13:33:12 2014 From: perbu at varnish-software.com (Per Buer) Date: Thu, 06 Feb 2014 14:33:12 +0100 Subject: [master] fd3383e change commet style Message-ID: commit fd3383e48270b559a6930ec13b8092bdffc8ec8b Author: Per Buer Date: Thu Feb 6 14:30:46 2014 +0100 change commet style diff --git a/doc/sphinx/users-guide/esi.rst b/doc/sphinx/users-guide/esi.rst index 8a12461..58b31f2 100644 --- a/doc/sphinx/users-guide/esi.rst +++ b/doc/sphinx/users-guide/esi.rst @@ -48,11 +48,11 @@ For ESI to work you need to activate ESI processing in VCL, like this:: sub vcl_fetch { if (req.url == "/test.html") { - set beresp.do_esi = true; /* Do ESI processing */ - set beresp.ttl = 24 h; /* Sets the TTL on the HTML above */ + set beresp.do_esi = true; // Do ESI processing + set beresp.ttl = 24 h; // Sets the TTL on the HTML above } elseif (req.url == "/cgi-bin/date.cgi") { - set beresp.ttl = 1m; /* Sets a one minute TTL on */ - /* the included object */ + set beresp.ttl = 1m; // Sets a one minute TTL on + // the included object } } @@ -83,4 +83,4 @@ Doing ESI on JSON and other non-XMLish content Please note that Varnish will peek at the included content. If it doesn't start with a "<" Varnish assumes you didn't really mean to include it and disregard it. You can alter this behaviour by setting -the esi_syntax parameter (see ref:`ref-varnishd`). \ No newline at end of file +the esi_syntax parameter (see ref:`ref-varnishd`). From martin at varnish-software.com Thu Feb 6 13:51:27 2014 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Thu, 06 Feb 2014 14:51:27 +0100 Subject: [master] e462839 Disable daemonize option for varnishtop Message-ID: commit e462839eb0d11e8709c757c5cbbd7a914ce3b9e2 Author: Martin Blix Grydeland Date: Thu Feb 6 14:50:47 2014 +0100 Disable daemonize option for varnishtop This option got added by misstake. Disable it as it doesn't do any good for this application. diff --git a/bin/varnishtop/varnishtop_options.h b/bin/varnishtop/varnishtop_options.h index 592694a..2d3353e 100644 --- a/bin/varnishtop/varnishtop_options.h +++ b/bin/varnishtop/varnishtop_options.h @@ -57,7 +57,6 @@ VSL_OPT_b VSL_OPT_c VSL_OPT_C VUT_OPT_d -VUT_OPT_D TOP_OPT_f VUT_OPT_g VUT_OPT_h From perbu at varnish-software.com Thu Feb 6 14:27:42 2014 From: perbu at varnish-software.com (Per Buer) Date: Thu, 06 Feb 2014 15:27:42 +0100 Subject: [master] daee5be Remove residue of former structure Message-ID: commit daee5be0d9003df7c766f6a0d62774741c228bdf Author: Per Buer Date: Thu Feb 6 14:43:49 2014 +0100 Remove residue of former structure diff --git a/doc/sphinx/users-guide/increasing-your-hitrate.rst b/doc/sphinx/users-guide/increasing-your-hitrate.rst index 462a781..b5fa17e 100644 --- a/doc/sphinx/users-guide/increasing-your-hitrate.rst +++ b/doc/sphinx/users-guide/increasing-your-hitrate.rst @@ -200,14 +200,3 @@ setting up redirects or by using the following VCL:: } -Ways of increasing your hitrate even more -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -The following chapters should give your ways of further increasing -your hitrate, especially the chapter on Cookies. - - * :ref:`users-guide-cookies` - * :ref:`users-guide-vary` - * :ref:`users-guide-purging` - * :ref:`users-guide-esi` - From perbu at varnish-software.com Thu Feb 6 14:27:42 2014 From: perbu at varnish-software.com (Per Buer) Date: Thu, 06 Feb 2014 15:27:42 +0100 Subject: [master] 4f7f7e0 Rewrite intro Message-ID: commit 4f7f7e0d9c1ebb6cf89187c56365f892024e3fa1 Author: Per Buer Date: Thu Feb 6 15:21:32 2014 +0100 Rewrite intro diff --git a/doc/sphinx/tutorial/introduction.rst b/doc/sphinx/tutorial/introduction.rst index 1f41b0f..5241575 100644 --- a/doc/sphinx/tutorial/introduction.rst +++ b/doc/sphinx/tutorial/introduction.rst @@ -1,31 +1,28 @@ .. _tutorial-intro: -What is Varnish? ----------------- - -Varnish Cache is a web application accelerator. It can also be called -a HTTP reverse proxy. It sits in front of a web server, accepts HTTP -requests and tries to answer those by looking them up in it's -cache. If it can't answer the request from cache it will hand the -request over to a backend server. - -You can say that Varnish Cache is a specialized key-value store that -stores HTTP responses. These are looked up with HTTP requests. If a -match is found the content is delivered. - -Varnish Cache will typically look up a response by inspecting the HTTP -Host header together with the URL. Varnish Cache maintains an index, -a hash, with all the host+url combinations that are kept in the cache. - -Some times Varnish will refuse to store the content in it's -cache. This might be because the HTTP reponse has metadata that -disables cacheing or that there might be a cookie involved. Varnish, -in the default configuration, will refuse to cache content when there -are cookies involved because it has no idea if the content is derived -from the cookie or not. - -All this behaviour can be changed using VCL. See the Users Guide for -more information on how to do that. +The fundamentals of web proxy caching with Varnish +-------------------------------------------------- + +Varnish is a caching HTTP reverse proxy. It recieves requests from +clients and tries to answer them from its cache. If it cannot answer +the request from its cache it will forward the request to the backend, +fetch the response, store it and deliver it to the client. + +Varnish decides whether it can store the content or not based on the +response it's gets back from the backend. The backend can instruct +Varnish to cache the content with the HTTP response header +Cache-Control. + +Varnish will be very careful when it encounters cookies, either coming +from the client or from the origin server. When Varnish sees a +Set-Cookie header on a response it decides that the object is not +cacheable. When there is a Cookie header in the request it will also +refuse to serve a cached object and rather ask the backend for version +of the object that is tailored to the request. + +This behaviour and most other behaviour can be changed using policies +written in the Varnish Configuration Language. See the Users Guide +for more information on how to do that. Performance From perbu at varnish-software.com Thu Feb 6 14:27:42 2014 From: perbu at varnish-software.com (Per Buer) Date: Thu, 06 Feb 2014 15:27:42 +0100 Subject: [master] 9335747 fix reference Message-ID: commit 93357472bfdaa16b321346b067b93f80000facc3 Author: Per Buer Date: Thu Feb 6 15:22:16 2014 +0100 fix reference diff --git a/doc/sphinx/users-guide/operation-logging.rst b/doc/sphinx/users-guide/operation-logging.rst index 856cbfa..aaf3bb5 100644 --- a/doc/sphinx/users-guide/operation-logging.rst +++ b/doc/sphinx/users-guide/operation-logging.rst @@ -65,4 +65,4 @@ want to know are: Only list transactions where the tag matches a regular expression. If it matches you will get the whole transaction. -For more information on this topic please see ref:`ref-varnishlog`. +For more information on this topic please see :ref:`ref-varnishlog`. From fgsch at lodoss.net Fri Feb 7 02:25:27 2014 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Fri, 07 Feb 2014 03:25:27 +0100 Subject: [master] 1bc8f54 Fix dist Message-ID: commit 1bc8f5449bd33a23f2e6c97d41af91091917bd4a Author: Federico G. Schwindt Date: Fri Feb 7 02:24:59 2014 +0000 Fix dist diff --git a/doc/sphinx/Makefile.am b/doc/sphinx/Makefile.am index 7940d07..3abd43f 100644 --- a/doc/sphinx/Makefile.am +++ b/doc/sphinx/Makefile.am @@ -143,7 +143,6 @@ EXTRA_DIST = \ users-guide/increasing-your-hitrate.rst \ users-guide/index.rst \ users-guide/intro.rst \ - users-guide/operation-cli.rst \ users-guide/operation-logging.rst \ users-guide/operation.rst \ users-guide/operation-statistics.rst \ From phk at FreeBSD.org Fri Feb 7 11:29:43 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 07 Feb 2014 12:29:43 +0100 Subject: [master] 0f5f294 White space nit Message-ID: commit 0f5f29436c3cc225c66883cdfa0d681d7b0ccdda Author: Poul-Henning Kamp Date: Thu Feb 6 18:05:14 2014 +0000 White space nit diff --git a/lib/libvarnish/vfil.c b/lib/libvarnish/vfil.c index df02a48..5a5f087 100644 --- a/lib/libvarnish/vfil.c +++ b/lib/libvarnish/vfil.c @@ -133,6 +133,6 @@ VFIL_nonblocking(int fd) assert(i != -1); i |= O_NONBLOCK; i = fcntl(fd, F_SETFL, i); - assert(i != -1); - return (i); + assert(i != -1); + return (i); } From phk at FreeBSD.org Fri Feb 7 11:29:43 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 07 Feb 2014 12:29:43 +0100 Subject: [master] f01131b Fix printf format nit. Message-ID: commit f01131b30ff664f8cdf9657947cc178cbbf32416 Author: Poul-Henning Kamp Date: Fri Feb 7 11:29:26 2014 +0000 Fix printf format nit. Fixes #1429 diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c index 99c54fa..0b71923 100644 --- a/bin/varnishtest/vtc_varnish.c +++ b/bin/varnishtest/vtc_varnish.c @@ -813,7 +813,7 @@ varnish_expect(const struct varnish *v, char * const *av) { av[0], sp.val, av[1], av[2]); } else { vtc_log(v->vl, 0, "Not true: %s (%ju) %s %s (%ju)", - av[0], sp.val, av[1], av[2], ref); + av[0], (uintmax_t)sp.val, av[1], av[2], (uintmax_t)ref); } } From phk at FreeBSD.org Fri Feb 7 11:40:16 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 07 Feb 2014 12:40:16 +0100 Subject: [master] d427ba9 Always nuke the IMS-candidate object if we successfully IMS fetch it. Message-ID: commit d427ba97b2b769941cc405c5b1bd843043d4755c Author: Poul-Henning Kamp Date: Fri Feb 7 11:39:53 2014 +0000 Always nuke the IMS-candidate object if we successfully IMS fetch it. diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index c6514fd..9254c8e 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -660,6 +660,7 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo) assert(al == bo->ims_obj->len); assert(obj->len == al); VBO_setstate(bo, BOS_FINISHED); + EXP_Rearm(bo->ims_obj, bo->ims_obj->exp.t_origin, 0, 0, 0); } HSH_Complete(obj->objcore); return (F_STP_DONE); From phk at FreeBSD.org Fri Feb 7 12:04:15 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 07 Feb 2014 13:04:15 +0100 Subject: [master] 7ccfbdd Remove a noise debug vsl Message-ID: commit 7ccfbdd73da6410edd3be697389b5f31fc4794f1 Author: Poul-Henning Kamp Date: Fri Feb 7 11:56:45 2014 +0000 Remove a noise debug vsl diff --git a/bin/varnishd/cache/cache_obj.c b/bin/varnishd/cache/cache_obj.c index 3c2f670..a92d29f 100644 --- a/bin/varnishd/cache/cache_obj.c +++ b/bin/varnishd/cache/cache_obj.c @@ -86,7 +86,6 @@ ObjIter(struct objiter *oi, void **p, ssize_t *l) ol = oi->len; while (1) { nl = VBO_waitlen(oi->bo, ol); - VSL(SLT_Debug, 0, "STREAM %zd -> %zd", ol, nl); if (nl != ol) break; if (oi->bo->state == BOS_FINISHED) From phk at FreeBSD.org Fri Feb 7 12:04:15 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Fri, 07 Feb 2014 13:04:15 +0100 Subject: [master] 1418ca7 Make sure the thread pool herders wake up every so often so they notice if the params have changed. Message-ID: commit 1418ca74677af0fc9feae0fcd3090dcd4f531554 Author: Poul-Henning Kamp Date: Fri Feb 7 11:56:56 2014 +0000 Make sure the thread pool herders wake up every so often so they notice if the params have changed. diff --git a/bin/varnishd/cache/cache_pool.c b/bin/varnishd/cache/cache_pool.c index b22fe09..75fac47 100644 --- a/bin/varnishd/cache/cache_pool.c +++ b/bin/varnishd/cache/cache_pool.c @@ -411,7 +411,8 @@ pool_herder(void *priv) Lck_Lock(&pp->mtx); if (!pp->dry) { - (void)Lck_CondWait(&pp->herder_cond, &pp->mtx, 0); + (void)Lck_CondWait(&pp->herder_cond, &pp->mtx, + VTIM_real() + 5); } else { /* XXX: unsafe counters */ VSC_C_main->threads_limited++; From fgsch at lodoss.net Fri Feb 7 12:30:29 2014 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Fri, 07 Feb 2014 13:30:29 +0100 Subject: [master] 6ef598f Make this work with bsd make as well Message-ID: commit 6ef598f51fc80db676c1f84a754093141f371a4f Author: Federico G. Schwindt Date: Fri Feb 7 12:23:01 2014 +0000 Make this work with bsd make as well Avoid using gnu make specific rules. While here sort entries and add missing dep for varnishd. diff --git a/man/Makefile.am b/man/Makefile.am index 2b26b0b..50e9b64 100644 --- a/man/Makefile.am +++ b/man/Makefile.am @@ -8,9 +8,10 @@ vsc2rst_SOURCES = vsc2rst.c \ AM_CPPFLAGS = -I$(top_srcdir)/include -dist_man_MANS = vcl.7 \ +dist_man_MANS = \ varnish-cli.7 \ varnish-counters.7 \ + vcl.7 \ vsl.7 \ vsl-query.7 \ varnishadm.1 \ @@ -24,16 +25,16 @@ dist_man_MANS = vcl.7 \ MAINTAINERCLEANFILES = $(dist_man_MANS) -vcl.7: $(top_srcdir)/doc/sphinx/reference/vcl.rst \ - $(top_srcdir)/bin/varnishd/builtin.vcl - ${RST2MAN} $(top_srcdir)/doc/sphinx/reference/vcl.rst $@ - varnish-cli.7: $(top_srcdir)/doc/sphinx/reference/varnish-cli.rst ${RST2MAN} $(top_srcdir)/doc/sphinx/reference/varnish-cli.rst $@ varnish-counters.7: vsc2rst ./vsc2rst | ${RST2MAN} - $@ +vcl.7: $(top_srcdir)/doc/sphinx/reference/vcl.rst \ + $(top_srcdir)/bin/varnishd/builtin.vcl + ${RST2MAN} $(top_srcdir)/doc/sphinx/reference/vcl.rst $@ + vsl.7: $(top_srcdir)/doc/sphinx/reference/vsl.rst \ $(top_srcdir)/lib/libvarnishapi/vsl-tags.rst ${RST2MAN} $(top_srcdir)/doc/sphinx/reference/vsl.rst $@ @@ -41,11 +42,13 @@ vsl.7: $(top_srcdir)/doc/sphinx/reference/vsl.rst \ vsl-query.7: $(top_srcdir)/doc/sphinx/reference/vsl-query.rst ${RST2MAN} $(top_srcdir)/doc/sphinx/reference/vsl-query.rst $@ -%.7: $(top_srcdir)/doc/sphinx/reference/%.rst - ${RST2MAN} $(top_srcdir)/doc/sphinx/reference/vsl-query.rst $@ +varnishadm.1: $(top_srcdir)/doc/sphinx/reference/varnishadm.rst + ${RST2MAN} $(top_srcdir)/doc/sphinx/reference/varnishadm.rst $@ -%.1: $(top_srcdir)/doc/sphinx/reference/%.rst - ${RST2MAN} $< $@ +varnishd.1: \ + $(top_srcdir)/doc/sphinx/reference/varnishd.rst \ + $(top_srcdir)/doc/sphinx/include/params.rst + ${RST2MAN} $(top_srcdir)/doc/sphinx/reference/varnishd.rst $@ varnishncsa.1: \ $(top_srcdir)/doc/sphinx/reference/varnishncsa.rst \ @@ -59,6 +62,15 @@ varnishlog.1: \ $(top_srcdir)/doc/sphinx/include/varnishlog_synopsis.rst ${RST2MAN} $(top_srcdir)/doc/sphinx/reference/varnishlog.rst $@ +varnishreplay.1: $(top_srcdir)/doc/sphinx/reference/varnishreplay.rst + ${RST2MAN} $(top_srcdir)/doc/sphinx/reference/varnishreplay.rst $@ + +varnishstat.1: $(top_srcdir)/doc/sphinx/reference/varnishstat.rst + ${RST2MAN} $(top_srcdir)/doc/sphinx/reference/varnishstat.rst $@ + +varnishtest.1: $(top_srcdir)/doc/sphinx/reference/varnishtest.rst + ${RST2MAN} $(top_srcdir)/doc/sphinx/reference/varnishtest.rst $@ + varnishtop.1: \ $(top_srcdir)/doc/sphinx/reference/varnishtop.rst \ $(top_srcdir)/doc/sphinx/include/varnishtop_options.rst \ From daghf at varnish-software.com Fri Feb 7 12:52:41 2014 From: daghf at varnish-software.com (Dag Haavi Finstad) Date: Fri, 07 Feb 2014 13:52:41 +0100 Subject: [master] a68bedb Fix varnishlog option doc typo. Message-ID: commit a68bedb64414234f3943054eec5bf89c585d569b Author: Dag Haavi Finstad Date: Fri Feb 7 13:52:38 2014 +0100 Fix varnishlog option doc typo. diff --git a/doc/sphinx/reference/varnishlog.rst b/doc/sphinx/reference/varnishlog.rst index 60ebc57..7f6d0bf 100644 --- a/doc/sphinx/reference/varnishlog.rst +++ b/doc/sphinx/reference/varnishlog.rst @@ -32,14 +32,14 @@ The following options are available: -k num Only show the first num log transactions (or log records - in --raw mode) + in -g raw mode) XXX: Not yet implemented -s num Skip the first num log transactions (or log records if - in --raw mode) + in -g raw mode) XXX: Not yet implemented From phk at FreeBSD.org Sun Feb 9 23:05:54 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 10 Feb 2014 00:05:54 +0100 Subject: [master] 0ccbd83 Move the closing of VDI connection to also cover successful IMS fetches. Message-ID: commit 0ccbd8320692becd41f27061737dbfede593550d Author: Poul-Henning Kamp Date: Sun Feb 9 23:05:28 2014 +0000 Move the closing of VDI connection to also cover successful IMS fetches. Spotted by: scoof diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 9254c8e..819c39f 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -498,14 +498,6 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) bo->t_body = VTIM_mono(); - if (bo->vbc != NULL) { - if (bo->should_close) - VDI_CloseFd(&bo->vbc); - else - VDI_RecycleFd(&bo->vbc); - AZ(bo->vbc); - } - http_Teardown(bo->bereq); http_Teardown(bo->beresp); @@ -721,6 +713,14 @@ vbf_fetch_thread(struct worker *wrk, void *priv) } assert(WRW_IsReleased(wrk)); + if (bo->vbc != NULL) { + if (bo->should_close) + VDI_CloseFd(&bo->vbc); + else + VDI_RecycleFd(&bo->vbc); + AZ(bo->vbc); + } + if (bo->state == BOS_FAILED) assert(bo->fetch_objcore->flags & OC_F_FAILED); From phk at FreeBSD.org Tue Feb 11 09:32:22 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 11 Feb 2014 10:32:22 +0100 Subject: [master] 13e2f2c Name the mempool guardian threads. Message-ID: commit 13e2f2c694c76b0e6994626c849c954f768deef2 Author: Poul-Henning Kamp Date: Tue Feb 11 09:31:59 2014 +0000 Name the mempool guardian threads. diff --git a/bin/varnishd/cache/cache_mempool.c b/bin/varnishd/cache/cache_mempool.c index fded87b..79d1841 100644 --- a/bin/varnishd/cache/cache_mempool.c +++ b/bin/varnishd/cache/cache_mempool.c @@ -51,7 +51,7 @@ VTAILQ_HEAD(memhead_s, memitem); struct mempool { unsigned magic; #define MEMPOOL_MAGIC 0x37a75a8d - char name[8]; + char name[12]; struct memhead_s list; struct memhead_s surplus; struct lock mtx; @@ -101,6 +101,7 @@ mpl_guard(void *priv) double last = 0; CAST_OBJ_NOTNULL(mpl, priv, MEMPOOL_MAGIC); + THR_SetName(mpl->name); mpl_slp = 0.15; // random while (1) { VTIM_sleep(mpl_slp); @@ -229,7 +230,7 @@ MPL_New(const char *name, ALLOC_OBJ(mpl, MEMPOOL_MAGIC); AN(mpl); - bprintf(mpl->name, "%s", name); + bprintf(mpl->name, "MPL_%s", name); mpl->param = pp; mpl->cur_size = cur_size; VTAILQ_INIT(&mpl->list); @@ -237,7 +238,7 @@ MPL_New(const char *name, Lck_New(&mpl->mtx, lck_mempool); /* XXX: prealloc min_pool */ mpl->vsc = VSM_Alloc(sizeof *mpl->vsc, - VSC_CLASS, VSC_type_mempool, mpl->name); + VSC_CLASS, VSC_type_mempool, mpl->name + 4); AN(mpl->vsc); AZ(pthread_create(&mpl->thread, NULL, mpl_guard, mpl)); AZ(pthread_detach(mpl->thread)); From phk at FreeBSD.org Tue Feb 11 10:33:14 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 11 Feb 2014 11:33:14 +0100 Subject: [master] a88dbf9 Fix a memory leak in BAN processing: We didn't free the compiled regexp. Message-ID: commit a88dbf913c7c264bb994f1fd5810e8a6ab27c3cc Author: Poul-Henning Kamp Date: Tue Feb 11 10:32:01 2014 +0000 Fix a memory leak in BAN processing: We didn't free the compiled regexp. Also solve a abstract corner-case when malloc(3) fails. We'll probably still come crashing down, but not for this reason any more. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 93ec51f..7ab3a1a 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -811,6 +811,7 @@ struct ban *BAN_New(void); int BAN_AddTest(struct ban *, const char *, const char *, const char *); void BAN_Free(struct ban *b); char *BAN_Insert(struct ban *b); +void BAN_Free_Errormsg(char *); void BAN_Init(void); void BAN_Shutdown(void); void BAN_NewObjCore(struct objcore *oc); diff --git a/bin/varnishd/cache/cache_ban.c b/bin/varnishd/cache/cache_ban.c index 1c6b0c8..99f2914 100644 --- a/bin/varnishd/cache/cache_ban.c +++ b/bin/varnishd/cache/cache_ban.c @@ -394,6 +394,7 @@ ban_parse_regexp(struct ban *b, const char *a3) rc = pcre_fullinfo(re, NULL, PCRE_INFO_SIZE, &sz); AZ(rc); ban_add_lump(b, re, sz); + pcre_free(re); return (0); } @@ -464,19 +465,27 @@ BAN_AddTest(struct ban *b, const char *a1, const char *a2, const char *a3) * deleted. */ +static char ban_error_nomem[] = "Could not get memory"; + static char * ban_ins_error(const char *p) { char *r = NULL; - static char nomem[] = "Could not get memory"; if (p != NULL) r = strdup(p); if (r == NULL) - r = nomem; + r = ban_error_nomem; return (r); } +void +BAN_Free_Errormsg(char *p) +{ + if (p != ban_error_nomem) + free(p); +} + char * BAN_Insert(struct ban *b) { @@ -1229,7 +1238,7 @@ ccf_ban(struct cli *cli, const char * const *av, void *priv) p = BAN_Insert(b); if (p != NULL) { VCLI_Out(cli, "%s", p); - free(p); + BAN_Free_Errormsg(p); VCLI_SetResult(cli, CLIS_PARAM); } } diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c index 3d45e4c..ce536e5 100644 --- a/bin/varnishd/cache/cache_vrt.c +++ b/bin/varnishd/cache/cache_vrt.c @@ -446,7 +446,7 @@ VRT_ban_string(const struct vrt_ctx *ctx, const char *str) if (a1 != NULL) { VSLb(ctx->vsl, SLT_VCL_Error, "ban(): %s", a1); - free(a1); + BAN_Free_Errormsg(a1); } break; } From fgsch at lodoss.net Sun Feb 16 17:00:45 2014 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sun, 16 Feb 2014 18:00:45 +0100 Subject: [master] fdabaa1 Spelling Message-ID: commit fdabaa15d33cd9b4689582777af476c0c8e1a20e Author: Federico G. Schwindt Date: Sun Feb 16 09:18:00 2014 +0000 Spelling diff --git a/doc/sphinx/users-guide/compression.rst b/doc/sphinx/users-guide/compression.rst index 0b78893..5e21511 100644 --- a/doc/sphinx/users-guide/compression.rst +++ b/doc/sphinx/users-guide/compression.rst @@ -36,7 +36,7 @@ vcl_fetch by setting do_gzip to true, like this:: } Please make sure that you don't try to compress content that is -incompressable, like jpgs, gifs and mp3. You'll only waste CPU +uncompressable, like jpgs, gifs and mp3. You'll only waste CPU cycles. You can also uncompress objects before storing it in memory by setting do_gunzip to *true* but I have no idea why anybody would want to do that. diff --git a/doc/sphinx/users-guide/devicedetection.rst b/doc/sphinx/users-guide/devicedetection.rst index e78ceda..c7acd73 100644 --- a/doc/sphinx/users-guide/devicedetection.rst +++ b/doc/sphinx/users-guide/devicedetection.rst @@ -28,7 +28,7 @@ Setting this header can be as simple as:: } There are different commercial and free offerings in doing grouping and -identifiying clients in further detail than this. For a basic and community +identifying clients in further detail than this. For a basic and community based regular expression set, see https://github.com/varnish/varnish-devicedetect/ . diff --git a/doc/sphinx/users-guide/intro.rst b/doc/sphinx/users-guide/intro.rst index bd1ec46..79b4c06 100644 --- a/doc/sphinx/users-guide/intro.rst +++ b/doc/sphinx/users-guide/intro.rst @@ -99,9 +99,9 @@ and facilities Varnish offers. Finally, Murphys Law must be contended with: Things will go wrong, and more likely than not, they will do so at zero-zero-dark O'clock. Most likely during a hurricane, when your phones battery is flat and your -wife had prepared a intimate evening to celebrate your aniversary. +wife had prepared a intimate evening to celebrate your anniversary. -Yes, we've all been there, havn't we? +Yes, we've all been there, haven't we? When things go wrong :ref:`users_trouble` will hopefully be of some help. diff --git a/doc/sphinx/users-guide/params.rst b/doc/sphinx/users-guide/params.rst index 8985bdc..d3a10af 100644 --- a/doc/sphinx/users-guide/params.rst +++ b/doc/sphinx/users-guide/params.rst @@ -5,7 +5,7 @@ Parameters Varnish Cache has a set of parameter that affect its behaviour and performance. Most of these parameters can be set on the Varnish -command line (through varnishadm) useing the param.set keyword. +command line (through varnishadm) using the param.set keyword. Some parameters can, for security purposes be read only using the "-r" command line switch to varnishd. diff --git a/doc/sphinx/users-guide/run_security.rst b/doc/sphinx/users-guide/run_security.rst index fb4b4d4..16ab277 100644 --- a/doc/sphinx/users-guide/run_security.rst +++ b/doc/sphinx/users-guide/run_security.rst @@ -9,7 +9,7 @@ this chapter: We have protected Varnish as well as we can from anything which can come in through HTTP socket. If parts of your web infrastructure are outsourced or otherwise -partitioned along adminitrative lines, you need to think about +partitioned along administrative lines, you need to think about security. Varnish provides four levels of authority, roughly related to diff --git a/doc/sphinx/users-guide/vcl-example-manipulating-responses.rst b/doc/sphinx/users-guide/vcl-example-manipulating-responses.rst index 8afdb50..b5724b4 100644 --- a/doc/sphinx/users-guide/vcl-example-manipulating-responses.rst +++ b/doc/sphinx/users-guide/vcl-example-manipulating-responses.rst @@ -3,7 +3,7 @@ Altering the backend response ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Here we override the TTL of a object comming from the backend if it +Here we override the TTL of a object coming from the backend if it matches certain criteria:: sub vcl_fetch { diff --git a/doc/sphinx/users-guide/vcl-examples.rst b/doc/sphinx/users-guide/vcl-examples.rst index 931ec27..e3a9489 100644 --- a/doc/sphinx/users-guide/vcl-examples.rst +++ b/doc/sphinx/users-guide/vcl-examples.rst @@ -3,7 +3,7 @@ VCL Examples ------------ These are a short collection of examples that showcase some of the -capabilites of the VCL language. +capabilities of the VCL language. .. toctree:: diff --git a/doc/sphinx/users-guide/vcl-hashing.rst b/doc/sphinx/users-guide/vcl-hashing.rst index 01b42d0..fdbe37f 100644 --- a/doc/sphinx/users-guide/vcl-hashing.rst +++ b/doc/sphinx/users-guide/vcl-hashing.rst @@ -3,7 +3,7 @@ Hashing Internally, when Varnish stores content in it's store it uses a hash key to find the object again. In the default setup this key is -calculated based on the content of the *Host* header or the IP adress +calculated based on the content of the *Host* header or the IP address of the server and the URL. Behold the default vcl:: @@ -19,8 +19,8 @@ Behold the default vcl:: } As you can see it first chucks in req.url then req.http.host if it -exsists. It is worth pointing out that Varnish doesn't lowercase the -hostname or the URL before hashing it so in thery having Varnish.org/ +exists. It is worth pointing out that Varnish doesn't lowercase the +hostname or the URL before hashing it so in theory having Varnish.org/ and varnish.org/ would result in different cache entries. Browers however, tend to lowercase hostnames. diff --git a/doc/sphinx/users-guide/vcl-variables.rst b/doc/sphinx/users-guide/vcl-variables.rst index 978f5e4..15999cc 100644 --- a/doc/sphinx/users-guide/vcl-variables.rst +++ b/doc/sphinx/users-guide/vcl-variables.rst @@ -15,7 +15,7 @@ In VCL, there several important objects. *beresp* The backend respons object. It contains the headers of the object - comming from the backend. Most of the work you do in vcl_fetch you + coming from the backend. Most of the work you do in vcl_fetch you do on the beresp object. *resp* diff --git a/doc/sphinx/users-guide/vcl.rst b/doc/sphinx/users-guide/vcl.rst index dc3fdc5..53d99e3 100644 --- a/doc/sphinx/users-guide/vcl.rst +++ b/doc/sphinx/users-guide/vcl.rst @@ -16,7 +16,7 @@ the request is being handled by altering the VCL code. You can direct certain requests to certains backends, you can alter the requests and the responses or have Varnish take various actions depending on arbitrary properties of the request or the response. This makes -Varnish an extremly powerful HTTP processor, not just for caching. +Varnish an extremely powerful HTTP processor, not just for caching. Varnish translates VCL into binary code which is then executed when requests arrive. The performance impact of VCL is negligible. From fgsch at lodoss.net Sun Feb 16 17:00:45 2014 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sun, 16 Feb 2014 18:00:45 +0100 Subject: [master] 8a1448a Mention all the valid units of time on error Message-ID: commit 8a1448ad1e3a3617c8cb44c68472349591df2b42 Author: Federico G. Schwindt Date: Sun Feb 16 13:24:36 2014 +0000 Mention all the valid units of time on error diff --git a/lib/libvcc/vcc_expr.c b/lib/libvcc/vcc_expr.c index fab381a..08f91df 100644 --- a/lib/libvcc/vcc_expr.c +++ b/lib/libvcc/vcc_expr.c @@ -77,7 +77,7 @@ vcc_TimeUnit(struct vcc *tl) else { VSB_printf(tl->sb, "Unknown time unit "); vcc_ErrToken(tl, tl->t); - VSB_printf(tl->sb, ". Legal are 's', 'm', 'h' and 'd'\n"); + VSB_printf(tl->sb, ". Legal are 'ms', 's', 'm', 'h', 'd' and 'w'\n"); vcc_ErrWhere(tl, tl->t); return (1.0); } From fgsch at lodoss.net Mon Feb 17 08:07:24 2014 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Mon, 17 Feb 2014 09:07:24 +0100 Subject: [master] f66d9ae Start updating vcl(7) for 4.0 Message-ID: commit f66d9ae6c2688007345586a07c7107511761cc4c Author: Federico G. Schwindt Date: Mon Feb 17 08:02:48 2014 +0000 Start updating vcl(7) for 4.0 diff --git a/doc/sphinx/reference/vcl.rst b/doc/sphinx/reference/vcl.rst index 9aea743..7e00e43 100644 --- a/doc/sphinx/reference/vcl.rst +++ b/doc/sphinx/reference/vcl.rst @@ -33,20 +33,18 @@ For an overview of the VCL syntax please see the users guide. Backend declarations -------------------- -A backend declaration creates and initializes a named backend object: -:: +A backend declaration creates and initializes a named backend object:: - backend www { - .host = "www.example.com"; - .port = "http"; - } + backend www { + .host = "www.example.com"; + .port = "http"; + } -The backend object can later be used to select a backend at request time: -:: +The backend object can later be used to select a backend at request time:: - if (req.http.host ~ "(?i)^(www.)?example.com$") { - set req.backend = www; - } + if (req.http.host ~ "(?i)^(www.)?example.com$") { + set req.backend = www; + } To avoid overloading backend servers, .max_connections can be set to limit the maximum number of concurrent backend connections. @@ -57,24 +55,15 @@ backend connection, .first_byte_timeout for the time to wait for the first byte from the backend and .between_bytes_timeout for time to wait between each received byte. -These can be set in the declaration like this: -:: - - backend www { - .host = "www.example.com"; - .port = "http"; - .connect_timeout = 1s; - .first_byte_timeout = 5s; - .between_bytes_timeout = 2s; - } - -To mark a backend as unhealthy after number of items have been added -to its saintmode list ``.saintmode_threshold`` can be set to the maximum -list size. Setting a value of 0 disables saint mode checking entirely -for that backend. The value in the backend declaration overrides the -parameter. - +These can be set in the declaration like this:: + backend www { + .host = "www.example.com"; + .port = "http"; + .connect_timeout = 1s; + .first_byte_timeout = 5s; + .between_bytes_timeout = 2s; + } .. _ref-vcl-director: @@ -89,24 +78,23 @@ be used. There are several types of directors. The different director types use different algorithms to choose which backend to use. -Configuring a director may look like this: -:: - - director b2 random { - .retries = 5; - { - // We can refer to named backends - .backend = b1; - .weight = 7; - } - { - // Or define them inline - .backend = { - .host = "fs2"; - } - .weight = 3; +Configuring a director may look like this:: + + director b2 random { + .retries = 5; + { + # We can refer to named backends + .backend = b1; + .weight = 7; + } + { + # Or define them inline + .backend = { + .host = "fs2"; + } + .weight = 3; + } } - } The family of random directors ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -171,8 +159,7 @@ The DNS director ~~~~~~~~~~~~~~~~ The DNS director can use backends in two different ways. Either like the -random or round-robin director or using .list: -:: +random or round-robin director or using .list:: director directorname dns { .list = { @@ -207,27 +194,26 @@ round-robin manner. The fallback director ~~~~~~~~~~~~~~~~~~~~~ -The fallback director will pick the first backend that is healthy. It +The fallback director will pick the first backend that is healthy. It considers them in the order in which they are listed in its definition. The fallback director does not take any options. -An example of a fallback director: -:: +An example of a fallback director:: - director b3 fallback { - { .backend = www1; } - { .backend = www2; } // will only be used if www1 is unhealthy. - { .backend = www3; } // will only be used if both www1 and www2 - // are unhealthy. - } + director b3 fallback { + { .backend = www1; } + { .backend = www2; } # will only be used if www1 is unhealthy. + { .backend = www3; } # will only be used if both www1 and www2 + # are unhealthy. + } Backend probes -------------- Backends can be probed to see whether they should be considered -healthy or not. The return status can also be checked by using -req.backend.healthy. +healthy or not. The return status can also be checked by using the +healthy function from the std vmod. Probes take the following parameters: @@ -241,7 +227,7 @@ Probes take the following parameters: .window How many of the latest polls we examine to determine backend health. Defaults to 8. -.threshold +.threshold How many of the polls in .window must have succeeded for us to consider the backend healthy. If this is set to more than or equal to the threshold, the backend starts as healthy. Defaults to the @@ -264,66 +250,61 @@ Probes take the following parameters: Default is 2 seconds. A backend with a probe can be defined like this, together with the -backend or director: -:: - - backend www { - .host = "www.example.com"; - .port = "http"; - .probe = { - .url = "/test.jpg"; - .timeout = 0.3 s; - .window = 8; - .threshold = 3; - .initial = 3; +backend or director:: + + backend www { + .host = "www.example.com"; + .port = "http"; + .probe = { + .url = "/test.jpg"; + .timeout = 0.3s; + .window = 8; + .threshold = 3; + .initial = 3; + } } - } -Or it can be defined separately and then referenced: -:: +Or it can be defined separately and then referenced:: - probe healthcheck { - .url = "/status.cgi"; - .interval = 60s; - .timeout = 0.3 s; - .window = 8; - .threshold = 3; - .initial = 3; - .expected_response = 200; - } - - backend www { - .host = "www.example.com"; - .port = "http"; - .probe = healthcheck; - } + probe healthcheck { + .url = "/status.cgi"; + .interval = 60s; + .timeout = 0.3s; + .window = 8; + .threshold = 3; + .initial = 3; + .expected_response = 200; + } -If you have many backends this can simplify the config a lot. + backend www { + .host = "www.example.com"; + .port = "http"; + .probe = healthcheck; + } +If you have many backends this can simplify the config a lot. -It is also possible to specify the raw HTTP request: -:: +It is also possible to specify the raw HTTP request:: - probe rawprobe { - # NB: \r\n automatically inserted after each string! - .request = - "GET / HTTP/1.1" - "Host: www.foo.bar" - "Connection: close"; - } + probe rawprobe { + # NB: \r\n automatically inserted after each string! + .request = + "GET / HTTP/1.1" + "Host: www.foo.bar" + "Connection: close"; + } ACLs ---- An ACL declaration creates and initializes a named access control list -which can later be used to match client addresses: -:: +which can later be used to match client addresses:: - acl local { - "localhost"; // myself - "192.0.2.0"/24; // and everyone on the local network - ! "192.0.2.23"; // except for the dialin router - } + acl local { + "localhost"; # myself + "192.0.2.0"/24; # and everyone on the local network + ! "192.0.2.23"; # except for the dialin router + } If an ACL entry specifies a host name which Varnish is unable to resolve, it will match any address it is compared to. Consequently, @@ -331,12 +312,11 @@ if it is preceded by a negation mark, it will reject any address it is compared to, which may not be what you intended. If the entry is enclosed in parentheses, however, it will simply be ignored. -To match an IP address against an ACL, simply use the match operator: -:: +To match an IP address against an ACL, simply use the match operator:: - if (client.ip ~ local) { - return (pipe); - } + if (client.ip ~ local) { + return (pipe); + } Regular Expressions ------------------- @@ -346,54 +326,51 @@ complete description of PCRE please see the pcre(3) man page. To send flags to the PCRE engine, such as to turn on *case insensitivity* add the flag within parens following a question mark, -like this: -:: - - # If host is NOT example dot com.. - if (req.http.host !~ "(?i)example.com$") { - ... - } +like this:: + # If host is NOT example dot com.. + if (req.http.host !~ "(?i)example.com$") { + ... + } Functions --------- The following built-in functions are available: +ban(expression) + Bans all objects in cache that match the expression. + hash_data(str) - Adds a string to the hash input. In default.vcl hash_data() is - called on the host and URL of the *request*. + Adds a string to the hash input. In the built-in VCL hash_data() + is called on the host and URL of the *request*. regsub(str, regex, sub) - Returns a copy of str with the first occurrence of the regular + Returns a copy of str with the first occurrence of the regular expression regex replaced with sub. Within sub, \\0 (which can also be spelled \\&) is replaced with the entire matched string, - and \\n is replaced with the contents of subgroup n in the + and \\n is replaced with the contents of subgroup n in the matched string. regsuball(str, regex, sub) As regsub() but this replaces all occurrences. -ban(ban expression) - Bans all objects in cache that match the expression. - Subroutines ~~~~~~~~~~~ -A subroutine is used to group code for legibility or reusability: -:: - - sub pipe_if_local { - if (client.ip ~ local) { - return (pipe); +A subroutine is used to group code for legibility or reusability:: + + sub pipe_if_local { + if (client.ip ~ local) { + return (pipe); + } } - } Subroutines in VCL do not take arguments, nor do they return values. -To call a subroutine, use the call keyword followed by the subroutine's name: +To call a subroutine, use the call keyword followed by the subroutine's name:: -call pipe_if_local; + call pipe_if_local; There are a number of special subroutines which hook into the Varnish workflow. These subroutines may inspect and manipulate HTTP headers @@ -416,72 +393,87 @@ vcl_recv been received and parsed. Its purpose is to decide whether or not to serve the request, how to do it, and, if applicable, which backend to use. - + The vcl_recv subroutine may terminate with calling return() on one of the following keywords: - error code [reason] + error(code [, reason]) Return the specified error code to the client and abandon the request. - pass - Switch to pass mode. Control will eventually pass to vcl_pass. - - pipe - Switch to pipe mode. Control will eventually pass to vcl_pipe. - - lookup + hash Look up the requested object in the cache. Control will eventually pass to vcl_hit or vcl_miss, depending on whether the object is in the cache. The ``bereq.method`` value will be set to ``GET`` regardless of the value of ``req.method``. -vcl_pipe - Called upon entering pipe mode. In this mode, the request is passed - on to the backend, and any further data from either client or - backend is passed on unaltered until either end closes the - connection. - - The vcl_pipe subroutine may terminate with calling return() with one of - the following keywords: - - error code [reason] - Return the specified error code to the client and abandon the request. + pass + Switch to pass mode. Control will eventually pass to vcl_pass. pipe - Proceed with pipe mode. + Switch to pipe mode. Control will eventually pass to vcl_pipe. + + purge + ? vcl_pass Called upon entering pass mode. In this mode, the request is passed on to the backend, and the backend's response is passed on to the client, but is not entered into the cache. Subsequent requests submitted over the same client connection are handled normally. - + The vcl_pass subroutine may terminate with calling return() with one of the following keywords: - - error code [reason] + + error(code [, reason]) Return the specified error code to the client and abandon the request. - pass + fetch Proceed with pass mode. restart - Restart the transaction. Increases the restart counter. If the number - of restarts is higher than *max_restarts* Varnish emits a guru meditation + Restart the transaction. Increases the restart counter. If the number + of restarts is higher than *max_restarts* Varnish emits a guru meditation error. +vcl_pipe + Called upon entering pipe mode. In this mode, the request is passed + on to the backend, and any further data from either client or + backend is passed on unaltered until either end closes the + connection. + + The vcl_pipe subroutine may terminate with calling return() with one of + the following keywords: + + error(code [, reason]) + Return the specified error code to the client and abandon the request. + + pipe + Proceed with pipe mode. + +vcl_purge + ? + + The vcl_purge subroutine may terminate with calling return() with one of + the following keywords: + + error(code [, reason]) + Return the specified error code to the client and abandon the request. + +.. fetch +.. Not implemented. + vcl_hash You may call hash_data() on the data you would like to add to the hash. - + The vcl_hash subroutine may terminate with calling return() with one of the following keywords: - hash + lookup Proceed. vcl_hit Called after a cache lookup if the requested document was found in the cache. - + The vcl_hit subroutine may terminate with calling return() with one of the following keywords: @@ -489,69 +481,73 @@ vcl_hit Deliver the cached object to the client. Control will eventually pass to vcl_deliver. - error code [reason] + error(code [, reason]) Return the specified error code to the client and abandon the request. + fetch + ? + pass Switch to pass mode. Control will eventually pass to vcl_pass. restart - Restart the transaction. Increases the restart counter. If the number - of restarts is higher than *max_restarts* Varnish emits a guru meditation + Restart the transaction. Increases the restart counter. If the number + of restarts is higher than *max_restarts* Varnish emits a guru meditation error. vcl_miss Called after a cache lookup if the requested document was not found in the cache. Its purpose is to decide whether or not to attempt to retrieve the document from the backend, and which backend to use. - + The vcl_miss subroutine may terminate with calling return() with one of the following keywords: - error code [reason] + error(code [, reason]) Return the specified error code to the client and abandon the request. + fetch + Retrieve the requested object from the backend. Control will + eventually pass to vcl_backend_fetch. + pass Switch to pass mode. Control will eventually pass to vcl_pass. + restart + ? + +vcl_backend_fetch + ? + + The vcl_backend_fetch subroutine may terminate with calling return() + with one of the following keywords: + + abandon + ? + fetch Retrieve the requested object from the backend. Control will - eventually pass to vcl_fetch. + eventually pass to vcl_backend_response. -vcl_fetch +vcl_backend_response Called after a document has been successfully retrieved from the backend. - - The vcl_fetch subroutine may terminate with calling return() with - one of the following keywords: + + The vcl_backend_response subroutine may terminate with calling return() + with one of the following keywords: + + abandon + ? deliver Possibly insert the object into the cache, then deliver it to the client. Control will eventually pass to vcl_deliver. - error code [reason] - Return the specified error code to the client and abandon the request. - - hit_for_pass - Pass in fetch. Passes the object without caching it. This will - create a so-called hit_for_pass object which has the side effect - that the decision not to cache will be cached. This is to allow - would-be uncachable requests to be passed to the backend at the - same time. The same logic is not necessary in vcl_recv because - this happens before any potential queueing for an object takes - place. Note that the TTL for the hit_for_pass object will be set - to what the current value of beresp.ttl is. Control will be - handled to vcl_deliver on the current request, but subsequent - requests will go directly to vcl_pass based on the hit_for_pass - object. - - restart - Restart the transaction. Increases the restart counter. If the number - of restarts is higher than *max_restarts* Varnish emits a guru meditation - error. + retry + ? vcl_deliver Called before a cached object is delivered to the client. - + The vcl_deliver subroutine may terminate with one of the following keywords: @@ -559,23 +555,23 @@ vcl_deliver Deliver the object to the client. restart - Restart the transaction. Increases the restart counter. If the number - of restarts is higher than *max_restarts* Varnish emits a guru meditation + Restart the transaction. Increases the restart counter. If the number + of restarts is higher than *max_restarts* Varnish emits a guru meditation error. vcl_error - Called when we hit an error, either explicitly or implicitly due to + Called when we hit an error, either explicitly or implicitly due to backend or internal errors. The vcl_error subroutine may terminate by calling return with one of the following keywords: - + deliver Deliver the error object to the client. restart - Restart the transaction. Increases the restart counter. If the number - of restarts is higher than *max_restarts* Varnish emits a guru meditation + Restart the transaction. Increases the restart counter. If the number + of restarts is higher than *max_restarts* Varnish emits a guru meditation error. vcl_fini @@ -587,7 +583,6 @@ vcl_fini ok Normal return, VCL will be discarded. - If one of these subroutines is left undefined or terminates without reaching a handling decision, control will be handed over to the builtin default. See the EXAMPLES section for a listing of the @@ -601,30 +596,29 @@ appear in the source. The default versions distributed with Varnish will be implicitly concatenated as a last resort at the end. -Example: -:: +Example:: - # in file "main.vcl" - include "backends.vcl"; - include "ban.vcl"; - - # in file "backends.vcl" - sub vcl_recv { - if (req.http.host ~ "(?i)example.com") { - set req.backend = foo; - } elsif (req.http.host ~ "(?i)example.org") { - set req.backend = bar; - } + # in file "main.vcl" + include "backends.vcl"; + include "ban.vcl"; + + # in file "backends.vcl" + sub vcl_recv { + if (req.http.host ~ "(?i)example.com") { + set req.backend_hint = foo; + } elsif (req.http.host ~ "(?i)example.org") { + set req.backend_hint = bar; } + } - # in file "ban.vcl" - sub vcl_recv { - if (client.ip ~ admin_network) { + # in file "ban.vcl" + sub vcl_recv { + if (client.ip ~ admin_network) { if (req.http.Cache-Control ~ "no-cache") { - ban("req.url ~ " + req.url); - } - } - } + ban("req.url ~ " + req.url); + } + } + } Variables ~~~~~~~~~ @@ -634,7 +628,7 @@ made available to the handler subroutines through global variables. The following variables are always available: -now +now The current time, in seconds since the epoch. When used in string context it returns a formatted string. @@ -654,26 +648,22 @@ client.ip client.identity Identification of the client, used to load balance in the client director. -server.hostname - The host name of the server. - -server.identity - The identity of the server, as set by the -i - parameter. If the -i parameter is not passed to varnishd, - server.identity will be set to the name of the instance, as - specified by the -n parameter. - server.ip The IP address of the socket on which the client connection was received. -server.port - The port number of the socket on which the client connection was received. +server.hostname + The host name of the server. + +server.identity + The identity of the server, as set by the -i parameter. + If the -i parameter is not passed to varnishd, server.identity will be + set to the name of the instance, as specified by the -n parameter. req.method The request type (e.g. "GET", "HEAD"). req.request - Outdated way to spell req.method. + For backward compatibility. Same as req.method. req.url The requested URL. @@ -681,31 +671,17 @@ req.url req.proto The HTTP protocol version used by the client. -req.backend - The backend to use to service the request. - -req.backend.healthy - Whether the backend is healthy or not. Requires an active probe to be set - on the backend. - req.http.header The corresponding HTTP header. -req.hash_always_miss - Force a cache miss for this request. If set to true Varnish will disregard - any existing objects and always (re)fetch from the backend. - -req.hash_ignore_busy - Ignore any busy object during cache lookup. You would want to do - this if you have two server looking up content from each other to - avoid potential deadlocks. +req.backend_hint + Set bereq.backend to this if we attempt to fetch. This variable is + a convenience so the overall policy can be set up once and for all + in vcl_recv. req.can_gzip Does the client accept the gzip transfer encoding. -req.restarts - A count of how many times this request has been restarted. - req.esi Boolean. Set to false to disable ESI processing regardless of any value in beresp.do_esi. Defaults to true. This variable is subject @@ -714,8 +690,20 @@ req.esi req.esi_level A count of how many levels of ESI requests we're currently at. -req.grace - Set to a period to enable grace. +req.hash_always_miss + Force a cache miss for this request. If set to true Varnish will disregard + any existing objects and always (re)fetch from the backend. + +req.hash_ignore_busy + Ignore any busy object during cache lookup. You would want to do + this if you have two server looking up content from each other to + avoid potential deadlocks. + +req.restarts + A count of how many times this request has been restarted. + +req.ttl + ? req.xid Unique ID of this request. @@ -727,7 +715,7 @@ bereq.method The request type (e.g. "GET", "HEAD"). bereq.request - Outdated way to spell bereq.method. + For backward compatibility. Same as bereq.method. bereq.url The requested URL. @@ -738,43 +726,29 @@ bereq.proto bereq.http.header The corresponding HTTP header. +bereq.backend + ? + +bereq.between_bytes_timeout + The time in seconds to wait between each received byte from the + backend. Not available in pipe mode. + bereq.connect_timeout The time in seconds to wait for a backend connection. bereq.first_byte_timeout - The time in seconds to wait for the first byte from the backend. Not + The time in seconds to wait for the first byte from the backend. Not available in pipe mode. -bereq.between_bytes_timeout - The time in seconds to wait between each received byte from the - backend. Not available in pipe mode. +bereq.retries + ? + +bereq.uncacheable + ? The following variables are available after the requested object has been retrieved from the backend, before it is entered into the cache. In -other words, they are available in vcl_fetch: - -beresp.do_stream - Deliver the object to the client directly without fetching the whole - object into Varnish. If this request is pass'ed it will not be - stored in memory. As of Varnish Cache 3.0 the object will marked as busy - as it is delivered so only client can access the object. - -beresp.do_esi - Boolean. ESI-process the object after fetching it. Defaults to - false. Set it to true to parse the object for ESI directives. Will - only be honored if req.esi is true. - -beresp.do_gzip - Boolean. Gzip the object before storing it. Defaults to false. When - http_gzip_support is on Varnish will request already compressed - content from the backend and as such compression in Varnish is not needed. - -beresp.do_gunzip - Boolean. Unzip the object before storing it in the cache. Defaults - to false. - -beresp.http.header - The corresponding HTTP header. +other words, they are available in vcl_backend_response: beresp.proto The HTTP protocol version used the backend replied with. @@ -782,31 +756,57 @@ beresp.proto beresp.status The HTTP status code returned by the server. -beresp.response +beresp.reason The HTTP status message returned by the server. -beresp.ttl - The object's remaining time to live, in seconds. beresp.ttl is writable. +beresp.response + For backward compatibility. Same as beresp.reason. -beresp.grace - Set to a period to enable grace. +beresp.http.header + The corresponding HTTP header. -beresp.saintmode - Set to a period to enable saint mode. +beresp.backend.ip + IP of the backend this response was fetched from. beresp.backend.name Name of the backend this response was fetched from. -beresp.backend.ip - IP of the backend this response was fetched from. +beresp.do_esi + Boolean. ESI-process the object after fetching it. Defaults to + false. Set it to true to parse the object for ESI directives. Will + only be honored if req.esi is true. + +beresp.do_gunzip + Boolean. Unzip the object before storing it in the cache. Defaults to + false. + +beresp.do_gzip + Boolean. Gzip the object before storing it. Defaults to false. When + http_gzip_support is on Varnish will request already compressed + content from the backend and as such compression in Varnish is not needed. + +beresp.do_stream + Deliver the object to the client directly without fetching the whole + object into varnish. If this request is pass'ed it will not be + stored in memory. As of Varnish Cache 3.0 the object will marked as busy + as it is delivered so only client can access the object. + +beresp.grace + Set to a period to enable grace. -beresp.backend.port - Port of the backend this response was fetched from. +beresp.keep + ? -beresp.storage - Set to force Varnish to save this object to a particular storage +beresp.storage_hint + Hint to Varnish that you want to save this object to a particular storage backend. +beresp.ttl + The object's remaining time to live, in seconds. beresp.ttl is writable. + +beresp.uncacheable + ? + After the object is entered into the cache, the following (mostly read-only) variables are available when the object has been located in cache, typically in vcl_hit, or when constructing a synthetic reply in @@ -818,33 +818,35 @@ obj.proto obj.status The HTTP status code returned by the server. -obj.response +obj.reason The HTTP status message returned by the server. -obj.ttl - The object's remaining time to live, in seconds. obj.ttl is writable. +obj.response + For backward compatibility. Same as obj.reason. -obj.last_use - The approximate time elapsed since the object was last requests, in - seconds. This variable is also available in vcl_deliver. +obj.http.header + The corresponding HTTP header. + +obj.grace + The object's grace period in seconds. obj.grace is writable. obj.hits - The approximate number of times the object has been delivered. A value + The approximate number of times the object has been delivered. A value of 0 indicates a cache miss. This variable is also available in vcl_deliver. -obj.grace - The object's grace period in seconds. obj.grace is writable. +obj.keep + ? -obj.http.header - The corresponding HTTP header. +obj.last_use + The approximate time elapsed since the object was last requests, in + seconds. This variable is also available in vcl_deliver. -The following variables are available while determining the hash key -of an object: +obj.ttl + The object's remaining time to live, in seconds. obj.ttl is writable. -req.hash - The hash key used to refer to an object in the cache. Used when - both reading from and writing to the cache. +obj.uncacheable + ? The following variables are available while preparing a response to the client: @@ -854,32 +856,33 @@ resp.proto resp.status The HTTP status code that will be returned. -resp.response +resp.reason The HTTP status message that will be returned. +resp.response + For backward compatibility. Same as resp.reason. + resp.http.header The corresponding HTTP header. -Values may be assigned to variables using the set keyword: -:: +Values may be assigned to variables using the set keyword:: - sub vcl_recv { - # Normalize the Host: header - if (req.http.host ~ "(?i)^(www.)?example.com$") { - set req.http.host = "www.example.com"; + sub vcl_recv { + # Normalize the Host: header + if (req.http.host ~ "(?i)^(www.)?example.com$") { + set req.http.host = "www.example.com"; + } } - } -HTTP headers can be removed entirely using the remove keyword: -:: +HTTP headers can be removed entirely using the unset keyword:: - sub vcl_fetch { - # Don't cache cookies - remove beresp.http.Set-Cookie; - } + sub vcl_backend_response { + # Don't cache cookies + unset beresp.http.Set-Cookie; + } -Grace and saint mode --------------------- +Grace +----- If the backend takes a long time to generate an object there is a risk of a thread pile up. In order to prevent this you can enable *grace*. @@ -891,134 +894,116 @@ object will be kept up to two minutes past their expiration time or a fresh object is generated. :: - sub vcl_recv { - set req.grace = 2m; - } - sub vcl_fetch { - set beresp.grace = 2m; - } - -Saint mode is similar to grace mode and relies on the same -infrastructure but functions differently. You can add VCL code to -vcl_fetch to see whether or not you *like* the response coming from -the backend. If you find that the response is not appropriate you can -set beresp.saintmode to a time limit and call *restart*. Varnish will -then retry other backends to try to fetch the object again. - -If there are no more backends or if you hit *max_restarts* and we have -an object that is younger than what you set beresp.saintmode to be -Varnish will serve the object, even if it is stale. + sub vcl_backend_response { + set beresp.grace = 2m; + } EXAMPLES ======== The following code is the equivalent of the default configuration with the backend address set to "backend.example.com" and no backend port -specified: -:: +specified:: - backend default { - .host = "backend.example.com"; - .port = "http"; - } + backend default { + .host = "backend.example.com"; + .port = "http"; + } .. include:: ../../../bin/varnishd/builtin.vcl :literal: The following example shows how to support multiple sites running on separate backends in the same Varnish instance, by selecting backends -based on the request URL: -:: +based on the request URL:: - backend www { - .host = "www.example.com"; - .port = "80"; - } - - backend images { - .host = "images.example.com"; - .port = "80"; - } - - sub vcl_recv { - if (req.http.host ~ "(?i)^(www.)?example.com$") { - set req.http.host = "www.example.com"; - set req.backend = www; - } elsif (req.http.host ~ "(?i)^images.example.com$") { - set req.backend = images; - } else { - error 404 "Unknown virtual host"; + backend www { + .host = "www.example.com"; + .port = "80"; + } + + backend images { + .host = "images.example.com"; + .port = "80"; + } + + sub vcl_recv { + if (req.http.host ~ "(?i)^(www.)?example.com$") { + set req.http.host = "www.example.com"; + set req.backend_hint = www; + } elsif (req.http.host ~ "(?i)^images.example.com$") { + set req.backend_hint = images; + } else { + return (error(404, "Unknown virtual host")); + } } - } The following snippet demonstrates how to force a minimum TTL for all documents. Note that this is not the same as setting the default_ttl run-time parameter, as that only affects document for -which the backend did not specify a TTL: -:: - - import std; # needed for std.log +which the backend did not specify a TTL:: + + import std; # needed for std.log - sub vcl_fetch { - if (beresp.ttl < 120s) { - std.log("Adjusting TTL"); - set beresp.ttl = 120s; + sub vcl_backend_response { + if (beresp.ttl < 120s) { + std.log("Adjusting TTL"); + set beresp.ttl = 120s; + } } - } The following snippet demonstrates how to force Varnish to cache -documents even when cookies are present: -:: +documents even when cookies are present:: - sub vcl_recv { - if (req.method == "GET" && req.http.cookie) { - return(lookup); + sub vcl_recv { + if (req.method == "GET" && req.http.cookie) { + return (hash); + } + } + + sub vcl_backend_response { + if (beresp.http.Set-Cookie) { + return (deliver); + } } - } - - sub vcl_fetch { - if (beresp.http.Set-Cookie) { - return(deliver); - } - } The following code implements the HTTP PURGE method as used by Squid -for object invalidation: -:: +for object invalidation:: - acl purge { - "localhost"; - "192.0.2.1"/24; - } + acl purge { + "localhost"; + "192.0.2.1"/24; + } - sub vcl_recv { - if (req.method == "PURGE") { - if (!client.ip ~ purge) { - error 405 "Not allowed."; - } - return(lookup); + sub vcl_recv { + if (req.method == "PURGE") { + if (!client.ip ~ purge) { + return (error(405, "Not allowed.")); + } + return (hash); + } } - } - sub vcl_hit { - if (req.method == "PURGE") { - purge; - error 200 "Purged."; + sub vcl_hit { + if (req.method == "PURGE") { + purge; + return (error(200, "Purged.")); + } } - } - sub vcl_miss { - if (req.method == "PURGE") { - purge; - error 200 "Purged."; + sub vcl_miss { + if (req.method == "PURGE") { + purge; + return (error(200, "Purged.")); + } } - } SEE ALSO ======== * varnishd(1) -* vmod_std(7) +* vmod_directors(3) +* vmod_std(3) HISTORY ======= From fgsch at lodoss.net Mon Feb 17 08:07:24 2014 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Mon, 17 Feb 2014 09:07:24 +0100 Subject: [master] eeb8d58 Various fixes Message-ID: commit eeb8d58715b023fdd5938790931bafd97c52f662 Author: Federico G. Schwindt Date: Mon Feb 17 08:03:57 2014 +0000 Various fixes Spelling. While here also fix indentation and make sure we are using the right name for the variables and not the backward compat ones. diff --git a/bin/varnishd/builtin.vcl b/bin/varnishd/builtin.vcl index 3a723e3..00f5f6c 100644 --- a/bin/varnishd/builtin.vcl +++ b/bin/varnishd/builtin.vcl @@ -105,7 +105,7 @@ sub vcl_hit { return (deliver); } if (obj.ttl + obj.grace > 0s) { - // Object is in grace, delive it + // Object is in grace, deliver it // Automatically triggers a background fetch return (deliver); } @@ -132,7 +132,7 @@ sub vcl_backend_response { /* * Mark as "Hit-For-Pass" for the next 2 minutes */ - set beresp.ttl = 120 s; + set beresp.ttl = 120s; set beresp.uncacheable = true; } return (deliver); @@ -150,7 +150,7 @@ sub vcl_deliver { } /* - * We can come here "invisibly" with the following errors: 413, 417 & 503 + * We can come here "invisibly" with the following errors: 413, 417 & 503 */ sub vcl_error { set obj.http.Content-Type = "text/html; charset=utf-8"; @@ -161,11 +161,11 @@ sub vcl_error { "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> - "} + obj.status + " " + obj.response + {" + "} + obj.status + " " + obj.reason + {" -

Error "} + obj.status + " " + obj.response + {"

-

"} + obj.response + {"

+

Error "} + obj.status + " " + obj.reason + {"

+

"} + obj.reason + {"

Guru Meditation:

XID: "} + req.xid + {"


@@ -177,9 +177,9 @@ sub vcl_error { } sub vcl_init { - return (ok); + return (ok); } sub vcl_fini { - return (ok); + return (ok); } From fgsch at lodoss.net Mon Feb 17 08:53:57 2014 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Mon, 17 Feb 2014 09:53:57 +0100 Subject: [master] ed27a26 Improve manpage formatting Message-ID: commit ed27a2634576f9911e01b23db05065833a924abe Author: Federico G. Schwindt Date: Mon Feb 17 08:44:13 2014 +0000 Improve manpage formatting Add a second parameter to $Module to specify the manpage section and change how the description is printed. diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py index 959f203..be6cff6 100755 --- a/lib/libvcc/vmodtool.py +++ b/lib/libvcc/vmodtool.py @@ -93,11 +93,12 @@ class token(object): ####################################################################### class vmod(object): - def __init__(self, nam, dnam): + def __init__(self, nam, dnam, sec): if not is_c_name(nam): raise Exception("Module name '%s' is illegal" % nam) self.nam = nam self.dnam = dnam + self.sec = sec self.init = None self.funcs = list() self.objs = list() @@ -243,11 +244,18 @@ class vmod(object): self.doc_str.append(l) def doc_dump(self, fo, suf): - i = "vmod_" + self.nam + " -- " + self.dnam + i = "vmod_" + self.nam fo.write("=" * len(i) + "\n") fo.write(i + "\n") fo.write("=" * len(i) + "\n") fo.write("\n") + i = self.dnam + fo.write("-" * len(i) + "\n") + fo.write(i + "\n") + fo.write("-" * len(i) + "\n") + fo.write("\n") + fo.write(":Manual section: %s\n" % self.sec) + fo.write("\n") fo.write("SYNOPSIS\n") fo.write("========\n") fo.write("\n") @@ -529,11 +537,12 @@ def parse_enum2(tl): def parse_module(tl): nm = tl.get_token().str + sec = tl.get_token().str s = "" while len(tl.tl) > 0: s += " " + tl.get_token().str dnm = s[1:] - return vmod(nm, dnm) + return vmod(nm, dnm, sec) ####################################################################### # From fgsch at lodoss.net Mon Feb 17 08:53:58 2014 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Mon, 17 Feb 2014 09:53:58 +0100 Subject: [master] 962aa94 Pass the section Message-ID: commit 962aa9422cb50f8f1dd5180f226ebeadab56f2c9 Author: Federico G. Schwindt Date: Mon Feb 17 08:51:18 2014 +0000 Pass the section diff --git a/lib/libvmod_debug/vmod.vcc b/lib/libvmod_debug/vmod.vcc index 4f74a24..71a98d6 100644 --- a/lib/libvmod_debug/vmod.vcc +++ b/lib/libvmod_debug/vmod.vcc @@ -25,7 +25,7 @@ # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. -$Module debug Development, test and debug +$Module debug 3 Development, test and debug DESCRIPTION =========== diff --git a/lib/libvmod_directors/vmod.vcc b/lib/libvmod_directors/vmod.vcc index 37d8f56..609fc77 100644 --- a/lib/libvmod_directors/vmod.vcc +++ b/lib/libvmod_directors/vmod.vcc @@ -25,7 +25,7 @@ # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. -$Module directors Backend traffic directors +$Module directors 3 Backend traffic directors $Object round_robin() $Method VOID .add_backend(BACKEND) diff --git a/lib/libvmod_std/vmod.vcc b/lib/libvmod_std/vmod.vcc index 1a66dbd..a777801 100644 --- a/lib/libvmod_std/vmod.vcc +++ b/lib/libvmod_std/vmod.vcc @@ -25,7 +25,7 @@ # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. -$Module std Varnish Standard Module +$Module std 3 Varnish Standard Module DESCRIPTION =========== From fgsch at lodoss.net Mon Feb 17 09:11:18 2014 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Mon, 17 Feb 2014 10:11:18 +0100 Subject: [master] 6131dc9 Hook the vmod_directors manpage Message-ID: commit 6131dc97727b6e5029d2ad771b53f3a6129a75ae Author: Federico G. Schwindt Date: Mon Feb 17 09:04:52 2014 +0000 Hook the vmod_directors manpage diff --git a/lib/libvmod_directors/Makefile.am b/lib/libvmod_directors/Makefile.am index d44839d..7b66787 100644 --- a/lib/libvmod_directors/Makefile.am +++ b/lib/libvmod_directors/Makefile.am @@ -6,12 +6,14 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/bin/varnishd \ -I$(top_builddir)/include +dist_man_MANS = vmod_directors.3 + vmoddir = $(pkglibdir)/vmods vmod_srcdir = $(top_srcdir)/lib/libvmod_directors vmodtool = $(top_srcdir)/lib/libvcc/vmodtool.py vmod_LTLIBRARIES = libvmod_directors.la -libvmod_directors_la_LDFLAGS = $(AM_LDFLAGS) -module -export-dynamic -avoid-version -shared -rpath /nowhere +libvmod_directors_la_LDFLAGS = $(AM_LDFLAGS) -module -export-dynamic -avoid-version -shared libvmod_directors_la_SOURCES = \ vdir.c \ @@ -36,3 +38,13 @@ EXTRA_DIST = vmod.vcc CLEANFILES = $(builddir)/vcc_if.c $(builddir)/vcc_if.h \ $(builddir)/vmod_directors.rst \ $(builddir)/vmod_directors.man.rst + +vmod_directors.3: $(vmod_srcdir)/vmod_directors.man.rst +if HAVE_RST2MAN + ${RST2MAN} $? $@ +else + @echo "========================================" + @echo "You need rst2man installed to make dist" + @echo "========================================" + @false +endif From fgsch at lodoss.net Mon Feb 17 09:11:18 2014 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Mon, 17 Feb 2014 10:11:18 +0100 Subject: [master] 5c3ce45 Use the generated rst when creating the manpage Message-ID: commit 5c3ce452c58e0c7cb8c55cea8071b92249efb013 Author: Federico G. Schwindt Date: Mon Feb 17 09:05:33 2014 +0000 Use the generated rst when creating the manpage diff --git a/lib/libvmod_std/Makefile.am b/lib/libvmod_std/Makefile.am index cd8aebf..2e27af5 100644 --- a/lib/libvmod_std/Makefile.am +++ b/lib/libvmod_std/Makefile.am @@ -37,7 +37,7 @@ CLEANFILES = $(builddir)/vcc_if.c $(builddir)/vcc_if.h \ $(builddir)/vmod_std.rst \ $(builddir)/vmod_std.man.rst -vmod_std.3: $(top_srcdir)/doc/sphinx/reference/vmod_std.rst +vmod_std.3: $(vmod_srcdir)/vmod_std.man.rst if HAVE_RST2MAN ${RST2MAN} $? $@ else From phk at FreeBSD.org Mon Feb 17 09:29:55 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 17 Feb 2014 10:29:55 +0100 Subject: [master] 70d557a Fix test-case to match updated error from compiler. Message-ID: commit 70d557a65de408cb2177bb6047dbd305f073d330 Author: Poul-Henning Kamp Date: Mon Feb 17 09:28:55 2014 +0000 Fix test-case to match updated error from compiler. Varnishtest not run by: fgs diff --git a/bin/varnishtest/tests/v00016.vtc b/bin/varnishtest/tests/v00016.vtc index 7a00d95..69e99e5 100644 --- a/bin/varnishtest/tests/v00016.vtc +++ b/bin/varnishtest/tests/v00016.vtc @@ -73,7 +73,7 @@ varnish v1 -vcl { } -varnish v1 -errvcl {Unknown time unit 'k'. Legal are 's', 'm', 'h' and 'd'} { +varnish v1 -errvcl {Unknown time unit 'k'. Legal are 'ms', 's', 'm', 'h', 'd' and 'w'} { backend b { .host = "127.0.0.1"; } sub vcl_backend_response { set obj.ttl = 1. k; } } From fgsch at lodoss.net Mon Feb 17 10:04:31 2014 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Mon, 17 Feb 2014 11:04:31 +0100 Subject: [master] e85e0aa Ensure rst files are built before generating the manpages Message-ID: commit e85e0aae8197bdcec0aa15dae4b4c41753f08441 Author: Federico G. Schwindt Date: Mon Feb 17 10:01:14 2014 +0000 Ensure rst files are built before generating the manpages diff --git a/lib/libvmod_directors/Makefile.am b/lib/libvmod_directors/Makefile.am index 7b66787..087ecbb 100644 --- a/lib/libvmod_directors/Makefile.am +++ b/lib/libvmod_directors/Makefile.am @@ -28,7 +28,7 @@ nodist_libvmod_directors_la_SOURCES = \ vcc_if.h # BUILT_SOURCES is only a hack and dependency tracking does not help for the first build -vdir.lo fall_back.lo hash.lo random.lo round_robin.lo: vcc_if.h +vdir.lo fall_back.lo hash.lo random.lo round_robin.lo vmod_directors.rst vmod_directors.man.rst: vcc_if.h vcc_if.c vcc_if.h: $(vmodtool) $(vmod_srcdir)/vmod.vcc @PYTHON@ $(vmodtool) $(vmod_srcdir)/vmod.vcc diff --git a/lib/libvmod_std/Makefile.am b/lib/libvmod_std/Makefile.am index 2e27af5..bd66ab1 100644 --- a/lib/libvmod_std/Makefile.am +++ b/lib/libvmod_std/Makefile.am @@ -26,7 +26,7 @@ nodist_libvmod_std_la_SOURCES = \ vcc_if.h # BUILT_SOURCES is only a hack and dependency tracking does not help for the first build -vmod_std.lo vmod_std_fileread.lo vmod_std_conversions.lo: vcc_if.h +vmod_std.lo vmod_std_fileread.lo vmod_std_conversions.lo vmod_std.rst vmod_std.man.rst: vcc_if.h vcc_if.c vcc_if.h: $(vmodtool) $(vmod_srcdir)/vmod.vcc @PYTHON@ $(vmodtool) $(vmod_srcdir)/vmod.vcc From phk at FreeBSD.org Mon Feb 17 11:06:11 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 17 Feb 2014 12:06:11 +0100 Subject: [master] c14936b Fix uintmax_t printf format arguments. Message-ID: commit c14936bcfff366c8aae97d159d5fcd98050a3058 Author: Poul-Henning Kamp Date: Mon Feb 17 11:05:45 2014 +0000 Fix uintmax_t printf format arguments. Fixes #1432 diff --git a/bin/varnishstat/varnishstat.c b/bin/varnishstat/varnishstat.c index 0971c10..10f6d51 100644 --- a/bin/varnishstat/varnishstat.c +++ b/bin/varnishstat/varnishstat.c @@ -65,7 +65,7 @@ do_xml_cb(void *priv, const struct VSC_point * const pt) if (strcmp(sec->fantom->ident, "")) printf("\t\t%s\n", sec->fantom->ident); printf("\t\t%s\n", pt->desc->name); - printf("\t\t%ju\n", val); + printf("\t\t%ju\n", (uintmax_t)val); printf("\t\t%c\n", pt->desc->flag); printf("\t\t%s\n", pt->desc->sdesc); printf("\t\n"); @@ -119,7 +119,7 @@ do_json_cb(void *priv, const struct VSC_point * const pt) if (strcmp(sec->fantom->ident, "")) printf("\"ident\": \"%s\", ", sec->fantom->ident); - printf("\"value\": %ju, ", val); + printf("\"value\": %ju, ", (uintmax_t)val); printf("\"flag\": \"%c\", ", pt->desc->flag); printf("\"description\": \"%s\"", pt->desc->sdesc); @@ -180,9 +180,11 @@ do_once_cb(void *priv, const struct VSC_point * const pt) op->pad = i + 1; printf("%*.*s", op->pad - i, op->pad - i, ""); if (pt->desc->flag == 'a' || pt->desc->flag == 'c') - printf("%12ju %12.2f %s\n", val, val / op->up, pt->desc->sdesc); + printf("%12ju %12.2f %s\n", + (uintmax_t)val, val / op->up, pt->desc->sdesc); else - printf("%12ju %12s %s\n", val, ". ", pt->desc->sdesc); + printf("%12ju %12s %s\n", + (uintmax_t)val, ". ", pt->desc->sdesc); return (0); } From fgsch at lodoss.net Mon Feb 17 12:28:55 2014 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Mon, 17 Feb 2014 13:28:55 +0100 Subject: [master] a5f678f Revert 5c3ce452, e85e0aae and 6131dc97 for now Message-ID: commit a5f678f47328c100f646a4162551d1c8dfdfd12a Author: Federico G. Schwindt Date: Mon Feb 17 12:23:45 2014 +0000 Revert 5c3ce452, e85e0aae and 6131dc97 for now They break the build if parallelised and make jenkins upset diff --git a/lib/libvmod_directors/Makefile.am b/lib/libvmod_directors/Makefile.am index 087ecbb..6a85ad5 100644 --- a/lib/libvmod_directors/Makefile.am +++ b/lib/libvmod_directors/Makefile.am @@ -6,8 +6,6 @@ AM_CPPFLAGS = \ -I$(top_srcdir)/bin/varnishd \ -I$(top_builddir)/include -dist_man_MANS = vmod_directors.3 - vmoddir = $(pkglibdir)/vmods vmod_srcdir = $(top_srcdir)/lib/libvmod_directors vmodtool = $(top_srcdir)/lib/libvcc/vmodtool.py @@ -28,7 +26,7 @@ nodist_libvmod_directors_la_SOURCES = \ vcc_if.h # BUILT_SOURCES is only a hack and dependency tracking does not help for the first build -vdir.lo fall_back.lo hash.lo random.lo round_robin.lo vmod_directors.rst vmod_directors.man.rst: vcc_if.h +vdir.lo fall_back.lo hash.lo random.lo round_robin.lo: vcc_if.h vcc_if.c vcc_if.h: $(vmodtool) $(vmod_srcdir)/vmod.vcc @PYTHON@ $(vmodtool) $(vmod_srcdir)/vmod.vcc @@ -38,13 +36,3 @@ EXTRA_DIST = vmod.vcc CLEANFILES = $(builddir)/vcc_if.c $(builddir)/vcc_if.h \ $(builddir)/vmod_directors.rst \ $(builddir)/vmod_directors.man.rst - -vmod_directors.3: $(vmod_srcdir)/vmod_directors.man.rst -if HAVE_RST2MAN - ${RST2MAN} $? $@ -else - @echo "========================================" - @echo "You need rst2man installed to make dist" - @echo "========================================" - @false -endif diff --git a/lib/libvmod_std/Makefile.am b/lib/libvmod_std/Makefile.am index bd66ab1..cd8aebf 100644 --- a/lib/libvmod_std/Makefile.am +++ b/lib/libvmod_std/Makefile.am @@ -26,7 +26,7 @@ nodist_libvmod_std_la_SOURCES = \ vcc_if.h # BUILT_SOURCES is only a hack and dependency tracking does not help for the first build -vmod_std.lo vmod_std_fileread.lo vmod_std_conversions.lo vmod_std.rst vmod_std.man.rst: vcc_if.h +vmod_std.lo vmod_std_fileread.lo vmod_std_conversions.lo: vcc_if.h vcc_if.c vcc_if.h: $(vmodtool) $(vmod_srcdir)/vmod.vcc @PYTHON@ $(vmodtool) $(vmod_srcdir)/vmod.vcc @@ -37,7 +37,7 @@ CLEANFILES = $(builddir)/vcc_if.c $(builddir)/vcc_if.h \ $(builddir)/vmod_std.rst \ $(builddir)/vmod_std.man.rst -vmod_std.3: $(vmod_srcdir)/vmod_std.man.rst +vmod_std.3: $(top_srcdir)/doc/sphinx/reference/vmod_std.rst if HAVE_RST2MAN ${RST2MAN} $? $@ else From fgsch at lodoss.net Mon Feb 17 12:28:55 2014 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Mon, 17 Feb 2014 13:28:55 +0100 Subject: [master] 1fbe580 Move vcl_hash close to vcl_recv Message-ID: commit 1fbe580804e0c58f5f541082b049c9a27d0187ac Author: Federico G. Schwindt Date: Mon Feb 17 12:28:17 2014 +0000 Move vcl_hash close to vcl_recv diff --git a/doc/sphinx/reference/vcl.rst b/doc/sphinx/reference/vcl.rst index 7e00e43..8cb7439 100644 --- a/doc/sphinx/reference/vcl.rst +++ b/doc/sphinx/reference/vcl.rst @@ -415,6 +415,15 @@ vcl_recv purge ? +vcl_hash + You may call hash_data() on the data you would like to add to the hash. + + The vcl_hash subroutine may terminate with calling return() with one of + the following keywords: + + lookup + Proceed. + vcl_pass Called upon entering pass mode. In this mode, the request is passed on to the backend, and the backend's response is passed on to the @@ -462,15 +471,6 @@ vcl_purge .. fetch .. Not implemented. -vcl_hash - You may call hash_data() on the data you would like to add to the hash. - - The vcl_hash subroutine may terminate with calling return() with one of - the following keywords: - - lookup - Proceed. - vcl_hit Called after a cache lookup if the requested document was found in the cache. From phk at FreeBSD.org Mon Feb 17 16:20:45 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 17 Feb 2014 17:20:45 +0100 Subject: [master] 8c66705 When changing the busyobj we should use broadcast so everybody hears. Message-ID: commit 8c6670580d04f02016b9302445bc97cb6ed1a14d Author: Poul-Henning Kamp Date: Mon Feb 17 16:20:00 2014 +0000 When changing the busyobj we should use broadcast so everybody hears. Spotted by: gquintard diff --git a/bin/varnishd/cache/cache_busyobj.c b/bin/varnishd/cache/cache_busyobj.c index 65a24bf..d6b43ae 100644 --- a/bin/varnishd/cache/cache_busyobj.c +++ b/bin/varnishd/cache/cache_busyobj.c @@ -222,7 +222,7 @@ VBO_extend(struct busyobj *bo, ssize_t l) CHECK_OBJ_NOTNULL(st, STORAGE_MAGIC); st->len += l; bo->fetch_obj->len += l; - AZ(pthread_cond_signal(&bo->cond)); + AZ(pthread_cond_broadcast(&bo->cond)); Lck_Unlock(&bo->mtx); } @@ -248,7 +248,7 @@ VBO_setstate(struct busyobj *bo, enum busyobj_state_e next) VSLb(bo->vsl, SLT_Debug, "XXX BOS: %d -> %d", bo->state, next); assert(next > bo->state); bo->state = next; - AZ(pthread_cond_signal(&bo->cond)); + AZ(pthread_cond_broadcast(&bo->cond)); Lck_Unlock(&bo->mtx); } From phk at FreeBSD.org Mon Feb 17 19:10:53 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 17 Feb 2014 20:10:53 +0100 Subject: [master] 8f26bf5 Bump the cli_timeout up to 60 seconds to reduce false alarms. Message-ID: commit 8f26bf57a3130ecf3efa75ad3a422500619ed8aa Author: Poul-Henning Kamp Date: Mon Feb 17 19:07:27 2014 +0000 Bump the cli_timeout up to 60 seconds to reduce false alarms. There seems to be a tendency for systems to trip up the previous 10 second cli_timeout during nightly housekeeping operations, possibly log rotation running out of cron. diff --git a/bin/varnishd/mgt/mgt_param_tbl.c b/bin/varnishd/mgt/mgt_param_tbl.c index 578bd85..b6ae75c 100644 --- a/bin/varnishd/mgt/mgt_param_tbl.c +++ b/bin/varnishd/mgt/mgt_param_tbl.c @@ -286,7 +286,7 @@ struct parspec mgt_parspec[] = { "Timeout for the childs replies to CLI requests from " "the mgt_param.", 0, - "10", "seconds" }, + "60", "seconds" }, { "ping_interval", tweak_uint, &mgt_param.ping_interval, "0", NULL, "Interval between pings from parent to child.\n" From fgsch at lodoss.net Mon Feb 17 21:07:58 2014 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Mon, 17 Feb 2014 22:07:58 +0100 Subject: [master] 1e0e7b4 Remove backward compatibility Message-ID: commit 1e0e7b4cb1dc4330ee0cacae89b971c4c1caaa1a Author: Federico G. Schwindt Date: Mon Feb 17 21:04:38 2014 +0000 Remove backward compatibility This kills `remove', `.request' and `.response'. Use `unset', `.method' and `.reason' instead. ok phk. diff --git a/bin/varnishtest/tests/b00018.vtc b/bin/varnishtest/tests/b00018.vtc index 3989b57..682c19c 100644 --- a/bin/varnishtest/tests/b00018.vtc +++ b/bin/varnishtest/tests/b00018.vtc @@ -9,7 +9,7 @@ varnish v1 -vcl+backend { sub vcl_backend_response { set beresp.http.Foo = "bar"; set beresp.status = 523; - set beresp.response = "not ok"; + set beresp.reason = "not ok"; set beresp.uncacheable = true; set beresp.ttl = 0s; return (deliver); diff --git a/bin/varnishtest/tests/b00019.vtc b/bin/varnishtest/tests/b00019.vtc index 6b33702..597e8b9 100644 --- a/bin/varnishtest/tests/b00019.vtc +++ b/bin/varnishtest/tests/b00019.vtc @@ -28,13 +28,13 @@ varnish v1 -vcl+backend { sub vcl_error { if (req.restarts == 2) { set obj.status = 200; - set obj.response = "restart=2"; + set obj.reason = "restart=2"; } elsif (req.restarts > 2) { set obj.status = 501; - set obj.response = "restart>2"; + set obj.reason = "restart>2"; } elsif (req.restarts < 2) { set obj.status = 500; - set obj.response = "restart<2"; + set obj.reason = "restart<2"; } } } -start diff --git a/bin/varnishtest/tests/b00035.vtc b/bin/varnishtest/tests/b00035.vtc deleted file mode 100644 index dbe8a6f..0000000 --- a/bin/varnishtest/tests/b00035.vtc +++ /dev/null @@ -1,26 +0,0 @@ -varnishtest "{be}req.request compat check" - -server s1 { - rxreq - expect req.method == "GETABCD" - txresp -} -start - -varnish v1 -vcl+backend { - - sub vcl_recv { - set req.method = req.request + "A"; - set req.request = req.method + "B"; - return (pass); - } - - sub vcl_backend_fetch { - set bereq.method = bereq.request + "C"; - set bereq.request = bereq.method + "D"; - } -} -start - -client c1 { - txreq - rxresp -} -run diff --git a/bin/varnishtest/tests/b00036.vtc b/bin/varnishtest/tests/b00036.vtc index cb0b6e5..4cd6e17 100644 --- a/bin/varnishtest/tests/b00036.vtc +++ b/bin/varnishtest/tests/b00036.vtc @@ -9,7 +9,7 @@ server s1 { varnish v1 -vcl+backend { sub vcl_recv { - if (req.request == "PURGE") { + if (req.method == "PURGE") { return (purge); } } diff --git a/bin/varnishtest/tests/r00292.vtc b/bin/varnishtest/tests/r00292.vtc index f6bc807..4972188 100644 --- a/bin/varnishtest/tests/r00292.vtc +++ b/bin/varnishtest/tests/r00292.vtc @@ -18,8 +18,8 @@ server s1 { varnish v1 -vcl+backend { sub vcl_recv { - remove req.http.hdr1; - remove req.http.hdr5; + unset req.http.hdr1; + unset req.http.hdr5; } } -start diff --git a/bin/varnishtest/tests/r00494.vtc b/bin/varnishtest/tests/r00494.vtc index 31a9d6e..cb0bbe8 100644 --- a/bin/varnishtest/tests/r00494.vtc +++ b/bin/varnishtest/tests/r00494.vtc @@ -11,7 +11,7 @@ server s1 { varnish v1 -vcl+backend { sub vcl_backend_response { set beresp.http.bar = beresp.http.foo; - remove beresp.http.foo; + unset beresp.http.foo; } } -start diff --git a/bin/varnishtest/tests/r00965.vtc b/bin/varnishtest/tests/r00965.vtc index 72317de..ccd01b5 100644 --- a/bin/varnishtest/tests/r00965.vtc +++ b/bin/varnishtest/tests/r00965.vtc @@ -8,7 +8,7 @@ server s1 { varnish v1 -vcl+backend { sub vcl_recv { if (req.http.X-Banned == "check") { - remove req.http.X-Banned; + unset req.http.X-Banned; } elseif (req.restarts == 0) { set req.http.X-Banned = "check"; if (req.http.x-pass) { diff --git a/bin/varnishtest/tests/v00001.vtc b/bin/varnishtest/tests/v00001.vtc index 4f77f25..1798ec9 100644 --- a/bin/varnishtest/tests/v00001.vtc +++ b/bin/varnishtest/tests/v00001.vtc @@ -1,4 +1,4 @@ -varnishtest "VCL/VRT: url/request/proto/response/status" +varnishtest "VCL/VRT: url/request/proto/reason/status" server s1 { @@ -28,14 +28,14 @@ varnish v1 -vcl+backend { } sub vcl_backend_response { set beresp.http.foobar = - beresp.proto + beresp.response + beresp.status; + beresp.proto + beresp.reason + beresp.status; set beresp.proto = "HTTP/1.2"; - set beresp.response = "For circular files"; + set beresp.reason = "For circular files"; set beresp.status = 903; } sub vcl_deliver { set resp.proto = "HTTP/1.2"; - set resp.response = "Naah, lets fail it"; + set resp.reason = "Naah, lets fail it"; set resp.status = 904; # XXX should be moved to it's own test set resp.http.x-served-by-hostname = server.hostname; diff --git a/doc/sphinx/reference/vcl.rst b/doc/sphinx/reference/vcl.rst index 8cb7439..9f384f8 100644 --- a/doc/sphinx/reference/vcl.rst +++ b/doc/sphinx/reference/vcl.rst @@ -662,9 +662,6 @@ server.identity req.method The request type (e.g. "GET", "HEAD"). -req.request - For backward compatibility. Same as req.method. - req.url The requested URL. @@ -714,9 +711,6 @@ request (either for a cache miss or for pass or pipe mode): bereq.method The request type (e.g. "GET", "HEAD"). -bereq.request - For backward compatibility. Same as bereq.method. - bereq.url The requested URL. @@ -759,9 +753,6 @@ beresp.status beresp.reason The HTTP status message returned by the server. -beresp.response - For backward compatibility. Same as beresp.reason. - beresp.http.header The corresponding HTTP header. @@ -821,9 +812,6 @@ obj.status obj.reason The HTTP status message returned by the server. -obj.response - For backward compatibility. Same as obj.reason. - obj.http.header The corresponding HTTP header. @@ -859,9 +847,6 @@ resp.status resp.reason The HTTP status message that will be returned. -resp.response - For backward compatibility. Same as resp.reason. - resp.http.header The corresponding HTTP header. diff --git a/lib/libvcc/generate.py b/lib/libvcc/generate.py index 01a6243..466bf6b 100755 --- a/lib/libvcc/generate.py +++ b/lib/libvcc/generate.py @@ -578,11 +578,6 @@ The client's IP address. # Backwards compatibility: aliases = [ - ('req.request', 'req.method'), - ('bereq.request', 'bereq.method'), - ('beresp.response', 'beresp.reason'), - ('resp.response', 'resp.reason'), - ('obj.response', 'obj.reason'), ] stv_variables = ( diff --git a/lib/libvcc/vcc_action.c b/lib/libvcc/vcc_action.c index 7e9bf2e..b0f7d98 100644 --- a/lib/libvcc/vcc_action.c +++ b/lib/libvcc/vcc_action.c @@ -411,7 +411,6 @@ static struct action_table { { "hash_data", parse_hash_data, VCL_MET_HASH }, { "new", parse_new, VCL_MET_INIT}, { "purge", parse_purge, VCL_MET_MISS | VCL_MET_HIT }, - { "remove", parse_unset }, /* backward compatibility */ { "return", parse_return }, { "rollback", parse_rollback }, { "set", parse_set }, From phk at FreeBSD.org Tue Feb 18 08:36:45 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 18 Feb 2014 09:36:45 +0100 Subject: [master] 603e1cb Add a currently unused vcl_backend_error{} method Message-ID: commit 603e1cbd752961c3cdd6fd5fc4f2e279f676ddec Author: Poul-Henning Kamp Date: Tue Feb 18 08:36:26 2014 +0000 Add a currently unused vcl_backend_error{} method diff --git a/bin/varnishd/builtin.vcl b/bin/varnishd/builtin.vcl index 00f5f6c..09c08cc 100644 --- a/bin/varnishd/builtin.vcl +++ b/bin/varnishd/builtin.vcl @@ -41,6 +41,9 @@ vcl 4.0; +####################################################################### +# Client side + sub vcl_recv { if (req.restarts == 0) { if (req.http.x-forwarded-for) { @@ -117,27 +120,6 @@ sub vcl_miss { return (fetch); } - -sub vcl_backend_fetch { - return (fetch); -} - -sub vcl_backend_response { - if (beresp.ttl <= 0s || - beresp.http.Set-Cookie || - beresp.http.Surrogate-control ~ "no-store" || - (!beresp.http.Surrogate-Control && - beresp.http.Cache-Control ~ "no-cache|no-store|private") || - beresp.http.Vary == "*") { - /* - * Mark as "Hit-For-Pass" for the next 2 minutes - */ - set beresp.ttl = 120s; - set beresp.uncacheable = true; - } - return (deliver); -} - sub vcl_deliver { /* * These two write to the stored object causing extra page faults @@ -176,6 +158,36 @@ sub vcl_error { return (deliver); } +####################################################################### +# Backend Fetch + +sub vcl_backend_fetch { + return (fetch); +} + +sub vcl_backend_response { + if (beresp.ttl <= 0s || + beresp.http.Set-Cookie || + beresp.http.Surrogate-control ~ "no-store" || + (!beresp.http.Surrogate-Control && + beresp.http.Cache-Control ~ "no-cache|no-store|private") || + beresp.http.Vary == "*") { + /* + * Mark as "Hit-For-Pass" for the next 2 minutes + */ + set beresp.ttl = 120s; + set beresp.uncacheable = true; + } + return (deliver); +} + +sub vcl_backend_error { + return (deliver); +} + +####################################################################### +# Housekeeping + sub vcl_init { return (ok); } diff --git a/lib/libvcc/generate.py b/lib/libvcc/generate.py index 466bf6b..0702465 100755 --- a/lib/libvcc/generate.py +++ b/lib/libvcc/generate.py @@ -78,6 +78,10 @@ tokens = { # Our methods and actions returns =( + + ############################################################### + # Client side + ('recv', "C", ('error', 'pass', 'pipe', 'hash', 'purge',) @@ -106,6 +110,18 @@ returns =( "C", ('error', 'restart', 'pass', 'fetch', 'deliver',) ), + ('deliver', + "C", + ('restart', 'deliver',) + ), + ('error', + "C", + ('restart', 'deliver',) + ), + + ############################################################### + # Backend-fetch + ('backend_fetch', "B", ('fetch', 'abandon') @@ -114,14 +130,14 @@ returns =( "B", ('deliver', 'retry', 'abandon') ), - ('deliver', - "C", - ('restart', 'deliver',) - ), - ('error', - "C", - ('restart', 'deliver',) + ('backend_error', + "B", + ('deliver', 'retry') ), + + ############################################################### + # Housekeeping + ('init', "", ('ok',) From lkarsten at varnish-software.com Wed Feb 19 13:58:40 2014 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Wed, 19 Feb 2014 14:58:40 +0100 Subject: [master] 86c21b6 Squash cosmetic compile error on ARMv7l Message-ID: commit 86c21b6f9abeb1aec918b3588642c720facb2014 Author: Lasse Karstensen Date: Wed Feb 19 14:57:43 2014 +0100 Squash cosmetic compile error on ARMv7l diff --git a/bin/varnishncsa/varnishncsa.c b/bin/varnishncsa/varnishncsa.c index c7157f4..7434070 100644 --- a/bin/varnishncsa/varnishncsa.c +++ b/bin/varnishncsa/varnishncsa.c @@ -853,7 +853,7 @@ dispatch_f(struct VSL_data *vsl, struct VSL_transaction * const pt[], int main(int argc, char * const *argv) { - char opt; + signed char opt; char *format = NULL; memset(&CTX, 0, sizeof CTX); From perbu at varnish-software.com Thu Feb 20 19:23:20 2014 From: perbu at varnish-software.com (Per Buer) Date: Thu, 20 Feb 2014 20:23:20 +0100 Subject: [master] 79a0da1 Fix for OS X/Darvin Message-ID: commit 79a0da1f306631812fb5c666534a5473afadd34e Author: Per Buer Date: Wed Feb 19 15:16:47 2014 +0100 Fix for OS X/Darvin diff --git a/bin/varnishtest/tests/r00310.vtc b/bin/varnishtest/tests/r00310.vtc index 6a5ce22..38c8a32 100644 --- a/bin/varnishtest/tests/r00310.vtc +++ b/bin/varnishtest/tests/r00310.vtc @@ -1,7 +1,7 @@ varnishtest "Test obj.http.x-cache in vcl_hit" varnish v1 -errvcl {'obj.http.x-cache': cannot be set in method 'vcl_hit'.} { - backend foo { .host = "localhost"; } + backend foo { .host = "127.0.0.1"; } sub vcl_hit { set obj.http.x-cache = "hit"; From perbu at varnish-software.com Thu Feb 20 19:23:20 2014 From: perbu at varnish-software.com (Per Buer) Date: Thu, 20 Feb 2014 20:23:20 +0100 Subject: [master] 05d0d53 rewrite for readability Message-ID: commit 05d0d5306e558096d39f57641559ab4f9a08e834 Author: Per Buer Date: Thu Feb 20 19:28:48 2014 +0100 rewrite for readability diff --git a/doc/sphinx/tutorial/introduction.rst b/doc/sphinx/tutorial/introduction.rst index 5241575..3f65968 100644 --- a/doc/sphinx/tutorial/introduction.rst +++ b/doc/sphinx/tutorial/introduction.rst @@ -8,23 +8,23 @@ clients and tries to answer them from its cache. If it cannot answer the request from its cache it will forward the request to the backend, fetch the response, store it and deliver it to the client. +When Varnish has a cached response ready it is typically delivered in +a matter of microseconds, several orders of magnitude faster than your +typical application server, so you want to make sure to have it answer +as many of the requests as possible. + Varnish decides whether it can store the content or not based on the response it's gets back from the backend. The backend can instruct Varnish to cache the content with the HTTP response header -Cache-Control. - -Varnish will be very careful when it encounters cookies, either coming -from the client or from the origin server. When Varnish sees a -Set-Cookie header on a response it decides that the object is not -cacheable. When there is a Cookie header in the request it will also -refuse to serve a cached object and rather ask the backend for version -of the object that is tailored to the request. +Cache-Control. There are a few other conditions where Varnish will not +cache, the most common one being cookies. Since cookies is a good +indication that a web object is personlised, Varnish will with it's +default configuration, not cache it. This behaviour and most other behaviour can be changed using policies written in the Varnish Configuration Language. See the Users Guide for more information on how to do that. - Performance ~~~~~~~~~~~ From perbu at varnish-software.com Thu Feb 20 19:23:20 2014 From: perbu at varnish-software.com (Per Buer) Date: Thu, 20 Feb 2014 20:23:20 +0100 Subject: [master] b161676 remove cruft Message-ID: commit b161676f4222e946ab7f1554f3b66807916e3b75 Author: Per Buer Date: Thu Feb 20 19:29:11 2014 +0100 remove cruft diff --git a/doc/sphinx/tutorial/putting_varnish_on_port_80.rst b/doc/sphinx/tutorial/putting_varnish_on_port_80.rst index db3c7fb..acef0c6 100644 --- a/doc/sphinx/tutorial/putting_varnish_on_port_80.rst +++ b/doc/sphinx/tutorial/putting_varnish_on_port_80.rst @@ -2,9 +2,8 @@ Put Varnish on port 80 ---------------------- -Until now we've been running with Varnish on a high port, for testing -purposes. You probably don't want to do this in the long term so let's -put Varnish on port 80. +Until now we've been running with Varnish on a high port, which is +great for testing purposes. Lets put Varnish on the default HTTP port. First we stop varnish:: @@ -16,7 +15,8 @@ Now we need to edit the configuration file that starts Varnish. Debian/Ubuntu ~~~~~~~~~~~~~ -On Debian/Ubuntu this is /etc/default/varnish. In the file you'll find some text that looks like this:: +On Debian/Ubuntu this is /etc/default/varnish. In the file you'll find +some text that looks like this:: DAEMON_OPTS="-a :6081 \ -T localhost:6082 \ From perbu at varnish-software.com Thu Feb 20 19:23:20 2014 From: perbu at varnish-software.com (Per Buer) Date: Thu, 20 Feb 2014 20:23:20 +0100 Subject: [master] 74bc2ec Remove commentary Message-ID: commit 74bc2ec05e2b7d54c6b792c714a8839a4eb57063 Author: Per Buer Date: Thu Feb 20 19:39:04 2014 +0100 Remove commentary diff --git a/doc/sphinx/users-guide/index.rst b/doc/sphinx/users-guide/index.rst index 7b909c9..ced7723 100644 --- a/doc/sphinx/users-guide/index.rst +++ b/doc/sphinx/users-guide/index.rst @@ -4,7 +4,6 @@ The Varnish Users Guide %%%%%%%%%%%%%%%%%%%%%%%%%%%%% -(The plan for ...) The Varnish documentation consists of three main documents: * :ref:`tutorial-index` explains the basics and gets you started with Varnish. From perbu at varnish-software.com Thu Feb 20 19:23:20 2014 From: perbu at varnish-software.com (Per Buer) Date: Thu, 20 Feb 2014 20:23:20 +0100 Subject: [master] f180ee4 Remove commentary Message-ID: commit f180ee4a6f440e1870c3e8df67f81a29ffad11d3 Author: Per Buer Date: Thu Feb 20 19:39:18 2014 +0100 Remove commentary diff --git a/doc/sphinx/users-guide/intro.rst b/doc/sphinx/users-guide/intro.rst index 79b4c06..18b4a1d 100644 --- a/doc/sphinx/users-guide/intro.rst +++ b/doc/sphinx/users-guide/intro.rst @@ -105,4 +105,3 @@ Yes, we've all been there, haven't we? When things go wrong :ref:`users_trouble` will hopefully be of some help. -And now, lets put som substance on this skeleton outline... From perbu at varnish-software.com Thu Feb 20 19:23:20 2014 From: perbu at varnish-software.com (Per Buer) Date: Thu, 20 Feb 2014 20:23:20 +0100 Subject: [master] 840f5cf spelling Message-ID: commit 840f5cf7cc84115946b8268fe7de98fd106ea51a Author: Per Buer Date: Thu Feb 20 19:39:35 2014 +0100 spelling diff --git a/doc/sphinx/users-guide/params.rst b/doc/sphinx/users-guide/params.rst index d3a10af..a283d51 100644 --- a/doc/sphinx/users-guide/params.rst +++ b/doc/sphinx/users-guide/params.rst @@ -3,7 +3,7 @@ Parameters ---------- -Varnish Cache has a set of parameter that affect its behaviour and +Varnish Cache has a set of parameters that affect its behaviour and performance. Most of these parameters can be set on the Varnish command line (through varnishadm) using the param.set keyword. From perbu at varnish-software.com Thu Feb 20 19:23:20 2014 From: perbu at varnish-software.com (Per Buer) Date: Thu, 20 Feb 2014 20:23:20 +0100 Subject: [master] 794e231 Add reference to ACLs Message-ID: commit 794e23178ac91d065f75f14ad17bb1492ce2b73c Author: Per Buer Date: Thu Feb 20 19:40:15 2014 +0100 Add reference to ACLs diff --git a/doc/sphinx/users-guide/run_security.rst b/doc/sphinx/users-guide/run_security.rst index 16ab277..dfcfc6d 100644 --- a/doc/sphinx/users-guide/run_security.rst +++ b/doc/sphinx/users-guide/run_security.rst @@ -223,6 +223,5 @@ to various kinds of attacks and subversive activities. If you have "administrative" HTTP requests, for instance PURGE requests, we strongly recommend that you restrict them to trusted -IP numbers/nets using VCL's Access Control Lists. +IP numbers/nets using VCL's :ref:`vcl_syntax_acl`. -.. (XXX: missing ref to ACL) From perbu at varnish-software.com Thu Feb 20 19:23:20 2014 From: perbu at varnish-software.com (Per Buer) Date: Thu, 20 Feb 2014 20:23:20 +0100 Subject: [master] 5a68ff7 add label Message-ID: commit 5a68ff7e4e9744decb01566bd1ccac8c6734e476 Author: Per Buer Date: Thu Feb 20 19:40:56 2014 +0100 add label diff --git a/doc/sphinx/users-guide/vcl-syntax.rst b/doc/sphinx/users-guide/vcl-syntax.rst index c979bb5..14e07ed 100644 --- a/doc/sphinx/users-guide/vcl-syntax.rst +++ b/doc/sphinx/users-guide/vcl-syntax.rst @@ -25,6 +25,8 @@ including ", newline and other control characters except for the NUL (0x00) character. If you really want NUL characters in a string there is a VMOD that makes it possible to create such strings. +.. _vcl_syntax_acl: + Access control lists (ACLs) ~~~~~~~~~~~~~~~~~~~~~~~~~~~ From perbu at varnish-software.com Thu Feb 20 19:23:20 2014 From: perbu at varnish-software.com (Per Buer) Date: Thu, 20 Feb 2014 20:23:20 +0100 Subject: [master] bdcda11 remove redundant intro Message-ID: commit bdcda11174040a31de91939cc3523edba21c56e1 Author: Per Buer Date: Thu Feb 20 19:41:24 2014 +0100 remove redundant intro diff --git a/doc/sphinx/users-guide/vcl.rst b/doc/sphinx/users-guide/vcl.rst index 53d99e3..0e56c3a 100644 --- a/doc/sphinx/users-guide/vcl.rst +++ b/doc/sphinx/users-guide/vcl.rst @@ -34,7 +34,6 @@ code commented out in default.vcl that ships with Varnish Cache. .. toctree:: :maxdepth: 1 - vcl-intro vcl-syntax vcl-built-in-subs vcl-variables From perbu at varnish-software.com Thu Feb 20 19:23:20 2014 From: perbu at varnish-software.com (Per Buer) Date: Thu, 20 Feb 2014 20:23:20 +0100 Subject: [master] 30f2ac8 Fixed some things. Lots more to do on this one Message-ID: commit 30f2ac823b6ce0a8d4d15767de331322cdfa72ef Author: Per Buer Date: Thu Feb 20 20:23:08 2014 +0100 Fixed some things. Lots more to do on this one diff --git a/doc/sphinx/users-guide/vcl-built-in-subs.rst b/doc/sphinx/users-guide/vcl-built-in-subs.rst index 0ab6ced..2202af0 100644 --- a/doc/sphinx/users-guide/vcl-built-in-subs.rst +++ b/doc/sphinx/users-guide/vcl-built-in-subs.rst @@ -1,31 +1,26 @@ .. _vcl-built-in-subs: -Built in subroutines --------------------- - - -vcl_init -~~~~~~~~ +.. XXX This document needs substational review. - Called when VCL is loaded, before any requests pass through it. - Typically used to initialize VMODs. - return() values: +Built in subroutines +-------------------- - ok - Normal return, VCL continues loading. vcl_recv ~~~~~~~~ - Called at the beginning of a request, after the complete request has - been received and parsed. Its purpose is to decide whether or not - to serve the request, how to do it, and, if applicable, which backend - to use. +Called at the beginning of a request, after the complete request has +been received and parsed. Its purpose is to decide whether or not to +serve the request, how to do it, and, if applicable, which backend to +use. - The vcl_recv subroutine may terminate with calling ``return()`` on one of - the following keywords: +It is also used to modify the request, something you'll probably find +yourself doing frequently. + +The vcl_recv subroutine may terminate with calling ``return()`` on one +of the following keywords: error code [reason] Return the specified error code to the client and abandon the request. @@ -43,71 +38,22 @@ vcl_recv to ``GET`` regardless of the value of ``req.method``. -vcl_pipe -~~~~~~~~ - Called upon entering pipe mode. In this mode, the request is passed - on to the backend, and any further data from either client or - backend is passed on unaltered until either end closes the - connection. +vcl_backend_fetch +~~~~~~~~~~~~~~~~~ - The vcl_pipe subroutine may terminate with calling return() with one of - the following keywords: +Called before sending the backend request. In this subroutine you +typically alter the request before it gets to the backend. - error code [reason] - Return the specified error code to the client and abandon the request. +.. XXX Return statements? - pipe - Proceed with pipe mode. -vcl_pass -~~~~~~~~ - - Called upon entering pass mode. In this mode, the request is passed - on to the backend, and the backend's response is passed on to the - client, but is not entered into the cache. Subsequent requests - submitted over the same client connection are handled normally. - - The vcl_pass subroutine may terminate with calling return() with one - of the following keywords: - - error code [reason] - Return the specified error code to the client and abandon the request. - - pass - Proceed with pass mode. - - restart - Restart the transaction. Increases the restart counter. If the number - of restarts is higher than *max_restarts* Varnish emits a guru meditation - error. - -vcl_miss -~~~~~~~~ - -Called after a cache lookup if the requested document was not found in -the cache. Its purpose is to decide whether or not to attempt to -retrieve the document from the backend, and which backend to use. - -The vcl_miss subroutine may terminate with calling return() with one -of the following keywords: - - error code [reason] - Return the specified error code to the client and abandon the request. - - pass - Switch to pass mode. Control will eventually pass to vcl_pass. - - fetch - Retrieve the requested object from the backend. Control will - eventually pass to vcl_fetch. - -vcl_fetch -~~~~~~~~~ +vcl_backend_response +~~~~~~~~~~~~~~~~~~~ Called after a document has been successfully retrieved from the backend. -The vcl_fetch subroutine may terminate with calling return() with one +The vcl_backend_response subroutine may terminate with calling return() with one of the following keywords: deliver @@ -151,13 +97,13 @@ keywords: of restarts is higher than *max_restarts* Varnish emits a guru meditation error. -vcl_error -~~~~~~~~~ +vcl_backend_error +~~~~~~~~~~~~~~~~~ Called when we hit an error, either explicitly or implicitly due to backend or internal errors. -The vcl_error subroutine may terminate by calling return with one of +The vcl_backend_error subroutine may terminate by calling return with one of the following keywords: deliver @@ -168,11 +114,85 @@ the following keywords: of restarts is higher than *max_restarts* Varnish emits a guru meditation error. + +vcl_pipe +~~~~~~~~ + +Called upon entering pipe mode. In this mode, the request is passed +on to the backend, and any further data from either client or +backend is passed on unaltered until either end closes the +connection. + + The vcl_pipe subroutine may terminate with calling return() with one of + the following keywords: + + error code [reason] + Return the specified error code to the client and abandon the request. + + pipe + Proceed with pipe mode. + +vcl_pass +~~~~~~~~ + +Called upon entering pass mode. In this mode, the request is passed +on to the backend, and the backend's response is passed on to the +client, but is not entered into the cache. Subsequent requests +submitted over the same client connection are handled normally. + +The vcl_pass subroutine may terminate with calling return() with one +of the following keywords: + + error code [reason] + Return the specified error code to the client and abandon the request. + + pass + Proceed with pass mode. + + restart + Restart the transaction. Increases the restart counter. If the number + of restarts is higher than *max_restarts* Varnish emits a guru meditation + error. + +vcl_miss +~~~~~~~~ + +Called after a cache lookup if the requested document was not found in +the cache. Its purpose is to decide whether or not to attempt to +retrieve the document from the backend, and which backend to use. + +The vcl_miss subroutine may terminate with calling return() with one +of the following keywords: + + error code [reason] + Return the specified error code to the client and abandon the request. + + pass + Switch to pass mode. Control will eventually pass to vcl_pass. + + fetch + Retrieve the requested object from the backend. Control will + eventually pass to vcl_fetch. + + + +vcl_init +~~~~~~~~ + +Called when VCL is loaded, before any requests pass through it. +Typically used to initialize VMODs. + + return() values: + + ok + Normal return, VCL continues loading. + + vcl_fini ~~~~~~~~ - Called when VCL is discarded only after all requests have exited the VCL. - Typically used to clean up VMODs. +Called when VCL is discarded only after all requests have exited the VCL. +Typically used to clean up VMODs. return() values: From perbu at varnish-software.com Fri Feb 21 11:09:46 2014 From: perbu at varnish-software.com (Per Buer) Date: Fri, 21 Feb 2014 12:09:46 +0100 Subject: [master] f03a993 4.0 updates Message-ID: commit f03a993b0f04894f99d8931c06eaabdcb60c694d Author: Per Buer Date: Fri Feb 21 12:07:48 2014 +0100 4.0 updates diff --git a/doc/sphinx/users-guide/vcl-variables.rst b/doc/sphinx/users-guide/vcl-variables.rst index 15999cc..f21e30e 100644 --- a/doc/sphinx/users-guide/vcl-variables.rst +++ b/doc/sphinx/users-guide/vcl-variables.rst @@ -11,15 +11,17 @@ In VCL, there several important objects. do on or with the req object. *bereq* - The backend request object. + The backend request object. Varnish contructs this before sending it to the + backend. *beresp* - The backend respons object. It contains the headers of the object - coming from the backend. Most of the work you do in vcl_fetch you - do on the beresp object. + The backend response object. It contains the headers of the object + coming from the backend. If you want to modify the reponse coming from the + server you modify this object in vcl_backend_reponse. *resp* - The HTTP response right before it is delivered to the client. + The HTTP response right before it is delivered to the client. It is + typically modified in vcl_deliver. *obj* The object as it is stored in cache. Mostly read only. From perbu at varnish-software.com Fri Feb 21 11:09:46 2014 From: perbu at varnish-software.com (Per Buer) Date: Fri, 21 Feb 2014 12:09:46 +0100 Subject: [master] 033c75b Update example.vcl Message-ID: commit 033c75b7bb7a0692982c1c06dc2026c0382ca30b Author: Per Buer Date: Fri Feb 21 10:54:08 2014 +0100 Update example.vcl diff --git a/etc/example.vcl b/etc/example.vcl index c093552..b99ec90 100644 --- a/etc/example.vcl +++ b/etc/example.vcl @@ -5,7 +5,7 @@ # The builtin VCL is called when there is no explicit explicit return # statement. # -# See the VCL tutorial at https://www.varnish-cache.org/docs/trunk/tutorial/ +# See the VCL chapters in the Users Guide at https://www.varnish-cache.org/docs/ # and http://varnish-cache.org/trac/wiki/VCLExamples for more examples. # Marker to tell the VCL compiler that this VCL has been adapted to the @@ -20,16 +20,21 @@ backend default { sub vcl_recv { # Happens before we check if we have this in cache already. - # See http://www.varnish-cache.org/docs/3.0/tutorial/vcl.html#vcl_recv + # + # Typically you clean up the request here, removing cookies you don't need, + # rewriting the request, etc. } sub vcl_backend_response { # Happens after we have read the response headers from the backend. - # See http://www.varnish-cache.org/docs/3.0/tutorial/vcl.html#vcl_fetch + # + # Here you clean the response headers, removing silly Set-Cookie headers + # and other mistakes your backend does. } sub vcl_deliver { # Happens when we have all the pieces we need, and are about to send the # response to the client. - # See http://www.varnish-cache.org/docs/3.0/tutorial/vcl.html#vcl_fetch + # + # You can do accounting or modifying the final object here. } From perbu at varnish-software.com Fri Feb 21 11:09:46 2014 From: perbu at varnish-software.com (Per Buer) Date: Fri, 21 Feb 2014 12:09:46 +0100 Subject: [master] 03893a9 4.0 updates Message-ID: commit 03893a974183b5468d72bab9b032c0c453843af1 Author: Per Buer Date: Fri Feb 21 12:08:20 2014 +0100 4.0 updates diff --git a/doc/sphinx/users-guide/vcl-actions.rst b/doc/sphinx/users-guide/vcl-actions.rst index c981051..fc5a0da 100644 --- a/doc/sphinx/users-guide/vcl-actions.rst +++ b/doc/sphinx/users-guide/vcl-actions.rst @@ -21,7 +21,7 @@ The most common actions to return are these: *lookup* When you return lookup from vcl_recv you tell Varnish to deliver content from cache even if the request othervise indicates that the request - should be passed. You can't return lookup from vcl_fetch. + should be passed. *pipe* Pipe can be returned from vcl_recv as well. Pipe short circuits the @@ -34,3 +34,12 @@ The most common actions to return are these: *deliver* Deliver the cached object to the client. Usually returned from vcl_fetch. + +*restart* + Restart processing of the request. You can restart the processing of + the whole transaction. Changes to the req object are retained. + +*retry* + Retry the request against the backend. This can be called from + vcl_backend_response or vcl_backend_error if you don't like the response + that the backend delivered. From perbu at varnish-software.com Fri Feb 21 20:09:31 2014 From: perbu at varnish-software.com (Per Buer) Date: Fri, 21 Feb 2014 21:09:31 +0100 Subject: [master] b84796f 4.0 syntax changes Message-ID: commit b84796f178b9501539e0ab553f0fcb9302b5ab12 Author: Per Buer Date: Fri Feb 21 21:05:07 2014 +0100 4.0 syntax changes diff --git a/doc/sphinx/users-guide/compression.rst b/doc/sphinx/users-guide/compression.rst index 5e21511..d611807 100644 --- a/doc/sphinx/users-guide/compression.rst +++ b/doc/sphinx/users-guide/compression.rst @@ -29,7 +29,7 @@ backend sends content in clear text it will be stored like that. You can make Varnish compress content before storing it in cache in vcl_fetch by setting do_gzip to true, like this:: - sub vcl_fetch { + sub vcl_backend_response { if (beresp.http.content-type ~ "text") { set beresp.do_gzip = true; } From perbu at varnish-software.com Fri Feb 21 20:09:31 2014 From: perbu at varnish-software.com (Per Buer) Date: Fri, 21 Feb 2014 21:09:31 +0100 Subject: [master] e5840a2 rename Message-ID: commit e5840a2f6d82f305a528912632cad3e08a4f61ff Author: Per Buer Date: Fri Feb 21 21:04:15 2014 +0100 rename diff --git a/doc/sphinx/users-guide/orphans.rst b/doc/sphinx/users-guide/orphans.rst new file mode 100644 index 0000000..76fbf5d --- /dev/null +++ b/doc/sphinx/users-guide/orphans.rst @@ -0,0 +1,11 @@ +Orphans +======= + +XXX: These are chapters which need to find a new home in the other sections. + +.. toctree:: + :maxdepth: 2 + + esi + vary + cookies From perbu at varnish-software.com Fri Feb 21 20:09:31 2014 From: perbu at varnish-software.com (Per Buer) Date: Fri, 21 Feb 2014 21:09:31 +0100 Subject: [master] 96b94ac Add -b flag to help debugging Message-ID: commit 96b94ac5d3e2dbf81ce9f6f051ba422274341af3 Author: Per Buer Date: Fri Feb 21 21:05:36 2014 +0100 Add -b flag to help debugging diff --git a/doc/sphinx/users-guide/increasing-your-hitrate.rst b/doc/sphinx/users-guide/increasing-your-hitrate.rst index b5fa17e..fe1161d 100644 --- a/doc/sphinx/users-guide/increasing-your-hitrate.rst +++ b/doc/sphinx/users-guide/increasing-your-hitrate.rst @@ -23,7 +23,7 @@ Tool: varnishtop ~~~~~~~~~~~~~~~~ You can use varnishtop to identify what URLs are hitting the backend -the most. ``varnishtop -i txurl`` is an essential command. You can see +the most. ``varnishtop -b -i txurl`` is an essential command. You can see some other examples of varnishtop usage in :ref:`users-guide-statistics`. From perbu at varnish-software.com Fri Feb 21 20:09:31 2014 From: perbu at varnish-software.com (Per Buer) Date: Fri, 21 Feb 2014 21:09:31 +0100 Subject: [master] eafac81 call the orphans orphans Message-ID: commit eafac811e45e916ae168e200140b9d853bbdb689 Author: Per Buer Date: Fri Feb 21 21:05:59 2014 +0100 call the orphans orphans diff --git a/doc/sphinx/users-guide/index.rst b/doc/sphinx/users-guide/index.rst index ced7723..efe6d25 100644 --- a/doc/sphinx/users-guide/index.rst +++ b/doc/sphinx/users-guide/index.rst @@ -45,7 +45,7 @@ Detailed Table of Contents: report performance troubleshooting - operation + orphans .. customizing (which is a non ideal title) From perbu at varnish-software.com Fri Feb 21 20:09:31 2014 From: perbu at varnish-software.com (Per Buer) Date: Fri, 21 Feb 2014 21:09:31 +0100 Subject: [master] 9fc490c minor nitpicking Message-ID: commit 9fc490c3e0d1590cd7af9fad1011783d6690d41b Author: Per Buer Date: Fri Feb 21 21:06:34 2014 +0100 minor nitpicking diff --git a/doc/sphinx/users-guide/operation-logging.rst b/doc/sphinx/users-guide/operation-logging.rst index aaf3bb5..547a987 100644 --- a/doc/sphinx/users-guide/operation-logging.rst +++ b/doc/sphinx/users-guide/operation-logging.rst @@ -5,10 +5,12 @@ Logging in Varnish One of the really nice features in Varnish is how logging works. Instead of logging to normal log file Varnish logs to a shared -memory segment. When the end of the segment is reached we start over, -overwriting old data. This is much, much faster than logging to a file -and it doesn't require disk space. Besides it gives you much, much -more information when you need it. +memory segment, called the VSL - the Varnish Shared Log. When the end +of the segment is reached we start over, overwriting old data. + +This is much, much faster than logging to a file and it doesn't +require disk space. Besides it gives you much, much more information +when you need it. The flip side is that if you forget to have a program actually write the logs to disk they will disappear. @@ -40,12 +42,12 @@ app. You'll see lines like these.:: 11 RxHeader c Host: localhost:8080 11 RxHeader c Connection: keep-alive -The first column is an arbitrary number, it defines the request. Lines -with the same number are part of the same HTTP transaction. The second -column is the *tag* of the log message. All log entries are tagged -with a tag indicating what sort of activity is being logged. Tags -starting with Rx indicate Varnish is recieving data and Tx indicates -sending data. +The first column is an arbitrary number, it identifies the +session. Lines with the same number are coming from the same session +and are being handled by the same thread. The second column is the +*tag* of the log message. All log entries are tagged with a tag +indicating what sort of activity is being logged. Tags starting with +Rx indicate Varnish is recieving data and Tx indicates sending data. The third column tell us whether this is is data coming or going to the client (c) or to/from the backend (b). The forth column is the From perbu at varnish-software.com Fri Feb 21 20:09:31 2014 From: perbu at varnish-software.com (Per Buer) Date: Fri, 21 Feb 2014 21:09:31 +0100 Subject: [master] a66b2ff Remove varnishsizes, add reference to man pages Message-ID: commit a66b2ffb0e6f8adad7d3b1cc5e5c20248e83641a Author: Per Buer Date: Fri Feb 21 21:07:22 2014 +0100 Remove varnishsizes, add reference to man pages diff --git a/doc/sphinx/users-guide/operation-statistics.rst b/doc/sphinx/users-guide/operation-statistics.rst index 8736c5e..c891342 100644 --- a/doc/sphinx/users-guide/operation-statistics.rst +++ b/doc/sphinx/users-guide/operation-statistics.rst @@ -23,6 +23,8 @@ is being asked the most. ``varnishtop -i RxHeader -I Accept-Encoding`` will show the most popular Accept-Encoding header the client are sending you. +For more information please see :ref:`ref-varnishtop`. + varnishhist ~~~~~~~~~~~ @@ -33,13 +35,7 @@ vertical scale are displayed in the top left corner. The horizontal scale is logarithmic. Hits are marked with a pipe character ("|"), and misses are marked with a hash character ("#"). - -varnishsizes -~~~~~~~~~~~~ - -Varnishsizes does the same as varnishhist, except it shows the size of -the objects and not the time take to complete the request. This gives -you a good overview of how big the objects you are serving are. +For more information please see :ref:`ref-varnishhist`. varnishstat @@ -55,3 +51,4 @@ graphs of these counters. One such program is Munin. Munin can be found at http://munin-monitoring.org/ . There is a plugin for munin in the Varnish source code. +For more information please see :ref:`ref-varnishstat`. From perbu at varnish-software.com Fri Feb 21 20:09:31 2014 From: perbu at varnish-software.com (Per Buer) Date: Fri, 21 Feb 2014 21:09:31 +0100 Subject: [master] df8c054 comment the VCL for clarity Message-ID: commit df8c054419e6867eb178f68a94d536293b83fc85 Author: Per Buer Date: Fri Feb 21 21:07:44 2014 +0100 comment the VCL for clarity diff --git a/doc/sphinx/users-guide/purging.rst b/doc/sphinx/users-guide/purging.rst index 5604d96..38de2d3 100644 --- a/doc/sphinx/users-guide/purging.rst +++ b/doc/sphinx/users-guide/purging.rst @@ -39,6 +39,7 @@ following VCL in place:: if (!client.ip ~ purge) { error 405 "Not allowed."; } + # jump to hit/miss return (lookup); } } @@ -133,7 +134,7 @@ object is not available in the ban lurker thread. You can use the following template to write ban lurker friendly bans:: - sub vcl_fetch { + sub vcl_backend_response { set beresp.http.x-url = req.url; } From perbu at varnish-software.com Fri Feb 21 20:09:31 2014 From: perbu at varnish-software.com (Per Buer) Date: Fri, 21 Feb 2014 21:09:31 +0100 Subject: [master] 5ef8de8 4.0 updates to vcl + language Message-ID: commit 5ef8de8c9e35adec2c27323cd694d2428767a199 Author: Per Buer Date: Fri Feb 21 21:08:16 2014 +0100 4.0 updates to vcl + language diff --git a/doc/sphinx/users-guide/vcl-backends.rst b/doc/sphinx/users-guide/vcl-backends.rst index dc9a3cb..d5b1aae 100644 --- a/doc/sphinx/users-guide/vcl-backends.rst +++ b/doc/sphinx/users-guide/vcl-backends.rst @@ -115,8 +115,14 @@ Directors You can also group several backend into a group of backends. These groups are called directors. This will give you increased performance -and resilience. You can define several backends and group them -together in a director.:: +and resilience. + +You can define several backends and group them together in a +director. This requires you to load a VMOD, a Varnish module, and then to +call certain actions in vcl_init.:: + + + import directors; # load the directors backend server1 { .host = "192.168.0.10"; @@ -125,24 +131,21 @@ together in a director.:: .host = "192.168.0.10"; } -Now we create the director.:: - - director example_director round-robin { - { - .backend = server1; + sub vcl_init { + new bar = directors.round_robin(); + bar.add_backend(server1); + bar.add_backend(server2); } - # server2 - { - .backend = server2; - } - # foo + + sub vcl_recv { + # send all traffic to the bar director: + req.backend = bar.backend; } - This director is a round-robin director. This means the director will distribute the incoming requests on a round-robin basis. There is also a *random* director which distributes requests in a, you guessed -it, random fashion. +it, random fashion. But what if one of your servers goes down? Can Varnish direct all the requests to the healthy server? Sure it can. This is where the Health @@ -202,7 +205,9 @@ initial Now we define the director.:: - director example_director round-robin { + import directors; + + director example_director round-robin { { .backend = server1; } From perbu at varnish-software.com Fri Feb 21 20:09:31 2014 From: perbu at varnish-software.com (Per Buer) Date: Fri, 21 Feb 2014 21:09:31 +0100 Subject: [master] 7f443a3 rename Message-ID: commit 7f443a3ae77acabfab7d4d05fdbe45fa09189c47 Author: Per Buer Date: Fri Feb 21 21:09:21 2014 +0100 rename diff --git a/doc/sphinx/users-guide/operation.rst b/doc/sphinx/users-guide/operation.rst deleted file mode 100644 index 76fbf5d..0000000 --- a/doc/sphinx/users-guide/operation.rst +++ /dev/null @@ -1,11 +0,0 @@ -Orphans -======= - -XXX: These are chapters which need to find a new home in the other sections. - -.. toctree:: - :maxdepth: 2 - - esi - vary - cookies From tfheen at fastly.com Fri Feb 21 22:45:08 2014 From: tfheen at fastly.com (Tollef Fog Heen) Date: Fri, 21 Feb 2014 23:45:08 +0100 Subject: [master] 96b94ac Add -b flag to help debugging In-Reply-To: References: Message-ID: TxURL will always be towards the backend to -b or not doesn't make any real difference.? - T -------------- next part -------------- An HTML attachment was scrubbed... URL: From perbu at varnish-software.com Mon Feb 24 08:42:58 2014 From: perbu at varnish-software.com (Per Buer) Date: Mon, 24 Feb 2014 09:42:58 +0100 Subject: [master] 6737d14 Ignore various autogenerated files Message-ID: commit 6737d14391b3e30ecd54cebe89d450c3e9ebe79d Author: Per Buer Date: Mon Feb 24 09:42:41 2014 +0100 Ignore various autogenerated files diff --git a/.gitignore b/.gitignore index 35dfbe7..a6d7219 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ Makefile.in *.la *~ *.sw[op] +*.trs # Various auto-tools artifacts @@ -78,6 +79,8 @@ cscope.*out /man/vsc2rst /man/*.7 /man/*.1 +/bin/*/*.1 +/bin/*/*.rst /doc/sphinx/include /bin/varnish*/varnish*_opt2rst /bin/varnishadm/varnishadm From perbu at varnish-software.com Mon Feb 24 09:49:04 2014 From: perbu at varnish-software.com (Per Buer) Date: Mon, 24 Feb 2014 10:49:04 +0100 Subject: [master] b47c027 4.0 updates Message-ID: commit b47c02728e029d9bc8a9a03afe913fb6c297b132 Author: Per Buer Date: Mon Feb 24 10:49:02 2014 +0100 4.0 updates diff --git a/doc/sphinx/users-guide/increasing-your-hitrate.rst b/doc/sphinx/users-guide/increasing-your-hitrate.rst index fe1161d..9d1dc67 100644 --- a/doc/sphinx/users-guide/increasing-your-hitrate.rst +++ b/doc/sphinx/users-guide/increasing-your-hitrate.rst @@ -146,7 +146,8 @@ header. You could easily add support for this header in VCL. In vcl_fetch:: if (beresp.http.Pragma ~ "nocache") { - return(hit_for_pass); + set beresp.uncacheable = true; + set beresp.ttl = 120s; // how long not to cache this url. } Authorization diff --git a/doc/sphinx/users-guide/vcl-actions.rst b/doc/sphinx/users-guide/vcl-actions.rst index fc5a0da..691baa4 100644 --- a/doc/sphinx/users-guide/vcl-actions.rst +++ b/doc/sphinx/users-guide/vcl-actions.rst @@ -10,14 +10,6 @@ The most common actions to return are these: and from the backend server. It won't be cached. pass can be returned from vcl_recv -*hit_for_pass* - Similar to pass, but accessible from vcl_fetch. Unlike pass, hit_for_pass - will create a hitforpass object in the cache. This has the side-effect of - caching the decision not to cache. This is to allow would-be uncachable - requests to be passed to the backend at the same time. The same logic is - not necessary in vcl_recv because this happens before any potential - queueing for an object takes place. - *lookup* When you return lookup from vcl_recv you tell Varnish to deliver content from cache even if the request othervise indicates that the request @@ -33,7 +25,7 @@ The most common actions to return are these: header before actually returning pipe. *deliver* - Deliver the cached object to the client. Usually returned from vcl_fetch. + Deliver the object to the client. Usually returned from vcl_backend_response. *restart* Restart processing of the request. You can restart the processing of diff --git a/doc/sphinx/users-guide/vcl-variables.rst b/doc/sphinx/users-guide/vcl-variables.rst index f21e30e..20fcd4e 100644 --- a/doc/sphinx/users-guide/vcl-variables.rst +++ b/doc/sphinx/users-guide/vcl-variables.rst @@ -12,7 +12,7 @@ In VCL, there several important objects. *bereq* The backend request object. Varnish contructs this before sending it to the - backend. + backend. It is based on the req object. *beresp* The backend response object. It contains the headers of the object From martin at varnish-software.com Mon Feb 24 12:50:14 2014 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Mon, 24 Feb 2014 13:50:14 +0100 Subject: [master] 2f580e2 Fix std.duration documentation of qualifiers Message-ID: commit 2f580e27c311060d4fc92fb600ec4aa865c4907d Author: Martin Blix Grydeland Date: Mon Feb 24 13:36:46 2014 +0100 Fix std.duration documentation of qualifiers std.duration conversion function has a mandatory qualifier. Change the wording from 'can' to 'must' specify the qualifier. Add a test case for a string without a qualifier. diff --git a/bin/varnishtest/tests/m00005.vtc b/bin/varnishtest/tests/m00005.vtc index 2ea397a..aa7143d 100644 --- a/bin/varnishtest/tests/m00005.vtc +++ b/bin/varnishtest/tests/m00005.vtc @@ -85,4 +85,10 @@ client c1 { expect resp.http.ttl == 1000002.000 expect resp.bodylen == 1 + txreq -url "/1" -hdr "ttl: 100" + rxresp + expect resp.status == 200 + expect resp.http.ttl == 1000002.000 + expect resp.bodylen == 1 + } -run diff --git a/lib/libvmod_std/vmod.vcc b/lib/libvmod_std/vmod.vcc index a777801..a55371c 100644 --- a/lib/libvmod_std/vmod.vcc +++ b/lib/libvmod_std/vmod.vcc @@ -111,9 +111,10 @@ Example $Function DURATION duration(STRING, DURATION) Description - Converts the string *s* to seconds. *s* can be quantified with - the usual s (seconds), m (minutes), h (hours), d (days) and w - (weeks) units. If *s* fails to parse, *fallback* will be returned. + Converts the string *s* to seconds. *s* must be quantified + with the usual s (seconds), m (minutes), h (hours), d (days) + and w (weeks) units. If *s* fails to parse, *fallback* will be + returned. Example set beresp.ttl = std.duration("1w", 3600s); From martin at varnish-software.com Mon Feb 24 12:50:14 2014 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Mon, 24 Feb 2014 13:50:14 +0100 Subject: [master] d35ed6e Add 'ms' conversion qualifier to std.duration Message-ID: commit d35ed6e2617203a0ce9d5cd27bb2286720efab73 Author: Martin Blix Grydeland Date: Mon Feb 24 13:48:38 2014 +0100 Add 'ms' conversion qualifier to std.duration Add 'ms' conversion qualifier to std.duration, and update documentation and test case. Fixes: #1434 diff --git a/bin/varnishtest/tests/m00005.vtc b/bin/varnishtest/tests/m00005.vtc index aa7143d..53f5ae3 100644 --- a/bin/varnishtest/tests/m00005.vtc +++ b/bin/varnishtest/tests/m00005.vtc @@ -19,6 +19,12 @@ varnish v1 -vcl+backend { } -start client c1 { + txreq -url "/1" -hdr "ttl: 10ms " + rxresp + expect resp.status == 200 + expect resp.http.ttl == 1000001.010 + expect resp.bodylen == 1 + txreq -url "/1" -hdr "ttl: 10s " rxresp expect resp.status == 200 diff --git a/lib/libvmod_std/vmod.vcc b/lib/libvmod_std/vmod.vcc index a55371c..baeb48f 100644 --- a/lib/libvmod_std/vmod.vcc +++ b/lib/libvmod_std/vmod.vcc @@ -112,9 +112,9 @@ $Function DURATION duration(STRING, DURATION) Description Converts the string *s* to seconds. *s* must be quantified - with the usual s (seconds), m (minutes), h (hours), d (days) - and w (weeks) units. If *s* fails to parse, *fallback* will be - returned. + with the usual ms (milliseconds), s (seconds), m (minutes), h + (hours), d (days) and w (weeks) units. If *s* fails to parse, + *fallback* will be returned. Example set beresp.ttl = std.duration("1w", 3600s); diff --git a/lib/libvmod_std/vmod_std_conversions.c b/lib/libvmod_std/vmod_std_conversions.c index f9cba84..b9020d1 100644 --- a/lib/libvmod_std/vmod_std_conversions.c +++ b/lib/libvmod_std/vmod_std_conversions.c @@ -76,7 +76,13 @@ vmod_duration(const struct vrt_ctx *ctx, const char *p, VCL_DURATION d) /* NB: Keep this list synchronized with VCC */ switch (*e++) { case 's': break; - case 'm': r *= 60.; break; + case 'm': + if (*e == 's') { + r *= 1e-3; + e++; + } else + r *= 60.; + break; case 'h': r *= 60.*60.; break; case 'd': r *= 60.*60.*24.; break; case 'w': r *= 60.*60.*24.*7.; break; From lkarsten at varnish-software.com Mon Feb 24 13:17:26 2014 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Mon, 24 Feb 2014 14:17:26 +0100 Subject: [master] 339b68f Rename =build/ to build/ Message-ID: commit 339b68f92bca636bd8cb786fc68cb5ea437202fe Author: Lasse Karstensen Date: Mon Feb 24 14:14:42 2014 +0100 Rename =build/ to build/ That silly equality sign constantly needed to be escaped and is just unecessesary finger gymnastics. Die, please. diff --git a/.gitignore b/.gitignore index a6d7219..3df191e 100644 --- a/.gitignore +++ b/.gitignore @@ -95,7 +95,7 @@ cscope.*out # Doc-stuff generated from xml /doc/*.html -/doc/sphinx/=build/ +/doc/sphinx/build/ /doc/sphinx/conf.py /doc/sphinx/reference/vcl_var.rst diff --git a/doc/sphinx/Makefile.am b/doc/sphinx/Makefile.am index 3abd43f..8e891c8 100644 --- a/doc/sphinx/Makefile.am +++ b/doc/sphinx/Makefile.am @@ -5,7 +5,7 @@ SPHINXOPTS = SPHINXBUILD = sphinx-build PAPER = a4 -BUILDDIR = =build +BUILDDIR = build # Internal variables. PAPEROPT_a4 = -D latex_paper_size=a4 diff --git a/doc/sphinx/conf.py.in b/doc/sphinx/conf.py.in index d5415da..b9fce6a 100644 --- a/doc/sphinx/conf.py.in +++ b/doc/sphinx/conf.py.in @@ -37,8 +37,8 @@ source_suffix = '.rst' master_doc = 'index' # General information about the project. -project = u'Varnish' -copyright = u'2010-2014 (c) Varnish Software AS' +project = u'Varnish Cache' +copyright = u'2010-2014, Varnish Software AS' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the From lkarsten at varnish-software.com Mon Feb 24 13:17:26 2014 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Mon, 24 Feb 2014 14:17:26 +0100 Subject: [master] 714dae2 Make the TOC look sane PDF/latex version Message-ID: commit 714dae2c06bbbfd7ced61ac7c8384e2d18d15a00 Author: Lasse Karstensen Date: Mon Feb 24 14:16:35 2014 +0100 Make the TOC look sane PDF/latex version diff --git a/doc/sphinx/conf.py.in b/doc/sphinx/conf.py.in index b9fce6a..d825d6b 100644 --- a/doc/sphinx/conf.py.in +++ b/doc/sphinx/conf.py.in @@ -199,8 +199,8 @@ htmlhelp_basename = 'Varnishdoc' # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, documentclass [howto/manual]). latex_documents = [ - ('index', 'Varnish.tex', u'Varnish Documentation', - u'Varnish Project', 'manual'), + ('index', 'Varnish.tex', u'Varnish Administrator documentation', + u'Varnish Cache Project', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of diff --git a/doc/sphinx/index.rst b/doc/sphinx/index.rst index 3d1e28f..b29121e 100644 --- a/doc/sphinx/index.rst +++ b/doc/sphinx/index.rst @@ -1,8 +1,4 @@ -.. Varnish documentation master file, created by - sphinx-quickstart on Tue Apr 20 13:02:15 2010. - .. We use the following header indicators - .. For titles: .. H1 diff --git a/doc/sphinx/users-guide/index.rst b/doc/sphinx/users-guide/index.rst index efe6d25..1000a6f 100644 --- a/doc/sphinx/users-guide/index.rst +++ b/doc/sphinx/users-guide/index.rst @@ -32,10 +32,6 @@ from transaction level to aggregate statistics. :ref:`users_trouble` is for locating and fixing trouble with Varnish. - -Detailed Table of Contents: ---------------------------- - .. toctree:: :maxdepth: 2 From lkarsten at varnish-software.com Mon Feb 24 15:14:44 2014 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Mon, 24 Feb 2014 16:14:44 +0100 Subject: [master] 2d1a8c1 Assorted minor documentation fixes Message-ID: commit 2d1a8c11ea88e3fc394ba160183282ddbdcbd672 Author: Lasse Karstensen Date: Mon Feb 24 16:14:38 2014 +0100 Assorted minor documentation fixes diff --git a/doc/sphinx/installation/bugs.rst b/doc/sphinx/installation/bugs.rst index b1cb06a..16f0c51 100644 --- a/doc/sphinx/installation/bugs.rst +++ b/doc/sphinx/installation/bugs.rst @@ -28,7 +28,7 @@ Varnish crashes Plain and simple: **boom** Varnish is split over two processes, the manager and the child. The child -does all the work, and the manager hangs around to resurect it, if it +does all the work, and the manager hangs around to resurect it if it crashes. Therefore, the first thing to do if you see a Varnish crash, is to examine @@ -77,9 +77,10 @@ general forms: (yet) written the padded-box error handling code for. The most likely cause here, is that you need a larger workspace - for HTTP headers and Cookies. (XXX: which params to tweak) + for HTTP headers and Cookies. Please try that before reporting a bug. +.. (TODO: which params to tweak) "Assert error in ..." This is something bad that should never happen, and a bug diff --git a/doc/sphinx/installation/help.rst b/doc/sphinx/installation/help.rst index 5e62e77..4fb8362 100644 --- a/doc/sphinx/installation/help.rst +++ b/doc/sphinx/installation/help.rst @@ -33,23 +33,24 @@ families and jobs to deal with also. You are more than welcome to just hang out, and while we don't mind the occational intrusion of the real world into the flow, keep -it mostly on topic, and dont paste random links unless they are +it mostly on topic, and don't paste random links unless they are *really* spectacular and intelligent. Mailing Lists ============= -Getting on or off our mailinglist happens through MailMan_. +Getting on or off our mailing lists happens through MailMan_. If you are going to use Varnish, subscribing to our ``varnish-announce`` -mailing list is probably a very good idea. The typical pattern is that +mailing list is probably a very good idea. The typical pattern is that people spend some time getting Varnish running, and then more or less -forget about it. Therefore the announce list is a good way to be +forget about it. Therefore the announce list is a good way to be reminded about new releases, bad bugs or security holes. + The ``varnish-misc`` mailing list is for general banter, questions, suggestions, ideas and so on. If you are new to Varnish it may pay -off to subscribe to -misc, simply to have an ear to the telegraph-pole +off to subscribe to it, simply to have an ear to the telegraph-pole and learn some smart tricks. This is a good place to ask for help with more complex issues, that require quoting of files and long explanations. @@ -59,6 +60,7 @@ thread changes, please change the subject to match, some of us deal with hundreds of emails per day, after spam-filters, and we need all the help we can get to pick the interesting ones. + The ``varnish-dev`` mailing list is used by the developers and is usually quite focused on source-code and such. Everybody on the -dev list is also on -misc, so cross-posting only serves to annoy diff --git a/doc/sphinx/installation/index.rst b/doc/sphinx/installation/index.rst index b1e0a23..60d43e0 100644 --- a/doc/sphinx/installation/index.rst +++ b/doc/sphinx/installation/index.rst @@ -5,7 +5,7 @@ Varnish Installation %%%%%%%%%%%%%%%%%%%% This document explains how to get Varnish onto your system, where -to get help, how report bugs etc. In other words, it is a manual +to get help, how report bugs and so on. In other words, it is a manual about pretty much everything else than actually using Varnish to move traffic. diff --git a/doc/sphinx/installation/install.rst b/doc/sphinx/installation/install.rst index ef31f86..45c5e4e 100644 --- a/doc/sphinx/installation/install.rst +++ b/doc/sphinx/installation/install.rst @@ -13,7 +13,7 @@ are most comfortable with. Source or packages? ------------------- -Installing Varnish on most relevant operating systems can usually +Installing Varnish on most relevant operating systems can usually be done with with the systems package manager, typical examples being: @@ -36,8 +36,9 @@ on `repo.varnish-cache.org `_. See the Varnish is included in the `EPEL `_ repository, however due to incompatible syntax changes in newer versions of Varnish, only older -versions are available. We recommend that you install the latest -version from our repository. +versions are available. + +We recommend that you install the latest version from our repository. Debian/Ubuntu ------------- @@ -69,7 +70,7 @@ git repository by doing. Please note that a git checkout will need some more build-dependencies than listed below, in particular the Python Docutils and Sphinx. -Build dependencies on Debian / Ubuntu +Build dependencies on Debian / Ubuntu -------------------------------------- In order to build Varnish from source you need a number of packages @@ -77,7 +78,7 @@ installed. On a Debian or Ubuntu system these are: * autotools-dev * automake1.11 -* libtool +* libtool * autoconf * libncurses-dev * groff-base @@ -89,7 +90,7 @@ installed. On a Debian or Ubuntu system these are: If you're building from git, you also need the following: * python-docutils -* python-sphinx (optional, if you want the HTML docs built) +* python-sphinx (optional, if you want to build the documentation) Build dependencies on Red Hat / CentOS -------------------------------------- @@ -97,8 +98,8 @@ Build dependencies on Red Hat / CentOS To build Varnish on a Red Hat or CentOS system you need the following packages installed: -* automake -* autoconf +* automake +* autoconf * libtool * ncurses-devel * groff @@ -109,10 +110,10 @@ packages installed: If you're building from git, you also need the following: * docutils -* python-sphinx (optional, if you want the HTML docs built) +* python-sphinx (optional, if you want to build the documentation) -Configuring and compiling -------------------------- +Compiling Varnish +----------------- Next, configuration: The configuration will need the dependencies above satisfied. Once that is taken care of:: @@ -133,7 +134,7 @@ tea while it runs, it takes some minutes:: Don't worry if a single or two tests fail, some of the tests are a bit too timing sensitive (Please tell us which so we can fix it) but -if a lot of them fails, and in particular if the ``b00000.vtc`` test +if a lot of them fails, and in particular if the ``b00000.vtc`` test fails, something is horribly wrong, and you will get nowhere without figuring out what. @@ -146,6 +147,6 @@ And finally, the true test of a brave heart:: Varnish will now be installed in /usr/local. The varnishd binary is in /usr/local/sbin/varnishd and its default configuration will be -/usr/local/etc/varnish/default.vcl. +/usr/local/etc/varnish/default.vcl. -You can now proceed to the :ref:`tutorial-index`. +You can now proceed to the :ref:`tutorial-index`. diff --git a/doc/sphinx/installation/prerequisites.rst b/doc/sphinx/installation/prerequisites.rst index ad92ee0..736bcd8 100644 --- a/doc/sphinx/installation/prerequisites.rst +++ b/doc/sphinx/installation/prerequisites.rst @@ -4,6 +4,7 @@ Prerequisites In order for you to install Varnish you must have the following: + * A recent, preferably server grade, computer. * A fairly modern and 64 bit version of either - Linux - FreeBSD diff --git a/doc/sphinx/users-guide/command-line.rst b/doc/sphinx/users-guide/command-line.rst index 65dec6a..dc25087 100644 --- a/doc/sphinx/users-guide/command-line.rst +++ b/doc/sphinx/users-guide/command-line.rst @@ -62,7 +62,7 @@ If you go with -f, you can start with a VCL file containing just:: which is exactly what -b does. -In both cases the default VCL code is appended. +In both cases the built-in VCL code is appended. Other options ^^^^^^^^^^^^^ @@ -74,9 +74,9 @@ By default Varnish will use 100 megabytes of malloc(3) storage for caching objects, if you want to cache more than that, you should look at the '-s' argument. -If you run a really big site, you may want to tune the size of -the tread-pools and other parameters with the '-p' argument, -but we generally advice not to do that, unless you need to. +If you run a really big site, you may want to tune the number of +worker threads and other parameters with the '-p' argument, +but we generally advice not to do that unless you need to. Before you go into production, you may also want to re-visit the chapter diff --git a/doc/sphinx/users-guide/intro.rst b/doc/sphinx/users-guide/intro.rst index 18b4a1d..6a67fc5 100644 --- a/doc/sphinx/users-guide/intro.rst +++ b/doc/sphinx/users-guide/intro.rst @@ -48,10 +48,10 @@ each and every HTTP request which comes in. Because the VCL is compiled to C code, and the C code is compiled to machine instructions, even very complex VCL programs execute in -a a few microseconds, without impacting performance at all. +a few microseconds, without impacting performance at all. And don't fret if you are not really a programmer, VCL is very -simple to do simpel things with:: +simple to do simple things with:: sub vcl_recv { # Remove the cookie header to enable caching @@ -73,7 +73,7 @@ Varnish uses a piece of shared memory to report its activity and status. For each HTTP request, a number of very detailed records will be appended to the log segment in this shared memory. Other processes can subscribe to log-records, filter them, and format them, for -instance as NCSA style log records. +instance as Apache/NCSA style log records. Another segment in shared memory is used for statistics counters, this allows real-time, down to microsecond resolution monitoring diff --git a/doc/sphinx/users-guide/run_cli.rst b/doc/sphinx/users-guide/run_cli.rst index a5e97e1..b534971 100644 --- a/doc/sphinx/users-guide/run_cli.rst +++ b/doc/sphinx/users-guide/run_cli.rst @@ -14,7 +14,7 @@ same machine as varnishd is running:: If you want to run varnishadm from a remote system, you can do it two ways. -You can ssh into the varnishd computer and run varnishadm:: +You can SSH into the varnishd computer and run varnishadm:: ssh $http_front_end varnishadm help @@ -27,7 +27,7 @@ And then on the remote system run varnishadm:: varnishadm -T $http_front_end -S /etc/copy_of_varnish_secret help -but as you can see, ssh is much more convenient. +but as you can see, SSH is much more convenient. If you run varnishadm without arguments, it will read CLI commands from stdin, if you give it arguments, it will treat those as the single @@ -36,7 +36,7 @@ CLI command to execute. The CLI always returns a status code to tell how it went: '200' means OK, anything else means there were some kind of trouble. -Varnishadm will exit with status 1 and print the status code on +varnishadm will exit with status 1 and print the status code on standard error if it is not 200. What can you do with the CLI @@ -86,9 +86,8 @@ to the previous VCL program again:: varnish> vcl.use old_name The switch is instantaneous, all new requests will start using the -VCL you activated right away, but for consistency, the requests -currently being processed, complete using whatever VCL they started -with. +VCL you activated right away. The requests currently being processed complete +using whatever VCL they started with. It is good idea to design an emergency-VCL before you need it, and always have it loaded, so you can switch to it with a single @@ -120,9 +119,10 @@ a HTTP request asks for it. Banning stuff is much cheaper than restarting Varnish to get rid of wronly cached content. -In addition to handling such special occations, banning can be used -in many creative ways to keep the cache up to date, more about -that in: (XXX: xref) +.. In addition to handling such special occations, banning can be used +.. in many creative ways to keep the cache up to date, more about +.. that in: (TODO: xref) + Change parameters ^^^^^^^^^^^^^^^^^ @@ -136,7 +136,7 @@ but they can also be examined and changed on the fly from the CLI:: Default is off Prefer IPv6 address when connecting to backends which have both IPv4 and IPv6 addresses. - + varnish> param.set prefer_ipv6 true 200 diff --git a/doc/sphinx/users-guide/storage-backends.rst b/doc/sphinx/users-guide/storage-backends.rst index 6f0fe9b..b12dba0 100644 --- a/doc/sphinx/users-guide/storage-backends.rst +++ b/doc/sphinx/users-guide/storage-backends.rst @@ -19,10 +19,11 @@ malloc syntax: malloc[,size] Malloc is a memory based backend. Each object will be allocated from -memory. If your system runs low on memory swap will be used. Be aware -that the size limitation only limits the actual storage and that -approximately 1k of memory per object will be used for various -internal structures. +memory. If your system runs low on memory swap will be used. + +Be aware that the size limitation only limits the actual storage and that +approximately 1k of memory per object will be used for various internal +structures. The size parameter specifies the maximum amount of memory varnishd will allocate. The size is assumed to be in bytes, unless followed by @@ -36,19 +37,19 @@ one of the following suffixes: T, t The size is expressed in tebibytes. -The default size is unlimited. +The default size is unlimited. -Mallocs performance is bound by memory speed so it is very fast. If +malloc's performance is bound by memory speed so it is very fast. If the dataset is bigger than what can fit in memory performance will -depend on the operating system and how well it doesn paging. +depend on the operating system and how well it does paging. file ~~~~ syntax: file[,path[,size[,granularity]]] -The file backend stores objects in memory backed by a file on disk -with mmap. +The file backend stores objects in memory backed by an unlinked file on disk +with mmap. The path parameter specifies either the path to the backing file or the path to a directory in which varnishd will create the backing @@ -84,8 +85,8 @@ allocation. All allocations are rounded up to this size. The is assumed to be in bytes, unless followed by one of the suffixes described for size except for %. -The default size is the VM page size. The size should be reduced if -you have many small objects. +The default granularity is the VM page size. The size should be reduced if you +have many small objects. File performance is typically limited by the write speed of the device, and depending on use, the seek time. @@ -127,10 +128,11 @@ and can make previously banned objects reappear. Transient Storage ----------------- - + If you name any of your storage backend "Transient" it will be used for transient (short lived) objects. By default Varnish would use an unlimited malloc backend for this. Varnish will consider an object short lived if the TTL is below the parameter "shortlived". + diff --git a/doc/sphinx/users-guide/vcl-intro.rst b/doc/sphinx/users-guide/vcl-intro.rst index bc90411..095896c 100644 --- a/doc/sphinx/users-guide/vcl-intro.rst +++ b/doc/sphinx/users-guide/vcl-intro.rst @@ -21,7 +21,7 @@ Varnish will execute the built in VCL code. You will see this VCL code commented out in default.vcl. 99% of all the changes you'll need to do will be done in two of these -subroutines. *vcl_recv* and *vcl_fetch*. +subroutines. *vcl_recv* and *vcl_backend_response*. .. _users-guide-vcl_fetch_actions: diff --git a/doc/sphinx/users-guide/vcl.rst b/doc/sphinx/users-guide/vcl.rst index 0e56c3a..defe566 100644 --- a/doc/sphinx/users-guide/vcl.rst +++ b/doc/sphinx/users-guide/vcl.rst @@ -4,12 +4,11 @@ VCL - Varnish Configuration Language ------------------------------------ This section is about getting Varnish to do what you want to -your HTTP traffic, using the Varnish Configuration Language. +your HTTP traffic, using the Varnish Configuration Language (VCL). Varnish has a great configuration system. Most other systems use configuration directives, where you basically turn on and off lots of -switches. Varnish uses a domain specific language called Varnish -Configuration Language, or VCL for short. +switches. Varnish uses a domain specific language called VCL for this. Every inbound request flows through Varnish and you can influence how the request is being handled by altering the VCL code. You can direct @@ -26,8 +25,8 @@ are executed at different times. One is executed when we get the request, another when files are fetched from the backend server. If you don't call an action in your subroutine and it reaches the end -Varnish will execute some built in VCL code. You will see this VCL -code commented out in default.vcl that ships with Varnish Cache. +Varnish will execute some built-in VCL code. You will see this VCL +code commented out in builtin.vcl that ships with Varnish Cache. .. _users-guide-vcl_fetch_actions: @@ -45,4 +44,4 @@ code commented out in default.vcl that ships with Varnish Cache. vcl-examples websockets devicedetection - + From fgsch at lodoss.net Mon Feb 24 16:09:06 2014 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Mon, 24 Feb 2014 17:09:06 +0100 Subject: [master] 349256d Sync with vmod.vcc Message-ID: commit 349256d65a7b908cdf986bfc53b7acd4ab1b3918 Author: Federico G. Schwindt Date: Mon Feb 24 16:08:29 2014 +0000 Sync with vmod.vcc diff --git a/doc/sphinx/reference/vmod_std.rst b/doc/sphinx/reference/vmod_std.rst index 36a2678..41c38e6 100644 --- a/doc/sphinx/reference/vmod_std.rst +++ b/doc/sphinx/reference/vmod_std.rst @@ -23,7 +23,7 @@ DESCRIPTION Vmod_std contains basic functions which are part and parcel of Varnish, but which for reasons of architecture fit better in a VMOD. -One specific class of functions in vmod_std is the conversions functions +One particular class of functions in vmod_std is the conversions functions which all have the form:: TYPE type(STRING, TYPE) @@ -127,9 +127,10 @@ duration Prototype DURATION duration(STRING s, DURATION fallback) Description - Converts the string *s* to seconds. *s* can be quantified with - the usual s (seconds), m (minutes), h (hours), d (days) and w - (weeks) units. If *s* fails to parse, *fallback* will be returned. + Converts the string *s* to seconds. *s* must be quantified + with ms (milliseconds), s (seconds), m (minutes), h (hours), + d (days) or w (weeks) units. If *s* fails to parse, + *fallback* will be returned. Example set beresp.ttl = std.duration("1w", 3600s); @@ -154,6 +155,22 @@ Description Example if (std.ip(req.http.X-forwarded-for, "0.0.0.0") ~ my_acl) { ... } +healthy +------- +Prototype + BOOL healthy(BACKEND backend) + +Description + Returns true if the backend is healthy. + +port +---- +Prototype + INT port(IP ip) + +Description + Returns the port number of an IP address. + SEE ALSO ======== From fgsch at lodoss.net Mon Feb 24 16:21:15 2014 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Mon, 24 Feb 2014 17:21:15 +0100 Subject: [master] da2566c Minor cosmetic changes Message-ID: commit da2566c2ae9297cf5f0fd28be1098fce2000b7d8 Author: Federico G. Schwindt Date: Mon Feb 24 16:20:58 2014 +0000 Minor cosmetic changes diff --git a/lib/libvmod_std/vmod.vcc b/lib/libvmod_std/vmod.vcc index baeb48f..dcb12ec 100644 --- a/lib/libvmod_std/vmod.vcc +++ b/lib/libvmod_std/vmod.vcc @@ -112,8 +112,8 @@ $Function DURATION duration(STRING, DURATION) Description Converts the string *s* to seconds. *s* must be quantified - with the usual ms (milliseconds), s (seconds), m (minutes), h - (hours), d (days) and w (weeks) units. If *s* fails to parse, + with ms (milliseconds), s (seconds), m (minutes), h (hours), + d (days) or w (weeks) units. If *s* fails to parse, *fallback* will be returned. Example set beresp.ttl = std.duration("1w", 3600s); @@ -138,12 +138,12 @@ Example $Function BOOL healthy(BACKEND) Description - Returns true if the backend is healthy + Returns true if the backend is healthy. $Function INT port(IP) Description - Returns the port number of an IP address + Returns the port number of an IP address. SEE ALSO From lkarsten at varnish-software.com Tue Feb 25 11:10:50 2014 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Tue, 25 Feb 2014 12:10:50 +0100 Subject: [master] 543302c Wording, less genitive in the heading Message-ID: commit 543302c4d3c74389ce78b81ff2e423dbacf00f0d Author: Lasse Karstensen Date: Tue Feb 25 12:10:20 2014 +0100 Wording, less genitive in the heading diff --git a/doc/sphinx/index.rst b/doc/sphinx/index.rst index b29121e..e83d1dc 100644 --- a/doc/sphinx/index.rst +++ b/doc/sphinx/index.rst @@ -12,20 +12,16 @@ .. ~~~~~~~~~~~~~~~~~~~~~~ .. ...................... -Welcome to Varnish's documentation! -=================================== +Welcome to the Varnish documentation! +===================================== -Varnish is a state of the art web accelerator. Its mission is to sit -in front of a web server and cache content. It makes your web site -go faster. +Varnish is a state of the art web accelerator. It has its mission in front of a +web server and cache content. It makes your web site go faster. We suggest you start by reading the installation guide :ref:`install-index`. Once you have Varnish up and running go through our tutorial - :ref:`tutorial-index`. - -Contents: - .. toctree:: :maxdepth: 1 From phk at FreeBSD.org Tue Feb 25 11:33:25 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 25 Feb 2014 12:33:25 +0100 Subject: [master] c2ebc12 Introduce two new states in backend-fetch state machine: retry and error Message-ID: commit c2ebc12633e6cc577e5ffa6b2cf23eb4e1af9ba4 Author: Poul-Henning Kamp Date: Tue Feb 18 12:19:23 2014 +0000 Introduce two new states in backend-fetch state machine: retry and error diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 819c39f..31379cf 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -45,6 +45,22 @@ */ static void +make_it_503(struct busyobj *bo) +{ + + HTTP_Setup(bo->beresp, bo->ws, bo->vsl, SLT_BerespMethod); + http_SetResp(bo->beresp, "HTTP/1.1", 503, "Backend fetch failed"); + http_SetHeader(bo->beresp, "Content-Length: 0"); + http_SetHeader(bo->beresp, "Connection: close"); + bo->exp.ttl = 0; + bo->exp.grace = 0; + bo->exp.keep = 0; +} + +/*-------------------------------------------------------------------- + */ + +static void vbf_release_req(struct busyobj *bo) { assert(bo->state == BOS_INVALID); @@ -103,7 +119,31 @@ vbf_stp_mkbereq(const struct worker *wrk, struct busyobj *bo) } /*-------------------------------------------------------------------- - * Copy run bereq by VCL::vcl_backend_fetch{} + * Start a new VSL transaction and try again + */ + +static enum fetch_step +vbf_stp_retry(struct worker *wrk, struct busyobj *bo) +{ + unsigned owid, wid; + + CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + + // XXX: BereqEnd + BereqAcct ? + wid = VXID_Get(&wrk->vxid_pool); + VSLb(bo->vsl, SLT_Link, "bereq %u retry", wid); + VSLb(bo->vsl, SLT_End, "%s", ""); + VSL_Flush(bo->vsl, 0); + owid = bo->vsl->wid & VSL_IDENTMASK; + bo->vsl->wid = wid | VSL_BACKENDMARKER; + VSLb(bo->vsl, SLT_Begin, "bereq %u retry", owid); + + return (F_STP_STARTFETCH); +} + +/*-------------------------------------------------------------------- + * Setup bereq from bereq0, run vcl_backend_fetch */ static enum fetch_step @@ -138,21 +178,6 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo) return (F_STP_FETCHHDR); } -/*-------------------------------------------------------------------- - */ - -static void -make_it_503(struct busyobj *bo) -{ - - HTTP_Setup(bo->beresp, bo->ws, bo->vsl, SLT_BerespMethod); - http_SetResp(bo->beresp, "HTTP/1.1", 503, "Backend fetch failed"); - http_SetHeader(bo->beresp, "Content-Length: 0"); - http_SetHeader(bo->beresp, "Connection: close"); - bo->exp.ttl = 0; - bo->exp.grace = 0; - bo->exp.keep = 0; -} /*-------------------------------------------------------------------- */ @@ -161,7 +186,6 @@ static enum fetch_step vbf_stp_fetchhdr(struct worker *wrk, struct busyobj *bo) { int i, do_ims, fail; - unsigned owid, wid; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); @@ -247,17 +271,9 @@ vbf_stp_fetchhdr(struct worker *wrk, struct busyobj *bo) if (bo->vbc) VDI_CloseFd(&bo->vbc); bo->retries++; - if (bo->retries <= cache_param->max_retries) { - // XXX: BereqEnd + BereqAcct ? - wid = VXID_Get(&wrk->vxid_pool); - VSLb(bo->vsl, SLT_Link, "bereq %u retry", wid); - VSLb(bo->vsl, SLT_End, "%s", ""); - VSL_Flush(bo->vsl, 0); - owid = bo->vsl->wid & VSL_IDENTMASK; - bo->vsl->wid = wid | VSL_BACKENDMARKER; - VSLb(bo->vsl, SLT_Begin, "bereq %u retry", owid); - return (F_STP_STARTFETCH); - } + if (bo->retries <= cache_param->max_retries) + return (F_STP_RETRY); + VSLb(bo->vsl, SLT_VCL_Error, "Too many retries, delivering 503"); make_it_503(bo); @@ -548,13 +564,6 @@ VSLb(bo->vsl, SLT_Debug, "YYY REF %d %d", return (F_STP_DONE); } -static enum fetch_step -vbf_stp_done(void) -{ - WRONG("Just plain wrong"); - return (F_STP_DONE); -} - /*-------------------------------------------------------------------- */ @@ -659,8 +668,28 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo) } /*-------------------------------------------------------------------- + * Create synth object */ +static enum fetch_step +vbf_stp_error(struct worker *wrk, struct busyobj *bo) +{ + CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + WRONG(""); + return (F_STP_DONE); +} + +/*-------------------------------------------------------------------- + */ + +static enum fetch_step +vbf_stp_done(void) +{ + WRONG("Just plain wrong"); + return (F_STP_DONE); +} + static const char * vbf_step_name(enum fetch_step stp) { @@ -675,7 +704,6 @@ vbf_step_name(enum fetch_step stp) } } - static void vbf_fetch_thread(struct worker *wrk, void *priv) { diff --git a/include/tbl/steps.h b/include/tbl/steps.h index d99738c..9ef7f6c 100644 --- a/include/tbl/steps.h +++ b/include/tbl/steps.h @@ -50,10 +50,12 @@ REQ_STEP(error, ERROR, (wrk, req)) #ifdef FETCH_STEP FETCH_STEP(mkbereq, MKBEREQ, (wrk, bo)) +FETCH_STEP(retry, RETRY, (wrk, bo)) FETCH_STEP(startfetch, STARTFETCH, (wrk, bo)) FETCH_STEP(fetchhdr, FETCHHDR, (wrk, bo)) FETCH_STEP(condfetch, CONDFETCH, (wrk, bo)) FETCH_STEP(fetch, FETCH, (wrk, bo)) +FETCH_STEP(error, ERROR, (wrk, bo)) FETCH_STEP(done, DONE, ()) #endif diff --git a/lib/libvcc/generate.py b/lib/libvcc/generate.py index 0702465..29dcb9e 100755 --- a/lib/libvcc/generate.py +++ b/lib/libvcc/generate.py @@ -120,7 +120,7 @@ returns =( ), ############################################################### - # Backend-fetch + # Backend-fetch ('backend_fetch', "B", From phk at FreeBSD.org Tue Feb 25 11:33:25 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 25 Feb 2014 12:33:25 +0100 Subject: [master] fb97c67 Extract the bereq->obj creation code to a separate function Message-ID: commit fb97c67b70fa87dcc2091c05c104bb1e68cff37a Author: Poul-Henning Kamp Date: Tue Feb 18 13:17:18 2014 +0000 Extract the bereq->obj creation code to a separate function diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 31379cf..f044347 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -71,6 +71,119 @@ vbf_release_req(struct busyobj *bo) } /*-------------------------------------------------------------------- + */ + +static int +vbf_bereq2obj(struct worker *wrk, struct busyobj *bo) +{ + unsigned l; + char *b; + struct vsb *vary = NULL; + int varyl = 0; + uint16_t nhttp; + struct object *obj; + struct http *hp, *hp2; + + l = 0; + + /* Create Vary instructions */ + if (!(bo->fetch_objcore->flags & OC_F_PRIVATE)) { + varyl = VRY_Create(bo, &vary); + if (varyl > 0) { + AN(vary); + assert(varyl == VSB_len(vary)); + l += varyl; + } else if (varyl < 0) { + /* + * Vary parse error + * Complain about it, and make this a pass. + */ + VSLb(bo->vsl, SLT_Error, + "Illegal 'Vary' header from backend, " + "making this a pass."); + bo->uncacheable = 1; + AZ(vary); + } else + /* No vary */ + AZ(vary); + } + + l += http_EstimateWS(bo->beresp, + bo->uncacheable ? HTTPH_R_PASS : HTTPH_A_INS, &nhttp); + + if (bo->uncacheable) + bo->fetch_objcore->flags |= OC_F_PASS; + + if (bo->uncacheable || + bo->exp.ttl+bo->exp.grace+bo->exp.keep < cache_param->shortlived) + bo->storage_hint = TRANSIENT_STORAGE; + + AZ(bo->stats); + bo->stats = &wrk->stats; + AN(bo->fetch_objcore); + obj = STV_NewObject(bo, bo->storage_hint, l, nhttp); +#if 0 + // XXX: we shouldn't retry if we're already on Transient + if (obj == NULL && + (bo->storage_hint == NULL || + strcmp(bo->storage_hint, TRANSIENT_STORAGE))) { +#else + if (obj == NULL) { +#endif + /* + * Try to salvage the transaction by allocating a + * shortlived object on Transient storage. + */ + if (bo->exp.ttl > cache_param->shortlived) + bo->exp.ttl = cache_param->shortlived; + bo->exp.grace = 0.0; + bo->exp.keep = 0.0; + obj = STV_NewObject(bo, TRANSIENT_STORAGE, l, nhttp); + } + if (obj == NULL) + return (-1); + + CHECK_OBJ_NOTNULL(obj, OBJECT_MAGIC); + + bo->storage_hint = NULL; + + AZ(bo->fetch_obj); + bo->fetch_obj = obj; + + if (bo->do_gzip || (bo->is_gzip && !bo->do_gunzip)) + obj->gziped = 1; + + if (vary != NULL) { + obj->vary = (void *)WS_Copy(obj->http->ws, + VSB_data(vary), varyl); + AN(obj->vary); + (void)VRY_Validate(obj->vary); + VSB_delete(vary); + } + + obj->vxid = bo->vsl->wid; + obj->response = bo->err_code; + WS_Assert(bo->ws_o); + + /* Filter into object */ + hp = bo->beresp; + hp2 = obj->http; + + hp2->logtag = SLT_ObjMethod; + http_FilterResp(hp, hp2, bo->uncacheable ? HTTPH_R_PASS : HTTPH_A_INS); + http_CopyHome(hp2); + + if (http_GetHdr(hp, H_Last_Modified, &b)) + obj->last_modified = VTIM_parse(b); + else + obj->last_modified = floor(bo->exp.t_origin); + + assert(WRW_IsReleased(wrk)); + + return (0); +} + +/*-------------------------------------------------------------------- * Copy req->bereq */ @@ -300,12 +413,6 @@ vbf_stp_fetchhdr(struct worker *wrk, struct busyobj *bo) static enum fetch_step vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) { - struct http *hp, *hp2; - char *b; - uint16_t nhttp; - unsigned l; - struct vsb *vary = NULL; - int varyl = 0; struct object *obj; ssize_t est = -1; @@ -388,97 +495,14 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) if (bo->htc.body_status == BS_NONE) bo->do_stream = 0; - l = 0; - - /* Create Vary instructions */ - if (!(bo->fetch_objcore->flags & OC_F_PRIVATE)) { - varyl = VRY_Create(bo, &vary); - if (varyl > 0) { - AN(vary); - assert(varyl == VSB_len(vary)); - l += varyl; - } else if (varyl < 0) { - /* - * Vary parse error - * Complain about it, and make this a pass. - */ - VSLb(bo->vsl, SLT_Error, - "Illegal 'Vary' header from backend, " - "making this a pass."); - bo->uncacheable = 1; - AZ(vary); - } else - /* No vary */ - AZ(vary); - } - - l += http_EstimateWS(bo->beresp, - bo->uncacheable ? HTTPH_R_PASS : HTTPH_A_INS, &nhttp); - - if (bo->uncacheable) - bo->fetch_objcore->flags |= OC_F_PASS; - - if (bo->uncacheable || - bo->exp.ttl+bo->exp.grace+bo->exp.keep < cache_param->shortlived) - bo->storage_hint = TRANSIENT_STORAGE; - - AZ(bo->stats); - bo->stats = &wrk->stats; - AN(bo->fetch_objcore); - obj = STV_NewObject(bo, bo->storage_hint, l, nhttp); - if (obj == NULL) { - /* - * Try to salvage the transaction by allocating a - * shortlived object on Transient storage. - */ - if (bo->exp.ttl > cache_param->shortlived) - bo->exp.ttl = cache_param->shortlived; - bo->exp.grace = 0.0; - bo->exp.keep = 0.0; - obj = STV_NewObject(bo, TRANSIENT_STORAGE, l, nhttp); - } - if (obj == NULL) { + if (vbf_bereq2obj(wrk, bo)) { bo->stats = NULL; (void)VFP_Error(bo, "Could not get storage"); VDI_CloseFd(&bo->vbc); return (F_STP_DONE); } - CHECK_OBJ_NOTNULL(obj, OBJECT_MAGIC); - - bo->storage_hint = NULL; - - AZ(bo->fetch_obj); - bo->fetch_obj = obj; - - if (bo->do_gzip || (bo->is_gzip && !bo->do_gunzip)) - obj->gziped = 1; - - if (vary != NULL) { - obj->vary = (void *)WS_Copy(obj->http->ws, - VSB_data(vary), varyl); - AN(obj->vary); - (void)VRY_Validate(obj->vary); - VSB_delete(vary); - } - obj->vxid = bo->vsl->wid; - obj->response = bo->err_code; - WS_Assert(bo->ws_o); - - /* Filter into object */ - hp = bo->beresp; - hp2 = obj->http; - - hp2->logtag = SLT_ObjMethod; - http_FilterResp(hp, hp2, bo->uncacheable ? HTTPH_R_PASS : HTTPH_A_INS); - http_CopyHome(hp2); - - if (http_GetHdr(hp, H_Last_Modified, &b)) - obj->last_modified = VTIM_parse(b); - else - obj->last_modified = floor(bo->exp.t_origin); - - assert(WRW_IsReleased(wrk)); + obj = bo->fetch_obj; /* * Ready to fetch the body @@ -514,9 +538,6 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) bo->t_body = VTIM_mono(); - http_Teardown(bo->bereq); - http_Teardown(bo->beresp); - VSLb(bo->vsl, SLT_Fetch_Body, "%u(%s)", bo->htc.body_status, body_status_2str(bo->htc.body_status)); @@ -606,7 +627,7 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo) obj->gzip_last = bo->ims_obj->gzip_last; obj->gzip_stop = bo->ims_obj->gzip_stop; - /* XXX: ESI */ + XXXAZ(bo->ims_obj->esidata); if (bo->ims_obj->vary != NULL) { obj->vary = (void *)WS_Copy(obj->http->ws, @@ -676,6 +697,24 @@ vbf_stp_error(struct worker *wrk, struct busyobj *bo) { CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + + AN(bo->fetch_objcore->flags &= OC_F_BUSY); + + // XXX: reset all beresp flags ? + + HTTP_Setup(bo->beresp, bo->ws, bo->vsl, SLT_BerespMethod); + http_SetResp(bo->beresp, "HTTP/1.1", 503, "Backend fetch failed"); + http_SetHeader(bo->beresp, "Content-Length: 0"); + http_SetHeader(bo->beresp, "Connection: close"); + + bo->exp.ttl = 0; + bo->exp.grace = 0; + bo->exp.keep = 0; + + VCL_backend_error_method(bo->vcl, wrk, NULL, bo, bo->bereq->ws); + + xxxassert(wrk->handling == VCL_RET_DELIVER); + WRONG(""); return (F_STP_DONE); } @@ -749,6 +788,9 @@ vbf_fetch_thread(struct worker *wrk, void *priv) AZ(bo->vbc); } + http_Teardown(bo->bereq); + http_Teardown(bo->beresp); + if (bo->state == BOS_FAILED) assert(bo->fetch_objcore->flags & OC_F_FAILED); From phk at FreeBSD.org Tue Feb 25 11:33:25 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 25 Feb 2014 12:33:25 +0100 Subject: [master] 2ddc91f Make bereq.* vars available in vcl_backend_error{} Message-ID: commit 2ddc91fa4c49a219cc9890eed3803d46371e1861 Author: Poul-Henning Kamp Date: Tue Feb 18 13:49:20 2014 +0000 Make bereq.* vars available in vcl_backend_error{} diff --git a/lib/libvcc/generate.py b/lib/libvcc/generate.py index 29dcb9e..f313bd5 100755 --- a/lib/libvcc/generate.py +++ b/lib/libvcc/generate.py @@ -367,36 +367,36 @@ The client's IP address. ), ('beresp.proto', 'STRING', - ( 'backend_response',), - ( 'backend_response',), """ + ( 'backend_response', 'backend_error'), + ( 'backend_response', 'backend_error'), """ The HTTP protocol version used the backend replied with. """ ), ('beresp.status', 'INT', - ( 'backend_response',), - ( 'backend_response',), """ + ( 'backend_response', 'backend_error'), + ( 'backend_response', 'backend_error'), """ The HTTP status code returned by the server. """ ), ('beresp.reason', 'STRING', - ( 'backend_response',), - ( 'backend_response',), """ + ( 'backend_response', 'backend_error'), + ( 'backend_response', 'backend_error'), """ The HTTP status message returned by the server. """ ), ('beresp.http.', 'HEADER', - ( 'backend_response',), - ( 'backend_response',), """ + ( 'backend_response', 'backend_error'), + ( 'backend_response', 'backend_error'), """ The corresponding HTTP header. """ ), ('beresp.do_esi', 'BOOL', - ( 'backend_response',), - ( 'backend_response',), """ + ( 'backend_response', 'backend_error'), + ( 'backend_response', 'backend_error'), """ Boolean. ESI-process the object after fetching it. Defaults to false. Set it to true to parse the object for ESI directives. Will only be honored if @@ -405,8 +405,8 @@ The client's IP address. ), ('beresp.do_stream', 'BOOL', - ( 'backend_response',), - ( 'backend_response',), """ + ( 'backend_response', 'backend_error'), + ( 'backend_response', 'backend_error'), """ Deliver the object to the client directly without fetching the whole object into varnish. If this request is pass'ed it will not be stored in memory. @@ -416,8 +416,8 @@ The client's IP address. ), ('beresp.do_gzip', 'BOOL', - ( 'backend_response',), - ( 'backend_response',), """ + ( 'backend_response', 'backend_error'), + ( 'backend_response', 'backend_error'), """ Boolean. Gzip the object before storing it. Defaults to false. When http_gzip_support is on Varnish will request already compressed content from the backend @@ -426,57 +426,57 @@ The client's IP address. ), ('beresp.do_gunzip', 'BOOL', - ( 'backend_response',), - ( 'backend_response',), """ + ( 'backend_response', 'backend_error'), + ( 'backend_response', 'backend_error'), """ Boolean. Unzip the object before storing it in the cache. Defaults to false. """ ), ('beresp.uncacheable', 'BOOL', - ( 'backend_response',), - ( 'backend_response',), """ + ( 'backend_response', 'backend_error'), + ( 'backend_response', 'backend_error'), """ """ ), ('beresp.ttl', 'DURATION', - ( 'backend_response',), - ( 'backend_response',), """ + ( 'backend_response', 'backend_error'), + ( 'backend_response', 'backend_error'), """ The object's remaining time to live, in seconds. beresp.ttl is writable. """ ), ('beresp.grace', 'DURATION', - ( 'backend_response',), - ( 'backend_response',), """ + ( 'backend_response', 'backend_error'), + ( 'backend_response', 'backend_error'), """ Set to a period to enable grace. """ ), ('beresp.keep', 'DURATION', - ( 'backend_response',), - ( 'backend_response',), """ + ( 'backend_response', 'backend_error'), + ( 'backend_response', 'backend_error'), """ """ ), ('beresp.backend.name', 'STRING', - ( 'backend_response',), + ( 'backend_response', 'backend_error'), ( ), """ Name of the backend this response was fetched from. """ ), ('beresp.backend.ip', 'IP', - ( 'backend_response',), + ( 'backend_response', 'backend_error'), ( ), """ IP of the backend this response was fetched from. """ ), ('beresp.storage_hint', 'STRING', - ( 'backend_response',), - ( 'backend_response',), """ + ( 'backend_response', 'backend_error'), + ( 'backend_response', 'backend_error'), """ Hint to Varnish that you want to save this object to a particular storage backend. """ From phk at FreeBSD.org Tue Feb 25 11:33:25 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 25 Feb 2014 12:33:25 +0100 Subject: [master] a6277de Shift the 503 creation into the error step. Message-ID: commit a6277de361e1d17b5aabb0fd36baf705b2e418f4 Author: Poul-Henning Kamp Date: Tue Feb 18 14:13:27 2014 +0000 Shift the 503 creation into the error step. diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index f044347..51cb160 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -41,21 +41,6 @@ #include "vcl.h" #include "vtim.h" -/*-------------------------------------------------------------------- - */ - -static void -make_it_503(struct busyobj *bo) -{ - - HTTP_Setup(bo->beresp, bo->ws, bo->vsl, SLT_BerespMethod); - http_SetResp(bo->beresp, "HTTP/1.1", 503, "Backend fetch failed"); - http_SetHeader(bo->beresp, "Content-Length: 0"); - http_SetHeader(bo->beresp, "Connection: close"); - bo->exp.ttl = 0; - bo->exp.grace = 0; - bo->exp.keep = 0; -} /*-------------------------------------------------------------------- */ @@ -298,7 +283,7 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo) static enum fetch_step vbf_stp_fetchhdr(struct worker *wrk, struct busyobj *bo) { - int i, do_ims, fail; + int i, do_ims; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); @@ -330,14 +315,11 @@ vbf_stp_fetchhdr(struct worker *wrk, struct busyobj *bo) if (i) { AZ(bo->vbc); - make_it_503(bo); - fail = 1; - } else { - AN(bo->vbc); - http_VSL_log(bo->beresp); - fail = 0; - } + return (F_STP_ERROR); + } + AN(bo->vbc); + http_VSL_log(bo->beresp); /* * These two headers can be spread over multiple actual headers @@ -353,8 +335,6 @@ vbf_stp_fetchhdr(struct worker *wrk, struct busyobj *bo) * NB: Also sets other wrk variables */ bo->htc.body_status = RFC2616_Body(bo, &wrk->stats); - if (i && bo->htc.body_status == BS_LENGTH) - bo->htc.body_status = BS_NONE; bo->err_code = http_GetStatus(bo->beresp); @@ -381,22 +361,18 @@ vbf_stp_fetchhdr(struct worker *wrk, struct busyobj *bo) VCL_backend_response_method(bo->vcl, wrk, NULL, bo, bo->beresp->ws); if (wrk->handling == VCL_RET_RETRY) { - if (bo->vbc) - VDI_CloseFd(&bo->vbc); + AN (bo->vbc); + VDI_CloseFd(&bo->vbc); bo->retries++; if (bo->retries <= cache_param->max_retries) return (F_STP_RETRY); - VSLb(bo->vsl, SLT_VCL_Error, "Too many retries, delivering 503"); - make_it_503(bo); - wrk->handling = VCL_RET_DELIVER; + return (F_STP_ERROR); } assert(bo->state == BOS_REQ_DONE); VBO_setstate(bo, BOS_COMMITTED); - if (fail) - (void)VFP_Error(bo, "Fetch failed"); if (bo->do_esi) bo->do_stream = 0; @@ -414,7 +390,7 @@ static enum fetch_step vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) { struct object *obj; - ssize_t est = -1; + ssize_t est; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); @@ -465,8 +441,8 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) /* But we can't do both at the same time */ assert(bo->do_gzip == 0 || bo->do_gunzip == 0); - if (bo->vbc != NULL) - est = V1F_Setup_Fetch(bo); + AN(bo->vbc); + est = V1F_Setup_Fetch(bo); if (bo->do_gunzip || (bo->is_gzip && bo->do_esi)) { RFC2616_Weaken_Etag(bo->beresp); @@ -715,7 +691,21 @@ vbf_stp_error(struct worker *wrk, struct busyobj *bo) xxxassert(wrk->handling == VCL_RET_DELIVER); - WRONG(""); + http_PrintfHeader(bo->beresp, "Content-Length: %jd", (intmax_t)0); + http_PrintfHeader(bo->beresp, "X-XXXPHK: yes"); + + if (vbf_bereq2obj(wrk, bo)) { + INCOMPL(); + } + + HSH_Unbusy(&wrk->stats, bo->fetch_obj->objcore); + + if (!(bo->fetch_obj->objcore->flags & OC_F_PRIVATE)) { + EXP_Insert(bo->fetch_obj->objcore); + AN(bo->fetch_obj->objcore->ban); + } + VBO_setstate(bo, BOS_FINISHED); + HSH_Complete(bo->fetch_obj->objcore); return (F_STP_DONE); } diff --git a/bin/varnishtest/tests/b00015.vtc b/bin/varnishtest/tests/b00015.vtc index 9905e96..029f782 100644 --- a/bin/varnishtest/tests/b00015.vtc +++ b/bin/varnishtest/tests/b00015.vtc @@ -21,7 +21,7 @@ client c1 { txreq -url "/" rxresp expect resp.status == 503 - expect resp.http.X-varnish == "1005" + expect resp.http.X-varnish == "1004" } -run delay .1 @@ -46,7 +46,7 @@ client c1 { txreq -url "/" rxresp expect resp.status == 302 - expect resp.http.X-varnish == "1009" + expect resp.http.X-varnish == "1007" } -run delay .1 @@ -55,7 +55,7 @@ client c1 { txreq -url "/" rxresp expect resp.status == 302 - expect resp.http.X-varnish == "1012 1010" + expect resp.http.X-varnish == "1010 1008" } -run delay .1 @@ -79,7 +79,7 @@ client c1 { txreq -url "/2" rxresp expect resp.status == 502 - expect resp.http.X-varnish == "1014" + expect resp.http.X-varnish == "1012" } -run delay .1 @@ -88,7 +88,7 @@ client c1 { txreq -url "/2" rxresp expect resp.status == 502 - expect resp.http.X-varnish == "1017 1015" + expect resp.http.X-varnish == "1015 1013" } -run delay .1 diff --git a/bin/varnishtest/tests/r01395.vtc b/bin/varnishtest/tests/r01395.vtc index c3243f6..acad0fe 100644 --- a/bin/varnishtest/tests/r01395.vtc +++ b/bin/varnishtest/tests/r01395.vtc @@ -5,8 +5,8 @@ varnish v1 -vcl { .host = "${bad_ip}"; .port = "9090"; } - sub vcl_error { - set obj.status = 299; + sub vcl_backend_error { + set beresp.status = 299; } } -start From phk at FreeBSD.org Tue Feb 25 11:33:25 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 25 Feb 2014 12:33:25 +0100 Subject: [master] ed7b310 Only attempt to salvage an object into Transient if it wasn't already destined for Transient in the first place. Message-ID: commit ed7b3105e82ff289d0ee8132fcacac0dd7cfe645 Author: Poul-Henning Kamp Date: Wed Feb 19 08:05:59 2014 +0000 Only attempt to salvage an object into Transient if it wasn't already destined for Transient in the first place. diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 51cb160..661d802 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -107,14 +107,9 @@ vbf_bereq2obj(struct worker *wrk, struct busyobj *bo) bo->stats = &wrk->stats; AN(bo->fetch_objcore); obj = STV_NewObject(bo, bo->storage_hint, l, nhttp); -#if 0 - // XXX: we shouldn't retry if we're already on Transient if (obj == NULL && (bo->storage_hint == NULL || strcmp(bo->storage_hint, TRANSIENT_STORAGE))) { -#else - if (obj == NULL) { -#endif /* * Try to salvage the transaction by allocating a * shortlived object on Transient storage. @@ -316,7 +311,7 @@ vbf_stp_fetchhdr(struct worker *wrk, struct busyobj *bo) if (i) { AZ(bo->vbc); return (F_STP_ERROR); - } + } AN(bo->vbc); http_VSL_log(bo->beresp); diff --git a/bin/varnishtest/tests/r01284.vtc b/bin/varnishtest/tests/r01284.vtc index 697f104..6299926 100644 --- a/bin/varnishtest/tests/r01284.vtc +++ b/bin/varnishtest/tests/r01284.vtc @@ -36,8 +36,8 @@ client c1 { delay 1 } -run -# Two failures, one for obj2 and two for the attempts at sending error -varnish v1 -expect SMA.Transient.c_fail == 3 +# Two failures, one for obj2 and one for the attempts at sending error +varnish v1 -expect SMA.Transient.c_fail == 2 client c1 { # Check that Varnish is still alive From phk at FreeBSD.org Tue Feb 25 11:33:25 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 25 Feb 2014 12:33:25 +0100 Subject: [master] 128ca35 remove a couple of pointless copies of the HTTP status. Message-ID: commit 128ca35f6a48b5bea340d9ad734dd7c5394dd8ce Author: Poul-Henning Kamp Date: Wed Feb 19 08:35:05 2014 +0000 remove a couple of pointless copies of the HTTP status. Pick it out of struct http when needed. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 7ab3a1a..623e5ba 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -524,7 +524,6 @@ struct busyobj { int retries; unsigned refcount; double t_fetch; - uint16_t err_code; struct req *req; uint8_t *vary; @@ -591,7 +590,6 @@ struct object { struct objcore *objcore; uint8_t *vary; - uint16_t response; /* XXX: make bitmap */ uint8_t gziped; diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 661d802..4e4b229 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -142,7 +142,6 @@ vbf_bereq2obj(struct worker *wrk, struct busyobj *bo) } obj->vxid = bo->vsl->wid; - obj->response = bo->err_code; WS_Assert(bo->ws_o); /* Filter into object */ @@ -331,8 +330,6 @@ vbf_stp_fetchhdr(struct worker *wrk, struct busyobj *bo) */ bo->htc.body_status = RFC2616_Body(bo, &wrk->stats); - bo->err_code = http_GetStatus(bo->beresp); - /* * What does RFC2616 think about TTL ? */ diff --git a/bin/varnishd/cache/cache_http1_deliver.c b/bin/varnishd/cache/cache_http1_deliver.c index 66982b2..2c681d6 100644 --- a/bin/varnishd/cache/cache_http1_deliver.c +++ b/bin/varnishd/cache/cache_http1_deliver.c @@ -93,7 +93,7 @@ v1d_dorange(struct req *req, const char *r) ssize_t low, high, has_low; CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - assert(req->obj->response == 200); + assert(http_GetStatus(req->obj->http) == 200); if (strncmp(r, "bytes=", 6)) return; r += 6; @@ -271,7 +271,7 @@ V1D_Deliver(struct req *req) req->wantbody && !(req->res_mode & (RES_ESI|RES_ESI_CHILD)) && cache_param->http_range_support && - req->obj->response == 200) { + http_GetStatus(req->obj->http) == 200) { http_SetHeader(req->resp, "Accept-Ranges: bytes"); if (http_GetHdr(req->http, H_Range, &r)) v1d_dorange(req, r); diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index b2f3ef0..cb78866 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -147,7 +147,7 @@ cnt_deliver(struct worker *wrk, struct req *req) if (!(req->obj->objcore->flags & OC_F_PASS) && req->esi_level == 0 - && req->obj->response == 200 + && http_GetStatus(req->obj->http) == 200 && req->http->conds && RFC2616_Do_Cond(req)) http_SetResp(req->resp, "HTTP/1.1", 304, "Not Modified"); @@ -304,7 +304,7 @@ cnt_fetch(struct worker *wrk, struct req *req) req->obj = oc_getobj(&wrk->stats, req->objcore); req->objcore = NULL; - req->err_code = req->obj->response; + req->err_code = http_GetStatus(req->obj->http); req->req_step = R_STP_DELIVER; return (REQ_FSM_MORE); } From phk at FreeBSD.org Tue Feb 25 11:33:25 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 25 Feb 2014 12:33:25 +0100 Subject: [master] 6675a65 Ensure that bitfields get set. Message-ID: commit 6675a655c54c1ae55445d3c5b40839cc14ca11c9 Author: Poul-Henning Kamp Date: Wed Feb 19 09:19:45 2014 +0000 Ensure that bitfields get set. diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index 2b1629a..2c79c0e 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -159,7 +159,7 @@ VRT_l_bereq_uncacheable(const struct vrt_ctx *ctx, unsigned a) VSLb(ctx->vsl, SLT_VCL_Error, "Ignoring attempt to reset bereq.uncacheable"); } else if (a) { - ctx->bo->do_pass = a; + ctx->bo->do_pass = 1; } } @@ -182,7 +182,7 @@ VRT_l_beresp_uncacheable(const struct vrt_ctx *ctx, unsigned a) "Ignoring attempt to reset beresp.uncacheable"); } else if (a) { VSLb(ctx->vsl, SLT_Debug, "XXXX: UNCACHEABLE %u" , a); - ctx->bo->uncacheable = a; + ctx->bo->uncacheable = 1; } } From phk at FreeBSD.org Tue Feb 25 11:33:25 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 25 Feb 2014 12:33:25 +0100 Subject: [master] d2a7d10 Use the correct flag to controll EXP_Touch() calls Message-ID: commit d2a7d10fb6747720ad8a896939cdb9a69cd07271 Author: Poul-Henning Kamp Date: Fri Feb 21 08:36:45 2014 +0000 Use the correct flag to controll EXP_Touch() calls diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index cb78866..ba3ef0d 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -100,7 +100,7 @@ cnt_deliver(struct worker *wrk, struct req *req) assert(req->obj->objcore->refcnt > 0); req->t_resp = W_TIM_real(wrk); - if (!(req->obj->objcore->flags & OC_F_PRIVATE)) + if (req->obj->objcore->flags & OC_F_EXP) EXP_Touch(req->obj->objcore, req->t_resp); HTTP_Setup(req->resp, req->ws, req->vsl, SLT_RespMethod); From phk at FreeBSD.org Tue Feb 25 11:33:25 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 25 Feb 2014 12:33:25 +0100 Subject: [master] d1f1a6d Gently shuffle things around a bit. Message-ID: commit d1f1a6dd90d9f73ca33d6a76b42be7e3a9431ea0 Author: Poul-Henning Kamp Date: Fri Feb 21 09:00:16 2014 +0000 Gently shuffle things around a bit. diff --git a/bin/varnishd/cache/cache_expire.c b/bin/varnishd/cache/cache_expire.c index eeda901..1471a64 100644 --- a/bin/varnishd/cache/cache_expire.c +++ b/bin/varnishd/cache/cache_expire.c @@ -234,6 +234,8 @@ EXP_Rearm(struct object *o, double now, double ttl, double grace, double keep) CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); assert(oc->refcnt > 0); + AN(oc->flags & OC_F_EXP); + if (!isnan(ttl)) o->exp.ttl = now + ttl - o->exp.t_origin; if (!isnan(grace)) @@ -253,7 +255,6 @@ EXP_Rearm(struct object *o, double now, double ttl, double grace, double keep) CHECK_OBJ_NOTNULL(lru, LRU_MAGIC); Lck_Lock(&lru->mtx); - AN(oc->flags & OC_F_EXP); if (!isnan(now) && when <= now) oc->flags |= OC_F_DYING; diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 4e4b229..cdea235 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -56,10 +56,11 @@ vbf_release_req(struct busyobj *bo) } /*-------------------------------------------------------------------- + * Turn the beresp into a obj */ static int -vbf_bereq2obj(struct worker *wrk, struct busyobj *bo) +vbf_beresp2obj(struct worker *wrk, struct busyobj *bo) { unsigned l; char *b; @@ -157,8 +158,6 @@ vbf_bereq2obj(struct worker *wrk, struct busyobj *bo) else obj->last_modified = floor(bo->exp.t_origin); - assert(WRW_IsReleased(wrk)); - return (0); } @@ -302,16 +301,16 @@ vbf_stp_fetchhdr(struct worker *wrk, struct busyobj *bo) i = V1F_fetch_hdr(wrk, bo, bo->req); } - if (bo->do_pass && bo->req != NULL) - vbf_release_req(bo); /* XXX : retry ?? */ - - AZ(bo->req); - if (i) { AZ(bo->vbc); return (F_STP_ERROR); } + if (bo->do_pass && bo->req != NULL) + vbf_release_req(bo); /* XXX : retry ?? */ + + AZ(bo->req); + AN(bo->vbc); http_VSL_log(bo->beresp); @@ -463,13 +462,15 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) if (bo->htc.body_status == BS_NONE) bo->do_stream = 0; - if (vbf_bereq2obj(wrk, bo)) { + if (vbf_beresp2obj(wrk, bo)) { bo->stats = NULL; (void)VFP_Error(bo, "Could not get storage"); VDI_CloseFd(&bo->vbc); return (F_STP_DONE); } + assert(WRW_IsReleased(wrk)); + obj = bo->fetch_obj; /* @@ -536,11 +537,6 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) if (!bo->do_stream && bo->state != BOS_FAILED) HSH_Unbusy(&wrk->stats, obj->objcore); - if (bo->state != BOS_FAILED && !(obj->objcore->flags & OC_F_PRIVATE)) { - EXP_Insert(obj->objcore); - AN(obj->objcore->ban); - } - HSH_Complete(obj->objcore); assert(bo->refcount >= 1); @@ -615,10 +611,6 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo) VBO_setstate(bo, BOS_FETCHING); HSH_Unbusy(&wrk->stats, obj->objcore); - if (!(obj->objcore->flags & OC_F_PRIVATE)) { - EXP_Insert(obj->objcore); - AN(obj->objcore->ban); - } st = NULL; al = 0; @@ -683,19 +675,17 @@ vbf_stp_error(struct worker *wrk, struct busyobj *bo) xxxassert(wrk->handling == VCL_RET_DELIVER); + if (bo->req != NULL) + vbf_release_req(bo); + http_PrintfHeader(bo->beresp, "Content-Length: %jd", (intmax_t)0); http_PrintfHeader(bo->beresp, "X-XXXPHK: yes"); - if (vbf_bereq2obj(wrk, bo)) { + if (vbf_beresp2obj(wrk, bo)) { INCOMPL(); } HSH_Unbusy(&wrk->stats, bo->fetch_obj->objcore); - - if (!(bo->fetch_obj->objcore->flags & OC_F_PRIVATE)) { - EXP_Insert(bo->fetch_obj->objcore); - AN(bo->fetch_obj->objcore->ban); - } VBO_setstate(bo, BOS_FINISHED); HSH_Complete(bo->fetch_obj->objcore); return (F_STP_DONE); diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index b7eba44..9d5f9d1 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -678,8 +678,12 @@ HSH_Unbusy(struct dstat *ds, struct objcore *oc) if (oh->waitinglist != NULL) hsh_rush(ds, oh); Lck_Unlock(&oh->mtx); - if (!(oc->flags & OC_F_PRIVATE)) + if (!(oc->flags & OC_F_PRIVATE)) { BAN_NewObjCore(oc); + EXP_Insert(oc); + AN(oc->flags & OC_F_EXP); + AN(oc->ban); + } } /*--------------------------------------------------------------------- From phk at FreeBSD.org Tue Feb 25 11:33:25 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 25 Feb 2014 12:33:25 +0100 Subject: [master] f1708eb Deal with BS_ERROR much earlier Message-ID: commit f1708ebab3c417c6c75ce771d4952e0de3c842a2 Author: Poul-Henning Kamp Date: Fri Feb 21 09:35:39 2014 +0000 Deal with BS_ERROR much earlier diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index cdea235..de527da 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -329,6 +329,13 @@ vbf_stp_fetchhdr(struct worker *wrk, struct busyobj *bo) */ bo->htc.body_status = RFC2616_Body(bo, &wrk->stats); + if (bo->htc.body_status == BS_ERROR) { + AN (bo->vbc); + VDI_CloseFd(&bo->vbc); + VSLb(bo->vsl, SLT_VCL_Error, "Body cannot be fetched"); + return (F_STP_ERROR); + } + /* * What does RFC2616 think about TTL ? */ @@ -488,19 +495,9 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) else if (bo->state != BOS_FAILED) WRONG("Wrong bo->state"); - switch (bo->htc.body_status) { - case BS_NONE: - break; - case BS_ERROR: - /* XXX: Why not earlier ? */ - bo->should_close |= - VFP_Error(bo, "error incompatible Transfer-Encoding"); - break; - default: - if (bo->vbc == NULL) - (void)VFP_Error(bo, "Backend connection gone"); - else - VFP_Fetch_Body(bo, est); + if (bo->htc.body_status != BS_NONE) { + assert(bo->htc.body_status != BS_ERROR); + VFP_Fetch_Body(bo, est); } bo->stats = NULL; From phk at FreeBSD.org Tue Feb 25 11:33:25 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 25 Feb 2014 12:33:25 +0100 Subject: [master] e734b2a Now that busyobj has its own worker thread, borrow the stats throughout the show. Message-ID: commit e734b2a4e9e89b169765b66289ea99651c65d3fb Author: Poul-Henning Kamp Date: Fri Feb 21 09:50:39 2014 +0000 Now that busyobj has its own worker thread, borrow the stats throughout the show. diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index de527da..0b9bf21 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -60,7 +60,7 @@ vbf_release_req(struct busyobj *bo) */ static int -vbf_beresp2obj(struct worker *wrk, struct busyobj *bo) +vbf_beresp2obj(struct busyobj *bo) { unsigned l; char *b; @@ -104,8 +104,6 @@ vbf_beresp2obj(struct worker *wrk, struct busyobj *bo) bo->exp.ttl+bo->exp.grace+bo->exp.keep < cache_param->shortlived) bo->storage_hint = TRANSIENT_STORAGE; - AZ(bo->stats); - bo->stats = &wrk->stats; AN(bo->fetch_objcore); obj = STV_NewObject(bo, bo->storage_hint, l, nhttp); if (obj == NULL && @@ -469,8 +467,7 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) if (bo->htc.body_status == BS_NONE) bo->do_stream = 0; - if (vbf_beresp2obj(wrk, bo)) { - bo->stats = NULL; + if (vbf_beresp2obj(bo)) { (void)VFP_Error(bo, "Could not get storage"); VDI_CloseFd(&bo->vbc); return (F_STP_DONE); @@ -500,8 +497,6 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) VFP_Fetch_Body(bo, est); } - bo->stats = NULL; - bo->t_body = VTIM_mono(); VSLb(bo->vsl, SLT_Fetch_Body, "%u(%s)", @@ -572,7 +567,6 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo) vl = 0; l += http_EstimateWS(bo->ims_obj->http, 0, &nhttp); - bo->stats = &wrk->stats; obj = STV_NewObject(bo, bo->storage_hint, l, nhttp); if (obj == NULL) { (void)VFP_Error(bo, "Could not get storage"); @@ -634,7 +628,6 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo) } while (bo->state < BOS_FAILED && (ois == OIS_DATA || ois == OIS_STREAM)); ObjIterEnd(&oi); - bo->stats = NULL; if (bo->state != BOS_FAILED) { assert(al == bo->ims_obj->len); assert(obj->len == al); @@ -678,7 +671,7 @@ vbf_stp_error(struct worker *wrk, struct busyobj *bo) http_PrintfHeader(bo->beresp, "Content-Length: %jd", (intmax_t)0); http_PrintfHeader(bo->beresp, "X-XXXPHK: yes"); - if (vbf_beresp2obj(wrk, bo)) { + if (vbf_beresp2obj(bo)) { INCOMPL(); } @@ -731,6 +724,8 @@ vbf_fetch_thread(struct worker *wrk, void *priv) bo->t_hdr = NAN; bo->t_body = NAN; + bo->stats = &wrk->stats; + while (stp != F_STP_DONE) { CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); bo->step = stp; @@ -749,6 +744,8 @@ vbf_fetch_thread(struct worker *wrk, void *priv) } assert(WRW_IsReleased(wrk)); + bo->stats = NULL; + if (bo->vbc != NULL) { if (bo->should_close) VDI_CloseFd(&bo->vbc); From phk at FreeBSD.org Tue Feb 25 11:33:25 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 25 Feb 2014 12:33:25 +0100 Subject: [master] 6801c39 Eliminate some debugging which has overstayed its usefulness Message-ID: commit 6801c3965be74f78b7986146709d366ab10e2de9 Author: Poul-Henning Kamp Date: Fri Feb 21 10:01:08 2014 +0000 Eliminate some debugging which has overstayed its usefulness diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 0b9bf21..5b89bf1 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -536,8 +536,6 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) if (bo->state != BOS_FAILED) VBO_setstate(bo, BOS_FINISHED); -VSLb(bo->vsl, SLT_Debug, "YYY REF %d %d", - bo->refcount, bo->fetch_obj->objcore->refcnt); return (F_STP_DONE); } @@ -691,20 +689,6 @@ vbf_stp_done(void) return (F_STP_DONE); } -static const char * -vbf_step_name(enum fetch_step stp) -{ - switch (stp) { -#define FETCH_STEP(l, U, arg) \ - case F_STP_##U: \ - return (#U); -#include "tbl/steps.h" -#undef FETCH_STEP - default: - return ("F-step ?"); - } -} - static void vbf_fetch_thread(struct worker *wrk, void *priv) { @@ -739,8 +723,6 @@ vbf_fetch_thread(struct worker *wrk, void *priv) default: WRONG("Illegal fetch_step"); } - VSLb(bo->vsl, SLT_Debug, "%s -> %s", - vbf_step_name(bo->step), vbf_step_name(stp)); } assert(WRW_IsReleased(wrk)); From phk at FreeBSD.org Tue Feb 25 11:33:25 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 25 Feb 2014 12:33:25 +0100 Subject: [master] 911194b Collect code for increased clarity Message-ID: commit 911194b2d03a57637b7ce4fb00dd6479f21e7703 Author: Poul-Henning Kamp Date: Mon Feb 24 14:08:55 2014 +0000 Collect code for increased clarity diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 5b89bf1..890b247 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -422,21 +422,19 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) if (bo->do_gunzip && !bo->is_gzip) bo->do_gunzip = 0; - /* If we do gunzip, remove the C-E header */ - if (bo->do_gunzip) - http_Unset(bo->beresp, H_Content_Encoding); - /* We wont gzip unless it is ungziped */ if (bo->do_gzip && !bo->is_gunzip) bo->do_gzip = 0; - /* If we do gzip, add the C-E header */ - if (bo->do_gzip) - http_SetHeader(bo->beresp, "Content-Encoding: gzip"); - /* But we can't do both at the same time */ assert(bo->do_gzip == 0 || bo->do_gunzip == 0); + /* Fix Content-Encoding, as appropriate */ + if (bo->do_gzip) + http_SetHeader(bo->beresp, "Content-Encoding: gzip"); + else if (bo->do_gunzip) + http_Unset(bo->beresp, H_Content_Encoding); + AN(bo->vbc); est = V1F_Setup_Fetch(bo); From phk at FreeBSD.org Tue Feb 25 11:33:25 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 25 Feb 2014 12:33:25 +0100 Subject: [master] 6895fcb Use the same storage allocation policy for 304/IMS as for regular fetches. Message-ID: commit 6895fcb6801994073068d9d6d48b3f6a84f77868 Author: Poul-Henning Kamp Date: Tue Feb 25 08:28:16 2014 +0000 Use the same storage allocation policy for 304/IMS as for regular fetches. diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 890b247..914c6d4 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -56,6 +56,52 @@ vbf_release_req(struct busyobj *bo) } /*-------------------------------------------------------------------- + * Allocate an object, with fall-back to Transient. + * XXX: This somewhat overlaps the stuff in stevedore.c + * XXX: Should this be merged over there ? + */ + +static struct object * +vbf_allocobj(struct busyobj *bo, unsigned l, uint16_t nhttp) +{ + struct object *obj; + const char *storage_hint; + double lifetime; + + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + CHECK_OBJ_NOTNULL(bo->fetch_objcore, OBJCORE_MAGIC); + + lifetime = bo->exp.ttl + bo->exp.grace + bo->exp.keep; + + if (bo->uncacheable || lifetime < cache_param->shortlived) + storage_hint = TRANSIENT_STORAGE; + else + storage_hint = bo->storage_hint; + + bo->storage_hint = NULL; + + obj = STV_NewObject(bo, storage_hint, l, nhttp); + + if (obj != NULL) + return (obj); + + if (storage_hint != NULL && !strcmp(storage_hint, TRANSIENT_STORAGE)) + return (NULL); + + /* + * Try to salvage the transaction by allocating a shortlived object + * on Transient storage. + */ + + if (bo->exp.ttl > cache_param->shortlived) + bo->exp.ttl = cache_param->shortlived; + bo->exp.grace = 0.0; + bo->exp.keep = 0.0; + obj = STV_NewObject(bo, TRANSIENT_STORAGE, l, nhttp); + return (obj); +} + +/*-------------------------------------------------------------------- * Turn the beresp into a obj */ @@ -100,32 +146,13 @@ vbf_beresp2obj(struct busyobj *bo) if (bo->uncacheable) bo->fetch_objcore->flags |= OC_F_PASS; - if (bo->uncacheable || - bo->exp.ttl+bo->exp.grace+bo->exp.keep < cache_param->shortlived) - bo->storage_hint = TRANSIENT_STORAGE; - - AN(bo->fetch_objcore); - obj = STV_NewObject(bo, bo->storage_hint, l, nhttp); - if (obj == NULL && - (bo->storage_hint == NULL || - strcmp(bo->storage_hint, TRANSIENT_STORAGE))) { - /* - * Try to salvage the transaction by allocating a - * shortlived object on Transient storage. - */ - if (bo->exp.ttl > cache_param->shortlived) - bo->exp.ttl = cache_param->shortlived; - bo->exp.grace = 0.0; - bo->exp.keep = 0.0; - obj = STV_NewObject(bo, TRANSIENT_STORAGE, l, nhttp); - } + obj = vbf_allocobj(bo, l, nhttp); + if (obj == NULL) return (-1); CHECK_OBJ_NOTNULL(obj, OBJECT_MAGIC); - bo->storage_hint = NULL; - AZ(bo->fetch_obj); bo->fetch_obj = obj; @@ -563,7 +590,7 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo) vl = 0; l += http_EstimateWS(bo->ims_obj->http, 0, &nhttp); - obj = STV_NewObject(bo, bo->storage_hint, l, nhttp); + obj = vbf_allocobj(bo, l, nhttp); if (obj == NULL) { (void)VFP_Error(bo, "Could not get storage"); VDI_CloseFd(&bo->vbc); From phk at FreeBSD.org Tue Feb 25 11:33:25 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 25 Feb 2014 12:33:25 +0100 Subject: [master] 8c8b500 Drop the BOS_COMMITTED state, and rename BOS_FETCHING to BOS_STREAM which is really what client threads care about. Message-ID: commit 8c8b5007403f80ecb4cca537d1fb8f7bc0648e1f Author: Poul-Henning Kamp Date: Tue Feb 25 09:27:23 2014 +0000 Drop the BOS_COMMITTED state, and rename BOS_FETCHING to BOS_STREAM which is really what client threads care about. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 623e5ba..5db6e22 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -503,8 +503,7 @@ oc_getlru(const struct objcore *oc) enum busyobj_state_e { BOS_INVALID = 0, /* don't touch (yet) */ BOS_REQ_DONE, /* beresp.* can be examined */ - BOS_COMMITTED, /* beresp.* can be examined */ - BOS_FETCHING, /* beresp.* can be examined */ + BOS_STREAM, /* beresp.* can be examined */ BOS_FINISHED, /* object is complete */ BOS_FAILED, /* something went wrong */ }; diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 914c6d4..b64b2bb 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -395,7 +395,6 @@ vbf_stp_fetchhdr(struct worker *wrk, struct busyobj *bo) } assert(bo->state == BOS_REQ_DONE); - VBO_setstate(bo, BOS_COMMITTED); if (bo->do_esi) bo->do_stream = 0; @@ -509,13 +508,13 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) assert(bo->refcount >= 1); AZ(WS_Overflowed(bo->ws_o)); - if (bo->do_stream) - HSH_Unbusy(&wrk->stats, obj->objcore); - if (bo->state == BOS_COMMITTED) - VBO_setstate(bo, BOS_FETCHING); - else if (bo->state != BOS_FAILED) - WRONG("Wrong bo->state"); + assert (bo->state == BOS_REQ_DONE); + + if (bo->do_stream) { + HSH_Unbusy(&wrk->stats, obj->objcore); + VBO_setstate(bo, BOS_STREAM); + } if (bo->htc.body_status != BS_NONE) { assert(bo->htc.body_status != BS_ERROR); @@ -530,7 +529,10 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) if (bo->state == BOS_FAILED) { wrk->stats.fetch_failed++; } else { - assert(bo->state == BOS_FETCHING); + if (bo->do_stream) + assert(bo->state == BOS_STREAM); + else + assert(bo->state == BOS_REQ_DONE); VSLb(bo->vsl, SLT_Length, "%zd", obj->len); @@ -622,7 +624,7 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo) AZ(WS_Overflowed(bo->ws_o)); - VBO_setstate(bo, BOS_FETCHING); + VBO_setstate(bo, BOS_STREAM); HSH_Unbusy(&wrk->stats, obj->objcore); @@ -849,9 +851,7 @@ VBF_Fetch(struct worker *wrk, struct req *req, struct objcore *oc, if (mode == VBF_BACKGROUND) { VBO_waitstate(bo, BOS_REQ_DONE); } else { - VBO_waitstate(bo, BOS_FETCHING); - if (!bo->do_stream) - VBO_waitstate(bo, BOS_FINISHED); + VBO_waitstate(bo, BOS_STREAM); assert(bo->state != BOS_FAILED || (oc->flags & OC_F_FAILED)); } VBO_DerefBusyObj(wrk, &bo); diff --git a/bin/varnishd/cache/cache_fetch_proc.c b/bin/varnishd/cache/cache_fetch_proc.c index ea928e4..b21ca15 100644 --- a/bin/varnishd/cache/cache_fetch_proc.c +++ b/bin/varnishd/cache/cache_fetch_proc.c @@ -61,7 +61,7 @@ VFP_Error(struct busyobj *bo, const char *fmt, ...) va_list ap; CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); - assert(bo->state >= BOS_COMMITTED); + assert(bo->state >= BOS_REQ_DONE); if (bo->state < BOS_FAILED) { va_start(ap, fmt); VSLbv(bo->vsl, SLT_FetchError, fmt, ap); From phk at FreeBSD.org Tue Feb 25 11:33:26 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 25 Feb 2014 12:33:26 +0100 Subject: [master] 25b38f9 Add the internal bo->failed state we need to allow retries separate from the external BOS_FAILED state. Message-ID: commit 25b38f92702e74d0014c36033b24755c79dddada Author: Poul-Henning Kamp Date: Tue Feb 25 10:29:24 2014 +0000 Add the internal bo->failed state we need to allow retries separate from the external BOS_FAILED state. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 5db6e22..7c6079e 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -500,6 +500,9 @@ oc_getlru(const struct objcore *oc) * streaming delivery will make use of. */ +/* + * The macro-states we expose outside the fetch code + */ enum busyobj_state_e { BOS_INVALID = 0, /* don't touch (yet) */ BOS_REQ_DONE, /* beresp.* can be examined */ @@ -514,7 +517,6 @@ struct busyobj { struct lock mtx; pthread_cond_t cond; char *end; - enum fetch_step step; /* * All fields from refcount and down are zeroed when the busyobj @@ -532,6 +534,7 @@ struct busyobj { intptr_t vfps_priv[N_VFPS]; int vfp_nxt; + int failed; enum busyobj_state_e state; struct ws ws[1]; diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index b64b2bb..0c621df 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -494,7 +494,7 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) if (vbf_beresp2obj(bo)) { (void)VFP_Error(bo, "Could not get storage"); VDI_CloseFd(&bo->vbc); - return (F_STP_DONE); + return (F_STP_ERROR); } assert(WRW_IsReleased(wrk)); @@ -526,7 +526,7 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) VSLb(bo->vsl, SLT_Fetch_Body, "%u(%s)", bo->htc.body_status, body_status_2str(bo->htc.body_status)); - if (bo->state == BOS_FAILED) { + if (bo->failed) { wrk->stats.fetch_failed++; } else { if (bo->do_stream) @@ -553,16 +553,29 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) } } - if (!bo->do_stream && bo->state != BOS_FAILED) - HSH_Unbusy(&wrk->stats, obj->objcore); + if (!bo->do_stream) { + if (bo->failed) { + if (bo->fetch_obj != NULL) { + oc_freeobj(bo->fetch_objcore); + bo->fetch_obj = NULL; + bo->stats->n_object--; + } + return (F_STP_ERROR); + } else { + HSH_Unbusy(&wrk->stats, obj->objcore); + VBO_setstate(bo, BOS_FINISHED); + } + } else if (bo->failed) { + HSH_Fail(bo->fetch_objcore); + VBO_setstate(bo, BOS_FAILED); + } else { + VBO_setstate(bo, BOS_FINISHED); + } HSH_Complete(obj->objcore); assert(bo->refcount >= 1); - if (bo->state != BOS_FAILED) - VBO_setstate(bo, BOS_FINISHED); - return (F_STP_DONE); } @@ -650,14 +663,16 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo) if (st->len == st->space) st = NULL; } - } while (bo->state < BOS_FAILED && - (ois == OIS_DATA || ois == OIS_STREAM)); + } while (!bo->failed && (ois == OIS_DATA || ois == OIS_STREAM)); ObjIterEnd(&oi); - if (bo->state != BOS_FAILED) { + if (!bo->failed) { assert(al == bo->ims_obj->len); assert(obj->len == al); VBO_setstate(bo, BOS_FINISHED); EXP_Rearm(bo->ims_obj, bo->ims_obj->exp.t_origin, 0, 0, 0); + } else { + HSH_Fail(bo->fetch_objcore); + VBO_setstate(bo, BOS_FAILED); } HSH_Complete(obj->objcore); return (F_STP_DONE); @@ -673,7 +688,7 @@ vbf_stp_error(struct worker *wrk, struct busyobj *bo) CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); - AN(bo->fetch_objcore->flags &= OC_F_BUSY); + AN(bo->fetch_objcore->flags & OC_F_BUSY); // XXX: reset all beresp flags ? @@ -697,7 +712,9 @@ vbf_stp_error(struct worker *wrk, struct busyobj *bo) http_PrintfHeader(bo->beresp, "X-XXXPHK: yes"); if (vbf_beresp2obj(bo)) { - INCOMPL(); + VBO_setstate(bo, BOS_FAILED); + HSH_Fail(bo->fetch_objcore); + return (F_STP_DONE); } HSH_Unbusy(&wrk->stats, bo->fetch_obj->objcore); @@ -739,7 +756,6 @@ vbf_fetch_thread(struct worker *wrk, void *priv) while (stp != F_STP_DONE) { CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); - bo->step = stp; switch(stp) { #define FETCH_STEP(l, U, arg) \ case F_STP_##U: \ diff --git a/bin/varnishd/cache/cache_fetch_proc.c b/bin/varnishd/cache/cache_fetch_proc.c index b21ca15..8861e1d 100644 --- a/bin/varnishd/cache/cache_fetch_proc.c +++ b/bin/varnishd/cache/cache_fetch_proc.c @@ -62,12 +62,11 @@ VFP_Error(struct busyobj *bo, const char *fmt, ...) CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); assert(bo->state >= BOS_REQ_DONE); - if (bo->state < BOS_FAILED) { + if (!bo->failed) { va_start(ap, fmt); VSLbv(bo->vsl, SLT_FetchError, fmt, ap); va_end(ap); - HSH_Fail(bo->fetch_objcore); - VBO_setstate(bo, BOS_FAILED); + bo->failed = 1; } return (VFP_ERROR); } @@ -214,7 +213,7 @@ VFP_Fetch_Body(struct busyobj *bo, ssize_t est) bo->should_close = 1; break; } - assert(bo->state != BOS_FAILED); + AZ(bo->failed); if (st == NULL) { st = VFP_GetStorage(bo, est); est = 0; @@ -228,7 +227,7 @@ VFP_Fetch_Body(struct busyobj *bo, ssize_t est) CHECK_OBJ_NOTNULL(st, STORAGE_MAGIC); assert(st == VTAILQ_LAST(&bo->fetch_obj->store, storagehead)); l = st->space - st->len; - assert(bo->state != BOS_FAILED); + AZ(bo->failed); vfps = VFP_Suck(bo, st->ptr + st->len, &l); if (l > 0 && vfps != VFP_ERROR) { assert(!VTAILQ_EMPTY(&bo->fetch_obj->store)); @@ -239,7 +238,7 @@ VFP_Fetch_Body(struct busyobj *bo, ssize_t est) } while (vfps == VFP_OK); if (vfps == VFP_ERROR) { - assert(bo->state == BOS_FAILED); + AN(bo->failed); (void)VFP_Error(bo, "Fetch Pipeline failed to process"); bo->should_close = 1; } diff --git a/bin/varnishtest/tests/r01284.vtc b/bin/varnishtest/tests/r01284.vtc index 6299926..123ddb2 100644 --- a/bin/varnishtest/tests/r01284.vtc +++ b/bin/varnishtest/tests/r01284.vtc @@ -19,6 +19,10 @@ varnish v1 \ } } -start +varnish v1 -cliok "param.set debug +syncvsl" + +delay .1 + client c1 { # Fill transient txreq -url "/obj1" @@ -26,6 +30,8 @@ client c1 { expect resp.status == 200 } -run +delay .1 + varnish v1 -expect SMA.Transient.g_bytes > 1048000 varnish v1 -expect SMA.Transient.g_space < 200 @@ -36,8 +42,8 @@ client c1 { delay 1 } -run -# Two failures, one for obj2 and one for the attempts at sending error -varnish v1 -expect SMA.Transient.c_fail == 2 +# Three failures, one for obj2, one for vcl_backend_error{} and for vcl_error{} +varnish v1 -expect SMA.Transient.c_fail == 3 client c1 { # Check that Varnish is still alive From lkarsten at varnish-software.com Tue Feb 25 11:41:10 2014 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Tue, 25 Feb 2014 12:41:10 +0100 Subject: [master] fd2f519 Fix faulty example. Reformat tabs/spaces Message-ID: commit fd2f5191b21721ed3c6a6f7e56f0605333bd9c5c Author: Lasse Karstensen Date: Tue Feb 25 12:39:40 2014 +0100 Fix faulty example. Reformat tabs/spaces Fixes #1438. diff --git a/doc/sphinx/users-guide/vcl-backends.rst b/doc/sphinx/users-guide/vcl-backends.rst index d5b1aae..ee21f4d 100644 --- a/doc/sphinx/users-guide/vcl-backends.rst +++ b/doc/sphinx/users-guide/vcl-backends.rst @@ -11,17 +11,17 @@ your favorite text editor and open the relevant VCL file. Somewhere in the top there will be a section that looks a bit like this.:: - # backend default { - # .host = "127.0.0.1"; - # .port = "8080"; - # } + # backend default { + # .host = "127.0.0.1"; + # .port = "8080"; + # } We comment in this bit of text making the text look like.:: - backend default { - .host = "127.0.0.1"; - .port = "8080"; - } + backend default { + .host = "127.0.0.1"; + .port = "8080"; + } Now, this piece of configuration defines a backend in Varnish called *default*. When Varnish needs to get content from this backend it will @@ -46,27 +46,27 @@ site. Lets say our Java application should handle URL beginning with We manage to get the thing up and running on port 8000. Now, lets have a look at the default.vcl.:: - backend default { - .host = "127.0.0.1"; - .port = "8080"; - } + backend default { + .host = "127.0.0.1"; + .port = "8080"; + } We add a new backend.:: - backend java { - .host = "127.0.0.1"; - .port = "8000"; - } + backend java { + .host = "127.0.0.1"; + .port = "8000"; + } Now we need tell where to send the difference URL. Lets look at vcl_recv.:: - sub vcl_recv { - if (req.url ~ "^/java/") { - set req.backend = java; - } else { - set req.backend = default. - } - } + sub vcl_recv { + if (req.url ~ "^/java/") { + set req.backend = java; + } else { + set req.backend = default. + } + } It's quite simple, really. Lets stop and think about this for a moment. As you can see you can define how you choose backends based on @@ -86,25 +86,24 @@ hosts you just need to inspect req.http.host. You can have something like this::: - sub vcl_recv { - if (req.http.host ~ "foo.com") { - set req.backend = foo; - } elsif (req.http.host ~ "bar.com") { - set req.backend = bar; - } - } + sub vcl_recv { + if (req.http.host ~ "foo.com") { + set req.backend = foo; + } elsif (req.http.host ~ "bar.com") { + set req.backend = bar; + } + } Note that the first regular expressions will match foo.com, www.foo.com, zoop.foo.com and any other host ending in foo.com. In this example this is intentional but you might want it to be a bit more tight, maybe relying on the == operator in stead, like this::: - - sub vcl_recv { - if (req.http.host == "foo.com" or req.http.host == "www.foo.com") { - set req.backend = foo; + sub vcl_recv { + if (req.http.host == "foo.com" or req.http.host == "www.foo.com") { + set req.backend = foo; + } } - } .. _users-guide-advanced_backend_servers-directors: @@ -115,37 +114,37 @@ Directors You can also group several backend into a group of backends. These groups are called directors. This will give you increased performance -and resilience. +and resilience. You can define several backends and group them together in a -director. This requires you to load a VMOD, a Varnish module, and then to +director. This requires you to load a VMOD, a Varnish module, and then to call certain actions in vcl_init.:: - import directors; # load the directors + import directors; # load the directors - backend server1 { - .host = "192.168.0.10"; - } - backend server2{ - .host = "192.168.0.10"; - } - - sub vcl_init { - new bar = directors.round_robin(); - bar.add_backend(server1); - bar.add_backend(server2); - } - - sub vcl_recv { - # send all traffic to the bar director: - req.backend = bar.backend; + backend server1 { + .host = "192.168.0.10"; + } + backend server2{ + .host = "192.168.0.10"; } + sub vcl_init { + new bar = directors.round_robin(); + bar.add_backend(server1); + bar.add_backend(server2); + } + + sub vcl_recv { + # send all traffic to the bar director: + req.backend = bar.backend(); + } + This director is a round-robin director. This means the director will distribute the incoming requests on a round-robin basis. There is also a *random* director which distributes requests in a, you guessed -it, random fashion. +it, random fashion. But what if one of your servers goes down? Can Varnish direct all the requests to the healthy server? Sure it can. This is where the Health @@ -159,64 +158,59 @@ Health checks Lets set up a director with two backends and health checks. First lets define the backends.:: - backend server1 { - .host = "server1.example.com"; - .probe = { - .url = "/"; - .interval = 5s; - .timeout = 1 s; - .window = 5; - .threshold = 3; - } - } - backend server2 { - .host = "server2.example.com"; - .probe = { - .url = "/"; - .interval = 5s; - .timeout = 1 s; - .window = 5; - .threshold = 3; - } + backend server1 { + .host = "server1.example.com"; + .probe = { + .url = "/"; + .interval = 5s; + .timeout = 1 s; + .window = 5; + .threshold = 3; } + } + + backend server2 { + .host = "server2.example.com"; + .probe = { + .url = "/"; + .interval = 5s; + .timeout = 1 s; + .window = 5; + .threshold = 3; + } + } Whats new here is the probe. Varnish will check the health of each -backend with a probe. The options are +backend with a probe. The options are: url - What URL should Varnish request. + What URL should Varnish request. interval - How often should we poll + How often should we poll timeout - What is the timeout of the probe + What is the timeout of the probe window - Varnish will maintain a *sliding window* of the results. Here the - window has five checks. + Varnish will maintain a *sliding window* of the results. Here the + window has five checks. threshold - How many of the .window last polls must be good for the backend to be declared healthy. + How many of the .window last polls must be good for the backend to be declared healthy. initial - How many of the of the probes a good when Varnish starts - defaults - to the same amount as the threshold. + How many of the of the probes a good when Varnish starts - defaults + to the same amount as the threshold. Now we define the director.:: - import directors; - - director example_director round-robin { - { - .backend = server1; - } - # server2 - { - .backend = server2; - } + import directors; - } + director example_director round-robin { + { .backend = server1; } + { .backend = server2; } + } You use this director just as you would use any other director or backend. Varnish will not send traffic to hosts that are marked as From lkarsten at varnish-software.com Tue Feb 25 11:48:15 2014 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Tue, 25 Feb 2014 12:48:15 +0100 Subject: [master] 625f53b Prettier formatting of RST lists. Message-ID: commit 625f53b391b1acaeeb6774259c362e772d59b006 Author: Lasse Karstensen Date: Tue Feb 25 12:47:34 2014 +0100 Prettier formatting of RST lists. Remove the last few tabs that was forgotten on the last commit. diff --git a/doc/sphinx/users-guide/vcl-backends.rst b/doc/sphinx/users-guide/vcl-backends.rst index ee21f4d..6e72416 100644 --- a/doc/sphinx/users-guide/vcl-backends.rst +++ b/doc/sphinx/users-guide/vcl-backends.rst @@ -124,11 +124,11 @@ call certain actions in vcl_init.:: import directors; # load the directors backend server1 { - .host = "192.168.0.10"; - } - backend server2{ - .host = "192.168.0.10"; - } + .host = "192.168.0.10"; + } + backend server2 { + .host = "192.168.0.10"; + } sub vcl_init { new bar = directors.round_robin(); @@ -138,7 +138,7 @@ call certain actions in vcl_init.:: sub vcl_recv { # send all traffic to the bar director: - req.backend = bar.backend(); + req.backend = bar.backend(); } This director is a round-robin director. This means the director will @@ -170,14 +170,14 @@ define the backends.:: } backend server2 { - .host = "server2.example.com"; - .probe = { + .host = "server2.example.com"; + .probe = { .url = "/"; .interval = 5s; .timeout = 1 s; .window = 5; .threshold = 3; - } + } } Whats new here is the probe. Varnish will check the health of each From lkarsten at varnish-software.com Tue Feb 25 13:09:41 2014 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Tue, 25 Feb 2014 14:09:41 +0100 Subject: [master] 7633860 Remove extra meta-header. Message-ID: commit 76338608b75334bf504667a562585f6dce0ca5cd Author: Lasse Karstensen Date: Tue Feb 25 13:54:24 2014 +0100 Remove extra meta-header. We never know when to update this header. All the important parts of it is available in the git log. Since we don't really do versioning of documentation, it was really just taking up space. I've tried my best to keep the author names from the headers in the history section. diff --git a/doc/sphinx/reference/varnish-cli.rst b/doc/sphinx/reference/varnish-cli.rst index 33e9a67..f967465 100644 --- a/doc/sphinx/reference/varnish-cli.rst +++ b/doc/sphinx/reference/varnish-cli.rst @@ -6,11 +6,6 @@ Varnish CLI Varnish Command Line Interface ------------------------------ -:Author: Per Buer -:Date: 2011-03-23 -:Version: 0.1 -:Manual section: 7 - DESCRIPTION =========== diff --git a/doc/sphinx/reference/varnishadm.rst b/doc/sphinx/reference/varnishadm.rst index 95113fa..54e42ec 100644 --- a/doc/sphinx/reference/varnishadm.rst +++ b/doc/sphinx/reference/varnishadm.rst @@ -2,16 +2,9 @@ varnishadm ========== ----------------------------------- Control a running Varnish instance ---------------------------------- -:Author: Cecilie Fritzvold -:Author: Per Buer -:Date: 2010-05-31 -:Version: 0.3 -:Manual section: 1 - SYNOPSIS ======== diff --git a/doc/sphinx/reference/varnishd.rst b/doc/sphinx/reference/varnishd.rst index f5599c5..0f7d7fa 100644 --- a/doc/sphinx/reference/varnishd.rst +++ b/doc/sphinx/reference/varnishd.rst @@ -1,20 +1,13 @@ .. _ref-varnishd: -========= - varnishd -========= +======== +varnishd +======== ----------------------- HTTP accelerator daemon ----------------------- -:Author: Dag-Erling Sm?rgrav -:Author: Stig Sandbeck Mathisen -:Author: Per Buer -:Date: 2010-05-31 -:Version: 1.0 -:Manual section: 1 - SYNOPSIS ======== diff --git a/doc/sphinx/reference/varnishhist.rst b/doc/sphinx/reference/varnishhist.rst index 6446fb1..f513294 100644 --- a/doc/sphinx/reference/varnishhist.rst +++ b/doc/sphinx/reference/varnishhist.rst @@ -6,12 +6,6 @@ varnishhist Varnish request histogram ------------------------- -:Author: Dag-Erling Sm?rgrav -:Date: 2010-05-31 -:Version: 1.0 -:Manual section: 1 - - SYNOPSIS ======== @@ -80,8 +74,9 @@ SEE ALSO HISTORY ======= -The varnishhist utility was developed by Poul-Henning Kamp in cooperation with Verdens Gang -AS and Varnish Software AS. This manual page was written by Dag-Erling Sm?rgrav. +The varnishhist utility was developed by Poul-Henning Kamp in cooperation with +Verdens Gang AS and Varnish Software AS. This manual page was written by +Dag-Erling Sm?rgrav. COPYRIGHT ========= diff --git a/doc/sphinx/reference/varnishlog.rst b/doc/sphinx/reference/varnishlog.rst index 7f6d0bf..b916752 100644 --- a/doc/sphinx/reference/varnishlog.rst +++ b/doc/sphinx/reference/varnishlog.rst @@ -8,14 +8,6 @@ varnishlog Display Varnish logs -------------------- -:Author: Dag-Erling Sm?rgrav -:Author: Per Buer -:Author: Martin Blix Grydeland -:Date: 2013-05-15 -:Version: 0.3 -:Manual section: 1 - - SYNOPSIS ======== @@ -70,7 +62,7 @@ HISTORY The varnishlog utility was developed by Poul-Henning Kamp in cooperation with Verdens Gang AS and Varnish Software AS. This manual page was initially written by Dag-Erling -Sm?rgrav. +Sm?rgrav, and later updated by Per Buer and Martin Blix Grydeland. COPYRIGHT diff --git a/doc/sphinx/reference/varnishncsa.rst b/doc/sphinx/reference/varnishncsa.rst index 8189696..2902f6b 100644 --- a/doc/sphinx/reference/varnishncsa.rst +++ b/doc/sphinx/reference/varnishncsa.rst @@ -6,13 +6,6 @@ varnishncsa Display Varnish logs in Apache / NCSA combined log format --------------------------------------------------------- -:Author: Dag-Erling Sm?rgrav -:Author: Martin Blix Grydeland -:Date: 2010-05-31 -:Version: 1.0 -:Manual section: 1 - - SYNOPSIS ======== @@ -139,8 +132,10 @@ HISTORY ======= The varnishncsa utility was developed by Poul-Henning Kamp in -cooperation with Verdens Gang AS and Varnish Software AS. This manual page was -written by Dag-Erling Sm?rgrav . +cooperation with Verdens Gang AS and Varnish Software AS. This manual page was +initially written by Dag-Erling Sm?rgrav , and later updated +by Martin Blix Grydeland. + COPYRIGHT ========= diff --git a/doc/sphinx/reference/varnishreplay.rst b/doc/sphinx/reference/varnishreplay.rst index b8b89e9..884e7b7 100644 --- a/doc/sphinx/reference/varnishreplay.rst +++ b/doc/sphinx/reference/varnishreplay.rst @@ -6,13 +6,6 @@ varnishreplay HTTP traffic replay tool ------------------------ -:Author: Cecilie Fritzvold -:Author: Per Buer -:Date: 2010-05-31 -:Version: 1.0 -:Manual section: 1 - - SYNOPSIS ======== varnishreplay [-D] -a address:port -r file diff --git a/doc/sphinx/reference/varnishsizes.rst b/doc/sphinx/reference/varnishsizes.rst index cc36277..91c37a9 100644 --- a/doc/sphinx/reference/varnishsizes.rst +++ b/doc/sphinx/reference/varnishsizes.rst @@ -6,13 +6,6 @@ varnishsizes Varnish object size request histogram ------------------------------------- -:Author: Dag Erling Sm?rgrav -:Author: Kristian Lyngst?l -:Author: Per Buer -:Date: 2010-05-31 -:Version: 1.0 -:Manual section: 1 - SYNOPSIS ======== diff --git a/doc/sphinx/reference/varnishstat.rst b/doc/sphinx/reference/varnishstat.rst index 67829c0..3505526 100644 --- a/doc/sphinx/reference/varnishstat.rst +++ b/doc/sphinx/reference/varnishstat.rst @@ -8,14 +8,6 @@ varnishstat Varnish Cache statistics --------------------------- -:Author: Dag-Erling Sm?rgrav -:Author: Per Buer -:Author: Lasse Karstensen -:Date: 2011-11-07 -:Version: 1.1 -:Manual section: 1 - - SYNOPSIS ======== @@ -115,7 +107,9 @@ HISTORY The varnishstat utility was originally developed by Poul-Henning Kamp in cooperation with Verdens Gang AS and Varnish -Software AS. Manual page written by Dag-Erling Sm?rgrav and Per Buer. +Software AS. Manual page written by Dag-Erling Sm?rgrav, Per Buer +and Lasse Karstensen. + COPYRIGHT ========= diff --git a/doc/sphinx/reference/varnishtest.rst b/doc/sphinx/reference/varnishtest.rst index 52c642b..03f47da 100644 --- a/doc/sphinx/reference/varnishtest.rst +++ b/doc/sphinx/reference/varnishtest.rst @@ -6,13 +6,6 @@ varnishtest Test program for Varnish ------------------------ -:Author: Stig Sandbeck Mathisen -:Author: Kristian Lyngst?l -:Date: 2011-11-15 -:Version: 1.1 -:Manual section: 1 - - SYNOPSIS ======== diff --git a/doc/sphinx/reference/varnishtop.rst b/doc/sphinx/reference/varnishtop.rst index 7ebc384..4692143 100644 --- a/doc/sphinx/reference/varnishtop.rst +++ b/doc/sphinx/reference/varnishtop.rst @@ -6,13 +6,6 @@ varnishtop Varnish log entry ranking ------------------------- -:Author: Dag-Erling Sm?rgrav -:Author: Martin Blix Grydeland -:Date: 2010-05-31 -:Version: 1.0 -:Manual section: 1 - - SYNOPSIS ======== @@ -62,7 +55,9 @@ HISTORY The varnishtop utility was originally developed by Poul-Henning Kamp in cooperation with Verdens Gang AS and Varnish Software AS, and later substantially rewritten by Dag-Erling Sm?rgrav. This manual page was -written by Dag-Erling Sm?rgrav. +written by Dag-Erling Sm?rgrav, and later updated by Martin Blix +Grydeland. + COPYRIGHT ========= diff --git a/doc/sphinx/reference/vcl.rst b/doc/sphinx/reference/vcl.rst index 9f384f8..436d58d 100644 --- a/doc/sphinx/reference/vcl.rst +++ b/doc/sphinx/reference/vcl.rst @@ -8,14 +8,6 @@ VCL Varnish Configuration Language ------------------------------ -:Author: Dag-Erling Sm?rgrav -:Author: Poul-Henning Kamp -:Author: Kristian Lyngst?l -:Author: Per Buer -:Date: 2010-06-02 -:Version: 1.0 -:Manual section: 7 - DESCRIPTION =========== @@ -995,8 +987,9 @@ HISTORY VCL was developed by Poul-Henning Kamp in cooperation with Verdens Gang AS, Redpill Linpro and Varnish Software. This manual page was -written by Dag-Erling Sm?rgrav and later edited by Poul-Henning Kamp -and Per Buer. +written by Dag-Erling Sm?rgrav and later edited by Poul-Henning Kamp, +Kristian Lyngst?l and Per Buer. + COPYRIGHT ========= diff --git a/doc/sphinx/reference/vmod_std.rst b/doc/sphinx/reference/vmod_std.rst index 41c38e6..b8f2aa3 100644 --- a/doc/sphinx/reference/vmod_std.rst +++ b/doc/sphinx/reference/vmod_std.rst @@ -6,12 +6,6 @@ vmod_std Varnish Standard Module ----------------------- -:Author: Per Buer -:Date: 2011-05-19 -:Version: 1.0 -:Manual section: 3 - - SYNOPSIS ======== From lkarsten at varnish-software.com Tue Feb 25 13:09:41 2014 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Tue, 25 Feb 2014 14:09:41 +0100 Subject: [master] 0f66e81 Reformatting tab/space and width. Message-ID: commit 0f66e81e5e858e5b43aa8f1e1008661cf571df40 Author: Lasse Karstensen Date: Tue Feb 25 14:08:39 2014 +0100 Reformatting tab/space and width. Also removed one last meta-header forgotten on the last commit. diff --git a/doc/sphinx/reference/varnishadm.rst b/doc/sphinx/reference/varnishadm.rst index 54e42ec..5bb9f6e 100644 --- a/doc/sphinx/reference/varnishadm.rst +++ b/doc/sphinx/reference/varnishadm.rst @@ -29,22 +29,23 @@ OPTIONS ======= -t timeout - Wait no longer than this many seconds for an operation to finish. + Wait no longer than this many seconds for an operation to finish. -S secret_file - Specify the authentication secret file. This should be the same -S - argument as was given to varnishd. Only processes which can read - the contents of this file, will be able to authenticate the CLI connection. - --T address:port - Connect to the management interface at the specified address and port. + Specify the authentication secret file. This should be the same -S + argument as was given to varnishd. Only processes which can read + the contents of this file, will be able to authenticate the CLI connection. -n name - Connect to the instance of varnishd with this name. + Connect to the instance of varnishd with this name. + +-T address:port + Connect to the management interface at the specified address and port. + The syntax and operation of the actual CLI interface is described in the varnish-cli(7) manual page. Parameteres are described in -varnishd(1) manual page. +varnishd(1) manual page. Additionally, a summary of commands can be obtained by issuing the *help* command, and a summary of parameters can be obtained by issuing @@ -61,9 +62,9 @@ EXAMPLES Some ways you can use varnishadm:: - varnishadm -T localhost:999 -S /var/db/secret vcl.use foo - echo vcl.use foo | varnishadm -T localhost:999 -S /var/db/secret - echo vcl.use foo | ssh vhost varnishadm -T localhost:999 -S /var/db/secret + varnishadm -T localhost:999 -S /var/db/secret vcl.use foo + echo vcl.use foo | varnishadm -T localhost:999 -S /var/db/secret + echo vcl.use foo | ssh vhost varnishadm -T localhost:999 -S /var/db/secret SEE ALSO ======== @@ -74,7 +75,7 @@ HISTORY ======= The varnishadm utility and this manual page were written by Cecilie -Fritzvold. Converted to reStructured and updated in 2010 by Per +Fritzvold. Converted to reStructuredText and updated in 2010 by Per Buer. COPYRIGHT diff --git a/doc/sphinx/reference/varnishd.rst b/doc/sphinx/reference/varnishd.rst index 0f7d7fa..a93ecac 100644 --- a/doc/sphinx/reference/varnishd.rst +++ b/doc/sphinx/reference/varnishd.rst @@ -30,7 +30,7 @@ OPTIONS ======= -a address[:port][,address[:port][...] - Listen for client requests on the specified address and port. The address can be a host + Listen for client requests on the specified address and port. The address can be a host name (?localhost?), an IPv4 dotted-quad (?127.0.0.1?), or an IPv6 address enclosed in square brackets (?[::1]?). If address is not specified, varnishd will listen on all available IPv4 and IPv6 interfaces. If port is not specified, the default HTTP port as @@ -39,10 +39,10 @@ OPTIONS -b host[:port] Use the specified host as backend server. If port is not specified, - the default is 8080. + the default is 8080. --C Print VCL code compiled to C language and exit. Specify the VCL file - to compile with the -f option. +-C Print VCL code compiled to C language and exit. Specify the VCL file + to compile with the -f option. -d Enables debugging mode: The parent process runs in the foreground with a CLI connection on stdin/stdout, and the child process must be started explicitly with a CLI command. @@ -78,9 +78,9 @@ OPTIONS -P file Write the process's PID to the specified file. -p param=value - Set the parameter specified by param to the specified value. See Run-Time - Parameters for a list of parameters. This option can be used multiple - times to specify multiple parameters. + Set the parameter specified by param to the specified value. See + Run-Time Parameters for a list of parameters. This option can be + used multiple times to specify multiple parameters. -S file Path to a file containing a secret used for authorizing access to the management port. @@ -100,15 +100,13 @@ OPTIONS Interface for a list of management commands. -M address:port - Connect to this port and offer the command line - interface. Think of it as a reverse shell. When running with - -M and there is no backend defined the child process (the cache) - will not start initially. + Connect to this port and offer the command line interface. + Think of it as a reverse shell. When running with -M and there is + no backend defined the child process (the cache) will not start + initially. --t ttl - Specifies a hard minimum time to live for cached - documents. This is a shortcut for specifying the - default_ttl run-time parameter. +-t ttl Specifies a hard minimum time to live for cached documents. This + is a shortcut for specifying the default_ttl run-time parameter. -r param[,param...] Make the listed parameters read only. This gives the @@ -120,8 +118,8 @@ OPTIONS -u user Specifies the name of an unprivileged user to which the child process should switch before it starts accepting - connections. This is a shortcut for specifying the user - run- time parameter. + connections. This is a shortcut for specifying the user + runtime parameter. If specifying both a user and a group, the user should be specified first. @@ -135,19 +133,19 @@ Hash Algorithms The following hash algorithms are available: simple_list - A simple doubly-linked list. Not recommended for production use. + A simple doubly-linked list. Not recommended for production use. classic[,buckets] - A standard hash table. This is the default. The hash key is the - CRC32 of the object's URL modulo the size of the hash table. Each - table entry points to a list of elements which share the same hash - key. The buckets parameter specifies the number of entries in the - hash table. The default is 16383. + A standard hash table. This is the default. The hash key is the + CRC32 of the object's URL modulo the size of the hash table. Each + table entry points to a list of elements which share the same hash + key. The buckets parameter specifies the number of entries in the + hash table. The default is 16383. critbit - A self-scaling tree structure. The default hash algorithm in 2.1. In - comparison to a more traditional B tree the critbit tree is almost - completely lockless. + A self-scaling tree structure. The default hash algorithm in 2.1. In + comparison to a more traditional B tree the critbit tree is almost + completely lockless. Storage Types ------------- @@ -243,7 +241,7 @@ The varnishd daemon was developed by Poul-Henning Kamp in cooperation with Verdens Gang AS, Varnish Software AS and Varnish Software. This manual page was written by Dag-Erling Sm?rgrav with updates by -Stig Sandbeck Mathisen +Stig Sandbeck Mathisen . COPYRIGHT diff --git a/doc/sphinx/reference/varnishsizes.rst b/doc/sphinx/reference/varnishsizes.rst index 91c37a9..af2e05b 100644 --- a/doc/sphinx/reference/varnishsizes.rst +++ b/doc/sphinx/reference/varnishsizes.rst @@ -76,6 +76,7 @@ The varnishsizes utility was developed by Kristian Lyngst?l based on varnishhist. This manual page was written by Kristian Lyngst?l, Dag-Erling Sm?rgrav and Per Buer. + COPYRIGHT ========= diff --git a/doc/sphinx/reference/varnishtest.rst b/doc/sphinx/reference/varnishtest.rst index 03f47da..a3a0eec 100644 --- a/doc/sphinx/reference/varnishtest.rst +++ b/doc/sphinx/reference/varnishtest.rst @@ -126,6 +126,7 @@ This manual page was originally written by Stig Sandbeck Mathisen and updated by Kristian Lyngst?l . + COPYRIGHT ========= diff --git a/doc/sphinx/reference/vsl-query.rst b/doc/sphinx/reference/vsl-query.rst index 9547a59..f188113 100644 --- a/doc/sphinx/reference/vsl-query.rst +++ b/doc/sphinx/reference/vsl-query.rst @@ -4,11 +4,6 @@ Varnish VSL Query Expressions ============================= -:Author: Martin Blix Grydeland -:Date: 2013-09-26 -:Version: 0.1 -:Manual section: 7 - OVERVIEW ======== @@ -238,3 +233,9 @@ QUERY EXPRESSION EXAMPLES their ESI subrequests. (Assumes request grouping mode). :: BerespStatus >= 500 or {2+}ReqEnd[5] > 1. + +HISTORY +======= + +This document was written by Martin Blix Grydeland. + diff --git a/doc/sphinx/reference/vsl.rst b/doc/sphinx/reference/vsl.rst index 7f79209..78c3456 100644 --- a/doc/sphinx/reference/vsl.rst +++ b/doc/sphinx/reference/vsl.rst @@ -8,12 +8,6 @@ VSL Shared Memory Logging --------------------- -:Author: Poul-Henning Kamp -:Author: Martin Blix Grydeland -:Date: 2013-10-16 -:Version: 1.0 -:Manual section: 7 - OVERVIEW ======== @@ -26,6 +20,14 @@ VSL tags .. include:: ../../../lib/libvarnishapi/vsl-tags.rst + +HISTORY +======= + +This document was initially written by Poul-Henning Kamp, and later updated by +Martin Blix Grydeland. + + SEE ALSO ======== * varnishlog(1) From martin at varnish-software.com Tue Feb 25 14:58:39 2014 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Tue, 25 Feb 2014 15:58:39 +0100 Subject: [master] c28824d Port varnishhist.c to the new api Message-ID: commit c28824d7a943beac75045681d6d2e2caac44291d Author: Guillaume Quintard Date: Tue Feb 4 10:07:37 2014 +0100 Port varnishhist.c to the new api diff --git a/bin/varnishhist/varnishhist.c b/bin/varnishhist/varnishhist.c index 03bfd88..bf61060 100644 --- a/bin/varnishhist/varnishhist.c +++ b/bin/varnishhist/varnishhist.c @@ -48,12 +48,16 @@ #include "vapi/vsl.h" #include "vapi/vsm.h" +#include "vapi/voptget.h" #include "vas.h" #include "vcs.h" +#include "vut.h" #define HIST_N 2000 /* how far back we remember */ #define HIST_RES 100 /* bucket resolution */ +static const char progname[] = "varnishhist"; + static int hist_low; static int hist_high; static int hist_range; @@ -61,15 +65,13 @@ static int hist_buckets; static pthread_mutex_t mtx = PTHREAD_MUTEX_INITIALIZER; +static int end_of_file = 0; static int delay = 1; static unsigned rr_hist[HIST_N]; static unsigned nhist; static unsigned next_hist; static unsigned *bucket_miss; static unsigned *bucket_hit; -static unsigned char hh[FD_SETSIZE]; -static uint64_t bitmap[FD_SETSIZE]; -static double values[FD_SETSIZE]; static char *format; static int match_tag; @@ -105,7 +107,9 @@ struct profile { int field; int hist_low; int hist_high; -} profiles[] = { +} + +profiles[] = { { .name = "responsetime", .tag = SLT_ReqEnd, @@ -126,7 +130,7 @@ struct profile { static struct profile *active_profile; static void -update(struct VSM_data *vd) +update(void) { int w = COLS / hist_range; int n = w * hist_range; @@ -146,7 +150,10 @@ update(struct VSM_data *vd) mvprintw(LINES - 1, w * i, "|1e%d", j); } - mvprintw(0, 0, "%*s", COLS - 1, VSM_Name(vd)); + if (end_of_file) + mvprintw(0, 0, "%*s", COLS - 1, "EOF"); + else + mvprintw(0, 0, "%*s", COLS - 1, VUT.name); /* count our flock */ for (i = 0; i < n; ++i) @@ -177,113 +184,77 @@ update(struct VSM_data *vd) refresh(); } -static int -h_hist(void *priv, enum VSL_tag_e tag, unsigned fd, unsigned len, - unsigned spec, const char *ptr, uint64_t bm) +static int /*__match_proto__ (VSLQ_dispatch_f)*/ +accumulate(struct VSL_data *vsl, struct VSL_transaction * const pt[], + void *priv) { int i, j; - struct VSM_data *vd = priv; - (void)spec; - - if (fd >= FD_SETSIZE) - /* oops */ - return (0); - - bitmap[fd] |= bm; + unsigned tag, hit; + double value; + struct VSL_transaction *tr; + for (tr = pt[0]; tr != NULL; tr = *++pt) { + value = -1; + hit = 0; + while ((1 == VSL_Next(tr->c))) { + if (!VSL_Match(vsl, tr->c)) + continue; + /* get the value we want, and register if it's a hit*/ + tag = VSL_TAG(tr->c->rec.ptr); + if (tag == match_tag) { + i = sscanf(VSL_CDATA(tr->c->rec.ptr), format, &value); + assert(i == 1); + } else if (tag == SLT_Hit) + hit = 1; + + /* select bucket */ + i = HIST_RES * (log(value) / log_ten); + if (i < hist_low * HIST_RES) + i = hist_low * HIST_RES; + if (i >= hist_high * HIST_RES) + i = hist_high * HIST_RES - 1; + i -= hist_low * HIST_RES; + assert(i >= 0); + assert(i < hist_buckets); + pthread_mutex_lock(&mtx); + + /* phase out old data */ + if (nhist == HIST_N) { + j = rr_hist[next_hist]; + if (j < 0) { + assert(bucket_miss[-j] > 0); + bucket_miss[-j]--; + } else { + assert(bucket_hit[j] > 0); + bucket_hit[j]--; + } + } else { + ++nhist; + } - if (tag == SLT_Hit) { - hh[fd] = 1; - return (0); - } - if (tag == match_tag) { - char buf[1024]; /* size? */ - assert(len < sizeof(buf)); - memcpy(buf, ptr, len); - buf[len] = '\0'; - i = sscanf(buf, format, &values[fd]); - assert(i == 1); - } + /* phase in new data */ + if (hit) { + bucket_hit[i]++; + rr_hist[next_hist] = i; + } else { + bucket_miss[i]++; + rr_hist[next_hist] = -i; + } + if (++next_hist == HIST_N) { + next_hist = 0; + } + pthread_mutex_unlock(&mtx); - if (tag != SLT_ReqEnd) - return (0); - if (!VSL_Matched(vd, bitmap[fd])) { - bitmap[fd] = 0; - hh[fd] = 0; - return (0); - } - - /* select bucket */ - i = HIST_RES * (log(values[fd]) / log_ten); - if (i < hist_low * HIST_RES) - i = hist_low * HIST_RES; - if (i >= hist_high * HIST_RES) - i = hist_high * HIST_RES - 1; - i -= hist_low * HIST_RES; - assert(i >= 0); - assert(i < hist_buckets); - pthread_mutex_lock(&mtx); - - /* phase out old data */ - if (nhist == HIST_N) { - j = rr_hist[next_hist]; - if (j < 0) { - assert(bucket_miss[-j] > 0); - bucket_miss[-j]--; - } else { - assert(bucket_hit[j] > 0); - bucket_hit[j]--; } - } else { - ++nhist; - } - - /* phase in new data */ - if (hh[fd] || i == 0) { - bucket_hit[i]++; - rr_hist[next_hist] = i; - } else { - bucket_miss[i]++; - rr_hist[next_hist] = -i; } - if (++next_hist == HIST_N) { - next_hist = 0; - } - hh[fd] = 0; - bitmap[fd] = 0; - - pthread_mutex_unlock(&mtx); - return (0); } static void * -accumulate_thread(void *arg) +do_curses(void *arg) { - struct VSM_data *vd = arg; - int i; - - for (;;) { - i = VSL_Dispatch(vd, h_hist, vd); - if (i < 0) - break; - if (i == 0) - usleep(50000); - } - return (arg); -} - -static void -do_curses(struct VSM_data *vd) -{ - pthread_t thr; int ch; - if (pthread_create(&thr, NULL, accumulate_thread, vd) != 0) { - fprintf(stderr, "pthread_create(): %s\n", strerror(errno)); - exit(1); - } - initscr(); raw(); noecho(); @@ -293,7 +264,7 @@ do_curses(struct VSM_data *vd) erase(); for (;;) { pthread_mutex_lock(&mtx); - update(vd); + update(); pthread_mutex_unlock(&mtx); timeout(delay * 1000); @@ -321,7 +292,7 @@ do_curses(struct VSM_data *vd) case 'Q': case 'q': endwin(); - return; + pthread_exit(NULL); case '0': case '1': case '2': @@ -339,34 +310,37 @@ do_curses(struct VSM_data *vd) break; } } + pthread_exit(NULL); } /*--------------------------------------------------------------------*/ static void -usage(void) +usage(int status) { fprintf(stderr, "usage: varnishhist " "%s [-p profile] [-f field_num] " - "[-R max] [-r min] [-V] [-w delay]\n", VSL_USAGE); - exit(1); + "[-R max] [-r min] [-V] [-w delay]\n", "varnishhist"); + exit(status); } int main(int argc, char **argv) { - int o, i; - struct VSM_data *vd; + int i; const char *profile = "responsetime"; + pthread_t thr; int fnum = -1; hist_low = -1; hist_high = -1; match_tag = -1; - vd = VSM_New(); + VUT_Init(progname); + if (0) + (void)usage; - while ((o = getopt(argc, argv, VSL_ARGS "Vw:r:R:f:p:")) != -1) { - switch (o) { + while ((i = getopt(argc, argv, vopt_optstring)) != -1) { + switch (i) { case 'V': VCS_Message("varnishhist"); exit(0); @@ -393,9 +367,8 @@ main(int argc, char **argv) profile = optarg; break; default: - if (VSL_Arg(vd, o, optarg) > 0) - break; - usage(); + if (!VUT_Arg(i, optarg)) + usage(1); } } if (profile) { @@ -437,13 +410,19 @@ main(int argc, char **argv) } strcpy(format + 4*(fnum-1), "%lf"); - if (VSM_Open(vd)) { - fprintf(stderr, "%s\n", VSM_Error(vd)); - exit(1); - } - log_ten = log(10.0); - do_curses(vd); + VUT_Setup(); + if (pthread_create(&thr, NULL, do_curses, NULL) != 0) { + fprintf(stderr, "pthread_create(): %s\n", + strerror(errno)); + exit(1); + } + VUT.dispatch_f = &accumulate; + VUT.dispatch_priv = NULL; + VUT_Main(); + end_of_file = 1; + pthread_join(thr, NULL); + VUT_Fini(); exit(0); } From martin at varnish-software.com Tue Feb 25 14:58:39 2014 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Tue, 25 Feb 2014 15:58:39 +0100 Subject: [master] f23c07c Update autotools to compile varnishhist Message-ID: commit f23c07c77537454e2cb59f480a14d5529b0dd777 Author: Guillaume Quintard Date: Tue Feb 4 10:08:20 2014 +0100 Update autotools to compile varnishhist diff --git a/bin/Makefile.am b/bin/Makefile.am index 48a9a51..a6defb4 100644 --- a/bin/Makefile.am +++ b/bin/Makefile.am @@ -6,7 +6,7 @@ SUBDIRS = varnishadm varnishd varnishlog varnishtest varnishncsa if VARNISH_CURSES -#SUBDIRS += varnishhist varnishstat varnishtop +SUBDIRS += varnishhist SUBDIRS += varnishstat SUBDIRS += varnishtop endif diff --git a/bin/varnishhist/Makefile.am b/bin/varnishhist/Makefile.am index 9511a6e..a24f29a 100644 --- a/bin/varnishhist/Makefile.am +++ b/bin/varnishhist/Makefile.am @@ -5,8 +5,14 @@ AM_CPPFLAGS = -I$(top_srcdir)/include bin_PROGRAMS = varnishhist varnishhist_SOURCES = varnishhist.c \ + varnishhist_options.h \ + varnishhist_options.c \ $(top_builddir)/lib/libvarnish/vas.c \ - $(top_builddir)/lib/libvarnish/version.c + $(top_builddir)/lib/libvarnish/version.c \ + $(top_srcdir)/lib/libvarnish/vpf.c \ + $(top_srcdir)/lib/libvarnish/vtim.c \ + $(top_srcdir)/lib/libvarnish/flopen.c \ + $(top_srcdir)/lib/libvarnishtools/vut.c varnishhist_LDADD = \ $(top_builddir)/lib/libvarnishcompat/libvarnishcompat.la \ diff --git a/configure.ac b/configure.ac index f25b2cf..5c46de8 100644 --- a/configure.ac +++ b/configure.ac @@ -566,6 +566,7 @@ AC_CONFIG_FILES([ bin/varnishlog/Makefile bin/varnishstat/Makefile bin/varnishtop/Makefile + bin/varnishhist/Makefile bin/varnishtest/Makefile bin/varnishncsa/Makefile doc/Makefile From martin at varnish-software.com Tue Feb 25 14:58:39 2014 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Tue, 25 Feb 2014 15:58:39 +0100 Subject: [master] ce26d62 Handle the options like the other tools Message-ID: commit ce26d62cf3e695c5339e513d629f8fa694201c96 Author: Guillaume Quintard Date: Tue Feb 4 14:46:45 2014 +0100 Handle the options like the other tools diff --git a/bin/varnishhist/varnishhist.c b/bin/varnishhist/varnishhist.c index bf61060..626eba6 100644 --- a/bin/varnishhist/varnishhist.c +++ b/bin/varnishhist/varnishhist.c @@ -318,9 +318,12 @@ do_curses(void *arg) static void usage(int status) { - fprintf(stderr, "usage: varnishhist " - "%s [-p profile] [-f field_num] " - "[-R max] [-r min] [-V] [-w delay]\n", "varnishhist"); + const char **opt; + + fprintf(stderr, "Usage: %s \n\n", progname); + fprintf(stderr, "Options:\n"); + for (opt = vopt_usage; *opt != NULL; opt +=2) + fprintf(stderr, " %-25s %s\n", *opt, *(opt + 1)); exit(status); } @@ -328,12 +331,12 @@ int main(int argc, char **argv) { int i; + char *colon; const char *profile = "responsetime"; pthread_t thr; int fnum = -1; - hist_low = -1; - hist_high = -1; - match_tag = -1; + struct profile cli_p; + cli_p.name = 0; VUT_Init(progname); if (0) @@ -341,30 +344,30 @@ main(int argc, char **argv) while ((i = getopt(argc, argv, vopt_optstring)) != -1) { switch (i) { - case 'V': - VCS_Message("varnishhist"); - exit(0); - case 'i': - match_tag = VSL_Name2Tag(optarg, -1); + case 'P': + colon = strchr(optarg, ':'); + /* no colon, take the profile as a name*/ + if (colon == NULL) { + profile = optarg; + break; + } + /* else it's a definition, we hope */ + if (sscanf(colon+1, "%d:%d:%d", + &cli_p.field, &cli_p.hist_low, &cli_p.hist_high) != 3) { + fprintf(stderr, "%s is neither a profile name nor definition (SLT_Tag:field:min:max)\n", optarg); + exit(1); + } + + match_tag = VSL_Name2Tag(optarg, colon - optarg); if (match_tag < 0) { - fprintf(stderr, "No such tag %s\n", optarg); + fprintf(stderr, "No such tag in %s\n", optarg); exit(1); } - break; - case 'w': - delay = atoi(optarg); - break; - case 'f': - fnum = atoi(optarg); - break; - case 'R': - hist_high = atoi(optarg); - break; - case 'r': - hist_low = atoi(optarg); - break; - case 'p': - profile = optarg; + cli_p.name = "custom"; + cli_p.tag = match_tag; + profile = NULL; + active_profile = &cli_p; + break; default: if (!VUT_Arg(i, optarg)) @@ -383,21 +386,10 @@ main(int argc, char **argv) fprintf(stderr, "No such profile %s\n", profile); exit(1); } - if (match_tag < 0) { - match_tag = active_profile->tag; - } - - if (fnum < 0) { - fnum = active_profile->field; - } - - if (hist_low < 0) { - hist_low = active_profile->hist_low; - } - - if (hist_high < 0) { - hist_high = active_profile->hist_high; - } + match_tag = active_profile->tag; + fnum = active_profile->field; + hist_low = active_profile->hist_low; + hist_high = active_profile->hist_high; hist_range = hist_high - hist_low; hist_buckets = hist_range * HIST_RES; diff --git a/bin/varnishhist/varnishhist_options.c b/bin/varnishhist/varnishhist_options.c new file mode 100644 index 0000000..718fd3d --- /dev/null +++ b/bin/varnishhist/varnishhist_options.c @@ -0,0 +1,34 @@ +/*- + * Copyright (c) 2014 Varnish Software AS + * All rights reserved. + * + * Author: Martin Blix Grydeland + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * Option definitions for varnishtop + */ + +#include +#define VOPT_DEFINITION +#define VOPT_INC "varnishhist_options.h" +#include "vapi/voptget.h" diff --git a/bin/varnishhist/varnishhist_options.h b/bin/varnishhist/varnishhist_options.h new file mode 100644 index 0000000..e362d32 --- /dev/null +++ b/bin/varnishhist/varnishhist_options.h @@ -0,0 +1,68 @@ +/*- + * Copyright (c) 2014 Varnish Software AS + * All rights reserved. + * + * Author: Martin Blix Grydeland + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * Option definitions for varnishtop + */ + +#include "vapi/vapi_options.h" +#include "vut_options.h" + +#define HIS_OPT_p \ + VOPT("p:", "[-p period]", "Refresh period", \ + "Specified the number of seconds between screen refreshes" \ + " default is 1 second, and can be changed during the run" \ + " by pressing the [1-9] keys" \ + ) + +#define HIS_OPT_P \ + VOPT("P:", "[-P ]", "Profile definition", \ + "Either specify \"size\" or \"responstime\" profile or create a new one" \ + " Define the tag we'll look for, and the field number of the value" \ + " we are interested in. min and max are the boundaries of the graph" \ + " (these are power of tens)" \ + ) + +VSL_OPT_b +VSL_OPT_c +VSL_OPT_C +VUT_OPT_d +VUT_OPT_D +VUT_OPT_g +VUT_OPT_h +VSL_OPT_i +VSL_OPT_I +VSL_OPT_L +VUT_OPT_n +VUT_OPT_N +HIS_OPT_p +HIS_OPT_P +VUT_OPT_q +VUT_OPT_r +VSL_OPT_T +VSL_OPT_x +VSL_OPT_X +VUT_OPT_V From martin at varnish-software.com Tue Feb 25 14:58:39 2014 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Tue, 25 Feb 2014 15:58:39 +0100 Subject: [master] ff35db6 Fix white spaces Message-ID: commit ff35db66d5a3ef78bcef7ffe73a9951a4605bb70 Author: Guillaume Quintard Date: Tue Feb 4 15:02:02 2014 +0100 Fix white spaces diff --git a/bin/varnishhist/varnishhist.c b/bin/varnishhist/varnishhist.c index 626eba6..1705518 100644 --- a/bin/varnishhist/varnishhist.c +++ b/bin/varnishhist/varnishhist.c @@ -220,7 +220,7 @@ accumulate(struct VSL_data *vsl, struct VSL_transaction * const pt[], /* phase out old data */ if (nhist == HIST_N) { j = rr_hist[next_hist]; - if (j < 0) { + if (j < 0) { assert(bucket_miss[-j] > 0); bucket_miss[-j]--; } else { @@ -376,7 +376,7 @@ main(int argc, char **argv) } if (profile) { for (active_profile = profiles; active_profile->name; - active_profile++) { + active_profile++) { if (strcmp(active_profile->name, profile) == 0) { break; } From martin at varnish-software.com Tue Feb 25 14:58:39 2014 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Tue, 25 Feb 2014 15:58:39 +0100 Subject: [master] 1346cd8 Build varnishhist documentation Message-ID: commit 1346cd8b6f5aaf9bb5b47c16b301267c53e261bf Author: Guillaume Quintard Date: Tue Feb 4 15:02:32 2014 +0100 Build varnishhist documentation diff --git a/bin/varnishhist/Makefile.am b/bin/varnishhist/Makefile.am index a24f29a..986966f 100644 --- a/bin/varnishhist/Makefile.am +++ b/bin/varnishhist/Makefile.am @@ -19,3 +19,35 @@ varnishhist_LDADD = \ $(top_builddir)/lib/libvarnishapi/libvarnishapi.la \ -lm \ @CURSES_LIB@ ${RT_LIBS} ${PTHREAD_LIBS} + +noinst_PROGRAMS = varnishhist_opt2rst +varnishhist_opt2rst_SOURCES = \ + varnishhist_options.h \ + varnishhist_options.c \ + $(top_srcdir)/lib/libvarnishtools/opt2rst.c + +BUILT_SOURCES = varnishhist_options.rst varnishhist_synopsis.rst +EXTRA_DIST = $(BUILT_SOURCES) +MAINTAINERCLEANFILES = $(EXTRA_DIST) + +varnishhist_options.rst: + ./varnishhist_opt2rst options > $@ +varnishhist_synopsis.rst: + ./varnishhist_opt2rst synopsis > $@ + +if HAVE_RST2MAN +varnishhist_options.rst varnishhist_synopsis.rst: varnishhist_opt2rst +endif + +varnishhist.1: \ + $(top_srcdir)/doc/sphinx/reference/varnishhist.rst \ + varnishhist_options.rst \ + varnishhist_synopsis.rst +if HAVE_RST2MAN + ${RST2MAN} $(top_srcdir)/doc/sphinx/reference/varnishhist.rst $@ +else + @echo "========================================" + @echo "You need rst2man installed to make dist" + @echo "========================================" + @false +endif diff --git a/bin/varnishhist/varnishhist_options.h b/bin/varnishhist/varnishhist_options.h index e362d32..2b71835 100644 --- a/bin/varnishhist/varnishhist_options.h +++ b/bin/varnishhist/varnishhist_options.h @@ -40,7 +40,7 @@ #define HIS_OPT_P \ VOPT("P:", "[-P ]", "Profile definition", \ - "Either specify \"size\" or \"responstime\" profile or create a new one" \ + "Either specify \"size\" or \"responstime\" profile or create a new one." \ " Define the tag we'll look for, and the field number of the value" \ " we are interested in. min and max are the boundaries of the graph" \ " (these are power of tens)" \ diff --git a/doc/sphinx/reference/varnishhist.rst b/doc/sphinx/reference/varnishhist.rst index f513294..901c7f4 100644 --- a/doc/sphinx/reference/varnishhist.rst +++ b/doc/sphinx/reference/varnishhist.rst @@ -9,8 +9,8 @@ Varnish request histogram SYNOPSIS ======== -varnishhist [-b] [-C] [-c] [-d] [-I regex] [-i tag] [-m tag:regex ...] -[-n varnish_name] [-r file] [-V] [-w delay] [-X regex] [-x tag] +.. include:: ../../../bin/varnishhist/varnishhist_synopsis.rst +varnishhist |synopsis| DESCRIPTION =========== @@ -24,44 +24,7 @@ and misses are marked with a hash character ("#"). The following options are available: --b Include log entries which result from communication with - a backend server. If neither -b nor -c is - specified, varnishhist acts as if they both were. - --C Ignore case when matching regular expressions. - --c Include log entries which result from communication with - a client. If neither -b nor -c is specified, - varnishhist acts as if they both were. - --d Process old log entries on startup. Normally, varnishhist - will only process entries which are written to the - log after it starts. - --I regex Include log entries which match the specified - regular expression. If neither -I nor -i is specified, - all log entries are included. - --i tag Include log entries with the specified tag. If neither - -I nor -i is specified, all log entries are included. - --m tag:regex only count transactions where tag matches regex. Multiple - -m options are AND-ed together. - --n Specifies the name of the varnishd instance to get logs - from. If -n is not specified, the host name is used. - --r file Read log entries from file instead of shared memory. - --V Display the version number and exit. - --w delay Wait at least delay seconds between each update. The - default is 1. file instead of displaying them. The file - will be overwritten unless the -a option was specified. - --X regex Exclude log entries which match the specified regular expression. - --x tag Exclude log entries with the specified tag. +.. include:: ../../../bin/varnishhist/varnishhist_options.rst SEE ALSO ======== From martin at varnish-software.com Tue Feb 25 14:58:39 2014 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Tue, 25 Feb 2014 15:58:39 +0100 Subject: [master] 01e6b2e Silence sign-compare warnings Message-ID: commit 01e6b2e348b35ce4fe06929ca99f1c0c931d06ea Author: Guillaume Quintard Date: Tue Feb 4 15:56:41 2014 +0100 Silence sign-compare warnings diff --git a/bin/varnishhist/varnishhist.c b/bin/varnishhist/varnishhist.c index c838fef..3845db3 100644 --- a/bin/varnishhist/varnishhist.c +++ b/bin/varnishhist/varnishhist.c @@ -132,11 +132,12 @@ static struct profile *active_profile; static void update(void) { - int w = COLS / hist_range; - int n = w * hist_range; + unsigned w = COLS / hist_range; + unsigned n = w * hist_range; unsigned bm[n], bh[n]; unsigned max; - int i, j, scale; + unsigned i, j, scale; + int k, l; erase(); @@ -145,9 +146,9 @@ update(void) n = w * hist_range; for (i = 0; i < n; ++i) (void)mvaddch(LINES - 2, i, '-'); - for (i = 0, j = hist_low; i < hist_range; ++i, ++j) { - (void)mvaddch(LINES - 2, w * i, '+'); - mvprintw(LINES - 1, w * i, "|1e%d", j); + for (k = 0, l = hist_low; k < hist_range; ++k, ++l) { + (void)mvaddch(LINES - 2, w * k, '+'); + mvprintw(LINES - 1, w * k, "|1e%d", l); } if (end_of_file) @@ -158,16 +159,17 @@ update(void) /* count our flock */ for (i = 0; i < n; ++i) bm[i] = bh[i] = 0; - for (i = 0, max = 1; i < hist_buckets; ++i) { - j = i * n / hist_buckets; - bm[j] += bucket_miss[i]; - bh[j] += bucket_hit[i]; - if (bm[j] + bh[j] > max) - max = bm[j] + bh[j]; + for (k = 0, max = 1; k < hist_buckets; ++k) { + l = k * n / hist_buckets; + bm[l] += bucket_miss[k]; + bh[l] += bucket_hit[k]; + if (bm[l] + bh[l] > max) + max = bm[l] + bh[l]; } /* scale */ - for (i = 0; max / scales[i] > LINES - 3; ++i) + assert(LINES - 3 >= 0); + for (i = 0; max / scales[i] > (unsigned)(LINES - 3); ++i) /* nothing */ ; scale = scales[i]; @@ -201,7 +203,8 @@ accumulate(struct VSL_data *vsl, struct VSL_transaction * const pt[], continue; /* get the value we want, and register if it's a hit*/ tag = VSL_TAG(tr->c->rec.ptr); - if (tag == match_tag) { + assert(match_tag >= 0); + if (tag == (unsigned)match_tag) { i = sscanf(VSL_CDATA(tr->c->rec.ptr), format, &value); assert(i == 1); } else if (tag == SLT_Hit) From martin at varnish-software.com Tue Feb 25 14:58:39 2014 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Tue, 25 Feb 2014 15:58:39 +0100 Subject: [master] cce5ff4 Silence unused-parameter warnings Message-ID: commit cce5ff42b190e541d095dae9ef3e74ae117d0ab3 Author: Guillaume Quintard Date: Tue Feb 4 15:41:09 2014 +0100 Silence unused-parameter warnings diff --git a/bin/varnishhist/varnishhist.c b/bin/varnishhist/varnishhist.c index 1705518..c838fef 100644 --- a/bin/varnishhist/varnishhist.c +++ b/bin/varnishhist/varnishhist.c @@ -192,6 +192,7 @@ accumulate(struct VSL_data *vsl, struct VSL_transaction * const pt[], unsigned tag, hit; double value; struct VSL_transaction *tr; + (void)priv; for (tr = pt[0]; tr != NULL; tr = *++pt) { value = -1; hit = 0; @@ -254,6 +255,7 @@ static void * do_curses(void *arg) { int ch; + (void)arg; initscr(); raw(); From martin at varnish-software.com Tue Feb 25 14:58:39 2014 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Tue, 25 Feb 2014 15:58:39 +0100 Subject: [master] 238d27c Only commit once, at the end of transaction Message-ID: commit 238d27c571c744f4f7a2c832c04d757d34f57a4f Author: Guillaume Quintard Date: Thu Feb 6 17:03:35 2014 +0100 Only commit once, at the end of transaction diff --git a/bin/varnishhist/varnishhist.c b/bin/varnishhist/varnishhist.c index 3845db3..92aa3f4 100644 --- a/bin/varnishhist/varnishhist.c +++ b/bin/varnishhist/varnishhist.c @@ -209,6 +209,8 @@ accumulate(struct VSL_data *vsl, struct VSL_transaction * const pt[], assert(i == 1); } else if (tag == SLT_Hit) hit = 1; + if (tag != SLT_ReqEnd && value == -1) + continue; /* select bucket */ i = HIST_RES * (log(value) / log_ten); From martin at varnish-software.com Tue Feb 25 14:58:39 2014 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Tue, 25 Feb 2014 15:58:39 +0100 Subject: [master] b230de2 Limit the grouping method Message-ID: commit b230de211b544485ce987b091106c29439e14901 Author: Guillaume Quintard Date: Thu Feb 6 18:19:12 2014 +0100 Limit the grouping method diff --git a/bin/varnishhist/varnishhist.c b/bin/varnishhist/varnishhist.c index 92aa3f4..ec30da5 100644 --- a/bin/varnishhist/varnishhist.c +++ b/bin/varnishhist/varnishhist.c @@ -381,6 +381,12 @@ main(int argc, char **argv) usage(1); } } + /* Check for valid grouping mode */ + assert(VUT.g_arg < VSL_g__MAX); + if (VUT.g_arg != VSL_g_vxid && VUT.g_arg != VSL_g_request) + VUT_Error(1, "Invalid grouping mode: %s (only vxid and request are supported)", + VSLQ_grouping[VUT.g_arg]); + if (profile) { for (active_profile = profiles; active_profile->name; active_profile++) { From martin at varnish-software.com Tue Feb 25 14:58:39 2014 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Tue, 25 Feb 2014 15:58:39 +0100 Subject: [master] e6645af Remove -i, -I, -x, -X options invarnishhist Message-ID: commit e6645af6b642107a671120eb29376e165f5ce0c2 Author: Guillaume Quintard Date: Thu Feb 6 17:17:22 2014 +0100 Remove -i, -I, -x, -X options invarnishhist diff --git a/bin/varnishhist/varnishhist_options.h b/bin/varnishhist/varnishhist_options.h index 2b71835..65301e5 100644 --- a/bin/varnishhist/varnishhist_options.h +++ b/bin/varnishhist/varnishhist_options.h @@ -53,8 +53,6 @@ VUT_OPT_d VUT_OPT_D VUT_OPT_g VUT_OPT_h -VSL_OPT_i -VSL_OPT_I VSL_OPT_L VUT_OPT_n VUT_OPT_N @@ -63,6 +61,4 @@ HIS_OPT_P VUT_OPT_q VUT_OPT_r VSL_OPT_T -VSL_OPT_x -VSL_OPT_X VUT_OPT_V From martin at varnish-software.com Tue Feb 25 14:58:40 2014 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Tue, 25 Feb 2014 15:58:40 +0100 Subject: [master] 476c8fd Remove useless call to VSL_Match Message-ID: commit 476c8fd7bac32486d85a1e395bea77647cd86b10 Author: Guillaume Quintard Date: Thu Feb 6 17:18:31 2014 +0100 Remove useless call to VSL_Match diff --git a/bin/varnishhist/varnishhist.c b/bin/varnishhist/varnishhist.c index ec30da5..0824b48 100644 --- a/bin/varnishhist/varnishhist.c +++ b/bin/varnishhist/varnishhist.c @@ -199,8 +199,6 @@ accumulate(struct VSL_data *vsl, struct VSL_transaction * const pt[], value = -1; hit = 0; while ((1 == VSL_Next(tr->c))) { - if (!VSL_Match(vsl, tr->c)) - continue; /* get the value we want, and register if it's a hit*/ tag = VSL_TAG(tr->c->rec.ptr); assert(match_tag >= 0); From martin at varnish-software.com Tue Feb 25 14:58:40 2014 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Tue, 25 Feb 2014 15:58:40 +0100 Subject: [master] b733d48 Force filtering to client requests Message-ID: commit b733d48c62be51ca81273b326aafa7fe1e76c262 Author: Guillaume Quintard Date: Thu Feb 6 17:22:06 2014 +0100 Force filtering to client requests diff --git a/bin/varnishhist/varnishhist.c b/bin/varnishhist/varnishhist.c index 0824b48..1fed60b 100644 --- a/bin/varnishhist/varnishhist.c +++ b/bin/varnishhist/varnishhist.c @@ -347,6 +347,8 @@ main(int argc, char **argv) if (0) (void)usage; + /* only client requests */ + assert(VUT_Arg('c', NULL)); while ((i = getopt(argc, argv, vopt_optstring)) != -1) { switch (i) { case 'P': diff --git a/bin/varnishhist/varnishhist_options.h b/bin/varnishhist/varnishhist_options.h index 65301e5..5e595a3 100644 --- a/bin/varnishhist/varnishhist_options.h +++ b/bin/varnishhist/varnishhist_options.h @@ -46,8 +46,6 @@ " (these are power of tens)" \ ) -VSL_OPT_b -VSL_OPT_c VSL_OPT_C VUT_OPT_d VUT_OPT_D From martin at varnish-software.com Tue Feb 25 14:58:40 2014 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Tue, 25 Feb 2014 15:58:40 +0100 Subject: [master] c37045f Keep only reqs and bereqs Message-ID: commit c37045f9a1d5740a6c4900a77b8f240bc982b8b2 Author: Guillaume Quintard Date: Thu Feb 6 17:37:21 2014 +0100 Keep only reqs and bereqs diff --git a/bin/varnishhist/varnishhist.c b/bin/varnishhist/varnishhist.c index 1fed60b..01fc66d 100644 --- a/bin/varnishhist/varnishhist.c +++ b/bin/varnishhist/varnishhist.c @@ -198,6 +198,8 @@ accumulate(struct VSL_data *vsl, struct VSL_transaction * const pt[], for (tr = pt[0]; tr != NULL; tr = *++pt) { value = -1; hit = 0; + if (tr->type != VSL_t_bereq && tr->type != VSL_t_req) + continue; while ((1 == VSL_Next(tr->c))) { /* get the value we want, and register if it's a hit*/ tag = VSL_TAG(tr->c->rec.ptr); From martin at varnish-software.com Tue Feb 25 14:58:40 2014 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Tue, 25 Feb 2014 15:58:40 +0100 Subject: [master] 28b62f1 Fix Ctrl-C handling in varnishhist Message-ID: commit 28b62f14c1c5a4767d13763995776aa3a0590cf5 Author: Guillaume Quintard Date: Thu Feb 6 17:40:09 2014 +0100 Fix Ctrl-C handling in varnishhist diff --git a/bin/varnishhist/varnishhist.c b/bin/varnishhist/varnishhist.c index 01fc66d..51c87ec 100644 --- a/bin/varnishhist/varnishhist.c +++ b/bin/varnishhist/varnishhist.c @@ -288,16 +288,15 @@ do_curses(void *arg) redrawwin(stdscr); refresh(); break; - case '\003': /* Ctrl-C */ - raise(SIGINT); - break; case '\032': /* Ctrl-Z */ endwin(); raise(SIGTSTP); break; + case '\003': /* Ctrl-C */ case '\021': /* Ctrl-Q */ case 'Q': case 'q': + raise(SIGINT); endwin(); pthread_exit(NULL); case '0': From martin at varnish-software.com Tue Feb 25 14:58:40 2014 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Tue, 25 Feb 2014 15:58:40 +0100 Subject: [master] a870df8 Add attribution Message-ID: commit a870df8d69e1bb95c2a8f733f7c6f4a3fd7f1e8b Author: Martin Blix Grydeland Date: Tue Feb 25 15:53:48 2014 +0100 Add attribution diff --git a/bin/varnishhist/varnishhist.c b/bin/varnishhist/varnishhist.c index 51c87ec..3bc1a3a 100644 --- a/bin/varnishhist/varnishhist.c +++ b/bin/varnishhist/varnishhist.c @@ -5,6 +5,7 @@ * * Author: Poul-Henning Kamp * Author: Dag-Erling Sm?rgrav + * Author: Guillaume Quintard * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions From martin at varnish-software.com Tue Feb 25 14:58:40 2014 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Tue, 25 Feb 2014 15:58:40 +0100 Subject: [master] a3c4079 Line break and whitespace fixes Message-ID: commit a3c40796003fc7cedf8e86c5684d76fd20d1a3c4 Author: Martin Blix Grydeland Date: Tue Feb 4 15:58:01 2014 +0100 Line break and whitespace fixes diff --git a/bin/varnishhist/varnishhist.c b/bin/varnishhist/varnishhist.c index 3bc1a3a..87558e1 100644 --- a/bin/varnishhist/varnishhist.c +++ b/bin/varnishhist/varnishhist.c @@ -108,8 +108,7 @@ struct profile { int field; int hist_low; int hist_high; -} - +} profiles[] = { { .name = "responsetime", @@ -206,7 +205,8 @@ accumulate(struct VSL_data *vsl, struct VSL_transaction * const pt[], tag = VSL_TAG(tr->c->rec.ptr); assert(match_tag >= 0); if (tag == (unsigned)match_tag) { - i = sscanf(VSL_CDATA(tr->c->rec.ptr), format, &value); + i = sscanf(VSL_CDATA(tr->c->rec.ptr), format, + &value); assert(i == 1); } else if (tag == SLT_Hit) hit = 1; @@ -361,9 +361,11 @@ main(int argc, char **argv) break; } /* else it's a definition, we hope */ - if (sscanf(colon+1, "%d:%d:%d", - &cli_p.field, &cli_p.hist_low, &cli_p.hist_high) != 3) { - fprintf(stderr, "%s is neither a profile name nor definition (SLT_Tag:field:min:max)\n", optarg); + if (sscanf(colon+1, "%d:%d:%d", &cli_p.field, + &cli_p.hist_low, &cli_p.hist_high) != 3) { + fprintf(stderr, "%s is neither a profile name" + "nor definition (SLT_Tag:field:min:max)\n", + optarg); exit(1); } From martin at varnish-software.com Tue Feb 25 14:58:40 2014 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Tue, 25 Feb 2014 15:58:40 +0100 Subject: [master] 9b9498c Silence unused argument warning Message-ID: commit 9b9498cc4bc933f43ab7aed3d0a7ff71bf622f07 Author: Martin Blix Grydeland Date: Tue Feb 25 11:50:44 2014 +0100 Silence unused argument warning diff --git a/bin/varnishhist/varnishhist.c b/bin/varnishhist/varnishhist.c index 87558e1..3cf128e 100644 --- a/bin/varnishhist/varnishhist.c +++ b/bin/varnishhist/varnishhist.c @@ -194,7 +194,10 @@ accumulate(struct VSL_data *vsl, struct VSL_transaction * const pt[], unsigned tag, hit; double value; struct VSL_transaction *tr; + + (void)vsl; (void)priv; + for (tr = pt[0]; tr != NULL; tr = *++pt) { value = -1; hit = 0; From martin at varnish-software.com Tue Feb 25 14:58:40 2014 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Tue, 25 Feb 2014 15:58:40 +0100 Subject: [master] b6eacbd Fix varnishhist Makefile Message-ID: commit b6eacbde019ec778b6cbb6bbba5921e844d1ea04 Author: Martin Blix Grydeland Date: Tue Feb 25 11:51:04 2014 +0100 Fix varnishhist Makefile diff --git a/bin/varnishhist/Makefile.am b/bin/varnishhist/Makefile.am index 986966f..748721b 100644 --- a/bin/varnishhist/Makefile.am +++ b/bin/varnishhist/Makefile.am @@ -7,8 +7,8 @@ bin_PROGRAMS = varnishhist varnishhist_SOURCES = varnishhist.c \ varnishhist_options.h \ varnishhist_options.c \ - $(top_builddir)/lib/libvarnish/vas.c \ - $(top_builddir)/lib/libvarnish/version.c \ + $(top_srcdir)/lib/libvarnish/vas.c \ + $(top_srcdir)/lib/libvarnish/version.c \ $(top_srcdir)/lib/libvarnish/vpf.c \ $(top_srcdir)/lib/libvarnish/vtim.c \ $(top_srcdir)/lib/libvarnish/flopen.c \ @@ -25,29 +25,3 @@ varnishhist_opt2rst_SOURCES = \ varnishhist_options.h \ varnishhist_options.c \ $(top_srcdir)/lib/libvarnishtools/opt2rst.c - -BUILT_SOURCES = varnishhist_options.rst varnishhist_synopsis.rst -EXTRA_DIST = $(BUILT_SOURCES) -MAINTAINERCLEANFILES = $(EXTRA_DIST) - -varnishhist_options.rst: - ./varnishhist_opt2rst options > $@ -varnishhist_synopsis.rst: - ./varnishhist_opt2rst synopsis > $@ - -if HAVE_RST2MAN -varnishhist_options.rst varnishhist_synopsis.rst: varnishhist_opt2rst -endif - -varnishhist.1: \ - $(top_srcdir)/doc/sphinx/reference/varnishhist.rst \ - varnishhist_options.rst \ - varnishhist_synopsis.rst -if HAVE_RST2MAN - ${RST2MAN} $(top_srcdir)/doc/sphinx/reference/varnishhist.rst $@ -else - @echo "========================================" - @echo "You need rst2man installed to make dist" - @echo "========================================" - @false -endif From martin at varnish-software.com Tue Feb 25 14:58:40 2014 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Tue, 25 Feb 2014 15:58:40 +0100 Subject: [master] 57b22d5 Fix line breaks Message-ID: commit 57b22d58377226ae257af57cf85595fe5310a057 Author: Martin Blix Grydeland Date: Tue Feb 4 16:47:59 2014 +0100 Fix line breaks diff --git a/bin/varnishhist/varnishhist_options.h b/bin/varnishhist/varnishhist_options.h index 5e595a3..6c9baa2 100644 --- a/bin/varnishhist/varnishhist_options.h +++ b/bin/varnishhist/varnishhist_options.h @@ -39,11 +39,13 @@ ) #define HIS_OPT_P \ - VOPT("P:", "[-P ]", "Profile definition", \ - "Either specify \"size\" or \"responstime\" profile or create a new one." \ - " Define the tag we'll look for, and the field number of the value" \ - " we are interested in. min and max are the boundaries of the graph" \ - " (these are power of tens)" \ + VOPT("P:", "[-P ]", \ + "Profile definition", \ + "Either specify \"size\" or \"responstime\" profile or" \ + " create a new one. Define the tag we'll look for, and the" \ + " field number of the value we are interested in. min and" \ + " max are the boundaries of the graph (these are power of" \ + " tens)." \ ) VSL_OPT_C From martin at varnish-software.com Tue Feb 25 14:58:40 2014 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Tue, 25 Feb 2014 15:58:40 +0100 Subject: [master] 5f13f64 Fix up -p documentation Message-ID: commit 5f13f64be13fa9f68ca059fc69746743307bb9a0 Author: Martin Blix Grydeland Date: Tue Feb 4 16:48:43 2014 +0100 Fix up -p documentation diff --git a/bin/varnishhist/varnishhist_options.h b/bin/varnishhist/varnishhist_options.h index 6c9baa2..db5a870 100644 --- a/bin/varnishhist/varnishhist_options.h +++ b/bin/varnishhist/varnishhist_options.h @@ -33,9 +33,9 @@ #define HIS_OPT_p \ VOPT("p:", "[-p period]", "Refresh period", \ - "Specified the number of seconds between screen refreshes" \ - " default is 1 second, and can be changed during the run" \ - " by pressing the [1-9] keys" \ + "Specified the number of seconds between screen refreshes." \ + " Default is 1 second, and can be changed at runtime by" \ + " pressing the [1-9] keys." \ ) #define HIS_OPT_P \ From martin at varnish-software.com Tue Feb 25 14:58:40 2014 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Tue, 25 Feb 2014 15:58:40 +0100 Subject: [master] 343418d Change varnishtop -> varnishhist Message-ID: commit 343418dade50e6aa7035005d10532a88b99c7c85 Author: Martin Blix Grydeland Date: Tue Feb 4 16:49:42 2014 +0100 Change varnishtop -> varnishhist diff --git a/bin/varnishhist/varnishhist_options.c b/bin/varnishhist/varnishhist_options.c index 718fd3d..c4f5d27 100644 --- a/bin/varnishhist/varnishhist_options.c +++ b/bin/varnishhist/varnishhist_options.c @@ -25,7 +25,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * Option definitions for varnishtop + * Option definitions for varnishhist */ #include diff --git a/bin/varnishhist/varnishhist_options.h b/bin/varnishhist/varnishhist_options.h index db5a870..11479dd 100644 --- a/bin/varnishhist/varnishhist_options.h +++ b/bin/varnishhist/varnishhist_options.h @@ -25,7 +25,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * Option definitions for varnishtop + * Option definitions for varnishhist */ #include "vapi/vapi_options.h" From martin at varnish-software.com Tue Feb 25 14:58:40 2014 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Tue, 25 Feb 2014 15:58:40 +0100 Subject: [master] 885e5f1 Update linebreaks and error string formatting Message-ID: commit 885e5f1fedca8bbce581325ab9c941db1e329992 Author: Martin Blix Grydeland Date: Tue Feb 25 13:03:16 2014 +0100 Update linebreaks and error string formatting diff --git a/bin/varnishhist/varnishhist.c b/bin/varnishhist/varnishhist.c index 3cf128e..4fc6866 100644 --- a/bin/varnishhist/varnishhist.c +++ b/bin/varnishhist/varnishhist.c @@ -366,15 +366,16 @@ main(int argc, char **argv) /* else it's a definition, we hope */ if (sscanf(colon+1, "%d:%d:%d", &cli_p.field, &cli_p.hist_low, &cli_p.hist_high) != 3) { - fprintf(stderr, "%s is neither a profile name" - "nor definition (SLT_Tag:field:min:max)\n", - optarg); + fprintf(stderr, "-P: '%s' is not a valid" + " profile name or definition\n", optarg); exit(1); } match_tag = VSL_Name2Tag(optarg, colon - optarg); if (match_tag < 0) { - fprintf(stderr, "No such tag in %s\n", optarg); + fprintf(stderr, + "-P: '%s' is not a valid tag name\n", + optarg); exit(1); } cli_p.name = "custom"; @@ -391,8 +392,9 @@ main(int argc, char **argv) /* Check for valid grouping mode */ assert(VUT.g_arg < VSL_g__MAX); if (VUT.g_arg != VSL_g_vxid && VUT.g_arg != VSL_g_request) - VUT_Error(1, "Invalid grouping mode: %s (only vxid and request are supported)", - VSLQ_grouping[VUT.g_arg]); + VUT_Error(1, "Invalid grouping mode: %s" + " (only vxid and request are supported)", + VSLQ_grouping[VUT.g_arg]); if (profile) { for (active_profile = profiles; active_profile->name; @@ -403,7 +405,7 @@ main(int argc, char **argv) } } if (! active_profile->name) { - fprintf(stderr, "No such profile %s\n", profile); + fprintf(stderr, "-P: No such profile '%s'\n", profile); exit(1); } match_tag = active_profile->tag; From martin at varnish-software.com Tue Feb 25 14:58:40 2014 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Tue, 25 Feb 2014 15:58:40 +0100 Subject: [master] 18266c8 Make field match failure ignore the record rather than assert Message-ID: commit 18266c8b46c0919e949e71df8897dbcf850b242a Author: Martin Blix Grydeland Date: Tue Feb 25 13:12:21 2014 +0100 Make field match failure ignore the record rather than assert diff --git a/bin/varnishhist/varnishhist.c b/bin/varnishhist/varnishhist.c index 4fc6866..1767db0 100644 --- a/bin/varnishhist/varnishhist.c +++ b/bin/varnishhist/varnishhist.c @@ -210,7 +210,8 @@ accumulate(struct VSL_data *vsl, struct VSL_transaction * const pt[], if (tag == (unsigned)match_tag) { i = sscanf(VSL_CDATA(tr->c->rec.ptr), format, &value); - assert(i == 1); + if (i != 1) + continue; } else if (tag == SLT_Hit) hit = 1; if (tag != SLT_ReqEnd && value == -1) From martin at varnish-software.com Tue Feb 25 14:58:40 2014 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Tue, 25 Feb 2014 15:58:40 +0100 Subject: [master] 3a1ba09 Only look at client requests in varnishhist. Message-ID: commit 3a1ba09193055cc43d3c9896edaec7939a7e37f5 Author: Martin Blix Grydeland Date: Tue Feb 25 14:05:19 2014 +0100 Only look at client requests in varnishhist. Without the -b -c options enabled, looking at backend requests becomes ill-defined. Disable anything but non-esi client requests for now. This can be extended in the future. diff --git a/bin/varnishhist/varnishhist.c b/bin/varnishhist/varnishhist.c index 1767db0..faec821 100644 --- a/bin/varnishhist/varnishhist.c +++ b/bin/varnishhist/varnishhist.c @@ -199,10 +199,14 @@ accumulate(struct VSL_data *vsl, struct VSL_transaction * const pt[], (void)priv; for (tr = pt[0]; tr != NULL; tr = *++pt) { + if (tr->type != VSL_t_req) + /* Only look at client requests */ + continue; + if (tr->reason == VSL_r_esi) + /* Skip ESI requests */ + continue; value = -1; hit = 0; - if (tr->type != VSL_t_bereq && tr->type != VSL_t_req) - continue; while ((1 == VSL_Next(tr->c))) { /* get the value we want, and register if it's a hit*/ tag = VSL_TAG(tr->c->rec.ptr); From martin at varnish-software.com Tue Feb 25 14:58:40 2014 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Tue, 25 Feb 2014 15:58:40 +0100 Subject: [master] d0dfe0a Rearrange the varnishhist loop Message-ID: commit d0dfe0ae50f74af49c8e0d5bcb41b0cc76973830 Author: Martin Blix Grydeland Date: Tue Feb 25 14:41:23 2014 +0100 Rearrange the varnishhist loop Rearrange the varnishhist loop so that we can skip restarts from being counted and make it more readable. diff --git a/bin/varnishhist/varnishhist.c b/bin/varnishhist/varnishhist.c index faec821..b77d381 100644 --- a/bin/varnishhist/varnishhist.c +++ b/bin/varnishhist/varnishhist.c @@ -190,8 +190,7 @@ static int /*__match_proto__ (VSLQ_dispatch_f)*/ accumulate(struct VSL_data *vsl, struct VSL_transaction * const pt[], void *priv) { - int i, j; - unsigned tag, hit; + int i, j, tag, skip, match, hit; double value; struct VSL_transaction *tr; @@ -205,62 +204,75 @@ accumulate(struct VSL_data *vsl, struct VSL_transaction * const pt[], if (tr->reason == VSL_r_esi) /* Skip ESI requests */ continue; - value = -1; + hit = 0; - while ((1 == VSL_Next(tr->c))) { + skip = 0; + match = 0; + while (skip == 0 && 1 == VSL_Next(tr->c)) { /* get the value we want, and register if it's a hit*/ tag = VSL_TAG(tr->c->rec.ptr); - assert(match_tag >= 0); - if (tag == (unsigned)match_tag) { + + switch (tag) { + case SLT_Hit: + hit = 1; + break; + case SLT_VCL_return: + if (!strcasecmp(VSL_CDATA(tr->c->rec.ptr), + "restart")) + skip = 1; + break; + default: + if (tag != match_tag) + break; i = sscanf(VSL_CDATA(tr->c->rec.ptr), format, &value); if (i != 1) - continue; - } else if (tag == SLT_Hit) - hit = 1; - if (tag != SLT_ReqEnd && value == -1) - continue; - - /* select bucket */ - i = HIST_RES * (log(value) / log_ten); - if (i < hist_low * HIST_RES) - i = hist_low * HIST_RES; - if (i >= hist_high * HIST_RES) - i = hist_high * HIST_RES - 1; - i -= hist_low * HIST_RES; - assert(i >= 0); - assert(i < hist_buckets); - pthread_mutex_lock(&mtx); - - /* phase out old data */ - if (nhist == HIST_N) { - j = rr_hist[next_hist]; - if (j < 0) { - assert(bucket_miss[-j] > 0); - bucket_miss[-j]--; - } else { - assert(bucket_hit[j] > 0); - bucket_hit[j]--; - } - } else { - ++nhist; + break; + match = 1; + break; } + } - /* phase in new data */ - if (hit) { - bucket_hit[i]++; - rr_hist[next_hist] = i; + if (skip || !match) + continue; + + /* select bucket */ + i = HIST_RES * (log(value) / log_ten); + if (i < hist_low * HIST_RES) + i = hist_low * HIST_RES; + if (i >= hist_high * HIST_RES) + i = hist_high * HIST_RES - 1; + i -= hist_low * HIST_RES; + assert(i >= 0); + assert(i < hist_buckets); + pthread_mutex_lock(&mtx); + + /* phase out old data */ + if (nhist == HIST_N) { + j = rr_hist[next_hist]; + if (j < 0) { + assert(bucket_miss[-j] > 0); + bucket_miss[-j]--; } else { - bucket_miss[i]++; - rr_hist[next_hist] = -i; - } - if (++next_hist == HIST_N) { - next_hist = 0; + assert(bucket_hit[j] > 0); + bucket_hit[j]--; } - pthread_mutex_unlock(&mtx); - + } else { + ++nhist; + } + /* phase in new data */ + if (hit) { + bucket_hit[i]++; + rr_hist[next_hist] = i; + } else { + bucket_miss[i]++; + rr_hist[next_hist] = -i; } + if (++next_hist == HIST_N) { + next_hist = 0; + } + pthread_mutex_unlock(&mtx); } return (0); } From martin at varnish-software.com Tue Feb 25 14:58:40 2014 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Tue, 25 Feb 2014 15:58:40 +0100 Subject: [master] 549ecd9 Disable daemon mode for varnishhist Message-ID: commit 549ecd98eceb8536985641b8d3d8b50725830b5b Author: Martin Blix Grydeland Date: Tue Feb 25 14:52:37 2014 +0100 Disable daemon mode for varnishhist diff --git a/bin/varnishhist/varnishhist_options.h b/bin/varnishhist/varnishhist_options.h index 11479dd..bab592a 100644 --- a/bin/varnishhist/varnishhist_options.h +++ b/bin/varnishhist/varnishhist_options.h @@ -50,7 +50,6 @@ VSL_OPT_C VUT_OPT_d -VUT_OPT_D VUT_OPT_g VUT_OPT_h VSL_OPT_L From martin at varnish-software.com Tue Feb 25 14:58:40 2014 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Tue, 25 Feb 2014 15:58:40 +0100 Subject: [master] 8c022f2 Redefine -g option to reflect the valid grouping types. Message-ID: commit 8c022f2def00ae8389ee00b681b40fd81c56abe4 Author: Martin Blix Grydeland Date: Tue Feb 25 15:00:27 2014 +0100 Redefine -g option to reflect the valid grouping types. diff --git a/bin/varnishhist/varnishhist_options.h b/bin/varnishhist/varnishhist_options.h index bab592a..0a0e2b3 100644 --- a/bin/varnishhist/varnishhist_options.h +++ b/bin/varnishhist/varnishhist_options.h @@ -31,6 +31,12 @@ #include "vapi/vapi_options.h" #include "vut_options.h" +#define HIS_OPT_g \ + VOPT("g:", "[-g ]", "Grouping mode", \ + "The grouping of the log records. The default is to group" \ + " by vxid." \ + ) + #define HIS_OPT_p \ VOPT("p:", "[-p period]", "Refresh period", \ "Specified the number of seconds between screen refreshes." \ @@ -50,7 +56,7 @@ VSL_OPT_C VUT_OPT_d -VUT_OPT_g +HIS_OPT_g VUT_OPT_h VSL_OPT_L VUT_OPT_n From martin at varnish-software.com Tue Feb 25 14:58:40 2014 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Tue, 25 Feb 2014 15:58:40 +0100 Subject: [master] 168be72 Update copyright Message-ID: commit 168be724894759602b33d401994be94945e9488b Author: Martin Blix Grydeland Date: Tue Feb 25 15:53:29 2014 +0100 Update copyright diff --git a/bin/varnishhist/varnishhist.c b/bin/varnishhist/varnishhist.c index b77d381..c7406da 100644 --- a/bin/varnishhist/varnishhist.c +++ b/bin/varnishhist/varnishhist.c @@ -1,6 +1,6 @@ /*- * Copyright (c) 2006 Verdens Gang AS - * Copyright (c) 2006-2011 Varnish Software AS + * Copyright (c) 2006-2014 Varnish Software AS * All rights reserved. * * Author: Poul-Henning Kamp From tfheen at fastly.com Tue Feb 25 15:02:18 2014 From: tfheen at fastly.com (Tollef Fog Heen) Date: Tue, 25 Feb 2014 16:02:18 +0100 Subject: [master] 1346cd8 Build varnishhist documentation In-Reply-To: References: Message-ID: > > diff --git a/bin/varnishhist/Makefile.am b/bin/varnishhist/Makefile.am > index a24f29a..986966f 100644 > --- a/bin/varnishhist/Makefile.am > +++ b/bin/varnishhist/Makefile.am > @@ -19,3 +19,35 @@ varnishhist_LDADD = \ > $(top_builddir)/lib/libvarnishapi/libvarnishapi.la \ > -lm \ > @CURSES_LIB@ ${RT_LIBS} ${PTHREAD_LIBS} > + > +noinst_PROGRAMS = varnishhist_opt2rst > +varnishhist_opt2rst_SOURCES = \ > + varnishhist_options.h \ > + varnishhist_options.c \ > + $(top_srcdir)/lib/libvarnishtools/opt2rst.c > + > +BUILT_SOURCES = varnishhist_options.rst varnishhist_synopsis.rst > +EXTRA_DIST = $(BUILT_SOURCES) > +MAINTAINERCLEANFILES = $(EXTRA_DIST) > + > +varnishhist_options.rst: > + ./varnishhist_opt2rst options > $@ > +varnishhist_synopsis.rst: > + ./varnishhist_opt2rst synopsis > $@ > + > +if HAVE_RST2MAN > +varnishhist_options.rst varnishhist_synopsis.rst: varnishhist_opt2rst > +endif > + > +varnishhist.1: \ > + $(top_srcdir)/doc/sphinx/reference/varnishhist.rst \ > + varnishhist_options.rst \ > + varnishhist_synopsis.rst > +if HAVE_RST2MAN > + ${RST2MAN} $(top_srcdir)/doc/sphinx/reference/varnishhist.rst $@ > +else > + @echo "========================================" > + @echo "You need rst2man installed to make dist" > + @echo "========================================" > + @false > +endif > This is different to how all the other docs are built now, I think it should be changed to be in line with how we do it now. - Tollef -------------- next part -------------- An HTML attachment was scrubbed... URL: From martin at varnish-software.com Tue Feb 25 15:16:08 2014 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Tue, 25 Feb 2014 16:16:08 +0100 Subject: [master] 57a7f98 Add the missing build bits for varnishhist Message-ID: commit 57a7f98eaa38cb6b9e2061a2d220fe9728cfd97b Author: Martin Blix Grydeland Date: Tue Feb 25 16:15:40 2014 +0100 Add the missing build bits for varnishhist diff --git a/doc/sphinx/Makefile.am b/doc/sphinx/Makefile.am index 8e891c8..5be4551 100644 --- a/doc/sphinx/Makefile.am +++ b/doc/sphinx/Makefile.am @@ -123,6 +123,7 @@ EXTRA_DIST = \ reference/varnishstat.rst \ reference/varnishtest.rst \ reference/varnishtop.rst \ + reference/varnishhist.rst \ reference/vcl.rst \ reference/vmod.rst \ reference/vmod_std.rst \ @@ -198,5 +199,12 @@ include/varnishtop_synopsis.rst: $(top_builddir)/bin/varnishtop/varnishtop_opt2r BUILT_SOURCES += include/varnishtop_options.rst \ include/varnishtop_synopsis.rst +include/varnishhist_options.rst: $(top_builddir)/bin/varnishhist/varnishhist_opt2rst + $(top_builddir)/bin/varinshhist/varnishhist_opt2rst options > $@ +include/varnishhist_synopsis.rst: $(top_builddir)/bin/varnishhist/varnishhist_opt2rst + $(top_builddir)/bin/varinshhist/varnishhist_opt2rst synopsis > $@ +BUILT_SOURCES += include/varnishhist_options.rst \ + include/varnishhist_synopsis.rst + EXTRA_DIST += $(BUILT_SOURCES) MAINTAINERCLEANFILES = $(EXTRA_DIST) diff --git a/man/Makefile.am b/man/Makefile.am index 50e9b64..3321a2f 100644 --- a/man/Makefile.am +++ b/man/Makefile.am @@ -21,7 +21,8 @@ dist_man_MANS = \ varnishreplay.1 \ varnishstat.1 \ varnishtest.1 \ - varnishtop.1 + varnishtop.1 \ + varnishhist.1 MAINTAINERCLEANFILES = $(dist_man_MANS) @@ -76,3 +77,9 @@ varnishtop.1: \ $(top_srcdir)/doc/sphinx/include/varnishtop_options.rst \ $(top_srcdir)/doc/sphinx/include/varnishtop_synopsis.rst ${RST2MAN} $(top_srcdir)/doc/sphinx/reference/varnishtop.rst $@ + +varnishhist.1: \ + $(top_srcdir)/doc/sphinx/reference/varnishhist.rst \ + $(top_srcdir)/doc/sphinx/include/varnishhist_options.rst \ + $(top_srcdir)/doc/sphinx/include/varnishhist_synopsis.rst + ${RST2MAN} $(top_srcdir)/doc/sphinx/reference/varnishhist.rst $@ From martin at varnish-software.com Tue Feb 25 15:21:06 2014 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Tue, 25 Feb 2014 16:21:06 +0100 Subject: [master] 56cbab9 Fix spelling error Message-ID: commit 56cbab96034e29f1492f1e4b66162076a31553d5 Author: Martin Blix Grydeland Date: Tue Feb 25 16:20:59 2014 +0100 Fix spelling error diff --git a/doc/sphinx/Makefile.am b/doc/sphinx/Makefile.am index 5be4551..631a3bb 100644 --- a/doc/sphinx/Makefile.am +++ b/doc/sphinx/Makefile.am @@ -200,7 +200,7 @@ BUILT_SOURCES += include/varnishtop_options.rst \ include/varnishtop_synopsis.rst include/varnishhist_options.rst: $(top_builddir)/bin/varnishhist/varnishhist_opt2rst - $(top_builddir)/bin/varinshhist/varnishhist_opt2rst options > $@ + $(top_builddir)/bin/varnishhist/varnishhist_opt2rst options > $@ include/varnishhist_synopsis.rst: $(top_builddir)/bin/varnishhist/varnishhist_opt2rst $(top_builddir)/bin/varinshhist/varnishhist_opt2rst synopsis > $@ BUILT_SOURCES += include/varnishhist_options.rst \ From martin at varnish-software.com Tue Feb 25 15:23:12 2014 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Tue, 25 Feb 2014 16:23:12 +0100 Subject: [master] 9e3ce13 And another spelling error Message-ID: commit 9e3ce1315ff82857d3aa0aac44d0515b05a58998 Author: Martin Blix Grydeland Date: Tue Feb 25 16:22:54 2014 +0100 And another spelling error diff --git a/doc/sphinx/Makefile.am b/doc/sphinx/Makefile.am index 631a3bb..26033c2 100644 --- a/doc/sphinx/Makefile.am +++ b/doc/sphinx/Makefile.am @@ -202,7 +202,7 @@ BUILT_SOURCES += include/varnishtop_options.rst \ include/varnishhist_options.rst: $(top_builddir)/bin/varnishhist/varnishhist_opt2rst $(top_builddir)/bin/varnishhist/varnishhist_opt2rst options > $@ include/varnishhist_synopsis.rst: $(top_builddir)/bin/varnishhist/varnishhist_opt2rst - $(top_builddir)/bin/varinshhist/varnishhist_opt2rst synopsis > $@ + $(top_builddir)/bin/varnishhist/varnishhist_opt2rst synopsis > $@ BUILT_SOURCES += include/varnishhist_options.rst \ include/varnishhist_synopsis.rst From perbu at varnish-software.com Tue Feb 25 19:09:40 2014 From: perbu at varnish-software.com (Per Buer) Date: Tue, 25 Feb 2014 20:09:40 +0100 Subject: [master] 5885903 Seems we don't need to ignore these Message-ID: commit 58859030a9d13f283dbdbc6d106463cc114ee709 Author: Per Buer Date: Tue Feb 25 20:09:25 2014 +0100 Seems we don't need to ignore these diff --git a/.gitignore b/.gitignore index 3df191e..dd684da 100644 --- a/.gitignore +++ b/.gitignore @@ -79,8 +79,6 @@ cscope.*out /man/vsc2rst /man/*.7 /man/*.1 -/bin/*/*.1 -/bin/*/*.rst /doc/sphinx/include /bin/varnish*/varnish*_opt2rst /bin/varnishadm/varnishadm From martin at varnish-software.com Tue Feb 25 21:48:12 2014 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Tue, 25 Feb 2014 22:48:12 +0100 Subject: [master] 3f79aa1 Fix include directory path Message-ID: commit 3f79aa1a30ecba3742d5964b7d5666318044a97d Author: Martin Blix Grydeland Date: Tue Feb 25 22:46:44 2014 +0100 Fix include directory path Fix the varnishhist documentation include file paths. diff --git a/doc/sphinx/reference/varnishhist.rst b/doc/sphinx/reference/varnishhist.rst index 901c7f4..8071384 100644 --- a/doc/sphinx/reference/varnishhist.rst +++ b/doc/sphinx/reference/varnishhist.rst @@ -9,7 +9,7 @@ Varnish request histogram SYNOPSIS ======== -.. include:: ../../../bin/varnishhist/varnishhist_synopsis.rst +.. include:: ../include/varnishhist_synopsis.rst varnishhist |synopsis| DESCRIPTION @@ -24,7 +24,7 @@ and misses are marked with a hash character ("#"). The following options are available: -.. include:: ../../../bin/varnishhist/varnishhist_options.rst +.. include:: ../include/varnishhist_options.rst SEE ALSO ======== From martin at varnish-software.com Wed Feb 26 10:08:03 2014 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Wed, 26 Feb 2014 11:08:03 +0100 Subject: [master] 7c511ff Remove operation.rst from the dist lists to fix build Message-ID: commit 7c511ff549e14aee6cd853e1f35721cd532a7278 Author: Martin Blix Grydeland Date: Wed Feb 26 11:07:24 2014 +0100 Remove operation.rst from the dist lists to fix build diff --git a/doc/sphinx/Makefile.am b/doc/sphinx/Makefile.am index 26033c2..ac09cc0 100644 --- a/doc/sphinx/Makefile.am +++ b/doc/sphinx/Makefile.am @@ -145,7 +145,6 @@ EXTRA_DIST = \ users-guide/index.rst \ users-guide/intro.rst \ users-guide/operation-logging.rst \ - users-guide/operation.rst \ users-guide/operation-statistics.rst \ users-guide/params.rst \ users-guide/performance.rst \ diff --git a/doc/sphinx/Makefile.phk b/doc/sphinx/Makefile.phk index b14e6cb..18197a6 100644 --- a/doc/sphinx/Makefile.phk +++ b/doc/sphinx/Makefile.phk @@ -155,7 +155,6 @@ EXTRA_DIST = \ users-guide/intro.rst \ users-guide/operation-cli.rst \ users-guide/operation-logging.rst \ - users-guide/operation.rst \ users-guide/operation-statistics.rst \ users-guide/params.rst \ users-guide/performance.rst \ From perbu at varnish-software.com Wed Feb 26 11:30:54 2014 From: perbu at varnish-software.com (Per Buer) Date: Wed, 26 Feb 2014 12:30:54 +0100 Subject: [master] 2b9db41 Rewrite for 4.0 - might still need review Message-ID: commit 2b9db41c981d1218c1a83e9b6e6174fe3513f671 Author: Per Buer Date: Wed Feb 26 12:29:27 2014 +0100 Rewrite for 4.0 - might still need review diff --git a/doc/sphinx/users-guide/vcl-syntax.rst b/doc/sphinx/users-guide/vcl-syntax.rst index 14e07ed..15b6da3 100644 --- a/doc/sphinx/users-guide/vcl-syntax.rst +++ b/doc/sphinx/users-guide/vcl-syntax.rst @@ -95,4 +95,5 @@ To call a subroutine, use the call keyword followed by the subroutine's name: call pipe_if_local; Varnish has quite a few built in subroutines that are called for each -transaction as it flows through Varnish. See :ref:`vcl-built-in-subs`. +transaction as it flows through Varnish. These builtin subroutines are all named vcl_*. Your own subroutines cannot start their name with vcl_. +See :ref:`vcl-built-in-subs`. From perbu at varnish-software.com Wed Feb 26 11:30:54 2014 From: perbu at varnish-software.com (Per Buer) Date: Wed, 26 Feb 2014 12:30:54 +0100 Subject: [master] 56adaeb -b is redundant Message-ID: commit 56adaeb29445c6be2cf8dc4fc53e8a5dca5825b3 Author: Per Buer Date: Wed Feb 26 12:30:21 2014 +0100 -b is redundant diff --git a/doc/sphinx/users-guide/increasing-your-hitrate.rst b/doc/sphinx/users-guide/increasing-your-hitrate.rst index 9d1dc67..431c0fc 100644 --- a/doc/sphinx/users-guide/increasing-your-hitrate.rst +++ b/doc/sphinx/users-guide/increasing-your-hitrate.rst @@ -23,8 +23,10 @@ Tool: varnishtop ~~~~~~~~~~~~~~~~ You can use varnishtop to identify what URLs are hitting the backend -the most. ``varnishtop -b -i txurl`` is an essential command. You can see -some other examples of varnishtop usage in :ref:`users-guide-statistics`. +the most. ``varnishtop -i txurl`` is an essential command, showing you +the top txurl requests Varnish is sending towards the backend. You can +see some other examples of varnishtop usage in +:ref:`users-guide-statistics`. Tool: varnishlog From perbu at varnish-software.com Wed Feb 26 11:30:54 2014 From: perbu at varnish-software.com (Per Buer) Date: Wed, 26 Feb 2014 12:30:54 +0100 Subject: [master] 0aac416 4.0 rewrite Message-ID: commit 0aac4167512cad131023bfdefb84072922d15a47 Author: Per Buer Date: Wed Feb 26 12:30:50 2014 +0100 4.0 rewrite diff --git a/doc/sphinx/users-guide/vcl-built-in-subs.rst b/doc/sphinx/users-guide/vcl-built-in-subs.rst index 2202af0..7a31aef 100644 --- a/doc/sphinx/users-guide/vcl-built-in-subs.rst +++ b/doc/sphinx/users-guide/vcl-built-in-subs.rst @@ -22,7 +22,7 @@ yourself doing frequently. The vcl_recv subroutine may terminate with calling ``return()`` on one of the following keywords: - error code [reason] + error Return the specified error code to the client and abandon the request. pass @@ -31,56 +31,117 @@ of the following keywords: pipe Switch to pipe mode. Control will eventually pass to vcl_pipe. - lookup - Look up the requested object in the cache. Control will - eventually pass to vcl_hit or vcl_miss, depending on whether the - object is in the cache. The ``bereq.method`` value will be set - to ``GET`` regardless of the value of ``req.method``. + hash + Continue processing the object as a potential candidate for + caching. Passes the control over to vcl_hash. + purge + Calls vcl_purge where the object will be purged. -vcl_backend_fetch -~~~~~~~~~~~~~~~~~ +vcl_pipe +~~~~~~~~ -Called before sending the backend request. In this subroutine you -typically alter the request before it gets to the backend. +Called upon entering pipe mode. In this mode, the request is passed +on to the backend, and any further data from either client or backend +is passed on unaltered until either end closes the +connection. Basically, Varnish will degrade into a simple TCP proxy, +shuffling bytes back and forth. -.. XXX Return statements? +The vcl_pipe subroutine may terminate with calling return() with one +of the following keywords: + error code [reason] + Return the specified error code to the client and abandon the request. -vcl_backend_response -~~~~~~~~~~~~~~~~~~~ + pipe + Proceed with pipe mode. -Called after a document has been successfully retrieved from the backend. +vcl_pass +~~~~~~~~ -The vcl_backend_response subroutine may terminate with calling return() with one -of the following keywords: +Called upon entering pass mode. In this mode, the request is passed +on to the backend, and the backend's response is passed on to the +client, but is not entered into the cache. Subsequent requests +submitted over the same client connection are handled normally. - deliver - Possibly insert the object into the cache, then deliver it to the - client. Control will eventually pass to vcl_deliver. +The vcl_pass subroutine may terminate with calling return() with one +of the following keywords: - error code [reason] + error [reason] Return the specified error code to the client and abandon the request. - hit_for_pass - Pass in fetch. Passes the object without caching it. This will - create a so-called hit_for_pass object which has the side effect - that the decision not to cache will be cached. This is to allow - would-be uncachable requests to be passed to the backend at the - same time. The same logic is not necessary in vcl_recv because - this happens before any potential queueing for an object takes - place. Note that the TTL for the hit_for_pass object will be set - to what the current value of beresp.ttl is. Control will be - handled to vcl_deliver on the current request, but subsequent - requests will go directly to vcl_pass based on the hit_for_pass - object. + pass + Proceed with pass mode. + + restart + Restart the transaction. Increases the restart counter. If the number + of restarts is higher than *max_restarts* Varnish emits a guru meditation + error. + + +vcl_hit +~~~~~~~ + +Called is a cache lookup is successful. restart Restart the transaction. Increases the restart counter. If the number of restarts is higher than *max_restarts* Varnish emits a guru meditation error. + deliver + Deliver the object. Control passes to vcl_deliver. + + error [reason] + Return the specified error code to the client and abandon the request. + + +vcl_miss +~~~~~~~~ + +Called after a cache lookup if the requested document was not found in +the cache. Its purpose is to decide whether or not to attempt to +retrieve the document from the backend, and which backend to use. + +The vcl_miss subroutine may terminate with calling return() with one +of the following keywords: + + error [reason] + Return the specified error code to the client and abandon the request. + + pass + Switch to pass mode. Control will eventually pass to vcl_pass. + + fetch + Retrieve the requested object from the backend. Control will + eventually pass to vcl_fetch. + +vcl_hash +~~~~~~~~ + +Called after vcl_recv to create a hash value for the request. This is +used as a key to look up the object in Varnish. + + lookup + Look up the object in cache. + + +vcl_purge +~~~~~~~~~ + +Purge the object and all it's variants. Variants created when the +backend issues a Vary response. + + fetch + Execute the purge. + + error + Fail the purge request. Typically you would call error here it + request doesn't pass the ACLs. + + + vcl_deliver ~~~~~~~~~~~ @@ -97,83 +158,82 @@ keywords: of restarts is higher than *max_restarts* Varnish emits a guru meditation error. -vcl_backend_error -~~~~~~~~~~~~~~~~~ -Called when we hit an error, either explicitly or implicitly due to -backend or internal errors. +.. XXX +.. vcl_error +.. ~~~~~~~~~ -The vcl_backend_error subroutine may terminate by calling return with one of -the following keywords: +.. Not sure if we're going to keep this around. - deliver - Deliver the error object to the client. - restart - Restart the transaction. Increases the restart counter. If the number - of restarts is higher than *max_restarts* Varnish emits a guru meditation - error. +vcl_backend_fetch +~~~~~~~~~~~~~~~~~ +Called before sending the backend request. In this subroutine you +typically alter the request before it gets to the backend. -vcl_pipe -~~~~~~~~ + fetch + Fetch the object from the backend. -Called upon entering pipe mode. In this mode, the request is passed -on to the backend, and any further data from either client or -backend is passed on unaltered until either end closes the -connection. + abandon + Abandon the backend request and generates an error. + - The vcl_pipe subroutine may terminate with calling return() with one of - the following keywords: +vcl_backend_response +~~~~~~~~~~~~~~~~~~~~ - error code [reason] - Return the specified error code to the client and abandon the request. +Called after an response has been successfully retrieved from the +backend. The response is availble as beresp. Note that Varnish might +not be talking to an actual client, so operations that require a +client to be present are not allowed. Specifically there is no req +object and restarts are not allowed. - pipe - Proceed with pipe mode. +The vcl_backend_response subroutine may terminate with calling return() with one +of the following keywords: -vcl_pass -~~~~~~~~ + deliver + Possibly insert the object into the cache, then deliver it to the + Control will eventually pass to vcl_deliver. Caching is dependant + on beresp.cacheable. -Called upon entering pass mode. In this mode, the request is passed -on to the backend, and the backend's response is passed on to the -client, but is not entered into the cache. Subsequent requests -submitted over the same client connection are handled normally. + error [reason] + Return the specified error code to the client and abandon the request. -The vcl_pass subroutine may terminate with calling return() with one -of the following keywords: + retry + Retry the backend transaction. Increases the retries counter. If the number + of retries is higher than *max_retries* Varnish emits a guru meditation + error. - error code [reason] - Return the specified error code to the client and abandon the request. +vcl_backend_error +~~~~~~~~~~~~~~~~~ - pass - Proceed with pass mode. +This subroutine is called if we fail the backend fetch. - restart - Restart the transaction. Increases the restart counter. If the number - of restarts is higher than *max_restarts* Varnish emits a guru meditation - error. + deliver + Deliver the error. -vcl_miss -~~~~~~~~ + retry + Retry the backend transaction. Increases the retries counter. If the number + of retries is higher than *max_retries* Varnish emits a guru meditation + error. -Called after a cache lookup if the requested document was not found in -the cache. Its purpose is to decide whether or not to attempt to -retrieve the document from the backend, and which backend to use. -The vcl_miss subroutine may terminate with calling return() with one -of the following keywords: +vcl_backend_error +~~~~~~~~~~~~~~~~~ - error code [reason] - Return the specified error code to the client and abandon the request. +Called when we hit an error, either explicitly or implicitly due to +backend or internal errors. - pass - Switch to pass mode. Control will eventually pass to vcl_pass. +The vcl_backend_error subroutine may terminate by calling return with one of +the following keywords: - fetch - Retrieve the requested object from the backend. Control will - eventually pass to vcl_fetch. + deliver + Deliver the error object to the client. + retry + Retry the backend transaction. Increases the retries counter. If the number + of retries is higher than *max_retries* Varnish emits a guru meditation + error. vcl_init From fgsch at lodoss.net Wed Feb 26 14:25:05 2014 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Wed, 26 Feb 2014 15:25:05 +0100 Subject: [master] e551669 Make rst2man mandatory Message-ID: commit e5516699439d560f5df326a55a427b3a9f2bdce5 Author: Federico G. Schwindt Date: Wed Feb 26 14:20:00 2014 +0000 Make rst2man mandatory This simplifies the autofoo magic and fixes the manpage installation on the dist tarball when rst2man was not installed. diff --git a/Makefile.am b/Makefile.am index 389be99..7624ec5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,6 +1,6 @@ ACLOCAL_AMFLAGS = -I m4 -SUBDIRS = include lib bin etc doc redhat +SUBDIRS = include lib bin etc doc man redhat pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = varnishapi.pc @@ -20,16 +20,6 @@ DISTCHECK_CONFIGURE_FLAGS = \ install-data-local: $(install_sh) -d -m 0755 $(DESTDIR)$(localstatedir)/varnish -if HAVE_RST2MAN -SUBDIRS += man -else -dist-hook: - @echo "========================================" - @echo "You need rst2man installed to make dist" - @echo "========================================" - @false -endif - distcheck-hook: V="@PACKAGE_VERSION@" ; \ V="$${V%%-*}" ; \ diff --git a/configure.ac b/configure.ac index 5c46de8..6f43695 100644 --- a/configure.ac +++ b/configure.ac @@ -50,15 +50,15 @@ CC="$PTHREAD_CC" AC_PROG_INSTALL AC_PROG_MAKE_SET + AC_ARG_WITH([rst2man], - AS_HELP_STRING([--with-rst2man=PATH], - [Location of rst2man (auto)]), - [RST2MAN="$withval"], - [AC_CHECK_PROGS(RST2MAN, [rst2man rst2man.py], "no") - if test "x$RST2MAN" = "xno"; then - AC_MSG_WARN([rst2man not found - not building man pages]) - fi]) -AM_CONDITIONAL(HAVE_RST2MAN,[test "x$RST2MAN" != "xno"]) + AS_HELP_STRING([--with-rst2man=PATH], [Location of rst2man (auto)]), + [RST2MAN="$withval"], + AC_CHECK_PROGS(RST2MAN, [rst2man rst2man.py], [])) +if test -z "$RST2MAN"; then + AC_MSG_ERROR( + [rst2man is needed to build Varnish, please install python-docutils.]) +fi AC_ARG_WITH([rst2html], AS_HELP_STRING([--with-rst2html=PATH], diff --git a/lib/libvarnishapi/Makefile.am b/lib/libvarnishapi/Makefile.am index 9c96d39..f0a23fa 100644 --- a/lib/libvarnishapi/Makefile.am +++ b/lib/libvarnishapi/Makefile.am @@ -73,10 +73,8 @@ vsl2rst_SOURCES = \ $(top_srcdir)/include/tbl/vsl_tags.h \ $(top_srcdir)/include/tbl/vsl_tags_http.h -if HAVE_RST2MAN vsl-tags.rst: vsl2rst ./vsl2rst > $@ -endif vxp_fixed_token.c vxp_tokens.h: \ $(srcdir)/generate.py diff --git a/lib/libvmod_std/Makefile.am b/lib/libvmod_std/Makefile.am index cd8aebf..8967bf5 100644 --- a/lib/libvmod_std/Makefile.am +++ b/lib/libvmod_std/Makefile.am @@ -38,11 +38,4 @@ CLEANFILES = $(builddir)/vcc_if.c $(builddir)/vcc_if.h \ $(builddir)/vmod_std.man.rst vmod_std.3: $(top_srcdir)/doc/sphinx/reference/vmod_std.rst -if HAVE_RST2MAN ${RST2MAN} $? $@ -else - @echo "========================================" - @echo "You need rst2man installed to make dist" - @echo "========================================" - @false -endif diff --git a/man/Makefile.am b/man/Makefile.am index 3321a2f..9343063 100644 --- a/man/Makefile.am +++ b/man/Makefile.am @@ -1,8 +1,6 @@ # -if HAVE_RST2MAN noinst_PROGRAMS = vsc2rst -endif vsc2rst_SOURCES = vsc2rst.c \ $(top_srcdir)/include/tbl/vsc_fields.h From martin at varnish-software.com Thu Feb 27 09:24:49 2014 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Thu, 27 Feb 2014 10:24:49 +0100 Subject: [master] 755836a Warn on VSL record batches containing records with VXID missmatch Message-ID: commit 755836a1c58f5ab6c6b2f895a077af33c88e088a Author: Martin Blix Grydeland Date: Thu Feb 27 10:17:54 2014 +0100 Warn on VSL record batches containing records with VXID missmatch diff --git a/lib/libvarnishapi/vsl_dispatch.c b/lib/libvarnishapi/vsl_dispatch.c index 0aee758..709b9fe 100644 --- a/lib/libvarnishapi/vsl_dispatch.c +++ b/lib/libvarnishapi/vsl_dispatch.c @@ -847,6 +847,11 @@ vtx_scan(struct VSLQ *vslq, struct vtx *vtx) while (vslc_vtx_next(&vtx->c.cursor) == 1) { ptr = vtx->c.cursor.rec.ptr; + if (VSL_ID(ptr) != vtx->key.vxid) { + (void)vtx_diag_tag(vtx, ptr, "vxid missmatch"); + continue; + } + tag = VSL_TAG(ptr); assert(tag != SLT__Batch); @@ -1026,7 +1031,7 @@ static int vtx_diag_tag(struct vtx *vtx, const uint32_t *ptr, const char *reason) { - vtx_synth_rec(vtx, SLT_VSL, "%s (%s: %.*s)", reason, + vtx_synth_rec(vtx, SLT_VSL, "%s (%u:%s \"%.*s\")", reason, VSL_ID(ptr), VSL_tags[VSL_TAG(ptr)], (int)VSL_LEN(ptr), VSL_CDATA(ptr)); return (-1); } From martin at varnish-software.com Thu Feb 27 09:24:49 2014 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Thu, 27 Feb 2014 10:24:49 +0100 Subject: [master] 95dd968 Don't assert on multiple End records seen in a record set. Message-ID: commit 95dd9683ab3d4c4bb7423c7701721493bd00ea48 Author: Martin Blix Grydeland Date: Thu Feb 27 10:18:55 2014 +0100 Don't assert on multiple End records seen in a record set. Spotted by: Dag diff --git a/lib/libvarnishapi/vsl_dispatch.c b/lib/libvarnishapi/vsl_dispatch.c index 709b9fe..3acdbd2 100644 --- a/lib/libvarnishapi/vsl_dispatch.c +++ b/lib/libvarnishapi/vsl_dispatch.c @@ -842,10 +842,8 @@ vtx_scan(struct VSLQ *vslq, struct vtx *vtx) const uint32_t *ptr; enum VSL_tag_e tag; - if (vtx->flags & VTX_F_END) - return; - - while (vslc_vtx_next(&vtx->c.cursor) == 1) { + while (!(vtx->flags & VTX_F_COMPLETE) && + vslc_vtx_next(&vtx->c.cursor) == 1) { ptr = vtx->c.cursor.rec.ptr; if (VSL_ID(ptr) != vtx->key.vxid) { (void)vtx_diag_tag(vtx, ptr, "vxid missmatch"); @@ -867,12 +865,14 @@ vtx_scan(struct VSLQ *vslq, struct vtx *vtx) case SLT_End: vtx->flags |= VTX_F_END; - vtx_mark_complete(vslq, vtx); break; default: break; } } + + if (vtx->flags & VTX_F_END && !(vtx->flags & VTX_F_COMPLETE)) + vtx_mark_complete(vslq, vtx); } /* Force a vtx into complete status by synthing the necessary outstanding From lkarsten at varnish-software.com Thu Feb 27 09:34:41 2014 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 27 Feb 2014 10:34:41 +0100 Subject: [master] 92d71fb s/req.backend/req.backend_hint/g Message-ID: commit 92d71fb8eeaf5d7e8599c7ecb90da6f603d0941c Author: Lasse Karstensen Date: Wed Feb 26 13:12:59 2014 +0100 s/req.backend/req.backend_hint/g diff --git a/doc/sphinx/reference/vcl.rst b/doc/sphinx/reference/vcl.rst index 436d58d..57072d0 100644 --- a/doc/sphinx/reference/vcl.rst +++ b/doc/sphinx/reference/vcl.rst @@ -35,7 +35,7 @@ A backend declaration creates and initializes a named backend object:: The backend object can later be used to select a backend at request time:: if (req.http.host ~ "(?i)^(www.)?example.com$") { - set req.backend = www; + set req.backend_hint = www; } To avoid overloading backend servers, .max_connections can be set to diff --git a/doc/sphinx/users-guide/devicedetection.rst b/doc/sphinx/users-guide/devicedetection.rst index c7acd73..e60b438 100644 --- a/doc/sphinx/users-guide/devicedetection.rst +++ b/doc/sphinx/users-guide/devicedetection.rst @@ -229,7 +229,7 @@ special needs in VCL, you can use the X-UA-Device header like this:: # call some detection engine if (req.http.X-UA-Device ~ "^mobile" || req.http.X-UA-device ~ "^tablet") { - set req.backend = mobile; + set req.backend_hint = mobile; } } sub vcl_hash { diff --git a/doc/sphinx/users-guide/vcl-backends.rst b/doc/sphinx/users-guide/vcl-backends.rst index 6e72416..099e2a6 100644 --- a/doc/sphinx/users-guide/vcl-backends.rst +++ b/doc/sphinx/users-guide/vcl-backends.rst @@ -62,9 +62,9 @@ Now we need tell where to send the difference URL. Lets look at vcl_recv.:: sub vcl_recv { if (req.url ~ "^/java/") { - set req.backend = java; + set req.backend_hint = java; } else { - set req.backend = default. + set req.backend_hint = default. } } @@ -88,9 +88,9 @@ You can have something like this::: sub vcl_recv { if (req.http.host ~ "foo.com") { - set req.backend = foo; + set req.backend_hint = foo; } elsif (req.http.host ~ "bar.com") { - set req.backend = bar; + set req.backend_hint = bar; } } @@ -101,7 +101,7 @@ more tight, maybe relying on the == operator in stead, like this::: sub vcl_recv { if (req.http.host == "foo.com" or req.http.host == "www.foo.com") { - set req.backend = foo; + set req.backend_hint = foo; } } @@ -138,7 +138,7 @@ call certain actions in vcl_init.:: sub vcl_recv { # send all traffic to the bar director: - req.backend = bar.backend(); + req.backend_hint = bar.backend(); } This director is a round-robin director. This means the director will diff --git a/doc/sphinx/whats-new/upgrading.rst b/doc/sphinx/whats-new/upgrading.rst index 97e3a0d..68a41d0 100644 --- a/doc/sphinx/whats-new/upgrading.rst +++ b/doc/sphinx/whats-new/upgrading.rst @@ -32,7 +32,7 @@ Since the client director was already a special case of the hash director, it ha } sub vcl_recv { - set req.backend = h.backend(client.ip); + set req.backend_hint = h.backend(client.ip); } error() is now a return value From lkarsten at varnish-software.com Thu Feb 27 09:34:41 2014 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 27 Feb 2014 10:34:41 +0100 Subject: [master] d8f74bc Reindent with 4 spaces, 2 for continuations Message-ID: commit d8f74bc538393bb8c67de3660c7126dc144487f2 Author: Lasse Karstensen Date: Wed Feb 26 13:36:57 2014 +0100 Reindent with 4 spaces, 2 for continuations diff --git a/bin/varnishd/builtin.vcl b/bin/varnishd/builtin.vcl index 09c08cc..a6a126d 100644 --- a/bin/varnishd/builtin.vcl +++ b/bin/varnishd/builtin.vcl @@ -46,12 +46,12 @@ vcl 4.0; sub vcl_recv { if (req.restarts == 0) { - if (req.http.x-forwarded-for) { - set req.http.X-Forwarded-For = - req.http.X-Forwarded-For + ", " + client.ip; - } else { - set req.http.X-Forwarded-For = client.ip; - } + if (req.http.x-forwarded-for) { + set req.http.X-Forwarded-For = + req.http.X-Forwarded-For + ", " + client.ip; + } else { + set req.http.X-Forwarded-For = client.ip; + } } if (req.method != "GET" && req.method != "HEAD" && @@ -104,13 +104,13 @@ sub vcl_purge { sub vcl_hit { if (obj.ttl >= 0s) { - // A pure unadultered hit, deliver it - return (deliver); + // A pure unadultered hit, deliver it + return (deliver); } if (obj.ttl + obj.grace > 0s) { - // Object is in grace, deliver it - // Automatically triggers a background fetch - return (deliver); + // Object is in grace, deliver it + // Automatically triggers a background fetch + return (deliver); } // fetch & deliver once we get the result return (fetch); @@ -167,22 +167,22 @@ sub vcl_backend_fetch { sub vcl_backend_response { if (beresp.ttl <= 0s || - beresp.http.Set-Cookie || - beresp.http.Surrogate-control ~ "no-store" || - (!beresp.http.Surrogate-Control && - beresp.http.Cache-Control ~ "no-cache|no-store|private") || - beresp.http.Vary == "*") { - /* - * Mark as "Hit-For-Pass" for the next 2 minutes - */ - set beresp.ttl = 120s; - set beresp.uncacheable = true; + beresp.http.Set-Cookie || + beresp.http.Surrogate-control ~ "no-store" || + (!beresp.http.Surrogate-Control && + beresp.http.Cache-Control ~ "no-cache|no-store|private") || + beresp.http.Vary == "*") { + /* + * Mark as "Hit-For-Pass" for the next 2 minutes + */ + set beresp.ttl = 120s; + set beresp.uncacheable = true; } return (deliver); } sub vcl_backend_error { - return (deliver); + return (deliver); } ####################################################################### From phk at FreeBSD.org Thu Feb 27 10:03:01 2014 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 27 Feb 2014 11:03:01 +0100 Subject: [master] a95525a Remove an almost correct assert. Message-ID: commit a95525aff978039148712306134ad60d9b9c0b67 Author: Poul-Henning Kamp Date: Thu Feb 27 10:01:11 2014 +0000 Remove an almost correct assert. The real condition is that either there is no busyobj or it is in state BOS_FINISHED, being rapidly dismantled. The locking of testing that would be to complex and expensive so we eliminate the assert instead, and strengthen another busyobj related check a little bit in compensation. Fixes #1440 diff --git a/bin/varnishd/cache/cache_busyobj.c b/bin/varnishd/cache/cache_busyobj.c index d6b43ae..db1c7a1 100644 --- a/bin/varnishd/cache/cache_busyobj.c +++ b/bin/varnishd/cache/cache_busyobj.c @@ -244,9 +244,10 @@ VBO_waitlen(struct busyobj *bo, ssize_t l) void VBO_setstate(struct busyobj *bo, enum busyobj_state_e next) { - Lck_Lock(&bo->mtx); - VSLb(bo->vsl, SLT_Debug, "XXX BOS: %d -> %d", bo->state, next); + CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); + assert(bo->do_stream || next != BOS_STREAM); assert(next > bo->state); + Lck_Lock(&bo->mtx); bo->state = next; AZ(pthread_cond_broadcast(&bo->cond)); Lck_Unlock(&bo->mtx); diff --git a/bin/varnishd/cache/cache_http1_deliver.c b/bin/varnishd/cache/cache_http1_deliver.c index 2c681d6..c9f373a 100644 --- a/bin/varnishd/cache/cache_http1_deliver.c +++ b/bin/varnishd/cache/cache_http1_deliver.c @@ -294,7 +294,6 @@ V1D_Deliver(struct req *req) if (!req->wantbody) { /* This was a HEAD or conditional request */ } else if (req->res_mode & RES_ESI) { - AZ(req->obj->objcore->busyobj); ESI_Deliver(req); } else if (req->res_mode & RES_ESI_CHILD && req->gzip_resp) { while (req->obj->objcore->busyobj) From lkarsten at varnish-software.com Thu Feb 27 11:30:16 2014 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 27 Feb 2014 12:30:16 +0100 Subject: [master] b3ff41f Explain default groupmode in short help. Message-ID: commit b3ff41f5da0c0a05683d9e5d59c2f619c78f55bb Author: Lasse Karstensen Date: Thu Feb 27 12:28:25 2014 +0100 Explain default groupmode in short help. Main reason to duplicate is that it should be visible in "varnishlog --help". (and friends) diff --git a/include/vut_options.h b/include/vut_options.h index 1f19024..de3bab2 100644 --- a/include/vut_options.h +++ b/include/vut_options.h @@ -41,7 +41,7 @@ ) #define VUT_OPT_g \ - VOPT("g:", "[-g ]", "Grouping mode", \ + VOPT("g:", "[-g ]", "Grouping mode (default: vxid)", \ "The grouping of the log records. The default is to group" \ " by vxid." \ ) From fgsch at lodoss.net Thu Feb 27 11:33:46 2014 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Thu, 27 Feb 2014 12:33:46 +0100 Subject: [master] 42cec19 Remove --without-rst2man Message-ID: commit 42cec19d525f56297626831782643d776866e87a Author: Federico G. Schwindt Date: Thu Feb 27 11:29:06 2014 +0000 Remove --without-rst2man This is mandatory now. diff --git a/redhat/varnish.spec b/redhat/varnish.spec index 451d131..e883314 100644 --- a/redhat/varnish.spec +++ b/redhat/varnish.spec @@ -98,9 +98,9 @@ export CFLAGS="$CFLAGS -Wp,-D_FORTIFY_SOURCE=0" # Remove "--disable static" if you want to build static libraries # jemalloc is not compatible with Red Hat's ppc64 RHEL kernel :-( %ifarch ppc64 ppc - %configure --disable-static --localstatedir=/var/lib --without-jemalloc --without-rst2man --without-rst2html + %configure --disable-static --localstatedir=/var/lib --without-jemalloc --without-rst2html %else - %configure --disable-static --localstatedir=/var/lib --without-rst2man --without-rst2html + %configure --disable-static --localstatedir=/var/lib --without-rst2html %endif # We have to remove rpath - not allowed in Fedora From lkarsten at varnish-software.com Thu Feb 27 12:09:30 2014 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Thu, 27 Feb 2014 13:09:30 +0100 Subject: [master] 0eb0c12 Separate files forgotten in b3ff41f5 Message-ID: commit 0eb0c12a6620fc9e40521b89e5c3e29b2ec9354a Author: Lasse Karstensen Date: Thu Feb 27 13:08:30 2014 +0100 Separate files forgotten in b3ff41f5 Try to be consistent in the help text across the different tools. diff --git a/bin/varnishhist/varnishhist_options.h b/bin/varnishhist/varnishhist_options.h index 0a0e2b3..fdd217e 100644 --- a/bin/varnishhist/varnishhist_options.h +++ b/bin/varnishhist/varnishhist_options.h @@ -32,7 +32,7 @@ #include "vut_options.h" #define HIS_OPT_g \ - VOPT("g:", "[-g ]", "Grouping mode", \ + VOPT("g:", "[-g ]", "Grouping mode (default: vxid)", \ "The grouping of the log records. The default is to group" \ " by vxid." \ ) diff --git a/bin/varnishncsa/varnishncsa_options.h b/bin/varnishncsa/varnishncsa_options.h index 346b7fc..dc8ea30 100644 --- a/bin/varnishncsa/varnishncsa_options.h +++ b/bin/varnishncsa/varnishncsa_options.h @@ -41,7 +41,7 @@ ) #define NCSA_OPT_g \ - VOPT("g:", "[-g ]", "Grouping mode", \ + VOPT("g:", "[-g ]", "Grouping mode (default: vxid)", \ "The grouping of the log records. The default is to group" \ " by vxid." \ ) From fgsch at lodoss.net Thu Feb 27 12:14:15 2014 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Thu, 27 Feb 2014 13:14:15 +0100 Subject: [master] aa8c6e3 Move python-docutils to BuildRequires Message-ID: commit aa8c6e3b7ed8eadc126520c4a596a5331856aa7c Author: Federico G. Schwindt Date: Thu Feb 27 12:12:10 2014 +0000 Move python-docutils to BuildRequires Missed in 42cec19d diff --git a/redhat/varnish.spec b/redhat/varnish.spec index e883314..81ad6f1 100644 --- a/redhat/varnish.spec +++ b/redhat/varnish.spec @@ -14,9 +14,9 @@ Source0: %{name}-%{version}%{?vd_rc}.tar.gz #Source0: %{name}-trunk.tar.gz BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) # To build from git, start with a make dist, see redhat/README.redhat -# You will need at least automake autoconf libtool python-docutils -#BuildRequires: automake autoconf libtool python-docutils -BuildRequires: ncurses-devel groff pcre-devel pkgconfig libedit-devel +# You will need at least automake autoconf libtool +#BuildRequires: automake autoconf libtool +BuildRequires: ncurses-devel groff pcre-devel pkgconfig python-docutils libedit-devel Requires: varnish-libs = %{version}-%{release} Requires: logrotate Requires: ncurses From martin at varnish-software.com Thu Feb 27 14:21:08 2014 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Thu, 27 Feb 2014 15:21:08 +0100 Subject: [master] f278f8b Warn on duplicate Begin log records Message-ID: commit f278f8b2ac33b51d8a35b5ad26f58dd5bbfd7d5a Author: Martin Blix Grydeland Date: Thu Feb 27 12:35:50 2014 +0100 Warn on duplicate Begin log records diff --git a/lib/libvarnishapi/vsl_dispatch.c b/lib/libvarnishapi/vsl_dispatch.c index 3acdbd2..8a7f6e6 100644 --- a/lib/libvarnishapi/vsl_dispatch.c +++ b/lib/libvarnishapi/vsl_dispatch.c @@ -855,8 +855,12 @@ vtx_scan(struct VSLQ *vslq, struct vtx *vtx) switch (tag) { case SLT_Begin: - (void)vtx_scan_begin(vslq, vtx, ptr); - vtx->flags |= VTX_F_BEGIN; + if (vtx->flags & VTX_F_BEGIN) + (void)vtx_diag_tag(vtx, ptr, "duplicate begin"); + else { + (void)vtx_scan_begin(vslq, vtx, ptr); + vtx->flags |= VTX_F_BEGIN; + } break; case SLT_Link: @@ -864,15 +868,15 @@ vtx_scan(struct VSLQ *vslq, struct vtx *vtx) break; case SLT_End: + AZ(vtx->flags & VTX_F_END); vtx->flags |= VTX_F_END; + vtx_mark_complete(vslq, vtx); break; + default: break; } } - - if (vtx->flags & VTX_F_END && !(vtx->flags & VTX_F_COMPLETE)) - vtx_mark_complete(vslq, vtx); } /* Force a vtx into complete status by synthing the necessary outstanding From martin at varnish-software.com Thu Feb 27 14:21:08 2014 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Thu, 27 Feb 2014 15:21:08 +0100 Subject: [master] 2386b35 Allow link to parent on ESI subrequests and in -grequest mode Message-ID: commit 2386b3512523282ce3a42b2bad806c718897015a Author: Martin Blix Grydeland Date: Thu Feb 27 15:18:31 2014 +0100 Allow link to parent on ESI subrequests and in -grequest mode diff --git a/lib/libvarnishapi/vsl_dispatch.c b/lib/libvarnishapi/vsl_dispatch.c index 8a7f6e6..bf4bcd0 100644 --- a/lib/libvarnishapi/vsl_dispatch.c +++ b/lib/libvarnishapi/vsl_dispatch.c @@ -744,7 +744,8 @@ vtx_scan_begin(struct VSLQ *vslq, struct vtx *vtx, const uint32_t *ptr) if (vslq->grouping == VSL_g_vxid) return (0); /* No links */ - if (vslq->grouping == VSL_g_request && vtx->type == VSL_t_req) + if (vslq->grouping == VSL_g_request && vtx->type == VSL_t_req && + vtx->reason == VSL_r_rxreq) return (0); /* No links */ if (vtx->parent != NULL) { From martin at varnish-software.com Thu Feb 27 15:02:57 2014 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Thu, 27 Feb 2014 16:02:57 +0100 Subject: [master] df1cdb8 Avoid duplicate Begin/End records on ESI subrequests Message-ID: commit df1cdb82cb1c103c1ae610fc6e6ebb4e75de054f Author: Martin Blix Grydeland Date: Thu Feb 27 15:34:38 2014 +0100 Avoid duplicate Begin/End records on ESI subrequests When starting an ESI subrequest, make sure that the Begin/End headers are only output once, formatted for ESI. Fixes: #1441 diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index e76b437..65ad51d 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -61,6 +61,7 @@ ved_include(struct req *preq, const char *src, const char *host) req = SES_GetReq(wrk, preq->sp); req->req_body_status = REQ_BODY_NONE; + AN(req->vsl->wid & VSL_CLIENTMARKER); VSLb(req->vsl, SLT_Begin, "req %u esi", preq->vsl->wid & VSL_IDENTMASK); VSLb(preq->vsl, SLT_Link, "req %u esi", req->vsl->wid & VSL_IDENTMASK); req->esi_level = preq->esi_level + 1; @@ -115,8 +116,8 @@ ved_include(struct req *preq, const char *src, const char *host) (void)usleep(10000); } - VSLb(req->vsl, SLT_End, "%s", ""); - req->vsl->wid = 0; + /* Make sure the VSL id has been released */ + AZ(req->vsl->wid); /* Reset the workspace */ WS_Reset(wrk->aws, wrk_ws_wm); /* XXX ? */ diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c index 83ed4cd..96a2507 100644 --- a/bin/varnishd/cache/cache_session.c +++ b/bin/varnishd/cache/cache_session.c @@ -159,6 +159,9 @@ ses_sess_pool_task(struct worker *wrk, void *arg) req = SES_GetReq(wrk, sp); CHECK_OBJ_NOTNULL(req, REQ_MAGIC); + AN(req->vsl->wid & VSL_CLIENTMARKER); + VSLb(req->vsl, SLT_Begin, "req %u rxreq", sp->vxid & VSL_IDENTMASK); + VSL(SLT_Link, sp->vxid, "req %u rxreq", req->vsl->wid & VSL_IDENTMASK); sp->sess_step = S_STP_NEWREQ; ses_req_pool_task(wrk, req); @@ -389,9 +392,6 @@ SES_GetReq(struct worker *wrk, struct sess *sp) sz = cache_param->vsl_buffer; VSL_Setup(req->vsl, p, sz); req->vsl->wid = VXID_Get(&wrk->vxid_pool) | VSL_CLIENTMARKER; - VSLb(req->vsl, SLT_Begin, "req %u rxreq", sp->vxid & VSL_IDENTMASK); - VSL(SLT_Link, req->sp->vxid, "req %u rxreq", - req->vsl->wid & VSL_IDENTMASK); p += sz; p = (void*)PRNDUP(p); diff --git a/bin/varnishtest/tests/r01441.vtc b/bin/varnishtest/tests/r01441.vtc new file mode 100644 index 0000000..ec9553d --- /dev/null +++ b/bin/varnishtest/tests/r01441.vtc @@ -0,0 +1,40 @@ +varnishtest "Session grouping on ESI" + +server s1 { + rxreq + expect req.url == "/" + txresp -body "" + + rxreq + expect req.url == "/include" + txresp -body "included" +} -start + +varnish v1 -vcl+backend { + sub vcl_backend_response { + if (bereq.url == "/") { + set beresp.do_esi = true; + } + } +} -start + +logexpect l1 -v v1 -g session { + expect 0 1000 Begin sess 0 HTTP/1 + expect * = End + expect 0 1001 Begin req 1000 rxreq + expect * = End + expect 0 1002 Begin bereq 1001 fetch + expect * = End + expect 0 1003 Begin req 1001 esi + expect * = End + expect 0 1004 Begin bereq 1003 fetch + expect * = End +} -start + +client c1 { + txreq -url "/" + rxresp + expect resp.status == 200 +} -run + +logexpect l1 -wait From fgsch at lodoss.net Thu Feb 27 18:23:17 2014 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Thu, 27 Feb 2014 19:23:17 +0100 Subject: [master] 9dbe0ec Rename =build to build Message-ID: commit 9dbe0ec2bcf6a3fa2d48f40812b13a38fbb92cc3 Author: Federico G. Schwindt Date: Thu Feb 27 18:22:55 2014 +0000 Rename =build to build Forgotten in 339b68f9 diff --git a/doc/sphinx/Makefile.phk b/doc/sphinx/Makefile.phk index 18197a6..fea357f 100644 --- a/doc/sphinx/Makefile.phk +++ b/doc/sphinx/Makefile.phk @@ -5,7 +5,7 @@ SPHINXOPTS = SPHINXBUILD = sphinx-build PAPER = -BUILDDIR = =build +BUILDDIR = build # Internal variables. PAPEROPT_a4 = -D latex_paper_size=a4 diff --git a/doc/sphinx/conf.py.in b/doc/sphinx/conf.py.in index d825d6b..f68a20f 100644 --- a/doc/sphinx/conf.py.in +++ b/doc/sphinx/conf.py.in @@ -64,7 +64,7 @@ release = '@VERSION@' # List of directories, relative to source directory, that shouldn't be searched # for source files. -exclude_patterns = ['=build','reference/params.rst'] +exclude_patterns = ['build','reference/params.rst'] # The reST default role (used for this markup: `text`) to use for all documents. #default_role = None diff --git a/redhat/varnish.spec b/redhat/varnish.spec index 81ad6f1..6f35ecc 100644 --- a/redhat/varnish.spec +++ b/redhat/varnish.spec @@ -118,9 +118,9 @@ make %{?_smp_mflags} V=1 redhat/varnish.initrc redhat/varnishlog.initrc redhat/varnishncsa.initrc %endif -rm -rf doc/sphinx/\=build/html/_sources -mv doc/sphinx/\=build/html doc -rm -rf doc/sphinx/\=build +rm -rf doc/sphinx/build/html/_sources +mv doc/sphinx/build/html doc +rm -rf doc/sphinx/build %check # rhel5 on ppc64 is just too strange