diff options
author | Bhasker Hariharan <bhaskerh@google.com> | 2020-11-17 22:56:44 -0800 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-11-17 22:58:53 -0800 |
commit | 0e32d98f3a5d4f81459635efcaa53898f43996b9 (patch) | |
tree | b1ddd76e2121e2d2f970203fa612bd9ef5e13b8e /pkg/tcpip/transport | |
parent | ee6dd8cb97128e996c5ce41f22866edc91907eae (diff) |
Fix endpoint.Read() when endpoint is in StateError.
If the endpoint is in StateError but e.hardErrorLocked() returns
nil then return ErrClosedForRecieve.
This can happen if a concurrent write on the same endpoint was in progress
when the endpoint transitioned to an error state.
PiperOrigin-RevId: 343018257
Diffstat (limited to 'pkg/tcpip/transport')
-rw-r--r-- | pkg/tcpip/transport/tcp/endpoint.go | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/pkg/tcpip/transport/tcp/endpoint.go b/pkg/tcpip/transport/tcp/endpoint.go index a2161e49d..173cd28ec 100644 --- a/pkg/tcpip/transport/tcp/endpoint.go +++ b/pkg/tcpip/transport/tcp/endpoint.go @@ -1330,7 +1330,10 @@ func (e *endpoint) Read(*tcpip.FullAddress) (buffer.View, tcpip.ControlMessages, if s := e.EndpointState(); !s.connected() && s != StateClose && bufUsed == 0 { e.rcvListMu.Unlock() if s == StateError { - return buffer.View{}, tcpip.ControlMessages{}, e.hardErrorLocked() + if err := e.hardErrorLocked(); err != nil { + return buffer.View{}, tcpip.ControlMessages{}, err + } + return buffer.View{}, tcpip.ControlMessages{}, tcpip.ErrClosedForReceive } e.stats.ReadErrors.NotConnected.Increment() return buffer.View{}, tcpip.ControlMessages{}, tcpip.ErrNotConnected |