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