[master] 11fc2672b Get rid of the trivial/single-file res_mode flags

Poul-Henning Kamp phk at FreeBSD.org
Mon Oct 15 20:18:09 UTC 2018


commit 11fc2672b698a6319ad6bffef7cfef3441180ce7
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Oct 15 20:16:55 2018 +0000

    Get rid of the trivial/single-file res_mode flags

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index b038ad157..3a3453c60 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -515,12 +515,7 @@ struct req {
 
 	/* Delivery mode */
 	unsigned		res_mode;
-#define RES_LEN			(1<<1)
-#define RES_EOF			(1<<2)
-#define RES_CHUNKED		(1<<3)
 #define RES_ESI			(1<<4)
-#define RES_ESI_CHILD		(1<<5)
-#define RES_GUNZIP		(1<<6)
 #define RES_PIPE		(1<<7)
 
 	/* Transaction VSL buffer */
diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c
index 468504fcd..9d1fd4782 100644
--- a/bin/varnishd/cache/cache_esi_deliver.c
+++ b/bin/varnishd/cache/cache_esi_deliver.c
@@ -831,7 +831,6 @@ ved_deliver(struct req *req, struct boc *boc, int wantbody)
 	if (boc == NULL && ObjGetLen(req->wrk, req->objcore) == 0)
 		return;
 
-	req->res_mode |= RES_ESI_CHILD;
 	i = ObjCheckFlag(req->wrk, req->objcore, OF_GZIPED);
 	if (ecx->isgzip && i && !(req->res_mode & RES_ESI)) {
 		ved_stripgzip(req, boc);
diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c
index bfe2f6279..a06bba614 100644
--- a/bin/varnishd/cache/cache_gzip.c
+++ b/bin/varnishd/cache/cache_gzip.c
@@ -299,7 +299,6 @@ vdp_gunzip_init(struct req *req, void **priv)
 		return (-1);
 	}
 
-	req->res_mode |= RES_GUNZIP;
 	VGZ_Obuf(vg, vg->m_buf, vg->m_sz);
 	*priv = vg;
 
diff --git a/bin/varnishd/http1/cache_http1_deliver.c b/bin/varnishd/http1/cache_http1_deliver.c
index 580a23e37..b2e061391 100644
--- a/bin/varnishd/http1/cache_http1_deliver.c
+++ b/bin/varnishd/http1/cache_http1_deliver.c
@@ -84,7 +84,7 @@ v1d_error(struct req *req, const char *msg)
 void v_matchproto_(vtr_deliver_f)
 V1D_Deliver(struct req *req, struct boc *boc, int sendbody)
 {
-	int err = 0;
+	int err = 0, chunked = 0;
 	unsigned u;
 	uint64_t hdrbytes, bytes;
 
@@ -103,14 +103,14 @@ V1D_Deliver(struct req *req, struct boc *boc, int sendbody)
 		http_SetHeader(req->resp, "Connection: keep-alive");
 
 	if (sendbody) {
-		if (http_GetHdr(req->resp, H_Content_Length, NULL))
-			req->res_mode |= RES_LEN;
-		else if (req->http->protover == 11) {
-			req->res_mode |= RES_CHUNKED;
-			http_SetHeader(req->resp, "Transfer-Encoding: chunked");
-		} else {
-			req->res_mode |= RES_EOF;
-			req->doclose = SC_TX_EOF;
+		if (!http_GetHdr(req->resp, H_Content_Length, NULL)) {
+			if (req->http->protover == 11) {
+				chunked = 1;
+				http_SetHeader(req->resp,
+				    "Transfer-Encoding: chunked");
+			} else {
+				req->doclose = SC_TX_EOF;
+			}
 		}
 		if (VDP_Push(req, &v1d_vdp, NULL)) {
 			v1d_error(req, "workspace_thread overflow");
@@ -144,10 +144,10 @@ V1D_Deliver(struct req *req, struct boc *boc, int sendbody)
 	if (sendbody) {
 		if (DO_DEBUG(DBG_FLUSH_HEAD))
 			(void)V1L_Flush(req->wrk);
-		if (req->res_mode & RES_CHUNKED)
+		if (chunked)
 			V1L_Chunked(req->wrk);
 		err = VDP_DeliverObj(req);
-		if (!err && (req->res_mode & RES_CHUNKED))
+		if (!err && chunked)
 			V1L_EndChunk(req->wrk);
 	}
 


More information about the varnish-commit mailing list