summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Sustrik <sustrik@250bpm.com>2011-03-27 09:50:25 +0200
committerMartin Sustrik <sustrik@250bpm.com>2011-03-27 09:50:25 +0200
commit17fdb5e3a8956887e76c487e36d1dc8b667ca248 (patch)
tree14e04fe9adfa732679eb1285b3c64d9b8296394b
parent82dbef360c1fd5b20c8b59e1fc7273af14f55502 (diff)
zmq_recv() returns size of the message even if it's truncated
Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
-rw-r--r--src/zmq.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/zmq.cpp b/src/zmq.cpp
index 399a426..c65e166 100644
--- a/src/zmq.cpp
+++ b/src/zmq.cpp
@@ -371,24 +371,24 @@ int zmq_recv (void *s_, void *buf_, size_t len_, int flags_)
int rc = zmq_msg_init (&msg);
errno_assert (rc == 0);
- rc = zmq_recvmsg (s_, &msg, flags_);
- if (unlikely (rc < 0)) {
+ int nbytes = zmq_recvmsg (s_, &msg, flags_);
+ if (unlikely (nbytes < 0)) {
int err = errno;
- int rc2 = zmq_msg_close (&msg);
- errno_assert (rc2 == 0);
+ rc = zmq_msg_close (&msg);
+ errno_assert (rc == 0);
errno = err;
return -1;
}
// At the moment an oversized message is silently truncated.
// TODO: Build in a notification mechanism to report the overflows.
- size_t to_copy = size_t (rc) < len_ ? size_t (rc) : len_;
+ size_t to_copy = size_t (nbytes) < len_ ? size_t (nbytes) : len_;
memcpy (buf_, zmq_msg_data (&msg), to_copy);
rc = zmq_msg_close (&msg);
errno_assert (rc == 0);
- return (int) to_copy;
+ return nbytes;
}
int zmq_sendmsg (void *s_, zmq_msg_t *msg_, int flags_)