Mailing List Archive

r2536 - trunk/varnish-cache/bin/varnishd
Author: phk
Date: 2008-02-23 21:03:51 +0100 (Sat, 23 Feb 2008)
New Revision: 2536

Modified:
trunk/varnish-cache/bin/varnishd/cache.h
trunk/varnish-cache/bin/varnishd/cache_center.c
trunk/varnish-cache/bin/varnishd/cache_expire.c
trunk/varnish-cache/bin/varnishd/cache_hash.c
Log:
Make cache_expire.c pick up its own reference on the object.


Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h 2008-02-23 19:58:04 UTC (rev 2535)
+++ trunk/varnish-cache/bin/varnishd/cache.h 2008-02-23 20:03:51 UTC (rev 2536)
@@ -438,7 +438,7 @@
#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);

Modified: trunk/varnish-cache/bin/varnishd/cache_center.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_center.c 2008-02-23 19:58:04 UTC (rev 2535)
+++ trunk/varnish-cache/bin/varnishd/cache_center.c 2008-02-23 20:03:51 UTC (rev 2536)
@@ -374,7 +374,7 @@
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++;

Modified: trunk/varnish-cache/bin/varnishd/cache_expire.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_expire.c 2008-02-23 19:58:04 UTC (rev 2535)
+++ trunk/varnish-cache/bin/varnishd/cache_expire.c 2008-02-23 20:03:51 UTC (rev 2536)
@@ -86,12 +86,16 @@
/*--------------------------------------------------------------------*/

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);

Modified: trunk/varnish-cache/bin/varnishd/cache_hash.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_hash.c 2008-02-23 19:58:04 UTC (rev 2535)
+++ trunk/varnish-cache/bin/varnishd/cache_hash.c 2008-02-23 20:03:51 UTC (rev 2536)
@@ -264,11 +264,6 @@
}
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 @@
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);