[master] 861d557 Dramatically reduce the scope of enum baninfo: It is now only part of the stevedore API.

Poul-Henning Kamp phk at FreeBSD.org
Tue Feb 9 01:19:12 CET 2016


commit 861d5577cb5cc6132d4f199948acc8336c2e7552
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Feb 8 21:13:41 2016 +0000

    Dramatically reduce the scope of enum baninfo:  It is now only
    part of the stevedore API.

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 3cdaca7..701a1e4 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -1061,8 +1061,6 @@ int STV_NewObject(struct worker *, struct objcore *,
     const char *hint, unsigned len);
 void STV_open(void);
 void STV_close(void);
-int STV_BanInfo(enum baninfo event, const uint8_t *ban, unsigned len);
-void STV_BanExport(const uint8_t *bans, 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 b0f53ad..3f70c42 100644
--- a/bin/varnishd/cache/cache_ban.c
+++ b/bin/varnishd/cache/cache_ban.c
@@ -301,19 +301,23 @@ ban_export(void)
 	VSC_C_main->bans_persisted_fragmentation = 0;
 }
 
+/*
+ * For both of these we do a full export on info failure to remove
+ * holes in the exported list.
+ * XXX: we should keep track of the size of holes in the last exported list
+ */
 void
-ban_info(enum baninfo event, const uint8_t *ban, unsigned len)
+ban_info_new(const uint8_t *ban, unsigned len)
 {
-	if (STV_BanInfo(event, ban, len)) {
-		/* One or more stevedores reported failure. Export the
-		 * list instead. The exported list should take up less
-		 * space due to drops being purged and completed being
-		 * truncated. */
-		/* XXX: Keep some measure of how much space can be
-		 * saved, and only export if it's worth it. Assert if
-		 * not */
+	if (STV_BanInfoNew(ban, len))
+		ban_export();
+}
+
+void
+ban_info_drop(const uint8_t *ban, unsigned len)
+{
+	if (STV_BanInfoNew(ban, len))
 		ban_export();
-	}
 }
 
 /*--------------------------------------------------------------------
@@ -743,7 +747,7 @@ BAN_Compile(void)
 
 	/* Report the place-holder ban */
 	b = VTAILQ_FIRST(&ban_head);
-	AZ(STV_BanInfo(BI_NEW, b->spec, ban_len(b->spec)));
+	ban_info_new(b->spec, ban_len(b->spec));
 
 	ban_export();
 
diff --git a/bin/varnishd/cache/cache_ban.h b/bin/varnishd/cache/cache_ban.h
index 100acee..f3992bb 100644
--- a/bin/varnishd/cache/cache_ban.h
+++ b/bin/varnishd/cache/cache_ban.h
@@ -109,7 +109,9 @@ extern pthread_cond_t	ban_lurker_cond;
 
 void ban_mark_completed(struct ban *b);
 unsigned ban_len(const uint8_t *banspec);
-void ban_info(enum baninfo event, const uint8_t *ban, unsigned len);
+void ban_info_new(const uint8_t *ban, unsigned len);
+void ban_info_drop(const uint8_t *ban, unsigned len);
+
 int ban_evaluate(struct worker *wrk, const uint8_t *bs, struct objcore *oc,
     const struct http *reqhttp, unsigned *tests);
 double ban_time(const uint8_t *banspec);
diff --git a/bin/varnishd/cache/cache_ban_build.c b/bin/varnishd/cache/cache_ban_build.c
index b3bda03..4dec68b 100644
--- a/bin/varnishd/cache/cache_ban_build.c
+++ b/bin/varnishd/cache/cache_ban_build.c
@@ -306,7 +306,7 @@ BAN_Commit(struct ban_proto *bp)
 		VSC_C_main->bans_req++;
 
 	if (bi != NULL)
