Latch error values returned from any VDP function, making sure that
all subsequent calls to VDP_bytes() becomes noops. This allows calling
code to allow calling VDP_bytes() again even if a previous call
returned error.

Fixes: #1642
---
 bin/varnishd/cache/cache.h              | 1 +
 bin/varnishd/cache/cache_deliver_proc.c | 4 ++++
 bin/varnishd/cache/cache_session.c      | 1 +
 3 files changed, 6 insertions(+)

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 1db9644..f250afe 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -612,6 +612,7 @@ struct req {
        /* Deliver pipeline */
        struct vdp_entry_s      vdp;
        struct vdp_entry        *vdp_nxt;
+       unsigned                vdp_errval;
 
        /* Transaction VSL buffer */
        struct vsl_log          vsl[1];
diff --git a/bin/varnishd/cache/cache_deliver_proc.c 
b/bin/varnishd/cache/cache_deliver_proc.c
index a3701a9..a74b41f 100644
--- a/bin/varnishd/cache/cache_deliver_proc.c
+++ b/bin/varnishd/cache/cache_deliver_proc.c
@@ -40,6 +40,8 @@ VDP_bytes(struct req *req, enum vdp_action act, const void 
*ptr, ssize_t len)
 
        CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
        assert(act == VDP_NULL || act == VDP_FLUSH);
+       if (req->vdp_errval)
+               return (req->vdp_errval);
        vdp = req->vdp_nxt;
        CHECK_OBJ_NOTNULL(vdp, VDP_ENTRY_MAGIC);
        req->vdp_nxt = VTAILQ_NEXT(vdp, list);
@@ -47,6 +49,8 @@ VDP_bytes(struct req *req, enum vdp_action act, const void 
*ptr, ssize_t len)
        assert(act > VDP_NULL || len > 0);
        /* Call the present layer, while pointing to the next layer down */
        retval = vdp->func(req, act, &vdp->priv, ptr, len);
+       if (retval)
+               req->vdp_errval = retval; /* Latch error value */
        req->vdp_nxt = vdp;
        return (retval);
 }
diff --git a/bin/varnishd/cache/cache_session.c 
b/bin/varnishd/cache/cache_session.c
index 60c893e..cf1c4d5 100644
--- a/bin/varnishd/cache/cache_session.c
+++ b/bin/varnishd/cache/cache_session.c
@@ -373,6 +373,7 @@ SES_GetReq(const struct worker *wrk, struct sess *sp)
 
        req->vdp_nxt = 0;
        VTAILQ_INIT(&req->vdp);
+       req->vdp_errval = 0;
 
        return (req);
 }
-- 
2.1.3


_______________________________________________
varnish-dev mailing list
[email protected]
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-dev

Reply via email to