|
|
@ -82,7 +82,16 @@ void EthStratumClient::connect() |
|
|
|
|
|
|
|
cnote << "Connecting to stratum server " << p_active->host + ":" + p_active->port; |
|
|
|
|
|
|
|
m_serviceThread = std::thread{boost::bind(&boost::asio::io_service::run, &m_io_service)}; |
|
|
|
if (m_serviceThread.joinable()) |
|
|
|
{ |
|
|
|
// If the service thread have been created try to reset the service.
|
|
|
|
m_io_service.reset(); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
// Otherwise, if the first time here, create new thread.
|
|
|
|
m_serviceThread = std::thread{boost::bind(&boost::asio::io_service::run, &m_io_service)}; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#define BOOST_ASIO_ENABLE_CANCELIO |
|
|
@ -121,7 +130,7 @@ void EthStratumClient::reconnect() |
|
|
|
} |
|
|
|
|
|
|
|
cnote << "Reconnecting in 3 seconds..."; |
|
|
|
boost::asio::deadline_timer timer(m_io_service, boost::posix_time::seconds(3)); |
|
|
|
boost::asio::deadline_timer timer(m_io_service, boost::posix_time::seconds(3)); |
|
|
|
timer.wait(); |
|
|
|
|
|
|
|
connect(); |
|
|
|