Commit ae96ce0a authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Make EXP_Touch() responsible for updating the o->last_lru timestamp.

Various minor nits



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@5581 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 49d58be1
...@@ -571,7 +571,7 @@ void EXP_Insert(struct object *o); ...@@ -571,7 +571,7 @@ 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 ttl);
void EXP_Init(void); void EXP_Init(void);
void EXP_Rearm(const struct object *o); void EXP_Rearm(const struct object *o);
int EXP_Touch(const struct object *o); void EXP_Touch(struct object *o, double tnow);
int EXP_NukeOne(const struct sess *sp, const struct lru *lru); int EXP_NukeOne(const struct sess *sp, const struct lru *lru);
/* cache_fetch.c */ /* cache_fetch.c */
......
...@@ -179,9 +179,8 @@ cnt_deliver(struct sess *sp) ...@@ -179,9 +179,8 @@ cnt_deliver(struct sess *sp)
sp->t_resp = TIM_real(); sp->t_resp = TIM_real();
if (sp->obj->objcore != NULL) { if (sp->obj->objcore != NULL) {
if ((sp->t_resp - sp->obj->last_lru) > params->lru_timeout && if ((sp->t_resp - sp->obj->last_lru) > params->lru_timeout)
EXP_Touch(sp->obj)) EXP_Touch(sp->obj, sp->t_resp);
sp->obj->last_lru = sp->t_resp; /* XXX: locking ? */
sp->obj->last_use = sp->t_resp; /* XXX: locking ? */ sp->obj->last_use = sp->t_resp; /* XXX: locking ? */
} }
sp->wrk->resp = sp->wrk->http[2]; sp->wrk->resp = sp->wrk->http[2];
......
...@@ -154,17 +154,14 @@ EXP_Insert(struct object *o) ...@@ -154,17 +154,14 @@ EXP_Insert(struct object *o)
* This optimization obviously leaves the LRU list imperfectly sorted. * This optimization obviously leaves the LRU list imperfectly sorted.
*/ */
int void
EXP_Touch(const struct object *o) EXP_Touch(struct object *o, double tnow)
{ {
int retval;
struct objcore *oc; struct objcore *oc;
struct lru *lru; struct lru *lru;
CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
oc = o->objcore; oc = o->objcore;
if (oc == NULL)
return (0);
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC); CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
/* /*
...@@ -175,21 +172,22 @@ EXP_Touch(const struct object *o) ...@@ -175,21 +172,22 @@ EXP_Touch(const struct object *o)
* the cleaner from doing its job. * the cleaner from doing its job.
*/ */
if (oc->flags & OC_F_LRUDONTMOVE) if (oc->flags & OC_F_LRUDONTMOVE)
return (0); return;
lru = STV_lru(o->objstore); lru = STV_lru(o->objstore);
CHECK_OBJ_NOTNULL(lru, LRU_MAGIC); CHECK_OBJ_NOTNULL(lru, LRU_MAGIC);
retval = 0;
if (Lck_Trylock(&exp_mtx)) if (Lck_Trylock(&exp_mtx))
return (retval); return;
if (oc->flags & OC_F_ONLRU) { /* XXX ?? */ if (oc->flags & OC_F_ONLRU) { /* XXX ?? */
VLIST_REMOVE(oc, lru_list); VLIST_REMOVE(oc, lru_list);
VLIST_INSERT_BEFORE(&lru->senteniel, oc, lru_list); VLIST_INSERT_BEFORE(&lru->senteniel, oc, lru_list);
VSC_main->n_lru_moved++; VSC_main->n_lru_moved++;
retval = 1; o->last_lru = tnow;
} }
Lck_Unlock(&exp_mtx); Lck_Unlock(&exp_mtx);
return (retval);
} }
/*-------------------------------------------------------------------- /*--------------------------------------------------------------------
......
...@@ -305,6 +305,7 @@ default_oc_freeobj(struct objcore *oc) ...@@ -305,6 +305,7 @@ default_oc_freeobj(struct objcore *oc)
CAST_OBJ_NOTNULL(o, oc->priv, OBJECT_MAGIC); CAST_OBJ_NOTNULL(o, oc->priv, OBJECT_MAGIC);
oc->priv = NULL; oc->priv = NULL;
oc->methods = NULL;
STV_Freestore(o); STV_Freestore(o);
STV_free(o->objstore); STV_free(o->objstore);
......
...@@ -29,6 +29,8 @@ ...@@ -29,6 +29,8 @@
* *
* XXX: Before we start the client or maybe after it stops, we should give the * XXX: Before we start the client or maybe after it stops, we should give the
* XXX: stevedores a chance to examine their storage for consistency. * XXX: stevedores a chance to examine their storage for consistency.
*
* XXX: Do we ever free the LRU-lists ?
*/ */
#include "config.h" #include "config.h"
......
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