From 772778c0eced8f8d63bfe6b1e9801ad6aada65bf Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 11 Dec 2012 11:49:42 +0100 Subject: On SQLITE_BUSY, wait a random amount of time If all contending processes wait a fixed amount of time (100 ms), there is a good probability that they'll just collide again. --- src/libmain/shared.cc | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/libmain/shared.cc') diff --git a/src/libmain/shared.cc b/src/libmain/shared.cc index ead3fc017ae2..e869ef0379ad 100644 --- a/src/libmain/shared.cc +++ b/src/libmain/shared.cc @@ -10,6 +10,7 @@ #include #include +#include #include #include @@ -135,6 +136,11 @@ static void initAndRun(int argc, char * * argv) everybody. */ umask(0022); + /* Initialise the PRNG. */ + struct timeval tv; + gettimeofday(&tv, 0); + srandom(tv.tv_usec); + /* Process the NIX_LOG_TYPE environment variable. */ string lt = getEnv("NIX_LOG_TYPE"); if (lt != "") setLogType(lt); -- cgit 1.4.1