mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-06 14:19:59 -05:00
Add thread safety annotations to CAddrMan public functions
This commit is contained in:
parent
b138973a8b
commit
5ef1d0b698
1 changed files with 14 additions and 0 deletions
|
@ -231,6 +231,7 @@ public:
|
||||||
*/
|
*/
|
||||||
template <typename Stream>
|
template <typename Stream>
|
||||||
void Serialize(Stream& s_) const
|
void Serialize(Stream& s_) const
|
||||||
|
EXCLUSIVE_LOCKS_REQUIRED(!cs)
|
||||||
{
|
{
|
||||||
LOCK(cs);
|
LOCK(cs);
|
||||||
|
|
||||||
|
@ -296,6 +297,7 @@ public:
|
||||||
|
|
||||||
template <typename Stream>
|
template <typename Stream>
|
||||||
void Unserialize(Stream& s_)
|
void Unserialize(Stream& s_)
|
||||||
|
EXCLUSIVE_LOCKS_REQUIRED(!cs)
|
||||||
{
|
{
|
||||||
LOCK(cs);
|
LOCK(cs);
|
||||||
|
|
||||||
|
@ -452,6 +454,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void Clear()
|
void Clear()
|
||||||
|
EXCLUSIVE_LOCKS_REQUIRED(!cs)
|
||||||
{
|
{
|
||||||
LOCK(cs);
|
LOCK(cs);
|
||||||
std::vector<int>().swap(vRandom);
|
std::vector<int>().swap(vRandom);
|
||||||
|
@ -487,6 +490,7 @@ public:
|
||||||
|
|
||||||
//! Return the number of (unique) addresses in all tables.
|
//! Return the number of (unique) addresses in all tables.
|
||||||
size_t size() const
|
size_t size() const
|
||||||
|
EXCLUSIVE_LOCKS_REQUIRED(!cs)
|
||||||
{
|
{
|
||||||
LOCK(cs); // TODO: Cache this in an atomic to avoid this overhead
|
LOCK(cs); // TODO: Cache this in an atomic to avoid this overhead
|
||||||
return vRandom.size();
|
return vRandom.size();
|
||||||
|
@ -494,6 +498,7 @@ public:
|
||||||
|
|
||||||
//! Add a single address.
|
//! Add a single address.
|
||||||
bool Add(const CAddress &addr, const CNetAddr& source, int64_t nTimePenalty = 0)
|
bool Add(const CAddress &addr, const CNetAddr& source, int64_t nTimePenalty = 0)
|
||||||
|
EXCLUSIVE_LOCKS_REQUIRED(!cs)
|
||||||
{
|
{
|
||||||
LOCK(cs);
|
LOCK(cs);
|
||||||
bool fRet = false;
|
bool fRet = false;
|
||||||
|
@ -508,6 +513,7 @@ public:
|
||||||
|
|
||||||
//! Add multiple addresses.
|
//! Add multiple addresses.
|
||||||
bool Add(const std::vector<CAddress> &vAddr, const CNetAddr& source, int64_t nTimePenalty = 0)
|
bool Add(const std::vector<CAddress> &vAddr, const CNetAddr& source, int64_t nTimePenalty = 0)
|
||||||
|
EXCLUSIVE_LOCKS_REQUIRED(!cs)
|
||||||
{
|
{
|
||||||
LOCK(cs);
|
LOCK(cs);
|
||||||
int nAdd = 0;
|
int nAdd = 0;
|
||||||
|
@ -523,6 +529,7 @@ public:
|
||||||
|
|
||||||
//! Mark an entry as accessible.
|
//! Mark an entry as accessible.
|
||||||
void Good(const CService &addr, bool test_before_evict = true, int64_t nTime = GetAdjustedTime())
|
void Good(const CService &addr, bool test_before_evict = true, int64_t nTime = GetAdjustedTime())
|
||||||
|
EXCLUSIVE_LOCKS_REQUIRED(!cs)
|
||||||
{
|
{
|
||||||
LOCK(cs);
|
LOCK(cs);
|
||||||
Check();
|
Check();
|
||||||
|
@ -532,6 +539,7 @@ public:
|
||||||
|
|
||||||
//! Mark an entry as connection attempted to.
|
//! Mark an entry as connection attempted to.
|
||||||
void Attempt(const CService &addr, bool fCountFailure, int64_t nTime = GetAdjustedTime())
|
void Attempt(const CService &addr, bool fCountFailure, int64_t nTime = GetAdjustedTime())
|
||||||
|
EXCLUSIVE_LOCKS_REQUIRED(!cs)
|
||||||
{
|
{
|
||||||
LOCK(cs);
|
LOCK(cs);
|
||||||
Check();
|
Check();
|
||||||
|
@ -541,6 +549,7 @@ public:
|
||||||
|
|
||||||
//! See if any to-be-evicted tried table entries have been tested and if so resolve the collisions.
|
//! See if any to-be-evicted tried table entries have been tested and if so resolve the collisions.
|
||||||
void ResolveCollisions()
|
void ResolveCollisions()
|
||||||
|
EXCLUSIVE_LOCKS_REQUIRED(!cs)
|
||||||
{
|
{
|
||||||
LOCK(cs);
|
LOCK(cs);
|
||||||
Check();
|
Check();
|
||||||
|
@ -550,6 +559,7 @@ public:
|
||||||
|
|
||||||
//! Randomly select an address in tried that another address is attempting to evict.
|
//! Randomly select an address in tried that another address is attempting to evict.
|
||||||
CAddrInfo SelectTriedCollision()
|
CAddrInfo SelectTriedCollision()
|
||||||
|
EXCLUSIVE_LOCKS_REQUIRED(!cs)
|
||||||
{
|
{
|
||||||
LOCK(cs);
|
LOCK(cs);
|
||||||
Check();
|
Check();
|
||||||
|
@ -562,6 +572,7 @@ public:
|
||||||
* Choose an address to connect to.
|
* Choose an address to connect to.
|
||||||
*/
|
*/
|
||||||
CAddrInfo Select(bool newOnly = false)
|
CAddrInfo Select(bool newOnly = false)
|
||||||
|
EXCLUSIVE_LOCKS_REQUIRED(!cs)
|
||||||
{
|
{
|
||||||
LOCK(cs);
|
LOCK(cs);
|
||||||
Check();
|
Check();
|
||||||
|
@ -578,6 +589,7 @@ public:
|
||||||
* @param[in] network Select only addresses of this network (nullopt = all).
|
* @param[in] network Select only addresses of this network (nullopt = all).
|
||||||
*/
|
*/
|
||||||
std::vector<CAddress> GetAddr(size_t max_addresses, size_t max_pct, std::optional<Network> network)
|
std::vector<CAddress> GetAddr(size_t max_addresses, size_t max_pct, std::optional<Network> network)
|
||||||
|
EXCLUSIVE_LOCKS_REQUIRED(!cs)
|
||||||
{
|
{
|
||||||
LOCK(cs);
|
LOCK(cs);
|
||||||
Check();
|
Check();
|
||||||
|
@ -589,6 +601,7 @@ public:
|
||||||
|
|
||||||
//! Outer function for Connected_()
|
//! Outer function for Connected_()
|
||||||
void Connected(const CService &addr, int64_t nTime = GetAdjustedTime())
|
void Connected(const CService &addr, int64_t nTime = GetAdjustedTime())
|
||||||
|
EXCLUSIVE_LOCKS_REQUIRED(!cs)
|
||||||
{
|
{
|
||||||
LOCK(cs);
|
LOCK(cs);
|
||||||
Check();
|
Check();
|
||||||
|
@ -597,6 +610,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetServices(const CService &addr, ServiceFlags nServices)
|
void SetServices(const CService &addr, ServiceFlags nServices)
|
||||||
|
EXCLUSIVE_LOCKS_REQUIRED(!cs)
|
||||||
{
|
{
|
||||||
LOCK(cs);
|
LOCK(cs);
|
||||||
Check();
|
Check();
|
||||||
|
|
Loading…
Add table
Reference in a new issue