From bd9d7715ebe864d1aa85700d1b55b4f37568a1a4 Mon Sep 17 00:00:00 2001 From: Martin Sustrik Date: Thu, 24 Mar 2011 15:18:20 +0100 Subject: [PATCH] ZMQ_RATE and ZMQ_RECOVERY_IVL types cahnged to int Signed-off-by: Martin Sustrik --- doc/zmq_getsockopt.txt | 4 ++-- doc/zmq_setsockopt.txt | 4 ++-- src/options.cpp | 21 ++++++++++----------- src/options.hpp | 5 +++-- src/pgm_socket.cpp | 4 ++-- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/doc/zmq_getsockopt.txt b/doc/zmq_getsockopt.txt index 8189cf37..88a4071b 100644 --- a/doc/zmq_getsockopt.txt +++ b/doc/zmq_getsockopt.txt @@ -131,7 +131,7 @@ The 'ZMQ_RATE' option shall retrieve the maximum send or receive data rate for multicast transports using the specified 'socket'. [horizontal] -Option value type:: int64_t +Option value type:: int Option value unit:: kilobits per second Default value:: 100 Applicable socket types:: all, when using multicast transports @@ -145,7 +145,7 @@ 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 type:: int Option value unit:: milliseconds Default value:: 10000 Applicable socket types:: all, when using multicast transports diff --git a/doc/zmq_setsockopt.txt b/doc/zmq_setsockopt.txt index 0d1de3d5..f4863050 100644 --- a/doc/zmq_setsockopt.txt +++ b/doc/zmq_setsockopt.txt @@ -133,7 +133,7 @@ The 'ZMQ_RATE' option shall set the maximum send or receive data rate for multicast transports such as linkzmq:zmq_pgm[7] using the specified 'socket'. [horizontal] -Option value type:: int64_t +Option value type:: int Option value unit:: kilobits per second Default value:: 100 Applicable socket types:: all, when using multicast transports @@ -151,7 +151,7 @@ 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 type:: int Option value unit:: milliseconds Default value:: 10000 Applicable socket types:: all, when using multicast transports diff --git a/src/options.cpp b/src/options.cpp index 4c1289ad..13332dac 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -79,19 +79,19 @@ 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 (int) || *((int*) optval_) <= 0) { errno = EINVAL; return -1; } - rate = (uint32_t) *((int64_t*) optval_); + rate = *((int*) optval_); return 0; case ZMQ_RECOVERY_IVL: - if (optvallen_ != sizeof (int64_t) || *((int64_t*) optval_) < 0) { + if (optvallen_ != sizeof (int) || *((int*) optval_) < 0) { errno = EINVAL; return -1; } - recovery_ivl = (uint32_t) *((int64_t*) optval_); + recovery_ivl = *((int*) optval_); return 0; case ZMQ_SNDBUF: @@ -195,23 +195,22 @@ int zmq::options_t::getsockopt (int option_, void *optval_, size_t *optvallen_) *optvallen_ = identity.size (); return 0; - case ZMQ_RATE: - if (*optvallen_ < sizeof (int64_t)) { + if (*optvallen_ < sizeof (int)) { errno = EINVAL; return -1; } - *((int64_t*) optval_) = rate; - *optvallen_ = sizeof (int64_t); + *((int*) optval_) = rate; + *optvallen_ = sizeof (int); return 0; case ZMQ_RECOVERY_IVL: - if (*optvallen_ < sizeof (int64_t)) { + if (*optvallen_ < sizeof (int)) { errno = EINVAL; return -1; } - *((int64_t*) optval_) = recovery_ivl; - *optvallen_ = sizeof (int64_t); + *((int*) optval_) = recovery_ivl; + *optvallen_ = sizeof (int); return 0; case ZMQ_SNDBUF: diff --git a/src/options.hpp b/src/options.hpp index 1699c1ac..d039554d 100644 --- a/src/options.hpp +++ b/src/options.hpp @@ -40,10 +40,10 @@ namespace zmq blob_t identity; // Maximum tranfer rate [kb/s]. Default 100kb/s. - uint32_t rate; + int rate; // Reliability time interval [ms]. Default 10 seconds. - uint32_t recovery_ivl; + int recovery_ivl; // SO_SNDBUF and SO_RCVBUF to be passed to underlying transport sockets. int sndbuf; @@ -58,6 +58,7 @@ namespace zmq // Minimum interval between attempts to reconnect, in milliseconds. // Default 100ms int reconnect_ivl; + // Maximum interval between attempts to reconnect, in milliseconds. // Default 0 (unused) int reconnect_ivl_max; diff --git a/src/pgm_socket.cpp b/src/pgm_socket.cpp index 10d8f39c..d84ecb07 100644 --- a/src/pgm_socket.cpp +++ b/src/pgm_socket.cpp @@ -668,10 +668,10 @@ void zmq::pgm_socket_t::process_upstream () int zmq::pgm_socket_t::compute_sqns (int tpdu_) { // Convert rate into B/ms. - uint64_t rate = ((uint64_t) options.rate) / 8; + uint64_t rate = uint64_t (options.rate) / 8; // Compute the size of the buffer in bytes. - uint64_t size = options.recovery_ivl * rate; + uint64_t size = uint64_t (options.recovery_ivl) * rate; // Translate the size into number of packets. uint64_t sqns = size / tpdu_;