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

Commit c69c293

Browse files
committed
Use feature tests for checking if we have zmq::socket::disconnect
Since 9c02de3 (- Commit after merge with NextRelease branch at release 22135, 2013-02-22) we check the libzmq version to decide if cppzmq's socket class has a disconnect method or not. This currently fails on debian wheezy. As that is also the wrong approach in general, we now use a compilation test in the cmake setup phase to determine if we have the disconnect method or not. This is only done on non-Windows platforms, on Windows we assume that we have a disconnect method (we currently always compile against a cppzmq version which has it). In addition the define got also renamed from ZMQ_HAS_DISCONNECT to TANGO_ZMQ_HAS_DISCONNECT to make it clear that this is our define.
1 parent 7e7846d commit c69c293

File tree

6 files changed

+30
-15
lines changed

6 files changed

+30
-15
lines changed

configure/CMakeLists.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,18 @@ Please install cppzmq (https://github.com/zeromq/cppzmq) on your system and/or u
151151
<OMNI_BASE>/include and system include directories).")
152152
endif()
153153

154+
if(NOT WIN32)
155+
try_compile(TANGO_ZMQ_HAS_DISCONNECT ${CMAKE_BINARY_DIR}/test_cppzmq_disconnect
156+
SOURCES ${CMAKE_SOURCE_DIR}/configure/test_cppzmq_disconnect.cpp
157+
COMPILE_DEFINITIONS "-I ${CPPZMQ_BASE}/include -I ${ZMQ_BASE}/include"
158+
LINK_LIBRARIES "${ZMQ_PKG_LIBRARIES}")
159+
160+
message(STATUS "Check if zmq::socket has a disconnect method: ${TANGO_ZMQ_HAS_DISCONNECT}")
161+
else()
162+
set(TANGO_ZMQ_HAS_DISCONNECT TRUE)
163+
message(STATUS "Check if zmq::socket has a disconnect method: ${TANGO_ZMQ_HAS_DISCONNECT} (hardcoded)")
164+
endif(NOT WIN32)
165+
154166
message("Verifying ${OMNIIDL_PATH}omniidl")
155167
if(WIN32)
156168
execute_process(COMMAND ${OMNIIDL_PATH}omniidl.exe -V RESULT_VARIABLE FAILED)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#include <zmq.hpp>
2+
3+
int main(int, char**)
4+
{
5+
zmq::context_t c;
6+
zmq::socket_t s(c, ZMQ_REQ);
7+
s.disconnect("some endpoint");
8+
}

cppapi/client/eventconsumer.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,6 @@
4545

4646
#include <zmq.hpp>
4747

48-
#ifdef ZMQ_VERSION
49-
#if ZMQ_VERSION > 30201
50-
#define ZMQ_HAS_DISCONNECT
51-
#endif
52-
#endif
53-
54-
5548
namespace Tango
5649
{
5750

cppapi/client/eventkeepalive.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ bool EventConsumerKeepAliveThread::reconnect_to_zmq_channel(EvChanIte &ipos,Even
188188

189189
string adm_name = ipos->second.full_adm_name;
190190

191-
#ifdef ZMQ_HAS_DISCONNECT
191+
#ifdef TANGO_ZMQ_HAS_DISCONNECT
192192
//
193193
// Forget exception which could happen during massive restart of device server process running on the same host
194194
//
@@ -406,7 +406,7 @@ void EventConsumerKeepAliveThread::re_subscribe_event(EvCbIte &epos,EvChanIte &i
406406
void EventConsumerKeepAliveThread::reconnect_to_zmq_event(EvChanIte &ipos,EventConsumer *event_consumer,DeviceData &dd)
407407
{
408408
EvCbIte epos;
409-
#ifdef ZMQ_HAS_DISCONNECT
409+
#ifdef TANGO_ZMQ_HAS_DISCONNECT
410410
bool disconnect_called = false;
411411
#endif
412412

@@ -448,7 +448,7 @@ void EventConsumerKeepAliveThread::reconnect_to_zmq_event(EvChanIte &ipos,EventC
448448
string prefix = fqen.substr(0,pos + 1);
449449
d_name.insert(0,prefix);
450450

451-
#ifdef ZMQ_HAS_DISCONNECT
451+
#ifdef TANGO_ZMQ_HAS_DISCONNECT
452452
if (disconnect_called == false)
453453
{
454454
event_consumer->disconnect_event(epos->second.fully_qualified_event_name,epos->second.endpoint);

cppapi/client/zmqeventconsumer.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,7 @@ bool ZmqEventConsumer::process_ctrl(zmq::message_t &received_ctrl,zmq::pollitem_
800800
//
801801

802802
const char *event_name = &(tmp_ptr[1]);
803-
#ifdef ZMQ_HAS_DISCONNECT
803+
#ifdef TANGO_ZMQ_HAS_DISCONNECT
804804
const char *endpoint = &(tmp_ptr[1 + ::strlen(event_name) + 1]);
805805
const char *endpoint_event = &(tmp_ptr[1 + ::strlen(event_name) + ::strlen(endpoint) + 2]);
806806
#endif
@@ -822,7 +822,7 @@ bool ZmqEventConsumer::process_ctrl(zmq::message_t &received_ctrl,zmq::pollitem_
822822
multi_tango_host(heartbeat_sub_sock,UNSUBSCRIBE,base_name);
823823
}
824824

825-
#ifdef ZMQ_HAS_DISCONNECT
825+
#ifdef TANGO_ZMQ_HAS_DISCONNECT
826826
//
827827
// Remove the endpoint in the vector of already connected heartbeat and disconnect the socket to this endpoint
828828
//
@@ -1349,7 +1349,7 @@ void ZmqEventConsumer::connect_event_channel(string &channel_name,TANGO_UNUSED(D
13491349
buffer[length] = ZMQ_CONNECT_HEARTBEAT;
13501350
length++;
13511351

1352-
#ifdef ZMQ_HAS_DISCONNECT
1352+
#ifdef TANGO_ZMQ_HAS_DISCONNECT
13531353
buffer[length] = 0;
13541354
#else
13551355
if (reconnect == true)
@@ -1721,7 +1721,7 @@ void ZmqEventConsumer::connect_event_system(TANGO_UNUSED(string &device_name),TA
17211721
buffer[length] = ZMQ_CONNECT_EVENT;
17221722
length++;
17231723

1724-
#ifdef ZMQ_HAS_DISCONNECT
1724+
#ifdef TANGO_ZMQ_HAS_DISCONNECT
17251725
buffer[length] = 0;
17261726
#else
17271727
if (filters.size() == 1 && filters[0] == "reconnect")
@@ -3546,7 +3546,7 @@ ReceivedFromAdmin ZmqEventConsumer::initialize_received_from_admin(const Tango::
35463546
return result;
35473547
}
35483548

3549-
#ifdef ZMQ_HAS_DISCONNECT
3549+
#ifdef TANGO_ZMQ_HAS_DISCONNECT
35503550
void ZmqEventConsumer::disconnect_socket(zmq::socket_t& socket, const char* endpoint)
35513551
{
35523552
try

cppapi/server/tango_const.h.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,8 @@ const int PUB_HWM = 1000;
146146
const int SUB_HWM = 1000;
147147
const int SUB_SEND_HWM = 10000;
148148

149+
#cmakedefine TANGO_ZMQ_HAS_DISCONNECT
150+
149151
//
150152
// Event when using a file as database stuff
151153
//

0 commit comments

Comments
 (0)