r2481 - trunk/varnish-cache/bin/varnishd

phk at projects.linpro.no phk at projects.linpro.no
Fri Feb 15 13:47:43 CET 2008


Author: phk
Date: 2008-02-15 13:47:42 +0100 (Fri, 15 Feb 2008)
New Revision: 2481

Modified:
   trunk/varnish-cache/bin/varnishd/cache_dir_random.c
Log:
Assert that VCC did its job with respect to weights.


Modified: trunk/varnish-cache/bin/varnishd/cache_dir_random.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_dir_random.c	2008-02-15 12:44:42 UTC (rev 2480)
+++ trunk/varnish-cache/bin/varnishd/cache_dir_random.c	2008-02-15 12:47:42 UTC (rev 2481)
@@ -56,7 +56,6 @@
 #define VDI_RANDOM_MAGIC	0x476d25b7
 	struct director		dir;
 	struct backend		*backend;
-	unsigned		nhosts;
 	struct vdi_random_host	*hosts;
 };
 
@@ -121,6 +120,7 @@
 	vh = vs->hosts;
 	te = t->members;
 	for (i = 0; i < t->nmember; i++, vh++, te++) {
+		assert(te->weight > 0.0);
 		s += te->weight;
 		vh->backend = VBE_AddBackend(cli, te->host);
 	}
@@ -128,6 +128,7 @@
 	/* Normalize weights */
 	i = 0;
 	a = 0.0;
+	assert(s > 0.0);
 	for (te = t->members; te->host != NULL; te++, i++) {
 		/* First normalize the specified weight in FP */
 		b = te->weight / s;




More information about the varnish-commit mailing list