From c8538123a7618343056b8ca2bc7445de8f0620ec Mon Sep 17 00:00:00 2001 From: Jonas Schnelli Date: Sun, 5 Nov 2017 16:34:40 -1000 Subject: [PATCH 1/2] Update ban-state in case of dirty-state during periodic sweep --- src/net.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/net.cpp b/src/net.cpp index 258599747a6..58601096472 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -612,6 +612,11 @@ void CConnman::SweepBanned() else ++it; } + + // update UI + if(setBannedIsDirty && clientInterface) { + clientInterface->BannedListChanged(); + } } bool CConnman::BannedSetIsDirty() From 57ac471a294fc7039140eed91d217ad1af7fa7af Mon Sep 17 00:00:00 2001 From: Jonas Schnelli Date: Sat, 18 Nov 2017 21:38:27 -1000 Subject: [PATCH 2/2] Call BannedListChanged outside of cs_setBanned lock --- src/net.cpp | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/net.cpp b/src/net.cpp index 58601096472..0e6a490e30c 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -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(); } }