summaryrefslogtreecommitdiffhomepage
path: root/pkg/tcpip/transport/tcp/snd.go
diff options
context:
space:
mode:
authorIan Gudger <igudger@google.com>2018-10-31 18:41:48 -0700
committerShentubot <shentubot@google.com>2018-10-31 18:42:44 -0700
commit59b7766af7c78f330d09044e68bb195e495993ea (patch)
tree8d729c85ec5c2755cafe50846c54a2b36dd80693 /pkg/tcpip/transport/tcp/snd.go
parenteeddae1199d9b84ee84011be0019328724ebdcf3 (diff)
Fix a race where keepalives could be sent while there is pending data
PiperOrigin-RevId: 219571556 Change-Id: I5a1042c1cb05eb2711eb01627fd298bad6c543a6
Diffstat (limited to 'pkg/tcpip/transport/tcp/snd.go')
-rw-r--r--pkg/tcpip/transport/tcp/snd.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/pkg/tcpip/transport/tcp/snd.go b/pkg/tcpip/transport/tcp/snd.go
index eefe93d48..b260c0e57 100644
--- a/pkg/tcpip/transport/tcp/snd.go
+++ b/pkg/tcpip/transport/tcp/snd.go
@@ -405,6 +405,7 @@ func (s *sender) sendData() {
// eventually.
var seg *segment
end := s.sndUna.Add(s.sndWnd)
+ var dataSent bool
for seg = s.writeNext; 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.
@@ -448,6 +449,12 @@ func (s *sender) sendData() {
segEnd = seg.sequenceNumber.Add(seqnum.Size(seg.data.Size()))
}
+ if !dataSent {
+ dataSent = true
+ // We are sending data, so we should stop the keepalive timer to
+ // ensure that no keepalives are sent while there is pending data.
+ s.ep.disableKeepaliveTimer()
+ }
s.sendSegment(seg.data, seg.flags, seg.sequenceNumber)
// Update sndNxt if we actually sent new data (as opposed to