Skip to content

Commit

Permalink
prevent double lock for 'm_banned_mutex'
Browse files Browse the repository at this point in the history
`BanMan::SweepBanned()` is only called internally in `src/banman.cpp`.
`BanMan::GetBanned()` locks 'm_banned_mutex' and then calls `BanMan::SweepBanned()`
without releasing the lock.
This commit changes `BanMan::GetBanned()` to lock 'm_banned_mutex' only after
`BanMan::SweepBanned()` releases it.
  • Loading branch information
w0xlt committed Jan 18, 2022
1 parent b43ad37 commit 5289e99
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/banman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,9 @@ bool BanMan::Unban(const CSubNet& sub_net)

void BanMan::GetBanned(banmap_t& banmap)
{
LOCK(m_banned_mutex);
// Sweep the banlist so expired bans are not returned
SweepBanned();
LOCK(m_banned_mutex);
banmap = m_banned; //create a thread safe copy
}

Expand Down

0 comments on commit 5289e99

Please sign in to comment.