Set tcp endpoint state atomically

PiperOrigin-RevId: 384776517
This commit is contained in:
Tamir Duberstein
2021-07-14 13:57:15 -07:00
committed by gVisor bot
parent a1044cb881
commit e963657e7c
+1 -2
View File
@@ -754,7 +754,7 @@ func (e *endpoint) ResumeWork() {
//
// Precondition: e.mu must be held to call this method.
func (e *endpoint) setEndpointState(state EndpointState) {
oldstate := EndpointState(atomic.LoadUint32(&e.state))
oldstate := EndpointState(atomic.SwapUint32(&e.state, uint32(state)))
switch state {
case StateEstablished:
e.stack.Stats().TCP.CurrentEstablished.Increment()
@@ -771,7 +771,6 @@ func (e *endpoint) setEndpointState(state EndpointState) {
e.stack.Stats().TCP.CurrentEstablished.Decrement()
}
}
atomic.StoreUint32(&e.state, uint32(state))
}
// EndpointState returns the current state of the endpoint.