Commit bc150de8 authored by Pieter Hintjens's avatar Pieter Hintjens

Merge pull request #355 from hurtonm/fq_lb_fix

Prevent connection starvation
parents 4e7be102 2973eaf4
...@@ -46,10 +46,13 @@ void zmq::fq_t::attach (pipe_t *pipe_) ...@@ -46,10 +46,13 @@ void zmq::fq_t::attach (pipe_t *pipe_)
void zmq::fq_t::terminated (pipe_t *pipe_) void zmq::fq_t::terminated (pipe_t *pipe_)
{ {
const pipes_t::size_type index = pipes.index (pipe_);
// Remove the pipe from the list; adjust number of active pipes // Remove the pipe from the list; adjust number of active pipes
// accordingly. // accordingly.
if (pipes.index (pipe_) < active) { if (index < active) {
active--; active--;
pipes.swap (index, active);
if (current == active) if (current == active)
current = 0; current = 0;
} }
......
...@@ -58,6 +58,7 @@ void zmq::lb_t::terminated (pipe_t *pipe_) ...@@ -58,6 +58,7 @@ void zmq::lb_t::terminated (pipe_t *pipe_)
// accordingly. // accordingly.
if (index < active) { if (index < active) {
active--; active--;
pipes.swap (index, active);
if (current == active) if (current == active)
current = 0; current = 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