Skip to content

Commit

Permalink
Merge branch 'kf_subscriberchange' of github.com:DUNE-DAQ/lbrulibs in…
Browse files Browse the repository at this point in the history
…to kf_subscriberchange
  • Loading branch information
Jose Guillermo Panduro Vazquez committed Jul 16, 2021
2 parents 0faf595 + e5be505 commit cfbb96e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/ZMQLinkModel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class ZMQLinkModel : public ZMQLinkConcept {
m_queue_timeout = std::chrono::milliseconds(m_cfg.zmq_receiver_timeout);
TLOG_DEBUG(5) << "ZMQLinkModel conf: initialising subscriber!";
m_subscriber_connected = false;
m_subscriber.setsockopt(ZMQ_RCVTIMEO, (int)m_queue_timeout.count());
//m_subscriber.setsockopt(ZMQ_RCVTIMEO, (int)m_queue_timeout.count());
m_subscriber.setsockopt(ZMQ_SUBSCRIBE, "", 0);
TLOG_DEBUG(5) << "ZMQLinkModel conf: connecting subscriber!";
m_subscriber.connect(m_ZMQLink_sourceLink);
Expand Down Expand Up @@ -156,12 +156,16 @@ class ZMQLinkModel : public ZMQLinkConcept {

size_t counter = 0;
std::ostringstream oss;

zmq::pollitem_t items[] = {{static_cast<void*>(m_subscriber),0,ZMQ_POLLIN,0}};
while (m_run_marker.load()) {
TLOG_DEBUG(1) << "Looping";

if (m_subscriber_connected) {
TLOG_DEBUG(1) << ": Ready to receive data";
zmq::message_t msg;
zmq::poll (&items [0],1,m_queue_timeout);
if (items[0].revents & ZMQ_POLLIN){
auto recvd = m_subscriber.recv(&msg);
if (recvd == 0) {
TLOG_DEBUG(1) << "No data received, moving to next loop iteration";
Expand All @@ -179,6 +183,8 @@ class ZMQLinkModel : public ZMQLinkConcept {

TLOG_DEBUG(1) << ": End of do_work loop";
counter++;
}

} else {
TLOG_DEBUG(1) << "Subscriber not yet connected";
}
Expand Down

0 comments on commit cfbb96e

Please sign in to comment.