diff options
author | Zhaozhong Ni <nzz@google.com> | 2018-12-05 13:50:14 -0800 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2018-12-05 13:51:16 -0800 |
commit | fda4557e3dc19c72f857b107a52359723cd37216 (patch) | |
tree | 8b9ece367e3a58f13514d7a3c1383cca78082500 /pkg | |
parent | 592f5bdc675ae2933919b649b45551c6781c7876 (diff) |
sentry: skip waiting for undrain for netstack TCP endpoints in error state.
PiperOrigin-RevId: 224214981
Change-Id: I4c1dd5b1c856f7a4f9866a5dda44a5297e92486a
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/tcpip/transport/tcp/connect.go | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/pkg/tcpip/transport/tcp/connect.go b/pkg/tcpip/transport/tcp/connect.go index 00cb39560..0e6bb6763 100644 --- a/pkg/tcpip/transport/tcp/connect.go +++ b/pkg/tcpip/transport/tcp/connect.go @@ -976,25 +976,35 @@ func (e *endpoint) protocolMainLoop(handshake bool) *tcpip.Error { e.mu.Unlock() } if n¬ifyClose != 0 && closeTimer == nil { - // Reset the connection 3 seconds after the - // endpoint has been closed. + // Reset the connection 3 seconds after + // the endpoint has been closed. + // + // The timer could fire in background + // when the endpoint is drained. That's + // OK as the loop here will not honor + // the firing until the undrain arrives. closeTimer = time.AfterFunc(3*time.Second, func() { closeWaker.Assert() }) } + if n¬ifyKeepaliveChanged != 0 { + // The timer could fire in background + // when the endpoint is drained. That's + // OK. See above. + e.resetKeepaliveTimer(true) + } + if n¬ifyDrain != 0 { for !e.segmentQueue.empty() { if err := e.handleSegments(); err != nil { return err } } - close(e.drainDone) - <-e.undrain - } - - if n¬ifyKeepaliveChanged != 0 { - e.resetKeepaliveTimer(true) + if e.state != stateError { + close(e.drainDone) + <-e.undrain + } } return nil |