[4.1] 962fe5a Make std.syslog() work from vcl_{init,fini}
Lasse Karstensen
lkarsten at varnish-software.com
Tue Jun 14 11:46:10 CEST 2016
commit 962fe5acf7c813dbebddc9ce240a2aad5124c38e
Author: Federico G. Schwindt <fgsch at lodoss.net>
Date: Mon May 16 20:38:09 2016 +0100
Make std.syslog() work from vcl_{init,fini}
Related to #1924.
diff --git a/bin/varnishtest/tests/r01924.vtc b/bin/varnishtest/tests/r01924.vtc
index ed5095b..d553124 100644
--- a/bin/varnishtest/tests/r01924.vtc
+++ b/bin/varnishtest/tests/r01924.vtc
@@ -1,4 +1,4 @@
-varnishtest "Test std.log from vcl_{init,fini}"
+varnishtest "Test std.{log,syslog} from vcl_{init,fini}"
server s1 {
rxreq
@@ -10,10 +10,12 @@ varnish v1 -vcl+backend {
sub vcl_init {
std.log("init");
+ std.syslog(8 + 7, "init");
}
sub vcl_fini {
std.log("fini");
+ std.syslog(8 + 7, "fini");
}
} -start
diff --git a/configure.ac b/configure.ac
index f506ed5..d318408 100644
--- a/configure.ac
+++ b/configure.ac
@@ -243,6 +243,7 @@ AC_CHECK_FUNCS([nanosleep])
AC_CHECK_FUNCS([setppriv])
AC_CHECK_FUNCS([fallocate])
AC_CHECK_FUNCS([closefrom])
+AC_CHECK_FUNCS([vsyslog])
save_LIBS="${LIBS}"
LIBS="${PTHREAD_LIBS}"
diff --git a/lib/libvmod_std/vmod_std.c b/lib/libvmod_std/vmod_std.c
index c5cdfc1..6cd5b8a 100644
--- a/lib/libvmod_std/vmod_std.c
+++ b/lib/libvmod_std/vmod_std.c
@@ -163,14 +163,17 @@ vmod_syslog(VRT_CTX, VCL_INT fac, 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->ws != 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)
+ syslog((int)fac, "%s", t.b);
+ WS_Release(ctx->ws, 0);
+ } else
+ vsyslog((int)fac, fmt, ap);
va_end(ap);
- if (t.e != NULL)
- syslog((int)fac, "%s", t.b);
- WS_Release(ctx->ws, 0);
}
VCL_VOID __match_proto__(td_std_collect)
More information about the varnish-commit
mailing list