Skip to content

Commit

Permalink
Avoid using deprecated function zmq_recvmsg
Browse files Browse the repository at this point in the history
The zmq_recvmsg() function has been replaced by zmq_msg_recv() since version 3.2.0, and has since been marked as deprecated.
See: https://raw.githubusercontent.com/zeromq/zeromq3-x/master/NEWS
Replace our uses of the old function (which was in monitor_t::monitor()) with the more modern function call. Support backwards compatibility with a #DEFINE macro for versions of zmq preceeding 3.2.0
  • Loading branch information
gdfast committed Nov 10, 2015
1 parent 4d79066 commit 5989203
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions zmq.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ typedef struct {
} zmq_event_t;
#endif

// Avoid using deprecated message receive function when possible
#if ZMQ_VERSION < ZMQ_MAKE_VERSION(3, 2, 0)
# define zmq_msg_recv zmq_recvmsg
#endif


// In order to prevent unused variable warnings when building in non-debug
// mode use this macro to make assertions.
#ifndef NDEBUG
Expand Down Expand Up @@ -659,7 +665,7 @@ namespace zmq
while (true) {
zmq_msg_t eventMsg;
zmq_msg_init (&eventMsg);
rc = zmq_recvmsg (s, &eventMsg, 0);
rc = zmq_msg_recv (s, &eventMsg, 0);
if (rc == -1 && zmq_errno() == ETERM)
break;
assert (rc != -1);
Expand All @@ -676,7 +682,7 @@ namespace zmq
#ifdef ZMQ_NEW_MONITOR_EVENT_LAYOUT
zmq_msg_t addrMsg;
zmq_msg_init (&addrMsg);
rc = zmq_recvmsg (s, &addrMsg, 0);
rc = zmq_msg_recv (s, &addrMsg, 0);
if (rc == -1 && zmq_errno() == ETERM)
break;
assert (rc != -1);
Expand Down

0 comments on commit 5989203

Please sign in to comment.