Auto merge of #4387 - gladcow:issue3813_backport_upstream_11107, r=daira
Fix races in AppInitMain and others with lock and atomic bools (Bitcoin backport) Backport bitcoin https://github.com/bitcoin/bitcoin/pull/11107 (excluding the last commit, it was fixed in Zcash before). This functionality is required for https://github.com/zcash/zcash/pull/4368 (details https://github.com/zcash/zcash/pull/4368#issuecomment-595284681) as part of the issue https://github.com/zcash/zcash/issues/3813 resolution.
This commit is contained in:
commit
8c48786d7d
18
src/init.cpp
18
src/init.cpp
|
@ -1621,15 +1621,21 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
|
||||||
return InitError(strErrors.str());
|
return InitError(strErrors.str());
|
||||||
|
|
||||||
//// debug print
|
//// debug print
|
||||||
LogPrintf("mapBlockIndex.size() = %u\n", mapBlockIndex.size());
|
{
|
||||||
LogPrintf("nBestHeight = %d\n", chainActive.Height());
|
LOCK(cs_main);
|
||||||
|
LogPrintf("mapBlockIndex.size() = %u\n", mapBlockIndex.size());
|
||||||
|
LogPrintf("nBestHeight = %d\n", chainActive.Height());
|
||||||
|
}
|
||||||
#ifdef ENABLE_WALLET
|
#ifdef ENABLE_WALLET
|
||||||
LogPrintf("setKeyPool.size() = %u\n", pwalletMain ? pwalletMain->setKeyPool.size() : 0);
|
if (pwalletMain)
|
||||||
LogPrintf("mapWallet.size() = %u\n", pwalletMain ? pwalletMain->mapWallet.size() : 0);
|
{
|
||||||
LogPrintf("mapAddressBook.size() = %u\n", pwalletMain ? pwalletMain->mapAddressBook.size() : 0);
|
LOCK(pwalletMain->cs_wallet);
|
||||||
|
LogPrintf("setKeyPool.size() = %u\n", pwalletMain->setKeyPool.size());
|
||||||
|
LogPrintf("mapWallet.size() = %u\n", pwalletMain->mapWallet.size());
|
||||||
|
LogPrintf("mapAddressBook.size() = %u\n", pwalletMain->mapAddressBook.size());
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
if (GetBoolArg("-listenonion", DEFAULT_LISTEN_ONION))
|
if (GetBoolArg("-listenonion", DEFAULT_LISTEN_ONION))
|
||||||
StartTorControl(threadGroup, scheduler);
|
StartTorControl(threadGroup, scheduler);
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,7 @@ CConditionVariable cvBlockChange;
|
||||||
int nScriptCheckThreads = 0;
|
int nScriptCheckThreads = 0;
|
||||||
bool fExperimentalMode = false;
|
bool fExperimentalMode = false;
|
||||||
bool fImporting = false;
|
bool fImporting = false;
|
||||||
bool fReindex = false;
|
std::atomic_bool fReindex(false);
|
||||||
bool fTxIndex = false;
|
bool fTxIndex = false;
|
||||||
bool fInsightExplorer = false; // insightexplorer
|
bool fInsightExplorer = false; // insightexplorer
|
||||||
bool fAddressIndex = false; // insightexplorer
|
bool fAddressIndex = false; // insightexplorer
|
||||||
|
@ -4455,7 +4455,7 @@ bool static LoadBlockIndexDB()
|
||||||
// Check whether we need to continue reindexing
|
// Check whether we need to continue reindexing
|
||||||
bool fReindexing = false;
|
bool fReindexing = false;
|
||||||
pblocktree->ReadReindexing(fReindexing);
|
pblocktree->ReadReindexing(fReindexing);
|
||||||
fReindex |= fReindexing;
|
if(fReindexing) fReindex = true;
|
||||||
|
|
||||||
// Check whether we have a transaction index
|
// Check whether we have a transaction index
|
||||||
pblocktree->ReadFlag("txindex", fTxIndex);
|
pblocktree->ReadFlag("txindex", fTxIndex);
|
||||||
|
|
|
@ -139,7 +139,7 @@ extern CWaitableCriticalSection csBestBlock;
|
||||||
extern CConditionVariable cvBlockChange;
|
extern CConditionVariable cvBlockChange;
|
||||||
extern bool fExperimentalMode;
|
extern bool fExperimentalMode;
|
||||||
extern bool fImporting;
|
extern bool fImporting;
|
||||||
extern bool fReindex;
|
extern std::atomic_bool fReindex;
|
||||||
extern int nScriptCheckThreads;
|
extern int nScriptCheckThreads;
|
||||||
extern bool fTxIndex;
|
extern bool fTxIndex;
|
||||||
|
|
||||||
|
|
|
@ -107,12 +107,12 @@ private:
|
||||||
public:
|
public:
|
||||||
bool WriteBatchSync(const std::vector<std::pair<int, const CBlockFileInfo*> >& fileInfo, int nLastFile, const std::vector<const CBlockIndex*>& blockinfo);
|
bool WriteBatchSync(const std::vector<std::pair<int, const CBlockFileInfo*> >& fileInfo, int nLastFile, const std::vector<const CBlockIndex*>& blockinfo);
|
||||||
bool EraseBatchSync(const std::vector<const CBlockIndex*>& blockinfo);
|
bool EraseBatchSync(const std::vector<const CBlockIndex*>& blockinfo);
|
||||||
bool ReadBlockFileInfo(int nFile, CBlockFileInfo &fileinfo);
|
bool ReadBlockFileInfo(int nFile, CBlockFileInfo &info);
|
||||||
bool ReadLastBlockFile(int &nFile);
|
bool ReadLastBlockFile(int &nFile);
|
||||||
bool WriteReindexing(bool fReindex);
|
bool WriteReindexing(bool fReindexing);
|
||||||
bool ReadReindexing(bool &fReindex);
|
bool ReadReindexing(bool &fReindexing);
|
||||||
bool ReadTxIndex(const uint256 &txid, CDiskTxPos &pos);
|
bool ReadTxIndex(const uint256 &txid, CDiskTxPos &pos);
|
||||||
bool WriteTxIndex(const std::vector<std::pair<uint256, CDiskTxPos> > &list);
|
bool WriteTxIndex(const std::vector<std::pair<uint256, CDiskTxPos> > &vect);
|
||||||
|
|
||||||
// START insightexplorer
|
// START insightexplorer
|
||||||
bool UpdateAddressUnspentIndex(const std::vector<CAddressUnspentDbEntry> &vect);
|
bool UpdateAddressUnspentIndex(const std::vector<CAddressUnspentDbEntry> &vect);
|
||||||
|
|
Loading…
Reference in New Issue