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
This commit is contained in:
UdjinM6 2015-08-05 01:49:34 +03:00
parent ff159ad7e7
commit 7d78c98f0d
3 changed files with 9 additions and 36 deletions

View File

@ -2219,16 +2219,7 @@ void ThreadCheckDarkSendPool()
if(c % 60 == 0) if(c % 60 == 0)
{ {
{ mnodeman.CheckAndRemove();
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.ProcessMasternodeConnections(); mnodeman.ProcessMasternodeConnections();
masternodePayments.CleanPaymentList(); masternodePayments.CleanPaymentList();
CleanTransactionLocksList(); CleanTransactionLocksList();

View File

@ -70,14 +70,14 @@ void ProcessMessageInstantX(CNode* pfrom, std::string& strCommand, CDataStream&
bool fMissingInputs = false; bool fMissingInputs = false;
CValidationState state; CValidationState state;
LOCK(cs_main); bool fAccepted = false;
if (AcceptToMemoryPool(mempool, state, tx, true, &fMissingInputs))
{ {
vector<CInv> vInv; LOCK(cs_main);
vInv.push_back(inv); fAccepted = AcceptToMemoryPool(mempool, state, tx, true, &fMissingInputs);
LOCK(cs_vNodes); }
BOOST_FOREACH(CNode* pnode, vNodes) if (fAccepted)
pnode->PushMessage("inv", vInv); {
RelayInv(inv);
DoConsensusVote(tx, nBlockHeight); DoConsensusVote(tx, nBlockHeight);
@ -161,12 +161,7 @@ void ProcessMessageInstantX(CNode* pfrom, std::string& strCommand, CDataStream&
mapUnknownVotes[ctx.vinMasternode.prevout.hash] = GetTime()+(60*10); mapUnknownVotes[ctx.vinMasternode.prevout.hash] = GetTime()+(60*10);
} }
} }
vector<CInv> vInv; RelayInv(inv);
vInv.push_back(inv);
LOCK(cs_vNodes);
BOOST_FOREACH(CNode* pnode, vNodes)
pnode->PushMessage("inv", vInv);
} }
return; return;

View File

@ -3279,22 +3279,9 @@ bool ProcessNewBlock(CValidationState &state, CNode* pfrom, CBlock* pblock, CDis
if(!fLiteMode){ if(!fLiteMode){
if (masternodeSync.RequestedMasternodeAssets > MASTERNODE_SYNC_LIST) { if (masternodeSync.RequestedMasternodeAssets > MASTERNODE_SYNC_LIST) {
CScript payee;
CTxIn vin;
darkSendPool.NewBlock(); darkSendPool.NewBlock();
masternodePayments.ProcessBlock(GetHeight()+10); masternodePayments.ProcessBlock(GetHeight()+10);
budget.NewBlock(); 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");
}
}
} }
} }