Commit 3e432587 authored by Pieter Hintjens's avatar Pieter Hintjens

Merge pull request #1570 from djelenc/deque_bug

Problem: Tests in Travis are failing randomly
parents 39a0d339 64ffda90
...@@ -245,8 +245,10 @@ int zmq::xpub_t::xrecv (msg_t *msg_) ...@@ -245,8 +245,10 @@ int zmq::xpub_t::xrecv (msg_t *msg_)
} }
// User is reading a message, set last_pipe and remove it from the deque // User is reading a message, set last_pipe and remove it from the deque
last_pipe = pending_pipes.front (); if (manual && !pending_pipes.empty ()) {
pending_pipes.pop_front (); last_pipe = pending_pipes.front ();
pending_pipes.pop_front ();
}
int rc = msg_->close (); int rc = msg_->close ();
errno_assert (rc == 0); errno_assert (rc == 0);
...@@ -285,10 +287,13 @@ void zmq::xpub_t::send_unsubscription (unsigned char *data_, size_t size_, ...@@ -285,10 +287,13 @@ void zmq::xpub_t::send_unsubscription (unsigned char *data_, size_t size_,
unsub [0] = 0; unsub [0] = 0;
if (size_ > 0) if (size_ > 0)
memcpy (&unsub [1], data_, size_); memcpy (&unsub [1], data_, size_);
self->last_pipe = NULL;
self->pending_pipes.push_back (NULL);
self->pending_data.push_back (unsub); self->pending_data.push_back (unsub);
self->pending_metadata.push_back (NULL); self->pending_metadata.push_back (NULL);
self->pending_flags.push_back (0); self->pending_flags.push_back (0);
if (self->manual) {
self->last_pipe = NULL;
self->pending_pipes.push_back (NULL);
}
} }
} }
...@@ -199,7 +199,7 @@ int test_xpub_proxy_unsubscribe_on_disconnect() ...@@ -199,7 +199,7 @@ int test_xpub_proxy_unsubscribe_on_disconnect()
assert (zmq_send (xsub_proxy, sub_buff, 2, 0) == 2); assert (zmq_send (xsub_proxy, sub_buff, 2, 0) == 2);
// should receive another unsubscribe msg // should receive another unsubscribe msg
assert (zmq_recv (xpub_proxy, sub_buff, 2, ZMQ_DONTWAIT) == 2 assert (zmq_recv (xpub_proxy, sub_buff, 2, 0) == 2
&& "Should receive the second unsubscribe message."); && "Should receive the second unsubscribe message.");
assert (sub_buff [0] == 0); assert (sub_buff [0] == 0);
assert (sub_buff [1] == *topic); assert (sub_buff [1] == *topic);
......
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