[master] 8f937e31f straighten cli ctx vs. temperature event
Nils Goroll
nils.goroll at uplex.de
Tue Jan 21 16:40:08 UTC 2020
commit 8f937e31f6c5e2abf0d65a9a539e9bb6c78de4f4
Author: Nils Goroll <nils.goroll at uplex.de>
Date: Tue Jan 21 16:29:18 2020 +0100
straighten cli ctx vs. temperature event
Our code was inconsistent with respect to the cli vrt_ctx.msg being set
for vcl temperature events.
This patch is intended as a temporary bandaid to at least make the code
consistent.
A proper solution is pending after clarification of the intent in #2902,
in particular wrt VCL_EVENT_COLD, which, by design, should not have a
ctx->msg, but does have one at the moment.
See #2902 for more details
diff --git a/bin/varnishd/cache/cache_vcl.c b/bin/varnishd/cache/cache_vcl.c
index 2bd3f1eeb..4a6a0605d 100644
--- a/bin/varnishd/cache/cache_vcl.c
+++ b/bin/varnishd/cache/cache_vcl.c
@@ -567,6 +567,9 @@ vcl_cancel_load(struct vrt_ctx *ctx, struct cli *cli,
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));
+ VCL_Rel_CliCtx(&ctx);
+ ctx = VCL_Get_CliCtx(0);
+ ctx->vcl = vcl;
ctx->method = VCL_MET_FINI;
AZ(vcl_send_event(ctx, VCL_EVENT_DISCARD));
ctx->method = 0;
@@ -641,20 +644,24 @@ VCL_Poll(void)
struct vcl *vcl, *vcl2;
ASSERT_CLI();
- ctx = VCL_Get_CliCtx(0);
VTAILQ_FOREACH_SAFE(vcl, &vcl_head, list, vcl2) {
if (vcl->temp == VCL_TEMP_BUSY ||
vcl->temp == VCL_TEMP_COOLING) {
+ // XXX #2902 : cold event to have msg ?
+ // move ctx into vcl_set_state() ?
+ ctx = VCL_Get_CliCtx(1);
ctx->vcl = vcl;
ctx->syntax = ctx->vcl->conf->syntax;
ctx->method = 0;
(void)vcl_set_state(ctx, "0");
+ VCL_Rel_CliCtx(&ctx);
}
if (vcl->discard && vcl->temp == VCL_TEMP_COLD) {
AZ(vcl->busy);
assert(vcl != vcl_active);
assert(VTAILQ_EMPTY(&vcl->ref_list));
VTAILQ_REMOVE(&vcl_head, vcl, list);
+ ctx = VCL_Get_CliCtx(0);
ctx->vcl = vcl;
ctx->syntax = ctx->vcl->conf->syntax;
ctx->method = VCL_MET_FINI;
@@ -665,9 +672,9 @@ VCL_Poll(void)
VCL_Close(&vcl);
VSC_C_main->n_vcl--;
VSC_C_main->n_vcl_discard--;
+ VCL_Rel_CliCtx(&ctx);
}
}
- VCL_Rel_CliCtx(&ctx);
}
/*--------------------------------------------------------------------*/
diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c
index d6d32ca0a..ef5a135cd 100644
--- a/bin/varnishd/cache/cache_vrt.c
+++ b/bin/varnishd/cache/cache_vrt.c
@@ -631,6 +631,7 @@ VRT_fail(VRT_CTX, const char *fmt, ...)
if (ctx->vsl != NULL) {
VSLbv(ctx->vsl, SLT_VCL_Error, fmt, ap);
} else {
+ AN(ctx->msg);
VSB_vprintf(ctx->msg, fmt, ap);
VSB_putc(ctx->msg, '\n');
}
More information about the varnish-commit
mailing list