Merge #12329: net: don't retry failed oneshot connections forever
660f5f1
net: don't retry failed oneshot connections forever (Cory Fields)
Pull request description:
As introduced by (my suggestion, sorry, in) #11512, failed dns resolves end up as oneshots. But failed oneshots are re-added as oneshots, so we need to make sure that we're not queuing these up forever after failed resolves.
Rather than trying to differentiate, I think we should just not re-add failed oneshots and be done with it.
Maybe @sipa can shed a light on what the original intention was.
Tree-SHA512: 2dfe35dabfb6354c315cf6f8ae42971765d36575e685662caae7ed8f9dea9472c6fb1fd5e62ec35301550b74b6613a54265e90fca2a6618544f78dacaac4d4fd
This commit is contained in:
commit
aa360e76a7
2 changed files with 8 additions and 11 deletions
17
src/net.cpp
17
src/net.cpp
|
@ -1682,8 +1682,7 @@ void CConnman::ProcessOneShot()
|
||||||
CAddress addr;
|
CAddress addr;
|
||||||
CSemaphoreGrant grant(*semOutbound, true);
|
CSemaphoreGrant grant(*semOutbound, true);
|
||||||
if (grant) {
|
if (grant) {
|
||||||
if (!OpenNetworkConnection(addr, false, &grant, strDest.c_str(), true))
|
OpenNetworkConnection(addr, false, &grant, strDest.c_str(), true);
|
||||||
AddOneShot(strDest);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1953,29 +1952,29 @@ void CConnman::ThreadOpenAddedConnections()
|
||||||
}
|
}
|
||||||
|
|
||||||
// if successful, this moves the passed grant to the constructed node
|
// 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
|
// Initiate outbound network connection
|
||||||
//
|
//
|
||||||
if (interruptNet) {
|
if (interruptNet) {
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
if (!fNetworkActive) {
|
if (!fNetworkActive) {
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
if (!pszDest) {
|
if (!pszDest) {
|
||||||
if (IsLocal(addrConnect) ||
|
if (IsLocal(addrConnect) ||
|
||||||
FindNode((CNetAddr)addrConnect) || IsBanned(addrConnect) ||
|
FindNode((CNetAddr)addrConnect) || IsBanned(addrConnect) ||
|
||||||
FindNode(addrConnect.ToStringIPPort()))
|
FindNode(addrConnect.ToStringIPPort()))
|
||||||
return false;
|
return;
|
||||||
} else if (FindNode(std::string(pszDest)))
|
} else if (FindNode(std::string(pszDest)))
|
||||||
return false;
|
return;
|
||||||
|
|
||||||
CNode* pnode = ConnectNode(addrConnect, pszDest, fCountFailure);
|
CNode* pnode = ConnectNode(addrConnect, pszDest, fCountFailure);
|
||||||
|
|
||||||
if (!pnode)
|
if (!pnode)
|
||||||
return false;
|
return;
|
||||||
if (grantOutbound)
|
if (grantOutbound)
|
||||||
grantOutbound->MoveTo(pnode->grantOutbound);
|
grantOutbound->MoveTo(pnode->grantOutbound);
|
||||||
if (fOneShot)
|
if (fOneShot)
|
||||||
|
@ -1990,8 +1989,6 @@ bool CConnman::OpenNetworkConnection(const CAddress& addrConnect, bool fCountFai
|
||||||
LOCK(cs_vNodes);
|
LOCK(cs_vNodes);
|
||||||
vNodes.push_back(pnode);
|
vNodes.push_back(pnode);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CConnman::ThreadMessageHandler()
|
void CConnman::ThreadMessageHandler()
|
||||||
|
|
|
@ -177,7 +177,7 @@ public:
|
||||||
void Interrupt();
|
void Interrupt();
|
||||||
bool GetNetworkActive() const { return fNetworkActive; };
|
bool GetNetworkActive() const { return fNetworkActive; };
|
||||||
void SetNetworkActive(bool active);
|
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 CheckIncomingNonce(uint64_t nonce);
|
||||||
|
|
||||||
bool ForNode(NodeId id, std::function<bool(CNode* pnode)> func);
|
bool ForNode(NodeId id, std::function<bool(CNode* pnode)> func);
|
||||||
|
|
Loading…
Add table
Reference in a new issue