r3552 - in branches/2.0/varnish-cache/bin: varnishd varnishtest/tests
tfheen at projects.linpro.no
tfheen at projects.linpro.no
Wed Jan 28 13:13:06 CET 2009
Author: tfheen
Date: 2009-01-28 13:13:05 +0100 (Wed, 28 Jan 2009)
New Revision: 3552
Added:
branches/2.0/varnish-cache/bin/varnishtest/tests/v00023.vtc
Modified:
branches/2.0/varnish-cache/bin/varnishd/cache_vrt.c
Log:
Merge r3388:
Make sure that
set obj.ttl = 0s
means that the object is not hit again by actually using "-1" instead.
This works around the rounding error which otherwise causes the object
to be inside TTL for up to one second - epsilon.
Modified: branches/2.0/varnish-cache/bin/varnishd/cache_vrt.c
===================================================================
--- branches/2.0/varnish-cache/bin/varnishd/cache_vrt.c 2009-01-28 12:06:57 UTC (rev 3551)
+++ branches/2.0/varnish-cache/bin/varnishd/cache_vrt.c 2009-01-28 12:13:05 UTC (rev 3552)
@@ -318,9 +318,16 @@
CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC); /* XXX */
WSP(sp, SLT_TTL, "%u VCL %.0f %.0f",
sp->obj->xid, a, sp->t_req);
- if (a < 0)
- a = 0;
- sp->obj->ttl = sp->t_req + a;
+ /*
+ * If people set obj.ttl = 0s, they don't expect it to be cacheable
+ * any longer, but it will still be for up to 1s - epsilon because
+ * of the rounding to seconds.
+ * We special case and make sure that rounding does not surprise.
+ */
+ if (a <= 0)
+ sp->obj->ttl = sp->t_req - 1;
+ else
+ sp->obj->ttl = sp->t_req + a;
EXP_Rearm(sp->obj);
}
Copied: branches/2.0/varnish-cache/bin/varnishtest/tests/v00023.vtc (from rev 3388, trunk/varnish-cache/bin/varnishtest/tests/v00023.vtc)
===================================================================
--- branches/2.0/varnish-cache/bin/varnishtest/tests/v00023.vtc (rev 0)
+++ branches/2.0/varnish-cache/bin/varnishtest/tests/v00023.vtc 2009-01-28 12:13:05 UTC (rev 3552)
@@ -0,0 +1,31 @@
+# $Id$
+
+test "Test that obj.ttl = 0s prevents subsequent hits"
+
+server s1 {
+ rxreq
+ expect req.url == "/foo"
+ txresp -status 200 -body "1"
+ rxreq
+ expect req.url == "/foo"
+ txresp -status 200 -body "22"
+} -start
+
+varnish v1 -vcl+backend {
+ sub vcl_hit {
+ set obj.ttl = 0s;
+ restart;
+ }
+} -start
+
+client c1 {
+ txreq -url "/foo"
+ rxresp
+ expect resp.status == 200
+ expect resp.bodylen == 1
+
+ txreq -url "/foo"
+ rxresp
+ expect resp.status == 200
+ expect resp.bodylen == 2
+} -run
More information about the varnish-commit
mailing list