mirror of
https://github.com/zeromq/libzmq.git
synced 2025-10-28 19:52:00 +01:00
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 <sustrik@250bpm.com>
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -84,17 +84,7 @@ 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;
|
||||
@@ -680,18 +670,13 @@ 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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user