From 7d78c98f0d63491623ec49a3ed3d312ded683a17 Mon Sep 17 00:00:00 2001 From: UdjinM6 Date: Wed, 5 Aug 2015 01:49:34 +0300 Subject: [PATCH] Few more lock-related fixes: - do not lock cs_main for mnodeman.CheckAndRemove() - we have trylock inside CMasternode.Check, should be enough - fast cs_main lock for ix - use RelayInv instead of manually locking nodes / pushing inv - do not lock cs_vNodes / ClearFulfilledRequest on every 100th block, CMasternodeSync should already handle resync by itself better now --- src/darksend.cpp | 11 +---------- src/instantx.cpp | 21 ++++++++------------- src/main.cpp | 13 ------------- 3 files changed, 9 insertions(+), 36 deletions(-) diff --git a/src/darksend.cpp b/src/darksend.cpp index dd16c143d3..8235cd511e 100644 --- a/src/darksend.cpp +++ b/src/darksend.cpp @@ -2219,16 +2219,7 @@ void ThreadCheckDarkSendPool() if(c % 60 == 0) { - { - LOCK(cs_main); - /* - cs_main is required for doing CMasternode.Check because something - is modifying the coins view without a mempool lock. It causes - segfaults from this code without the cs_main lock. - */ - mnodeman.CheckAndRemove(); - } - + mnodeman.CheckAndRemove(); mnodeman.ProcessMasternodeConnections(); masternodePayments.CleanPaymentList(); CleanTransactionLocksList(); diff --git a/src/instantx.cpp b/src/instantx.cpp index b834454b01..1f08fd07d9 100644 --- a/src/instantx.cpp +++ b/src/instantx.cpp @@ -70,14 +70,14 @@ void ProcessMessageInstantX(CNode* pfrom, std::string& strCommand, CDataStream& bool fMissingInputs = false; CValidationState state; - LOCK(cs_main); - if (AcceptToMemoryPool(mempool, state, tx, true, &fMissingInputs)) + bool fAccepted = false; { - vector vInv; - vInv.push_back(inv); - LOCK(cs_vNodes); - BOOST_FOREACH(CNode* pnode, vNodes) - pnode->PushMessage("inv", vInv); + LOCK(cs_main); + fAccepted = AcceptToMemoryPool(mempool, state, tx, true, &fMissingInputs); + } + if (fAccepted) + { + RelayInv(inv); DoConsensusVote(tx, nBlockHeight); @@ -161,12 +161,7 @@ void ProcessMessageInstantX(CNode* pfrom, std::string& strCommand, CDataStream& mapUnknownVotes[ctx.vinMasternode.prevout.hash] = GetTime()+(60*10); } } - vector vInv; - vInv.push_back(inv); - LOCK(cs_vNodes); - BOOST_FOREACH(CNode* pnode, vNodes) - pnode->PushMessage("inv", vInv); - + RelayInv(inv); } return; diff --git a/src/main.cpp b/src/main.cpp index adeabc4e43..5e2ccee54c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3279,22 +3279,9 @@ bool ProcessNewBlock(CValidationState &state, CNode* pfrom, CBlock* pblock, CDis if(!fLiteMode){ if (masternodeSync.RequestedMasternodeAssets > MASTERNODE_SYNC_LIST) { - CScript payee; - CTxIn vin; darkSendPool.NewBlock(); masternodePayments.ProcessBlock(GetHeight()+10); budget.NewBlock(); - - //allow clients to ask for syncing again if they need it - if(GetHeight() % 100 == 0) { - LOCK(cs_vNodes); - BOOST_FOREACH(CNode* pnode, vNodes) { - pnode->ClearFulfilledRequest("getspork"); - pnode->ClearFulfilledRequest("mnsync"); - pnode->ClearFulfilledRequest("mnwsync"); - pnode->ClearFulfilledRequest("busync"); - } - } } }