Merge pull request #4037 from gmaxwell/fdleaks
Prevent socket leak in ThreadSocketHandler.
This commit is contained in:
commit
fe451fe944
2 changed files with 8 additions and 7 deletions
|
@ -946,12 +946,8 @@ void ThreadSocketHandler()
|
||||||
}
|
}
|
||||||
else if (nInbound >= nMaxConnections - MAX_OUTBOUND_CONNECTIONS)
|
else if (nInbound >= nMaxConnections - MAX_OUTBOUND_CONNECTIONS)
|
||||||
{
|
{
|
||||||
{
|
|
||||||
LOCK(cs_setservAddNodeAddresses);
|
|
||||||
if (!setservAddNodeAddresses.count(addr))
|
|
||||||
closesocket(hSocket);
|
closesocket(hSocket);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else if (CNode::IsBanned(addr))
|
else if (CNode::IsBanned(addr))
|
||||||
{
|
{
|
||||||
LogPrintf("connection from %s dropped (banned)\n", addr.ToString());
|
LogPrintf("connection from %s dropped (banned)\n", addr.ToString());
|
||||||
|
|
|
@ -293,8 +293,10 @@ bool static Socks5(string strDest, int port, SOCKET& hSocket)
|
||||||
case 0x03:
|
case 0x03:
|
||||||
{
|
{
|
||||||
ret = recv(hSocket, pchRet3, 1, 0) != 1;
|
ret = recv(hSocket, pchRet3, 1, 0) != 1;
|
||||||
if (ret)
|
if (ret) {
|
||||||
|
closesocket(hSocket);
|
||||||
return error("Error reading from proxy");
|
return error("Error reading from proxy");
|
||||||
|
}
|
||||||
int nRecv = pchRet3[0];
|
int nRecv = pchRet3[0];
|
||||||
ret = recv(hSocket, pchRet3, nRecv, 0) != nRecv;
|
ret = recv(hSocket, pchRet3, nRecv, 0) != nRecv;
|
||||||
break;
|
break;
|
||||||
|
@ -501,6 +503,7 @@ bool ConnectSocket(const CService &addrDest, SOCKET& hSocketRet, int nTimeout)
|
||||||
return false;
|
return false;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
closesocket(hSocket);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -532,7 +535,9 @@ bool ConnectSocketByName(CService &addr, SOCKET& hSocketRet, const char *pszDest
|
||||||
|
|
||||||
switch(nameproxy.second) {
|
switch(nameproxy.second) {
|
||||||
default:
|
default:
|
||||||
case 4: return false;
|
case 4:
|
||||||
|
closesocket(hSocket);
|
||||||
|
return false;
|
||||||
case 5:
|
case 5:
|
||||||
if (!Socks5(strDest, port, hSocket))
|
if (!Socks5(strDest, port, hSocket))
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in a new issue