Commit 3339706e authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Delaminate the VSL api from the VSM api



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@4940 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 1a0e526e
......@@ -322,6 +322,7 @@ main(int argc, char **argv)
struct VSM_data *vd;
vd = VSM_New();
VSL_Setup(vd);
while ((o = getopt(argc, argv, VSL_LOG_ARGS "Vw:")) != -1) {
switch (o) {
......@@ -338,7 +339,7 @@ main(int argc, char **argv)
}
}
if (VSM_OpenLog(vd))
if (VSL_Open(vd, 1))
exit(1);
log_ten = log(10.0);
......
......@@ -41,7 +41,6 @@ SVNID("$Id$")
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <limits.h>
#include "compat/daemon.h"
......@@ -80,7 +79,7 @@ static enum vsl_tag last[65536];
#define F_MATCH (1 << 1)
static int match_tag = -1;
static vre_t *match_re;
static const vre_t *match_re;
static void
h_order_finish(int fd)
......@@ -195,7 +194,7 @@ h_order(void *priv, enum vsl_tag tag, unsigned fd, unsigned len,
}
static void
do_order(struct VSM_data *vd, int argc, char * const *argv)
do_order(const struct VSM_data *vd, int argc, char * const *argv)
{
int i;
const char *error;
......@@ -268,7 +267,7 @@ open_log(const char *w_arg, int a_flag)
}
static void
do_write(struct VSM_data *vd, const char *w_arg, int a_flag)
do_write(const struct VSM_data *vd, const char *w_arg, int a_flag)
{
int fd, i, l;
uint32_t *p;
......@@ -282,7 +281,7 @@ do_write(struct VSM_data *vd, const char *w_arg, int a_flag)
break;
if (i > 0) {
l = VSL_LEN(p);
i = write(fd, p, 8 + VSL_WORDS(l) * 4);
i = write(fd, p, 8L + VSL_WORDS(l) * 4L);
if (i < 0) {
perror(w_arg);
exit(1);
......@@ -319,6 +318,7 @@ main(int argc, char * const *argv)
struct VSM_data *vd;
vd = VSM_New();
VSL_Setup(vd);
while ((c = getopt(argc, argv, VSL_LOG_ARGS "aDoP:uVw:")) != -1) {
switch (c) {
......@@ -361,7 +361,7 @@ main(int argc, char * const *argv)
if (o_flag && w_arg != NULL)
usage();
if (VSM_OpenLog(vd))
if (VSL_Open(vd, 1))
exit(1);
if (P_arg && (pfh = vpf_open(P_arg, 0644, NULL)) == NULL) {
......
......@@ -528,6 +528,7 @@ main(int argc, char *argv[])
FILE *of;
vd = VSM_New();
VSL_Setup(vd);
while ((c = getopt(argc, argv, VSL_LOG_ARGS "aDP:Vw:f")) != -1) {
switch (c) {
......@@ -565,7 +566,7 @@ main(int argc, char *argv[])
VSL_Log_Arg(vd, 'c', optarg);
if (VSM_OpenLog(vd))
if (VSL_Open(vd, 1))
exit(1);
if (P_arg && (pfh = vpf_open(P_arg, 0644, NULL)) == NULL) {
......
......@@ -721,6 +721,7 @@ main(int argc, char *argv[])
const char *address = NULL;
vd = VSM_New();
VSL_Setup(vd);
debug = 0;
VSL_Log_Arg(vd, 'c', NULL);
......@@ -743,7 +744,7 @@ main(int argc, char *argv[])
usage();
}
if (VSM_OpenLog(vd))
if (VSL_Open(vd, 1))
exit(1);
addr_info = init_connection(address);
......
......@@ -323,6 +323,7 @@ main(int argc, char **argv)
struct VSM_data *vd;
vd = VSM_New();
VSL_Setup(vd);
while ((o = getopt(argc, argv, VSL_LOG_ARGS "Vw:")) != -1) {
switch (o) {
......@@ -339,7 +340,7 @@ main(int argc, char **argv)
}
}
if (VSM_OpenLog(vd))
if (VSL_Open(vd, 1))
exit(1);
log_ten = log(10.0);
......
......@@ -308,6 +308,7 @@ main(int argc, char **argv)
int o, once = 0;
vd = VSM_New();
VSL_Setup(vd);
while ((o = getopt(argc, argv, VSL_LOG_ARGS "1fV")) != -1) {
switch (o) {
......@@ -328,7 +329,7 @@ main(int argc, char **argv)
}
}
if (VSM_OpenLog(vd))
if (VSL_Open(vd, 1))
exit (1);
if (once) {
......
......@@ -188,6 +188,21 @@ int VSC_Iter(const struct VSM_data *vd, vsc_iter_f *func, void *priv);
* VSL level access functions
*/
void VSL_Setup(struct VSM_data *vd);
/*
* Setup vd for use with VSL functions.
*/
int VSL_Open(struct VSM_data *vd, int diag);
/*
* Attempt to open and map the shared memory file.
* If diag is non-zero, diagnostics are emitted.
* Returns:
* 0 on success
* != 0 on failure
*/
typedef int vsl_handler(void *priv, enum vsl_tag tag, unsigned fd,
unsigned len, unsigned spec, const char *ptr);
#define VSL_S_CLIENT (1 << 0)
......@@ -199,10 +214,9 @@ typedef int vsl_handler(void *priv, enum vsl_tag tag, unsigned fd,
vsl_handler VSL_H_Print;
struct VSM_data;
void VSL_Select(const struct VSM_data *vd, unsigned tag);
int VSM_OpenLog(struct VSM_data *vd);
void VSL_NonBlocking(struct VSM_data *vd, int nb);
int VSL_Dispatch(struct VSM_data *vd, vsl_handler *func, void *priv);
int VSL_NextLog(struct VSM_data *lh, uint32_t **pp);
void VSL_NonBlocking(const struct VSM_data *vd, int nb);
int VSL_Dispatch(const struct VSM_data *vd, vsl_handler *func, void *priv);
int VSL_NextLog(const struct VSM_data *lh, uint32_t **pp);
int VSL_Log_Arg(struct VSM_data *vd, int arg, const char *opt);
extern const char *VSL_tags[256];
......
......@@ -7,7 +7,8 @@ lib_LTLIBRARIES = libvarnishapi.la
libvarnishapi_la_LDFLAGS = -version-info 1:0:0
libvarnishapi_la_SOURCES = \
vslapi.h \
vsm_api.h \
vsl_api.h \
\
../libvarnish/assert.c \
../libvarnish/argv.c \
......
......@@ -40,13 +40,12 @@ SVNID("$Id$")
#include "vas.h"
#include "vsm.h"
#include "vsc.h"
#include "vre.h"
#include "argv.h"
#include "vqueue.h"
#include "miniobj.h"
#include "varnishapi.h"
#include "vslapi.h"
#include "vsm_api.h"
struct vsc_sf {
unsigned magic;
......@@ -80,18 +79,23 @@ VSC_Setup(struct VSM_data *vd)
CHECK_OBJ_NOTNULL(vd, VSM_MAGIC);
AZ(vd->vsc);
// XXX: AZ(vd->vsm);
AZ(vd->vsl);
ALLOC_OBJ(vd->vsc, VSC_MAGIC);
AN(vd->vsc);
VTAILQ_INIT(&vd->vsc->sf_list);
}
/*--------------------------------------------------------------------*/
void
vsc_delete(const struct VSM_data *vd)
vsc_delete(struct VSM_data *vd)
{
struct vsc_sf *sf;
struct vsc *vsc = vd->vsc;
struct vsc *vsc;
CHECK_OBJ_NOTNULL(vd, VSM_MAGIC);
vsc = vd->vsc;
vd->vsc = NULL;
CHECK_OBJ_NOTNULL(vsc, VSC_MAGIC);
while(!VTAILQ_EMPTY(&vsc->sf_list)) {
sf = VTAILQ_FIRST(&vsc->sf_list);
......@@ -99,7 +103,7 @@ vsc_delete(const struct VSM_data *vd)
free(sf->class);
free(sf->ident);
free(sf->name);
free(sf);
FREE_OBJ(sf);
}
}
......
......@@ -45,15 +45,13 @@ SVNID("$Id$")
#include "vsl.h"
#include "vre.h"
#include "vbm.h"
#include "vqueue.h"
#include "miniobj.h"
#include "varnishapi.h"
#include "vslapi.h"
#include "vsm_api.h"
#include "vsl_api.h"
#include "vmb.h"
static int vsl_nextlog(struct VSM_data *vd, uint32_t **pp);
/*--------------------------------------------------------------------*/
const char *VSL_tags[256] = {
......@@ -64,73 +62,133 @@ const char *VSL_tags[256] = {
/*--------------------------------------------------------------------*/
void
VSL_Setup(struct VSM_data *vd)
{
struct vsl *vsl;
CHECK_OBJ_NOTNULL(vd, VSM_MAGIC);
AZ(vd->vsc);
AZ(vd->vsl);
ALLOC_OBJ(vsl, VSL_MAGIC);
AN(vsl);
vd->vsl = vsl;
vsl->regflags = 0;
/* XXX: Allocate only if log access */
vsl->vbm_client = vbit_init(4096);
vsl->vbm_backend = vbit_init(4096);
vsl->vbm_supress = vbit_init(256);
vsl->vbm_select = vbit_init(256);
vsl->r_fd = -1;
/* XXX: Allocate only if -r option given ? */
vsl->rbuflen = 256; /* XXX ?? */
vsl->rbuf = malloc(vsl->rbuflen * 4L);
assert(vsl->rbuf != NULL);
}
/*--------------------------------------------------------------------*/
void
vsl_delete(struct VSM_data *vd)
{
struct vsl *vsl;
CHECK_OBJ_NOTNULL(vd, VSM_MAGIC);
vsl = vd->vsl;
vd->vsl = NULL;
CHECK_OBJ_NOTNULL(vsl, VSL_MAGIC);
vbit_destroy(vsl->vbm_client);
vbit_destroy(vsl->vbm_backend);
vbit_destroy(vsl->vbm_supress);
vbit_destroy(vsl->vbm_select);
free(vsl->rbuf);
FREE_OBJ(vsl);
}
/*--------------------------------------------------------------------*/
void
VSL_Select(const struct VSM_data *vd, unsigned tag)
{
struct vsl *vsl;
CHECK_OBJ_NOTNULL(vd, VSM_MAGIC);
vbit_set(vd->vbm_select, tag);
vsl = vd->vsl;
CHECK_OBJ_NOTNULL(vsl, VSL_MAGIC);
vbit_set(vsl->vbm_select, tag);
}
/*--------------------------------------------------------------------*/
void
VSL_NonBlocking(struct VSM_data *vd, int nb)
VSL_NonBlocking(const struct VSM_data *vd, int nb)
{
struct vsl *vsl;
CHECK_OBJ_NOTNULL(vd, VSM_MAGIC);
vsl = vd->vsl;
CHECK_OBJ_NOTNULL(vsl, VSL_MAGIC);
if (nb)
vd->flags |= F_NON_BLOCKING;
vsl->flags |= F_NON_BLOCKING;
else
vd->flags &= ~F_NON_BLOCKING;
vsl->flags &= ~F_NON_BLOCKING;
}
/*--------------------------------------------------------------------*/
static int
vsl_nextlog(struct VSM_data *vd, uint32_t **pp)
vsl_nextlog(struct vsl *vsl, uint32_t **pp)
{
unsigned w, l;
uint32_t t;
int i;
CHECK_OBJ_NOTNULL(vd, VSM_MAGIC);
if (vd->r_fd != -1) {
assert(vd->rbuflen >= 8);
i = read(vd->r_fd, vd->rbuf, 8);
CHECK_OBJ_NOTNULL(vsl, VSL_MAGIC);
if (vsl->r_fd != -1) {
assert(vsl->rbuflen >= 8);
i = read(vsl->r_fd, vsl->rbuf, 8);
if (i != 8)
return (-1);
l = 2 + VSL_WORDS(VSL_LEN(vd->rbuf));
if (vd->rbuflen < l) {
l = 2 + VSL_WORDS(VSL_LEN(vsl->rbuf));
if (vsl->rbuflen < l) {
l += 256;
vd->rbuf = realloc(vd->rbuf, l * 4);
assert(vd->rbuf != NULL);
vd->rbuflen = l;
vsl->rbuf = realloc(vsl->rbuf, l * 4L);
assert(vsl->rbuf != NULL);
vsl->rbuflen = l;
}
i = read(vd->r_fd, vd->rbuf + 2, l * 4 - 8);
i = read(vsl->r_fd, vsl->rbuf + 2, l * 4L - 8L);
if (i != l)
return (-1);
*pp = vd->rbuf;
*pp = vsl->rbuf;
return (1);
}
for (w = 0; w < TIMEOUT_USEC;) {
t = *vd->log_ptr;
t = *vsl->log_ptr;
if (t == VSL_WRAPMARKER ||
(t == VSL_ENDMARKER && vd->last_seq != vd->log_start[0])) {
vd->log_ptr = vd->log_start + 1;
vd->last_seq = vd->log_start[0];
(t == VSL_ENDMARKER && vsl->last_seq != vsl->log_start[0])) {
vsl->log_ptr = vsl->log_start + 1;
vsl->last_seq = vsl->log_start[0];
VRMB();
continue;
}
if (t == VSL_ENDMARKER) {
if (vd->flags & F_NON_BLOCKING)
if (vsl->flags & F_NON_BLOCKING)
return (-1);
w += SLEEP_USEC;
AZ(usleep(SLEEP_USEC));
continue;
}
*pp = (void*)(uintptr_t)vd->log_ptr; /* Loose volatile */
vd->log_ptr = VSL_NEXT(vd->log_ptr);
*pp = (void*)(uintptr_t)vsl->log_ptr; /* Loose volatile */
vsl->log_ptr = VSL_NEXT(vsl->log_ptr);
return (1);
}
*pp = NULL;
......@@ -138,16 +196,20 @@ vsl_nextlog(struct VSM_data *vd, uint32_t **pp)
}
int
VSL_NextLog(struct VSM_data *vd, uint32_t **pp)
VSL_NextLog(const struct VSM_data *vd, uint32_t **pp)
{
struct vsl *vsl;
uint32_t *p;
unsigned char t;
unsigned u;
int i;
CHECK_OBJ_NOTNULL(vd, VSM_MAGIC);
vsl = vd->vsl;
CHECK_OBJ_NOTNULL(vsl, VSL_MAGIC);
while (1) {
i = vsl_nextlog(vd, &p);
i = vsl_nextlog(vsl, &p);
if (i != 1)
return (i);
u = VSL_ID(p);
......@@ -155,43 +217,43 @@ VSL_NextLog(struct VSM_data *vd, uint32_t **pp)
switch(t) {
case SLT_SessionOpen:
case SLT_ReqStart:
vbit_set(vd->vbm_client, u);
vbit_clr(vd->vbm_backend, u);
vbit_set(vsl->vbm_client, u);
vbit_clr(vsl->vbm_backend, u);
break;
case SLT_BackendOpen:
case SLT_BackendXID:
vbit_clr(vd->vbm_client, u);
vbit_set(vd->vbm_backend, u);
vbit_clr(vsl->vbm_client, u);
vbit_set(vsl->vbm_backend, u);
break;
default:
break;
}
if (vd->skip) {
--vd->skip;
if (vsl->skip) {
--vsl->skip;
continue;
} else if (vd->keep) {
if (--vd->keep == 0)
} else if (vsl->keep) {
if (--vsl->keep == 0)
return (-1);
}
if (vbit_test(vd->vbm_select, t)) {
if (vbit_test(vsl->vbm_select, t)) {
*pp = p;
return (1);
}
if (vbit_test(vd->vbm_supress, t))
if (vbit_test(vsl->vbm_supress, t))
continue;
if (vd->b_opt && !vbit_test(vd->vbm_backend, u))
if (vsl->b_opt && !vbit_test(vsl->vbm_backend, u))
continue;
if (vd->c_opt && !vbit_test(vd->vbm_client, u))
if (vsl->c_opt && !vbit_test(vsl->vbm_client, u))
continue;
if (vd->regincl != NULL) {
i = VRE_exec(vd->regincl, VSL_DATA(p), VSL_LEN(p),
if (vsl->regincl != NULL) {
i = VRE_exec(vsl->regincl, VSL_DATA(p), VSL_LEN(p),
0, 0, NULL, 0);
if (i == VRE_ERROR_NOMATCH)
continue;
}
if (vd->regexcl != NULL) {
i = VRE_exec(vd->regincl, VSL_DATA(p), VSL_LEN(p),
if (vsl->regexcl != NULL) {
i = VRE_exec(vsl->regincl, VSL_DATA(p), VSL_LEN(p),
0, 0, NULL, 0);
if (i != VRE_ERROR_NOMATCH)
continue;
......@@ -204,13 +266,17 @@ VSL_NextLog(struct VSM_data *vd, uint32_t **pp)
/*--------------------------------------------------------------------*/
int
VSL_Dispatch(struct VSM_data *vd, vsl_handler *func, void *priv)
VSL_Dispatch(const struct VSM_data *vd, vsl_handler *func, void *priv)
{
struct vsl *vsl;
int i;
unsigned u, l, s;
uint32_t *p;
CHECK_OBJ_NOTNULL(vd, VSM_MAGIC);
vsl = vd->vsl;
CHECK_OBJ_NOTNULL(vsl, VSL_MAGIC);
while (1) {
i = VSL_NextLog(vd, &p);
if (i != 1)
......@@ -218,9 +284,9 @@ VSL_Dispatch(struct VSM_data *vd, vsl_handler *func, void *priv)
u = VSL_ID(p);
l = VSL_LEN(p);
s = 0;
if (vbit_test(vd->vbm_backend, u))
if (vbit_test(vsl->vbm_backend, u))
s |= VSL_S_BACKEND;
if (vbit_test(vd->vbm_client, u))
if (vbit_test(vsl->vbm_client, u))
s |= VSL_S_CLIENT;
if (func(priv, VSL_TAG(p), u, l, s, VSL_DATA(p)))
return (1);
......@@ -260,23 +326,32 @@ VSL_H_Print(void *priv, enum vsl_tag tag, unsigned fd, unsigned len,
/*--------------------------------------------------------------------*/
int
VSM_OpenLog(struct VSM_data *vd)
VSL_Open(struct VSM_data *vd, int diag)
{
struct vsl *vsl;
struct vsm_chunk *sha;
int i;
CHECK_OBJ_NOTNULL(vd, VSM_MAGIC);
vsl = vd->vsl;
CHECK_OBJ_NOTNULL(vsl, VSL_MAGIC);
i = VSM_Open(vd, diag);
if (i)
return (i);
sha = vsm_find_alloc(vd, VSL_CLASS, "", "");
assert(sha != NULL);
vd->log_start = VSM_PTR(sha);
vd->log_end = VSM_NEXT(sha);
vd->log_ptr = vd->log_start + 1;
vsl->log_start = VSM_PTR(sha);
vsl->log_end = VSM_NEXT(sha);
vsl->log_ptr = vsl->log_start + 1;
vd->last_seq = vd->log_start[0];
vsl->last_seq = vsl->log_start[0];
VRMB();
if (!vd->d_opt && vd->r_fd == -1) {
while (*vd->log_ptr != VSL_ENDMARKER)
vd->log_ptr = VSL_NEXT(vd->log_ptr);
if (!vsl->d_opt && vsl->r_fd == -1) {
while (*vsl->log_ptr != VSL_ENDMARKER)
vsl->log_ptr = VSL_NEXT(vsl->log_ptr);
}
return (0);
}
......@@ -44,28 +44,27 @@ SVNID("$Id$")
#include <unistd.h>
#include "vas.h"
#include "argv.h"
#include "vin.h"
#include "vre.h"
#include "vbm.h"
#include "vqueue.h"
#include "miniobj.h"
#include "varnishapi.h"
#include "vslapi.h"
#include "vsm_api.h"
#include "vsl_api.h"
/*--------------------------------------------------------------------*/
static int
vsl_r_arg(struct VSM_data *vd, const char *opt)
vsl_r_arg(const struct VSM_data *vd, const char *opt)
{
CHECK_OBJ_NOTNULL(vd, VSM_MAGIC);
if (!strcmp(opt, "-"))
vd->r_fd = STDIN_FILENO;
vd->vsl->r_fd = STDIN_FILENO;
else
vd->r_fd = open(opt, O_RDONLY);
if (vd->r_fd < 0) {
vd->vsl->r_fd = open(opt, O_RDONLY);
if (vd->vsl->r_fd < 0) {
perror(opt);
return (-1);
}
......@@ -75,7 +74,7 @@ vsl_r_arg(struct VSM_data *vd, const char *opt)
/*--------------------------------------------------------------------*/
static int
vsl_IX_arg(struct VSM_data *vd, const char *opt, int arg)
vsl_IX_arg(const struct VSM_data *vd, const char *opt, int arg)
{
vre_t **rp;
const char *error;
......@@ -83,14 +82,14 @@ vsl_IX_arg(struct VSM_data *vd, const char *opt, int arg)
CHECK_OBJ_NOTNULL(vd, VSM_MAGIC);
if (arg == 'I')
rp = &vd->regincl;
rp = &vd->vsl->regincl;
else
rp = &vd->regexcl;
rp = &vd->vsl->regexcl;
if (*rp != NULL) {
fprintf(stderr, "Option %c can only be given once", arg);
return (-1);
}
*rp = VRE_compile(opt, vd->regflags, &error, &erroroffset);
*rp = VRE_compile(opt, vd->vsl->regflags, &error, &erroroffset);
if (*rp == NULL) {
fprintf(stderr, "Illegal regex: %s\n", error);
return (-1);
......@@ -101,17 +100,17 @@ vsl_IX_arg(struct VSM_data *vd, const char *opt, int arg)
/*--------------------------------------------------------------------*/
static int
vsl_ix_arg(struct VSM_data *vd, const char *opt, int arg)
vsl_ix_arg(const struct VSM_data *vd, const char *opt, int arg)
{
int i, j, l;
const char *b, *e, *p, *q;
CHECK_OBJ_NOTNULL(vd, VSM_MAGIC);
/* If first option is 'i', set all bits for supression */
if (arg == 'i' && !(vd->flags & F_SEEN_IX))
if (arg == 'i' && !(vd->vsl->flags & F_SEEN_IX))
for (i = 0; i < 256; i++)
vbit_set(vd->vbm_supress, i);
vd->flags |= F_SEEN_IX;
vbit_set(vd->vsl->vbm_supress, i);
vd->vsl->flags |= F_SEEN_IX;
for (b = opt; *b; b = e) {
while (isspace(*b))
......@@ -136,9 +135,9 @@ vsl_ix_arg(struct VSM_data *vd, const char *opt, int arg)
continue;
if (arg == 'x')
vbit_set(vd->vbm_supress, i);
vbit_set(vd->vsl->vbm_supress, i);
else
vbit_clr(vd->vbm_supress, i);
vbit_clr(vd->vsl->vbm_supress, i);
break;
}
if (i == 256) {
......@@ -153,7 +152,7 @@ vsl_ix_arg(struct VSM_data *vd, const char *opt, int arg)
/*--------------------------------------------------------------------*/
static int
vsl_s_arg(struct VSM_data *vd, const char *opt)
vsl_s_arg(const struct VSM_data *vd, const char *opt)
{
char *end;
......@@ -162,7 +161,7 @@ vsl_s_arg(struct VSM_data *vd, const char *opt)
fprintf(stderr, "number required for -s\n");
return (-1);
}
vd->skip = strtoul(opt, &end, 10);
vd->vsl->skip = strtoul(opt, &end, 10);
if (*end != '\0') {
fprintf(stderr, "invalid number for -s\n");
return (-1);
......@@ -173,7 +172,7 @@ vsl_s_arg(struct VSM_data *vd, const char *opt)
/*--------------------------------------------------------------------*/
static int
vsl_k_arg(struct VSM_data *vd, const char *opt)
vsl_k_arg(const struct VSM_data *vd, const char *opt)
{
char *end;
......@@ -182,7 +181,7 @@ vsl_k_arg(struct VSM_data *vd, const char *opt)
fprintf(stderr, "number required for -k\n");
return (-1);
}
vd->keep = strtoul(opt, &end, 10);
vd->vsl->keep = strtoul(opt, &end, 10);
if (*end != '\0') {
fprintf(stderr, "invalid number for -k\n");
return (-1);
......@@ -198,11 +197,11 @@ VSL_Log_Arg(struct VSM_data *vd, int arg, const char *opt)
CHECK_OBJ_NOTNULL(vd, VSM_MAGIC);
switch (arg) {
case 'b': vd->b_opt = !vd->b_opt; return (1);
case 'c': vd->c_opt = !vd->c_opt; return (1);
case 'b': vd->vsl->b_opt = !vd->vsl->b_opt; return (1);
case 'c': vd->vsl->c_opt = !vd->vsl->c_opt; return (1);
case 'd':
vd->d_opt = !vd->d_opt;
vd->flags |= F_NON_BLOCKING;
vd->vsl->d_opt = !vd->vsl->d_opt;
vd->vsl->flags |= F_NON_BLOCKING;
return (1);
case 'i': case 'x': return (vsl_ix_arg(vd, opt, arg));
case 'k': return (vsl_k_arg(vd, opt));
......@@ -210,15 +209,15 @@ VSL_Log_Arg(struct VSM_data *vd, int arg, const char *opt)
case 'r': return (vsl_r_arg(vd, opt));
case 's': return (vsl_s_arg(vd, opt));
case 'I': case 'X': return (vsl_IX_arg(vd, opt, arg));
case 'C': vd->regflags = VRE_CASELESS; return (1);
case 'C': vd->vsl->regflags = VRE_CASELESS; return (1);
case 'L':
vd->L_opt = strtoul(opt, NULL, 0);
if (vd->L_opt < 1024 || vd->L_opt > 65000) {
vd->vsl->L_opt = strtoul(opt, NULL, 0);
if (vd->vsl->L_opt < 1024 || vd->vsl->L_opt > 65000) {
fprintf(stderr, "%s\n", VIN_L_MSG);
exit (1);
}
free(vd->n_opt);
vd->n_opt = vin_L_arg(vd->L_opt);
vd->n_opt = vin_L_arg(vd->vsl->L_opt);
assert(vd->n_opt != NULL);
return (1);
default:
......
......@@ -46,12 +46,11 @@ SVNID("$Id$")
#include "vas.h"
#include "vin.h"
#include "vsm.h"
#include "vre.h"
#include "vbm.h"
#include "miniobj.h"
#include "varnishapi.h"
#include "vslapi.h"
#include "vsm_api.h"
#ifndef MAP_HASSEMAPHORE
#define MAP_HASSEMAPHORE 0 /* XXX Linux */
......@@ -72,20 +71,6 @@ VSM_New(void)
vd->vsl_fd = -1;
vd->regflags = 0;
/* XXX: Allocate only if log access */
vd->vbm_client = vbit_init(4096);
vd->vbm_backend = vbit_init(4096);
vd->vbm_supress = vbit_init(256);
vd->vbm_select = vbit_init(256);
vd->r_fd = -1;
/* XXX: Allocate only if -r option given ? */
vd->rbuflen = 256; /* XXX ?? */
vd->rbuf = malloc(vd->rbuflen * 4L);
assert(vd->rbuf != NULL);
CHECK_OBJ_NOTNULL(vd, VSM_MAGIC);
return (vd);
}
......@@ -138,16 +123,16 @@ VSM_Delete(struct VSM_data *vd)
{
CHECK_OBJ_NOTNULL(vd, VSM_MAGIC);
VSM_Close(vd);
vbit_destroy(vd->vbm_client);
vbit_destroy(vd->vbm_backend);
vbit_destroy(vd->vbm_supress);
vbit_destroy(vd->vbm_select);
free(vd->n_opt);
free(vd->rbuf);
free(vd->fname);
if (vd->vsc != NULL)
vsc_delete(vd);
if (vd->vsl != NULL)
vsl_delete(vd);
free(vd);
}
......
......@@ -56,56 +56,11 @@ struct VSM_data {
/* Stuff relating the stats fields start here */
struct vsc *vsc;
/* Stuff relating the log records below here */
volatile uint32_t *log_start;
volatile uint32_t *log_end;
volatile uint32_t *log_ptr;
volatile uint32_t last_seq;
/* for -r option */
int r_fd;
unsigned rbuflen;
uint32_t *rbuf;
unsigned L_opt;
int b_opt;
int c_opt;
int d_opt;
unsigned flags;
#define F_SEEN_IX (1 << 0)
#define F_NON_BLOCKING (1 << 1)
/*
* These two bitmaps mark fd's as belonging to client or backend
* transactions respectively.
*/
struct vbitmap *vbm_client;
struct vbitmap *vbm_backend;
/*
* Bit map of programatically selected tags, that cannot be suppressed.
* This way programs can make sure they will see certain tags, even
* if the user tries to supress them with -x/-X
*/
struct vbitmap *vbm_select; /* index: tag */
/* Bit map of tags selected/supressed with -[iIxX] options */
struct vbitmap *vbm_supress; /* index: tag */
int regflags;
vre_t *regincl;
vre_t *regexcl;
unsigned long skip;
unsigned long keep;
struct vsl *vsl;
};
struct vsm_chunk *vsm_find_alloc(const struct VSM_data *vd, const char *class,
const char *type, const char *ident);
void vsc_delete(const struct VSM_data *vd);
void vsc_delete(struct VSM_data *vd);
void vsl_delete(struct VSM_data *vd);
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