[master] 56234c1 Move the EXP_Touch() logic into EXP_Touch().

Poul-Henning Kamp phk at varnish-cache.org
Mon Nov 11 08:59:46 CET 2013


commit 56234c12da25fdeeb8299c9ae574da25c4d2ae53
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Nov 11 07:59:14 2013 +0000

    Move the EXP_Touch() logic into EXP_Touch().

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 17f7f1f..e7bffde 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -915,7 +915,7 @@ void EXP_Inject(struct objcore *oc, struct lru *lru, double when);
 void EXP_Init(void);
 void EXP_Rearm(struct object *o, double now, double ttl, double grace,
     double keep);
-int EXP_Touch(struct objcore *oc);
+void EXP_Touch(struct objcore *oc, double now);
 int EXP_NukeOne(struct busyobj *, struct lru *lru);
 void EXP_NukeLRU(struct worker *wrk, struct vsl_log *vsl, struct lru *lru);
 
diff --git a/bin/varnishd/cache/cache_expire.c b/bin/varnishd/cache/cache_expire.c
index 40f9c33..e3feee9 100644
--- a/bin/varnishd/cache/cache_expire.c
+++ b/bin/varnishd/cache/cache_expire.c
@@ -177,13 +177,19 @@ EXP_Insert(struct objcore *oc)
  * This optimization obviously leaves the LRU list imperfectly sorted.
  */
 
-int
-EXP_Touch(struct objcore *oc)
+void
+EXP_Touch(struct objcore *oc, double now)
 {
 	struct lru *lru;
 
 	CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
 
+	if (oc->busyobj != NULL)
+		return;
+
+	if (now - oc->last_lru < cache_param->lru_timeout)
+		return;
+
 	lru = oc_getlru(oc);
 	CHECK_OBJ_NOTNULL(lru, LRU_MAGIC);
 
@@ -192,21 +198,21 @@ EXP_Touch(struct objcore *oc)
 	 * objects on the lru list, since LRU doesn't really help much.
 	 */
 	if (lru->flags & LRU_F_DONTMOVE)
-		return (0);
+		return;
 
 	if (Lck_Trylock(&lru->mtx))
-		return (0);
+		return;
 
 	AN(oc->flags & OC_F_EXP);
 
 	if (!(oc->flags & OC_F_OFFLRU)) {
-		/* Can only it while it's actually on the LRU list */
+		/* Can only touch it while it's actually on the LRU list */
 		VTAILQ_REMOVE(&lru->lru_head, oc, lru_list);
 		VTAILQ_INSERT_TAIL(&lru->lru_head, oc, lru_list);
 		VSC_C_main->n_lru_moved++;
 	}
+	oc->last_lru = now;
 	Lck_Unlock(&lru->mtx);
-	return (1);
 }
 
 /*--------------------------------------------------------------------
diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c
index 9218584..bab3b61 100644
--- a/bin/varnishd/cache/cache_req_fsm.c
+++ b/bin/varnishd/cache/cache_req_fsm.c
@@ -104,12 +104,8 @@ cnt_deliver(struct worker *wrk, struct req *req)
 	assert(req->obj->objcore->refcnt > 0);
 
 	req->t_resp = W_TIM_real(wrk);
-	if (!(req->obj->objcore->flags & OC_F_PRIVATE)) {
-		if (req->obj->objcore->busyobj == NULL &&
-		    (req->t_resp - req->obj->objcore->last_lru) >
-		    cache_param->lru_timeout && EXP_Touch(req->obj->objcore))
-			req->obj->objcore->last_lru = req->t_resp;
-	}
+	if (!(req->obj->objcore->flags & OC_F_PRIVATE))
+		EXP_Touch(req->obj->objcore, req->t_resp);
 
 	HTTP_Setup(req->resp, req->ws, req->vsl, HTTP_Resp);
 



More information about the varnish-commit mailing list