summaryrefslogtreecommitdiffhomepage
path: root/pkg/tcpip/transport/tcp
diff options
context:
space:
mode:
authorZhaozhong Ni <nzz@google.com>2018-07-12 13:38:26 -0700
committerShentubot <shentubot@google.com>2018-07-12 13:39:28 -0700
commitcc34a90fb46348fd4588d4191ddba0a1d27c1132 (patch)
treea0e9e7b056d9f6fc4d3ef53a45305725b7d60b99 /pkg/tcpip/transport/tcp
parent67507bd579a305e5d993c7cca71b665f33f341ff (diff)
netstack: do not defer panicable logic in tcp main loop.
PiperOrigin-RevId: 204355026 Change-Id: I1a8229879ea3b58aa861a4eb4456fd7aff99863d
Diffstat (limited to 'pkg/tcpip/transport/tcp')
-rw-r--r--pkg/tcpip/transport/tcp/connect.go14
1 files changed, 9 insertions, 5 deletions
diff --git a/pkg/tcpip/transport/tcp/connect.go b/pkg/tcpip/transport/tcp/connect.go
index 33bf4fc0b..8d70eb45a 100644
--- a/pkg/tcpip/transport/tcp/connect.go
+++ b/pkg/tcpip/transport/tcp/connect.go
@@ -828,7 +828,7 @@ func (e *endpoint) protocolMainLoop(handshake bool) *tcpip.Error {
var closeTimer *time.Timer
var closeWaker sleep.Waker
- defer func() {
+ epilogue := func() {
// e.mu is expected to be hold upon entering this section.
if e.snd != nil {
@@ -849,7 +849,7 @@ func (e *endpoint) protocolMainLoop(handshake bool) *tcpip.Error {
// When the protocol loop exits we should wake up our waiters.
e.waiterQueue.Notify(waiter.EventHUp | waiter.EventErr | waiter.EventIn | waiter.EventOut)
- }()
+ }
if handshake {
// This is an active connection, so we must initiate the 3-way
@@ -867,7 +867,8 @@ func (e *endpoint) protocolMainLoop(handshake bool) *tcpip.Error {
e.mu.Lock()
e.state = stateError
e.hardError = err
- // Lock released in deferred statement.
+ // Lock released below.
+ epilogue()
return err
}
@@ -1013,7 +1014,9 @@ func (e *endpoint) protocolMainLoop(handshake bool) *tcpip.Error {
if err := funcs[v].f(); err != nil {
e.mu.Lock()
e.resetConnectionLocked(err)
- // Lock released in deferred statement.
+ // Lock released below.
+ epilogue()
+
return nil
}
}
@@ -1021,7 +1024,8 @@ func (e *endpoint) protocolMainLoop(handshake bool) *tcpip.Error {
// Mark endpoint as closed.
e.mu.Lock()
e.state = stateClosed
- // Lock released in deferred statement.
+ // Lock released below.
+ epilogue()
return nil
}