Commit 56234c12 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Move the EXP_Touch() logic into EXP_Touch().

parent 7dd89f87
......@@ -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);
......
......@@ -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);
}
/*--------------------------------------------------------------------
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment