r4984 - in trunk/varnish-cache: bin/varnishd include lib/libvcl

phk at varnish-cache.org phk at varnish-cache.org
Tue Jun 22 15:01:22 CEST 2010


Author: phk
Date: 2010-06-22 15:01:22 +0200 (Tue, 22 Jun 2010)
New Revision: 4984

Modified:
   trunk/varnish-cache/bin/varnishd/cache_backend_cfg.c
   trunk/varnish-cache/bin/varnishd/cache_backend_poll.c
   trunk/varnish-cache/include/vrt.h
   trunk/varnish-cache/lib/libvcl/vcc_backend.c
   trunk/varnish-cache/lib/libvcl/vcc_compile.h
   trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c
Log:
Emit probe-specs as separate free-standing structs, and point
to them from backend specs.



Modified: trunk/varnish-cache/bin/varnishd/cache_backend_cfg.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_backend_cfg.c	2010-06-22 12:22:03 UTC (rev 4983)
+++ trunk/varnish-cache/bin/varnishd/cache_backend_cfg.c	2010-06-22 13:01:22 UTC (rev 4984)
@@ -251,7 +251,7 @@
 
 	assert(b->ipv4 != NULL || b->ipv6 != NULL);
 
-	VBP_Start(b, &vb->probe);
+	VBP_Start(b, vb->probe);
 	VTAILQ_INSERT_TAIL(&backends, b, list);
 	VSC_main->n_backend++;
 	return (b);

Modified: trunk/varnish-cache/bin/varnishd/cache_backend_poll.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_backend_poll.c	2010-06-22 12:22:03 UTC (rev 4983)
+++ trunk/varnish-cache/bin/varnishd/cache_backend_poll.c	2010-06-22 13:01:22 UTC (rev 4984)
@@ -424,14 +424,13 @@
 
 	ASSERT_CLI();
 
-	ALLOC_OBJ(vt, VBP_TARGET_MAGIC);
-	AN(vt);
-	if (!memcmp(&vt->probe, p, sizeof *p)) {
-		FREE_OBJ(vt);
-		/* No probe defined for this backend, set it healthy */
+	if (p == NULL) {
 		b->healthy = 1;
 		return;
 	}
+
+	ALLOC_OBJ(vt, VBP_TARGET_MAGIC);
+	AN(vt);
 	vt->backend = b;
 	vt->probe = *p;
 

Modified: trunk/varnish-cache/include/vrt.h
===================================================================
--- trunk/varnish-cache/include/vrt.h	2010-06-22 12:22:03 UTC (rev 4983)
+++ trunk/varnish-cache/include/vrt.h	2010-06-22 13:01:22 UTC (rev 4984)
@@ -74,7 +74,7 @@
 	double				between_bytes_timeout;
 	unsigned			max_connections;
 	unsigned			saintmode_threshold;
-	struct vrt_backend_probe	probe;
+	const struct vrt_backend_probe	*probe;
 };
 
 /*

Modified: trunk/varnish-cache/lib/libvcl/vcc_backend.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_backend.c	2010-06-22 12:22:03 UTC (rev 4983)
+++ trunk/varnish-cache/lib/libvcl/vcc_backend.c	2010-06-22 13:01:22 UTC (rev 4984)
@@ -228,11 +228,9 @@
 	/* .url and .request are mutually exclusive */
 
 	if (*t_did != NULL) {
-		vsb_printf(tl->sb,
-		    "Probe request redefinition at:\n");
+		vsb_printf(tl->sb, "Probe request redefinition at:\n");
 		vcc_ErrWhere(tl, t_field);
-		vsb_printf(tl->sb,
-		    "Previous definition:\n");
+		vsb_printf(tl->sb, "Previous definition:\n");
 		vcc_ErrWhere(tl, *t_did);
 		return;
 	}
@@ -240,7 +238,7 @@
 }
 
 static void
-vcc_ParseProbe(struct tokenlist *tl)
+vcc_ParseProbeSpec(struct tokenlist *tl)
 {
 	struct fld_spec *fs;
 	struct token *t_field;
@@ -266,7 +264,8 @@
 	threshold = 0;
 	initial = 0;
 	status = 0;
-	Fb(tl, 0, "\t.probe = {\n");
+	Fh(tl, 0, "static const struct vrt_backend_probe vgc_probe_%d = {\n",
+	    tl->nprobe++);
 	while (tl->t->tok != '}') {
 
 		vcc_IsField(tl, &t_field, fs);
@@ -275,32 +274,32 @@
 			vcc_ProbeRedef(tl, &t_did, t_field);
 			ERRCHK(tl);
 			ExpectErr(tl, CSTR);
-			Fb(tl, 0, "\t\t.url = ");
-			EncToken(tl->fb, tl->t);
-			Fb(tl, 0, ",\n");
+			Fh(tl, 0, "\t.url = ");
+			EncToken(tl->fh, tl->t);
+			Fh(tl, 0, ",\n");
 			vcc_NextToken(tl);
 		} else if (vcc_IdIs(t_field, "request")) {
 			vcc_ProbeRedef(tl, &t_did, t_field);
 			ERRCHK(tl);
 			ExpectErr(tl, CSTR);
-			Fb(tl, 0, "\t\t.request =\n");
+			Fh(tl, 0, "\t.request =\n");
 			while (tl->t->tok == CSTR) {
-				Fb(tl, 0, "\t\t\t");
-				EncToken(tl->fb, tl->t);
-				Fb(tl, 0, " \"\\r\\n\"\n");
+				Fh(tl, 0, "\t\t");
+				EncToken(tl->fh, tl->t);
+				Fh(tl, 0, " \"\\r\\n\"\n");
 				vcc_NextToken(tl);
 			}
-			Fb(tl, 0, "\t\t\t\"\\r\\n\",\n");
+			Fh(tl, 0, "\t\t\"\\r\\n\",\n");
 		} else if (vcc_IdIs(t_field, "timeout")) {
-			Fb(tl, 0, "\t\t.timeout = ");
+			Fh(tl, 0, "\t.timeout = ");
 			vcc_TimeVal(tl, &t);
 			ERRCHK(tl);
-			Fb(tl, 0, "%g,\n", t);
+			Fh(tl, 0, "%g,\n", t);
 		} else if (vcc_IdIs(t_field, "interval")) {
-			Fb(tl, 0, "\t\t.interval = ");
+			Fh(tl, 0, "\t.interval = ");
 			vcc_TimeVal(tl, &t);
 			ERRCHK(tl);
-			Fb(tl, 0, "%g,\n", t);
+			Fh(tl, 0, "%g,\n", t);
 		} else if (vcc_IdIs(t_field, "window")) {
 			t_window = tl->t;
 			window = vcc_UintVal(tl);
@@ -361,16 +360,16 @@
 			AN(t_window);
 			vcc_ErrWhere(tl, t_window);
 		}
-		Fb(tl, 0, "\t\t.window = %u,\n", window);
-		Fb(tl, 0, "\t\t.threshold = %u,\n", threshold);
+		Fh(tl, 0, "\t.window = %u,\n", window);
+		Fh(tl, 0, "\t.threshold = %u,\n", threshold);
 	}
 	if (t_initial != NULL)
-		Fb(tl, 0, "\t\t.initial = %u,\n", initial);
+		Fh(tl, 0, "\t.initial = %u,\n", initial);
 	else
-		Fb(tl, 0, "\t\t.initial = ~0U,\n", initial);
+		Fh(tl, 0, "\t.initial = ~0U,\n", initial);
 	if (status > 0)
-		Fb(tl, 0, "\t\t.exp_status = %u,\n", status);
-	Fb(tl, 0, "\t},\n");
+		Fh(tl, 0, "\t.exp_status = %u,\n", status);
+	Fh(tl, 0, "};\n");
 	SkipToken(tl, '}');
 }
 
@@ -496,8 +495,9 @@
 			ERRCHK(tl);
 			saint = u;
 			SkipToken(tl, ';');
-		} else if (vcc_IdIs(t_field, "probe")) {
-			vcc_ParseProbe(tl);
+		} else if (vcc_IdIs(t_field, "probe") && tl->t->tok == '{') {
+			Fb(tl, 0, "\t.probe = &vgc_probe_%d,\n", tl->nprobe);
+			vcc_ParseProbeSpec(tl);
 			ERRCHK(tl);
 		} else {
 			ErrInternal(tl);

Modified: trunk/varnish-cache/lib/libvcl/vcc_compile.h
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_compile.h	2010-06-22 12:22:03 UTC (rev 4983)
+++ trunk/varnish-cache/lib/libvcl/vcc_compile.h	2010-06-22 13:01:22 UTC (rev 4984)
@@ -88,6 +88,8 @@
 
 	VTAILQ_HEAD(, acl_e)	acl;
 
+	int			nprobe;
+
 	int			defaultdir;
 	struct token		*t_defaultdir;
 	struct token		*t_dir;

Modified: trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c	2010-06-22 12:22:03 UTC (rev 4983)
+++ trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c	2010-06-22 13:01:22 UTC (rev 4984)
@@ -233,8 +233,8 @@
 	    "char\t\t*ipv6_sockaddr;\n\n\tdouble\t\t\t\tconnect_timeout;\n"
 	    "\tdouble\t\t\t\tfirst_byte_timeout;\n\tdouble\t\t\t\tbetween_byt"
 	    "es_timeout;\n\tunsigned\t\t\tmax_connections;\n\tunsigned\t"
-	    "\t\tsaintmode_threshold;\n\tstruct vrt_backend_probe\tprobe;\n"
-	    "};\n\n/*\n * A director with an unpredictable reply\n"
+	    "\t\tsaintmode_threshold;\n\tconst struct vrt_backend_probe\t"
+	    "*probe;\n};\n\n/*\n * A director with an unpredictable reply\n"
 	    " */\n\nstruct vrt_dir_random_entry {\n\tint\t\t\t\t\thost;\n"
 	    "\tdouble\t\t\t\t\tweight;\n};\n\nstruct vrt_dir_random {\n"
 	    "\tconst char\t\t\t\t*name;\n\tunsigned\t\t\t\tretries;\n"




More information about the varnish-commit mailing list