Adjust to VDP API Changes from VC#4035

Ref https://github.com/varnishcache/varnish-cache/pull/4035
parent dd88f32c
...@@ -140,7 +140,8 @@ get_zipflow_top(VRT_CTX) ...@@ -140,7 +140,8 @@ get_zipflow_top(VRT_CTX)
} }
static int vdp_zipflow_init(VRT_CTX, struct vdp_ctx *vdc, void **priv, static int vdp_zipflow_init(VRT_CTX, struct vdp_ctx *vdc, void **priv,
struct objcore *oc); struct objcore *oc, struct req *req,
struct http *hd, intmax_t *cl);
static int vdp_zipflow_fini(struct vdp_ctx *vdc, void **priv); static int vdp_zipflow_fini(struct vdp_ctx *vdc, void **priv);
static int vdp_zipflow_bytes(struct vdp_ctx *vdc, enum vdp_action act, static int vdp_zipflow_bytes(struct vdp_ctx *vdc, enum vdp_action act,
void **priv, const void *ptr, ssize_t len); void **priv, const void *ptr, ssize_t len);
...@@ -154,7 +155,8 @@ static const struct vdp vdp_zipflow[1] = {{ ...@@ -154,7 +155,8 @@ static const struct vdp vdp_zipflow[1] = {{
}}; }};
static int vdp_zipsub_init(VRT_CTX, struct vdp_ctx *vdc, void **priv, static int vdp_zipsub_init(VRT_CTX, struct vdp_ctx *vdc, void **priv,
struct objcore *oc); struct objcore *oc, struct req *req,
struct http *hd, intmax_t *cl);
static int vdp_zipsub_fini(struct vdp_ctx *vdc, void **priv); static int vdp_zipsub_fini(struct vdp_ctx *vdc, void **priv);
static int vdp_zipsub_bytes(struct vdp_ctx *vdc, enum vdp_action act, static int vdp_zipsub_bytes(struct vdp_ctx *vdc, enum vdp_action act,
void **priv, const void *ptr, ssize_t len); void **priv, const void *ptr, ssize_t len);
...@@ -611,26 +613,32 @@ zipsub_take(const struct zipflow_request *zfr) ...@@ -611,26 +613,32 @@ zipsub_take(const struct zipflow_request *zfr)
} }
static int static int
vdp_zipsub_init(VRT_CTX, struct vdp_ctx *vdc, void **priv, struct objcore *oc) vdp_zipsub_init(VRT_CTX, struct vdp_ctx *vdc, void **priv,
struct objcore *oc, struct req *req,
struct http *hd, intmax_t *cl)
{ {
struct zipflow_request *zfr; struct zipflow_request *zfr;
struct zipflow_top *zft; struct zipflow_top *zft;
struct req *req;
int r; int r;
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
(void) vdc; CHECK_OBJ_NOTNULL(vdc, VDP_CTX_MAGIC);
AN(vdc);
AN(priv); AN(priv);
(void) priv; CHECK_OBJ_ORNULL(oc, OBJCORE_MAGIC);
CHECK_OBJ_ORNULL(req, REQ_MAGIC);
CHECK_OBJ_NOTNULL(hd, HTTP_MAGIC);
AN(cl);
if (req == NULL) {
VSLb(vdc->vsl, SLT_Error,
"zipflow can only be used on the client side");
return (1);
}
CAST_OBJ_NOTNULL(zfr, *priv, ZIPFLOW_REQUEST_MAGIC); CAST_OBJ_NOTNULL(zfr, *priv, ZIPFLOW_REQUEST_MAGIC);
(void) oc;
zft = zipsub_take(zfr); zft = zipsub_take(zfr);
req = vdc->req;
CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
if (req->resp_len == 0) if (req->resp_len == 0)
zfr->bundle = 0; zfr->bundle = 0;
...@@ -656,25 +664,34 @@ vdp_zipsub_init(VRT_CTX, struct vdp_ctx *vdc, void **priv, struct objcore *oc) ...@@ -656,25 +664,34 @@ vdp_zipsub_init(VRT_CTX, struct vdp_ctx *vdc, void **priv, struct objcore *oc)
} }
static int static int
vdp_zipflow_init(VRT_CTX, struct vdp_ctx *vdc, void **priv, struct objcore *oc) vdp_zipflow_init(VRT_CTX, struct vdp_ctx *vdc, void **priv,
struct objcore *oc, struct req *req,
struct http *hd, intmax_t *cl)
{ {
struct zipflow_request *zfr = get_zipflow_request(ctx); struct zipflow_request *zfr;
struct zipflow_top *zft; struct zipflow_top *zft;
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
CHECK_OBJ_NOTNULL(vdc, VDP_CTX_MAGIC);
AN(priv);
CHECK_OBJ_ORNULL(oc, OBJCORE_MAGIC);
CHECK_OBJ_ORNULL(req, REQ_MAGIC);
CHECK_OBJ_NOTNULL(hd, HTTP_MAGIC);
AN(cl);
zfr = get_zipflow_request(ctx);
if (zfr == NULL) if (zfr == NULL)
return (1); return (1);
zft = zfr->top; zft = zfr->top;
CHECK_OBJ_NOTNULL(zft, ZIPFLOW_TOP_MAGIC); CHECK_OBJ_NOTNULL(zft, ZIPFLOW_TOP_MAGIC);
CHECK_OBJ_NOTNULL(vdc, VDP_CTX_MAGIC);
CHECK_OBJ_NOTNULL(vdc->req, REQ_MAGIC);
if (zft->req) { if (zft->req) {
VSLb(vdc->vsl, SLT_Error, "zipflow: can't be nested"); VSLb(vdc->vsl, SLT_Error, "zipflow: can't be nested");
return (-1); return (-1);
} }
if (vdc->req->resp_len == 0) { if (*cl == 0) {
VSLb(vdc->vsl, SLT_Error, "zipflow: need body bytes"); VSLb(vdc->vsl, SLT_Error, "zipflow: need body bytes");
return (-1); return (-1);
} }
...@@ -693,7 +710,7 @@ vdp_zipflow_init(VRT_CTX, struct vdp_ctx *vdc, void **priv, struct objcore *oc) ...@@ -693,7 +710,7 @@ vdp_zipflow_init(VRT_CTX, struct vdp_ctx *vdc, void **priv, struct objcore *oc)
} }
AZ(zft->req); AZ(zft->req);
zft->req = vdc->req; zft->req = req;
AZ(zft->zip); AZ(zft->zip);
zft->zip = zip_pipe(vdc, vdp_zipflow_put, zfr->level); zft->zip = zip_pipe(vdc, vdp_zipflow_put, zfr->level);
if (zft->zip == NULL) { if (zft->zip == NULL) {
...@@ -706,7 +723,7 @@ vdp_zipflow_init(VRT_CTX, struct vdp_ctx *vdc, void **priv, struct objcore *oc) ...@@ -706,7 +723,7 @@ vdp_zipflow_init(VRT_CTX, struct vdp_ctx *vdc, void **priv, struct objcore *oc)
AZ(*priv); AZ(*priv);
*priv = zfr; *priv = zfr;
return (vdp_zipsub_init(ctx, vdc, priv, oc)); return (vdp_zipsub_init(ctx, vdc, priv, oc, req, hd, cl));
} }
static void static void
...@@ -1009,7 +1026,8 @@ zfr_deliver(struct req *req, struct boc *boc, int wantbody) ...@@ -1009,7 +1026,8 @@ zfr_deliver(struct req *req, struct boc *boc, int wantbody)
INIT_OBJ(ctx, VRT_CTX_MAGIC); INIT_OBJ(ctx, VRT_CTX_MAGIC);
VCL_Req2Ctx(ctx, req); VCL_Req2Ctx(ctx, req);
i = VDP_Push(ctx, req->vdc, req->ws, vdp_zipsub, req->transport_priv); i = VDP_Push(ctx, req->vdc, req->ws, vdp_zipsub, req->transport_priv,
req->objcore, req, req->resp, &req->resp_len);
if (i == 0) { if (i == 0) {
i = VDP_DeliverObj(req->vdc, req->objcore); i = VDP_DeliverObj(req->vdc, req->objcore);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment