Use non-zero timeout for polling TCP connection

Allow poll to wait for a signal on the socket instead of requiring that
it be set immediately. This fixes flakiness caused by connections not
being established fast enough. For https://fxbug.dev/124433

PiperOrigin-RevId: 520212110
This commit is contained in:
Alex Konradi
2023-03-28 20:36:14 -07:00
committed by gVisor bot
parent 6890e539c7
commit a08ec09cc8
+6 -1
View File
@@ -354,7 +354,12 @@ CreateTCPConnectAcceptSocketPair(int bound, FileDescriptor connected, int type,
if (connect_result == -1) {
struct pollfd connect_poll = {connected.get(), POLLOUT | POLLERR | POLLHUP,
0};
RETURN_ERROR_IF_SYSCALL_FAIL(RetryEINTR(poll)(&connect_poll, 1, 0));
int num_fds;
RETURN_ERROR_IF_SYSCALL_FAIL(
(num_fds = RetryEINTR(poll)(&connect_poll, 1, -1)));
if (num_fds != 1) {
return PosixError(ENOTCONN, "connect failed");
}
int error = 0;
socklen_t errorlen = sizeof(error);
RETURN_ERROR_IF_SYSCALL_FAIL(