r5585 - trunk/varnish-cache/bin/varnishd

phk at varnish-cache.org phk at varnish-cache.org
Mon Nov 22 11:43:28 CET 2010


Author: phk
Date: 2010-11-22 11:43:28 +0100 (Mon, 22 Nov 2010)
New Revision: 5585

Modified:
   trunk/varnish-cache/bin/varnishd/cache.h
   trunk/varnish-cache/bin/varnishd/cache_expire.c
Log:
Clarify expiry/lru insert a little bit



Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h	2010-11-22 10:28:32 UTC (rev 5584)
+++ trunk/varnish-cache/bin/varnishd/cache.h	2010-11-22 10:43:28 UTC (rev 5585)
@@ -568,7 +568,7 @@
 
 /* cache_expiry.c */
 void EXP_Insert(struct object *o);
-void EXP_Inject(struct objcore *oc, struct lru *lru, double ttl);
+void EXP_Inject(struct objcore *oc, struct lru *lru, double when);
 void EXP_Init(void);
 void EXP_Rearm(const struct object *o);
 void EXP_Touch(struct object *o, double tnow);

Modified: trunk/varnish-cache/bin/varnishd/cache_expire.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_expire.c	2010-11-22 10:28:32 UTC (rev 5584)
+++ trunk/varnish-cache/bin/varnishd/cache_expire.c	2010-11-22 10:43:28 UTC (rev 5585)
@@ -87,6 +87,21 @@
 	return (1);
 }
 
+/*--------------------------------------------------------------------*/
+
+static void
+exp_insert(struct objcore *oc, struct lru *lru)
+{
+	CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
+	CHECK_OBJ_NOTNULL(lru, LRU_MAGIC);
+
+	assert(oc->timer_idx == BINHEAP_NOIDX);
+	binheap_insert(exp_heap, oc);
+	assert(oc->timer_idx != BINHEAP_NOIDX);
+	VLIST_INSERT_BEFORE(&lru->senteniel, oc, lru_list);
+	oc->flags |= OC_F_ONLRU;
+}
+
 /*--------------------------------------------------------------------
  * Object has been added to cache, record in lru & binheap.
  *
@@ -94,19 +109,15 @@
  */
 
 void
-EXP_Inject(struct objcore *oc, struct lru *lru, double ttl)
+EXP_Inject(struct objcore *oc, struct lru *lru, double when)
 {
 
 	CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
 	CHECK_OBJ_NOTNULL(lru, LRU_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);
-	VLIST_INSERT_BEFORE(&lru->senteniel, oc, lru_list);
-	oc->flags |= OC_F_ONLRU;
+	oc->timer_when = when;
+	exp_insert(oc, lru);
 	Lck_Unlock(&exp_mtx);
 }
 
@@ -132,15 +143,12 @@
 
 	assert(o->entered != 0 && !isnan(o->entered));
 	o->last_lru = o->entered;
+
+	lru = STV_lru(o->objstore);
+	CHECK_OBJ_NOTNULL(lru, LRU_MAGIC);
 	Lck_Lock(&exp_mtx);
-	assert(oc->timer_idx == BINHEAP_NOIDX);
 	(void)update_object_when(o);
-	binheap_insert(exp_heap, oc);
-	assert(oc->timer_idx != BINHEAP_NOIDX);
-	lru = STV_lru(o->objstore);
-	CHECK_OBJ_NOTNULL(lru, LRU_MAGIC);
-	VLIST_INSERT_BEFORE(&lru->senteniel, oc, lru_list);
-	oc->flags |= OC_F_ONLRU;
+	exp_insert(oc, lru);
 	Lck_Unlock(&exp_mtx);
 	oc_updatemeta(oc);
 }




More information about the varnish-commit mailing list