[master] 06d0296 Make the VFP_ methods take a "void *priv" rather than a busyobj, to pave the way for sharing some code on client and backend side.

Poul-Henning Kamp phk at varnish-cache.org
Wed Jan 23 13:41:10 CET 2013


commit 06d029674c66c60efa50f32fe25c98eae45efcfd
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Wed Jan 23 12:40:32 2013 +0000

    Make the VFP_ methods take a "void *priv" rather than a busyobj,
    to pave the way for sharing some code on client and backend side.

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index d60d657..f77837a 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -268,11 +268,9 @@ struct dstat {
 
 /* Fetch processors --------------------------------------------------*/
 
-void VBO_extend(const struct busyobj *, ssize_t);
-
-typedef void vfp_begin_f(struct busyobj *, size_t );
-typedef int vfp_bytes_f(struct busyobj *, struct http_conn *, ssize_t);
-typedef int vfp_end_f(struct busyobj *);
+typedef void vfp_begin_f(void *priv, size_t );
+typedef int vfp_bytes_f(void *priv, struct http_conn *, ssize_t);
+typedef int vfp_end_f(void *priv);
 
 struct vfp {
 	vfp_begin_f	*begin;
@@ -787,6 +785,7 @@ void VBO_Init(void);
 struct busyobj *VBO_GetBusyObj(struct worker *, struct req *);
 void VBO_DerefBusyObj(struct worker *wrk, struct busyobj **busyobj);
 void VBO_Free(struct busyobj **vbo);
+void VBO_extend(const struct busyobj *, ssize_t);
 
 /* cache_http1_fsm.c [HTTP1] */
 typedef int (req_body_iter_f)(struct req *, void *priv, void *ptr, size_t);
diff --git a/bin/varnishd/cache/cache_esi_fetch.c b/bin/varnishd/cache/cache_esi_fetch.c
index f98e90c..0031a3c 100644
--- a/bin/varnishd/cache/cache_esi_fetch.c
+++ b/bin/varnishd/cache/cache_esi_fetch.c
@@ -296,12 +296,13 @@ vfp_esi_bytes_gg(const struct busyobj *bo, struct vef_priv *vef,
 /*---------------------------------------------------------------------*/
 
 static void __match_proto__(vfp_begin_f)
-vfp_esi_begin(struct busyobj *bo, size_t estimate)
+vfp_esi_begin(void *priv, size_t estimate)
 {
+	struct busyobj *bo;
 	struct vef_priv *vef;
 
+	CAST_OBJ_NOTNULL(bo, priv, BUSYOBJ_MAGIC);
 	(void)estimate;
-	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
 
 	ALLOC_OBJ(vef, VEF_MAGIC);
 	XXXAN(vef);
@@ -340,12 +341,13 @@ vfp_esi_begin(struct busyobj *bo, size_t estimate)
 }
 
 static int __match_proto__(vfp_bytes_f)
-vfp_esi_bytes(struct busyobj *bo, struct http_conn *htc, ssize_t bytes)
+vfp_esi_bytes(void *priv, struct http_conn *htc, ssize_t bytes)
 {
+	struct busyobj *bo;
 	struct vef_priv *vef;
 	int i;
 
-	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
+	CAST_OBJ_NOTNULL(bo, priv, BUSYOBJ_MAGIC);
 	vef = bo->vef_priv;
 	CHECK_OBJ_NOTNULL(vef, VEF_MAGIC);
 
@@ -364,14 +366,15 @@ vfp_esi_bytes(struct busyobj *bo, struct http_conn *htc, ssize_t bytes)
 }
 
 static int __match_proto__(vfp_end_f)
-vfp_esi_end(struct busyobj *bo)
+vfp_esi_end(void *priv)
 {
+	struct busyobj *bo;
 	struct vsb *vsb;
 	struct vef_priv *vef;
 	ssize_t l;
 	int retval = 0;
 
-	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
+	CAST_OBJ_NOTNULL(bo, priv, BUSYOBJ_MAGIC);
 	AN(bo->vep);
 
 	if (bo->state == BOS_FAILED)
diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index 3ed08d0..0d539f7 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -129,8 +129,11 @@ VFP_End(struct busyobj *bo)
  * as seen on the socket, or zero if unknown.
  */
 static void __match_proto__(vfp_begin_f)
-vfp_nop_begin(struct busyobj *bo, size_t estimate)
+vfp_nop_begin(void *priv, size_t estimate)
 {
+	struct busyobj *bo;
+
+	CAST_OBJ_NOTNULL(bo, priv, BUSYOBJ_MAGIC);
 
 	if (estimate > 0)
 		(void)FetchStorage(bo, estimate);
@@ -148,10 +151,13 @@ vfp_nop_begin(struct busyobj *bo, size_t estimate)
  */
 
 static int __match_proto__(vfp_bytes_f)
-vfp_nop_bytes(struct busyobj *bo, struct http_conn *htc, ssize_t bytes)
+vfp_nop_bytes(void *priv, struct http_conn *htc, ssize_t bytes)
 {
 	ssize_t l, wl;
 	struct storage *st;
+	struct busyobj *bo;
+
+	CAST_OBJ_NOTNULL(bo, priv, BUSYOBJ_MAGIC);
 
 	while (bytes > 0) {
 		st = FetchStorage(bo, 0);
@@ -180,10 +186,12 @@ vfp_nop_bytes(struct busyobj *bo, struct http_conn *htc, ssize_t bytes)
  */
 
 static int __match_proto__(vfp_end_f)
-vfp_nop_end(struct busyobj *bo)
+vfp_nop_end(void *priv)
 {
 	struct storage *st;
+	struct busyobj *bo;
 
+	CAST_OBJ_NOTNULL(bo, priv, BUSYOBJ_MAGIC);
 	st = VTAILQ_LAST(&bo->fetch_obj->store, storagehead);
 	if (st == NULL)
 		return (0);
diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c
index 28a8937..9410b26 100644
--- a/bin/varnishd/cache/cache_gzip.c
+++ b/bin/varnishd/cache/cache_gzip.c
@@ -441,25 +441,28 @@ VGZ_Destroy(struct vgz **vgp)
  */
 
 static void __match_proto__(vfp_begin_f)
-vfp_gunzip_begin(struct busyobj *bo, size_t estimate)
+vfp_gunzip_begin(void *priv, size_t estimate)
 {
+	struct busyobj *bo;
+
+	CAST_OBJ_NOTNULL(bo, priv, BUSYOBJ_MAGIC);
 	(void)estimate;
-	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
 	AZ(bo->vgz_rx);
 	bo->vgz_rx = VGZ_NewUngzip(bo->vsl, "U F -");
 	XXXAZ(vgz_getmbuf(bo->vgz_rx));
 }
 
 static int __match_proto__(vfp_bytes_f)
-vfp_gunzip_bytes(struct busyobj *bo, struct http_conn *htc, ssize_t bytes)
+vfp_gunzip_bytes(void *priv, struct http_conn *htc, ssize_t bytes)
 {
 	struct vgz *vg;
+	struct busyobj *bo;
 	ssize_t l, wl;
 	int i = -100;
 	size_t dl;
 	const void *dp;
 
-	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
+	CAST_OBJ_NOTNULL(bo, priv, BUSYOBJ_MAGIC);
 	vg = bo->vgz_rx;
 	CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC);
 	AZ(vg->vz.avail_in);
@@ -487,11 +490,12 @@ vfp_gunzip_bytes(struct busyobj *bo, struct http_conn *htc, ssize_t bytes)
 }
 
 static int __match_proto__(vfp_end_f)
-vfp_gunzip_end(struct busyobj *bo)
+vfp_gunzip_end(void *priv)
 {
 	struct vgz *vg;
+	struct busyobj *bo;
 
-	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
+	CAST_OBJ_NOTNULL(bo, priv, BUSYOBJ_MAGIC);
 	vg = bo->vgz_rx;
 	bo->vgz_rx = NULL;
 	CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC);
@@ -517,26 +521,28 @@ struct vfp vfp_gunzip = {
  */
 
 static void __match_proto__(vfp_begin_f)
-vfp_gzip_begin(struct busyobj *bo, size_t estimate)
+vfp_gzip_begin(void *priv, size_t estimate)
 {
 	(void)estimate;
+	struct busyobj *bo;
 
-	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
+	CAST_OBJ_NOTNULL(bo, priv, BUSYOBJ_MAGIC);
 	AZ(bo->vgz_rx);
 	bo->vgz_rx = VGZ_NewGzip(bo->vsl, "G F -");
 	XXXAZ(vgz_getmbuf(bo->vgz_rx));
 }
 
 static int __match_proto__(vfp_bytes_f)
-vfp_gzip_bytes(struct busyobj *bo, struct http_conn *htc, ssize_t bytes)
+vfp_gzip_bytes(void *priv, struct http_conn *htc, ssize_t bytes)
 {
 	struct vgz *vg;
+	struct busyobj *bo;
 	ssize_t l, wl;
 	int i = -100;
 	size_t dl;
 	const void *dp;
 
-	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
+	CAST_OBJ_NOTNULL(bo, priv, BUSYOBJ_MAGIC);
 	vg = bo->vgz_rx;
 	CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC);
 	AZ(vg->vz.avail_in);
@@ -561,14 +567,15 @@ vfp_gzip_bytes(struct busyobj *bo, struct http_conn *htc, ssize_t bytes)
 }
 
 static int __match_proto__(vfp_end_f)
-vfp_gzip_end(struct busyobj *bo)
+vfp_gzip_end(void *priv)
 {
 	struct vgz *vg;
+	struct busyobj *bo;
 	size_t dl;
 	const void *dp;
 	int i;
 
-	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
+	CAST_OBJ_NOTNULL(bo, priv, BUSYOBJ_MAGIC);
 	vg = bo->vgz_rx;
 	CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC);
 	bo->vgz_rx = NULL;
@@ -603,9 +610,11 @@ struct vfp vfp_gzip = {
  */
 
 static void __match_proto__(vfp_begin_f)
-vfp_testgzip_begin(struct busyobj *bo, size_t estimate)
+vfp_testgzip_begin(void *priv, size_t estimate)
 {
-	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
+	struct busyobj *bo;
+
+	CAST_OBJ_NOTNULL(bo, priv, BUSYOBJ_MAGIC);
 	(void)estimate;
 	bo->vgz_rx = VGZ_NewUngzip(bo->vsl, "u F -");
 	CHECK_OBJ_NOTNULL(bo->vgz_rx, VGZ_MAGIC);
@@ -613,16 +622,17 @@ vfp_testgzip_begin(struct busyobj *bo, size_t estimate)
 }
 
 static int __match_proto__(vfp_bytes_f)
-vfp_testgzip_bytes(struct busyobj *bo, struct http_conn *htc, ssize_t bytes)
+vfp_testgzip_bytes(void *priv, struct http_conn *htc, ssize_t bytes)
 {
 	struct vgz *vg;
+	struct busyobj *bo;
 	ssize_t l, wl;
 	int i = -100;
 	size_t dl;
 	const void *dp;
 	struct storage *st;
 
-	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
+	CAST_OBJ_NOTNULL(bo, priv, BUSYOBJ_MAGIC);
 	vg = bo->vgz_rx;
 	CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC);
 	AZ(vg->vz.avail_in);
@@ -656,11 +666,12 @@ vfp_testgzip_bytes(struct busyobj *bo, struct http_conn *htc, ssize_t bytes)
 }
 
 static int __match_proto__(vfp_end_f)
-vfp_testgzip_end(struct busyobj *bo)
+vfp_testgzip_end(void *priv)
 {
 	struct vgz *vg;
+	struct busyobj *bo;
 
-	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
+	CAST_OBJ_NOTNULL(bo, priv, BUSYOBJ_MAGIC);
 	vg = bo->vgz_rx;
 	bo->vgz_rx = NULL;
 	CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC);



More information about the varnish-commit mailing list