[master] 1c24449 Move the actual pushing of objects through VDP to a new function: VDP_DeliverObj()

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


commit 1c24449296aa987745ef2e039aa13f5006c77551
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Oct 27 16:39:21 2014 +0000

    Move the actual pushing of objects through VDP to a new
    function: VDP_DeliverObj()

diff --git a/bin/varnishd/cache/cache_deliver_proc.c b/bin/varnishd/cache/cache_deliver_proc.c
index fda860c..a3701a9 100644
--- a/bin/varnishd/cache/cache_deliver_proc.c
+++ b/bin/varnishd/cache/cache_deliver_proc.c
@@ -96,3 +96,47 @@ VDP_close(struct req *req)
 	while (!VTAILQ_EMPTY(&req->vdp))
 		vdp_pop(req, VTAILQ_FIRST(&req->vdp)->func);
 }
+
+/*--------------------------------------------------------------------*/
+
+enum objiter_status
+VDP_DeliverObj(struct req *req)
+{
+	enum objiter_status ois;
+	ssize_t len;
+	void *oi;
+	void *ptr;
+
+	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
+
+	if (req->res_mode & RES_ESI) {
+		ESI_Deliver(req);
+		return (OIS_DONE);
+	}
+
+	oi = ObjIterBegin(req->wrk, req->objcore);
+	XXXAN(oi);
+	AZ(req->synth_body);
+
+	do {
+		ois = ObjIter(req->objcore, oi, &ptr, &len);
+		switch(ois) {
+		case OIS_DONE:
+			AZ(len);
+			break;
+		case OIS_ERROR:
+			break;
+		case OIS_DATA:
+		case OIS_STREAM:
+			if (VDP_bytes(req,
+			     ois == OIS_DATA ? VDP_NULL : VDP_FLUSH,  ptr, len))
+				ois = OIS_ERROR;
+			break;
+		default:
+			WRONG("Wrong OIS value");
+		}
+	} while (ois == OIS_DATA || ois == OIS_STREAM);
+	ObjIterEnd(req->objcore, &oi);
+	return (ois);
+}
+
diff --git a/bin/varnishd/cache/cache_filter.h b/bin/varnishd/cache/cache_filter.h
index 49dda2f..859b1e5 100644
--- a/bin/varnishd/cache/cache_filter.h
+++ b/bin/varnishd/cache/cache_filter.h
@@ -108,6 +108,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, int bottom);
 void VDP_close(struct req *req);
+enum objiter_status VDP_DeliverObj(struct req *req);
 
 vdp_bytes VDP_gunzip;
 vdp_bytes VED_pretend_gzip;
diff --git a/bin/varnishd/http1/cache_http1_deliver.c b/bin/varnishd/http1/cache_http1_deliver.c
index 8012f7c..32bf944 100644
--- a/bin/varnishd/http1/cache_http1_deliver.c
+++ b/bin/varnishd/http1/cache_http1_deliver.c
@@ -188,44 +188,6 @@ v1d_dorange(struct req *req, struct busyobj *bo, const char *r)
 	VDP_push(req, v1d_range_bytes, v1rp, 0);
 }
 
-/*--------------------------------------------------------------------*/
-
-static enum objiter_status
-v1d_WriteDirObj(struct req *req)
-{
-	enum objiter_status ois;
-	ssize_t len;
-	void *oi;
-	void *ptr;
-
-	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
-
-	oi = ObjIterBegin(req->wrk, req->objcore);
-	XXXAN(oi);
-	AZ(req->synth_body);
-
-	do {
-		ois = ObjIter(req->objcore, oi, &ptr, &len);
-		switch(ois) {
-		case OIS_DONE:
-			AZ(len);
-			break;
-		case OIS_ERROR:
-			break;
-		case OIS_DATA:
-		case OIS_STREAM:
-			if (VDP_bytes(req,
-			     ois == OIS_DATA ? VDP_NULL : VDP_FLUSH,  ptr, len))
-				ois = OIS_ERROR;
-			break;
-		default:
-			WRONG("Wrong OIS value");
-		}
-	} while (ois == OIS_DATA || ois == OIS_STREAM);
-	ObjIterEnd(req->objcore, &oi);
-	return (ois);
-}
-
 /*--------------------------------------------------------------------
  */
 void
@@ -257,10 +219,7 @@ V1D_Deliver(struct req *req, struct busyobj *bo)
 			else if (!req->gzip_resp && i)
 				VDP_push(req, VDP_gunzip, NULL, 0);
 
-			if (req->res_mode & RES_ESI)
-				ESI_Deliver(req);
-			else
-				(void)v1d_WriteDirObj(req);
+			(void)VDP_DeliverObj(req);
 		}
 		(void)VDP_bytes(req, VDP_FLUSH, NULL, 0);
 		VDP_close(req);
@@ -353,12 +312,8 @@ V1D_Deliver(struct req *req, struct busyobj *bo)
 		V1L_Chunked(req->wrk);
 
 	ois = OIS_DONE;
-	if (req->wantbody) {
-		if (req->res_mode & RES_ESI)
-			ESI_Deliver(req);
-		else
-			ois = v1d_WriteDirObj(req);
-	}
+	if (req->wantbody)
+		ois = VDP_DeliverObj(req);
 	(void)VDP_bytes(req, VDP_FLUSH, NULL, 0);
 
 	if (ois == OIS_DONE && (req->res_mode & RES_CHUNKED))



More information about the varnish-commit mailing list