[master] 1016485 Make the req responsisble for getting rid of its own body.

Poul-Henning Kamp phk at varnish-cache.org
Thu May 23 10:55:09 CEST 2013


commit 10164855643afc42364c234428e5133143b8175d
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Thu May 23 08:54:52 2013 +0000

    Make the req responsisble for getting rid of its own body.

diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index 6018879..375c1d8 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -681,7 +681,7 @@ cnt_fetch(struct worker *wrk, struct req *req, struct busyobj *bo)
 
 	HTTP_Setup(bo->beresp, bo->ws, bo->vsl, HTTP_Beresp);
 
-	i = FetchHdr(wrk, bo, bo->do_pass ? req : NULL);
+	i = FetchHdr(wrk, bo, req);
 	/*
 	 * If we recycle a backend connection, there is a finite chance
 	 * that the backend closed it before we get a request to it.
@@ -689,12 +689,9 @@ cnt_fetch(struct worker *wrk, struct req *req, struct busyobj *bo)
 	 */
 	if (i == 1) {
 		VSC_C_main->backend_retry++;
-		i = FetchHdr(wrk, bo, bo->do_pass ? req : NULL);
+		i = FetchHdr(wrk, bo, req);
 	}
 
-	if (bo->fetch_objcore->objhead != NULL)
-		(void)HTTP1_DiscardReqBody(req);	// XXX
-
 	if (!i) {
 		/*
 		 * These two headers can be spread over multiple actual headers
@@ -798,7 +795,8 @@ VBF_Fetch(struct worker *wrk, struct req *req)
 	vbf_make_bereq(wrk, req, bo);
 	xxxassert (wrk->handling == VCL_RET_FETCH);
 
-	i = cnt_fetch(wrk, req, bo);
+	i = cnt_fetch(wrk, bo->do_pass ? req : NULL, bo);
+
 	if (i)
 		return (i);
 
@@ -858,11 +856,6 @@ VBF_Fetch(struct worker *wrk, struct req *req)
 	else if (bo->is_gzip)
 		bo->vfp = &vfp_testgzip;
 
-	if (bo->do_esi || req->esi_level > 0)
-		bo->do_stream = 0;
-	if (!req->wantbody)
-		bo->do_stream = 0;
-
 	/* No reason to try streaming a non-existing body */
 	if (bo->htc.body_status == BS_NONE)
 		bo->do_stream = 0;
@@ -956,18 +949,6 @@ VBF_Fetch(struct worker *wrk, struct req *req)
 
 	assert(WRW_IsReleased(wrk));
 
-#if 0
-	/*
-	 * If we can deliver a 304 reply, we don't bother streaming.
-	 * Notice that vcl_deliver{} could still nuke the headers
-	 * that allow the 304, in which case we return 200 non-stream.
-	 */
-	if (obj->response == 200 &&
-	    req->http->conds &&
-	    RFC2616_Do_Cond(req))
-		bo->do_stream = 0;
-#endif
-
 	/*
 	 * Ready to fetch the body
 	 */
diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c
index 9f1df09..2def95e 100644
--- a/bin/varnishd/cache/cache_req_fsm.c
+++ b/bin/varnishd/cache/cache_req_fsm.c
@@ -362,6 +362,7 @@ cnt_fetch(struct worker *wrk, struct req *req)
 	i = VBF_Fetch(wrk, req);
 	AN(req->busyobj);
 	assert(req->busyobj->refcount > 0);
+	(void)HTTP1_DiscardReqBody(req);
 	if (i < 0) {
 		VBO_DerefBusyObj(wrk, &req->busyobj);
 		req->err_code = 503;



More information about the varnish-commit mailing list