[master] 9bba6622d centralize setting ctx->syntax

Nils Goroll nils.goroll at uplex.de
Thu Feb 13 09:29:06 UTC 2020


commit 9bba6622d9f4e056c72cc0c80fea57ea744d0d0b
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Thu Feb 13 10:01:36 2020 +0100

    centralize setting ctx->syntax
    
    ... and ensure it always gets set during cli operations also

diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c
index 2e1f6a69f..c1c11e6a1 100644
--- a/bin/varnishd/cache/cache_vcl.c
+++ b/bin/varnishd/cache/cache_vcl.c
@@ -83,6 +83,7 @@ VCL_Bo2Ctx(struct vrt_ctx *ctx, struct busyobj *bo)
 	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
 	CHECK_OBJ_NOTNULL(bo->wrk, WORKER_MAGIC);
 	ctx->vcl = bo->vcl;
+	ctx->syntax = ctx->vcl->conf->syntax;
 	ctx->vsl = bo->vsl;
 	ctx->http_bereq = bo->bereq;
 	ctx->http_beresp = bo->beresp;
@@ -102,6 +103,7 @@ VCL_Req2Ctx(struct vrt_ctx *ctx, struct req *req)
 	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
 
 	ctx->vcl = req->vcl;
+	ctx->syntax = ctx->vcl->conf->syntax;
 	ctx->vsl = req->vsl;
 	ctx->http_req = req->http;
 	CHECK_OBJ_NOTNULL(req->top, REQTOP_MAGIC);
@@ -586,6 +588,7 @@ vcl_cancel_load(struct vrt_ctx *ctx, struct cli *cli,
 	ctx = VCL_Get_CliCtx(0);
 	ctx->vcl = vcl;
 	ctx->method = VCL_MET_FINI;
+	ctx->syntax = ctx->vcl->conf->syntax;
 	AZ(vcl_send_event(ctx, VCL_EVENT_DISCARD));
 	ctx->method = 0;
 	vcl_KillBackends(vcl);
@@ -623,6 +626,7 @@ vcl_load(struct cli *cli, struct vrt_ctx *ctx,
 	vcl->temp = VCL_TEMP_INIT;
 
 	ctx->vcl = vcl;
+	ctx->syntax = ctx->vcl->conf->syntax;
 
 	VSB_clear(ctx->msg);
 	ctx->method = VCL_MET_INIT;
@@ -801,6 +805,7 @@ vcl_cli_state(struct cli *cli, const char * const *av, void *priv)
 	ctx = VCL_Get_CliCtx(1);
 	ctx->vcl = vcl_find(av[2]);
 	AN(ctx->vcl);
+	ctx->syntax = ctx->vcl->conf->syntax;
 	if (vcl_set_state(ctx, av[3])) {
 		AZ(VSB_finish(ctx->msg));
 		VCLI_SetResult(cli, CLIS_CANT);
diff --git a/bin/varnishd/cache/cache_vrt_vcl.c b/bin/varnishd/cache/cache_vrt_vcl.c
index 2d7b39a36..eda1fe3db 100644
--- a/bin/varnishd/cache/cache_vrt_vcl.c
+++ b/bin/varnishd/cache/cache_vrt_vcl.c
@@ -442,7 +442,6 @@ vcl_call_method(struct worker *wrk, struct req *req, struct busyobj *bo,
 		VCL_Bo2Ctx(&ctx, bo);
 	}
 	assert(ctx.now != 0);
-	ctx.syntax = ctx.vcl->conf->syntax;
 	ctx.specific = specific;
 	ctx.method = method;
 	aws = WS_Snapshot(wrk->aws);


More information about the varnish-commit mailing list