From 1490c19eb494dcd61734dc764529b3e06fbb5fe4 Mon Sep 17 00:00:00 2001 From: phk Date: Fri, 15 Feb 2008 12:47:42 +0000 Subject: [PATCH] Assert that VCC did its job with respect to weights. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@2481 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- varnish-cache/bin/varnishd/cache_dir_random.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/varnish-cache/bin/varnishd/cache_dir_random.c b/varnish-cache/bin/varnishd/cache_dir_random.c index 25abe586..76c7d43a 100644 --- a/varnish-cache/bin/varnishd/cache_dir_random.c +++ b/varnish-cache/bin/varnishd/cache_dir_random.c @@ -56,7 +56,6 @@ struct vdi_random { #define VDI_RANDOM_MAGIC 0x476d25b7 struct director dir; struct backend *backend; - unsigned nhosts; struct vdi_random_host *hosts; }; @@ -121,6 +120,7 @@ VRT_init_dir_random(struct cli *cli, struct director **bp, const struct vrt_dir_ 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 @@ VRT_init_dir_random(struct cli *cli, struct director **bp, const struct vrt_dir_ /* 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; -- 2.39.5