]> git.ipfire.org Git - thirdparty/squid.git/commit
Unify r.n.g. seed generation (#1109)
authorAlex Rousskov <rousskov@measurement-factory.com>
Mon, 8 Aug 2022 16:10:06 +0000 (16:10 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Tue, 9 Aug 2022 00:40:53 +0000 (00:40 +0000)
commit4a28fc5546e36182eaf0beea1818f25587d34e3f
treec5b20e3bf5ebde46f1082def630210a3e8936809
parentefdbb07dc999d554f57f5e868cdce2b3c847fad4
Unify r.n.g. seed generation (#1109)

Using time-based expressions for seeding pseudo random number generators
often results in multiple SMP workers getting the same seed. That, in
turn, may result in unwanted correlation of supposed-to-be-independent
worker activities: making artificially similar decisions (that are
supposed to be "random") and/or concentrating rather than
spreading/sharing load.

The recently added RandomUuid code did not use time-based seeds in
anticipation of this unification.

This change converts all std::mt19937 users in src/ except the random
ACL code (that probably deserves a dedicated change).

C++ standard does not guarantee that std::random_device does not force
users to wait while more entropy is accumulated. Based on public
comments and source code analysis of popular STL implementations, we
should be getting the desired no-wait behavior from popular STLs, in
popular environments. If Squid encounters a special environment where
the default std::random_device waits for entropy, more code and/or
configuration options will be needed to accommodate that special case.
The biggest drawback with this approach is that it may be difficult for
the admins to discover that std::random_device is waiting in their
environment. This is mitigated by the low probability of that happening.
src/auth/basic/RADIUS/Makefile.am
src/auth/basic/RADIUS/basic_radius_auth.cc
src/auth/digest/Config.cc
src/base/Makefile.am
src/base/Random.cc [new file with mode: 0644]
src/base/Random.h [new file with mode: 0644]
src/base/RandomUuid.cc
src/dns_internal.cc
src/event.cc
src/fs/ufs/UFSSwapDir.cc
src/tests/SBufFindTest.cc