Commit bc7e06ec authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Move the object busy flag up to the objcore.



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@3773 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 6ece6e46
......@@ -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);
}
......@@ -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);
......
......@@ -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);
......
......@@ -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;
......
......@@ -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;
......
......@@ -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,
......
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