From a2252de2bcecb672f09c8a5d0013cce23d1d404f Mon Sep 17 00:00:00 2001 From: Martin Sustrik Date: Thu, 24 Mar 2011 14:36:40 +0100 Subject: ZMQ_RECOVERY_IVL and ZMQ_RECOVERY_IVL_MSEC reconciled There's only one option now -- ZMQ_RECOVRY_IVL -- and it's measured in milliseconds. Signed-off-by: Martin Sustrik --- doc/zmq_getsockopt.txt | 24 ++---------------------- doc/zmq_setsockopt.txt | 31 +++---------------------------- include/zmq.h | 1 - src/options.cpp | 22 ++-------------------- src/options.hpp | 4 +--- src/pgm_socket.cpp | 23 ++++------------------- 6 files changed, 12 insertions(+), 93 deletions(-) diff --git a/doc/zmq_getsockopt.txt b/doc/zmq_getsockopt.txt index 81dcba3..f2ad575 100644 --- a/doc/zmq_getsockopt.txt +++ b/doc/zmq_getsockopt.txt @@ -141,33 +141,13 @@ ZMQ_RECOVERY_IVL: Get multicast recovery interval ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_RECOVERY_IVL' option shall retrieve the recovery interval for multicast transports using the specified 'socket'. The recovery interval -determines the maximum time in seconds that a receiver can be absent from a +determines the maximum time in milliseconds that a receiver can be absent from a multicast group before unrecoverable data loss will occur. -[horizontal] -Option value type:: int64_t -Option value unit:: seconds -Default value:: 10 -Applicable socket types:: all, when using multicast transports - - -ZMQ_RECOVERY_IVL_MSEC: Get multicast recovery interval in milliseconds -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -The 'ZMQ_RECOVERY_IVL'_MSEC option shall retrieve the recovery interval, in -milliseconds, for multicast transports using the specified 'socket'. The -recovery interval determines the maximum time in seconds that a receiver -can be absent from a multicast group before unrecoverable data loss will -occur. - -For backward compatibility, the default value of 'ZMQ_RECOVERY_IVL_MSEC' is --1 indicating that the recovery interval should be obtained from the -'ZMQ_RECOVERY_IVL' option. However, if the 'ZMQ_RECOVERY_IVL_MSEC' value is -not zero, then it will take precedence, and be used. - [horizontal] Option value type:: int64_t Option value unit:: milliseconds -Default value:: -1 +Default value:: 10000 Applicable socket types:: all, when using multicast transports diff --git a/doc/zmq_setsockopt.txt b/doc/zmq_setsockopt.txt index 5d93a62..3cf3276 100644 --- a/doc/zmq_setsockopt.txt +++ b/doc/zmq_setsockopt.txt @@ -143,32 +143,8 @@ ZMQ_RECOVERY_IVL: Set multicast recovery interval ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_RECOVERY_IVL' option shall set the recovery interval for multicast transports using the specified 'socket'. The recovery interval determines the -maximum time in seconds that a receiver can be absent from a multicast group -before unrecoverable data loss will occur. - -CAUTION: Exercise care when setting large recovery intervals as the data -needed for recovery will be held in memory. For example, a 1 minute recovery -interval at a data rate of 1Gbps requires a 7GB in-memory buffer. - -[horizontal] -Option value type:: int64_t -Option value unit:: seconds -Default value:: 10 -Applicable socket types:: all, when using multicast transports - - -ZMQ_RECOVERY_IVL_MSEC: Set multicast recovery interval in milliseconds -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -The 'ZMQ_RECOVERY_IVL_MSEC' option shall set the recovery interval, specified -in milliseconds (ms) for multicast transports using the specified 'socket'. -The recovery interval determines the maximum time in milliseconds that a -receiver can be absent from a multicast group before unrecoverable data loss -will occur. - -A non-zero value of the 'ZMQ_RECOVERY_IVL_MSEC' option will take precedence -over the 'ZMQ_RECOVERY_IVL' option, but since the default for the -'ZMQ_RECOVERY_IVL_MSEC' is -1, the default is to use the 'ZMQ_RECOVERY_IVL' -option value. +maximum time in milliseconds that a receiver can be absent from a multicast +group before unrecoverable data loss will occur. CAUTION: Exercise care when setting large recovery intervals as the data needed for recovery will be held in memory. For example, a 1 minute recovery @@ -177,10 +153,9 @@ interval at a data rate of 1Gbps requires a 7GB in-memory buffer. [horizontal] Option value type:: int64_t Option value unit:: milliseconds -Default value:: -1 +Default value:: 10000 Applicable socket types:: all, when using multicast transports - ZMQ_SNDBUF: Set kernel transmit buffer size ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_SNDBUF' option shall set the underlying kernel transmit buffer size diff --git a/include/zmq.h b/include/zmq.h index aa16554..27aeb29 100644 --- a/include/zmq.h +++ b/include/zmq.h @@ -199,7 +199,6 @@ ZMQ_EXPORT int zmq_term (void *context); #define ZMQ_LINGER 17 #define ZMQ_RECONNECT_IVL 18 #define ZMQ_BACKLOG 19 -#define ZMQ_RECOVERY_IVL_MSEC 20 /* opt. recovery time, reconcile in 3.x */ #define ZMQ_RECONNECT_IVL_MAX 21 #define ZMQ_MAXMSGSIZE 22 diff --git a/src/options.cpp b/src/options.cpp index 9916475..a053048 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -29,8 +29,7 @@ zmq::options_t::options_t () : hwm (0), affinity (0), rate (100), - recovery_ivl (10), - recovery_ivl_msec (-1), + recovery_ivl (10000), sndbuf (0), rcvbuf (0), type (-1), @@ -80,7 +79,7 @@ int zmq::options_t::setsockopt (int option_, const void *optval_, return 0; case ZMQ_RATE: - if (optvallen_ != sizeof (int64_t) || *((int64_t*) optval_) < 0) { + if (optvallen_ != sizeof (int64_t) || *((int64_t*) optval_) <= 0) { errno = EINVAL; return -1; } @@ -95,14 +94,6 @@ int zmq::options_t::setsockopt (int option_, const void *optval_, recovery_ivl = (uint32_t) *((int64_t*) optval_); return 0; - case ZMQ_RECOVERY_IVL_MSEC: - if (optvallen_ != sizeof (int64_t) || *((int64_t*) optval_) < 0) { - errno = EINVAL; - return -1; - } - recovery_ivl_msec = (int32_t) *((int64_t*) optval_); - return 0; - case ZMQ_SNDBUF: if (optvallen_ != sizeof (uint64_t)) { errno = EINVAL; @@ -223,15 +214,6 @@ int zmq::options_t::getsockopt (int option_, void *optval_, size_t *optvallen_) *optvallen_ = sizeof (int64_t); return 0; - case ZMQ_RECOVERY_IVL_MSEC: - if (*optvallen_ < sizeof (int64_t)) { - errno = EINVAL; - return -1; - } - *((int64_t*) optval_) = recovery_ivl_msec; - *optvallen_ = sizeof (int64_t); - return 0; - case ZMQ_SNDBUF: if (*optvallen_ < sizeof (uint64_t)) { errno = EINVAL; diff --git a/src/options.hpp b/src/options.hpp index a1f9f33..8b5864e 100644 --- a/src/options.hpp +++ b/src/options.hpp @@ -42,10 +42,8 @@ namespace zmq // Maximum tranfer rate [kb/s]. Default 100kb/s. uint32_t rate; - // Reliability time interval [s]. Default 10s. + // Reliability time interval [ms]. Default 10 seconds. uint32_t recovery_ivl; - // Reliability time interval [ms]. Default -1 = not used. - int32_t recovery_ivl_msec; uint64_t sndbuf; uint64_t rcvbuf; diff --git a/src/pgm_socket.cpp b/src/pgm_socket.cpp index 89cdcea..10d8f39 100644 --- a/src/pgm_socket.cpp +++ b/src/pgm_socket.cpp @@ -83,19 +83,9 @@ int zmq::pgm_socket_t::init (bool udp_encapsulation_, const char *network_) } memset (network, '\0', sizeof (network)); memcpy (network, network_, port_delim - network_); - - // Validate socket options - // Data rate is in [B/s]. options.rate is in [kb/s]. - if (options.rate <= 0) { - errno = EINVAL; - return -1; - } - // Recovery interval [s] or [ms] - based on the user's call - if ((options.recovery_ivl <= 0) && (options.recovery_ivl_msec <= 0)) { - errno = EINVAL; - return -1; - } + zmq_assert (options.rate > 0); + // Zero counter used in msgrecv. nbytes_rec = 0; nbytes_processed = 0; @@ -679,19 +669,14 @@ int zmq::pgm_socket_t::compute_sqns (int tpdu_) { // Convert rate into B/ms. uint64_t rate = ((uint64_t) options.rate) / 8; - - // Get recovery interval in milliseconds. - uint64_t interval = options.recovery_ivl_msec >= 0 ? - options.recovery_ivl_msec : - options.recovery_ivl * 1000; // Compute the size of the buffer in bytes. - uint64_t size = interval * rate; + uint64_t size = options.recovery_ivl * rate; // Translate the size into number of packets. uint64_t sqns = size / tpdu_; - // Buffer should be able to contain at least one packet. + // Buffer should be able to hold at least one packet. if (sqns == 0) sqns = 1; -- cgit v1.2.3