[3.0] 6990271 Add n_waitinglist counter decrements when freeing struct waitinglist.
Martin Blix Grydeland
martin at varnish-cache.org
Tue Feb 5 13:25:32 CET 2013
commit 6990271f0b6aadb0c51d776a504294d9134b4238
Author: Martin Blix Grydeland <martin at varnish-software.com>
Date: Tue Feb 5 13:06:15 2013 +0100
Add n_waitinglist counter decrements when freeing struct waitinglist.
Fixes: #1261
diff --git a/bin/varnishd/cache_hash.c b/bin/varnishd/cache_hash.c
index 8da00a4..ca31404 100644
--- a/bin/varnishd/cache_hash.c
+++ b/bin/varnishd/cache_hash.c
@@ -138,6 +138,7 @@ HSH_Cleanup(struct worker *w)
if (w->nwaitinglist != NULL) {
FREE_OBJ(w->nwaitinglist);
w->nwaitinglist = NULL;
+ w->stats.n_waitinglist--;
}
if (w->nhashpriv != NULL) {
/* XXX: If needed, add slinger method for this */
@@ -486,12 +487,13 @@ 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;
struct waitinglist *wl;
+ AN(ds);
CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC);
Lck_AssertHeld(&oh->mtx);
wl = oh->waitinglist;
@@ -516,6 +518,7 @@ hsh_rush(struct objhead *oh)
if (VTAILQ_EMPTY(&wl->list)) {
oh->waitinglist = NULL;
FREE_OBJ(wl);
+ ds->n_waitinglist--;
}
}
@@ -636,7 +639,7 @@ HSH_Unbusy(const struct sess *sp)
sp->wrk->nbusyobj = oc->busyobj;
oc->busyobj = NULL;
if (oh->waitinglist != NULL)
- hsh_rush(oh);
+ hsh_rush(&sp->wrk->stats, oh);
AN(oc->ban);
Lck_Unlock(&oh->mtx);
assert(oc_getobj(sp->wrk, oc) == o);
@@ -714,7 +717,7 @@ HSH_Deref(struct worker *w, struct objcore *oc, struct object **oo)
AN(oc->methods);
}
if (oh->waitinglist != NULL)
- hsh_rush(oh);
+ hsh_rush(&w->stats, oh);
Lck_Unlock(&oh->mtx);
if (r != 0)
return (r);
diff --git a/bin/varnishtest/tests/r01261.vtc b/bin/varnishtest/tests/r01261.vtc
new file mode 100644
index 0000000..5b35b4a
--- /dev/null
+++ b/bin/varnishtest/tests/r01261.vtc
@@ -0,0 +1,29 @@
+varnishtest "#1261 - Test n_waitinglist counter"
+
+server s1 {
+ rxreq
+ sema r1 sync 2
+ delay 1
+ txresp
+} -start
+
+varnish v1 -arg "-p thread_pools=1 -w2,2,100" -vcl+backend {
+} -start
+
+client c1 {
+ txreq -url "/test1"
+ rxresp
+ expect resp.status == 200
+} -start
+
+client c2 {
+ txreq -url "/test1"
+ sema r1 sync 2
+ rxresp
+ expect resp.status == 200
+} -start
+
+client c1 -wait
+client c2 -wait
+
+varnish v1 -expect n_waitinglist == 2
More information about the varnish-commit
mailing list