[master] 27fd76a Don't use 8k stackbuffer, now that thread-stacks get smaller.

Poul-Henning Kamp phk at varnish-cache.org
Mon Feb 20 11:24:08 CET 2012


commit 27fd76aa7d9c613bb020da8d4a6e5ea5d808d9fc
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Feb 20 10:23:53 2012 +0000

    Don't use 8k stackbuffer, now that thread-stacks get smaller.

diff --git a/lib/libvmod_std/vmod_std.c b/lib/libvmod_std/vmod_std.c
index 4b9fd5f..a6f348b 100644
--- a/lib/libvmod_std/vmod_std.c
+++ b/lib/libvmod_std/vmod_std.c
@@ -145,28 +145,39 @@ vmod_random(struct sess *sp, double lo, double hi)
 void __match_proto__()
 vmod_log(struct sess *sp, const char *fmt, ...)
 {
-	char buf[8192], *p;
+	char *p;
+	unsigned u;
 	va_list ap;
+	txt t;
 
+	u = WS_Reserve(sp->req->ws, 0);
+	p = sp->req->ws->f;
 	va_start(ap, fmt);
-	p = VRT_StringList(buf, sizeof buf, fmt, ap);
+	p = VRT_StringList(p, u, fmt, ap);
 	va_end(ap);
-	if (p != NULL)
-		VSLb(sp->req->vsl, SLT_VCL_Log, "%s", buf);
+	if (p != NULL) {
+		t.b = p;
+		t.e = strchr(p, '\0');
+		VSLbt(sp->req->vsl, SLT_VCL_Log, t);
+	}
+	WS_Release(sp->req->ws, 0);
 }
 
 void
 vmod_syslog(struct sess *sp, int fac, const char *fmt, ...)
 {
-	char buf[8192], *p;
+	char *p;
+	unsigned u;
 	va_list ap;
 
-	(void)sp;
+	u = WS_Reserve(sp->req->ws, 0);
+	p = sp->req->ws->f;
 	va_start(ap, fmt);
-	p = VRT_StringList(buf, sizeof buf, fmt, ap);
+	p = VRT_StringList(p, u, fmt, ap);
 	va_end(ap);
 	if (p != NULL)
-		syslog(fac, "%s", buf);
+		syslog(fac, "%s", p);
+	WS_Release(sp->req->ws, 0);
 }
 
 const char * __match_proto__()



More information about the varnish-commit mailing list