]> err.no Git - varnish/commitdiff
Move the hash'ers refcount up to objhead, it is generic.
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Wed, 19 Nov 2008 10:21:30 +0000 (10:21 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Wed, 19 Nov 2008 10:21:30 +0000 (10:21 +0000)
git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@3404 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishd/cache.h
varnish-cache/bin/varnishd/hash_classic.c
varnish-cache/bin/varnishd/hash_simple_list.c

index 4267738a5acf9c39900e9729b3f8f9b0b238e4dd..601bdd118b4046006c04ab6748a44f19e5c4e687 100644 (file)
@@ -297,6 +297,7 @@ struct objhead {
        void                    *hashpriv;
 
        struct lock             mtx;
+       unsigned                refcnt;
        VTAILQ_HEAD(,object)    objects;
        char                    *hash;
        unsigned                hashlen;
index fe208d53ecaa853c31a9835e362b24e05e97bde2..280d50ebdfb2f1485976c6e17a16d0498bb706a7 100644 (file)
@@ -49,7 +49,6 @@ struct hcl_entry {
        VTAILQ_ENTRY(hcl_entry) list;
        struct hcl_hd           *head;
        struct objhead          *oh;
-       unsigned                refcnt;
        unsigned                digest;
        unsigned                hash;
 };
@@ -167,7 +166,7 @@ hcl_lookup(const struct sess *sp, struct objhead *noh)
                                continue;
                        if (i > 0)
                                break;
-                       he->refcnt++;
+                       he->oh->refcnt++;
                        roh = he->oh;
                        Lck_Unlock(&hp->mtx);
                        /*
@@ -191,7 +190,7 @@ hcl_lookup(const struct sess *sp, struct objhead *noh)
                                VTAILQ_INSERT_BEFORE(he, he2, list);
                        else
                                VTAILQ_INSERT_TAIL(&hp->head, he2, list);
-                       he2->refcnt++;
+                       he2->oh->refcnt++;
                        noh = he2->oh;
                        Lck_Unlock(&hp->mtx);
                        return (noh);
@@ -231,11 +230,11 @@ hcl_deref(const struct objhead *oh)
        CAST_OBJ_NOTNULL(he, oh->hashpriv, HCL_ENTRY_MAGIC);
        hp = he->head;
        CHECK_OBJ_NOTNULL(hp, HCL_HEAD_MAGIC);
-       assert(he->refcnt > 0);
+       assert(he->oh->refcnt > 0);
        assert(he->hash < hcl_nhash);
        assert(hp == &hcl_head[he->hash]);
        Lck_Lock(&hp->mtx);
-       if (--he->refcnt == 0)
+       if (--he->oh->refcnt == 0)
                VTAILQ_REMOVE(&hp->head, he, list);
        else
                he = NULL;
index ac2ff68c5869f01883e990d033b81b4e1342a9fa..a317b76165d1cce76a402ba14fbbc54deaefe783 100644 (file)
@@ -47,7 +47,6 @@
 struct hsl_entry {
        VTAILQ_ENTRY(hsl_entry) list;
        struct objhead          *oh;
-       unsigned                refcnt;
 };
 
 static VTAILQ_HEAD(, hsl_entry)        hsl_head = VTAILQ_HEAD_INITIALIZER(hsl_head);
@@ -85,7 +84,7 @@ hsl_lookup(const struct sess *sp, struct objhead *noh)
                        continue;
                if (i > 0)
                        break;
-               he->refcnt++;
+               he->oh->refcnt++;
                noh = he->oh;
                Lck_Unlock(&hsl_mtx);
                return (noh);
@@ -94,7 +93,7 @@ hsl_lookup(const struct sess *sp, struct objhead *noh)
                he2 = calloc(sizeof *he2, 1);
                XXXAN(he2);
                he2->oh = noh;
-               he2->refcnt = 1;
+               he2->oh->refcnt = 1;
 
                noh->hashpriv = he2;
                noh->hash = malloc(sp->lhashptr);
@@ -124,7 +123,7 @@ hsl_deref(const struct objhead *oh)
        AN(oh->hashpriv);
        he = oh->hashpriv;
        Lck_Lock(&hsl_mtx);
-       if (--he->refcnt == 0) {
+       if (--he->oh->refcnt == 0) {
                VTAILQ_REMOVE(&hsl_head, he, list);
                free(he);
                ret = 0;