r4127 - in trunk/varnish-cache/bin: varnishd varnishtest/tests

phk at projects.linpro.no phk at projects.linpro.no
Mon Jun 22 12:36:30 CEST 2009


Author: phk
Date: 2009-06-22 12:36:30 +0200 (Mon, 22 Jun 2009)
New Revision: 4127

Added:
   trunk/varnish-cache/bin/varnishtest/tests/p00004.vtc
Modified:
   trunk/varnish-cache/bin/varnishd/storage_persistent.c
Log:
Insert persistent objects with a refcount of one for the hash-tree.



Modified: trunk/varnish-cache/bin/varnishd/storage_persistent.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/storage_persistent.c	2009-06-22 09:58:31 UTC (rev 4126)
+++ trunk/varnish-cache/bin/varnishd/storage_persistent.c	2009-06-22 10:36:30 UTC (rev 4127)
@@ -620,7 +620,8 @@
 	AN(oc->flags & OC_F_PERSISTENT);
 	oc->flags &= ~OC_F_PERSISTENT;
 
-	oc->obj->refcnt = 0;
+	/* refcnt is one because the object is in the hash */
+	oc->obj->refcnt = 1;
 	oc->obj->objcore = oc;
 	oc->obj->objhead = oh;
 	oc->obj->ban = oc->ban;

Added: trunk/varnish-cache/bin/varnishtest/tests/p00004.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/p00004.vtc	                        (rev 0)
+++ trunk/varnish-cache/bin/varnishtest/tests/p00004.vtc	2009-06-22 10:36:30 UTC (rev 4127)
@@ -0,0 +1,62 @@
+# $Id$
+
+test "Check object references"
+
+shell "rm -f /tmp/__v1/_.per"
+
+server s1 {
+	rxreq 
+	txresp -hdr "Foo: foo"
+	rxreq 
+	txresp -hdr "Bar: bar"
+} -start
+
+varnish v1 \
+	-arg "-pdiag_bitmap=0x20000" \
+	-arg "-spersistent,/tmp/__v1/_.per,10m" \
+	-vcl+backend { } -start 
+
+client c1 {
+	txreq -url "/foo"
+	rxresp
+	expect resp.status == 200
+	expect resp.http.X-Varnish == "1001"
+	expect resp.http.foo == "foo"
+} -run
+
+varnish v1 -expect n_object == 1
+
+client c1 {
+	txreq -url "/bar"
+	rxresp
+	expect resp.status == 200
+	expect resp.http.X-Varnish == "1002"
+	expect resp.http.bar == "bar"
+} -run
+
+varnish v1 -expect n_object == 2
+
+varnish v1 -cliok stop
+varnish v1 -cliok start -cliok "debug.xid 2000"
+
+varnish v1 -expect n_object == 2
+
+client c1 {
+	txreq -url "/foo"
+	rxresp
+	expect resp.status == 200
+	expect resp.http.X-Varnish == "2001 1001"
+	expect resp.http.foo == "foo"
+} -run
+
+varnish v1 -expect n_object == 2
+
+client c1 {
+	txreq -url "/bar"
+	rxresp
+	expect resp.status == 200
+	expect resp.http.X-Varnish == "2002 1002"
+	expect resp.http.bar == "bar"
+} -run
+
+varnish v1 -expect n_object == 2



More information about the varnish-commit mailing list