Commit 9e000c8f authored by Ben Gray's avatar Ben Gray Committed by Martin Sustrik

Patch for issue LIBZMQ-275. Dealing with VSM in distribution when pipes fail to write.

Signed-off-by: 's avatarBen Gray <ben@benjamg.com>
parent 68ab5f87
...@@ -137,6 +137,16 @@ void zmq::dist_t::distribute (msg_t *msg_, int flags_) ...@@ -137,6 +137,16 @@ void zmq::dist_t::distribute (msg_t *msg_, int flags_)
return; return;
} }
if (msg_->is_vsm ()) {
for (pipes_t::size_type i = 0; i < matching; ++i)
write (pipes [i], msg_);
int rc = msg_->close();
errno_assert (rc == 0);
rc = msg_->init ();
errno_assert (rc == 0);
return;
}
// Add matching-1 references to the message. We already hold one reference, // Add matching-1 references to the message. We already hold one reference,
// that's why -1. // that's why -1.
msg_->add_refs ((int) matching - 1); msg_->add_refs ((int) matching - 1);
......
...@@ -237,6 +237,11 @@ bool zmq::msg_t::is_delimiter () ...@@ -237,6 +237,11 @@ bool zmq::msg_t::is_delimiter ()
return u.base.type == type_delimiter; return u.base.type == type_delimiter;
} }
bool zmq::msg_t::is_vsm ()
{
return u.base.type == type_vsm;
}
void zmq::msg_t::add_refs (int refs_) void zmq::msg_t::add_refs (int refs_)
{ {
zmq_assert (refs_ >= 0); zmq_assert (refs_ >= 0);
...@@ -279,3 +284,4 @@ bool zmq::msg_t::rm_refs (int refs_) ...@@ -279,3 +284,4 @@ bool zmq::msg_t::rm_refs (int refs_)
return true; return true;
} }
...@@ -68,6 +68,7 @@ namespace zmq ...@@ -68,6 +68,7 @@ namespace zmq
void set_flags (unsigned char flags_); void set_flags (unsigned char flags_);
void reset_flags (unsigned char flags_); void reset_flags (unsigned char flags_);
bool is_delimiter (); bool is_delimiter ();
bool is_vsm ();
// After calling this function you can copy the message in POD-style // After calling this function you can copy the message in POD-style
// refs_ times. No need to call copy. // refs_ times. No need to call copy.
......
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