Commit 00e11b88 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Make cache_expire.c pick up its own reference on the object.


git-svn-id: http://www.varnish-cache.org/svn/trunk@2536 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 0cbcee38
...@@ -438,7 +438,7 @@ extern pthread_t cli_thread; ...@@ -438,7 +438,7 @@ extern pthread_t cli_thread;
#define ASSERT_CLI() do {assert(pthread_self() == cli_thread);} while (0) #define ASSERT_CLI() do {assert(pthread_self() == cli_thread);} while (0)
/* cache_expiry.c */ /* cache_expiry.c */
void EXP_Insert(struct object *o); void EXP_Insert(struct object *o, double now);
void EXP_Init(void); void EXP_Init(void);
void EXP_Rearm(struct object *o); void EXP_Rearm(struct object *o);
void EXP_Touch(struct object *o, double now); void EXP_Touch(struct object *o, double now);
......
...@@ -374,7 +374,7 @@ cnt_fetch(struct sess *sp) ...@@ -374,7 +374,7 @@ cnt_fetch(struct sess *sp)
sp->obj->cacheable = 1; sp->obj->cacheable = 1;
if (sp->obj->objhead != NULL) { if (sp->obj->objhead != NULL) {
VRY_Create(sp); VRY_Create(sp);
HSH_Ref(sp->obj); /* get another, STP_DELIVER will deref */ EXP_Insert(sp->obj, sp->wrk->used);
HSH_Unbusy(sp->obj); HSH_Unbusy(sp->obj);
} }
sp->wrk->acct.fetch++; sp->wrk->acct.fetch++;
......
...@@ -86,12 +86,16 @@ update_object_when(struct object *o) ...@@ -86,12 +86,16 @@ update_object_when(struct object *o)
/*--------------------------------------------------------------------*/ /*--------------------------------------------------------------------*/
void void
EXP_Insert(struct object *o) EXP_Insert(struct object *o, double now)
{ {
CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
assert(o->busy);
assert(o->cacheable);
HSH_Ref(o);
assert(o->timer_idx == 0); assert(o->timer_idx == 0);
update_object_when(o); update_object_when(o);
o->lru_stamp = now;
LOCK(&exp_mtx); LOCK(&exp_mtx);
binheap_insert(exp_heap, o); binheap_insert(exp_heap, o);
VTAILQ_INSERT_TAIL(&exp_lru, o, deathrow); VTAILQ_INSERT_TAIL(&exp_lru, o, deathrow);
......
...@@ -264,11 +264,6 @@ HSH_Lookup(struct sess *sp) ...@@ -264,11 +264,6 @@ HSH_Lookup(struct sess *sp)
} }
UNLOCK(&oh->mtx); UNLOCK(&oh->mtx);
BAN_NewObj(o); 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); return (o);
} }
...@@ -297,8 +292,6 @@ HSH_Unbusy(struct object *o) ...@@ -297,8 +292,6 @@ HSH_Unbusy(struct object *o)
CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
assert(o->busy); assert(o->busy);
assert(o->refcnt > 0); assert(o->refcnt > 0);
if (o->cacheable)
EXP_Insert(o);
oh = o->objhead; oh = o->objhead;
if (oh != NULL) { if (oh != NULL) {
CHECK_OBJ(oh, OBJHEAD_MAGIC); CHECK_OBJ(oh, OBJHEAD_MAGIC);
......
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