[master] fa31620e2 Allow VDP->init to say "no thanks, but do go on delivering."

Poul-Henning Kamp phk at FreeBSD.org
Mon Nov 19 22:15:16 UTC 2018


commit fa31620e2facb1e44f8379dd2c00c477889ba3e3
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 0e7602a10..c549f3be3 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)
 {
 	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)
 	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);
@@ -106,6 +108,12 @@ VDP_Push(struct req *req, const struct vdp *vdp, void *priv)
 	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 79097f99d..57415e1af 100644
--- a/bin/varnishd/cache/cache_filter.h
+++ b/bin/varnishd/cache/cache_filter.h
@@ -99,6 +99,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