diff options
author | Pieter Wuille <pieter.wuille@gmail.com> | 2013-07-25 02:34:42 +0200 |
---|---|---|
committer | Pieter Wuille <pieter.wuille@gmail.com> | 2013-10-15 22:34:25 +0200 |
commit | 7d38af3c493f9ea24c722ec2e6d3c51f4e851364 (patch) | |
tree | d77ceb6b56ef3cd5ad9720fff44f5c0191187389 /src/main.cpp | |
parent | 49d754d91522f5eceec7b6a6aef2e027009a7b67 (diff) |
Push down cs_main locking in ProcessMessage
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/src/main.cpp b/src/main.cpp index 0c31655fe9..f2e6b67f8a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3278,6 +3278,8 @@ void static ProcessGetData(CNode* pfrom) vector<CInv> vNotFound; + LOCK(cs_main); + while (it != pfrom->vRecvGetData.end()) { // Don't bother if send buffer is too full to respond anyway if (pfrom->nSendSize >= SendBufferSize()) @@ -3450,7 +3452,6 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) pfrom->fClient = !(pfrom->nServices & NODE_NETWORK); - AddTimeData(pfrom->addr, nTime); // Change version pfrom->PushMessage("verack"); @@ -3492,6 +3493,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) LogPrintf("receive version message: version %d, blocks=%d, us=%s, them=%s, peer=%s\n", pfrom->nVersion, pfrom->nStartingHeight, addrMe.ToString().c_str(), addrFrom.ToString().c_str(), pfrom->addr.ToString().c_str()); + LOCK(cs_main); + AddTimeData(pfrom->addr, nTime); cPeerBlockCounts.input(pfrom->nStartingHeight); } @@ -3595,6 +3598,9 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) break; } } + + LOCK(cs_main); + for (unsigned int nInv = 0; nInv < vInv.size(); nInv++) { const CInv &inv = vInv[nInv]; @@ -3652,6 +3658,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) uint256 hashStop; vRecv >> locator >> hashStop; + LOCK(cs_main); + // Find the last block the caller has in the main chain CBlockIndex* pindex = locator.GetBlockIndex(); @@ -3686,6 +3694,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) uint256 hashStop; vRecv >> locator >> hashStop; + LOCK(cs_main); + CBlockIndex* pindex = NULL; if (locator.IsNull()) { @@ -3728,6 +3738,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) CInv inv(MSG_TX, tx.GetHash()); pfrom->AddInventoryKnown(inv); + LOCK(cs_main); + bool fMissingInputs = false; CValidationState state; if (mempool.accept(state, tx, true, &fMissingInputs)) @@ -3802,6 +3814,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) CInv inv(MSG_BLOCK, block.GetHash()); pfrom->AddInventoryKnown(inv); + LOCK(cs_main); + CValidationState state; if (ProcessBlock(state, pfrom, &block)) mapAlreadyAskedFor.erase(inv); @@ -3823,6 +3837,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) else if (strCommand == "mempool") { + LOCK(cs_main); + std::vector<uint256> vtxid; LOCK2(mempool.cs, pfrom->cs_filter); mempool.queryHashes(vtxid); @@ -4088,10 +4104,7 @@ bool ProcessMessages(CNode* pfrom) bool fRet = false; try { - { - LOCK(cs_main); - fRet = ProcessMessage(pfrom, strCommand, vRecv); - } + fRet = ProcessMessage(pfrom, strCommand, vRecv); boost::this_thread::interruption_point(); } catch (std::ios_base::failure& e) |