[master] 7ec9794 Move res_mode from worker to req

Poul-Henning Kamp phk at varnish-cache.org
Mon Feb 13 13:17:13 CET 2012


commit 7ec9794e3679f4313e9d5c630665b2e34d28030d
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Feb 13 12:17:00 2012 +0000

    Move res_mode from worker to req

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 3fafda1..162cbe9 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -343,15 +343,6 @@ struct worker {
 	double			first_byte_timeout;
 	double			between_bytes_timeout;
 
-	/* 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)
-
 	/* Temporary accounting */
 	struct acct		acct_tmp;
 };
@@ -626,6 +617,14 @@ struct req {
 	ssize_t			l_crc;
 	uint32_t		crc;
 
+	/* 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)
 
 };
 
diff --git a/bin/varnishd/cache/cache_center.c b/bin/varnishd/cache/cache_center.c
index 6692491..826e1d7 100644
--- a/bin/varnishd/cache/cache_center.c
+++ b/bin/varnishd/cache/cache_center.c
@@ -216,26 +216,26 @@ cnt_prepresp(struct sess *sp, struct worker *wrk, struct req *req)
 		AssertObjCorePassOrBusy(req->obj->objcore);
 	}
 
-	wrk->res_mode = 0;
+	req->res_mode = 0;
 
 	if (wrk->busyobj == NULL)
-		wrk->res_mode |= RES_LEN;
+		req->res_mode |= RES_LEN;
 
 	if (wrk->busyobj != NULL &&
 	    (wrk->busyobj->h_content_length != NULL ||
 	    !wrk->busyobj->do_stream) &&
 	    !wrk->busyobj->do_gzip && !wrk->busyobj->do_gunzip)
-		wrk->res_mode |= RES_LEN;
+		req->res_mode |= RES_LEN;
 
 	if (!req->disable_esi && req->obj->esidata != NULL) {
 		/* In ESI mode, we don't know the aggregate length */
-		wrk->res_mode &= ~RES_LEN;
-		wrk->res_mode |= RES_ESI;
+		req->res_mode &= ~RES_LEN;
+		req->res_mode |= RES_ESI;
 	}
 
 	if (req->esi_level > 0) {
-		wrk->res_mode &= ~RES_LEN;
-		wrk->res_mode |= RES_ESI_CHILD;
+		req->res_mode &= ~RES_LEN;
+		req->res_mode |= RES_ESI_CHILD;
 	}
 
 	if (cache_param->http_gzip_support && req->obj->gziped &&
@@ -244,24 +244,24 @@ cnt_prepresp(struct sess *sp, struct worker *wrk, struct req *req)
 		 * We don't know what it uncompresses to
 		 * XXX: we could cache that
 		 */
-		wrk->res_mode &= ~RES_LEN;
-		wrk->res_mode |= RES_GUNZIP;
+		req->res_mode &= ~RES_LEN;
+		req->res_mode |= RES_GUNZIP;
 	}
 
-	if (!(wrk->res_mode & (RES_LEN|RES_CHUNKED|RES_EOF))) {
+	if (!(req->res_mode & (RES_LEN|RES_CHUNKED|RES_EOF))) {
 		if (req->obj->len == 0 &&
 		    (wrk->busyobj == NULL || !wrk->busyobj->do_stream))
 			/*
 			 * If the object is empty, neither ESI nor GUNZIP
 			 * can make it any different size
 			 */
-			wrk->res_mode |= RES_LEN;
+			req->res_mode |= RES_LEN;
 		else if (!req->wantbody) {
 			/* Nothing */
 		} else if (req->http->protover >= 11) {
-			wrk->res_mode |= RES_CHUNKED;
+			req->res_mode |= RES_CHUNKED;
 		} else {
-			wrk->res_mode |= RES_EOF;
+			req->res_mode |= RES_EOF;
 			req->doclose = "EOF mode";
 		}
 	}
diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c
index 9747919..bfd6a8c 100644
--- a/bin/varnishd/cache/cache_esi_deliver.c
+++ b/bin/varnishd/cache/cache_esi_deliver.c
@@ -60,7 +60,7 @@ ved_include(struct sess *sp, const char *src, const char *host)
 
 	obj = sp->req->obj;
 	sp->req->obj = NULL;
-	res_mode = sp->wrk->res_mode;
+	res_mode = sp->req->res_mode;
 
 	/* Reset request to status before we started messing with it */
 	HTTP_Copy(sp->req->http, sp->req->http0);
@@ -107,14 +107,14 @@ ved_include(struct sess *sp, const char *src, const char *host)
 	assert(sp->step == STP_DONE);
 	sp->req->esi_level--;
 	sp->req->obj = obj;
-	sp->wrk->res_mode = res_mode;
+	sp->req->res_mode = res_mode;
 
 	/* Reset the workspace */
 	WS_Reset(sp->req->ws, sp_ws_wm);
 	WS_Reset(w->aws, wrk_ws_wm);	/* XXX ? */
 
 	WRW_Reserve(sp->wrk, &sp->fd);
-	if (sp->wrk->res_mode & RES_CHUNKED)
+	if (sp->req->res_mode & RES_CHUNKED)
 		WRW_Chunked(sp->wrk);
 }
 
