From 187b7d2bb36e6de9cd960378021ebe690619a2ef Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Sun, 23 May 2021 19:32:03 +0300 Subject: [PATCH] refactor: Avoid recursive locking in CAddrMan::Check --- src/addrman.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/addrman.h b/src/addrman.h index 600c524bce5..3474153e36d 100644 --- a/src/addrman.h +++ b/src/addrman.h @@ -585,12 +585,10 @@ public: */ std::vector GetAddr(size_t max_addresses, size_t max_pct, std::optional network) { + LOCK(cs); Check(); std::vector 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);