mirror of
https://github.com/NixOS/nix
synced 2025-06-27 04:21:16 +02:00
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.
This commit is contained in:
parent
e087bfef5f
commit
772778c0ec
2 changed files with 7 additions and 1 deletions
|
@ -10,6 +10,7 @@
|
|||
#include <cctype>
|
||||
#include <exception>
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue