summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Hurton <hurtonm@gmail.com>2010-02-10 12:48:04 +0100
committerMartin Hurton <hurtonm@gmail.com>2010-02-10 17:12:54 +0100
commitbc9b7f1f54b9dcf754021f1f7eb766d71cc97f29 (patch)
treeb7a80e32dca84459814acd33d72c5f06c6d68244 /src
parent6b3c1798e7554dd1ce63b2ad137e327f3f32fcf1 (diff)
lb: bugfix - never skip active pipe when sending msg
Diffstat (limited to 'src')
-rw-r--r--src/lb.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/lb.cpp b/src/lb.cpp
index 7dd7d97..e1628db 100644
--- a/src/lb.cpp
+++ b/src/lb.cpp
@@ -46,8 +46,11 @@ void zmq::lb_t::detach (writer_t *pipe_)
{
// Remove the pipe from the list; adjust number of active pipes
// accordingly.
- if (pipes.index (pipe_) < active)
+ if (pipes.index (pipe_) < active) {
active--;
+ if (current == active)
+ current = 0;
+ }
pipes.erase (pipe_);
}
@@ -55,6 +58,8 @@ void zmq::lb_t::kill (writer_t *pipe_)
{
// Move the pipe to the list of inactive pipes.
active--;
+ if (current == active)
+ current = 0;
pipes.swap (pipes.index (pipe_), active);
}
@@ -73,11 +78,6 @@ int zmq::lb_t::send (zmq_msg_t *msg_, int flags_)
return -1;
}
- // Move to the next pipe (load-balancing).
- current++;
- if (current >= active)
- current = 0;
-
// TODO: Implement this once queue limits are in-place.
zmq_assert (pipes [current]->check_write (zmq_msg_size (msg_)));
@@ -89,6 +89,11 @@ int zmq::lb_t::send (zmq_msg_t *msg_, int flags_)
int rc = zmq_msg_init (msg_);
zmq_assert (rc == 0);
+ // Move to the next pipe (load-balancing).
+ current++;
+ if (current >= active)
+ current = 0;
+
return 0;
}