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