[master] 62bdefe Introduce VFP_NULL as a possible return from vfp->init() to mean "ignore me".

Poul-Henning Kamp phk at FreeBSD.org
Wed Jul 9 14:26:24 CEST 2014


commit 62bdefe0887ad1d32c26904a4fa2980f55599801
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Wed Jul 9 12:25:27 2014 +0000

    Introduce VFP_NULL as a possible return from vfp->init() to mean "ignore me".

diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index afab80c..7824e26 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -443,17 +443,6 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo)
 
 	AN(bo->vbc);
 
-	if (bo->content_length == 0) {
-		/*
-		 * If the length is known to be zero, it's not gziped.
-		 * A similar issue exists for chunked encoding but we
-		 * don't handle that.  See #1320.
-		 */
-		http_Unset(bo->beresp, H_Content_Encoding);
-		bo->is_gzip = 0;
-		bo->is_gunzip = 1;
-	}
-
 	/* But we can't do both at the same time */
 	assert(bo->do_gzip == 0 || bo->do_gunzip == 0);
 
diff --git a/bin/varnishd/cache/cache_fetch_proc.c b/bin/varnishd/cache/cache_fetch_proc.c
index 7b95617..72f2a81 100644
--- a/bin/varnishd/cache/cache_fetch_proc.c
+++ b/bin/varnishd/cache/cache_fetch_proc.c
@@ -113,32 +113,29 @@ vfp_suck_fini(struct busyobj *bo)
 {
 	struct vfp_entry *vfe;
 
-	VTAILQ_FOREACH(vfe, &bo->vfp, list) {
+	VTAILQ_FOREACH(vfe, &bo->vfp, list)
 		if(vfe->closed == VFP_OK && vfe->vfp->fini != NULL)
 			vfe->vfp->fini(bo, vfe);
-	}
 }
 
 static enum vfp_status
 vfp_suck_init(struct busyobj *bo)
 {
-	enum vfp_status retval = VFP_OK;
 	struct vfp_entry *vfe;
 
 	VTAILQ_FOREACH(vfe, &bo->vfp, list) {
 		if (vfe->vfp->init == NULL)
 			continue;
-		retval = vfe->vfp->init(bo, vfe);
-		if (retval != VFP_OK) {
+		vfe->closed = vfe->vfp->init(bo, vfe);
+		if (vfe->closed != VFP_OK && vfe->closed != VFP_NULL) {
 			(void)VFP_Error(bo,
 			    "Fetch filter %s failed to initialize",
 			    vfe->vfp->name);
 			vfp_suck_fini(bo);
-			vfe->closed = retval;
-			return (retval);
+			return (vfe->closed);
 		}
 	}
-	return (retval);
+	return (VFP_OK);
 }
 
 /**********************************************************************
@@ -160,16 +157,17 @@ VFP_Suck(struct busyobj *bo, void *p, ssize_t *lp)
 	CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC);
 	bo->vfp_nxt = VTAILQ_NEXT(vfe, list);
 
-	if (vfe->closed == VFP_OK) {
+	if (vfe->closed == VFP_NULL) {
+		vp = VFP_Suck(bo, p, lp);
+	} else if (vfe->closed == VFP_OK) {
 		vp = vfe->vfp->pull(bo, vfe, p, lp);
-		if (vp == VFP_ERROR)
-			(void)VFP_Error(bo, "Fetch filter %s returned %d",
-			    vfe->vfp->name, vp);
-		if (vp != VFP_OK) {
+		if (vp == VFP_END || vp == VFP_ERROR) {
 			if (vfe->vfp->fini != NULL)
 				vfe->vfp->fini(bo, vfe);
 			vfe->closed = vp;
-		}
+		} else if (vp != VFP_OK)
+			(void)VFP_Error(bo, "Fetch filter %s returned %d",
+			    vfe->vfp->name, vp);
 	} else {
 		/* Already closed filter */
 		*lp = 0;
diff --git a/bin/varnishd/cache/cache_filter.h b/bin/varnishd/cache/cache_filter.h
index 933d2e7..8fae76a 100644
--- a/bin/varnishd/cache/cache_filter.h
+++ b/bin/varnishd/cache/cache_filter.h
@@ -37,6 +37,7 @@ enum vfp_status {
 	VFP_ERROR = -1,
 	VFP_OK = 0,
 	VFP_END = 1,
+	VFP_NULL = 2,
 };
 
 typedef enum vfp_status vfp_init_f(struct busyobj *, struct vfp_entry *);
diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c
index 526e91d..d020bc0 100644
--- a/bin/varnishd/cache/cache_gzip.c
+++ b/bin/varnishd/cache/cache_gzip.c
@@ -458,6 +458,9 @@ vfp_gzip_init(struct busyobj *bo, struct vfp_entry *vfe)
         CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
 	CHECK_OBJ_NOTNULL(vfe, VFP_ENTRY_MAGIC);
 
+	if (bo->content_length == 0)
+		return (VFP_NULL);
+
 	if (vfe->vfp->priv2 == VFP_GZIP)
 		vg = VGZ_NewGzip(bo->vsl, vfe->vfp->priv1);
 	else



More information about the varnish-commit mailing list