[4.0] 14a9cbc Rename shm_reclen to vsl_reclen for consistency.

Lasse Karstensen lkarsten at varnish-software.com
Mon Sep 22 16:38:22 CEST 2014


commit 14a9cbc1eab47addf113b05375fb2013c85cf5eb
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Jul 28 07:57:33 2014 +0000

    Rename shm_reclen to vsl_reclen for consistency.
    
    Leave shm_reclen as a parameter alias for now.
    
    Parameter vsl_buffer must be 12 bytes larger than vsl_reclen in order
    to avoid a panic when we try to put 12 pounds of VSL into a 5 pound
    vsl_buffer sack.   Tweak the opposite parameter Minimum or Maximum value
    when we set one of of these parameters.
    
    Fixes #1547

diff --git a/bin/varnishd/cache/cache_shmlog.c b/bin/varnishd/cache/cache_shmlog.c
index d0733d7..7c364c1 100644
--- a/bin/varnishd/cache/cache_shmlog.c
+++ b/bin/varnishd/cache/cache_shmlog.c
@@ -179,7 +179,7 @@ vslr(enum VSL_tag_e tag, uint32_t vxid, const char *b, unsigned len)
 	uint32_t *p;
 	unsigned mlen;
 
-	mlen = cache_param->shm_reclen;
+	mlen = cache_param->vsl_reclen;
 
 	/* Truncate */
 	if (len > mlen)
@@ -209,7 +209,7 @@ void
 VSL(enum VSL_tag_e tag, uint32_t vxid, const char *fmt, ...)
 {
 	va_list ap;
-	unsigned n, mlen = cache_param->shm_reclen;
+	unsigned n, mlen = cache_param->vsl_reclen;
 	char buf[mlen];
 
 	AN(fmt);
@@ -267,7 +267,7 @@ VSLbt(struct vsl_log *vsl, enum VSL_tag_e tag, txt t)
 	Tcheck(t);
 	if (vsl_tag_is_masked(tag))
 		return;
-	mlen = cache_param->shm_reclen;
+	mlen = cache_param->vsl_reclen;
 
 	/* Truncate */
 	l = Tlen(t);
@@ -321,7 +321,7 @@ VSLbv(struct vsl_log *vsl, enum VSL_tag_e tag, const char *fmt, va_list ap)
 		return;
 	}
 
-	mlen = cache_param->shm_reclen;
+	mlen = cache_param->vsl_reclen;
 
 	/* Flush if we cannot fit a full size record */
 	if (VSL_END(vsl->wlp, mlen + 1) >= vsl->wle)
