diff options
author | Billy Donahue <billy.donahue@mongodb.com> | 2019-10-09 17:09:10 +0000 |
---|---|---|
committer | evergreen <evergreen@mongodb.com> | 2019-10-09 17:09:10 +0000 |
commit | e1f433d2c47f623ceb5d1d1aee7605fefb71b846 (patch) | |
tree | c5e9cf60c65093839d1402e9755faf8342dd78e4 /src/mongo/util/uuid.cpp | |
parent | 3cb9e7903a73e0bbcd1b00823bbd53e0f4341acd (diff) | |
download | mongo-e1f433d2c47f623ceb5d1d1aee7605fefb71b846.tar.gz |
SERVER-43641 upgrade random.h
This reverts commit a40b196bd3cecd0b66a6323f57e6f08efe0af392.
Diffstat (limited to 'src/mongo/util/uuid.cpp')
-rw-r--r-- | src/mongo/util/uuid.cpp | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/src/mongo/util/uuid.cpp b/src/mongo/util/uuid.cpp index d729777cf30..63ca7bc1e2d 100644 --- a/src/mongo/util/uuid.cpp +++ b/src/mongo/util/uuid.cpp @@ -43,7 +43,7 @@ namespace mongo { namespace { Mutex uuidGenMutex; -auto uuidGen = SecureRandom::create(); +SecureRandom uuidGen; // Regex to match valid version 4 UUIDs with variant bits set std::regex uuidRegex("[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}", @@ -97,19 +97,12 @@ bool UUID::isRFC4122v4() const { } UUID UUID::gen() { - int64_t randomWords[2]; - + UUIDStorage randomBytes; { stdx::lock_guard<Latch> lk(uuidGenMutex); - - // Generate 128 random bits - randomWords[0] = uuidGen->nextInt64(); - randomWords[1] = uuidGen->nextInt64(); + uuidGen.fill(&randomBytes, sizeof(randomBytes)); } - UUIDStorage randomBytes; - memcpy(&randomBytes, randomWords, sizeof(randomBytes)); - // Set version in high 4 bits of byte 6 and variant in high 2 bits of byte 8, see RFC 4122, // section 4.1.1, 4.1.2 and 4.1.3. randomBytes[6] &= 0x0f; |