mirror of
https://github.com/zeromq/libzmq.git
synced 2025-10-28 03:20:13 +01:00
ZMQ_RECONNECT_IVL_MAX socket option added
It allows for exponential back-off strategy when reconnecting. Signed-off-by: Thijs Terlouw <thijsterlouw@gmail.com>
This commit is contained in:
committed by
Martin Sustrik
parent
8e61a11b39
commit
f7f1dfc86d
@@ -37,6 +37,7 @@ zmq::options_t::options_t () :
|
||||
type (-1),
|
||||
linger (-1),
|
||||
reconnect_ivl (100),
|
||||
reconnect_ivl_max (0),
|
||||
backlog (100),
|
||||
requires_in (false),
|
||||
requires_out (false),
|
||||
@@ -161,6 +162,18 @@ int zmq::options_t::setsockopt (int option_, const void *optval_,
|
||||
reconnect_ivl = *((int*) optval_);
|
||||
return 0;
|
||||
|
||||
case ZMQ_RECONNECT_IVL_MAX:
|
||||
if (optvallen_ != sizeof (int)) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
if (*((int*) optval_) < 0) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
reconnect_ivl_max = *((int*) optval_);
|
||||
return 0;
|
||||
|
||||
case ZMQ_BACKLOG:
|
||||
if (optvallen_ != sizeof (int)) {
|
||||
errno = EINVAL;
|
||||
@@ -297,6 +310,15 @@ int zmq::options_t::getsockopt (int option_, void *optval_, size_t *optvallen_)
|
||||
*optvallen_ = sizeof (int);
|
||||
return 0;
|
||||
|
||||
case ZMQ_RECONNECT_IVL_MAX:
|
||||
if (*optvallen_ < sizeof (int)) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
*((int*) optval_) = reconnect_ivl_max;
|
||||
*optvallen_ = sizeof (int);
|
||||
return 0;
|
||||
|
||||
case ZMQ_BACKLOG:
|
||||
if (*optvallen_ < sizeof (int)) {
|
||||
errno = EINVAL;
|
||||
|
||||
Reference in New Issue
Block a user