diff options
author | gVisor bot <gvisor-bot@google.com> | 2021-09-29 20:49:29 +0000 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2021-09-29 20:49:29 +0000 |
commit | 818f93f19d57a2451abb27e71605be1b53e211ab (patch) | |
tree | a5c24205bddb25f6e9dae2e5aa8ccb9ec7dae7fe /pkg/tcpip/transport | |
parent | 4fb6de0d7c0af7f287944af0d7e5de839b02c171 (diff) | |
parent | f4340b0c9fc24aee34b00073f6be5b38a2d09bce (diff) |
Merge release-20210921.0-42-gf4340b0c9 (automated)
Diffstat (limited to 'pkg/tcpip/transport')
-rw-r--r-- | pkg/tcpip/transport/tcp/accept.go | 6 | ||||
-rw-r--r-- | pkg/tcpip/transport/tcp/endpoint.go | 28 |
2 files changed, 13 insertions, 21 deletions
diff --git a/pkg/tcpip/transport/tcp/accept.go b/pkg/tcpip/transport/tcp/accept.go index 52d121907..2a77f07cf 100644 --- a/pkg/tcpip/transport/tcp/accept.go +++ b/pkg/tcpip/transport/tcp/accept.go @@ -525,10 +525,8 @@ func (e *endpoint) handleListenSegment(ctx *listenContext, s *segment) tcpip.Err e.acceptMu.Lock() defer e.acceptMu.Unlock() for { - if e.acceptQueue == (acceptQueue{}) { - // If the listener has transitioned out of the listen state - // (accepted is the zero value), the new endpoint is reset - // instead. + // The listener is transitioning out of the Listen state; bail. + if e.acceptQueue.capacity == 0 { return false } if e.acceptQueue.isFull() { diff --git a/pkg/tcpip/transport/tcp/endpoint.go b/pkg/tcpip/transport/tcp/endpoint.go index ec7e98ec8..6fca6346b 100644 --- a/pkg/tcpip/transport/tcp/endpoint.go +++ b/pkg/tcpip/transport/tcp/endpoint.go @@ -1085,10 +1085,6 @@ func (e *endpoint) closePendingAcceptableConnectionsLocked() { e.acceptQueue = acceptQueue{} e.acceptMu.Unlock() - if acceptedCopy == (acceptQueue{}) { - return - } - e.acceptCond.Broadcast() // Reset all connections that are waiting to be accepted. @@ -2486,21 +2482,19 @@ func (e *endpoint) listen(backlog int) tcpip.Error { if e.EndpointState() == StateListen && !e.closed { e.acceptMu.Lock() defer e.acceptMu.Unlock() - if e.acceptQueue == (acceptQueue{}) { - // listen is called after shutdown. - e.shutdownFlags = 0 - e.rcvQueueInfo.rcvQueueMu.Lock() - e.rcvQueueInfo.RcvClosed = false - e.rcvQueueInfo.rcvQueueMu.Unlock() - } else { - // Adjust the size of the backlog iff we can fit - // existing pending connections into the new one. - if e.acceptQueue.endpoints.Len() > backlog { - return &tcpip.ErrInvalidEndpointState{} - } + + // Adjust the size of the backlog iff we can fit + // existing pending connections into the new one. + if e.acceptQueue.endpoints.Len() > backlog { + return &tcpip.ErrInvalidEndpointState{} } e.acceptQueue.capacity = backlog + e.shutdownFlags = 0 + e.rcvQueueInfo.rcvQueueMu.Lock() + e.rcvQueueInfo.RcvClosed = false + e.rcvQueueInfo.rcvQueueMu.Unlock() + // Notify any blocked goroutines that they can attempt to // deliver endpoints again. e.acceptCond.Broadcast() @@ -2535,7 +2529,7 @@ func (e *endpoint) listen(backlog int) tcpip.Error { // may be pre-populated with some previously accepted (but not Accepted) // endpoints. e.acceptMu.Lock() - if e.acceptQueue == (acceptQueue{}) { + if e.acceptQueue.capacity == 0 { e.acceptQueue.capacity = backlog } e.acceptMu.Unlock() |