Skip to content

Commit

Permalink
Call BannedListChanged outside of cs_setBanned lock
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasschnelli committed Nov 19, 2017
1 parent c853812 commit 57ac471
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions src/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -596,25 +596,27 @@ void CConnman::SetBanned(const banmap_t &banMap)
void CConnman::SweepBanned()
{
int64_t now = GetTime();

LOCK(cs_setBanned);
banmap_t::iterator it = setBanned.begin();
while(it != setBanned.end())
bool notifyUI = false;
{
CSubNet subNet = (*it).first;
CBanEntry banEntry = (*it).second;
if(now > banEntry.nBanUntil)
LOCK(cs_setBanned);
banmap_t::iterator it = setBanned.begin();
while(it != setBanned.end())
{
setBanned.erase(it++);
setBannedIsDirty = true;
LogPrint(BCLog::NET, "%s: Removed banned node ip/subnet from banlist.dat: %s\n", __func__, subNet.ToString());
CSubNet subNet = (*it).first;
CBanEntry banEntry = (*it).second;
if(now > banEntry.nBanUntil)
{
setBanned.erase(it++);
setBannedIsDirty = true;
notifyUI = true;
LogPrint(BCLog::NET, "%s: Removed banned node ip/subnet from banlist.dat: %s\n", __func__, subNet.ToString());
}
else
++it;
}
else
++it;
}

// update UI
if(setBannedIsDirty && clientInterface) {
if(notifyUI && clientInterface) {
clientInterface->BannedListChanged();
}
}
Expand Down

0 comments on commit 57ac471

Please sign in to comment.