Unverified Commit aafdeb76 authored by Luca Boccassi's avatar Luca Boccassi Committed by GitHub

Merge pull request #2825 from rolftimmermans/req_relaxed_has_out

Problem: REQ socket with ZMQ_REQ_RELAXED does not report ZMQ_POLLOUT when queried for events after first message.
parents b3d19ffe c8592dfb
......@@ -213,7 +213,7 @@ bool zmq::req_t::xhas_in ()
bool zmq::req_t::xhas_out ()
{
if (receiving_reply)
if (receiving_reply && strict)
return false;
return dealer_t::xhas_out ();
......
......@@ -54,6 +54,16 @@ static void bounce (void *socket)
} while (more);
}
static int get_events (void *socket)
{
int rc;
int events;
size_t events_size = sizeof(events);
rc = zmq_getsockopt (socket, ZMQ_EVENTS, &events, &events_size);
assert (rc == 0);
return events;
}
int main (void)
{
setup_test_environment ();
......@@ -97,14 +107,23 @@ int main (void)
// Case 1: Second send() before a reply arrives in a pipe.
int events = get_events (req);
assert(events == ZMQ_POLLOUT);
// Send a request, ensure it arrives, don't send a reply
s_send_seq (req, "A", "B", SEQ_END);
s_recv_seq (rep [0], "A", "B", SEQ_END);
events = get_events (req);
assert(events == ZMQ_POLLOUT);
// Send another request on the REQ socket
s_send_seq (req, "C", "D", SEQ_END);
s_recv_seq (rep [1], "C", "D", SEQ_END);
events = get_events (req);
assert(events == ZMQ_POLLOUT);
// Send a reply to the first request - that should be discarded by the REQ
s_send_seq (rep [0], "WRONG", SEQ_END);
......@@ -112,7 +131,6 @@ int main (void)
s_send_seq (rep [1], "OK", SEQ_END);
s_recv_seq (req, "OK", SEQ_END);
// Another standard req-rep cycle, just to check
s_send_seq (req, "E", SEQ_END);
s_recv_seq (rep [2], "E", SEQ_END);
......
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