From ed210ee4039306def6dcaff75da2e5fa0fa5e1e3 Mon Sep 17 00:00:00 2001 From: wwqgtxx Date: Wed, 6 Dec 2023 11:00:45 +0800 Subject: [PATCH] fix: only using xsync with pointer to avoid unaligned 64-bit atomic operation closed #783 --- transport/tuic/v5/client.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/transport/tuic/v5/client.go b/transport/tuic/v5/client.go index 8daa0925..8a4d6fb1 100644 --- a/transport/tuic/v5/client.go +++ b/transport/tuic/v5/client.go @@ -47,7 +47,7 @@ type clientImpl struct { openStreams atomic.Int64 closed atomic.Bool - udpInputMap xsync.MapOf[uint16, net.Conn] + udpInputMap *xsync.MapOf[uint16, net.Conn] // only ready for PoolClient dialerRef C.Dialer @@ -270,7 +270,7 @@ func (t *clientImpl) forceClose(quicConn quic.Connection, err error) { if quicConn != nil { _ = quicConn.CloseWithError(ProtocolError, errStr) } - udpInputMap := &t.udpInputMap + udpInputMap := t.udpInputMap udpInputMap.Range(func(key uint16, value net.Conn) bool { conn := value _ = conn.Close() @@ -406,7 +406,7 @@ func NewClient(clientOption *ClientOption, udp bool, dialerRef C.Dialer) *Client ClientOption: clientOption, udp: udp, dialerRef: dialerRef, - udpInputMap: *xsync.NewMapOf[uint16, net.Conn](), + udpInputMap: xsync.NewMapOf[uint16, net.Conn](), } c := &Client{ci} runtime.SetFinalizer(c, closeClient)