[6.0] 322bcca64 Make the individual VFP->init()'s responsible for the objflags.

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Thu Aug 16 08:52:45 UTC 2018


commit 322bcca6431ce0920e0330dd72b3a5af2fa6eebb
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Tue Apr 17 21:00:17 2018 +0000

    Make the individual VFP->init()'s responsible for the objflags.

diff --git a/bin/varnishd/cache/cache_esi_fetch.c b/bin/varnishd/cache/cache_esi_fetch.c
index 906c2ba3a..5411df238 100644
--- a/bin/varnishd/cache/cache_esi_fetch.c
+++ b/bin/varnishd/cache/cache_esi_fetch.c
@@ -156,6 +156,7 @@ vfp_esi_gzip_init(struct vfp_ctx *vc, struct vfp_entry *vfe)
 	ALLOC_OBJ(vef, VEF_MAGIC);
 	if (vef == NULL)
 		return (VFP_ERROR);
+	vc->obj_flags |= OF_GZIPED | OF_CHGGZIP | OF_ESIPROC;
 	vef->vgz = VGZ_NewGzip(vc->wrk->vsl, "G F E");
 	vef->vep = VEP_Init(vc, vc->req, vfp_vep_callback, vef);
 	vef->ibuf_sz = cache_param->gzip_buffer;
@@ -229,6 +230,7 @@ vfp_esi_init(struct vfp_ctx *vc, struct vfp_entry *vfe)
 	ALLOC_OBJ(vef, VEF_MAGIC);
 	if (vef == NULL)
 		return (VFP_ERROR);
+	vc->obj_flags |= OF_ESIPROC;
 	vef->vep = VEP_Init(vc, vc->req, NULL, NULL);
 	vfe->priv1 = vef;
 	return (VFP_OK);
diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index 27e7e70c9..aacbc69e6 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -503,6 +503,7 @@ vbf_stp_fetchbody(struct worker *wrk, struct busyobj *bo)
 static int
 vbf_figure_out_vfp(struct busyobj *bo)
 {
+	int is_gzip, is_gunzip;
 
 	/*
 	 * The VCL variables beresp.do_g[un]zip tells us how we want the
@@ -543,26 +544,26 @@ vbf_figure_out_vfp(struct busyobj *bo)
 	if (!cache_param->http_gzip_support)
 		bo->do_gzip = bo->do_gunzip = 0;
 
-	bo->is_gzip = http_HdrIs(bo->beresp, H_Content_Encoding, "gzip");
-	bo->is_gunzip = !http_GetHdr(bo->beresp, H_Content_Encoding, NULL);
-	assert(bo->is_gzip == 0 || bo->is_gunzip == 0);
+	is_gzip = http_HdrIs(bo->beresp, H_Content_Encoding, "gzip");
+	is_gunzip = !http_GetHdr(bo->beresp, H_Content_Encoding, NULL);
+	assert(is_gzip == 0 || is_gunzip == 0);
 
 	/* We won't gunzip unless it is gzip'ed */
-	if (bo->do_gunzip && !bo->is_gzip)
+	if (bo->do_gunzip && !is_gzip)
 		bo->do_gunzip = 0;
 
 	/* We wont gzip unless if it already is gzip'ed */
-	if (bo->do_gzip && !bo->is_gunzip)
+	if (bo->do_gzip && !is_gunzip)
 		bo->do_gzip = 0;
 
 	/* But we can't do both at the same time */
 	assert(bo->do_gzip == 0 || bo->do_gunzip == 0);
 
-	if (bo->do_gunzip || (bo->is_gzip && bo->do_esi))
+	if (bo->do_gunzip || (is_gzip && bo->do_esi))
 		if (VFP_Push(bo->vfc, &VFP_gunzip) == NULL)
 			return (-1);
 
-	if (bo->do_esi && (bo->do_gzip || (bo->is_gzip && !bo->do_gunzip)))
+	if (bo->do_esi && (bo->do_gzip || (is_gzip && !bo->do_gunzip)))
 		return (VFP_Push(bo->vfc, &VFP_esi_gzip) == NULL ? -1 : 0);
 
 	if (bo->do_esi)
@@ -571,7 +572,7 @@ vbf_figure_out_vfp(struct busyobj *bo)
 	if (bo->do_gzip)
 		return (VFP_Push(bo->vfc, &VFP_gzip) == NULL ? -1 : 0);
 
-	if (bo->is_gzip && !bo->do_gunzip)
+	if (is_gzip && !bo->do_gunzip)
 		return (VFP_Push(bo->vfc, &VFP_testgunzip) == NULL ? -1 : 0);
 
 	return (0);
@@ -614,14 +615,10 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo)
 		return (F_STP_ERROR);
 	}
 
