[master] 3450da1 fiddle the VFP's a little bit.

Poul-Henning Kamp phk at varnish-cache.org
Thu Aug 22 11:35:53 CEST 2013


commit 3450da1fc4d11da6fb61e85921be6866e409444f
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Thu Aug 22 08:07:15 2013 +0000

    fiddle the VFP's a little bit.

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 879b637..fffe812 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -259,9 +259,9 @@ struct dstat {
 
 /* Fetch processors --------------------------------------------------*/
 
-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);
+typedef void vfp_begin_f(struct busyobj *bo, size_t );
+typedef int vfp_bytes_f(struct busyobj *bo, struct http_conn *, ssize_t);
+typedef int vfp_end_f(struct busyobj *bo);
 
 struct vfp {
 	vfp_begin_f	*begin;
diff --git a/bin/varnishd/cache/cache_esi_fetch.c b/bin/varnishd/cache/cache_esi_fetch.c
index 7da3608..e64d796 100644
--- a/bin/varnishd/cache/cache_esi_fetch.c
+++ b/bin/varnishd/cache/cache_esi_fetch.c
@@ -295,12 +295,11 @@ vfp_esi_bytes_gg(const struct busyobj *bo, struct vef_priv *vef,
 /*---------------------------------------------------------------------*/
 
 static void __match_proto__(vfp_begin_f)
-vfp_esi_begin(void *priv, size_t estimate)
+vfp_esi_begin(struct busyobj *bo, size_t estimate)
 {
-	struct busyobj *bo;
 	struct vef_priv *vef;
 
-	CAST_OBJ_NOTNULL(bo, priv, BUSYOBJ_MAGIC);
+	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
 	(void)estimate;
 
 	ALLOC_OBJ(vef, VEF_MAGIC);
@@ -340,13 +339,12 @@ vfp_esi_begin(void *priv, size_t estimate)
 }
 
 static int __match_proto__(vfp_bytes_f)
-vfp_esi_bytes(void *priv, struct http_conn *htc, ssize_t bytes)
+vfp_esi_bytes(struct busyobj *bo, struct http_conn *htc, ssize_t bytes)
 {
-	struct busyobj *bo;
 	struct vef_priv *vef;
 	int i;
 
-	CAST_OBJ_NOTNULL(bo, priv, BUSYOBJ_MAGIC);
+	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
 	vef = bo->vef_priv;
 	CHECK_OBJ_NOTNULL(vef, VEF_MAGIC);
 
@@ -365,15 +363,14 @@ vfp_esi_bytes(void *priv, struct http_conn *htc, ssize_t bytes)
 }
 
 static int __match_proto__(vfp_end_f)
-vfp_esi_end(void *priv)
+vfp_esi_end(struct busyobj *bo)
 {
-	struct busyobj *bo;
 	struct vsb *vsb;
 	struct vef_priv *vef;
 	ssize_t l;
 	int retval = 0;
 
-	CAST_OBJ_NOTNULL(bo, priv, BUSYOBJ_MAGIC);
+	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
 	AN(bo->vep);
 
 	if (bo->state == BOS_FAILED)
diff --git a/bin/varnishd/cache/cache_fetch_proc.c b/bin/varnishd/cache/cache_fetch_proc.c
index fdc896c..cacfcc0 100644
--- a/bin/varnishd/cache/cache_fetch_proc.c
+++ b/bin/varnishd/cache/cache_fetch_proc.c
@@ -89,11 +89,10 @@ VFP_Error(struct busyobj *bo, const char *error)
  * as seen on the socket, or zero if unknown.
  */
 static void __match_proto__(vfp_begin_f)
-vfp_nop_begin(void *priv, size_t estimate)
+vfp_nop_begin(struct busyobj *bo, size_t estimate)
 {
-	struct busyobj *bo;
 
-	CAST_OBJ_NOTNULL(bo, priv, BUSYOBJ_MAGIC);
+	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
 
 	if (estimate > 0)
 		(void)VFP_GetStorage(bo, estimate);
@@ -111,13 +110,12 @@ vfp_nop_begin(void *priv, size_t estimate)
  */
 
 static int __match_proto__(vfp_bytes_f)
-vfp_nop_bytes(void *priv, struct http_conn *htc, ssize_t bytes)
+vfp_nop_bytes(struct busyobj *bo, struct http_conn *htc, ssize_t bytes)
 {
 	ssize_t l, wl;
 	struct storage *st;
-	struct busyobj *bo;
 
-	CAST_OBJ_NOTNULL(bo, priv, BUSYOBJ_MAGIC);
+	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
 
 	while (bytes > 0) {
 		st = VFP_GetStorage(bo, 0);
@@ -146,23 +144,10 @@ vfp_nop_bytes(void *priv, struct http_conn *htc, ssize_t bytes)
  */
 
 static int __match_proto__(vfp_end_f)
-vfp_nop_end(void *priv)
+vfp_nop_end(struct busyobj *bo)
 {
-	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);
-
-	if (st->len == 0) {
-		VTAILQ_REMOVE(&bo->fetch_obj->store, st, list);
-		STV_free(st);
-		return (0);
-	}
-	if (st->len < st->space)
-		STV_trim(st, st->len, 1);
+	(void)bo;
 	return (0);
 }
 
diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c
index f0374a7..be633d3 100644
--- a/bin/varnishd/cache/cache_gzip.c
+++ b/bin/varnishd/cache/cache_gzip.c
@@ -441,11 +441,10 @@ VGZ_Destroy(struct vgz **vgp)
  */
 
 static void __match_proto__(vfp_begin_f)
-vfp_gunzip_begin(void *priv, size_t estimate)
+vfp_gunzip_begin(struct busyobj *bo, size_t estimate)
 {
-	struct busyobj *bo;
 
-	CAST_OBJ_NOTNULL(bo, priv, BUSYOBJ_MAGIC);
+	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
 	(void)estimate;
 	AZ(bo->vgz_rx);
 	bo->vgz_rx = VGZ_NewUngzip(bo->vsl, "U F -");
@@ -453,16 +452,15 @@ vfp_gunzip_begin(void *priv, size_t estimate)
 }
 
 static int __match_proto__(vfp_bytes_f)
-vfp_gunzip_bytes(void *priv, struct http_conn *htc, ssize_t bytes)
+vfp_gunzip_bytes(struct busyobj *bo, 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;
 
-	CAST_OBJ_NOTNULL(bo, priv, BUSYOBJ_MAGIC);
+	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
 	vg = bo->vgz_rx;
 	CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC);
 	AZ(vg->vz.avail_in);
@@ -490,12 +488,11 @@ vfp_gunzip_bytes(void *priv, struct http_conn *htc, ssize_t bytes)
 }
 
 static int __match_proto__(vfp_end_f)
-vfp_gunzip_end(void *priv)
+vfp_gunzip_end(struct busyobj *bo)
 {
 	struct vgz *vg;
-	struct busyobj *bo;
 
-	CAST_OBJ_NOTNULL(bo, priv, BUSYOBJ_MAGIC);
+	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
 	vg = bo->vgz_rx;
 	bo->vgz_rx = NULL;
 	CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC);
@@ -521,28 +518,26 @@ struct vfp vfp_gunzip = {
  */
 
 static void __match_proto__(vfp_begin_f)
-vfp_gzip_begin(void *priv, size_t estimate)
+vfp_gzip_begin(struct busyobj *bo, size_t estimate)
 {
 	(void)estimate;
-	struct busyobj *bo;
 
-	CAST_OBJ_NOTNULL(bo, priv, BUSYOBJ_MAGIC);
+	CHECK_OBJ_NOTNULL(bo, 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(void *priv, struct http_conn *htc, ssize_t bytes)
+vfp_gzip_bytes(struct busyobj *bo, 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;
 
-	CAST_OBJ_NOTNULL(bo, priv, BUSYOBJ_MAGIC);
+	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
 	vg = bo->vgz_rx;
 	CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC);
 	AZ(vg->vz.avail_in);
@@ -567,15 +562,14 @@ vfp_gzip_bytes(void *priv, struct http_conn *htc, ssize_t bytes)
 }
 
 static int __match_proto__(vfp_end_f)
-vfp_gzip_end(void *priv)
+vfp_gzip_end(struct busyobj *bo)
 {
 	struct vgz *vg;
-	struct busyobj *bo;
 	size_t dl;
 	const void *dp;
 	int i;
 
-	CAST_OBJ_NOTNULL(bo, priv, BUSYOBJ_MAGIC);
+	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
 	vg = bo->vgz_rx;
 	CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC);
 	bo->vgz_rx = NULL;
@@ -610,11 +604,10 @@ struct vfp vfp_gzip = {
  */
 
 static void __match_proto__(vfp_begin_f)
-vfp_testgzip_begin(void *priv, size_t estimate)
+vfp_testgzip_begin(struct busyobj *bo, size_t estimate)
 {
-	struct busyobj *bo;
 
-	CAST_OBJ_NOTNULL(bo, priv, BUSYOBJ_MAGIC);
+	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
 	(void)estimate;
 	bo->vgz_rx = VGZ_NewUngzip(bo->vsl, "u F -");
 	CHECK_OBJ_NOTNULL(bo->vgz_rx, VGZ_MAGIC);
@@ -622,17 +615,16 @@ vfp_testgzip_begin(void *priv, size_t estimate)
 }
 
 static int __match_proto__(vfp_bytes_f)
-vfp_testgzip_bytes(void *priv, struct http_conn *htc, ssize_t bytes)
+vfp_testgzip_bytes(struct busyobj *bo, 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;
 
-	CAST_OBJ_NOTNULL(bo, priv, BUSYOBJ_MAGIC);
+	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
 	vg = bo->vgz_rx;
 	CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC);
 	AZ(vg->vz.avail_in);
@@ -666,12 +658,11 @@ vfp_testgzip_bytes(void *priv, struct http_conn *htc, ssize_t bytes)
 }
 
 static int __match_proto__(vfp_end_f)
-vfp_testgzip_end(void *priv)
+vfp_testgzip_end(struct busyobj *bo)
 {
 	struct vgz *vg;
-	struct busyobj *bo;
 
-	CAST_OBJ_NOTNULL(bo, priv, BUSYOBJ_MAGIC);
+	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
 	vg = bo->vgz_rx;
 	bo->vgz_rx = NULL;
 	CHECK_OBJ_NOTNULL(vg, VGZ_MAGIC);
diff --git a/bin/varnishd/cache/cache_http1_fetch.c b/bin/varnishd/cache/cache_http1_fetch.c
index 65d2e93..cd917a1 100644
--- a/bin/varnishd/cache/cache_http1_fetch.c
+++ b/bin/varnishd/cache/cache_http1_fetch.c
@@ -384,13 +384,18 @@ V1F_fetch_body(struct worker *wrk, struct busyobj *bo)
 	}
 	AZ(bo->vgz_rx);
 
-#if 0
 	/*
-	 * We always call vfp_nop_end() to ditch or trim the last storage
-	 * segment, to avoid having to replicate that code in all vfp's.
+	 * Trim or delete the last segment, if any
 	 */
-	AZ(vfp_nop_end(bo));
-#endif
+
+	st = VTAILQ_LAST(&bo->fetch_obj->store, storagehead);
+	if (st != NULL) {
+		if (st->len == 0) {
+			VTAILQ_REMOVE(&bo->fetch_obj->store, st, list);
+			STV_free(st);
+		} else if (st->len < st->space)
+			STV_trim(st, st->len, 1);
+	}
 
 	bo->vfp = NULL;
 



More information about the varnish-commit mailing list