mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user