r5195 - trunk/varnish-cache/lib/libvarnish
phk at varnish-cache.org
phk at varnish-cache.org
Mon Sep 13 12:00:41 CEST 2010
Author: phk
Date: 2010-09-13 12:00:41 +0200 (Mon, 13 Sep 2010)
New Revision: 5195
Modified:
trunk/varnish-cache/lib/libvarnish/binary_heap.c
Log:
Fix an embarrasing typo in the WM-Aware binary heap layout.
The effect of this is that the root object in the binheap could be
wrong and thus hold the expiry thread hostage, even though other objects
were ripe for expiry.
This would show up as inflated obj/objcore/objhdr counts, but have no
other deleritous effects.
Detected, conclusively, by: sky
Modified: trunk/varnish-cache/lib/libvarnish/binary_heap.c
===================================================================
--- trunk/varnish-cache/lib/libvarnish/binary_heap.c 2010-09-13 06:45:59 UTC (rev 5194)
+++ trunk/varnish-cache/lib/libvarnish/binary_heap.c 2010-09-13 10:00:41 UTC (rev 5195)
@@ -57,6 +57,9 @@
*/
#define ROW_SHIFT 16
+
+#undef PARANOIA
+
/* Private definitions -----------------------------------------------*/
#define ROOT_IDX 1
@@ -127,8 +130,12 @@
} else {
/* The rest is as usual, only inside the page */
*a = u + (u & bh->page_mask);
- *b += 1;
+ *b = *a + 1;
}
+#ifdef PARANOIA
+ assert(parent(bh, *a) == u);
+ assert(parent(bh, *b) == u);
+#endif
}
@@ -284,12 +291,29 @@
(void)binheap_trickleup(bh, u);
}
+
+#ifdef PARANOIA
+static void
+chk(const struct binheap *bh)
+{
+ unsigned u, v;
+
+ for (u = 2; u < bh->next; u++) {
+ v = parent(bh, u);
+ assert(!bh->cmp(bh->priv, A(bh, u), A(bh, v)));
+ }
+}
+#endif
+
void *
binheap_root(const struct binheap *bh)
{
assert(bh != NULL);
assert(bh->magic == BINHEAP_MAGIC);
+#ifdef PARANOIA
+ chk(bh);
+#endif
return (A(bh, ROOT_IDX));
}
More information about the varnish-commit
mailing list