summaryrefslogtreecommitdiffhomepage
path: root/receive.go
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-09-24 01:52:02 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2018-09-24 01:52:02 +0200
commitebc7541953269b39cd73d703166b9b8ee7b34e37 (patch)
tree9f436df296e7fba4a29b4a084d637c304844b7de /receive.go
parent833597b585f460aaa17bad93ad59290ec282e77e (diff)
Fix shutdown races
Diffstat (limited to 'receive.go')
-rw-r--r--receive.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/receive.go b/receive.go
index ab86913..01151ca 100644
--- a/receive.go
+++ b/receive.go
@@ -247,7 +247,6 @@ func (device *Device) RoutineDecryption() {
// check if dropped
if elem.IsDropped() {
- device.PutInboundElement(elem)
continue
}
@@ -281,7 +280,6 @@ func (device *Device) RoutineDecryption() {
if err != nil {
elem.Drop()
device.PutMessageBuffer(elem.buffer)
- elem.buffer = nil
}
elem.mutex.Unlock()
}
@@ -313,6 +311,7 @@ func (device *Device) RoutineHandshake() {
for {
if elem.buffer != nil {
device.PutMessageBuffer(elem.buffer)
+ elem.buffer = nil
}
select {
@@ -494,7 +493,7 @@ func (peer *Peer) RoutineSequentialReceiver() {
logDebug.Println(peer, "- Routine: sequential receiver - stopped")
peer.routines.stopping.Done()
if elem != nil {
- if elem.buffer != nil {
+ if !elem.IsDropped() {
device.PutMessageBuffer(elem.buffer)
}
device.PutInboundElement(elem)
@@ -507,10 +506,11 @@ func (peer *Peer) RoutineSequentialReceiver() {
for {
if elem != nil {
- if elem.buffer != nil {
+ if !elem.IsDropped() {
device.PutMessageBuffer(elem.buffer)
}
device.PutInboundElement(elem)
+ elem = nil
}
select {