Browse Source

net: don't retry failed oneshot connections forever

Github-Pull: #12329
Rebased-From: 660f5f19ae74cc81b83540fcb95a33ec437834c8
Tree-SHA512: 7e7401b0ade3a2482dd246cc92c795230b37001a13fd7d050847ea532b619106dfdfc113e95c2891c689d421b3dd775d1833789061cd90dc094f13c4f5f6b278
0.16
Cory Fields 6 years ago committed by Wladimir J. van der Laan
parent
commit
5303970c26
No known key found for this signature in database
GPG Key ID: 1E4AED62986CD25D
  1. 17
      src/net.cpp
  2. 2
      src/net.h

17
src/net.cpp

@ -1682,8 +1682,7 @@ void CConnman::ProcessOneShot() @@ -1682,8 +1682,7 @@ void CConnman::ProcessOneShot()
CAddress addr;
CSemaphoreGrant grant(*semOutbound, true);
if (grant) {
if (!OpenNetworkConnection(addr, false, &grant, strDest.c_str(), true))
AddOneShot(strDest);
OpenNetworkConnection(addr, false, &grant, strDest.c_str(), true);
}
}
@ -1953,29 +1952,29 @@ void CConnman::ThreadOpenAddedConnections() @@ -1953,29 +1952,29 @@ void CConnman::ThreadOpenAddedConnections()
}
// if successful, this moves the passed grant to the constructed node
bool CConnman::OpenNetworkConnection(const CAddress& addrConnect, bool fCountFailure, CSemaphoreGrant *grantOutbound, const char *pszDest, bool fOneShot, bool fFeeler, bool manual_connection)
void CConnman::OpenNetworkConnection(const CAddress& addrConnect, bool fCountFailure, CSemaphoreGrant *grantOutbound, const char *pszDest, bool fOneShot, bool fFeeler, bool manual_connection)
{
//
// Initiate outbound network connection
//
if (interruptNet) {
return false;
return;
}
if (!fNetworkActive) {
return false;
return;
}
if (!pszDest) {
if (IsLocal(addrConnect) ||
FindNode((CNetAddr)addrConnect) || IsBanned(addrConnect) ||
FindNode(addrConnect.ToStringIPPort()))
return false;
return;
} else if (FindNode(std::string(pszDest)))
return false;
return;
CNode* pnode = ConnectNode(addrConnect, pszDest, fCountFailure);
if (!pnode)
return false;
return;
if (grantOutbound)
grantOutbound->MoveTo(pnode->grantOutbound);
if (fOneShot)
@ -1990,8 +1989,6 @@ bool CConnman::OpenNetworkConnection(const CAddress& addrConnect, bool fCountFai @@ -1990,8 +1989,6 @@ bool CConnman::OpenNetworkConnection(const CAddress& addrConnect, bool fCountFai
LOCK(cs_vNodes);
vNodes.push_back(pnode);
}
return true;
}
void CConnman::ThreadMessageHandler()

2
src/net.h

@ -177,7 +177,7 @@ public: @@ -177,7 +177,7 @@ public:
void Interrupt();
bool GetNetworkActive() const { return fNetworkActive; };
void SetNetworkActive(bool active);
bool OpenNetworkConnection(const CAddress& addrConnect, bool fCountFailure, CSemaphoreGrant *grantOutbound = nullptr, const char *strDest = nullptr, bool fOneShot = false, bool fFeeler = false, bool manual_connection = false);
void OpenNetworkConnection(const CAddress& addrConnect, bool fCountFailure, CSemaphoreGrant *grantOutbound = nullptr, const char *strDest = nullptr, bool fOneShot = false, bool fFeeler = false, bool manual_connection = false);
bool CheckIncomingNonce(uint64_t nonce);
bool ForNode(NodeId id, std::function<bool(CNode* pnode)> func);

Loading…
Cancel
Save