summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorZhaozhong Ni <nzz@google.com>2018-08-23 16:13:22 -0700
committerShentubot <shentubot@google.com>2018-08-23 16:14:46 -0700
commite855e9cebc45f5fd7a9583f476c8965fc395a15e (patch)
tree438ee8a2f0d58011f270a628d0ca6da48bc66674
parentba8f6ba8c899d2e900fa7e9ee5aede31cba1de9c (diff)
netstack: make listening tcp socket close state setting and cleanup atomic.
Otherwise the socket saving logic might find workers still running for closed sockets unexpectedly. PiperOrigin-RevId: 210018905 Change-Id: I443a04d355613f5f9983252cc6863bff6e0eda3a
-rw-r--r--pkg/tcpip/transport/tcp/accept.go8
1 files changed, 3 insertions, 5 deletions
diff --git a/pkg/tcpip/transport/tcp/accept.go b/pkg/tcpip/transport/tcp/accept.go
index 63058e420..c22ed5ea7 100644
--- a/pkg/tcpip/transport/tcp/accept.go
+++ b/pkg/tcpip/transport/tcp/accept.go
@@ -363,11 +363,6 @@ func (e *endpoint) protocolListenLoop(rcvWnd seqnum.Size) *tcpip.Error {
e.mu.Lock()
e.state = stateClosed
- // Notify waiters that the endpoint is shutdown.
- e.mu.Unlock()
- e.waiterQueue.Notify(waiter.EventIn | waiter.EventOut)
- e.mu.Lock()
-
// Do cleanup if needed.
e.completeWorkerLocked()
@@ -375,6 +370,9 @@ func (e *endpoint) protocolListenLoop(rcvWnd seqnum.Size) *tcpip.Error {
close(e.drainDone)
}
e.mu.Unlock()
+
+ // Notify waiters that the endpoint is shutdown.
+ e.waiterQueue.Notify(waiter.EventIn | waiter.EventOut)
}()
e.mu.Lock()