]> err.no Git - varnish/commitdiff
Move the LRU timestamp from the objcore to the object, we only access
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Thu, 12 Feb 2009 22:26:44 +0000 (22:26 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Thu, 12 Feb 2009 22:26:44 +0000 (22:26 +0000)
it when we have used the object anyway.

git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@3757 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishd/cache.h
varnish-cache/bin/varnishd/cache_center.c
varnish-cache/bin/varnishd/cache_expire.c

index e8486542a0f6cb86c6f48497c07247090dac7734..0101ee34e4d4db4cb8cdd780a7f885ac13605cef 100644 (file)
@@ -267,7 +267,6 @@ struct objcore {
        VTAILQ_ENTRY(objcore)   list;
        VTAILQ_ENTRY(objcore)   lru_list;
        int                     on_lru;
-       double                  lru_stamp;
 };
 
 /* Object structure --------------------------------------------------*/
@@ -302,6 +301,7 @@ struct object {
        double                  prefetch;
 
        double                  last_modified;
+       double                  last_lru;
 
        struct http             http[1];
 
@@ -463,7 +463,7 @@ extern pthread_t cli_thread;
 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 */
index fea97a13282cdde37aeb115e9123d72f4c4334f2..895c2061365486132a3afa7089a552e02fab0c2c 100644 (file)
@@ -159,8 +159,10 @@ cnt_deliver(struct sess *sp)
 
        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);
index 315b65ea9a5a62c103de643a1c94acdb2d3cf314..8d14e89ac2e9b797b61d62b08e6fa61469015a89 100644 (file)
@@ -133,7 +133,7 @@ EXP_Insert(struct object *o)
        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);
@@ -153,27 +153,27 @@ EXP_Insert(struct object *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);
 }
 
 /*--------------------------------------------------------------------