[master] 62c5b88 Clean up vfp_ctx a bit.

Poul-Henning Kamp phk at FreeBSD.org
Thu Oct 26 13:30:16 UTC 2017


commit 62c5b886dbdd2b65ef7629058010526b603efa70
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Thu Oct 26 09:58:00 2017 +0000

    Clean up vfp_ctx a bit.

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 9ee0917..dc0a12c 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -175,17 +175,14 @@ VTAILQ_HEAD(vfp_entry_s, vfp_entry);
 struct vfp_ctx {
 	unsigned		magic;
 #define VFP_CTX_MAGIC		0x61d9d3e5
-	struct busyobj		*bo;
+	int			failed;
+	struct http		*req;
+	struct http		*resp;
 	struct worker		*wrk;
 	struct objcore		*oc;
 
-	int			failed;
-
 	struct vfp_entry_s	vfp;
 	struct vfp_entry	*vfp_nxt;
-
-	struct http		*http;
-	struct http		*esi_req;
 };
 
 /*--------------------------------------------------------------------
diff --git a/bin/varnishd/cache/cache_esi_fetch.c b/bin/varnishd/cache/cache_esi_fetch.c
index 071fb79..47ea1c8 100644
--- a/bin/varnishd/cache/cache_esi_fetch.c
+++ b/bin/varnishd/cache/cache_esi_fetch.c
@@ -84,7 +84,6 @@ vfp_vep_callback(struct vfp_ctx *vc, void *priv, ssize_t l, enum vgz_flag flg)
 	if (l == 0 && flg == VGZ_NORMAL)
 		return (vef->tot);
 
-	CHECK_OBJ_NOTNULL(vc->bo, BUSYOBJ_MAGIC);
 	VGZ_Ibuf(vef->vgz, vef->ibuf_o, l);
 	do {
 		dl = 0;
@@ -152,13 +151,13 @@ vfp_esi_gzip_init(struct vfp_ctx *vc, struct vfp_entry *vfe)
 	struct vef_priv *vef;
 
 	CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC);
-	CHECK_OBJ_NOTNULL(vc->esi_req, HTTP_MAGIC);
+	CHECK_OBJ_NOTNULL(vc->req, HTTP_MAGIC);
 	CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC);
 	ALLOC_OBJ(vef, VEF_MAGIC);
 	if (vef == NULL)
 		return (VFP_ERROR);
 	vef->vgz = VGZ_NewGzip(vc->wrk->vsl, "G F E");
-	vef->vep = VEP_Init(vc, vc->esi_req, vfp_vep_callback, vef);
+	vef->vep = VEP_Init(vc, vc->req, vfp_vep_callback, vef);
 	vef->ibuf_sz = cache_param->gzip_buffer;
 	vef->ibuf = calloc(1L, vef->ibuf_sz);
 	if (vef->ibuf == NULL)
@@ -167,12 +166,12 @@ vfp_esi_gzip_init(struct vfp_ctx *vc, struct vfp_entry *vfe)
 	vef->ibuf_o = vef->ibuf;
 	vfe->priv1 = vef;
 
-	RFC2616_Weaken_Etag(vc->http);
-	http_Unset(vc->http, H_Content_Length);
-	http_Unset(vc->http, H_Content_Encoding);
-	http_SetHeader(vc->http, "Content-Encoding: gzip");
+	RFC2616_Weaken_Etag(vc->resp);
+	http_Unset(vc->resp, H_Content_Length);
+	http_Unset(vc->resp, H_Content_Encoding);
+	http_SetHeader(vc->resp, "Content-Encoding: gzip");
 
-	RFC2616_Vary_AE(vc->http);
+	RFC2616_Vary_AE(vc->resp);
 
 	return (VFP_OK);
 }
@@ -226,11 +225,11 @@ vfp_esi_init(struct vfp_ctx *vc, struct vfp_entry *vfe)
 	struct vef_priv *vef;
 
 	CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC);
-	CHECK_OBJ_NOTNULL(vc->esi_req, HTTP_MAGIC);
+	CHECK_OBJ_NOTNULL(vc->req, HTTP_MAGIC);
 	ALLOC_OBJ(vef, VEF_MAGIC);
 	if (vef == NULL)
 		return (VFP_ERROR);
-	vef->vep = VEP_Init(vc, vc->esi_req, NULL, NULL);
+	vef->vep = VEP_Init(vc, vc->req, NULL, NULL);
 	vfe->priv1 = vef;
 	return (VFP_OK);
 }
diff --git a/bin/varnishd/cache/cache_esi_parse.c b/bin/varnishd/cache/cache_esi_parse.c
index 5ce78bd..048672b 100644
--- a/bin/varnishd/cache/cache_esi_parse.c
+++ b/bin/varnishd/cache/cache_esi_parse.c
@@ -1030,7 +1030,7 @@ VEP_Init(struct vfp_ctx *vc, const struct http *req, vep_callback_t *cb,
 
 	CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC);
 	CHECK_OBJ_NOTNULL(req, HTTP_MAGIC);
-	vep = WS_Alloc(vc->http->ws, sizeof *vep);
+	vep = WS_Alloc(vc->resp->ws, sizeof *vep);
 	AN(vep);
 
 	INIT_OBJ(vep, VEP_MAGIC);
diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index 167c8a5..9c25e70 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -288,10 +288,9 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo)
 	AZ(bo->htc);
 
 	VFP_Setup(bo->vfc, wrk);
-	bo->vfc->bo = bo;
 	bo->vfc->oc = bo->fetch_objcore;
-	bo->vfc->http = bo->beresp;
-	bo->vfc->esi_req = bo->bereq;
+	bo->vfc->resp = bo->beresp;
+	bo->vfc->req = bo->bereq;
 
 	i = VDI_GetHdr(wrk, bo);
 
@@ -812,11 +811,10 @@ vbf_stp_error(struct worker *wrk, struct busyobj *bo)
 
 	assert(wrk->handling == VCL_RET_DELIVER);
 
-	assert(bo->vfc->bo == bo);
 	assert(bo->vfc->wrk == bo->wrk);
 	assert(bo->vfc->oc == bo->fetch_objcore);
-	assert(bo->vfc->http == bo->beresp);
-	assert(bo->vfc->esi_req == bo->bereq);
+	assert(bo->vfc->resp == bo->beresp);
+	assert(bo->vfc->req == bo->bereq);
 
 	if (vbf_beresp2obj(bo)) {
 		(void)VFP_Error(bo->vfc, "Could not get storage");
diff --git a/bin/varnishd/cache/cache_fetch_proc.c b/bin/varnishd/cache/cache_fetch_proc.c
index 3426f78..7d9bf5c 100644
--- a/bin/varnishd/cache/cache_fetch_proc.c
+++ b/bin/varnishd/cache/cache_fetch_proc.c
@@ -134,7 +134,7 @@ VFP_Open(struct vfp_ctx *vc)
 	struct vfp_entry *vfe;
 
 	CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC);
-	CHECK_OBJ_NOTNULL(vc->http, HTTP_MAGIC);
+	CHECK_OBJ_NOTNULL(vc->resp, HTTP_MAGIC);
 	CHECK_OBJ_NOTNULL(vc->wrk, WORKER_MAGIC);
 	AN(vc->wrk->vsl);
 
@@ -201,9 +201,9 @@ VFP_Push(struct vfp_ctx *vc, const struct vfp *vfp)
 	struct vfp_entry *vfe;
 
 	CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC);
-	CHECK_OBJ_NOTNULL(vc->http, HTTP_MAGIC);
+	CHECK_OBJ_NOTNULL(vc->resp, HTTP_MAGIC);
 
-	vfe = WS_Alloc(vc->http->ws, sizeof *vfe);
+	vfe = WS_Alloc(vc->resp->ws, sizeof *vfe);
 	if (vfe == NULL) {
 		(void)VFP_Error(vc, "Workspace overflow");
 		return (NULL);
diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c
index f2b638a..28e99e3 100644
--- a/bin/varnishd/cache/cache_gzip.c
+++ b/bin/varnishd/cache/cache_gzip.c
@@ -446,11 +446,11 @@ vfp_gzip_init(struct vfp_ctx *vc, struct vfp_entry *vfe)
 	CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC);
 
 	if (vfe->vfp == &VFP_gzip) {
-		if (http_GetHdr(vc->http, H_Content_Encoding, NULL))
+		if (http_GetHdr(vc->resp, H_Content_Encoding, NULL))
 			return (VFP_NULL);
 		vg = VGZ_NewGzip(vc->wrk->vsl, vfe->vfp->priv1);
 	} else {
-		if (!http_HdrIs(vc->http, H_Content_Encoding, "gzip"))
+		if (!http_HdrIs(vc->resp, H_Content_Encoding, "gzip"))
 			return (VFP_NULL);
 		if (vfe->vfp == &VFP_gunzip)
 			vg = VGZ_NewGunzip(vc->wrk->vsl, vfe->vfp->priv1);
@@ -466,16 +466,16 @@ vfp_gzip_init(struct vfp_ctx *vc, struct vfp_entry *vfe)
 	AZ(vg->m_len);
 
 	if (vfe->vfp == &VFP_gunzip || vfe->vfp == &VFP_gzip) {
-		http_Unset(vc->http, H_Content_Encoding);
-		http_Unset(vc->http, H_Content_Length);
-		RFC2616_Weaken_Etag(vc->http);
+		http_Unset(vc->resp, H_Content_Encoding);
+		http_Unset(vc->resp, H_Content_Length);
+		RFC2616_Weaken_Etag(vc->resp);
 	}
 
 	if (vfe->vfp == &VFP_gzip)
-		http_SetHeader(vc->http, "Content-Encoding: gzip");
+		http_SetHeader(vc->resp, "Content-Encoding: gzip");
 
 	if (vfe->vfp == &VFP_gzip || vfe->vfp == &VFP_testgunzip)
-		RFC2616_Vary_AE(vc->http);
+		RFC2616_Vary_AE(vc->resp);
 
 	return (VFP_OK);
 }
diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c
index 8ea3621..649b74a 100644
--- a/bin/varnishd/cache/cache_req_fsm.c
+++ b/bin/varnishd/cache/cache_req_fsm.c
@@ -92,7 +92,7 @@ cnt_transport(struct worker *wrk, struct req *req)
 	if (req->req_body_status < REQ_BODY_TAKEN) {
 		AN(req->transport->req_body != NULL);
 		VFP_Setup(req->vfc, wrk);
-		req->vfc->http = req->http;
+		req->vfc->resp = req->http;		// XXX
 		req->transport->req_body(req);
 	}
 
diff --git a/bin/varnishd/http1/cache_http1_fetch.c b/bin/varnishd/http1/cache_http1_fetch.c
index 6c14193..e823c18 100644
--- a/bin/varnishd/http1/cache_http1_fetch.c
+++ b/bin/varnishd/http1/cache_http1_fetch.c
@@ -203,7 +203,7 @@ V1F_FetchRespHdr(struct busyobj *bo)
 	htc->doclose = http_DoConnection(hp);
 	RFC2616_Response_Body(bo->wrk, bo);
 
-	assert(bo->vfc->http == bo->beresp);
+	assert(bo->vfc->resp == bo->beresp);
 	if (bo->htc->body_status != BS_NONE &&
 	    bo->htc->body_status != BS_ERROR)
 		(void)V1F_Setup_Fetch(bo->vfc, bo->htc);


More information about the varnish-commit mailing list