-		ban_info(BI_NEW, b->spec, ln);	/* Notify stevedores */
+		ban_info_new(b->spec, ln);	/* Notify stevedores */
 
 	if (cache_param->ban_dups) {
 		/* Hunt down duplicates, and mark them as completed */
diff --git a/bin/varnishd/cache/cache_ban_lurker.c b/bin/varnishd/cache/cache_ban_lurker.c
index 63371f8..e913fda 100644
--- a/bin/varnishd/cache/cache_ban_lurker.c
+++ b/bin/varnishd/cache/cache_ban_lurker.c
@@ -71,7 +71,7 @@ ban_cleantail(void)
 			VTAILQ_REMOVE(&ban_head, b, list);
 			VSC_C_main->bans_persisted_fragmentation +=
 			    ban_len(b->spec);
-			ban_info(BI_DROP, b->spec, ban_len(b->spec));
+			ban_info_drop(b->spec, ban_len(b->spec));
 		} else {
 			b = NULL;
 		}
diff --git a/bin/varnishd/cache/cache_priv.h b/bin/varnishd/cache/cache_priv.h
index f3a3aaa..7dd941e 100644
--- a/bin/varnishd/cache/cache_priv.h
+++ b/bin/varnishd/cache/cache_priv.h
@@ -128,6 +128,11 @@ void VRTPRIV_dynamic_kill(struct vrt_privs *privs, uintptr_t id);
 /* cache_vrt_vmod.c */
 void VMOD_Init(void);
 
+/* stevedore.c */
+int STV_BanInfoDrop(const uint8_t *ban, unsigned len);
+int STV_BanInfoNew(const uint8_t *ban, unsigned len);
+void STV_BanExport(const uint8_t *banlist, unsigned len);
+
 /* storage_persistent.c */
 void SMP_Init(void);
 void SMP_Ready(void);
diff --git a/bin/varnishd/common/common.h b/bin/varnishd/common/common.h
index 52bbd90..0b494c3 100644
--- a/bin/varnishd/common/common.h
+++ b/bin/varnishd/common/common.h
@@ -40,11 +40,6 @@
 #include "vsb.h"
 #include "vapi/vsc_int.h"
 
-enum baninfo {
-	BI_NEW,
-	BI_DROP
-};
-
 struct cli;
 
 /**********************************************************************
diff --git a/bin/varnishd/storage/stevedore.c b/bin/varnishd/storage/stevedore.c
index 660f511..a7648ec 100644
--- a/bin/varnishd/storage/stevedore.c
+++ b/bin/varnishd/storage/stevedore.c
@@ -166,14 +166,27 @@ STV_close(void)
  */
 
 int
-STV_BanInfo(enum baninfo event, const uint8_t *ban, unsigned len)
+STV_BanInfoDrop(const uint8_t *ban, unsigned len)
 {
 	struct stevedore *stv;
 	int r = 0;
 
 	VTAILQ_FOREACH(stv, &stv_stevedores, list)
 		if (stv->baninfo != NULL)
-			r |= stv->baninfo(stv, event, ban, len);
+			r |= stv->baninfo(stv, BI_DROP, ban, len);
+
+	return (r);
+}
+
+int
+STV_BanInfoNew(const uint8_t *ban, unsigned len)
+{
+	struct stevedore *stv;
+	int r = 0;
+
+	VTAILQ_FOREACH(stv, &stv_stevedores, list)
+		if (stv->baninfo != NULL)
+			r |= stv->baninfo(stv, BI_NEW, ban, len);
 
 	return (r);
 }
diff --git a/bin/varnishd/storage/storage.h b/bin/varnishd/storage/storage.h
index 4f12d9c..462c74c 100644
--- a/bin/varnishd/storage/storage.h
+++ b/bin/varnishd/storage/storage.h
@@ -40,6 +40,11 @@ struct vsl_log;
 struct vfp_ctx;
 struct obj_methods;
 
+enum baninfo {
+	BI_NEW,
+	BI_DROP
+};
+
 /* Storage -----------------------------------------------------------*/
 
 struct storage {



More information about the varnish-commit mailing list