mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2025-01-20 12:40:46 +00:00
MINOR: lbprm: compute the hash avalanche in gen_hash()
Instead of systematically computing the avalanche hash right after the gen_hash() call, do it inside the gen_hash() function directly to ensure avalanche setting is always considered.
This commit is contained in:
parent
a7563158f7
commit
08767e162d
@ -99,6 +99,9 @@ static unsigned int gen_hash(const struct proxy* px, const char* key, unsigned l
|
||||
break;
|
||||
}
|
||||
|
||||
if ((px->lbprm.algo & BE_LB_HASH_MOD) == BE_LB_HMOD_AVAL)
|
||||
hash = full_hash(hash);
|
||||
|
||||
return hash;
|
||||
}
|
||||
|
||||
@ -190,6 +193,10 @@ static struct server *get_server_sh(struct proxy *px, const char *addr, int len,
|
||||
h ^= ntohl(*(unsigned int *)(&addr[l]));
|
||||
l += sizeof (int);
|
||||
}
|
||||
/* FIXME: why don't we use gen_hash() here as well?
|
||||
* -> we don't take into account hash function from "hash_type"
|
||||
* options here..
|
||||
*/
|
||||
if ((px->lbprm.algo & BE_LB_HASH_MOD) == BE_LB_HMOD_AVAL)
|
||||
h = full_hash(h);
|
||||
hash_done:
|
||||
@ -245,8 +252,6 @@ static struct server *get_server_uh(struct proxy *px, char *uri, int uri_len, co
|
||||
|
||||
hash = gen_hash(px, start, (end - start));
|
||||
|
||||
if ((px->lbprm.algo & BE_LB_HASH_MOD) == BE_LB_HMOD_AVAL)
|
||||
hash = full_hash(hash);
|
||||
hash_done:
|
||||
if ((px->lbprm.algo & BE_LB_LKUP) == BE_LB_LKUP_CHTREE)
|
||||
return chash_get_server_hash(px, hash, avoid);
|
||||
@ -302,9 +307,6 @@ static struct server *get_server_ph(struct proxy *px, const char *uri, int uri_l
|
||||
}
|
||||
hash = gen_hash(px, start, (end - start));
|
||||
|
||||
if ((px->lbprm.algo & BE_LB_HASH_MOD) == BE_LB_HMOD_AVAL)
|
||||
hash = full_hash(hash);
|
||||
|
||||
if ((px->lbprm.algo & BE_LB_LKUP) == BE_LB_LKUP_CHTREE)
|
||||
return chash_get_server_hash(px, hash, avoid);
|
||||
else
|
||||
@ -382,9 +384,6 @@ static struct server *get_server_ph_post(struct stream *s, const struct server *
|
||||
}
|
||||
hash = gen_hash(px, start, (end - start));
|
||||
|
||||
if ((px->lbprm.algo & BE_LB_HASH_MOD) == BE_LB_HMOD_AVAL)
|
||||
hash = full_hash(hash);
|
||||
|
||||
if ((px->lbprm.algo & BE_LB_LKUP) == BE_LB_LKUP_CHTREE)
|
||||
return chash_get_server_hash(px, hash, avoid);
|
||||
else
|
||||
@ -477,8 +476,7 @@ static struct server *get_server_hh(struct stream *s, const struct server *avoid
|
||||
start = p;
|
||||
hash = gen_hash(px, start, (end - start));
|
||||
}
|
||||
if ((px->lbprm.algo & BE_LB_HASH_MOD) == BE_LB_HMOD_AVAL)
|
||||
hash = full_hash(hash);
|
||||
|
||||
hash_done:
|
||||
if ((px->lbprm.algo & BE_LB_LKUP) == BE_LB_LKUP_CHTREE)
|
||||
return chash_get_server_hash(px, hash, avoid);
|
||||
@ -522,8 +520,6 @@ static struct server *get_server_rch(struct stream *s, const struct server *avoi
|
||||
*/
|
||||
hash = gen_hash(px, smp.data.u.str.area, len);
|
||||
|
||||
if ((px->lbprm.algo & BE_LB_HASH_MOD) == BE_LB_HMOD_AVAL)
|
||||
hash = full_hash(hash);
|
||||
hash_done:
|
||||
if ((px->lbprm.algo & BE_LB_LKUP) == BE_LB_LKUP_CHTREE)
|
||||
return chash_get_server_hash(px, hash, avoid);
|
||||
@ -556,8 +552,6 @@ static struct server *get_server_expr(struct stream *s, const struct server *avo
|
||||
*/
|
||||
hash = gen_hash(px, smp->data.u.str.area, smp->data.u.str.data);
|
||||
|
||||
if ((px->lbprm.algo & BE_LB_HASH_MOD) == BE_LB_HMOD_AVAL)
|
||||
hash = full_hash(hash);
|
||||
hash_done:
|
||||
if ((px->lbprm.algo & BE_LB_LKUP) == BE_LB_LKUP_CHTREE)
|
||||
return chash_get_server_hash(px, hash, avoid);
|
||||
|
Loading…
Reference in New Issue
Block a user