From dridi.boukelmoune at gmail.com Tue Dec 1 17:02:32 2015 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 01 Dec 2015 18:02:32 +0100 Subject: [master] 445854c Reserve space for the "cooling" state in vcl.list Message-ID: commit 445854c072e328ab484589c8f9122ed36dff943d Author: Dridi Boukelmoune Date: Tue Dec 1 12:30:16 2015 +0100 Reserve space for the "cooling" state in vcl.list A VCL may show up as auto/cooling in the CLI, breaking the columns align in the output. Also for 4.1 diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c index c747ead..469fcf9 100644 --- a/bin/varnishd/cache/cache_vcl.c +++ b/bin/varnishd/cache/cache_vcl.c @@ -554,7 +554,7 @@ ccf_config_list(struct cli *cli, const char * const *av, void *priv) flg = "discarded"; } else flg = "available"; - VCLI_Out(cli, "%-10s %4s/%s %6u %s\n", + VCLI_Out(cli, "%-10s %4s/%-8s %6u %s\n", flg, vcl->state, vcl->temp, vcl->busy, vcl->loaded_name); } } diff --git a/bin/varnishd/mgt/mgt_vcl.c b/bin/varnishd/mgt/mgt_vcl.c index bb298bb..b12bdb6 100644 --- a/bin/varnishd/mgt/mgt_vcl.c +++ b/bin/varnishd/mgt/mgt_vcl.c @@ -414,7 +414,7 @@ mcf_vcl_list(struct cli *cli, const char * const *av, void *priv) free(p); } else { VTAILQ_FOREACH(vp, &vclhead, list) { - VCLI_Out(cli, "%-10s %4s/%s %6s %s\n", + VCLI_Out(cli, "%-10s %4s/%-8s %6s %s\n", vp == active_vcl ? "active" : "available", vp->state, vp->warm ? "warm" : "cold", "", vp->name); From dridi.boukelmoune at gmail.com Tue Dec 1 17:02:32 2015 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 01 Dec 2015 18:02:32 +0100 Subject: [master] fbd1c18 Document that VCL_EVENT_USE is deprecated Message-ID: commit fbd1c18cc891cd915dd33be55afb43371de1c8a6 Author: Dridi Boukelmoune Date: Tue Dec 1 12:46:43 2015 +0100 Document that VCL_EVENT_USE is deprecated And stop using it in the test suite. Also for 4.1 diff --git a/bin/varnishtest/tests/v00044.vtc b/bin/varnishtest/tests/v00044.vtc index c3fd107..aa79e6a 100644 --- a/bin/varnishtest/tests/v00044.vtc +++ b/bin/varnishtest/tests/v00044.vtc @@ -7,7 +7,7 @@ server s1 -repeat 20 { close } -start -# The debug vmod logs some vcl events +# The debug vmod logs temperature vcl events varnish v1 -arg "-p vcl_cooldown=1" -vcl { import ${vmod_debug}; backend default { @@ -69,7 +69,6 @@ varnish v1 -clierr 106 "vcl.state vcl2 cold" logexpect l1 -v v1 -g raw { expect * 0 Debug "vcl1: VCL_EVENT_COLD" expect * 0 Debug "vcl1: VCL_EVENT_WARM" - expect * 0 Debug "vcl1: VCL_EVENT_USE" } -start # ...when you use a cold VCL diff --git a/doc/sphinx/reference/vmod.rst b/doc/sphinx/reference/vmod.rst index 0d30162..fac9e70 100644 --- a/doc/sphinx/reference/vmod.rst +++ b/doc/sphinx/reference/vmod.rst @@ -358,10 +358,10 @@ Event functions VMODs can have an "event" function which is called when a VCL which imports the VMOD is loaded, made active, or discarded. This corresponds to the -``VCL_EVENT_LOAD``, ``VCL_EVENT_USE``, and ``VCL_EVENT_DISCARD`` events, -respectively. In addition, this function will be called when the VCL state is -changed to cold or warm, corresponding to the ``VCL_EVENT_COLD`` and -``VCL_EVENT_WARM`` events. +``VCL_EVENT_LOAD``, and ``VCL_EVENT_DISCARD`` events, respectively. In +addition, this function will be called when the VCL temperature is changed to +cold or warm, corresponding to the ``VCL_EVENT_COLD`` and ``VCL_EVENT_WARM`` +events. The first argument to the event function is a VRT context. @@ -379,11 +379,13 @@ discarded and free this global state when the count reaches zero. VMOD writers are *strongly* encouraged to release all per-VCL resources for a given VCL when it emits a ``VCL_EVENT_COLD`` event. You will get a chance to reacquire the resources before the VCL becomes active again and be notified -first with a ``VCL_EVENT_WARM`` event, and then a ``VCL_EVENT_USE`` event. -Unless a user decides that a given VCL should always be warm, an inactive VMOD -will eventually become cold and should manage resources accordingly. +first with a ``VCL_EVENT_WARM`` event. Unless a user decides that a given VCL +should always be warm, an inactive VMOD will eventually become cold and should +manage resources accordingly. -.. TODO vmod objects +There is also a ``VCL_EVENT_USE`` event. Please note that this event is now +deprecated and may be removed in a future release. A warm VCL should be ready +to use so no additional task should be postponed at use time. When to lock, and when not to lock ================================== diff --git a/lib/libvmod_debug/vmod_debug.c b/lib/libvmod_debug/vmod_debug.c index 732d89a..b065b7f 100644 --- a/lib/libvmod_debug/vmod_debug.c +++ b/lib/libvmod_debug/vmod_debug.c @@ -258,7 +258,6 @@ event_function(VRT_CTX, struct vmod_priv *priv, enum vcl_event_e e) switch (e) { case VCL_EVENT_COLD: ev = "VCL_EVENT_COLD"; break; case VCL_EVENT_WARM: ev = "VCL_EVENT_WARM"; break; - case VCL_EVENT_USE: ev = "VCL_EVENT_USE"; break; default: ev = NULL; } From dridi.boukelmoune at gmail.com Tue Dec 1 17:02:32 2015 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 01 Dec 2015 18:02:32 +0100 Subject: [master] efd5dfd VMODs handling of VCL_EVENT_COLD must be failsafe Message-ID: commit efd5dfda5b8314d7443fcbc8c2e0ddfb79049bf3 Author: Dridi Boukelmoune Date: Tue Dec 1 15:48:38 2015 +0100 VMODs handling of VCL_EVENT_COLD must be failsafe Also for 4.1 diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c index 469fcf9..cdd4124 100644 --- a/bin/varnishd/cache/cache_vcl.c +++ b/bin/varnishd/cache/cache_vcl.c @@ -404,7 +404,7 @@ vcl_set_state(struct vcl *vcl, const char *state) break; if (vcl->busy == 0) { vcl->temp = vcl_temp_cold; - (void)vcl->conf->event_vcl(&ctx, VCL_EVENT_COLD); + AZ(vcl->conf->event_vcl(&ctx, VCL_EVENT_COLD)); vcl_BackendEvent(vcl, VCL_EVENT_COLD); } else { vcl->temp = vcl_temp_cooling; From dridi.boukelmoune at gmail.com Tue Dec 1 17:02:32 2015 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 01 Dec 2015 18:02:32 +0100 Subject: [master] c503bb7 Avoid connection attempts to ${bad_ip}:80 Message-ID: commit c503bb741552061618d28733c1b8e640c6b74401 Author: Dridi Boukelmoune Date: Tue Dec 1 16:37:01 2015 +0100 Avoid connection attempts to ${bad_ip}:80 There is a Squid server listening in today's office... diff --git a/bin/varnishtest/tests/b00015.vtc b/bin/varnishtest/tests/b00015.vtc index e26b16d..ec1990f 100644 --- a/bin/varnishtest/tests/b00015.vtc +++ b/bin/varnishtest/tests/b00015.vtc @@ -4,7 +4,8 @@ varnishtest "Check synthetic error page caching" varnish v1 -vcl { backend foo { - .host = "${bad_ip}"; .port = "9080"; + .host = "${bad_ip}"; + .port = "9080"; } } -start diff --git a/bin/varnishtest/tests/b00017.vtc b/bin/varnishtest/tests/b00017.vtc index 81776bb..d0088aa 100644 --- a/bin/varnishtest/tests/b00017.vtc +++ b/bin/varnishtest/tests/b00017.vtc @@ -2,7 +2,8 @@ varnishtest "Check that we do not close one error" varnish v1 -vcl { backend foo { - .host = "${bad_ip}"; .port = "9080"; + .host = "${bad_ip}"; + .port = "9080"; } sub vcl_recv { return (synth(888)); diff --git a/bin/varnishtest/tests/c00028.vtc b/bin/varnishtest/tests/c00028.vtc index 10caf43..7ecfb7c 100644 --- a/bin/varnishtest/tests/c00028.vtc +++ b/bin/varnishtest/tests/c00028.vtc @@ -2,7 +2,8 @@ varnishtest "Test that we can't recurse restarts forever" varnish v1 -vcl { backend bad { - .host = "${bad_ip}"; .port = "9090"; + .host = "${bad_ip}"; + .port = "9090"; } sub vcl_backend_fetch { diff --git a/bin/varnishtest/tests/c00061.vtc b/bin/varnishtest/tests/c00061.vtc index ef2ae76..b22f259 100644 --- a/bin/varnishtest/tests/c00061.vtc +++ b/bin/varnishtest/tests/c00061.vtc @@ -2,7 +2,7 @@ varnishtest "retry in vcl_backend_error" varnish v1 -vcl { - backend b1 { .host = "${bad_ip}"; } + backend b1 { .host = "${bad_ip}"; .port = "9080"; } sub vcl_backend_error { return (retry); diff --git a/bin/varnishtest/tests/c00063.vtc b/bin/varnishtest/tests/c00063.vtc index 0da903e..9da60a0 100644 --- a/bin/varnishtest/tests/c00063.vtc +++ b/bin/varnishtest/tests/c00063.vtc @@ -2,7 +2,7 @@ varnishtest "cache backend synth object" varnish v1 -vcl { - backend b { .host = "${bad_ip}"; } + backend b { .host = "${bad_ip}"; .port = "9080"; } sub vcl_backend_error { set beresp.ttl = 1s; diff --git a/bin/varnishtest/tests/c00066.vtc b/bin/varnishtest/tests/c00066.vtc index ec88da6..14d4126 100644 --- a/bin/varnishtest/tests/c00066.vtc +++ b/bin/varnishtest/tests/c00066.vtc @@ -6,7 +6,7 @@ server s1 { } -start varnish v1 -vcl+backend { - backend bad { .host = "${bad_ip}"; } + backend bad { .host = "${bad_ip}"; .port = "9080"; } sub vcl_recv { if (req.url == "/synth") { return (synth(200, "Synth test")); diff --git a/bin/varnishtest/tests/d00007.vtc b/bin/varnishtest/tests/d00007.vtc index 298fbf7..26112e6 100644 --- a/bin/varnishtest/tests/d00007.vtc +++ b/bin/varnishtest/tests/d00007.vtc @@ -8,7 +8,7 @@ server s1 { varnish v1 -vcl { import ${vmod_debug}; - backend dummy { .host = "${bad_ip}"; } + backend dummy { .host = "${bad_ip}"; .port = "9080"; } sub vcl_init { new s1 = debug.dyn("${s1_addr}", "${s1_port}"); diff --git a/bin/varnishtest/tests/d00008.vtc b/bin/varnishtest/tests/d00008.vtc index a30edd8..79096b9 100644 --- a/bin/varnishtest/tests/d00008.vtc +++ b/bin/varnishtest/tests/d00008.vtc @@ -15,7 +15,7 @@ server s2 { varnish v1 -vcl { import ${vmod_debug}; - backend dummy { .host = "${bad_ip}"; } + backend dummy { .host = "${bad_ip}"; .port = "9080"; } sub vcl_init { new s1 = debug.dyn("${s1_addr}", "${s1_port}"); diff --git a/bin/varnishtest/tests/d00009.vtc b/bin/varnishtest/tests/d00009.vtc index c888d20..46d05c4 100644 --- a/bin/varnishtest/tests/d00009.vtc +++ b/bin/varnishtest/tests/d00009.vtc @@ -18,7 +18,7 @@ server s2 { varnish v1 -vcl { import ${vmod_debug}; - backend dummy { .host = "${bad_ip}"; } + backend dummy { .host = "${bad_ip}"; .port = "9080"; } sub vcl_init { new s1 = debug.dyn("${s1_addr}", "${s1_port}"); diff --git a/bin/varnishtest/tests/d00010.vtc b/bin/varnishtest/tests/d00010.vtc index 1db0ea7..145112a 100644 --- a/bin/varnishtest/tests/d00010.vtc +++ b/bin/varnishtest/tests/d00010.vtc @@ -18,7 +18,7 @@ server s2 { varnish v1 -vcl { import ${vmod_debug}; - backend dummy { .host = "${bad_ip}"; } + backend dummy { .host = "${bad_ip}"; .port = "9080"; } sub vcl_init { new s1 = debug.dyn("${s1_addr}", "${s1_port}"); diff --git a/bin/varnishtest/tests/d00011.vtc b/bin/varnishtest/tests/d00011.vtc index 01d45a1..639161e 100644 --- a/bin/varnishtest/tests/d00011.vtc +++ b/bin/varnishtest/tests/d00011.vtc @@ -12,7 +12,7 @@ varnish v1 -vcl { import ${vmod_std}; import ${vmod_debug}; - backend dummy { .host = "${bad_ip}"; } + backend dummy { .host = "${bad_ip}"; .port = "9080"; } sub vcl_init { new s1 = debug.dyn("${s1_addr}", "${s1_port}"); diff --git a/bin/varnishtest/tests/d00012.vtc b/bin/varnishtest/tests/d00012.vtc index 74aaa8d..41d23e4 100644 --- a/bin/varnishtest/tests/d00012.vtc +++ b/bin/varnishtest/tests/d00012.vtc @@ -12,7 +12,7 @@ server s1 { varnish v1 -arg "-p thread_pools=1" -vcl { import ${vmod_debug}; - backend dummy { .host = "${bad_ip}"; } + backend dummy { .host = "${bad_ip}"; .port = "9080"; } sub vcl_init { new s1 = debug.dyn("${s1_addr}", "${s1_port}"); @@ -41,7 +41,7 @@ server s2 { varnish v1 -vcl { import ${vmod_debug}; - backend dummy { .host = "${bad_ip}"; } + backend dummy { .host = "${bad_ip}"; .port = "9080"; } sub vcl_init { new s2 = debug.dyn("${s2_addr}", "${s2_port}"); diff --git a/bin/varnishtest/tests/d00013.vtc b/bin/varnishtest/tests/d00013.vtc index 25ab33f..6762f41 100644 --- a/bin/varnishtest/tests/d00013.vtc +++ b/bin/varnishtest/tests/d00013.vtc @@ -12,7 +12,7 @@ varnish v1 -vcl { import ${vmod_std}; import ${vmod_debug}; - backend dummy { .host = "${bad_ip}"; } + backend dummy { .host = "${bad_ip}"; .port = "9080"; } sub vcl_init { new s1 = debug.dyn("${s1_addr}", "${s1_port}"); diff --git a/bin/varnishtest/tests/r01002.vtc b/bin/varnishtest/tests/r01002.vtc index 2697d77..6e9e3fd 100644 --- a/bin/varnishtest/tests/r01002.vtc +++ b/bin/varnishtest/tests/r01002.vtc @@ -3,7 +3,7 @@ varnishtest "Real relational comparisons" varnish v1 -vcl { import ${vmod_std}; - backend foo { .host = "${bad_ip}"; } + backend foo { .host = "${bad_ip}"; .port = "9080"; } sub vcl_recv { if (std.random(0,5) < 1.0) { return (pipe); diff --git a/bin/varnishtest/tests/r01395.vtc b/bin/varnishtest/tests/r01395.vtc index 591bb2e..06962db 100644 --- a/bin/varnishtest/tests/r01395.vtc +++ b/bin/varnishtest/tests/r01395.vtc @@ -2,7 +2,8 @@ varnishtest "Test vcl_synth is called even if vcl_backend_fetch failed" varnish v1 -vcl { backend default { - .host = "${bad_ip}"; .port = "9090"; + .host = "${bad_ip}"; + .port = "9090"; } sub vcl_backend_error { diff --git a/bin/varnishtest/tests/r01398.vtc b/bin/varnishtest/tests/r01398.vtc index fe89e0d..ec0003e 100644 --- a/bin/varnishtest/tests/r01398.vtc +++ b/bin/varnishtest/tests/r01398.vtc @@ -2,7 +2,8 @@ varnishtest "ticket 1398" varnish v1 -vcl { backend foo { - .host = "${bad_ip}"; .port = "9080"; + .host = "${bad_ip}"; + .port = "9080"; } sub vcl_backend_response { set beresp.http.X-BE-Name = beresp.backend.name; diff --git a/bin/varnishtest/tests/r01504.vtc b/bin/varnishtest/tests/r01504.vtc index 0277c65..8a466f7 100644 --- a/bin/varnishtest/tests/r01504.vtc +++ b/bin/varnishtest/tests/r01504.vtc @@ -3,6 +3,7 @@ varnishtest "unreferenced acls" varnish v1 -arg "-p vcc_err_unref=off" -vcl { backend s1 { .host = "${bad_ip}"; + .port = "9090"; } acl foo { "127.0.0.1"; diff --git a/bin/varnishtest/tests/r01510.vtc b/bin/varnishtest/tests/r01510.vtc index 47b87cb..6b74f54 100644 --- a/bin/varnishtest/tests/r01510.vtc +++ b/bin/varnishtest/tests/r01510.vtc @@ -11,7 +11,7 @@ varnish v1 -errvcl {Object name 'first' already used.} { varnish v1 -errvcl {Object name 'first' already used.} { import ${vmod_debug}; - backend first { .host = "${bad_ip}"; } + backend first { .host = "${bad_ip}"; .port = "9080"; } sub vcl_init { new first = debug.obj("FOO"); diff --git a/bin/varnishtest/tests/r01512.vtc b/bin/varnishtest/tests/r01512.vtc index 71496a2..87556f1 100644 --- a/bin/varnishtest/tests/r01512.vtc +++ b/bin/varnishtest/tests/r01512.vtc @@ -33,7 +33,7 @@ client c1 { # Then across v_b_e and v_b_f varnish v1 -vcl { - backend bad { .host = "${bad_ip}"; } + backend bad { .host = "${bad_ip}"; .port = "9080"; } sub vcl_backend_fetch { set bereq.backend = bad; if (bereq.http.x-abandon == "2") { diff --git a/bin/varnishtest/tests/r01730.vtc b/bin/varnishtest/tests/r01730.vtc index 2e15ead..e54a410 100644 --- a/bin/varnishtest/tests/r01730.vtc +++ b/bin/varnishtest/tests/r01730.vtc @@ -1,7 +1,7 @@ varnishtest "Test connection error on pipe" varnish v1 -vcl { - backend default { .host = "${bad_ip}"; } + backend default { .host = "${bad_ip}"; .port = "9080"; } sub vcl_recv { return (pipe); } From dridi.boukelmoune at gmail.com Tue Dec 1 17:05:16 2015 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Tue, 01 Dec 2015 09:05:16 -0800 Subject: [varnishcache/varnish-cache] 445854: Reserve space for the "cooling" state in vcl.list Message-ID: <565dd34cbfb87_498c3fcc409c92c076727@hookshot-fe6-cp1-prd.iad.github.net.mail> Branch: refs/heads/master Home: https://github.com/varnishcache/varnish-cache Commit: 445854c072e328ab484589c8f9122ed36dff943d https://github.com/varnishcache/varnish-cache/commit/445854c072e328ab484589c8f9122ed36dff943d Author: Dridi Boukelmoune Date: 2015-12-01 (Tue, 01 Dec 2015) Changed paths: M bin/varnishd/cache/cache_vcl.c M bin/varnishd/mgt/mgt_vcl.c Log Message: ----------- Reserve space for the "cooling" state in vcl.list A VCL may show up as auto/cooling in the CLI, breaking the columns align in the output. Also for 4.1 Commit: fbd1c18cc891cd915dd33be55afb43371de1c8a6 https://github.com/varnishcache/varnish-cache/commit/fbd1c18cc891cd915dd33be55afb43371de1c8a6 Author: Dridi Boukelmoune Date: 2015-12-01 (Tue, 01 Dec 2015) Changed paths: M bin/varnishtest/tests/v00044.vtc M doc/sphinx/reference/vmod.rst M lib/libvmod_debug/vmod_debug.c Log Message: ----------- Document that VCL_EVENT_USE is deprecated And stop using it in the test suite. Also for 4.1 Commit: efd5dfda5b8314d7443fcbc8c2e0ddfb79049bf3 https://github.com/varnishcache/varnish-cache/commit/efd5dfda5b8314d7443fcbc8c2e0ddfb79049bf3 Author: Dridi Boukelmoune Date: 2015-12-01 (Tue, 01 Dec 2015) Changed paths: M bin/varnishd/cache/cache_vcl.c Log Message: ----------- VMODs handling of VCL_EVENT_COLD must be failsafe Also for 4.1 Commit: c503bb741552061618d28733c1b8e640c6b74401 https://github.com/varnishcache/varnish-cache/commit/c503bb741552061618d28733c1b8e640c6b74401 Author: Dridi Boukelmoune Date: 2015-12-01 (Tue, 01 Dec 2015) Changed paths: M bin/varnishtest/tests/b00015.vtc M bin/varnishtest/tests/b00017.vtc M bin/varnishtest/tests/c00028.vtc M bin/varnishtest/tests/c00061.vtc M bin/varnishtest/tests/c00063.vtc M bin/varnishtest/tests/c00066.vtc M bin/varnishtest/tests/d00007.vtc M bin/varnishtest/tests/d00008.vtc M bin/varnishtest/tests/d00009.vtc M bin/varnishtest/tests/d00010.vtc M bin/varnishtest/tests/d00011.vtc M bin/varnishtest/tests/d00012.vtc M bin/varnishtest/tests/d00013.vtc M bin/varnishtest/tests/r01002.vtc M bin/varnishtest/tests/r01395.vtc M bin/varnishtest/tests/r01398.vtc M bin/varnishtest/tests/r01504.vtc M bin/varnishtest/tests/r01510.vtc M bin/varnishtest/tests/r01512.vtc M bin/varnishtest/tests/r01730.vtc Log Message: ----------- Avoid connection attempts to ${bad_ip}:80 There is a Squid server listening in today's office... Compare: https://github.com/varnishcache/varnish-cache/compare/1c7f56d5ef14...c503bb741552 From lkarsten at varnish-software.com Fri Dec 4 10:09:03 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Fri, 04 Dec 2015 11:09:03 +0100 Subject: [master] 37ad0f5 Minor cleanup of varnishadm man page. Message-ID: commit 37ad0f5d6281a53007993f5ba91b82b42abadeae Author: Lasse Karstensen Date: Fri Dec 4 11:06:03 2015 +0100 Minor cleanup of varnishadm man page. * Adhere to current style guide. * Sort argument list. * Add missing reference to related man pages. diff --git a/doc/sphinx/reference/varnishadm.rst b/doc/sphinx/reference/varnishadm.rst index 41e879a..4f24c2c 100644 --- a/doc/sphinx/reference/varnishadm.rst +++ b/doc/sphinx/reference/varnishadm.rst @@ -14,15 +14,16 @@ Control a running Varnish instance SYNOPSIS ======== -varnishadm [-t timeout] [-S secret_file] [-T address:port] [-n name] [command [...]] +varnishadm [-n ident] [-t timeout] [-S secretfile] -T [address]:port [command [...]] + DESCRIPTION =========== -The varnishadm utility establishes a CLI connection to varnishd either +The `varnishadm` utility establishes a CLI connection to varnishd either using -n *name* or using the -T and -S arguments. If -n *name* is given the location of the secret file and the address:port is looked -up in shared memory. If neither is given varnishadm will look for an +up in shared memory. If neither is given `varnishadm` will look for an instance without a given name. If a command is given, the command and arguments are sent over the CLI @@ -34,16 +35,16 @@ replies between the CLI socket and stdin/stdout. OPTIONS ======= --t timeout - Wait no longer than this many seconds for an operation to finish. +-n ident + Connect to the instance of `varnishd` with this name. --S secret_file +-S secretfile Specify the authentication secret file. This should be the same -S - argument as was given to varnishd. Only processes which can read + 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. +-t timeout + Wait no longer than this many seconds for an operation to finish. -T Connect to the management interface at the specified address and port. @@ -60,7 +61,7 @@ the *param.show* command. EXIT STATUS =========== -If a command is given, the exit status of the varnishadm utility is +If a command is given, the exit status of the `varnishadm` utility is zero if the command succeeded, and non-zero otherwise. EXAMPLES @@ -76,6 +77,7 @@ SEE ALSO ======== * :ref:`varnishd(1)` +* :ref:`varnish-cli(7)` HISTORY ======= From lkarsten at varnish-software.com Fri Dec 4 10:10:13 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Fri, 04 Dec 2015 02:10:13 -0800 Subject: [varnishcache/varnish-cache] 37ad0f: Minor cleanup of varnishadm man page. Message-ID: <56616685b2cd7_2b823fcdc209129c15491@hookshot-fe3-cp1-prd.iad.github.net.mail> Branch: refs/heads/master Home: https://github.com/varnishcache/varnish-cache Commit: 37ad0f5d6281a53007993f5ba91b82b42abadeae https://github.com/varnishcache/varnish-cache/commit/37ad0f5d6281a53007993f5ba91b82b42abadeae Author: Lasse Karstensen Date: 2015-12-04 (Fri, 04 Dec 2015) Changed paths: M doc/sphinx/reference/varnishadm.rst Log Message: ----------- Minor cleanup of varnishadm man page. * Adhere to current style guide. * Sort argument list. * Add missing reference to related man pages. From lkarsten at varnish-software.com Fri Dec 4 10:31:20 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Fri, 04 Dec 2015 11:31:20 +0100 Subject: [master] 8139164 Document what panic.clear -z does. Message-ID: commit 8139164be4e44c07569c7954a164e0d847503436 Author: Lasse Karstensen Date: Fri Dec 4 11:29:58 2015 +0100 Document what panic.clear -z does. diff --git a/doc/sphinx/reference/varnish-cli.rst b/doc/sphinx/reference/varnish-cli.rst index c55ecf8..390bbe9 100644 --- a/doc/sphinx/reference/varnish-cli.rst +++ b/doc/sphinx/reference/varnish-cli.rst @@ -133,7 +133,7 @@ panic.show Return the last panic, if any. panic.clear [-z] - Clear the last panic, if any. + Clear the last panic, if any. -z will clear related varnishstat counter(s). storage.list List storage devices. From lkarsten at varnish-software.com Fri Dec 4 10:31:20 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Fri, 04 Dec 2015 11:31:20 +0100 Subject: [master] d654c6e Fold history and copyright into an authors section. Message-ID: commit d654c6e56b20c8736a1812f4fd25931d1777e69e Author: Lasse Karstensen Date: Fri Dec 4 11:30:23 2015 +0100 Fold history and copyright into an authors section. diff --git a/doc/sphinx/reference/varnish-cli.rst b/doc/sphinx/reference/varnish-cli.rst index 390bbe9..cc716f6 100644 --- a/doc/sphinx/reference/varnish-cli.rst +++ b/doc/sphinx/reference/varnish-cli.rst @@ -305,24 +305,16 @@ the backend contains "USERID=1663":: req.http.host ~ "^(?i)(www\.)example.com$" && obj.http.set-cookie ~ "USERID=1663" +AUTHORS +======= + +This manual page was originally written by Per Buer and later modified by +Federico G. Schwindt, Dridi Boukelmoune, Lasse Karstensen and Poul-Henning +Kamp. + SEE ALSO ======== * :ref:`varnishadm(1)` * :ref:`varnishd(1)` * :ref:`vcl(7)` - -HISTORY -======= - -The Varnish manual page was written by Per Buer in 2011. Some of the -text was taken from the Varnish Cache wiki, the :ref:`varnishd(1)` man -page or the Varnish source code. - -COPYRIGHT -========= - -This document is licensed under the same licence as Varnish -itself. See LICENCE for details. - -* Copyright (c) 2011-2015 Varnish Software AS From lkarsten at varnish-software.com Fri Dec 4 10:35:13 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Fri, 04 Dec 2015 02:35:13 -0800 Subject: [varnishcache/varnish-cache] 813916: Document what panic.clear -z does. Message-ID: <56616c6196907_2fe43fd4f254129c19273@hookshot-fe4-cp1-prd.iad.github.net.mail> Branch: refs/heads/master Home: https://github.com/varnishcache/varnish-cache Commit: 8139164be4e44c07569c7954a164e0d847503436 https://github.com/varnishcache/varnish-cache/commit/8139164be4e44c07569c7954a164e0d847503436 Author: Lasse Karstensen Date: 2015-12-04 (Fri, 04 Dec 2015) Changed paths: M doc/sphinx/reference/varnish-cli.rst Log Message: ----------- Document what panic.clear -z does. Commit: d654c6e56b20c8736a1812f4fd25931d1777e69e https://github.com/varnishcache/varnish-cache/commit/d654c6e56b20c8736a1812f4fd25931d1777e69e Author: Lasse Karstensen Date: 2015-12-04 (Fri, 04 Dec 2015) Changed paths: M doc/sphinx/reference/varnish-cli.rst Log Message: ----------- Fold history and copyright into an authors section. Compare: https://github.com/varnishcache/varnish-cache/compare/37ad0f5d6281...d654c6e56b20 From lkarsten at varnish-software.com Fri Dec 4 10:55:46 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Fri, 04 Dec 2015 11:55:46 +0100 Subject: [master] 87e98de Add extra sentence on -z in inline help as well. Message-ID: commit 87e98def99ef0844615149bed0040864daed24f5 Author: Lasse Karstensen Date: Fri Dec 4 11:46:06 2015 +0100 Add extra sentence on -z in inline help as well. Forgotten in commit 8139164. diff --git a/include/vcli.h b/include/vcli.h index da61d30..de6e324 100644 --- a/include/vcli.h +++ b/include/vcli.h @@ -168,7 +168,7 @@ #define CLI_PANIC_CLEAR \ "panic.clear", \ "panic.clear [-z]", \ - "\tClear the last panic, if any.", \ + "\tClear the last panic, if any. -z will clear related varnishstat counter(s)", \ 0, 1 /* From lkarsten at varnish-software.com Fri Dec 4 10:55:46 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Fri, 04 Dec 2015 11:55:46 +0100 Subject: [master] 8c28f42 Update usage text to reflect reality. Message-ID: commit 8c28f42849f77bcd773553bdc7315ccd42395c12 Author: Lasse Karstensen Date: Fri Dec 4 11:54:18 2015 +0100 Update usage text to reflect reality. Update built-in usage text to reflect that -T is optional. diff --git a/bin/varnishadm/varnishadm.c b/bin/varnishadm/varnishadm.c index 12650b2..621d696 100644 --- a/bin/varnishadm/varnishadm.c +++ b/bin/varnishadm/varnishadm.c @@ -380,8 +380,8 @@ static void usage(void) { fprintf(stderr, - "usage: varnishadm [-n ident] [-t timeout] [-S secretfile] " - "-T [address]:port command [...]\n"); + "Usage: varnishadm [-n ident] [-t timeout] [-S secretfile] " + "[-T [address]:port] [command [...]]\n"); fprintf(stderr, "\t-n is mutually exclusive with -S and -T\n"); exit(1); } diff --git a/doc/sphinx/reference/varnishadm.rst b/doc/sphinx/reference/varnishadm.rst index 4f24c2c..29a34ec 100644 --- a/doc/sphinx/reference/varnishadm.rst +++ b/doc/sphinx/reference/varnishadm.rst @@ -14,7 +14,7 @@ Control a running Varnish instance SYNOPSIS ======== -varnishadm [-n ident] [-t timeout] [-S secretfile] -T [address]:port [command [...]] +varnishadm [-n ident] [-t timeout] [-S secretfile] [-T [address]:port] [command [...]] DESCRIPTION From lkarsten at varnish-software.com Fri Dec 4 10:55:46 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Fri, 04 Dec 2015 11:55:46 +0100 Subject: [master] 4f966f8 Fold history into authors. Message-ID: commit 4f966f809ba41158834dfff401ea810d56453119 Author: Lasse Karstensen Date: Fri Dec 4 11:55:37 2015 +0100 Fold history into authors. diff --git a/doc/sphinx/reference/varnishadm.rst b/doc/sphinx/reference/varnishadm.rst index 29a34ec..395a72a 100644 --- a/doc/sphinx/reference/varnishadm.rst +++ b/doc/sphinx/reference/varnishadm.rst @@ -29,7 +29,7 @@ instance without a given name. If a command is given, the command and arguments are sent over the CLI connection and the result returned on stdout. -If no command argument is given varnishadm will pass commands and +If no command argument is given `varnishadm` will pass commands and replies between the CLI socket and stdin/stdout. OPTIONS @@ -79,17 +79,9 @@ SEE ALSO * :ref:`varnishd(1)` * :ref:`varnish-cli(7)` -HISTORY +AUTHORS ======= -The varnishadm utility and this manual page were written by Cecilie -Fritzvold. Converted to reStructuredText and updated in 2010 by Per -Buer. - -COPYRIGHT -========= - -This document is licensed under the same licence as Varnish -itself. See LICENCE for details. - -* Copyright (c) 2007-2015 Varnish Software AS +The `varnishadm` utility and this manual page were written by Cecilie +Fritzvold. This man page has later been modified by Per Buer, Federico G. +Schwindt and Lasse Karstensen. From lkarsten at varnish-software.com Fri Dec 4 11:00:13 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Fri, 04 Dec 2015 03:00:13 -0800 Subject: [varnishcache/varnish-cache] 87e98d: Add extra sentence on -z in inline help as well. Message-ID: <5661723db9664_2c8c3ff26d1bb29c209f1@hookshot-fe3-cp1-prd.iad.github.net.mail> Branch: refs/heads/master Home: https://github.com/varnishcache/varnish-cache Commit: 87e98def99ef0844615149bed0040864daed24f5 https://github.com/varnishcache/varnish-cache/commit/87e98def99ef0844615149bed0040864daed24f5 Author: Lasse Karstensen Date: 2015-12-04 (Fri, 04 Dec 2015) Changed paths: M include/vcli.h Log Message: ----------- Add extra sentence on -z in inline help as well. Forgotten in commit 8139164. Commit: 8c28f42849f77bcd773553bdc7315ccd42395c12 https://github.com/varnishcache/varnish-cache/commit/8c28f42849f77bcd773553bdc7315ccd42395c12 Author: Lasse Karstensen Date: 2015-12-04 (Fri, 04 Dec 2015) Changed paths: M bin/varnishadm/varnishadm.c M doc/sphinx/reference/varnishadm.rst Log Message: ----------- Update usage text to reflect reality. Update built-in usage text to reflect that -T is optional. Commit: 4f966f809ba41158834dfff401ea810d56453119 https://github.com/varnishcache/varnish-cache/commit/4f966f809ba41158834dfff401ea810d56453119 Author: Lasse Karstensen Date: 2015-12-04 (Fri, 04 Dec 2015) Changed paths: M doc/sphinx/reference/varnishadm.rst Log Message: ----------- Fold history into authors. Compare: https://github.com/varnishcache/varnish-cache/compare/d654c6e56b20...4f966f809ba4 From lkarsten at varnish-software.com Fri Dec 4 11:01:50 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Fri, 04 Dec 2015 12:01:50 +0100 Subject: [master] e97964a Add some examples of backend expressions. Message-ID: commit e97964a17d390ca2e7df7510725213b6448484a3 Author: Lasse Karstensen Date: Fri Dec 4 12:00:36 2015 +0100 Add some examples of backend expressions. diff --git a/doc/sphinx/reference/varnish-cli.rst b/doc/sphinx/reference/varnish-cli.rst index cc716f6..3149b83 100644 --- a/doc/sphinx/reference/varnish-cli.rst +++ b/doc/sphinx/reference/varnish-cli.rst @@ -159,6 +159,14 @@ name, IP address and port in "name(IP address:port)" format. All fields are optional. If no exact matching backend is found, partial matching will be attempted based on the provided name, IP address and port fields. +Examples:: + + backend.list def* + backend.set_health default sick + backend.set_health def* healthy + backend.set_health * auto + + Ban Expressions --------------- From lkarsten at varnish-software.com Fri Dec 4 11:05:12 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Fri, 04 Dec 2015 03:05:12 -0800 Subject: [varnishcache/varnish-cache] e97964: Add some examples of backend expressions. Message-ID: <56617368e1bb3_44dd3f90f3b8b2bc23095@hookshot-fe5-cp1-prd.iad.github.net.mail> Branch: refs/heads/master Home: https://github.com/varnishcache/varnish-cache Commit: e97964a17d390ca2e7df7510725213b6448484a3 https://github.com/varnishcache/varnish-cache/commit/e97964a17d390ca2e7df7510725213b6448484a3 Author: Lasse Karstensen Date: 2015-12-04 (Fri, 04 Dec 2015) Changed paths: M doc/sphinx/reference/varnish-cli.rst Log Message: ----------- Add some examples of backend expressions. From martin at varnish-software.com Fri Dec 4 12:13:23 2015 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Fri, 04 Dec 2015 13:13:23 +0100 Subject: [master] 765b6d3 Restart epoll_wait on EINTR error Message-ID: commit 765b6d3b3bb6f96e2c5945abe998ba9016327116 Author: Martin Blix Grydeland Date: Fri Dec 4 13:12:05 2015 +0100 Restart epoll_wait on EINTR error This works around a Linux kernel bug where the epoll_wait will return EINTR when the process is subjected to a ptrace or the OS wakes from suspend. Fixes: #1763 diff --git a/bin/varnishd/waiter/cache_waiter_epoll.c b/bin/varnishd/waiter/cache_waiter_epoll.c index cb6dbdc..f50ae46 100644 --- a/bin/varnishd/waiter/cache_waiter_epoll.c +++ b/bin/varnishd/waiter/cache_waiter_epoll.c @@ -38,6 +38,7 @@ #include #include +#include #include "cache/cache.h" @@ -110,7 +111,12 @@ vwe_thread(void *priv) i = (int)ceil(1e3 * then); assert(i > 0); Lck_Unlock(&vwe->mtx); - n = epoll_wait(vwe->epfd, ev, NEEV, i); + do { + /* Due to a linux kernel bug, epoll_wait can + return EINTR when the process is subjected to + ptrace or waking from OS suspend. */ + n = epoll_wait(vwe->epfd, ev, NEEV, i); + } while (n < 0 && errno == EINTR); assert(n >= 0); assert(n <= NEEV); now = VTIM_real(); From martin at varnish-software.com Fri Dec 4 12:15:13 2015 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Fri, 04 Dec 2015 04:15:13 -0800 Subject: [varnishcache/varnish-cache] 765b6d: Restart epoll_wait on EINTR error Message-ID: <566183d153980_46a23fcf8c86d29c842f3@hookshot-fe5-cp1-prd.iad.github.net.mail> Branch: refs/heads/master Home: https://github.com/varnishcache/varnish-cache Commit: 765b6d3b3bb6f96e2c5945abe998ba9016327116 https://github.com/varnishcache/varnish-cache/commit/765b6d3b3bb6f96e2c5945abe998ba9016327116 Author: Martin Blix Grydeland Date: 2015-12-04 (Fri, 04 Dec 2015) Changed paths: M bin/varnishd/waiter/cache_waiter_epoll.c Log Message: ----------- Restart epoll_wait on EINTR error This works around a Linux kernel bug where the epoll_wait will return EINTR when the process is subjected to a ptrace or the OS wakes from suspend. Fixes: #1763 From dridi.boukelmoune at gmail.com Fri Dec 4 15:03:22 2015 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 04 Dec 2015 16:03:22 +0100 Subject: [master] 16b8375 Clarify VRT_delete_backend a bit Message-ID: commit 16b8375210973852fa39afafad3239d382661fe5 Author: Dridi Boukelmoune Date: Fri Dec 4 15:09:02 2015 +0100 Clarify VRT_delete_backend a bit diff --git a/bin/varnishd/cache/cache_backend_cfg.c b/bin/varnishd/cache/cache_backend_cfg.c index 0a58de1..141a06a 100644 --- a/bin/varnishd/cache/cache_backend_cfg.c +++ b/bin/varnishd/cache/cache_backend_cfg.c @@ -152,6 +152,9 @@ VRT_delete_backend(VRT_CTX, struct director **dp) VTAILQ_REMOVE(&backends, be, list); VTAILQ_INSERT_TAIL(&cool_backends, be, list); Lck_Unlock(&be->mtx); + + // NB. The backend is still usable for the ongoing transactions, + // this is why we don't bust the director's magic number. } /*--------------------------------------------------------------------- From dridi.boukelmoune at gmail.com Fri Dec 4 15:03:22 2015 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 04 Dec 2015 16:03:22 +0100 Subject: [master] 50aeefc Allow VMODs to hold a reference on a warm VCL Message-ID: commit 50aeefcceec15b765b2be0bb45d5c2de057802fe Author: Dridi Boukelmoune Date: Fri Dec 4 15:24:19 2015 +0100 Allow VMODs to hold a reference on a warm VCL diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c index cdd4124..8f41773 100644 --- a/bin/varnishd/cache/cache_vcl.c +++ b/bin/varnishd/cache/cache_vcl.c @@ -61,6 +61,7 @@ struct vcl { char state[8]; char *loaded_name; unsigned busy; + unsigned refcount; unsigned discard; const char *temp; VTAILQ_HEAD(,backend) backend_list; @@ -244,6 +245,7 @@ vcl_KillBackends(struct vcl *vcl) CHECK_OBJ_NOTNULL(vcl, VCL_MAGIC); AZ(vcl->busy); + AZ(vcl->refcount); while (1) { be = VTAILQ_FIRST(&vcl->backend_list); if (be == NULL) @@ -366,6 +368,41 @@ VRT_count(VRT_CTX, unsigned u) ctx->vcl->conf->ref[u].line, ctx->vcl->conf->ref[u].pos); } +void +VRT_ref_vcl(VRT_CTX) +{ + struct vcl *vcl; + + ASSERT_CLI(); + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + + vcl = ctx->vcl; + CHECK_OBJ_NOTNULL(vcl, VCL_MAGIC); + xxxassert(vcl->temp == vcl_temp_warm); + + Lck_Lock(&vcl_mtx); + vcl->refcount++; + Lck_Unlock(&vcl_mtx); +} + +void +VRT_rel_vcl(VRT_CTX) +{ + struct vcl *vcl; + + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + + vcl = ctx->vcl; + CHECK_OBJ_NOTNULL(vcl, VCL_MAGIC); + assert(vcl->temp == vcl_temp_warm || vcl->temp == vcl_temp_cooling); + + Lck_Lock(&vcl_mtx); + assert(vcl->refcount > 0); + vcl->refcount--; + /* No garbage collection here, for the same reasons as in VCL_Rel. */ + Lck_Unlock(&vcl_mtx); +} + /*--------------------------------------------------------------------*/ static struct vcl * @@ -402,7 +439,7 @@ vcl_set_state(struct vcl *vcl, const char *state) vcl->temp = vcl_temp_cold; if (vcl->temp == vcl_temp_cold) break; - if (vcl->busy == 0) { + if (vcl->busy == 0 && vcl->refcount == 0) { vcl->temp = vcl_temp_cold; AZ(vcl->conf->event_vcl(&ctx, VCL_EVENT_COLD)); vcl_BackendEvent(vcl, VCL_EVENT_COLD); @@ -508,6 +545,7 @@ VCL_Nuke(struct vcl *vcl) assert(vcl != vcl_active); assert(vcl->discard); AZ(vcl->busy); + AZ(vcl->refcount); VTAILQ_REMOVE(&vcl_head, vcl, list); ctx.method = VCL_MET_FINI; ctx.handling = &hand; @@ -531,7 +569,7 @@ VCL_Poll(void) VTAILQ_FOREACH_SAFE(vcl, &vcl_head, list, vcl2) { if (vcl->temp == vcl_temp_cooling) vcl_set_state(vcl, "0"); - if (vcl->discard && vcl->busy == 0) + if (vcl->discard && vcl->busy == 0 && vcl->refcount == 0) VCL_Nuke(vcl); } } @@ -602,7 +640,7 @@ ccf_config_discard(struct cli *cli, const char * const *av, void *priv) vcl->discard = 1; Lck_Unlock(&vcl_mtx); - if (vcl->busy == 0) + if (vcl->busy == 0 && vcl->refcount == 0) VCL_Nuke(vcl); } diff --git a/doc/sphinx/reference/vmod.rst b/doc/sphinx/reference/vmod.rst index fac9e70..ad6e03f 100644 --- a/doc/sphinx/reference/vmod.rst +++ b/doc/sphinx/reference/vmod.rst @@ -383,6 +383,13 @@ first with a ``VCL_EVENT_WARM`` event. Unless a user decides that a given VCL should always be warm, an inactive VMOD will eventually become cold and should manage resources accordingly. +If your VMOD is running an asynchronous background job you can hold a reference +to the VCL to prevent it from going cold too soon and get the same guarantees +as backends with ongoing requests for instance. For that, you must acquire the +reference by calling ``VRT_ref_vcl`` when you receive a ``VCL_EVENT_WARM`` and +later calling ``VRT_rel_vcl`` once the background job is over. Receiving a +``VCL_EVENT_COLD`` is your cue to terminate any background job bound to a VCL. + There is also a ``VCL_EVENT_USE`` event. Please note that this event is now deprecated and may be removed in a future release. A warm VCL should be ready to use so no additional task should be postponed at use time. @@ -396,7 +403,7 @@ their own locking to protect shared resources. When a VCL is loaded or unloaded, the event and priv->free are run sequentially all in a single thread, and there is guaranteed to be no other activity related to this particular VCL, nor are -there init/fini activity in any other VCL or VMOD at this time. +there init/fini activity in any other VCL or VMOD at this time. That means that the VMOD init, and any object init/fini functions are already serialized in sensible order, and won't need any locking, diff --git a/include/vrt.h b/include/vrt.h index 2d0a012..2203bd8 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -295,6 +295,9 @@ struct vmod_priv { typedef int vmod_event_f(VRT_CTX, struct vmod_priv *, enum vcl_event_e); #endif +void VRT_ref_vcl(VRT_CTX); +void VRT_rel_vcl(VRT_CTX); + void VRT_priv_fini(const struct vmod_priv *p); struct vmod_priv *VRT_priv_task(VRT_CTX, void *vmod_id); struct vmod_priv *VRT_priv_top(VRT_CTX, void *vmod_id); From dridi.boukelmoune at gmail.com Fri Dec 4 15:03:22 2015 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 04 Dec 2015 16:03:22 +0100 Subject: [master] 3162873 Don't create backends on cooling VCLs, return NULL Message-ID: commit 3162873747e9241383626d9cb501f363f7931b4b Author: Dridi Boukelmoune Date: Fri Dec 4 15:44:44 2015 +0100 Don't create backends on cooling VCLs, return NULL diff --git a/bin/varnishd/cache/cache_backend.h b/bin/varnishd/cache/cache_backend.h index 17b90f0..0bc73ed 100644 --- a/bin/varnishd/cache/cache_backend.h +++ b/bin/varnishd/cache/cache_backend.h @@ -130,5 +130,5 @@ struct vbc *VBT_Get(struct tcp_pool *, double tmo, const struct backend *, void VBT_Wait(struct worker *, struct vbc *); /* cache_vcl.c */ -void VCL_AddBackend(struct vcl *, struct backend *); +int VCL_AddBackend(struct vcl *, struct backend *); void VCL_DelBackend(struct backend *); diff --git a/bin/varnishd/cache/cache_backend_cfg.c b/bin/varnishd/cache/cache_backend_cfg.c index 141a06a..ad96330 100644 --- a/bin/varnishd/cache/cache_backend_cfg.c +++ b/bin/varnishd/cache/cache_backend_cfg.c @@ -65,10 +65,12 @@ struct director * VRT_new_backend(VRT_CTX, const struct vrt_backend *vrt) { struct backend *b; + struct director *d; struct vsb *vsb; struct vcl *vcl; struct tcp_pool *tp = NULL; const struct vrt_backend_probe *vbp; + int retval; CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(vrt, VRT_BACKEND_MAGIC); @@ -123,9 +125,15 @@ VRT_new_backend(VRT_CTX, const struct vrt_backend *vrt) if (vbp != NULL) VBP_Insert(b, vbp, tp); - VCL_AddBackend(ctx->vcl, b); + retval = VCL_AddBackend(ctx->vcl, b); + + if (retval == 0) + return (b->director); - return (b->director); + d = b->director; + VRT_delete_backend(ctx, &d); + AZ(d); + return (NULL); } /*-------------------------------------------------------------------- diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c index 8f41773..a6d0c26 100644 --- a/bin/varnishd/cache/cache_vcl.c +++ b/bin/varnishd/cache/cache_vcl.c @@ -193,12 +193,16 @@ VCL_Rel(struct vcl **vcc) /*--------------------------------------------------------------------*/ -void +int VCL_AddBackend(struct vcl *vcl, struct backend *be) { CHECK_OBJ_NOTNULL(vcl, VCL_MAGIC); CHECK_OBJ_NOTNULL(be, BACKEND_MAGIC); + + if (vcl->temp == vcl_temp_cooling) + return (1); + Lck_Lock(&vcl_mtx); VTAILQ_INSERT_TAIL(&vcl->backend_list, be, vcl_list); Lck_Unlock(&vcl_mtx); @@ -208,6 +212,8 @@ VCL_AddBackend(struct vcl *vcl, struct backend *be) VBE_Event(be, VCL_EVENT_WARM); } else if (vcl->temp != vcl_temp_init) WRONG("Dynamic Backends can only be added to warm VCLs"); + + return (0); } void diff --git a/doc/sphinx/reference/directors.rst b/doc/sphinx/reference/directors.rst index 8ad919b..10e41d6 100644 --- a/doc/sphinx/reference/directors.rst +++ b/doc/sphinx/reference/directors.rst @@ -110,7 +110,9 @@ Finally, Varnish will take care of event propagation for *all* native backends, but dynamic backends can only be created when the VCL is warm. If your backends are created by an independent thread (basically outside of VCL scope) you must subscribe to VCL events and watch for VCL state (see -:ref:`ref-vmod-event-functions`). You are also encouraged to comply with the +:ref:`ref-vmod-event-functions`). Varnish will panic if you try to create a +backend on a cold VCL, and ``VRT_new_backend`` will return ``NULL`` if the VCL +is cooling. You are also encouraged to comply with the :ref:`ref_vcl_temperature` in general. From dridi.boukelmoune at gmail.com Fri Dec 4 15:03:22 2015 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 04 Dec 2015 16:03:22 +0100 Subject: [master] 2b6bf4f Start documenting that VCL cool down should go fast Message-ID: commit 2b6bf4fe047524e314deb9b96960159e9f6ca536 Author: Dridi Boukelmoune Date: Fri Dec 4 16:01:08 2015 +0100 Start documenting that VCL cool down should go fast diff --git a/doc/sphinx/reference/vmod.rst b/doc/sphinx/reference/vmod.rst index ad6e03f..57fa09c 100644 --- a/doc/sphinx/reference/vmod.rst +++ b/doc/sphinx/reference/vmod.rst @@ -390,6 +390,10 @@ reference by calling ``VRT_ref_vcl`` when you receive a ``VCL_EVENT_WARM`` and later calling ``VRT_rel_vcl`` once the background job is over. Receiving a ``VCL_EVENT_COLD`` is your cue to terminate any background job bound to a VCL. +In the case where properly releasing resources may take some time, you can +opt for an asynchronous worker, either by spawning a thread and tracking it, or +by using Varnish's worker pools. + There is also a ``VCL_EVENT_USE`` event. Please note that this event is now deprecated and may be removed in a future release. A warm VCL should be ready to use so no additional task should be postponed at use time. From dridi.boukelmoune at gmail.com Fri Dec 4 15:05:14 2015 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Fri, 04 Dec 2015 07:05:14 -0800 Subject: [varnishcache/varnish-cache] 16b837: Clarify VRT_delete_backend a bit Message-ID: <5661abaa10356_23093fcf84f772c023773@hookshot-fe3-cp1-prd.iad.github.net.mail> Branch: refs/heads/master Home: https://github.com/varnishcache/varnish-cache Commit: 16b8375210973852fa39afafad3239d382661fe5 https://github.com/varnishcache/varnish-cache/commit/16b8375210973852fa39afafad3239d382661fe5 Author: Dridi Boukelmoune Date: 2015-12-04 (Fri, 04 Dec 2015) Changed paths: M bin/varnishd/cache/cache_backend_cfg.c Log Message: ----------- Clarify VRT_delete_backend a bit Commit: 50aeefcceec15b765b2be0bb45d5c2de057802fe https://github.com/varnishcache/varnish-cache/commit/50aeefcceec15b765b2be0bb45d5c2de057802fe Author: Dridi Boukelmoune Date: 2015-12-04 (Fri, 04 Dec 2015) Changed paths: M bin/varnishd/cache/cache_vcl.c M doc/sphinx/reference/vmod.rst M include/vrt.h Log Message: ----------- Allow VMODs to hold a reference on a warm VCL Commit: 3162873747e9241383626d9cb501f363f7931b4b https://github.com/varnishcache/varnish-cache/commit/3162873747e9241383626d9cb501f363f7931b4b Author: Dridi Boukelmoune Date: 2015-12-04 (Fri, 04 Dec 2015) Changed paths: M bin/varnishd/cache/cache_backend.h M bin/varnishd/cache/cache_backend_cfg.c M bin/varnishd/cache/cache_vcl.c M doc/sphinx/reference/directors.rst Log Message: ----------- Don't create backends on cooling VCLs, return NULL Commit: 2b6bf4fe047524e314deb9b96960159e9f6ca536 https://github.com/varnishcache/varnish-cache/commit/2b6bf4fe047524e314deb9b96960159e9f6ca536 Author: Dridi Boukelmoune Date: 2015-12-04 (Fri, 04 Dec 2015) Changed paths: M doc/sphinx/reference/vmod.rst Log Message: ----------- Start documenting that VCL cool down should go fast Compare: https://github.com/varnishcache/varnish-cache/compare/765b6d3b3bb6...2b6bf4fe0475 From fgsch at lodoss.net Fri Dec 4 23:04:18 2015 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sat, 05 Dec 2015 00:04:18 +0100 Subject: [master] 7b2be3c Spelling Message-ID: commit 7b2be3cff20246cd04e6a72a009f57214377a4c8 Author: Federico G. Schwindt Date: Fri Dec 4 12:29:52 2015 +0000 Spelling diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index d79cde2..abc705b 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -113,7 +113,7 @@ ved_include(struct req *preq, const char *src, const char *host, http_ForceField(req->http0, HTTP_HDR_METHOD, "GET"); http_ForceField(req->http0, HTTP_HDR_PROTO, "HTTP/1.1"); - /* Don't allow conditionalss, we can't use a 304 */ + /* Don't allow conditionals, we can't use a 304 */ http_Unset(req->http0, H_If_Modified_Since); http_Unset(req->http0, H_If_None_Match); From fgsch at lodoss.net Fri Dec 4 23:04:18 2015 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sat, 05 Dec 2015 00:04:18 +0100 Subject: [master] 271e1c5 Ignore 0 Content-Lengths in 204 responses Message-ID: commit 271e1c5299c5b32ee636e4a7e009fbbb5080569f Author: Federico G. Schwindt Date: Fri Dec 4 16:08:06 2015 +0000 Ignore 0 Content-Lengths in 204 responses Broken implementations do it contrary to what the RFC mandates. Fixes #1826. diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 17aba0e..fe26ac4 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -345,7 +345,8 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo) * [RFC7230 3.3.1 p29 and 3.3.2 p31] */ wrk->stats->fetch_204++; - if (http_GetHdr(bo->beresp, H_Content_Length, NULL) || + if ((http_GetHdr(bo->beresp, H_Content_Length, NULL) && + bo->htc->content_length != 0) || http_GetHdr(bo->beresp, H_Transfer_Encoding, NULL)) bo->htc->body_status = BS_ERROR; else diff --git a/bin/varnishtest/tests/r01826.vtc b/bin/varnishtest/tests/r01826.vtc new file mode 100644 index 0000000..eeb4503 --- /dev/null +++ b/bin/varnishtest/tests/r01826.vtc @@ -0,0 +1,15 @@ +varnishtest "Check we ignore a zero C-L with a 204" + +server s1 { + rxreq + txresp -status 204 -nolen -hdr "Content-Length: 0" +} -start + +varnish v1 -vcl+backend { +} -start + +client c1 { + txreq + rxresp + expect resp.status == 204 +} -run From fgsch at lodoss.net Fri Dec 4 23:05:13 2015 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Fri, 04 Dec 2015 15:05:13 -0800 Subject: [varnishcache/varnish-cache] 7b2be3: Spelling Message-ID: <56621c2977d61_34f33fcf440152b817297@hookshot-fe2-cp1-prd.iad.github.net.mail> Branch: refs/heads/master Home: https://github.com/varnishcache/varnish-cache Commit: 7b2be3cff20246cd04e6a72a009f57214377a4c8 https://github.com/varnishcache/varnish-cache/commit/7b2be3cff20246cd04e6a72a009f57214377a4c8 Author: Federico G. Schwindt Date: 2015-12-04 (Fri, 04 Dec 2015) Changed paths: M bin/varnishd/cache/cache_esi_deliver.c Log Message: ----------- Spelling Commit: 271e1c5299c5b32ee636e4a7e009fbbb5080569f https://github.com/varnishcache/varnish-cache/commit/271e1c5299c5b32ee636e4a7e009fbbb5080569f Author: Federico G. Schwindt Date: 2015-12-04 (Fri, 04 Dec 2015) Changed paths: M bin/varnishd/cache/cache_fetch.c A bin/varnishtest/tests/r01826.vtc Log Message: ----------- Ignore 0 Content-Lengths in 204 responses Broken implementations do it contrary to what the RFC mandates. Fixes #1826. Compare: https://github.com/varnishcache/varnish-cache/compare/2b6bf4fe0475...271e1c5299c5 From fgsch at lodoss.net Sat Dec 5 10:46:31 2015 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sat, 05 Dec 2015 11:46:31 +0100 Subject: [master] 697fd44 Drop extra colon (:) Message-ID: commit 697fd4448b365d630d74bc54d41c300ef1b52fbb Author: Federico G. Schwindt Date: Sat Dec 5 10:43:20 2015 +0000 Drop extra colon (:) diff --git a/lib/libvcc/vcc_vmod.c b/lib/libvcc/vcc_vmod.c index e8bab4f..60d2ed2 100644 --- a/lib/libvcc/vcc_vmod.c +++ b/lib/libvcc/vcc_vmod.c @@ -111,7 +111,7 @@ vcc_ParseImport(struct vcc *tl) if (hdl == NULL) { VSB_printf(tl->sb, "Could not load VMOD %.*s\n", PF(mod)); VSB_printf(tl->sb, "\tFile name: %s\n", fn); - VSB_printf(tl->sb, "\tdlerror:: %s\n", dlerror()); + VSB_printf(tl->sb, "\tdlerror: %s\n", dlerror()); vcc_ErrWhere(tl, mod); return; } From fgsch at lodoss.net Sat Dec 5 10:50:12 2015 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sat, 05 Dec 2015 02:50:12 -0800 Subject: [varnishcache/varnish-cache] 697fd4: Drop extra colon (:) Message-ID: <5662c16460b26_5be73f8ea7b552a02157a6@hookshot-fe2-cp1-prd.iad.github.net.mail> Branch: refs/heads/master Home: https://github.com/varnishcache/varnish-cache Commit: 697fd4448b365d630d74bc54d41c300ef1b52fbb https://github.com/varnishcache/varnish-cache/commit/697fd4448b365d630d74bc54d41c300ef1b52fbb Author: Federico G. Schwindt Date: 2015-12-05 (Sat, 05 Dec 2015) Changed paths: M lib/libvcc/vcc_vmod.c Log Message: ----------- Drop extra colon (:) From dridi.boukelmoune at gmail.com Sat Dec 5 16:10:32 2015 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Sat, 05 Dec 2015 17:10:32 +0100 Subject: [master] 57a5b9c Introduce a new "busy" VCL temperature Message-ID: commit 57a5b9c78f669f43819df6e9fa5438e56afb0fc2 Author: Dridi Boukelmoune Date: Fri Dec 4 22:07:14 2015 +0100 Introduce a new "busy" VCL temperature Now that VCLs can be referenced, there are two different situations stalling the cooldown. The "cooling" one is kept for VCLs that have received a COLD event, and the "busy" one is introduced to wait for ongoing transactions. Basically, if there are transactions, the VCL is still active even though it's not *the* active VCL and should therefore be considered warm. This guarantees that WARM and COLD events are balanced, and also that a "busy" VCL doesn't need to warm up if it is set to warm again. The new VCL temperature engine looks like this: .----------W>---------------. | .--W>---. v init ---> cold --| |-- warm --. ^ ^ '------' The transitions marked with a 'W' or a 'C' are the one dispatching WARM and COLD events respectively. Since the "busy" state is considered warm, VMODs should operate as such and backend creation remains possible. diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c index a6d0c26..664c2c1 100644 --- a/bin/varnishd/cache/cache_vcl.c +++ b/bin/varnishd/cache/cache_vcl.c @@ -50,6 +50,7 @@ static const char * const vcl_temp_init = "init"; static const char * const vcl_temp_cold = "cold"; static const char * const vcl_temp_warm = "warm"; +static const char * const vcl_temp_busy = "busy"; static const char * const vcl_temp_cooling = "cooling"; struct vcl { @@ -164,7 +165,7 @@ VCL_Ref(struct vcl *vcl) { CHECK_OBJ_NOTNULL(vcl, VCL_MAGIC); - assert(vcl->temp == vcl_temp_warm || vcl->temp == vcl_temp_cooling); + assert(vcl->temp != vcl_temp_init && vcl->temp != vcl_temp_cold); Lck_Lock(&vcl_mtx); assert(vcl->busy > 0); vcl->busy++; @@ -207,10 +208,10 @@ VCL_AddBackend(struct vcl *vcl, struct backend *be) VTAILQ_INSERT_TAIL(&vcl->backend_list, be, vcl_list); Lck_Unlock(&vcl_mtx); - if (vcl->temp == vcl_temp_warm) { + if (vcl->temp == vcl_temp_warm || vcl->temp == vcl_temp_busy) /* Only when adding backend to already warm VCL */ VBE_Event(be, VCL_EVENT_WARM); - } else if (vcl->temp != vcl_temp_init) + else if (vcl->temp != vcl_temp_init) WRONG("Dynamic Backends can only be added to warm VCLs"); return (0); @@ -400,7 +401,8 @@ VRT_rel_vcl(VRT_CTX) vcl = ctx->vcl; CHECK_OBJ_NOTNULL(vcl, VCL_MAGIC); - assert(vcl->temp == vcl_temp_warm || vcl->temp == vcl_temp_cooling); + assert(vcl->temp == vcl_temp_warm || vcl->temp == vcl_temp_busy || + vcl->temp == vcl_temp_cooling); Lck_Lock(&vcl_mtx); assert(vcl->refcount > 0); @@ -430,6 +432,7 @@ static void vcl_set_state(struct vcl *vcl, const char *state) { struct vrt_ctx ctx; + const char *target; unsigned hand = 0; ASSERT_CLI(); @@ -441,22 +444,29 @@ vcl_set_state(struct vcl *vcl, const char *state) switch(state[0]) { case '0': - if (vcl->temp == vcl_temp_init) - vcl->temp = vcl_temp_cold; - if (vcl->temp == vcl_temp_cold) - break; - if (vcl->busy == 0 && vcl->refcount == 0) { - vcl->temp = vcl_temp_cold; + assert(vcl->temp != vcl_temp_cold); + target = vcl->busy ? vcl_temp_busy : vcl_temp_cold; + if (target == vcl_temp_cold && (vcl->temp == vcl_temp_warm || + vcl->temp == vcl_temp_busy)) { + + vcl->temp = vcl->refcount ? vcl_temp_cooling : + vcl_temp_cold; AZ(vcl->conf->event_vcl(&ctx, VCL_EVENT_COLD)); vcl_BackendEvent(vcl, VCL_EVENT_COLD); - } else { - vcl->temp = vcl_temp_cooling; } + else if (vcl->busy) + vcl->temp = vcl_temp_busy; + else + vcl->temp = vcl->refcount ? vcl_temp_cooling : + vcl_temp_cold; break; case '1': - if (vcl->temp == vcl_temp_cooling) + assert(vcl->temp != vcl_temp_warm); + /* The warm VCL hasn't seen a cold event yet */ + if (vcl->temp == vcl_temp_busy) vcl->temp = vcl_temp_warm; - else { + /* The VCL must first reach a stable cold state */ + else if (vcl->temp != vcl_temp_cooling) { vcl->temp = vcl_temp_warm; (void)vcl->conf->event_vcl(&ctx, VCL_EVENT_WARM); vcl_BackendEvent(vcl, VCL_EVENT_WARM); @@ -573,9 +583,10 @@ VCL_Poll(void) ASSERT_CLI(); VTAILQ_FOREACH_SAFE(vcl, &vcl_head, list, vcl2) { - if (vcl->temp == vcl_temp_cooling) + if (vcl->temp == vcl_temp_busy || + vcl->temp == vcl_temp_cooling) vcl_set_state(vcl, "0"); - if (vcl->discard && vcl->busy == 0 && vcl->refcount == 0) + if (vcl->discard && vcl->temp == vcl_temp_cold) VCL_Nuke(vcl); } } From dridi.boukelmoune at gmail.com Sat Dec 5 16:10:32 2015 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Sat, 05 Dec 2015 17:10:32 +0100 Subject: [master] 28eec51 Make event handling more readable in vmod-debug Message-ID: commit 28eec51b3d1c4d3a6d4da947bb7fea73028af19c Author: Dridi Boukelmoune Date: Sat Dec 5 15:48:30 2015 +0100 Make event handling more readable in vmod-debug diff --git a/lib/libvmod_debug/vmod_debug.c b/lib/libvmod_debug/vmod_debug.c index b065b7f..9b3449c 100644 --- a/lib/libvmod_debug/vmod_debug.c +++ b/lib/libvmod_debug/vmod_debug.c @@ -249,23 +249,10 @@ priv_vcl_free(void *priv) AZ(priv_vcl); } -int __match_proto__(vmod_event_f) -event_function(VRT_CTX, struct vmod_priv *priv, enum vcl_event_e e) +static int +event_load(VRT_CTX, struct vmod_priv *priv) { struct priv_vcl *priv_vcl; - const char *ev; - - switch (e) { - case VCL_EVENT_COLD: ev = "VCL_EVENT_COLD"; break; - case VCL_EVENT_WARM: ev = "VCL_EVENT_WARM"; break; - default: ev = NULL; - } - - if (ev != NULL) - VSL(SLT_Debug, 0, "%s: %s", VCL_Name(ctx->vcl), ev); - - if (e != VCL_EVENT_LOAD) - return (0); AN(ctx->msg); if (cache_param->nuke_limit == 42) { @@ -282,6 +269,40 @@ event_function(VRT_CTX, struct vmod_priv *priv, enum vcl_event_e e) return (0); } +static int +event_warm(VRT_CTX) +{ + + VSL(SLT_Debug, 0, "%s: VCL_EVENT_WARM", VCL_Name(ctx->vcl)); + + if (cache_param->max_esi_depth == 42) { + VSB_printf(ctx->msg, "max_esi_depth is not the answer."); + return (-1); + } + + return (0); +} + +static int +event_cold(VRT_CTX) +{ + + VSL(SLT_Debug, 0, "%s: VCL_EVENT_COLD", VCL_Name(ctx->vcl)); + return (0); +} + +int __match_proto__(vmod_event_f) +event_function(VRT_CTX, struct vmod_priv *priv, enum vcl_event_e e) +{ + + switch (e) { + case VCL_EVENT_LOAD: return event_load(ctx, priv); + case VCL_EVENT_COLD: return event_cold(ctx); + case VCL_EVENT_WARM: return event_warm(ctx); + default: return (0); + } +} + VCL_VOID __match_proto__(td_debug_sleep) vmod_sleep(VRT_CTX, VCL_DURATION t) { From dridi.boukelmoune at gmail.com Sat Dec 5 16:10:32 2015 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Sat, 05 Dec 2015 17:10:32 +0100 Subject: [master] 8bf2b0a Hold a VCL reference in the debug vmod Message-ID: commit 8bf2b0aee5da016125b5ddd007b9b0d040f1a535 Author: Dridi Boukelmoune Date: Sat Dec 5 16:09:14 2015 +0100 Hold a VCL reference in the debug vmod By default the reference is released as soon as the VCL goes cold, which doesn't harm the existing tests yet allows to cover the new VRT_ref_vcl and VRT_rel_vcl functions. It is possible to ask the vmod to release the reference after a delay. diff --git a/lib/libvmod_debug/vmod.vcc b/lib/libvmod_debug/vmod.vcc index dad36ec..42159fb 100644 --- a/lib/libvmod_debug/vmod.vcc +++ b/lib/libvmod_debug/vmod.vcc @@ -138,3 +138,7 @@ Mark a workspace as overflowed. $Function INT workspace_free(ENUM { client, backend, session, thread }) Find how much unallocated space there is left in a workspace. + +$Function VOID vcl_release_delay(DURATION) + +Hold a reference to the VCL when it goes cold for the given delay. diff --git a/lib/libvmod_debug/vmod_debug.c b/lib/libvmod_debug/vmod_debug.c index 9b3449c..91b49c7 100644 --- a/lib/libvmod_debug/vmod_debug.c +++ b/lib/libvmod_debug/vmod_debug.c @@ -28,6 +28,7 @@ #include "config.h" +#include #include #include @@ -46,6 +47,8 @@ struct priv_vcl { uintptr_t exp_cb; }; +VCL_DURATION vcl_release_delay = 0.0; + VCL_VOID __match_proto__(td_debug_panic) vmod_panic(VRT_CTX, const char *str, ...) { @@ -280,14 +283,38 @@ event_warm(VRT_CTX) return (-1); } + VRT_ref_vcl(ctx); return (0); } +static void* +cooldown_thread(void *priv) +{ + struct vrt_ctx ctx; + + AN(priv); + INIT_OBJ(&ctx, VRT_CTX_MAGIC); + ctx.vcl = (struct vcl*)priv; + + VTIM_sleep(vcl_release_delay); + VRT_rel_vcl(&ctx); + return (NULL); +} + static int event_cold(VRT_CTX) { + pthread_t thread; VSL(SLT_Debug, 0, "%s: VCL_EVENT_COLD", VCL_Name(ctx->vcl)); + + if (vcl_release_delay == 0.0) { + VRT_rel_vcl(ctx); + return (0); + } + + AZ(pthread_create(&thread, NULL, cooldown_thread, ctx->vcl)); + AZ(pthread_detach(thread)); return (0); } @@ -379,3 +406,12 @@ vmod_workspace_overflow(VRT_CTX, VCL_ENUM which) WS_MarkOverflow(ws); } + +void +vmod_vcl_release_delay(VRT_CTX, VCL_DURATION delay) +{ + + CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + assert(delay > 0.0); + vcl_release_delay = delay; +} From dridi.boukelmoune at gmail.com Sat Dec 5 16:10:32 2015 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Sat, 05 Dec 2015 17:10:32 +0100 Subject: [master] 502a871 Coverage for the cooling state Message-ID: commit 502a871051ccf7a9037f7c5aad3977618e2355c6 Author: Dridi Boukelmoune Date: Sat Dec 5 16:17:02 2015 +0100 Coverage for the cooling state diff --git a/bin/varnishtest/tests/v00045.vtc b/bin/varnishtest/tests/v00045.vtc new file mode 100644 index 0000000..b1754ee --- /dev/null +++ b/bin/varnishtest/tests/v00045.vtc @@ -0,0 +1,29 @@ +varnishtest "Hold a reference to a VCL after a COLD event" + +server s1 -start + +# Load and use a new VCL that will hold a reference +varnish v1 -vcl+backend { + import ${vmod_debug}; + sub vcl_init { + debug.vcl_release_delay(2s); + } +} -start + +# Load and use a new VCL, freeze the first +varnish v1 -vcl+backend {} +varnish v1 -cliok "vcl.state vcl1 cold" + +# We should now see it as cooling +delay 1 +shell { + ${varnishadm} -n ${v1_name} vcl.list | + grep "auto/cooling.*vcl1" >/dev/null +} + +# It will eventually cool down +delay 2 +shell { + ${varnishadm} -n ${v1_name} vcl.list | + grep "auto/cold.*vcl1" >/dev/null +} From dridi.boukelmoune at gmail.com Sat Dec 5 16:14:30 2015 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Sat, 05 Dec 2015 17:14:30 +0100 Subject: [master] 89ce06a Wording Message-ID: commit 89ce06aa305f577fd140dd35b6adf5d20a7444f0 Author: Dridi Boukelmoune Date: Sat Dec 5 17:14:19 2015 +0100 Wording diff --git a/bin/varnishtest/tests/v00045.vtc b/bin/varnishtest/tests/v00045.vtc index b1754ee..1cc1259 100644 --- a/bin/varnishtest/tests/v00045.vtc +++ b/bin/varnishtest/tests/v00045.vtc @@ -2,7 +2,7 @@ varnishtest "Hold a reference to a VCL after a COLD event" server s1 -start -# Load and use a new VCL that will hold a reference +# Load and use a VCL that will hold a reference varnish v1 -vcl+backend { import ${vmod_debug}; sub vcl_init { From dridi.boukelmoune at gmail.com Sat Dec 5 16:15:13 2015 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Sat, 05 Dec 2015 08:15:13 -0800 Subject: [varnishcache/varnish-cache] 57a5b9: Introduce a new "busy" VCL temperature Message-ID: <56630d9113c8f_57503fde6b9212b8225211@hookshot-fe5-cp1-prd.iad.github.net.mail> Branch: refs/heads/master Home: https://github.com/varnishcache/varnish-cache Commit: 57a5b9c78f669f43819df6e9fa5438e56afb0fc2 https://github.com/varnishcache/varnish-cache/commit/57a5b9c78f669f43819df6e9fa5438e56afb0fc2 Author: Dridi Boukelmoune Date: 2015-12-05 (Sat, 05 Dec 2015) Changed paths: M bin/varnishd/cache/cache_vcl.c Log Message: ----------- Introduce a new "busy" VCL temperature Now that VCLs can be referenced, there are two different situations stalling the cooldown. The "cooling" one is kept for VCLs that have received a COLD event, and the "busy" one is introduced to wait for ongoing transactions. Basically, if there are transactions, the VCL is still active even though it's not *the* active VCL and should therefore be considered warm. This guarantees that WARM and COLD events are balanced, and also that a "busy" VCL doesn't need to warm up if it is set to warm again. The new VCL temperature engine looks like this: .----------W>---------------. | .--W>---. v init ---> cold --| |-- warm --. ^ ^ '------' The transitions marked with a 'W' or a 'C' are the one dispatching WARM and COLD events respectively. Since the "busy" state is considered warm, VMODs should operate as such and backend creation remains possible. Commit: 28eec51b3d1c4d3a6d4da947bb7fea73028af19c https://github.com/varnishcache/varnish-cache/commit/28eec51b3d1c4d3a6d4da947bb7fea73028af19c Author: Dridi Boukelmoune Date: 2015-12-05 (Sat, 05 Dec 2015) Changed paths: M lib/libvmod_debug/vmod_debug.c Log Message: ----------- Make event handling more readable in vmod-debug Commit: 8bf2b0aee5da016125b5ddd007b9b0d040f1a535 https://github.com/varnishcache/varnish-cache/commit/8bf2b0aee5da016125b5ddd007b9b0d040f1a535 Author: Dridi Boukelmoune Date: 2015-12-05 (Sat, 05 Dec 2015) Changed paths: M lib/libvmod_debug/vmod.vcc M lib/libvmod_debug/vmod_debug.c Log Message: ----------- Hold a VCL reference in the debug vmod By default the reference is released as soon as the VCL goes cold, which doesn't harm the existing tests yet allows to cover the new VRT_ref_vcl and VRT_rel_vcl functions. It is possible to ask the vmod to release the reference after a delay. Commit: 502a871051ccf7a9037f7c5aad3977618e2355c6 https://github.com/varnishcache/varnish-cache/commit/502a871051ccf7a9037f7c5aad3977618e2355c6 Author: Dridi Boukelmoune Date: 2015-12-05 (Sat, 05 Dec 2015) Changed paths: A bin/varnishtest/tests/v00045.vtc Log Message: ----------- Coverage for the cooling state Commit: 89ce06aa305f577fd140dd35b6adf5d20a7444f0 https://github.com/varnishcache/varnish-cache/commit/89ce06aa305f577fd140dd35b6adf5d20a7444f0 Author: Dridi Boukelmoune Date: 2015-12-05 (Sat, 05 Dec 2015) Changed paths: M bin/varnishtest/tests/v00045.vtc Log Message: ----------- Wording Compare: https://github.com/varnishcache/varnish-cache/compare/697fd4448b36...89ce06aa305f From dridi.boukelmoune at gmail.com Sat Dec 5 16:20:53 2015 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Sat, 05 Dec 2015 17:20:53 +0100 Subject: [master] 6a6358f Polish Message-ID: commit 6a6358f5fc5be3f1325fad6fcd6f18257c21dfdf Author: Dridi Boukelmoune Date: Sat Dec 5 17:20:37 2015 +0100 Polish diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c index 664c2c1..54effd1 100644 --- a/bin/varnishd/cache/cache_vcl.c +++ b/bin/varnishd/cache/cache_vcl.c @@ -432,7 +432,6 @@ static void vcl_set_state(struct vcl *vcl, const char *state) { struct vrt_ctx ctx; - const char *target; unsigned hand = 0; ASSERT_CLI(); @@ -445,8 +444,7 @@ vcl_set_state(struct vcl *vcl, const char *state) switch(state[0]) { case '0': assert(vcl->temp != vcl_temp_cold); - target = vcl->busy ? vcl_temp_busy : vcl_temp_cold; - if (target == vcl_temp_cold && (vcl->temp == vcl_temp_warm || + if (vcl->busy == 0 && (vcl->temp == vcl_temp_warm || vcl->temp == vcl_temp_busy)) { vcl->temp = vcl->refcount ? vcl_temp_cooling : From dridi.boukelmoune at gmail.com Sat Dec 5 16:25:12 2015 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Sat, 05 Dec 2015 08:25:12 -0800 Subject: [varnishcache/varnish-cache] 6a6358: Polish Message-ID: <56630fe8b669a_17f03fe512ee929c520f2@hookshot-fe6-cp1-prd.iad.github.net.mail> Branch: refs/heads/master Home: https://github.com/varnishcache/varnish-cache Commit: 6a6358f5fc5be3f1325fad6fcd6f18257c21dfdf https://github.com/varnishcache/varnish-cache/commit/6a6358f5fc5be3f1325fad6fcd6f18257c21dfdf Author: Dridi Boukelmoune Date: 2015-12-05 (Sat, 05 Dec 2015) Changed paths: M bin/varnishd/cache/cache_vcl.c Log Message: ----------- Polish From dridi.boukelmoune at gmail.com Mon Dec 7 13:28:08 2015 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 07 Dec 2015 14:28:08 +0100 Subject: [master] ae5a342 Polish Message-ID: commit ae5a3429ca0f117ea15f1be3c1c493b4612e3ee5 Author: Dridi Boukelmoune Date: Mon Dec 7 12:14:12 2015 +0100 Polish diff --git a/bin/varnishd/mgt/mgt_vcl.c b/bin/varnishd/mgt/mgt_vcl.c index b12bdb6..37359f2 100644 --- a/bin/varnishd/mgt/mgt_vcl.c +++ b/bin/varnishd/mgt/mgt_vcl.c @@ -416,8 +416,8 @@ mcf_vcl_list(struct cli *cli, const char * const *av, void *priv) VTAILQ_FOREACH(vp, &vclhead, list) { VCLI_Out(cli, "%-10s %4s/%-8s %6s %s\n", vp == active_vcl ? "active" : "available", - vp->state, - vp->warm ? "warm" : "cold", "", vp->name); + vp->state, vp->warm ? "warm" : "cold", "", + vp->name); } } } From dridi.boukelmoune at gmail.com Mon Dec 7 13:30:14 2015 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 07 Dec 2015 05:30:14 -0800 Subject: [varnishcache/varnish-cache] ae5a34: Polish Message-ID: <566589e69dcca_6b4c3f8f5a14d2b83907@hookshot-fe4-cp1-prd.iad.github.net.mail> Branch: refs/heads/master Home: https://github.com/varnishcache/varnish-cache Commit: ae5a3429ca0f117ea15f1be3c1c493b4612e3ee5 https://github.com/varnishcache/varnish-cache/commit/ae5a3429ca0f117ea15f1be3c1c493b4612e3ee5 Author: Dridi Boukelmoune Date: 2015-12-07 (Mon, 07 Dec 2015) Changed paths: M bin/varnishd/mgt/mgt_vcl.c Log Message: ----------- Polish From dridi.boukelmoune at gmail.com Mon Dec 7 17:28:13 2015 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 07 Dec 2015 18:28:13 +0100 Subject: [master] 513aee7 Add a reminder for a VRT_MINOR_VERSION bump Message-ID: commit 513aee7831f3a24158fd49a4e8560ffce915b2f9 Author: Dridi Boukelmoune Date: Mon Dec 7 18:23:09 2015 +0100 Add a reminder for a VRT_MINOR_VERSION bump This is for the 4.1 ABI, since the next major release will have a VRT_MAJOR_VERSION bump instead. The two functions may also change semantics before the next 4.1.x, but will still be _new_ as far as releases are concerned. diff --git a/include/vrt.h b/include/vrt.h index 2203bd8..96a3c64 100644 --- a/include/vrt.h +++ b/include/vrt.h @@ -40,6 +40,9 @@ * * changes to consider with next VRT_MAJOR_VERSION bump: * - cache_vrt.c: -> ssize_t VRT_CacheReqBody(VRT_CTX, size_t) + * + * changes to consider with next VRT_MINOR_VERSION bump for 4.1: + * - cache_vcl.c: -> VRT_ref_vcl, VRT_rel_vcl */ #define VRT_MAJOR_VERSION 3U From dridi.boukelmoune at gmail.com Mon Dec 7 17:30:14 2015 From: dridi.boukelmoune at gmail.com (Dridi Boukelmoune) Date: Mon, 07 Dec 2015 09:30:14 -0800 Subject: [varnishcache/varnish-cache] 513aee: Add a reminder for a VRT_MINOR_VERSION bump Message-ID: <5665c226abafc_1afe3feb942572bc3414c6@hookshot-fe6-cp1-prd.iad.github.net.mail> Branch: refs/heads/master Home: https://github.com/varnishcache/varnish-cache Commit: 513aee7831f3a24158fd49a4e8560ffce915b2f9 https://github.com/varnishcache/varnish-cache/commit/513aee7831f3a24158fd49a4e8560ffce915b2f9 Author: Dridi Boukelmoune Date: 2015-12-07 (Mon, 07 Dec 2015) Changed paths: M include/vrt.h Log Message: ----------- Add a reminder for a VRT_MINOR_VERSION bump This is for the 4.1 ABI, since the next major release will have a VRT_MAJOR_VERSION bump instead. The two functions may also change semantics before the next 4.1.x, but will still be _new_ as far as releases are concerned. From phk at FreeBSD.org Tue Dec 8 09:32:20 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 08 Dec 2015 10:32:20 +0100 Subject: [master] 003e82a typo Message-ID: commit 003e82a0f42d7756dfa7d9f64a452fa0786ed3ea Author: Poul-Henning Kamp Date: Tue Dec 8 09:32:02 2015 +0000 typo diff --git a/lib/libvmod_debug/vmod.vcc b/lib/libvmod_debug/vmod.vcc index 42159fb..74c8c12 100644 --- a/lib/libvmod_debug/vmod.vcc +++ b/lib/libvmod_debug/vmod.vcc @@ -78,7 +78,7 @@ Test object .. NOTE: .enum before .foo as part of test r01332.vtc $Method VOID .enum(ENUM { phk, des, kristian, mithrandir, martin }) -Testing that emums work as part of object and that the parser isn't +Testing that enums work as part of object and that the parser isn't (too) buggy. $Method STRING .foo(STRING why) From phk at FreeBSD.org Tue Dec 8 09:35:13 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 08 Dec 2015 01:35:13 -0800 Subject: [varnishcache/varnish-cache] 003e82: typo Message-ID: <5666a4514daa8_cb83ff3c339b2b81152a@hookshot-fe2-cp1-prd.iad.github.net.mail> Branch: refs/heads/master Home: https://github.com/varnishcache/varnish-cache Commit: 003e82a0f42d7756dfa7d9f64a452fa0786ed3ea https://github.com/varnishcache/varnish-cache/commit/003e82a0f42d7756dfa7d9f64a452fa0786ed3ea Author: Poul-Henning Kamp Date: 2015-12-08 (Tue, 08 Dec 2015) Changed paths: M lib/libvmod_debug/vmod.vcc Log Message: ----------- typo From daghf at varnish-software.com Tue Dec 8 10:43:17 2015 From: daghf at varnish-software.com (Dag Haavi Finstad) Date: Tue, 08 Dec 2015 11:43:17 +0100 Subject: [master] a3ebb1b Pass the busyobj pointer also for vdir_pick_be. Message-ID: commit a3ebb1b642b0c6b793c0b7bca590181e2a98b81a Author: Dag Haavi Finstad Date: Mon Dec 7 16:19:26 2015 +0100 Pass the busyobj pointer also for vdir_pick_be. It's needed for the vdi_healthy_f invocation. diff --git a/lib/libvmod_directors/hash.c b/lib/libvmod_directors/hash.c index a858a09..9aa62f0 100644 --- a/lib/libvmod_directors/hash.c +++ b/lib/libvmod_directors/hash.c @@ -97,6 +97,7 @@ vmod_hash_backend(VRT_CTX, struct vmod_directors_hash *rr, double r; CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); + CHECK_OBJ_ORNULL(ctx->bo, BUSYOBJ_MAGIC); CHECK_OBJ_NOTNULL(rr, VMOD_DIRECTORS_HASH_MAGIC); SHA256_Init(&sha_ctx); @@ -113,6 +114,6 @@ vmod_hash_backend(VRT_CTX, struct vmod_directors_hash *rr, r = vbe32dec(sha256); r = scalbn(r, -32); assert(r >= 0 && r <= 1.0); - be = vdir_pick_be(rr->vd, r); + be = vdir_pick_be(rr->vd, r, ctx->bo); return (be); } diff --git a/lib/libvmod_directors/random.c b/lib/libvmod_directors/random.c index 2f29887..980ef94 100644 --- a/lib/libvmod_directors/random.c +++ b/lib/libvmod_directors/random.c @@ -71,7 +71,7 @@ vmod_random_resolve(const struct director *dir, struct worker *wrk, CAST_OBJ_NOTNULL(rr, dir->priv, VMOD_DIRECTORS_RANDOM_MAGIC); r = scalbn(random(), -31); assert(r >= 0 && r < 1.0); - be = vdir_pick_be(rr->vd, r); + be = vdir_pick_be(rr->vd, r, bo); return (be); } diff --git a/lib/libvmod_directors/vdir.c b/lib/libvmod_directors/vdir.c index 411df34..1112bad 100644 --- a/lib/libvmod_directors/vdir.c +++ b/lib/libvmod_directors/vdir.c @@ -177,7 +177,7 @@ vdir_pick_by_weight(const struct vdir *vd, double w, } VCL_BACKEND -vdir_pick_be(struct vdir *vd, double w) +vdir_pick_be(struct vdir *vd, double w, const struct busyobj *bo) { unsigned u; double tw = 0.0; @@ -185,7 +185,7 @@ vdir_pick_be(struct vdir *vd, double w) vdir_lock(vd); for (u = 0; u < vd->n_backend; u++) { - if (vd->backend[u]->healthy(vd->backend[u], NULL, NULL)) { + if (vd->backend[u]->healthy(vd->backend[u], bo, NULL)) { vbit_clr(vd->vbm, u); tw += vd->weight[u]; } else diff --git a/lib/libvmod_directors/vdir.h b/lib/libvmod_directors/vdir.h index 2e1cfe1..b420f68 100644 --- a/lib/libvmod_directors/vdir.h +++ b/lib/libvmod_directors/vdir.h @@ -49,4 +49,4 @@ void vdir_unlock(struct vdir *vd); unsigned vdir_add_backend(struct vdir *, VCL_BACKEND be, double weight); unsigned vdir_any_healthy(struct vdir *, const struct busyobj *, double *changed); -VCL_BACKEND vdir_pick_be(struct vdir *, double w); +VCL_BACKEND vdir_pick_be(struct vdir *, double w, const struct busyobj *); From daghf at varnish-software.com Tue Dec 8 10:45:13 2015 From: daghf at varnish-software.com (Dag Haavi Finstad) Date: Tue, 08 Dec 2015 02:45:13 -0800 Subject: [varnishcache/varnish-cache] a3ebb1: Pass the busyobj pointer also for vdir_pick_be. Message-ID: <5666b4b923798_4a113f9acb40b2bc635c6@hookshot-fe1-cp1-prd.iad.github.net.mail> Branch: refs/heads/master Home: https://github.com/varnishcache/varnish-cache Commit: a3ebb1b642b0c6b793c0b7bca590181e2a98b81a https://github.com/varnishcache/varnish-cache/commit/a3ebb1b642b0c6b793c0b7bca590181e2a98b81a Author: Dag Haavi Finstad Date: 2015-12-08 (Tue, 08 Dec 2015) Changed paths: M lib/libvmod_directors/hash.c M lib/libvmod_directors/random.c M lib/libvmod_directors/vdir.c M lib/libvmod_directors/vdir.h Log Message: ----------- Pass the busyobj pointer also for vdir_pick_be. It's needed for the vdi_healthy_f invocation. From martin at varnish-software.com Wed Dec 9 15:57:51 2015 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Wed, 09 Dec 2015 16:57:51 +0100 Subject: [4.0] 4332353 Remember to lock the backend's mutex when increasing the refcount during VCL load. Message-ID: commit 43323536ab2f44b20dfa23f774144e374bc8eb0f Author: Martin Blix Grydeland Date: Wed Dec 9 16:53:19 2015 +0100 Remember to lock the backend's mutex when increasing the refcount during VCL load. diff --git a/bin/varnishd/cache/cache_backend_cfg.c b/bin/varnishd/cache/cache_backend_cfg.c index b7f6a8d..a5d913f 100644 --- a/bin/varnishd/cache/cache_backend_cfg.c +++ b/bin/varnishd/cache/cache_backend_cfg.c @@ -136,7 +136,9 @@ VBE_DropRefVcl(struct backend *b) CHECK_OBJ_NOTNULL(b, BACKEND_MAGIC); + ASSERT_CLI(); Lck_Lock(&b->mtx); + assert(b->vsc->vcls > 0); b->vsc->vcls--; VBE_DropRefLocked(b, NULL); } @@ -196,7 +198,9 @@ VBE_AddBackend(struct cli *cli, const struct vrt_backend *vb) if (vb->ipv6_suckaddr != NULL && VSA_Compare(b->ipv6, vb->ipv6_suckaddr)) continue; + Lck_Lock(&b->mtx); b->refcount++; + Lck_Unlock(&b->mtx); b->vsc->vcls++; return (b); } From martin at varnish-software.com Wed Dec 9 16:00:18 2015 From: martin at varnish-software.com (Martin Blix Grydeland) Date: Wed, 09 Dec 2015 08:00:18 -0800 Subject: [varnishcache/varnish-cache] 433235: Remember to lock the backend's mutex when increasi... Message-ID: <5668501226135_759b3fc6a4f9d29c3693a@hookshot-fe5-cp1-prd.iad.github.net.mail> Branch: refs/heads/4.0 Home: https://github.com/varnishcache/varnish-cache Commit: 43323536ab2f44b20dfa23f774144e374bc8eb0f https://github.com/varnishcache/varnish-cache/commit/43323536ab2f44b20dfa23f774144e374bc8eb0f Author: Martin Blix Grydeland Date: 2015-12-09 (Wed, 09 Dec 2015) Changed paths: M bin/varnishd/cache/cache_backend_cfg.c Log Message: ----------- Remember to lock the backend's mutex when increasing the refcount during VCL load. From phk at FreeBSD.org Thu Dec 10 00:23:28 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 10 Dec 2015 01:23:28 +0100 Subject: [master] 6e29a15 Constify req.body pointer when interating over it. Message-ID: commit 6e29a151a0e37b9b6aed5d08f3c8b56008235471 Author: Poul-Henning Kamp Date: Wed Dec 9 22:00:58 2015 +0000 Constify req.body pointer when interating over it. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index e7700d0..4fac13c 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -682,7 +682,8 @@ void VBO_waitstate(struct busyobj *bo, enum busyobj_state_e want); /* cache_req_body.c */ int VRB_Ignore(struct req *req); ssize_t VRB_Cache(struct req *req, ssize_t maxsize); -typedef int (req_body_iter_f)(struct req *, void *priv, void *ptr, size_t); +typedef int (req_body_iter_f)(struct req *, void *priv, + const void *ptr, size_t); ssize_t VRB_Iterate(struct req *req, req_body_iter_f *func, void *priv); void VRB_Free(struct req *req); diff --git a/bin/varnishd/cache/cache_req_body.c b/bin/varnishd/cache/cache_req_body.c index f50621e..02050f9 100644 --- a/bin/varnishd/cache/cache_req_body.c +++ b/bin/varnishd/cache/cache_req_body.c @@ -147,7 +147,7 @@ VRB_Iterate(struct req *req, req_body_iter_f *func, void *priv) */ static int __match_proto__(req_body_iter_f) -httpq_req_body_discard(struct req *req, void *priv, void *ptr, size_t len) +httpq_req_body_discard(struct req *req, void *priv, const void *ptr, size_t len) { CHECK_OBJ_NOTNULL(req, REQ_MAGIC); diff --git a/bin/varnishd/http1/cache_http1_fetch.c b/bin/varnishd/http1/cache_http1_fetch.c index a69fb92..0a7f100 100644 --- a/bin/varnishd/http1/cache_http1_fetch.c +++ b/bin/varnishd/http1/cache_http1_fetch.c @@ -49,7 +49,7 @@ */ static int __match_proto__(req_body_iter_f) -vbf_iter_req_body(struct req *req, void *priv, void *ptr, size_t l) +vbf_iter_req_body(struct req *req, void *priv, const void *ptr, size_t l) { struct busyobj *bo; From phk at FreeBSD.org Thu Dec 10 00:23:28 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 10 Dec 2015 01:23:28 +0100 Subject: [master] f5b92e2 Make VDP_DeliverObj() return a simple int status code Message-ID: commit f5b92e27478874a46b71d4aa0c3e35bdaa31f396 Author: Poul-Henning Kamp Date: Wed Dec 9 22:20:16 2015 +0000 Make VDP_DeliverObj() return a simple int status code diff --git a/bin/varnishd/cache/cache_deliver_proc.c b/bin/varnishd/cache/cache_deliver_proc.c index 0e84bae..9de94dd 100644 --- a/bin/varnishd/cache/cache_deliver_proc.c +++ b/bin/varnishd/cache/cache_deliver_proc.c @@ -114,10 +114,11 @@ VDP_close(struct req *req) /*--------------------------------------------------------------------*/ -enum objiter_status +int VDP_DeliverObj(struct req *req) { enum objiter_status ois; + int err = 0; ssize_t len; void *oi; void *ptr; @@ -134,6 +135,7 @@ VDP_DeliverObj(struct req *req) AZ(len); break; case OIS_ERROR: + err = -1; break; case OIS_DATA: case OIS_STREAM: @@ -147,5 +149,5 @@ VDP_DeliverObj(struct req *req) } while (ois == OIS_DATA || ois == OIS_STREAM); (void)VDP_bytes(req, VDP_FLUSH, NULL, 0); ObjIterEnd(req->objcore, &oi); - return (ois); + return (err); } diff --git a/bin/varnishd/cache/cache_filter.h b/bin/varnishd/cache/cache_filter.h index 016bcb0..aba9d65 100644 --- a/bin/varnishd/cache/cache_filter.h +++ b/bin/varnishd/cache/cache_filter.h @@ -108,7 +108,7 @@ struct vdp_entry { int VDP_bytes(struct req *, enum vdp_action act, const void *ptr, ssize_t len); void VDP_push(struct req *, vdp_bytes *func, void *priv, int bottom); void VDP_close(struct req *req); -enum objiter_status VDP_DeliverObj(struct req *req); +int VDP_DeliverObj(struct req *req); vdp_bytes VDP_gunzip; vdp_bytes VDP_ESI; diff --git a/bin/varnishd/http1/cache_http1_deliver.c b/bin/varnishd/http1/cache_http1_deliver.c index 0135ed8..99ac91f 100644 --- a/bin/varnishd/http1/cache_http1_deliver.c +++ b/bin/varnishd/http1/cache_http1_deliver.c @@ -81,7 +81,7 @@ v1d_error(struct req *req, const char *msg) void __match_proto__(vtr_deliver_f) V1D_Deliver(struct req *req, struct busyobj *bo, int sendbody) { - enum objiter_status ois; + int err = 0; CHECK_OBJ_NOTNULL(req, REQ_MAGIC); CHECK_OBJ_ORNULL(bo, BUSYOBJ_MAGIC); @@ -125,16 +125,15 @@ V1D_Deliver(struct req *req, struct busyobj *bo, int sendbody) if (DO_DEBUG(DBG_FLUSH_HEAD)) (void)V1L_Flush(req->wrk); - ois = OIS_DONE; if (sendbody && req->resp_len != 0) { if (req->res_mode & RES_CHUNKED) V1L_Chunked(req->wrk); - ois = VDP_DeliverObj(req); - if (ois == OIS_DONE && (req->res_mode & RES_CHUNKED)) + err = VDP_DeliverObj(req); + if (!err && (req->res_mode & RES_CHUNKED)) V1L_EndChunk(req->wrk); } - if ((V1L_FlushRelease(req->wrk) || ois != OIS_DONE) && req->sp->fd >= 0) + if ((V1L_FlushRelease(req->wrk) || err) && req->sp->fd >= 0) SES_Close(req->sp, SC_REM_CLOSE); AZ(req->wrk->v1l); VDP_close(req); From phk at FreeBSD.org Thu Dec 10 00:23:28 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 10 Dec 2015 01:23:28 +0100 Subject: [master] ef14640 Add ObjIterate() wrapper function Message-ID: commit ef14640730b8eca2cfb7458d08ee10270ce7968f Author: Poul-Henning Kamp Date: Wed Dec 9 22:31:06 2015 +0000 Add ObjIterate() wrapper function diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 4fac13c..eb892ae 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -855,6 +855,9 @@ void *MPL_Get(struct mempool *mpl, unsigned *size); void MPL_Free(struct mempool *mpl, void *item); /* cache_obj.c */ +typedef int objiterate_f(void *priv, int flush, const void *ptr, ssize_t len); +int ObjIterate(struct worker *, struct objcore *, + void *priv, objiterate_f *func); enum objiter_status { OIS_DONE, OIS_DATA, diff --git a/bin/varnishd/cache/cache_obj.c b/bin/varnishd/cache/cache_obj.c index 53fe080..2203845 100644 --- a/bin/varnishd/cache/cache_obj.c +++ b/bin/varnishd/cache/cache_obj.c @@ -231,6 +231,40 @@ ObjIterEnd(struct objcore *oc, void **oix) FREE_OBJ(oi); } +int +ObjIterate(struct worker *wrk, struct objcore *oc, + void *priv, objiterate_f *func) +{ + void *oi; + enum objiter_status ois; + void *ptr; + ssize_t len; + + oi = ObjIterBegin(wrk, oc); + do { + ois = ObjIter(oc, oi, &ptr, &len); + switch(ois) { + case OIS_DONE: + AZ(len); + break; + case OIS_ERROR: + break; + case OIS_DATA: + if (func(priv, 0, ptr, len)) + ois = OIS_ERROR; + break; + case OIS_STREAM: + if (func(priv, 1, ptr, len)) + ois = OIS_ERROR; + break; + default: + WRONG("Wrong OIS value"); + } + } while (ois == OIS_DATA || ois == OIS_STREAM); + ObjIterEnd(oc, &oi); + return (ois == OIS_DONE ? 0 : -1); +} + /*-------------------------------------------------------------------- */ From phk at FreeBSD.org Thu Dec 10 00:23:28 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 10 Dec 2015 01:23:28 +0100 Subject: [master] 1551a2d Use ObjIterate() Message-ID: commit 1551a2d19cd1493b1d62e80c89741426dc445656 Author: Poul-Henning Kamp Date: Wed Dec 9 22:31:50 2015 +0000 Use ObjIterate() diff --git a/bin/varnishd/cache/cache_deliver_proc.c b/bin/varnishd/cache/cache_deliver_proc.c index 9de94dd..5060f9f 100644 --- a/bin/varnishd/cache/cache_deliver_proc.c +++ b/bin/varnishd/cache/cache_deliver_proc.c @@ -114,40 +114,17 @@ VDP_close(struct req *req) /*--------------------------------------------------------------------*/ +static int __match_proto__(objiterate_f) +vdp_objiterator(void *priv, int flush, const void *ptr, ssize_t len) +{ + return (VDP_bytes(priv, flush ? VDP_FLUSH : VDP_NULL, ptr, len)); +} + + int VDP_DeliverObj(struct req *req) { - enum objiter_status ois; - int err = 0; - ssize_t len; - void *oi; - void *ptr; CHECK_OBJ_NOTNULL(req, REQ_MAGIC); - - oi = ObjIterBegin(req->wrk, req->objcore); - XXXAN(oi); - - do { - ois = ObjIter(req->objcore, oi, &ptr, &len); - switch(ois) { - case OIS_DONE: - AZ(len); - break; - case OIS_ERROR: - err = -1; - break; - case OIS_DATA: - case OIS_STREAM: - if (VDP_bytes(req, - ois == OIS_DATA ? VDP_NULL : VDP_FLUSH, ptr, len)) - ois = OIS_ERROR; - break; - default: - WRONG("Wrong OIS value"); - } - } while (ois == OIS_DATA || ois == OIS_STREAM); - (void)VDP_bytes(req, VDP_FLUSH, NULL, 0); - ObjIterEnd(req->objcore, &oi); - return (err); + return (ObjIterate(req->wrk, req->objcore, req, vdp_objiterator)); } From phk at FreeBSD.org Thu Dec 10 00:23:28 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 10 Dec 2015 01:23:28 +0100 Subject: [master] b924bdf Use ObjIterate() Message-ID: commit b924bdf615821f51816e842cbf1113890a4ec7bc Author: Poul-Henning Kamp Date: Wed Dec 9 22:40:46 2015 +0000 Use ObjIterate() diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index fe26ac4..38c897d 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -693,14 +693,35 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo) /*-------------------------------------------------------------------- */ +static int +vbf_objiterator(void *priv, int flush, const void *ptr, ssize_t len) +{ + struct busyobj *bo; + ssize_t l; + const uint8_t *ps = ptr; + uint8_t *pd; + + (void)flush; + CAST_OBJ_NOTNULL(bo, priv, BUSYOBJ_MAGIC); + + while (len > 0) { + l = ObjGetLen(bo->wrk, bo->stale_oc); + assert(l > 0); + if (VFP_GetStorage(bo->vfc, &l, &pd) != VFP_OK) + return (1); + if (len < l) + l = len; + memcpy(pd, ps, l); + VBO_extend(bo, l); + ps += l; + len -= l; + } + return (0); +} + static enum fetch_step vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo) { - void *oi; - void *sp; - ssize_t sl, al, l; - uint8_t *ptr; - enum objiter_status ois; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC); @@ -719,27 +740,9 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo) VBO_setstate(bo, BOS_STREAM); } - al = 0; - oi = ObjIterBegin(wrk, bo->stale_oc); - do { - ois = ObjIter(bo->stale_oc, oi, &sp, &sl); - if (ois == OIS_ERROR) - (void)VFP_Error(bo->vfc, "Template object failed"); - while (sl > 0) { - l = ObjGetLen(bo->wrk, bo->stale_oc) - al; - assert(l > 0); - if (VFP_GetStorage(bo->vfc, &l, &ptr) != VFP_OK) - break; - if (sl < l) - l = sl; - memcpy(ptr, sp, l); - VBO_extend(bo, l); - al += l; - sp = (char *)sp + l; - sl -= l; - } - } while (!bo->vfc->failed && (ois == OIS_DATA || ois == OIS_STREAM)); - ObjIterEnd(bo->stale_oc, &oi); + if (ObjIterate(wrk, bo->stale_oc, bo, vbf_objiterator)) + (void)VFP_Error(bo->vfc, "Template object failed"); + if (bo->stale_oc->flags & OC_F_FAILED) (void)VFP_Error(bo->vfc, "Template object failed"); if (bo->vfc->failed) { @@ -750,7 +753,6 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo) if (!bo->do_stream) HSH_Unbusy(wrk, bo->fetch_objcore); - assert(ObjGetLen(bo->wrk, bo->fetch_objcore) == al); EXP_Rearm(bo->stale_oc, bo->stale_oc->exp.t_origin, 0, 0, 0); /* Recycle the backend connection before setting BOS_FINISHED to From phk at FreeBSD.org Thu Dec 10 00:23:28 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 10 Dec 2015 01:23:28 +0100 Subject: [master] 3dc7521 Convert to use ObjIterate() Message-ID: commit 3dc7521c6db46919630c735664a7e147e14a0a87 Author: Poul-Henning Kamp Date: Wed Dec 9 22:49:10 2015 +0000 Convert to use ObjIterate() diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c index abc705b..a4f8d72 100644 --- a/bin/varnishd/cache/cache_esi_deliver.c +++ b/bin/varnishd/cache/cache_esi_deliver.c @@ -516,30 +516,178 @@ ved_pretend_gzip(struct req *req, enum vdp_action act, void **priv, * much cheaper than running a gunzip instance. */ +struct ved_foo { + unsigned magic; +#define VED_FOO_MAGIC 0x6a5a262d + struct req *req; + struct req *preq; + ssize_t start, last, stop, lpad; + ssize_t ll; + uint64_t olen; + uint8_t *dbits; + uint8_t tailbuf[8]; +}; + +static int +ved_objiterate(void *priv, int flush, const void *ptr, ssize_t len) +{ + struct ved_foo *foo; + const uint8_t *pp; + ssize_t dl; + ssize_t l; + + CAST_OBJ_NOTNULL(foo, priv, VED_FOO_MAGIC); + (void)flush; + pp = ptr; + if (len > 0) { + /* Skip over the GZIP header */ + dl = foo->start / 8 - foo->ll; + if (dl > 0) { + /* Before foo.start, skip */ + if (dl > len) + dl = len; + foo->ll += dl; + len -= dl; + pp += dl; + } + } + if (len > 0) { + /* The main body of the object */ + dl = foo->last / 8 - foo->ll; + if (dl > 0) { + if (dl > len) + dl = len; + if (ved_bytes(foo->req, foo->preq, VDP_NULL, pp, dl)) + return(-1); + foo->ll += dl; + len -= dl; + pp += dl; + } + } + if (len > 0 && foo->ll == foo->last / 8) { + /* Remove the "LAST" bit */ + foo->dbits[0] = *pp; + foo->dbits[0] &= ~(1U << (foo->last & 7)); + if (ved_bytes(foo->req, foo->preq, VDP_NULL, foo->dbits, 1)) + return (-1); + foo->ll++; + len--; + pp++; + } + if (len > 0) { + /* Last block */ + dl = foo->stop / 8 - foo->ll; + if (dl > 0) { + if (dl > len) + dl = len; + if (ved_bytes(foo->req, foo->preq, VDP_NULL, pp, dl)) + return (-1); + foo->ll += dl; + len -= dl; + pp += dl; + } + } + if (len > 0 && (foo->stop & 7) && foo->ll == foo->stop / 8) { + /* Add alignment to byte boundary */ + foo->dbits[1] = *pp; + foo->ll++; + len--; + pp++; + switch((int)(foo->stop & 7)) { + case 1: /* + * x000.... + * 00000000 00000000 11111111 11111111 + */ + case 3: /* + * xxx000.. + * 00000000 00000000 11111111 11111111 + */ + case 5: /* + * xxxxx000 + * 00000000 00000000 11111111 11111111 + */ + foo->dbits[2] = 0x00; foo->dbits[3] = 0x00; + foo->dbits[4] = 0xff; foo->dbits[5] = 0xff; + foo->lpad = 5; + break; + case 2: /* xx010000 00000100 00000001 00000000 */ + foo->dbits[1] |= 0x08; + foo->dbits[2] = 0x20; + foo->dbits[3] = 0x80; + foo->dbits[4] = 0x00; + foo->lpad = 4; + break; + case 4: /* xxxx0100 00000001 00000000 */ + foo->dbits[1] |= 0x20; + foo->dbits[2] = 0x80; + foo->dbits[3] = 0x00; + foo->lpad = 3; + break; + case 6: /* xxxxxx01 00000000 */ + foo->dbits[1] |= 0x80; + foo->dbits[2] = 0x00; + foo->lpad = 2; + break; + case 7: /* + * xxxxxxx0 + * 00...... + * 00000000 00000000 11111111 11111111 + */ + foo->dbits[2] = 0x00; + foo->dbits[3] = 0x00; foo->dbits[4] = 0x00; + foo->dbits[5] = 0xff; foo->dbits[6] = 0xff; + foo->lpad = 6; + break; + case 0: /* xxxxxxxx */ + default: + WRONG("compiler must be broken"); + } + if (ved_bytes(foo->req, foo->preq, + VDP_NULL, foo->dbits + 1, foo->lpad)) + return (-1); + } + if (len > 0) { + /* Recover GZIP tail */ + dl = foo->olen - foo->ll; + assert(dl >= 0); + if (dl > len) + dl = len; + if (dl > 0) { + assert(dl <= 8); + l = foo->ll - (foo->olen - 8); + assert(l >= 0); + assert(l <= 8); + assert(l + dl <= 8); + memcpy(foo->tailbuf + l, pp, dl); + foo->ll += dl; + len -= dl; + } + } + assert(len == 0); + return (0); +} + static void ved_stripgzip(struct req *req, struct busyobj *bo) { - ssize_t start, last, stop, lpad; ssize_t l; char *p; uint32_t icrc; uint32_t ilen; - uint64_t olen; uint8_t *dbits; - uint8_t *pp; - uint8_t tailbuf[8]; - enum objiter_status ois; - void *oi; - void *sp; - ssize_t sl, ll, dl; struct ecx *ecx; - struct req *preq; + struct ved_foo foo; CHECK_OBJ_NOTNULL(req, REQ_MAGIC); CHECK_OBJ_NOTNULL(req->objcore, OBJCORE_MAGIC); CAST_OBJ_NOTNULL(ecx, req->transport_priv, ECX_MAGIC); - preq = ecx->preq; + INIT_OBJ(&foo, VED_FOO_MAGIC); + foo.req = req; + foo.preq = ecx->preq; + memset(foo.tailbuf, 0xdd, sizeof foo.tailbuf); + + /* XXX: Is this really required ? */ if (bo != NULL) VBO_waitstate(bo, BOS_FINISHED); @@ -554,162 +702,28 @@ ved_stripgzip(struct req *req, struct busyobj *bo) p = ObjGetattr(req->wrk, req->objcore, OA_GZIPBITS, &l); AN(p); assert(l == 32); - start = vbe64dec(p); - last = vbe64dec(p + 8); - stop = vbe64dec(p + 16); - olen = ObjGetLen(req->wrk, req->objcore); - assert(start > 0 && start < olen * 8); - assert(last > 0 && last < olen * 8); - assert(stop > 0 && stop < olen * 8); - assert(last >= start); - assert(last < stop); + foo.start = vbe64dec(p); + foo.last = vbe64dec(p + 8); + foo.stop = vbe64dec(p + 16); + foo.olen = ObjGetLen(req->wrk, req->objcore); + assert(foo.start > 0 && foo.start < foo.olen * 8); + assert(foo.last > 0 && foo.last < foo.olen * 8); + assert(foo.stop > 0 && foo.stop < foo.olen * 8); + assert(foo.last >= foo.start); + assert(foo.last < foo.stop); /* The start bit must be byte aligned. */ - AZ(start & 7); - - /* - * XXX: optimize for the case where the 'last' - * XXX: bit is in a empty copy block - */ + AZ(foo.start & 7); - memset(tailbuf, 0xdd, sizeof tailbuf); dbits = WS_Alloc(req->ws, 8); AN(dbits); - ll = 0; - oi = ObjIterBegin(req->wrk, req->objcore); - do { - ois = ObjIter(req->objcore, oi, &sp, &sl); - pp = sp; - if (sl > 0) { - /* Skip over the GZIP header */ - dl = start / 8 - ll; - if (dl > 0) { - /* Before start, skip */ - if (dl > sl) - dl = sl; - ll += dl; - sl -= dl; - pp += dl; - } - } - if (sl > 0) { - /* The main body of the object */ - dl = last / 8 - ll; - if (dl > 0) { - if (dl > sl) - dl = sl; - if (ved_bytes(req, preq, VDP_NULL, pp, dl)) - break; - ll += dl; - sl -= dl; - pp += dl; - } - } - if (sl > 0 && ll == last / 8) { - /* Remove the "LAST" bit */ - dbits[0] = *pp; - dbits[0] &= ~(1U << (last & 7)); - if (ved_bytes(req, preq, VDP_NULL, dbits, 1)) - break; - ll++; - sl--; - pp++; - } - if (sl > 0) { - /* Last block */ - dl = stop / 8 - ll; - if (dl > 0) { - if (dl > sl) - dl = sl; - if (ved_bytes(req, preq, VDP_NULL, pp, dl)) - break; - ll += dl; - sl -= dl; - pp += dl; - } - } - if (sl > 0 && (stop & 7) && ll == stop / 8) { - /* Add alignment to byte boundary */ - dbits[1] = *pp; - ll++; - sl--; - pp++; - switch((int)(stop & 7)) { - case 1: /* - * x000.... - * 00000000 00000000 11111111 11111111 - */ - case 3: /* - * xxx000.. - * 00000000 00000000 11111111 11111111 - */ - case 5: /* - * xxxxx000 - * 00000000 00000000 11111111 11111111 - */ - dbits[2] = 0x00; dbits[3] = 0x00; - dbits[4] = 0xff; dbits[5] = 0xff; - lpad = 5; - break; - case 2: /* xx010000 00000100 00000001 00000000 */ - dbits[1] |= 0x08; - dbits[2] = 0x20; - dbits[3] = 0x80; - dbits[4] = 0x00; - lpad = 4; - break; - case 4: /* xxxx0100 00000001 00000000 */ - dbits[1] |= 0x20; - dbits[2] = 0x80; - dbits[3] = 0x00; - lpad = 3; - break; - case 6: /* xxxxxx01 00000000 */ - dbits[1] |= 0x80; - dbits[2] = 0x00; - lpad = 2; - break; - case 7: /* - * xxxxxxx0 - * 00...... - * 00000000 00000000 11111111 11111111 - */ - dbits[2] = 0x00; - dbits[3] = 0x00; dbits[4] = 0x00; - dbits[5] = 0xff; dbits[6] = 0xff; - lpad = 6; - break; - case 0: /* xxxxxxxx */ - default: - WRONG("compiler must be broken"); - } - if (ved_bytes(req, preq, VDP_NULL, dbits + 1, lpad)) - break; - } - if (sl > 0) { - /* Recover GZIP tail */ - dl = olen - ll; - assert(dl >= 0); - if (dl > sl) - dl = sl; - if (dl > 0) { - assert(dl <= 8); - l = ll - (olen - 8); - assert(l >= 0); - assert(l <= 8); - assert(l + dl <= 8); - memcpy(tailbuf + l, pp, dl); - ll += dl; - sl -= dl; - pp += dl; - } - } - } while (ois == OIS_DATA || ois == OIS_STREAM); - ObjIterEnd(req->objcore, &oi); - (void)ved_bytes(req, preq, VDP_FLUSH, NULL, 0); + foo.dbits = dbits; + (void)ObjIterate(req->wrk, req->objcore, &foo, ved_objiterate); + /* XXX: error check ?? */ + (void)ved_bytes(req, foo.preq, VDP_FLUSH, NULL, 0); - icrc = vle32dec(tailbuf); - ilen = vle32dec(tailbuf + 4); + icrc = vle32dec(foo.tailbuf); + ilen = vle32dec(foo.tailbuf + 4); ecx->crc = crc32_combine(ecx->crc, icrc, ilen); ecx->l_crc += ilen; From phk at FreeBSD.org Thu Dec 10 00:23:28 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 10 Dec 2015 01:23:28 +0100 Subject: [master] c2c164d Convert to ObjIterate() Message-ID: commit c2c164d8f25732a970dc87fbc079a96c4d02d07d Author: Poul-Henning Kamp Date: Wed Dec 9 23:02:53 2015 +0000 Convert to ObjIterate() diff --git a/bin/varnishd/cache/cache_req_body.c b/bin/varnishd/cache/cache_req_body.c index 02050f9..36256c9 100644 --- a/bin/varnishd/cache/cache_req_body.c +++ b/bin/varnishd/cache/cache_req_body.c @@ -47,33 +47,51 @@ * return length or -1 on error */ +struct vrb_foo { + unsigned magic; +#define VRB_FOO_MAGIC 0x30240389 + struct req *req; + void *priv; + req_body_iter_f *func; + ssize_t ll; +}; + +static int +vrb_objiterator(void *priv, int flush, const void *ptr, ssize_t len) +{ + struct vrb_foo *foo; + + CAST_OBJ_NOTNULL(foo, priv, VRB_FOO_MAGIC); + + (void)flush; + foo->ll += len; + return (foo->func(foo->req, foo->priv, ptr, len)); +} + ssize_t VRB_Iterate(struct req *req, req_body_iter_f *func, void *priv) { char buf[8192]; ssize_t l, ll = 0; - void *p; int i; struct vfp_ctx *vfc; enum vfp_status vfps = VFP_ERROR; - void *oi; - enum objiter_status ois; + struct vrb_foo foo; CHECK_OBJ_NOTNULL(req, REQ_MAGIC); AN(func); switch(req->req_body_status) { case REQ_BODY_CACHED: - oi = ObjIterBegin(req->wrk, req->body_oc); - AN(oi); - do { - ois = ObjIter(req->body_oc, oi, &p, &l); - ll += l; - if (l > 0 && func(req, priv, p, l)) - break; - } while (ois == OIS_DATA); - ObjIterEnd(req->body_oc, &oi); - return (ois == OIS_DONE ? ll : -1); + INIT_OBJ(&foo, VRB_FOO_MAGIC); + foo.req = req; + foo.priv = priv; + foo.func = func; + foo.ll = 0; + + if (ObjIterate(req->wrk, req->body_oc, &foo, vrb_objiterator)) + return (-1); + return (foo.ll); case REQ_BODY_NONE: return (0); case REQ_BODY_WITH_LEN: From phk at FreeBSD.org Thu Dec 10 00:23:28 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 10 Dec 2015 01:23:28 +0100 Subject: [master] b44b1e9 Integrate the previous three ObjIter* functions into ObjIterate() Message-ID: commit b44b1e94d9eddc3701e6e3ac053b36e4848e82f7 Author: Poul-Henning Kamp Date: Thu Dec 10 00:20:06 2015 +0000 Integrate the previous three ObjIter* functions into ObjIterate() diff --git a/bin/varnishd/cache/cache_obj.c b/bin/varnishd/cache/cache_obj.c index f7c0712..206cf03 100644 --- a/bin/varnishd/cache/cache_obj.c +++ b/bin/varnishd/cache/cache_obj.c @@ -31,7 +31,7 @@ * ObjExtend Commit space * ObjDone Object completed * ObjGetLen Len of committed space - * ObjIter Iterate over committed space + * ObjIterate Iterate over committed space * ObjReserveAttr Attr will be set later * ObjSetAttr Set attr now * ObjGetAttr Get attr no @@ -70,196 +70,102 @@ obj_getobj(struct worker *wrk, struct objcore *oc) } /*==================================================================== - * ObjIterBegin() - * ObjIter() - * ObjIterEnd() + * ObjIterate() * - * These three allow iteration over the body of an object. - * The ObjIterBegin() returns a magic cookie which must be passed to - * ObjIter() and which ObjIterEnd() will obliterate again. - * - * These functions get slightly complicated due to unbusy but not - * yet completed objects (ie: when streaming). Exactly how they - * interact with ObjExtend(), especially with respect to locking, - * is entirely up to the implementation. */ -enum objiter_status { - OIS_DONE, - OIS_DATA, - OIS_STREAM, - OIS_ERROR, -}; - -struct objiter { - unsigned magic; -#define OBJITER_MAGIC 0x745fb151 - struct busyobj *bo; - struct objcore *oc; - struct object *obj; - struct storage *st; - struct worker *wrk; - ssize_t len; - struct storage *checkpoint; - ssize_t checkpoint_len; -}; - -static void * -ObjIterBegin(struct worker *wrk, struct objcore *oc) +int +ObjIterate(struct worker *wrk, struct objcore *oc, + void *priv, objiterate_f *func) { - struct objiter *oi; + struct busyobj *bo; struct object *obj; + struct storage *st; + struct storage *checkpoint = NULL; + ssize_t checkpoint_len = 0; + ssize_t len = 0; + int ret = 0; + ssize_t ol; + ssize_t nl; + ssize_t sl; + void *p; + ssize_t l; + const struct storeobj_methods *om = obj_getmethods(oc); - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); + if (om->objiterator != NULL) + return (om->objiterator(wrk, oc, priv, func)); - CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); obj = obj_getobj(wrk, oc); CHECK_OBJ_NOTNULL(obj, OBJECT_MAGIC); - ALLOC_OBJ(oi, OBJITER_MAGIC); - if (oi == NULL) - return (oi); - oi->oc = oc; - oi->obj = obj; - oi->wrk = wrk; - oi->bo = HSH_RefBusy(oc); - return (oi); -} -static enum objiter_status -ObjIter(void *oix, void **p, ssize_t *l) -{ - struct objiter *oi; - ssize_t ol; - ssize_t nl; - ssize_t sl; + bo = HSH_RefBusy(oc); + + if (bo == NULL) { + VTAILQ_FOREACH(st, &obj->list, list) + if (func(priv, 0, st->ptr, st->len)) + return (-1); + return (0); + } + + p = NULL; + l = 0; - AN(oix); - AN(p); - AN(l); - - CAST_OBJ_NOTNULL(oi, oix, OBJITER_MAGIC); - CHECK_OBJ_NOTNULL(oi->obj, OBJECT_MAGIC); - *p = NULL; - *l = 0; - - if (oi->bo == NULL) { - if (oi->st == NULL) - oi->st = VTAILQ_FIRST(&oi->obj->list); - else - oi->st = VTAILQ_NEXT(oi->st, list); - while(oi->st != NULL && oi->st->len == 0) - oi->st = VTAILQ_NEXT(oi->st, list); - if (oi->st != NULL) { - *p = oi->st->ptr; - *l = oi->st->len; - assert(*l > 0); - return (OIS_DATA); + while (1) { + ol = len; + nl = VBO_waitlen(wrk, bo, ol); + if (bo->state == BOS_FAILED) { + ret = -1; + break; } - return (OIS_DONE); - } else { - ol = oi->len; - while (1) { - nl = VBO_waitlen(oi->wrk, oi->bo, ol); - if (nl != ol) + if (nl == ol) { + if (bo->state == BOS_FINISHED) break; - if (oi->bo->state == BOS_FINISHED) - return (OIS_DONE); - if (oi->bo->state == BOS_FAILED) - return (OIS_ERROR); + continue; } - Lck_Lock(&oi->bo->mtx); - AZ(VTAILQ_EMPTY(&oi->obj->list)); - if (oi->checkpoint == NULL) { - oi->st = VTAILQ_FIRST(&oi->obj->list); + Lck_Lock(&bo->mtx); + AZ(VTAILQ_EMPTY(&obj->list)); + if (checkpoint == NULL) { + st = VTAILQ_FIRST(&obj->list); sl = 0; } else { - oi->st = oi->checkpoint; - sl = oi->checkpoint_len; - ol -= oi->checkpoint_len; + st = checkpoint; + sl = checkpoint_len; + ol -= checkpoint_len; } - while (oi->st != NULL) { - if (oi->st->len > ol) { - *p = oi->st->ptr + ol; - *l = oi->st->len - ol; - oi->len += *l; + while (st != NULL) { + if (st->len > ol) { + p = st->ptr + ol; + l = st->len - ol; + len += l; break; } - ol -= oi->st->len; + ol -= st->len; assert(ol >= 0); - nl -= oi->st->len; + nl -= st->len; assert(nl > 0); - sl += oi->st->len; - oi->st = VTAILQ_NEXT(oi->st, list); - if (VTAILQ_NEXT(oi->st, list) != NULL) { - oi->checkpoint = oi->st; - oi->checkpoint_len = sl; + sl += st->len; + st = VTAILQ_NEXT(st, list); + if (VTAILQ_NEXT(st, list) != NULL) { + checkpoint = st; + checkpoint_len = sl; } } - CHECK_OBJ_NOTNULL(oi->obj, OBJECT_MAGIC); - CHECK_OBJ_NOTNULL(oi->st, STORAGE_MAGIC); - oi->st = VTAILQ_NEXT(oi->st, list); - if (oi->st != NULL && oi->st->len == 0) - oi->st = NULL; - Lck_Unlock(&oi->bo->mtx); - assert(*l > 0 || oi->bo->state == BOS_FINISHED); - return (oi->st != NULL ? OIS_DATA : OIS_STREAM); - } -} - -static void -ObjIterEnd(void **oix) -{ - struct objiter *oi; - - AN(oix); - - CAST_OBJ_NOTNULL(oi, (*oix), OBJITER_MAGIC); - *oix = NULL; - CHECK_OBJ_NOTNULL(oi->obj, OBJECT_MAGIC); - if (oi->bo != NULL) { - if (oi->oc->flags & OC_F_PASS) - oi->bo->abandon = 1; - VBO_DerefBusyObj(oi->wrk, &oi->bo); - } - FREE_OBJ(oi); -} - -int -ObjIterate(struct worker *wrk, struct objcore *oc, - void *priv, objiterate_f *func) -{ - void *oi; - enum objiter_status ois; - void *ptr; - ssize_t len; - const struct storeobj_methods *om = obj_getmethods(oc); - - if (om->objiterator != NULL) - return (om->objiterator(wrk, oc, priv, func)); - - oi = ObjIterBegin(wrk, oc); - do { - ois = ObjIter(oi, &ptr, &len); - switch(ois) { - case OIS_DONE: - AZ(len); - break; - case OIS_ERROR: - break; - case OIS_DATA: - if (func(priv, 0, ptr, len)) - ois = OIS_ERROR; - break; - case OIS_STREAM: - if (func(priv, 1, ptr, len)) - ois = OIS_ERROR; + CHECK_OBJ_NOTNULL(obj, OBJECT_MAGIC); + CHECK_OBJ_NOTNULL(st, STORAGE_MAGIC); + st = VTAILQ_NEXT(st, list); + if (st != NULL && st->len == 0) + st = NULL; + Lck_Unlock(&bo->mtx); + assert(l > 0 || bo->state == BOS_FINISHED); + if (func(priv, st != NULL ? 0 : 1, p, l)) { + ret = -1; break; - default: - WRONG("Wrong OIS value"); } - } while (ois == OIS_DATA || ois == OIS_STREAM); - ObjIterEnd(&oi); - return (ois == OIS_DONE ? 0 : -1); + } + if (oc->flags & OC_F_PASS) + bo->abandon = 1; + VBO_DerefBusyObj(wrk, &bo); + return (ret); } /*-------------------------------------------------------------------- From phk at FreeBSD.org Thu Dec 10 00:23:28 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 10 Dec 2015 01:23:28 +0100 Subject: [master] 0e7aad8 Replace the three stevedore methods for iterating over objects with a single one. Message-ID: commit 0e7aad850a3cb2344140f3d0d5530f1969a5664f Author: Poul-Henning Kamp Date: Wed Dec 9 23:11:35 2015 +0000 Replace the three stevedore methods for iterating over objects with a single one. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index eb892ae..10019bf 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -858,15 +858,6 @@ void MPL_Free(struct mempool *mpl, void *item); typedef int objiterate_f(void *priv, int flush, const void *ptr, ssize_t len); int ObjIterate(struct worker *, struct objcore *, void *priv, objiterate_f *func); -enum objiter_status { - OIS_DONE, - OIS_DATA, - OIS_STREAM, - OIS_ERROR, -}; -void *ObjIterBegin(struct worker *, struct objcore *); -enum objiter_status ObjIter(struct objcore *, void *, void **, ssize_t *); -void ObjIterEnd(struct objcore *, void **); int ObjGetSpace(struct worker *, struct objcore *, ssize_t *sz, uint8_t **ptr); void ObjExtend(struct worker *, struct objcore *, ssize_t l); void ObjTrimStore(struct worker *, struct objcore *); diff --git a/bin/varnishd/cache/cache_obj.c b/bin/varnishd/cache/cache_obj.c index 2203845..f7c0712 100644 --- a/bin/varnishd/cache/cache_obj.c +++ b/bin/varnishd/cache/cache_obj.c @@ -84,6 +84,13 @@ obj_getobj(struct worker *wrk, struct objcore *oc) * is entirely up to the implementation. */ +enum objiter_status { + OIS_DONE, + OIS_DATA, + OIS_STREAM, + OIS_ERROR, +}; + struct objiter { unsigned magic; #define OBJITER_MAGIC 0x745fb151 @@ -97,18 +104,14 @@ struct objiter { ssize_t checkpoint_len; }; -void * +static void * ObjIterBegin(struct worker *wrk, struct objcore *oc) { struct objiter *oi; struct object *obj; - const struct storeobj_methods *om = obj_getmethods(oc); CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - if (om->objiterbegin != NULL) - return (om->objiterbegin(wrk, oc)); - CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); obj = obj_getobj(wrk, oc); CHECK_OBJ_NOTNULL(obj, OBJECT_MAGIC); @@ -122,22 +125,18 @@ ObjIterBegin(struct worker *wrk, struct objcore *oc) return (oi); } -enum objiter_status -ObjIter(struct objcore *oc, void *oix, void **p, ssize_t *l) +static enum objiter_status +ObjIter(void *oix, void **p, ssize_t *l) { struct objiter *oi; ssize_t ol; ssize_t nl; ssize_t sl; - const struct storeobj_methods *om = obj_getmethods(oc); AN(oix); AN(p); AN(l); - if (om->objiter != NULL) - return (om->objiter(oc, oix, p, l)); - CAST_OBJ_NOTNULL(oi, oix, OBJITER_MAGIC); CHECK_OBJ_NOTNULL(oi->obj, OBJECT_MAGIC); *p = NULL; @@ -207,19 +206,13 @@ ObjIter(struct objcore *oc, void *oix, void **p, ssize_t *l) } } -void -ObjIterEnd(struct objcore *oc, void **oix) +static void +ObjIterEnd(void **oix) { struct objiter *oi; - const struct storeobj_methods *om = obj_getmethods(oc); AN(oix); - if (om->objiterend != NULL) { - om->objiterend(oc, oix); - return; - } - CAST_OBJ_NOTNULL(oi, (*oix), OBJITER_MAGIC); *oix = NULL; CHECK_OBJ_NOTNULL(oi->obj, OBJECT_MAGIC); @@ -239,10 +232,14 @@ ObjIterate(struct worker *wrk, struct objcore *oc, enum objiter_status ois; void *ptr; ssize_t len; + const struct storeobj_methods *om = obj_getmethods(oc); + + if (om->objiterator != NULL) + return (om->objiterator(wrk, oc, priv, func)); oi = ObjIterBegin(wrk, oc); do { - ois = ObjIter(oc, oi, &ptr, &len); + ois = ObjIter(oi, &ptr, &len); switch(ois) { case OIS_DONE: AZ(len); @@ -261,7 +258,7 @@ ObjIterate(struct worker *wrk, struct objcore *oc, WRONG("Wrong OIS value"); } } while (ois == OIS_DATA || ois == OIS_STREAM); - ObjIterEnd(oc, &oi); + ObjIterEnd(&oi); return (ois == OIS_DONE ? 0 : -1); } diff --git a/bin/varnishd/storage/storage.h b/bin/varnishd/storage/storage.h index 5c5bdfb..f6636ee 100644 --- a/bin/varnishd/storage/storage.h +++ b/bin/varnishd/storage/storage.h @@ -79,6 +79,8 @@ struct object { /* Methods on objcore ------------------------------------------------*/ +#ifdef VARNISH_CACHE_CHILD + typedef void updatemeta_f(struct worker *, struct objcore *oc); typedef void freeobj_f(struct worker *, struct objcore *oc); typedef struct lru *getlru_f(const struct objcore *oc); @@ -93,10 +95,8 @@ typedef struct object *getobj_f(struct worker *, struct objcore *oc); * Or the can be "complex" and provide all of these methods: * (Described in comments in cache_obj.c) */ -typedef void *objiterbegin_f(struct worker *, struct objcore *oc); -typedef enum objiter_status objiter_f(struct objcore *oc, void *oix, - void **p, ssize_t *l); -typedef void objiterend_f(struct objcore *, void **oix); +typedef int objiterator_f(struct worker *, struct objcore *oc, + void *priv, objiterate_f *func); typedef int objgetspace_f(struct worker *, struct objcore *, ssize_t *sz, uint8_t **ptr); typedef void objextend_f(struct worker *, struct objcore *, ssize_t l); @@ -115,9 +115,7 @@ struct storeobj_methods { getobj_f *getobj; - objiterbegin_f *objiterbegin; - objiter_f *objiter; - objiterend_f *objiterend; + objiterator_f *objiterator; objgetspace_f *objgetspace; objextend_f *objextend; objgetlen_f *objgetlen; @@ -127,6 +125,12 @@ struct storeobj_methods { objsetattr_f *objsetattr; }; +#else + +struct storeobj_methods; + +#endif + /* Prototypes --------------------------------------------------------*/ typedef void storage_init_f(struct stevedore *, int ac, char * const *av); From phk at FreeBSD.org Thu Dec 10 00:25:12 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 09 Dec 2015 16:25:12 -0800 Subject: [varnishcache/varnish-cache] 6e29a1: Constify req.body pointer when interating over it. Message-ID: <5668c668e763b_344f3ffc293c32b8109062@hookshot-fe4-cp1-prd.iad.github.net.mail> Branch: refs/heads/master Home: https://github.com/varnishcache/varnish-cache Commit: 6e29a151a0e37b9b6aed5d08f3c8b56008235471 https://github.com/varnishcache/varnish-cache/commit/6e29a151a0e37b9b6aed5d08f3c8b56008235471 Author: Poul-Henning Kamp Date: 2015-12-09 (Wed, 09 Dec 2015) Changed paths: M bin/varnishd/cache/cache.h M bin/varnishd/cache/cache_req_body.c M bin/varnishd/http1/cache_http1_fetch.c Log Message: ----------- Constify req.body pointer when interating over it. Commit: f5b92e27478874a46b71d4aa0c3e35bdaa31f396 https://github.com/varnishcache/varnish-cache/commit/f5b92e27478874a46b71d4aa0c3e35bdaa31f396 Author: Poul-Henning Kamp Date: 2015-12-09 (Wed, 09 Dec 2015) Changed paths: M bin/varnishd/cache/cache_deliver_proc.c M bin/varnishd/cache/cache_filter.h M bin/varnishd/http1/cache_http1_deliver.c Log Message: ----------- Make VDP_DeliverObj() return a simple int status code Commit: ef14640730b8eca2cfb7458d08ee10270ce7968f https://github.com/varnishcache/varnish-cache/commit/ef14640730b8eca2cfb7458d08ee10270ce7968f Author: Poul-Henning Kamp Date: 2015-12-09 (Wed, 09 Dec 2015) Changed paths: M bin/varnishd/cache/cache.h M bin/varnishd/cache/cache_obj.c Log Message: ----------- Add ObjIterate() wrapper function Commit: 1551a2d19cd1493b1d62e80c89741426dc445656 https://github.com/varnishcache/varnish-cache/commit/1551a2d19cd1493b1d62e80c89741426dc445656 Author: Poul-Henning Kamp Date: 2015-12-09 (Wed, 09 Dec 2015) Changed paths: M bin/varnishd/cache/cache_deliver_proc.c Log Message: ----------- Use ObjIterate() Commit: b924bdf615821f51816e842cbf1113890a4ec7bc https://github.com/varnishcache/varnish-cache/commit/b924bdf615821f51816e842cbf1113890a4ec7bc Author: Poul-Henning Kamp Date: 2015-12-09 (Wed, 09 Dec 2015) Changed paths: M bin/varnishd/cache/cache_fetch.c Log Message: ----------- Use ObjIterate() Commit: 3dc7521c6db46919630c735664a7e147e14a0a87 https://github.com/varnishcache/varnish-cache/commit/3dc7521c6db46919630c735664a7e147e14a0a87 Author: Poul-Henning Kamp Date: 2015-12-09 (Wed, 09 Dec 2015) Changed paths: M bin/varnishd/cache/cache_esi_deliver.c Log Message: ----------- Convert to use ObjIterate() Commit: c2c164d8f25732a970dc87fbc079a96c4d02d07d https://github.com/varnishcache/varnish-cache/commit/c2c164d8f25732a970dc87fbc079a96c4d02d07d Author: Poul-Henning Kamp Date: 2015-12-09 (Wed, 09 Dec 2015) Changed paths: M bin/varnishd/cache/cache_req_body.c Log Message: ----------- Convert to ObjIterate() Commit: 0e7aad850a3cb2344140f3d0d5530f1969a5664f https://github.com/varnishcache/varnish-cache/commit/0e7aad850a3cb2344140f3d0d5530f1969a5664f Author: Poul-Henning Kamp Date: 2015-12-09 (Wed, 09 Dec 2015) Changed paths: M bin/varnishd/cache/cache.h M bin/varnishd/cache/cache_obj.c M bin/varnishd/storage/storage.h Log Message: ----------- Replace the three stevedore methods for iterating over objects with a single one. Commit: b44b1e94d9eddc3701e6e3ac053b36e4848e82f7 https://github.com/varnishcache/varnish-cache/commit/b44b1e94d9eddc3701e6e3ac053b36e4848e82f7 Author: Poul-Henning Kamp Date: 2015-12-10 (Thu, 10 Dec 2015) Changed paths: M bin/varnishd/cache/cache_obj.c Log Message: ----------- Integrate the previous three ObjIter* functions into ObjIterate() Compare: https://github.com/varnishcache/varnish-cache/compare/a3ebb1b642b0...b44b1e94d9ed From phk at FreeBSD.org Thu Dec 10 09:07:51 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 10 Dec 2015 10:07:51 +0100 Subject: [master] 72a8e80 Make the req.body iterator use same prototype as obj iterator Message-ID: commit 72a8e80c33056b6141b991f2e4faf94cff6ce60d Author: Poul-Henning Kamp Date: Thu Dec 10 09:07:29 2015 +0000 Make the req.body iterator use same prototype as obj iterator diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 10019bf..dc2d72e 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -682,8 +682,7 @@ void VBO_waitstate(struct busyobj *bo, enum busyobj_state_e want); /* cache_req_body.c */ int VRB_Ignore(struct req *req); ssize_t VRB_Cache(struct req *req, ssize_t maxsize); -typedef int (req_body_iter_f)(struct req *, void *priv, - const void *ptr, size_t); +typedef int req_body_iter_f(void *priv, int flush, const void *ptr, ssize_t len); ssize_t VRB_Iterate(struct req *req, req_body_iter_f *func, void *priv); void VRB_Free(struct req *req); diff --git a/bin/varnishd/cache/cache_req_body.c b/bin/varnishd/cache/cache_req_body.c index 36256c9..4f4d2af 100644 --- a/bin/varnishd/cache/cache_req_body.c +++ b/bin/varnishd/cache/cache_req_body.c @@ -56,16 +56,15 @@ struct vrb_foo { ssize_t ll; }; -static int +static int __match_proto__(objiterate_f) vrb_objiterator(void *priv, int flush, const void *ptr, ssize_t len) { struct vrb_foo *foo; CAST_OBJ_NOTNULL(foo, priv, VRB_FOO_MAGIC); - (void)flush; foo->ll += len; - return (foo->func(foo->req, foo->priv, ptr, len)); + return (foo->func(foo->priv, flush, ptr, len)); } ssize_t @@ -144,7 +143,7 @@ VRB_Iterate(struct req *req, req_body_iter_f *func, void *priv) req->req_bodybytes += l; req->acct.req_bodybytes += l; ll += l; - l = func(req, priv, buf, l); + l = func(priv, 1, buf, l); if (l) { req->req_body_status = REQ_BODY_FAIL; ll = -1; @@ -165,11 +164,11 @@ VRB_Iterate(struct req *req, req_body_iter_f *func, void *priv) */ static int __match_proto__(req_body_iter_f) -httpq_req_body_discard(struct req *req, void *priv, const void *ptr, size_t len) +httpq_req_body_discard(void *priv, int flush, const void *ptr, ssize_t len) { - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); (void)priv; + (void)flush; (void)ptr; (void)len; return (0); diff --git a/bin/varnishd/http1/cache_http1_fetch.c b/bin/varnishd/http1/cache_http1_fetch.c index 0a7f100..4659c54 100644 --- a/bin/varnishd/http1/cache_http1_fetch.c +++ b/bin/varnishd/http1/cache_http1_fetch.c @@ -49,16 +49,15 @@ */ static int __match_proto__(req_body_iter_f) -vbf_iter_req_body(struct req *req, void *priv, const void *ptr, size_t l) +vbf_iter_req_body(void *priv, int flush, const void *ptr, ssize_t l) { struct busyobj *bo; - CHECK_OBJ_NOTNULL(req, REQ_MAGIC); CAST_OBJ_NOTNULL(bo, priv, BUSYOBJ_MAGIC); if (l > 0) { bo->acct.bereq_bodybytes += V1L_Write(bo->wrk, ptr, l); - if (V1L_Flush(bo->wrk)) + if (flush && V1L_Flush(bo->wrk)) return (-1); } return (0); From phk at FreeBSD.org Thu Dec 10 09:10:14 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 10 Dec 2015 01:10:14 -0800 Subject: [varnishcache/varnish-cache] 72a8e8: Make the req.body iterator use same prototype as o... Message-ID: <566941762c810_39bf3fd5430992c06449e@hookshot-fe6-cp1-prd.iad.github.net.mail> Branch: refs/heads/master Home: https://github.com/varnishcache/varnish-cache Commit: 72a8e80c33056b6141b991f2e4faf94cff6ce60d https://github.com/varnishcache/varnish-cache/commit/72a8e80c33056b6141b991f2e4faf94cff6ce60d Author: Poul-Henning Kamp Date: 2015-12-10 (Thu, 10 Dec 2015) Changed paths: M bin/varnishd/cache/cache.h M bin/varnishd/cache/cache_req_body.c M bin/varnishd/http1/cache_http1_fetch.c Log Message: ----------- Make the req.body iterator use same prototype as obj iterator From fgsch at lodoss.net Thu Dec 10 09:11:38 2015 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Thu, 10 Dec 2015 10:11:38 +0100 Subject: [master] c11fc5b Add missing double quotes Message-ID: commit c11fc5bd998b8d3ac5f983f9cb16bfe059159802 Author: Federico G. Schwindt Date: Thu Dec 10 01:44:35 2015 +0000 Add missing double quotes diff --git a/lib/libvmod_std/vmod.vcc b/lib/libvmod_std/vmod.vcc index b0dba07..61c334f 100644 --- a/lib/libvmod_std/vmod.vcc +++ b/lib/libvmod_std/vmod.vcc @@ -64,7 +64,7 @@ Description request so probably want to set it on every request should you utilize it. Example - | if (req.url ~ ^/slow/) { + | if (req.url ~ "^/slow/") { | std.set_ip_tos(0); | } From fgsch at lodoss.net Thu Dec 10 09:11:38 2015 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Thu, 10 Dec 2015 10:11:38 +0100 Subject: [master] 858486f Handle pthread_setname_np() and variants correctly Message-ID: commit 858486fc29392cf98a30d137fe76cdd6efc18cae Author: Federico G. Schwindt Date: Thu Dec 10 09:05:16 2015 +0000 Handle pthread_setname_np() and variants correctly Send your kudos to POSIX for failing to provide a standard here. diff --git a/bin/varnishd/cache/cache_main.c b/bin/varnishd/cache/cache_main.c index bfb428e..0f28302 100644 --- a/bin/varnishd/cache/cache_main.c +++ b/bin/varnishd/cache/cache_main.c @@ -95,8 +95,14 @@ THR_SetName(const char *name) #if defined(HAVE_PTHREAD_SET_NAME_NP) pthread_set_name_np(pthread_self(), name); #elif defined(HAVE_PTHREAD_SETNAME_NP) +#if defined(__APPLE__) + pthread_setname_np(name); +#elif defined(__NetBSD__) + pthread_setname_np(pthread_self(), "%s", name); +#else pthread_setname_np(pthread_self(), name); #endif +#endif } const char * From fgsch at lodoss.net Thu Dec 10 09:15:13 2015 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Thu, 10 Dec 2015 01:15:13 -0800 Subject: [varnishcache/varnish-cache] c11fc5: Add missing double quotes Message-ID: <566942a1e7a2d_547f3fedb9d932bc881da@hookshot-fe1-cp1-prd.iad.github.net.mail> Branch: refs/heads/master Home: https://github.com/varnishcache/varnish-cache Commit: c11fc5bd998b8d3ac5f983f9cb16bfe059159802 https://github.com/varnishcache/varnish-cache/commit/c11fc5bd998b8d3ac5f983f9cb16bfe059159802 Author: Federico G. Schwindt Date: 2015-12-10 (Thu, 10 Dec 2015) Changed paths: M lib/libvmod_std/vmod.vcc Log Message: ----------- Add missing double quotes Commit: 858486fc29392cf98a30d137fe76cdd6efc18cae https://github.com/varnishcache/varnish-cache/commit/858486fc29392cf98a30d137fe76cdd6efc18cae Author: Federico G. Schwindt Date: 2015-12-10 (Thu, 10 Dec 2015) Changed paths: M bin/varnishd/cache/cache_main.c Log Message: ----------- Handle pthread_setname_np() and variants correctly Send your kudos to POSIX for failing to provide a standard here. Compare: https://github.com/varnishcache/varnish-cache/compare/72a8e80c3305...858486fc2939 From phk at FreeBSD.org Thu Dec 10 09:21:52 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 10 Dec 2015 10:21:52 +0100 Subject: [master] 1bbc648 Reorder some includes to be alphabetical Message-ID: commit 1bbc648a3c759b05bcc76759864e8e4c052008fd Author: Poul-Henning Kamp Date: Thu Dec 10 09:21:33 2015 +0000 Reorder some includes to be alphabetical diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index dc2d72e..2c84e28 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -679,17 +679,6 @@ ssize_t VBO_waitlen(struct worker *, struct busyobj *, ssize_t l); void VBO_setstate(struct busyobj *bo, enum busyobj_state_e next); void VBO_waitstate(struct busyobj *bo, enum busyobj_state_e want); -/* cache_req_body.c */ -int VRB_Ignore(struct req *req); -ssize_t VRB_Cache(struct req *req, ssize_t maxsize); -typedef int req_body_iter_f(void *priv, int flush, const void *ptr, ssize_t len); -ssize_t VRB_Iterate(struct req *req, req_body_iter_f *func, void *priv); -void VRB_Free(struct req *req); - -/* cache_req_fsm.c [CNT] */ -enum req_fsm_nxt CNT_Request(struct worker *, struct req *); -void CNT_AcctLogCharge(struct dstat *, struct req *); - /* cache_cli.c [CLI] */ extern pthread_t cli_thread; #define ASSERT_CLI() do {assert(pthread_self() == cli_thread);} while (0) @@ -906,6 +895,17 @@ void Req_Release(struct req *); int Req_Cleanup(struct sess *sp, struct worker *wrk, struct req *req); void Req_Fail(struct req *req, enum sess_close reason); +/* cache_req_body.c */ +int VRB_Ignore(struct req *req); +ssize_t VRB_Cache(struct req *req, ssize_t maxsize); +typedef int req_body_iter_f(void *priv, int flush, const void *ptr, ssize_t len); +ssize_t VRB_Iterate(struct req *req, req_body_iter_f *func, void *priv); +void VRB_Free(struct req *req); + +/* cache_req_fsm.c [CNT] */ +enum req_fsm_nxt CNT_Request(struct worker *, struct req *); +void CNT_AcctLogCharge(struct dstat *, struct req *); + /* cache_session.c [SES] */ struct sess *SES_New(struct pool *); void SES_Close(struct sess *sp, enum sess_close reason); From phk at FreeBSD.org Thu Dec 10 09:25:14 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 10 Dec 2015 01:25:14 -0800 Subject: [varnishcache/varnish-cache] 1bbc64: Reorder some includes to be alphabetical Message-ID: <566944fa81b75_38333f817235329c614c4@hookshot-fe6-cp1-prd.iad.github.net.mail> Branch: refs/heads/master Home: https://github.com/varnishcache/varnish-cache Commit: 1bbc648a3c759b05bcc76759864e8e4c052008fd https://github.com/varnishcache/varnish-cache/commit/1bbc648a3c759b05bcc76759864e8e4c052008fd Author: Poul-Henning Kamp Date: 2015-12-10 (Thu, 10 Dec 2015) Changed paths: M bin/varnishd/cache/cache.h Log Message: ----------- Reorder some includes to be alphabetical From phk at FreeBSD.org Thu Dec 10 09:37:09 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 10 Dec 2015 10:37:09 +0100 Subject: [master] faae8c1 Use the same iterator function prototype for obj and req.body Message-ID: commit faae8c1da7c355956126b7485dc677e8891ff4cb Author: Poul-Henning Kamp Date: Thu Dec 10 09:36:50 2015 +0000 Use the same iterator function prototype for obj and req.body diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 2c84e28..7f51968 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -898,8 +898,7 @@ void Req_Fail(struct req *req, enum sess_close reason); /* cache_req_body.c */ int VRB_Ignore(struct req *req); ssize_t VRB_Cache(struct req *req, ssize_t maxsize); -typedef int req_body_iter_f(void *priv, int flush, const void *ptr, ssize_t len); -ssize_t VRB_Iterate(struct req *req, req_body_iter_f *func, void *priv); +int VRB_Iterate(struct req *req, objiterate_f *func, void *priv); void VRB_Free(struct req *req); /* cache_req_fsm.c [CNT] */ diff --git a/bin/varnishd/cache/cache_req_body.c b/bin/varnishd/cache/cache_req_body.c index 4f4d2af..92be12c 100644 --- a/bin/varnishd/cache/cache_req_body.c +++ b/bin/varnishd/cache/cache_req_body.c @@ -47,50 +47,25 @@ * return length or -1 on error */ -struct vrb_foo { - unsigned magic; -#define VRB_FOO_MAGIC 0x30240389 - struct req *req; - void *priv; - req_body_iter_f *func; - ssize_t ll; -}; - -static int __match_proto__(objiterate_f) -vrb_objiterator(void *priv, int flush, const void *ptr, ssize_t len) -{ - struct vrb_foo *foo; - - CAST_OBJ_NOTNULL(foo, priv, VRB_FOO_MAGIC); - - foo->ll += len; - return (foo->func(foo->priv, flush, ptr, len)); -} - -ssize_t -VRB_Iterate(struct req *req, req_body_iter_f *func, void *priv) +int +VRB_Iterate(struct req *req, objiterate_f *func, void *priv) { char buf[8192]; - ssize_t l, ll = 0; + ssize_t l; int i; struct vfp_ctx *vfc; enum vfp_status vfps = VFP_ERROR; - struct vrb_foo foo; + int ret = 0; CHECK_OBJ_NOTNULL(req, REQ_MAGIC); AN(func); switch(req->req_body_status) { case REQ_BODY_CACHED: - INIT_OBJ(&foo, VRB_FOO_MAGIC); - foo.req = req; - foo.priv = priv; - foo.func = func; - foo.ll = 0; - if (ObjIterate(req->wrk, req->body_oc, &foo, vrb_objiterator)) + if (ObjIterate(req->wrk, req->body_oc, priv, func)) return (-1); - return (foo.ll); + return (0); case REQ_BODY_NONE: return (0); case REQ_BODY_WITH_LEN: @@ -137,16 +112,15 @@ VRB_Iterate(struct req *req, req_body_iter_f *func, void *priv) vfps = VFP_Suck(vfc, buf, &l); if (vfps == VFP_ERROR) { req->req_body_status = REQ_BODY_FAIL; - ll = -1; + ret = -1; break; } else if (l > 0) { req->req_bodybytes += l; req->acct.req_bodybytes += l; - ll += l; l = func(priv, 1, buf, l); if (l) { req->req_body_status = REQ_BODY_FAIL; - ll = -1; + ret = -1; break; } } @@ -154,7 +128,7 @@ VRB_Iterate(struct req *req, req_body_iter_f *func, void *priv) VFP_Close(vfc); VSLb_ts_req(req, "ReqBody", VTIM_real()); - return (ll); + return (ret); } /*---------------------------------------------------------------------- @@ -163,7 +137,7 @@ VRB_Iterate(struct req *req, req_body_iter_f *func, void *priv) * For HTTP1 we have no such luck, and we just iterate it into oblivion. */ -static int __match_proto__(req_body_iter_f) +static int __match_proto__(objiterate_f) httpq_req_body_discard(void *priv, int flush, const void *ptr, ssize_t len) { diff --git a/bin/varnishd/http1/cache_http1_fetch.c b/bin/varnishd/http1/cache_http1_fetch.c index 4659c54..ef24a71 100644 --- a/bin/varnishd/http1/cache_http1_fetch.c +++ b/bin/varnishd/http1/cache_http1_fetch.c @@ -48,7 +48,7 @@ * Pass the request body to the backend */ -static int __match_proto__(req_body_iter_f) +static int __match_proto__(objiterate_f) vbf_iter_req_body(void *priv, int flush, const void *ptr, ssize_t l) { struct busyobj *bo; From phk at FreeBSD.org Thu Dec 10 09:40:13 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 10 Dec 2015 01:40:13 -0800 Subject: [varnishcache/varnish-cache] faae8c: Use the same iterator function prototype for obj a... Message-ID: <5669487d967a8_7f13faa6a1d72bc934f3@hookshot-fe2-cp1-prd.iad.github.net.mail> Branch: refs/heads/master Home: https://github.com/varnishcache/varnish-cache Commit: faae8c1da7c355956126b7485dc677e8891ff4cb https://github.com/varnishcache/varnish-cache/commit/faae8c1da7c355956126b7485dc677e8891ff4cb Author: Poul-Henning Kamp Date: 2015-12-10 (Thu, 10 Dec 2015) Changed paths: M bin/varnishd/cache/cache.h M bin/varnishd/cache/cache_req_body.c M bin/varnishd/http1/cache_http1_fetch.c Log Message: ----------- Use the same iterator function prototype for obj and req.body From fgsch at lodoss.net Fri Dec 11 15:32:03 2015 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Fri, 11 Dec 2015 16:32:03 +0100 Subject: [master] 038b70f Whitespace Message-ID: commit 038b70fdac73bf4d8f6845070b0c48d6788b85a9 Author: Federico G. Schwindt Date: Thu Dec 10 11:10:13 2015 +0000 Whitespace diff --git a/Makefile.inc.phk b/Makefile.inc.phk index c864efa..680bab1 100644 --- a/Makefile.inc.phk +++ b/Makefile.inc.phk @@ -1,6 +1,6 @@ .PHONY: default -default: all +default: all WARNS ?= 1 @@ -39,7 +39,7 @@ LIB_READLINE = ${CFG_LINEDISC} ####################################################################### ifdef USE_THREADS CFLAGS += -pthread -D_THREAD_SAFE -g -O2 -PROG_LDFLAGS += -pthread -D_THREAD_SAFE -g -O2 +PROG_LDFLAGS += -pthread -D_THREAD_SAFE -g -O2 endif ifdef USE_DLOPEN @@ -164,7 +164,7 @@ ifeq ($(TGT), all) include _.deplib endif -$(LIBNAME).a: $(LIB_OBJ) +$(LIBNAME).a: $(LIB_OBJ) $(AR) -rc $(LIBNAME).a $^ ranlib $(LIBNAME).a diff --git a/bin/Makefile.phk b/bin/Makefile.phk index ce538a1..66816ff 100644 --- a/bin/Makefile.phk +++ b/bin/Makefile.phk @@ -1,10 +1,10 @@ -SUBDIRS += varnishadm -SUBDIRS += varnishd +SUBDIRS += varnishadm +SUBDIRS += varnishd SUBDIRS += varnishlog SUBDIRS += varnishncsa -SUBDIRS += varnishtest +SUBDIRS += varnishtest SUBDIRS += varnishstat -SUBDIRS += varnishhist +SUBDIRS += varnishhist SUBDIRS += varnishtop TOPDIR = $(CURDIR)/.. diff --git a/bin/flint.lnt b/bin/flint.lnt index 0bc6639..0c9412c 100644 --- a/bin/flint.lnt +++ b/bin/flint.lnt @@ -35,7 +35,7 @@ -elib(659) // no tokens after struct def. -elib(123) // macro def. with arg at, (just warn) --emacro(702, WEXITSTATUS) // signed shift right +-emacro(702, WEXITSTATUS) // signed shift right -e786 // String concatenation within initializer -e726 // Extraneous comma ignored diff --git a/bin/varnishadm/Makefile.phk b/bin/varnishadm/Makefile.phk index 6d6cb2a..368b80a 100644 --- a/bin/varnishadm/Makefile.phk +++ b/bin/varnishadm/Makefile.phk @@ -4,7 +4,7 @@ LD_ADD += ${LIB_VARNISHAPI} LD_ADD += ${LIB_VARNISH} LD_ADD += ${LIB_PCRE} LD_ADD += ${LIB_READLINE} -LD_ADD += -lm +LD_ADD += -lm RST_MAN += $(TOPDIR)/doc/sphinx/reference/varnishadm.rst diff --git a/bin/varnishd/Makefile.am b/bin/varnishd/Makefile.am index d252c1b..0648822 100644 --- a/bin/varnishd/Makefile.am +++ b/bin/varnishd/Makefile.am @@ -97,7 +97,7 @@ varnishd_SOURCES = \ waiter/cache_waiter_epoll.c \ waiter/cache_waiter_kqueue.c \ waiter/cache_waiter_poll.c \ - waiter/cache_waiter_ports.c + waiter/cache_waiter_ports.c noinst_HEADERS = \ builtin_vcl.h \ diff --git a/bin/varnishd/flint.lnt b/bin/varnishd/flint.lnt index 38453d1..200e37b 100644 --- a/bin/varnishd/flint.lnt +++ b/bin/varnishd/flint.lnt @@ -118,9 +118,9 @@ -e455 // thread lock -e458 // unprotected read -e728 // Symbol ... not explicitly initialized --e716 // while(1) ... --e785 // Too few initializers for aggregate --e850 // for loop index variable '___' whose type category is '___' +-e716 // while(1) ... +-e785 // Too few initializers for aggregate +-e850 // for loop index variable '___' whose type category is '___' // is modified in body of the for loop that began at '___' diff --git a/bin/varnishd/vclflint.sh b/bin/varnishd/vclflint.sh index cd3e7d9..24d47bf 100755 --- a/bin/varnishd/vclflint.sh +++ b/bin/varnishd/vclflint.sh @@ -10,4 +10,4 @@ else echo "usage!" 1>&2 fi -flexelint vclflint.lnt /tmp/_.c +flexelint vclflint.lnt /tmp/_.c diff --git a/bin/varnishlog/flint.lnt b/bin/varnishlog/flint.lnt index c90f53b..f2b336d 100644 --- a/bin/varnishlog/flint.lnt +++ b/bin/varnishlog/flint.lnt @@ -3,11 +3,11 @@ -e747 // 16 Info 747 Significant prototype coercion (___) ___ to ___ -e763 // Redundant declaration for symbol '...' previously declared --e716 // while(1) ... +-e716 // while(1) ... --e457 // unprotected write access --e459 // unprotected access --e458 // unprotected access +-e457 // unprotected write access +-e459 // unprotected access +-e458 // unprotected access -e732 // Loss of sign (arg. no. 2) (int to unsigned -e737 // [45] Loss of sign in promotion from int to unsigned diff --git a/bin/varnishncsa/flint.lnt b/bin/varnishncsa/flint.lnt index ce8b3f4..fd2c864 100644 --- a/bin/varnishncsa/flint.lnt +++ b/bin/varnishncsa/flint.lnt @@ -4,8 +4,8 @@ -e763 // Redundant declaration for symbol '...' previously declared -e726 // Extraneous comma ignored -e728 // Symbol ... not explicitly initialized --e716 // while(1) ... --e785 // Too few initializers for aggregate +-e716 // while(1) ... +-e785 // Too few initializers for aggregate -e786 // String concatenation within initializer // cache_center.c diff --git a/bin/varnishstat/flint.lnt b/bin/varnishstat/flint.lnt index 005b4aa..509e13a 100644 --- a/bin/varnishstat/flint.lnt +++ b/bin/varnishstat/flint.lnt @@ -7,11 +7,11 @@ -e747 // 16 Info 747 Significant prototype coercion (___) ___ to ___ -e763 // Redundant declaration for symbol '...' previously declared --e716 // while(1) ... +-e716 // while(1) ... --e457 // unprotected write access --e459 // unprotected access --e458 // unprotected access +-e457 // unprotected write access +-e459 // unprotected access +-e458 // unprotected access -e732 // Loss of sign (arg. no. 2) (int to unsigned -e737 // [45] Loss of sign in promotion from int to unsigned diff --git a/bin/varnishtest/flint.lnt b/bin/varnishtest/flint.lnt index 8ee39d2..b7306f1 100644 --- a/bin/varnishtest/flint.lnt +++ b/bin/varnishtest/flint.lnt @@ -16,12 +16,12 @@ -e679 // Suspicious Truncation in arithmetic expression combining with pointer -e763 // Redundant declaration for symbol '...' previously declared --e716 // while(1) ... +-e716 // while(1) ... --e457 // unprotected write access --e459 // unprotected access --e458 // unprotected access -// +-e457 // unprotected write access +-e459 // unprotected access +-e458 // unprotected access +// -e732 // Loss of sign (arg. no. 2) (int to unsigned -e737 // [45] Loss of sign in promotion from int to unsigned -e713 // Loss of precision (assignment) (unsigned long long to long long) diff --git a/bin/varnishtop/flint.lnt b/bin/varnishtop/flint.lnt index 5f41983..4920e47 100644 --- a/bin/varnishtop/flint.lnt +++ b/bin/varnishtop/flint.lnt @@ -3,11 +3,11 @@ -e747 // 16 Info 747 Significant prototype coercion (___) ___ to ___ -e763 // Redundant declaration for symbol '...' previously declared --e716 // while(1) ... +-e716 // while(1) ... --e457 // unprotected write access --e459 // unprotected access --e458 // unprotected access +-e457 // unprotected write access +-e459 // unprotected access +-e458 // unprotected access -e732 // Loss of sign (arg. no. 2) (int to unsigned -e737 // [45] Loss of sign in promotion from int to unsigned diff --git a/config.phk b/config.phk index 430a887..7058ced 100644 --- a/config.phk +++ b/config.phk @@ -72,7 +72,7 @@ if true ; then sys/mount.h \ sys/statvfs.h \ sys/vfs.h \ - umem.h + umem.h do if [ -f /usr/include/$i ] ; then n=`echo $i | tr '[a-z/.]' '[A-Z__]'` @@ -109,7 +109,7 @@ fi VCSF=include/vcs_version.h VMAV=include/vmod_abi.h -if [ -d ./.git ] ; then +if [ -d ./.git ] ; then V=`git show -s --pretty=format:%h` B=`git rev-parse --abbrev-ref HEAD` else @@ -147,7 +147,7 @@ fi ask_compiler() { a=`echo "$2" | ${CC-cc} -E - -DWARNS=${WARNS-1} | - sed -e '/^#/d' -e '/^$/d' -e 's/"//g' -e 's/~/"/g' ` + sed -e '/^#/d' -e '/^$/d' -e 's/"//g' -e 's/~/"/g' ` echo "$1='" $a "'" >> _.cache } @@ -302,5 +302,5 @@ exit 0 # HAVE_LIBUMEM - # USE_PCRE_JIT - # _FILE_OFFSET_BITS - -# +# # #echo 'CF_CFLAGS="-Wall"' diff --git a/configure.ac b/configure.ac index 1062797..f89977b 100644 --- a/configure.ac +++ b/configure.ac @@ -179,7 +179,7 @@ AC_CHECK_HEADERS([edit/readline/readline.h], [AC_DEFINE([HAVE_LIBEDIT], [1], [Define if we have libedit]) LIBEDIT_LIBS="-ledit"], - [PKG_CHECK_MODULES([LIBEDIT], [libedit], + [PKG_CHECK_MODULES([LIBEDIT], [libedit], # having the module does not imply having the header [AC_CHECK_HEADERS([editline/readline.h], [AC_DEFINE([HAVE_LIBEDIT], [1], [Define if we have libedit])], @@ -275,7 +275,7 @@ AC_CACHE_CHECK([whether we have support for visibility attributes], if test "$ac_cv_have_viz" = no; then libvgz_extra_cflags="-DNO_VIZ" AC_SUBST(libvgz_extra_cflags) -fi +fi CFLAGS="${save_CFLAGS}" # Use jemalloc on Linux @@ -334,7 +334,7 @@ AC_SYS_LARGEFILE save_LIBS="${LIBS}" LIBS="${LIBS} ${RT_LIBS}" AC_CHECK_FUNCS([clock_gettime]) -AC_CHECK_FUNCS([gethrtime]) +AC_CHECK_FUNCS([gethrtime]) LIBS="${save_LIBS}" # --enable-kqueue diff --git a/doc/sphinx/Makefile.phk b/doc/sphinx/Makefile.phk index 8ed14ae..35bea90 100644 --- a/doc/sphinx/Makefile.phk +++ b/doc/sphinx/Makefile.phk @@ -189,7 +189,7 @@ EXTRA_DIST = \ include/varnishhist_options.rst \ include/varnishhist_synopsis.rst \ reference/vmod_std.generated.rst \ - reference/vmod_directors.generated.rst + reference/vmod_directors.generated.rst dist-hook: diff --git a/doc/sphinx/glossary/index.rst b/doc/sphinx/glossary/index.rst index a3d9761..7877f60 100644 --- a/doc/sphinx/glossary/index.rst +++ b/doc/sphinx/glossary/index.rst @@ -4,7 +4,7 @@ Varnish Glossary ================ -.. glossary:: +.. glossary:: :sorted: .. diff --git a/doc/sphinx/installation/bugs.rst b/doc/sphinx/installation/bugs.rst index b5fd756..091b7c7 100644 --- a/doc/sphinx/installation/bugs.rst +++ b/doc/sphinx/installation/bugs.rst @@ -19,7 +19,7 @@ do not have a way to simulate high levels of real-life web-traffic, so telling us to "have 10.000 clients hit at once" does not really allow us to reproduce. -To report a bug please follow the suggested procedure described in the "Trouble Tickets" +To report a bug please follow the suggested procedure described in the "Trouble Tickets" section of the documentation (above). Roughly we categorize bugs in to three kinds of bugs (described below) with Varnish. The information @@ -119,7 +119,7 @@ furiously on some futile condition. Commands like ``top -H`` or ``ps -Haxlw`` or ``ps -efH`` should be able to figure that out. -.. XXX:Maybe a short description of what valuable information the various commands above generates? /benc +.. XXX:Maybe a short description of what valuable information the various commands above generates? /benc If one or more threads are spinning, use ``strace`` or ``ktrace`` or ``truss`` diff --git a/doc/sphinx/installation/help.rst b/doc/sphinx/installation/help.rst index 22cd106..ba6dbd8 100644 --- a/doc/sphinx/installation/help.rst +++ b/doc/sphinx/installation/help.rst @@ -8,7 +8,7 @@ this process as much as possible. But before you grab hold of us, spend a moment composing your thoughts and formulate your question. From our perspective there is nothing as pointless as simply telling -us "Varnish does not work for me" with no further information. This does not give us any relevant information to use when trying to figure out whats wrong. +us "Varnish does not work for me" with no further information. This does not give us any relevant information to use when trying to figure out whats wrong. And before you even do that, do a couple of searches to see if your question is already answered, if it has been, you will get your answer @@ -78,7 +78,7 @@ bug in Varnish. Ask on IRC first if you are in doubt. The reason for this policy, is to avoid bugs being drowned in a pile of other `issues`, feature suggestions for future releases, and double postings of calls for help -from people who forgot to check back on already opened Tickets. +from people who forgot to check back on already opened Tickets. .. XXX: Not sure what you want with the last sentence above. benc diff --git a/doc/sphinx/installation/platformnotes.rst b/doc/sphinx/installation/platformnotes.rst index 0eca96f..741d98b 100644 --- a/doc/sphinx/installation/platformnotes.rst +++ b/doc/sphinx/installation/platformnotes.rst @@ -13,7 +13,7 @@ On RHEL6 Transparent Hugepage kernel support is enabled by default. This is known to cause sporadic crashes of Varnish. It is recommended to disable transparent hugepages on affected systems. This -can be done with +can be done with ``echo "never" > /sys/kernel/mm/redhat_transparent_hugepage/enabled`` (runtime) and changes to `/etc/sysctl.conf` (persisted.) diff --git a/doc/sphinx/phk/autocrap.rst b/doc/sphinx/phk/autocrap.rst index e97ac4c..86a2dd1 100644 --- a/doc/sphinx/phk/autocrap.rst +++ b/doc/sphinx/phk/autocrap.rst @@ -47,7 +47,7 @@ right before you can even think about compiling the source code. Second, it doesn't actually work, you still have to do the hard work and figure out the right way to explain to the autocrap tools what -you are trying to do and how to do it, only you have to do so in +you are trying to do and how to do it, only you have to do so in a language which is used to produce M4 macro invocations etc. etc. In the meantime, the UNIX diversity has shrunk from 50+ significantly diff --git a/doc/sphinx/phk/backends.rst b/doc/sphinx/phk/backends.rst index 952a791..2a2a348 100644 --- a/doc/sphinx/phk/backends.rst +++ b/doc/sphinx/phk/backends.rst @@ -52,7 +52,7 @@ VCLs where backend "b1" points at two different physical machines, for instance when we migrate or upgrade the backend. The identity of the state than can be shared is therefore the triplet: - {VCL-name, IPv4+port, IPv6+port} + {VCL-name, IPv4+port, IPv6+port} No Information without Representation ===================================== diff --git a/doc/sphinx/phk/barriers.rst b/doc/sphinx/phk/barriers.rst index 4eac78a..e85e81a 100644 --- a/doc/sphinx/phk/barriers.rst +++ b/doc/sphinx/phk/barriers.rst @@ -48,7 +48,7 @@ barriers between the various components:: The really Important Barrier ============================ -The central actor in Varnish is the Manager process, "MGR", which is the +The central actor in Varnish is the Manager process, "MGR", which is the process the administrator "(ADMIN)" starts to get web-cache service. Having been there myself, I do not subscribe to the "I feel cool and important diff --git a/doc/sphinx/phk/gzip.rst b/doc/sphinx/phk/gzip.rst index c5e4aad..68ff0f0 100644 --- a/doc/sphinx/phk/gzip.rst +++ b/doc/sphinx/phk/gzip.rst @@ -47,7 +47,7 @@ always set to: Accept-Encoding: gzip -Even if this particular client does not support +Even if this particular client does not support To always entice the backend into sending us gzip'ed content. diff --git a/doc/sphinx/phk/http20.rst b/doc/sphinx/phk/http20.rst index c2b4d17..525f0f3 100644 --- a/doc/sphinx/phk/http20.rst +++ b/doc/sphinx/phk/http20.rst @@ -257,7 +257,7 @@ and repeat markers, rather than throwing everything after deflate and hope for a miracle. I think this protocol is the best basis to start from, but like -the other two, it has a long way to go, before it can truly +the other two, it has a long way to go, before it can truly earn the name HTTP/2.0. diff --git a/doc/sphinx/phk/platforms.rst b/doc/sphinx/phk/platforms.rst index 18ee017..e85f925 100644 --- a/doc/sphinx/phk/platforms.rst +++ b/doc/sphinx/phk/platforms.rst @@ -39,7 +39,7 @@ We care about these platforms because our users use them and because they deliver a lot of bang for the buck with Varnish. These platforms are in our "tinderbox" tests, we use them ourselves -and they pass all regression tests all the time. +and they pass all regression tests all the time. Platform specific bug reports gets acted on. *FreeBSD* diff --git a/doc/sphinx/phk/spdy.rst b/doc/sphinx/phk/spdy.rst index 7cc1f4f..7f70236 100644 --- a/doc/sphinx/phk/spdy.rst +++ b/doc/sphinx/phk/spdy.rst @@ -61,7 +61,7 @@ Treaty and the convention about chemical and biological weapons.) So my insight about Varnish, that it has to become a socket-wrench-like toolchest for doing things with HTTP traffic, will probably elicit a lot -of "duh!" reactions, until people, including me, understand the +of "duh!" reactions, until people, including me, understand the ramifications more fully. Things you cannot do with Varnish today diff --git a/doc/sphinx/phk/three-zero.rst b/doc/sphinx/phk/three-zero.rst index 41499b0..c1fd3b8 100644 --- a/doc/sphinx/phk/three-zero.rst +++ b/doc/sphinx/phk/three-zero.rst @@ -53,7 +53,7 @@ shows a nice trend on Google and #varnish confuses the heck out of teenage girls and wood workers on Twitter, so clearly I am doing something right. -I still worry about the `The Fraud Police +I still worry about the `The Fraud Police `_ though, "I have no idea what I'm doing, and I totally make shit up as I go along." is a disturbingly precise summary of how I feel about my diff --git a/doc/sphinx/phk/wanton_destruction.rst b/doc/sphinx/phk/wanton_destruction.rst index 4289cf1..8ad757d 100644 --- a/doc/sphinx/phk/wanton_destruction.rst +++ b/doc/sphinx/phk/wanton_destruction.rst @@ -24,7 +24,7 @@ rebuild it, to become the house we want now. For one thing, doing major surgery on a house while you live in it is double-minus-fun and it always slows the rebuild project down -when you have to keep at least one toilet working and sanitary and +when you have to keep at least one toilet working and sanitary and be able to cook and sleep on the building site. So we'll be building a new house on a plot of land on the other @@ -40,7 +40,7 @@ Using a major piece of software, is like moving into a house: You need to adapt your life and the house or the software to each other, since nothing is ever quite perfect, there will be limitations. -And those limitations affect how you think: If you live in a +And those limitations affect how you think: If you live in a 2 bedroom apartment, you won't even be considering inviting 80 guests to a party. @@ -55,7 +55,7 @@ the next couple of years, it'll be called Varnish V4 and that means that you will have to decide who gets which room and where to store the towels and grandmothers old china, all over again. -I'm sure you'll hate me for it, "Why do we have to move ?", "It +I'm sure you'll hate me for it, "Why do we have to move ?", "It really wasn't that bad after all" and so on and so forth. But if I do my job right, that will soon turn into "Ohh, that's pretty neat, I always wanted one of those..." and "Hey... Watch me diff --git a/doc/sphinx/tutorial/backend_servers.rst b/doc/sphinx/tutorial/backend_servers.rst index ce39bc1..7d7b70a 100644 --- a/doc/sphinx/tutorial/backend_servers.rst +++ b/doc/sphinx/tutorial/backend_servers.rst @@ -16,7 +16,7 @@ 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"; @@ -43,7 +43,7 @@ localhost, port 8080.:: Varnish can have several backends defined and can even join several backends together into clusters of backends for load balancing purposes, having Varnish -pick one backend based on different algorithms. +pick one backend based on different algorithms. Next, let's have a look at some of what makes Varnish unique and what you can do with it. diff --git a/doc/sphinx/tutorial/starting_varnish.rst b/doc/sphinx/tutorial/starting_varnish.rst index 8d9b64c..b90e6b6 100644 --- a/doc/sphinx/tutorial/starting_varnish.rst +++ b/doc/sphinx/tutorial/starting_varnish.rst @@ -39,7 +39,7 @@ 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"; @@ -49,7 +49,7 @@ We'll change it and make it point to something that works. Hopefully http://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"; diff --git a/doc/sphinx/users-guide/command-line.rst b/doc/sphinx/users-guide/command-line.rst index 854fb32..ad04c02 100644 --- a/doc/sphinx/users-guide/command-line.rst +++ b/doc/sphinx/users-guide/command-line.rst @@ -3,8 +3,8 @@ Important command line arguments -------------------------------- -There a two command line arguments you have to set when starting Varnish, these are: -* what TCP port to serve HTTP from, and +There a two command line arguments you have to set when starting Varnish, these are: +* what TCP port to serve HTTP from, and * where the backend server can be contacted. If you have installed Varnish through using a provided operating system bound package, diff --git a/doc/sphinx/users-guide/compression.rst b/doc/sphinx/users-guide/compression.rst index edd3c6f..d88e351 100644 --- a/doc/sphinx/users-guide/compression.rst +++ b/doc/sphinx/users-guide/compression.rst @@ -4,7 +4,7 @@ Compression ----------- In Varnish 3.0 we introduced native support for compression, using gzip -encoding. *Before* 3.0, Varnish would never compress objects. +encoding. *Before* 3.0, Varnish would never compress objects. In Varnish 4.0 compression defaults to "on", meaning that it tries to be smart and do the sensible thing. diff --git a/doc/sphinx/users-guide/devicedetection.rst b/doc/sphinx/users-guide/devicedetection.rst index 67f711a..8027909 100644 --- a/doc/sphinx/users-guide/devicedetection.rst +++ b/doc/sphinx/users-guide/devicedetection.rst @@ -7,7 +7,7 @@ Device detection is figuring out what kind of content to serve to a client based on the User-Agent string supplied in a request. Use cases for this are for example to send size reduced files to mobile -clients with small screens and on high latency networks, or to +clients with small screens and on high latency networks, or to provide a streaming video codec that the client understands. There are a couple of typical strategies to use for this type of scenario: @@ -16,7 +16,7 @@ There are a couple of typical strategies to use for this type of scenario: 3) Change the backend request so that the backend sends tailored content. To perhaps make the strategies easier to understand, we, in this context, assume -that the `req.http.X-UA-Device` header is present and unique per client class. +that the `req.http.X-UA-Device` header is present and unique per client class. Setting this header can be as simple as:: @@ -35,7 +35,7 @@ https://github.com/varnish/varnish-devicedetect/. Serve the different content on the same URL ------------------------------------------- -The tricks involved are: +The tricks involved are: 1. Detect the client (pretty simple, just include `devicedetect.vcl` and call it). 2. Figure out how to signal the backend the client class. This @@ -55,7 +55,7 @@ Example 1: Send HTTP header to backend The basic case is that Varnish adds the 'X-UA-Device' HTTP header on the backend requests, and the backend mentions in the response 'Vary' header that the content -is dependant on this header. +is dependant on this header. Everything works out of the box from Varnish' perspective. @@ -63,7 +63,7 @@ Everything works out of the box from Varnish' perspective. VCL:: - sub vcl_recv { + sub vcl_recv { # call some detection engine that set req.http.X-UA-Device } # req.http.X-UA-Device is copied by Varnish into bereq.http.X-UA-Device @@ -73,15 +73,15 @@ VCL:: # use the same cached object for all U-As that map to the same X-UA-Device. # # If the backend does not mention in Vary that it has crafted special - # content based on the User-Agent (==X-UA-Device), add it. + # content based on the User-Agent (==X-UA-Device), add it. # If your backend does set Vary: User-Agent, you may have to remove that here. sub vcl_backend_response { if (bereq.http.X-UA-Device) { if (!beresp.http.Vary) { # no Vary at all - set beresp.http.Vary = "X-UA-Device"; + set beresp.http.Vary = "X-UA-Device"; } elseif (beresp.http.Vary !~ "X-UA-Device") { # add to existing Vary - set beresp.http.Vary = beresp.http.Vary + ", X-UA-Device"; - } + set beresp.http.Vary = beresp.http.Vary + ", X-UA-Device"; + } } # comment this out if you don't want the client to know your # classification @@ -122,7 +122,7 @@ headers are (by default) available for the script. VCL:: - sub vcl_recv { + sub vcl_recv { # call some detection engine that set req.http.X-UA-Device } @@ -163,7 +163,7 @@ is changed. VCL:: - sub vcl_recv { + sub vcl_recv { # call some detection engine that set req.http.X-UA-Device } @@ -172,7 +172,7 @@ VCL:: # if there are existing GET arguments; if (req.url ~ "\?") { set req.http.X-get-devicetype = "&devicetype=" + req.http.X-UA-Device; - } else { + } else { set req.http.X-get-devicetype = "?devicetype=" + req.http.X-UA-Device; } set req.url = req.url + req.http.X-get-devicetype; @@ -253,7 +253,7 @@ VCL:: return(synth(750, "Moved Temporarily")); } } - + sub vcl_synth { if (obj.status == 750) { set obj.http.Location = "http://m.example.com" + req.url; diff --git a/doc/sphinx/users-guide/esi.rst b/doc/sphinx/users-guide/esi.rst index b81d2ea..30379a1 100644 --- a/doc/sphinx/users-guide/esi.rst +++ b/doc/sphinx/users-guide/esi.rst @@ -12,12 +12,12 @@ in all the other pages. .. XXX:What other pages? benc Used properly this strategy can dramatically increase -your hit rate and reduce the load on your servers. +your hit rate and reduce the load on your servers. In Varnish we've only so far implemented a small subset of ESI. As of version 2.1 we have three ESI statements:: - esi:include + esi:include esi:remove @@ -34,7 +34,7 @@ Lets see an example how this could be used. This simple cgi script outputs the date:: #!/bin/sh - + echo 'Content-type: text/html' echo '' date "+%Y-%m-%d %H:%M" @@ -73,10 +73,10 @@ in them, allowing you to only render the content when the page is not being ESI-processed. For example:: - + The license - diff --git a/doc/sphinx/users-guide/index.rst b/doc/sphinx/users-guide/index.rst index e1c3e83..4aae504 100644 --- a/doc/sphinx/users-guide/index.rst +++ b/doc/sphinx/users-guide/index.rst @@ -8,7 +8,7 @@ The Varnish documentation consists of three main documents: * :ref:`tutorial-index` explains the basics and gets you started with Varnish. * :ref:`users-guide-index` (this document), explains how Varnish works - and how you can use it to improve your website. + and how you can use it to improve your website. * :ref:`reference-index` contains hard facts and is useful for looking up specific questions. diff --git a/doc/sphinx/users-guide/intro.rst b/doc/sphinx/users-guide/intro.rst index 927292a..f430d75 100644 --- a/doc/sphinx/users-guide/intro.rst +++ b/doc/sphinx/users-guide/intro.rst @@ -5,7 +5,7 @@ The Big Varnish Picture In this section we will cover answers to the questions: - What is in this package called "Varnish"? -- what are all the different bits and pieces named? +- what are all the different bits and pieces named? - Will you need a hex-wrench for assembly? The two main parts of Varnish are the two processes in the `varnishd` diff --git a/doc/sphinx/users-guide/operation-logging.rst b/doc/sphinx/users-guide/operation-logging.rst index fdbcf58..bb4c7cc 100644 --- a/doc/sphinx/users-guide/operation-logging.rst +++ b/doc/sphinx/users-guide/operation-logging.rst @@ -6,7 +6,7 @@ Logging in Varnish One of the really nice features in Varnish is the way logging works. Instead of logging to a normal log file Varnish logs to a shared memory segment, called the VSL - the Varnish Shared Log. When the end -of the segment is reached we start over, overwriting old data. +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 @@ -32,7 +32,7 @@ These is the Varnish master process checking up on the caching process to see that everything is OK. Now go to the browser and reload the page displaying your web -app. +app. .. XXX:Doesn't this require a setup of a running varnishd and a web application being cached? benc You'll see lines like these.:: diff --git a/doc/sphinx/users-guide/params.rst b/doc/sphinx/users-guide/params.rst index df4bfdf..5422c98 100644 --- a/doc/sphinx/users-guide/params.rst +++ b/doc/sphinx/users-guide/params.rst @@ -20,7 +20,7 @@ a somewhat longer description on what it does and what the default is type ``param.show`` and the name of the parameter, like this:: varnish> param.show shortlived - 200 + 200 shortlived 10.000000 [s] Default is 10.0 Objects created with TTL shorter than this are diff --git a/doc/sphinx/users-guide/vcl-actions.rst b/doc/sphinx/users-guide/vcl-actions.rst index ed2b8ba..e66250f 100644 --- a/doc/sphinx/users-guide/vcl-actions.rst +++ b/doc/sphinx/users-guide/vcl-actions.rst @@ -13,9 +13,9 @@ The most common actions to return are these: `vcl_recv`. *hash* - When you return hash from `vcl_recv` you tell Varnish to deliver content - from cache even if the request othervise indicates that the request - should be passed. + When you return hash from `vcl_recv` you tell Varnish to deliver content + from cache even if the request othervise indicates that the request + should be passed. *pipe* @@ -23,11 +23,11 @@ The most common actions to return are these: Pipe can be returned from `vcl_recv` as well. Pipe short circuits the client and the backend connections and Varnish will just sit there - and shuffle bytes back and forth. Varnish will not look at the data being - send back and forth - so your logs will be incomplete. + and shuffle bytes back and forth. Varnish will not look at the data being + send back and forth - so your logs will be incomplete. *deliver* - Deliver the object to the client. Usually returned from `vcl_backend_response`. + Deliver the object to the client. Usually returned from `vcl_backend_response`. *restart* Restart processing of the request. You can restart the processing of @@ -35,5 +35,5 @@ The most common actions to return are these: *retry* Retry the request against the backend. This can be returned from - `vcl_backend_response` or `vcl_backend_error` if you don't like the response + `vcl_backend_response` or `vcl_backend_error` if you don't like the response that the backend delivered. diff --git a/doc/sphinx/users-guide/vcl-example-acls.rst b/doc/sphinx/users-guide/vcl-example-acls.rst index 45afaa2..c76842f 100644 --- a/doc/sphinx/users-guide/vcl-example-acls.rst +++ b/doc/sphinx/users-guide/vcl-example-acls.rst @@ -11,7 +11,7 @@ the IP address of the client against an ACL with the match operator.:: "192.168.1.0"/24; /* and everyone on the local network */ ! "192.168.1.23"; /* except for the dialin router */ } - + sub vcl_recv { if (req.method == "PURGE") { if (client.ip ~ local) { @@ -19,6 +19,6 @@ the IP address of the client against an ACL with the match operator.:: } else { return(synth(403, "Access denied.")); } - } + } } - + diff --git a/doc/sphinx/users-guide/vcl-example-manipulating-headers.rst b/doc/sphinx/users-guide/vcl-example-manipulating-headers.rst index 7e65663..1ea81b1 100644 --- a/doc/sphinx/users-guide/vcl-example-manipulating-headers.rst +++ b/doc/sphinx/users-guide/vcl-example-manipulating-headers.rst @@ -17,5 +17,5 @@ Now, when the request is handled to the backend server there will be no cookie header. The interesting line is the one with the if-statement. It matches the URL, taken from the request object, and matches it against the regular expression. Note the match operator. If -it matches the Cookie: header of the request is unset (deleted). +it matches the Cookie: header of the request is unset (deleted). diff --git a/doc/sphinx/users-guide/vcl-inline-c.rst b/doc/sphinx/users-guide/vcl-inline-c.rst index e0d0998..d9748a3 100644 --- a/doc/sphinx/users-guide/vcl-inline-c.rst +++ b/doc/sphinx/users-guide/vcl-inline-c.rst @@ -16,7 +16,7 @@ One of the first uses of inline C was logging to `syslog`.:: C{ #include }C - + sub vcl_something { C{ syslog(LOG_INFO, "Something happened at VCL line XX."); diff --git a/doc/sphinx/users-guide/vcl-variables.rst b/doc/sphinx/users-guide/vcl-variables.rst index 70862e5..4531537 100644 --- a/doc/sphinx/users-guide/vcl-variables.rst +++ b/doc/sphinx/users-guide/vcl-variables.rst @@ -28,7 +28,7 @@ objects can be accessed and manipulated using VCL. The HTTP response right before it is delivered to the client. It is typically modified in `vcl_deliver`. -*obj* +*obj* The object as it is stored in cache. Read only. .. XXX:What object? the current request? benc diff --git a/include/Makefile.am b/include/Makefile.am index 7088579..ced33c8 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -98,7 +98,7 @@ vcl.h: $(top_srcdir)/lib/libvcc/generate.py $(top_srcdir)/include/vrt.h @PYTHON@ $(top_srcdir)/lib/libvcc/generate.py $(top_srcdir) $(top_builddir) BUILT_SOURCES = vcs_version.h vmod_abi.h -MAINTAINERCLEANFILES = vcs_version.h +MAINTAINERCLEANFILES = vcs_version.h vcs_version.h: FORCE @if [ -d "$(top_srcdir)/.git" ]; then \ V="$$(git show -s --pretty=format:%h)" \ diff --git a/lib/Makefile.phk b/lib/Makefile.phk index 6eba2c8..83d0674 100644 --- a/lib/Makefile.phk +++ b/lib/Makefile.phk @@ -1,5 +1,5 @@ SUBDIRS = libvcc libvarnish libvarnishapi libvarnishtools libvcc -SUBDIRS += libvgz +SUBDIRS += libvgz SUBDIRS += libvmod_debug libvmod_directors libvmod_std TOPDIR = $(CURDIR)/.. diff --git a/lib/libvarnish/flint.lnt b/lib/libvarnish/flint.lnt index f86bb8d..c98d791 100644 --- a/lib/libvarnish/flint.lnt +++ b/lib/libvarnish/flint.lnt @@ -26,8 +26,8 @@ -e763 // Redundant declaration for symbol '...' previously declared -e726 // Extraneous comma ignored -e728 // Symbol ... not explicitly initialized --e716 // while(1) ... --e785 // Too few initializers for aggregate +-e716 // while(1) ... +-e785 // Too few initializers for aggregate -e786 // String concatenation within initializer -esym(534, sprintf) // Ignoring return value of function diff --git a/lib/libvarnishapi/libvarnishapi.map b/lib/libvarnishapi/libvarnishapi.map index 653342f..e5aa91d 100644 --- a/lib/libvarnishapi/libvarnishapi.map +++ b/lib/libvarnishapi/libvarnishapi.map @@ -2,7 +2,7 @@ * Copyright (c) 2011-2015 Varnish Software AS * All rights reserved. * - * Author: Tollef Fog Heen + * Author: Tollef Fog Heen * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions diff --git a/lib/libvcc/flint.lnt b/lib/libvcc/flint.lnt index 60b3850..e264dab 100644 --- a/lib/libvcc/flint.lnt +++ b/lib/libvcc/flint.lnt @@ -26,7 +26,7 @@ -esym(534, vsb_vprintf) // Ignoring return value of function -esym(534, memset) // Ignoring return value of function -e788 // enum constant 'HND_Unclass' not used within defaulted switch --e716 // while(1) ... +-e716 // while(1) ... -e786 // String concatenation within initializer -e732 // Loss of sign (arg. no. 2) (int to unsigned int) diff --git a/lib/libvmod_std/vmod.vcc b/lib/libvmod_std/vmod.vcc index 61c334f..cc2506e 100644 --- a/lib/libvmod_std/vmod.vcc +++ b/lib/libvmod_std/vmod.vcc @@ -243,7 +243,7 @@ Description Note that the comparison is case sensitive. Example | if (std.strstr(req.url, req.http.restrict)) { - | ... + | ... | } This will check if the content of req.http.restrict occurs @@ -265,7 +265,7 @@ Description | "784111777" Example | if (std.time(resp.http.last-modified, now) < now - 1w) { - | ... + | ... | } diff --git a/varnish.m4 b/varnish.m4 index fcf6b2d..8a9f647 100644 --- a/varnish.m4 +++ b/varnish.m4 @@ -31,7 +31,7 @@ # For compatibility with autoconf < 2.63b m4_ifndef([AS_VAR_COPY], [m4_define([AS_VAR_COPY], - [AS_LITERAL_IF([$1[]$2], [$1=$$2], [eval $1=\$$2])])]) + [AS_LITERAL_IF([$1[]$2], [$1=$$2], [eval $1=\$$2])])]) # VARNISH_VMOD_INCLUDE_DIR([]) # ---------------------------- From fgsch at lodoss.net Fri Dec 11 15:32:03 2015 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Fri, 11 Dec 2015 16:32:03 +0100 Subject: [master] e4637bb Random pass at sanitising and cleaning some tests Message-ID: commit e4637bb641ae1d8456747bc0262b5f93e663ed95 Author: Federico G. Schwindt Date: Fri Dec 11 15:02:28 2015 +0000 Random pass at sanitising and cleaning some tests diff --git a/bin/varnishtest/tests/c00025.vtc b/bin/varnishtest/tests/c00025.vtc index ea0866a..bf519f2 100644 --- a/bin/varnishtest/tests/c00025.vtc +++ b/bin/varnishtest/tests/c00025.vtc @@ -2,30 +2,24 @@ varnishtest "Test If-None-Match" server s1 { rxreq - expect req.url == "/foo" - txresp -hdr {ETag: "123456789"} \ - -body "11111\n" + expect req.url == / + txresp -hdr {ETag: "123456789"} -bodylen 10 } -start varnish v1 -vcl+backend { } -start client c1 { - txreq -url "/foo" + txreq rxresp expect resp.status == 200 - expect resp.bodylen == 6 + expect resp.bodylen == 10 + expect resp.http.etag == {"123456789"} - txreq -url "/foo" \ - -hdr {If-None-Match: "12345678"} + txreq -hdr {If-None-Match: "12345678"} rxresp expect resp.status == 200 - txreq -url "/foo" \ - -hdr {If-None-Match: "123456789"} + txreq -hdr {If-None-Match: "123456789"} rxresp -no_obj expect resp.status == 304 -} - -client c1 -run - -client c1 -run +} -run diff --git a/bin/varnishtest/tests/c00026.vtc b/bin/varnishtest/tests/c00026.vtc index d528c0b..49e4984 100644 --- a/bin/varnishtest/tests/c00026.vtc +++ b/bin/varnishtest/tests/c00026.vtc @@ -1,51 +1,34 @@ -varnishtest "Client IMS/INM: Test Combination of If-None-Match and If-Modified-Since" +varnishtest "Test client If-None-Match and If-Modified-Since together" server s1 { rxreq - expect req.url == "/foo" + expect req.url == / txresp -hdr {ETag: "123456789"} \ - -hdr "Last-Modified: Thu, 26 Jun 2008 12:00:01 GMT" \ - -body "11111\n" + -hdr "Last-Modified: Thu, 26 Jun 2008 12:00:01 GMT" \ + -bodylen 10 } -start varnish v1 -vcl+backend { } -start client c1 { - txreq -url "/foo" + txreq rxresp expect resp.status == 200 - expect resp.bodylen == 6 + expect resp.bodylen == 10 + expect resp.http.etag == {"123456789"} - txreq -url "/foo" \ - -hdr {If-None-Match: "123456789"} - rxresp -no_obj - expect resp.status == 304 - - txreq -url "/foo" \ - -hdr "If-Modified-Since: Thu, 26 Jun 2008 12:00:01 GMT" - rxresp -no_obj - expect resp.status == 304 - - txreq -url "/foo" \ - -hdr "If-Modified-Since: Thu, 26 Jun 2008 12:00:00 GMT" \ + txreq -hdr "If-Modified-Since: Thu, 26 Jun 2008 12:00:00 GMT" \ -hdr {If-None-Match: "123456789"} rxresp expect resp.status == 200 - txreq -url "/foo" \ - -hdr "If-Modified-Since: Thu, 26 Jun 2008 12:00:01 GMT" \ + txreq -hdr "If-Modified-Since: Thu, 26 Jun 2008 12:00:01 GMT" \ -hdr {If-None-Match: "12345678"} rxresp expect resp.status == 200 - txreq -url "/foo" \ - -hdr "If-Modified-Since: Thu, 26 Jun 2008 12:00:01 GMT" \ + txreq -hdr "If-Modified-Since: Thu, 26 Jun 2008 12:00:01 GMT" \ -hdr {If-None-Match: "123456789"} rxresp -no_obj expect resp.status == 304 - -} - -client c1 -run - -client c1 -run +} -run diff --git a/bin/varnishtest/tests/m00001.vtc b/bin/varnishtest/tests/m00001.vtc index 1e0b45f..968345a 100644 --- a/bin/varnishtest/tests/m00001.vtc +++ b/bin/varnishtest/tests/m00001.vtc @@ -5,7 +5,7 @@ server s1 { txresp -hdr "foo: bAr" -hdr "bar: fOo" -bodylen 4 } -start -varnish v1 -arg "-pthread_pools=1" -vcl+backend { +varnish v1 -vcl+backend { import ${vmod_std}; sub vcl_deliver { diff --git a/bin/varnishtest/tests/m00002.vtc b/bin/varnishtest/tests/m00002.vtc index b0c3ebe..bb5626d 100644 --- a/bin/varnishtest/tests/m00002.vtc +++ b/bin/varnishtest/tests/m00002.vtc @@ -1,21 +1,21 @@ -varnishtest "Test std.random" +varnishtest "Test std.random()" # needs random generator random server s1 { rxreq - txresp -proto HTTP/1.0 -nolen -bodylen 9 + txresp } -start varnish v1 -vcl+backend { import ${vmod_std}; - sub vcl_backend_response { - set beresp.http.rnd1 = std.random(0,1); - set beresp.http.rnd2 = std.random(0,10); - set beresp.http.rnd3 = std.random(8,10); - set beresp.http.rnd4 = std.random(99,100); + sub vcl_deliver { + set resp.http.rnd1 = std.random(0, 1); + set resp.http.rnd2 = std.random(0, 10); + set resp.http.rnd3 = std.random(8, 10); + set resp.http.rnd4 = std.random(99, 100); } } -start @@ -30,5 +30,4 @@ client c1 { expect resp.http.rnd2 == 7.478 expect resp.http.rnd3 == 9.034 expect resp.http.rnd4 == 99.502 - expect resp.bodylen == 9 } -run diff --git a/bin/varnishtest/tests/m00003.vtc b/bin/varnishtest/tests/m00003.vtc index c0a5aeb..073632d 100644 --- a/bin/varnishtest/tests/m00003.vtc +++ b/bin/varnishtest/tests/m00003.vtc @@ -4,29 +4,19 @@ feature topbuild server s1 { rxreq - txresp -hdr "foo: bAr" -hdr "bar: fOo" -bodylen 4 + txresp } -start -varnish v1 -arg "-pthread_pools=1" \ - -arg "-pvmod_dir=${topbuild}/lib/libvmod_std/.libs/" \ - -vcl+backend { +varnish v1 -arg "-pvmod_dir=${topbuild}/lib/libvmod_std/.libs/" \ + -vcl+backend { import std; - - sub vcl_deliver { - set resp.http.foo = std.toupper(resp.http.foo); - set resp.http.bar = std.tolower(resp.http.bar); - std.set_ip_tos(32); - } } -start -client c1 { - txreq -url "/bar" - rxresp - expect resp.status == 200 - expect resp.bodylen == "4" - expect resp.http.foo == "BAR" - expect resp.http.bar == "foo" -} -run +varnish v1 -cliok "param.set vmod_dir /nonexistent" + +varnish v1 -errvcl {No such file or directory} { + import std; +} varnish v1 -errvcl {Expected 'from path ...'} { import std to; diff --git a/bin/varnishtest/tests/m00004.vtc b/bin/varnishtest/tests/m00004.vtc index 80300ff..9e1d047 100644 --- a/bin/varnishtest/tests/m00004.vtc +++ b/bin/varnishtest/tests/m00004.vtc @@ -13,9 +13,7 @@ server s1 { } } -start -varnish v1 \ - -arg "-pthread_pools=1" \ - -vcl+backend { +varnish v1 -vcl+backend { import ${vmod_std}; sub vcl_deliver { diff --git a/bin/varnishtest/tests/m00005.vtc b/bin/varnishtest/tests/m00005.vtc index 5ef9dde..d89396c 100644 --- a/bin/varnishtest/tests/m00005.vtc +++ b/bin/varnishtest/tests/m00005.vtc @@ -1,106 +1,72 @@ -varnishtest "test vmod_std.duration conversion" +varnishtest "Test std.duration()" server s1 { rxreq - expect req.url == "/1" - txresp -bodylen 1 - + txresp } -start varnish v1 -vcl+backend { import ${vmod_std}; - sub vcl_recv { - set req.ttl = 1000000s + std.duration(req.http.ttl, 1s); - } sub vcl_deliver { - set resp.http.ttl = (req.ttl + 1s); + set resp.http.ttl = std.duration(req.http.ttl, 1s) + 1000000s; } } -start client c1 { - txreq -url "/1" -hdr "ttl: 10ms " + txreq -hdr "ttl: 10ms" rxresp - expect resp.status == 200 - expect resp.http.ttl == 1000001.010 - expect resp.bodylen == 1 + expect resp.http.ttl == 1000000.010 - txreq -url "/1" -hdr "ttl: 10s " + txreq -hdr "ttl: 10s" rxresp - expect resp.status == 200 - expect resp.http.ttl == 1000011.000 - expect resp.bodylen == 1 + expect resp.http.ttl == 1000010.000 - txreq -url "/1" -hdr "ttl: 10m " + txreq -hdr "ttl: 10m" rxresp - expect resp.status == 200 - expect resp.http.ttl == 1000601.000 - expect resp.bodylen == 1 + expect resp.http.ttl == 1000600.000 - txreq -url "/1" -hdr "ttl: 10h " + txreq -hdr "ttl: 10h" rxresp - expect resp.status == 200 - expect resp.http.ttl == 1036001.000 - expect resp.bodylen == 1 + expect resp.http.ttl == 1036000.000 - txreq -url "/1" -hdr "ttl: 10d " + txreq -hdr "ttl: 10d" rxresp - expect resp.status == 200 - expect resp.http.ttl == 1864001.000 - expect resp.bodylen == 1 + expect resp.http.ttl == 1864000.000 - txreq -url "/1" -hdr "ttl: 10w " + txreq -hdr "ttl: 10w" rxresp - expect resp.status == 200 - expect resp.http.ttl == 7048001.000 - expect resp.bodylen == 1 + expect resp.http.ttl == 7048000.000 - txreq -url "/1" -hdr "ttl: -100s " + txreq -hdr "ttl: 1y" rxresp - expect resp.status == 200 - expect resp.http.ttl == 999901.000 - expect resp.bodylen == 1 + expect resp.http.ttl == 32536000.000 - txreq -url "/1" -hdr "ttl: s " + txreq -hdr "ttl: -100s" rxresp - expect resp.status == 200 - expect resp.http.ttl == 1000002.000 - expect resp.bodylen == 1 + expect resp.http.ttl == 999900.000 - txreq -url "/1" -hdr "ttl: 3wx " + txreq -hdr "ttl: s" rxresp - expect resp.status == 200 - expect resp.http.ttl == 1000002.000 - expect resp.bodylen == 1 + expect resp.http.ttl == 1000001.000 - txreq -url "/1" -hdr "ttl: -inf " + txreq -hdr "ttl: 3wx" rxresp - expect resp.status == 200 - expect resp.http.ttl == 1000002.000 - expect resp.bodylen == 1 + expect resp.http.ttl == 1000001.000 - txreq -url "/1" -hdr "ttl: 2x " + txreq -hdr "ttl: -inf" rxresp - expect resp.status == 200 - expect resp.http.ttl == 1000002.000 - expect resp.bodylen == 1 + expect resp.http.ttl == 1000001.000 - txreq -url "/1" -hdr "ttl: 2h x " + txreq -hdr "ttl: 2x" rxresp - expect resp.status == 200 - expect resp.http.ttl == 1000002.000 - expect resp.bodylen == 1 + expect resp.http.ttl == 1000001.000 - txreq -url "/1" -hdr "ttl: 100" + txreq -hdr "ttl: 2h x" rxresp - expect resp.status == 200 - expect resp.http.ttl == 1000002.000 - expect resp.bodylen == 1 + expect resp.http.ttl == 1000001.000 - txreq -url "/1" -hdr "ttl: 1y" + txreq -hdr "ttl: 100" rxresp - expect resp.status == 200 - expect resp.http.ttl == 32536001.000 - expect resp.bodylen == 1 - + expect resp.http.ttl == 1000001.000 } -run diff --git a/bin/varnishtest/tests/m00006.vtc b/bin/varnishtest/tests/m00006.vtc index 1dd4dec..d002112 100644 --- a/bin/varnishtest/tests/m00006.vtc +++ b/bin/varnishtest/tests/m00006.vtc @@ -2,14 +2,9 @@ varnishtest "test vmod_std.collect()" server s1 { rxreq - expect req.url == "/1" expect req.http.foo == "1, 2" - txresp -hdr "bar: a" -hdr "bar: b" -bodylen 1 - - rxreq - expect req.url == "/2" - expect req.http.baz == "1, 2" - txresp -hdr "qux: a" -hdr "qux: b" -bodylen 1 + expect req.http.baz == "3, 4" + txresp -hdr "bar: a" -hdr "bar: b" -hdr "qux: c" -hdr "qux: d" } -start varnish v1 -vcl+backend { @@ -30,15 +25,8 @@ varnish v1 -vcl+backend { } -start client c1 { - txreq -url "/1" -hdr "Foo: 1" -hdr "Foo: 2" + txreq -hdr "Foo: 1" -hdr "Foo: 2" -hdr "Baz: 3" -hdr "Baz: 4" rxresp expect resp.http.bar == "a, b" - expect resp.status == 200 - expect resp.bodylen == 1 - - txreq -url "/2" -hdr "Baz: 1" -hdr "Baz: 2" - rxresp - expect resp.http.qux == "a, b" - expect resp.status == 200 - expect resp.bodylen == 1 + expect resp.http.qux == "c, d" } -run diff --git a/bin/varnishtest/tests/m00007.vtc b/bin/varnishtest/tests/m00007.vtc index a99ac10..9a1fe39 100644 --- a/bin/varnishtest/tests/m00007.vtc +++ b/bin/varnishtest/tests/m00007.vtc @@ -1,53 +1,47 @@ -varnishtest "test vmod_std.integer conversion" +varnishtest "Test std.integer()" server s1 { rxreq - expect req.url == "/1" - txresp -bodylen 1 - + txresp } -start varnish v1 -vcl+backend { import ${vmod_std}; sub vcl_deliver { - set resp.http.biggerthanzero = (std.integer(req.http.foo,0) > 0); - set resp.http.smallerthanzero = (std.integer(req.http.foo,0) < 0); - set resp.http.iszero = (std.integer(req.http.foo,0) == 0); - set resp.http.converted = std.integer(req.http.foo,0); + set resp.http.gtzero = (std.integer(req.http.foo, 0) > 0); + set resp.http.ltzero = (std.integer(req.http.foo, 0) < 0); + set resp.http.iszero = (std.integer(req.http.foo, 0) == 0); + set resp.http.converted = std.integer(req.http.foo, 0); } } -start client c1 { - txreq -url "/1" -hdr "foo: 1" + txreq -hdr "foo: 1" rxresp - expect resp.status == 200 - expect resp.http.biggerthanzero == true - expect resp.http.smallerthanzero == false + expect resp.http.gtzero == true + expect resp.http.ltzero == false expect resp.http.iszero == false expect resp.http.converted == 1 - txreq -url "/1" -hdr "foo: -1" + txreq -hdr "foo: -1" rxresp - expect resp.status == 200 - expect resp.http.biggerthanzero == false - expect resp.http.smallerthanzero == true + expect resp.http.gtzero == false + expect resp.http.ltzero == true expect resp.http.iszero == false expect resp.http.converted == -1 - txreq -url "/1" + txreq -hdr "foo: 0" rxresp - expect resp.status == 200 - expect resp.http.biggerthanzero == false - expect resp.http.smallerthanzero == false + expect resp.http.gtzero == false + expect resp.http.ltzero == false expect resp.http.iszero == true expect resp.http.converted == 0 - txreq -url "/1" -hdr "foo: bar" + txreq -hdr "foo: bar" rxresp - expect resp.status == 200 - expect resp.http.biggerthanzero == false - expect resp.http.smallerthanzero == false + expect resp.http.gtzero == false + expect resp.http.ltzero == false expect resp.http.iszero == true expect resp.http.converted == 0 } -run diff --git a/bin/varnishtest/tests/m00011.vtc b/bin/varnishtest/tests/m00011.vtc index bf96dd5..930ed8e 100644 --- a/bin/varnishtest/tests/m00011.vtc +++ b/bin/varnishtest/tests/m00011.vtc @@ -1,16 +1,13 @@ -varnishtest "Test std.ip" +varnishtest "Test std.ip()" server s1 { rxreq - txresp -body "1" - rxreq - txresp -body "22" + txresp } -start - -varnish v1 -arg "-Wpoll" -vcl+backend { - +varnish v1 -vcl+backend { import ${vmod_std}; + sub vcl_deliver { set resp.http.foo0 = std.ip("8.8.8.*", client.ip); set resp.http.foo1 = std.ip("9.9.9.*", server.ip); @@ -22,16 +19,12 @@ varnish v1 -arg "-Wpoll" -vcl+backend { } -start client c1 { - txreq -url "/foo1" + txreq rxresp - expect resp.bodylen == 1 expect resp.http.foo0 == "127.0.0.1" expect resp.http.foo1 == "127.0.0.1" expect resp.http.foo2 == "127.0.0.2" expect resp.http.foo3 == "1.2.3.5" expect resp.http.foo4 == "2001:db8::" expect resp.http.foo5 == "::1" - txreq -url "/foo2" - rxresp - expect resp.bodylen == 2 } -run diff --git a/bin/varnishtest/tests/m00013.vtc b/bin/varnishtest/tests/m00013.vtc index c3a6295..6f27c57 100644 --- a/bin/varnishtest/tests/m00013.vtc +++ b/bin/varnishtest/tests/m00013.vtc @@ -1,4 +1,4 @@ -varnishtest "Timestamps from std vmod" +varnishtest "Test std.timestamp()" server s1 { rxreq @@ -38,7 +38,6 @@ logexpect l1 -v v1 -g request { client c1 { txreq rxresp - expect resp.status == 200 } -run logexpect l1 -wait diff --git a/bin/varnishtest/tests/r01826.vtc b/bin/varnishtest/tests/r01826.vtc index eeb4503..6a553d5 100644 --- a/bin/varnishtest/tests/r01826.vtc +++ b/bin/varnishtest/tests/r01826.vtc @@ -2,7 +2,7 @@ varnishtest "Check we ignore a zero C-L with a 204" server s1 { rxreq - txresp -status 204 -nolen -hdr "Content-Length: 0" + txresp -status 204 } -start varnish v1 -vcl+backend { From fgsch at lodoss.net Fri Dec 11 15:32:03 2015 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Fri, 11 Dec 2015 16:32:03 +0100 Subject: [master] 6469345 Use a weak comparison function for If-None-Match Message-ID: commit 6469345568aa852258e71df7e42492dfe8cac46b Author: Federico G. Schwindt Date: Fri Dec 11 15:26:03 2015 +0000 Use a weak comparison function for If-None-Match As per RFC 7232. Fixes #1816. diff --git a/bin/varnishd/cache/cache_rfc2616.c b/bin/varnishd/cache/cache_rfc2616.c index 7608755..d3fa8a2 100644 --- a/bin/varnishd/cache/cache_rfc2616.c +++ b/bin/varnishd/cache/cache_rfc2616.c @@ -232,6 +232,16 @@ RFC2616_Req_Gzip(const struct http *hp) /*--------------------------------------------------------------------*/ +static inline int +rfc2616_weak_compare(const char *p, const char *e) +{ + if (p[0] == 'W' && p[1] == '/') + p += 2; + if (e[0] == 'W' && e[1] == '/') + e += 2; + return (strcmp(p, e) != 0); +} + int RFC2616_Do_Cond(const struct req *req) { @@ -239,12 +249,20 @@ RFC2616_Do_Cond(const struct req *req) double ims, lm; int do_cond = 0; - /* RFC 2616 13.3.4 states we need to match both ETag - and If-Modified-Since if present*/ + /* + * RFC 2616 13.3.4 states we need to match both ETag and + * If-Modified-Since if present. + */ + if (http_GetHdr(req->http, H_If_None_Match, &p) && + http_GetHdr(req->resp, H_ETag, &e)) { + if (rfc2616_weak_compare(p, e)) + return (0); + do_cond = 1; + } - if (http_GetHdr(req->http, H_If_Modified_Since, &p) ) { + if (http_GetHdr(req->http, H_If_Modified_Since, &p)) { ims = VTIM_parse(p); - if (ims > req->t_req) /* [RFC2616 14.25] */ + if (!ims || ims > req->t_req) /* [RFC2616 14.25] */ return (0); AZ(ObjGetDouble(req->wrk, req->objcore, OA_LASTMODIFIED, &lm)); if (lm > ims) @@ -252,13 +270,6 @@ RFC2616_Do_Cond(const struct req *req) do_cond = 1; } - if (http_GetHdr(req->http, H_If_None_Match, &p) && - http_GetHdr(req->resp, H_ETag, &e)) { - if (strcmp(p,e) != 0) - return (0); - do_cond = 1; - } - return (do_cond); } diff --git a/bin/varnishtest/tests/c00025.vtc b/bin/varnishtest/tests/c00025.vtc index bf519f2..9b7fc95 100644 --- a/bin/varnishtest/tests/c00025.vtc +++ b/bin/varnishtest/tests/c00025.vtc @@ -4,6 +4,10 @@ server s1 { rxreq expect req.url == / txresp -hdr {ETag: "123456789"} -bodylen 10 + + rxreq + expect req.url == /other + txresp -hdr {ETag: W/"123456789"} -bodylen 10 } -start varnish v1 -vcl+backend { } -start @@ -22,4 +26,36 @@ client c1 { txreq -hdr {If-None-Match: "123456789"} rxresp -no_obj expect resp.status == 304 + + txreq -hdr {If-None-Match: W/"12345678"} + rxresp + expect resp.status == 200 + + txreq -hdr {If-None-Match: W/"123456789"} + rxresp -no_obj + expect resp.status == 304 +} -run + +client c2 { + txreq -url /other + rxresp + expect resp.status == 200 + expect resp.bodylen == 10 + expect resp.http.etag == {W/"123456789"} + + txreq -url /other -hdr {If-None-Match: "12345678"} + rxresp + expect resp.status == 200 + + txreq -url /other -hdr {If-None-Match: "123456789"} + rxresp -no_obj + expect resp.status == 304 + + txreq -url /other -hdr {If-None-Match: W/"12345678"} + rxresp + expect resp.status == 200 + + txreq -url /other -hdr {If-None-Match: W/"123456789"} + rxresp -no_obj + expect resp.status == 304 } -run From fgsch at lodoss.net Fri Dec 11 15:35:13 2015 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Fri, 11 Dec 2015 07:35:13 -0800 Subject: [varnishcache/varnish-cache] 038b70: Whitespace Message-ID: <566aed3166971_49933fa966ddb2c05769d@hookshot-fe3-cp1-prd.iad.github.net.mail> Branch: refs/heads/master Home: https://github.com/varnishcache/varnish-cache Commit: 038b70fdac73bf4d8f6845070b0c48d6788b85a9 https://github.com/varnishcache/varnish-cache/commit/038b70fdac73bf4d8f6845070b0c48d6788b85a9 Author: Federico G. Schwindt Date: 2015-12-10 (Thu, 10 Dec 2015) Changed paths: M Makefile.inc.phk M bin/Makefile.phk M bin/flint.lnt M bin/varnishadm/Makefile.phk M bin/varnishd/Makefile.am M bin/varnishd/flint.lnt M bin/varnishd/vclflint.sh M bin/varnishlog/flint.lnt M bin/varnishncsa/flint.lnt M bin/varnishstat/flint.lnt M bin/varnishtest/flint.lnt M bin/varnishtop/flint.lnt M config.phk M configure.ac M doc/sphinx/Makefile.phk M doc/sphinx/glossary/index.rst M doc/sphinx/installation/bugs.rst M doc/sphinx/installation/help.rst M doc/sphinx/installation/platformnotes.rst M doc/sphinx/phk/autocrap.rst M doc/sphinx/phk/backends.rst M doc/sphinx/phk/barriers.rst M doc/sphinx/phk/gzip.rst M doc/sphinx/phk/http20.rst M doc/sphinx/phk/platforms.rst M doc/sphinx/phk/spdy.rst M doc/sphinx/phk/three-zero.rst M doc/sphinx/phk/wanton_destruction.rst M doc/sphinx/tutorial/backend_servers.rst M doc/sphinx/tutorial/starting_varnish.rst M doc/sphinx/users-guide/command-line.rst M doc/sphinx/users-guide/compression.rst M doc/sphinx/users-guide/devicedetection.rst M doc/sphinx/users-guide/esi.rst M doc/sphinx/users-guide/index.rst M doc/sphinx/users-guide/intro.rst M doc/sphinx/users-guide/operation-logging.rst M doc/sphinx/users-guide/params.rst M doc/sphinx/users-guide/vcl-actions.rst M doc/sphinx/users-guide/vcl-example-acls.rst M doc/sphinx/users-guide/vcl-example-manipulating-headers.rst M doc/sphinx/users-guide/vcl-inline-c.rst M doc/sphinx/users-guide/vcl-variables.rst M include/Makefile.am M lib/Makefile.phk M lib/libvarnish/flint.lnt M lib/libvarnishapi/libvarnishapi.map M lib/libvcc/flint.lnt M lib/libvmod_std/vmod.vcc M varnish.m4 Log Message: ----------- Whitespace Commit: e4637bb641ae1d8456747bc0262b5f93e663ed95 https://github.com/varnishcache/varnish-cache/commit/e4637bb641ae1d8456747bc0262b5f93e663ed95 Author: Federico G. Schwindt Date: 2015-12-11 (Fri, 11 Dec 2015) Changed paths: M bin/varnishtest/tests/c00025.vtc M bin/varnishtest/tests/c00026.vtc M bin/varnishtest/tests/m00001.vtc M bin/varnishtest/tests/m00002.vtc M bin/varnishtest/tests/m00003.vtc M bin/varnishtest/tests/m00004.vtc M bin/varnishtest/tests/m00005.vtc M bin/varnishtest/tests/m00006.vtc M bin/varnishtest/tests/m00007.vtc M bin/varnishtest/tests/m00011.vtc M bin/varnishtest/tests/m00013.vtc M bin/varnishtest/tests/r01826.vtc Log Message: ----------- Random pass at sanitising and cleaning some tests Commit: 6469345568aa852258e71df7e42492dfe8cac46b https://github.com/varnishcache/varnish-cache/commit/6469345568aa852258e71df7e42492dfe8cac46b Author: Federico G. Schwindt Date: 2015-12-11 (Fri, 11 Dec 2015) Changed paths: M bin/varnishd/cache/cache_rfc2616.c M bin/varnishtest/tests/c00025.vtc Log Message: ----------- Use a weak comparison function for If-None-Match As per RFC 7232. Fixes #1816. Compare: https://github.com/varnishcache/varnish-cache/compare/faae8c1da7c3...6469345568aa From fgsch at lodoss.net Sat Dec 12 12:27:14 2015 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sat, 12 Dec 2015 13:27:14 +0100 Subject: [master] cccf6a1 For range requests we need a strong validator Message-ID: commit cccf6a16971d1c3c122b3b09cd0dedf1fadc3ed4 Author: Federico G. Schwindt Date: Sat Dec 12 12:14:50 2015 +0000 For range requests we need a strong validator That is, if both If-None-Match and Range are present we need to use a strong comparison as the representation needs to be byte-for-byte identical. diff --git a/bin/varnishd/cache/cache_rfc2616.c b/bin/varnishd/cache/cache_rfc2616.c index d3fa8a2..0c0e127 100644 --- a/bin/varnishd/cache/cache_rfc2616.c +++ b/bin/varnishd/cache/cache_rfc2616.c @@ -233,13 +233,22 @@ RFC2616_Req_Gzip(const struct http *hp) /*--------------------------------------------------------------------*/ static inline int +rfc2616_strong_compare(const char *p, const char *e) +{ + if ((p[0] == 'W' && p[1] == '/') || + (e[0] == 'W' && e[1] == '/')) + return (0); + return (strcmp(p, e) == 0); +} + +static inline int rfc2616_weak_compare(const char *p, const char *e) { if (p[0] == 'W' && p[1] == '/') p += 2; if (e[0] == 'W' && e[1] == '/') e += 2; - return (strcmp(p, e) != 0); + return (strcmp(p, e) == 0); } int @@ -255,9 +264,12 @@ RFC2616_Do_Cond(const struct req *req) */ if (http_GetHdr(req->http, H_If_None_Match, &p) && http_GetHdr(req->resp, H_ETag, &e)) { - if (rfc2616_weak_compare(p, e)) + if (http_GetHdr(req->http, H_Range, NULL)) + do_cond = rfc2616_strong_compare(p, e); + else + do_cond = rfc2616_weak_compare(p, e); + if (!do_cond) return (0); - do_cond = 1; } if (http_GetHdr(req->http, H_If_Modified_Since, &p)) { diff --git a/bin/varnishtest/tests/c00025.vtc b/bin/varnishtest/tests/c00025.vtc index 9b7fc95..f5b8988 100644 --- a/bin/varnishtest/tests/c00025.vtc +++ b/bin/varnishtest/tests/c00025.vtc @@ -27,6 +27,10 @@ client c1 { rxresp -no_obj expect resp.status == 304 + txreq -hdr "Range: bytes=1-2" -hdr {If-None-Match: "123456789"} + rxresp -no_obj + expect resp.status == 304 + txreq -hdr {If-None-Match: W/"12345678"} rxresp expect resp.status == 200 @@ -34,9 +38,11 @@ client c1 { txreq -hdr {If-None-Match: W/"123456789"} rxresp -no_obj expect resp.status == 304 -} -run -client c2 { + txreq -hdr "Range: bytes=1-2" -hdr {If-None-Match: W/"123456789"} + rxresp + expect resp.status == 206 + txreq -url /other rxresp expect resp.status == 200 @@ -51,6 +57,11 @@ client c2 { rxresp -no_obj expect resp.status == 304 + txreq -url /other -hdr "Range: bytes=1-2" \ + -hdr {If-None-Match: "123456789"} + rxresp + expect resp.status == 206 + txreq -url /other -hdr {If-None-Match: W/"12345678"} rxresp expect resp.status == 200 @@ -58,4 +69,9 @@ client c2 { txreq -url /other -hdr {If-None-Match: W/"123456789"} rxresp -no_obj expect resp.status == 304 + + txreq -url /other -hdr "Range: bytes=1-2" \ + -hdr {If-None-Match: W/"123456789"} + rxresp + expect resp.status == 206 } -run From fgsch at lodoss.net Sat Dec 12 12:30:15 2015 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sat, 12 Dec 2015 04:30:15 -0800 Subject: [varnishcache/varnish-cache] cccf6a: For range requests we need a strong validator Message-ID: <566c1357c0526_7fbb3fd8280572c0212579@hookshot-fe2-cp1-prd.iad.github.net.mail> Branch: refs/heads/master Home: https://github.com/varnishcache/varnish-cache Commit: cccf6a16971d1c3c122b3b09cd0dedf1fadc3ed4 https://github.com/varnishcache/varnish-cache/commit/cccf6a16971d1c3c122b3b09cd0dedf1fadc3ed4 Author: Federico G. Schwindt Date: 2015-12-12 (Sat, 12 Dec 2015) Changed paths: M bin/varnishd/cache/cache_rfc2616.c M bin/varnishtest/tests/c00025.vtc Log Message: ----------- For range requests we need a strong validator That is, if both If-None-Match and Range are present we need to use a strong comparison as the representation needs to be byte-for-byte identical. From fgsch at lodoss.net Sat Dec 12 20:51:26 2015 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sat, 12 Dec 2015 21:51:26 +0100 Subject: [master] 7bb758f Ignore If-Modified-Since if we have If-None-Match Message-ID: commit 7bb758fd81265d912c28048d7a41c4316a8d8686 Author: Federico G. Schwindt Date: Sat Dec 12 13:32:28 2015 +0000 Ignore If-Modified-Since if we have If-None-Match The latter takes precedence as per RFC 7232. Also if we have an I-N-M but no entity don't check I-M-S, just do a non-conditional request. diff --git a/bin/varnishd/cache/cache_rfc2616.c b/bin/varnishd/cache/cache_rfc2616.c index 0c0e127..cb089cf 100644 --- a/bin/varnishd/cache/cache_rfc2616.c +++ b/bin/varnishd/cache/cache_rfc2616.c @@ -256,33 +256,31 @@ RFC2616_Do_Cond(const struct req *req) { const char *p, *e; double ims, lm; - int do_cond = 0; /* - * RFC 2616 13.3.4 states we need to match both ETag and - * If-Modified-Since if present. + * We MUST ignore If-Modified-Since if we have an If-None-Match + * header [RFC7232 3.3 p16]. */ - if (http_GetHdr(req->http, H_If_None_Match, &p) && - http_GetHdr(req->resp, H_ETag, &e)) { + if (http_GetHdr(req->http, H_If_None_Match, &p)) { + if (!http_GetHdr(req->resp, H_ETag, &e)) + return (0); if (http_GetHdr(req->http, H_Range, NULL)) - do_cond = rfc2616_strong_compare(p, e); + return (rfc2616_strong_compare(p, e)); else - do_cond = rfc2616_weak_compare(p, e); - if (!do_cond) - return (0); + return (rfc2616_weak_compare(p, e)); } if (http_GetHdr(req->http, H_If_Modified_Since, &p)) { ims = VTIM_parse(p); - if (!ims || ims > req->t_req) /* [RFC2616 14.25] */ + if (!ims || ims > req->t_req) /* [RFC7232 3.3 p16] */ return (0); AZ(ObjGetDouble(req->wrk, req->objcore, OA_LASTMODIFIED, &lm)); if (lm > ims) return (0); - do_cond = 1; + return (1); } - return (do_cond); + return (0); } /*--------------------------------------------------------------------*/ diff --git a/bin/varnishtest/tests/c00026.vtc b/bin/varnishtest/tests/c00026.vtc index 49e4984..82019bd 100644 --- a/bin/varnishtest/tests/c00026.vtc +++ b/bin/varnishtest/tests/c00026.vtc @@ -6,6 +6,11 @@ server s1 { txresp -hdr {ETag: "123456789"} \ -hdr "Last-Modified: Thu, 26 Jun 2008 12:00:01 GMT" \ -bodylen 10 + + rxreq + expect req.url == /other + txresp -hdr "Last-Modified: Thu, 26 Jun 2008 12:00:01 GMT" \ + -bodylen 10 } -start varnish v1 -vcl+backend { } -start @@ -19,8 +24,8 @@ client c1 { txreq -hdr "If-Modified-Since: Thu, 26 Jun 2008 12:00:00 GMT" \ -hdr {If-None-Match: "123456789"} - rxresp - expect resp.status == 200 + rxresp -no_obj + expect resp.status == 304 txreq -hdr "If-Modified-Since: Thu, 26 Jun 2008 12:00:01 GMT" \ -hdr {If-None-Match: "12345678"} @@ -31,4 +36,10 @@ client c1 { -hdr {If-None-Match: "123456789"} rxresp -no_obj expect resp.status == 304 + + txreq -url /other \ + -hdr "If-Modified-Since: Thu, 26 Jun 2008 12:00:01 GMT" \ + -hdr {If-None-Match: "123456789"} + rxresp + expect resp.status == 200 } -run diff --git a/bin/varnishtest/tests/r00907.vtc b/bin/varnishtest/tests/r00907.vtc deleted file mode 100644 index 4bd767f..0000000 --- a/bin/varnishtest/tests/r00907.vtc +++ /dev/null @@ -1,31 +0,0 @@ -varnishtest "Ticket #907 200/304 handling with Etags + Last-Modified" - -server s1 { - rxreq - txresp \ - -hdr {ETag: "saengei1Ohshicich4iteesu"} \ - -hdr "Last-Modified: Tue, 20 Sep 2011 18:55:00 GMT" -} -start - -varnish v1 -vcl+backend { - sub vcl_deliver { - set resp.http.x-timestamp = now; - } -} -start - -client c1 { - txreq -hdr {If-None-Match: "saengei1Ohshicich4iteesu"} - rxresp -no_obj - expect resp.status == 304 - - txreq -hdr {If-None-Match: "saengei1Ohshicich4iteesu"} \ - -hdr "If-Modified-Since: Tue, 20 Sep 2011 18:54:59 GMT" - rxresp -no_obj - expect resp.status == 200 - - txreq -hdr {If-None-Match: "saengei1Ohshicich4iteesu"} \ - -hdr "If-Modified-Since: Tue, 20 Sep 2011 18:55:00 GMT" - rxresp -no_obj - expect resp.status == 304 - -} -run From fgsch at lodoss.net Sat Dec 12 20:55:13 2015 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Sat, 12 Dec 2015 12:55:13 -0800 Subject: [varnishcache/varnish-cache] 7bb758: Ignore If-Modified-Since if we have If-None-Match Message-ID: <566c89b176b0d_5b563f879501b2b81344b0@hookshot-fe1-cp1-prd.iad.github.net.mail> Branch: refs/heads/master Home: https://github.com/varnishcache/varnish-cache Commit: 7bb758fd81265d912c28048d7a41c4316a8d8686 https://github.com/varnishcache/varnish-cache/commit/7bb758fd81265d912c28048d7a41c4316a8d8686 Author: Federico G. Schwindt Date: 2015-12-12 (Sat, 12 Dec 2015) Changed paths: M bin/varnishd/cache/cache_rfc2616.c M bin/varnishtest/tests/c00026.vtc R bin/varnishtest/tests/r00907.vtc Log Message: ----------- Ignore If-Modified-Since if we have If-None-Match The latter takes precedence as per RFC 7232. Also if we have an I-N-M but no entity don't check I-M-S, just do a non-conditional request. From phk at FreeBSD.org Mon Dec 14 13:52:22 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 14 Dec 2015 14:52:22 +0100 Subject: [master] dc24aa9 Staticize Message-ID: commit dc24aa95156fee011d501a96f64fca062670fe72 Author: Poul-Henning Kamp Date: Mon Dec 14 13:51:37 2015 +0000 Staticize diff --git a/lib/libvmod_debug/vmod_debug.c b/lib/libvmod_debug/vmod_debug.c index 91b49c7..a9e2cde 100644 --- a/lib/libvmod_debug/vmod_debug.c +++ b/lib/libvmod_debug/vmod_debug.c @@ -47,7 +47,7 @@ struct priv_vcl { uintptr_t exp_cb; }; -VCL_DURATION vcl_release_delay = 0.0; +static VCL_DURATION vcl_release_delay = 0.0; VCL_VOID __match_proto__(td_debug_panic) vmod_panic(VRT_CTX, const char *str, ...) From phk at FreeBSD.org Mon Dec 14 13:52:23 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 14 Dec 2015 14:52:23 +0100 Subject: [master] 3afde33 FreeBSD's dlopen doesn't return a strerror(3) output, hunt the VCC's own complaint instead. Message-ID: commit 3afde33a7c619d6a3e38241751420b7738034776 Author: Poul-Henning Kamp Date: Mon Dec 14 13:51:43 2015 +0000 FreeBSD's dlopen doesn't return a strerror(3) output, hunt the VCC's own complaint instead. diff --git a/bin/varnishtest/tests/m00003.vtc b/bin/varnishtest/tests/m00003.vtc index 073632d..85970dd 100644 --- a/bin/varnishtest/tests/m00003.vtc +++ b/bin/varnishtest/tests/m00003.vtc @@ -14,7 +14,7 @@ varnish v1 -arg "-pvmod_dir=${topbuild}/lib/libvmod_std/.libs/" \ varnish v1 -cliok "param.set vmod_dir /nonexistent" -varnish v1 -errvcl {No such file or directory} { +varnish v1 -errvcl {Could not load VMOD std} { import std; } From phk at FreeBSD.org Mon Dec 14 13:55:14 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 14 Dec 2015 05:55:14 -0800 Subject: [varnishcache/varnish-cache] dc24aa: Staticize Message-ID: <566eca42a5122_590f3f9b1294b2bc2556@hookshot-fe6-cp1-prd.iad.github.net.mail> Branch: refs/heads/master Home: https://github.com/varnishcache/varnish-cache Commit: dc24aa95156fee011d501a96f64fca062670fe72 https://github.com/varnishcache/varnish-cache/commit/dc24aa95156fee011d501a96f64fca062670fe72 Author: Poul-Henning Kamp Date: 2015-12-14 (Mon, 14 Dec 2015) Changed paths: M lib/libvmod_debug/vmod_debug.c Log Message: ----------- Staticize Commit: 3afde33a7c619d6a3e38241751420b7738034776 https://github.com/varnishcache/varnish-cache/commit/3afde33a7c619d6a3e38241751420b7738034776 Author: Poul-Henning Kamp Date: 2015-12-14 (Mon, 14 Dec 2015) Changed paths: M bin/varnishtest/tests/m00003.vtc Log Message: ----------- FreeBSD's dlopen doesn't return a strerror(3) output, hunt the VCC's own complaint instead. Compare: https://github.com/varnishcache/varnish-cache/compare/7bb758fd8126...3afde33a7c61 From phk at FreeBSD.org Mon Dec 14 14:27:41 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 14 Dec 2015 15:27:41 +0100 Subject: [master] e28f685 Disable the last test, it fails consistently on FreeBSD. Message-ID: commit e28f6851dd4d25b26d828a347288aaa6c94e1ef5 Author: Poul-Henning Kamp Date: Mon Dec 14 14:27:15 2015 +0000 Disable the last test, it fails consistently on FreeBSD. diff --git a/bin/varnishtest/tests/d00012.vtc b/bin/varnishtest/tests/d00012.vtc index 41d23e4..edc028b 100644 --- a/bin/varnishtest/tests/d00012.vtc +++ b/bin/varnishtest/tests/d00012.vtc @@ -74,4 +74,6 @@ varnish v1 -cli "vcl.list" #varnish v1 -expect MAIN.n_backend == 2 # expected: vcl2.dummy, vcl2.s2 varnish v1 -expect n_vcl_avail == 1 -varnish v1 -expect n_vcl_discard == 0 + +# XXX This test fails on FreeBSD +# XXX varnish v1 -expect n_vcl_discard == 0 From phk at FreeBSD.org Mon Dec 14 14:30:16 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 14 Dec 2015 06:30:16 -0800 Subject: [varnishcache/varnish-cache] e28f68: Disable the last test, it fails consistently on Fr... Message-ID: <566ed2783bda4_56863faad8b0b2c03527@hookshot-fe2-cp1-prd.iad.github.net.mail> Branch: refs/heads/master Home: https://github.com/varnishcache/varnish-cache Commit: e28f6851dd4d25b26d828a347288aaa6c94e1ef5 https://github.com/varnishcache/varnish-cache/commit/e28f6851dd4d25b26d828a347288aaa6c94e1ef5 Author: Poul-Henning Kamp Date: 2015-12-14 (Mon, 14 Dec 2015) Changed paths: M bin/varnishtest/tests/d00012.vtc Log Message: ----------- Disable the last test, it fails consistently on FreeBSD. From fgsch at lodoss.net Mon Dec 14 19:16:11 2015 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Mon, 14 Dec 2015 20:16:11 +0100 Subject: [master] dabf783 Use VSB_putc for single char ops Message-ID: commit dabf783269955c8faa07b100a08f93ec7a142736 Author: Federico G. Schwindt Date: Mon Dec 14 11:06:39 2015 +0000 Use VSB_putc for single char ops diff --git a/bin/varnishd/cache/cache_ban_build.c b/bin/varnishd/cache/cache_ban_build.c index 801774f..b3bda03 100644 --- a/bin/varnishd/cache/cache_ban_build.c +++ b/bin/varnishd/cache/cache_ban_build.c @@ -105,7 +105,7 @@ ban_add_lump(const struct ban_proto *bp, const void *p, uint32_t len) buf[0] = 0xff; while (VSB_len(bp->vsb) & PALGN) - VSB_bcat(bp->vsb, buf, 1); + VSB_putc(bp->vsb, buf[0]); vbe32enc(buf, len); VSB_bcat(bp->vsb, buf, sizeof buf); VSB_bcat(bp->vsb, p, len); diff --git a/bin/varnishd/cache/cache_esi_parse.c b/bin/varnishd/cache/cache_esi_parse.c index 76591d0..383731f 100644 --- a/bin/varnishd/cache/cache_esi_parse.c +++ b/bin/varnishd/cache/cache_esi_parse.c @@ -906,7 +906,7 @@ VEP_Parse(struct vep_state *vep, const char *p, size_t l) while (p < e && *p != '>' && *p != vep->attr_delim && (vep->attr_delim != ' ' || !vct_issp(*p))) { if (vep->attr_vsb != NULL) - VSB_bcat(vep->attr_vsb, p, 1); + VSB_putc(vep->attr_vsb, *p); p++; } if (p < e && *p == '>') { diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c index 614317a..b60ddbd 100644 --- a/bin/varnishd/cache/cache_panic.c +++ b/bin/varnishd/cache/cache_panic.c @@ -526,7 +526,7 @@ pan_ic(const char *func, const char *file, int line, const char *cond, } } VSB_printf(pan_vsb, "\n"); - VSB_bcat(pan_vsb, "", 1); /* NUL termination */ + VSB_putc(pan_vsb, '\0'); /* NUL termination */ if (FEATURE(FEATURE_NO_COREDUMP)) exit(4); diff --git a/lib/libvarnishapi/vxp.c b/lib/libvarnishapi/vxp.c index 5dad106..db91b30 100644 --- a/lib/libvarnishapi/vxp.c +++ b/lib/libvarnishapi/vxp.c @@ -82,9 +82,9 @@ vxp_quote(const struct vxp *vxp, const char *b, const char *e, int tokoff) assert(e <= vxp->e); for (p = vxp->b; p < vxp->e; p++) { if (isspace(*p)) - VSB_bcat(vxp->sb, " ", 1); + VSB_putc(vxp->sb, ' '); else - VSB_bcat(vxp->sb, p, 1); + VSB_putc(vxp->sb, *p); } VSB_putc(vxp->sb, '\n'); for (p = vxp->b; p < vxp->e; p++) { diff --git a/lib/libvcc/vcc_token.c b/lib/libvcc/vcc_token.c index 6201fea..a8513f8 100644 --- a/lib/libvcc/vcc_token.c +++ b/lib/libvcc/vcc_token.c @@ -135,13 +135,13 @@ vcc_quoteline(const struct vcc *tl, const char *l, const char *le) y &= ~7; y += 8; while (x < y) { - VSB_bcat(tl->sb, " ", 1); + VSB_putc(tl->sb, ' '); x++; } } else { x++; y++; - VSB_bcat(tl->sb, p, 1); + VSB_putc(tl->sb, *p); } } VSB_putc(tl->sb, '\n'); From fgsch at lodoss.net Mon Dec 14 19:16:11 2015 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Mon, 14 Dec 2015 20:16:11 +0100 Subject: [master] 176ead9 Fix format string warnings Message-ID: commit 176ead9ce93db22444824056fe6bb32739e41c1a Author: Federico G. Schwindt Date: Mon Dec 14 18:49:17 2015 +0000 Fix format string warnings diff --git a/bin/varnishstat/varnishstat_curses.c b/bin/varnishstat/varnishstat_curses.c index 3dd4230..1c90652 100644 --- a/bin/varnishstat/varnishstat_curses.c +++ b/bin/varnishstat/varnishstat_curses.c @@ -540,7 +540,7 @@ static void print_duration(WINDOW *w, time_t t) { - wprintw(w, "%4d+%02d:%02d:%02d", + wprintw(w, "%4lu+%02lu:%02lu:%02lu", t / 86400, (t % 86400) / 3600, (t % 3600) / 60, t % 60); } @@ -790,8 +790,8 @@ draw_line_bitmap(WINDOW *w, int y, int x, int X, struct pt *pt) case COL_VAL: if (X - x < COLW) return; - mvwprintw(w, y, x, " %010.10jx", - (pt->cur >> 24) & 0xffffffffffLL); + mvwprintw(w, y, x, " %10.10jx", + (uintmax_t)((pt->cur >> 24) & 0xffffffffffLL)); x += COLW; break; case COL_MAP: From fgsch at lodoss.net Mon Dec 14 19:16:11 2015 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Mon, 14 Dec 2015 20:16:11 +0100 Subject: [master] 84f57a3 Check format string in some curses implementations Message-ID: commit 84f57a3f541a6922398e25c79f77f828d3d6500e Author: Federico G. Schwindt Date: Mon Dec 14 18:51:24 2015 +0000 Check format string in some curses implementations This is enough to get the warnings fixed in the previous commit on Linux. diff --git a/include/vcurses.h b/include/vcurses.h index d24b556..911cf96 100644 --- a/include/vcurses.h +++ b/include/vcurses.h @@ -33,6 +33,8 @@ #elif defined HAVE_NCURSES_CURSES_H # include #elif defined HAVE_NCURSES_H +# define GCC_PRINTF +# define GCC_SCANF # include #elif defined HAVE_CURSES_H # include From fgsch at lodoss.net Mon Dec 14 19:16:11 2015 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Mon, 14 Dec 2015 20:16:11 +0100 Subject: [master] 63383ec Add missing header on NetBSD Message-ID: commit 63383ec0db51153dc02727664d4e05756c60b039 Author: Federico G. Schwindt Date: Mon Dec 14 18:52:59 2015 +0000 Add missing header on NetBSD diff --git a/lib/libvarnish/vtcp.c b/lib/libvarnish/vtcp.c index cb4d3c4..0c6a312 100644 --- a/lib/libvarnish/vtcp.c +++ b/lib/libvarnish/vtcp.c @@ -32,6 +32,7 @@ #include #include #include +#include #ifdef HAVE_SYS_FILIO_H # include #endif From fgsch at lodoss.net Mon Dec 14 19:20:14 2015 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Mon, 14 Dec 2015 11:20:14 -0800 Subject: [varnishcache/varnish-cache] dabf78: Use VSB_putc for single char ops Message-ID: <566f166ee4489_86c3ff2a3b3b2a0226ab@hookshot-fe1-cp1-prd.iad.github.net.mail> Branch: refs/heads/master Home: https://github.com/varnishcache/varnish-cache Commit: dabf783269955c8faa07b100a08f93ec7a142736 https://github.com/varnishcache/varnish-cache/commit/dabf783269955c8faa07b100a08f93ec7a142736 Author: Federico G. Schwindt Date: 2015-12-14 (Mon, 14 Dec 2015) Changed paths: M bin/varnishd/cache/cache_ban_build.c M bin/varnishd/cache/cache_esi_parse.c M bin/varnishd/cache/cache_panic.c M lib/libvarnishapi/vxp.c M lib/libvcc/vcc_token.c Log Message: ----------- Use VSB_putc for single char ops Commit: 176ead9ce93db22444824056fe6bb32739e41c1a https://github.com/varnishcache/varnish-cache/commit/176ead9ce93db22444824056fe6bb32739e41c1a Author: Federico G. Schwindt Date: 2015-12-14 (Mon, 14 Dec 2015) Changed paths: M bin/varnishstat/varnishstat_curses.c Log Message: ----------- Fix format string warnings Commit: 84f57a3f541a6922398e25c79f77f828d3d6500e https://github.com/varnishcache/varnish-cache/commit/84f57a3f541a6922398e25c79f77f828d3d6500e Author: Federico G. Schwindt Date: 2015-12-14 (Mon, 14 Dec 2015) Changed paths: M include/vcurses.h Log Message: ----------- Check format string in some curses implementations This is enough to get the warnings fixed in the previous commit on Linux. Commit: 63383ec0db51153dc02727664d4e05756c60b039 https://github.com/varnishcache/varnish-cache/commit/63383ec0db51153dc02727664d4e05756c60b039 Author: Federico G. Schwindt Date: 2015-12-14 (Mon, 14 Dec 2015) Changed paths: M lib/libvarnish/vtcp.c Log Message: ----------- Add missing header on NetBSD Compare: https://github.com/varnishcache/varnish-cache/compare/e28f6851dd4d...63383ec0db51 From fgsch at lodoss.net Mon Dec 14 19:29:18 2015 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Mon, 14 Dec 2015 20:29:18 +0100 Subject: [master] aed3e68 Fix another warning spotted on FreeBSD Message-ID: commit aed3e68fd0c32904c1435cf010789d29883600e6 Author: Federico G. Schwindt Date: Mon Dec 14 19:28:28 2015 +0000 Fix another warning spotted on FreeBSD diff --git a/bin/varnishstat/varnishstat_curses.c b/bin/varnishstat/varnishstat_curses.c index 1c90652..a27d438 100644 --- a/bin/varnishstat/varnishstat_curses.c +++ b/bin/varnishstat/varnishstat_curses.c @@ -934,7 +934,7 @@ draw_bar_b(void) page_start + l_points < n_ptarray ? page_start + l_points : n_ptarray, n_ptarray); - mvwprintw(w_bar_b, 0, X - strlen(buf), buf); + mvwprintw(w_bar_b, 0, X - strlen(buf), "%s", buf); X -= strlen(buf) + 2; level = VSC_LevelDesc(verbosity); From fgsch at lodoss.net Mon Dec 14 19:30:15 2015 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Mon, 14 Dec 2015 11:30:15 -0800 Subject: [varnishcache/varnish-cache] aed3e6: Fix another warning spotted on FreeBSD Message-ID: <566f18c78f3ea_59b03fe4aac8129c882d6@hookshot-fe1-cp1-prd.iad.github.net.mail> Branch: refs/heads/master Home: https://github.com/varnishcache/varnish-cache Commit: aed3e68fd0c32904c1435cf010789d29883600e6 https://github.com/varnishcache/varnish-cache/commit/aed3e68fd0c32904c1435cf010789d29883600e6 Author: Federico G. Schwindt Date: 2015-12-14 (Mon, 14 Dec 2015) Changed paths: M bin/varnishstat/varnishstat_curses.c Log Message: ----------- Fix another warning spotted on FreeBSD From fgsch at lodoss.net Mon Dec 14 19:57:46 2015 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Mon, 14 Dec 2015 20:57:46 +0100 Subject: [master] 534aeac Use some casting foo to get this building Message-ID: commit 534aeac48a797735278f596b5c43b3d396be5bf1 Author: Federico G. Schwindt Date: Mon Dec 14 19:47:05 2015 +0000 Use some casting foo to get this building NetBSD's pthread_setname_np(3) wants a void *. Sigh. diff --git a/bin/varnishd/cache/cache_main.c b/bin/varnishd/cache/cache_main.c index 0f28302..8d2e8f0 100644 --- a/bin/varnishd/cache/cache_main.c +++ b/bin/varnishd/cache/cache_main.c @@ -98,7 +98,7 @@ THR_SetName(const char *name) #if defined(__APPLE__) pthread_setname_np(name); #elif defined(__NetBSD__) - pthread_setname_np(pthread_self(), "%s", name); + pthread_setname_np(pthread_self(), "%s", (char *)(uintptr_t)name); #else pthread_setname_np(pthread_self(), name); #endif From fgsch at lodoss.net Mon Dec 14 20:00:15 2015 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Mon, 14 Dec 2015 12:00:15 -0800 Subject: [varnishcache/varnish-cache] 534aea: Use some casting foo to get this building Message-ID: <566f1fcfd1426_64e53fa401ee92bc3839@hookshot-fe5-cp1-prd.iad.github.net.mail> Branch: refs/heads/master Home: https://github.com/varnishcache/varnish-cache Commit: 534aeac48a797735278f596b5c43b3d396be5bf1 https://github.com/varnishcache/varnish-cache/commit/534aeac48a797735278f596b5c43b3d396be5bf1 Author: Federico G. Schwindt Date: 2015-12-14 (Mon, 14 Dec 2015) Changed paths: M bin/varnishd/cache/cache_main.c Log Message: ----------- Use some casting foo to get this building NetBSD's pthread_setname_np(3) wants a void *. Sigh. From phk at FreeBSD.org Mon Dec 14 20:34:27 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 14 Dec 2015 21:34:27 +0100 Subject: [master] e294481 Add an explicit OC_F_INCOMPLETE flag to limit the amount of code that needs to know about oc->busyobj semantics Message-ID: commit e29448145caf8d2df363912871c01a079b46bc2d Author: Poul-Henning Kamp Date: Mon Dec 14 20:33:50 2015 +0000 Add an explicit OC_F_INCOMPLETE flag to limit the amount of code that needs to know about oc->busyobj semantics diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 7f51968..918d620 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -404,6 +404,7 @@ struct objcore { uint16_t flags; #define OC_F_BUSY (1<<1) #define OC_F_PASS (1<<2) +#define OC_F_INCOMPLETE (1<<3) #define OC_F_PRIVATE (1<<8) #define OC_F_FAILED (1<<9) diff --git a/bin/varnishd/cache/cache_expire.c b/bin/varnishd/cache/cache_expire.c index 65236b7..5c27d07 100644 --- a/bin/varnishd/cache/cache_expire.c +++ b/bin/varnishd/cache/cache_expire.c @@ -231,7 +231,7 @@ EXP_Touch(struct objcore *oc, double now) CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); - if (oc->busyobj != NULL) + if (oc->flags & OC_F_INCOMPLETE) return; if (now - oc->last_lru < cache_param->lru_interval) diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c index aa516bf..917109a 100644 --- a/bin/varnishd/cache/cache_gzip.c +++ b/bin/varnishd/cache/cache_gzip.c @@ -307,8 +307,8 @@ VDP_gunzip(struct req *req, enum vdp_action act, void **priv, http_Unset(req->resp, H_Content_Encoding); req->resp_len = -1; - if (req->objcore->busyobj != NULL) - return (0); /* Incomplete, no idea about length */ + if (req->objcore->flags & OC_F_INCOMPLETE) + return (0); /* No idea about length */ p = ObjGetattr(req->wrk, req->objcore, OA_GZIPBITS, &dl); if (p == NULL || dl != 32) diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c index d93320d..85da4f0 100644 --- a/bin/varnishd/cache/cache_hash.c +++ b/bin/varnishd/cache/cache_hash.c @@ -75,7 +75,7 @@ hsh_NewObjCore(struct worker *wrk) ALLOC_OBJ(oc, OBJCORE_MAGIC); XXXAN(oc); wrk->stats->n_objectcore++; - oc->flags |= OC_F_BUSY; + oc->flags |= OC_F_BUSY | OC_F_INCOMPLETE; return (oc); } @@ -650,6 +650,7 @@ HSH_Fail(struct objcore *oc) Lck_Lock(&oh->mtx); oc->flags |= OC_F_FAILED; + oc->flags &= ~OC_F_INCOMPLETE; oc->busyobj = NULL; Lck_Unlock(&oh->mtx); } @@ -669,6 +670,7 @@ HSH_Complete(struct objcore *oc) Lck_Lock(&oh->mtx); oc->busyobj = NULL; + oc->flags &= ~OC_F_INCOMPLETE; Lck_Unlock(&oh->mtx); } diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c index 5dd890e..b76c069 100644 --- a/bin/varnishd/cache/cache_vrt_var.c +++ b/bin/varnishd/cache/cache_vrt_var.c @@ -670,7 +670,7 @@ VRT_r_resp_is_streaming(VRT_CTX) if (ctx->req->objcore == NULL) return (0); /* When called from vcl_synth */ CHECK_OBJ_NOTNULL(ctx->req->objcore, OBJCORE_MAGIC); - return (ctx->req->objcore->busyobj != NULL ? 1 : 0); + return (ctx->req->objcore->flags & OC_F_INCOMPLETE ? 1 : 0); } /*--------------------------------------------------------------------*/ From phk at FreeBSD.org Mon Dec 14 20:35:13 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 14 Dec 2015 12:35:13 -0800 Subject: [varnishcache/varnish-cache] e29448: Add an explicit OC_F_INCOMPLETE flag to limit the ... Message-ID: <566f28017af20_3803fd8950bf2b810076e@hookshot-fe3-cp1-prd.iad.github.net.mail> Branch: refs/heads/master Home: https://github.com/varnishcache/varnish-cache Commit: e29448145caf8d2df363912871c01a079b46bc2d https://github.com/varnishcache/varnish-cache/commit/e29448145caf8d2df363912871c01a079b46bc2d Author: Poul-Henning Kamp Date: 2015-12-14 (Mon, 14 Dec 2015) Changed paths: M bin/varnishd/cache/cache.h M bin/varnishd/cache/cache_expire.c M bin/varnishd/cache/cache_gzip.c M bin/varnishd/cache/cache_hash.c M bin/varnishd/cache/cache_vrt_var.c Log Message: ----------- Add an explicit OC_F_INCOMPLETE flag to limit the amount of code that needs to know about oc->busyobj semantics From phk at FreeBSD.org Mon Dec 14 22:36:58 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 14 Dec 2015 23:36:58 +0100 Subject: [master] 15aad35 Move the default objcore->methods into their own file. Message-ID: commit 15aad353d94fae4e3108ab2acc335c95f7bd9c0f Author: Poul-Henning Kamp Date: Mon Dec 14 21:29:19 2015 +0000 Move the default objcore->methods into their own file. These are the methods used by "simple" stevedores, more advanced stevedores can bring their own set. diff --git a/bin/varnishd/Makefile.am b/bin/varnishd/Makefile.am index 0648822..99e7fb4 100644 --- a/bin/varnishd/Makefile.am +++ b/bin/varnishd/Makefile.am @@ -91,6 +91,7 @@ varnishd_SOURCES = \ storage/mgt_storage_persistent.c \ storage/storage_persistent_silo.c \ storage/storage_persistent_subr.c \ + storage/storage_simple.c \ storage/storage_umem.c \ waiter/mgt_waiter.c \ waiter/cache_waiter.c \ diff --git a/bin/varnishd/storage/stevedore.c b/bin/varnishd/storage/stevedore.c index 77e54a3..6c0ad0b 100644 --- a/bin/varnishd/storage/stevedore.c +++ b/bin/varnishd/storage/stevedore.c @@ -44,58 +44,6 @@ static const struct stevedore * volatile stv_next; -/*--------------------------------------------------------------------- - * Default objcore methods - */ - -static struct object * __match_proto__(getobj_f) -default_oc_getobj(struct worker *wrk, struct objcore *oc) -{ - struct object *o; - - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); - if (oc->stobj->priv == NULL) - return (NULL); - CAST_OBJ_NOTNULL(o, oc->stobj->priv, OBJECT_MAGIC); - return (o); -} - -static void __match_proto__(freeobj_f) -default_oc_freeobj(struct worker *wrk, struct objcore *oc) -{ - struct object *o; - - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); - CHECK_OBJ_NOTNULL(oc->stobj, STOREOBJ_MAGIC); - ObjSlim(wrk, oc); - CAST_OBJ_NOTNULL(o, oc->stobj->priv, OBJECT_MAGIC); - o->magic = 0; - - STV_free(oc->stobj->stevedore, o->objstore); - - memset(oc->stobj, 0, sizeof oc->stobj); - - wrk->stats->n_object--; -} - -static struct lru * __match_proto__(getlru_f) -default_oc_getlru(const struct objcore *oc) -{ - const struct stevedore *stv; - - stv = oc->stobj->stevedore; - CHECK_OBJ_NOTNULL(stv, STEVEDORE_MAGIC); - return (stv->lru); -} - -const struct storeobj_methods default_oc_methods = { - .getobj = default_oc_getobj, - .freeobj = default_oc_freeobj, - .getlru = default_oc_getlru, -}; - /*-------------------------------------------------------------------- */ diff --git a/bin/varnishd/storage/storage_simple.c b/bin/varnishd/storage/storage_simple.c new file mode 100644 index 0000000..141b413 --- /dev/null +++ b/bin/varnishd/storage/storage_simple.c @@ -0,0 +1,88 @@ +/*- + * Copyright (c) 2007-2015 Varnish Software AS + * All rights reserved. + * + * Author: Poul-Henning Kamp + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ + +#include "config.h" + +#include +#include + +#include "cache/cache.h" + +#include "storage/storage.h" + +/*--------------------------------------------------------------------- + */ + +static struct object * __match_proto__(getobj_f) +default_oc_getobj(struct worker *wrk, struct objcore *oc) +{ + struct object *o; + + CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); + CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); + if (oc->stobj->priv == NULL) + return (NULL); + CAST_OBJ_NOTNULL(o, oc->stobj->priv, OBJECT_MAGIC); + return (o); +} + +static void __match_proto__(freeobj_f) +default_oc_freeobj(struct worker *wrk, struct objcore *oc) +{ + struct object *o; + + CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); + CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); + CHECK_OBJ_NOTNULL(oc->stobj, STOREOBJ_MAGIC); + ObjSlim(wrk, oc); + CAST_OBJ_NOTNULL(o, oc->stobj->priv, OBJECT_MAGIC); + o->magic = 0; + + STV_free(oc->stobj->stevedore, o->objstore); + + memset(oc->stobj, 0, sizeof oc->stobj); + + wrk->stats->n_object--; +} + +static struct lru * __match_proto__(getlru_f) +default_oc_getlru(const struct objcore *oc) +{ + const struct stevedore *stv; + + stv = oc->stobj->stevedore; + CHECK_OBJ_NOTNULL(stv, STEVEDORE_MAGIC); + return (stv->lru); +} + +const struct storeobj_methods default_oc_methods = { + .getobj = default_oc_getobj, + .freeobj = default_oc_freeobj, + .getlru = default_oc_getlru, +}; From phk at FreeBSD.org Mon Dec 14 22:36:58 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 14 Dec 2015 23:36:58 +0100 Subject: [master] 2c76f5b Collect all the stuff which implements objects on top of "simple" stevedores and call it "SML". Message-ID: commit 2c76f5b2152d714f42c322041d9552d73ef597c9 Author: Poul-Henning Kamp Date: Mon Dec 14 22:35:56 2015 +0000 Collect all the stuff which implements objects on top of "simple" stevedores and call it "SML". I bet this is going to surprise Martin :-) diff --git a/bin/varnishd/Makefile.am b/bin/varnishd/Makefile.am index 99e7fb4..1f1f110 100644 --- a/bin/varnishd/Makefile.am +++ b/bin/varnishd/Makefile.am @@ -113,6 +113,7 @@ noinst_HEADERS = \ mgt/mgt_cli.h \ mgt/mgt_param.h \ storage/storage.h \ + storage/storage_simple.h \ storage/storage_persistent.h \ waiter/waiter_priv.h \ waiter/mgt_waiter.h diff --git a/bin/varnishd/cache/cache_obj.c b/bin/varnishd/cache/cache_obj.c index 206cf03..cadd0f1 100644 --- a/bin/varnishd/cache/cache_obj.c +++ b/bin/varnishd/cache/cache_obj.c @@ -57,18 +57,6 @@ obj_getmethods(const struct objcore *oc) return (oc->stobj->stevedore->methods); } -static struct object * -obj_getobj(struct worker *wrk, struct objcore *oc) -{ - const struct storeobj_methods *m; - - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); - m = obj_getmethods(oc); - AN(m->getobj); - return (m->getobj(wrk, oc)); -} - /*==================================================================== * ObjIterate() * @@ -78,127 +66,12 @@ int ObjIterate(struct worker *wrk, struct objcore *oc, void *priv, objiterate_f *func) { - struct busyobj *bo; - struct object *obj; - struct storage *st; - struct storage *checkpoint = NULL; - ssize_t checkpoint_len = 0; - ssize_t len = 0; - int ret = 0; - ssize_t ol; - ssize_t nl; - ssize_t sl; - void *p; - ssize_t l; const struct storeobj_methods *om = obj_getmethods(oc); - if (om->objiterator != NULL) - return (om->objiterator(wrk, oc, priv, func)); - - obj = obj_getobj(wrk, oc); - CHECK_OBJ_NOTNULL(obj, OBJECT_MAGIC); - - bo = HSH_RefBusy(oc); - - if (bo == NULL) { - VTAILQ_FOREACH(st, &obj->list, list) - if (func(priv, 0, st->ptr, st->len)) - return (-1); - return (0); - } - - p = NULL; - l = 0; - - while (1) { - ol = len; - nl = VBO_waitlen(wrk, bo, ol); - if (bo->state == BOS_FAILED) { - ret = -1; - break; - } - if (nl == ol) { - if (bo->state == BOS_FINISHED) - break; - continue; - } - Lck_Lock(&bo->mtx); - AZ(VTAILQ_EMPTY(&obj->list)); - if (checkpoint == NULL) { - st = VTAILQ_FIRST(&obj->list); - sl = 0; - } else { - st = checkpoint; - sl = checkpoint_len; - ol -= checkpoint_len; - } - while (st != NULL) { - if (st->len > ol) { - p = st->ptr + ol; - l = st->len - ol; - len += l; - break; - } - ol -= st->len; - assert(ol >= 0); - nl -= st->len; - assert(nl > 0); - sl += st->len; - st = VTAILQ_NEXT(st, list); - if (VTAILQ_NEXT(st, list) != NULL) { - checkpoint = st; - checkpoint_len = sl; - } - } - CHECK_OBJ_NOTNULL(obj, OBJECT_MAGIC); - CHECK_OBJ_NOTNULL(st, STORAGE_MAGIC); - st = VTAILQ_NEXT(st, list); - if (st != NULL && st->len == 0) - st = NULL; - Lck_Unlock(&bo->mtx); - assert(l > 0 || bo->state == BOS_FINISHED); - if (func(priv, st != NULL ? 0 : 1, p, l)) { - ret = -1; - break; - } - } - if (oc->flags & OC_F_PASS) - bo->abandon = 1; - VBO_DerefBusyObj(wrk, &bo); - return (ret); -} - -/*-------------------------------------------------------------------- - */ - -static struct storage * -objallocwithnuke(struct worker *wrk, const struct stevedore *stv, size_t size) -{ - struct storage *st = NULL; - unsigned fail; - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - CHECK_OBJ_NOTNULL(stv, STEVEDORE_MAGIC); - - if (size > cache_param->fetch_maxchunksize) - size = cache_param->fetch_maxchunksize; - - assert(size <= UINT_MAX); /* field limit in struct storage */ - - for (fail = 0; fail <= cache_param->nuke_limit; fail++) { - /* try to allocate from it */ - AN(stv->alloc); - st = STV_alloc(stv, size); - if (st != NULL) - break; - - /* no luck; try to free some space and keep trying */ - if (fail < cache_param->nuke_limit && - EXP_NukeOne(wrk, stv->lru) == -1) - break; - } - CHECK_OBJ_ORNULL(st, STORAGE_MAGIC); - return (st); + AN(func); + AN(om->objiterator); + return (om->objiterator(wrk, oc, priv, func)); } /*==================================================================== @@ -213,8 +86,6 @@ objallocwithnuke(struct worker *wrk, const struct stevedore *stv, size_t size) int ObjGetSpace(struct worker *wrk, struct objcore *oc, ssize_t *sz, uint8_t **ptr) { - struct object *o; - struct storage *st; const struct storeobj_methods *om = obj_getmethods(oc); CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); @@ -222,37 +93,8 @@ ObjGetSpace(struct worker *wrk, struct objcore *oc, ssize_t *sz, uint8_t **ptr) AN(ptr); assert(*sz > 0); - if (om->objgetspace != NULL) - return (om->objgetspace(wrk, oc, sz, ptr)); - - o = obj_getobj(wrk, oc); - CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); - - st = VTAILQ_LAST(&o->list, storagehead); - if (st != NULL && st->len < st->space) { - *sz = st->space - st->len; - *ptr = st->ptr + st->len; - assert (*sz > 0); - return (1); - } - - st = objallocwithnuke(wrk, oc->stobj->stevedore, *sz); - if (st == NULL) - return (0); - - if (oc->busyobj != NULL) { - CHECK_OBJ_NOTNULL(oc->busyobj, BUSYOBJ_MAGIC); - Lck_Lock(&oc->busyobj->mtx); - VTAILQ_INSERT_TAIL(&o->list, st, list); - Lck_Unlock(&oc->busyobj->mtx); - } else { - AN(oc->flags & (OC_F_PRIVATE)); - VTAILQ_INSERT_TAIL(&o->list, st, list); - } - *sz = st->space - st->len; - assert (*sz > 0); - *ptr = st->ptr + st->len; - return (1); + AN(om->objgetspace); + return (om->objgetspace(wrk, oc, sz, ptr)); } /*==================================================================== @@ -265,25 +107,13 @@ ObjGetSpace(struct worker *wrk, struct objcore *oc, ssize_t *sz, uint8_t **ptr) void ObjExtend(struct worker *wrk, struct objcore *oc, ssize_t l) { - struct object *o; - struct storage *st; const struct storeobj_methods *om = obj_getmethods(oc); CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); assert(l > 0); - if (om->objextend != NULL) { - om->objextend(wrk, oc, l); - return; - } - - o = obj_getobj(wrk, oc); - CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); - st = VTAILQ_LAST(&o->list, storagehead); - CHECK_OBJ_NOTNULL(st, STORAGE_MAGIC); - assert(st->len + l <= st->space); - st->len += l; - o->len += l; + AN(om->objextend); + om->objextend(wrk, oc, l); } /*==================================================================== @@ -295,20 +125,14 @@ ObjExtend(struct worker *wrk, struct objcore *oc, ssize_t l) uint64_t ObjGetLen(struct worker *wrk, struct objcore *oc) { - struct object *o; const struct storeobj_methods *om = obj_getmethods(oc); CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - if (om->objgetlen != NULL) - return (om->objgetlen(wrk, oc)); - - o = obj_getobj(wrk, oc); - CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); - return (o->len); + AN(om->objgetlen); + return (om->objgetlen(wrk, oc)); } - /*==================================================================== * ObjTrimStore() * @@ -319,31 +143,13 @@ ObjGetLen(struct worker *wrk, struct objcore *oc) void ObjTrimStore(struct worker *wrk, struct objcore *oc) { - const struct stevedore *stv; - struct storage *st; - struct object *o; const struct storeobj_methods *om = obj_getmethods(oc); CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - if (om->objtrimstore != NULL) { + if (om->objtrimstore != NULL) om->objtrimstore(wrk, oc); - return; - } - - stv = oc->stobj->stevedore; - CHECK_OBJ_NOTNULL(stv, STEVEDORE_MAGIC); - o = obj_getobj(wrk, oc); - CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); - st = VTAILQ_LAST(&o->list, storagehead); - if (st == NULL) - return; - if (st->len == 0) { - VTAILQ_REMOVE(&o->list, st, list); - STV_free(stv, st); - } else if (st->len < st->space) { - STV_trim(stv, st, st->len, 1); - } + return; } /*==================================================================== @@ -356,32 +162,12 @@ ObjTrimStore(struct worker *wrk, struct objcore *oc) void ObjSlim(struct worker *wrk, struct objcore *oc) { - const struct stevedore *stv; - struct object *o; - struct storage *st, *stn; const struct storeobj_methods *om = obj_getmethods(oc); CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - if (om->objslim != NULL) { + if (om->objslim != NULL) om->objslim(wrk, oc); - return; - } - - stv = oc->stobj->stevedore; - CHECK_OBJ_NOTNULL(stv, STEVEDORE_MAGIC); - o = obj_getobj(wrk, oc); - CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); - - if (o->esidata != NULL) { - STV_free(stv, o->esidata); - o->esidata = NULL; - } - VTAILQ_FOREACH_SAFE(st, &o->list, list, stn) { - CHECK_OBJ_NOTNULL(st, STORAGE_MAGIC); - VTAILQ_REMOVE(&o->list, st, list); - STV_free(stv, st); - } } /*==================================================================== @@ -393,8 +179,8 @@ ObjUpdateMeta(struct worker *wrk, struct objcore *oc) CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - if (m->updatemeta != NULL) - m->updatemeta(wrk, oc); + if (m->objupdatemeta != NULL) + m->objupdatemeta(wrk, oc); } /*==================================================================== @@ -406,8 +192,8 @@ ObjFreeObj(struct worker *wrk, struct objcore *oc) CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - AN(m->freeobj); - m->freeobj(wrk, oc); + AN(m->objfree); + m->objfree(wrk, oc); AZ(oc->stobj->stevedore); } @@ -418,8 +204,8 @@ ObjGetLRU(const struct objcore *oc) { const struct storeobj_methods *m = obj_getmethods(oc); - AN(m->getlru); - return (m->getlru(oc)); + AN(m->objgetlru); + return (m->objgetlru(oc)); } /*==================================================================== @@ -432,47 +218,12 @@ void * ObjGetattr(struct worker *wrk, struct objcore *oc, enum obj_attr attr, ssize_t *len) { - struct object *o; - ssize_t dummy; const struct storeobj_methods *om = obj_getmethods(oc); CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - if (om->objgetattr != NULL) - return (om->objgetattr(wrk, oc, attr, len)); - - if (len == NULL) - len = &dummy; - o = obj_getobj(wrk, oc); - CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); - switch (attr) { - case OA_ESIDATA: - if (o->esidata == NULL) - return (NULL); - *len = o->esidata->len; - return (o->esidata->ptr); - case OA_FLAGS: - *len = sizeof o->oa_flags; - return (o->oa_flags); - case OA_GZIPBITS: - *len = sizeof o->oa_gzipbits; - return (o->oa_gzipbits); - case OA_HEADERS: - *len = 0; // XXX: hack - return (o->oa_http); - case OA_LASTMODIFIED: - *len = sizeof o->oa_lastmodified; - return (o->oa_lastmodified); - case OA_VARY: - *len = 4; // XXX: hack - return (o->oa_vary); - case OA_VXID: - *len = sizeof o->oa_vxid; - return (o->oa_vxid); - default: - break; - } - WRONG("Unsupported OBJ_ATTR"); + AN(om->objgetattr); + return (om->objgetattr(wrk, oc, attr, len)); } /*==================================================================== @@ -486,64 +237,12 @@ void * ObjSetattr(struct worker *wrk, struct objcore *oc, enum obj_attr attr, ssize_t len, const void *ptr) { - struct object *o; - void *retval = NULL; - struct storage *st; const struct storeobj_methods *om = obj_getmethods(oc); CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - if (om->objsetattr != NULL) - return (om->objsetattr(wrk, oc, attr, len, ptr)); - - o = obj_getobj(wrk, oc); - CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); - st = o->objstore; - switch (attr) { - case OA_ESIDATA: - o->esidata = objallocwithnuke(wrk, oc->stobj->stevedore, len); - if (o->esidata == NULL) - return (NULL); - o->esidata->len = len; - retval = o->esidata->ptr; - break; - case OA_FLAGS: - assert(len == sizeof o->oa_flags); - retval = o->oa_flags; - break; - case OA_GZIPBITS: - assert(len == sizeof o->oa_gzipbits); - retval = o->oa_gzipbits; - break; - case OA_HEADERS: - len = PRNDUP(len); - assert(st->len + len <= st->space); - o->oa_http = (void*)(st->ptr + st->len); - st->len += len; - retval = o->oa_http; - break; - case OA_LASTMODIFIED: - assert(len == sizeof o->oa_lastmodified); - retval = o->oa_lastmodified; - break; - case OA_VARY: - len = PRNDUP(len); - assert(st->len + len <= st->space); - o->oa_vary = (void*)(st->ptr + st->len); - st->len += len; - retval = o->oa_vary; - break; - case OA_VXID: - assert(len == sizeof o->oa_vxid); - retval = o->oa_vxid; - break; - default: - WRONG("Unsupported OBJ_ATTR"); - break; - } - if (ptr != NULL) - memcpy(retval, ptr, len); - return (retval); + AN(om->objsetattr); + return (om->objsetattr(wrk, oc, attr, len, ptr)); } /*==================================================================== diff --git a/bin/varnishd/storage/mgt_stevedore.c b/bin/varnishd/storage/mgt_stevedore.c index 109290f..9852ea6 100644 --- a/bin/varnishd/storage/mgt_stevedore.c +++ b/bin/varnishd/storage/mgt_stevedore.c @@ -183,8 +183,8 @@ STV_Config(const char *spec) ARGV_ERR("(-s%s) too many arguments\n", stv->name); AN(stv->alloc); - if (stv->allocobj == NULL) - stv->allocobj = stv_default_allocobj; + AN(stv->allocobj); + AN(stv->methods); if (!strcmp(stv->ident, TRANSIENT_STORAGE)) { stv->transient = 1; diff --git a/bin/varnishd/storage/mgt_storage_persistent.c b/bin/varnishd/storage/mgt_storage_persistent.c index 76d6436..f55d793 100644 --- a/bin/varnishd/storage/mgt_storage_persistent.c +++ b/bin/varnishd/storage/mgt_storage_persistent.c @@ -44,6 +44,7 @@ #include "cache/cache.h" #include "storage/storage.h" +#include "storage/storage_simple.h" #include "vsha256.h" diff --git a/bin/varnishd/storage/stevedore.c b/bin/varnishd/storage/stevedore.c index 6c0ad0b..1029dd2 100644 --- a/bin/varnishd/storage/stevedore.c +++ b/bin/varnishd/storage/stevedore.c @@ -131,65 +131,6 @@ STV_alloc(const struct stevedore *stv, size_t size) return (st); } -/*-------------------------------------------------------------------- - * This function is called by stevedores ->allocobj() method, which - * very often will be stv_default_allocobj() below, to convert a slab - * of storage into object which the stevedore can then register in its - * internal state, before returning it to STV_NewObject(). - * As you probably guessed: All this for persistence. - */ - -struct object * -STV_MkObject(const struct stevedore *stv, struct objcore *oc, void *ptr) -{ - struct object *o; - - CHECK_OBJ_NOTNULL(stv, STEVEDORE_MAGIC); - CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); - - assert(PAOK(ptr)); - - o = ptr; - INIT_OBJ(o, OBJECT_MAGIC); - - VTAILQ_INIT(&o->list); - - oc->stobj->magic = STOREOBJ_MAGIC; - oc->stobj->stevedore = stv; - AN(stv->methods); - oc->stobj->priv = o; - return (o); -} - -/*-------------------------------------------------------------------- - * This is the default ->allocobj() which all stevedores who do not - * implement persistent storage can rely on. - */ - -int -stv_default_allocobj(const struct stevedore *stv, struct objcore *oc, - unsigned wsl) -{ - struct object *o; - struct storage *st; - unsigned ltot; - - CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); - ltot = sizeof(struct object) + PRNDUP(wsl); - st = stv->alloc(stv, ltot); - if (st == NULL) - return (0); - if (st->space < ltot) { - stv->free(st); - return (0); - } - o = STV_MkObject(stv, oc, st->ptr); - CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); - st->len = sizeof(*o); - o->objstore = st; - return (1); -} - /*------------------------------------------------------------------- * Allocate storage for an object, based on the header information. * XXX: If we know (a hint of) the length, we could allocate space diff --git a/bin/varnishd/storage/storage.h b/bin/varnishd/storage/storage.h index f6636ee..a42a9cb 100644 --- a/bin/varnishd/storage/storage.h +++ b/bin/varnishd/storage/storage.h @@ -55,46 +55,17 @@ struct storage { unsigned space; }; -/* Object ------------------------------------------------------------*/ - -VTAILQ_HEAD(storagehead, storage); - -struct object { - unsigned magic; -#define OBJECT_MAGIC 0x32851d42 - struct storage *objstore; - - char oa_vxid[4]; - uint8_t *oa_vary; - uint8_t *oa_http; - uint8_t oa_flags[1]; - char oa_gzipbits[32]; - char oa_lastmodified[8]; - - struct storagehead list; - ssize_t len; - - struct storage *esidata; -}; - /* Methods on objcore ------------------------------------------------*/ #ifdef VARNISH_CACHE_CHILD -typedef void updatemeta_f(struct worker *, struct objcore *oc); -typedef void freeobj_f(struct worker *, struct objcore *oc); -typedef struct lru *getlru_f(const struct objcore *oc); - -/* - * Stevedores can either be simple, and provide just this method: - */ +typedef void objupdatemeta_f(struct worker *, struct objcore *oc); +typedef void objfree_f(struct worker *, struct objcore *oc); +typedef struct lru *objgetlru_f(const struct objcore *oc); -typedef struct object *getobj_f(struct worker *, struct objcore *oc); +/* This method is only used by SML (...to get to persistent) */ +typedef struct object *sml_getobj_f(struct worker *, struct objcore *oc); -/* - * Or the can be "complex" and provide all of these methods: - * (Described in comments in cache_obj.c) - */ typedef int objiterator_f(struct worker *, struct objcore *oc, void *priv, objiterate_f *func); typedef int objgetspace_f(struct worker *, struct objcore *, @@ -109,11 +80,11 @@ typedef void *objsetattr_f(struct worker *, struct objcore *, typedef uint64_t objgetlen_f(struct worker *, struct objcore *); struct storeobj_methods { - freeobj_f *freeobj; - getlru_f *getlru; - updatemeta_f *updatemeta; + objfree_f *objfree; + objgetlru_f *objgetlru; + objupdatemeta_f *objupdatemeta; - getobj_f *getobj; + sml_getobj_f *sml_getobj; objiterator_f *objiterator; objgetspace_f *objgetspace; @@ -152,10 +123,6 @@ typedef void storage_banexport_f(const struct stevedore *, const uint8_t *bans, #include "tbl/vrt_stv_var.h" #undef VRTSTVTYPE -extern storage_allocobj_f stv_default_allocobj; - -extern const struct storeobj_methods default_oc_methods; - /*--------------------------------------------------------------------*/ struct stevedore { @@ -199,8 +166,6 @@ extern struct stevedore *stv_transient; int STV_GetFile(const char *fn, int *fdp, const char **fnp, const char *ctx); uintmax_t STV_FileSize(int fd, const char *size, unsigned *granularity, const char *ctx); -struct object *STV_MkObject(const struct stevedore *, struct objcore *, - void *ptr); struct lru *LRU_Alloc(void); void LRU_Free(struct lru *lru); diff --git a/bin/varnishd/storage/storage_file.c b/bin/varnishd/storage/storage_file.c index 151f75e..c1d7992 100644 --- a/bin/varnishd/storage/storage_file.c +++ b/bin/varnishd/storage/storage_file.c @@ -39,6 +39,7 @@ #include "cache/cache.h" #include "storage/storage.h" +#include "storage/storage_simple.h" #include "vnum.h" #include "vfil.h" @@ -535,7 +536,8 @@ const struct stevedore smf_stevedore = { .alloc = smf_alloc, .trim = smf_trim, .free = smf_free, - .methods = &default_oc_methods, + .allocobj = SML_allocobj, + .methods = &SML_methods, }; #ifdef INCLUDE_TEST_DRIVER diff --git a/bin/varnishd/storage/storage_malloc.c b/bin/varnishd/storage/storage_malloc.c index ce6b0c2..d7d4561 100644 --- a/bin/varnishd/storage/storage_malloc.c +++ b/bin/varnishd/storage/storage_malloc.c @@ -36,6 +36,7 @@ #include "cache/cache.h" #include "storage/storage.h" +#include "storage/storage_simple.h" #include "vnum.h" @@ -251,7 +252,8 @@ const struct stevedore sma_stevedore = { .alloc = sma_alloc, .free = sma_free, .trim = sma_trim, - .methods = &default_oc_methods, + .allocobj = SML_allocobj, + .methods = &SML_methods, .var_free_space = sma_free_space, .var_used_space = sma_used_space, }; diff --git a/bin/varnishd/storage/storage_persistent.c b/bin/varnishd/storage/storage_persistent.c index b87fece..a71f150 100644 --- a/bin/varnishd/storage/storage_persistent.c +++ b/bin/varnishd/storage/storage_persistent.c @@ -44,6 +44,7 @@ #include "cache/cache.h" #include "storage/storage.h" +#include "storage/storage_simple.h" #include "hash/hash_slinger.h" #include "vcli.h" @@ -53,6 +54,8 @@ #include "storage/storage_persistent.h" +static struct storeobj_methods smp_oc_realmethods; + /*--------------------------------------------------------------------*/ /* @@ -526,7 +529,7 @@ smp_allocobj(const struct stevedore *stv, struct objcore *oc, unsigned wsl) assert(st->space >= ltot); - o = STV_MkObject(stv, oc, st->ptr); + o = SML_MkObject(stv, oc, st->ptr); AN(oc->stobj->stevedore); assert(oc->stobj->stevedore == stv); CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); @@ -592,7 +595,7 @@ const struct stevedore smp_stevedore = { .signal_close = smp_signal_close, .baninfo = smp_baninfo, .banexport = smp_banexport, - .methods = &smp_oc_methods, + .methods = &smp_oc_realmethods, }; /*-------------------------------------------------------------------- @@ -682,6 +685,11 @@ void SMP_Init(void) { CLI_AddFuncs(debug_cmds); + smp_oc_realmethods = SML_methods; + smp_oc_realmethods.sml_getobj = smp_oc_methods.sml_getobj; + smp_oc_realmethods.objupdatemeta = smp_oc_methods.objupdatemeta; + smp_oc_realmethods.objfree = smp_oc_methods.objfree; + smp_oc_realmethods.objgetlru = smp_oc_methods.objgetlru; } /*-------------------------------------------------------------------- diff --git a/bin/varnishd/storage/storage_persistent_silo.c b/bin/varnishd/storage/storage_persistent_silo.c index ab604d8..8b370c6 100644 --- a/bin/varnishd/storage/storage_persistent_silo.c +++ b/bin/varnishd/storage/storage_persistent_silo.c @@ -40,6 +40,7 @@ #include "cache/cache.h" #include "storage/storage.h" +#include "storage/storage_simple.h" #include "hash/hash_slinger.h" #include "vsha256.h" @@ -387,7 +388,7 @@ smp_loaded_st(const struct smp_sc *sc, const struct smp_seg *sg, */ static struct object * -smp_oc_getobj(struct worker *wrk, struct objcore *oc) +smp_oc_sml_getobj(struct worker *wrk, struct objcore *oc) { struct object *o; struct smp_seg *sg; @@ -401,7 +402,7 @@ smp_oc_getobj(struct worker *wrk, struct objcore *oc) AN(oc->stobj->stevedore); /* Some calls are direct, but they should match anyway */ - assert(oc->stobj->stevedore->methods->getobj == smp_oc_getobj); + assert(oc->stobj->stevedore->methods->sml_getobj == smp_oc_sml_getobj); CAST_OBJ_NOTNULL(sg, oc->stobj->priv, SMP_SEG_MAGIC); so = smp_find_so(sg, oc->stobj->priv2); @@ -455,7 +456,7 @@ smp_oc_getobj(struct worker *wrk, struct objcore *oc) } static void -smp_oc_updatemeta(struct worker *wrk, struct objcore *oc) +smp_oc_objupdatemeta(struct worker *wrk, struct objcore *oc) { struct object *o; struct smp_seg *sg; @@ -463,7 +464,7 @@ smp_oc_updatemeta(struct worker *wrk, struct objcore *oc) CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); - o = smp_oc_getobj(wrk, oc); + o = smp_oc_sml_getobj(wrk, oc); AN(o); CAST_OBJ_NOTNULL(sg, oc->stobj->priv, SMP_SEG_MAGIC); @@ -482,8 +483,8 @@ smp_oc_updatemeta(struct worker *wrk, struct objcore *oc) } } -static void __match_proto__(freeobj_f) -smp_oc_freeobj(struct worker *wrk, struct objcore *oc) +static void __match_proto__(objfree_f) +smp_oc_objfree(struct worker *wrk, struct objcore *oc) { struct smp_seg *sg; struct smp_object *so; @@ -516,8 +517,8 @@ smp_oc_freeobj(struct worker *wrk, struct objcore *oc) * Find the per-segment lru list for this object */ -static struct lru * __match_proto__(getlru_f) -smp_oc_getlru(const struct objcore *oc) +static struct lru * __match_proto__(objgetlru_f) +smp_oc_objgetlru(const struct objcore *oc) { struct smp_seg *sg; @@ -526,10 +527,10 @@ smp_oc_getlru(const struct objcore *oc) } const struct storeobj_methods smp_oc_methods = { - .getobj = smp_oc_getobj, - .updatemeta = smp_oc_updatemeta, - .freeobj = smp_oc_freeobj, - .getlru = smp_oc_getlru, + .sml_getobj = smp_oc_sml_getobj, + .objupdatemeta = smp_oc_objupdatemeta, + .objfree = smp_oc_objfree, + .objgetlru = smp_oc_objgetlru, }; /*--------------------------------------------------------------------*/ diff --git a/bin/varnishd/storage/storage_simple.c b/bin/varnishd/storage/storage_simple.c index 141b413..b8eedec 100644 --- a/bin/varnishd/storage/storage_simple.c +++ b/bin/varnishd/storage/storage_simple.c @@ -33,27 +33,92 @@ #include #include "cache/cache.h" +#include "hash/hash_slinger.h" #include "storage/storage.h" +#include "storage/storage_simple.h" + +/*-------------------------------------------------------------------- + * This function is called by stevedores ->allocobj() method, which + * very often will be SML_allocobj() below, to convert a slab + * of storage into object which the stevedore can then register in its + * internal state, before returning it to STV_NewObject(). + * As you probably guessed: All this for persistence. + */ + +struct object * +SML_MkObject(const struct stevedore *stv, struct objcore *oc, void *ptr) +{ + struct object *o; + + CHECK_OBJ_NOTNULL(stv, STEVEDORE_MAGIC); + CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); + + assert(PAOK(ptr)); + + o = ptr; + INIT_OBJ(o, OBJECT_MAGIC); + + VTAILQ_INIT(&o->list); + + oc->stobj->magic = STOREOBJ_MAGIC; + oc->stobj->stevedore = stv; + AN(stv->methods); + oc->stobj->priv = o; + return (o); +} + +/*-------------------------------------------------------------------- + * This is the default ->allocobj() which all stevedores who do not + * implement persistent storage can rely on. + */ + +int +SML_allocobj(const struct stevedore *stv, struct objcore *oc, + unsigned wsl) +{ + struct object *o; + struct storage *st; + unsigned ltot; + + CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); + ltot = sizeof(struct object) + PRNDUP(wsl); + st = stv->alloc(stv, ltot); + if (st == NULL) + return (0); + if (st->space < ltot) { + stv->free(st); + return (0); + } + o = SML_MkObject(stv, oc, st->ptr); + CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); + st->len = sizeof(*o); + o->objstore = st; + return (1); +} /*--------------------------------------------------------------------- */ -static struct object * __match_proto__(getobj_f) -default_oc_getobj(struct worker *wrk, struct objcore *oc) +static struct object * +getobj(struct worker *wrk, struct objcore *oc) { + const struct storeobj_methods *m; struct object *o; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); + m = oc->stobj->stevedore->methods; + if (m->sml_getobj != NULL) + return (m->sml_getobj(wrk, oc)); if (oc->stobj->priv == NULL) return (NULL); CAST_OBJ_NOTNULL(o, oc->stobj->priv, OBJECT_MAGIC); return (o); } -static void __match_proto__(freeobj_f) -default_oc_freeobj(struct worker *wrk, struct objcore *oc) +static void __match_proto__(objfree_f) +sml_objfree(struct worker *wrk, struct objcore *oc) { struct object *o; @@ -71,8 +136,8 @@ default_oc_freeobj(struct worker *wrk, struct objcore *oc) wrk->stats->n_object--; } -static struct lru * __match_proto__(getlru_f) -default_oc_getlru(const struct objcore *oc) +static struct lru * __match_proto__(objgetlru_f) +sml_objgetlru(const struct objcore *oc) { const struct stevedore *stv; @@ -81,8 +146,363 @@ default_oc_getlru(const struct objcore *oc) return (stv->lru); } -const struct storeobj_methods default_oc_methods = { - .getobj = default_oc_getobj, - .freeobj = default_oc_freeobj, - .getlru = default_oc_getlru, +static int __match_proto__(objiterate_f) +sml_iterator(struct worker *wrk, struct objcore *oc, + void *priv, objiterate_f *func) +{ + struct busyobj *bo; + struct object *obj; + struct storage *st; + struct storage *checkpoint = NULL; + ssize_t checkpoint_len = 0; + ssize_t len = 0; + int ret = 0; + ssize_t ol; + ssize_t nl; + ssize_t sl; + void *p; + ssize_t l; + + obj = getobj(wrk, oc); + CHECK_OBJ_NOTNULL(obj, OBJECT_MAGIC); + + bo = HSH_RefBusy(oc); + + if (bo == NULL) { + VTAILQ_FOREACH(st, &obj->list, list) + if (func(priv, 0, st->ptr, st->len)) + return (-1); + return (0); + } + + p = NULL; + l = 0; + + while (1) { + ol = len; + nl = VBO_waitlen(wrk, bo, ol); + if (bo->state == BOS_FAILED) { + ret = -1; + break; + } + if (nl == ol) { + if (bo->state == BOS_FINISHED) + break; + continue; + } + Lck_Lock(&bo->mtx); + AZ(VTAILQ_EMPTY(&obj->list)); + if (checkpoint == NULL) { + st = VTAILQ_FIRST(&obj->list); + sl = 0; + } else { + st = checkpoint; + sl = checkpoint_len; + ol -= checkpoint_len; + } + while (st != NULL) { + if (st->len > ol) { + p = st->ptr + ol; + l = st->len - ol; + len += l; + break; + } + ol -= st->len; + assert(ol >= 0); + nl -= st->len; + assert(nl > 0); + sl += st->len; + st = VTAILQ_NEXT(st, list); + if (VTAILQ_NEXT(st, list) != NULL) { + checkpoint = st; + checkpoint_len = sl; + } + } + CHECK_OBJ_NOTNULL(obj, OBJECT_MAGIC); + CHECK_OBJ_NOTNULL(st, STORAGE_MAGIC); + st = VTAILQ_NEXT(st, list); + if (st != NULL && st->len == 0) + st = NULL; + Lck_Unlock(&bo->mtx); + assert(l > 0 || bo->state == BOS_FINISHED); + if (func(priv, st != NULL ? 0 : 1, p, l)) { + ret = -1; + break; + } + } + if (oc->flags & OC_F_PASS) + bo->abandon = 1; + VBO_DerefBusyObj(wrk, &bo); + return (ret); +} + +/*-------------------------------------------------------------------- + */ + +static struct storage * +objallocwithnuke(struct worker *wrk, const struct stevedore *stv, size_t size) +{ + struct storage *st = NULL; + unsigned fail; + + CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); + CHECK_OBJ_NOTNULL(stv, STEVEDORE_MAGIC); + + if (size > cache_param->fetch_maxchunksize) + size = cache_param->fetch_maxchunksize; + + assert(size <= UINT_MAX); /* field limit in struct storage */ + + for (fail = 0; fail <= cache_param->nuke_limit; fail++) { + /* try to allocate from it */ + AN(stv->alloc); + st = STV_alloc(stv, size); + if (st != NULL) + break; + + /* no luck; try to free some space and keep trying */ + if (fail < cache_param->nuke_limit && + EXP_NukeOne(wrk, stv->lru) == -1) + break; + } + CHECK_OBJ_ORNULL(st, STORAGE_MAGIC); + return (st); +} + +static int __match_proto__(objgetspace_f) +sml_getspace(struct worker *wrk, struct objcore *oc, ssize_t *sz, + uint8_t **ptr) +{ + struct object *o; + struct storage *st; + + CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); + AN(sz); + AN(ptr); + assert(*sz > 0); + + o = getobj(wrk, oc); + CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); + + st = VTAILQ_LAST(&o->list, storagehead); + if (st != NULL && st->len < st->space) { + *sz = st->space - st->len; + *ptr = st->ptr + st->len; + assert (*sz > 0); + return (1); + } + + st = objallocwithnuke(wrk, oc->stobj->stevedore, *sz); + if (st == NULL) + return (0); + + if (oc->busyobj != NULL) { + CHECK_OBJ_NOTNULL(oc->busyobj, BUSYOBJ_MAGIC); + Lck_Lock(&oc->busyobj->mtx); + VTAILQ_INSERT_TAIL(&o->list, st, list); + Lck_Unlock(&oc->busyobj->mtx); + } else { + AN(oc->flags & (OC_F_PRIVATE)); + VTAILQ_INSERT_TAIL(&o->list, st, list); + } + *sz = st->space - st->len; + assert (*sz > 0); + *ptr = st->ptr + st->len; + return (1); +} + +static void __match_proto__(objextend_f) +sml_extend(struct worker *wrk, struct objcore *oc, ssize_t l) +{ + struct object *o; + struct storage *st; + + CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); + assert(l > 0); + + o = getobj(wrk, oc); + CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); + st = VTAILQ_LAST(&o->list, storagehead); + CHECK_OBJ_NOTNULL(st, STORAGE_MAGIC); + assert(st->len + l <= st->space); + st->len += l; + o->len += l; +} + +static uint64_t __match_proto__(objgetlen_f) +sml_getlen(struct worker *wrk, struct objcore *oc) +{ + struct object *o; + + CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); + + o = getobj(wrk, oc); + CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); + return (o->len); +} + +static void __match_proto__(objtrimstore_f) +sml_trimstore(struct worker *wrk, struct objcore *oc) +{ + const struct stevedore *stv; + struct storage *st; + struct object *o; + + CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); + + stv = oc->stobj->stevedore; + CHECK_OBJ_NOTNULL(stv, STEVEDORE_MAGIC); + o = getobj(wrk, oc); + CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); + st = VTAILQ_LAST(&o->list, storagehead); + if (st == NULL) + return; + if (st->len == 0) { + VTAILQ_REMOVE(&o->list, st, list); + STV_free(stv, st); + } else if (st->len < st->space) { + STV_trim(stv, st, st->len, 1); + } +} + +static void __match_proto__(objslim_f) +sml_slim(struct worker *wrk, struct objcore *oc) +{ + const struct stevedore *stv; + struct object *o; + struct storage *st, *stn; + + CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); + + stv = oc->stobj->stevedore; + CHECK_OBJ_NOTNULL(stv, STEVEDORE_MAGIC); + o = getobj(wrk, oc); + CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); + + if (o->esidata != NULL) { + STV_free(stv, o->esidata); + o->esidata = NULL; + } + VTAILQ_FOREACH_SAFE(st, &o->list, list, stn) { + CHECK_OBJ_NOTNULL(st, STORAGE_MAGIC); + VTAILQ_REMOVE(&o->list, st, list); + STV_free(stv, st); + } +} + +static void * __match_proto__(objgetattr_f) +sml_getattr(struct worker *wrk, struct objcore *oc, enum obj_attr attr, + ssize_t *len) +{ + struct object *o; + ssize_t dummy; + + CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); + + if (len == NULL) + len = &dummy; + o = getobj(wrk, oc); + CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); + switch (attr) { + case OA_ESIDATA: + if (o->esidata == NULL) + return (NULL); + *len = o->esidata->len; + return (o->esidata->ptr); + case OA_FLAGS: + *len = sizeof o->oa_flags; + return (o->oa_flags); + case OA_GZIPBITS: + *len = sizeof o->oa_gzipbits; + return (o->oa_gzipbits); + case OA_HEADERS: + *len = 0; // XXX: hack + return (o->oa_http); + case OA_LASTMODIFIED: + *len = sizeof o->oa_lastmodified; + return (o->oa_lastmodified); + case OA_VARY: + *len = 4; // XXX: hack + return (o->oa_vary); + case OA_VXID: + *len = sizeof o->oa_vxid; + return (o->oa_vxid); + default: + break; + } + WRONG("Unsupported OBJ_ATTR"); +} + +static void * __match_proto__(objsetattr_f) +sml_setattr(struct worker *wrk, struct objcore *oc, enum obj_attr attr, + ssize_t len, const void *ptr) +{ + struct object *o; + void *retval = NULL; + struct storage *st; + + CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); + + o = getobj(wrk, oc); + CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); + st = o->objstore; + switch (attr) { + case OA_ESIDATA: + o->esidata = objallocwithnuke(wrk, oc->stobj->stevedore, len); + if (o->esidata == NULL) + return (NULL); + o->esidata->len = len; + retval = o->esidata->ptr; + break; + case OA_FLAGS: + assert(len == sizeof o->oa_flags); + retval = o->oa_flags; + break; + case OA_GZIPBITS: + assert(len == sizeof o->oa_gzipbits); + retval = o->oa_gzipbits; + break; + case OA_HEADERS: + len = PRNDUP(len); + assert(st->len + len <= st->space); + o->oa_http = (void*)(st->ptr + st->len); + st->len += len; + retval = o->oa_http; + break; + case OA_LASTMODIFIED: + assert(len == sizeof o->oa_lastmodified); + retval = o->oa_lastmodified; + break; + case OA_VARY: + len = PRNDUP(len); + assert(st->len + len <= st->space); + o->oa_vary = (void*)(st->ptr + st->len); + st->len += len; + retval = o->oa_vary; + break; + case OA_VXID: + assert(len == sizeof o->oa_vxid); + retval = o->oa_vxid; + break; + default: + WRONG("Unsupported OBJ_ATTR"); + break; + } + if (ptr != NULL) + memcpy(retval, ptr, len); + return (retval); +} + + +const struct storeobj_methods SML_methods = { + .objfree = sml_objfree, + .objgetlru = sml_objgetlru, + .objiterator = sml_iterator, + .objgetspace = sml_getspace, + .objextend = sml_extend, + .objgetlen = sml_getlen, + .objtrimstore = sml_trimstore, + .objslim = sml_slim, + .objgetattr = sml_getattr, + .objsetattr = sml_setattr, }; diff --git a/bin/varnishd/storage/storage_simple.h b/bin/varnishd/storage/storage_simple.h new file mode 100644 index 0000000..b199e7a --- /dev/null +++ b/bin/varnishd/storage/storage_simple.h @@ -0,0 +1,62 @@ +/*- + * Copyright (c) 2006 Verdens Gang AS + * Copyright (c) 2006-2011 Varnish Software AS + * All rights reserved. + * + * Author: Poul-Henning Kamp + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * SML is a set of methods for simple stevedores which just do simple + * memory allocation and leave all the high-level stuff to SML. + * + */ + +/* Object ------------------------------------------------------------*/ + +VTAILQ_HEAD(storagehead, storage); + +struct object { + unsigned magic; +#define OBJECT_MAGIC 0x32851d42 + struct storage *objstore; + + char oa_vxid[4]; + uint8_t *oa_vary; + uint8_t *oa_http; + uint8_t oa_flags[1]; + char oa_gzipbits[32]; + char oa_lastmodified[8]; + + struct storagehead list; + ssize_t len; + + struct storage *esidata; +}; + +extern const struct storeobj_methods SML_methods; + +struct object *SML_MkObject(const struct stevedore *, struct objcore *, + void *ptr); + +storage_allocobj_f SML_allocobj; + diff --git a/bin/varnishd/storage/storage_umem.c b/bin/varnishd/storage/storage_umem.c index eb194aa..aa268ec 100644 --- a/bin/varnishd/storage/storage_umem.c +++ b/bin/varnishd/storage/storage_umem.c @@ -41,6 +41,7 @@ #include "cache/cache.h" #include "storage/storage.h" +#include "storage/storage_simple.h" static size_t smu_max = SIZE_MAX; static MTX smu_mtx; @@ -161,7 +162,8 @@ const struct stevedore smu_stevedore = { .alloc = smu_alloc, .free = smu_free, .trim = smu_trim, - .methods = &default_oc_methods, + .allocobj = SML_allocobj, + .methods = &SML_methods, }; #endif /* HAVE_UMEM_H */ From phk at FreeBSD.org Mon Dec 14 22:40:15 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Mon, 14 Dec 2015 14:40:15 -0800 Subject: [varnishcache/varnish-cache] 15aad3: Move the default objcore->methods into their own f... Message-ID: <566f454fce9f4_22183fdbff7f72c094925@hookshot-fe4-cp1-prd.iad.github.net.mail> Branch: refs/heads/master Home: https://github.com/varnishcache/varnish-cache Commit: 15aad353d94fae4e3108ab2acc335c95f7bd9c0f https://github.com/varnishcache/varnish-cache/commit/15aad353d94fae4e3108ab2acc335c95f7bd9c0f Author: Poul-Henning Kamp Date: 2015-12-14 (Mon, 14 Dec 2015) Changed paths: M bin/varnishd/Makefile.am M bin/varnishd/storage/stevedore.c A bin/varnishd/storage/storage_simple.c Log Message: ----------- Move the default objcore->methods into their own file. These are the methods used by "simple" stevedores, more advanced stevedores can bring their own set. Commit: 2c76f5b2152d714f42c322041d9552d73ef597c9 https://github.com/varnishcache/varnish-cache/commit/2c76f5b2152d714f42c322041d9552d73ef597c9 Author: Poul-Henning Kamp Date: 2015-12-14 (Mon, 14 Dec 2015) Changed paths: M bin/varnishd/Makefile.am M bin/varnishd/cache/cache_obj.c M bin/varnishd/storage/mgt_stevedore.c M bin/varnishd/storage/mgt_storage_persistent.c M bin/varnishd/storage/stevedore.c M bin/varnishd/storage/storage.h M bin/varnishd/storage/storage_file.c M bin/varnishd/storage/storage_malloc.c M bin/varnishd/storage/storage_persistent.c M bin/varnishd/storage/storage_persistent_silo.c M bin/varnishd/storage/storage_simple.c A bin/varnishd/storage/storage_simple.h M bin/varnishd/storage/storage_umem.c Log Message: ----------- Collect all the stuff which implements objects on top of "simple" stevedores and call it "SML". I bet this is going to surprise Martin :-) Compare: https://github.com/varnishcache/varnish-cache/compare/e29448145caf...2c76f5b2152d From phk at FreeBSD.org Tue Dec 15 10:41:09 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 15 Dec 2015 11:41:09 +0100 Subject: [master] 52f4ccf Put the objcore methods into their own .h file. Message-ID: commit 52f4ccfcb7e4d205a2a66d4920f421ee72e51659 Author: Poul-Henning Kamp Date: Tue Dec 15 10:40:25 2015 +0000 Put the objcore methods into their own .h file. This saves a ugly ifdef for mgt code in storage.h diff --git a/bin/varnishd/Makefile.am b/bin/varnishd/Makefile.am index 1f1f110..6bb046c 100644 --- a/bin/varnishd/Makefile.am +++ b/bin/varnishd/Makefile.am @@ -104,6 +104,7 @@ noinst_HEADERS = \ builtin_vcl.h \ cache/cache_ban.h \ cache/cache_esi.h \ + cache/cache_obj.h \ cache/cache_pool.h \ cache/cache_priv.h \ common/heritage.h \ diff --git a/bin/varnishd/cache/cache_obj.c b/bin/varnishd/cache/cache_obj.c index cadd0f1..35e7a2f 100644 --- a/bin/varnishd/cache/cache_obj.c +++ b/bin/varnishd/cache/cache_obj.c @@ -43,11 +43,12 @@ #include #include "cache.h" +#include "cache_obj.h" #include "vend.h" #include "storage/storage.h" #include "hash/hash_slinger.h" -static const struct storeobj_methods * +static const struct obj_methods * obj_getmethods(const struct objcore *oc) { @@ -66,7 +67,7 @@ int ObjIterate(struct worker *wrk, struct objcore *oc, void *priv, objiterate_f *func) { - const struct storeobj_methods *om = obj_getmethods(oc); + const struct obj_methods *om = obj_getmethods(oc); CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); AN(func); @@ -86,7 +87,7 @@ ObjIterate(struct worker *wrk, struct objcore *oc, int ObjGetSpace(struct worker *wrk, struct objcore *oc, ssize_t *sz, uint8_t **ptr) { - const struct storeobj_methods *om = obj_getmethods(oc); + const struct obj_methods *om = obj_getmethods(oc); CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); AN(sz); @@ -107,7 +108,7 @@ ObjGetSpace(struct worker *wrk, struct objcore *oc, ssize_t *sz, uint8_t **ptr) void ObjExtend(struct worker *wrk, struct objcore *oc, ssize_t l) { - const struct storeobj_methods *om = obj_getmethods(oc); + const struct obj_methods *om = obj_getmethods(oc); CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); assert(l > 0); @@ -125,7 +126,7 @@ ObjExtend(struct worker *wrk, struct objcore *oc, ssize_t l) uint64_t ObjGetLen(struct worker *wrk, struct objcore *oc) { - const struct storeobj_methods *om = obj_getmethods(oc); + const struct obj_methods *om = obj_getmethods(oc); CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); @@ -143,7 +144,7 @@ ObjGetLen(struct worker *wrk, struct objcore *oc) void ObjTrimStore(struct worker *wrk, struct objcore *oc) { - const struct storeobj_methods *om = obj_getmethods(oc); + const struct obj_methods *om = obj_getmethods(oc); CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); @@ -162,7 +163,7 @@ ObjTrimStore(struct worker *wrk, struct objcore *oc) void ObjSlim(struct worker *wrk, struct objcore *oc) { - const struct storeobj_methods *om = obj_getmethods(oc); + const struct obj_methods *om = obj_getmethods(oc); CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); @@ -175,7 +176,7 @@ ObjSlim(struct worker *wrk, struct objcore *oc) void ObjUpdateMeta(struct worker *wrk, struct objcore *oc) { - const struct storeobj_methods *m = obj_getmethods(oc); + const struct obj_methods *m = obj_getmethods(oc); CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); @@ -188,7 +189,7 @@ ObjUpdateMeta(struct worker *wrk, struct objcore *oc) void ObjFreeObj(struct worker *wrk, struct objcore *oc) { - const struct storeobj_methods *m = obj_getmethods(oc); + const struct obj_methods *m = obj_getmethods(oc); CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); @@ -202,7 +203,7 @@ ObjFreeObj(struct worker *wrk, struct objcore *oc) struct lru * ObjGetLRU(const struct objcore *oc) { - const struct storeobj_methods *m = obj_getmethods(oc); + const struct obj_methods *m = obj_getmethods(oc); AN(m->objgetlru); return (m->objgetlru(oc)); @@ -218,7 +219,7 @@ void * ObjGetattr(struct worker *wrk, struct objcore *oc, enum obj_attr attr, ssize_t *len) { - const struct storeobj_methods *om = obj_getmethods(oc); + const struct obj_methods *om = obj_getmethods(oc); CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); @@ -237,7 +238,7 @@ void * ObjSetattr(struct worker *wrk, struct objcore *oc, enum obj_attr attr, ssize_t len, const void *ptr) { - const struct storeobj_methods *om = obj_getmethods(oc); + const struct obj_methods *om = obj_getmethods(oc); CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); diff --git a/bin/varnishd/cache/cache_obj.h b/bin/varnishd/cache/cache_obj.h new file mode 100644 index 0000000..3b2a937 --- /dev/null +++ b/bin/varnishd/cache/cache_obj.h @@ -0,0 +1,68 @@ +/*- + * Copyright (c) 2006 Verdens Gang AS + * Copyright (c) 2006-2011 Varnish Software AS + * All rights reserved. + * + * Author: Poul-Henning Kamp + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + */ + +/* Methods on objcore ------------------------------------------------*/ + +typedef void objupdatemeta_f(struct worker *, struct objcore *); +typedef void objfree_f(struct worker *, struct objcore *); +typedef struct lru *objgetlru_f(const struct objcore *); + +/* This method is only used by SML (...to get to persistent) */ +typedef struct object *sml_getobj_f(struct worker *, struct objcore *); + +typedef int objiterator_f(struct worker *, struct objcore *, + void *priv, objiterate_f *func); +typedef int objgetspace_f(struct worker *, struct objcore *, + ssize_t *sz, uint8_t **ptr); +typedef void objextend_f(struct worker *, struct objcore *, ssize_t l); +typedef void objtrimstore_f(struct worker *, struct objcore *); +typedef void objslim_f(struct worker *, struct objcore *); +typedef void *objgetattr_f(struct worker *, struct objcore *, + enum obj_attr attr, ssize_t *len); +typedef void *objsetattr_f(struct worker *, struct objcore *, + enum obj_attr attr, ssize_t len, const void *ptr); +typedef uint64_t objgetlen_f(struct worker *, struct objcore *); + +struct obj_methods { + objfree_f *objfree; + objgetlru_f *objgetlru; + objupdatemeta_f *objupdatemeta; + + sml_getobj_f *sml_getobj; + + objiterator_f *objiterator; + objgetspace_f *objgetspace; + objextend_f *objextend; + objgetlen_f *objgetlen; + objtrimstore_f *objtrimstore; + objslim_f *objslim; + objgetattr_f *objgetattr; + objsetattr_f *objsetattr; +}; diff --git a/bin/varnishd/storage/storage.h b/bin/varnishd/storage/storage.h index a42a9cb..0d0d429 100644 --- a/bin/varnishd/storage/storage.h +++ b/bin/varnishd/storage/storage.h @@ -39,6 +39,7 @@ struct worker; struct lru; struct vsl_log; struct vfp_ctx; +struct obj_methods; /* Storage -----------------------------------------------------------*/ @@ -55,53 +56,6 @@ struct storage { unsigned space; }; -/* Methods on objcore ------------------------------------------------*/ - -#ifdef VARNISH_CACHE_CHILD - -typedef void objupdatemeta_f(struct worker *, struct objcore *oc); -typedef void objfree_f(struct worker *, struct objcore *oc); -typedef struct lru *objgetlru_f(const struct objcore *oc); - -/* This method is only used by SML (...to get to persistent) */ -typedef struct object *sml_getobj_f(struct worker *, struct objcore *oc); - -typedef int objiterator_f(struct worker *, struct objcore *oc, - void *priv, objiterate_f *func); -typedef int objgetspace_f(struct worker *, struct objcore *, - ssize_t *sz, uint8_t **ptr); -typedef void objextend_f(struct worker *, struct objcore *, ssize_t l); -typedef void objtrimstore_f(struct worker *, struct objcore *); -typedef void objslim_f(struct worker *, struct objcore *); -typedef void *objgetattr_f(struct worker *, struct objcore *, - enum obj_attr attr, ssize_t *len); -typedef void *objsetattr_f(struct worker *, struct objcore *, - enum obj_attr attr, ssize_t len, const void *ptr); -typedef uint64_t objgetlen_f(struct worker *, struct objcore *); - -struct storeobj_methods { - objfree_f *objfree; - objgetlru_f *objgetlru; - objupdatemeta_f *objupdatemeta; - - sml_getobj_f *sml_getobj; - - objiterator_f *objiterator; - objgetspace_f *objgetspace; - objextend_f *objextend; - objgetlen_f *objgetlen; - objtrimstore_f *objtrimstore; - objslim_f *objslim; - objgetattr_f *objgetattr; - objsetattr_f *objsetattr; -}; - -#else - -struct storeobj_methods; - -#endif - /* Prototypes --------------------------------------------------------*/ typedef void storage_init_f(struct stevedore *, int ac, char * const *av); @@ -141,7 +95,7 @@ struct stevedore { storage_baninfo_f *baninfo; /* --//-- */ storage_banexport_f *banexport; /* --//-- */ - const struct storeobj_methods + const struct obj_methods *methods; struct lru *lru; diff --git a/bin/varnishd/storage/storage_persistent.c b/bin/varnishd/storage/storage_persistent.c index a71f150..5b9910f 100644 --- a/bin/varnishd/storage/storage_persistent.c +++ b/bin/varnishd/storage/storage_persistent.c @@ -43,6 +43,7 @@ #include #include "cache/cache.h" +#include "cache/cache_obj.h" #include "storage/storage.h" #include "storage/storage_simple.h" @@ -54,7 +55,7 @@ #include "storage/storage_persistent.h" -static struct storeobj_methods smp_oc_realmethods; +static struct obj_methods smp_oc_realmethods; /*--------------------------------------------------------------------*/ diff --git a/bin/varnishd/storage/storage_persistent.h b/bin/varnishd/storage/storage_persistent.h index 3a1d4f2..b20ef02 100644 --- a/bin/varnishd/storage/storage_persistent.h +++ b/bin/varnishd/storage/storage_persistent.h @@ -307,7 +307,7 @@ void smp_new_seg(struct smp_sc *sc); void smp_close_seg(struct smp_sc *sc, struct smp_seg *sg); void smp_init_oc(struct objcore *oc, struct smp_seg *sg, unsigned objidx); void smp_save_segs(struct smp_sc *sc); -extern const struct storeobj_methods smp_oc_methods; +extern const struct obj_methods smp_oc_methods; /* storage_persistent_subr.c */ diff --git a/bin/varnishd/storage/storage_persistent_silo.c b/bin/varnishd/storage/storage_persistent_silo.c index 8b370c6..e8034cd 100644 --- a/bin/varnishd/storage/storage_persistent_silo.c +++ b/bin/varnishd/storage/storage_persistent_silo.c @@ -39,6 +39,7 @@ #include #include "cache/cache.h" +#include "cache/cache_obj.h" #include "storage/storage.h" #include "storage/storage_simple.h" @@ -526,7 +527,7 @@ smp_oc_objgetlru(const struct objcore *oc) return (sg->lru); } -const struct storeobj_methods smp_oc_methods = { +const struct obj_methods smp_oc_methods = { .sml_getobj = smp_oc_sml_getobj, .objupdatemeta = smp_oc_objupdatemeta, .objfree = smp_oc_objfree, diff --git a/bin/varnishd/storage/storage_simple.c b/bin/varnishd/storage/storage_simple.c index b8eedec..11d55dc 100644 --- a/bin/varnishd/storage/storage_simple.c +++ b/bin/varnishd/storage/storage_simple.c @@ -33,6 +33,7 @@ #include #include "cache/cache.h" +#include "cache/cache_obj.h" #include "hash/hash_slinger.h" #include "storage/storage.h" @@ -103,7 +104,7 @@ SML_allocobj(const struct stevedore *stv, struct objcore *oc, static struct object * getobj(struct worker *wrk, struct objcore *oc) { - const struct storeobj_methods *m; + const struct obj_methods *m; struct object *o; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); @@ -494,7 +495,7 @@ sml_setattr(struct worker *wrk, struct objcore *oc, enum obj_attr attr, } -const struct storeobj_methods SML_methods = { +const struct obj_methods SML_methods = { .objfree = sml_objfree, .objgetlru = sml_objgetlru, .objiterator = sml_iterator, diff --git a/bin/varnishd/storage/storage_simple.h b/bin/varnishd/storage/storage_simple.h index b199e7a..ce4a286 100644 --- a/bin/varnishd/storage/storage_simple.h +++ b/bin/varnishd/storage/storage_simple.h @@ -53,7 +53,7 @@ struct object { struct storage *esidata; }; -extern const struct storeobj_methods SML_methods; +extern const struct obj_methods SML_methods; struct object *SML_MkObject(const struct stevedore *, struct objcore *, void *ptr); diff --git a/bin/varnishd/storage/storage_umem.c b/bin/varnishd/storage/storage_umem.c index aa268ec..71919b8 100644 --- a/bin/varnishd/storage/storage_umem.c +++ b/bin/varnishd/storage/storage_umem.c @@ -40,6 +40,7 @@ #include #include "cache/cache.h" +#include "cache/cache_obj.h" #include "storage/storage.h" #include "storage/storage_simple.h" From phk at FreeBSD.org Tue Dec 15 10:45:13 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 15 Dec 2015 02:45:13 -0800 Subject: [varnishcache/varnish-cache] 52f4cc: Put the objcore methods into their own .h file. Message-ID: <566fef398e5b2_6c863f893df252a0147b8@hookshot-fe4-cp1-prd.iad.github.net.mail> Branch: refs/heads/master Home: https://github.com/varnishcache/varnish-cache Commit: 52f4ccfcb7e4d205a2a66d4920f421ee72e51659 https://github.com/varnishcache/varnish-cache/commit/52f4ccfcb7e4d205a2a66d4920f421ee72e51659 Author: Poul-Henning Kamp Date: 2015-12-15 (Tue, 15 Dec 2015) Changed paths: M bin/varnishd/Makefile.am M bin/varnishd/cache/cache_obj.c A bin/varnishd/cache/cache_obj.h M bin/varnishd/storage/storage.h M bin/varnishd/storage/storage_persistent.c M bin/varnishd/storage/storage_persistent.h M bin/varnishd/storage/storage_persistent_silo.c M bin/varnishd/storage/storage_simple.c M bin/varnishd/storage/storage_simple.h M bin/varnishd/storage/storage_umem.c Log Message: ----------- Put the objcore methods into their own .h file. This saves a ugly ifdef for mgt code in storage.h From fgsch at lodoss.net Tue Dec 15 15:46:56 2015 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Tue, 15 Dec 2015 16:46:56 +0100 Subject: [master] 616c1ee Speed up VSB_bcat() Message-ID: commit 616c1ee573e4e1a0b98918acaee75f3d7e681bf9 Author: Federico G. Schwindt Date: Tue Dec 15 15:24:26 2015 +0000 Speed up VSB_bcat() Rather than copying one char at the time extend the buffer as needed and use memcpy. diff --git a/lib/libvarnish/vsb.c b/lib/libvarnish/vsb.c index 92abdf2..ad98c8a 100644 --- a/lib/libvarnish/vsb.c +++ b/lib/libvarnish/vsb.c @@ -278,20 +278,20 @@ VSB_put_byte(struct vsb *s, int c) int VSB_bcat(struct vsb *s, const void *buf, size_t len) { - const char *str = buf; - const char *end = str + len; - assert_VSB_integrity(s); assert_VSB_state(s, 0); if (s->s_error != 0) return (-1); _vsb_indent(s); - for (; str < end; str++) { - VSB_put_byte(s, *str); + if (len > VSB_FREESPACE(s)) { + if (VSB_extend(s, len - VSB_FREESPACE(s)) < 0) + s->s_error = ENOMEM; if (s->s_error != 0) return (-1); } + memcpy(s->s_buf + s->s_len, buf, len); + s->s_len += len; return (0); } From fgsch at lodoss.net Tue Dec 15 15:50:14 2015 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Tue, 15 Dec 2015 07:50:14 -0800 Subject: [varnishcache/varnish-cache] 616c1e: Speed up VSB_bcat() Message-ID: <567036b6335b3_79123f9bcb3fd29c9676f@hookshot-fe5-cp1-prd.iad.github.net.mail> Branch: refs/heads/master Home: https://github.com/varnishcache/varnish-cache Commit: 616c1ee573e4e1a0b98918acaee75f3d7e681bf9 https://github.com/varnishcache/varnish-cache/commit/616c1ee573e4e1a0b98918acaee75f3d7e681bf9 Author: Federico G. Schwindt Date: 2015-12-15 (Tue, 15 Dec 2015) Changed paths: M lib/libvarnish/vsb.c Log Message: ----------- Speed up VSB_bcat() Rather than copying one char at the time extend the buffer as needed and use memcpy. From phk at FreeBSD.org Tue Dec 15 22:20:04 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 15 Dec 2015 23:20:04 +0100 Subject: [master] 8775521 Change allocobj related prototypes Message-ID: commit 877552140e5a2c05983ec8cdd14e2f52a6468b23 Author: Poul-Henning Kamp Date: Tue Dec 15 22:19:49 2015 +0000 Change allocobj related prototypes diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 918d620..195c5f8 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -1040,7 +1040,7 @@ void RFC2616_Weaken_Etag(struct http *hp); void RFC2616_Vary_AE(struct http *hp); /* stevedore.c */ -int STV_NewObject(struct objcore *, struct worker *, +int STV_NewObject(struct worker *, struct objcore *, const char *hint, unsigned len); struct storage *STV_alloc(const struct stevedore *, size_t size); void STV_trim(const struct stevedore *, struct storage *, size_t size, diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c index 38c897d..cc93d97 100644 --- a/bin/varnishd/cache/cache_fetch.c +++ b/bin/varnishd/cache/cache_fetch.c @@ -62,7 +62,7 @@ vbf_allocobj(struct busyobj *bo, unsigned l) bo->storage_hint = NULL; - if (STV_NewObject(bo->fetch_objcore, bo->wrk, storage_hint, l)) + if (STV_NewObject(bo->wrk, bo->fetch_objcore, storage_hint, l)) return (1); if (storage_hint != NULL && !strcmp(storage_hint, TRANSIENT_STORAGE)) @@ -77,7 +77,7 @@ vbf_allocobj(struct busyobj *bo, unsigned l) oc->exp.ttl = cache_param->shortlived; oc->exp.grace = 0.0; oc->exp.keep = 0.0; - return (STV_NewObject(bo->fetch_objcore, bo->wrk, + return (STV_NewObject(bo->wrk, bo->fetch_objcore, TRANSIENT_STORAGE, l)); } diff --git a/bin/varnishd/cache/cache_req_body.c b/bin/varnishd/cache/cache_req_body.c index 92be12c..30089d1 100644 --- a/bin/varnishd/cache/cache_req_body.c +++ b/bin/varnishd/cache/cache_req_body.c @@ -218,7 +218,7 @@ VRB_Cache(struct req *req, ssize_t maxsize) req->body_oc = HSH_Private(req->wrk); AN(req->body_oc); - XXXAN(STV_NewObject(req->body_oc, req->wrk, TRANSIENT_STORAGE, 8)); + XXXAN(STV_NewObject(req->wrk, req->body_oc, TRANSIENT_STORAGE, 8)); vfc->http = req->http; vfc->oc = req->body_oc; diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index a539817..5127f55 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -287,7 +287,7 @@ cnt_synth(struct worker *wrk, struct req *req) req->objcore = HSH_Private(wrk); CHECK_OBJ_NOTNULL(req->objcore, OBJCORE_MAGIC); - if (STV_NewObject(req->objcore, wrk, TRANSIENT_STORAGE, 1024)) { + if (STV_NewObject(wrk, req->objcore, TRANSIENT_STORAGE, 1024)) { szl = VSB_len(synth_body); assert(szl >= 0); } else diff --git a/bin/varnishd/storage/stevedore.c b/bin/varnishd/storage/stevedore.c index 1029dd2..b924c4a 100644 --- a/bin/varnishd/storage/stevedore.c +++ b/bin/varnishd/storage/stevedore.c @@ -138,7 +138,7 @@ STV_alloc(const struct stevedore *stv, size_t size) */ int -STV_NewObject(struct objcore *oc, struct worker *wrk, +STV_NewObject(struct worker *wrk, struct objcore *oc, const char *hint, unsigned wsl) { struct stevedore *stv, *stv0; @@ -150,12 +150,12 @@ STV_NewObject(struct objcore *oc, struct worker *wrk, stv = stv0 = stv_pick_stevedore(wrk->vsl, &hint); AN(stv->allocobj); - j = stv->allocobj(stv, oc, wsl); + j = stv->allocobj(wrk, stv, oc, wsl, 0); if (j == 0 && hint == NULL) { do { stv = stv_pick_stevedore(wrk->vsl, &hint); AN(stv->allocobj); - j = stv->allocobj(stv, oc, wsl); + j = stv->allocobj(wrk, stv, oc, wsl, 0); } while (j == 0 && stv != stv0); } if (j == 0) { @@ -163,7 +163,7 @@ STV_NewObject(struct objcore *oc, struct worker *wrk, for (i = 0; j == 0 && i < cache_param->nuke_limit; i++) { if (EXP_NukeOne(wrk, stv->lru) == -1) break; - j = stv->allocobj(stv, oc, wsl); + j = stv->allocobj(wrk, stv, oc, wsl, 0); } } diff --git a/bin/varnishd/storage/storage.h b/bin/varnishd/storage/storage.h index 0d0d429..297b583 100644 --- a/bin/varnishd/storage/storage.h +++ b/bin/varnishd/storage/storage.h @@ -63,8 +63,8 @@ typedef void storage_open_f(const struct stevedore *); typedef struct storage *storage_alloc_f(const struct stevedore *, size_t size); typedef void storage_trim_f(struct storage *, size_t size, int move_ok); typedef void storage_free_f(struct storage *); -typedef int storage_allocobj_f(const struct stevedore *, struct objcore *, - unsigned ltot); +typedef int storage_allocobj_f(struct worker *, const struct stevedore *, + struct objcore *, unsigned ltot, int really); typedef void storage_close_f(const struct stevedore *); typedef void storage_signal_close_f(const struct stevedore *); typedef int storage_baninfo_f(const struct stevedore *, enum baninfo event, diff --git a/bin/varnishd/storage/storage_persistent.c b/bin/varnishd/storage/storage_persistent.c index 5b9910f..2ec51d3 100644 --- a/bin/varnishd/storage/storage_persistent.c +++ b/bin/varnishd/storage/storage_persistent.c @@ -503,8 +503,9 @@ smp_allocx(const struct stevedore *st, size_t min_size, size_t max_size, * Allocate an object */ -static int -smp_allocobj(const struct stevedore *stv, struct objcore *oc, unsigned wsl) +static int __match_proto__(storage_allocobj_f) +smp_allocobj(struct worker *wrk, const struct stevedore *stv, + struct objcore *oc, unsigned wsl, int really) { struct object *o; struct storage *st; @@ -514,7 +515,9 @@ smp_allocobj(const struct stevedore *stv, struct objcore *oc, unsigned wsl) unsigned objidx; unsigned ltot; + CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); + (void)really; CAST_OBJ_NOTNULL(sc, stv->priv, SMP_SC_MAGIC); /* Don't entertain already dead objects */ diff --git a/bin/varnishd/storage/storage_simple.c b/bin/varnishd/storage/storage_simple.c index 11d55dc..63a1117 100644 --- a/bin/varnishd/storage/storage_simple.c +++ b/bin/varnishd/storage/storage_simple.c @@ -74,15 +74,17 @@ SML_MkObject(const struct stevedore *stv, struct objcore *oc, void *ptr) * implement persistent storage can rely on. */ -int -SML_allocobj(const struct stevedore *stv, struct objcore *oc, - unsigned wsl) +int __match_proto__(storage_allocobj_f) +SML_allocobj(struct worker *wrk, const struct stevedore *stv, + struct objcore *oc, unsigned wsl, int really) { struct object *o; struct storage *st; unsigned ltot; + CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); + (void)really; ltot = sizeof(struct object) + PRNDUP(wsl); st = stv->alloc(stv, ltot); if (st == NULL) From phk at FreeBSD.org Tue Dec 15 22:25:14 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 15 Dec 2015 14:25:14 -0800 Subject: [varnishcache/varnish-cache] 877552: Change allocobj related prototypes Message-ID: <5670934a94600_701a3fa2315472bc10971b@hookshot-fe1-cp1-prd.iad.github.net.mail> Branch: refs/heads/master Home: https://github.com/varnishcache/varnish-cache Commit: 877552140e5a2c05983ec8cdd14e2f52a6468b23 https://github.com/varnishcache/varnish-cache/commit/877552140e5a2c05983ec8cdd14e2f52a6468b23 Author: Poul-Henning Kamp Date: 2015-12-15 (Tue, 15 Dec 2015) Changed paths: M bin/varnishd/cache/cache.h M bin/varnishd/cache/cache_fetch.c M bin/varnishd/cache/cache_req_body.c M bin/varnishd/cache/cache_req_fsm.c M bin/varnishd/storage/stevedore.c M bin/varnishd/storage/storage.h M bin/varnishd/storage/storage_persistent.c M bin/varnishd/storage/storage_simple.c Log Message: ----------- Change allocobj related prototypes From phk at FreeBSD.org Tue Dec 15 22:51:04 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 15 Dec 2015 23:51:04 +0100 Subject: [master] 1808216 Make VSB_bcat() take a ssize_t to be able to assert non-negative lengths. Message-ID: commit 18082164c232735abbff81ec9a24233a23f4cda6 Author: Poul-Henning Kamp Date: Tue Dec 15 22:50:21 2015 +0000 Make VSB_bcat() take a ssize_t to be able to assert non-negative lengths. Spotted by: FlexeLint diff --git a/include/vsb.h b/include/vsb.h index 61b64c0..4b34314 100644 --- a/include/vsb.h +++ b/include/vsb.h @@ -61,7 +61,7 @@ struct vsb *VSB_new(struct vsb *, char *, int, int); #define VSB_new_auto() \ VSB_new(NULL, NULL, 0, VSB_AUTOEXTEND) void VSB_clear(struct vsb *); -int VSB_bcat(struct vsb *, const void *, size_t); +int VSB_bcat(struct vsb *, const void *, ssize_t); int VSB_cat(struct vsb *, const char *); int VSB_printf(struct vsb *, const char *, ...) __v_printflike(2, 3); diff --git a/lib/libvarnish/vsb.c b/lib/libvarnish/vsb.c index ad98c8a..7b9380a 100644 --- a/lib/libvarnish/vsb.c +++ b/lib/libvarnish/vsb.c @@ -276,13 +276,16 @@ VSB_put_byte(struct vsb *s, int c) * Append a byte string to an vsb. */ int -VSB_bcat(struct vsb *s, const void *buf, size_t len) +VSB_bcat(struct vsb *s, const void *buf, ssize_t len) { assert_VSB_integrity(s); assert_VSB_state(s, 0); + assert(len >= 0); if (s->s_error != 0) return (-1); + if (len == 0) + return (0); _vsb_indent(s); if (len > VSB_FREESPACE(s)) { if (VSB_extend(s, len - VSB_FREESPACE(s)) < 0) From phk at FreeBSD.org Tue Dec 15 22:55:14 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 15 Dec 2015 14:55:14 -0800 Subject: [varnishcache/varnish-cache] 180821: Make VSB_bcat() take a ssize_t to be able to asser... Message-ID: <56709a52972e1_57c03fe0613d92b811151@hookshot-fe2-cp1-prd.iad.github.net.mail> Branch: refs/heads/master Home: https://github.com/varnishcache/varnish-cache Commit: 18082164c232735abbff81ec9a24233a23f4cda6 https://github.com/varnishcache/varnish-cache/commit/18082164c232735abbff81ec9a24233a23f4cda6 Author: Poul-Henning Kamp Date: 2015-12-15 (Tue, 15 Dec 2015) Changed paths: M include/vsb.h M lib/libvarnish/vsb.c Log Message: ----------- Make VSB_bcat() take a ssize_t to be able to assert non-negative lengths. Spotted by: FlexeLint From phk at FreeBSD.org Wed Dec 16 00:24:34 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 16 Dec 2015 01:24:34 +0100 Subject: [master] cb7c470 Move LRU Nuking into the stevedores, while preserving the current stevedore selection algorithm exactly. Message-ID: commit cb7c47046e810c703295a66164d761abc2e925a4 Author: Poul-Henning Kamp Date: Wed Dec 16 00:24:02 2015 +0000 Move LRU Nuking into the stevedores, while preserving the current stevedore selection algorithm exactly. diff --git a/bin/varnishd/storage/stevedore.c b/bin/varnishd/storage/stevedore.c index b924c4a..e761f89 100644 --- a/bin/varnishd/storage/stevedore.c +++ b/bin/varnishd/storage/stevedore.c @@ -142,7 +142,7 @@ STV_NewObject(struct worker *wrk, struct objcore *oc, const char *hint, unsigned wsl) { struct stevedore *stv, *stv0; - int i, j; + int j; CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); @@ -158,13 +158,9 @@ STV_NewObject(struct worker *wrk, struct objcore *oc, j = stv->allocobj(wrk, stv, oc, wsl, 0); } while (j == 0 && stv != stv0); } - if (j == 0) { + if (j == 0 && cache_param->nuke_limit > 0) { /* no luck; try to free some space and keep trying */ - for (i = 0; j == 0 && i < cache_param->nuke_limit; i++) { - if (EXP_NukeOne(wrk, stv->lru) == -1) - break; - j = stv->allocobj(wrk, stv, oc, wsl, 0); - } + j = stv->allocobj(wrk, stv, oc, wsl, cache_param->nuke_limit); } if (j == 0) diff --git a/bin/varnishd/storage/storage_persistent.c b/bin/varnishd/storage/storage_persistent.c index 2ec51d3..dd0c66b 100644 --- a/bin/varnishd/storage/storage_persistent.c +++ b/bin/varnishd/storage/storage_persistent.c @@ -517,8 +517,8 @@ smp_allocobj(struct worker *wrk, const struct stevedore *stv, CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); - (void)really; CAST_OBJ_NOTNULL(sc, stv->priv, SMP_SC_MAGIC); + assert(really >= 0); /* Don't entertain already dead objects */ if ((oc->exp.ttl + oc->exp.grace + oc->exp.keep) <= 0.) @@ -527,10 +527,24 @@ smp_allocobj(struct worker *wrk, const struct stevedore *stv, ltot = sizeof(struct object) + PRNDUP(wsl); ltot = IRNUP(sc, ltot); - st = smp_allocx(stv, ltot, ltot, &so, &objidx, &sg); - if (st == NULL) - return (0); + while (1) { + if (really > 0) { + if (EXP_NukeOne(wrk, stv->lru) == -1) + return (0); + really--; + } + st = smp_allocx(stv, ltot, ltot, &so, &objidx, &sg); + if (st != NULL && st->space < ltot) { + stv->free(st); // NOP + st = NULL; + } + if (st != NULL) + break; + if (!really) + return (0); + } + AN(st); assert(st->space >= ltot); o = SML_MkObject(stv, oc, st->ptr); diff --git a/bin/varnishd/storage/storage_simple.c b/bin/varnishd/storage/storage_simple.c index 63a1117..0092d0e 100644 --- a/bin/varnishd/storage/storage_simple.c +++ b/bin/varnishd/storage/storage_simple.c @@ -84,15 +84,25 @@ SML_allocobj(struct worker *wrk, const struct stevedore *stv, CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); - (void)really; + assert(really >= 0); ltot = sizeof(struct object) + PRNDUP(wsl); - st = stv->alloc(stv, ltot); - if (st == NULL) - return (0); - if (st->space < ltot) { - stv->free(st); - return (0); + while (1) { + if (really > 0) { + if (EXP_NukeOne(wrk, stv->lru) == -1) + return (0); + really--; + } + st = stv->alloc(stv, ltot); + if (st != NULL && st->space < ltot) { + stv->free(st); + st = NULL; + } + if (st != NULL) + break; + if (!really) + return (0); } + AN(st); o = SML_MkObject(stv, oc, st->ptr); CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); st->len = sizeof(*o); From phk at FreeBSD.org Wed Dec 16 00:25:13 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Tue, 15 Dec 2015 16:25:13 -0800 Subject: [varnishcache/varnish-cache] cb7c47: Move LRU Nuking into the stevedores, while preserv... Message-ID: <5670af692b0ca_701b3f8a9fe132a05951b@hookshot-fe1-cp1-prd.iad.github.net.mail> Branch: refs/heads/master Home: https://github.com/varnishcache/varnish-cache Commit: cb7c47046e810c703295a66164d761abc2e925a4 https://github.com/varnishcache/varnish-cache/commit/cb7c47046e810c703295a66164d761abc2e925a4 Author: Poul-Henning Kamp Date: 2015-12-16 (Wed, 16 Dec 2015) Changed paths: M bin/varnishd/storage/stevedore.c M bin/varnishd/storage/storage_persistent.c M bin/varnishd/storage/storage_simple.c Log Message: ----------- Move LRU Nuking into the stevedores, while preserving the current stevedore selection algorithm exactly. From phk at FreeBSD.org Wed Dec 16 08:24:31 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 16 Dec 2015 09:24:31 +0100 Subject: [master] ea95f53 STV_{alloc|free|trim}() are only used from SML. Message-ID: commit ea95f53ae78a44f236145ac2bafebd385d49a9d1 Author: Poul-Henning Kamp Date: Wed Dec 16 08:24:03 2015 +0000 STV_{alloc|free|trim}() are only used from SML. diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index 195c5f8..ffdbcbb 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -1042,10 +1042,6 @@ void RFC2616_Vary_AE(struct http *hp); /* stevedore.c */ int STV_NewObject(struct worker *, struct objcore *, const char *hint, unsigned len); -struct storage *STV_alloc(const struct stevedore *, size_t size); -void STV_trim(const struct stevedore *, struct storage *, size_t size, - int move_ok); -void STV_free(const struct stevedore *, struct storage *st); void STV_open(void); void STV_close(void); int STV_BanInfo(enum baninfo event, const uint8_t *ban, unsigned len); diff --git a/bin/varnishd/storage/stevedore.c b/bin/varnishd/storage/stevedore.c index e761f89..fa2d56c 100644 --- a/bin/varnishd/storage/stevedore.c +++ b/bin/varnishd/storage/stevedore.c @@ -101,35 +101,6 @@ stv_pick_stevedore(struct vsl_log *vsl, const char **hint) return (stv); } -/*-------------------------------------------------------------------*/ - -struct storage * -STV_alloc(const struct stevedore *stv, size_t size) -{ - struct storage *st; - - CHECK_OBJ_NOTNULL(stv, STEVEDORE_MAGIC); - - if (size > cache_param->fetch_maxchunksize) - size = cache_param->fetch_maxchunksize; - - assert(size <= UINT_MAX); /* field limit in struct storage */ - - for (;;) { - /* try to allocate from it */ - AN(stv->alloc); - st = stv->alloc(stv, size); - if (st != NULL) - break; - - if (size <= cache_param->fetch_chunksize) - break; - - size >>= 1; - } - CHECK_OBJ_ORNULL(st, STORAGE_MAGIC); - return (st); -} /*------------------------------------------------------------------- * Allocate storage for an object, based on the header information. @@ -175,27 +146,6 @@ STV_NewObject(struct worker *wrk, struct objcore *oc, /*-------------------------------------------------------------------*/ void -STV_trim(const struct stevedore *stv, struct storage *st, size_t size, - int move_ok) -{ - - CHECK_OBJ_NOTNULL(stv, STEVEDORE_MAGIC); - CHECK_OBJ_NOTNULL(st, STORAGE_MAGIC); - if (stv->trim) - stv->trim(st, size, move_ok); -} - -void -STV_free(const struct stevedore *stv, struct storage *st) -{ - - CHECK_OBJ_NOTNULL(stv, STEVEDORE_MAGIC); - CHECK_OBJ_NOTNULL(st, STORAGE_MAGIC); - AN(stv->free); - stv->free(st); -} - -void STV_open(void) { struct stevedore *stv; diff --git a/bin/varnishd/storage/storage.h b/bin/varnishd/storage/storage.h index 297b583..0793b4e 100644 --- a/bin/varnishd/storage/storage.h +++ b/bin/varnishd/storage/storage.h @@ -86,9 +86,9 @@ struct stevedore { unsigned transient; storage_init_f *init; /* called by mgt process */ storage_open_f *open; /* called by cache process */ - storage_alloc_f *alloc; /* --//-- */ - storage_trim_f *trim; /* --//-- */ - storage_free_f *free; /* --//-- */ + storage_alloc_f *alloc; /* --//-- only if SML */ + storage_trim_f *trim; /* --//-- only if SML */ + storage_free_f *free; /* --//-- only if SML */ storage_close_f *close; /* --//-- */ storage_allocobj_f *allocobj; /* --//-- */ storage_signal_close_f *signal_close; /* --//-- */ diff --git a/bin/varnishd/storage/storage_simple.c b/bin/varnishd/storage/storage_simple.c index 0092d0e..e79f86b 100644 --- a/bin/varnishd/storage/storage_simple.c +++ b/bin/varnishd/storage/storage_simple.c @@ -39,6 +39,57 @@ #include "storage/storage.h" #include "storage/storage_simple.h" +/*-------------------------------------------------------------------*/ + +static struct storage * +sml_stv_alloc(const struct stevedore *stv, size_t size) +{ + struct storage *st; + + CHECK_OBJ_NOTNULL(stv, STEVEDORE_MAGIC); + + if (size > cache_param->fetch_maxchunksize) + size = cache_param->fetch_maxchunksize; + + assert(size <= UINT_MAX); /* field limit in struct storage */ + + for (;;) { + /* try to allocate from it */ + AN(stv->alloc); + st = stv->alloc(stv, size); + if (st != NULL) + break; + + if (size <= cache_param->fetch_chunksize) + break; + + size >>= 1; + } + CHECK_OBJ_ORNULL(st, STORAGE_MAGIC); + return (st); +} + +static void +sml_stv_free(const struct stevedore *stv, struct storage *st) +{ + + CHECK_OBJ_NOTNULL(stv, STEVEDORE_MAGIC); + CHECK_OBJ_NOTNULL(st, STORAGE_MAGIC); + AN(stv->free); + stv->free(st); +} + +static void +sml_stv_trim(const struct stevedore *stv, struct storage *st, size_t size, + int move_ok) +{ + + CHECK_OBJ_NOTNULL(stv, STEVEDORE_MAGIC); + CHECK_OBJ_NOTNULL(st, STORAGE_MAGIC); + if (stv->trim) + stv->trim(st, size, move_ok); +} + /*-------------------------------------------------------------------- * This function is called by stevedores ->allocobj() method, which * very often will be SML_allocobj() below, to convert a slab @@ -142,7 +193,7 @@ sml_objfree(struct worker *wrk, struct objcore *oc) CAST_OBJ_NOTNULL(o, oc->stobj->priv, OBJECT_MAGIC); o->magic = 0; - STV_free(oc->stobj->stevedore, o->objstore); + sml_stv_free(oc->stobj->stevedore, o->objstore); memset(oc->stobj, 0, sizeof oc->stobj); @@ -269,7 +320,7 @@ objallocwithnuke(struct worker *wrk, const struct stevedore *stv, size_t size) for (fail = 0; fail <= cache_param->nuke_limit; fail++) { /* try to allocate from it */ AN(stv->alloc); - st = STV_alloc(stv, size); + st = sml_stv_alloc(stv, size); if (st != NULL) break; @@ -372,9 +423,9 @@ sml_trimstore(struct worker *wrk, struct objcore *oc) return; if (st->len == 0) { VTAILQ_REMOVE(&o->list, st, list); - STV_free(stv, st); + sml_stv_free(stv, st); } else if (st->len < st->space) { - STV_trim(stv, st, st->len, 1); + sml_stv_trim(stv, st, st->len, 1); } } @@ -393,13 +444,13 @@ sml_slim(struct worker *wrk, struct objcore *oc) CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); if (o->esidata != NULL) { - STV_free(stv, o->esidata); + sml_stv_free(stv, o->esidata); o->esidata = NULL; } VTAILQ_FOREACH_SAFE(st, &o->list, list, stn) { CHECK_OBJ_NOTNULL(st, STORAGE_MAGIC); VTAILQ_REMOVE(&o->list, st, list); - STV_free(stv, st); + sml_stv_free(stv, st); } } From phk at FreeBSD.org Wed Dec 16 08:25:13 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 16 Dec 2015 00:25:13 -0800 Subject: [varnishcache/varnish-cache] ea95f5: STV_{alloc|free|trim}() are only used from SML. Message-ID: <56711fe985277_12e03f84ff2672bc684b@hookshot-fe4-cp1-prd.iad.github.net.mail> Branch: refs/heads/master Home: https://github.com/varnishcache/varnish-cache Commit: ea95f53ae78a44f236145ac2bafebd385d49a9d1 https://github.com/varnishcache/varnish-cache/commit/ea95f53ae78a44f236145ac2bafebd385d49a9d1 Author: Poul-Henning Kamp Date: 2015-12-16 (Wed, 16 Dec 2015) Changed paths: M bin/varnishd/cache/cache.h M bin/varnishd/storage/stevedore.c M bin/varnishd/storage/storage.h M bin/varnishd/storage/storage_simple.c Log Message: ----------- STV_{alloc|free|trim}() are only used from SML. From phk at FreeBSD.org Wed Dec 16 10:22:17 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 16 Dec 2015 11:22:17 +0100 Subject: [master] 6f6bf9d Move LRU-touching behind a oc->touch method. Message-ID: commit 6f6bf9dbb8ca834855a22d10d169efbd5557e184 Author: Poul-Henning Kamp Date: Wed Dec 16 10:21:25 2015 +0000 Move LRU-touching behind a oc->touch method. This makes it easier for -spersistent to avoid LRU touching diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index ffdbcbb..fe1f37e 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -363,9 +363,6 @@ struct lru { #define LRU_MAGIC 0x3fec7bb0 VTAILQ_HEAD(,objcore) lru_head; struct lock mtx; - unsigned flags; -#define LRU_F_DONTMOVE (1<<1) -#define LRU_F_CONDEMMED (1<<2) unsigned n_objcore; }; @@ -850,6 +847,7 @@ int ObjIterate(struct worker *, struct objcore *, int ObjGetSpace(struct worker *, struct objcore *, ssize_t *sz, uint8_t **ptr); void ObjExtend(struct worker *, struct objcore *, ssize_t l); void ObjTrimStore(struct worker *, struct objcore *); +void ObjTouch(struct worker *wrk, struct objcore *oc, double now); unsigned ObjGetXID(struct worker *, struct objcore *); uint64_t ObjGetLen(struct worker *, struct objcore *oc); void ObjUpdateMeta(struct worker *, struct objcore *); diff --git a/bin/varnishd/cache/cache_expire.c b/bin/varnishd/cache/cache_expire.c index 5c27d07..a01ca0a 100644 --- a/bin/varnishd/cache/cache_expire.c +++ b/bin/varnishd/cache/cache_expire.c @@ -240,13 +240,6 @@ EXP_Touch(struct objcore *oc, double now) lru = ObjGetLRU(oc); CHECK_OBJ_NOTNULL(lru, LRU_MAGIC); - /* - * For -spersistent (and possibly other stevedores, we don't move - * objects on the lru list, since LRU doesn't really help much. - */ - if (lru->flags & LRU_F_DONTMOVE) - return; - if (Lck_Trylock(&lru->mtx)) return; diff --git a/bin/varnishd/cache/cache_obj.c b/bin/varnishd/cache/cache_obj.c index 35e7a2f..ebbb76f 100644 --- a/bin/varnishd/cache/cache_obj.c +++ b/bin/varnishd/cache/cache_obj.c @@ -36,6 +36,7 @@ * ObjSetAttr Set attr now * ObjGetAttr Get attr no * ObjRelease Done with attr ptr + * ObjTouch Object was used */ #include "config.h" @@ -247,6 +248,20 @@ ObjSetattr(struct worker *wrk, struct objcore *oc, enum obj_attr attr, } /*==================================================================== + * ObjTouch() + */ + +void +ObjTouch(struct worker *wrk, struct objcore *oc, double now) +{ + const struct obj_methods *om = obj_getmethods(oc); + + CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); + if (om->objtouch != NULL) + om->objtouch(wrk, oc, now); +} + +/*==================================================================== * Utility functions which work on top of the previous ones */ diff --git a/bin/varnishd/cache/cache_obj.h b/bin/varnishd/cache/cache_obj.h index 3b2a937..c08d75c 100644 --- a/bin/varnishd/cache/cache_obj.h +++ b/bin/varnishd/cache/cache_obj.h @@ -49,6 +49,7 @@ typedef void *objgetattr_f(struct worker *, struct objcore *, typedef void *objsetattr_f(struct worker *, struct objcore *, enum obj_attr attr, ssize_t len, const void *ptr); typedef uint64_t objgetlen_f(struct worker *, struct objcore *); +typedef void objtouch_f(struct worker *, struct objcore *, double now); struct obj_methods { objfree_f *objfree; @@ -65,4 +66,5 @@ struct obj_methods { objslim_f *objslim; objgetattr_f *objgetattr; objsetattr_f *objsetattr; + objtouch_f *objtouch; }; diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c index 5127f55..8279bdd 100644 --- a/bin/varnishd/cache/cache_req_fsm.c +++ b/bin/varnishd/cache/cache_req_fsm.c @@ -126,7 +126,7 @@ cnt_deliver(struct worker *wrk, struct req *req) assert(req->objcore->refcnt > 0); if (req->objcore->exp_flags & OC_EF_EXP) - EXP_Touch(req->objcore, req->t_prev); + ObjTouch(req->wrk, req->objcore, req->t_prev); HTTP_Setup(req->resp, req->ws, req->vsl, SLT_RespMethod); if (HTTP_Decode(req->resp, diff --git a/bin/varnishd/storage/storage_persistent.c b/bin/varnishd/storage/storage_persistent.c index dd0c66b..330f580 100644 --- a/bin/varnishd/storage/storage_persistent.c +++ b/bin/varnishd/storage/storage_persistent.c @@ -708,6 +708,7 @@ SMP_Init(void) smp_oc_realmethods.objupdatemeta = smp_oc_methods.objupdatemeta; smp_oc_realmethods.objfree = smp_oc_methods.objfree; smp_oc_realmethods.objgetlru = smp_oc_methods.objgetlru; + smp_oc_realmethods.objtouch = NULL; } /*-------------------------------------------------------------------- diff --git a/bin/varnishd/storage/storage_persistent_silo.c b/bin/varnishd/storage/storage_persistent_silo.c index e8034cd..90b9fb6 100644 --- a/bin/varnishd/storage/storage_persistent_silo.c +++ b/bin/varnishd/storage/storage_persistent_silo.c @@ -225,7 +225,6 @@ smp_new_seg(struct smp_sc *sc) *sg = tmpsg; sg->lru = LRU_Alloc(); CHECK_OBJ_NOTNULL(sg->lru, LRU_MAGIC); - sg->lru->flags |= LRU_F_DONTMOVE; sg->p.offset = IRNUP(sc, sg->p.offset); sg->p.length -= sg->p.offset - tmpsg.p.offset; diff --git a/bin/varnishd/storage/storage_simple.c b/bin/varnishd/storage/storage_simple.c index e79f86b..168e7ff 100644 --- a/bin/varnishd/storage/storage_simple.c +++ b/bin/varnishd/storage/storage_simple.c @@ -557,6 +557,14 @@ sml_setattr(struct worker *wrk, struct objcore *oc, enum obj_attr attr, return (retval); } +static void __match_proto__(objtouch_f) +sml_touch(struct worker *wrk, struct objcore *oc, double now) +{ + + CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); + CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); + EXP_Touch(oc, now); +} const struct obj_methods SML_methods = { .objfree = sml_objfree, @@ -569,4 +577,5 @@ const struct obj_methods SML_methods = { .objslim = sml_slim, .objgetattr = sml_getattr, .objsetattr = sml_setattr, + .objtouch = sml_touch, }; From phk at FreeBSD.org Wed Dec 16 10:25:13 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 16 Dec 2015 02:25:13 -0800 Subject: [varnishcache/varnish-cache] 6f6bf9: Move LRU-touching behind a oc->touch method. Message-ID: <56713c09a5bea_33813f80658952b888673@hookshot-fe5-cp1-prd.iad.github.net.mail> Branch: refs/heads/master Home: https://github.com/varnishcache/varnish-cache Commit: 6f6bf9dbb8ca834855a22d10d169efbd5557e184 https://github.com/varnishcache/varnish-cache/commit/6f6bf9dbb8ca834855a22d10d169efbd5557e184 Author: Poul-Henning Kamp Date: 2015-12-16 (Wed, 16 Dec 2015) Changed paths: M bin/varnishd/cache/cache.h M bin/varnishd/cache/cache_expire.c M bin/varnishd/cache/cache_obj.c M bin/varnishd/cache/cache_obj.h M bin/varnishd/cache/cache_req_fsm.c M bin/varnishd/storage/storage_persistent.c M bin/varnishd/storage/storage_persistent_silo.c M bin/varnishd/storage/storage_simple.c Log Message: ----------- Move LRU-touching behind a oc->touch method. This makes it easier for -spersistent to avoid LRU touching From phk at FreeBSD.org Wed Dec 16 11:35:48 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 16 Dec 2015 12:35:48 +0100 Subject: [master] fe0382d Integrate EXP_Touch() into sml_touch() Message-ID: commit fe0382d73f68c7aec468e7d1481a85fcee1c3486 Author: Poul-Henning Kamp Date: Wed Dec 16 11:35:27 2015 +0000 Integrate EXP_Touch() into sml_touch() diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index fe1f37e..f9350ec 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -690,7 +690,6 @@ void EXP_Insert(struct worker *wrk, struct objcore *oc); void EXP_Inject(struct worker *wrk, struct objcore *oc, struct lru *lru); void EXP_Rearm(struct objcore *, double now, double ttl, double grace, double keep); -void EXP_Touch(struct objcore *oc, double now); int EXP_NukeOne(struct worker *wrk, struct lru *lru); enum exp_event_e { diff --git a/bin/varnishd/cache/cache_expire.c b/bin/varnishd/cache/cache_expire.c index a01ca0a..119f521 100644 --- a/bin/varnishd/cache/cache_expire.c +++ b/bin/varnishd/cache/cache_expire.c @@ -217,45 +217,6 @@ EXP_Insert(struct worker *wrk, struct objcore *oc) } /*-------------------------------------------------------------------- - * Object was used, move to tail of LRU list. - * - * To avoid the exphdl->mtx becoming a hotspot, we only attempt to move - * objects if they have not been moved recently and if the lock is available. - * This optimization obviously leaves the LRU list imperfectly sorted. - */ - -void -EXP_Touch(struct objcore *oc, double now) -{ - struct lru *lru; - - CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); - - if (oc->flags & OC_F_INCOMPLETE) - return; - - if (now - oc->last_lru < cache_param->lru_interval) - return; - - lru = ObjGetLRU(oc); - CHECK_OBJ_NOTNULL(lru, LRU_MAGIC); - - if (Lck_Trylock(&lru->mtx)) - return; - - AN(oc->exp_flags & OC_EF_EXP); - - if (!(oc->exp_flags & OC_EF_OFFLRU)) { - /* Can only touch it while it's actually on the LRU list */ - VTAILQ_REMOVE(&lru->lru_head, oc, lru_list); - VTAILQ_INSERT_TAIL(&lru->lru_head, oc, lru_list); - VSC_C_main->n_lru_moved++; - } - oc->last_lru = now; - Lck_Unlock(&lru->mtx); -} - -/*-------------------------------------------------------------------- * We have changed one or more of the object timers, tell the exp_thread * */ diff --git a/bin/varnishd/storage/storage_simple.c b/bin/varnishd/storage/storage_simple.c index 168e7ff..6ce07c6 100644 --- a/bin/varnishd/storage/storage_simple.c +++ b/bin/varnishd/storage/storage_simple.c @@ -560,10 +560,40 @@ sml_setattr(struct worker *wrk, struct objcore *oc, enum obj_attr attr, static void __match_proto__(objtouch_f) sml_touch(struct worker *wrk, struct objcore *oc, double now) { + struct lru *lru; CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); - EXP_Touch(oc, now); + + /* + * To avoid the exphdl->mtx becoming a hotspot, we only + * attempt to move objects if they have not been moved + * recently and if the lock is available. This optimization + * obviously leaves the LRU list imperfectly sorted. + */ + + if (oc->flags & OC_F_INCOMPLETE) + return; + + if (now - oc->last_lru < cache_param->lru_interval) + return; + + lru = ObjGetLRU(oc); + CHECK_OBJ_NOTNULL(lru, LRU_MAGIC); + + if (Lck_Trylock(&lru->mtx)) + return; + + AN(oc->exp_flags & OC_EF_EXP); + + if (!(oc->exp_flags & OC_EF_OFFLRU)) { + /* Can only touch it while it's actually on the LRU list */ + VTAILQ_REMOVE(&lru->lru_head, oc, lru_list); + VTAILQ_INSERT_TAIL(&lru->lru_head, oc, lru_list); + VSC_C_main->n_lru_moved++; + } + oc->last_lru = now; + Lck_Unlock(&lru->mtx); } const struct obj_methods SML_methods = { From phk at FreeBSD.org Wed Dec 16 11:40:15 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 16 Dec 2015 03:40:15 -0800 Subject: [varnishcache/varnish-cache] fe0382: Integrate EXP_Touch() into sml_touch() Message-ID: <56714d9f77a5b_13e53f9549dfb2b88969b@hookshot-fe4-cp1-prd.iad.github.net.mail> Branch: refs/heads/master Home: https://github.com/varnishcache/varnish-cache Commit: fe0382d73f68c7aec468e7d1481a85fcee1c3486 https://github.com/varnishcache/varnish-cache/commit/fe0382d73f68c7aec468e7d1481a85fcee1c3486 Author: Poul-Henning Kamp Date: 2015-12-16 (Wed, 16 Dec 2015) Changed paths: M bin/varnishd/cache/cache.h M bin/varnishd/cache/cache_expire.c M bin/varnishd/storage/storage_simple.c Log Message: ----------- Integrate EXP_Touch() into sml_touch() From fgsch at lodoss.net Wed Dec 16 16:32:22 2015 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Wed, 16 Dec 2015 17:32:22 +0100 Subject: [master] 2e84c9b Recognize NetBSD Message-ID: commit 2e84c9bac92e88604491b562b29589d0c600e626 Author: Federico G. Schwindt Date: Wed Dec 16 16:31:17 2015 +0000 Recognize NetBSD diff --git a/autogen.sh b/autogen.sh index 8a13e62..f299ab6 100755 --- a/autogen.sh +++ b/autogen.sh @@ -12,6 +12,9 @@ Darwin) FreeBSD) LIBTOOLIZE=libtoolize ;; +NetBSD) + LIBTOOLIZE=libtoolize + ;; OpenBSD) LIBTOOLIZE=libtoolize ;; From fgsch at lodoss.net Wed Dec 16 16:35:16 2015 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Wed, 16 Dec 2015 08:35:16 -0800 Subject: [varnishcache/varnish-cache] 2e84c9: Recognize NetBSD Message-ID: <567192c478e9f_5d803f8c524bb2c02428d@hookshot-fe2-cp1-prd.iad.github.net.mail> Branch: refs/heads/master Home: https://github.com/varnishcache/varnish-cache Commit: 2e84c9bac92e88604491b562b29589d0c600e626 https://github.com/varnishcache/varnish-cache/commit/2e84c9bac92e88604491b562b29589d0c600e626 Author: Federico G. Schwindt Date: 2015-12-16 (Wed, 16 Dec 2015) Changed paths: M autogen.sh Log Message: ----------- Recognize NetBSD From phk at FreeBSD.org Wed Dec 16 20:44:15 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 16 Dec 2015 21:44:15 +0100 Subject: [master] 26039a7 Don't call up the stack to call ourselves. Message-ID: commit 26039a79517476eee4d3a207175f8e3082d8654f Author: Poul-Henning Kamp Date: Wed Dec 16 20:43:56 2015 +0000 Don't call up the stack to call ourselves. diff --git a/bin/varnishd/storage/storage_simple.c b/bin/varnishd/storage/storage_simple.c index 6ce07c6..6550c0f 100644 --- a/bin/varnishd/storage/storage_simple.c +++ b/bin/varnishd/storage/storage_simple.c @@ -181,6 +181,31 @@ getobj(struct worker *wrk, struct objcore *oc) return (o); } +static void __match_proto__(objslim_f) +sml_slim(struct worker *wrk, struct objcore *oc) +{ + const struct stevedore *stv; + struct object *o; + struct storage *st, *stn; + + CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); + + stv = oc->stobj->stevedore; + CHECK_OBJ_NOTNULL(stv, STEVEDORE_MAGIC); + o = getobj(wrk, oc); + CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); + + if (o->esidata != NULL) { + sml_stv_free(stv, o->esidata); + o->esidata = NULL; + } + VTAILQ_FOREACH_SAFE(st, &o->list, list, stn) { + CHECK_OBJ_NOTNULL(st, STORAGE_MAGIC); + VTAILQ_REMOVE(&o->list, st, list); + sml_stv_free(stv, st); + } +} + static void __match_proto__(objfree_f) sml_objfree(struct worker *wrk, struct objcore *oc) { @@ -189,7 +214,7 @@ sml_objfree(struct worker *wrk, struct objcore *oc) CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); CHECK_OBJ_NOTNULL(oc->stobj, STOREOBJ_MAGIC); - ObjSlim(wrk, oc); + sml_slim(wrk, oc); CAST_OBJ_NOTNULL(o, oc->stobj->priv, OBJECT_MAGIC); o->magic = 0; @@ -429,31 +454,6 @@ sml_trimstore(struct worker *wrk, struct objcore *oc) } } -static void __match_proto__(objslim_f) -sml_slim(struct worker *wrk, struct objcore *oc) -{ - const struct stevedore *stv; - struct object *o; - struct storage *st, *stn; - - CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC); - - stv = oc->stobj->stevedore; - CHECK_OBJ_NOTNULL(stv, STEVEDORE_MAGIC); - o = getobj(wrk, oc); - CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); - - if (o->esidata != NULL) { - sml_stv_free(stv, o->esidata); - o->esidata = NULL; - } - VTAILQ_FOREACH_SAFE(st, &o->list, list, stn) { - CHECK_OBJ_NOTNULL(st, STORAGE_MAGIC); - VTAILQ_REMOVE(&o->list, st, list); - sml_stv_free(stv, st); - } -} - static void * __match_proto__(objgetattr_f) sml_getattr(struct worker *wrk, struct objcore *oc, enum obj_attr attr, ssize_t *len) From phk at FreeBSD.org Wed Dec 16 20:45:14 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 16 Dec 2015 12:45:14 -0800 Subject: [varnishcache/varnish-cache] 26039a: Don't call up the stack to call ourselves. Message-ID: <5671cd5aa9638_6ff53f9b055672c0619b1@hookshot-fe1-cp1-prd.iad.github.net.mail> Branch: refs/heads/master Home: https://github.com/varnishcache/varnish-cache Commit: 26039a79517476eee4d3a207175f8e3082d8654f https://github.com/varnishcache/varnish-cache/commit/26039a79517476eee4d3a207175f8e3082d8654f Author: Poul-Henning Kamp Date: 2015-12-16 (Wed, 16 Dec 2015) Changed paths: M bin/varnishd/storage/storage_simple.c Log Message: ----------- Don't call up the stack to call ourselves. From phk at FreeBSD.org Wed Dec 16 22:37:51 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 16 Dec 2015 23:37:51 +0100 Subject: [master] 1f490ae Remove the list of all mutexes, we have never used it for anything. Message-ID: commit 1f490ae77651e7391d4f6e04e27556a5d0a505b9 Author: Poul-Henning Kamp Date: Wed Dec 16 22:36:51 2015 +0000 Remove the list of all mutexes, we have never used it for anything. diff --git a/bin/varnishd/cache/cache_lck.c b/bin/varnishd/cache/cache_lck.c index c623ab7..f1cea24 100644 --- a/bin/varnishd/cache/cache_lck.c +++ b/bin/varnishd/cache/cache_lck.c @@ -41,25 +41,18 @@ #include "cache.h" -/*The constability of lck depends on platform pthreads implementation */ - struct ilck { unsigned magic; #define ILCK_MAGIC 0x7b86c8a5 - pthread_mutex_t mtx; int held; + pthread_mutex_t mtx; pthread_t owner; - VTAILQ_ENTRY(ilck) list; const char *w; struct VSC_C_lck *stat; }; static pthread_mutexattr_t attr; -static VTAILQ_HEAD(, ilck) ilck_head = VTAILQ_HEAD_INITIALIZER(ilck_head); - -static pthread_mutex_t lck_mtx; - /*--------------------------------------------------------------------*/ static void @@ -226,9 +219,6 @@ Lck__New(struct lock *lck, struct VSC_C_lck *st, const char *w) ilck->stat = st; ilck->stat->creat++; AZ(pthread_mutex_init(&ilck->mtx, &attr)); - AZ(pthread_mutex_lock(&lck_mtx)); - VTAILQ_INSERT_TAIL(&ilck_head, ilck, list); - AZ(pthread_mutex_unlock(&lck_mtx)); lck->priv = ilck; } @@ -240,9 +230,6 @@ Lck_Delete(struct lock *lck) CAST_OBJ_NOTNULL(ilck, lck->priv, ILCK_MAGIC); ilck->stat->destroy++; lck->priv = NULL; - AZ(pthread_mutex_lock(&lck_mtx)); - VTAILQ_REMOVE(&ilck_head, ilck, list); - AZ(pthread_mutex_unlock(&lck_mtx)); AZ(pthread_mutex_destroy(&ilck->mtx)); FREE_OBJ(ilck); } @@ -259,7 +246,6 @@ LCK_Init(void) #if !defined(__APPLE__) && !defined(__MACH__) AZ(pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK)); #endif - AZ(pthread_mutex_init(&lck_mtx, &attr)); #define LOCK(nam) \ lck_##nam = VSM_Alloc(sizeof(struct VSC_C_lck), \ VSC_CLASS, VSC_type_lck, #nam); From phk at FreeBSD.org Wed Dec 16 22:40:14 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 16 Dec 2015 14:40:14 -0800 Subject: [varnishcache/varnish-cache] 1f490a: Remove the list of all mutexes, we have never used... Message-ID: <5671e84e16254_75fa3fb05066d2b81224e6@hookshot-fe5-cp1-prd.iad.github.net.mail> Branch: refs/heads/master Home: https://github.com/varnishcache/varnish-cache Commit: 1f490ae77651e7391d4f6e04e27556a5d0a505b9 https://github.com/varnishcache/varnish-cache/commit/1f490ae77651e7391d4f6e04e27556a5d0a505b9 Author: Poul-Henning Kamp Date: 2015-12-16 (Wed, 16 Dec 2015) Changed paths: M bin/varnishd/cache/cache_lck.c Log Message: ----------- Remove the list of all mutexes, we have never used it for anything. From phk at FreeBSD.org Wed Dec 16 23:26:51 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 17 Dec 2015 00:26:51 +0100 Subject: [master] d549b55 Make it possible to creat LCK classes at runtime. Message-ID: commit d549b55f1bf74357ed62e0192f90118306499cde Author: Poul-Henning Kamp Date: Wed Dec 16 23:04:42 2015 +0000 Make it possible to creat LCK classes at runtime. Use the hash_classic class as proof of concept diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h index f9350ec..4d60624 100644 --- a/bin/varnishd/cache/cache.h +++ b/bin/varnishd/cache/cache.h @@ -827,6 +827,8 @@ int Lck_CondWait(pthread_cond_t *cond, struct lock *lck, double); #define Lck_Trylock(a) Lck__Trylock(a, __func__, __LINE__) #define Lck_AssertHeld(a) Lck__Assert(a, 1) +struct VSC_C_lck *Lck_CreateClass(const char *name); + #define LOCK(nam) extern struct VSC_C_lck *lck_##nam; #include "tbl/locks.h" #undef LOCK diff --git a/bin/varnishd/cache/cache_lck.c b/bin/varnishd/cache/cache_lck.c index f1cea24..b702c2f 100644 --- a/bin/varnishd/cache/cache_lck.c +++ b/bin/varnishd/cache/cache_lck.c @@ -212,6 +212,7 @@ Lck__New(struct lock *lck, struct VSC_C_lck *st, const char *w) struct ilck *ilck; AN(st); + AN(w); AZ(lck->priv); ALLOC_OBJ(ilck, ILCK_MAGIC); AN(ilck); @@ -234,6 +235,13 @@ Lck_Delete(struct lock *lck) FREE_OBJ(ilck); } +struct VSC_C_lck * +Lck_CreateClass(const char *name) +{ + return(VSM_Alloc(sizeof(struct VSC_C_lck), + VSC_CLASS, VSC_type_lck, name)); +} + #define LOCK(nam) struct VSC_C_lck *lck_##nam; #include "tbl/locks.h" #undef LOCK @@ -246,9 +254,7 @@ LCK_Init(void) #if !defined(__APPLE__) && !defined(__MACH__) AZ(pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ERRORCHECK)); #endif -#define LOCK(nam) \ - lck_##nam = VSM_Alloc(sizeof(struct VSC_C_lck), \ - VSC_CLASS, VSC_type_lck, #nam); +#define LOCK(nam) lck_##nam = Lck_CreateClass(#nam); #include "tbl/locks.h" #undef LOCK } diff --git a/bin/varnishd/hash/hash_classic.c b/bin/varnishd/hash/hash_classic.c index ef817ea..29fffd9 100644 --- a/bin/varnishd/hash/hash_classic.c +++ b/bin/varnishd/hash/hash_classic.c @@ -38,6 +38,8 @@ #include "hash/hash_slinger.h" +static struct VSC_C_lck *lck_hcl; + /*--------------------------------------------------------------------*/ struct hcl_hd { @@ -90,6 +92,7 @@ hcl_start(void) { unsigned u; + lck_hcl = Lck_CreateClass("hcl"); hcl_head = calloc(sizeof *hcl_head, hcl_nhash); XXXAN(hcl_head); diff --git a/include/tbl/locks.h b/include/tbl/locks.h index 8fe77fe..16af3ac 100644 --- a/include/tbl/locks.h +++ b/include/tbl/locks.h @@ -35,7 +35,6 @@ LOCK(busyobj) LOCK(cli) LOCK(exp) LOCK(hcb) -LOCK(hcl) LOCK(hsl) LOCK(lru) LOCK(mempool) From phk at FreeBSD.org Wed Dec 16 23:26:51 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 17 Dec 2015 00:26:51 +0100 Subject: [master] 6a8a2ca Make the persistent locks dynamic Message-ID: commit 6a8a2ca5a98cb3156283d68513880e3558fbe88c Author: Poul-Henning Kamp Date: Wed Dec 16 23:14:58 2015 +0000 Make the persistent locks dynamic diff --git a/bin/varnishd/storage/storage_persistent.c b/bin/varnishd/storage/storage_persistent.c index 330f580..df00621 100644 --- a/bin/varnishd/storage/storage_persistent.c +++ b/bin/varnishd/storage/storage_persistent.c @@ -57,6 +57,8 @@ static struct obj_methods smp_oc_realmethods; +static struct VSC_C_lck *lck_smp; + /*--------------------------------------------------------------------*/ /* @@ -702,10 +704,11 @@ static struct cli_proto debug_cmds[] = { void SMP_Init(void) { + lck_smp = Lck_CreateClass("smp"); CLI_AddFuncs(debug_cmds); smp_oc_realmethods = SML_methods; smp_oc_realmethods.sml_getobj = smp_oc_methods.sml_getobj; - smp_oc_realmethods.objupdatemeta = smp_oc_methods.objupdatemeta; + smp_oc_realmethods.objupdatemeta = smp_oc_methods.objupdatemeta; smp_oc_realmethods.objfree = smp_oc_methods.objfree; smp_oc_realmethods.objgetlru = smp_oc_methods.objgetlru; smp_oc_realmethods.objtouch = NULL; diff --git a/include/tbl/locks.h b/include/tbl/locks.h index 16af3ac..ccef6d5 100644 --- a/include/tbl/locks.h +++ b/include/tbl/locks.h @@ -43,7 +43,6 @@ LOCK(pipestat) LOCK(sess) LOCK(sma) LOCK(smf) -LOCK(smp) LOCK(vbe) LOCK(vcapace) LOCK(vcl) From phk at FreeBSD.org Wed Dec 16 23:26:51 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 17 Dec 2015 00:26:51 +0100 Subject: [master] 5cc2036 Also make this debugging hash class' locks dynamic Message-ID: commit 5cc2036a5645cd7ddd9f1568d13142611b2cfe79 Author: Poul-Henning Kamp Date: Wed Dec 16 23:26:32 2015 +0000 Also make this debugging hash class' locks dynamic diff --git a/bin/varnishd/hash/hash_simple_list.c b/bin/varnishd/hash/hash_simple_list.c index d99bb89..a946d16 100644 --- a/bin/varnishd/hash/hash_simple_list.c +++ b/bin/varnishd/hash/hash_simple_list.c @@ -35,6 +35,8 @@ #include "hash/hash_slinger.h" +static struct VSC_C_lck *lck_hsl; + /*--------------------------------------------------------------------*/ static VTAILQ_HEAD(, objhead) hsl_head = VTAILQ_HEAD_INITIALIZER(hsl_head); @@ -49,6 +51,7 @@ static void __match_proto__(hash_start_f) hsl_start(void) { + lck_hsl = Lck_CreateClass("hsl"); Lck_New(&hsl_mtx, lck_hsl); } diff --git a/include/tbl/locks.h b/include/tbl/locks.h index ccef6d5..25502e1 100644 --- a/include/tbl/locks.h +++ b/include/tbl/locks.h @@ -35,7 +35,6 @@ LOCK(busyobj) LOCK(cli) LOCK(exp) LOCK(hcb) -LOCK(hsl) LOCK(lru) LOCK(mempool) LOCK(objhdr) From phk at FreeBSD.org Wed Dec 16 23:30:14 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Wed, 16 Dec 2015 15:30:14 -0800 Subject: [varnishcache/varnish-cache] d549b5: Make it possible to creat LCK classes at runtime. Message-ID: <5671f4068c88d_2ab83fa2162912b8100467@hookshot-fe3-cp1-prd.iad.github.net.mail> Branch: refs/heads/master Home: https://github.com/varnishcache/varnish-cache Commit: d549b55f1bf74357ed62e0192f90118306499cde https://github.com/varnishcache/varnish-cache/commit/d549b55f1bf74357ed62e0192f90118306499cde Author: Poul-Henning Kamp Date: 2015-12-16 (Wed, 16 Dec 2015) Changed paths: M bin/varnishd/cache/cache.h M bin/varnishd/cache/cache_lck.c M bin/varnishd/hash/hash_classic.c M include/tbl/locks.h Log Message: ----------- Make it possible to creat LCK classes at runtime. Use the hash_classic class as proof of concept Commit: 6a8a2ca5a98cb3156283d68513880e3558fbe88c https://github.com/varnishcache/varnish-cache/commit/6a8a2ca5a98cb3156283d68513880e3558fbe88c Author: Poul-Henning Kamp Date: 2015-12-16 (Wed, 16 Dec 2015) Changed paths: M bin/varnishd/storage/storage_persistent.c M include/tbl/locks.h Log Message: ----------- Make the persistent locks dynamic Commit: 5cc2036a5645cd7ddd9f1568d13142611b2cfe79 https://github.com/varnishcache/varnish-cache/commit/5cc2036a5645cd7ddd9f1568d13142611b2cfe79 Author: Poul-Henning Kamp Date: 2015-12-16 (Wed, 16 Dec 2015) Changed paths: M bin/varnishd/hash/hash_simple_list.c M include/tbl/locks.h Log Message: ----------- Also make this debugging hash class' locks dynamic Compare: https://github.com/varnishcache/varnish-cache/compare/1f490ae77651...5cc2036a5645 From phk at FreeBSD.org Thu Dec 17 10:48:38 2015 From: phk at FreeBSD.org (Poul-Henning Kamp) Date: Thu, 17 Dec 2015 11:48:38 +0100 Subject: [master] 5060748 Make the sma and smf locks dynamic. Message-ID: commit 506074885f5acfa4f3f151814729d32f11f8214a Author: Poul-Henning Kamp Date: Thu Dec 17 10:48:24 2015 +0000 Make the sma and smf locks dynamic. diff --git a/bin/varnishd/storage/storage_file.c b/bin/varnishd/storage/storage_file.c index c1d7992..9df6d9f 100644 --- a/bin/varnishd/storage/storage_file.c +++ b/bin/varnishd/storage/storage_file.c @@ -63,6 +63,8 @@ */ #define NBUCKET (128 / 4 + 1) +static struct VSC_C_lck *lck_smf; + /*--------------------------------------------------------------------*/ VTAILQ_HEAD(smfhead, smf); @@ -420,6 +422,9 @@ smf_open(const struct stevedore *st) off_t fail = 1 << 30; /* XXX: where is OFF_T_MAX ? */ off_t sum = 0; + ASSERT_CLI(); + if (lck_smf == NULL) + lck_smf = Lck_CreateClass("smf"); CAST_OBJ_NOTNULL(sc, st->priv, SMF_SC_MAGIC); sc->stats = VSM_Alloc(sizeof *sc->stats, VSC_CLASS, VSC_type_smf, st->ident); diff --git a/bin/varnishd/storage/storage_malloc.c b/bin/varnishd/storage/storage_malloc.c index d7d4561..8f085f7 100644 --- a/bin/varnishd/storage/storage_malloc.c +++ b/bin/varnishd/storage/storage_malloc.c @@ -57,6 +57,8 @@ struct sma { struct sma_sc *sc; }; +static struct VSC_C_lck *lck_sma; + static struct storage * sma_alloc(const struct stevedore *st, size_t size) { @@ -235,6 +237,9 @@ sma_open(const struct stevedore *st) { struct sma_sc *sma_sc; + ASSERT_CLI(); + if (lck_sma == NULL) + lck_sma = Lck_CreateClass("sma"); CAST_OBJ_NOTNULL(sma_sc, st->priv, SMA_SC_MAGIC); Lck_New(&sma_sc->sma_mtx, lck_sma); sma_sc->stats = VSM_Alloc(sizeof *sma_sc->stats, diff --git a/include/tbl/locks.h b/include/tbl/locks.h index 25502e1..8d99eb7 100644 --- a/include/tbl/locks.h +++ b/include/tbl/locks.h @@ -40,8 +40,6 @@ LOCK(mempool) LOCK(objhdr) LOCK(pipestat) LOCK(sess) -LOCK(sma) -LOCK(smf) LOCK(vbe) LOCK(vcapace) LOCK(vcl) From fgsch at lodoss.net Fri Dec 18 14:44:27 2015 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Fri, 18 Dec 2015 15:44:27 +0100 Subject: [master] 390c19e Polish Message-ID: commit 390c19ebde531ff3a890d0e5ea6ae117177999a1 Author: Federico G. Schwindt Date: Fri Dec 18 13:55:49 2015 +0000 Polish diff --git a/lib/libvarnish/vtcp.c b/lib/libvarnish/vtcp.c index 0c6a312..09bf909 100644 --- a/lib/libvarnish/vtcp.c +++ b/lib/libvarnish/vtcp.c @@ -324,10 +324,10 @@ VTCP_close(int *s) void VTCP_set_read_timeout(int s, double seconds) { +#ifdef SO_RCVTIMEO_WORKS struct timeval timeout; timeout.tv_sec = (int)floor(seconds); timeout.tv_usec = (int)(1e6 * (seconds - timeout.tv_sec)); -#ifdef SO_RCVTIMEO_WORKS /* * Solaris bug (present at least in snv_151 and older): If this fails * with EINVAL, the socket is half-closed (SS_CANTSENDMORE) and the @@ -338,6 +338,7 @@ VTCP_set_read_timeout(int s, double seconds) &timeout, sizeof timeout)); #else (void)s; + (void)seconds; #endif } From lkarsten at varnish-software.com Mon Dec 21 12:11:20 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Mon, 21 Dec 2015 13:11:20 +0100 Subject: [4.0] 96ad118 Remove stale redhat packaging files. Message-ID: commit 96ad1189bb8fd6016faf479645db9bba4eb0e627 Author: Lasse Karstensen Date: Fri Nov 27 16:16:12 2015 +0100 Remove stale redhat packaging files. All packaging files for 4.0 and 4.1 now live in the pkg-varnish-cache.git repository. See https://github.com/varnishcache/pkg-varnish-cache/ diff --git a/Makefile.am b/Makefile.am index 7624ec5..f299f77 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,6 +1,6 @@ ACLOCAL_AMFLAGS = -I m4 -SUBDIRS = include lib bin etc doc man redhat +SUBDIRS = include lib bin etc doc man 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 -distcheck-hook: - V="@PACKAGE_VERSION@" ; \ - V="$${V%%-*}" ; \ - if ! grep "^Version: $$V$$" $(top_distdir)/redhat/varnish.spec && \ - [ "@PACKAGE_VERSION@" != "trunk" ]; then \ - echo "$$V" ; \ - echo "redhat/varnish.spec does not have a version number matching the package" ; \ - exit 1 ; \ - fi - distcleancheck_listfiles = \ find . -type f -exec sh -c 'test -f $(srcdir)/$$1 || echo $$1' \ sh '{}' ';' diff --git a/configure.ac b/configure.ac index 0eed0e9..4bd3ad0 100644 --- a/configure.ac +++ b/configure.ac @@ -642,7 +642,6 @@ AC_CONFIG_FILES([ lib/libvmod_std/Makefile lib/libvmod_directors/Makefile man/Makefile - redhat/Makefile varnishapi.pc varnishapi-uninstalled.pc ]) diff --git a/redhat/Makefile.am b/redhat/Makefile.am deleted file mode 100644 index ceac128..0000000 --- a/redhat/Makefile.am +++ /dev/null @@ -1,17 +0,0 @@ -# - -EXTRA_DIST = \ - README.redhat \ - TODO \ - varnish.initrc \ - varnish.logrotate \ - varnish_reload_vcl \ - varnish.spec \ - varnish.sysconfig \ - varnishlog.initrc \ - varnishncsa.initrc \ - varnish.params \ - varnish.service \ - varnishncsa.service \ - varnishlog.service \ - find-provides diff --git a/redhat/README.redhat b/redhat/README.redhat deleted file mode 100644 index bb020cf..0000000 --- a/redhat/README.redhat +++ /dev/null @@ -1,78 +0,0 @@ -GCC -=== -Varnish requires a GCC-compiler compatible with the compiler used to -build varnish with. This means GCC 3.4.6 on a standard RHEL4 system. - -Varnish should work fine with GCC 3.3 and above. - -Building a RPM package from a git checkout -========================================== - -You may build an rpm package direct from a git checkout. Here is an -example on how you may do this: - -git clone git://git.varnish-cache.org/varnish-cache -cd varnish-cache -sed -i "s/^Release: .*/Release: 0.git$(date +%Y%m%d)%{?dist}/" \ - redhat/varnish.spec -./autogen.sh && ./configure -make dist && rpmbuild -ts varnish-trunk.tar.gz - -This builds a source rpm. Then you can, for example on a RHEL5 system, -do something like this: - -rpmbuild --define "dist .el5" --rebuild /path/to/varnish-3.0-0.git20110203.src.rpm - - -Upgrading from 1.x to 2.0 -========================= -There are a few changes in the vcl language from varnish-1.x to 2.0. -Because of varnish' dynamic vcl loading feature, there is no way to -guarantee that the vcl file in use actually exists on disk. Thus, -there is no way to securely automate this process, and one must do the -changes by hand. - -In vcl, the word "insert" has been replaced by "deliver". - -In the vcl declaration of backends, where one earlier used "set -backend", backend parts are now just prefixed with a dot, so the -default localhost configuration will look like this: - -backend default { - .host = "127.0.0.1"; - .port = "80"; -} - -Configuration of addresses and ports -==================================== -In this package, varnish is configured to make the accelerator daemon -listen to port 6081. The administration interface listens to port 6082 -on 127.0.0.1. Addresses and ports can be changed in -/etc/sysconfig/varnish. - -The admin interface can be accessed by standard telnet. - -The default config will try to forward http requests to -localhost:80. You may change this in /etc/varnish/vcl.conf. Please -read the vcl(7) man page for more information on the vcl language. - -To gain actual value from varnish, you may want to move the listening -port to port 80, and your webserver to 8080 or similar. - -Running with jemalloc on ppc or ppc64 on fedora: Edit and recompile -=================================================================== -To get a package through to Fedora, it has to build in Red Hat's Koji -build environment. Their ppc and ppc64 builders run mock on a RHEL -ppc64 kernel. Our use of jemalloc does not work on this kernel, and -the build stays unsuccessful. As ppc64 is not the primary target of -varnish development, it may take some time to get this bug fixed. -To get the package through to Fedora, jemalloc is disabled in the ppc -and ppc64 builds. - -Now, varnish with jemalloc enabled is known to work at least on the -ppc (32bit) kernel in Fedora 9. If you run on ppc, and have a workload -that suits jemalloc better, you might want to change the specfile and -recompile. We would very much like feedback from anyone running -varnish on Fedora's own ppc64 kernel. - - diff --git a/redhat/TODO b/redhat/TODO deleted file mode 100644 index e055efd..0000000 --- a/redhat/TODO +++ /dev/null @@ -1,5 +0,0 @@ -Todolist for the rpm package - -* Perhaps add a default logger, adding Common Logfile Format logs -* Add the package to Fedora Extras - diff --git a/redhat/find-provides b/redhat/find-provides deleted file mode 100755 index 2545e99..0000000 --- a/redhat/find-provides +++ /dev/null @@ -1,20 +0,0 @@ -#! /bin/sh - -# This script is used to inject the Varnish ABI into the provides. - -set -x - -if [ -x /usr/lib/rpm/redhat/find-provides ]; then - /usr/lib/rpm/redhat/find-provides "$@" -elif [ -x /usr/lib/rpm/find-provides ]; then - /usr/lib/rpm/find-provides "$@" -fi - -cd $(dirname $0)/.. - -printf '#include "vcs_version.h"\nVCS_Version\n' \ - | cpp - -Iinclude | sed -e '/^"/!d' -e 's/\"//g' -e 's/^/varnishabi-strict-/' - -printf '#include "vrt.h"\nvarnishabi- VRT_MAJOR_VERSION . VRT_MINOR_VERSION\n' \ - | cpp - -Iinclude \ - | sed -e '/^varnishabi-/!d' -e 's/U//g' -e 's/ //g' diff --git a/redhat/varnish.initrc b/redhat/varnish.initrc deleted file mode 100755 index 082c770..0000000 --- a/redhat/varnish.initrc +++ /dev/null @@ -1,172 +0,0 @@ -#! /bin/sh -# -# varnish Control the Varnish Cache -# -# chkconfig: - 90 10 -# description: Varnish is a high-perfomance HTTP accelerator -# processname: varnishd -# config: /etc/sysconfig/varnish -# pidfile: /var/run/varnishd.pid - -### BEGIN INIT INFO -# Provides: varnish -# Required-Start: $network $local_fs $remote_fs -# Required-Stop: $network $local_fs $remote_fs -# Default-Start: -# Default-Stop: -# Should-Start: $syslog -# Short-Description: start and stop varnishd -# Description: Varnish is a high-perfomance HTTP accelerator -### END INIT INFO - -# Source function library. -. /etc/init.d/functions - -retval=0 -pidfile=/var/run/varnish.pid - -exec="/usr/sbin/varnishd" -reload_exec="/usr/sbin/varnish_reload_vcl" -prog="varnishd" -config="/etc/sysconfig/varnish" -lockfile="/var/lock/subsys/varnish" - -# Include varnish defaults -[ -e /etc/sysconfig/varnish ] && . /etc/sysconfig/varnish - - -start() { - - if [ ! -x $exec ] - then - echo $exec not found - exit 5 - fi - - if [ ! -f $config ] - then - echo $config not found - exit 6 - fi - echo -n "Starting Varnish Cache: " - - # Open files (usually 1024, which is way too small for varnish) - ulimit -n ${NFILES:-131072} - - # Varnish wants to lock shared memory log in memory. - ulimit -l ${MEMLOCK:-82000} - - # Maximum number of threads (default in CentOS is 1024, which - # is often too small for varnish) - ulimit -u ${NPROCS:-unlimited} - - # If defined, set maximum core size. - if [ -n "${DAEMON_COREFILE_LIMIT}" ] - then - ulimit -c ${DAEMON_COREFILE_LIMIT} - fi - - # $DAEMON_OPTS is set in /etc/sysconfig/varnish. At least, one - # has to set up a backend, or /tmp will be used, which is a bad idea. - if [ "$DAEMON_OPTS" = "" ]; then - echo "\$DAEMON_OPTS empty." - echo -n "Please put configuration options in $config" - return 6 - else - # Varnish always gives output on STDOUT - daemon --pidfile $pidfile $exec -P $pidfile "$DAEMON_OPTS" > /dev/null 2>&1 - retval=$? - if [ $retval -eq 0 ] - then - touch $lockfile - echo_success - echo - else - echo_failure - echo - fi - return $retval - fi -} - -stop() { - echo -n "Stopping Varnish Cache: " - killproc -p $pidfile $prog - retval=$? - echo - [ $retval -eq 0 ] && rm -f $lockfile - return $retval -} - -restart() { - stop - start -} - -reload() { - if [ "$RELOAD_VCL" = "1" ] - then - $reload_exec - else - force_reload - fi -} - -force_reload() { - restart -} - -rh_status() { - status -p $pidfile $prog -} - -rh_status_q() { - rh_status >/dev/null 2>&1 -} - -configtest() { - if [ -f "$VARNISH_VCL_CONF" ]; then - $exec -f "$VARNISH_VCL_CONF" -C -n /tmp > /dev/null && echo "Syntax ok" - else - echo "VARNISH_VCL_CONF is unset or does not point to a file" - fi -} - -# See how we were called. -case "$1" in - start) - rh_status_q && exit 0 - $1 - ;; - stop) - rh_status_q || exit 0 - $1 - ;; - restart) - $1 - ;; - reload) - rh_status_q || exit 7 - $1 - ;; - force-reload) - force_reload - ;; - status) - rh_status - ;; - condrestart|try-restart) - rh_status_q || exit 0 - restart - ;; - configtest) - configtest - ;; - *) - echo "Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}" - - exit 2 -esac - -exit $? - diff --git a/redhat/varnish.logrotate b/redhat/varnish.logrotate deleted file mode 100644 index 535614d..0000000 --- a/redhat/varnish.logrotate +++ /dev/null @@ -1,10 +0,0 @@ -/var/log/varnish/*.log { - missingok - notifempty - sharedscripts - delaycompress - postrotate - /bin/kill -HUP `cat /var/run/varnishlog.pid 2>/dev/null` 2> /dev/null || true - /bin/kill -HUP `cat /var/run/varnishncsa.pid 2>/dev/null` 2> /dev/null || true - endscript -} diff --git a/redhat/varnish.params b/redhat/varnish.params deleted file mode 100644 index 27a14dd..0000000 --- a/redhat/varnish.params +++ /dev/null @@ -1,35 +0,0 @@ -# Varnish environment configuration description. This was derived from -# the old style sysconfig/defaults settings - -# Set this to 1 to make systemd reload try to switch vcl without restart. -RELOAD_VCL=1 - -# Main configuration file. You probably want to change it. -VARNISH_VCL_CONF=/etc/varnish/default.vcl - -# Default address and port to bind to. Blank address means all IPv4 -# and IPv6 interfaces, otherwise specify a host name, an IPv4 dotted -# quad, or an IPv6 address in brackets. -# VARNISH_LISTEN_ADDRESS=192.168.1.5 -VARNISH_LISTEN_PORT=6081 - -# Admin interface listen address and port -VARNISH_ADMIN_LISTEN_ADDRESS=127.0.0.1 -VARNISH_ADMIN_LISTEN_PORT=6082 - -# Shared secret file for admin interface -VARNISH_SECRET_FILE=/etc/varnish/secret - -# Backend storage specification, see Storage Types in the varnishd(5) -# man page for details. -VARNISH_STORAGE="file,/var/lib/varnish/varnish_storage.bin,1G" - -# Default TTL used when the backend does not specify one -VARNISH_TTL=120 - -# User and group for the varnishd worker processes -VARNISH_USER=varnish -VARNISH_GROUP=varnish - -# Other options, see the man page varnishd(1) -#DAEMON_OPTS="-p thread_pool_min=5 -p thread_pool_max=500 -p thread_pool_timeout=300" diff --git a/redhat/varnish.service b/redhat/varnish.service deleted file mode 100644 index ed2b572..0000000 --- a/redhat/varnish.service +++ /dev/null @@ -1,44 +0,0 @@ -[Unit] -Description=Varnish Cache, a high-performance HTTP accelerator -After=syslog.target network.target - -[Service] -# If you want to make changes to this file, please copy it to -# /etc/systemd/system/varnish.service and make your changes there. -# This will override the file kept at /lib/systemd/system/varnish.service -# -# Enviroment variables may be found in /etc/varnish/varnish.params -# - -# Maximum number of open files (for ulimit -n) -LimitNOFILE=131072 - -# Locked shared memory (for ulimit -l) -# Default log size is 82MB + header -LimitMEMLOCK=82000 - -# Maximum size of the corefile. -LimitCORE=infinity - -EnvironmentFile=/etc/varnish/varnish.params - -Type=forking -PIDFile=/var/run/varnish.pid -PrivateTmp=true -ExecStartPre=/usr/sbin/varnishd -C -f $VARNISH_VCL_CONF $DAEMON_OPTS -ExecStart=/usr/sbin/varnishd \ - -P /var/run/varnish.pid \ - -f $VARNISH_VCL_CONF \ - -a ${VARNISH_LISTEN_ADDRESS}:${VARNISH_LISTEN_PORT} \ - -T ${VARNISH_ADMIN_LISTEN_ADDRESS}:${VARNISH_ADMIN_LISTEN_PORT} \ - -t $VARNISH_TTL \ - -u $VARNISH_USER \ - -g $VARNISH_GROUP \ - -S $VARNISH_SECRET_FILE \ - -s $VARNISH_STORAGE \ - $DAEMON_OPTS - -ExecReload=/usr/sbin/varnish_reload_vcl - -[Install] -WantedBy=multi-user.target diff --git a/redhat/varnish.spec b/redhat/varnish.spec deleted file mode 100644 index fc9ac28..0000000 --- a/redhat/varnish.spec +++ /dev/null @@ -1,639 +0,0 @@ -%define XXXv_rc rc3 -%define vd_rc %{?v_rc:-%{?v_rc}} -%define _use_internal_dependency_generator 0 -%define __find_provides %{_builddir}/varnish-%{version}%{?v_rc:-%{?v_rc}}/redhat/find-provides -Summary: High-performance HTTP accelerator -Name: varnish -Version: 4.0.3 -#Release: 0.20140328%{?v_rc}%{?dist} -Release: 2%{?v_rc}%{?dist} -License: BSD -Group: System Environment/Daemons -URL: https://www.varnish-cache.org/ -#Source0: http://repo.varnish-cache.org/source/%{name}-%{version}.tar.gz -Source0: %{name}-%{version}%{?vd_rc}.tar.gz -#Source0: %{name}-trunk.tar.gz -BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) -BuildRequires: automake -BuildRequires: autoconf -BuildRequires: jemalloc-devel -BuildRequires: libedit-devel -BuildRequires: libtool -BuildRequires: ncurses-devel -BuildRequires: pcre-devel -BuildRequires: pkgconfig -BuildRequires: python-docutils >= 0.6 -BuildRequires: python-sphinx -Requires: jemalloc -Requires: libedit -Requires: logrotate -Requires: ncurses -Requires: pcre -Requires: varnish-libs = %{version}-%{release} -Requires(pre): shadow-utils -Requires(post): /sbin/chkconfig, /usr/bin/uuidgen -Requires(preun): /sbin/chkconfig -Requires(preun): /sbin/service -%if %{undefined suse_version} -Requires(preun): initscripts -%endif -%if 0%{?fedora} >= 17 || 0%{?rhel} >= 7 -Requires(post): systemd-units -Requires(post): systemd-sysv -Requires(preun): systemd-units -Requires(postun): systemd-units -BuildRequires: systemd-units -%endif - -# Varnish actually needs gcc installed to work. It uses the C compiler -# at runtime to compile the VCL configuration files. This is by design. -Requires: gcc - -%description -This is Varnish Cache, a high-performance HTTP accelerator. -Documentation wiki and additional information about Varnish is -available on the following web site: http://www.varnish-cache.org/ - -%package libs -Summary: Libraries for %{name} -Group: System Environment/Libraries -BuildRequires: ncurses-devel -#Obsoletes: libvarnish1 - -%description libs -Libraries for %{name}. -Varnish Cache is a high-performance HTTP accelerator - -%package libs-devel -Summary: Development files for %{name}-libs -Group: System Environment/Libraries -BuildRequires: ncurses-devel -Requires: varnish-libs = %{version}-%{release} -Requires: python - -%description libs-devel -Development files for %{name}-libs -Varnish Cache is a high-performance HTTP accelerator - -%package docs -Summary: Documentation files for %name -Group: System Environment/Libraries - -%description docs -Documentation files for %name - -#%package libs-static -#Summary: Files for static linking of %{name} library functions -#Group: System Environment/Libraries -#BuildRequires: ncurses-devel -#Requires: varnish-libs-devel = %{version}-%{release} -# -#%description libs-static -#Files for static linking of varnish library functions -#Varnish Cache is a high-performance HTTP accelerator - -%prep -%setup -n varnish-%{version}%{?vd_rc} -#%setup -q -n varnish-trunk - -%build -# No pkgconfig/libpcre.pc in rhel4 -%if 0%{?rhel} == 4 - export PCRE_CFLAGS="`pcre-config --cflags`" - export PCRE_LIBS="`pcre-config --libs`" -%endif - -%if 0%{?rhel} == 6 -export CFLAGS="$CFLAGS -O2 -g -Wp,-D_FORTIFY_SOURCE=0" -%endif - -# 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-rst2html -%else - %configure --disable-static --localstatedir=/var/lib --without-rst2html -%endif - -# We have to remove rpath - not allowed in Fedora -# (This problem only visible on 64 bit arches) -#sed -i 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g; -# s|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' libtool - -make %{?_smp_mflags} V=1 - -%if 0%{?fedora}%{?rhel} != 0 && 0%{?rhel} <= 4 && 0%{?fedora} <= 8 - # Old style daemon function - sed -i 's,--pidfile \$pidfile,,g; - s,status -p \$pidfile,status,g; - s,killproc -p \$pidfile,killproc,g' \ - 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 - -%check -# rhel5 on ppc64 is just too strange -%ifarch ppc64 - %if 0%{?rhel} > 4 - cp bin/varnishd/.libs/varnishd bin/varnishd/lt-varnishd - %endif -%endif - -# The redhat ppc builders seem to have some ulimit problems? -# These tests work on a rhel4 ppc/ppc64 instance outside the builders -%ifarch ppc64 ppc - %if 0%{?rhel} == 4 - rm bin/varnishtest/tests/c00031.vtc - rm bin/varnishtest/tests/r00387.vtc - %endif -%endif - -make check %{?_smp_mflags} LD_LIBRARY_PATH="../../lib/libvarnish/.libs:../../lib/libvarnishcompat/.libs:../../lib/libvarnishapi/.libs:../../lib/libvcc/.libs:../../lib/libvgz/.libs" VERBOSE=1 - -%install -rm -rf %{buildroot} -make install DESTDIR=%{buildroot} INSTALL="install -p" - -# None of these for fedora -find %{buildroot}/%{_libdir}/ -name '*.la' -exec rm -f {} ';' - -# Remove this line to build a devel package with symlinks -#find %{buildroot}/%{_libdir}/ -name '*.so' -type l -exec rm -f {} ';' - -mkdir -p %{buildroot}/var/lib/varnish -mkdir -p %{buildroot}/var/log/varnish -mkdir -p %{buildroot}/var/run/varnish -mkdir -p %{buildroot}%{_sysconfdir}/ld.so.conf.d/ -install -D -m 0644 etc/example.vcl %{buildroot}%{_sysconfdir}/varnish/default.vcl -install -D -m 0644 redhat/varnish.logrotate %{buildroot}%{_sysconfdir}/logrotate.d/varnish - -# systemd support -%if 0%{?fedora} >= 17 || 0%{?rhel} >= 7 -mkdir -p %{buildroot}%{_unitdir} -install -D -m 0644 redhat/varnish.service %{buildroot}%{_unitdir}/varnish.service -install -D -m 0644 redhat/varnish.params %{buildroot}%{_sysconfdir}/varnish/varnish.params -install -D -m 0644 redhat/varnishncsa.service %{buildroot}%{_unitdir}/varnishncsa.service -install -D -m 0644 redhat/varnishlog.service %{buildroot}%{_unitdir}/varnishlog.service -sed -i 's,sysconfig/varnish,varnish/varnish.params,' redhat/varnish_reload_vcl -# default is standard sysvinit -%else -install -D -m 0644 redhat/varnish.sysconfig %{buildroot}%{_sysconfdir}/sysconfig/varnish -install -D -m 0755 redhat/varnish.initrc %{buildroot}%{_initrddir}/varnish -install -D -m 0755 redhat/varnishlog.initrc %{buildroot}%{_initrddir}/varnishlog -install -D -m 0755 redhat/varnishncsa.initrc %{buildroot}%{_initrddir}/varnishncsa -%endif -install -D -m 0755 redhat/varnish_reload_vcl %{buildroot}%{_sbindir}/varnish_reload_vcl - -echo %{_libdir}/varnish > %{buildroot}%{_sysconfdir}/ld.so.conf.d/varnish-%{_arch}.conf - -%clean -rm -rf %{buildroot} - -%files -%defattr(-,root,root,-) -%{_sbindir}/* -%{_bindir}/* -%{_var}/lib/varnish -%{_var}/log/varnish -%{_mandir}/man1/*.1* -%{_mandir}/man3/*.3* -%{_mandir}/man7/*.7* -%doc LICENSE README redhat/README.redhat ChangeLog -%{_docdir}/varnish/ -%dir %{_sysconfdir}/varnish/ -%config(noreplace) %{_sysconfdir}/varnish/default.vcl -%config(noreplace) %{_sysconfdir}/logrotate.d/varnish - -# systemd from fedora 17 and rhel 7 -%if 0%{?fedora} >= 17 || 0%{?rhel} >= 7 -%{_unitdir}/varnish.service -%{_unitdir}/varnishncsa.service -%{_unitdir}/varnishlog.service -%config(noreplace)%{_sysconfdir}/varnish/varnish.params - -# default is standard sysvinit -%else -%config(noreplace) %{_sysconfdir}/sysconfig/varnish -%{_initrddir}/varnish -%{_initrddir}/varnishlog -%{_initrddir}/varnishncsa -%endif - -%files libs -%defattr(-,root,root,-) -%{_libdir}/*.so.* -%{_libdir}/varnish -%doc LICENSE -%config %{_sysconfdir}/ld.so.conf.d/varnish-%{_arch}.conf - -%files libs-devel -%defattr(-,root,root,-) -%{_libdir}/lib*.so -%dir %{_includedir}/varnish -%{_includedir}/varnish/* -%{_libdir}/pkgconfig/varnishapi.pc -/usr/share/varnish -/usr/share/aclocal - -%doc LICENSE - -%files docs -%defattr(-,root,root,-) -%doc LICENSE -%doc doc/sphinx -%doc doc/html -%doc doc/changes*.html - -#%files libs-static -#%{_libdir}/libvarnish.a -#%{_libdir}/libvarnishapi.a -#%{_libdir}/libvarnishcompat.a -#%{_libdir}/libvcc.a -#%doc LICENSE - -%pre -getent group varnish >/dev/null || groupadd -r varnish -getent passwd varnish >/dev/null || \ - useradd -r -g varnish -d /var/lib/varnish -s /sbin/nologin \ - -c "Varnish Cache" varnish -exit 0 - -%post -%if 0%{?fedora} >= 17 || 0%{?rhel} >= 7 -/bin/systemctl daemon-reload >/dev/null 2>&1 || : -%else -/sbin/chkconfig --add varnish -/sbin/chkconfig --add varnishlog -/sbin/chkconfig --add varnishncsa -%endif -test -f /etc/varnish/secret || (uuidgen > /etc/varnish/secret && chmod 0600 /etc/varnish/secret) - -%triggerun -- varnish < 3.0.2-1 -# Save the current service runlevel info -# User must manually run systemd-sysv-convert --apply varnish -# to migrate them to systemd targets -%{_bindir}/systemd-sysv-convert --save varnish >/dev/null 2>&1 ||: - -# If the package is allowed to autostart: -#/bin/systemctl --no-reload enable varnish.service >/dev/null 2>&1 ||: - -# Run these because the SysV package being removed won't do them -/sbin/chkconfig --del varnish >/dev/null 2>&1 || : -#/bin/systemctl try-restart varnish.service >/dev/null 2>&1 || : - -%preun -if [ $1 -lt 1 ]; then - # Package removal, not upgrade - %if 0%{?fedora} >= 17 || 0%{?rhel} >= 7 - /bin/systemctl --no-reload disable varnish.service > /dev/null 2>&1 || : - /bin/systemctl stop varnish.service > /dev/null 2>&1 || : - %else - /sbin/service varnish stop > /dev/null 2>&1 - /sbin/service varnishlog stop > /dev/null 2>&1 - /sbin/service varnishncsa stop > /dev/null 2>%1 - /sbin/chkconfig --del varnish - /sbin/chkconfig --del varnishlog - /sbin/chkconfig --del varnishncsa - %endif -fi - -%post libs -p /sbin/ldconfig - -%postun libs -p /sbin/ldconfig - -%changelog -* Mon Mar 12 2012 Ingvar Hagelund - 3.0.2-2 -- Added PrivateTmp=true to varnishd unit file, closing #782539 -- Fixed comment typos in varnish unit file - -* Tue Mar 06 2012 Ingvar Hagelund - 3.0.2-1 -- New upstream version 3.0.2 -- Removed INSTALL as requested by rpmlint -- Added a ld.so.conf.d fragment file listing libdir/varnish -- Removed redundant doc/html/_sources -- systemd support from fedora 17 -- Stopped using macros for make and install, according to - Fedora's packaging guidelines -- Changes merged from upstream: - - Added suse_version macro - - Added comments on building from a git checkout - - mkpasswd -> uuidgen for fewer dependencies - - Fixed missing quotes around cflags for pcre - - Removed unnecessary 32/64 bit parallell build hack as this is fixed upstream - - Fixed typo in configure call, disable -> without - - Added lib/libvgz/.libs to LD_LIBRARY_PATH in make check - - Added section 3 manpages - - Configure with --without-rst2man --without-rst2html - - changelog entries -- Removed unnecessary patch for system jemalloc, upstream now supports this - -* Fri Feb 10 2012 Petr Pisar - 2.1.5-4 -- Rebuild against PCRE 8.30 - -* Sat Jan 14 2012 Fedora Release Engineering - 2.1.5-3 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild - -* Mon Feb 07 2011 Fedora Release Engineering - 2.1.5-2 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_15_Mass_Rebuild - -* Tue Feb 01 2011 Ingvar Hagelund - 2.1.5-1 -- New upstream release -- New download location -- Moved varnish_reload_vcl to sbin -- Removed patches included upstream -- Use jemalloc as system installed library - -* Mon Nov 15 2010 Ingvar Hagelund - 3.0.0-0.svn20101115r5543 -- Merged some changes from fedora -- Upped general version to 3.0 prerelease in trunk - -* Thu Nov 04 2010 Ingvar Hagelund - 2.1.4-4 -- Added a patch fixing a missing echo in the init script that - masked failure output from the script -- Added a patch from upstream, fixing a problem with Content-Length - headers (upstream r5461, upstream bug #801) -- Added a patch from upstream, adding empty Default-Start and Default-Stop - to initscripts for better lsb compliance -- Added varnish_reload_vcl from trunk -- Synced descriptions from release spec - -* Thu Oct 28 2010 Ingvar Hagelund - 2.1.4-3 -- Fixed missing manpages because of no rst2man in rhel4 and 5 - -* Mon Oct 25 2010 Ingvar Hagelund - 2.1.4-2 -- Removed RHEL6/ppc64 specific patch that has been included upstream - -* Mon Oct 25 2010 Ingvar Hagelund - 2.1.4-1 -- New upstream release -- New URL for source tarball and main website -- Prebuilt html docs now included, use that instead of running sphinx -- Putting sphinx generated doc in a separate subpackage -- Replaced specific include files with a wildcard glob -- Needs python-sphinx and deps to build sphinx documentation - -* Tue Aug 24 2010 Ingvar Hagelund - 2.1.3-2 -- Added a RHEL6/ppc64 specific patch that changes the hard coded - stack size in tests/c00031.vtc - -* Thu Jul 29 2010 Ingvar Hagelund - 2.1.4-0.svn20100824r5117 -- Replaced specific include files with a wildcard glob -- Needs python-sphinx and deps to build sphinx documentation -- Builds html and latex documentation. Put that in a subpackage varnish-docs - -* Thu Jul 29 2010 Ingvar Hagelund - 2.1.3-1 -- New upstream release -- Add a patch for jemalloc on s390 that lacks upstream - -* Wed May 05 2010 Ingvar Hagelund - 2.1.2-1 -- New upstream release -- Remove patches merged upstream - -* Tue Apr 27 2010 Ingvar Hagelund - 2.1.1-1 -- New upstream release -- Added a fix for missing pkgconfig/libpcre.pc on rhel4 -- Added a patch from trunk making the rpm buildable on lowspec - build hosts (like Red Hat's ppc build farm nodes) -- Removed patches that are merged upstream - -* Wed Apr 14 2010 Ingvar Hagelund - 2.1.0-2 -- Added a patch from svn that fixes changes-2.0.6-2.1.0.xml - -* Tue Apr 06 2010 Ingvar Hagelund - 2.1.0-1 -- New upstream release; note: Configuration changes, see the README -- Removed unneeded patches -- CVE-2009-2936: Added a patch from Debian that adds the -S option - to the varnisdh(1) manpage and to the sysconfig defaults, thus - password-protecting the admin interface port (#579536,#579533) -- Generates that password in the post script, requires mkpasswd -- Added a patch from Robert Scheck for explicit linking to libm -- Requires pcre - -* Wed Dec 23 2009 Ingvar Hagelund - 2.0.6-2 -- Added a test that enables jemalloc on ppc if the kernel is - not a rhel5 kernel (as on redhat builders) -- Removed tests c00031.vtc and r00387on rhel4/ppc as they fail - on the Red Hat ppc builders (but works on my rhel4 ppc instance) -- Added a patch that fixes broken changes-2.0.6.html in doc - -* Mon Dec 14 2009 Ingvar Hagelund - 2.0.6-1 -- New upstream release -- Removed patches for libjemalloc, as they are added upstream - -* Mon Nov 09 2009 Ingvar Hagelund - 2.0.5-1 -- New upstream release - -* Thu Aug 13 2009 Ingvar Hagelund - 2.0.4-4 -- Added a sparc specific patch to libjemalloc. - -* Sun Jul 26 2009 Fedora Release Engineering - 2.0.4-3 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild - -* Thu Jun 04 2009 Ingvar Hagelund - 2.0.4-2 -- Added a s390 specific patch to libjemalloc. - -* Fri Mar 27 2009 Ingvar Hagelund - 2.0.4-1 - New upstream release 2.0.4 - -* Wed Feb 25 2009 Fedora Release Engineering - 2.0.3-2 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild - -* Wed Feb 11 2009 Ingvar Hagelund - 2.0.3-1 - New upstream release 2.0.3. A bugfix and feature enhancement release - -* Fri Dec 12 2008 Ingvar Hagelund - 2.0.2-2 - Added a fix for a timeout bug, backported from trunk - -* Mon Nov 10 2008 Ingvar Hagelund - 2.0.2-1 - New upstream release 2.0.2. A bugfix release - -* Sun Nov 02 2008 Ingvar Hagelund - 2.0.1-2 -- Removed the requirement for kernel => 2.6.0. All supported - platforms meets this, and it generates strange errors in EPEL - -* Fri Oct 17 2008 Ingvar Hagelund - 2.0.1-1 -- 2.0.1 released, a bugfix release. New upstream sources -- Package now also available in EPEL - -* Thu Oct 16 2008 Ingvar Hagelund - 2.0-2 -- Readded the debugflag patch. It's so practical -- Added a strange workaround for make check on ppc64 - -* Wed Oct 15 2008 Ingvar Hagelund - 2.0-1 -- 2.0 released. New upstream sources -- Disabled jemalloc on ppc and ppc64. Added a note in README.redhat -- Synced to upstream again. No more patches needed - -* Wed Oct 08 2008 Ingvar Hagelund - 2.0-0.11.rc1 -- 2.0-rc1 released. New upstream sources -- Added a patch for pagesize to match redhat's rhel5 ppc64 koji build boxes -- Added a patch for test a00008, from r3269 -- Removed condrestart in postscript at upgrade. We don't want that - -* Fri Sep 26 2008 Ingvar Hagelund - 2.0-0.10.beta2 -- 2.0-beta2 released. New upstream sources -- Whitespace changes to make rpmlint more happy - -* Fri Sep 12 2008 Ingvar Hagelund - 2.0-0.9.20080912svn3184 -- Added varnisncsa init script (Colin Hill) -- Corrected varnishlog init script (Colin Hill) - -* Tue Sep 09 2008 Ingvar Hagelund - 2.0-0.8.beta1 -- Added a patch from r3171 that fixes an endian bug on ppc and ppc64 -- Added a hack that changes the varnishtest ports for 64bits builds, - so they can run in parallell with 32bits build on same build host - -* Tue Sep 02 2008 Ingvar Hagelund - 2.0-0.7.beta1 -- Added a patch from r3156 and r3157, hiding a legit errno in make check - -* Tue Sep 02 2008 Ingvar Hagelund - 2.0-0.6.beta1 -- Added a commented option for max coresize in the sysconfig script -- Added a comment in README.redhat about upgrading from 1.x to 2.0 - -* Fri Aug 29 2008 Ingvar Hagelund - 2.0-0.5.beta1 -- Bumped version numbers and source url for first beta release \o/ -- Added a missing directory to the libs-devel package (Michael Schwendt) -- Added the LICENSE file to the libs-devel package -- Moved make check to its proper place -- Removed superfluous definition of lockfile in initscripts - -* Wed Aug 27 2008 Ingvar Hagelund - 2.0-0.4.20080827svn3136 -- Fixed up init script for varnishlog too - -* Mon Aug 25 2008 Ingvar Hagelund - 2.0-0.3.20080825svn3125 -- Fixing up init script according to newer Fedora standards -- The build now runs the test suite after compiling -- Requires initscripts -- Change default.vcl from nothing but comments to point to localhost:80, - -* Mon Aug 18 2008 Ingvar Hagelund - 2.0-0.2.tp2 -- Changed source, version and release to match 2.0-tp2 - -* Thu Aug 14 2008 Ingvar Hagelund - 2.0-0.1.20080814svn -- default.vcl has moved -- Added groff to build requirements - -* Tue Feb 19 2008 Fedora Release Engineering - 1.1.2-6 -- Autorebuild for GCC 4.3 - -* Sat Dec 29 2007 Ingvar Hagelund - 1.1.2-5 -- Added missing configuration examples -- Corrected the license to "BSD" - -* Fri Dec 28 2007 Ingvar Hagelund - 1.1.2-4 -- Build for fedora update - -* Fri Dec 28 2007 Ingvar Hagelund - 1.1.2-2 -- Added missing changelog items - -* Thu Dec 20 2007 Stig Sandbeck Mathisen - 1.1.2-1 -- Bumped the version number to 1.1.2. -- Addeed build dependency on libxslt - -* Fri Sep 07 2007 Ingvar Hagelund - 1.1.1-3 -- Added a patch, changeset 1913 from svn trunk. This makes varnish - more stable under specific loads. - -* Thu Sep 06 2007 Ingvar Hagelund - 1.1.1-2 -- Removed autogen call (only diff from relase tarball) - -* Mon Aug 20 2007 Ingvar Hagelund - 1.1.1-1 -- Bumped the version number to 1.1.1. - -* Tue Aug 14 2007 Ingvar Hagelund - 1.1.svn -- Update for 1.1 branch -- Added the devel package for the header files and static library files -- Added a varnish user, and fixed the init script accordingly - -* Thu Jul 05 2007 Dag-Erling Sm?rgrav - 1.1-1 -- Bump Version and Release for 1.1 - -* Mon May 28 2007 Ingvar Hagelund - 1.0.4-3 -- Fixed initrc-script bug only visible on el4 (fixes #107) - -* Sun May 20 2007 Ingvar Hagelund - 1.0.4-2 -- Repack from unchanged 1.0.4 tarball -- Final review request and CVS request for Fedora Extras -- Repack with extra obsoletes for upgrading from older sf.net package - -* Fri May 18 2007 Dag-Erling Sm?rgrav - 1.0.4-1 -- Bump Version and Release for 1.0.4 - -* Wed May 16 2007 Ingvar Hagelund - 1.0.svn-20070517 -- Wrapping up for 1.0.4 -- Changes in sysconfig and init scripts. Syncing with files in - trunk/debian - -* Fri May 11 2007 Ingvar Hagelund - 1.0.svn-20070511 -- Threw latest changes into svn trunk -- Removed the conversion of manpages into utf8. They are all utf8 in trunk - -* Wed May 09 2007 Ingvar Hagelund - 1.0.3-7 -- Simplified the references to the subpackage names -- Added init and logrotate scripts for varnishlog - -* Mon Apr 23 2007 Ingvar Hagelund - 1.0.3-6 -- Removed unnecessary macro lib_name -- Fixed inconsistently use of brackets in macros -- Added a condrestart to the initscript -- All manfiles included, not just the compressed ones -- Removed explicit requirement for ncurses. rpmbuild figures out the - correct deps by itself. -- Added ulimit value to initskript and sysconfig file -- Many thanks to Matthias Saou for valuable input - -* Mon Apr 16 2007 Ingvar Hagelund - 1.0.3-5 -- Added the dist tag -- Exchanged RPM_BUILD_ROOT variable for buildroot macro -- Removed stripping of binaries to create a meaningful debug package -- Removed BuildRoot and URL from subpackages, they are picked from the - main package -- Removed duplication of documentation files in the subpackages -- 'chkconfig --list' removed from post script -- Package now includes _sysconfdir/varnish/ -- Trimmed package information -- Removed static libs and .so-symlinks. They can be added to a -devel package - later if anybody misses them - -* Wed Feb 28 2007 Ingvar Hagelund - 1.0.3-4 -- More small specfile fixes for Fedora Extras Package - Review Request, see bugzilla ticket 230275 -- Removed rpath (only visible on x86_64 and probably ppc64) - -* Tue Feb 27 2007 Ingvar Hagelund - 1.0.3-3 -- Made post-1.0.3 changes into a patch to the upstream tarball -- First Fedora Extras Package Review Request - -* Fri Feb 23 2007 Ingvar Hagelund - 1.0.3-2 -- A few other small changes to make rpmlint happy - -* Thu Feb 22 2007 Ingvar Hagelund - 1.0.3-1 -- New release 1.0.3. See the general ChangeLog -- Splitted the package into varnish, libvarnish1 and - libvarnish1-devel - -* Thu Oct 19 2006 Ingvar Hagelund - 1.0.2-7 -- Added a Vendor tag - -* Thu Oct 19 2006 Ingvar Hagelund - 1.0.2-6 -- Added redhat subdir to svn -- Removed default vcl config file. Used the new upstream variant instead. -- Based build on svn. Running autogen.sh as start of build. Also added - libtool, autoconf and automake to BuildRequires. -- Removed rule to move varnishd to sbin. This is now fixed in upstream -- Changed the sysconfig script to include a lot more nice features. - Most of these were ripped from the Debian package. Updated initscript - to reflect this. - -* Tue Oct 10 2006 Ingvar Hagelund - 1.0.1-3 -- Moved Red Hat specific files to its own subdirectory - -* Tue Sep 26 2006 Ingvar Hagelund - 1.0.1-2 -- Added gcc requirement. -- Changed to an even simpler example vcl in to /etc/varnish (thanks, perbu) -- Added a sysconfig entry - -* Fri Sep 22 2006 Ingvar Hagelund - 1.0.1-1 -- Initial build. diff --git a/redhat/varnish.sysconfig b/redhat/varnish.sysconfig deleted file mode 100644 index 6aa2354..0000000 --- a/redhat/varnish.sysconfig +++ /dev/null @@ -1,111 +0,0 @@ -# Configuration file for varnish -# -# /etc/init.d/varnish expects the variable $DAEMON_OPTS to be set from this -# shell script fragment. -# - -# Maximum number of open files (for ulimit -n) -NFILES=131072 - -# Locked shared memory (for ulimit -l) -# Default log size is 82MB + header -MEMLOCK=82000 - -# Maximum number of threads (for ulimit -u) -NPROCS="unlimited" - -# Maximum size of corefile (for ulimit -c). Default in Fedora is 0 -# DAEMON_COREFILE_LIMIT="unlimited" - -# Set this to 1 to make init script reload try to switch vcl without restart. -# To make this work, you need to set the following variables -# explicit: VARNISH_VCL_CONF, VARNISH_ADMIN_LISTEN_ADDRESS, -# VARNISH_ADMIN_LISTEN_PORT, VARNISH_SECRET_FILE, or in short, -# use Alternative 3, Advanced configuration, below -RELOAD_VCL=1 - -# This file contains 4 alternatives, please use only one. - -## Alternative 1, Minimal configuration, no VCL -# -# Listen on port 6081, administration on localhost:6082, and forward to -# content server on localhost:8080. Use a fixed-size cache file. -# -#DAEMON_OPTS="-a :6081 \ -# -T localhost:6082 \ -# -b localhost:8080 \ -# -u varnish -g varnish \ -# -s file,/var/lib/varnish/varnish_storage.bin,1G" - - -## Alternative 2, Configuration with VCL -# -# Listen on port 6081, administration on localhost:6082, and forward to -# one content server selected by the vcl file, based on the request. Use a -# fixed-size cache file. -# -#DAEMON_OPTS="-a :6081 \ -# -T localhost:6082 \ -# -f /etc/varnish/default.vcl \ -# -u varnish -g varnish \ -# -S /etc/varnish/secret \ -# -s file,/var/lib/varnish/varnish_storage.bin,1G" - - -## Alternative 3, Advanced configuration -# -# See varnishd(1) for more information. -# -# # Main configuration file. You probably want to change it :) -VARNISH_VCL_CONF=/etc/varnish/default.vcl -# -# # Default address and port to bind to -# # Blank address means all IPv4 and IPv6 interfaces, otherwise specify -# # a host name, an IPv4 dotted quad, or an IPv6 address in brackets. -# VARNISH_LISTEN_ADDRESS= -VARNISH_LISTEN_PORT=6081 -# -# # Telnet admin interface listen address and port -VARNISH_ADMIN_LISTEN_ADDRESS=127.0.0.1 -VARNISH_ADMIN_LISTEN_PORT=6082 -# -# # Shared secret file for admin interface -VARNISH_SECRET_FILE=/etc/varnish/secret -# -# # The minimum number of worker threads to start -VARNISH_MIN_THREADS=50 -# -# # The Maximum number of worker threads to start -VARNISH_MAX_THREADS=1000 -# -# # Idle timeout for worker threads -VARNISH_THREAD_TIMEOUT=120 -# -# # Cache file size: in bytes, optionally using k / M / G / T suffix, -# # or in percentage of available disk space using the % suffix. -VARNISH_STORAGE_SIZE=256M -# -# # Backend storage specification -VARNISH_STORAGE="malloc,${VARNISH_STORAGE_SIZE}" -# -# # Default TTL used when the backend does not specify one -VARNISH_TTL=120 -# -# # DAEMON_OPTS is used by the init script. If you add or remove options, make -# # sure you update this section, too. -DAEMON_OPTS="-a ${VARNISH_LISTEN_ADDRESS}:${VARNISH_LISTEN_PORT} \ - -f ${VARNISH_VCL_CONF} \ - -T ${VARNISH_ADMIN_LISTEN_ADDRESS}:${VARNISH_ADMIN_LISTEN_PORT} \ - -t ${VARNISH_TTL} \ - -p thread_pool_min=${VARNISH_MIN_THREADS} \ - -p thread_pool_max=${VARNISH_MAX_THREADS} \ - -p thread_pool_timeout=${VARNISH_THREAD_TIMEOUT} \ - -u varnish -g varnish \ - -S ${VARNISH_SECRET_FILE} \ - -s ${VARNISH_STORAGE}" -# - - -## Alternative 4, Do It Yourself. See varnishd(1) for more information. -# -# DAEMON_OPTS="" diff --git a/redhat/varnish_reload_vcl b/redhat/varnish_reload_vcl deleted file mode 100755 index be3c21a..0000000 --- a/redhat/varnish_reload_vcl +++ /dev/null @@ -1,114 +0,0 @@ -#!/bin/bash -# -# reload vcl revisited -# A script that loads new vcl based on data from /etc/sysconfig/varnish -# Ingvar Hagelund -# -# This is free software, distributed under the standard 2 clause BSD license, -# see the LICENSE file in the Varnish documentation directory -# -# The following environment variables have to be set: -# RELOAD_VCL, VARNISH_VCL_CONF, VARNISH_ADMIN_LISTEN_PORT -# The following are optional: -# VARNISH_SECRET_FILE, VARNISH_ADMIN_LISTEN_ADDRESS -# -# Requires GNU bash and GNU date -# - -debug=false - -missing() { - echo "Missing configuration variable: $1" - exit 2 -} - -print_debug() { - echo " -Parsed configuration: -RELOAD_VCL=\"$RELOAD_VCL\" -VARNISH_VCL_CONF=\"$VARNISH_VCL_CONF\" -VARNISH_ADMIN_LISTEN_ADDRESS=\"$VARNISH_ADMIN_LISTEN_ADDRESS\" -VARNISH_ADMIN_LISTEN_PORT=\"$VARNISH_ADMIN_LISTEN_PORT\" -VARNISH_SECRET_FILE=\"$VARNISH_SECRET_FILE\" -" -} - -# Read configuration -. /etc/sysconfig/varnish - -$debug && print_debug - -# Check configuration -if [ ! "$RELOAD_VCL" = "1" ]; then - echo "Error: RELOAD_VCL is not set to 1" - exit 2 - -elif [ -z "$VARNISH_VCL_CONF" ]; then - echo "Error: VARNISH_VCL_CONF is not set" - exit 2 - -elif [ ! -s "$VARNISH_VCL_CONF" ]; then - echo "Eror: VCL config $VARNISH_VCL_CONF is unreadable or empty" - exit 2 - -elif [ -z "$VARNISH_ADMIN_LISTEN_ADDRESS" ]; then - echo "Warning: VARNISH_ADMIN_LISTEN_ADDRESS is not set, using 127.0.0.1" - VARNISH_ADMIN_LISTEN_ADDRESS="127.0.0.1" - -elif [ -z "$VARNISH_ADMIN_LISTEN_PORT" ]; then - echo "Error: VARNISH_ADMIN_LISTEN_PORT is not set" - exit 2 - -elif [ -z "$VARNISH_SECRET_FILE" ]; then - echo "Warning: VARNISH_SECRET_FILE is not set" - secret="" - -elif [ ! -s "$VARNISH_SECRET_FILE" ]; then - echo "Error: varnish secret file $VARNISH_SECRET_FILE is unreadable or empty" - exit 2 -else - secret="-S $VARNISH_SECRET_FILE" -fi - -# Done parsing, set up command -VARNISHADM="varnishadm $secret -T $VARNISH_ADMIN_LISTEN_ADDRESS:$VARNISH_ADMIN_LISTEN_PORT" - -# Now do the real work -new_config="reload_$(date +%FT%H:%M:%S)" - -# Check if we are able to connect at all -if $VARNISHADM vcl.list > /dev/null; then - $debug && echo vcl.list succeeded -else - echo "Unable to run $VARNISHADM vcl.list" - exit 1 -fi - -if $VARNISHADM vcl.list | awk ' { print $3 } ' | grep -q $new_config; then - echo Trying to use new config $new_config, but that is already in use - exit 2 -fi - -current_config=$( $VARNISHADM vcl.list | awk ' /^active/ { print $3 } ' ) - -echo "Loading vcl from $VARNISH_VCL_CONF" -echo "Current running config name is $current_config" -echo "Using new config name $new_config" - -if $VARNISHADM vcl.load $new_config $VARNISH_VCL_CONF; then - $debug && echo "$VARNISHADM vcl.load succeded" -else - echo "$VARNISHADM vcl.load failed" - exit 1 -fi - -if $VARNISHADM vcl.use $new_config; then - $debug && echo "$VARNISHADM vcl.use succeded" -else - echo "$VARNISHADM vcl.use failed" - exit 1 -fi -$VARNISHADM vcl.list -echo Done -exit 0 - diff --git a/redhat/varnishlog.initrc b/redhat/varnishlog.initrc deleted file mode 100644 index 2b5fc51..0000000 --- a/redhat/varnishlog.initrc +++ /dev/null @@ -1,116 +0,0 @@ -#! /bin/sh -# -# varnishlog Control the Varnish logging daemon -# -# chkconfig: - 90 10 -# description: Varnish Cache logging daemon -# processname: varnishlog -# config: -# pidfile: /var/run/varnishlog.pid - -### BEGIN INIT INFO -# Provides: varnishlog -# Required-Start: $network $local_fs $remote_fs -# Required-Stop: $network $local_fs $remote_fs -# Default-Start: -# Default-Stop: -# Short-Description: start and stop varnishlog -# Description: Varnish Cache logging daemon -### END INIT INFO - -# Source function library. -. /etc/init.d/functions - -retval=0 -pidfile="/var/run/varnishlog.pid" -lockfile="/var/lock/subsys/varnishlog" -logfile="/var/log/varnish/varnish.log" - -exec="/usr/bin/varnishlog" -prog="varnishlog" - -DAEMON_OPTS="-a -w $logfile -D -P $pidfile" - -# Include varnishlog defaults -[ -e /etc/sysconfig/varnishlog ] && . /etc/sysconfig/varnishlog - -start() { - - if [ ! -x $exec ] - then - echo $exec not found - exit 5 - fi - - echo -n "Starting varnish logging daemon: " - - daemon --pidfile $pidfile $exec "$DAEMON_OPTS" - echo - return $retval -} - -stop() { - echo -n "Stopping varnish logging daemon: " - killproc -p $pidfile $prog - retval=$? - echo - [ $retval -eq 0 ] && rm -f $lockfile - return $retval -} - -restart() { - stop - start -} - -reload() { - restart -} - -force_reload() { - restart -} - -rh_status() { - status -p $pidfile $prog -} - -rh_status_q() { - rh_status >/dev/null 2>&1 -} - -# See how we were called. -case "$1" in - start) - rh_status_q && exit 0 - $1 - ;; - stop) - rh_status_q || exit 0 - $1 - ;; - restart) - $1 - ;; - reload) - rh_status_q || exit 7 - $1 - ;; - force-reload) - force_reload - ;; - status) - rh_status - ;; - condrestart|try-restart) - rh_status_q || exit 0 - restart - ;; - *) - echo "Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}" - - exit 2 -esac - -exit $? - diff --git a/redhat/varnishlog.service b/redhat/varnishlog.service deleted file mode 100644 index c7a0193..0000000 --- a/redhat/varnishlog.service +++ /dev/null @@ -1,11 +0,0 @@ -[Unit] -Description=Varnish HTTP accelerator logging daemon -After=varnish.service - -[Service] -Type=forking -PIDFile=/run/varnishlog.pid -ExecStart=/usr/bin/varnishlog -a -w /var/log/varnish/varnish.log -D -P /run/varnishlog.pid - -[Install] -WantedBy=multi-user.target diff --git a/redhat/varnishncsa.initrc b/redhat/varnishncsa.initrc deleted file mode 100644 index b23fa48..0000000 --- a/redhat/varnishncsa.initrc +++ /dev/null @@ -1,116 +0,0 @@ -#! /bin/sh -# -# varnishncsa Control the Varnish NCSA logging daemon -# -# chkconfig: - 90 10 -# description: Varnish Cache logging daemon -# processname: varnishncsa -# config: -# pidfile: /var/run/varnishncsa.pid - -### BEGIN INIT INFO -# Provides: varnishncsa -# Required-Start: $network $local_fs $remote_fs -# Required-Stop: $network $local_fs $remote_fs -# Default-Start: -# Default-Stop: -# Short-Description: start and stop varnishncsa -# Description: Varnish Cache NCSA logging daemon -### END INIT INFO - -# Source function library. -. /etc/init.d/functions - -retval=0 -pidfile="/var/run/varnishncsa.pid" -lockfile="/var/lock/subsys/varnishncsa" -logfile="/var/log/varnish/varnishncsa.log" - -exec="/usr/bin/varnishncsa" -prog="varnishncsa" - -DAEMON_OPTS="-a -w $logfile -D -P $pidfile" - -# Include varnishncsa defaults -[ -e /etc/sysconfig/varnishncsa ] && . /etc/sysconfig/varnishncsa - -start() { - - if [ ! -x $exec ] - then - echo $exec not found - exit 5 - fi - - echo -n "Starting varnish ncsa logging daemon: " - - daemon --pidfile $pidfile $exec "$DAEMON_OPTS" - echo - return $retval -} - -stop() { - echo -n "Stopping varnish ncsa logging daemon: " - killproc -p $pidfile $prog - retval=$? - echo - [ $retval -eq 0 ] && rm -f $lockfile - return $retval -} - -restart() { - stop - start -} - -reload() { - restart -} - -force_reload() { - restart -} - -rh_status() { - status -p $pidfile $prog -} - -rh_status_q() { - rh_status >/dev/null 2>&1 -} - -# See how we were called. -case "$1" in - start) - rh_status_q && exit 0 - $1 - ;; - stop) - rh_status_q || exit 0 - $1 - ;; - restart) - $1 - ;; - reload) - rh_status_q || exit 7 - $1 - ;; - force-reload) - force_reload - ;; - status) - rh_status - ;; - condrestart|try-restart) - rh_status_q || exit 0 - restart - ;; - *) - echo "Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}" - - exit 2 -esac - -exit $? - diff --git a/redhat/varnishncsa.service b/redhat/varnishncsa.service deleted file mode 100644 index e2ebdcd..0000000 --- a/redhat/varnishncsa.service +++ /dev/null @@ -1,11 +0,0 @@ -[Unit] -Description=Varnish HTTP accelerator NCSA daemon -After=varnish.service - -[Service] -Type=forking -PIDFile=/run/varnishncsa.pid -ExecStart=/usr/bin/varnishncsa -a -w /var/log/varnish/varnishncsa.log -D -P /run/varnishncsa.pid - -[Install] -WantedBy=multi-user.target From lkarsten at varnish-software.com Mon Dec 21 12:11:20 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Mon, 21 Dec 2015 13:11:20 +0100 Subject: [4.0] 46b05e4 Merge branch '4.0' of git.varnish-cache.org:varnish-cache into 4.0 Message-ID: commit 46b05e4ece76b5988833a2c8b25d5b95817cf408 Merge: 96ad118 4332353 Author: Lasse Karstensen Date: Mon Dec 21 13:11:01 2015 +0100 Merge branch '4.0' of git.varnish-cache.org:varnish-cache into 4.0 From lkarsten at varnish-software.com Mon Dec 21 12:21:58 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Mon, 21 Dec 2015 13:21:58 +0100 Subject: [master] 871bfe7 Add reference to varnish-counters(7). Message-ID: commit 871bfe79a7dbca135cf49ec3581eb46df0b9e9d2 Author: Lasse Karstensen Date: Mon Dec 21 13:20:51 2015 +0100 Add reference to varnish-counters(7). diff --git a/doc/sphinx/reference/varnishstat.rst b/doc/sphinx/reference/varnishstat.rst index 5eef680..4b8d98c 100644 --- a/doc/sphinx/reference/varnishstat.rst +++ b/doc/sphinx/reference/varnishstat.rst @@ -201,6 +201,7 @@ between each block of output. SEE ALSO ======== +* :ref:`varnish-counters(7)` * :ref:`varnishd(1)` * :ref:`varnishhist(1)` * :ref:`varnishlog(1)` From lkarsten at varnish-software.com Mon Dec 21 12:21:58 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Mon, 21 Dec 2015 13:21:58 +0100 Subject: [master] 40d3be9 Change man page history into authors section. Message-ID: commit 40d3be9ff2ac08096d084a57d9d6702479501bf2 Author: Lasse Karstensen Date: Mon Dec 21 13:20:54 2015 +0100 Change man page history into authors section. We don't maintain any history, and the man page is covered by the distribution copyright. diff --git a/doc/sphinx/reference/varnishstat.rst b/doc/sphinx/reference/varnishstat.rst index 4b8d98c..80ba96b 100644 --- a/doc/sphinx/reference/varnishstat.rst +++ b/doc/sphinx/reference/varnishstat.rst @@ -209,20 +209,9 @@ SEE ALSO * :ref:`varnishtop(1)` * curses(3) -HISTORY + +AUTHORS ======= -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, Per Buer, +This manual page was written by Dag-Erling Sm?rgrav, Per Buer, Lasse Karstensen and Martin Blix Grydeland. - - -COPYRIGHT -========= - -This document is licensed under the same licence as Varnish -itself. See LICENCE for details. - -* Copyright (c) 2006 Verdens Gang AS -* Copyright (c) 2006-2015 Varnish Software AS From lkarsten at varnish-software.com Mon Dec 21 12:28:02 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Mon, 21 Dec 2015 13:28:02 +0100 Subject: [master] a795e0b Add ref for sphinx. Message-ID: commit a795e0b496c32c84a9cb01ccc5345135f9505986 Author: Lasse Karstensen Date: Mon Dec 21 13:26:49 2015 +0100 Add ref for sphinx. diff --git a/man/vsc2rst.c b/man/vsc2rst.c index 93950f0..11c3d2a 100644 --- a/man/vsc2rst.c +++ b/man/vsc2rst.c @@ -47,6 +47,8 @@ int main(int argc, char **argv) { (void)argc; (void)argv; + P(".. _varnish-counters(7): "); + P(""); P("================"); P("varnish-counters"); P("================"); From lkarsten at varnish-software.com Mon Dec 21 13:27:46 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Mon, 21 Dec 2015 14:27:46 +0100 Subject: [master] 1b72563 Move varnish-counters man page. Message-ID: commit 1b72563e9c0a50afa5613bad5344c37e75f2c2c8 Author: Lasse Karstensen Date: Mon Dec 21 14:24:14 2015 +0100 Move varnish-counters man page. To get this into the normal Sphinx build, move it to bin/varnishstat/ (where it feels like it belongs the most), and use our normal build flow for man pages. diff --git a/.gitignore b/.gitignore index 5795c63..0cfaa04 100644 --- a/.gitignore +++ b/.gitignore @@ -76,7 +76,6 @@ cscope.*out # Man-files and binaries -/man/vsc2rst /man/*.1 /man/*.3 /man/*.7 @@ -90,6 +89,7 @@ cscope.*out /bin/varnishncsa/varnishncsa /bin/varnishreplay/varnishreplay /bin/varnishstat/varnishstat +/bin/varnishstat/vsc2rst /bin/varnishtest/varnishtest /bin/varnishtop/varnishtop diff --git a/bin/varnishstat/Makefile.am b/bin/varnishstat/Makefile.am index 664131d..a276444 100644 --- a/bin/varnishstat/Makefile.am +++ b/bin/varnishstat/Makefile.am @@ -19,3 +19,6 @@ varnishstat_LDADD = \ $(top_builddir)/lib/libvarnishcompat/libvarnishcompat.la \ $(top_builddir)/lib/libvarnishapi/libvarnishapi.la \ @CURSES_LIB@ ${RT_LIBS} ${LIBM} ${PTHREAD_LIBS} + +noinst_PROGRAMS = vsc2rst +vsc2rst_SOURCES = vsc2rst.c $(top_srcdir)/include/tbl/vsc_fields.h diff --git a/bin/varnishstat/vsc2rst.c b/bin/varnishstat/vsc2rst.c new file mode 100644 index 0000000..3358db4 --- /dev/null +++ b/bin/varnishstat/vsc2rst.c @@ -0,0 +1,109 @@ +/*- + * Copyright (c) 2011-2015 Varnish Software AS + * All rights reserved. + * + * Author: Tollef Fog Heen + * + * 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. + * + */ + +#include "config.h" + +#include + +#define VSC_LEVEL_F(v,l,e,d) \ + static const char VSC_level_##v[] = l; +#include "tbl/vsc_levels.h" +#undef VSC_LEVEL_F + +#define P(x, ...) \ + printf(x "\n", ##__VA_ARGS__) +#define VSC_LEVEL_F(v,l,e,d) \ + printf("%s ? %s\n\t%s\n\n", l, e, d); +#define VSC_F(n, t, l, s, f, v, d, e) \ + printf("%s ? %s (%s)\n\t%s\n\n", #n, e, VSC_level_##v, d); + +int main(int argc, char **argv) +{ + (void)argc; + (void)argv; + P("COUNTER LEVELS"); + P("=============="); + P(""); +#include "tbl/vsc_levels.h" + + P(""); + P("MAIN COUNTERS (MAIN.*)"); + P("======================"); + P(""); +#include "tbl/vsc_f_main.h" + + P("MANAGEMENT PROCESS COUNTERS (MGT.*)"); + P("==================================="); + P(""); +#define VSC_DO_MGT +#include "tbl/vsc_fields.h" +#undef VSC_DO_MGT + + P(""); + P("PER MEMORY POOL COUNTERS (MEMPOOL.*)"); + P("===================================="); + P(""); +#define VSC_DO_MEMPOOL +#include "tbl/vsc_fields.h" +#undef VSC_DO_MEMPOOL + + P(""); + P("PER MALLOC STORAGE COUNTERS (SMA.*)"); + P("==================================="); + P(""); +#define VSC_DO_SMA +#include "tbl/vsc_fields.h" +#undef VSC_DO_SMA + + P(""); + P("PER FILE STORAGE COUNTERS (SMF.*)"); + P("================================="); + P(""); +#define VSC_DO_SMF +#include "tbl/vsc_fields.h" +#undef VSC_DO_SMF + + P(""); + P("PER BACKEND COUNTERS (VBE.*)"); + P("============================"); + P(""); +#define VSC_DO_VBE +#include "tbl/vsc_fields.h" +#undef VSC_DO_VBE + + P(""); + P("LOCK COUNTERS (LCK.*)"); + P("====================="); + P(""); +#define VSC_DO_LCK +#include "tbl/vsc_fields.h" +#undef VSC_DO_LCK + + return (0); +} diff --git a/doc/sphinx/Makefile.am b/doc/sphinx/Makefile.am index fbfe06b..b17ec99 100644 --- a/doc/sphinx/Makefile.am +++ b/doc/sphinx/Makefile.am @@ -128,6 +128,10 @@ include/params.rst: $(top_builddir)/bin/varnishd/varnishd $(top_builddir)/bin/varnishd/varnishd -x dumprstparam > include/params.rst BUILT_SOURCES = include/params.rst +include/counters.rst: $(top_builddir)/bin/varnishstat/vsc2rst + $(top_builddir)/bin/varnishstat/vsc2rst > $@ +BUILT_SOURCES += include/counters.rst + # XXX add varnishstat here when it's been _opt2rst'ed include/varnishncsa_options.rst: $(top_builddir)/bin/varnishncsa/varnishncsa_opt2rst diff --git a/doc/sphinx/reference/index.rst b/doc/sphinx/reference/index.rst index e787b4e..603d1a0 100644 --- a/doc/sphinx/reference/index.rst +++ b/doc/sphinx/reference/index.rst @@ -23,6 +23,7 @@ The Varnish Reference Manual vmod_std.generated.rst vmod_directors.generated.rst directors.rst + varnish-counters.rst vsl.rst vsl-query.rst diff --git a/doc/sphinx/reference/varnish-counters.rst b/doc/sphinx/reference/varnish-counters.rst new file mode 100644 index 0000000..781eeaa --- /dev/null +++ b/doc/sphinx/reference/varnish-counters.rst @@ -0,0 +1,21 @@ +.. _varnish-counters(7): + +================ +varnish-counters +================ + +--------------------------------- +Varnish counter field definitions +--------------------------------- + +:Manual section: 7 + + +.. include:: ../include/counters.rst + + +AUTHORS +======= + +This man page was written by Lasse Karstensen, using content from vsc2rst +written by Tollef Fog Heen. diff --git a/man/Makefile.am b/man/Makefile.am index 82f5471..35a8c52 100644 --- a/man/Makefile.am +++ b/man/Makefile.am @@ -1,11 +1,5 @@ # -noinst_PROGRAMS = vsc2rst -vsc2rst_SOURCES = vsc2rst.c \ - $(top_srcdir)/include/tbl/vsc_fields.h - -AM_CPPFLAGS = -I$(top_srcdir)/include - dist_man_MANS = \ varnish-cli.7 \ varnish-counters.7 \ @@ -30,8 +24,8 @@ RST2ANY_FLAGS = --halt=2 varnish-cli.7: $(top_srcdir)/doc/sphinx/reference/varnish-cli.rst ${RST2MAN} $(RST2ANY_FLAGS) $(top_srcdir)/doc/sphinx/reference/varnish-cli.rst $@ -varnish-counters.7: vsc2rst - ./vsc2rst | ${RST2MAN} $(RST2ANY_FLAGS) - $@ +varnish-counters.7: $(top_srcdir)/doc/sphinx/reference/varnish-counters.rst + ${RST2MAN} $(RST2ANY_FLAGS) $(top_srcdir)/doc/sphinx/reference/varnish-counters.rst $@ vcl.7: $(top_srcdir)/doc/sphinx/reference/vcl.rst \ $(top_srcdir)/bin/varnishd/builtin.vcl diff --git a/man/vsc2rst.c b/man/vsc2rst.c deleted file mode 100644 index 11c3d2a..0000000 --- a/man/vsc2rst.c +++ /dev/null @@ -1,132 +0,0 @@ -/*- - * Copyright (c) 2011-2015 Varnish Software AS - * All rights reserved. - * - * Author: Tollef Fog Heen - * - * 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. - * - */ - -#include "config.h" - -#include - -#define VSC_LEVEL_F(v,l,e,d) \ - static const char VSC_level_##v[] = l; -#include "tbl/vsc_levels.h" -#undef VSC_LEVEL_F - -#define P(x, ...) \ - printf(x "\n", ##__VA_ARGS__) -#define VSC_LEVEL_F(v,l,e,d) \ - printf("%s ? %s\n\t%s\n\n", l, e, d); -#define VSC_F(n, t, l, s, f, v, d, e) \ - printf("%s ? %s (%s)\n\t%s\n\n", #n, e, VSC_level_##v, d); - -int main(int argc, char **argv) -{ - (void)argc; - (void)argv; - P(".. _varnish-counters(7): "); - P(""); - P("================"); - P("varnish-counters"); - P("================"); - P(""); - - P("---------------------------------"); - P("Varnish counter field definitions"); - P("---------------------------------"); - P(""); - - P(":Manual section: 7"); - P(""); - - P("COUNTER LEVELS"); - P("=============="); - P(""); -#include "tbl/vsc_levels.h" - - P(""); - P("MAIN COUNTERS (MAIN.*)"); - P("======================"); - P(""); -#include "tbl/vsc_f_main.h" - - P("MANAGEMENT PROCESS COUNTERS (MGT.*)"); - P("==================================="); - P(""); -#define VSC_DO_MGT -#include "tbl/vsc_fields.h" -#undef VSC_DO_MGT - - P(""); - P("PER MEMORY POOL COUNTERS (MEMPOOL.*)"); - P("===================================="); - P(""); -#define VSC_DO_MEMPOOL -#include "tbl/vsc_fields.h" -#undef VSC_DO_MEMPOOL - - P(""); - P("PER MALLOC STORAGE COUNTERS (SMA.*)"); - P("==================================="); - P(""); -#define VSC_DO_SMA -#include "tbl/vsc_fields.h" -#undef VSC_DO_SMA - - P(""); - P("PER FILE STORAGE COUNTERS (SMF.*)"); - P("================================="); - P(""); -#define VSC_DO_SMF -#include "tbl/vsc_fields.h" -#undef VSC_DO_SMF - - P(""); - P("PER BACKEND COUNTERS (VBE.*)"); - P("============================"); - P(""); -#define VSC_DO_VBE -#include "tbl/vsc_fields.h" -#undef VSC_DO_VBE - - P(""); - P("LOCK COUNTERS (LCK.*)"); - P("====================="); - P(""); -#define VSC_DO_LCK -#include "tbl/vsc_fields.h" -#undef VSC_DO_LCK - - P(""); - P("COPYRIGHT"); - P("========="); - P("This document is licensed under the same licence as Varnish"); - P("itself. See LICENCE for details."); - P(""); - P("* Copyright (c) 2006 Verdens Gang AS"); - P("* Copyright (c) 2006-2015 Varnish Software AS"); - return (0); -} From lkarsten at varnish-software.com Mon Dec 21 13:54:38 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Mon, 21 Dec 2015 14:54:38 +0100 Subject: [master] 06063ce Use one level less of indirection. Message-ID: commit 06063ce9e7751643f6b4e235ef2441c30ef55601 Author: Lasse Karstensen Date: Mon Dec 21 14:29:06 2015 +0100 Use one level less of indirection. Trips up my syntax highlighting. diff --git a/doc/sphinx/Makefile.am b/doc/sphinx/Makefile.am index b17ec99..e47a60d 100644 --- a/doc/sphinx/Makefile.am +++ b/doc/sphinx/Makefile.am @@ -7,10 +7,7 @@ SPHINXBUILD = sphinx-build -W -q -N PAPER = a4 BUILDDIR = build -# Internal variables. -PAPEROPT_a4 = -D latex_paper_size=a4 -PAPEROPT_letter = -D latex_paper_size=letter -ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) $(builddir) +ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees -D latex_paper_size=$(PAPER) $(SPHINXOPTS) $(builddir) .PHONY: help clean html dirhtml pickle json htmlhelp qthelp latex changes linkcheck doctest From lkarsten at varnish-software.com Mon Dec 21 13:54:38 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Mon, 21 Dec 2015 14:54:38 +0100 Subject: [master] b91cddb Sort list of references. Message-ID: commit b91cddbb4771273a5e341e9390dd5af83792b903 Author: Lasse Karstensen Date: Mon Dec 21 14:47:31 2015 +0100 Sort list of references. diff --git a/doc/sphinx/reference/varnishstat.rst b/doc/sphinx/reference/varnishstat.rst index 80ba96b..a0619ae 100644 --- a/doc/sphinx/reference/varnishstat.rst +++ b/doc/sphinx/reference/varnishstat.rst @@ -201,13 +201,13 @@ between each block of output. SEE ALSO ======== -* :ref:`varnish-counters(7)` * :ref:`varnishd(1)` * :ref:`varnishhist(1)` * :ref:`varnishlog(1)` * :ref:`varnishncsa(1)` * :ref:`varnishtop(1)` * curses(3) +* :ref:`varnish-counters(7)` AUTHORS From lkarsten at varnish-software.com Mon Dec 21 13:54:38 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Mon, 21 Dec 2015 14:54:38 +0100 Subject: [master] 0ff8de5 Filter subdir-include messages. Message-ID: commit 0ff8de5eca001a7fd28fc27559c8b11e349e035e Author: Lasse Karstensen Date: Mon Dec 21 14:51:05 2015 +0100 Filter subdir-include messages. diff --git a/autogen.des b/autogen.des index 0cbbbc0..45698f4 100755 --- a/autogen.des +++ b/autogen.des @@ -13,7 +13,8 @@ if [ -f /usr/bin/clang -a "x${CC}" = "x" ] ; then fi rm -f configure -. ./autogen.sh +. ./autogen.sh 2>&1 | egrep -v "(subdir-objects|is in a subdirectory)" + # autoconf prior to 2.62 has issues with zsh 4.2 and newer export CONFIG_SHELL=/bin/sh From lkarsten at varnish-software.com Mon Dec 21 14:09:52 2015 From: lkarsten at varnish-software.com (Lasse Karstensen) Date: Mon, 21 Dec 2015 15:09:52 +0100 Subject: [master] d2fd2b9 Avoid repeated copying of generated RST files. Message-ID: commit d2fd2b9e21341aeb4289edc0a0e8b4b277d581e5 Author: Lasse Karstensen Date: Mon Dec 21 15:09:00 2015 +0100 Avoid repeated copying of generated RST files. diff --git a/doc/sphinx/Makefile.am b/doc/sphinx/Makefile.am index e47a60d..52fa8de 100644 --- a/doc/sphinx/Makefile.am +++ b/doc/sphinx/Makefile.am @@ -159,17 +159,12 @@ include/varnishhist_synopsis.rst: $(top_builddir)/bin/varnishhist/varnishhist_op BUILT_SOURCES += include/varnishhist_options.rst \ include/varnishhist_synopsis.rst -.PHONY: reference -reference: - test -d $@ || mkdir $@ -BUILT_SOURCES += reference - -reference/vmod_std.generated.rst: reference $(top_builddir)/lib/libvmod_std/vmod_std.rst - cp $(top_builddir)/lib/libvmod_std/vmod_std.rst $@ +reference/vmod_std.generated.rst: $(top_builddir)/lib/libvmod_std/vmod_std.rst + mkdir -p reference && cp $(top_builddir)/lib/libvmod_std/vmod_std.rst $@ BUILT_SOURCES += reference/vmod_std.generated.rst -reference/vmod_directors.generated.rst: reference $(top_builddir)/lib/libvmod_directors/vmod_directors.rst - cp $(top_builddir)/lib/libvmod_directors/vmod_directors.rst $@ +reference/vmod_directors.generated.rst: $(top_builddir)/lib/libvmod_directors/vmod_directors.rst + mkdir -p reference && cp $(top_builddir)/lib/libvmod_directors/vmod_directors.rst $@ BUILT_SOURCES += reference/vmod_directors.generated.rst EXTRA_DIST += $(BUILT_SOURCES) From fgsch at lodoss.net Mon Dec 21 20:34:46 2015 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Mon, 21 Dec 2015 21:34:46 +0100 Subject: [master] e28ba05 Fix distcheck Message-ID: commit e28ba055056a5ad02771e984d24c2c82aac5ff9d Author: Federico G. Schwindt Date: Mon Dec 21 20:19:49 2015 +0000 Fix distcheck diff --git a/doc/sphinx/Makefile.am b/doc/sphinx/Makefile.am index 52fa8de..0a4973c 100644 --- a/doc/sphinx/Makefile.am +++ b/doc/sphinx/Makefile.am @@ -159,12 +159,17 @@ include/varnishhist_synopsis.rst: $(top_builddir)/bin/varnishhist/varnishhist_op BUILT_SOURCES += include/varnishhist_options.rst \ include/varnishhist_synopsis.rst +.PHONY: reference +reference: + test -d $@ || mkdir $@ +BUILT_SOURCES += reference + reference/vmod_std.generated.rst: $(top_builddir)/lib/libvmod_std/vmod_std.rst - mkdir -p reference && cp $(top_builddir)/lib/libvmod_std/vmod_std.rst $@ + cp $(top_builddir)/lib/libvmod_std/vmod_std.rst $@ BUILT_SOURCES += reference/vmod_std.generated.rst reference/vmod_directors.generated.rst: $(top_builddir)/lib/libvmod_directors/vmod_directors.rst - mkdir -p reference && cp $(top_builddir)/lib/libvmod_directors/vmod_directors.rst $@ + cp $(top_builddir)/lib/libvmod_directors/vmod_directors.rst $@ BUILT_SOURCES += reference/vmod_directors.generated.rst EXTRA_DIST += $(BUILT_SOURCES) From fgsch at lodoss.net Wed Dec 23 08:58:41 2015 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Wed, 23 Dec 2015 09:58:41 +0100 Subject: [master] 28915cf Revert d2fd2b9e and e28ba055 Message-ID: commit 28915cf79a317ea3033af5e68be0572bf2d8ed64 Author: Federico G. Schwindt Date: Wed Dec 23 08:58:23 2015 +0000 Revert d2fd2b9e and e28ba055 Unbreaks distcheck. diff --git a/doc/sphinx/Makefile.am b/doc/sphinx/Makefile.am index 0a4973c..e47a60d 100644 --- a/doc/sphinx/Makefile.am +++ b/doc/sphinx/Makefile.am @@ -164,11 +164,11 @@ reference: test -d $@ || mkdir $@ BUILT_SOURCES += reference -reference/vmod_std.generated.rst: $(top_builddir)/lib/libvmod_std/vmod_std.rst +reference/vmod_std.generated.rst: reference $(top_builddir)/lib/libvmod_std/vmod_std.rst cp $(top_builddir)/lib/libvmod_std/vmod_std.rst $@ BUILT_SOURCES += reference/vmod_std.generated.rst -reference/vmod_directors.generated.rst: $(top_builddir)/lib/libvmod_directors/vmod_directors.rst +reference/vmod_directors.generated.rst: reference $(top_builddir)/lib/libvmod_directors/vmod_directors.rst cp $(top_builddir)/lib/libvmod_directors/vmod_directors.rst $@ BUILT_SOURCES += reference/vmod_directors.generated.rst From fgsch at lodoss.net Wed Dec 23 10:41:04 2015 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Wed, 23 Dec 2015 11:41:04 +0100 Subject: [master] 199945a Do not leak comments into the generated html Message-ID: commit 199945af1bf5b20de2b2057d2e8ca06d1de766d7 Author: Federico G. Schwindt Date: Wed Dec 23 10:40:37 2015 +0000 Do not leak comments into the generated html diff --git a/doc/sphinx/users-guide/increasing-your-hitrate.rst b/doc/sphinx/users-guide/increasing-your-hitrate.rst index fe9219c..08eb09d 100644 --- a/doc/sphinx/users-guide/increasing-your-hitrate.rst +++ b/doc/sphinx/users-guide/increasing-your-hitrate.rst @@ -193,7 +193,9 @@ A somewhat simpler example that can accomplish almost the same functionality can found below. Instead of filtering out "other" cookies it instead picks out "the one" cookie that is needed, copies it to another header and then copies it back to the request, deleting the original cookie header. + .. XXX:Verify correctness of request above! benc + :: sub vcl_recv { @@ -298,11 +300,9 @@ Normalizing your namespace Some sites are accessed via lots of hostnames. http://www.varnish-software.com/, http://varnish-software.com/ and http://varnishsoftware.com/ all point at the same site. Since Varnish -doesn't know they are the same, -.. XXX: heavy meaning change above. benc -Varnish will cache different versions of every page for every -hostname. You can mitigate this in your web server configuration -by setting up redirects or by using the following VCL:: +doesn't know they are the same, Varnish will cache different versions of +every page for every hostname. You can mitigate this in your web server +configuration by setting up redirects or by using the following VCL:: if (req.http.host ~ "(?i)^(www.)?varnish-?software.com") { set req.http.host = "varnish-software.com"; diff --git a/doc/sphinx/users-guide/operation-logging.rst b/doc/sphinx/users-guide/operation-logging.rst index bb4c7cc..e6b58f2 100644 --- a/doc/sphinx/users-guide/operation-logging.rst +++ b/doc/sphinx/users-guide/operation-logging.rst @@ -31,8 +31,8 @@ You'll see lines like these scrolling slowly by.:: These is the Varnish master process checking up on the caching process to see that everything is OK. -Now go to the browser and reload the page displaying your web -app. +Now go to the browser and reload the page displaying your web app. + .. XXX:Doesn't this require a setup of a running varnishd and a web application being cached? benc You'll see lines like these.:: diff --git a/doc/sphinx/users-guide/operation-statistics.rst b/doc/sphinx/users-guide/operation-statistics.rst index 7a4827d..af062bd 100644 --- a/doc/sphinx/users-guide/operation-statistics.rst +++ b/doc/sphinx/users-guide/operation-statistics.rst @@ -29,11 +29,9 @@ varnishhist The :ref:`varnishhist(1)` utility reads :ref:`varnishd(1)` shared memory logs and presents a continuously updated histogram showing the distribution of the last N requests by their processing. -.. XXX:1? benc -The value of N and the -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 ("#"). +The value of N and the 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 ("#"). varnishstat ~~~~~~~~~~~ From francisco at varnish-software.com Wed Dec 23 15:56:47 2015 From: francisco at varnish-software.com (Francisco Velázquez) Date: Wed, 23 Dec 2015 16:56:47 +0100 Subject: [master] e72dbc1 Fixing sentence Message-ID: commit e72dbc146045a980a3c9204f9a683c93052025b2 Author: Francisco Vel?zquez Date: Wed Dec 23 15:22:52 2015 +0000 Fixing sentence diff --git a/doc/sphinx/users-guide/esi.rst b/doc/sphinx/users-guide/esi.rst index 30379a1..0f16405 100644 --- a/doc/sphinx/users-guide/esi.rst +++ b/doc/sphinx/users-guide/esi.rst @@ -3,7 +3,7 @@ Content composition with Edge Side Includes ------------------------------------------- -Varnish can cache create web pages by assembling different pages, called `fragments`, +Varnish can create web pages by assembling different pages, called `fragments`, together into one page. These `fragments` can have individual cache policies. If you have a web site with a list showing the five most popular articles on your site, this list can probably be cached as a `fragment` and included From fgsch at lodoss.net Thu Dec 24 14:06:50 2015 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Thu, 24 Dec 2015 15:06:50 +0100 Subject: [master] 37d738e Kill some dead assignments Message-ID: commit 37d738ea4c04629766e510daf3d440ac621d8156 Author: Federico G. Schwindt Date: Thu Dec 24 13:32:10 2015 +0000 Kill some dead assignments diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c index 3d23c7c..f1bb4c0 100644 --- a/bin/varnishd/cache/cache_session.c +++ b/bin/varnishd/cache/cache_session.c @@ -238,7 +238,6 @@ SES_RxStuff(struct http_conn *htc, htc_complete_f *func, /* Working on it */ if (t1 != NULL && isnan(*t1)) *t1 = now; - tmo = tn - now; } else if (hs != HTC_S_EMPTY) WRONG("htc_status_e"); diff --git a/bin/varnishstat/varnishstat_curses.c b/bin/varnishstat/varnishstat_curses.c index a27d438..174df57 100644 --- a/bin/varnishstat/varnishstat_curses.c +++ b/bin/varnishstat/varnishstat_curses.c @@ -943,10 +943,8 @@ draw_bar_b(void) level->label); X -= strlen(level->label) + 2; } - if (!hide_unseen) { + if (!hide_unseen) mvwprintw(w_bar_b, 0, X - 6, "%s", "UNSEEN"); - X -= 8; - } wnoutrefresh(w_bar_b); } diff --git a/bin/varnishtest/vtc_logexp.c b/bin/varnishtest/vtc_logexp.c index 767f7e6..1c0ea70 100644 --- a/bin/varnishtest/vtc_logexp.c +++ b/bin/varnishtest/vtc_logexp.c @@ -283,7 +283,6 @@ logexp_thread(void *priv) AN(le->vsm); AN(le->vslq); - i = 0; AZ(le->test); vtc_log(le->vl, 4, "beg|"); if (le->query != NULL) diff --git a/bin/varnishtest/vtc_varnish.c b/bin/varnishtest/vtc_varnish.c index 1c00ed0..292be63 100644 --- a/bin/varnishtest/vtc_varnish.c +++ b/bin/varnishtest/vtc_varnish.c @@ -237,14 +237,10 @@ varnishlog_thread(void *priv) tag = VSL_TAG(c->rec.ptr); vxid = VSL_ID(c->rec.ptr); - if (tag == SLT__Batch) { - tagname = "Batch"; - len = 0; + if (tag == SLT__Batch) continue; - } else { - tagname = VSL_tags[tag]; - len = VSL_LEN(c->rec.ptr); - } + tagname = VSL_tags[tag]; + len = VSL_LEN(c->rec.ptr); type = VSL_CLIENT(c->rec.ptr) ? 'c' : VSL_BACKEND(c->rec.ptr) ? 'b' : '-'; data = VSL_CDATA(c->rec.ptr); diff --git a/lib/libvcc/vcc_acl.c b/lib/libvcc/vcc_acl.c index b9722ce..b5ee224 100644 --- a/lib/libvcc/vcc_acl.c +++ b/lib/libvcc/vcc_acl.c @@ -348,7 +348,6 @@ vcc_acl_emit(struct vcc *tl, const char *acln, int anon) struct acl_e *ae; int depth, l, m, i; unsigned at[VRT_ACL_MAXADDR + 1]; - const char *oc; struct token *t; struct inifin *ifp; @@ -371,7 +370,6 @@ vcc_acl_emit(struct vcc *tl, const char *acln, int anon) "\tif (0) match_acl_named_%s(0, 0);\n", acln); } depth = -1; - oc = 0; at[0] = 256; VTAILQ_FOREACH(ae, &tl->acl, list) { @@ -383,7 +381,6 @@ vcc_acl_emit(struct vcc *tl, const char *acln, int anon) } /* Back down, if necessary */ - oc = ""; while (l <= depth) { Fh(tl, 0, "\t%*s}\n", -depth, ""); depth--; @@ -397,23 +394,21 @@ vcc_acl_emit(struct vcc *tl, const char *acln, int anon) for (i = l; m >= 8; m -= 8, i++) { if (i == 0) Fh(tl, 0, "\t%*s%sif (fam == %d) {\n", - -i, "", oc, ae->data[i]); + -i, "", "", ae->data[i]); else Fh(tl, 0, "\t%*s%sif (a[%d] == %d) {\n", - -i, "", oc, i - 1, ae->data[i]); + -i, "", "", i - 1, ae->data[i]); at[i] = ae->data[i]; depth = i; - oc = ""; } if (m > 0) { /* Do fractional byte compares */ Fh(tl, 0, "\t%*s%sif ((a[%d] & 0x%x) == %d) {\n", - -i, "", oc, i - 1, (0xff00 >> m) & 0xff, + -i, "", "", i - 1, (0xff00 >> m) & 0xff, ae->data[i] & ((0xff00 >> m) & 0xff)); at[i] = 256; depth = i; - oc = ""; } i = (ae->mask + 7) / 8; From fgsch at lodoss.net Thu Dec 24 14:53:55 2015 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Thu, 24 Dec 2015 15:53:55 +0100 Subject: [4.0] f4cea8e Switch to container-based infrastructure Message-ID: commit f4cea8e13d8b142a679764ec7b338a33e69e6d98 Author: Federico G. Schwindt Date: Mon Aug 3 17:53:25 2015 +0100 Switch to container-based infrastructure diff --git a/.travis.yml b/.travis.yml index 8caad42..164ba4b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,8 +3,12 @@ language: c compiler: - clang - gcc +addons: + apt: + packages: + - python-docutils before_install: - - sudo apt-get install python-docutils - ./autogen.sh - ./configure +sudo: false script: 'make -j3 check VERBOSE=1' From fgsch at lodoss.net Tue Dec 29 01:40:59 2015 From: fgsch at lodoss.net (Federico G. Schwindt) Date: Tue, 29 Dec 2015 02:40:59 +0100 Subject: [master] ad35dd2 vdef.h is not generated Message-ID: commit ad35dd29cc140737f6acc256ab64874f112d7ab9 Author: Federico G. Schwindt Date: Tue Dec 29 01:35:21 2015 +0000 vdef.h is not generated diff --git a/lib/libvcc/generate.py b/lib/libvcc/generate.py index 7a7413f..c799bed 100755 --- a/lib/libvcc/generate.py +++ b/lib/libvcc/generate.py @@ -1228,7 +1228,7 @@ vcl_output_lang_h(struct vsb *sb) { """) -emit_file(fo, buildroot, "include/vdef.h") +emit_file(fo, srcroot, "include/vdef.h") emit_file(fo, buildroot, "include/vcl.h") emit_file(fo, srcroot, "include/vrt.h") emit_file(fo, buildroot, "include/vrt_obj.h")