This repository was archived by the owner on Apr 24, 2022. It is now read-only.
File tree 2 files changed +6
-1
lines changed
2 files changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ namespace dev
22
22
void setConnection (URI &conn)
23
23
{
24
24
m_conn = &conn;
25
+ m_canconnect.store (false , std::memory_order_relaxed);
25
26
}
26
27
27
28
virtual void connect () = 0;
@@ -49,6 +50,7 @@ namespace dev
49
50
std::atomic<bool > m_subscribed = { false };
50
51
std::atomic<bool > m_authorized = { false };
51
52
std::atomic<bool > m_connected = { false };
53
+ std::atomic<bool > m_canconnect = { false };
52
54
53
55
boost::asio::ip::basic_endpoint<boost::asio::ip::tcp> m_endpoint;
54
56
Original file line number Diff line number Diff line change @@ -257,7 +257,9 @@ void EthStratumClient::disconnect_finalize() {
257
257
258
258
// If we got disconnected during autodetection phase
259
259
// reissue a connect lowering stratum mode checks
260
- if (!m_conn->StratumModeConfirmed ())
260
+ // m_canconnect flag is used to prevent never-ending loop when
261
+ // remote endpoint rejects connections attempts persistently since the first
262
+ if (!m_conn->StratumModeConfirmed () && m_canconnect.load (std::memory_order_relaxed))
261
263
{
262
264
unsigned l = m_conn->StratumMode ();
263
265
if (l > 0 )
@@ -440,6 +442,7 @@ void EthStratumClient::connect_handler(const boost::system::error_code& ec)
440
442
441
443
// Immediately set connecting flag to prevent
442
444
// occurrence of subsequents timeouts (if any)
445
+ m_canconnect.store (true , std::memory_order_relaxed);
443
446
m_connecting.store (false , std::memory_order_relaxed);
444
447
m_conntimer.cancel ();
445
448
You can’t perform that action at this time.
0 commit comments