From 73e7ef37c2e72dd542d20ddc5be30cedce68e329 Mon Sep 17 00:00:00 2001 From: Martin Sustrik Date: Sun, 10 Oct 2010 09:23:37 +0200 Subject: When XREP silently drops message, it does not empty it -- fixed Signed-off-by: Martin Sustrik --- src/xrep.cpp | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'src') 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; } -- cgit v1.2.3