mirror of
https://git.zx2c4.com/wireguard-go
synced 2025-10-05 16:47:02 +08:00
all: use Go 1.19 and its atomic types
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:

committed by
Jason A. Donenfeld

parent
d1d08426b2
commit
b51010ba13
@@ -282,7 +282,7 @@ func (device *Device) ConsumeMessageInitiation(msg *MessageInitiation) *Peer {
|
||||
// lookup peer
|
||||
|
||||
peer := device.LookupPeer(peerPK)
|
||||
if peer == nil || !peer.isRunning.Get() {
|
||||
if peer == nil || !peer.isRunning.Load() {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -581,12 +581,12 @@ func (peer *Peer) BeginSymmetricSession() error {
|
||||
defer keypairs.Unlock()
|
||||
|
||||
previous := keypairs.previous
|
||||
next := keypairs.loadNext()
|
||||
next := keypairs.next.Load()
|
||||
current := keypairs.current
|
||||
|
||||
if isInitiator {
|
||||
if next != nil {
|
||||
keypairs.storeNext(nil)
|
||||
keypairs.next.Store(nil)
|
||||
keypairs.previous = next
|
||||
device.DeleteKeypair(current)
|
||||
} else {
|
||||
@@ -595,7 +595,7 @@ func (peer *Peer) BeginSymmetricSession() error {
|
||||
device.DeleteKeypair(previous)
|
||||
keypairs.current = keypair
|
||||
} else {
|
||||
keypairs.storeNext(keypair)
|
||||
keypairs.next.Store(keypair)
|
||||
device.DeleteKeypair(next)
|
||||
keypairs.previous = nil
|
||||
device.DeleteKeypair(previous)
|
||||
@@ -607,18 +607,18 @@ func (peer *Peer) BeginSymmetricSession() error {
|
||||
func (peer *Peer) ReceivedWithKeypair(receivedKeypair *Keypair) bool {
|
||||
keypairs := &peer.keypairs
|
||||
|
||||
if keypairs.loadNext() != receivedKeypair {
|
||||
if keypairs.next.Load() != receivedKeypair {
|
||||
return false
|
||||
}
|
||||
keypairs.Lock()
|
||||
defer keypairs.Unlock()
|
||||
if keypairs.loadNext() != receivedKeypair {
|
||||
if keypairs.next.Load() != receivedKeypair {
|
||||
return false
|
||||
}
|
||||
old := keypairs.previous
|
||||
keypairs.previous = keypairs.current
|
||||
peer.device.DeleteKeypair(old)
|
||||
keypairs.current = keypairs.loadNext()
|
||||
keypairs.storeNext(nil)
|
||||
keypairs.current = keypairs.next.Load()
|
||||
keypairs.next.Store(nil)
|
||||
return true
|
||||
}
|
||||
|
Reference in New Issue
Block a user