Fix sleep

Signed-off-by: Anthony Fieroni <bvbfan@abv.bg>
This commit is contained in:
Anthony Fieroni 2019-11-25 15:08:02 +02:00
parent 17a4ded0ca
commit 1cc1b0fb80

View file

@ -5,8 +5,10 @@
#include <trie.h> #include <trie.h>
#include <algorithm> #include <algorithm>
#include <chrono>
#include <memory> #include <memory>
#include <iomanip> #include <iomanip>
#include <thread>
#include <tuple> #include <tuple>
#include <boost/container/flat_map.hpp> #include <boost/container/flat_map.hpp>
@ -466,20 +468,23 @@ bool CClaimTrieCacheBase::flush()
{ {
if (transacting) { if (transacting) {
getMerkleHash(); getMerkleHash();
RETRY_COMMIT: do {
try { try {
db << "commit"; db << "commit";
} } catch (const sqlite::sqlite_exception& e) {
catch (const sqlite::sqlite_exception& e) {
logPrint << "ERROR in ClaimTrieCache flush: " << e.what() << Clog::endl;
auto code = e.get_code(); auto code = e.get_code();
if (code == SQLITE_LOCKED || code == SQLITE_BUSY) { if (code == SQLITE_LOCKED || code == SQLITE_BUSY) {
LogPrintf("Retrying the commit in one second.\n", e.what()); logPrint << "Retrying the commit in one second." << Clog::endl;
MilliSleep(1000); using namespace std::chrono_literals;
goto RETRY_COMMIT; std::this_thread::sleep_for(1s);
} continue;
} else {
logPrint << "ERROR in ClaimTrieCache::" << __func__ << "(): " << e.what() << Clog::endl;
return false; return false;
} }
}
break;
} while (true);
transacting = false; transacting = false;
} }
base->nNextHeight = nNextHeight; base->nNextHeight = nNextHeight;