diff --git a/connection_manager.go b/connection_manager.go index 8b52764..88ba86c 100644 --- a/connection_manager.go +++ b/connection_manager.go @@ -64,7 +64,7 @@ func newConnectionManager(ctx context.Context, l *logrus.Logger, intf *Interface outLock: newSyncRWMutex("connection-manager-out"), relayUsed: make(map[uint32]struct{}), relayUsedLock: newSyncRWMutex("connection-manager-relay-used"), - trafficTimer: NewLockingTimerWheel[uint32](time.Millisecond*500, max), + trafficTimer: NewLockingTimerWheel[uint32]("connection-manager-timer", time.Millisecond*500, max), intf: intf, pendingDeletion: make(map[uint32]struct{}), checkInterval: checkInterval, diff --git a/dns_server.go b/dns_server.go index 3109b4c..6b1bd70 100644 --- a/dns_server.go +++ b/dns_server.go @@ -5,7 +5,6 @@ import ( "net" "strconv" "strings" - "sync" "github.com/miekg/dns" "github.com/sirupsen/logrus" @@ -20,15 +19,16 @@ var dnsServer *dns.Server var dnsAddr string type dnsRecords struct { - sync.RWMutex + syncRWMutex dnsMap map[string]string hostMap *HostMap } func newDnsRecords(hostMap *HostMap) *dnsRecords { return &dnsRecords{ - dnsMap: make(map[string]string), - hostMap: hostMap, + syncRWMutex: newSyncRWMutex("dns-records"), + dnsMap: make(map[string]string), + hostMap: hostMap, } } diff --git a/handshake_manager.go b/handshake_manager.go index 2e6bcbd..5d76ec9 100644 --- a/handshake_manager.go +++ b/handshake_manager.go @@ -110,7 +110,7 @@ func NewHandshakeManager(l *logrus.Logger, mainHostMap *HostMap, lightHouse *Lig outside: outside, config: config, trigger: make(chan iputil.VpnIp, config.triggerBuffer), - OutboundHandshakeTimer: NewLockingTimerWheel[iputil.VpnIp](config.tryInterval, hsTimeout(config.retries, config.tryInterval)), + OutboundHandshakeTimer: NewLockingTimerWheel[iputil.VpnIp]("handshake-manager-timer", config.tryInterval, hsTimeout(config.retries, config.tryInterval)), messageMetrics: config.messageMetrics, metricInitiated: metrics.GetOrRegisterCounter("handshake_manager.initiated", nil), metricTimedOut: metrics.GetOrRegisterCounter("handshake_manager.timed_out", nil), diff --git a/mutex_debug.go b/mutex_debug.go index 7ba9667..2fc6eb7 100644 --- a/mutex_debug.go +++ b/mutex_debug.go @@ -21,9 +21,11 @@ var allowedConcurrentLocks = map[mutexKey][]mutexKey{ "connection-manager-in": {"hostmap"}, "connection-manager-out": {"connection-state-write", "connection-manager-in"}, "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": {"handshake-manager"}, "relay-state": {"hostmap", "connection-manager-relay-used"}, diff --git a/timeout.go b/timeout.go index c1b4c39..705e58f 100644 --- a/timeout.go +++ b/timeout.go @@ -1,7 +1,6 @@ package nebula import ( - "sync" "time" ) @@ -34,7 +33,7 @@ type TimerWheel[T any] struct { } type LockingTimerWheel[T any] struct { - m sync.Mutex + m syncMutex t *TimerWheel[T] } @@ -81,8 +80,9 @@ func NewTimerWheel[T any](min, max time.Duration) *TimerWheel[T] { } // NewLockingTimerWheel is version of TimerWheel that is safe for concurrent use with a small performance penalty -func NewLockingTimerWheel[T any](min, max time.Duration) *LockingTimerWheel[T] { +func NewLockingTimerWheel[T any](name string, min, max time.Duration) *LockingTimerWheel[T] { return &LockingTimerWheel[T]{ + m: newSyncMutex(name), t: NewTimerWheel[T](min, max), } }