Skip to content

Commit

Permalink
Fix spurious test failure in reqRep
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan Eilemann authored and Stefan Eilemann committed Jul 28, 2017
1 parent d9169fb commit 92178a5
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions zeroeq/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ class Client::Impl : public detail::Receiver
public:
explicit Impl(const std::string& session)
: detail::Receiver(SERVER_SERVICE, session == DEFAULT_SESSION
? getDefaultRepSession()
: session)
? getDefaultRepSession()
: session)
, _servers(zmq_socket(getContext(), ZMQ_DEALER),
[](void* s) { ::zmq_close(s); })
{
Expand Down Expand Up @@ -78,9 +78,9 @@ class Client::Impl : public detail::Receiver
uint64_t id;
uint128_t replyID;

if (!_recv(&id, sizeof(id)) || !_recv(nullptr, 0))
if (!_recv(&id, sizeof(id), ZMQ_DONTWAIT) || !_recv(nullptr, 0, 0))
return false;
const bool payload = _recv(&replyID, sizeof(replyID));
const bool payload = _recv(&replyID, sizeof(replyID), 0);

#ifdef ZEROEQ_BIGENDIAN
detail::byteswap(replyID); // convert to little endian wire protocol
Expand Down Expand Up @@ -133,11 +133,12 @@ class Client::Impl : public detail::Receiver
}

/** @return true if more data available */
bool _recv(void* data, const size_t size)
bool _recv(void* data, const size_t size, const int flags)
{
zmq_msg_t msg;
zmq_msg_init(&msg);
zmq_msg_recv(&msg, _servers.get(), 0);
if (zmq_msg_recv(&msg, _servers.get(), flags) == -1)
return false;

if (zmq_msg_size(&msg) != size)
ZEROEQWARN << "Reply size mismatch, expected " << size << " got "
Expand Down

0 comments on commit 92178a5

Please sign in to comment.