diff options
author | Kevin Krakauer <krakauer@google.com> | 2021-05-17 12:11:09 -0700 |
---|---|---|
committer | Kevin Krakauer <krakauer@google.com> | 2021-05-17 12:11:09 -0700 |
commit | 303c70194d086aef30c5e04b28836790e2c86e66 (patch) | |
tree | 3ae6a17f4fc5bb92aaff0629ae57afb40d24f171 | |
parent | 7654181cc7c4f7633a1e96280bfd32391a3fbce3 (diff) |
replace use of atomic with AlignedAtomicInt64
-rw-r--r-- | pkg/tcpip/socketops.go | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/pkg/tcpip/socketops.go b/pkg/tcpip/socketops.go index b26936b7f..b7c2de652 100644 --- a/pkg/tcpip/socketops.go +++ b/pkg/tcpip/socketops.go @@ -222,7 +222,7 @@ type SocketOptions struct { getReceiveBufferLimits GetReceiveBufferLimits `state:"manual"` // receiveBufferSize determines the receive buffer size for this socket. - receiveBufferSize int64 + receiveBufferSize atomicbitops.AlignedAtomicInt64 // mu protects the access to the below fields. mu sync.Mutex `state:"nosave"` @@ -653,13 +653,13 @@ func (so *SocketOptions) SetSendBufferSize(sendBufferSize int64, notify bool) { // GetReceiveBufferSize gets value for SO_RCVBUF option. func (so *SocketOptions) GetReceiveBufferSize() int64 { - return atomic.LoadInt64(&so.receiveBufferSize) + return so.receiveBufferSize.Load() } // SetReceiveBufferSize sets value for SO_RCVBUF option. func (so *SocketOptions) SetReceiveBufferSize(receiveBufferSize int64, notify bool) { if !notify { - atomic.StoreInt64(&so.receiveBufferSize, receiveBufferSize) + so.receiveBufferSize.Store(receiveBufferSize) return } @@ -684,8 +684,8 @@ func (so *SocketOptions) SetReceiveBufferSize(receiveBufferSize int64, notify bo v = math.MaxInt32 } - oldSz := atomic.LoadInt64(&so.receiveBufferSize) + oldSz := so.receiveBufferSize.Load() // Notify endpoint about change in buffer size. newSz := so.handler.OnSetReceiveBufferSize(v, oldSz) - atomic.StoreInt64(&so.receiveBufferSize, newSz) + so.receiveBufferSize.Store(newSz) } |