Skip to content

Commit 33bda6a

Browse files
committed
Fix data race condition in BanMan::DumpBanlist()
The m_is_dirty value being read in BannedSetIsDirty() can differ from the value being set in SweepBanned(), i.e., be inconsistent with a BanMan instance internal state.
1 parent 5e20e9e commit 33bda6a

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/banman.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,11 @@ void BanMan::DumpBanlist()
4343
static Mutex dump_mutex;
4444
LOCK(dump_mutex);
4545

46-
SweepBanned(); // clean unused entries (if bantime has expired)
47-
48-
if (!BannedSetIsDirty()) return;
46+
{
47+
LOCK(m_cs_banned);
48+
SweepBanned();
49+
if (!BannedSetIsDirty()) return;
50+
}
4951

5052
int64_t n_start = GetTimeMillis();
5153

0 commit comments

Comments
 (0)