Adapt to filter API changes

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