[master] c6d80ca Stringify oc->flags and oc->exp_flags on panic

Federico G. Schwindt fgsch at lodoss.net
Wed May 25 11:28:08 CEST 2016


commit c6d80ca7806dc5ebbfcd25361bb1beaa9b78b813
Author: Federico G. Schwindt <fgsch at lodoss.net>
Date:   Wed May 25 09:26:55 2016 +0100

    Stringify oc->flags and oc->exp_flags on panic

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index d2903b9..c1b90ae 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -405,6 +405,18 @@ enum obj_flags {
 #undef OBJ_FLAG
 };
 
+enum oc_flags {
+#define OC_FLAG(U, l, v)	OC_F_##U = v,
+#include "tbl/oc_flags.h"
+#undef OC_FLAG
+};
+
+enum oc_exp_flags {
+#define OC_EXP_FLAG(U, l, v)	OC_EF_##U = v,
+#include "tbl/oc_exp_flags.h"
+#undef OC_EXP_FLAG
+};
+
 struct objcore {
 	unsigned		magic;
 #define OBJCORE_MAGIC		0x4d301302
@@ -421,19 +433,8 @@ struct objcore {
 	float			keep;
 
 	uint8_t			flags;
-#define OC_F_BUSY		(1<<1)
-#define OC_F_PASS		(1<<2)
-#define OC_F_ABANDON		(1<<4)
-#define OC_F_PRIVATE		(1<<5)
-#define OC_F_FAILED		(1<<6)
-#define OC_F_DYING		(1<<7)
 
 	uint8_t			exp_flags;
-#define OC_EF_POSTED		(1<<1)
-#define OC_EF_REFD		(1<<2)
-#define OC_EF_MOVE		(1<<3)
-#define OC_EF_INSERT		(1<<4)
-#define OC_EF_REMOVE		(1<<5)
 
 	uint16_t		oa_present;
 
diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c
index 7fb6bd8..53ef3cd 100644
--- a/bin/varnishd/cache/cache_panic.c
+++ b/bin/varnishd/cache/cache_panic.c
@@ -145,8 +145,8 @@ pan_ws(struct vsb *vsb, const struct ws *ws)
 	PAN_CheckMagic(vsb, ws, WS_MAGIC);
 	if (!(ws->id[0] & 0x20))
 		VSB_printf(vsb, "OVERFLOWED ");
-	VSB_printf(vsb, "id = \"%s\",\n",  ws->id);
-	VSB_printf(vsb, "{s, f, r, e} = {%p",  ws->s);
+	VSB_printf(vsb, "id = \"%s\",\n", ws->id);
+	VSB_printf(vsb, "{s, f, r, e} = {%p", ws->s);
 	if (ws->f > ws->s)
 		VSB_printf(vsb, ", +%ld", (long) (ws->f - ws->s));
 	else
@@ -243,6 +243,7 @@ pan_boc(struct vsb *vsb, const struct boc *boc)
 static void
 pan_objcore(struct vsb *vsb, const char *typ, const struct objcore *oc)
 {
+	const char *p;
 
 	VSB_printf(vsb, "objcore[%s] = %p {\n", typ, oc);
 	if (pan_already(vsb, oc))
@@ -250,8 +251,20 @@ pan_objcore(struct vsb *vsb, const char *typ, const struct objcore *oc)
 	VSB_indent(vsb, 2);
 	PAN_CheckMagic(vsb, oc, OBJCORE_MAGIC);
 	VSB_printf(vsb, "refcnt = %d,\n", oc->refcnt);
-	VSB_printf(vsb, "flags = 0x%x,\n", oc->flags);
-	VSB_printf(vsb, "exp_flags = 0x%x,\n", oc->exp_flags);
+	VSB_printf(vsb, "flags = {");
+	p = "";
+#define OC_FLAG(U, l, v) \
+	if (oc->flags & v) { VSB_printf(vsb, "%s" #l, p); p = ", "; }
+#include "tbl/oc_flags.h"
+#undef OC_FLAG
+	VSB_printf(vsb, "},\n");
+	VSB_printf(vsb, "exp_flags = {");
+	p = "";
+#define OC_EXP_FLAG(U, l, v) \
+	if (oc->exp_flags & v) { VSB_printf(vsb, "%s" #l, p); p = ", "; }
+#include "tbl/oc_exp_flags.h"
+#undef OC_EXP_FLAG
+	VSB_printf(vsb, "},\n");
 	if (oc->boc != NULL)
 		pan_boc(vsb, oc->boc);
 	VSB_printf(vsb, "exp = {%f, %f, %f, %f}\n",
@@ -347,7 +360,7 @@ pan_busyobj(struct vsb *vsb, const struct busyobj *bo)
 	p = "";
 	/*lint -save -esym(438,p) */
 #define BO_FLAG(l, r, w, d) \
-	if(bo->l) { VSB_printf(vsb,  "%s" #l, p); p = ", "; }
+	if(bo->l) { VSB_printf(vsb, "%s" #l, p); p = ", "; }
 #include "tbl/bo_flags.h"
 #undef BO_FLAG
 	/*lint -restore */
diff --git a/include/tbl/oc_exp_flags.h b/include/tbl/oc_exp_flags.h
new file mode 100644
index 0000000..2fc16e5
--- /dev/null
+++ b/include/tbl/oc_exp_flags.h
@@ -0,0 +1,35 @@
+/*-
+ * Copyright (c) 2016 Varnish Software AS
+ * All rights reserved.
+ *
+ * Author: Federico G. Schwindt <fgsch at lodoss.net>
+ *
+ * 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.
+ */
+
+/*lint -save -e525 -e539 */
+OC_EXP_FLAG(POSTED,	posted,		(1<<1))
+OC_EXP_FLAG(REFD,	refd,		(1<<2))
+OC_EXP_FLAG(MOVE,	move,		(1<<3))
+OC_EXP_FLAG(INSERT,	insert,		(1<<4))
+OC_EXP_FLAG(REMOVE,	remove,		(1<<5))
+/*lint -restore */
diff --git a/include/tbl/oc_flags.h b/include/tbl/oc_flags.h
new file mode 100644
index 0000000..825312b
--- /dev/null
+++ b/include/tbl/oc_flags.h
@@ -0,0 +1,36 @@
+/*-
+ * Copyright (c) 2016 Varnish Software AS
+ * All rights reserved.
+ *
+ * Author: Federico G. Schwindt <fgsch at lodoss.net>
+ *
+ * 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.
+ */
+
+/*lint -save -e525 -e539 */
+OC_FLAG(BUSY,		busy,		(1<<1))
+OC_FLAG(PASS,		pass,		(1<<2))
+OC_FLAG(ABANDON,	abandon,	(1<<4))
+OC_FLAG(PRIVATE,	private,	(1<<5))
+OC_FLAG(FAILED,		failed,		(1<<6))
+OC_FLAG(DYING,		dying,		(1<<7))
+/*lint -restore */



More information about the varnish-commit mailing list