Commit 6402f792 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Put the cleanup next to the preallocation and remember to release

the preallocated objcore



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@3797 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 98b2ef2f
......@@ -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)
{
......
......@@ -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);
}
......
......@@ -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);
......
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