[master] 94d1d0f Polish VDP stack mgt API

Poul-Henning Kamp phk at FreeBSD.org
Mon Oct 27 14:17:02 CET 2014


commit 94d1d0fd601711d74f3d47dd5f89ed9adc0d732f
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Oct 27 13:16:46 2014 +0000

    Polish VDP stack mgt API

diff --git a/bin/varnishd/cache/cache_deliver_proc.c b/bin/varnishd/cache/cache_deliver_proc.c
index 65f90c9..fda860c 100644
--- a/bin/varnishd/cache/cache_deliver_proc.c
+++ b/bin/varnishd/cache/cache_deliver_proc.c
@@ -52,7 +52,7 @@ VDP_bytes(struct req *req, enum vdp_action act, const void *ptr, ssize_t len)
 }
 
 void
-VDP_push(struct req *req, vdp_bytes *func, void *priv)
+VDP_push(struct req *req, vdp_bytes *func, void *priv, int bottom)
 {
 	struct vdp_entry *vdp;
 
@@ -64,8 +64,11 @@ VDP_push(struct req *req, vdp_bytes *func, void *priv)
 	INIT_OBJ(vdp, VDP_ENTRY_MAGIC);
 	vdp->func = func;
 	vdp->priv = priv;
-	VTAILQ_INSERT_HEAD(&req->vdp, vdp, list);
-	req->vdp_nxt = vdp;
+	if (bottom)
+		VTAILQ_INSERT_TAIL(&req->vdp, vdp, list);
+	else
+		VTAILQ_INSERT_HEAD(&req->vdp, vdp, list);
+	req->vdp_nxt = VTAILQ_FIRST(&req->vdp);
 
 	AZ(vdp->func(req, VDP_INIT, &vdp->priv, NULL, 0));
 }
diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c
index 504902c..0cb4713 100644
--- a/bin/varnishd/cache/cache_esi_deliver.c
+++ b/bin/varnishd/cache/cache_esi_deliver.c
@@ -127,10 +127,7 @@ ved_include(struct req *preq, const char *src, const char *host)
 	req->crc = preq->crc;
 	req->l_crc = preq->l_crc;
 
-
-	req->vdp_nxt = 0;
-	VTAILQ_INIT(&req->vdp);
-	VDP_push(req, ved_vdp_bytes, preq);
+	VDP_push(req, ved_vdp_bytes, preq, 0);
 
 	THR_SetRequest(req);
 
diff --git a/bin/varnishd/cache/cache_filter.h b/bin/varnishd/cache/cache_filter.h
index 87f240a..49dda2f 100644
--- a/bin/varnishd/cache/cache_filter.h
+++ b/bin/varnishd/cache/cache_filter.h
@@ -106,7 +106,7 @@ struct vdp_entry {
 };
 
 int VDP_bytes(struct req *, enum vdp_action act, const void *ptr, ssize_t len);
-void VDP_push(struct req *, vdp_bytes *func, void *priv);
+void VDP_push(struct req *, vdp_bytes *func, void *priv, int bottom);
 void VDP_close(struct req *req);
 
 vdp_bytes VDP_gunzip;
diff --git a/bin/varnishd/cache/cache_session.c b/bin/varnishd/cache/cache_session.c
index 024d74f..7749216 100644
--- a/bin/varnishd/cache/cache_session.c
+++ b/bin/varnishd/cache/cache_session.c
@@ -371,6 +371,9 @@ SES_GetReq(const struct worker *wrk, struct sess *sp)
 	req->t_prev = NAN;
 	req->t_req = NAN;
 
+	req->vdp_nxt = 0;
+	VTAILQ_INIT(&req->vdp);
+
 	return (req);
 }
 
diff --git a/bin/varnishd/http1/cache_http1_deliver.c b/bin/varnishd/http1/cache_http1_deliver.c
index eb15df4..22e8666 100644
--- a/bin/varnishd/http1/cache_http1_deliver.c
+++ b/bin/varnishd/http1/cache_http1_deliver.c
@@ -185,7 +185,7 @@ v1d_dorange(struct req *req, struct busyobj *bo, const char *r)
 	v1rp->range_off = 0;
 	v1rp->range_low = low;
 	v1rp->range_high = high + 1;
-	VDP_push(req, v1d_range_bytes, v1rp);
+	VDP_push(req, v1d_range_bytes, v1rp, 0);
 }
 
 /*--------------------------------------------------------------------*/
@@ -308,10 +308,10 @@ V1D_Deliver(struct req *req, struct busyobj *bo)
 		} else {
 			if (req->gzip_resp &&
 			    !ObjCheckFlag(req->wrk, req->objcore, OF_GZIPED))
-				VDP_push(req, VED_pretend_gzip, NULL);
+				VDP_push(req, VED_pretend_gzip, NULL, 0);
 			else if (!req->gzip_resp &&
 			    ObjCheckFlag(req->wrk, req->objcore, OF_GZIPED))
-				VDP_push(req, VDP_gunzip, NULL);
+				VDP_push(req, VDP_gunzip, NULL, 0);
 
 			if (req->res_mode & RES_ESI)
 				ESI_Deliver(req);
@@ -335,10 +335,6 @@ V1D_Deliver(struct req *req, struct busyobj *bo)
 	http_SetHeader(req->resp,
 	    req->doclose ? "Connection: close" : "Connection: keep-alive");
 
-	req->vdp_nxt = 0;
-	VTAILQ_INIT(&req->vdp);
-	VDP_push(req, v1d_bytes, NULL);
-
 	if (
 	    req->wantbody &&
 	    cache_param->http_range_support &&
@@ -349,7 +345,9 @@ V1D_Deliver(struct req *req, struct busyobj *bo)
 	}
 
 	if (req->res_mode & RES_GUNZIP)
-		VDP_push(req, VDP_gunzip, NULL);
+		VDP_push(req, VDP_gunzip, NULL, 0);
+
+	VDP_push(req, v1d_bytes, NULL, 1);
 
 	V1L_Reserve(req->wrk, req->ws, &req->sp->fd, req->vsl, req->t_prev);
 



More information about the varnish-commit mailing list