mirror of
https://github.com/zeromq/libzmq.git
synced 2025-10-28 19:52:00 +01:00
Fix data loss for PUB/SUB and unidirectional transports (LIBZMQ-268)
With the introduction of subscription forwarding, the first message sent on a PUB socket using a unidirectional transport (e.g. PGM) is always lost due to the "subscribe to all" being done asynchronously. This patch fixes the problem and also refactors the code to have a single point where the "subscribe to all" is performed. Signed-off-by: Martin Lucina <martin@lucina.net>
This commit is contained in:
@@ -37,11 +37,16 @@ zmq::xpub_t::~xpub_t ()
|
||||
{
|
||||
}
|
||||
|
||||
void zmq::xpub_t::xattach_pipe (pipe_t *pipe_)
|
||||
void zmq::xpub_t::xattach_pipe (pipe_t *pipe_, bool icanhasall_)
|
||||
{
|
||||
zmq_assert (pipe_);
|
||||
dist.attach (pipe_);
|
||||
|
||||
// If icanhasall_ is specified, the caller would like to subscribe
|
||||
// to all data on this pipe, implicitly.
|
||||
if (icanhasall_)
|
||||
subscriptions.add (NULL, 0, pipe_);
|
||||
|
||||
// The pipe is active when attached. Let's read the subscriptions from
|
||||
// it, if any.
|
||||
xread_activated (pipe_);
|
||||
|
||||
Reference in New Issue
Block a user