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

phk at projects.linpro.no phk at projects.linpro.no
Tue Mar 10 11:11:25 CET 2009


Author: phk
Date: 2009-03-10 11:11:25 +0100 (Tue, 10 Mar 2009)
New Revision: 3908

Modified:
   trunk/varnish-cache/bin/varnishd/cache.h
   trunk/varnish-cache/bin/varnishd/cache_hash.c
   trunk/varnish-cache/bin/varnishd/storage_persistent.c
   trunk/varnish-cache/bin/varnishtest/tests/p0000.vtc
Log:
Implement the minium SMP_Fixup() function for resurrecting objects from
persistent storage.

We now pass the first, very rudimentary, test-case for persistent storage.



Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h	2009-03-09 14:27:28 UTC (rev 3907)
+++ trunk/varnish-cache/bin/varnishd/cache.h	2009-03-10 10:11:25 UTC (rev 3908)
@@ -659,6 +659,9 @@
 struct vsb *SMS_Makesynth(struct object *obj);
 void SMS_Finish(struct object *obj);
 
+/* storage_persistent.c */
+void SMP_Fixup(struct sess *sp, struct objhead *oh, struct objcore *oc);
+
 /*
  * A normal pointer difference is signed, but we never want a negative value
  * so this little tool will make sure we don't get that.

Modified: trunk/varnish-cache/bin/varnishd/cache_hash.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_hash.c	2009-03-09 14:27:28 UTC (rev 3907)
+++ trunk/varnish-cache/bin/varnishd/cache_hash.c	2009-03-10 10:11:25 UTC (rev 3908)
@@ -400,7 +400,8 @@
 	/* Insert (precreated) objcore in objecthead */
 	oc = w->nobjcore;
 	w->nobjcore = NULL;
-	AN(oc->flags & OC_F_BUSY);
+	AZ(oc->flags & OC_F_BUSY);
+	CHECK_OBJ_NOTNULL(oc->obj, OBJECT_MAGIC);
 
 	/* XXX: Should this not be ..._HEAD now ? */
 	VTAILQ_INSERT_TAIL(&oh->objcs, oc, list);
@@ -452,7 +453,8 @@
 		assert(oh->refcnt > 1);
 		CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
 
-		XXXAZ(oc->flags & OC_F_PERSISTENT);
+		if (oc->flags & OC_F_PERSISTENT)
+			SMP_Fixup(sp, oh, oc);
 
 		if (oc->flags & OC_F_BUSY) {
 			busy_oc = oc;

Modified: trunk/varnish-cache/bin/varnishd/storage_persistent.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/storage_persistent.c	2009-03-09 14:27:28 UTC (rev 3907)
+++ trunk/varnish-cache/bin/varnishd/storage_persistent.c	2009-03-10 10:11:25 UTC (rev 3908)
@@ -414,6 +414,26 @@
 }
 
 /*--------------------------------------------------------------------
+ * Fixup an object
+ */
+
+void
+SMP_Fixup(struct sess *sp, struct objhead *oh, struct objcore *oc)
+{
+fprintf(stderr, "Fixup %p %p\n", sp, oc);
+
+	oc->flags &= ~OC_F_PERSISTENT;
+
+	oc->obj->refcnt = 0;
+	oc->obj->objcore = oc;
+	oc->obj->objhead = oh;
+
+	/* XXX: Placeholder for persistent bans */
+	oc->obj->ban = NULL;
+	BAN_NewObj(oc->obj);
+}
+
+/*--------------------------------------------------------------------
  * Load segments
  */
 
@@ -442,6 +462,8 @@
 		    so, so->ttl - t_now, so->offset);
 		HSH_Prealloc(sp);
 		sp->wrk->nobjcore->flags |= OC_F_PERSISTENT;
+		sp->wrk->nobjcore->flags &= ~OC_F_BUSY;
+		sp->wrk->nobjcore->obj = (void*)(so->offset + sc->ptr);
 		memcpy(sp->wrk->nobjhead->digest, so->hash, SHA256_LEN);
 		(void)HSH_Insert(sp);
 	}

Modified: trunk/varnish-cache/bin/varnishtest/tests/p0000.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/p0000.vtc	2009-03-09 14:27:28 UTC (rev 3907)
+++ trunk/varnish-cache/bin/varnishtest/tests/p0000.vtc	2009-03-10 10:11:25 UTC (rev 3908)
@@ -23,11 +23,11 @@
 
 varnish v1 -start
 
-#client c1 {
-#	txreq -url "/"
-#	rxresp
-#	expect resp.status == 200
-#	expect resp.http.X-Varnish == "1001"
-#} -run
+client c1 {
+	txreq -url "/"
+	rxresp
+	expect resp.status == 200
+	expect resp.http.X-Varnish == "1001"
+} -run
 
-shell "rm -f /tmp/__v1/_.per"
+# shell "rm -f /tmp/__v1/_.per"



More information about the varnish-commit mailing list