From: phk Date: Sat, 23 Feb 2008 20:03:51 +0000 (+0000) Subject: Make cache_expire.c pick up its own reference on the object. X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=89b9b9b7d17b053233316aa02da4e7d95cf631bc;p=varnish Make cache_expire.c pick up its own reference on the object. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@2536 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- diff --git a/varnish-cache/bin/varnishd/cache.h b/varnish-cache/bin/varnishd/cache.h index c18a6b18..b127789e 100644 --- a/varnish-cache/bin/varnishd/cache.h +++ b/varnish-cache/bin/varnishd/cache.h @@ -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); diff --git a/varnish-cache/bin/varnishd/cache_center.c b/varnish-cache/bin/varnishd/cache_center.c index fab7232c..01ed8bb7 100644 --- a/varnish-cache/bin/varnishd/cache_center.c +++ b/varnish-cache/bin/varnishd/cache_center.c @@ -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++; diff --git a/varnish-cache/bin/varnishd/cache_expire.c b/varnish-cache/bin/varnishd/cache_expire.c index a870b0d4..891e4e69 100644 --- a/varnish-cache/bin/varnishd/cache_expire.c +++ b/varnish-cache/bin/varnishd/cache_expire.c @@ -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); diff --git a/varnish-cache/bin/varnishd/cache_hash.c b/varnish-cache/bin/varnishd/cache_hash.c index eb62ba2a..2efc1627 100644 --- a/varnish-cache/bin/varnishd/cache_hash.c +++ b/varnish-cache/bin/varnishd/cache_hash.c @@ -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);