Skip to content

Commit 5989203

Browse files
committed
Avoid using deprecated function zmq_recvmsg
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
1 parent 4d79066 commit 5989203

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

zmq.hpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,12 @@ typedef struct {
8686
} zmq_event_t;
8787
#endif
8888

89+
// Avoid using deprecated message receive function when possible
90+
#if ZMQ_VERSION < ZMQ_MAKE_VERSION(3, 2, 0)
91+
# define zmq_msg_recv zmq_recvmsg
92+
#endif
93+
94+
8995
// In order to prevent unused variable warnings when building in non-debug
9096
// mode use this macro to make assertions.
9197
#ifndef NDEBUG
@@ -659,7 +665,7 @@ namespace zmq
659665
while (true) {
660666
zmq_msg_t eventMsg;
661667
zmq_msg_init (&eventMsg);
662-
rc = zmq_recvmsg (s, &eventMsg, 0);
668+
rc = zmq_msg_recv (s, &eventMsg, 0);
663669
if (rc == -1 && zmq_errno() == ETERM)
664670
break;
665671
assert (rc != -1);
@@ -676,7 +682,7 @@ namespace zmq
676682
#ifdef ZMQ_NEW_MONITOR_EVENT_LAYOUT
677683
zmq_msg_t addrMsg;
678684
zmq_msg_init (&addrMsg);
679-
rc = zmq_recvmsg (s, &addrMsg, 0);
685+
rc = zmq_msg_recv (s, &addrMsg, 0);
680686
if (rc == -1 && zmq_errno() == ETERM)
681687
break;
682688
assert (rc != -1);

0 commit comments

Comments
 (0)