From 7bbd49726b4cbd280f8e085152b86b79713250e3 Mon Sep 17 00:00:00 2001 From: Luca Boccassi Date: Sat, 18 Feb 2023 14:20:54 +0000 Subject: [PATCH] Problem: no permission to relicense ZMQ_RECONNECT_IVL_MAX Solution: remove the implementation. Thijs Terlouw , the author, did not respond to requests to allow relicensing to MPL2, so we have to remove his copyrighted work. Remove the implementation and make get/set return -EOPNOTSUPP. --- doc/zmq_getsockopt.txt | 26 +++++++------------------- doc/zmq_setsockopt.txt | 23 ++++++----------------- src/options.cpp | 21 ++++++++++----------- src/options.hpp | 4 ---- src/stream_connecter_base.cpp | 11 ----------- 5 files changed, 23 insertions(+), 62 deletions(-) diff --git a/doc/zmq_getsockopt.txt b/doc/zmq_getsockopt.txt index accd5a2d..d244ae0c 100644 --- a/doc/zmq_getsockopt.txt +++ b/doc/zmq_getsockopt.txt @@ -619,23 +619,11 @@ Default value:: 100 Applicable socket types:: all, only for connection-oriented transports -ZMQ_RECONNECT_IVL_MAX: Retrieve maximum reconnection interval -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -The 'ZMQ_RECONNECT_IVL_MAX' option shall retrieve the maximum reconnection -interval for the specified 'socket'. This is the maximum period 0MQ shall wait -between attempts to reconnect. On each reconnect attempt, the previous interval -shall be doubled until ZMQ_RECONNECT_IVL_MAX is reached. This allows for -exponential backoff strategy. Default value means no exponential backoff is -performed and reconnect interval calculations are only based on -ZMQ_RECONNECT_IVL. - -NOTE: Values less than ZMQ_RECONNECT_IVL will be ignored. - -[horizontal] -Option value type:: int -Option value unit:: milliseconds -Default value:: 0 (only use ZMQ_RECONNECT_IVL) -Applicable socket types:: all, only for connection-oriented transport +ZMQ_RECONNECT_IVL_MAX: DEPRECATED +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The 'ZMQ_RECONNECT_IVL_MAX option is an empty stub that only returns an +*EOPNOTSUPP* error, as the author did not provide a relicense agreement for +the Mozilla Public License v2 relicense of libzmq. ZMQ_RECONNECT_STOP: Retrieve condition where reconnection will stop @@ -985,8 +973,8 @@ Applicable socket types:: All, when using TCP, IPC, PGM or NORM transport. ZMQ_TOPICS_COUNT: Number of topic subscriptions received ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -Gets the number of topic (prefix) subscriptions either -* received on a (X)PUB socket from all the connected (X)SUB sockets or +Gets the number of topic (prefix) subscriptions either +* received on a (X)PUB socket from all the connected (X)SUB sockets or * acknowledged on an (X)SUB socket from all the connected (X)PUB sockets NOTE: in DRAFT state, not yet available in stable releases. diff --git a/doc/zmq_setsockopt.txt b/doc/zmq_setsockopt.txt index 77712a41..fdd7e751 100644 --- a/doc/zmq_setsockopt.txt +++ b/doc/zmq_setsockopt.txt @@ -750,22 +750,11 @@ Default value:: 100 Applicable socket types:: all, only for connection-oriented transports -ZMQ_RECONNECT_IVL_MAX: Set maximum reconnection interval -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -The 'ZMQ_RECONNECT_IVL_MAX' option shall set the maximum reconnection interval -for the specified 'socket'. This is the maximum period 0MQ shall wait between -attempts to reconnect. On each reconnect attempt, the previous interval shall be -doubled until ZMQ_RECONNECT_IVL_MAX is reached. This allows for exponential -backoff strategy. Default value means no exponential backoff is performed and -reconnect interval calculations are only based on ZMQ_RECONNECT_IVL. - -NOTE: Values less than ZMQ_RECONNECT_IVL will be ignored. - -[horizontal] -Option value type:: int -Option value unit:: milliseconds -Default value:: 0 (only use ZMQ_RECONNECT_IVL) -Applicable socket types:: all, only for connection-oriented transports +ZMQ_RECONNECT_IVL_MAX: DEPRECATED +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +The 'ZMQ_RECONNECT_IVL_MAX option is an empty stub that only returns an +*EOPNOTSUPP* error, as the author did not provide a relicense agreement for +the Mozilla Public License v2 relicense of libzmq. ZMQ_RECONNECT_STOP: Set condition where reconnection will stop @@ -784,7 +773,7 @@ connection attempts to non-0MQ sockets. Note that when specifying this option you may also want to set `ZMQ_HANDSHAKE_IVL` -- the default handshake interval is 30000 (30 seconds), which is typically too large. -The 'ZMQ_RECONNECT_STOP_AFTER_DISCONNECT' option will stop reconnection when +The 'ZMQ_RECONNECT_STOP_AFTER_DISCONNECT' option will stop reconnection when zmq_disconnect() has been called. This can be useful when the user's request failed (server not ready), as the socket does not need to continue to reconnect after user disconnect actively. diff --git a/src/options.cpp b/src/options.cpp index 2c39c8ac..ca4ad49e 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -213,7 +213,6 @@ zmq::options_t::options_t () : tcp_maxrt (0), reconnect_stop (0), reconnect_ivl (100), - reconnect_ivl_max (0), backlog (100), maxmsgsize (-1), rcvtimeo (-1), @@ -428,11 +427,11 @@ int zmq::options_t::setsockopt (int option_, break; case ZMQ_RECONNECT_IVL_MAX: - if (is_int && value >= 0) { - reconnect_ivl_max = value; - return 0; - } - break; +#ifdef ZMQ_HAVE_WINDOWS + return WSAEOPNOTSUPP; +#else + return -EOPNOTSUPP; +#endif case ZMQ_BACKLOG: if (is_int && value >= 0) { @@ -1076,11 +1075,11 @@ int zmq::options_t::getsockopt (int option_, break; case ZMQ_RECONNECT_IVL_MAX: - if (is_int) { - *value = reconnect_ivl_max; - return 0; - } - break; +#ifdef ZMQ_HAVE_WINDOWS + return WSAEOPNOTSUPP; +#else + return -EOPNOTSUPP; +#endif case ZMQ_BACKLOG: if (is_int) { diff --git a/src/options.hpp b/src/options.hpp index 049e2a0c..54a725fd 100644 --- a/src/options.hpp +++ b/src/options.hpp @@ -127,10 +127,6 @@ struct options_t // Default 100ms int reconnect_ivl; - // Maximum interval between attempts to reconnect, in milliseconds. - // Default 0 (unused) - int reconnect_ivl_max; - // Maximum backlog for pending connections. int backlog; diff --git a/src/stream_connecter_base.cpp b/src/stream_connecter_base.cpp index 138d7d61..37dac995 100644 --- a/src/stream_connecter_base.cpp +++ b/src/stream_connecter_base.cpp @@ -123,17 +123,6 @@ int zmq::stream_connecter_base_t::get_new_reconnect_ivl () ? _current_reconnect_ivl + random_jitter : std::numeric_limits::max (); - // Only change the new current reconnect interval if the maximum reconnect - // interval was set and if it's larger than the reconnect interval. - if (options.reconnect_ivl_max > 0 - && options.reconnect_ivl_max > options.reconnect_ivl) { - // Calculate the next interval - _current_reconnect_ivl = - _current_reconnect_ivl < std::numeric_limits::max () / 2 - ? std::min (_current_reconnect_ivl * 2, options.reconnect_ivl_max) - : options.reconnect_ivl_max; - } - return interval; }