Commit beda3fc9 authored by UdjinM6's avatar UdjinM6
Browse files

more trylock+wait: rpc, GetHeight

parent 177125ac
Showing with 16 additions and 4 deletions
+16 -4
......@@ -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(10); continue; }
return chainActive.Height();
}
}
void UpdatePreferredDownload(CNode* node, CNodeState* state)
......
......@@ -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 {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment