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:
Luca Boccassi
2017-09-19 00:14:10 +01:00
parent e2f2193bec
commit edb4ca1023
10 changed files with 196 additions and 0 deletions

View File

@@ -536,6 +536,11 @@ void zmq::session_base_t::reconnect ()
// Reconnect.
if (options.reconnect_ivl != -1)
start_connecting (true);
else {
std::string *ep = new (std::string);
addr->to_string (*ep);
send_term_endpoint (socket, ep);
}
// For subscriber sockets we hiccup the inbound pipe, which will cause
// the socket object to resend all the subscriptions.