Skip to content

Commit c94b121

Browse files
authored
impl(common): improve InvocationIdGenerator seed (#13711)
Use `MakeDefaultPRNG()` to initialize the PRNG (pseudo-random number generator) in `InvocationIdGenerator`. This function consumes the same amount of entropy from the OS as the previous call, but uses `std::seed_seq` to fill the initial state of the PRNG. AFAIK, `std::seed_seq` produces better distributed seeds from the same entropy.
1 parent 89db20a commit c94b121

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

google/cloud/internal/invocation_id_generator.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ namespace internal {
2424

2525
// Initialize the random bit source with some minimal entropy.
2626
InvocationIdGenerator::InvocationIdGenerator()
27-
: generator_(std::random_device{}()) {}
27+
: generator_(MakeDefaultPRNG()) {}
2828

2929
std::string InvocationIdGenerator::MakeInvocationId() {
3030
// A retry id is supposed to be a UUID V4 string. We assume you have read the

0 commit comments

Comments
 (0)