Handle infinite hwms properly

This commit is contained in:
Richard Newton 2015-06-05 19:06:36 +01:00
parent 15eecf4cf4
commit dc949624e1
2 changed files with 14 additions and 4 deletions

View File

@ -520,8 +520,18 @@ void zmq::pipe_t::hiccup ()
void zmq::pipe_t::set_hwms (int inhwm_, int outhwm_)
{
lwm = compute_lwm(inhwm_ + inhwmboost);
hwm = outhwm_ + outhwmboost;
int in = inhwm_ + inhwmboost;
int out = outhwm_ + outhwmboost;
// if either send or recv side has hwm <= 0 it means infinite so we should set hwms infinite
if (inhwm_ <= 0 || inhwmboost <= 0)
in = 0;
if (outhwm_ <= 0 || outhwmboost <= 0)
out = 0;
lwm = compute_lwm(in);
hwm = out;
}
void zmq::pipe_t::set_hwms_boost(int inhwmboost_, int outhwmboost_)

View File

@ -278,13 +278,13 @@ int main (void)
count = test_inproc_connect_first (0, 0);
assert (count == MAX_SENDS);
// Infinite send buffer
// Infinite receive buffer
count = test_inproc_bind_first (1, 0);
assert (count == MAX_SENDS);
count = test_inproc_connect_first (1, 0);
assert (count == MAX_SENDS);
// Infinite receive buffer
// Infinite send buffer
count = test_inproc_bind_first (0, 1);
assert (count == MAX_SENDS);
count = test_inproc_connect_first (0, 1);