Skip to content
This repository was archived by the owner on Jul 8, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cppapi/client/eventconsumer.h
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,7 @@ private :
void print_error_message(const char *mess) {ApiUtil *au=ApiUtil::instance();au->print_error_message(mess);}
void set_ctrl_sock_bound() {sock_bound_mutex.lock();ctrl_socket_bound=true;sock_bound_mutex.unlock();}
bool is_ctrl_sock_bound() {bool _b;sock_bound_mutex.lock();_b=ctrl_socket_bound;sock_bound_mutex.unlock();return _b;}
void set_socket_hwm(size_t hwm);

bool check_zmq_endpoint(const string &);

Expand Down
22 changes: 21 additions & 1 deletion cppapi/client/zmqeventconsumer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,7 @@ bool ZmqEventConsumer::process_ctrl(zmq::message_t &received_ctrl,zmq::pollitem_

if (connect_pub == true)
{
event_sub_sock->setsockopt(ZMQ_RCVHWM,&sub_hwm,sizeof(sub_hwm));
set_socket_hwm(sub_hwm);

event_sub_sock->connect(endpoint);
if (force_connect == 0)
Expand Down Expand Up @@ -3497,6 +3497,26 @@ void ZmqEventConsumer::get_subscribed_event_ids(DeviceProxy *_dev,vector<int> &_
}
}

/**
*
* Set the ZMQ Receive Buffer High Water Mark only if it changes
* This is to reduce the impact of a bug present in ZMQ 4.2.0 and ZMQ 4.2.1
* which leads to a bad lwm and hwm calculation when ZMQ_RCVHWM is set after
* the bind of the socket. See cppTango#444 for more details
*
* @param hwm: new ZMQ receive buffer high water mark
*/
void ZmqEventConsumer::set_socket_hwm(size_t hwm)
{
int current_sub_hwm = SUB_HWM;
size_t curr_sub_hw_size = sizeof(current_sub_hwm);
event_sub_sock->getsockopt(ZMQ_RCVHWM,&current_sub_hwm, &curr_sub_hw_size);
if(hwm != current_sub_hwm)
{
event_sub_sock->setsockopt(ZMQ_RCVHWM, &hwm, sizeof(hwm));
}
}

//--------------------------------------------------------------------------------------------------------------------
//
// method :
Expand Down