Commit 12fa49fa authored by Nils Goroll's avatar Nils Goroll

rework the vcl flags interface, some cleanup of vdp_pesi_init

we now get the flags from vcl once when we init the pesi vdp
parent e5ef7bf0
......@@ -344,7 +344,7 @@ static void fini_subreq(struct req *, struct node *);
static void fini_data(struct req *, struct node *);
/* id for PRIV_TASK */
const void * const priv_task_id_serial = &priv_task_id_serial;
const void * const priv_task_id_cfg = &priv_task_id_cfg;
/* shared object globals */
static unsigned loadcnt = 0, warmcnt = 0;
......@@ -1119,21 +1119,6 @@ req_fini(struct req **reqp, struct worker *wrk)
Req_Release(req);
}
static int
want_serial(struct req *preq)
{
struct vmod_priv *vclserial;
struct vrt_ctx dummy_ctx[1];
INIT_OBJ(dummy_ctx, VRT_CTX_MAGIC);
dummy_ctx->req = preq;
dummy_ctx->ws = preq->ws;
vclserial = VRT_priv_task(dummy_ctx, priv_task_id_serial);
return (vclserial != NULL && vclserial->priv == (void *)PF_CFG_SERIAL);
}
static int
vped_include(struct req *preq, const char *src, const char *host,
struct pesi *pesi, struct node *node)
......@@ -1256,7 +1241,7 @@ vped_include(struct req *preq, const char *src, const char *host,
VSLdbgv(preq, "ved_include: attempt new thread req=%p", req);
if ((pesi->flags & PF_CFG_BLOCK_FINAL) == 0) {
if (want_serial(preq)) {
if (pesi->flags & PF_CFG_SERIAL) {
ved_task(wrk, req);
return (0);
}
......@@ -2156,6 +2141,30 @@ push_vdps(struct req *req, struct nexus_gzip *gz)
return (0);
}
static void
vcl_cfg(struct req *req, 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);
if (priv_task == NULL || priv_task->len == 0)
return;
assert(priv_task->len == 1);
AZ(priv_task->free);
vclflags = (unsigned)(uintptr_t)priv_task->priv;
AZ(vclflags & ~PF_MASK_CFG);
*flags = (*flags & ~PF_MASK_CFG) | vclflags;
}
static int v_matchproto_(vdp_init_f)
vdp_pesi_init(struct req *req, void **priv)
{
......@@ -2165,33 +2174,18 @@ vdp_pesi_init(struct req *req, void **priv)
CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
AN(priv);
AZ(*priv);
if (!ObjHasAttr(req->wrk, req->objcore, OA_ESIDATA))
return (1);
if (req->esi_level > 0) {
if (*priv != NULL) {
CHECK_OBJ((struct pesi *)*priv, PESI_MAGIC);
assert(*priv == req->transport_priv);
WS_Assert_Allocated(req->ws, *priv,
sizeof(struct pesi));
return (0);
}
CAST_OBJ_NOTNULL(pesi, req->transport_priv, PESI_MAGIC);
*priv = pesi;
if (VALID_OBJ((struct pesi *)req->transport_priv, PESI_MAGIC)) {
WS_Assert_Allocated(req->ws, req->transport_priv,
sizeof(struct pesi));
*priv = req->transport_priv;
/* XXX debugging */
struct vdp_entry *vdpe;
CHECK_OBJ_NOTNULL(req->vdc, VDP_CTX_MAGIC);
VTAILQ_FOREACH(vdpe, &req->vdc->vdp, list) {
CHECK_OBJ_NOTNULL(vdpe, VDP_ENTRY_MAGIC);
VSLdbgv(req, "vdp_pesi_init: VDP list: %s",
vdpe->vdp->name);
}
return (0);
}
WS_Assert_Allocated(req->ws, pesi, sizeof *pesi);
vcl_cfg(req, &pesi->flags);
return (0);
}
AZ(req->esi_level);
......@@ -2223,6 +2217,7 @@ vdp_pesi_init(struct req *req, void **priv)
"Cannot allocate workspace for parallel ESI data");
return (-1);
}
vcl_cfg(req, &pesi->flags);
pecx = pesi->pecx;
*priv = pesi;
RFC2616_Weaken_Etag(req->resp);
......@@ -2974,7 +2969,8 @@ vmod_activate(VRT_CTX)
VCL_VOID
vmod_serial(VRT_CTX, VCL_BOOL b)
{
struct vmod_priv *task;
struct vmod_priv *priv_task;
unsigned vclflags;
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
......@@ -2984,16 +2980,31 @@ vmod_serial(VRT_CTX, VCL_BOOL b)
return;
}
task = VRT_priv_task(ctx, priv_task_id_serial);
priv_task = VRT_priv_task(ctx, priv_task_id_cfg);
if (task == NULL) {
if (priv_task == NULL) {
VRT_fail(ctx, "no priv_task");
return;
}
/* for now, just put the flags in the priv */
assert(sizeof task->priv >= sizeof(unsigned));
task->priv = b ? (void *)PF_CFG_SERIAL : (void *)0;
assert(sizeof priv_task->priv >= sizeof(unsigned));
if (priv_task->len == 0) {
vclflags = PF_CFG_DEFAULT;
priv_task->len = 1;
}
else {
vclflags = (unsigned)(uintptr_t)priv_task->priv;
assert(priv_task->len == 1);
}
AZ(vclflags & ~PF_MASK_CFG);
vclflags &= ~PF_CFG_SERIAL;
if (b)
vclflags |= PF_CFG_SERIAL;
priv_task->priv = (void *)(uintptr_t)vclflags;
}
/* Event function */
......
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