aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Willemsen <dwillemsen@google.com>2019-01-11 14:27:33 -0800
committerDan Willemsen <dwillemsen@google.com>2019-01-11 14:27:33 -0800
commit59e7b3e05f1b8553f2c6e9fa329543d8b42fca8e (patch)
treec2aeaac4f7064d6ba4dc02d4772d9a278449f10c
parent3173dc0bcf3faee24d3e173fdf9584f03eee1971 (diff)
downloadkati-59e7b3e05f1b8553f2c6e9fa329543d8b42fca8e.tar.gz
Use std::random_device instead of initializing via getpid
getpid worked fine for this until we started trying to run Kati within a pid namespace (via nsjail). Then it consistently got the same pid, which resulted in multiple copies of Kati all running on the same CPU. Change-Id: If50846f742c3898ca92e21e0d2c78ad8e34d0128
-rw-r--r--affinity.cc2
1 files changed, 1 insertions, 1 deletions
diff --git a/affinity.cc b/affinity.cc
index 8be3fad..92320ee 100644
--- a/affinity.cc
+++ b/affinity.cc
@@ -30,7 +30,7 @@
void SetAffinityForSingleThread() {
cpu_set_t cs;
CPU_ZERO(&cs);
- std::default_random_engine generator(getpid());
+ std::random_device generator;
std::uniform_int_distribution<int> distribution(0, g_flags.num_cpus - 1);
int cpu = distribution(generator);