r422 - in trunk/varnish-cache: include lib/libvarnishapi
phk at projects.linpro.no
phk at projects.linpro.no
Tue Jul 11 13:36:14 CEST 2006
Author: phk
Date: 2006-07-11 13:36:14 +0200 (Tue, 11 Jul 2006)
New Revision: 422
Modified:
trunk/varnish-cache/include/varnishapi.h
trunk/varnish-cache/lib/libvarnishapi/shmlog.c
Log:
Add -b[ackend] and -c[lient] generic options to logtailers
Modified: trunk/varnish-cache/include/varnishapi.h
===================================================================
--- trunk/varnish-cache/include/varnishapi.h 2006-07-11 07:38:42 UTC (rev 421)
+++ trunk/varnish-cache/include/varnishapi.h 2006-07-11 11:36:14 UTC (rev 422)
@@ -8,7 +8,7 @@
#define V_DEAD __attribute__ ((noreturn))
/* shmlog.c */
-#define VSL_ARGS "r:i:x:CI:X:"
+#define VSL_ARGS "bcr:i:x:CI:X:"
struct VSL_data;
struct VSL_data *VSL_New(void);
int VSL_OpenLog(struct VSL_data *vd);
Modified: trunk/varnish-cache/lib/libvarnishapi/shmlog.c
===================================================================
--- trunk/varnish-cache/lib/libvarnishapi/shmlog.c 2006-07-11 07:38:42 UTC (rev 421)
+++ trunk/varnish-cache/lib/libvarnishapi/shmlog.c 2006-07-11 11:36:14 UTC (rev 422)
@@ -24,9 +24,14 @@
FILE *fi;
unsigned char rbuf[4 + 255 + 1];
+ int b_opt;
+ int c_opt;
+
int ix_opt;
unsigned char supr[256];
+ unsigned char dir[65536];
+
int regflags;
regex_t *regincl;
regex_t *regexcl;
@@ -39,6 +44,7 @@
static int vsl_fd;
static struct shmloghead *vsl_lh;
+
/*--------------------------------------------------------------------*/
const char *VSL_tags[256] = {
@@ -102,6 +108,9 @@
VSL_OpenLog(struct VSL_data *vd)
{
+ if (!vd->b_opt && !vd->c_opt)
+ vd->b_opt = vd->c_opt = 1;
+
if (vd->fi != NULL)
return (0);
@@ -155,14 +164,30 @@
{
unsigned char *p;
regmatch_t rm;
+ unsigned u;
int i;
while (1) {
p = vsl_nextlog(vd);
if (p == NULL)
return (p);
+ u = (p[2] << 8) | p[3];
+ switch(p[0]) {
+ case SLT_SessionOpen:
+ vd->dir[u] = 1;
+ break;
+ case SLT_BackendOpen:
+ vd->dir[u] = 2;
+ break;
+ default:
+ break;
+ }
if (vd->supr[p[0]])
continue;
+ if (vd->b_opt && vd->dir[u] == 1)
+ continue;
+ if (vd->c_opt && vd->dir[u] == 2)
+ continue;
if (vd->regincl != NULL) {
rm.rm_so = 0;
rm.rm_eo = p[1];
@@ -285,6 +310,8 @@
VSL_Arg(struct VSL_data *vd, int arg, const char *opt)
{
switch (arg) {
+ case 'b': vd->b_opt = !vd->b_opt; return (1);
+ case 'c': vd->c_opt = !vd->c_opt; return (1);
case 'i': case 'x': return (vsl_ix_arg(vd, opt, arg));
case 'r': return (vsl_r_arg(vd, opt));
case 'I': case 'X': return (vsl_IX_arg(vd, opt, arg));
More information about the varnish-commit
mailing list