Call BannedListChanged outside of cs_setBanned lock

This commit is contained in:
Jonas Schnelli 2017-11-18 21:38:27 -10:00
parent c8538123a7
commit 57ac471a29
No known key found for this signature in database
GPG key ID: 1EB776BB03C7922D

View file

@ -596,7 +596,8 @@ void CConnman::SetBanned(const banmap_t &banMap)
void CConnman::SweepBanned() void CConnman::SweepBanned()
{ {
int64_t now = GetTime(); int64_t now = GetTime();
bool notifyUI = false;
{
LOCK(cs_setBanned); LOCK(cs_setBanned);
banmap_t::iterator it = setBanned.begin(); banmap_t::iterator it = setBanned.begin();
while(it != setBanned.end()) while(it != setBanned.end())
@ -607,14 +608,15 @@ void CConnman::SweepBanned()
{ {
setBanned.erase(it++); setBanned.erase(it++);
setBannedIsDirty = true; setBannedIsDirty = true;
notifyUI = true;
LogPrint(BCLog::NET, "%s: Removed banned node ip/subnet from banlist.dat: %s\n", __func__, subNet.ToString()); LogPrint(BCLog::NET, "%s: Removed banned node ip/subnet from banlist.dat: %s\n", __func__, subNet.ToString());
} }
else else
++it; ++it;
} }
}
// update UI // update UI
if(setBannedIsDirty && clientInterface) { if(notifyUI && clientInterface) {
clientInterface->BannedListChanged(); clientInterface->BannedListChanged();
} }
} }