diff --git a/go.mod b/go.mod index f61ebf7..d790c2d 100644 --- a/go.mod +++ b/go.mod @@ -24,7 +24,7 @@ require ( github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e github.com/stefanberger/go-pkcs11uri v0.0.0-20230803200340-78284954bff6 github.com/stretchr/testify v1.10.0 - github.com/timandy/routine v1.1.1 + github.com/timandy/routine v1.1.5 github.com/vishvananda/netlink v1.3.0 golang.org/x/crypto v0.36.0 golang.org/x/exp v0.0.0-20230725093048-515e97ebf090 diff --git a/go.sum b/go.sum index bc4c366..5098e63 100644 --- a/go.sum +++ b/go.sum @@ -149,6 +149,8 @@ github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOf github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/timandy/routine v1.1.1 h1:6/Z7qLFZj3GrzuRksBFzIG8YGUh8CLhjnnMePBQTrEI= github.com/timandy/routine v1.1.1/go.mod h1:OZHPOKSvqL/ZvqXFkNZyit0xIVelERptYXdAHH00adQ= +github.com/timandy/routine v1.1.5 h1:LSpm7Iijwb9imIPlucl4krpr2EeCeAUvifiQ9Uf5X+M= +github.com/timandy/routine v1.1.5/go.mod h1:kXslgIosdY8LW0byTyPnenDgn4/azt2euufAq9rK51w= github.com/vishvananda/netlink v1.3.0 h1:X7l42GfcV4S6E4vHTsw48qbrV+9PVojNfIhZcwQdrZk= github.com/vishvananda/netlink v1.3.0/go.mod h1:i6NetklAujEcC6fK0JPjT8qSwWyO0HLn4UKG+hGqeJs= github.com/vishvananda/netns v0.0.4 h1:Oeaw1EM2JMxD51g9uhtC0D7erkIjgmj8+JZc26m1YX8= diff --git a/mutex_debug.go b/mutex_debug.go index ce5050a..e5a7b3c 100644 --- a/mutex_debug.go +++ b/mutex_debug.go @@ -19,18 +19,18 @@ type mutexKey = string // in the same order, to prevent deadlocks. var allowedConcurrentLocks = map[mutexKey][]mutexKey{ "connection-manager-in": {"hostmap"}, - "connection-manager-out": {"connection-state-write", "connection-manager-in"}, + "connection-manager-out": {"connection-manager-in", "handshake-hostinfo", "handshake-manager"}, "connection-manager-relay-used": {"handshake-hostinfo"}, "connection-manager-timer": {"connection-manager-out"}, - "connection-state-write": {"hostmap"}, - "firewall-conntrack": {"handshake-hostinfo"}, - "handshake-manager": {"hostmap"}, - "handshake-manager-timer": {"handshake-manager"}, - "hostmap": {"handshake-hostinfo", "lighthouse-query-chan"}, - "lighthouse": {"handshake-manager"}, - "relay-state": {"hostmap", "connection-manager-relay-used"}, - "remote-list": {"lighthouse"}, - "lighthouse-query-chan": {"handshake-hostinfo"}, + // "connection-state-write": {"hostmap"}, + "firewall-conntrack": {"handshake-hostinfo"}, + "handshake-manager": {"handshake-hostinfo", "hostmap"}, + "handshake-manager-timer": {"handshake-manager"}, + "hostmap": {"lighthouse-query-chan", "handshake-hostinfo"}, + "lighthouse": {"handshake-hostinfo"}, + "relay-state": {"connection-manager-relay-used", "hostmap"}, + "remote-list": {"lighthouse", "handshake-manager"}, + "lighthouse-query-chan": {"handshake-hostinfo"}, } type mutexValue struct { @@ -42,7 +42,7 @@ func (m mutexValue) String() string { return fmt.Sprintf("%s:%d", m.file, m.line) } -var threadLocal routine.ThreadLocal = routine.NewThreadLocalWithInitial(func() any { return map[mutexKey]mutexValue{} }) +var threadLocal = routine.NewThreadLocalWithInitial[map[mutexKey]mutexValue](func() map[mutexKey]mutexValue { return map[mutexKey]mutexValue{} }) var allowedDAG dag.AcyclicGraph @@ -137,7 +137,7 @@ func checkMutex(state map[mutexKey]mutexValue, add mutexKey) { } func chanDebugRecv(key mutexKey) { - m := threadLocal.Get().(map[mutexKey]mutexValue) + m := threadLocal.Get() checkMutex(m, key) v := mutexValue{} _, v.file, v.line, _ = runtime.Caller(1) @@ -145,12 +145,12 @@ func chanDebugRecv(key mutexKey) { } func chanDebugSend(key mutexKey) { - m := threadLocal.Get().(map[mutexKey]mutexValue) + m := threadLocal.Get() checkMutex(m, key) } func (s *syncRWMutex) Lock() { - m := threadLocal.Get().(map[mutexKey]mutexValue) + m := threadLocal.Get() checkMutex(m, s.mutexKey) v := mutexValue{} _, v.file, v.line, _ = runtime.Caller(1) @@ -159,13 +159,13 @@ func (s *syncRWMutex) Lock() { } func (s *syncRWMutex) Unlock() { - m := threadLocal.Get().(map[mutexKey]mutexValue) + m := threadLocal.Get() delete(m, s.mutexKey) s.RWMutex.Unlock() } func (s *syncRWMutex) RLock() { - m := threadLocal.Get().(map[mutexKey]mutexValue) + m := threadLocal.Get() checkMutex(m, s.mutexKey) v := mutexValue{} _, v.file, v.line, _ = runtime.Caller(1) @@ -174,13 +174,13 @@ func (s *syncRWMutex) RLock() { } func (s *syncRWMutex) RUnlock() { - m := threadLocal.Get().(map[mutexKey]mutexValue) + m := threadLocal.Get() delete(m, s.mutexKey) s.RWMutex.RUnlock() } func (s *syncMutex) Lock() { - m := threadLocal.Get().(map[mutexKey]mutexValue) + m := threadLocal.Get() checkMutex(m, s.mutexKey) v := mutexValue{} _, v.file, v.line, _ = runtime.Caller(1) @@ -189,7 +189,7 @@ func (s *syncMutex) Lock() { } func (s *syncMutex) Unlock() { - m := threadLocal.Get().(map[mutexKey]mutexValue) + m := threadLocal.Get() delete(m, s.mutexKey) s.Mutex.Unlock() }