r4128 - trunk/varnish-cache/bin/varnishd

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


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

Modified:
   trunk/varnish-cache/bin/varnishd/cache.h
   trunk/varnish-cache/bin/varnishd/cache_expire.c
   trunk/varnish-cache/bin/varnishd/cache_hash.c
   trunk/varnish-cache/bin/varnishd/storage_persistent.c
Log:
Inject persistent objects into the EXP engine.



Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h	2009-06-22 10:36:30 UTC (rev 4127)
+++ trunk/varnish-cache/bin/varnishd/cache.h	2009-06-22 10:56:30 UTC (rev 4128)
@@ -487,6 +487,7 @@
 
 /* cache_expiry.c */
 void EXP_Insert(struct object *o);
+void EXP_Inject(struct objcore *oc, struct objcore_head *lru, double ttl);
 void EXP_Init(void);
 void EXP_Rearm(const struct object *o);
 int EXP_Touch(const struct object *o);

Modified: trunk/varnish-cache/bin/varnishd/cache_expire.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_expire.c	2009-06-22 10:36:30 UTC (rev 4127)
+++ trunk/varnish-cache/bin/varnishd/cache_expire.c	2009-06-22 10:56:30 UTC (rev 4128)
@@ -97,6 +97,31 @@
  */
 
 void
+EXP_Inject(struct objcore *oc, struct objcore_head *lru, double ttl)
+{
+
+	CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
+
+	Lck_Lock(&exp_mtx);
+	assert(oc->timer_idx == BINHEAP_NOIDX);
+	oc->timer_when = ttl;
+	binheap_insert(exp_heap, oc);
+	assert(oc->timer_idx != BINHEAP_NOIDX);
+	if (lru != NULL) {
+		VTAILQ_INSERT_TAIL(lru, oc, lru_list);
+		oc->flags |= OC_F_ONLRU;
+	}
+	Lck_Unlock(&exp_mtx);
+}
+
+/*--------------------------------------------------------------------
+ * Object has been added to cache, record in lru & binheap.
+ *
+ * We grab a reference to the object, which will keep it around until
+ * we decide its time to let it go.
+ */
+
+void
 EXP_Insert(struct object *o)
 {
 	struct objcore *oc;

Modified: trunk/varnish-cache/bin/varnishd/cache_hash.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_hash.c	2009-06-22 10:36:30 UTC (rev 4127)
+++ trunk/varnish-cache/bin/varnishd/cache_hash.c	2009-06-22 10:56:30 UTC (rev 4128)
@@ -408,8 +408,6 @@
 	/* NB: do not deref objhead the new object inherits our reference */
 	Lck_Unlock(&oh->mtx);
 	sp->wrk->stats->n_object++;
-
-	/* XXX: Insert in EXP */
 	return (oc);
 }
 

Modified: trunk/varnish-cache/bin/varnishd/storage_persistent.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/storage_persistent.c	2009-06-22 10:36:30 UTC (rev 4127)
+++ trunk/varnish-cache/bin/varnishd/storage_persistent.c	2009-06-22 10:56:30 UTC (rev 4128)
@@ -800,6 +800,7 @@
 	uint64_t length;
 	struct smp_segment *ss;
 	struct smp_object *so;
+	struct objcore *oc;
 	uint32_t no;
 	double t_now = TIM_real();
 	struct smp_signctx ctx[1];
@@ -819,13 +820,15 @@
 		if (so->ttl < t_now)
 			continue;
 		HSH_Prealloc(sp);
-		sp->wrk->nobjcore->flags |= OC_F_PERSISTENT;
-		sp->wrk->nobjcore->flags &= ~OC_F_BUSY;
-		sp->wrk->nobjcore->obj = (void*)so;
-		sp->wrk->nobjcore->smp_seg = sg;
-		sp->wrk->nobjcore->ban = BAN_RefBan(so->ban, sc->tailban);
+		oc = sp->wrk->nobjcore;
+		oc->flags |= OC_F_PERSISTENT;
+		oc->flags &= ~OC_F_BUSY;
+		oc->obj = (void*)so;
+		oc->smp_seg = sg;
+		oc->ban = BAN_RefBan(so->ban, sc->tailban);
 		memcpy(sp->wrk->nobjhead->digest, so->hash, SHA256_LEN);
 		(void)HSH_Insert(sp);
+		EXP_Inject(oc, NULL, so->ttl);
 		sg->nalloc++;
 	}
 	WRK_SumStat(sp->wrk);



More information about the varnish-commit mailing list