From b5e91eaa52cfb9b43dff0f857938ca231068924d Mon Sep 17 00:00:00 2001 From: Ian Gudger Date: Wed, 14 Nov 2018 11:57:58 -0800 Subject: Clean up tcp.sendData PiperOrigin-RevId: 221484739 Change-Id: I44c71f79f99d0d00a2e70a7f06d7024a62a5de0a --- pkg/tcpip/buffer/view.go | 2 +- pkg/tcpip/transport/tcp/snd.go | 13 +++++-------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/pkg/tcpip/buffer/view.go b/pkg/tcpip/buffer/view.go index 6c70e0d69..d8c3b0cb4 100644 --- a/pkg/tcpip/buffer/view.go +++ b/pkg/tcpip/buffer/view.go @@ -146,7 +146,7 @@ func (vv VectorisedView) Views() []View { } // Append appends the views in a vectorised view to this vectorised view. -func (vv *VectorisedView) Append(vv2 *VectorisedView) { +func (vv *VectorisedView) Append(vv2 VectorisedView) { vv.views = append(vv.views, vv2.views...) vv.size += vv2.size } diff --git a/pkg/tcpip/transport/tcp/snd.go b/pkg/tcpip/transport/tcp/snd.go index f6dc7520b..b47e279fc 100644 --- a/pkg/tcpip/transport/tcp/snd.go +++ b/pkg/tcpip/transport/tcp/snd.go @@ -404,8 +404,7 @@ func (s *sender) sendData() { seg := s.writeNext end := s.sndUna.Add(s.sndWnd) var dataSent bool - for next := (*segment)(nil); seg != nil && s.outstanding < s.sndCwnd; seg = next { - next = seg.Next() + for ; seg != nil && s.outstanding < s.sndCwnd; seg = seg.Next() { // We abuse the flags field to determine if we have already // assigned a sequence number to this segment. @@ -428,17 +427,16 @@ func (s *sender) sendData() { // in poorly written DNS implementations. var nextTooBig bool - for next != nil && next.data.Size() != 0 { - if seg.data.Size()+next.data.Size() > available { + for seg.Next() != nil && seg.Next().data.Size() != 0 { + if seg.data.Size()+seg.Next().data.Size() > available { nextTooBig = true break } - seg.data.Append(&next.data) + seg.data.Append(seg.Next().data) // Consume the segment that we just merged in. - s.writeList.Remove(next) - next = next.Next() + s.writeList.Remove(seg.Next()) } if !nextTooBig && seg.data.Size() < available { @@ -496,7 +494,6 @@ func (s *sender) sendData() { nSeg.data.TrimFront(available) nSeg.sequenceNumber.UpdateForward(seqnum.Size(available)) s.writeList.InsertAfter(seg, nSeg) - next = nSeg seg.data.CapLength(available) } -- cgit v1.2.3