Fix locking order (#1252)
* Add cs_main locks prior to governance locks to ensure correct locking order
This commit is contained in:
parent
0c2304e24f
commit
3b9a748d5e
@ -155,7 +155,7 @@ void CGovernanceManager::ProcessMessage(CNode* pfrom, std::string& strCommand, C
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOCK(cs);
|
LOCK2(cs_main, cs);
|
||||||
|
|
||||||
if(mapSeenGovernanceObjects.count(nHash)) {
|
if(mapSeenGovernanceObjects.count(nHash)) {
|
||||||
// TODO - print error code? what if it's GOVOBJ_ERROR_IMMATURE?
|
// TODO - print error code? what if it's GOVOBJ_ERROR_IMMATURE?
|
||||||
@ -284,7 +284,7 @@ void CGovernanceManager::CheckOrphanVotes(CGovernanceObject& govobj, CGovernance
|
|||||||
|
|
||||||
bool CGovernanceManager::AddGovernanceObject(CGovernanceObject& govobj)
|
bool CGovernanceManager::AddGovernanceObject(CGovernanceObject& govobj)
|
||||||
{
|
{
|
||||||
LOCK(cs);
|
LOCK2(cs_main, cs);
|
||||||
std::string strError = "";
|
std::string strError = "";
|
||||||
|
|
||||||
DBG( cout << "CGovernanceManager::AddGovernanceObject START" << endl; );
|
DBG( cout << "CGovernanceManager::AddGovernanceObject START" << endl; );
|
||||||
@ -564,8 +564,9 @@ void CGovernanceManager::NewBlock()
|
|||||||
// IF WE'RE NOT SYNCED, EXIT
|
// IF WE'RE NOT SYNCED, EXIT
|
||||||
if(!masternodeSync.IsSynced()) return;
|
if(!masternodeSync.IsSynced()) return;
|
||||||
|
|
||||||
TRY_LOCK(cs, fBudgetNewBlock);
|
if(!pCurrentBlockIndex) return;
|
||||||
if(!fBudgetNewBlock || !pCurrentBlockIndex) return;
|
LOCK(cs);
|
||||||
|
|
||||||
|
|
||||||
// CHECK OBJECTS WE'VE ASKED FOR, REMOVE OLD ENTRIES
|
// CHECK OBJECTS WE'VE ASKED FOR, REMOVE OLD ENTRIES
|
||||||
|
|
||||||
@ -652,7 +653,7 @@ void CGovernanceManager::Sync(CNode* pfrom, uint256 nProp)
|
|||||||
LogPrint("gobject", "CGovernanceManager::Sync -- syncing to peer=%d, nProp = %s\n", pfrom->id, nProp.ToString());
|
LogPrint("gobject", "CGovernanceManager::Sync -- syncing to peer=%d, nProp = %s\n", pfrom->id, nProp.ToString());
|
||||||
|
|
||||||
{
|
{
|
||||||
LOCK(cs);
|
LOCK2(cs_main, cs);
|
||||||
fRateChecksEnabled = false;
|
fRateChecksEnabled = false;
|
||||||
for(object_m_it it = mapObjects.begin(); it != mapObjects.end(); ++it) {
|
for(object_m_it it = mapObjects.begin(); it != mapObjects.end(); ++it) {
|
||||||
uint256 h = it->first;
|
uint256 h = it->first;
|
||||||
|
Loading…
Reference in New Issue
Block a user