[master] a86fd4f Eliminate VDP_FINISH, it's unmanageable and we have VDP_FINI

Poul-Henning Kamp phk at FreeBSD.org
Thu Oct 23 21:46:32 CEST 2014


commit a86fd4f671cf4ff00766d0e344c423be004f7abd
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Thu Oct 23 19:46:05 2014 +0000

    Eliminate VDP_FINISH, it's unmanageable and we have VDP_FINI

diff --git a/bin/varnishd/cache/cache_deliver_proc.c b/bin/varnishd/cache/cache_deliver_proc.c
index 5b6e94d..86c9889 100644
--- a/bin/varnishd/cache/cache_deliver_proc.c
+++ b/bin/varnishd/cache/cache_deliver_proc.c
@@ -39,6 +39,7 @@ VDP_bytes(struct req *req, enum vdp_action act, const void *ptr, ssize_t len)
 	struct vdp_entry *vdp;
 
 	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
+	assert(act == VDP_NULL || act == VDP_FLUSH);
 	vdp = req->vdp_nxt;
 	CHECK_OBJ_NOTNULL(vdp, VDP_ENTRY_MAGIC);
 	req->vdp_nxt = VTAILQ_NEXT(vdp, list);
diff --git a/bin/varnishd/cache/cache_filter.h b/bin/varnishd/cache/cache_filter.h
index 2912ece..fce1c09 100644
--- a/bin/varnishd/cache/cache_filter.h
+++ b/bin/varnishd/cache/cache_filter.h
@@ -88,11 +88,10 @@ enum vfp_status VFP_GetStorage(struct vfp_ctx *, ssize_t *sz, uint8_t **ptr);
 /* Deliver processors ------------------------------------------------*/
 
 enum vdp_action {
-	VDP_INIT,
-	VDP_FINI,
-	VDP_NULL,
-	VDP_FLUSH,
-	VDP_FINISH,
+	VDP_INIT,		/* Happens on VDP_push() */
+	VDP_FINI,		/* Happens on VDP_pop() */
+	VDP_NULL,		/* Input buffer valid after call */
+	VDP_FLUSH,		/* Input buffer will be invalidated */
 };
 
 typedef int vdp_bytes(struct req *, enum vdp_action, void **priv,
diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c
index 93b16dd..c32f760 100644
--- a/bin/varnishd/cache/cache_gzip.c
+++ b/bin/varnishd/cache/cache_gzip.c
@@ -277,11 +277,11 @@ VDP_gunzip(struct req *req, enum vdp_action act, void **priv,
 	const void *dp;
 	struct worker *wrk;
 	struct vgz *vg;
-	int retval;
 
 	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
 	wrk = req->wrk;
 	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
+
 	if (act == VDP_INIT) {
 		vg = VGZ_NewUngzip(req->vsl, "U D -");
 		AN(vg);
@@ -291,33 +291,28 @@ VDP_gunzip(struct req *req, enum vdp_action act, void **priv,
 		*priv = vg;
 		return (0);
 	}
+
 	CAST_OBJ_NOTNULL(vg, *priv, VGZ_MAGIC);
+	AN(vg->m_buf);
+
 	if (act == VDP_FINI) {
+		AZ(len);
+		AZ(vg->m_len);
 		(void)VGZ_Destroy(&vg);
 		*priv = NULL;
 		return (0);
 	}
-	AN(vg->m_buf);
 
-	if (len == 0) {
-		AN(act > VDP_NULL);
-		retval = VDP_bytes(req, act, vg->m_buf, vg->m_len);
-		vg->m_len = 0;
-		VGZ_Obuf(vg, vg->m_buf, vg->m_sz);
-		return (retval);
-	}
+	if (len == 0)
+		return (0);
 
 	VGZ_Ibuf(vg, ptr, len);
 	do {
-		if (vg->m_len == vg->m_sz)
-			vr = VGZ_STUCK;
-		else {
-			vr = VGZ_Gunzip(vg, &dp, &dl);
-			vg->m_len += dl;
-		}
+		vr = VGZ_Gunzip(vg, &dp, &dl);
+		vg->m_len += dl;
 		if (vr < VGZ_OK)
 			return (-1);
-		if (vg->m_len == vg->m_sz || vr == VGZ_STUCK) {
+		if (vg->m_len == vg->m_sz || vr != VGZ_OK) {
 			if (VDP_bytes(req, VDP_FLUSH, vg->m_buf, vg->m_len))
 				return (-1);
 			vg->m_len = 0;
diff --git a/bin/varnishd/http1/cache_http1_deliver.c b/bin/varnishd/http1/cache_http1_deliver.c
index d9eae86..7d873ed 100644
--- a/bin/varnishd/http1/cache_http1_deliver.c
+++ b/bin/varnishd/http1/cache_http1_deliver.c
@@ -222,7 +222,6 @@ v1d_WriteDirObj(struct req *req)
 			WRONG("Wrong OIS value");
 		}
 	} while (ois == OIS_DATA || ois == OIS_STREAM);
-	(void)VDP_bytes(req, VDP_FINISH,  NULL, 0);
 	ObjIterEnd(req->objcore, &oi);
 	return (ois);
 }



More information about the varnish-commit mailing list