More completely seed UUID::Random()
Generate enuogh randomness with std::random_device to fully seed the
internal state of an std::mt19937. This ensures that even the first
UUID::Random() call after boot has full entropy, so long as
`std::random_device` is non-deterministic.
Also, initialize the random number generator during AOS initialization.
Change-Id: Ie09d85f09f7969bcd47576a577b4415d39186233
Signed-off-by: James Kuszmaul <james.kuszmaul@bluerivertech.com>
diff --git a/aos/init.cc b/aos/init.cc
index 7d4840c..3ca7314 100644
--- a/aos/init.cc
+++ b/aos/init.cc
@@ -15,6 +15,7 @@
#include "glog/logging.h"
#include "aos/realtime.h"
+#include "aos/uuid.h"
DEFINE_bool(coredump, false, "If true, write core dumps on failure.");
@@ -37,6 +38,10 @@
}
RegisterMallocHook();
+ // Ensure that the random number generator for the UUID code is initialized
+ // (it does some potentially expensive random number generation).
+ UUID::Random();
+
initialized = true;
}