mirror of
https://github.com/zeromq/libzmq.git
synced 2024-12-31 01:43:02 +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:
parent
8d34332ff2
commit
2fe9dd9101
@ -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 ();
|
||||
|
Loading…
x
Reference in New Issue
Block a user