backported networking tweaks
This commit is contained in:
parent
55730549af
commit
b18091f63c
2 changed files with 13 additions and 7 deletions
15
src/net.cpp
15
src/net.cpp
|
@ -172,7 +172,7 @@ CAddress GetLocalAddress(const CNetAddr *paddrPeer, ServiceFlags nLocalServices)
|
|||
static int GetnScore(const CService& addr)
|
||||
{
|
||||
LOCK(cs_mapLocalHost);
|
||||
if (mapLocalHost.count(addr) == LOCAL_NONE)
|
||||
if (mapLocalHost.count(addr) == 0)
|
||||
return 0;
|
||||
return mapLocalHost[addr].nScore;
|
||||
}
|
||||
|
@ -926,7 +926,8 @@ size_t CConnman::SocketSendData(CNode *pnode) const
|
|||
int nErr = WSAGetLastError();
|
||||
if (nErr != WSAEWOULDBLOCK && nErr != WSAEMSGSIZE && nErr != WSAEINTR && nErr != WSAEINPROGRESS)
|
||||
{
|
||||
LogPrintf("socket send error %s\n", NetworkErrorString(nErr));
|
||||
LogPrintf("socket send error: %s%s\n", NetworkErrorString(nErr),
|
||||
fLogIPs ? (", peeraddr=" + pnode->addrName) : std::string());
|
||||
pnode->CloseSocketDisconnect();
|
||||
}
|
||||
}
|
||||
|
@ -1325,6 +1326,9 @@ void CConnman::ThreadSocketHandler()
|
|||
}
|
||||
}
|
||||
|
||||
if (interruptNet)
|
||||
return;
|
||||
|
||||
#ifdef USE_POLL
|
||||
std::vector<struct pollfd> vpollfds;
|
||||
vpollfds.reserve(pollfds.size());
|
||||
|
@ -1359,8 +1363,6 @@ void CConnman::ThreadSocketHandler()
|
|||
}
|
||||
#endif
|
||||
|
||||
if (interruptNet)
|
||||
return;
|
||||
//
|
||||
// Accept new connections
|
||||
//
|
||||
|
@ -1385,7 +1387,7 @@ void CConnman::ThreadSocketHandler()
|
|||
for (CNode* pnode : vNodesCopy)
|
||||
{
|
||||
if (interruptNet)
|
||||
return;
|
||||
break;
|
||||
|
||||
//
|
||||
// Receive
|
||||
|
@ -1450,7 +1452,8 @@ void CConnman::ThreadSocketHandler()
|
|||
if (nErr != WSAEWOULDBLOCK && nErr != WSAEMSGSIZE && nErr != WSAEINTR && nErr != WSAEINPROGRESS)
|
||||
{
|
||||
if (!pnode->fDisconnect)
|
||||
LogPrintf("socket recv error %s\n", NetworkErrorString(nErr));
|
||||
LogPrintf("socket recv error: %s%s\n", NetworkErrorString(nErr),
|
||||
fLogIPs ? (", peeraddr=" + pnode->addrName) : std::string());
|
||||
pnode->CloseSocketDisconnect();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1981,7 +1981,9 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
|
|||
{
|
||||
pfrom->AddInventoryKnown(inv);
|
||||
if (fBlocksOnly) {
|
||||
LogPrint(BCLog::NET, "transaction (%s) inv sent in violation of protocol peer=%d\n", inv.hash.ToString(), pfrom->GetId());
|
||||
LogPrint(BCLog::NET, "transaction (%s) inv sent in violation of protocol, disconnecting peer=%d\n", inv.hash.ToString(), pfrom->GetId());
|
||||
pfrom->fDisconnect = true;
|
||||
return true;
|
||||
} else if (!fAlreadyHave && !fImporting && !fReindex && !IsInitialBlockDownload()) {
|
||||
pfrom->AskFor(inv);
|
||||
}
|
||||
|
@ -2206,6 +2208,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
|
|||
if (!fRelayTxes && (!pfrom->fWhitelisted || !gArgs.GetBoolArg("-whitelistrelay", DEFAULT_WHITELISTRELAY)))
|
||||
{
|
||||
LogPrint(BCLog::NET, "transaction sent in violation of protocol peer=%d\n", pfrom->GetId());
|
||||
pfrom->fDisconnect = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue