From 0b47e0098e8510b2e36a38036c88e64882c9f874 Mon Sep 17 00:00:00 2001 From: Timo Sirainen Date: Thu, 2 Dec 2010 22:59:42 +0000 Subject: [PATCH] lib_init(): Call srand() with a bit better seed. --- src/lib/lib.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/lib/lib.c b/src/lib/lib.c index bb832e7dd0..b9d87c7c8a 100644 --- a/src/lib/lib.c +++ b/src/lib/lib.c @@ -6,7 +6,8 @@ #include "process-title.h" #include -#include +#include +#include size_t nearest_power(size_t num) { @@ -20,8 +21,12 @@ size_t nearest_power(size_t num) void lib_init(void) { + struct timeval tv; + /* standard way to get rand() return different values. */ - srand((unsigned int) time(NULL)); + if (gettimeofday(&tv, NULL) < 0) + i_fatal("gettimeofday(): %m"); + srand((unsigned int) (tv.tv_sec ^ tv.tv_usec ^ getpid())); data_stack_init(); hostpid_init(); -- 2.47.3