aboutsummaryrefslogtreecommitdiff
path: root/net.cpp
diff options
context:
space:
mode:
authorGavin Andresen <gavinandresen@gmail.com>2011-02-16 14:43:04 -0500
committerGavin Andresen <gavinandresen@gmail.com>2011-02-16 14:43:04 -0500
commit5a3e82f9f543bdc88b8eaadee5d694b4f6cebdc7 (patch)
tree667e3ddcf868269dd7e68eb65791b8bfb9a00b9b /net.cpp
parent9cbae55a6ed6fcc46e636b4ae670816aab3746ec (diff)
downloadbitcoin-5a3e82f9f543bdc88b8eaadee5d694b4f6cebdc7.tar.xz
Set maxconnections default to 125
Diffstat (limited to 'net.cpp')
-rw-r--r--net.cpp20
1 files changed, 6 insertions, 14 deletions
diff --git a/net.cpp b/net.cpp
index 8480a2fcf4..0ba147bf75 100644
--- a/net.cpp
+++ b/net.cpp
@@ -688,25 +688,18 @@ void ThreadSocketHandler2(void* parg)
socklen_t len = sizeof(sockaddr);
SOCKET hSocket = accept(hListenSocket, (struct sockaddr*)&sockaddr, &len);
CAddress addr(sockaddr);
- bool fLimitConnections = false;
int nInbound = 0;
- if (mapArgs.count("-maxconnections"))
- fLimitConnections = true;
-
- if (fLimitConnections)
- {
- CRITICAL_BLOCK(cs_vNodes)
- foreach(CNode* pnode, vNodes)
- if (pnode->fInbound)
- nInbound++;
- }
+ CRITICAL_BLOCK(cs_vNodes)
+ foreach(CNode* pnode, vNodes)
+ if (pnode->fInbound)
+ nInbound++;
if (hSocket == INVALID_SOCKET)
{
if (WSAGetLastError() != WSAEWOULDBLOCK)
printf("socket error accept failed: %d\n", WSAGetLastError());
}
- else if (fLimitConnections && nInbound >= atoi(mapArgs["-maxconnections"]) - MAX_OUTBOUND_CONNECTIONS)
+ else if (nInbound >= GetArg("-maxconnections", 125) - MAX_OUTBOUND_CONNECTIONS)
{
closesocket(hSocket);
}
@@ -988,8 +981,7 @@ void ThreadOpenConnections2(void* parg)
if (!pnode->fInbound)
nOutbound++;
int nMaxOutboundConnections = MAX_OUTBOUND_CONNECTIONS;
- if (mapArgs.count("-maxconnections"))
- nMaxOutboundConnections = min(nMaxOutboundConnections, atoi(mapArgs["-maxconnections"]));
+ nMaxOutboundConnections = min(nMaxOutboundConnections, (int)GetArg("-maxconnections", 125));
if (nOutbound < nMaxOutboundConnections)
break;
Sleep(2000);