Remove some locking in net.h/net.cpp (#1905)
* Remove unnecessary LOCK in ConnectNode FindNode already does the necessary lock * Remove unnecessary semicolon * Remove critical section and assert for ref counts in CNode nRefCount is an atomic now and thus doesn't need locking anymore.
This commit is contained in:
parent
bb20b4e7b5
commit
4719ec477c
@ -351,7 +351,6 @@ CNode* CConnman::ConnectNode(CAddress addrConnect, const char *pszDest, bool fCo
|
||||
if (IsLocal(addrConnect))
|
||||
return NULL;
|
||||
|
||||
LOCK(cs_vNodes);
|
||||
// Look for an existing connection
|
||||
CNode* pnode = FindNode((CService)addrConnect);
|
||||
if (pnode)
|
||||
@ -913,7 +912,7 @@ static bool ReverseCompareNodeTimeConnected(const NodeEvictionCandidate& a, cons
|
||||
|
||||
static bool CompareNetGroupKeyed(const NodeEvictionCandidate &a, const NodeEvictionCandidate &b) {
|
||||
return a.nKeyedNetGroup < b.nKeyedNetGroup;
|
||||
};
|
||||
}
|
||||
|
||||
static bool CompareNodeBlockTime(const NodeEvictionCandidate &a, const NodeEvictionCandidate &b)
|
||||
{
|
||||
|
@ -808,8 +808,6 @@ public:
|
||||
~CNode();
|
||||
|
||||
private:
|
||||
CCriticalSection cs_nRefCount;
|
||||
|
||||
CNode(const CNode&);
|
||||
void operator=(const CNode&);
|
||||
|
||||
@ -842,7 +840,6 @@ public:
|
||||
|
||||
int GetRefCount()
|
||||
{
|
||||
LOCK(cs_nRefCount);
|
||||
assert(nRefCount >= 0);
|
||||
return nRefCount;
|
||||
}
|
||||
@ -866,16 +863,13 @@ public:
|
||||
|
||||
CNode* AddRef()
|
||||
{
|
||||
LOCK(cs_nRefCount);
|
||||
nRefCount++;
|
||||
return this;
|
||||
}
|
||||
|
||||
void Release()
|
||||
{
|
||||
LOCK(cs_nRefCount);
|
||||
nRefCount--;
|
||||
assert(nRefCount >= 0);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user