summaryrefslogtreecommitdiffhomepage
path: root/test/packetimpact/tests
diff options
context:
space:
mode:
authorgVisor bot <gvisor-bot@google.com>2020-04-13 23:04:01 -0700
committergVisor bot <gvisor-bot@google.com>2020-04-13 23:05:08 -0700
commitc230d12b5ce540239df06e517f3b1b72722dcc14 (patch)
tree4c191ea971d550cd9c446a502d2b8d33fe939195 /test/packetimpact/tests
parent71e6ac3e1f551cf52166bf501de114f06502b994 (diff)
Add Sniffer.Drain() draining socket receive buffer
Add Sniffer.Drain() which drains the socket's receive buffer by temporarily setting the socket to non-blocking, and receiving in a loop until EINTR, EWOULDBLOCK or EAGAIN. This method should be used when long periods of time elapses without receiving on the socket, because uninteresting packets may have piled up in the receive buffer, filling it up and causing packets critical to test operation to be dropped. PiperOrigin-RevId: 306380480
Diffstat (limited to 'test/packetimpact/tests')
-rw-r--r--test/packetimpact/tests/fin_wait2_timeout_test.go2
1 files changed, 2 insertions, 0 deletions
diff --git a/test/packetimpact/tests/fin_wait2_timeout_test.go b/test/packetimpact/tests/fin_wait2_timeout_test.go
index 90e16ef65..b98594f94 100644
--- a/test/packetimpact/tests/fin_wait2_timeout_test.go
+++ b/test/packetimpact/tests/fin_wait2_timeout_test.go
@@ -53,6 +53,8 @@ func TestFinWait2Timeout(t *testing.T) {
conn.Send(tb.TCP{Flags: tb.Uint8(header.TCPFlagAck)})
time.Sleep(5 * time.Second)
+ conn.Drain()
+
conn.Send(tb.TCP{Flags: tb.Uint8(header.TCPFlagAck)})
if tt.linger2 {
if _, err := conn.Expect(tb.TCP{Flags: tb.Uint8(header.TCPFlagRst)}, time.Second); err != nil {