From: phk Date: Fri, 20 Feb 2009 17:21:30 +0000 (+0000) Subject: Put the cleanup next to the preallocation and remember to release X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7b87dbbc53a01c8d6df6be08cfe10b4b47d267ea;p=varnish Put the cleanup next to the preallocation and remember to release the preallocated objcore git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@3797 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- diff --git a/varnish-cache/bin/varnishd/cache_hash.c b/varnish-cache/bin/varnishd/cache_hash.c index f416e28d..70c7bf31 100644 --- a/varnish-cache/bin/varnishd/cache_hash.c +++ b/varnish-cache/bin/varnishd/cache_hash.c @@ -140,6 +140,27 @@ HSH_Prealloc(struct sess *sp) CHECK_OBJ_NOTNULL(w->nobj, OBJECT_MAGIC); } +void +HSH_Cleanup(struct worker *w) +{ + + if (w->nobjcore != NULL) { + FREE_OBJ(w->nobjcore); + w->nobjcore = NULL; + } + if (w->nobjhead != NULL) { + Lck_Delete(&w->nobjhead->mtx); + FREE_OBJ(w->nobjhead); + w->nobjhead = NULL; + w->stats->n_objecthead--; + } + if (w->nobj != NULL) { + STV_free(w->nobj->objstore); + w->nobj = NULL; + w->stats->n_object--; + } +} + void HSH_DeleteObjHead(struct worker *w, struct objhead *oh) { diff --git a/varnish-cache/bin/varnishd/cache_pool.c b/varnish-cache/bin/varnishd/cache_pool.c index 5c3b363d..e555ef07 100644 --- a/varnish-cache/bin/varnishd/cache_pool.c +++ b/varnish-cache/bin/varnishd/cache_pool.c @@ -365,12 +365,8 @@ wrk_thread(void *priv) AZ(pthread_cond_destroy(&w->cond)); if (w->srcaddr != NULL) free(w->srcaddr); - if (w->nobjhead != NULL) { - Lck_Delete(&w->nobjhead->mtx); - FREE_OBJ(w->nobjhead); - } - if (w->nobj!= NULL) - STV_free(w->nobj->objstore); + HSH_Cleanup(w); + WRK_SumStat(w); return (NULL); } diff --git a/varnish-cache/bin/varnishd/hash_slinger.h b/varnish-cache/bin/varnishd/hash_slinger.h index c52bc4d0..c6f8df15 100644 --- a/varnish-cache/bin/varnishd/hash_slinger.h +++ b/varnish-cache/bin/varnishd/hash_slinger.h @@ -30,6 +30,7 @@ */ struct sess; +struct worker; struct object; typedef void hash_init_f(int ac, char * const *av); @@ -50,6 +51,7 @@ struct hash_slinger { /* cache_hash.c */ void HSH_Prealloc(struct sess *sp); +void HSH_Cleanup(struct worker *w); void HSH_Freestore(struct object *o); void HSH_Copy(const struct sess *sp, struct objhead *o); struct object *HSH_Lookup(struct sess *sp);