]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MINOR: tools: seed the statistical PRNG slightly better
authorWilly Tarreau <w@1wt.eu>
Fri, 1 Mar 2024 15:17:47 +0000 (16:17 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 1 Mar 2024 15:25:39 +0000 (16:25 +0100)
commit7151076522eface09dc3268e9d12286ff570e9b0
tree04b68296d1d6c87804f053a993c86ed44c063f0b
parent31ec9f18bb73737fc8e96f8781e1f251ddc44522
BUG/MINOR: tools: seed the statistical PRNG slightly better

Thomas Baroux reported a very interesting issue. "balance random" would
systematically assign the same server first upon restart. That comes from
its use of statistical_prng() which is only seeded with the thread number,
and since at low loads threads are assigned to incoming connections in
round robin order, practically speaking, the same thread always gets the
same request and will produce the same random number.

We already have a much better RNG that's also way more expensive, but we
can use it at boot time to seed the PRNG instead of using the thread ID
only.

This needs to be backported to 2.4.
src/tools.c