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

phk at projects.linpro.no phk at projects.linpro.no
Tue Aug 18 13:46:06 CEST 2009


Author: phk
Date: 2009-08-18 13:46:06 +0200 (Tue, 18 Aug 2009)
New Revision: 4197

Added:
   trunk/varnish-cache/bin/varnishtest/tests/p00005.vtc
Modified:
   trunk/varnish-cache/bin/varnishd/cache_expire.c
   trunk/varnish-cache/bin/varnishd/cache_hash.c
   trunk/varnish-cache/bin/varnishtest/tests/v00004.vtc
Log:
Fix expiry of non-instantiated objects.

Add test-case for same.



Modified: trunk/varnish-cache/bin/varnishd/cache_expire.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_expire.c	2009-08-18 11:23:41 UTC (rev 4196)
+++ trunk/varnish-cache/bin/varnishd/cache_expire.c	2009-08-18 11:46:06 UTC (rev 4197)
@@ -262,7 +262,9 @@
 			continue;
 		}
 
+
 		/* It's time... */
+		CHECK_OBJ_NOTNULL(oc->objhead, OBJHEAD_MAGIC);
 
 		/* Remove from binheap */
 		assert(oc->timer_idx != BINHEAP_NOIDX);
@@ -286,16 +288,19 @@
 
 		Lck_Unlock(&exp_mtx);
 
+		CHECK_OBJ_NOTNULL(oc->objhead, OBJHEAD_MAGIC);
 		if (!(oc->flags & OC_F_PERSISTENT)) {
 			o = oc->obj;
 			CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
-			CHECK_OBJ_NOTNULL(oc->objhead, OBJHEAD_MAGIC);
 			WSL(sp->wrk, SLT_ExpKill, 0, "%u %d",
 			    o->xid, (int)(o->ttl - t));
 			HSH_Deref(sp->wrk, &o);
 		} else {
-			WSL(sp->wrk, SLT_ExpKill, 0, "%u %d",
+			WSL(sp->wrk, SLT_ExpKill, 1, "%u %d",
 			    o, (int)(oc->timer_when - t));
+			sp->objhead = oc->objhead;
+			sp->objcore = oc;
+			HSH_DerefObjCore(sp);
 		}
 	}
 }

Modified: trunk/varnish-cache/bin/varnishd/cache_hash.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_hash.c	2009-08-18 11:23:41 UTC (rev 4196)
+++ trunk/varnish-cache/bin/varnishd/cache_hash.c	2009-08-18 11:46:06 UTC (rev 4197)
@@ -406,6 +406,7 @@
 	/* XXX: Should this not be ..._HEAD now ? */
 	VTAILQ_INSERT_TAIL(&oh->objcs, oc, list);
 	/* NB: do not deref objhead the new object inherits our reference */
+	oc->objhead = oh;
 	Lck_Unlock(&oh->mtx);
 	sp->wrk->stats->n_object++;
 	return (oc);
@@ -642,6 +643,7 @@
 
 	Lck_Lock(&oh->mtx);
 	VTAILQ_REMOVE(&oh->objcs, oc, list);
+	sp->wrk->stats->n_object--;
 	Lck_Unlock(&oh->mtx);
 	assert(oh->refcnt > 0);
 	FREE_OBJ(oc);

Added: trunk/varnish-cache/bin/varnishtest/tests/p00005.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/p00005.vtc	                        (rev 0)
+++ trunk/varnish-cache/bin/varnishtest/tests/p00005.vtc	2009-08-18 11:46:06 UTC (rev 4197)
@@ -0,0 +1,50 @@
+# $Id$
+
+test "Check expiry of non-instantiated object"
+
+shell "rm -f /tmp/__v1/_.per"
+
+server s1 {
+	rxreq 
+	txresp -hdr "Foo: foo1"
+} -start
+
+varnish v1 \
+	-arg "-pdiag_bitmap=0x30000" \
+	-arg "-spersistent,/tmp/__v1/_.per,10m" \
+	-vcl+backend { 
+		sub vcl_fetch {
+			set beresp.ttl = 3s;
+		}
+	} -start 
+
+client c1 {
+	txreq -url "/foo"
+	rxresp
+	expect resp.status == 200
+	expect resp.http.X-Varnish == "1001"
+	expect resp.http.foo == "foo1"
+} -run
+
+varnish v1 -expect n_object == 1
+
+varnish v1 -stop
+
+server s1 -wait {
+	rxreq 
+	txresp -hdr "Foo: foo2"
+} -start
+
+varnish v1 -start
+
+delay 5
+
+client c1 {
+	txreq -url "/foo"
+	rxresp
+	expect resp.status == 200
+	expect resp.http.X-Varnish == "1001"
+	expect resp.http.foo == "foo2"
+} -run
+
+varnish v1 -expect n_object == 1

Modified: trunk/varnish-cache/bin/varnishtest/tests/v00004.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/v00004.vtc	2009-08-18 11:23:41 UTC (rev 4196)
+++ trunk/varnish-cache/bin/varnishtest/tests/v00004.vtc	2009-08-18 11:46:06 UTC (rev 4197)
@@ -29,6 +29,8 @@
 }
 
 varnish v1 -expect n_backend == 2
+# give the expiry thread a chance to let go of its VCL
+delay 2
 varnish v1 -expect n_vcl == 3
 
 



More information about the varnish-commit mailing list