mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-08 10:31:50 -05:00
Fix race condition for SetBannedSetDirty() calls
Another thread can `SetBannedSetDirty(true)` while `CBanDB::Write()` call being executed. The following `SetBannedSetDirty(false)` effectively makes `m_is_dirty` flag value inconsistent with the actual `m_banned` state. Such behavior can result in data loss, e.g., during shutdown.
This commit is contained in:
parent
83c7646715
commit
99a6b699cd
1 changed files with 3 additions and 2 deletions
|
@ -49,11 +49,12 @@ void BanMan::DumpBanlist()
|
|||
SweepBanned();
|
||||
if (!BannedSetIsDirty()) return;
|
||||
banmap = m_banned;
|
||||
SetBannedSetDirty(false);
|
||||
}
|
||||
|
||||
int64_t n_start = GetTimeMillis();
|
||||
if (m_ban_db.Write(banmap)) {
|
||||
SetBannedSetDirty(false);
|
||||
if (!m_ban_db.Write(banmap)) {
|
||||
SetBannedSetDirty(true);
|
||||
}
|
||||
|
||||
LogPrint(BCLog::NET, "Flushed %d banned node addresses/subnets to disk %dms\n", banmap.size(),
|
||||
|
|
Loading…
Add table
Reference in a new issue