5
0
mirror of https://github.com/cwinfo/yggdrasil-go.git synced 2024-11-22 21:10:29 +00:00

Use mutex in switch/tcp init

This commit is contained in:
Neil Alexander 2018-12-29 19:53:31 +00:00
parent fa7c4117b4
commit 2925920c70
No known key found for this signature in database
GPG Key ID: A02A2019A2BB0944
2 changed files with 4 additions and 0 deletions

View File

@ -186,7 +186,9 @@ func (t *switchTable) init(core *Core) {
now := time.Now()
t.core = core
t.reconfigure = make(chan bool, 1)
t.core.configMutex.RLock()
t.key = t.core.sigPub
t.core.configMutex.RUnlock()
locator := switchLocator{root: t.key, tstamp: now.Unix()}
peers := make(map[switchPort]peerInfo)
t.data = switchData{locator: locator, peers: peers}

View File

@ -83,8 +83,10 @@ func (iface *tcpInterface) connectSOCKS(socksaddr, peeraddr string) {
// Initializes the struct.
func (iface *tcpInterface) init(core *Core) (err error) {
iface.core = core
iface.core.configMutex.RLock()
iface.tcp_addr = iface.core.config.Listen
iface.tcp_timeout = time.Duration(iface.core.config.ReadTimeout) * time.Millisecond
iface.core.configMutex.RUnlock()
if iface.tcp_timeout >= 0 && iface.tcp_timeout < default_tcp_timeout {
iface.tcp_timeout = default_tcp_timeout
}