Problem: XPUB treats non-sub/cancel as sub/cancel

Solution: only process for sub/cancel if the messages are actually sub/cancel.
Regression introduced by cf9ccbb which tried to skip non-sub/cancel processing
for PUB.
This commit is contained in:
Luca Boccassi 2020-06-13 15:09:05 +01:00
parent b4aa912467
commit e0e3ce081e

View File

@ -131,19 +131,7 @@ void zmq::xpub_t::xread_activated (pipe_t *pipe_)
_process_subscribe =
!_only_first_subscribe || is_subscribe_or_cancel;
if (!is_subscribe_or_cancel && options.type != ZMQ_PUB) {
// Process user message coming upstream from xsub socket,
// but not if the type is PUB, which never processes user
// messages
_pending_data.push_back (blob_t (msg_data, msg.size ()));
if (metadata)
metadata->add_ref ();
_pending_metadata.push_back (metadata);
_pending_flags.push_back (msg.flags ());
msg.close ();
continue;
}
if (is_subscribe_or_cancel) {
if (_manual) {
// Store manual subscription to use on termination
if (!subscribe)
@ -157,9 +145,11 @@ void zmq::xpub_t::xread_activated (pipe_t *pipe_)
const mtrie_t::rm_result rm_result =
_subscriptions.rm (data, size, pipe_);
// TODO reconsider what to do if rm_result == mtrie_t::not_found
notify = rm_result != mtrie_t::values_remain || _verbose_unsubs;
notify =
rm_result != mtrie_t::values_remain || _verbose_unsubs;
} else {
const bool first_added = _subscriptions.add (data, size, pipe_);
const bool first_added =
_subscriptions.add (data, size, pipe_);
notify = first_added || _verbose_subs;
}
}
@ -191,6 +181,16 @@ void zmq::xpub_t::xread_activated (pipe_t *pipe_)
_pending_metadata.push_back (metadata);
_pending_flags.push_back (0);
}
} else if (options.type != ZMQ_PUB) {
// Process user message coming upstream from xsub socket,
// but not if the type is PUB, which never processes user
// messages
_pending_data.push_back (blob_t (msg_data, msg.size ()));
if (metadata)
metadata->add_ref ();
_pending_metadata.push_back (metadata);
_pending_flags.push_back (msg.flags ());
}
msg.close ();
}