mirror of
https://github.com/zeromq/libzmq.git
synced 2025-09-17 19:44:01 +02:00
Problem: REQ socket with ZMQ_REQ_RELAXED does not report ZMQ_POLLOUT when queried for events after first message.
Solution: Check for strictness before returning false if no reply has been received.
This commit is contained in:
parent
b3d19ffe1a
commit
c8592dfbc3
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user