r3631 - branches/2.0/varnish-cache/bin/varnishd
tfheen at projects.linpro.no
tfheen at projects.linpro.no
Thu Feb 5 14:06:15 CET 2009
Author: tfheen
Date: 2009-02-05 14:06:15 +0100 (Thu, 05 Feb 2009)
New Revision: 3631
Modified:
branches/2.0/varnish-cache/bin/varnishd/heritage.h
branches/2.0/varnish-cache/bin/varnishd/mgt_param.c
branches/2.0/varnish-cache/bin/varnishd/shmlog.c
Log:
Merge r3428: Make the maximum record length in the shm log a paramter "shm_reclen".
Modified: branches/2.0/varnish-cache/bin/varnishd/heritage.h
===================================================================
--- branches/2.0/varnish-cache/bin/varnishd/heritage.h 2009-02-05 13:03:15 UTC (rev 3630)
+++ branches/2.0/varnish-cache/bin/varnishd/heritage.h 2009-02-05 13:06:15 UTC (rev 3631)
@@ -98,6 +98,8 @@
unsigned obj_workspace;
unsigned shm_workspace;
+ unsigned shm_reclen;
+
/* Acceptor hints */
unsigned sess_timeout;
unsigned pipe_timeout;
Modified: branches/2.0/varnish-cache/bin/varnishd/mgt_param.c
===================================================================
--- branches/2.0/varnish-cache/bin/varnishd/mgt_param.c 2009-02-05 13:03:15 UTC (rev 3630)
+++ branches/2.0/varnish-cache/bin/varnishd/mgt_param.c 2009-02-05 13:06:15 UTC (rev 3631)
@@ -636,6 +636,11 @@
"Minimum is 4096 bytes.",
DELAYED_EFFECT,
"8192", "bytes" },
+ { "shm_reclen", tweak_uint, &master.shm_reclen, 16, 65535,
+ "Maximum number of bytes in SHM log record.\n"
+ "Maximum is 65535 bytes.",
+ 0,
+ "255", "bytes" },
{ "default_grace", tweak_uint, &master.default_grace, 0, UINT_MAX,
"Default grace period. We will deliver an object "
"this long after it has expired, provided another thread "
Modified: branches/2.0/varnish-cache/bin/varnishd/shmlog.c
===================================================================
--- branches/2.0/varnish-cache/bin/varnishd/shmlog.c 2009-02-05 13:03:15 UTC (rev 3630)
+++ branches/2.0/varnish-cache/bin/varnishd/shmlog.c 2009-02-05 13:06:15 UTC (rev 3631)
@@ -81,6 +81,8 @@
vsl_hdr(enum shmlogtag tag, unsigned char *p, unsigned len, unsigned id)
{
+ assert(len < 0x10000);
+ assert(id < 0x10000);
p[__SHMLOG_LEN_HIGH] = (len >> 8) & 0xff;
p[__SHMLOG_LEN_LOW] = len & 0xff;
p[__SHMLOG_ID_HIGH] = (id >> 8) & 0xff;
@@ -100,14 +102,15 @@
VSLR(enum shmlogtag tag, int id, txt t)
{
unsigned char *p;
- unsigned l;
+ unsigned l, mlen;
Tcheck(t);
+ mlen = params->shm_reclen;
/* Truncate */
l = Tlen(t);
- if (l > 255) {
- l = 255;
+ if (l > mlen) {
+ l = mlen;
t.e = t.b + l;
}
@@ -136,11 +139,12 @@
{
va_list ap;
unsigned char *p;
- unsigned n;
+ unsigned n, mlen;
txt t;
AN(fmt);
va_start(ap, fmt);
+ mlen = params->shm_reclen;
if (strchr(fmt, '%') == NULL) {
t.b = TRUST_ME(fmt);
@@ -153,13 +157,14 @@
assert(loghead->ptr < loghead->size);
/* Wrap if we cannot fit a full size record */
- if (loghead->ptr + SHMLOG_NEXTTAG + 255 + 1 >= loghead->size)
+ if (loghead->ptr + SHMLOG_NEXTTAG + mlen + 1 >= loghead->size)
vsl_wrap();
p = logstart + loghead->ptr;
- n = vsnprintf((char *)(p + SHMLOG_DATA), 256, fmt, ap);
- if (n > 255)
- n = 255; /* we truncate long fields */
+ /* +1 for the NUL */
+ n = vsnprintf((char *)(p + SHMLOG_DATA), mlen + 1, fmt, ap);
+ if (n > mlen)
+ n = mlen; /* we truncate long fields */
vsl_hdr(tag, p, n, id);
loghead->ptr += SHMLOG_NEXTTAG + n;
assert(loghead->ptr < loghead->size);
@@ -203,14 +208,15 @@
WSLR(struct worker *w, enum shmlogtag tag, int id, txt t)
{
unsigned char *p;
- unsigned l;
+ unsigned l, mlen;
Tcheck(t);
+ mlen = params->shm_reclen;
/* Truncate */
l = Tlen(t);
- if (l > 255) {
- l = 255;
+ if (l > mlen) {
+ l = mlen;
t.e = t.b + l;
}
@@ -234,11 +240,12 @@
{
va_list ap;
unsigned char *p;
- unsigned n;
+ unsigned n, mlen;
txt t;
AN(fmt);
va_start(ap, fmt);
+ mlen = params->shm_reclen;
if (strchr(fmt, '%') == NULL) {
t.b = TRUST_ME(fmt);
@@ -248,13 +255,14 @@
assert(w->wlp < w->wle);
/* Wrap if we cannot fit a full size record */
- if (w->wlp + SHMLOG_NEXTTAG + 255 + 1 >= w->wle)
+ if (w->wlp + SHMLOG_NEXTTAG + mlen + 1 >= w->wle)
WSL_Flush(w, 1);
p = w->wlp;
- n = vsnprintf((char *)(p + SHMLOG_DATA), 256, fmt, ap);
- if (n > 255)
- n = 255; /* we truncate long fields */
+ /* +1 for the NUL */
+ n = vsnprintf((char *)(p + SHMLOG_DATA), mlen + 1, fmt, ap);
+ if (n > mlen)
+ n = mlen; /* we truncate long fields */
vsl_hdr(tag, p, n, id);
w->wlp += SHMLOG_NEXTTAG + n;
assert(w->wlp < w->wle);
More information about the varnish-commit
mailing list