mirror of
https://github.com/slackhq/nebula.git
synced 2024-09-20 14:56:12 +08:00
more
This commit is contained in:
parent
94dd14c1a3
commit
1be8dc43a7
|
@ -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,
|
||||
|
|
|
@ -5,7 +5,6 @@ import (
|
|||
"net"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"github.com/miekg/dns"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
@ -20,13 +19,14 @@ 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{
|
||||
syncRWMutex: newSyncRWMutex("dns-records"),
|
||||
dnsMap: make(map[string]string),
|
||||
hostMap: hostMap,
|
||||
}
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -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"},
|
||||
|
|
|
@ -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),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue