[master] ac632fd Make it possible to push VFPs both on top and bottom of the stack and put the V1F VFPs after all the gzip/esi etc. have been pushed.

Poul-Henning Kamp phk at FreeBSD.org
Wed Jul 9 12:25:41 CEST 2014


commit ac632fdf4553beda4c44333295a9460cac797b11
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Wed Jul 9 10:24:48 2014 +0000

    Make it possible to push VFPs both on top and bottom of the stack
    and put the V1F VFPs after all the gzip/esi etc. have been pushed.

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 0efc30e..ef6423d 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -884,7 +884,6 @@ enum vfp_status VFP_Error(struct busyobj *, const char *fmt, ...)
     __printflike(2, 3);
 void VFP_Init(void);
 void VFP_Fetch_Body(struct busyobj *bo);
-void VFP_Push(struct busyobj *, const struct vfp *, intptr_t priv);
 enum vfp_status VFP_Suck(struct busyobj *, void *p, ssize_t *lp);
 
 /* cache_gzip.c */
diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index 64ae86e..afab80c 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -442,8 +442,6 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo)
 		bo->do_gzip = 0;
 
 	AN(bo->vbc);
-	if (bo->htc.body_status != BS_NONE)
-		V1F_Setup_Fetch(bo);
 
 	if (bo->content_length == 0) {
 		/*
@@ -467,22 +465,22 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo)
 
 	if (bo->do_gunzip || (bo->is_gzip && bo->do_esi)) {
 		RFC2616_Weaken_Etag(bo->beresp);
-		VFP_Push(bo, &vfp_gunzip, 0);
+		VFP_Push(bo, &vfp_gunzip, 0, 1);
 	}
 
 	if (bo->do_esi && bo->do_gzip) {
-		VFP_Push(bo, &vfp_esi_gzip, 0);
+		VFP_Push(bo, &vfp_esi_gzip, 0, 1);
 		RFC2616_Weaken_Etag(bo->beresp);
 	} else if (bo->do_esi && bo->is_gzip && !bo->do_gunzip) {
-		VFP_Push(bo, &vfp_esi_gzip, 0);
+		VFP_Push(bo, &vfp_esi_gzip, 0, 1);
 		RFC2616_Weaken_Etag(bo->beresp);
 	} else if (bo->do_esi) {
-		VFP_Push(bo, &vfp_esi, 0);
+		VFP_Push(bo, &vfp_esi, 0, 1);
 	} else if (bo->do_gzip) {
-		VFP_Push(bo, &vfp_gzip, 0);
+		VFP_Push(bo, &vfp_gzip, 0, 1);
 		RFC2616_Weaken_Etag(bo->beresp);
 	} else if (bo->is_gzip && !bo->do_gunzip) {
-		VFP_Push(bo, &vfp_testgunzip, 0);
+		VFP_Push(bo, &vfp_testgunzip, 0, 1);
 	}
 
 	if (bo->fetch_objcore->flags & OC_F_PRIVATE)
@@ -508,6 +506,9 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo)
 	if (bo->do_gzip || bo->do_gunzip)
 		obj->changed_gzip = 1;
 
+	if (bo->htc.body_status != BS_NONE)
+		V1F_Setup_Fetch(bo);
+
 	/*
 	 * Ready to fetch the body
 	 */
diff --git a/bin/varnishd/cache/cache_fetch_proc.c b/bin/varnishd/cache/cache_fetch_proc.c
index a6d6df1..7b95617 100644
--- a/bin/varnishd/cache/cache_fetch_proc.c
+++ b/bin/varnishd/cache/cache_fetch_proc.c
@@ -255,7 +255,7 @@ VFP_Fetch_Body(struct busyobj *bo)
 }
 
 void
-VFP_Push(struct busyobj *bo, const struct vfp *vfp, intptr_t priv)
+VFP_Push(struct busyobj *bo, const struct vfp *vfp, intptr_t priv, int top)
 {
 	struct vfp_entry *vfe;
 
@@ -266,8 +266,12 @@ VFP_Push(struct busyobj *bo, const struct vfp *vfp, intptr_t priv)
 	vfe->vfp = vfp;
 	vfe->priv2 = priv;
 	vfe->closed = VFP_OK;
-	VTAILQ_INSERT_HEAD(&bo->vfp, vfe, list);
-	bo->vfp_nxt = vfe;
+	if (top)
+		VTAILQ_INSERT_HEAD(&bo->vfp, vfe, list);
+	else
+		VTAILQ_INSERT_TAIL(&bo->vfp, vfe, list);
+	if (VTAILQ_FIRST(&bo->vfp) == vfe)
+		bo->vfp_nxt = vfe;
 }
 
 /*--------------------------------------------------------------------
diff --git a/bin/varnishd/cache/cache_filter.h b/bin/varnishd/cache/cache_filter.h
index a5716a4..933d2e7 100644
--- a/bin/varnishd/cache/cache_filter.h
+++ b/bin/varnishd/cache/cache_filter.h
@@ -59,6 +59,8 @@ extern const struct vfp vfp_testgunzip;
 extern const struct vfp vfp_esi;
 extern const struct vfp vfp_esi_gzip;
 
+void VFP_Push(struct busyobj *, const struct vfp *, intptr_t priv, int top);
+
 
 /* Deliver processors ------------------------------------------------*/
 
diff --git a/bin/varnishd/cache/cache_http1_fetch.c b/bin/varnishd/cache/cache_http1_fetch.c
index 3a381af..47b5029 100644
--- a/bin/varnishd/cache/cache_http1_fetch.c
+++ b/bin/varnishd/cache/cache_http1_fetch.c
@@ -161,15 +161,15 @@ V1F_Setup_Fetch(struct busyobj *bo)
 	switch(htc->body_status) {
 	case BS_EOF:
 		assert(bo->content_length == -1);
-		VFP_Push(bo, &v1f_eof, 0);
+		VFP_Push(bo, &v1f_eof, 0, 0);
 		break;
 	case BS_LENGTH:
 		assert(bo->content_length > 0);
-		VFP_Push(bo, &v1f_straight, bo->content_length);
+		VFP_Push(bo, &v1f_straight, bo->content_length, 0);
 		break;
 	case BS_CHUNKED:
 		assert(bo->content_length == -1);
-		VFP_Push(bo, &v1f_chunked, -1);
+		VFP_Push(bo, &v1f_chunked, -1, 0);
 		break;
 	default:
 		WRONG("Wrong body_status");



More information about the varnish-commit mailing list