summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Sustrik <sustrik@250bpm.com>2011-03-24 14:36:40 +0100
committerMartin Sustrik <sustrik@250bpm.com>2011-03-24 14:36:40 +0100
commita2252de2bcecb672f09c8a5d0013cce23d1d404f (patch)
tree79e54107e3a7e4a5285f5873a95e0e177a48a0ae /src
parent8463b4d55e45ea29d5a23f867e7f1c0077279ee7 (diff)
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>
Diffstat (limited to 'src')
-rw-r--r--src/options.cpp22
-rw-r--r--src/options.hpp4
-rw-r--r--src/pgm_socket.cpp23
3 files changed, 7 insertions, 42 deletions
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;