mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-28 17:09:34 -05:00
fixed deadlock caused by locking the mutex in p3Identity after the one in p3GxsReputation
This commit is contained in:
parent
f90ebb1dfc
commit
7327f1a98b
@ -451,23 +451,24 @@ void p3GxsReputation::cleanup()
|
|||||||
++it ;
|
++it ;
|
||||||
}
|
}
|
||||||
|
|
||||||
// update opinions based on flags and contact information
|
// Update opinions based on flags and contact information.
|
||||||
|
// Note: the call to rsIdentity->isARegularContact() is done off-mutex, in order to avoid a cross-deadlock, as
|
||||||
|
// normally, p3GxsReputation gets called by p3dentity and not te reverse. That explains the weird implementation
|
||||||
|
// of these two loops.
|
||||||
{
|
{
|
||||||
std::list<RsGxsId> should_set_to_positive ;
|
std::list<RsGxsId> should_set_to_positive_candidates ;
|
||||||
|
|
||||||
|
if(mAutoSetPositiveOptionToContacts)
|
||||||
{
|
{
|
||||||
RsStackMutex stack(mReputationMtx); /****** LOCKED MUTEX *******/
|
RsStackMutex stack(mReputationMtx); /****** LOCKED MUTEX *******/
|
||||||
|
|
||||||
for(std::map<RsGxsId,Reputation>::iterator it(mReputations.begin());it!=mReputations.end();++it)
|
for(std::map<RsGxsId,Reputation>::iterator it(mReputations.begin());it!=mReputations.end();++it)
|
||||||
{
|
if(it->second.mOwnOpinion == RsReputations::OPINION_NEUTRAL)
|
||||||
bool is_a_contact = rsIdentity->isARegularContact(it->first) ;
|
should_set_to_positive_candidates.push_back(it->first) ;
|
||||||
|
|
||||||
if(mAutoSetPositiveOptionToContacts && is_a_contact && it->second.mOwnOpinion == RsReputations::OPINION_NEUTRAL)
|
|
||||||
should_set_to_positive.push_back(it->first) ;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for(std::list<RsGxsId>::const_iterator it(should_set_to_positive.begin());it!=should_set_to_positive.end();++it)
|
for(std::list<RsGxsId>::const_iterator it(should_set_to_positive_candidates.begin());it!=should_set_to_positive_candidates.end();++it)
|
||||||
|
if(rsIdentity->isARegularContact(*it))
|
||||||
setOwnOpinion(*it,RsReputations::OPINION_POSITIVE) ;
|
setOwnOpinion(*it,RsReputations::OPINION_POSITIVE) ;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user