Commit 21c215fa authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Always initialize ctx->handling to zero, and try to avoid setting

it more than once.
parent 7347e93a
......@@ -107,6 +107,7 @@ vcl_get_ctx(unsigned method, int msg)
{
AZ(ctx_cli.handling);
INIT_OBJ(&ctx_cli, VRT_CTX_MAGIC);
handling_cli = 0;
ctx_cli.handling = &handling_cli;
ctx_cli.method = method;
if (msg) {
......@@ -148,6 +149,7 @@ vcl_send_event(VRT_CTX, enum vcl_event_e ev)
ev == VCL_EVENT_COLD ||
ev == VCL_EVENT_DISCARD);
AN(ctx->handling);
*ctx->handling = 0;
AN(ctx->ws);
if (ev == VCL_EVENT_LOAD || ev == VCL_EVENT_WARM)
......@@ -713,6 +715,7 @@ vcl_cancel_load(VRT_CTX, struct cli *cli, const char *name, const char *step)
VCLI_Out(cli, "VCL \"%s\" Failed %s", name, step);
if (VSB_len(ctx->msg))
VCLI_Out(cli, "\nMessage:\n\t%s", VSB_data(ctx->msg));
*ctx->handling = 0;
AZ(vcl->conf->event_vcl(ctx, VCL_EVENT_DISCARD));
vcl_KillBackends(vcl);
VCL_Close(&vcl);
......@@ -753,6 +756,7 @@ vcl_load(struct cli *cli, struct vrt_ctx *ctx,
vcl_cancel_load(ctx, cli, name, "initialization");
return;
}
assert(*ctx->handling == VCL_RET_OK);
VSB_clear(ctx->msg);
i = vcl_set_state(ctx, state);
if (i) {
......@@ -761,7 +765,6 @@ vcl_load(struct cli *cli, struct vrt_ctx *ctx,
return;
}
bprintf(vcl->state, "%s", state + 1);
assert(*ctx->handling == VCL_RET_OK);
VCLI_Out(cli, "Loaded \"%s\" as \"%s\"", fn , name);
VTAILQ_INSERT_TAIL(&vcl_head, vcl, list);
Lck_Lock(&vcl_mtx);
......@@ -1041,9 +1044,9 @@ vcl_call_method(struct worker *wrk, struct req *req, struct busyobj *bo,
ctx.vsl = vsl;
ctx.specific = specific;
ctx.method = method;
wrk->handling = 0;
ctx.handling = &wrk->handling;
aws = WS_Snapshot(wrk->aws);
wrk->handling = 0;
wrk->cur_method = method;
wrk->seen_methods |= method;
AN(vsl);
......
......@@ -252,7 +252,9 @@ VRT_handling(VRT_CTX, unsigned hand)
{
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
assert(hand > 0);
assert(hand < VCL_RET_MAX);
// XXX:NOTYET assert(*ctx->handling == 0);
*ctx->handling = hand;
}
......
varnishtest "Check -f command line arg"
server s1 {
rxreq
expect req.url == "/foo"
......
......@@ -311,6 +311,8 @@ EmitInitFini(const struct vcc *tl)
}
Fc(tl, 0, "\t(void)VGC_function_vcl_init(ctx);\n");
Fc(tl, 0, "\tif (*ctx->handling == 0)\n");
Fc(tl, 0, "\t\tVRT_handling(ctx, VCL_RET_OK);\n");
Fc(tl, 0, "\treturn (*ctx->handling == VCL_RET_OK ? 0: -1);\n");
Fc(tl, 0, "}\n");
......@@ -655,8 +657,6 @@ vcc_CompileSource(struct vcc *tl, struct source *sp)
* in members called from vcl_init, so set OK up front
* and return with whatever was set last.
*/
if (method_tab[i].bitval == VCL_MET_INIT)
Fc(tl, 1, " VRT_handling(ctx, VCL_RET_OK);\n");
Fc(tl, 1, "%s", VSB_data(tl->fm[i]));
if (method_tab[i].bitval == VCL_MET_INIT)
Fc(tl, 1, " return (1);\n");
......
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