r4776 - in trunk/varnish-cache: include lib/libvarnish lib/libvarnishapi

phk at varnish-cache.org phk at varnish-cache.org
Thu May 6 11:10:36 CEST 2010


Author: phk
Date: 2010-05-06 11:10:36 +0200 (Thu, 06 May 2010)
New Revision: 4776

Modified:
   trunk/varnish-cache/include/shmlog.h
   trunk/varnish-cache/include/varnishapi.h
   trunk/varnish-cache/lib/libvarnish/vin.c
   trunk/varnish-cache/lib/libvarnishapi/shmlog.c
Log:
Implement the -L(earn) option in all the log/stats tools via libvarnishapi



Modified: trunk/varnish-cache/include/shmlog.h
===================================================================
--- trunk/varnish-cache/include/shmlog.h	2010-05-06 09:00:15 UTC (rev 4775)
+++ trunk/varnish-cache/include/shmlog.h	2010-05-06 09:10:36 UTC (rev 4776)
@@ -111,5 +111,9 @@
 
 /* This function lives in both libvarnish and libvarnishapi */
 int vin_n_arg(const char *n_arg, char **name, char **dir, char **vsl);
+char *vin_L_arg(unsigned L_arg);
+#define VIN_L_LOW	1024
+#define VIN_L_HIGH	65000
+#define VIN_L_OK(a)	(a >= VIN_L_LOW && a <= VIN_L_HIGH)
 
 #endif

Modified: trunk/varnish-cache/include/varnishapi.h
===================================================================
--- trunk/varnish-cache/include/varnishapi.h	2010-05-06 09:00:15 UTC (rev 4775)
+++ trunk/varnish-cache/include/varnishapi.h	2010-05-06 09:10:36 UTC (rev 4776)
@@ -43,8 +43,8 @@
     unsigned len, unsigned spec, const char *ptr);
 #define VSL_S_CLIENT	(1 << 0)
 #define VSL_S_BACKEND	(1 << 1)
-#define VSL_LOG_ARGS	"bCcdI:i:k:n:r:s:X:x:"
-#define VSL_STAT_ARGS	"n:"
+#define VSL_LOG_ARGS	"bCcdI:i:k:L:n:r:s:X:x:"
+#define VSL_STAT_ARGS	"L:n:"
 #define VSL_USAGE	"[-bCcd] [-i tag] [-I regexp] [-k keep]" \
 			" [-r file] [-s skip] [-X regexp] [-x tag]"
 vsl_handler VSL_H_Print;

Modified: trunk/varnish-cache/lib/libvarnish/vin.c
===================================================================
--- trunk/varnish-cache/lib/libvarnish/vin.c	2010-05-06 09:00:15 UTC (rev 4775)
+++ trunk/varnish-cache/lib/libvarnish/vin.c	2010-05-06 09:10:36 UTC (rev 4776)
@@ -100,3 +100,13 @@
 	}
 	return (0);
 }
+
+char *
+vin_L_arg(unsigned L_arg)
+{
+	char p[PATH_MAX];
+
+	assert(VIN_L_OK(L_arg));
+	bprintf(p, "/tmp/varnish_L_%u", L_arg);
+	return (strdup(p));
+}

Modified: trunk/varnish-cache/lib/libvarnishapi/shmlog.c
===================================================================
--- trunk/varnish-cache/lib/libvarnishapi/shmlog.c	2010-05-06 09:00:15 UTC (rev 4775)
+++ trunk/varnish-cache/lib/libvarnishapi/shmlog.c	2010-05-06 09:10:36 UTC (rev 4776)
@@ -69,6 +69,7 @@
 	unsigned		rbuflen;
 	unsigned char		*rbuf;
 
+	unsigned		L_opt;
 	char			*n_opt;
 	int			b_opt;
 	int			c_opt;
@@ -585,16 +586,27 @@
 		vd->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));
 	case 'n':
 		free(vd->n_opt);
 		vd->n_opt = strdup(opt);
 		assert(vd->n_opt != NULL);
 		return (1);
 	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 's': return (vsl_s_arg(vd, opt));
-	case 'k': return (vsl_k_arg(vd, opt));
+	case 'L':
+		vd->L_opt = strtoul(opt, NULL, 0);
+		if (vd->L_opt < 1024 || vd->L_opt > 65000) {
+			fprintf(stderr,
+			    "Illegal -L option must be [1024...65000]\n");
+			exit (1);
+		}
+		free(vd->n_opt);
+		vd->n_opt = vin_L_arg(vd->L_opt);
+		assert(vd->n_opt != NULL);
+		return (1);
 	default:
 		return (0);
 	}




More information about the varnish-commit mailing list