Problem: maximum allowed value for ZMQ_HEARTBEAT_TTL is wrong

Solution: use UINT16_MAX
This commit is contained in:
Simon Giesecke 2018-05-25 10:50:47 +02:00
parent 50374bf6f5
commit d90e70c1cf
2 changed files with 5 additions and 2 deletions

View File

@ -361,6 +361,7 @@ no effect.
Option value type:: int
Option value unit:: milliseconds
Default value:: 0
Maximum value:: 6553599 (which is 2^16-1 deciseconds)
Applicable socket types:: all, when using connection-oriented transports

View File

@ -282,6 +282,8 @@ int zmq::options_t::set_curve_key (uint8_t *destination,
return -1;
}
const int deciseconds_per_millisecond = 100;
int zmq::options_t::setsockopt (int option_,
const void *optval_,
size_t optvallen_)
@ -665,8 +667,8 @@ int zmq::options_t::setsockopt (int option_,
case ZMQ_HEARTBEAT_TTL:
// Convert this to deciseconds from milliseconds
value = value / 100;
if (is_int && value >= 0 && value <= 6553) {
value = value / deciseconds_per_millisecond;
if (is_int && value >= 0 && value <= UINT16_MAX) {
heartbeat_ttl = static_cast<uint16_t> (value);
return 0;
}