[master] f79746c Move bo->failed to the vfp_ctx.

Poul-Henning Kamp phk at FreeBSD.org
Thu Jul 17 13:14:11 CEST 2014


commit f79746c9f5ae3b6920b6150af1af5ea975c2d1de
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Thu Jul 17 11:13:25 2014 +0000

    Move bo->failed to the vfp_ctx.

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index cded88d..a6c7006 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -457,6 +457,8 @@ struct vfp_ctx {
 #define VFP_CTX_MAGIC		0x61d9d3e5
 	struct busyobj		*bo;
 
+	int			failed;
+
 	struct vfp_entry_s	vfp;
 	struct vfp_entry	*vfp_nxt;
 
@@ -482,9 +484,8 @@ struct busyobj {
 
 	uint8_t			*vary;
 
-	struct vfp_ctx		vfc;
+	struct vfp_ctx		vfc[1];
 
-	int			failed;
 	enum busyobj_state_e	state;
 
 	struct ws		ws[1];
diff --git a/bin/varnishd/cache/cache_esi_fetch.c b/bin/varnishd/cache/cache_esi_fetch.c
index cc5f8d6..786d638 100644
--- a/bin/varnishd/cache/cache_esi_fetch.c
+++ b/bin/varnishd/cache/cache_esi_fetch.c
@@ -101,7 +101,7 @@ vfp_vep_callback(struct busyobj *bo, void *priv, ssize_t l, enum vgz_flag flg)
 }
 
 static enum vfp_status
-vfp_esi_end(const struct vfp_ctx *vc, struct vef_priv *vef,
+vfp_esi_end(struct vfp_ctx *vc, struct vef_priv *vef,
     enum vfp_status retval)
 {
 	struct vsb *vsb;
diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index 8f967e2..70efc36 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -367,10 +367,10 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo)
 	} else
 		do_ims = 0;
 
-	VFP_Setup(&bo->vfc);
-	bo->vfc.bo = bo;
-	bo->vfc.http = bo->beresp;
-	bo->vfc.vsl = bo->vsl;
+	VFP_Setup(bo->vfc);
+	bo->vfc->bo = bo;
+	bo->vfc->http = bo->beresp;
+	bo->vfc->vsl = bo->vsl;
 
 	VCL_backend_response_method(bo->vcl, wrk, NULL, bo, bo->beresp->ws);
 
@@ -452,18 +452,18 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo)
 	assert(bo->do_gzip == 0 || bo->do_gunzip == 0);
 
 	if (bo->do_gunzip || (bo->is_gzip && bo->do_esi))
-		(void)VFP_Push(&bo->vfc, &vfp_gunzip, 1);
+		(void)VFP_Push(bo->vfc, &vfp_gunzip, 1);
 
 	if (bo->do_esi && bo->do_gzip) {
-		(void)VFP_Push(&bo->vfc, &vfp_esi_gzip, 1);
+		(void)VFP_Push(bo->vfc, &vfp_esi_gzip, 1);
 	} else if (bo->do_esi && bo->is_gzip && !bo->do_gunzip) {
-		(void)VFP_Push(&bo->vfc, &vfp_esi_gzip, 1);
+		(void)VFP_Push(bo->vfc, &vfp_esi_gzip, 1);
 	} else if (bo->do_esi) {
-		(void)VFP_Push(&bo->vfc, &vfp_esi, 1);
+		(void)VFP_Push(bo->vfc, &vfp_esi, 1);
 	} else if (bo->do_gzip) {
-		(void)VFP_Push(&bo->vfc, &vfp_gzip, 1);
+		(void)VFP_Push(bo->vfc, &vfp_gzip, 1);
 	} else if (bo->is_gzip && !bo->do_gunzip) {
-		(void)VFP_Push(&bo->vfc, &vfp_testgunzip, 1);
+		(void)VFP_Push(bo->vfc, &vfp_testgunzip, 1);
 	}
 
 	if (bo->fetch_objcore->flags & OC_F_PRIVATE)
@@ -473,14 +473,14 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo)
 	if (bo->htc.body_status == BS_NONE)
 		bo->do_stream = 0;
 
-	if (VFP_Open(&bo->vfc)) {
-		(void)VFP_Error(&bo->vfc, "Fetch Pipeline failed to open");
+	if (VFP_Open(bo->vfc)) {
+		(void)VFP_Error(bo->vfc, "Fetch Pipeline failed to open");
 		bo->doclose = SC_RX_BODY;
 		return (F_STP_ERROR);
 	}
 
 	if (vbf_beresp2obj(bo)) {
-		(void)VFP_Error(&bo->vfc, "Could not get storage");
+		(void)VFP_Error(bo->vfc, "Could not get storage");
 		bo->doclose = SC_RX_BODY;
 		return (F_STP_ERROR);
 	}
@@ -520,10 +520,10 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo)
 	if (bo->htc.body_status != BS_NONE) {
 		assert(bo->htc.body_status != BS_ERROR);
 		VFP_Fetch_Body(bo);
-		bo->acct.beresp_bodybytes = bo->vfc.bodybytes;
+		bo->acct.beresp_bodybytes = bo->vfc->bodybytes;
 	}
 
