[master] bb3d027bf Ensure that transports call VDP_Close()

Nils Goroll nils.goroll at uplex.de
Fri Mar 1 14:43:05 UTC 2024


commit bb3d027bf6647185be548050243e1cb9d36741a7
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Wed Feb 28 15:04:39 2024 +0100

    Ensure that transports call VDP_Close()

diff --git a/bin/varnishd/cache/cache_deliver_proc.c b/bin/varnishd/cache/cache_deliver_proc.c
index a6d9832ed..035cf526f 100644
--- a/bin/varnishd/cache/cache_deliver_proc.c
+++ b/bin/varnishd/cache/cache_deliver_proc.c
@@ -59,7 +59,15 @@ VDP_Panic(struct vsb *vsb, const struct vdp_ctx *vdc)
 	VSB_cat(vsb, "},\n");
 }
 
-
+/*
+ * Ensure that transports have called VDP_Close()
+ * to avoid leaks in VDPs
+ */
+void
+VDP_Fini(struct vdp_ctx *vdc)
+{
+	assert(VTAILQ_EMPTY(&vdc->vdp));
+}
 
 void
 VDP_Init(struct vdp_ctx *vdc, struct worker *wrk, struct vsl_log *vsl,
diff --git a/bin/varnishd/cache/cache_req.c b/bin/varnishd/cache/cache_req.c
index cfea8fce2..bd457ff19 100644
--- a/bin/varnishd/cache/cache_req.c
+++ b/bin/varnishd/cache/cache_req.c
@@ -313,6 +313,8 @@ Req_Cleanup(struct sess *sp, struct worker *wrk, struct req *req)
 		wrk->stats->ws_client_overflow++;
 
 	wrk->seen_methods = 0;
+
+	VDP_Fini(req->vdc);
 }
 
 /*----------------------------------------------------------------------
diff --git a/bin/varnishd/cache/cache_varnishd.h b/bin/varnishd/cache/cache_varnishd.h
index 540781821..0ce03cf0a 100644
--- a/bin/varnishd/cache/cache_varnishd.h
+++ b/bin/varnishd/cache/cache_varnishd.h
@@ -189,6 +189,7 @@ void VDI_Event(const struct director *d, enum vcl_event_e ev);
 void VDI_Init(void);
 
 /* cache_deliver_proc.c */
+void VDP_Fini(struct vdp_ctx *vdc);
 void VDP_Init(struct vdp_ctx *vdc, struct worker *wrk, struct vsl_log *vsl,
     struct req *req);
 uint64_t VDP_Close(struct vdp_ctx *, struct objcore *, struct boc *);


More information about the varnish-commit mailing list