Adapt to filter API changes

parent 43e61e17
......@@ -139,13 +139,14 @@ const struct vdp vped_pretend_gz = {
*/
static int v_matchproto_(vdp_fini_f)
vped_gzgz_init(struct vdp_ctx *vdc, void **priv, struct objcore *oc)
vped_gzgz_init(VRT_CTX, struct vdp_ctx *vdc, void **priv, struct objcore *oc)
{
struct req *req;
ssize_t l;
const char *p;
struct vped_gzgz_priv *foo;
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
CHECK_OBJ_NOTNULL(vdc, VDP_CTX_MAGIC);
(void)oc;
req = vdc->req;
......
......@@ -484,11 +484,12 @@ vped_include(struct req *preq, const char *src, const char *host,
*/
static int v_matchproto_(vdp_init_f)
pesi_buf_init(struct vdp_ctx *vdc, void **priv, struct objcore *oc)
pesi_buf_init(VRT_CTX, struct vdp_ctx *vdc, void **priv, struct objcore *oc)
{
struct req *req;
struct pesi *pesi;
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
CHECK_OBJ_NOTNULL(vdc, VDP_CTX_MAGIC);
req = vdc->req;
CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
......@@ -682,7 +683,7 @@ vdp_pesi_init(VRT_CTX, struct vdp_ctx *vdc, void **priv, struct objcore *oc)
assert(WS_Allocated(req->ws, pesi, sizeof *pesi));
node_fill_nodestock(req->ws, &pesi->nodestock);
get_task_cfg(req, &pesi->flags);
get_task_cfg(ctx, &pesi->flags);
#ifdef DEBUG_PESI_WS
pesi->ws_snap = WS_Snapshot(req->ws);
#endif
......@@ -719,7 +720,7 @@ vdp_pesi_init(VRT_CTX, struct vdp_ctx *vdc, void **priv, struct objcore *oc)
"Cannot allocate workspace for parallel ESI data");
return (-1);
}
get_task_cfg(req, &pesi->flags);
get_task_cfg(ctx, &pesi->flags);
pecx = pesi->pecx;
*priv = pesi;
......@@ -1276,6 +1277,7 @@ vped_deliver(struct req *req, struct boc *boc, int wantbody)
struct node *node, *parent;
struct nexus_gzip *gz;
struct vped_gzgz_priv *vgzgz = NULL;
struct vrt_ctx ctx[1];
const struct vdp *vdp;
VSLdbgv(req, "vped_deliver: req=%p boc=%p wantbody=%d", req, boc,
......@@ -1312,6 +1314,9 @@ vped_deliver(struct req *req, struct boc *boc, int wantbody)
gz = &parent->nexus.gzip;
INIT_OBJ(ctx, VRT_CTX_MAGIC);
VCL_Req2Ctx(ctx, req);
if (gz->is && obj_gzipped && !(req->res_mode & RES_ESI)) {
/* OA_GZIPBITS are not valid until BOS_FINISHED */
if (boc != NULL)
......@@ -1350,9 +1355,10 @@ vped_deliver(struct req *req, struct boc *boc, int wantbody)
AZ(vgzgz);
// VDP_pesi + buf has been pushed from VCL
push_vdps(req, vgzgz, gz);
push_vdps(ctx, req, vgzgz, gz);
AN(parent);
AZ(VDP_Push(req->vdc, req->ws, &vped_to_parent, parent->nexus.req));
AZ(VDP_Push(ctx, req->vdc, req->ws,
&vped_to_parent, parent->nexus.req));
(void)VDP_DeliverObj(req->vdc, req->objcore);
......@@ -1367,11 +1373,12 @@ vped_deliver(struct req *req, struct boc *boc, int wantbody)
else if (obj_final && (pesi->flags & PF_CFG_BLOCK_FINAL) == 0) {
VSLdbg(req, "vped_deliver: T_NEXUS buffering no ESI");
AZ(VDP_Push(req->vdc, req->ws, &VDP_pesi_buf, pesi));
AZ(VDP_Push(ctx, req->vdc, req->ws, &VDP_pesi_buf, pesi));
AN(parent);
assert(parent->type == T_NEXUS);
push_vdps(req, vgzgz, gz);
AZ(VDP_Push(req->vdc, req->ws, &vped_to_parent, parent->nexus.req));
push_vdps(ctx, req, vgzgz, gz);
AZ(VDP_Push(ctx, req->vdc, req->ws,
&vped_to_parent, parent->nexus.req));
(void)VDP_DeliverObj(req->vdc, req->objcore);
......@@ -1389,8 +1396,9 @@ vped_deliver(struct req *req, struct boc *boc, int wantbody)
else if (obj_final) {
VSLdbg(req, "vped_deliver: T_FINAL");
push_vdps(req, vgzgz, gz);
AZ(VDP_Push(req->vdc, req->ws, &vped_to_parent, parent->nexus.req));
push_vdps(ctx, req, vgzgz, gz);
AZ(VDP_Push(ctx, req->vdc, req->ws,
&vped_to_parent, parent->nexus.req));
node_mutate_prep(tree, node);
......@@ -1428,8 +1436,9 @@ vped_deliver(struct req *req, struct boc *boc, int wantbody)
VSLdbg(req, "vped_deliver: T_SUBREQ");
AZ(req->objcore->flags & OC_F_FINAL);
push_vdps(req, vgzgz, gz);
AZ(VDP_Push(req->vdc, req->ws, &vped_to_parent, parent->nexus.req));
push_vdps(ctx, req, vgzgz, gz);
AZ(VDP_Push(ctx, req->vdc, req->ws,
&vped_to_parent, parent->nexus.req));
node_mutate_prep(tree, node);
......
......@@ -36,4 +36,4 @@ extern const struct vdp VDP_pesi;
* task config
*/
void get_task_cfg(struct req *, unsigned *);
void get_task_cfg(VRT_CTX, unsigned *);
......@@ -256,18 +256,13 @@ WRONG("illegal enum");
/* VDP's access to the cfg */
void
get_task_cfg(struct req *req, unsigned *flags)
get_task_cfg(VRT_CTX, unsigned *flags)
{
struct vmod_priv *priv_task;
struct vrt_ctx dummy_ctx[1];
unsigned vclflags;
INIT_OBJ(dummy_ctx, VRT_CTX_MAGIC);
dummy_ctx->req = req;
dummy_ctx->ws = req->ws;
/* zero length in the priv task == not configured from vcl */
priv_task = VRT_priv_task(dummy_ctx, priv_task_id_cfg);
priv_task = VRT_priv_task(ctx, priv_task_id_cfg);
if (priv_task == NULL || priv_task->len == 0)
return;
......@@ -349,6 +344,9 @@ vmod_event(VRT_CTX, struct vmod_priv *priv, enum vcl_event_e e)
switch (e) {
case VCL_EVENT_LOAD:
if (VRT_AddFilter(ctx, NULL, &VDP_pesi))
return (1);
if (loadcnt++ == 0) {
AZ(vsc_seg);
lck_bytes_tree = Lck_CreateClass(&vsc_seg, "pesi.buf");
......@@ -363,10 +361,9 @@ vmod_event(VRT_CTX, struct vmod_priv *priv, enum vcl_event_e e)
Lck_New(&stats_lock, lck_stats);
}
VRT_AddVDP(ctx, &VDP_pesi);
break;
case VCL_EVENT_DISCARD:
VRT_RemoveVDP(ctx, &VDP_pesi);
VRT_RemoveFilter(ctx, NULL, &VDP_pesi);
AN(loadcnt);
if (--loadcnt == 0) {
......
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