summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gray <ben@benjamg.com>2011-10-27 13:59:54 +0200
committerMartin Sustrik <sustrik@250bpm.com>2011-10-27 13:59:54 +0200
commit9e000c8f26c99656dd967a8d15997b879af5817b (patch)
tree14e0972cd5c5fbc7cc002f557e70c99331e503c1
parent68ab5f87edd2436757ab92b22238a5a4114d7b0d (diff)
Patch for issue LIBZMQ-275. Dealing with VSM in distribution when pipes fail to write.
Signed-off-by: Ben Gray <ben@benjamg.com>
-rw-r--r--src/dist.cpp10
-rw-r--r--src/msg.cpp6
-rw-r--r--src/msg.hpp1
3 files changed, 17 insertions, 0 deletions
diff --git a/src/dist.cpp b/src/dist.cpp
index 795e13e..b4fae6f 100644
--- a/src/dist.cpp
+++ b/src/dist.cpp
@@ -137,6 +137,16 @@ void zmq::dist_t::distribute (msg_t *msg_, int flags_)
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,
// that's why -1.
msg_->add_refs ((int) matching - 1);
diff --git a/src/msg.cpp b/src/msg.cpp
index e51ab67..fba7ec9 100644
--- a/src/msg.cpp
+++ b/src/msg.cpp
@@ -237,6 +237,11 @@ bool zmq::msg_t::is_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_)
{
zmq_assert (refs_ >= 0);
@@ -279,3 +284,4 @@ bool zmq::msg_t::rm_refs (int refs_)
return true;
}
+
diff --git a/src/msg.hpp b/src/msg.hpp
index 514f95b..6b4e216 100644
--- a/src/msg.hpp
+++ b/src/msg.hpp
@@ -68,6 +68,7 @@ namespace zmq
void set_flags (unsigned char flags_);
void reset_flags (unsigned char flags_);
bool is_delimiter ();
+ bool is_vsm ();
// After calling this function you can copy the message in POD-style
// refs_ times. No need to call copy.