Commit 084e1c21 authored by Douglas Young's avatar Douglas Young

Fix for issue #307

dist was skipping over pipes when one failed because the non-working pipe got
swapped with a working pipe but the write was never retried on that pipe
parent 6d776d08
...@@ -139,7 +139,8 @@ void zmq::dist_t::distribute (msg_t *msg_, int flags_) ...@@ -139,7 +139,8 @@ void zmq::dist_t::distribute (msg_t *msg_, int flags_)
if (msg_->is_vsm ()) { if (msg_->is_vsm ()) {
for (pipes_t::size_type i = 0; i < matching; ++i) for (pipes_t::size_type i = 0; i < matching; ++i)
write (pipes [i], msg_); if(!write (pipes [i], msg_))
--i; // Retry last write because index will have been swapped
int rc = msg_->close(); int rc = msg_->close();
errno_assert (rc == 0); errno_assert (rc == 0);
rc = msg_->init (); rc = msg_->init ();
...@@ -154,8 +155,10 @@ void zmq::dist_t::distribute (msg_t *msg_, int flags_) ...@@ -154,8 +155,10 @@ void zmq::dist_t::distribute (msg_t *msg_, int flags_)
// Push copy of the message to each matching pipe. // Push copy of the message to each matching pipe.
int failed = 0; int failed = 0;
for (pipes_t::size_type i = 0; i < matching; ++i) for (pipes_t::size_type i = 0; i < matching; ++i)
if (!write (pipes [i], msg_)) if (!write (pipes [i], msg_)) {
++failed; ++failed;
--i; // Retry last write because index will have been swapped
}
if (unlikely (failed)) if (unlikely (failed))
msg_->rm_refs (failed); msg_->rm_refs (failed);
......
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