John, Sorry for the slow response. Your logic is sound, I think. Would you make this change as a pull request to libzmq?
-Pieter On Tue, Nov 6, 2012 at 7:21 AM, John Muehlhausen <[email protected]> wrote: > The bold patch below causes only subscription requests to be verbose. Using > the patch, unsubscribe requests are not verbose, even with ZMQ_XPUB_VERBOSE > set. (It should be noted that my fix for issue 456 was only on the > subscribe side.) > > There is a use-case where only subscriptions should be verbose, from the > perspective of the publisher: > > When anyone new comes: send them (and everyone) a snapshot (i.e., from the > last value cache) > When the last person leaves: release resources associated with the topic > > > If unsubscribe is also verbose, then we need to consider how to know when an > unsubscribe message is the "last" one. The only way would be to count > subscriptions, then count unsubscriptions. The problem is that a whole slew > of unsubscriptions can be represented by only one unsubscribe message, as in > the case of a socket disconnect of a xpub/xsub router. So I don't think > counting works. > > If there is a real use-case for unsubscribe to be verbose also then I'd like > to recommend a new socket option to enable this behavior. Otherwise I'd > like to propose this patch. Either way I'll make the appropriate issue on > Jira. Apologies if creating an issue is the right way to start this > conversation. > > -John > > void zmq::xpub_t::xread_activated (pipe_t *pipe_) > { > // There are some subscriptions waiting. Let's process them. > msg_t sub; > while (pipe_->read (&sub)) { > > // Apply the subscription to the trie. > unsigned char *const data = (unsigned char*) sub.data (); > const size_t size = sub.size (); > if (size > 0 && (*data == 0 || *data == 1)) { > bool unique; > if (*data == 0) > unique = subscriptions.rm (data + 1, size - 1, pipe_); > else > unique = subscriptions.add (data + 1, size - 1, pipe_); > > // If the subscription is not a duplicate store it so that it > can be > // passed to used on next recv call. > // if (options.type == ZMQ_XPUB && (unique || verbose)) > if (options.type == ZMQ_XPUB && (unique || (*data && verbose))) > pending.push_back (blob_t (data, size)); > } > > sub.close (); > } > } > _______________________________________________ zeromq-dev mailing list [email protected] http://lists.zeromq.org/mailman/listinfo/zeromq-dev
