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

Move the hash'ers refcount up to objhead, it is generic.



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@3404 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 47cba392
...@@ -297,6 +297,7 @@ struct objhead { ...@@ -297,6 +297,7 @@ struct objhead {
void *hashpriv; void *hashpriv;
struct lock mtx; struct lock mtx;
unsigned refcnt;
VTAILQ_HEAD(,object) objects; VTAILQ_HEAD(,object) objects;
char *hash; char *hash;
unsigned hashlen; unsigned hashlen;
......
...@@ -49,7 +49,6 @@ struct hcl_entry { ...@@ -49,7 +49,6 @@ struct hcl_entry {
VTAILQ_ENTRY(hcl_entry) list; VTAILQ_ENTRY(hcl_entry) list;
struct hcl_hd *head; struct hcl_hd *head;
struct objhead *oh; struct objhead *oh;
unsigned refcnt;
unsigned digest; unsigned digest;
unsigned hash; unsigned hash;
}; };
...@@ -167,7 +166,7 @@ hcl_lookup(const struct sess *sp, struct objhead *noh) ...@@ -167,7 +166,7 @@ hcl_lookup(const struct sess *sp, struct objhead *noh)
continue; continue;
if (i > 0) if (i > 0)
break; break;
he->refcnt++; he->oh->refcnt++;
roh = he->oh; roh = he->oh;
Lck_Unlock(&hp->mtx); Lck_Unlock(&hp->mtx);
/* /*
...@@ -191,7 +190,7 @@ hcl_lookup(const struct sess *sp, struct objhead *noh) ...@@ -191,7 +190,7 @@ hcl_lookup(const struct sess *sp, struct objhead *noh)
VTAILQ_INSERT_BEFORE(he, he2, list); VTAILQ_INSERT_BEFORE(he, he2, list);
else else
VTAILQ_INSERT_TAIL(&hp->head, he2, list); VTAILQ_INSERT_TAIL(&hp->head, he2, list);
he2->refcnt++; he2->oh->refcnt++;
noh = he2->oh; noh = he2->oh;
Lck_Unlock(&hp->mtx); Lck_Unlock(&hp->mtx);
return (noh); return (noh);
...@@ -231,11 +230,11 @@ hcl_deref(const struct objhead *oh) ...@@ -231,11 +230,11 @@ hcl_deref(const struct objhead *oh)
CAST_OBJ_NOTNULL(he, oh->hashpriv, HCL_ENTRY_MAGIC); CAST_OBJ_NOTNULL(he, oh->hashpriv, HCL_ENTRY_MAGIC);
hp = he->head; hp = he->head;
CHECK_OBJ_NOTNULL(hp, HCL_HEAD_MAGIC); CHECK_OBJ_NOTNULL(hp, HCL_HEAD_MAGIC);
assert(he->refcnt > 0); assert(he->oh->refcnt > 0);
assert(he->hash < hcl_nhash); assert(he->hash < hcl_nhash);
assert(hp == &hcl_head[he->hash]); assert(hp == &hcl_head[he->hash]);
Lck_Lock(&hp->mtx); Lck_Lock(&hp->mtx);
if (--he->refcnt == 0) if (--he->oh->refcnt == 0)
VTAILQ_REMOVE(&hp->head, he, list); VTAILQ_REMOVE(&hp->head, he, list);
else else
he = NULL; he = NULL;
......
...@@ -47,7 +47,6 @@ ...@@ -47,7 +47,6 @@
struct hsl_entry { struct hsl_entry {
VTAILQ_ENTRY(hsl_entry) list; VTAILQ_ENTRY(hsl_entry) list;
struct objhead *oh; struct objhead *oh;
unsigned refcnt;
}; };
static VTAILQ_HEAD(, hsl_entry) hsl_head = VTAILQ_HEAD_INITIALIZER(hsl_head); 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) ...@@ -85,7 +84,7 @@ hsl_lookup(const struct sess *sp, struct objhead *noh)
continue; continue;
if (i > 0) if (i > 0)
break; break;
he->refcnt++; he->oh->refcnt++;
noh = he->oh; noh = he->oh;
Lck_Unlock(&hsl_mtx); Lck_Unlock(&hsl_mtx);
return (noh); return (noh);
...@@ -94,7 +93,7 @@ hsl_lookup(const struct sess *sp, struct objhead *noh) ...@@ -94,7 +93,7 @@ hsl_lookup(const struct sess *sp, struct objhead *noh)
he2 = calloc(sizeof *he2, 1); he2 = calloc(sizeof *he2, 1);
XXXAN(he2); XXXAN(he2);
he2->oh = noh; he2->oh = noh;
he2->refcnt = 1; he2->oh->refcnt = 1;
noh->hashpriv = he2; noh->hashpriv = he2;
noh->hash = malloc(sp->lhashptr); noh->hash = malloc(sp->lhashptr);
...@@ -124,7 +123,7 @@ hsl_deref(const struct objhead *oh) ...@@ -124,7 +123,7 @@ hsl_deref(const struct objhead *oh)
AN(oh->hashpriv); AN(oh->hashpriv);
he = oh->hashpriv; he = oh->hashpriv;
Lck_Lock(&hsl_mtx); Lck_Lock(&hsl_mtx);
if (--he->refcnt == 0) { if (--he->oh->refcnt == 0) {
VTAILQ_REMOVE(&hsl_head, he, list); VTAILQ_REMOVE(&hsl_head, he, list);
free(he); free(he);
ret = 0; ret = 0;
......
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