@@ -247,7 +247,7 @@ ESI_Deliver(struct sess *sp)
 		 * Only the top level document gets to decide this.
 		 */
 		sp->req->gzip_resp = 0;
-		if (isgzip && !(sp->wrk->res_mode & RES_GUNZIP)) {
+		if (isgzip && !(sp->req->res_mode & RES_GUNZIP)) {
 			assert(sizeof gzip_hdr == 10);
 			/* Send out the gzip header */
 			(void)WRW_Write(sp->wrk, gzip_hdr, 10);
diff --git a/bin/varnishd/cache/cache_response.c b/bin/varnishd/cache/cache_response.c
index 2b22829..d560211 100644
--- a/bin/varnishd/cache/cache_response.c
+++ b/bin/varnishd/cache/cache_response.c
@@ -94,7 +94,7 @@ res_dorange(const struct sess *sp, const char *r, ssize_t *plow, ssize_t *phigh)
 	    "Content-Range: bytes %jd-%jd/%jd",
 	    (intmax_t)low, (intmax_t)high, (intmax_t)req->obj->len);
 	http_Unset(req->resp, H_Content_Length);
-	assert(sp->wrk->res_mode & RES_LEN);
+	assert(req->res_mode & RES_LEN);
 	http_PrintfHeader(sp->wrk, sp->vsl_id, req->resp,
 	    "Content-Length: %jd", (intmax_t)(1 + high - low));
 	http_SetResp(req->resp, "HTTP/1.1", 206, "Partial Content");
@@ -119,7 +119,7 @@ RES_BuildHttp(const struct sess *sp)
 	req->resp->logtag = HTTP_Tx;
 	http_FilterResp(sp, req->obj->http, req->resp, 0);
 
-	if (!(sp->wrk->res_mode & RES_LEN)) {
+	if (!(req->res_mode & RES_LEN)) {
 		http_Unset(req->resp, H_Content_Length);
 	} else if (cache_param->http_range_support) {
 		/* We only accept ranges if we know the length */
@@ -127,7 +127,7 @@ RES_BuildHttp(const struct sess *sp)
 		    "Accept-Ranges: bytes");
 	}
 
-	if (sp->wrk->res_mode & RES_CHUNKED)
+	if (req->res_mode & RES_CHUNKED)
 		http_SetHeader(sp->wrk, sp->vsl_id, req->resp,
 		    "Transfer-Encoding: chunked");
 
@@ -260,8 +260,8 @@ RES_WriteObj(struct sess *sp)
 	high = req->obj->len - 1;
 	if (
 	    req->wantbody &&
-	    (sp->wrk->res_mode & RES_LEN) &&
-	    !(sp->wrk->res_mode & (RES_ESI|RES_ESI_CHILD|RES_GUNZIP)) &&
+	    (req->res_mode & RES_LEN) &&
+	    !(req->res_mode & (RES_ESI|RES_ESI_CHILD|RES_GUNZIP)) &&
 	    cache_param->http_range_support &&
 	    req->obj->response == 200 &&
 	    http_GetHdr(req->http, H_Range, &r))
@@ -270,41 +270,41 @@ RES_WriteObj(struct sess *sp)
 	/*
 	 * Always remove C-E if client don't grok it
 	 */
-	if (sp->wrk->res_mode & RES_GUNZIP)
+	if (req->res_mode & RES_GUNZIP)
 		http_Unset(req->resp, H_Content_Encoding);
 
 	/*
 	 * Send HTTP protocol header, unless interior ESI object
 	 */
-	if (!(sp->wrk->res_mode & RES_ESI_CHILD))
+	if (!(req->res_mode & RES_ESI_CHILD))
 		sp->wrk->acct_tmp.hdrbytes +=
 		    http_Write(sp->wrk, sp->vsl_id, req->resp, 1);
 
 	if (!req->wantbody)
-		sp->wrk->res_mode &= ~RES_CHUNKED;
+		req->res_mode &= ~RES_CHUNKED;
 
-	if (sp->wrk->res_mode & RES_CHUNKED)
+	if (req->res_mode & RES_CHUNKED)
 		WRW_Chunked(sp->wrk);
 
 	if (!req->wantbody) {
 		/* This was a HEAD or conditional request */
 	} else if (req->obj->len == 0) {
 		/* Nothing to do here */
-	} else if (sp->wrk->res_mode & RES_ESI) {
+	} else if (req->res_mode & RES_ESI) {
 		ESI_Deliver(sp);
-	} else if (sp->wrk->res_mode & RES_ESI_CHILD && req->gzip_resp) {
+	} else if (req->res_mode & RES_ESI_CHILD && req->gzip_resp) {
 		ESI_DeliverChild(sp);
-	} else if (sp->wrk->res_mode & RES_ESI_CHILD &&
+	} else if (req->res_mode & RES_ESI_CHILD &&
 	    !req->gzip_resp && req->obj->gziped) {
 		res_WriteGunzipObj(sp);
-	} else if (sp->wrk->res_mode & RES_GUNZIP) {
+	} else if (req->res_mode & RES_GUNZIP) {
 		res_WriteGunzipObj(sp);
 	} else {
 		res_WriteDirObj(sp, low, high);
 	}
 
-	if (sp->wrk->res_mode & RES_CHUNKED &&
-	    !(sp->wrk->res_mode & RES_ESI_CHILD))
+	if (req->res_mode & RES_CHUNKED &&
+	    !(req->res_mode & RES_ESI_CHILD))
 		WRW_EndChunk(sp->wrk);
 
 	if (WRW_FlushRelease(sp->wrk) && sp->fd >= 0)
@@ -321,18 +321,18 @@ RES_StreamStart(struct sess *sp)
 	sctx = sp->wrk->sctx;
 	CHECK_OBJ_NOTNULL(sctx, STREAM_CTX_MAGIC);
 
-	AZ(sp->wrk->res_mode & RES_ESI_CHILD);
+	AZ(sp->req->res_mode & RES_ESI_CHILD);
 	AN(sp->req->wantbody);
 
 	WRW_Reserve(sp->wrk, &sp->fd);
 
-	if (sp->wrk->res_mode & RES_GUNZIP) {
+	if (sp->req->res_mode & RES_GUNZIP) {
 		sctx->vgz = VGZ_NewUngzip(sp->wrk, "U S -");
 		AZ(VGZ_WrwInit(sctx->vgz));
 		http_Unset(sp->req->resp, H_Content_Encoding);
 	}
 
-	if (!(sp->wrk->res_mode & RES_CHUNKED) &&
+	if (!(sp->req->res_mode & RES_CHUNKED) &&
 	    sp->wrk->busyobj->h_content_length != NULL)
 		http_PrintfHeader(sp->wrk, sp->vsl_id, sp->req->resp,
 		    "Content-Length: %s", sp->wrk->busyobj->h_content_length);
@@ -340,7 +340,7 @@ RES_StreamStart(struct sess *sp)
 	sp->wrk->acct_tmp.hdrbytes +=
 	    http_Write(sp->wrk, sp->vsl_id, sp->req->resp, 1);
 
-	if (sp->wrk->res_mode & RES_CHUNKED)
+	if (sp->req->res_mode & RES_CHUNKED)
 		WRW_Chunked(sp->wrk);
 }
 
@@ -367,7 +367,7 @@ RES_StreamPoll(struct worker *wrk)
 		}
 		l2 = st->len + l - sctx->stream_next;
 		ptr = st->ptr + (sctx->stream_next - l);
-		if (wrk->res_mode & RES_GUNZIP) {
+		if (wrk->sp->req->res_mode & RES_GUNZIP) {
 			(void)VGZ_WrwGunzip(wrk, sctx->vgz, ptr, l2);
 		} else {
 			(void)WRW_Write(wrk, ptr, l2);
@@ -375,7 +375,7 @@ RES_StreamPoll(struct worker *wrk)
 		l += st->len;
 		sctx->stream_next += l2;
 	}
-	if (!(wrk->res_mode & RES_GUNZIP))
+	if (!(wrk->sp->req->res_mode & RES_GUNZIP))
 		(void)WRW_Flush(wrk);
 
 	if (wrk->busyobj->fetch_obj->objcore == NULL ||
@@ -404,13 +404,13 @@ RES_StreamEnd(struct sess *sp)
 	sctx = sp->wrk->sctx;
 	CHECK_OBJ_NOTNULL(sctx, STREAM_CTX_MAGIC);
 
-	if (sp->wrk->res_mode & RES_GUNZIP) {
+	if (sp->req->res_mode & RES_GUNZIP) {
 		AN(sctx->vgz);
 		VGZ_WrwFlush(sp->wrk, sctx->vgz);
 		(void)VGZ_Destroy(&sctx->vgz, sp->vsl_id);
 	}
-	if (sp->wrk->res_mode & RES_CHUNKED &&
-	    !(sp->wrk->res_mode & RES_ESI_CHILD))
+	if (sp->req->res_mode & RES_CHUNKED &&
+	    !(sp->req->res_mode & RES_ESI_CHILD))
 		WRW_EndChunk(sp->wrk);
 	if (WRW_FlushRelease(sp->wrk))
 		SES_Close(sp, "remote closed");
diff --git a/bin/varnishd/flint.lnt b/bin/varnishd/flint.lnt
index 1942c63..15f91df 100644
--- a/bin/varnishd/flint.lnt
+++ b/bin/varnishd/flint.lnt
@@ -165,3 +165,4 @@
 -e712	// 96 Loss of precision (___) (___ to ___)
 -e747	// 297 Significant prototype coercion (___) ___ to ___
 -e840	// Use of nul character in a string literal (see: vcc_if.c)
+-e663	// Suspicious array to pointer conversion



More information about the varnish-commit mailing list