]> err.no Git - varnish/commitdiff
Move the object busy flag up to the objcore.
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Mon, 16 Feb 2009 15:06:18 +0000 (15:06 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Mon, 16 Feb 2009 15:06:18 +0000 (15:06 +0000)
git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@3773 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishd/cache.h
varnish-cache/bin/varnishd/cache_center.c
varnish-cache/bin/varnishd/cache_expire.c
varnish-cache/bin/varnishd/cache_fetch.c
varnish-cache/bin/varnishd/cache_hash.c
varnish-cache/bin/varnishd/cache_vrt_esi.c

index 76ea74f5aa3aa3921984b645f34395dc9fe6ba08..80e6008c7cfc3f2ebed2edb8f2c5a2d6d4fd9f9e 100644 (file)
@@ -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);
+}
index 895c2061365486132a3afa7089a552e02fab0c2c..746da36a177a97084f5fe9018862f68b0cb50e11 100644 (file)
@@ -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);
index e69393fff4ece9274e7f48184430d9b4707cdac5..27eca861819e52f13e23cedf15df1a32d1f14b47 100644 (file)
@@ -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);
index a82fe27a24efc570c46956f4aceb8e7620a542aa..fd08aecbf127ffd357e9fb651f912f74ff821ccb 100644 (file)
@@ -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;
index dda20d319c51068d867d703c8e08821a5b920544..8049a2d11282036c749f4d3852ca430572cfa1d7 100644 (file)
@@ -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;
index 5ce829b13b9c57f3a45356a75275e210b79c74ed..d92c628fdb03a558eb873f6e6e5a186327a4604f 100644 (file)
@@ -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,