Skip to content

Commit

Permalink
net: don't retry failed oneshot connections forever
Browse files Browse the repository at this point in the history
  • Loading branch information
theuni committed Feb 1, 2018
1 parent 84291d1 commit 660f5f1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
17 changes: 7 additions & 10 deletions src/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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)
Expand All @@ -1990,8 +1989,6 @@ bool CConnman::OpenNetworkConnection(const CAddress& addrConnect, bool fCountFai
LOCK(cs_vNodes);
vNodes.push_back(pnode);
}

return true;
}

void CConnman::ThreadMessageHandler()
Expand Down
2 changes: 1 addition & 1 deletion src/net.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ class CConnman
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);
Expand Down

0 comments on commit 660f5f1

Please sign in to comment.