-	if (bo->failed && !bo->do_stream) {
+	if (bo->vfc->failed && !bo->do_stream) {
 		assert(bo->state < BOS_STREAM);
 		if (bo->fetch_obj != NULL) {
 			ObjFreeObj(bo->fetch_objcore, bo->stats);
@@ -532,7 +532,7 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo)
 		return (F_STP_ERROR);
 	}
 
-	if (bo->failed)
+	if (bo->vfc->failed)
 		return (F_STP_FAIL);
 
 	if (bo->do_stream)
@@ -633,9 +633,9 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo)
 			if (st->len == st->space)
 				st = NULL;
 		}
-	} while (!bo->failed && (ois == OIS_DATA || ois == OIS_STREAM));
+	} while (!bo->vfc->failed && (ois == OIS_DATA || ois == OIS_STREAM));
 	ObjIterEnd(&oi);
-	if (bo->failed)
+	if (bo->vfc->failed)
 		return (F_STP_FAIL);
 
 	if (!bo->do_stream)
diff --git a/bin/varnishd/cache/cache_fetch_proc.c b/bin/varnishd/cache/cache_fetch_proc.c
index 80952c7..e72d74f 100644
--- a/bin/varnishd/cache/cache_fetch_proc.c
+++ b/bin/varnishd/cache/cache_fetch_proc.c
@@ -53,18 +53,17 @@ static unsigned fetchfrag;
  */
 
 enum vfp_status
-VFP_Error(const struct vfp_ctx *vc, const char *fmt, ...)
+VFP_Error(struct vfp_ctx *vc, const char *fmt, ...)
 {
 	va_list ap;
 
 	CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC);
-	CHECK_OBJ_NOTNULL(vc->bo, BUSYOBJ_MAGIC);
 	assert(vc->bo->state >= BOS_REQ_DONE);
-	if (!vc->bo->failed) {
+	if (!vc->failed) {
 		va_start(ap, fmt);
 		VSLbv(vc->vsl, SLT_FetchError, fmt, ap);
 		va_end(ap);
-		vc->bo->failed = 1;
+		vc->failed = 1;
 	}
 	return (VFP_ERROR);
 }
@@ -96,7 +95,7 @@ VFP_GetStorage(struct busyobj *bo, ssize_t sz)
 		l = cache_param->fetch_chunksize;
 	st = STV_alloc(bo, l);
 	if (st == NULL) {
-		(void)VFP_Error(&bo->vfc, "Could not get storage");
+		(void)VFP_Error(bo->vfc, "Could not get storage");
 	} else {
 		AZ(st->len);
 		Lck_Lock(&bo->mtx);
@@ -201,7 +200,7 @@ VFP_Fetch_Body(struct busyobj *bo)
 
 	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
 
-	AN(bo->vfc.vfp_nxt);
+	AN(bo->vfc->vfp_nxt);
 
 	est = bo->content_length;
 	if (est < 0)
@@ -221,14 +220,14 @@ VFP_Fetch_Body(struct busyobj *bo)
 			bo->doclose = SC_RX_BODY;
 			break;
 		}
-		AZ(bo->failed);
+		AZ(bo->vfc->failed);
 		if (st == NULL) {
 			st = VFP_GetStorage(bo, est);
 			est = 0;
 		}
 		if (st == NULL) {
 			bo->doclose = SC_RX_BODY;
-			(void)VFP_Error(&bo->vfc, "Out of storage");
+			(void)VFP_Error(bo->vfc, "Out of storage");
 			break;
 		}
 
@@ -236,8 +235,8 @@ VFP_Fetch_Body(struct busyobj *bo)
 		assert(st == VTAILQ_LAST(&bo->fetch_obj->body->list,
 		    storagehead));
 		l = st->space - st->len;
-		AZ(bo->failed);
-		vfps = VFP_Suck(&bo->vfc, st->ptr + st->len, &l);
+		AZ(bo->vfc->failed);
+		vfps = VFP_Suck(bo->vfc, st->ptr + st->len, &l);
 		if (l > 0 && vfps != VFP_ERROR) {
 			AZ(VTAILQ_EMPTY(&bo->fetch_obj->body->list));
 			VBO_extend(bo, l);
@@ -247,12 +246,12 @@ VFP_Fetch_Body(struct busyobj *bo)
 	} while (vfps == VFP_OK);
 
 	if (vfps == VFP_ERROR) {
-		AN(bo->failed);
-		(void)VFP_Error(&bo->vfc, "Fetch Pipeline failed to process");
+		AN(bo->vfc->failed);
+		(void)VFP_Error(bo->vfc, "Fetch Pipeline failed to process");
 		bo->doclose = SC_RX_BODY;
 	}
 
-	vfp_suck_fini(&bo->vfc);
+	vfp_suck_fini(bo->vfc);
 
 	if (!bo->do_stream)
 		ObjTrimStore(bo->fetch_objcore, bo->stats);
diff --git a/bin/varnishd/cache/cache_filter.h b/bin/varnishd/cache/cache_filter.h
index 4065cc7..584bf77 100644
--- a/bin/varnishd/cache/cache_filter.h
+++ b/bin/varnishd/cache/cache_filter.h
@@ -65,7 +65,7 @@ struct vfp_entry *VFP_Push(struct vfp_ctx *, const struct vfp *, int top);
 void VFP_Setup(struct vfp_ctx *vc);
 int VFP_Open(struct vfp_ctx *bo);
 enum vfp_status VFP_Suck(struct vfp_ctx *, void *p, ssize_t *lp);
-enum vfp_status VFP_Error(const struct vfp_ctx *, const char *fmt, ...)
+enum vfp_status VFP_Error(struct vfp_ctx *, const char *fmt, ...)
     __printflike(2, 3);
 
 /* Deliver processors ------------------------------------------------*/
diff --git a/bin/varnishd/cache/cache_http1_fetch.c b/bin/varnishd/cache/cache_http1_fetch.c
index 1f53747..b622c3c 100644
--- a/bin/varnishd/cache/cache_http1_fetch.c
+++ b/bin/varnishd/cache/cache_http1_fetch.c
@@ -166,19 +166,19 @@ V1F_Setup_Fetch(struct busyobj *bo)
 	switch(htc->body_status) {
 	case BS_EOF:
 		assert(bo->content_length == -1);
-		vfe = VFP_Push(&bo->vfc, &v1f_eof, 0);
+		vfe = VFP_Push(bo->vfc, &v1f_eof, 0);
 		vfe->priv1 = &bo->htc;
 		vfe->priv2 = 0;
 		break;
 	case BS_LENGTH:
 		assert(bo->content_length > 0);
-		vfe = VFP_Push(&bo->vfc, &v1f_straight, 0);
+		vfe = VFP_Push(bo->vfc, &v1f_straight, 0);
 		vfe->priv1 = &bo->htc;
 		vfe->priv2 = bo->content_length;
 		break;
 	case BS_CHUNKED:
 		assert(bo->content_length == -1);
-		vfe = VFP_Push(&bo->vfc, &v1f_chunked, 0);
+		vfe = VFP_Push(bo->vfc, &v1f_chunked, 0);
 		vfe->priv1 = &bo->htc;
 		vfe->priv2 = -1;
 		break;
diff --git a/bin/varnishd/cache/cache_panic.c b/bin/varnishd/cache/cache_panic.c
index d59333b..9eed031 100644
--- a/bin/varnishd/cache/cache_panic.c
+++ b/bin/varnishd/cache/cache_panic.c
@@ -294,7 +294,7 @@ pan_busyobj(const struct busyobj *bo)
 	pan_ws(bo->ws, 4);
 	VSB_printf(pan_vsp, "  refcnt = %u\n", bo->refcount);
 	VSB_printf(pan_vsp, "  retries = %d\n", bo->retries);
-	VSB_printf(pan_vsp, "  failed = %d\n", bo->failed);
+	VSB_printf(pan_vsp, "  failed = %d\n", bo->vfc->failed);
 	VSB_printf(pan_vsp, "  state = %d\n", (int)bo->state);
 #define BO_FLAG(l, r, w, d) if(bo->l) VSB_printf(pan_vsp, "    is_" #l "\n");
 #include "tbl/bo_flags.h"
@@ -302,9 +302,9 @@ pan_busyobj(const struct busyobj *bo)
 
 	VSB_printf(pan_vsp, "    bodystatus = %d (%s),\n",
 	    bo->htc.body_status, body_status_2str(bo->htc.body_status));
-	if (!VTAILQ_EMPTY(&bo->vfc.vfp)) {
+	if (!VTAILQ_EMPTY(&bo->vfc->vfp)) {
 		VSB_printf(pan_vsp, "    filters =");
-		VTAILQ_FOREACH(vfe, &bo->vfc.vfp, list)
+		VTAILQ_FOREACH(vfe, &bo->vfc->vfp, list)
 			VSB_printf(pan_vsp, " %s=%d",
 			    vfe->vfp->name, (int)vfe->closed);
 		VSB_printf(pan_vsp, "\n");



More information about the varnish-commit mailing list