diff options
author | Zhaozhong Ni <nzz@google.com> | 2018-08-23 16:13:22 -0700 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2018-08-23 16:14:46 -0700 |
commit | e855e9cebc45f5fd7a9583f476c8965fc395a15e (patch) | |
tree | 438ee8a2f0d58011f270a628d0ca6da48bc66674 | |
parent | ba8f6ba8c899d2e900fa7e9ee5aede31cba1de9c (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.go | 8 |
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() |