diff --git a/include/types/server.h b/include/types/server.h index ce138206b..5d8921282 100644 --- a/include/types/server.h +++ b/include/types/server.h @@ -203,6 +203,7 @@ struct server { unsigned wscore; /* weight score, used during srv map computation */ unsigned prev_eweight; /* eweight before last change */ unsigned rweight; /* remainer of weight in the current LB tree */ + unsigned cumulative_weight; /* weight of servers prior to this one in the same group, for chash balancing */ unsigned npos, lpos; /* next and last positions in the LB tree */ struct eb32_node lb_node; /* node used for tree-based load balancing */ struct eb_root *lb_tree; /* we want to know in what tree the server is */ diff --git a/src/backend.c b/src/backend.c index faf872c0b..573f054dc 100644 --- a/src/backend.c +++ b/src/backend.c @@ -115,9 +115,11 @@ void recount_servers(struct proxy *px) !(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; } }