VTAILQ_ENTRY(objcore) list;
VTAILQ_ENTRY(objcore) lru_list;
int on_lru;
- double lru_stamp;
};
/* Object structure --------------------------------------------------*/
double prefetch;
double last_modified;
+ double last_lru;
struct http http[1];
void EXP_Insert(struct object *o);
void EXP_Init(void);
void EXP_Rearm(const struct object *o);
-void EXP_Touch(const struct object *o, double now);
+int EXP_Touch(const struct object *o);
int EXP_NukeOne(struct sess *sp);
/* cache_fetch.c */
sp->t_resp = TIM_real();
if (sp->obj->objhead != NULL) {
+ if ((sp->t_resp - sp->obj->last_lru) > params->lru_timeout &&
+ EXP_Touch(sp->obj))
+ sp->obj->last_lru = sp->t_resp; /* XXX: locking ? */
sp->obj->last_use = sp->t_resp; /* XXX: locking ? */
- EXP_Touch(sp->obj, sp->t_resp);
}
RES_BuildHttp(sp);
VCL_deliver_method(sp);
oc = o->objcore;
assert(o->entered != 0 && !isnan(o->entered));
- oc->lru_stamp = o->entered;
+ o->last_lru = o->entered;
Lck_Lock(&exp_mtx);
assert(oc->timer_idx == BINHEAP_NOIDX);
(void)update_object_when(o);
* that can be worked around by examining obj.last_use in vcl_discard{}
*/
-void
-EXP_Touch(const struct object *o, double now)
+int
+EXP_Touch(const struct object *o)
{
struct objcore *oc;
+ int retval = 0;
CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
oc = o->objcore;
if (oc == NULL)
- return;
+ return (retval);
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
- if (oc->lru_stamp + params->lru_timeout > now)
- return;
if (Lck_Trylock(&exp_mtx))
- return;
+ return (retval);
if (oc->on_lru) {
VTAILQ_REMOVE(&lru, oc, lru_list);
VTAILQ_INSERT_TAIL(&lru, oc, lru_list);
- oc->lru_stamp = now;
VSL_stats->n_lru_moved++;
+ retval = 1;
}
Lck_Unlock(&exp_mtx);
+ return (retval);
}
/*--------------------------------------------------------------------