mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-07 07:37:02 +02: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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((px->lbprm.algo & BE_LB_HASH_MOD) == BE_LB_HMOD_AVAL)
|
||||||
|
hash = full_hash(hash);
|
||||||
|
|
||||||
return 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]));
|
h ^= ntohl(*(unsigned int *)(&addr[l]));
|
||||||
l += sizeof (int);
|
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)
|
if ((px->lbprm.algo & BE_LB_HASH_MOD) == BE_LB_HMOD_AVAL)
|
||||||
h = full_hash(h);
|
h = full_hash(h);
|
||||||
hash_done:
|
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));
|
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:
|
hash_done:
|
||||||
if ((px->lbprm.algo & BE_LB_LKUP) == BE_LB_LKUP_CHTREE)
|
if ((px->lbprm.algo & BE_LB_LKUP) == BE_LB_LKUP_CHTREE)
|
||||||
return chash_get_server_hash(px, hash, avoid);
|
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));
|
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)
|
if ((px->lbprm.algo & BE_LB_LKUP) == BE_LB_LKUP_CHTREE)
|
||||||
return chash_get_server_hash(px, hash, avoid);
|
return chash_get_server_hash(px, hash, avoid);
|
||||||
else
|
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));
|
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)
|
if ((px->lbprm.algo & BE_LB_LKUP) == BE_LB_LKUP_CHTREE)
|
||||||
return chash_get_server_hash(px, hash, avoid);
|
return chash_get_server_hash(px, hash, avoid);
|
||||||
else
|
else
|
||||||
@ -477,8 +476,7 @@ static struct server *get_server_hh(struct stream *s, const struct server *avoid
|
|||||||
start = p;
|
start = p;
|
||||||
hash = gen_hash(px, start, (end - start));
|
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:
|
hash_done:
|
||||||
if ((px->lbprm.algo & BE_LB_LKUP) == BE_LB_LKUP_CHTREE)
|
if ((px->lbprm.algo & BE_LB_LKUP) == BE_LB_LKUP_CHTREE)
|
||||||
return chash_get_server_hash(px, hash, avoid);
|
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);
|
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:
|
hash_done:
|
||||||
if ((px->lbprm.algo & BE_LB_LKUP) == BE_LB_LKUP_CHTREE)
|
if ((px->lbprm.algo & BE_LB_LKUP) == BE_LB_LKUP_CHTREE)
|
||||||
return chash_get_server_hash(px, hash, avoid);
|
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);
|
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:
|
hash_done:
|
||||||
if ((px->lbprm.algo & BE_LB_LKUP) == BE_LB_LKUP_CHTREE)
|
if ((px->lbprm.algo & BE_LB_LKUP) == BE_LB_LKUP_CHTREE)
|
||||||
return chash_get_server_hash(px, hash, avoid);
|
return chash_get_server_hash(px, hash, avoid);
|
||||||
|
Loading…
Reference in New Issue
Block a user