[master] abf653c Argument polishing

Poul-Henning Kamp phk at varnish-cache.org
Wed Feb 9 14:50:27 CET 2011


commit abf653cdd5f6f5ac057f876fef2904c3a2db245f
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Wed Feb 9 13:07:49 2011 +0000

    Argument polishing

diff --git a/bin/varnishd/cache.h b/bin/varnishd/cache.h
index be209a7..0ab2dc1 100644
--- a/bin/varnishd/cache.h
+++ b/bin/varnishd/cache.h
@@ -632,7 +632,7 @@ void EXP_Insert(struct object *o);
 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);
+int EXP_Touch(struct objcore *oc);
 int EXP_NukeOne(const struct sess *sp, struct lru *lru);
 
 /* cache_fetch.c */
diff --git a/bin/varnishd/cache_center.c b/bin/varnishd/cache_center.c
index 96e585e..48f9c15 100644
--- a/bin/varnishd/cache_center.c
+++ b/bin/varnishd/cache_center.c
@@ -208,8 +208,9 @@ cnt_deliver(struct sess *sp)
 
 	sp->t_resp = TIM_real();
 	if (sp->obj->objcore != NULL) {
-		if ((sp->t_resp - sp->obj->last_lru) > params->lru_timeout)
-			EXP_Touch(sp->obj, sp->t_resp);
+		if ((sp->t_resp - sp->obj->last_lru) > params->lru_timeout &&
+		    EXP_Touch(sp->obj->objcore))
+			sp->obj->last_lru = sp->t_resp;
 		sp->obj->last_use = sp->t_resp;	/* XXX: locking ? */
 	}
 	sp->wrk->resp = sp->wrk->http[2];
diff --git a/bin/varnishd/cache_expire.c b/bin/varnishd/cache_expire.c
index 32de4a3..1da3532 100644
--- a/bin/varnishd/cache_expire.c
+++ b/bin/varnishd/cache_expire.c
@@ -156,14 +156,11 @@ EXP_Insert(struct object *o)
  * This optimization obviously leaves the LRU list imperfectly sorted.
  */
 
-void
-EXP_Touch(struct object *o, double tnow)
+int
+EXP_Touch(struct objcore *oc)
 {
-	struct objcore *oc;
 	struct lru *lru;
 
-	CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
-	oc = o->objcore;
 	CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
 
 	/*
@@ -174,7 +171,7 @@ EXP_Touch(struct object *o, double tnow)
 	 * the cleaner from doing its job.
 	 */
 	if (oc->flags & OC_F_LRUDONTMOVE)
-		return;
+		return (0);
 
 	lru = oc_getlru(oc);
 	CHECK_OBJ_NOTNULL(lru, LRU_MAGIC);
@@ -186,16 +183,15 @@ EXP_Touch(struct object *o, double tnow)
 	 * reduce contention a fair bit
 	 */
 	if (Lck_Trylock(&lru->mtx))
-		return;
+		return (0);
 
 	if (oc->timer_idx != BINHEAP_NOIDX) {
 		VTAILQ_REMOVE(&lru->lru_head, oc, lru_list);
 		VTAILQ_INSERT_TAIL(&lru->lru_head, oc, lru_list);
 		VSC_main->n_lru_moved++;
-		o->last_lru = tnow;
 	}
-
 	Lck_Unlock(&lru->mtx);
+	return (1);
 }
 
 /*--------------------------------------------------------------------



More information about the varnish-commit mailing list