Skip to content

Commit

Permalink
Merge pull request #496 from UdjinM6/v0.12.0.x_locks_fixes
Browse files Browse the repository at this point in the history
V0.12.0.x locks fixes
  • Loading branch information
evan82 committed Aug 9, 2015
2 parents d6ab60b + 84264b0 commit d54d64d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/darksend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ bool CDarksendPool::SetCollateralAddress(std::string strAddress){
void CDarksendPool::UnlockCoins(){
while(true) {
TRY_LOCK(pwalletMain->cs_wallet, lockWallet);
if(!lockWallet) {MilliSleep(10); continue;}
if(!lockWallet) {MilliSleep(50); continue;}
BOOST_FOREACH(CTxIn v, lockedCoins)
pwalletMain->UnlockCoin(v.prevout);
break;
Expand Down Expand Up @@ -1161,7 +1161,7 @@ void CDarksendPool::SendDarksendDenominate(std::vector<CTxIn>& vin, std::vector<

while(true){
TRY_LOCK(cs_main, lockMain);
if(!lockMain) { MilliSleep(10); continue;}
if(!lockMain) { MilliSleep(50); continue;}
if(!AcceptableInputs(mempool, state, CTransaction(tx), false, NULL, false, true)){
LogPrintf("dsi -- transaction not valid! %s \n", tx.ToString());
UnlockCoins();
Expand Down
11 changes: 7 additions & 4 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,11 @@ CNodeState *State(NodeId pnode) {

int GetHeight()
{
LOCK(cs_main);
return chainActive.Height();
while(true){
TRY_LOCK(cs_main, lockMain);
if(!lockMain) { MilliSleep(50); continue; }
return chainActive.Height();
}
}

void UpdatePreferredDownload(CNode* node, CNodeState* state)
Expand Down Expand Up @@ -2618,7 +2621,7 @@ bool ActivateBestChain(CValidationState &state, CBlock *pblock) {
bool fInitialDownload;
while(true) {
TRY_LOCK(cs_main, lockMain);
if(!lockMain) { MilliSleep(10); continue; }
if(!lockMain) { MilliSleep(50); continue; }

pindexMostWork = FindMostWorkChain();

Expand Down Expand Up @@ -3266,7 +3269,7 @@ bool ProcessNewBlock(CValidationState &state, CNode* pfrom, CBlock* pblock, CDis

while(true) {
TRY_LOCK(cs_main, lockMain);
if(!lockMain) { MilliSleep(10); continue; }
if(!lockMain) { MilliSleep(50); continue; }

MarkBlockAsReceived(pblock->GetHash());
if (!checked) {
Expand Down
13 changes: 11 additions & 2 deletions src/rpcserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1017,8 +1017,17 @@ json_spirit::Value CRPCTable::execute(const std::string &strMethod, const json_s
LOCK(cs_main);
result = pcmd->actor(params, false);
} else {
LOCK2(cs_main, pwalletMain->cs_wallet);
result = pcmd->actor(params, false);
while (true) {
TRY_LOCK(cs_main, lockMain);
if(!lockMain) { MilliSleep(50); continue; }
while (true) {
TRY_LOCK(pwalletMain->cs_wallet, lockWallet);
if(!lockMain) { MilliSleep(50); continue; }
result = pcmd->actor(params, false);
break;
}
break;
}
}
#else // ENABLE_WALLET
else {
Expand Down

0 comments on commit d54d64d

Please sign in to comment.