[master] 3247c51 Make pretend_gzip a VDP

Poul-Henning Kamp phk at FreeBSD.org
Tue Oct 21 22:43:41 CEST 2014


commit 3247c51d0e36654c3bf597347bb6a52530433e6b
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Tue Oct 21 20:43:15 2014 +0000

    Make pretend_gzip a VDP

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 185b3e8..7705ea4 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -1119,6 +1119,7 @@ void VRTPRIV_dynamic_kill(struct sess *sp, uintptr_t id);
 
 void ESI_Deliver(struct req *);
 void ESI_DeliverChild(struct req *);
+vdp_bytes VED_pretend_gzip;
 
 /* cache_vrt_vmod.c */
 void VMOD_Init(void);
diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c
index ba72bb7..cfb488e 100644
--- a/bin/varnishd/cache/cache_esi_deliver.c
+++ b/bin/varnishd/cache/cache_esi_deliver.c
@@ -205,12 +205,18 @@ ved_decode_len(uint8_t **pp)
  * the stream with a bit more overhead.
  */
 
-static int
-ved_pretend_gzip(struct req *req, const uint8_t *p, ssize_t l)
+int __match_proto__(vdp_bytes)
+VED_pretend_gzip(struct req *req, enum vdp_action act, const void *pv,
+    ssize_t l)
 {
 	uint8_t buf1[5], buf2[5];
+	const uint8_t *p;
 	uint16_t lx;
 
+	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
+	(void)act;
+	p = pv;
+
 	lx = 65535;
 	buf1[0] = 0;
 	vle16enc(buf1 + 1, lx);
@@ -355,7 +361,8 @@ ESI_Deliver(struct req *req)
 					 * A gzip'ed ESI response, but the VEC
 					 * was not gzip'ed.
 					 */
-					(void)ved_pretend_gzip(req, pp, l2);
+					(void)VED_pretend_gzip(req, VDP_NULL,
+					    pp, l2);
 				} else if (isgzip) {
 					/*
 					 * A gzip'ed VEC, but ungzip'ed ESI
@@ -482,16 +489,8 @@ ESI_DeliverChild(struct req *req)
 	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
 	CHECK_OBJ_NOTNULL(req->objcore, OBJCORE_MAGIC);
 
-	if (!ObjCheckFlag(req->wrk, req->objcore, OF_GZIPED)) {
-		oi = ObjIterBegin(req->wrk, req->objcore);
-		do {
-			ois = ObjIter(req->objcore, oi, &sp, &sl);
-			if (sl > 0 && ved_pretend_gzip(req, sp, sl))
-				break;
-		} while (ois == OIS_DATA || ois == OIS_STREAM);
-		ObjIterEnd(req->objcore, &oi);
-		return;
-	}
+	AN(ObjCheckFlag(req->wrk, req->objcore, OF_GZIPED));
+
 	/*
 	 * This is the interesting case: Deliver all the deflate
 	 * blocks, stripping the "LAST" bit of the last one and
diff --git a/bin/varnishd/http1/cache_http1_deliver.c b/bin/varnishd/http1/cache_http1_deliver.c
index 08d3264..70d61c7 100644
--- a/bin/varnishd/http1/cache_http1_deliver.c
+++ b/bin/varnishd/http1/cache_http1_deliver.c
@@ -340,6 +340,11 @@ V1D_Deliver(struct req *req, struct busyobj *bo)
 		/* This was a HEAD or conditional request */
 	} else if (req->res_mode & RES_ESI) {
 		ESI_Deliver(req);
+	} else if (req->res_mode & RES_ESI_CHILD && req->gzip_resp &&
+	    !ObjCheckFlag(req->wrk, req->objcore, OF_GZIPED)) {
+		VDP_push(req, VED_pretend_gzip);
+		ois = v1d_WriteDirObj(req);
+		VDP_pop(req, VED_pretend_gzip);
 	} else if (req->res_mode & RES_ESI_CHILD && req->gzip_resp) {
 		if (bo != NULL)
 			VBO_waitstate(bo, BOS_FINISHED);



More information about the varnish-commit mailing list