[master] 644be66 More V1D/VDP reorg

Poul-Henning Kamp phk at FreeBSD.org
Mon Oct 27 15:18:50 CET 2014


commit 644be66fbec23145bd5caceee00f8fca934274d6
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Oct 27 14:18:35 2014 +0000

    More V1D/VDP reorg

diff --git a/bin/varnishd/http1/cache_http1_deliver.c b/bin/varnishd/http1/cache_http1_deliver.c
index 22e8666..8012f7c 100644
--- a/bin/varnishd/http1/cache_http1_deliver.c
+++ b/bin/varnishd/http1/cache_http1_deliver.c
@@ -233,23 +233,41 @@ V1D_Deliver(struct req *req, struct busyobj *bo)
 {
 	const char *r;
 	enum objiter_status ois;
+	int i;
 
 	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
 	CHECK_OBJ_NOTNULL(req->objcore, OBJCORE_MAGIC);
 
 	req->res_mode = 0;
 
-	if (req->esi_level > 0)
+	if (!req->disable_esi &&
+	    ObjGetattr(req->wrk, req->objcore, OA_ESIDATA, NULL) != NULL)
+		req->res_mode |= RES_ESI;
+
+	if (req->esi_level > 0) {
 		req->res_mode |= RES_ESI_CHILD;
+		i = ObjCheckFlag(req->wrk, req->objcore, OF_GZIPED);
+		if (req->gzip_resp && i && !(req->res_mode & RES_ESI)) {
+			if (bo != NULL)
+				VBO_waitstate(bo, BOS_FINISHED);
+			ESI_DeliverChild(req);
+		} else {
+			if (req->gzip_resp && !i)
+				VDP_push(req, VED_pretend_gzip, NULL, 0);
+			else if (!req->gzip_resp && i)
+				VDP_push(req, VDP_gunzip, NULL, 0);
 
-	if (!req->disable_esi && ObjGetattr(req->wrk, req->objcore,
-	    OA_ESIDATA, NULL) != NULL) {
-		/* In ESI mode, we can't know the aggregate length */
-		req->res_mode |= RES_ESI;
-		RFC2616_Weaken_Etag(req->resp);
+			if (req->res_mode & RES_ESI)
+				ESI_Deliver(req);
+			else
+				(void)v1d_WriteDirObj(req);
+		}
+		(void)VDP_bytes(req, VDP_FLUSH, NULL, 0);
+		VDP_close(req);
+		return;
 	}
 
-	if (req->res_mode & (RES_ESI_CHILD|RES_ESI)) {
+	if (req->res_mode & RES_ESI) {
 		/* nothing */
 	} else if (http_IsStatus(req->resp, 304)) {
 		req->res_mode &= ~RES_LEN;
@@ -298,31 +316,6 @@ V1D_Deliver(struct req *req, struct busyobj *bo)
 	}
 	VSLb(req->vsl, SLT_Debug, "RES_MODE %x", req->res_mode);
 
-	if (req->esi_level > 0) {
-		if (req->gzip_resp &&
-		    ObjCheckFlag(req->wrk, req->objcore, OF_GZIPED) &&
-		    !(req->res_mode & RES_ESI)) {
-			if (bo != NULL)
-				VBO_waitstate(bo, BOS_FINISHED);
-			ESI_DeliverChild(req);
-		} else {
-			if (req->gzip_resp &&
-			    !ObjCheckFlag(req->wrk, req->objcore, OF_GZIPED))
-				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, 0);
-
-			if (req->res_mode & RES_ESI)
-				ESI_Deliver(req);
-			else
-				(void)v1d_WriteDirObj(req);
-		}
-		(void)VDP_bytes(req, VDP_FLUSH, NULL, 0);
-		VDP_close(req);
-		return;
-	}
-
 	if (!(req->res_mode & RES_LEN))
 		http_Unset(req->resp, H_Content_Length);
 
@@ -332,6 +325,9 @@ V1D_Deliver(struct req *req, struct busyobj *bo)
 	if (req->res_mode & RES_CHUNKED)
 		http_SetHeader(req->resp, "Transfer-Encoding: chunked");
 
+	if (req->res_mode & RES_ESI)
+		RFC2616_Weaken_Etag(req->resp);
+
 	http_SetHeader(req->resp,
 	    req->doclose ? "Connection: close" : "Connection: keep-alive");
 



More information about the varnish-commit mailing list