diff --git a/doc/zmq_setsockopt.txt b/doc/zmq_setsockopt.txt index 583578fe..f3866fac 100644 --- a/doc/zmq_setsockopt.txt +++ b/doc/zmq_setsockopt.txt @@ -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 diff --git a/include/zmq.h b/include/zmq.h index 14e260f7..4b9bd9f5 100644 --- a/include/zmq.h +++ b/include/zmq.h @@ -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 diff --git a/src/xpub.cpp b/src/xpub.cpp index bc686d42..b823c40c 100644 --- a/src/xpub.cpp +++ b/src/xpub.cpp @@ -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 (optval_) < 0) { errno = EINVAL; return -1; } - - if (option_ == ZMQ_XPUB_VERBOSE) + if (option_ == ZMQ_XPUB_VERBOSE) { verbose_subs = (*static_cast (optval_) != 0); + verbose_unsubs = 0; + } else - if (option_ == ZMQ_XPUB_VERBOSE_UNSUBSCRIBE) - verbose_unsubs = (*static_cast (optval_) != 0); + if (option_ == ZMQ_XPUB_VERBOSER) { + verbose_subs = (*static_cast (optval_) != 0); + verbose_unsubs = verbose_subs; + } else if (option_ == ZMQ_XPUB_NODROP) lossy = (*static_cast (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) {