Increase timeout when observing TCP connection failures

Give the Netstack additional time to reject incoming connections for which
there are no listening sockets. This prevents flakes in test environments with
CPU contention, where the Netstack may be descheduled for multiple seconds.

PiperOrigin-RevId: 623165285
This commit is contained in:
Jeff Martin
2024-04-09 07:51:59 -07:00
committed by gVisor bot
parent 91a283f8fa
commit 5b9642a0f2
+4 -2
View File
@@ -1257,7 +1257,8 @@ PosixErrorOr<FileDescriptor> nonBlockingConnectNoListener(
// Wait for the connect to fail.
struct pollfd poll_fd = {s.get(), POLLERR, 0};
EXPECT_THAT(RetryEINTR(poll)(&poll_fd, 1, 1000), SyscallSucceedsWithValue(1));
EXPECT_THAT(RetryEINTR(poll)(&poll_fd, 1, kTimeoutMillis),
SyscallSucceedsWithValue(1));
return std::move(s);
}
@@ -1732,7 +1733,8 @@ TEST_P(SimpleTcpSocketTest, NonBlockingConnectRefused) {
// We don't need to specify any events to get POLLHUP or POLLERR as these
// are added before the poll.
struct pollfd poll_fd = {s.get(), /*events=*/0, 0};
EXPECT_THAT(RetryEINTR(poll)(&poll_fd, 1, 1000), SyscallSucceedsWithValue(1));
EXPECT_THAT(RetryEINTR(poll)(&poll_fd, 1, kTimeoutMillis),
SyscallSucceedsWithValue(1));
// The ECONNREFUSED should cause us to be woken up with POLLHUP.
EXPECT_NE(poll_fd.revents & (POLLHUP | POLLERR), 0);