mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Poll for POLLERR before validating ICMP error
...since ICMP errors are returned asynchronously. This also matches the behavior of existing tests. PiperOrigin-RevId: 435484650
This commit is contained in:
@@ -382,6 +382,11 @@ TEST_P(UdpSocketTest, ConnectWriteToInvalidPort) {
|
||||
ASSERT_THAT(sendto(sock_.get(), buf, sizeof(buf), 0, addr, addrlen_),
|
||||
SyscallSucceedsWithValue(sizeof(buf)));
|
||||
|
||||
// Poll to make sure we get the ICMP error back.
|
||||
constexpr int kTimeout = 1000;
|
||||
struct pollfd pfd = {sock_.get(), POLLERR, 0};
|
||||
ASSERT_THAT(RetryEINTR(poll)(&pfd, 1, kTimeout), SyscallSucceedsWithValue(1));
|
||||
|
||||
// Now verify that we got an ICMP error back of ECONNREFUSED.
|
||||
int err;
|
||||
socklen_t optlen = sizeof(err);
|
||||
|
||||
Reference in New Issue
Block a user