Skip to content
This repository has been archived by the owner on Mar 4, 2024. It is now read-only.

uv: seed the PRNG #197

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/uv.c
Expand Up @@ -594,7 +594,12 @@ static raft_time uvTime(struct raft_io *io)
/* Implementation of raft_io->random. */
static int uvRandom(struct raft_io *io, int min, int max)
{
(void)io;
static bool initialized = false;
if (!initialized) {
struct uv *uv = io->impl;
srand((unsigned)uv_now(uv->loop) + (unsigned)uv->id);
initialized = true;
}
return min + (abs(rand()) % (max - min));
}

Expand Down