summaryrefslogtreecommitdiff
path: root/src/pipe.cpp
diff options
context:
space:
mode:
authorMartin Hurton <hurtonm@gmail.com>2010-07-14 18:31:17 +0200
committerMartin Hurton <hurtonm@gmail.com>2010-07-24 17:33:54 +0200
commit10533a560b4af1d3dae63c87c737e25bbdb78998 (patch)
treef46481d018f32f4cdba9ff1397b2214bbc0acfec /src/pipe.cpp
parente1c596b37eef2c2c72c605d7bf4a5c97050add6b (diff)
pipe: check_read() should check for message delimiter
Diffstat (limited to 'src/pipe.cpp')
-rw-r--r--src/pipe.cpp27
1 files changed, 22 insertions, 5 deletions
diff --git a/src/pipe.cpp b/src/pipe.cpp
index e2c3c4d..200beb0 100644
--- a/src/pipe.cpp
+++ b/src/pipe.cpp
@@ -44,15 +44,32 @@ void zmq::reader_t::set_pipe (pipe_t *pipe_)
register_pipe (pipe);
}
+bool zmq::reader_t::is_delimiter (zmq_msg_t &msg_)
+{
+ unsigned char *offset = 0;
+
+ return msg_.content == (void*) (offset + ZMQ_DELIMITER);
+}
+
bool zmq::reader_t::check_read ()
{
// Check if there's an item in the pipe.
- if (pipe->check_read ())
- return true;
-
// If not, deactivate the pipe.
- endpoint->kill (this);
- return false;
+ if (!pipe->check_read ()) {
+ endpoint->kill (this);
+ return false;
+ }
+
+ // If the next item in the pipe is message delimiter,
+ // initiate its termination.
+ if (pipe->probe (is_delimiter)) {
+ if (endpoint)
+ endpoint->detach_inpipe (this);
+ term ();
+ return false;
+ }
+
+ return true;
}
bool zmq::reader_t::read (zmq_msg_t *msg_)