diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-05-20 03:24:14 +0200 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2018-05-20 03:24:14 +0200 |
commit | e04f9543c011b67d81b85f97743dc9701ec446dc (patch) | |
tree | df62dc094eddd4e7fff9fcca1ec99fce868d042d /send.go | |
parent | fa003b6933b07bdf87a541114ba8fe694329e2b2 (diff) |
Fix race in packetInNonceQueueIsAwaitingKey
Diffstat (limited to 'send.go')
-rw-r--r-- | send.go | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -108,7 +108,7 @@ func addToEncryptionQueue( /* Queues a keepalive if no packets are queued for peer */ func (peer *Peer) SendKeepalive() bool { - if len(peer.queue.nonce) != 0 || peer.queue.packetInNonceQueueIsAwaitingKey || !peer.isRunning.Get() { + if len(peer.queue.nonce) != 0 || peer.queue.packetInNonceQueueIsAwaitingKey.Get() || !peer.isRunning.Get() { return false } elem := peer.device.NewOutboundElement() @@ -304,7 +304,7 @@ func (device *Device) RoutineReadFromTUN() { // insert into nonce/pre-handshake queue if peer.isRunning.Get() { - if peer.queue.packetInNonceQueueIsAwaitingKey { + if peer.queue.packetInNonceQueueIsAwaitingKey.Get() { peer.SendHandshakeInitiation(false) } addToOutboundQueue(peer.queue.nonce, elem) @@ -334,7 +334,7 @@ func (peer *Peer) RoutineNonce() { defer func() { logDebug.Println(peer, ": Routine: nonce worker - stopped") - peer.queue.packetInNonceQueueIsAwaitingKey = false + peer.queue.packetInNonceQueueIsAwaitingKey.Set(false) peer.routines.stopping.Done() }() @@ -353,7 +353,7 @@ func (peer *Peer) RoutineNonce() { for { NextPacket: - peer.queue.packetInNonceQueueIsAwaitingKey = false + peer.queue.packetInNonceQueueIsAwaitingKey.Set(false) select { case <-peer.routines.stop: @@ -381,7 +381,7 @@ func (peer *Peer) RoutineNonce() { break } } - peer.queue.packetInNonceQueueIsAwaitingKey = true + peer.queue.packetInNonceQueueIsAwaitingKey.Set(true) // no suitable key pair, request for new handshake @@ -408,7 +408,7 @@ func (peer *Peer) RoutineNonce() { return } } - peer.queue.packetInNonceQueueIsAwaitingKey = false + peer.queue.packetInNonceQueueIsAwaitingKey.Set(false) // populate work element |