[PATCH 11/13] Generalize the ban reporting to the stevedores using their API. This way any stevedore interested in new bans can request to be notified (not just the persistent).

Martin Blix Grydeland martin at varnish-software.com
Mon Oct 1 12:26:18 CEST 2012


---
 bin/varnishd/cache/cache.h                |    2 +-
 bin/varnishd/cache/cache_ban.c            |    6 ++++--
 bin/varnishd/storage/stevedore.c          |    9 +++++++++
 bin/varnishd/storage/storage.h            |    3 +++
 bin/varnishd/storage/storage_persistent.c |    7 +++++--
 5 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 7533782..7ecf954 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -1054,6 +1054,7 @@ void STV_free(struct storage *st);
 void STV_open(void);
 void STV_close(void);
 void STV_Freestore(struct object *o);
+void STV_NewBan(const uint8_t *ban, unsigned len);
 
 /* storage_synth.c */
 struct vsb *SMS_Makesynth(struct object *obj);
@@ -1063,7 +1064,6 @@ void SMS_Init(void);
 /* storage_persistent.c */
 void SMP_Init(void);
 void SMP_Ready(void);
-void SMP_NewBan(const uint8_t *ban, unsigned len);
 
 /*
  * A normal pointer difference is signed, but we never want a negative value
diff --git a/bin/varnishd/cache/cache_ban.c b/bin/varnishd/cache/cache_ban.c
index 2054d3e..f895467 100644
--- a/bin/varnishd/cache/cache_ban.c
+++ b/bin/varnishd/cache/cache_ban.c
@@ -413,7 +413,7 @@ BAN_Insert(struct ban *b)
 	else
 		be = NULL;
 
-	SMP_NewBan(b->spec, ln);
+	STV_NewBan(b->spec, ln);	/* Notify stevedores */
 	Lck_Unlock(&ban_mtx);
 
 	if (be == NULL)
@@ -595,7 +595,9 @@ BAN_Compile(void)
 
 	ASSERT_CLI();
 
-	SMP_NewBan(ban_magic->spec, ban_len(ban_magic->spec));
+	/* Notify stevedores */
+	STV_NewBan(ban_magic->spec, ban_len(ban_magic->spec));
+
 	ban_start = VTAILQ_FIRST(&ban_head);
 	WRK_BgThread(&ban_thread, "ban-lurker", ban_lurker, NULL);
 }
diff --git a/bin/varnishd/storage/stevedore.c b/bin/varnishd/storage/stevedore.c
index fa5a683..c02e5f7 100644
--- a/bin/varnishd/storage/stevedore.c
+++ b/bin/varnishd/storage/stevedore.c
@@ -453,6 +453,15 @@ STV_close(void)
 		stv->close(stv);
 }
 
+void
+STV_NewBan(const uint8_t *ban, unsigned len)
+{
+	struct stevedore *stv;
+
+	VTAILQ_FOREACH(stv, &stv_stevedores, list)
+		if (stv->newban != NULL)
+			stv->newban(stv, ban, len);
+}
 
 /*--------------------------------------------------------------------
  * VRT functions for stevedores
diff --git a/bin/varnishd/storage/storage.h b/bin/varnishd/storage/storage.h
index fd1adef..49cd0f8 100644
--- a/bin/varnishd/storage/storage.h
+++ b/bin/varnishd/storage/storage.h
@@ -48,6 +48,8 @@ typedef struct object *storage_allocobj_f(struct stevedore *, struct busyobj *,
     struct objcore **, unsigned ltot, const struct stv_objsecrets *);
 typedef void storage_close_f(const struct stevedore *);
 typedef void storage_signal_close_f(const struct stevedore *);
+typedef void storage_newban_f(struct stevedore *, const uint8_t *ban,
+    unsigned len);
 
 /* Prototypes for VCL variable responders */
 #define VRTSTVTYPE(ct) typedef ct storage_var_##ct(const struct stevedore *);
@@ -71,6 +73,7 @@ struct stevedore {
 	storage_close_f		*close;		/* --//-- */
 	storage_allocobj_f	*allocobj;	/* --//-- */
 	storage_signal_close_f	*signal_close;	/* --//-- */
+	storage_newban_f	*newban;	/* --//-- */
 
 	struct lru		*lru;
 
diff --git a/bin/varnishd/storage/storage_persistent.c b/bin/varnishd/storage/storage_persistent.c
index 6b8764f..f38aba6 100644
--- a/bin/varnishd/storage/storage_persistent.c
+++ b/bin/varnishd/storage/storage_persistent.c
@@ -92,11 +92,13 @@ smp_appendban(struct smp_sc *sc, struct smp_signspace *spc,
 
 /* Trust that cache_ban.c takes care of locking */
 
-void
-SMP_NewBan(const uint8_t *ban, unsigned ln)
+static void
+smp_newban(struct stevedore *stv, const uint8_t *ban, unsigned ln)
 {
 	struct smp_sc *sc;
 
+	(void)stv;
+
 	VTAILQ_FOREACH(sc, &silos, list) {
 		smp_appendban(sc, &sc->ban1, ln, ban);
 		smp_appendban(sc, &sc->ban2, ln, ban);
@@ -584,6 +586,7 @@ const struct stevedore smp_stevedore = {
 	.allocobj =	smp_allocobj,
 	.free	=	smp_free,
 	.signal_close = smp_signal_close,
+	.newban =	smp_newban,
 };
 
 /*--------------------------------------------------------------------
-- 
1.7.9.5




More information about the varnish-dev mailing list