summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMartin Sustrik <sustrik@250bpm.com>2010-10-10 09:23:37 +0200
committerMartin Sustrik <sustrik@250bpm.com>2010-10-10 09:23:37 +0200
commit73e7ef37c2e72dd542d20ddc5be30cedce68e329 (patch)
tree612db0bc49fb8ca1f4c0e7b8f50108a5b8d2ae98 /src
parentf5030a93a52fc73292c16dae5f8e0e1b39732df0 (diff)
When XREP silently drops message, it does not empty it -- fixed
Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
Diffstat (limited to 'src')
-rw-r--r--src/xrep.cpp29
1 files changed, 15 insertions, 14 deletions
diff --git a/src/xrep.cpp b/src/xrep.cpp
index 9cbd9cb..2d538db 100644
--- a/src/xrep.cpp
+++ b/src/xrep.cpp
@@ -173,23 +173,24 @@ int zmq::xrep_t::xsend (zmq_msg_t *msg_, int flags_)
zmq_assert (!current_out);
// If we have malformed message (prefix with no subsequent message)
- // then just silently drop the message.
- if ((msg_->flags & ZMQ_MSG_MORE) == 0)
- return 0;
-
- more_out = true;
+ // then just silently ignore it.
+ if (msg_->flags & ZMQ_MSG_MORE) {
- // Find the pipe associated with the identity stored in the prefix.
- // If there's no such pipe just silently drop the message.
- blob_t identity ((unsigned char*) zmq_msg_data (msg_),
- zmq_msg_size (msg_));
- outpipes_t::iterator it = outpipes.find (identity);
- if (it == outpipes.end ())
- return 0;
+ more_out = true;
- // Remember the outgoing pipe.
- current_out = it->second.writer;
+ // Find the pipe associated with the identity stored in the prefix.
+ // If there's no such pipe just silently ignore the message.
+ blob_t identity ((unsigned char*) zmq_msg_data (msg_),
+ zmq_msg_size (msg_));
+ outpipes_t::iterator it = outpipes.find (identity);
+ if (it != outpipes.end ())
+ current_out = it->second.writer;
+ }
+ int rc = zmq_msg_close (msg_);
+ zmq_assert (rc == 0);
+ rc = zmq_msg_init (msg_);
+ zmq_assert (rc == 0);
return 0;
}