[zeromq-dev] regarding jira issue LIBZMQ-456 - ZMQ_XPUB_VERBOSE does not propagate in a tree of XPUB/XSUB devices
John Muehlhausen
jgm at jgm.org
Wed Oct 24 09:22:04 CEST 2012
I think this is an easy fix, and I am hoping that an active developer can
apply it so that I don't have to set up to contribute code and possibly
botch something in the process.
The issue is that ZMQ_XPUB_VERBOSE will not propagate through a chain of
XPUB/XSUB connections since XSUB stops duplicates as well as XPUB.
So, for example, if sub1 and sub2 both subscribe to key1 then pub1 will get
two subscription notifications. However, if sub1 and sub2 subscribe to
key1 on device1, and device1 attempts to forward both of these
subscriptions to pub1, only one will be forwarded because the XSUB socket
of the device will filter out the second request.
I think the easy fix is as follows (in bold). This removes filtering of
duplicates on the XSUB side. Existing code that does not use
ZMQ_XPUB_VERBOSE should not break because the duplicates will still be
filtered out on the XPUB side, however there will be a little additional
network traffic. Another solution would be to add an XSUB socket option
(ZMQ_XSUB_VERBOSE?) but it would be a bit more work and certainly beyond me.
int zmq::xsub_t::xsend (msg_t *msg_, int flags_)
{
size_t size = msg_->size ();
unsigned char *data = (unsigned char*) msg_->data ();
// Malformed subscriptions.
if (size < 1 || (*data != 0 && *data != 1)) {
errno = EINVAL;
return -1;
}
// Process the subscription.
if (*data == 1) {
* //if (subscriptions.add (data + 1, size - 1))*
* subscriptions.add (data + 1, size - 1);*
return dist.send_to_all (msg_, flags_);
}
else {
if (subscriptions.rm (data + 1, size - 1))
return dist.send_to_all (msg_, flags_);
}
int rc = msg_->close ();
errno_assert (rc == 0);
rc = msg_->init ();
errno_assert (rc == 0);
return 0;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.zeromq.org/pipermail/zeromq-dev/attachments/20121024/586e69f9/attachment.htm>
More information about the zeromq-dev
mailing list