Skip to content
This repository

Fix for issue #307 #291

Merged
merged 1 commit into from over 2 years ago

2 participants

Douglas Young Ian Barber
Douglas Young

dist_t distribute() 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. This fix retries the write with the same index so the newly swapped pipe is also written to. This should stop apparently dropped PUB/XPUB messages due to closed SUB sockets.

Douglas Young rcxdude 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
084e1c2
Ian Barber ianbarber merged commit 4c93fc2 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Mar 25, 2012
Douglas Young rcxdude 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
084e1c2
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 5 additions and 2 deletions. Show diff stats Hide diff stats

  1. +5 2 src/dist.cpp
7 src/dist.cpp
@@ -139,7 +139,8 @@ void zmq::dist_t::distribute (msg_t *msg_, int flags_)
139 139
140 140 if (msg_->is_vsm ()) {
141 141 for (pipes_t::size_type i = 0; i < matching; ++i)
142   - write (pipes [i], msg_);
  142 + if(!write (pipes [i], msg_))
  143 + --i; // Retry last write because index will have been swapped
143 144 int rc = msg_->close();
144 145 errno_assert (rc == 0);
145 146 rc = msg_->init ();
@@ -154,8 +155,10 @@ void zmq::dist_t::distribute (msg_t *msg_, int flags_)
154 155 // Push copy of the message to each matching pipe.
155 156 int failed = 0;
156 157 for (pipes_t::size_type i = 0; i < matching; ++i)
157   - if (!write (pipes [i], msg_))
  158 + if (!write (pipes [i], msg_)) {
158 159 ++failed;
  160 + --i; // Retry last write because index will have been swapped
  161 + }
159 162 if (unlikely (failed))
160 163 msg_->rm_refs (failed);
161 164

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.