Commit 14a9cbc1 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp Committed by Lasse Karstensen

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
parent fcc5fe39
......@@ -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)
......
......@@ -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;
......
......@@ -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;
......
......@@ -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);
......
......@@ -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,
......
......@@ -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>
......@@ -329,6 +330,45 @@ tweak_bytes_u(struct vsb *vsb, const struct parspec *par, const char *arg)
return (0);
}
/*--------------------------------------------------------------------
* 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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment