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

Merge pull request #842 from Arceliar/mutex

Fix incorrect mutex use in ipv6rwc
This commit is contained in:
Arceliar 2021-09-24 04:43:44 -05:00 committed by GitHub
commit 6af9b61b15
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 27 additions and 7 deletions

View File

@ -1,3 +1,4 @@
//go:build debug
// +build debug // +build debug
package core package core

View File

@ -1,3 +1,4 @@
//go:build darwin
// +build darwin // +build darwin
package core package core

View File

@ -1,3 +1,4 @@
//go:build linux
// +build linux // +build linux
package core package core

View File

@ -1,3 +1,4 @@
//go:build !darwin && !linux
// +build !darwin,!linux // +build !darwin,!linux
package core package core

View File

@ -1,3 +1,4 @@
//go:build darwin
// +build darwin // +build darwin
package defaults package defaults

View File

@ -1,3 +1,4 @@
//go:build freebsd
// +build freebsd // +build freebsd
package defaults package defaults

View File

@ -1,3 +1,4 @@
//go:build linux
// +build linux // +build linux
package defaults package defaults

View File

@ -1,3 +1,4 @@
//go:build openbsd
// +build openbsd // +build openbsd
package defaults package defaults

View File

@ -1,3 +1,4 @@
//go:build !linux && !darwin && !windows && !openbsd && !freebsd
// +build !linux,!darwin,!windows,!openbsd,!freebsd // +build !linux,!darwin,!windows,!openbsd,!freebsd
package defaults package defaults

View File

@ -1,3 +1,4 @@
//go:build windows
// +build windows // +build windows
package defaults package defaults

View File

@ -132,6 +132,7 @@ func (k *keyStore) update(key ed25519.PublicKey) *keyInfo {
var kArray keyArray var kArray keyArray
copy(kArray[:], key) copy(kArray[:], key)
var info *keyInfo var info *keyInfo
var packets [][]byte
if info = k.keyToInfo[kArray]; info == nil { if info = k.keyToInfo[kArray]; info == nil {
info = new(keyInfo) info = new(keyInfo)
info.key = kArray info.key = kArray
@ -140,19 +141,19 @@ func (k *keyStore) update(key ed25519.PublicKey) *keyInfo {
k.keyToInfo[info.key] = info k.keyToInfo[info.key] = info
k.addrToInfo[info.address] = info k.addrToInfo[info.address] = info
k.subnetToInfo[info.subnet] = info k.subnetToInfo[info.subnet] = info
k.resetTimeout(info)
k.mutex.Unlock()
if buf := k.addrBuffer[info.address]; buf != nil { if buf := k.addrBuffer[info.address]; buf != nil {
k.core.WriteTo(buf.packet, iwt.Addr(info.key[:])) packets = append(packets, buf.packet)
delete(k.addrBuffer, info.address) delete(k.addrBuffer, info.address)
} }
if buf := k.subnetBuffer[info.subnet]; buf != nil { if buf := k.subnetBuffer[info.subnet]; buf != nil {
k.core.WriteTo(buf.packet, iwt.Addr(info.key[:])) packets = append(packets, buf.packet)
delete(k.subnetBuffer, info.subnet) delete(k.subnetBuffer, info.subnet)
} }
} else { }
k.resetTimeout(info) k.resetTimeout(info)
k.mutex.Unlock() k.mutex.Unlock()
for _, packet := range packets {
k.core.WriteTo(packet, iwt.Addr(info.key[:]))
} }
return info return info
} }

View File

@ -1,3 +1,4 @@
//go:build darwin
// +build darwin // +build darwin
package multicast package multicast

View File

@ -1,3 +1,4 @@
//go:build !linux && !darwin && !netbsd && !freebsd && !openbsd && !dragonflybsd && !windows
// +build !linux,!darwin,!netbsd,!freebsd,!openbsd,!dragonflybsd,!windows // +build !linux,!darwin,!netbsd,!freebsd,!openbsd,!dragonflybsd,!windows
package multicast package multicast

View File

@ -1,3 +1,4 @@
//go:build linux || netbsd || freebsd || openbsd || dragonflybsd
// +build linux netbsd freebsd openbsd dragonflybsd // +build linux netbsd freebsd openbsd dragonflybsd
package multicast package multicast

View File

@ -1,3 +1,4 @@
//go:build windows
// +build windows // +build windows
package multicast package multicast

View File

@ -1,3 +1,4 @@
//go:build openbsd || freebsd
// +build openbsd freebsd // +build openbsd freebsd
package tuntap package tuntap

View File

@ -1,3 +1,4 @@
//go:build !mobile
// +build !mobile // +build !mobile
package tuntap package tuntap

View File

@ -1,3 +1,4 @@
//go:build !mobile
// +build !mobile // +build !mobile
package tuntap package tuntap

View File

@ -1,3 +1,4 @@
//go:build !linux && !darwin && !windows && !openbsd && !freebsd && !mobile
// +build !linux,!darwin,!windows,!openbsd,!freebsd,!mobile // +build !linux,!darwin,!windows,!openbsd,!freebsd,!mobile
package tuntap package tuntap

View File

@ -1,3 +1,4 @@
//go:build windows
// +build windows // +build windows
package tuntap package tuntap