Merge pull request #603 from ricnewton/master

Add monitor event for when monitoring is stopped so we can unblock any sockets waiting on monitor socket.
This commit is contained in:
Ian Barber 2013-07-01 04:08:25 -07:00
commit 5a30022045
3 changed files with 14 additions and 2 deletions

View File

@ -314,12 +314,14 @@ ZMQ_EXPORT int zmq_msg_set (zmq_msg_t *msg, int option, int optval);
#define ZMQ_EVENT_CLOSED 128
#define ZMQ_EVENT_CLOSE_FAILED 256
#define ZMQ_EVENT_DISCONNECTED 512
#define ZMQ_EVENT_MONITOR_STOPPED 1024
#define ZMQ_EVENT_ALL ( ZMQ_EVENT_CONNECTED | ZMQ_EVENT_CONNECT_DELAYED | \
ZMQ_EVENT_CONNECT_RETRIED | ZMQ_EVENT_LISTENING | \
ZMQ_EVENT_BIND_FAILED | ZMQ_EVENT_ACCEPTED | \
ZMQ_EVENT_ACCEPT_FAILED | ZMQ_EVENT_CLOSED | \
ZMQ_EVENT_CLOSE_FAILED | ZMQ_EVENT_DISCONNECTED )
ZMQ_EVENT_CLOSE_FAILED | ZMQ_EVENT_DISCONNECTED | \
ZMQ_EVENT_MONITOR_STOPPED)
/* Socket event data */
typedef struct {

View File

@ -1221,6 +1221,12 @@ void zmq::socket_base_t::monitor_event (zmq_event_t event_, const std::string& a
void zmq::socket_base_t::stop_monitor()
{
if (monitor_socket) {
if (monitor_events & ZMQ_EVENT_MONITOR_STOPPED) {
zmq_event_t event;
event.event = ZMQ_EVENT_MONITOR_STOPPED;
event.value = 0;
monitor_event (event, "");
}
zmq_close (monitor_socket);
monitor_socket = NULL;
monitor_events = 0;

View File

@ -58,7 +58,11 @@ static bool read_msg(void* s, zmq_event_t& event, std::string& ep)
memcpy(&event.value, data+sizeof(event.event), sizeof(event.value));
// copy address part
ep = std::string((char*)zmq_msg_data(&msg2), zmq_msg_size(&msg2));
return false ;
if (event.event == ZMQ_EVENT_MONITOR_STOPPED)
return true;
return false;
}