summaryrefslogtreecommitdiffstats
path: root/src/publisher
diff options
context:
space:
mode:
authorimarom <imarom@cisco.com>2017-02-27 14:46:46 +0200
committerimarom <imarom@cisco.com>2017-02-27 14:49:49 +0200
commitfd87764ebc8733b44bc4a43a180b635ce190a123 (patch)
tree85214d10351544328eb2f0b38effdd55bd67507b /src/publisher
parent768b4f27f89fc4ed40c8588db3b3a751abf41d5e (diff)
ZMQ publisher might hang if it sends a message during ctrl + c
the reason is that when calling zmq_close and zmq_term from the same thread, zmq_close will wait for the message to be sent (but will return the control to the calling thread) and then zmq_ctx_destroy will hang forever see: https://lists.zeromq.org/pipermail/zeromq-dev/2013-September/022469.html Signed-off-by: imarom <imarom@cisco.com>
Diffstat (limited to 'src/publisher')
-rw-r--r--src/publisher/trex_publisher.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/publisher/trex_publisher.cpp b/src/publisher/trex_publisher.cpp
index dc37d14c..f5437378 100644
--- a/src/publisher/trex_publisher.cpp
+++ b/src/publisher/trex_publisher.cpp
@@ -73,6 +73,13 @@ TrexPublisher::Create(uint16_t port, bool disable){
void
TrexPublisher::Delete(){
if (m_publisher) {
+
+ /* before calling zmq_close set the linger property to zero
+ (othersie zmq_ctx_destroy might hang forever)
+ */
+ int val = 0;
+ zmq_setsockopt(m_publisher, ZMQ_LINGER, &val, sizeof(val));
+
zmq_close (m_publisher);
m_publisher = NULL;
}