test: fix SetupTimeWaitClose to create a time wait bucket reliably

Linux can close a tcp connection without a time wait bucket if fin packets come
from both sides close to each other.

Let's send some data after the first fin packet to be sure that it is acked
before sending fin from another side.

PiperOrigin-RevId: 575002422
This commit is contained in:
Andrei Vagin
2023-10-19 14:29:06 -07:00
committed by gVisor bot
parent 0b9e5810d6
commit d039776e16
+6
View File
@@ -1113,6 +1113,12 @@ void SetupTimeWaitClose(const TestAddress* listener,
ASSERT_THAT(poll(&pfd, 1, kTimeout), SyscallSucceedsWithValue(1));
ASSERT_EQ(pfd.revents, POLLIN);
}
// Send/recv some data to be sure that the fin packet has been acked.
char c = 0;
ASSERT_THAT(send(passive_closefd.get(), &c, 1, 0),
SyscallSucceedsWithValue(sizeof(c)));
ASSERT_THAT(recv(active_closefd.get(), &c, 1, 0),
SyscallSucceedsWithValue(sizeof(c)));
ASSERT_THAT(shutdown(passive_closefd.get(), SHUT_WR), SyscallSucceeds());
{
constexpr int kTimeout = 10000;