[master] 40d5594 Pass struct vfp_entry * to the vfps.

Poul-Henning Kamp phk at FreeBSD.org
Mon Jul 7 11:50:54 CEST 2014


commit 40d5594de5a55bb649bd1d46d897ec80525b4d1c
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Jul 7 08:16:50 2014 +0000

    Pass struct vfp_entry * to the vfps.

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index d0137fe..996d3dc 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -448,7 +448,7 @@ struct vfp_entry {
 	unsigned		magic;
 #define VFP_ENTRY_MAGIC		0xbe32a027
 	const struct vfp	*vfp;
-	// void			*priv1;
+	void			*priv1;
 	intptr_t		priv2;
 	VTAILQ_ENTRY(vfp_entry)	list;
 };
diff --git a/bin/varnishd/cache/cache_esi_fetch.c b/bin/varnishd/cache/cache_esi_fetch.c
index 9424399..5b5f9ce 100644
--- a/bin/varnishd/cache/cache_esi_fetch.c
+++ b/bin/varnishd/cache/cache_esi_fetch.c
@@ -142,13 +142,15 @@ vfp_esi_end(struct busyobj *bo, struct vef_priv *vef, enum vfp_status retval)
 }
 
 static enum vfp_status __match_proto__(vfp_pull_f)
-vfp_esi_gzip_pull(struct busyobj *bo, void *p, ssize_t *lp, intptr_t *priv)
+vfp_esi_gzip_pull(struct busyobj *bo, void *p, ssize_t *lp,
+    struct vfp_entry *vfe)
 {
 	enum vfp_status vp;
 	ssize_t d, l;
 	struct vef_priv *vef;
 
 	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
+	CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC);
 	if (p == vfp_init) {
 		ALLOC_OBJ(vef, VEF_MAGIC);
 		XXXAN(vef);
@@ -159,20 +161,19 @@ vfp_esi_gzip_pull(struct busyobj *bo, void *p, ssize_t *lp, intptr_t *priv)
 		XXXAN(vef->ibuf);
 		vef->ibuf_i = vef->ibuf;
 		vef->ibuf_o = vef->ibuf;
-		*priv = (uintptr_t)vef;
+		vfe->priv1 = vef;
 		return (VFP_OK);
 	}
 	if (p == vfp_fini) {
-		if (*priv)
-			(void)vfp_esi_end(bo, (void*)*priv, VFP_ERROR);
-		*priv = 0;
+		if (vfe->priv1 != NULL)
+			(void)vfp_esi_end(bo, vfe->priv1, VFP_ERROR);
+		vfe->priv1 = NULL;
 		return (VFP_ERROR);
 	}
 	AN(p);
 	AN(lp);
 	*lp = 0;
-	AN(priv);
-	CAST_OBJ_NOTNULL(vef, (void*)*priv, VEF_MAGIC);
+	CAST_OBJ_NOTNULL(vef, vfe->priv1, VEF_MAGIC);
 	l = vef->ibuf_sz - (vef->ibuf_i - vef->ibuf);
 	if (DO_DEBUG(DBG_ESI_CHOP)) {
 		d = (random() & 3) + 1;
@@ -197,36 +198,36 @@ vfp_esi_gzip_pull(struct busyobj *bo, void *p, ssize_t *lp, intptr_t *priv)
 	}
 	if (vp == VFP_END) {
 		vp = vfp_esi_end(bo, vef, vp);
-		*priv = 0;
+		vfe->priv1 = NULL;
 	}
 	return (vp);
 }
 
 static enum vfp_status __match_proto__(vfp_pull_f)
-vfp_esi_pull(struct busyobj *bo, void *p, ssize_t *lp, intptr_t *priv)
+vfp_esi_pull(struct busyobj *bo, void *p, ssize_t *lp, struct vfp_entry *vfe)
 {
 	enum vfp_status vp;
 	ssize_t d;
 	struct vef_priv *vef;
 
 	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
+	CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC);
 	if (p == vfp_init) {
 		ALLOC_OBJ(vef, VEF_MAGIC);
 		XXXAN(vef);
 		vef->vep = VEP_Init(bo, NULL, NULL);
-		*priv = (uintptr_t)vef;
+		vfe->priv1 = vef;
 		return (VFP_OK);
 	}
 	if (p == vfp_fini) {
-		if (*priv)
-			(void)vfp_esi_end(bo, (void*)*priv, VFP_ERROR);
-		*priv = 0;
+		if (vfe->priv1 != NULL)
+			(void)vfp_esi_end(bo, vfe->priv1, VFP_ERROR);
+		vfe->priv1 = NULL;
 		return (VFP_ERROR);
 	}
 	AN(p);
 	AN(lp);
