[master] faa60dc52 Make arguments to VDP_DeliverObj() explicit

Poul-Henning Kamp phk at FreeBSD.org
Mon Oct 26 20:07:09 UTC 2020


commit faa60dc526859eb0ba6b8a0baec38689803ff27c
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Oct 26 18:55:31 2020 +0000

    Make arguments to VDP_DeliverObj() explicit

diff --git a/bin/varnishd/cache/cache_deliver_proc.c b/bin/varnishd/cache/cache_deliver_proc.c
index 7ba2450a5..5cf465866 100644
--- a/bin/varnishd/cache/cache_deliver_proc.c
+++ b/bin/varnishd/cache/cache_deliver_proc.c
@@ -184,20 +184,23 @@ vdp_objiterator(void *priv, unsigned flush, const void *ptr, ssize_t len)
 }
 
 
-int
-VDP_DeliverObj(struct req *req)
+int VDP_DeliverObj(struct vdp_ctx *vdc, struct objcore *oc, struct worker *wrk,
+    struct vsl_log *vsl, struct req *req)
 {
 	int r, final;
 
-	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
-	req->vdc->req = req;
-	req->vdc->vsl = req->vsl;
-	req->vdc->wrk = req->wrk;
-	final = req->objcore->flags & (OC_F_PRIVATE | OC_F_HFM | OC_F_HFP)
-	    ? 1 : 0;
-	r = ObjIterate(req->wrk, req->objcore, req->vdc, vdp_objiterator, final);
+	CHECK_OBJ_NOTNULL(vdc, VDP_CTX_MAGIC);
+	CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
+	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
+	AN(vsl);
+	CHECK_OBJ_ORNULL(req, REQ_MAGIC);
+	vdc->vsl = vsl;
+	vdc->wrk = wrk;
+	vdc->req = req;
+	final = oc->flags & (OC_F_PRIVATE | OC_F_HFM | OC_F_HFP) ? 1 : 0;
+	r = ObjIterate(wrk, oc, vdc, vdp_objiterator, final);
 	if (r == 0)
-		r = VDP_bytes(req->vdc, VDP_END, NULL, 0);
+		r = VDP_bytes(vdc, VDP_END, NULL, 0);
 	if (r < 0)
 		return (r);
 	return (0);
diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c
index 5e702a3be..4548b5a51 100644
--- a/bin/varnishd/cache/cache_esi_deliver.c
+++ b/bin/varnishd/cache/cache_esi_deliver.c
@@ -865,7 +865,8 @@ ved_deliver(struct req *req, struct boc *boc, int wantbody)
 	}
 
 	if (i == 0) {
-		i = VDP_DeliverObj(req);
+		i = VDP_DeliverObj(
+		    req->vdc, req->objcore, req->wrk, req->vsl, req);
 	} else {
 		VSLb(req->vsl, SLT_Error, "Failure to push ESI processors");
 		req->doclose = SC_OVERLOAD;
diff --git a/bin/varnishd/cache/cache_filter.h b/bin/varnishd/cache/cache_filter.h
index f185171a8..fbf9b76ad 100644
--- a/bin/varnishd/cache/cache_filter.h
+++ b/bin/varnishd/cache/cache_filter.h
@@ -148,6 +148,14 @@ struct vdp_ctx {
 	struct req		*req;
 };
 
+extern const struct vdp VDP_gunzip;
+extern const struct vdp VDP_esi;
+extern const struct vdp VDP_range;
+
+uint64_t VDP_Close(struct req *req);
+int VDP_DeliverObj(struct vdp_ctx *vdc, struct objcore *oc, struct worker *wrk,
+    struct vsl_log *vsl, struct req *req);
+
 void VDP_Init(struct vdp_ctx *vdx);
 int VDP_bytes(struct vdp_ctx *, enum vdp_action act, const void *ptr, ssize_t len);
 int VDP_Push(struct req *, const struct vdp *, void *priv);
diff --git a/bin/varnishd/cache/cache_varnishd.h b/bin/varnishd/cache/cache_varnishd.h
index bc9750910..385c38e0d 100644
--- a/bin/varnishd/cache/cache_varnishd.h
+++ b/bin/varnishd/cache/cache_varnishd.h
@@ -233,14 +233,6 @@ void CLI_Init(void);
 void CLI_Run(void);
 void CLI_AddFuncs(struct cli_proto *p);
 
-/* cache_deliver_proc.c */
-uint64_t VDP_Close(struct req *req);
-int VDP_DeliverObj(struct req *req);
-
-extern const struct vdp VDP_gunzip;
-extern const struct vdp VDP_esi;
-extern const struct vdp VDP_range;
-
 /* cache_expire.c */
 void EXP_Init(void);
 void EXP_Shutdown(void);
diff --git a/bin/varnishd/http1/cache_http1_deliver.c b/bin/varnishd/http1/cache_http1_deliver.c
index 42262d384..ec8826168 100644
--- a/bin/varnishd/http1/cache_http1_deliver.c
+++ b/bin/varnishd/http1/cache_http1_deliver.c
@@ -149,7 +149,8 @@ V1D_Deliver(struct req *req, struct boc *boc, int sendbody)
 			(void)V1L_Flush(req->wrk);
 		if (chunked)
 			V1L_Chunked(req->wrk);
-		err = VDP_DeliverObj(req);
+		err = VDP_DeliverObj(
+		    req->vdc, req->objcore, req->wrk, req->vsl, req);
 		if (!err && chunked)
 			V1L_EndChunk(req->wrk);
 	}
diff --git a/bin/varnishd/http2/cache_http2_deliver.c b/bin/varnishd/http2/cache_http2_deliver.c
index 54be4148b..1ebfd3253 100644
--- a/bin/varnishd/http2/cache_http2_deliver.c
+++ b/bin/varnishd/http2/cache_http2_deliver.c
@@ -332,7 +332,8 @@ h2_deliver(struct req *req, struct boc *boc, int sendbody)
 	/* XXX someone into H2 please add appropriate error handling */
 	if (sendbody) {
 		if (!VDP_Push(req, &h2_vdp, NULL))
-			(void)VDP_DeliverObj(req);
+			(void)VDP_DeliverObj(
+			     req->vdc, req->objcore, req->wrk, req->vsl, req);
 	}
 
 	AZ(req->wrk->v1l);


More information about the varnish-commit mailing list