From 107581213cd04e14d5b44efa1730a0134f958a92 Mon Sep 17 00:00:00 2001 From: Emmanuel Taurel Date: Tue, 20 Mar 2012 09:22:27 +0100 Subject: [PATCH] Disable reconnection option Add value -1 to the ZMQ_RECONNECT_IVL to disable the reconnection algorithm --- doc/zmq_getsockopt.txt | 2 +- doc/zmq_setsockopt.txt | 2 +- src/options.cpp | 2 +- src/session_base.cpp | 3 ++- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/doc/zmq_getsockopt.txt b/doc/zmq_getsockopt.txt index 66cfe912..c110abaa 100644 --- a/doc/zmq_getsockopt.txt +++ b/doc/zmq_getsockopt.txt @@ -223,7 +223,7 @@ ZMQ_RECONNECT_IVL: Retrieve reconnection interval The 'ZMQ_RECONNECT_IVL' option shall retrieve the initial reconnection interval for the specified 'socket'. The reconnection interval is the period 0MQ shall wait between attempts to reconnect disconnected peers when using -connection-oriented transports. +connection-oriented transports. The value -1 means no reconnection. NOTE: The reconnection interval may be randomized by 0MQ to prevent reconnection storms in topologies with a large number of peers per socket. diff --git a/doc/zmq_setsockopt.txt b/doc/zmq_setsockopt.txt index 68a5ffc6..e785da8e 100644 --- a/doc/zmq_setsockopt.txt +++ b/doc/zmq_setsockopt.txt @@ -232,7 +232,7 @@ ZMQ_RECONNECT_IVL: Set reconnection interval The 'ZMQ_RECONNECT_IVL' option shall set the initial reconnection interval for the specified 'socket'. The reconnection interval is the period 0MQ shall wait between attempts to reconnect disconnected peers when using -connection-oriented transports. +connection-oriented transports. The value -1 means no reconnection. NOTE: The reconnection interval may be randomized by 0MQ to prevent reconnection storms in topologies with a large number of peers per socket. diff --git a/src/options.cpp b/src/options.cpp index 5f1d4440..58263e0d 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -140,7 +140,7 @@ int zmq::options_t::setsockopt (int option_, const void *optval_, errno = EINVAL; return -1; } - if (*((int*) optval_) < 0) { + if (*((int*) optval_) < -1) { errno = EINVAL; return -1; } diff --git a/src/session_base.cpp b/src/session_base.cpp index 6dc5166f..9c0d9e66 100644 --- a/src/session_base.cpp +++ b/src/session_base.cpp @@ -375,7 +375,8 @@ void zmq::session_base_t::detached () } // Reconnect. - start_connecting (true); + if (options.reconnect_ivl != -1) + start_connecting (true); // For subscriber sockets we hiccup the inbound pipe, which will cause // the socket object to resend all the subscriptions.