r4777 - in trunk/varnish-cache: bin/varnishd include lib/libvarnishapi

phk at varnish-cache.org phk at varnish-cache.org
Thu May 6 11:39:23 CEST 2010


Author: phk
Date: 2010-05-06 11:39:23 +0200 (Thu, 06 May 2010)
New Revision: 4777

Modified:
   trunk/varnish-cache/bin/varnishd/common.h
   trunk/varnish-cache/bin/varnishd/varnishd.c
   trunk/varnish-cache/include/shmlog.h
   trunk/varnish-cache/lib/libvarnishapi/shmlog.c
Log:
Add -L option to varnishd, it will:

- enable -d
- set listen address to ($L)
- set telnet address to ($L + 1)
- if no storage configured, use "-smalloc, 1m"
- set -n to /tmp/varnish_L_$L
- set ping_interval to zero

Still missing:  VCC magic to hack backends port number.




Modified: trunk/varnish-cache/bin/varnishd/common.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/common.h	2010-05-06 09:10:36 UTC (rev 4776)
+++ trunk/varnish-cache/bin/varnishd/common.h	2010-05-06 09:39:23 UTC (rev 4777)
@@ -50,6 +50,7 @@
 struct vsb;
 extern struct vsb *vident;
 int Symbol_Lookup(struct vsb *vsb, void *ptr);
+extern unsigned L_arg;
 
 #define TRUST_ME(ptr)	((void*)(uintptr_t)(ptr))
 

Modified: trunk/varnish-cache/bin/varnishd/varnishd.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/varnishd.c	2010-05-06 09:10:36 UTC (rev 4776)
+++ trunk/varnish-cache/bin/varnishd/varnishd.c	2010-05-06 09:39:23 UTC (rev 4777)
@@ -84,6 +84,7 @@
 struct vev_base		*mgt_evb;
 int			exit_status = 0;
 struct vsb		*vident;
+unsigned		L_arg = 0;
 
 static void
 build_vident(void)
@@ -423,6 +424,7 @@
 	struct cli cli[1];
 	struct pidfh *pfh = NULL;
 	char *dirname;
+	char tmpbuf[128];
 
 	/*
 	 * Start out by closing all unwanted file descriptors we might
@@ -486,7 +488,7 @@
 	cli_check(cli);
 
 	while ((o = getopt(argc, argv,
-	    "a:b:Cdf:Fg:h:i:l:M:n:P:p:S:s:T:t:u:Vx:w:")) != -1)
+	    "a:b:Cdf:Fg:h:i:l:L:M:n:P:p:S:s:T:t:u:Vx:w:")) != -1)
 		switch (o) {
 		case 'a':
 			MCF_ParamSet(cli, "listen_address", optarg);
@@ -519,6 +521,20 @@
 		case 'l':
 			l_arg = optarg;
 			break;
+		case 'L':
+			L_arg = strtoul(optarg, NULL, 0);
+			if (!VIN_L_OK(L_arg)) {
+				fprintf(stderr, "%s\n", VIN_L_MSG);
+				exit (1);
+			}
+			d_flag++;
+			n_arg = vin_L_arg(L_arg);
+			MCF_ParamSet(cli, "ping_interval", "0");
+
+			bprintf(tmpbuf, "127.0.0.1:%u", L_arg);
+			MCF_ParamSet(cli, "listen_address", tmpbuf);
+
+			break;
 		case 'M':
 			M_arg = optarg;
 			break;
@@ -575,6 +591,12 @@
 	argc -= optind;
 	argv += optind;
 
+	if (L_arg) {
+		/* Learner mode */
+		if (!s_arg_given)
+			setup_storage("malloc,1m");
+	}
+
 	if (argc != 0) {
 		fprintf(stderr, "Too many arguments (%s...)\n", argv[0]);
 		usage();
@@ -696,6 +718,10 @@
 		mgt_cli_master(M_arg);
 	if (T_arg != NULL)
 		mgt_cli_telnet(T_arg);
+	else if (L_arg > 0) {
+		bprintf(tmpbuf, "127.0.0.1:%u", L_arg + 1);
+		mgt_cli_telnet(tmpbuf);
+	}
 
 	MGT_Run();
 

Modified: trunk/varnish-cache/include/shmlog.h
===================================================================
--- trunk/varnish-cache/include/shmlog.h	2010-05-06 09:10:36 UTC (rev 4776)
+++ trunk/varnish-cache/include/shmlog.h	2010-05-06 09:39:23 UTC (rev 4777)
@@ -115,5 +115,6 @@
 #define VIN_L_LOW	1024
 #define VIN_L_HIGH	65000
 #define VIN_L_OK(a)	(a >= VIN_L_LOW && a <= VIN_L_HIGH)
+#define VIN_L_MSG	"-L argument must be [1024...65000]"
 
 #endif

Modified: trunk/varnish-cache/lib/libvarnishapi/shmlog.c
===================================================================
--- trunk/varnish-cache/lib/libvarnishapi/shmlog.c	2010-05-06 09:10:36 UTC (rev 4776)
+++ trunk/varnish-cache/lib/libvarnishapi/shmlog.c	2010-05-06 09:39:23 UTC (rev 4777)
@@ -599,8 +599,7 @@
 	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");
+			fprintf(stderr, "%s\n", VIN_L_MSG);
 			exit (1);
 		}
 		free(vd->n_opt);




More information about the varnish-commit mailing list