From 0dda75447f8715856cc8a79eadea7b96a4c7acf4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathieu=20Border=C3=A9?= Date: Tue, 27 Apr 2021 16:08:12 +0200 Subject: [PATCH] uv: seed the PRNG --- src/uv.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/uv.c b/src/uv.c index 53aa91061..ababe6c48 100644 --- a/src/uv.c +++ b/src/uv.c @@ -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)); }