aboutsummaryrefslogtreecommitdiff
path: root/src/banman.cpp
diff options
context:
space:
mode:
authorHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2022-01-26 16:38:21 +0200
committerHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2022-01-28 19:27:25 +0000
commit33bda6ab87cc1b569e96da337296eb3e9ce6db1a (patch)
tree5bc2366b6a5cdca8986db86f594ed0d205072e53 /src/banman.cpp
parent5e20e9ec3859205c220867ca49efb752b8edaacc (diff)
downloadbitcoin-33bda6ab87cc1b569e96da337296eb3e9ce6db1a.tar.xz
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.
Diffstat (limited to 'src/banman.cpp')
-rw-r--r--src/banman.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/banman.cpp b/src/banman.cpp
index 7fa489b051..2b029198db 100644
--- a/src/banman.cpp
+++ b/src/banman.cpp
@@ -43,9 +43,11 @@ void BanMan::DumpBanlist()
static Mutex dump_mutex;
LOCK(dump_mutex);
- SweepBanned(); // clean unused entries (if bantime has expired)
-
- if (!BannedSetIsDirty()) return;
+ {
+ LOCK(m_cs_banned);
+ SweepBanned();
+ if (!BannedSetIsDirty()) return;
+ }
int64_t n_start = GetTimeMillis();