Changeset View
Changeset View
Standalone View
Standalone View
src/init.cpp
Show First 20 Lines • Show All 959 Lines • ▼ Show 20 Lines | if (!strCmd.empty()) { | ||||
boost::replace_all(strCmd, "%s", pBlockIndex->GetBlockHash().GetHex()); | boost::replace_all(strCmd, "%s", pBlockIndex->GetBlockHash().GetHex()); | ||||
std::thread t(runCommand, strCmd); | std::thread t(runCommand, strCmd); | ||||
// thread runs free | // thread runs free | ||||
t.detach(); | t.detach(); | ||||
} | } | ||||
} | } | ||||
static bool fHaveGenesis = false; | static bool fHaveGenesis = false; | ||||
static CWaitableCriticalSection cs_GenesisWait; | static Mutex g_genesis_wait_mutex; | ||||
static CConditionVariable condvar_GenesisWait; | static std::condition_variable g_genesis_wait_cv; | ||||
static void BlockNotifyGenesisWait(bool, const CBlockIndex *pBlockIndex) { | static void BlockNotifyGenesisWait(bool, const CBlockIndex *pBlockIndex) { | ||||
if (pBlockIndex != nullptr) { | if (pBlockIndex != nullptr) { | ||||
{ | { | ||||
LOCK(cs_GenesisWait); | LOCK(g_genesis_wait_mutex); | ||||
fHaveGenesis = true; | fHaveGenesis = true; | ||||
} | } | ||||
condvar_GenesisWait.notify_all(); | g_genesis_wait_cv.notify_all(); | ||||
} | } | ||||
} | } | ||||
struct CImportingNow { | struct CImportingNow { | ||||
CImportingNow() { | CImportingNow() { | ||||
assert(fImporting == false); | assert(fImporting == false); | ||||
fImporting = true; | fImporting = true; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 1,279 Lines • ▼ Show 20 Lines | for (const std::string &strFile : gArgs.GetArgs("-loadblock")) { | ||||
vImportFiles.push_back(strFile); | vImportFiles.push_back(strFile); | ||||
} | } | ||||
threadGroup.create_thread( | threadGroup.create_thread( | ||||
boost::bind(&ThreadImport, std::ref(config), vImportFiles)); | boost::bind(&ThreadImport, std::ref(config), vImportFiles)); | ||||
// Wait for genesis block to be processed | // Wait for genesis block to be processed | ||||
{ | { | ||||
WAIT_LOCK(cs_GenesisWait, lock); | WAIT_LOCK(g_genesis_wait_mutex, lock); | ||||
// We previously could hang here if StartShutdown() is called prior to | // We previously could hang here if StartShutdown() is called prior to | ||||
// ThreadImport getting started, so instead we just wait on a timer to | // ThreadImport getting started, so instead we just wait on a timer to | ||||
// check ShutdownRequested() regularly. | // check ShutdownRequested() regularly. | ||||
while (!fHaveGenesis && !ShutdownRequested()) { | while (!fHaveGenesis && !ShutdownRequested()) { | ||||
condvar_GenesisWait.wait_for(lock, std::chrono::milliseconds(500)); | g_genesis_wait_cv.wait_for(lock, std::chrono::milliseconds(500)); | ||||
} | } | ||||
uiInterface.NotifyBlockTip.disconnect(BlockNotifyGenesisWait); | uiInterface.NotifyBlockTip.disconnect(BlockNotifyGenesisWait); | ||||
} | } | ||||
if (ShutdownRequested()) { | if (ShutdownRequested()) { | ||||
return false; | return false; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 95 Lines • Show Last 20 Lines |