mirror of
https://github.com/SChernykh/p2pool.git
synced 2024-12-22 19:39:22 +00:00
ZMQReader: keep trying to connect on startup
This commit is contained in:
parent
9885f82e9e
commit
966b499e5c
2 changed files with 9 additions and 8 deletions
|
@ -76,20 +76,22 @@ ZMQReader::~ZMQReader()
|
|||
}
|
||||
}
|
||||
|
||||
void ZMQReader::run_wrapper(void* arg)
|
||||
{
|
||||
reinterpret_cast<ZMQReader*>(arg)->run();
|
||||
LOGINFO(1, "worker thread stopped");
|
||||
}
|
||||
|
||||
void ZMQReader::run()
|
||||
{
|
||||
try {
|
||||
char addr[32];
|
||||
|
||||
snprintf(addr, sizeof(addr), "tcp://%s:%u", m_address, m_zmqPort);
|
||||
if (!connect(addr, m_zmqPort)) {
|
||||
throw zmq::error_t();
|
||||
}
|
||||
while (!connect(addr, m_zmqPort)) { if (m_finished.load()) return; }
|
||||
|
||||
snprintf(addr, sizeof(addr), "tcp://127.0.0.1:%u", m_publisherPort);
|
||||
if (!connect(addr, m_publisherPort)) {
|
||||
throw zmq::error_t();
|
||||
}
|
||||
while (!connect(addr, m_publisherPort)) { if (m_finished.load()) return; }
|
||||
|
||||
m_subscriber.set(zmq::sockopt::subscribe, "json-full-chain_main");
|
||||
m_subscriber.set(zmq::sockopt::subscribe, "json-full-miner_data");
|
||||
|
@ -122,7 +124,6 @@ void ZMQReader::run()
|
|||
LOGERR(1, "exception " << e.what() << ", aborting");
|
||||
panic();
|
||||
}
|
||||
LOGINFO(1, "worker thread stopped");
|
||||
}
|
||||
|
||||
bool ZMQReader::connect(const char* address, uint32_t id)
|
||||
|
|
|
@ -28,7 +28,7 @@ public:
|
|||
~ZMQReader();
|
||||
|
||||
private:
|
||||
static void run_wrapper(void* arg) { reinterpret_cast<ZMQReader*>(arg)->run(); }
|
||||
static void run_wrapper(void* arg);
|
||||
void run();
|
||||
bool connect(const char* address, uint32_t id);
|
||||
|
||||
|
|
Loading…
Reference in a new issue