mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-10 00:08:07 +02:00
Merge pull request #10399 from nix-windows/portable-sleep
Make SQLite busy back-off logic portable
This commit is contained in:
commit
6b889e0588
1 changed files with 3 additions and 4 deletions
|
@ -7,6 +7,7 @@
|
|||
#include <sqlite3.h>
|
||||
|
||||
#include <atomic>
|
||||
#include <thread>
|
||||
|
||||
namespace nix {
|
||||
|
||||
|
@ -256,10 +257,8 @@ void handleSQLiteBusy(const SQLiteBusy & e, time_t & nextWarning)
|
|||
/* Sleep for a while since retrying the transaction right away
|
||||
is likely to fail again. */
|
||||
checkInterrupt();
|
||||
struct timespec t;
|
||||
t.tv_sec = 0;
|
||||
t.tv_nsec = (random() % 100) * 1000 * 1000; /* <= 0.1s */
|
||||
nanosleep(&t, 0);
|
||||
/* <= 0.1s */
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds { rand() % 100 });
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue