From 2761ce5af7227a5cafe7ae1951ccb8d51e170ab1 Mon Sep 17 00:00:00 2001 From: SChernykh Date: Fri, 27 Aug 2021 10:32:31 +0200 Subject: [PATCH] Fixed a leak in ZMQReader --- src/zmq_reader.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/zmq_reader.cpp b/src/zmq_reader.cpp index df4956f..4d96253 100644 --- a/src/zmq_reader.cpp +++ b/src/zmq_reader.cpp @@ -93,15 +93,15 @@ void ZMQReader::run() m_subscriber.set(zmq::sockopt::subscribe, "json-full-miner_data"); m_subscriber.set(zmq::sockopt::subscribe, "json-minimal-txpool_add"); + zmq_msg_t message; + int rc = zmq_msg_init(&message); + if (rc != 0) { + throw zmq::error_t(); + } + LOGINFO(1, "worker thread ready"); do { - zmq_msg_t message; - int rc = zmq_msg_init(&message); - if (rc != 0) { - throw zmq::error_t(); - } - rc = zmq_msg_recv(&message, m_subscriber, 0); if (rc < 0) { throw zmq::error_t(); @@ -113,6 +113,8 @@ void ZMQReader::run() parse(reinterpret_cast(zmq_msg_data(&message)), zmq_msg_size(&message)); } while (true); + + zmq_msg_close(&message); } catch (const std::exception& e) { LOGERR(1, "exception " << e.what() << ", aborting");