@@ -581,12 +581,12 @@ func (peer *Peer) BeginSymmetricSession() error {
581
581
defer keypairs .Unlock ()
582
582
583
583
previous := keypairs .previous
584
- next := keypairs .next . Load ()
584
+ next := keypairs .next
585
585
current := keypairs .current
586
586
587
587
if isInitiator {
588
588
if next != nil {
589
- keypairs .next . Store ( nil )
589
+ keypairs .next = nil
590
590
keypairs .previous = next
591
591
device .DeleteKeypair (current )
592
592
} else {
@@ -595,7 +595,7 @@ func (peer *Peer) BeginSymmetricSession() error {
595
595
device .DeleteKeypair (previous )
596
596
keypairs .current = keypair
597
597
} else {
598
- keypairs .next . Store ( keypair )
598
+ keypairs .next = keypair
599
599
device .DeleteKeypair (next )
600
600
keypairs .previous = nil
601
601
device .DeleteKeypair (previous )
@@ -607,18 +607,15 @@ func (peer *Peer) BeginSymmetricSession() error {
607
607
func (peer * Peer ) ReceivedWithKeypair (receivedKeypair * Keypair ) bool {
608
608
keypairs := & peer .keypairs
609
609
610
- if keypairs .next .Load () != receivedKeypair {
611
- return false
612
- }
613
610
keypairs .Lock ()
614
611
defer keypairs .Unlock ()
615
- if keypairs .next . Load () != receivedKeypair {
612
+ if keypairs .next != receivedKeypair {
616
613
return false
617
614
}
618
615
old := keypairs .previous
619
616
keypairs .previous = keypairs .current
620
617
peer .device .DeleteKeypair (old )
621
- keypairs .current = keypairs .next . Load ()
622
- keypairs .next . Store ( nil )
618
+ keypairs .current = keypairs .next
619
+ keypairs .next = nil
623
620
return true
624
621
}
0 commit comments