@@ -581,12 +581,12 @@ func (peer *Peer) BeginSymmetricSession() error {
581581 defer keypairs .Unlock ()
582582
583583 previous := keypairs .previous
584- next := keypairs .next . Load ()
584+ next := keypairs .next
585585 current := keypairs .current
586586
587587 if isInitiator {
588588 if next != nil {
589- keypairs .next . Store ( nil )
589+ keypairs .next = nil
590590 keypairs .previous = next
591591 device .DeleteKeypair (current )
592592 } else {
@@ -595,7 +595,7 @@ func (peer *Peer) BeginSymmetricSession() error {
595595 device .DeleteKeypair (previous )
596596 keypairs .current = keypair
597597 } else {
598- keypairs .next . Store ( keypair )
598+ keypairs .next = keypair
599599 device .DeleteKeypair (next )
600600 keypairs .previous = nil
601601 device .DeleteKeypair (previous )
@@ -607,18 +607,15 @@ func (peer *Peer) BeginSymmetricSession() error {
607607func (peer * Peer ) ReceivedWithKeypair (receivedKeypair * Keypair ) bool {
608608 keypairs := & peer .keypairs
609609
610- if keypairs .next .Load () != receivedKeypair {
611- return false
612- }
613610 keypairs .Lock ()
614611 defer keypairs .Unlock ()
615- if keypairs .next . Load () != receivedKeypair {
612+ if keypairs .next != receivedKeypair {
616613 return false
617614 }
618615 old := keypairs .previous
619616 keypairs .previous = keypairs .current
620617 peer .device .DeleteKeypair (old )
621- keypairs .current = keypairs .next . Load ()
622- keypairs .next . Store ( nil )
618+ keypairs .current = keypairs .next
619+ keypairs .next = nil
623620 return true
624621}
0 commit comments