[PATCH] Decrement the n_waitinglist counter when freeing waitinglists.

Martin Blix Grydeland martin at varnish-software.com
Mon Mar 12 12:40:15 CET 2012


---
 bin/varnishd/cache/cache_center.c |    2 +-
 bin/varnishd/cache/cache_hash.c   |   12 +++++++-----
 bin/varnishd/hash/hash_slinger.h  |    2 +-
 3 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c
index ecea4b5..6930e60 100644
--- a/bin/varnishd/cache/cache_center.c
+++ b/bin/varnishd/cache/cache_center.c
@@ -938,7 +938,7 @@ cnt_fetchbody(struct sess *sp, struct worker *wrk, struct req *req)
 		AN(req->obj->objcore);
 		AN(req->obj->objcore->ban);
 		AZ(req->obj->ws_o->overflow);
-		HSH_Unbusy(req->obj->objcore);
+		HSH_Unbusy(&wrk->stats, req->obj->objcore);
 	}
 	VBO_DerefBusyObj(wrk, &req->busyobj);
 	wrk->acct_tmp.fetch++;
diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c
index 1e21214..3059642 100644
--- a/bin/varnishd/cache/cache_hash.c
+++ b/bin/varnishd/cache/cache_hash.c
@@ -125,6 +125,7 @@ HSH_Cleanup(struct worker *wrk)
 	if (wrk->nwaitinglist != NULL) {
 		FREE_OBJ(wrk->nwaitinglist);
 		wrk->nwaitinglist = NULL;
+		wrk->stats.n_waitinglist--;
 	}
 	if (wrk->nhashpriv != NULL) {
 		/* XXX: If needed, add slinger method for this */
@@ -470,7 +471,7 @@ HSH_Lookup(struct sess *sp, struct objhead **poh)
  */
 
 static void
-hsh_rush(struct objhead *oh)
+hsh_rush(struct dstat *ds, struct objhead *oh)
 {
 	unsigned u;
 	struct sess *sp;
@@ -499,6 +500,7 @@ hsh_rush(struct objhead *oh)
 	if (VTAILQ_EMPTY(&wl->list)) {
 		oh->waitinglist = NULL;
 		FREE_OBJ(wl);
+		ds->n_waitinglist--;
 	}
 }
 
@@ -578,12 +580,12 @@ HSH_Drop(struct worker *wrk, struct object **oo)
 	AssertObjCorePassOrBusy((*oo)->objcore);
 	(*oo)->exp.ttl = -1.;
 	if ((*oo)->objcore != NULL)		/* Pass has no objcore */
-		HSH_Unbusy((*oo)->objcore);
+		HSH_Unbusy(&wrk->stats, (*oo)->objcore);
 	(void)HSH_Deref(&wrk->stats, NULL, oo);
 }
 
 void
-HSH_Unbusy(struct objcore *oc)
+HSH_Unbusy(struct dstat *ds, struct objcore *oc)
 {
 	struct objhead *oh;
 
@@ -605,7 +607,7 @@ HSH_Unbusy(struct objcore *oc)
 	oc->flags &= ~OC_F_BUSY;
 	oc->busyobj = NULL;
 	if (oh->waitinglist != NULL)
-		hsh_rush(oh);
+		hsh_rush(ds, oh);
 	AN(oc->ban);
 	Lck_Unlock(&oh->mtx);
 }
@@ -682,7 +684,7 @@ HSH_Deref(struct dstat *ds, struct objcore *oc, struct object **oo)
 		AN(oc->methods);
 	}
 	if (oh->waitinglist != NULL)
-		hsh_rush(oh);
+		hsh_rush(ds, oh);
 	Lck_Unlock(&oh->mtx);
 	if (r != 0)
 		return (r);
diff --git a/bin/varnishd/hash/hash_slinger.h b/bin/varnishd/hash/hash_slinger.h
index b15d9df..a3577a7 100644
--- a/bin/varnishd/hash/hash_slinger.h
+++ b/bin/varnishd/hash/hash_slinger.h
@@ -53,7 +53,6 @@ struct hash_slinger {
 /* cache_hash.c */
 void HSH_Cleanup(struct worker *w);
 struct objcore *HSH_Lookup(struct sess *sp, struct objhead **poh);
-void HSH_Unbusy(struct objcore *);
 void HSH_Ref(struct objcore *o);
 void HSH_Drop(struct worker *, struct object **);
 void HSH_Init(const struct hash_slinger *slinger);
@@ -94,6 +93,7 @@ struct objhead {
 #define hoh_head _u.n.u_n_hoh_head
 };
 
+void HSH_Unbusy(struct dstat *, struct objcore *);
 void HSH_DeleteObjHead(struct dstat *, struct objhead *oh);
 int HSH_Deref(struct dstat *, struct objcore *oc, struct object **o);
 #endif /* VARNISH_CACHE_CHILD */
-- 
1.7.4.1




More information about the varnish-dev mailing list