[master] 7a7d36b Make setting of vfe->priv* fields something callers of VFP_Push() does.

Poul-Henning Kamp phk at FreeBSD.org
Tue Jul 15 09:28:50 CEST 2014


commit 7a7d36bd82b128fd771fbd1365aaef8c6f05f80e
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Tue Jul 15 07:28:16 2014 +0000

    Make setting of vfe->priv* fields something callers of VFP_Push() does.

diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index 536eece..1942765 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -447,18 +447,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))
-		VFP_Push(bo, &vfp_gunzip, 0, 1);
+		(void)VFP_Push(bo, &vfp_gunzip, 1);
 
 	if (bo->do_esi && bo->do_gzip) {
-		VFP_Push(bo, &vfp_esi_gzip, 0, 1);
+		(void)VFP_Push(bo, &vfp_esi_gzip, 1);
 	} else if (bo->do_esi && bo->is_gzip && !bo->do_gunzip) {
-		VFP_Push(bo, &vfp_esi_gzip, 0, 1);
+		(void)VFP_Push(bo, &vfp_esi_gzip, 1);
 	} else if (bo->do_esi) {
-		VFP_Push(bo, &vfp_esi, 0, 1);
+		(void)VFP_Push(bo, &vfp_esi, 1);
 	} else if (bo->do_gzip) {
-		VFP_Push(bo, &vfp_gzip, 0, 1);
+		(void)VFP_Push(bo, &vfp_gzip, 1);
 	} else if (bo->is_gzip && !bo->do_gunzip) {
-		VFP_Push(bo, &vfp_testgunzip, 0, 1);
+		(void)VFP_Push(bo, &vfp_testgunzip, 1);
 	}
 
 	if (bo->fetch_objcore->flags & OC_F_PRIVATE)
diff --git a/bin/varnishd/cache/cache_fetch_proc.c b/bin/varnishd/cache/cache_fetch_proc.c
index 054b279..67039f0 100644
--- a/bin/varnishd/cache/cache_fetch_proc.c
+++ b/bin/varnishd/cache/cache_fetch_proc.c
@@ -244,8 +244,8 @@ VFP_Fetch_Body(struct busyobj *bo)
 		ObjTrimStore(bo->fetch_objcore, bo->stats);
 }
 
