Added socket option ZMQ_INVERT_MATCHING.

ZMQ_INVERT_MATCHING reverses the PUB/SUB prefix matching. The subscription
list becomes a rejection list. The PUB socket sends messages to all
connected (X)SUB sockets that do not have any matching subscription.

Whenever the option is used on a PUB/XPUB socket, any connecting SUB
sockets must also set it or they will reject everything the publisher
sends them. XSUB sockets are unaffected because they do not filter out
incoming messages.
This commit is contained in:
Julien Ruffin
2015-01-26 15:59:19 +01:00
parent 148cec0a52
commit cf2238f80e
11 changed files with 222 additions and 2 deletions

View File

@@ -179,9 +179,14 @@ int zmq::xpub_t::xsend (msg_t *msg_)
bool msg_more = msg_->flags () & msg_t::more ? true : false;
// For the first part of multi-part message, find the matching pipes.
if (!more)
if (!more) {
subscriptions.match ((unsigned char*) msg_->data (), msg_->size (),
mark_as_matching, this);
// If inverted matching is used, reverse the selection now
if (options.invert_matching) {
dist.reverse_match();
}
}
int rc = -1; // Assume we fail
if (lossy || dist.check_hwm ()) {