r2572 - in trunk/varnish-cache: bin/varnishlog include lib/libvarnishapi

des at projects.linpro.no des at projects.linpro.no
Sat Mar 8 17:55:22 CET 2008


Author: des
Date: 2008-03-08 17:55:22 +0100 (Sat, 08 Mar 2008)
New Revision: 2572

Modified:
   trunk/varnish-cache/bin/varnishlog/varnishlog.1
   trunk/varnish-cache/include/varnishapi.h
   trunk/varnish-cache/lib/libvarnishapi/shmlog.c
Log:
Add a -s option which specifies a number of entries to skip.


Modified: trunk/varnish-cache/bin/varnishlog/varnishlog.1
===================================================================
--- trunk/varnish-cache/bin/varnishlog/varnishlog.1	2008-03-08 15:43:28 UTC (rev 2571)
+++ trunk/varnish-cache/bin/varnishlog/varnishlog.1	2008-03-08 16:55:22 UTC (rev 2572)
@@ -28,7 +28,7 @@
 .\"
 .\" $Id$
 .\"
-.Dd November 8, 2007
+.Dd March 8, 2008
 .Dt VARNISHLOG 1
 .Os
 .Sh NAME
@@ -48,6 +48,7 @@
 .Op Fl o
 .Op Fl P Ar file
 .Op Fl r Ar file
+.Op Fl s Ar num
 .Op Fl V
 .Op Fl w Ar file
 .Op Fl X Ar regex
@@ -126,6 +127,10 @@
 Read log entries from
 .Ar file
 instead of shared memory.
+.It Fl s Ar num
+Skip the first
+.Ar num
+log records.
 .It Fl V
 Display the version number and exit.
 .It Fl w Ar file

Modified: trunk/varnish-cache/include/varnishapi.h
===================================================================
--- trunk/varnish-cache/include/varnishapi.h	2008-03-08 15:43:28 UTC (rev 2571)
+++ trunk/varnish-cache/include/varnishapi.h	2008-03-08 16:55:22 UTC (rev 2572)
@@ -44,8 +44,8 @@
 typedef int vsl_handler(void *priv, enum shmlogtag tag, unsigned fd, unsigned len, unsigned spec, const char *ptr);
 #define VSL_S_CLIENT	(1 << 0)
 #define VSL_S_BACKEND	(1 << 1)
-#define VSL_ARGS	"bCcdI:i:r:X:x:"
-#define VSL_USAGE	"[-bCcd] [-i tag] [-I regexp] [-r file] [-X regexp] [-x tag]"
+#define VSL_ARGS	"bCcdI:i:r:s:X:x:"
+#define VSL_USAGE	"[-bCcd] [-i tag] [-I regexp] [-r file] [-s skip] [-X regexp] [-x tag]"
 vsl_handler VSL_H_Print;
 struct VSL_data;
 struct VSL_data *VSL_New(void);

Modified: trunk/varnish-cache/lib/libvarnishapi/shmlog.c
===================================================================
--- trunk/varnish-cache/lib/libvarnishapi/shmlog.c	2008-03-08 15:43:28 UTC (rev 2571)
+++ trunk/varnish-cache/lib/libvarnishapi/shmlog.c	2008-03-08 16:55:22 UTC (rev 2572)
@@ -85,6 +85,8 @@
 	int			regflags;
 	regex_t			*regincl;
 	regex_t			*regexcl;
+
+	unsigned long		skip;
 };
 
 #ifndef MAP_HASSEMAPHORE
@@ -292,6 +294,10 @@
 		default:
 			break;
 		}
+		if (vd->skip) {
+			--vd->skip;
+			continue;
+		}
 		if (vd->map[p[SHMLOG_TAG]] & M_SELECT) {
 			*pp = p;
 			return (1);
@@ -478,6 +484,26 @@
 
 /*--------------------------------------------------------------------*/
 
+static int
+vsl_s_arg(struct VSL_data *vd, const char *opt)
+{
+	char *end;
+
+	CHECK_OBJ_NOTNULL(vd, VSL_MAGIC);
+	if (*opt == '\0') {
+		fprintf(stderr, "number required for -s\n");
+		return (-1);
+	}
+	vd->skip = strtoul(opt, &end, 10);
+	if (*end != '\0') {
+		fprintf(stderr, "invalid number for -s\n");
+		return (-1);
+	}
+	return (1);
+}
+
+/*--------------------------------------------------------------------*/
+
 int
 VSL_Arg(struct VSL_data *vd, int arg, const char *opt)
 {
@@ -491,6 +517,7 @@
 	case 'r': return (vsl_r_arg(vd, opt));
 	case 'I': case 'X': return (vsl_IX_arg(vd, opt, arg));
 	case 'C': vd->regflags = REG_ICASE; return (1);
+	case 's': return (vsl_s_arg(vd, opt));
 	default:
 		return (0);
 	}




More information about the varnish-commit mailing list