diff options
-rw-r--r-- | src/addrman.h | 4 | ||||
-rw-r--r-- | src/test/addrman_tests.cpp | 3 | ||||
-rw-r--r-- | src/test/fuzz/addrman.cpp | 2 | ||||
-rw-r--r-- | src/test/net_tests.cpp | 1 |
4 files changed, 6 insertions, 4 deletions
diff --git a/src/addrman.h b/src/addrman.h index d4f67c2f5b..6347a24d55 100644 --- a/src/addrman.h +++ b/src/addrman.h @@ -631,12 +631,12 @@ protected: uint256 nKey; //! Source of random numbers for randomization in inner loops - mutable FastRandomContext insecure_rand; + mutable FastRandomContext insecure_rand GUARDED_BY(cs); -private: //! A mutex to protect the inner data structures. mutable Mutex cs; +private: //! Serialization versions. enum Format : uint8_t { V0_HISTORICAL = 0, //!< historic format, before commit e6b343d88 diff --git a/src/test/addrman_tests.cpp b/src/test/addrman_tests.cpp index 5e5c5eba69..79c7102c4f 100644 --- a/src/test/addrman_tests.cpp +++ b/src/test/addrman_tests.cpp @@ -34,6 +34,7 @@ public: //! Ensure that bucket placement is always the same for testing purposes. void MakeDeterministic() { + LOCK(cs); nKey.SetNull(); insecure_rand = FastRandomContext(true); } @@ -87,11 +88,11 @@ public: { CAddrMan::Clear(); if (deterministic) { + LOCK(cs); nKey.SetNull(); insecure_rand = FastRandomContext(true); } } - }; static CNetAddr ResolveIP(const std::string& ip) diff --git a/src/test/fuzz/addrman.cpp b/src/test/fuzz/addrman.cpp index ee9485eba5..fb003ea3a8 100644 --- a/src/test/fuzz/addrman.cpp +++ b/src/test/fuzz/addrman.cpp @@ -27,7 +27,7 @@ class CAddrManDeterministic : public CAddrMan public: void MakeDeterministic(const uint256& random_seed) { - insecure_rand = FastRandomContext{random_seed}; + WITH_LOCK(cs, insecure_rand = FastRandomContext{random_seed}); Clear(); } }; diff --git a/src/test/net_tests.cpp b/src/test/net_tests.cpp index 46f88c1282..acbbf357d2 100644 --- a/src/test/net_tests.cpp +++ b/src/test/net_tests.cpp @@ -37,6 +37,7 @@ public: //! Ensure that bucket placement is always the same for testing purposes. void MakeDeterministic() { + LOCK(cs); nKey.SetNull(); insecure_rand = FastRandomContext(true); } |