[master] dad7f7d Make std.log() work from vcl_{init,fini}
Federico G. Schwindt
fgsch at lodoss.net
Mon May 16 19:46:06 CEST 2016
commit dad7f7d810e918658049e48f91cdfc2c391ec07a
Author: Federico G. Schwindt <fgsch at lodoss.net>
Date: Mon May 16 18:40:11 2016 +0100
Make std.log() work from vcl_{init,fini}
Fixes #1924.
diff --git a/bin/varnishtest/tests/r01924.vtc b/bin/varnishtest/tests/r01924.vtc
new file mode 100644
index 0000000..ed5095b
--- /dev/null
+++ b/bin/varnishtest/tests/r01924.vtc
@@ -0,0 +1,22 @@
+varnishtest "Test std.log from vcl_{init,fini}"
+
+server s1 {
+ rxreq
+ txresp
+} -start
+
+varnish v1 -vcl+backend {
+ import std;
+
+ sub vcl_init {
+ std.log("init");
+ }
+
+ sub vcl_fini {
+ std.log("fini");
+ }
+} -start
+
+varnish v1 -vcl+backend { }
+
+varnish v1 -cliok "vcl.discard vcl1"
diff --git a/lib/libvmod_std/vmod_std.c b/lib/libvmod_std/vmod_std.c
index 1a8f56b..4522147 100644
--- a/lib/libvmod_std/vmod_std.c
+++ b/lib/libvmod_std/vmod_std.c
@@ -139,17 +139,20 @@ vmod_log(VRT_CTX, const char *fmt, ...)
txt t;
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
- u = WS_Reserve(ctx->ws, 0);
- t.b = ctx->ws->f;
va_start(ap, fmt);
- t.e = VRT_StringList(ctx->ws->f, u, fmt, ap);
+ if (ctx->vsl != NULL) {
+ u = WS_Reserve(ctx->ws, 0);
+ t.b = ctx->ws->f;
+ t.e = VRT_StringList(ctx->ws->f, u, fmt, ap);
+ if (t.e != NULL) {
+ assert(t.e > t.b);
+ t.e--;
+ VSLbt(ctx->vsl, SLT_VCL_Log, t);
+ }
+ WS_Release(ctx->ws, 0);
+ } else
+ VSLv(SLT_VCL_Log, 0, fmt, ap);
va_end(ap);
- if (t.e != NULL) {
- assert(t.e > t.b);
- t.e--;
- VSLbt(ctx->vsl, SLT_VCL_Log, t);
- }
- WS_Release(ctx->ws, 0);
}
VCL_VOID __match_proto__(td_std_syslog)
More information about the varnish-commit
mailing list