mirror of
https://github.com/haproxy/haproxy.git
synced 2026-05-25 18:52:21 -04:00
BUG/MINOR: haterm: fix the random suffix multiplication
Some checks are pending
Contrib / admin/halog/ (push) Waiting to run
Contrib / dev/flags/ (push) Waiting to run
Contrib / dev/haring/ (push) Waiting to run
Contrib / dev/hpack/ (push) Waiting to run
Contrib / dev/poll/ (push) Waiting to run
VTest / Generate Build Matrix (push) Waiting to run
VTest / (push) Blocked by required conditions
Windows / Windows, gcc, all features (push) Waiting to run
Some checks are pending
Contrib / admin/halog/ (push) Waiting to run
Contrib / dev/flags/ (push) Waiting to run
Contrib / dev/haring/ (push) Waiting to run
Contrib / dev/hpack/ (push) Waiting to run
Contrib / dev/poll/ (push) Waiting to run
VTest / Generate Build Matrix (push) Waiting to run
VTest / (push) Blocked by required conditions
Windows / Windows, gcc, all features (push) Waiting to run
Passing a size or anything with suffix "r" is supposed to apply a random factor form 0 to 1. However due to the replacement of random() with ha_random64(), all 64 bits are random before the divide, so the end result is a random 32-bit value. In addition, ha_random64() is slow since shared between threads. Let's use statistical_prng() which is designed for this purpose and is much cheaper. No backport is needed, this is only in 3.4.
This commit is contained in:
parent
32fc35ef09
commit
e8c9aabd62
1 changed files with 1 additions and 1 deletions
|
|
@ -788,7 +788,7 @@ static void hstream_parse_uri(struct ist uri, struct hstream *hs)
|
|||
} while (*next);
|
||||
|
||||
if (use_rand)
|
||||
result = ((long long)ha_random64() * result) / ((long long)RAND_MAX + 1);
|
||||
result = ((long long)statistical_prng() * result) / 0xFFFFFFFFU;
|
||||
|
||||
switch (*arg) {
|
||||
case 's':
|
||||
|
|
|
|||
Loading…
Reference in a new issue