[PATCH 01/10] Maintain an offset into the persisted ban list pointing to the first non-dropped ban.
Martin Blix Grydeland
martin at varnish-software.com
Wed Oct 10 16:27:14 CEST 2012
---
bin/varnishd/storage/storage_persistent.c | 37 +++++++++++++++++++++++++++++
bin/varnishd/storage/storage_persistent.h | 1 +
2 files changed, 38 insertions(+)
diff --git a/bin/varnishd/storage/storage_persistent.c b/bin/varnishd/storage/storage_persistent.c
index 5f756b7..f5398b9 100644
--- a/bin/varnishd/storage/storage_persistent.c
+++ b/bin/varnishd/storage/storage_persistent.c
@@ -90,6 +90,37 @@ smp_appendban(struct smp_sc *sc, struct smp_signspace *spc,
smp_append_signspace(spc, ptr - ptr2);
}
+/*--------------------------------------------------------------------
+ * Update *offset with the offset of the first ban record past ban
+ */
+
+static void
+smp_offset_banlist(struct smp_sc *sc, struct smp_signspace *spc,
+ uint64_t *offset, const uint8_t *ban, unsigned ln)
+{
+ uint8_t *ptr, *ptr2;
+ uint32_t len;
+
+ (void)sc;
+ ptr = ptr2 = (uint8_t *)SIGNSPACE_DATA(spc) + *offset;
+ assert(ptr <= (uint8_t *)SIGNSPACE_FRONT(spc));
+
+ while (ptr < (uint8_t *)SIGNSPACE_FRONT(spc)) {
+ AZ(memcmp(ptr, "BAN", 4));
+ ptr += 4;
+
+ len = vbe32dec(ptr);
+ ptr += 4;
+
+ ptr += len;
+
+ if (len == ln && !memcmp(ptr - len, ban, len)) {
+ *offset += ptr - ptr2;
+ return;
+ }
+ }
+}
+
/* Trust that cache_ban.c takes care of locking */
static void
@@ -106,6 +137,12 @@ smp_baninfo(struct stevedore *stv, enum baninfo event,
smp_appendban(sc, &sc->ban2, len, ban);
}
break;
+ case BI_DROP:
+ VTAILQ_FOREACH(sc, &silos, list) {
+ smp_offset_banlist(sc, &sc->ban1, &sc->ban1_offset,
+ ban, len);
+ }
+ break;
default:
/* Ignored */
break;
diff --git a/bin/varnishd/storage/storage_persistent.h b/bin/varnishd/storage/storage_persistent.h
index cb2efb3..c2cbac3 100644
--- a/bin/varnishd/storage/storage_persistent.h
+++ b/bin/varnishd/storage/storage_persistent.h
@@ -139,6 +139,7 @@ struct smp_sc {
struct smp_signspace seg2;
struct ban *tailban;
+ uint64_t ban1_offset;
struct lock mtx;
--
1.7.9.5
More information about the varnish-dev
mailing list