Commit a1cb6511 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Fix my brainfart in PRIV_SESS and PRIV_REQ: We want one variable for

each VMOD which asks.

Patch by:	mithrandir
Fixes #1600
parent 0107b32f
......@@ -47,26 +47,29 @@ struct vrt_privs {
struct vmod_priv priv[1];
const struct VCL_conf *vcl;
uintptr_t id;
uintptr_t vmod_id;
};
/*--------------------------------------------------------------------
*/
static struct vmod_priv *
VRT_priv_dynamic(VRT_CTX, uintptr_t id)
VRT_priv_dynamic(VRT_CTX, uintptr_t id, uintptr_t vmod_id)
{
struct vrt_privs *vps;
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
VTAILQ_FOREACH(vps, &ctx->req->sp->privs, list) {
CHECK_OBJ_NOTNULL(vps, VRT_PRIVS_MAGIC);
if (vps->vcl == ctx->vcl && vps->id == id)
if (vps->vcl == ctx->vcl && vps->id == id
&& vps->vmod_id == vmod_id)
return (vps->priv);
}
ALLOC_OBJ(vps, VRT_PRIVS_MAGIC);
AN(vps);
vps->vcl = ctx->vcl;
vps->id = id;
vps->vmod_id = vmod_id;
VTAILQ_INSERT_TAIL(&ctx->req->sp->privs, vps, list);
return (vps->priv);
}
......@@ -91,15 +94,15 @@ VRTPRIV_dynamic_kill(struct sess *sp, uintptr_t id)
}
struct vmod_priv *
VRT_priv_req(VRT_CTX)
VRT_priv_req(VRT_CTX, void *vmod_id)
{
return (VRT_priv_dynamic(ctx, (uintptr_t)ctx->req));
return (VRT_priv_dynamic(ctx, (uintptr_t)ctx->req, (uintptr_t)vmod_id));
}
struct vmod_priv *
VRT_priv_sess(VRT_CTX)
VRT_priv_sess(VRT_CTX, void *vmod_id)
{
return (VRT_priv_dynamic(ctx, (uintptr_t)NULL));
return (VRT_priv_dynamic(ctx, (uintptr_t)NULL, (uintptr_t)vmod_id));
}
/*--------------------------------------------------------------------
......
......@@ -246,8 +246,8 @@ struct vmod_priv {
typedef int vmod_init_f(struct vmod_priv *, const struct VCL_conf *);
void VRT_priv_fini(const struct vmod_priv *p);
struct vmod_priv *VRT_priv_sess(VRT_CTX);
struct vmod_priv *VRT_priv_req(VRT_CTX);
struct vmod_priv *VRT_priv_sess(VRT_CTX, void *vmod_id);
struct vmod_priv *VRT_priv_req(VRT_CTX, void *vmod_id);
/* Stevedore related functions */
int VRT_Stv(const char *nm);
......
......@@ -567,10 +567,18 @@ vcc_func(struct vcc *tl, struct expr **e, const char *cfunc,
e2 = vcc_mk_expr(VOID, "&%s", buf);
p += strlen(p) + 1;
} else if (fmt == VOID && !strcmp(p, "PRIV_REQ")) {
e2 = vcc_mk_expr(VOID, "VRT_priv_req(ctx)");
r = strchr(name, '.');
AN(r);
e2 = vcc_mk_expr(VOID,
"VRT_priv_req(ctx, &VGC_vmod_%.*s)",
(int) (r - name), name);
p += strlen(p) + 1;
} else if (fmt == VOID && !strcmp(p, "PRIV_SESS")) {
e2 = vcc_mk_expr(VOID, "VRT_priv_sess(ctx)");
r = strchr(name, '.');
AN(r);
e2 = vcc_mk_expr(VOID,
"VRT_priv_sess(ctx, &VGC_vmod_%.*s)",
(int) (r - name), name);
p += strlen(p) + 1;
} else if (fmt == ENUM) {
ExpectErr(tl, ID);
......
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