[6.0] 44464a7fa Allow VDP->init to say "no thanks, but do go on delivering."
Dridi Boukelmoune
dridi.boukelmoune at gmail.com
Wed Feb 6 10:11:09 UTC 2019
commit 44464a7fa0ecbaa7495f772f94782394954e9215
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Mon Nov 19 12:21:26 2018 +0000
Allow VDP->init to say "no thanks, but do go on delivering."
diff --git a/bin/varnishd/cache/cache_deliver_proc.c b/bin/varnishd/cache/cache_deliver_proc.c
index 6d603ad77..f943d3f53 100644
--- a/bin/varnishd/cache/cache_deliver_proc.c
+++ b/bin/varnishd/cache/cache_deliver_proc.c
@@ -78,6 +78,7 @@ VDP_push(struct req *req, const struct vdp *vdp, void *priv, int bottom)
{
struct vdp_entry *vdpe;
struct vdp_ctx *vdc;
+ uintptr_t sn;
CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
vdc = req->vdc;
@@ -91,6 +92,7 @@ VDP_push(struct req *req, const struct vdp *vdp, void *priv, int bottom)
if (DO_DEBUG(DBG_PROCESSORS))
VSLb(req->vsl, SLT_Debug, "VDP_push(%s)", vdp->name);
+ sn = WS_Snapshot(req->ws);
vdpe = WS_Alloc(req->ws, sizeof *vdpe);
if (vdpe == NULL) {
AZ(vdc->retval);
@@ -109,6 +111,12 @@ VDP_push(struct req *req, const struct vdp *vdp, void *priv, int bottom)
AZ(vdc->retval);
if (vdpe->vdp->init != NULL)
vdc->retval = vdpe->vdp->init(req, &vdpe->priv);
+ if (vdc->retval > 0) {
+ VTAILQ_REMOVE(&vdc->vdp, vdpe, list);
+ vdc->nxt = VTAILQ_FIRST(&vdc->vdp);
+ WS_Reset(req->ws, sn);
+ vdc->retval = 0;
+ }
return (vdc->retval);
}
diff --git a/bin/varnishd/cache/cache_filter.h b/bin/varnishd/cache/cache_filter.h
index 30af823e4..6c2c04b70 100644
--- a/bin/varnishd/cache/cache_filter.h
+++ b/bin/varnishd/cache/cache_filter.h
@@ -97,6 +97,13 @@ enum vdp_action {
};
typedef int vdp_init_f(struct req *, void **priv);
+/*
+ * Return value:
+ * negative: Error - abandon delivery
+ * zero: OK
+ * positive: Don't push this VDP anyway
+ */
+
typedef int vdp_fini_f(struct req *, void **priv);
typedef int vdp_bytes_f(struct req *, enum vdp_action, void **priv,
const void *ptr, ssize_t len);
More information about the varnish-commit
mailing list