aboutsummaryrefslogtreecommitdiff
path: root/src/addrman.h
diff options
context:
space:
mode:
authorHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2021-05-23 19:32:03 +0300
committerHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2021-06-14 17:28:37 +0300
commit187b7d2bb36e6de9cd960378021ebe690619a2ef (patch)
treea8e42308abeab4f243779915a9ebcb8474fccccc /src/addrman.h
parentf77d9c79aa41dab4285e95c9432cc6d853be67a3 (diff)
refactor: Avoid recursive locking in CAddrMan::Check
Diffstat (limited to 'src/addrman.h')
-rw-r--r--src/addrman.h9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/addrman.h b/src/addrman.h
index 600c524bce..3474153e36 100644
--- a/src/addrman.h
+++ b/src/addrman.h
@@ -585,12 +585,10 @@ public:
*/
std::vector<CAddress> GetAddr(size_t max_addresses, size_t max_pct, std::optional<Network> network)
{
+ LOCK(cs);
Check();
std::vector<CAddress> vAddr;
- {
- LOCK(cs);
- GetAddr_(vAddr, max_addresses, max_pct, network);
- }
+ GetAddr_(vAddr, max_addresses, max_pct, network);
Check();
return vAddr;
}
@@ -714,9 +712,10 @@ private:
//! Consistency check
void Check()
+ EXCLUSIVE_LOCKS_REQUIRED(cs)
{
#ifdef DEBUG_ADDRMAN
- LOCK(cs);
+ AssertLockHeld(cs);
const int err = Check_();
if (err) {
LogPrintf("ADDRMAN CONSISTENCY CHECK FAILED!!! err=%i\n", err);