diff --git a/libretroshare/src/services/p3gxsreputation.cc b/libretroshare/src/services/p3gxsreputation.cc index aa64bec14..0152909ef 100644 --- a/libretroshare/src/services/p3gxsreputation.cc +++ b/libretroshare/src/services/p3gxsreputation.cc @@ -451,24 +451,25 @@ void p3GxsReputation::cleanup() ++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 should_set_to_positive ; + std::list should_set_to_positive_candidates ; + if(mAutoSetPositiveOptionToContacts) { RsStackMutex stack(mReputationMtx); /****** LOCKED MUTEX *******/ for(std::map::iterator it(mReputations.begin());it!=mReputations.end();++it) - { - bool is_a_contact = rsIdentity->isARegularContact(it->first) ; - - if(mAutoSetPositiveOptionToContacts && is_a_contact && it->second.mOwnOpinion == RsReputations::OPINION_NEUTRAL) - should_set_to_positive.push_back(it->first) ; - } + if(it->second.mOwnOpinion == RsReputations::OPINION_NEUTRAL) + should_set_to_positive_candidates.push_back(it->first) ; } - for(std::list::const_iterator it(should_set_to_positive.begin());it!=should_set_to_positive.end();++it) - setOwnOpinion(*it,RsReputations::OPINION_POSITIVE) ; + for(std::list::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) ; } }