Skip to content
This repository was archived by the owner on Jul 8, 2022. It is now read-only.

Commit 1199ea1

Browse files
committed
Set the ZMQ Receive Buffer High Water Mark only if it changes (#444)
This is to reduce the impact of a bug present in ZMQ 4.2.0 and ZMQ 4.2.1 which led to a bad lwm and hwm calculation when ZMQ_RCVHWM was set after the bind of the socket. See cppTango#444 for more details
1 parent e0d625d commit 1199ea1

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

cppapi/client/zmqeventconsumer.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -886,7 +886,17 @@ bool ZmqEventConsumer::process_ctrl(zmq::message_t &received_ctrl,zmq::pollitem_
886886

887887
if (connect_pub == true)
888888
{
889-
event_sub_sock->setsockopt(ZMQ_RCVHWM,&sub_hwm,sizeof(sub_hwm));
889+
int current_sub_hwm = SUB_HWM;
890+
size_t curr_sub_hw_size = sizeof(current_sub_hwm);
891+
event_sub_sock->getsockopt(ZMQ_RCVHWM,&current_sub_hwm, &curr_sub_hw_size);
892+
if(sub_hwm != current_sub_hwm)
893+
{
894+
// Set the ZMQ Receive Buffer High Water Mark only if it changes
895+
// This is to reduce the impact of a bug present in ZMQ 4.2.0 and ZMQ 4.2.1
896+
// which leads to a bad lwm and hwm calculation when ZMQ_RCVHWM is set after
897+
// the bind of the socket. See cppTango#444 for more details
898+
event_sub_sock->setsockopt(ZMQ_RCVHWM, &sub_hwm, sizeof(sub_hwm));
899+
}
890900

891901
event_sub_sock->connect(endpoint);
892902
if (force_connect == 0)

0 commit comments

Comments
 (0)