[master] 7a2e13ff0 VDP: allow for init-only filter implementations
Nils Goroll
nils.goroll at uplex.de
Wed Aug 21 17:48:05 UTC 2024
commit 7a2e13ff0fa32631bf2e270418f98e9b7cd3bdc0
Author: Nils Goroll <nils.goroll at uplex.de>
Date: Wed Aug 21 19:35:07 2024 +0200
VDP: allow for init-only filter implementations
VDPs can remove themselves from the filter list with a positive return value of
the init function, so VDPs which do not implement a bytes function can already
exist. Except there was an assertion requiring a non-NULL bytes function
pointer.
We now move the assertion such that a bytes function is only required if the
init function returns zero.
diff --git a/bin/varnishd/cache/cache_deliver_proc.c b/bin/varnishd/cache/cache_deliver_proc.c
index b0af89c74..04ff3bbec 100644
--- a/bin/varnishd/cache/cache_deliver_proc.c
+++ b/bin/varnishd/cache/cache_deliver_proc.c
@@ -155,7 +155,6 @@ VDP_Push(VRT_CTX, struct vdp_ctx *vdc, struct ws *ws, const struct vdp *vdp,
AN(ws);
AN(vdp);
AN(vdp->name);
- AN(vdp->bytes);
if (vdc->retval)
return (vdc->retval);
@@ -176,17 +175,18 @@ VDP_Push(VRT_CTX, struct vdp_ctx *vdc, struct ws *ws, const struct vdp *vdp,
vdc->nxt = VTAILQ_FIRST(&vdc->vdp);
AZ(vdc->retval);
- if (vdpe->vdp->init == NULL)
- return (vdc->retval);
-
- vdc->retval = vdpe->vdp->init(ctx, vdc, &vdpe->priv,
- vdpe == vdc->nxt ? vdc->req->objcore : NULL);
+ if (vdpe->vdp->init != NULL) {
+ vdc->retval = vdpe->vdp->init(ctx, vdc, &vdpe->priv,
+ vdpe == vdc->nxt ? vdc->req->objcore : NULL);
+ }
if (vdc->retval > 0) {
VTAILQ_REMOVE(&vdc->vdp, vdpe, list);
vdc->nxt = VTAILQ_FIRST(&vdc->vdp);
vdc->retval = 0;
}
+ else if (vdc->retval == 0)
+ AN(vdp->bytes);
return (vdc->retval);
}
More information about the varnish-commit
mailing list