]> err.no Git - varnish/commitdiff
Make cache_expire.c pick up its own reference on the object.
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Sat, 23 Feb 2008 20:03:51 +0000 (20:03 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Sat, 23 Feb 2008 20:03:51 +0000 (20:03 +0000)
git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@2536 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
varnish-cache/bin/varnishd/cache_hash.c

index c18a6b185c6902730f7988c9ef4c2360042af56c..b127789e2b10b1856b3a86120c6d252649f17e28 100644 (file)
@@ -438,7 +438,7 @@ extern pthread_t cli_thread;
 #define ASSERT_CLI() do {assert(pthread_self() == cli_thread);} while (0)
 
 /* cache_expiry.c */
-void EXP_Insert(struct object *o);
+void EXP_Insert(struct object *o, double now);
 void EXP_Init(void);
 void EXP_Rearm(struct object *o);
 void EXP_Touch(struct object *o, double now);
index fab7232c35931bd8572890da19c61d6e376aa3f3..01ed8bb7c3e2788c222677c395cd88793c789302 100644 (file)
@@ -374,7 +374,7 @@ cnt_fetch(struct sess *sp)
        sp->obj->cacheable = 1;
        if (sp->obj->objhead != NULL) {
                VRY_Create(sp);
-               HSH_Ref(sp->obj); /* get another, STP_DELIVER will deref */
+               EXP_Insert(sp->obj, sp->wrk->used);
                HSH_Unbusy(sp->obj);
        }
        sp->wrk->acct.fetch++;
index a870b0d40e6318e41dc984d991b485320f7b06d7..891e4e69afb3a1c415fc8e5c5414232163145e92 100644 (file)
@@ -86,12 +86,16 @@ update_object_when(struct object *o)
 /*--------------------------------------------------------------------*/
 
 void
-EXP_Insert(struct object *o)
+EXP_Insert(struct object *o, double now)
 {
 
        CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
+       assert(o->busy);
+       assert(o->cacheable);
+       HSH_Ref(o);
        assert(o->timer_idx == 0);
        update_object_when(o);
+       o->lru_stamp = now;
        LOCK(&exp_mtx);
        binheap_insert(exp_heap, o);
        VTAILQ_INSERT_TAIL(&exp_lru, o, deathrow);
index eb62ba2a767c330e9b494b579fd7fb1ffc9eed75..2efc1627cc9985d71dd64f29169b08c2ab24142c 100644 (file)
@@ -264,11 +264,6 @@ HSH_Lookup(struct sess *sp)
        }
        UNLOCK(&oh->mtx);
        BAN_NewObj(o);
-       /*
-        * It's cheaper to copy the timestamp here, than to get a new one
-        * in EXP_Insert().
-        */
-       o->lru_stamp = w->used;
        return (o);
 }
 
@@ -297,8 +292,6 @@ HSH_Unbusy(struct object *o)
        CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
        assert(o->busy);
        assert(o->refcnt > 0);
-       if (o->cacheable)
-               EXP_Insert(o);
        oh = o->objhead;
        if (oh != NULL) {
                CHECK_OBJ(oh, OBJHEAD_MAGIC);