diff --git a/lix/libstore/sqlite.cc b/lix/libstore/sqlite.cc index 217f470a2..bf88b7142 100644 --- a/lix/libstore/sqlite.cc +++ b/lix/libstore/sqlite.cc @@ -5,9 +5,10 @@ #include "lix/libutil/signals.hh" #include "lix/libutil/url.hh" -#include #include +#include +#include namespace nix { @@ -284,12 +285,10 @@ void handleSQLiteBusy(const SQLiteBusy & e, time_t & nextWarning) /* Sleep for a while since retrying the transaction right away is likely to fail again. */ checkInterrupt(); - static thread_local std::default_random_engine generator(clock()); + static thread_local std::default_random_engine generator(std::random_device{}()); std::uniform_int_distribution uniform_dist(0, 100); - struct timespec t; - t.tv_sec = 0; - t.tv_nsec = uniform_dist(generator) * 1000 * 1000; /* <= 0.1s */ - nanosleep(&t, 0); + /* <= 0.1s */ + std::this_thread::sleep_for(std::chrono::milliseconds { uniform_dist(generator) }); } }