summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
authorJulian Andres Klode <julian.klode@canonical.com>2018-07-05 17:45:40 +0200
committerJulian Andres Klode <julian.klode@canonical.com>2018-07-06 10:40:28 +0200
commit420009e46ce7c0d97a2dc5e216ffce48dd7c0846 (patch)
treee65cbe9b0b622cbc6b6e7c3edcbbfcb921cbb535 /apt-pkg
parenta7b4dd425c10730b886f3ea0b2e045ee5015cfe5 (diff)
Use cheaper entropy source for randomizing items to fetch
The random_device fails if not enough entropy is available. We do not need high-quality entropy here, though, so let's switch to a seed based on the current time in nanoseconds, XORed with the PID.
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/acquire-item.cc5
1 files changed, 3 insertions, 2 deletions
diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc
index 0126b0f63..b40c67ec1 100644
--- a/apt-pkg/acquire-item.cc
+++ b/apt-pkg/acquire-item.cc
@@ -33,6 +33,7 @@
#include <algorithm>
#include <ctime>
+#include <chrono>
#include <iostream>
#include <memory>
#include <numeric>
@@ -1526,8 +1527,8 @@ void pkgAcqMetaClearSig::QueueIndexes(bool const verify) /*{{{*/
can be as we shouldn't be telling the mirrors (and everyone else watching)
which is native/foreign arch, specific order of preference of translations, … */
auto range_start = IndexTargets.begin();
- std::random_device rd;
- std::default_random_engine g(rd());
+ auto seed = (std::chrono::high_resolution_clock::now().time_since_epoch() / std::chrono::nanoseconds(1)) ^ getpid();
+ std::default_random_engine g(seed);
do {
auto const type = range_start->Option(IndexTarget::CREATED_BY);
auto const range_end = std::find_if_not(range_start, IndexTargets.end(),