mirror of
https://github.com/zeromq/libzmq.git
synced 2025-03-09 07:16:04 +00:00
fixes #1315 socket monitor hangs if zmq_bind fails
This commit is contained in:
parent
a28398a4e8
commit
516b440e0d
@ -1497,12 +1497,12 @@ int zmq::socket_base_t::monitor (const char *addr_, int events_)
|
|||||||
int linger = 0;
|
int linger = 0;
|
||||||
int rc = zmq_setsockopt (monitor_socket, ZMQ_LINGER, &linger, sizeof (linger));
|
int rc = zmq_setsockopt (monitor_socket, ZMQ_LINGER, &linger, sizeof (linger));
|
||||||
if (rc == -1)
|
if (rc == -1)
|
||||||
stop_monitor ();
|
stop_monitor (false);
|
||||||
|
|
||||||
// Spawn the monitor socket endpoint
|
// Spawn the monitor socket endpoint
|
||||||
rc = zmq_bind (monitor_socket, addr_);
|
rc = zmq_bind (monitor_socket, addr_);
|
||||||
if (rc == -1)
|
if (rc == -1)
|
||||||
stop_monitor ();
|
stop_monitor (false);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1598,10 +1598,10 @@ void zmq::socket_base_t::monitor_event (int event_, int value_, const std::strin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void zmq::socket_base_t::stop_monitor (void)
|
void zmq::socket_base_t::stop_monitor (bool send_monitor_stopped_event_)
|
||||||
{
|
{
|
||||||
if (monitor_socket) {
|
if (monitor_socket) {
|
||||||
if (monitor_events & ZMQ_EVENT_MONITOR_STOPPED)
|
if ((monitor_events & ZMQ_EVENT_MONITOR_STOPPED) && send_monitor_stopped_event_)
|
||||||
monitor_event (ZMQ_EVENT_MONITOR_STOPPED, 0, "");
|
monitor_event (ZMQ_EVENT_MONITOR_STOPPED, 0, "");
|
||||||
zmq_close (monitor_socket);
|
zmq_close (monitor_socket);
|
||||||
monitor_socket = NULL;
|
monitor_socket = NULL;
|
||||||
|
@ -175,7 +175,7 @@ namespace zmq
|
|||||||
void monitor_event (int event_, int value_, const std::string& addr_);
|
void monitor_event (int event_, int value_, const std::string& addr_);
|
||||||
|
|
||||||
// Monitor socket cleanup
|
// Monitor socket cleanup
|
||||||
void stop_monitor ();
|
void stop_monitor (bool send_monitor_stopped_event_ = true);
|
||||||
|
|
||||||
// Next assigned name on a zmq_connect() call used by ROUTER and STREAM socket types
|
// Next assigned name on a zmq_connect() call used by ROUTER and STREAM socket types
|
||||||
std::string connect_rid;
|
std::string connect_rid;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user