diff --git a/go.mod b/go.mod index dbf02ed9..5b28d3ed 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/smallnest/rpcx -go 1.19 +go 1.20 require ( github.com/ChimeraCoder/gojson v1.1.0 diff --git a/server/server.go b/server/server.go index 84106f3d..2fe78523 100644 --- a/server/server.go +++ b/server/server.go @@ -95,7 +95,7 @@ type Server struct { mu sync.RWMutex activeConn map[net.Conn]struct{} doneChan chan struct{} - seq uint64 + seq atomic.Uint64 inShutdown int32 onShutdown []func(s *Server) @@ -185,7 +185,7 @@ func (s *Server) SendMessage(conn net.Conn, servicePath, serviceMethod string, m req := protocol.NewMessage() req.SetMessageType(protocol.Request) - seq := atomic.AddUint64(&s.seq, 1) + seq := s.seq.Add(1) req.SetSeq(seq) req.SetOneway(true) req.SetSerializeType(protocol.SerializeNone)