summaryrefslogtreecommitdiffhomepage
path: root/pkg/tcpip/transport/tcp
diff options
context:
space:
mode:
authorIan Gudger <igudger@google.com>2018-09-19 17:48:24 -0700
committerShentubot <shentubot@google.com>2018-09-19 17:49:18 -0700
commit117ac8bc5b4a98cd74c68ac0feed02b5bb4b78b1 (patch)
tree09e87b5f8d22b9d115de0139425e933dbb50111e /pkg/tcpip/transport/tcp
parente3952733011df912ecaa48974832a054a45c345a (diff)
Fix data race on tcp.endpoint.hardError in tcp.(*endpoint).Read
tcp.endpoint.hardError is protected by tcp.endpoint.mu. PiperOrigin-RevId: 213730698 Change-Id: I4e4f322ac272b145b500b1a652fbee0c7b985be2
Diffstat (limited to 'pkg/tcpip/transport/tcp')
-rw-r--r--pkg/tcpip/transport/tcp/endpoint.go5
1 files changed, 3 insertions, 2 deletions
diff --git a/pkg/tcpip/transport/tcp/endpoint.go b/pkg/tcpip/transport/tcp/endpoint.go
index a048cadf8..e82e25233 100644
--- a/pkg/tcpip/transport/tcp/endpoint.go
+++ b/pkg/tcpip/transport/tcp/endpoint.go
@@ -127,7 +127,7 @@ type endpoint struct {
// hardError is meaningful only when state is stateError, it stores the
// error to be returned when read/write syscalls are called and the
- // endpoint is in this state.
+ // endpoint is in this state. hardError is protected by mu.
hardError *tcpip.Error `state:".(string)"`
// workerRunning specifies if a worker goroutine is running.
@@ -447,9 +447,10 @@ func (e *endpoint) Read(*tcpip.FullAddress) (buffer.View, tcpip.ControlMessages,
bufUsed := e.rcvBufUsed
if s := e.state; s != stateConnected && s != stateClosed && bufUsed == 0 {
e.rcvListMu.Unlock()
+ he := e.hardError
e.mu.RUnlock()
if s == stateError {
- return buffer.View{}, tcpip.ControlMessages{}, e.hardError
+ return buffer.View{}, tcpip.ControlMessages{}, he
}
return buffer.View{}, tcpip.ControlMessages{}, tcpip.ErrInvalidEndpointState
}