]> err.no Git - varnish/commitdiff
Put the cleanup next to the preallocation and remember to release
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Fri, 20 Feb 2009 17:21:30 +0000 (17:21 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Fri, 20 Feb 2009 17:21:30 +0000 (17:21 +0000)
the preallocated objcore

git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@3797 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishd/cache_hash.c
varnish-cache/bin/varnishd/cache_pool.c
varnish-cache/bin/varnishd/hash_slinger.h

index f416e28d2a335425ce6c8e67a2a88d77e0efea37..70c7bf31f47762f774b1714cc5029aaec24f32fb 100644 (file)
@@ -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)
 {
index 5c3b363d4b4caf7de935b3c440fd191dd51c0b57..e555ef071b605ac5c9b65a81a285679097bbe64c 100644 (file)
@@ -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);
 }
 
index c52bc4d03fc40a1dc0d5beec27f1b32d211b9213..c6f8df1596dfa8358171928116e1cfd648d0c285 100644 (file)
@@ -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);