]> err.no Git - varnish/commitdiff
Assert that VCC did its job with respect to weights.
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Fri, 15 Feb 2008 12:47:42 +0000 (12:47 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Fri, 15 Feb 2008 12:47:42 +0000 (12:47 +0000)
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

index 25abe586ef7e14800f9769067c22bb60a65aad98..76c7d43a5ac5464e9d0fcad00e2cdde3df1da23f 100644 (file)
@@ -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;