Commit 11175a33 authored by Pieter Hintjens's avatar Pieter Hintjens

Problem: security tests block on zmq_send

The expect_bounce_fail () helper assumed that messages could always
be sent. However in some cases zmq_send() blocks, due to there not
being any outgoing pipe. This changed in 77f5f7, where previously
there would be a pipe that kept trying to reconnect forever.

Solution: use a send timeout and check for EAGAIN if sending failed.
parent a1fbd973
......@@ -130,12 +130,13 @@ expect_bounce_fail (void *server, void *client)
assert (zmq_errno () == EAGAIN);
// Send message from server to client to test other direction
// If connection failed, send may block, without a timeout
rc = zmq_setsockopt (server, ZMQ_SNDTIMEO, &timeout, sizeof (int));
assert (rc == 0);
rc = zmq_send (server, content, 32, ZMQ_SNDMORE);
assert ((rc == 32) || ((rc == -1) && (errno == EAGAIN)));
assert (rc == 32 || (rc == -1 && zmq_errno () == EAGAIN));
rc = zmq_send (server, content, 32, 0);
assert ((rc == 32) || ((rc == -1) && (errno == EAGAIN)));
assert (rc == 32 || (rc == -1 && zmq_errno () == EAGAIN));
// Receive message at client side (should not succeed)
rc = zmq_setsockopt (client, ZMQ_RCVTIMEO, &timeout, sizeof (int));
......
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