Commit 2fe9dd91 authored by trya's avatar trya

Problem: ZMQ_CONFLATE on PUB sockets delivers to only one subscriber at most

Solution: Fix behavior of dbuffer on writes. Message passed in argument
of dbuffer::write can be assigned directly to the back buffer without
leaking, since the message has already the right reference count (see
dist::distribute and msg_t::add_refs). Secondly, in order to prevent the
message pending in the front buffer from leaking if it hasn't been
closed yet (for example because the peer is not reachable anymore), move
back buffer to front buffer using msg_t::move instead of swapping the
buffers, thus allowing release of the message in the front buffer.
parent 8d34332f
......@@ -78,12 +78,12 @@ template <> class dbuffer_t<msg_t>
msg_t &xvalue = const_cast<msg_t &> (value_);
zmq_assert (xvalue.check ());
_back->move (xvalue); // cannot just overwrite, might leak
*_back = value_;
zmq_assert (_back->check ());
if (_sync.try_lock ()) {
std::swap (_back, _front);
_front->move (*_back);
_has_msg = true;
_sync.unlock ();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment