[6.0] ed4639cd7 Let VPF's handle their own 206 policy.

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


commit ed4639cd752698aa50241354f18293a0227bafeb
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Tue Apr 17 21:26:34 2018 +0000

    Let VPF's handle their own 206 policy.

diff --git a/bin/varnishd/cache/cache_esi_fetch.c b/bin/varnishd/cache/cache_esi_fetch.c
index 5411df238..acc110481 100644
--- a/bin/varnishd/cache/cache_esi_fetch.c
+++ b/bin/varnishd/cache/cache_esi_fetch.c
@@ -153,6 +153,11 @@ vfp_esi_gzip_init(struct vfp_ctx *vc, struct vfp_entry *vfe)
 	CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC);
 	CHECK_OBJ_NOTNULL(vc->req, HTTP_MAGIC);
 	CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC);
+	if (http_GetStatus(vc->resp) == 206) {
+		VSLb(vc->wrk->vsl, SLT_VCL_Error,
+		    "Attempted ESI on partial (206) response");
+		return (VFP_ERROR);
+	}
 	ALLOC_OBJ(vef, VEF_MAGIC);
 	if (vef == NULL)
 		return (VFP_ERROR);
@@ -227,6 +232,11 @@ vfp_esi_init(struct vfp_ctx *vc, struct vfp_entry *vfe)
 
 	CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC);
 	CHECK_OBJ_NOTNULL(vc->req, HTTP_MAGIC);
+	if (http_GetStatus(vc->resp) == 206) {
+		VSLb(vc->wrk->vsl, SLT_VCL_Error,
+		    "Attempted ESI on partial (206) response");
+		return (VFP_ERROR);
+	}
 	ALLOC_OBJ(vef, VEF_MAGIC);
 	if (vef == NULL)
 		return (VFP_ERROR);
diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index aacbc69e6..ee6091dab 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -516,22 +516,8 @@ vbf_figure_out_vfp(struct busyobj *bo)
 	 *	no Content-Encoding		--> object is not gzip'ed.
 	 *	anything else			--> do nothing wrt gzip
 	 *
-	 * On partial responses (206 on pass), we fail if do_esi is
-	 * requested because it could leak partial esi-directives, and
-	 * ignore gzipery, because it makes no sense.
-	 *
 	 */
 
-	if (http_GetStatus(bo->beresp) == 206) {
-		if (bo->do_esi) {
-			VSLb(bo->vsl, SLT_VCL_Error,
-			    "beresp.do_esi on partial response");
-			return (-1);
-		}
-		bo->do_gzip = bo->do_gunzip = 0;
-		return (0);
-	}
-
 	/* No body -> done */
 	if (bo->htc->body_status == BS_NONE ||
 	    bo->htc->content_length == 0) {
diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c
index 2c6e9cea7..3694c0ad2 100644
--- a/bin/varnishd/cache/cache_gzip.c
+++ b/bin/varnishd/cache/cache_gzip.c
@@ -442,6 +442,13 @@ vfp_gzip_init(struct vfp_ctx *vc, struct vfp_entry *vfe)
 	CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC);
 	CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC);
 
+	/*
+	 * G(un)zip makes no sence on partial responses, but since
+	 * it is an pure 1:1 transform, we can just ignore it.
+	 */
+	if (http_GetStatus(vc->resp) == 206)
+		return (VFP_NULL);
+
 	if (vfe->vfp == &VFP_gzip) {
 		if (http_GetHdr(vc->resp, H_Content_Encoding, NULL))
 			return (VFP_NULL);
diff --git a/bin/varnishd/cache/cache_main.c b/bin/varnishd/cache/cache_main.c
index fe8cdb34d..c77cca91b 100644
--- a/bin/varnishd/cache/cache_main.c
+++ b/bin/varnishd/cache/cache_main.c
@@ -102,7 +102,7 @@ THR_SetName(const char *name)
 
 	AZ(pthread_setspecific(name_key, name));
 #if defined(HAVE_PTHREAD_SET_NAME_NP)
-	(void)pthread_set_name_np(pthread_self(), name);
+	pthread_set_name_np(pthread_self(), name);
 #elif defined(HAVE_PTHREAD_SETNAME_NP)
 #if defined(__APPLE__)
 	(void)pthread_setname_np(name);


More information about the varnish-commit mailing list