Commit 128bed47 authored by Martin Hurton's avatar Martin Hurton

Merge pull request #1170 from hintjens/master

Fixed issues with xpub nodrop property
parents 81485c76 2584c3a7
......@@ -95,6 +95,9 @@ tests/test_bind_src_address
tests/test_metadata
tests/test_id2fd
tests/test_capabilities
tests/test_hwm_pubsub
tests/test_router_mandatory_hwm
tests/test_xpub_nodrop
tests/test*.log
tests/test*.trs
src/platform.hpp*
......
......@@ -30,6 +30,7 @@ zmq::xpub_t::xpub_t (class ctx_t *parent_, uint32_t tid_, int sid_) :
more (false)
{
options.type = ZMQ_XPUB;
lossy = true;
}
zmq::xpub_t::~xpub_t ()
......@@ -90,10 +91,6 @@ 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_NODROP) {
errno = EINVAL;
return -1;
}
if (optvallen_ != sizeof (int) || *static_cast <const int*> (optval_) < 0) {
errno = EINVAL;
return -1;
......@@ -101,8 +98,12 @@ int zmq::xpub_t::xsetsockopt (int option_, const void *optval_,
if (option_ == ZMQ_XPUB_VERBOSE)
verbose = (*static_cast <const int*> (optval_) != 0);
else
nodrop = (*static_cast <const int*> (optval_) != 0);
if (option_ == ZMQ_XPUB_NODROP)
lossy = (*static_cast <const int*> (optval_) == 0);
else {
errno = EINVAL;
return -1;
}
return 0;
}
......@@ -131,7 +132,7 @@ int zmq::xpub_t::xsend (msg_t *msg_)
subscriptions.match ((unsigned char*) msg_->data (), msg_->size (),
mark_as_matching, this);
if (nodrop && !dist.check_hwm ()) {
if (lossy == false && !dist.check_hwm ()) {
errno = EAGAIN;
return -1;
}
......
......@@ -79,8 +79,8 @@ namespace zmq
// True if we are in the middle of sending a multi-part message.
bool more;
// dont drop messages if hwm reached, just return with EAGAIN
bool nodrop;
// Drop messages if HWM reached, otherwise return with EAGAIN
bool lossy;
// List of pending (un)subscriptions, ie. those that were already
// applied to the trie, but not yet received by the user.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment