aboutsummaryrefslogtreecommitdiff
path: root/src/net.cpp
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2013-03-29 00:43:31 +0100
committerPieter Wuille <sipa@ulyssis.org>2013-04-04 14:45:45 +0200
commitcedaa714462871213472019545b8e862dacdac91 (patch)
tree624e3d8ff65f5f2978abe5fa0c7274b8c6c41f47 /src/net.cpp
parentaaf47eac3abef5741b6c108fdc8a19cb46b773a2 (diff)
downloadbitcoin-cedaa714462871213472019545b8e862dacdac91.tar.xz
Drop release times for CNode
It seems there were two mechanisms for assessing whether a CNode was still in use: a refcount and a release timestamp. The latter seems to have been there for a long time, as a safety mechanism. However, this timer also keeps CNode objects alive for far longer than necessary after disconnects, potentially opening up a DoS window. This commit removes the timestamp-based mechanism, and replaces it with an assert(nRefCount >= 0), to verify that the refcounting is indeed correctly working.
Diffstat (limited to 'src/net.cpp')
-rw-r--r--src/net.cpp14
1 files changed, 3 insertions, 11 deletions
diff --git a/src/net.cpp b/src/net.cpp
index 5f8b5ba32b..804eba3ccb 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -453,7 +453,7 @@ CNode* FindNode(const CService& addr)
return NULL;
}
-CNode* ConnectNode(CAddress addrConnect, const char *pszDest, int64 nTimeout)
+CNode* ConnectNode(CAddress addrConnect, const char *pszDest)
{
if (pszDest == NULL) {
if (IsLocal(addrConnect))
@@ -463,10 +463,7 @@ CNode* ConnectNode(CAddress addrConnect, const char *pszDest, int64 nTimeout)
CNode* pnode = FindNode((CService)addrConnect);
if (pnode)
{
- if (nTimeout != 0)
- pnode->AddRef(nTimeout);
- else
- pnode->AddRef();
+ pnode->AddRef();
return pnode;
}
}
@@ -498,10 +495,7 @@ CNode* ConnectNode(CAddress addrConnect, const char *pszDest, int64 nTimeout)
// Add node
CNode* pnode = new CNode(hSocket, addrConnect, pszDest ? pszDest : "", false);
- if (nTimeout != 0)
- pnode->AddRef(nTimeout);
- else
- pnode->AddRef();
+ pnode->AddRef();
{
LOCK(cs_vNodes);
@@ -615,7 +609,6 @@ void CNode::copyStats(CNodeStats &stats)
X(nVersion);
X(strSubVer);
X(fInbound);
- X(nReleaseTime);
X(nStartingHeight);
X(nMisbehavior);
}
@@ -773,7 +766,6 @@ void ThreadSocketHandler()
pnode->Cleanup();
// hold in disconnected pool until all refs are released
- pnode->nReleaseTime = max(pnode->nReleaseTime, GetTime() + 15 * 60);
if (pnode->fNetworkNode || pnode->fInbound)
pnode->Release();
vNodesDisconnected.push_back(pnode);