From fd27a917ef068a4e17cddbe3f671b59f52e6e030 Mon Sep 17 00:00:00 2001 From: Bhasker Hariharan Date: Thu, 19 Mar 2020 09:41:56 -0700 Subject: Address comments on workMu removal change. Updates #231, #357 PiperOrigin-RevId: 301833669 --- pkg/tcpip/transport/tcp/accept.go | 2 +- pkg/tcpip/transport/tcp/tcp_test.go | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) (limited to 'pkg') diff --git a/pkg/tcpip/transport/tcp/accept.go b/pkg/tcpip/transport/tcp/accept.go index 4d7602d54..3f80995f3 100644 --- a/pkg/tcpip/transport/tcp/accept.go +++ b/pkg/tcpip/transport/tcp/accept.go @@ -420,7 +420,7 @@ func (e *endpoint) handleSynSegment(ctx *listenContext, s *segment, opts *header } func (e *endpoint) incSynRcvdCount() bool { - if e.synRcvdCount >= (cap(e.acceptedChan)) { + if e.synRcvdCount >= cap(e.acceptedChan) { return false } e.synRcvdCount++ diff --git a/pkg/tcpip/transport/tcp/tcp_test.go b/pkg/tcpip/transport/tcp/tcp_test.go index 39d36d2ba..ce3df7478 100644 --- a/pkg/tcpip/transport/tcp/tcp_test.go +++ b/pkg/tcpip/transport/tcp/tcp_test.go @@ -2236,12 +2236,13 @@ func TestSegmentMerging(t *testing.T) { c.CreateConnected(789, 30000, -1 /* epRcvBuf */) - // Send 10 1 byte segments to fill up InitialWindow but don't - // ACK. That should prevent anymore packets from going out. - for i := 0; i < 10; i++ { + // Send tcp.InitialCwnd number of segments to fill up + // InitialWindow but don't ACK. That should prevent + // anymore packets from going out. + for i := 0; i < tcp.InitialCwnd; i++ { view := buffer.NewViewFromBytes([]byte{0}) if _, _, err := c.EP.Write(tcpip.SlicePayload(view), tcpip.WriteOptions{}); err != nil { - t.Fatalf("Write #%d failed: %v", i+1, err) + t.Fatalf("Write #%d failed: %s", i+1, err) } } @@ -2256,8 +2257,8 @@ func TestSegmentMerging(t *testing.T) { } } - // Check that we get 10 packets of 1 byte each. - for i := 0; i < 10; i++ { + // Check that we get tcp.InitialCwnd packets. + for i := 0; i < tcp.InitialCwnd; i++ { b := c.GetPacket() checker.IPv4(t, b, checker.PayloadLen(header.TCPMinimumSize+1), -- cgit v1.2.3