Skip to content

Commit 660f5f1

Browse files
committed
net: don't retry failed oneshot connections forever
1 parent 84291d1 commit 660f5f1

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)