[PATCH 07/15] Report ban events through struct ban pointers.
Martin Blix Grydeland
martin at varnish-software.com
Wed Nov 7 12:32:10 CET 2012
Stevedores will use BAN_Spec to get the ban byte string, which will be
truncated for GONE bans.
---
bin/varnishd/cache/cache.h | 2 +-
bin/varnishd/cache/cache_ban.c | 7 +++----
bin/varnishd/storage/stevedore.c | 4 ++--
bin/varnishd/storage/storage.h | 3 ++-
bin/varnishd/storage/storage_persistent.c | 10 ++++++----
5 files changed, 14 insertions(+), 12 deletions(-)
diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 582dc0b..f0bba19 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -1060,7 +1060,7 @@ void STV_free(struct storage *st);
void STV_open(void);
void STV_close(void);
void STV_Freestore(struct object *o);
-void STV_BanInfo(enum baninfo event, const uint8_t *ban, unsigned len);
+void STV_BanInfo(enum baninfo event, const struct ban *ban);
/* storage_synth.c */
struct vsb *SMS_Makesynth(struct object *obj);
diff --git a/bin/varnishd/cache/cache_ban.c b/bin/varnishd/cache/cache_ban.c
index d15f6c5..4853be3 100644
--- a/bin/varnishd/cache/cache_ban.c
+++ b/bin/varnishd/cache/cache_ban.c
@@ -442,7 +442,7 @@ BAN_Insert(struct ban *b)
else
be = NULL;
- STV_BanInfo(BI_NEW, b->spec, ln); /* Notify stevedores */
+ STV_BanInfo(BI_NEW, b); /* Notify stevedores */
Lck_Unlock(&ban_mtx);
if (be == NULL)
@@ -670,7 +670,7 @@ BAN_Compile(void)
AZ(ban_shutdown);
/* Notify stevedores */
- STV_BanInfo(BI_NEW, ban_magic->spec, ban_len(ban_magic->spec));
+ STV_BanInfo(BI_NEW, ban_magic);
ban_start = VTAILQ_FIRST(&ban_head);
WRK_BgThread(&ban_thread, "ban-lurker", ban_lurker, NULL);
@@ -1030,8 +1030,7 @@ ban_lurker(struct worker *wrk, void *priv)
bf = ban_CheckLast();
if (bf != NULL)
/* Notify stevedores */
- STV_BanInfo(BI_DROP, bf->spec,
- ban_len(bf->spec));
+ STV_BanInfo(BI_DROP, bf);
Lck_Unlock(&ban_mtx);
if (bf != NULL)
BAN_Free(bf);
diff --git a/bin/varnishd/storage/stevedore.c b/bin/varnishd/storage/stevedore.c
index 5262b70..c64fb62 100644
--- a/bin/varnishd/storage/stevedore.c
+++ b/bin/varnishd/storage/stevedore.c
@@ -454,13 +454,13 @@ STV_close(void)
}
void
-STV_BanInfo(enum baninfo event, const uint8_t *ban, unsigned len)
+STV_BanInfo(enum baninfo event, const struct ban *ban)
{
struct stevedore *stv;
VTAILQ_FOREACH(stv, &stv_stevedores, list)
if (stv->baninfo != NULL)
- stv->baninfo(stv, event, ban, len);
+ stv->baninfo(stv, event, ban);
}
/*--------------------------------------------------------------------
diff --git a/bin/varnishd/storage/storage.h b/bin/varnishd/storage/storage.h
index e9971e7..f54b8c3 100644
--- a/bin/varnishd/storage/storage.h
+++ b/bin/varnishd/storage/storage.h
@@ -38,6 +38,7 @@ struct busyobj;
struct objcore;
struct worker;
struct lru;
+struct ban;
typedef void storage_init_f(struct stevedore *, int ac, char * const *av);
typedef void storage_open_f(const struct stevedore *);
@@ -49,7 +50,7 @@ typedef struct object *storage_allocobj_f(struct stevedore *, struct busyobj *,
typedef void storage_close_f(const struct stevedore *);
typedef void storage_signal_close_f(const struct stevedore *);
typedef void storage_baninfo_f(struct stevedore *, enum baninfo event,
- const uint8_t *ban, unsigned len);
+ const struct ban *ban);
/* Prototypes for VCL variable responders */
#define VRTSTVTYPE(ct) typedef ct storage_var_##ct(const struct stevedore *);
diff --git a/bin/varnishd/storage/storage_persistent.c b/bin/varnishd/storage/storage_persistent.c
index 3a6ade5..ec306e6 100644
--- a/bin/varnishd/storage/storage_persistent.c
+++ b/bin/varnishd/storage/storage_persistent.c
@@ -93,10 +93,11 @@ smp_appendban(struct smp_sc *sc, struct smp_signspace *spc,
/* Trust that cache_ban.c takes care of locking */
static void
-smp_baninfo(struct stevedore *stv, enum baninfo event,
- const uint8_t *ban, unsigned len)
+smp_baninfo(struct stevedore *stv, enum baninfo event, const struct ban *ban)
{
struct smp_sc *sc;
+ const uint8_t *spec;
+ unsigned len;
CAST_OBJ_NOTNULL(sc, stv->priv, SMP_SC_MAGIC);
@@ -106,8 +107,9 @@ smp_baninfo(struct stevedore *stv, enum baninfo event,
switch (event) {
case BI_NEW:
- smp_appendban(sc, &sc->ban1, len, ban);
- smp_appendban(sc, &sc->ban2, len, ban);
+ BAN_Spec(ban, &spec, &len);
+ smp_appendban(sc, &sc->ban1, len, spec);
+ smp_appendban(sc, &sc->ban2, len, spec);
break;
default:
/* Ignored */
--
1.7.9.5
More information about the varnish-dev
mailing list