Commit 62c75f7d authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Start registering VDPs

parent 3f533abb
...@@ -130,3 +130,5 @@ struct vdp_ctx { ...@@ -130,3 +130,5 @@ struct vdp_ctx {
int VDP_bytes(struct req *, enum vdp_action act, const void *ptr, ssize_t len); int VDP_bytes(struct req *, enum vdp_action act, const void *ptr, ssize_t len);
int VDP_push(struct req *, const struct vdp *, void *priv, int bottom); int VDP_push(struct req *, const struct vdp *, void *priv, int bottom);
void VRT_AddVDP(VRT_CTX, const struct vdp *);
void VRT_RemoveVDP(VRT_CTX, const struct vdp *);
...@@ -408,6 +408,8 @@ VCL_Close(struct vcl **vclp) ...@@ -408,6 +408,8 @@ VCL_Close(struct vcl **vclp)
CHECK_OBJ_NOTNULL(*vclp, VCL_MAGIC); CHECK_OBJ_NOTNULL(*vclp, VCL_MAGIC);
vcl = *vclp; vcl = *vclp;
*vclp = NULL; *vclp = NULL;
assert(VTAILQ_EMPTY(&vcl->vfps));
assert(VTAILQ_EMPTY(&vcl->vdps));
AZ(dlclose(vcl->dlh)); AZ(dlclose(vcl->dlh));
AZ(errno=pthread_rwlock_destroy(&vcl->temp_rwl)); AZ(errno=pthread_rwlock_destroy(&vcl->temp_rwl));
FREE_OBJ(vcl); FREE_OBJ(vcl);
...@@ -565,6 +567,7 @@ vcl_load(struct cli *cli, struct vrt_ctx *ctx, ...@@ -565,6 +567,7 @@ vcl_load(struct cli *cli, struct vrt_ctx *ctx,
VTAILQ_INIT(&vcl->director_list); VTAILQ_INIT(&vcl->director_list);
VTAILQ_INIT(&vcl->ref_list); VTAILQ_INIT(&vcl->ref_list);
VTAILQ_INIT(&vcl->vfps); VTAILQ_INIT(&vcl->vfps);
VTAILQ_INIT(&vcl->vdps);
vcl->temp = VCL_TEMP_INIT; vcl->temp = VCL_TEMP_INIT;
......
...@@ -31,9 +31,9 @@ ...@@ -31,9 +31,9 @@
* *
*/ */
struct vfp_filter; struct vfilter;
VTAILQ_HEAD(vfp_filter_head, vfp_filter); VTAILQ_HEAD(vfilter_head, vfilter);
struct vcl { struct vcl {
...@@ -53,7 +53,8 @@ struct vcl { ...@@ -53,7 +53,8 @@ struct vcl {
int nrefs; int nrefs;
struct vcl *label; struct vcl *label;
int nlabels; int nlabels;
struct vfp_filter_head vfps; struct vfilter_head vfps;
struct vfilter_head vdps;
}; };
struct vclref { struct vclref {
......
...@@ -46,49 +46,103 @@ ...@@ -46,49 +46,103 @@
/*-------------------------------------------------------------------- /*--------------------------------------------------------------------
*/ */
struct vfp_filter { struct vfilter {
unsigned magic; unsigned magic;
#define VFP_FILTER_MAGIC 0xd40894e9 #define VFILTER_MAGIC 0xd40894e9
const struct vfp *filter; const struct vfp *vfp;
const struct vdp *vdp;
const char *name;
int nlen; int nlen;
VTAILQ_ENTRY(vfp_filter) list; VTAILQ_ENTRY(vfilter) list;
}; };
static struct vfp_filter_head vfp_filters = static struct vfilter_head vfp_filters =
VTAILQ_HEAD_INITIALIZER(vfp_filters); VTAILQ_HEAD_INITIALIZER(vfp_filters);
static struct vfilter_head vdp_filters =
VTAILQ_HEAD_INITIALIZER(vdp_filters);
void void
VRT_AddVFP(VRT_CTX, const struct vfp *filter) VRT_AddVFP(VRT_CTX, const struct vfp *filter)
{ {
struct vfp_filter *vp; struct vfilter *vp;
struct vfp_filter_head *hd = &vfp_filters; struct vfilter_head *hd = &vfp_filters;
CHECK_OBJ_ORNULL(ctx, VRT_CTX_MAGIC);
VTAILQ_FOREACH(vp, hd, list) { VTAILQ_FOREACH(vp, hd, list) {
xxxassert(vp->filter != filter); xxxassert(vp->vfp != filter);
xxxassert(strcasecmp(vp->filter->name, filter->name)); xxxassert(strcasecmp(vp->name, filter->name));
} }
if (ctx != NULL) { if (ctx != NULL) {
ASSERT_CLI();
hd = &ctx->vcl->vfps; hd = &ctx->vcl->vfps;
VTAILQ_FOREACH(vp, hd, list) { VTAILQ_FOREACH(vp, hd, list) {
xxxassert(vp->filter != filter); xxxassert(vp->vfp != filter);
xxxassert(strcasecmp(vp->filter->name, filter->name)); xxxassert(strcasecmp(vp->name, filter->name));
}
}
ALLOC_OBJ(vp, VFILTER_MAGIC);
AN(vp);
vp->vfp = filter;
vp->name = filter->name;
vp->nlen = strlen(vp->name);
VTAILQ_INSERT_TAIL(hd, vp, list);
}
void
VRT_AddVDP(VRT_CTX, const struct vdp *filter)
{
struct vfilter *vp;
struct vfilter_head *hd = &vdp_filters;
CHECK_OBJ_ORNULL(ctx, VRT_CTX_MAGIC);
VTAILQ_FOREACH(vp, hd, list) {
xxxassert(vp->vdp != filter);
xxxassert(strcasecmp(vp->name, filter->name));
}
if (ctx != NULL) {
ASSERT_CLI();
hd = &ctx->vcl->vdps;
VTAILQ_FOREACH(vp, hd, list) {
xxxassert(vp->vdp != filter);
xxxassert(strcasecmp(vp->name, filter->name));
} }
} }
ALLOC_OBJ(vp, VFP_FILTER_MAGIC); ALLOC_OBJ(vp, VFILTER_MAGIC);
AN(vp); AN(vp);
vp->filter = filter; vp->vdp = filter;
vp->nlen = strlen(filter->name); vp->name = filter->name;
vp->nlen = strlen(vp->name);
VTAILQ_INSERT_TAIL(hd, vp, list); VTAILQ_INSERT_TAIL(hd, vp, list);
} }
void void
VRT_RemoveVFP(VRT_CTX, const struct vfp *filter) VRT_RemoveVFP(VRT_CTX, const struct vfp *filter)
{ {
struct vfp_filter *vp; struct vfilter *vp;
struct vfp_filter_head *hd = &ctx->vcl->vfps; struct vfilter_head *hd = &ctx->vcl->vfps;
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
ASSERT_CLI();
VTAILQ_FOREACH(vp, hd, list) {
if (vp->vfp == filter)
break;
}
XXXAN(vp);
VTAILQ_REMOVE(hd, vp, list);
FREE_OBJ(vp);
}
void
VRT_RemoveVDP(VRT_CTX, const struct vdp *filter)
{
struct vfilter *vp;
struct vfilter_head *hd = &ctx->vcl->vdps;
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
ASSERT_CLI();
VTAILQ_FOREACH(vp, hd, list) { VTAILQ_FOREACH(vp, hd, list) {
if (vp->filter == filter) if (vp->vdp == filter)
break; break;
} }
XXXAN(vp); XXXAN(vp);
...@@ -100,7 +154,7 @@ int ...@@ -100,7 +154,7 @@ int
VCL_StackVFP(struct vfp_ctx *vc, const struct vcl *vcl, const char *fl) VCL_StackVFP(struct vfp_ctx *vc, const struct vcl *vcl, const char *fl)
{ {
const char *p, *q; const char *p, *q;
const struct vfp_filter *vp; const struct vfilter *vp;
VSLb(vc->wrk->vsl, SLT_Filters, "%s", fl); VSLb(vc->wrk->vsl, SLT_Filters, "%s", fl);
...@@ -115,21 +169,21 @@ VCL_StackVFP(struct vfp_ctx *vc, const struct vcl *vcl, const char *fl) ...@@ -115,21 +169,21 @@ VCL_StackVFP(struct vfp_ctx *vc, const struct vcl *vcl, const char *fl)
VTAILQ_FOREACH(vp, &vfp_filters, list) { VTAILQ_FOREACH(vp, &vfp_filters, list) {
if (vp->nlen != q - p) if (vp->nlen != q - p)
continue; continue;
if (!memcmp(p, vp->filter->name, vp->nlen)) if (!memcmp(p, vp->name, vp->nlen))
break; break;
} }
if (vp == NULL) { if (vp == NULL) {
VTAILQ_FOREACH(vp, &vcl->vfps, list) { VTAILQ_FOREACH(vp, &vcl->vfps, list) {
if (vp->nlen != q - p) if (vp->nlen != q - p)
continue; continue;
if (!memcmp(p, vp->filter->name, vp->nlen)) if (!memcmp(p, vp->name, vp->nlen))
break; break;
} }
} }
if (vp == NULL) if (vp == NULL)
return (VFP_Error(vc, return (VFP_Error(vc,
"Filter '%.*s' not found", (int)(q-p), p)); "Filter '%.*s' not found", (int)(q-p), p));
if (VFP_Push(vc, vp->filter) == NULL) if (VFP_Push(vc, vp->vfp) == NULL)
return (-1); return (-1);
} }
return (0); return (0);
...@@ -143,6 +197,8 @@ VCL_VRT_Init(void) ...@@ -143,6 +197,8 @@ VCL_VRT_Init(void)
VRT_AddVFP(NULL, &VFP_gzip); VRT_AddVFP(NULL, &VFP_gzip);
VRT_AddVFP(NULL, &VFP_esi); VRT_AddVFP(NULL, &VFP_esi);
VRT_AddVFP(NULL, &VFP_esi_gzip); VRT_AddVFP(NULL, &VFP_esi_gzip);
VRT_AddVDP(NULL, &VDP_esi);
VRT_AddVDP(NULL, &VDP_gunzip);
} }
/*-------------------------------------------------------------------- /*--------------------------------------------------------------------
......
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