From 1a95488a4ffee2312ff23dd4155443c3018e5cfa Mon Sep 17 00:00:00 2001 From: Nishant Chaprana Date: Mon, 20 Sep 2021 14:39:21 +0530 Subject: [PATCH] Use rand_r() instead of rand() Change-Id: I540778e549bb0e46271db3ce3e0b5fb967d8e84e Signed-off-by: Nishant Chaprana --- plugin/online-monitor/url-checker.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin/online-monitor/url-checker.c b/plugin/online-monitor/url-checker.c index 467b990..43dad20 100755 --- a/plugin/online-monitor/url-checker.c +++ b/plugin/online-monitor/url-checker.c @@ -110,9 +110,9 @@ static void _get_url(char **url) /* Generate a random number in range [0, 5] */ const int max_url = 6; + unsigned int seed = time(0); - srand(time(0)); - int index = (rand() % max_url); + int index = (rand_r(&seed) % max_url); *url = g_strdup(config->url_list[index]); } -- 2.34.1