Skip to content

Commit 187b7d2

Browse files
committed
refactor: Avoid recursive locking in CAddrMan::Check
1 parent f77d9c7 commit 187b7d2

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/addrman.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -585,12 +585,10 @@ class CAddrMan
585585
*/
586586
std::vector<CAddress> GetAddr(size_t max_addresses, size_t max_pct, std::optional<Network> network)
587587
{
588+
LOCK(cs);
588589
Check();
589590
std::vector<CAddress> vAddr;
590-
{
591-
LOCK(cs);
592-
GetAddr_(vAddr, max_addresses, max_pct, network);
593-
}
591+
GetAddr_(vAddr, max_addresses, max_pct, network);
594592
Check();
595593
return vAddr;
596594
}
@@ -714,9 +712,10 @@ class CAddrMan
714712

715713
//! Consistency check
716714
void Check()
715+
EXCLUSIVE_LOCKS_REQUIRED(cs)
717716
{
718717
#ifdef DEBUG_ADDRMAN
719-
LOCK(cs);
718+
AssertLockHeld(cs);
720719
const int err = Check_();
721720
if (err) {
722721
LogPrintf("ADDRMAN CONSISTENCY CHECK FAILED!!! err=%i\n", err);

0 commit comments

Comments
 (0)