From e6d47f233b8b67747fa7b2eb9c6e75ccdab21804 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sun, 24 Oct 2010 18:35:32 -0400 Subject: [PATCH] Bug - Duplicate UUIDs under Cygwin - Fixed bug caused by using a high-resolution timer (gettimeofday) on Windows, which only has a 10ms resolution timer. Consequently the random number seed used was from a significantly reduced pool, which leads to duplicate UUIDs. --- src/main.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 2ea3b5bd1..1120fb8f9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -27,7 +27,7 @@ #include #include -#include +#include #include "Context.h" #include "../auto.h" @@ -36,12 +36,10 @@ Context context; int main (int argc, char** argv) { // Set up randomness. - struct timeval tv; - gettimeofday (&tv, NULL); #ifdef HAVE_SRANDOM - srandom (tv.tv_usec); + srandom (time (NULL)); #else - srand (tv.tv_usec); + srand (time (NULL)); #endif int status = 0;