r3797 - trunk/varnish-cache/bin/varnishd

phk at projects.linpro.no phk at projects.linpro.no
Fri Feb 20 18:21:30 CET 2009


Author: phk
Date: 2009-02-20 18:21:30 +0100 (Fri, 20 Feb 2009)
New Revision: 3797

Modified:
   trunk/varnish-cache/bin/varnishd/cache_hash.c
   trunk/varnish-cache/bin/varnishd/cache_pool.c
   trunk/varnish-cache/bin/varnishd/hash_slinger.h
Log:
Put the cleanup next to the preallocation and remember to release
the preallocated objcore



Modified: trunk/varnish-cache/bin/varnishd/cache_hash.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_hash.c	2009-02-20 15:25:06 UTC (rev 3796)
+++ trunk/varnish-cache/bin/varnishd/cache_hash.c	2009-02-20 17:21:30 UTC (rev 3797)
@@ -141,6 +141,27 @@
 }
 
 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)
 {
 

Modified: trunk/varnish-cache/bin/varnishd/cache_pool.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_pool.c	2009-02-20 15:25:06 UTC (rev 3796)
+++ trunk/varnish-cache/bin/varnishd/cache_pool.c	2009-02-20 17:21:30 UTC (rev 3797)
@@ -365,12 +365,8 @@
 	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);
 }
 

Modified: trunk/varnish-cache/bin/varnishd/hash_slinger.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/hash_slinger.h	2009-02-20 15:25:06 UTC (rev 3796)
+++ trunk/varnish-cache/bin/varnishd/hash_slinger.h	2009-02-20 17:21:30 UTC (rev 3797)
@@ -30,6 +30,7 @@
  */
 
 struct sess;
+struct worker;
 struct object;
 
 typedef void hash_init_f(int ac, char * const *av);
@@ -50,6 +51,7 @@
 
 /* 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);



More information about the varnish-commit mailing list