mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Retry ioctl when checking TCP socket receive queue len
When checking how much data is left in the receive queue, retry to allow time for packets to propagate and the system to push data into the socket's receive queue. PiperOrigin-RevId: 500257746
This commit is contained in:
@@ -771,8 +771,18 @@ TEST_P(TcpSocketTest, Tiocinq) {
|
||||
ASSERT_THAT(read, SyscallSucceeds());
|
||||
size -= read;
|
||||
|
||||
// The remaining data should end up in the receive queue.
|
||||
constexpr absl::Duration kSleepFor = absl::Milliseconds(10);
|
||||
int inq = 0;
|
||||
ASSERT_THAT(ioctl(accepted_.get(), TIOCINQ, &inq), SyscallSucceeds());
|
||||
for (const auto start = absl::Now();
|
||||
absl::Now() <= start + absl::Milliseconds(kTimeoutMillis);) {
|
||||
ASSERT_THAT(ioctl(accepted_.get(), TIOCINQ, &inq), SyscallSucceeds());
|
||||
if (size == inq) {
|
||||
break;
|
||||
}
|
||||
absl::SleepFor(kSleepFor);
|
||||
}
|
||||
|
||||
ASSERT_EQ(inq, size);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user