Commit d90e70c1 authored by Simon Giesecke's avatar Simon Giesecke

Problem: maximum allowed value for ZMQ_HEARTBEAT_TTL is wrong

Solution: use UINT16_MAX
parent 50374bf6
...@@ -361,6 +361,7 @@ no effect. ...@@ -361,6 +361,7 @@ no effect.
Option value type:: int Option value type:: int
Option value unit:: milliseconds Option value unit:: milliseconds
Default value:: 0 Default value:: 0
Maximum value:: 6553599 (which is 2^16-1 deciseconds)
Applicable socket types:: all, when using connection-oriented transports Applicable socket types:: all, when using connection-oriented transports
......
...@@ -282,6 +282,8 @@ int zmq::options_t::set_curve_key (uint8_t *destination, ...@@ -282,6 +282,8 @@ int zmq::options_t::set_curve_key (uint8_t *destination,
return -1; return -1;
} }
const int deciseconds_per_millisecond = 100;
int zmq::options_t::setsockopt (int option_, int zmq::options_t::setsockopt (int option_,
const void *optval_, const void *optval_,
size_t optvallen_) size_t optvallen_)
...@@ -665,8 +667,8 @@ int zmq::options_t::setsockopt (int option_, ...@@ -665,8 +667,8 @@ int zmq::options_t::setsockopt (int option_,
case ZMQ_HEARTBEAT_TTL: case ZMQ_HEARTBEAT_TTL:
// Convert this to deciseconds from milliseconds // Convert this to deciseconds from milliseconds
value = value / 100; value = value / deciseconds_per_millisecond;
if (is_int && value >= 0 && value <= 6553) { if (is_int && value >= 0 && value <= UINT16_MAX) {
heartbeat_ttl = static_cast<uint16_t> (value); heartbeat_ttl = static_cast<uint16_t> (value);
return 0; return 0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment