Problem: ZMQ_XPUB_VERBOSE_UNSUBSCRIBE is clumsy

This option has a few issues. The name is long and clumsy. The
functonality is not smooth: one must set both this and
ZMQ_XPUB_VERBOSE at the same time, or things will break mysteriously.

Solution: rename to ZMQ_XPUB_VERBOSER and make an atomic option.

That is, implicitly does ZMQ_XPUB_VERBOSE.
This commit is contained in:
Pieter Hintjens 2016-02-09 09:53:41 +01:00
parent da8ce55a14
commit 7f6ed167fc
3 changed files with 27 additions and 30 deletions

View File

@ -915,11 +915,11 @@ Default value:: N/A
Applicable socket types:: ZMQ_SUB
ZMQ_XPUB_VERBOSE: provide all subscription messages on XPUB sockets
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Sets the 'XPUB' socket behaviour on new subscriptions and unsubscriptions.
A value of '0' is the default and passes only new subscription messages to
upstream. A value of '1' passes all subscription messages upstream.
ZMQ_XPUB_VERBOSE: pass subscribe messages on XPUB socket
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Sets the 'XPUB' socket behaviour on new subscriptions. If enabled,
the socket passes all subscribe messages to the caller. If disabled,
these are not visible to the caller. The default is 0 (disabled).
[horizontal]
Option value type:: int
@ -928,17 +928,12 @@ Default value:: 0
Applicable socket types:: ZMQ_XPUB
ZMQ_XPUB_VERBOSE_UNSUBSCRIBE: provide all unsubscription messages on XPUB sockets
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Sets the 'XPUB' socket behaviour on new subscriptions and unsubscriptions.
A value of '0' is the default and passes only the last unsubscription message to
upstream. A value of '1' passes all unsubscription messages upstream.
This behaviour should be enabled in all the intermediary XPUB sockets if
ZMQ_XPUB_VERBOSE is also being used in order to allow the correct forwarding
of all the unsubscription messages.
NOTE: This behaviour only takes effect when ZMQ_XPUB_VERBOSE is also enabled.
ZMQ_XPUB_VERBOSER: pass subscribe and unsubscribe messages on XPUB socket
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Sets the 'XPUB' socket behaviour on new subscriptions and ubsubscriptions.
If enabled, the socket passes all subscribe and unsubscribe messages to the
caller. If disabled, these are not visible to the caller. The default is 0
(disabled).
[horizontal]
Option value type:: int

View File

@ -335,7 +335,7 @@ ZMQ_EXPORT const char *zmq_msg_group (zmq_msg_t *msg);
#define ZMQ_HEARTBEAT_IVL 75
#define ZMQ_HEARTBEAT_TTL 76
#define ZMQ_HEARTBEAT_TIMEOUT 77
#define ZMQ_XPUB_VERBOSE_UNSUBSCRIBE 78
#define ZMQ_XPUB_VERBOSER 78
#define ZMQ_CONNECT_TIMEOUT 79
#define ZMQ_TCP_MAXRT 80
#define ZMQ_THREAD_SAFE 81

View File

@ -133,19 +133,23 @@ void zmq::xpub_t::xwrite_activated (pipe_t *pipe_)
int zmq::xpub_t::xsetsockopt (int option_, const void *optval_,
size_t optvallen_)
{
if (option_ == ZMQ_XPUB_VERBOSE || option_ == ZMQ_XPUB_VERBOSE_UNSUBSCRIBE ||
option_ == ZMQ_XPUB_NODROP || option_ == ZMQ_XPUB_MANUAL)
{
if (option_ == ZMQ_XPUB_VERBOSE
|| option_ == ZMQ_XPUB_VERBOSER
|| option_ == ZMQ_XPUB_NODROP
|| option_ == ZMQ_XPUB_MANUAL) {
if (optvallen_ != sizeof(int) || *static_cast <const int*> (optval_) < 0) {
errno = EINVAL;
return -1;
}
if (option_ == ZMQ_XPUB_VERBOSE)
if (option_ == ZMQ_XPUB_VERBOSE) {
verbose_subs = (*static_cast <const int*> (optval_) != 0);
verbose_unsubs = 0;
}
else
if (option_ == ZMQ_XPUB_VERBOSE_UNSUBSCRIBE)
verbose_unsubs = (*static_cast <const int*> (optval_) != 0);
if (option_ == ZMQ_XPUB_VERBOSER) {
verbose_subs = (*static_cast <const int*> (optval_) != 0);
verbose_unsubs = verbose_subs;
}
else
if (option_ == ZMQ_XPUB_NODROP)
lossy = (*static_cast <const int*> (optval_) == 0);
@ -155,15 +159,13 @@ int zmq::xpub_t::xsetsockopt (int option_, const void *optval_,
}
else
if (option_ == ZMQ_SUBSCRIBE && manual) {
if (last_pipe != NULL) {
subscriptions.add((unsigned char *)optval_, optvallen_, last_pipe);
}
if (last_pipe != NULL)
subscriptions.add ((unsigned char *)optval_, optvallen_, last_pipe);
}
else
if (option_ == ZMQ_UNSUBSCRIBE && manual) {
if (last_pipe != NULL) {
subscriptions.rm((unsigned char *)optval_, optvallen_, last_pipe);
}
if (last_pipe != NULL)
subscriptions.rm ((unsigned char *)optval_, optvallen_, last_pipe);
}
else
if (option_ == ZMQ_XPUB_WELCOME_MSG) {