File tree Expand file tree Collapse file tree 4 files changed +6
-4
lines changed Expand file tree Collapse file tree 4 files changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -631,12 +631,12 @@ class CAddrMan
631
631
uint256 nKey;
632
632
633
633
// ! Source of random numbers for randomization in inner loops
634
- mutable FastRandomContext insecure_rand;
634
+ mutable FastRandomContext insecure_rand GUARDED_BY (cs) ;
635
635
636
- private:
637
636
// ! A mutex to protect the inner data structures.
638
637
mutable Mutex cs;
639
638
639
+ private:
640
640
// ! Serialization versions.
641
641
enum Format : uint8_t {
642
642
V0_HISTORICAL = 0 , // !< historic format, before commit e6b343d88
Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ class CAddrManTest : public CAddrMan
34
34
// ! Ensure that bucket placement is always the same for testing purposes.
35
35
void MakeDeterministic ()
36
36
{
37
+ LOCK (cs);
37
38
nKey.SetNull ();
38
39
insecure_rand = FastRandomContext (true );
39
40
}
@@ -87,11 +88,11 @@ class CAddrManTest : public CAddrMan
87
88
{
88
89
CAddrMan::Clear ();
89
90
if (deterministic) {
91
+ LOCK (cs);
90
92
nKey.SetNull ();
91
93
insecure_rand = FastRandomContext (true );
92
94
}
93
95
}
94
-
95
96
};
96
97
97
98
static CNetAddr ResolveIP (const std::string& ip)
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ class CAddrManDeterministic : public CAddrMan
27
27
public:
28
28
void MakeDeterministic (const uint256& random_seed)
29
29
{
30
- insecure_rand = FastRandomContext{random_seed};
30
+ WITH_LOCK (cs, insecure_rand = FastRandomContext{random_seed}) ;
31
31
Clear ();
32
32
}
33
33
};
Original file line number Diff line number Diff line change @@ -37,6 +37,7 @@ class CAddrManSerializationMock : public CAddrMan
37
37
// ! Ensure that bucket placement is always the same for testing purposes.
38
38
void MakeDeterministic ()
39
39
{
40
+ LOCK (cs);
40
41
nKey.SetNull ();
41
42
insecure_rand = FastRandomContext (true );
42
43
}
You can’t perform that action at this time.
0 commit comments