Skip to content

Commit 0188b94

Browse files
committed
vrt_ctx: Make ctx->vsl not NULL in vcl_{init,fini}
This is a common source of panic when vmods functions/methods logging to vsl get called from housekeeping vcl subroutines. Refs #2998
1 parent 3e5b337 commit 0188b94

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

bin/varnishd/cache/cache_vcl.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,8 @@ VCL_Get_CliCtx(int msg)
136136
if (msg) {
137137
ctx_cli.msg = VSB_new_auto();
138138
AN(ctx_cli.msg);
139-
} else {
140-
ctx_cli.vsl = &vsl_cli;
141139
}
140+
ctx_cli.vsl = &vsl_cli;
142141
ctx_cli.ws = &ws_cli;
143142
WS_Assert(ctx_cli.ws);
144143
return (&ctx_cli);

bin/varnishd/cache/cache_vrt.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -683,12 +683,12 @@ VRT_fail(VRT_CTX, const char *fmt, ...)
683683
AN(fmt);
684684
AZ(strchr(fmt, '\n'));
685685
va_start(ap, fmt);
686-
if (ctx->vsl != NULL) {
687-
VSLbv(ctx->vsl, SLT_VCL_Error, fmt, ap);
688-
} else {
689-
AN(ctx->msg);
686+
if (ctx->msg != NULL) {
690687
VSB_vprintf(ctx->msg, fmt, ap);
691688
VSB_putc(ctx->msg, '\n');
689+
} else {
690+
AN(ctx->vsl);
691+
VSLbv(ctx->vsl, SLT_VCL_Error, fmt, ap);
692692
}
693693
va_end(ap);
694694
ctx->vpi->handling = VCL_RET_FAIL;

0 commit comments

Comments
 (0)