diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2019-08-28 13:26:44 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-28 13:26:44 +0200 |
commit | 3da400b8c6e95b139a43d12b362f7eddb0aacd87 (patch) | |
tree | 8b0b6fda28629ff1250769e5338e8707b0755ffc /vespalib/src | |
parent | 2fbebc6f826294f3f48089b7cb75bb785ba25935 (diff) | |
parent | 5348c1c5a9e72031f27dcf39d456036a911bcfcd (diff) |
Merge pull request #10404 from vespa-engine/balder/avoid-time-calls
Avoid calling time(nullptr).
Diffstat (limited to 'vespalib/src')
-rw-r--r-- | vespalib/src/vespa/vespalib/util/random.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/vespalib/src/vespa/vespalib/util/random.cpp b/vespalib/src/vespa/vespalib/util/random.cpp index 0f29e398ca6..50ff41e3407 100644 --- a/vespalib/src/vespa/vespalib/util/random.cpp +++ b/vespalib/src/vespa/vespalib/util/random.cpp @@ -5,6 +5,7 @@ #include <cstring> #include <ctime> #include <unistd.h> +#include <chrono> namespace vespalib { @@ -30,7 +31,7 @@ RandomGen::RandomGen() : _state(0) { unsigned long seed = getpid(); - seed ^= time(0); + seed ^= std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::steady_clock::now().time_since_epoch()).count(); char hn[32]; memset(hn, 0, sizeof(hn)); gethostname(hn, 32); |