[MEDIUM] differentiate between generic LB params and map-specific ones

Since the introduction of server weights, all load balancing algorithms
relied on a pre-computed map. Incidently, quite a bunch of map-specific
parameters were used at random places in order to get the number of
servers or their total weight. It was not architecturally acceptable
that optimizations for the map computation had impact on external parts.
For instance, during this cleanup it was found that a backend weight was
seen as 1 when only the first backup server is used, whatever its weight.

This cleanup consists in differentiating between LB-generic parameters,
such as total weights, number of servers, etc... and map-specific ones.
The struct proxy has been enhanced in order to make it easier to later
support other algorithms. The recount_servers() function now also
updates generic values such as total weights so that it's not needed
anymore to call recalc_server_map() when weights are needed. This
permitted to simplify some code which does not need to know about map
internals anymore.
diff --git a/include/proto/backend.h b/include/proto/backend.h
index fc71717..7414ede 100644
--- a/include/proto/backend.h
+++ b/include/proto/backend.h
@@ -46,7 +46,7 @@
 /*
  * This function tries to find a running server with free connection slots for
  * the proxy <px> following the round-robin method.
- * If any server is found, it will be returned and px->srv_rr_idx will be updated
+ * If any server is found, it will be returned and px->lbprm.map.rr_idx will be updated
  * to point to the next server. If no valid server is found, NULL is returned.
  */
 static inline struct server *get_server_rr_with_conns(struct proxy *px)
@@ -54,25 +54,25 @@
 	int newidx;
 	struct server *srv;
 
-	if (px->map_state & PR_MAP_RECALC)
-		recalc_server_map(px);
-
-	if (px->srv_map_sz == 0)
+	if (px->lbprm.tot_weight == 0)
 		return NULL;
 
+	if (px->lbprm.map.state & PR_MAP_RECALC)
+		recalc_server_map(px);
+
-	if (px->srv_rr_idx < 0 || px->srv_rr_idx >= px->srv_map_sz)
-		px->srv_rr_idx = 0;
-	newidx = px->srv_rr_idx;
+	if (px->lbprm.map.rr_idx < 0 || px->lbprm.map.rr_idx >= px->lbprm.tot_weight)
+		px->lbprm.map.rr_idx = 0;
+	newidx = px->lbprm.map.rr_idx;
 
 	do {
-		srv = px->srv_map[newidx++];
+		srv = px->lbprm.map.srv[newidx++];
 		if (!srv->maxconn || srv->cur_sess < srv_dynamic_maxconn(srv)) {
-			px->srv_rr_idx = newidx;
+			px->lbprm.map.rr_idx = newidx;
 			return srv;
 		}
-		if (newidx == px->srv_map_sz)
+		if (newidx == px->lbprm.tot_weight)
 			newidx = 0;
-	} while (newidx != px->srv_rr_idx);
+	} while (newidx != px->lbprm.map.rr_idx);
 
 	return NULL;
 }
@@ -81,20 +81,20 @@
 /*
  * This function tries to find a running server for the proxy <px> following
  * the round-robin method.
- * If any server is found, it will be returned and px->srv_rr_idx will be updated
+ * If any server is found, it will be returned and px->lbprm.map.rr_idx will be updated
  * to point to the next server. If no valid server is found, NULL is returned.
  */
 static inline struct server *get_server_rr(struct proxy *px)
 {
-	if (px->map_state & PR_MAP_RECALC)
-		recalc_server_map(px);
-
-	if (px->srv_map_sz == 0)
+	if (px->lbprm.tot_weight == 0)
 		return NULL;
 
+	if (px->lbprm.map.state & PR_MAP_RECALC)
+		recalc_server_map(px);
+
-	if (px->srv_rr_idx < 0 || px->srv_rr_idx >= px->srv_map_sz)
-		px->srv_rr_idx = 0;
-	return px->srv_map[px->srv_rr_idx++];
+	if (px->lbprm.map.rr_idx < 0 || px->lbprm.map.rr_idx >= px->lbprm.tot_weight)
+		px->lbprm.map.rr_idx = 0;
+	return px->lbprm.map.srv[px->lbprm.map.rr_idx++];
 }
 
 
@@ -110,21 +110,21 @@
 {
 	unsigned int h, l;
 
-	if (px->map_state & PR_MAP_RECALC)
-		recalc_server_map(px);
-
-	if (px->srv_map_sz == 0)
+	if (px->lbprm.tot_weight == 0)
 		return NULL;
 
+	if (px->lbprm.map.state & PR_MAP_RECALC)
+		recalc_server_map(px);
+
 	l = h = 0;
 	if (px->srv_act > 1 || (px->srv_act == 0 && px->srv_bck > 1)) {
 		while ((l + sizeof (int)) <= len) {
 			h ^= ntohl(*(unsigned int *)(&addr[l]));
 			l += sizeof (int);
 		}
-		h %= px->srv_map_sz;
+		h %= px->lbprm.tot_weight;
 	}
-	return px->srv_map[h];
+	return px->lbprm.map.srv[h];
 }
 
 /* 
@@ -144,12 +144,12 @@
 	unsigned long hash = 0;
 	int c;
 
-	if (px->map_state & PR_MAP_RECALC)
-		recalc_server_map(px);
-
-	if (px->srv_map_sz == 0)
+	if (px->lbprm.tot_weight == 0)
 		return NULL;
 
+	if (px->lbprm.map.state & PR_MAP_RECALC)
+		recalc_server_map(px);
+
 	while (uri_len--) {
 		c = *uri++;
 		if (c == '?')
@@ -157,7 +157,7 @@
 		hash = c + (hash << 6) + (hash << 16) - hash;
 	}
 
-	return px->srv_map[hash % px->srv_map_sz];
+	return px->lbprm.map.srv[hash % px->lbprm.tot_weight];
 }