MINOR: server: compute a "cumulative weight" to allow chash balancing to hit its target

For active servers, this is the sum of the eweights of all active
servers before this one in the backend, and
[srv->cumulative_weight .. srv_cumulative_weight + srv_eweight) is a
space occupied by this server in the range [0 .. lbprm.tot_wact), and
likewise for backup servers with tot_wbck. This allows choosing a
server or a range of servers proportional to their weight, by simple
integer comparison.

Signed-off-by: Andrew Rodland <andrewr@vimeo.com>
diff --git a/src/backend.c b/src/backend.c
index faf872c..573f054 100644
--- a/src/backend.c
+++ b/src/backend.c
@@ -115,9 +115,11 @@
 			    !(px->options & PR_O_USE_ALL_BK))
 				px->lbprm.fbck = srv;
 			px->srv_bck++;
+			srv->cumulative_weight = px->lbprm.tot_wbck;
 			px->lbprm.tot_wbck += srv->eweight;
 		} else {
 			px->srv_act++;
+			srv->cumulative_weight = px->lbprm.tot_wact;
 			px->lbprm.tot_wact += srv->eweight;
 		}
 	}