From 773320799af5ae56b1c17f6eb358b09254f82605 Mon Sep 17 00:00:00 2001 From: Andrej Babic Date: Wed, 15 Jul 2020 10:34:54 +0200 Subject: [PATCH] Switch analysis socket to NOBLOCK Since we cannot control the rate of the producer (its whatever the detector is currently doing) we cannot afford to block if no clients are present. --- sf-stream/src/ZmqLiveSender.cpp | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/sf-stream/src/ZmqLiveSender.cpp b/sf-stream/src/ZmqLiveSender.cpp index 2262892..716bb37 100644 --- a/sf-stream/src/ZmqLiveSender.cpp +++ b/sf-stream/src/ZmqLiveSender.cpp @@ -194,21 +194,25 @@ void ZmqLiveSender::send(const ModuleFrameBuffer *meta, const char *data) text_header = buffer.GetString(); } - zmq_send(socket_live_, - text_header.c_str(), - text_header.size(), - ZMQ_SNDMORE | ZMQ_NOBLOCK); + // TODO: Ugly. Fix this flow control. + if (zmq_send(socket_live_, + text_header.c_str(), + text_header.size(), + ZMQ_SNDMORE | ZMQ_NOBLOCK) != -1) { - if ( send_live_analysis == 0 ) { - zmq_send(socket_live_, - (char*)data, - buffer_config::MODULE_N_BYTES * config_.n_modules, - 0); - } else { - zmq_send(socket_live_, - (char*)data_empty, - 8, - 0); + if ( send_live_analysis == 0 ) { + zmq_send(socket_live_, + (char*)data, + buffer_config::MODULE_N_BYTES * config_.n_modules, + ZMQ_NOBLOCK); + } else { + zmq_send(socket_live_, + (char*)data_empty, + 8, + ZMQ_NOBLOCK); + } } + + }