[master] 2b6f327 Turn the confusion of busyobj flags into a #include table.

Poul-Henning Kamp phk at FreeBSD.org
Thu Jan 16 16:15:11 CET 2014


commit 2b6f3276a105cff0f3c79558ca11b46ceafb0bdb
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Thu Jan 16 15:14:35 2014 +0000

    Turn the confusion of busyobj flags into a #include table.

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index baf09a1..4f1c550 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -527,8 +527,6 @@ struct busyobj {
 	struct req		*req;
 
 	uint8_t			*vary;
-	unsigned		is_gzip;
-	unsigned		is_gunzip;
 
 #define N_VFPS			5
 	vfp_pull_f		*vfps[N_VFPS];
@@ -551,18 +549,11 @@ struct busyobj {
 
 	struct pool_task	fetch_task;
 
-	unsigned		should_close;
 	char			*h_content_length;
 
-	unsigned		do_esi;
-	unsigned		do_gzip;
-	unsigned		do_gunzip;
-	unsigned		do_stream;
-
-	/* do_pass is our intent, uncacheable is the result */
-	unsigned		do_pass;
-	unsigned		uncacheable;
-	unsigned		abandon;
+#define BO_FLAG(l, r, w, d) unsigned	l:1;
+#include "tbl/bo_flags.h"
+#undef BO_FLAG
 
 	/* Timeouts */
 	double			connect_timeout;
diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c
index 8f8f8fd..21dac0b 100644
--- a/bin/varnishd/cache/cache_panic.c
+++ b/bin/varnishd/cache/cache_panic.c
@@ -267,13 +267,10 @@ pan_busyobj(const struct busyobj *bo)
 
 	VSB_printf(pan_vsp, "  busyobj = %p {\n", bo);
 	pan_ws(bo->ws, 4);
-	if (bo->is_gzip)	VSB_printf(pan_vsp, "    is_gzip\n");
-	if (bo->is_gunzip)	VSB_printf(pan_vsp, "    is_gunzip\n");
-	if (bo->do_gzip)	VSB_printf(pan_vsp, "    do_gzip\n");
-	if (bo->do_gunzip)	VSB_printf(pan_vsp, "    do_gunzip\n");
-	if (bo->do_esi)		VSB_printf(pan_vsp, "    do_esi\n");
-	if (bo->do_stream)	VSB_printf(pan_vsp, "    do_stream\n");
-	if (bo->should_close)	VSB_printf(pan_vsp, "    should_close\n");
+#define BO_FLAG(l, r, w, d) if(bo->l) VSB_printf(pan_vsp, "    is_" #l "\n");
+#include "tbl/bo_flags.h"
+#undef BO_FLAG
+
 	VSB_printf(pan_vsp, "    bodystatus = %d (%s),\n",
 	    bo->htc.body_status, body_status_2str(bo->htc.body_status));
 	VSB_printf(pan_vsp, "    },\n");
diff --git a/bin/varnishd/cache/cache_vrt_var.c b/bin/varnishd/cache/cache_vrt_var.c
index cb0d42e..607c6f1 100644
--- a/bin/varnishd/cache/cache_vrt_var.c
+++ b/bin/varnishd/cache/cache_vrt_var.c
@@ -121,27 +121,31 @@ VRT_DO_STATUS(beresp)
 
 /*--------------------------------------------------------------------*/
 
-#define VBERESP(dir, type, onm, field)					\
+#define VBERESPW0(field)
+#define VBERESPW1(field)						\
 void									\
-VRT_l_##dir##_##onm(const struct vrt_ctx *ctx, type a)			\
+VRT_l_beresp_##field(const struct vrt_ctx *ctx, unsigned a)		\
 {									\
 	CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);				\
 	CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC);			\
-	ctx->bo->field = a;						\
-}									\
-									\
-type									\
-VRT_r_##dir##_##onm(const struct vrt_ctx *ctx)				\
+	ctx->bo->field = a ? 1 : 0;					\
+}
+
+#define VBERESPR0(field)
+#define VBERESPR1(field)						\
+unsigned								\
+VRT_r_beresp_##field(const struct vrt_ctx *ctx)				\
 {									\
 	CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);				\
 	CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC);			\
 	return (ctx->bo->field);					\
 }
 
-VBERESP(beresp, unsigned, do_esi,	do_esi)
-VBERESP(beresp, unsigned, do_gzip,	do_gzip)
-VBERESP(beresp, unsigned, do_gunzip,	do_gunzip)
-VBERESP(beresp, unsigned, do_stream,	do_stream)
+#define BO_FLAG(l, r, w, d) \
+	VBERESPR##r(l) \
+	VBERESPW##r(l)
+#include "tbl/bo_flags.h"
+#undef BO_FLAG
 
 /*--------------------------------------------------------------------*/
 
diff --git a/include/Makefile.am b/include/Makefile.am
index 17633ce..3813836 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -5,6 +5,7 @@ nobase_pkginclude_HEADERS = \
 	tbl/acct_fields.h \
 	tbl/backend_poll.h \
 	tbl/ban_vars.h \
+	tbl/bo_flags.h \
 	tbl/body_status.h \
 	tbl/debug_bits.h \
 	tbl/feature_bits.h \
diff --git a/include/tbl/bo_flags.h b/include/tbl/bo_flags.h
new file mode 100644
index 0000000..ac52ef7
--- /dev/null
+++ b/include/tbl/bo_flags.h
@@ -0,0 +1,44 @@
+/*-
+ * Copyright (c) 2014 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.
+ *
+ */
+
+/*lint -save -e525 -e539 */
+
+/* lower, vcl_r, vcl_w, doc */
+BO_FLAG(do_esi,		1, 1, "")
+BO_FLAG(do_gzip,	1, 1, "")
+BO_FLAG(do_gunzip,	1, 1, "")
+BO_FLAG(do_stream,	1, 1, "")
+BO_FLAG(do_pass,	0, 0, "")
+BO_FLAG(uncacheable,	0, 0, "")
+BO_FLAG(abandon,	0, 0, "")
+BO_FLAG(is_gzip,	0, 0, "")
+BO_FLAG(is_gunzip,	0, 0, "")
+BO_FLAG(should_close,	0, 0, "")
+
+/*lint -restore */



More information about the varnish-commit mailing list