Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V0.12.0.x locks fixes #496

Merged
merged 2 commits into from
Aug 9, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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