Skip to content

Commit

Permalink
Few more lock-related fixes:
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
UdjinM6 committed Aug 4, 2015
1 parent ff159ad commit 7d78c98
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 36 deletions.
11 changes: 1 addition & 10 deletions src/darksend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
21 changes: 8 additions & 13 deletions src/instantx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<CInv> 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);

Expand Down Expand Up @@ -161,12 +161,7 @@ void ProcessMessageInstantX(CNode* pfrom, std::string& strCommand, CDataStream&
mapUnknownVotes[ctx.vinMasternode.prevout.hash] = GetTime()+(60*10);
}
}
vector<CInv> vInv;
vInv.push_back(inv);
LOCK(cs_vNodes);
BOOST_FOREACH(CNode* pnode, vNodes)
pnode->PushMessage("inv", vInv);

RelayInv(inv);
}

return;
Expand Down
13 changes: 0 additions & 13 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}
}
}

Expand Down

0 comments on commit 7d78c98

Please sign in to comment.