-	AN(priv);
-	CAST_OBJ_NOTNULL(vef, (void*)*priv, VEF_MAGIC);
+	CAST_OBJ_NOTNULL(vef, vfe->priv1, VEF_MAGIC);
 	if (DO_DEBUG(DBG_ESI_CHOP)) {
 		d = (random() & 3) + 1;
 		if (d < *lp)
@@ -237,7 +238,7 @@ vfp_esi_pull(struct busyobj *bo, void *p, ssize_t *lp, intptr_t *priv)
 		VEP_Parse(vef->vep, bo, p, *lp);
 	if (vp == VFP_END) {
 		vp = vfp_esi_end(bo, vef, vp);
-		*priv = 0;
+		vfe->priv1 = NULL;
 	}
 	return (vp);
 }
diff --git a/bin/varnishd/cache/cache_fetch_proc.c b/bin/varnishd/cache/cache_fetch_proc.c
index 20e5d09..eae386d 100644
--- a/bin/varnishd/cache/cache_fetch_proc.c
+++ b/bin/varnishd/cache/cache_fetch_proc.c
@@ -115,7 +115,7 @@ static enum vfp_status
 vfp_call(struct busyobj *bo, struct vfp_entry *vfe, void *p, ssize_t *lp)
 {
 	AN(vfe->vfp->pull);
-	return (vfe->vfp->pull(bo, p, lp, &vfe->priv2));
+	return (vfe->vfp->pull(bo, p, lp, vfe));
 }
 
 static void
diff --git a/bin/varnishd/cache/cache_filter.h b/bin/varnishd/cache/cache_filter.h
index d2b0cf1..0d0c670 100644
--- a/bin/varnishd/cache/cache_filter.h
+++ b/bin/varnishd/cache/cache_filter.h
@@ -29,6 +29,7 @@
 
 struct busyobj;
 struct req;
+struct vfp_entry;
 
 /* Fetch processors --------------------------------------------------*/
 
@@ -38,7 +39,7 @@ enum vfp_status {
 	VFP_END = 1,
 };
 typedef enum vfp_status
