summaryrefslogtreecommitdiff
path: root/src/swap.cpp
diff options
context:
space:
mode:
authorMikko Koppanen <mkoppanen@php.net>2010-12-15 20:10:27 +0100
committerMartin Sustrik <sustrik@250bpm.com>2010-12-15 20:10:27 +0100
commit27e83cc5258e191a7d5977e202046447df7896b9 (patch)
tree57572817c9a7e135624f29cae7cbadcce490be88 /src/swap.cpp
parenta46980babe076d34347629a54e9635466e6e2a9f (diff)
Fixes assertion on pipe.cpp:237 when swap fills up.
Fixes swap::full () functionality Signed-off-by: Mikko Koppanen <mkoppanen@php.net>
Diffstat (limited to 'src/swap.cpp')
-rw-r--r--src/swap.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/swap.cpp b/src/swap.cpp
index e3cc63e..b1add37 100644
--- a/src/swap.cpp
+++ b/src/swap.cpp
@@ -189,10 +189,23 @@ bool zmq::swap_t::empty ()
return read_pos == write_pos;
}
+/*
bool zmq::swap_t::full ()
{
- return buffer_space () == 1;
+ // Check that at least the message size can be written to the swap.
+ return buffer_space () < (int64_t) (sizeof (size_t) + 1);
}
+*/
+
+bool zmq::swap_t::fits (zmq_msg_t *msg_)
+{
+ // Check whether whole binary representation of the message
+ // fits into the swap.
+ size_t msg_size = zmq_msg_size (msg_);
+ if (buffer_space () <= (int64_t) (sizeof msg_size + 1 + msg_size))
+ return false;
+ return true;
+ }
void zmq::swap_t::copy_from_file (void *buffer_, size_t count_)
{