[master] e5813c0 Open the VFP pipe before we start streaming, and change the open order to bottom up, so that header modifications happen in the sensible order.

Poul-Henning Kamp phk at FreeBSD.org
Wed Jul 9 15:58:26 CEST 2014


commit e5813c05866224815ec23431eb5cf29ef7533360
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Wed Jul 9 13:56:48 2014 +0000

    Open the VFP pipe before we start streaming, and change the open
    order to bottom up, so that header modifications happen in the
    sensible order.

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index ef6423d..dc781b6 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -454,6 +454,8 @@ struct vfp_entry {
 	VTAILQ_ENTRY(vfp_entry)	list;
 };
 
+VTAILQ_HEAD(vfp_entry_s, vfp_entry);
+
 struct busyobj {
 	unsigned		magic;
 #define BUSYOBJ_MAGIC		0x23b95567
@@ -471,7 +473,7 @@ struct busyobj {
 
 	uint8_t			*vary;
 
-	VTAILQ_HEAD(,vfp_entry)	vfp;
+	struct vfp_entry_s	vfp;
 	struct vfp_entry	*vfp_nxt;
 
 	int			failed;
diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index 7824e26..22cfac6 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -481,7 +481,7 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo)
 
 	if (vbf_beresp2obj(bo)) {
 		(void)VFP_Error(bo, "Could not get storage");
-		VDI_CloseFd(&bo->vbc, &bo->acct);
+		bo->should_close = 1;
 		return (F_STP_ERROR);
 	}
 
@@ -508,6 +508,12 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo)
 
 	assert (bo->state == BOS_REQ_DONE);
 
+	if (VFP_Open(bo)) {
+		(void)VFP_Error(bo, "Fetch Pipeline failed to open");
+		bo->should_close = 1;
+		return (F_STP_ERROR);
+	}
+
 	if (bo->do_stream) {
 		HSH_Unbusy(&wrk->stats, obj->objcore);
 		VBO_setstate(bo, BOS_STREAM);
diff --git a/bin/varnishd/cache/cache_fetch_proc.c b/bin/varnishd/cache/cache_fetch_proc.c
index 72f2a81..a60269a 100644
--- a/bin/varnishd/cache/cache_fetch_proc.c
+++ b/bin/varnishd/cache/cache_fetch_proc.c
@@ -118,24 +118,24 @@ vfp_suck_fini(struct busyobj *bo)
 			vfe->vfp->fini(bo, vfe);
 }
 
-static enum vfp_status
-vfp_suck_init(struct busyobj *bo)
+int
+VFP_Open(struct busyobj *bo)
 {
 	struct vfp_entry *vfe;
 
-	VTAILQ_FOREACH(vfe, &bo->vfp, list) {
+	VTAILQ_FOREACH_REVERSE(vfe, &bo->vfp, vfp_entry_s, list) {
 		if (vfe->vfp->init == NULL)
 			continue;
 		vfe->closed = vfe->vfp->init(bo, vfe);
 		if (vfe->closed != VFP_OK && vfe->closed != VFP_NULL) {
 			(void)VFP_Error(bo,
-			    "Fetch filter %s failed to initialize",
+			    "Fetch filter %s failed to open",
 			    vfe->vfp->name);
 			vfp_suck_fini(bo);
-			return (vfe->closed);
+			return (-1);
 		}
 	}
-	return (VFP_OK);
+	return (0);
 }
 
 /**********************************************************************
@@ -196,12 +196,6 @@ VFP_Fetch_Body(struct busyobj *bo)
 	if (est < 0)
 		est = 0;
 
-	if (vfp_suck_init(bo) != VFP_OK) {
-		(void)VFP_Error(bo, "Fetch Pipeline failed to initialize");
-		bo->should_close = 1;
-		return;
-	}
-
 	do {
 		if (bo->abandon) {
 			/*
diff --git a/bin/varnishd/cache/cache_filter.h b/bin/varnishd/cache/cache_filter.h
index 8fae76a..fdded29 100644
--- a/bin/varnishd/cache/cache_filter.h
+++ b/bin/varnishd/cache/cache_filter.h
@@ -61,6 +61,7 @@ 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);
+int VFP_Open(struct busyobj *bo);
 
 
 /* Deliver processors ------------------------------------------------*/



More information about the varnish-commit mailing list