mirror of
https://github.com/zeromq/libzmq.git
synced 2025-10-30 13:47:13 +01:00
Problem: zmq_connect fails after disconnect due to RECONNECT_IVL == -1
Solution: when a connection breaks and ZMQ_RECONNECT_IVL is set to -1, which means a reconnection will not be attempted, send a message from the I/O thread to the application thread to make the socket call term_endpoint, which is the equivalent of manually calling zmq_disconnect. This way subsequent zmq_connect call to the same endpoint will attempt again to do a connection. Otherwise, for some socket types like SUBs, those new connects will fail as the endpoint is recorded, despite the connection having been permanently closed. Add test cases to exercise this corner case with TCP and IPC.
This commit is contained in:
@@ -134,6 +134,10 @@ void zmq::object_t::process_command (command_t &cmd_)
|
||||
process_term_ack ();
|
||||
break;
|
||||
|
||||
case command_t::term_endpoint:
|
||||
process_term_endpoint (cmd_.args.term_endpoint.endpoint);
|
||||
break;
|
||||
|
||||
case command_t::reap:
|
||||
process_reap (cmd_.args.reap.socket);
|
||||
break;
|
||||
@@ -332,6 +336,16 @@ void zmq::object_t::send_term_ack (own_t *destination_)
|
||||
send_command (cmd);
|
||||
}
|
||||
|
||||
void zmq::object_t::send_term_endpoint (own_t *destination_,
|
||||
std::string *endpoint_)
|
||||
{
|
||||
command_t cmd;
|
||||
cmd.destination = destination_;
|
||||
cmd.type = command_t::term_endpoint;
|
||||
cmd.args.term_endpoint.endpoint = endpoint_;
|
||||
send_command (cmd);
|
||||
}
|
||||
|
||||
void zmq::object_t::send_reap (class socket_base_t *socket_)
|
||||
{
|
||||
command_t cmd;
|
||||
@@ -435,6 +449,11 @@ void zmq::object_t::process_term_ack ()
|
||||
zmq_assert (false);
|
||||
}
|
||||
|
||||
void zmq::object_t::process_term_endpoint (std::string *)
|
||||
{
|
||||
zmq_assert (false);
|
||||
}
|
||||
|
||||
void zmq::object_t::process_reap (class socket_base_t *)
|
||||
{
|
||||
zmq_assert (false);
|
||||
|
||||
Reference in New Issue
Block a user