-    vfp_pull_f(struct busyobj *bo, void *p, ssize_t *len, intptr_t *priv);
+    vfp_pull_f(struct busyobj *, void *ptr, ssize_t *len, struct vfp_entry *);
 
 struct vfp {
 	vfp_pull_f	*pull;
diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c
index 2e3528b..bbae538 100644
--- a/bin/varnishd/cache/cache_gzip.c
+++ b/bin/varnishd/cache/cache_gzip.c
@@ -451,7 +451,7 @@ VGZ_Destroy(struct vgz **vgp)
  */
 
 static enum vfp_status __match_proto__(vfp_pull_f)
-vfp_gunzip_pull(struct busyobj *bo, void *p, ssize_t *lp, intptr_t *priv)
+vfp_gunzip_pull(struct busyobj *bo, void *p, ssize_t *lp, struct vfp_entry *vfe)
 {
         ssize_t l;
 	struct vgz *vg;
@@ -461,27 +461,27 @@ vfp_gunzip_pull(struct busyobj *bo, void *p, ssize_t *lp, intptr_t *priv)
 	enum vfp_status vp = VFP_OK;
 
         CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
+	CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC);
 	if (p == vfp_init) {
 		vg = VGZ_NewUngzip(bo->vsl, "U F -");
 		XXXAZ(vgz_getmbuf(vg));
-		*priv = (uintptr_t)vg;
+		vfe->priv1 = vg;
 		VGZ_Ibuf(vg, vg->m_buf, 0);
 		AZ(vg->m_len);
 		return (VFP_OK);
 	}
 	if (p == vfp_fini) {
-		if (*priv != 0) {
-			CAST_OBJ_NOTNULL(vg, (void*)(*priv), VGZ_MAGIC);
-			*priv = 0;
+		if (vfe->priv1 != NULL) {
+			CAST_OBJ_NOTNULL(vg, vfe->priv1, VGZ_MAGIC);
+			vfe->priv1 = NULL;
 			(void)VGZ_Destroy(&vg);
 		}
-		*priv = 0;
+		vfe->priv1 = NULL;
 		return (VFP_ERROR);
 	}
         AN(p);
         AN(lp);
-        AN(priv);
-	CAST_OBJ_NOTNULL(vg, (void*)(*priv), VGZ_MAGIC);
+	CAST_OBJ_NOTNULL(vg, vfe->priv1, VGZ_MAGIC);
 	l = *lp;
 	*lp = 0;
 	VGZ_Obuf(vg, p, l);
@@ -525,7 +525,7 @@ const struct vfp vfp_gunzip = {
  */
 
 static enum vfp_status __match_proto__(vfp_pull_f)
-vfp_gzip_pull(struct busyobj *bo, void *p, ssize_t *lp, intptr_t *priv)
+vfp_gzip_pull(struct busyobj *bo, void *p, ssize_t *lp, struct vfp_entry *vfe)
 {
         ssize_t l;
 	struct vgz *vg;
@@ -535,27 +535,27 @@ vfp_gzip_pull(struct busyobj *bo, void *p, ssize_t *lp, intptr_t *priv)
 	enum vfp_status vp = VFP_ERROR;
 
         CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
+	CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC);
 	if (p == vfp_init) {
 		vg = VGZ_NewGzip(bo->vsl, "G F -");
 		XXXAZ(vgz_getmbuf(vg));
-		*priv = (uintptr_t)vg;
+		vfe->priv1 = vg;
 		VGZ_Ibuf(vg, vg->m_buf, 0);
 		AZ(vg->m_len);
 		vg->flag = VGZ_NORMAL;
 		return (VFP_OK);
 	}
 	if (p == vfp_fini) {
-		if (*priv != 0) {
-			CAST_OBJ_NOTNULL(vg, (void*)(*priv), VGZ_MAGIC);
-			*priv = 0;
+		if (vfe->priv1 != NULL) {
+			CAST_OBJ_NOTNULL(vg, vfe->priv1, VGZ_MAGIC);
+			vfe->priv1 = NULL;
 			(void)VGZ_Destroy(&vg);
 		}
 		return (VFP_ERROR);
 	}
         AN(p);
         AN(lp);
-        AN(priv);
-	CAST_OBJ_NOTNULL(vg, (void*)(*priv), VGZ_MAGIC);
+	CAST_OBJ_NOTNULL(vg, vfe->priv1, VGZ_MAGIC);
 	l = *lp;
 	*lp = 0;
 	VGZ_Obuf(vg, p, l);
@@ -600,7 +600,8 @@ const struct vfp vfp_gzip = {
  */
 
 static enum vfp_status __match_proto__(vfp_pull_f)
-vfp_testgunzip_pull(struct busyobj *bo, void *p, ssize_t *lp, intptr_t *priv)
+vfp_testgunzip_pull(struct busyobj *bo, void *p, ssize_t *lp,
+    struct vfp_entry *vfe)
 {
 	struct vgz *vg;
 	enum vgzret_e vr = VGZ_ERROR;
@@ -609,25 +610,25 @@ vfp_testgunzip_pull(struct busyobj *bo, void *p, ssize_t *lp, intptr_t *priv)
 	enum vfp_status vp;
 
         CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
+	CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC);
 	if (p == vfp_init) {
 		vg = VGZ_NewUngzip(bo->vsl, "u F -");
 		XXXAZ(vgz_getmbuf(vg));
-		*priv = (uintptr_t)vg;
+		vfe->priv1 = vg;
 		AZ(vg->m_len);
 		return (VFP_OK);
 	}
 	if (p == vfp_fini) {
-		if (*priv != 0) {
-			CAST_OBJ_NOTNULL(vg, (void*)(*priv), VGZ_MAGIC);
-			*priv = 0;
+		if (vfe->priv1 != NULL) {
+			CAST_OBJ_NOTNULL(vg, vfe->priv1, VGZ_MAGIC);
+			vfe->priv1 = NULL;
 			(void)VGZ_Destroy(&vg);
 		}
 		return (VFP_ERROR);
 	}
         AN(p);
         AN(lp);
-        AN(priv);
-	CAST_OBJ_NOTNULL(vg, (void*)(*priv), VGZ_MAGIC);
+	CAST_OBJ_NOTNULL(vg, vfe->priv1, VGZ_MAGIC);
 	vp = VFP_Suck(bo, p, lp);
 	if (vp == VFP_ERROR)
 		return (vp);
diff --git a/bin/varnishd/cache/cache_http1_fetch.c b/bin/varnishd/cache/cache_http1_fetch.c
index 65c2591..9fa7258 100644
--- a/bin/varnishd/cache/cache_http1_fetch.c
+++ b/bin/varnishd/cache/cache_http1_fetch.c
@@ -69,33 +69,35 @@ vbf_fetch_number(const char *nbr, int radix)
 /*--------------------------------------------------------------------*/
 
 static enum vfp_status __match_proto__(vfp_pull_f)
-v1f_pull_straight(struct busyobj *bo, void *p, ssize_t *lp, intptr_t *priv)
+v1f_pull_straight(struct busyobj *bo, void *p, ssize_t *lp,
+    struct vfp_entry *vfe)
 {
 	ssize_t l, lr;
 
 	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
+	CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC);
+
 	if (p == vfp_init)
 		return (VFP_OK);
 	if (p == vfp_fini)
 		return (VFP_ERROR);
 	AN(p);
 	AN(lp);
-	AN(priv);
 
 	l = *lp;
 	*lp = 0;
 
-	if (!*priv)		// XXX: Optimize Content-Len: 0 out earlier
+	if (vfe->priv2 == 0) // XXX: Optimize Content-Len: 0 out earlier
 		return (VFP_END);
-	if (*priv < l)
-		l = *priv;
+	if (vfe->priv2 < l)
+		l = vfe->priv2;
 	lr = HTTP1_Read(&bo->htc, p, l);
 	bo->acct.beresp_bodybytes += lr;
 	if (lr <= 0)
 		return (VFP_Error(bo, "straight insufficient bytes"));
 	*lp = lr;
-	*priv -= lr;
-	if (*priv == 0)
+	vfe->priv2 -= lr;
+	if (vfe->priv2 == 0)
 		return (VFP_END);
 	return (VFP_OK);
 }
@@ -111,20 +113,22 @@ static const struct vfp v1f_straight = {
  */
 
 static enum vfp_status __match_proto__(vfp_pull_f)
-v1f_pull_chunked(struct busyobj *bo, void *p, ssize_t *lp, intptr_t *priv)
+v1f_pull_chunked(struct busyobj *bo, void *p, ssize_t *lp,
+    struct vfp_entry *vfe)
 {
 	const char *err;
 
 	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
+	CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC);
+
 	if (p == vfp_init)
 		return (VFP_OK);
 	if (p == vfp_fini)
 		return (VFP_ERROR);
 	AN(p);
 	AN(lp);
-	AN(priv);
 
-	switch (HTTP1_Chunked(&bo->htc, priv, &err,
+	switch (HTTP1_Chunked(&bo->htc, &vfe->priv2, &err,
 	    &bo->acct.beresp_bodybytes, p, lp)) {
 	case H1CR_ERROR:
 		return (VFP_Error(bo, "%s", err));
@@ -144,18 +148,18 @@ static const struct vfp v1f_chunked = {
 /*--------------------------------------------------------------------*/
 
 static enum vfp_status __match_proto__(vfp_pull_f)
-v1f_pull_eof(struct busyobj *bo, void *p, ssize_t *lp, intptr_t *priv)
+v1f_pull_eof(struct busyobj *bo, void *p, ssize_t *lp, struct vfp_entry *vfe)
 {
 	ssize_t l, lr;
 
 	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
+	CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC);
 	if (p == vfp_init)
 		return (VFP_OK);
 	if (p == vfp_fini)
 		return (VFP_ERROR);
 	AN(p);
 	AN(lp);
-	AN(priv);
 
 	l = *lp;
 	*lp = 0;



More information about the varnish-commit mailing list