Commit c5320314 authored by Geoff Simmons's avatar Geoff Simmons

varnishevent: added config params max_vcl_log and max_vcl_call

parent e07523f6
......@@ -116,6 +116,8 @@ CONF_Add(const char *lval, const char *rval)
confUnsigned("max.reclen", max_reclen);
confUnsigned("max.headers", max_headers);
confUnsigned("max.vcl_log", max_vcl_log);
confUnsigned("max.vcl_call", max_vcl_call);
confUnsigned("max.fd", max_fd);
confUnsigned("max.data", max_data);
confUnsigned("monitor.interval", monitor_interval);
......@@ -191,6 +193,8 @@ CONF_Init(void)
config.max_reclen = DEFAULT_MAX_RECLEN;
config.max_headers = DEFAULT_MAX_HEADERS;
config.max_vcl_log = DEFAULT_MAX_HEADERS;
config.max_vcl_call = DEFAULT_MAX_HEADERS;
config.max_fd = DEFAULT_MAX_FD;
config.max_data = DEFAULT_MAX_DATA;
config.housekeep_interval = DEFAULT_HOUSEKEEP_INTERVAL;
......
......@@ -77,16 +77,16 @@ DATA_Clear_Logline(logline_t *ll)
ll->tag[i].len = 0;
}
#define INIT_HDR_RECORDS(tag, hdr) do { \
#define INIT_HDR_RECORDS(tag, hdr, max) do { \
if (FMT_Read_Hdr(tag)) { \
hdr = (hdr_t *) malloc(sizeof(hdr_t)); \
if (hdr == NULL) \
return errno; \
hdr->record \
= (record_t *) calloc(config.max_headers, sizeof(record_t)); \
= (record_t *) calloc(max, sizeof(record_t)); \
if (hdr->record == NULL) \
return errno; \
for (int j = 0; j < config.max_headers; j++) { \
for (int j = 0; j < max; j++) { \
hdr->record[j].magic = RECORD_MAGIC; \
hdr->record[j].data = &bufptr[bufidx++ * config.max_reclen]; \
} \
......@@ -110,9 +110,9 @@ DATA_Init(void)
if (FMT_Read_Hdr(SLT_TxHeader))
nrecords += config.max_data * config.max_headers;
if (FMT_Read_Hdr(SLT_VCL_Log))
nrecords += config.max_data * config.max_headers;
nrecords += config.max_data * config.max_vcl_log;
if (FMT_Read_Hdr(SLT_VCL_call))
nrecords += config.max_data * config.max_headers;
nrecords += config.max_data * config.max_vcl_call;
LOG_Log(LOG_DEBUG, "Allocating space for %d records (%d bytes)", nrecords,
nrecords * config.max_reclen);
......@@ -135,10 +135,13 @@ DATA_Init(void)
logline[i].tag[j].data = &bufptr[bufidx++ * config.max_reclen];
}
INIT_HDR_RECORDS(SLT_RxHeader, logline[i].rx_headers);
INIT_HDR_RECORDS(SLT_TxHeader, logline[i].tx_headers);
INIT_HDR_RECORDS(SLT_VCL_Log, logline[i].vcl_log);
INIT_HDR_RECORDS(SLT_VCL_call, logline[i].vcl_call);
INIT_HDR_RECORDS(SLT_RxHeader, logline[i].rx_headers,
config.max_headers);
INIT_HDR_RECORDS(SLT_TxHeader, logline[i].tx_headers,
config.max_headers);
INIT_HDR_RECORDS(SLT_VCL_Log, logline[i].vcl_log, config.max_vcl_log);
INIT_HDR_RECORDS(SLT_VCL_call, logline[i].vcl_call,
config.max_vcl_call);
logline[i].magic = LOGLINE_MAGIC;
DATA_Clear_Logline(&logline[i]);
......
......@@ -264,6 +264,7 @@ collect(struct logline_t *lp, enum VSL_tag_e tag, unsigned spec,
{
hdr_t *hdr = NULL;
record_t *rec = NULL;
unsigned *max;
switch (tag) {
case SLT_BackendReuse:
......@@ -325,22 +326,31 @@ collect(struct logline_t *lp, enum VSL_tag_e tag, unsigned spec,
len = config.max_reclen;
}
if (tag == SLT_RxHeader)
if (tag == SLT_RxHeader) {
hdr = lp->rx_headers;
else if (tag == SLT_TxHeader)
max = &config.max_headers;
}
else if (tag == SLT_TxHeader) {
hdr = lp->tx_headers;
else if (tag == SLT_VCL_Log)
max = &config.max_headers;
}
else if (tag == SLT_VCL_Log) {
hdr = lp->vcl_log;
else if (tag == SLT_VCL_call)
max = &config.max_vcl_log;
}
else if (tag == SLT_VCL_call) {
hdr = lp->vcl_call;
max = &config.max_vcl_call;
}
if (hdr != NULL) {
if (hdr->nrec < config.max_headers)
if (hdr->nrec < *max)
rec = &hdr->record[hdr->nrec++];
else {
LOG_Log(LOG_ALERT,
"Number of headers exceeds max %u, DATA DISCARDED: %s [%.*s]",
config.max_headers, VSL_tags[tag], len, ptr);
"Number of records for %s exceeds max %u, "
"DATA DISCARDED: [%.*s]",
VSL_tags[tag], *max, len, ptr);
hdr_overflows++;
return;
}
......
......@@ -159,6 +159,9 @@ struct config {
/* varnishd param http_max_hdr */
unsigned max_headers;
unsigned max_vcl_log;
unsigned max_vcl_call;
unsigned max_fd;
unsigned max_data;
......
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