0
0
mirror of https://github.com/zeromq/libzmq.git synced 2024-12-29 08:39:42 +08:00

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.
This commit is contained in:
trya 2019-09-23 01:15:23 +02:00
parent 8d34332ff2
commit 2fe9dd9101

View File

@ -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 ();