[master] 0b7cc04 Add a new "feature" parameter and move certain bits from diag_bitmaps there. These bits are legitimate feature-ettes which might make sense in a production environment.

Poul-Henning Kamp phk at varnish-cache.org
Tue Aug 28 09:42:36 CEST 2012


commit 0b7cc04c35e917df74cfa976748ae3cae092f65a
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Tue Aug 28 07:41:45 2012 +0000

    Add a new "feature" parameter and move certain bits from diag_bitmaps
    there.  These bits are legitimate feature-ettes which might make sense
    in a production environment.
    
    XXX: need doc-change

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 30f8e99..94db4b6 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -1118,6 +1118,13 @@ Tadd(txt *t, const char *p, int l)
 #define W_TIM_real(w) ((w)->lastused = VTIM_real())
 
 static inline int
+FEATURE(enum feature_bits x)
+{
+	return (cache_param->feature_bits[(unsigned)x>>3] &
+	    (0x80U >> ((unsigned)x & 7)));
+}
+
+static inline int
 DO_DEBUG(enum debug_bits x)
 {
 	return (cache_param->debug_bits[(unsigned)x>>3] &
diff --git a/bin/varnishd/cache/cache_main.c b/bin/varnishd/cache/cache_main.c
index 8af00f6..ac36308 100644
--- a/bin/varnishd/cache/cache_main.c
+++ b/bin/varnishd/cache/cache_main.c
@@ -225,7 +225,7 @@ child_main(void)
 	CLI_AddFuncs(debug_cmds);
 
 	/* Wait for persistent storage to load if asked to */
-	if (cache_param->diag_bitmap & 0x00020000)
+	if (FEATURE(FEATURE_WAIT_SILO))
 		SMP_Ready();
 
 	CLI_Run();
diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c
index ee7dd78..c93749f 100644
--- a/bin/varnishd/cache/cache_panic.c
+++ b/bin/varnishd/cache/cache_panic.c
@@ -392,7 +392,7 @@ pan_ic(const char *func, const char *file, int line, const char *cond,
 
 	pan_backtrace();
 
-	if (!(cache_param->diag_bitmap & 0x2000)) {
+	if (!FEATURE(FEATURE_SHORT_PANIC)) {
 		req = THR_GetRequest();
 		if (req != NULL)
 			pan_req(req);
@@ -400,10 +400,7 @@ pan_ic(const char *func, const char *file, int line, const char *cond,
 	VSB_printf(pan_vsp, "\n");
 	VSB_bcat(pan_vsp, "", 1);	/* NUL termination */
 
-	if (cache_param->diag_bitmap & 0x4000)
-		(void)fputs(heritage.panic_str, stderr);
-
-	if (cache_param->diag_bitmap & 0x1000)
+	if (FEATURE(FEATURE_NO_COREDUMP))
 		exit(4);
 	else
 		abort();
diff --git a/bin/varnishd/common/params.h b/bin/varnishd/common/params.h
index 6c3abb4..6abe0fc 100644
--- a/bin/varnishd/common/params.h
+++ b/bin/varnishd/common/params.h
@@ -40,6 +40,13 @@ enum debug_bits {
        DBG_Reserved
 };
 
+enum feature_bits {
+#define FEATURE_BIT(U, l, p, d, ld) FEATURE_##U,
+#include "tbl/feature_bits.h"
+#undef FEATURE_BIT
+       FEATURE_Reserved
+};
+
 struct poolparam {
 	unsigned		min_pool;
 	unsigned		max_pool;
@@ -207,4 +214,5 @@ struct params {
 
 	uint8_t			vsl_mask[256>>3];
 	uint8_t			debug_bits[(DBG_Reserved+7)>>3];
+	uint8_t			feature_bits[(FEATURE_Reserved+7)>>3];
 };
diff --git a/bin/varnishd/mgt/mgt_child.c b/bin/varnishd/mgt/mgt_child.c
index c869897..95d1794 100644
--- a/bin/varnishd/mgt/mgt_child.c
+++ b/bin/varnishd/mgt/mgt_child.c
@@ -88,6 +88,14 @@ static struct vlu	*vlu;
 
 static struct vsb *child_panic = NULL;
 
+static inline int
+MGT_FEATURE(enum feature_bits x)
+{
+	return (mgt_param.feature_bits[(unsigned)x>>3] &
+	    (0x80U >> ((unsigned)x & 7)));
+}
+
+
 /*--------------------------------------------------------------------
  * Track the highest file descriptor the parent knows is being used.
  *
@@ -213,7 +221,7 @@ MGT_Child_Cli_Fail(void)
 		return;
 	REPORT(LOG_ERR, "Child (%jd) not responding to CLI, killing it.",
 	    (intmax_t)child_pid);
-	if (mgt_param.diag_bitmap & 0x1000)
+	if (MGT_FEATURE(FEATURE_NO_COREDUMP))
 		(void)kill(child_pid, SIGKILL);
 	else
 		(void)kill(child_pid, SIGQUIT);
diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c
index aa99683..434082e 100644
--- a/bin/varnishd/mgt/mgt_param.c
+++ b/bin/varnishd/mgt/mgt_param.c
@@ -1049,10 +1049,6 @@ static const struct parspec input_parspec[] = {
 		"  0x00000008 - mutex logging.\n"
 		"  0x00000010 - mutex contests.\n"
 		"  0x00000080 - mutex timing.\n"
-		"  0x00001000 - do not core-dump child process.\n"
-		"  0x00002000 - only short panic message.\n"
-		"  0x00004000 - panic to stderr.\n"
-		"  0x00020000 - synchronous start of persistence.\n"
 		"\n"
 		"Use 0x notation and do the bitor in your head :-)\n"
 		"\n"
diff --git a/bin/varnishd/mgt/mgt_param_bits.c b/bin/varnishd/mgt/mgt_param_bits.c
index b238823..a5996a2 100644
--- a/bin/varnishd/mgt/mgt_param_bits.c
+++ b/bin/varnishd/mgt/mgt_param_bits.c
@@ -115,7 +115,7 @@ bit_tweak(struct cli *cli, uint8_t *p, unsigned l, const char *arg,
  */
 
 static const char * const VSL_tags[256] = {
-#  define SLTM(foo,sdesc,ldesc)       [SLT_##foo] = #foo,
+#  define SLTM(foo,sdesc,ldesc) [SLT_##foo] = #foo,
 #  include "tbl/vsl_tags.h"
 #  undef SLTM
 	NULL
@@ -158,7 +158,7 @@ tweak_vsl_mask(struct cli *cli, const struct parspec *par, const char *arg)
  */
 
 static const char * const debug_tags[] = {
-#  define DEBUG_BIT(U,l,p,d)       [DBG_##U] = #l,
+#  define DEBUG_BIT(U,l,p,d) [DBG_##U] = #l,
 #  include "tbl/debug_bits.h"
 #  undef DEBUG_BIT
        NULL
@@ -193,6 +193,46 @@ tweak_debug(struct cli *cli, const struct parspec *par, const char *arg)
 }
 
 /*--------------------------------------------------------------------
+ * The feature parameter
+ */
+
+static const char * const feature_tags[] = {
+#  define FEATURE_BIT(U,l,p,d, ld) [FEATURE_##U] = #l,
+#  include "tbl/feature_bits.h"
+#  undef FEATURE_BIT
+       NULL
+};
+
+static void
+tweak_feature(struct cli *cli, const struct parspec *par, const char *arg)
+{
+	const char *s;
+	unsigned j;
+	(void)par;
+
+	if (arg != NULL) {
+		if (!strcmp(arg, "none")) {
+			memset(mgt_param.feature_bits,
+			    0, sizeof mgt_param.feature_bits);
+		} else {
+			bit_tweak(cli, mgt_param.feature_bits,
+			    FEATURE_Reserved, arg, feature_tags,
+			    "feature bit", "+");
+		}
+	} else {
+		s = "";
+		for (j = 0; j < (unsigned)FEATURE_Reserved; j++) {
+			if (bit(mgt_param.feature_bits, j, BTST)) {
+				VCLI_Out(cli, "%s+%s", s, feature_tags[j]);
+				s = ",";
+			}
+		}
+		if (*s == '\0')
+			VCLI_Out(cli, "none");
+	}
+}
+
+/*--------------------------------------------------------------------
  * The parameter table itself
  */
 
@@ -211,5 +251,13 @@ const struct parspec VSL_parspec[] = {
 #include "tbl/debug_bits.h"
 #undef DEBUG_BIT
 		, 0, "none", "" },
+	{ "feature", tweak_feature, NULL, 0, 0,
+		"Enable/Disable various minor features.\n"
+		"\tnone\t\tDisable all features.\n"
+		"Use +/- prefix to enable/disable individual feature:\n"
+#define FEATURE_BIT(U, l, p, d, ld) "\t" #l "\t" p d "\n"
+#include "tbl/feature_bits.h"
+#undef FEATURE_BIT
+		, 0, "none", "" },
 	{ NULL, NULL, NULL }
 };
diff --git a/bin/varnishtest/tests/c00054.vtc b/bin/varnishtest/tests/c00054.vtc
index e6e2260..d3a1072 100644
--- a/bin/varnishtest/tests/c00054.vtc
+++ b/bin/varnishtest/tests/c00054.vtc
@@ -21,6 +21,7 @@ varnish v1 -clierr 106 {param.set vsl_mask \"}
 
 varnish v1 -cliok "param.set debug +workspace"
 varnish v1 -cliok "param.show debug"
+varnish v1 -cliok "param.show feature"
 
 client c1 {
 	txreq
diff --git a/bin/varnishtest/tests/p00000.vtc b/bin/varnishtest/tests/p00000.vtc
index 12fa676..745abf5 100644
--- a/bin/varnishtest/tests/p00000.vtc
+++ b/bin/varnishtest/tests/p00000.vtc
@@ -8,7 +8,7 @@ server s1 {
 shell "rm -f ${tmpdir}/_.per"
 
 varnish v1 \
-	-arg "-pdiag_bitmap=0x20000" \
+	-arg "-pfeature=+wait_silo" \
 	-storage "-spersistent,${tmpdir}/_.per,10m" \
 	-vcl+backend { } -start 
 
diff --git a/bin/varnishtest/tests/p00001.vtc b/bin/varnishtest/tests/p00001.vtc
index 26ea975..ac95149 100644
--- a/bin/varnishtest/tests/p00001.vtc
+++ b/bin/varnishtest/tests/p00001.vtc
@@ -8,7 +8,7 @@ server s1 {
 } -start
 
 varnish v1 \
-	-arg "-pdiag_bitmap=0x20000" \
+	-arg "-pfeature=+wait_silo" \
 	-arg "-pban_lurker_sleep=0" \
 	-storage "-spersistent,${tmpdir}/_.per,10m" \
 	-vcl+backend { } -start 
diff --git a/bin/varnishtest/tests/p00002.vtc b/bin/varnishtest/tests/p00002.vtc
index e3ea052..dc6e584 100644
--- a/bin/varnishtest/tests/p00002.vtc
+++ b/bin/varnishtest/tests/p00002.vtc
@@ -8,7 +8,7 @@ server s1 {
 } -start
 
 varnish v1 \
-	-arg "-pdiag_bitmap=0x20000" \
+	-arg "-pfeature=+wait_silo" \
 	-arg "-pban_lurker_sleep=0" \
 	-storage "-spersistent,${tmpdir}/_.per1,10m" \
 	-storage "-spersistent,${tmpdir}/_.per2,10m" \
diff --git a/bin/varnishtest/tests/p00003.vtc b/bin/varnishtest/tests/p00003.vtc
index f554536..4af3b14 100644
--- a/bin/varnishtest/tests/p00003.vtc
+++ b/bin/varnishtest/tests/p00003.vtc
@@ -8,7 +8,7 @@ server s1 {
 } -start
 
 varnish v1 \
-	-arg "-pdiag_bitmap=0x20000" \
+	-arg "-pfeature=+wait_silo" \
 	-storage "-spersistent,${tmpdir}/_.per,10m" \
 	-arg "-pban_lurker_sleep=0" \
 	-vcl+backend { } -start 
diff --git a/bin/varnishtest/tests/p00004.vtc b/bin/varnishtest/tests/p00004.vtc
index 343d7de..f1e4368 100644
--- a/bin/varnishtest/tests/p00004.vtc
+++ b/bin/varnishtest/tests/p00004.vtc
@@ -10,7 +10,7 @@ server s1 {
 } -start
 
 varnish v1 \
-	-arg "-pdiag_bitmap=0x20000" \
+	-arg "-pfeature=+wait_silo" \
 	-storage "-spersistent,${tmpdir}/_.per,10m" \
 	-arg "-pban_lurker_sleep=0" \
 	-vcl+backend { } -start 
diff --git a/bin/varnishtest/tests/p00005.vtc b/bin/varnishtest/tests/p00005.vtc
index e519cc1..cb0c4e2 100644
--- a/bin/varnishtest/tests/p00005.vtc
+++ b/bin/varnishtest/tests/p00005.vtc
@@ -17,7 +17,7 @@ varnish v1 \
 	} -start 
 
 varnish v1 -cliok "param.set debug +syncvsl"
-varnish v1 -cliok "param.set diag_bitmap 0x20000"
+varnish v1 -cliok "param.set feature +wait_silo"
 
 client c1 {
 	txreq -url "/foo"
diff --git a/bin/varnishtest/tests/r00915.vtc b/bin/varnishtest/tests/r00915.vtc
index 07a39d9..266c6b7 100644
--- a/bin/varnishtest/tests/r00915.vtc
+++ b/bin/varnishtest/tests/r00915.vtc
@@ -8,7 +8,7 @@ server s1 {
 shell "rm -f ${tmpdir}/_.per"
 
 varnish v1 \
-	-arg "-pdiag_bitmap=0x20000" \
+	-arg "-pfeature=+wait_silo" \
 	-storage "-spersistent,${tmpdir}/_.per,10m" \
 	-vcl+backend { 
 
diff --git a/bin/varnishtest/tests/r00962.vtc b/bin/varnishtest/tests/r00962.vtc
index aa0fb10..4331cd0 100644
--- a/bin/varnishtest/tests/r00962.vtc
+++ b/bin/varnishtest/tests/r00962.vtc
@@ -11,7 +11,7 @@ server s1 {
 shell "rm -f ${tmpdir}/_.per?"
 
 varnish v1 \
-	-arg "-pdiag_bitmap=0x20000" \
+	-arg "-pfeature=+wait_silo" \
 	-storage "-spersistent,${tmpdir}/_.per1,10m -spersistent,${tmpdir}/_.per2,10m" \
 	-vcl+backend { 
 	sub vcl_fetch {
@@ -42,7 +42,7 @@ server s1 {
 
 
 varnish v2 \
-	-arg "-pdiag_bitmap=0x20000" \
+	-arg "-pfeature=+wait_silo" \
 	-storage "-spersistent,${tmpdir}/_.per2,10m -spersistent,${tmpdir}/_.per1,10m" \
 	-vcl+backend { } -start 
 
diff --git a/bin/varnishtest/tests/v00010.vtc b/bin/varnishtest/tests/v00010.vtc
index 2e9a385..19405cc 100644
--- a/bin/varnishtest/tests/v00010.vtc
+++ b/bin/varnishtest/tests/v00010.vtc
@@ -37,7 +37,7 @@ varnish v1 -storage "-smalloc,1m" -vcl+backend {
 	}
 } -start
 
-varnish v1 -cliok "param.set diag_bitmap 0x00001000"
+varnish v1 -cliok "param.set feature +no_coredump"
 
 # Force the (random) port selected to be used again after restart.
 varnish v1 -cliok "param.set listen_address ${v1_addr}:${v1_port}"
diff --git a/include/Makefile.am b/include/Makefile.am
index 7562f6c..15df374 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -7,6 +7,7 @@ nobase_pkginclude_HEADERS = \
 	tbl/ban_vars.h \
 	tbl/body_status.h \
 	tbl/debug_bits.h \
+	tbl/feature_bits.h \
 	tbl/http_headers.h \
 	tbl/http_response.h \
 	tbl/locks.h \
diff --git a/include/tbl/feature_bits.h b/include/tbl/feature_bits.h
new file mode 100644
index 0000000..9d99449
--- /dev/null
+++ b/include/tbl/feature_bits.h
@@ -0,0 +1,43 @@
+/*-
+ * Copyright (c) 2012 Varnish Software AS
+ * All rights reserved.
+ *
+ * Author: Poul-Henning Kamp <phk at phk.freebsd.dk>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * Fields in the feature parameter
+ *
+ */
+
+FEATURE_BIT(SHORT_PANIC,	short_panic,	"",
+    "Short panic message.",
+    "Reduce level of detail for panic messages."
+)
+FEATURE_BIT(WAIT_SILO,		wait_silo,	"",
+    "Wait for persistent silo.",
+    "Wait for persistent silos to load completely before serving requests."
+)
+FEATURE_BIT(NO_COREDUMP,	no_coredump,	"",
+    "No coredumps.",
+    "Don't attempt to coredump child process on panics."
+)



More information about the varnish-commit mailing list