mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-02 09:46:52 -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>
|
||||
void Serialize(Stream& s_) const
|
||||
EXCLUSIVE_LOCKS_REQUIRED(!cs)
|
||||
{
|
||||
LOCK(cs);
|
||||
|
||||
|
@ -296,6 +297,7 @@ public:
|
|||
|
||||
template <typename Stream>
|
||||
void Unserialize(Stream& s_)
|
||||
EXCLUSIVE_LOCKS_REQUIRED(!cs)
|
||||
{
|
||||
LOCK(cs);
|
||||
|
||||
|
@ -452,6 +454,7 @@ public:
|
|||
}
|
||||
|
||||
void Clear()
|
||||
EXCLUSIVE_LOCKS_REQUIRED(!cs)
|
||||
{
|
||||
LOCK(cs);
|
||||
std::vector<int>().swap(vRandom);
|
||||
|
@ -487,6 +490,7 @@ public:
|
|||
|
||||
//! Return the number of (unique) addresses in all tables.
|
||||
size_t size() const
|
||||
EXCLUSIVE_LOCKS_REQUIRED(!cs)
|
||||
{
|
||||
LOCK(cs); // TODO: Cache this in an atomic to avoid this overhead
|
||||
return vRandom.size();
|
||||
|
@ -494,6 +498,7 @@ public:
|
|||
|
||||
//! Add a single address.
|
||||
bool Add(const CAddress &addr, const CNetAddr& source, int64_t nTimePenalty = 0)
|
||||
EXCLUSIVE_LOCKS_REQUIRED(!cs)
|
||||
{
|
||||
LOCK(cs);
|
||||
bool fRet = false;
|
||||
|
@ -508,6 +513,7 @@ public:
|
|||
|
||||
//! Add multiple addresses.
|
||||
bool Add(const std::vector<CAddress> &vAddr, const CNetAddr& source, int64_t nTimePenalty = 0)
|
||||
EXCLUSIVE_LOCKS_REQUIRED(!cs)
|
||||
{
|
||||
LOCK(cs);
|
||||
int nAdd = 0;
|
||||
|
@ -523,6 +529,7 @@ public:
|
|||
|
||||
//! Mark an entry as accessible.
|
||||
void Good(const CService &addr, bool test_before_evict = true, int64_t nTime = GetAdjustedTime())
|
||||
EXCLUSIVE_LOCKS_REQUIRED(!cs)
|
||||
{
|
||||
LOCK(cs);
|
||||
Check();
|
||||
|
@ -532,6 +539,7 @@ public:
|
|||
|
||||
//! Mark an entry as connection attempted to.
|
||||
void Attempt(const CService &addr, bool fCountFailure, int64_t nTime = GetAdjustedTime())
|
||||
EXCLUSIVE_LOCKS_REQUIRED(!cs)
|
||||
{
|
||||
LOCK(cs);
|
||||
Check();
|
||||
|
@ -541,6 +549,7 @@ public:
|
|||
|
||||
//! See if any to-be-evicted tried table entries have been tested and if so resolve the collisions.
|
||||
void ResolveCollisions()
|
||||
EXCLUSIVE_LOCKS_REQUIRED(!cs)
|
||||
{
|
||||
LOCK(cs);
|
||||
Check();
|
||||
|
@ -550,6 +559,7 @@ public:
|
|||
|
||||
//! Randomly select an address in tried that another address is attempting to evict.
|
||||
CAddrInfo SelectTriedCollision()
|
||||
EXCLUSIVE_LOCKS_REQUIRED(!cs)
|
||||
{
|
||||
LOCK(cs);
|
||||
Check();
|
||||
|
@ -562,6 +572,7 @@ public:
|
|||
* Choose an address to connect to.
|
||||
*/
|
||||
CAddrInfo Select(bool newOnly = false)
|
||||
EXCLUSIVE_LOCKS_REQUIRED(!cs)
|
||||
{
|
||||
LOCK(cs);
|
||||
Check();
|
||||
|
@ -578,6 +589,7 @@ public:
|
|||
* @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)
|
||||
EXCLUSIVE_LOCKS_REQUIRED(!cs)
|
||||
{
|
||||
LOCK(cs);
|
||||
Check();
|
||||
|
@ -589,6 +601,7 @@ public:
|
|||
|
||||
//! Outer function for Connected_()
|
||||
void Connected(const CService &addr, int64_t nTime = GetAdjustedTime())
|
||||
EXCLUSIVE_LOCKS_REQUIRED(!cs)
|
||||
{
|
||||
LOCK(cs);
|
||||
Check();
|
||||
|
@ -597,6 +610,7 @@ public:
|
|||
}
|
||||
|
||||
void SetServices(const CService &addr, ServiceFlags nServices)
|
||||
EXCLUSIVE_LOCKS_REQUIRED(!cs)
|
||||
{
|
||||
LOCK(cs);
|
||||
Check();
|
||||
|
|
Loading…
Add table
Reference in a new issue