From 5ecfc6925b3dde72e209b702cb087310a0071ea0 Mon Sep 17 00:00:00 2001 From: Aleksey Myasnikov Date: Wed, 8 Nov 2023 02:52:40 +0300 Subject: [PATCH] fix CAS --- internal/conn/conn.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/internal/conn/conn.go b/internal/conn/conn.go index e3140b1ec..1b074a83e 100644 --- a/internal/conn/conn.go +++ b/internal/conn/conn.go @@ -140,12 +140,9 @@ func (c *conn) SetState(s State) State { } func (c *conn) setState(s State) State { - state := c.state.Load() - if c.state.CompareAndSwap(state, uint32(s)) { + if state := State(c.state.Swap(uint32(s))); state != s { trace.DriverOnConnStateChange( - c.config.Trace(), - c.endpoint.Copy(), - State(state), + c.config.Trace(), c.endpoint.Copy(), state, )(s) } return s