From eadf6619ace01d7d51bd25343c5659b216eb6e4f Mon Sep 17 00:00:00 2001 From: phk Date: Mon, 16 Feb 2009 15:06:18 +0000 Subject: [PATCH] Move the object busy flag up to the objcore. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@3773 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- varnish-cache/bin/varnishd/cache.h | 11 +++++++++-- varnish-cache/bin/varnishd/cache_center.c | 3 +-- varnish-cache/bin/varnishd/cache_expire.c | 2 +- varnish-cache/bin/varnishd/cache_fetch.c | 3 ++- varnish-cache/bin/varnishd/cache_hash.c | 10 +++++----- varnish-cache/bin/varnishd/cache_vrt_esi.c | 3 +-- 6 files changed, 19 insertions(+), 13 deletions(-) diff --git a/varnish-cache/bin/varnishd/cache.h b/varnish-cache/bin/varnishd/cache.h index 76ea74f5..80e6008c 100644 --- a/varnish-cache/bin/varnishd/cache.h +++ b/varnish-cache/bin/varnishd/cache.h @@ -267,6 +267,7 @@ struct objcore { #define OC_T_PREFETCH 2 unsigned char flags; #define OC_F_ONLRU (1<<0) +#define OC_F_BUSY (1<<1) unsigned timer_idx; VTAILQ_ENTRY(objcore) list; VTAILQ_ENTRY(objcore) lru_list; @@ -294,7 +295,6 @@ struct object { unsigned cacheable; - unsigned busy; unsigned len; double age; @@ -416,7 +416,6 @@ struct vbe_conn { /* Prototypes etc ----------------------------------------------------*/ - /* cache_acceptor.c */ void vca_return_session(struct sess *sp); void vca_close_session(struct sess *sp, const char *why); @@ -698,3 +697,11 @@ Tadd(txt *t, const char *p, int l) t->b = t->e; } } + +static inline unsigned +ObjIsBusy(const struct object *o) +{ + CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); + CHECK_OBJ_NOTNULL(o->objcore, OBJCORE_MAGIC); + return (o->objcore->flags & OC_F_BUSY); +} diff --git a/varnish-cache/bin/varnishd/cache_center.c b/varnish-cache/bin/varnishd/cache_center.c index 895c2061..746da36a 100644 --- a/varnish-cache/bin/varnishd/cache_center.c +++ b/varnish-cache/bin/varnishd/cache_center.c @@ -601,7 +601,7 @@ cnt_lookup(struct sess *sp) sp->obj = o; /* If we inserted a new object it's a miss */ - if (sp->obj->busy) { + if (ObjIsBusy(sp->obj)) { VSL_stats->cache_miss++; sp->step = STP_MISS; return (0); @@ -730,7 +730,6 @@ cnt_pass(struct sess *sp) HSH_Prealloc(sp); sp->obj = sp->wrk->nobj; sp->wrk->nobj = NULL; - sp->obj->busy = 1; sp->sendbody = 1; sp->step = STP_FETCH; return (0); diff --git a/varnish-cache/bin/varnishd/cache_expire.c b/varnish-cache/bin/varnishd/cache_expire.c index e69393ff..27eca861 100644 --- a/varnish-cache/bin/varnishd/cache_expire.c +++ b/varnish-cache/bin/varnishd/cache_expire.c @@ -128,7 +128,7 @@ EXP_Insert(struct object *o) struct objcore *oc; CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); - assert(o->busy); + AN(ObjIsBusy(o)); assert(o->cacheable); HSH_Ref(o); CHECK_OBJ_NOTNULL(o->objcore, OBJCORE_MAGIC); diff --git a/varnish-cache/bin/varnishd/cache_fetch.c b/varnish-cache/bin/varnishd/cache_fetch.c index a82fe27a..fd08aecb 100644 --- a/varnish-cache/bin/varnishd/cache_fetch.c +++ b/varnish-cache/bin/varnishd/cache_fetch.c @@ -326,7 +326,8 @@ Fetch(struct sess *sp) CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC); CHECK_OBJ_NOTNULL(sp->bereq, BEREQ_MAGIC); AN(sp->director); - AN(sp->obj->busy); + if (sp->obj->objcore != NULL) /* pass has no objcore */ + AN(ObjIsBusy(sp->obj)); AN(sp->bereq); w = sp->wrk; bereq = sp->bereq; diff --git a/varnish-cache/bin/varnishd/cache_hash.c b/varnish-cache/bin/varnishd/cache_hash.c index dda20d31..8049a2d1 100644 --- a/varnish-cache/bin/varnishd/cache_hash.c +++ b/varnish-cache/bin/varnishd/cache_hash.c @@ -96,6 +96,7 @@ HSH_Prealloc(struct sess *sp) if (w->nobjcore == NULL) { ALLOC_OBJ(oc, OBJCORE_MAGIC); w->nobjcore = oc; + oc->flags |= OC_F_BUSY; } CHECK_OBJ_NOTNULL(w->nobjcore, OBJCORE_MAGIC); @@ -126,7 +127,6 @@ HSH_Prealloc(struct sess *sp) http_Setup(o->http, o->ws_o); o->magic = OBJECT_MAGIC; o->http->magic = HTTP_MAGIC; - o->busy = 1; o->refcnt = 1; o->grace = NAN; o->entered = NAN; @@ -269,7 +269,7 @@ HSH_Lookup(struct sess *sp) o = oc->obj; CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); - if (o->busy) { + if (ObjIsBusy(o)) { busy_o = o; continue; } @@ -377,7 +377,7 @@ HSH_Drop(struct sess *sp) CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); o = sp->obj; CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); - assert(o->busy); + AN(ObjIsBusy(o)); assert(o->refcnt > 0); o->ttl = 0; o->cacheable = 0; @@ -395,7 +395,7 @@ HSH_Unbusy(const struct sess *sp) CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); o = sp->obj; CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); - assert(o->busy); + AN(ObjIsBusy(o)); assert(o->refcnt > 0); if (o->ws_o->overflow) VSL_stats->n_objoverflow++; @@ -408,7 +408,7 @@ HSH_Unbusy(const struct sess *sp) CHECK_OBJ(oh, OBJHEAD_MAGIC); Lck_Lock(&oh->mtx); } - o->busy = 0; + o->objcore->flags &= ~OC_F_BUSY; if (oh != NULL) hsh_rush(oh); parent = o->parent; diff --git a/varnish-cache/bin/varnishd/cache_vrt_esi.c b/varnish-cache/bin/varnishd/cache_vrt_esi.c index 5ce829b1..d92c628f 100644 --- a/varnish-cache/bin/varnishd/cache_vrt_esi.c +++ b/varnish-cache/bin/varnishd/cache_vrt_esi.c @@ -643,8 +643,7 @@ VRT_ESI(struct sess *sp) CHECK_OBJ_NOTNULL(sp, SESS_MAGIC); CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC); - - assert(sp->obj->busy); + AN(ObjIsBusy(sp->obj)); if (sp->cur_method != VCL_MET_FETCH) { /* XXX: we should catch this at compile time */ WSP(sp, SLT_VCL_error, -- 2.39.5