diff --git a/include/types/backend.h b/include/types/backend.h index e67f0be54..ea38ed2c2 100644 --- a/include/types/backend.h +++ b/include/types/backend.h @@ -144,6 +144,7 @@ struct lbprm { int tot_used; /* total number of servers used for LB */ int wmult; /* ratio between user weight and effective weight */ int wdiv; /* ratio between effective weight and user weight */ + int hash_balance_factor; /* load balancing factor * 100, 0 if disabled */ char *arg_str; /* name of the URL parameter/header/cookie used for hashing */ int arg_len; /* strlen(arg_str), computed only once */ int arg_opt1; /* extra option 1 for the LB algo (algo-specific) */ diff --git a/include/types/lb_chash.h b/include/types/lb_chash.h index b711636e2..5991ce961 100644 --- a/include/types/lb_chash.h +++ b/include/types/lb_chash.h @@ -30,7 +30,6 @@ struct lb_chash { struct eb_root act; /* weighted chash entries of active servers */ struct eb_root bck; /* weighted chash entries of backup servers */ struct eb32_node *last; /* last node found in case of round robin (or NULL) */ - int balance_factor; /* load balancing factor * 100, 0 if disabled */ }; #endif /* _TYPES_LB_CHASH_H */ diff --git a/src/cfgparse-listen.c b/src/cfgparse-listen.c index 7514a47ef..1af86ded4 100644 --- a/src/cfgparse-listen.c +++ b/src/cfgparse-listen.c @@ -426,7 +426,7 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm) if (curproxy->cap & PR_CAP_BE) { curproxy->lbprm.algo = defproxy.lbprm.algo; - curproxy->lbprm.chash.balance_factor = defproxy.lbprm.chash.balance_factor; + curproxy->lbprm.hash_balance_factor = defproxy.lbprm.hash_balance_factor; curproxy->fullconn = defproxy.fullconn; curproxy->conn_retries = defproxy.conn_retries; curproxy->redispatch_after = defproxy.redispatch_after; @@ -3654,8 +3654,8 @@ stats_error_parsing: err_code |= ERR_ALERT | ERR_FATAL; goto out; } - curproxy->lbprm.chash.balance_factor = atol(args[1]); - if (curproxy->lbprm.chash.balance_factor != 0 && curproxy->lbprm.chash.balance_factor <= 100) { + curproxy->lbprm.hash_balance_factor = atol(args[1]); + if (curproxy->lbprm.hash_balance_factor != 0 && curproxy->lbprm.hash_balance_factor <= 100) { ha_alert("parsing [%s:%d] : '%s' must be 0 or greater than 100.\n", file, linenum, args[0]); err_code |= ERR_ALERT | ERR_FATAL; goto out; diff --git a/src/cfgparse.c b/src/cfgparse.c index 7c316df05..31698b9b7 100644 --- a/src/cfgparse.c +++ b/src/cfgparse.c @@ -453,7 +453,6 @@ void init_default_instance() defproxy.maxconn = cfg_maxpconn; defproxy.conn_retries = CONN_RETRIES; defproxy.redispatch_after = 0; - defproxy.lbprm.chash.balance_factor = 0; defproxy.options = PR_O_REUSE_SAFE; defproxy.max_out_conns = MAX_SRV_LIST; diff --git a/src/lb_chash.c b/src/lb_chash.c index 186e87a5f..a35351e96 100644 --- a/src/lb_chash.c +++ b/src/lb_chash.c @@ -290,7 +290,7 @@ int chash_server_is_eligible(struct server *s) /* The total number of slots to allocate is the total number of outstanding requests * (including the one we're about to make) times the load-balance-factor, rounded up. */ - unsigned tot_slots = ((s->proxy->served + 1) * s->proxy->lbprm.chash.balance_factor + 99) / 100; + unsigned tot_slots = ((s->proxy->served + 1) * s->proxy->lbprm.hash_balance_factor + 99) / 100; unsigned slots_per_weight = tot_slots / s->proxy->lbprm.tot_weight; unsigned remainder = tot_slots % s->proxy->lbprm.tot_weight; @@ -368,7 +368,7 @@ struct server *chash_get_server_hash(struct proxy *p, unsigned int hash, const s } loop = 0; - while (nsrv == avoid || (p->lbprm.chash.balance_factor && !chash_server_is_eligible(nsrv))) { + while (nsrv == avoid || (p->lbprm.hash_balance_factor && !chash_server_is_eligible(nsrv))) { next = eb32_next(next); if (!next) { next = eb32_first(root);