diff --git a/bin/varnishd/common/params.h b/bin/varnishd/common/params.h
index 7e208af..35c0a7a 100644
--- a/bin/varnishd/common/params.h
+++ b/bin/varnishd/common/params.h
@@ -103,7 +103,7 @@ struct params {
 	unsigned		http_resp_hdr_len;
 	unsigned		http_max_hdr;
 
-	unsigned		shm_reclen;
+	unsigned		vsl_reclen;
 
 	double			timeout_linger;
 	double			timeout_idle;
diff --git a/bin/varnishd/mgt/mgt_param.c b/bin/varnishd/mgt/mgt_param.c
index b5aec87..e8a1763 100644
--- a/bin/varnishd/mgt/mgt_param.c
+++ b/bin/varnishd/mgt/mgt_param.c
@@ -484,6 +484,7 @@ MCF_SetMinimum(const char *param, const char *new_min)
 {
 	struct parspec *pp;
 
+	AN(new_min);
 	pp = mcf_findpar(param);
 	AN(pp);
 	pp->min = new_min;
@@ -495,6 +496,7 @@ MCF_SetMaximum(const char *param, const char *new_max)
 {
 	struct parspec *pp;
 
+	AN(new_max);
 	pp = mcf_findpar(param);
 	AN(pp);
 	pp->max = new_max;
diff --git a/bin/varnishd/mgt/mgt_param.h b/bin/varnishd/mgt/mgt_param.h
index 3263537..f60180b 100644
--- a/bin/varnishd/mgt/mgt_param.h
+++ b/bin/varnishd/mgt/mgt_param.h
@@ -63,6 +63,8 @@ tweak_t tweak_timeout;
 tweak_t tweak_uint;
 tweak_t tweak_user;
 tweak_t tweak_waiter;
+tweak_t tweak_vsl_buffer;
+tweak_t tweak_vsl_reclen;
 
 int tweak_generic_uint(struct vsb *vsb, volatile unsigned *dest,
     const char *arg, const char *min, const char *max);
diff --git a/bin/varnishd/mgt/mgt_param_tbl.c b/bin/varnishd/mgt/mgt_param_tbl.c
index a338e34..37d9a66 100644
--- a/bin/varnishd/mgt/mgt_param_tbl.c
+++ b/bin/varnishd/mgt/mgt_param_tbl.c
@@ -160,23 +160,27 @@ struct parspec mgt_parspec[] = {
 		0,
 		"64", "header lines" },
 	{ "vsl_buffer",
-		tweak_bytes_u, &mgt_param.vsl_buffer,
+		tweak_vsl_buffer, &mgt_param.vsl_buffer,
 		"1024", NULL,
 		"Bytes of (req-/backend-)workspace dedicated to buffering"
 		" VSL records.\n"
-		"At a bare minimum, this must be longer than"
-		" the longest HTTP header to be logged.\n"
 		"Setting this too high costs memory, setting it too low"
 		" will cause more VSL flushes and likely increase"
-		" lock-contention on the VSL mutex.\n"
-		"Minimum is 1k bytes.",
+		" lock-contention on the VSL mutex.\n\n"
+		"The minimum tracks the vsl_reclen parameter + 12 bytes.",
 		0,
 		"4k", "bytes" },
+	{ "vsl_reclen",
+		tweak_vsl_reclen, &mgt_param.vsl_reclen,
+		"16", "65535",
+		"Maximum number of bytes in SHM log record.\n\n"
+		"The maximum tracks the vsl_buffer parameter - 12 bytes.",
+		0,
+		"255", "bytes" },
 	{ "shm_reclen",
-		tweak_bytes_u, &mgt_param.shm_reclen,
+		tweak_vsl_reclen, &mgt_param.vsl_reclen,
 		"16", "65535",
-		"Maximum number of bytes in SHM log record.\n"
-		"Maximum is 65535 bytes.",
+		"Old name for vsl_reclen, use that instead.",
 		0,
 		"255", "bytes" },
 	{ "timeout_idle", tweak_timeout, &mgt_param.timeout_idle,
diff --git a/bin/varnishd/mgt/mgt_param_tweak.c b/bin/varnishd/mgt/mgt_param_tweak.c
index 4e2645f..7d9fb4f 100644
--- a/bin/varnishd/mgt/mgt_param_tweak.c
+++ b/bin/varnishd/mgt/mgt_param_tweak.c
@@ -36,6 +36,7 @@
 #include <limits.h>
 #include <math.h>
 #include <pwd.h>
+#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
@@ -330,6 +331,45 @@ tweak_bytes_u(struct vsb *vsb, const struct parspec *par, const char *arg)
 }
 
 /*--------------------------------------------------------------------
+ * vsl_buffer and vsl_reclen have dependencies.
+ */
+
+int
+tweak_vsl_buffer(struct vsb *vsb, const struct parspec *par, const char *arg)
+{
+	volatile unsigned *d1;
+	volatile ssize_t dest;
+	char buf[20];
+
+	d1 = par->priv;
+	dest = *d1;
+	if (tweak_generic_bytes(vsb, &dest, arg, par->min, par->max))
+		return (-1);
+	*d1 = dest;
+	bprintf(buf, "%u", *d1 - 12);
+	MCF_SetMaximum("vsl_reclen", strdup(buf));
+	MCF_SetMaximum("shm_reclen", strdup(buf));
+	return (0);
+}
+
+int
+tweak_vsl_reclen(struct vsb *vsb, const struct parspec *par, const char *arg)
+{
+	volatile unsigned *d1;
+	volatile ssize_t dest;
+	char buf[20];
+
+	d1 = par->priv;
+	dest = *d1;
+	if (tweak_generic_bytes(vsb, &dest, arg, par->min, par->max))
+		return (-1);
+	*d1 = dest;
+	bprintf(buf, "%u", *d1 + 12);
+	MCF_SetMinimum("vsl_buffer", strdup(buf));
+	return (0);
+}
+
+/*--------------------------------------------------------------------
  * XXX: slightly magic.  We want to initialize to "nobody" (XXX: shouldn't
  * XXX: that be something autocrap found for us ?) but we don't want to
  * XXX: fail initialization if that user doesn't exists, even though we



More information about the varnish-commit mailing list