-void
-VFP_Push(struct busyobj *bo, const struct vfp *vfp, intptr_t priv, int top)
+struct vfp_entry *
+VFP_Push(struct busyobj *bo, const struct vfp *vfp, int top)
 {
 	struct vfp_entry *vfe;
 
@@ -254,7 +254,6 @@ VFP_Push(struct busyobj *bo, const struct vfp *vfp, intptr_t priv, int top)
 	AN(vfe);
 	vfe->magic = VFP_ENTRY_MAGIC;
 	vfe->vfp = vfp;
-	vfe->priv2 = priv;
 	vfe->closed = VFP_OK;
 	if (top)
 		VTAILQ_INSERT_HEAD(&bo->vfp, vfe, list);
@@ -262,6 +261,7 @@ VFP_Push(struct busyobj *bo, const struct vfp *vfp, intptr_t priv, int top)
 		VTAILQ_INSERT_TAIL(&bo->vfp, vfe, list);
 	if (VTAILQ_FIRST(&bo->vfp) == vfe)
 		bo->vfp_nxt = vfe;
+	return (vfe);
 }
 
 /*--------------------------------------------------------------------
diff --git a/bin/varnishd/cache/cache_filter.h b/bin/varnishd/cache/cache_filter.h
index fdded29..ab0c351 100644
--- a/bin/varnishd/cache/cache_filter.h
+++ b/bin/varnishd/cache/cache_filter.h
@@ -60,7 +60,7 @@ 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);
+struct vfp_entry *VFP_Push(struct busyobj *bo, const struct vfp *vfp, int top);
 int VFP_Open(struct busyobj *bo);
 
 
diff --git a/bin/varnishd/cache/cache_http1_fetch.c b/bin/varnishd/cache/cache_http1_fetch.c
index a36cc70..8ec3553 100644
--- a/bin/varnishd/cache/cache_http1_fetch.c
+++ b/bin/varnishd/cache/cache_http1_fetch.c
@@ -49,10 +49,11 @@ v1f_pull_straight(struct busyobj *bo, struct vfp_entry *vfe, void *p,
     ssize_t *lp)
 {
 	ssize_t l, lr;
+	struct http_conn *htc;
 
 	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
 	CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC);
-
+	CAST_OBJ_NOTNULL(htc, vfe->priv1, HTTP_CONN_MAGIC);
 	AN(p);
 	AN(lp);
 
@@ -63,7 +64,7 @@ v1f_pull_straight(struct busyobj *bo, struct vfp_entry *vfe, void *p,
 		return (VFP_END);
 	if (vfe->priv2 < l)
 		l = vfe->priv2;
-	lr = HTTP1_Read(&bo->htc, p, l);
+	lr = HTTP1_Read(htc, p, l);
 	bo->acct.beresp_bodybytes += lr;
 	if (lr <= 0)
 		return (VFP_Error(bo, "straight insufficient bytes"));
@@ -90,14 +91,15 @@ v1f_pull_chunked(struct busyobj *bo, struct vfp_entry *vfe, void *p,
     ssize_t *lp)
 {
 	const char *err;
+	struct http_conn *htc;
 
 	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
 	CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC);
-
+	CAST_OBJ_NOTNULL(htc, vfe->priv1, HTTP_CONN_MAGIC);
 	AN(p);
 	AN(lp);
 
-	switch (HTTP1_Chunked(&bo->htc, &vfe->priv2, &err,
+	switch (HTTP1_Chunked(htc, &vfe->priv2, &err,
 	    &bo->acct.beresp_bodybytes, p, lp)) {
 	case H1CR_ERROR:
 		return (VFP_Error(bo, "%s", err));
@@ -122,15 +124,17 @@ v1f_pull_eof(struct busyobj *bo, struct vfp_entry *vfe, void *p,
     ssize_t *lp)
 {
 	ssize_t l, lr;
+	struct http_conn *htc;
 
 	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
 	CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC);
+	CAST_OBJ_NOTNULL(htc, vfe->priv1, HTTP_CONN_MAGIC);
 	AN(p);
 	AN(lp);
 
 	l = *lp;
 	*lp = 0;
-	lr = HTTP1_Read(&bo->htc, p, l);
+	lr = HTTP1_Read(htc, p, l);
 	if (lr < 0)
 		return (VFP_Error(bo,"eof socket fail"));
 	if (lr == 0)
@@ -152,6 +156,7 @@ void
 V1F_Setup_Fetch(struct busyobj *bo)
 {
 	struct http_conn *htc;
+	struct vfp_entry *vfe;
 
 	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
 	htc = &bo->htc;
@@ -161,15 +166,21 @@ V1F_Setup_Fetch(struct busyobj *bo)
 	switch(htc->body_status) {
 	case BS_EOF:
 		assert(bo->content_length == -1);
-		VFP_Push(bo, &v1f_eof, 0, 0);
+		vfe = VFP_Push(bo, &v1f_eof, 0);
+		vfe->priv1 = &bo->htc;
+		vfe->priv2 = 0;
 		break;
 	case BS_LENGTH:
 		assert(bo->content_length > 0);
-		VFP_Push(bo, &v1f_straight, bo->content_length, 0);
+		vfe = VFP_Push(bo, &v1f_straight, 0);
+		vfe->priv1 = &bo->htc;
+		vfe->priv2 = bo->content_length;
 		break;
 	case BS_CHUNKED:
 		assert(bo->content_length == -1);
-		VFP_Push(bo, &v1f_chunked, -1, 0);
+		vfe = VFP_Push(bo, &v1f_chunked, 0);
+		vfe->priv1 = &bo->htc;
+		vfe->priv2 = -1;
 		break;
 	default:
 		WRONG("Wrong body_status");



More information about the varnish-commit mailing list