[master] 8c5d1e729 Try to contain pipe-magic in pipe code.

Poul-Henning Kamp phk at FreeBSD.org
Wed Feb 19 13:29:06 UTC 2020


commit 8c5d1e7298d3bd79b1af924ead1a4dd5d83be2a0
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Wed Feb 19 10:47:43 2020 +0000

    Try to contain pipe-magic in pipe code.

diff --git a/bin/varnishd/cache/cache_backend.c b/bin/varnishd/cache/cache_backend.c
index 81ab3c5fa..1ce50846c 100644
--- a/bin/varnishd/cache/cache_backend.c
+++ b/bin/varnishd/cache/cache_backend.c
@@ -288,7 +288,7 @@ vbe_dir_gethdrs(VRT_CTX, VCL_BACKEND d)
 			extrachance = 0;
 
 		i = V1F_SendReq(wrk, bo, &bo->acct.bereq_hdrbytes,
-				&bo->acct.bereq_bodybytes, 0);
+				&bo->acct.bereq_bodybytes);
 
 		if (PFD_State(pfd) != PFD_STATE_USED) {
 			if (VTP_Wait(wrk, pfd, VTIM_real() +
@@ -374,7 +374,7 @@ vbe_dir_http1pipe(VRT_CTX, VCL_BACKEND d)
 	} else {
 		CHECK_OBJ_NOTNULL(ctx->bo->htc, HTTP_CONN_MAGIC);
 		i = V1F_SendReq(ctx->req->wrk, ctx->bo,
-		    &v1a.bereq, &v1a.out, 1);
+		    &v1a.bereq, &v1a.out);
 		VSLb_ts_req(ctx->req, "Pipe", W_TIM_real(ctx->req->wrk));
 		if (i == 0)
 			V1P_Process(ctx->req, *PFD_Fd(pfd), &v1a);
diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c
index 7cff23876..a7dbb42e3 100644
--- a/bin/varnishd/cache/cache_req_fsm.c
+++ b/bin/varnishd/cache/cache_req_fsm.c
@@ -740,6 +740,9 @@ cnt_pipe(struct worker *wrk, struct req *req)
 			AZ(bo->req);
 			bo->req = req;
 			bo->wrk = wrk;
+			/* Unless cached, reqbody is not our job */
+			if (req->req_body_status != REQ_BODY_CACHED)
+				req->req_body_status = REQ_BODY_NONE;
 			SES_Close(req->sp, VDI_Http1Pipe(req, bo));
 			nxt = REQ_FSM_DONE;
 			V1P_Leave();
diff --git a/bin/varnishd/http1/cache_http1.h b/bin/varnishd/http1/cache_http1.h
index 4e66938bb..2e8b03ac3 100644
--- a/bin/varnishd/http1/cache_http1.h
+++ b/bin/varnishd/http1/cache_http1.h
@@ -33,7 +33,7 @@ struct VSC_vbe;
 
 /* cache_http1_fetch.c [V1F] */
 int V1F_SendReq(struct worker *, struct busyobj *, uint64_t *ctr_hdrbytes,
-    uint64_t *ctr_bodybytes, int onlycached);
+    uint64_t *ctr_bodybytes);
 int V1F_FetchRespHdr(struct busyobj *);
 int V1F_Setup_Fetch(struct vfp_ctx *vfc, struct http_conn *htc);
 
diff --git a/bin/varnishd/http1/cache_http1_fetch.c b/bin/varnishd/http1/cache_http1_fetch.c
index 50edabb83..ee7a9fec1 100644
--- a/bin/varnishd/http1/cache_http1_fetch.c
+++ b/bin/varnishd/http1/cache_http1_fetch.c
@@ -71,7 +71,7 @@ vbf_iter_req_body(void *priv, unsigned flush, const void *ptr, ssize_t l)
 
 int
 V1F_SendReq(struct worker *wrk, struct busyobj *bo, uint64_t *ctr_hdrbytes,
-    uint64_t *ctr_bodybytes, int onlycached)
+    uint64_t *ctr_bodybytes)
 {
 	struct http *hp;
 	enum sess_close sc;
@@ -114,7 +114,7 @@ V1F_SendReq(struct worker *wrk, struct busyobj *bo, uint64_t *ctr_hdrbytes,
 		if (do_chunked)
 			V1L_EndChunk(wrk);
 	} else if (bo->req != NULL &&
-	    (bo->req->req_body_status == REQ_BODY_CACHED || !onlycached)) {
+	    bo->req->req_body_status != REQ_BODY_NONE) {
 		if (do_chunked)
 			V1L_Chunked(wrk);
 		i = VRB_Iterate(wrk, bo->vsl, bo->req, vbf_iter_req_body, bo);


More information about the varnish-commit mailing list