mirror of
https://github.com/zeromq/libzmq.git
synced 2025-10-13 14:45:38 +02: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:
@@ -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.
|
||||
|
Reference in New Issue
Block a user