Skip to content

Commit aa360e7

Browse files
committed
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
2 parents 41363fe + 660f5f1 commit aa360e7

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

src/net.cpp

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1682,8 +1682,7 @@ void CConnman::ProcessOneShot()
16821682
CAddress addr;
16831683
CSemaphoreGrant grant(*semOutbound, true);
16841684
if (grant) {
1685-
if (!OpenNetworkConnection(addr, false, &grant, strDest.c_str(), true))
1686-
AddOneShot(strDest);
1685+
OpenNetworkConnection(addr, false, &grant, strDest.c_str(), true);
16871686
}
16881687
}
16891688

@@ -1953,29 +1952,29 @@ void CConnman::ThreadOpenAddedConnections()
19531952
}
19541953

19551954
// if successful, this moves the passed grant to the constructed node
1956-
bool CConnman::OpenNetworkConnection(const CAddress& addrConnect, bool fCountFailure, CSemaphoreGrant *grantOutbound, const char *pszDest, bool fOneShot, bool fFeeler, bool manual_connection)
1955+
void CConnman::OpenNetworkConnection(const CAddress& addrConnect, bool fCountFailure, CSemaphoreGrant *grantOutbound, const char *pszDest, bool fOneShot, bool fFeeler, bool manual_connection)
19571956
{
19581957
//
19591958
// Initiate outbound network connection
19601959
//
19611960
if (interruptNet) {
1962-
return false;
1961+
return;
19631962
}
19641963
if (!fNetworkActive) {
1965-
return false;
1964+
return;
19661965
}
19671966
if (!pszDest) {
19681967
if (IsLocal(addrConnect) ||
19691968
FindNode((CNetAddr)addrConnect) || IsBanned(addrConnect) ||
19701969
FindNode(addrConnect.ToStringIPPort()))
1971-
return false;
1970+
return;
19721971
} else if (FindNode(std::string(pszDest)))
1973-
return false;
1972+
return;
19741973

19751974
CNode* pnode = ConnectNode(addrConnect, pszDest, fCountFailure);
19761975

19771976
if (!pnode)
1978-
return false;
1977+
return;
19791978
if (grantOutbound)
19801979
grantOutbound->MoveTo(pnode->grantOutbound);
19811980
if (fOneShot)
@@ -1990,8 +1989,6 @@ bool CConnman::OpenNetworkConnection(const CAddress& addrConnect, bool fCountFai
19901989
LOCK(cs_vNodes);
19911990
vNodes.push_back(pnode);
19921991
}
1993-
1994-
return true;
19951992
}
19961993

19971994
void CConnman::ThreadMessageHandler()

src/net.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ class CConnman
177177
void Interrupt();
178178
bool GetNetworkActive() const { return fNetworkActive; };
179179
void SetNetworkActive(bool active);
180-
bool OpenNetworkConnection(const CAddress& addrConnect, bool fCountFailure, CSemaphoreGrant *grantOutbound = nullptr, const char *strDest = nullptr, bool fOneShot = false, bool fFeeler = false, bool manual_connection = false);
180+
void OpenNetworkConnection(const CAddress& addrConnect, bool fCountFailure, CSemaphoreGrant *grantOutbound = nullptr, const char *strDest = nullptr, bool fOneShot = false, bool fFeeler = false, bool manual_connection = false);
181181
bool CheckIncomingNonce(uint64_t nonce);
182182

183183
bool ForNode(NodeId id, std::function<bool(CNode* pnode)> func);

0 commit comments

Comments
 (0)