-	if (bo->do_esi)
-		ObjSetFlag(bo->wrk, bo->fetch_objcore, OF_ESIPROC, 1);
-
-	if (bo->do_gzip || (bo->is_gzip && !bo->do_gunzip))
-		ObjSetFlag(bo->wrk, bo->fetch_objcore, OF_GZIPED, 1);
-
-	if (bo->do_gzip || bo->do_gunzip)
-		ObjSetFlag(bo->wrk, bo->fetch_objcore, OF_CHGGZIP, 1);
+#define OBJ_FLAG(U, l, v)						\
+	if (bo->vfc->obj_flags & OF_##U)				\
+		ObjSetFlag(bo->wrk, bo->fetch_objcore, OF_##U, 1);
+#include "tbl/obj_attr.h"
 
 	if (!(bo->fetch_objcore->flags & OC_F_PASS) &&
 	    http_IsStatus(bo->beresp, 200) && (
diff --git a/bin/varnishd/cache/cache_filter.h b/bin/varnishd/cache/cache_filter.h
index 474583613..f6dae16e9 100644
--- a/bin/varnishd/cache/cache_filter.h
+++ b/bin/varnishd/cache/cache_filter.h
@@ -82,6 +82,7 @@ struct vfp_ctx {
 
 	struct vfp_entry_s	vfp;
 	struct vfp_entry	*vfp_nxt;
+	unsigned		obj_flags;
 };
 
 enum vfp_status VFP_Suck(struct vfp_ctx *, void *p, ssize_t *lp);
diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c
index 72a86dd99..2c6e9cea7 100644
--- a/bin/varnishd/cache/cache_gzip.c
+++ b/bin/varnishd/cache/cache_gzip.c
@@ -446,13 +446,18 @@ vfp_gzip_init(struct vfp_ctx *vc, struct vfp_entry *vfe)
 		if (http_GetHdr(vc->resp, H_Content_Encoding, NULL))
 			return (VFP_NULL);
 		vg = VGZ_NewGzip(vc->wrk->vsl, vfe->vfp->priv1);
+		vc->obj_flags |= OF_GZIPED | OF_CHGGZIP;
 	} else {
 		if (!http_HdrIs(vc->resp, H_Content_Encoding, "gzip"))
 			return (VFP_NULL);
-		if (vfe->vfp == &VFP_gunzip)
+		if (vfe->vfp == &VFP_gunzip) {
 			vg = VGZ_NewGunzip(vc->wrk->vsl, vfe->vfp->priv1);
-		else
+			vc->obj_flags &= ~OF_GZIPED;
+			vc->obj_flags |= OF_CHGGZIP;
+		} else {
 			vg = VGZ_NewTestGunzip(vc->wrk->vsl, vfe->vfp->priv1);
+			vc->obj_flags |= OF_GZIPED;
+		}
 	}
 	if (vg == NULL)
 		return (VFP_ERROR);
diff --git a/include/tbl/bo_flags.h b/include/tbl/bo_flags.h
index 575769997..88b8eebe3 100644
--- a/include/tbl/bo_flags.h
+++ b/include/tbl/bo_flags.h
@@ -36,8 +36,6 @@ 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(is_gzip,	0, 0, "")
-BO_FLAG(is_gunzip,	0, 0, "")
 BO_FLAG(was_304,	1, 0, "")
 BO_FLAG(is_bgfetch,	0, 0, "")
 #undef BO_FLAG


More information about the varnish-commit mailing list